|
| 1 | +--- |
| 2 | +description: Complete workflow - branch, commit, push, and create PR with rich context |
| 3 | +--- |
| 4 | + |
| 5 | +# TASK: Commit & Push — Complete Git Workflow |
| 6 | + |
| 7 | +## Task Contract |
| 8 | + |
| 9 | +This section defines **what must be done**, not a mindset. |
| 10 | + |
| 11 | +You are required to execute the full workflow below: |
| 12 | +- Ensure work is on a non-main branch |
| 13 | +- Commit the current changes using the specified commit structure |
| 14 | +- Push the branch to the remote |
| 15 | +- Create a pull request with a complete description |
| 16 | + |
| 17 | +**The task is incomplete until the branch is pushed and a PR exists.** |
| 18 | + |
| 19 | +_Context:_ Every change should tell a story that future agents can understand. |
| 20 | + |
| 21 | +## Execution Procedure |
| 22 | + |
| 23 | +Follow the steps below in order. Do not stop after committing — pushing and PR creation are required. |
| 24 | + |
| 25 | +### 1. Check Current Branch Status |
| 26 | + |
| 27 | +```bash |
| 28 | +git status |
| 29 | +git branch --show-current |
| 30 | +``` |
| 31 | + |
| 32 | +**Decision Point:** |
| 33 | +- If on `main` or `master`: Create a feature branch |
| 34 | +- If on a feature branch: Continue with that branch |
| 35 | +- If uncommitted changes exist: They'll move to the new branch |
| 36 | + |
| 37 | +### 2. Create Feature Branch (if needed) |
| 38 | + |
| 39 | +If on main/master, create a descriptive branch: |
| 40 | + |
| 41 | +```bash |
| 42 | +# Branch naming convention: type/short-description |
| 43 | +# Examples: fix/kiro-timestamps, feat/add-auth, refactor/agent-cli |
| 44 | +git checkout -b <type>/<short-description> |
| 45 | +``` |
| 46 | + |
| 47 | +**Branch Types:** |
| 48 | +- `fix/` - Bug fixes |
| 49 | +- `feat/` - New features |
| 50 | +- `refactor/` - Code restructuring |
| 51 | +- `docs/` - Documentation |
| 52 | +- `chore/` - Maintenance |
| 53 | +- `perf/` - Performance improvements |
| 54 | + |
| 55 | +### 3. Analyze and Stage Changes |
| 56 | + |
| 57 | +```bash |
| 58 | +git status |
| 59 | +git diff |
| 60 | +git add -A # or selectively add files |
| 61 | +git diff --staged |
| 62 | +``` |
| 63 | + |
| 64 | +**Safety Checks:** |
| 65 | +- ⚠️ Check for secrets (.env, API keys, credentials) |
| 66 | +- ⚠️ Verify no unintended files are staged |
| 67 | +- ⚠️ Ensure changes are related and cohesive |
| 68 | + |
| 69 | +### 4. Categorize the Change |
| 70 | + |
| 71 | +| Type | When to Use | Example | |
| 72 | +|------|-------------|---------| |
| 73 | +| `feat` | New functionality | `feat(auth): add JWT refresh token rotation` | |
| 74 | +| `fix` | Bug fix | `fix(api): handle null response in user fetch` | |
| 75 | +| `refactor` | Code restructure | `refactor(db): extract query builder to module` | |
| 76 | +| `docs` | Documentation | `docs(api): add OpenAPI examples` | |
| 77 | +| `test` | Tests | `test(auth): add edge cases for token expiration` | |
| 78 | +| `chore` | Maintenance | `chore(deps): upgrade langfuse to v3.0` | |
| 79 | +| `perf` | Performance | `perf(search): add index for user lookups` | |
| 80 | +| `style` | Formatting | `style: apply ruff formatting` | |
| 81 | + |
| 82 | +### 5. Craft Commit Message |
| 83 | + |
| 84 | +**Format:** |
| 85 | +``` |
| 86 | +type(scope): concise description (imperative mood) |
| 87 | +
|
| 88 | +[Body - 2-4 sentences explaining WHY and CONTEXT] |
| 89 | +
|
| 90 | +Changes: |
| 91 | +- Key change 1 |
| 92 | +- Key change 2 |
| 93 | +
|
| 94 | +Pattern: [Patterns or conventions followed] |
| 95 | +Decision: [Key decisions made] |
| 96 | +Related: [Related files or components] |
| 97 | +``` |
| 98 | + |
| 99 | +**Rules:** |
| 100 | +1. **Subject line:** |
| 101 | + - Imperative mood: "add" not "added" |
| 102 | + - Include scope: `feat(auth)`, `fix(api/users)` |
| 103 | + - Under 72 characters |
| 104 | + - Specific and descriptive |
| 105 | + |
| 106 | +2. **Body:** |
| 107 | + - Explain WHY, not just what |
| 108 | + - Mention patterns established |
| 109 | + - Note non-obvious decisions |
| 110 | + - Reference related components |
| 111 | + |
| 112 | +3. **Context for future agents:** |
| 113 | + - Database locations |
| 114 | + - File patterns followed |
| 115 | + - Architecture decisions |
| 116 | + - Gotchas or edge cases |
| 117 | + |
| 118 | +### 6. Execute Commit |
| 119 | + |
| 120 | +```bash |
| 121 | +git commit -m "$(cat <<'EOF' |
| 122 | +type(scope): description |
| 123 | +
|
| 124 | +Problem or context explaining why this change was needed. |
| 125 | +
|
| 126 | +Changes: |
| 127 | +- Specific change 1 |
| 128 | +- Specific change 2 |
| 129 | +
|
| 130 | +Pattern: Follows existing pattern in path/to/file |
| 131 | +Decision: Chose approach X because Y |
| 132 | +Related: Other files or components affected |
| 133 | +EOF |
| 134 | +)" |
| 135 | +``` |
| 136 | + |
| 137 | +### 7. Push to Remote |
| 138 | + |
| 139 | +```bash |
| 140 | +git push -u origin $(git branch --show-current) |
| 141 | +``` |
| 142 | + |
| 143 | +### 8. Create Pull Request |
| 144 | + |
| 145 | +Use GitHub CLI to create PR with rich description: |
| 146 | + |
| 147 | +```bash |
| 148 | +gh pr create --title "Type: Brief description" --body "$(cat <<'EOF' |
| 149 | +## Problem |
| 150 | +[Describe the issue or need this PR addresses] |
| 151 | +
|
| 152 | +## Solution |
| 153 | +[Explain the approach taken and why] |
| 154 | +
|
| 155 | +## Changes |
| 156 | +- Modified file/component 1 |
| 157 | +- Added feature/fix 2 |
| 158 | +- Updated related component 3 |
| 159 | +
|
| 160 | +## Testing |
| 161 | +[How this was tested or validated] |
| 162 | +
|
| 163 | +## Example Output |
| 164 | +``` |
| 165 | +[Show example of the fix/feature in action if applicable] |
| 166 | +``` |
| 167 | +
|
| 168 | +## Notes |
| 169 | +[Any additional context, gotchas, or follow-up needed] |
| 170 | +EOF |
| 171 | +)" |
| 172 | +``` |
| 173 | + |
| 174 | +**PR Description Template:** |
| 175 | + |
| 176 | +```markdown |
| 177 | +## Problem |
| 178 | +[What issue does this solve? What was broken or missing?] |
| 179 | + |
| 180 | +## Solution |
| 181 | +[High-level approach and key decisions] |
| 182 | + |
| 183 | +## Changes |
| 184 | +- File/component changes |
| 185 | +- New patterns introduced |
| 186 | +- Related updates |
| 187 | + |
| 188 | +## Testing |
| 189 | +[Validation performed] |
| 190 | + |
| 191 | +## Example Output |
| 192 | +[Code examples, screenshots, or output samples] |
| 193 | + |
| 194 | +## Notes |
| 195 | +[Additional context, breaking changes, follow-up items] |
| 196 | +``` |
| 197 | + |
| 198 | +### 9. Required Completion Report |
| 199 | + |
| 200 | +After successful push and PR creation, report: |
| 201 | + |
| 202 | +``` |
| 203 | +✅ Branch: <branch-name> |
| 204 | +✅ Commit: <hash> - <subject> |
| 205 | +✅ Files: <count> files changed (+X, -Y lines) |
| 206 | +✅ Pushed: origin/<branch-name> |
| 207 | +✅ PR: #<number> - <url> |
| 208 | +``` |
| 209 | + |
| 210 | +## Example Workflow |
| 211 | + |
| 212 | +**Scenario:** Fix missing timestamps in Kiro conversation history |
| 213 | + |
| 214 | +```bash |
| 215 | +# 1. Check status |
| 216 | +git status |
| 217 | +git branch --show-current # Returns: main |
| 218 | + |
| 219 | +# 2. Create branch |
| 220 | +git checkout -b fix/kiro-timestamps |
| 221 | + |
| 222 | +# 3. Stage changes |
| 223 | +git add packages/pybackend/kiro_agent_cli.py |
| 224 | + |
| 225 | +# 4. Commit with context |
| 226 | +git commit -m "$(cat <<'EOF' |
| 227 | +fix(kiro): extract timestamps and format tool usage in conversation history |
| 228 | +
|
| 229 | +Kiro CLI stores rich metadata in SQLite that wasn't being parsed, causing |
| 230 | +"Unknown time" timestamps and empty tool messages in MADE chat history export. |
| 231 | +
|
| 232 | +Changes: |
| 233 | +- Extract assistant timestamps from request_metadata.stream_end_timestamp_ms |
| 234 | +- Parse tool_uses array to show tool name and arguments (truncated to 200 chars) |
| 235 | +- Combine assistant explanation text with formatted tool information |
| 236 | +
|
| 237 | +Pattern: Follows existing HistoryMessage structure from agent_results.py |
| 238 | +Database: Kiro stores conversations in ~/.local/share/kiro-cli/data.sqlite3 |
| 239 | +Format: Tool args displayed as "Tool: name\n arg: value" for readability |
| 240 | +
|
| 241 | +Fixes missing timestamps on all assistant messages and provides context |
| 242 | +for tool invocations instead of empty content. |
| 243 | +EOF |
| 244 | +)" |
| 245 | + |
| 246 | +# 5. Push |
| 247 | +git push -u origin fix/kiro-timestamps |
| 248 | + |
| 249 | +# 6. Create PR |
| 250 | +gh pr create --title "Fix: Extract timestamps and format tool usage in Kiro conversation history" --body "$(cat <<'EOF' |
| 251 | +## Problem |
| 252 | +Chat history export from Kiro CLI showed: |
| 253 | +- Missing timestamps ("Unknown time") on assistant messages |
| 254 | +- Empty/minimal content for tool usage messages |
| 255 | +
|
| 256 | +## Solution |
| 257 | +Extract rich metadata from Kiro's SQLite database: |
| 258 | +- Parse `request_metadata.stream_end_timestamp_ms` for timestamps |
| 259 | +- Format `tool_uses` array with tool name and arguments |
| 260 | +- Truncate long arguments to 200 chars for readability |
| 261 | +
|
| 262 | +## Changes |
| 263 | +- Modified `packages/pybackend/kiro_agent_cli.py` |
| 264 | +- Updated `_parse_conversation_history()` method |
| 265 | +
|
| 266 | +## Testing |
| 267 | +Validated against conversation `b7cd2f67-ee9e-40db-a244-8cbdbf719630`: |
| 268 | +- All 28 messages now have proper timestamps |
| 269 | +- Tool invocations show formatted tool info |
| 270 | +
|
| 271 | +## Example Output |
| 272 | +``` |
| 273 | +Tool: execute_bash |
| 274 | + command: git checkout main && git pull |
| 275 | + summary: Switch to main branch and pull latest changes |
| 276 | +``` |
| 277 | +
|
| 278 | +Fixes missing timestamps and provides context for tool invocations in chat history export. |
| 279 | +EOF |
| 280 | +)" |
| 281 | +``` |
| 282 | + |
| 283 | +## Safety Checks |
| 284 | + |
| 285 | +- ⚠️ **Never commit to main/master directly** without explicit user confirmation |
| 286 | +- ⚠️ **Check for secrets** in staged files (.env, API keys, passwords) |
| 287 | +- ⚠️ **Verify branch name** is descriptive and follows convention |
| 288 | +- ⚠️ **Review diff** before committing to catch unintended changes |
| 289 | +- ⚠️ **Test locally** if possible before pushing |
| 290 | + |
| 291 | +## Output Format |
| 292 | + |
| 293 | +After completion, provide: |
| 294 | + |
| 295 | +``` |
| 296 | +✅ **Workflow Complete** |
| 297 | +
|
| 298 | +**Branch:** fix/kiro-timestamps |
| 299 | +**Commit:** 5784230 - fix(kiro): extract timestamps and format tool usage |
| 300 | +**Files Changed:** 1 file (+26, -6 lines) |
| 301 | +**Pushed:** origin/fix/kiro-timestamps |
| 302 | +**PR:** #165 - https://github.com/user/repo/pull/165 |
| 303 | +
|
| 304 | +The changes are ready for review. |
| 305 | +``` |
0 commit comments