aiwcli 0.10.3 → 0.11.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/bin/run.js +1 -1
- package/dist/commands/clear.js +28 -131
- package/dist/commands/init/index.js +3 -3
- package/dist/lib/gitignore-manager.d.ts +32 -0
- package/dist/lib/gitignore-manager.js +141 -2
- package/dist/templates/CLAUDE.md +8 -8
- package/dist/templates/_shared/.claude/commands/handoff-resume.md +64 -0
- package/dist/templates/_shared/.claude/commands/handoff.md +16 -10
- package/dist/templates/_shared/.claude/settings.json +7 -7
- package/dist/templates/_shared/hooks-ts/_utils/git-state.ts +2 -0
- package/dist/templates/_shared/hooks-ts/archive_plan.ts +159 -0
- package/dist/templates/_shared/hooks-ts/context_monitor.ts +147 -0
- package/dist/templates/_shared/hooks-ts/file-suggestion.ts +130 -0
- package/dist/templates/_shared/hooks-ts/pre_compact.ts +49 -0
- package/dist/templates/_shared/hooks-ts/session_end.ts +104 -0
- package/dist/templates/_shared/hooks-ts/session_start.ts +144 -0
- package/dist/templates/_shared/hooks-ts/task_create_capture.ts +48 -0
- package/dist/templates/_shared/hooks-ts/task_update_capture.ts +74 -0
- package/dist/templates/_shared/hooks-ts/user_prompt_submit.ts +83 -0
- package/dist/templates/_shared/lib-ts/CLAUDE.md +318 -0
- package/dist/templates/_shared/lib-ts/base/atomic-write.ts +12 -12
- package/dist/templates/_shared/lib-ts/base/constants.ts +22 -15
- package/dist/templates/_shared/lib-ts/base/hook-utils.ts +129 -50
- package/dist/templates/_shared/lib-ts/base/inference.ts +28 -21
- package/dist/templates/_shared/lib-ts/base/logger.ts +31 -15
- package/dist/templates/_shared/lib-ts/base/state-io.ts +9 -7
- package/dist/templates/_shared/lib-ts/base/stop-words.ts +131 -131
- package/dist/templates/_shared/lib-ts/base/subprocess-utils.ts +139 -0
- package/dist/templates/_shared/lib-ts/base/utils.ts +69 -69
- package/dist/templates/_shared/lib-ts/context/context-formatter.ts +30 -24
- package/dist/templates/_shared/lib-ts/context/context-selector.ts +50 -32
- package/dist/templates/_shared/lib-ts/context/context-store.ts +76 -48
- package/dist/templates/_shared/lib-ts/context/plan-manager.ts +61 -37
- package/dist/templates/_shared/lib-ts/context/task-tracker.ts +10 -6
- package/dist/templates/_shared/lib-ts/handoff/document-generator.ts +11 -10
- package/dist/templates/_shared/lib-ts/handoff/handoff-reader.ts +159 -0
- package/dist/templates/_shared/lib-ts/templates/formatters.ts +6 -4
- package/dist/templates/_shared/lib-ts/types.ts +68 -55
- package/dist/templates/_shared/scripts/resolve_context.ts +24 -0
- package/dist/templates/_shared/scripts/resume_handoff.ts +321 -0
- package/dist/templates/_shared/scripts/save_handoff.ts +21 -21
- package/dist/templates/_shared/scripts/status_line.ts +733 -0
- package/dist/templates/cc-native/.claude/settings.json +175 -185
- package/dist/templates/cc-native/TEMPLATE-SCHEMA.md +15 -17
- package/dist/templates/cc-native/_cc-native/agents/CLAUDE.md +0 -2
- package/dist/templates/cc-native/_cc-native/hooks/CLAUDE.md +109 -135
- package/dist/templates/cc-native/_cc-native/hooks/add_plan_context.ts +119 -0
- package/dist/templates/cc-native/_cc-native/hooks/cc-native-plan-review.ts +921 -0
- package/dist/templates/cc-native/_cc-native/hooks/plan_questions_early.ts +61 -0
- package/dist/templates/cc-native/_cc-native/lib-ts/aggregate-agents.ts +157 -0
- package/dist/templates/cc-native/_cc-native/lib-ts/artifacts.ts +709 -0
- package/dist/templates/cc-native/_cc-native/lib-ts/cc-native-state.ts +199 -0
- package/dist/templates/cc-native/_cc-native/lib-ts/cli-output-parser.ts +124 -0
- package/dist/templates/cc-native/_cc-native/lib-ts/config.ts +57 -0
- package/dist/templates/cc-native/_cc-native/lib-ts/constants.ts +83 -0
- package/dist/templates/cc-native/_cc-native/lib-ts/debug.ts +80 -0
- package/dist/templates/cc-native/_cc-native/lib-ts/index.ts +119 -0
- package/dist/templates/cc-native/_cc-native/lib-ts/json-parser.ts +162 -0
- package/dist/templates/cc-native/_cc-native/lib-ts/nul +3 -0
- package/dist/templates/cc-native/_cc-native/lib-ts/orchestrator.ts +249 -0
- package/dist/templates/cc-native/_cc-native/lib-ts/reviewers/agent.ts +155 -0
- package/dist/templates/cc-native/_cc-native/lib-ts/reviewers/codex.ts +130 -0
- package/dist/templates/cc-native/_cc-native/lib-ts/reviewers/gemini.ts +106 -0
- package/dist/templates/cc-native/_cc-native/lib-ts/reviewers/index.ts +10 -0
- package/dist/templates/cc-native/_cc-native/lib-ts/reviewers/types.ts +23 -0
- package/dist/templates/cc-native/_cc-native/lib-ts/state.ts +243 -0
- package/dist/templates/cc-native/_cc-native/lib-ts/tsconfig.json +18 -0
- package/dist/templates/cc-native/_cc-native/lib-ts/types.ts +310 -0
- package/dist/templates/cc-native/_cc-native/lib-ts/verdict.ts +72 -0
- package/dist/templates/cc-native/_cc-native/plan-review.config.json +1 -9
- package/oclif.manifest.json +1 -1
- package/package.json +1 -1
- package/dist/templates/_shared/hooks/__init__.py +0 -16
- package/dist/templates/_shared/hooks/__pycache__/__init__.cpython-313.pyc +0 -0
- package/dist/templates/_shared/hooks/__pycache__/archive_plan.cpython-313.pyc +0 -0
- package/dist/templates/_shared/hooks/__pycache__/context_enforcer.cpython-313.pyc +0 -0
- package/dist/templates/_shared/hooks/__pycache__/context_monitor.cpython-313.pyc +0 -0
- package/dist/templates/_shared/hooks/__pycache__/file-suggestion.cpython-313.pyc +0 -0
- package/dist/templates/_shared/hooks/__pycache__/pre_compact.cpython-313.pyc +0 -0
- package/dist/templates/_shared/hooks/__pycache__/session_end.cpython-313.pyc +0 -0
- package/dist/templates/_shared/hooks/__pycache__/session_start.cpython-313.pyc +0 -0
- package/dist/templates/_shared/hooks/__pycache__/task_create_atomicity.cpython-313.pyc +0 -0
- package/dist/templates/_shared/hooks/__pycache__/task_create_capture.cpython-313.pyc +0 -0
- package/dist/templates/_shared/hooks/__pycache__/task_update_capture.cpython-313.pyc +0 -0
- package/dist/templates/_shared/hooks/__pycache__/user_prompt_submit.cpython-313.pyc +0 -0
- package/dist/templates/_shared/hooks/archive_plan.py +0 -177
- package/dist/templates/_shared/hooks/context_monitor.py +0 -270
- package/dist/templates/_shared/hooks/file-suggestion.py +0 -215
- package/dist/templates/_shared/hooks/pre_compact.py +0 -104
- package/dist/templates/_shared/hooks/session_end.py +0 -173
- package/dist/templates/_shared/hooks/session_start.py +0 -206
- package/dist/templates/_shared/hooks/task_create_capture.py +0 -108
- package/dist/templates/_shared/hooks/task_update_capture.py +0 -145
- package/dist/templates/_shared/hooks/user_prompt_submit.py +0 -139
- package/dist/templates/_shared/lib/__init__.py +0 -1
- package/dist/templates/_shared/lib/__pycache__/__init__.cpython-313.pyc +0 -0
- package/dist/templates/_shared/lib/base/__init__.py +0 -65
- package/dist/templates/_shared/lib/base/__pycache__/__init__.cpython-313.pyc +0 -0
- package/dist/templates/_shared/lib/base/__pycache__/atomic_write.cpython-313.pyc +0 -0
- package/dist/templates/_shared/lib/base/__pycache__/constants.cpython-313.pyc +0 -0
- package/dist/templates/_shared/lib/base/__pycache__/hook_utils.cpython-313.pyc +0 -0
- package/dist/templates/_shared/lib/base/__pycache__/inference.cpython-313.pyc +0 -0
- package/dist/templates/_shared/lib/base/__pycache__/logger.cpython-313.pyc +0 -0
- package/dist/templates/_shared/lib/base/__pycache__/stop_words.cpython-313.pyc +0 -0
- package/dist/templates/_shared/lib/base/__pycache__/subprocess_utils.cpython-313.pyc +0 -0
- package/dist/templates/_shared/lib/base/__pycache__/utils.cpython-313.pyc +0 -0
- package/dist/templates/_shared/lib/base/atomic_write.py +0 -180
- package/dist/templates/_shared/lib/base/constants.py +0 -358
- package/dist/templates/_shared/lib/base/hook_utils.py +0 -339
- package/dist/templates/_shared/lib/base/inference.py +0 -307
- package/dist/templates/_shared/lib/base/logger.py +0 -305
- package/dist/templates/_shared/lib/base/stop_words.py +0 -221
- package/dist/templates/_shared/lib/base/subprocess_utils.py +0 -46
- package/dist/templates/_shared/lib/base/utils.py +0 -263
- package/dist/templates/_shared/lib/context/__init__.py +0 -102
- package/dist/templates/_shared/lib/context/__pycache__/__init__.cpython-313.pyc +0 -0
- package/dist/templates/_shared/lib/context/__pycache__/cache.cpython-313.pyc +0 -0
- package/dist/templates/_shared/lib/context/__pycache__/context_extractor.cpython-313.pyc +0 -0
- package/dist/templates/_shared/lib/context/__pycache__/context_formatter.cpython-313.pyc +0 -0
- package/dist/templates/_shared/lib/context/__pycache__/context_manager.cpython-313.pyc +0 -0
- package/dist/templates/_shared/lib/context/__pycache__/context_selector.cpython-313.pyc +0 -0
- package/dist/templates/_shared/lib/context/__pycache__/context_store.cpython-313.pyc +0 -0
- package/dist/templates/_shared/lib/context/__pycache__/discovery.cpython-313.pyc +0 -0
- package/dist/templates/_shared/lib/context/__pycache__/event_log.cpython-313.pyc +0 -0
- package/dist/templates/_shared/lib/context/__pycache__/plan_archive.cpython-313.pyc +0 -0
- package/dist/templates/_shared/lib/context/__pycache__/plan_manager.cpython-313.pyc +0 -0
- package/dist/templates/_shared/lib/context/__pycache__/task_sync.cpython-313.pyc +0 -0
- package/dist/templates/_shared/lib/context/__pycache__/task_tracker.cpython-313.pyc +0 -0
- package/dist/templates/_shared/lib/context/context_formatter.py +0 -317
- package/dist/templates/_shared/lib/context/context_selector.py +0 -508
- package/dist/templates/_shared/lib/context/context_store.py +0 -653
- package/dist/templates/_shared/lib/context/plan_manager.py +0 -303
- package/dist/templates/_shared/lib/context/task_tracker.py +0 -188
- package/dist/templates/_shared/lib/handoff/__init__.py +0 -22
- package/dist/templates/_shared/lib/handoff/__pycache__/__init__.cpython-313.pyc +0 -0
- package/dist/templates/_shared/lib/handoff/__pycache__/document_generator.cpython-313.pyc +0 -0
- package/dist/templates/_shared/lib/handoff/document_generator.py +0 -278
- package/dist/templates/_shared/lib/templates/README.md +0 -206
- package/dist/templates/_shared/lib/templates/__init__.py +0 -36
- package/dist/templates/_shared/lib/templates/__pycache__/__init__.cpython-313.pyc +0 -0
- package/dist/templates/_shared/lib/templates/__pycache__/formatters.cpython-313.pyc +0 -0
- package/dist/templates/_shared/lib/templates/__pycache__/persona_questions.cpython-313.pyc +0 -0
- package/dist/templates/_shared/lib/templates/__pycache__/plan_context.cpython-313.pyc +0 -0
- package/dist/templates/_shared/lib/templates/formatters.py +0 -146
- package/dist/templates/_shared/lib/templates/plan_context.py +0 -73
- package/dist/templates/_shared/scripts/__pycache__/save_handoff.cpython-313.pyc +0 -0
- package/dist/templates/_shared/scripts/__pycache__/status_line.cpython-313.pyc +0 -0
- package/dist/templates/_shared/scripts/save_handoff.py +0 -357
- package/dist/templates/_shared/scripts/status_line.py +0 -716
- package/dist/templates/cc-native/.claude/commands/cc-native/fresh-perspective.md +0 -8
- package/dist/templates/cc-native/.windsurf/workflows/cc-native/fresh-perspective.md +0 -8
- package/dist/templates/cc-native/MIGRATION.md +0 -86
- package/dist/templates/cc-native/_cc-native/hooks/__pycache__/add_plan_context.cpython-313.pyc +0 -0
- package/dist/templates/cc-native/_cc-native/hooks/__pycache__/cc-native-plan-review.cpython-313.pyc +0 -0
- package/dist/templates/cc-native/_cc-native/hooks/__pycache__/mark_questions_asked.cpython-313.pyc +0 -0
- package/dist/templates/cc-native/_cc-native/hooks/__pycache__/plan_accepted.cpython-313.pyc +0 -0
- package/dist/templates/cc-native/_cc-native/hooks/__pycache__/plan_questions_early.cpython-313.pyc +0 -0
- package/dist/templates/cc-native/_cc-native/hooks/__pycache__/suggest-fresh-perspective.cpython-313.pyc +0 -0
- package/dist/templates/cc-native/_cc-native/hooks/add_plan_context.py +0 -130
- package/dist/templates/cc-native/_cc-native/hooks/cc-native-plan-review.py +0 -954
- package/dist/templates/cc-native/_cc-native/hooks/plan_questions_early.py +0 -81
- package/dist/templates/cc-native/_cc-native/hooks/suggest-fresh-perspective.py +0 -340
- package/dist/templates/cc-native/_cc-native/lib/CLAUDE.md +0 -265
- package/dist/templates/cc-native/_cc-native/lib/__init__.py +0 -53
- package/dist/templates/cc-native/_cc-native/lib/__pycache__/__init__.cpython-313.pyc +0 -0
- package/dist/templates/cc-native/_cc-native/lib/__pycache__/atomic_write.cpython-313.pyc +0 -0
- package/dist/templates/cc-native/_cc-native/lib/__pycache__/constants.cpython-313.pyc +0 -0
- package/dist/templates/cc-native/_cc-native/lib/__pycache__/debug.cpython-313.pyc +0 -0
- package/dist/templates/cc-native/_cc-native/lib/__pycache__/orchestrator.cpython-313.pyc +0 -0
- package/dist/templates/cc-native/_cc-native/lib/__pycache__/state.cpython-313.pyc +0 -0
- package/dist/templates/cc-native/_cc-native/lib/__pycache__/utils.cpython-313.pyc +0 -0
- package/dist/templates/cc-native/_cc-native/lib/constants.py +0 -45
- package/dist/templates/cc-native/_cc-native/lib/debug.py +0 -139
- package/dist/templates/cc-native/_cc-native/lib/orchestrator.py +0 -362
- package/dist/templates/cc-native/_cc-native/lib/reviewers/__init__.py +0 -28
- package/dist/templates/cc-native/_cc-native/lib/reviewers/__pycache__/__init__.cpython-313.pyc +0 -0
- package/dist/templates/cc-native/_cc-native/lib/reviewers/__pycache__/agent.cpython-313.pyc +0 -0
- package/dist/templates/cc-native/_cc-native/lib/reviewers/__pycache__/base.cpython-313.pyc +0 -0
- package/dist/templates/cc-native/_cc-native/lib/reviewers/__pycache__/codex.cpython-313.pyc +0 -0
- package/dist/templates/cc-native/_cc-native/lib/reviewers/__pycache__/gemini.cpython-313.pyc +0 -0
- package/dist/templates/cc-native/_cc-native/lib/reviewers/agent.py +0 -215
- package/dist/templates/cc-native/_cc-native/lib/reviewers/base.py +0 -88
- package/dist/templates/cc-native/_cc-native/lib/reviewers/codex.py +0 -124
- package/dist/templates/cc-native/_cc-native/lib/reviewers/gemini.py +0 -108
- package/dist/templates/cc-native/_cc-native/lib/state.py +0 -268
- package/dist/templates/cc-native/_cc-native/lib/utils.py +0 -1071
- package/dist/templates/cc-native/_cc-native/scripts/__pycache__/aggregate_agents.cpython-313.pyc +0 -0
- package/dist/templates/cc-native/_cc-native/scripts/aggregate_agents.py +0 -168
- package/dist/templates/cc-native/_cc-native/workflows/fresh-perspective.md +0 -134
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Handoff reader utilities for programmatic resume.
|
|
3
|
+
*
|
|
4
|
+
* Provides functions to find, read, and parse handoff folders
|
|
5
|
+
* created by save_handoff.ts. Used by resume_handoff.ts script
|
|
6
|
+
* and potentially by session_start hooks.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import * as fs from "node:fs";
|
|
10
|
+
import * as path from "node:path";
|
|
11
|
+
|
|
12
|
+
import { getContextHandoffsDir } from "../base/constants.js";
|
|
13
|
+
import { getContext } from "../context/context-store.js";
|
|
14
|
+
import type { HandoffSections } from "../types.js";
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Find the most recent handoff folder for a context.
|
|
18
|
+
* Lists subdirectories in the handoffs dir, sorts by name
|
|
19
|
+
* (YYYY-MM-DD-HHMM format ensures lexicographic = chronological).
|
|
20
|
+
* Returns full path to most recent folder, or null.
|
|
21
|
+
*/
|
|
22
|
+
export function findLatestHandoff(contextId: string, projectRoot?: string): null | string {
|
|
23
|
+
const handoffsDir = getContextHandoffsDir(contextId, projectRoot);
|
|
24
|
+
|
|
25
|
+
try {
|
|
26
|
+
if (!fs.existsSync(handoffsDir)) return null;
|
|
27
|
+
const entries = fs.readdirSync(handoffsDir, { withFileTypes: true })
|
|
28
|
+
.filter(e => e.isDirectory())
|
|
29
|
+
.map(e => e.name)
|
|
30
|
+
.sort();
|
|
31
|
+
|
|
32
|
+
if (entries.length === 0) return null;
|
|
33
|
+
return path.join(handoffsDir, entries.at(-1)!);
|
|
34
|
+
} catch {
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Read all section files from a handoff folder, structured by priority.
|
|
41
|
+
* Returns content for each file (null if missing/unreadable).
|
|
42
|
+
*/
|
|
43
|
+
export function readHandoffSections(handoffFolder: string): HandoffSections {
|
|
44
|
+
const fileMap: Record<keyof HandoffSections, string> = {
|
|
45
|
+
index: "index.md",
|
|
46
|
+
deadEnds: "dead-ends.md",
|
|
47
|
+
pending: "pending.md",
|
|
48
|
+
plan: "plan.md",
|
|
49
|
+
decisions: "decisions.md",
|
|
50
|
+
completedWork: "completed-work.md",
|
|
51
|
+
context: "context.md",
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
const sections: HandoffSections = {
|
|
55
|
+
index: null,
|
|
56
|
+
deadEnds: null,
|
|
57
|
+
pending: null,
|
|
58
|
+
plan: null,
|
|
59
|
+
decisions: null,
|
|
60
|
+
completedWork: null,
|
|
61
|
+
context: null,
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
for (const [key, filename] of Object.entries(fileMap)) {
|
|
65
|
+
const filePath = path.join(handoffFolder, filename);
|
|
66
|
+
try {
|
|
67
|
+
if (fs.existsSync(filePath)) {
|
|
68
|
+
sections[key as keyof HandoffSections] = fs.readFileSync(filePath, "utf8");
|
|
69
|
+
}
|
|
70
|
+
} catch {
|
|
71
|
+
// graceful — leave as null
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return sections;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Parse the handoff folder name to extract creation timestamp.
|
|
80
|
+
* Expects YYYY-MM-DD-HHMM format (with optional -N suffix for collisions).
|
|
81
|
+
*/
|
|
82
|
+
export function getHandoffTimestamp(handoffFolder: string): Date | null {
|
|
83
|
+
const basename = path.basename(handoffFolder);
|
|
84
|
+
// Match YYYY-MM-DD-HHMM with optional collision suffix
|
|
85
|
+
const match = basename.match(/^(\d{4})-(\d{2})-(\d{2})-(\d{2})(\d{2})/);
|
|
86
|
+
if (!match) return null;
|
|
87
|
+
|
|
88
|
+
const [, year, month, day, hour, minute] = match;
|
|
89
|
+
const date = new Date(
|
|
90
|
+
Number.parseInt(year!, 10),
|
|
91
|
+
Number.parseInt(month!, 10) - 1,
|
|
92
|
+
Number.parseInt(day!, 10),
|
|
93
|
+
Number.parseInt(hour!, 10),
|
|
94
|
+
Number.parseInt(minute!, 10),
|
|
95
|
+
);
|
|
96
|
+
|
|
97
|
+
return isNaN(date.getTime()) ? null : date;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Get the plan path referenced by a handoff.
|
|
102
|
+
* First checks plan.md frontmatter for plan_path, then falls back
|
|
103
|
+
* to the context state's plan_path.
|
|
104
|
+
*/
|
|
105
|
+
export function getHandoffPlanReference(
|
|
106
|
+
handoffFolder: string,
|
|
107
|
+
contextId: string,
|
|
108
|
+
projectRoot?: string,
|
|
109
|
+
): null | string {
|
|
110
|
+
// Try plan.md frontmatter
|
|
111
|
+
const planMdPath = path.join(handoffFolder, "plan.md");
|
|
112
|
+
try {
|
|
113
|
+
if (fs.existsSync(planMdPath)) {
|
|
114
|
+
const content = fs.readFileSync(planMdPath, "utf8");
|
|
115
|
+
const frontmatter = parseFrontmatter(content);
|
|
116
|
+
if (frontmatter["plan_path"]) {
|
|
117
|
+
const pp = frontmatter["plan_path"];
|
|
118
|
+
if (fs.existsSync(pp)) return pp;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
} catch {
|
|
122
|
+
// fall through to context state
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
// Fall back to context state
|
|
126
|
+
try {
|
|
127
|
+
const context = getContext(contextId, projectRoot);
|
|
128
|
+
if (context?.plan_path && fs.existsSync(context.plan_path)) {
|
|
129
|
+
return context.plan_path;
|
|
130
|
+
}
|
|
131
|
+
} catch {
|
|
132
|
+
// ignore
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
return null;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Parse YAML-style frontmatter from markdown content.
|
|
140
|
+
* Returns key-value pairs from the --- block.
|
|
141
|
+
*/
|
|
142
|
+
function parseFrontmatter(content: string): Record<string, string> {
|
|
143
|
+
const frontmatter: Record<string, string> = {};
|
|
144
|
+
if (!content.startsWith("---")) return frontmatter;
|
|
145
|
+
|
|
146
|
+
const parts = content.split("---", 3);
|
|
147
|
+
if (parts.length < 3) return frontmatter;
|
|
148
|
+
|
|
149
|
+
for (const line of parts[1]!.trim().split("\n")) {
|
|
150
|
+
const colonIdx = line.indexOf(":");
|
|
151
|
+
if (colonIdx !== -1) {
|
|
152
|
+
const key = line.slice(0, colonIdx).trim();
|
|
153
|
+
const value = line.slice(colonIdx + 1).trim();
|
|
154
|
+
frontmatter[key] = value;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
return frontmatter;
|
|
159
|
+
}
|
|
@@ -32,7 +32,7 @@ export function getStatusIcon(status: string): string {
|
|
|
32
32
|
|
|
33
33
|
// §13.3 — Task rendering
|
|
34
34
|
export function renderTaskItem(
|
|
35
|
-
task:
|
|
35
|
+
task: Record<string, any> | Task,
|
|
36
36
|
showDescription = true,
|
|
37
37
|
maxDescriptionLength = 100,
|
|
38
38
|
): string {
|
|
@@ -48,14 +48,16 @@ export function renderTaskItem(
|
|
|
48
48
|
let truncated = description.slice(0, maxDescriptionLength);
|
|
49
49
|
if (description.length > maxDescriptionLength) {
|
|
50
50
|
truncated += "...";
|
|
51
|
-
}
|
|
51
|
+
}
|
|
52
|
+
|
|
52
53
|
return `${line}\n - ${truncated}`;
|
|
53
|
-
}
|
|
54
|
+
}
|
|
55
|
+
|
|
54
56
|
return line;
|
|
55
57
|
}
|
|
56
58
|
|
|
57
59
|
export function renderTaskList(
|
|
58
|
-
tasks: Array<
|
|
60
|
+
tasks: Array<Record<string, any> | Task>,
|
|
59
61
|
header = "Active Tasks",
|
|
60
62
|
showDescription = true,
|
|
61
63
|
): string {
|
|
@@ -5,112 +5,114 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
// §1.1
|
|
8
|
-
export type Mode = "
|
|
8
|
+
export type Mode = "active" | "has_handoff" | "has_plan" | "idle";
|
|
9
9
|
|
|
10
10
|
export interface ContextState {
|
|
11
|
-
id: string;
|
|
12
|
-
status: "active" | "completed";
|
|
13
|
-
summary: string;
|
|
14
|
-
method: string;
|
|
15
|
-
tags: string[];
|
|
16
11
|
created_at: string;
|
|
12
|
+
handoff_consumed: boolean;
|
|
13
|
+
handoff_path: null | string;
|
|
14
|
+
id: string;
|
|
17
15
|
last_active: string;
|
|
16
|
+
last_session: LastSession | null;
|
|
17
|
+
method: string;
|
|
18
18
|
mode: Mode;
|
|
19
|
-
plan_path: string | null;
|
|
20
|
-
plan_hash: string | null;
|
|
21
|
-
plan_signature: string | null;
|
|
22
|
-
plan_id: string | null;
|
|
23
19
|
plan_anchors: string[];
|
|
24
20
|
plan_consumed: boolean;
|
|
25
|
-
|
|
26
|
-
|
|
21
|
+
plan_hash: null | string;
|
|
22
|
+
plan_id: null | string;
|
|
23
|
+
plan_path: null | string;
|
|
24
|
+
plan_signature: null | string;
|
|
27
25
|
session_ids: string[];
|
|
28
|
-
|
|
26
|
+
status: "active" | "completed";
|
|
27
|
+
summary: string;
|
|
28
|
+
tags: string[];
|
|
29
29
|
tasks: Task[];
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
// §1.2
|
|
33
33
|
export interface GitState {
|
|
34
34
|
branch?: string;
|
|
35
|
-
uncommitted_files?: string[];
|
|
36
35
|
last_commit_short?: string;
|
|
36
|
+
uncommitted_files?: string[];
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
export interface LastSession {
|
|
40
|
-
session_id?: string;
|
|
41
|
-
saved_at?: string;
|
|
42
|
-
save_reason?: string;
|
|
43
|
-
transcript_path?: string;
|
|
44
40
|
context_remaining_pct?: number;
|
|
41
|
+
context_warnings_fired?: number[];
|
|
45
42
|
git_state?: GitState;
|
|
43
|
+
save_reason?: string;
|
|
44
|
+
saved_at?: string;
|
|
45
|
+
session_id?: string;
|
|
46
|
+
transcript_path?: string;
|
|
46
47
|
}
|
|
47
48
|
|
|
48
49
|
// §1.3
|
|
49
50
|
export interface Task {
|
|
50
|
-
id: string;
|
|
51
|
-
subject: string;
|
|
52
|
-
description: string;
|
|
53
51
|
active_form: string;
|
|
54
|
-
|
|
52
|
+
completed_at: null | string;
|
|
55
53
|
created_at: string;
|
|
56
|
-
|
|
54
|
+
description: string;
|
|
57
55
|
evidence: string;
|
|
58
|
-
work_summary: string;
|
|
59
56
|
files_changed: string[];
|
|
57
|
+
id: string;
|
|
60
58
|
session_id?: string;
|
|
59
|
+
status: "blocked" | "completed" | "in_progress" | "pending";
|
|
60
|
+
subject: string;
|
|
61
|
+
work_summary: string;
|
|
61
62
|
}
|
|
62
63
|
|
|
63
64
|
// §1.4
|
|
64
65
|
export interface IndexEntry {
|
|
65
|
-
summary: string;
|
|
66
|
-
mode: string;
|
|
67
66
|
last_active: string;
|
|
67
|
+
mode: string;
|
|
68
|
+
summary: string;
|
|
68
69
|
}
|
|
69
70
|
|
|
70
71
|
export interface IndexFile {
|
|
71
|
-
version: "3.0";
|
|
72
|
-
updated_at: string;
|
|
73
|
-
sessions: Record<string, string>;
|
|
74
72
|
contexts: Record<string, IndexEntry>;
|
|
73
|
+
sessions: Record<string, string>;
|
|
74
|
+
updated_at: string;
|
|
75
|
+
version: "3.0";
|
|
75
76
|
}
|
|
76
77
|
|
|
77
78
|
// §1.5
|
|
78
79
|
export interface LogEntry {
|
|
79
|
-
ts: string;
|
|
80
|
-
level: "debug" | "info" | "warn" | "error";
|
|
81
|
-
hook: string;
|
|
82
|
-
msg: string;
|
|
83
80
|
component?: string;
|
|
84
81
|
data?: any;
|
|
82
|
+
hook: string;
|
|
83
|
+
level: "debug" | "error" | "info" | "warn";
|
|
84
|
+
msg: string;
|
|
85
85
|
tb?: string;
|
|
86
|
+
ts: string;
|
|
86
87
|
}
|
|
87
88
|
|
|
88
89
|
// §1.6
|
|
89
90
|
export interface HookInput {
|
|
90
|
-
hook_event_name: string;
|
|
91
|
-
tool_name?: string;
|
|
92
|
-
tool_input?: Record<string, any>;
|
|
93
|
-
tool_result?: string;
|
|
94
|
-
session_id?: string;
|
|
95
|
-
cwd?: string;
|
|
96
|
-
transcript_path?: string;
|
|
97
91
|
context_window?: {
|
|
92
|
+
context_window_size?: number;
|
|
98
93
|
current_usage?: {
|
|
94
|
+
cache_creation_input_tokens?: number;
|
|
99
95
|
cache_read_input_tokens?: number;
|
|
100
96
|
input_tokens?: number;
|
|
101
|
-
cache_creation_input_tokens?: number;
|
|
102
97
|
output_tokens?: number;
|
|
103
98
|
};
|
|
104
|
-
context_window_size?: number;
|
|
105
99
|
};
|
|
100
|
+
cwd?: string;
|
|
101
|
+
hook_event_name: string;
|
|
106
102
|
permission_mode?: string;
|
|
103
|
+
session_id?: string;
|
|
107
104
|
source?: string;
|
|
105
|
+
tool_input?: Record<string, any>;
|
|
106
|
+
tool_name?: string;
|
|
107
|
+
tool_result?: string;
|
|
108
|
+
transcript_path?: string;
|
|
108
109
|
}
|
|
109
110
|
|
|
110
111
|
// §1.7
|
|
111
112
|
export interface HookOutput {
|
|
112
113
|
hookSpecificOutput?: {
|
|
113
114
|
additionalContext?: string;
|
|
115
|
+
hookEventName?: string;
|
|
114
116
|
permissionDecision?: "allow" | "deny";
|
|
115
117
|
permissionDecisionReason?: string;
|
|
116
118
|
};
|
|
@@ -118,34 +120,45 @@ export interface HookOutput {
|
|
|
118
120
|
|
|
119
121
|
// §1.8
|
|
120
122
|
export interface InferenceResult {
|
|
121
|
-
success: boolean;
|
|
122
|
-
output: string;
|
|
123
123
|
error?: string;
|
|
124
124
|
latency_ms: number;
|
|
125
|
+
output: string;
|
|
126
|
+
success: boolean;
|
|
125
127
|
}
|
|
126
128
|
|
|
127
129
|
// §1.9
|
|
128
130
|
export interface HandoffDocument {
|
|
131
|
+
active_tasks: Task[];
|
|
132
|
+
completed_tasks_this_session: Array<{ subject: string }>;
|
|
133
|
+
context_folder: string;
|
|
129
134
|
context_id: string;
|
|
130
135
|
context_summary: string;
|
|
131
|
-
session_id: string;
|
|
132
|
-
reason: string;
|
|
133
136
|
created_at: string;
|
|
134
|
-
plan_path: string | null;
|
|
135
|
-
context_folder: string;
|
|
136
137
|
events_log_path: string;
|
|
137
|
-
|
|
138
|
-
completed_tasks_this_session: Array<{ subject: string }>;
|
|
139
|
-
work_summary: string;
|
|
140
|
-
next_steps: string[];
|
|
138
|
+
file_path: null | string;
|
|
141
139
|
important_notes: string[];
|
|
142
|
-
|
|
140
|
+
next_steps: string[];
|
|
141
|
+
plan_path: null | string;
|
|
142
|
+
reason: string;
|
|
143
|
+
session_id: string;
|
|
144
|
+
work_summary: string;
|
|
143
145
|
}
|
|
144
146
|
|
|
145
147
|
// §1.10
|
|
148
|
+
export interface HandoffSections {
|
|
149
|
+
completedWork: null | string;
|
|
150
|
+
context: null | string;
|
|
151
|
+
deadEnds: null | string;
|
|
152
|
+
decisions: null | string;
|
|
153
|
+
index: null | string;
|
|
154
|
+
pending: null | string;
|
|
155
|
+
plan: null | string;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
// §1.11
|
|
146
159
|
export interface CaretCommand {
|
|
147
160
|
ends: string[];
|
|
148
|
-
|
|
149
|
-
new_context_desc: string | null;
|
|
161
|
+
new_context_desc: null | string;
|
|
150
162
|
remaining_prompt: string;
|
|
163
|
+
select: null | string;
|
|
151
164
|
}
|
|
@@ -0,0 +1,24 @@
|
|
|
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
|
+
import { getProjectRoot } from "../lib-ts/base/constants.js";
|
|
13
|
+
import { eprint } from "../lib-ts/base/utils.js";
|
|
14
|
+
import { findActiveContextId } from "../lib-ts/context/context-store.js";
|
|
15
|
+
|
|
16
|
+
const projectRoot = getProjectRoot(process.cwd());
|
|
17
|
+
const contextId = findActiveContextId(projectRoot);
|
|
18
|
+
|
|
19
|
+
if (!contextId) {
|
|
20
|
+
eprint("No active context found. Handoffs require an active context.");
|
|
21
|
+
process.exit(1);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
console.log(contextId);
|