@codyswann/lisa 2.327.0 → 2.328.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (109) hide show
  1. package/dist/core/upstream-evidence-manifest.d.ts.map +1 -1
  2. package/dist/core/upstream-evidence-manifest.js +30 -6
  3. package/dist/core/upstream-evidence-manifest.js.map +1 -1
  4. package/package.json +2 -2
  5. package/plugins/lisa/.claude-plugin/plugin.json +1 -1
  6. package/plugins/lisa/.codex-plugin/plugin.json +1 -1
  7. package/plugins/lisa/.codex-plugin/skills/lisa-detect-tooling/SKILL.md +21 -1
  8. package/plugins/lisa/.codex-plugin/skills/lisa-detect-tooling/scripts/detect-tooling.mjs +25 -13
  9. package/plugins/lisa/.codex-plugin/skills/lisa-secrets-access/scripts/validate-config.mjs +72 -10
  10. package/plugins/lisa/.codex-plugin/skills/lisa-setup-local-env/SKILL.md +95 -0
  11. package/plugins/lisa/.codex-plugin/skills/lisa-setup-local-env/agents/openai.yaml +4 -0
  12. package/plugins/lisa/.codex-plugin/skills/lisa-setup-local-env/scripts/local-env.mjs +174 -0
  13. package/plugins/lisa/.codex-plugin/skills/lisa-setup-remote-env/SKILL.md +27 -11
  14. package/plugins/lisa/.codex-plugin/skills/lisa-setup-remote-env/scripts/setup-remote-env.mjs +70 -30
  15. package/plugins/lisa/.codex-plugin/skills/lisa-setup-remote-env/scripts/toolchain.mjs +132 -6
  16. package/plugins/lisa/commands/setup/local-env.md +7 -0
  17. package/plugins/lisa/skills/lisa-detect-tooling/SKILL.md +21 -1
  18. package/plugins/lisa/skills/lisa-detect-tooling/scripts/detect-tooling.mjs +25 -13
  19. package/plugins/lisa/skills/lisa-secrets-access/scripts/validate-config.mjs +72 -10
  20. package/plugins/lisa/skills/lisa-setup-local-env/SKILL.md +95 -0
  21. package/plugins/lisa/skills/lisa-setup-local-env/agents/openai.yaml +4 -0
  22. package/plugins/lisa/skills/lisa-setup-local-env/scripts/local-env.mjs +174 -0
  23. package/plugins/lisa/skills/lisa-setup-remote-env/SKILL.md +27 -11
  24. package/plugins/lisa/skills/lisa-setup-remote-env/scripts/setup-remote-env.mjs +70 -30
  25. package/plugins/lisa/skills/lisa-setup-remote-env/scripts/toolchain.mjs +132 -6
  26. package/plugins/lisa-agy/commands/lisa/setup/local-env.md +7 -0
  27. package/plugins/lisa-agy/plugin.json +1 -1
  28. package/plugins/lisa-agy/skills/lisa-detect-tooling/SKILL.md +21 -1
  29. package/plugins/lisa-agy/skills/lisa-detect-tooling/scripts/detect-tooling.mjs +25 -13
  30. package/plugins/lisa-agy/skills/lisa-secrets-access/scripts/validate-config.mjs +72 -10
  31. package/plugins/lisa-agy/skills/lisa-setup-local-env/SKILL.md +95 -0
  32. package/plugins/lisa-agy/skills/lisa-setup-local-env/scripts/local-env.mjs +174 -0
  33. package/plugins/lisa-agy/skills/lisa-setup-remote-env/SKILL.md +27 -11
  34. package/plugins/lisa-agy/skills/lisa-setup-remote-env/scripts/setup-remote-env.mjs +70 -30
  35. package/plugins/lisa-agy/skills/lisa-setup-remote-env/scripts/toolchain.mjs +132 -6
  36. package/plugins/lisa-cdk/.claude-plugin/plugin.json +1 -1
  37. package/plugins/lisa-cdk/.codex-plugin/plugin.json +1 -1
  38. package/plugins/lisa-cdk-agy/plugin.json +1 -1
  39. package/plugins/lisa-cdk-copilot/.claude-plugin/plugin.json +1 -1
  40. package/plugins/lisa-cdk-cursor/.claude-plugin/plugin.json +1 -1
  41. package/plugins/lisa-copilot/.claude-plugin/plugin.json +1 -1
  42. package/plugins/lisa-copilot/commands/lisa/setup/local-env.md +7 -0
  43. package/plugins/lisa-copilot/skills/lisa-detect-tooling/SKILL.md +21 -1
  44. package/plugins/lisa-copilot/skills/lisa-detect-tooling/scripts/detect-tooling.mjs +25 -13
  45. package/plugins/lisa-copilot/skills/lisa-secrets-access/scripts/validate-config.mjs +72 -10
  46. package/plugins/lisa-copilot/skills/lisa-setup-local-env/SKILL.md +95 -0
  47. package/plugins/lisa-copilot/skills/lisa-setup-local-env/scripts/local-env.mjs +174 -0
  48. package/plugins/lisa-copilot/skills/lisa-setup-remote-env/SKILL.md +27 -11
  49. package/plugins/lisa-copilot/skills/lisa-setup-remote-env/scripts/setup-remote-env.mjs +70 -30
  50. package/plugins/lisa-copilot/skills/lisa-setup-remote-env/scripts/toolchain.mjs +132 -6
  51. package/plugins/lisa-cursor/.claude-plugin/plugin.json +1 -1
  52. package/plugins/lisa-cursor/commands/lisa/setup/local-env.md +7 -0
  53. package/plugins/lisa-cursor/skills/lisa-detect-tooling/SKILL.md +21 -1
  54. package/plugins/lisa-cursor/skills/lisa-detect-tooling/scripts/detect-tooling.mjs +25 -13
  55. package/plugins/lisa-cursor/skills/lisa-secrets-access/scripts/validate-config.mjs +72 -10
  56. package/plugins/lisa-cursor/skills/lisa-setup-local-env/SKILL.md +95 -0
  57. package/plugins/lisa-cursor/skills/lisa-setup-local-env/scripts/local-env.mjs +174 -0
  58. package/plugins/lisa-cursor/skills/lisa-setup-remote-env/SKILL.md +27 -11
  59. package/plugins/lisa-cursor/skills/lisa-setup-remote-env/scripts/setup-remote-env.mjs +70 -30
  60. package/plugins/lisa-cursor/skills/lisa-setup-remote-env/scripts/toolchain.mjs +132 -6
  61. package/plugins/lisa-expo/.claude-plugin/plugin.json +1 -1
  62. package/plugins/lisa-expo/.codex-plugin/plugin.json +1 -1
  63. package/plugins/lisa-expo-agy/plugin.json +1 -1
  64. package/plugins/lisa-expo-copilot/.claude-plugin/plugin.json +1 -1
  65. package/plugins/lisa-expo-cursor/.claude-plugin/plugin.json +1 -1
  66. package/plugins/lisa-harper-fabric/.claude-plugin/plugin.json +1 -1
  67. package/plugins/lisa-harper-fabric/.codex-plugin/plugin.json +1 -1
  68. package/plugins/lisa-harper-fabric-agy/plugin.json +1 -1
  69. package/plugins/lisa-harper-fabric-copilot/.claude-plugin/plugin.json +1 -1
  70. package/plugins/lisa-harper-fabric-cursor/.claude-plugin/plugin.json +1 -1
  71. package/plugins/lisa-nestjs/.claude-plugin/plugin.json +1 -1
  72. package/plugins/lisa-nestjs/.codex-plugin/plugin.json +1 -1
  73. package/plugins/lisa-nestjs-agy/plugin.json +1 -1
  74. package/plugins/lisa-nestjs-copilot/.claude-plugin/plugin.json +1 -1
  75. package/plugins/lisa-nestjs-cursor/.claude-plugin/plugin.json +1 -1
  76. package/plugins/lisa-openclaw/.claude-plugin/plugin.json +1 -1
  77. package/plugins/lisa-openclaw/.codex-plugin/plugin.json +1 -1
  78. package/plugins/lisa-openclaw-agy/plugin.json +1 -1
  79. package/plugins/lisa-openclaw-copilot/.claude-plugin/plugin.json +1 -1
  80. package/plugins/lisa-openclaw-cursor/.claude-plugin/plugin.json +1 -1
  81. package/plugins/lisa-phaser/.claude-plugin/plugin.json +1 -1
  82. package/plugins/lisa-phaser/.codex-plugin/plugin.json +1 -1
  83. package/plugins/lisa-phaser-agy/plugin.json +1 -1
  84. package/plugins/lisa-phaser-copilot/.claude-plugin/plugin.json +1 -1
  85. package/plugins/lisa-phaser-cursor/.claude-plugin/plugin.json +1 -1
  86. package/plugins/lisa-rails/.claude-plugin/plugin.json +1 -1
  87. package/plugins/lisa-rails/.codex-plugin/plugin.json +1 -1
  88. package/plugins/lisa-rails-agy/plugin.json +1 -1
  89. package/plugins/lisa-rails-copilot/.claude-plugin/plugin.json +1 -1
  90. package/plugins/lisa-rails-cursor/.claude-plugin/plugin.json +1 -1
  91. package/plugins/lisa-typescript/.claude-plugin/plugin.json +1 -1
  92. package/plugins/lisa-typescript/.codex-plugin/plugin.json +1 -1
  93. package/plugins/lisa-typescript-agy/plugin.json +1 -1
  94. package/plugins/lisa-typescript-copilot/.claude-plugin/plugin.json +1 -1
  95. package/plugins/lisa-typescript-cursor/.claude-plugin/plugin.json +1 -1
  96. package/plugins/lisa-wiki/.claude-plugin/plugin.json +1 -1
  97. package/plugins/lisa-wiki/.codex-plugin/plugin.json +1 -1
  98. package/plugins/lisa-wiki-agy/plugin.json +1 -1
  99. package/plugins/lisa-wiki-copilot/.claude-plugin/plugin.json +1 -1
  100. package/plugins/lisa-wiki-cursor/.claude-plugin/plugin.json +1 -1
  101. package/plugins/src/base/commands/setup/local-env.md +7 -0
  102. package/plugins/src/base/skills/lisa-detect-tooling/SKILL.md +21 -1
  103. package/plugins/src/base/skills/lisa-detect-tooling/scripts/detect-tooling.mjs +25 -13
  104. package/plugins/src/base/skills/lisa-secrets-access/scripts/validate-config.mjs +72 -10
  105. package/plugins/src/base/skills/lisa-setup-local-env/SKILL.md +95 -0
  106. package/plugins/src/base/skills/lisa-setup-local-env/scripts/local-env.mjs +174 -0
  107. package/plugins/src/base/skills/lisa-setup-remote-env/SKILL.md +27 -11
  108. package/plugins/src/base/skills/lisa-setup-remote-env/scripts/setup-remote-env.mjs +70 -30
  109. package/plugins/src/base/skills/lisa-setup-remote-env/scripts/toolchain.mjs +132 -6
