impr: Add non-interactive mode to CLI#2588
Conversation
|
pkg.pr.new packages benchmark commit |
📊 Bundle Size Comparison
👀 Notable resultsStatic test results:No major changes. Dynamic test results:No major changes. 📋 All resultsClick to reveal the results table (355 entries).
If you wish to run a comparison for other, slower bundlers, run the 'Tree-shake test' from the GitHub Actions menu. |
Resolution Time Benchmark---
config:
themeVariables:
xyChart:
plotColorPalette: "#E63946, #3B82F6, #059669"
---
xychart
title "Random Branching (🔴 PR | 🔵 main | 🟢 release)"
x-axis "max depth" [1, 2, 3, 4, 5, 6, 7, 8]
y-axis "time (ms)"
line [0.40, 0.81, 1.82, 2.73, 3.37, 5.13, 10.07, 11.62]
line [0.42, 0.82, 1.65, 2.65, 3.32, 4.86, 9.91, 10.25]
line [0.45, 0.91, 1.99, 3.04, 3.24, 5.48, 9.66, 11.83]
---
config:
themeVariables:
xyChart:
plotColorPalette: "#E63946, #3B82F6, #059669"
---
xychart
title "Linear Recursion (🔴 PR | 🔵 main | 🟢 release)"
x-axis "max depth" [1, 2, 3, 4, 5, 6, 7, 8]
y-axis "time (ms)"
line [0.12, 0.23, 0.28, 0.36, 0.49, 0.52, 0.62, 0.71]
line [0.15, 0.26, 0.32, 0.38, 0.50, 0.53, 0.62, 0.68]
line [0.12, 0.30, 0.32, 0.38, 0.56, 0.56, 0.67, 0.73]
---
config:
themeVariables:
xyChart:
plotColorPalette: "#E63946, #3B82F6, #059669"
---
xychart
title "Full Tree (🔴 PR | 🔵 main | 🟢 release)"
x-axis "max depth" [1, 2, 3, 4, 5, 6, 7, 8]
y-axis "time (ms)"
line [0.45, 1.01, 1.76, 2.85, 5.91, 11.98, 25.50, 52.52]
line [0.47, 1.04, 2.05, 2.96, 5.78, 11.88, 24.33, 49.53]
line [0.43, 1.00, 1.96, 3.06, 5.64, 12.57, 25.75, 52.32]
|
There was a problem hiding this comment.
Pull request overview
Adds a non-interactive (“--yes”) mode and richer CLI options to @typegpu/cli, enabling scripted project creation/enhancement with selectable templates, packages, agent skills, and explicit package manager selection.
Changes:
- Introduces centralized CLI option parsing/validation (
options.ts) and extends CLI entrypoint flags/usage. - Updates create/enhance flows to support non-interactive execution paths (including package selection and agent skills install).
- Refactors “ask” steps into reusable “setup” helpers for non-interactive automation.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/typegpu-cli/src/utils/files.ts | Adds non-interactive directory preparation and supports passing explicit ecosystem packages into scaffolding. |
| packages/typegpu-cli/src/steps/webgpu-types.ts | Extracts non-interactive setupWebgpuTypes helper and reuses it from the prompt-based flow. |
| packages/typegpu-cli/src/steps/vite.ts | Adds non-interactive setupVite helper with optional config creation. |
| packages/typegpu-cli/src/steps/typegpu.ts | Adds non-interactive helpers for installing typegpu and ecosystem packages. |
| packages/typegpu-cli/src/steps/skills.ts | Extracts addAgentSkills helper for non-interactive usage. |
| packages/typegpu-cli/src/options.ts | New module for parsing/validating templates, packages, and package manager flags. |
| packages/typegpu-cli/src/index.ts | Expands CLI args/help and wires parsed options into create/enhance commands. |
| packages/typegpu-cli/src/enhance.ts | Adds non-interactive enhance flow and supports preselected packages/agent skills/package manager. |
| packages/typegpu-cli/src/create.ts | Adds non-interactive create flow (defaults, no prompts) and supports explicit template/packages/skills. |
| packages/typegpu-cli/README.md | Documents new non-interactive usage examples and flags. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
f21ef8c to
4bf2be9
Compare
# Conflicts: # packages/typegpu-cli/src/utils/files.ts
|
Could we make |
| To run the recommended enhance flow without prompts: | ||
|
|
||
| ```sh | ||
| npx typegpu@latest --enhance --yes --recommended |
There was a problem hiding this comment.
Could we install Agent Skills by default in non-interactive mode, and not have a recommended preset?
|
|
||
| const helpMessage = `\ | ||
| Usage: tgpu [OPTION]... | ||
| Usage: tgpu [PROJECT_DIR] [OPTION]... |
There was a problem hiding this comment.
| Usage: tgpu [PROJECT_DIR] [OPTION]... | |
| Usage: npx typegpu [PROJECT_DIR] [OPTION]... |
|
|
||
| :::tip | ||
| The TypeGPU project starter can install the skill for you. Run `npx typegpu@latest` and enable AI skills when prompted. | ||
| For a non-interactive setup, run `npx typegpu@latest my-app --yes --agent-skills`. |
There was a problem hiding this comment.
| For a non-interactive setup, run `npx typegpu@latest my-app --yes --agent-skills`. | |
| For a non-interactive setup, run `npx typegpu@latest my-app --yes`. |
| :::tip | ||
| The TypeGPU project starter can install the skill for you. Run `npx typegpu@latest` and enable AI skills when prompted. | ||
| For a non-interactive setup, run `npx typegpu@latest my-app --yes --agent-skills`. | ||
| For an existing project, run `npx typegpu@latest --enhance --yes --agent-skills`. |
There was a problem hiding this comment.
| For an existing project, run `npx typegpu@latest --enhance --yes --agent-skills`. | |
| For an existing project, run `npx typegpu@latest --enhance --yes`. |
| You can still select the important setup choices explicitly: | ||
|
|
||
| ```sh | ||
| npx typegpu@latest my-app --yes --template vite-react --packages @typegpu/sdf --packages @typegpu/noise |
There was a problem hiding this comment.
| npx typegpu@latest my-app --yes --template vite-react --packages @typegpu/sdf --packages @typegpu/noise | |
| npx typegpu@latest my-app --yes --template vite-react --addons @typegpu/sdf, @typegpu/noise |
| ``` | ||
|
|
||
| `--yes` skips dependency installation. | ||
| Use `--agent-skills` when you want the TypeGPU AI skill installed during project creation: |
There was a problem hiding this comment.
| Use `--agent-skills` when you want the TypeGPU AI skill installed during project creation: |
| Use `--agent-skills` when you want the TypeGPU AI skill installed during project creation: | ||
|
|
||
| ```sh | ||
| npx typegpu@latest my-app --yes --agent-skills |
There was a problem hiding this comment.
| npx typegpu@latest my-app --yes --agent-skills | |
| npx typegpu@latest my-app --yes |
| if (options?.nonInteractive) { | ||
| await runNonInteractiveEnhance(cwd, pmAgent, pkg, options); | ||
| p.outro('Done! Get ready for a shaderful experience.'); | ||
| return; | ||
| } | ||
|
|
There was a problem hiding this comment.
Now, this block is fine. In the future, we should add a command line argument for the project kind.
| if (!pm) { | ||
| const detected = await detect({ cwd }); | ||
| let pmAgent = options?.packageManager ?? detected?.agent; | ||
| if (!pmAgent && options?.nonInteractive && process.env.npm_config_user_agent) { |
There was a problem hiding this comment.
| if (!pmAgent && options?.nonInteractive && process.env.npm_config_user_agent) { | |
| if (!pmAgent && process.env.npm_config_user_agent) { |
| if (!pmAgent) { | ||
| failAndExit('Could not detect package manager.'); | ||
| } |
There was a problem hiding this comment.
| if (!pmAgent) { | |
| failAndExit('Could not detect package manager.'); | |
| } |
| if (!pmAgent && options?.nonInteractive && process.env.npm_config_user_agent) { | ||
| pmAgent = pmFromUserAgent(process.env.npm_config_user_agent); | ||
| } | ||
| if (!pmAgent && options?.nonInteractive) { |
There was a problem hiding this comment.
| if (!pmAgent && options?.nonInteractive) { | |
| if (!pmAgent) { |
|
|
||
| if (!PACKAGE_MANAGERS.includes(packageManager as (typeof PACKAGE_MANAGERS)[number])) { | ||
| failAndExit( | ||
| `Unknown package manager: ${packageManager}. Expected one of: ${PACKAGE_MANAGERS.join(', ')}.`, |
There was a problem hiding this comment.
This is not consistent with --help, which does not include pnpm@6 and yarn@berry. We can do the same trick with package manager that we used for templates and addons.
|
|
||
| if (argv.enhance) { | ||
| await enhanceProject(cwd); | ||
| await enhanceProject(cwd, commonOptions); |
There was a problem hiding this comment.
If argv._[0] is not undefined, we should probably warn that it is ignored or run cd into this directory.
closes #2585
closes #2586