opensip-cli 0.1.6 → 0.1.7
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/admit-tool-package.d.ts.map +1 -1
- package/dist/bootstrap/admit-tool-package.js +8 -3
- package/dist/bootstrap/admit-tool-package.js.map +1 -1
- package/dist/bootstrap/bind-tool-context.d.ts.map +1 -1
- package/dist/bootstrap/bind-tool-context.js +5 -3
- package/dist/bootstrap/bind-tool-context.js.map +1 -1
- package/dist/bootstrap/build-command-registration-input.d.ts +7 -0
- package/dist/bootstrap/build-command-registration-input.d.ts.map +1 -1
- package/dist/bootstrap/build-command-registration-input.js +11 -4
- package/dist/bootstrap/build-command-registration-input.js.map +1 -1
- package/dist/bootstrap/build-per-run-scope.d.ts +12 -0
- package/dist/bootstrap/build-per-run-scope.d.ts.map +1 -1
- package/dist/bootstrap/build-per-run-scope.js +84 -9
- package/dist/bootstrap/build-per-run-scope.js.map +1 -1
- package/dist/bootstrap/bundled-manifest.d.ts +5 -0
- package/dist/bootstrap/bundled-manifest.d.ts.map +1 -0
- package/dist/bootstrap/bundled-manifest.js +13 -0
- package/dist/bootstrap/bundled-manifest.js.map +1 -0
- package/dist/bootstrap/bundled-tools.manifest.json +19 -1
- package/dist/bootstrap/config-and-capabilities.d.ts.map +1 -1
- package/dist/bootstrap/config-and-capabilities.js +5 -4
- package/dist/bootstrap/config-and-capabilities.js.map +1 -1
- package/dist/bootstrap/constants.d.ts +3 -0
- package/dist/bootstrap/constants.d.ts.map +1 -0
- package/dist/bootstrap/constants.js +3 -0
- package/dist/bootstrap/constants.js.map +1 -0
- package/dist/bootstrap/decorate-tool-primary.d.ts +50 -0
- package/dist/bootstrap/decorate-tool-primary.d.ts.map +1 -0
- package/dist/bootstrap/decorate-tool-primary.js +111 -0
- package/dist/bootstrap/decorate-tool-primary.js.map +1 -0
- package/dist/bootstrap/execute-post-bailout-bootstrap.d.ts.map +1 -1
- package/dist/bootstrap/execute-post-bailout-bootstrap.js +10 -0
- package/dist/bootstrap/execute-post-bailout-bootstrap.js.map +1 -1
- package/dist/bootstrap/index.d.ts +1 -1
- package/dist/bootstrap/index.d.ts.map +1 -1
- package/dist/bootstrap/index.js +1 -4
- package/dist/bootstrap/index.js.map +1 -1
- package/dist/bootstrap/io-plane.d.ts +47 -0
- package/dist/bootstrap/io-plane.d.ts.map +1 -0
- package/dist/bootstrap/io-plane.js +73 -0
- package/dist/bootstrap/io-plane.js.map +1 -0
- package/dist/bootstrap/load-tool-capabilities.d.ts.map +1 -1
- package/dist/bootstrap/load-tool-capabilities.js +18 -2
- package/dist/bootstrap/load-tool-capabilities.js.map +1 -1
- package/dist/bootstrap/owning-tool-init.d.ts.map +1 -1
- package/dist/bootstrap/owning-tool-init.js +7 -4
- package/dist/bootstrap/owning-tool-init.js.map +1 -1
- package/dist/bootstrap/phase-map.d.ts +20 -0
- package/dist/bootstrap/phase-map.d.ts.map +1 -0
- package/dist/bootstrap/phase-map.js +108 -0
- package/dist/bootstrap/phase-map.js.map +1 -0
- package/dist/bootstrap/pre-action-hook.d.ts.map +1 -1
- package/dist/bootstrap/pre-action-hook.js +19 -2
- package/dist/bootstrap/pre-action-hook.js.map +1 -1
- package/dist/bootstrap/register-tools-discovery.d.ts +38 -39
- package/dist/bootstrap/register-tools-discovery.d.ts.map +1 -1
- package/dist/bootstrap/register-tools-discovery.js +132 -83
- package/dist/bootstrap/register-tools-discovery.js.map +1 -1
- package/dist/bootstrap/register-tools-mount.d.ts +18 -1
- package/dist/bootstrap/register-tools-mount.d.ts.map +1 -1
- package/dist/bootstrap/register-tools-mount.js +118 -18
- package/dist/bootstrap/register-tools-mount.js.map +1 -1
- package/dist/bootstrap/register-tools.d.ts +58 -14
- package/dist/bootstrap/register-tools.d.ts.map +1 -1
- package/dist/bootstrap/register-tools.js +185 -14
- package/dist/bootstrap/register-tools.js.map +1 -1
- package/dist/bootstrap/root-version.d.ts +26 -0
- package/dist/bootstrap/root-version.d.ts.map +1 -0
- package/dist/bootstrap/root-version.js +36 -0
- package/dist/bootstrap/root-version.js.map +1 -0
- package/dist/bootstrap/scope-access.d.ts +11 -0
- package/dist/bootstrap/scope-access.d.ts.map +1 -1
- package/dist/bootstrap/scope-access.js +26 -0
- package/dist/bootstrap/scope-access.js.map +1 -1
- package/dist/bootstrap/tool-lifecycle.d.ts +0 -22
- package/dist/bootstrap/tool-lifecycle.d.ts.map +1 -1
- package/dist/bootstrap/tool-lifecycle.js +0 -23
- package/dist/bootstrap/tool-lifecycle.js.map +1 -1
- package/dist/bootstrap/validate-tool.d.ts +10 -4
- package/dist/bootstrap/validate-tool.d.ts.map +1 -1
- package/dist/bootstrap/validate-tool.js +76 -22
- package/dist/bootstrap/validate-tool.js.map +1 -1
- package/dist/cli-context.d.ts +2 -2
- package/dist/cli-context.d.ts.map +1 -1
- package/dist/cli-context.js +20 -35
- package/dist/cli-context.js.map +1 -1
- package/dist/commands/agent-catalog.d.ts +29 -0
- package/dist/commands/agent-catalog.d.ts.map +1 -1
- package/dist/commands/agent-catalog.js +77 -36
- package/dist/commands/agent-catalog.js.map +1 -1
- package/dist/commands/clear.d.ts.map +1 -1
- package/dist/commands/clear.js +0 -1
- package/dist/commands/clear.js.map +1 -1
- package/dist/commands/command-scope-index.d.ts +15 -1
- package/dist/commands/command-scope-index.d.ts.map +1 -1
- package/dist/commands/command-scope-index.js +10 -1
- package/dist/commands/command-scope-index.js.map +1 -1
- package/dist/commands/completion.d.ts +67 -6
- package/dist/commands/completion.d.ts.map +1 -1
- package/dist/commands/completion.js +84 -12
- package/dist/commands/completion.js.map +1 -1
- package/dist/commands/configure.d.ts.map +1 -1
- package/dist/commands/configure.js +0 -1
- package/dist/commands/configure.js.map +1 -1
- package/dist/commands/host-command-specs.d.ts +16 -9
- package/dist/commands/host-command-specs.d.ts.map +1 -1
- package/dist/commands/host-command-specs.js +45 -19
- package/dist/commands/host-command-specs.js.map +1 -1
- package/dist/commands/host-config-flag.d.ts +21 -0
- package/dist/commands/host-config-flag.d.ts.map +1 -0
- package/dist/commands/host-config-flag.js +21 -0
- package/dist/commands/host-config-flag.js.map +1 -0
- package/dist/commands/host-subcommand-groups.d.ts +46 -5
- package/dist/commands/host-subcommand-groups.d.ts.map +1 -1
- package/dist/commands/host-subcommand-groups.js +97 -65
- package/dist/commands/host-subcommand-groups.js.map +1 -1
- package/dist/commands/index.d.ts +1 -1
- package/dist/commands/index.js +1 -1
- package/dist/commands/internal-command-visibility.d.ts +42 -0
- package/dist/commands/internal-command-visibility.d.ts.map +1 -0
- package/dist/commands/internal-command-visibility.js +54 -0
- package/dist/commands/internal-command-visibility.js.map +1 -0
- package/dist/commands/mount-command-action.d.ts +5 -0
- package/dist/commands/mount-command-action.d.ts.map +1 -1
- package/dist/commands/mount-command-action.js +26 -2
- package/dist/commands/mount-command-action.js.map +1 -1
- package/dist/commands/mount-command-spec.d.ts +9 -2
- package/dist/commands/mount-command-spec.d.ts.map +1 -1
- package/dist/commands/mount-command-spec.js +9 -1
- package/dist/commands/mount-command-spec.js.map +1 -1
- package/dist/commands/plugin/domain-resolution.d.ts +12 -13
- package/dist/commands/plugin/domain-resolution.d.ts.map +1 -1
- package/dist/commands/plugin/domain-resolution.js +12 -58
- package/dist/commands/plugin/domain-resolution.js.map +1 -1
- package/dist/commands/plugin/host-dir.d.ts +0 -1
- package/dist/commands/plugin/host-dir.d.ts.map +1 -1
- package/dist/commands/plugin/host-dir.js +1 -1
- package/dist/commands/plugin/host-dir.js.map +1 -1
- package/dist/commands/plugin.d.ts +20 -14
- package/dist/commands/plugin.d.ts.map +1 -1
- package/dist/commands/plugin.js +39 -47
- package/dist/commands/plugin.js.map +1 -1
- package/dist/commands/render-outcome.d.ts.map +1 -1
- package/dist/commands/render-outcome.js.map +1 -1
- package/dist/commands/shared.d.ts +9 -0
- package/dist/commands/shared.d.ts.map +1 -1
- package/dist/commands/tools/create.d.ts +11 -0
- package/dist/commands/tools/create.d.ts.map +1 -0
- package/dist/commands/tools/create.js +84 -0
- package/dist/commands/tools/create.js.map +1 -0
- package/dist/commands/tools/index.d.ts.map +1 -1
- package/dist/commands/tools/index.js +31 -0
- package/dist/commands/tools/index.js.map +1 -1
- package/dist/commands/tools/runtime-probe-entry.d.ts.map +1 -1
- package/dist/commands/tools/runtime-probe-entry.js +4 -2
- package/dist/commands/tools/runtime-probe-entry.js.map +1 -1
- package/dist/commands/tools/validate.d.ts.map +1 -1
- package/dist/commands/tools/validate.js +12 -5
- package/dist/commands/tools/validate.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 +18 -0
- package/dist/env/host-env-specs.d.ts.map +1 -1
- package/dist/env/host-env-specs.js +36 -2
- package/dist/env/host-env-specs.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +24 -6
- package/dist/index.js.map +1 -1
- package/dist/report-compose.d.ts.map +1 -1
- package/dist/report-compose.js +2 -2
- package/dist/report-compose.js.map +1 -1
- package/dist/session-replay-registry.d.ts +1 -1
- package/dist/session-replay-registry.d.ts.map +1 -1
- package/dist/session-replay-registry.js +3 -1
- package/dist/session-replay-registry.js.map +1 -1
- package/dist/ui/result-to-view.d.ts +27 -7
- package/dist/ui/result-to-view.d.ts.map +1 -1
- package/dist/ui/result-to-view.js +68 -75
- 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 +3 -1
- 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 +21 -0
- package/dist/ui/views/tools-views.js.map +1 -1
- package/package.json +32 -32
- package/dist/bootstrap/authored-tool-admission.d.ts +0 -23
- package/dist/bootstrap/authored-tool-admission.d.ts.map +0 -1
- package/dist/bootstrap/authored-tool-admission.js +0 -54
- package/dist/bootstrap/authored-tool-admission.js.map +0 -1
- package/dist/bootstrap/egress-plane.d.ts +0 -22
- package/dist/bootstrap/egress-plane.d.ts.map +0 -1
- package/dist/bootstrap/egress-plane.js +0 -37
- package/dist/bootstrap/egress-plane.js.map +0 -1
- package/dist/bootstrap/installed-tool-admission.d.ts +0 -20
- package/dist/bootstrap/installed-tool-admission.d.ts.map +0 -1
- package/dist/bootstrap/installed-tool-admission.js +0 -60
- package/dist/bootstrap/installed-tool-admission.js.map +0 -1
- package/dist/bootstrap/live-plane.d.ts +0 -51
- package/dist/bootstrap/live-plane.d.ts.map +0 -1
- package/dist/bootstrap/live-plane.js +0 -72
- package/dist/bootstrap/live-plane.js.map +0 -1
- package/dist/bootstrap/register-tools-bundled.d.ts +0 -28
- package/dist/bootstrap/register-tools-bundled.d.ts.map +0 -1
- package/dist/bootstrap/register-tools-bundled.js +0 -107
- package/dist/bootstrap/register-tools-bundled.js.map +0 -1
- package/dist/bootstrap/register-tools-shared.d.ts +0 -40
- package/dist/bootstrap/register-tools-shared.d.ts.map +0 -1
- package/dist/bootstrap/register-tools-shared.js +0 -98
- package/dist/bootstrap/register-tools-shared.js.map +0 -1
|
@@ -6,14 +6,22 @@
|
|
|
6
6
|
* {@link executePostBailoutBootstrap} (phases 5–9). This module wires those
|
|
7
7
|
* to Commander's preAction/postAction hooks.
|
|
8
8
|
*/
|
|
9
|
-
import { currentScope, generatePrefixedId } from '@opensip-cli/core';
|
|
9
|
+
import { currentScope, exitScope, generatePrefixedId } from '@opensip-cli/core';
|
|
10
10
|
import { commandPath } from '../commands/command-scope-index.js';
|
|
11
|
+
import { hostEnv } from '../env/host-env-specs.js';
|
|
11
12
|
import { executePostBailoutBootstrap } from './execute-post-bailout-bootstrap.js';
|
|
12
13
|
import { planPreActionBootstrap } from './plan-pre-action-bootstrap.js';
|
|
13
14
|
export { resolveOwningTool } from './owning-tool-init.js';
|
|
14
15
|
export function installPreActionHook(program, version, runtime, commandScopes) {
|
|
15
16
|
program.hook('preAction', async (_thisCommand, actionCommand) => {
|
|
16
|
-
|
|
17
|
+
// B1 ("Child runId behavior"): resolve `runId` env-FIRST. A forked/spawned
|
|
18
|
+
// child re-enters this hook and inherits its parent's run via `OPENSIP_RUN_ID`
|
|
19
|
+
// (set in the child env by `correlationToEnv`); a top-level invocation, with
|
|
20
|
+
// no `OPENSIP_RUN_ID` set, mints a fresh id. This is the single inheritance
|
|
21
|
+
// seam — the spec JSON deliberately never carries `runId`, because the logger
|
|
22
|
+
// that stamps every worker line is already live before the spec is parsed.
|
|
23
|
+
const inherited = hostEnv.get('OPENSIP_RUN_ID');
|
|
24
|
+
const runId = inherited && inherited.length > 0 ? inherited : generatePrefixedId('run');
|
|
17
25
|
const opts = actionCommand.opts();
|
|
18
26
|
const cwd = opts.cwd ?? process.cwd();
|
|
19
27
|
const cwdExplicit = actionCommand.getOptionValueSource('cwd') === 'cli';
|
|
@@ -49,5 +57,14 @@ export function disposeCurrentScope() {
|
|
|
49
57
|
catch {
|
|
50
58
|
// @swallow-ok dispose errors on shutdown; the run has already produced its outcome.
|
|
51
59
|
}
|
|
60
|
+
finally {
|
|
61
|
+
// Complete the per-command lifecycle: clear the ambient ALS slot so a
|
|
62
|
+
// subsequent command in the same process (a long-lived host driving
|
|
63
|
+
// Commander sequentially) starts with a clean slot and its `enterScope`
|
|
64
|
+
// does not trip the always-on re-entrancy guard against this finished run.
|
|
65
|
+
// Production runs one command per process, so this is normally the final
|
|
66
|
+
// teardown; it is a no-op when no scope is current.
|
|
67
|
+
exitScope();
|
|
68
|
+
}
|
|
52
69
|
}
|
|
53
70
|
//# sourceMappingURL=pre-action-hook.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pre-action-hook.js","sourceRoot":"","sources":["../../src/bootstrap/pre-action-hook.ts"],"names":[],"mappings":"AAAA,qOAAqO;AACrO;;;;;;GAMG;AAEH,OAAO,EAAE,YAAY,EAAE,kBAAkB,E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I;YACV,GAAG;YACH,WAAW;YACX,KAAK;YACL,WAAW,EAAE,aAAa,CAAC,IAAI,EAAE;YACjC,WAAW,EAAE,WAAW,CAAC,aAAa,CAAC;YACvC,aAAa;YACb,kBAAkB,EAAE,IAAI,CAAC,MAA4B;SACtD,CAAC,CAAC;QAEH,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,2BAA2B,CAAC;YAClD,IAAI;YACJ,OAAO;YACP,OAAO;YACP,iIAAiI;YACjI,OAAO,EAAE,aAAa,CAAC,eAAe,EAAE,CAAC,KAAK,KAAK,KAAK;YACxD,MAAM,EAAE,IAAI,CAAC,MAA4B;SAC1C,CAAC,CAAC;QACH,KAAK,CAAC,WAAW,CAAC,KAAK,CACrB,MAAM,EACN,OAAO,EACP,sCAAsC,aAAa,CAAC,IAAI,EAAE,GAAG,CAC9D,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,OAAO,CAAC,IAAI,CAAC,YAAY,EAAE,mBAAmB,CAAC,CAAC;AAClD,CAAC;AAED,MAAM,UAAU,mBAAmB;IACjC,IAAI,CAAC;QACH,MAAM,CAAC,GAAG,YAAY,EAAE,CAAC;QACzB,IAAI,CAAC,IAAI,OAAO,CAAC,CAAC,OAAO,KAAK,UAAU,EAAE,CAAC;YACzC,CAAC,CAAC,OAAO,EAAE,CAAC;QACd,CAAC;IACH,CAAC;IAAC,MAAM,CAAC;QACP,oFAAoF;IACtF,CAAC;YAAS,CAAC;QACT,sEAAsE;QACtE,oEAAoE;QACpE,wEAAwE;QACxE,2EAA2E;QAC3E,yEAAyE;QACzE,oDAAoD;QACpD,SAAS,EAAE,CAAC;IACd,CAAC;AACH,CAAC"}
|
|
@@ -1,4 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* register-tools-discovery — installed + authored tool admission and discovery.
|
|
3
|
+
*
|
|
4
|
+
* Extracted from register-tools.ts so the bundled registration path stays a
|
|
5
|
+
* focused module under the file-length soft limit.
|
|
6
|
+
*/
|
|
1
7
|
import { type ToolPluginManifest, type ToolProvenance, type ToolRegistry, type ToolDiscoverySource } from '@opensip-cli/core';
|
|
8
|
+
import { type ToolRuntimeLoad } from './admit-tool-package.js';
|
|
9
|
+
import type { ToolAdmission } from './tool-admission-types.js';
|
|
10
|
+
export type AuthoredAdmission = ToolAdmission;
|
|
11
|
+
/**
|
|
12
|
+
* Admit or reject a PROJECT-LOCAL authored tool under the deny-by-default trust
|
|
13
|
+
* policy. The trust decision always precedes module import; a non-allowlisted
|
|
14
|
+
* tool fails closed before any authored code can run.
|
|
15
|
+
*
|
|
16
|
+
* @throws {PluginIncompatibleError} When the sidecar manifest is missing,
|
|
17
|
+
* malformed, incompatible, or not trusted by the project-tool allowlist.
|
|
18
|
+
*/
|
|
19
|
+
export declare function admitProjectLocalTool(args: {
|
|
20
|
+
readonly dir: string;
|
|
21
|
+
readonly env?: NodeJS.ProcessEnv;
|
|
22
|
+
}): AuthoredAdmission;
|
|
23
|
+
/**
|
|
24
|
+
* Admit a USER-GLOBAL authored tool — trusted-by-default because the user placed
|
|
25
|
+
* it in their own home-dir tool host, but still fail-closed on a missing or
|
|
26
|
+
* incompatible manifest.
|
|
27
|
+
*/
|
|
28
|
+
export declare function admitUserGlobalTool(args: {
|
|
29
|
+
readonly dir: string;
|
|
30
|
+
}): AuthoredAdmission;
|
|
31
|
+
/**
|
|
32
|
+
* Emit the best-effort stderr line + structured warning for a discovered
|
|
33
|
+
* INSTALLED tool whose runtime failed to load. Each failure reason maps to its
|
|
34
|
+
* own diagnostic while preserving the installed leg's skip-not-crash posture.
|
|
35
|
+
*/
|
|
36
|
+
export declare function emitInstalledLoadFailure(name: string, load: Extract<ToolRuntimeLoad, {
|
|
37
|
+
ok: false;
|
|
38
|
+
}>): void;
|
|
2
39
|
export interface DiscoveryOptions {
|
|
3
40
|
/**
|
|
4
41
|
* Ordered tool-discovery sources (precedence: first wins on duplicate
|
|
@@ -47,45 +84,7 @@ export declare function discoverAndRegisterToolPackages(registry: ToolRegistry,
|
|
|
47
84
|
/**
|
|
48
85
|
* Discover + admit + register AUTHORED Tool sidecars from the two authored
|
|
49
86
|
* roots, then dynamic-import each admitted runtime through the shared
|
|
50
|
-
* `importToolRuntime` seam
|
|
51
|
-
* bundled and installed legs travel (ADR-0027; this is the leg that makes the
|
|
52
|
-
* dormant {@link admitProjectLocalTool} live).
|
|
53
|
-
*
|
|
54
|
-
* Two roots, two trust postures:
|
|
55
|
-
* - **global** (`~/.opensip-cli/tools/`) → {@link admitUserGlobalTool},
|
|
56
|
-
* trusted-by-default.
|
|
57
|
-
* - **project** (`<project>/opensip-cli/tools/`) → {@link admitProjectLocalTool},
|
|
58
|
-
* deny-by-default (allowlist via `OPENSIP_CLI_ALLOW_PROJECT_TOOLS`).
|
|
59
|
-
*
|
|
60
|
-
* Global is processed FIRST so a project-authored tool cannot shadow a same-id
|
|
61
|
-
* global one — matching the `~/.opensip-cli/plugins` precedence note in
|
|
62
|
-
* {@link buildToolDiscoverySources} (first-writer-wins via the registry).
|
|
63
|
-
* `builtInIds` are skipped so an authored tool never shadows a bundled one.
|
|
64
|
-
*
|
|
65
|
-
* **Trust-before-import.** For each candidate, the admit step (which EMBEDS the
|
|
66
|
-
* trust decision — deny-by-default inside `admitProjectLocalTool`) runs to
|
|
67
|
-
* completion BEFORE `importToolRuntime`. A non-allowlisted project tool THROWS
|
|
68
|
-
* `PluginIncompatibleError` (exit 5) here, propagated out of the walk: it must
|
|
69
|
-
* fail the run loudly — that is the clone-protection contract.
|
|
70
|
-
*
|
|
71
|
-
* **Error-posture asymmetry (deliberate).** An un-allowlisted *project* tool is
|
|
72
|
-
* fail-closed by policy (clone-risk; the user must opt in). A *global* tool that
|
|
73
|
-
* fails to load is also fail-closed (the user explicitly authored it into
|
|
74
|
-
* `$HOME`). This differs from the *installed* npm leg, where a stray bad plugin
|
|
75
|
-
* skips-with-diagnostic so it can't take fit/graph/sim down — authored tools are
|
|
76
|
-
* first-party-intent, installed tools are ambient.
|
|
77
|
-
*
|
|
78
|
-
* @param registry The per-invocation tool registry to populate.
|
|
79
|
-
* @param opts.projectAuthoredDir `resolveProjectPaths(root).authoredToolsDir`,
|
|
80
|
-
* or `undefined` when there is no resolvable project context.
|
|
81
|
-
* @param opts.globalAuthoredDir `resolveUserPaths().authoredToolsDir`.
|
|
82
|
-
* @param opts.env Environment carrying the project allowlist (default
|
|
83
|
-
* `process.env`); injectable for tests.
|
|
84
|
-
* @param builtInIds Bundled-tool ids to skip on a name collision.
|
|
85
|
-
* @param provenance Sink for admitted authored tools' provenance records.
|
|
86
|
-
* @param manifests Sink for admitted authored tools' manifests (§5.3).
|
|
87
|
-
* @throws {PluginIncompatibleError} for an un-allowlisted project tool, or any
|
|
88
|
-
* authored tool whose sidecar/runtime is missing/incompatible (fail-closed).
|
|
87
|
+
* `importToolRuntime` seam.
|
|
89
88
|
*/
|
|
90
89
|
export declare function discoverAndRegisterAuthoredTools(registry: ToolRegistry, opts: {
|
|
91
90
|
readonly projectAuthoredDir?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"register-tools-discovery.d.ts","sourceRoot":"","sources":["../../src/bootstrap/register-tools-discovery.ts"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"register-tools-discovery.d.ts","sourceRoot":"","sources":["../../src/bootstrap/register-tools-discovery.ts"],"names":[],"mappings":"AACA;;;;;GAKG;AAEH,OAAO,EAYL,KAAK,kBAAkB,EACvB,KAAK,cAAc,EACnB,KAAK,YAAY,EACjB,KAAK,mBAAmB,EAEzB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAGL,KAAK,eAAe,EACrB,MAAM,yBAAyB,CAAC;AAIjC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAE/D,MAAM,MAAM,iBAAiB,GAAG,aAAa,CAAC;AAsC9C;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE;IAC1C,QAAQ,CAAC,GAAG,EAAE,MAAM,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C,IAAI,CAAC,CAuBf"}
|
|
@@ -1,9 +1,122 @@
|
|
|
1
1
|
// @fitness-ignore-file performance-anti-patterns -- sequential await across discovered tool packages preserves load order for plugin-conflict detection; bounded by installed plugin count
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
/**
|
|
3
|
+
* register-tools-discovery — installed + authored tool admission and discovery.
|
|
4
|
+
*
|
|
5
|
+
* Extracted from register-tools.ts so the bundled registration path stays a
|
|
6
|
+
* focused module under the file-length soft limit.
|
|
7
|
+
*/
|
|
8
|
+
import { admitTool, assertManifestMatchesTool, discoverAuthoredToolSidecars, discoverToolPackagesFromAnchors, logger, PluginIncompatibleError, PROJECT_LOCAL_MANIFEST_FILE, resolveProjectContext, resolveProjectPaths, resolveUserPaths, loadToolManifest, } from '@opensip-cli/core';
|
|
9
|
+
import { hostRuntimeImportPolicyFor, importToolRuntime, } from './admit-tool-package.js';
|
|
10
|
+
import { BOOTSTRAP_MODULE } from './constants.js';
|
|
11
|
+
import { isProjectLocalToolTrusted } from './tool-trust.js';
|
|
12
|
+
/**
|
|
13
|
+
* The shared admission tail for both authored sources. When `preloadedManifest`
|
|
14
|
+
* is supplied we use that snapshot so the trust decision and compatibility gate
|
|
15
|
+
* see the identical declaration.
|
|
16
|
+
*
|
|
17
|
+
* @throws {PluginIncompatibleError} When the sidecar manifest is missing,
|
|
18
|
+
* malformed, or rejected by the compatibility gate.
|
|
19
|
+
*/
|
|
20
|
+
function admitAuthoredTool(source, dir, preloadedManifest) {
|
|
21
|
+
const rawManifest = preloadedManifest ?? loadToolManifest(source, dir);
|
|
22
|
+
if (rawManifest === undefined) {
|
|
23
|
+
throw new PluginIncompatibleError(`${source} tool at '${dir}' has no conformant ${PROJECT_LOCAL_MANIFEST_FILE} sidecar`, { diagnostic: 'manifest missing or malformed' });
|
|
24
|
+
}
|
|
25
|
+
const result = admitTool({
|
|
26
|
+
manifest: rawManifest,
|
|
27
|
+
source,
|
|
28
|
+
dir,
|
|
29
|
+
explicitlyRequested: true,
|
|
30
|
+
});
|
|
31
|
+
if (result.decision !== 'admit') {
|
|
32
|
+
throw new PluginIncompatibleError(`${source} tool '${rawManifest.id}' is incompatible: ${result.diagnostic ?? 'compatibility gate rejected it'}`, { diagnostic: result.diagnostic });
|
|
33
|
+
}
|
|
34
|
+
return { provenance: result.provenance, manifest: result.manifest };
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Admit or reject a PROJECT-LOCAL authored tool under the deny-by-default trust
|
|
38
|
+
* policy. The trust decision always precedes module import; a non-allowlisted
|
|
39
|
+
* tool fails closed before any authored code can run.
|
|
40
|
+
*
|
|
41
|
+
* @throws {PluginIncompatibleError} When the sidecar manifest is missing,
|
|
42
|
+
* malformed, incompatible, or not trusted by the project-tool allowlist.
|
|
43
|
+
*/
|
|
44
|
+
export function admitProjectLocalTool(args) {
|
|
45
|
+
const manifest = loadToolManifest('project-local', args.dir);
|
|
46
|
+
if (manifest === undefined) {
|
|
47
|
+
throw new PluginIncompatibleError(`project-local tool at '${args.dir}' has no conformant ${PROJECT_LOCAL_MANIFEST_FILE} sidecar`, { diagnostic: 'manifest missing or malformed' });
|
|
48
|
+
}
|
|
49
|
+
if (!isProjectLocalToolTrusted(manifest.id, args.env)) {
|
|
50
|
+
throw new PluginIncompatibleError(`project-local tool '${manifest.id}' is not trusted to load (deny-by-default). ` +
|
|
51
|
+
`Allowlist it via OPENSIP_CLI_ALLOW_PROJECT_TOOLS='${manifest.id}' to admit it.`, { diagnostic: 'project-local tool not allowlisted (deny-by-default)' });
|
|
52
|
+
}
|
|
53
|
+
return admitAuthoredTool('project-local', args.dir, manifest);
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Admit a USER-GLOBAL authored tool — trusted-by-default because the user placed
|
|
57
|
+
* it in their own home-dir tool host, but still fail-closed on a missing or
|
|
58
|
+
* incompatible manifest.
|
|
59
|
+
*/
|
|
60
|
+
export function admitUserGlobalTool(args) {
|
|
61
|
+
return admitAuthoredTool('user-global', args.dir);
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Run the admission gate over a discovered INSTALLED tool package before its
|
|
65
|
+
* module is imported. Installed tools are best-effort: incompatible or malformed
|
|
66
|
+
* ambient packages skip with diagnostics rather than crashing unrelated commands.
|
|
67
|
+
*/
|
|
68
|
+
function admitInstalledTool(pkg, builtInIds) {
|
|
69
|
+
const manifest = loadToolManifest('installed', pkg.packageDir);
|
|
70
|
+
if (manifest === undefined) {
|
|
71
|
+
process.stderr.write(`opensip: tool package ${pkg.name} has no conformant package.json#opensipTools manifest — skipping\n`);
|
|
72
|
+
logger.warn({
|
|
73
|
+
evt: 'cli.tool.manifest_invalid',
|
|
74
|
+
module: BOOTSTRAP_MODULE,
|
|
75
|
+
name: pkg.name,
|
|
76
|
+
});
|
|
77
|
+
return undefined;
|
|
78
|
+
}
|
|
79
|
+
if (builtInIds.has(manifest.id))
|
|
80
|
+
return undefined;
|
|
81
|
+
const result = admitTool({
|
|
82
|
+
manifest,
|
|
83
|
+
source: 'installed',
|
|
84
|
+
dir: pkg.packageDir,
|
|
85
|
+
packageName: pkg.name,
|
|
86
|
+
explicitlyRequested: false,
|
|
87
|
+
});
|
|
88
|
+
if (result.decision !== 'admit')
|
|
89
|
+
return undefined;
|
|
90
|
+
return { provenance: result.provenance, manifest: result.manifest };
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Emit the best-effort stderr line + structured warning for a discovered
|
|
94
|
+
* INSTALLED tool whose runtime failed to load. Each failure reason maps to its
|
|
95
|
+
* own diagnostic while preserving the installed leg's skip-not-crash posture.
|
|
96
|
+
*/
|
|
97
|
+
export function emitInstalledLoadFailure(name, load) {
|
|
98
|
+
if (load.reason === 'no-entry') {
|
|
99
|
+
process.stderr.write(`opensip: tool package ${name} has no resolvable entry point — skipping\n`);
|
|
100
|
+
logger.warn({ evt: 'cli.tool.no_entry', module: BOOTSTRAP_MODULE, name });
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
if (load.reason === 'invalid-shape') {
|
|
104
|
+
process.stderr.write(`opensip: tool package ${name} does not export a valid \`tool\` — skipping\n`);
|
|
105
|
+
logger.warn({
|
|
106
|
+
evt: 'cli.tool.invalid_shape',
|
|
107
|
+
module: BOOTSTRAP_MODULE,
|
|
108
|
+
name,
|
|
109
|
+
});
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
process.stderr.write(`opensip: failed to load tool ${name}: ${load.detail ?? 'import failed'}\n`);
|
|
113
|
+
logger.warn({
|
|
114
|
+
evt: 'cli.tool.load_failed',
|
|
115
|
+
module: BOOTSTRAP_MODULE,
|
|
116
|
+
name,
|
|
117
|
+
error: load.detail,
|
|
118
|
+
});
|
|
119
|
+
}
|
|
7
120
|
/**
|
|
8
121
|
* Build the ordered tool-discovery sources. Order is precedence
|
|
9
122
|
* (first-occurrence-wins on duplicate name):
|
|
@@ -58,42 +171,33 @@ export function buildToolDiscoverySources(cwd, cliInstallDir) {
|
|
|
58
171
|
* @param provenance Optional sink for admitted tools' provenance records.
|
|
59
172
|
*/
|
|
60
173
|
export async function discoverAndRegisterToolPackages(registry, opts, builtInIds, provenance = [], manifests = []) {
|
|
61
|
-
// `builtInIds` is the set of already-registered bundled-tool *human ids* (manifest.id)
|
|
62
|
-
// to skip on a name collision (launch — passed explicitly by the composition root, which
|
|
63
|
-
// derives it from the bundled MANIFESTS it just loaded; compare against runtime
|
|
64
|
-
// metadata.name for the human key).
|
|
65
174
|
const discovered = discoverToolPackagesFromAnchors(opts.sources);
|
|
175
|
+
// Stable-UUID collision guard (ADR-0048): a discovered package whose runtime
|
|
176
|
+
// `metadata.id` (the stable UUID) is already registered is the SAME tool
|
|
177
|
+
// re-discovered via a stray anchor — e.g. a second copy of `@opensip-cli/*`
|
|
178
|
+
// in a node_modules ABOVE the project root. The human-name skip alone misses
|
|
179
|
+
// it when the two copies disagree on `metadata.name` (e.g. one built before
|
|
180
|
+
// the verb-rename), which would otherwise double-register and trip the
|
|
181
|
+
// session-replay duplicate guard. UUID is identity; skip on a UUID match.
|
|
182
|
+
const registeredStableIds = new Set(registry.list().map((t) => t.metadata.id));
|
|
66
183
|
for (const pkg of discovered) {
|
|
67
184
|
try {
|
|
68
|
-
// Compatibility gate BEFORE import (launch). `undefined` means the
|
|
69
|
-
// gate skipped it (or it's a built-in id); an admission means import +
|
|
70
|
-
// register as before.
|
|
71
185
|
const admission = admitInstalledTool(pkg, builtInIds);
|
|
72
186
|
if (admission === undefined)
|
|
73
187
|
continue;
|
|
74
|
-
// Load the runtime through the SHARED dynamic-import path (launch) — the
|
|
75
|
-
// same `importToolRuntime` the bundled path uses. Resolves the entry
|
|
76
|
-
// from `packageDir` so a tool living in a host dir off the CLI's own
|
|
77
|
-
// module-resolution path still loads. An installed tool is best-effort:
|
|
78
|
-
// any load failure skips-with-diagnostic (it must not take fit/graph/sim
|
|
79
|
-
// down), in contrast to the bundled path's fail-closed.
|
|
80
188
|
const load = await importToolRuntime(pkg.packageDir, hostRuntimeImportPolicyFor('installed'));
|
|
81
189
|
if (!load.ok) {
|
|
82
190
|
emitInstalledLoadFailure(pkg.name, load);
|
|
83
191
|
continue;
|
|
84
192
|
}
|
|
85
|
-
// builtInIds holds human ids (from bundled manifests); compare against runtime human name
|
|
86
193
|
if (builtInIds.has(load.tool.metadata.name ?? load.tool.metadata.id))
|
|
87
194
|
continue;
|
|
88
|
-
//
|
|
89
|
-
//
|
|
90
|
-
|
|
195
|
+
// Stable-UUID collision (see above): the same tool already registered
|
|
196
|
+
// under a possibly-different human name. Skip the re-discovered copy.
|
|
197
|
+
if (registeredStableIds.has(load.tool.metadata.id))
|
|
198
|
+
continue;
|
|
91
199
|
assertManifestMatchesTool(admission.manifest, load.tool);
|
|
92
200
|
registry.register(load.tool, { sourcePackage: pkg.name });
|
|
93
|
-
// Record provenance + manifest only now that the tool actually
|
|
94
|
-
// registered — `plugin list` and the per-run capability registry must
|
|
95
|
-
// never include a tool whose runtime failed to load (parity with the
|
|
96
|
-
// bundled/authored legs, which also record after registration).
|
|
97
201
|
provenance.push(admission.provenance);
|
|
98
202
|
manifests.push(admission.manifest);
|
|
99
203
|
}
|
|
@@ -112,48 +216,9 @@ export async function discoverAndRegisterToolPackages(registry, opts, builtInIds
|
|
|
112
216
|
/**
|
|
113
217
|
* Discover + admit + register AUTHORED Tool sidecars from the two authored
|
|
114
218
|
* roots, then dynamic-import each admitted runtime through the shared
|
|
115
|
-
* `importToolRuntime` seam
|
|
116
|
-
* bundled and installed legs travel (ADR-0027; this is the leg that makes the
|
|
117
|
-
* dormant {@link admitProjectLocalTool} live).
|
|
118
|
-
*
|
|
119
|
-
* Two roots, two trust postures:
|
|
120
|
-
* - **global** (`~/.opensip-cli/tools/`) → {@link admitUserGlobalTool},
|
|
121
|
-
* trusted-by-default.
|
|
122
|
-
* - **project** (`<project>/opensip-cli/tools/`) → {@link admitProjectLocalTool},
|
|
123
|
-
* deny-by-default (allowlist via `OPENSIP_CLI_ALLOW_PROJECT_TOOLS`).
|
|
124
|
-
*
|
|
125
|
-
* Global is processed FIRST so a project-authored tool cannot shadow a same-id
|
|
126
|
-
* global one — matching the `~/.opensip-cli/plugins` precedence note in
|
|
127
|
-
* {@link buildToolDiscoverySources} (first-writer-wins via the registry).
|
|
128
|
-
* `builtInIds` are skipped so an authored tool never shadows a bundled one.
|
|
129
|
-
*
|
|
130
|
-
* **Trust-before-import.** For each candidate, the admit step (which EMBEDS the
|
|
131
|
-
* trust decision — deny-by-default inside `admitProjectLocalTool`) runs to
|
|
132
|
-
* completion BEFORE `importToolRuntime`. A non-allowlisted project tool THROWS
|
|
133
|
-
* `PluginIncompatibleError` (exit 5) here, propagated out of the walk: it must
|
|
134
|
-
* fail the run loudly — that is the clone-protection contract.
|
|
135
|
-
*
|
|
136
|
-
* **Error-posture asymmetry (deliberate).** An un-allowlisted *project* tool is
|
|
137
|
-
* fail-closed by policy (clone-risk; the user must opt in). A *global* tool that
|
|
138
|
-
* fails to load is also fail-closed (the user explicitly authored it into
|
|
139
|
-
* `$HOME`). This differs from the *installed* npm leg, where a stray bad plugin
|
|
140
|
-
* skips-with-diagnostic so it can't take fit/graph/sim down — authored tools are
|
|
141
|
-
* first-party-intent, installed tools are ambient.
|
|
142
|
-
*
|
|
143
|
-
* @param registry The per-invocation tool registry to populate.
|
|
144
|
-
* @param opts.projectAuthoredDir `resolveProjectPaths(root).authoredToolsDir`,
|
|
145
|
-
* or `undefined` when there is no resolvable project context.
|
|
146
|
-
* @param opts.globalAuthoredDir `resolveUserPaths().authoredToolsDir`.
|
|
147
|
-
* @param opts.env Environment carrying the project allowlist (default
|
|
148
|
-
* `process.env`); injectable for tests.
|
|
149
|
-
* @param builtInIds Bundled-tool ids to skip on a name collision.
|
|
150
|
-
* @param provenance Sink for admitted authored tools' provenance records.
|
|
151
|
-
* @param manifests Sink for admitted authored tools' manifests (§5.3).
|
|
152
|
-
* @throws {PluginIncompatibleError} for an un-allowlisted project tool, or any
|
|
153
|
-
* authored tool whose sidecar/runtime is missing/incompatible (fail-closed).
|
|
219
|
+
* `importToolRuntime` seam.
|
|
154
220
|
*/
|
|
155
221
|
export async function discoverAndRegisterAuthoredTools(registry, opts, builtInIds, provenance = [], manifests = []) {
|
|
156
|
-
// Global FIRST (trusted-by-default), then project (deny-by-default).
|
|
157
222
|
for (const candidate of discoverAuthoredToolSidecars(opts.globalAuthoredDir)) {
|
|
158
223
|
await admitAndRegisterAuthored({
|
|
159
224
|
registry,
|
|
@@ -166,8 +231,6 @@ export async function discoverAndRegisterAuthoredTools(registry, opts, builtInId
|
|
|
166
231
|
}
|
|
167
232
|
if (opts.projectAuthoredDir !== undefined) {
|
|
168
233
|
for (const candidate of discoverAuthoredToolSidecars(opts.projectAuthoredDir)) {
|
|
169
|
-
// admitProjectLocalTool embeds the deny-by-default trust gate; a
|
|
170
|
-
// non-allowlisted tool THROWS here, BEFORE importToolRuntime below.
|
|
171
234
|
await admitAndRegisterAuthored({
|
|
172
235
|
registry,
|
|
173
236
|
admission: admitProjectLocalTool({ dir: candidate.dir, env: opts.env }),
|
|
@@ -179,22 +242,10 @@ export async function discoverAndRegisterAuthoredTools(registry, opts, builtInId
|
|
|
179
242
|
}
|
|
180
243
|
}
|
|
181
244
|
}
|
|
182
|
-
/**
|
|
183
|
-
* Shared register-step for an already-ADMITTED authored tool: skip a
|
|
184
|
-
* built-in-id collision, dynamic-import the runtime (fail-closed on failure —
|
|
185
|
-
* an authored tool is first-party-intent), run the manifest⇔runtime drift
|
|
186
|
-
* guard, register, and record provenance + manifest. Admission (incl. the trust
|
|
187
|
-
* decision) has already happened by the time this is called — so import here
|
|
188
|
-
* never precedes a trust decision.
|
|
189
|
-
*
|
|
190
|
-
* @throws {PluginIncompatibleError} when the authored tool's runtime fails to
|
|
191
|
-
* load via the plugin path — an authored tool is first-party-intent, so a
|
|
192
|
-
* load failure is fail-closed (surfaced), never silently skipped.
|
|
193
|
-
*/
|
|
245
|
+
/** @throws {PluginIncompatibleError} When the authored tool runtime fails to load. */
|
|
194
246
|
async function admitAndRegisterAuthored(args) {
|
|
195
247
|
const { registry, admission, dir, builtInIds, provenance, manifests } = args;
|
|
196
248
|
const { provenance: prov, manifest } = admission;
|
|
197
|
-
// Never shadow a bundled tool (defense in depth; the registry also dedupes).
|
|
198
249
|
if (builtInIds.has(prov.id))
|
|
199
250
|
return;
|
|
200
251
|
const load = await importToolRuntime(dir, hostRuntimeImportPolicyFor(prov.source));
|
|
@@ -202,8 +253,6 @@ async function admitAndRegisterAuthored(args) {
|
|
|
202
253
|
const detailSuffix = load.detail ? `: ${load.detail}` : '';
|
|
203
254
|
throw new PluginIncompatibleError(`${prov.source} tool '${prov.id}' failed to load via the plugin path (${load.reason}${detailSuffix})`, { diagnostic: `authored tool runtime load failed: ${load.reason}` });
|
|
204
255
|
}
|
|
205
|
-
// Drift guard: the static sidecar and the runtime tool are two declarations
|
|
206
|
-
// of the same identity — catch a sidecar that fell out of sync.
|
|
207
256
|
assertManifestMatchesTool(manifest, load.tool);
|
|
208
257
|
registry.register(load.tool);
|
|
209
258
|
provenance.push(prov);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"register-tools-discovery.js","sourceRoot":"","sources":["../../src/bootstrap/register-tools-discovery.ts"],"names":[],"mappings":"AAAA,2LAA2L;AAC3L,OAAO,EACL,yBAAyB,EACzB,4BAA4B,EAC5B,+BAA+B,EAC/B,MAAM,EACN,uBAAuB,EACvB,qBAAqB,EACrB,mBAAmB,EACnB,gBAAgB,
|
|
1
|
+
{"version":3,"file":"register-tools-discovery.js","sourceRoot":"","sources":["../../src/bootstrap/register-tools-discovery.ts"],"names":[],"mappings":"AAAA,2LAA2L;AAC3L;;;;;GAKG;AAEH,OAAO,EACL,SAAS,EACT,yBAAyB,EACzB,4BAA4B,EAC5B,+BAA+B,EAC/B,MAAM,EACN,uBAAuB,EACvB,2BAA2B,EAC3B,qBAAqB,EACrB,mBAAmB,EACnB,gBAAgB,EAChB,gBAAgB,GAMjB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EACL,0BAA0B,EAC1B,iBAAiB,GAElB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,yBAAyB,EAAE,MAAM,iBAAiB,CAAC;AAM5D;;;;;;;GAOG;AACH,SAAS,iBAAiB,CACxB,MAAkB,EAClB,GAAW,EACX,iBAAuD;IAEvD,MAAM,WAAW,GAAG,iBAAiB,IAAI,gBAAgB,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IACvE,IAAI,WAAW,KAAK,SAAS,EAAE,CAAC;QAC9B,MAAM,IAAI,uBAAuB,CAC/B,GAAG,MAAM,aAAa,GAAG,uBAAuB,2BAA2B,UAAU,EACrF,EAAE,UAAU,EAAE,+BAA+B,EAAE,CAChD,CAAC;IACJ,CAAC;IAED,MAAM,MAAM,GAAG,SAAS,CAAC;QACvB,QAAQ,EAA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EAAE,UAAU,EAAE,sCAAsC,IAAI,CAAC,MAAM,EAAE,EAAE,CACpE,CAAC;IACJ,CAAC;IAED,yBAAyB,CAAC,QAAQ,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;IAE/C,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC7B,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACtB,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;AAC3B,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type CliProgram } from '@opensip-cli/contracts';
|
|
2
|
-
import { type ToolCliContext, type ToolRegistry } from '@opensip-cli/core';
|
|
2
|
+
import { type Tool, type ToolCliContext, type ToolRegistry } from '@opensip-cli/core';
|
|
3
3
|
/**
|
|
4
4
|
* Walk the registry and mount each tool's commands onto `program`. This is
|
|
5
5
|
* **step 8** of the tool lifecycle (launch, §5.4) — see
|
|
@@ -22,4 +22,21 @@ import { type ToolCliContext, type ToolRegistry } from '@opensip-cli/core';
|
|
|
22
22
|
* @param ctx The per-invocation handler context (render/emit/scope — no program).
|
|
23
23
|
*/
|
|
24
24
|
export declare function mountAllToolCommands(registry: ToolRegistry, program: CliProgram, ctx: ToolCliContext): void;
|
|
25
|
+
/**
|
|
26
|
+
* Mount ONE tool's commands from its declared `commandSpecs` — the only command
|
|
27
|
+
* surface (public launch). Extracted so {@link mountAllToolCommands} keeps its
|
|
28
|
+
* per-tool failure isolation around a single call. A tool with no `commandSpecs`
|
|
29
|
+
* contributes nothing and is surfaced via `cli.tool.no_command_surface`.
|
|
30
|
+
*
|
|
31
|
+
* Nesting (`CommandSpec.parent`, tool-command-surface-taxonomy Task 0.4): a spec
|
|
32
|
+
* declaring `parent` is mounted as a SUBCOMMAND of the same-tool spec whose name
|
|
33
|
+
* matches `parent` (the tool's primary verb) — enabling the `<tool> <verb>`
|
|
34
|
+
* grammar (`graph export`, `fit list`). This is the SAME generic parent+leaf
|
|
35
|
+
* pattern the host already uses for `sessions`/`plugin`/`tools`
|
|
36
|
+
* (`host-command-specs.ts:mountHostCommands`): the parent's mounted Commander
|
|
37
|
+
* command (which also carries its own action) hosts the child via
|
|
38
|
+
* `mountCommandSpec(primaryCmd, child, ctx)`. No per-tool special case. Specs
|
|
39
|
+
* with no `parent` mount flat onto the root program exactly as before.
|
|
40
|
+
*/
|
|
41
|
+
export declare function mountOneTool(program: CliProgram, tool: Tool, ctx: ToolCliContext): void;
|
|
25
42
|
//# sourceMappingURL=register-tools-mount.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"register-tools-mount.d.ts","sourceRoot":"","sources":["../../src/bootstrap/register-tools-mount.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,
|
|
1
|
+
{"version":3,"file":"register-tools-mount.d.ts","sourceRoot":"","sources":["../../src/bootstrap/register-tools-mount.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAU,KAAK,IAAI,EAAE,KAAK,cAAc,EAAE,KAAK,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAY9F;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,oBAAoB,CAClC,QAAQ,EAAE,YAAY,EACtB,OAAO,EAAE,UAAU,EACnB,GAAG,EAAE,cAAc,GAClB,IAAI,CA2BN;AAqCD;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,cAAc,GAAG,IAAI,CA4BvF"}
|