@codyswann/lisa 4.103.8 → 4.103.9
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/all/copy-overwrite/scripts/lisa-hooks/block-direct-issue-create.sh +12 -13
- package/all/copy-overwrite/scripts/lisa-hooks/block-no-verify.sh +4 -5
- package/all/copy-overwrite/scripts/lisa-hooks/worktree-binding-guard.mjs +16 -30
- package/all/copy-overwrite/scripts/lisa-postinstall.mjs +4 -15
- package/all/deletions.json +92 -2
- package/dist/cli/apply.d.ts.map +1 -1
- package/dist/cli/apply.js +1 -22
- package/dist/cli/apply.js.map +1 -1
- package/dist/cli/refresh-hooks-cmd.d.ts.map +1 -1
- package/dist/cli/refresh-hooks-cmd.js +3 -8
- package/dist/cli/refresh-hooks-cmd.js.map +1 -1
- package/dist/cli/worktree-prune.d.ts.map +1 -1
- package/dist/cli/worktree-prune.js +2 -4
- package/dist/cli/worktree-prune.js.map +1 -1
- package/dist/codex/scripts/block-no-verify.sh +4 -5
- package/dist/core/lisa-owned-hash-ledger.d.ts.map +1 -1
- package/dist/core/lisa-owned-hash-ledger.js +8 -0
- package/dist/core/lisa-owned-hash-ledger.js.map +1 -1
- 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 -71
- package/dist/core/upstream-evidence-manifest.js.map +1 -1
- package/dist/migrations/index.d.ts +0 -1
- package/dist/migrations/index.d.ts.map +1 -1
- package/dist/migrations/index.js +0 -3
- package/dist/migrations/index.js.map +1 -1
- package/dist/migrations/prune-retired-third-party-plugins.d.ts +2 -2
- package/dist/migrations/prune-retired-third-party-plugins.js +2 -2
- package/dist/opencode/hooks-installer.d.ts.map +1 -1
- package/dist/opencode/hooks-installer.js +17 -4
- 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 +0 -6
- package/dist/opencode/plugin-catalog.js.map +1 -1
- package/dist/opencode/plugin-templates/block-no-verify.sh +4 -5
- package/dist/opencode/plugin-templates/lisa-block-no-verify.ts +1 -1
- package/package.json +6 -8
- package/plugins/lisa/.claude-plugin/plugin.json +1 -5
- package/plugins/lisa/.codex-plugin/hooks.json +0 -4
- package/plugins/lisa/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa/hooks/block-direct-issue-create.sh +12 -13
- package/plugins/lisa/hooks/block-no-verify.agy.sh +4 -5
- package/plugins/lisa/hooks/block-no-verify.sh +4 -5
- package/plugins/lisa/hooks/block-shell-json-parsing.agy.sh +3 -3
- package/plugins/lisa/hooks/failure-signature-index.mjs +2 -2
- package/plugins/lisa/hooks/worktree-binding-guard.mjs +16 -30
- package/plugins/lisa-agy/hooks/block-direct-issue-create.sh +12 -13
- package/plugins/lisa-agy/hooks/block-no-verify.agy.sh +4 -5
- package/plugins/lisa-agy/hooks/block-shell-json-parsing.agy.sh +3 -3
- package/plugins/lisa-agy/hooks.json +0 -13
- 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 -5
- package/plugins/lisa-copilot/hooks/block-direct-issue-create.sh +12 -13
- package/plugins/lisa-copilot/hooks/block-no-verify.sh +4 -5
- package/plugins/lisa-copilot/hooks/failure-signature-index.mjs +2 -2
- package/plugins/lisa-copilot/hooks/worktree-binding-guard.mjs +16 -30
- package/plugins/lisa-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-cursor/hooks/block-direct-issue-create.sh +12 -13
- package/plugins/lisa-cursor/hooks/block-no-verify.sh +4 -5
- package/plugins/lisa-cursor/hooks/failure-signature-index.mjs +2 -2
- package/plugins/lisa-cursor/hooks/hooks.json +0 -4
- package/plugins/lisa-cursor/hooks/worktree-binding-guard.mjs +16 -30
- 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-direct-issue-create.sh +12 -13
- package/plugins/lisa-devin/hooks/block-no-verify.sh +4 -5
- package/plugins/lisa-devin/hooks/failure-signature-index.mjs +2 -2
- package/plugins/lisa-devin/hooks/worktree-binding-guard.mjs +16 -30
- package/plugins/lisa-devin/hooks.json +0 -4
- 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/materialized-artifacts.json +0 -2
- package/plugins/src/base/.claude-plugin/plugin.json +0 -4
- package/plugins/src/base/hooks/block-direct-issue-create.sh +12 -13
- package/plugins/src/base/hooks/block-no-verify.agy.sh +4 -5
- package/plugins/src/base/hooks/block-no-verify.sh +4 -5
- package/plugins/src/base/hooks/block-shell-json-parsing.agy.sh +3 -3
- package/plugins/src/base/hooks/failure-signature-index.mjs +2 -2
- package/plugins/src/base/hooks/worktree-binding-guard.mjs +16 -30
- package/scripts/build-plugins.sh +10 -15
- package/scripts/check-cwd-resolution-corpus.mjs +4 -5
- package/scripts/check-generated-artifact-merge-coverage.mjs +0 -7
- package/scripts/copy-opencode-plugin-templates.mjs +0 -1
- package/scripts/generate-agy-plugin-artifacts.mjs +8 -13
- package/scripts/install-claude-plugins.sh +7 -11
- package/scripts/lib/packaged-apply-driver.mjs +4 -22
- package/scripts/lib/shell-guard-refusal-coverage.mjs +3 -3
- package/scripts/materialize-copy-overwrite.mjs +2 -2
- package/scripts/merge-generated-artifact.mjs +3 -3
- package/scripts/remedy-conformance.mjs +12 -13
- package/scripts/two-channel-couplings.json +1 -1
- package/all/copy-overwrite/scripts/lisa-hooks/parity-safety-net.sh +0 -16
- package/dist/core/native-safety-net-retirement.d.ts +0 -13
- package/dist/core/native-safety-net-retirement.d.ts.map +0 -1
- package/dist/core/native-safety-net-retirement.js +0 -23
- package/dist/core/native-safety-net-retirement.js.map +0 -1
- package/dist/migrations/retire-native-safety-net.d.ts +0 -18
- package/dist/migrations/retire-native-safety-net.d.ts.map +0 -1
- package/dist/migrations/retire-native-safety-net.js +0 -36
- package/dist/migrations/retire-native-safety-net.js.map +0 -1
- package/dist/opencode/plugin-templates/lisa-parity-safety-net.ts +0 -4
- package/dist/opencode/plugin-templates/parity-safety-net.sh +0 -16
- package/plugins/lisa/hooks/parity-safety-net.agy.sh +0 -6
- package/plugins/lisa/hooks/parity-safety-net.sh +0 -16
- package/plugins/lisa-agy/hooks/parity-safety-net.agy.sh +0 -6
- package/plugins/lisa-agy/hooks/parity-safety-net.sh +0 -16
- package/plugins/lisa-copilot/hooks/parity-safety-net.sh +0 -16
- package/plugins/lisa-cursor/hooks/parity-safety-net.sh +0 -16
- package/plugins/lisa-devin/hooks/parity-safety-net.sh +0 -16
- package/plugins/src/base/hooks/parity-safety-net.agy.sh +0 -6
- package/plugins/src/base/hooks/parity-safety-net.sh +0 -13
- package/scripts/deployed-guard-advice.mjs +0 -637
- package/scripts/fixtures/native-safety-net-retirement/Dockerfile +0 -5
- package/scripts/fixtures/native-safety-net-retirement/invoke-opencode.mjs +0 -13
- package/scripts/fixtures/native-safety-net-retirement/isolated-linker.mjs +0 -101
- package/scripts/fixtures/native-safety-net-retirement/journey.mjs +0 -381
- package/scripts/fixtures/native-safety-net-retirement/probes.mjs +0 -208
- package/scripts/fixtures/native-safety-net-retirement/reduced-core.mjs +0 -93
- package/scripts/generate-retired-safety-net-manifest.mjs +0 -56
- package/scripts/generate-scratch-supervisor-profile.mjs +0 -75
- package/scripts/lib/retired-safety-net-manifest.json +0 -150
- package/scripts/retire-native-safety-net.mjs +0 -237
- package/scripts/verify-native-safety-net-retirement.mjs +0 -287
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
/** Real reduced-core apply, separately from the normal package-update journey. */
|
|
2
|
-
import assert from "node:assert/strict";
|
|
3
|
-
import { readFileSync, existsSync } from "node:fs";
|
|
4
|
-
import path from "node:path";
|
|
5
|
-
import { pathToFileURL } from "node:url";
|
|
6
|
-
import { CONTROL, TARGET, ok, run, sha } from "./probes.mjs";
|
|
7
|
-
|
|
8
|
-
const [pkg, projectDir] = process.argv.slice(2);
|
|
9
|
-
assert.equal(process.platform, "linux");
|
|
10
|
-
assert.ok(existsSync("/.dockerenv"));
|
|
11
|
-
const { Lisa } = await import(
|
|
12
|
-
pathToFileURL(path.join(pkg, "dist/core/lisa.js")).href
|
|
13
|
-
);
|
|
14
|
-
const { createDependencies } = await import(
|
|
15
|
-
pathToFileURL(path.join(pkg, "dist/cli/shared-options.js")).href
|
|
16
|
-
);
|
|
17
|
-
const { ConsoleLogger } = await import(
|
|
18
|
-
pathToFileURL(path.join(pkg, "dist/logging/index.js")).href
|
|
19
|
-
);
|
|
20
|
-
const proof = { root: projectDir, commands: [] };
|
|
21
|
-
const hooks = path.join(projectDir, "scripts/lisa-hooks");
|
|
22
|
-
const CANONICAL = "parity-safety-net.sh";
|
|
23
|
-
const CONTROL_HANDLER = "block-no-verify.sh";
|
|
24
|
-
const invoke = (name, command, agy = false) =>
|
|
25
|
-
run(proof, "/bin/bash", [path.join(hooks, name)], {
|
|
26
|
-
input: JSON.stringify(
|
|
27
|
-
agy
|
|
28
|
-
? { toolCall: { name: "run_command", args: { CommandLine: command } } }
|
|
29
|
-
: { tool_name: "Bash", tool_input: { command } }
|
|
30
|
-
),
|
|
31
|
-
});
|
|
32
|
-
const config = {
|
|
33
|
-
lisaDir: pkg,
|
|
34
|
-
destDir: projectDir,
|
|
35
|
-
dryRun: false,
|
|
36
|
-
yesMode: true,
|
|
37
|
-
validateOnly: false,
|
|
38
|
-
skipGitCheck: false,
|
|
39
|
-
postinstall: true,
|
|
40
|
-
harness: "fleet",
|
|
41
|
-
};
|
|
42
|
-
const packageHash = sha(readFileSync(path.join(projectDir, "package.json")));
|
|
43
|
-
const controlHash = sha(readFileSync(path.join(hooks, CONTROL_HANDLER)));
|
|
44
|
-
assert.equal(invoke(CANONICAL, TARGET).status, 2);
|
|
45
|
-
assert.equal(
|
|
46
|
-
JSON.parse(invoke("parity-safety-net.agy.sh", TARGET, true).stdout).decision,
|
|
47
|
-
"deny"
|
|
48
|
-
);
|
|
49
|
-
assert.equal(invoke(CONTROL_HANDLER, CONTROL).status, 2);
|
|
50
|
-
for (const args of [
|
|
51
|
-
["init", "--initial-branch=main"],
|
|
52
|
-
["config", "user.name", "Lisa verification"],
|
|
53
|
-
["config", "user.email", "verification@example.invalid"],
|
|
54
|
-
["add", "--all"],
|
|
55
|
-
["commit", "-m", "Initialize reduced-core fixture"],
|
|
56
|
-
])
|
|
57
|
-
ok(proof, "git", args);
|
|
58
|
-
const lisa = new Lisa(
|
|
59
|
-
config,
|
|
60
|
-
createDependencies(false, true, new ConsoleLogger())
|
|
61
|
-
);
|
|
62
|
-
const result = await lisa.apply();
|
|
63
|
-
assert.equal(result.success, true, JSON.stringify(result));
|
|
64
|
-
assert.equal(invoke(CANONICAL, TARGET).status, 0);
|
|
65
|
-
assert.equal(
|
|
66
|
-
JSON.parse(invoke("parity-safety-net.agy.sh", TARGET, true).stdout).decision,
|
|
67
|
-
"allow"
|
|
68
|
-
);
|
|
69
|
-
assert.equal(invoke(CONTROL_HANDLER, CONTROL).status, 2);
|
|
70
|
-
assert.equal(sha(readFileSync(path.join(hooks, CONTROL_HANDLER))), controlHash);
|
|
71
|
-
assert.equal(
|
|
72
|
-
sha(readFileSync(path.join(projectDir, "package.json"))),
|
|
73
|
-
packageHash
|
|
74
|
-
);
|
|
75
|
-
for (const entry of [
|
|
76
|
-
".opencode/plugin/lisa-parity-safety-net.ts",
|
|
77
|
-
".codex/hooks.json",
|
|
78
|
-
".devin/hooks.v1.json",
|
|
79
|
-
".lisa/apply-receipt.json",
|
|
80
|
-
])
|
|
81
|
-
assert.equal(existsSync(path.join(projectDir, entry)), false, entry);
|
|
82
|
-
console.log(
|
|
83
|
-
JSON.stringify({
|
|
84
|
-
phase: "real-reduced-core-apply",
|
|
85
|
-
outcome: "PASS",
|
|
86
|
-
apply_mode: "postinstall-safe",
|
|
87
|
-
target: "allowed",
|
|
88
|
-
unrelated: "refused",
|
|
89
|
-
package_preserved: true,
|
|
90
|
-
no_agent_emit_or_counterfeit_receipt: true,
|
|
91
|
-
commands: proof.commands,
|
|
92
|
-
})
|
|
93
|
-
);
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
/** Hash ownership for the three retired native safety-net entry points. */
|
|
3
|
-
import { createHash } from "node:crypto";
|
|
4
|
-
import { readFileSync, writeFileSync } from "node:fs";
|
|
5
|
-
import path from "node:path";
|
|
6
|
-
import {
|
|
7
|
-
historicalHashes,
|
|
8
|
-
readLedgerSections,
|
|
9
|
-
} from "./generate-lisa-owned-hash-ledger.mjs";
|
|
10
|
-
import { withOwnershipHeader } from "./materialize-copy-overwrite.mjs";
|
|
11
|
-
|
|
12
|
-
const root = path.resolve(import.meta.dirname, "..");
|
|
13
|
-
const output = path.join(root, "scripts/lib/retired-safety-net-manifest.json");
|
|
14
|
-
const sources = {
|
|
15
|
-
"parity-safety-net.sh": "plugins/src/base/hooks/parity-safety-net.sh",
|
|
16
|
-
"parity-safety-net.agy.sh": "plugins/src/base/hooks/parity-safety-net.agy.sh",
|
|
17
|
-
"lisa-parity-safety-net.ts":
|
|
18
|
-
"src/opencode/plugin-templates/lisa-parity-safety-net.ts",
|
|
19
|
-
};
|
|
20
|
-
const previous = (() => {
|
|
21
|
-
try {
|
|
22
|
-
return JSON.parse(readFileSync(output, "utf8"));
|
|
23
|
-
} catch (error) {
|
|
24
|
-
if (error.code === "ENOENT") return {};
|
|
25
|
-
throw error;
|
|
26
|
-
}
|
|
27
|
-
})();
|
|
28
|
-
const { ledger } = readLedgerSections(root);
|
|
29
|
-
const entries = Object.fromEntries(
|
|
30
|
-
Object.entries(sources).map(([name, source]) => {
|
|
31
|
-
// Keep known hashes under shallow clones, just as the shipping ledger does.
|
|
32
|
-
const hashes = new Set([
|
|
33
|
-
...(previous[name]?.hashes ?? []),
|
|
34
|
-
...(ledger?.get(`scripts/lisa-hooks/${name}`) ?? []),
|
|
35
|
-
...historicalHashes(root, source),
|
|
36
|
-
...historicalHashes(root, `plugins/lisa/hooks/${name}`),
|
|
37
|
-
...historicalHashes(root, `plugins/lisa-agy/hooks/${name}`),
|
|
38
|
-
]);
|
|
39
|
-
const authored = readFileSync(path.join(root, source), "utf8");
|
|
40
|
-
const shim =
|
|
41
|
-
name === "parity-safety-net.sh"
|
|
42
|
-
? withOwnershipHeader(authored, name)
|
|
43
|
-
: authored;
|
|
44
|
-
hashes.add(createHash("sha256").update(shim).digest("hex"));
|
|
45
|
-
return [name, { source, hashes: [...hashes].sort(), shim }];
|
|
46
|
-
})
|
|
47
|
-
);
|
|
48
|
-
const rendered = `${JSON.stringify(entries, null, 2)}\n`;
|
|
49
|
-
if (process.argv.includes("--check")) {
|
|
50
|
-
if (readFileSync(output, "utf8") !== rendered) {
|
|
51
|
-
console.error(
|
|
52
|
-
"Retired safety-net ownership changed; run node scripts/generate-retired-safety-net-manifest.mjs"
|
|
53
|
-
);
|
|
54
|
-
process.exitCode = 1;
|
|
55
|
-
} else console.log("Retired safety-net ownership is current.");
|
|
56
|
-
} else writeFileSync(output, rendered);
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
/**
|
|
3
|
-
* Bind the guard's reviewed public-supervisor profile to canonical source.
|
|
4
|
-
* The generated constants ship inside the guard. A host manifest or command
|
|
5
|
-
* argument cannot replace them. Source changes require generation and review.
|
|
6
|
-
* @module scripts/generate-scratch-supervisor-profile
|
|
7
|
-
*/
|
|
8
|
-
import { createHash } from "node:crypto";
|
|
9
|
-
import { readFileSync, writeFileSync } from "node:fs";
|
|
10
|
-
import path from "node:path";
|
|
11
|
-
import { fileURLToPath } from "node:url";
|
|
12
|
-
import { invokedAsScript } from "./lib/invoked-as-script.mjs";
|
|
13
|
-
|
|
14
|
-
/** Render the two fixed constants from complete canonical supervisor bytes.
|
|
15
|
-
* @param {string} guard - Editable canonical guard source.
|
|
16
|
-
* @param {Buffer} source - Complete canonical supervisor bytes.
|
|
17
|
-
* @returns {string} Guard with the exact source profile.
|
|
18
|
-
*/
|
|
19
|
-
export function renderScratchProfile(guard, source) {
|
|
20
|
-
const text = source.toString("utf8");
|
|
21
|
-
if (!Buffer.from(text).equals(source) || source.length > 262144) {
|
|
22
|
-
throw new Error("Canonical supervisor source is not bounded UTF8");
|
|
23
|
-
}
|
|
24
|
-
const count = [
|
|
25
|
-
...text.matchAll(
|
|
26
|
-
/^\s*rm -rf "(\$_quarantine|\$_root|\$_entry|\$LISA_SCRATCH_ROOT)"/gm
|
|
27
|
-
),
|
|
28
|
-
].length;
|
|
29
|
-
if (count === 0)
|
|
30
|
-
throw new Error("Canonical supervisor cleanup profile is absent");
|
|
31
|
-
const values = {
|
|
32
|
-
SHA256: createHash("sha256").update(source).digest("hex"),
|
|
33
|
-
CLEANUP_COUNT: String(count),
|
|
34
|
-
};
|
|
35
|
-
return Object.entries(values).reduce((current, [key, value]) => {
|
|
36
|
-
const expression = new RegExp(
|
|
37
|
-
`^readonly SCRATCH_SUPERVISOR_${key}='[^'\\n]*'$`,
|
|
38
|
-
"gm"
|
|
39
|
-
);
|
|
40
|
-
if ([...current.matchAll(expression)].length !== 1) {
|
|
41
|
-
throw new Error("Canonical guard source profile is ambiguous");
|
|
42
|
-
}
|
|
43
|
-
return current.replace(
|
|
44
|
-
expression,
|
|
45
|
-
`readonly SCRATCH_SUPERVISOR_${key}='${value}'`
|
|
46
|
-
);
|
|
47
|
-
}, guard);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
if (invokedAsScript(import.meta.url)) {
|
|
51
|
-
if (
|
|
52
|
-
process.argv.slice(2).some(argument => argument !== "--check") ||
|
|
53
|
-
process.argv.length > 3
|
|
54
|
-
) {
|
|
55
|
-
throw new Error("Usage: generate-scratch-supervisor-profile.mjs [--check]");
|
|
56
|
-
}
|
|
57
|
-
const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");
|
|
58
|
-
const guardPath = path.join(
|
|
59
|
-
root,
|
|
60
|
-
"plugins/src/base/hooks/parity-safety-net.sh"
|
|
61
|
-
);
|
|
62
|
-
const current = readFileSync(guardPath, "utf8");
|
|
63
|
-
const rendered = renderScratchProfile(
|
|
64
|
-
current,
|
|
65
|
-
readFileSync(
|
|
66
|
-
path.join(root, "all/copy-overwrite/scripts/lisa-scratch-run.sh")
|
|
67
|
-
)
|
|
68
|
-
);
|
|
69
|
-
if (process.argv.includes("--check")) {
|
|
70
|
-
if (current !== rendered)
|
|
71
|
-
throw new Error("Canonical supervisor source profile is stale");
|
|
72
|
-
} else if (current !== rendered) {
|
|
73
|
-
writeFileSync(guardPath, rendered);
|
|
74
|
-
}
|
|
75
|
-
}
|
|
@@ -1,150 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"parity-safety-net.sh": {
|
|
3
|
-
"source": "plugins/src/base/hooks/parity-safety-net.sh",
|
|
4
|
-
"hashes": [
|
|
5
|
-
"062c69eea85157f1e941ec3626d8912aa9f182af6ccdbe19687588a6074db5ce",
|
|
6
|
-
"07002535de10d89f6d73e8922517550a02a8974549aaf200c9c314e6f4f83c70",
|
|
7
|
-
"0a984421f99371c00391f48ca6da2508f67385812d0b168fceed1fd29edfd936",
|
|
8
|
-
"1026cf31eceae774ceb055f023ea0edd70d8dcca6132161a932289adea04ba7e",
|
|
9
|
-
"10f328abffac44d436c709d328cb4d8b2a0d2fe2bbe61c774c92da07e98651ad",
|
|
10
|
-
"1162ffd16cef3b23282d2f5207abcb88429462a74a9df1035f0df4968f6dd456",
|
|
11
|
-
"12a2baaf08d27f7944f78fa61c0e36b4bd66adda72310381b12a03a5b380c54f",
|
|
12
|
-
"14158ed93668fadc2154074470dcb257bbb28d8e6b62c8d8615b78fa200d72b0",
|
|
13
|
-
"14fc5e292aebf83dd24fec12fb32e2beb509a9324f127a24a64d5c5d4d05c576",
|
|
14
|
-
"1bf3512bb94923a6cb25b1e7a619a3fc8e1336bffa16f499b459aaee3eaed66d",
|
|
15
|
-
"1d0dbbf436f87ad8b2252ca1a559e44f96751b1c3261cc7a7021989998e2231c",
|
|
16
|
-
"1d4fbe135f1bb4e861d286a6512ed201d4522250dfe3f9eba6584bc5ff166a95",
|
|
17
|
-
"1eef68ecb04183ec75f0c049f039e60c6030d1e7ffb4974c59ef47488e4a3931",
|
|
18
|
-
"1f4759053311d99f371b4f16b6a2c7cc8a6b9afc3f717512c9a4dab595616a17",
|
|
19
|
-
"23cfde6251672a87565af7c2a3dad3c02907d9e726a31e86f3124d7e1030273f",
|
|
20
|
-
"26cd8395f18dda3860a73e90c9c68d16caa07de8a8aa26f71dc09f1c3d74bb15",
|
|
21
|
-
"2b1ca7d317dea3af106df1a74b1718e3df9c18e76e9d9d769aa3271b7abf8a3f",
|
|
22
|
-
"2b3d806137b34bfdd21be9e76ca5159f7b11fbd3ca9223d99bef298e42f49c0d",
|
|
23
|
-
"2bdba97c9a1ccc0e70247ee02b5eff02c042aba83b8e7fed3dfbf29a8a83b394",
|
|
24
|
-
"2da3ad6d7680b61e20b48022e57b8960e063266cb26c197c2c8daa89adf4b648",
|
|
25
|
-
"2f20dd5fca989c27165dda50270546297095fb1b6620a98e9b66ac6dd5d82b94",
|
|
26
|
-
"307f934810a36f5889bc443d7ab3f4166eccd74820b44ff2973b6fc58fe0841d",
|
|
27
|
-
"388cf8847581d96a1ff8ea98290a33a5f96d67cdd502ea807a0b8d88efe90e19",
|
|
28
|
-
"38ae9df19e83950549d8832e888b18654e6d4c45ebfed857c423554cd3ead9f7",
|
|
29
|
-
"3b884946639996f862d0ed6b3a6e34c94f5f8f0189822fc7acba9b1ff241a969",
|
|
30
|
-
"3be47054e9a434dd748e63f9cfad67437824c9b9feda292b28b5757fd2d06ad9",
|
|
31
|
-
"3cc1b8a1730f7a35b82293824715538432bb4c410be38d64ee887eb55fea23b4",
|
|
32
|
-
"3dcf3897381b6cd14903681b371ffde94e3839f34a39acb6192d69f20e06345d",
|
|
33
|
-
"40e12bb956baacb23846456d20b840e11c14dae539fc67806476eb674d6c38b1",
|
|
34
|
-
"40e6c3a23809cf322441265600326fa8c45b184fd9193cd3f8ffdeed597b5365",
|
|
35
|
-
"4242b39169bb05aaac4113569125a2c3a351c5dde2d12fd7dacc303dd9a2b5a4",
|
|
36
|
-
"450338257697a75a8fce9f06f3fc00bf3417947e50d601794da41f9c520a7cc3",
|
|
37
|
-
"4693b532d4f406af6d9559382d35cb65a77782a611a0cba2838d182c71690472",
|
|
38
|
-
"4e3be52be5d36c4be961557188b4f46ba1f1a17a09e53c6514b82ff11a8920db",
|
|
39
|
-
"57051a1913665b34acc342002d799c703258650a19c9b9894e1911ddf3bd519f",
|
|
40
|
-
"5d65516d4a1c7cd41c82941596e9f3fe9b96a1030891b40a1a6080171dddede8",
|
|
41
|
-
"5ef7c10bee0110c4af1e429fac01332433102c495ec467966ddd7b1494dc899d",
|
|
42
|
-
"61f639b07344124fa6c1c66b031e7a699cded442d5ac9a44e1027cba686b6fa2",
|
|
43
|
-
"64546813f168fb446f39e34bc674fd3af85b15bd5e7f4f6bf4503463e701a7b9",
|
|
44
|
-
"649968db4d1aa6ee33fb83ea16d7481806b5cbf3a94aceed9a22bb2615ecf71a",
|
|
45
|
-
"649aecd270cb50794f04a02224e53f8ca6c4409ae50aae73017b62803048be57",
|
|
46
|
-
"67a600105e3d96c0bfedcfc576fe667c4698679236a6c8253fcd8ff2eaf9e649",
|
|
47
|
-
"6a77308c1dc48e3bb87e2ee3a9494e9cb00bea127df0d4cfdf02b2afbdc2bbcb",
|
|
48
|
-
"6c4d5267bc8c4a97a9970987f880f9651c1b2fa2aab9948599d9cb1020ca7614",
|
|
49
|
-
"6cefe613e6cf296fc10927ed886981b00e1f627cb98c1ad1de20db5c829ddfd2",
|
|
50
|
-
"6e76a941e1afb0ebb223d527bc70f73eb101650df5b9d61f77ae951dd601e94d",
|
|
51
|
-
"72640d632dbcfa9fc2fc1b7b22a0d232487251c899352168640e3cd91a52c377",
|
|
52
|
-
"743663565a80b56abc63fbe23dd4da557c41c96a6e98bfe7eca46245dc4e7cb9",
|
|
53
|
-
"74b5b90fcf15dbeb14a69677cf74e339154421cd056fdaf603d1167b34a74105",
|
|
54
|
-
"772202ddd42d626625ff719666afbbe83445d8bae1bc7c0fb5ffdcb402be83f8",
|
|
55
|
-
"7b2c5ea41466f0334a6100a411ca6de033964b3b054d32e0e40778a2ad53bb41",
|
|
56
|
-
"7c5907f9c8f230963f49c4022ccf972cda26634d2ab766118477bbd62f2bdd88",
|
|
57
|
-
"7d034892e60ba52dc964c8d46bcd6aa2ad203b451da8043c12eaf4d646e0011d",
|
|
58
|
-
"7f55986eb29f8ace8616595da4bbe60d80a96f9f29b24fb72efd66bb96b22464",
|
|
59
|
-
"80998c022d907cb2442f93f1356caf8f8f7f50e27cfd44e491f95177b98da458",
|
|
60
|
-
"8509567b13d520ca3d455c2f7ebc69a043d4a73deeab8ba402bb2e1b3c68930e",
|
|
61
|
-
"8b17a697b8a5d0ad13fc2c6012a76915183fc74f3fa1b3eb3fbf8658ca587343",
|
|
62
|
-
"8e19d5f1ba7abe3d22fbee47ff8e0fad76b965ccca20b8849e3c43ab07d9a4ef",
|
|
63
|
-
"90115e7e9d61ff6b0ab64d5154783805ac41e968dcaf398c7a807e76c3f07a9e",
|
|
64
|
-
"9404c374cbd90a0860410080f1044d087c51d84bb4c0a37343c2b632c3a9d03b",
|
|
65
|
-
"98c98b87b3a706dc0f6627bf3f74c815ec1e0f6e111da720bcc92831fe78a7c7",
|
|
66
|
-
"9c8762f3d200572adcdc8ed5718bdd6282fe0fad2eea595a05c559b3dc55aa00",
|
|
67
|
-
"9e5b906e069c6d759304e208a9bc6a089c453c21561b120181ec2c62e8325b45",
|
|
68
|
-
"a10252283023f8657677529e515db6d828453ee3a786fda1ba878f6ac7a35d45",
|
|
69
|
-
"a185d2af6016f93ae7ffe4d584dc36e4e45f624ad5c81113114e12785003b373",
|
|
70
|
-
"a211f1a06aecddb841851463da302f694ab0eafff6bab75ee944b0a58aac431d",
|
|
71
|
-
"a22fd1b7c483f1a538202353ee85c82be17a8910e03c0a930635ce8cb3595c64",
|
|
72
|
-
"a28779ba2e6e4e999014d50734ea0b7e36af886bdb08d144bd4274acd642c902",
|
|
73
|
-
"a71032a182f2cebea3c90476de1ab49bf7a99d0ecbb331fe95ebbeada0f5a0ff",
|
|
74
|
-
"a77a6a15a74a98135d73dcf41e26ee3bbc69f1575693c7c40e3d47a946a2eb07",
|
|
75
|
-
"aa887e9b54353d2a6622547bb4abc442fa33848e3269643a7461e0432b40bee1",
|
|
76
|
-
"ad836d6bcf9b5222b313ba1b8b6714448bac0ca8446feaa55430079d0115f2f7",
|
|
77
|
-
"afe82473fe2a08af298997cbce62417fdaefa37f4a963f720ed38b992a65b8d3",
|
|
78
|
-
"affab52ae58f0ec50ea2a80398c4362a77cb51f824fa8a615bd3e3de8c3e36ca",
|
|
79
|
-
"b0a251412034a54d3a254a5af2c2d1bdb4c6e4e1db3b148c819fa587a2bd7620",
|
|
80
|
-
"b4848fc9e7c2f208369eb340d75e59ca0053b9d6a870c3b39bee781fb9b0fd6a",
|
|
81
|
-
"b5505f55a5092f1d451ae5a01ada85a031e5b063d08fc0ce5527d94b67191a60",
|
|
82
|
-
"b6fbbda29d897a7c39cf0524c91d5c66a47054df32e036f15cdabefdc34ac72a",
|
|
83
|
-
"b755796c218d5b397f4b4bc9077e25a7c5d9bf4fa94eee41c6191a65a80cae78",
|
|
84
|
-
"b83c5043a0f29b2d8851258acfe6906aab7922cd80f486e25220e55f26a8c0a5",
|
|
85
|
-
"bacf584ff4783ab3cb94b59b38fc92dcbc1a9bc3e96ee78246109abede88bfcd",
|
|
86
|
-
"baf3c78b7c333735142cc1a7bc19369f953a4699f7be517bb4e3c12167d5c60b",
|
|
87
|
-
"bb400559f30ffaddcd93c8a2fc64e01922041a3cfdb213d85beb7fed68b42a28",
|
|
88
|
-
"bc67b489af67175696a4378d7e04fe3a7ad3e00029aabc6611bdcf740fc35b32",
|
|
89
|
-
"c0aa42f5e0a15a5d1938369129d0b7f726a4db1a80389d427e6f9647d7cf97fa",
|
|
90
|
-
"c0b820f7b9a1992f11e8ac79b717a228bb3abb055dc72a8f2b11a489c7a6b68b",
|
|
91
|
-
"c4a51de3f1512e7e18935612137e4ddaf548db68f878d8239fcc85436b0f27c7",
|
|
92
|
-
"c57b70eed03b74e7c8335c40b0c2b1102e217e507337b71fcf3d2bec5a450bf8",
|
|
93
|
-
"c663d2a06b32fb263e52cdc9b713a8f73d53f8dc9adebccea44f481210b742d6",
|
|
94
|
-
"c78524d4f11d1de4887c6df139c809dac05813ead6f1e0261f39b8c54f37263c",
|
|
95
|
-
"c93b51e96272b8e2df8a1524b47bc6affd0d327b591f6efe55fe1cb3f16dea17",
|
|
96
|
-
"caea02a07027fc1c74d47e08b36299d369c5c9f7c4043da8828fbca3c64eb2aa",
|
|
97
|
-
"cb5275900b141dc8befc124f2c2e818524a2f65ab8db484ba83f1c00b6210b30",
|
|
98
|
-
"cc9b44042d184a65277116009fccc26a678b57dbc51699e5acaae8afdf9735ff",
|
|
99
|
-
"cda051c451145d6ff93a744a290176640cae39309cd346a00e73a924add089d8",
|
|
100
|
-
"cecab19d8997af8a0864cebf25f32d9bb537043894fc06cc2389fe9c159da529",
|
|
101
|
-
"cfa7f56b1db4e1c0cedb8c3af39eb1af25202569ad5299b278db002ae3584913",
|
|
102
|
-
"d12583803e8ff5e4b64e68eafc8d3c377af4c400d8b7ecd1c7fe699d8f92784a",
|
|
103
|
-
"d70546773bef81d3c8accb2e4bcdde33fe233d253052f382adc8b50b9f2ef178",
|
|
104
|
-
"d9ea58150aa27e7f0aa9a4ef155ed446d30bdfc932d01c64e2b8ca211aa0de7b",
|
|
105
|
-
"db56b49f8a069f5a2f7d352b4f880d8637c3b82ae106e9bf148747f0de424dce",
|
|
106
|
-
"dc9fb867693d67015b3cfd59f5f4bc81aba418746c3c22663d421e0c345b9295",
|
|
107
|
-
"df2ff8dc0f4be6077c2824bb0ece2eb5e72b982538b87e3c758128bc824185f1",
|
|
108
|
-
"df4de965f12ac79a5e9d75c795780e5f1db641468dca7a9d373deb36d9765114",
|
|
109
|
-
"e192737a8756b97e406d2b1cbdb099e3b7f190cc6b96c3681284637de95c1646",
|
|
110
|
-
"e328293f30b39345c26472d3f55b5870d6e23b36d351cd81b43f8cd99a6a608d",
|
|
111
|
-
"e6213bdbfb477f1e37f9111c1e46df1365cb85d5190c5a0cc134edbba52e7d9f",
|
|
112
|
-
"e63b511a942eb2735db2d1b26f13b7eabc60f56e2f40d343dbd58cd3ffe765ba",
|
|
113
|
-
"e6a7f34b68e7c0f1c91669aa90dbbc52d475776efd48922b4cfdf6c4736ccec0",
|
|
114
|
-
"e77079eaa42abf6ab05b4b9140c56a9e9ebbbcac2bc4c01c369e5c1bc5104e6f",
|
|
115
|
-
"eac730634b0f36a91d8a1c18dfb52bdcd668d353420faf525c7bdfdeafb6b509",
|
|
116
|
-
"eb1eb871e8f2f2a21d4bf5bd3a0197975269bf80faf12063bc4ca2bc8660bc1b",
|
|
117
|
-
"ec2eca79031802a67b973482c67cc6dc704606dc12cc4ef3c1904f0afde8480b",
|
|
118
|
-
"ed490ea5c1cfde1b224d935a071cd82ce7578c83fe53815aaf91f1fc4e46f216",
|
|
119
|
-
"f0bc51085b954b4fc9dcda8329069e8c23cc2a3a8bc388d69a1bb43e96af4bda",
|
|
120
|
-
"f0bf8390d9d857b7a1da17504dceb9699c1d4399bcf70d543c3a509caf70888c",
|
|
121
|
-
"f58a1b98128d90ab8879dc08177fb53482c15dc6c743efefc63bda4f2a5f9728",
|
|
122
|
-
"f740f600b255742a50f28e5c9d09427c5783c4084e84052dca46bc1f0c94a187",
|
|
123
|
-
"f7ae7f75c84d00d730f525a2f7779afe7fd68e0f81b58f955739718a4890dd35",
|
|
124
|
-
"f9ba6746df5639e0ac307bbfeaf8f98fc15856a4452986ae6a6b3ad884d26f15",
|
|
125
|
-
"f9f2622b2664ced23825a3c35400797ed68e274677aabdfa69e590218109a10e",
|
|
126
|
-
"fa8f4a6517eacd9266feb7afd62398cdf2075d4824cac24b45bb64ad0cd18c86",
|
|
127
|
-
"fb487a2d54b05a8d3268ce46e64b044a68896827941eb9e6e25b975e76762e13",
|
|
128
|
-
"ff15992834e3bb911a560a6f65be76a791a8cd262f36b18972f25a8dc36d7c00"
|
|
129
|
-
],
|
|
130
|
-
"shim": "#!/usr/bin/env bash\n# This file is managed by Lisa and IS replaced on each `lisa` run.\n# Do not edit directly — durable changes belong upstream in Lisa.\n\n# Retired in #4672. Kept callable for persisted and already-loaded hooks.\n# The Lisa plugin and every unrelated guard remain enabled.\n# The shared parser remains for active instruction guards and legacy copies.\n# No input parsing, command execution, dependencies, or policy refusals.\n# Retained source-profile metadata for compatibility with build tooling. The\n# retired hook never uses this profile to classify a command.\nreadonly SCRATCH_SUPERVISOR_SHA256='76ccf8ca6f98b214361f02ebf6ad58041129b76ed29128455e810095db6c292f'\nreadonly SCRATCH_SUPERVISOR_CLEANUP_COUNT='7'\n# Drain hook input with bounded Bash builtins so native writers do not hit a\n# closed pipe. Nothing in the input is interpreted or executed.\nwhile IFS= read -r -n 8192 _lisa_retired_chunk || [ -n \"$_lisa_retired_chunk\" ]; do :; done\nexit 0\n"
|
|
131
|
-
},
|
|
132
|
-
"parity-safety-net.agy.sh": {
|
|
133
|
-
"source": "plugins/src/base/hooks/parity-safety-net.agy.sh",
|
|
134
|
-
"hashes": [
|
|
135
|
-
"11a4046b6c5b084e2ccd23f956a5b243e20eb83779a379c0874fafff2c1e95c8",
|
|
136
|
-
"ce9bd2b4566ad9147e4ace56434cffbbe87edb4ccbb57549ab3fd9f4c671ced4"
|
|
137
|
-
],
|
|
138
|
-
"shim": "#!/usr/bin/env bash\n# Retired native safety-net adapter (#4672). Old agy registrations stay valid.\n# Does not require the formerly delegated parity-safety-net.sh sibling.\nwhile IFS= read -r -n 8192 _lisa_retired_chunk || [ -n \"$_lisa_retired_chunk\" ]; do :; done\nprintf '{\"decision\":\"allow\"}\\n'\nexit 0\n"
|
|
139
|
-
},
|
|
140
|
-
"lisa-parity-safety-net.ts": {
|
|
141
|
-
"source": "src/opencode/plugin-templates/lisa-parity-safety-net.ts",
|
|
142
|
-
"hashes": [
|
|
143
|
-
"7e3b3f6e0e6548984146b2b8ab471266631458309695f5fc794eb0d792342bef",
|
|
144
|
-
"870365ad7876d8f2ba991e8654899fc888e6c37c4977508b8d790869654f647e",
|
|
145
|
-
"a7bf88e6e5aa39b95785ec2522d9ee9b56b69935a17350fd7b5c06aea396fbc7",
|
|
146
|
-
"b8c5cce685557676782daa5c4cc932a3f3deb647ead8b2de3efd5157ab135003"
|
|
147
|
-
],
|
|
148
|
-
"shim": "/** Retired native safety-net compatibility entry (#4672). No sibling required. */\nexport const LisaParitySafetyNet = async () => ({\n \"tool.execute.before\": async () => {},\n});\n"
|
|
149
|
-
}
|
|
150
|
-
}
|
|
@@ -1,237 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
/**
|
|
3
|
-
* Retire only hash-proven Lisa safety-net handlers. Old registrations stay
|
|
4
|
-
* callable, including commands captured by an already running agent. Never
|
|
5
|
-
* disable the enclosing Lisa plugin or rewrite an operator's settings.
|
|
6
|
-
*/
|
|
7
|
-
import { createHash, randomUUID } from "node:crypto";
|
|
8
|
-
import {
|
|
9
|
-
constants,
|
|
10
|
-
lstatSync,
|
|
11
|
-
openSync,
|
|
12
|
-
closeSync,
|
|
13
|
-
chmodSync,
|
|
14
|
-
readFileSync,
|
|
15
|
-
readdirSync,
|
|
16
|
-
realpathSync,
|
|
17
|
-
renameSync,
|
|
18
|
-
unlinkSync,
|
|
19
|
-
writeFileSync,
|
|
20
|
-
} from "node:fs";
|
|
21
|
-
import { homedir } from "node:os";
|
|
22
|
-
import path from "node:path";
|
|
23
|
-
import { invokedAsScript } from "./lib/invoked-as-script.mjs";
|
|
24
|
-
|
|
25
|
-
const packageRoot = path.resolve(import.meta.dirname, "..");
|
|
26
|
-
const manifest = JSON.parse(
|
|
27
|
-
readFileSync(
|
|
28
|
-
new URL("./lib/retired-safety-net-manifest.json", import.meta.url),
|
|
29
|
-
"utf8"
|
|
30
|
-
)
|
|
31
|
-
);
|
|
32
|
-
const sha = bytes => createHash("sha256").update(bytes).digest("hex");
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* Known installed plugin containers, never arbitrary registry installPaths.
|
|
36
|
-
* Walks do not follow symlinks into source checkouts or other user directories.
|
|
37
|
-
* Global Lisa plugin copies must also retire: they can serve many projects.
|
|
38
|
-
* @param {NodeJS.ProcessEnv} [env] Runtime configuration
|
|
39
|
-
* @returns {string[]} Container roots
|
|
40
|
-
*/
|
|
41
|
-
export function installedPluginRoots(env = process.env) {
|
|
42
|
-
const home = homedir();
|
|
43
|
-
return [
|
|
44
|
-
path.join(
|
|
45
|
-
env.CLAUDE_CODE_PLUGIN_CACHE_DIR ||
|
|
46
|
-
path.join(
|
|
47
|
-
env.CLAUDE_CONFIG_DIR || path.join(home, ".claude"),
|
|
48
|
-
"plugins"
|
|
49
|
-
),
|
|
50
|
-
"cache"
|
|
51
|
-
),
|
|
52
|
-
path.join(env.CODEX_HOME || path.join(home, ".codex"), "plugins/cache"),
|
|
53
|
-
path.join(home, ".cursor/plugins/cache"),
|
|
54
|
-
path.join(home, ".cursor/plugins/local"),
|
|
55
|
-
path.join(home, ".gemini/config/plugins"),
|
|
56
|
-
path.join(home, ".copilot/installed-plugins"),
|
|
57
|
-
path.join(
|
|
58
|
-
env.XDG_CONFIG_HOME || path.join(home, ".config"),
|
|
59
|
-
"devin/plugins"
|
|
60
|
-
),
|
|
61
|
-
];
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* Inspect a path without treating inaccessible data as an absent installation.
|
|
66
|
-
* @param {string} file Candidate path
|
|
67
|
-
* @returns {import('node:fs').Stats|undefined} Stat if present
|
|
68
|
-
*/
|
|
69
|
-
function stat(file) {
|
|
70
|
-
try {
|
|
71
|
-
return lstatSync(file);
|
|
72
|
-
} catch (error) {
|
|
73
|
-
if (error.code === "ENOENT") return undefined;
|
|
74
|
-
throw error;
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* Refuse symlink ancestors: renaming through them would edit another checkout.
|
|
80
|
-
* @param {string} file Absolute path
|
|
81
|
-
* @returns {boolean} Whether all existing components are literal
|
|
82
|
-
*/
|
|
83
|
-
function literalPath(file) {
|
|
84
|
-
const parent = path.dirname(file);
|
|
85
|
-
if (parent !== file && !literalPath(parent)) return false;
|
|
86
|
-
return stat(file)?.isSymbolicLink() !== true;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
* Select exact target filenames under bounded plugin trees, preserving all else.
|
|
91
|
-
* @param {string} root Container or project handler directory
|
|
92
|
-
* @param {number} depth Remaining nesting budget
|
|
93
|
-
* @returns {string[]} Existing regular target handlers
|
|
94
|
-
*/
|
|
95
|
-
function findHandlers(root, depth = 7) {
|
|
96
|
-
const info = stat(root);
|
|
97
|
-
if (!info?.isDirectory() || !literalPath(root)) return [];
|
|
98
|
-
return readdirSync(root, { withFileTypes: true }).flatMap(entry => {
|
|
99
|
-
const file = path.join(root, entry.name);
|
|
100
|
-
if (entry.isFile() && Object.hasOwn(manifest, entry.name)) return [file];
|
|
101
|
-
return depth > 0 && entry.isDirectory()
|
|
102
|
-
? findHandlers(file, depth - 1)
|
|
103
|
-
: [];
|
|
104
|
-
});
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
/**
|
|
108
|
-
* Replace an owned target atomically, breaking cache hardlinks instead of
|
|
109
|
-
* changing their shared inode. Revalidate the read image immediately before
|
|
110
|
-
* rename. A custom or concurrently changed copy is preserved and reported.
|
|
111
|
-
* @param {string} file Target handler
|
|
112
|
-
* @param {boolean} dryRun Report without writes
|
|
113
|
-
* @returns {{path:string,status:string}} Per-handler result
|
|
114
|
-
*/
|
|
115
|
-
function retireHandler(file, dryRun) {
|
|
116
|
-
const entry = manifest[path.basename(file)];
|
|
117
|
-
const before = stat(file);
|
|
118
|
-
if (!before?.isFile() || !literalPath(file))
|
|
119
|
-
return { path: file, status: "preserved-nonliteral" };
|
|
120
|
-
const fd = openSync(file, constants.O_RDONLY | constants.O_NOFOLLOW);
|
|
121
|
-
let bytes;
|
|
122
|
-
try {
|
|
123
|
-
bytes = readFileSync(fd);
|
|
124
|
-
} finally {
|
|
125
|
-
closeSync(fd);
|
|
126
|
-
}
|
|
127
|
-
if (bytes.equals(Buffer.from(entry.shim)))
|
|
128
|
-
return { path: file, status: "already-retired" };
|
|
129
|
-
if (!entry.hashes.includes(sha(bytes)))
|
|
130
|
-
return { path: file, status: "preserved-custom" };
|
|
131
|
-
if (dryRun) return { path: file, status: "would-retire" };
|
|
132
|
-
const temporary = path.join(
|
|
133
|
-
path.dirname(file),
|
|
134
|
-
`.lisa-retire-${randomUUID()}`
|
|
135
|
-
);
|
|
136
|
-
try {
|
|
137
|
-
writeFileSync(temporary, entry.shim, {
|
|
138
|
-
flag: "wx",
|
|
139
|
-
mode: before.mode & 0o777,
|
|
140
|
-
});
|
|
141
|
-
chmodSync(temporary, before.mode & 0o777);
|
|
142
|
-
const current = stat(file);
|
|
143
|
-
if (
|
|
144
|
-
!literalPath(file) ||
|
|
145
|
-
current?.ino !== before.ino ||
|
|
146
|
-
current?.dev !== before.dev ||
|
|
147
|
-
!readFileSync(file).equals(bytes)
|
|
148
|
-
) {
|
|
149
|
-
throw new Error(
|
|
150
|
-
`Safety-net retirement preserved a concurrently changed handler: ${file}`
|
|
151
|
-
);
|
|
152
|
-
}
|
|
153
|
-
renameSync(temporary, file);
|
|
154
|
-
} finally {
|
|
155
|
-
if (stat(temporary)) unlinkSync(temporary);
|
|
156
|
-
}
|
|
157
|
-
return { path: file, status: "retired" };
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
/**
|
|
161
|
-
* Reconcile existing target handlers; no template apply or evidence writes.
|
|
162
|
-
* @param {{projectDir:string,dryRun?:boolean,pluginRoots?:readonly string[]}} options Scope
|
|
163
|
-
* @returns {{path:string,status:string}[]} Exact decisions
|
|
164
|
-
*/
|
|
165
|
-
export function retireNativeSafetyNet({
|
|
166
|
-
projectDir,
|
|
167
|
-
dryRun = false,
|
|
168
|
-
pluginRoots = [],
|
|
169
|
-
}) {
|
|
170
|
-
const root = realpathSync(projectDir);
|
|
171
|
-
const local = [
|
|
172
|
-
"scripts/lisa-hooks",
|
|
173
|
-
".claude",
|
|
174
|
-
".codex",
|
|
175
|
-
".devin",
|
|
176
|
-
".cursor",
|
|
177
|
-
".opencode",
|
|
178
|
-
".agents/plugins",
|
|
179
|
-
".github/plugins",
|
|
180
|
-
"plugins",
|
|
181
|
-
];
|
|
182
|
-
const handlers = [
|
|
183
|
-
...new Set(
|
|
184
|
-
[...local.map(dir => path.join(root, dir)), ...pluginRoots].flatMap(dir =>
|
|
185
|
-
findHandlers(dir)
|
|
186
|
-
)
|
|
187
|
-
),
|
|
188
|
-
].sort();
|
|
189
|
-
return handlers.map(file => retireHandler(file, dryRun));
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
if (invokedAsScript(import.meta.url)) {
|
|
193
|
-
const args = process.argv.slice(2);
|
|
194
|
-
const supported = new Set(["--install", "--dry-run", "--json"]);
|
|
195
|
-
for (const argument of args.filter(value => value.startsWith("--"))) {
|
|
196
|
-
if (!supported.delete(argument))
|
|
197
|
-
throw new Error(`Unknown or duplicate retirement option: ${argument}`);
|
|
198
|
-
}
|
|
199
|
-
const destinations = args.filter(value => !value.startsWith("--"));
|
|
200
|
-
if (destinations.length > 1)
|
|
201
|
-
throw new Error("Retirement accepts exactly one project destination");
|
|
202
|
-
const dependency = packageRoot.endsWith(
|
|
203
|
-
path.join(path.sep, "node_modules", "@codyswann", "lisa")
|
|
204
|
-
);
|
|
205
|
-
const virtualStore = dependency
|
|
206
|
-
? [".pnpm", ".bun"]
|
|
207
|
-
.map(store => path.join(path.sep, "node_modules", store) + path.sep)
|
|
208
|
-
.find(marker => packageRoot.includes(marker))
|
|
209
|
-
: undefined;
|
|
210
|
-
const installRoot = virtualStore
|
|
211
|
-
? packageRoot.split(virtualStore)[0]
|
|
212
|
-
: dependency
|
|
213
|
-
? path.resolve(packageRoot, "../../..")
|
|
214
|
-
: packageRoot;
|
|
215
|
-
const projectDir = path.resolve(
|
|
216
|
-
destinations[0] ||
|
|
217
|
-
(args.includes("--install") ? installRoot : process.cwd())
|
|
218
|
-
);
|
|
219
|
-
// Source-repository dependency installation is not a downstream update.
|
|
220
|
-
// Explicit apply reuses this reconciler after copying its target templates.
|
|
221
|
-
const selfInstall = args.includes("--install") && projectDir === packageRoot;
|
|
222
|
-
const decisions = selfInstall
|
|
223
|
-
? []
|
|
224
|
-
: retireNativeSafetyNet({
|
|
225
|
-
projectDir,
|
|
226
|
-
dryRun: args.includes("--dry-run"),
|
|
227
|
-
// A source checkout's build/test/apply is not a dependency update. Only
|
|
228
|
-
// an installed dependency reconciles its independent installed copies.
|
|
229
|
-
pluginRoots: dependency ? installedPluginRoots() : [],
|
|
230
|
-
});
|
|
231
|
-
if (args.includes("--json")) console.log(JSON.stringify(decisions));
|
|
232
|
-
else
|
|
233
|
-
for (const decision of decisions) {
|
|
234
|
-
if (decision.status !== "already-retired")
|
|
235
|
-
console.log(`lisa: safety-net ${decision.status}: ${decision.path}`);
|
|
236
|
-
}
|
|
237
|
-
}
|