argsbarg 7.1.1 → 7.1.3

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 (71) hide show
  1. package/CHANGELOG.md +38 -1
  2. package/README.md +7 -7
  3. package/docs/README.md +1 -1
  4. package/docs/cli-program.md +1 -1
  5. package/docs/configure.md +2 -2
  6. package/docs/mcp.md +53 -4
  7. package/docs/output-schema.md +6 -0
  8. package/examples/full-example/AGENTS.md +1 -1
  9. package/examples/full-example/bun.lock +83 -1
  10. package/examples/full-example/justfile +5 -3
  11. package/examples/full-example-json/AGENTS.md +1 -1
  12. package/examples/full-example-json/README.md +1 -0
  13. package/examples/full-example-json/bun.lock +83 -1
  14. package/examples/full-example-json/docs/cli-schema.json +284 -9
  15. package/examples/full-example-json/docs/cli.md +236 -18
  16. package/examples/full-example-json/docs/http.md +1 -0
  17. package/examples/full-example-json/docs/mcp.md +18 -0
  18. package/examples/full-example-json/docs/openapi.json +155 -0
  19. package/examples/full-example-json/justfile +5 -3
  20. package/examples/full-example-json/src/commands/shape-area/__generated__/ShapeAreaInputSchema.json +59 -0
  21. package/examples/full-example-json/src/commands/shape-area/__generated__/index.ts +5 -0
  22. package/examples/full-example-json/src/commands/shape-area/command.test.ts +34 -0
  23. package/examples/full-example-json/src/commands/shape-area/command.ts +31 -0
  24. package/examples/full-example-json/src/commands/shape-area/types.ts +28 -0
  25. package/examples/full-example-json/src/program.ts +2 -1
  26. package/examples/mcp-plugin/.claude-plugin/plugin.json +7 -1
  27. package/examples/mcp-plugin/.cursor-plugin/plugin.json +7 -1
  28. package/examples/mcp-plugin/AGENTS.md +14 -1
  29. package/examples/mcp-plugin/README.md +19 -10
  30. package/examples/mcp-plugin/bun.lock +83 -1
  31. package/examples/mcp-plugin/bunfig.toml +4 -0
  32. package/examples/mcp-plugin/docs/node-distro.md +97 -0
  33. package/examples/mcp-plugin/justfile +12 -11
  34. package/examples/mcp-plugin/package.json +2 -1
  35. package/examples/mcp-plugin/scripts/release.ts +10 -11
  36. package/index.d.ts +62 -0
  37. package/package.json +1 -1
  38. package/src/cli-tool/create.test.ts +14 -0
  39. package/src/cli-tool/create.ts +9 -0
  40. package/src/cli-tool/main.ts +1 -1
  41. package/src/cli-tool/schemagen/run.ts +41 -2
  42. package/src/cli-tool/schemagen/schemagen.test.ts +87 -2
  43. package/src/config/validate.test.ts +157 -0
  44. package/src/config/validate.ts +353 -26
  45. package/src/core/document-leaf.test.ts +53 -0
  46. package/src/core/json-pointer.ts +46 -0
  47. package/src/core/types.ts +33 -0
  48. package/src/core/validate.ts +68 -1
  49. package/src/docs/docs.test.ts +7 -0
  50. package/src/docs/mcp-guide.ts +43 -1
  51. package/src/headless/tool-call.test.ts +74 -2
  52. package/src/headless/tool-call.ts +44 -22
  53. package/src/http/schema-deref.ts +1 -23
  54. package/src/index.ts +3 -0
  55. package/src/mcp/server.ts +28 -4
  56. package/src/mcp/tools.test.ts +292 -0
  57. package/src/mcp/tools.ts +144 -6
  58. package/src/runtime/cli.ts +6 -1
  59. package/src/server/context.ts +6 -0
  60. package/src/test/integration/mcp.test.ts +73 -0
  61. package/src/test/mcp-integration-fixture.ts +1 -0
  62. package/src/test/mcp-size-fixture.ts +31 -0
  63. package/examples/mcp-plugin/.mcp.json +0 -6
  64. package/examples/mcp-plugin/mcp.json +0 -8
  65. package/examples/mcp-plugin/scripts/mcp.mjs +0 -11106
  66. package/examples/mcp-plugin/src/commands/render-json/__generated__/RenderJsonInputSchema.json +0 -15
  67. package/examples/mcp-plugin/src/commands/render-json/__generated__/index.ts +0 -5
  68. package/examples/mcp-plugin/src/commands/status/__generated__/StatusJsonOutputSchema.json +0 -15
  69. package/examples/mcp-plugin/src/commands/status/__generated__/index.ts +0 -5
  70. package/examples/mcp-plugin/src/commands/workspaces/__generated__/WorkspaceNameInputSchema.json +0 -15
  71. package/examples/mcp-plugin/src/commands/workspaces/__generated__/index.ts +0 -5
