# Implementation Checklist

Use this checklist to track your progress implementing the pipeline deployment integration.

## Pre-Implementation

- [ ] Review `README.md` to understand the architecture
- [ ] Review `INTEGRATION-SUMMARY.md` for overview
- [ ] Ensure you have access to all required repositories
- [ ] Verify you have kubectl access to tbi-agent namespace
- [ ] Confirm GitHub token has repo access
- [ ] Confirm Anthropic API key is available

## Phase 1: Workspace Setup (5 minutes)

- [ ] Open Kiro IDE with tbi-devops-environments workspace
- [ ] Add tbi-devops-mgt as workspace folder
  - [ ] Command Palette → "Workspaces: Add Folder to Workspace"
  - [ ] Navigate to `/Users/iakpabio/Desktop/git-code/tbi-code/tbi-devops-mgt`
  - [ ] Click "Add"
- [ ] Verify both folders visible in workspace explorer
- [ ] Verify Kiro can read files from tbi-devops-mgt

## Phase 2: Code Integration (15 minutes)

### Copy Module
- [ ] Copy `pipeline-deployer.js` to tbi-devops-mgt/src/
  ```bash
  cp integration/tbi-agent-pipeline-integration/code-updates/pipeline-deployer.js \
     /Users/iakpabio/Desktop/git-code/tbi-code/tbi-devops-mgt/src/
  ```
- [ ] Verify file exists in target location

### Install Dependencies
- [ ] Navigate to tbi-devops-mgt/src/
  ```bash
  cd /Users/iakpabio/Desktop/git-code/tbi-code/tbi-devops-mgt/src/
  ```
- [ ] Install new dependencies
  ```bash
  npm install simple-git js-yaml
  ```
- [ ] Verify installation successful
  ```bash
  npm list simple-git js-yaml
  ```

### Update devops-agent.js
- [ ] Open `/Users/iakpabio/Desktop/git-code/tbi-code/tbi-devops-mgt/src/devops-agent.js`
- [ ] Add import at top:
  ```javascript
  const PipelineDeployer = require('./pipeline-deployer');
  ```
- [ ] Add to constructor:
  ```javascript
  this.pipelineDeployer = new PipelineDeployer({
    anthropicApiKey: process.env.ANTHROPIC_API_KEY,
    devopsEnvironmentsRepo: process.env.TBI_DEVOPS_ENVIRONMENTS_REPO,
    environmentsRepo: process.env.TBI_ENVIRONMENTS_REPO
  });
  ```
- [ ] Add to initialize method:
  ```javascript
  await this.pipelineDeployer.initialize();
  ```
- [ ] Add command handler in message processing:
  ```javascript
  if (command === 'create' && subCommand === 'pipeline') {
    return await this.handleCreatePipeline(context, args);
  }
  ```
- [ ] Copy `handleCreatePipeline` method from `code-updates/devops-agent-updates.js`
- [ ] Copy `parseOptions` helper method
- [ ] Update help command to include pipeline commands
- [ ] Save file

### Update package.json
- [ ] Open `/Users/iakpabio/Desktop/git-code/tbi-code/tbi-devops-mgt/src/package.json`
- [ ] Verify dependencies added:
  ```json
  "simple-git": "^3.22.0",
  "js-yaml": "^4.1.0"
  ```
- [ ] Save file

### Test Locally (Optional)
- [ ] Run linter: `npm run lint`
- [ ] Run tests: `npm test` (if tests exist)
- [ ] Fix any errors

## Phase 3: Kubernetes Configuration (10 minutes)

### Create ConfigMaps
- [ ] Navigate to tbi-devops-common
  ```bash
  cd /Users/iakpabio/Desktop/git-code/tbi-code/tbi-devops-common/app/monitor/apps/tbi-agent/
  ```
- [ ] Create system prompt ConfigMap
  ```bash
  kubectl create configmap tbi-agent-pipeline-config \
    --from-file=system-prompt.txt=/Users/iakpabio/Desktop/git-code/tbi-code/tbi-devops-environments/integration/tbi-agent-pipeline-integration/k8s-configmaps/system-prompt.txt \
    -n tbi-agent --dry-run=client -o yaml > configmap-pipeline-config.yaml
  ```
