argsbarg 4.1.0 → 5.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +74 -1
- package/README.md +91 -85
- package/docs/README.md +8 -8
- package/docs/ai-skills.md +9 -9
- package/docs/bundled-docs.md +5 -5
- package/docs/cli-program.md +13 -11
- package/docs/config-schema.md +36 -9
- package/docs/configure.md +177 -0
- package/docs/developing.md +7 -7
- package/docs/distribution-homebrew.md +104 -0
- package/docs/mcp.md +11 -12
- package/docs/output-schema.md +1 -1
- package/examples/full-example/Formula/.gitkeep +0 -0
- package/examples/full-example/README.md +98 -0
- package/examples/full-example/biome.json +22 -0
- package/examples/{consumer-app → full-example}/bun.lock +2 -0
- package/examples/full-example/justfile +134 -0
- package/examples/{consumer-app → full-example}/package.json +10 -3
- package/examples/{consumer-app → full-example}/schemas/generated/app-config.json +1 -1
- package/examples/{consumer-app → full-example}/schemas/generated/status.json +1 -1
- package/examples/full-example/scripts/create-identity.ts +11 -0
- package/examples/full-example/scripts/formula-shared.ts +73 -0
- package/examples/full-example/scripts/gen-dev-formula.ts +26 -0
- package/examples/full-example/scripts/print-identity.ts +27 -0
- package/examples/full-example/src/commands/echo/command.ts +21 -0
- package/examples/full-example/src/commands/status/command.test.ts +10 -0
- package/examples/full-example/src/commands/status/command.ts +36 -0
- package/examples/{consumer-app → full-example}/src/commands/status/types.ts +1 -1
- package/examples/full-example/src/index.ts +10 -0
- package/examples/full-example/src/program.ts +57 -0
- package/examples/{consumer-app → full-example}/src/types.ts +1 -1
- package/examples/nested.ts +1 -3
- package/index.d.ts +49 -81
- package/package.json +2 -2
- package/src/builtins/builtins.test.ts +84 -64
- package/src/builtins/completion-group.ts +17 -17
- package/src/builtins/configure-copy.ts +86 -0
- package/src/builtins/configure.ts +70 -0
- package/src/builtins/dispatch.ts +13 -9
- package/src/builtins/index.ts +1 -1
- package/src/builtins/mcp.ts +2 -2
- package/src/builtins/registry.ts +6 -4
- package/src/capabilities.ts +22 -15
- package/src/cli-tool/cli-smoke.test.ts +29 -0
- package/src/cli-tool/create.test.ts +141 -0
- package/src/cli-tool/create.ts +402 -0
- package/{examples/consumer-app/capabilities.test.ts → src/cli-tool/full-example-capabilities.test.ts} +16 -15
- package/src/cli-tool/main.ts +8 -0
- package/src/cli-tool/post-create.ts +111 -0
- package/src/cli-tool/program.ts +97 -0
- package/src/cli-tool/prompt.ts +28 -0
- package/src/cli-tool/run-create.ts +138 -0
- package/src/cli.ts +0 -2
- package/src/config/bootstrap.ts +27 -18
- package/src/config/file.test.ts +1 -1
- package/src/config/resolve.test.ts +167 -0
- package/src/config/resolve.ts +52 -8
- package/src/configure/configure.test.ts +148 -0
- package/src/configure/index.ts +284 -0
- package/src/configure/prompt.ts +40 -0
- package/src/docs/api-guide.test.ts +4 -5
- package/src/docs/builtin.ts +3 -5
- package/src/docs/docs.test.ts +6 -5
- package/src/docs/mcp-guide.ts +11 -12
- package/src/index.ts +5 -12
- package/src/install/binary-placement.test.ts +101 -0
- package/src/install/binary-placement.ts +47 -0
- package/src/install/install-validate.test.ts +5 -5
- package/src/install/normalize-uninstall.ts +11 -0
- package/src/install/normalize.ts +4 -19
- package/src/install/opts.ts +17 -0
- package/src/install/paths.ts +0 -22
- package/src/install/plan.ts +14 -6
- package/src/install/shell.ts +0 -14
- package/src/install/status.test.ts +6 -6
- package/src/install/status.ts +0 -6
- package/src/install/target-effective.ts +8 -10
- package/src/install/target-scope.ts +26 -36
- package/src/install/target-types.ts +0 -16
- package/src/install/targets/app.ts +19 -28
- package/src/install/targets/configure.ts +6 -2
- package/src/install/targets/index.ts +0 -3
- package/src/install/targets.test.ts +26 -44
- package/src/invoke.test.ts +1 -1
- package/src/mcp/env.test.ts +92 -0
- package/src/mcp/env.ts +15 -14
- package/src/mcp/tools.ts +1 -1
- package/src/mcp.integration.test.ts +4 -4
- package/src/parse.test.ts +13 -14
- package/src/prompt.ts +10 -0
- package/src/schema.ts +1 -1
- package/src/skill/hint.ts +2 -2
- package/src/types.ts +48 -22
- package/src/validate.ts +22 -28
- package/docs/install.md +0 -290
- package/docs/templates/cursor/rules/cli-program.mdc +0 -31
- package/examples/config-app/main.ts +0 -20
- package/examples/config-app/program.ts +0 -78
- package/examples/config-app/schema.ts +0 -37
- package/examples/config-app/types.ts +0 -19
- package/examples/consumer-app/README.md +0 -56
- package/examples/consumer-app/src/main.ts +0 -15
- package/examples/consumer-app/src/program.ts +0 -108
- package/src/builtins/install.ts +0 -136
- package/src/install/app.ts +0 -94
- package/src/install/bootstrap.ts +0 -22
- package/src/install/completions.ts +0 -56
- package/src/install/index.ts +0 -415
- package/src/install/install.test.ts +0 -333
- package/src/install/targets/completions.ts +0 -133
- package/src/install/update.test.ts +0 -123
- package/src/install/update.ts +0 -54
- /package/examples/{consumer-app → full-example}/schemas/configSchemas.ts +0 -0
- /package/examples/{consumer-app → full-example}/schemas/outputSchemas.ts +0 -0
- /package/examples/{consumer-app → full-example}/scripts/schemagen/discover-schema-roots.test.ts +0 -0
- /package/examples/{consumer-app → full-example}/scripts/schemagen/discover-schema-roots.ts +0 -0
- /package/examples/{consumer-app → full-example}/scripts/schemagen/naming.ts +0 -0
- /package/examples/{consumer-app → full-example}/scripts/schemagen.ts +0 -0
- /package/examples/{consumer-app → full-example}/tsconfig.json +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,76 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [5.0.1] - 2026-07-04
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
## [5.0.0] - 2026-07-03
|
|
14
|
+
|
|
15
|
+
### Added
|
|
16
|
+
|
|
17
|
+
- **Top-level `configure` built-in** — interactive per-target wizard (TTY required); non-interactive `--sync --yes` (replaces `install --reinstall`), `--remove-all --yes`, `--remove-config --yes`, and `--status`.
|
|
18
|
+
- **`configure --remove-config --yes`** — config-only removal without touching skills/MCP.
|
|
19
|
+
|
|
20
|
+
### Changed
|
|
21
|
+
|
|
22
|
+
- **Breaking: `install` and `uninstall` removed** — use `configure` and its flags; no redirects or deprecated aliases.
|
|
23
|
+
- **Breaking: `program.install` → `program.configure`** — `CliConfigureConfig`, `CliConfigureTargets`, `caps.configure`.
|
|
24
|
+
- **Breaking: `completion` hidden** from help and exported schema; still callable for Homebrew `generate_completions_from_executable`.
|
|
25
|
+
- **Breaking: skill install hint** — `Generated by … configure` (was `install --skill`).
|
|
26
|
+
- **Formula `post_install`** — `configure --sync --yes` (was `install --reinstall --yes`).
|
|
27
|
+
- **Just recipes** — `sync-artifacts`, `configure --remove-all --yes`, `configure --remove-config --yes`.
|
|
28
|
+
- **Docs** — `docs/install.md` replaced by [docs/configure.md](docs/configure.md).
|
|
29
|
+
|
|
30
|
+
### Removed
|
|
31
|
+
|
|
32
|
+
- Top-level **`install`** and **`uninstall`** commands and all scoped install/uninstall flags (`--all`, `--skill`, `--mcp`, `--reinstall`, …).
|
|
33
|
+
|
|
34
|
+
## [4.1.1] - 2026-07-03
|
|
35
|
+
|
|
36
|
+
### Added
|
|
37
|
+
|
|
38
|
+
- **`argsbarg create`** — interactive bootstrap from `examples/full-example`; copies template with substitutions; post-create runs `bun install`, schemagen, Cursor rule merge, `bun test`, and git init when appropriate.
|
|
39
|
+
|
|
40
|
+
### Changed
|
|
41
|
+
|
|
42
|
+
- **Breaking: `bunx argsbarg scaffold homebrew` → `bunx argsbarg create`** — single template in `examples/full-example/`; removed `docs/templates/homebrew/`.
|
|
43
|
+
- **`examples/full-example/`** — `src/index.ts`, per-command modules, Biome, `.cursor/rules/` (`cli-program.mdc`, `code.mdc`).
|
|
44
|
+
|
|
45
|
+
### Removed
|
|
46
|
+
|
|
47
|
+
- **`argsbarg scaffold`** subcommands and **`docs/templates/homebrew/`**.
|
|
48
|
+
|
|
49
|
+
### Added
|
|
50
|
+
|
|
51
|
+
- **`CliAppConfigEntry.resolve`** — optional per-key fallback resolver after file (e.g. `gh auth token`); return `undefined` to fall back to `entry.env` and defaults. Resolution order: env → file → `resolve` → env → default.
|
|
52
|
+
- **Install `--mcp` / `--skill` / `--configure` combined** — scoped flags compose (configure no longer blocks skill/MCP plan); configure wizard runs after install when combined.
|
|
53
|
+
- **Top-level `uninstall` command** — sibling of `install` for removing agent artifacts; bare `uninstall` defaults to `--all`.
|
|
54
|
+
- **Homebrew-first distribution** — tap-from-repo formula pattern; [docs/distribution-homebrew.md](docs/distribution-homebrew.md).
|
|
55
|
+
- **Homebrew dev just recipes** — `install-local`, `reinstall-local`, `install-production` (+ `install` / `reinstall` aliases); `uninstall`, `uninstall-config`, `uninstall-release`, `uninstall-release-tap`, `test-release` in full-example template.
|
|
56
|
+
- **CLI bin split** — `argsbarg` package bin points to `src/cli-tool/main.ts`; library API remains `import from "argsbarg"`.
|
|
57
|
+
- **Config path exports** — `resolveAppConfigPath`, `displayAppConfigPath` exported from `argsbarg`.
|
|
58
|
+
- **`--reinstall` greenfield fallback** — when no artifacts detected, `--reinstall` runs full `--all` plan (fresh `brew install` post_install).
|
|
59
|
+
|
|
60
|
+
### Changed
|
|
61
|
+
|
|
62
|
+
- **`mcpServer.shellEnv` default on** — login-shell env is captured at MCP startup unless `shellEnv: false`. PATH is merged; other vars fill gaps in host env.
|
|
63
|
+
- **`CliAppConfigEntry.resolve` must be synchronous** — returning a Promise is ignored with a stderr warning; use `Bun.spawnSync` with piped stdout for subprocess resolvers (e.g. `gh auth token`).
|
|
64
|
+
|
|
65
|
+
- **Breaking: `examples/consumer-app/` → `examples/full-example/`** — expanded justfile (dev/build/test/schemagen + Homebrew); CLI key `full-example`; removed redundant `examples/config-app/`.
|
|
66
|
+
|
|
67
|
+
- **Breaking: `install --uninstall` removed** — use `<key> uninstall` instead (`install --uninstall` exits with a redirect message).
|
|
68
|
+
- **Breaking: Homebrew-only install model** — drop self-install to `~/.local/bin`, `install --app`, `install --update` / `updateGetLatest`, home-dir completion installer (`install --completions`), bare-argv install bootstrap.
|
|
69
|
+
- **Breaking: configure opt-in** — `configure` target excluded from `--all`; no post-install wizard; run `install --configure` explicitly.
|
|
70
|
+
- **Install `--all` / `--reinstall`** — skills and MCP only (binary + completions via Homebrew formula).
|
|
71
|
+
- **Completion built-in notes** — Homebrew installs completions; link to Shell-Completion docs.
|
|
72
|
+
|
|
73
|
+
### Removed
|
|
74
|
+
|
|
75
|
+
- **`examples/config-app/`** — superseded by `full-example` (`program.appConfig`, schemagen, and `config get`/`set` covered there).
|
|
76
|
+
- **`install --update`**, **`updateGetLatest`**, **`ghReleaseUpdateGetLatest`** usage in install flow.
|
|
77
|
+
- **Completion installer** — `install/targets/completions.ts`, home-dir completion paths.
|
|
78
|
+
- **Install bootstrap** — bare argv no longer rewrites to `install`.
|
|
79
|
+
|
|
10
80
|
## [4.1.0] - 2026-07-01
|
|
11
81
|
|
|
12
82
|
### Added
|
|
@@ -497,7 +567,10 @@ const cli = { ... } satisfies CliProgram; // or : CliProgram
|
|
|
497
567
|
- Migrate schemas: rename every `children` property to **`commands`**; move positional definitions to **`CliPositional`** objects on `positionals` and strip `positional` / `argMin` / `argMax` from flag definitions under `options` (flags only carry `name`, `description`, `kind`, and optional `shortName`).
|
|
498
568
|
- Imports: use `CliPositional` where needed; replace `CliOptionDef` with `CliOption` or `CliPositional` as appropriate.
|
|
499
569
|
|
|
500
|
-
[Unreleased]: https://github.com/bdombro/bun-argsbarg/compare/
|
|
570
|
+
[Unreleased]: https://github.com/bdombro/bun-argsbarg/compare/v5.0.1...HEAD
|
|
571
|
+
[5.0.1]: https://github.com/bdombro/bun-argsbarg/releases/tag/v5.0.1
|
|
572
|
+
[5.0.0]: https://github.com/bdombro/bun-argsbarg/releases/tag/v5.0.0
|
|
573
|
+
[4.1.1]: https://github.com/bdombro/bun-argsbarg/releases/tag/v4.1.1
|
|
501
574
|
[4.1.0]: https://github.com/bdombro/bun-argsbarg/releases/tag/v4.1.0
|
|
502
575
|
[4.0.4]: https://github.com/bdombro/bun-argsbarg/releases/tag/v4.0.4
|
|
503
576
|
[4.0.3]: https://github.com/bdombro/bun-argsbarg/releases/tag/v4.0.3
|
package/README.md
CHANGED
|
@@ -1,36 +1,36 @@
|
|
|
1
|
-
|
|
2
|
-
<!-- Big money NE - https://patorjk.com/software/taag/#p=testall&f=Bulbhead&t=shebangsy&x=none&v=4&h=4&w=80&we=false> -->
|
|
1
|
+
Logo
|
|
3
2
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
[
|
|
7
|
-
[
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
[GitHub](https://github.com/bdombro/bun-argsbarg)
|
|
6
|
+
[License: MIT](LICENSE)
|
|
7
|
+
[npm version](https://www.npmjs.com/package/argsbarg)
|
|
8
|
+
[Bun](https://bun.sh)
|
|
8
9
|
|
|
9
10
|
Build beautiful, well-behaved CLI+MCP apps with Bun — **no third-party runtime dependencies**.
|
|
10
11
|
|
|
11
12
|
Why another CLI parser?
|
|
12
13
|
|
|
13
|
-
*Schema-first* — define your entire CLI’s structure, commands, options, and help in a single, explicit data model, making the command-line interface centralized, clear, and self-describing upfront.
|
|
14
|
+
*Schema-first* — define your entire CLI’s structure, commands, options, and help in a single, explicit data model, making the command-line interface auto-validated, centralized, clear, and self-describing upfront.
|
|
14
15
|
|
|
15
|
-
*
|
|
16
|
+
*AI Friendly* — Generate and install rich skills, mcp server, docs based on the schema.
|
|
16
17
|
|
|
17
|
-
*
|
|
18
|
+
*Beautiful* `-h` *screens* — scoped help at any routing depth, rendered in rounded UTF-8 boxes with tables, terminal-width wrapping, and color when stdout is a TTY. Errors print in red with contextual help on stderr.
|
|
18
19
|
|
|
19
|
-
*
|
|
20
|
+
*Shell completions* — `completion bash`, `completion zsh`, and `completion fish` built-ins generate scripts consumed by Homebrew during formula `install` (`generate_completions_from_executable`). See [docs/distribution-homebrew.md](docs/distribution-homebrew.md).
|
|
20
21
|
|
|
21
22
|
*Bun-optimized* — built from the ground up for Bun and TypeScript, leveraging Bun’s performance and modern JavaScript features without any extra dependencies.
|
|
22
23
|
|
|
23
24
|
Also checkout ArgsBarg for [cpp](https://github.com/bdombro/cpp-argsbarg), [nim](https://github.com/bdombro/nim-argsbarg), and [swift](https://github.com/bdombro/swift-argsbarg)!
|
|
24
25
|
|
|
25
26
|
Halps! -->
|
|
26
|
-
|
|
27
|
+
help-preview.png
|
|
27
28
|
|
|
28
29
|
Sub-level Halps! -->
|
|
29
|
-
|
|
30
|
+
help-l2-preview.png
|
|
30
31
|
|
|
31
32
|
Shell completions! -->
|
|
32
|
-
|
|
33
|
-
|
|
33
|
+
completions-preview.png
|
|
34
34
|
|
|
35
35
|
## Usage
|
|
36
36
|
|
|
@@ -73,8 +73,6 @@ await cli.run();
|
|
|
73
73
|
|
|
74
74
|
`Cli.run()` parses `process.argv`, prints help or errors, dispatches the leaf handler, and **exits the process**.
|
|
75
75
|
|
|
76
|
-
|
|
77
|
-
|
|
78
76
|
## What is it?
|
|
79
77
|
|
|
80
78
|
Everything you need for a first-class CLI:
|
|
@@ -96,50 +94,45 @@ Everything you need for a first-class CLI:
|
|
|
96
94
|
Every app gets:
|
|
97
95
|
|
|
98
96
|
- `-h` / `--help` at any routing depth (scoped help).
|
|
99
|
-
-
|
|
100
|
-
-
|
|
101
|
-
-
|
|
102
|
-
-
|
|
103
|
-
-
|
|
104
|
-
|
|
105
|
-
Do not declare a top-level command named **`completion`**, **`version`**, or **`install`** — they are reserved.
|
|
106
|
-
When **`mcpServer.enabled`** is `true`, do not declare a top-level command named **`mcp`** — it is reserved for the MCP built-in.
|
|
107
|
-
When **`docs.enabled`** is `true`, do not declare a top-level command named **`docs`** — it is reserved for the docs built-in.
|
|
97
|
+
- `completion bash` **/** `completion zsh` **/** `completion fish` — print shell completion scripts to stdout (injected by `Cli.run()`).
|
|
98
|
+
- `version` — print `CliProgram.version` (`myapp version`).
|
|
99
|
+
- `mcp` — when `mcpServer.enabled` is `true`, run as an MCP stdio server (`myapp mcp`).
|
|
100
|
+
- `docs` — when `docs.enabled` is `true`, print bundled markdown topics, schema JSON, API markdown, and generated skill content (`myapp docs`, `myapp docs readme`, `myapp docs schema`, `myapp docs api`, `myapp docs skill`, …). See [docs/bundled-docs.md](docs/bundled-docs.md).
|
|
101
|
+
- `configure` — manage agent skills, MCP config, and app config (`myapp configure --sync --yes` after Homebrew install). See [docs/configure.md](docs/configure.md).
|
|
108
102
|
|
|
103
|
+
Do not declare a top-level command named `completion`, `version`, or `configure` — they are reserved.
|
|
104
|
+
When `mcpServer.enabled` is `true`, do not declare a top-level command named `mcp` — it is reserved for the MCP built-in.
|
|
105
|
+
When `docs.enabled` is `true`, do not declare a top-level command named `docs` — it is reserved for the docs built-in.
|
|
109
106
|
|
|
110
107
|
### MCP (AI agents)
|
|
111
108
|
|
|
112
109
|
Opt in on the program root with `mcpServer: { enabled: true }`, then run `myapp mcp` for a stdio MCP server. Each leaf command becomes a tool; the CLI tree is available as resource `<sanitized-key>://schema` (same as `myapp docs schema`). Handlers can read `ctx.invocation`; use `cli.invoke(argv)` for headless testing.
|
|
113
110
|
|
|
114
|
-
See **[docs/mcp.md](docs/mcp.md)** for configuration, env bootstrapping, custom resources, Cursor setup, and protocol details. See **[docs/cli-program.md](docs/cli-program.md)** for schema authoring (consumer apps:
|
|
111
|
+
See **[docs/mcp.md](docs/mcp.md)** for configuration, env bootstrapping, custom resources, Cursor setup, and protocol details. See **[docs/cli-program.md](docs/cli-program.md)** for schema authoring (consumer apps: run `bunx argsbarg create` or refresh with `bun scripts/merge-cli-program-rule.ts .` from the argsbarg package).
|
|
115
112
|
|
|
116
|
-
###
|
|
113
|
+
### Configure CLI
|
|
117
114
|
|
|
118
|
-
|
|
115
|
+
Ship via **Homebrew** (tap-from-repo). The formula installs the binary and shell completions; `post_install` runs agent artifact refresh:
|
|
119
116
|
|
|
120
117
|
```bash
|
|
121
|
-
|
|
118
|
+
brew tap <org>/<repo>
|
|
119
|
+
brew install <tap>/myapp
|
|
120
|
+
myapp configure # interactive per-target setup; opt-in app config wizard
|
|
122
121
|
```
|
|
123
122
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
See **[docs/install.md](docs/install.md)** for `--reinstall`, `install --update`, `--status`, `--uninstall`, and flags.
|
|
127
|
-
|
|
123
|
+
See **[docs/distribution-homebrew.md](docs/distribution-homebrew.md)** for formula patterns and `bunx argsbarg create`. See **[docs/configure.md](docs/configure.md)** for `configure`, `--sync`, `--remove-all`, and `--status`.
|
|
128
124
|
|
|
129
125
|
### Shell completions
|
|
130
126
|
|
|
131
|
-
|
|
132
|
-
myapp completion bash > ~/.bash_completion.d/myapp
|
|
133
|
-
# or: source <(myapp completion bash)
|
|
127
|
+
Homebrew installs completion scripts during `brew install` via `generate_completions_from_executable`. The CLI still exposes generation for formula authors:
|
|
134
128
|
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
myapp completion fish > ~/.config/fish/completions/myapp.fish
|
|
129
|
+
```bash
|
|
130
|
+
myapp completion bash
|
|
131
|
+
myapp completion zsh
|
|
132
|
+
myapp completion fish
|
|
140
133
|
```
|
|
141
134
|
|
|
142
|
-
|
|
135
|
+
Users configure their shell per [Homebrew Shell Completion](https://docs.brew.sh/Shell-Completion).
|
|
143
136
|
|
|
144
137
|
## Quick Start
|
|
145
138
|
|
|
@@ -147,31 +140,38 @@ myapp completion fish > ~/.config/fish/completions/myapp.fish
|
|
|
147
140
|
bun add argsbarg
|
|
148
141
|
```
|
|
149
142
|
|
|
143
|
+
|
|
144
|
+
|
|
150
145
|
### Cursor / AI agents
|
|
151
146
|
|
|
152
147
|
Argsbarg ships authoring docs in `node_modules/argsbarg/docs/`. Agents do not load them unless your repo points there — copy the thin Cursor rule after install (it tells agents to **read** `cli-program.md`, not duplicate it):
|
|
153
148
|
|
|
154
149
|
```bash
|
|
155
150
|
mkdir -p .cursor/rules
|
|
156
|
-
|
|
151
|
+
mkdir -p .cursor/rules
|
|
152
|
+
bun scripts/merge-cli-program-rule.ts . \
|
|
153
|
+
node_modules/argsbarg/examples/full-example/.cursor/rules/cli-program.mdc
|
|
157
154
|
```
|
|
158
155
|
|
|
159
156
|
Add app-specific conventions in a second rule if needed. Copy the rule from the template, then add a `**<your-app> conventions:**` block at the bottom (see **Cursor rule** in [docs/cli-program.md](docs/cli-program.md)). Documentation map: **[docs/README.md](docs/README.md)**.
|
|
160
157
|
|
|
161
|
-
|
|
162
158
|
## How it works
|
|
163
159
|
|
|
164
160
|
1. Build a **program root** with `satisfies CliProgram` (or `: CliProgram`): `key` is the app name, `commands` are top-level subcommands, `options` are global flags. A router root must not set `handler` or declare `positionals` (validated at startup). A leaf root may set `handler` and `positionals` directly. Use `fallbackCommand` / `fallbackMode` on any **routing node** for default subcommand routing (not root-only).
|
|
165
161
|
2. Call `await new Cli(program).run()` — validates, parses argv, renders help or errors, invokes the leaf handler, and `process.exit`s with status **0** on success, **1** on implicit help or error (explicit `--help` → **0**).
|
|
166
162
|
3. From a handler, `cliErrWithHelp(ctx, "message")` prints a red error line plus contextual help on stderr and exits **1**.
|
|
167
163
|
|
|
164
|
+
|
|
165
|
+
|
|
168
166
|
### Fallback modes (`CliFallbackMode`)
|
|
169
167
|
|
|
170
|
-
|
|
171
|
-
|
|
|
172
|
-
|
|
|
173
|
-
| `
|
|
174
|
-
| `
|
|
168
|
+
|
|
169
|
+
| Mode | Empty argv | Unknown first token |
|
|
170
|
+
| ------------------ | ------------------ | ---------------------------------------------------- |
|
|
171
|
+
| `MissingOnly` | Default command | Error |
|
|
172
|
+
| `MissingOrUnknown` | Default command | Default command (token becomes argv for the default) |
|
|
173
|
+
| `UnknownOnly` | Root help (exit 1) | Default command |
|
|
174
|
+
|
|
175
175
|
|
|
176
176
|
With `MissingOrUnknown` / `UnknownOnly`, unrecognized flags at the **current routing node** stop option consumption and the remainder is passed to the default command.
|
|
177
177
|
|
|
@@ -181,12 +181,16 @@ Set `fallbackCommand` / `fallbackMode` on nested routers too — e.g. `docs` wit
|
|
|
181
181
|
|
|
182
182
|
Add `CliPositional` entries to the command’s `positionals` list (separate from `CliOption` flags). With `argMax: 0`, the tail accepts at least `argMin` tokens and has no upper bound unless you set `argMax` > 0.
|
|
183
183
|
|
|
184
|
-
|
|
185
|
-
|
|
|
186
|
-
|
|
|
187
|
-
| `argMin
|
|
188
|
-
| `argMin: 0`, `argMax:
|
|
189
|
-
| `argMin:
|
|
184
|
+
|
|
185
|
+
| Fields | Label |
|
|
186
|
+
| ---------------------------------------------------------------- | -------- |
|
|
187
|
+
| omit `argMin` / `argMax` (defaults `1` / `1`, one required word) | `<n>` |
|
|
188
|
+
| `argMin: 0`, `argMax: 1` | `[n]` |
|
|
189
|
+
| `argMin: 0`, `argMax: 0` | `[n...]` |
|
|
190
|
+
| `argMin: 1`, `argMax: 0` | `<n...>` |
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
|
|
190
194
|
|
|
191
195
|
### Reading values (`CliContext`)
|
|
192
196
|
|
|
@@ -201,25 +205,26 @@ Add `CliPositional` entries to the command’s `positionals` list (separate from
|
|
|
201
205
|
- `ctx.positional("name")` — named positional lookup; varargs slots return `string[]`, single slots return `string | undefined`.
|
|
202
206
|
- `ctx.program` — program root (`CliProgram`) for contextual help.
|
|
203
207
|
|
|
204
|
-
### Capabilities (built-ins)
|
|
205
208
|
|
|
206
|
-
`completion`, `version`, `install`, and `mcp` are not part of your schema — they are injected at runtime from program-level config (`mcpServer`, `install`, `docs`). Reserved command names: `completion` and `version` always; `install` unless `install.enabled: false`; `mcp` when `mcpServer.enabled` is `true`; `docs` when `docs.enabled` is `true`. When `install.updateGetLatest` is set, `install --update` is available (not a separate command).
|
|
207
209
|
|
|
210
|
+
### Capabilities (built-ins)
|
|
208
211
|
|
|
212
|
+
`completion`, `version`, `install`, and `mcp` are not part of your schema — they are injected at runtime from program-level config (`mcpServer`, `install`, `docs`). Reserved command names: `completion` and `version` always; `install` unless `install.enabled: false`; `mcp` when `mcpServer.enabled` is `true`; `docs` when `docs.enabled` is `true`.
|
|
209
213
|
|
|
210
214
|
## Examples
|
|
211
215
|
|
|
212
216
|
Check the `examples/` directory for full working scripts:
|
|
213
217
|
|
|
214
|
-
| Example | File | Shows |
|
|
215
|
-
| --- | --- | --- |
|
|
216
|
-
| `ArgsBargMinimal` | `examples/minimal.ts` | String + presence flags, `MissingOrUnknown` fallback. |
|
|
217
|
-
| `ArgsBargNested` | `examples/nested.ts` | Nested command tree, positional tails, async handlers. |
|
|
218
|
-
| `ArgsBargFormats` | `examples/formats.ts` | `CliValueFormat`, `default`, `readLeafInputs()`. |
|
|
219
|
-
| `ArgsBargConfigApp` | `examples/config-app/` | `program.appConfig`, `ctx.appConfig`, built-in `config get`/`set`, inline JSON Schema. |
|
|
220
|
-
| `ArgsBargConsumerApp` | `examples/consumer-app/` | **Copy template:** all builtins, schemagen discovery, `outputSchema`, `from "argsbarg"`. |
|
|
221
218
|
|
|
222
|
-
|
|
219
|
+
| Example | File | Shows |
|
|
220
|
+
| --------------------- | ------------------------ | ---------------------------------------------------------------------------------------- |
|
|
221
|
+
| `ArgsBargMinimal` | `examples/minimal.ts` | String + presence flags, `MissingOrUnknown` fallback. |
|
|
222
|
+
| `ArgsBargNested` | `examples/nested.ts` | Nested command tree, positional tails, async handlers. |
|
|
223
|
+
| `ArgsBargFormats` | `examples/formats.ts` | `CliValueFormat`, `default`, `readLeafInputs()`. |
|
|
224
|
+
| `ArgsBargFullExample` | `examples/full-example/` | **Copy template:** all builtins, schemagen, Homebrew justfile, `outputSchema`, `from "argsbarg"`. |
|
|
225
|
+
|
|
226
|
+
|
|
227
|
+
Examples ship in the npm package under `node_modules/argsbarg/examples/`. Bootstrap a production CLI with `bunx argsbarg create my-cli`.
|
|
223
228
|
|
|
224
229
|
```bash
|
|
225
230
|
export PATH="$PATH:$(pwd)/examples"
|
|
@@ -234,11 +239,8 @@ nested.ts read ./README.md
|
|
|
234
239
|
|
|
235
240
|
bun ./examples/formats.ts run --tags demo,docs --on 2026-06-22
|
|
236
241
|
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
cd examples/consumer-app && bun install && bun run schemagen
|
|
241
|
-
CONSUMER_APP_API_TOKEN=dev bun run start status --json
|
|
242
|
+
cd examples/full-example && just setup && just schemagen
|
|
243
|
+
FULL_EXAMPLE_API_TOKEN=dev just run status --json
|
|
242
244
|
```
|
|
243
245
|
|
|
244
246
|
|
|
@@ -247,23 +249,27 @@ CONSUMER_APP_API_TOKEN=dev bun run start status --json
|
|
|
247
249
|
|
|
248
250
|
The package root (`argsbarg` / `src/index.ts`) exports the types and runtime you need to define a schema and run it. Parsing, completion script generation, help rendering, and schema pre-validation live in other modules under `src/` for tests and advanced integrations.
|
|
249
251
|
|
|
250
|
-
|
|
251
|
-
|
|
|
252
|
-
|
|
|
253
|
-
| `
|
|
254
|
-
| `
|
|
255
|
-
| `
|
|
256
|
-
| `
|
|
257
|
-
| `
|
|
258
|
-
| `
|
|
259
|
-
| `
|
|
260
|
-
| `
|
|
261
|
-
| `
|
|
262
|
-
|
|
263
|
-
|
|
252
|
+
|
|
253
|
+
| Symbol | Role |
|
|
254
|
+
| ----------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
255
|
+
| `CliProgram`, `CliOption`, `CliPositional`, `CliHandler` | Schema and handler types. |
|
|
256
|
+
| `CliOptionKind`, `CliValueFormat`, `CliFallbackMode` | Option kinds, value formats (`duration`, `comma-list`, `date`, `date-time`), and root fallback behavior. |
|
|
257
|
+
| `CliSchemaValidationError` | Thrown when the static command tree violates schema rules. |
|
|
258
|
+
| `CliContext` | Handler context (`ctx.hasFlag`, `ctx.stringOpt`, `ctx.durationOpt`, `ctx.readLeafInputs`, `ctx.invocation`, …). |
|
|
259
|
+
| `CliLeafInputs` | Record type returned by `readLeafInputs()` — coerced option/positional values keyed by schema name. |
|
|
260
|
+
| `Cli` | Runtime: validate + freeze program, `run()`, `invoke()`, `serveMcp()`, `appConfig` getter, `exportCommandSchema()`, `exportAppConfigSchema()`. |
|
|
261
|
+
| `CliInvokeResult`, `CliInvokeKind` | Result types from `cli.invoke()`. |
|
|
262
|
+
| `CliAppConfig`, `CliAppConfigEntry` | App config block on the program root (`entries` metadata overlay + optional `jsonSchema`). |
|
|
263
|
+
| `cliErrWithHelp(ctx, msg)` | Print error + scoped help on stderr, exit 1. |
|
|
264
|
+
| `parseDurationMs`, `parseCommaList`, `parseDate`, `parseDateTime` | Optional format parsers for use outside handlers. |
|
|
265
|
+
|
|
266
|
+
|
|
267
|
+
Reserved identifiers (validated at startup): root commands `completion`, `version`, `install`, `docs` (when `docs.enabled` is `true`), and `mcp` (when `mcpServer.enabled` is `true`).
|
|
264
268
|
|
|
265
269
|
---
|
|
266
270
|
|
|
271
|
+
|
|
272
|
+
|
|
267
273
|
## License
|
|
268
274
|
|
|
269
|
-
MIT
|
|
275
|
+
MIT
|
package/docs/README.md
CHANGED
|
@@ -8,12 +8,13 @@ Start here to pick the right guide.
|
|
|
8
8
|
| **Authoring a `CliProgram`** (humans or agents) | [cli-program.md](cli-program.md) — schema, formats, headless, `read*Flags` |
|
|
9
9
|
| **JSON stdout / `outputSchema`** | [output-schema.md](output-schema.md) — codegen pipeline, JSDoc, narrowing |
|
|
10
10
|
| **App config / `program.appConfig`** | [config-schema.md](config-schema.md) — flat JSON file, `ctx.appConfig`, codegen |
|
|
11
|
-
| **Exposing MCP tools** | [mcp.md](mcp.md) — stdio server, `inputSchema`, varargs, `
|
|
12
|
-
| **Shipping
|
|
11
|
+
| **Exposing MCP tools** | [mcp.md](mcp.md) — stdio server, `inputSchema`, varargs, `configure --sync` |
|
|
12
|
+
| **Shipping configure / agent artifacts** | [configure.md](configure.md) — Homebrew + `myapp configure --sync` |
|
|
13
|
+
| **Homebrew tap-from-repo distribution** | [distribution-homebrew.md](distribution-homebrew.md) — formula pattern, `argsbarg create` |
|
|
13
14
|
| **Bundling `myapp docs` topics** | [bundled-docs.md](bundled-docs.md) — consumer docgen vs framework docs |
|
|
14
|
-
| **Agent skills** | [ai-skills.md](ai-skills.md) — `
|
|
15
|
+
| **Agent skills** | [ai-skills.md](ai-skills.md) — `configure`, `docs skill` |
|
|
15
16
|
| **Maintaining the argsbarg repo** | [developing.md](developing.md) — release, consumers, npm `files` |
|
|
16
|
-
| **Cursor / IDE agents in a consumer app** |
|
|
17
|
+
| **Cursor / IDE agents in a consumer app** | `bunx argsbarg create` (includes rule) or `bun scripts/merge-cli-program-rule.ts .` from argsbarg checkout |
|
|
17
18
|
| **Runnable examples** (shipped in npm) | [examples/](examples/) — see table below |
|
|
18
19
|
|
|
19
20
|
## Examples (agents: read these)
|
|
@@ -22,9 +23,8 @@ Examples are included in the npm tarball (`package.json` `files`). After `bun ad
|
|
|
22
23
|
|
|
23
24
|
| Tier | Path | Use when |
|
|
24
25
|
| --- | --- | --- |
|
|
25
|
-
| Learn | [examples/minimal.ts](../examples/minimal.ts), [
|
|
26
|
-
|
|
|
27
|
-
| **Copy** | [examples/consumer-app/](../examples/consumer-app/) | Bootstrapping a production CLI (all builtins + schemagen) |
|
|
26
|
+
| Learn | [examples/minimal.ts](../examples/minimal.ts), [examples/nested.ts](../examples/nested.ts), [formats.ts](../examples/formats.ts) | One feature at a time |
|
|
27
|
+
| **Copy** | [examples/full-example/](../examples/full-example/) | Bootstrapping a production CLI (all builtins + schemagen + Homebrew justfile) |
|
|
28
28
|
|
|
29
29
|
## Framework docs vs consumer docgen
|
|
30
30
|
|
|
@@ -32,6 +32,6 @@ Examples are included in the npm tarball (`package.json` `files`). After `bun ad
|
|
|
32
32
|
| --- | --- | --- |
|
|
33
33
|
| **Framework docs** | How argsbarg works; authoring conventions | This directory — shipped in `node_modules/argsbarg/docs/` after `bun add argsbarg` |
|
|
34
34
|
| **Consumer docgen** | *Your* command tree, API, MCP guide for *your* app | `myapp docs api`, `docs schema`, `docs mcp` — written to `./docs/` with `--save` |
|
|
35
|
-
| **Cursor rule** | Thin tripwire telling agents to read framework docs | `node_modules/argsbarg/
|
|
35
|
+
| **Cursor rule** | Thin tripwire telling agents to read framework docs | `node_modules/argsbarg/examples/full-example/.cursor/rules/cli-program.mdc` — included by `create`; refresh with `merge-cli-program-rule.ts` |
|
|
36
36
|
|
|
37
37
|
Agents do **not** load `node_modules/argsbarg/docs/` unless your repo references them (Cursor rule, `AGENTS.md`, or an `alwaysApply` project rule). Generated `./docs/api.md` in a consumer repo describes **your** CLI, not argsbarg itself.
|
package/docs/ai-skills.md
CHANGED
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
ArgsBarg can generate Cursor and Claude Code skill directories (`SKILL.md` + `reference.md`) from your CLI schema.
|
|
4
4
|
|
|
5
|
-
## Install via `
|
|
5
|
+
## Install via `configure` (recommended)
|
|
6
6
|
|
|
7
7
|
Install skills to the user environment:
|
|
8
8
|
|
|
9
9
|
```bash
|
|
10
|
-
myapp
|
|
11
|
-
# or
|
|
12
|
-
myapp
|
|
10
|
+
myapp configure --sync --yes
|
|
11
|
+
# or interactive (accept skill targets when prompted):
|
|
12
|
+
myapp configure
|
|
13
13
|
```
|
|
14
14
|
|
|
15
15
|
Skills are written when the agent home or CLI exists:
|
|
@@ -37,7 +37,7 @@ For library use, call `cliSkillInstall(root, "cursor" | "claude", { global: true
|
|
|
37
37
|
- **`SKILL.md`** — YAML frontmatter, compact command index, pitfalls, and a pointer to `reference.md`
|
|
38
38
|
- **`reference.md`** — full `docs api` markdown reference
|
|
39
39
|
|
|
40
|
-
Installed files include an HTML comment hint (`Generated by myapp
|
|
40
|
+
Installed files include an HTML comment hint (`Generated by myapp configure; do not edit.`) after SKILL.md frontmatter and at the top of `reference.md`.
|
|
41
41
|
|
|
42
42
|
Skills describe **shell invocation only** — no MCP setup, `mcp.json`, or `tools/call` guidance. Use **`myapp docs mcp`** (when `docs` and `mcpServer` are enabled) or connect the MCP server for agent execution.
|
|
43
43
|
|
|
@@ -46,15 +46,15 @@ Skills describe **shell invocation only** — no MCP setup, `mcp.json`, or `tool
|
|
|
46
46
|
| Mechanism | Role |
|
|
47
47
|
| --- | --- |
|
|
48
48
|
| **`myapp mcp`** (requires `mcpServer`) | Runtime tool execution over MCP |
|
|
49
|
-
| **`myapp
|
|
49
|
+
| **`myapp configure`** (skill targets) | Persists optimized skill bundle (`SKILL.md` index + `reference.md` full API) |
|
|
50
50
|
| **`myapp docs`** (requires `docs`) | Bundled markdown on stdout (`docs mcp` when MCP enabled) |
|
|
51
51
|
|
|
52
|
-
`SKILL.md` is the routing index; `reference.md` matches `docs api`. Prefer `
|
|
52
|
+
`SKILL.md` is the routing index; `reference.md` matches `docs api`. Prefer `configure` over `docs skill` for agents. See [cli-program.md](cli-program.md).
|
|
53
53
|
|
|
54
|
-
**Claude Code plugin** (`mcpServer.claudePlugin: true` → `mcp bundle` writes `dist/claude-plugin/<name>.zip`) ships a separate MCP pointer skill (`SKILL.md` only) that routes agents to the bundled MCP server. This is a **dist artifact**, not installed via `
|
|
54
|
+
**Claude Code plugin** (`mcpServer.claudePlugin: true` → `mcp bundle` writes `dist/claude-plugin/<name>.zip`) ships a separate MCP pointer skill (`SKILL.md` only) that routes agents to the bundled MCP server. This is a **dist artifact**, not installed via `configure`. Use **`configure`** for persisted shell-oriented skills.
|
|
55
55
|
|
|
56
56
|
See also:
|
|
57
57
|
|
|
58
58
|
- [Bundled docs](bundled-docs.md) — `docs` config and compile-time imports
|
|
59
59
|
- [MCP server](mcp.md) — `mcpServer` config and `mcp` protocol
|
|
60
|
-
- [
|
|
60
|
+
- [Configure](configure.md) — app, completions, skills, and MCP config
|
package/docs/bundled-docs.md
CHANGED
|
@@ -8,7 +8,7 @@ Two documentation layers often coexist in a consumer repo:
|
|
|
8
8
|
|
|
9
9
|
| Layer | Contents | How agents/humans get it |
|
|
10
10
|
| --- | --- | --- |
|
|
11
|
-
| **Argsbarg framework** | How to author `CliProgram`, MCP varargs policy, headless patterns | `node_modules/argsbarg/docs/` — wire via [Cursor rule](
|
|
11
|
+
| **Argsbarg framework** | How to author `CliProgram`, MCP varargs policy, headless patterns | `node_modules/argsbarg/docs/` — wire via [full-example Cursor rule](../examples/full-example/.cursor/rules/cli-program.mdc) or `AGENTS.md` |
|
|
12
12
|
| **Your CLI (docgen)** | Your command tree, options, MCP tool list, install notes | `myapp docs api`, `docs schema`, `docs mcp` — save with `--save` to `./docs/` |
|
|
13
13
|
|
|
14
14
|
`docs api` and `docs schema` embed each leaf’s `outputSchema` when set — see [output-schema.md](output-schema.md) for how to generate and wire schemas.
|
|
@@ -50,7 +50,7 @@ myapp docs readme --save # write ./docs/readme.md
|
|
|
50
50
|
myapp docs schema --save # write ./docs/schema.json
|
|
51
51
|
```
|
|
52
52
|
|
|
53
|
-
When `docs` is enabled, top-level `myapp --help` points agents at `myapp docs skill`. The `docs skill` subcommand description recommends `
|
|
53
|
+
When `docs` is enabled, top-level `myapp --help` points agents at `myapp docs skill`. The `docs skill` subcommand description recommends `configure` for a persisted bundle.
|
|
54
54
|
|
|
55
55
|
## Configuration
|
|
56
56
|
|
|
@@ -83,11 +83,11 @@ When `docs.enabled` is `true`:
|
|
|
83
83
|
|
|
84
84
|
- **`docs schema`** — same JSON as the former root `--schema` flag (handlers omitted; built-in subtrees included for leaf roots).
|
|
85
85
|
- **`docs api`** — markdown rendering of the same command tree (options, positionals, subcommands, fallback routing).
|
|
86
|
-
- **`docs skill`** — prints the compact `SKILL.md` index. Prefer `
|
|
86
|
+
- **`docs skill`** — prints the compact `SKILL.md` index. Prefer `configure --sync --yes` for agents (persists index + full API in `reference.md`).
|
|
87
87
|
|
|
88
88
|
## MCP guide (`docs mcp`)
|
|
89
89
|
|
|
90
|
-
When both `docs.enabled` and `mcpServer.enabled` are `true`, ArgsBarg injects a **`docs mcp`** topic with an auto-generated guide: tool list, `program.appConfig`, schema resource URI, `
|
|
90
|
+
When both `docs.enabled` and `mcpServer.enabled` are `true`, ArgsBarg injects a **`docs mcp`** topic with an auto-generated guide: tool list, `program.appConfig`, schema resource URI, `configure --sync`, and protocol notes.
|
|
91
91
|
|
|
92
92
|
There is no override API in v1 — customize behavior via `mcpTool.description` on leaf commands.
|
|
93
93
|
|
|
@@ -99,7 +99,7 @@ All `docs` subcommands are hidden from MCP `tools/list` (`mcpTool: { enabled: fa
|
|
|
99
99
|
|
|
100
100
|
| Channel | Role |
|
|
101
101
|
| --- | --- |
|
|
102
|
-
| `
|
|
102
|
+
| `configure` (skill targets) | Writes compact `SKILL.md` + full-API `reference.md` to disk |
|
|
103
103
|
| `docs skill` | Print generated `SKILL.md` to stdout |
|
|
104
104
|
| `docs api` | Print command tree markdown to stdout |
|
|
105
105
|
| `docs schema` | Print command tree JSON to stdout |
|
package/docs/cli-program.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
ArgsBarg turns your schema into help, shell completions, MCP tools, and agent skills. **The same `description` fields you write for humans are the agent contract** for basic apps.
|
|
4
4
|
|
|
5
|
-
**Documentation map:** [docs/README.md](README.md) — which guide to read for MCP,
|
|
5
|
+
**Documentation map:** [docs/README.md](README.md) — which guide to read for MCP, configure, consumer docgen, and Cursor setup.
|
|
6
6
|
|
|
7
7
|
## Minimal app (MCP is free)
|
|
8
8
|
|
|
@@ -413,11 +413,12 @@ await cli.run();
|
|
|
413
413
|
| Field | Default | Purpose |
|
|
414
414
|
| --- | --- | --- |
|
|
415
415
|
| `description` | *(required)* | Shown in prompts, `config get`, and bundle manifests |
|
|
416
|
-
| `title` | config key | Short label in `
|
|
416
|
+
| `title` | config key | Short label in interactive `configure` |
|
|
417
417
|
| `default` | — | Used when `jsonSchema` omitted (all-string mode) |
|
|
418
418
|
| `required` | `true` | When `false`, optional unless required by `jsonSchema` |
|
|
419
419
|
| `sensitive` | name heuristic (`token`, `secret`, …) | Redact in prompts, `config get`, and status |
|
|
420
|
-
| `env` | — | When set: non-empty host env overrides file; exported to `process.env` after resolve |
|
|
420
|
+
| `env` | — | When set: non-empty host env overrides file; consulted again after `resolve` when `resolve` returns `undefined`; exported to `process.env` after resolve |
|
|
421
|
+
| `resolve` | — | Optional fallback after file; return `undefined` to fall back to `env` (if set) and defaults |
|
|
421
422
|
|
|
422
423
|
**Config file** (created on demand):
|
|
423
424
|
|
|
@@ -426,16 +427,16 @@ await cli.run();
|
|
|
426
427
|
- **Strict:** unknown keys rejected on load.
|
|
427
428
|
- **CLI:** missing required config exits 1 before the leaf handler (TTY prompt when interactive). Built-in `docs` and `config get`/`set` skip this exit.
|
|
428
429
|
- **MCP:** server stays up; missing config returns `isError: true` at `tools/call`.
|
|
429
|
-
- **Configure:**
|
|
430
|
-
- **Agent integration:** `
|
|
430
|
+
- **Configure:** interactive `configure` runs the app config wizard; **`configure --sync`** refreshes agent artifacts.
|
|
431
|
+
- **Agent integration:** `configure.agentIntegration` (`mcp` | `skill` | `both`) sets default sync targets; see [configure.md](configure.md#configuretargets).
|
|
431
432
|
|
|
432
|
-
See [config-schema.md](config-schema.md) for codegen, [
|
|
433
|
+
See [config-schema.md](config-schema.md) for codegen, [configure.md](configure.md) (`configure.targets`), and [mcp.md](mcp.md).
|
|
433
434
|
|
|
434
435
|
**Handler access (`ctx.appConfig`):** `get`, `require`, `set`, `read`, `path`, `dir` — prefer over `process.env` in handlers; env export remains for subprocess inheritance. `path` is the resolved absolute config file path (`~/.local/lib/<key>/config`); `dir` is its parent directory.
|
|
435
436
|
|
|
436
437
|
## Reserved names
|
|
437
438
|
|
|
438
|
-
Do not declare user commands named `completion`, `
|
|
439
|
+
Do not declare user commands named `completion`, `configure`, `mcp`, `version`, `docs`, or `config` at the root — ArgsBarg injects these when configured.
|
|
439
440
|
|
|
440
441
|
## Cursor rule for consumer repos
|
|
441
442
|
|
|
@@ -447,10 +448,11 @@ Agents do **not** discover package docs automatically. Wire them in after `bun a
|
|
|
447
448
|
|
|
448
449
|
```bash
|
|
449
450
|
mkdir -p .cursor/rules
|
|
450
|
-
|
|
451
|
+
bun scripts/merge-cli-program-rule.ts . \
|
|
452
|
+
node_modules/argsbarg/examples/full-example/.cursor/rules/cli-program.mdc
|
|
451
453
|
```
|
|
452
454
|
|
|
453
|
-
The template is ~
|
|
455
|
+
The template is ~30 lines: when to read which doc, plus hard rules agents often get wrong. It does **not** duplicate this guide. `bunx argsbarg create` copies this file into new projects automatically.
|
|
454
456
|
|
|
455
457
|
2. **Add an app-specific block at the bottom** (recommended). Replace the template placeholder with a heading like `**myapp conventions:**` and short bullets — shared flag modules, `read*Flags` / `resolve*` paths, Ink vs JSON-only, etc. Example:
|
|
456
458
|
|
|
@@ -465,7 +467,7 @@ If you maintain argsbarg from a sibling checkout, `just consumer-dev` / `just co
|
|
|
465
467
|
|
|
466
468
|
3. **Optional:** a separate rule (e.g. `.cursor/argsbarg.mdc` or `AGENTS.md`) for broader package API notes.
|
|
467
469
|
|
|
468
|
-
**Not this file:** `myapp
|
|
470
|
+
**Not this file:** `myapp configure` writes the **app** skill (`SKILL.md` under `~/.cursor/skills/`) from your command schema — how to *invoke* the CLI. The rule above is for *authoring* argsbarg schema.
|
|
469
471
|
|
|
470
472
|
## See also
|
|
471
473
|
|
|
@@ -473,5 +475,5 @@ If you maintain argsbarg from a sibling checkout, `just consumer-dev` / `just co
|
|
|
473
475
|
- [Output schemas](output-schema.md) — codegen pipeline for leaf `outputSchema`
|
|
474
476
|
- [Developing argsbarg](developing.md) — release, consumer sync, npm `files`
|
|
475
477
|
- [MCP server](mcp.md) — tools, schema resource, env bootstrapping
|
|
476
|
-
- [Agent skills](ai-skills.md) — `
|
|
478
|
+
- [Agent skills](ai-skills.md) — `configure`
|
|
477
479
|
- [Bundled docs](bundled-docs.md) — `docs` topics, consumer docgen vs framework docs
|