@@ -14,6 +14,7 @@ Argsbarg schema-first copy template (@sg schemagen, JSON schemas, REST CRUD)
14
14
 
15
15
  - `echo` — Echo a message (MCP-friendly leaf).
16
16
  - `render-json` — Echo a JSON message (schema-first JSON leaf demo).
17
+ - `shape-area` — Compute the area of a circle or rectangle (union-input JSON leaf demo).
17
18
  - `status` — Show app version.
18
19
  - `workspaces` — Workspace collection and CRUD.
19
20
 
@@ -205,11 +206,11 @@ MCP server and bundle tools.
205
206
 
206
207
  #### Subcommands
207
208
 
208
- - `bundle` — Pack dist MCP artifacts (`.mcpb`, Claude Code plugin zip) from dist/<key>.
209
+ - `bundle` — Pack dist MCP artifacts (`.mcpb`, Claude Code plugin zip, Cursor plugin zip) from dist/<key>.
209
210
 
210
211
  ##### `full-example-json echo mcp bundle`
211
212
 
212
- Pack dist MCP artifacts (`.mcpb`, Claude Code plugin zip) from dist/<key>.
213
+ Pack dist MCP artifacts (`.mcpb`, Claude Code plugin zip, Cursor plugin zip) from dist/<key>.
213
214
 
214
215
  #### `full-example-json echo http`
215
216
 
@@ -422,11 +423,11 @@ MCP server and bundle tools.
422
423
 
423
424
  #### Subcommands
424
425
 
425
- - `bundle` — Pack dist MCP artifacts (`.mcpb`, Claude Code plugin zip) from dist/<key>.
426
+ - `bundle` — Pack dist MCP artifacts (`.mcpb`, Claude Code plugin zip, Cursor plugin zip) from dist/<key>.
426
427
 
427
428
  ##### `full-example-json render-json mcp bundle`
428
429
 
429
- Pack dist MCP artifacts (`.mcpb`, Claude Code plugin zip) from dist/<key>.
430
+ Pack dist MCP artifacts (`.mcpb`, Claude Code plugin zip, Cursor plugin zip) from dist/<key>.
430
431
 
431
432
  #### `full-example-json render-json http`
432
433
 
@@ -457,6 +458,223 @@ HTTP API server for tools.
457
458
  | `--no-access-log` | flag | optional | — | Disable HTTP access logs. |
458
459
  | `--dev` | flag | optional | — | Print full stacks to stderr on errors. |
459
460
 