- [ ] Create templates ConfigMap
  ```bash
  kubectl create configmap tbi-agent-pipeline-templates \
    --from-file=/Users/iakpabio/Desktop/git-code/tbi-code/tbi-devops-environments/integration/tbi-agent-pipeline-integration/k8s-configmaps/templates/ \
    -n tbi-agent --dry-run=client -o yaml > configmap-pipeline-templates.yaml
  ```
- [ ] Verify ConfigMap files created
  ```bash
  ls -la configmap-*.yaml
  ```

### Update Deployment Manifest
- [ ] Open `deployment.yaml`
- [ ] Add volumes section:
  ```yaml
  volumes:
    - name: pipeline-config
      configMap:
        name: tbi-agent-pipeline-config
    - name: pipeline-templates
      configMap:
        name: tbi-agent-pipeline-templates
  ```
- [ ] Add volume mounts to container:
  ```yaml
  volumeMounts:
    - name: pipeline-config
      mountPath: /app/config
    - name: pipeline-templates
      mountPath: /app/templates
  ```
- [ ] Add environment variables:
  ```yaml
  env:
    - name: TBI_DEVOPS_ENVIRONMENTS_REPO
      value: "git@github.com:travelbrands/tbi-devops-environments.git"
    - name: TBI_ENVIRONMENTS_REPO
      value: "git@github.com:travelbrands/tbi-environments.git"
    - name: GITHUB_TOKEN
      valueFrom:
        secretKeyRef:
          name: tbi-agent-secrets
          key: github-token
  ```
- [ ] Save file

### Update Secrets (if needed)
- [ ] Check if GitHub token exists in secret
  ```bash
  kubectl get secret tbi-agent-secrets -n tbi-agent -o yaml
  ```
- [ ] If needed, update secret with GitHub token
  ```bash
  kubectl create secret generic tbi-agent-secrets \
    --from-literal=github-token=<your-token> \
    --from-literal=anthropic-api-key=<your-key> \
    -n tbi-agent --dry-run=client -o yaml | kubectl apply -f -
  ```

## Phase 4: Deployment (10 minutes)

### Commit Changes
- [ ] Navigate to tbi-devops-mgt
  ```bash
  cd /Users/iakpabio/Desktop/git-code/tbi-code/tbi-devops-mgt
  ```
- [ ] Check status
  ```bash
  git status
  ```
- [ ] Add changes
  ```bash
  git add src/
  ```
- [ ] Commit
  ```bash
  git commit -m "Add pipeline deployment capabilities"
  ```
- [ ] Push
  ```bash
  git push
  ```

### Commit Kubernetes Changes
- [ ] Navigate to tbi-devops-common
  ```bash
  cd /Users/iakpabio/Desktop/git-code/tbi-code/tbi-devops-common
  ```
- [ ] Check status
  ```bash
  git status
  ```
- [ ] Add changes
  ```bash
  git add app/monitor/apps/tbi-agent/
  ```
- [ ] Commit
  ```bash
  git commit -m "Add pipeline deployment ConfigMaps and update deployment"
  ```
- [ ] Push
  ```bash
  git push
  ```

### Deploy via ArgoCD
- [ ] Wait for ArgoCD to detect changes (usually < 3 minutes)
- [ ] Check ArgoCD sync status
- [ ] If needed, manually sync in ArgoCD UI

### Verify Deployment
- [ ] Check pod status
  ```bash
  kubectl get pods -n tbi-agent
  ```
- [ ] Check pod logs
  ```bash
  kubectl logs -n tbi-agent -l app=tbi-agent --tail=50
  ```
- [ ] Look for "Pipeline deployer initialized" message
- [ ] Check ConfigMaps mounted
  ```bash
  kubectl describe pod -n tbi-agent -l app=tbi-agent | grep -A 5 "Mounts:"
  ```

## Phase 5: Testing (15 minutes)

### Basic Test
- [ ] Open Microsoft Teams
- [ ] Send test command:
  ```
  @tbi-agent create pipeline tbi-test-service redtag nodejs
  ```
