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.
- package/bin/dev.cmd +3 -3
- package/bin/dev.js +16 -16
- package/bin/run.cmd +3 -3
- package/bin/run.js +21 -21
- package/dist/commands/branch.js +7 -2
- package/dist/lib/bmad-installer.js +37 -37
- package/dist/lib/terminal.d.ts +2 -0
- package/dist/lib/terminal.js +57 -7
- package/dist/templates/CLAUDE.md +205 -205
- package/dist/templates/_shared/.claude/commands/handoff-resume.md +12 -64
- package/dist/templates/_shared/.claude/commands/handoff.md +12 -198
- package/dist/templates/_shared/.claude/settings.json +65 -65
- package/dist/templates/_shared/.codex/workflows/handoff.md +226 -226
- package/dist/templates/_shared/.windsurf/workflows/handoff.md +226 -226
- package/dist/templates/_shared/handoff-system/CLAUDE.md +421 -0
- package/dist/templates/_shared/{lib-ts/handoff → handoff-system/lib}/document-generator.ts +215 -216
- package/dist/templates/_shared/{lib-ts/handoff → handoff-system/lib}/handoff-reader.ts +157 -158
- package/dist/templates/_shared/{scripts → handoff-system/scripts}/resume_handoff.ts +373 -373
- package/dist/templates/_shared/{scripts → handoff-system/scripts}/save_handoff.ts +469 -358
- package/dist/templates/_shared/handoff-system/workflows/handoff-resume.md +66 -0
- package/dist/templates/_shared/{workflows → handoff-system/workflows}/handoff.md +254 -254
- package/dist/templates/_shared/hooks-ts/_utils/git-state.ts +2 -2
- package/dist/templates/_shared/hooks-ts/archive_plan.ts +159 -159
- package/dist/templates/_shared/hooks-ts/context_monitor.ts +147 -147
- package/dist/templates/_shared/hooks-ts/file-suggestion.ts +128 -128
- package/dist/templates/_shared/hooks-ts/pre_compact.ts +49 -49
- package/dist/templates/_shared/hooks-ts/session_end.ts +196 -183
- package/dist/templates/_shared/hooks-ts/session_start.ts +163 -151
- package/dist/templates/_shared/hooks-ts/task_create_capture.ts +48 -48
- package/dist/templates/_shared/hooks-ts/task_update_capture.ts +74 -74
- package/dist/templates/_shared/hooks-ts/user_prompt_submit.ts +93 -93
- package/dist/templates/_shared/lib-ts/CLAUDE.md +367 -367
- package/dist/templates/_shared/lib-ts/base/atomic-write.ts +138 -138
- package/dist/templates/_shared/lib-ts/base/constants.ts +303 -303
- package/dist/templates/_shared/lib-ts/base/git-state.ts +58 -58
- package/dist/templates/_shared/lib-ts/base/hook-utils.ts +582 -582
- package/dist/templates/_shared/lib-ts/base/inference.ts +301 -301
- package/dist/templates/_shared/lib-ts/base/logger.ts +247 -247
- package/dist/templates/_shared/lib-ts/base/state-io.ts +202 -130
- package/dist/templates/_shared/lib-ts/base/stop-words.ts +184 -184
- package/dist/templates/_shared/lib-ts/base/subprocess-utils.ts +56 -0
- package/dist/templates/_shared/lib-ts/base/utils.ts +184 -184
- package/dist/templates/_shared/lib-ts/context/context-formatter.ts +566 -560
- package/dist/templates/_shared/lib-ts/context/context-selector.ts +524 -515
- package/dist/templates/_shared/lib-ts/context/context-store.ts +712 -668
- package/dist/templates/_shared/lib-ts/context/plan-manager.ts +312 -312
- package/dist/templates/_shared/lib-ts/context/task-tracker.ts +185 -185
- package/dist/templates/_shared/lib-ts/package.json +20 -20
- package/dist/templates/_shared/lib-ts/templates/formatters.ts +102 -102
- package/dist/templates/_shared/lib-ts/templates/plan-context.ts +58 -58
- package/dist/templates/_shared/lib-ts/tsconfig.json +13 -13
- package/dist/templates/_shared/lib-ts/types.ts +186 -180
- package/dist/templates/_shared/scripts/resolve_context.ts +33 -33
- package/dist/templates/_shared/scripts/status_line.ts +690 -690
- package/dist/templates/cc-native/.claude/commands/{rlm → cc-native/rlm}/ask.md +136 -136
- package/dist/templates/cc-native/.claude/commands/{rlm → cc-native/rlm}/index.md +21 -21
- package/dist/templates/cc-native/.claude/commands/{rlm → cc-native/rlm}/overview.md +56 -56
- package/dist/templates/cc-native/.claude/commands/cc-native/specdev.md +10 -10
- package/dist/templates/cc-native/.windsurf/workflows/cc-native/fix.md +8 -8
- package/dist/templates/cc-native/.windsurf/workflows/cc-native/implement.md +8 -8
- package/dist/templates/cc-native/.windsurf/workflows/cc-native/research.md +8 -8
- package/dist/templates/cc-native/CC-NATIVE-README.md +189 -189
- package/dist/templates/cc-native/TEMPLATE-SCHEMA.md +304 -304
- package/dist/templates/cc-native/_cc-native/agents/CLAUDE.md +143 -143
- package/dist/templates/cc-native/_cc-native/agents/PLAN-ORCHESTRATOR.md +213 -213
- package/dist/templates/cc-native/_cc-native/agents/plan-questions/PLAN-QUESTIONER.md +70 -70
- package/dist/templates/cc-native/_cc-native/cc-native.config.json +96 -96
- package/dist/templates/cc-native/_cc-native/hooks/CLAUDE.md +247 -247
- package/dist/templates/cc-native/_cc-native/hooks/cc-native-plan-review.ts +76 -76
- package/dist/templates/cc-native/_cc-native/hooks/enhance_plan_post_subagent.ts +54 -54
- package/dist/templates/cc-native/_cc-native/hooks/enhance_plan_post_write.ts +51 -51
- package/dist/templates/cc-native/_cc-native/hooks/mark_questions_asked.ts +53 -53
- package/dist/templates/cc-native/_cc-native/hooks/plan_questions_early.ts +61 -61
- package/dist/templates/cc-native/_cc-native/lib-ts/agent-selection.ts +163 -163
- package/dist/templates/cc-native/_cc-native/lib-ts/aggregate-agents.ts +156 -156
- package/dist/templates/cc-native/_cc-native/lib-ts/artifacts/format.ts +597 -597
- package/dist/templates/cc-native/_cc-native/lib-ts/artifacts/index.ts +26 -26
- package/dist/templates/cc-native/_cc-native/lib-ts/artifacts/tracker.ts +107 -107
- package/dist/templates/cc-native/_cc-native/lib-ts/artifacts/write.ts +119 -119
- package/dist/templates/cc-native/_cc-native/lib-ts/artifacts.ts +21 -21
- package/dist/templates/cc-native/_cc-native/lib-ts/cc-native-state.ts +319 -319
- package/dist/templates/cc-native/_cc-native/lib-ts/cli-output-parser.ts +144 -144
- package/dist/templates/cc-native/_cc-native/lib-ts/config.ts +57 -57
- package/dist/templates/cc-native/_cc-native/lib-ts/constants.ts +83 -83
- package/dist/templates/cc-native/_cc-native/lib-ts/corroboration.ts +119 -119
- package/dist/templates/cc-native/_cc-native/lib-ts/debug.ts +79 -79
- package/dist/templates/cc-native/_cc-native/lib-ts/graduation.ts +132 -132
- package/dist/templates/cc-native/_cc-native/lib-ts/index.ts +116 -116
- package/dist/templates/cc-native/_cc-native/lib-ts/json-parser.ts +168 -168
- package/dist/templates/cc-native/_cc-native/lib-ts/orchestrator.ts +70 -70
- package/dist/templates/cc-native/_cc-native/lib-ts/output-builder.ts +130 -130
- package/dist/templates/cc-native/_cc-native/lib-ts/plan-discovery.ts +80 -80
- package/dist/templates/cc-native/_cc-native/lib-ts/plan-enhancement.ts +41 -41
- package/dist/templates/cc-native/_cc-native/lib-ts/plan-questions.ts +101 -101
- package/dist/templates/cc-native/_cc-native/lib-ts/review-pipeline.ts +511 -511
- package/dist/templates/cc-native/_cc-native/lib-ts/reviewers/agent.ts +71 -71
- package/dist/templates/cc-native/_cc-native/lib-ts/reviewers/base/base-agent.ts +217 -217
- package/dist/templates/cc-native/_cc-native/lib-ts/reviewers/index.ts +12 -12
- package/dist/templates/cc-native/_cc-native/lib-ts/reviewers/providers/claude-agent.ts +66 -65
- package/dist/templates/cc-native/_cc-native/lib-ts/reviewers/providers/codex-agent.ts +184 -184
- package/dist/templates/cc-native/_cc-native/lib-ts/reviewers/providers/gemini-agent.ts +39 -39
- package/dist/templates/cc-native/_cc-native/lib-ts/reviewers/providers/orchestrator-claude-agent.ts +196 -195
- package/dist/templates/cc-native/_cc-native/lib-ts/reviewers/schemas.ts +201 -201
- package/dist/templates/cc-native/_cc-native/lib-ts/reviewers/types.ts +21 -21
- package/dist/templates/cc-native/_cc-native/lib-ts/rlm/CLAUDE.md +480 -480
- package/dist/templates/cc-native/_cc-native/lib-ts/rlm/embedding-indexer.ts +287 -287
- package/dist/templates/cc-native/_cc-native/lib-ts/rlm/hyde.ts +148 -148
- package/dist/templates/cc-native/_cc-native/lib-ts/rlm/index.ts +54 -54
- package/dist/templates/cc-native/_cc-native/lib-ts/rlm/logger.ts +58 -58
- package/dist/templates/cc-native/_cc-native/lib-ts/rlm/ollama-client.ts +208 -208
- package/dist/templates/cc-native/_cc-native/lib-ts/rlm/retrieval-pipeline.ts +460 -460
- package/dist/templates/cc-native/_cc-native/lib-ts/rlm/transcript-indexer.ts +446 -447
- package/dist/templates/cc-native/_cc-native/lib-ts/rlm/transcript-loader.ts +280 -280
- package/dist/templates/cc-native/_cc-native/lib-ts/rlm/transcript-searcher.ts +274 -274
- package/dist/templates/cc-native/_cc-native/lib-ts/rlm/types.ts +201 -201
- package/dist/templates/cc-native/_cc-native/lib-ts/rlm/vector-store.ts +278 -278
- package/dist/templates/cc-native/_cc-native/lib-ts/settings.ts +184 -184
- package/dist/templates/cc-native/_cc-native/lib-ts/state.ts +275 -275
- package/dist/templates/cc-native/_cc-native/lib-ts/tsconfig.json +18 -18
- package/dist/templates/cc-native/_cc-native/lib-ts/types.ts +329 -329
- package/dist/templates/cc-native/_cc-native/lib-ts/verdict.ts +72 -72
- package/dist/templates/cc-native/_cc-native/workflows/specdev.md +9 -9
- package/oclif.manifest.json +1 -1
- package/package.json +108 -108
- package/dist/templates/cc-native/_cc-native/lib-ts/nul +0 -3
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Barrel re-export for artifacts submodules.
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
export {
|
|
6
|
-
formatReviewMarkdown,
|
|
7
|
-
formatCombinedMarkdown,
|
|
8
|
-
buildInlineReviewSummary,
|
|
9
|
-
extractTopIssuesText,
|
|
10
|
-
buildHighIssuesDocument,
|
|
11
|
-
buildCorroborationReport,
|
|
12
|
-
generateReviewIndex,
|
|
13
|
-
buildCombinedJson,
|
|
14
|
-
} from "./format.js";
|
|
15
|
-
|
|
16
|
-
export {
|
|
17
|
-
writeCombinedArtifacts,
|
|
18
|
-
writeFile,
|
|
19
|
-
writeFileNonCritical,
|
|
20
|
-
} from "./write.js";
|
|
21
|
-
|
|
22
|
-
export {
|
|
23
|
-
writeReviewTracker,
|
|
24
|
-
extractPreviousHashes,
|
|
25
|
-
} from "./tracker.js";
|
|
26
|
-
export type { ReviewTrackerEntry } from "./tracker.js";
|
|
1
|
+
/**
|
|
2
|
+
* Barrel re-export for artifacts submodules.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
export {
|
|
6
|
+
formatReviewMarkdown,
|
|
7
|
+
formatCombinedMarkdown,
|
|
8
|
+
buildInlineReviewSummary,
|
|
9
|
+
extractTopIssuesText,
|
|
10
|
+
buildHighIssuesDocument,
|
|
11
|
+
buildCorroborationReport,
|
|
12
|
+
generateReviewIndex,
|
|
13
|
+
buildCombinedJson,
|
|
14
|
+
} from "./format.js";
|
|
15
|
+
|
|
16
|
+
export {
|
|
17
|
+
writeCombinedArtifacts,
|
|
18
|
+
writeFile,
|
|
19
|
+
writeFileNonCritical,
|
|
20
|
+
} from "./write.js";
|
|
21
|
+
|
|
22
|
+
export {
|
|
23
|
+
writeReviewTracker,
|
|
24
|
+
extractPreviousHashes,
|
|
25
|
+
} from "./tracker.js";
|
|
26
|
+
export type { ReviewTrackerEntry } from "./tracker.js";
|
|
@@ -1,107 +1,107 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Review tracker management — human-readable lifecycle summary.
|
|
3
|
-
* Extracted from artifacts.ts.
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import * as fs from "node:fs";
|
|
7
|
-
import * as path from "node:path";
|
|
8
|
-
import { logWarn } from "../../../_shared/lib-ts/base/logger.js";
|
|
9
|
-
|
|
10
|
-
// ---------------------------------------------------------------------------
|
|
11
|
-
// Types
|
|
12
|
-
// ---------------------------------------------------------------------------
|
|
13
|
-
|
|
14
|
-
export interface ReviewTrackerEntry {
|
|
15
|
-
iteration: number;
|
|
16
|
-
timestamp: string;
|
|
17
|
-
planHash: string;
|
|
18
|
-
verdict: string;
|
|
19
|
-
decision: string;
|
|
20
|
-
score: number;
|
|
21
|
-
topIssues: string[];
|
|
22
|
-
reviewFolder: string;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
// ---------------------------------------------------------------------------
|
|
26
|
-
// Tracker Writing
|
|
27
|
-
// ---------------------------------------------------------------------------
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Build or update the review-tracker.md in the cc-native reviews directory.
|
|
31
|
-
*/
|
|
32
|
-
export function writeReviewTracker(
|
|
33
|
-
ccNativeReviewsDir: string,
|
|
34
|
-
entry: ReviewTrackerEntry,
|
|
35
|
-
): void {
|
|
36
|
-
const trackerPath = path.join(ccNativeReviewsDir, "review-tracker.md");
|
|
37
|
-
|
|
38
|
-
let existingContent = "";
|
|
39
|
-
try {
|
|
40
|
-
if (fs.existsSync(trackerPath)) {
|
|
41
|
-
existingContent = fs.readFileSync(trackerPath, "utf-8");
|
|
42
|
-
}
|
|
43
|
-
} catch {
|
|
44
|
-
// Fresh start
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
const previousHashes = extractPreviousHashes(existingContent);
|
|
48
|
-
const hashChanged = previousHashes.length > 0 &&
|
|
49
|
-
previousHashes[previousHashes.length - 1] !== entry.planHash;
|
|
50
|
-
|
|
51
|
-
const lines: string[] = [];
|
|
52
|
-
const verdictEmoji = entry.decision === "allow" ? "\u2705" : "\u274c";
|
|
53
|
-
const changeNote = previousHashes.length > 0
|
|
54
|
-
? (hashChanged ? "\u2705 Plan was revised (hash changed)" : "\u26a0\ufe0f Plan unchanged since last review")
|
|
55
|
-
: "Initial review";
|
|
56
|
-
|
|
57
|
-
lines.push(`## Iteration ${entry.iteration} \u2014 ${entry.timestamp} \u2014 ${verdictEmoji} ${entry.verdict.toUpperCase()}`);
|
|
58
|
-
lines.push("");
|
|
59
|
-
lines.push(`- **Decision:** ${entry.decision}`);
|
|
60
|
-
lines.push(`- **Score:** ${entry.score.toFixed(2)}`);
|
|
61
|
-
lines.push(`- **Plan hash:** \`${entry.planHash}\``);
|
|
62
|
-
lines.push(`- **Status:** ${changeNote}`);
|
|
63
|
-
lines.push(`- **Full review:** [\`${path.basename(entry.reviewFolder)}/\`](${path.basename(entry.reviewFolder)}/index.md)`);
|
|
64
|
-
|
|
65
|
-
if (entry.topIssues.length > 0) {
|
|
66
|
-
lines.push("");
|
|
67
|
-
lines.push("**Top issues:**");
|
|
68
|
-
for (const issue of entry.topIssues) {
|
|
69
|
-
lines.push(`- ${issue}`);
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
lines.push("");
|
|
73
|
-
|
|
74
|
-
let output: string;
|
|
75
|
-
if (!existingContent || !existingContent.includes("# Plan Review Tracker")) {
|
|
76
|
-
output = [
|
|
77
|
-
"# Plan Review Tracker",
|
|
78
|
-
"",
|
|
79
|
-
"> Auto-generated by plan review hook. Shows review lifecycle across iterations.",
|
|
80
|
-
"> Check `plan.md` in each iteration folder to diff plan changes.",
|
|
81
|
-
"",
|
|
82
|
-
...lines,
|
|
83
|
-
].join("\n");
|
|
84
|
-
} else {
|
|
85
|
-
output = existingContent.trimEnd() + "\n\n" + lines.join("\n");
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
try {
|
|
89
|
-
fs.writeFileSync(trackerPath, output, "utf-8");
|
|
90
|
-
} catch (e) {
|
|
91
|
-
logWarn("artifacts", `Failed to write review tracker: ${e}`);
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
// ---------------------------------------------------------------------------
|
|
96
|
-
// Helpers
|
|
97
|
-
// ---------------------------------------------------------------------------
|
|
98
|
-
|
|
99
|
-
export function extractPreviousHashes(content: string): string[] {
|
|
100
|
-
const hashes: string[] = [];
|
|
101
|
-
const regex = /\*\*Plan hash:\*\* `([a-f0-9]+)`/g;
|
|
102
|
-
let match: RegExpExecArray | null;
|
|
103
|
-
while ((match = regex.exec(content)) !== null) {
|
|
104
|
-
hashes.push(match[1]!);
|
|
105
|
-
}
|
|
106
|
-
return hashes;
|
|
107
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* Review tracker management — human-readable lifecycle summary.
|
|
3
|
+
* Extracted from artifacts.ts.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import * as fs from "node:fs";
|
|
7
|
+
import * as path from "node:path";
|
|
8
|
+
import { logWarn } from "../../../_shared/lib-ts/base/logger.js";
|
|
9
|
+
|
|
10
|
+
// ---------------------------------------------------------------------------
|
|
11
|
+
// Types
|
|
12
|
+
// ---------------------------------------------------------------------------
|
|
13
|
+
|
|
14
|
+
export interface ReviewTrackerEntry {
|
|
15
|
+
iteration: number;
|
|
16
|
+
timestamp: string;
|
|
17
|
+
planHash: string;
|
|
18
|
+
verdict: string;
|
|
19
|
+
decision: string;
|
|
20
|
+
score: number;
|
|
21
|
+
topIssues: string[];
|
|
22
|
+
reviewFolder: string;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// ---------------------------------------------------------------------------
|
|
26
|
+
// Tracker Writing
|
|
27
|
+
// ---------------------------------------------------------------------------
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Build or update the review-tracker.md in the cc-native reviews directory.
|
|
31
|
+
*/
|
|
32
|
+
export function writeReviewTracker(
|
|
33
|
+
ccNativeReviewsDir: string,
|
|
34
|
+
entry: ReviewTrackerEntry,
|
|
35
|
+
): void {
|
|
36
|
+
const trackerPath = path.join(ccNativeReviewsDir, "review-tracker.md");
|
|
37
|
+
|
|
38
|
+
let existingContent = "";
|
|
39
|
+
try {
|
|
40
|
+
if (fs.existsSync(trackerPath)) {
|
|
41
|
+
existingContent = fs.readFileSync(trackerPath, "utf-8");
|
|
42
|
+
}
|
|
43
|
+
} catch {
|
|
44
|
+
// Fresh start
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const previousHashes = extractPreviousHashes(existingContent);
|
|
48
|
+
const hashChanged = previousHashes.length > 0 &&
|
|
49
|
+
previousHashes[previousHashes.length - 1] !== entry.planHash;
|
|
50
|
+
|
|
51
|
+
const lines: string[] = [];
|
|
52
|
+
const verdictEmoji = entry.decision === "allow" ? "\u2705" : "\u274c";
|
|
53
|
+
const changeNote = previousHashes.length > 0
|
|
54
|
+
? (hashChanged ? "\u2705 Plan was revised (hash changed)" : "\u26a0\ufe0f Plan unchanged since last review")
|
|
55
|
+
: "Initial review";
|
|
56
|
+
|
|
57
|
+
lines.push(`## Iteration ${entry.iteration} \u2014 ${entry.timestamp} \u2014 ${verdictEmoji} ${entry.verdict.toUpperCase()}`);
|
|
58
|
+
lines.push("");
|
|
59
|
+
lines.push(`- **Decision:** ${entry.decision}`);
|
|
60
|
+
lines.push(`- **Score:** ${entry.score.toFixed(2)}`);
|
|
61
|
+
lines.push(`- **Plan hash:** \`${entry.planHash}\``);
|
|
62
|
+
lines.push(`- **Status:** ${changeNote}`);
|
|
63
|
+
lines.push(`- **Full review:** [\`${path.basename(entry.reviewFolder)}/\`](${path.basename(entry.reviewFolder)}/index.md)`);
|
|
64
|
+
|
|
65
|
+
if (entry.topIssues.length > 0) {
|
|
66
|
+
lines.push("");
|
|
67
|
+
lines.push("**Top issues:**");
|
|
68
|
+
for (const issue of entry.topIssues) {
|
|
69
|
+
lines.push(`- ${issue}`);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
lines.push("");
|
|
73
|
+
|
|
74
|
+
let output: string;
|
|
75
|
+
if (!existingContent || !existingContent.includes("# Plan Review Tracker")) {
|
|
76
|
+
output = [
|
|
77
|
+
"# Plan Review Tracker",
|
|
78
|
+
"",
|
|
79
|
+
"> Auto-generated by plan review hook. Shows review lifecycle across iterations.",
|
|
80
|
+
"> Check `plan.md` in each iteration folder to diff plan changes.",
|
|
81
|
+
"",
|
|
82
|
+
...lines,
|
|
83
|
+
].join("\n");
|
|
84
|
+
} else {
|
|
85
|
+
output = existingContent.trimEnd() + "\n\n" + lines.join("\n");
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
try {
|
|
89
|
+
fs.writeFileSync(trackerPath, output, "utf-8");
|
|
90
|
+
} catch (e) {
|
|
91
|
+
logWarn("artifacts", `Failed to write review tracker: ${e}`);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// ---------------------------------------------------------------------------
|
|
96
|
+
// Helpers
|
|
97
|
+
// ---------------------------------------------------------------------------
|
|
98
|
+
|
|
99
|
+
export function extractPreviousHashes(content: string): string[] {
|
|
100
|
+
const hashes: string[] = [];
|
|
101
|
+
const regex = /\*\*Plan hash:\*\* `([a-f0-9]+)`/g;
|
|
102
|
+
let match: RegExpExecArray | null;
|
|
103
|
+
while ((match = regex.exec(content)) !== null) {
|
|
104
|
+
hashes.push(match[1]!);
|
|
105
|
+
}
|
|
106
|
+
return hashes;
|
|
107
|
+
}
|
|
@@ -1,119 +1,119 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* File I/O for review artifacts.
|
|
3
|
-
* Extracted from artifacts.ts.
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import * as fs from "node:fs";
|
|
7
|
-
import * as path from "node:path";
|
|
8
|
-
import { atomicWrite } from "../../../_shared/lib-ts/base/atomic-write.js";
|
|
9
|
-
import { logDebug, logWarn, logError } from "../../../_shared/lib-ts/base/logger.js";
|
|
10
|
-
import { sanitizeFilename } from "../../../_shared/lib-ts/base/constants.js";
|
|
11
|
-
import { ENABLE_ROBUST_PLAN_WRITES } from "../constants.js";
|
|
12
|
-
import type { CombinedReviewResult, CorroborationResult } from "../types.js";
|
|
13
|
-
import {
|
|
14
|
-
formatCombinedMarkdown,
|
|
15
|
-
buildCombinedJson,
|
|
16
|
-
generateReviewIndex,
|
|
17
|
-
} from "./format.js";
|
|
18
|
-
|
|
19
|
-
// ---------------------------------------------------------------------------
|
|
20
|
-
// Artifact Writing
|
|
21
|
-
// ---------------------------------------------------------------------------
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Write combined review artifacts to context reviews folder.
|
|
25
|
-
* Uses atomic writes for critical files when ENABLE_ROBUST_PLAN_WRITES is true.
|
|
26
|
-
*/
|
|
27
|
-
export function writeCombinedArtifacts(
|
|
28
|
-
base: string,
|
|
29
|
-
plan: string,
|
|
30
|
-
result: CombinedReviewResult,
|
|
31
|
-
payload: Record<string, unknown>,
|
|
32
|
-
settings?: Record<string, unknown>,
|
|
33
|
-
contextReviewsDir?: string,
|
|
34
|
-
reviewFolder?: string,
|
|
35
|
-
iteration?: number,
|
|
36
|
-
corroboration?: CorroborationResult,
|
|
37
|
-
): string {
|
|
38
|
-
const outDir = reviewFolder ?? contextReviewsDir;
|
|
39
|
-
if (!outDir) {
|
|
40
|
-
throw new Error("Either contextReviewsDir or reviewFolder is required");
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
logDebug("utils", `Using review folder: ${outDir}`);
|
|
44
|
-
|
|
45
|
-
try {
|
|
46
|
-
fs.mkdirSync(outDir, { recursive: true });
|
|
47
|
-
} catch (e: unknown) {
|
|
48
|
-
logError("utils", `Cannot create directory ${outDir}: ${e}`);
|
|
49
|
-
throw e;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
// JSON write
|
|
53
|
-
const jsonPath = path.join(outDir, "review.json");
|
|
54
|
-
const jsonData = buildCombinedJson(result);
|
|
55
|
-
writeFile(jsonPath, JSON.stringify(jsonData, null, 2));
|
|
56
|
-
|
|
57
|
-
// Markdown write
|
|
58
|
-
const mdPath = path.join(outDir, "review.md");
|
|
59
|
-
const mdContent = formatCombinedMarkdown(result, settings, corroboration);
|
|
60
|
-
writeFile(mdPath, mdContent);
|
|
61
|
-
|
|
62
|
-
// Individual reviewer writes (non-critical)
|
|
63
|
-
const reviewerOutputDir = path.join(outDir, "reviewer-output");
|
|
64
|
-
try {
|
|
65
|
-
fs.mkdirSync(reviewerOutputDir, { recursive: true });
|
|
66
|
-
} catch (e) {
|
|
67
|
-
logWarn("artifacts", `Failed to create reviewer-output dir: ${e}`);
|
|
68
|
-
}
|
|
69
|
-
for (const [name, r] of Object.entries(result.agents)) {
|
|
70
|
-
if (r.data) {
|
|
71
|
-
writeFileNonCritical(
|
|
72
|
-
path.join(reviewerOutputDir, `${sanitizeFilename(name)}.json`),
|
|
73
|
-
JSON.stringify(r.data, null, 2),
|
|
74
|
-
);
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
// Generate index.md for folder-based reviews
|
|
79
|
-
if (reviewFolder) {
|
|
80
|
-
const indexContent = generateReviewIndex(result, iteration, settings);
|
|
81
|
-
writeFileNonCritical(path.join(outDir, "index.md"), indexContent);
|
|
82
|
-
return path.join(outDir, "index.md");
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
return mdPath;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
// ---------------------------------------------------------------------------
|
|
89
|
-
// File Write Helpers
|
|
90
|
-
// ---------------------------------------------------------------------------
|
|
91
|
-
|
|
92
|
-
export function writeFile(filePath: string, content: string): void {
|
|
93
|
-
try {
|
|
94
|
-
if (ENABLE_ROBUST_PLAN_WRITES) {
|
|
95
|
-
const [success, error] = atomicWrite(filePath, content);
|
|
96
|
-
if (!success) throw new Error(`Atomic write failed: ${error}`);
|
|
97
|
-
} else {
|
|
98
|
-
fs.writeFileSync(filePath, content, "utf-8");
|
|
99
|
-
}
|
|
100
|
-
} catch (e: unknown) {
|
|
101
|
-
logError("utils", `Failed to write ${path.basename(filePath)}: ${e}`);
|
|
102
|
-
throw e;
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
export function writeFileNonCritical(filePath: string, content: string): void {
|
|
107
|
-
try {
|
|
108
|
-
if (ENABLE_ROBUST_PLAN_WRITES) {
|
|
109
|
-
const [success, error] = atomicWrite(filePath, content);
|
|
110
|
-
if (!success) {
|
|
111
|
-
logWarn("utils", `Failed to write ${path.basename(filePath)}: ${error}`);
|
|
112
|
-
}
|
|
113
|
-
} else {
|
|
114
|
-
fs.writeFileSync(filePath, content, "utf-8");
|
|
115
|
-
}
|
|
116
|
-
} catch (e: unknown) {
|
|
117
|
-
logWarn("utils", `Failed to write ${path.basename(filePath)}: ${e}`);
|
|
118
|
-
}
|
|
119
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* File I/O for review artifacts.
|
|
3
|
+
* Extracted from artifacts.ts.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import * as fs from "node:fs";
|
|
7
|
+
import * as path from "node:path";
|
|
8
|
+
import { atomicWrite } from "../../../_shared/lib-ts/base/atomic-write.js";
|
|
9
|
+
import { logDebug, logWarn, logError } from "../../../_shared/lib-ts/base/logger.js";
|
|
10
|
+
import { sanitizeFilename } from "../../../_shared/lib-ts/base/constants.js";
|
|
11
|
+
import { ENABLE_ROBUST_PLAN_WRITES } from "../constants.js";
|
|
12
|
+
import type { CombinedReviewResult, CorroborationResult } from "../types.js";
|
|
13
|
+
import {
|
|
14
|
+
formatCombinedMarkdown,
|
|
15
|
+
buildCombinedJson,
|
|
16
|
+
generateReviewIndex,
|
|
17
|
+
} from "./format.js";
|
|
18
|
+
|
|
19
|
+
// ---------------------------------------------------------------------------
|
|
20
|
+
// Artifact Writing
|
|
21
|
+
// ---------------------------------------------------------------------------
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Write combined review artifacts to context reviews folder.
|
|
25
|
+
* Uses atomic writes for critical files when ENABLE_ROBUST_PLAN_WRITES is true.
|
|
26
|
+
*/
|
|
27
|
+
export function writeCombinedArtifacts(
|
|
28
|
+
base: string,
|
|
29
|
+
plan: string,
|
|
30
|
+
result: CombinedReviewResult,
|
|
31
|
+
payload: Record<string, unknown>,
|
|
32
|
+
settings?: Record<string, unknown>,
|
|
33
|
+
contextReviewsDir?: string,
|
|
34
|
+
reviewFolder?: string,
|
|
35
|
+
iteration?: number,
|
|
36
|
+
corroboration?: CorroborationResult,
|
|
37
|
+
): string {
|
|
38
|
+
const outDir = reviewFolder ?? contextReviewsDir;
|
|
39
|
+
if (!outDir) {
|
|
40
|
+
throw new Error("Either contextReviewsDir or reviewFolder is required");
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
logDebug("utils", `Using review folder: ${outDir}`);
|
|
44
|
+
|
|
45
|
+
try {
|
|
46
|
+
fs.mkdirSync(outDir, { recursive: true });
|
|
47
|
+
} catch (e: unknown) {
|
|
48
|
+
logError("utils", `Cannot create directory ${outDir}: ${e}`);
|
|
49
|
+
throw e;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// JSON write
|
|
53
|
+
const jsonPath = path.join(outDir, "review.json");
|
|
54
|
+
const jsonData = buildCombinedJson(result);
|
|
55
|
+
writeFile(jsonPath, JSON.stringify(jsonData, null, 2));
|
|
56
|
+
|
|
57
|
+
// Markdown write
|
|
58
|
+
const mdPath = path.join(outDir, "review.md");
|
|
59
|
+
const mdContent = formatCombinedMarkdown(result, settings, corroboration);
|
|
60
|
+
writeFile(mdPath, mdContent);
|
|
61
|
+
|
|
62
|
+
// Individual reviewer writes (non-critical)
|
|
63
|
+
const reviewerOutputDir = path.join(outDir, "reviewer-output");
|
|
64
|
+
try {
|
|
65
|
+
fs.mkdirSync(reviewerOutputDir, { recursive: true });
|
|
66
|
+
} catch (e) {
|
|
67
|
+
logWarn("artifacts", `Failed to create reviewer-output dir: ${e}`);
|
|
68
|
+
}
|
|
69
|
+
for (const [name, r] of Object.entries(result.agents)) {
|
|
70
|
+
if (r.data) {
|
|
71
|
+
writeFileNonCritical(
|
|
72
|
+
path.join(reviewerOutputDir, `${sanitizeFilename(name)}.json`),
|
|
73
|
+
JSON.stringify(r.data, null, 2),
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// Generate index.md for folder-based reviews
|
|
79
|
+
if (reviewFolder) {
|
|
80
|
+
const indexContent = generateReviewIndex(result, iteration, settings);
|
|
81
|
+
writeFileNonCritical(path.join(outDir, "index.md"), indexContent);
|
|
82
|
+
return path.join(outDir, "index.md");
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
return mdPath;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// ---------------------------------------------------------------------------
|
|
89
|
+
// File Write Helpers
|
|
90
|
+
// ---------------------------------------------------------------------------
|
|
91
|
+
|
|
92
|
+
export function writeFile(filePath: string, content: string): void {
|
|
93
|
+
try {
|
|
94
|
+
if (ENABLE_ROBUST_PLAN_WRITES) {
|
|
95
|
+
const [success, error] = atomicWrite(filePath, content);
|
|
96
|
+
if (!success) throw new Error(`Atomic write failed: ${error}`);
|
|
97
|
+
} else {
|
|
98
|
+
fs.writeFileSync(filePath, content, "utf-8");
|
|
99
|
+
}
|
|
100
|
+
} catch (e: unknown) {
|
|
101
|
+
logError("utils", `Failed to write ${path.basename(filePath)}: ${e}`);
|
|
102
|
+
throw e;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export function writeFileNonCritical(filePath: string, content: string): void {
|
|
107
|
+
try {
|
|
108
|
+
if (ENABLE_ROBUST_PLAN_WRITES) {
|
|
109
|
+
const [success, error] = atomicWrite(filePath, content);
|
|
110
|
+
if (!success) {
|
|
111
|
+
logWarn("utils", `Failed to write ${path.basename(filePath)}: ${error}`);
|
|
112
|
+
}
|
|
113
|
+
} else {
|
|
114
|
+
fs.writeFileSync(filePath, content, "utf-8");
|
|
115
|
+
}
|
|
116
|
+
} catch (e: unknown) {
|
|
117
|
+
logWarn("utils", `Failed to write ${path.basename(filePath)}: ${e}`);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Review artifact writing and formatting.
|
|
3
|
-
* Re-exports from artifacts/ subdirectory for backward compatibility.
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
export {
|
|
7
|
-
formatReviewMarkdown,
|
|
8
|
-
formatCombinedMarkdown,
|
|
9
|
-
buildInlineReviewSummary,
|
|
10
|
-
extractTopIssuesText,
|
|
11
|
-
buildHighIssuesDocument,
|
|
12
|
-
buildCorroborationReport,
|
|
13
|
-
generateReviewIndex,
|
|
14
|
-
buildCombinedJson,
|
|
15
|
-
writeCombinedArtifacts,
|
|
16
|
-
writeFile,
|
|
17
|
-
writeFileNonCritical,
|
|
18
|
-
writeReviewTracker,
|
|
19
|
-
extractPreviousHashes,
|
|
20
|
-
} from "./artifacts/index.js";
|
|
21
|
-
export type { ReviewTrackerEntry } from "./artifacts/index.js";
|
|
1
|
+
/**
|
|
2
|
+
* Review artifact writing and formatting.
|
|
3
|
+
* Re-exports from artifacts/ subdirectory for backward compatibility.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
export {
|
|
7
|
+
formatReviewMarkdown,
|
|
8
|
+
formatCombinedMarkdown,
|
|
9
|
+
buildInlineReviewSummary,
|
|
10
|
+
extractTopIssuesText,
|
|
11
|
+
buildHighIssuesDocument,
|
|
12
|
+
buildCorroborationReport,
|
|
13
|
+
generateReviewIndex,
|
|
14
|
+
buildCombinedJson,
|
|
15
|
+
writeCombinedArtifacts,
|
|
16
|
+
writeFile,
|
|
17
|
+
writeFileNonCritical,
|
|
18
|
+
writeReviewTracker,
|
|
19
|
+
extractPreviousHashes,
|
|
20
|
+
} from "./artifacts/index.js";
|
|
21
|
+
export type { ReviewTrackerEntry } from "./artifacts/index.js";
|