argsbarg 6.1.9 → 6.1.10

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 CHANGED
@@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [6.1.10] - 2026-07-29
11
+
12
+ ### Changed
13
+
14
+ - Update docs
15
+
10
16
  ## [6.1.9] - 2026-07-27
11
17
 
12
18
  ### Added
@@ -879,7 +885,8 @@ const cli = { ... } satisfies CliProgram; // or : CliProgram
879
885
  - 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`).
880
886
  - Imports: use `CliPositional` where needed; replace `CliOptionDef` with `CliOption` or `CliPositional` as appropriate.
881
887
 
882
- [Unreleased]: https://github.com/bdombro/bun-argsbarg/compare/v6.1.9...HEAD
888
+ [Unreleased]: https://github.com/bdombro/bun-argsbarg/compare/v6.1.10...HEAD
889
+ [6.1.10]: https://github.com/bdombro/bun-argsbarg/releases/tag/v6.1.10
883
890
  [6.1.9]: https://github.com/bdombro/bun-argsbarg/releases/tag/v6.1.9
884
891
  [6.1.8]: https://github.com/bdombro/bun-argsbarg/releases/tag/v6.1.8
885
892
  [6.1.7]: https://github.com/bdombro/bun-argsbarg/releases/tag/v6.1.7
package/README.md CHANGED
@@ -5,32 +5,48 @@ Logo
5
5
  [npm version](https://www.npmjs.com/package/argsbarg)
6
6
  [Bun](https://bun.sh)
7
7
 
8
- Build beautiful, well-behaved CLI+MCP+HTTP apps with Bun — **no third-party runtime dependencies**.
8
+ Build beautiful, well-behaved, production-grade CLIs, HTTP REST services, MCP Servers for Bun from a single, unified schema. All with only 2 modest dependencies.
9
9
 
10
- Why another CLI parser?
10
+ Why ArgsBarg?
11
11
 
12
- *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.
12
+ *Schema-first & Auto-validated* — Define your entire command structure, options, description, and inputs once. ArgsBarg compiles this into type-safe option accessors, command-line routing, and validation schemas, keeping your code and interfaces perfectly aligned.
13
13
 
14
- *AI Friendly* — Generate and install rich skills, mcp server, docs based on the schema.
14
+ *Automated Schemagen & Docgen* — Maintain single-source truth by decorating standard TypeScript types (`/** @sg */ interface...`) to automatically compile them into runtime validation schemas (`argsbarg schemagen`). Easily export standard-compliant API documentation, full CLI reference markdown, OpenAPI 3.1 definitions, and agent skill sheets directly from your code (`docs --save` command) using introspection.
15
15
 
16
- *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.
16
+ *Production REST Server* — Instantly expose your commands as HTTP REST endpoints (`POST /v1/some-command`) with built-in Kubernetes-compliant `/health/liveness` and `/health/readiness` probes, ECS structured JSON logging to `stderr`, and auto-generated OpenAPI 3.1 specs with an interactive Swagger UI.
17
17
 
18
- *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).
18
+ *First-Class Homebrew Distribution* — Exposes robust native support for packaging and distributing compiled binaries and shell completions cleanly via a standard tap-from-repo Homebrew model. Includes built-in completion script generators (`completion bash`/`zsh`/`fish`) consumed by Homebrew's standard `generate_completions_from_executable` command out of the box, ensuring friction-free installations and updates for your developers.
19
+
20
+ *High-Performance & Light Footprint* — Optimized specifically for Bun. Executes TypeScript and TSX source files directly with no transpile or bundling steps required, leveraging `Bun.serve` for rapid startup and low memory usage. Ships with only two production dependencies (`@cfworker/json-schema` and `ts-json-schema-generator`).
19
21
 
20
- *Bun-optimized* — built from the ground up for Bun and TypeScript, leveraging Bun’s performance and modern JavaScript features without any extra dependencies.
22
+ *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.
23
+
24
+ *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).
21
25
 
22
26
  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)!
23
27
 
24
28
  Halps! -->
25
29
  help-preview.png
30
+ [help-preview.png](docs/help-preview.png)
31
+
26
32
 
27
33
  Sub-level Halps! -->
28
34
  help-l2-preview.png
35
+ [help-l2-preview.png](docs/help-l2-preview.png)
29
36
 
30
37
  Shell completions! -->
31
38
  completions-preview.png
39
+ [completions-preview.png](docs/completions-preview.png)
40
+
41
+ Production-grade HTTP Server! -->
42
+ ```sh
43
+ $ myapp http
44
+ {"@timestamp":"2026-07-29T10:23:59.094Z","message":"HTTP API listening on http://127.0.0.1:13000",...}
45
+ {"@timestamp":"2026-07-29T10:23:59.194Z","message":"GET /health/liveness","ecs.version":"8.11.0",...}
46
+ {"@timestamp":"2026-07-29T10:23:59.195Z","message":"server stopping","ecs.version":"8.11.0",...}
47
+ ```
32
48
 
33
- ## Usage
49
+ ## Basic Usage
34
50
 
35
51
  ```typescript
36
52
  import { Cli, type CliProgram, CliOptionKind } from "argsbarg";
@@ -85,83 +101,123 @@ Everything you need for a first-class CLI:
85
101
  - **Rich help**: rounded UTF-8 boxes, tables, terminal width detection (`process.stdout.columns`), colors when stdout/stderr is a TTY
86
102
  - **TypeScript-native**: Typed option accessors (`ctx.typedOpt<T>`) and `async/await` handler support.
87
103
 
104
+ ## Getting Started
88
105
 
106
+ You can either quickly bootstrap a complete, feature-rich project skeleton using our CLI creator or manually integrate ArgsBarg into an existing codebase.
89
107
 
90
- ## Built-ins
108
+ ### Option A: Bootstrap a New Project (Recommended)
91
109
 
92
- Every app gets:
110
+ ArgsBarg provides an interactive project generator to scaffold a new repository fully equipped with TypeScript, Biome, automated schemagen/docgen, standard testing, and Homebrew integration rules:
93
111
 
