create-quiver 0.17.5 → 0.17.6

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.
Files changed (32) hide show
  1. package/docs/TROUBLESHOOTING.md +52 -0
  2. package/docs/reference/commands.md +3 -0
  3. package/docs/workflows/existing-project-ai-quiver-setup.md +0 -1
  4. package/docs/workflows/existing-project.md +1 -0
  5. package/package.json +1 -1
  6. package/specs/quiver-v43-cli-i18n-audit-release-readiness/command-language-mode-matrix.json +1 -0
  7. package/specs/quiver-v57-evidence-budget-recovery-ux/EVIDENCE_REPORT.md +27 -0
  8. package/specs/quiver-v57-evidence-budget-recovery-ux/EXECUTION_PLAN.md +41 -0
  9. package/specs/quiver-v57-evidence-budget-recovery-ux/SPEC.md +139 -0
  10. package/specs/quiver-v57-evidence-budget-recovery-ux/STATUS.md +20 -0
  11. package/specs/quiver-v57-evidence-budget-recovery-ux/pr.md +124 -0
  12. package/specs/quiver-v57-evidence-budget-recovery-ux/slices/slice-01-recovery-contract-security-classifier/CLOSURE_BRIEF.md +22 -0
  13. package/specs/quiver-v57-evidence-budget-recovery-ux/slices/slice-01-recovery-contract-security-classifier/EXECUTION_BRIEF.md +58 -0
  14. package/specs/quiver-v57-evidence-budget-recovery-ux/slices/slice-01-recovery-contract-security-classifier/pr.md +12 -0
  15. package/specs/quiver-v57-evidence-budget-recovery-ux/slices/slice-01-recovery-contract-security-classifier/slice.json +60 -0
  16. package/specs/quiver-v57-evidence-budget-recovery-ux/slices/slice-02-budget-command-recommendation/CLOSURE_BRIEF.md +9 -0
  17. package/specs/quiver-v57-evidence-budget-recovery-ux/slices/slice-02-budget-command-recommendation/EXECUTION_BRIEF.md +54 -0
  18. package/specs/quiver-v57-evidence-budget-recovery-ux/slices/slice-02-budget-command-recommendation/pr.md +12 -0
  19. package/specs/quiver-v57-evidence-budget-recovery-ux/slices/slice-02-budget-command-recommendation/slice.json +60 -0
  20. package/specs/quiver-v57-evidence-budget-recovery-ux/slices/slice-03-cli-json-i18n-output/CLOSURE_BRIEF.md +10 -0
  21. package/specs/quiver-v57-evidence-budget-recovery-ux/slices/slice-03-cli-json-i18n-output/EXECUTION_BRIEF.md +58 -0
  22. package/specs/quiver-v57-evidence-budget-recovery-ux/slices/slice-03-cli-json-i18n-output/pr.md +13 -0
  23. package/specs/quiver-v57-evidence-budget-recovery-ux/slices/slice-03-cli-json-i18n-output/slice.json +68 -0
  24. package/specs/quiver-v57-evidence-budget-recovery-ux/slices/slice-04-integration-fixtures-docs-release-smoke/CLOSURE_BRIEF.md +14 -0
  25. package/specs/quiver-v57-evidence-budget-recovery-ux/slices/slice-04-integration-fixtures-docs-release-smoke/EXECUTION_BRIEF.md +55 -0
  26. package/specs/quiver-v57-evidence-budget-recovery-ux/slices/slice-04-integration-fixtures-docs-release-smoke/pr.md +14 -0
  27. package/specs/quiver-v57-evidence-budget-recovery-ux/slices/slice-04-integration-fixtures-docs-release-smoke/slice.json +65 -0
  28. package/src/create-quiver/commands/ai.js +96 -1
  29. package/src/create-quiver/lib/ai/analyze-project-recovery.js +736 -0
  30. package/src/create-quiver/lib/ai/analyze-project-validation.js +1 -0
  31. package/src/create-quiver/lib/i18n/messages/en.js +6 -0
  32. package/src/create-quiver/lib/i18n/messages/es.js +6 -0