@@ -0,0 +1,174 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Bring a developer's machine in line with the toolchain the project declares.
4
+ *
5
+ * The manifest, the planner, the pins and the installers are the remote flow's,
6
+ * unchanged and imported — this is the surface that was missing, not a second
7
+ * implementation. `remoteEnv.tools` was always surface-aware and the executor
8
+ * always understood `local`; the only way to reach either was to run a file
9
+ * called `setup-remote-env.mjs` out of a directory called `lisa-remote-env`,
10
+ * which nobody looking for local setup ever found.
11
+ *
12
+ * Two things differ from the remote flow, and both are because a person is here:
13
+ *
14
+ * consent — a container provisions itself silently because it is disposable
15
+ * and nobody is watching. A laptop belongs to someone, so nothing
16
+ * is installed until they ask with --install-tools.
17
+ *
18
+ * tolerance — a container that cannot be fully provisioned should fail before
19
+ * it half-runs, because there is no one to read the report. A
20
+ * developer can act on a list, so an unprovisionable tool is
21
+ * reported, everything else is still installed, and the exit code
22
+ * carries the failure.
23
+ * @module local-env
24
+ */
25
+
26
+ import { existsSync } from "node:fs";
27
+ import { dirname, resolve } from "node:path";
28
+ import { fileURLToPath, pathToFileURL } from "node:url";
29
+
30
+ const HERE = dirname(fileURLToPath(import.meta.url));
31
+
32
+ /**
33
+ * Resolve a script belonging to a sibling skill.
34
+ *
35
+ * Skills are always siblings under one `skills/` directory, in every install
36
+ * layout, so this holds for a plugin install, a checkout, and node_modules
37
+ * alike. Failing loudly here beats reimplementing what the sibling owns.
38
+ * @param {string} skill Sibling skill slug.
39
+ * @param {string} script Script filename.
40
+ * @returns {string} Absolute path.
41
+ */
42
+ function siblingScript(skill, script) {
43
+ const path = resolve(HERE, "..", "..", skill, "scripts", script);
44
+ if (!existsSync(path)) {
45
+ throw new Error(
46
+ `cannot find ${skill}/scripts/${script} beside this skill.\n` +
47
+ `Local setup composes with that skill rather than reimplementing it: ` +
48
+ `the pins, checksums and installers must be the same ones the remote ` +
49
+ `surface uses, or the two drift and only one gets fixed.`
50
+ );
51
+ }
52
+ return path;
53
+ }
54
+
55
+ /**
56
+ * Load the pieces the remote flow owns.
57
+ * @returns {Promise<object>} The imported helpers.
58
+ */
59
+ async function loadRemoteEnv() {
60
+ const setup = await import(
61
+ pathToFileURL(
62
+ siblingScript("lisa-setup-remote-env", "setup-remote-env.mjs")
63
+ ).href
64
+ );
65
+ const toolchain = await import(
66
+ pathToFileURL(siblingScript("lisa-setup-remote-env", "toolchain.mjs")).href
67
+ );
68
+ return { ...toolchain, ...setup };
69
+ }
70
+
71
+ /**
72
+ * Describe one blocked decision in terms a person can act on.
73
+ *
74
+ * A blocked step on a laptop is usually one of two things, and they are fixed
75
+ * differently: a tool the project requires and the machine lacks (install it),
76
+ * or a tool with no artifact pinned for this platform (add the pin, or install
77
+ * it however this platform normally would). Printing the planner's reason alone
78
+ * left the reader to work out which.
79
+ * @param {object} step A plan step.
80
+ * @param {string} platform The platform key that was resolved against.
81
+ * @returns {string} A rendered block.
82
+ */
83
+ function explainBlocked(step, platform) {
84
+ if (step.action === "invalid" && step.reason.includes("no pin for")) {
85
+ return (
86
+ ` ${step.name} — declared, but no artifact is pinned for ${platform}.\n` +
87
+ ` Lisa will not guess a download URL, because a guessed artifact is ` +
88
+ `one the checksum cannot vouch for.\n` +
89
+ ` Add a "${platform}" block under this tool's "platforms" map, or ` +
90
+ `install it yourself.`
91
+ );
92
+ }
93
+ return ` ${step.name} — ${step.reason.split("\n")[0]}`;
94
+ }
95
+
96
+ /**
97
+ * Report and optionally apply the local toolchain.
98
+ * @param {object} argv Parsed arguments.
99
+ * @returns {Promise<number>} Process exit code.
100
+ */
101
+ export async function run(argv) {
102
+ const env = await loadRemoteEnv();
103
+ // Both seams exist for tests, and both default to this machine. A platform
104
+ // that can only be exercised by running on it is one CI will never cover,
105
+ // which is how a resolution bug ships to the platform nobody tested.
106
+ const platform = argv.platform ?? env.currentPlatform();
107
+ const { tools } = env.readRemoteEnvConfig(argv.cwd);
108
+
109
+ const declared = (tools.require ?? []).length + (tools.install ?? []).length;
110
+ if (declared === 0) {
111
+ console.log(
112
+ "No tools are declared in remoteEnv.tools, so there is nothing to check.\n" +
113
+ "Run /lisa:detect-tooling — it reads npm scripts, MCP servers, " +
114
+ "credential\nnotes and quality config, and proposes pinned entries for " +
115
+ "what it finds."
116
+ );
117
+ return 0;
118
+ }
119
+
120
+ const plan = env.planToolchain(tools, env.probe, "local", platform);
121
+ const blocked = plan.filter(
122
+ step => step.action === "missing" || step.action === "invalid"
123
+ );
124
+ const installable = plan.filter(step => step.action === "install");
125
+
126
+ if (argv.json) {
127
+ console.log(JSON.stringify({ platform, plan }, null, 2));
128
+ return blocked.length ? 1 : 0;
129
+ }
130
+
131
+ console.log(`Local toolchain for ${platform}\n`);
132
+ for (const step of plan) {
133
+ console.log(` ${step.action.padEnd(8)} ${step.reason.split("\n")[0]}`);
134
+ }
135
+
136
+ if (installable.length && !argv.installTools) {
137
+ console.log(
138
+ `\n${installable.length} declared tool(s) can be installed here.\n` +
139
+ `Nothing has been installed: this machine is yours, not a container.\n` +
140
+ `Re-run with --install-tools to provision them into ~/.local/bin.`
141
+ );
142
+ }
143
+
144
+ if (installable.length && argv.installTools) {
145
+ const binDir = env.ensureBinDir();
146
+ console.log(`\nInstalling into ${binDir}`);
147
+ for (const step of installable) {
148
+ console.log(` ${step.name}`);
149
+ if (!argv.dryRun) env.installTool(step.tool, binDir);
150
+ }
151
+ }
152
+
153
+ if (blocked.length) {
154
+ console.log(`\n${blocked.length} tool(s) this command cannot resolve:\n`);
155
+ for (const step of blocked) console.log(explainBlocked(step, platform));
156
+ return 1;
157
+ }
158
+
159
+ return 0;
160
+ }
161
+
162
+ if (import.meta.url === `file://${process.argv[1]}`) {
163
+ const argv = {
164
+ installTools: process.argv.includes("--install-tools"),
165
+ dryRun: process.argv.includes("--dry-run"),
166
+ json: process.argv.includes("--json"),
167
+ };
168
+ run(argv)
169
+ .then(code => process.exit(code))
170
+ .catch(err => {
171
+ console.error(err.message);
172
+ process.exit(1);
173
+ });
174
+ }
@@ -95,6 +95,19 @@ This repository has paid for that twice: `gh` was declared nowhere and a cloud s
95
95
 
