Skip to content

feat(import): expose --max-files and warn on truncated code collection - #1196

Merged
jeff-r2026 merged 1 commit into
Tencent:mainfrom
hongchuwudi:feat/import-max-files
Oct 17, 2026
Merged

jeff-r2026 merged 1 commit into
Tencent:mainfrom
hongchuwudi:feat/import-max-files

Conversation

@hongchuwudi

Copy link
Copy Markdown
Contributor

Closes #1194

Summary

teamai import collected at most 200 source files per repository from a hardcoded cap, and truncated silently — a repository with more files produced a partial knowledge graph with no signal. This adds --max-files <n> to set the cap per run (the default stays 200) and warns with both counts when a source is truncated.

Change

  • CLI: teamai import --max-files <n>, validated as a positive integer (--max-files must be a positive integer otherwise, exit 1).

  • Plumbing: import.ts → --dir / --from-repo / --from-repo-list → importLocalCheckout / importFromRepo / importFromRepoList → importCodebase → extractCodebase. The extractor already accepted maxFiles; only the CLI entry was missing.

  • Warning: collectCode now also returns the candidate count, and extractCodebase warns when files were dropped instead of truncating silently:

    [extract] demo-repo: 6 source files matched, but only the first 3 were collected. Raise the limit with --max-files <n>.
    

    Collection order is unchanged (key files first).

  • Docs: docs/guide/knowledge.md and its zh-CN page; skill-data/core/references/commands.md regenerated with npx vitest run commands-reference -u.

Type of Change

  • New feature (non-breaking change that adds functionality)

Test Plan

  • npm run build ✓, npx tsc --noEmit ✓, npm run lint ✓ (0 errors).
  • npx vitest run codebase-extract-fallback → 18 passed, including two new tests: --max-files caps collection and warns with both counts; no warning when every candidate fits.
  • Affected suites (codebase-*, import-*, ci-extract-mr, anchors, dry-run-load-path, scala/swift-extractor): 244 passed, 5 failed — all five are pre-existing Windows-only failures. A run on pristine origin/main (fe3b906) reproduces the identical failures (C:/ vs C:\ path forms in anchors, a | in a temp path in codebase-reconcile, EPERM/timeout in dry-run-load-path).
  • Real CLI run from dist/index.js against a temp repo with 6 source files:
$ teamai import --help | grep max-files
  --max-files <n>  Max source files collected per repository (default 200)

$ teamai import --dir <repo> --output <out> --skip-enrich --max-files 3
[extract] demo-repo: 6 source files matched, but only the first 3 were collected. Raise the limit with --max-files <n>.
[extract] demo-repo complete
  Files: 3
  Facts: 3 (component:3)
  ...
✔ Local directory demo-repo import complete

$ teamai import --dir <repo> --output <out2> --skip-enrich      # default 200
[extract] demo-repo complete
  Files: 6
  ...

$ teamai import --dir <repo> --output <out3> --skip-enrich --max-files 0
✖ --max-files must be a positive integer            (exit 1)

$ teamai import --dir <repo> --output <out4> --skip-enrich --max-files abc
✖ --max-files must be a positive integer            (exit 1)

Notes for Reviewers

  • The default intentionally stays at 200. The issue also floated raising it, but that changes collection cost for every existing import, so I left that as a separate decision.
  • --from-repo-list forwards the same cap to each repository it imports. --from-mr and teamai ci extract-mr keep their own internal limits and are untouched.

`teamai import` capped code collection at a hardcoded 200 source files per
repository and truncated silently, so a larger repository produced a
partial knowledge graph with no signal. `--max-files <n>` now sets the cap
for `--dir`, `--from-repo` and `--from-repo-list`; the default stays 200.
When a source has more candidate files than the cap, the run warns with
both counts and points at the flag.

Closes Tencent#1194
@github-actions

Copy link
Copy Markdown

No findings in the scoped PR diff.

The PR description documents sufficient testing, including a representative real-CLI run covering truncation, default collection, and invalid --max-files values.

Review was read-only; I did not run, build, or install anything from the PR.

@jeff-r2026
jeff-r2026 merged commit 8ab2027 into Tencent:main Oct 17, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

建议:import 提取代码知识时暴露 --max-files 参数(当前硬编码 200 且静默截断)

2 participants