opensip-cli 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +202 -0
- package/NOTICE +8 -0
- package/README.md +51 -0
- package/dist/api.d.ts +17 -0
- package/dist/api.d.ts.map +1 -0
- package/dist/api.js +16 -0
- package/dist/api.js.map +1 -0
- package/dist/bootstrap/admit-tool-package.d.ts +117 -0
- package/dist/bootstrap/admit-tool-package.d.ts.map +1 -0
- package/dist/bootstrap/admit-tool-package.js +170 -0
- package/dist/bootstrap/admit-tool-package.js.map +1 -0
- package/dist/bootstrap/baseline-seams.d.ts +30 -0
- package/dist/bootstrap/baseline-seams.d.ts.map +1 -0
- package/dist/bootstrap/baseline-seams.js +156 -0
- package/dist/bootstrap/baseline-seams.js.map +1 -0
- package/dist/bootstrap/bootstrap-error.d.ts +41 -0
- package/dist/bootstrap/bootstrap-error.d.ts.map +1 -0
- package/dist/bootstrap/bootstrap-error.js +33 -0
- package/dist/bootstrap/bootstrap-error.js.map +1 -0
- package/dist/bootstrap/build-command-registration-input.d.ts +34 -0
- package/dist/bootstrap/build-command-registration-input.d.ts.map +1 -0
- package/dist/bootstrap/build-command-registration-input.js +73 -0
- package/dist/bootstrap/build-command-registration-input.js.map +1 -0
- package/dist/bootstrap/build-per-run-scope.d.ts +62 -0
- package/dist/bootstrap/build-per-run-scope.d.ts.map +1 -0
- package/dist/bootstrap/build-per-run-scope.js +152 -0
- package/dist/bootstrap/build-per-run-scope.js.map +1 -0
- package/dist/bootstrap/build-targets.d.ts +42 -0
- package/dist/bootstrap/build-targets.d.ts.map +1 -0
- package/dist/bootstrap/build-targets.js +117 -0
- package/dist/bootstrap/build-targets.js.map +1 -0
- package/dist/bootstrap/cli-defaults.d.ts +35 -0
- package/dist/bootstrap/cli-defaults.d.ts.map +1 -0
- package/dist/bootstrap/cli-defaults.js +65 -0
- package/dist/bootstrap/cli-defaults.js.map +1 -0
- package/dist/bootstrap/config-and-capabilities.d.ts +74 -0
- package/dist/bootstrap/config-and-capabilities.d.ts.map +1 -0
- package/dist/bootstrap/config-and-capabilities.js +224 -0
- package/dist/bootstrap/config-and-capabilities.js.map +1 -0
- package/dist/bootstrap/deliver-envelope.d.ts +80 -0
- package/dist/bootstrap/deliver-envelope.d.ts.map +1 -0
- package/dist/bootstrap/deliver-envelope.js +195 -0
- package/dist/bootstrap/deliver-envelope.js.map +1 -0
- package/dist/bootstrap/egress-plane.d.ts +22 -0
- package/dist/bootstrap/egress-plane.d.ts.map +1 -0
- package/dist/bootstrap/egress-plane.js +37 -0
- package/dist/bootstrap/egress-plane.js.map +1 -0
- package/dist/bootstrap/host-planes.d.ts +28 -0
- package/dist/bootstrap/host-planes.d.ts.map +1 -0
- package/dist/bootstrap/host-planes.js +152 -0
- package/dist/bootstrap/host-planes.js.map +1 -0
- package/dist/bootstrap/index.d.ts +76 -0
- package/dist/bootstrap/index.d.ts.map +1 -0
- package/dist/bootstrap/index.js +109 -0
- package/dist/bootstrap/index.js.map +1 -0
- package/dist/bootstrap/live-plane.d.ts +51 -0
- package/dist/bootstrap/live-plane.d.ts.map +1 -0
- package/dist/bootstrap/live-plane.js +72 -0
- package/dist/bootstrap/live-plane.js.map +1 -0
- package/dist/bootstrap/load-tool-capabilities.d.ts +42 -0
- package/dist/bootstrap/load-tool-capabilities.d.ts.map +1 -0
- package/dist/bootstrap/load-tool-capabilities.js +76 -0
- package/dist/bootstrap/load-tool-capabilities.js.map +1 -0
- package/dist/bootstrap/output-plane.d.ts +37 -0
- package/dist/bootstrap/output-plane.d.ts.map +1 -0
- package/dist/bootstrap/output-plane.js +114 -0
- package/dist/bootstrap/output-plane.js.map +1 -0
- package/dist/bootstrap/owning-tool-init.d.ts +32 -0
- package/dist/bootstrap/owning-tool-init.d.ts.map +1 -0
- package/dist/bootstrap/owning-tool-init.js +69 -0
- package/dist/bootstrap/owning-tool-init.js.map +1 -0
- package/dist/bootstrap/pre-action-guards.d.ts +44 -0
- package/dist/bootstrap/pre-action-guards.d.ts.map +1 -0
- package/dist/bootstrap/pre-action-guards.js +136 -0
- package/dist/bootstrap/pre-action-guards.js.map +1 -0
- package/dist/bootstrap/pre-action-hook.d.ts +68 -0
- package/dist/bootstrap/pre-action-hook.d.ts.map +1 -0
- package/dist/bootstrap/pre-action-hook.js +289 -0
- package/dist/bootstrap/pre-action-hook.js.map +1 -0
- package/dist/bootstrap/pre-action-messages.d.ts +32 -0
- package/dist/bootstrap/pre-action-messages.d.ts.map +1 -0
- package/dist/bootstrap/pre-action-messages.js +49 -0
- package/dist/bootstrap/pre-action-messages.js.map +1 -0
- package/dist/bootstrap/process-idempotency.d.ts +17 -0
- package/dist/bootstrap/process-idempotency.d.ts.map +1 -0
- package/dist/bootstrap/process-idempotency.js +20 -0
- package/dist/bootstrap/process-idempotency.js.map +1 -0
- package/dist/bootstrap/register-language-adapters.d.ts +23 -0
- package/dist/bootstrap/register-language-adapters.d.ts.map +1 -0
- package/dist/bootstrap/register-language-adapters.js +35 -0
- package/dist/bootstrap/register-language-adapters.js.map +1 -0
- package/dist/bootstrap/register-tools.d.ts +228 -0
- package/dist/bootstrap/register-tools.d.ts.map +1 -0
- package/dist/bootstrap/register-tools.js +696 -0
- package/dist/bootstrap/register-tools.js.map +1 -0
- package/dist/bootstrap/render.d.ts +27 -0
- package/dist/bootstrap/render.d.ts.map +1 -0
- package/dist/bootstrap/render.js +53 -0
- package/dist/bootstrap/render.js.map +1 -0
- package/dist/bootstrap/report.d.ts +34 -0
- package/dist/bootstrap/report.d.ts.map +1 -0
- package/dist/bootstrap/report.js +47 -0
- package/dist/bootstrap/report.js.map +1 -0
- package/dist/bootstrap/run-plane.d.ts +105 -0
- package/dist/bootstrap/run-plane.d.ts.map +1 -0
- package/dist/bootstrap/run-plane.js +190 -0
- package/dist/bootstrap/run-plane.js.map +1 -0
- package/dist/bootstrap/scope-access.d.ts +68 -0
- package/dist/bootstrap/scope-access.d.ts.map +1 -0
- package/dist/bootstrap/scope-access.js +115 -0
- package/dist/bootstrap/scope-access.js.map +1 -0
- package/dist/bootstrap/state-seams.d.ts +14 -0
- package/dist/bootstrap/state-seams.d.ts.map +1 -0
- package/dist/bootstrap/state-seams.js +26 -0
- package/dist/bootstrap/state-seams.js.map +1 -0
- package/dist/bootstrap/tool-lifecycle.d.ts +102 -0
- package/dist/bootstrap/tool-lifecycle.d.ts.map +1 -0
- package/dist/bootstrap/tool-lifecycle.js +103 -0
- package/dist/bootstrap/tool-lifecycle.js.map +1 -0
- package/dist/bootstrap/tool-trust.d.ts +49 -0
- package/dist/bootstrap/tool-trust.d.ts.map +1 -0
- package/dist/bootstrap/tool-trust.js +65 -0
- package/dist/bootstrap/tool-trust.js.map +1 -0
- package/dist/bootstrap/validate-tool.d.ts +22 -0
- package/dist/bootstrap/validate-tool.d.ts.map +1 -0
- package/dist/bootstrap/validate-tool.js +38 -0
- package/dist/bootstrap/validate-tool.js.map +1 -0
- package/dist/cli-context.d.ts +38 -0
- package/dist/cli-context.d.ts.map +1 -0
- package/dist/cli-context.js +134 -0
- package/dist/cli-context.js.map +1 -0
- package/dist/commands/agent-catalog.d.ts +45 -0
- package/dist/commands/agent-catalog.d.ts.map +1 -0
- package/dist/commands/agent-catalog.js +115 -0
- package/dist/commands/agent-catalog.js.map +1 -0
- package/dist/commands/assemble-outcome.d.ts +69 -0
- package/dist/commands/assemble-outcome.d.ts.map +1 -0
- package/dist/commands/assemble-outcome.js +121 -0
- package/dist/commands/assemble-outcome.js.map +1 -0
- package/dist/commands/clear.d.ts +32 -0
- package/dist/commands/clear.d.ts.map +1 -0
- package/dist/commands/clear.js +73 -0
- package/dist/commands/clear.js.map +1 -0
- package/dist/commands/completion.d.ts +90 -0
- package/dist/commands/completion.d.ts.map +1 -0
- package/dist/commands/completion.js +233 -0
- package/dist/commands/completion.js.map +1 -0
- package/dist/commands/configure.d.ts +32 -0
- package/dist/commands/configure.d.ts.map +1 -0
- package/dist/commands/configure.js +94 -0
- package/dist/commands/configure.js.map +1 -0
- package/dist/commands/history.d.ts +18 -0
- package/dist/commands/history.d.ts.map +1 -0
- package/dist/commands/history.js +48 -0
- package/dist/commands/history.js.map +1 -0
- package/dist/commands/host-command-specs.d.ts +49 -0
- package/dist/commands/host-command-specs.d.ts.map +1 -0
- package/dist/commands/host-command-specs.js +331 -0
- package/dist/commands/host-command-specs.js.map +1 -0
- package/dist/commands/host-subcommand-groups.d.ts +69 -0
- package/dist/commands/host-subcommand-groups.d.ts.map +1 -0
- package/dist/commands/host-subcommand-groups.js +374 -0
- package/dist/commands/host-subcommand-groups.js.map +1 -0
- package/dist/commands/index.d.ts +36 -0
- package/dist/commands/index.d.ts.map +1 -0
- package/dist/commands/index.js +36 -0
- package/dist/commands/index.js.map +1 -0
- package/dist/commands/init/config-templates.d.ts +16 -0
- package/dist/commands/init/config-templates.d.ts.map +1 -0
- package/dist/commands/init/config-templates.js +108 -0
- package/dist/commands/init/config-templates.js.map +1 -0
- package/dist/commands/init/file-classifier.d.ts +40 -0
- package/dist/commands/init/file-classifier.d.ts.map +1 -0
- package/dist/commands/init/file-classifier.js +155 -0
- package/dist/commands/init/file-classifier.js.map +1 -0
- package/dist/commands/init/language-detection.d.ts +44 -0
- package/dist/commands/init/language-detection.d.ts.map +1 -0
- package/dist/commands/init/language-detection.js +124 -0
- package/dist/commands/init/language-detection.js.map +1 -0
- package/dist/commands/init/scaffold-writer.d.ts +26 -0
- package/dist/commands/init/scaffold-writer.d.ts.map +1 -0
- package/dist/commands/init/scaffold-writer.js +102 -0
- package/dist/commands/init/scaffold-writer.js.map +1 -0
- package/dist/commands/init/state-machine.d.ts +32 -0
- package/dist/commands/init/state-machine.d.ts.map +1 -0
- package/dist/commands/init/state-machine.js +105 -0
- package/dist/commands/init/state-machine.js.map +1 -0
- package/dist/commands/init.d.ts +95 -0
- package/dist/commands/init.d.ts.map +1 -0
- package/dist/commands/init.js +209 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/mount-command-spec.d.ts +106 -0
- package/dist/commands/mount-command-spec.d.ts.map +1 -0
- package/dist/commands/mount-command-spec.js +313 -0
- package/dist/commands/mount-command-spec.js.map +1 -0
- package/dist/commands/mount-result-command.d.ts +71 -0
- package/dist/commands/mount-result-command.d.ts.map +1 -0
- package/dist/commands/mount-result-command.js +76 -0
- package/dist/commands/mount-result-command.js.map +1 -0
- package/dist/commands/plugin/config-edit.d.ts +20 -0
- package/dist/commands/plugin/config-edit.d.ts.map +1 -0
- package/dist/commands/plugin/config-edit.js +102 -0
- package/dist/commands/plugin/config-edit.js.map +1 -0
- package/dist/commands/plugin/domain-resolution.d.ts +38 -0
- package/dist/commands/plugin/domain-resolution.d.ts.map +1 -0
- package/dist/commands/plugin/domain-resolution.js +98 -0
- package/dist/commands/plugin/domain-resolution.js.map +1 -0
- package/dist/commands/plugin/host-dir.d.ts +42 -0
- package/dist/commands/plugin/host-dir.d.ts.map +1 -0
- package/dist/commands/plugin/host-dir.js +168 -0
- package/dist/commands/plugin/host-dir.js.map +1 -0
- package/dist/commands/plugin-host-ops.d.ts +41 -0
- package/dist/commands/plugin-host-ops.d.ts.map +1 -0
- package/dist/commands/plugin-host-ops.js +114 -0
- package/dist/commands/plugin-host-ops.js.map +1 -0
- package/dist/commands/plugin.d.ts +81 -0
- package/dist/commands/plugin.d.ts.map +1 -0
- package/dist/commands/plugin.js +287 -0
- package/dist/commands/plugin.js.map +1 -0
- package/dist/commands/render-outcome.d.ts +52 -0
- package/dist/commands/render-outcome.d.ts.map +1 -0
- package/dist/commands/render-outcome.js +55 -0
- package/dist/commands/render-outcome.js.map +1 -0
- package/dist/commands/session-show.d.ts +27 -0
- package/dist/commands/session-show.d.ts.map +1 -0
- package/dist/commands/session-show.js +166 -0
- package/dist/commands/session-show.js.map +1 -0
- package/dist/commands/shared.d.ts +107 -0
- package/dist/commands/shared.d.ts.map +1 -0
- package/dist/commands/shared.js +13 -0
- package/dist/commands/shared.js.map +1 -0
- package/dist/commands/tools/data-purge.d.ts +20 -0
- package/dist/commands/tools/data-purge.d.ts.map +1 -0
- package/dist/commands/tools/data-purge.js +59 -0
- package/dist/commands/tools/data-purge.js.map +1 -0
- package/dist/commands/tools/index.d.ts +16 -0
- package/dist/commands/tools/index.d.ts.map +1 -0
- package/dist/commands/tools/index.js +213 -0
- package/dist/commands/tools/index.js.map +1 -0
- package/dist/commands/tools/install.d.ts +24 -0
- package/dist/commands/tools/install.d.ts.map +1 -0
- package/dist/commands/tools/install.js +83 -0
- package/dist/commands/tools/install.js.map +1 -0
- package/dist/commands/tools/list.d.ts +41 -0
- package/dist/commands/tools/list.d.ts.map +1 -0
- package/dist/commands/tools/list.js +103 -0
- package/dist/commands/tools/list.js.map +1 -0
- package/dist/commands/tools/runtime-probe-entry.d.ts +14 -0
- package/dist/commands/tools/runtime-probe-entry.d.ts.map +1 -0
- package/dist/commands/tools/runtime-probe-entry.js +36 -0
- package/dist/commands/tools/runtime-probe-entry.js.map +1 -0
- package/dist/commands/tools/runtime-probe.d.ts +29 -0
- package/dist/commands/tools/runtime-probe.d.ts.map +1 -0
- package/dist/commands/tools/runtime-probe.js +66 -0
- package/dist/commands/tools/runtime-probe.js.map +1 -0
- package/dist/commands/tools/storage-contract-checks.d.ts +37 -0
- package/dist/commands/tools/storage-contract-checks.d.ts.map +1 -0
- package/dist/commands/tools/storage-contract-checks.js +91 -0
- package/dist/commands/tools/storage-contract-checks.js.map +1 -0
- package/dist/commands/tools/uninstall.d.ts +29 -0
- package/dist/commands/tools/uninstall.d.ts.map +1 -0
- package/dist/commands/tools/uninstall.js +77 -0
- package/dist/commands/tools/uninstall.js.map +1 -0
- package/dist/commands/tools/validate.d.ts +44 -0
- package/dist/commands/tools/validate.d.ts.map +1 -0
- package/dist/commands/tools/validate.js +202 -0
- package/dist/commands/tools/validate.js.map +1 -0
- package/dist/commands/uninstall/targets.d.ts +53 -0
- package/dist/commands/uninstall/targets.d.ts.map +1 -0
- package/dist/commands/uninstall/targets.js +205 -0
- package/dist/commands/uninstall/targets.js.map +1 -0
- package/dist/commands/uninstall.d.ts +88 -0
- package/dist/commands/uninstall.d.ts.map +1 -0
- package/dist/commands/uninstall.js +184 -0
- package/dist/commands/uninstall.js.map +1 -0
- package/dist/env/host-env-specs.d.ts +52 -0
- package/dist/env/host-env-specs.d.ts.map +1 -0
- package/dist/env/host-env-specs.js +129 -0
- package/dist/env/host-env-specs.js.map +1 -0
- package/dist/error-handler.d.ts +64 -0
- package/dist/error-handler.d.ts.map +1 -0
- package/dist/error-handler.js +180 -0
- package/dist/error-handler.js.map +1 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +154 -0
- package/dist/index.js.map +1 -0
- package/dist/open-report.d.ts +40 -0
- package/dist/open-report.d.ts.map +1 -0
- package/dist/open-report.js +54 -0
- package/dist/open-report.js.map +1 -0
- package/dist/report-compose.d.ts +35 -0
- package/dist/report-compose.d.ts.map +1 -0
- package/dist/report-compose.js +103 -0
- package/dist/report-compose.js.map +1 -0
- package/dist/session-replay-registry.d.ts +20 -0
- package/dist/session-replay-registry.d.ts.map +1 -0
- package/dist/session-replay-registry.js +38 -0
- package/dist/session-replay-registry.js.map +1 -0
- package/dist/telemetry/profiling.d.ts +42 -0
- package/dist/telemetry/profiling.d.ts.map +1 -0
- package/dist/telemetry/profiling.js +160 -0
- package/dist/telemetry/profiling.js.map +1 -0
- package/dist/telemetry/sdk-init.d.ts +87 -0
- package/dist/telemetry/sdk-init.d.ts.map +1 -0
- package/dist/telemetry/sdk-init.js +235 -0
- package/dist/telemetry/sdk-init.js.map +1 -0
- package/dist/ui/App.d.ts +32 -0
- package/dist/ui/App.d.ts.map +1 -0
- package/dist/ui/App.js +35 -0
- package/dist/ui/App.js.map +1 -0
- package/dist/ui/render.d.ts +15 -0
- package/dist/ui/render.d.ts.map +1 -0
- package/dist/ui/render.js +21 -0
- package/dist/ui/render.js.map +1 -0
- package/dist/ui/result-to-view.d.ts +40 -0
- package/dist/ui/result-to-view.d.ts.map +1 -0
- package/dist/ui/result-to-view.js +389 -0
- package/dist/ui/result-to-view.js.map +1 -0
- package/dist/ui/views/init-view.d.ts +9 -0
- package/dist/ui/views/init-view.d.ts.map +1 -0
- package/dist/ui/views/init-view.js +119 -0
- package/dist/ui/views/init-view.js.map +1 -0
- package/dist/ui/views/misc-views.d.ts +18 -0
- package/dist/ui/views/misc-views.d.ts.map +1 -0
- package/dist/ui/views/misc-views.js +244 -0
- package/dist/ui/views/misc-views.js.map +1 -0
- package/dist/ui/views/plugin-view.d.ts +8 -0
- package/dist/ui/views/plugin-view.d.ts.map +1 -0
- package/dist/ui/views/plugin-view.js +135 -0
- package/dist/ui/views/plugin-view.js.map +1 -0
- package/dist/ui/views/tools-views.d.ts +12 -0
- package/dist/ui/views/tools-views.d.ts.map +1 -0
- package/dist/ui/views/tools-views.js +152 -0
- package/dist/ui/views/tools-views.js.map +1 -0
- package/dist/update-notifier.d.ts +108 -0
- package/dist/update-notifier.d.ts.map +1 -0
- package/dist/update-notifier.js +188 -0
- package/dist/update-notifier.js.map +1 -0
- package/dist/update-state.d.ts +40 -0
- package/dist/update-state.d.ts.map +1 -0
- package/dist/update-state.js +81 -0
- package/dist/update-state.js.map +1 -0
- package/dist/welcome.d.ts +53 -0
- package/dist/welcome.d.ts.map +1 -0
- package/dist/welcome.js +89 -0
- package/dist/welcome.js.map +1 -0
- package/package.json +100 -0
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* cli-context — the thin `ToolCliContext` assembler (host-owned-run-timing
|
|
3
|
+
* Phase 6). `buildToolCliContext` wires together the focused host planes —
|
|
4
|
+
* output, egress, run, live, baseline, state, host-planes — into the single
|
|
5
|
+
* coherent context handed to each tool and host command. Each concern's logic
|
|
6
|
+
* lives in its own `bootstrap/*-plane` (or `*-seams`) module; this file only
|
|
7
|
+
* composes them and exposes the `scope` getter + the assembled context.
|
|
8
|
+
*
|
|
9
|
+
* There is NO module-global bootstrap-handoff bag. The populated registries +
|
|
10
|
+
* admitted-tool manifests/provenance are captured in the pre-action-hook closure
|
|
11
|
+
* (`installPreActionHook` is called AFTER `bootstrapCli` in `main()`), the hook
|
|
12
|
+
* builds + enters the per-run `RunScope`, and from there every per-run read
|
|
13
|
+
* (project, datastore, manifests, provenance, …) goes through `currentScope()`.
|
|
14
|
+
*
|
|
15
|
+
* Lazy datastore: a closure-based thunk caches the open DataStore on first access and
|
|
16
|
+
* lands on `RunScope.datastore`; paths that never touch it never materialise
|
|
17
|
+
* `.runtime/datastore.sqlite`.
|
|
18
|
+
*/
|
|
19
|
+
import { logger as defaultLogger, } from '@opensip-cli/core';
|
|
20
|
+
import { buildBaselineSeams } from './bootstrap/baseline-seams.js';
|
|
21
|
+
import { createEgressPlane } from './bootstrap/egress-plane.js';
|
|
22
|
+
import { buildHostPlanes } from './bootstrap/host-planes.js';
|
|
23
|
+
import { createLivePlane } from './bootstrap/live-plane.js';
|
|
24
|
+
import { createOutputPlane } from './bootstrap/output-plane.js';
|
|
25
|
+
import { createRunActionHooks, createRunPlaneFactory, createRunSessionSeam, } from './bootstrap/run-plane.js';
|
|
26
|
+
import { getProjectDatastore, readScope } from './bootstrap/scope-access.js';
|
|
27
|
+
import { buildStateSeams } from './bootstrap/state-seams.js';
|
|
28
|
+
/** Structured-log `module` tag for this composition-root module. */
|
|
29
|
+
const MODULE_TAG = 'cli:context';
|
|
30
|
+
// ---------------------------------------------------------------------------
|
|
31
|
+
// No module-global bootstrap-handoff bag.
|
|
32
|
+
//
|
|
33
|
+
// The registries + admitted-tool manifests/provenance the pre-action hook needs
|
|
34
|
+
// to BUILD the scope are captured in the hook closure (`installPreActionHook` is
|
|
35
|
+
// called AFTER `bootstrapCli` in `main()`; see `PreActionRuntime`). Once the hook
|
|
36
|
+
// calls `enterScope`, ALL per-run state — project, datastore thunk, diagnostics,
|
|
37
|
+
// AND the admitted-tool manifests/provenance (now stamped onto `RunScope`) — is
|
|
38
|
+
// read exclusively via `currentScope()` (ALS). Host commands that surface the
|
|
39
|
+
// admitted set (`plugin list`, `tools list`, `tools uninstall`) read
|
|
40
|
+
// `currentScope()?.toolProvenance` / `?.toolManifests`.
|
|
41
|
+
// ---------------------------------------------------------------------------
|
|
42
|
+
// Per-run scope + datastore readers live in `bootstrap/scope-access.ts`; the
|
|
43
|
+
// live-view registry lives in `bootstrap/live-plane.ts`. Both are re-exported
|
|
44
|
+
// here so existing importers (`main()` + the dynamic-import tests) keep their
|
|
45
|
+
// stable `cli-context.js` entry point while this module focuses on assembly.
|
|
46
|
+
export { buildDatastoreThunk, getCurrentProjectRoot, getOrOpenDatastore, } from './bootstrap/scope-access.js';
|
|
47
|
+
export { createLiveViewRegistry } from './bootstrap/live-plane.js';
|
|
48
|
+
export function buildToolCliContext(opts) {
|
|
49
|
+
const log = opts.logger ?? defaultLogger;
|
|
50
|
+
// Output plane owns the single `process.exitCode` write path + the four
|
|
51
|
+
// `--json` emit seams (launch §5.5). Its `setExitCode` is the one threaded
|
|
52
|
+
// into egress so the run's exit code has exactly one author.
|
|
53
|
+
const outputPlane = createOutputPlane({ render: opts.render, logger: log });
|
|
54
|
+
// Host planes with stable deps only (same lazy datastore resolver):
|
|
55
|
+
// - baseline/ratchet persistence + diff + exports (ADR-0036);
|
|
56
|
+
// - durable per-tool keyed JSON state (ADR-0042);
|
|
57
|
+
// - governance / entitlements / audit (H1-H3);
|
|
58
|
+
// - effectful egress (cloud sync + `--report-to` + SARIF file sink).
|
|
59
|
+
const baselineSeams = buildBaselineSeams({ getDatastore: getProjectDatastore, logger: log });
|
|
60
|
+
const stateSeams = buildStateSeams({ getDatastore: getProjectDatastore });
|
|
61
|
+
const hostPlanes = buildHostPlanes({ getDatastore: getProjectDatastore, logger: log });
|
|
62
|
+
const egressPlane = createEgressPlane({ setExitCode: outputPlane.setExitCode, logger: log });
|
|
63
|
+
// Host run-lifecycle plane (host-owned-run-timing Phase 1). The FACTORY holds
|
|
64
|
+
// stable deps only — it must NOT start a lifecycle here. The lifecycle is
|
|
65
|
+
// created inside the command action (mount-command-spec calls `beginRun()`
|
|
66
|
+
// after RunScope entry, before the handler) or lazily on first `timing` read.
|
|
67
|
+
const runPlane = createRunPlaneFactory({
|
|
68
|
+
// Best-effort datastore resolver via the entered scope thunk (no direct /
|
|
69
|
+
// global access). Returns undefined when no project/datastore is in scope.
|
|
70
|
+
getDatastore: () => {
|
|
71
|
+
try {
|
|
72
|
+
const thunk = readScope().datastore;
|
|
73
|
+
return thunk ? thunk() : undefined;
|
|
74
|
+
}
|
|
75
|
+
catch (error) {
|
|
76
|
+
// @swallow-ok no entered scope / no datastore in scope is normal for
|
|
77
|
+
// non-project commands and tests; degrade to "no datastore" (the run
|
|
78
|
+
// plane then no-ops). Debug-log for diagnosability.
|
|
79
|
+
log.debug?.({
|
|
80
|
+
evt: 'cli.context.datastore_unavailable',
|
|
81
|
+
module: MODULE_TAG,
|
|
82
|
+
error: error instanceof Error ? error.message : String(error),
|
|
83
|
+
});
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
},
|
|
87
|
+
logger: log,
|
|
88
|
+
});
|
|
89
|
+
// Public run seam (display-only timing) + internal action hooks (the mount
|
|
90
|
+
// dispatch reads the hooks via cast). Both bind the run plane factory above;
|
|
91
|
+
// there is NO public generic-session writer — tools return a contribution and
|
|
92
|
+
// the action hook persists it.
|
|
93
|
+
const runSession = createRunSessionSeam(runPlane);
|
|
94
|
+
const runActionHooks = createRunActionHooks(runPlane);
|
|
95
|
+
// Live plane binds the per-invocation registry (built in `main()`) to the run
|
|
96
|
+
// plane so `renderLive` owns the live run lifecycle: it times the TTY
|
|
97
|
+
// occupancy and persists the renderer's returned `session` contribution.
|
|
98
|
+
const livePlane = createLivePlane({ liveViews: opts.liveViews, runPlane, runSession });
|
|
99
|
+
const ctx = {
|
|
100
|
+
get scope() {
|
|
101
|
+
// The pre-action-hook (or explicit runWithScope in tests) enters the
|
|
102
|
+
// RunScope via AsyncLocalStorage before the action body or any reader runs.
|
|
103
|
+
// `cli.scope` (and currentScope()) surface the identical entered scope.
|
|
104
|
+
// After Phase 3, readScope() no longer has holder fallbacks.
|
|
105
|
+
return readScope();
|
|
106
|
+
},
|
|
107
|
+
render: (result) => opts.render(result),
|
|
108
|
+
registerLiveView: livePlane.register,
|
|
109
|
+
renderLive: livePlane.renderLive,
|
|
110
|
+
maybeOpenReport: opts.maybeOpenReport,
|
|
111
|
+
logger: log,
|
|
112
|
+
setExitCode: outputPlane.setExitCode,
|
|
113
|
+
...outputPlane.emits, // emitJson / emitEnvelope / emitError / emitRaw
|
|
114
|
+
deliverSignals: egressPlane.deliverSignals,
|
|
115
|
+
writeSarif: egressPlane.writeSarif,
|
|
116
|
+
// Host baseline/ratchet plane seams (ADR-0036) — persistence + diff + exports.
|
|
117
|
+
saveBaseline: baselineSeams.saveBaseline,
|
|
118
|
+
compareBaseline: baselineSeams.compareBaseline,
|
|
119
|
+
exportBaselineSarif: baselineSeams.exportBaselineSarif,
|
|
120
|
+
exportBaselineFingerprints: baselineSeams.exportBaselineFingerprints,
|
|
121
|
+
toolState: stateSeams, // ADR-0042: durable per-tool keyed JSON state
|
|
122
|
+
runSession, // host-owned; shared with the live plane
|
|
123
|
+
hostPlanes, // Host-owned governance / entitlements / audit plane (H1-H3)
|
|
124
|
+
// Internal run-lifecycle hooks (not public ToolCliContext members; the mount
|
|
125
|
+
// dispatch reads them via cast). beginRun marks the lifecycle start at the
|
|
126
|
+
// command-action boundary; completeRun persists a returned contribution.
|
|
127
|
+
...runActionHooks,
|
|
128
|
+
};
|
|
129
|
+
return {
|
|
130
|
+
ctx,
|
|
131
|
+
getExitCode: outputPlane.getExitCode,
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
//# sourceMappingURL=cli-context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli-context.js","sourceRoot":"","sources":["../src/cli-context.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAEL,MAAM,IAAI,aAAa,GAGxB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
+
* Structured catalog for AI agents.
|
|
3
|
+
* Provides stable entry points, recommended patterns (including the new
|
|
4
|
+
* agent ergonomics like --filter, --raw, --summary-only), and example shapes.
|
|
5
|
+
* This is intentionally a small, self-contained surface so agents can
|
|
6
|
+
* bootstrap their usage without parsing --help text or source.
|
|
7
|
+
*
|
|
8
|
+
* Future: can be made more dynamic by introspecting live CommandSpecs
|
|
9
|
+
* (see completion.ts for precedent).
|
|
10
|
+
*/
|
|
11
|
+
export interface AgentCatalog {
|
|
12
|
+
readonly version: string;
|
|
13
|
+
readonly description: string;
|
|
14
|
+
readonly entryPoints: readonly {
|
|
15
|
+
readonly command: string;
|
|
16
|
+
readonly description: string;
|
|
17
|
+
readonly examples: readonly string[];
|
|
18
|
+
}[];
|
|
19
|
+
readonly commonPatterns: readonly {
|
|
20
|
+
readonly name: string;
|
|
21
|
+
readonly description: string;
|
|
22
|
+
readonly example: string;
|
|
23
|
+
}[];
|
|
24
|
+
readonly outputShapes: {
|
|
25
|
+
readonly signalEnvelope: string;
|
|
26
|
+
readonly sessionReplay: string;
|
|
27
|
+
readonly history: string;
|
|
28
|
+
};
|
|
29
|
+
readonly notes: readonly string[];
|
|
30
|
+
}
|
|
31
|
+
export declare function buildAgentCatalog(): AgentCatalog;
|
|
32
|
+
export declare function executeAgentCatalog(opts?: {
|
|
33
|
+
json?: boolean;
|
|
34
|
+
}): {
|
|
35
|
+
type: string;
|
|
36
|
+
catalog: AgentCatalog;
|
|
37
|
+
title?: undefined;
|
|
38
|
+
lines?: undefined;
|
|
39
|
+
} | {
|
|
40
|
+
type: string;
|
|
41
|
+
title: string;
|
|
42
|
+
lines: string[];
|
|
43
|
+
catalog?: undefined;
|
|
44
|
+
};
|
|
45
|
+
//# sourceMappingURL=agent-catalog.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-catalog.d.ts","sourceRoot":"","sources":["../../src/commands/agent-catalog.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,WAAW,EAAE,SAAS;QAC7B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;QACzB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;QAC7B,QAAQ,CAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,CAAC;KACtC,EAAE,CAAC;IACJ,QAAQ,CAAC,cAAc,EAAE,SAAS;QAChC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;QACtB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;QAC7B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;KAC1B,EAAE,CAAC;IACJ,QAAQ,CAAC,YAAY,EAAE;QACrB,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;QAChC,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;QAC/B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;KAC1B,CAAC;IACF,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;CACnC;AAED,wBAAgB,iBAAiB,IAAI,YAAY,CA8FhD;AAED,wBAAgB,mBAAmB,CAAC,IAAI,GAAE;IAAE,IAAI,CAAC,EAAE,OAAO,CAAA;CAAO;;;;;;;;;;EA8BhE"}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
export function buildAgentCatalog() {
|
|
2
|
+
return {
|
|
3
|
+
version: '1.0.0',
|
|
4
|
+
description: 'Stable, machine-oriented surface for AI agents using OpenSIP CLI. ' +
|
|
5
|
+
'Focus on --json paths, sessions for historical results, and composable filters. ' +
|
|
6
|
+
'Human UX (tables, banners) is preserved unchanged.',
|
|
7
|
+
entryPoints: [
|
|
8
|
+
{
|
|
9
|
+
command: 'fit',
|
|
10
|
+
description: 'Run fitness checks. Use --json for machine output (SignalEnvelope).',
|
|
11
|
+
examples: ['opensip fit --recipe default --json', 'opensip fit --check some-check --json'],
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
command: 'graph',
|
|
15
|
+
description: 'Build static call graph + rules. --json yields SignalEnvelope.',
|
|
16
|
+
examples: ['opensip graph --json', 'opensip graph --sarif out.sarif'],
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
command: 'sessions list',
|
|
20
|
+
description: 'List stored sessions. --summary-only is agent-friendly (omits heavy payloads).',
|
|
21
|
+
examples: [
|
|
22
|
+
'opensip sessions list --json --summary-only',
|
|
23
|
+
'opensip sessions list --json --tool fit --limit 5',
|
|
24
|
+
],
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
command: 'sessions show',
|
|
28
|
+
description: 'Retrieve a prior run as SessionReplayResult (includes projected SignalEnvelope). ' +
|
|
29
|
+
'Supports latest + --tool and rich filtering.',
|
|
30
|
+
examples: [
|
|
31
|
+
'opensip sessions show latest --tool fit --json',
|
|
32
|
+
'opensip sessions show latest --tool fit --json --filter errors-only --filter top:20',
|
|
33
|
+
'opensip sessions show GRAPH_01... --json --raw',
|
|
34
|
+
'opensip sessions show previous --tool graph --json',
|
|
35
|
+
],
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
command: 'agent-catalog',
|
|
39
|
+
description: 'This command. Self-describing catalog for agents (JSON preferred).',
|
|
40
|
+
examples: ['opensip agent-catalog --json'],
|
|
41
|
+
},
|
|
42
|
+
],
|
|
43
|
+
commonPatterns: [
|
|
44
|
+
{
|
|
45
|
+
name: 'Inspect latest fit with focus on errors',
|
|
46
|
+
description: 'After a fit run, pull only actionable errors (high severity) and limit count.',
|
|
47
|
+
example: 'opensip sessions show latest --tool fit --json --filter errors-only --filter top:10',
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
name: 'Lean session menu for agents',
|
|
51
|
+
description: 'Get pointers to interesting sessions without downloading full historical payloads.',
|
|
52
|
+
example: 'opensip sessions list --json --summary-only --tool fit',
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
name: 'Minimal raw envelope for token-sensitive agents',
|
|
56
|
+
description: 'Bypass the standard CommandResult wrapper when you only need the core data.',
|
|
57
|
+
example: 'opensip sessions show latest --tool graph --json --raw',
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
name: 'Relative navigation',
|
|
61
|
+
description: 'Walk backwards through recent runs of a specific tool without tracking IDs.',
|
|
62
|
+
example: 'opensip sessions show previous --tool fit --json --filter warnings-only',
|
|
63
|
+
},
|
|
64
|
+
],
|
|
65
|
+
outputShapes: {
|
|
66
|
+
signalEnvelope: 'The canonical cross-tool currency (schemaVersion, tool, runId, verdict, units, signals). ' +
|
|
67
|
+
'Every fit/graph/sim result (live or replayed) carries one. See contracts for full type.',
|
|
68
|
+
sessionReplay: 'For sessions show: { session: {id,tool,startedAt,completedAt,score,passed,...}, fidelity: "projection", envelope: SignalEnvelope, filtersApplied?, ...counts }',
|
|
69
|
+
history: 'For sessions list: { type: "history", sessions: HistorySession[] } where each has showCommand + optional summary.',
|
|
70
|
+
},
|
|
71
|
+
notes: [
|
|
72
|
+
'All machine output is under --json. Use --raw on show for the smallest possible payload.',
|
|
73
|
+
'filtersApplied, originalSignalCount, returnedSignalCount appear when --filter is used.',
|
|
74
|
+
'The fidelity field on replays is always "projection" (rebuilt from persisted data).',
|
|
75
|
+
'Human-readable output (no --json) uses the same tables/banners as before — unchanged.',
|
|
76
|
+
'Dogfood gate requires 0 errors + 0 warnings on fit:ci and graph:ci after any change.',
|
|
77
|
+
// Hygiene invariant (host-planes-scope-seams-hygiene Phases 2-4): everything runs inside an
|
|
78
|
+
// entered RunScope; the only sanctioned seams for output, delivery, baselines, toolState,
|
|
79
|
+
// and hostPlanes (governance/audit/entitlements) are the documented methods on ToolCliContext
|
|
80
|
+
// (render, emitJson, emitEnvelope, deliverSignals, writeSarif, + the baseline/toolState/hostPlanes
|
|
81
|
+
// accessors). Direct stdout, the old pre-scope holder, or raw datastore from handlers is
|
|
82
|
+
// forbidden and caught by ESLint + fitness check + runtime guards. Bootstrap root is exempted.
|
|
83
|
+
'Only the methods on the ToolCliContext you receive are allowed for emission/state/planes.',
|
|
84
|
+
],
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
export function executeAgentCatalog(opts = {}) {
|
|
88
|
+
const catalog = buildAgentCatalog();
|
|
89
|
+
if (opts.json) {
|
|
90
|
+
// Return a result shape that the host can emit cleanly.
|
|
91
|
+
// Using a plain object here; a proper AgentCatalogResult union member
|
|
92
|
+
// can be added in Phase 6 wiring for full type safety / parity.
|
|
93
|
+
return {
|
|
94
|
+
type: 'agent-catalog',
|
|
95
|
+
catalog,
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
// Human summary (simple, not the full catalog dump).
|
|
99
|
+
const lines = [
|
|
100
|
+
'Agent Catalog (use --json for the full machine-readable version)',
|
|
101
|
+
'',
|
|
102
|
+
'Primary patterns for agents:',
|
|
103
|
+
...catalog.commonPatterns.map((p) => ` • ${p.name}: ${p.example}`),
|
|
104
|
+
'',
|
|
105
|
+
'Key entry points: ' + catalog.entryPoints.map((e) => e.command).join(', '),
|
|
106
|
+
'',
|
|
107
|
+
'See --json output or the docs for complete shapes and more examples.',
|
|
108
|
+
];
|
|
109
|
+
return {
|
|
110
|
+
type: 'text-lines',
|
|
111
|
+
title: 'Agent Catalog',
|
|
112
|
+
lines,
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
//# sourceMappingURL=agent-catalog.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-catalog.js","sourceRoot":"","sources":["../../src/commands/agent-catalog.ts"],"names":[],"mappings":"AA+BA,MAAM,UAAU,iBAAiB;IAC/B,OAAO;QACL,OAAO,EAAE,OAAO;QAChB,WAAW,EACT,oEAAoE;YACpE,kFAAkF;YAClF,oDAAoD;QACtD,WAAW,EAAE;YACX;gBACE,OAAO,EAAE,KAAK;gBACd,WAAW,EAAE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AC9F,mGAAmG;YACnG,yFAAyF;YACzF,+FAA+F;YAC/F,2FAA2F;SAC5F;KACF,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,mBAAmB,CAAC,OAA2B,EAAE;IAC/D,MAAM,OAAO,GAAG,iBAAiB,EAAE,CAAC;IAEpC,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;QACd,wDAAwD;QACxD,sEAAsE;QACtE,gEAAgE;QAChE,OAAO;YACL,IAAI,EAAE,eAAe;YACrB,OAAO;SACR,CAAC;IACJ,CAAC;IAED,qDAAqD;IACrD,MAAM,KAAK,GAAa;QACtB,kEAAkE;QAClE,EAAE;QACF,8BAA8B;QAC9B,GAAG,OAAO,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,OAAO,EAAE,CAAC;QACnE,EAAE;QACF,oBAAoB,GAAG,OAAO,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;QAC3E,EAAE;QACF,sEAAsE;KACvE,CAAC;IAEF,OAAO;QACL,IAAI,EAAE,YAAY;QAClB,KAAK,EAAE,eAAe;QACtB,KAAK;KACN,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* assemble-outcome — the host-owned assembler that STAMPS a {@link CommandOutcome}
|
|
3
|
+
* onto a handler's pure-domain return (launch, north-star §5.5).
|
|
4
|
+
*
|
|
5
|
+
* The single load-bearing rule of the Output plane: **the host assembles, the
|
|
6
|
+
* handler stays pure domain.** A tool handler returns (or hands the host) its
|
|
7
|
+
* `SignalEnvelope` / `CommandResult` / a bare JSON document / an error message;
|
|
8
|
+
* THIS module turns that into the one outer currency by deriving `kind`,
|
|
9
|
+
* `status`, `exitCode`, the structured `errors`, AND stamping the scope-owned
|
|
10
|
+
* `diagnostics` snapshot. The handler never constructs a `CommandOutcome` (it
|
|
11
|
+
* cannot — the diagnostics bus is scope-collected). This keeps every tool,
|
|
12
|
+
* first-party or external, off the privilege of choosing its own error JSON or
|
|
13
|
+
* success carrier.
|
|
14
|
+
*
|
|
15
|
+
* No stdout here — the builders only read the current scope's diagnostics bus.
|
|
16
|
+
* {@link renderOutcome} (the sibling) is the one place an outcome reaches a stream.
|
|
17
|
+
*/
|
|
18
|
+
import { type CommandOutcome, type SignalEnvelope } from '@opensip-cli/contracts';
|
|
19
|
+
/** Derive a run outcome's `kind` from the envelope's tool id: `'<tool>.run'`. */
|
|
20
|
+
export declare function kindFromEnvelope(envelope: SignalEnvelope): string;
|
|
21
|
+
/**
|
|
22
|
+
* Derive a result outcome's `kind` from a `CommandResult`'s discriminant
|
|
23
|
+
* (`result.type`, e.g. `'history'` → `'history'`), falling back to a neutral
|
|
24
|
+
* `'command.result'` for bare JSON documents that carry no `type`.
|
|
25
|
+
*/
|
|
26
|
+
export declare function kindFromResult(value: unknown): string;
|
|
27
|
+
/**
|
|
28
|
+
* Wrap a completed run's {@link SignalEnvelope} as a `status:'ok'` outcome — the
|
|
29
|
+
* envelope rides UNCHANGED under `.envelope` (the byte-identical inner currency;
|
|
30
|
+
* the break is purely this new outer wrapper). `status` is `'ok'` for any run
|
|
31
|
+
* that completed: a failing gate is a successful run with a non-zero `exitCode`,
|
|
32
|
+
* and the gate verdict is read from `.envelope.verdict`, not the outer status.
|
|
33
|
+
*/
|
|
34
|
+
export declare function outcomeFromEnvelope(envelope: SignalEnvelope, exitCode: number): CommandOutcome;
|
|
35
|
+
/**
|
|
36
|
+
* Wrap a `CommandResult` (or a bare JSON document) as `.data`. An `ErrorResult`
|
|
37
|
+
* (`type:'error'`) becomes a `status:'error'` outcome carrying its own
|
|
38
|
+
* `exitCode` + a structured `errors` entry; everything else is `status:'ok'` with
|
|
39
|
+
* the supplied `exitCode`.
|
|
40
|
+
*/
|
|
41
|
+
export declare function outcomeFromResult(value: unknown, exitCode: number): CommandOutcome;
|
|
42
|
+
/**
|
|
43
|
+
* Build a `status:'error'` outcome from a thrown error — the host's error
|
|
44
|
+
* stamper. A typed {@link ToolError} maps to its canonical exit code
|
|
45
|
+
* (`mapToolErrorToExitCode`) and contributes its `code`; an untyped error is a
|
|
46
|
+
* `RUNTIME_ERROR` (exit 1). The actionable `suggestion` comes from the shared
|
|
47
|
+
* `getErrorSuggestion` rule table — the same diagnosis the legacy
|
|
48
|
+
* `handleParseError` surfaced.
|
|
49
|
+
*
|
|
50
|
+
* @param kind The outcome kind (e.g. `'bootstrap.error'` for a pre-handler
|
|
51
|
+
* failure, Phase 3); defaults to `'command.error'`.
|
|
52
|
+
*/
|
|
53
|
+
export declare function outcomeFromError(error: unknown, opts?: {
|
|
54
|
+
readonly kind?: string;
|
|
55
|
+
}): CommandOutcome;
|
|
56
|
+
/**
|
|
57
|
+
* Build a `status:'error'` outcome from an already-resolved message + exit code —
|
|
58
|
+
* the seam tool handlers use when they have a diagnosed failure (the former
|
|
59
|
+
* `emitJson({ error })` shape) rather than a thrown error to map.
|
|
60
|
+
*/
|
|
61
|
+
export declare function outcomeFromErrorMessage(opts: {
|
|
62
|
+
readonly message: string;
|
|
63
|
+
readonly exitCode: number;
|
|
64
|
+
readonly suggestion?: string;
|
|
65
|
+
/** Optional machine-readable error category, surfaced as `ErrorDetail.code`. */
|
|
66
|
+
readonly code?: string;
|
|
67
|
+
readonly kind?: string;
|
|
68
|
+
}): CommandOutcome;
|
|
69
|
+
//# sourceMappingURL=assemble-outcome.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assemble-outcome.d.ts","sourceRoot":"","sources":["../../src/commands/assemble-outcome.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAIL,KAAK,cAAc,EAGnB,KAAK,cAAc,EACpB,MAAM,wBAAwB,CAAC;AAgBhC,iFAAiF;AACjF,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,cAAc,GAAG,MAAM,CAEjE;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAGrD;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,GAAG,cAAc,CAE9F;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,GAAG,cAAc,CAYlF;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,OAAO,EACd,IAAI,GAAE;IAAE,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAO,GACpC,cAAc,CAgBhB;AAED;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,IAAI,EAAE;IAC5C,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B,gFAAgF;IAChF,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;CACxB,GAAG,cAAc,CAajB"}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* assemble-outcome — the host-owned assembler that STAMPS a {@link CommandOutcome}
|
|
3
|
+
* onto a handler's pure-domain return (launch, north-star §5.5).
|
|
4
|
+
*
|
|
5
|
+
* The single load-bearing rule of the Output plane: **the host assembles, the
|
|
6
|
+
* handler stays pure domain.** A tool handler returns (or hands the host) its
|
|
7
|
+
* `SignalEnvelope` / `CommandResult` / a bare JSON document / an error message;
|
|
8
|
+
* THIS module turns that into the one outer currency by deriving `kind`,
|
|
9
|
+
* `status`, `exitCode`, the structured `errors`, AND stamping the scope-owned
|
|
10
|
+
* `diagnostics` snapshot. The handler never constructs a `CommandOutcome` (it
|
|
11
|
+
* cannot — the diagnostics bus is scope-collected). This keeps every tool,
|
|
12
|
+
* first-party or external, off the privilege of choosing its own error JSON or
|
|
13
|
+
* success carrier.
|
|
14
|
+
*
|
|
15
|
+
* No stdout here — the builders only read the current scope's diagnostics bus.
|
|
16
|
+
* {@link renderOutcome} (the sibling) is the one place an outcome reaches a stream.
|
|
17
|
+
*/
|
|
18
|
+
import { EXIT_CODES, getErrorSuggestion, mapToolErrorToExitCode, } from '@opensip-cli/contracts';
|
|
19
|
+
import { ToolError, currentScope } from '@opensip-cli/core';
|
|
20
|
+
/**
|
|
21
|
+
* Attach the scope-owned diagnostics snapshot (north-star §5.10) to a freshly
|
|
22
|
+
* built outcome. The host stamps it here — a handler never assembles diagnostics
|
|
23
|
+
* (it cannot: the bus is scope-collected). Omitted entirely when no scope is
|
|
24
|
+
* bound (isolated unit tests) or the bus is empty-and-untraced, keeping the
|
|
25
|
+
* outcome shape minimal.
|
|
26
|
+
*/
|
|
27
|
+
function withDiagnostics(outcome) {
|
|
28
|
+
const diagnostics = currentScope()?.diagnostics?.snapshot();
|
|
29
|
+
if (diagnostics === undefined)
|
|
30
|
+
return outcome;
|
|
31
|
+
return { ...outcome, diagnostics };
|
|
32
|
+
}
|
|
33
|
+
/** Derive a run outcome's `kind` from the envelope's tool id: `'<tool>.run'`. */
|
|
34
|
+
export function kindFromEnvelope(envelope) {
|
|
35
|
+
return `${envelope.tool}.run`;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Derive a result outcome's `kind` from a `CommandResult`'s discriminant
|
|
39
|
+
* (`result.type`, e.g. `'history'` → `'history'`), falling back to a neutral
|
|
40
|
+
* `'command.result'` for bare JSON documents that carry no `type`.
|
|
41
|
+
*/
|
|
42
|
+
export function kindFromResult(value) {
|
|
43
|
+
const type = value?.type;
|
|
44
|
+
return typeof type === 'string' ? type : 'command.result';
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Wrap a completed run's {@link SignalEnvelope} as a `status:'ok'` outcome — the
|
|
48
|
+
* envelope rides UNCHANGED under `.envelope` (the byte-identical inner currency;
|
|
49
|
+
* the break is purely this new outer wrapper). `status` is `'ok'` for any run
|
|
50
|
+
* that completed: a failing gate is a successful run with a non-zero `exitCode`,
|
|
51
|
+
* and the gate verdict is read from `.envelope.verdict`, not the outer status.
|
|
52
|
+
*/
|
|
53
|
+
export function outcomeFromEnvelope(envelope, exitCode) {
|
|
54
|
+
return withDiagnostics({ kind: kindFromEnvelope(envelope), status: 'ok', exitCode, envelope });
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Wrap a `CommandResult` (or a bare JSON document) as `.data`. An `ErrorResult`
|
|
58
|
+
* (`type:'error'`) becomes a `status:'error'` outcome carrying its own
|
|
59
|
+
* `exitCode` + a structured `errors` entry; everything else is `status:'ok'` with
|
|
60
|
+
* the supplied `exitCode`.
|
|
61
|
+
*/
|
|
62
|
+
export function outcomeFromResult(value, exitCode) {
|
|
63
|
+
if (value?.type === 'error') {
|
|
64
|
+
const err = value;
|
|
65
|
+
return withDiagnostics({
|
|
66
|
+
kind: 'error',
|
|
67
|
+
status: 'error',
|
|
68
|
+
exitCode: err.exitCode,
|
|
69
|
+
data: value,
|
|
70
|
+
errors: [{ message: err.message, ...(err.suggestion ? { suggestion: err.suggestion } : {}) }],
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
return withDiagnostics({ kind: kindFromResult(value), status: 'ok', exitCode, data: value });
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Build a `status:'error'` outcome from a thrown error — the host's error
|
|
77
|
+
* stamper. A typed {@link ToolError} maps to its canonical exit code
|
|
78
|
+
* (`mapToolErrorToExitCode`) and contributes its `code`; an untyped error is a
|
|
79
|
+
* `RUNTIME_ERROR` (exit 1). The actionable `suggestion` comes from the shared
|
|
80
|
+
* `getErrorSuggestion` rule table — the same diagnosis the legacy
|
|
81
|
+
* `handleParseError` surfaced.
|
|
82
|
+
*
|
|
83
|
+
* @param kind The outcome kind (e.g. `'bootstrap.error'` for a pre-handler
|
|
84
|
+
* failure, Phase 3); defaults to `'command.error'`.
|
|
85
|
+
*/
|
|
86
|
+
export function outcomeFromError(error, opts = {}) {
|
|
87
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
88
|
+
const suggestion = getErrorSuggestion(error)?.action;
|
|
89
|
+
const detail = {
|
|
90
|
+
message,
|
|
91
|
+
...(suggestion ? { suggestion } : {}),
|
|
92
|
+
...(error instanceof ToolError ? { code: error.code } : {}),
|
|
93
|
+
};
|
|
94
|
+
const exitCode = error instanceof ToolError ? mapToolErrorToExitCode(error) : EXIT_CODES.RUNTIME_ERROR;
|
|
95
|
+
return withDiagnostics({
|
|
96
|
+
kind: opts.kind ?? 'command.error',
|
|
97
|
+
status: 'error',
|
|
98
|
+
exitCode,
|
|
99
|
+
errors: [detail],
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Build a `status:'error'` outcome from an already-resolved message + exit code —
|
|
104
|
+
* the seam tool handlers use when they have a diagnosed failure (the former
|
|
105
|
+
* `emitJson({ error })` shape) rather than a thrown error to map.
|
|
106
|
+
*/
|
|
107
|
+
export function outcomeFromErrorMessage(opts) {
|
|
108
|
+
return withDiagnostics({
|
|
109
|
+
kind: opts.kind ?? 'command.error',
|
|
110
|
+
status: 'error',
|
|
111
|
+
exitCode: opts.exitCode,
|
|
112
|
+
errors: [
|
|
113
|
+
{
|
|
114
|
+
message: opts.message,
|
|
115
|
+
...(opts.suggestion ? { suggestion: opts.suggestion } : {}),
|
|
116
|
+
...(opts.code ? { code: opts.code } : {}),
|
|
117
|
+
},
|
|
118
|
+
],
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
//# sourceMappingURL=assemble-outcome.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assemble-outcome.js","sourceRoot":"","sources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AAE,CAAC,MAAM,CAAC;KACjB,CAAC,CAAC;AACL,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,uBAAuB,CAAC,IAOvC;IACC,OAAO,eAAe,CAAC;QACrB,IAAI,EAAE,IAAI,CAAC,IAAI,IAAI,eAAe;QAClC,MAAM,EAAE,OAAO;QACf,QAAQ,EAAE,IAAI,CAAC,QAAQ;QACvB,MAAM,EAAE;YACN;gBACE,OAAO,EAAE,IAAI,CAAC,OAAO;gBACrB,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,IAAI,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;gBAC3D,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;aAC1C;SACF;KACF,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* clear command — clear session data from the project-local SQLite DB.
|
|
3
|
+
*
|
|
4
|
+
* Rows in the `sessions` table (and cascaded findings/checks) are
|
|
5
|
+
* the unit of deletion. The CLI
|
|
6
|
+
* bootstrap opens the DataStore in `preAction`; this command receives
|
|
7
|
+
* the constructed repo from its caller.
|
|
8
|
+
*
|
|
9
|
+
* Uses Node `readline` for interactive confirmation (Ink's `useInput`
|
|
10
|
+
* raw-mode requirement is incompatible with prompts on every TTY).
|
|
11
|
+
* Banners and result lines route through the Ink renderer via the
|
|
12
|
+
* `clear-done` `CommandResult` shape — no raw ANSI escapes here.
|
|
13
|
+
*/
|
|
14
|
+
import type { ClearDoneResult } from '@opensip-cli/contracts';
|
|
15
|
+
import type { DataStore } from '@opensip-cli/datastore';
|
|
16
|
+
export interface ClearOptions {
|
|
17
|
+
olderThan?: number;
|
|
18
|
+
yes: boolean;
|
|
19
|
+
datastore: DataStore;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Prompt for confirmation (unless --yes), then delete sessions.
|
|
23
|
+
* Returns a `ClearDoneResult` that the renderer turns into the banner
|
|
24
|
+
* + status line. The rendering is `App.tsx`'s `case 'clear-done':`
|
|
25
|
+
* branch — this function is pure I/O for the prompt only.
|
|
26
|
+
*
|
|
27
|
+
* Deletion goes through `SessionRepo` against the project-local
|
|
28
|
+
* SQLite DB. Cascaded findings/checks are removed by foreign-key
|
|
29
|
+
* cascade rules in the schema.
|
|
30
|
+
*/
|
|
31
|
+
export declare function executeClear(opts: ClearOptions): Promise<ClearDoneResult>;
|
|
32
|
+
//# sourceMappingURL=clear.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clear.d.ts","sourceRoot":"","sources":["../../src/commands/clear.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAQH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAExD,MAAM,WAAW,YAAY;IAC3B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,GAAG,EAAE,OAAO,CAAC;IACb,SAAS,EAAE,SAAS,CAAC;CACtB;AAYD;;;;;;;;;GASG;AACH,wBAAsB,YAAY,CAAC,IAAI,EAAE,YAAY,GAAG,OAAO,CAAC,eAAe,CAAC,CAyC/E"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* clear command — clear session data from the project-local SQLite DB.
|
|
3
|
+
*
|
|
4
|
+
* Rows in the `sessions` table (and cascaded findings/checks) are
|
|
5
|
+
* the unit of deletion. The CLI
|
|
6
|
+
* bootstrap opens the DataStore in `preAction`; this command receives
|
|
7
|
+
* the constructed repo from its caller.
|
|
8
|
+
*
|
|
9
|
+
* Uses Node `readline` for interactive confirmation (Ink's `useInput`
|
|
10
|
+
* raw-mode requirement is incompatible with prompts on every TTY).
|
|
11
|
+
* Banners and result lines route through the Ink renderer via the
|
|
12
|
+
* `clear-done` `CommandResult` shape — no raw ANSI escapes here.
|
|
13
|
+
*/
|
|
14
|
+
// @fitness-ignore-file only-documented-toolcli-seams -- interactive TTY confirmation: the pre-prompt notes printed before "Continue? (y/n)" are human-readable readline UX, not machine run output through a ToolCliContext seam (mirrors the ESLint exemption for this file). Result lines route through the Ink `clear-done` CommandResult. (Architecture review finding 5.)
|
|
15
|
+
import { createInterface } from 'node:readline';
|
|
16
|
+
import { SessionRepo } from '@opensip-cli/session-store';
|
|
17
|
+
function ask(question) {
|
|
18
|
+
const rl = createInterface({ input: process.stdin, output: process.stdout });
|
|
19
|
+
return new Promise((resolve) => {
|
|
20
|
+
rl.question(question, (answer) => {
|
|
21
|
+
rl.close();
|
|
22
|
+
resolve(answer.trim().toLowerCase());
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Prompt for confirmation (unless --yes), then delete sessions.
|
|
28
|
+
* Returns a `ClearDoneResult` that the renderer turns into the banner
|
|
29
|
+
* + status line. The rendering is `App.tsx`'s `case 'clear-done':`
|
|
30
|
+
* branch — this function is pure I/O for the prompt only.
|
|
31
|
+
*
|
|
32
|
+
* Deletion goes through `SessionRepo` against the project-local
|
|
33
|
+
* SQLite DB. Cascaded findings/checks are removed by foreign-key
|
|
34
|
+
* cascade rules in the schema.
|
|
35
|
+
*/
|
|
36
|
+
export async function executeClear(opts) {
|
|
37
|
+
const repo = new SessionRepo(opts.datastore);
|
|
38
|
+
const sessionCount = repo.count();
|
|
39
|
+
if (sessionCount === 0) {
|
|
40
|
+
return { type: 'clear-done', action: 'empty', deletedCount: 0, sessionCount: 0 };
|
|
41
|
+
}
|
|
42
|
+
if (!opts.yes) {
|
|
43
|
+
// Pre-prompt note. Stdout `process.stdout.write` is fine here:
|
|
44
|
+
// Ink can't own this since it conflicts with `readline.question()`,
|
|
45
|
+
// and there are no ANSI escapes — just plain text the user reads
|
|
46
|
+
// before answering. Ink renders the result message after.
|
|
47
|
+
const dayWord = opts.olderThan === 1 ? 'day' : 'days';
|
|
48
|
+
const description = opts.olderThan
|
|
49
|
+
? `This will delete session data older than ${opts.olderThan} ${dayWord} from the project-local SQLite store.`
|
|
50
|
+
: 'This will delete ALL session data from the project-local SQLite store.';
|
|
51
|
+
process.stdout.write(`\n ${description}\n`);
|
|
52
|
+
process.stdout.write(` ${sessionCount} session${sessionCount === 1 ? '' : 's'} currently stored.\n`);
|
|
53
|
+
process.stdout.write(` This includes run history and dashboard data.\n\n`);
|
|
54
|
+
const answer = await ask(' Continue? (y/n) ');
|
|
55
|
+
if (answer !== 'y') {
|
|
56
|
+
return { type: 'clear-done', action: 'cancelled', deletedCount: 0, sessionCount };
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
let deletedCount;
|
|
60
|
+
if (opts.olderThan !== undefined && opts.olderThan > 0) {
|
|
61
|
+
// Wall-time cutoff (N calendar-ish days ago by ms). Not sensitive to
|
|
62
|
+
// local date boundaries or DST; sessions are purged if their stored
|
|
63
|
+
// timestamp is older than (now - N*24h). This matches the user-facing
|
|
64
|
+
// "older than X days" language in the prompt.
|
|
65
|
+
const cutoff = new Date(Date.now() - opts.olderThan * 24 * 60 * 60 * 1000);
|
|
66
|
+
deletedCount = repo.purge(cutoff);
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
deletedCount = repo.clearAll();
|
|
70
|
+
}
|
|
71
|
+
return { type: 'clear-done', action: 'done', deletedCount, sessionCount };
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=clear.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clear.js","sourceRoot":"","sources":["../../src/commands/clear.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,+WAA+W;AAE/W,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAEhD,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA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