burgee 0.3.0 → 0.4.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 (51) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +61 -9
  3. package/dist/brand.d.ts +62 -1
  4. package/dist/brand.js +73 -7
  5. package/dist/{commander-argument.js → commander/argument.js} +4 -1
  6. package/dist/{commander-command.d.ts → commander/command.d.ts} +5 -5
  7. package/dist/{commander-command.js → commander/command.js} +159 -22
  8. package/dist/{commander-error.js → commander/error.js} +2 -0
  9. package/dist/{commander-help.d.ts → commander/help.d.ts} +3 -3
  10. package/dist/{commander-help.js → commander/help.js} +18 -1
  11. package/dist/{commander-option.d.ts → commander/option.d.ts} +1 -1
  12. package/dist/{commander-option.js → commander/option.js} +15 -1
  13. package/dist/commander.d.ts +8 -8
  14. package/dist/commander.js +8 -8
  15. package/dist/completions.js +15 -4
  16. package/dist/execute.js +39 -24
  17. package/dist/schema.d.ts +2 -0
  18. package/dist/schema.js +3 -0
  19. package/dist/unknown-option.d.ts +9 -0
  20. package/dist/unknown-option.js +27 -0
  21. package/dist/{yargs-burgee.d.ts → yargs/burgee.d.ts} +2 -2
  22. package/dist/{yargs-burgee.js → yargs/burgee.js} +15 -1
  23. package/dist/{yargs-cliui.js → yargs/cliui.js} +8 -0
  24. package/dist/{yargs-command.d.ts → yargs/command.d.ts} +5 -5
  25. package/dist/{yargs-command.js → yargs/command.js} +9 -2
  26. package/dist/{yargs-completion.d.ts → yargs/completion.d.ts} +3 -3
  27. package/dist/{yargs-completion.js → yargs/completion.js} +7 -2
  28. package/dist/{yargs-factory.d.ts → yargs/factory.d.ts} +8 -8
  29. package/dist/{yargs-factory.js → yargs/factory.js} +63 -13
  30. package/dist/{yargs-middleware.js → yargs/middleware.js} +6 -1
  31. package/dist/{yargs-shim.d.ts → yargs/shim.d.ts} +3 -3
  32. package/dist/{yargs-shim.js → yargs/shim.js} +24 -5
  33. package/dist/{yargs-usage.d.ts → yargs/usage.d.ts} +1 -1
  34. package/dist/{yargs-usage.js → yargs/usage.js} +9 -1
  35. package/dist/{yargs-utils.js → yargs/utils.js} +11 -0
  36. package/dist/{yargs-validation.d.ts → yargs/validation.d.ts} +1 -1
  37. package/dist/{yargs-validation.js → yargs/validation.js} +7 -1
  38. package/dist/{yargs-y18n.js → yargs/y18n.js} +6 -0
  39. package/dist/yargs-helpers.d.ts +1 -1
  40. package/dist/yargs-helpers.js +1 -1
  41. package/dist/yargs.d.ts +4 -4
  42. package/dist/yargs.js +5 -5
  43. package/package.json +2 -1
  44. /package/dist/{commander-argument.d.ts → commander/argument.d.ts} +0 -0
  45. /package/dist/{commander-error.d.ts → commander/error.d.ts} +0 -0
  46. /package/dist/{commander-suggest.d.ts → suggest.d.ts} +0 -0
  47. /package/dist/{commander-suggest.js → suggest.js} +0 -0
  48. /package/dist/{yargs-cliui.d.ts → yargs/cliui.d.ts} +0 -0
  49. /package/dist/{yargs-middleware.d.ts → yargs/middleware.d.ts} +0 -0
  50. /package/dist/{yargs-utils.d.ts → yargs/utils.d.ts} +0 -0
  51. /package/dist/{yargs-y18n.d.ts → yargs/y18n.d.ts} +0 -0
@@ -5,14 +5,14 @@
5
5
  * `getInternalMethods()` seam are the upstream's — that is what makes a user's
6
6
  * existing program run unchanged (J2).
