[bug] Codebase import: --skip-enrich drops AI enrichment, same-name --dir checkouts collide, and deep enrich follows symlinks
Maintainers usually reply within 1 day
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 54/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- node.js, typescript
Research direction
Start with the named paths in src/import-codebase.ts, src/codebase-extract.ts, and src/deep-enrich.ts; compare the staging and publish flow under --skip-enrich, how --dir sources get identities, and the deep-enrich write sites. Check docs/guide/knowledge.md for the incremental behavior described there. Done means all four reproductions are addressed, including preventing writes through symlink targets.
Written by the indexing model from the issue text.
Description
What happens
Four gaps in how teamai import publishes a codebase's evidence (teamwiki/evidence/code/<slug>/) and how deep enrich writes into it. All four are on main (f70ce259) and were found while reviewing #1417.
--skip-enrichdrops the AI enrichment. A daily static sync (import --skip-enrich --incremental) loses the published AI_manifest.json,_domains.jsonand the deep-enrichdocs/.router.mdfalls back to the default domain until the next AI run.- Two
--dircheckouts with the same basename share one evidence directory. Importing/a/svcand then/b/svcreplaces the first codebase's evidence with the second's. --incrementalon a--dircheckout without anoriginremote always runs a full extraction. The run prints[extract] no matching source baseline, running full extraction, whiledocs/guide/knowledge.md:151says--incrementalre-extracts only the changed files.- Deep enrich writes through symlinks in
docs/. If the team repo holds a symlink atevidence/code/<slug>/docs/<component>.md(orREADME.md,graph-g*.md), deep enrich overwrites the file it points to, outside the teamwiki.
Why
- Under
--skip-enrich, extraction writes the deterministic fallback_manifest.jsoninto staging (src/codebase-extract.ts:1001-1008).importCodebasethen deletes everything in the published evidence directory except.indices, and copies staging over it (src/import-codebase.ts:112-118). Deep enrich does not run under--skip-enrich(import-codebase.ts:159), so nothing rebuilds what was removed. defaultProjectSlugreturnspath.basename(dir)unless the directory is a workspace root (src/codebase-extract.ts:556-563). Remote imports use<provider>__<owner>__<repo>, so only--dircollides.- The incremental baseline is used only when its
source-manifest.jsonmatches the source'srepoIdentity(manifestMatchesSource,src/codebase-extract.ts:604). A checkout with no remote has no identity, so it never matches. src/deep-enrich.tschecks component slugs withassertSafeResourceName(line 433), then writes withwriteFile(lines 440, 483, 505-507, 635, 664, 693), which follows a symlink at the target path. It takes write access to the team repo, which can already ship hooks, so this is hardening rather than a new exposure.
Reproduction
Run with built CLIs and an isolated HOME during the #1417 review:
- (1) AI-enriched evidence (manifest,
_domains.json,docs/written by hand), thenimport --dir <src> --skip-enrich --all --incrementalafter one source change: all three are gone, androuter.mdshows the fallback domain. - (2)
import --dir /a/svcwith a curated doc, thenimport --dir /b/svc: A's evidence is replaced by B's. - (3) The same
--incrementalrun with and without anoriginremote: only the run with a remote seeds from the baseline. - (4) A symlink at
docs/README.mdordocs/graph-g1-relations.mdpointing outside the teamwiki: deep enrich overwrote the outside file. (A link atdocs/<component>.mdto an existing file is skipped as already written; a dangling one is followed.)
Possible fix
- (1) #1417 carries
docs/and_domains.jsonacross imports. The fallback manifest lists the same top-level modules as the AI one, so pruning removed components against it is correct. What it still loses is the AI-written component content in_manifest.json; keeping that under--skip-enrichis the remaining part. - (2) Make the
--dirslug unique when the directory has a remote (use the repo identity, as remote imports do). Otherwise refuse to replace evidence whosesource-manifest.jsonnames a different source. - (3) Either fall back to the checkout's path as identity, or have the docs say
--incrementalneeds anoriginremote for--dir. - (4) Refuse to write through a symlink in the evidence directory (
lstatbefore writing, or write to a temp file and rename).
- Dominant language
- TypeScript
- Stars
- 5.6k
- Forks
- 471
- Avg merge
- 22h 54m
- Merged PRs (30d)
- 347
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from Tencent/teamai-cli
-
enhancement question
Difficulty 5/5 Over a week Newbie friendliness 45/100
Tencent/teamai-cli#1429 · 1 comment ·
Maintainers usually reply within 1 day
-
enhancement
Difficulty 4/5 3-5 days Newbie friendliness 45/100
Tencent/teamai-cli#1426 · 1 comment ·
Maintainers usually reply within 1 day
-
enhancement
Difficulty 5/5 Over a week Newbie friendliness 35/100
Tencent/teamai-cli#1419 ·
Maintainers usually reply within 1 day
-
enhancement
Difficulty 5/5 Over a week Newbie friendliness 35/100
Tencent/teamai-cli#1418 ·
Maintainers usually reply within 1 day
-
enhancement
Difficulty 4/5 3-5 days Newbie friendliness 58/100
Tencent/teamai-cli#1416 · 1 comment ·
Maintainers usually reply within 1 day
All issues in Tencent/teamai-cli
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Maintainers usually reply within 1 day
-
Difficulty 1/5 1-3 hours Newbie friendliness 84/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 83/100
keptinventory/kept#336 ·
Maintainers usually reply within 1 day
-
good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
-
hemi-earn
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
vetro-protocol/vetro-monorepo#1013 ·
Maintainers usually reply within 1 day