rafcode 2.1.0 → 2.2.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 +4 -1
- package/CLAUDE.md +59 -11
- package/RAF/ahslfe-config-wizard/decisions.md +34 -0
- package/RAF/ahslfe-config-wizard/input.md +1 -0
- package/RAF/ahslfe-config-wizard/outcomes/01-define-config-schema.md +38 -0
- package/RAF/ahslfe-config-wizard/outcomes/02-refactor-codebase-to-use-config.md +67 -0
- package/RAF/ahslfe-config-wizard/outcomes/03-create-config-documentation.md +37 -0
- package/RAF/ahslfe-config-wizard/outcomes/04-implement-raf-config-command.md +47 -0
- package/RAF/ahslfe-config-wizard/outcomes/05-update-claude-md.md +26 -0
- package/RAF/ahslfe-config-wizard/plans/01-define-config-schema.md +73 -0
- package/RAF/ahslfe-config-wizard/plans/02-refactor-codebase-to-use-config.md +74 -0
- package/RAF/ahslfe-config-wizard/plans/03-create-config-documentation.md +57 -0
- package/RAF/ahslfe-config-wizard/plans/04-implement-raf-config-command.md +66 -0
- package/RAF/ahslfe-config-wizard/plans/05-update-claude-md.md +60 -0
- package/RAF/ahstvo-token-tracker/decisions.md +44 -0
- package/RAF/ahstvo-token-tracker/input.md +3 -0
- package/RAF/ahstvo-token-tracker/outcomes/01-full-model-id-support.md +43 -0
- package/RAF/ahstvo-token-tracker/outcomes/02-name-generation-no-session.md +33 -0
- package/RAF/ahstvo-token-tracker/outcomes/03-unify-stream-json-execution.md +48 -0
- package/RAF/ahstvo-token-tracker/outcomes/04-token-tracking-cost-calculation.md +53 -0
- package/RAF/ahstvo-token-tracker/outcomes/05-token-cost-console-reporting.md +57 -0
- package/RAF/ahstvo-token-tracker/outcomes/06-runtime-verbose-toggle.md +53 -0
- package/RAF/ahstvo-token-tracker/outcomes/07-readme-config-docs.md +36 -0
- package/RAF/ahstvo-token-tracker/plans/01-full-model-id-support.md +35 -0
- package/RAF/ahstvo-token-tracker/plans/02-name-generation-no-session.md +36 -0
- package/RAF/ahstvo-token-tracker/plans/03-unify-stream-json-execution.md +44 -0
- package/RAF/ahstvo-token-tracker/plans/04-token-tracking-cost-calculation.md +56 -0
- package/RAF/ahstvo-token-tracker/plans/05-token-cost-console-reporting.md +55 -0
- package/RAF/ahstvo-token-tracker/plans/06-runtime-verbose-toggle.md +48 -0
- package/RAF/ahstvo-token-tracker/plans/07-readme-config-docs.md +44 -0
- package/README.md +34 -0
- package/dist/commands/config.d.ts +3 -0
- package/dist/commands/config.d.ts.map +1 -0
- package/dist/commands/config.js +173 -0
- package/dist/commands/config.js.map +1 -0
- package/dist/commands/do.d.ts.map +1 -1
- package/dist/commands/do.js +50 -28
- package/dist/commands/do.js.map +1 -1
- package/dist/commands/plan.d.ts.map +1 -1
- package/dist/commands/plan.js +3 -2
- package/dist/commands/plan.js.map +1 -1
- package/dist/core/claude-runner.d.ts +17 -13
- package/dist/core/claude-runner.d.ts.map +1 -1
- package/dist/core/claude-runner.js +42 -257
- package/dist/core/claude-runner.js.map +1 -1
- package/dist/core/failure-analyzer.d.ts.map +1 -1
- package/dist/core/failure-analyzer.js +6 -3
- package/dist/core/failure-analyzer.js.map +1 -1
- package/dist/core/git.d.ts.map +1 -1
- package/dist/core/git.js +10 -3
- package/dist/core/git.js.map +1 -1
- package/dist/core/pull-request.d.ts +1 -1
- package/dist/core/pull-request.d.ts.map +1 -1
- package/dist/core/pull-request.js +7 -4
- package/dist/core/pull-request.js.map +1 -1
- package/dist/core/shutdown-handler.d.ts.map +1 -1
- package/dist/core/shutdown-handler.js +0 -4
- package/dist/core/shutdown-handler.js.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/parsers/stream-renderer.d.ts +16 -4
- package/dist/parsers/stream-renderer.d.ts.map +1 -1
- package/dist/parsers/stream-renderer.js +35 -5
- package/dist/parsers/stream-renderer.js.map +1 -1
- package/dist/prompts/execution.d.ts.map +1 -1
- package/dist/prompts/execution.js +11 -1
- package/dist/prompts/execution.js.map +1 -1
- package/dist/types/config.d.ts +95 -5
- package/dist/types/config.d.ts.map +1 -1
- package/dist/types/config.js +63 -3
- package/dist/types/config.js.map +1 -1
- package/dist/utils/config.d.ts +59 -7
- package/dist/utils/config.d.ts.map +1 -1
- package/dist/utils/config.js +276 -21
- package/dist/utils/config.js.map +1 -1
- package/dist/utils/name-generator.d.ts +3 -7
- package/dist/utils/name-generator.d.ts.map +1 -1
- package/dist/utils/name-generator.js +75 -61
- package/dist/utils/name-generator.js.map +1 -1
- package/dist/utils/terminal-symbols.d.ts +21 -0
- package/dist/utils/terminal-symbols.d.ts.map +1 -1
- package/dist/utils/terminal-symbols.js +62 -0
- package/dist/utils/terminal-symbols.js.map +1 -1
- package/dist/utils/token-tracker.d.ts +45 -0
- package/dist/utils/token-tracker.d.ts.map +1 -0
- package/dist/utils/token-tracker.js +107 -0
- package/dist/utils/token-tracker.js.map +1 -0
- package/dist/utils/validation.d.ts +5 -5
- package/dist/utils/validation.d.ts.map +1 -1
- package/dist/utils/validation.js +10 -6
- package/dist/utils/validation.js.map +1 -1
- package/dist/utils/verbose-toggle.d.ts +33 -0
- package/dist/utils/verbose-toggle.d.ts.map +1 -0
- package/dist/utils/verbose-toggle.js +94 -0
- package/dist/utils/verbose-toggle.js.map +1 -0
- package/package.json +1 -1
- package/src/commands/config.ts +204 -0
- package/src/commands/do.ts +59 -27
- package/src/commands/plan.ts +3 -2
- package/src/core/claude-runner.ts +58 -311
- package/src/core/failure-analyzer.ts +6 -3
- package/src/core/git.ts +10 -3
- package/src/core/pull-request.ts +7 -4
- package/src/core/shutdown-handler.ts +0 -5
- package/src/index.ts +2 -0
- package/src/parsers/stream-renderer.ts +55 -8
- package/src/prompts/config-docs.md +331 -0
- package/src/prompts/execution.ts +13 -1
- package/src/types/config.ts +156 -8
- package/src/utils/config.ts +335 -21
- package/src/utils/name-generator.ts +84 -71
- package/src/utils/terminal-symbols.ts +68 -0
- package/src/utils/token-tracker.ts +135 -0
- package/src/utils/validation.ts +15 -10
- package/src/utils/verbose-toggle.ts +103 -0
- package/tests/unit/claude-runner.test.ts +216 -403
- package/tests/unit/config-command.test.ts +163 -0
- package/tests/unit/config.test.ts +608 -30
- package/tests/unit/name-generator.test.ts +99 -75
- package/tests/unit/pull-request.test.ts +2 -0
- package/tests/unit/stream-renderer.test.ts +83 -30
- package/tests/unit/terminal-symbols.test.ts +157 -0
- package/tests/unit/token-tracker.test.ts +352 -0
- package/tests/unit/verbose-toggle.test.ts +204 -0
- package/RAF/ahrtxf-session-sentinel/decisions.md +0 -19
- package/RAF/ahrtxf-session-sentinel/input.md +0 -1
- package/RAF/ahrtxf-session-sentinel/outcomes/01-capture-session-id.md +0 -37
- package/RAF/ahrtxf-session-sentinel/outcomes/02-resume-flag.md +0 -45
- package/RAF/ahrtxf-session-sentinel/plans/01-capture-session-id.md +0 -41
- package/RAF/ahrtxf-session-sentinel/plans/02-resume-flag.md +0 -51
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
# Task: Capture Session ID from Claude CLI Output
|
|
2
|
-
|
|
3
|
-
## Objective
|
|
4
|
-
Extract and store the Claude session ID from stream-json output in both verbose and non-interactive execution modes.
|
|
5
|
-
|
|
6
|
-
## Context
|
|
7
|
-
Claude CLI emits a `session_id` in its `system.init` NDJSON event when using `--output-format stream-json`. RAF currently discards this event entirely. We need to capture and surface this ID so it can be used for session resumption and debugging.
|
|
8
|
-
|
|
9
|
-
## Requirements
|
|
10
|
-
- Unify both `run()` (non-interactive) and `runVerbose()` methods to use `--output-format stream-json` so that the system init event is always available
|
|
11
|
-
- In non-verbose mode, parse NDJSON events silently (extract textContent for output accumulation and detect completion markers) without rendering anything to stdout
|
|
12
|
-
- In verbose mode, continue rendering stream events to stdout as before
|
|
13
|
-
- Extract `session_id` from the `system.init` event (first event in the stream)
|
|
14
|
-
- Add `sessionId?: string` field to the `RunResult` type returned by both `run()` and `runVerbose()`
|
|
15
|
-
- Modify `renderStreamEvent()` in `stream-renderer.ts` to return the session_id when it encounters a system init event, rather than discarding it
|
|
16
|
-
- When a session is interrupted (Ctrl+C, timeout, context overflow), print the session ID to terminal: `Session ID: <id>` so the user can copy it
|
|
17
|
-
- Add tests for the session ID extraction from system init events
|
|
18
|
-
- Add tests verifying session ID is included in RunResult
|
|
19
|
-
|
|
20
|
-
## Implementation Steps
|
|
21
|
-
1. Update the `RunResult` type to include an optional `sessionId` field
|
|
22
|
-
2. Modify `renderStreamEvent()` to extract and return `session_id` from system init events (add a new field to the return type, e.g. `sessionId?: string`)
|
|
23
|
-
3. Refactor `run()` to use `--output-format stream-json` internally, parsing NDJSON lines the same way `runVerbose()` does, but without writing display output to stdout
|
|
24
|
-
4. In both `run()` and `runVerbose()`, capture the session_id from the first system init event and include it in the returned `RunResult`
|
|
25
|
-
5. In the shutdown handler and timeout/overflow paths, print the captured session ID to the terminal before exiting
|
|
26
|
-
6. Write unit tests for session ID extraction from stream events
|
|
27
|
-
7. Write integration-style tests verifying RunResult includes sessionId
|
|
28
|
-
|
|
29
|
-
## Acceptance Criteria
|
|
30
|
-
- [ ] `run()` uses stream-json format internally and parses events silently
|
|
31
|
-
- [ ] `runVerbose()` continues to display stream events as before
|
|
32
|
-
- [ ] Both methods return `sessionId` in `RunResult` when available
|
|
33
|
-
- [ ] On interruption (Ctrl+C, timeout, overflow), session ID is printed to terminal
|
|
34
|
-
- [ ] Existing tests continue to pass
|
|
35
|
-
- [ ] New tests cover session ID extraction
|
|
36
|
-
|
|
37
|
-
## Notes
|
|
38
|
-
- The system init event format is: `{ type: 'system', subtype: 'init', session_id: string, tools: string[], model: string }`
|
|
39
|
-
- Currently `stream-renderer.ts` line 96 returns `{ display: '', textContent: '' }` for all system events — this is where extraction should happen
|
|
40
|
-
- The `run()` method currently uses plain text output with `child_process.spawn` — it needs to switch to stream-json parsing similar to `runVerbose()`. Consider extracting shared NDJSON parsing logic to avoid duplication.
|
|
41
|
-
- Be careful: `run()` has its own completion marker detection and timeout logic that must continue to work with the new stream-json parsing
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
# Task: Add --resume Flag to raf do Command
|
|
2
|
-
|
|
3
|
-
## Objective
|
|
4
|
-
Add a `--resume` option to `raf do` that resumes an interrupted Claude session for a specific task.
|
|
5
|
-
|
|
6
|
-
## Context
|
|
7
|
-
After task 01 captures the session ID and displays it on interruption, users need a way to actually resume the interrupted session. This task adds `raf do <project> --resume <session-id>` which passes Claude CLI's `--resume` flag to continue a session from where it left off.
|
|
8
|
-
|
|
9
|
-
## Dependencies
|
|
10
|
-
01
|
|
11
|
-
|
|
12
|
-
## Requirements
|
|
13
|
-
- Add `--resume <session-id>` option to the `raf do` command in Commander.js
|
|
14
|
-
- When `--resume` is provided, RAF should:
|
|
15
|
-
1. Identify the task to resume — find the first task that is in-progress (has no outcome file, or has a partial/missing completion marker)
|
|
16
|
-
2. Skip the normal task execution flow and instead spawn Claude with `--resume <session-id>` flag
|
|
17
|
-
3. Do NOT pass `-p` (prompt), `--append-system-prompt`, or `--model` flags — rely on Claude's session state to restore these
|
|
18
|
-
4. DO pass `--dangerously-skip-permissions` as it's required for non-interactive operation
|
|
19
|
-
5. Still use `--output-format stream-json` so we can capture the new session's events and detect completion
|
|
20
|
-
6. Continue monitoring for completion markers and outcome file as usual
|
|
21
|
-
- After the resumed session completes, normal post-task flow should apply (outcome validation, commit verification, next task, etc.)
|
|
22
|
-
- If `--resume` is used with `--worktree`, ensure the CWD is set to the worktree path
|
|
23
|
-
- Print a clear message indicating which task is being resumed: `Resuming task <id> with session <session-id>`
|
|
24
|
-
- Add a new method to `ClaudeRunner` (e.g. `runResume(sessionId, options)`) that spawns Claude with the `--resume` flag
|
|
25
|
-
- Cover the new flag and resume method with tests
|
|
26
|
-
|
|
27
|
-
## Implementation Steps
|
|
28
|
-
1. Add `--resume <session-id>` option to the `do` command definition in `src/commands/do.ts`
|
|
29
|
-
2. Add a `runResume()` method to `ClaudeRunner` that spawns Claude with `--resume <session-id> --dangerously-skip-permissions --output-format stream-json` and the same completion monitoring as existing methods
|
|
30
|
-
3. In the task execution loop, when `--resume` is provided:
|
|
31
|
-
- Determine the current task (first task without a valid outcome)
|
|
32
|
-
- Call `runResume()` instead of the normal `run()`/`runVerbose()` method
|
|
33
|
-
- After the resumed task completes, clear the `--resume` flag so subsequent tasks use normal execution
|
|
34
|
-
4. Handle edge cases: invalid session ID format, all tasks already complete, resumed session fails
|
|
35
|
-
5. Write tests for the new `runResume()` method
|
|
36
|
-
6. Write tests for the `--resume` flag integration in the do command
|
|
37
|
-
|
|
38
|
-
## Acceptance Criteria
|
|
39
|
-
- [ ] `raf do <project> --resume <session-id>` resumes the interrupted session
|
|
40
|
-
- [ ] Claude is spawned with `--resume` flag and without prompt/model/system-prompt flags
|
|
41
|
-
- [ ] Completion monitoring works the same as normal execution
|
|
42
|
-
- [ ] After resumed task completes, subsequent tasks run normally
|
|
43
|
-
- [ ] Works with `--worktree` mode
|
|
44
|
-
- [ ] Clear user-facing message on resume start
|
|
45
|
-
- [ ] Tests cover resume path
|
|
46
|
-
|
|
47
|
-
## Notes
|
|
48
|
-
- Claude CLI's `--resume` flag restores the full session context including the system prompt, so we must NOT pass those flags again (they may conflict or be rejected)
|
|
49
|
-
- The `--resume` flag only applies to a single task — after it completes (or fails), remaining tasks use normal execution
|
|
50
|
-
- Consider what happens if the user provides a session ID for a task that already completed — should gracefully handle this
|
|
51
|
-
- Check Claude CLI docs/help to verify exact `--resume` flag syntax: `claude --resume <session-id>`
|