rafcode 2.3.0 → 2.4.1-0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (129) hide show
  1. package/.claude/settings.local.json +3 -1
  2. package/CLAUDE.md +21 -4
  3. package/RAF/ahvrih-rate-forge/decisions.md +70 -0
  4. package/RAF/ahvrih-rate-forge/input.md +44 -0
  5. package/RAF/ahvrih-rate-forge/outcomes/01-remove-claude-command-config.md +58 -0
  6. package/RAF/ahvrih-rate-forge/outcomes/02-fix-mixed-attempt-cost.md +46 -0
  7. package/RAF/ahvrih-rate-forge/outcomes/03-rate-limit-estimation.md +82 -0
  8. package/RAF/ahvrih-rate-forge/outcomes/04-show-version-in-do-logs.md +45 -0
  9. package/RAF/ahvrih-rate-forge/outcomes/05-sync-main-before-worktree.md +96 -0
  10. package/RAF/ahvrih-rate-forge/outcomes/06-sync-readme-with-codebase.md +45 -0
  11. package/RAF/ahvrih-rate-forge/outcomes/07-no-session-persistence.md +26 -0
  12. package/RAF/ahvrih-rate-forge/outcomes/08-plan-execution-metadata.md +130 -0
  13. package/RAF/ahvrih-rate-forge/plans/01-remove-claude-command-config.md +36 -0
  14. package/RAF/ahvrih-rate-forge/plans/02-fix-mixed-attempt-cost.md +33 -0
  15. package/RAF/ahvrih-rate-forge/plans/03-rate-limit-estimation.md +82 -0
  16. package/RAF/ahvrih-rate-forge/plans/04-show-version-in-do-logs.md +32 -0
  17. package/RAF/ahvrih-rate-forge/plans/05-sync-main-before-worktree.md +40 -0
  18. package/RAF/ahvrih-rate-forge/plans/06-sync-readme-with-codebase.md +61 -0
  19. package/RAF/ahvrih-rate-forge/plans/07-no-session-persistence.md +28 -0
  20. package/RAF/ahvrih-rate-forge/plans/08-plan-execution-metadata.md +123 -0
  21. package/RAF/ahwidh-quick-fix-gremlin/decisions.md +37 -0
  22. package/RAF/ahwidh-quick-fix-gremlin/input.md +35 -0
  23. package/RAF/ahwidh-quick-fix-gremlin/outcomes/01-fix-name-generation-prompt.md +33 -0
  24. package/RAF/ahwidh-quick-fix-gremlin/outcomes/02-fix-amend-commit-scope.md +43 -0
  25. package/RAF/ahwidh-quick-fix-gremlin/outcomes/03-fix-diverged-main-branch-sync.md +32 -0
  26. package/RAF/ahwidh-quick-fix-gremlin/outcomes/04-wire-rate-limit-to-do-command.md +61 -0
  27. package/RAF/ahwidh-quick-fix-gremlin/outcomes/05-add-config-get-set-flags.md +125 -0
  28. package/RAF/ahwidh-quick-fix-gremlin/outcomes/06-sync-worktree-branch-before-execution.md +96 -0
  29. package/RAF/ahwidh-quick-fix-gremlin/outcomes/07-update-frontmatter-format.md +107 -0
  30. package/RAF/ahwidh-quick-fix-gremlin/outcomes/08-remove-plan-token-report.md +76 -0
  31. package/RAF/ahwidh-quick-fix-gremlin/plans/01-fix-name-generation-prompt.md +52 -0
  32. package/RAF/ahwidh-quick-fix-gremlin/plans/02-fix-amend-commit-scope.md +48 -0
  33. package/RAF/ahwidh-quick-fix-gremlin/plans/03-fix-diverged-main-branch-sync.md +49 -0
  34. package/RAF/ahwidh-quick-fix-gremlin/plans/04-wire-rate-limit-to-do-command.md +78 -0
  35. package/RAF/ahwidh-quick-fix-gremlin/plans/05-add-config-get-set-flags.md +101 -0
  36. package/RAF/ahwidh-quick-fix-gremlin/plans/06-sync-worktree-branch-before-execution.md +92 -0
  37. package/RAF/ahwidh-quick-fix-gremlin/plans/07-update-frontmatter-format.md +105 -0
  38. package/RAF/ahwidh-quick-fix-gremlin/plans/08-remove-plan-token-report.md +50 -0
  39. package/README.md +27 -7
  40. package/dist/commands/config.d.ts.map +1 -1
  41. package/dist/commands/config.js +209 -6
  42. package/dist/commands/config.js.map +1 -1
  43. package/dist/commands/do.d.ts.map +1 -1
  44. package/dist/commands/do.js +140 -21
  45. package/dist/commands/do.js.map +1 -1
  46. package/dist/commands/plan.d.ts.map +1 -1
  47. package/dist/commands/plan.js +27 -5
  48. package/dist/commands/plan.js.map +1 -1
  49. package/dist/core/claude-runner.d.ts +0 -6
  50. package/dist/core/claude-runner.d.ts.map +1 -1
  51. package/dist/core/claude-runner.js +4 -9
  52. package/dist/core/claude-runner.js.map +1 -1
  53. package/dist/core/failure-analyzer.d.ts.map +1 -1
  54. package/dist/core/failure-analyzer.js +3 -3
  55. package/dist/core/failure-analyzer.js.map +1 -1
  56. package/dist/core/pull-request.js +3 -3
  57. package/dist/core/pull-request.js.map +1 -1
  58. package/dist/core/state-derivation.d.ts +5 -0
  59. package/dist/core/state-derivation.d.ts.map +1 -1
  60. package/dist/core/state-derivation.js +14 -4
  61. package/dist/core/state-derivation.js.map +1 -1
  62. package/dist/core/worktree.d.ts +44 -0
  63. package/dist/core/worktree.d.ts.map +1 -1
  64. package/dist/core/worktree.js +247 -0
  65. package/dist/core/worktree.js.map +1 -1
  66. package/dist/prompts/amend.d.ts.map +1 -1
  67. package/dist/prompts/amend.js +28 -11
  68. package/dist/prompts/amend.js.map +1 -1
  69. package/dist/prompts/planning.d.ts.map +1 -1
  70. package/dist/prompts/planning.js +28 -11
  71. package/dist/prompts/planning.js.map +1 -1
  72. package/dist/types/config.d.ts +30 -13
  73. package/dist/types/config.d.ts.map +1 -1
  74. package/dist/types/config.js +14 -10
  75. package/dist/types/config.js.map +1 -1
  76. package/dist/utils/config.d.ts +47 -4
  77. package/dist/utils/config.d.ts.map +1 -1
  78. package/dist/utils/config.js +176 -30
  79. package/dist/utils/config.js.map +1 -1
  80. package/dist/utils/frontmatter.d.ts +53 -0
  81. package/dist/utils/frontmatter.d.ts.map +1 -0
  82. package/dist/utils/frontmatter.js +115 -0
  83. package/dist/utils/frontmatter.js.map +1 -0
  84. package/dist/utils/name-generator.d.ts.map +1 -1
  85. package/dist/utils/name-generator.js +9 -19
  86. package/dist/utils/name-generator.js.map +1 -1
  87. package/dist/utils/session-parser.d.ts +44 -0
  88. package/dist/utils/session-parser.d.ts.map +1 -0
  89. package/dist/utils/session-parser.js +122 -0
  90. package/dist/utils/session-parser.js.map +1 -0
  91. package/dist/utils/terminal-symbols.d.ts +22 -3
  92. package/dist/utils/terminal-symbols.d.ts.map +1 -1
  93. package/dist/utils/terminal-symbols.js +52 -18
  94. package/dist/utils/terminal-symbols.js.map +1 -1
  95. package/dist/utils/token-tracker.d.ts +20 -0
  96. package/dist/utils/token-tracker.d.ts.map +1 -1
  97. package/dist/utils/token-tracker.js +57 -2
  98. package/dist/utils/token-tracker.js.map +1 -1
  99. package/package.json +1 -1
  100. package/src/commands/config.ts +242 -7
  101. package/src/commands/do.ts +177 -23
  102. package/src/commands/plan.ts +27 -4
  103. package/src/core/claude-runner.ts +4 -16
  104. package/src/core/failure-analyzer.ts +3 -3
  105. package/src/core/pull-request.ts +3 -3
  106. package/src/core/state-derivation.ts +20 -4
  107. package/src/core/worktree.ts +266 -0
  108. package/src/prompts/amend.ts +28 -11
  109. package/src/prompts/config-docs.md +91 -29
  110. package/src/prompts/planning.ts +28 -11
  111. package/src/types/config.ts +46 -21
  112. package/src/utils/config.ts +200 -33
  113. package/src/utils/frontmatter.ts +140 -0
  114. package/src/utils/name-generator.ts +9 -19
  115. package/src/utils/terminal-symbols.ts +68 -16
  116. package/src/utils/token-tracker.ts +65 -2
  117. package/tests/unit/claude-runner-interactive.test.ts +8 -6
  118. package/tests/unit/claude-runner.test.ts +5 -66
  119. package/tests/unit/commit-planning-artifacts-worktree.test.ts +6 -14
  120. package/tests/unit/commit-planning-artifacts.test.ts +4 -12
  121. package/tests/unit/config-command.test.ts +176 -6
  122. package/tests/unit/config.test.ts +268 -45
  123. package/tests/unit/frontmatter.test.ts +276 -0
  124. package/tests/unit/name-generator.test.ts +1 -1
  125. package/tests/unit/post-execution-picker.test.ts +6 -0
  126. package/tests/unit/terminal-symbols.test.ts +142 -0
  127. package/tests/unit/token-tracker.test.ts +304 -1
  128. package/tests/unit/validation.test.ts +6 -4
  129. package/tests/unit/worktree.test.ts +309 -0