@@ -0,0 +1,54 @@
1
+ # EXECUTION_BRIEF - slice-02 Budget + Command Recommendation
2
+
3
+ ## Objective
4
+
5
+ Calculate safe budget recommendations and a rerun command from the slice-01 recovery classification output.
6
+
7
+ ## Context
8
+
9
+ This slice consumes classification data only. It must not decide path safety or read raw evidence paths directly.
10
+
11
+ ## Scope
12
+
13
+ - Calculate `recommended_max_files` and `recommended_max_bytes`.
14
+ - Preserve original budgets and never lower them.
15
+ - Apply caps and return `scope_required` when recommendations exceed caps.
16
+ - Prefer enabling category flags when appropriate.
17
+ - Build a one-line portable command preserving relevant flags.
18
+ - Add unit tests for budget math and command preservation.
19
+
20
+ ## Acceptance Criteria
21
+
22
+ - Recommendations only use safe-to-include evidence.
23
+ - Unsafe and metadata-only evidence do not increase budget.
24
+ - Existing budget values are never reduced.
25
+ - Caps prevent runaway recommendations.
26
+ - Recommended command preserves `--deep`, provider/model, scope/category/lang/strict flags.
27
+ - Transient flags such as `--json` and `--dry-run` are not preserved.
28
+
29
+ ## Expected Files
30
+
31
+ - `src/create-quiver/lib/ai/analyze-project-recovery.js`
32
+ - `tests/lib/ai-analyze-project-recovery.test.js`
33
+ - `specs/quiver-v57-evidence-budget-recovery-ux/**`
34
+
35
+ ## Validation
36
+
37
+ ```bash
38
+ node --test tests/lib/ai-analyze-project-recovery.test.js
39
+ node bin/create-quiver.js spec validate specs/quiver-v57-evidence-budget-recovery-ux --strict
40
+ git diff --check
41
+ ```
42
+
43
+ ## Completion Checklist
44
+
45
+ - Budget formula is implemented from classification output only.
46
+ - Caps are enforced and tested.
47
+ - Command builder preserves relevant flags and drops transient flags.
48
+ - Unsafe and metadata-only evidence do not increase budgets.
49
+ - Slice closure brief records validation evidence.
50
+
51
+ ## Constraints
52
+
53
+ - Do not alter CLI rendering in this slice.
54
+ - Do not recalculate security.
@@ -0,0 +1,12 @@
1
+ # PR - slice-02 Budget + Command Recommendation
2
+
3
+ ## Summary
4
+
5
+ - Adds budget calculation for safe missing evidence.
6
+ - Adds recovery caps and `scope_required` fallback.
7
+ - Adds one-line command builder that preserves relevant flags and drops transient flags.
8
+ - Keeps unsafe and metadata-only evidence out of budget expansion.
9
+
10
+ ## Validation
11
+
12
+ - PASS `node --test tests/lib/ai-analyze-project-recovery.test.js`
@@ -0,0 +1,60 @@
1
+ {
2
+ "slice_id": "slice-02-budget-command-recommendation",
3
+ "ticket": "QUIVER-57-02",
4
+ "type": "feature",
5
+ "title": "Budget + Command Recommendation",
6
+ "objective": "Generate safe rerun budget and command recommendations from recovery classification.",
7
+ "description": "Adds safe recovery budget calculation, caps, category flag hints, and a rerun command builder based only on classified evidence.",
8
+ "git": {
9
+ "branch_type": "feature",
10
+ "base_branch": "main",
11
+ "branch_slug": "v57-budget-command-recommendation",
12
+ "branch_name": "feature/QUIVER-57-02-v57-budget-command-recommendation"
13
+ },
14
+ "files": [
15
+ "src/create-quiver/lib/ai/analyze-project-recovery.js",
16
+ "tests/lib/ai-analyze-project-recovery.test.js",
17
+ "specs/quiver-v57-evidence-budget-recovery-ux/**"
18
+ ],
19
+ "allowed_write_paths": [
20
+ "src/create-quiver/lib/ai/analyze-project-recovery.js",
21
+ "tests/lib/ai-analyze-project-recovery.test.js",
22
+ "specs/quiver-v57-evidence-budget-recovery-ux/**"
23
+ ],
24
+ "depends_on": ["slice-01-recovery-contract-security-classifier"],
25
+ "parallel_safe": "never",
26
+ "parallel_safe_reason": "Consumes the finalized recovery classification contract.",
27
+ "must": [
28
+ "Calculate recommended max files and max bytes from recovery classification output only.",
29
+ "Never recommend budgets lower than the user's current effective budgets.",
30
+ "Apply caps so recovery cannot suggest runaway context expansion.",
31
+ "Preserve relevant analyze-project flags in the suggested command.",
32
+ "Drop transient or unsafe flags from the suggested command.",
33
+ "Ensure unsafe, generated, dependency, and metadata-only evidence does not increase recommended budgets."
34
+ ],
35
+ "not_included": [
36
+ "CLI rendering changes.",
37
+ "Security classification recalculation.",
38
+ "Automatic retry with expanded budgets.",
39
+ "Provider schema changes.",
40
+ "Relaxing evidence validation."
41
+ ],
42
+ "acceptance": [
43
+ "Recommendations are calculated only from safe evidence paths.",
44
+ "Unsafe and metadata-only evidence never increases the recommended budget.",
45
+ "Existing user budgets are not reduced.",
46
+ "Caps prevent unbounded max-files or max-bytes suggestions.",
47
+ "The suggested command preserves deep, provider, model, scope, category, language, and strict flags when applicable.",
48
+ "The suggested command omits transient output and execution flags."
49
+ ],
50
+ "actual_hours": 4,
51
+ "tests": [
52
+ "node --test tests/lib/ai-analyze-project-recovery.test.js",
53
+ "node bin/create-quiver.js spec validate specs/quiver-v57-evidence-budget-recovery-ux --strict",
54
+ "git diff --check"
55
+ ],
56
+ "estimated_hours": 4,
57
+ "status": "completed",
58
+ "started_at": "2026-06-18T00:00:00.000Z",
59
+ "completed_at": "2026-06-18T00:00:00.000Z"
60
+ }
@@ -0,0 +1,10 @@
1
+ # CLOSURE_BRIEF - slice-03 CLI + JSON + i18n Output
2
+
3
+ ## Summary
4
+
5
+ Integrated recovery guidance into final analyze-project evidence validation failures.
6
+
7
+ ## Validation
8
+
9
+ - PASS `node --test tests/commands/ai-analyze-project-provider.test.js`
10
+ - PASS `node --test tests/lib/i18n-catalog.test.js`
@@ -0,0 +1,58 @@
1
+ # EXECUTION_BRIEF - slice-03 CLI + JSON + i18n Output
2
+
3
+ ## Objective
4
+
5
+ Render the recovery payload in human CLI output, JSON output, validation manifests, and English/Spanish messages.
6
+
7
+ ## Context
8
+
9
+ This slice consumes the recovery payload from slice 02. It must not recalculate path safety or budget recommendations.
10
+
11
+ ## Scope
12
+
13
+ - Integrate recovery payload into final `evidence-not-selected` failure handling.
14
+ - Print prominent recommended fix before long issue details.
15
+ - Add optional `recovery` object to `--json`.
16
+ - Persist recovery payload in validation manifest.
17
+ - Add English and Spanish messages.
18
+ - Add focused command and i18n tests.
19
+
20
+ ## Acceptance Criteria
21
+
22
+ - Human output highlights the recommended command or safe fallback.
23
+ - Long missing evidence lists are grouped and truncated.
24
+ - `--json` remains valid and backward-compatible.
25
+ - Spanish output renders recovery guidance when `--lang es` is active.
26
+ - Exit code remains non-zero for invalid final provider output.
27
+
28
+ ## Expected Files
29
+
30
+ - `src/create-quiver/commands/ai.js`
31
+ - `src/create-quiver/lib/ai/analyze-project-validation.js`
32
+ - `src/create-quiver/lib/i18n/messages/en.js`
33
+ - `src/create-quiver/lib/i18n/messages/es.js`
34
+ - `tests/commands/ai-analyze-project-provider.test.js`
35
+ - `tests/lib/i18n-catalog.test.js`
36
+ - `specs/quiver-v57-evidence-budget-recovery-ux/**`
37
+
38
+ ## Validation
39
+
40
+ ```bash
41
+ node --test tests/commands/ai-analyze-project-provider.test.js
42
+ node --test tests/lib/i18n-catalog.test.js
43
+ node bin/create-quiver.js spec validate specs/quiver-v57-evidence-budget-recovery-ux --strict
44
+ git diff --check
45
+ ```
46
+
47
+ ## Completion Checklist
48
+
49
+ - CLI output renders recovery guidance prominently.
50
+ - JSON output includes optional recovery payload.
51
+ - Validation manifest persists recovery payload.
52
+ - English and Spanish copy are covered by tests.
53
+ - Slice closure brief records validation evidence.
54
+
55
+ ## Constraints
56
+
57
+ - Do not weaken validation.
58
+ - Do not auto-apply recovery.
@@ -0,0 +1,13 @@
1
+ # PR - slice-03 CLI + JSON + i18n Output
2
+
3
+ ## Summary
4
+
5
+ - Adds prominent recovery guidance to final `evidence-not-selected` failures.
6
+ - Adds optional recovery payload to validation manifests and thrown errors.
7
+ - Adds English and Spanish recovery copy.
8
+ - Covers Spanish recovery command output in provider command tests.
9
+
10
+ ## Validation
11
+
12
+ - PASS `node --test tests/commands/ai-analyze-project-provider.test.js`
13
+ - PASS `node --test tests/lib/i18n-catalog.test.js`
@@ -0,0 +1,68 @@
1
+ {
2
+ "slice_id": "slice-03-cli-json-i18n-output",
3
+ "ticket": "QUIVER-57-03",
4
+ "type": "feature",
5
+ "title": "CLI + JSON + i18n Output",
6
+ "objective": "Expose recovery guidance in CLI output, JSON output, manifests, and English/Spanish messages.",
7
+ "description": "Integrates recovery payloads into analyze-project failure output, JSON error output, validation manifests, and English/Spanish copy.",
8
+ "git": {
9
+ "branch_type": "feature",
10
+ "base_branch": "main",
11
+ "branch_slug": "v57-cli-json-i18n-output",
12
+ "branch_name": "feature/QUIVER-57-03-v57-cli-json-i18n-output"
13
+ },
14
+ "files": [
15
+ "src/create-quiver/commands/ai.js",
16
+ "src/create-quiver/lib/ai/analyze-project-validation.js",
17
+ "src/create-quiver/lib/i18n/messages/en.js",
18
+ "src/create-quiver/lib/i18n/messages/es.js",
19
+ "tests/commands/ai-analyze-project-provider.test.js",
20
+ "tests/lib/i18n-catalog.test.js",
21
+ "specs/quiver-v57-evidence-budget-recovery-ux/**"
22
+ ],
23
+ "allowed_write_paths": [
24
+ "src/create-quiver/commands/ai.js",
25
+ "src/create-quiver/lib/ai/analyze-project-validation.js",
26
+ "src/create-quiver/lib/i18n/messages/en.js",
27
+ "src/create-quiver/lib/i18n/messages/es.js",
28
+ "tests/commands/ai-analyze-project-provider.test.js",
29
+ "tests/lib/i18n-catalog.test.js",
30
+ "specs/quiver-v57-evidence-budget-recovery-ux/**"
31
+ ],
32
+ "depends_on": ["slice-02-budget-command-recommendation"],
33
+ "parallel_safe": "never",
34
+ "parallel_safe_reason": "Consumes the recovery recommendation contract from slice 02.",
35
+ "must": [
36
+ "Detect evidence-not-selected validation failures and attach recovery guidance.",
37
+ "Render a prominent safe rerun command in human CLI output.",
38
+ "Expose recovery details in JSON output without breaking existing fields.",
39
+ "Persist recovery details in validation or repair manifests.",
40
+ "Provide English and Spanish copy for recovery guidance.",
41
+ "Keep analyze-project failing when final validation remains invalid."
42
+ ],
43
+ "not_included": [
44
+ "Weakening schema or evidence validation.",
45
+ "Automatically applying recovery budgets.",
46
+ "Changing budget recommendation formulas.",
47
+ "Adding live provider integration tests.",
48
+ "Writing final docs after invalid JSON."
49
+ ],
50
+ "acceptance": [
51
+ "Evidence validation failures include a highlighted next command.",
52
+ "Issue details remain grouped and truncated instead of producing noisy schema dumps.",
53
+ "JSON output remains valid and includes recovery details when available.",
54
+ "Spanish output includes equivalent actionable recovery guidance.",
55
+ "The command exits as a controlled failure until validation passes."
56
+ ],
57
+ "actual_hours": 4,
58
+ "tests": [
59
+ "node --test tests/commands/ai-analyze-project-provider.test.js",
60
+ "node --test tests/lib/i18n-catalog.test.js",
61
+ "node bin/create-quiver.js spec validate specs/quiver-v57-evidence-budget-recovery-ux --strict",
62
+ "git diff --check"
63
+ ],
64
+ "estimated_hours": 4,
65
+ "status": "completed",
66
+ "started_at": "2026-06-18T00:00:00.000Z",
67
+ "completed_at": "2026-06-18T00:00:00.000Z"
68
+ }
@@ -0,0 +1,14 @@
1
+ # CLOSURE_BRIEF - slice-04 Integration Fixtures + Docs + Release Smoke
2
+
3
+ ## Summary
4
+
5
+ Completed integration fixture coverage, documentation, and release evidence for evidence budget recovery UX.
6
+
7
+ ## Validation
8
+
9
+ - PASS `node --test tests/lib/ai-analyze-project-recovery.test.js`
10
+ - PASS `node --test tests/commands/ai-analyze-project-provider.test.js`
11
+ - PASS `node --test tests/lib/i18n-catalog.test.js`
12
+ - PASS `npm run docs:check`
13
+ - PASS `node bin/create-quiver.js spec validate specs/quiver-v57-evidence-budget-recovery-ux --strict`
14
+ - PASS `git diff --check`
@@ -0,0 +1,55 @@
1
+ # EXECUTION_BRIEF - slice-04 Integration Fixtures + Docs + Release Smoke
2
+
3
+ ## Objective
4
+
5
+ Validate the full recovery workflow with fixtures, docs, and release smoke evidence.
6
+
7
+ ## Context
8
+
9
+ This slice validates the feature end to end after the contracts and CLI output are implemented.
10
+
11
+ ## Scope
12
+
13
+ - Add sanitized nika-erp-style fixture coverage.
14
+ - Add docs/troubleshooting guidance.
15
+ - Validate manifests and JSON recovery payloads.
16
+ - Validate English and Spanish command output.
17
+ - Update release evidence.
18
+
19
+ ## Acceptance Criteria
20
+
21
+ - A nika-erp-style evidence failure produces a clear recovery command or safe fallback.
22
+ - Unsafe paths are never recommended.
23
+ - Manifests contain recovery classification and command data.
24
+ - Docs explain why `--max-bytes` exists and how to rerun safely.
25
+ - Release smoke evidence is recorded.
26
+
27
+ ## Expected Files
28
+
29
+ - `tests/commands/ai-analyze-project-provider.test.js`
30
+ - `docs/**`
31
+ - `specs/quiver-v57-evidence-budget-recovery-ux/**`
32
+
33
+ ## Validation
34
+
35
+ ```bash
36
+ node --test tests/lib/ai-analyze-project-recovery.test.js
37
+ node --test tests/commands/ai-analyze-project-provider.test.js
38
+ node --test tests/lib/i18n-catalog.test.js
39
+ npm run docs:check
40
+ node bin/create-quiver.js spec validate specs/quiver-v57-evidence-budget-recovery-ux --strict
41
+ git diff --check
42
+ ```
43
+
44
+ ## Completion Checklist
45
+
46
+ - Sanitized nika-erp-style fixture reproduces recovery guidance.
47
+ - Docs explain `--max-files`, `--max-bytes`, and safe rerun guidance.
48
+ - Release evidence records validation commands.
49
+ - No private repo content or secrets are stored.
50
+ - Slice closure brief records validation evidence.
51
+
52
+ ## Constraints
53
+
54
+ - Do not require a real private project fixture in CI.
55
+ - Do not store secrets or private project content.
@@ -0,0 +1,14 @@
1
+ # PR - slice-04 Integration Fixtures + Docs + Release Smoke
2
+
3
+ ## Summary
4
+
5
+ - Adds public troubleshooting guidance for `evidence-not-selected` recovery.
6
+ - Documents safe rerun commands and when to use `--max-files`, `--max-bytes`, `--include-tests`, `--include-db`, or `--scope`.
7
+ - Adds provider command coverage for Spanish recovery output, manifests, and `--json` recovery payloads.
8
+
9
+ ## Validation
10
+
11
+ - PASS `node --test tests/lib/ai-analyze-project-recovery.test.js`
12
+ - PASS `node --test tests/commands/ai-analyze-project-provider.test.js`
13
+ - PASS `node --test tests/lib/i18n-catalog.test.js`
14
+ - PASS `npm run docs:check`
@@ -0,0 +1,65 @@
1
+ {
2
+ "slice_id": "slice-04-integration-fixtures-docs-release-smoke",
3
+ "ticket": "QUIVER-57-04",
4
+ "type": "feature",
5
+ "title": "Integration Fixtures + Docs + Release Smoke",
6
+ "objective": "Validate recovery guidance end to end and document the safe rerun workflow.",
7
+ "description": "Completes integration evidence, documentation, troubleshooting guidance, and release-smoke coverage for the recovery workflow.",
8
+ "git": {
9
+ "branch_type": "feature",
10
+ "base_branch": "main",
11
+ "branch_slug": "v57-integration-fixtures-docs-release-smoke",
12
+ "branch_name": "feature/QUIVER-57-04-v57-integration-fixtures-docs-release-smoke"
13
+ },
14
+ "files": [
15
+ "tests/lib/ai-analyze-project-recovery.test.js",
16
+ "tests/commands/ai-analyze-project-provider.test.js",
17
+ "tests/lib/i18n-catalog.test.js",
18
+ "docs/**",
19
+ "specs/quiver-v57-evidence-budget-recovery-ux/**"
20
+ ],
21
+ "allowed_write_paths": [
22
+ "tests/lib/ai-analyze-project-recovery.test.js",
23
+ "tests/commands/ai-analyze-project-provider.test.js",
24
+ "tests/lib/i18n-catalog.test.js",
25
+ "docs/**",
26
+ "specs/quiver-v57-evidence-budget-recovery-ux/**"
27
+ ],
28
+ "depends_on": ["slice-03-cli-json-i18n-output"],
29
+ "parallel_safe": "after_dependencies",
30
+ "parallel_safe_reason": "Docs and fixture drafting can run in parallel after slice 03, but final smoke depends on all prior slices.",
31
+ "must": [
32
+ "Cover nika-erp-style evidence validation failures with sanitized fixtures.",
33
+ "Document how users should respond to budget and evidence recovery guidance.",
34
+ "Ensure recovery details are represented in manifests and JSON output.",
35
+ "Verify English and Spanish recovery output.",
36
+ "Record release-smoke evidence for the final workflow."
37
+ ],
38
+ "not_included": [
39
+ "Committing private real-project fixtures.",
40
+ "Storing secrets or private source content in tests.",
41
+ "Publishing npm packages.",
42
+ "Making live provider calls mandatory in CI.",
43
+ "Changing product code in analyzed repositories."
44
+ ],
45
+ "acceptance": [
46
+ "A nika-erp-style failure produces a clear recovery command.",
47
+ "Unsafe, generated, and metadata-only paths are not recommended as context expansion targets.",
48
+ "Validation manifests include recovery details when relevant.",
49
+ "Documentation explains why and how to adjust max-files and max-bytes.",
50
+ "Release evidence identifies the smoke command and expected controlled behavior."
51
+ ],
52
+ "actual_hours": 3,
53
+ "tests": [
54
+ "node --test tests/lib/ai-analyze-project-recovery.test.js",
55
+ "node --test tests/commands/ai-analyze-project-provider.test.js",
56
+ "node --test tests/lib/i18n-catalog.test.js",
57
+ "npm run docs:check",
58
+ "node bin/create-quiver.js spec validate specs/quiver-v57-evidence-budget-recovery-ux --strict",
59
+ "git diff --check"
60
+ ],
61
+ "estimated_hours": 3,
62
+ "status": "completed",
63
+ "started_at": "2026-06-18T00:00:00.000Z",
64
+ "completed_at": "2026-06-18T00:00:00.000Z"
65
+ }
@@ -32,6 +32,10 @@ const {
32
32
  parseAnalyzeProjectOutputWithRepair,
33
33
  writeAnalyzeProjectRepairManifest,
34
34
  } = require('../lib/ai/analyze-project-repair');
