rafcode 2.4.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.
- package/.claude/settings.local.json +3 -1
- package/CLAUDE.md +3 -1
- package/RAF/ahwidh-quick-fix-gremlin/decisions.md +37 -0
- package/RAF/ahwidh-quick-fix-gremlin/input.md +35 -0
- package/RAF/ahwidh-quick-fix-gremlin/outcomes/01-fix-name-generation-prompt.md +33 -0
- package/RAF/ahwidh-quick-fix-gremlin/outcomes/02-fix-amend-commit-scope.md +43 -0
- package/RAF/ahwidh-quick-fix-gremlin/outcomes/03-fix-diverged-main-branch-sync.md +32 -0
- package/RAF/ahwidh-quick-fix-gremlin/outcomes/04-wire-rate-limit-to-do-command.md +61 -0
- package/RAF/ahwidh-quick-fix-gremlin/outcomes/05-add-config-get-set-flags.md +125 -0
- package/RAF/ahwidh-quick-fix-gremlin/outcomes/06-sync-worktree-branch-before-execution.md +96 -0
- package/RAF/ahwidh-quick-fix-gremlin/outcomes/07-update-frontmatter-format.md +107 -0
- package/RAF/ahwidh-quick-fix-gremlin/outcomes/08-remove-plan-token-report.md +76 -0
- package/RAF/ahwidh-quick-fix-gremlin/plans/01-fix-name-generation-prompt.md +52 -0
- package/RAF/ahwidh-quick-fix-gremlin/plans/02-fix-amend-commit-scope.md +48 -0
- package/RAF/ahwidh-quick-fix-gremlin/plans/03-fix-diverged-main-branch-sync.md +49 -0
- package/RAF/ahwidh-quick-fix-gremlin/plans/04-wire-rate-limit-to-do-command.md +78 -0
- package/RAF/ahwidh-quick-fix-gremlin/plans/05-add-config-get-set-flags.md +101 -0
- package/RAF/ahwidh-quick-fix-gremlin/plans/06-sync-worktree-branch-before-execution.md +92 -0
- package/RAF/ahwidh-quick-fix-gremlin/plans/07-update-frontmatter-format.md +105 -0
- package/RAF/ahwidh-quick-fix-gremlin/plans/08-remove-plan-token-report.md +50 -0
- package/dist/commands/config.d.ts.map +1 -1
- package/dist/commands/config.js +209 -1
- package/dist/commands/config.js.map +1 -1
- package/dist/commands/do.d.ts.map +1 -1
- package/dist/commands/do.js +36 -5
- package/dist/commands/do.js.map +1 -1
- package/dist/commands/plan.d.ts.map +1 -1
- package/dist/commands/plan.js +2 -55
- package/dist/commands/plan.js.map +1 -1
- package/dist/core/claude-runner.d.ts +0 -6
- package/dist/core/claude-runner.d.ts.map +1 -1
- package/dist/core/claude-runner.js +1 -5
- package/dist/core/claude-runner.js.map +1 -1
- package/dist/core/worktree.d.ts +12 -0
- package/dist/core/worktree.d.ts.map +1 -1
- package/dist/core/worktree.js +33 -1
- package/dist/core/worktree.js.map +1 -1
- package/dist/prompts/amend.d.ts.map +1 -1
- package/dist/prompts/amend.js +3 -1
- package/dist/prompts/amend.js.map +1 -1
- package/dist/prompts/planning.d.ts.map +1 -1
- package/dist/prompts/planning.js +3 -1
- package/dist/prompts/planning.js.map +1 -1
- package/dist/utils/frontmatter.d.ts +13 -3
- package/dist/utils/frontmatter.d.ts.map +1 -1
- package/dist/utils/frontmatter.js +40 -10
- package/dist/utils/frontmatter.js.map +1 -1
- package/dist/utils/name-generator.d.ts.map +1 -1
- package/dist/utils/name-generator.js +7 -16
- package/dist/utils/name-generator.js.map +1 -1
- package/dist/utils/terminal-symbols.js +2 -2
- package/dist/utils/terminal-symbols.js.map +1 -1
- package/package.json +1 -1
- package/src/commands/config.ts +242 -0
- package/src/commands/do.ts +37 -4
- package/src/commands/plan.ts +2 -65
- package/src/core/claude-runner.ts +1 -12
- package/src/core/worktree.ts +37 -1
- package/src/prompts/amend.ts +3 -1
- package/src/prompts/planning.ts +3 -1
- package/src/utils/frontmatter.ts +41 -11
- package/src/utils/name-generator.ts +7 -16
- package/src/utils/terminal-symbols.ts +2 -2
- package/tests/unit/commit-planning-artifacts-worktree.test.ts +6 -14
- package/tests/unit/commit-planning-artifacts.test.ts +4 -12
- package/tests/unit/config-command.test.ts +170 -0
- package/tests/unit/frontmatter.test.ts +95 -1
- package/tests/unit/name-generator.test.ts +1 -1
- package/tests/unit/post-execution-picker.test.ts +1 -0
- package/tests/unit/worktree.test.ts +68 -1
- package/src/utils/session-parser.ts +0 -161
- package/tests/unit/session-parser.test.ts +0 -301
package/CLAUDE.md
CHANGED
|
@@ -46,6 +46,7 @@ RAF/
|
|
|
46
46
|
|
|
47
47
|
Each plan file MUST have Obsidian-style frontmatter at the top, before the `# Task:` heading:
|
|
48
48
|
```markdown
|
|
49
|
+
---
|
|
49
50
|
effort: medium
|
|
50
51
|
---
|
|
51
52
|
# Task: [Task Name]
|
|
@@ -77,10 +78,11 @@ effort: medium
|
|
|
77
78
|
```
|
|
78
79
|
|
|
79
80
|
**Frontmatter**:
|
|
80
|
-
- Uses Obsidian
|
|
81
|
+
- Uses standard Obsidian/YAML format: opening `---`, `key: value` lines, closing `---`
|
|
81
82
|
- `effort` is REQUIRED: `low`, `medium`, or `high` — determines execution model via `effortMapping`
|
|
82
83
|
- `model` is OPTIONAL: explicit model override (subject to ceiling)
|
|
83
84
|
- Frontmatter is parsed by `src/utils/frontmatter.ts`
|
|
85
|
+
- Parser also supports legacy format (no opening `---`) for backward compatibility
|
|
84
86
|
|
|
85
87
|
**Dependencies Section**:
|
|
86
88
|
- Optional - omit if task has no dependencies
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# Project Decisions
|
|
2
|
+
|
|
3
|
+
## For `raf config --get/--set`: Should `--get` with no key show the full merged config (defaults + overrides), or only user overrides from the config file?
|
|
4
|
+
Full merged config — Shows the complete resolved config with all defaults filled in, so users see every active setting.
|
|
5
|
+
|
|
6
|
+
## For `raf config --set`: Should setting a value to its default automatically remove it from the config file (keeping config minimal), or always write explicitly?
|
|
7
|
+
Remove if default — If the value matches the default, remove the key from the config file to keep it clean.
|
|
8
|
+
|
|
9
|
+
## For the diverged main branch fix: Should callers treat this as a hard error or a warning?
|
|
10
|
+
Warning only — Show a visible warning (yellow) but continue execution. Stale base is better than blocking work.
|
|
11
|
+
|
|
12
|
+
## For the name generation fix: Should the fix tighten the prompt, add response parsing, or both?
|
|
13
|
+
Prompt only — Just improve the prompt instructions to be more explicit about output format.
|
|
14
|
+
|
|
15
|
+
## For `raf config --get models.plan`: Should the output be plain value only or formatted?
|
|
16
|
+
Plain value — Just print 'opus'. Easy to pipe into other commands.
|
|
17
|
+
|
|
18
|
+
## For the token investigation task: Research only or plan fix now?
|
|
19
|
+
Research now and create task if needed — investigated and found it's a display issue: `input_tokens` from Claude API only reports non-cached tokens. Fix plan created as task 07 to show total input in display.
|
|
20
|
+
|
|
21
|
+
## Token investigation findings
|
|
22
|
+
Root cause: Claude API separates `input_tokens` (non-cached, e.g. 3-22) from `cache_read_input_tokens` (e.g. 18,000+) and `cache_creation_input_tokens` (e.g. 6,000+). RAF displays only non-cached as "X in". Fix: sum all three for the display. Cost calculation is already correct.
|
|
23
|
+
|
|
24
|
+
## For amend commit fix: Should plan files be removed from the commit or committed separately?
|
|
25
|
+
Remove from commit — Only commit input.md and decisions.md during planning. Plan files get committed by Claude during execution.
|
|
26
|
+
|
|
27
|
+
## For syncing worktree branch with main before execution: Rebase or merge?
|
|
28
|
+
Rebase onto main — Cleaner history, replays worktree commits on top of latest main.
|
|
29
|
+
|
|
30
|
+
## If the rebase has conflicts, should `raf do` abort or skip sync?
|
|
31
|
+
Skip sync and warn — Skip the sync step, show a warning, and continue execution on the current branch state.
|
|
32
|
+
|
|
33
|
+
## For removing token report from plan: Should `session-parser.ts` and its tests be deleted or kept?
|
|
34
|
+
Delete session-parser entirely — Remove session-parser.ts and its test file since they have no other consumers.
|
|
35
|
+
|
|
36
|
+
## Should the `sessionId` parameter be removed from `runInteractive()` in claude-runner.ts?
|
|
37
|
+
Remove sessionId from runInteractive() too — Clean up the runner API as well since no other callers pass sessionId.
|
|
@@ -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
|
+
**[](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
|
+
**[](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>
|