aiwcli 0.10.2 → 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.d.ts +11 -6
- package/dist/commands/clear.js +229 -381
- package/dist/commands/init/index.d.ts +1 -17
- package/dist/commands/init/index.js +22 -107
- package/dist/lib/gitignore-manager.d.ts +32 -0
- package/dist/lib/gitignore-manager.js +141 -2
- package/dist/lib/template-installer.d.ts +7 -12
- package/dist/lib/template-installer.js +69 -193
- package/dist/lib/template-settings-reconstructor.d.ts +35 -0
- package/dist/lib/template-settings-reconstructor.js +130 -0
- 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 +138 -0
- package/dist/templates/_shared/lib-ts/base/constants.ts +306 -0
- package/dist/templates/_shared/lib-ts/base/git-state.ts +58 -0
- package/dist/templates/_shared/lib-ts/base/hook-utils.ts +439 -0
- package/dist/templates/_shared/lib-ts/base/inference.ts +252 -0
- package/dist/templates/_shared/lib-ts/base/logger.ts +250 -0
- package/dist/templates/_shared/lib-ts/base/state-io.ts +116 -0
- package/dist/templates/_shared/lib-ts/base/stop-words.ts +184 -0
- package/dist/templates/_shared/lib-ts/base/subprocess-utils.ts +162 -0
- package/dist/templates/_shared/lib-ts/base/utils.ts +184 -0
- package/dist/templates/_shared/lib-ts/context/context-formatter.ts +438 -0
- package/dist/templates/_shared/lib-ts/context/context-selector.ts +515 -0
- package/dist/templates/_shared/lib-ts/context/context-store.ts +707 -0
- package/dist/templates/_shared/lib-ts/context/plan-manager.ts +316 -0
- package/dist/templates/_shared/lib-ts/context/task-tracker.ts +185 -0
- package/dist/templates/_shared/lib-ts/handoff/document-generator.ts +216 -0
- package/dist/templates/_shared/lib-ts/handoff/handoff-reader.ts +159 -0
- package/dist/templates/_shared/lib-ts/package.json +21 -0
- package/dist/templates/_shared/lib-ts/templates/formatters.ts +104 -0
- package/dist/templates/_shared/{lib/templates/plan_context.py → lib-ts/templates/plan-context.ts} +14 -22
- package/dist/templates/_shared/lib-ts/tsconfig.json +13 -0
- package/dist/templates/_shared/lib-ts/types.ts +164 -0
- 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 +359 -0
- 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/ARCH-EVOLUTION.md +63 -0
- package/dist/templates/cc-native/_cc-native/agents/ARCH-PATTERNS.md +62 -0
- package/dist/templates/cc-native/_cc-native/agents/ARCH-STRUCTURE.md +63 -0
- package/dist/templates/cc-native/_cc-native/agents/{ASSUMPTION-CHAIN-TRACER.md → ASSUMPTION-TRACER.md} +6 -10
- package/dist/templates/cc-native/_cc-native/agents/CLARITY-AUDITOR.md +6 -10
- package/dist/templates/cc-native/_cc-native/agents/CLAUDE.md +74 -3
- package/dist/templates/cc-native/_cc-native/agents/COMPLETENESS-FEASIBILITY.md +67 -0
- package/dist/templates/cc-native/_cc-native/agents/COMPLETENESS-GAPS.md +71 -0
- package/dist/templates/cc-native/_cc-native/agents/COMPLETENESS-ORDERING.md +63 -0
- package/dist/templates/cc-native/_cc-native/agents/CONSTRAINT-VALIDATOR.md +73 -0
- package/dist/templates/cc-native/_cc-native/agents/DESIGN-ADR-VALIDATOR.md +62 -0
- package/dist/templates/cc-native/_cc-native/agents/DESIGN-SCALE-MATCHER.md +65 -0
- package/dist/templates/cc-native/_cc-native/agents/DEVILS-ADVOCATE.md +6 -9
- package/dist/templates/cc-native/_cc-native/agents/DOCUMENTATION-PHILOSOPHY.md +87 -0
- package/dist/templates/cc-native/_cc-native/agents/HANDOFF-READINESS.md +5 -9
- package/dist/templates/cc-native/_cc-native/agents/{HIDDEN-COMPLEXITY-DETECTOR.md → HIDDEN-COMPLEXITY.md} +6 -10
- package/dist/templates/cc-native/_cc-native/agents/INCREMENTAL-DELIVERY.md +67 -0
- package/dist/templates/cc-native/_cc-native/agents/PLAN-ORCHESTRATOR.md +91 -18
- package/dist/templates/cc-native/_cc-native/agents/RISK-DEPENDENCY.md +63 -0
- package/dist/templates/cc-native/_cc-native/agents/RISK-FMEA.md +67 -0
- package/dist/templates/cc-native/_cc-native/agents/RISK-PREMORTEM.md +72 -0
- package/dist/templates/cc-native/_cc-native/agents/RISK-REVERSIBILITY.md +75 -0
- package/dist/templates/cc-native/_cc-native/agents/SCOPE-BOUNDARY.md +78 -0
- package/dist/templates/cc-native/_cc-native/agents/SIMPLICITY-GUARDIAN.md +5 -9
- package/dist/templates/cc-native/_cc-native/agents/SKEPTIC.md +16 -12
- package/dist/templates/cc-native/_cc-native/agents/TESTDRIVEN-BEHAVIOR-AUDITOR.md +62 -0
- package/dist/templates/cc-native/_cc-native/agents/TESTDRIVEN-CHARACTERIZATION.md +72 -0
- package/dist/templates/cc-native/_cc-native/agents/TESTDRIVEN-FIRST-VALIDATOR.md +62 -0
- package/dist/templates/cc-native/_cc-native/agents/TESTDRIVEN-PYRAMID-ANALYZER.md +62 -0
- package/dist/templates/cc-native/_cc-native/agents/TRADEOFF-COSTS.md +68 -0
- package/dist/templates/cc-native/_cc-native/agents/TRADEOFF-STAKEHOLDERS.md +66 -0
- package/dist/templates/cc-native/_cc-native/agents/VERIFY-COVERAGE.md +75 -0
- package/dist/templates/cc-native/_cc-native/agents/VERIFY-STRENGTH.md +70 -0
- 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 +12 -16
- package/oclif.manifest.json +1 -1
- package/package.json +1 -1
- package/dist/lib/template-merger.d.ts +0 -47
- package/dist/lib/template-merger.js +0 -162
- 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 -169
- 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 -341
- package/dist/templates/_shared/lib/base/inference.py +0 -318
- package/dist/templates/_shared/lib/base/logger.py +0 -291
- package/dist/templates/_shared/lib/base/stop_words.py +0 -213
- package/dist/templates/_shared/lib/base/subprocess_utils.py +0 -46
- package/dist/templates/_shared/lib/base/utils.py +0 -242
- 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 -204
- 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/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 -701
- 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/agents/ACCESSIBILITY-TESTER.md +0 -79
- package/dist/templates/cc-native/_cc-native/agents/ARCHITECT-REVIEWER.md +0 -48
- package/dist/templates/cc-native/_cc-native/agents/CODE-REVIEWER.md +0 -70
- package/dist/templates/cc-native/_cc-native/agents/COMPLETENESS-CHECKER.md +0 -59
- package/dist/templates/cc-native/_cc-native/agents/CONTEXT-EXTRACTOR.md +0 -92
- package/dist/templates/cc-native/_cc-native/agents/DOCUMENTATION-REVIEWER.md +0 -51
- package/dist/templates/cc-native/_cc-native/agents/FEASIBILITY-ANALYST.md +0 -57
- package/dist/templates/cc-native/_cc-native/agents/FRESH-PERSPECTIVE.md +0 -54
- package/dist/templates/cc-native/_cc-native/agents/INCENTIVE-MAPPER.md +0 -61
- package/dist/templates/cc-native/_cc-native/agents/PENETRATION-TESTER.md +0 -79
- package/dist/templates/cc-native/_cc-native/agents/PERFORMANCE-ENGINEER.md +0 -75
- package/dist/templates/cc-native/_cc-native/agents/PRECEDENT-FINDER.md +0 -70
- package/dist/templates/cc-native/_cc-native/agents/REVERSIBILITY-ANALYST.md +0 -61
- package/dist/templates/cc-native/_cc-native/agents/RISK-ASSESSOR.md +0 -58
- package/dist/templates/cc-native/_cc-native/agents/SECOND-ORDER-ANALYST.md +0 -61
- package/dist/templates/cc-native/_cc-native/agents/STAKEHOLDER-ADVOCATE.md +0 -55
- package/dist/templates/cc-native/_cc-native/agents/TRADE-OFF-ILLUMINATOR.md +0 -204
- 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 -869
- 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 -1027
- 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,164 @@
|
|
|
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 = "active" | "has_handoff" | "has_plan" | "idle";
|
|
9
|
+
|
|
10
|
+
export interface ContextState {
|
|
11
|
+
created_at: string;
|
|
12
|
+
handoff_consumed: boolean;
|
|
13
|
+
handoff_path: null | string;
|
|
14
|
+
id: string;
|
|
15
|
+
last_active: string;
|
|
16
|
+
last_session: LastSession | null;
|
|
17
|
+
method: string;
|
|
18
|
+
mode: Mode;
|
|
19
|
+
plan_anchors: string[];
|
|
20
|
+
plan_consumed: boolean;
|
|
21
|
+
plan_hash: null | string;
|
|
22
|
+
plan_id: null | string;
|
|
23
|
+
plan_path: null | string;
|
|
24
|
+
plan_signature: null | string;
|
|
25
|
+
session_ids: string[];
|
|
26
|
+
status: "active" | "completed";
|
|
27
|
+
summary: string;
|
|
28
|
+
tags: string[];
|
|
29
|
+
tasks: Task[];
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// §1.2
|
|
33
|
+
export interface GitState {
|
|
34
|
+
branch?: string;
|
|
35
|
+
last_commit_short?: string;
|
|
36
|
+
uncommitted_files?: string[];
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export interface LastSession {
|
|
40
|
+
context_remaining_pct?: number;
|
|
41
|
+
context_warnings_fired?: number[];
|
|
42
|
+
git_state?: GitState;
|
|
43
|
+
save_reason?: string;
|
|
44
|
+
saved_at?: string;
|
|
45
|
+
session_id?: string;
|
|
46
|
+
transcript_path?: string;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// §1.3
|
|
50
|
+
export interface Task {
|
|
51
|
+
active_form: string;
|
|
52
|
+
completed_at: null | string;
|
|
53
|
+
created_at: string;
|
|
54
|
+
description: string;
|
|
55
|
+
evidence: string;
|
|
56
|
+
files_changed: string[];
|
|
57
|
+
id: string;
|
|
58
|
+
session_id?: string;
|
|
59
|
+
status: "blocked" | "completed" | "in_progress" | "pending";
|
|
60
|
+
subject: string;
|
|
61
|
+
work_summary: string;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// §1.4
|
|
65
|
+
export interface IndexEntry {
|
|
66
|
+
last_active: string;
|
|
67
|
+
mode: string;
|
|
68
|
+
summary: string;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export interface IndexFile {
|
|
72
|
+
contexts: Record<string, IndexEntry>;
|
|
73
|
+
sessions: Record<string, string>;
|
|
74
|
+
updated_at: string;
|
|
75
|
+
version: "3.0";
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// §1.5
|
|
79
|
+
export interface LogEntry {
|
|
80
|
+
component?: string;
|
|
81
|
+
data?: any;
|
|
82
|
+
hook: string;
|
|
83
|
+
level: "debug" | "error" | "info" | "warn";
|
|
84
|
+
msg: string;
|
|
85
|
+
tb?: string;
|
|
86
|
+
ts: string;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// §1.6
|
|
90
|
+
export interface HookInput {
|
|
91
|
+
context_window?: {
|
|
92
|
+
context_window_size?: number;
|
|
93
|
+
current_usage?: {
|
|
94
|
+
cache_creation_input_tokens?: number;
|
|
95
|
+
cache_read_input_tokens?: number;
|
|
96
|
+
input_tokens?: number;
|
|
97
|
+
output_tokens?: number;
|
|
98
|
+
};
|
|
99
|
+
};
|
|
100
|
+
cwd?: string;
|
|
101
|
+
hook_event_name: string;
|
|
102
|
+
permission_mode?: string;
|
|
103
|
+
session_id?: string;
|
|
104
|
+
source?: string;
|
|
105
|
+
tool_input?: Record<string, any>;
|
|
106
|
+
tool_name?: string;
|
|
107
|
+
tool_result?: string;
|
|
108
|
+
transcript_path?: string;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// §1.7
|
|
112
|
+
export interface HookOutput {
|
|
113
|
+
hookSpecificOutput?: {
|
|
114
|
+
additionalContext?: string;
|
|
115
|
+
hookEventName?: string;
|
|
116
|
+
permissionDecision?: "allow" | "deny";
|
|
117
|
+
permissionDecisionReason?: string;
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// §1.8
|
|
122
|
+
export interface InferenceResult {
|
|
123
|
+
error?: string;
|
|
124
|
+
latency_ms: number;
|
|
125
|
+
output: string;
|
|
126
|
+
success: boolean;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
// §1.9
|
|
130
|
+
export interface HandoffDocument {
|
|
131
|
+
active_tasks: Task[];
|
|
132
|
+
completed_tasks_this_session: Array<{ subject: string }>;
|
|
133
|
+
context_folder: string;
|
|
134
|
+
context_id: string;
|
|
135
|
+
context_summary: string;
|
|
136
|
+
created_at: string;
|
|
137
|
+
events_log_path: string;
|
|
138
|
+
file_path: null | string;
|
|
139
|
+
important_notes: string[];
|
|
140
|
+
next_steps: string[];
|
|
141
|
+
plan_path: null | string;
|
|
142
|
+
reason: string;
|
|
143
|
+
session_id: string;
|
|
144
|
+
work_summary: string;
|
|
145
|
+
}
|
|
146
|
+
|
|
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
|
|
159
|
+
export interface CaretCommand {
|
|
160
|
+
ends: string[];
|
|
161
|
+
new_context_desc: null | string;
|
|
162
|
+
remaining_prompt: string;
|
|
163
|
+
select: null | string;
|
|
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);
|
|
@@ -0,0 +1,321 @@
|
|
|
1
|
+
#!/usr/bin/env bun
|
|
2
|
+
/**
|
|
3
|
+
* Resume a handoff document by reading all sections and outputting
|
|
4
|
+
* a structured briefing to stdout.
|
|
5
|
+
*
|
|
6
|
+
* Usage:
|
|
7
|
+
* bun .aiwcli/_shared/scripts/resume_handoff.ts <handoff_folder_or_index>
|
|
8
|
+
* bun .aiwcli/_shared/scripts/resume_handoff.ts --context <context_id>
|
|
9
|
+
*
|
|
10
|
+
* If no args, auto-discovers the active context and finds the latest handoff.
|
|
11
|
+
*
|
|
12
|
+
* Outputs structured markdown to stdout in priority order,
|
|
13
|
+
* ready to be consumed by the /handoff-resume command template.
|
|
14
|
+
*/
|
|
15
|
+
import * as fs from "node:fs";
|
|
16
|
+
import * as path from "node:path";
|
|
17
|
+
|
|
18
|
+
import { getProjectRoot } from "../lib-ts/base/constants.js";
|
|
19
|
+
import { getGitStatusShort } from "../lib-ts/base/git-state.js";
|
|
20
|
+
import { eprint } from "../lib-ts/base/utils.js";
|
|
21
|
+
import { findActiveContextId } from "../lib-ts/context/context-store.js";
|
|
22
|
+
import {
|
|
23
|
+
findLatestHandoff,
|
|
24
|
+
getHandoffPlanReference,
|
|
25
|
+
getHandoffTimestamp,
|
|
26
|
+
readHandoffSections,
|
|
27
|
+
} from "../lib-ts/handoff/handoff-reader.js";
|
|
28
|
+
|
|
29
|
+
// ---------------------------------------------------------------------------
|
|
30
|
+
// Helpers
|
|
31
|
+
// ---------------------------------------------------------------------------
|
|
32
|
+
|
|
33
|
+
function formatRelativeAge(date: Date): string {
|
|
34
|
+
const now = new Date();
|
|
35
|
+
const diffMs = now.getTime() - date.getTime();
|
|
36
|
+
const diffMin = Math.floor(diffMs / 60_000);
|
|
37
|
+
const diffHours = Math.floor(diffMin / 60);
|
|
38
|
+
const diffDays = Math.floor(diffHours / 24);
|
|
39
|
+
|
|
40
|
+
if (diffDays === 0) {
|
|
41
|
+
if (diffHours === 0) {
|
|
42
|
+
return diffMin <= 1 ? "just now" : `${diffMin} minutes ago`;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return diffHours === 1 ? "1 hour ago" : `${diffHours} hours ago`;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
if (diffDays === 1) return "yesterday";
|
|
49
|
+
return `${diffDays} days ago`;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Count plan completion from plan.md content.
|
|
54
|
+
* Returns [completed, total] or null if no checkboxes found.
|
|
55
|
+
*/
|
|
56
|
+
function countPlanProgress(planContent: string): [number, number] | null {
|
|
57
|
+
const checked = (planContent.match(/\[x\]/gi) ?? []).length;
|
|
58
|
+
const unchecked = (planContent.match(/\[ \]/g) ?? []).length;
|
|
59
|
+
const total = checked + unchecked;
|
|
60
|
+
if (total === 0) return null;
|
|
61
|
+
return [checked, total];
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Strip the leading H1 title line from section content if present.
|
|
66
|
+
* Handoff section files typically start with "# Title\n\n..."
|
|
67
|
+
*/
|
|
68
|
+
function stripTitle(content: string): string {
|
|
69
|
+
const lines = content.split("\n");
|
|
70
|
+
if (lines[0]?.startsWith("# ")) {
|
|
71
|
+
// Remove title and leading blank lines
|
|
72
|
+
let i = 1;
|
|
73
|
+
while (i < lines.length && lines[i]!.trim() === "") i++;
|
|
74
|
+
return lines.slice(i).join("\n").trim();
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
return content.trim();
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// ---------------------------------------------------------------------------
|
|
81
|
+
// Resolution
|
|
82
|
+
// ---------------------------------------------------------------------------
|
|
83
|
+
|
|
84
|
+
function resolveHandoffFolder(args: string[]): [string, null | string] {
|
|
85
|
+
const projectRoot = getProjectRoot(process.cwd());
|
|
86
|
+
|
|
87
|
+
// --context <id>
|
|
88
|
+
const ctxIdx = args.indexOf("--context");
|
|
89
|
+
if (ctxIdx !== -1 && args[ctxIdx + 1]) {
|
|
90
|
+
const contextId = args[ctxIdx + 1]!;
|
|
91
|
+
const folder = findLatestHandoff(contextId, projectRoot);
|
|
92
|
+
if (!folder) {
|
|
93
|
+
eprint(`No handoff folders found for context: ${contextId}`);
|
|
94
|
+
process.exit(1);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
return [folder, contextId];
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// Direct path argument
|
|
101
|
+
if (args.length > 0 && !args[0]!.startsWith("--")) {
|
|
102
|
+
let target = args[0]!;
|
|
103
|
+
|
|
104
|
+
// If it's a file (e.g., index.md), use the parent folder
|
|
105
|
+
try {
|
|
106
|
+
const stat = fs.statSync(target);
|
|
107
|
+
if (stat.isFile()) {
|
|
108
|
+
target = path.dirname(target);
|
|
109
|
+
}
|
|
110
|
+
} catch {
|
|
111
|
+
eprint(`Path not found: ${target}`);
|
|
112
|
+
process.exit(1);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
// Verify it looks like a handoff folder (has index.md)
|
|
116
|
+
if (!fs.existsSync(path.join(target, "index.md"))) {
|
|
117
|
+
eprint(`Not a handoff folder (no index.md): ${target}`);
|
|
118
|
+
process.exit(1);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
return [target, null];
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// Auto-discover active context
|
|
125
|
+
const discoveredId = findActiveContextId(projectRoot);
|
|
126
|
+
if (discoveredId) {
|
|
127
|
+
const folder = findLatestHandoff(discoveredId, projectRoot);
|
|
128
|
+
if (!folder) {
|
|
129
|
+
eprint(`No handoff folders found for context: ${discoveredId} (auto-discovered)`);
|
|
130
|
+
process.exit(1);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
return [folder, discoveredId];
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
eprint(
|
|
137
|
+
"No active context found.\n\n" +
|
|
138
|
+
"Usage: bun resume_handoff.ts <handoff_folder_or_index>\n" +
|
|
139
|
+
" bun resume_handoff.ts --context <context_id>",
|
|
140
|
+
);
|
|
141
|
+
process.exit(1);
|
|
142
|
+
return ["", null]; // unreachable
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
// ---------------------------------------------------------------------------
|
|
146
|
+
// Main
|
|
147
|
+
// ---------------------------------------------------------------------------
|
|
148
|
+
|
|
149
|
+
function main(): void {
|
|
150
|
+
const args = process.argv.slice(2);
|
|
151
|
+
const [handoffFolder, contextId] = resolveHandoffFolder(args);
|
|
152
|
+
const projectRoot = getProjectRoot(process.cwd());
|
|
153
|
+
|
|
154
|
+
// Staleness check
|
|
155
|
+
const timestamp = getHandoffTimestamp(handoffFolder);
|
|
156
|
+
let ageStr = "unknown age";
|
|
157
|
+
let staleWarning = "";
|
|
158
|
+
if (timestamp) {
|
|
159
|
+
ageStr = formatRelativeAge(timestamp);
|
|
160
|
+
const diffDays = Math.floor((Date.now() - timestamp.getTime()) / 86_400_000);
|
|
161
|
+
if (diffDays > 7) {
|
|
162
|
+
staleWarning = `\n> **WARNING:** This handoff is ${diffDays} days old. Git state may have diverged significantly.\n`;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
// Read all sections
|
|
167
|
+
const sections = readHandoffSections(handoffFolder);
|
|
168
|
+
|
|
169
|
+
// Plan status
|
|
170
|
+
let planStatus = "No plan document";
|
|
171
|
+
const resolvedContextId = contextId ?? extractContextIdFromIndex(sections.index);
|
|
172
|
+
if (sections.plan) {
|
|
173
|
+
const progress = countPlanProgress(sections.plan);
|
|
174
|
+
if (progress) {
|
|
175
|
+
const [done, total] = progress;
|
|
176
|
+
const pct = Math.round((done / total) * 100);
|
|
177
|
+
planStatus = `${done}/${total} complete (${pct}%)`;
|
|
178
|
+
} else {
|
|
179
|
+
planStatus = "Plan present (no checkboxes)";
|
|
180
|
+
}
|
|
181
|
+
} else if (resolvedContextId) {
|
|
182
|
+
// Check for plan reference in context state
|
|
183
|
+
const planRef = getHandoffPlanReference(handoffFolder, resolvedContextId, projectRoot);
|
|
184
|
+
if (planRef) {
|
|
185
|
+
try {
|
|
186
|
+
const planContent = fs.readFileSync(planRef, "utf8");
|
|
187
|
+
const progress = countPlanProgress(planContent);
|
|
188
|
+
if (progress) {
|
|
189
|
+
const [done, total] = progress;
|
|
190
|
+
const pct = Math.round((done / total) * 100);
|
|
191
|
+
planStatus = `${done}/${total} complete (${pct}%) — from ${path.basename(planRef)}`;
|
|
192
|
+
} else {
|
|
193
|
+
planStatus = `Plan at ${planRef} (no checkboxes)`;
|
|
194
|
+
}
|
|
195
|
+
} catch {
|
|
196
|
+
planStatus = `Plan referenced at ${planRef} (unreadable)`;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
// Git delta
|
|
202
|
+
const currentGit = getGitStatusShort(projectRoot);
|
|
203
|
+
|
|
204
|
+
// Build output
|
|
205
|
+
const out: string[] = [];
|
|
206
|
+
|
|
207
|
+
out.push(`## Session Resumed from Handoff`, "");
|
|
208
|
+
out.push(`**Source:** \`${path.basename(handoffFolder)}\` (${ageStr})`);
|
|
209
|
+
if (resolvedContextId) out.push(`**Context:** ${resolvedContextId}`);
|
|
210
|
+
out.push(`**Plan Status:** ${planStatus}`);
|
|
211
|
+
if (staleWarning) out.push(staleWarning);
|
|
212
|
+
out.push("", "---", "", "### Dead Ends — Do Not Retry", "");
|
|
213
|
+
if (sections.deadEnds) {
|
|
214
|
+
const content = stripTitle(sections.deadEnds);
|
|
215
|
+
if (content && content !== "(No content for this section)") {
|
|
216
|
+
out.push(content);
|
|
217
|
+
} else {
|
|
218
|
+
out.push("(No dead ends recorded)");
|
|
219
|
+
}
|
|
220
|
+
} else {
|
|
221
|
+
out.push("(No dead-ends.md found)");
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
out.push("", "### Pending Items", "");
|
|
225
|
+
if (sections.pending) {
|
|
226
|
+
const content = stripTitle(sections.pending);
|
|
227
|
+
if (content && content !== "(No content for this section)") {
|
|
228
|
+
out.push(content);
|
|
229
|
+
} else {
|
|
230
|
+
out.push("(No pending items)");
|
|
231
|
+
}
|
|
232
|
+
} else {
|
|
233
|
+
out.push("(No pending.md found)");
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
out.push("");
|
|
237
|
+
|
|
238
|
+
// Priority 3: Plan remaining items (from plan.md in handoff)
|
|
239
|
+
if (sections.plan) {
|
|
240
|
+
const planContent = stripTitle(sections.plan);
|
|
241
|
+
// Extract unchecked items
|
|
242
|
+
const remaining = planContent
|
|
243
|
+
.split("\n")
|
|
244
|
+
.filter(line => /\[ \]/.test(line))
|
|
245
|
+
.map(line => line.trim());
|
|
246
|
+
if (remaining.length > 0) {
|
|
247
|
+
out.push("### Plan — Remaining Items", "");
|
|
248
|
+
for (const item of remaining) {
|
|
249
|
+
out.push(item);
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
out.push("");
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
// Priority 4: Decisions
|
|
257
|
+
out.push("### Settled Decisions", "");
|
|
258
|
+
if (sections.decisions) {
|
|
259
|
+
const content = stripTitle(sections.decisions);
|
|
260
|
+
if (content && content !== "(No content for this section)") {
|
|
261
|
+
out.push(content);
|
|
262
|
+
} else {
|
|
263
|
+
out.push("(No decisions recorded)");
|
|
264
|
+
}
|
|
265
|
+
} else {
|
|
266
|
+
out.push("(No decisions.md found)");
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
out.push("", "### Git Delta Since Handoff", "", "**Current git status:**", "```", currentGit, "```", "", "### Completed Work", "");
|
|
270
|
+
if (sections.completedWork) {
|
|
271
|
+
const content = stripTitle(sections.completedWork);
|
|
272
|
+
if (content && content !== "(No content for this section)") {
|
|
273
|
+
out.push(content);
|
|
274
|
+
} else {
|
|
275
|
+
out.push("(No completed work recorded)");
|
|
276
|
+
}
|
|
277
|
+
} else {
|
|
278
|
+
out.push("(No completed-work.md found)");
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
out.push("", "### Context Notes", "");
|
|
282
|
+
if (sections.context) {
|
|
283
|
+
const content = stripTitle(sections.context);
|
|
284
|
+
if (content && content !== "(No content for this section)") {
|
|
285
|
+
out.push(content);
|
|
286
|
+
} else {
|
|
287
|
+
out.push("None");
|
|
288
|
+
}
|
|
289
|
+
} else {
|
|
290
|
+
out.push("None");
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
out.push("", "---", "", "**Create ISC tasks** from the pending items and remaining plan items above using TaskCreate. Each task should be ~8 words, state a desired end-state (not an action), and be binary testable.");
|
|
294
|
+
|
|
295
|
+
console.log(out.join("\n"));
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
/**
|
|
299
|
+
* Try to extract context_id from index.md frontmatter.
|
|
300
|
+
*/
|
|
301
|
+
function extractContextIdFromIndex(indexContent: null | string): null | string {
|
|
302
|
+
if (!indexContent) return null;
|
|
303
|
+
if (!indexContent.startsWith("---")) return null;
|
|
304
|
+
|
|
305
|
+
const parts = indexContent.split("---", 3);
|
|
306
|
+
if (parts.length < 3) return null;
|
|
307
|
+
|
|
308
|
+
for (const line of parts[1]!.trim().split("\n")) {
|
|
309
|
+
const colonIdx = line.indexOf(":");
|
|
310
|
+
if (colonIdx !== -1) {
|
|
311
|
+
const key = line.slice(0, colonIdx).trim();
|
|
312
|
+
if (key === "context_id") {
|
|
313
|
+
return line.slice(colonIdx + 1).trim();
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
return null;
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
main();
|