Skip to content

feat: add object form for input globs with base directory#295

Merged
branchseer merged 4 commits intomainfrom
claude/glob-input-enhancement-Q7oWG
Mar 25, 2026
Merged

feat: add object form for input globs with base directory#295
branchseer merged 4 commits intomainfrom
claude/glob-input-enhancement-Q7oWG

Conversation

@branchseer
Copy link
Member

@branchseer branchseer commented Mar 25, 2026

Summary

  • Input entries now support an object form { "base": "workspace" | "package", "pattern": "..."} to resolve glob patterns relative to the workspace root instead of the package directory
  • Bare string globs continue to work as before (resolved relative to the package directory)
  • Negation (!) is supported in both the bare string and object forms
  • base is required in the object form — if you want package-relative, just use a bare string.
    { "base": "package", "pattern": "src/**" } is equivalent to "src/**".

Example

{
  "input": [
    "src/**",
    { "base": "workspace", "pattern": "configs/tsconfig.json" },
    { "base": "workspace", "pattern": "!dist/**"},
    { "auto": true }
  ]
}

Test plan

  • Unit tests for deserialization of new object form (valid values, missing base error, invalid base error, mixed arrays)
  • Unit tests for glob resolution with workspace and package bases
  • Plan snapshot fixture (input-workspace-base) verifying workspace-relative resolution
  • TypeScript type generation updated and verified

https://claude.ai/code/session_01KiaZHtCW4hCsdJyPuBNPnw

Allow glob patterns to resolve relative to the workspace root using
`{ "pattern": "...", "base": "workspace" | "package" }` syntax.

https://claude.ai/code/session_01KiaZHtCW4hCsdJyPuBNPnw
@chatgpt-codex-connector
Copy link

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

claude added 2 commits March 25, 2026 05:36
The fixture was a root package where package_dir == workspace_root,
making workspace-base indistinguishable from package-base. Now uses
a packages/app subpackage so the snapshot clearly shows the difference.

https://claude.ai/code/session_01KiaZHtCW4hCsdJyPuBNPnw
@branchseer branchseer requested a review from Copilot March 25, 2026 08:11
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds support for specifying a base directory for input glob patterns via an object form, enabling workspace-root-relative glob resolution while preserving existing package-relative string behavior.

Changes:

  • Introduces { pattern, base } input entry form with base: "workspace" | "package" and updates input resolution logic accordingly.
  • Adds unit tests and a snapshot fixture to validate deserialization and resolution across bases (including negation).
  • Updates docs, TypeScript type generation output, and changelog to describe the new capability.

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
docs/inputs.md Documents the new object form, updates behavior summary, and clarifies base resolution behavior.
crates/vite_task_graph/src/config/user.rs Adds InputBase and a new UserInputEntry variant; extends serde tests for the new form.
crates/vite_task_graph/src/config/mod.rs Implements base-aware glob resolution via a shared insert_glob helper and adds resolution tests.
crates/vite_task_graph/run-config.ts Updates generated TS types/docs to include InputBase and the object input entry shape.
crates/vite_task_plan/tests/plan_snapshots/fixtures/input-workspace-base/** Adds a workspace-based fixture and snapshot verifying workspace-relative resolution in the plan output.
CLAUDE.md Updates example configuration to include the new object-form input entry.
CHANGELOG.md Records the new feature in the changelog.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

docs/inputs.md Outdated
Comment on lines +71 to +75
"inputs": [
"src/**",
{ "pattern": "configs/tsconfig.json", "base": "workspace" },
{ "pattern": "!dist/**", "base": "workspace" }
]
Copy link

Copilot AI Mar 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The configuration key is inconsistent with the rest of the PR (and the examples/fixtures), which use \"input\" (singular). This new example uses \"inputs\", which will mislead users and likely won’t match actual config parsing. Rename \"inputs\" to \"input\" here (and consider aligning the Behavior Summary rows you touched in the same doc section to use input: as well).

Copilot uses AI. Check for mistakes.
Comment on lines +33 to +43
#[serde(untagged)]
pub enum UserInputEntry {
/// Glob pattern (positive or negative starting with `!`)
/// Glob pattern (positive or negative starting with `!`), resolved relative to package dir
Glob(Str),
/// Glob pattern with explicit base directory
GlobWithBase {
/// The glob pattern (positive or negative starting with `!`)
pattern: Str,
/// The base directory for resolving the pattern
base: InputBase,
},
Copy link

Copilot AI Mar 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because GlobWithBase is an inline struct variant under #[serde(untagged)] and does not deny unknown fields, objects that accidentally include extra keys (e.g. { \"auto\": true, \"pattern\": \"...\", \"base\": \"workspace\" }) may deserialize successfully but silently ignore the extra fields. To make configuration errors fail fast, consider using deny_unknown_fields for object variants (typically by moving GlobWithBase/Auto into dedicated structs annotated with #[serde(deny_unknown_fields)], then referencing those structs from the enum variants).

Copilot uses AI. Check for mistakes.
- Fix `"inputs"` → `"input"` in docs/inputs.md to match actual config field name
- Extract GlobWithBase and AutoInput into dedicated structs with
  `#[serde(deny_unknown_fields)]` so ambiguous objects like
  `{ "auto": true, "pattern": "...", "base": "workspace" }` are rejected
- Add test for mixed auto+glob fields rejection
- Regenerate TypeScript type definitions

https://claude.ai/code/session_01KiaZHtCW4hCsdJyPuBNPnw
@branchseer branchseer merged commit 8b4c8d3 into main Mar 25, 2026
9 checks passed
@branchseer branchseer deleted the claude/glob-input-enhancement-Q7oWG branch March 25, 2026 09:25
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.

4 participants