burgee 0.13.1 → 0.14.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/argv.js CHANGED
@@ -8,5 +8,5 @@ export function isJsonFlag(arg) {
8
8
  export function mayServe(argv) {
9
9
  const head = beforeTerminator(argv);
10
10
  const first = argv[0];
11
- return first === '__complete' || first === 'completion' || first === 'help' || head[0] === '--mcp' || (head[0] === 'config' && head[1] === 'explain') || head.includes('--schema');
11
+ return first === '__complete' || first === 'completion' || first === 'help' || first === 'schema' || head[0] === '--mcp' || (head[0] === 'config' && head[1] === 'explain') || head.includes('--schema');
12
12
  }
package/dist/brand.js CHANGED
@@ -75,9 +75,9 @@ export function chargeRotation() {
75
75
  export function placeCharge(markup, scale = CHARGE.scale) {
76
76
  return `<g transform="${chargeTransform(scale)}">${markup}</g>`;
77
77
  }
78
+ const bar = (at, fill) => `<rect x="${at.x}" y="${at.y}" width="${BAR.width}" height="${BAR.height}"` +
79
+ ` rx="${BAR.radius}" fill="${fill}"/>`;
78
80
  export function chargeGroup(colors, scale = CHARGE.scale) {
79
- const bar = (at, fill) => `<rect x="${at.x}" y="${at.y}" width="${BAR.width}" height="${BAR.height}"` +
80
- ` rx="${BAR.radius}" fill="${fill}"/>`;
81
81
  return (`<g transform="${chargeTransform(scale)}">` +
82
82
  `<g transform="${chargeRotation()}">` +
83
83
  `${bar(LEAD_BAR, colors.lead)}${bar(FOLLOW_BAR, colors.follow)}</g></g>`);
@@ -727,7 +727,7 @@ Expecting one of '${HOOK_EVENTS.join("', '")}'`);
727
727
  if (arg.required && this.args[i] == null)
728
728
  this.missingArgument(arg.name());
729
729
  });
730
- const last = this.registeredArguments[this.registeredArguments.length - 1];
730
+ const last = this.registeredArguments.at(-1);
731
731
  if (this.registeredArguments.length > 0 && last?.variadic)
732
732
  return;
733
733
  if (this.args.length > this.registeredArguments.length)
@@ -1193,7 +1193,7 @@ Expecting one of '${HOOK_EVENTS.join("', '")}'`);
1193
1193
  if (alias === undefined)
1194
1194
  return this._aliases[0];
1195
1195
  let command = this;
1196
- const last = this.commands[this.commands.length - 1];
1196
+ const last = this.commands.at(-1);
1197
1197
  if (this.commands.length !== 0 && last?._executableHandler) {
1198
1198
  command = last;
1199
1199
  }
@@ -54,7 +54,7 @@ const promise = (program, root) => walk(root).some((n) => Object.values(n.option
54
54
  const fname = (program, path) => `_${[program, ...path].join('_').replaceAll(/[^A-Za-z0-9_]/g, '_')}`;
55
55
  function bashCase(program, node) {
56
56
  const opts = Object.entries(node.options).flatMap(([n, s]) => flags(n, s));
57
- const subs = node.children.map((c) => c.path[c.path.length - 1] ?? '');
57
+ const subs = node.children.map((c) => c.path.at(-1) ?? '');
58
58
  const valued = Object.entries(node.options)
59
59
  .filter(([, s]) => takesValue(s))
60
60
  .map(([n, s]) => isDynamic(s)
@@ -114,8 +114,8 @@ function zshFunction(program, node) {
114
114
  if (node.children.length === 0) {
115
115
  return `${fname(program, node.path)}() {\n _arguments -s ${options.join(' ')} '*: :_files'\n}`;
116
116
  }
117
- const subs = node.children.map((c) => sq(`${c.path[c.path.length - 1] ?? ''}[${c.description.replaceAll(/[[\]:]/g, ' ')}]`)).join(' ');
118
- const dispatch = node.children.map((c) => ` ${c.path[c.path.length - 1] ?? ''}) ${fname(program, c.path)} ;;`).join('\n');
117
+ const subs = node.children.map((c) => sq(`${c.path.at(-1) ?? ''}[${c.description.replaceAll(/[[\]:]/g, ' ')}]`)).join(' ');
118
+ const dispatch = node.children.map((c) => ` ${c.path.at(-1) ?? ''}) ${fname(program, c.path)} ;;`).join('\n');
119
119
  return `${fname(program, node.path)}() {
120
120
  local context state state_descr line
121
121
  typeset -A opt_args
@@ -153,7 +153,7 @@ function fish(program, root) {
153
153
  for (const node of walk(root)) {
154
154
  const cond = sq(fishCondition(node));
155
155
  for (const c of node.children)
156
- lines.push(`complete -c ${program} -n ${cond} -f -a ${c.path[c.path.length - 1] ?? ''} -d ${sq(c.description)}`);
156
+ lines.push(`complete -c ${program} -n ${cond} -f -a ${c.path.at(-1) ?? ''} -d ${sq(c.description)}`);
157
157
  for (const [name, spec] of Object.entries(node.options)) {
158
158
  lines.push(fishOption({ program, cond, node }, kebab(name), spec));
159
159
  if (spec.negatable === true) {
@@ -168,7 +168,7 @@ ${lines.join('\n')}
168
168
  `;
169
169
  }
170
170
  function pwshEntry(node) {
171
- const subs = node.children.map((c) => `@('${c.path[c.path.length - 1] ?? ''}', 'Command', '${c.description.replaceAll("'", "''")}')`);
171
+ const subs = node.children.map((c) => `@('${c.path.at(-1) ?? ''}', 'Command', '${c.description.replaceAll("'", "''")}')`);
172
172
  const opts = Object.entries(node.options).flatMap(([n, s]) => flags(n, s).map((f) => `@('${f}', 'ParameterName', '${(s.description ?? '').replaceAll("'", "''")}')`));
173
173
  const values = Object.entries(node.options)
174
174
  .filter(([, s]) => s.choices !== undefined)
@@ -230,7 +230,7 @@ export function renderFigSpec(manifest) {
230
230
  const { program, root } = completionTree(manifest);
231
231
  const entries = new Map();
232
232
  for (const node of walk(root)) {
233
- const entry = { name: node.path[node.path.length - 1] ?? program, options: figOptions(node) };
233
+ const entry = { name: node.path.at(-1) ?? program, options: figOptions(node) };
234
234
  if (node.description !== '')
235
235
  entry.description = node.description;
236
236
  entries.set(node.path.join(' '), entry);
package/dist/help.js CHANGED
@@ -39,6 +39,7 @@ const GLOBAL = [
39
39
  { term: '--json', text: 'machine-readable output', kind: 'flag' },
40
40
  { term: '--help', text: 'show this help', kind: 'flag' },
41
41
  ];
42
+ const ROOT_GLOBAL = [...GLOBAL, { term: '--schema', text: 'the program as data', kind: 'flag' }];
42
43
  function deprecation(d) {
43
44
  if (d === undefined || d === false)
44
45
  return '';
@@ -96,7 +97,7 @@ function commandSections(manifest, node) {
96
97
  for (const c of children) {
97
98
  const heading = c.group ?? 'Commands:';
98
99
  const rows = groups.get(heading) ?? [];
99
- rows.push({ term: c.path[c.path.length - 1] ?? '', text: `${c.summary ?? c.description ?? ''}${deprecation(c.deprecated)}`.trim(), kind: 'command' });
100
+ rows.push({ term: c.path.at(-1) ?? '', text: `${c.summary ?? c.description ?? ''}${deprecation(c.deprecated)}`.trim(), kind: 'command' });
100
101
  groups.set(heading, rows);
101
102
  }
102
103
  return [...groups].map(([title, rows]) => ({ title, rows }));
@@ -194,13 +195,14 @@ export function renderHelp(manifest, node, opts = {}) {
194
195
  const args = argumentRows(node.arguments ?? []);
195
196
  const options = optionRows(node.options, verbose);
196
197
  const env = environmentRows(node.options);
197
- const column = termColumn([...args, ...options, ...GLOBAL, ...commands.flatMap((s) => s.rows), ...env], width);
198
+ const global = node.path.length === root.length ? ROOT_GLOBAL : GLOBAL;
199
+ const column = termColumn([...args, ...options, ...global, ...commands.flatMap((s) => s.rows), ...env], width);
198
200
  const lines = [usageLine(node, root, commands.length > 0, paint), ''];
199
201
  if (node.description !== undefined)
200
202
  lines.push(...wrap(`${node.description}${deprecation(node.deprecated)}`, width), '');
201
203
  lines.push(...section('Arguments:', layout(args, width, column, paint), paint));
202
204
  lines.push(...section('Options:', layout(options, width, column, paint), paint));
203
- lines.push(...section('Global options:', layout(GLOBAL, width, column, paint), paint));
205
+ lines.push(...section('Global options:', layout(global, width, column, paint), paint));
204
206
  for (const s of commands)
205
207
  lines.push(...section(s.title, layout(s.rows, width, column, paint), paint));
206
208
  lines.push(...section('Examples:', exampleLines(node.examples ?? [], width), paint));
package/dist/surfaces.js CHANGED
@@ -69,6 +69,13 @@ async function helpCommand(manifest, argv, root, io) {
69
69
  const { node } = manifest.resolve(argv, root);
70
70
  return renderHelp(manifest, node ?? rootNode(manifest, root), io);
71
71
  }
72
+ function schemaAlias(manifest, argv) {
73
+ const top = manifest.find(manifest.rootPath);
74
+ const takesWords = (top?.run ?? top?.load) !== undefined && (top?.arguments?.length ?? 0) > 0;
75
+ if (argv[0] !== 'schema' || takesWords || manifest.find([...manifest.rootPath, 'schema']) !== undefined)
76
+ return undefined;
77
+ return ['--schema', ...argv.slice(1)];
78
+ }
72
79
  export async function serve(manifest, argv, io, engine) {
73
80
  const head = beforeTerminator(argv);
74
81
  if (argv[0] === '__complete') {
@@ -87,9 +94,11 @@ export async function serve(manifest, argv, io, engine) {
87
94
  io.out.write(await helpCommand(manifest, argv.slice(1), manifest.rootPath, io));
88
95
  return true;
89
96
  }
90
- if (head.includes('--schema')) {
97
+ const asked = schemaAlias(manifest, argv) ?? argv;
98
+ const askedHead = beforeTerminator(asked);
99
+ if (askedHead.includes('--schema')) {
91
100
  const { schemaSurface } = await import('./schema-surface.js');
92
- io.out.write(`${await machineJson(await schemaSurface(manifest, argv), head)}\n`);
101
+ io.out.write(`${await machineJson(await schemaSurface(manifest, asked), askedHead)}\n`);
93
102
  return true;
94
103
  }
95
104
  if (head[0] === '--mcp') {
@@ -56,7 +56,7 @@ export class UI {
56
56
  width: i === 0 && columns.length > 1 ? leftColumnWidth : undefined,
57
57
  })));
58
58
  });
59
- return this.rows[this.rows.length - 1];
59
+ return this.rows.at(-1);
60
60
  }
61
61
  colFromString(text) {
62
62
  return { text, padding: this.measurePadding(text) };
@@ -743,7 +743,7 @@ export class YargsInstance {
743
743
  return false;
744
744
  return supportedOpts.includes(k);
745
745
  });
746
- const fullCommand = this.#context.fullCommands[this.#context.fullCommands.length - 1];
746
+ const fullCommand = this.#context.fullCommands.at(-1);
747
747
  const parseOptions = fullCommand ? this.#command.cmdToParseOptions(fullCommand) : { array: [], alias: {}, default: {}, demand: {} };
748
748
  objectKeys(parseOptions).forEach((pk) => {
749
749
  const parseOption = parseOptions[pk];
@@ -1515,7 +1515,7 @@ export class YargsInstance {
1515
1515
  return this.#postProcess(argv, populateDoubleDash, !!calledFromCommand, false);
1516
1516
  if (this.#helpOpt) {
1517
1517
  const helpCmds = [this.#helpOpt].concat(aliases[this.#helpOpt] || []).filter((k) => k.length > 1);
1518
- if (helpCmds.includes(`${argv._[argv._.length - 1]}`)) {
1518
+ if (helpCmds.includes(`${argv._.at(-1)}`)) {
1519
1519
  argv._.pop();
1520
1520
  helpOptSet = true;
1521
1521
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "burgee",
3
- "version": "0.13.1",
3
+ "version": "0.14.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",
@@ -148,10 +148,10 @@
148
148
  },
149
149
  "dependencies": {
150
150
  "bellpull": "^0.4.2",
151
- "closeout": "^0.5.3",
151
+ "closeout": "^0.5.4",
152
152
  "linegauge": "^0.5.4",
153
- "roundel": "^0.5.3",
154
- "seniority": "^0.6.2"
153
+ "roundel": "^0.5.4",
154
+ "seniority": "^0.6.3"
155
155
  },
156
156
  "devDependencies": {
157
157
  "vitest": "^5.0.1"