burgee 0.9.2 → 0.10.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/dist/execute.js CHANGED
@@ -326,6 +326,7 @@ async function surface(manifest, argv, io) {
326
326
  return true;
327
327
  }
328
328
  if (head.includes('--schema')) {
329
+ const { schemaSurface } = await import('./schema-surface.js');
329
330
  io.out.write(`${await machineJson(await schemaSurface(manifest, argv), head)}\n`);
330
331
  return true;
331
332
  }
@@ -351,16 +352,6 @@ async function surface(manifest, argv, io) {
351
352
  }
352
353
  return false;
353
354
  }
354
- const SCHEMA_BUDGET = 48_000;
355
- async function schemaSurface(manifest, argv) {
356
- const { commandSchemaOf, schemaOf, summaryOf } = await import('./schema.js');
357
- const { node } = manifest.resolve(beforeTerminator(argv).filter((a) => a !== '--schema' && !a.startsWith('--format=')), manifest.rootPath);
358
- if (node?.run !== undefined)
359
- return commandSchemaOf(node, manifest.rootPath);
360
- const full = schemaOf(manifest);
361
- const budget = manifest.schemaBudget ?? SCHEMA_BUDGET;
362
- return JSON.stringify(full).length <= budget ? full : summaryOf(manifest, budget);
363
- }
364
355
  async function helpCommand(manifest, argv, root, io) {
365
356
  const { node } = manifest.resolve(argv, root);
366
357
  return renderHelp(manifest, node ?? rootNode(manifest, root), io);
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Copyright (c) 2026 Ofri Peretz
3
+ * Licensed under the MIT License. Use of this source code is governed by the
4
+ * MIT license that can be found in the LICENSE file.
5
+ */
6
+ /**
7
+ * N13 / D-116 — `--schema <command> --field <path>`: one field of one command's schema, so an
8
+ * agent under a token budget reads `options.region` instead of the whole document. The path is
9
+ * dotted; a step that does not exist is refused naming the steps that do.
10
+ *
11
+ * With the `--schema` surface it serves: `execute.ts` imports this module only when `--schema`
12
+ * is on the command line (M2), so neither weighs on a run that does not ask for it.
13
+ */
14
+ import { type Manifest } from './manifest.js';
15
+ export declare function fieldOf(doc: unknown, path: string, command: string): unknown;
16
+ /**
17
+ * `--schema` under a character budget (N13): one command's full schema when a command is
18
+ * named (the drilling), the whole program when it fits, a summary naming every command
19
+ * and how to drill when it does not.
20
+ */
21
+ export declare function schemaSurface(manifest: Manifest, argv: string[]): Promise<unknown>;
@@ -0,0 +1,38 @@
1
+ import { UsageError } from './validate.js';
2
+ const isRecord = (value) => typeof value === 'object' && value !== null && !Array.isArray(value);
3
+ export function fieldOf(doc, path, command) {
4
+ let at = doc;
5
+ const walked = [];
6
+ for (const step of path.split('.')) {
7
+ if (!isRecord(at) || !(step in at)) {
8
+ const here = walked.length === 0 ? `"${command}"` : `"${walked.join('.')}"`;
9
+ const valid = isRecord(at) ? Object.keys(at).join(', ') : 'none — it is a value';
10
+ throw new UsageError(`${here} has no field "${step}"`, `fields here: ${valid}`);
11
+ }
12
+ at = at[step];
13
+ walked.push(step);
14
+ }
15
+ return at;
16
+ }
17
+ const SCHEMA_BUDGET = 48_000;
18
+ export async function schemaSurface(manifest, argv) {
19
+ const { commandSchemaOf, schemaOf, summaryOf } = await import('./schema.js');
20
+ const end = argv.indexOf('--');
21
+ const head = end === -1 ? argv : argv.slice(0, end);
22
+ const at = head.findIndex((a) => a === '--field' || a.startsWith('--field='));
23
+ const field = at === -1 ? undefined : (head[at]?.slice('--field='.length) || head[at + 1]);
24
+ const width = head[at] === '--field' ? 1 : 0;
25
+ const drop = at === -1 ? -1 : at + width;
26
+ const path = head.filter((a, i) => a !== '--schema' && !a.startsWith('--format=') && (i < at || i > drop));
27
+ const { node } = manifest.resolve(path, manifest.rootPath);
28
+ if (field !== undefined) {
29
+ if (node?.run === undefined)
30
+ throw new UsageError('--field drills into one command', 'name the command first: --schema <command> --field <path>');
31
+ return fieldOf(commandSchemaOf(node, manifest.rootPath), field, path.join(' '));
32
+ }
33
+ if (node?.run !== undefined)
34
+ return commandSchemaOf(node, manifest.rootPath);
35
+ const full = schemaOf(manifest);
36
+ const budget = manifest.schemaBudget ?? SCHEMA_BUDGET;
37
+ return JSON.stringify(full).length <= budget ? full : summaryOf(manifest, budget);
38
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "burgee",
3
- "version": "0.9.2",
3
+ "version": "0.10.0",
4
4
  "description": "An agent-native CLI framework, drop-in compatible with commander and yargs. One declaration; help, --json, --schema, --mcp and completions all projected from it.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -147,8 +147,8 @@
147
147
  },
148
148
  "dependencies": {
149
149
  "bellpull": "^0.2.2",
150
- "closeout": "^0.3.2",
151
- "linegauge": "^0.4.2",
150
+ "closeout": "^0.4.0",
151
+ "linegauge": "^0.4.3",
152
152
  "roundel": "^0.4.2",
153
153
  "seniority": "^0.4.2"
154
154
  },