96
96
  The detector proposes and a human decides. It writes nothing, so provisioning still only ever happens from a reviewed, pinned, checksummed entry.
97
97
 
98
+ ## The same manifest provisions a laptop
99
+
100
+ `remoteEnv.tools` is not a remote-only manifest, and `/lisa:setup:local-env` is how a developer
101
+ applies it to their own machine — same pins, same checksums, same installers, differing only in
102
+ that nothing installs without `--install-tools` and that a newer tool already on `PATH` is left
103
+ alone rather than downgraded.
104
+
105
+ A downloaded tool declares a `platforms` map keyed `<platform>-<arch>`, each block carrying its
106
+ own `install` method, `url`, and `sha256`, because the artifact and the archive kind both vary
107
+ by platform. Before that existed, the only way to keep a Linux binary off a laptop was
108
+ `surfaces: ["remote"]`, which achieved it by making the tool uninstallable there — so `bws` and
109
+ `gh` were required on developer machines and provisionable only in containers.
110
+
98
111
  ## Toolchain manifest — two entry kinds
99
112
 
100
113
  ```json
@@ -108,20 +121,23 @@ The detector proposes and a human decides. It writes nothing, so provisioning st
108
121
  { "name": "unzip" }
109
122
  ],
110
123
  "install": [
111
- {
112
- "name": "bws",
113
- "version": "2.1.0",
114
- "install": "release-zip",
115
- "url": "https://<vendor>/releases/download/bws-v2.1.0/bws-<platform>-2.1.0.zip",
116
- "sha256": "<sha256 published with that exact release>"
117
- },
118
124
  {
119
125
  "name": "gh",
120
126
  "version": "2.83.0",
121
- "install": "release-tar",
122
- "url": "https://<vendor>/releases/download/v2.83.0/gh_2.83.0_linux_amd64.tar.gz",
123
- "sha256": "<sha256 published with that exact release>",
124
- "binary": "gh_2.83.0_linux_amd64/bin/gh"
127
+ "platforms": {
128
+ "linux-x64": {
129
+ "install": "release-tar",
130
+ "url": "https://<vendor>/releases/download/v2.83.0/gh_2.83.0_linux_amd64.tar.gz",
131
+ "sha256": "<sha256 published with that exact release>",
132
+ "binary": "gh_2.83.0_linux_amd64/bin/gh"
133
+ },
134
+ "darwin-arm64": {
135
+ "install": "release-zip",
136
+ "url": "https://<vendor>/releases/download/v2.83.0/gh_2.83.0_macOS_arm64.zip",
137
+ "sha256": "<sha256 published with that exact release>",
138
+ "binary": "gh_2.83.0_macOS_arm64/bin/gh"
139
+ }
140
+ }
125
141
  },
126
142
  {
127
143
  "name": "codex",
@@ -29,6 +29,7 @@
29
29
  */
30
30
 
31
31
  import { execFileSync } from "node:child_process";
32
+ import { createHash } from "node:crypto";
32
33
  import {
33
34
  chmodSync,
34
35
  existsSync,
@@ -37,7 +38,7 @@ import {
37
38
  rmSync,
38
39
  writeFileSync,
39
40
  } from "node:fs";
40
- import { basename, delimiter, dirname, join, resolve } from "node:path";
41
+ import { delimiter, dirname, join, resolve } from "node:path";
41
42
  import { fileURLToPath, pathToFileURL } from "node:url";
42
43
 
43
44
  import { assertPinned, extractVersion, planToolchain } from "./toolchain.mjs";
@@ -122,6 +123,34 @@ export function probe(name, exec = execFileSync) {
122
123
  }
123
124
  }
124
125
 
126
+ /**
127
+ * Refuse an archive whose contents are not exactly what was pinned.
128
+ *
129
+ * Hashed in-process rather than by shelling out. `sha256sum` is a GNU coreutils
130
+ * program: it is not present on a stock macOS, where the equivalent is
131
+ * `shasum -a 256`, and it was never in the manifest's `require` list either — so
132
+ * the verification step depended on a tool nothing asserted, on every surface.
133
+ * Doing it here removes the dependency instead of adding a second name to probe
134
+ * for, and the check can then be tested without a real archive or a real binary.
135
+ * @param {string} archive Path to the downloaded file.
136
+ * @param {string} expected Pinned lowercase hex digest.
137
+ * @param {string} name Tool name, for the message.
138
+ */
139
+ export function verifyChecksum(archive, expected, name) {
140
+ const actual = createHash("sha256")
141
+ .update(readFileSync(archive))
142
+ .digest("hex");
143
+ if (actual !== String(expected).trim().toLowerCase()) {
144
+ throw new Error(
145
+ `${name}: checksum mismatch — refusing to install.\n` +
146
+ ` expected ${expected}\n` +
147
+ ` actual ${actual}\n` +
148
+ `The URL served something other than the reviewed artifact. Do not ` +
149
+ `update the pin to match without establishing why it changed.`
150
+ );
151
+ }
152
+ }
153
+
125
154
  /**
126
155
  * Install a pinned archive, refusing anything whose checksum does not match.
127
156
  * @param {object} tool Manifest entry.
@@ -137,10 +166,7 @@ function installReleaseZip(tool, binDir) {
137
166
  });
138
167
  // Verify before unpacking, not after. An unexpected archive must fail
139
168
  // before any of its contents reach a directory that is on PATH.
140
- execFileSync("sha256sum", ["-c", "-"], {
141
- input: `${tool.sha256} ${archive}\n`,
142
- stdio: ["pipe", "ignore", "inherit"],
143
- });
169
+ verifyChecksum(archive, tool.sha256, tool.name);
144
170
  execFileSync("unzip", ["-q", "-o", archive, "-d", temporary], {
145
171
  stdio: "inherit",
146
172
  });
@@ -171,10 +197,7 @@ function installReleaseTar(tool, binDir) {
171
197
  execFileSync("curl", ["-fsSL", tool.url, "-o", archive], {
172
198
  stdio: "inherit",
173
199
  });
174
- execFileSync("sha256sum", ["-c", "-"], {
175
- input: `${tool.sha256} ${archive}\n`,
176
- stdio: ["pipe", "ignore", "inherit"],
177
- });
200
+ verifyChecksum(archive, tool.sha256, tool.name);
178
201
  execFileSync("tar", ["-xzf", archive, "-C", temporary], {
179
202
  stdio: "inherit",
180
203
  });
@@ -205,16 +228,46 @@ function installNpmGlobal(tool) {
205
228
 
206
229
  /**
207
230
  * Execute one install decision.
208
- * @param {object} tool Manifest entry.
231
+ *
232
+ * Exported because the local-environment flow installs from the same manifest
233
+ * with the same pins and the same checksum refusal. A second installer would be
234
+ * a second thing to keep honest, and the one people run least would rot.
235
+ * @param {object} tool Manifest entry, already resolved to this platform.
209
236
  * @param {string} binDir Directory for downloaded binaries.
210
237
  */
211
- function installTool(tool, binDir) {
238
+ export function installTool(tool, binDir) {
212
239
  assertPinned(tool);
213
240
  if (tool.install === "release-zip") installReleaseZip(tool, binDir);
214
241
  else if (tool.install === "release-tar") installReleaseTar(tool, binDir);
215
242
  else installNpmGlobal(tool);
216
243
  }
217
244
 
245
+ /**
246
+ * Create the directory installs land in, and make sure PATH will find it.
247
+ *
248
+ * Installing a binary somewhere nothing looks is the same as not installing it.
249
+ * `~/.local/bin` is on PATH by default on a developer workstation and is NOT on
250
+ * a minimal container, so the toolchain step reported `install bws`, the file
251
+ * landed at ~/.local/bin/bws mode 755, and the very next step died with
252
+ * `spawnSync bws ENOENT`.
253
+ *
254
+ * This was invisible in every local test because a workstation shell already
255
+ * exports the directory — the environment doing the hiding was the one used to
256
+ * verify the fix.
257
+ *
258
+ * Prepended, not appended: a pinned-and-checksummed binary must win over
259
+ * whatever an image happens to ship under the same name.
260
+ * @returns {string} The directory installs are written to.
261
+ */
262
+ export function ensureBinDir() {
263
+ const binDir = join(process.env.HOME ?? "", ".local", "bin");
264
+ mkdirSync(binDir, { recursive: true, mode: 0o755 });
265
+ if (!pathContains(binDir)) {
266
+ process.env.PATH = `${binDir}${delimiter}${process.env.PATH ?? ""}`;
267
+ }
268
+ return binDir;
269
+ }
270
+
218
271
  /**
219
272
  * Apply the toolchain plan, reporting every decision.
220
273
  * @param {object} tools Manifest.
@@ -231,8 +284,7 @@ function applyToolchain(tools, dryRun, options = {}) {
231
284
  throw new Error(blocked.map(p => p.reason).join("\n\n"));
232
285
  }
233
286
 
234
- const binDir = join(process.env.HOME ?? "", ".local", "bin");
235
- mkdirSync(binDir, { recursive: true, mode: 0o755 });
287
+ const binDir = ensureBinDir();
236
288
  const byName = new Map((tools.install ?? []).map(t => [t.name, t]));
237
289
 
238
290
  // Installing is a different act on a laptop than in a container. A container
@@ -263,26 +315,14 @@ function applyToolchain(tools, dryRun, options = {}) {
263
315
  return plan;
264
316
  }
265
317
 
266
- // Installing a binary somewhere nothing looks is the same as not installing
267
- // it. `~/.local/bin` is on PATH by default on a developer workstation and is
268
- // NOT on a minimal container, so the toolchain step reported `install bws`,
269
- // the file landed at ~/.local/bin/bws mode 755, and the very next step died
270
- // with `spawnSync bws ENOENT`.
271
- //
272
- // This was invisible in every local test because a workstation shell already
273
- // exports the directory — the environment doing the hiding was the one used
274
- // to verify the fix.
275
- //
276
- // Prepended, not appended: a pinned-and-checksummed binary must win over
277
- // whatever an image happens to ship under the same name.
278
- if (!pathContains(binDir)) {
279
- process.env.PATH = `${binDir}${delimiter}${process.env.PATH ?? ""}`;
280
- }
281
-
282
318
  for (const step of plan) {
283
319
  console.log(` ${step.action.padEnd(8)} ${step.reason}`);
320
+ // The planner already resolved this entry to the running platform, so use
321
+ // what it decided rather than looking the raw entry up again. `byName` is
322
+ // the pre-platform shape and would hand the installer a url that belongs to
323
+ // whichever platform happened to be written first.
284
324
  if (step.action === "install" && !dryRun)
285
- installTool(byName.get(step.name), binDir);
325
+ installTool(step.tool ?? byName.get(step.name), binDir);
286
326
  }
287
327
  return plan;
288
328
  }
@@ -100,7 +100,7 @@ function planRequired(tool, found) {
100
100
  * @param {{version: string|null, present: boolean}} found Probe result.
101
101
  * @returns {{name: string, action: string, reason: string}} The decision.
102
102
  */
103
- function planInstallable(tool, found) {
103
+ function planInstallable(tool, found, pinIsFloor = false) {
104
104
  if (!tool.version) {
105
105
  return {
106
106
  name: tool.name,
@@ -115,6 +115,25 @@ function planInstallable(tool, found) {
115
115
  reason: `${tool.name} ${tool.version} already installed`,
116
116
  };
117
117
  }
118
+ // On a laptop the pin is a floor, not an equality. A container is disposable
119
+ // and reproducible by construction, so an exact match is right there. A
120
+ // developer's machine is shared with every other project they work on, and
121
+ // installing a pinned binary into ~/.local/bin ahead of a NEWER one already on
122
+ // PATH is a downgrade this project imposed on all of them — for gh, pinned at
123
+ // 2.83.0 against a workstation running 2.96.0, that is the likely case rather
124
+ // than the exotic one.
125
+ if (
126
+ pinIsFloor &&
127
+ found.present &&
128
+ found.version &&
129
+ compareVersions(found.version, tool.version) > 0
130
+ ) {
131
+ return {
132
+ name: tool.name,
133
+ action: "newer",
134
+ reason: `${tool.name} ${found.version} is newer than the pinned ${tool.version} — leaving it alone`,
135
+ };
136
+ }
118
137
  return {
119
138
  name: tool.name,
120
139
  action: "install",
@@ -127,6 +146,72 @@ function planInstallable(tool, found) {
127
146
  /** Surfaces a manifest entry may name. */
128
147
  const KNOWN_SURFACES = new Set(["local", "remote"]);
129
148
 
149
+ /**
150
+ * The platform key a manifest entry is resolved against.
151
+ *
152
+ * `<platform>-<arch>` rather than either alone, because both halves change the
153
+ * artifact: an Apple Silicon laptop and an Intel one run different builds of the
154
+ * same release, and so do an arm64 container and an amd64 one.
155
+ * @param {{platform: string, arch: string}} [runtime] Injectable, for tests.
156
+ * @returns {string} A key such as "darwin-arm64" or "linux-x64".
157
+ */
158
+ export function currentPlatform(runtime = process) {
159
+ return `${runtime.platform}-${runtime.arch}`;
160
+ }
161
+
162
+ /**
163
+ * Collapse a manifest entry to the artifact for one platform.
164
+ *
165
+ * A download URL is platform-specific and a checksum doubly so, which the
166
+ * single-URL shape could not express: the only way to stop a laptop being handed
167
+ * a Linux binary was `surfaces: ["remote"]`, which bought that safety by making
168
+ * the tool uninstallable on the laptop entirely. So `bws` and `gh` — the two
169
+ * tools Lisa's own guardrails shell out to — were declared, required, and
170
+ * unprovisionable on the machine most likely to be missing them.
171
+ *
172
+ * A `platforms` map fixes the cause instead of the symptom. `install` lives
173
+ * inside each block rather than beside it, because the method varies too: gh
174
+ * publishes a .tar.gz for Linux and a .zip for macOS, so a single install method
175
+ * would have forced one platform onto an archive kind its vendor does not ship.
176
+ *
177
+ * A flat entry is still valid and means "identical everywhere" — true of every
178
+ * `npm-global` install, which is genuinely platform-independent.
179
+ * @param {object} tool Manifest entry.
180
+ * @param {string} [platform] Platform key to resolve for.
181
+ * @returns {object} The entry with its platform block merged in.
182
+ */
183
+ export function resolvePlatform(tool, platform = currentPlatform()) {
184
+ const { platforms } = tool;
185
+ if (platforms === undefined) return tool;
186
+ if (
187
+ typeof platforms !== "object" ||
188
+ platforms === null ||
189
+ Array.isArray(platforms)
190
+ ) {
191
+ throw new Error(
192
+ `${tool.name}: platforms must be an object keyed by <platform>-<arch>, ` +
193
+ `got ${Array.isArray(platforms) ? "an array" : typeof platforms}.\n` +
194
+ `Omit it when one artifact serves every platform.`
195
+ );
196
+ }
197
+ const block = platforms[platform];
198
+ if (!block) {
199
+ const known = Object.keys(platforms).sort().join(", ");
200
+ throw new Error(
201
+ `${tool.name}: no pin for ${platform}.\n` +
202
+ `Declared platforms: ${known || "(none)"}.\n` +
203
+ `Add a block for ${platform} with its own url and sha256, or drop the ` +
204
+ `tool from this surface. Guessing an artifact would defeat the ` +
205
+ `checksum.`
206
+ );
207
+ }
208
+ // The platform block wins over the shared fields, and `platforms` itself is
209
+ // dropped so a resolved entry is indistinguishable from a flat one — that is
210
+ // what lets assertPinned and the installers stay unaware of any of this.
211
+ const { platforms: _discarded, ...shared } = tool;
212
+ return { ...shared, ...block };
213
+ }
214
+
130
215
  /**
131
216
  * Whether a manifest entry applies to the surface being provisioned.
132
217
  *
@@ -171,18 +256,48 @@ export function appliesToSurface(tool, surface) {
171
256
 
172
257
  /**
173
258
  * Produce the complete plan for a toolchain manifest.
259
+ *
260
+ * Install entries are resolved to the running platform here rather than at
261
+ * install time, so a tool with no artifact for this machine is reported
262
+ * alongside every other problem instead of aborting the run at the first one.
263
+ * An operator fixing a manifest wants the whole list.
264
+ *
265
+ * `require` entries are deliberately not resolved: they carry a name and a
266
+ * minimum version, nothing platform-specific, and inventing a per-platform shape
267
+ * for them would be ceremony with no artifact behind it.
174
268
  * @param {{require?: object[], install?: object[]}} tools Manifest.
175
269
  * @param {(name: string) => {version: string|null, present: boolean}} probe Version probe.
176
- * @returns {Array<{name: string, action: string, reason: string}>} Ordered decisions.
270
+ * @param {string} [surface] Surface being provisioned.
271
+ * @param {string} [platform] Platform key to resolve install entries against.
272
+ * @returns {Array<{name: string, action: string, reason: string, tool?: object}>} Ordered decisions.
177
273
  */
178
- export function planToolchain(tools, probe, surface = "remote") {
274
+ export function planToolchain(
275
+ tools,
276
+ probe,
277
+ surface = "remote",
278
+ platform = currentPlatform()
279
+ ) {
179
280
  const plan = [];
180
281
  for (const tool of tools.require ?? [])
181
282
  if (appliesToSurface(tool, surface))
182
283
  plan.push(planRequired(tool, probe(tool.name)));
183
- for (const tool of tools.install ?? [])
184
- if (appliesToSurface(tool, surface))
185
- plan.push(planInstallable(tool, probe(tool.name)));
284
+ for (const tool of tools.install ?? []) {
285
+ if (!appliesToSurface(tool, surface)) continue;
286
+ let resolved;
287
+ try {
288
+ resolved = resolvePlatform(tool, platform);
289
+ } catch (err) {
290
+ plan.push({ name: tool.name, action: "invalid", reason: err.message });
291
+ continue;
292
+ }
293
+ // The resolved entry travels with the decision so the installer never has to
294
+ // resolve a second time — two resolutions are two chances to disagree, and
295
+ // the one that installs would be the one nothing tested.
296
+ plan.push({
297
+ ...planInstallable(resolved, probe(tool.name), surface === "local"),
298
+ tool: resolved,
299
+ });
300
+ }
186
301
  return plan;
187
302
  }
188
303
 
@@ -195,6 +310,17 @@ export function planToolchain(tools, probe, surface = "remote") {
195
310
  * @param {object} tool Manifest entry.
196
311
  */
197
312
  export function assertPinned(tool) {
313
+ // An unresolved entry reaching here means a caller skipped resolvePlatform and
314
+ // is about to read a url and sha256 that belong to no platform in particular.
315
+ // Refusing is the point: the failure this whole change exists to prevent is
316
+ // exactly "downloaded the wrong platform's artifact", and a silent pass here
317
+ // would reintroduce it one call site at a time.
318
+ if (tool.platforms !== undefined) {
319
+ throw new Error(
320
+ `${tool.name}: platform-specific entry was not resolved before install.\n` +
321
+ `Call resolvePlatform() first — the shared fields alone do not name an artifact.`
322
+ );
323
+ }
198
324
  // Both archive kinds carry the same obligation, and differ only in how they
199
325
  // are unpacked. gh, for one, publishes no zip for Linux at all — only .deb,
200
326
  // .rpm and .tar.gz — so a zip-only installer could not pin the CLI that
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa",
3
- "version": "2.327.0",
3
+ "version": "2.328.1",
4
4
  "description": "Universal governance — agents, skills, commands, hooks, and rules for all projects",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -0,0 +1,7 @@
1
+ ---
2
+ description: "Bring this machine in line with the toolchain the project declares. Reports every tool in remoteEnv.tools that is missing, outdated, or unpinned for this platform, and installs the missing ones into ~/.local/bin from the same pinned, checksummed entries the remote surfaces use — but only when asked with --install-tools. A newer tool already on PATH is left alone."
3
+ allowed-tools: ["Skill"]
4
+ argument-hint: "[--install-tools] [--json]"
5
+ ---
6
+
7
+ Use the /lisa-setup-local-env skill to report and optionally install the project's declared toolchain on this machine. $ARGUMENTS
@@ -46,7 +46,27 @@ What genuinely differs is **consent**, not the list:
46
46
 
47
47
  Omitting `surfaces` means every surface, because that is true of most tools and the cost of forgetting should be a redundant check rather than a silent absence.
48
48
 
49
- A platform-specific pin is the exception worth knowing: a Linux release archive must be `surfaces: ["remote"]`, with a matching `require` entry for `local`, so a laptop asserts the tool without being offered a binary it cannot run.
49
+ Platform differences are **not** expressed with `surfaces`. A downloaded tool declares a
50
+ `platforms` map keyed `<platform>-<arch>`, each block carrying its own `install` method, `url`,
51
+ and `sha256`:
52
+
53
+ ```json
54
+ "platforms": {
55
+ "linux-x64": { "install": "release-tar", "url": "...", "sha256": "..." },
56
+ "darwin-arm64": { "install": "release-zip", "url": "...", "sha256": "..." }
57
+ }
58
+ ```
59
+
60
+ The method lives inside the block because it varies — gh ships a `.tar.gz` for Linux and a
61
+ `.zip` for macOS. A flat entry means one artifact serves everything, which is true of
62
+ `npm-global` and nothing else.
63
+
64
+ This replaces an earlier convention worth naming, because its residue may still be in a
65
+ manifest you read: a Linux archive used to be marked `surfaces: ["remote"]` with a bare
66
+ `require` entry for `local`, so a laptop asserted the tool without being offered a binary it
67
+ could not run. That kept the wrong binary off the laptop by making the tool uninstallable
68
+ there — which is how `bws` and `gh`, the two CLIs Lisa's own guardrails shell out to, came to
69
+ be required on developer machines and provisionable only in containers.
50
70
 
51
71
  ## Usage
52
72