argsbarg 4.0.4 → 4.1.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.
Files changed (147) hide show
  1. package/CHANGELOG.md +77 -1
  2. package/README.md +91 -85
  3. package/docs/README.md +6 -6
  4. package/docs/ai-skills.md +8 -5
  5. package/docs/bundled-docs.md +1 -1
  6. package/docs/cli-program.md +9 -7
  7. package/docs/config-schema.md +37 -13
  8. package/docs/developing.md +8 -8
  9. package/docs/distribution-homebrew.md +103 -0
  10. package/docs/install.md +143 -106
  11. package/docs/mcp.md +23 -12
  12. package/docs/output-schema.md +1 -1
  13. package/examples/full-example/Formula/.gitkeep +0 -0
  14. package/examples/full-example/README.md +98 -0
  15. package/examples/full-example/biome.json +22 -0
  16. package/examples/{consumer-app → full-example}/bun.lock +2 -0
  17. package/examples/full-example/justfile +134 -0
  18. package/examples/{consumer-app → full-example}/package.json +10 -3
  19. package/examples/{consumer-app → full-example}/schemas/generated/app-config.json +1 -1
  20. package/examples/{consumer-app → full-example}/schemas/generated/status.json +1 -1
  21. package/examples/full-example/scripts/create-identity.ts +11 -0
  22. package/examples/full-example/scripts/formula-shared.ts +73 -0
  23. package/examples/full-example/scripts/gen-dev-formula.ts +26 -0
  24. package/examples/full-example/scripts/print-identity.ts +27 -0
  25. package/examples/full-example/src/commands/echo/command.ts +21 -0
  26. package/examples/full-example/src/commands/status/command.test.ts +10 -0
  27. package/examples/full-example/src/commands/status/command.ts +36 -0
  28. package/examples/{consumer-app → full-example}/src/commands/status/types.ts +1 -1
  29. package/examples/full-example/src/index.ts +10 -0
  30. package/examples/full-example/src/program.ts +57 -0
  31. package/examples/{consumer-app → full-example}/src/types.ts +1 -1
  32. package/examples/mcp-test.ts +8 -24
  33. package/examples/nested.ts +1 -3
  34. package/index.d.ts +81 -65
  35. package/package.json +2 -2
  36. package/src/builtins/builtins.test.ts +37 -22
  37. package/src/builtins/completion-group.ts +17 -15
  38. package/src/builtins/config.test.ts +31 -25
  39. package/src/builtins/config.ts +4 -3
  40. package/src/builtins/dispatch.ts +25 -1
  41. package/src/builtins/install.ts +45 -82
  42. package/src/builtins/mcp.ts +1 -1
  43. package/src/builtins/registry.ts +2 -0
  44. package/src/builtins/uninstall.ts +80 -0
  45. package/src/capabilities.ts +5 -7
  46. package/src/cli-tool/cli-smoke.test.ts +19 -0
  47. package/src/cli-tool/create.test.ts +119 -0
  48. package/src/cli-tool/create.ts +380 -0
  49. package/{examples/consumer-app/capabilities.test.ts → src/cli-tool/full-example-capabilities.test.ts} +15 -14
  50. package/src/cli-tool/main.ts +8 -0
  51. package/src/cli-tool/post-create.ts +111 -0
  52. package/src/cli-tool/program.ts +82 -0
  53. package/src/cli-tool/prompt.ts +28 -0
  54. package/src/cli-tool/run-create.ts +149 -0
  55. package/src/config/bootstrap.ts +174 -66
  56. package/src/config/context.test.ts +22 -36
  57. package/src/config/context.ts +5 -4
  58. package/src/config/file.test.ts +66 -56
  59. package/src/config/file.ts +33 -25
  60. package/src/config/resolve.test.ts +192 -1
  61. package/src/config/resolve.ts +92 -13
  62. package/src/config.integration.test.ts +17 -10
  63. package/src/docs/api-guide.test.ts +4 -5
  64. package/src/docs/docs.test.ts +2 -1
  65. package/src/docs/mcp-guide.ts +7 -8
  66. package/src/hidden-mcpb.test.ts +41 -1
  67. package/src/index.ts +7 -10
  68. package/src/install/binary-placement.test.ts +101 -0
  69. package/src/install/binary-placement.ts +47 -0
  70. package/src/install/detect-installed.ts +2 -97
  71. package/src/install/index.ts +239 -168
  72. package/src/install/install-validate.test.ts +61 -0
  73. package/src/install/install.test.ts +170 -90
  74. package/src/install/mcp-openclaw.test.ts +40 -0
  75. package/src/install/mcp-openclaw.ts +106 -0
  76. package/src/install/normalize-uninstall.ts +11 -0
  77. package/src/install/normalize.ts +20 -0
  78. package/src/install/paths.ts +18 -26
  79. package/src/install/plan.ts +40 -261
  80. package/src/install/shell.ts +0 -14
  81. package/src/install/status.test.ts +85 -0
  82. package/src/install/status.ts +22 -15
  83. package/src/install/target-base.ts +93 -0
  84. package/src/install/target-detect.ts +20 -0
  85. package/src/install/target-effective.ts +129 -0
  86. package/src/install/target-mcp-cli.ts +149 -0
  87. package/src/install/target-mcp-json.ts +130 -0
  88. package/src/install/target-plan-build.ts +67 -0
  89. package/src/install/target-registry.ts +57 -0
  90. package/src/install/target-scope.ts +253 -0
  91. package/src/install/target-skill.ts +104 -0
  92. package/src/install/target-types.ts +129 -0
  93. package/src/install/targets/app.ts +60 -0
  94. package/src/install/targets/chatgpt-mcp.ts +12 -0
  95. package/src/install/targets/claude-code-mcp.ts +15 -0
  96. package/src/install/targets/claude-desktop-mcp.ts +12 -0
  97. package/src/install/targets/claude-skill.ts +16 -0
  98. package/src/install/targets/codex-mcp.ts +25 -0
  99. package/src/install/targets/codex-skill.ts +14 -0
  100. package/src/install/targets/configure.ts +63 -0
  101. package/src/install/targets/cursor-mcp.ts +15 -0
  102. package/src/install/targets/cursor-skill.ts +16 -0
  103. package/src/install/targets/index.ts +50 -0
  104. package/src/install/targets/openclaw-mcp.ts +25 -0
  105. package/src/install/targets/openclaw-skill.ts +17 -0
  106. package/src/install/targets/opencode-mcp.ts +101 -0
  107. package/src/install/targets/opencode-skill.ts +15 -0
  108. package/src/install/targets.test.ts +118 -0
  109. package/src/install/uninstall.ts +16 -152
  110. package/src/invoke.test.ts +7 -1
  111. package/src/mcp/bundle.ts +16 -4
  112. package/src/mcp/claude.test.ts +14 -1
  113. package/src/mcp/claude.ts +11 -4
  114. package/src/mcp/env.test.ts +92 -0
  115. package/src/mcp/env.ts +15 -14
  116. package/src/mcp/zip.test.ts +17 -0
  117. package/src/mcp/zip.ts +62 -9
  118. package/src/mcp.integration.test.ts +1 -1
  119. package/src/parse.test.ts +14 -2
  120. package/src/paths/host.ts +11 -11
  121. package/src/paths/remove-empty-dir.ts +13 -0
  122. package/src/prompt.ts +10 -0
  123. package/src/schema.ts +9 -1
  124. package/src/skill/generate.ts +18 -4
  125. package/src/skill/install.ts +33 -6
  126. package/src/skill/naming.ts +28 -0
  127. package/src/types.ts +86 -7
  128. package/src/validate.ts +73 -9
  129. package/docs/templates/cursor/rules/cli-program.mdc +0 -31
  130. package/examples/config-app/main.ts +0 -20
  131. package/examples/config-app/program.ts +0 -81
  132. package/examples/config-app/schema.ts +0 -37
  133. package/examples/config-app/types.ts +0 -19
  134. package/examples/consumer-app/README.md +0 -57
  135. package/examples/consumer-app/src/main.ts +0 -15
  136. package/examples/consumer-app/src/program.ts +0 -108
  137. package/src/install/binary.ts +0 -94
  138. package/src/install/completions.ts +0 -56
  139. package/src/install/update.test.ts +0 -108
  140. package/src/install/update.ts +0 -57
  141. /package/examples/{consumer-app → full-example}/schemas/configSchemas.ts +0 -0
  142. /package/examples/{consumer-app → full-example}/schemas/outputSchemas.ts +0 -0
  143. /package/examples/{consumer-app → full-example}/scripts/schemagen/discover-schema-roots.test.ts +0 -0
  144. /package/examples/{consumer-app → full-example}/scripts/schemagen/discover-schema-roots.ts +0 -0
  145. /package/examples/{consumer-app → full-example}/scripts/schemagen/naming.ts +0 -0
  146. /package/examples/{consumer-app → full-example}/scripts/schemagen.ts +0 -0
  147. /package/examples/{consumer-app → full-example}/tsconfig.json +0 -0
