opensip-cli 0.1.5 → 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.
Files changed (229) hide show
  1. package/dist/bootstrap/admit-tool-package.d.ts +15 -1
  2. package/dist/bootstrap/admit-tool-package.d.ts.map +1 -1
  3. package/dist/bootstrap/admit-tool-package.js +30 -5
  4. package/dist/bootstrap/admit-tool-package.js.map +1 -1
  5. package/dist/bootstrap/bind-tool-context.d.ts.map +1 -1
  6. package/dist/bootstrap/bind-tool-context.js +5 -3
  7. package/dist/bootstrap/bind-tool-context.js.map +1 -1
  8. package/dist/bootstrap/build-command-registration-input.d.ts +7 -0
  9. package/dist/bootstrap/build-command-registration-input.d.ts.map +1 -1
  10. package/dist/bootstrap/build-command-registration-input.js +11 -4
  11. package/dist/bootstrap/build-command-registration-input.js.map +1 -1
  12. package/dist/bootstrap/build-per-run-scope.d.ts +12 -0
  13. package/dist/bootstrap/build-per-run-scope.d.ts.map +1 -1
  14. package/dist/bootstrap/build-per-run-scope.js +84 -9
  15. package/dist/bootstrap/build-per-run-scope.js.map +1 -1
  16. package/dist/bootstrap/bundled-manifest.d.ts +5 -0
  17. package/dist/bootstrap/bundled-manifest.d.ts.map +1 -0
  18. package/dist/bootstrap/bundled-manifest.js +13 -0
  19. package/dist/bootstrap/bundled-manifest.js.map +1 -0
  20. package/dist/bootstrap/bundled-tools.manifest.json +19 -1
  21. package/dist/bootstrap/config-and-capabilities.d.ts +5 -3
  22. package/dist/bootstrap/config-and-capabilities.d.ts.map +1 -1
  23. package/dist/bootstrap/config-and-capabilities.js +10 -7
  24. package/dist/bootstrap/config-and-capabilities.js.map +1 -1
  25. package/dist/bootstrap/constants.d.ts +3 -0
  26. package/dist/bootstrap/constants.d.ts.map +1 -0
  27. package/dist/bootstrap/constants.js +3 -0
  28. package/dist/bootstrap/constants.js.map +1 -0
  29. package/dist/bootstrap/decorate-tool-primary.d.ts +50 -0
  30. package/dist/bootstrap/decorate-tool-primary.d.ts.map +1 -0
  31. package/dist/bootstrap/decorate-tool-primary.js +111 -0
  32. package/dist/bootstrap/decorate-tool-primary.js.map +1 -0
  33. package/dist/bootstrap/execute-post-bailout-bootstrap.d.ts +1 -0
  34. package/dist/bootstrap/execute-post-bailout-bootstrap.d.ts.map +1 -1
  35. package/dist/bootstrap/execute-post-bailout-bootstrap.js +12 -1
  36. package/dist/bootstrap/execute-post-bailout-bootstrap.js.map +1 -1
  37. package/dist/bootstrap/index.d.ts +1 -1
  38. package/dist/bootstrap/index.d.ts.map +1 -1
  39. package/dist/bootstrap/index.js +1 -4
  40. package/dist/bootstrap/index.js.map +1 -1
  41. package/dist/bootstrap/io-plane.d.ts +47 -0
  42. package/dist/bootstrap/io-plane.d.ts.map +1 -0
  43. package/dist/bootstrap/io-plane.js +73 -0
  44. package/dist/bootstrap/io-plane.js.map +1 -0
  45. package/dist/bootstrap/load-tool-capabilities.d.ts.map +1 -1
  46. package/dist/bootstrap/load-tool-capabilities.js +18 -2
  47. package/dist/bootstrap/load-tool-capabilities.js.map +1 -1
  48. package/dist/bootstrap/owning-tool-init.d.ts.map +1 -1
  49. package/dist/bootstrap/owning-tool-init.js +7 -4
  50. package/dist/bootstrap/owning-tool-init.js.map +1 -1
  51. package/dist/bootstrap/phase-map.d.ts +20 -0
  52. package/dist/bootstrap/phase-map.d.ts.map +1 -0
  53. package/dist/bootstrap/phase-map.js +108 -0
  54. package/dist/bootstrap/phase-map.js.map +1 -0
  55. package/dist/bootstrap/plan-pre-action-bootstrap.d.ts +5 -5
  56. package/dist/bootstrap/plan-pre-action-bootstrap.d.ts.map +1 -1
  57. package/dist/bootstrap/plan-pre-action-bootstrap.js +3 -19
  58. package/dist/bootstrap/plan-pre-action-bootstrap.js.map +1 -1
  59. package/dist/bootstrap/pre-action-guards.d.ts +2 -1
  60. package/dist/bootstrap/pre-action-guards.d.ts.map +1 -1
  61. package/dist/bootstrap/pre-action-guards.js +3 -27
  62. package/dist/bootstrap/pre-action-guards.js.map +1 -1
  63. package/dist/bootstrap/pre-action-hook.d.ts +2 -1
  64. package/dist/bootstrap/pre-action-hook.d.ts.map +1 -1
  65. package/dist/bootstrap/pre-action-hook.js +23 -4
  66. package/dist/bootstrap/pre-action-hook.js.map +1 -1
  67. package/dist/bootstrap/register-tools-discovery.d.ts +38 -39
  68. package/dist/bootstrap/register-tools-discovery.d.ts.map +1 -1
  69. package/dist/bootstrap/register-tools-discovery.js +134 -85
  70. package/dist/bootstrap/register-tools-discovery.js.map +1 -1
  71. package/dist/bootstrap/register-tools-mount.d.ts +18 -1
  72. package/dist/bootstrap/register-tools-mount.d.ts.map +1 -1
  73. package/dist/bootstrap/register-tools-mount.js +118 -18
  74. package/dist/bootstrap/register-tools-mount.js.map +1 -1
  75. package/dist/bootstrap/register-tools.d.ts +58 -14
  76. package/dist/bootstrap/register-tools.d.ts.map +1 -1
  77. package/dist/bootstrap/register-tools.js +185 -14
  78. package/dist/bootstrap/register-tools.js.map +1 -1
  79. package/dist/bootstrap/root-version.d.ts +26 -0
  80. package/dist/bootstrap/root-version.d.ts.map +1 -0
  81. package/dist/bootstrap/root-version.js +36 -0
  82. package/dist/bootstrap/root-version.js.map +1 -0
  83. package/dist/bootstrap/scope-access.d.ts +11 -0
  84. package/dist/bootstrap/scope-access.d.ts.map +1 -1
  85. package/dist/bootstrap/scope-access.js +26 -0
  86. package/dist/bootstrap/scope-access.js.map +1 -1
  87. package/dist/bootstrap/tool-lifecycle.d.ts +0 -22
  88. package/dist/bootstrap/tool-lifecycle.d.ts.map +1 -1
  89. package/dist/bootstrap/tool-lifecycle.js +0 -23
  90. package/dist/bootstrap/tool-lifecycle.js.map +1 -1
  91. package/dist/bootstrap/validate-tool.d.ts +10 -4
  92. package/dist/bootstrap/validate-tool.d.ts.map +1 -1
  93. package/dist/bootstrap/validate-tool.js +76 -22
  94. package/dist/bootstrap/validate-tool.js.map +1 -1
  95. package/dist/cli-context.d.ts +2 -2
  96. package/dist/cli-context.d.ts.map +1 -1
  97. package/dist/cli-context.js +20 -35
  98. package/dist/cli-context.js.map +1 -1
  99. package/dist/commands/agent-catalog.d.ts +29 -0
  100. package/dist/commands/agent-catalog.d.ts.map +1 -1
  101. package/dist/commands/agent-catalog.js +77 -36
  102. package/dist/commands/agent-catalog.js.map +1 -1
  103. package/dist/commands/clear.d.ts.map +1 -1
  104. package/dist/commands/clear.js +0 -1
  105. package/dist/commands/clear.js.map +1 -1
  106. package/dist/commands/command-scope-index.d.ts +45 -0
  107. package/dist/commands/command-scope-index.d.ts.map +1 -0
  108. package/dist/commands/command-scope-index.js +51 -0
  109. package/dist/commands/command-scope-index.js.map +1 -0
  110. package/dist/commands/completion.d.ts +67 -6
  111. package/dist/commands/completion.d.ts.map +1 -1
  112. package/dist/commands/completion.js +84 -12
  113. package/dist/commands/completion.js.map +1 -1
  114. package/dist/commands/configure.d.ts.map +1 -1
  115. package/dist/commands/configure.js +0 -1
  116. package/dist/commands/configure.js.map +1 -1
  117. package/dist/commands/host-command-specs.d.ts +16 -9
  118. package/dist/commands/host-command-specs.d.ts.map +1 -1
  119. package/dist/commands/host-command-specs.js +47 -21
  120. package/dist/commands/host-command-specs.js.map +1 -1
  121. package/dist/commands/host-config-flag.d.ts +21 -0
  122. package/dist/commands/host-config-flag.d.ts.map +1 -0
  123. package/dist/commands/host-config-flag.js +21 -0
  124. package/dist/commands/host-config-flag.js.map +1 -0
  125. package/dist/commands/host-subcommand-groups.d.ts +46 -5
  126. package/dist/commands/host-subcommand-groups.d.ts.map +1 -1
  127. package/dist/commands/host-subcommand-groups.js +97 -65
  128. package/dist/commands/host-subcommand-groups.js.map +1 -1
  129. package/dist/commands/index.d.ts +1 -1
  130. package/dist/commands/index.js +1 -1
  131. package/dist/commands/internal-command-visibility.d.ts +42 -0
  132. package/dist/commands/internal-command-visibility.d.ts.map +1 -0
  133. package/dist/commands/internal-command-visibility.js +54 -0
  134. package/dist/commands/internal-command-visibility.js.map +1 -0
  135. package/dist/commands/mount-command-action.d.ts +24 -0
  136. package/dist/commands/mount-command-action.d.ts.map +1 -0
  137. package/dist/commands/mount-command-action.js +78 -0
  138. package/dist/commands/mount-command-action.js.map +1 -0
  139. package/dist/commands/mount-command-spec-wiring.d.ts +24 -0
  140. package/dist/commands/mount-command-spec-wiring.d.ts.map +1 -0
  141. package/dist/commands/mount-command-spec-wiring.js +71 -0
  142. package/dist/commands/mount-command-spec-wiring.js.map +1 -0
  143. package/dist/commands/mount-command-spec.d.ts +9 -2
  144. package/dist/commands/mount-command-spec.d.ts.map +1 -1
  145. package/dist/commands/mount-command-spec.js +11 -135
  146. package/dist/commands/mount-command-spec.js.map +1 -1
  147. package/dist/commands/plugin/domain-resolution.d.ts +12 -13
  148. package/dist/commands/plugin/domain-resolution.d.ts.map +1 -1
  149. package/dist/commands/plugin/domain-resolution.js +12 -58
  150. package/dist/commands/plugin/domain-resolution.js.map +1 -1
  151. package/dist/commands/plugin/host-dir.d.ts +0 -1
  152. package/dist/commands/plugin/host-dir.d.ts.map +1 -1
  153. package/dist/commands/plugin/host-dir.js +1 -1
  154. package/dist/commands/plugin/host-dir.js.map +1 -1
  155. package/dist/commands/plugin.d.ts +20 -14
  156. package/dist/commands/plugin.d.ts.map +1 -1
  157. package/dist/commands/plugin.js +39 -47
  158. package/dist/commands/plugin.js.map +1 -1
  159. package/dist/commands/render-outcome.d.ts.map +1 -1
  160. package/dist/commands/render-outcome.js.map +1 -1
  161. package/dist/commands/shared.d.ts +9 -0
  162. package/dist/commands/shared.d.ts.map +1 -1
  163. package/dist/commands/tools/create.d.ts +11 -0
  164. package/dist/commands/tools/create.d.ts.map +1 -0
  165. package/dist/commands/tools/create.js +84 -0
  166. package/dist/commands/tools/create.js.map +1 -0
  167. package/dist/commands/tools/index.d.ts.map +1 -1
  168. package/dist/commands/tools/index.js +31 -0
  169. package/dist/commands/tools/index.js.map +1 -1
  170. package/dist/commands/tools/runtime-probe-entry.d.ts.map +1 -1
  171. package/dist/commands/tools/runtime-probe-entry.js +4 -2
  172. package/dist/commands/tools/runtime-probe-entry.js.map +1 -1
  173. package/dist/commands/tools/validate.d.ts.map +1 -1
  174. package/dist/commands/tools/validate.js +12 -5
  175. package/dist/commands/tools/validate.js.map +1 -1
  176. package/dist/commands/uninstall.d.ts.map +1 -1
  177. package/dist/commands/uninstall.js +0 -1
  178. package/dist/commands/uninstall.js.map +1 -1
  179. package/dist/env/host-env-specs.d.ts +18 -0
  180. package/dist/env/host-env-specs.d.ts.map +1 -1
  181. package/dist/env/host-env-specs.js +36 -2
  182. package/dist/env/host-env-specs.js.map +1 -1
  183. package/dist/index.d.ts +1 -1
  184. package/dist/index.d.ts.map +1 -1
  185. package/dist/index.js +46 -21
  186. package/dist/index.js.map +1 -1
  187. package/dist/report-compose.d.ts.map +1 -1
  188. package/dist/report-compose.js +2 -2
  189. package/dist/report-compose.js.map +1 -1
  190. package/dist/session-replay-registry.d.ts +1 -1
  191. package/dist/session-replay-registry.d.ts.map +1 -1
  192. package/dist/session-replay-registry.js +3 -1
  193. package/dist/session-replay-registry.js.map +1 -1
  194. package/dist/ui/result-to-view.d.ts +27 -7
  195. package/dist/ui/result-to-view.d.ts.map +1 -1
  196. package/dist/ui/result-to-view.js +68 -75
  197. package/dist/ui/result-to-view.js.map +1 -1
  198. package/dist/ui/views/misc-views.d.ts.map +1 -1
  199. package/dist/ui/views/misc-views.js +3 -1
  200. package/dist/ui/views/misc-views.js.map +1 -1
  201. package/dist/ui/views/tools-views.d.ts +2 -1
  202. package/dist/ui/views/tools-views.d.ts.map +1 -1
  203. package/dist/ui/views/tools-views.js +21 -0
  204. package/dist/ui/views/tools-views.js.map +1 -1
  205. package/package.json +32 -32
  206. package/dist/bootstrap/authored-tool-admission.d.ts +0 -23
  207. package/dist/bootstrap/authored-tool-admission.d.ts.map +0 -1
  208. package/dist/bootstrap/authored-tool-admission.js +0 -54
  209. package/dist/bootstrap/authored-tool-admission.js.map +0 -1
  210. package/dist/bootstrap/egress-plane.d.ts +0 -22
  211. package/dist/bootstrap/egress-plane.d.ts.map +0 -1
  212. package/dist/bootstrap/egress-plane.js +0 -37
  213. package/dist/bootstrap/egress-plane.js.map +0 -1
  214. package/dist/bootstrap/installed-tool-admission.d.ts +0 -20
  215. package/dist/bootstrap/installed-tool-admission.d.ts.map +0 -1
  216. package/dist/bootstrap/installed-tool-admission.js +0 -60
  217. package/dist/bootstrap/installed-tool-admission.js.map +0 -1
  218. package/dist/bootstrap/live-plane.d.ts +0 -51
  219. package/dist/bootstrap/live-plane.d.ts.map +0 -1
  220. package/dist/bootstrap/live-plane.js +0 -72
  221. package/dist/bootstrap/live-plane.js.map +0 -1
  222. package/dist/bootstrap/register-tools-bundled.d.ts +0 -28
  223. package/dist/bootstrap/register-tools-bundled.d.ts.map +0 -1
  224. package/dist/bootstrap/register-tools-bundled.js +0 -107
  225. package/dist/bootstrap/register-tools-bundled.js.map +0 -1
  226. package/dist/bootstrap/register-tools-shared.d.ts +0 -40
  227. package/dist/bootstrap/register-tools-shared.d.ts.map +0 -1
  228. package/dist/bootstrap/register-tools-shared.js +0 -98
  229. package/dist/bootstrap/register-tools-shared.js.map +0 -1
