argsbarg 6.1.9 → 6.2.0

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 (134) hide show
  1. package/CHANGELOG.md +17 -1
  2. package/README.md +187 -93
  3. package/docs/README.md +3 -2
  4. package/docs/ai-skills.md +36 -23
  5. package/docs/cli-program.md +12 -11
  6. package/docs/config-schema.md +3 -3
  7. package/docs/configure.md +12 -16
  8. package/docs/decisions.md +74 -37
  9. package/docs/developing.md +6 -6
  10. package/docs/distribution-homebrew.md +117 -104
  11. package/docs/mcp.md +21 -57
  12. package/docs/output-schema.md +2 -2
  13. package/examples/formats.ts +5 -6
  14. package/examples/full-example/README.md +7 -69
  15. package/examples/full-example/docs/cli-schema.json +1 -1659
  16. package/examples/full-example/docs/cli.md +2 -1538
  17. package/examples/full-example/docs/http.md +3 -8
  18. package/examples/full-example/docs/mcp.md +23 -59
  19. package/examples/full-example/docs/openapi.json +2 -782
  20. package/examples/full-example/docs/skill.md +18 -14
  21. package/examples/full-example/justfile +22 -14
  22. package/examples/full-example/scripts/create-identity.ts +2 -1
  23. package/examples/full-example/src/commands/status/command.test.ts +2 -2
  24. package/examples/full-example/src/commands/status/command.ts +7 -6
  25. package/examples/full-example/src/program.ts +4 -10
  26. package/examples/full-example-json/Formula/.gitkeep +0 -0
  27. package/examples/full-example-json/Formula/full-example-json.rb +35 -0
  28. package/examples/full-example-json/README.md +27 -0
  29. package/examples/full-example-json/biome.json +22 -0
  30. package/examples/full-example-json/bun.lock +48 -0
  31. package/examples/full-example-json/docs/README.md +27 -0
  32. package/examples/full-example-json/docs/cli-schema.json +2145 -0
  33. package/examples/full-example-json/docs/cli.md +1990 -0
  34. package/examples/full-example-json/docs/http.md +92 -0
  35. package/examples/full-example-json/docs/mcp.md +116 -0
  36. package/examples/full-example-json/docs/openapi.json +1246 -0
  37. package/examples/full-example-json/docs/skill.md +57 -0
  38. package/examples/full-example-json/justfile +171 -0
  39. package/examples/full-example-json/package.json +22 -0
  40. package/examples/full-example-json/scripts/create-identity.ts +12 -0
  41. package/examples/full-example-json/scripts/dev-formula.ts +97 -0
  42. package/examples/full-example-json/scripts/formula-shared.test.ts +68 -0
  43. package/examples/full-example-json/scripts/formula-shared.ts +170 -0
  44. package/examples/full-example-json/scripts/print-identity.ts +28 -0
  45. package/examples/full-example-json/scripts/release.ts +212 -0
  46. package/examples/full-example-json/src/commands/echo/command.ts +26 -0
  47. package/examples/full-example-json/src/commands/status/command.test.ts +10 -0
  48. package/examples/full-example-json/src/commands/status/command.ts +28 -0
  49. package/examples/full-example-json/src/index.ts +10 -0
  50. package/examples/full-example-json/src/program.ts +33 -0
  51. package/examples/full-example-json/src/types/md.d.ts +4 -0
  52. package/examples/full-example-json/tsconfig.json +17 -0
  53. package/examples/minimal.ts +17 -17
  54. package/examples/nested.ts +10 -10
  55. package/examples/option-required.ts +13 -13
  56. package/examples/servers.ts +10 -10
  57. package/index.d.ts +17 -43
  58. package/package.json +1 -1
  59. package/src/cli-tool/create.test.ts +44 -68
  60. package/src/cli-tool/create.ts +81 -17
  61. package/src/cli-tool/full-example-capabilities.test.ts +33 -18
  62. package/src/cli-tool/post-create.ts +31 -17
  63. package/src/cli-tool/program.ts +16 -7
  64. package/src/cli-tool/prompt.ts +27 -0
  65. package/src/cli-tool/run-create.ts +19 -7
  66. package/src/cli-tool/schemagen/schemagen.test.ts +3 -3
  67. package/src/configure/artifacts/install-validate.test.ts +20 -33
  68. package/src/configure/artifacts/paths.ts +9 -53
  69. package/src/configure/artifacts/status.test.ts +13 -16
  70. package/src/configure/artifacts/status.ts +5 -22
  71. package/src/configure/artifacts/target-base.ts +6 -15
  72. package/src/configure/artifacts/target-effective.ts +16 -54
  73. package/src/configure/artifacts/target-mcp-json.ts +2 -5
  74. package/src/configure/artifacts/target-registry.ts +0 -7
  75. package/src/configure/artifacts/target-scope.ts +7 -17
  76. package/src/configure/artifacts/target-skill.ts +6 -15
  77. package/src/configure/artifacts/target-types.ts +6 -54
  78. package/src/configure/artifacts/targets/agents-mcp.ts +11 -0
  79. package/src/configure/artifacts/targets/configure.ts +1 -5
  80. package/src/configure/artifacts/targets/index.ts +4 -44
  81. package/src/configure/artifacts/targets/skill.ts +12 -0
  82. package/src/configure/artifacts/targets.test.ts +21 -59
  83. package/src/configure/configure.test.ts +35 -46
  84. package/src/configure/index.ts +19 -19
  85. package/src/configure/prompt.ts +2 -12
  86. package/src/core/parse.test.ts +21 -32
  87. package/src/core/types.ts +18 -44
  88. package/src/core/validate.ts +28 -45
  89. package/src/docs/docs.test.ts +4 -4
  90. package/src/docs/http-guide.ts +1 -1
  91. package/src/docs/mcp-guide.ts +41 -71
  92. package/src/docs/resolve.ts +1 -1
  93. package/src/docs/save.ts +1 -1
  94. package/src/exports/cli.ts +1 -1
  95. package/src/index.ts +1 -1
  96. package/src/skill/generate.ts +26 -45
  97. package/src/skill/install.ts +18 -38
  98. package/src/skill/naming.ts +3 -27
  99. package/src/test/integration/config.test.ts +3 -3
  100. package/src/test/integration/mcp.test.ts +4 -4
  101. package/{examples/mcp-test.ts → src/test/mcp-integration-fixture.ts} +20 -22
  102. package/src/configure/artifacts/target-mcp-cli.ts +0 -127
  103. package/src/configure/artifacts/targets/chatgpt-mcp.ts +0 -12
  104. package/src/configure/artifacts/targets/claude-code-mcp.ts +0 -15
  105. package/src/configure/artifacts/targets/claude-desktop-mcp.ts +0 -12
  106. package/src/configure/artifacts/targets/claude-skill.ts +0 -16
  107. package/src/configure/artifacts/targets/codex-mcp.ts +0 -25
  108. package/src/configure/artifacts/targets/codex-skill.ts +0 -14
  109. package/src/configure/artifacts/targets/cursor-mcp.ts +0 -15
  110. package/src/configure/artifacts/targets/cursor-skill.ts +0 -16
  111. package/src/configure/artifacts/targets/openclaw-mcp.ts +0 -25
  112. package/src/configure/artifacts/targets/openclaw-skill.ts +0 -17
  113. package/src/configure/artifacts/targets/opencode-mcp.ts +0 -96
  114. package/src/configure/artifacts/targets/opencode-skill.ts +0 -15
  115. /package/examples/{full-example → full-example-json}/src/commands/render-json/__generated__/RenderJsonInputSchema.json +0 -0
  116. /package/examples/{full-example → full-example-json}/src/commands/render-json/__generated__/index.ts +0 -0
  117. /package/examples/{full-example → full-example-json}/src/commands/render-json/command.test.ts +0 -0
  118. /package/examples/{full-example → full-example-json}/src/commands/render-json/command.ts +0 -0
  119. /package/examples/{full-example → full-example-json}/src/commands/render-json/types.ts +0 -0
  120. /package/examples/{full-example → full-example-json}/src/commands/status/__generated__/StatusJsonOutputSchema.json +0 -0
  121. /package/examples/{full-example → full-example-json}/src/commands/status/__generated__/index.ts +0 -0
  122. /package/examples/{full-example → full-example-json}/src/commands/status/types.ts +0 -0
  123. /package/examples/{full-example → full-example-json}/src/commands/workspaces/__generated__/WorkspaceNameInputSchema.json +0 -0
  124. /package/examples/{full-example → full-example-json}/src/commands/workspaces/__generated__/index.ts +0 -0
  125. /package/examples/{full-example → full-example-json}/src/commands/workspaces/command.test.ts +0 -0
  126. /package/examples/{full-example → full-example-json}/src/commands/workspaces/command.ts +0 -0
  127. /package/examples/{full-example → full-example-json}/src/commands/workspaces/types.ts +0 -0
  128. /package/examples/{full-example → full-example-json}/src/db/index.test.ts +0 -0
  129. /package/examples/{full-example → full-example-json}/src/db/index.ts +0 -0
  130. /package/examples/{full-example → full-example-json}/src/db/migrate.test.ts +0 -0
  131. /package/examples/{full-example → full-example-json}/src/db/migrate.ts +0 -0
  132. /package/examples/{full-example → full-example-json}/src/db/migrations/001_workspaces.sql +0 -0
  133. /package/examples/{full-example → full-example-json}/src/db/tables/workspaces.ts +0 -0
  134. /package/examples/{full-example → full-example-json}/src/types/argsbarg.d.ts +0 -0
