@memberjunction/cli 6.1.0-edge.3 → 6.1.0-edge.5
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 +81 -0
- package/dist/commands/ai/actions/list.d.ts +2 -1
- package/dist/commands/ai/actions/list.d.ts.map +1 -1
- package/dist/commands/ai/actions/list.js +12 -3
- package/dist/commands/ai/actions/list.js.map +1 -1
- package/dist/commands/ai/actions/run.d.ts +7 -6
- package/dist/commands/ai/actions/run.d.ts.map +1 -1
- package/dist/commands/ai/actions/run.js +15 -16
- package/dist/commands/ai/actions/run.js.map +1 -1
- package/dist/commands/ai/agents/list.d.ts +2 -1
- package/dist/commands/ai/agents/list.d.ts.map +1 -1
- package/dist/commands/ai/agents/list.js +12 -3
- package/dist/commands/ai/agents/list.js.map +1 -1
- package/dist/commands/ai/agents/run.d.ts +7 -6
- package/dist/commands/ai/agents/run.d.ts.map +1 -1
- package/dist/commands/ai/agents/run.js +27 -5
- package/dist/commands/ai/agents/run.js.map +1 -1
- package/dist/commands/ai/audit/agent-run.d.ts +15 -14
- package/dist/commands/ai/audit/agent-run.d.ts.map +1 -1
- package/dist/commands/ai/audit/agent-run.js +18 -6
- package/dist/commands/ai/audit/agent-run.js.map +1 -1
- package/dist/commands/ai/prompts/run.d.ts +10 -9
- package/dist/commands/ai/prompts/run.d.ts.map +1 -1
- package/dist/commands/ai/prompts/run.js +12 -3
- package/dist/commands/ai/prompts/run.js.map +1 -1
- package/dist/commands/ai/usage.d.ts +7 -0
- package/dist/commands/ai/usage.d.ts.map +1 -0
- package/dist/commands/ai/usage.js +10 -0
- package/dist/commands/ai/usage.js.map +1 -0
- package/dist/commands/app/check-updates.d.ts.map +1 -1
- package/dist/commands/app/check-updates.js +55 -17
- package/dist/commands/app/check-updates.js.map +1 -1
- package/dist/commands/app/remove.d.ts.map +1 -1
- package/dist/commands/app/remove.js +12 -4
- package/dist/commands/app/remove.js.map +1 -1
- package/dist/commands/app/usage.d.ts +7 -0
- package/dist/commands/app/usage.d.ts.map +1 -0
- package/dist/commands/app/usage.js +10 -0
- package/dist/commands/app/usage.js.map +1 -0
- package/dist/commands/artifacts/usage.d.ts +7 -0
- package/dist/commands/artifacts/usage.d.ts.map +1 -0
- package/dist/commands/artifacts/usage.js +10 -0
- package/dist/commands/artifacts/usage.js.map +1 -0
- package/dist/commands/baseline/usage.d.ts +7 -0
- package/dist/commands/baseline/usage.d.ts.map +1 -0
- package/dist/commands/baseline/usage.js +10 -0
- package/dist/commands/baseline/usage.js.map +1 -0
- package/dist/commands/bump/usage.d.ts +7 -0
- package/dist/commands/bump/usage.d.ts.map +1 -0
- package/dist/commands/bump/usage.js +10 -0
- package/dist/commands/bump/usage.js.map +1 -0
- package/dist/commands/bundle/usage.d.ts +7 -0
- package/dist/commands/bundle/usage.d.ts.map +1 -0
- package/dist/commands/bundle/usage.js +10 -0
- package/dist/commands/bundle/usage.js.map +1 -0
- package/dist/commands/clean/usage.d.ts +7 -0
- package/dist/commands/clean/usage.d.ts.map +1 -0
- package/dist/commands/clean/usage.js +10 -0
- package/dist/commands/clean/usage.js.map +1 -0
- package/dist/commands/dbdoc/usage.d.ts +7 -0
- package/dist/commands/dbdoc/usage.d.ts.map +1 -0
- package/dist/commands/dbdoc/usage.js +10 -0
- package/dist/commands/dbdoc/usage.js.map +1 -0
- package/dist/commands/dev/workspace/index.d.ts.map +1 -1
- package/dist/commands/dev/workspace/index.js +7 -2
- package/dist/commands/dev/workspace/index.js.map +1 -1
- package/dist/commands/doctor/usage.d.ts +7 -0
- package/dist/commands/doctor/usage.d.ts.map +1 -0
- package/dist/commands/doctor/usage.js +10 -0
- package/dist/commands/doctor/usage.js.map +1 -0
- package/dist/commands/install/index.d.ts +20 -0
- package/dist/commands/install/index.d.ts.map +1 -1
- package/dist/commands/install/index.js +80 -10
- package/dist/commands/install/index.js.map +1 -1
- package/dist/commands/install/usage.d.ts +7 -0
- package/dist/commands/install/usage.d.ts.map +1 -0
- package/dist/commands/install/usage.js +10 -0
- package/dist/commands/install/usage.js.map +1 -0
- package/dist/commands/migrate/convert.d.ts +26 -0
- package/dist/commands/migrate/convert.d.ts.map +1 -1
- package/dist/commands/migrate/convert.js +115 -13
- package/dist/commands/migrate/convert.js.map +1 -1
- package/dist/commands/migrate/index.d.ts +9 -0
- package/dist/commands/migrate/index.d.ts.map +1 -1
- package/dist/commands/migrate/index.js +41 -1
- package/dist/commands/migrate/index.js.map +1 -1
- package/dist/commands/migrate/rebake.d.ts +1 -0
- package/dist/commands/migrate/rebake.d.ts.map +1 -1
- package/dist/commands/migrate/rebake.js +16 -6
- package/dist/commands/migrate/rebake.js.map +1 -1
- package/dist/commands/migrate/usage.d.ts +7 -0
- package/dist/commands/migrate/usage.d.ts.map +1 -0
- package/dist/commands/migrate/usage.js +10 -0
- package/dist/commands/migrate/usage.js.map +1 -0
- package/dist/commands/plugin/usage.d.ts +7 -0
- package/dist/commands/plugin/usage.d.ts.map +1 -0
- package/dist/commands/plugin/usage.js +10 -0
- package/dist/commands/plugin/usage.js.map +1 -0
- package/dist/commands/querygen/usage.d.ts +7 -0
- package/dist/commands/querygen/usage.d.ts.map +1 -0
- package/dist/commands/querygen/usage.js +10 -0
- package/dist/commands/querygen/usage.js.map +1 -0
- package/dist/commands/sql-audit/usage.d.ts +7 -0
- package/dist/commands/sql-audit/usage.d.ts.map +1 -0
- package/dist/commands/sql-audit/usage.js +10 -0
- package/dist/commands/sql-audit/usage.js.map +1 -0
- package/dist/commands/sql-convert/usage.d.ts +7 -0
- package/dist/commands/sql-convert/usage.d.ts.map +1 -0
- package/dist/commands/sql-convert/usage.js +10 -0
- package/dist/commands/sql-convert/usage.js.map +1 -0
- package/dist/commands/standards/usage.d.ts +7 -0
- package/dist/commands/standards/usage.d.ts.map +1 -0
- package/dist/commands/standards/usage.js +10 -0
- package/dist/commands/standards/usage.js.map +1 -0
- package/dist/commands/sync/file-reset.d.ts +6 -6
- package/dist/commands/sync/file-reset.d.ts.map +1 -1
- package/dist/commands/sync/file-reset.js +151 -127
- package/dist/commands/sync/file-reset.js.map +1 -1
- package/dist/commands/sync/init.d.ts +10 -1
- package/dist/commands/sync/init.d.ts.map +1 -1
- package/dist/commands/sync/init.js +127 -78
- package/dist/commands/sync/init.js.map +1 -1
- package/dist/commands/test/compare.d.ts +11 -11
- package/dist/commands/test/compare.d.ts.map +1 -1
- package/dist/commands/test/compare.js +8 -7
- package/dist/commands/test/compare.js.map +1 -1
- package/dist/commands/test/history.d.ts +7 -7
- package/dist/commands/test/history.d.ts.map +1 -1
- package/dist/commands/test/history.js +8 -7
- package/dist/commands/test/history.js.map +1 -1
- package/dist/commands/test/list.d.ts +8 -8
- package/dist/commands/test/list.d.ts.map +1 -1
- package/dist/commands/test/list.js +8 -7
- package/dist/commands/test/list.js.map +1 -1
- package/dist/commands/test/regression/compare.d.ts.map +1 -1
- package/dist/commands/test/regression/compare.js +5 -7
- package/dist/commands/test/regression/compare.js.map +1 -1
- package/dist/commands/test/run.d.ts +9 -9
- package/dist/commands/test/run.d.ts.map +1 -1
- package/dist/commands/test/run.js +8 -7
- package/dist/commands/test/run.js.map +1 -1
- package/dist/commands/test/suite.d.ts +11 -11
- package/dist/commands/test/suite.d.ts.map +1 -1
- package/dist/commands/test/suite.js +8 -7
- package/dist/commands/test/suite.js.map +1 -1
- package/dist/commands/test/usage.d.ts +7 -0
- package/dist/commands/test/usage.d.ts.map +1 -0
- package/dist/commands/test/usage.js +10 -0
- package/dist/commands/test/usage.js.map +1 -0
- package/dist/commands/test/validate.d.ts +7 -7
- package/dist/commands/test/validate.d.ts.map +1 -1
- package/dist/commands/test/validate.js +8 -7
- package/dist/commands/test/validate.js.map +1 -1
- package/dist/commands/translate-sql/usage.d.ts +7 -0
- package/dist/commands/translate-sql/usage.d.ts.map +1 -0
- package/dist/commands/translate-sql/usage.js +10 -0
- package/dist/commands/translate-sql/usage.js.map +1 -0
- package/dist/commands/update/usage.d.ts +7 -0
- package/dist/commands/update/usage.d.ts.map +1 -0
- package/dist/commands/update/usage.js +10 -0
- package/dist/commands/update/usage.js.map +1 -0
- package/dist/commands/usage.d.ts.map +1 -1
- package/dist/commands/usage.js +9 -4
- package/dist/commands/usage.js.map +1 -1
- package/dist/hooks/prerun.d.ts.map +1 -1
- package/dist/hooks/prerun.js +63 -30
- package/dist/hooks/prerun.js.map +1 -1
- package/dist/lib/cli-plugins.d.ts +8 -1
- package/dist/lib/cli-plugins.d.ts.map +1 -1
- package/dist/lib/cli-plugins.js +17 -1
- package/dist/lib/cli-plugins.js.map +1 -1
- package/dist/lib/derived-usage.d.ts +68 -0
- package/dist/lib/derived-usage.d.ts.map +1 -0
- package/dist/lib/derived-usage.js +121 -0
- package/dist/lib/derived-usage.js.map +1 -0
- package/dist/lib/domain-profiles.d.ts +42 -0
- package/dist/lib/domain-profiles.d.ts.map +1 -0
- package/dist/lib/domain-profiles.js +118 -0
- package/dist/lib/domain-profiles.js.map +1 -0
- package/dist/lib/domain-usage-command.d.ts.map +1 -1
- package/dist/lib/domain-usage-command.js +9 -4
- package/dist/lib/domain-usage-command.js.map +1 -1
- package/dist/lib/format-compat.d.ts +68 -0
- package/dist/lib/format-compat.d.ts.map +1 -0
- package/dist/lib/format-compat.js +111 -0
- package/dist/lib/format-compat.js.map +1 -0
- package/dist/lib/interactive-guard.d.ts +56 -0
- package/dist/lib/interactive-guard.d.ts.map +1 -0
- package/dist/lib/interactive-guard.js +60 -0
- package/dist/lib/interactive-guard.js.map +1 -0
- package/dist/lib/legacy-install.d.ts.map +1 -1
- package/dist/lib/legacy-install.js +4 -0
- package/dist/lib/legacy-install.js.map +1 -1
- package/dist/lib/usage-render.d.ts +2 -2
- package/dist/lib/usage-render.d.ts.map +1 -1
- package/dist/lib/usage-render.js +2 -1
- package/dist/lib/usage-render.js.map +1 -1
- package/dist/light-commands.d.ts.map +1 -1
- package/dist/light-commands.js +43 -0
- package/dist/light-commands.js.map +1 -1
- package/dist/utils/open-app-context.d.ts +24 -0
- package/dist/utils/open-app-context.d.ts.map +1 -1
- package/dist/utils/open-app-context.js +21 -6
- package/dist/utils/open-app-context.js.map +1 -1
- package/dist/utils/update-check.d.ts +86 -0
- package/dist/utils/update-check.d.ts.map +1 -0
- package/dist/utils/update-check.js +98 -0
- package/dist/utils/update-check.js.map +1 -0
- package/oclif.manifest.json +4099 -3239
- package/package.json +21 -21
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { DomainUsageCommand } from '../../lib/domain-usage-command.js';
|
|
2
|
+
/** Tier-2 usage for the `update` domain (`mj update usage`). */
|
|
3
|
+
export default class UpdateUsage extends DomainUsageCommand {
|
|
4
|
+
static description: string;
|
|
5
|
+
protected Domain: string;
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=usage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usage.d.ts","sourceRoot":"","sources":["../../../src/commands/update/usage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,mCAAmC,CAAC;AAEvE,gEAAgE;AAChE,MAAM,CAAC,OAAO,OAAO,WAAY,SAAQ,kBAAkB;IACzD,MAAM,CAAC,WAAW,SAAmF;IACrG,SAAS,CAAC,MAAM,SAAY;CAC7B"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { DomainUsageCommand } from '../../lib/domain-usage-command.js';
|
|
2
|
+
/** Tier-2 usage for the `update` domain (`mj update usage`). */
|
|
3
|
+
export default class UpdateUsage extends DomainUsageCommand {
|
|
4
|
+
constructor() {
|
|
5
|
+
super(...arguments);
|
|
6
|
+
this.Domain = 'update';
|
|
7
|
+
}
|
|
8
|
+
static { this.description = 'Show usage, flags, examples, and runtime hints for every `mj update` command.'; }
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=usage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usage.js","sourceRoot":"","sources":["../../../src/commands/update/usage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,mCAAmC,CAAC;AAEvE,gEAAgE;AAChE,MAAM,CAAC,OAAO,OAAO,WAAY,SAAQ,kBAAkB;IAA3D;;QAEY,WAAM,GAAG,QAAQ,CAAC;IAC9B,CAAC;aAFQ,gBAAW,GAAG,+EAA+E,AAAlF,CAAmF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usage.d.ts","sourceRoot":"","sources":["../../src/commands/usage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAS,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"usage.d.ts","sourceRoot":"","sources":["../../src/commands/usage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAS,MAAM,aAAa,CAAC;AAM7C;;;;;;GAMG;AACH,MAAM,CAAC,OAAO,OAAO,KAAM,SAAQ,OAAO;IACxC,MAAM,CAAC,WAAW,SAA+G;IAEjI,MAAM,CAAC,QAAQ,WAGb;IAEF,MAAM,CAAC,KAAK;;MAMV;IAEI,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CAQ3B"}
|
package/dist/commands/usage.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Command, Flags } from '@oclif/core';
|
|
2
|
-
import { CLIPluginRegistry } from '@memberjunction/cli-core';
|
|
2
|
+
import { CLIPluginRegistry, ResolveOutputFormat } from '@memberjunction/cli-core';
|
|
3
3
|
import { loadAllCliPlugins } from '../lib/cli-plugins.js';
|
|
4
4
|
import { emitUsage, renderDomainMap } from '../lib/usage-render.js';
|
|
5
5
|
/**
|
|
@@ -16,14 +16,19 @@ export default class Usage extends Command {
|
|
|
16
16
|
`<%= config.bin %> <%= command.id %> --format=json`,
|
|
17
17
|
]; }
|
|
18
18
|
static { this.flags = {
|
|
19
|
-
|
|
19
|
+
// No default: the absence of a value is what lets a piped stdout select json.
|
|
20
|
+
format: Flags.string({
|
|
21
|
+
options: ['text', 'json', 'md'],
|
|
22
|
+
description: 'Output format. Defaults to text on a terminal and json when stdout is piped.',
|
|
23
|
+
}),
|
|
20
24
|
}; }
|
|
21
25
|
async run() {
|
|
22
26
|
const { flags } = await this.parse(Usage);
|
|
23
|
-
await loadAllCliPlugins(process.cwd());
|
|
27
|
+
await loadAllCliPlugins(process.cwd(), this.config.commands);
|
|
24
28
|
const map = CLIPluginRegistry.BuildDomainMap();
|
|
25
29
|
const result = CLIPluginRegistry.AsResult('usage', { guidance: map.guidance, domains: map.domains });
|
|
26
|
-
|
|
30
|
+
const { format } = ResolveOutputFormat({ formatFlag: flags.format });
|
|
31
|
+
emitUsage((m) => this.log(m), format, result, renderDomainMap(map));
|
|
27
32
|
}
|
|
28
33
|
}
|
|
29
34
|
//# sourceMappingURL=usage.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usage.js","sourceRoot":"","sources":["../../src/commands/usage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"usage.js","sourceRoot":"","sources":["../../src/commands/usage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAClF,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAGpE;;;;;;GAMG;AACH,MAAM,CAAC,OAAO,OAAO,KAAM,SAAQ,OAAO;aACjC,gBAAW,GAAG,2GAA2G,CAAC;aAE1H,aAAQ,GAAG;QAChB,qCAAqC;QACrC,mDAAmD;KACpD,CAAC;aAEK,UAAK,GAAG;QACb,8EAA8E;QAC9E,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC;YACnB,OAAO,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,CAAC;YAC/B,WAAW,EAAE,8EAA8E;SAC5F,CAAC;KACH,CAAC;IAEF,KAAK,CAAC,GAAG;QACP,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QAC1C,MAAM,iBAAiB,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,IAAI,CAAC,MAAM,CAAC,QAA0C,CAAC,CAAC;QAC/F,MAAM,GAAG,GAAG,iBAAiB,CAAC,cAAc,EAAE,CAAC;QAC/C,MAAM,MAAM,GAAG,iBAAiB,CAAC,QAAQ,CAAC,OAAO,EAAE,EAAE,QAAQ,EAAE,GAAG,CAAC,QAAQ,EAAE,OAAO,EAAE,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC;QACrG,MAAM,EAAE,MAAM,EAAE,GAAG,mBAAmB,CAAC,EAAE,UAAU,EAAE,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC;QACrE,SAAS,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,eAAe,CAAC,GAAG,CAAC,CAAC,CAAC;IACtE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prerun.d.ts","sourceRoot":"","sources":["../../src/hooks/prerun.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"prerun.d.ts","sourceRoot":"","sources":["../../src/hooks/prerun.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAgCnC,QAAA,MAAM,IAAI,EAAE,IAAI,CAAC,QAAQ,CA2ExB,CAAC;AAcF,eAAe,IAAI,CAAC"}
|
package/dist/hooks/prerun.js
CHANGED
|
@@ -1,42 +1,75 @@
|
|
|
1
1
|
import figlet from 'figlet';
|
|
2
|
+
import { INTERACTIVE_ENV, ResolveOutputFormat, ShouldSuppressChrome } from '@memberjunction/cli-core';
|
|
2
3
|
import { LIGHT_COMMANDS } from '../light-commands.js';
|
|
4
|
+
/**
|
|
5
|
+
* Strips a global boolean flag from argv in place and reports whether it was there.
|
|
6
|
+
*
|
|
7
|
+
* Global chrome flags have to work on ANY command, including the ~80 that are still
|
|
8
|
+
* plain oclif `Command`s and don't declare them — oclif's strict parser would reject
|
|
9
|
+
* an undeclared flag with "Nonexistent flag". So the hook consumes them here and
|
|
10
|
+
* signals downstream through the environment instead.
|
|
11
|
+
*/
|
|
12
|
+
function takeGlobalFlag(argv, flag) {
|
|
13
|
+
let found = false;
|
|
14
|
+
for (let i = argv.length - 1; i >= 0; i--) {
|
|
15
|
+
if (argv[i] === flag) {
|
|
16
|
+
argv.splice(i, 1);
|
|
17
|
+
found = true;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return found;
|
|
21
|
+
}
|
|
22
|
+
/** Reads `--format=x` or `--format x` out of raw argv, before any command has parsed it. */
|
|
23
|
+
function readFormatArg(argv) {
|
|
24
|
+
const eq = argv.find((a) => a.startsWith('--format='));
|
|
25
|
+
if (eq)
|
|
26
|
+
return eq.slice('--format='.length);
|
|
27
|
+
const i = argv.indexOf('--format');
|
|
28
|
+
return i >= 0 ? argv[i + 1] : undefined;
|
|
29
|
+
}
|
|
3
30
|
const hook = async function (options) {
|
|
4
31
|
const argv = options.argv ?? [];
|
|
5
|
-
//
|
|
6
|
-
//
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
// commands still gate their runtime advisory) and strip the flag from argv in place
|
|
21
|
-
// so the per-command parser never sees an undeclared flag.
|
|
32
|
+
// `--interactive` / `--no-interactive` override the terminal detection that decides
|
|
33
|
+
// whether a command may prompt. Like `--no-banner` they must work on every command,
|
|
34
|
+
// including the ~80 that don't declare them, so they are consumed here and forwarded
|
|
35
|
+
// via env to both BaseCLIPlugin and the unmigrated commands' interactive guards.
|
|
36
|
+
// BOTH are stripped unconditionally before either is acted on: short-circuiting the
|
|
37
|
+
// second strip would leave the losing flag in argv, where oclif's strict parser
|
|
38
|
+
// rejects it as a nonexistent flag on any command that doesn't declare it.
|
|
39
|
+
const forceOff = takeGlobalFlag(argv, '--no-interactive');
|
|
40
|
+
const forceOn = takeGlobalFlag(argv, '--interactive');
|
|
41
|
+
// Passing both resolves to off — the safe answer when the caller contradicts itself.
|
|
42
|
+
if (forceOff)
|
|
43
|
+
process.env[INTERACTIVE_ENV] = '0';
|
|
44
|
+
else if (forceOn)
|
|
45
|
+
process.env[INTERACTIVE_ENV] = '1';
|
|
46
|
+
const noBanner = takeGlobalFlag(argv, '--no-banner');
|
|
22
47
|
if (noBanner) {
|
|
23
48
|
process.env.MJ_CLI_NO_BANNER = '1';
|
|
24
|
-
for (let i = argv.length - 1; i >= 0; i--) {
|
|
25
|
-
if (argv[i] === '--no-banner')
|
|
26
|
-
argv.splice(i, 1);
|
|
27
|
-
}
|
|
28
49
|
}
|
|
29
|
-
//
|
|
30
|
-
|
|
31
|
-
|
|
50
|
+
// Decide chrome with the SAME resolver the commands themselves use, rather than
|
|
51
|
+
// re-deriving the format from argv here. The two views drifting is not hypothetical:
|
|
52
|
+
// while this hook only looked for `--format` in argv, `MJ_CLI_FORMAT=json mj codegen`
|
|
53
|
+
// at a terminal printed a figlet banner and *then* a JSON envelope — the env var the
|
|
54
|
+
// command honours was invisible to the banner decision, and the pipe check that would
|
|
55
|
+
// otherwise have saved us does not fire on a TTY. Routing both through
|
|
56
|
+
// ResolveOutputFormat makes that class of mismatch unrepresentable, and picks up the
|
|
57
|
+
// format aliases (`markdown`, `console`, …) for free.
|
|
58
|
+
const { format } = ResolveOutputFormat({
|
|
59
|
+
formatFlag: readFormatArg(argv),
|
|
60
|
+
// oclif's own `--json` boolean, declared by install:claude / update:claude.
|
|
61
|
+
jsonFlag: argv.includes('--json'),
|
|
62
|
+
});
|
|
63
|
+
const quiet = argv.some((arg) => arg === '--quiet' || (/^-[^-]+/.test(arg) && arg.includes('q')));
|
|
64
|
+
// ShouldSuppressChrome covers both machine formats and a redirected stdout: a caller
|
|
65
|
+
// that piped us has already said it is a machine, and a banner in its capture buffer
|
|
66
|
+
// is pure noise.
|
|
67
|
+
if (noBanner || quiet || ShouldSuppressChrome(format)) {
|
|
68
|
+
// Still conditionally load bootstrap — just no decorative output. (The old `--json`
|
|
69
|
+
// branch returned *without* loading it, which would have silently skipped class
|
|
70
|
+
// registration for any heavy command that later grew a `--json` flag.)
|
|
32
71
|
return await maybeLoadBootstrap(options);
|
|
33
72
|
}
|
|
34
|
-
// Skip banners entirely when --json is requested — the contract for --json
|
|
35
|
-
// is that stdout is parseable JSON, and any banner above it breaks
|
|
36
|
-
// `mj … --json | jq`. This early-return also skips the userAgent line below.
|
|
37
|
-
if (options.argv?.some((arg) => arg === '--json')) {
|
|
38
|
-
return;
|
|
39
|
-
}
|
|
40
73
|
// Suppress the large figlet banner for hot-path, frequently-run commands (e.g. `mj sync *`)
|
|
41
74
|
// and the agent-facing usage commands, where it's pure scrollback cost. The
|
|
42
75
|
// compact userAgent line below still prints.
|
package/dist/hooks/prerun.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prerun.js","sourceRoot":"","sources":["../../src/hooks/prerun.ts"],"names":[],"mappings":"AACA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD,
|
|
1
|
+
{"version":3,"file":"prerun.js","sourceRoot":"","sources":["../../src/hooks/prerun.ts"],"names":[],"mappings":"AACA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC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OclifCommandShape } from './derived-usage.js';
|
|
1
2
|
/**
|
|
2
3
|
* Loads all CLI plugins so their `@RegisterClass(BaseCLIPlugin, …)` decorators
|
|
3
4
|
* populate the ClassFactory — the basis for the `mj usage` / `mj <domain> usage`
|
|
@@ -11,6 +12,12 @@
|
|
|
11
12
|
* These plugin modules are intentionally light — they static-import only
|
|
12
13
|
* cli-core + oclif + global and dynamic-import their heavy engines at execution
|
|
13
14
|
* time — so loading them here for usage composition is cheap.
|
|
15
|
+
*
|
|
16
|
+
* Finally, when the caller passes oclif's own command list, every command that no
|
|
17
|
+
* plugin declared gets a usage entry derived from oclif's manifest. Registration
|
|
18
|
+
* order is load-bearing: plugin metadata is read first and `RegisterUsage` is
|
|
19
|
+
* first-wins, so a migrated command keeps its curated entry and only the rest fall
|
|
20
|
+
* back to derivation.
|
|
14
21
|
*/
|
|
15
|
-
export declare function loadAllCliPlugins(searchFrom?: string): Promise<void>;
|
|
22
|
+
export declare function loadAllCliPlugins(searchFrom?: string, oclifCommands?: readonly OclifCommandShape[]): Promise<void>;
|
|
16
23
|
//# sourceMappingURL=cli-plugins.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli-plugins.d.ts","sourceRoot":"","sources":["../../src/lib/cli-plugins.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"cli-plugins.d.ts","sourceRoot":"","sources":["../../src/lib/cli-plugins.ts"],"names":[],"mappings":"AAEA,OAAO,EAAwB,KAAK,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAGlF;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAsB,iBAAiB,CACrC,UAAU,GAAE,MAAsB,EAClC,aAAa,CAAC,EAAE,SAAS,iBAAiB,EAAE,GAC3C,OAAO,CAAC,IAAI,CAAC,CAsBf"}
|
package/dist/lib/cli-plugins.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { CLIPluginRegistry } from '@memberjunction/cli-core';
|
|
2
2
|
import { RegisterDevWorkspaceUsage } from './dev-workspace/usage.js';
|
|
3
|
+
import { registerDerivedUsage } from './derived-usage.js';
|
|
4
|
+
import { DOMAIN_PROFILES } from './domain-profiles.js';
|
|
3
5
|
/**
|
|
4
6
|
* Loads all CLI plugins so their `@RegisterClass(BaseCLIPlugin, …)` decorators
|
|
5
7
|
* populate the ClassFactory — the basis for the `mj usage` / `mj <domain> usage`
|
|
@@ -13,8 +15,14 @@ import { RegisterDevWorkspaceUsage } from './dev-workspace/usage.js';
|
|
|
13
15
|
* These plugin modules are intentionally light — they static-import only
|
|
14
16
|
* cli-core + oclif + global and dynamic-import their heavy engines at execution
|
|
15
17
|
* time — so loading them here for usage composition is cheap.
|
|
18
|
+
*
|
|
19
|
+
* Finally, when the caller passes oclif's own command list, every command that no
|
|
20
|
+
* plugin declared gets a usage entry derived from oclif's manifest. Registration
|
|
21
|
+
* order is load-bearing: plugin metadata is read first and `RegisterUsage` is
|
|
22
|
+
* first-wins, so a migrated command keeps its curated entry and only the rest fall
|
|
23
|
+
* back to derivation.
|
|
16
24
|
*/
|
|
17
|
-
export async function loadAllCliPlugins(searchFrom = process.cwd()) {
|
|
25
|
+
export async function loadAllCliPlugins(searchFrom = process.cwd(), oclifCommands) {
|
|
18
26
|
await import('@memberjunction/metadata-sync/plugins');
|
|
19
27
|
await import('@memberjunction/codegen-lib/plugins');
|
|
20
28
|
// The `dev` domain ships inside this CLI as plain oclif commands (they must stay
|
|
@@ -27,5 +35,13 @@ export async function loadAllCliPlugins(searchFrom = process.cwd()) {
|
|
|
27
35
|
for (const f of failed) {
|
|
28
36
|
process.stderr.write(`Warning: could not load CLI plugin "${f.specifier}": ${f.error}\n`);
|
|
29
37
|
}
|
|
38
|
+
// Tier-1 domain summaries: a hand-written line beats one synthesized from N command
|
|
39
|
+
// summaries. Registered for every profiled domain, including plugin-backed ones —
|
|
40
|
+
// first-wins means a plugin that already declared one keeps it.
|
|
41
|
+
for (const [domain, profile] of Object.entries(DOMAIN_PROFILES)) {
|
|
42
|
+
CLIPluginRegistry.RegisterDomainSummary(domain, profile.summary);
|
|
43
|
+
}
|
|
44
|
+
if (oclifCommands?.length)
|
|
45
|
+
registerDerivedUsage(oclifCommands);
|
|
30
46
|
}
|
|
31
47
|
//# sourceMappingURL=cli-plugins.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli-plugins.js","sourceRoot":"","sources":["../../src/lib/cli-plugins.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,yBAAyB,EAAE,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"cli-plugins.js","sourceRoot":"","sources":["../../src/lib/cli-plugins.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,yBAAyB,EAAE,MAAM,0BAA0B,CAAC;AACrE,OAAO,EAAE,oBAAoB,EAA0B,MAAM,oBAAoB,CAAC;AAClF,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAEvD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,aAAqB,OAAO,CAAC,GAAG,EAAE,EAClC,aAA4C;IAE5C,MAAM,MAAM,CAAC,uCAAuC,CAAC,CAAC;IACtD,MAAM,MAAM,CAAC,qCAAqC,CAAC,CAAC;IACpD,iFAAiF;IACjF,oFAAoF;IACpF,2DAA2D;IAC3D,yBAAyB,EAAE,CAAC;IAC5B,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,iBAAiB,CAAC,qBAAqB,CAAC,UAAU,CAAC,CAAC;IAC7E,6EAA6E;IAC7E,oDAAoD;IACpD,KAAK,MAAM,CAAC,IAAI,MAAM,EAAE,CAAC;QACvB,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,uCAAuC,CAAC,CAAC,SAAS,MAAM,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC;IAC5F,CAAC;IAED,oFAAoF;IACpF,kFAAkF;IAClF,gEAAgE;IAChE,KAAK,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,eAAe,CAAC,EAAE,CAAC;QAChE,iBAAiB,CAAC,qBAAqB,CAAC,MAAM,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;IACnE,CAAC;IAED,IAAI,aAAa,EAAE,MAAM;QAAE,oBAAoB,CAAC,aAAa,CAAC,CAAC;AACjE,CAAC"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Derives `mj usage` entries for the commands that are still plain oclif
|
|
3
|
+
* `Command`s, straight from oclif's own manifest.
|
|
4
|
+
*
|
|
5
|
+
* Why derive rather than hand-write: `mj usage` tier 1 tells an agent
|
|
6
|
+
* *"Run `mj <domain> usage` before invoking. Do NOT guess flags."* — so a domain
|
|
7
|
+
* absent from that map reads as "this domain does not exist". Before this, only the
|
|
8
|
+
* handful of `BaseCLIPlugin` domains were registered, and the map confidently
|
|
9
|
+
* advertised a fraction of the CLI. A map that lies by omission is worse than no map,
|
|
10
|
+
* because an agent has no way to tell the difference.
|
|
11
|
+
*
|
|
12
|
+
* Hand-writing 80-odd `PluginUsage` literals would have fixed it once and rotted
|
|
13
|
+
* immediately. oclif already holds every command's description, flags, and examples
|
|
14
|
+
* and cannot fall out of sync with itself, so the only thing left to hand-maintain
|
|
15
|
+
* is what oclif genuinely doesn't know: the runtime budget (see `domain-profiles.ts`).
|
|
16
|
+
*
|
|
17
|
+
* Registration is additive and never overwrites: `CLIPluginRegistry.RegisterUsage`
|
|
18
|
+
* keeps the first entry per command key, and plugin-declared `static Usage` is read
|
|
19
|
+
* first, so a migrated command always keeps its richer, curated metadata.
|
|
20
|
+
*/
|
|
21
|
+
import { type PluginUsage } from '@memberjunction/cli-core';
|
|
22
|
+
/**
|
|
23
|
+
* The slice of oclif's `Command.Loadable` this module reads.
|
|
24
|
+
*
|
|
25
|
+
* Declared structurally rather than imported so the derivation can be unit-tested
|
|
26
|
+
* with plain literals, and so a future oclif shape change surfaces here rather than
|
|
27
|
+
* in every caller.
|
|
28
|
+
*/
|
|
29
|
+
export interface OclifCommandShape {
|
|
30
|
+
id: string;
|
|
31
|
+
description?: string;
|
|
32
|
+
summary?: string;
|
|
33
|
+
hidden?: boolean;
|
|
34
|
+
flags?: Record<string, OclifFlagShape | undefined>;
|
|
35
|
+
examples?: ReadonlyArray<string | {
|
|
36
|
+
command?: string;
|
|
37
|
+
description?: string;
|
|
38
|
+
}>;
|
|
39
|
+
}
|
|
40
|
+
/** The slice of an oclif flag definition this module reads. */
|
|
41
|
+
export interface OclifFlagShape {
|
|
42
|
+
type?: string;
|
|
43
|
+
description?: string;
|
|
44
|
+
char?: string;
|
|
45
|
+
options?: readonly string[];
|
|
46
|
+
required?: boolean;
|
|
47
|
+
}
|
|
48
|
+
/** The domain is the first segment: `sync:push` → `sync`, `codegen` → `codegen`. */
|
|
49
|
+
export declare function domainOf(commandId: string): string;
|
|
50
|
+
/**
|
|
51
|
+
* Synthesizes a {@link PluginUsage} from one oclif command definition.
|
|
52
|
+
*
|
|
53
|
+
* Exported for testing — the registration path below is what production calls.
|
|
54
|
+
*/
|
|
55
|
+
export declare function deriveUsage(command: OclifCommandShape): PluginUsage;
|
|
56
|
+
/**
|
|
57
|
+
* Registers derived usage for every visible oclif command.
|
|
58
|
+
*
|
|
59
|
+
* Hidden commands and oclif's own built-ins (`help`, `version`) are skipped — the
|
|
60
|
+
* former are hidden from humans, so advertising them to an agent would be a strictly
|
|
61
|
+
* worse kind of surprise; the latter are not MJ domains. Already-registered commands
|
|
62
|
+
* (plugins, and the `dev` domain's explicit registrations) are left alone by
|
|
63
|
+
* `RegisterUsage`'s first-wins rule.
|
|
64
|
+
*
|
|
65
|
+
* Returns the keys it registered, so a caller or test can assert coverage.
|
|
66
|
+
*/
|
|
67
|
+
export declare function registerDerivedUsage(commands: readonly OclifCommandShape[]): string[];
|
|
68
|
+
//# sourceMappingURL=derived-usage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"derived-usage.d.ts","sourceRoot":"","sources":["../../src/lib/derived-usage.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,EAAqB,KAAK,WAAW,EAAwB,MAAM,0BAA0B,CAAC;AAGrG;;;;;;GAMG;AACH,MAAM,WAAW,iBAAiB;IAChC,EAAE,EAAE,MAAM,CAAC;IACX,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,GAAG,SAAS,CAAC,CAAC;IACnD,QAAQ,CAAC,EAAE,aAAa,CAAC,MAAM,GAAG;QAAE,OAAO,CAAC,EAAE,MAAM,CAAC;QAAC,WAAW,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CAC/E;AAED,+DAA+D;AAC/D,MAAM,WAAW,cAAc;IAC7B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC5B,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAcD,oFAAoF;AACpF,wBAAgB,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAElD;AAsCD;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,iBAAiB,GAAG,WAAW,CAenE;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,SAAS,iBAAiB,EAAE,GAAG,MAAM,EAAE,CAUrF"}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Derives `mj usage` entries for the commands that are still plain oclif
|
|
3
|
+
* `Command`s, straight from oclif's own manifest.
|
|
4
|
+
*
|
|
5
|
+
* Why derive rather than hand-write: `mj usage` tier 1 tells an agent
|
|
6
|
+
* *"Run `mj <domain> usage` before invoking. Do NOT guess flags."* — so a domain
|
|
7
|
+
* absent from that map reads as "this domain does not exist". Before this, only the
|
|
8
|
+
* handful of `BaseCLIPlugin` domains were registered, and the map confidently
|
|
9
|
+
* advertised a fraction of the CLI. A map that lies by omission is worse than no map,
|
|
10
|
+
* because an agent has no way to tell the difference.
|
|
11
|
+
*
|
|
12
|
+
* Hand-writing 80-odd `PluginUsage` literals would have fixed it once and rotted
|
|
13
|
+
* immediately. oclif already holds every command's description, flags, and examples
|
|
14
|
+
* and cannot fall out of sync with itself, so the only thing left to hand-maintain
|
|
15
|
+
* is what oclif genuinely doesn't know: the runtime budget (see `domain-profiles.ts`).
|
|
16
|
+
*
|
|
17
|
+
* Registration is additive and never overwrites: `CLIPluginRegistry.RegisterUsage`
|
|
18
|
+
* keeps the first entry per command key, and plugin-declared `static Usage` is read
|
|
19
|
+
* first, so a migrated command always keeps its richer, curated metadata.
|
|
20
|
+
*/
|
|
21
|
+
import { CLIPluginRegistry } from '@memberjunction/cli-core';
|
|
22
|
+
import { getDomainProfile } from './domain-profiles.js';
|
|
23
|
+
/**
|
|
24
|
+
* oclif's own built-in plugin commands. They are real commands, but they are not part
|
|
25
|
+
* of MJ's surface — advertising `help` and `version` as top-level *domains* in the
|
|
26
|
+
* tier-1 map would push two non-domains ahead of real ones for no benefit.
|
|
27
|
+
*/
|
|
28
|
+
const BUILT_IN_COMMANDS = new Set(['help', 'version']);
|
|
29
|
+
/** oclif ids are colon-separated internally but render with the configured separator. */
|
|
30
|
+
function normalizeCommandKey(id) {
|
|
31
|
+
return id.trim().replace(/[\s:]+/g, ':');
|
|
32
|
+
}
|
|
33
|
+
/** The domain is the first segment: `sync:push` → `sync`, `codegen` → `codegen`. */
|
|
34
|
+
export function domainOf(commandId) {
|
|
35
|
+
return normalizeCommandKey(commandId).split(':')[0] ?? commandId;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* First sentence (or first line) of a description, for the one-line summary.
|
|
39
|
+
* oclif descriptions are frequently multi-paragraph; the tier-1 map has room for one line.
|
|
40
|
+
*/
|
|
41
|
+
function firstLine(text) {
|
|
42
|
+
if (!text)
|
|
43
|
+
return undefined;
|
|
44
|
+
const line = text.split('\n').map((l) => l.trim()).find((l) => l.length > 0);
|
|
45
|
+
if (!line)
|
|
46
|
+
return undefined;
|
|
47
|
+
const sentence = /^(.*?[.!?])(\s|$)/.exec(line);
|
|
48
|
+
return (sentence?.[1] ?? line).trim();
|
|
49
|
+
}
|
|
50
|
+
/** oclif accepts examples as strings or `{command, description}` objects. */
|
|
51
|
+
function normalizeExamples(examples) {
|
|
52
|
+
if (!examples?.length)
|
|
53
|
+
return undefined;
|
|
54
|
+
const out = examples
|
|
55
|
+
.map((e) => (typeof e === 'string' ? e : e.command))
|
|
56
|
+
.filter((e) => typeof e === 'string' && e.length > 0);
|
|
57
|
+
return out.length > 0 ? out : undefined;
|
|
58
|
+
}
|
|
59
|
+
/** Converts oclif's flag record to the usage surface's flag list, options included. */
|
|
60
|
+
function normalizeFlags(flags) {
|
|
61
|
+
if (!flags)
|
|
62
|
+
return undefined;
|
|
63
|
+
const out = [];
|
|
64
|
+
for (const [name, def] of Object.entries(flags)) {
|
|
65
|
+
if (!def)
|
|
66
|
+
continue;
|
|
67
|
+
const type = def.options?.length ? def.options.join('|') : (def.type ?? 'string');
|
|
68
|
+
const parts = [def.description ?? ''];
|
|
69
|
+
if (def.char)
|
|
70
|
+
parts.push(`(-${def.char})`);
|
|
71
|
+
if (def.required)
|
|
72
|
+
parts.push('(required)');
|
|
73
|
+
out.push({ name: `--${name}`, type, description: parts.filter(Boolean).join(' ').trim() });
|
|
74
|
+
}
|
|
75
|
+
return out.length > 0 ? out : undefined;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Synthesizes a {@link PluginUsage} from one oclif command definition.
|
|
79
|
+
*
|
|
80
|
+
* Exported for testing — the registration path below is what production calls.
|
|
81
|
+
*/
|
|
82
|
+
export function deriveUsage(command) {
|
|
83
|
+
const key = normalizeCommandKey(command.id);
|
|
84
|
+
const domain = domainOf(key);
|
|
85
|
+
const profile = getDomainProfile(domain);
|
|
86
|
+
const description = command.description ?? command.summary;
|
|
87
|
+
return {
|
|
88
|
+
domain,
|
|
89
|
+
command: key,
|
|
90
|
+
summary: command.summary ?? firstLine(description) ?? `mj ${key.replace(/:/g, ' ')}`,
|
|
91
|
+
description,
|
|
92
|
+
flags: normalizeFlags(command.flags),
|
|
93
|
+
examples: normalizeExamples(command.examples),
|
|
94
|
+
runtime: profile.runtime,
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Registers derived usage for every visible oclif command.
|
|
99
|
+
*
|
|
100
|
+
* Hidden commands and oclif's own built-ins (`help`, `version`) are skipped — the
|
|
101
|
+
* former are hidden from humans, so advertising them to an agent would be a strictly
|
|
102
|
+
* worse kind of surprise; the latter are not MJ domains. Already-registered commands
|
|
103
|
+
* (plugins, and the `dev` domain's explicit registrations) are left alone by
|
|
104
|
+
* `RegisterUsage`'s first-wins rule.
|
|
105
|
+
*
|
|
106
|
+
* Returns the keys it registered, so a caller or test can assert coverage.
|
|
107
|
+
*/
|
|
108
|
+
export function registerDerivedUsage(commands) {
|
|
109
|
+
const registered = [];
|
|
110
|
+
for (const command of commands) {
|
|
111
|
+
if (!command?.id || command.hidden)
|
|
112
|
+
continue;
|
|
113
|
+
if (BUILT_IN_COMMANDS.has(normalizeCommandKey(command.id)))
|
|
114
|
+
continue;
|
|
115
|
+
const usage = deriveUsage(command);
|
|
116
|
+
CLIPluginRegistry.RegisterUsage(usage);
|
|
117
|
+
registered.push(usage.command);
|
|
118
|
+
}
|
|
119
|
+
return registered;
|
|
120
|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AAS;QAC7C,IAAI,iBAAiB,CAAC,GAAG,CAAC,mBAAmB,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;YAAE,SAAS;QACrE,MAAM,KAAK,GAAG,WAAW,CAAC,OAAO,CAAC,CAAC;QACnC,iBAAiB,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;QACvC,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IACjC,CAAC;IACD,OAAO,UAAU,CAAC;AACpB,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { RuntimeHint } from '@memberjunction/cli-core';
|
|
2
|
+
/**
|
|
3
|
+
* Per-domain runtime + summary for the commands that are still plain oclif
|
|
4
|
+
* `Command`s rather than `BaseCLIPlugin` subclasses.
|
|
5
|
+
*
|
|
6
|
+
* This table is deliberately the ONLY hand-maintained part of the usage surface.
|
|
7
|
+
* Everything else about an unmigrated command — its description, flags, and
|
|
8
|
+
* examples — is derived from oclif's own manifest at runtime (see
|
|
9
|
+
* `derived-usage.ts`), so it cannot drift from the actual command.
|
|
10
|
+
*
|
|
11
|
+
* What lives here is exactly what oclif does not know: how long a command tends to
|
|
12
|
+
* run (so an agent can budget a timeout) and a one-line domain summary for the
|
|
13
|
+
* tier-1 map. A domain missing from this table still appears — it just falls back
|
|
14
|
+
* to {@link DEFAULT_DOMAIN_PROFILE}, so adding a command can never make `mj usage`
|
|
15
|
+
* lie by omission.
|
|
16
|
+
*/
|
|
17
|
+
export interface DomainProfile {
|
|
18
|
+
/** One line for the tier-1 `mj usage` map. */
|
|
19
|
+
summary: string;
|
|
20
|
+
/** Timeout budget for the slowest command in the domain. */
|
|
21
|
+
runtime: RuntimeHint;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Applied to any domain not listed below. `variable` is the honest answer for an
|
|
25
|
+
* undocumented command — it tells an agent "I don't know, don't set a tight timeout"
|
|
26
|
+
* rather than implying a fast run.
|
|
27
|
+
*/
|
|
28
|
+
export declare const DEFAULT_DOMAIN_PROFILE: DomainProfile;
|
|
29
|
+
/**
|
|
30
|
+
* Per-domain profiles.
|
|
31
|
+
*
|
|
32
|
+
* Domains whose commands ship as `BaseCLIPlugin` plugins (`sync`, `codegen`) still
|
|
33
|
+
* appear here: a plugin declares usage per COMMAND, and the tier-1 map needs a line
|
|
34
|
+
* for the DOMAIN. Without one, a multi-command domain renders as one command's
|
|
35
|
+
* summary plus "(+7 more commands)", which tells an agent nothing about what the
|
|
36
|
+
* domain is for. The per-command metadata those plugins declare is untouched —
|
|
37
|
+
* `RegisterUsage` is first-wins and reads plugin metadata first.
|
|
38
|
+
*/
|
|
39
|
+
export declare const DOMAIN_PROFILES: Readonly<Record<string, DomainProfile>>;
|
|
40
|
+
/** The profile for a domain, falling back to {@link DEFAULT_DOMAIN_PROFILE}. */
|
|
41
|
+
export declare function getDomainProfile(domain: string): DomainProfile;
|
|
42
|
+
//# sourceMappingURL=domain-profiles.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"domain-profiles.d.ts","sourceRoot":"","sources":["../../src/lib/domain-profiles.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAE5D;;;;;;;;;;;;;;GAcG;AACH,MAAM,WAAW,aAAa;IAC5B,8CAA8C;IAC9C,OAAO,EAAE,MAAM,CAAC;IAChB,4DAA4D;IAC5D,OAAO,EAAE,WAAW,CAAC;CACtB;AAED;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,EAAE,aAGpC,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,eAAe,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CA6FnE,CAAC;AAEF,gFAAgF;AAChF,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,aAAa,CAE9D"}
|