@codyswann/lisa 4.101.4 → 4.101.6
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/core/nightly-e2e-guard-behavior-certificate.js +2 -2
- package/dist/core/upstream-evidence-manifest.d.ts.map +1 -1
- package/dist/core/upstream-evidence-manifest.js +24 -5
- package/dist/core/upstream-evidence-manifest.js.map +1 -1
- package/dist/opencode/hooks-installer.d.ts.map +1 -1
- package/dist/opencode/hooks-installer.js +8 -0
- package/dist/opencode/hooks-installer.js.map +1 -1
- package/dist/opencode/plugin-catalog.d.ts.map +1 -1
- package/dist/opencode/plugin-catalog.js +5 -0
- package/dist/opencode/plugin-catalog.js.map +1 -1
- package/dist/opencode/plugin-templates/block-host-name-leak.mjs +511 -0
- package/dist/opencode/plugin-templates/block-host-name-leak.sh +69 -0
- package/dist/opencode/plugin-templates/host-name-command-context.mjs +455 -0
- package/dist/opencode/plugin-templates/lisa-block-host-name-leak.ts +62 -0
- package/package.json +4 -4
- package/plugins/lisa/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa/.codex-plugin/scripts/automation-run-record.mjs +678 -0
- package/plugins/lisa/.codex-plugin/scripts/blocker-edge-resolution.mjs +150 -0
- package/plugins/lisa/.codex-plugin/scripts/intake-blocker-reprobe.mjs +1379 -0
- package/plugins/lisa/.codex-plugin/scripts/intake-prework-denominator.mjs +249 -0
- package/plugins/lisa/.codex-plugin/scripts/operator-id-kinds.mjs +120 -0
- package/plugins/lisa/.codex-plugin/scripts/qa-signal-lifecycle.mjs +523 -0
- package/plugins/lisa/.codex-plugin/scripts/ready-queue-order.mjs +549 -0
- package/plugins/lisa/.codex-plugin/scripts/resolve-lifecycle-role.mjs +347 -0
- package/plugins/lisa/hooks/block-host-name-leak.mjs +11 -5
- package/plugins/lisa/hooks/host-name-command-context.mjs +45 -2
- package/plugins/lisa-agy/hooks/block-host-name-leak.mjs +11 -5
- package/plugins/lisa-agy/hooks/host-name-command-context.mjs +45 -2
- package/plugins/lisa-agy/plugin.json +1 -1
- package/plugins/lisa-cdk/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-cdk/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-cdk-agy/plugin.json +1 -1
- package/plugins/lisa-cdk-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-cdk-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-cdk-devin/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-cdk-devin/.devin-plugin/plugin.json +1 -1
- package/plugins/lisa-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-copilot/hooks/block-host-name-leak.mjs +11 -5
- package/plugins/lisa-copilot/hooks/host-name-command-context.mjs +45 -2
- package/plugins/lisa-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-cursor/hooks/block-host-name-leak.mjs +11 -5
- package/plugins/lisa-cursor/hooks/host-name-command-context.mjs +45 -2
- package/plugins/lisa-devin/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-devin/.devin-plugin/plugin.json +1 -1
- package/plugins/lisa-devin/hooks/block-host-name-leak.mjs +11 -5
- package/plugins/lisa-devin/hooks/host-name-command-context.mjs +45 -2
- package/plugins/lisa-expo/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-expo/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-expo-agy/plugin.json +1 -1
- package/plugins/lisa-expo-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-expo-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-expo-devin/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-expo-devin/.devin-plugin/plugin.json +1 -1
- package/plugins/lisa-harper-fabric/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-harper-fabric/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-harper-fabric-agy/plugin.json +1 -1
- package/plugins/lisa-harper-fabric-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-harper-fabric-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-harper-fabric-devin/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-harper-fabric-devin/.devin-plugin/plugin.json +1 -1
- package/plugins/lisa-nestjs/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-nestjs/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-nestjs-agy/plugin.json +1 -1
- package/plugins/lisa-nestjs-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-nestjs-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-nestjs-devin/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-nestjs-devin/.devin-plugin/plugin.json +1 -1
- package/plugins/lisa-openclaw/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-openclaw/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-openclaw-agy/plugin.json +1 -1
- package/plugins/lisa-openclaw-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-openclaw-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-openclaw-devin/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-openclaw-devin/.devin-plugin/plugin.json +1 -1
- package/plugins/lisa-phaser/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-phaser/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-phaser-agy/plugin.json +1 -1
- package/plugins/lisa-phaser-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-phaser-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-phaser-devin/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-phaser-devin/.devin-plugin/plugin.json +1 -1
- package/plugins/lisa-rails/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-rails/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-rails-agy/plugin.json +1 -1
- package/plugins/lisa-rails-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-rails-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-rails-devin/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-rails-devin/.devin-plugin/plugin.json +1 -1
- package/plugins/lisa-typescript/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-typescript/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-typescript-agy/plugin.json +1 -1
- package/plugins/lisa-typescript-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-typescript-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-typescript-devin/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-typescript-devin/.devin-plugin/plugin.json +1 -1
- package/plugins/lisa-wiki/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-wiki/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-wiki-agy/plugin.json +1 -1
- package/plugins/lisa-wiki-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-wiki-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-wiki-devin/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-wiki-devin/.devin-plugin/plugin.json +1 -1
- package/plugins/src/base/hooks/block-host-name-leak.mjs +11 -5
- package/plugins/src/base/hooks/host-name-command-context.mjs +45 -2
- package/scripts/copy-opencode-plugin-templates.mjs +3 -0
- package/scripts/generate-codex-plugin-artifacts.mjs +6 -0
- package/scripts/lib/codex-shared-scripts.mjs +156 -0
- package/scripts/lib/host-name-launcher-cases.mjs +280 -0
- package/scripts/verify-host-name-target-scope.mjs +9 -0
|
@@ -0,0 +1,347 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Lifecycle-role resolution — the single resolver for every vendor.
|
|
4
|
+
*
|
|
5
|
+
* ## The defect this replaces
|
|
6
|
+
*
|
|
7
|
+
* Twelve skills inlined their own `read_role()` bash helper. Hashing the
|
|
8
|
+
* function bodies produced ELEVEN distinct implementations — only
|
|
9
|
+
* `lisa-linear-build-intake` and `lisa-linear-evidence` agreed. Copy-paste with
|
|
10
|
+
* no shared source is why the three vendors drifted apart on the same contract.
|
|
11
|
+
*
|
|
12
|
+
* The drift was not cosmetic. `lisa-linear-evidence` resolved
|
|
13
|
+
* `read_role review "In Review"` — a NON-EMPTY default — while
|
|
14
|
+
* `lisa-jira-evidence/scripts/post-evidence.sh` resolved the same role with
|
|
15
|
+
* `REVIEW=""` and an explicit skip branch. Same role, opposite behaviour, on the
|
|
16
|
+
* question of whether an unconfigured review step exists at all.
|
|
17
|
+
*
|
|
18
|
+
* ## R1 — absent means SKIP, never default
|
|
19
|
+
*
|
|
20
|
+
* `ready`, `claimed`, `blocked` and `done` are REQUIRED: a project that omits
|
|
21
|
+
* them is misconfigured and the caller should say so. `review` and the `qa.*`
|
|
22
|
+
* roles are OPTIONAL and have NO built-in default, so omitting one means the
|
|
23
|
+
* lifecycle skips that transition entirely.
|
|
24
|
+
*
|
|
25
|
+
* This is the difference between "not customized" and "we don't do this step",
|
|
26
|
+
* which a defaulting resolver cannot express. Measured downstream: a project
|
|
27
|
+
* deliberately bound no `review` role — a PR-open ticket was meant to stay in
|
|
28
|
+
* `claimed` until it reached an environment — and agents moved issues into a
|
|
29
|
+
* human-only review state anyway, because every layer that could have honoured
|
|
30
|
+
* the omission supplied a default instead.
|
|
31
|
+
*
|
|
32
|
+
* ## R2 — a fallback may inform a READ, never supply a WRITE target
|
|
33
|
+
*
|
|
34
|
+
* Linear states carry a machine-readable `type`, so a skill may fall back to
|
|
35
|
+
* resolving a role by type when the configured name is missing — the
|
|
36
|
+
* `config-resolution` rule permits this "but only to *read* … it must never
|
|
37
|
+
* invent a state to write into."
|
|
38
|
+
*
|
|
39
|
+
* Nothing enforced that sentence. The fallback selects the lowest-position
|
|
40
|
+
* `started` state, and on the board where this was measured the states ranked
|
|
41
|
+
* `blocked` (-1989.26), `claimed` (-1478.50), then two unbound human-only review
|
|
42
|
+
* states at -1209.69 and -1079.70. With `blocked` and `claimed` already taken,
|
|
43
|
+
* the fallback returned the first unbound one — precisely where two issues
|
|
44
|
+
* landed. Not fuzzy matching; position ordering, used for a write.
|
|
45
|
+
*
|
|
46
|
+
* `--intent=write` therefore refuses to return a fallback value and reports a
|
|
47
|
+
* setup defect instead. `--intent=read` may use one, and always reports which.
|
|
48
|
+
*
|
|
49
|
+
* ## Why a script rather than a shared bash snippet
|
|
50
|
+
*
|
|
51
|
+
* A snippet is copy-paste, which is the disease. Skills shell out to
|
|
52
|
+
* `${CLAUDE_PLUGIN_ROOT}/scripts/…` for exactly this reason elsewhere
|
|
53
|
+
* (`lifecycle-label-trust.mjs`, `automation-run-record.mjs`), and a real process
|
|
54
|
+
* boundary means the resolution can be unit-tested rather than re-read.
|
|
55
|
+
* @module scripts/resolve-lifecycle-role
|
|
56
|
+
*/
|
|
57
|
+
|
|
58
|
+
import { readFileSync, realpathSync } from "node:fs";
|
|
59
|
+
import { fileURLToPath } from "node:url";
|
|
60
|
+
|
|
61
|
+
/** Config file consulted first; its keys override the committed file. */
|
|
62
|
+
export const LOCAL_CONFIG = ".lisa.config.local.json";
|
|
63
|
+
|
|
64
|
+
/** The committed config file. */
|
|
65
|
+
export const GLOBAL_CONFIG = ".lisa.config.json";
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Roles a project MUST bind. Omitting one is a setup defect, not a policy
|
|
69
|
+
* choice — there is no coherent lifecycle without a ready lane, a claimed lane,
|
|
70
|
+
* a blocked lane and a terminal.
|
|
71
|
+
*/
|
|
72
|
+
export const REQUIRED_ROLES = Object.freeze([
|
|
73
|
+
"ready",
|
|
74
|
+
"claimed",
|
|
75
|
+
"blocked",
|
|
76
|
+
"done",
|
|
77
|
+
]);
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Roles a project MAY bind. Omitting one means the lifecycle skips that
|
|
81
|
+
* transition. These have NO built-in default — that is the whole point of R1.
|
|
82
|
+
*/
|
|
83
|
+
export const OPTIONAL_ROLES = Object.freeze(["review", "human_needed"]);
|
|
84
|
+
|
|
85
|
+
/** Where each vendor keeps its build lifecycle role map. */
|
|
86
|
+
export const VENDOR_ROOTS = Object.freeze({
|
|
87
|
+
jira: "jira.workflow",
|
|
88
|
+
linear: "linear.workflow",
|
|
89
|
+
github: "github.labels.build",
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
/** GitHub's PRD lifecycle is a separate required role map from build work. */
|
|
93
|
+
const GITHUB_PRD_PREFIX = "prd.";
|
|
94
|
+
|
|
95
|
+
/** Resolution outcomes, reported so a caller never has to guess what happened. */
|
|
96
|
+
export const OUTCOMES = Object.freeze({
|
|
97
|
+
CONFIGURED: "configured",
|
|
98
|
+
UNSET_OPTIONAL: "unset-optional",
|
|
99
|
+
UNSET_REQUIRED: "unset-required",
|
|
100
|
+
FALLBACK_REFUSED: "fallback-refused-for-write",
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Read a dotted path out of a parsed config object.
|
|
105
|
+
*
|
|
106
|
+
* @param {unknown} source parsed config
|
|
107
|
+
* @param {string} path dotted key path, e.g. `linear.workflow.review`
|
|
108
|
+
* @returns {unknown} the value, or undefined when any segment is missing
|
|
109
|
+
*/
|
|
110
|
+
export const readPath = (source, path) => {
|
|
111
|
+
let cursor = source;
|
|
112
|
+
for (const segment of path.split(".")) {
|
|
113
|
+
if (cursor === null || typeof cursor !== "object" || !(segment in cursor))
|
|
114
|
+
return undefined;
|
|
115
|
+
cursor = cursor[segment];
|
|
116
|
+
}
|
|
117
|
+
return cursor;
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Parse a config file, treating an unreadable or malformed file as absent.
|
|
122
|
+
*
|
|
123
|
+
* A malformed local override must not silently mask the committed file, so the
|
|
124
|
+
* caller is told which files actually parsed via the returned `sources`.
|
|
125
|
+
*
|
|
126
|
+
* @param {string} file path to read
|
|
127
|
+
* @returns {{ value: object | undefined, error: string | undefined }} parse result
|
|
128
|
+
*/
|
|
129
|
+
export const parseConfig = file => {
|
|
130
|
+
let raw;
|
|
131
|
+
try {
|
|
132
|
+
raw = readFileSync(file, "utf8");
|
|
133
|
+
} catch {
|
|
134
|
+
return { value: undefined, error: undefined };
|
|
135
|
+
}
|
|
136
|
+
try {
|
|
137
|
+
return { value: JSON.parse(raw), error: undefined };
|
|
138
|
+
} catch (cause) {
|
|
139
|
+
return {
|
|
140
|
+
value: undefined,
|
|
141
|
+
error: `${file} is not valid JSON: ${cause.message}`,
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Resolve one lifecycle role for one vendor.
|
|
148
|
+
*
|
|
149
|
+
* Resolution order is local config → global config → (nothing). There is no
|
|
150
|
+
* built-in default tier: see R1 in the module docblock.
|
|
151
|
+
*
|
|
152
|
+
* @param {object} options resolution inputs
|
|
153
|
+
* @param {string} options.role role name (`ready`, `review`, `human_needed`, …)
|
|
154
|
+
* @param {string} options.vendor one of `jira` | `linear` | `github`
|
|
155
|
+
* @param {"read" | "write"} [options.intent] what the caller will do with it
|
|
156
|
+
* @param {string} [options.env] env key when resolving the env-keyed `done` map
|
|
157
|
+
* @param {object} [options.local] pre-parsed local config (tests)
|
|
158
|
+
* @param {object} [options.global] pre-parsed global config (tests)
|
|
159
|
+
* @param {string} [options.fallback] a value a vendor fallback would supply
|
|
160
|
+
* @returns {{ value: string, outcome: string, source: string, message: string }} resolution
|
|
161
|
+
*/
|
|
162
|
+
export const resolveRole = ({
|
|
163
|
+
role,
|
|
164
|
+
vendor,
|
|
165
|
+
intent = "read",
|
|
166
|
+
env,
|
|
167
|
+
local,
|
|
168
|
+
global: globalConfig,
|
|
169
|
+
fallback,
|
|
170
|
+
}) => {
|
|
171
|
+
let root = VENDOR_ROOTS[vendor];
|
|
172
|
+
let configuredRole = role;
|
|
173
|
+
if (vendor === "github" && role.startsWith(GITHUB_PRD_PREFIX)) {
|
|
174
|
+
root = "github.labels.prd";
|
|
175
|
+
configuredRole = role.slice(GITHUB_PRD_PREFIX.length);
|
|
176
|
+
}
|
|
177
|
+
if (!root) {
|
|
178
|
+
return {
|
|
179
|
+
value: "",
|
|
180
|
+
outcome: OUTCOMES.UNSET_REQUIRED,
|
|
181
|
+
source: "none",
|
|
182
|
+
message: `Unknown vendor '${vendor}'. Expected one of: ${Object.keys(VENDOR_ROOTS).join(", ")}.`,
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
// `done` is env-keyed on every vendor; an env selects one rung of the map.
|
|
187
|
+
const path =
|
|
188
|
+
env && configuredRole === "done"
|
|
189
|
+
? `${root}.done.${env}`
|
|
190
|
+
: `${root}.${configuredRole}`;
|
|
191
|
+
|
|
192
|
+
for (const [label, source] of [
|
|
193
|
+
["local", local],
|
|
194
|
+
["global", globalConfig],
|
|
195
|
+
]) {
|
|
196
|
+
const found = readPath(source, path);
|
|
197
|
+
if (typeof found === "string" && found.length > 0) {
|
|
198
|
+
return {
|
|
199
|
+
value: found,
|
|
200
|
+
outcome: OUTCOMES.CONFIGURED,
|
|
201
|
+
source: label,
|
|
202
|
+
message: `${path} = ${found} (from ${label} config)`,
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
const optional =
|
|
208
|
+
!role.startsWith(GITHUB_PRD_PREFIX) &&
|
|
209
|
+
OPTIONAL_ROLES.includes(configuredRole);
|
|
210
|
+
|
|
211
|
+
// R2 — a fallback may inform a read, never supply a write target.
|
|
212
|
+
if (fallback && intent === "write") {
|
|
213
|
+
return {
|
|
214
|
+
value: "",
|
|
215
|
+
outcome: OUTCOMES.FALLBACK_REFUSED,
|
|
216
|
+
source: "none",
|
|
217
|
+
message:
|
|
218
|
+
`Refusing to write to '${fallback}': it was derived by fallback, not named at ${path}. ` +
|
|
219
|
+
`A fallback may inform a read but must never supply a write target (config-resolution). ` +
|
|
220
|
+
`Bind ${path} explicitly, or run /lisa:setup:${vendor}.`,
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
if (fallback) {
|
|
224
|
+
return {
|
|
225
|
+
value: fallback,
|
|
226
|
+
outcome: OUTCOMES.CONFIGURED,
|
|
227
|
+
source: "fallback",
|
|
228
|
+
message: `${path} is unset; using fallback '${fallback}' for a READ only.`,
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
if (optional) {
|
|
233
|
+
return {
|
|
234
|
+
value: "",
|
|
235
|
+
outcome: OUTCOMES.UNSET_OPTIONAL,
|
|
236
|
+
source: "none",
|
|
237
|
+
message:
|
|
238
|
+
`No ${path} configured; skipping the ${role} transition. ` +
|
|
239
|
+
`This is a supported configuration, not an error — the item stays in its current role.`,
|
|
240
|
+
};
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
return {
|
|
244
|
+
value: "",
|
|
245
|
+
outcome: OUTCOMES.UNSET_REQUIRED,
|
|
246
|
+
source: "none",
|
|
247
|
+
message: `Required role '${role}' is not configured at ${path}. Run /lisa:setup:${vendor}.`,
|
|
248
|
+
};
|
|
249
|
+
};
|
|
250
|
+
|
|
251
|
+
/**
|
|
252
|
+
* Parse `--key=value` / `--key value` argv into a plain object.
|
|
253
|
+
*
|
|
254
|
+
* @param {string[]} argv raw arguments
|
|
255
|
+
* @returns {Record<string, string>} parsed flags
|
|
256
|
+
*/
|
|
257
|
+
export const parseArgs = argv => {
|
|
258
|
+
const out = {};
|
|
259
|
+
for (let index = 0; index < argv.length; index += 1) {
|
|
260
|
+
const token = argv[index];
|
|
261
|
+
if (!token.startsWith("--")) continue;
|
|
262
|
+
const [key, inline] = token.slice(2).split("=");
|
|
263
|
+
if (inline !== undefined) {
|
|
264
|
+
out[key] = inline;
|
|
265
|
+
continue;
|
|
266
|
+
}
|
|
267
|
+
const next = argv[index + 1];
|
|
268
|
+
if (next && !next.startsWith("--")) {
|
|
269
|
+
out[key] = next;
|
|
270
|
+
index += 1;
|
|
271
|
+
} else {
|
|
272
|
+
out[key] = "true";
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
return out;
|
|
276
|
+
};
|
|
277
|
+
|
|
278
|
+
/**
|
|
279
|
+
* CLI entry point.
|
|
280
|
+
*
|
|
281
|
+
* Exit codes are the contract callers branch on:
|
|
282
|
+
* - `0` with a value on stdout — the role is configured (or a read fallback).
|
|
283
|
+
* - `0` with EMPTY stdout — an optional role is unset; skip the transition.
|
|
284
|
+
* - `2` — a required role is unset, or a write was refused a fallback value.
|
|
285
|
+
*
|
|
286
|
+
* The distinction between the two `0` cases is deliberate: an unset optional
|
|
287
|
+
* role is a supported configuration, so it must not look like a failure.
|
|
288
|
+
*
|
|
289
|
+
* @param {string[]} argv arguments after the script name
|
|
290
|
+
* @returns {number} process exit code
|
|
291
|
+
*/
|
|
292
|
+
export const main = argv => {
|
|
293
|
+
const args = parseArgs(argv);
|
|
294
|
+
if (!args.role || !args.vendor) {
|
|
295
|
+
process.stderr.write(
|
|
296
|
+
"usage: resolve-lifecycle-role.mjs --role <name> --vendor <jira|linear|github> " +
|
|
297
|
+
"[--intent read|write] [--env dev|staging|production] [--fallback <name>]\n"
|
|
298
|
+
);
|
|
299
|
+
return 2;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
const local = parseConfig(args.local ?? LOCAL_CONFIG);
|
|
303
|
+
const globalConfig = parseConfig(args.config ?? GLOBAL_CONFIG);
|
|
304
|
+
for (const parsed of [local, globalConfig]) {
|
|
305
|
+
if (parsed.error) {
|
|
306
|
+
process.stderr.write(`${parsed.error}\n`);
|
|
307
|
+
return 2;
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
const result = resolveRole({
|
|
312
|
+
role: args.role,
|
|
313
|
+
vendor: args.vendor,
|
|
314
|
+
intent: args.intent ?? "read",
|
|
315
|
+
env: args.env,
|
|
316
|
+
fallback: args.fallback,
|
|
317
|
+
local: local.value,
|
|
318
|
+
global: globalConfig.value,
|
|
319
|
+
});
|
|
320
|
+
|
|
321
|
+
if (args.json === "true") {
|
|
322
|
+
process.stdout.write(`${JSON.stringify(result)}\n`);
|
|
323
|
+
} else if (result.value) {
|
|
324
|
+
process.stdout.write(`${result.value}\n`);
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
if (result.outcome === OUTCOMES.CONFIGURED) return 0;
|
|
328
|
+
if (result.outcome === OUTCOMES.UNSET_OPTIONAL) {
|
|
329
|
+
process.stderr.write(`${result.message}\n`);
|
|
330
|
+
return 0;
|
|
331
|
+
}
|
|
332
|
+
process.stderr.write(`${result.message}\n`);
|
|
333
|
+
return 2;
|
|
334
|
+
};
|
|
335
|
+
|
|
336
|
+
const invokedDirectly = (() => {
|
|
337
|
+
try {
|
|
338
|
+
return (
|
|
339
|
+
realpathSync(process.argv[1] ?? "") ===
|
|
340
|
+
realpathSync(fileURLToPath(import.meta.url))
|
|
341
|
+
);
|
|
342
|
+
} catch {
|
|
343
|
+
return false;
|
|
344
|
+
}
|
|
345
|
+
})();
|
|
346
|
+
|
|
347
|
+
if (invokedDirectly) process.exit(main(process.argv.slice(2)));
|
|
@@ -47,11 +47,13 @@
|
|
|
47
47
|
* `dist/` ships to npm, so **this** repository may not name its hosts. A host
|
|
48
48
|
* naming itself carries none of that.
|
|
49
49
|
*
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
50
|
+
* Claude, Codex, Cursor, Antigravity, Copilot and Devin register the canonical
|
|
51
|
+
* plugin guard. OpenCode installs a native tool.execute.before adapter beside
|
|
52
|
+
* the same wrapper/classifier/helper; its package staging adds only the normal
|
|
53
|
+
* ownership banner. It preserves exit0 warnings and exit2 refusals. All seven
|
|
54
|
+
* surfaces therefore share target-scoped policy, rather than refusing a host
|
|
55
|
+
* project's own name. The generic dispatcher copy-overwrite roster remains
|
|
56
|
+
* separate; this guard is not added to that roster.
|
|
55
57
|
*
|
|
56
58
|
* WHERE IT APPLIES: THE TARGET, NOT THE CHECKOUT (#4462)
|
|
57
59
|
*
|
|
@@ -70,6 +72,10 @@
|
|
|
70
72
|
* routing. Unsupported shell syntax, unresolved expansions and ambiguous
|
|
71
73
|
* repositories earn no host exemption. This is bounded command inspection,
|
|
72
74
|
* not shell execution or a claim to close every shell/identity leak class.
|
|
75
|
+
* Literal one-level sh -c and bash -c executable-script operands reuse that
|
|
76
|
+
* inspection with the inherited directory/environment. No other quoted argv
|
|
77
|
+
* is interpreted as code. Dynamic scripts, deeper nesting, other interpreters
|
|
78
|
+
* and other launcher options remain outside this recognition contract.
|
|
73
79
|
*
|
|
74
80
|
* FAILING OPEN, LOUDLY
|
|
75
81
|
*
|
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
/**
|
|
1
|
+
/**
|
|
2
|
+
* Bounded command/target resolution; submitted scripts are never executed.
|
|
3
|
+
* One literal sh/bash -c script operand is parsed once. Dynamic scripts,
|
|
4
|
+
* deeper launchers, other interpreters and other launcher options are outside
|
|
5
|
+
* this recognition contract, not proof that an unrecognized command is safe.
|
|
6
|
+
*/
|
|
2
7
|
import { execFileSync } from "node:child_process";
|
|
3
8
|
import { statSync } from "node:fs";
|
|
4
9
|
import path from "node:path";
|
|
@@ -204,11 +209,30 @@ export function repositoryFromSpec(spec) {
|
|
|
204
209
|
* @returns {object[]} Active gh calls with their bounded command contexts.
|
|
205
210
|
*/
|
|
206
211
|
export function ghCommands(command, initialCwd, env = process.env) {
|
|
212
|
+
return commandContexts(command, initialCwd, env, true, false);
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
/**
|
|
216
|
+
* Parse a command list, permitting at most one literal executable script slot.
|
|
217
|
+
* @param {string} command Command text, never evaluated.
|
|
218
|
+
* @param {string|undefined} initialCwd Inherited literal directory, if known.
|
|
219
|
+
* @param {object} env Inherited environment.
|
|
220
|
+
* @param {boolean} launcherAllowed Whether one launcher remains in scope.
|
|
221
|
+
* @param {boolean} initialUncertain Whether the parent context is unresolved.
|
|
222
|
+
* @returns {object[]} Active gh calls and their isolated command contexts.
|
|
223
|
+
*/
|
|
224
|
+
function commandContexts(
|
|
225
|
+
command,
|
|
226
|
+
initialCwd,
|
|
227
|
+
env,
|
|
228
|
+
launcherAllowed,
|
|
229
|
+
initialUncertain
|
|
230
|
+
) {
|
|
207
231
|
const calls = [];
|
|
208
232
|
const inherited = { ...env };
|
|
209
233
|
let cwd = initialCwd,
|
|
210
234
|
segment = [],
|
|
211
|
-
uncertain =
|
|
235
|
+
uncertain = initialUncertain;
|
|
212
236
|
const consume = () => {
|
|
213
237
|
if (segment.length === 0) return;
|
|
214
238
|
const local = { ...inherited };
|
|
@@ -263,6 +287,25 @@ export function ghCommands(command, initialCwd, env = process.env) {
|
|
|
263
287
|
env: local,
|
|
264
288
|
certainContext: !uncertain,
|
|
265
289
|
});
|
|
290
|
+
} else if (
|
|
291
|
+
launcherAllowed &&
|
|
292
|
+
segment[index]?.literal &&
|
|
293
|
+
["sh", "bash"].includes(path.basename(executable ?? "")) &&
|
|
294
|
+
segment[index + 1]?.literal &&
|
|
295
|
+
segment[index + 1].value === "-c" &&
|
|
296
|
+
segment[index + 2]?.literal
|
|
297
|
+
) {
|
|
298
|
+
// Only this operand is executable text. Later argv words are $0/$1/etc,
|
|
299
|
+
// not scripts. Child cd/export changes cannot mutate the outer shell.
|
|
300
|
+
calls.push(
|
|
301
|
+
...commandContexts(
|
|
302
|
+
segment[index + 2].value,
|
|
303
|
+
cwd,
|
|
304
|
+
local,
|
|
305
|
+
false,
|
|
306
|
+
uncertain
|
|
307
|
+
)
|
|
308
|
+
);
|
|
266
309
|
} else {
|
|
267
310
|
// A function/source/pushd or unsupported launcher may change the shell
|
|
268
311
|
// context. Do not grant later writes an exemption based on the old cwd.
|
|
@@ -47,11 +47,13 @@
|
|
|
47
47
|
* `dist/` ships to npm, so **this** repository may not name its hosts. A host
|
|
48
48
|
* naming itself carries none of that.
|
|
49
49
|
*
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
50
|
+
* Claude, Codex, Cursor, Antigravity, Copilot and Devin register the canonical
|
|
51
|
+
* plugin guard. OpenCode installs a native tool.execute.before adapter beside
|
|
52
|
+
* the same wrapper/classifier/helper; its package staging adds only the normal
|
|
53
|
+
* ownership banner. It preserves exit0 warnings and exit2 refusals. All seven
|
|
54
|
+
* surfaces therefore share target-scoped policy, rather than refusing a host
|
|
55
|
+
* project's own name. The generic dispatcher copy-overwrite roster remains
|
|
56
|
+
* separate; this guard is not added to that roster.
|
|
55
57
|
*
|
|
56
58
|
* WHERE IT APPLIES: THE TARGET, NOT THE CHECKOUT (#4462)
|
|
57
59
|
*
|
|
@@ -70,6 +72,10 @@
|
|
|
70
72
|
* routing. Unsupported shell syntax, unresolved expansions and ambiguous
|
|
71
73
|
* repositories earn no host exemption. This is bounded command inspection,
|
|
72
74
|
* not shell execution or a claim to close every shell/identity leak class.
|
|
75
|
+
* Literal one-level sh -c and bash -c executable-script operands reuse that
|
|
76
|
+
* inspection with the inherited directory/environment. No other quoted argv
|
|
77
|
+
* is interpreted as code. Dynamic scripts, deeper nesting, other interpreters
|
|
78
|
+
* and other launcher options remain outside this recognition contract.
|
|
73
79
|
*
|
|
74
80
|
* FAILING OPEN, LOUDLY
|
|
75
81
|
*
|
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
/**
|
|
1
|
+
/**
|
|
2
|
+
* Bounded command/target resolution; submitted scripts are never executed.
|
|
3
|
+
* One literal sh/bash -c script operand is parsed once. Dynamic scripts,
|
|
4
|
+
* deeper launchers, other interpreters and other launcher options are outside
|
|
5
|
+
* this recognition contract, not proof that an unrecognized command is safe.
|
|
6
|
+
*/
|
|
2
7
|
import { execFileSync } from "node:child_process";
|
|
3
8
|
import { statSync } from "node:fs";
|
|
4
9
|
import path from "node:path";
|
|
@@ -204,11 +209,30 @@ export function repositoryFromSpec(spec) {
|
|
|
204
209
|
* @returns {object[]} Active gh calls with their bounded command contexts.
|
|
205
210
|
*/
|
|
206
211
|
export function ghCommands(command, initialCwd, env = process.env) {
|
|
212
|
+
return commandContexts(command, initialCwd, env, true, false);
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
/**
|
|
216
|
+
* Parse a command list, permitting at most one literal executable script slot.
|
|
217
|
+
* @param {string} command Command text, never evaluated.
|
|
218
|
+
* @param {string|undefined} initialCwd Inherited literal directory, if known.
|
|
219
|
+
* @param {object} env Inherited environment.
|
|
220
|
+
* @param {boolean} launcherAllowed Whether one launcher remains in scope.
|
|
221
|
+
* @param {boolean} initialUncertain Whether the parent context is unresolved.
|
|
222
|
+
* @returns {object[]} Active gh calls and their isolated command contexts.
|
|
223
|
+
*/
|
|
224
|
+
function commandContexts(
|
|
225
|
+
command,
|
|
226
|
+
initialCwd,
|
|
227
|
+
env,
|
|
228
|
+
launcherAllowed,
|
|
229
|
+
initialUncertain
|
|
230
|
+
) {
|
|
207
231
|
const calls = [];
|
|
208
232
|
const inherited = { ...env };
|
|
209
233
|
let cwd = initialCwd,
|
|
210
234
|
segment = [],
|
|
211
|
-
uncertain =
|
|
235
|
+
uncertain = initialUncertain;
|
|
212
236
|
const consume = () => {
|
|
213
237
|
if (segment.length === 0) return;
|
|
214
238
|
const local = { ...inherited };
|
|
@@ -263,6 +287,25 @@ export function ghCommands(command, initialCwd, env = process.env) {
|
|
|
263
287
|
env: local,
|
|
264
288
|
certainContext: !uncertain,
|
|
265
289
|
});
|
|
290
|
+
} else if (
|
|
291
|
+
launcherAllowed &&
|
|
292
|
+
segment[index]?.literal &&
|
|
293
|
+
["sh", "bash"].includes(path.basename(executable ?? "")) &&
|
|
294
|
+
segment[index + 1]?.literal &&
|
|
295
|
+
segment[index + 1].value === "-c" &&
|
|
296
|
+
segment[index + 2]?.literal
|
|
297
|
+
) {
|
|
298
|
+
// Only this operand is executable text. Later argv words are $0/$1/etc,
|
|
299
|
+
// not scripts. Child cd/export changes cannot mutate the outer shell.
|
|
300
|
+
calls.push(
|
|
301
|
+
...commandContexts(
|
|
302
|
+
segment[index + 2].value,
|
|
303
|
+
cwd,
|
|
304
|
+
local,
|
|
305
|
+
false,
|
|
306
|
+
uncertain
|
|
307
|
+
)
|
|
308
|
+
);
|
|
266
309
|
} else {
|
|
267
310
|
// A function/source/pushd or unsupported launcher may change the shell
|
|
268
311
|
// context. Do not grant later writes an exemption based on the old cwd.
|
|
@@ -47,11 +47,13 @@
|
|
|
47
47
|
* `dist/` ships to npm, so **this** repository may not name its hosts. A host
|
|
48
48
|
* naming itself carries none of that.
|
|
49
49
|
*
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
50
|
+
* Claude, Codex, Cursor, Antigravity, Copilot and Devin register the canonical
|
|
51
|
+
* plugin guard. OpenCode installs a native tool.execute.before adapter beside
|
|
52
|
+
* the same wrapper/classifier/helper; its package staging adds only the normal
|
|
53
|
+
* ownership banner. It preserves exit0 warnings and exit2 refusals. All seven
|
|
54
|
+
* surfaces therefore share target-scoped policy, rather than refusing a host
|
|
55
|
+
* project's own name. The generic dispatcher copy-overwrite roster remains
|
|
56
|
+
* separate; this guard is not added to that roster.
|
|
55
57
|
*
|
|
56
58
|
* WHERE IT APPLIES: THE TARGET, NOT THE CHECKOUT (#4462)
|
|
57
59
|
*
|
|
@@ -70,6 +72,10 @@
|
|
|
70
72
|
* routing. Unsupported shell syntax, unresolved expansions and ambiguous
|
|
71
73
|
* repositories earn no host exemption. This is bounded command inspection,
|
|
72
74
|
* not shell execution or a claim to close every shell/identity leak class.
|
|
75
|
+
* Literal one-level sh -c and bash -c executable-script operands reuse that
|
|
76
|
+
* inspection with the inherited directory/environment. No other quoted argv
|
|
77
|
+
* is interpreted as code. Dynamic scripts, deeper nesting, other interpreters
|
|
78
|
+
* and other launcher options remain outside this recognition contract.
|
|
73
79
|
*
|
|
74
80
|
* FAILING OPEN, LOUDLY
|
|
75
81
|
*
|