@@ -8,10 +8,6 @@ ArgsBarg turns your schema into help, shell completions, MCP tools, and agent sk
8
8
 
9
9
  ```typescript
10
10
  const cli = {
11
- key: "myapp",
12
- version: "1.0.0",
13
- description: "One-line summary of what the CLI does.",
14
- mcpServer: { enabled: true },
15
11
  commands: [
16
12
  {
17
13
  key: "greet",
@@ -22,6 +18,10 @@ const cli = {
22
18
  handler: async (ctx) => { /* ... */ },
23
19
  },
24
20
  ],
21
+ description: "One-line summary of what the CLI does.",
22
+ key: "myapp",
23
+ mcpServer: { enabled: true },
24
+ version: "1.0.0",
25
25
  } satisfies CliProgram;
26
26
  ```
27
27
 
@@ -31,11 +31,11 @@ No `mcpTool` blocks required. Every leaf becomes an MCP tool; `inputSchema` come
31
31
 
32
32
  ```typescript
33
33
  const cli = {
34
- key: "myapp",
35
- version: "1.0.0",
34
+ commands: [/* ... */],
36
35
  description: "One-line summary of what the CLI does.",
37
36
  httpServer: { enabled: true }, // myapp api → http://127.0.0.1:3000
38
- commands: [/* ... */],
37
+ key: "myapp",
38
+ version: "1.0.0",
39
39
  } satisfies CliProgram;
40
40
  ```