94
- - `-h` / `--help` at any routing depth (scoped help).
95
- - `completion bash` **/** `completion zsh` **/** `completion fish` — print shell completion scripts to stdout (injected by `Cli.run()`).
96
- - `version` — print `CliProgram.version` (`myapp version`).
97
- - `mcp` — when `mcpServer.enabled` is `true`, run as an MCP stdio server (`myapp mcp`).
98
- - `http` — when `httpServer.enabled` is `true`, run as an HTTP tool server (`myapp http`).
99
- - `docs` — print bundled markdown topics, schema JSON, CLI markdown, and generated skill content (`myapp docs cli`, `myapp docs cli-schema`, `myapp docs skill`, …). Enabled by default; opt out with `docs: { enabled: false }`. See [docs/bundled-docs.md](docs/bundled-docs.md).
100
- - `configure` — manage agent skills, MCP config, and app config (`myapp configure --sync --yes` after Homebrew install). See [docs/configure.md](docs/configure.md).
112
+ ```bash
113
+ # Interactive setup (prompts for naming and git configurations)
114
+ bunx argsbarg create my-app
101
115
 
102
- Do not declare a top-level command named `completion`, `version`, or `configure` — they are reserved.
103
- When `mcpServer.enabled` is `true`, do not declare a top-level command named `mcp` — it is reserved for the MCP built-in.
104
- When `httpServer.enabled` is `true`, do not declare a top-level command named `http` — it is reserved for the HTTP built-in.
105
- When docs is enabled (default), do not declare a top-level command named `docs` — it is reserved for the docs built-in. Opt out with `docs: { enabled: false }` if needed.
116
+ # Non-interactive / Headless setup
117
+ bunx argsbarg create my-app \
118
+ --key my-cli --release-repo org/my-cli --yes
119
+ ```
106
120
 
107
- ### MCP (AI agents)
121
+ Edit `scripts/create-identity.ts` in the new repository to set your description. The `create` command copies the full-featured template, runs `bun install`, bootstraps a git repository (if standalone), and runs initial validation tests.
108
122
 
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 cli-schema`). Handlers can read `ctx.invocation`; use `cli.invoke(argv)` for headless testing.
123
+ #### What the bootstrapped template includes:
110
124
 
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).
125
+ | Area | Files / wiring |
126
+ | --------------------- | ---------------------------------------------------------------------------------------- |
127
+ | All built-ins | `completion`, `version`, `configure`, `docs`, `mcp`, `http`, `configure get`/`set` |
128
+ | `@sg` schemagen | `/** @sg */` on types in `src/**/*.ts` → `{TypeName}Schema` in `__generated__/` |
129
+ | `outputSchema` | `src/commands/status/types.ts` → `StatusJsonOutputSchema` from `__generated__/` |
130
+ | Schemagen | `just schemagen` → `argsbarg schemagen` (justfile exports `node_modules/.bin` on `PATH`) |
131
+ | Command layout | `src/commands/<name>/command.ts`; registration in `src/program.ts` |
132
+ | MCP doc topics | `docs.topics` auto-exposed as `<key>://docs/<topic>` resources when docs + MCP enabled |
133
+ | Package import | `from "argsbarg"` (not relative to argsbarg `src/`) |
134
+ | Homebrew distribution | `scripts/formula-shared.ts`, `scripts/dev-formula.ts`, `Formula/`, `justfile` |
135
+ | Dev tooling | Biome (`just format` / `just lint`), TypeScript, colocated tests |
136
+ | Cursor rules | `.cursor/rules/cli-program.mdc`, `.cursor/rules/code.mdc` |
112
137
 
113
- ### HTTP tool server
138
+ *Tip: Verify an existing tree or template setup with `bunx argsbarg create --check .`*
114
139
 
115
- Opt in on the program root with `httpServer: { enabled: true }`, then run `myapp http` for an HTTP REST server (default `http://127.0.0.1:3000`). Nested CLI paths map to REST routes at the server root by default (e.g. `/workspaces`); set `httpServer.pathPrefix: "/api"` to prefix all user routes. Discover routes via `GET /openapi.json`.
140
+ ### Option B: Manual Installation (For Existing Projects)
116
141
 
117
- See **[docs/http-server.md](docs/http-server.md)** for endpoints, curl examples, and response shapes.
142
+ To manually integrate ArgsBarg into your existing Bun application: `bun add argsbarg`.
118
143
 
119
- ### Configure CLI
120
144
 
