argsbarg 6.2.0 → 6.3.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 +26 -1
- package/README.md +10 -12
- package/docs/README.md +5 -5
- package/docs/ai-skills.md +9 -9
- package/docs/bundled-docs.md +3 -3
- package/docs/cli-program.md +11 -13
- package/docs/configure.md +37 -15
- package/docs/developing.md +11 -7
- package/docs/distribution-homebrew.md +2 -2
- package/docs/mcp.md +3 -3
- package/docs/output-schema.md +1 -1
- package/examples/full-example/.cursor/hooks/run-tests-on-stop.ts +56 -0
- package/examples/full-example/.cursor/hooks.json +12 -0
- package/examples/full-example/AGENTS.md +75 -0
- package/examples/full-example/CLAUDE.md +1 -0
- package/examples/full-example/Formula/full-example.rb +1 -1
- package/examples/full-example/docs/README.md +1 -1
- package/examples/full-example/docs/cli-schema.json +6 -6
- package/examples/full-example/docs/cli.md +6 -6
- package/examples/full-example/docs/mcp.md +2 -2
- package/examples/full-example/docs/skill.md +2 -2
- package/examples/full-example/justfile +12 -12
- package/examples/full-example/scripts/formula-shared.ts +1 -1
- package/examples/full-example-json/.cursor/hooks/run-tests-on-stop.ts +56 -0
- package/examples/full-example-json/.cursor/hooks.json +12 -0
- package/examples/full-example-json/AGENTS.md +86 -0
- package/examples/full-example-json/CLAUDE.md +1 -0
- package/examples/full-example-json/Formula/full-example-json.rb +1 -1
- package/examples/full-example-json/docs/README.md +1 -1
- package/examples/full-example-json/docs/cli-schema.json +27 -27
- package/examples/full-example-json/docs/cli.md +27 -27
- package/examples/full-example-json/docs/mcp.md +2 -2
- package/examples/full-example-json/docs/skill.md +2 -2
- package/examples/full-example-json/justfile +12 -12
- package/examples/full-example-json/scripts/formula-shared.ts +1 -1
- package/index.d.ts +20 -4
- package/package.json +1 -1
- package/src/builtins/builtins.test.ts +7 -7
- package/src/builtins/configure-copy.ts +2 -2
- package/src/builtins/configure.ts +4 -4
- package/src/configure/configure.test.ts +85 -12
- package/src/configure/index.ts +45 -13
- package/src/core/types.ts +21 -4
- package/src/docs/docs.test.ts +2 -2
- package/src/docs/mcp-guide.ts +2 -2
- package/src/index.ts +1 -0
- package/src/skill/generate.ts +2 -2
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
# full-example
|
|
2
|
+
|
|
3
|
+
## Tooling
|
|
4
|
+
|
|
5
|
+
- Bun only (`bun`, `bunx`, `bun test`). No Node/npm/pnpm.
|
|
6
|
+
|
|
7
|
+
## Documentation
|
|
8
|
+
|
|
9
|
+
- `README.md` — user-facing install/commands
|
|
10
|
+
- `docs/architecture.md` — maintainer internals (create if missing)
|
|
11
|
+
- Generated: `just docgen` → `docs/cli.md`, `docs/cli-schema.json`, `docs/skill.md`
|
|
12
|
+
|
|
13
|
+
<!-- argsbarg:managed -->
|
|
14
|
+
|
|
15
|
+
## Argsbarg schema
|
|
16
|
+
|
|
17
|
+
When adding or changing argsbarg schema, leaf handlers, or MCP exposure:
|
|
18
|
+
|
|
19
|
+
1. **Read** `node_modules/argsbarg/docs/cli-program.md` (required — authoritative guide).
|
|
20
|
+
2. MCP tools, varargs → `node_modules/argsbarg/docs/mcp.md`.
|
|
21
|
+
3. JSON stdout / `outputSchema` and `@sg` schemagen → `node_modules/argsbarg/docs/output-schema.md` and `examples/full-example-json/`.
|
|
22
|
+
4. App config / `program.appConfig` → `node_modules/argsbarg/docs/config-schema.md`.
|
|
23
|
+
5. `configure`, Homebrew distribution → `node_modules/argsbarg/docs/configure.md` and `distribution-homebrew.md`.
|
|
24
|
+
6. Bundled `docs` built-in → `node_modules/argsbarg/docs/bundled-docs.md`.
|
|
25
|
+
7. **Examples** (shipped under `node_modules/argsbarg/examples/`):
|
|
26
|
+
- **CLI copy template** (this repo) — builtins only, no schemagen
|
|
27
|
+
- **Schema-first copy template** — `@sg`, `inputSchema`/`outputSchema`, REST CRUD → `examples/full-example-json/`
|
|
28
|
+
|
|
29
|
+
**Hard rules** (details and examples are in the docs above — do not contradict them):
|
|
30
|
+
|
|
31
|
+
- Reserved root commands: `completion`, `configure`, `mcp`, `version`, `docs`.
|
|
32
|
+
- `satisfies CliProgram` / `CliLeaf`; action-oriented `description` on root, commands, options, and positionals.
|
|
33
|
+
- Omit `mcpTool` unless genuinely CLI-only (`enabled: false`) or an irreducible wire limit — fix schema and headless handlers first.
|
|
34
|
+
- Interactive leaves: one headless path for MCP, non-TTY CLI, and `--yes` / `--dry-run` / `--json` (`shouldRunHeadless*`, `requireYesInNonTty`); not raw `isTTY`.
|
|
35
|
+
- String options: `format` / `default` / `pattern` per `cli-program.md`.
|
|
36
|
+
- Varargs (`argMax: 0`): CLI space-separated; MCP JSON array only — no comma-splitting positionals.
|
|
37
|
+
|
|
38
|
+
## Code conventions
|
|
39
|
+
|
|
40
|
+
### JSDoc
|
|
41
|
+
|
|
42
|
+
Add doc comments for exported surfaces that are not obvious from the name alone. Skip comments on short test callbacks and pure re-export files.
|
|
43
|
+
|
|
44
|
+
### Names
|
|
45
|
+
|
|
46
|
+
Use names that describe the domain role, not generic placeholders like `data` or `handler`, except in very small scopes.
|
|
47
|
+
|
|
48
|
+
### Structure
|
|
49
|
+
|
|
50
|
+
After imports, put **exported** symbols first (alphabetical within each kind), then **module-private** helpers at the bottom. Use `~/…` only where you would otherwise use `../` (or deeper) to reach another module under `src/`. Same-directory (`./`) and child (`./foo/…`) imports stay relative. Use `.ts` extensions.
|
|
51
|
+
|
|
52
|
+
### Module boundaries
|
|
53
|
+
|
|
54
|
+
| Path | Owns | Must not |
|
|
55
|
+
| --- | --- | --- |
|
|
56
|
+
| `src/index.ts` | Thin entry: `new Cli(program).run()` | Inline leaf handlers, business logic |
|
|
57
|
+
| `src/types/` | Global type declarations (e.g. `md.d.ts`) | Runtime logic |
|
|
58
|
+
| `src/program.ts` | `CliProgram` assembly: `docs`, `commands: […]` | Inline leaf handlers, business logic |
|
|
59
|
+
| `src/commands/<name>/` | One user-facing command: `command.ts` | Shared helpers unrelated to the command |
|
|
60
|
+
| `scripts/` | Dev tooling (formula helpers) | Production command paths |
|
|
61
|
+
|
|
62
|
+
When adding commands: `src/commands/<name>/command.ts`; register in `program.ts` **alphabetically by command key**.
|
|
63
|
+
|
|
64
|
+
**Argsbarg schema:** see Argsbarg schema section above.
|
|
65
|
+
|
|
66
|
+
### Execution
|
|
67
|
+
|
|
68
|
+
- **CLI:** `bun ./src/index.ts …` or `just run …`
|
|
69
|
+
- **Tests:** `just test` (after `just check`)
|
|
70
|
+
|
|
71
|
+
<!-- /argsbarg:managed -->
|
|
72
|
+
|
|
73
|
+
**full-example conventions:**
|
|
74
|
+
|
|
75
|
+
Replace with app-specific bullets.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
@AGENTS.md
|
|
@@ -5,7 +5,7 @@ Reference template for argsbarg consumer docgen. Every builtin is enabled in `sr
|
|
|
5
5
|
| If you are… | Read |
|
|
6
6
|
| --- | --- |
|
|
7
7
|
| **Using the CLI** | [../README.md](../README.md) |
|
|
8
|
-
| **Authoring argsbarg schema** | `node_modules/argsbarg/docs/cli-program.md` — see
|
|
8
|
+
| **Authoring argsbarg schema** | `node_modules/argsbarg/docs/cli-program.md` — see [`AGENTS.md`](../AGENTS.md) |
|
|
9
9
|
| **HTTP API / curl** | [http.md](http.md) — generated; or run `full-example docs http` |
|
|
10
10
|
| **MCP tools** | [mcp.md](mcp.md) — generated; or run `full-example docs mcp` |
|
|
11
11
|
| **Full command tree (markdown)** | [cli.md](cli.md) — generated |
|
|
@@ -21,10 +21,10 @@
|
|
|
21
21
|
{
|
|
22
22
|
"key": "configure",
|
|
23
23
|
"description": "Set up agent skills and MCP config for this app (binary via Homebrew).",
|
|
24
|
-
"notes": "Set up agent artifacts after the binary is installed via Homebrew (see README for tap install).\n\nHomebrew post_install runs:\n full-example configure --
|
|
24
|
+
"notes": "Set up agent artifacts after the binary is installed via Homebrew (see README for tap install).\n\nHomebrew post_install runs:\n full-example configure --refresh --yes\n\nInteractive setup (per target):\n full-example configure\n\nUpgrade:\n brew upgrade full-example\n\nShell completions are installed by Homebrew during brew install.\nSee: https://docs.brew.sh/Shell-Completion\n\nSee what is installed:\n full-example configure --status\n\nUninstall:\n brew uninstall <tap>/full-example\n\nThe formula uninstall hook runs `configure --remove-all --yes` (skills, MCP, and app config).\n\nUse --dry to preview changes without writing files.\nUse --json for machine-readable output.",
|
|
25
25
|
"options": [
|
|
26
26
|
{
|
|
27
|
-
"name": "
|
|
27
|
+
"name": "refresh",
|
|
28
28
|
"description": "Refresh installed skills and MCP. Used by Homebrew post_install.",
|
|
29
29
|
"kind": "presence"
|
|
30
30
|
},
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
},
|
|
41
41
|
{
|
|
42
42
|
"name": "yes",
|
|
43
|
-
"description": "Skip confirmation (required for --
|
|
43
|
+
"description": "Skip confirmation (required for --refresh, --remove-all, --remove-config).",
|
|
44
44
|
"kind": "presence",
|
|
45
45
|
"shortName": "y"
|
|
46
46
|
},
|
|
@@ -261,10 +261,10 @@
|
|
|
261
261
|
{
|
|
262
262
|
"key": "configure",
|
|
263
263
|
"description": "Set up agent skills and MCP config for this app (binary via Homebrew).",
|
|
264
|
-
"notes": "Set up agent artifacts after the binary is installed via Homebrew (see README for tap install).\n\nHomebrew post_install runs:\n full-example configure --
|
|
264
|
+
"notes": "Set up agent artifacts after the binary is installed via Homebrew (see README for tap install).\n\nHomebrew post_install runs:\n full-example configure --refresh --yes\n\nInteractive setup (per target):\n full-example configure\n\nUpgrade:\n brew upgrade full-example\n\nShell completions are installed by Homebrew during brew install.\nSee: https://docs.brew.sh/Shell-Completion\n\nSee what is installed:\n full-example configure --status\n\nUninstall:\n brew uninstall <tap>/full-example\n\nThe formula uninstall hook runs `configure --remove-all --yes` (skills, MCP, and app config).\n\nUse --dry to preview changes without writing files.\nUse --json for machine-readable output.",
|
|
265
265
|
"options": [
|
|
266
266
|
{
|
|
267
|
-
"name": "
|
|
267
|
+
"name": "refresh",
|
|
268
268
|
"description": "Refresh installed skills and MCP. Used by Homebrew post_install.",
|
|
269
269
|
"kind": "presence"
|
|
270
270
|
},
|
|
@@ -280,7 +280,7 @@
|
|
|
280
280
|
},
|
|
281
281
|
{
|
|
282
282
|
"name": "yes",
|
|
283
|
-
"description": "Skip confirmation (required for --
|
|
283
|
+
"description": "Skip confirmation (required for --refresh, --remove-all, --remove-config).",
|
|
284
284
|
"kind": "presence",
|
|
285
285
|
"shortName": "y"
|
|
286
286
|
},
|
|
@@ -44,7 +44,7 @@ Set up agent skills and MCP config for this app (binary via Homebrew).
|
|
|
44
44
|
> Set up agent artifacts after the binary is installed via Homebrew (see README for tap install).
|
|
45
45
|
>
|
|
46
46
|
> Homebrew post_install runs:
|
|
47
|
-
> full-example configure --
|
|
47
|
+
> full-example configure --refresh --yes
|
|
48
48
|
>
|
|
49
49
|
> Interactive setup (per target):
|
|
50
50
|
> full-example configure
|
|
@@ -72,10 +72,10 @@ Set up agent skills and MCP config for this app (binary via Homebrew).
|
|
|
72
72
|
|
|
73
73
|
| Option | Type | Required | Format / default | Description |
|
|
74
74
|
| --- | --- | --- | --- | --- |
|
|
75
|
-
| `--
|
|
75
|
+
| `--refresh` | flag | optional | — | Refresh installed skills and MCP. Used by Homebrew post_install. |
|
|
76
76
|
| `--remove-all` | flag | optional | — | Remove all detected agent artifacts (skills and MCP). |
|
|
77
77
|
| `--status` | flag | optional | — | Print what is currently installed (read-only). |
|
|
78
|
-
| `--yes` (`-y`) | flag | optional | — | Skip confirmation (required for --
|
|
78
|
+
| `--yes` (`-y`) | flag | optional | — | Skip confirmation (required for --refresh, --remove-all, --remove-config). |
|
|
79
79
|
| `--dry` | flag | optional | — | Show what would change without writing files. |
|
|
80
80
|
| `--json` | flag | optional | — | Print changed paths or status JSON on stdout. |
|
|
81
81
|
|
|
@@ -263,7 +263,7 @@ Set up agent skills and MCP config for this app (binary via Homebrew).
|
|
|
263
263
|
> Set up agent artifacts after the binary is installed via Homebrew (see README for tap install).
|
|
264
264
|
>
|
|
265
265
|
> Homebrew post_install runs:
|
|
266
|
-
> full-example configure --
|
|
266
|
+
> full-example configure --refresh --yes
|
|
267
267
|
>
|
|
268
268
|
> Interactive setup (per target):
|
|
269
269
|
> full-example configure
|
|
@@ -291,10 +291,10 @@ Set up agent skills and MCP config for this app (binary via Homebrew).
|
|
|
291
291
|
|
|
292
292
|
| Option | Type | Required | Format / default | Description |
|
|
293
293
|
| --- | --- | --- | --- | --- |
|
|
294
|
-
| `--
|
|
294
|
+
| `--refresh` | flag | optional | — | Refresh installed skills and MCP. Used by Homebrew post_install. |
|
|
295
295
|
| `--remove-all` | flag | optional | — | Remove all detected agent artifacts (skills and MCP). |
|
|
296
296
|
| `--status` | flag | optional | — | Print what is currently installed (read-only). |
|
|
297
|
-
| `--yes` (`-y`) | flag | optional | — | Skip confirmation (required for --
|
|
297
|
+
| `--yes` (`-y`) | flag | optional | — | Skip confirmation (required for --refresh, --remove-all, --remove-config). |
|
|
298
298
|
| `--dry` | flag | optional | — | Show what would change without writing files. |
|
|
299
299
|
| `--json` | flag | optional | — | Print changed paths or status JSON on stdout. |
|
|
300
300
|
|
|
@@ -8,12 +8,12 @@ full-example exposes an MCP server with features similar to the CLI.
|
|
|
8
8
|
|
|
9
9
|
### `.agents` auto-install
|
|
10
10
|
|
|
11
|
-
When `mcpServer.enabled` is set, `configure --
|
|
11
|
+
When `mcpServer.enabled` is set, `configure --refresh` merges this server into `~/.agents/mcp.json` per the https://dotagentsprotocol.com.
|
|
12
12
|
|
|
13
13
|
Install the CLI first so `full-example` is on your PATH (e.g. `brew install full-example`).
|
|
14
14
|
|
|
15
15
|
```bash
|
|
16
|
-
full-example configure --
|
|
16
|
+
full-example configure --refresh --yes
|
|
17
17
|
```
|
|
18
18
|
|
|
19
19
|
Writes or updates `~/.agents/mcp.json` with a `mcpServers` entry for this app.
|
|
@@ -34,9 +34,9 @@ For full detail, open `reference.md` in this skill directory (same as `full-exam
|
|
|
34
34
|
|
|
35
35
|
## Install location
|
|
36
36
|
|
|
37
|
-
Install follows the
|
|
37
|
+
Install follows the https://dotagentsprotocol.com:
|
|
38
38
|
|
|
39
|
-
- Auto-install: `full-example configure --
|
|
39
|
+
- Auto-install: `full-example configure --refresh --yes` when `skill.enabled` → `~/.agents/skills/full-example/`
|
|
40
40
|
- Cursor and most coding agents read `~/.agents/skills/` natively
|
|
41
41
|
|
|
42
42
|
**Claude Code (manual):** symlink or copy into Claude's skill directory:
|
|
@@ -67,16 +67,16 @@ http:
|
|
|
67
67
|
install: install-local
|
|
68
68
|
|
|
69
69
|
# Refresh skills and MCP without reinstalling the formula
|
|
70
|
-
|
|
71
|
-
just run configure --
|
|
70
|
+
refresh-artifacts:
|
|
71
|
+
just run configure --refresh --yes
|
|
72
72
|
|
|
73
73
|
# Dev install: build, stage dev formula, brew install, restore release formula
|
|
74
74
|
install-local: build
|
|
75
|
-
@brew untap {{tap}} 2>/dev/null || true
|
|
75
|
+
@NONINTERACTIVE=1 brew untap {{tap}} 2>/dev/null || true
|
|
76
76
|
mkdir -p {{tap_parent}}
|
|
77
77
|
ln -sfn '{{justfile_directory()}}' {{tap_path}}
|
|
78
78
|
bun scripts/dev-formula.ts install
|
|
79
|
-
brew install --formula {{tap}}/{{cli_key}}
|
|
79
|
+
brew install --force --formula {{tap}}/{{cli_key}}
|
|
80
80
|
bun scripts/dev-formula.ts reset
|
|
81
81
|
@echo ""
|
|
82
82
|
@echo "Next: {{cli_key}} configure"
|
|
@@ -121,10 +121,10 @@ release *ARGS:
|
|
|
121
121
|
|
|
122
122
|
# Install release formula from tap and run formula test
|
|
123
123
|
test-release:
|
|
124
|
-
brew untap {{tap}} 2>/dev/null || true
|
|
124
|
+
NONINTERACTIVE=1 brew untap {{tap}} 2>/dev/null || true
|
|
125
125
|
mkdir -p {{tap_parent}}
|
|
126
126
|
ln -sfn '{{justfile_directory()}}' {{tap_path}}
|
|
127
|
-
brew uninstall --formula {{tap}}/{{cli_key}} 2>/dev/null || true
|
|
127
|
+
NONINTERACTIVE=1 brew uninstall --formula {{tap}}/{{cli_key}} 2>/dev/null || true
|
|
128
128
|
brew install --formula {{tap}}/{{cli_key}}
|
|
129
129
|
brew test {{cli_key}}
|
|
130
130
|
|
|
@@ -145,15 +145,15 @@ uninstall-config:
|
|
|
145
145
|
|
|
146
146
|
# Remove formula and untap
|
|
147
147
|
uninstall-formula:
|
|
148
|
-
@brew uninstall --formula {{tap}}/{{cli_key}} 2>/dev/null || true
|
|
149
|
-
@brew uninstall --formula {{tap}}/{{cli_key}}-local 2>/dev/null || true
|
|
150
|
-
@brew untap {{tap}} 2>/dev/null || true
|
|
148
|
+
@NONINTERACTIVE=1 brew uninstall --formula {{tap}}/{{cli_key}} 2>/dev/null || true
|
|
149
|
+
@NONINTERACTIVE=1 brew uninstall --formula {{tap}}/{{cli_key}}-local 2>/dev/null || true
|
|
150
|
+
@NONINTERACTIVE=1 brew untap {{tap}} 2>/dev/null || true
|
|
151
151
|
|
|
152
152
|
# Remove release formula (does not untap)
|
|
153
153
|
uninstall-release:
|
|
154
|
-
@brew uninstall --formula {{tap}}/{{cli_key}} 2>/dev/null || true
|
|
154
|
+
@NONINTERACTIVE=1 brew uninstall --formula {{tap}}/{{cli_key}} 2>/dev/null || true
|
|
155
155
|
|
|
156
156
|
# Remove release formula and untap
|
|
157
157
|
uninstall-release-tap:
|
|
158
|
-
@brew uninstall --formula {{tap}}/{{cli_key}} 2>/dev/null || true
|
|
159
|
-
@brew untap {{tap}} 2>/dev/null || true
|
|
158
|
+
@NONINTERACTIVE=1 brew uninstall --formula {{tap}}/{{cli_key}} 2>/dev/null || true
|
|
159
|
+
@NONINTERACTIVE=1 brew untap {{tap}} 2>/dev/null || true
|
|
@@ -20,7 +20,7 @@ export const formulaInstallRuby = `def install
|
|
|
20
20
|
end`;
|
|
21
21
|
|
|
22
22
|
export const formulaPostInstallRuby = `def post_install
|
|
23
|
-
system bin/"${key}", "configure", "--
|
|
23
|
+
system bin/"${key}", "configure", "--refresh", "--yes"
|
|
24
24
|
end`;
|
|
25
25
|
|
|
26
26
|
export const formulaUninstallRuby = `def uninstall
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
#!/usr/bin/env bun
|
|
2
|
+
/* Cursor stop hook: run `just test` on agent completion; follow up if it fails. */
|
|
3
|
+
|
|
4
|
+
try {
|
|
5
|
+
const empty = () => {
|
|
6
|
+
console.log("{}");
|
|
7
|
+
process.exit(0);
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
const input = JSON.parse(await Bun.stdin.text()) as {
|
|
11
|
+
status?: string;
|
|
12
|
+
loop_count?: number;
|
|
13
|
+
workspace_roots?: string[];
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
if (input.status !== "completed") empty();
|
|
17
|
+
|
|
18
|
+
const cwd = input.workspace_roots?.[0] ?? process.cwd();
|
|
19
|
+
if (!(await Bun.file(`${cwd}/justfile`).exists())) empty();
|
|
20
|
+
|
|
21
|
+
const diff = Bun.spawnSync(["git", "diff", "--name-only", "HEAD"], { cwd, stdout: "pipe" });
|
|
22
|
+
const CODE_FILE = /\.(t|j)sx?$/i;
|
|
23
|
+
const SKIP_PREFIX = /^(node_modules|dist|\.cursor)\//;
|
|
24
|
+
const changed = new TextDecoder()
|
|
25
|
+
.decode(diff.stdout)
|
|
26
|
+
.split("\n")
|
|
27
|
+
.some(
|
|
28
|
+
(path) =>
|
|
29
|
+
path &&
|
|
30
|
+
(path === "justfile" || (CODE_FILE.test(path) && !SKIP_PREFIX.test(path))),
|
|
31
|
+
);
|
|
32
|
+
if (!changed) empty();
|
|
33
|
+
|
|
34
|
+
const proc = Bun.spawnSync(["just", "test"], {
|
|
35
|
+
cwd,
|
|
36
|
+
env: { ...process.env, FORCE_COLOR: "0" },
|
|
37
|
+
stderr: "pipe",
|
|
38
|
+
stdout: "pipe",
|
|
39
|
+
});
|
|
40
|
+
const output =
|
|
41
|
+
new TextDecoder().decode(proc.stdout) + new TextDecoder().decode(proc.stderr);
|
|
42
|
+
|
|
43
|
+
if (proc.exitCode === 0) empty();
|
|
44
|
+
|
|
45
|
+
const lines = output.trimEnd().split("\n");
|
|
46
|
+
const tail = lines.length > 80 ? lines.slice(-80).join("\n") : output.trimEnd();
|
|
47
|
+
const n = (input.loop_count ?? 0) + 1;
|
|
48
|
+
|
|
49
|
+
console.log(
|
|
50
|
+
JSON.stringify({
|
|
51
|
+
followup_message: `Tests failed (auto-retry ${n}/20). Fix and ensure \`just test\` passes.\n\n\`\`\`\n${tail}\n\`\`\``,
|
|
52
|
+
}),
|
|
53
|
+
);
|
|
54
|
+
} catch {
|
|
55
|
+
console.log("{}");
|
|
56
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
# full-example-json
|
|
2
|
+
|
|
3
|
+
## Tooling
|
|
4
|
+
|
|
5
|
+
- Bun only (`bun`, `bunx`, `bun test`). No Node/npm/pnpm.
|
|
6
|
+
|
|
7
|
+
## Documentation
|
|
8
|
+
|
|
9
|
+
- `README.md` — user-facing install/commands
|
|
10
|
+
- `docs/architecture.md` — maintainer internals (create if missing)
|
|
11
|
+
- Generated: `just docgen` → `docs/cli.md`, `docs/cli-schema.json`, `docs/skill.md`
|
|
12
|
+
|
|
13
|
+
<!-- argsbarg:managed -->
|
|
14
|
+
|
|
15
|
+
## Argsbarg schema
|
|
16
|
+
|
|
17
|
+
When adding or changing argsbarg schema, leaf handlers, or MCP exposure:
|
|
18
|
+
|
|
19
|
+
1. **Read** `node_modules/argsbarg/docs/cli-program.md` (required — authoritative guide).
|
|
20
|
+
2. MCP tools, varargs, `inputSchema` → also `node_modules/argsbarg/docs/mcp.md`.
|
|
21
|
+
3. JSON stdout / `outputSchema` guide and codegen → `node_modules/argsbarg/docs/output-schema.md`.
|
|
22
|
+
4. App config / `program.appConfig` guide and codegen → `node_modules/argsbarg/docs/config-schema.md`.
|
|
23
|
+
5. `configure`, `configure.targets`, Homebrew distribution → `node_modules/argsbarg/docs/configure.md` and `distribution-homebrew.md`.
|
|
24
|
+
6. Bundled `docs` built-in → `node_modules/argsbarg/docs/bundled-docs.md`.
|
|
25
|
+
7. **Examples** (shipped under `node_modules/argsbarg/examples/`):
|
|
26
|
+
- **Copy template** (all builtins, `@sg` schemagen, Homebrew justfile, `outputSchema`) → `examples/full-example/`
|
|
27
|
+
|
|
28
|
+
**Hard rules** (details and examples are in the docs above — do not contradict them):
|
|
29
|
+
|
|
30
|
+
- Reserved root commands: `completion`, `configure`, `mcp`, `version`, `docs`.
|
|
31
|
+
- `satisfies CliProgram` / `CliLeaf`; action-oriented `description` on root, commands, options, and positionals.
|
|
32
|
+
- Omit `mcpTool` unless genuinely CLI-only (`enabled: false`) or an irreducible wire limit — fix schema and headless handlers first.
|
|
33
|
+
- Interactive leaves: one headless path for MCP, non-TTY CLI, and `--yes` / `--dry-run` / `--json` (`shouldRunHeadless*`, `requireYesInNonTty`); not raw `isTTY`.
|
|
34
|
+
- String options: `format` / `default` / `pattern` per `cli-program.md`; `readLeafInputs()` for multi-flag leaves.
|
|
35
|
+
- Varargs (`argMax: 0`): CLI space-separated; MCP JSON array only — no comma-splitting positionals.
|
|
36
|
+
- Multi-surface leaves (Ink + headless + MCP): one **`read*Flags(ctx)`** per command (or shared family helper + extensions); one **`resolve*Input(flags)`** for cross-field rules — handler reads ctx once, all paths share the struct.
|
|
37
|
+
- JSON stdout: `import { StatusJsonOutputSchema } from "./__generated__"` — declare `/** @sg */` on the type in `types.ts`; handlers import types from the same module.
|
|
38
|
+
- App config (optional): `import { AppConfigSchema } from "./config/__generated__"` — `/** @sg */` on `AppConfig` in `src/config/types.ts`.
|
|
39
|
+
|
|
40
|
+
## Code conventions
|
|
41
|
+
|
|
42
|
+
### JSDoc
|
|
43
|
+
|
|
44
|
+
Add doc comments for exported surfaces that are not obvious from the name alone: JSON output schemas, public types, and non-trivial algorithms. Skip comments on short test callbacks and pure re-export files.
|
|
45
|
+
|
|
46
|
+
### Names
|
|
47
|
+
|
|
48
|
+
Use names that describe the domain role, not generic placeholders like `data` or `handler`, except in very small scopes.
|
|
49
|
+
|
|
50
|
+
### Structure
|
|
51
|
+
|
|
52
|
+
After imports, put **exported** symbols first (alphabetical within each kind), then **module-private** helpers at the bottom. Use `~/…` only where you would otherwise use `../` (or deeper) to reach another module under `src/`. Same-directory (`./`) and child (`./foo/…`) imports stay relative. Use `.ts` extensions.
|
|
53
|
+
|
|
54
|
+
### Module boundaries
|
|
55
|
+
|
|
56
|
+
| Path | Owns | Must not |
|
|
57
|
+
| --- | --- | --- |
|
|
58
|
+
| `src/index.ts` | Thin entry: `new Cli(program).run()` | Inline leaf handlers, business logic |
|
|
59
|
+
| `src/types/` | Global type declarations and module augmentations (e.g. `argsbarg.d.ts`, `md.d.ts`) | Runtime logic, imports from outside `types/` |
|
|
60
|
+
| `src/program.ts` | `CliProgram` assembly: `docs`, `commands: […]` | Inline leaf handlers, business logic |
|
|
61
|
+
| `src/db/` | `AppDb` (SQLite connect, migrate, domain access), `migrate.ts`, `migrations/*.sql` | Command handlers |
|
|
62
|
+
| `src/commands/<name>/` | One user-facing command: `command.ts`, optional `types.ts` with `/** @sg */` | Shared helpers (lift to `src/db/`) |
|
|
63
|
+
| `src/**/__generated__/` | Generated JSON Schema + `index.ts` re-exports | Hand-edited generated files |
|
|
64
|
+
| `scripts/` | Dev tooling (formula helpers) | Production command paths |
|
|
65
|
+
|
|
66
|
+
When adding commands: `src/commands/<name>/command.ts` + `types.ts` when schemas are needed; register in `program.ts` **alphabetically by command key**.
|
|
67
|
+
|
|
68
|
+
**Argsbarg schema:** see Argsbarg schema section above.
|
|
69
|
+
|
|
70
|
+
### Execution
|
|
71
|
+
|
|
72
|
+
- **Runtime:** Bun (`just test`, `just dev`).
|
|
73
|
+
- **Tests:** colocate `*.test.ts` next to the module.
|
|
74
|
+
- **Schemagen:** after changing `/** @sg */` types in `src/`, run `just schemagen` (`__generated__/` is gitignored).
|
|
75
|
+
|
|
76
|
+
### Abstractions
|
|
77
|
+
|
|
78
|
+
Avoid needless extraction: keep single-use helpers in the calling file by default. Split only when reused elsewhere, the caller is large or hard to follow, or extraction clarifies a substantial unit. Do not create tiny one-off helpers.
|
|
79
|
+
- ❌ `utils/formatX.ts` — 60-line helper used by one command
|
|
80
|
+
- ✅ inline helper in that command file
|
|
81
|
+
|
|
82
|
+
<!-- /argsbarg:managed -->
|
|
83
|
+
|
|
84
|
+
**full-example-json conventions:**
|
|
85
|
+
|
|
86
|
+
Replace with app-specific bullets.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
@AGENTS.md
|
|
@@ -5,7 +5,7 @@ Reference template for argsbarg consumer docgen. Every builtin is enabled in `sr
|
|
|
5
5
|
| If you are… | Read |
|
|
6
6
|
| --- | --- |
|
|
7
7
|
| **Using the CLI** | [../README.md](../README.md) |
|
|
8
|
-
| **Authoring argsbarg schema** | `node_modules/argsbarg/docs/cli-program.md` — see
|
|
8
|
+
| **Authoring argsbarg schema** | `node_modules/argsbarg/docs/cli-program.md` — see [`AGENTS.md`](../AGENTS.md) |
|
|
9
9
|
| **HTTP API / curl** | [http.md](http.md) — generated; or run `full-example docs http` |
|
|
10
10
|
| **MCP tools** | [mcp.md](mcp.md) — generated; or run `full-example docs mcp` |
|
|
11
11
|
| **Full command tree (markdown)** | [cli.md](cli.md) — generated |
|