7
7
  */
8
- import { type Effects, Manifest, type Plugin } from './manifest.js';
9
- import { type CommandInstance } from './yargs-command.js';
10
- import { type CompletionFunction } from './yargs-completion.js';
11
- import { type Middleware } from './yargs-middleware.js';
12
- import type { PlatformShim } from './yargs-shim.js';
13
- import { type FailureFunction, type UsageInstance } from './yargs-usage.js';
14
- import { YError } from './yargs-utils.js';
15
- import { type ValidationInstance } from './yargs-validation.js';
8
+ import { type Effects, Manifest, type Plugin } from '../manifest.js';
9
+ import { type CommandInstance } from './command.js';
10
+ import { type CompletionFunction } from './completion.js';
11
+ import { type Middleware } from './middleware.js';
12
+ import type { PlatformShim } from './shim.js';
13
+ import { type FailureFunction, type UsageInstance } from './usage.js';
14
+ import { YError } from './utils.js';
15
+ import { type ValidationInstance } from './validation.js';
16
16
  export interface Options {
17
17
  array: string[];
18
18
  boolean: string[];
@@ -1,16 +1,23 @@
1
+ /**
2
+ * yargs' `YargsInstance`, ported method for method from yargs 18 and graded by yargs'
3
+ * own suite through `compat-oracle`. Every public method, its argsert contract, the
4
+ * parse pipeline, the freeze/unfreeze bookkeeping around `.parse()` and the
5
+ * `getInternalMethods()` seam are the upstream's — that is what makes a user's
6
+ * existing program run unchanged (J2).
7
+ */
1
8
  var _a;
2
- import { ExitCode } from './exit-code.js';
3
- import { Manifest } from './manifest.js';
4
- import { serveMcp } from './mcp.js';
5
- import { schemaOf } from './schema.js';
6
- import { projectManifest, render } from './yargs-burgee.js';
7
- import { command as Command, isCommandBuilderCallback } from './yargs-command.js';
8
- import { completion as Completion } from './yargs-completion.js';
9
- import { applyMiddleware, GlobalMiddleware } from './yargs-middleware.js';
10
- import { tokenizeArgString } from './yargs-parser.js';
11
- import { usage as Usage } from './yargs-usage.js';
12
- import { applyExtends, argsert, isPromise, maybeAsyncResult, objectKeys, objFilter, setBlocking, YError } from './yargs-utils.js';
13
- import { validation as Validation } from './yargs-validation.js';
9
+ import { ExitCode } from '../exit-code.js';
10
+ import { Manifest } from '../manifest.js';
11
+ import { serveMcp } from '../mcp.js';
12
+ import { schemaOf } from '../schema.js';
13
+ import { tokenizeArgString } from '../yargs-parser.js';
14
+ import { projectManifest, render } from './burgee.js';
15
+ import { command as Command, isCommandBuilderCallback } from './command.js';
16
+ import { completion as Completion } from './completion.js';
17
+ import { applyMiddleware, GlobalMiddleware } from './middleware.js';
18
+ import { usage as Usage } from './usage.js';
19
+ import { applyExtends, argsert, isPromise, maybeAsyncResult, objectKeys, objFilter, setBlocking, YError } from './utils.js';
20
+ import { validation as Validation } from './validation.js';
14
21
  const DEFAULT_LOCALE = 'en_US';
15
22
  export function YargsFactory(shim) {
16
23
  return (processArgs = [], cwd = shim.process.cwd(), parentRequire) => {
@@ -64,6 +71,7 @@ export class YargsInstance {
64
71
  #usageConfig = {};
65
72
  #versionOpt = null;
66
73
  #validation;
74
+ // ───── burgee: the manifest projection, plugins, --json, the surfaces and the seam ─────
67
75
  #burgee = undefined;
68
76
  #effects = undefined;
69
77
  #manifest = undefined;
@@ -74,6 +82,7 @@ export class YargsInstance {
74
82
  this.#parentRequire = parentRequire;
75
83
  this.#globalMiddleware = new GlobalMiddleware(this);
76
84
  this.$0 = this.#getDollarZero();
85
+ // kReset builds the four collaborators; the definite assignments below are its result.
77
86
  this.#options = undefined;
78
87
  this.#usage = undefined;
79
88
  this.#validation = undefined;
@@ -593,6 +602,8 @@ export class YargsInstance {
593
602
  argsert('[string|array] [function|boolean|object] [function]', [args, shortCircuit, _parseFn], arguments.length);
594
603
  if (shortCircuit === true)
595
604
  return this.#parse(args, shortCircuit, _parseFn);
605
+ // burgee: --json and the seam are per parse. What this parse turns on (json, an exit
606
+ // already reported) is put back afterwards, so the next parse starts as the program left it.
596
607
  const before = this.#burgee === undefined ? undefined : { ...this.#burgee };
597
608
  const restore = () => {
598
609
  this.#burgee = before;
@@ -611,6 +622,8 @@ export class YargsInstance {
611
622
  throw err;
612
623
  }
613
624
  }
625
+ // The seam: the whole run settles to one E1 exit. yargs reports its own failures
626
+ // through exit(); a handler that throws synchronously is the one thing that escapes it.
614
627
  seam.exited = false;
615
628
  const finish = (argv) => {
616
629
  if (!this.#burgee?.exited)
@@ -662,6 +675,8 @@ export class YargsInstance {
662
675
  if (!shortCircuit) {
663
676
  const served = this.#burgeeSurface(args);
664
677
  if (served !== false) {
678
+ // A surface was (or is being) served: the argv handed back is the short-circuit parse,
679
+ // as after --help. Completions and --mcp load lazily, so those two return a promise.
665
680
  const settle = () => {
666
681
  const argv = this.#runYargsParserAndExecuteCommands(args, true);
667
682
  this.#unfreeze();
@@ -905,6 +920,7 @@ export class YargsInstance {
905
920
  delete argv['--'];
906
921
  }
907
922
  catch {
923
+ // a frozen argv keeps its `--`; yargs ignores the failure
908
924
  }
909
925
  return argv;
910
926
  }
@@ -925,6 +941,8 @@ export class YargsInstance {
925
941
  const burgee = this.#burgee;
926
942
  const line = args.join(' ');
927
943
  if (burgee?.json) {
944
+ // Under --json the failure is one envelope on stdout; the help screen and the
945
+ // message yargs prints on the way are kept only as the envelope's message.
928
946
  if (line.trim() !== '')
929
947
  burgee.lastError = line;
930
948
  }
@@ -1042,6 +1060,7 @@ export class YargsInstance {
1042
1060
  obj = JSON.parse(this.#shim.readFileSync(pkgJsonPath, 'utf8'));
1043
1061
  }
1044
1062
  catch {
1063
+ // no package.json above: version reads 'unknown', as upstream
1045
1064
  }
1046
1065
  this.#pkgs[npath] = obj || {};
1047
1066
  return this.#pkgs[npath];
@@ -1135,19 +1154,32 @@ export class YargsInstance {
1135
1154
  runHandler: this.#runHandler.bind(this),
1136
1155
  };
1137
1156
  }
1157
+ // ───── burgee: additive, and guarded so a program that asks for none of it runs as on yargs ─────
1158
+ /**
1159
+ * The manifest every surface reads (J7, J8). Projected on each access from what the
1160
+ * program registered; a command's builder is run on a scratch instance to learn its
1161
+ * options, exactly as yargs' own completion does. Plugin-contributed nodes are kept.
1162
+ */
1138
1163
  get manifest() {
1139
1164
  this.#manifest ??= new Manifest();
1140
1165
  projectManifest(this.#manifest, this.#snapshot());
1141
1166
  return this.#manifest;
1142
1167
  }
1168
+ /** burgee: declare what the command does to the world (N6); what exposes it as an MCP tool (N2). */
1143
1169
  effects(value) {
1144
1170
  this.#effects = value;
1145
1171
  return this;
1146
1172
  }
1173
+ /** Additive: plugins yargs never had. `preRun`/`postRun` fire around every handler. */
1147
1174
  use(plugin) {
1148
1175
  this.manifest.use(plugin);
1149
1176
  return this;
1150
1177
  }
1178
+ /**
1179
+ * Inject the streams and the exit for this instance (T1). Output goes to `stdout`/`stderr`
1180
+ * instead of the console, and `exit` receives an E1 code: OK for help and version, USAGE
1181
+ * for a validation failure, RUNTIME for a handler that threw.
1182
+ */
1151
1183
  burgee(seam) {
1152
1184
  this.#burgee = { ...(this.#burgee ?? { json: false, lastError: '' }), ...seam };
1153
1185
  return this;
@@ -1160,6 +1192,7 @@ export class YargsInstance {
1160
1192
  let positionals = { demanded: [], optional: [] };
1161
1193
  let hasHandler = false;
1162
1194
  let description;
1195
+ // The default command (`$0`, `*`) is the root's own handler, not a child path.
1163
1196
  const isDefault = (h) => /^\$0( |$)/.test(h.original);
1164
1197
  for (const [name, handler] of Object.entries(handlers)) {
1165
1198
  if (isDefault(handler))
@@ -1201,6 +1234,7 @@ export class YargsInstance {
1201
1234
  commands,
1202
1235
  };
1203
1236
  }
1237
+ /** A command's snapshot: what its builder registered on the scratch, plus the command string's positionals. */
1204
1238
  #snapshotOf(handler, name) {
1205
1239
  const snap = this.#snapshot();
1206
1240
  snap.name = name;
@@ -1210,6 +1244,7 @@ export class YargsInstance {
1210
1244
  snap.version = undefined;
1211
1245
  return snap;
1212
1246
  }
1247
+ /** Run a command's builder on a fresh instance, as yargs' completion does, and hand that instance back. */
1213
1248
  #childOf(handler) {
1214
1249
  const child = new _a([], this.#cwd, this.#parentRequire, this.#shim);
1215
1250
  child.#context.fullCommands.push(handler.original);
@@ -1226,9 +1261,11 @@ export class YargsInstance {
1226
1261
  }
1227
1262
  }
1228
1263
  catch {
1264
+ // A builder that cannot run outside a parse projects only the command string.
1229
1265
  }
1230
1266
  return child;
1231
1267
  }
1268
+ /** `--json` that the program did not declare is burgee's envelope, not an unknown option. */
1232
1269
  #takeJson(args) {
1233
1270
  const list = typeof args === 'string' ? tokenizeArgString(args) : args;
1234
1271
  const terminator = list.indexOf('--');
@@ -1240,6 +1277,11 @@ export class YargsInstance {
1240
1277
  this.#burgee = { ...(this.#burgee ?? { lastError: '' }), json: true };
1241
1278
  return [...list.slice(0, index), ...list.slice(index + 1)];
1242
1279
  }
1280
+ /**
1281
+ * Whether the program declared an option or command by this name — at the root, or in
1282
+ * any command's builder, which the manifest projection runs to find out. Any command in
1283
+ * the tree that declares the flag keeps it: the surface is additive only.
1284
+ */
1243
1285
  #declares(key) {
1244
1286
  if (this.#options.key[key] || Object.values(this.#options.alias).some((list) => list.includes(key)))
1245
1287
  return true;
@@ -1247,12 +1289,17 @@ export class YargsInstance {
1247
1289
  return true;
1248
1290
  return this.manifest.commands.some((node) => Object.prototype.hasOwnProperty.call(node.options, key));
1249
1291
  }
1292
+ /**
1293
+ * `--schema`, `--mcp` and `completion <shell>` on a yargs-syntax program, from its
1294
+ * manifest (J2). Only when the program declares none of them itself; `--schema` is
1295
+ * synchronous, the other two load lazily and return a promise.
1296
+ */
1250
1297
  #burgeeSurface(args) {
1251
1298
  const list = typeof args === 'string' ? tokenizeArgString(args) : args;
1252
1299
  const terminator = list.indexOf('--');
1253
1300
  const head = terminator === -1 ? list : list.slice(0, terminator);
1254
1301
  if (head[0] === 'completion' && this.#completionCommand === null && !this.#declares('completion')) {
1255
- return import('./completions.js').then(({ renderCompletion, renderFigSpec, SHELLS }) => {
1302
+ return import('../completions.js').then(({ renderCompletion, renderFigSpec, SHELLS }) => {
1256
1303
  const shell = head[1] ?? '';
1257
1304
  if (shell === 'fig') {
1258
1305
  this.#logger.log(JSON.stringify(renderFigSpec(this.manifest), null, 2));
@@ -1295,6 +1342,7 @@ export class YargsInstance {
1295
1342
  }
1296
1343
  return false;
1297
1344
  }
1345
+ /** The handler, wrapped in the plugin hooks and followed by the envelope or the rendering. */
1298
1346
  #runHandler(handler, argv, original) {
1299
1347
  const manifest = this.#manifest;
1300
1348
  const settle = (value) => {
@@ -1335,6 +1383,7 @@ export class YargsInstance {
1335
1383
  const code = err instanceof YError || err === undefined || typeof err === 'string' ? 'usage' : 'runtime';
1336
1384
  this.#logger.log(JSON.stringify({ ok: false, error: { code, message } }));
1337
1385
  }
1386
+ /** burgee: where every option value came from (V3), from yargs-parser's own bookkeeping where it keeps any. */
1338
1387
  #provenance(argv) {
1339
1388
  const out = {};
1340
1389
  const defaulted = this.parsed?.defaulted ?? {};
@@ -1604,3 +1653,4 @@ _a = YargsInstance;
1604
1653
  export function isYargsInstance(y) {
1605
1654
  return !!y && typeof y.getInternalMethods === 'function';
1606
1655
  }
1656
+ //# sourceMappingURL=factory.js.map
@@ -1,4 +1,8 @@
1
- import { argsert, isPromise } from './yargs-utils.js';
1
+ /**
2
+ * yargs' middleware — global, per-command, and the coerce middleware `.coerce()`
3
+ * registers — ported for `burgee/yargs`.
4
+ */
5
+ import { argsert, isPromise } from './utils.js';
2
6
  export class GlobalMiddleware {
3
7
  globalMiddleware = [];
4
8
  frozens = [];
@@ -79,3 +83,4 @@ export function applyMiddleware(argv, yargs, middlewares, beforeValidation) {
79
83
  return isPromise(result) ? result.then((middlewareObj) => Object.assign(acc, middlewareObj)) : Object.assign(acc, result);
80
84
  }, argv);
81
85
  }
86
+ //# sourceMappingURL=middleware.js.map
@@ -7,9 +7,9 @@
7
7
  import { readdirSync, readFileSync } from 'node:fs';
8
8
  import { basename, dirname, extname, join, relative, resolve } from 'node:path';
9
9
  import { inspect } from 'node:util';
10
- import { cliui } from './yargs-cliui.js';
11
- import { Parser } from './yargs-parser.js';
12
- import { type Y18N } from './yargs-y18n.js';
10
+ import { Parser } from '../yargs-parser.js';
11
+ import { cliui } from './cliui.js';
12
+ import { type Y18N } from './y18n.js';
13
13
  export interface PlatformShim {
14
14
  assert: {
15
15
  notStrictEqual: (a: any, b: any, m?: string) => void;
@@ -1,15 +1,22 @@
1
+ /**
2
+ * yargs' Node platform shim — the one object every yargs module reaches the platform
3
+ * through — built from burgee's own ports of its dependencies (J9). Anything that
4
+ * yargs 18 took from `cliui`, `escalade`, `get-caller-file`, `string-width`, `y18n`
5
+ * and `yargs-parser` is served from here.
6
+ */
1
7
  import { readdirSync, readFileSync, statSync } from 'node:fs';
2
8
  import { createRequire } from 'node:module';
3
9
  import { basename, dirname, extname, join, relative, resolve } from 'node:path';
4
10
  import { fileURLToPath } from 'node:url';
5
11
  import { inspect } from 'node:util';
6
- import { cliui, stringWidth } from './yargs-cliui.js';
7
- import { Parser } from './yargs-parser.js';
8
- import { getProcessArgvBin } from './yargs-utils.js';
9
- import { y18n } from './yargs-y18n.js';
12
+ import { Parser } from '../yargs-parser.js';
13
+ import { cliui, stringWidth } from './cliui.js';
14
+ import { getProcessArgvBin } from './utils.js';
15
+ import { y18n } from './y18n.js';
10
16
  const here = fileURLToPath(import.meta.url);
11
17
  const mainFilename = here.substring(0, here.lastIndexOf('node_modules'));
12
18
  const nodeRequire = createRequire(import.meta.url);
19
+ /** escalade/sync: walk up from `start`, asking `callback` at each directory. */
13
20
  function findUp(start, callback) {
14
21
  let dir = resolve('.', start);
15
22
  let tmp;
@@ -27,6 +34,7 @@ function findUp(start, callback) {
27
34
  }
28
35
  return undefined;
29
36
  }
37
+ /** get-caller-file: the file that called the function that called this (v8 stack). */
30
38
  function getCallerFile(position = 2) {
31
39
  if (position >= Error.stackTraceLimit) {
32
40
  throw new TypeError(`getCallerFile(position) requires position be less then Error.stackTraceLimit but position was: \`${position}\` and Error.stackTraceLimit was: \`${Error.stackTraceLimit}\``);
@@ -49,6 +57,16 @@ function strictEqual(actual, expected, message) {
49
57
  if (actual !== expected)
50
58
  throw new Error(message ?? `Expected values to be strictly equal:\n\n${inspect(actual)} !== ${inspect(expected)}\n`);
51
59
  }
60
+ /**
61
+ * Where the 29 locale files live: the package root, not beside this file.
62
+ *
63
+ * This was `resolve(dirname(here), '../locales')`, which was right only while this file sat
64
+ * directly in `dist/`. The first directory added under `src/` made it `dist/locales`, y18n
65
+ * returned the key for every string, and 14 of yargs' own 804 tests failed. Walking up to
66
+ * `package.json` resolves the same from `src/`, from `dist/`, and from
67
+ * `node_modules/burgee/dist/` once published — so a later move cannot repeat it.
68
+ */
69
+ const locales = resolve(dirname(findUp(here, (_dir, names) => (names.includes('package.json') ? 'package.json' : undefined)) ?? here), 'locales');
52
70
  export const shim = {
53
71
  assert: { notStrictEqual, strictEqual },
54
72
  cliui,
@@ -80,5 +98,6 @@ export const shim = {
80
98
  return /^file:\/\//.exec(callerFile) ? fileURLToPath(callerFile) : callerFile;
81
99
  },
82
100
  stringWidth,
83
- y18n: y18n({ directory: resolve(dirname(here), '../locales'), updateFiles: false }),
101
+ y18n: y18n({ directory: locales, updateFiles: false }),
84
102
  };
103
+ //# sourceMappingURL=shim.js.map
@@ -3,7 +3,7 @@
3
3
  * version string — ported for `burgee/yargs`. Help is rendered through the cliui port,
4
4
  * so yargs' usage tests compare whole screens byte for byte.
5
5
  */
6
- import type { PlatformShim } from './yargs-shim.js';
6
+ import type { PlatformShim } from './shim.js';
7
7
  export type FailureFunction = (msg: string | undefined | null, err: Error | undefined, usage: UsageInstance) => void;
8
8
  export interface UsageInstance {
9
9
  failFn: (f: FailureFunction | boolean) => void;
@@ -1,4 +1,9 @@
1
- import { objFilter, setBlocking, YError } from './yargs-utils.js';
1
+ /**
2
+ * yargs' usage — the help screen, `fail`, examples, epilogues, descriptions and the
3
+ * version string — ported for `burgee/yargs`. Help is rendered through the cliui port,
4
+ * so yargs' usage tests compare whole screens byte for byte.
5
+ */
6
+ import { objFilter, setBlocking, YError } from './utils.js';
2
7
  function isBoolean(fail) {
3
8
  return typeof fail === 'boolean';
4
9
  }
@@ -55,6 +60,8 @@ export function usage(yargs, shim) {
55
60
  }
56
61
  }
57
62
  err = err || new YError(msg);
63
+ // The error rides along so an injected exit (burgee's seam) can tell a usage failure
64
+ // from a handler's; without a seam yargs exits the process and it is unobservable.
58
65
  if (yargs.getExitProcess())
59
66
  return yargs.exit(1, err);
60
67
  else if (yargs.getInternalMethods().hasParseCallback())
@@ -477,3 +484,4 @@ function getIndentation(text) {
477
484
  function getText(text) {
478
485
  return isIndentedText(text) ? text.text : text;
479
486
  }
487
+ //# sourceMappingURL=usage.js.map
@@ -1,3 +1,9 @@
1
+ /**
2
+ * yargs' small internal modules — yerror, parse-command, argsert, obj-filter, is-promise,
3
+ * levenshtein, maybe-async-result, set-blocking, apply-extends, process-argv — ported
4
+ * for `burgee/yargs`. Its suite imports four of these by their upstream file paths; the
5
+ * oracle shims those paths to this entry, so the names here are the upstream names.
6
+ */
1
7
  import { readFileSync } from 'node:fs';
2
8
  import { createRequire } from 'node:module';
3
9
  import { dirname, resolve } from 'node:path';
@@ -158,6 +164,10 @@ export function getProcessArgvBin() {
158
164
  }
159
165
  const nodeRequire = createRequire(import.meta.url);
160
166
  let previouslyVisitedConfigs = [];
167
+ /**
168
+ * `extends` in a config object. The upstream resolves a bare specifier with
169
+ * `import.meta.resolve` and then loads it through `require`; both are done from here.
170
+ */
161
171
  export function applyExtends(config, cwd, mergeExtends) {
162
172
  let defaultConfig = {};
163
173
  if (Object.prototype.hasOwnProperty.call(config, 'extends')) {
@@ -207,3 +217,4 @@ function mergeDeep(config1, config2) {
207
217
  export function objectKeys(object) {
208
218
  return Object.keys(object);
209
219
  }
220
+ //# sourceMappingURL=utils.js.map
@@ -3,7 +3,7 @@
3
3
  * modes, choices, implications, conflicts, and `recommendCommands` — ported for
4
4
  * `burgee/yargs`. Every message is the upstream's through y18n.
5
5
  */
6
- import type { PlatformShim } from './yargs-shim.js';
6
+ import type { PlatformShim } from './shim.js';
7
7
  export interface ValidationInstance {
8
8
  nonOptionCount: (argv: any) => void;
9
9
  positionalCount: (required: number, observed: number) => void;
@@ -1,4 +1,9 @@
1
- import { argsert, levenshtein as distance, objFilter } from './yargs-utils.js';
1
+ /**
2
+ * yargs' validation — demanded options and commands, unknown arguments under strict
3
+ * modes, choices, implications, conflicts, and `recommendCommands` — ported for
4
+ * `burgee/yargs`. Every message is the upstream's through y18n.
5
+ */
6
+ import { argsert, levenshtein as distance, objFilter } from './utils.js';
2
7
  const specialKeys = ['$0', '--', '_'];
3
8
  export function validation(yargs, usage, shim) {
4
9
  const __ = shim.y18n.__;
@@ -259,3 +264,4 @@ export function validation(yargs, usage, shim) {
259
264
  };
260
265
  return self;
261
266
  }
267
+ //# sourceMappingURL=validation.js.map
@@ -1,3 +1,8 @@
1
+ /**
2
+ * y18n 5 — yargs' string table — ported for `burgee/yargs`. The 29 locales ship with
3
+ * burgee under `locales/`, read on first use of a locale, never written (yargs runs
4
+ * y18n with `updateFiles: false`).
5
+ */
1
6
  import { readFileSync, statSync } from 'node:fs';
2
7
  import { resolve } from 'node:path';
3
8
  import { format } from 'node:util';
@@ -115,3 +120,4 @@ export function y18n(opts) {
115
120
  locale: table.locale,
116
121
  };
117
122
  }
123
+ //# sourceMappingURL=y18n.js.map
@@ -2,5 +2,5 @@
2
2
  * `burgee/yargs/helpers` — what `yargs/helpers` exports: `hideBin`, `applyExtends`
3
3
  * and the parser.
4
4
  */
5
- export { applyExtends, hideBin } from './yargs-utils.js';
5
+ export { applyExtends, hideBin } from './yargs/utils.js';
6
6
  export { Parser } from './yargs-parser.js';
@@ -1,2 +1,2 @@
1
- export { applyExtends, hideBin } from './yargs-utils.js';
1
+ export { applyExtends, hideBin } from './yargs/utils.js';
2
2
  export { Parser } from './yargs-parser.js';
package/dist/yargs.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- export { YargsInstance, isYargsInstance, type Options, type ParseCallback } from './yargs-factory.js';
1
+ export { YargsInstance, isYargsInstance, type Options, type ParseCallback } from './yargs/factory.js';
2
2
  export { Parser, camelCase, decamelize, looksLikeNumber, type DetailedArguments } from './yargs-parser.js';
3
- export { applyExtends, argsert, hideBin, isPromise, objFilter, parseCommand, YError, type ParsedCommand } from './yargs-utils.js';
4
- export { shim as platformShim, type PlatformShim } from './yargs-shim.js';
5
- declare const Yargs: (processArgs?: string | string[], cwd?: string, parentRequire?: NodeJS.Require) => import("./yargs-factory.js").YargsInstance;
3
+ export { applyExtends, argsert, hideBin, isPromise, objFilter, parseCommand, YError, type ParsedCommand } from './yargs/utils.js';
4
+ export { shim as platformShim, type PlatformShim } from './yargs/shim.js';
5
+ declare const Yargs: (processArgs?: string | string[], cwd?: string, parentRequire?: NodeJS.Require) => import("./yargs/factory.js").YargsInstance;
6
6
  export default Yargs;
package/dist/yargs.js CHANGED
@@ -1,8 +1,8 @@
1
- import { YargsFactory } from './yargs-factory.js';
2
- import { shim } from './yargs-shim.js';
3
- export { YargsInstance, isYargsInstance } from './yargs-factory.js';
1
+ import { YargsFactory } from './yargs/factory.js';
2
+ import { shim } from './yargs/shim.js';
3
+ export { YargsInstance, isYargsInstance } from './yargs/factory.js';
4
4
  export { Parser, camelCase, decamelize, looksLikeNumber } from './yargs-parser.js';
5
- export { applyExtends, argsert, hideBin, isPromise, objFilter, parseCommand, YError } from './yargs-utils.js';
6
- export { shim as platformShim } from './yargs-shim.js';
5
+ export { applyExtends, argsert, hideBin, isPromise, objFilter, parseCommand, YError } from './yargs/utils.js';
6
+ export { shim as platformShim } from './yargs/shim.js';
7
7
  const Yargs = YargsFactory(shim);
8
8
  export default Yargs;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "burgee",
3
- "version": "0.3.0",
3
+ "version": "0.4.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",
@@ -69,6 +69,7 @@
69
69
  "build": "tsc -p tsconfig.build.json && node ../../scripts/strip-comments.mjs dist",
70
70
  "typecheck": "tsc -p tsconfig.json --noEmit",
71
71
  "test": "vitest run --passWithNoTests",
72
+ "coverage": "vitest run --coverage.enabled",
72
73
  "lint": "eslint src"
73
74
  },
74
75
  "repository": {
File without changes
File without changes
File without changes
File without changes
File without changes