- [ ] Wait for response (30-60 seconds)
- [ ] Verify success message received
- [ ] Check files created in tbi-devops-environments
- [ ] Check files created in tbi-environments

### Verify Generated Files
- [ ] Navigate to tbi-devops-environments
  ```bash
  cd /Users/iakpabio/Desktop/git-code/tbi-code/tbi-devops-environments
  ```
- [ ] Pull latest changes
  ```bash
  git pull
  ```
- [ ] Check service directory exists
  ```bash
  ls -la dev/tbi-test-service/
  ```
- [ ] Verify all files created:
  - [ ] `.circleci/config.yml`
  - [ ] `docker/Dockerfile`
  - [ ] `scripts/deploy-services.sh`
  - [ ] `scripts/setup-kubectl.sh`
  - [ ] `charts/tbi-test-service/`

### Verify Environment Files
- [ ] Navigate to tbi-environments
  ```bash
  cd /Users/iakpabio/Desktop/git-code/tbi-code/tbi-environments
  ```
- [ ] Pull latest changes
  ```bash
  git pull
  ```
- [ ] Check values file
  ```bash
  cat dev/values/tbi-test-service.yaml
  ```
- [ ] Check secrets file
  ```bash
  cat dev/secrets/secrets.tbi-test-service.yaml
  ```
- [ ] Check requirements.yaml updated
  ```bash
  grep tbi-test-service dev/requirements.yaml
  ```

### Error Handling Test
- [ ] Test with invalid namespace:
  ```
  @tbi-agent create pipeline test-service invalid-namespace nodejs
  ```
- [ ] Verify error message received
- [ ] Test with missing parameters:
  ```
  @tbi-agent create pipeline test-service
  ```
- [ ] Verify error message received

### Help Command Test
- [ ] Test help command:
  ```
  @tbi-agent pipeline help
  ```
- [ ] Verify help text displayed

## Phase 6: Documentation (5 minutes)

- [ ] Update team documentation with new capability
- [ ] Share Teams command examples with team
- [ ] Document any issues encountered
- [ ] Create runbook for troubleshooting

## Post-Implementation

### Monitoring (First Week)
- [ ] Monitor pod logs daily
- [ ] Track success rate of pipeline creations
- [ ] Collect feedback from team
- [ ] Document any issues

### Optimization (First Month)
- [ ] Review generated pipelines for quality
- [ ] Identify common patterns
- [ ] Update templates if needed
- [ ] Add more tech stack support

### Enhancements (Ongoing)
- [ ] Add pipeline status command
- [ ] Add list pipelines command
- [ ] Add update pipeline command
- [ ] Add validation before creation
- [ ] Add rollback capability
- [ ] Integrate with CircleCI API
- [ ] Add cost estimation
- [ ] Add security scanning

## Rollback Plan (If Needed)

If something goes wrong:

- [ ] Revert tbi-devops-mgt changes
  ```bash
  cd /Users/iakpabio/Desktop/git-code/tbi-code/tbi-devops-mgt
  git revert HEAD
  git push
  ```
- [ ] Revert tbi-devops-common changes
  ```bash
  cd /Users/iakpabio/Desktop/git-code/tbi-code/tbi-devops-common
  git revert HEAD
  git push
  ```
- [ ] Delete ConfigMaps
  ```bash
  kubectl delete configmap tbi-agent-pipeline-config -n tbi-agent
  kubectl delete configmap tbi-agent-pipeline-templates -n tbi-agent
  ```
- [ ] Wait for ArgoCD to sync
- [ ] Verify pod returns to previous state

## Success Criteria

- [x] All code changes committed and pushed
- [x] ConfigMaps created and applied
- [x] Deployment updated and synced
- [x] Pod running without errors
- [x] Test command successful
- [x] Files generated correctly
- [x] Team notified of new capability

## Notes

Use this space to track issues, decisions, or observations:

```
Date: ___________
Notes:




```

---

**Estimated Total Time**: 1-1.5 hours

**Difficulty**: Medium

**Risk Level**: Low (can be rolled back easily)

**Impact**: High (enables fast pipeline creation for all services)
