Skip to content

feat(vet): accept -E/--external to pass external KCL packages - #365

Merged
Peefy merged 1 commit into
mainfrom
fix/issue-1877-vet-external-flag
Aug 12, 2026
Merged

feat(vet): accept -E/--external to pass external KCL packages#365
Peefy merged 1 commit into
mainfrom
fix/issue-1877-vet-external-flag

Conversation

@Peefy

@Peefy Peefy commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Fixes kcl-lang/kcl#1877.

kcl vet did not expose any way to declare external KCL package
mappings, so schemas that imported other packages failed validation
even though kcl run handled the same scenario via -E/--external
and the underlying Rust service already supported external_pkgs.

Changes

  • Add the same -E/--external flag used by kcl run to kcl vet.
    Each value is parsed as pkg_name=pkg_path and forwarded to the
    embedded validate.ValidateOptions.ExternalPackages (newly added
    in kcl-lang/kcl-go alongside this change).
  • Surface malformed entries (pkg_name or pkg_path missing) as a
    clear error rather than silently dropping them, matching the
    long-standing behaviour of kcl run --external consumers.
  • Add a vet_test.go covering the flag registration, the parser,
    and the gRPC conversion helper.

Test plan

  • go test ./cmd/kcl/commands/... -run Vet — passes locally,
    including all eight table-driven parser cases, the flag
    registration check, and the empty-field short-circuit.
  • Manual end-to-end:
# ext/kcl.mod + ext/main.k defines schema Value
# with_ext/schema.k imports ext
kcl vet -E ext=../ext data.json schema.k
# -> "Validate success!"

Without -E the historical "Cannot find the module" error is
preserved, so this change is strictly additive for existing
invocations.

Depends on kcl-lang/kcl-go#566, which adds the new
ValidateOptions.ExternalPackages field this CLI change forwards
into.

@Peefy
Peefy force-pushed the fix/issue-1877-vet-external-flag branch from c2d536b to 32c63ff Compare August 12, 2026 01:45
The `kcl vet` command did not expose any way to declare external KCL
package mappings, so schemas that imported other packages failed
validation even though `kcl run` handled the same scenario via the
`-E/--external` flag and the underlying Rust service already
supported `external_pkgs`.

Add the same `-E/--external` flag to `kcl vet`, parse each value as
`pkg_name=pkg_path` (matching `kcl run`) and forward the parsed
entries directly to `gpyrpc.ValidateCodeArgs.ExternalPkgs`. Using
the stable gRPC schema keeps this CLI buildable against any released
version of kcl-go without waiting for a coordinated release. Empty
entries are skipped and malformed entries (missing separator, name
or path) surface as a clear error rather than being silently dropped.

Fixes kcl-lang/kcl#1877.

Signed-off-by: Claude <claude@anthropic.com>
@Peefy
Peefy force-pushed the fix/issue-1877-vet-external-flag branch from 32c63ff to c91fd78 Compare August 12, 2026 01:48
@coveralls

Copy link
Copy Markdown

Coverage Report for CI Build 31554848354

Coverage remained the same at 27.691%

Details

  • Coverage remained the same as the base build.
  • Patch coverage: No coverable lines changed in this PR.
  • No coverage regressions found.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 892
Covered Lines: 247
Line Coverage: 27.69%
Coverage Strength: 0.3 hits per line

💛 - Coveralls

@Peefy
Peefy merged commit 5c3df55 into main Aug 12, 2026
10 checks passed
@Peefy
Peefy deleted the fix/issue-1877-vet-external-flag branch August 12, 2026 02:00
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.

KCL vet command doesn't work on schemas which import other KCL Packages

3 participants