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.
- package/CHANGELOG.md +17 -1
- package/README.md +187 -93
- package/docs/README.md +3 -2
- package/docs/ai-skills.md +36 -23
- package/docs/cli-program.md +12 -11
- package/docs/config-schema.md +3 -3
- package/docs/configure.md +12 -16
- package/docs/decisions.md +74 -37
- package/docs/developing.md +6 -6
- package/docs/distribution-homebrew.md +117 -104
- package/docs/mcp.md +21 -57
- package/docs/output-schema.md +2 -2
- package/examples/formats.ts +5 -6
- package/examples/full-example/README.md +7 -69
- package/examples/full-example/docs/cli-schema.json +1 -1659
- package/examples/full-example/docs/cli.md +2 -1538
- package/examples/full-example/docs/http.md +3 -8
- package/examples/full-example/docs/mcp.md +23 -59
- package/examples/full-example/docs/openapi.json +2 -782
- package/examples/full-example/docs/skill.md +18 -14
- package/examples/full-example/justfile +22 -14
- package/examples/full-example/scripts/create-identity.ts +2 -1
- package/examples/full-example/src/commands/status/command.test.ts +2 -2
- package/examples/full-example/src/commands/status/command.ts +7 -6
- package/examples/full-example/src/program.ts +4 -10
- package/examples/full-example-json/Formula/.gitkeep +0 -0
- package/examples/full-example-json/Formula/full-example-json.rb +35 -0
- package/examples/full-example-json/README.md +27 -0
- package/examples/full-example-json/biome.json +22 -0
- package/examples/full-example-json/bun.lock +48 -0
- package/examples/full-example-json/docs/README.md +27 -0
- package/examples/full-example-json/docs/cli-schema.json +2145 -0
- package/examples/full-example-json/docs/cli.md +1990 -0
- package/examples/full-example-json/docs/http.md +92 -0
- package/examples/full-example-json/docs/mcp.md +116 -0
- package/examples/full-example-json/docs/openapi.json +1246 -0
- package/examples/full-example-json/docs/skill.md +57 -0
- package/examples/full-example-json/justfile +171 -0
- package/examples/full-example-json/package.json +22 -0
- package/examples/full-example-json/scripts/create-identity.ts +12 -0
- package/examples/full-example-json/scripts/dev-formula.ts +97 -0
- package/examples/full-example-json/scripts/formula-shared.test.ts +68 -0
- package/examples/full-example-json/scripts/formula-shared.ts +170 -0
- package/examples/full-example-json/scripts/print-identity.ts +28 -0
- package/examples/full-example-json/scripts/release.ts +212 -0
- package/examples/full-example-json/src/commands/echo/command.ts +26 -0
- package/examples/full-example-json/src/commands/status/command.test.ts +10 -0
- package/examples/full-example-json/src/commands/status/command.ts +28 -0
- package/examples/full-example-json/src/index.ts +10 -0
- package/examples/full-example-json/src/program.ts +33 -0
- package/examples/full-example-json/src/types/md.d.ts +4 -0
- package/examples/full-example-json/tsconfig.json +17 -0
- package/examples/minimal.ts +17 -17
- package/examples/nested.ts +10 -10
- package/examples/option-required.ts +13 -13
- package/examples/servers.ts +10 -10
- package/index.d.ts +17 -43
- package/package.json +1 -1
- package/src/cli-tool/create.test.ts +44 -68
- package/src/cli-tool/create.ts +81 -17
- package/src/cli-tool/full-example-capabilities.test.ts +33 -18
- package/src/cli-tool/post-create.ts +31 -17
- package/src/cli-tool/program.ts +16 -7
- package/src/cli-tool/prompt.ts +27 -0
- package/src/cli-tool/run-create.ts +19 -7
- package/src/cli-tool/schemagen/schemagen.test.ts +3 -3
- package/src/configure/artifacts/install-validate.test.ts +20 -33
- package/src/configure/artifacts/paths.ts +9 -53
- package/src/configure/artifacts/status.test.ts +13 -16
- package/src/configure/artifacts/status.ts +5 -22
- package/src/configure/artifacts/target-base.ts +6 -15
- package/src/configure/artifacts/target-effective.ts +16 -54
- package/src/configure/artifacts/target-mcp-json.ts +2 -5
- package/src/configure/artifacts/target-registry.ts +0 -7
- package/src/configure/artifacts/target-scope.ts +7 -17
- package/src/configure/artifacts/target-skill.ts +6 -15
- package/src/configure/artifacts/target-types.ts +6 -54
- package/src/configure/artifacts/targets/agents-mcp.ts +11 -0
- package/src/configure/artifacts/targets/configure.ts +1 -5
- package/src/configure/artifacts/targets/index.ts +4 -44
- package/src/configure/artifacts/targets/skill.ts +12 -0
- package/src/configure/artifacts/targets.test.ts +21 -59
- package/src/configure/configure.test.ts +35 -46
- package/src/configure/index.ts +19 -19
- package/src/configure/prompt.ts +2 -12
- package/src/core/parse.test.ts +21 -32
- package/src/core/types.ts +18 -44
- package/src/core/validate.ts +28 -45
- package/src/docs/docs.test.ts +4 -4
- package/src/docs/http-guide.ts +1 -1
- package/src/docs/mcp-guide.ts +41 -71
- package/src/docs/resolve.ts +1 -1
- package/src/docs/save.ts +1 -1
- package/src/exports/cli.ts +1 -1
- package/src/index.ts +1 -1
- package/src/skill/generate.ts +26 -45
- package/src/skill/install.ts +18 -38
- package/src/skill/naming.ts +3 -27
- package/src/test/integration/config.test.ts +3 -3
- package/src/test/integration/mcp.test.ts +4 -4
- package/{examples/mcp-test.ts → src/test/mcp-integration-fixture.ts} +20 -22
- package/src/configure/artifacts/target-mcp-cli.ts +0 -127
- package/src/configure/artifacts/targets/chatgpt-mcp.ts +0 -12
- package/src/configure/artifacts/targets/claude-code-mcp.ts +0 -15
- package/src/configure/artifacts/targets/claude-desktop-mcp.ts +0 -12
- package/src/configure/artifacts/targets/claude-skill.ts +0 -16
- package/src/configure/artifacts/targets/codex-mcp.ts +0 -25
- package/src/configure/artifacts/targets/codex-skill.ts +0 -14
- package/src/configure/artifacts/targets/cursor-mcp.ts +0 -15
- package/src/configure/artifacts/targets/cursor-skill.ts +0 -16
- package/src/configure/artifacts/targets/openclaw-mcp.ts +0 -25
- package/src/configure/artifacts/targets/openclaw-skill.ts +0 -17
- package/src/configure/artifacts/targets/opencode-mcp.ts +0 -96
- package/src/configure/artifacts/targets/opencode-skill.ts +0 -15
- /package/examples/{full-example → full-example-json}/src/commands/render-json/__generated__/RenderJsonInputSchema.json +0 -0
- /package/examples/{full-example → full-example-json}/src/commands/render-json/__generated__/index.ts +0 -0
- /package/examples/{full-example → full-example-json}/src/commands/render-json/command.test.ts +0 -0
- /package/examples/{full-example → full-example-json}/src/commands/render-json/command.ts +0 -0
- /package/examples/{full-example → full-example-json}/src/commands/render-json/types.ts +0 -0
- /package/examples/{full-example → full-example-json}/src/commands/status/__generated__/StatusJsonOutputSchema.json +0 -0
- /package/examples/{full-example → full-example-json}/src/commands/status/__generated__/index.ts +0 -0
- /package/examples/{full-example → full-example-json}/src/commands/status/types.ts +0 -0
- /package/examples/{full-example → full-example-json}/src/commands/workspaces/__generated__/WorkspaceNameInputSchema.json +0 -0
- /package/examples/{full-example → full-example-json}/src/commands/workspaces/__generated__/index.ts +0 -0
- /package/examples/{full-example → full-example-json}/src/commands/workspaces/command.test.ts +0 -0
- /package/examples/{full-example → full-example-json}/src/commands/workspaces/command.ts +0 -0
- /package/examples/{full-example → full-example-json}/src/commands/workspaces/types.ts +0 -0
- /package/examples/{full-example → full-example-json}/src/db/index.test.ts +0 -0
- /package/examples/{full-example → full-example-json}/src/db/index.ts +0 -0
- /package/examples/{full-example → full-example-json}/src/db/migrate.test.ts +0 -0
- /package/examples/{full-example → full-example-json}/src/db/migrate.ts +0 -0
- /package/examples/{full-example → full-example-json}/src/db/migrations/001_workspaces.sql +0 -0
- /package/examples/{full-example → full-example-json}/src/db/tables/workspaces.ts +0 -0
- /package/examples/{full-example → full-example-json}/src/types/argsbarg.d.ts +0 -0
package/docs/cli-program.md
CHANGED
|
@@ -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
|
-
|
|
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
|
-
|
|
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
|
|
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 `~/.
|
|
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
|
|
package/docs/config-schema.md
CHANGED
|
@@ -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/) | **
|
|
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
|
-
|
|
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
|
-
|
|
|
72
|
-
|
|
|
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
|
-
-
|
|
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)
|
|
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
|
-
|
|
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`**
|
|
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
|
-
|
|
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
|
-
|
|
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: `
|
|
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
|
-
#
|
|
1
|
+
# Architecture Decision Records (ADRs)
|
|
2
2
|
|
|
3
|
-
This
|
|
3
|
+
This document records the key architectural decisions made during the design and implementation of ArgsBarg.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
---
|
|
6
6
|
|
|
7
|
-
|
|
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
|
-
|
|
12
|
-
|
|
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
|
-
|
|
45
|
+
### Status
|
|
22
46
|
|
|
23
|
-
|
|
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
|
-
|
|
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
|
-
|
|
53
|
+
### Decision
|
|
34
54
|
|
|
35
|
-
|
|
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
|
-
|
|
57
|
+
### Consequences
|
|
43
58
|
|
|
44
|
-
|
|
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
|
-
|
|
49
|
-
|
|
50
|
-
|
|
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
|
-
|
|
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
|
package/docs/developing.md
CHANGED
|
@@ -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 `~/.
|
|
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
|
-
##
|
|
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-
|
|
73
|
+
just example-full-check
|
|
74
74
|
just test
|
|
75
75
|
```
|
|
76
76
|
|
|
@@ -1,159 +1,172 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Homebrew Distribution & Release Guide (Tap-from-Repo)
|
|
2
2
|
|
|
3
|
-
|
|
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
|
-
|
|
5
|
+
---
|
|
6
6
|
|
|
7
|
-
|
|
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
|
-
|
|
9
|
+
ArgsBarg maps the lifecycle of your application directly to standard Homebrew hooks, separating binary installation from user-interactive environment setup.
|
|
16
10
|
|
|
17
|
-
|
|
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
|
-
|
|
18
|
+
*Note: This architecture explicitly separates non-interactive installation (safe for automation/CI) from interactive configuration (which requires a TTY).*
|
|
20
19
|
|
|
21
|
-
|
|
22
|
-
brew install gh # skip if already installed
|
|
23
|
-
gh auth login # skip if already authenticated
|
|
24
|
-
```
|
|
20
|
+
---
|
|
25
21
|
|
|
26
|
-
|
|
22
|
+
## 2. Distribution Strategies: Public vs. Private Taps
|
|
27
23
|
|
|
28
|
-
|
|
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
|
-
|
|
26
|
+
### Strategy A: Public Open-Source Taps (Default)
|
|
41
27
|
|
|
42
|
-
|
|
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
|
-
|
|
46
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
```
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
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
|
-
|
|
82
|
-
|
|
83
|
-
|
|
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
|
-
|
|
86
|
-
|
|
87
|
-
end
|
|
56
|
+
# 3. Perform interactive configuration (such as API tokens) if required
|
|
57
|
+
{key} configure
|
|
88
58
|
```
|
|
89
59
|
|
|
90
|
-
|
|
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
|
-
|
|
68
|
+
---
|
|
98
69
|
|
|
99
|
-
|
|
70
|
+
## 3. Standardized Formula Pattern
|
|
100
71
|
|
|
101
|
-
|
|
72
|
+
ArgsBarg standardizes your Homebrew formulas. A typical generated formula (`Formula/{key}.rb`) is incredibly clean:
|
|
102
73
|
|
|
103
|
-
|
|
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
|
-
|
|
107
|
+
---
|
|
106
108
|
|
|
107
|
-
|
|
109
|
+
## 4. Developer Iteration Workflow
|
|
108
110
|
|
|
109
|
-
|
|
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
|
-
|
|
113
|
+
### Local Staging Commands:
|
|
117
114
|
|
|
118
115
|
```bash
|
|
119
|
-
|
|
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
|
-
|
|
129
|
+
### Under the Hood:
|
|
123
130
|
|
|
124
|
-
|
|
131
|
+
To ensure you test the exact formula that will be shipped to production, `just install-local` runs:
|
|
125
132
|
|
|
126
|
-
|
|
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
|
-
|
|
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
|
-
|
|
139
|
+
## 5. Automated Release Pipeline
|
|
133
140
|
|
|
134
|
-
|
|
141
|
+
ArgsBarg automates the release cycle. A production-ready release is performed using a single command:
|
|
135
142
|
|
|
136
143
|
```bash
|
|
137
|
-
|
|
138
|
-
just release
|
|
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
|
-
|
|
148
|
+
### Release Pipeline Steps:
|
|
144
149
|
|
|
145
|
-
|
|
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
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
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
|
-
|
|
166
|
+
---
|
|
156
167
|
|
|
157
|
-
|
|
168
|
+
## 6. Directory Defaults
|
|
158
169
|
|
|
159
|
-
|
|
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.
|