@picassohq/cli 0.0.0-stage → 1.0.2

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 (232) hide show
  1. package/agents/browser_agent.yaml +53 -0
  2. package/agents/code_reviewer.yaml +49 -0
  3. package/agents/codebase_investigator.yaml +70 -0
  4. package/agents/design_auditor.yaml +50 -0
  5. package/agents/devex_auditor.yaml +50 -0
  6. package/agents/doc_writer.yaml +54 -0
  7. package/agents/engineering_architect.yaml +51 -0
  8. package/agents/generalist.yaml +55 -0
  9. package/agents/migration_planner.yaml +51 -0
  10. package/agents/product_reviewer.yaml +48 -0
  11. package/agents/qa_operator.yaml +52 -0
  12. package/agents/release_engineer.yaml +50 -0
  13. package/agents/security_auditor.yaml +62 -0
  14. package/agents/test_writer.yaml +52 -0
  15. package/assets/first-light-lockup.png +0 -0
  16. package/assets/first-light-tagline.png +0 -0
  17. package/assets/house/README.md +26 -0
  18. package/assets/house/auraone-banner.png +0 -0
  19. package/assets/house/auraone-logo.png +0 -0
  20. package/assets/house/kiro-prism-banner.png +0 -0
  21. package/assets/house/kiro-prism-logo.png +0 -0
  22. package/assets/house/picasso-banner.png +0 -0
  23. package/assets/house/picasso-logo.png +0 -0
  24. package/assets/wordmark-app.png +0 -0
  25. package/assets/wordmark-tight.png +0 -0
  26. package/assets/wordmark.png +0 -0
  27. package/design/styles.css +1042 -0
  28. package/dist/build-info.json +37 -0
  29. package/dist/index.js +3062 -0
  30. package/goals/cli-hardening.yaml +40 -0
  31. package/goals/repo-maintenance.yaml +40 -0
  32. package/package.json +49 -4
  33. package/runtime/dsh/picasso-ecosystem.community.amendments.yml +24 -0
  34. package/runtime/dsh/picasso-ecosystem.community.json +185 -0
  35. package/runtime/dsh/picasso-ecosystem.community.patch.yml +40 -0
  36. package/runtime/dsh/picasso-ecosystem.cordis.patch.yml +143 -0
  37. package/runtime/dsh/picasso-isolation.patch.yml +25 -0
  38. package/runtime/dsh/picasso-providers.patch.yml +373 -0
  39. package/runtime/dsh/picasso-runtime.cordis.yml +738 -0
  40. package/runtime/dsh/picasso-sdk.patch.yml +204 -0
  41. package/runtime/engine-manifest.json +215 -0
  42. package/runtime/package.json +6 -0
  43. package/runtime/packages/picasso-cache-probe/cordis.patch.yml +5 -0
  44. package/runtime/packages/picasso-cache-probe/index.js +477 -0
  45. package/runtime/packages/picasso-cache-probe/package.json +38 -0
  46. package/runtime/packages/picasso-commands/cordis.patch.yml +4 -0
  47. package/runtime/packages/picasso-commands/fresh-review.js +573 -0
  48. package/runtime/packages/picasso-commands/index.js +497 -0
  49. package/runtime/packages/picasso-commands/package.json +28 -0
  50. package/runtime/packages/picasso-instructions/conflicts.js +115 -0
  51. package/runtime/packages/picasso-instructions/formats.js +145 -0
  52. package/runtime/packages/picasso-instructions/frontmatter.js +175 -0
  53. package/runtime/packages/picasso-instructions/glob.js +114 -0
  54. package/runtime/packages/picasso-instructions/globals.js +90 -0
  55. package/runtime/packages/picasso-instructions/imports.js +123 -0
  56. package/runtime/packages/picasso-instructions/index.js +326 -0
  57. package/runtime/packages/picasso-instructions/modes.js +64 -0
  58. package/runtime/packages/picasso-instructions/package.json +30 -0
  59. package/runtime/packages/picasso-instructions/parse.js +134 -0
  60. package/runtime/packages/picasso-instructions/report.js +161 -0
  61. package/runtime/packages/picasso-instructions/resolve.js +939 -0
  62. package/runtime/packages/picasso-instructions/scan.js +181 -0
  63. package/runtime/packages/picasso-instructions/settings.js +150 -0
  64. package/runtime/packages/picasso-instructions/skills.js +345 -0
  65. package/runtime/packages/picasso-lean-context/cordis.patch.yml +13 -0
  66. package/runtime/packages/picasso-lean-context/index.js +6280 -0
  67. package/runtime/packages/picasso-lean-context/package.json +26 -0
  68. package/runtime/packages/picasso-lean-context/read-image-recovery.js +306 -0
  69. package/runtime/packages/picasso-lean-context/timeline.js +418 -0
  70. package/runtime/packages/picasso-librarian/classify.js +146 -0
  71. package/runtime/packages/picasso-librarian/cordis.patch.yml +10 -0
  72. package/runtime/packages/picasso-librarian/index.js +878 -0
  73. package/runtime/packages/picasso-librarian/notes.js +159 -0
  74. package/runtime/packages/picasso-librarian/package.json +34 -0
  75. package/runtime/packages/picasso-librarian/state.js +478 -0
  76. package/runtime/packages/picasso-memory/index.js +1184 -0
  77. package/runtime/packages/picasso-memory/package.json +21 -0
  78. package/runtime/packages/picasso-model-router/connections.js +912 -0
  79. package/runtime/packages/picasso-model-router/cordis.patch.yml +17 -0
  80. package/runtime/packages/picasso-model-router/index.js +1083 -0
  81. package/runtime/packages/picasso-model-router/package.json +30 -0
  82. package/runtime/packages/picasso-options/cordis.patch.yml +4 -0
  83. package/runtime/packages/picasso-options/index.js +263 -0
  84. package/runtime/packages/picasso-options/package.json +28 -0
  85. package/runtime/packages/picasso-progress-reports/cordis.patch.yml +10 -0
  86. package/runtime/packages/picasso-progress-reports/index.js +267 -0
  87. package/runtime/packages/picasso-progress-reports/package.json +30 -0
  88. package/runtime/packages/picasso-progress-reports/report.js +235 -0
  89. package/runtime/packages/picasso-sdk-server/aside.js +142 -0
  90. package/runtime/packages/picasso-sdk-server/connections.js +38 -0
  91. package/runtime/packages/picasso-sdk-server/context-timeline.js +27 -0
  92. package/runtime/packages/picasso-sdk-server/egress-gate.js +520 -0
  93. package/runtime/packages/picasso-sdk-server/failure-policy.js +246 -0
  94. package/runtime/packages/picasso-sdk-server/file-input.js +169 -0
  95. package/runtime/packages/picasso-sdk-server/goal.js +131 -0
  96. package/runtime/packages/picasso-sdk-server/ignore-file.js +458 -0
  97. package/runtime/packages/picasso-sdk-server/ignore-plugin.js +12 -0
  98. package/runtime/packages/picasso-sdk-server/ignore-sandbox.js +122 -0
  99. package/runtime/packages/picasso-sdk-server/ignore-snapshot.js +131 -0
  100. package/runtime/packages/picasso-sdk-server/image-input.js +44 -0
  101. package/runtime/packages/picasso-sdk-server/index.js +891 -0
  102. package/runtime/packages/picasso-sdk-server/instructions.js +34 -0
  103. package/runtime/packages/picasso-sdk-server/jobs.js +113 -0
  104. package/runtime/packages/picasso-sdk-server/mcp-gate.js +51 -0
  105. package/runtime/packages/picasso-sdk-server/model-selection.js +162 -0
  106. package/runtime/packages/picasso-sdk-server/package.json +50 -0
  107. package/runtime/packages/picasso-sdk-server/picasso-records.js +50 -0
  108. package/runtime/packages/picasso-sdk-server/provider-reload.js +84 -0
  109. package/runtime/packages/picasso-sdk-server/queue.js +322 -0
  110. package/runtime/packages/picasso-sdk-server/requester.js +43 -0
  111. package/runtime/packages/picasso-sdk-server/rewind.js +108 -0
  112. package/runtime/packages/picasso-sdk-server/schedule.js +187 -0
  113. package/runtime/packages/picasso-sdk-server/session-grants.js +35 -0
  114. package/runtime/packages/picasso-sdk-server/session-state.js +118 -0
  115. package/runtime/packages/picasso-sdk-server/shell-paths.js +869 -0
  116. package/runtime/packages/picasso-sdk-server/stream-deltas.js +211 -0
  117. package/runtime/packages/picasso-sdk-server/team-tasks.js +451 -0
  118. package/runtime/packages/picasso-sdk-server/tool-output.js +128 -0
  119. package/runtime/packages/picasso-sdk-server/tools-list.js +51 -0
  120. package/runtime/packages/picasso-sdk-server/wave2-hooks.js +612 -0
  121. package/runtime/packages/picasso-sdk-server/workspace-archive.js +170 -0
  122. package/runtime/packages/picasso-sdk-server/workspace-restore.js +180 -0
  123. package/runtime/packages/picasso-web-search/backends.js +412 -0
  124. package/runtime/packages/picasso-web-search/config.js +121 -0
  125. package/runtime/packages/picasso-web-search/cordis.patch.yml +7 -0
  126. package/runtime/packages/picasso-web-search/failure.js +116 -0
  127. package/runtime/packages/picasso-web-search/format.js +42 -0
  128. package/runtime/packages/picasso-web-search/index.js +71 -0
  129. package/runtime/packages/picasso-web-search/package.json +38 -0
  130. package/runtime/packages/picasso-web-search/router.js +156 -0
  131. package/runtime/packages/picasso-x-reader/circle.js +324 -0
  132. package/runtime/packages/picasso-x-reader/command.js +169 -0
  133. package/runtime/packages/picasso-x-reader/cordis.patch.yml +8 -0
  134. package/runtime/packages/picasso-x-reader/index.js +170 -0
  135. package/runtime/packages/picasso-x-reader/package.json +39 -0
  136. package/runtime/packages/picasso-x-reader/read.js +370 -0
  137. package/runtime/packages/picasso-x-reader/rewrite.js +38 -0
  138. package/runtime/packages/picasso-x-reader/settings.js +131 -0
  139. package/runtime/packages/picasso-x-reader/urls.js +154 -0
  140. package/runtime/packages/picasso-x-reader/xmd.js +512 -0
  141. package/runtime/plugins/picasso-auth-bridge/index.js +380 -0
  142. package/runtime/plugins/picasso-auth-bridge/package.json +28 -0
  143. package/runtime/plugins/picasso-auto-approve/index.js +1003 -0
  144. package/runtime/plugins/picasso-auto-approve/package.json +28 -0
  145. package/runtime/plugins/picasso-browser/index.js +424 -0
  146. package/runtime/plugins/picasso-browser/package.json +28 -0
  147. package/runtime/plugins/picasso-checkpoints/evidence.js +210 -0
  148. package/runtime/plugins/picasso-checkpoints/index.js +885 -0
  149. package/runtime/plugins/picasso-checkpoints/package.json +29 -0
  150. package/runtime/plugins/picasso-commands/fresh-review.js +573 -0
  151. package/runtime/plugins/picasso-commands/index.js +497 -0
  152. package/runtime/plugins/picasso-commands/package.json +28 -0
  153. package/runtime/plugins/picasso-instructions/conflicts.js +115 -0
  154. package/runtime/plugins/picasso-instructions/formats.js +145 -0
  155. package/runtime/plugins/picasso-instructions/frontmatter.js +175 -0
  156. package/runtime/plugins/picasso-instructions/glob.js +114 -0
  157. package/runtime/plugins/picasso-instructions/globals.js +90 -0
  158. package/runtime/plugins/picasso-instructions/imports.js +123 -0
  159. package/runtime/plugins/picasso-instructions/index.js +326 -0
  160. package/runtime/plugins/picasso-instructions/modes.js +64 -0
  161. package/runtime/plugins/picasso-instructions/package.json +30 -0
  162. package/runtime/plugins/picasso-instructions/parse.js +134 -0
  163. package/runtime/plugins/picasso-instructions/report.js +161 -0
  164. package/runtime/plugins/picasso-instructions/resolve.js +939 -0
  165. package/runtime/plugins/picasso-instructions/scan.js +181 -0
  166. package/runtime/plugins/picasso-instructions/settings.js +150 -0
  167. package/runtime/plugins/picasso-instructions/skills.js +345 -0
  168. package/runtime/plugins/picasso-lean-context/index.js +6280 -0
  169. package/runtime/plugins/picasso-lean-context/package.json +26 -0
  170. package/runtime/plugins/picasso-lean-context/read-image-recovery.js +306 -0
  171. package/runtime/plugins/picasso-lean-context/timeline.js +418 -0
  172. package/runtime/plugins/picasso-librarian/classify.js +146 -0
  173. package/runtime/plugins/picasso-librarian/index.js +878 -0
  174. package/runtime/plugins/picasso-librarian/notes.js +159 -0
  175. package/runtime/plugins/picasso-librarian/package.json +34 -0
  176. package/runtime/plugins/picasso-librarian/state.js +478 -0
  177. package/runtime/plugins/picasso-lifecycle-hooks/index.js +186 -0
  178. package/runtime/plugins/picasso-lifecycle-hooks/package.json +25 -0
  179. package/runtime/plugins/picasso-mail/inbox.js +207 -0
  180. package/runtime/plugins/picasso-mail/index.js +293 -0
  181. package/runtime/plugins/picasso-mail/package.json +22 -0
  182. package/runtime/plugins/picasso-memory/index.js +1184 -0
  183. package/runtime/plugins/picasso-memory/package.json +21 -0
  184. package/runtime/plugins/picasso-model-router/connections.js +912 -0
  185. package/runtime/plugins/picasso-model-router/index.js +1083 -0
  186. package/runtime/plugins/picasso-model-router/package.json +30 -0
  187. package/runtime/plugins/picasso-options/index.js +263 -0
  188. package/runtime/plugins/picasso-options/package.json +28 -0
  189. package/runtime/plugins/picasso-progress-reports/index.js +267 -0
  190. package/runtime/plugins/picasso-progress-reports/package.json +30 -0
  191. package/runtime/plugins/picasso-progress-reports/report.js +235 -0
  192. package/runtime/plugins/picasso-provider-models/index.js +436 -0
  193. package/runtime/plugins/picasso-provider-models/package.json +28 -0
  194. package/runtime/plugins/picasso-repo-index/index.js +1850 -0
  195. package/runtime/plugins/picasso-repo-index/package.json +28 -0
  196. package/runtime/plugins/picasso-schedule-pause/index.js +344 -0
  197. package/runtime/plugins/picasso-schedule-pause/package.json +28 -0
  198. package/runtime/plugins/picasso-session-lifecycle/index.js +796 -0
  199. package/runtime/plugins/picasso-session-lifecycle/package.json +28 -0
  200. package/runtime/plugins/picasso-trackers/index.js +895 -0
  201. package/runtime/plugins/picasso-trackers/package.json +28 -0
  202. package/runtime/plugins/picasso-web-search/backends.js +412 -0
  203. package/runtime/plugins/picasso-web-search/config.js +121 -0
  204. package/runtime/plugins/picasso-web-search/failure.js +116 -0
  205. package/runtime/plugins/picasso-web-search/format.js +42 -0
  206. package/runtime/plugins/picasso-web-search/index.js +71 -0
  207. package/runtime/plugins/picasso-web-search/package.json +38 -0
  208. package/runtime/plugins/picasso-web-search/router.js +156 -0
  209. package/runtime/plugins/picasso-x-reader/circle.js +324 -0
  210. package/runtime/plugins/picasso-x-reader/command.js +169 -0
  211. package/runtime/plugins/picasso-x-reader/index.js +170 -0
  212. package/runtime/plugins/picasso-x-reader/package.json +39 -0
  213. package/runtime/plugins/picasso-x-reader/read.js +370 -0
  214. package/runtime/plugins/picasso-x-reader/rewrite.js +38 -0
  215. package/runtime/plugins/picasso-x-reader/settings.js +131 -0
  216. package/runtime/plugins/picasso-x-reader/urls.js +154 -0
  217. package/runtime/plugins/picasso-x-reader/xmd.js +512 -0
  218. package/runtime/relay/attachment-text.mjs +737 -0
  219. package/runtime/relay/companion/companion.css +126 -0
  220. package/runtime/relay/companion/companion.js +648 -0
  221. package/runtime/relay/companion/icon.svg +5 -0
  222. package/runtime/relay/companion/index.html +25 -0
  223. package/runtime/relay/companion/manifest.json +13 -0
  224. package/runtime/relay/companion/sw.js +41 -0
  225. package/runtime/relay/main.mjs +38580 -0
  226. package/runtime/relay/model-listing.mjs +614 -0
  227. package/runtime/relay/versions-routes.mjs +1400 -0
  228. package/runtime/verify-plugins.mjs +205 -0
  229. package/runtime-lock/package-lock.json +10779 -0
  230. package/runtime-lock/package.json +7 -0
  231. package/scripts/install-runtime.mjs +400 -0
  232. package/README.md +0 -3
