burgee 0.7.1 → 0.9.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/README.md +1 -0
- package/dist/check.d.ts +22 -0
- package/dist/check.js +35 -0
- package/dist/cli.d.ts +31 -3
- package/dist/cli.js +36 -7
- package/dist/commander/argument.js +0 -3
- package/dist/commander/command.d.ts +7 -3
- package/dist/commander/command.js +54 -187
- package/dist/commander/error.js +0 -2
- package/dist/commander/help.js +0 -17
- package/dist/commander/option.js +0 -14
- package/dist/compat.d.ts +30 -0
- package/dist/compat.js +4 -0
- package/dist/config.d.ts +10 -0
- package/dist/config.js +2 -0
- package/dist/definition.d.ts +24 -6
- package/dist/definition.js +18 -14
- package/dist/execute.d.ts +1 -0
- package/dist/execute.js +45 -27
- package/dist/exit-code.d.ts +17 -1
- package/dist/exit-code.js +1 -0
- package/dist/help-entry.d.ts +2 -0
- package/dist/help-entry.js +1 -0
- package/dist/help.d.ts +12 -0
- package/dist/help.js +6 -0
- package/dist/index.d.ts +32 -7
- package/dist/index.js +1 -7
- package/dist/mcp-entry.d.ts +2 -0
- package/dist/mcp-entry.js +1 -0
- package/dist/mcp.d.ts +33 -13
- package/dist/mcp.js +4 -3
- package/dist/meow/parse.d.ts +21 -0
- package/dist/meow/parse.js +43 -0
- package/dist/meow/present.d.ts +35 -0
- package/dist/meow/present.js +58 -0
- package/dist/meow/types.d.ts +47 -0
- package/dist/meow/types.js +3 -0
- package/dist/meow/validate.d.ts +35 -0
- package/dist/meow/validate.js +144 -0
- package/dist/meow.d.ts +6 -0
- package/dist/meow.js +146 -0
- package/dist/migrate.d.ts +142 -0
- package/dist/migrate.js +284 -0
- package/dist/plugin.d.ts +1 -1
- package/dist/plugin.js +1 -1
- package/dist/runtime.d.ts +2 -0
- package/dist/runtime.js +3 -0
- package/dist/schema-entry.d.ts +3 -0
- package/dist/schema-entry.js +2 -0
- package/dist/schema.json +1 -1
- package/dist/testing-helpers.js +3 -1
- package/dist/validate.d.ts +15 -0
- package/dist/validate.js +10 -0
- package/dist/yargs/burgee.js +0 -14
- package/dist/yargs/cliui.js +0 -53
- package/dist/yargs/command.js +0 -7
- package/dist/yargs/completion.js +0 -5
- package/dist/yargs/factory.js +7 -57
- package/dist/yargs/middleware.js +0 -5
- package/dist/yargs/shim.js +0 -20
- package/dist/yargs/usage.js +0 -8
- package/dist/yargs/utils.js +0 -11
- package/dist/yargs/validation.js +0 -6
- package/dist/yargs/y18n.js +0 -6
- package/package.json +32 -7
package/README.md
CHANGED
package/dist/check.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { ExitCode } from './exit-code.js';
|
|
2
|
+
export interface CheckReport {
|
|
3
|
+
name: string;
|
|
4
|
+
commands: {
|
|
5
|
+
path: string;
|
|
6
|
+
description: string;
|
|
7
|
+
effects: string;
|
|
8
|
+
}[];
|
|
9
|
+
hooks: {
|
|
10
|
+
stage: 'preRun' | 'postRun' | 'onError';
|
|
11
|
+
applies: string;
|
|
12
|
+
}[];
|
|
13
|
+
}
|
|
14
|
+
export interface CheckRefusal {
|
|
15
|
+
refused: {
|
|
16
|
+
code: string;
|
|
17
|
+
message: string;
|
|
18
|
+
fix: string;
|
|
19
|
+
};
|
|
20
|
+
exitCode: ExitCode;
|
|
21
|
+
}
|
|
22
|
+
export declare function checkPlugin(file: string): Promise<CheckReport | CheckRefusal>;
|
package/dist/check.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { resolve } from 'node:path';
|
|
2
|
+
import { pathToFileURL } from 'node:url';
|
|
3
|
+
import { ExitCode } from './exit-code.js';
|
|
4
|
+
import { Manifest } from './manifest.js';
|
|
5
|
+
import { PluginError, validate } from './plugin.js';
|
|
6
|
+
const STAGES = ['preRun', 'postRun', 'onError'];
|
|
7
|
+
const refuse = (code, message, fix) => ({ refused: { code, message, fix }, exitCode: ExitCode.RUNTIME });
|
|
8
|
+
export async function checkPlugin(file) {
|
|
9
|
+
const loaded = (await import(pathToFileURL(resolve(file)).href));
|
|
10
|
+
const plugin = loaded.default ?? loaded;
|
|
11
|
+
try {
|
|
12
|
+
validate(plugin, []);
|
|
13
|
+
new Manifest().use(plugin);
|
|
14
|
+
}
|
|
15
|
+
catch (error) {
|
|
16
|
+
if (error instanceof PluginError)
|
|
17
|
+
return refuse(error.code, error.message, error.fix);
|
|
18
|
+
if (error instanceof Error)
|
|
19
|
+
return refuse('E_PLUGIN_SCHEMA', error.message, 'fix the contributed command the message names; it is checked exactly as one of the program’s own');
|
|
20
|
+
throw error;
|
|
21
|
+
}
|
|
22
|
+
const { name, commands = [], hooks = {} } = plugin;
|
|
23
|
+
const report = {
|
|
24
|
+
name,
|
|
25
|
+
commands: commands.map((c) => ({ path: c.path.join(' '), description: c.description ?? '', effects: String(c.effects ?? 'undeclared') })),
|
|
26
|
+
hooks: STAGES.filter((stage) => hooks[stage] !== undefined).map((stage) => ({
|
|
27
|
+
stage,
|
|
28
|
+
applies: hooks[stage]?.filter?.command === undefined ? 'every command' : `commands matching ${String(hooks[stage]?.filter?.command)}`,
|
|
29
|
+
})),
|
|
30
|
+
};
|
|
31
|
+
if (report.commands.length === 0 && report.hooks.length === 0) {
|
|
32
|
+
return refuse('E_NO_CONTRIBUTION', `${name} registers, but contributes nothing burgee reads`, 'add `commands` or `hooks` — a key another package in the family reads is allowed in the same object, but `burgee check` cannot show it');
|
|
33
|
+
}
|
|
34
|
+
return report;
|
|
35
|
+
}
|
package/dist/cli.d.ts
CHANGED
|
@@ -26,7 +26,7 @@ export declare const brandCommand: import("./execute.js").Command<{
|
|
|
26
26
|
readonly type: "string";
|
|
27
27
|
readonly description: "outline colour, hex. Omit for no outline";
|
|
28
28
|
};
|
|
29
|
-
readonly
|
|
29
|
+
readonly bordureWidth: {
|
|
30
30
|
readonly type: "string";
|
|
31
31
|
readonly default: "1.5";
|
|
32
32
|
readonly description: "outline width";
|
|
@@ -43,7 +43,7 @@ export declare const brandCommand: import("./execute.js").Command<{
|
|
|
43
43
|
readonly type: "string";
|
|
44
44
|
readonly description: "page colour(s) the flag will fly on, comma separated. Checked for contrast";
|
|
45
45
|
};
|
|
46
|
-
readonly
|
|
46
|
+
readonly allowLowContrast: {
|
|
47
47
|
readonly type: "boolean";
|
|
48
48
|
readonly description: "emit anyway when a contrast check fails. Says so in the output";
|
|
49
49
|
};
|
|
@@ -54,9 +54,37 @@ export declare const brandCommand: import("./execute.js").Command<{
|
|
|
54
54
|
* CLI's own weight and the framework's stay what they were (W4).
|
|
55
55
|
*/
|
|
56
56
|
export declare const devCommand: import("./execute.js").Command<{
|
|
57
|
-
readonly
|
|
57
|
+
readonly noWatch: {
|
|
58
58
|
readonly type: "boolean";
|
|
59
59
|
readonly description: "load once and serve; do not watch for changes";
|
|
60
60
|
};
|
|
61
61
|
}>;
|
|
62
|
+
/**
|
|
63
|
+
* `burgee migrate [dir]` — rewrite a commander or yargs project's imports to burgee's
|
|
64
|
+
* drop-in front-ends and report what changed, with the numbers that say why it was safe.
|
|
65
|
+
*
|
|
66
|
+
* The engine is loaded on this path only (K6), the same way `dev` is: a dynamic import, so
|
|
67
|
+
* `burgee`'s own start-up and the framework's weight are what they were. `weight.test.ts`
|
|
68
|
+
* denies `migrate.js` to the root entry by name, so that cannot drift back.
|
|
69
|
+
*
|
|
70
|
+
* `idempotent` is the honest answer rather than the conservative one, and it is earned:
|
|
71
|
+
* `burgee/commander` is not a key in the mapping, so a second run over a migrated tree
|
|
72
|
+
* rewrites nothing. N6 then requires the result to report `changed`, which it does.
|
|
73
|
+
*/
|
|
74
|
+
export declare const migrateCommand: import("./execute.js").Command<{
|
|
75
|
+
readonly dryRun: {
|
|
76
|
+
readonly type: "boolean";
|
|
77
|
+
readonly description: "scan and report; write nothing";
|
|
78
|
+
};
|
|
79
|
+
readonly force: {
|
|
80
|
+
readonly type: "boolean";
|
|
81
|
+
readonly description: "migrate even though the git tree has uncommitted changes";
|
|
82
|
+
};
|
|
83
|
+
}>;
|
|
84
|
+
/**
|
|
85
|
+
* `burgee check <plugin-file>` — the feedback loop PRINCIPLES 7 asks every extension surface
|
|
86
|
+
* for, and the one burgee did not have. See `check.ts`: this one returns its report as data, so
|
|
87
|
+
* `--json` is the form an agent that just wrote a plugin reads.
|
|
88
|
+
*/
|
|
89
|
+
export declare const pluginCheckCommand: import("./execute.js").Command<import("./execute.js").OptionSpecs>;
|
|
62
90
|
export declare const program: import("./manifest.js").Manifest;
|
package/dist/cli.js
CHANGED
|
@@ -44,14 +44,14 @@ export const brandCommand = defineCommand({
|
|
|
44
44
|
description: 'path to an SVG whose contents replace the bars, drawn in a 0 0 100 100 box',
|
|
45
45
|
},
|
|
46
46
|
bordure: { type: 'string', description: 'outline colour, hex. Omit for no outline' },
|
|
47
|
-
|
|
47
|
+
bordureWidth: { type: 'string', default: DEFAULT_BORDURE_WIDTH, description: 'outline width' },
|
|
48
48
|
tagline: { type: 'string', description: 'one line under the name on the card and cover' },
|
|
49
49
|
out: { type: 'string', description: 'directory to write into. Omit to print the flag only' },
|
|
50
50
|
'on': {
|
|
51
51
|
type: 'string',
|
|
52
52
|
description: 'page colour(s) the flag will fly on, comma separated. Checked for contrast',
|
|
53
53
|
},
|
|
54
|
-
|
|
54
|
+
allowLowContrast: {
|
|
55
55
|
type: 'boolean',
|
|
56
56
|
description: 'emit anyway when a contrast check fails. Says so in the output',
|
|
57
57
|
},
|
|
@@ -68,7 +68,7 @@ export const brandCommand = defineCommand({
|
|
|
68
68
|
: {
|
|
69
69
|
bordure: {
|
|
70
70
|
color: options.bordure,
|
|
71
|
-
width: Number(options
|
|
71
|
+
width: Number(options.bordureWidth ?? DEFAULT_BORDURE_WIDTH),
|
|
72
72
|
},
|
|
73
73
|
};
|
|
74
74
|
const brand = {
|
|
@@ -84,7 +84,7 @@ export const brandCommand = defineCommand({
|
|
|
84
84
|
.filter((g) => g !== '');
|
|
85
85
|
const findings = auditBurgee(brand, grounds);
|
|
86
86
|
const failed = findings.filter((f) => !f.passes);
|
|
87
|
-
if (failed.length > 0 && options
|
|
87
|
+
if (failed.length > 0 && options.allowLowContrast !== true) {
|
|
88
88
|
throw new Error(`contrast below WCAG AA:\n${report(failed)}\n${CONTRAST_HINT}`);
|
|
89
89
|
}
|
|
90
90
|
const written = surfaces(brand, options.tagline ?? '');
|
|
@@ -103,7 +103,7 @@ export const devCommand = defineCommand({
|
|
|
103
103
|
description: 'Watch a CLI entry, reload it on change, and serve it as MCP on stdio while you write it',
|
|
104
104
|
arguments: [{ name: 'entry', description: 'the module that exports the program, as program or as its default export', required: true }],
|
|
105
105
|
options: {
|
|
106
|
-
|
|
106
|
+
noWatch: { type: 'boolean', description: 'load once and serve; do not watch for changes' },
|
|
107
107
|
},
|
|
108
108
|
effects: 'withheld',
|
|
109
109
|
run: async ({ positionals, options }) => {
|
|
@@ -111,13 +111,42 @@ export const devCommand = defineCommand({
|
|
|
111
111
|
if (entry === undefined)
|
|
112
112
|
throw new Error('an entry file is required');
|
|
113
113
|
const [{ dev }, { processRuntime }] = await Promise.all([import('./dev.js'), import('./runtime.js')]);
|
|
114
|
-
const handle = dev({ entry, input: processRuntime.stdin, output: processRuntime.stdout, log: processRuntime.stderr, watch: options
|
|
114
|
+
const handle = dev({ entry, input: processRuntime.stdin, output: processRuntime.stdout, log: processRuntime.stderr, watch: options.noWatch !== true });
|
|
115
115
|
await handle.done;
|
|
116
116
|
},
|
|
117
117
|
});
|
|
118
|
+
export const migrateCommand = defineCommand({
|
|
119
|
+
name: 'migrate',
|
|
120
|
+
description: 'Rewrite commander and yargs imports to burgee’s drop-in front-ends, and report what changed',
|
|
121
|
+
arguments: [{ name: 'dir', description: 'the project to migrate. Defaults to the current directory', required: false }],
|
|
122
|
+
options: {
|
|
123
|
+
dryRun: { type: 'boolean', description: 'scan and report; write nothing' },
|
|
124
|
+
force: { type: 'boolean', description: 'migrate even though the git tree has uncommitted changes' },
|
|
125
|
+
},
|
|
126
|
+
effects: 'idempotent',
|
|
127
|
+
examples: [
|
|
128
|
+
{ command: 'burgee migrate --dry-run', description: 'what it would change, without changing it' },
|
|
129
|
+
{ command: 'burgee migrate --json', description: 'the same report as data; exit 1 when anything was refused' },
|
|
130
|
+
],
|
|
131
|
+
run: async ({ positionals, options }) => {
|
|
132
|
+
const [{ migrate }, { host }] = await Promise.all([import('./migrate.js'), import('./runtime.js')]);
|
|
133
|
+
return await migrate({ dir: positionals[0] ?? host.cwd(), dryRun: options.dryRun === true, force: options.force === true });
|
|
134
|
+
},
|
|
135
|
+
});
|
|
136
|
+
export const pluginCheckCommand = defineCommand({
|
|
137
|
+
name: 'check',
|
|
138
|
+
description: 'Validate a burgee plugin, register it into a throwaway program, and report what it contributes',
|
|
139
|
+
arguments: [{ name: 'file', description: 'the plugin module to check' }],
|
|
140
|
+
effects: 'read_only',
|
|
141
|
+
examples: [
|
|
142
|
+
{ command: 'burgee check ./my-plugin.mjs', description: 'what the plugin contributes, or why it was refused' },
|
|
143
|
+
{ command: 'burgee check ./my-plugin.mjs --json', description: 'the same, as data; exit 1 on a refusal' },
|
|
144
|
+
],
|
|
145
|
+
run: async ({ positionals }) => (await import('./check.js')).checkPlugin(positionals[0] ?? ''),
|
|
146
|
+
});
|
|
118
147
|
export const program = defineProgram({
|
|
119
148
|
name: 'burgee',
|
|
120
149
|
description: 'The agent-native CLI framework, and the tools that come with it',
|
|
121
|
-
commands: [brandCommand, devCommand],
|
|
150
|
+
commands: [brandCommand, devCommand, migrateCommand, pluginCheckCommand],
|
|
122
151
|
});
|
|
123
152
|
run(program);
|
|
@@ -8,7 +8,6 @@ export class Argument {
|
|
|
8
8
|
argChoices = undefined;
|
|
9
9
|
required;
|
|
10
10
|
_name;
|
|
11
|
-
/** `<required>`, `[optional]`, bare = required; a trailing `...` makes it variadic. */
|
|
12
11
|
constructor(name, description) {
|
|
13
12
|
this.description = description || '';
|
|
14
13
|
switch (name[0]) {
|
|
@@ -67,9 +66,7 @@ export class Argument {
|
|
|
67
66
|
return this;
|
|
68
67
|
}
|
|
69
68
|
}
|
|
70
|
-
/** `<name>` / `[name]` / `<name...>` for usage strings. */
|
|
71
69
|
export function humanReadableArgName(arg) {
|
|
72
70
|
const nameOutput = arg.name() + (arg.variadic ? '...' : '');
|
|
73
71
|
return arg.required ? `<${nameOutput}>` : `[${nameOutput}]`;
|
|
74
72
|
}
|
|
75
|
-
//# sourceMappingURL=argument.js.map
|
|
@@ -72,6 +72,8 @@ interface SavedState {
|
|
|
72
72
|
interface Burgee {
|
|
73
73
|
exit: ((code: number) => void) | undefined;
|
|
74
74
|
json: boolean;
|
|
75
|
+
/** One failure, one envelope (G5). */
|
|
76
|
+
reported?: boolean;
|
|
75
77
|
}
|
|
76
78
|
export declare class Command extends EventEmitter {
|
|
77
79
|
commands: Command[];
|
|
@@ -244,6 +246,8 @@ export declare class Command extends EventEmitter {
|
|
|
244
246
|
optsWithGlobals(): Record<string, unknown>;
|
|
245
247
|
/** Display an error message and exit (or call exitOverride). */
|
|
246
248
|
error(message: string, errorOptions?: ErrorOptions): never;
|
|
249
|
+
/** One failure as the envelope (E3, G5); `fix` only when one candidate was named. */
|
|
250
|
+
_reportJson(code: string, message: string): void;
|
|
247
251
|
/** Apply environment variables to options that have no value from the cli or client code. */
|
|
248
252
|
_parseOptionsEnv(): void;
|
|
249
253
|
/** Apply implied option values where the option is undefined or at its default. */
|
|
@@ -328,15 +332,15 @@ export declare class Command extends EventEmitter {
|
|
|
328
332
|
*/
|
|
329
333
|
_burgeeSurface(userArgs: string[]): boolean | Promise<boolean>;
|
|
330
334
|
/** The surfaces after `completion`: `--schema` is synchronous, `--mcp` serves until stdin closes. */
|
|
331
|
-
_burgeeSurfaceRest(head: string[]
|
|
335
|
+
_burgeeSurfaceRest(head: string[]): boolean | Promise<boolean>;
|
|
332
336
|
/** Additive, and the point of the whole exercise: plugins commander has never had (#2505, unlanded). */
|
|
333
337
|
use(plugin: Plugin): this;
|
|
334
338
|
/** Inject the streams and the exit for one parse; returns commander's own parse options. */
|
|
335
339
|
_prepareBurgee(parseOptions?: BurgeeParseOptions): ParseOptions | undefined;
|
|
336
340
|
/** In burgee mode the whole run settles to one E1 exit; otherwise commander's behaviour, untouched. */
|
|
337
341
|
_runBurgee(run: () => unknown): unknown;
|
|
338
|
-
/**
|
|
339
|
-
|
|
342
|
+
/** Any command from here down declares this flag, so burgee does not serve it: additive only. */
|
|
343
|
+
_declares(flag: string): boolean;
|
|
340
344
|
/** The action, wrapped in the plugin hooks and followed by the envelope or the rendering. */
|
|
341
345
|
_runAction(): unknown;
|
|
342
346
|
/** burgee (M5): once per process, on stderr; only for a command that asked, so commander's own output is untouched. */
|