121
- Ship via **Homebrew** (tap-from-repo). The formula installs the binary and shell completions; `post_install` runs agent artifact refresh. Private taps require `gh auth login` — see [docs/distribution-homebrew.md](docs/distribution-homebrew.md#end-user-install).
145
+ ## Built-in Commands
122
146
 
123
- ```bash
124
- brew install gh
125
- gh auth login
126
- brew tap <org>/<repo> git@github.com:<org>/<repo>.git
127
- brew install <tap>/myapp
128
- myapp configure # interactive per-target setup; opt-in app config wizard
129
- ```
147
+ ArgsBarg automatically integrates several core features into your application. These are divided into stable core capabilities and optional experimental integrations:
148
+
149
+ ### Core Capabilities (Stable)
150
+
151
+ - `-h` / `--help` — Highly-formatted, terminal-width scoped help at any routing depth.
152
+ - `version` — Print the program's version (e.g., `myapp version`).
153
+ - `http` — Launch the high-performance HTTP REST server (injected when `httpServer.enabled` is `true`).
154
+ - `completion bash` / `zsh` / `fish` — Generate shell completion scripts to stdout for deployment and packaging.
155
+ - `docs` — Print bundled markdown topics, schema JSON, or CLI reference markdown (`myapp docs cli`, `myapp docs cli-schema`, etc.). Enabled by default; see [docs/bundled-docs.md](docs/bundled-docs.md).
156
+ - `configure get` / `set` — Query and update application-level configurations non-interactively (active when `program.appConfig` contains configuration schema entries).
157
+
158
+ ### Experimental Integrations (Opt-in)
130
159
 
131
- 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`.
160
+ - `mcp` — Run as a Model Context Protocol stdio-based agent server (injected when `mcpServer.enabled` is `true`). See [docs/mcp.md](docs/mcp.md).
161
+ - `configure` (`--sync` / `--status` / `--remove-all`) — Interactive environment setup and developer agent credentials sync (enabled by default; opt out with `configure: { enabled: false }`). See [docs/configure.md](docs/configure.md).
132
162
 
133
- ### Shell completions
163
+ Do not declare top-level commands named `completion`, `version`, or `docs` as they are reserved by default. If their respective features are enabled, `http`, `mcp`, and `configure` are also reserved.
134
164
 
135
- Homebrew installs completion scripts during `brew install` via `generate_completions_from_executable`. The CLI still exposes generation for formula authors:
165
+ ## HTTP REST Server
166
+
167
+ By opting in with `httpServer: { enabled: true }` on your program root, running your app with the `http` subcommand launches a high-performance HTTP REST server powered natively by `Bun.serve`. This is ideal for sidecars, microservices, and micro-container deployments (such as in Kubernetes).
168
+
169
+ Nested command paths map directly to standard REST paths (e.g., `v1 invoices render` maps to `POST /v1/invoices/render`).
170
+
171
+ ```typescript
172
+ const cli = {
173
+ key: "myapp",
174
+ version: "1.0.0",
175
+ description: "My service.",
176
+ httpServer: { enabled: true, port: 3000 },
177
+ commands: [/* ... */],
178
+ } satisfies CliProgram;
179
+ ```
136
180
 
137
181
  ```bash
138
- myapp completion bash
139
- myapp completion zsh
140
- myapp completion fish
182
+ myapp http --port 3000
141
183
  ```
142
184
 
143
- Users configure their shell per [Homebrew Shell Completion](https://docs.brew.sh/Shell-Completion).
144
185
 
145
- ## Quick Start
186
+
187
+ ### Key HTTP Features:
188
+
189
+ - **Built-in Health Checks** — Automatic `/health/liveness` (responds 200 when online) and `/health/readiness` (responds 200 when online and config validation passes) probes out of the box, compliant with container orchestrators.
190
+ - **OpenAPI 3.1 Spec & Swagger UI** — Serves standard `/openapi.json` and a `/swagger` interactive API browser generated directly from your command schema and JSDoc metadata.
191
+ - **Pre-Handler Schema Validation** — Incoming request payloads are validated against the compile-time JSON Schema (`inputSchema`) on leaf commands before your handler ever runs.
192
+ - **ECS Structured Logging** — Access and error logs are automatically structured as Elastic Common Schema (ECS) JSON objects and written to `stderr` (e.g., for Datadog or ELK collection).
193
+ - **W3C Distributed Tracing** — Automatically parses, propagates, and echoes `traceparent` headers for distributed tracing pipelines.
194
+
195
+ See **[docs/http-server.md](docs/http-server.md)** for details on endpoints and response shapes, and **[docs/logging.md](docs/logging.md)** for log configurations.
196
+
197
+ ## Distribution & Packaging (Homebrew)
198
+
199
+ ArgsBarg is built to distribute the compiled binary and shell completions cleanly through Homebrew via a standard **tap-from-repo** model.
200
+
201
+ ### Installation & Post-Install Setup:
146
202
 
147
203
  ```bash
148
- bun add argsbarg
204
+ brew tap <org>/<repo> git@github.com:<org>/<repo>.git
205
+ brew install <tap>/myapp
149
206
  ```
150
207
 
208
+ During installation, Homebrew registers the built-in generated shell completions automatically via `generate_completions_from_executable` (see [docs/distribution-homebrew.md](docs/distribution-homebrew.md)).
151
209
 
210
+ ### Shell Completions:
152
211
 
153
- ### Cursor / AI agents
154
-
155
- 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):
212
+ Completion scripts can also be output directly at any time for manual setups or formula auditing:
156
213
 
157
214
  ```bash
158
- mkdir -p .cursor/rules
159
- mkdir -p .cursor/rules
160
- bun scripts/merge-cli-program-rule.ts . \
161
- node_modules/argsbarg/examples/full-example/.cursor/rules/cli-program.mdc
215
+ myapp completion bash
216
+ myapp completion zsh
217
+ myapp completion fish
162
218
  ```
163
219
 
164
- 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)**.
220
+
165
221
 
166
222
  ## How it works
167
223
 
@@ -230,7 +286,7 @@ Check the `examples/` directory for full working scripts:
230
286
  | --------------------- | ------------------------ | ------------------------------------------------------------------------------------------------- |
231
287
  | `ArgsBargMinimal` | `examples/minimal.ts` | String + presence flags, `MissingOrUnknown` fallback. |
232
288
  | `ArgsBargNested` | `examples/nested.ts` | Nested command tree, positional tails, async handlers. |
233
- | `ArgsBargFormats` | `examples/formats.ts` | `CliValueFormat`, `default`, `ctx.inputs`. |
289
+ | `ArgsBargFormats` | `examples/formats.ts` | `CliValueFormat`, `default`, `ctx.inputs`. |
234
290
  | `ArgsBargFullExample` | `examples/full-example/` | **Copy template:** all builtins, schemagen, Homebrew justfile, `outputSchema`, `from "argsbarg"`. |
235
291
 
236
292
 
@@ -266,21 +322,21 @@ To refresh Cursor rules in an existing consumer: `bun scripts/merge-cli-program-
266
322
  ### What the full-example template includes
267
323
 
268
324
 
269
- | Area | Files / wiring |
270
- | --------------------- | -------------------------------------------------------------------------------------- |
271
- | All builtins | `completion`, `version`, `configure`, `docs`, `mcp`, `http`, `configure get`/`set` |
272
- | `@sg` schemagen | `/** @sg */` on types in `src/**/*.ts` → `{TypeName}Schema` in `__generated__/` |
273
- | `outputSchema` | `src/commands/status/types.ts` → `StatusJsonOutputSchema` from `__generated__/` |
325
+ | Area | Files / wiring |
326
+ | --------------------- | ---------------------------------------------------------------------------------------- |
327
+ | All builtins | `completion`, `version`, `configure`, `docs`, `mcp`, `http`, `configure get`/`set` |
328
+ | `@sg` schemagen | `/** @sg */` on types in `src/**/*.ts` → `{TypeName}Schema` in `__generated__/` |
329
+ | `outputSchema` | `src/commands/status/types.ts` → `StatusJsonOutputSchema` from `__generated__/` |
274
330
  | Schemagen | `just schemagen` → `argsbarg schemagen` (justfile exports `node_modules/.bin` on `PATH`) |
275
- | Command layout | `src/commands/<name>/command.ts`; registration in `src/program.ts` |
276
- | MCP doc topics | `docs.topics` auto-exposed as `<key>://docs/<topic>` resources when docs + MCP enabled |
277
- | Package import | `from "argsbarg"` (not relative to argsbarg `src/`) |
278
- | Homebrew distribution | `scripts/formula-shared.ts`, `scripts/dev-formula.ts`, `Formula/`, `justfile` |
279
- | Dev tooling | Biome (`just format` / `just lint`), TypeScript, colocated tests |
280
- | Cursor rules | `.cursor/rules/cli-program.mdc`, `.cursor/rules/code.mdc` |
331
+ | Command layout | `src/commands/<name>/command.ts`; registration in `src/program.ts` |
332
+ | MCP doc topics | `docs.topics` auto-exposed as `<key>://docs/<topic>` resources when docs + MCP enabled |
333
+ | Package import | `from "argsbarg"` (not relative to argsbarg `src/`) |
334
+ | Homebrew distribution | `scripts/formula-shared.ts`, `scripts/dev-formula.ts`, `Formula/`, `justfile` |
335
+ | Dev tooling | Biome (`just format` / `just lint`), TypeScript, colocated tests |
336
+ | Cursor rules | `.cursor/rules/cli-program.mdc`, `.cursor/rules/code.mdc` |
281
337
 
282
338
 
283
- When changing builtins or the template, run `just check-full-example` from the argsbarg repo root.
339
+ When changing builtins or the template, run `just example-full-check` from the argsbarg repo root.
284
340
 
285
341
  ```bash
286
342
  export PATH="$PATH:$(pwd)/examples"
@@ -301,6 +357,42 @@ just run status --json
301
357
 
302
358
 
303
359
 
360
+ ## [Experimental] AI Agent & Copilot Integrations
361
+
362
+ ArgsBarg includes optional experimental features designed to make your CLI and services easily discoverable and executable by modern developer AI agents (such as Cursor, Claude Code, and standard MCP clients). These are entirely opt-in and do not affect the footprint, performance, or stability of the core CLI and HTTP layers.
363
+
364
+ ### 1. Model Context Protocol (MCP) Server
365
+
366
+ Opt in by setting `mcpServer: { enabled: true }` on your program root. Running `myapp mcp` starts a JSON-RPC 2.0 stdio server.
367
+
368
+ - **Automatic Tool Exposure** — Every leaf command in your CLI tree becomes an executable MCP tool with inputs automatically generated from your CLI options.
369
+ - **Documentation Resources** — Your CLI structure, JSON schemas, and bundled `docs.topics` are automatically exposed to agents as resources (e.g., `<key>://schema`).
370
+ - **Context-Aware Invocations** — Handlers can read `ctx.invocation` to distinguish between direct CLI, HTTP requests, or headless MCP calls.
371
+
372
+ See **[docs/mcp.md](docs/mcp.md)** for configuration, env bootstrapping, custom resources, Cursor/Claude setup, and protocol details.
373
+
374
+ ### 2. IDE Copilot Rules (Cursor / Claude Code)
375
+
376
+ ArgsBarg ships authoring docs under `node_modules/argsbarg/docs/`. Because AI agents do not automatically read inside `node_modules/`, you can copy a thin custom rule into your project:
377
+
378
+ ```bash
379
+ mkdir -p .cursor/rules
380
+ bun scripts/merge-cli-program-rule.ts . \
381
+ node_modules/argsbarg/examples/full-example/.cursor/rules/cli-program.mdc
382
+ ```
383
+
384
+ This acts as a "tripwire" that instructs AI agents in your workspace to read ArgsBarg's framework documentation before modifying your command definitions or schemas. See the **Cursor rule** section in [docs/cli-program.md](docs/cli-program.md).
385
+
386
+ ### 3. Generated Skills & Workspace Configuration
387
+
388
+ Running `myapp configure` launches an interactive setup wizard that can automatically write compact `SKILL.md` index files and full-reference markdown files (`reference.md`) directly into your global IDE directories (e.g., `~/.cursor/skills/` or `~/.claude/skills/`).
389
+
390
+ See **[docs/configure.md](docs/configure.md)** and **[docs/ai-skills.md](docs/ai-skills.md)** for developer setup and automated Homebrew pipeline integration.
391
+
392
+ ---
393
+
394
+
395
+
304
396
  ## Public API overview
305
397
 
306
398
  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.
@@ -311,8 +403,8 @@ The package root (`argsbarg` / `src/index.ts`) exports the types and runtime you
311
403
  | `CliProgram`, `CliOption`, `CliPositional`, `CliHandler` | Schema and handler types. |
312
404
  | `CliOptionKind`, `CliValueFormat`, `CliFallbackMode` | Option kinds, value formats (`duration`, `comma-list`, `date`, `date-time`), and root fallback behavior. |
313
405
  | `CliSchemaValidationError` | Thrown when the static command tree violates schema rules. |
314
- | `CliContext` | Handler context (`ctx.hasFlag`, `ctx.stringOpt`, `ctx.durationOpt`, `ctx.inputs`, `ctx.invocation`, …). |
315
- | `CliLeafInputs` | Record type returned by `ctx.inputs` — coerced option/positional values keyed by schema name. |
406
+ | `CliContext` | Handler context (`ctx.hasFlag`, `ctx.stringOpt`, `ctx.durationOpt`, `ctx.inputs`, `ctx.invocation`, …). |
407
+ | `CliLeafInputs` | Record type returned by `ctx.inputs` — coerced option/positional values keyed by schema name. |
316
408
  | `Cli` | Runtime: validate + freeze program, `run()`, `invoke()`, `serveMcp()`, `appConfig` getter, `exportCommandSchema()`, `exportAppConfigSchema()`. |
317
409
  | `CliInvokeResult`, `CliInvokeKind` | Result types from `cli.invoke()`. |
318
410
  | `CliAppConfig`, `CliAppConfigEntry` | App config block on the program root (`entries` metadata overlay + optional `jsonSchema`). |
package/docs/decisions.md CHANGED
@@ -1,59 +1,96 @@
1
- # Decisions
1
+ # Architecture Decision Records (ADRs)
2
2
 
3
- This doc tracks big architectural decisions so that we can avoid re-hashing the same decisions over and over.
3
+ This document records the key architectural decisions made during the design and implementation of ArgsBarg.
4
4
 
5
- ## HTTP REST vs flat `/tools/:name`
5
+ ---
6
6
 
7
- Decision: **nested `/api/...` REST** (7.0)
7
+ ## ADR 1: Exclusively Support Bun as the JavaScript/TypeScript Runtime
8
+
9
+ ### Status
10
+
11
+ Accepted
8
12
 
9
13
  ### Context
10
14
 
11
- - v6 exposed tools as `POST /tools/:flat-name` with hyphen-joined paths
12
- - Nested resources (e.g. `workspaces/{id}`) and verb-specific methods need a route model aligned with the CLI tree
15
+ We evaluated whether to build ArgsBarg as a dual-runtime library supporting both Node.js and Bun, or to target Bun exclusively.
16
+
17
+ Supporting Node.js requires maintaining complex build steps (transpilation, bundlers, CommonJS vs ESM dual-packaging, polyfills for HTTP serving) and limits the features we can offer to both the library and its consumers.
18
+
19
+ ### Decision
20
+
21
+ Exclusively support Bun as the sole runtime for ArgsBarg and its consumer applications.
22
+
23
+ ### Consequences
24
+
25
+ - **Pros:**
26
+ - **Zero-Build, Source-First Architecture:** Because Bun executes TypeScript and TSX directly from source, consumers can run their source code directly in production without any transpile or bundling steps (no Babel, Webpack, `ts-node`, or `tsx` required).
27
+ - **High-Performance Native HTTP (**`Bun.serve`**):** ArgsBarg's HTTP REST server is built directly on top of Bun's native, ultra-fast HTTP stack, offering millisecond-range startup times and massive throughput out of the box with zero boilerplate.
28
+ - **Native File and Text Imports:** ArgsBarg leverages Bun's native import attributes (e.g., `import readmeText from "./README.md" with { type: "text" }`) to bundle documentation and schemas at compile-time without reading the filesystem at runtime or requiring custom bundler plugins.
29
+ - **Unified, Lightweight Toolchain:** Both the framework and consumers benefit from Bun's native, ultra-fast package manager, built-in test runner (`bun test`), and zero-config TypeScript support, keeping the project's footprint and developer friction incredibly low.
30
+ - **Cons (What We Lose):**
31
+ - **Loss of Node-Only Enterprise Tooling:** We lose out-of-the-box integration with legacy enterprise APMs (Application Performance Monitoring like Datadog, New Relic) and security/compliance scanners that are strictly compiled for Node.js runtimes or depend on Node's internal V8 debugging APIs.
32
+ - **Serverless Platform Friction:** Standard serverless platforms (e.g., AWS Lambda, Google Cloud Functions) have optimized native runtimes for Node.js, whereas running Bun on these platforms requires deploying custom layers or heavier Docker containers.
33
+ - **Reduced Addressable Library Adoption:** By locking out standard Node.js environments, we lose a significant portion of the mainstream Node.js developer base who cannot adopt Bun due to rigid corporate policies, legacy infrastructure, or strict compliance guidelines.
34
+ - **100% Node API Compatibility Guarantee:** While Bun's Node compatibility layer is exceptionally high, we lose the 100% absolute guarantee that legacy CommonJS packages or complex native C++ addons (N-API) will run flawlessly without minor polyfill adjustments.
35
+ - **No Node.js Execution Path:** Applications cannot run on standard Node.js without a separate bundling/transpilation layer, making ArgsBarg a Bun-exclusive framework.
36
+
37
+ ---
38
+
39
+
40
+
41
+ ## ADR 2: Schema-Driven Contracts via JSON Schema (vs Zod)
13
42
 
14
- ### Rationale
15
43
 
16
- 1. Command tree already encodes hierarchy — REST paths mirror `http.segment ?? key` plus `:param` routers
17
- 2. Verb leaves (`get`, `post`, …) map to HTTP methods without duplicating path segments
18
- 3. OpenAPI paths match real URLs clients call; query/body binding matches MCP flat args
19
- 4. Hard break on `/tools/*` is acceptable pre-7.0-ship
20
44
 
21
- ## Validation: JSON-SCHEMA vs Zod, etc
45
+ ### Status
22
46
 
23
- Decision: JSON-SCHEMA
47
+ Accepted
24
48
 
25
49
  ### Context
26
- - JSON-SCHEMA is an open standard to capture a schema in json
27
- - Zod is the leading Typescript schema management library
28
- - Others are similar or less good than Zod
29
50
 
30
- ### Rational
31
- Zod may actually cause more complexity and little/no gain for consumers.
51
+ We evaluated schema management and runtime validation libraries—specifically comparing the TypeScript-first library **Zod** against the industry-standard **JSON Schema** specification—for input and configuration contracts.
32
52
 
33
- Yes Zod implements some features we do custom for JSON-SCHEMA, but is opinionated, less flexible, and would actually explode complexity in some situations. Zod could be a win for consumers if they require substantial, complex validation -- but then that may not convert well to json-schema anyways and json-schema generation is a big win.
53
+ ### Decision
34
54
 
35
- 1. Argsbarg does a lot of schema patching/manipulation to create different schemas per target (cli-schema.json, MCP contract, openapi.json). This would be harder with Zod
36
- 2. Consumers can use Zod by converting to JSON Schema (`zod-to-json-schema`, `z.toJSONSchema()`) and passing the result to `inputSchema` / `appConfig.jsonSchema`. Argsbarg resolves the validator draft from each schema’s `$schema` (Draft-07 default; 2019-09 / 2020-12 when set).
37
- 3. For uses like API pass-through, proxy, dynamic schemas, Zod may actually explode complexity for consumers.
38
- 4. Our TS->json-schema approach is actually easier and better in many cases
39
- - Just write plain typescript, done.
40
- - Better intellisense -- substantially less abstraction/inference, much better control
55
+ Adopt JSON Schema (using `@cfworker/json-schema` and `ts-json-schema-generator`) as the core validation format.
41
56
 
42
- ## Structured logging (ECS Logging)
57
+ ### Consequences
43
58
 
44
- Decision: **ECS Logging–compatible NDJSON to stderr** (default), with optional `enrich` / `serialize` hooks
59
+ - **Pros:**
60
+ - **Dynamic Manipulation:** Allows ArgsBarg to dynamically slice, patch, and transform schemas at runtime for different targets (CLI parser, MCP tools, OpenAPI JSON, and app configuration). This is far more complex to do with Zod.
61
+ - **Tooling Parity:** Integrates cleanly with a "write TypeScript, compile to schema" developer workflow.
62
+ - **Better IntelliSense:** Users write plain TypeScript interface definitions rather than chained Zod schemas, resulting in cleaner code and zero-abstraction IntelliSense.
63
+ - **Interop:** Consumers who prefer Zod can still use it and convert their schemas via `zod-to-json-schema` before passing them to ArgsBarg.
64
+ - **Cons:**
65
+ - Fewer expressive, runtime-only custom validation features (like refinements and transformations) built into the framework core.
66
+
67
+ ---
68
+
69
+
70
+
71
+ ## ADR 3: Structured Logging (ECS-Compatible JSON)
72
+
73
+
74
+
75
+ ### Status
76
+
77
+ Accepted (v6.1.9)
45
78
 
46
79
  ### Context
47
80
 
48
- - HTTP/MCP servers need access logs, error logs, and trace correlation in production log pipelines
49
- - Consumers may need custom fields (team labels, vendor-specific shapes) without baking proprietary formats into argsbarg core
50
- - OpenTelemetry log export is out of scope for the framework runtime (no third-party observability SDK dependency)
81
+ HTTP and MCP servers require standard, trace-correlated, and easily digestible access and error logging for production pipelines (such as Datadog, Elasticsearch, and GCP logs). We wanted to deliver first-class, standard-compliant logs out of the box without introducing heavy third-party observability libraries or proprietary schemas.
82
+
83
+ ### Decision
84
+
85
+ Emit server access and error logs to `stderr` formatted as Elastic Common Schema (ECS)-compatible NDJSON by default, with optional `program.log.enrich` and `program.log.serialize` hooks.
86
+
87
+ ### Consequences
51
88
 
52
- ### Rationale
89
+ - **Pros:**
90
+ - **Industry Standard:** ECS-compatible fields (`ecs.version`, `log.level`, etc.) play perfectly with all standard log collectors (ELK, Fluent Bit, Datadog).
91
+ - **Twelve-Factor Native:** Writing structured JSON to `stderr` keeps `stdout` clean for CLI command payloads and output redirects.
92
+ - **Distributed Tracing:** Standard W3C `traceparent` headers are automatically parsed and propagated without proprietary metadata layouts.
93
+ - **Zero Heavy Dependencies:** Avoids bundling heavy OpenTelemetry SDKs or other binary telemetry clients in the core open-source library.
94
+ - **Cons:**
95
+ - Requires minor log collector or format mapper adjustments if the deployment environment is strictly standardized on a non-ECS log layout.
53
96
 
54
- 1. **ECS Logging** is an open standard (NDJSON, `ecs.version`, canonical field names) — works with Elasticsearch, Datadog, GCP log agents, etc.
55
- 2. **stderr + JSONL** keeps stdout free for CLI output and matches twelve-factor log collection
56
- 3. **W3C Trace Context** (`traceparent`) enables cross-service correlation without vendor-specific field layouts
57
- 4. **`program.log.enrich`** — additive hook for consumer-specific fields; cannot override the ECS baseline
58
- 5. **`program.log.serialize`** — escape hatch for full custom lines in consumer repos (argsbarg does not endorse that output as ECS)
59
- 6. **No Tyson / OTel SDK in core** — proprietary or heavy observability stacks belong in consumer config or infra (Fluent Bit remapping), not in the open-source framework
@@ -70,7 +70,7 @@ Exclude `examples/full-example/node_modules/` from the npm tarball via [`.npmign
70
70
  [`examples/full-example/`](../examples/full-example/) must enable every builtin (`capabilities.test.ts`). After builtin or schemagen doc changes:
71
71
 
72
72
  ```bash
73
- just full-example-schemagen
73
+ just example-full-schemagen
74
74
  just test
75
75
  ```
76
76
 
@@ -1,159 +1,172 @@
1
- # Shipping via Homebrew (tap-from-repo)
1
+ # Homebrew Distribution & Release Guide (Tap-from-Repo)
2
2
 
3
- Argsbarg apps distribute the **binary and shell completions** through Homebrew, and **agent artifacts** (skills, MCP config) through `configure --sync`.
3
+ ArgsBarg provides native, first-class support for packaging, releasing, and distributing command-line binaries and shell autocomplete configurations through Homebrew via a standard **tap-from-repo** model. This is designed to serve as a secure, standard-compliant mechanism for internal enterprise distribution.
4
4
 
5
- ## Distribution model
5
+ ---
6
6
 
7
- | Layer | Mechanism |
8
- | --- | --- |
9
- | Binary + completions | Formula `install` block |
10
- | Skills + MCP | Formula `post_install` → `{key} configure --sync --yes` |
11
- | App config file | Bootstrapped as `{}` on `post_install` via `--sync` (`~/.local/lib/<key>/config.json`) |
12
- | App config values | User opt-in: `{key} configure` (interactive wizard when `program.appConfig` has entries) |
13
- | App config cleanup | Formula `uninstall` → `{key} configure --remove-all --yes` |
7
+ ## 1. Enterprise Distribution Model
14
8
 
15
- **Only tap-from-repo** — in-repo `Formula/` or GitHub tap. Not Homebrew core.
9
+ ArgsBarg maps the lifecycle of your application directly to standard Homebrew hooks, separating binary installation from user-interactive environment setup.
16
10
 
17
- ### End-user install
11
+ | Layer | Mechanism | Role in Lifecycle |
12
+ | --- | --- | --- |
13
+ | **Binary & Autocompletions** | Formula `install` block | Installs compiled binary and registers native shell autocompletions. |
14
+ | **Telemetry & Agent Synclinks** | Formula `post_install` | Automatically runs `{key} configure --sync --yes` to bootstrap configuration files and sync developer tools. |
15
+ | **Application Configuration** | User-facing `{key} configure` | Runs an interactive TTY setup wizard (only when `program.appConfig` defines required parameters). |
16
+ | **Clean Uninstall** | Formula `uninstall` | Automatically runs `{key} configure --remove-all --yes` to clean up local configurations and symlinks. |
18
17
 
19
- For **private or internal GitHub taps**, authenticate with GitHub CLI before `brew install` or `brew upgrade` (release formulae download via the GitHub API; Homebrew discovers credentials from `gh auth login`).
18
+ *Note: This architecture explicitly separates non-interactive installation (safe for automation/CI) from interactive configuration (which requires a TTY).*
20
19
 
21
- ```bash
22
- brew install gh # skip if already installed
23
- gh auth login # skip if already authenticated
24
- ```
20
+ ---
25
21
 
26
- Then:
22
+ ## 2. Distribution Strategies: Public vs. Private Taps
27
23
 
28
- ```bash
29
- brew tap <org>/<repo> git@github.com:<org>/<repo>.git
30
- brew install <tap>/{key}
31
- {key} configure # when app config is required
32
- ```
33
-
34
- Upgrade:
35
-
36
- ```bash
37
- brew upgrade {key}
38
- ```
24
+ ArgsBarg supports both open-source public formulas and secure private enterprise distribution. You can configure your repository structure depending on your project type.
39
25
 
40
- Local dev installs (`just install-local`) use a `file://` staging URL and do not need GitHub authentication.
26
+ ### Strategy A: Public Open-Source Taps (Default)
41
27
 
42
- ### Developer install
28
+ For open-source projects, Homebrew requires zero authentication. Users can tap your public repository and install your application with standard commands out of the box:
43
29
 
44
30
  ```bash
45
- just build
46
- just install-local # or `just install` (alias)
47
- just reinstall-local # fast binary swap (`install -m 755` into Cellar; run install-local first)
48
- just uninstall # undo formula + agent artifacts (app config removed by formula uninstall)
49
- ```
31
+ # Tap the public repository
32
+ brew tap <org>/<repo>
50
33
 
51
- Dev and release use the **same formula file** (`Formula/{key}.rb`). `just install-local` runs:
52
-
53
- ```bash
54
- bun scripts/dev-formula.ts install # back up release formula, write file:// dev formula
55
- brew install --formula <tap>/{key} # install from the dev formula
56
- bun scripts/dev-formula.ts reset # restore release formula
34
+ # Install the application
35
+ brew install <tap>/{key}
57
36
  ```
58
37
 
59
- If `brew install` fails, run `bun scripts/dev-formula.ts reset` manually to restore the release formula.
60
-
61
- ### Developer uninstall
38
+ The generated Homebrew formula points directly to your public GitHub release asset URL, allowing anyone to install and receive automatic updates securely.
62
39
 
63
- | Recipe | Removes |
64
- | --- | --- |
65
- | `just uninstall` | Formula `{key}` + tap symlink + skills/MCP + app config via formula `uninstall` |
66
- | `just uninstall-config` | App config file only (`configure --remove-config --yes`) |
67
- | `just uninstall-release` | Release formula from `{tap}` (keeps tap; agent artifacts via formula `uninstall`) |
68
- | `just uninstall-release-tap` | Release formula + `brew untap {tap}` (agent artifacts via formula `uninstall`) |
69
- | `just test-release` | Install release formula and run formula test |
40
+ ### Strategy B: Private & Proprietary Corporate Taps
70
41
 
71
- End users: `brew uninstall <tap>/<key>`. The formula `uninstall` hook runs `configure --remove-all --yes` (skills, MCP, and app config).
42
+ For proprietary, inner-source, or internal company tools, security is paramount. ArgsBarg provides a built-in strategy to distribute packages securely from private GitHub repositories without exposing sensitive personal tokens or raw download links in your formula code.
72
43
 
73
- ## Formula pattern
44
+ #### 1. End-User Authentication:
45
+ Users authenticate locally using the standard GitHub CLI (`gh`), which Homebrew natively integrates with to retrieve download credentials:
74
46
 
75
- ```ruby
76
- def install
77
- bin.install "{key}"
78
- generate_completions_from_executable(bin/"{key}", "completion", base_name: "{key}")
79
- end
47
+ ```bash
48
+ # 1. Install and authenticate with GitHub CLI (if not already done)
49
+ brew install gh
50
+ gh auth login
80
51
 
81
- def post_install
82
- system bin/"{key}", "configure", "--sync", "--yes"
83
- end
52
+ # 2. Tap and install your private corporate repository
53
+ brew tap <org>/<repo> git@github.com:<org>/<repo>.git
54
+ brew install <tap>/{key}
84
55
 
85
- def uninstall
86
- system bin/"{key}", "configure", "--remove-all", "--yes"
87
- end
56
+ # 3. Perform interactive configuration (such as API tokens) if required
57
+ {key} configure
88
58
  ```
89
59
 
90
- Release formulae generated by `scripts/formula-shared.ts` embed a `GitHubPrivateReleaseDownloadStrategy` that resolves the release asset through the GitHub API at download time and authenticates with `GitHub::API.credentials` (Homebrew discovers `gh auth login` automatically):
60
+ #### 2. The Private Release Strategy:
61
+ Release formulae generated by ArgsBarg's scripts utilize a custom **`GitHubPrivateReleaseDownloadStrategy`**. This strategy executes the secure asset download through standard GitHub API requests, leveraging the user's local `gh` login credentials securely under the hood:
91
62
 
92
63
  ```ruby
93
64
  url "https://github.com/<org>/<repo>/releases/download/vX.Y.Z/{key}",
94
65
  using: GitHubPrivateReleaseDownloadStrategy
95
66
  ```
96
67
 
97
- Local dev formulae (`just install-local`) use a plain `file://` URL and do not need the token.
68
+ ---
98
69
 
99
- Completions require users to configure their shell per [Homebrew Shell Completion](https://docs.brew.sh/Shell-Completion).
70
+ ## 3. Standardized Formula Pattern
100
71
 
101
- **Why the wizard is separate from `post_install`:** prompting for secrets requires a TTY. `post_install` only bootstraps an empty `config.json` and refreshes skills/MCP. Apps with `appConfig` print a one-line configure hint in formula `caveats` for the interactive wizard.
72
+ ArgsBarg standardizes your Homebrew formulas. A typical generated formula (`Formula/{key}.rb`) is incredibly clean:
102
73
 
103
- **MCP hosts:** when `mcpServer.enabled` is true, add a caveats line that chat apps (Cursor, Claude Desktop, etc.) must be **restarted** after `brew install` / `brew upgrade` — `post_install` updates MCP config on disk, but hosts typically load it only at startup.
74
+ ```ruby
75
+ class Myapp < Formula
76
+ desc "My application description"
77
+ homepage "https://github.com/org/myapp"
78
+ url "https://github.com/org/myapp/releases/download/v1.0.0/myapp.zip"
79
+ sha256 "a1b2c3d4e5f6g7h8..."
80
+ version "1.0.0"
81
+
82
+ def install
83
+ bin.install "myapp"
84
+ # Auto-generates shell completions for bash, zsh, and fish directly from the executable
85
+ generate_completions_from_executable(bin/"myapp", "completion", base_name: "myapp")
86
+ end
87
+
88
+ def post_install
89
+ # Non-interactive bootstrap of config files and developer links
90
+ system bin/"myapp", "configure", "--sync", "--yes"
91
+ end
92
+
93
+ def uninstall
94
+ # Graceful clean up of local files on uninstall
95
+ system bin/"myapp", "configure", "--remove-all", "--yes"
96
+ end
97
+
98
+ def caveats
99
+ <<~EOS
100
+ Interactive configuration is required. Please run:
101
+ myapp configure
102
+ EOS
103
+ end
104
+ end
105
+ ```
104
106
 
105
- ## Bootstrap CLI (`argsbarg create`)
107
+ ---
106
108
 
107
- Copy the shipped `examples/full-example` template into a new directory with identity substitutions, then run install, schemagen, tests, and git init (when appropriate):
109
+ ## 4. Developer Iteration Workflow
108
110
 
109
- ```bash
110
- bunx argsbarg create my-cli \
111
- --key my-cli --class-name MyCli --tap org/my-cli \
112
- --homepage https://github.com/org/my-cli --release-repo org/my-cli \
113
- --yes
114
- ```
111
+ ArgsBarg provides an optimized workflow for developers to build, package, and test their Homebrew installer locally before pushing releases.
115
112
 
116
- On a TTY, omit flags to use the interactive wizard. Verify an existing tree:
113
+ ### Local Staging Commands:
117
114
 
118
115
  ```bash
119
- bunx argsbarg create --check .
116
+ # 1. Build the local release binary
117
+ just build
118
+
119
+ # 2. Stage and install the formula locally (bypasses GitHub, uses file://)
120
+ just install-local
121
+
122
+ # 3. Swap updated binaries quickly during tight edit cycles
123
+ just reinstall-local
124
+
125
+ # 4. Uninstall the binary and gracefully clean up all configurations
126
+ just uninstall
120
127
  ```
121
128
 
122
- Template source: [`examples/full-example/`](../examples/full-example/) in the argsbarg package (also under `node_modules/argsbarg/examples/full-example` after `bun add argsbarg`).
129
+ ### Under the Hood:
123
130
 
124
- **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`.
131
+ To ensure you test the exact formula that will be shipped to production, `just install-local` runs:
125
132
 
126
- ## Release workflow
133
+ 1. `bun scripts/dev-formula.ts install` — Safely backs up your production formula and writes a temporary local dev formula using a `file://` URL pointing to your build directory.
134
+ 2. `brew install --formula <tap>/{key}` — Installs the package locally using Homebrew.
135
+ 3. `bun scripts/dev-formula.ts reset` — Automatically restores your production formula on disk.
127
136
 
128
- 1. `just build` → `dist/{key}`
129
- 2. `scripts/release.ts` → zips `dist/{key}` to `dist/{key}.zip`, writes `Formula/{key}.rb` (GitHub zip URL + archive sha256), commits, tags, uploads `dist/{key}.zip` to GitHub Releases
130
- 3. Users `brew upgrade {key}` from the tap
137
+ ---
131
138
 
132
- Requires the `zip` CLI on the release machine. `just install-local` still stages the bare binary via `file://` (no zip).
139
+ ## 5. Automated Release Pipeline
133
140
 
134
- ### Stale release cleanup
141
+ ArgsBarg automates the release cycle. A production-ready release is performed using a single command:
135
142
 
136
143
  ```bash
137
- just release --purge # delete all GitHub releases except the newest (confirm on TTY)
138
- just release --purge --yes # skip confirmation
139
- just release --purge --dry-run # list tags that would be deleted
140
- just release patch --purge # release, then purge older releases
144
+ # Performs build, zips binary, updates Formula with new SHA-256, tags git, pushes, and uploads release asset
145
+ just release patch # or minor | major
141
146
  ```
142
147
 
143
- `--purge` removes GitHub Release records and attached assets only — git tags remain on the remote. Old formula pins that reference deleted release URLs will fail until users upgrade.
148
+ ### Release Pipeline Steps:
144
149
 
145
- ## Removed (breaking)
150
+ 1. **Build**: Compiles the binary to `dist/{key}`.
151
+ 2. **Archive**: Packages the binary into a compressed `dist/{key}.zip`.
152
+ 3. **Integrity Check**: Calculates the cryptographically secure SHA-256 hash of the zip file.
153
+ 4. **Formula Sync**: Updates the version number and `sha256` parameter in `Formula/{key}.rb`.
154
+ 5. **Tag & Push**: Commits changes, tags the repository with the new version, pushes to GitHub, and publishes the compiled zip to GitHub Releases.
146
155
 
147
- - Self-install to `~/.local/bin`
148
- - Top-level `install` and `uninstall` commands (use `configure`)
149
- - `install --update` / `updateGetLatest`
150
- - Homebrew completion installer via CLI (Homebrew owns completions)
151
- - Bare-argv install bootstrap
152
- - Auto configure wizard after sync
153
- - Separate `{key}-local` formula and `{key}/dev` tap
156
+ ### Older Release Retention & Cleanup:
157
+
158
+ To keep your storage footprint clean, the pipeline supports purging stale historical release assets while preserving the git tags:
159
+
160
+ ```bash
161
+ just release --purge # Interactive tag purge of older release records
162
+ just release --purge --yes # Silent automated purge (useful in CI/CD)
163
+ just release --purge --dry-run # Preview list of tag deletions
164
+ ```
154
165
 
155
- ## Config path
166
+ ---
156
167
 
157
- Default: `~/.local/lib/<sanitized-key>/config.json`
168
+ ## 6. Directory Defaults
158
169
 
159
- Export helpers: `resolveAppConfigPath`, `displayAppConfigPath` from `argsbarg`.
170
+ Applications packaged via ArgsBarg adhere to standard system directories:
171
+ * **Resolved Configuration Path**: `~/.local/lib/<sanitized-key>/config.json`
172
+ * **Auto-Exports**: Developers can import `resolveAppConfigPath` or `displayAppConfigPath` directly from `argsbarg` to display helpful directories in help screens.
@@ -1,3 +1,5 @@
1
+ <!-- Generated by full-example docs http --save; do not edit. -->
2
+
1
3
  # HTTP API (full-example)
2
4
 
3
5
  full-example exposes user commands over HTTP REST routes derived from the CLI tree.
@@ -10,7 +12,7 @@ full-example http
10
12
 
11
13
  Listens on **http://127.0.0.1:3000** by default (`httpServer.host` / `httpServer.port`).
12
14
 
13
- Bind is localhost-only in v0 — use a reverse proxy for remote access.
15
+ Bind is localhost-only by default — use a reverse proxy for remote access.
14
16
 
15
17
  ## Endpoints
16
18
 
@@ -34,6 +34,22 @@ migrate DB="./workspaces.db":
34
34
  # Run schemagen, typecheck, and format
35
35
  check: schemagen format typecheck
36
36
 
37
+ # demo the HTTP API
38
+ demo-http:
39
+ #!/usr/bin/env bash
40
+ set -euo pipefail
41
+ bun ./src/index.ts http --port 13000 &
42
+ trap 'kill $! 2>/dev/null || true' EXIT
43
+ until curl -sf http://127.0.0.1:13000/health/liveness >/dev/null; do sleep 0.1; done
44
+
45
+ # demo a CLI command
46
+ demo-cli:
47
+ @just run {{cli_key}} status
48
+
49
+ # demo a CLI command
50
+ demo-help:
51
+ @just run {{cli_key}} --help
52
+
37
53
  # Run the CLI from source with optional args; restarts on file changes
38
54
  dev *ARGS:
39
55
  bun --watch ./src/index.ts {{ARGS}}
@@ -53,6 +69,10 @@ alias fmt := format
53
69
  format:
54
70
  bun run biome check ./src ./scripts --write --unsafe
55
71
 
72
+ # Run the HTTP server
73
+ http:
74
+ @just run http
75
+
56
76
  # Alias for backward compatibility
57
77
  install: install-local
58
78
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "argsbarg",
3
- "version": "6.1.9",
3
+ "version": "6.1.10",
4
4
  "main": "./src/index.ts",
5
5
  "module": "./src/index.ts",
6
6
  "dependencies": {
@@ -45,7 +45,7 @@ export function generateHttpGuide(root: CliProgram): string {
45
45
  "",
46
46
  `Listens on **${baseUrl}** by default (\`httpServer.host\` / \`httpServer.port\`).`,
47
47
  "",
48
- "Bind is localhost-only in v0 — use a reverse proxy for remote access.",
48
+ "Bind is localhost-only by default — use a reverse proxy for remote access.",
49
49
  "",
50
50
  "## Endpoints",
51
51
  "",
package/src/docs/save.ts CHANGED
@@ -8,7 +8,7 @@ import { docsTopicContent } from "./resolve.ts";
8
8
  export const DOCS_SAVE_DIR = "docs";
9
9
 
10
10
  /** Builtin docs topics generated by argsbarg (not consumer `docs.topics`). */
11
- export const DOCS_GENERATED_SAVE_TOPICS = ["mcp", "cli", "skill"] as const;
11
+ export const DOCS_GENERATED_SAVE_TOPICS = ["mcp", "cli", "skill", "http"] as const;
12
12
 
13
13
  /** Whether `--save` should prepend a generated-file hint (argsbarg writers only). */
14
14
  export function docsTopicIsGeneratedByArgsbarg(topic: string): boolean {