@@ -0,0 +1,205 @@
1
+ #!/usr/bin/env node
2
+ // AO-038.06 — Shared plugin-integrity verifier for the bundled PicassoEngine.
3
+ //
4
+ // bundle.mjs imports `collectPluginEntries` to bind every copied plugin file's sha256 into
5
+ // engine-manifest.json at package time. The SAME file is then copied into the engine bundle as
6
+ // `verify-plugins.mjs`, so the launcher (or `scripts/package-release.sh`, or a clean-host smoke
7
+ // test) can re-run it against the exact shipped bytes:
8
+ //
9
+ // PicassoEngine/bin/node PicassoEngine/verify-plugins.mjs
10
+ // (or from a checkout: node apps/desktop-helper/scripts/engine-verify.mjs <engineDir>)
11
+ //
12
+ // Zero external dependencies (Node builtins only) so it runs verbatim inside the bundle.
13
+ //
14
+ // Refusal classes (any one fails verification, exit 1):
15
+ // missing — a plugin dir or a hashed file is absent from the bundle
16
+ // tampered — a shipped file's sha256 differs from the manifest digest
17
+ // incompatible — the shipped package.json name/version differs from the manifest record
18
+ // manifest — engine-manifest.json is missing, unreadable, or has no plugin digests
19
+ //
20
+ // Exit: 0 = all plugin entries verified; 1 = refusal list non-empty; 2 = usage error.
21
+
22
+ import { createHash } from "node:crypto";
23
+ import { existsSync, readFileSync, readdirSync, realpathSync } from "node:fs";
24
+ import { dirname, join, resolve } from "node:path";
25
+ import { fileURLToPath } from "node:url";
26
+
27
+ export const PLUGIN_MANIFEST_SCHEMA_VERSION = 1;
28
+ // The plugin files bundle.mjs copies and binds into the manifest.
29
+ export const PLUGIN_HASHED_FILES = ["index.js", "package.json"];
30
+
31
+ /**
32
+ * The files a plugin dir ships and the manifest hashes: `index.js`, `package.json` and every other top-level
33
+ * `.js`/`.mjs` module beside them (a plugin may import siblings, e.g. picasso-checkpoints -> ./evidence.js).
34
+ */
35
+ export function pluginModuleFiles(dirPath) {
36
+ const extra = existsSync(dirPath)
37
+ ? readdirSync(dirPath, { withFileTypes: true })
38
+ .filter((entry) => entry.isFile() && /\.(?:m?js)$/u.test(entry.name) && !PLUGIN_HASHED_FILES.includes(entry.name))
39
+ .map((entry) => entry.name)
40
+ .sort()
41
+ : [];
42
+ return [...PLUGIN_HASHED_FILES, ...extra];
43
+ }
44
+
45
+ function sha256File(path) {
46
+ return createHash("sha256").update(readFileSync(path)).digest("hex");
47
+ }
48
+
49
+ /**
50
+ * Hash every hashed file of every plugin dir under `pluginsDir` (i.e. <pluginsDir>/<dir>/<file>).
51
+ * `dirs` is the expected dir list; when undefined, dirs are discovered on disk (used only for
52
+ * diagnostics — the manifest is authoritative at verify time).
53
+ */
54
+ export function collectPluginEntries(pluginsDir, dirs) {
55
+ const names = dirs ?? (existsSync(pluginsDir) ? readdirSync(pluginsDir).sort() : []);
56
+ const entries = {};
57
+ for (const dir of names) {
58
+ const dirPath = join(pluginsDir, dir);
59
+ const files = {};
60
+ let name = null;
61
+ let version = null;
62
+ for (const file of pluginModuleFiles(dirPath)) {
63
+ const filePath = join(dirPath, file);
64
+ files[file] = existsSync(filePath) ? sha256File(filePath) : null;
65
+ }
66
+ const manifestPath = join(dirPath, "package.json");
67
+ if (existsSync(manifestPath)) {
68
+ try {
69
+ const parsed = JSON.parse(readFileSync(manifestPath, "utf8"));
70
+ name = parsed.name ?? null;
71
+ version = parsed.version ?? null;
72
+ } catch {
73
+ /* unreadable manifest is caught as a digest mismatch at verify time */
74
+ }
75
+ }
76
+ entries[dir] = { name, version, files };
77
+ }
78
+ return { schemaVersion: PLUGIN_MANIFEST_SCHEMA_VERSION, dirs: entries };
79
+ }
80
+
81
+ /**
82
+ * Verify an engine dir (<engineDir>/engine-manifest.json + <engineDir>/plugins/<dir>/*).
83
+ * Returns { ok, failures, plugins } — `failures` is a list of {dir, file?, reason, detail}.
84
+ */
85
+ export function verifyEngineDir(engineDir) {
86
+ const root = resolve(engineDir);
87
+ const failures = [];
88
+ const manifestPath = join(root, "engine-manifest.json");
89
+ let manifest;
90
+ if (!existsSync(manifestPath)) {
91
+ return {
92
+ ok: false,
93
+ failures: [{ dir: null, reason: "manifest", detail: `engine-manifest.json missing at ${manifestPath}` }],
94
+ plugins: [],
95
+ };
96
+ }
97
+ try {
98
+ manifest = JSON.parse(readFileSync(manifestPath, "utf8"));
99
+ } catch (error) {
100
+ return {
101
+ ok: false,
102
+ failures: [{ dir: null, reason: "manifest", detail: `engine-manifest.json unreadable: ${error.message}` }],
103
+ plugins: [],
104
+ };
105
+ }
106
+ const plugins = manifest.plugins;
107
+ if (plugins?.schemaVersion !== PLUGIN_MANIFEST_SCHEMA_VERSION || plugins?.dirs === undefined) {
108
+ return {
109
+ ok: false,
110
+ failures: [
111
+ {
112
+ dir: null,
113
+ reason: "manifest",
114
+ detail: `manifest.plugins missing or schemaVersion !== ${PLUGIN_MANIFEST_SCHEMA_VERSION}; ` +
115
+ `rebuild the engine with apps/desktop-helper/scripts/bundle.mjs`,
116
+ },
117
+ ],
118
+ plugins: [],
119
+ };
120
+ }
121
+ const pluginsDir = join(root, "plugins");
122
+ const expected = plugins.dirs;
123
+ for (const [dir, record] of Object.entries(expected)) {
124
+ const dirPath = join(pluginsDir, dir);
125
+ if (!existsSync(dirPath)) {
126
+ failures.push({ dir, reason: "missing", detail: `plugin dir ${dir} absent from ${pluginsDir}` });
127
+ continue;
128
+ }
129
+ const recorded = Object.keys(record.files ?? {});
130
+ for (const file of [...new Set([...PLUGIN_HASHED_FILES, ...recorded])]) {
131
+ const filePath = join(dirPath, file);
132
+ const expectedDigest = record.files?.[file] ?? null;
133
+ if (expectedDigest === null) {
134
+ failures.push({ dir, file, reason: "manifest", detail: `no recorded digest for ${dir}/${file}` });
135
+ continue;
136
+ }
137
+ if (!existsSync(filePath)) {
138
+ failures.push({ dir, file, reason: "missing", detail: `${dir}/${file} absent from bundle` });
139
+ continue;
140
+ }
141
+ const actual = sha256File(filePath);
142
+ if (actual !== expectedDigest) {
143
+ failures.push({
144
+ dir,
145
+ file,
146
+ reason: "tampered",
147
+ detail: `${dir}/${file} sha256 ${actual.slice(0, 16)}… != manifest ${expectedDigest.slice(0, 16)}…`,
148
+ });
149
+ }
150
+ }
151
+ if (existsSync(join(dirPath, "package.json"))) {
152
+ try {
153
+ const shipped = JSON.parse(readFileSync(join(dirPath, "package.json"), "utf8"));
154
+ if (record.name !== null && shipped.name !== record.name) {
155
+ failures.push({
156
+ dir,
157
+ reason: "incompatible",
158
+ detail: `package name ${shipped.name} != manifest ${record.name}`,
159
+ });
160
+ }
161
+ if (record.version !== null && shipped.version !== record.version) {
162
+ failures.push({
163
+ dir,
164
+ reason: "incompatible",
165
+ detail: `package version ${shipped.version} != manifest ${record.version}`,
166
+ });
167
+ }
168
+ } catch {
169
+ failures.push({ dir, reason: "tampered", detail: `${dir}/package.json is not valid JSON` });
170
+ }
171
+ }
172
+ }
173
+ // A plugin dropped in outside the manifest is refused too — no untrusted lookup path.
174
+ if (existsSync(pluginsDir)) {
175
+ for (const stray of readdirSync(pluginsDir)) {
176
+ if (!(stray in expected)) {
177
+ failures.push({ dir: stray, reason: "tampered", detail: `unmanifested plugin dir ${stray} present in bundle` });
178
+ }
179
+ }
180
+ }
181
+ return { ok: failures.length === 0, failures, plugins: Object.keys(expected) };
182
+ }
183
+
184
+ // Compare real paths: Node resolves symlinks in import.meta.url but not in argv[1] (e.g. /tmp -> /private/tmp),
185
+ // and a mismatch here would make the verifier exit 0 without checking anything.
186
+ const isMain =
187
+ process.argv[1] !== undefined && realpathSync(fileURLToPath(import.meta.url)) === realpathSync(resolve(process.argv[1]));
188
+ if (isMain) {
189
+ // No arg: verify the engine dir this file lives in (the bundle ships it as <engine>/verify-plugins.mjs).
190
+ const engineDir = process.argv[2] ?? dirname(fileURLToPath(import.meta.url));
191
+ if (process.argv.includes("--help") || process.argv.includes("-h")) {
192
+ console.error("Usage: node verify-plugins.mjs [<PicassoEngine dir>] (default: script's own dir)");
193
+ process.exit(2);
194
+ }
195
+ const result = verifyEngineDir(engineDir);
196
+ if (result.ok) {
197
+ console.log(`plugins verified: ${result.plugins.length} plugin dirs match engine-manifest.json`);
198
+ process.exit(0);
199
+ }
200
+ console.error("engine plugin verification FAILED — refusing to treat the bundle as ready:");
201
+ for (const failure of result.failures) {
202
+ console.error(` ${failure.reason}: ${failure.detail}`);
203
+ }
204
+ process.exit(1);
205
+ }