461
+ ### `full-example-json shape-area`
462
+
463
+ Compute the area of a circle or rectangle (union-input JSON leaf demo).
464
+
465
+ #### Subcommands
466
+
467
+ - `version` — Print the program version.
468
+ - `configure` — Set up MCP config for this app (binary via Homebrew).
469
+ - `docs` — Print bundled CLI documentation.
470
+ - `mcp` — MCP server and bundle tools.
471
+ - `http` — HTTP API server for tools.
472
+
473
+ #### `full-example-json shape-area version`
474
+
475
+ Print the program version.
476
+
477
+ #### `full-example-json shape-area configure`
478
+
479
+ Set up MCP config for this app (binary via Homebrew).
480
+
481
+ > Set up agent artifacts after the binary is installed via Homebrew (see README for tap install).
482
+ >
483
+ > Homebrew installs the binary and shell completions only. Agent artifacts live under ~/.agents and are not written during brew install.
484
+ >
485
+ > After install or upgrade:
486
+ > full-example-json configure install
487
+ >
488
+ > Upgrade:
489
+ > brew upgrade full-example-json
490
+ > full-example-json configure install
491
+ >
492
+ > Shell completions are installed by Homebrew during brew install.
493
+ > See: https://docs.brew.sh/Shell-Completion
494
+ >
495
+ > See what is installed:
496
+ > full-example-json configure status
497
+ >
498
+ > Uninstall:
499
+ > full-example-json configure uninstall
500
+ > brew uninstall <tap>/full-example-json
501
+ >
502
+ > Use `configure status --json` for machine-readable output.
503
+
504
+ #### Subcommands
505
+
506
+ - `install` — Install agent artifacts and bootstrap app config.
507
+ - `uninstall` — Remove agent artifacts and app config.
508
+ - `status` — Print what is currently installed (read-only).
509
+
510
+ ##### `full-example-json shape-area configure install`
511
+
512
+ Install agent artifacts and bootstrap app config.
513
+
514
+ ##### `full-example-json shape-area configure uninstall`
515
+
516
+ Remove agent artifacts and app config.
517
+
518
+ #### Options
519
+
520
+ | Option | Type | Required | Format / default | Description |
521
+ | --- | --- | --- | --- | --- |
522
+ | `--yes` (`-y`) | flag | optional | — | Skip uninstall confirmation. |
523
+
524
+ ##### `full-example-json shape-area configure status`
525
+
526
+ Print what is currently installed (read-only).
527
+
528
+ #### Options
529
+
530
+ | Option | Type | Required | Format / default | Description |
531
+ | --- | --- | --- | --- | --- |
532
+ | `--json` | flag | optional | — | Print status JSON on stdout. |
533
+
534
+ #### `full-example-json shape-area docs`
535
+
536
+ Print bundled CLI documentation.
537
+
538
+ > Topics print to stdout. Add --save to write files under ./docs/.
539
+
540
+ #### Options
541
+
542
+ | Option | Type | Required | Format / default | Description |
543
+ | --- | --- | --- | --- | --- |
544
+ | `--save` | flag | optional | — | Write documentation to ./docs/. |
545
+
546
+ #### Subcommands
547
+
548
+ - `readme` — Print README (user guide).
549
+ - `mcp` — Print MCP server setup and tool guidance.
550
+ - `http` — Print HTTP API setup and tool guidance.
551
+ - `openapi` — Print the HTTP OpenAPI 3.1 document as JSON.
552
+ - `cli-schema` — Print the full CLI command tree as JSON.
553
+ - `cli` — Print the full command reference as markdown.
554
+
555
+ ##### `full-example-json shape-area docs readme`
556
+
557
+ Print README (user guide).
558
+
559
+ #### Options
560
+
561
+ | Option | Type | Required | Format / default | Description |
562
+ | --- | --- | --- | --- | --- |
563
+ | `--save` | flag | optional | — | Write documentation to ./docs/. |
564
+
565
+ ##### `full-example-json shape-area docs mcp`
566
+
567
+ Print MCP server setup and tool guidance.
568
+
569
+ #### Options
570
+
571
+ | Option | Type | Required | Format / default | Description |
572
+ | --- | --- | --- | --- | --- |
573
+ | `--save` | flag | optional | — | Write documentation to ./docs/. |
574
+
575
+ ##### `full-example-json shape-area docs http`
576
+
577
+ Print HTTP API setup and tool guidance.
578
+
579
+ #### Options
580
+
581
+ | Option | Type | Required | Format / default | Description |
582
+ | --- | --- | --- | --- | --- |
583
+ | `--save` | flag | optional | — | Write documentation to ./docs/. |
584
+
585
+ ##### `full-example-json shape-area docs openapi`
586
+
587
+ Print the HTTP OpenAPI 3.1 document as JSON.
588
+
589
+ #### Options
590
+
591
+ | Option | Type | Required | Format / default | Description |
592
+ | --- | --- | --- | --- | --- |
593
+ | `--save` | flag | optional | — | Write documentation to ./docs/. |
594
+
595
+ ##### `full-example-json shape-area docs cli-schema`
596
+
597
+ Print the full CLI command tree as JSON.
598
+
599
+ #### Options
600
+
601
+ | Option | Type | Required | Format / default | Description |
602
+ | --- | --- | --- | --- | --- |
603
+ | `--save` | flag | optional | — | Write documentation to ./docs/. |
604
+
605
+ ##### `full-example-json shape-area docs cli`
606
+
607
+ Print the full command reference as markdown.
608
+
609
+ #### Options
610
+
611
+ | Option | Type | Required | Format / default | Description |
612
+ | --- | --- | --- | --- | --- |
613
+ | `--save` | flag | optional | — | Write documentation to ./docs/. |
614
+
615
+ #### `full-example-json shape-area mcp`
616
+
617
+ MCP server and bundle tools.
618
+
619
+ > Stdio MCP server. Add to Cursor, Claude Code, or Claude Desktop:
620
+ >
621
+ > command: full-example-json
622
+ > args: mcp
623
+ >
624
+ > Or:
625
+ >
626
+ > full-example-json configure
627
+ >
628
+ > Full setup guide: full-example-json docs mcp
629
+
630
+ **Default subcommand:** `serve` (`missingOnly`)
631
+
632
+ #### Options
633
+
634
+ | Option | Type | Required | Format / default | Description |
635
+ | --- | --- | --- | --- | --- |
636
+ | `--obscure-errors` | flag | optional | — | Hide unexpected errors from clients. |
637
+ | `--log-format` | enum (`json`, `text`) | optional | — | Log format: json (ECS Logging) or text. |
638
+ | `--log-file` | string | optional | — | Append logs to this file (relative → app config dir). |
639
+ | `--dev` | flag | optional | — | Print full stacks to stderr on errors. |
640
+
641
+ #### Subcommands
642
+
643
+ - `bundle` — Pack dist MCP artifacts (`.mcpb`, Claude Code plugin zip, Cursor plugin zip) from dist/<key>.
644
+
645
+ ##### `full-example-json shape-area mcp bundle`
646
+
647
+ Pack dist MCP artifacts (`.mcpb`, Claude Code plugin zip, Cursor plugin zip) from dist/<key>.
648
+
649
+ #### `full-example-json shape-area http`
650
+
651
+ HTTP API server for tools.
652
+
653
+ > HTTP tool server on http://127.0.0.1:3000.
654
+ >
655
+ > Endpoints: GET /health/liveness, GET /health/readiness, GET /openapi.json, GET /swagger, /*
656
+ >
657
+ > Configure app settings:
658
+ >
659
+ > full-example-json configure
660
+ >
661
+ > Full setup guide: full-example-json docs http
662
+
663
+ **Default subcommand:** `serve` (`missingOnly`)
664
+
665
+ #### Options
666
+
667
+ | Option | Type | Required | Format / default | Description |
668
+ | --- | --- | --- | --- | --- |
669
+ | `--host` | string | optional | — | Listen host. |
670
+ | `--port` | number | optional | — | Listen port. |
671
+ | `--trust-proxy` | flag | optional | — | Honor X-Forwarded-For for client IP. |
672
+ | `--obscure-errors` | flag | optional | — | Hide unexpected errors from clients. |
673
+ | `--log-format` | enum (`json`, `text`) | optional | — | Log format: json (ECS Logging) or text. |
674
+ | `--log-file` | string | optional | — | Append logs to this file (relative → app config dir). |
675
+ | `--no-access-log` | flag | optional | — | Disable HTTP access logs. |
676
+ | `--dev` | flag | optional | — | Print full stacks to stderr on errors. |
677
+
460
678
  ### `full-example-json status`
461
679
 
462
680
  Show app version.
@@ -667,11 +885,11 @@ MCP server and bundle tools.
667
885
 
668
886
  #### Subcommands
669
887
 
670
- - `bundle` — Pack dist MCP artifacts (`.mcpb`, Claude Code plugin zip) from dist/<key>.
888
+ - `bundle` — Pack dist MCP artifacts (`.mcpb`, Claude Code plugin zip, Cursor plugin zip) from dist/<key>.
671
889
 
672
890
  ##### `full-example-json status mcp bundle`
673
891
 
674
- Pack dist MCP artifacts (`.mcpb`, Claude Code plugin zip) from dist/<key>.
892
+ Pack dist MCP artifacts (`.mcpb`, Claude Code plugin zip, Cursor plugin zip) from dist/<key>.
675
893
 
676
894
  #### `full-example-json status http`
677
895
 
@@ -894,11 +1112,11 @@ MCP server and bundle tools.
894
1112
 
895
1113
  #### Subcommands
896
1114
 
897
- - `bundle` — Pack dist MCP artifacts (`.mcpb`, Claude Code plugin zip) from dist/<key>.
1115
+ - `bundle` — Pack dist MCP artifacts (`.mcpb`, Claude Code plugin zip, Cursor plugin zip) from dist/<key>.
898
1116
 
899
1117
  ###### `full-example-json workspaces get mcp bundle`
900
1118
 
901
- Pack dist MCP artifacts (`.mcpb`, Claude Code plugin zip) from dist/<key>.
1119
+ Pack dist MCP artifacts (`.mcpb`, Claude Code plugin zip, Cursor plugin zip) from dist/<key>.
902
1120
 
903
1121
  ##### `full-example-json workspaces get http`
904
1122
 
@@ -1111,11 +1329,11 @@ MCP server and bundle tools.
1111
1329
 
1112
1330
  #### Subcommands
1113
1331
 
1114
- - `bundle` — Pack dist MCP artifacts (`.mcpb`, Claude Code plugin zip) from dist/<key>.
1332
+ - `bundle` — Pack dist MCP artifacts (`.mcpb`, Claude Code plugin zip, Cursor plugin zip) from dist/<key>.
1115
1333
 
1116
1334
  ###### `full-example-json workspaces post mcp bundle`
1117
1335
 
1118
- Pack dist MCP artifacts (`.mcpb`, Claude Code plugin zip) from dist/<key>.
1336
+ Pack dist MCP artifacts (`.mcpb`, Claude Code plugin zip, Cursor plugin zip) from dist/<key>.
1119
1337
 
1120
1338
  ##### `full-example-json workspaces post http`
1121
1339
 
@@ -1339,11 +1557,11 @@ MCP server and bundle tools.
1339
1557
 
1340
1558
  #### Subcommands
1341
1559
 
1342
- - `bundle` — Pack dist MCP artifacts (`.mcpb`, Claude Code plugin zip) from dist/<key>.
1560
+ - `bundle` — Pack dist MCP artifacts (`.mcpb`, Claude Code plugin zip, Cursor plugin zip) from dist/<key>.
1343
1561
 
1344
1562
  ###### `full-example-json workspaces :id get mcp bundle`
1345
1563
 
1346
- Pack dist MCP artifacts (`.mcpb`, Claude Code plugin zip) from dist/<key>.
1564
+ Pack dist MCP artifacts (`.mcpb`, Claude Code plugin zip, Cursor plugin zip) from dist/<key>.
1347
1565
 
1348
1566
  ###### `full-example-json workspaces :id get http`
1349
1567
 
@@ -1556,11 +1774,11 @@ MCP server and bundle tools.
1556
1774
 
1557
1775
  #### Subcommands
1558
1776
 
1559
- - `bundle` — Pack dist MCP artifacts (`.mcpb`, Claude Code plugin zip) from dist/<key>.
1777
+ - `bundle` — Pack dist MCP artifacts (`.mcpb`, Claude Code plugin zip, Cursor plugin zip) from dist/<key>.
1560
1778
 
1561
1779
  ###### `full-example-json workspaces :id put mcp bundle`
1562
1780
 
1563
- Pack dist MCP artifacts (`.mcpb`, Claude Code plugin zip) from dist/<key>.
1781
+ Pack dist MCP artifacts (`.mcpb`, Claude Code plugin zip, Cursor plugin zip) from dist/<key>.
1564
1782
 
1565
1783
  ###### `full-example-json workspaces :id put http`
1566
1784
 
@@ -1773,11 +1991,11 @@ MCP server and bundle tools.
1773
1991
 
1774
1992
  #### Subcommands
1775
1993
 
1776
- - `bundle` — Pack dist MCP artifacts (`.mcpb`, Claude Code plugin zip) from dist/<key>.
1994
+ - `bundle` — Pack dist MCP artifacts (`.mcpb`, Claude Code plugin zip, Cursor plugin zip) from dist/<key>.
1777
1995
 
1778
1996
  ###### `full-example-json workspaces :id patch mcp bundle`
1779
1997
 
1780
- Pack dist MCP artifacts (`.mcpb`, Claude Code plugin zip) from dist/<key>.
1998
+ Pack dist MCP artifacts (`.mcpb`, Claude Code plugin zip, Cursor plugin zip) from dist/<key>.
1781
1999
 
1782
2000
  ###### `full-example-json workspaces :id patch http`
1783
2001
 
@@ -1990,11 +2208,11 @@ MCP server and bundle tools.
1990
2208
 
1991
2209
  #### Subcommands
1992
2210
 
1993
- - `bundle` — Pack dist MCP artifacts (`.mcpb`, Claude Code plugin zip) from dist/<key>.
2211
+ - `bundle` — Pack dist MCP artifacts (`.mcpb`, Claude Code plugin zip, Cursor plugin zip) from dist/<key>.
1994
2212
 
1995
2213
  ###### `full-example-json workspaces :id delete mcp bundle`
1996
2214
 
1997
- Pack dist MCP artifacts (`.mcpb`, Claude Code plugin zip) from dist/<key>.
2215
+ Pack dist MCP artifacts (`.mcpb`, Claude Code plugin zip, Cursor plugin zip) from dist/<key>.
1998
2216
 
1999
2217
  ###### `full-example-json workspaces :id delete http`
2000
2218
 
@@ -61,6 +61,7 @@ See the argsbarg [logging guide](https://github.com/bdombro/bun-argsbarg/blob/ma
61
61
 
62
62
  - `POST /echo` (CLI: `full-example-json echo`) — Echo a message (MCP-friendly leaf).
63
63
  - `POST /render-json` (CLI: `full-example-json render-json`) — Echo a JSON message (schema-first JSON leaf demo).
64
+ - `POST /shape-area` (CLI: `full-example-json shape-area`) — Compute the area of a circle or rectangle (union-input JSON leaf demo).
64
65
  - `POST /status` (CLI: `full-example-json status`) — Show app version.
65
66
  - `GET /workspaces` (CLI: `full-example-json workspaces get`) — List workspaces.
66
67
  - `POST /workspaces` (CLI: `full-example-json workspaces post`) — Create a workspace.
@@ -93,6 +93,7 @@ full-example-json mcp
93
93
 
94
94
  - `full-example-json echo` — echo — Echo a message (MCP-friendly leaf).
95
95
  - `full-example-json render-json` — render-json — Echo a JSON message (schema-first JSON leaf demo).
96
+ - `full-example-json shape-area` — shape-area — Compute the area of a circle or rectangle (union-input JSON leaf demo).
96
97
  - `full-example-json status` — status — Show app version.
97
98
  - `full-example-json workspaces :id delete` — workspaces :id delete — Delete a workspace.
98
99
  - `full-example-json workspaces :id get` — workspaces :id get — Get one workspace.
@@ -101,6 +102,23 @@ full-example-json mcp
101
102
  - `full-example-json workspaces get` — workspaces get — List workspaces.
102
103
  - `full-example-json workspaces post` — workspaces post — Create a workspace.
103
104
 
105
+ ## Tool sizes
106
+
107
+ Clients read tool definitions with their own limits — a definition or description past those is truncated or read incompletely. Default limits here: description 2,048 chars, definition 51,200 bytes / 2,000 lines (override with `mcpServer.sizeLimits`).
108
+
109
+ | Tool | Description (chars) | Definition (bytes) | Definition (lines) | Status |
110
+ | --- | --- | --- | --- | --- |
111
+ | `echo` | 42 | 326 | 17 | ok |
112
+ | `render_json` | 64 | 443 | 19 | ok |
113
+ | `shape_area` | 84 | 1,769 | 72 | ok |
114
+ | `status` | 26 | 512 | 24 | ok |
115
+ | `workspaces__id_delete` | 43 | 205 | 9 | ok |
116
+ | `workspaces__id_get` | 39 | 198 | 9 | ok |
117
+ | `workspaces__id_patch` | 46 | 430 | 19 | ok |
118
+ | `workspaces__id_put` | 41 | 423 | 19 | ok |
119
+ | `workspaces_get` | 33 | 188 | 9 | ok |
120
+ | `workspaces_post` | 37 | 416 | 19 | ok |
121
+
104
122
  ## Tool arguments
105
123
 
106
124
  Arguments are a flat JSON object keyed by long option and positional names (hyphenated option names are valid keys).
@@ -18,6 +18,10 @@
18
18
  "name": "render-json",
19
19
  "description": "Echo a JSON message (schema-first JSON leaf demo)."
20
20
  },
21
+ {
22
+ "name": "shape-area",
23
+ "description": "Compute the area of a circle or rectangle (union-input JSON leaf demo)."
24
+ },
21
25
  {
22
26
  "name": "status",
23
27
  "description": "Show app version."
@@ -476,6 +480,157 @@
476
480
  }
477
481
  }
478
482
  },
483
+ "/shape-area": {
484
+ "post": {
485
+ "tags": [
486
+ "shape-area"
487
+ ],
488
+ "operationId": "_shape-area",
489
+ "summary": "Compute the area of a circle or rectangle (union-input JSON leaf demo).",
490
+ "responses": {
491
+ "201": {
492
+ "description": "Successful invocation",
493
+ "content": {
494
+ "application/json": {
495
+ "schema": {
496
+ "type": "object"
497
+ }
498
+ }
499
+ }
500
+ },
501
+ "400": {
502
+ "description": "Invalid arguments or help requested",
503
+ "content": {
504
+ "application/json; charset=utf-8": {
505
+ "schema": {
506
+ "type": "object",
507
+ "properties": {
508
+ "error": {
509
+ "type": "string"
510
+ }
511
+ },
512
+ "required": [
513
+ "error"
514
+ ]
515
+ }
516
+ }
517
+ }
518
+ },
519
+ "404": {
520
+ "description": "Not found",
521
+ "content": {
522
+ "application/json; charset=utf-8": {
523
+ "schema": {
524
+ "type": "object",
525
+ "properties": {
526
+ "error": {
527
+ "type": "string"
528
+ }
529
+ },
530
+ "required": [
531
+ "error"
532
+ ]
533
+ }
534
+ }
535
+ }
536
+ },
537
+ "500": {
538
+ "description": "Handler error",
539
+ "content": {
540
+ "application/json; charset=utf-8": {
541
+ "schema": {
542
+ "type": "object",
543
+ "properties": {
544
+ "error": {
545
+ "type": "string"
546
+ }
547
+ },
548
+ "required": [
549
+ "error"
550
+ ]
551
+ }
552
+ }
553
+ }
554
+ },
555
+ "503": {
556
+ "description": "Not ready or missing required config",
557
+ "content": {
558
+ "application/json; charset=utf-8": {
559
+ "schema": {
560
+ "type": "object",
561
+ "properties": {
562
+ "error": {
563
+ "type": "string"
564
+ }
565
+ },
566
+ "required": [
567
+ "error"
568
+ ]
569
+ }
570
+ }
571
+ }
572
+ }
573
+ },
574
+ "requestBody": {
575
+ "required": true,
576
+ "content": {
577
+ "application/json; charset=utf-8": {
578
+ "schema": {
579
+ "$schema": "http://json-schema.org/draft-07/schema#",
580
+ "anyOf": [
581
+ {
582
+ "type": "object",
583
+ "properties": {
584
+ "kind": {
585
+ "type": "string",
586
+ "const": "circle",
587
+ "description": "Shape discriminator."
588
+ },
589
+ "radius": {
590
+ "type": "number",
591
+ "description": "Circle radius."
592
+ }
593
+ },
594
+ "required": [
595
+ "kind",
596
+ "radius"
597
+ ],
598
+ "additionalProperties": false,
599
+ "description": "A circle, measured by radius."
600
+ },
601
+ {
602
+ "type": "object",
603
+ "properties": {
604
+ "kind": {
605
+ "type": "string",
606
+ "const": "rect",
607
+ "description": "Shape discriminator."
608
+ },
609
+ "width": {
610
+ "type": "number",
611
+ "description": "Rectangle width."
612
+ },
613
+ "height": {
614
+ "type": "number",
615
+ "description": "Rectangle height."
616
+ }
617
+ },
618
+ "required": [
619
+ "kind",
620
+ "width",
621
+ "height"
622
+ ],
623
+ "additionalProperties": false,
624
+ "description": "A rectangle, measured by width and height."
625
+ }
626
+ ],
627
+ "description": "Shape to measure: a circle or a rectangle."
628
+ }
629
+ }
630
+ }
631
+ }
632
+ }
633
+ },
479
634
  "/status": {
480
635
  "post": {
481
636
  "tags": [
@@ -4,8 +4,10 @@ set shell := ["bash", "-eu", "-o", "pipefail", "-c"]
4
4
  export PATH := justfile_directory() + "/node_modules/.bin:" + env_var("PATH")
5
5
 
6
6
  brew_prefix := `brew --prefix`
7
- tap_parent := brew_prefix + "/Library/Taps/{tapOrg}"
8
- tap_path := tap_parent + "/homebrew-{tapRepo}"
7
+ # Homebrew tap (org/repo); `argsbarg create` rewrites this literal to the new project's tap
8
+ tap := "bdombro/bun-argsbarg"
9
+ tap_parent := brew_prefix + "/Library/Taps/" + replace_regex(tap, "/.*", "")
10
+ tap_path := tap_parent + "/homebrew-" + replace_regex(tap, ".*/", "")
9
11
 
