aiwcli 0.12.7 → 0.13.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/dist/commands/clean.d.ts +7 -0
- package/dist/commands/clean.js +17 -8
- package/dist/commands/clear.d.ts +85 -0
- package/dist/commands/clear.js +455 -347
- package/dist/commands/init/index.d.ts +15 -0
- package/dist/commands/init/index.js +79 -38
- package/dist/lib/gitignore-manager.js +12 -13
- package/dist/lib/settings-hierarchy.d.ts +13 -1
- package/dist/lib/settings-hierarchy.js +1 -1
- package/dist/lib/template-linter.d.ts +4 -0
- package/dist/lib/template-linter.js +1 -1
- package/dist/lib/tty-detection.d.ts +1 -0
- package/dist/lib/tty-detection.js +1 -0
- package/dist/templates/CLAUDE.md +27 -0
- package/dist/templates/_shared/.claude/settings.json +7 -7
- package/dist/templates/_shared/.claude/{commands/handoff.md → skills/handoff/SKILL.md} +4 -3
- package/dist/templates/_shared/.claude/{commands/handoff-resume.md → skills/handoff-resume/SKILL.md} +3 -2
- package/dist/templates/_shared/.claude/skills/meta-plan/SKILL.md +43 -0
- package/dist/templates/_shared/.codex/workflows/handoff.md +1 -1
- package/dist/templates/_shared/.codex/workflows/meta-plan.md +347 -0
- package/dist/templates/_shared/.windsurf/workflows/handoff.md +1 -1
- package/dist/templates/_shared/.windsurf/workflows/meta-plan.md +347 -0
- package/dist/templates/_shared/hooks-ts/lint_after_edit.ts +59 -0
- package/dist/templates/_shared/hooks-ts/session_end.ts +11 -10
- package/dist/templates/_shared/hooks-ts/session_start.ts +15 -12
- package/dist/templates/_shared/hooks-ts/user_prompt_submit.ts +12 -12
- 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/hook-utils.ts +26 -7
- package/dist/templates/_shared/lib-ts/base/inference.ts +19 -19
- package/dist/templates/_shared/lib-ts/base/lint-dispatch.ts +287 -0
- package/dist/templates/_shared/lib-ts/base/state-io.ts +4 -3
- package/dist/templates/_shared/lib-ts/base/subprocess-utils.ts +3 -3
- package/dist/templates/_shared/lib-ts/context/CLAUDE.md +134 -0
- package/dist/templates/_shared/lib-ts/context/context-formatter.ts +16 -15
- package/dist/templates/_shared/lib-ts/context/context-selector.ts +16 -16
- package/dist/templates/_shared/lib-ts/context/context-store.ts +15 -14
- package/dist/templates/_shared/lib-ts/context/plan-manager.ts +2 -2
- package/dist/templates/_shared/scripts/resolve-run.ts +61 -0
- package/dist/templates/_shared/scripts/resolve_context.ts +1 -1
- package/dist/templates/_shared/scripts/status_line.ts +100 -94
- package/dist/templates/_shared/{handoff-system → skills/handoff-system}/CLAUDE.md +433 -421
- package/dist/templates/_shared/{handoff-system → skills/handoff-system}/lib/document-generator.ts +5 -4
- package/dist/templates/_shared/{handoff-system → skills/handoff-system}/lib/handoff-reader.ts +2 -1
- package/dist/templates/_shared/{handoff-system → skills/handoff-system}/scripts/resume_handoff.ts +6 -6
- package/dist/templates/_shared/{handoff-system → skills/handoff-system}/scripts/save_handoff.ts +16 -17
- package/dist/templates/_shared/{handoff-system → skills/handoff-system}/workflows/handoff-resume.md +2 -2
- package/dist/templates/_shared/{handoff-system → skills/handoff-system}/workflows/handoff.md +3 -3
- package/dist/templates/_shared/skills/meta-plan/CLAUDE.md +44 -0
- package/dist/templates/_shared/skills/meta-plan/workflows/meta-plan.md +347 -0
- package/dist/templates/cc-native/.claude/commands/cc-native/specdev.md +1 -1
- package/dist/templates/cc-native/.claude/settings.json +86 -57
- 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 +599 -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 -106
- package/dist/templates/cc-native/_cc-native/{lib-ts/artifacts → artifacts/lib}/write.ts +119 -118
- 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 -74
- 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/cc-native-state.ts +15 -16
- package/dist/templates/cc-native/_cc-native/lib-ts/index.ts +116 -116
- package/dist/templates/cc-native/_cc-native/lib-ts/plan-discovery.ts +3 -3
- package/dist/templates/cc-native/_cc-native/lib-ts/rlm/embedding-indexer.ts +16 -12
- package/dist/templates/cc-native/_cc-native/lib-ts/rlm/hyde.ts +2 -3
- package/dist/templates/cc-native/_cc-native/lib-ts/rlm/index.ts +31 -31
- package/dist/templates/cc-native/_cc-native/lib-ts/rlm/logger.ts +7 -6
- package/dist/templates/cc-native/_cc-native/lib-ts/rlm/ollama-client.ts +9 -7
- package/dist/templates/cc-native/_cc-native/lib-ts/rlm/retrieval-pipeline.ts +17 -14
- package/dist/templates/cc-native/_cc-native/lib-ts/rlm/transcript-indexer.ts +41 -37
- package/dist/templates/cc-native/_cc-native/lib-ts/rlm/transcript-loader.ts +43 -33
- package/dist/templates/cc-native/_cc-native/lib-ts/rlm/transcript-searcher.ts +20 -20
- package/dist/templates/cc-native/_cc-native/lib-ts/rlm/types.ts +9 -8
- package/dist/templates/cc-native/_cc-native/lib-ts/rlm/vector-store.ts +4 -3
- package/dist/templates/cc-native/_cc-native/lib-ts/settings.ts +9 -10
- package/dist/templates/cc-native/_cc-native/lib-ts/state.ts +20 -19
- 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 +162 -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 +121 -130
- package/dist/templates/cc-native/_cc-native/{lib-ts → plan-review/lib}/plan-questions.ts +101 -102
- package/dist/templates/cc-native/_cc-native/{lib-ts → plan-review/lib}/review-pipeline.ts +507 -511
- package/dist/templates/cc-native/_cc-native/{lib-ts → plan-review/lib}/reviewers/agent.ts +73 -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 +6 -5
- package/dist/templates/cc-native/_cc-native/lib-ts/artifacts.ts +0 -21
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Barrel re-export for artifacts submodules.
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
export {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
} from "./format.js";
|
|
15
|
-
|
|
16
|
-
export {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
export {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Barrel re-export for artifacts submodules.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
export {
|
|
6
|
+
buildCombinedJson,
|
|
7
|
+
buildCorroborationReport,
|
|
8
|
+
buildHighIssuesDocument,
|
|
9
|
+
buildInlineReviewSummary,
|
|
10
|
+
extractTopIssuesText,
|
|
11
|
+
formatCombinedMarkdown,
|
|
12
|
+
formatReviewMarkdown,
|
|
13
|
+
generateReviewIndex,
|
|
14
|
+
} from "./format.js";
|
|
15
|
+
|
|
16
|
+
export {
|
|
17
|
+
extractPreviousHashes,
|
|
18
|
+
writeReviewTracker,
|
|
19
|
+
} from "./tracker.js";
|
|
20
|
+
|
|
21
|
+
export type { ReviewTrackerEntry } from "./tracker.js";
|
|
22
|
+
export {
|
|
23
|
+
writeCombinedArtifacts,
|
|
24
|
+
writeFile,
|
|
25
|
+
writeFileNonCritical,
|
|
26
|
+
} from "./write.js";
|
|
@@ -1,107 +1,108 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Review tracker management — human-readable lifecycle summary.
|
|
3
|
-
* Extracted from artifacts.ts.
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import * as fs from "node:fs";
|
|
1
|
+
/**
|
|
2
|
+
* Review tracker management — human-readable lifecycle summary.
|
|
3
|
+
* Extracted from artifacts.ts.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import * as fs from "node:fs";
|
|
7
7
|
import * as path from "node:path";
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
//
|
|
12
|
-
//
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
//
|
|
27
|
-
//
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
const
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
const
|
|
53
|
-
const
|
|
54
|
-
|
|
55
|
-
: "
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
lines.push(
|
|
59
|
-
lines.push(
|
|
60
|
-
lines.push(`- **
|
|
61
|
-
lines.push(`- **
|
|
62
|
-
lines.push(`- **
|
|
63
|
-
lines.push(`- **
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
lines.push("
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
"",
|
|
79
|
-
"
|
|
80
|
-
">
|
|
81
|
-
"",
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
//
|
|
97
|
-
//
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
const
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
8
|
+
|
|
9
|
+
import { logWarn } from "../../../_shared/lib-ts/base/logger.js";
|
|
10
|
+
|
|
11
|
+
// ---------------------------------------------------------------------------
|
|
12
|
+
// Types
|
|
13
|
+
// ---------------------------------------------------------------------------
|
|
14
|
+
|
|
15
|
+
export interface ReviewTrackerEntry {
|
|
16
|
+
iteration: number;
|
|
17
|
+
timestamp: string;
|
|
18
|
+
planHash: string;
|
|
19
|
+
verdict: string;
|
|
20
|
+
decision: string;
|
|
21
|
+
score: number;
|
|
22
|
+
topIssues: string[];
|
|
23
|
+
reviewFolder: string;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// ---------------------------------------------------------------------------
|
|
27
|
+
// Tracker Writing
|
|
28
|
+
// ---------------------------------------------------------------------------
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Build or update the review-tracker.md in the cc-native reviews directory.
|
|
32
|
+
*/
|
|
33
|
+
export function writeReviewTracker(
|
|
34
|
+
ccNativeReviewsDir: string,
|
|
35
|
+
entry: ReviewTrackerEntry,
|
|
36
|
+
): void {
|
|
37
|
+
const trackerPath = path.join(ccNativeReviewsDir, "review-tracker.md");
|
|
38
|
+
|
|
39
|
+
let existingContent = "";
|
|
40
|
+
try {
|
|
41
|
+
if (fs.existsSync(trackerPath)) {
|
|
42
|
+
existingContent = fs.readFileSync(trackerPath, "utf-8");
|
|
43
|
+
}
|
|
44
|
+
} catch {
|
|
45
|
+
// Fresh start
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const previousHashes = extractPreviousHashes(existingContent);
|
|
49
|
+
const hashChanged = previousHashes.length > 0 &&
|
|
50
|
+
previousHashes.at(-1) !== entry.planHash;
|
|
51
|
+
|
|
52
|
+
const lines: string[] = [];
|
|
53
|
+
const verdictEmoji = entry.decision === "allow" ? "\u2705" : "\u274C";
|
|
54
|
+
const changeNote = previousHashes.length > 0
|
|
55
|
+
? (hashChanged ? "\u2705 Plan was revised (hash changed)" : "\u26A0\uFE0F Plan unchanged since last review")
|
|
56
|
+
: "Initial review";
|
|
57
|
+
|
|
58
|
+
lines.push(`## Iteration ${entry.iteration} \u2014 ${entry.timestamp} \u2014 ${verdictEmoji} ${entry.verdict.toUpperCase()}`);
|
|
59
|
+
lines.push("");
|
|
60
|
+
lines.push(`- **Decision:** ${entry.decision}`);
|
|
61
|
+
lines.push(`- **Score:** ${entry.score.toFixed(2)}`);
|
|
62
|
+
lines.push(`- **Plan hash:** \`${entry.planHash}\``);
|
|
63
|
+
lines.push(`- **Status:** ${changeNote}`);
|
|
64
|
+
lines.push(`- **Full review:** [\`${path.basename(entry.reviewFolder)}/\`](${path.basename(entry.reviewFolder)}/index.md)`);
|
|
65
|
+
|
|
66
|
+
if (entry.topIssues.length > 0) {
|
|
67
|
+
lines.push("");
|
|
68
|
+
lines.push("**Top issues:**");
|
|
69
|
+
for (const issue of entry.topIssues) {
|
|
70
|
+
lines.push(`- ${issue}`);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
lines.push("");
|
|
74
|
+
|
|
75
|
+
let output: string;
|
|
76
|
+
if (!existingContent || !existingContent.includes("# Plan Review Tracker")) {
|
|
77
|
+
output = [
|
|
78
|
+
"# Plan Review Tracker",
|
|
79
|
+
"",
|
|
80
|
+
"> Auto-generated by plan review hook. Shows review lifecycle across iterations.",
|
|
81
|
+
"> Check `plan.md` in each iteration folder to diff plan changes.",
|
|
82
|
+
"",
|
|
83
|
+
...lines,
|
|
84
|
+
].join("\n");
|
|
85
|
+
} else {
|
|
86
|
+
output = existingContent.trimEnd() + "\n\n" + lines.join("\n");
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
try {
|
|
90
|
+
fs.writeFileSync(trackerPath, output, "utf-8");
|
|
91
|
+
} catch (error) {
|
|
92
|
+
logWarn("artifacts", `Failed to write review tracker: ${error}`);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// ---------------------------------------------------------------------------
|
|
97
|
+
// Helpers
|
|
98
|
+
// ---------------------------------------------------------------------------
|
|
99
|
+
|
|
100
|
+
export function extractPreviousHashes(content: string): string[] {
|
|
101
|
+
const hashes: string[] = [];
|
|
102
|
+
const regex = /\*\*Plan hash:\*\* `([a-f0-9]+)`/g;
|
|
103
|
+
let match: RegExpExecArray | null;
|
|
104
|
+
while ((match = regex.exec(content)) !== null) {
|
|
105
|
+
hashes.push(match[1]!);
|
|
106
|
+
}
|
|
107
|
+
return hashes;
|
|
108
|
+
}
|
|
@@ -1,119 +1,120 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* File I/O for review artifacts.
|
|
3
|
-
* Extracted from artifacts.ts.
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import * as fs from "node:fs";
|
|
1
|
+
/**
|
|
2
|
+
* File I/O for review artifacts.
|
|
3
|
+
* Extracted from artifacts.ts.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import * as fs from "node:fs";
|
|
7
7
|
import * as path from "node:path";
|
|
8
|
-
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
} from "
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
//
|
|
21
|
-
//
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
*
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
const
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
const
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
//
|
|
90
|
-
//
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
}
|
|
8
|
+
|
|
9
|
+
import {
|
|
10
|
+
formatCombinedMarkdown,
|
|
11
|
+
buildCombinedJson,
|
|
12
|
+
generateReviewIndex,
|
|
13
|
+
} from "./format.js";
|
|
14
|
+
import { atomicWrite } from "../../../_shared/lib-ts/base/atomic-write.js";
|
|
15
|
+
import { sanitizeFilename } from "../../../_shared/lib-ts/base/constants.js";
|
|
16
|
+
import { logDebug, logWarn, logError } from "../../../_shared/lib-ts/base/logger.js";
|
|
17
|
+
import { ENABLE_ROBUST_PLAN_WRITES } from "../../lib-ts/constants.js";
|
|
18
|
+
import type { CombinedReviewResult, CorroborationResult } from "../../lib-ts/types.js";
|
|
19
|
+
|
|
20
|
+
// ---------------------------------------------------------------------------
|
|
21
|
+
// Artifact Writing
|
|
22
|
+
// ---------------------------------------------------------------------------
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Write combined review artifacts to context reviews folder.
|
|
26
|
+
* Uses atomic writes for critical files when ENABLE_ROBUST_PLAN_WRITES is true.
|
|
27
|
+
*/
|
|
28
|
+
export function writeCombinedArtifacts(
|
|
29
|
+
base: string,
|
|
30
|
+
plan: string,
|
|
31
|
+
result: CombinedReviewResult,
|
|
32
|
+
payload: Record<string, unknown>,
|
|
33
|
+
settings?: Record<string, unknown>,
|
|
34
|
+
contextReviewsDir?: string,
|
|
35
|
+
reviewFolder?: string,
|
|
36
|
+
iteration?: number,
|
|
37
|
+
corroboration?: CorroborationResult,
|
|
38
|
+
): string {
|
|
39
|
+
const outDir = reviewFolder ?? contextReviewsDir;
|
|
40
|
+
if (!outDir) {
|
|
41
|
+
throw new Error("Either contextReviewsDir or reviewFolder is required");
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
logDebug("utils", `Using review folder: ${outDir}`);
|
|
45
|
+
|
|
46
|
+
try {
|
|
47
|
+
fs.mkdirSync(outDir, { recursive: true });
|
|
48
|
+
} catch (error: unknown) {
|
|
49
|
+
logError("utils", `Cannot create directory ${outDir}: ${error}`);
|
|
50
|
+
throw error;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// JSON write
|
|
54
|
+
const jsonPath = path.join(outDir, "review.json");
|
|
55
|
+
const jsonData = buildCombinedJson(result);
|
|
56
|
+
writeFile(jsonPath, JSON.stringify(jsonData, null, 2));
|
|
57
|
+
|
|
58
|
+
// Markdown write
|
|
59
|
+
const mdPath = path.join(outDir, "review.md");
|
|
60
|
+
const mdContent = formatCombinedMarkdown(result, settings, corroboration);
|
|
61
|
+
writeFile(mdPath, mdContent);
|
|
62
|
+
|
|
63
|
+
// Individual reviewer writes (non-critical)
|
|
64
|
+
const reviewerOutputDir = path.join(outDir, "reviewer-output");
|
|
65
|
+
try {
|
|
66
|
+
fs.mkdirSync(reviewerOutputDir, { recursive: true });
|
|
67
|
+
} catch (error) {
|
|
68
|
+
logWarn("artifacts", `Failed to create reviewer-output dir: ${error}`);
|
|
69
|
+
}
|
|
70
|
+
for (const [name, r] of Object.entries(result.agents)) {
|
|
71
|
+
if (r.data) {
|
|
72
|
+
writeFileNonCritical(
|
|
73
|
+
path.join(reviewerOutputDir, `${sanitizeFilename(name)}.json`),
|
|
74
|
+
JSON.stringify(r.data, null, 2),
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// Generate index.md for folder-based reviews
|
|
80
|
+
if (reviewFolder) {
|
|
81
|
+
const indexContent = generateReviewIndex(result, iteration, settings);
|
|
82
|
+
writeFileNonCritical(path.join(outDir, "index.md"), indexContent);
|
|
83
|
+
return path.join(outDir, "index.md");
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
return mdPath;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// ---------------------------------------------------------------------------
|
|
90
|
+
// File Write Helpers
|
|
91
|
+
// ---------------------------------------------------------------------------
|
|
92
|
+
|
|
93
|
+
export function writeFile(filePath: string, content: string): void {
|
|
94
|
+
try {
|
|
95
|
+
if (ENABLE_ROBUST_PLAN_WRITES) {
|
|
96
|
+
const [success, error] = atomicWrite(filePath, content);
|
|
97
|
+
if (!success) throw new Error(`Atomic write failed: ${error}`);
|
|
98
|
+
} else {
|
|
99
|
+
fs.writeFileSync(filePath, content, "utf-8");
|
|
100
|
+
}
|
|
101
|
+
} catch (error: unknown) {
|
|
102
|
+
logError("utils", `Failed to write ${path.basename(filePath)}: ${error}`);
|
|
103
|
+
throw error;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export function writeFileNonCritical(filePath: string, content: string): void {
|
|
108
|
+
try {
|
|
109
|
+
if (ENABLE_ROBUST_PLAN_WRITES) {
|
|
110
|
+
const [success, error] = atomicWrite(filePath, content);
|
|
111
|
+
if (!success) {
|
|
112
|
+
logWarn("utils", `Failed to write ${path.basename(filePath)}: ${error}`);
|
|
113
|
+
}
|
|
114
|
+
} else {
|
|
115
|
+
fs.writeFileSync(filePath, content, "utf-8");
|
|
116
|
+
}
|
|
117
|
+
} catch (error: unknown) {
|
|
118
|
+
logWarn("utils", `Failed to write ${path.basename(filePath)}: ${error}`);
|
|
119
|
+
}
|
|
120
|
+
}
|