aiwcli 0.12.7 → 0.12.8
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/dist/templates/CLAUDE.md +27 -0
- package/dist/templates/_shared/.claude/{commands/handoff.md → skills/handoff/SKILL.md} +3 -2
- package/dist/templates/_shared/.claude/{commands/handoff-resume.md → skills/handoff-resume/SKILL.md} +2 -1
- package/dist/templates/_shared/handoff-system/CLAUDE.md +433 -421
- package/dist/templates/_shared/lib-ts/CLAUDE.md +3 -3
- package/dist/templates/_shared/lib-ts/base/constants.ts +324 -306
- package/dist/templates/_shared/lib-ts/base/inference.ts +3 -3
- package/dist/templates/_shared/lib-ts/context/CLAUDE.md +134 -0
- package/dist/templates/_shared/scripts/status_line.ts +26 -29
- package/dist/templates/cc-native/.claude/commands/cc-native/specdev.md +1 -1
- package/dist/templates/cc-native/.claude/settings.json +3 -2
- package/dist/templates/cc-native/_cc-native/artifacts/CLAUDE.md +64 -0
- package/dist/templates/cc-native/_cc-native/{lib-ts/artifacts → artifacts/lib}/format.ts +597 -597
- package/dist/templates/cc-native/_cc-native/{lib-ts/artifacts → artifacts/lib}/index.ts +26 -26
- package/dist/templates/cc-native/_cc-native/{lib-ts/artifacts → artifacts/lib}/tracker.ts +107 -107
- package/dist/templates/cc-native/_cc-native/{lib-ts/artifacts → artifacts/lib}/write.ts +119 -119
- package/dist/templates/cc-native/_cc-native/hooks/CLAUDE.md +237 -247
- package/dist/templates/cc-native/_cc-native/hooks/cc-native-plan-review.ts +76 -76
- package/dist/templates/cc-native/_cc-native/hooks/validate_task_prompt.ts +76 -0
- package/dist/templates/cc-native/_cc-native/lib-ts/aggregate-agents.ts +163 -156
- package/dist/templates/cc-native/_cc-native/lib-ts/index.ts +116 -116
- package/dist/templates/cc-native/_cc-native/lib-ts/settings.ts +1 -1
- package/dist/templates/cc-native/_cc-native/lib-ts/types.ts +329 -329
- package/dist/templates/cc-native/_cc-native/plan-review/CLAUDE.md +149 -0
- package/dist/templates/cc-native/_cc-native/plan-review/agents/CLAUDE.md +143 -0
- package/dist/templates/cc-native/_cc-native/plan-review/agents/PLAN-ORCHESTRATOR.md +213 -0
- package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-questions/PLAN-QUESTIONER.md +70 -0
- package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/ARCH-EVOLUTION.md +62 -0
- package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/ARCH-PATTERNS.md +61 -0
- package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/ARCH-STRUCTURE.md +62 -0
- package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/ASSUMPTION-TRACER.md +56 -0
- package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/CLARITY-AUDITOR.md +53 -0
- package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/COMPLETENESS-FEASIBILITY.md +66 -0
- package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/COMPLETENESS-GAPS.md +70 -0
- package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/COMPLETENESS-ORDERING.md +62 -0
- package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/CONSTRAINT-VALIDATOR.md +72 -0
- package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/DESIGN-ADR-VALIDATOR.md +61 -0
- package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/DESIGN-SCALE-MATCHER.md +64 -0
- package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/DEVILS-ADVOCATE.md +56 -0
- package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/DOCUMENTATION-PHILOSOPHY.md +86 -0
- package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/HANDOFF-READINESS.md +59 -0
- package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/HIDDEN-COMPLEXITY.md +58 -0
- package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/INCREMENTAL-DELIVERY.md +66 -0
- package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/RISK-DEPENDENCY.md +62 -0
- package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/RISK-FMEA.md +66 -0
- package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/RISK-PREMORTEM.md +71 -0
- package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/RISK-REVERSIBILITY.md +74 -0
- package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/SCOPE-BOUNDARY.md +77 -0
- package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/SIMPLICITY-GUARDIAN.md +62 -0
- package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/SKEPTIC.md +68 -0
- package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/TESTDRIVEN-BEHAVIOR-AUDITOR.md +61 -0
- package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/TESTDRIVEN-CHARACTERIZATION.md +71 -0
- package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/TESTDRIVEN-FIRST-VALIDATOR.md +61 -0
- package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/TESTDRIVEN-PYRAMID-ANALYZER.md +61 -0
- package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/TRADEOFF-COSTS.md +67 -0
- package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/TRADEOFF-STAKEHOLDERS.md +65 -0
- package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/VERIFY-COVERAGE.md +74 -0
- package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/VERIFY-STRENGTH.md +69 -0
- package/dist/templates/cc-native/_cc-native/{lib-ts → plan-review/lib}/agent-selection.ts +163 -163
- package/dist/templates/cc-native/_cc-native/{lib-ts → plan-review/lib}/corroboration.ts +119 -119
- package/dist/templates/cc-native/_cc-native/{lib-ts → plan-review/lib}/graduation.ts +132 -132
- package/dist/templates/cc-native/_cc-native/{lib-ts → plan-review/lib}/orchestrator.ts +70 -70
- package/dist/templates/cc-native/_cc-native/{lib-ts → plan-review/lib}/output-builder.ts +130 -130
- package/dist/templates/cc-native/_cc-native/{lib-ts → plan-review/lib}/plan-questions.ts +102 -102
- package/dist/templates/cc-native/_cc-native/{lib-ts → plan-review/lib}/review-pipeline.ts +511 -511
- package/dist/templates/cc-native/_cc-native/{lib-ts → plan-review/lib}/reviewers/agent.ts +74 -74
- package/dist/templates/cc-native/_cc-native/{lib-ts → plan-review/lib}/reviewers/base/base-agent.ts +217 -217
- package/dist/templates/cc-native/_cc-native/{lib-ts → plan-review/lib}/reviewers/index.ts +12 -12
- package/dist/templates/cc-native/_cc-native/{lib-ts → plan-review/lib}/reviewers/providers/claude-agent.ts +66 -66
- package/dist/templates/cc-native/_cc-native/{lib-ts → plan-review/lib}/reviewers/providers/codex-agent.ts +185 -185
- package/dist/templates/cc-native/_cc-native/{lib-ts → plan-review/lib}/reviewers/providers/gemini-agent.ts +39 -39
- package/dist/templates/cc-native/_cc-native/{lib-ts → plan-review/lib}/reviewers/providers/orchestrator-claude-agent.ts +196 -196
- package/dist/templates/cc-native/_cc-native/{lib-ts → plan-review/lib}/reviewers/schemas.ts +201 -201
- package/dist/templates/cc-native/_cc-native/{lib-ts → plan-review/lib}/reviewers/types.ts +23 -23
- package/dist/templates/cc-native/_cc-native/{lib-ts → plan-review/lib}/verdict.ts +72 -72
- package/dist/templates/cc-native/_cc-native/{workflows → plan-review/workflows}/specdev.md +9 -9
- package/oclif.manifest.json +1 -1
- package/package.json +1 -1
- package/dist/templates/cc-native/_cc-native/lib-ts/artifacts.ts +0 -21
|
@@ -12,9 +12,9 @@ import { execFileAsync, getInternalSubprocessEnv, shellQuoteWin } from "./subpro
|
|
|
12
12
|
|
|
13
13
|
// Model configurations §6.1
|
|
14
14
|
const MODELS: Record<string, string> = {
|
|
15
|
-
fast: "claude-
|
|
16
|
-
standard: "claude-sonnet-4-
|
|
17
|
-
smart: "claude-opus-4-
|
|
15
|
+
fast: "claude-haiku-4-5-20251001",
|
|
16
|
+
standard: "claude-sonnet-4-6",
|
|
17
|
+
smart: "claude-opus-4-6",
|
|
18
18
|
};
|
|
19
19
|
|
|
20
20
|
const TIMEOUTS: Record<string, number> = {
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
# Context Management System
|
|
2
|
+
|
|
3
|
+
Shared library for context lifecycle management: state machine, session binding, plan tracking, and artifact routing.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
A "context" is a named work session with a state machine that tracks mode transitions, staged artifacts, and session history. Contexts persist to disk as `state.json` files under `_output/contexts/{id}/`. They are the backbone of the handoff and session-restore system.
|
|
8
|
+
|
|
9
|
+
## File Structure
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
context/
|
|
13
|
+
├── CLAUDE.md ← This file
|
|
14
|
+
├── context-store.ts ← Core CRUD + state machine transitions
|
|
15
|
+
├── context-formatter.ts ← Context → human-readable text for injection
|
|
16
|
+
├── context-selector.ts ← Find active/relevant contexts by criteria
|
|
17
|
+
├── plan-manager.ts ← Plan file archive, discovery, hash, path extraction
|
|
18
|
+
└── task-tracker.ts ← Task progress tracking within a context
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## State Machine
|
|
22
|
+
|
|
23
|
+
```
|
|
24
|
+
┌─────────────┐
|
|
25
|
+
│ created │
|
|
26
|
+
└──────┬──────┘
|
|
27
|
+
│ first user prompt / maybeActivate()
|
|
28
|
+
▼
|
|
29
|
+
┌─────────────┐
|
|
30
|
+
┌──▶│ active │◀──────────────────┐
|
|
31
|
+
│ └──────┬──────┘ │
|
|
32
|
+
│ │ session_end + artifact │ session_start (clear)
|
|
33
|
+
│ ▼ │
|
|
34
|
+
│ ┌─────────────────┐ │
|
|
35
|
+
│ │ has_staged_work │ ──────────────┘
|
|
36
|
+
│ └──────┬──────────┘
|
|
37
|
+
│ │ work_consumed = true
|
|
38
|
+
│ ▼
|
|
39
|
+
│ ┌─────────────┐
|
|
40
|
+
│ │ archived │──▶ (terminal)
|
|
41
|
+
│ └─────────────┘
|
|
42
|
+
│
|
|
43
|
+
└─── reopenContext()
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
**Modes:**
|
|
47
|
+
- `created` — context initialized, not yet bound to a session
|
|
48
|
+
- `active` — session in progress, context is current
|
|
49
|
+
- `has_staged_work` — session ended with staged artifact (plan or handoff)
|
|
50
|
+
- `archived` — context complete and closed
|
|
51
|
+
|
|
52
|
+
## API Reference
|
|
53
|
+
|
|
54
|
+
### `context-store.ts`
|
|
55
|
+
|
|
56
|
+
| Function | Purpose |
|
|
57
|
+
|----------|---------|
|
|
58
|
+
| `createContext(id, opts)` | Create new context with initial state |
|
|
59
|
+
| `getContext(contextId)` | Read context by ID |
|
|
60
|
+
| `getAllContexts(mode?, root?)` | List all contexts, optionally filtered by mode |
|
|
61
|
+
| `getContextBySessionId(sessionId, root?)` | Find context that owns a session ID |
|
|
62
|
+
| `updateContext(contextId, patch)` | Partial state update |
|
|
63
|
+
| `bindSession(contextId, sessionId)` | Attach session ID to context |
|
|
64
|
+
| `updateMode(contextId, mode)` | Transition state machine mode |
|
|
65
|
+
| `maybeActivate(contextId)` | Activate if in `created` mode (idempotent) |
|
|
66
|
+
| `completeContext(contextId)` | Mark complete, archive |
|
|
67
|
+
| `archiveContext(contextId)` | Archive without completing |
|
|
68
|
+
| `reopenContext(contextId)` | Transition `archived` → `active` |
|
|
69
|
+
| `createContextFromPrompt(prompt)` | Create context from user prompt text |
|
|
70
|
+
| `loadState(contextId)` | Raw state.json read |
|
|
71
|
+
| `saveState(contextId, state)` | Raw state.json write |
|
|
72
|
+
| `determineArtifactType(context)` | Detect `"plan"` or `"handoff"` from staged state |
|
|
73
|
+
|
|
74
|
+
### `context-formatter.ts`
|
|
75
|
+
|
|
76
|
+
Formats context state for injection into Claude's context window.
|
|
77
|
+
|
|
78
|
+
| Function | Purpose |
|
|
79
|
+
|----------|---------|
|
|
80
|
+
| `formatContext(context)` | Full context as human-readable markdown |
|
|
81
|
+
| `formatContextSummary(context)` | Short one-line summary |
|
|
82
|
+
|
|
83
|
+
### `context-selector.ts`
|
|
84
|
+
|
|
85
|
+
Finds contexts by various criteria.
|
|
86
|
+
|
|
87
|
+
| Function | Purpose |
|
|
88
|
+
|----------|---------|
|
|
89
|
+
| `selectActiveContext(root?)` | Find the single active context (errors if multiple) |
|
|
90
|
+
| `findContextByMode(mode, root?)` | Find contexts in a given mode |
|
|
91
|
+
| `findStagedWorkContext(root?)` | Find context with `has_staged_work` mode |
|
|
92
|
+
|
|
93
|
+
### `plan-manager.ts`
|
|
94
|
+
|
|
95
|
+
Manages plan file lifecycle within a context.
|
|
96
|
+
|
|
97
|
+
| Function | Purpose |
|
|
98
|
+
|----------|---------|
|
|
99
|
+
| `archivePlan(contextId, planPath)` | Copy plan to context's `plans/` folder |
|
|
100
|
+
| `findLatestPlan(contextId)` | Find most recent archived plan |
|
|
101
|
+
| `generatePlanId()` | Generate unique plan ID |
|
|
102
|
+
| `normalizePlanContent(text)` | Strip metadata for hashing |
|
|
103
|
+
| `extractPlanAnchors(content)` | Extract key phrases from plan for matching |
|
|
104
|
+
| `findPlanPathInTranscript(transcriptPath)` | Parse plan path from JSONL transcript |
|
|
105
|
+
| `extractPlanPathFromResult(toolResult)` | Extract plan path from tool result JSON |
|
|
106
|
+
|
|
107
|
+
### `task-tracker.ts`
|
|
108
|
+
|
|
109
|
+
Tracks task progress (ISC criteria) within a context.
|
|
110
|
+
|
|
111
|
+
| Function | Purpose |
|
|
112
|
+
|----------|---------|
|
|
113
|
+
| `initTaskTracker(contextId)` | Create task tracker for context |
|
|
114
|
+
| `addTask(contextId, task)` | Add tracked task |
|
|
115
|
+
| `updateTask(contextId, taskId, patch)` | Update task status |
|
|
116
|
+
| `getTaskSummary(contextId)` | Progress summary |
|
|
117
|
+
|
|
118
|
+
## Which Hooks Use This System
|
|
119
|
+
|
|
120
|
+
| Hook | Usage |
|
|
121
|
+
|------|-------|
|
|
122
|
+
| `session_start.ts` | `getContextBySessionId()`, `bindSession()`, `updateMode()`, `getAllContexts()` |
|
|
123
|
+
| `session_end.ts` | `getContextBySessionId()`, `updateMode()`, `saveState()` |
|
|
124
|
+
| `user_prompt_submit.ts` | `getAllContexts()`, `maybeActivate()`, `determineArtifactType()` |
|
|
125
|
+
| `archive_plan.ts` | `getContextBySessionId()`, `archivePlan()` |
|
|
126
|
+
| `save_handoff.ts` | `getContextBySessionId()`, `updateContext()` |
|
|
127
|
+
| `cc-native-plan-review.ts` | `getContextBySessionId()`, `getAllContexts()` |
|
|
128
|
+
|
|
129
|
+
## Design Decisions
|
|
130
|
+
|
|
131
|
+
- **Single state.json per context:** All state is in one file. No distributed state. Atomic writes prevent corruption.
|
|
132
|
+
- **No moves out of lib-ts:** Context is pure library code imported by ~8 shared hooks. Moving it would require updating all those import paths for no structural gain. The subfolder is already co-located; it just needed documentation.
|
|
133
|
+
- **`maybeActivate()` is idempotent:** Can be called from any hook without checking current mode — safe to call repeatedly.
|
|
134
|
+
- **`determineArtifactType()` drives session restore:** Returns `"plan"` or `"handoff"` to dispatch the correct restoration path in `session_start.ts`.
|
|
@@ -266,9 +266,10 @@ function runGit(args: string[], cwd: string, timeout = 2000): string | null {
|
|
|
266
266
|
}
|
|
267
267
|
|
|
268
268
|
function getGitStatus(cwd: string): GitStatus | null {
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
269
|
+
// One call replaces 6: branch, modified, staged, untracked, ahead/behind, and repo check.
|
|
270
|
+
// porcelain=v2 -b gives structured header lines + per-file XY status codes.
|
|
271
|
+
const porcelain = runGit(["status", "--porcelain=v2", "-b"], cwd);
|
|
272
|
+
if (porcelain === null) return null;
|
|
272
273
|
|
|
273
274
|
const status: GitStatus = {
|
|
274
275
|
branch: "detached",
|
|
@@ -282,36 +283,32 @@ function getGitStatus(cwd: string): GitStatus | null {
|
|
|
282
283
|
age_color: GIT_AGE_FRESH,
|
|
283
284
|
};
|
|
284
285
|
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
286
|
+
for (const line of porcelain.split(/\r?\n/)) {
|
|
287
|
+
if (line.startsWith("# branch.head ")) {
|
|
288
|
+
const b = line.slice(14).trim();
|
|
289
|
+
status.branch = b === "(detached)" ? "detached" : b;
|
|
290
|
+
} else if (line.startsWith("# branch.ab ")) {
|
|
291
|
+
// Format: "+<ahead> -<behind>"
|
|
292
|
+
const m = line.match(/\+(\d+) -(\d+)/);
|
|
293
|
+
if (m) {
|
|
294
|
+
status.ahead = parseInt(m[1]!, 10);
|
|
295
|
+
status.behind = parseInt(m[2]!, 10);
|
|
296
|
+
}
|
|
297
|
+
} else if (line.startsWith("1 ") || line.startsWith("2 ")) {
|
|
298
|
+
// Changed tracked file: "1 XY ..." where X=staged Y=unstaged, '.'=unchanged
|
|
299
|
+
const x = line[2]!;
|
|
300
|
+
const y = line[3]!;
|
|
301
|
+
if (x !== ".") status.staged++;
|
|
302
|
+
if (y !== ".") status.modified++;
|
|
303
|
+
} else if (line.startsWith("? ")) {
|
|
304
|
+
status.untracked++;
|
|
305
|
+
}
|
|
306
|
+
}
|
|
300
307
|
|
|
301
|
-
// Stash count
|
|
308
|
+
// Stash count (no equivalent in status output)
|
|
302
309
|
const stash = runGit(["stash", "list"], cwd);
|
|
303
310
|
if (stash) status.stash_count = stash.split(/\r?\n/).filter(Boolean).length;
|
|
304
311
|
|
|
305
|
-
// Ahead/behind
|
|
306
|
-
const ab = runGit(["rev-list", "--left-right", "--count", "HEAD...@{u}"], cwd);
|
|
307
|
-
if (ab) {
|
|
308
|
-
const parts = ab.split(/\s+/);
|
|
309
|
-
if (parts.length >= 2) {
|
|
310
|
-
status.ahead = parseInt(parts[0]!, 10) || 0;
|
|
311
|
-
status.behind = parseInt(parts[1]!, 10) || 0;
|
|
312
|
-
}
|
|
313
|
-
}
|
|
314
|
-
|
|
315
312
|
// Commit age
|
|
316
313
|
const log = runGit(["log", "-1", "--format=%ct"], cwd);
|
|
317
314
|
if (log) {
|
|
@@ -5,6 +5,6 @@ description: Interview user about a spec file and develop detailed requirements
|
|
|
5
5
|
|
|
6
6
|
First, ask the user for the path to the spec file they want to develop.
|
|
7
7
|
|
|
8
|
-
Then load and execute `_cc-native/workflows/specdev.md`.
|
|
8
|
+
Then load and execute `_cc-native/plan-review/workflows/specdev.md`.
|
|
9
9
|
|
|
10
10
|
Follow the Clarify → Explore → Write pattern using native tools.
|
|
@@ -162,8 +162,9 @@
|
|
|
162
162
|
"matcher": "^Task$",
|
|
163
163
|
"hooks": [
|
|
164
164
|
{
|
|
165
|
-
"type": "
|
|
166
|
-
"
|
|
165
|
+
"type": "command",
|
|
166
|
+
"command": "bun .aiwcli/_cc-native/hooks/validate_task_prompt.ts",
|
|
167
|
+
"timeout": 20000
|
|
167
168
|
}
|
|
168
169
|
]
|
|
169
170
|
},
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# Artifacts System
|
|
2
|
+
|
|
3
|
+
Review artifact generation, formatting, and file I/O for the plan review pipeline.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
The artifacts system handles all output files produced by plan review runs: combined markdown reports, JSON results, inline summaries, corroboration reports, and the review tracker. It is a pure library — no hooks or scripts.
|
|
8
|
+
|
|
9
|
+
## File Structure
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
artifacts/
|
|
13
|
+
├── CLAUDE.md ← This file
|
|
14
|
+
└── lib/
|
|
15
|
+
├── index.ts ← Barrel re-export of all public API
|
|
16
|
+
├── format.ts ← Pure formatting functions (markdown, JSON, summaries)
|
|
17
|
+
├── write.ts ← File I/O: atomic writes to context reviews dir
|
|
18
|
+
└── tracker.ts ← Review tracker: read/write/hash extraction
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Public API (`lib/index.ts`)
|
|
22
|
+
|
|
23
|
+
| Function | Source | Purpose |
|
|
24
|
+
|----------|--------|---------|
|
|
25
|
+
| `formatReviewMarkdown` | format.ts | Format single agent review as markdown |
|
|
26
|
+
| `formatCombinedMarkdown` | format.ts | Format all agent reviews into combined markdown |
|
|
27
|
+
| `buildInlineReviewSummary` | format.ts | Short inline summary for context injection |
|
|
28
|
+
| `extractTopIssuesText` | format.ts | Extract top issues as text block |
|
|
29
|
+
| `buildHighIssuesDocument` | format.ts | Full high-issues document for context |
|
|
30
|
+
| `buildCorroborationReport` | format.ts | Corroboration analysis markdown report |
|
|
31
|
+
| `generateReviewIndex` | format.ts | Index markdown linking all review files |
|
|
32
|
+
| `buildCombinedJson` | format.ts | Combined JSON artifact for all reviews |
|
|
33
|
+
| `writeCombinedArtifacts` | write.ts | Write all artifacts to context reviews dir |
|
|
34
|
+
| `writeFile` | write.ts | Atomic file write |
|
|
35
|
+
| `writeFileNonCritical` | write.ts | Non-atomic file write (non-critical paths) |
|
|
36
|
+
| `writeReviewTracker` | tracker.ts | Write review tracker JSON to disk |
|
|
37
|
+
| `extractPreviousHashes` | tracker.ts | Read previous plan hashes from tracker |
|
|
38
|
+
| `ReviewTrackerEntry` | tracker.ts | Type: single tracker entry |
|
|
39
|
+
|
|
40
|
+
## Dependencies
|
|
41
|
+
|
|
42
|
+
- `../../lib-ts/types.ts` — `CombinedReviewResult`, `CorroborationResult` types
|
|
43
|
+
- `../../lib-ts/constants.ts` — `ENABLE_ROBUST_PLAN_WRITES` feature flag
|
|
44
|
+
- `../../../_shared/lib-ts/base/atomic-write.ts` — atomic file I/O
|
|
45
|
+
- `../../../_shared/lib-ts/base/constants.ts` — `sanitizeFilename`
|
|
46
|
+
- `../../../_shared/lib-ts/base/logger.ts` — logging
|
|
47
|
+
|
|
48
|
+
## Hooks
|
|
49
|
+
|
|
50
|
+
Hooks for this system are NOT co-located here. Hooks are path-referenced in `.claude/settings.json` at install time. Moving a hook file requires settings.json updates in both `.aiwcli/` and `packages/cli/src/templates/`, which is high blast-radius and fragile.
|
|
51
|
+
|
|
52
|
+
The artifacts system is invoked indirectly through the plan review pipeline — it has no dedicated hooks. See `../_cc-native/hooks/` for the plan review hooks that drive this system.
|
|
53
|
+
|
|
54
|
+
## Callers
|
|
55
|
+
|
|
56
|
+
- `../plan-review/lib/review-pipeline.ts` — primary caller, writes all review artifacts
|
|
57
|
+
- `../../lib-ts/index.ts` — re-exports public API surface
|
|
58
|
+
|
|
59
|
+
## Design Decisions
|
|
60
|
+
|
|
61
|
+
- **Pure library:** No global state, no side effects except file I/O in write.ts/tracker.ts
|
|
62
|
+
- **Atomic writes:** `write.ts` uses atomic writes (write to temp + rename) for critical review files when `ENABLE_ROBUST_PLAN_WRITES` is set, preventing partial writes on crash
|
|
63
|
+
- **format.ts is pure:** All formatting is pure functions — takes data, returns strings. No file I/O.
|
|
64
|
+
- **Co-location:** Moved from `lib-ts/artifacts/` to `artifacts/lib/` to give the system peer-level status alongside `plan-review/` and `rlm/`
|