@@ -32,16 +32,16 @@ Sibling repos under `../../ss/` (paths are machine-specific; adjust in `justfile
32
32
 
33
33
  | Recipe | When | Effect |
34
34
  | --- | --- | --- |
35
- | `just consumer-dev` | Before publish; hacking on argsbarg locally | `bun add argsbarg@file:<relative>`; refresh `.cursor/rules/cli-program.mdc` from template (keeps app-specific suffix) |
36
- | `just consumers-sync` | After release | Sets `"argsbarg": "^<this package.json version>"`, `bun install`, merge **argsbarg Cursor rule**, `just build`, `just docgen`, `just install` (consumer app binary, completions, and **app** skill) |
35
+ | `just consumers-dev` | Before publish; hacking on argsbarg locally | `bun add argsbarg@file:<relative>`; refresh `.cursor/rules/cli-program.mdc` from template (keeps app-specific suffix) |
36
+ | `just consumers-sync` | After release | Sets `"argsbarg": "^<this package.json version>"`, `bun install`, merge **argsbarg Cursor rule**, `just build`, `just docgen`, `just install-local` (Homebrew dev formula + agent artifacts; `just install` is an alias) |
37
37
 
38
38
  `consumers-sync` reads the version from **this repo’s** `package.json` — not npm. Run it **after** `just release` so consumers pin a version that exists on the registry.
39
39
 
40
- **Argsbarg authoring rule** — `scripts/merge-cli-program-rule.ts` copies `docs/templates/cursor/rules/cli-program.mdc` into each consumer’s `.cursor/rules/cli-program.mdc`, preserving any existing `**… conventions:**` footer block.
40
+ **Argsbarg authoring rule** — `scripts/merge-cli-program-rule.ts` copies `examples/full-example/.cursor/rules/cli-program.mdc` into each consumer’s `.cursor/rules/cli-program.mdc`, preserving any existing `**… conventions:**` footer block.
41
41
 
42
42
  **Recommended in each consumer:** replace the template placeholder with `**<app> conventions:**` bullets (paths to `read*Flags`, shared flags, Ink vs JSON-only). Commit that file; merges refresh the shared top, not your footer.
43
43
 
44
- **Consumer app skill** — `just install` in each consumer (part of `consumers-sync`) runs `myapp install --skill`, which updates `~/.cursor/skills/<app>/` from that app’s schema — not the argsbarg framework rule.
44
+ **Consumer app skill** — `just install-local` in each consumer (part of `consumers-sync`) runs Homebrew dev install then `myapp install --reinstall --yes`, which updates `~/.cursor/skills/<app>/` from that app’s schema — not the argsbarg framework rule.
45
45
 
46
46
  ## npm package contents
47
47
 
@@ -49,14 +49,14 @@ Sibling repos under `../../ss/` (paths are machine-specific; adjust in `justfile
49
49
 
50
50
  When adding docs or examples intended for consumers, ensure they live under whitelisted paths (`docs/`, `examples/`, `src/`, etc.).
51
51
 
52
- Exclude `examples/consumer-app/node_modules/` from the npm tarball via [`.npmignore`](../.npmignore).
52
+ Exclude `examples/full-example/node_modules/` from the npm tarball via [`.npmignore`](../.npmignore).
53
53
 
54
- ## Kitchen-sink example
54
+ ## Full example
55
55
 
56
- [`examples/consumer-app/`](../examples/consumer-app/) must enable every builtin (`capabilities.test.ts`). After builtin or schemagen doc changes:
56
+ [`examples/full-example/`](../examples/full-example/) must enable every builtin (`capabilities.test.ts`). After builtin or schemagen doc changes:
57
57
 
58
58
  ```bash
59
- just consumer-app-schemagen
59
+ just full-example-schemagen
60
60
  just test
61
61
  ```
62
62
 
@@ -0,0 +1,103 @@
1
+ # Shipping via Homebrew (tap-from-repo)
2
+
3
+ Argsbarg apps distribute the **binary and shell completions** through Homebrew, and **agent artifacts** (skills, MCP config) through `install --reinstall`.
4
+
5
+ ## Distribution model
6
+
7
+ | Layer | Mechanism |
8
+ | --- | --- |
9
+ | Binary + completions | Formula `install` block |
10
+ | Skills + MCP | Formula `post_install` → `{key} install --reinstall --yes` |
11
+ | App config | User opt-in: `{key} install --configure` (interactive; not run from formula `post_install`) |
12
+
13
+ **Only tap-from-repo** — in-repo `Formula/` or GitHub tap. Not Homebrew core.
14
+
15
+ ### End-user install
16
+
17
+ ```bash
18
+ brew tap <org>/<repo>
19
+ brew install <tap>/{key}
20
+ {key} install --configure # when app config is required
21
+ ```
22
+
23
+ ### Developer install
24
+
25
+ ```bash
26
+ just build
27
+ just install-local # or `just install` (alias)
28
+ just reinstall-local # fast binary swap (`install -m 755` into Cellar; run install-local first)
29
+ just uninstall # undo formula + agent artifacts (not app config)
30
+ ```
31
+
32
+ Dev and release use the **same formula** (`Formula/{key}.rb`, class name, install/post_install/test). `gen-dev-formula.ts` only changes `url`, `version`, and `sha256` to point at the local binary in `Formula/.staging/`. Release bumps restore the GitHub URL via `scripts/release.ts`.
33
+
34
+ ### Developer uninstall
35
+
36
+ | Recipe | Removes |
37
+ | --- | --- |
38
+ | `just uninstall` | Formula `{key}` + tap symlink + skills/MCP |
39
+ | `just uninstall-config` | App config file only (`uninstall --configure`) |
40
+ | `just uninstall-release` | Release formula from `{tap}` (keeps tap) |
41
+ | `just uninstall-release-tap` | Release formula + `brew untap {tap}` |
42
+ | `just test-release` | Install release formula and run formula test |
43
+
44
+ End users: `<key> uninstall --yes` then `brew uninstall <tap>/<key>`.
45
+
46
+ ## Formula pattern
47
+
48
+ ```ruby
49
+ def install
50
+ bin.install "{key}"
51
+ generate_completions_from_executable(bin/"{key}", "completion", base_name: "{key}")
52
+ end
53
+
54
+ def post_install
55
+ system bin/"{key}", "install", "--reinstall", "--yes"
56
+ end
57
+ ```
58
+
59
+ Completions require users to configure their shell per [Homebrew Shell Completion](https://docs.brew.sh/Shell-Completion).
60
+
61
+ **Why configure is separate from `post_install`:** the wizard is interactive (TTY + prompts for secrets). Formula `post_install` runs non-interactively during `brew install` and in CI (`brew test`). Apps with `appConfig` print a one-line configure hint in formula `caveats` instead.
62
+
63
+ ## Bootstrap CLI (`argsbarg create`)
64
+
65
+ Copy the shipped `examples/full-example` template into a new directory with identity substitutions, then run install, schemagen, tests, and git init (when appropriate):
66
+
67
+ ```bash
68
+ bunx argsbarg create my-cli \
69
+ --key my-cli --class-name MyCli --tap org/my-cli \
70
+ --homepage https://github.com/org/my-cli --release-repo org/my-cli \
71
+ --yes
72
+ ```
73
+
74
+ On a TTY, omit flags to use the interactive wizard. Verify an existing tree:
75
+
76
+ ```bash
77
+ bunx argsbarg create --check .
78
+ ```
79
+
80
+ Template source: [`examples/full-example/`](../examples/full-example/) in the argsbarg package (also under `node_modules/argsbarg/examples/full-example` after `bun add argsbarg`).
81
+
82
+ **Git bootstrap skip rules:** post-create skips `git init` when the target already has a `.git` directory, or when the target sits inside an existing git work tree (e.g. a monorepo subfolder). Standalone new directories get an `Initial commit`.
83
+
84
+ ## Release workflow
85
+
86
+ 1. `just build` → `dist/{key}`
87
+ 2. `scripts/release.ts` → writes `Formula/{key}.rb` (GitHub URL + sha256), commits, tags, uploads `dist/{key}` to GitHub Releases
88
+ 3. Users `brew upgrade {key}` from the tap
89
+
90
+ ## Removed (breaking)
91
+
92
+ - Self-install to `~/.local/bin`
93
+ - `install --update` / `updateGetLatest`
94
+ - `install --completions` (Homebrew owns completions)
95
+ - Bare-argv install bootstrap
96
+ - Auto configure wizard after `install --all`
97
+ - Separate `{key}-local` formula and `{key}/dev` tap
98
+
99
+ ## Config path
100
+
101
+ Default: `~/.local/lib/<sanitized-key>/config.json`
102
+
103
+ Export helpers: `resolveAppConfigPath`, `displayAppConfigPath` from `argsbarg`.
package/docs/install.md CHANGED
@@ -1,169 +1,206 @@
1
1
  # Install command
2
2
 
3
- The `install` built-in installs the binary, shell completions, agent skills, and MCP config. Opt out with `install: { enabled: false }` on the program root.
3
+ The `install` built-in manages **agent artifacts** (skills, MCP config, app config). The **binary and shell completions** ship via Homebrew — see [distribution-homebrew.md](distribution-homebrew.md).
4
4
 
5
- ## Quick start
5
+ Opt out with `install: { enabled: false }` on the program root.
6
+
7
+ ## End-user install (Homebrew)
8
+
9
+ ```bash
10
+ brew tap <org>/<repo>
11
+ brew install <tap>/<key>
12
+ <key> install --configure # when app config is required (interactive)
13
+ ```
14
+
15
+ Upgrade with `brew upgrade <key>`. Shell completions are installed by Homebrew during `brew install`. Users must configure their shell per [Homebrew Shell Completion](https://docs.brew.sh/Shell-Completion).
16
+
17
+ **Uninstall the binary:** `brew uninstall <key>`. Remove agent artifacts first (while the CLI is still on PATH):
18
+
19
+ ```bash
20
+ <key> uninstall --yes
21
+ brew uninstall <tap>/<key>
22
+ ```
23
+
24
+ ## Developer install
6
25
 
7
26
  ```bash
8
- # First-time setup
9
- myapp install --all --yes
27
+ just build
28
+ just install-local # same formula as production; gen-dev-formula uses file:// URL (`just install` is an alias)
29
+ ```
10
30
 
11
- # Refresh after upgrading (re-copy running binary + refresh installed artifacts)
12
- myapp install --reinstall
31
+ Dev flow matches release: formula `install` copies the binary and generates completions; `post_install` runs `<key> install --reinstall --yes` for skills/MCP. Use `just reinstall-local` to swap the binary into Cellar during tight edit cycles (skips completions and `post_install`). Use `just install-artifacts` to refresh agent artifacts without touching the binary.
13
32
 
14
- # Upgrade to latest release (when install.updateGetLatest is configured)
15
- myapp install --update
33
+ ## Quick reference
34
+
35
+ ```bash
36
+ # Refresh skills/MCP after upgrade (Homebrew post_install runs this automatically)
37
+ <key> install --reinstall --yes
16
38
 
17
39
  # See what is installed
18
- myapp install --status
40
+ <key> install --status
41
+
42
+ # Configure app settings (interactive wizard — not part of --all or post_install)
43
+ <key> install --configure
19
44
 
20
- # Remove everything installed with --all
21
- myapp install --uninstall --all --yes
45
+ # Remove agent artifacts (default: --all)
46
+ <key> uninstall --yes
22
47
  ```
23
48
 
49
+ Non-interactive / CI: pass **`--yes`** (or **`--json`**, **`--reinstall`**) — see [Confirmation](#confirmation).
50
+
24
51
  ## What gets installed
25
52
 
26
- | Target | Flag | Destination |
53
+ | Target | Flag | Mechanism |
27
54
  | --- | --- | --- |
28
- | Binary | `--bin` | `~/.local/bin/<key>` (or `--prefix`) |
29
- | Bash completion | `--completions` | `~/.bash_completion.d/<key>` + `.bashrc` PATH snippet |
30
- | Zsh completion | `--completions` | `~/.zsh/completions/_<key>` + `.zshrc` fpath snippet |
31
- | Fish completion | `--completions` | `~/.config/fish/completions/<key>.fish` |
32
- | Cursor skill | `--skill` | `~/.cursor/skills/<dir>/` when `~/.cursor` exists |
33
- | Claude skill | `--skill` | `~/.claude/skills/<dir>/` when `~/.claude` exists |
34
- | MCP config | `--mcp` | Cursor, Claude Code/Desktop, OpenCode (`~/.config/opencode`), Codex (`codex` on PATH), ChatGPT desktop (when app data exists). ChatGPT web uses Connectors — see `docs mcp` |
35
- | App config | `--config` | JSON config file for `program.appConfig` (with `--uninstall`; included in `--uninstall --all`) |
55
+ | Binary | Homebrew formula | `bin.install` in Formula |
56
+ | Shell completions | Homebrew formula | `generate_completions_from_executable` |
57
+ | Cursor skill | `--skill` / `--all` | `~/.cursor/skills/<dir>/` when `~/.cursor` exists |
58
+ | Claude skill | `--skill` / `--all` | `~/.claude/skills/<dir>/` when `~/.claude` exists |
59
+ | Codex / OpenCode / OpenClaw skills | `--skill` / `--all` | Agent-specific dirs when available |
60
+ | MCP config | `--mcp` / `--all` | Cursor, Claude Code/Desktop, OpenCode, Codex, OpenClaw, ChatGPT desktop |
61
+ | App config | `--configure` | Interactive wizard writes `~/.local/lib/<key>/config.json` |
36
62
 
37
- `--all` expands to `--bin`, `--completions`, `--skill`, and `--mcp` (when `mcpServer.enabled` is `true`) for both install and uninstall. Missing targets are skipped silently (no error if nothing is on disk or a shell/agent directory does not exist).
63
+ ### Externally managed binary (Homebrew)
38
64
 
39
- `install --uninstall` requires the same target flags as install (`--all`, `--bin`, etc.) — bare `--uninstall` alone is an error.
65
+ When **`PATH`** resolves the program key to the **running executable** (e.g. after `brew install`):
40
66
 
41
- Shells not on PATH are skipped silently (no warnings).
67
+ - **`install --status`** shows `app: system (PATH)`
68
+ - **`--all`** / **`--reinstall`** refresh skills and MCP only — not the binary or completions
42
69
 
43
- ## Configuration
70
+ MCP config uses the command name on **`PATH`**, not a Cellar path.
44
71
 
45
- On the program root:
72
+ ### Default `--all` behavior
46
73
 
47
- ```typescript
48
- install: {
49
- enabled: false, // opt out of the install built-in
50
- prefix: "~/.local/bin", // default bin directory
51
- updateGetLatest: async ({ version }) => {
52
- // download or locate latest binary; return { path, version, cleanup }
53
- return { path: "/tmp/myapp", version: "2.0.0" };
54
- },
55
- }
56
- ```
57
-
58
- When `updateGetLatest` is set, ArgsBarg adds **`install --update`** (download latest release and reinstall installed artifacts).
74
+ Bare **`install`** and **`install --all`** install targets with **`includedInAll: true`**. Core defaults:
59
75
 
60
- ### GitHub releases (`ghReleaseUpdateGetLatest`)
76
+ - **Agent integration** (`install.agentIntegration`, default from `mcpServer.enabled`):
77
+ - **`skill`** (default when MCP off): all `*Skill` keys in `--all`; paired `*Mcp` keys excluded
78
+ - **`mcp`** (default when `mcpServer.enabled`): all `*Mcp` keys in `--all`; paired skills excluded
79
+ - **`both`**: MCP and skill for the same host when available
80
+ - **`configure`** is **opt-in** (`includedInAll: false`) — run **`install --configure`** separately
61
81
 
62
- For compiled binaries published via `gh release`, wire a hook without hand-rolling download logic:
82
+ Desktop-only MCP hosts (`claudeDesktopMcp`, `chatgptMcp`) follow the MCP side only — no skill pair.
63
83
 
64
- ```typescript
65
- import {
66
- createGhFetchLatest,
67
- createGhVersionCheck,
68
- ghReleaseUpdateGetLatest,
69
- } from "argsbarg";
84
+ Scoped flags (`--skill`, `--mcp`, `--configure`) run that artifact category. Honor `enabled: false` as a hard off.
70
85
 
71
- const cachePath = path.join(configDir, "version-check.json");
86
+ Use **`install --status --json`** to preview effective targets before installing.
72
87
 
73
- install: {
74
- updateGetLatest: ghReleaseUpdateGetLatest({
75
- repo: "owner/repo",
76
- asset: "myapp",
77
- tempPrefix: "myapp-update.",
78
- cachePath,
79
- }),
80
- }
81
-
82
- // Optional: summary notice + background refresh
83
- const versionCheck = createGhVersionCheck({
84
- currentVersion: "1.0.0",
85
- commandName: "myapp",
86
- cachePath,
87
- fetchLatest: createGhFetchLatest({ repo: "owner/repo" }),
88
- });
89
- versionCheck.getUpdateNotice();
90
- versionCheck.refreshIfStale();
91
- ```
88
+ ### Asymmetric uninstall
92
89
 
93
- Requires `gh` on PATH and `gh auth login`. Consumers keep app-specific config only (~15 lines).
90
+ The top-level **`uninstall`** command removes agent artifacts. Bare **`uninstall`** is equivalent to **`uninstall --all`**.
94
91
 
95
- Environment:
92
+ - **`uninstall --all`** removes **every detected artifact type**, ignoring `install.targets`.
93
+ - Scoped uninstall (`--skill`, `--mcp`, `--configure`, …) removes only that category.
96
94
 
97
- - `INSTALL_PREFIX` — same as `install.prefix` / `--prefix`
95
+ Missing targets are skipped silently.
98
96
 
99
- ## App config (`program.appConfig`)
97
+ ## `install.targets`
100
98
 
101
- When `program.appConfig` is set on the program root, ArgsBarg manages a flat JSON config file:
99
+ Configure which artifacts participate in `--all`, `--reinstall`:
102
100
 
103
101
  ```typescript
104
- appConfig: {
105
- entries: {
106
- apiToken: {
107
- description: "Create at https://example.com/settings/tokens",
108
- env: "API_TOKEN",
109
- sensitive: true,
110
- },
102
+ install: {
103
+ agentIntegration: "mcp", // | "skill" | "both" — default from mcpServer.enabled
104
+ targets: {
105
+ chatgptMcp: false,
106
+ cursorSkill: { includedInAll: true },
111
107
  },
112
- path: "~/.config/myapp/config", // optional; default is OS-specific
113
108
  },
114
109
  ```
115
110
 
116
- Default path: `$XDG_CONFIG_HOME/<sanitized-key>/config` (Linux/macOS) or `%APPDATA%/<key>/config` (Windows).
111
+ `InstallTargetSpec` is `boolean` or `{ enabled?: boolean; includedInAll?: boolean }`.
112
+
113
+ Artifact keys: `chatgptMcp`, `claudeCodeMcp`, `claudeDesktopMcp`, `claudeSkill`, `codexMcp`, `codexSkill`, `configure`, `cursorMcp`, `cursorSkill`, `openclawMcp`, `openclawSkill`, `opencodeMcp`, `opencodeSkill`.
114
+
115
+ ## App config (`program.appConfig`)
116
+
117
+ When `program.appConfig` is set, ArgsBarg manages a flat JSON config file at `~/.local/lib/<sanitized-key>/config.json`.
117
118
 
118
119
  | Flag | Description |
119
120
  | --- | --- |
120
- | `--configure` | Interactive prompt for each schema entry; writes or updates the config file (standalone — not part of `--all`) |
121
- | `--uninstall --config` | Remove the config file (included in `--uninstall --all`) |
121
+ | `--configure` | Interactive prompt; writes or updates the config file. **Not** included in `--all`. |
122
122
  | `--status` | Shows config path and which required keys are set or missing |
123
123
 
124
- **Configure UX** (TTY):
124
+ Use **`uninstall --configure`** to remove the config directory.
125
125
 
126
+ Export helpers from `argsbarg`: `resolveAppConfigPath`, `displayAppConfigPath`.
127
+
128
+ ## `uninstall` command
129
+
130
+ Sibling of `install` for removing agent artifacts:
131
+
132
+ ```bash
133
+ <key> uninstall --yes # all artifacts (default)
134
+ <key> uninstall --configure --yes # config only
135
+ <key> uninstall --skill --yes # skills only
126
136
  ```
127
- API token
128
- Create at https://example.com/settings/tokens
129
- Current: REDACTED
130
- Value (Enter to keep):
131
- ```
132
137
 
133
- Non-sensitive vars show the current value; first-time setup omits the `Current:` line.
138
+ Same behavior flags as install: `--yes`, `--dry`, `--json`. Does not support `--status` or `--reinstall`.
139
+
140
+ ## Flags (`install`)
134
141
 
135
- ## Flags
142
+ ### Target flags
143
+
144
+ | Flag | Description |
145
+ | --- | --- |
146
+ | `--all` | Install the default agent artifact set for this app |
147
+ | `--skill` | Install agent skills |
148
+ | `--mcp` | Add MCP server configuration |
149
+ | `--configure` | Run the interactive configuration wizard |
150
+
151
+ ### Operation flags (`install`)
136
152
 
137
153
  | Flag | Description |
138
154
  | --- | --- |
139
- | `--yes` | Skip confirmation (required for non-TTY unless `--json`, `--reinstall`, or `--update`) |
140
- | `--dry` | Preview changes; per-step messages on stderr with `[dry run]` |
141
- | `--json` | Machine-readable output on stdout (implies `--yes`) |
142
- | `--quiet` | Suppress summaries and per-step messages (requires `--yes`) |
143
- | `--prefix <dir>` | Override binary install directory |
144
- | `--reinstall` | Reinstall artifacts already on disk (implies `--bin` + `--yes`) |
145
- | `--update` | Download latest release and reinstall installed artifacts (requires `install.updateGetLatest`; implies `--yes`) |
146
- | `--from <path>` | Binary to copy with `--reinstall` (default: running executable) |
147
155
  | `--status` | Read-only inventory |
148
- | `--uninstall` | Remove artifacts in scope (`--all`, `--bin`, `--completions`, `--skill`, `--mcp`, `--config`); skips targets not installed |
156
+ | `--reinstall` | Refresh installed agent artifacts (Homebrew `post_install`; greenfield → full `--all` plan) |
157
+ | `--from <path>` | App executable reference for status detection (rare; default: running executable) |
158
+
159
+ ### Behavior flags
160
+
161
+ | Flag | Description |
162
+ | --- | --- |
163
+ | `--yes`, `-y` | Skip confirmation |
164
+ | `--dry` | Preview changes |
165
+ | `--json` | Machine-readable output (implies `--yes`) |
166
+
167
+ ## Confirmation
168
+
169
+ Install and uninstall (except `--yes`, `--json`, `--dry`, `--reinstall`) print a **`{app} Setup`** banner and numbered plan. Reply **`y`** for all, **`n`** or Enter to abort, or numbers for a subset.
149
170
 
150
171
  ## MCP merge behavior
151
172
 
152
- When `--mcp` runs, entries are merged into `mcpServers[<sanitized-key>]` with:
173
+ When `--mcp` runs, entries are merged into host config with:
153
174
 
154
175
  ```json
155
176
  { "command": "<root.key>", "args": ["mcp"] }
156
177
  ```
157
178
 
158
- If an existing entry differs, the command exits with an error unless `--yes` is passed (then it overwrites).
179
+ If an existing entry differs, the command exits with an error unless `--yes` is passed.
180
+
181
+ ## Formula `post_install`
182
+
183
+ Release formulae should run:
184
+
185
+ ```ruby
186
+ def post_install
187
+ system bin/"myapp", "install", "--reinstall", "--yes"
188
+ end
189
+ ```
190
+
191
+ This refreshes skills/MCP without running the configure wizard (configure is opt-in).
192
+
193
+ ## Bootstrapping a new CLI
194
+
195
+ ```bash
196
+ bunx argsbarg create my-cli --key my-cli --class-name MyCli --tap org/repo --yes
197
+ bunx argsbarg create --check .
198
+ ```
199
+
200
+ See [distribution-homebrew.md](distribution-homebrew.md) and [../examples/full-example/README.md](../examples/full-example/README.md).
159
201
 
160
202
  ## Opt out
161
203
 
162
204
  ```typescript
163
- const cli = {
164
- key: "myapp",
165
- description: "...",
166
- install: { enabled: false },
167
- // ...
168
- } satisfies CliProgram;
205
+ install: { enabled: false },
169
206
  ```
package/docs/mcp.md CHANGED
@@ -131,7 +131,7 @@ Set `mcpServer` on the **program root only** (the `CliProgram` passed to `new Cl
131
131
  | --- | --- | --- |
132
132
  | `enabled` | *(required)* | Must be `true` when `mcpServer` is set |
133
133
  | `schemaResourceUri` | `<sanitized root key>://schema` | URI for the built-in schema resource |
134
- | `shellEnv` | off | Capture login-shell `env` at startup (`true` uses `$SHELL`, or pass a shell path) |
134
+ | `shellEnv` | on (opt-out with `false`) | Capture login-shell `env` at startup (`true` uses `$SHELL`, or pass a shell path) |
135
135
  | `resources` | `[]` | Custom `CliMcpResource` entries (additive; schema resource is always included) |
136
136
 
137
137
  MCP `serverInfo.name` and the default schema URI use the sanitized program `key` (non-alphanumeric characters become `_`). Program `version` comes from `CliProgram.version` (also used by the `version` built-in).
@@ -141,7 +141,7 @@ Example with optional fields:
141
141
  ```typescript
142
142
  mcpServer: {
143
143
  enabled: true,
144
- shellEnv: true,
144
+ shellEnv: false, // opt out of login-shell capture
145
145
  }
146
146
  ```
147
147
 
@@ -322,7 +322,7 @@ At server start (`Cli.serveMcp()`), before the NDJSON loop:
322
322
 
323
323
  **App config (`program.appConfig`):**
324
324
 
325
- - Default path: `$XDG_CONFIG_HOME/<sanitized-key>/config` (Linux/macOS) or `%APPDATA%/<key>/config` (Windows). Override with `config.path`.
325
+ - Default path: `~/.local/lib/<sanitized-key>/config`.
326
326
  - JSON shape: flat object keyed by schema names — `{ "apiToken": "…" }`. Unknown keys rejected on load.
327
327
  - Loaded at MCP startup; host `process.env` wins for mapped env vars already set.
328
328
  - Missing required config does **not** exit the MCP server — enforced at `tools/call` with a helpful error.
@@ -339,7 +339,6 @@ appConfig: {
339
339
  },
340
340
  mcpServer: {
341
341
  enabled: true,
342
- shellEnv: true,
343
342
  },
344
343
  ```
345
344
 
@@ -373,33 +372,45 @@ You should get one JSON line on stdout with `result.capabilities` and `result.se
373
372
 
374
373
  ## MCP Bundle (`mcp bundle`)
375
374
 
376
- When `mcpServer.enabled` is true, **`mcp bundle`** writes two distribution artifacts:
375
+ When `mcpServer.enabled` is true, **`mcp bundle`** writes dist artifacts you opt into on the program root:
377
376
 
378
377
  ```bash
379
378
  just build
380
379
  ./dist/myapp mcp bundle
381
- # → dist/myapp.mcpb
382
- # → dist/claude-plugin/myapp.zip
380
+ # → dist/myapp.mcpb (when mcpServer.mcpd: true)
381
+ # → dist/claude-plugin/myapp.zip (when mcpServer.claudePlugin: true)
383
382
  ```
384
383
 
385
- Expects the compiled binary at **`dist/<program.key>`**.
384
+ Enable one or both flags:
385
+
386
+ ```typescript
387
+ mcpServer: {
388
+ enabled: true,
389
+ mcpd: true, // Claude Desktop `.mcpb`
390
+ claudePlugin: true, // Claude Code plugin zip
391
+ },
392
+ ```
393
+
394
+ Expects the compiled binary at **`dist/<program.key>`**. Stdout prints one path per artifact produced.
386
395
 
387
396
  | Output | Purpose |
388
397
  | --- | --- |
389
- | **`dist/<key>.mcpb`** | Claude Desktop MCP Bundle (`.mcpb` zip) |
390
- | **`dist/claude-plugin/<name>.zip`** | Claude Code plugin zip (`<name>` is kebab-case from `program.key`) |
398
+ | **`dist/<key>.mcpb`** | Claude Desktop MCP Bundle — when `mcpd: true` (default **false**) |
399
+ | **`dist/claude-plugin/<name>.zip`** | Claude Code plugin zip — when `claudePlugin: true` (default **false**) |
391
400
 
392
401
  Manifest metadata is generated from your schema (`mcpServerId`, tools, `program.appConfig` user config for env-mapped entries). Optional pack-time fields live under **`mcpServer.bundle`** (`author`, `icon`, `longDescription`).
393
402
 
394
403
  **Claude Code plugin zip layout** (paths at archive root):
395
404
 
396
405
  ```
397
- .claude-plugin/plugin.json
406
+ .claude-plugin/plugin.json # includes "mcpServers": ".mcp.json"
398
407
  .mcp.json
399
- bin/myapp
408
+ bin/myapp # executable (0755 preserved in the zip)
400
409
  skills/<dirName>/SKILL.md
401
410
  ```
402
411
 
412
+ `plugin.json` references `.mcp.json` so Claude Desktop and Claude Code load the bundled MCP server when the plugin is enabled. The plugin zip preserves the executable bit on `bin/<key>`.
413
+
403
414
  The bundled `SKILL.md` is an **MCP routing stub** — it tells Claude to use the plugin’s MCP toolset (server id, `tools/list`, schema resource). It is not a shell CLI catalog and does not include `reference.md`. Use **`install --skill`** for a persisted shell-oriented skill bundle.
404
415
 
405
416
  Load locally with `claude --plugin-dir ./dist/claude-plugin/myapp.zip`.
@@ -186,7 +186,7 @@ Per repo:
186
186
 
187
187
  Add a bullet under your app’s `**… conventions:**` block in `.cursor/rules/cli-program.mdc` pointing at `node_modules/argsbarg/docs/output-schema.md` and your `src/schemas/` layout.
188
188
 
189
- **Reference implementation:** [`examples/consumer-app/`](../examples/consumer-app/) in this repo (shipped in npm as `node_modules/argsbarg/examples/consumer-app/`) — discovery script, bridges, and `status` leaf with `outputSchema`.
189
+ **Reference implementation:** [`examples/full-example/`](../examples/full-example/) in this repo (shipped in npm as `node_modules/argsbarg/examples/full-example/`) — discovery script, bridges, and `status` leaf with `outputSchema`.
190
190
 
191
191
  ## Out of scope
192
192
 
File without changes
@@ -0,0 +1,98 @@
1
+ # full-example
2
+
3
+ **Full argsbarg reference app** — bootstrap new production CLIs with `bunx argsbarg create`.
4
+
5
+ ## What this demonstrates
6
+
7
+ | Area | Files / wiring |
8
+ | --- | --- |
9
+ | All builtins | `completion`, `version`, `install`, `docs`, `mcp`, `config get`/`set` |
10
+ | `program.appConfig` | `src/types.ts` (`AppConfig`) → `schemas/configSchemas.ts` |
11
+ | `outputSchema` | `src/commands/status/types.ts` (`StatusJsonOutput`) → `schemas/outputSchemas.ts` |
12
+ | Schemagen | `scripts/schemagen.ts` + `scripts/schemagen/discover-schema-roots.ts` |
13
+ | Command layout | `src/commands/<name>/command.ts`; registration in `src/program.ts` |
14
+ | MCP doc topics | `docs.topics` auto-exposed as `<key>://docs/<topic>` resources when docs + MCP enabled |
15
+ | Package import | `from "argsbarg"` (not relative to argsbarg `src/`) |
16
+ | Homebrew distribution | `scripts/formula-shared.ts`, `scripts/gen-dev-formula.ts`, `Formula/`, `justfile` |
17
+ | Dev tooling | Biome (`just format` / `just lint`), TypeScript, colocated tests |
18
+ | Cursor rules | `.cursor/rules/cli-program.mdc`, `.cursor/rules/code.mdc` |
19
+
20
+ ## Bootstrap a new CLI
21
+
22
+ Interactive (TTY):
23
+
24
+ ```bash
25
+ bunx argsbarg create my-cli
26
+ ```
27
+
28
+ Non-interactive:
29
+
30
+ ```bash
31
+ bunx argsbarg create my-cli \
32
+ --key my-cli --class-name MyCli --tap org/my-cli \
33
+ --homepage https://github.com/org/my-cli --release-repo org/my-cli \
34
+ --yes
35
+ ```
36
+
37
+ `create` copies this template (including `.cursor/rules/cli-program.mdc`), substitutes identity placeholders, runs `bun install`, schemagen, `bun test`, and `git init` + Initial commit when appropriate.
38
+
39
+ **Git bootstrap:** skipped when `{target}/.git` already exists, or when the target is inside an existing git work tree (monorepo subfolder). Standalone new directories get `Initial commit`.
40
+
41
+ To refresh the Cursor rule in an existing consumer: `bun scripts/merge-cli-program-rule.ts .` from an argsbarg checkout (or pass the npm package path to the template).
42
+
43
+ ## Quick start (in this repo)
44
+
45
+ ```bash
46
+ cd examples/full-example
47
+ just setup
48
+ just schemagen # after changing src/**/types.ts
49
+ FULL_EXAMPLE_API_TOKEN=dev just run status --json
50
+ FULL_EXAMPLE_API_TOKEN=dev just run config get apiToken --json
51
+ FULL_EXAMPLE_API_TOKEN=dev just run docs readme
52
+ ```
53
+
54
+ ## Homebrew dev install
55
+
56
+ Requires [Homebrew](https://brew.sh) and a compiled binary at `dist/full-example`:
57
+
58
+ ```bash
59
+ just build
60
+ just install-local # first-time dev formula (`just install` is an alias)
61
+ just reinstall-local # fast binary swap during development
62
+ just install-production # uninstall local dev, install from GitHub tap
63
+ just test-release
64
+ ```
65
+
66
+ Undo a local dev install:
67
+
68
+ ```bash
69
+ just uninstall # dev formula + agent artifacts
70
+ just uninstall-config # app config only
71
+ just uninstall-release # release formula (keeps tap)
72
+ ```
73
+
74
+ See [docs/distribution-homebrew.md](../../docs/distribution-homebrew.md).
75
+
76
+ ## Schemagen markers
77
+
78
+ | Marker in interface JSDoc | Artifact |
79
+ | --- | --- |
80
+ | `Config schema` | `schemas/configSchemas.ts` + `schemas/generated/*-config.json` |
81
+ | `JSON payload` | `schemas/outputSchemas.ts` + `schemas/generated/*.json` |
82
+
83
+ Discovery walks `src/**/types.ts` only.
84
+
85
+ ## Environment
86
+
87
+ | Variable | Purpose |
88
+ | --- | --- |
89
+ | `FULL_EXAMPLE_API_TOKEN` | Overrides `apiToken` via `program.appConfig` env mapping |
90
+
91
+ ## Maintainers (argsbarg repo)
92
+
93
+ When adding or changing builtins, update this example and run:
94
+
95
+ ```bash
96
+ just check-full-example # from argsbarg repo root
97
+ just test # from examples/full-example
98
+ ```