@clidoc/cli 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +86 -0
  3. package/dist/bin.d.ts +3 -0
  4. package/dist/bin.d.ts.map +1 -0
  5. package/dist/bin.js +14 -0
  6. package/dist/bin.js.map +1 -0
  7. package/dist/commands/completion.d.ts +10 -0
  8. package/dist/commands/completion.d.ts.map +1 -0
  9. package/dist/commands/completion.js +24 -0
  10. package/dist/commands/completion.js.map +1 -0
  11. package/dist/commands/docgen.d.ts +6 -0
  12. package/dist/commands/docgen.d.ts.map +1 -0
  13. package/dist/commands/docgen.js +19 -0
  14. package/dist/commands/docgen.js.map +1 -0
  15. package/dist/commands/generate.d.ts +8 -0
  16. package/dist/commands/generate.d.ts.map +1 -0
  17. package/dist/commands/generate.js +40 -0
  18. package/dist/commands/generate.js.map +1 -0
  19. package/dist/commands/markdown.d.ts +6 -0
  20. package/dist/commands/markdown.d.ts.map +1 -0
  21. package/dist/commands/markdown.js +15 -0
  22. package/dist/commands/markdown.js.map +1 -0
  23. package/dist/commands/mcp.d.ts +16 -0
  24. package/dist/commands/mcp.d.ts.map +1 -0
  25. package/dist/commands/mcp.js +39 -0
  26. package/dist/commands/mcp.js.map +1 -0
  27. package/dist/commands/validate.d.ts +4 -0
  28. package/dist/commands/validate.d.ts.map +1 -0
  29. package/dist/commands/validate.js +17 -0
  30. package/dist/commands/validate.js.map +1 -0
  31. package/dist/definition.d.ts +48 -0
  32. package/dist/definition.d.ts.map +1 -0
  33. package/dist/definition.js +28 -0
  34. package/dist/definition.js.map +1 -0
  35. package/dist/index.d.ts +4 -0
  36. package/dist/index.d.ts.map +1 -0
  37. package/dist/index.js +21 -0
  38. package/dist/index.js.map +1 -0
  39. package/dist/io.d.ts +2 -0
  40. package/dist/io.d.ts.map +1 -0
  41. package/dist/io.js +12 -0
  42. package/dist/io.js.map +1 -0
  43. package/dist/mcp/compile.d.ts +10 -0
  44. package/dist/mcp/compile.d.ts.map +1 -0
  45. package/dist/mcp/compile.js +133 -0
  46. package/dist/mcp/compile.js.map +1 -0
  47. package/dist/mcp/index.d.ts +15 -0
  48. package/dist/mcp/index.d.ts.map +1 -0
  49. package/dist/mcp/index.js +133 -0
  50. package/dist/mcp/index.js.map +1 -0
  51. package/package.json +72 -0
  52. package/src/bin.ts +12 -0
  53. package/src/commands/completion.ts +28 -0
  54. package/src/commands/docgen.ts +21 -0
  55. package/src/commands/generate.ts +42 -0
  56. package/src/commands/markdown.ts +16 -0
  57. package/src/commands/mcp.ts +42 -0
  58. package/src/commands/validate.ts +18 -0
  59. package/src/definition.ts +29 -0
  60. package/src/index.ts +21 -0
  61. package/src/io.ts +12 -0
  62. package/src/mcp/compile.ts +126 -0
  63. package/src/mcp/index.ts +137 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Ben Houston
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,86 @@
1
+ # @clidoc/cli
2
+
3
+ [![npm version](https://img.shields.io/npm/v/%40clidoc%2Fcli)](https://www.npmjs.com/package/@clidoc/cli)
4
+ [![npm downloads](https://img.shields.io/npm/dw/%40clidoc%2Fcli)](https://www.npmjs.com/package/@clidoc/cli)
5
+ [![CI](https://github.com/bhouston/clidoc/actions/workflows/ci.yml/badge.svg)](https://github.com/bhouston/clidoc/actions/workflows/ci.yml)
6
+ [![Coverage](https://codecov.io/gh/bhouston/clidoc/graph/badge.svg)](https://codecov.io/gh/bhouston/clidoc)
7
+ [![Documentation](https://img.shields.io/badge/docs-clidoc.dev-blue)](https://clidoc.dev)
8
+
9
+ Generate OpenCLI JSON from framework metadata, validate JSON/YAML documents, and
10
+ render Markdown. Node 22.12+; ESM only.
11
+
12
+ The CLI being documented should provide its own `docgen` command, the human-facing
13
+ entry point. Install clidoc globally to validate and render the resulting file:
14
+
15
+ ```sh
16
+ npm install -g @clidoc/cli
17
+ mycli docgen --output cli.json
18
+ clidoc validate cli.json
19
+ clidoc markdown cli.json --output reference.md
20
+ ```
21
+
22
+ `mycli __opencli` is the hidden, machine-facing discovery subcommand, matching
23
+ upstream OpenCLI's Go adapters, including its `-o`/`--out <file>` flag
24
+ (`mycli __opencli --out cli.json`); omitted, it writes to stdout like
25
+ `clidoc docgen`/`clidoc generate`/`clidoc markdown` do when their own
26
+ `--output` is omitted. clidoc dogfoods this exact workflow on itself:
27
+ `clidoc docgen` and `clidoc __opencli` both describe the `clidoc` binary. As a
28
+ secondary option, trusted command definitions can be imported with
29
+ `clidoc generate ./definition.mjs --adapter yargs --output cli.json`. Invalid
30
+ input or command usage exits with status 1. `--help` describes command
31
+ arguments, and `--version` prints the installed package version.
32
+
33
+ The generation module must export `info` (`title`, `binary`, `version`) and a
34
+ default value: Yargs command modules, a Commander `Command`, or an oclif manifest.
35
+ Only import trusted modules: their top-level code and supported Yargs builder
36
+ callbacks execute during generation. Command handlers are never invoked.
37
+
38
+ Commands are separate files registered through `yargs-file-commands`, matching
39
+ the `hdrify` approach. `cliDocument()` derives this tool's OpenCLI document from
40
+ those same definitions. `runCli(argv)` supports embedding without exiting the
41
+ calling process; it rejects on invalid input.
42
+
43
+ See the [repository guide](../../README.md) and
44
+ [generated command reference](../../docs/generated/cli.md).
45
+
46
+ ## Shell completion
47
+
48
+ Generate standalone Bash, Zsh, and Fish scripts for clidoc or any validated OpenCLI
49
+ JSON/YAML document:
50
+
51
+ ```sh
52
+ clidoc completion bash # clidoc itself; script on stdout
53
+ clidoc completion zsh -i mycli.json -o mycli.zsh
54
+ clidoc completion fish -o ~/.config/fish/completions/clidoc.fish
55
+ ```
56
+
57
+ For Bash, activate with `source <(clidoc completion bash)`. For Zsh, run
58
+ `source <(clidoc completion zsh)` after `autoload -Uz compinit; compinit`.
59
+ Use `--binary name` to register an alternative executable name. Generated scripts
60
+ need neither Node nor clidoc at completion time. Regenerate them after CLI changes.
61
+ See the [completion guide](https://clidoc.dev/docs/guides/completion) for
62
+ persistent installation, supported syntax, and limitations.
63
+
64
+ ## MCP tools and stdio server
65
+
66
+ ```sh
67
+ clidoc mcp cli.json --output tools.json
68
+ clidoc mcp cli.json --serve --executable /absolute/path/to/mycli
69
+ ```
70
+
71
+ Exporting does not execute the CLI. Serving requires an explicit trusted
72
+ executable and validates every tool invocation. The bridge uses conventional
73
+ long options and `--` before positional arguments; see the
74
+ [MCP guide](../website/docs/guides/mcp.md) for the serialization contract,
75
+ client configuration, limits, and supported spec features.
76
+
77
+ Library users can import `compileMcpTools`, `createMcpServer`, and `serveMcp`
78
+ from `@clidoc/cli/mcp`.
79
+
80
+ ## License
81
+
82
+ MIT. See [LICENSE](../../LICENSE).
83
+
84
+ ## Author
85
+
86
+ [Ben Houston](https://ben3d.ca), Sponsored by [Land of Assets](https://landofassets.com).
package/dist/bin.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ export {};
3
+ //# sourceMappingURL=bin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bin.d.ts","sourceRoot":"","sources":["../src/bin.ts"],"names":[],"mappings":""}
package/dist/bin.js ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env node
2
+ import { hideBin } from 'yargs/helpers';
3
+ import { handleOpenCliRequest } from '@clidoc/core';
4
+ import { cliDocument, runCli } from './index.js';
5
+ try {
6
+ const argv = hideBin(process.argv);
7
+ if (!(await handleOpenCliRequest(argv, cliDocument)))
8
+ await runCli(argv);
9
+ }
10
+ catch (error) {
11
+ console.error(error instanceof Error ? error.message : String(error));
12
+ process.exitCode = 1;
13
+ }
14
+ //# sourceMappingURL=bin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bin.js","sourceRoot":"","sources":["../src/bin.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAEjD,IAAI,CAAC;IACH,MAAM,IAAI,GAAG,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IACnC,IAAI,CAAC,CAAC,MAAM,oBAAoB,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC;QAAE,MAAM,MAAM,CAAC,IAAI,CAAC,CAAC;AAC3E,CAAC;AAAC,OAAO,KAAK,EAAE,CAAC;IACf,OAAO,CAAC,KAAK,CAAC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;IACtE,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;AACvB,CAAC"}
@@ -0,0 +1,10 @@
1
+ export declare const command: import("yargs-file-commands").DefineCommandResult<{}, {
2
+ shell: "bash" | "fish" | "zsh";
3
+ } & {
4
+ input: string | undefined;
5
+ } & {
6
+ binary: string | undefined;
7
+ } & {
8
+ output: string | undefined;
9
+ }>;
10
+ //# sourceMappingURL=completion.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"completion.d.ts","sourceRoot":"","sources":["../../src/commands/completion.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,OAAO;;;;;;;;EAqBlB,CAAC"}
@@ -0,0 +1,24 @@
1
+ import { readFile } from 'node:fs/promises';
2
+ import { generateCompletion, parse } from '@clidoc/core';
3
+ import { defineCommand } from 'yargs-file-commands';
4
+ import { cliDocument } from '../definition.js';
5
+ import { output } from '../io.js';
6
+ export const command = defineCommand({
7
+ command: 'completion <shell>',
8
+ describe: 'Generate a standalone shell completion script',
9
+ builder: (yargs) => yargs
10
+ .positional('shell', {
11
+ type: 'string',
12
+ choices: ['bash', 'zsh', 'fish'],
13
+ demandOption: true,
14
+ describe: 'Target shell',
15
+ })
16
+ .option('input', { type: 'string', alias: 'i', describe: 'OpenCLI JSON or YAML file; defaults to clidoc itself' })
17
+ .option('binary', { type: 'string', describe: 'Executable name override for completion registration' })
18
+ .option('output', { type: 'string', alias: 'o', describe: 'Output file; defaults to stdout' }),
19
+ handler: async (argv) => {
20
+ const document = argv.input ? parse(await readFile(argv.input, 'utf8')) : cliDocument();
21
+ await output(generateCompletion(document, { shell: argv.shell, binary: argv.binary }), argv.output);
22
+ },
23
+ });
24
+ //# sourceMappingURL=completion.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"completion.js","sourceRoot":"","sources":["../../src/commands/completion.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,kBAAkB,EAAE,KAAK,EAAwB,MAAM,cAAc,CAAC;AAC/E,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OA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}>;
6
+ //# sourceMappingURL=docgen.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"docgen.d.ts","sourceRoot":"","sources":["../../src/commands/docgen.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,OAAO;;;;EAelB,CAAC"}
@@ -0,0 +1,19 @@
1
+ import { writeOpenCliDocument } from '@clidoc/core';
2
+ import { defineCommand } from 'yargs-file-commands';
3
+ import { cliDocument } from '../definition.js';
4
+ export const command = defineCommand({
5
+ command: 'docgen',
6
+ describe: 'Write clidoc’s own OpenCLI document',
7
+ builder: (yargs) => yargs
8
+ .option('format', {
9
+ type: 'string',
10
+ choices: ['json', 'yaml', 'markdown'],
11
+ default: 'json',
12
+ describe: 'Output format',
13
+ })
14
+ .option('output', { type: 'string', alias: 'o', describe: 'Output file; defaults to stdout' }),
15
+ handler: async (argv) => {
16
+ await writeOpenCliDocument(cliDocument(), argv.output, argv.format);
17
+ },
18
+ });
19
+ //# sourceMappingURL=docgen.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"docgen.js","sourceRoot":"","sources":["../../src/commands/docgen.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAEpD,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE/C,MAAM,CAAC,MAAM,OAAO,GAAG,aAAa,CAAC;IACnC,OAAO,EAAE,QAAQ;IACjB,QAAQ,EAAE,qCAAqC;IAC/C,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE,CACjB,KAAK;SACF,MAAM,CAAC,QAAQ,EAAE;QAChB,IAAI,EAAE,QAAQ;QACd,OAAO,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,UAAU,CAAU;QAC9C,OAAO,EAAE,MAAM;QACf,QAAQ,EAAE,eAAe;KAC1B,CAAC;SACD,MAAM,CAAC,QAAQ,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,GAAG,EAAE,QAAQ,EAAE,iCAAiC,EAAE,CAAC;IAClG,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE;QACtB,MAAM,oBAAoB,CAAC,WAAW,EAAE,EAAE,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,MAAwB,CAAC,CAAC;IACxF,CAAC;CACF,CAAC,CAAC"}
@@ -0,0 +1,8 @@
1
+ export declare const command: import("yargs-file-commands").DefineCommandResult<{}, {
2
+ module: string;
3
+ } & {
4
+ adapter: "commander" | "oclif" | "yargs";
5
+ } & {
6
+ output: string | undefined;
7
+ }>;
8
+ //# sourceMappingURL=generate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generate.d.ts","sourceRoot":"","sources":["../../src/commands/generate.ts"],"names":[],"mappings":"AASA,eAAO,MAAM,OAAO;;;;;;EAgClB,CAAC"}
@@ -0,0 +1,40 @@
1
+ import { resolve } from 'node:path';
2
+ import { pathToFileURL } from 'node:url';
3
+ import { parse } from '@clidoc/core';
4
+ import { fromYargs } from '@clidoc/adapter-yargs';
5
+ import { fromCommander } from '@clidoc/adapter-commander';
6
+ import { fromOclif } from '@clidoc/adapter-oclif';
7
+ import { defineCommand } from 'yargs-file-commands';
8
+ import { output } from '../io.js';
9
+ export const command = defineCommand({
10
+ command: 'generate <module>',
11
+ describe: 'Import a trusted framework definition module and generate OpenCLI JSON',
12
+ builder: (yargs) => yargs
13
+ .positional('module', {
14
+ type: 'string',
15
+ demandOption: true,
16
+ describe: 'Trusted JS module exporting default metadata and info',
17
+ })
18
+ .option('adapter', {
19
+ type: 'string',
20
+ choices: ['yargs', 'commander', 'oclif'],
21
+ demandOption: true,
22
+ describe: 'Framework adapter',
23
+ })
24
+ .option('output', { type: 'string', alias: 'o', describe: 'Output JSON file; defaults to stdout' }),
25
+ handler: async (argv) => {
26
+ // Importing code is intentional: this command accepts trusted local modules only.
27
+ const source = await import(pathToFileURL(resolve(argv.module)).href);
28
+ if (!source.default || !source.info)
29
+ throw new Error('Module must export default framework metadata and named info');
30
+ const document = argv.adapter === 'yargs'
31
+ ? fromYargs(source.default, source.info)
32
+ : argv.adapter === 'commander'
33
+ ? fromCommander(source.default, source.info)
34
+ : fromOclif(source.default, source.info);
35
+ const json = JSON.stringify(document, null, 2) + '\n';
36
+ parse(json);
37
+ await output(json, argv.output);
38
+ },
39
+ });
40
+ //# sourceMappingURL=generate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generate.js","sourceRoot":"","sources":["../../src/commands/generate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AACrC,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,MAAM,CAAC,MAAM,OAAO,GAAG,aAAa,CAAC;IACnC,OAAO,EAAE,mBAAmB;IAC5B,QAAQ,EAAE,wEAAwE;IAClF,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE,CACjB,KAAK;SACF,UAAU,CAAC,QAAQ,EAAE;QACpB,IAAI,EAAE,QAAQ;QACd,YAAY,EAAE,IAAI;QAClB,QAAQ,EAAE,uDAAuD;KAClE,CAAC;SACD,MAAM,CAAC,SAAS,EAAE;QACjB,IAAI,EAAE,QAAQ;QACd,OAAO,EAAE,CAAC,OAAO,EAAE,WAAW,EAAE,OAAO,CAAU;QACjD,YAAY,EAAE,IAAI;QAClB,QAAQ,EAAE,mBAAmB;KAC9B,CAAC;SACD,MAAM,CAAC,QAAQ,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,GAAG,EAAE,QAAQ,EAAE,sCAAsC,EAAE,CAAC;IACvG,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE;QACtB,kFAAkF;QAClF,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,aAAa,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;QACtE,IAAI,CAAC,MAAM,CAAC,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI;YACjC,MAAM,IAAI,KAAK,CAAC,8DAA8D,CAAC,CAAC;QAClF,MAAM,QAAQ,GACZ,IAAI,CAAC,OAAO,KAAK,OAAO;YACtB,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,IAAI,CAAC;YACxC,CAAC,CAAC,IAAI,CAAC,OAAO,KAAK,WAAW;gBAC5B,CAAC,CAAC,aAAa,CAAC,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,IAAI,CAAC;gBAC5C,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC;QAC/C,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,GAAG,IAAI,CAAC;QACtD,KAAK,CAAC,IAAI,CAAC,CAAC;QACZ,MAAM,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;IAClC,CAAC;CACF,CAAC,CAAC"}
@@ -0,0 +1,6 @@
1
+ export declare const command: import("yargs-file-commands").DefineCommandResult<{}, {
2
+ input: string;
3
+ } & {
4
+ output: string | undefined;
5
+ }>;
6
+ //# sourceMappingURL=markdown.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"markdown.d.ts","sourceRoot":"","sources":["../../src/commands/markdown.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,OAAO;;;;EAUlB,CAAC"}
@@ -0,0 +1,15 @@
1
+ import { readFile } from 'node:fs/promises';
2
+ import { parse, renderMarkdown } from '@clidoc/core';
3
+ import { defineCommand } from 'yargs-file-commands';
4
+ import { output } from '../io.js';
5
+ export const command = defineCommand({
6
+ command: 'markdown <input>',
7
+ describe: 'Render an OpenCLI document as Markdown',
8
+ builder: (yargs) => yargs
9
+ .positional('input', { type: 'string', demandOption: true, describe: 'OpenCLI JSON or YAML filename' })
10
+ .option('output', { type: 'string', alias: 'o', describe: 'Output file; defaults to stdout' }),
11
+ handler: async (argv) => {
12
+ await output(renderMarkdown(parse(await readFile(argv.input, 'utf8'))), argv.output);
13
+ },
14
+ });
15
+ //# sourceMappingURL=markdown.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"markdown.js","sourceRoot":"","sources":["../../src/commands/markdown.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,MAAM,CAAC,MAAM,OAAO,GAAG,aAAa,CAAC;IACnC,OAAO,EAAE,kBAAkB;IAC3B,QAAQ,EAAE,wCAAwC;IAClD,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE,CACjB,KAAK;SACF,UAAU,CAAC,OAAO,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,YAAY,EAAE,IAAI,EAAE,QAAQ,EAAE,+BAA+B,EAAE,CAAC;SACtG,MAAM,CAAC,QAAQ,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,GAAG,EAAE,QAAQ,EAAE,iCAAiC,EAAE,CAAC;IAClG,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE;QACtB,MAAM,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,MAAM,QAAQ,CAAC,IAAI,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;IACvF,CAAC;CACF,CAAC,CAAC"}
@@ -0,0 +1,16 @@
1
+ export declare const command: import("yargs-file-commands").DefineCommandResult<{}, {
2
+ input: string;
3
+ } & {
4
+ output: string | undefined;
5
+ } & {
6
+ serve: boolean;
7
+ } & {
8
+ executable: string | undefined;
9
+ } & {
10
+ cwd: string | undefined;
11
+ } & {
12
+ "timeout-ms": number | undefined;
13
+ } & {
14
+ "max-output-bytes": number | undefined;
15
+ }>;
16
+ //# sourceMappingURL=mcp.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mcp.d.ts","sourceRoot":"","sources":["../../src/commands/mcp.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,OAAO;;;;;;;;;;;;;;EAmClB,CAAC"}
@@ -0,0 +1,39 @@
1
+ import { readFile } from 'node:fs/promises';
2
+ import { parse } from '@clidoc/core';
3
+ import { defineCommand } from 'yargs-file-commands';
4
+ import { compileMcpTools, serveMcp } from '../mcp/index.js';
5
+ import { output } from '../io.js';
6
+ export const command = defineCommand({
7
+ command: 'mcp <input>',
8
+ describe: 'Export MCP tools or serve a trusted CLI over MCP stdio',
9
+ builder: (yargs) => yargs
10
+ .positional('input', { type: 'string', demandOption: true, describe: 'OpenCLI JSON or YAML filename' })
11
+ .option('output', { type: 'string', alias: 'o', describe: 'Tool catalog output file; defaults to stdout' })
12
+ .option('serve', { type: 'boolean', default: false, describe: 'Serve MCP over stdin/stdout' })
13
+ .option('executable', { type: 'string', describe: 'Trusted executable to run; required with --serve' })
14
+ .option('cwd', { type: 'string', describe: 'Working directory for CLI invocations' })
15
+ .option('timeout-ms', { type: 'number', describe: 'Invocation timeout in milliseconds (default: 30000)' })
16
+ .option('max-output-bytes', { type: 'number', describe: 'Combined stdout/stderr limit (default: 1048576)' }),
17
+ handler: async (argv) => {
18
+ if (argv.serve && argv.output)
19
+ throw new Error('--output cannot be used with --serve');
20
+ if (argv.serve && !argv.executable)
21
+ throw new Error('--serve requires --executable');
22
+ if (!argv.serve &&
23
+ [argv.executable, argv.cwd, argv.timeoutMs, argv.maxOutputBytes].some((value) => value !== undefined))
24
+ throw new Error('Execution options require --serve');
25
+ const document = parse(await readFile(argv.input, 'utf8'));
26
+ if (argv.serve) {
27
+ await serveMcp(document, {
28
+ executable: argv.executable,
29
+ cwd: argv.cwd,
30
+ timeoutMs: argv.timeoutMs,
31
+ maxOutputBytes: argv.maxOutputBytes,
32
+ });
33
+ }
34
+ else {
35
+ await output(JSON.stringify({ tools: compileMcpTools(document).map((entry) => entry.tool) }, null, 2) + '\n', argv.output);
36
+ }
37
+ },
38
+ });
39
+ //# sourceMappingURL=mcp.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mcp.js","sourceRoot":"","sources":["../../src/commands/mcp.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AACrC,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC5D,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,MAAM,CAAC,MAAM,OAAO,GAAG,aAAa,CAAC;IACnC,OAAO,EAAE,aAAa;IACtB,QAAQ,EAAE,wDAAwD;IAClE,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE,CACjB,KAAK;SACF,UAAU,CAAC,OAAO,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,YAAY,EAAE,IAAI,EAAE,QAAQ,EAAE,+BAA+B,EAAE,CAAC;SACtG,MAAM,CAAC,QAAQ,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,GAAG,EAAE,Q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AC,QAAQ,EAAE;gBACvB,UAAU,EAAE,IAAI,CAAC,UAAW;gBAC5B,GAAG,EAAE,IAAI,CAAC,GAAG;gBACb,SAAS,EAAE,IAAI,CAAC,SAAS;gBACzB,cAAc,EAAE,IAAI,CAAC,cAAc;aACpC,CAAC,CAAC;QACL,CAAC;aAAM,CAAC;YACN,MAAM,MAAM,CACV,IAAI,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,eAAe,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,GAAG,IAAI,EAC/F,IAAI,CAAC,MAAM,CACZ,CAAC;QACJ,CAAC;IACH,CAAC;CACF,CAAC,CAAC"}
@@ -0,0 +1,4 @@
1
+ export declare const command: import("yargs-file-commands").DefineCommandResult<{}, {
2
+ input: string;
3
+ }>;
4
+ //# sourceMappingURL=validate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../../src/commands/validate.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,OAAO;;EAalB,CAAC"}
@@ -0,0 +1,17 @@
1
+ import { readFile } from 'node:fs/promises';
2
+ import { parse } from '@clidoc/core';
3
+ import { defineCommand } from 'yargs-file-commands';
4
+ export const command = defineCommand({
5
+ command: 'validate <input>',
6
+ describe: 'Validate an OpenCLI JSON or YAML document',
7
+ builder: (yargs) => yargs.positional('input', {
8
+ type: 'string',
9
+ demandOption: true,
10
+ describe: 'OpenCLI document filename',
11
+ }),
12
+ handler: async ({ input }) => {
13
+ parse(await readFile(input, 'utf8'));
14
+ process.stdout.write('Valid OpenCLI document\n');
15
+ },
16
+ });
17
+ //# sourceMappingURL=validate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validate.js","sourceRoot":"","sources":["../../src/commands/validate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AACrC,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD,MAAM,CAAC,MAAM,OAAO,GAAG,aAAa,CAAC;IACnC,OAAO,EAAE,kBAAkB;IAC3B,QAAQ,EAAE,2CAA2C;IACrD,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE,CACjB,KAAK,CAAC,UAAU,CAAC,OAAO,EAAE;QACxB,IAAI,EAAE,QAAQ;QACd,YAAY,EAAE,IAAI;QAClB,QAAQ,EAAE,2BAA2B;KACtC,CAAC;IACJ,OAAO,EAAE,KAAK,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE;QAC3B,KAAK,CAAC,MAAM,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC;QACrC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,0BAA0B,CAAC,CAAC;IACnD,CAAC;CACF,CAAC,CAAC"}
@@ -0,0 +1,48 @@
1
+ export declare const info: {
2
+ title: string;
3
+ binary: string;
4
+ version: string;
5
+ summary: string;
6
+ };
7
+ export declare const commands: (import("yargs-file-commands").DefineCommandResult<{}, {
8
+ input: string;
9
+ }> | import("yargs-file-commands").DefineCommandResult<{}, {
10
+ format: string;
11
+ } & {
12
+ output: string | undefined;
13
+ }> | import("yargs-file-commands").DefineCommandResult<{}, {
14
+ input: string;
15
+ } & {
16
+ output: string | undefined;
17
+ }> | import("yargs-file-commands").DefineCommandResult<{}, {
18
+ module: string;
19
+ } & {
20
+ adapter: "commander" | "oclif" | "yargs";
21
+ } & {
22
+ output: string | undefined;
23
+ }> | import("yargs-file-commands").DefineCommandResult<{}, {
24
+ shell: "bash" | "fish" | "zsh";
25
+ } & {
26
+ input: string | undefined;
27
+ } & {
28
+ binary: string | undefined;
29
+ } & {
30
+ output: string | undefined;
31
+ }> | import("yargs-file-commands").DefineCommandResult<{}, {
32
+ input: string;
33
+ } & {
34
+ output: string | undefined;
35
+ } & {
36
+ serve: boolean;
37
+ } & {
38
+ executable: string | undefined;
39
+ } & {
40
+ cwd: string | undefined;
41
+ } & {
42
+ "timeout-ms": number | undefined;
43
+ } & {
44
+ "max-output-bytes": number | undefined;
45
+ }>)[];
46
+ /** Documentation and runtime share the exact same command definitions. */
47
+ export declare function cliDocument(): import("@clidoc/core").OpenCliDocument;
48
+ //# sourceMappingURL=definition.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"definition.d.ts","sourceRoot":"","sources":["../src/definition.ts"],"names":[],"mappings":"AAWA,eAAO,MAAM,IAAI;IACf,KAAK;IACL,MAAM;IACN,OAAO;IACP,OAAO;CACR,CAAC;AACF,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAA0D,CAAC;AAChF,0EAA0E;AAC1E,wBAAgB,WAAW,2CAS1B"}
@@ -0,0 +1,28 @@
1
+ import { createRequire } from 'node:module';
2
+ import { fromYargs } from '@clidoc/adapter-yargs';
3
+ import { command as completion } from './commands/completion.js';
4
+ import { command as docgen } from './commands/docgen.js';
5
+ import { command as generate } from './commands/generate.js';
6
+ import { command as mcp } from './commands/mcp.js';
7
+ import { command as markdown } from './commands/markdown.js';
8
+ import { command as validate } from './commands/validate.js';
9
+ const packageJson = createRequire(import.meta.url)('../package.json');
10
+ export const info = {
11
+ title: 'clidoc',
12
+ binary: 'clidoc',
13
+ version: packageJson.version,
14
+ summary: 'Generate, validate, and publish CLI documentation through OpenCLI.',
15
+ };
16
+ export const commands = [generate, markdown, validate, docgen, completion, mcp];
17
+ /** Documentation and runtime share the exact same command definitions. */
18
+ export function cliDocument() {
19
+ const document = fromYargs(commands, info);
20
+ document.global = {
21
+ flags: [
22
+ { name: 'help', type: 'boolean', summary: 'Show help' },
23
+ { name: 'version', type: 'boolean', summary: 'Show version number' },
24
+ ],
25
+ };
26
+ return document;
27
+ }
28
+ //# sourceMappingURL=definition.js.map
@@ -0,0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EAAE,OAAO,EAAE,qBAAqB,EAAE;SACrE;KACF,CAAC;IACF,OAAO,QAAQ,CAAC;AAClB,CAAC"}
@@ -0,0 +1,4 @@
1
+ export { cliDocument } from './definition.js';
2
+ /** Run without terminating the embedding process. Commands live in individual files. */
3
+ export declare function runCli(argv: string[]): Promise<void>;
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAE9C,wFAAwF;AACxF,wBAAsB,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAa1D"}
package/dist/index.js ADDED
@@ -0,0 +1,21 @@
1
+ import { fileURLToPath } from 'node:url';
2
+ import yargs from 'yargs';
3
+ import { fileCommands } from 'yargs-file-commands';
4
+ import { info } from './definition.js';
5
+ export { cliDocument } from './definition.js';
6
+ /** Run without terminating the embedding process. Commands live in individual files. */
7
+ export async function runCli(argv) {
8
+ await yargs(argv)
9
+ .scriptName('clidoc')
10
+ .command(await fileCommands({ commandDirs: [fileURLToPath(new URL('./commands', import.meta.url))] }))
11
+ .demandCommand(1)
12
+ .strict()
13
+ .help()
14
+ .version(info.version)
15
+ .exitProcess(false)
16
+ .fail((message, error) => {
17
+ throw error ?? new Error(message);
18
+ })
19
+ .parseAsync();
20
+ }
21
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AACvC,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAE9C,wFAAwF;AACxF,MAAM,CAAC,KAAK,UAAU,MAAM,CAAC,IAAc;IACzC,MAAM,KAAK,CAAC,IAAI,CAAC;SACd,UAAU,CAAC,QAAQ,CAAC;SACpB,OAAO,CAAC,MAAM,YAAY,CAAC,EAAE,WAAW,EAAE,CAAC,aAAa,CAAC,IAAI,GAAG,CAAC,YAAY,EAAE,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;SACrG,aAAa,CAAC,CAAC,CAAC;SAChB,MAAM,EAAE;SACR,IAAI,EAAE;SACN,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC;SACrB,WAAW,CAAC,KAAK,CAAC;SAClB,IAAI,CAAC,CAAC,OAAO,EAAE,KAAK,EAAE,EAAE;QACvB,MAAM,KAAK,IAAI,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC;IACpC,CAAC,CAAC;SACD,UAAU,EAAE,CAAC;AAClB,CAAC"}
package/dist/io.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export declare function output(content: string, filename?: string): Promise<void>;
2
+ //# sourceMappingURL=io.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"io.d.ts","sourceRoot":"","sources":["../src/io.ts"],"names":[],"mappings":"AAGA,wBAAsB,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAQ9E"}
package/dist/io.js ADDED
@@ -0,0 +1,12 @@
1
+ import { mkdir, writeFile } from 'node:fs/promises';
2
+ import { dirname, resolve } from 'node:path';
3
+ export async function output(content, filename) {
4
+ if (!filename) {
5
+ process.stdout.write(content);
6
+ return;
7
+ }
8
+ const destination = resolve(filename);
9
+ await mkdir(dirname(destination), { recursive: true });
10
+ await writeFile(destination, content);
11
+ }
12
+ //# sourceMappingURL=io.js.map
package/dist/io.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"io.js","sourceRoot":"","sources":["../src/io.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAE7C,MAAM,CAAC,KAAK,UAAU,MAAM,CAAC,OAAe,EAAE,QAAiB;IAC7D,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QAC9B,OAAO;IACT,CAAC;IACD,MAAM,WAAW,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;IACtC,MAAM,KAAK,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IACvD,MAAM,SAAS,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;AACxC,CAAC"}
@@ -0,0 +1,10 @@
1
+ import { type OpenCliDocument } from '@clidoc/core';
2
+ import type { Tool } from '@modelcontextprotocol/sdk/types.js';
3
+ /** A tool definition and its validated, shell-free argument encoder. */
4
+ export type CompiledMcpTool = {
5
+ tool: Tool;
6
+ argv: (input: unknown) => string[];
7
+ };
8
+ /** Compile the supported OpenCLI dialect to MCP tools without executing or modifying the spec. */
9
+ export declare function compileMcpTools(source: OpenCliDocument): CompiledMcpTool[];
10
+ //# sourceMappingURL=compile.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compile.d.ts","sourceRoot":"","sources":["../../src/mcp/compile.ts"],"names":[],"mappings":"AAEA,OAAO,EAAY,KAAK,eAAe,EAAgD,MAAM,cAAc,CAAC;AAC5G,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,oCAAoC,CAAC;AAE/D,wEAAwE;AACxE,MAAM,MAAM,eAAe,GAAG;IAAE,IAAI,EAAE,IAAI,CAAC;IAAC,IAAI,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,MAAM,EAAE,CAAA;CAAE,CAAC;AAmCjF,kGAAkG;AAClG,wBAAgB,eAAe,CAAC,MAAM,EAAE,eAAe,GAAG,eAAe,EAAE,CAmF1E"}