Skip to content

fix(codebase): write fallback evidence manifest so deep-enrich can start - #522

Merged
jeff-r2026 merged 1 commit into
Tencent:mainfrom
jimpablo:fix/508-extract-deep-enrich-manifest
Sep 12, 2026
Merged

jeff-r2026 merged 1 commit into
Tencent:mainfrom
jimpablo:fix/508-extract-deep-enrich-manifest

Conversation

@jimpablo

Copy link
Copy Markdown
Contributor

Summary

codebase --extract reported kind === 'component' facts but only wrote teamwiki/evidence/code/<project>/_manifest.json when AI enrichment succeeded. Small repos (no module with >= 5 facts), --skip-enrich, and AI failures left that file missing, so deep-enrich aborted with No components in _manifest.json while --lint still passed.

Extract now always writes a usable v2 evidence manifest when it has modules or component facts: AI output when enrich succeeds, otherwise a deterministic fallback (components[] with slug / docPath). User-facing English / --json output says when the fallback was written, or that deep-enrich will have no components when nothing can be written. Public empty-manifest errors no longer say to re-run extract. Hidden teamai deep-enrich exits non-zero when there are no components (previously exit 0).

Option C (lowering the >= 5 facts AI threshold) is intentionally not done; fallback covers that case without changing when AI is called.

Fixes #508.

Type of Change

  • Bug fix (non-breaking change that fixes an existing issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature causing existing behavior to change)
  • Documentation only
  • Refactor / internal cleanup

Test Plan

  • npx tsc --noEmit — clean
  • npx vitest run — 218 files / 3017 tests passed
  • npx vitest run src/__tests__/codebase-extract-fallback.test.ts src/__tests__/codebase-deep-enrich.test.ts src/__tests__/deep-enrich-graph-preserve.test.ts src/__tests__/import-dir.test.ts — 31/31 (includes Widget fixture, --skip-enrich, AI-fail, AI-success not overwritten, hidden after extract, empty-manifest exit 1)
  • npm run build then npx vitest run --config vitest.e2e.config.ts src/__tests__/e2e/codebase-extract-cli.test.ts — 9/9
  • Built CLI, issue codebase --extract and deep-enrich are not a closed loop: extract reports components but writes no _manifest.json, so deep-enrich aborts with "No components" #508 Widget repro (no API key):
    1. node dist/index.js codebase --extract <fixture> --project widget — exit 0, Facts: 1 (component:1), Wrote fallback _manifest.json (1 component, no AI enrich), both source-manifest.json and evidence/code/widget/_manifest.json present (components[0].slug + docPath set)
    2. node dist/index.js deep-enrich --project widget --wiki-root <fixture>/teamwiki — starts Phase 1 — Generating 1 component design docs, does not abort with No components in _manifest.json
    3. node dist/index.js codebase --lint --output <fixture> — exit 0, ✓ 无问题
  • Hidden empty wiki: teamai deep-enrich --project widget --wiki-root <empty> — exit 1, No components in _manifest.json, aborting
  • Public empty evidence: teamai codebase --deep-enrich --project widget --output <empty> — exit 1, No components in _manifest.json for project "widget"., does not say Run extract first
  • git diff --check — clean

CLI test report

Check Result
Widget extract writes fallback _manifest.json PASS
source-manifest.json still written PASS
Hidden deep-enrich after extract does not abort PASS
--lint on the same tree PASS
Hidden empty _manifest.json exits 1 PASS
Public empty message does not say re-run extract PASS
Successful AI enrich is not replaced by fallback (unit) PASS

Related Issues

Fixes #508.

Notes for Reviewers

  • Fallback component granularity matches AI enrich (top-level module, e.g. src for src/widget.ts). If there are no modules, it uses kind === 'component' fact names.
  • Successful AI enrich output is unchanged (AI enrich: N modules, domain=...).
  • Hidden teamai deep-enrich now sets process.exitCode = 1 whenever the engine returns complete: false (empty manifest or missing AI docs), matching the public command from fix(deep-enrich): retry missing AI docs after temporary failures #491. Import still calls deepEnrich() directly and does not use that wrapper.
  • import --dir / --from-repo will now run deep-enrich on small repos because a fallback _manifest.json exists; --skip-enrich still skips that stage.

Extract now writes teamwiki/evidence/code/<project>/_manifest.json from
module or component facts when AI enrichment is skipped, fails, or finds
no qualifying modules. Public empty-manifest errors no longer tell the
user to re-run extract. Hidden teamai deep-enrich exits non-zero when
there are no components.

Fixes Tencent#508.
@jeff-r2026
jeff-r2026 merged commit 0c9fcad into Tencent:main Sep 12, 2026
7 checks passed
Walternater pushed a commit to Walternater/teamai-cli that referenced this pull request Nov 2, 2026
…art (Tencent#522)

Extract now writes teamwiki/evidence/code/<project>/_manifest.json from
module or component facts when AI enrichment is skipped, fails, or finds
no qualifying modules. Public empty-manifest errors no longer tell the
user to re-run extract. Hidden teamai deep-enrich exits non-zero when
there are no components.

Fixes Tencent#508.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants