aiwcli 0.12.3 → 0.12.7

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 (125) hide show
  1. package/bin/dev.cmd +3 -3
  2. package/bin/dev.js +16 -16
  3. package/bin/run.cmd +3 -3
  4. package/bin/run.js +21 -21
  5. package/dist/commands/branch.js +7 -2
  6. package/dist/lib/bmad-installer.js +37 -37
  7. package/dist/lib/terminal.d.ts +2 -0
  8. package/dist/lib/terminal.js +57 -7
  9. package/dist/templates/CLAUDE.md +205 -205
  10. package/dist/templates/_shared/.claude/commands/handoff-resume.md +12 -64
  11. package/dist/templates/_shared/.claude/commands/handoff.md +12 -198
  12. package/dist/templates/_shared/.claude/settings.json +65 -65
  13. package/dist/templates/_shared/.codex/workflows/handoff.md +226 -226
  14. package/dist/templates/_shared/.windsurf/workflows/handoff.md +226 -226
  15. package/dist/templates/_shared/handoff-system/CLAUDE.md +421 -0
  16. package/dist/templates/_shared/{lib-ts/handoff → handoff-system/lib}/document-generator.ts +215 -216
  17. package/dist/templates/_shared/{lib-ts/handoff → handoff-system/lib}/handoff-reader.ts +157 -158
  18. package/dist/templates/_shared/{scripts → handoff-system/scripts}/resume_handoff.ts +373 -373
  19. package/dist/templates/_shared/{scripts → handoff-system/scripts}/save_handoff.ts +469 -358
  20. package/dist/templates/_shared/handoff-system/workflows/handoff-resume.md +66 -0
  21. package/dist/templates/_shared/{workflows → handoff-system/workflows}/handoff.md +254 -254
  22. package/dist/templates/_shared/hooks-ts/_utils/git-state.ts +2 -2
  23. package/dist/templates/_shared/hooks-ts/archive_plan.ts +159 -159
  24. package/dist/templates/_shared/hooks-ts/context_monitor.ts +147 -147
  25. package/dist/templates/_shared/hooks-ts/file-suggestion.ts +128 -128
  26. package/dist/templates/_shared/hooks-ts/pre_compact.ts +49 -49
  27. package/dist/templates/_shared/hooks-ts/session_end.ts +196 -183
  28. package/dist/templates/_shared/hooks-ts/session_start.ts +163 -151
  29. package/dist/templates/_shared/hooks-ts/task_create_capture.ts +48 -48
  30. package/dist/templates/_shared/hooks-ts/task_update_capture.ts +74 -74
  31. package/dist/templates/_shared/hooks-ts/user_prompt_submit.ts +93 -93
  32. package/dist/templates/_shared/lib-ts/CLAUDE.md +367 -367
  33. package/dist/templates/_shared/lib-ts/base/atomic-write.ts +138 -138
  34. package/dist/templates/_shared/lib-ts/base/constants.ts +303 -303
  35. package/dist/templates/_shared/lib-ts/base/git-state.ts +58 -58
  36. package/dist/templates/_shared/lib-ts/base/hook-utils.ts +582 -582
  37. package/dist/templates/_shared/lib-ts/base/inference.ts +301 -301
  38. package/dist/templates/_shared/lib-ts/base/logger.ts +247 -247
  39. package/dist/templates/_shared/lib-ts/base/state-io.ts +202 -130
  40. package/dist/templates/_shared/lib-ts/base/stop-words.ts +184 -184
  41. package/dist/templates/_shared/lib-ts/base/subprocess-utils.ts +56 -0
  42. package/dist/templates/_shared/lib-ts/base/utils.ts +184 -184
  43. package/dist/templates/_shared/lib-ts/context/context-formatter.ts +566 -560
  44. package/dist/templates/_shared/lib-ts/context/context-selector.ts +524 -515
  45. package/dist/templates/_shared/lib-ts/context/context-store.ts +712 -668
  46. package/dist/templates/_shared/lib-ts/context/plan-manager.ts +312 -312
  47. package/dist/templates/_shared/lib-ts/context/task-tracker.ts +185 -185
  48. package/dist/templates/_shared/lib-ts/package.json +20 -20
  49. package/dist/templates/_shared/lib-ts/templates/formatters.ts +102 -102
  50. package/dist/templates/_shared/lib-ts/templates/plan-context.ts +58 -58
  51. package/dist/templates/_shared/lib-ts/tsconfig.json +13 -13
  52. package/dist/templates/_shared/lib-ts/types.ts +186 -180
  53. package/dist/templates/_shared/scripts/resolve_context.ts +33 -33
  54. package/dist/templates/_shared/scripts/status_line.ts +690 -690
  55. package/dist/templates/cc-native/.claude/commands/{rlm → cc-native/rlm}/ask.md +136 -136
  56. package/dist/templates/cc-native/.claude/commands/{rlm → cc-native/rlm}/index.md +21 -21
  57. package/dist/templates/cc-native/.claude/commands/{rlm → cc-native/rlm}/overview.md +56 -56
  58. package/dist/templates/cc-native/.claude/commands/cc-native/specdev.md +10 -10
  59. package/dist/templates/cc-native/.windsurf/workflows/cc-native/fix.md +8 -8
  60. package/dist/templates/cc-native/.windsurf/workflows/cc-native/implement.md +8 -8
  61. package/dist/templates/cc-native/.windsurf/workflows/cc-native/research.md +8 -8
  62. package/dist/templates/cc-native/CC-NATIVE-README.md +189 -189
  63. package/dist/templates/cc-native/TEMPLATE-SCHEMA.md +304 -304
  64. package/dist/templates/cc-native/_cc-native/agents/CLAUDE.md +143 -143
  65. package/dist/templates/cc-native/_cc-native/agents/PLAN-ORCHESTRATOR.md +213 -213
  66. package/dist/templates/cc-native/_cc-native/agents/plan-questions/PLAN-QUESTIONER.md +70 -70
  67. package/dist/templates/cc-native/_cc-native/cc-native.config.json +96 -96
  68. package/dist/templates/cc-native/_cc-native/hooks/CLAUDE.md +247 -247
  69. package/dist/templates/cc-native/_cc-native/hooks/cc-native-plan-review.ts +76 -76
  70. package/dist/templates/cc-native/_cc-native/hooks/enhance_plan_post_subagent.ts +54 -54
  71. package/dist/templates/cc-native/_cc-native/hooks/enhance_plan_post_write.ts +51 -51
  72. package/dist/templates/cc-native/_cc-native/hooks/mark_questions_asked.ts +53 -53
  73. package/dist/templates/cc-native/_cc-native/hooks/plan_questions_early.ts +61 -61
  74. package/dist/templates/cc-native/_cc-native/lib-ts/agent-selection.ts +163 -163
  75. package/dist/templates/cc-native/_cc-native/lib-ts/aggregate-agents.ts +156 -156
  76. package/dist/templates/cc-native/_cc-native/lib-ts/artifacts/format.ts +597 -597
  77. package/dist/templates/cc-native/_cc-native/lib-ts/artifacts/index.ts +26 -26
  78. package/dist/templates/cc-native/_cc-native/lib-ts/artifacts/tracker.ts +107 -107
  79. package/dist/templates/cc-native/_cc-native/lib-ts/artifacts/write.ts +119 -119
  80. package/dist/templates/cc-native/_cc-native/lib-ts/artifacts.ts +21 -21
  81. package/dist/templates/cc-native/_cc-native/lib-ts/cc-native-state.ts +319 -319
  82. package/dist/templates/cc-native/_cc-native/lib-ts/cli-output-parser.ts +144 -144
  83. package/dist/templates/cc-native/_cc-native/lib-ts/config.ts +57 -57
  84. package/dist/templates/cc-native/_cc-native/lib-ts/constants.ts +83 -83
  85. package/dist/templates/cc-native/_cc-native/lib-ts/corroboration.ts +119 -119
  86. package/dist/templates/cc-native/_cc-native/lib-ts/debug.ts +79 -79
  87. package/dist/templates/cc-native/_cc-native/lib-ts/graduation.ts +132 -132
  88. package/dist/templates/cc-native/_cc-native/lib-ts/index.ts +116 -116
  89. package/dist/templates/cc-native/_cc-native/lib-ts/json-parser.ts +168 -168
  90. package/dist/templates/cc-native/_cc-native/lib-ts/orchestrator.ts +70 -70
  91. package/dist/templates/cc-native/_cc-native/lib-ts/output-builder.ts +130 -130
  92. package/dist/templates/cc-native/_cc-native/lib-ts/plan-discovery.ts +80 -80
  93. package/dist/templates/cc-native/_cc-native/lib-ts/plan-enhancement.ts +41 -41
  94. package/dist/templates/cc-native/_cc-native/lib-ts/plan-questions.ts +101 -101
  95. package/dist/templates/cc-native/_cc-native/lib-ts/review-pipeline.ts +511 -511
  96. package/dist/templates/cc-native/_cc-native/lib-ts/reviewers/agent.ts +71 -71
  97. package/dist/templates/cc-native/_cc-native/lib-ts/reviewers/base/base-agent.ts +217 -217
  98. package/dist/templates/cc-native/_cc-native/lib-ts/reviewers/index.ts +12 -12
  99. package/dist/templates/cc-native/_cc-native/lib-ts/reviewers/providers/claude-agent.ts +66 -65
  100. package/dist/templates/cc-native/_cc-native/lib-ts/reviewers/providers/codex-agent.ts +184 -184
  101. package/dist/templates/cc-native/_cc-native/lib-ts/reviewers/providers/gemini-agent.ts +39 -39
  102. package/dist/templates/cc-native/_cc-native/lib-ts/reviewers/providers/orchestrator-claude-agent.ts +196 -195
  103. package/dist/templates/cc-native/_cc-native/lib-ts/reviewers/schemas.ts +201 -201
  104. package/dist/templates/cc-native/_cc-native/lib-ts/reviewers/types.ts +21 -21
  105. package/dist/templates/cc-native/_cc-native/lib-ts/rlm/CLAUDE.md +480 -480
  106. package/dist/templates/cc-native/_cc-native/lib-ts/rlm/embedding-indexer.ts +287 -287
  107. package/dist/templates/cc-native/_cc-native/lib-ts/rlm/hyde.ts +148 -148
  108. package/dist/templates/cc-native/_cc-native/lib-ts/rlm/index.ts +54 -54
  109. package/dist/templates/cc-native/_cc-native/lib-ts/rlm/logger.ts +58 -58
  110. package/dist/templates/cc-native/_cc-native/lib-ts/rlm/ollama-client.ts +208 -208
  111. package/dist/templates/cc-native/_cc-native/lib-ts/rlm/retrieval-pipeline.ts +460 -460
  112. package/dist/templates/cc-native/_cc-native/lib-ts/rlm/transcript-indexer.ts +446 -447
  113. package/dist/templates/cc-native/_cc-native/lib-ts/rlm/transcript-loader.ts +280 -280
  114. package/dist/templates/cc-native/_cc-native/lib-ts/rlm/transcript-searcher.ts +274 -274
  115. package/dist/templates/cc-native/_cc-native/lib-ts/rlm/types.ts +201 -201
  116. package/dist/templates/cc-native/_cc-native/lib-ts/rlm/vector-store.ts +278 -278
  117. package/dist/templates/cc-native/_cc-native/lib-ts/settings.ts +184 -184
  118. package/dist/templates/cc-native/_cc-native/lib-ts/state.ts +275 -275
  119. package/dist/templates/cc-native/_cc-native/lib-ts/tsconfig.json +18 -18
  120. package/dist/templates/cc-native/_cc-native/lib-ts/types.ts +329 -329
  121. package/dist/templates/cc-native/_cc-native/lib-ts/verdict.ts +72 -72
  122. package/dist/templates/cc-native/_cc-native/workflows/specdev.md +9 -9
  123. package/oclif.manifest.json +1 -1
  124. package/package.json +108 -108
  125. package/dist/templates/cc-native/_cc-native/lib-ts/nul +0 -3
