argsbarg 3.3.10 → 3.3.11
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 +8 -1
- package/docs/bundled-docs.md +2 -0
- package/package.json +1 -1
- package/src/builtins/builtins.test.ts +9 -0
- package/src/builtins/presentation.ts +20 -1
- package/src/help.ts +17 -5
- package/src/index.test.ts +44 -0
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [3.3.11] - 2026-06-21
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- **Root help agent hint** — when `docs` is enabled, top-level `-h` includes a Notes line: `Agents: run \`myapp docs skill\` to learn how to use this app`. Root help also renders `program.notes`.
|
|
15
|
+
|
|
10
16
|
## [3.3.10] - 2026-06-21
|
|
11
17
|
|
|
12
18
|
### Changed
|
|
@@ -311,7 +317,8 @@ const cli = { ... } satisfies CliProgram; // or : CliProgram
|
|
|
311
317
|
- Migrate schemas: rename every `children` property to **`commands`**; move positional definitions to **`CliPositional`** objects on `positionals` and strip `positional` / `argMin` / `argMax` from flag definitions under `options` (flags only carry `name`, `description`, `kind`, and optional `shortName`).
|
|
312
318
|
- Imports: use `CliPositional` where needed; replace `CliOptionDef` with `CliOption` or `CliPositional` as appropriate.
|
|
313
319
|
|
|
314
|
-
[Unreleased]: https://github.com/bdombro/bun-argsbarg/compare/v3.3.
|
|
320
|
+
[Unreleased]: https://github.com/bdombro/bun-argsbarg/compare/v3.3.11...HEAD
|
|
321
|
+
[3.3.11]: https://github.com/bdombro/bun-argsbarg/releases/tag/v3.3.11
|
|
315
322
|
[3.3.10]: https://github.com/bdombro/bun-argsbarg/releases/tag/v3.3.10
|
|
316
323
|
[3.3.9]: https://github.com/bdombro/bun-argsbarg/releases/tag/v3.3.9
|
|
317
324
|
[3.3.8]: https://github.com/bdombro/bun-argsbarg/releases/tag/v3.3.8
|
package/docs/bundled-docs.md
CHANGED
|
@@ -35,6 +35,8 @@ myapp docs readme --save # write ./docs/readme.md
|
|
|
35
35
|
myapp docs schema --save # write ./docs/schema.json
|
|
36
36
|
```
|
|
37
37
|
|
|
38
|
+
When `docs` is enabled, top-level `myapp --help` includes a Notes line: `Agents: run \`myapp docs skill\` to learn how to use this app`.
|
|
39
|
+
|
|
38
40
|
## Configuration
|
|
39
41
|
|
|
40
42
|
| Field | Default | Purpose |
|
package/package.json
CHANGED
|
@@ -80,6 +80,15 @@ describe("presentation root", () => {
|
|
|
80
80
|
const root = cliPresentationRoot(fixture);
|
|
81
81
|
expect(root.commands?.map((c) => c.key)).toContain("version");
|
|
82
82
|
});
|
|
83
|
+
|
|
84
|
+
test("root notes include agent hint when docs enabled", () => {
|
|
85
|
+
const withDocs: CliProgram = {
|
|
86
|
+
...fixture,
|
|
87
|
+
docs: { enabled: true, topics: { readme: { text: "# r\n" } } },
|
|
88
|
+
};
|
|
89
|
+
const root = cliPresentationRoot(withDocs);
|
|
90
|
+
expect(root.notes).toContain("Agents: run `myapp docs skill` to learn how to use this app");
|
|
91
|
+
});
|
|
83
92
|
});
|
|
84
93
|
|
|
85
94
|
describe("completion emitters", () => {
|
|
@@ -34,11 +34,13 @@ export function presentationBuiltins(program: CliProgram, caps: CliCapabilities)
|
|
|
34
34
|
export function cliPresentationRoot(program: CliProgram): CliRouter {
|
|
35
35
|
const caps = resolveCapabilities(program);
|
|
36
36
|
const builtins = presentationBuiltins(program, caps);
|
|
37
|
+
const notes = presentationRootNotes(program, caps);
|
|
37
38
|
|
|
38
39
|
if (isCliLeaf(program)) {
|
|
39
40
|
return {
|
|
40
41
|
key: program.key,
|
|
41
42
|
description: program.description,
|
|
43
|
+
notes,
|
|
42
44
|
options: program.options,
|
|
43
45
|
commands: builtins,
|
|
44
46
|
};
|
|
@@ -47,7 +49,7 @@ export function cliPresentationRoot(program: CliProgram): CliRouter {
|
|
|
47
49
|
return {
|
|
48
50
|
key: program.key,
|
|
49
51
|
description: program.description,
|
|
50
|
-
notes
|
|
52
|
+
notes,
|
|
51
53
|
options: program.options,
|
|
52
54
|
fallbackCommand: program.fallbackCommand,
|
|
53
55
|
fallbackMode: program.fallbackMode,
|
|
@@ -55,5 +57,22 @@ export function cliPresentationRoot(program: CliProgram): CliRouter {
|
|
|
55
57
|
};
|
|
56
58
|
}
|
|
57
59
|
|
|
60
|
+
/** Root help notes: consumer `program.notes` plus agent discovery when `docs` is enabled. */
|
|
61
|
+
export function presentationRootNotes(program: CliProgram, caps: CliCapabilities): string | undefined {
|
|
62
|
+
const parts: string[] = [];
|
|
63
|
+
if ((program.notes ?? "").trim().length > 0) {
|
|
64
|
+
parts.push(program.notes!.trim());
|
|
65
|
+
}
|
|
66
|
+
if (caps.docs) {
|
|
67
|
+
const cmd = `${program.key} docs skill`;
|
|
68
|
+
parts.push(`Agents: run \`${cmd}\` to learn how to use this app`);
|
|
69
|
+
}
|
|
70
|
+
if (parts.length === 0) {
|
|
71
|
+
return undefined;
|
|
72
|
+
}
|
|
73
|
+
return parts.join("\n\n");
|
|
74
|
+
}
|
|
75
|
+
|
|
58
76
|
/** Presentation tree may include builtin leaf stubs. */
|
|
59
77
|
export type CliPresentationNode = CliNode | CliLeaf;
|
|
78
|
+
|
package/src/help.ts
CHANGED
|
@@ -381,6 +381,21 @@ function rowsForSubcommands(cmds: CliNode[]): HelpRow[] {
|
|
|
381
381
|
|
|
382
382
|
// ── Main Help Render ──────────────────────────────────────────────────────────
|
|
383
383
|
|
|
384
|
+
function appendNotesBox(
|
|
385
|
+
lines: string[],
|
|
386
|
+
notes: string | undefined,
|
|
387
|
+
appKey: string,
|
|
388
|
+
hw: number,
|
|
389
|
+
color: boolean,
|
|
390
|
+
): void {
|
|
391
|
+
if ((notes ?? "").length === 0) {
|
|
392
|
+
return;
|
|
393
|
+
}
|
|
394
|
+
const resolved = cliResolveNotes(notes!, appKey);
|
|
395
|
+
lines.push("");
|
|
396
|
+
lines.push(renderTextBox("Notes", wrapText(resolved, hw - 4), hw, color).join("\n"));
|
|
397
|
+
}
|
|
398
|
+
|
|
384
399
|
/**
|
|
385
400
|
* Renders full help for the app root or a nested command, following `helpPath` from the root key.
|
|
386
401
|
* `useStderr` is reserved for call-site consistency; width and color use stdout TTY.
|
|
@@ -416,6 +431,7 @@ export function cliHelpRender(schema: CliRouter, helpPath: string[], useStderr:
|
|
|
416
431
|
renderTableBox("Commands", rowsForSubcommands(schema.commands ?? []), hw, color).join("\n"),
|
|
417
432
|
);
|
|
418
433
|
}
|
|
434
|
+
appendNotesBox(lines, schema.notes, schema.key, hw, color);
|
|
419
435
|
return lines.join("\n") + "\n\n";
|
|
420
436
|
}
|
|
421
437
|
|
|
@@ -479,11 +495,7 @@ export function cliHelpRender(schema: CliRouter, helpPath: string[], useStderr:
|
|
|
479
495
|
}
|
|
480
496
|
|
|
481
497
|
if ((node.notes ?? "").length > 0) {
|
|
482
|
-
|
|
483
|
-
lines.push("");
|
|
484
|
-
lines.push(
|
|
485
|
-
renderTextBox("Notes", wrapText(resolved, hw - 4), hw, color).join("\n"),
|
|
486
|
-
);
|
|
498
|
+
appendNotesBox(lines, node.notes, schema.key, hw, color);
|
|
487
499
|
}
|
|
488
500
|
|
|
489
501
|
return lines.join("\n") + "\n\n";
|
package/src/index.test.ts
CHANGED
|
@@ -678,6 +678,50 @@ test("root help omits legacy --schema flag", () => {
|
|
|
678
678
|
expect(help).not.toContain("--schema");
|
|
679
679
|
});
|
|
680
680
|
|
|
681
|
+
test("root help shows agent docs hint when docs enabled", () => {
|
|
682
|
+
const root = testProgram({
|
|
683
|
+
key: "myapp",
|
|
684
|
+
version: "1.0.0",
|
|
685
|
+
description: "demo",
|
|
686
|
+
docs: {
|
|
687
|
+
enabled: true,
|
|
688
|
+
topics: { readme: { text: "# readme\n" } },
|
|
689
|
+
},
|
|
690
|
+
commands: [{ key: "run", description: "Run.", handler: () => {} }],
|
|
691
|
+
});
|
|
692
|
+
const help = cliHelpRender(cliPresentationRoot(root), [], false);
|
|
693
|
+
expect(help).toContain("Agents: run `myapp docs skill` to learn how to use this app");
|
|
694
|
+
});
|
|
695
|
+
|
|
696
|
+
test("root help omits agent hint when docs disabled", () => {
|
|
697
|
+
const root = testProgram({
|
|
698
|
+
key: "myapp",
|
|
699
|
+
version: "1.0.0",
|
|
700
|
+
description: "demo",
|
|
701
|
+
commands: [{ key: "run", description: "Run.", handler: () => {} }],
|
|
702
|
+
});
|
|
703
|
+
const help = cliHelpRender(cliPresentationRoot(root), [], false);
|
|
704
|
+
expect(help).not.toContain("Agents:");
|
|
705
|
+
expect(help).not.toContain("docs skill");
|
|
706
|
+
});
|
|
707
|
+
|
|
708
|
+
test("root help includes program notes and agent hint", () => {
|
|
709
|
+
const root = testProgram({
|
|
710
|
+
key: "myapp",
|
|
711
|
+
version: "1.0.0",
|
|
712
|
+
description: "demo",
|
|
713
|
+
notes: "See `{argsbarg:program} docs readme` for the user guide.",
|
|
714
|
+
docs: {
|
|
715
|
+
enabled: true,
|
|
716
|
+
topics: { readme: { text: "# readme\n" } },
|
|
717
|
+
},
|
|
718
|
+
commands: [{ key: "run", description: "Run.", handler: () => {} }],
|
|
719
|
+
});
|
|
720
|
+
const help = cliHelpRender(cliPresentationRoot(root), [], false);
|
|
721
|
+
expect(help).toContain("See `myapp docs readme` for the user guide.");
|
|
722
|
+
expect(help).toContain("myapp docs skill");
|
|
723
|
+
});
|
|
724
|
+
|
|
681
725
|
const nestedMcpFixture = testProgram({
|
|
682
726
|
key: "nested.ts",
|
|
683
727
|
description: "Nested groups demo.",
|