@@ -0,0 +1,35 @@
1
+
2
+ - [ ] add a quick way to see and edit current configuration like 'raf config --get model.plan' (or just get to see whole config, merged with default) and 'raf config --set model.plan sonnet' (support only last level of nesting, can't save whole model object). if get and set flag are present - don't lanuch setting wizard with sonnet (like with --reset)
3
+ - [ ] investigate why token calculation is so low? (example: Tokens: 22 in / 6,861 out). does't it include amend system prompt? my understanding that input tokens are roughly sum of amend system prompt and plan. but plans are usually bigger that 22 tokens. investigate and create task plan to fix if needed
4
+ - [ ] raf commits new plans in "--amend" mode. it should only commit changes in input.md and decisions.md
5
+ - [ ] fix pr comment (PR #5)[src/utils/terminal-symbols.ts](https://github.com/john-veresk/raf/pull/5/files/69f5fab1e125f871ce1356d366195ae34d195830#diff-796b8f7b8ea37125b855e9cb41581303ae65bc9e30693f8d9f91a8eb91554f15)
6
+
7
+ | |
8
+ |---|
9
+ |cost: CostBreakdown,|
10
+ |options: TokenSummaryOptions = {}|
11
+ |): string {|
12
+ |const { showCacheTokens = true, showRateLimitEstimate = false, rateLimitPercentage } = options;|
13
+
14
+  **[![P2 Badge](https://camo.githubusercontent.com/f2c1aacb361ddd3a0e9f9cacdb84fab050de434017f6747bb916e31e29bdf03d/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f50322d79656c6c6f773f7374796c653d666c6174)](https://camo.githubusercontent.com/f2c1aacb361ddd3a0e9f9cacdb84fab050de434017f6747bb916e31e29bdf03d/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f50322d79656c6c6f773f7374796c653d666c6174) Enable rate-limit estimate in default token summaries**
15
+
16
+ The formatter now defaults `showRateLimitEstimate` to `false`, but `raf do` still calls `formatTaskTokenSummary(...)` and `formatTokenTotalSummary(...)`without passing `TokenSummaryOptions`, so the newly added 5h window estimate is never shown in execution summaries despite `display.showRateLimitEstimate`defaulting to `true`. This makes the new rate-limit display/config effectively inactive in the main execution path unless every caller is updated.
17
+ - [ ] fix pr comment (https://github.com/john-veresk/raf/pull/5). use gh tool to fetch context if needed. [src/core/worktree.ts](https://github.com/john-veresk/raf/pull/5/files/69f5fab1e125f871ce1356d366195ae34d195830#diff-f5303b02aaa03b1fd86860fe0c47fe6aaa7e3e5ca598c7b581d54470d668670b)
18
+
19
+ Comment on lines +534 to +537
20
+
21
+ | |
22
+ |---|
23
+ |success: true,|
24
+ |mainBranch,|
25
+ |hadChanges: false,|
26
+ |error: `Local ${mainBranch} has diverged from origin, not updated`,|
27
+
28
+
29
+  **[![P2 Badge](https://camo.githubusercontent.com/f2c1aacb361ddd3a0e9f9cacdb84fab050de434017f6747bb916e31e29bdf03d/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f50322d79656c6c6f773f7374796c653d666c6174)](https://camo.githubusercontent.com/f2c1aacb361ddd3a0e9f9cacdb84fab050de434017f6747bb916e31e29bdf03d/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f50322d79656c6c6f773f7374796c653d666c6174) Treat diverged main branch as sync failure**
30
+
31
+ When `git fetch origin <main>:<main>` fails because local `<main>` has diverged, this branch returns `success: true` with an `error` message, which means the new callers in `runDoCommand`/`runPlanCommand` (they only warn on `success === false`) silently continue without actually updating the local main branch. In this state worktree/PR flows proceed on stale base refs without surfacing the sync problem, so this path should be reported as a failure (or callers must treat `error` as a warning condition).
32
+
33
+ ---
34
+
35
+ - [ ] remove token report from plan (and all the code related)
@@ -0,0 +1,33 @@
1
+ # Outcome: Fix project name generation prompt
2
+
3
+ ## Summary
4
+ Successfully tightened the Claude prompts for project name generation to prevent Haiku from outputting preamble text that gets misinterpreted as a project name option.
5
+
6
+ ## Changes Made
7
+
8
+ ### 1. Updated `MULTI_NAME_GENERATION_PROMPT` (src/utils/name-generator.ts:22-30)
9
+ - **Before**: Prompt started with "Generate 5 creative project names..." followed by detailed style descriptions
10
+ - **After**: Prompt now starts with "Output EXACTLY 5 project names, one per line. Do NOT include any introduction, explanation, preamble, numbering, or quotes."
11
+ - Removed numbered style descriptions (which encouraged narration) and replaced with concise bulleted rules
12
+ - Output format constraint is now the first thing the model sees
13
+
14
+ ### 2. Updated `NAME_GENERATION_PROMPT` (src/utils/name-generator.ts:6-20)
15
+ - **Before**: Output format instruction was buried after creative examples
16
+ - **After**: Prompt now starts with "Output ONLY the kebab-case name. No introduction, no explanation, no quotes."
17
+ - Consistent with the multi-name approach
18
+
19
+ ### 3. Updated test (tests/unit/name-generator.test.ts:173)
20
+ - Changed assertion from `expect(promptArg).toContain('Generate 5 creative project names')` to `expect(promptArg).toContain('Output EXACTLY 5 project names')`
21
+ - All 29 tests pass
22
+
23
+ ## Key Improvements
24
+ - Output format constraints are now the **first** thing in both prompts
25
+ - Explicit prohibition of preamble/introduction text
26
+ - Simplified instructions reduce the urge for models (especially Haiku) to narrate
27
+ - Maintains creative guidance while being more directive about format
28
+
29
+ ## Testing
30
+ - All existing unit tests pass (29/29)
31
+ - No changes to parsing logic as requested
32
+
33
+ <promise>COMPLETE</promise>
@@ -0,0 +1,43 @@
1
+ # Outcome: Fix amend mode commit to exclude plan files
2
+
3
+ ## Summary
4
+ Successfully modified amend mode to only commit `input.md` and `decisions.md`, excluding new plan files. Plan files are now deferred to task execution commits, matching the behavior of initial planning.
5
+
6
+ ## Changes Made
7
+
8
+ ### 1. Updated `src/commands/plan.ts` (lines 650-656)
9
+ - **Before**: Amend commit included `input.md`, `decisions.md`, and all new plan files via `additionalFiles` parameter
10
+ - **After**: Amend commit only includes `input.md` and `decisions.md`
11
+ - Removed the `newPlanPaths` variable (no longer needed)
12
+ - Updated comment to clarify plan files are committed during execution
13
+
14
+ ### 2. Updated `tests/unit/commit-planning-artifacts.test.ts` (lines 255-291)
15
+ - **Test name changed**: `'should stage additional files when provided'` → `'should not stage plan files in amend mode'`
16
+ - **Before**: Test verified 4 files were staged (input, decisions, 2 plan files) with `isAmend: true`
17
+ - **After**: Test verifies only 2 files are staged (input, decisions) with `isAmend: true`
18
+ - Removed `additionalFiles` parameter from the test call
19
+
20
+ ### 3. Updated `tests/unit/commit-planning-artifacts-worktree.test.ts` (two tests)
21
+
22
+ #### Test 1: `'should commit with amend mode in worktree'` (lines 165-183)
23
+ - Removed `additionalFiles` array and parameter
24
+ - Changed assertion from expecting plan file to be included to expecting it NOT to be included
25
+ - Updated comment to clarify plan files are not included in amend commit
26
+
27
+ #### Test 2: `'should commit after worktree recreation from branch'` (lines 237-255)
28
+ - Removed `additionalFiles` array and parameter
29
+ - Changed assertion from expecting plan file to be included to expecting it NOT to be included
30
+ - Updated comment to clarify plan files are not included in amend commit
31
+
32
+ ## Testing
33
+ All 21 tests pass:
34
+ - `commit-planning-artifacts.test.ts`: 16 tests ✓
35
+ - `commit-planning-artifacts-worktree.test.ts`: 5 tests ✓
36
+
37
+ ## Acceptance Criteria
38
+ - ✅ Amend commit only stages `input.md` and `decisions.md`
39
+ - ✅ `additionalFiles` is not passed in the amend code path
40
+ - ✅ Initial planning commit behavior unchanged
41
+ - ✅ Existing tests updated and passing
42
+
43
+ <promise>COMPLETE</promise>
@@ -0,0 +1,32 @@
1
+ # Outcome: Fix diverged main branch sync to report failure
2
+
3
+ ## Summary
4
+ Successfully changed `pullMainBranch()` to return `success: false` when the local main branch has diverged from remote, ensuring callers surface the issue as a warning instead of silently ignoring it.
5
+
6
+ ## Changes Made
7
+
8
+ ### 1. Updated `src/core/worktree.ts` (line 534)
9
+ - **Before**: `success: true` when local main has diverged from remote
10
+ - **After**: `success: false` when local main has diverged from remote
11
+ - The plain `git fetch origin main` still runs successfully, updating the remote ref
12
+ - The error message remains: `"Local ${mainBranch} has diverged from origin, not updated"`
13
+
14
+ ### 2. Updated `tests/unit/worktree.test.ts` (line 732)
15
+ - **Test**: "should warn when local main has diverged"
16
+ - **Before**: `expect(result.success).toBe(true)`
17
+ - **After**: `expect(result.success).toBe(false)`
18
+ - All 75 worktree tests pass
19
+
20
+ ## Key Improvements
21
+ - Diverged branch scenarios are now properly surfaced to callers
22
+ - Callers already had `if (!syncResult.success) { logger.warn(...) }` pattern in place (lines 243-250 in do.ts and similar in plan.ts)
23
+ - Users will now see a warning when their local main has diverged, instead of proceeding silently on a stale base ref
24
+ - Execution continues after the warning (soft failure), not a hard error
25
+
26
+ ## Acceptance Criteria
27
+ - ✅ Diverged branch path returns `success: false`
28
+ - ✅ Callers show a warning via `logger.warn()` (already handled)
29
+ - ✅ Execution continues after the warning (callers don't abort)
30
+ - ✅ Tests updated and passing (75/75 tests pass)
31
+
32
+ <promise>COMPLETE</promise>
@@ -0,0 +1,61 @@
1
+ # Outcome: Wire rate-limit estimate display config to do command
2
+
3
+ ## Summary
4
+ Successfully wired the `display.showRateLimitEstimate` and `display.showCacheTokens` config settings through to the token summary formatters in the `raf do` command. The rate limit percentage feature is now fully functional and respects user configuration.
5
+
6
+ ## Changes Made
7
+
8
+ ### 1. Updated `src/commands/do.ts`
9
+
10
+ **Import config helpers** (line 16):
11
+ - Added `getShowRateLimitEstimate` and `getShowCacheTokens` to imports from `../utils/config.js`
12
+
13
+ **Per-task token display - success path** (lines 1217-1225):
14
+ - Changed from calling `formatTaskTokenSummary(entry, calculateCost)` without options
15
+ - To calling with full options object containing:
16
+ - `showCacheTokens: getShowCacheTokens()`
17
+ - `showRateLimitEstimate: getShowRateLimitEstimate()`
18
+ - `rateLimitPercentage: tokenTracker.getCumulativeRateLimitPercentage()`
19
+
20
+ **Per-task token display - failure path** (lines 1245-1253):
21
+ - Applied identical changes to the failed-task code path
22
+ - Ensures rate limit percentage is shown even for failed tasks with partial usage data
23
+
24
+ **Grand total summary** (lines 1356-1365):
25
+ - Changed from calling `formatTokenTotalSummary(usage, cost)` without options
26
+ - To calling with full options object containing the same config values
27
+ - Uses `tokenTracker.getCumulativeRateLimitPercentage()` to get the final cumulative percentage
28
+
29
+ ### 2. Updated `src/utils/terminal-symbols.ts`
30
+
31
+ **Function `formatTokenLine`** (line 180):
32
+ - Changed default: `showRateLimitEstimate = false` → `showRateLimitEstimate = true`
33
+ - Now matches the config default (`display.showRateLimitEstimate: true`)
34
+
35
+ **Function `formatTokenTotalSummary`** (line 258):
36
+ - Changed default: `showRateLimitEstimate = false` → `showRateLimitEstimate = true`
37
+ - Ensures consistent default behavior across both formatter functions
38
+
39
+ ## Key Improvements
40
+
41
+ 1. **Feature is now live**: Previously dead code due to hardcoded `false` defaults
42
+ 2. **Config-driven**: Both `display.showRateLimitEstimate` and `display.showCacheTokens` are properly wired through
43
+ 3. **Cumulative tracking**: Each task shows the cumulative rate limit percentage up to that point
44
+ 4. **Grand total**: Final summary shows the total cumulative percentage across all tasks
45
+ 5. **User control**: Users can disable via `display.showRateLimitEstimate: false` in config
46
+
47
+ ## Testing
48
+
49
+ - All 1273 tests pass (including 76 terminal-symbols tests)
50
+ - TypeScript compilation successful with no errors
51
+ - No test changes required (existing tests already covered the functionality)
52
+
53
+ ## Acceptance Criteria
54
+
55
+ - ✅ Per-task token summaries show rate limit percentage when `display.showRateLimitEstimate` is `true`
56
+ - ✅ Grand total summary shows rate limit percentage
57
+ - ✅ Setting `display.showRateLimitEstimate: false` in config suppresses the display
58
+ - ✅ `display.showCacheTokens` config is also wired through
59
+ - ✅ Tests pass
60
+
61
+ <promise>COMPLETE</promise>
@@ -0,0 +1,125 @@
1
+ # Outcome: Add --get and --set flags to raf config
2
+
3
+ ## Summary
4
+ Successfully added `--get` and `--set` flags to `raf config` command for quick, non-interactive config viewing and editing without launching the Claude wizard.
5
+
6
+ ## Changes Made
7
+
8
+ ### 1. Updated `src/commands/config.ts`
9
+
10
+ **Enhanced ConfigCommandOptions interface** (lines 19-23):
11
+ - Added `get?: true | string` field (true when no key, string when specific key provided)
12
+ - Added `set?: string[]` field to capture key-value pairs
13
+
14
+ **Added helper functions** (lines 120-225):
15
+ - `getNestedValue(obj, dotPath)` - traverse config by dot notation
16
+ - `setNestedValue(obj, dotPath, value)` - set leaf values by dot notation
17
+ - `deleteNestedValue(obj, dotPath)` - remove leaf values and clean up empty parents
18
+ - `getDefaultValue(dotPath)` - get default value from DEFAULT_CONFIG
19
+ - `parseValue(value)` - parse strings to numbers/booleans via JSON.parse fallback
20
+ - `formatValue(value)` - format values for console output (plain strings, formatted objects)
21
+
22
+ **Implemented handleGet function** (lines 229-246):
23
+ - When `key === true`: prints full merged config as formatted JSON
24
+ - When `key` is a string: retrieves and prints the specific value
25
+ - Plain output for strings/numbers/booleans, formatted JSON for objects
26
+ - Exits with error if key not found
27
+
28
+ **Implemented handleSet function** (lines 248-296):
29
+ - Reads current user config or starts with empty object
30
+ - Parses value using JSON.parse (for numbers/booleans) with string fallback
31
+ - Validates key exists in schema by checking default value
32
+ - Compares with default value - if equal, removes key from config (keeps config minimal)
33
+ - Cleans up empty parent objects after removal
34
+ - Validates resulting config before saving
35
+ - Deletes config file if it becomes completely empty
36
+ - Provides clear success/info messages
37
+
38
+ **Updated command definition** (lines 300-335):
39
+ - Added `.option('--get [key]', '...')` for viewing config
40
+ - Added `.option('--set <items...>', '...')` for setting values (variadic to capture key + value)
41
+ - Added mutual exclusion check between `--get` and `--set`
42
+ - `--reset` takes precedence over other flags
43
+ - Routes to appropriate handler or falls back to interactive wizard
44
+
45
+ ### 2. Updated `tests/unit/config-command.test.ts`
46
+
47
+ **Added option tests** (lines 53-59):
48
+ - Tests verify `--get` and `--set` options exist on command
49
+
50
+ **Added --get flag test suite** (lines 246-269):
51
+ - Tests full config retrieval (no key)
52
+ - Tests specific key retrieval (dot notation)
53
+ - Tests nested keys (e.g., `display.showRateLimitEstimate`)
54
+ - Tests deeply nested keys (e.g., `pricing.opus.inputPerMTok`)
55
+
56
+ **Added --set flag test suite** (lines 271-343):
57
+ - Tests setting string values
58
+ - Tests setting number values (JSON.parse)
59
+ - Tests setting boolean values (JSON.parse)
60
+ - Tests default value removal (keeps config minimal)
61
+ - Tests empty parent object cleanup
62
+ - Tests validation after modification
63
+ - Tests config file deletion when empty
64
+ - Tests nested value updates
65
+
66
+ ## Key Features
67
+
68
+ 1. **Quick access**: No Claude wizard overhead for simple operations
69
+ 2. **Dot notation**: Supports all config paths (e.g., `models.plan`, `display.showRateLimitEstimate`)
70
+ 3. **Type parsing**: Automatically parses numbers and booleans via JSON.parse
71
+ 4. **Minimal config**: Removes keys that match defaults to keep config file clean
72
+ 5. **Parent cleanup**: Removes empty parent objects after leaf deletion
73
+ 6. **Validation**: Full schema validation before saving changes
74
+ 7. **Error handling**: Clear error messages for invalid keys, values, or operations
75
+ 8. **Mutual exclusion**: Prevents conflicting `--get`/`--set` flags
76
+
77
+ ## Usage Examples
78
+
79
+ ```bash
80
+ # View full merged config
81
+ raf config --get
82
+
83
+ # View specific value (plain output)
84
+ raf config --get models.plan
85
+ # Output: opus
86
+
87
+ # Set a model
88
+ raf config --set models.plan sonnet
89
+ # Output: Set models.plan = sonnet
90
+
91
+ # Set a number
92
+ raf config --set timeout 120
93
+ # Output: Set timeout = 120
94
+
95
+ # Set a boolean
96
+ raf config --set autoCommit false
97
+ # Output: Set autoCommit = false
98
+
99
+ # Set back to default (removes from config)
100
+ raf config --set models.plan opus
101
+ # Output: Value matches default, removing models.plan from config
102
+
103
+ # View nested value
104
+ raf config --get display.showRateLimitEstimate
105
+ # Output: true
106
+ ```
107
+
108
+ ## Testing
109
+ - All 40 config-command tests pass
110
+ - Full test suite: 1287 tests pass
111
+ - Manual testing confirms all functionality works as expected
112
+ - Error cases properly handled (invalid keys, invalid values, mutual exclusion)
113
+
114
+ ## Acceptance Criteria
115
+ - ✅ `raf config --get` prints full merged config as formatted JSON
116
+ - ✅ `raf config --get models.plan` prints plain value (e.g., `opus`)
117
+ - ✅ `raf config --set models.plan sonnet` updates config file
118
+ - ✅ Setting value to default removes it from config file
119
+ - ✅ Empty sections cleaned up after removal
120
+ - ✅ Value parsing handles strings, numbers, and booleans
121
+ - ✅ Invalid keys/values show clear error messages
122
+ - ✅ Interactive wizard NOT launched when --get or --set is present
123
+ - ✅ Tests pass
124
+
125
+ <promise>COMPLETE</promise>
@@ -0,0 +1,96 @@
1
+ # Outcome: Sync worktree branch with main before execution
2
+
3
+ ## Summary
4
+ Successfully implemented automatic rebasing of worktree branches onto the latest main branch before task execution in `raf do`. This ensures worktree branches are up-to-date, reducing merge conflicts later.
5
+
6
+ ## Changes Made
7
+
8
+ ### 1. Added `RebaseResult` interface and `rebaseOntoMain` function to `src/core/worktree.ts`
9
+
10
+ **New interface** (line 444-447):
11
+ - `RebaseResult` with `success: boolean` and `error?: string`
12
+
13
+ **New function `rebaseOntoMain`** (lines 668-695):
14
+ - Takes `mainBranch` (branch name) and `cwd` (worktree directory) as parameters
15
+ - Executes `git rebase ${mainBranch}` in the specified directory
16
+ - On rebase failure (e.g., conflicts):
17
+ - Automatically runs `git rebase --abort` to restore clean state
18
+ - Returns `success: false` with error message
19
+ - Gracefully ignores abort errors if abort itself fails
20
+ - Returns `success: true` on successful rebase
21
+
22
+ ### 2. Updated `src/commands/do.ts`
23
+
24
+ **Added imports** (lines 55-56):
25
+ - `detectMainBranch` and `rebaseOntoMain` from `../core/worktree.js`
26
+
27
+ **Stored main branch name** (lines 228, 246):
28
+ - Added `mainBranchName` variable to capture the main branch from `pullMainBranch()` sync result
29
+ - Falls back to `detectMainBranch()` if sync was disabled or failed
30
+
31
+ **Added rebase step** (lines 468-479):
32
+ - After post-execution action picker but before task execution
33
+ - Only runs when:
34
+ - In worktree mode (`worktreeMode && worktreeRoot`)
35
+ - `syncMainBranch` config setting is enabled
36
+ - Main branch can be detected
37
+ - On success: logs `"Rebased onto ${mainBranch}"`
38
+ - On failure: logs warning with error message and `"Continuing with current branch state."`
39
+ - Execution continues regardless of rebase outcome (soft failure)
40
+
41
+ ### 3. Added tests to `tests/unit/worktree.test.ts`
42
+
43
+ **Added `rebaseOntoMain` to imports** (line 49)
44
+
45
+ **Added test suite for `rebaseOntoMain`** (lines 809-857):
46
+
47
+ 1. **"should successfully rebase onto main branch"**:
48
+ - Mocks successful `git rebase main` execution
49
+ - Verifies `success: true` and no error
50
+ - Confirms git command called with correct `cwd`
51
+
52
+ 2. **"should abort rebase and return failure on conflict"**:
53
+ - Mocks rebase failure with "CONFLICT" error
54
+ - Verifies `success: false` with error message
55
+ - Confirms both `git rebase main` and `git rebase --abort` are called
56
+ - Ensures abort is called with correct `cwd`
57
+
58
+ 3. **"should handle rebase abort failure gracefully"**:
59
+ - Mocks both rebase and abort failures
60
+ - Verifies function still returns `success: false` even when abort fails
61
+ - Ensures abort errors don't crash the function
62
+
63
+ ### 4. Updated test mock in `tests/unit/post-execution-picker.test.ts`
64
+
65
+ **Added `rebaseOntoMain`** (line 68):
66
+ - Added to the worktree module mock to prevent import errors
67
+
68
+ ## Key Features
69
+
70
+ 1. **Automatic sync**: Worktree branches are rebased onto main before each execution, keeping them current
71
+ 2. **Conflict handling**: On rebase conflicts, automatically aborts and continues with a warning
72
+ 3. **Config-driven**: Respects `syncMainBranch` config setting (skips when disabled)
73
+ 4. **Main branch detection**: Uses cached main branch from sync step, falls back to detection
74
+ 5. **Clean state**: On conflict, `git rebase --abort` ensures worktree is left in a usable state
75
+ 6. **Soft failure**: Rebase failures are warnings, not errors - execution continues
76
+ 7. **Worktree-only**: Rebase only happens in worktree mode, not in standard mode
77
+
78
+ ## Testing
79
+
80
+ - All 1290 tests pass (78 worktree tests including 3 new rebase tests)
81
+ - TypeScript compilation successful with no errors
82
+ - Test coverage includes:
83
+ - Successful rebase scenario
84
+ - Conflict scenario with automatic abort
85
+ - Abort failure graceful handling
86
+
87
+ ## Acceptance Criteria
88
+
89
+ - ✅ Worktree branch is rebased onto main before task execution
90
+ - ✅ Conflicts cause rebase abort + warning, execution continues
91
+ - ✅ Rebase only happens in worktree mode
92
+ - ✅ Respects `syncMainBranch` config setting
93
+ - ✅ Main branch name correctly determined from sync result or detection
94
+ - ✅ Tests pass
95
+
96
+ <promise>COMPLETE</promise>
@@ -0,0 +1,107 @@
1
+ # Outcome: Update plan frontmatter to standard Obsidian format
2
+
3
+ ## Summary
4
+ Successfully migrated plan file frontmatter from the non-standard closing-delimiter-only format to the standard Obsidian/YAML format with both opening and closing `---` delimiters. The parser maintains full backward compatibility with existing plan files.
5
+
6
+ ## Changes Made
7
+
8
+ ### 1. Updated `src/utils/frontmatter.ts`
9
+
10
+ **Enhanced `parsePlanFrontmatter()` function** (lines 27-72):
11
+ - **Before**: Only supported legacy format (closing `---` only)
12
+ - **After**: Supports both standard format (`---`/`---`) and legacy format for backward compatibility
13
+
14
+ **Standard format detection** (lines 50-62):
15
+ - Checks if content starts with `---` (after trimming leading whitespace)
16
+ - If present: extracts content between opening `---` and closing `---`
17
+ - Handles `---` with trailing spaces/content on the same line
18
+ - Returns empty if no closing delimiter found
19
+
20
+ **Legacy format fallback** (lines 63-69):
21
+ - If no opening `---` found: uses original logic
22
+ - Finds first `---` and treats everything before it as frontmatter
23
+ - Maintains 100% compatibility with existing plan files
24
+
25
+ **Updated JSDoc** (lines 26-47):
26
+ - Documents both supported formats with examples
27
+ - Clarifies standard format is preferred
28
+
29
+ ### 2. Updated `tests/unit/frontmatter.test.ts`
30
+
31
+ **Added comprehensive standard format tests** (lines 4-96):
32
+ - Parse effort field in standard format
33
+ - Parse model field in standard format
34
+ - Parse both effort and model
35
+ - Handle empty frontmatter block (`---\n---`)
36
+ - Handle whitespace before opening delimiter
37
+ - Handle empty lines in frontmatter
38
+ - Handle opening delimiter with trailing spaces
39
+ - Return empty for missing closing delimiter
40
+ - Return empty for opening delimiter without newline
41
+
42
+ **Renamed legacy tests section** (line 98):
43
+ - Changed from `'valid frontmatter'` to `'legacy format (closing --- only)'`
44
+ - All existing tests remain unchanged and passing
45
+
46
+ **Test results**:
47
+ - All 26 frontmatter tests pass (9 new standard format tests, 16 legacy format tests, 1 renamed)
48
+ - Full test suite: 1299 tests pass (no regressions)
49
+
50
+ ### 3. Updated `src/prompts/planning.ts`
51
+
52
+ **Updated frontmatter format instructions** (lines 83-88):
53
+ - Changed example from closing-only to standard format with opening `---`
54
+ - Updated description: "The frontmatter uses standard YAML format with opening and closing \`---\` delimiters"
55
+
56
+ **Updated frontmatter optional model example** (lines 129-136):
57
+ - Added opening `---` to the example showing model override
58
+
59
+ ### 4. Updated `src/prompts/amend.ts`
60
+
61
+ **Updated frontmatter format instructions** (lines 138-143):
62
+ - Changed example from closing-only to standard format with opening `---`
63
+ - Updated description: "The frontmatter uses standard YAML format with opening and closing \`---\` delimiters"
64
+
65
+ **Updated frontmatter optional model example** (lines 188-195):
66
+ - Added opening `---` to the example showing model override
67
+
68
+ ### 5. Updated `CLAUDE.md`
69
+
70
+ **Updated Plan File Structure section** (lines 47-84):
71
+ - Changed frontmatter example from closing-only to standard format
72
+ - Updated frontmatter description:
73
+ - Before: "Uses Obsidian-style format: \`key: value\` lines followed by \`---\` (no opening delimiter)"
74
+ - After: "Uses standard Obsidian/YAML format: opening \`---\`, \`key: value\` lines, closing \`---\`"
75
+ - Added note: "Parser also supports legacy format (no opening \`---\`) for backward compatibility"
76
+
77
+ ### 6. Updated current project plan file
78
+
79
+ **Updated task 07 plan file** (`RAF/ahwidh-quick-fix-gremlin/plans/07-update-frontmatter-format.md`):
80
+ - Changed from `effort: medium\n---` to `---\neffort: medium\n---`
81
+ - Demonstrates the new standard format in action
82
+
83
+ ## Key Features
84
+
85
+ 1. **Standard compliance**: Aligns with Obsidian, Jekyll, Hugo, and other markdown tools
86
+ 2. **Backward compatibility**: All existing plan files with legacy format continue to work
87
+ 3. **Robust parsing**: Handles whitespace variations, empty blocks, and edge cases
88
+ 4. **Future-proof**: New plan files generated by Claude will use the standard format
89
+ 5. **Comprehensive testing**: 9 new tests for standard format, all legacy tests preserved
90
+
91
+ ## Acceptance Criteria
92
+
93
+ - ✅ Parser handles standard `---`/`---` format correctly
94
+ - ✅ Parser still handles legacy closing-only format (backward compatibility)
95
+ - ✅ Planning prompts generate the new standard format
96
+ - ✅ CLAUDE.md documentation updated
97
+ - ✅ Tests cover both old and new formats
98
+ - ✅ All existing tests pass (1299/1299)
99
+
100
+ ## Notes
101
+
102
+ - The parser uses `trimStart()` to handle optional leading whitespace before the opening `---`
103
+ - The standard format requires a newline after the opening `---` (cannot be `---key: value`)
104
+ - Legacy format is automatically detected when content doesn't start with `---`
105
+ - All future plan files generated by Claude will use the standard format with opening delimiter
106
+
107
+ <promise>COMPLETE</promise>
@@ -0,0 +1,76 @@
1
+ # Outcome: Remove Token Report from Plan Command
2
+
3
+ ## Summary
4
+ Successfully removed all token usage reporting from `raf plan` and `raf plan --amend` commands. The session-parser module and its tests have been deleted, and the sessionId parameter has been removed from the ClaudeRunner API.
5
+
6
+ ## Changes Made
7
+
8
+ ### 1. Updated `src/commands/plan.ts`
9
+
10
+ **Removed imports** (lines 3, 19-22):
11
+ - Removed `import * as crypto from 'node:crypto';`
12
+ - Removed `TokenTracker` from `../utils/token-tracker.js`
13
+ - Removed `parseSessionById` from `../utils/session-parser.js`
14
+ - Removed `formatTokenTotalSummary, TokenSummaryOptions` from `../utils/terminal-symbols.js`
15
+ - Removed `getDisplayConfig, getPricingConfig` from `../utils/config.js`
16
+
17
+ **Updated `runPlanCommand()` function** (lines 286-303):
18
+ - Removed `sessionId` generation using `crypto.randomUUID()`
19
+ - Removed `sessionCwd` variable
20
+ - Removed `sessionId` parameter from `claudeRunner.runInteractive()` call
21
+ - Removed `displayPlanSessionTokenSummary(sessionId, sessionCwd)` call after session completion
22
+
23
+ **Updated `runAmendCommand()` function** (lines 599-617):
24
+ - Removed `sessionId` generation using `crypto.randomUUID()`
25
+ - Removed `sessionCwd` variable
26
+ - Removed `sessionId` parameter from `claudeRunner.runInteractive()` call
27
+ - Removed `displayPlanSessionTokenSummary(sessionId, sessionCwd)` call after session completion
28
+
29
+ **Deleted function** (lines 700-739):
30
+ - Completely removed the `displayPlanSessionTokenSummary()` function
31
+
32
+ ### 2. Updated `src/core/claude-runner.ts`
33
+
34
+ **Removed from ClaudeRunnerOptions interface** (lines 34-39):
35
+ - Deleted the `sessionId?: string` field
36
+ - Deleted the associated JSDoc comment describing the sessionId parameter
37
+
38
+ **Updated `runInteractive()` method** (lines 284-305):
39
+ - Removed `sessionId` from the destructured options parameter
40
+ - Removed the conditional code block that added `--session-id` flag to Claude CLI args
41
+
42
+ ### 3. Deleted files
43
+ - Deleted `src/utils/session-parser.ts` entirely
44
+ - Deleted `tests/unit/session-parser.test.ts` entirely
45
+
46
+ ## Testing
47
+
48
+ - **Build verification**: `npm run build` passes with no TypeScript errors
49
+ - **Test suite**: All 1284 tests pass (down from 1299, indicating the session-parser tests were successfully removed)
50
+ - **No broken imports**: No import errors for the deleted modules
51
+
52
+ ## Key Improvements
53
+
54
+ 1. **Simplified planning command**: Removed unnecessary token tracking complexity from interactive planning sessions
55
+ 2. **Dead code elimination**: Deleted the session-parser module that only existed to support this removed feature
56
+ 3. **Cleaner API**: The `runInteractive()` method no longer has the unused sessionId parameter
57
+ 4. **Reduced dependencies**: Removed crypto, TokenTracker, and session-parser imports from plan.ts
58
+
59
+ ## Acceptance Criteria
60
+
61
+ - ✅ `raf plan` no longer displays a token usage summary after the planning session
62
+ - ✅ `raf plan --amend` no longer displays a token usage summary after the amendment session
63
+ - ✅ `src/utils/session-parser.ts` is deleted
64
+ - ✅ `tests/unit/session-parser.test.ts` is deleted
65
+ - ✅ `sessionId` parameter removed from `runInteractive()` API
66
+ - ✅ No unused imports remain in modified files
67
+ - ✅ Build passes (`npm run build`)
68
+ - ✅ Tests pass (`npm test` - 1284/1284 tests pass)
69
+
70
+ ## Notes
71
+
72
+ - Token tracking utilities (`TokenTracker`, `formatTokenTotalSummary`, `formatTaskTokenSummary`) remain in the codebase as they are still used by `raf do` command
73
+ - Display and pricing config sections remain valid for `raf do` usage
74
+ - No changes were made to the execution token reporting in `raf do` - that functionality is preserved and unaffected
75
+
76
+ <promise>COMPLETE</promise>
@@ -0,0 +1,52 @@
1
+ effort: low
2
+ ---
3
+ # Task: Fix project name generation prompt
4
+
5
+ ## Objective
6
+ Fix the multi-name generation prompt so Haiku doesn't output preamble text as the first "name" option.
7
+
8
+ ## Context
9
+ When using Haiku for name generation (`models.nameGeneration: haiku`), the model outputs a preamble like "I'll generate 5 creative project names with differ..." before the actual names. This preamble gets sanitized into a long kebab-case string and appears as the first option in the picker. The prompt needs stronger instructions to prevent this.
10
+
11
+ ## Requirements
12
+ - Tighten the `MULTI_NAME_GENERATION_PROMPT` in `src/utils/name-generator.ts` to prevent preamble
13
+ - Also tighten the single `NAME_GENERATION_PROMPT` for consistency
14
+ - Do NOT change the parsing logic (user chose prompt-only fix)
15
+ - Must work reliably with Haiku, Sonnet, and Opus models
16
+
17
+ ## Implementation Steps
18
+
19
+ 1. **Edit `src/utils/name-generator.ts`** — Update `MULTI_NAME_GENERATION_PROMPT` (line 22):
20
+ - Move the output format instruction to the very beginning of the prompt
21
+ - Add explicit "Do NOT include any introduction, explanation, or preamble" instruction
22
+ - Remove the numbered style descriptions (they encourage Haiku to narrate)
23
+ - Simplify to a direct instruction format. Example approach:
24
+ ```
25
+ Output EXACTLY 5 project names, one per line. No introductions, no explanations, no numbering, no quotes.
26
+
27
+ Rules:
28
+ - Each name: 1-3 words, kebab-case, lowercase with hyphens only
29
+ - Use varied styles: metaphorical, playful, action-oriented, abstract, cultural reference
30
+ - Make them memorable and evocative
31
+ - For projects with many unrelated tasks, prefer abstract/metaphorical names
32
+
33
+ Project description:
34
+ ```
35
+
36
+ 2. **Update `NAME_GENERATION_PROMPT`** (line 6) similarly:
37
+ - Lead with the output format constraint
38
+ - Add "No introduction, no explanation" reinforcement
39
+
40
+ 3. **Update tests** if any exist in `tests/unit/name-generator.test.ts` that assert on the prompt text
41
+
42
+ ## Acceptance Criteria
43
+ - [ ] Multi-name prompt starts with output format instruction
44
+ - [ ] Prompt explicitly forbids preamble/introduction text
45
+ - [ ] Numbered style descriptions removed or simplified to avoid narration
46
+ - [ ] Single-name prompt similarly tightened
47
+ - [ ] Existing tests pass
48
+
49
+ ## Notes
50
+ - The parsing already strips numbering prefixes and quotes, but can't distinguish a preamble sentence from a valid name
51
+ - Haiku is particularly prone to prefacing its response with context
52
+ - The key insight: put the output format constraint FIRST, before the creative instructions