10
12
  # List available recipes (default)
11
13
  _:
@@ -111,7 +113,7 @@ schemagen:
111
113
  # Install bun/npm dependencies and generate schemas
112
114
  setup:
113
115
  bun install
114
- test -f node_modules/argsbarg/bin/argsbarg && ln -sf ../argsbarg/bin/argsbarg node_modules/.bin/argsbarg
116
+ test -f node_modules/argsbarg/bin/argsbarg && ln -sf ../argsbarg/bin/argsbarg node_modules/.bin/argsbarg # argsbarg-dev-only: fix link for file:../.. installs
115
117
  just schemagen
116
118
 
117
119
  # Run unit tests (after check)
@@ -0,0 +1,59 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema#",
3
+ "anyOf": [
4
+ {
5
+ "$ref": "#/definitions/Circle"
6
+ },
7
+ {
8
+ "$ref": "#/definitions/Rect"
9
+ }
10
+ ],
11
+ "description": "Shape to measure: a circle or a rectangle.",
12
+ "definitions": {
13
+ "Circle": {
14
+ "type": "object",
15
+ "properties": {
16
+ "kind": {
17
+ "type": "string",
18
+ "const": "circle",
19
+ "description": "Shape discriminator."
20
+ },
21
+ "radius": {
22
+ "type": "number",
23
+ "description": "Circle radius."
24
+ }
25
+ },
26
+ "required": [
27
+ "kind",
28
+ "radius"
29
+ ],
30
+ "additionalProperties": false,
31
+ "description": "A circle, measured by radius."
32
+ },
33
+ "Rect": {
34
+ "type": "object",
35
+ "properties": {
36
+ "kind": {
37
+ "type": "string",
38
+ "const": "rect",
39
+ "description": "Shape discriminator."
40
+ },
41
+ "width": {
42
+ "type": "number",
43
+ "description": "Rectangle width."
44
+ },
45
+ "height": {
46
+ "type": "number",
47
+ "description": "Rectangle height."
48
+ }
49
+ },
50
+ "required": [
51
+ "kind",
52
+ "width",
53
+ "height"
54
+ ],
55
+ "additionalProperties": false,
56
+ "description": "A rectangle, measured by width and height."
57
+ }
58
+ }
59
+ }
@@ -0,0 +1,5 @@
1
+ // Auto-generated by argsbarg schemagen — do not edit by hand.
2
+
3
+ import ShapeAreaInputSchemaJson from "./ShapeAreaInputSchema.json";
4
+
5
+ export const ShapeAreaInputSchema = ShapeAreaInputSchemaJson as Record<string, unknown>;
@@ -0,0 +1,34 @@
1
+ import { describe, expect, test } from "bun:test";
2
+ import { Cli, type CliProgram } from "argsbarg";
3
+ import { shapeAreaTestProgram } from "./command.ts";
4
+
5
+ const baseProgram = {
6
+ key: "full-example",
7
+ version: "1.0.0",
8
+ description: "Demo.",
9
+ httpServer: { enabled: true },
10
+ commands: [],
11
+ } satisfies CliProgram;
12
+
13
+ describe("shape-area command", () => {
14
+ const cli = new Cli(shapeAreaTestProgram(baseProgram));
15
+
16
+ test("computes the area for each union branch", async () => {
17
+ const rect = await cli.invoke(["shape-area"], {
18
+ invocation: "http",
19
+ toolArgs: { kind: "rect", width: 2, height: 3 },
20
+ });
21
+ expect(rect.response?.body).toEqual({ area: 6 });
22
+
23
+ const circle = await cli.invoke(["shape-area"], { invocation: "http", toolArgs: { kind: "circle", radius: 1 } });
24
+ expect(circle.response?.body).toEqual({ area: Math.PI });
25
+ });
26
+
27
+ test("rejects fields from the wrong branch via inputSchema", async () => {
28
+ const result = await cli.invoke(["shape-area"], {
29
+ invocation: "http",
30
+ toolArgs: { kind: "circle", radius: 1, width: 2 },
31
+ });
32
+ expect(result.kind).toBe("error");
33
+ });
34
+ });