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,130 +1,121 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Output construction: issue truncation, verdict override, message building.
|
|
3
|
-
* Extracted from cc-native-plan-review.ts.
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import { logInfo } from "
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
// ---------------------------------------------------------------------------
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
)
|
|
37
|
-
|
|
38
|
-
if (
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
const
|
|
42
|
-
issues
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
// ---------------------------------------------------------------------------
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
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
|
-
const
|
|
95
|
-
|
|
96
|
-
const
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
`Revise the plan to address these issues, then call ExitPlanMode again. ` +
|
|
123
|
-
RESUBMIT_INSTRUCTION;
|
|
124
|
-
} else {
|
|
125
|
-
blockReason = `Plan review ${overall.toUpperCase()}${iterInfo}. Review complete. ${REVIEWER_CAVEAT}`;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
return { contextText, blockReason, shouldDeny };
|
|
129
|
-
}
|
|
130
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Output construction: issue truncation, verdict override, message building.
|
|
3
|
+
* Extracted from cc-native-plan-review.ts.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { logInfo } from "../../../_shared/lib-ts/base/logger.js";
|
|
7
|
+
import {
|
|
8
|
+
buildInlineReviewSummary,
|
|
9
|
+
extractTopIssuesText,
|
|
10
|
+
} from "../../artifacts/lib/format.js";
|
|
11
|
+
import type {
|
|
12
|
+
ReviewerResult,
|
|
13
|
+
CombinedReviewResult,
|
|
14
|
+
CorroborationResult,
|
|
15
|
+
IterationState,
|
|
16
|
+
} from "../../lib-ts/types.js";
|
|
17
|
+
|
|
18
|
+
const HOOK = "output-builder";
|
|
19
|
+
|
|
20
|
+
const REVIEWER_CAVEAT = "Reviewers have limited context compared to your full session — use your judgment to adopt valid points and dismiss genuine false positives. However, treat false positives as a clarity signal: if a reviewer misunderstood your plan, an agent executing it will likely hit the same confusion. Revise those sections to be unambiguous so no future reader — human or AI — makes the same mistake.";
|
|
21
|
+
const RESUBMIT_INSTRUCTION = "IMPORTANT: After revising the plan file, you MUST call ExitPlanMode again to trigger re-review. Do not end your turn or ask the user without calling ExitPlanMode.";
|
|
22
|
+
|
|
23
|
+
// ---------------------------------------------------------------------------
|
|
24
|
+
// Issue Truncation
|
|
25
|
+
// ---------------------------------------------------------------------------
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Truncate per-agent issues to top N by severity.
|
|
29
|
+
* Mutates agentResults[name].data.issues in place.
|
|
30
|
+
*/
|
|
31
|
+
export function truncateAgentIssues(
|
|
32
|
+
agentResults: Record<string, ReviewerResult>,
|
|
33
|
+
maxPerAgent: number,
|
|
34
|
+
): void {
|
|
35
|
+
for (const r of Object.values(agentResults)) {
|
|
36
|
+
if (!Array.isArray(r.data?.issues)) continue;
|
|
37
|
+
const issues = r.data.issues as Array<{ severity?: string }>;
|
|
38
|
+
if (issues.length <= maxPerAgent) continue;
|
|
39
|
+
const severityOrder: Record<string, number> = { high: 0, medium: 1, low: 2 };
|
|
40
|
+
issues.sort((a, b) => (severityOrder[a.severity ?? "low"] ?? 2) - (severityOrder[b.severity ?? "low"] ?? 2));
|
|
41
|
+
const originalCount = issues.length;
|
|
42
|
+
r.data.issues = issues.slice(0, maxPerAgent);
|
|
43
|
+
logInfo(HOOK, `${r.name}: truncated issues ${originalCount} → ${maxPerAgent}`);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// ---------------------------------------------------------------------------
|
|
48
|
+
// Verdict Override
|
|
49
|
+
// ---------------------------------------------------------------------------
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Override verdict to "fail" for agents exceeding high-issue threshold.
|
|
53
|
+
* Mutates agentResults[name].verdict in place.
|
|
54
|
+
*/
|
|
55
|
+
export function overrideVerdictsByThreshold(
|
|
56
|
+
agentResults: Record<string, ReviewerResult>,
|
|
57
|
+
threshold: number,
|
|
58
|
+
): void {
|
|
59
|
+
for (const r of Object.values(agentResults)) {
|
|
60
|
+
if (!r.verdict || r.verdict === "skip" || r.verdict === "error") continue;
|
|
61
|
+
const issues = Array.isArray(r.data?.issues) ? r.data.issues as Array<{ severity?: string }> : [];
|
|
62
|
+
const agentHigh = issues.filter(i => i.severity === "high").length;
|
|
63
|
+
if (agentHigh >= threshold) {
|
|
64
|
+
logInfo(HOOK, `${r.name}: verdict overridden to 'fail' (${agentHigh} high issues >= ${threshold})`);
|
|
65
|
+
r.verdict = "fail";
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// ---------------------------------------------------------------------------
|
|
71
|
+
// Output Building
|
|
72
|
+
// ---------------------------------------------------------------------------
|
|
73
|
+
|
|
74
|
+
export interface ReviewOutputParams {
|
|
75
|
+
combinedResult: CombinedReviewResult;
|
|
76
|
+
corroborationResult: CorroborationResult;
|
|
77
|
+
iterationState: IterationState;
|
|
78
|
+
reviewFile: string;
|
|
79
|
+
highIssuesPath: string;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export interface ReviewOutput {
|
|
83
|
+
contextText: string;
|
|
84
|
+
blockReason: string;
|
|
85
|
+
shouldDeny: boolean;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Build the final review output: context text and block reason.
|
|
90
|
+
*/
|
|
91
|
+
export function buildReviewOutput(params: ReviewOutputParams): ReviewOutput {
|
|
92
|
+
const { combinedResult, corroborationResult, iterationState } = params;
|
|
93
|
+
|
|
94
|
+
const shouldDeny = corroborationResult.blocking.length > 0;
|
|
95
|
+
const reviewScore = shouldDeny ? 1 : 0;
|
|
96
|
+
const overall = corroborationResult.verdict;
|
|
97
|
+
|
|
98
|
+
// Build inline summary (no individual issues — those go in blockReason)
|
|
99
|
+
const inlineSummary = buildInlineReviewSummary(combinedResult, 0, 800, corroborationResult);
|
|
100
|
+
const contextParts = [inlineSummary];
|
|
101
|
+
contextParts.push(`\nFull review: \`${params.reviewFile}\`\n`);
|
|
102
|
+
|
|
103
|
+
const contextText = contextParts.join("");
|
|
104
|
+
const iterInfo = ` (iteration ${iterationState.current}/${iterationState.max}, score=${reviewScore.toFixed(2)})`;
|
|
105
|
+
|
|
106
|
+
let blockReason: string;
|
|
107
|
+
if (shouldDeny) {
|
|
108
|
+
const topIssuesText = extractTopIssuesText(combinedResult, 15, "high");
|
|
109
|
+
blockReason = `Plan review FAILED${iterInfo}. ` +
|
|
110
|
+
`High-severity issues:\n${topIssuesText}\n\n` +
|
|
111
|
+
`Full details: \`${params.highIssuesPath}\`\n` +
|
|
112
|
+
`${REVIEWER_CAVEAT} ` +
|
|
113
|
+
`Revise the plan to address these issues, then call ExitPlanMode again. ` +
|
|
114
|
+
RESUBMIT_INSTRUCTION;
|
|
115
|
+
} else {
|
|
116
|
+
blockReason = `Plan review ${overall.toUpperCase()}${iterInfo}. Review complete. ${REVIEWER_CAVEAT}`;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
return { contextText, blockReason, shouldDeny };
|
|
120
|
+
}
|
|
121
|
+
|
|
@@ -1,102 +1,101 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Plan question generation — runs a fresh-context agent to identify
|
|
3
|
-
* questions, assumptions, and ambiguities in a plan before review.
|
|
4
|
-
* See cc-native-plan-review.ts for integration point (questions gate).
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import * as path from "node:path";
|
|
8
|
-
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import
|
|
13
|
-
import {
|
|
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
|
-
*
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
const
|
|
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
|
-
const
|
|
95
|
-
const
|
|
96
|
-
const
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* Plan question generation — runs a fresh-context agent to identify
|
|
3
|
+
* questions, assumptions, and ambiguities in a plan before review.
|
|
4
|
+
* See cc-native-plan-review.ts for integration point (questions gate).
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import * as path from "node:path";
|
|
8
|
+
|
|
9
|
+
import { runAgentReview } from "./reviewers/index.js";
|
|
10
|
+
import { QUESTIONS_SCHEMA } from "./reviewers/schemas.js";
|
|
11
|
+
import { logInfo, logWarn, logError } from "../../../_shared/lib-ts/base/logger.js";
|
|
12
|
+
import { findExecutable } from "../../../_shared/lib-ts/base/subprocess-utils.js";
|
|
13
|
+
import { aggregateAgents } from "../../lib-ts/aggregate-agents.js";
|
|
14
|
+
import type { AgentConfig } from "../../lib-ts/types.js";
|
|
15
|
+
|
|
16
|
+
// ---------------------------------------------------------------------------
|
|
17
|
+
// Types
|
|
18
|
+
// ---------------------------------------------------------------------------
|
|
19
|
+
|
|
20
|
+
export interface PlanQuestionsResult {
|
|
21
|
+
questions: string[];
|
|
22
|
+
assumptions: string[];
|
|
23
|
+
ambiguities: string[];
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// ---------------------------------------------------------------------------
|
|
27
|
+
// Provider assignment (local copy — avoids circular import from hook)
|
|
28
|
+
// ---------------------------------------------------------------------------
|
|
29
|
+
|
|
30
|
+
function assignProvider(agent: AgentConfig): AgentConfig {
|
|
31
|
+
// Default to claude provider with the agent's configured model
|
|
32
|
+
const found = findExecutable("claude");
|
|
33
|
+
if (found) {
|
|
34
|
+
return { ...agent, provider: "claude" };
|
|
35
|
+
}
|
|
36
|
+
logWarn("plan-questions", "Claude CLI not found, using agent defaults");
|
|
37
|
+
return agent;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// ---------------------------------------------------------------------------
|
|
41
|
+
// Main
|
|
42
|
+
// ---------------------------------------------------------------------------
|
|
43
|
+
|
|
44
|
+
const HOOK = "plan-questions";
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Run the plan-questions agent to generate questions about a plan.
|
|
48
|
+
* Returns structured questions/assumptions/ambiguities, or null on failure.
|
|
49
|
+
*
|
|
50
|
+
* The agent runs in a fresh context (no codebase, no session history)
|
|
51
|
+
* and uses QUESTIONS_SCHEMA instead of REVIEW_SCHEMA — the agent runner
|
|
52
|
+
* is schema-agnostic.
|
|
53
|
+
*/
|
|
54
|
+
export async function runPlanQuestions(
|
|
55
|
+
plan: string,
|
|
56
|
+
aiwcliDir: string,
|
|
57
|
+
timeout: number,
|
|
58
|
+
contextPath?: string,
|
|
59
|
+
sessionName?: string,
|
|
60
|
+
): Promise<PlanQuestionsResult | null> {
|
|
61
|
+
// Load the plan-questions agent from agents/plan-questions/
|
|
62
|
+
const questionsAgentDir = path.join(aiwcliDir, "_cc-native", "plan-review", "agents", "plan-questions");
|
|
63
|
+
const agents = aggregateAgents(questionsAgentDir);
|
|
64
|
+
|
|
65
|
+
if (agents.length === 0) {
|
|
66
|
+
logWarn(HOOK, `No agents found in ${questionsAgentDir}`);
|
|
67
|
+
return null;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// Use the first agent (PLAN-QUESTIONER)
|
|
71
|
+
let agent = agents[0]!;
|
|
72
|
+
logInfo(HOOK, `Using plan-questions agent: ${agent.name}`);
|
|
73
|
+
|
|
74
|
+
// Assign provider
|
|
75
|
+
agent = assignProvider(agent);
|
|
76
|
+
|
|
77
|
+
// Run the agent with QUESTIONS_SCHEMA
|
|
78
|
+
const result = await runAgentReview(
|
|
79
|
+
plan,
|
|
80
|
+
agent,
|
|
81
|
+
QUESTIONS_SCHEMA,
|
|
82
|
+
timeout,
|
|
83
|
+
contextPath,
|
|
84
|
+
sessionName ?? "unknown",
|
|
85
|
+
);
|
|
86
|
+
|
|
87
|
+
if (!result.ok) {
|
|
88
|
+
logError(HOOK, `Plan-questions agent failed: ${result.err}`);
|
|
89
|
+
return null;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// Extract structured data
|
|
93
|
+
const data = result.data ?? {};
|
|
94
|
+
const questions = Array.isArray(data.questions) ? (data.questions as string[]) : [];
|
|
95
|
+
const assumptions = Array.isArray(data.assumptions) ? (data.assumptions as string[]) : [];
|
|
96
|
+
const ambiguities = Array.isArray(data.ambiguities) ? (data.ambiguities as string[]) : [];
|
|
97
|
+
|
|
98
|
+
logInfo(HOOK, `Plan-questions result: ${questions.length} questions, ${assumptions.length} assumptions, ${ambiguities.length} ambiguities`);
|
|
99
|
+
|
|
100
|
+
return { questions, assumptions, ambiguities };
|
|
101
|
+
}
|