Skip to content

refactor: simplify CLI and Session API by removing generic type parameters#137

Merged
branchseer merged 10 commits intomainfrom
02-04-refactor_remove_directly_subcommand_caching
Feb 8, 2026
Merged

refactor: simplify CLI and Session API by removing generic type parameters#137
branchseer merged 10 commits intomainfrom
02-04-refactor_remove_directly_subcommand_caching

Conversation

@branchseer
Copy link
Copy Markdown
Member

Remove generic CustomSubcommand type parameter from Session, SessionCallbacks,
PlanRequestParser, and TaskSynthesizer. The CLI only supports run as a
top-level subcommand; synthetic tasks (lint, test, env-test) are now handled
purely by TaskSynthesizer via string matching on program name and args.

Key changes:

  • TaskSynthesizer trait takes (program, args) directly instead of a typed subcommand
  • Session/SessionCallbacks/PlanRequestParser no longer parameterized by subcommand type
  • plan_from_cli accepts BuiltInCommand directly (removed CLIArgs, TaskCLIArgs, ParsedTaskCLIArgs)
  • Binary crate owns its top-level Cli parser wrapping BuiltInCommand
  • E2E test fixtures converted from vite lint/vite env-test to vite run <task>
  • Removed same-name-as-builtin fixture (tested now-removed CLI lint vs run distinction)
  • Added diagnostic block sorting in E2E output redaction for deterministic snapshots

Co-Authored-By: Claude Opus 4.5 noreply@anthropic.com

Copy link
Copy Markdown
Member Author

branchseer commented Feb 4, 2026

@branchseer branchseer changed the base branch from main to graphite-base/137 February 6, 2026 05:04
@branchseer branchseer force-pushed the 02-04-refactor_remove_directly_subcommand_caching branch from d6ec191 to 3b2ec03 Compare February 6, 2026 05:04
@branchseer branchseer changed the base branch from graphite-base/137 to ci_add_--locked_flag_to_cargo_check_command February 6, 2026 05:04
@branchseer branchseer changed the base branch from ci_add_--locked_flag_to_cargo_check_command to graphite-base/137 February 6, 2026 06:37
…eters

Remove generic CustomSubcommand type parameter from Session, SessionCallbacks,
PlanRequestParser, and TaskSynthesizer. The CLI only supports `run` as a
top-level subcommand; synthetic tasks (lint, test, env-test) are now handled
purely by TaskSynthesizer via string matching on program name and args.

Key changes:
- TaskSynthesizer trait takes (program, args) directly instead of a typed subcommand
- Session/SessionCallbacks/PlanRequestParser no longer parameterized by subcommand type
- plan_from_cli accepts BuiltInCommand directly (removed CLIArgs, TaskCLIArgs, ParsedTaskCLIArgs)
- Binary crate owns its top-level Cli parser wrapping BuiltInCommand
- E2E test fixtures converted from `vite lint`/`vite env-test` to `vite run <task>`
- Removed same-name-as-builtin fixture (tested now-removed CLI lint vs run distinction)
- Added diagnostic block sorting in E2E output redaction for deterministic snapshots

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@branchseer branchseer force-pushed the 02-04-refactor_remove_directly_subcommand_caching branch from 3b2ec03 to 8830f7d Compare February 6, 2026 06:37
@graphite-app graphite-app bot changed the base branch from graphite-base/137 to main February 6, 2026 06:38
@branchseer branchseer force-pushed the 02-04-refactor_remove_directly_subcommand_caching branch from 8830f7d to 5207ad4 Compare February 6, 2026 06:38
branchseer and others added 8 commits February 6, 2026 21:40
…eters

Remove generic CustomSubcommand type parameter from Session, SessionCallbacks,
PlanRequestParser, and TaskSynthesizer. The CLI only supports `run` as a
top-level subcommand; synthetic tasks (lint, test, env-test) are now handled
purely by TaskSynthesizer via string matching on program name and args.

Key changes:
- TaskSynthesizer trait takes (program, args) directly instead of a typed subcommand
- Session/SessionCallbacks/PlanRequestParser no longer parameterized by subcommand type
- plan_from_cli accepts BuiltInCommand directly (removed CLIArgs, TaskCLIArgs, ParsedTaskCLIArgs)
- Binary crate owns its top-level Cli parser wrapping BuiltInCommand
- E2E test fixtures converted from `vite lint`/`vite env-test` to `vite run <task>`
- Removed same-name-as-builtin fixture (tested now-removed CLI lint vs run distinction)
- Added diagnostic block sorting in E2E output redaction for deterministic snapshots

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Group program/args/envs/cwd into a ScriptCommand struct passed by &mut
to both CommandHandler::handle_command and PlanRequestParser::get_plan_request.
Handlers can now mutate command fields in-place (e.g., rewriting vpr → vite run)
or return a Synthesized plan request. Replace old ViteTaskCommand variant with
NotSynthesized { is_vite_task_entry } and use clap's has_subcommand() for
subcommand detection.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Remove ExecutionCacheKeyKind and make ExecutionCacheKey a flat enum with
UserTask and Exec variants. The Exec variant derives its cache key from
actual execution content (program name, args, cwd) instead of requiring
callers to provide an opaque direct_execution_cache_key. This also removes
the direct_execution_cache_key field from SyntheticPlanRequest and renames
Session::plan_synthetic_task to Session::plan_exec.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Replace `ExecutionCacheKey::Exec { program_name, args, cwd }` with
`ExecAPI(Arc<[Str]>)`, an opaque caller-provided cache key. Add
`cache_key` parameter to `Session::plan_exec` and new
`ExecutionPlan::plan_exec` entry point. Bump cache DB version to 6.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Replace HandledCommand::NotSynthesized { is_vite_task_entry } with
explicit Verbatim and ViteTaskCommand(Command) variants. All vite
subcommand parsing (lint, test, env-test, run) now happens via a
clap-derived Args enum in vite_task_bin, simplifying PlanRequestParser
to a trivial dispatcher.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Extract RunCommand struct from Command::Run, add CacheSubcommand::Clean
to Command, and introduce Session::main() as the primary CLI entry point.
This makes reporter types and execute() internal, simplifying the public
API. When `vite cache clean` appears in a script, PlanRequestParser
generates a synthesized task with caching disabled.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add Session::exec for executing synthetic commands with cache support
independently of Session::main. In vite-plus, this pattern is used for
auto-install. Also expose Args enum and find_executable from
vite_task_bin, remove the Cli wrapper in main.rs, and add e2e tests
validating exec caching behavior.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@branchseer branchseer marked this pull request as ready for review February 8, 2026 15:30
@branchseer branchseer merged commit 6e3aa68 into main Feb 8, 2026
7 checks passed
@branchseer branchseer deleted the 02-04-refactor_remove_directly_subcommand_caching branch February 8, 2026 15:30
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.

1 participant