35
+ const {
36
+ buildEvidenceRecoveryPayload,
37
+ classifyEvidenceRecoveryIssues,
38
+ } = require('../lib/ai/analyze-project-recovery');
35
39
  const {
36
40
  confirmAnalyzeProjectWrites,
37
41
  reviewAnalyzeProjectDocProposal,
@@ -207,6 +211,40 @@ function formatAnalyzeProjectIssues(issues = [], maxIssues = 8) {
207
211
  return lines;
208
212
  }
209
213
 
214
+ function formatAnalyzeProjectRecoveryLines(recovery, translator = createTranslator('en')) {
215
+ if (!recovery || recovery.reason !== 'evidence_not_selected') {
216
+ return [];
217
+ }
218
+
219
+ const lines = [
220
+ '',
221
+ translator.t('analyze_project.recovery.title'),
222
+ ];
223
+
224
+ if (recovery.command) {
225
+ lines.push(
226
+ translator.t('analyze_project.recovery.reason'),
227
+ translator.t('analyze_project.recovery.recommended_command'),
228
+ recovery.command,
229
+ );
230
+ } else {
231
+ lines.push(translator.t('analyze_project.recovery.safe_fallback'));
232
+ }
233
+
234
+ if (recovery.budget) {
235
+ lines.push(translator.t('analyze_project.recovery.budget', {
236
+ files: recovery.budget.recommended_max_files || 0,
237
+ bytes: recovery.budget.recommended_max_bytes || 0,
238
+ }));
239
+ }
240
+
241
+ for (const warning of recovery.warnings || []) {
242
+ lines.push(`${translator.t('analyze_project.recovery.warning')}: ${warning}`);
243
+ }
244
+
245
+ return lines;
246
+ }
247
+
210
248
  function enhanceAnalyzeProjectAnalysisError(error, options = {}) {
211
249
  if (!error || error.code !== 'AI_ANALYZE_PROJECT_INVALID') {
212
250
  return error;
@@ -219,6 +257,7 @@ function enhanceAnalyzeProjectAnalysisError(error, options = {}) {
219
257
 
220
258
  const wrapped = new Error([
221
259
  error.message,
260
+ ...formatAnalyzeProjectRecoveryLines(options.recovery, options.translator),
222
261
  'Issues:',
223
262
  ...issueLines,
224
263
  options.repairManifest?.path ? `Repair manifest: ${options.repairManifest.path}` : '',
@@ -234,9 +273,40 @@ function enhanceAnalyzeProjectAnalysisError(error, options = {}) {
234
273
  wrapped.repair_manifest = options.repairManifest || null;
235
274
  wrapped.retry_manifest = options.retryManifest || null;
236
275
  wrapped.validation_manifest = options.validationManifest || null;
276
+ wrapped.recovery = options.recovery || null;
237
277
  return wrapped;
238
278
  }
239
279
 
280
+ function buildAnalyzeProjectEvidenceRecovery(repoRoot, error, report, options = {}) {
281
+ const issues = Array.isArray(error?.issues) ? error.issues : [];
282
+ if (!issues.some((issue) => (issue.issue || issue.code) === 'evidence-not-selected')) {
283
+ return null;
284
+ }
285
+
286
+ const classification = classifyEvidenceRecoveryIssues(repoRoot, issues, {
287
+ selectedFiles: report.selected_files || [],
288
+ omittedFiles: report.omitted_files || [],
289
+ safetyExclusions: report.safety_exclusions || [],
290
+ });
291
+ const payload = buildEvidenceRecoveryPayload(classification, {
292
+ budgets: report.budgets || {},
293
+ deep: report.options?.deep === true || options.deep === true,
294
+ includeDb: report.options?.include_db === true,
295
+ includeSource: report.options?.include_source === true,
296
+ includeTests: report.options?.include_tests === true,
297
+ lang: options.language,
298
+ model: options.model,
299
+ provider: options.provider,
300
+ scope: options.scope,
301
+ strict: options.strict === true,
302
+ });
303
+
304
+ return {
305
+ ...payload,
306
+ classification,
307
+ };
308
+ }
309
+
240
310
  function formatAnalyzeProjectFileLine(file) {
241
311
  const details = [];
242
312
  if (Array.isArray(file.signals) && file.signals.length > 0) {
@@ -2854,6 +2924,10 @@ async function runAnalyzeProject(repoRoot, options = {}) {
2854
2924
  });
2855
2925
  }
2856
2926
 
2927
+ const recovery = buildAnalyzeProjectEvidenceRecovery(repoRoot, error, report, {
2928
+ ...options,
2929
+ provider,
2930
+ });
2857
2931
  let validationManifest = null;
2858
2932
  try {
2859
2933
  validationManifest = writeAnalyzeProjectValidationManifest(repoRoot, {
@@ -2862,6 +2936,7 @@ async function runAnalyzeProject(repoRoot, options = {}) {
2862
2936
  command: 'ai analyze-project',
2863
2937
  runId: auditRunId,
2864
2938
  now: options.now,
2939
+ recovery,
2865
2940
  retry: {
2866
2941
  attempts: providerAttempts.length,
2867
2942
  max_retries: maxRetries,
@@ -2885,11 +2960,31 @@ async function runAnalyzeProject(repoRoot, options = {}) {
2885
2960
  validation: validationManifest,
2886
2961
  },
2887
2962
  });
2888
- throw enhanceAnalyzeProjectAnalysisError(error, {
2963
+ const enhancedError = enhanceAnalyzeProjectAnalysisError(error, {
2889
2964
  validationManifest,
2890
2965
  repairManifest: attemptRepairManifest,
2891
2966
  retryManifest,
2967
+ recovery,
2968
+ translator: progressTranslator,
2892
2969
  });
2970
+ if (options.json === true) {
2971
+ process.stdout.write(`${JSON.stringify({
2972
+ schema_version: 1,
2973
+ kind: 'quiver-analyze-project-error',
2974
+ ok: false,
2975
+ error: {
2976
+ code: enhancedError.code || null,
2977
+ message: error.message,
2978
+ },
2979
+ recovery,
2980
+ manifests: {
2981
+ repair: attemptRepairManifest,
2982
+ retry: retryManifest,
2983
+ validation: validationManifest,
2984
+ },
2985
+ }, null, 2)}\n`);
2986
+ }
2987
+ throw enhancedError;
2893
2988
  }
2894
2989
  }
2895
2990
  const completedReport = {