41
41
 
@@ -90,7 +90,7 @@ export const reserveCommand = {
90
90
 
91
91
  Use a **parameterized factory** only when the schema truly depends on inputs (e.g. `createUpsertCommand(deps)` for tests or injected config). A `reserveCommand()` that returns a static literal adds indirection without benefit.
92
92
 
93
- **`satisfies CliProgram`** on the root (or **`satisfies CliLeaf`** / router type on extracted modules) preserves type-checking whether inline or not.
93
+ **`satisfies CliProgram`** on the root (or **`satisfies CliLeaf`** / router type on extracted modules) preserves type-checking whether inline or not. Keep **program-root fields in alphabetical order** (`appConfig`, `commands`, `description`, `docs`, `hooks`, `httpServer`, `key`, `mcpServer`, `readiness`, `skill`, `version`, …).
94
94
 
95
95
  ## Descriptions
96
96
 
@@ -541,8 +541,9 @@ await cli.run();
541
541
  - **Strict:** unknown keys rejected on load.
542
542
  - **CLI:** missing required config exits 1 before the leaf handler (TTY prompt when interactive). Built-in `docs` and `configure get`/`set` skip this exit.
543
543
  - **MCP:** server stays up; missing config returns `isError: true` at `tools/call`.
544
- - **Configure:** interactive `configure` runs the app config wizard; **`configure --sync`** refreshes agent artifacts.
545
- - **Agent integration:** `configure.agentIntegration` (`mcp` | `skill` | `both`) sets default sync targets; see [configure.md](configure.md#configuretargets).
544
+ - **Configure:** interactive `configure` runs the app config wizard; **`configure --sync`** refreshes agent artifacts to `~/.agents/` ([.agents protocol](https://dotagentsprotocol.com/)).
545
+ - **Agent skill:** `program.skill: { enabled: true }` installs to `~/.agents/skills/<key>/` on `configure --sync`; see [configure.md](configure.md) and [ai-skills.md](ai-skills.md).
546
+ - **MCP install:** `mcpServer: { enabled: true }` merges into `~/.agents/mcp.json` on `configure --sync`; manual Cursor/Claude setup in [mcp.md](mcp.md).
546
547
 
547
548
  See [config-schema.md](config-schema.md) for codegen, [configure.md](configure.md) (`configure.targets`), and [mcp.md](mcp.md).
548
549
 
@@ -583,7 +584,7 @@ If you maintain argsbarg from a sibling checkout, `just consumer-dev` / `just co
583
584
 
584
585
  3. **Optional:** a separate rule (e.g. `.cursor/argsbarg.mdc` or `AGENTS.md`) for broader package API notes.
585
586
 
586
- **Not this file:** `myapp configure` writes the **app** skill (`SKILL.md` under `~/.cursor/skills/`) from your command schema — how to *invoke* the CLI. The rule above is for *authoring* argsbarg schema.
587
+ - **Not this file:** `myapp configure --sync` writes the **app** skill (`SKILL.md` under `~/.agents/skills/<key>/`) from your command schema — how to *invoke* the CLI. The rule above is for *authoring* argsbarg schema.
587
588
 
588
589
  ## See also
589
590
 
@@ -224,9 +224,9 @@ Object/array/`$ref` properties require `--json` on `configure set` when comma-se
224
224
 
225
225
  | Example | Role |
226
226
  | --- | --- |
227
- | [`examples/full-example/`](../examples/full-example/) | **Copy template** — `@sg` schemagen, builtins; optional `program.appConfig` |
227
+ | [`examples/full-example-json/`](../examples/full-example-json/) | **Schema-first copy template** — `@sg` schemagen, builtins; optional `program.appConfig` |
228
228
 
229
229
  ```bash
230
- cd examples/full-example && just setup && just schemagen
231
- FULL_EXAMPLE_API_TOKEN=dev just run configure get apiToken --json
230
+ cd examples/full-example-json && just setup && just schemagen
231
+ FULL_EXAMPLE_JSON_API_TOKEN=dev just run configure get apiToken --json
232
232
  ```
package/docs/configure.md CHANGED
@@ -68,10 +68,8 @@ Non-interactive / CI: pass **`--yes`** (or **`--json`**, **`--sync`**, **`--remo
68
68
  | --- | --- | --- |
69
69
  | Binary | skipped (read-only) | Homebrew formula `bin.install` |
70
70
  | Shell completions | skipped | Homebrew `generate_completions_from_executable` |
71
- | Cursor skill | Y/n prompt | `~/.cursor/skills/<dir>/` when `~/.cursor` exists |
72
- | Claude skill | Y/n prompt | `~/.claude/skills/<dir>/` when `~/.claude` exists |
73
- | Codex / OpenCode / OpenClaw skills | Y/n prompt | Agent-specific dirs when available |
74
- | MCP config | Y/n prompt when `mcpServer.enabled` | Cursor, Claude Code/Desktop, OpenCode, Codex, OpenClaw, ChatGPT desktop |
71
+ | Agent skill | skipped (automatic) | `~/.agents/skills/<key>/` when `program.skill.enabled` |
72
+ | MCP config | skipped (automatic) | `~/.agents/mcp.json` when `mcpServer.enabled` ([.agents protocol](https://dotagentsprotocol.com/)) |
75
73
  | App config | auto-runs wizard | Interactive wizard may update `~/.local/lib/<key>/config.json` when values change; `--sync` bootstraps an empty file on install |
76
74
 
77
75
  ### Externally managed binary (Homebrew)
@@ -79,37 +77,35 @@ Non-interactive / CI: pass **`--yes`** (or **`--json`**, **`--sync`**, **`--remo
79
77
  When **`PATH`** resolves the program key to the **running executable** (e.g. after `brew install`):
80
78
 
81
79
  - **`configure --status`** shows `app: system (PATH)`
82
- - **`--sync`** refreshes skills and MCP; also creates `~/.local/lib/<key>/config.json` as `{}` when missing (all apps)
80
+ - **`configure --sync`** refreshes the agent skill (when `program.skill.enabled`) and merges MCP into `~/.agents/mcp.json` (when `mcpServer.enabled`); also creates `~/.local/lib/<key>/config.json` as `{}` when missing (all apps)
83
81
 
84
- MCP config uses the command name on **`PATH`**, not a Cellar path.
82
+ MCP config uses the command name on **`PATH`**, not a Cellar path. For Cursor, Claude Code, and Claude Desktop, copy the `mcpServers` entry manually — see [mcp.md](mcp.md) and `docs mcp`.
85
83
 
86
84
  ### Interactive default
87
85
 
88
- Bare **`configure`** (TTY required) walks enabled install targets in order. For each target:
86
+ Bare **`configure`** (TTY required) runs the app config wizard when `program.appConfig` has entries. Agent skills and MCP are **not** prompted — they install automatically via brew `post_install` / `--sync` when `program.skill.enabled` or `mcpServer.enabled` respectively.
89
87
 
90
- - **Not installed:** `[Y/n]` — default install; `n` skips.
91
- - **Installed:** `[y/N]` — default keep; `n` uninstalls.
92
- - **App config** (`program.appConfig` with entries): runs the config wizard automatically (no Y/n gate). Remove the config file with **`configure --remove-config --yes`**.
88
+ Remove the config file with **`configure --remove-config --yes`**.
93
89
 
94
- The **`app`** target (binary on PATH) is shown in `--status` only — never mutated by `configure`.
90
+ The **`app`** and **`skill`** / **`agentsMcp`** targets are shown in `--status` only — never mutated by interactive `configure` (use `--sync` / brew hooks).
95
91
 
96
92
  ### `configure.targets`
97
93
 
98
- Configure which artifacts participate in `--sync`:
94
+ Optional gates for app binary status and app-config wizard participation in `--sync`:
99
95
 
100
96
  ```typescript
97
+ skill: { enabled: true },
98
+ mcpServer: { enabled: true },
101
99
  configure: {
102
- agentIntegration: "mcp", // | "skill" | "both" — default from mcpServer.enabled
103
100
  targets: {
104
- chatgptMcp: false,
105
- cursorSkill: { includedInAll: true },
101
+ configure: { includedInAll: true }, // optional: app config wizard on --sync
106
102
  },
107
103
  },
108
104
  ```
109
105
 
110
106
  `ConfigureTargetSpec` is `boolean` or `{ enabled?: boolean; includedInAll?: boolean }`.
111
107
 
112
- Artifact keys: `chatgptMcp`, `claudeCodeMcp`, `claudeDesktopMcp`, `claudeSkill`, `codexMcp`, `codexSkill`, `configure`, `cursorMcp`, `cursorSkill`, `openclawMcp`, `openclawSkill`, `opencodeMcp`, `opencodeSkill`.
108
+ Artifact keys: `app`, `configure`. Legacy `configure.targets.*Mcp` keys are rejected — MCP installs to `~/.agents/mcp.json` when `mcpServer.enabled`.
113
109
 
114
110
  ## App config (`program.appConfig`)
115
111
 
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
@@ -38,7 +38,7 @@ Sibling consumer repos (machine-specific paths in the root `justfile` `consumer_
38
38
 
39
39
  `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.
40
40
 
41
- **Argsbarg authoring rules** — `scripts/merge-cli-program-rule.ts` and `scripts/merge-code-rule.ts` copy templates from `examples/full-example/.cursor/rules/` into each consumer, preserving any existing `**… conventions:**` footer block.
41
+ **Argsbarg authoring rules** — `scripts/merge-cli-program-rule.ts` and `scripts/merge-code-rule.ts` copy templates from `examples/full-example-json/.cursor/rules/` into each consumer, preserving any existing `**… conventions:**` footer block.
42
42
 
43
43
  **Recommended in each consumer:** replace template placeholders with `**<app> conventions:**` bullets. Commit those files; merges refresh the shared top, not your footer.
44
44
 
@@ -55,7 +55,7 @@ Breaking changes (no backward compat). See [CHANGELOG.md](../CHANGELOG.md) `[Unr
55
55
  7. **Cursor rules:** `just consumers-dev` merges `cli-program.mdc` + `code.mdc` (includes **Abstractions** needless-extraction rule).
56
56
  8. **Verify:** `just test` and `just docgen` in each consumer repo.
57
57
 
58
- **Consumer app skill** — `just install-local` in each consumer (part of `consumers-sync`) runs Homebrew dev install then `myapp configure --sync --yes`, which updates `~/.cursor/skills/<app>/` from that app’s schema — not the argsbarg framework rule.
58
+ **Consumer app skill** — `just install-local` in each consumer (part of `consumers-sync`) runs Homebrew dev install then `myapp configure --sync --yes`, which updates `~/.agents/skills/<app>/` when `program.skill.enabled` — not the argsbarg framework rule.
59
59
 
60
60
  ## npm package contents
61
61
 
@@ -63,14 +63,14 @@ Breaking changes (no backward compat). See [CHANGELOG.md](../CHANGELOG.md) `[Unr
63
63
 
64
64
  When adding docs or examples intended for consumers, ensure they live under whitelisted paths (`docs/`, `examples/`, `src/`, etc.).
65
65
 
66
- Exclude `examples/full-example/node_modules/` from the npm tarball via [`.npmignore`](../.npmignore).
66
+ Exclude `examples/full-example/node_modules/` and `examples/full-example-json/node_modules/` from the npm tarball via [`.npmignore`](../.npmignore).
67
67
 
68
- ## Full example
68
+ ## Copy templates
69
69
 
70
- [`examples/full-example/`](../examples/full-example/) must enable every builtin (`capabilities.test.ts`). After builtin or schemagen doc changes:
70
+ Both [`examples/full-example/`](../examples/full-example/) (CLI) and [`examples/full-example-json/`](../examples/full-example-json/) (schema-first) 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-check
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.