@@ -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
- import { assertManifestMatchesTool, discoverAuthoredToolSidecars, discoverToolPackagesFromAnchors, logger, PluginIncompatibleError, resolveProjectContext, resolveProjectPaths, resolveUserPaths, } from '@opensip-cli/core';
3
- import { importToolRuntime } from './admit-tool-package.js';
4
- import { admitProjectLocalTool, admitUserGlobalTool, } from './authored-tool-admission.js';
5
- import { admitInstalledTool, emitInstalledLoadFailure } from './installed-tool-admission.js';
6
- import { BOOTSTRAP_MODULE } from './register-tools-shared.js';
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
- const load = await importToolRuntime(pkg.packageDir);
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
- // Drift guard the SAME manifest⇔runtime identity check the bundled and
89
- // authored legs run. For an installed tool a mismatch throws into the
90
- // surrounding catch (skip-with-diagnostic posture), never crashing the CLI.
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 — the same admit → import → register path the
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,31 +242,17 @@ 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
- const load = await importToolRuntime(dir);
251
+ const load = await importToolRuntime(dir, hostRuntimeImportPolicyFor(prov.source));
201
252
  if (!load.ok) {
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,GAKjB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EACL,qBAAqB,EACrB,mBAAmB,GAEpB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,kBAAkB,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AAC7F,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAY9D;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,yBAAyB,CACvC,GAAW,EACX,aAAqB;IAErB,MAAM,OAAO,GAA0B,EAAE,CAAC;IAC1C,IAAI,CAAC;QACH,MAAM,OAAO,GAAG,qBAAqB,CAAC,EAAE,GAAG,EAAE,WAAW,EAAE,KAAK,EAAE,CAAC,CAAC;QACnE,IAAI,OAAO,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;YAChC,OAAO,CAAC,IAAI,CAAC;gBACX,GAAG,EAAE,mBAAmB,CAAC,OAAO,CAAC,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AE,EAAE,CAAC;QACb,MAAM,YAAY,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC3D,MAAM,IAAI,uBAAuB,CAC/B,GAAG,IAAI,CAAC,MAAM,UAAU,IAAI,CAAC,EAAE,yCAAyC,IAAI,CAAC,MAAM,GAAG,YAAY,GAAG,EACrG,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,EAAqB,KAAK,cAAc,EAAE,KAAK,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAO9F;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,oBAAoB,CAClC,QAAQ,EAAE,YAAY,EACtB,OAAO,EAAE,UAAU,EACnB,GAAG,EAAE,cAAc,GAClB,IAAI,CAqBN"}
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"}
@@ -1,7 +1,9 @@
1
1
  import { logger } from '@opensip-cli/core';
2
+ import { internalCommandNames, showInternalCommands, } from '../commands/internal-command-visibility.js';
2
3
  import { mountCommandSpec } from '../commands/mount-command-spec.js';
3
4
  import { bindToolCliContext } from './bind-tool-context.js';
4
- import { BOOTSTRAP_MODULE } from './register-tools-shared.js';
5
+ import { BOOTSTRAP_MODULE } from './constants.js';
6
+ import { decorateToolPrimary } from './decorate-tool-primary.js';
5
7
  /**
6
8
  * Walk the registry and mount each tool's commands onto `program`. This is
7
9
  * **step 8** of the tool lifecycle (launch, §5.4) — see
@@ -41,37 +43,135 @@ export function mountAllToolCommands(registry, program, ctx) {
41
43
  });
42
44
  }
43
45
  }
46
+ // tool-command-surface-taxonomy Task 1.2: hide Tier-3 internal commands from
47
+ // `--help`. This is the single place that has walked EVERY tool's commands, so
48
+ // the descriptor-driven hide policy lives here (the host owns it; tools never
49
+ // pass a hidden flag). The commands stay mounted + invocable — only their
50
+ // `--help` listing is suppressed. `OPENSIP_CLI_SHOW_INTERNAL=1` reveals them.
51
+ hideInternalCommands(registry, program);
44
52
  // ADR-0021: one shared help shape across every mounted command — uniform
45
53
  // option/subcommand ordering and a docs footer — applied here (the single
46
54
  // place that has walked every tool's commands) rather than per tool.
47
55
  applySharedHelpConfiguration(program);
48
56
  }
57
+ /**
58
+ * Hide every mounted command the tools declared `visibility: 'internal'`
59
+ * (Tier-3) from `--help`, unless `OPENSIP_CLI_SHOW_INTERNAL=1`
60
+ * ({@link showInternalCommands}).
61
+ *
62
+ * Mechanism: Commander omits a command from help when its `_hidden` property is
63
+ * `true`; the command stays fully invocable (`opensip graph-shard-worker <spec>`
64
+ * still runs). That is the documented, minimal "keep the subcommand but hide it"
65
+ * mechanism — there is no post-hoc public `.command(name, desc, { hidden })`
66
+ * path, so we set the property Commander itself reads for help filtering.
67
+ *
68
+ * The internal-name set is descriptor-driven ({@link internalCommandNames}) — the
69
+ * SAME source the completion inventory filters on — so help and completion stay
70
+ * in lockstep. Walks the full command tree (including nested `<tool> <verb>`
71
+ * children) so a future internal nested command is hidden too.
72
+ */
73
+ function hideInternalCommands(registry, program) {
74
+ if (showInternalCommands())
75
+ return; // reveal override — leave everything visible
76
+ const internal = internalCommandNames(registry);
77
+ if (internal.size === 0)
78
+ return;
79
+ const hide = (cmd) => {
80
+ for (const sub of cmd.commands) {
81
+ if (internal.has(sub.name())) {
82
+ // Commander 15 reads `_hidden` when filtering help; setting it true hides
83
+ // the command from `--help` while leaving it invocable. Typed via a
84
+ // narrow structural cast — `_hidden` is Commander-internal, not on the
85
+ // public `Command` type, but it is the property the help renderer reads.
86
+ sub._hidden = true;
87
+ }
88
+ hide(sub);
89
+ }
90
+ };
91
+ hide(program);
92
+ }
49
93
  /**
50
94
  * Mount ONE tool's commands from its declared `commandSpecs` — the only command
51
95
  * surface (public launch). Extracted so {@link mountAllToolCommands} keeps its
52
96
  * per-tool failure isolation around a single call. A tool with no `commandSpecs`
53
97
  * contributes nothing and is surfaced via `cli.tool.no_command_surface`.
98
+ *
99
+ * Nesting (`CommandSpec.parent`, tool-command-surface-taxonomy Task 0.4): a spec
100
+ * declaring `parent` is mounted as a SUBCOMMAND of the same-tool spec whose name
101
+ * matches `parent` (the tool's primary verb) — enabling the `<tool> <verb>`
102
+ * grammar (`graph export`, `fit list`). This is the SAME generic parent+leaf
103
+ * pattern the host already uses for `sessions`/`plugin`/`tools`
104
+ * (`host-command-specs.ts:mountHostCommands`): the parent's mounted Commander
105
+ * command (which also carries its own action) hosts the child via
106
+ * `mountCommandSpec(primaryCmd, child, ctx)`. No per-tool special case. Specs
107
+ * with no `parent` mount flat onto the root program exactly as before.
108
+ */
109
+ export function mountOneTool(program, tool, ctx) {
110
+ if (tool.commandSpecs === undefined || tool.commandSpecs.length === 0) {
111
+ // No declarative command surface — a mis-declared tool contributes no
112
+ // commands. Surface it rather than silently mounting nothing.
113
+ logger.warn({
114
+ evt: 'cli.tool.no_command_surface',
115
+ module: BOOTSTRAP_MODULE,
116
+ toolId: tool.metadata.id, // stable
117
+ toolName: tool.metadata.name ?? tool.metadata.id,
118
+ detail: 'tool declares no commandSpecs; no commands mounted',
119
+ });
120
+ return;
121
+ }
122
+ const toolCtx = bindToolCliContext(tool, ctx);
123
+ const mountedByName = mountFlatSpecs(program, tool, toolCtx);
124
+ // Host-owned uniform decoration of the tool PRIMARY (the flat run command
125
+ // whose name === metadata.name): per-tool `--version`, guaranteed
126
+ // `--cwd`/`--json`/`--config`, and `--quiet`/`--verbose`. Applied ONCE here
127
+ // in the mount layer (not re-declared per tool) and ONLY to the primary —
128
+ // never the nested `<tool> <verb>` children or Tier-3 workers. A tool that
129
+ // declares no primary (its name doesn't match a flat spec) gets no
130
+ // decoration, exactly as before.
131
+ const primaryCmd = mountedByName.get(tool.metadata.name);
132
+ if (primaryCmd !== undefined)
133
+ decorateToolPrimary(primaryCmd, tool);
134
+ mountNestedSpecs(program, tool, toolCtx, mountedByName);
135
+ }
136
+ /**
137
+ * First pass: mount every flat (no-`parent`) spec onto the root program,
138
+ * recording each mounted command by name so nested children can resolve their
139
+ * declared parent. `Tool.commandSpecs` is `CommandSpec<unknown, ToolCliContext>[]`,
140
+ * which is assignable to the mounter's `HostCommandSpec` (handler contravariance).
54
141
  */
55
- function mountOneTool(program, tool, ctx) {
56
- if (tool.commandSpecs !== undefined && tool.commandSpecs.length > 0) {
57
- const toolCtx = bindToolCliContext(tool, ctx);
58
- for (const spec of tool.commandSpecs) {
59
- // `Tool.commandSpecs` is `CommandSpec<unknown, ToolCliContext>[]`, which
60
- // is assignable to the mounter's `HostCommandSpec` (handler contravariance
61
- // — an `unknown`-opts handler accepts a `Record`-opts call). No cast.
142
+ function mountFlatSpecs(program, tool, toolCtx) {
143
+ const mountedByName = new Map();
144
+ for (const spec of tool.commandSpecs ?? []) {
145
+ if (spec.parent !== undefined)
146
+ continue;
147
+ mountedByName.set(spec.name, mountCommandSpec(program, spec, toolCtx));
148
+ }
149
+ return mountedByName;
150
+ }
151
+ /**
152
+ * Second pass: mount each `parent`-nested spec onto its parent's mounted command
153
+ * (the `<tool> <verb>` grammar). A spec whose declared parent was not mounted in
154
+ * this tool is surfaced loudly (and mounted flat at root) rather than silently
155
+ * dropped.
156
+ */
157
+ function mountNestedSpecs(program, tool, toolCtx, mountedByName) {
158
+ for (const spec of tool.commandSpecs ?? []) {
159
+ if (spec.parent === undefined)
160
+ continue;
161
+ const parentCmd = mountedByName.get(spec.parent);
162
+ if (parentCmd === undefined) {
163
+ logger.warn({
164
+ evt: 'cli.tool.unknown_command_parent',
165
+ module: BOOTSTRAP_MODULE,
166
+ toolId: tool.metadata.id, // stable
167
+ toolName: tool.metadata.name ?? tool.metadata.id,
168
+ detail: `command '${spec.name}' declares parent '${spec.parent}', which is not a flat command on this tool; mounting flat at root instead`,
169
+ });
62
170
  mountCommandSpec(program, spec, toolCtx);
171
+ continue;
63
172
  }
64
- return;
173
+ mountCommandSpec(parentCmd, spec, toolCtx);
65
174
  }
66
- // No declarative command surface — a mis-declared tool contributes no commands.
67
- // Surface it rather than silently mounting nothing.
68
- logger.warn({
69
- evt: 'cli.tool.no_command_surface',
70
- module: BOOTSTRAP_MODULE,
71
- toolId: tool.metadata.id, // stable
72
- toolName: tool.metadata.name ?? tool.metadata.id,
73
- detail: 'tool declares no commandSpecs; no commands mounted',
74
- });
75
175
  }
76
176
  const DOCS_HELP_FOOTER = '\nDocs: https://opensip.ai/docs/opensip-cli';
77
177
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"register-tools-mount.js","sourceRoot":"","sources":["../../src/bootstrap/register-tools-mount.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAqD,MAAM,mBAAmB,CAAC;AAE9F,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AAErE,OAAO,EAAE,kBAAkB,EA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M,CAAC,IAAI,CAAC;gBACV,GAAG,EAAE,iCAAiC;gBACtC,MAAM,EAAE,gBAAgB;gBACxB,MAAM,EAAE,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,SAAS;gBACnC,QAAQ,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,IAAI,IAAI,CAAC,QAAQ,CAAC,EAAE;gBAChD,MAAM,EAAE,YAAY,IAAI,CAAC,IAAI,sBAAsB,IAAI,CAAC,MAAM,4EAA4E;aAC3I,CAAC,CAAC;YACH,gBAAgB,CAAC,OAAO,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;YACzC,SAAS;QACX,CAAC;QACD,gBAAgB,CAAC,SAAS,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;IAC7C,CAAC;AACH,CAAC;AAED,MAAM,gBAAgB,GAAG,6CAA6C,CAAC;AAEvE;;;;GAIG;AACH,SAAS,4BAA4B,CAAC,OAAmB;IACvD,MAAM,SAAS,GAAG,CAAC,GAAe,EAAQ,EAAE;QAC1C,GAAG,CAAC,aAAa,CAAC,EAAE,WAAW,EAAE,IAAI,EAAE,eAAe,EAAE,IAAI,EAAE,CAAC,CAAC;QAChE,KAAK,MAAM,GAAG,IAAI,GAAG,CAAC,QAAQ;YAAE,SAAS,CAAC,GAAG,CAAC,CAAC;IACjD,CAAC,CAAC;IACF,SAAS,CAAC,OAAO,CAAC,CAAC;IACnB,OAAO,CAAC,WAAW,CAAC,OAAO,EAAE,gBAAgB,CAAC,CAAC;AACjD,CAAC"}
@@ -1,18 +1,62 @@
1
1
  /**
2
- * register-tools — populate the kernel `ToolRegistry` with first-party
3
- * tools (fitness / simulation / graph) plus any third-party tool
4
- * packages discovered on disk.
2
+ * register-tools — populate the kernel ToolRegistry with bundled, installed,
3
+ * and authored tools (ADR-0027 / ADR-0041).
5
4
  *
6
- * Extracted from `index.ts`. The bundled-id skip below is defense in
7
- * depth: as of Layer 1 Phase 1 the registry itself enforces
8
- * first-writer-wins on duplicate ids and logs a structured
9
- * `tool.registry.duplicate` warning. Keeping the explicit guard avoids
10
- * a noisy warning when a third-party package happens to ship under a
11
- * built-in id.
5
+ * Merged registration cluster: manifest constants, bundled admission,
6
+ * installed/authored admission, and discovery walkers. Command mounting lives
7
+ * in register-tools-mount.ts.
12
8
  */
13
- export { BUNDLED_TOOL_PACKAGES, EXPECTED_SCAFFOLDING_TOOL_IDS } from './register-tools-shared.js';
14
- export { registerFirstPartyTools } from './register-tools-bundled.js';
15
- export { type DiscoveryOptions, buildToolDiscoverySources, discoverAndRegisterToolPackages, discoverAndRegisterAuthoredTools, } from './register-tools-discovery.js';
16
- export { type AuthoredAdmission, admitProjectLocalTool, admitUserGlobalTool, } from './authored-tool-admission.js';
17
- export { mountAllToolCommands } from './register-tools-mount.js';
9
+ import { type ToolPluginManifest, type ToolProvenance, type ToolRegistry } from '@opensip-cli/core';
10
+ export { BUNDLED_CAPABILITY_PACKS, BUNDLED_TOOL_PACKAGES, EXPECTED_SCAFFOLDING_TOOL_IDS, } from './bundled-manifest.js';
11
+ /**
12
+ * Resolve a bundled tool's PACKAGE DIR — the directory whose `package.json`
13
+ * carries the `opensipTools` manifest.
14
+ *
15
+ * The `./package.json` subpath is not declared in each engine's `exports`,
16
+ * so `require.resolve('<pkg>/package.json')` throws. Instead we resolve the
17
+ * package's MAIN entry (a bare-name resolve, always permitted by `exports`)
18
+ * and walk up to the nearest ancestor directory that has a `package.json`
19
+ * whose `name` matches `packageName`. That ancestor IS the tool's own
20
+ * package dir under both the source layout and pnpm's workspace-injected
21
+ * `node_modules` layout (verified against fitness/simulation/graph here).
22
+ *
23
+ * @returns the resolved package directory, or `undefined` when the package
24
+ * cannot be resolved (should never happen for a bundled direct dep).
25
+ */
26
+ export declare function resolveBundledPackageDir(packageName: string): string | undefined;
27
+ /**
28
+ * Resolve a bundled tool package's on-disk directory, requiring success.
29
+ *
30
+ * @throws {PluginIncompatibleError} when the package directory cannot be
31
+ * resolved on disk (its manifest is unreadable).
32
+ */
33
+ export declare function resolveRequiredBundledPackageDir(packageName: string): string;
34
+ /**
35
+ * Register the bundled first-party tools into the supplied registry, each one
36
+ * flowing through the SAME admit → dynamic-import → register path the external
37
+ * path uses (launch cutover — replaces the static-import + gate path).
38
+ *
39
+ * Per package name: `resolveBundledPackageDir` → `loadToolManifest('bundled')`
40
+ * → `admitTool({ source: 'bundled', explicitlyRequested: true })` →
41
+ * `importToolRuntime` (dynamic import + shape validation) → drift guard →
42
+ * `registry.register`. A bundled tool ships with the CLI, so it is always
43
+ * explicitly present: a missing/incompatible manifest or a runtime that fails
44
+ * to load is FAIL-CLOSED (never a silent skip). The recorded `ToolProvenance`
45
+ * (source `'bundled'`, trusted-by-shipping) and manifest are pushed onto the
46
+ * optional collectors so the composition root can surface provenance
47
+ * (`plugin list`) and seed the per-run capability registry (§5.3).
48
+ *
49
+ * @param registry The per-invocation tool registry to populate.
50
+ * @param provenance Optional sink for the admitted tools' provenance records.
51
+ * @param manifests Optional sink for the admitted tools' manifests (§5.3).
52
+ * @param packages The bundled package names to load (defaults to
53
+ * {@link BUNDLED_TOOL_PACKAGES}; injectable so the fail-closed paths are
54
+ * testable with fixture packages).
55
+ * @throws {PluginIncompatibleError} when a bundled tool cannot be resolved,
56
+ * has no conformant manifest, is out of range, or its runtime fails to load
57
+ * — mapped to `EXIT_CODES.PLUGIN_INCOMPATIBLE` (exit 5) by the CLI boundary.
58
+ */
59
+ export declare function registerFirstPartyTools(registry: ToolRegistry, provenance?: ToolProvenance[], manifests?: ToolPluginManifest[], packages?: readonly string[]): Promise<void>;
60
+ export { admitProjectLocalTool, admitUserGlobalTool, buildToolDiscoverySources, discoverAndRegisterAuthoredTools, discoverAndRegisterToolPackages, emitInstalledLoadFailure, type AuthoredAdmission, type DiscoveryOptions, } from './register-tools-discovery.js';
61
+ export { mountAllToolCommands, mountOneTool } from './register-tools-mount.js';
18
62
  //# sourceMappingURL=register-tools.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"register-tools.d.ts","sourceRoot":"","sources":["../../src/bootstrap/register-tools.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,qBAAqB,EAAE,6BAA6B,EAAE,MAAM,4BAA4B,CAAC;AAElG,OAAO,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AAEtE,OAAO,EACL,KAAK,gBAAgB,EACrB,yBAAyB,EACzB,+BAA+B,EAC/B,gCAAgC,GACjC,MAAM,+BAA+B,CAAC;AAEvC,OAAO,EACL,KAAK,iBAAiB,EACtB,qBAAqB,EACrB,mBAAmB,GACpB,MAAM,8BAA8B,CAAC;AAEtC,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC"}
1
+ {"version":3,"file":"register-tools.d.ts","sourceRoot":"","sources":["../../src/bootstrap/register-tools.ts"],"names":[],"mappings":"AACA;;;;;;;GAOG;AAMH,OAAO,EAGL,KAAK,kBAAkB,EACvB,KAAK,cAAc,EACnB,KAAK,YAAY,EAClB,MAAM,mBAAmB,CAAC;AAM3B,OAAO,EACL,wBAAwB,EACxB,qBAAqB,EACrB,6BAA6B,GAC9B,MAAM,uBAAuB,CAAC;AAK/B;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,wBAAwB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAkChF;AAED;;;;;GAKG;AACH,wBAAgB,gCAAgC,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAO5E;AAQD;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAsB,uBAAuB,CAC3C,QAAQ,EAAE,YAAY,EACtB,UAAU,GAAE,cAAc,EAAO,EACjC,SAAS,GAAE,kBAAkB,EAAO,EACpC,QAAQ,GAAE,SAAS,MAAM,EAA0B,GAClD,OAAO,CAAC,IAAI,CAAC,CAwCf;AA8DD,OAAO,EACL,qBAAqB,EACrB,mBAAmB,EACnB,yBAAyB,EACzB,gCAAgC,EAChC,+BAA+B,EAC/B,wBAA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