opensip-cli 0.1.10 → 0.1.12
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/bootstrap/baseline-seams.d.ts.map +1 -1
- package/dist/bootstrap/baseline-seams.js +0 -2
- package/dist/bootstrap/baseline-seams.js.map +1 -1
- package/dist/bootstrap/bootstrap-diagnostics-buffer.d.ts +15 -0
- package/dist/bootstrap/bootstrap-diagnostics-buffer.d.ts.map +1 -0
- package/dist/bootstrap/bootstrap-diagnostics-buffer.js +24 -0
- package/dist/bootstrap/bootstrap-diagnostics-buffer.js.map +1 -0
- package/dist/bootstrap/build-command-registration-input.d.ts +2 -0
- package/dist/bootstrap/build-command-registration-input.d.ts.map +1 -1
- package/dist/bootstrap/build-command-registration-input.js +1 -0
- package/dist/bootstrap/build-command-registration-input.js.map +1 -1
- package/dist/bootstrap/build-per-run-scope.d.ts +5 -1
- package/dist/bootstrap/build-per-run-scope.d.ts.map +1 -1
- package/dist/bootstrap/build-per-run-scope.js +8 -2
- package/dist/bootstrap/build-per-run-scope.js.map +1 -1
- package/dist/bootstrap/build-targets.d.ts.map +1 -1
- package/dist/bootstrap/build-targets.js +2 -7
- package/dist/bootstrap/build-targets.js.map +1 -1
- package/dist/bootstrap/bundled-tools.manifest.json +6 -1
- package/dist/bootstrap/config-and-capabilities.d.ts +2 -1
- package/dist/bootstrap/config-and-capabilities.d.ts.map +1 -1
- package/dist/bootstrap/config-and-capabilities.js +22 -13
- package/dist/bootstrap/config-and-capabilities.js.map +1 -1
- package/dist/bootstrap/deliver-envelope.d.ts.map +1 -1
- package/dist/bootstrap/deliver-envelope.js +0 -1
- package/dist/bootstrap/deliver-envelope.js.map +1 -1
- package/dist/bootstrap/discovery-diagnostics.d.ts +17 -0
- package/dist/bootstrap/discovery-diagnostics.d.ts.map +1 -0
- package/dist/bootstrap/discovery-diagnostics.js +94 -0
- package/dist/bootstrap/discovery-diagnostics.js.map +1 -0
- package/dist/bootstrap/dispatch-host-rpc-handler.d.ts.map +1 -1
- package/dist/bootstrap/dispatch-host-rpc-handler.js +0 -1
- package/dist/bootstrap/dispatch-host-rpc-handler.js.map +1 -1
- package/dist/bootstrap/dispatch-replay-result.d.ts.map +1 -1
- package/dist/bootstrap/dispatch-replay-result.js +0 -1
- package/dist/bootstrap/dispatch-replay-result.js.map +1 -1
- package/dist/bootstrap/execute-post-bailout-bootstrap.d.ts.map +1 -1
- package/dist/bootstrap/execute-post-bailout-bootstrap.js +8 -2
- package/dist/bootstrap/execute-post-bailout-bootstrap.js.map +1 -1
- package/dist/bootstrap/index.d.ts +6 -1
- package/dist/bootstrap/index.d.ts.map +1 -1
- package/dist/bootstrap/index.js +15 -4
- package/dist/bootstrap/index.js.map +1 -1
- package/dist/bootstrap/load-tool-capabilities.d.ts.map +1 -1
- package/dist/bootstrap/load-tool-capabilities.js +14 -2
- package/dist/bootstrap/load-tool-capabilities.js.map +1 -1
- package/dist/bootstrap/output-plane.d.ts.map +1 -1
- package/dist/bootstrap/output-plane.js +1 -0
- package/dist/bootstrap/output-plane.js.map +1 -1
- package/dist/bootstrap/pre-action-hook.d.ts.map +1 -1
- package/dist/bootstrap/pre-action-hook.js +0 -2
- package/dist/bootstrap/pre-action-hook.js.map +1 -1
- package/dist/bootstrap/pre-action-runtime.d.ts +2 -1
- package/dist/bootstrap/pre-action-runtime.d.ts.map +1 -1
- package/dist/bootstrap/register-tools-discovery.d.ts +6 -4
- package/dist/bootstrap/register-tools-discovery.d.ts.map +1 -1
- package/dist/bootstrap/register-tools-discovery.js +32 -19
- package/dist/bootstrap/register-tools-discovery.js.map +1 -1
- package/dist/bootstrap/register-tools-mount.d.ts +8 -5
- package/dist/bootstrap/register-tools-mount.d.ts.map +1 -1
- package/dist/bootstrap/register-tools-mount.js +35 -6
- package/dist/bootstrap/register-tools-mount.js.map +1 -1
- package/dist/bootstrap/register-tools.d.ts.map +1 -1
- package/dist/bootstrap/register-tools.js +0 -2
- package/dist/bootstrap/register-tools.js.map +1 -1
- package/dist/bootstrap/render-bootstrap-diagnostics.d.ts +13 -0
- package/dist/bootstrap/render-bootstrap-diagnostics.d.ts.map +1 -0
- package/dist/bootstrap/render-bootstrap-diagnostics.js +25 -0
- package/dist/bootstrap/render-bootstrap-diagnostics.js.map +1 -0
- package/dist/bootstrap/run-plane.d.ts.map +1 -1
- package/dist/bootstrap/run-plane.js +10 -4
- package/dist/bootstrap/run-plane.js.map +1 -1
- package/dist/bootstrap/state-seams.d.ts.map +1 -1
- package/dist/bootstrap/state-seams.js +0 -1
- package/dist/bootstrap/state-seams.js.map +1 -1
- package/dist/bootstrap/synthesize-external-tool.d.ts +0 -37
- package/dist/bootstrap/synthesize-external-tool.d.ts.map +1 -1
- package/dist/bootstrap/synthesize-external-tool.js +18 -67
- package/dist/bootstrap/synthesize-external-tool.js.map +1 -1
- package/dist/bootstrap/tool-command-worker-context.d.ts.map +1 -1
- package/dist/bootstrap/tool-command-worker-context.js +0 -1
- package/dist/bootstrap/tool-command-worker-context.js.map +1 -1
- package/dist/bootstrap/tool-command-worker-entry.d.ts.map +1 -1
- package/dist/bootstrap/tool-command-worker-entry.js +1 -3
- package/dist/bootstrap/tool-command-worker-entry.js.map +1 -1
- package/dist/bootstrap/tool-trust.d.ts.map +1 -1
- package/dist/bootstrap/tool-trust.js +15 -0
- package/dist/bootstrap/tool-trust.js.map +1 -1
- package/dist/bootstrap/validate-tool.d.ts.map +1 -1
- package/dist/bootstrap/validate-tool.js +63 -6
- package/dist/bootstrap/validate-tool.js.map +1 -1
- package/dist/cli-context.js +0 -1
- package/dist/cli-context.js.map +1 -1
- package/dist/commands/agent-catalog.d.ts.map +1 -1
- package/dist/commands/agent-catalog.js +14 -5
- package/dist/commands/agent-catalog.js.map +1 -1
- package/dist/commands/assemble-outcome.d.ts +2 -1
- package/dist/commands/assemble-outcome.d.ts.map +1 -1
- package/dist/commands/assemble-outcome.js +33 -16
- package/dist/commands/assemble-outcome.js.map +1 -1
- package/dist/commands/command-scope-index.d.ts +1 -1
- package/dist/commands/command-scope-index.js +2 -2
- package/dist/commands/command-scope-index.js.map +1 -1
- package/dist/commands/completion.d.ts +7 -33
- package/dist/commands/completion.d.ts.map +1 -1
- package/dist/commands/completion.js +77 -69
- package/dist/commands/completion.js.map +1 -1
- package/dist/commands/history.d.ts +3 -6
- package/dist/commands/history.d.ts.map +1 -1
- package/dist/commands/history.js +7 -12
- package/dist/commands/history.js.map +1 -1
- package/dist/commands/host-command-specs.d.ts +6 -30
- package/dist/commands/host-command-specs.d.ts.map +1 -1
- package/dist/commands/host-command-specs.js +10 -33
- package/dist/commands/host-command-specs.js.map +1 -1
- package/dist/commands/host-subcommand-groups.d.ts +8 -72
- package/dist/commands/host-subcommand-groups.d.ts.map +1 -1
- package/dist/commands/host-subcommand-groups.js +9 -400
- package/dist/commands/host-subcommand-groups.js.map +1 -1
- package/dist/commands/host-subcommand-plugins.d.ts +20 -0
- package/dist/commands/host-subcommand-plugins.d.ts.map +1 -0
- package/dist/commands/host-subcommand-plugins.js +114 -0
- package/dist/commands/host-subcommand-plugins.js.map +1 -0
- package/dist/commands/host-subcommand-sessions.d.ts +8 -0
- package/dist/commands/host-subcommand-sessions.d.ts.map +1 -0
- package/dist/commands/host-subcommand-sessions.js +201 -0
- package/dist/commands/host-subcommand-sessions.js.map +1 -0
- package/dist/commands/host-subcommand-shared.d.ts +20 -0
- package/dist/commands/host-subcommand-shared.d.ts.map +1 -0
- package/dist/commands/host-subcommand-shared.js +15 -0
- package/dist/commands/host-subcommand-shared.js.map +1 -0
- package/dist/commands/init/file-classifier.d.ts.map +1 -1
- package/dist/commands/init/file-classifier.js +0 -1
- package/dist/commands/init/file-classifier.js.map +1 -1
- package/dist/commands/init/scaffold-writer.d.ts.map +1 -1
- package/dist/commands/init/scaffold-writer.js +0 -1
- package/dist/commands/init/scaffold-writer.js.map +1 -1
- package/dist/commands/init/state-machine.d.ts.map +1 -1
- package/dist/commands/init/state-machine.js +0 -1
- package/dist/commands/init/state-machine.js.map +1 -1
- package/dist/commands/plugin/config-edit.d.ts.map +1 -1
- package/dist/commands/plugin/config-edit.js +0 -1
- package/dist/commands/plugin/config-edit.js.map +1 -1
- package/dist/commands/plugin/host-dir.d.ts.map +1 -1
- package/dist/commands/plugin/host-dir.js +0 -2
- package/dist/commands/plugin/host-dir.js.map +1 -1
- package/dist/commands/plugin-host-ops.d.ts.map +1 -1
- package/dist/commands/plugin-host-ops.js +0 -1
- package/dist/commands/plugin-host-ops.js.map +1 -1
- package/dist/commands/plugin.d.ts.map +1 -1
- package/dist/commands/plugin.js +0 -1
- package/dist/commands/plugin.js.map +1 -1
- package/dist/commands/session-show.d.ts +3 -1
- package/dist/commands/session-show.d.ts.map +1 -1
- package/dist/commands/session-show.js +23 -9
- package/dist/commands/session-show.js.map +1 -1
- package/dist/commands/shared.d.ts +3 -1
- package/dist/commands/shared.d.ts.map +1 -1
- package/dist/commands/tools/doctor.d.ts +7 -0
- package/dist/commands/tools/doctor.d.ts.map +1 -0
- package/dist/commands/tools/doctor.js +12 -0
- package/dist/commands/tools/doctor.js.map +1 -0
- package/dist/commands/tools/index.d.ts.map +1 -1
- package/dist/commands/tools/index.js +58 -8
- package/dist/commands/tools/index.js.map +1 -1
- package/dist/commands/uninstall/targets.d.ts +1 -1
- package/dist/commands/uninstall/targets.d.ts.map +1 -1
- package/dist/commands/uninstall/targets.js +6 -15
- package/dist/commands/uninstall/targets.js.map +1 -1
- package/dist/commands/uninstall.d.ts.map +1 -1
- package/dist/commands/uninstall.js +0 -1
- package/dist/commands/uninstall.js.map +1 -1
- package/dist/env/host-env-specs.d.ts.map +1 -1
- package/dist/env/host-env-specs.js +6 -0
- package/dist/env/host-env-specs.js.map +1 -1
- package/dist/format-bytes.d.ts +2 -0
- package/dist/format-bytes.d.ts.map +1 -0
- package/dist/format-bytes.js +10 -0
- package/dist/format-bytes.js.map +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -4
- package/dist/index.js.map +1 -1
- package/dist/open-report.d.ts.map +1 -1
- package/dist/open-report.js +0 -1
- package/dist/open-report.js.map +1 -1
- package/dist/report-compose.d.ts.map +1 -1
- package/dist/report-compose.js +0 -2
- package/dist/report-compose.js.map +1 -1
- package/dist/session-replay-registry.d.ts.map +1 -1
- package/dist/session-replay-registry.js +0 -2
- package/dist/session-replay-registry.js.map +1 -1
- package/dist/telemetry/sdk-init.d.ts.map +1 -1
- package/dist/telemetry/sdk-init.js +1 -1
- package/dist/telemetry/sdk-init.js.map +1 -1
- package/dist/ui/render-diagnostic.d.ts +20 -0
- package/dist/ui/render-diagnostic.d.ts.map +1 -0
- package/dist/ui/render-diagnostic.js +22 -0
- package/dist/ui/render-diagnostic.js.map +1 -0
- package/dist/ui/result-to-view.d.ts.map +1 -1
- package/dist/ui/result-to-view.js +13 -102
- package/dist/ui/result-to-view.js.map +1 -1
- package/dist/ui/views/misc-views.d.ts.map +1 -1
- package/dist/ui/views/misc-views.js +1 -9
- package/dist/ui/views/misc-views.js.map +1 -1
- package/dist/ui/views/tools-views.d.ts +2 -1
- package/dist/ui/views/tools-views.d.ts.map +1 -1
- package/dist/ui/views/tools-views.js +46 -5
- package/dist/ui/views/tools-views.js.map +1 -1
- package/dist/update-notifier.d.ts.map +1 -1
- package/dist/update-notifier.js +0 -1
- package/dist/update-notifier.js.map +1 -1
- package/dist/update-state.d.ts.map +1 -1
- package/dist/update-state.js +0 -2
- package/dist/update-state.js.map +1 -1
- package/package.json +33 -32
|
@@ -1,34 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* host-command-specs —
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* `Tool.commandSpecs` and aren't discovered. Mounting them via the same
|
|
9
|
-
* `mountCommandSpec` means the Phase 7 `command-surface-parity` guardrail sees
|
|
10
|
-
* ONE uniform command surface: no second, more-privileged raw-Commander path for
|
|
11
|
-
* "blessed" CLI-owned commands. The pack-management `plugin {add,list,remove,
|
|
12
|
-
* sync}` ops are host-owned too, but mount UNDER each pack-supporting tool
|
|
13
|
-
* primary (`opensip fit plugin …`) via {@link mountToolPluginGroups} — there is
|
|
14
|
-
* no top-level `opensip plugin`.
|
|
15
|
-
*
|
|
16
|
-
* Each spec's handler closes over the per-invocation {@link CliCommandsContext}
|
|
17
|
-
* (render / setExitCode / datastore thunk / pluginLayouts). The mount layer only
|
|
18
|
-
* reaches for `render` / `setExitCode` (the `command-result` + thrown-`ToolError`
|
|
19
|
-
* arms) — the `signal-envelope` / `live-view` arms are never exercised by a host
|
|
20
|
-
* command, so `CliCommandsContext` is a valid (leaner) `CommandMountContext`.
|
|
21
|
-
*
|
|
22
|
-
* The action-less subcommand GROUPS (`sessions`, `tools`) + the domain-bound
|
|
23
|
-
* per-tool `plugin` group leaves (and {@link mountToolPluginGroups}) live in
|
|
24
|
-
* `host-subcommand-groups.ts` (a leaf module that lets `completion.ts` source its
|
|
25
|
-
* sub-subcommand names without a cycle). This module assembles the TOP-LEVEL
|
|
26
|
-
* specs and mounts the whole surface.
|
|
27
|
-
*
|
|
28
|
-
* Specs are built per-invocation (in the builders below, not at module load) so
|
|
29
|
-
* the `--cwd` defaults that resolve to `process.cwd()` are evaluated fresh each
|
|
30
|
-
* run — byte-identical to the former `.option(spec, desc, process.cwd())`
|
|
31
|
-
* registrars.
|
|
2
|
+
* host-command-specs — CLI-owned commands as declarative {@link CommandSpec}s,
|
|
3
|
+
* mounted via the same `mountCommandSpec` plane as tools (Phase 6/7 parity).
|
|
4
|
+
* Host commands (`init`, `configure`, `sessions`, `report`, `completion`,
|
|
5
|
+
* `uninstall`, `tools`) are not tool plugins. Action-less groups and per-tool
|
|
6
|
+
* `plugin` leaves live in `host-subcommand-groups.ts`; this module assembles
|
|
7
|
+
* top-level specs. Built per-invocation so `--cwd` defaults stay fresh.
|
|
32
8
|
*/
|
|
33
9
|
import { EXIT_CODES } from '@opensip-cli/contracts';
|
|
34
10
|
import { ConfigurationError, defineCommand } from '@opensip-cli/core';
|
|
@@ -306,8 +282,9 @@ function buildHostCompletionSurface(ctx) {
|
|
|
306
282
|
return {
|
|
307
283
|
specs: [...buildNonCompletionHostSpecs(ctx), COMPLETION_SELF_SPEC],
|
|
308
284
|
groups: buildHostSubcommandGroups(ctx),
|
|
309
|
-
toolPluginGroups: buildToolPluginGroups(ctx).map((g) => ({
|
|
310
|
-
|
|
285
|
+
toolPluginGroups: buildToolPluginGroups(ctx, ctx.tools).map((g) => ({
|
|
286
|
+
parentVerb: g.parentVerb,
|
|
287
|
+
parentAliases: g.parentAliases,
|
|
311
288
|
leaves: g.leaves.map((l) => ({ name: l.name })),
|
|
312
289
|
})),
|
|
313
290
|
};
|
|
@@ -352,6 +329,6 @@ export function mountHostCommands(program, ctx) {
|
|
|
352
329
|
mountCommandSpec(parent, leaf, ctx);
|
|
353
330
|
}
|
|
354
331
|
}
|
|
355
|
-
mountToolPluginGroups(program, ctx);
|
|
332
|
+
mountToolPluginGroups(program, ctx, ctx.tools);
|
|
356
333
|
}
|
|
357
334
|
//# sourceMappingURL=host-command-specs.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"host-command-specs.js","sourceRoot":"","sources":["../../src/commands/host-command-specs.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"host-command-specs.js","sourceRoot":"","sources":["../../src/commands/host-command-specs.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,kBAAkB,EAAE,aAAa,EAAuB,MAAM,mBAAmB,CAAC;AAE3F,OAAO,EAAE,4BAA4B,EAAE,MAAM,2CAA2C,CAAC;AACzF,OAAO,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAE7D,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,EACL,2BAA2B,EAC3B,qBAAqB,EACrB,iBA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,GAAuB;IAC5E,KAAK,MAAM,IAAI,IAAI,sBAAsB,CAAC,GAAG,CAAC,EAAE,CAAC;QAC/C,gBAAgB,CAAC,OAAO,EAAE,IAAI,EAAE,GAAG,CAAC,CAAC;IACvC,CAAC;IACD,KAAK,MAAM,KAAK,IAAI,yBAAyB,CAAC,GAAG,CAAC,EAAE,CAAC;QACnD,MAAM,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,WAAW,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;QAC1E,KAAK,MAAM,IAAI,IAAI,KAAK,CAAC,MAAM,EAAE,CAAC;YAChC,gBAAgB,CAAC,MAAM,EAAE,IAAI,EAAE,GAAG,CAAC,CAAC;QACtC,CAAC;IACH,CAAC;IACD,qBAAqB,CAAC,OAAO,EAAE,GAAG,EAAE,GAAG,CAAC,KAAK,CAAC,CAAC;AACjD,CAAC"}
|
|
@@ -13,61 +13,15 @@
|
|
|
13
13
|
* leaves + inventory here (a module that imports NEITHER `completion.ts` nor
|
|
14
14
|
* `host-command-specs.ts`) lets both depend on this leaf module without a cycle.
|
|
15
15
|
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
* `command-surface-parity` guardrail's allow-list, see {@link HOST_SUBCOMMAND_GROUPS}).
|
|
20
|
-
* Their LEAVES (`sessions list|purge`, `tools list|install|…`) ARE specs.
|
|
21
|
-
*
|
|
22
|
-
* The PACK-management `plugin {add,list,remove,sync}` ops are NO LONGER a
|
|
23
|
-
* top-level group: they mount as a `plugin` group UNDER each pack-supporting
|
|
24
|
-
* tool primary (`opensip fit plugin …`, `opensip sim plugin …`) via
|
|
25
|
-
* `mountToolPluginGroups`, with the domain pre-bound from the tool (no
|
|
26
|
-
* `--domain` flag). Whole Tool plugins remain `opensip tools …`.
|
|
16
|
+
* Leaf specs are split across `host-subcommand-sessions.ts` and
|
|
17
|
+
* `host-subcommand-plugins.ts` to stay under the file-length-limit; this module
|
|
18
|
+
* remains the cycle-free assembly + inventory surface.
|
|
27
19
|
*/
|
|
28
|
-
import { type
|
|
20
|
+
import { type HostSpec } from './host-subcommand-shared.js';
|
|
29
21
|
import type { CliCommandsContext } from './shared.js';
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
export
|
|
33
|
-
/** Prefer the discovered project root; fall back to literal cwd; finally process.cwd(). */
|
|
34
|
-
export declare function effectiveCwd(opts: {
|
|
35
|
-
cwd?: string;
|
|
36
|
-
projectContext?: ProjectContext;
|
|
37
|
-
}): string;
|
|
38
|
-
/**
|
|
39
|
-
* Build the four domain-bound `plugin` leaf specs for ONE pack-supporting tool
|
|
40
|
-
* (`add`/`list`/`remove`/`sync`, all scoped to `domain`). Shared by the mount
|
|
41
|
-
* path (`mountToolPluginGroups`), the command-scope index, and the completion
|
|
42
|
-
* inventory so the three derive the SAME leaves.
|
|
43
|
-
*/
|
|
44
|
-
export declare function buildToolPluginLeaves(ctx: CliCommandsContext, domain: string): readonly HostSpec[];
|
|
45
|
-
/** One pack-supporting tool's `plugin` group: the tool's primary verb + the
|
|
46
|
-
* action-less `plugin` parent + the four domain-bound leaves. */
|
|
47
|
-
export interface ToolPluginGroup {
|
|
48
|
-
/** The tool primary verb the `plugin` group mounts under (`fit`/`sim`). */
|
|
49
|
-
readonly toolVerb: string;
|
|
50
|
-
/** The plugin domain (== `toolVerb` for the pack-supporting tools). */
|
|
51
|
-
readonly domain: string;
|
|
52
|
-
readonly description: string;
|
|
53
|
-
readonly leaves: readonly HostSpec[];
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* Derive the per-tool `plugin` groups from the host's contributed
|
|
57
|
-
* `pluginLayouts` — one group per pack-supporting domain (fit/sim). A tool with
|
|
58
|
-
* no `pluginLayout` (e.g. `graph`) contributes none, so it gets no `plugin`
|
|
59
|
-
* group. The single source the mount path + scope index + completion all read.
|
|
60
|
-
*/
|
|
61
|
-
export declare function buildToolPluginGroups(ctx: CliCommandsContext): readonly ToolPluginGroup[];
|
|
62
|
-
/**
|
|
63
|
-
* Mount each per-tool `plugin` group UNDER its pack-supporting tool primary
|
|
64
|
-
* (`opensip fit plugin …`), domain pre-bound from the tool. The host derives the
|
|
65
|
-
* groups from the contributed `pluginLayouts` (fit/sim; graph has none, so no
|
|
66
|
-
* group). The tool primary must already be mounted — it is, because the
|
|
67
|
-
* composition root mounts tools before the host commands; a domain whose primary
|
|
68
|
-
* is absent (isolated host-only tests) is skipped (nowhere to hang it).
|
|
69
|
-
*/
|
|
70
|
-
export declare function mountToolPluginGroups(program: CliProgram, ctx: CliCommandsContext): void;
|
|
22
|
+
export type { HostSpec } from './host-subcommand-shared.js';
|
|
23
|
+
export { effectiveCwd } from './host-subcommand-shared.js';
|
|
24
|
+
export { buildToolPluginLeaves, buildToolPluginGroups, mountToolPluginGroups, type ToolPluginGroup, } from './host-subcommand-plugins.js';
|
|
71
25
|
/** One subcommand-group parent: a raw action-less `program.command(name)`
|
|
72
26
|
* shell + the leaf specs that mount onto it. */
|
|
73
27
|
export interface HostSubcommandGroup {
|
|
@@ -82,27 +36,9 @@ export interface HostSubcommandGroup {
|
|
|
82
36
|
* allow-lists as documented host exceptions. Every other host command IS a spec.
|
|
83
37
|
*/
|
|
84
38
|
export declare const HOST_SUBCOMMAND_GROUPS: readonly string[];
|
|
85
|
-
/**
|
|
86
|
-
* Build the subcommand-group parents with their leaf specs. The mounter turns
|
|
87
|
-
* each into a raw parent `program.command(name)` plus `mountCommandSpec(parent,
|
|
88
|
-
* leaf)` for each leaf.
|
|
89
|
-
*/
|
|
39
|
+
/** Build the subcommand-group parents with their leaf specs. */
|
|
90
40
|
export declare function buildHostSubcommandGroups(ctx: CliCommandsContext): readonly HostSubcommandGroup[];
|
|
91
|
-
/**
|
|
92
|
-
* The host subcommand-group NAME inventory derived from the live leaf specs —
|
|
93
|
-
* the single source the shell-completion script (`completion.ts`) reads for the
|
|
94
|
-
* `plugin` / `sessions` sub-subcommand names instead of a second hand-maintained
|
|
95
|
-
* list (Phase 6 Task 6.2).
|
|
96
|
-
*
|
|
97
|
-
* NOTE: only the NAME lists are sourced here — the curated per-command flag
|
|
98
|
-
* subsets the completion script offers stay in `completion.ts`, since
|
|
99
|
-
* exhaustively deriving every declared flag would change the emitted script. The
|
|
100
|
-
* common flags themselves already derive from the shared ADR-0021 registry (the
|
|
101
|
-
* same registry the specs' `commonFlags` resolve through), so that half is
|
|
102
|
-
* already single-sourced.
|
|
103
|
-
*/
|
|
104
41
|
export interface HostCommandInventory {
|
|
105
|
-
/** Sub-subcommand names per group (`{ sessions: ['list','purge'], plugin: [...] }`). */
|
|
106
42
|
readonly groupSubcommands: Readonly<Record<string, readonly string[]>>;
|
|
107
43
|
}
|
|
108
44
|
/** Build the host subcommand-group name inventory (single source for completion). */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"host-subcommand-groups.d.ts","sourceRoot":"","sources":["../../src/commands/host-subcommand-groups.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"host-subcommand-groups.d.ts","sourceRoot":"","sources":["../../src/commands/host-subcommand-groups.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAGH,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAG5D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEtD,YAAY,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,EACL,qBAAqB,EACrB,qBAAqB,EACrB,qBAAqB,EACrB,KAAK,eAAe,GACrB,MAAM,8BAA8B,CAAC;AAEtC;iDACiD;AACjD,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,MAAM,EAAE,SAAS,QAAQ,EAAE,CAAC;CACtC;AAED;;;;;GAKG;AACH,eAAO,MAAM,sBAAsB,EAAE,SAAS,MAAM,EAAmC,CAAC;AAExF,gEAAgE;AAChE,wBAAgB,yBAAyB,CAAC,GAAG,EAAE,kBAAkB,GAAG,SAAS,mBAAmB,EAAE,CAajG;AAsBD,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,gBAAgB,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC,CAAC,CAAC;CACxE;AAED,qFAAqF;AACrF,wBAAgB,yBAAyB,IAAI,oBAAoB,CAMhE"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
// @fitness-ignore-file file-length-limit -- deliberate single cycle-free leaf module: it houses BOTH host subcommand groups' leaf specs (sessions + tools) AND the per-tool `plugin` group leaves + the completion inventory together specifically because it must import neither completion.ts nor host-command-specs.ts (see header — splitting would reintroduce the module cycle this file exists to break). Cohesive by design; grew past the 400-line soft limit with the per-leaf CommandSpec builders.
|
|
2
1
|
/**
|
|
3
2
|
* host-subcommand-groups — the action-less Commander subcommand GROUPS
|
|
4
3
|
* (`sessions`, `tools`) and their leaf {@link CommandSpec}s, PLUS the
|
|
@@ -14,394 +13,14 @@
|
|
|
14
13
|
* leaves + inventory here (a module that imports NEITHER `completion.ts` nor
|
|
15
14
|
* `host-command-specs.ts`) lets both depend on this leaf module without a cycle.
|
|
16
15
|
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
* `command-surface-parity` guardrail's allow-list, see {@link HOST_SUBCOMMAND_GROUPS}).
|
|
21
|
-
* Their LEAVES (`sessions list|purge`, `tools list|install|…`) ARE specs.
|
|
22
|
-
*
|
|
23
|
-
* The PACK-management `plugin {add,list,remove,sync}` ops are NO LONGER a
|
|
24
|
-
* top-level group: they mount as a `plugin` group UNDER each pack-supporting
|
|
25
|
-
* tool primary (`opensip fit plugin …`, `opensip sim plugin …`) via
|
|
26
|
-
* `mountToolPluginGroups`, with the domain pre-bound from the tool (no
|
|
27
|
-
* `--domain` flag). Whole Tool plugins remain `opensip tools …`.
|
|
16
|
+
* Leaf specs are split across `host-subcommand-sessions.ts` and
|
|
17
|
+
* `host-subcommand-plugins.ts` to stay under the file-length-limit; this module
|
|
18
|
+
* remains the cycle-free assembly + inventory surface.
|
|
28
19
|
*/
|
|
29
|
-
import {
|
|
30
|
-
import { currentScope, defineCommand, registeredToolShortIds, } from '@opensip-cli/core';
|
|
31
|
-
import { executeClear } from './clear.js';
|
|
32
|
-
import { showHistory } from './history.js';
|
|
33
|
-
import { mountCommandSpec } from './mount-command-spec.js';
|
|
34
|
-
import { pluginAdd, pluginList, pluginRemove, pluginSync } from './plugin.js';
|
|
35
|
-
import { executeSessionShow } from './session-show.js';
|
|
20
|
+
import { buildSessionsGroupLeaves } from './host-subcommand-sessions.js';
|
|
36
21
|
import { buildToolsGroupLeaves } from './tools/index.js';
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
const PROJECT_SCOPE = 'project';
|
|
40
|
-
/** The `command-result` output mode, named once (the leaves all share it). */
|
|
41
|
-
const COMMAND_RESULT = 'command-result';
|
|
42
|
-
const RAW_STREAM = 'raw-stream';
|
|
43
|
-
/** Prefer the discovered project root; fall back to literal cwd; finally process.cwd(). */
|
|
44
|
-
export function effectiveCwd(opts) {
|
|
45
|
-
return opts.projectContext?.projectRoot ?? opts.cwd ?? process.cwd();
|
|
46
|
-
}
|
|
47
|
-
// ---------------------------------------------------------------------------
|
|
48
|
-
// sessions list / purge
|
|
49
|
-
// ---------------------------------------------------------------------------
|
|
50
|
-
/**
|
|
51
|
-
* Validate a user-supplied `--tool` filter against the live tool registry (M3).
|
|
52
|
-
*
|
|
53
|
-
* The session/persistence discriminant is the OPEN `ToolShortId`, so a
|
|
54
|
-
* registered third-party tool's id is a legitimate filter — the former static
|
|
55
|
-
* `choices: ['fit','graph','sim']` Commander enum re-closed that set and denied
|
|
56
|
-
* third-party tools session-list parity. Membership is therefore validated at
|
|
57
|
-
* RUNTIME against the per-run `ToolRegistry` (always entered for host commands)
|
|
58
|
-
* rather than a compile-time enum. Returns `undefined` (valid) or an error
|
|
59
|
-
* detail the caller emits.
|
|
60
|
-
*/
|
|
61
|
-
function validateToolFilter(tool) {
|
|
62
|
-
if (tool === undefined)
|
|
63
|
-
return undefined;
|
|
64
|
-
const registry = currentScope()?.tools;
|
|
65
|
-
// No registry (isolated tests): fall back to accepting any non-empty id — the
|
|
66
|
-
// datastore simply returns rows for that discriminant (empty when none).
|
|
67
|
-
if (registry === undefined)
|
|
68
|
-
return undefined;
|
|
69
|
-
// Membership against the registry's session short ids (the set the
|
|
70
|
-
// `isRegisteredToolId` guard reads); used directly here so the unknown-id
|
|
71
|
-
// branch keeps `tool` typed as the original string for the message below.
|
|
72
|
-
const known = registeredToolShortIds(registry);
|
|
73
|
-
if (known.has(tool))
|
|
74
|
-
return undefined;
|
|
75
|
-
const knownList = [...known].sort();
|
|
76
|
-
return {
|
|
77
|
-
code: 'unknown-tool',
|
|
78
|
-
message: `unknown tool '${tool}'` +
|
|
79
|
-
(knownList.length > 0 ? `; registered tools: ${knownList.join(', ')}` : ''),
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
function buildSessionsListSpec(ctx) {
|
|
83
|
-
return defineCommand({
|
|
84
|
-
name: 'list',
|
|
85
|
-
description: 'List stored sessions',
|
|
86
|
-
commonFlags: ['json'],
|
|
87
|
-
options: [
|
|
88
|
-
{
|
|
89
|
-
flag: '--tool',
|
|
90
|
-
value: '<name>',
|
|
91
|
-
description: 'Filter to one tool (any registered tool id)',
|
|
92
|
-
},
|
|
93
|
-
{
|
|
94
|
-
flag: '--limit',
|
|
95
|
-
value: '<n>',
|
|
96
|
-
description: 'Maximum sessions to return',
|
|
97
|
-
parse: parsePositiveInt,
|
|
98
|
-
},
|
|
99
|
-
{
|
|
100
|
-
flag: '--summary-only',
|
|
101
|
-
description: 'Omit heavy per-session payloads (agent friendly; showCommand and lightweight summary remain). ' +
|
|
102
|
-
'Pairs well with --json for lean "menu" of historical results.',
|
|
103
|
-
},
|
|
104
|
-
],
|
|
105
|
-
scope: PROJECT_SCOPE,
|
|
106
|
-
output: COMMAND_RESULT,
|
|
107
|
-
handler: (rawOpts) => {
|
|
108
|
-
const opts = rawOpts;
|
|
109
|
-
const invalid = validateToolFilter(opts.tool);
|
|
110
|
-
if (invalid) {
|
|
111
|
-
ctx.setExitCode(EXIT_CODES.CONFIGURATION_ERROR);
|
|
112
|
-
return {
|
|
113
|
-
type: 'error',
|
|
114
|
-
message: invalid.message,
|
|
115
|
-
exitCode: EXIT_CODES.CONFIGURATION_ERROR,
|
|
116
|
-
};
|
|
117
|
-
}
|
|
118
|
-
return showHistory(ctx.datastore(), {
|
|
119
|
-
tool: opts.tool,
|
|
120
|
-
limit: opts.limit,
|
|
121
|
-
summaryOnly: !!opts.summaryOnly,
|
|
122
|
-
});
|
|
123
|
-
},
|
|
124
|
-
});
|
|
125
|
-
}
|
|
126
|
-
function buildSessionsShowSpec(ctx) {
|
|
127
|
-
return defineCommand({
|
|
128
|
-
name: 'show',
|
|
129
|
-
description: 'Display a stored session result',
|
|
130
|
-
commonFlags: ['json'],
|
|
131
|
-
args: [{ name: 'ref', description: 'Session id, or latest with --tool' }],
|
|
132
|
-
options: [
|
|
133
|
-
{
|
|
134
|
-
flag: '--tool',
|
|
135
|
-
value: '<name>',
|
|
136
|
-
description: 'Tool for latest, or an optional id sanity check (any registered tool id)',
|
|
137
|
-
},
|
|
138
|
-
{
|
|
139
|
-
flag: '--filter',
|
|
140
|
-
value: '<type>',
|
|
141
|
-
description: 'Filter replayed signals (repeatable): errors-only | warnings-only | top:<n>. ' +
|
|
142
|
-
'Composable, e.g. --filter errors-only --filter top:20. Agent ergonomics for historical results.',
|
|
143
|
-
arrayDefault: [],
|
|
144
|
-
parse: (val, prev) => [...prev, val],
|
|
145
|
-
},
|
|
146
|
-
{
|
|
147
|
-
flag: '--raw',
|
|
148
|
-
description: 'With --json: emit the inner payload (session + envelope + metadata) without the outer CommandResult wrapper. ' +
|
|
149
|
-
'Ideal for agents that want the smallest possible response.',
|
|
150
|
-
},
|
|
151
|
-
],
|
|
152
|
-
scope: PROJECT_SCOPE,
|
|
153
|
-
output: RAW_STREAM,
|
|
154
|
-
rawStreamReason: 'session-replay',
|
|
155
|
-
handler: async (rawOpts) => {
|
|
156
|
-
const opts = rawOpts;
|
|
157
|
-
const ref = opts._args[0];
|
|
158
|
-
const invalid = validateToolFilter(opts.tool);
|
|
159
|
-
if (invalid) {
|
|
160
|
-
if (opts.json === true) {
|
|
161
|
-
ctx.emitError({
|
|
162
|
-
message: invalid.message,
|
|
163
|
-
exitCode: EXIT_CODES.CONFIGURATION_ERROR,
|
|
164
|
-
code: invalid.code,
|
|
165
|
-
});
|
|
166
|
-
return;
|
|
167
|
-
}
|
|
168
|
-
ctx.setExitCode(EXIT_CODES.CONFIGURATION_ERROR);
|
|
169
|
-
await ctx.render({
|
|
170
|
-
type: 'error',
|
|
171
|
-
message: invalid.message,
|
|
172
|
-
exitCode: EXIT_CODES.CONFIGURATION_ERROR,
|
|
173
|
-
});
|
|
174
|
-
return;
|
|
175
|
-
}
|
|
176
|
-
const filters = normalizeFilterOption(opts.filter);
|
|
177
|
-
await executeSessionShow({
|
|
178
|
-
replayRegistry: ctx.sessionReplayRegistry,
|
|
179
|
-
ref,
|
|
180
|
-
tool: opts.tool,
|
|
181
|
-
json: opts.json,
|
|
182
|
-
filters,
|
|
183
|
-
raw: opts.raw,
|
|
184
|
-
render: ctx.render,
|
|
185
|
-
emitJson: ctx.emitJson,
|
|
186
|
-
emitRaw: ctx.emitRaw,
|
|
187
|
-
emitError: ctx.emitError,
|
|
188
|
-
setExitCode: ctx.setExitCode,
|
|
189
|
-
});
|
|
190
|
-
},
|
|
191
|
-
});
|
|
192
|
-
}
|
|
193
|
-
/**
|
|
194
|
-
* Normalize the repeatable `--filter` option (Commander yields a string for one
|
|
195
|
-
* occurrence, a string[] for many, undefined for none) into a uniform
|
|
196
|
-
* `string[] | undefined` for `executeSessionShow`.
|
|
197
|
-
*/
|
|
198
|
-
function normalizeFilterOption(filter) {
|
|
199
|
-
if (Array.isArray(filter))
|
|
200
|
-
return filter;
|
|
201
|
-
if (filter)
|
|
202
|
-
return [filter];
|
|
203
|
-
return undefined;
|
|
204
|
-
}
|
|
205
|
-
/**
|
|
206
|
-
* Validating coercion for `sessions list --limit <n>`.
|
|
207
|
-
*
|
|
208
|
-
* @throws {Error} When the raw value is not a positive integer.
|
|
209
|
-
*/
|
|
210
|
-
function parsePositiveInt(raw) {
|
|
211
|
-
const n = Number.parseInt(raw, 10);
|
|
212
|
-
if (Number.isNaN(n) || n <= 0) {
|
|
213
|
-
throw new Error(`Invalid --limit value: '${raw}'. Must be a positive integer.`);
|
|
214
|
-
}
|
|
215
|
-
return n;
|
|
216
|
-
}
|
|
217
|
-
/**
|
|
218
|
-
* Validating coercion for `sessions purge --older-than <days>` — identical to
|
|
219
|
-
* the former inline argParser. A named declaration (not an inline lambda) so the
|
|
220
|
-
* `@throws` contract below is documented.
|
|
221
|
-
*
|
|
222
|
-
* @throws {Error} When the raw value is not a non-negative integer.
|
|
223
|
-
*/
|
|
224
|
-
function parseOlderThanDays(raw) {
|
|
225
|
-
const n = Number.parseInt(raw, 10);
|
|
226
|
-
if (Number.isNaN(n) || n < 0) {
|
|
227
|
-
throw new Error(`Invalid --older-than value: '${raw}'. Must be a non-negative integer.`);
|
|
228
|
-
}
|
|
229
|
-
return n;
|
|
230
|
-
}
|
|
231
|
-
function buildSessionsPurgeSpec(ctx) {
|
|
232
|
-
return defineCommand({
|
|
233
|
-
name: 'purge',
|
|
234
|
-
description: 'Delete session rows from the project-local SQLite store (opensip-cli/.runtime/datastore.sqlite)',
|
|
235
|
-
commonFlags: ['json'],
|
|
236
|
-
options: [
|
|
237
|
-
{
|
|
238
|
-
flag: '--older-than',
|
|
239
|
-
value: '<days>',
|
|
240
|
-
description: 'Only delete sessions older than N days',
|
|
241
|
-
// Pure validating coercion — identical to the former inline argParser.
|
|
242
|
-
parse: parseOlderThanDays,
|
|
243
|
-
},
|
|
244
|
-
{ flag: '-y, --yes', description: 'Skip confirmation prompt', default: false },
|
|
245
|
-
],
|
|
246
|
-
scope: PROJECT_SCOPE,
|
|
247
|
-
output: COMMAND_RESULT,
|
|
248
|
-
handler: (rawOpts) => {
|
|
249
|
-
const opts = rawOpts;
|
|
250
|
-
return executeClear({
|
|
251
|
-
olderThan: opts.olderThan,
|
|
252
|
-
yes: opts.yes,
|
|
253
|
-
datastore: ctx.datastore(),
|
|
254
|
-
});
|
|
255
|
-
},
|
|
256
|
-
});
|
|
257
|
-
}
|
|
258
|
-
// ---------------------------------------------------------------------------
|
|
259
|
-
// <tool> plugin {list,add,remove,sync} — DOMAIN-BOUND extension-pack ops
|
|
260
|
-
// ---------------------------------------------------------------------------
|
|
261
|
-
//
|
|
262
|
-
// The pack ops are mounted UNDER each pack-supporting tool primary
|
|
263
|
-
// (`opensip fit plugin …`, `opensip sim plugin …`) by `mountToolPluginGroups`,
|
|
264
|
-
// with the `domain` PRE-BOUND from that tool. There is no top-level
|
|
265
|
-
// `opensip plugin` command and no `--domain`/`--type` flag: the tool the
|
|
266
|
-
// subcommand hangs off of IS the domain. Whole Tool plugins are managed by
|
|
267
|
-
// `opensip tools …`, never here.
|
|
268
|
-
/** The shared `--cwd <path>` option for the plugin leaves. Its description is
|
|
269
|
-
* "Project root" (NOT the registry's "Target directory"), so it is declared as
|
|
270
|
-
* a per-command OptionSpec rather than the `cwd` common flag — preserving the
|
|
271
|
-
* byte-identical help text. The default resolves per-invocation (the builders
|
|
272
|
-
* run on each `registerCliCommands` call). */
|
|
273
|
-
function pluginCwdOption() {
|
|
274
|
-
return {
|
|
275
|
-
flag: '--cwd',
|
|
276
|
-
value: '<path>',
|
|
277
|
-
description: 'Project root',
|
|
278
|
-
default: process.cwd(),
|
|
279
|
-
};
|
|
280
|
-
}
|
|
281
|
-
/** The single-domain layout view passed to the pure plugin commands so a
|
|
282
|
-
* bound `<tool> plugin …` op only ever touches its own domain. Resolved from
|
|
283
|
-
* the host's contributed `pluginLayouts` (so the domain is a real layout, not
|
|
284
|
-
* an arbitrary string); falls back to a minimal layout if the tool's full
|
|
285
|
-
* layout is somehow absent. */
|
|
286
|
-
function boundLayouts(ctx, domain) {
|
|
287
|
-
const match = ctx.pluginLayouts.find((l) => l.domain === domain);
|
|
288
|
-
return match ? [match] : [{ domain, userSubdirs: [] }];
|
|
289
|
-
}
|
|
290
|
-
function buildPluginListSpec(ctx, domain) {
|
|
291
|
-
return defineCommand({
|
|
292
|
-
name: 'list',
|
|
293
|
-
description: `List installed ${domain} packs`,
|
|
294
|
-
commonFlags: ['json'],
|
|
295
|
-
options: [pluginCwdOption()],
|
|
296
|
-
scope: PROJECT_SCOPE,
|
|
297
|
-
output: COMMAND_RESULT,
|
|
298
|
-
handler: (rawOpts) => {
|
|
299
|
-
const opts = rawOpts;
|
|
300
|
-
// Per-run admitted-tool provenance is on the entered RunScope (stamped by
|
|
301
|
-
// the bootstrap); read it here and pass it into the pure `pluginList`,
|
|
302
|
-
// scoped to this tool's own domain.
|
|
303
|
-
return pluginList(effectiveCwd(opts), boundLayouts(ctx, domain), currentScope()?.toolProvenance ?? []);
|
|
304
|
-
},
|
|
305
|
-
});
|
|
306
|
-
}
|
|
307
|
-
function buildPluginAddSpec(ctx, domain) {
|
|
308
|
-
return defineCommand({
|
|
309
|
-
name: 'add',
|
|
310
|
-
description: `Install a ${domain} pack and record it in opensip-cli.config.yml`,
|
|
311
|
-
commonFlags: ['json'],
|
|
312
|
-
options: [pluginCwdOption()],
|
|
313
|
-
// Empty description: the former `.command('add <package>')` declared the
|
|
314
|
-
// positional inline with no help text, so Commander rendered no "Arguments:"
|
|
315
|
-
// block. Keeping it empty preserves the byte-identical --help.
|
|
316
|
-
args: [{ name: 'package', description: '' }],
|
|
317
|
-
scope: PROJECT_SCOPE,
|
|
318
|
-
output: COMMAND_RESULT,
|
|
319
|
-
handler: (rawOpts) => {
|
|
320
|
-
const opts = rawOpts;
|
|
321
|
-
const packageName = opts._args[0];
|
|
322
|
-
// Domain is bound from the tool primary — no `--domain` flag.
|
|
323
|
-
return pluginAdd(packageName, effectiveCwd(opts), domain, boundLayouts(ctx, domain));
|
|
324
|
-
},
|
|
325
|
-
});
|
|
326
|
-
}
|
|
327
|
-
function buildPluginRemoveSpec(ctx, domain) {
|
|
328
|
-
return defineCommand({
|
|
329
|
-
name: 'remove',
|
|
330
|
-
description: `Uninstall a ${domain} pack and remove it from opensip-cli.config.yml`,
|
|
331
|
-
commonFlags: ['json'],
|
|
332
|
-
options: [pluginCwdOption()],
|
|
333
|
-
// Empty description — see the plugin-add note above (byte-identical --help).
|
|
334
|
-
args: [{ name: 'package', description: '' }],
|
|
335
|
-
scope: PROJECT_SCOPE,
|
|
336
|
-
output: COMMAND_RESULT,
|
|
337
|
-
handler: (rawOpts) => {
|
|
338
|
-
const opts = rawOpts;
|
|
339
|
-
const packageName = opts._args[0];
|
|
340
|
-
return pluginRemove(packageName, effectiveCwd(opts), domain, boundLayouts(ctx, domain));
|
|
341
|
-
},
|
|
342
|
-
});
|
|
343
|
-
}
|
|
344
|
-
function buildPluginSyncSpec(ctx, domain) {
|
|
345
|
-
return defineCommand({
|
|
346
|
-
name: 'sync',
|
|
347
|
-
description: `Install every ${domain} pack declared in opensip-cli.config.yml (post-clone bootstrap)`,
|
|
348
|
-
commonFlags: ['json'],
|
|
349
|
-
options: [pluginCwdOption()],
|
|
350
|
-
scope: PROJECT_SCOPE,
|
|
351
|
-
output: COMMAND_RESULT,
|
|
352
|
-
handler: (rawOpts) => {
|
|
353
|
-
const opts = rawOpts;
|
|
354
|
-
return pluginSync(effectiveCwd(opts), domain, boundLayouts(ctx, domain));
|
|
355
|
-
},
|
|
356
|
-
});
|
|
357
|
-
}
|
|
358
|
-
/**
|
|
359
|
-
* Build the four domain-bound `plugin` leaf specs for ONE pack-supporting tool
|
|
360
|
-
* (`add`/`list`/`remove`/`sync`, all scoped to `domain`). Shared by the mount
|
|
361
|
-
* path (`mountToolPluginGroups`), the command-scope index, and the completion
|
|
362
|
-
* inventory so the three derive the SAME leaves.
|
|
363
|
-
*/
|
|
364
|
-
export function buildToolPluginLeaves(ctx, domain) {
|
|
365
|
-
return [
|
|
366
|
-
buildPluginListSpec(ctx, domain),
|
|
367
|
-
buildPluginAddSpec(ctx, domain),
|
|
368
|
-
buildPluginRemoveSpec(ctx, domain),
|
|
369
|
-
buildPluginSyncSpec(ctx, domain),
|
|
370
|
-
];
|
|
371
|
-
}
|
|
372
|
-
/**
|
|
373
|
-
* Derive the per-tool `plugin` groups from the host's contributed
|
|
374
|
-
* `pluginLayouts` — one group per pack-supporting domain (fit/sim). A tool with
|
|
375
|
-
* no `pluginLayout` (e.g. `graph`) contributes none, so it gets no `plugin`
|
|
376
|
-
* group. The single source the mount path + scope index + completion all read.
|
|
377
|
-
*/
|
|
378
|
-
export function buildToolPluginGroups(ctx) {
|
|
379
|
-
return ctx.pluginLayouts.map((layout) => ({
|
|
380
|
-
toolVerb: layout.domain,
|
|
381
|
-
domain: layout.domain,
|
|
382
|
-
description: `Manage ${layout.domain} extension packs (add, list, remove, sync)`,
|
|
383
|
-
leaves: buildToolPluginLeaves(ctx, layout.domain),
|
|
384
|
-
}));
|
|
385
|
-
}
|
|
386
|
-
/**
|
|
387
|
-
* Mount each per-tool `plugin` group UNDER its pack-supporting tool primary
|
|
388
|
-
* (`opensip fit plugin …`), domain pre-bound from the tool. The host derives the
|
|
389
|
-
* groups from the contributed `pluginLayouts` (fit/sim; graph has none, so no
|
|
390
|
-
* group). The tool primary must already be mounted — it is, because the
|
|
391
|
-
* composition root mounts tools before the host commands; a domain whose primary
|
|
392
|
-
* is absent (isolated host-only tests) is skipped (nowhere to hang it).
|
|
393
|
-
*/
|
|
394
|
-
export function mountToolPluginGroups(program, ctx) {
|
|
395
|
-
for (const group of buildToolPluginGroups(ctx)) {
|
|
396
|
-
const primary = program.commands.find((c) => c.name() === group.toolVerb);
|
|
397
|
-
if (primary === undefined)
|
|
398
|
-
continue; // no tool primary mounted (host-only tests)
|
|
399
|
-
const parent = primary.command('plugin').description(group.description);
|
|
400
|
-
for (const leaf of group.leaves) {
|
|
401
|
-
mountCommandSpec(parent, leaf, ctx);
|
|
402
|
-
}
|
|
403
|
-
}
|
|
404
|
-
}
|
|
22
|
+
export { effectiveCwd } from './host-subcommand-shared.js';
|
|
23
|
+
export { buildToolPluginLeaves, buildToolPluginGroups, mountToolPluginGroups, } from './host-subcommand-plugins.js';
|
|
405
24
|
/**
|
|
406
25
|
* The action-less Commander subcommand GROUPS that legitimately cannot be a
|
|
407
26
|
* single {@link CommandSpec} — they have no action body, only sub-subcommands.
|
|
@@ -409,17 +28,13 @@ export function mountToolPluginGroups(program, ctx) {
|
|
|
409
28
|
* allow-lists as documented host exceptions. Every other host command IS a spec.
|
|
410
29
|
*/
|
|
411
30
|
export const HOST_SUBCOMMAND_GROUPS = ['sessions', 'tools'];
|
|
412
|
-
/**
|
|
413
|
-
* Build the subcommand-group parents with their leaf specs. The mounter turns
|
|
414
|
-
* each into a raw parent `program.command(name)` plus `mountCommandSpec(parent,
|
|
415
|
-
* leaf)` for each leaf.
|
|
416
|
-
*/
|
|
31
|
+
/** Build the subcommand-group parents with their leaf specs. */
|
|
417
32
|
export function buildHostSubcommandGroups(ctx) {
|
|
418
33
|
return [
|
|
419
34
|
{
|
|
420
35
|
name: 'sessions',
|
|
421
36
|
description: 'Manage session data',
|
|
422
|
-
leaves:
|
|
37
|
+
leaves: buildSessionsGroupLeaves(ctx),
|
|
423
38
|
},
|
|
424
39
|
{
|
|
425
40
|
name: 'tools',
|
|
@@ -428,12 +43,6 @@ export function buildHostSubcommandGroups(ctx) {
|
|
|
428
43
|
},
|
|
429
44
|
];
|
|
430
45
|
}
|
|
431
|
-
/**
|
|
432
|
-
* A no-op {@link CliCommandsContext} used purely to BUILD the group leaf specs
|
|
433
|
-
* so their `name` can be read for the completion-script sub-subcommand
|
|
434
|
-
* inventory. The handlers are never invoked here — we only inspect the static
|
|
435
|
-
* declarations — so the render/datastore/exit members are inert stubs.
|
|
436
|
-
*/
|
|
437
46
|
const INVENTORY_CTX = {
|
|
438
47
|
setExitCode: () => {
|
|
439
48
|
/* inert — inventory builds never dispatch a handler */
|
|
@@ -450,7 +59,7 @@ const INVENTORY_CTX = {
|
|
|
450
59
|
},
|
|
451
60
|
pluginLayouts: [],
|
|
452
61
|
toolScaffolds: [],
|
|
453
|
-
// eslint-disable-next-line unicorn/no-useless-undefined -- explicit no-store sentinel matching the `datastore` thunk contract
|
|
62
|
+
// eslint-disable-next-line unicorn/no-useless-undefined -- explicit no-store sentinel matching the `datastore` thunk contract
|
|
454
63
|
datastore: () => undefined,
|
|
455
64
|
};
|
|
456
65
|
/** Build the host subcommand-group name inventory (single source for completion). */
|