opensip-cli 0.1.2 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bootstrap/bind-tool-context.d.ts +16 -0
- package/dist/bootstrap/bind-tool-context.d.ts.map +1 -0
- package/dist/bootstrap/bind-tool-context.js +160 -0
- package/dist/bootstrap/bind-tool-context.js.map +1 -0
- package/dist/bootstrap/build-per-run-scope.d.ts.map +1 -1
- package/dist/bootstrap/build-per-run-scope.js +35 -2
- package/dist/bootstrap/build-per-run-scope.js.map +1 -1
- package/dist/bootstrap/execute-post-bailout-bootstrap.d.ts +45 -0
- package/dist/bootstrap/execute-post-bailout-bootstrap.d.ts.map +1 -0
- package/dist/bootstrap/execute-post-bailout-bootstrap.js +108 -0
- package/dist/bootstrap/execute-post-bailout-bootstrap.js.map +1 -0
- package/dist/bootstrap/plan-pre-action-bootstrap.d.ts +45 -0
- package/dist/bootstrap/plan-pre-action-bootstrap.d.ts.map +1 -0
- package/dist/bootstrap/plan-pre-action-bootstrap.js +86 -0
- package/dist/bootstrap/plan-pre-action-bootstrap.js.map +1 -0
- package/dist/bootstrap/pre-action-bootstrap-phases.d.ts +20 -0
- package/dist/bootstrap/pre-action-bootstrap-phases.d.ts.map +1 -0
- package/dist/bootstrap/pre-action-bootstrap-phases.js +25 -0
- package/dist/bootstrap/pre-action-bootstrap-phases.js.map +1 -0
- package/dist/bootstrap/pre-action-hook.d.ts +6 -66
- package/dist/bootstrap/pre-action-hook.d.ts.map +1 -1
- package/dist/bootstrap/pre-action-hook.js +22 -266
- package/dist/bootstrap/pre-action-hook.js.map +1 -1
- package/dist/bootstrap/pre-action-runtime.d.ts +9 -0
- package/dist/bootstrap/pre-action-runtime.d.ts.map +1 -0
- package/dist/bootstrap/pre-action-runtime.js +2 -0
- package/dist/bootstrap/pre-action-runtime.js.map +1 -0
- package/dist/bootstrap/register-tools-bundled.d.ts +28 -0
- package/dist/bootstrap/register-tools-bundled.d.ts.map +1 -0
- package/dist/bootstrap/register-tools-bundled.js +107 -0
- package/dist/bootstrap/register-tools-bundled.js.map +1 -0
- package/dist/bootstrap/register-tools-discovery.d.ts +154 -0
- package/dist/bootstrap/register-tools-discovery.d.ts.map +1 -0
- package/dist/bootstrap/register-tools-discovery.js +385 -0
- package/dist/bootstrap/register-tools-discovery.js.map +1 -0
- package/dist/bootstrap/register-tools-mount.d.ts +25 -0
- package/dist/bootstrap/register-tools-mount.d.ts.map +1 -0
- package/dist/bootstrap/register-tools-mount.js +91 -0
- package/dist/bootstrap/register-tools-mount.js.map +1 -0
- package/dist/bootstrap/register-tools-shared.d.ts +40 -0
- package/dist/bootstrap/register-tools-shared.d.ts.map +1 -0
- package/dist/bootstrap/register-tools-shared.js +98 -0
- package/dist/bootstrap/register-tools-shared.js.map +1 -0
- package/dist/bootstrap/register-tools.d.ts +4 -196
- package/dist/bootstrap/register-tools.d.ts.map +1 -1
- package/dist/bootstrap/register-tools.js +4 -668
- package/dist/bootstrap/register-tools.js.map +1 -1
- package/dist/commands/mount-command-spec.d.ts +2 -1
- package/dist/commands/mount-command-spec.d.ts.map +1 -1
- package/dist/commands/mount-command-spec.js +3 -6
- package/dist/commands/mount-command-spec.js.map +1 -1
- package/dist/env/host-env-specs.d.ts +4 -3
- package/dist/env/host-env-specs.d.ts.map +1 -1
- package/dist/env/host-env-specs.js +8 -3
- package/dist/env/host-env-specs.js.map +1 -1
- package/package.json +32 -32
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* bind-tool-context — mount-time guard for tool-scoped host planes.
|
|
3
|
+
*
|
|
4
|
+
* The host-owned baseline, toolState, governance, audit, and entitlement planes
|
|
5
|
+
* are all keyed by a `tool` string for backward compatibility with the public
|
|
6
|
+
* ToolCliContext. The mounted command already has an owning Tool, so bind that
|
|
7
|
+
* ownership into a thin context wrapper and reject accidental or malicious
|
|
8
|
+
* cross-tool keys before they reach persistence.
|
|
9
|
+
*/
|
|
10
|
+
import { type Tool, type ToolCliContext } from '@opensip-cli/core';
|
|
11
|
+
import type { RunActionHooks } from './run-plane.js';
|
|
12
|
+
type BoundToolCliContext = ToolCliContext & RunActionHooks;
|
|
13
|
+
export declare function toolOwnedKeys(tool: Tool): ReadonlySet<string>;
|
|
14
|
+
export declare function bindToolCliContext(tool: Tool, ctx: ToolCliContext): BoundToolCliContext;
|
|
15
|
+
export {};
|
|
16
|
+
//# sourceMappingURL=bind-tool-context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bind-tool-context.d.ts","sourceRoot":"","sources":["../../src/bootstrap/bind-tool-context.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAA2B,KAAK,IAAI,EAAE,KAAK,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAE5F,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAErD,KAAK,mBAAmB,GAAG,cAAc,GAAG,cAAc,CAAC;AAM3D,wBAAgB,aAAa,CAAC,IAAI,EAAE,IAAI,GAAG,WAAW,CAAC,MAAM,CAAC,CAS7D;AAqGD,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,cAAc,GAAG,mBAAmB,CA2DvF"}
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* bind-tool-context — mount-time guard for tool-scoped host planes.
|
|
3
|
+
*
|
|
4
|
+
* The host-owned baseline, toolState, governance, audit, and entitlement planes
|
|
5
|
+
* are all keyed by a `tool` string for backward compatibility with the public
|
|
6
|
+
* ToolCliContext. The mounted command already has an owning Tool, so bind that
|
|
7
|
+
* ownership into a thin context wrapper and reject accidental or malicious
|
|
8
|
+
* cross-tool keys before they reach persistence.
|
|
9
|
+
*/
|
|
10
|
+
import { PluginIncompatibleError } from '@opensip-cli/core';
|
|
11
|
+
function primaryCommandName(tool) {
|
|
12
|
+
return tool.commandSpecs?.[0]?.name ?? tool.commands[0]?.name;
|
|
13
|
+
}
|
|
14
|
+
export function toolOwnedKeys(tool) {
|
|
15
|
+
return new Set([
|
|
16
|
+
tool.metadata.id,
|
|
17
|
+
tool.metadata.name,
|
|
18
|
+
primaryCommandName(tool),
|
|
19
|
+
tool.sessionReplay?.tool,
|
|
20
|
+
].filter((value) => typeof value === 'string' && value.length > 0));
|
|
21
|
+
}
|
|
22
|
+
function describeTool(tool) {
|
|
23
|
+
return tool.metadata.name || tool.metadata.id;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* @throws {PluginIncompatibleError} When a mounted tool attempts to use a
|
|
27
|
+
* host-owned seam with another tool's namespace.
|
|
28
|
+
*/
|
|
29
|
+
function assertOwnToolKey(tool, allowed, requested, seam) {
|
|
30
|
+
if (allowed.has(requested))
|
|
31
|
+
return;
|
|
32
|
+
throw new PluginIncompatibleError(`tool '${describeTool(tool)}' attempted to use ${seam} for tool namespace '${requested}'. ` +
|
|
33
|
+
`Allowed namespaces: ${[...allowed].sort().join(', ')}.`, {
|
|
34
|
+
code: 'PLUGIN.IDENTITY_NAMESPACE_MISMATCH',
|
|
35
|
+
diagnostic: `cross-tool ${seam} namespace '${requested}'`,
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
function wrapHostPlanes(tool, allowed, hostPlanes) {
|
|
39
|
+
if (hostPlanes === undefined)
|
|
40
|
+
return undefined;
|
|
41
|
+
const wrapped = {};
|
|
42
|
+
const governance = hostPlanes.governance;
|
|
43
|
+
if (governance !== undefined) {
|
|
44
|
+
wrapped.governance = {
|
|
45
|
+
getGovernanceState: (toolId) => {
|
|
46
|
+
assertOwnToolKey(tool, allowed, toolId, 'hostPlanes.governance.getGovernanceState');
|
|
47
|
+
return governance.getGovernanceState(toolId);
|
|
48
|
+
},
|
|
49
|
+
listForProject: governance.listForProject.bind(governance),
|
|
50
|
+
queryAudit: (toolId, filter) => {
|
|
51
|
+
assertOwnToolKey(tool, allowed, toolId, 'hostPlanes.governance.queryAudit');
|
|
52
|
+
return governance.queryAudit(toolId, filter);
|
|
53
|
+
},
|
|
54
|
+
recordInstallation: (toolId, record) => {
|
|
55
|
+
assertOwnToolKey(tool, allowed, toolId, 'hostPlanes.governance.recordInstallation');
|
|
56
|
+
return governance.recordInstallation(toolId, record);
|
|
57
|
+
},
|
|
58
|
+
recordApprovalDecision: (toolId, decision) => {
|
|
59
|
+
assertOwnToolKey(tool, allowed, toolId, 'hostPlanes.governance.recordApprovalDecision');
|
|
60
|
+
return governance.recordApprovalDecision(toolId, decision);
|
|
61
|
+
},
|
|
62
|
+
setBlock: (toolId, blocked, reason) => {
|
|
63
|
+
assertOwnToolKey(tool, allowed, toolId, 'hostPlanes.governance.setBlock');
|
|
64
|
+
return governance.setBlock(toolId, blocked, reason);
|
|
65
|
+
},
|
|
66
|
+
checkAllowed: (toolId, action) => {
|
|
67
|
+
assertOwnToolKey(tool, allowed, toolId, 'hostPlanes.governance.checkAllowed');
|
|
68
|
+
return governance.checkAllowed(toolId, action);
|
|
69
|
+
},
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
const audit = hostPlanes.audit;
|
|
73
|
+
if (audit !== undefined) {
|
|
74
|
+
wrapped.audit = {
|
|
75
|
+
append: (toolId, entry) => {
|
|
76
|
+
assertOwnToolKey(tool, allowed, toolId, 'hostPlanes.audit.append');
|
|
77
|
+
return audit.append(toolId, entry);
|
|
78
|
+
},
|
|
79
|
+
query: (toolId, filter) => {
|
|
80
|
+
assertOwnToolKey(tool, allowed, toolId, 'hostPlanes.audit.query');
|
|
81
|
+
return audit.query(toolId, filter);
|
|
82
|
+
},
|
|
83
|
+
...(audit.exportForCloud ? { exportForCloud: audit.exportForCloud.bind(audit) } : {}),
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
const entitlements = hostPlanes.entitlements;
|
|
87
|
+
if (entitlements !== undefined) {
|
|
88
|
+
wrapped.entitlements = {
|
|
89
|
+
check: (toolId, action) => {
|
|
90
|
+
assertOwnToolKey(tool, allowed, toolId, 'hostPlanes.entitlements.check');
|
|
91
|
+
return entitlements.check(toolId, action);
|
|
92
|
+
},
|
|
93
|
+
recordUsage: (toolId, usage) => {
|
|
94
|
+
assertOwnToolKey(tool, allowed, toolId, 'hostPlanes.entitlements.recordUsage');
|
|
95
|
+
return entitlements.recordUsage(toolId, usage);
|
|
96
|
+
},
|
|
97
|
+
getLicenseState: (toolId) => {
|
|
98
|
+
assertOwnToolKey(tool, allowed, toolId, 'hostPlanes.entitlements.getLicenseState');
|
|
99
|
+
return entitlements.getLicenseState(toolId);
|
|
100
|
+
},
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
return wrapped;
|
|
104
|
+
}
|
|
105
|
+
export function bindToolCliContext(tool, ctx) {
|
|
106
|
+
const allowed = toolOwnedKeys(tool);
|
|
107
|
+
const source = ctx;
|
|
108
|
+
const bound = Object.defineProperties({}, Object.getOwnPropertyDescriptors(source));
|
|
109
|
+
Object.defineProperties(bound, {
|
|
110
|
+
saveBaseline: {
|
|
111
|
+
value: (toolId, envelope) => {
|
|
112
|
+
assertOwnToolKey(tool, allowed, toolId, 'saveBaseline');
|
|
113
|
+
return ctx.saveBaseline(toolId, envelope);
|
|
114
|
+
},
|
|
115
|
+
},
|
|
116
|
+
compareBaseline: {
|
|
117
|
+
value: (toolId, envelope) => {
|
|
118
|
+
assertOwnToolKey(tool, allowed, toolId, 'compareBaseline');
|
|
119
|
+
return ctx.compareBaseline(toolId, envelope);
|
|
120
|
+
},
|
|
121
|
+
},
|
|
122
|
+
exportBaselineSarif: {
|
|
123
|
+
value: (toolId, path) => {
|
|
124
|
+
assertOwnToolKey(tool, allowed, toolId, 'exportBaselineSarif');
|
|
125
|
+
return ctx.exportBaselineSarif(toolId, path);
|
|
126
|
+
},
|
|
127
|
+
},
|
|
128
|
+
exportBaselineFingerprints: {
|
|
129
|
+
value: (toolId, path) => {
|
|
130
|
+
assertOwnToolKey(tool, allowed, toolId, 'exportBaselineFingerprints');
|
|
131
|
+
return ctx.exportBaselineFingerprints(toolId, path);
|
|
132
|
+
},
|
|
133
|
+
},
|
|
134
|
+
toolState: {
|
|
135
|
+
value: {
|
|
136
|
+
get: (toolId, key) => {
|
|
137
|
+
assertOwnToolKey(tool, allowed, toolId, 'toolState.get');
|
|
138
|
+
return ctx.toolState.get(toolId, key);
|
|
139
|
+
},
|
|
140
|
+
put: (toolId, key, payload) => {
|
|
141
|
+
assertOwnToolKey(tool, allowed, toolId, 'toolState.put');
|
|
142
|
+
return ctx.toolState.put(toolId, key, payload);
|
|
143
|
+
},
|
|
144
|
+
delete: (toolId, key) => {
|
|
145
|
+
assertOwnToolKey(tool, allowed, toolId, 'toolState.delete');
|
|
146
|
+
return ctx.toolState.delete(toolId, key);
|
|
147
|
+
},
|
|
148
|
+
list: (toolId) => {
|
|
149
|
+
assertOwnToolKey(tool, allowed, toolId, 'toolState.list');
|
|
150
|
+
return ctx.toolState.list(toolId);
|
|
151
|
+
},
|
|
152
|
+
},
|
|
153
|
+
},
|
|
154
|
+
hostPlanes: {
|
|
155
|
+
value: wrapHostPlanes(tool, allowed, ctx.hostPlanes),
|
|
156
|
+
},
|
|
157
|
+
});
|
|
158
|
+
return bound;
|
|
159
|
+
}
|
|
160
|
+
//# sourceMappingURL=bind-tool-context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bind-tool-context.js","sourceRoot":"","sources":["../../src/bootstrap/bind-tool-context.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,uBAAuB,EAAkC,MAAM,mBAAmB,CAAC;AAM5F,SAAS,kBAAkB,CAAC,IAAU;IACpC,OAAO,IAAI,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,IAAI,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC;AAChE,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,IAAU;IACtC,OAAO,IAAI,GAAG,CACZ;QACE,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CAAC,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;gBACpC,CAAC;aACoC;SACxC;QACD,UAAU,EAAE;YACV,KAAK,EAAE,cAAc,CAAC,IAAI,EAAE,OAAO,EAAE,GAAG,CAAC,UAAU,CAAC;SACrD;KACF,CAAC,CAAC;IAEH,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build-per-run-scope.d.ts","sourceRoot":"","sources":["../../src/bootstrap/build-per-run-scope.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAKH,OAAO,EAEL,KAAK,gBAAgB,EACrB,KAAK,MAAM,
|
|
1
|
+
{"version":3,"file":"build-per-run-scope.d.ts","sourceRoot":"","sources":["../../src/bootstrap/build-per-run-scope.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAKH,OAAO,EAEL,KAAK,gBAAgB,EACrB,KAAK,MAAM,EAEX,KAAK,cAAc,EAEnB,QAAQ,EAGR,KAAK,kBAAkB,EACvB,KAAK,cAAc,EACnB,KAAK,YAAY,EAClB,MAAM,mBAAmB,CAAC;AAQ3B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAoDzD,4DAA4D;AAC5D,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,OAAO,EAAE,cAAc,CAAC;IACjC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,WAAW,EAAE,UAAU,CAAC,OAAO,eAAe,CAAC,CAAC;IACzD,QAAQ,CAAC,UAAU,EAAE;QACnB,QAAQ,CAAC,SAAS,EAAE,gBAAgB,CAAC;QACrC,QAAQ,CAAC,KAAK,EAAE,YAAY,CAAC;KAC9B,CAAC;IACF,QAAQ,CAAC,SAAS,EAAE,SAAS,kBAAkB,EAAE,CAAC;IAClD;;;;OAIG;IACH,QAAQ,CAAC,UAAU,EAAE,SAAS,cAAc,EAAE,CAAC;IAC/C,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;IAC3B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,EAAE;QACX,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;QACzB,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;KACrC,CAAC;CACH;AAED;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,qBAAqB,GAAG,QAAQ,CAqIvE"}
|
|
@@ -19,11 +19,44 @@
|
|
|
19
19
|
*/
|
|
20
20
|
import { join } from 'node:path';
|
|
21
21
|
import { resolveEffectiveCloudConfig } from '@opensip-cli/config';
|
|
22
|
-
import { createCapabilityRegistry, resolveUserPaths, RunScope, } from '@opensip-cli/core';
|
|
22
|
+
import { createCapabilityRegistry, PluginIncompatibleError, resolveUserPaths, RunScope, } from '@opensip-cli/core';
|
|
23
23
|
import { resolveSignalSink } from '@opensip-cli/output';
|
|
24
24
|
import { buildDatastoreThunk } from '../cli-context.js';
|
|
25
25
|
import { buildTargets } from './build-targets.js';
|
|
26
26
|
import { composeAndValidateToolConfig, wireCapabilityRegistry } from './config-and-capabilities.js';
|
|
27
|
+
const FORBIDDEN_SCOPE_CONTRIBUTION_KEYS = new Set(['__proto__', 'prototype', 'constructor']);
|
|
28
|
+
/**
|
|
29
|
+
* @throws {PluginIncompatibleError} When a tool returns an invalid scope
|
|
30
|
+
* contribution or attempts to overwrite an existing scope key.
|
|
31
|
+
*/
|
|
32
|
+
function installScopeContribution(scope, tool, contribution) {
|
|
33
|
+
if (typeof contribution !== 'object' || contribution === null || Array.isArray(contribution)) {
|
|
34
|
+
throw new PluginIncompatibleError(`tool '${tool.metadata.name || tool.metadata.id}' returned a non-object scope contribution`, {
|
|
35
|
+
code: 'PLUGIN.SCOPE_CONTRIBUTION_INVALID',
|
|
36
|
+
diagnostic: 'contributeScope must return a plain object',
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
for (const key of Object.keys(contribution)) {
|
|
40
|
+
if (FORBIDDEN_SCOPE_CONTRIBUTION_KEYS.has(key)) {
|
|
41
|
+
throw new PluginIncompatibleError(`tool '${tool.metadata.name || tool.metadata.id}' returned forbidden scope key '${key}'`, {
|
|
42
|
+
code: 'PLUGIN.SCOPE_CONTRIBUTION_FORBIDDEN_KEY',
|
|
43
|
+
diagnostic: `forbidden scope key '${key}'`,
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
// `key in scope` (not `hasOwnProperty`) so prototype members are protected
|
|
47
|
+
// too: `RunScope.dispose()` lives on the prototype, and an own-property
|
|
48
|
+
// shadow would silently hijack `disposeCurrentScope()`. This also rejects
|
|
49
|
+
// `Object.prototype` names; no namespaced tool subscope key collides with
|
|
50
|
+
// those, so the stricter check has no legitimate false positive.
|
|
51
|
+
if (key in scope) {
|
|
52
|
+
throw new PluginIncompatibleError(`tool '${tool.metadata.name || tool.metadata.id}' attempted to overwrite scope key '${key}'`, {
|
|
53
|
+
code: 'PLUGIN.SCOPE_CONTRIBUTION_COLLISION',
|
|
54
|
+
diagnostic: `scope key '${key}' already exists`,
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
Object.assign(scope, contribution);
|
|
59
|
+
}
|
|
27
60
|
/**
|
|
28
61
|
* Build the per-run RunScope + perform the post-construction wiring
|
|
29
62
|
* (contributeScope, capabilities, toolConfig, targets).
|
|
@@ -100,7 +133,7 @@ export function buildPerRunScope(input) {
|
|
|
100
133
|
for (const tool of tools.list()) {
|
|
101
134
|
const contribution = tool.contributeScope?.();
|
|
102
135
|
if (contribution)
|
|
103
|
-
|
|
136
|
+
installScopeContribution(scope, tool, contribution);
|
|
104
137
|
}
|
|
105
138
|
// §5.3 Phase 4: per-run capability registry (manifest domains → real registrars).
|
|
106
139
|
const capabilities = wireCapabilityRegistry({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build-per-run-scope.js","sourceRoot":"","sources":["../../src/bootstrap/build-per-run-scope.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EAAE,2BAA2B,EAAE,MAAM,qBAAqB,CAAC;AAClE,OAAO,EACL,wBAAwB,
|
|
1
|
+
{"version":3,"file":"build-per-run-scope.js","sourceRoot":"","sources":["../../src/bootstrap/build-per-run-scope.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EAAE,2BAA2B,EAAE,MAAM,qBAAqB,CAAC;AAClE,OAAO,EACL,wBAAwB,EAGxB,uBAAuB,EAEvB,gBAAgB,EAChB,QAAQ,GAMT,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAExD,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAExD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,4BAA4B,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;AAIpG,MAAM,iCAAiC,GAAG,IAAI,GAAG,CAAC,CAAC,WAAW,EAAE,WAAW,EAAE,aAAa,CAAC,CAAC,CAAC;AAE7F;;;GAGG;AACH,SAAS,wBAAwB,CAC/B,KAAe,EACf,IAAU,EACV,YAA+B;IAE/B,IAAI,OAAO,YAAY,KAAK,QAAQ,IAAI,YAAY,KAAK,IAAI,IAAI,KAAK,CAAC,OAAO,CAAC,YAAY,CAAC,EAAE,CAAC;QAC7F,MAAM,IAAI,uBAAuB,CAC/B,SAAS,IAAI,C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EAAE,cAAc,EAAE,cAAyC,EAAE;QAC/D,CAAC,CAAC,EAAE,CAAC;AACT,CAAC;AAED,sFAAsF;AACtF,mFAAmF;AACnF,iFAAiF;AACjF,gFAAgF;AAChF,2BAA2B"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* execute-post-bailout-bootstrap — post-bailout phases 5–9 (ADR-0052).
|
|
3
|
+
*
|
|
4
|
+
* Side effects after the bailout window: per-run logger, scope build/enter,
|
|
5
|
+
* host start effects, and tool preflight. Injectable deps support table-driven
|
|
6
|
+
* phase-order tests without Commander.
|
|
7
|
+
*/
|
|
8
|
+
import { createRunLogger, enterScope, type Logger, type RunScope } from '@opensip-cli/core';
|
|
9
|
+
import { startProfiling } from '../telemetry/profiling.js';
|
|
10
|
+
import { checkForUpdate } from '../update-notifier.js';
|
|
11
|
+
import { buildPerRunScope } from './build-per-run-scope.js';
|
|
12
|
+
import { loadOwningToolCapabilities } from './load-tool-capabilities.js';
|
|
13
|
+
import { maybeInitializeOwningTool, resolveOwningTool } from './owning-tool-init.js';
|
|
14
|
+
import type { PreActionBootstrapPlan } from './plan-pre-action-bootstrap.js';
|
|
15
|
+
import type { PreActionRuntime } from './pre-action-runtime.js';
|
|
16
|
+
/** Recorded phase transitions for ordering tests. */
|
|
17
|
+
export type PhaseRecorder = (phase: string) => void;
|
|
18
|
+
export interface PostBailoutBootstrapInput {
|
|
19
|
+
readonly plan: PreActionBootstrapPlan;
|
|
20
|
+
readonly runtime: PreActionRuntime;
|
|
21
|
+
readonly version: string;
|
|
22
|
+
readonly noCloud: boolean;
|
|
23
|
+
readonly apiKey?: string;
|
|
24
|
+
}
|
|
25
|
+
export interface PostBailoutBootstrapDeps {
|
|
26
|
+
readonly recordPhase?: PhaseRecorder;
|
|
27
|
+
readonly createRunLogger?: typeof createRunLogger;
|
|
28
|
+
readonly buildPerRunScope?: typeof buildPerRunScope;
|
|
29
|
+
readonly enterScope?: typeof enterScope;
|
|
30
|
+
readonly checkForUpdate?: typeof checkForUpdate;
|
|
31
|
+
readonly startProfiling?: typeof startProfiling;
|
|
32
|
+
readonly maybeInitializeOwningTool?: typeof maybeInitializeOwningTool;
|
|
33
|
+
readonly loadOwningToolCapabilities?: typeof loadOwningToolCapabilities;
|
|
34
|
+
readonly resolveOwningTool?: typeof resolveOwningTool;
|
|
35
|
+
}
|
|
36
|
+
export interface PostBailoutBootstrapResult {
|
|
37
|
+
readonly scope: RunScope;
|
|
38
|
+
readonly runLogger: Logger;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Run post-bailout bootstrap phases. Returns the entered scope and its
|
|
42
|
+
* per-run logger (ADR-0053).
|
|
43
|
+
*/
|
|
44
|
+
export declare function executePostBailoutBootstrap(input: PostBailoutBootstrapInput, deps?: PostBailoutBootstrapDeps): Promise<PostBailoutBootstrapResult>;
|
|
45
|
+
//# sourceMappingURL=execute-post-bailout-bootstrap.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"execute-post-bailout-bootstrap.d.ts","sourceRoot":"","sources":["../../src/bootstrap/execute-post-bailout-bootstrap.ts"],"names":[],"mappings":"AACA;;;;;;GAMG;AAEH,OAAO,EACL,eAAe,EAEf,UAAU,EAGV,KAAK,MAAM,EACX,KAAK,QAAQ,EACd,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EAAE,cAAc,EAAmB,MAAM,uBAAuB,CAAC;AAExE,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAE,0BAA0B,EAAE,MAAM,6BAA6B,CAAC;AACzE,OAAO,EAAE,yBAAyB,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAGrF,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AAC7E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,C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ter, logger, and enterScope calls are synchronous; the async tool lifecycle calls are awaited below.
|
|
2
|
+
/**
|
|
3
|
+
* execute-post-bailout-bootstrap — post-bailout phases 5–9 (ADR-0052).
|
|
4
|
+
*
|
|
5
|
+
* Side effects after the bailout window: per-run logger, scope build/enter,
|
|
6
|
+
* host start effects, and tool preflight. Injectable deps support table-driven
|
|
7
|
+
* phase-order tests without Commander.
|
|
8
|
+
*/
|
|
9
|
+
import { createRunLogger, currentScope, enterScope, getMeter, SystemError, } from '@opensip-cli/core';
|
|
10
|
+
import { startProfiling } from '../telemetry/profiling.js';
|
|
11
|
+
import { checkForUpdate, formatUpdateNag } from '../update-notifier.js';
|
|
12
|
+
import { buildPerRunScope } from './build-per-run-scope.js';
|
|
13
|
+
import { loadOwningToolCapabilities } from './load-tool-capabilities.js';
|
|
14
|
+
import { maybeInitializeOwningTool, resolveOwningTool } from './owning-tool-init.js';
|
|
15
|
+
import { PRE_ACTION_PHASES } from './pre-action-bootstrap-phases.js';
|
|
16
|
+
const MODULE_TAG = 'cli:bootstrap';
|
|
17
|
+
const CLI_PACKAGE_NAME = 'opensip-cli';
|
|
18
|
+
function noopPhaseRecord() {
|
|
19
|
+
// Default when callers omit recordPhase (production hook path).
|
|
20
|
+
}
|
|
21
|
+
const defaultDeps = {
|
|
22
|
+
createRunLogger,
|
|
23
|
+
buildPerRunScope,
|
|
24
|
+
enterScope,
|
|
25
|
+
checkForUpdate,
|
|
26
|
+
startProfiling,
|
|
27
|
+
maybeInitializeOwningTool,
|
|
28
|
+
loadOwningToolCapabilities,
|
|
29
|
+
resolveOwningTool,
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* Run post-bailout bootstrap phases. Returns the entered scope and its
|
|
33
|
+
* per-run logger (ADR-0053).
|
|
34
|
+
*/
|
|
35
|
+
export async function executePostBailoutBootstrap(input, deps = {}) {
|
|
36
|
+
const d = { ...defaultDeps, ...deps };
|
|
37
|
+
const record = deps.recordPhase ?? noopPhaseRecord;
|
|
38
|
+
const { plan, runtime, version, noCloud, apiKey } = input;
|
|
39
|
+
const { languages, tools, manifests, provenance } = runtime;
|
|
40
|
+
record(PRE_ACTION_PHASES.projectSideEffects);
|
|
41
|
+
const runLogger = d.createRunLogger(plan.runLoggerOptions);
|
|
42
|
+
const bannerSize = plan.cliDefaults.ui?.banner ?? 'mini';
|
|
43
|
+
const update = d.checkForUpdate({ name: CLI_PACKAGE_NAME, version });
|
|
44
|
+
if (update && (bannerSize !== 'mini' || plan.jsonOutput)) {
|
|
45
|
+
process.stderr.write(formatUpdateNag(version, update));
|
|
46
|
+
}
|
|
47
|
+
record(PRE_ACTION_PHASES.buildScope);
|
|
48
|
+
const scope = d.buildPerRunScope({
|
|
49
|
+
project: plan.project,
|
|
50
|
+
runId: plan.runId,
|
|
51
|
+
cwd: plan.cwd,
|
|
52
|
+
cliDefaults: plan.cliDefaults,
|
|
53
|
+
registries: { languages, tools },
|
|
54
|
+
manifests,
|
|
55
|
+
provenance,
|
|
56
|
+
apiKey,
|
|
57
|
+
noCloud,
|
|
58
|
+
logger: runLogger,
|
|
59
|
+
ui: { version, update },
|
|
60
|
+
});
|
|
61
|
+
record(PRE_ACTION_PHASES.enterScope);
|
|
62
|
+
d.enterScope(scope); // resilience-ok: Commander postAction in pre-action-hook.ts disposes the entered RunScope after the action completes.
|
|
63
|
+
if (!currentScope()) {
|
|
64
|
+
throw new SystemError('Scope was not entered before command dispatch', {
|
|
65
|
+
code: 'SYSTEM.SCOPE.NOT_ENTERED',
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
record(PRE_ACTION_PHASES.hostStartEffects);
|
|
69
|
+
scope.diagnostics.event('load', 'debug', `${tools.list().length} tool(s) loaded`);
|
|
70
|
+
scope.diagnostics.counter('tools.loaded', tools.list().length);
|
|
71
|
+
getMeter('opensip-cli').createCounter('opensip_cli.commands.started').add(1, {
|
|
72
|
+
command: plan.commandName,
|
|
73
|
+
});
|
|
74
|
+
scope.diagnostics.event('validate', 'debug', `project config resolved (scope: ${plan.project.scope})`);
|
|
75
|
+
runLogger.info({
|
|
76
|
+
evt: 'cli.run.start',
|
|
77
|
+
module: MODULE_TAG,
|
|
78
|
+
runId: plan.runId,
|
|
79
|
+
command: plan.commandName,
|
|
80
|
+
cwd: plan.cwd,
|
|
81
|
+
projectRoot: plan.project.projectRoot,
|
|
82
|
+
scope: plan.project.scope,
|
|
83
|
+
});
|
|
84
|
+
if (plan.project.walkedUp > 0) {
|
|
85
|
+
runLogger.info({
|
|
86
|
+
evt: 'cli.project.discovered',
|
|
87
|
+
module: MODULE_TAG,
|
|
88
|
+
runId: plan.runId,
|
|
89
|
+
cwd: plan.cwd,
|
|
90
|
+
projectRoot: plan.project.projectRoot,
|
|
91
|
+
walkedUp: plan.project.walkedUp,
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
d.startProfiling(scope, plan.commandName);
|
|
95
|
+
record(PRE_ACTION_PHASES.toolPreflight);
|
|
96
|
+
await d.maybeInitializeOwningTool(tools, plan.commandName, plan.runId);
|
|
97
|
+
const driven = await d.loadOwningToolCapabilities({
|
|
98
|
+
owningTool: d.resolveOwningTool(tools, plan.commandName),
|
|
99
|
+
projectDir: plan.project.projectRoot,
|
|
100
|
+
configPath: plan.project.scope === 'project' ? plan.project.configPath : undefined,
|
|
101
|
+
});
|
|
102
|
+
if (driven > 0) {
|
|
103
|
+
scope.diagnostics.event('load', 'debug', `drove ${String(driven)} owning-tool capability domain(s) (see per-domain 'capability ... loaded' events for contribution counts + errors)`);
|
|
104
|
+
scope.diagnostics.counter('capabilities.driven', driven);
|
|
105
|
+
}
|
|
106
|
+
return { scope, runLogger };
|
|
107
|
+
}
|
|
108
|
+
//# sourceMappingURL=execute-post-bailout-bootstrap.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"execute-post-bailout-bootstrap.js","sourceRoot":"","sources":["../../src/bootstrap/execute-post-bailout-bootstrap.ts"],"names":[],"mappings":"AAAA,qLAAqL;AACr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,CAAC,WAAW,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;IAEvE,MAAM,MAAM,GAAG,MAAM,CAAC,CAAC,0BAA0B,CAAC;QAChD,UAAU,EAAE,CAAC,CAAC,iBAAiB,CAAC,KAAK,EAAE,IAAI,CAAC,WAAW,CAAC;QACxD,UAAU,EAAE,IAAI,CAAC,OAAO,CAAC,WAAW;QACpC,UAAU,EAAE,IAAI,CAAC,OAAO,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,SAAS;KACnF,CAAC,CAAC;IACH,IAAI,MAAM,GAAG,CAAC,EAAE,CAAC;QACf,KAAK,CAAC,WAAW,CAAC,KAAK,CACrB,MAAM,EACN,OAAO,EACP,SAAS,MAAM,CAAC,MAAM,CAAC,oHAAoH,CAC5I,CAAC;QACF,KAAK,CAAC,WAAW,CAAC,OAAO,CAAC,qBAAqB,EAAE,MAAM,CAAC,CAAC;IAC3D,CAAC;IAED,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC;AAC9B,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* plan-pre-action-bootstrap — pure planner for the pre-action bootstrap
|
|
3
|
+
* phases through the bailout window (ADR-0052).
|
|
4
|
+
*
|
|
5
|
+
* Does NOT mutate the process-wide logger, enter a scope, or open a
|
|
6
|
+
* datastore. Returns a {@link PreActionBootstrapPlan} the hook (or tests)
|
|
7
|
+
* pass to the post-bailout executor.
|
|
8
|
+
*/
|
|
9
|
+
import { type LoggerOptions, type ProjectContext, type ToolRegistry } from '@opensip-cli/core';
|
|
10
|
+
import { PRE_ACTION_PHASES } from './pre-action-bootstrap-phases.js';
|
|
11
|
+
import type { loadCliDefaults as loadCliDefaultsFn } from './cli-defaults.js';
|
|
12
|
+
export interface PlanPreActionBootstrapInput {
|
|
13
|
+
readonly opts: Record<string, unknown>;
|
|
14
|
+
readonly cwd: string;
|
|
15
|
+
readonly cwdExplicit: boolean;
|
|
16
|
+
readonly runId: string;
|
|
17
|
+
readonly commandName: string;
|
|
18
|
+
readonly explicitConfigPath?: string;
|
|
19
|
+
readonly tools: ToolRegistry;
|
|
20
|
+
}
|
|
21
|
+
export interface PreActionBootstrapPlan {
|
|
22
|
+
readonly runId: string;
|
|
23
|
+
readonly cwd: string;
|
|
24
|
+
readonly cwdExplicit: boolean;
|
|
25
|
+
readonly opts: Record<string, unknown>;
|
|
26
|
+
readonly cliDefaults: ReturnType<typeof loadCliDefaultsFn>;
|
|
27
|
+
readonly project: ProjectContext;
|
|
28
|
+
readonly commandName: string;
|
|
29
|
+
readonly extraAgnostic: ReadonlySet<string>;
|
|
30
|
+
readonly jsonOutput: boolean;
|
|
31
|
+
/** Per-run logger options computed after bailouts (ADR-0053). */
|
|
32
|
+
readonly runLoggerOptions: LoggerOptions;
|
|
33
|
+
readonly completedThrough: typeof PRE_ACTION_PHASES.bailoutWindow;
|
|
34
|
+
}
|
|
35
|
+
/** Collect tool CommandSpecs that declare `scope: 'none'` for no-project guard. */
|
|
36
|
+
export declare function collectExtraAgnosticCommands(tools: ToolRegistry): ReadonlySet<string>;
|
|
37
|
+
/**
|
|
38
|
+
* Plan phases 1–4 (read options through bailout window). Throws
|
|
39
|
+
* {@link BootstrapError} on config-resolve or bailout failures.
|
|
40
|
+
*
|
|
41
|
+
* @throws {BootstrapError} When config resolution fails or an early bootstrap
|
|
42
|
+
* guard bails out before project side effects are allowed.
|
|
43
|
+
*/
|
|
44
|
+
export declare function planPreActionBootstrap(input: PlanPreActionBootstrapInput): PreActionBootstrapPlan;
|
|
45
|
+
//# sourceMappingURL=plan-pre-action-bootstrap.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plan-pre-action-bootstrap.d.ts","sourceRoot":"","sources":["../../src/bootstrap/plan-pre-action-bootstrap.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,OAAO,EAGL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AAgB,4BAA4B,CAAC,KAAK,EAAE,YAAY,GAAG,WAAW,CAAC,MAAM,CAAC,CAarF;AAED;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,2BAA2B,GAAG,sBAAsB,CAsDjG"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* plan-pre-action-bootstrap — pure planner for the pre-action bootstrap
|
|
3
|
+
* phases through the bailout window (ADR-0052).
|
|
4
|
+
*
|
|
5
|
+
* Does NOT mutate the process-wide logger, enter a scope, or open a
|
|
6
|
+
* datastore. Returns a {@link PreActionBootstrapPlan} the hook (or tests)
|
|
7
|
+
* pass to the post-bailout executor.
|
|
8
|
+
*/
|
|
9
|
+
import { existsSync } from 'node:fs';
|
|
10
|
+
import { resolveProjectContext, resolveProjectPaths, } from '@opensip-cli/core';
|
|
11
|
+
import { BootstrapError } from './bootstrap-error.js';
|
|
12
|
+
import { loadCliDefaults, mergeConfigDefaults } from './cli-defaults.js';
|
|
13
|
+
import { PRE_ACTION_PHASES } from './pre-action-bootstrap-phases.js';
|
|
14
|
+
import { checkNoProjectAndBailout, checkSchemaVersionAndBailout, warnAboutPhantomRuntimes, } from './pre-action-guards.js';
|
|
15
|
+
/** Collect tool CommandSpecs that declare `scope: 'none'` for no-project guard. */
|
|
16
|
+
export function collectExtraAgnosticCommands(tools) {
|
|
17
|
+
const extra = new Set();
|
|
18
|
+
for (const tool of tools.list()) {
|
|
19
|
+
for (const c of tool.commands || []) {
|
|
20
|
+
if (c.scope === 'none') {
|
|
21
|
+
extra.add(c.name);
|
|
22
|
+
for (const alias of c.aliases ?? []) {
|
|
23
|
+
extra.add(alias);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return extra;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Plan phases 1–4 (read options through bailout window). Throws
|
|
32
|
+
* {@link BootstrapError} on config-resolve or bailout failures.
|
|
33
|
+
*
|
|
34
|
+
* @throws {BootstrapError} When config resolution fails or an early bootstrap
|
|
35
|
+
* guard bails out before project side effects are allowed.
|
|
36
|
+
*/
|
|
37
|
+
export function planPreActionBootstrap(input) {
|
|
38
|
+
const { opts, cwd, cwdExplicit, runId, commandName, tools, explicitConfigPath } = input;
|
|
39
|
+
const cliDefaults = loadCliDefaults(cwd, explicitConfigPath);
|
|
40
|
+
mergeConfigDefaults(opts, cliDefaults);
|
|
41
|
+
let project;
|
|
42
|
+
try {
|
|
43
|
+
project = resolveProjectContext({
|
|
44
|
+
cwd,
|
|
45
|
+
cwdExplicit,
|
|
46
|
+
explicitConfigPath,
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
catch (error) {
|
|
50
|
+
const msg = error instanceof Error ? error.message : String(error);
|
|
51
|
+
throw new BootstrapError({
|
|
52
|
+
message: msg,
|
|
53
|
+
humanMessage: `✗ ${msg}`,
|
|
54
|
+
suggestion: 'Check opensip-cli.config.yml (or your --config path).',
|
|
55
|
+
exitCode: 2,
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
opts.projectContext = project;
|
|
59
|
+
opts.cwdExplicit = cwdExplicit;
|
|
60
|
+
const extraAgnostic = collectExtraAgnosticCommands(tools);
|
|
61
|
+
checkSchemaVersionAndBailout(project, runId);
|
|
62
|
+
checkNoProjectAndBailout(project, cwd, commandName, runId, extraAgnostic);
|
|
63
|
+
warnAboutPhantomRuntimes(project, opts.json === true);
|
|
64
|
+
const runLoggerOptions = {
|
|
65
|
+
silent: true,
|
|
66
|
+
debugMode: Boolean(opts.debug),
|
|
67
|
+
runId,
|
|
68
|
+
...(project.scope === 'project' && existsSync(project.projectRoot)
|
|
69
|
+
? { logDir: resolveProjectPaths(project.projectRoot).logsDir }
|
|
70
|
+
: {}),
|
|
71
|
+
};
|
|
72
|
+
return {
|
|
73
|
+
runId,
|
|
74
|
+
cwd,
|
|
75
|
+
cwdExplicit,
|
|
76
|
+
opts,
|
|
77
|
+
cliDefaults,
|
|
78
|
+
project,
|
|
79
|
+
commandName,
|
|
80
|
+
extraAgnostic,
|
|
81
|
+
jsonOutput: opts.json === true,
|
|
82
|
+
runLoggerOptions,
|
|
83
|
+
completedThrough: PRE_ACTION_PHASES.bailoutWindow,
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
//# sourceMappingURL=plan-pre-action-bootstrap.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plan-pre-action-bootstrap.js","sourceRoot":"","sources":["../../src/bootstrap/plan-pre-action-bootstrap.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAErC,OAAO,EACL,qBAAqB,EACrB,mBAAmB,GAIpB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACzE,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AACrE,OAAO,EACL,wBAAwB,EACxB,4BAA4B,EAC5B,wBAAwB,GACzB,MAAM,wBAAwB,CAAC;AA6BhC,mFAAmF;AACnF,MAAM,UAAU,4BAA4B,CAAC,KAAmB;IAC9D,MAAM,KAAK,GAAG,IAAI,GAAG,EAAU,CAAC;IAChC,KAAK,MAAM,IAAI,IAAI,KAAK,CAAC,IAAI,EAAE,EAAE,CAAC;QAChC,KAAK,MAAM,CAAC,IAAI,IAAI,CAAC,QAAQ,IAAI,EAAE,EAAE,CAAC;YACpC,IAAI,CAAC,CAAC,KAAK,KAAK,MAAM,EAAE,CAAC;gBACvB,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;gBAClB,KAAK,MAAM,KAAK,IAAI,CAAC,CAAC,OAAO,IAAI,EAAE,EAAE,CAAC;oBACpC,KAAK,CAAC,GAAG,CAAC,KA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,gBAAgB,GAAkB;QACtC,MAAM,EAAE,IAAI;QACZ,SAAS,EAAE,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC;QAC9B,KAAK;QACL,GAAG,CAAC,OAAO,CAAC,KAAK,KAAK,SAAS,IAAI,UAAU,CAAC,OAAO,CAAC,WAAW,CAAC;YAChE,CAAC,CAAC,EAAE,MAAM,EAAE,mBAAmB,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,OAAO,EAAE;YAC9D,CAAC,CAAC,EAAE,CAAC;KACR,CAAC;IAEF,OAAO;QACL,KAAK;QACL,GAAG;QACH,WAAW;QACX,IAAI;QACJ,WAAW;QACX,OAAO;QACP,WAAW;QACX,aAAa;QACb,UAAU,EAAE,IAAI,CAAC,IAAI,KAAK,IAAI;QAC9B,gBAAgB;QAChB,gBAAgB,EAAE,iBAAiB,CAAC,aAAa;KAClD,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Canonical bootstrap phase names (ADR-0052). The hook is the Commander
|
|
3
|
+
* adapter; business rules live behind the planner and post-bailout executor.
|
|
4
|
+
*/
|
|
5
|
+
export declare const PRE_ACTION_PHASES: {
|
|
6
|
+
readonly readCommandOptions: "read-command-options";
|
|
7
|
+
readonly mergeCliDefaults: "merge-cli-defaults";
|
|
8
|
+
readonly resolveProject: "resolve-project";
|
|
9
|
+
readonly bailoutWindow: "bailout-window";
|
|
10
|
+
readonly projectSideEffects: "project-side-effects";
|
|
11
|
+
readonly buildScope: "build-scope";
|
|
12
|
+
readonly enterScope: "enter-scope";
|
|
13
|
+
readonly hostStartEffects: "host-start-effects";
|
|
14
|
+
readonly toolPreflight: "tool-preflight";
|
|
15
|
+
readonly dispose: "dispose";
|
|
16
|
+
};
|
|
17
|
+
export type PreActionPhase = (typeof PRE_ACTION_PHASES)[keyof typeof PRE_ACTION_PHASES];
|
|
18
|
+
/** Post-bailout phases in load-bearing order (phases 5–9 of ADR-0052). */
|
|
19
|
+
export declare const POST_BAILOUT_PHASE_ORDER: readonly PreActionPhase[];
|
|
20
|
+
//# sourceMappingURL=pre-action-bootstrap-phases.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pre-action-bootstrap-phases.d.ts","sourceRoot":"","sources":["../../src/bootstrap/pre-action-bootstrap-phases.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,eAAO,MAAM,iBAAiB;;;;;;;;;;;CAWpB,CAAC;AAEX,MAAM,MAAM,cAAc,GAAG,CAAC,OAAO,iBAAiB,CAAC,CAAC,MAAM,OAAO,iBAAiB,CAAC,CAAC;AAExF,0EAA0E;AAC1E,eAAO,MAAM,wBAAwB,EAAE,SAAS,cAAc,EAMpD,CAAC"}
|