@@ -1,58 +1,58 @@
1
- /**
2
- * Plan evaluation guidance template.
3
- * Injected as context to guide the Plan agent during plan creation.
4
- */
5
-
6
- export function getEvaluationContextReminder(): string {
7
- return `## Write This Plan for a Different Agent
8
-
9
- The agent executing this plan has zero context from this conversation — no chat history, no memory of files explored or decisions made.
10
-
11
- Write as if you are that agent. What would you need?
12
-
13
- ### Structure
14
-
15
- \`\`\`
16
- # Plan: [descriptive title]
17
-
18
- ## Background
19
- Why this change is needed (2-3 sentences of motivation)
20
-
21
- ## Task
22
- What exactly to build or change
23
-
24
- ## Files
25
- **Modify:**
26
- - \`exact/path/to/file.ext\` — What changes and why
27
-
28
- **Reference:**
29
- - \`exact/path/to/reference.ext\` — Why relevant (e.g., "pattern to follow at lines 12-30")
30
-
31
- ## Steps
32
- Numbered steps with specific details. For each step, consider whether any of the skills available in your system-reminder messages would help the implementation agent — if so, reference the skill inline at the point of use.
33
-
34
- 1. [Specific action with function names, patterns, or code snippets]
35
- 2. [Enough detail for someone who never saw this conversation]
36
-
37
- ## Constraints
38
- Technical requirements, preferences, or limitations discovered during planning
39
-
40
- ## Verification
41
- Binary-testable checks the implementation agent runs to confirm success. Reference relevant skills inline where they aid verification.
42
-
43
- ## Decisions Worth Preserving
44
- Decisions made during this session that would be lost without documentation. Focus on:
45
- - What was chosen and why the alternatives were rejected
46
- - Constraints that aren't obvious from the code itself
47
- - Patterns discovered that prevent future mistakes
48
-
49
- The implementation agent should document these so the next session inherits what this session learned.
50
- \`\`\`
51
-
52
- ### Self-Check
53
- - [ ] Could I execute this plan having never seen this conversation?
54
- - [ ] Are all file paths exact (not "the auth file")?
55
- - [ ] Are implementation details specific (not "use the approach we discussed")?
56
- - [ ] Are relevant skills referenced where they add value?
57
- - [ ] Are key decisions captured so they survive this session?`;
58
- }
1
+ /**
2
+ * Plan evaluation guidance template.
3
+ * Injected as context to guide the Plan agent during plan creation.
4
+ */
5
+
6
+ export function getEvaluationContextReminder(): string {
7
+ return `## Write This Plan for a Different Agent
8
+
9
+ The agent executing this plan has zero context from this conversation — no chat history, no memory of files explored or decisions made.
10
+
11
+ Write as if you are that agent. What would you need?
12
+
13
+ ### Structure
14
+
15
+ \`\`\`
16
+ # Plan: [descriptive title]
17
+
18
+ ## Background
19
+ Why this change is needed (2-3 sentences of motivation)
20
+
21
+ ## Task
22
+ What exactly to build or change
23
+
24
+ ## Files
25
+ **Modify:**
26
+ - \`exact/path/to/file.ext\` — What changes and why
27
+
28
+ **Reference:**
29
+ - \`exact/path/to/reference.ext\` — Why relevant (e.g., "pattern to follow at lines 12-30")
30
+
31
+ ## Steps
32
+ Numbered steps with specific details. For each step, consider whether any of the skills available in your system-reminder messages would help the implementation agent — if so, reference the skill inline at the point of use.
33
+
34
+ 1. [Specific action with function names, patterns, or code snippets]
35
+ 2. [Enough detail for someone who never saw this conversation]
36
+
37
+ ## Constraints
38
+ Technical requirements, preferences, or limitations discovered during planning
39
+
40
+ ## Verification
41
+ Binary-testable checks the implementation agent runs to confirm success. Reference relevant skills inline where they aid verification.
42
+
43
+ ## Decisions Worth Preserving
44
+ Decisions made during this session that would be lost without documentation. Focus on:
45
+ - What was chosen and why the alternatives were rejected
46
+ - Constraints that aren't obvious from the code itself
47
+ - Patterns discovered that prevent future mistakes
48
+
49
+ The implementation agent should document these so the next session inherits what this session learned.
50
+ \`\`\`
51
+
52
+ ### Self-Check
53
+ - [ ] Could I execute this plan having never seen this conversation?
54
+ - [ ] Are all file paths exact (not "the auth file")?
55
+ - [ ] Are implementation details specific (not "use the approach we discussed")?
56
+ - [ ] Are relevant skills referenced where they add value?
57
+ - [ ] Are key decisions captured so they survive this session?`;
58
+ }
@@ -1,13 +1,13 @@
1
- {
2
- "compilerOptions": {
3
- "target": "es2022",
4
- "module": "Node16",
5
- "moduleResolution": "node16",
6
- "strict": true,
7
- "noUncheckedIndexedAccess": true,
8
- "outDir": "dist",
9
- "rootDir": ".",
10
- "declaration": true
11
- },
12
- "include": ["./**/*.ts"]
13
- }
1
+ {
2
+ "compilerOptions": {
3
+ "target": "es2022",
4
+ "module": "Node16",
5
+ "moduleResolution": "node16",
6
+ "strict": true,
7
+ "noUncheckedIndexedAccess": true,
8
+ "outDir": "dist",
9
+ "rootDir": ".",
10
+ "declaration": true
11
+ },
12
+ "include": ["./**/*.ts"]
13
+ }
@@ -1,180 +1,186 @@
1
- /**
2
- * Shared type definitions for the lib-ts library.
3
- * All field names use snake_case for JSON backward compatibility with state.json.
4
- * See SPEC.md §1 for full behavioral specification.
5
- */
6
-
7
- // §1.1
8
- export type Mode = "idle" | "has_plan" | "has_handoff" | "active";
9
-
10
- export interface ContextState {
11
- id: string;
12
- status: "active" | "completed";
13
- summary: string;
14
- method: string;
15
- tags: string[];
16
- created_at: string;
17
- last_active: string;
18
- mode: Mode;
19
- plan_path: string | null;
20
- plan_hash: string | null;
21
- plan_signature: string | null;
22
- plan_id: string | null;
23
- plan_anchors: string[];
24
- plan_consumed: boolean;
25
- plan_hash_consumed: string | null;
26
- handoff_path: string | null;
27
- handoff_consumed: boolean;
28
- session_ids: string[];
29
- last_session: LastSession | null;
30
- tasks: Task[];
31
- }
32
-
33
- // §1.2
34
- export interface GitState {
35
- branch?: string;
36
- uncommitted_files?: string[];
37
- last_commit_short?: string;
38
- }
39
-
40
- export interface LastSession {
41
- session_id?: string;
42
- saved_at?: string;
43
- save_reason?: string;
44
- transcript_path?: string;
45
- context_remaining_pct?: number;
46
- context_warnings_fired?: number[];
47
- git_state?: GitState;
48
- }
49
-
50
- // §1.3
51
- export interface Task {
52
- id: string;
53
- subject: string;
54
- description: string;
55
- active_form: string;
56
- status: "pending" | "in_progress" | "completed" | "blocked";
57
- created_at: string;
58
- completed_at: string | null;
59
- evidence: string;
60
- work_summary: string;
61
- files_changed: string[];
62
- session_id?: string;
63
- }
64
-
65
- // §1.4
66
- export interface IndexEntry {
67
- summary: string;
68
- mode: string;
69
- last_active: string;
70
- }
71
-
72
- export interface IndexFile {
73
- version: "3.0";
74
- updated_at: string;
75
- sessions: Record<string, string>;
76
- contexts: Record<string, IndexEntry>;
77
- }
78
-
79
- // §1.5
80
- export interface LogEntry {
81
- ts: string;
82
- level: "debug" | "info" | "warn" | "error";
83
- hook: string;
84
- msg: string;
85
- component?: string;
86
- data?: any;
87
- tb?: string;
88
- }
89
-
90
- // §1.6
91
- export interface HookInput {
92
- hook_event_name: string;
93
- tool_name?: string;
94
- tool_input?: Record<string, any>;
95
- tool_result?: string;
96
- session_id?: string;
97
- cwd?: string;
98
- transcript_path?: string;
99
- context_window?: {
100
- current_usage?: {
101
- cache_read_input_tokens?: number;
102
- input_tokens?: number;
103
- cache_creation_input_tokens?: number;
104
- output_tokens?: number;
105
- };
106
- context_window_size?: number;
107
- };
108
- permission_mode?: string;
109
- source?: string;
110
- }
111
-
112
- // §1.7 — Three hook output patterns (see hook-utils.ts for emit functions)
113
- export interface HookOutput {
114
- // Pattern 1: hookSpecificOutput (PreToolUse, PostToolUse, UserPromptSubmit, etc.)
115
- hookSpecificOutput?: {
116
- hookEventName?: string;
117
- additionalContext?: string;
118
- permissionDecision?: "allow" | "deny" | "ask";
119
- permissionDecisionReason?: string;
120
- updatedInput?: Record<string, unknown>;
121
- };
122
- // Pattern 2: Top-level decision (UserPromptSubmit, Stop, SubagentStop)
123
- decision?: "block";
124
- reason?: string;
125
- }
126
-
127
- // §1.7b — PermissionRequest output (structurally different from HookOutput)
128
- export interface PermissionRequestOutput {
129
- decision: {
130
- behavior: "allow" | "deny";
131
- message?: string;
132
- updatedInput?: Record<string, unknown>;
133
- updatedPermissions?: Record<string, unknown>;
134
- };
135
- }
136
-
137
- // §1.8
138
- export interface InferenceResult {
139
- success: boolean;
140
- output: string;
141
- error?: string;
142
- latency_ms: number;
143
- }
144
-
145
- // §1.9
146
- export interface HandoffDocument {
147
- context_id: string;
148
- context_summary: string;
149
- session_id: string;
150
- reason: string;
151
- created_at: string;
152
- plan_path: string | null;
153
- context_folder: string;
154
- events_log_path: string;
155
- active_tasks: Task[];
156
- completed_tasks_this_session: Array<{ subject: string }>;
157
- work_summary: string;
158
- next_steps: string[];
159
- important_notes: string[];
160
- file_path: string | null;
161
- }
162
-
163
- // §1.10
164
- export interface HandoffSections {
165
- index: string | null;
166
- deadEnds: string | null;
167
- pending: string | null;
168
- plan: string | null;
169
- decisions: string | null;
170
- completedWork: string | null;
171
- context: string | null;
172
- }
173
-
174
- // §1.11
175
- export interface CaretCommand {
176
- ends: string[];
177
- select: string | null;
178
- new_context_desc: string | null;
179
- remaining_prompt: string;
180
- }
1
+ /**
2
+ * Shared type definitions for the lib-ts library.
3
+ * All field names use snake_case for JSON backward compatibility with state.json.
4
+ * See SPEC.md §1 for full behavioral specification.
5
+ */
6
+
7
+ // §1.1
8
+ export type Mode = "idle" | "has_staged_work" | "active";
9
+
10
+ export interface ContextState {
11
+ id: string;
12
+ status: "active" | "completed";
13
+ summary: string;
14
+ method: string;
15
+ tags: string[];
16
+ created_at: string;
17
+ last_active: string;
18
+ mode: Mode;
19
+ plan_path: string | null;
20
+ plan_hash: string | null;
21
+ plan_signature: string | null;
22
+ plan_id: string | null;
23
+ plan_anchors: string[];
24
+ plan_hash_consumed: string | null;
25
+ handoff_path: string | null;
26
+ // Unified lifecycle fields (v0.13.0+)
27
+ work_consumed: boolean; // Replaces plan_consumed + handoff_consumed
28
+ next_artifact_type: "plan" | "handoff" | null; // Explicit artifact type for has_staged_work mode
29
+ // Deprecated fields (kept for migration)
30
+ /** @deprecated Use work_consumed instead */
31
+ plan_consumed?: boolean;
32
+ /** @deprecated Use work_consumed instead */
33
+ handoff_consumed?: boolean;
34
+ session_ids: string[];
35
+ last_session: LastSession | null;
36
+ tasks: Task[];
37
+ }
38
+
39
+ // §1.2
40
+ export interface GitState {
41
+ branch?: string;
42
+ uncommitted_files?: string[];
43
+ last_commit_short?: string;
44
+ }
45
+
46
+ export interface LastSession {
47
+ session_id?: string;
48
+ saved_at?: string;
49
+ save_reason?: string;
50
+ transcript_path?: string;
51
+ context_remaining_pct?: number;
52
+ context_warnings_fired?: number[];
53
+ git_state?: GitState;
54
+ }
55
+
56
+ // §1.3
57
+ export interface Task {
58
+ id: string;
59
+ subject: string;
60
+ description: string;
61
+ active_form: string;
62
+ status: "pending" | "in_progress" | "completed" | "blocked";
63
+ created_at: string;
64
+ completed_at: string | null;
65
+ evidence: string;
66
+ work_summary: string;
67
+ files_changed: string[];
68
+ session_id?: string;
69
+ }
70
+
71
+ // §1.4
72
+ export interface IndexEntry {
73
+ summary: string;
74
+ mode: string;
75
+ last_active: string;
76
+ }
77
+
78
+ export interface IndexFile {
79
+ version: "3.0";
80
+ updated_at: string;
81
+ sessions: Record<string, string>;
82
+ contexts: Record<string, IndexEntry>;
83
+ }
84
+
85
+ // §1.5
86
+ export interface LogEntry {
87
+ ts: string;
88
+ level: "debug" | "info" | "warn" | "error";
89
+ hook: string;
90
+ msg: string;
91
+ component?: string;
92
+ data?: any;
93
+ tb?: string;
94
+ }
95
+
96
+ // §1.6
97
+ export interface HookInput {
98
+ hook_event_name: string;
99
+ tool_name?: string;
100
+ tool_input?: Record<string, any>;
101
+ tool_result?: string;
102
+ session_id?: string;
103
+ cwd?: string;
104
+ transcript_path?: string;
105
+ context_window?: {
106
+ current_usage?: {
107
+ cache_read_input_tokens?: number;
108
+ input_tokens?: number;
109
+ cache_creation_input_tokens?: number;
110
+ output_tokens?: number;
111
+ };
112
+ context_window_size?: number;
113
+ };
114
+ permission_mode?: string;
115
+ source?: string;
116
+ }
117
+
118
+ // §1.7 Three hook output patterns (see hook-utils.ts for emit functions)
119
+ export interface HookOutput {
120
+ // Pattern 1: hookSpecificOutput (PreToolUse, PostToolUse, UserPromptSubmit, etc.)
121
+ hookSpecificOutput?: {
122
+ hookEventName?: string;
123
+ additionalContext?: string;
124
+ permissionDecision?: "allow" | "deny" | "ask";
125
+ permissionDecisionReason?: string;
126
+ updatedInput?: Record<string, unknown>;
127
+ };
128
+ // Pattern 2: Top-level decision (UserPromptSubmit, Stop, SubagentStop)
129
+ decision?: "block";
130
+ reason?: string;
131
+ }
132
+
133
+ // §1.7b — PermissionRequest output (structurally different from HookOutput)
134
+ export interface PermissionRequestOutput {
135
+ decision: {
136
+ behavior: "allow" | "deny";
137
+ message?: string;
138
+ updatedInput?: Record<string, unknown>;
139
+ updatedPermissions?: Record<string, unknown>;
140
+ };
141
+ }
142
+
143
+ // §1.8
144
+ export interface InferenceResult {
145
+ success: boolean;
146
+ output: string;
147
+ error?: string;
148
+ latency_ms: number;
149
+ }
150
+
151
+ // §1.9
152
+ export interface HandoffDocument {
153
+ context_id: string;
154
+ context_summary: string;
155
+ session_id: string;
156
+ reason: string;
157
+ created_at: string;
158
+ plan_path: string | null;
159
+ context_folder: string;
160
+ events_log_path: string;
161
+ active_tasks: Task[];
162
+ completed_tasks_this_session: Array<{ subject: string }>;
163
+ work_summary: string;
164
+ next_steps: string[];
165
+ important_notes: string[];
166
+ file_path: string | null;
167
+ }
168
+
169
+ // §1.10
170
+ export interface HandoffSections {
171
+ index: string | null;
172
+ deadEnds: string | null;
173
+ pending: string | null;
174
+ plan: string | null;
175
+ decisions: string | null;
176
+ completedWork: string | null;
177
+ context: string | null;
178
+ }
179
+
180
+ // §1.11
181
+ export interface CaretCommand {
182
+ ends: string[];
183
+ select: string | null;
184
+ new_context_desc: string | null;
185
+ remaining_prompt: string;
186
+ }
@@ -1,33 +1,33 @@
1
- #!/usr/bin/env bun
2
- /**
3
- * Resolve and print the active context ID.
4
- *
5
- * Usage:
6
- * bun .aiwcli/_shared/scripts/resolve_context.ts
7
- *
8
- * Prints the context ID to stdout. Exits 1 if no active context found.
9
- * Used by command templates (/handoff, /handoff-resume) to programmatically
10
- * get the context ID instead of parsing system reminders.
11
- *
12
- * Requires CLAUDE_SESSION_ID environment variable (set by Claude Code).
13
- */
14
- import { getContextBySessionId } from "../lib-ts/context/context-store.js";
15
- import { getProjectRoot } from "../lib-ts/base/constants.js";
16
- import { eprint } from "../lib-ts/base/utils.js";
17
-
18
- const projectRoot = getProjectRoot(process.cwd());
19
- const sessionId = process.env.CLAUDE_SESSION_ID;
20
-
21
- if (!sessionId) {
22
- eprint("CLAUDE_SESSION_ID not set. This script must be run from within a Claude Code session.");
23
- process.exit(1);
24
- }
25
-
26
- const context = getContextBySessionId(sessionId, projectRoot);
27
-
28
- if (!context) {
29
- eprint(`No context found for session: ${sessionId}`);
30
- process.exit(1);
31
- }
32
-
33
- console.log(context.id);
1
+ #!/usr/bin/env bun
2
+ /**
3
+ * Resolve and print the active context ID.
4
+ *
5
+ * Usage:
6
+ * bun .aiwcli/_shared/scripts/resolve_context.ts
7
+ *
8
+ * Prints the context ID to stdout. Exits 1 if no active context found.
9
+ * Used by command templates (/handoff, /handoff-resume) to programmatically
10
+ * get the context ID instead of parsing system reminders.
11
+ *
12
+ * Requires CLAUDE_SESSION_ID environment variable (set by Claude Code).
13
+ */
14
+ import { getContextBySessionId } from "../lib-ts/context/context-store.js";
15
+ import { getProjectRoot } from "../lib-ts/base/constants.js";
16
+ import { eprint } from "../lib-ts/base/utils.js";
17
+
18
+ const projectRoot = getProjectRoot(process.cwd());
19
+ const sessionId = process.env.CLAUDE_SESSION_ID;
20
+
21
+ if (!sessionId) {
22
+ eprint("CLAUDE_SESSION_ID not set. This script must be run from within a Claude Code session.");
23
+ process.exit(1);
24
+ }
25
+
26
+ const context = getContextBySessionId(sessionId, projectRoot);
27
+
28
+ if (!context) {
29
+ eprint(`No context found for session: ${sessionId}`);
30
+ process.exit(1);
31
+ }
32
+
33
+ console.log(context.id);