@codyswann/lisa 7.1.5 → 8.0.0

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 (661) hide show
  1. package/all/copy-overwrite/scripts/check-npm-publish-landed.mjs +0 -2
  2. package/all/copy-overwrite/scripts/lib/push-timing.mjs +3 -6
  3. package/all/copy-overwrite/scripts/lisa-enforcement-fallback.sh +31 -32
  4. package/all/copy-overwrite/scripts/lisa-hooks/block-managed-file-edits.sh +201 -20
  5. package/all/copy-overwrite/scripts/npm-updater-helper-graph.json +3 -2
  6. package/dist/cli/admit-cmd.d.ts.map +1 -1
  7. package/dist/cli/admit-cmd.js +16 -10
  8. package/dist/cli/admit-cmd.js.map +1 -1
  9. package/dist/cli/apply.d.ts.map +1 -1
  10. package/dist/cli/apply.js +2 -2
  11. package/dist/cli/apply.js.map +1 -1
  12. package/dist/cli/check-cmd.d.ts.map +1 -1
  13. package/dist/cli/check-cmd.js +8 -4
  14. package/dist/cli/check-cmd.js.map +1 -1
  15. package/dist/cli/doctor-coderabbit.js +2 -2
  16. package/dist/cli/doctor-coderabbit.js.map +1 -1
  17. package/dist/cli/doctor-readiness-supply-chain-python.d.ts +5 -1
  18. package/dist/cli/doctor-readiness-supply-chain-python.d.ts.map +1 -1
  19. package/dist/cli/doctor-readiness-supply-chain-python.js +44 -10
  20. package/dist/cli/doctor-readiness-supply-chain-python.js.map +1 -1
  21. package/dist/cli/doctor-readiness.js +2 -2
  22. package/dist/cli/doctor-readiness.js.map +1 -1
  23. package/dist/cli/doctor-worker-journey.js +2 -2
  24. package/dist/cli/doctor-worker-journey.js.map +1 -1
  25. package/dist/cli/doctor.d.ts.map +1 -1
  26. package/dist/cli/doctor.js +7 -4
  27. package/dist/cli/doctor.js.map +1 -1
  28. package/dist/cli/file-upstream-cmd.d.ts.map +1 -1
  29. package/dist/cli/file-upstream-cmd.js +20 -25
  30. package/dist/cli/file-upstream-cmd.js.map +1 -1
  31. package/dist/cli/gh-cli.d.ts +2 -2
  32. package/dist/cli/gh-cli.d.ts.map +1 -1
  33. package/dist/cli/gh-cli.js +13 -6
  34. package/dist/cli/gh-cli.js.map +1 -1
  35. package/dist/cli/health-cmd.d.ts.map +1 -1
  36. package/dist/cli/health-cmd.js +7 -19
  37. package/dist/cli/health-cmd.js.map +1 -1
  38. package/dist/cli/lisa-test-run-jest-merge.js +5 -5
  39. package/dist/cli/lisa-test-run-jest-merge.js.map +1 -1
  40. package/dist/cli/lisa-test-run.js +8 -4
  41. package/dist/cli/lisa-test-run.js.map +1 -1
  42. package/dist/cli/pr-landing.js +2 -2
  43. package/dist/cli/pr-landing.js.map +1 -1
  44. package/dist/cli/update-check.d.ts.map +1 -1
  45. package/dist/cli/update-check.js +7 -4
  46. package/dist/cli/update-check.js.map +1 -1
  47. package/dist/cli/update-cmd.d.ts.map +1 -1
  48. package/dist/cli/update-cmd.js +7 -4
  49. package/dist/cli/update-cmd.js.map +1 -1
  50. package/dist/cli/worktree-ownership.d.ts.map +1 -1
  51. package/dist/cli/worktree-ownership.js +3 -3
  52. package/dist/cli/worktree-ownership.js.map +1 -1
  53. package/dist/codex/hooks-catalog.d.ts +151 -0
  54. package/dist/codex/hooks-catalog.d.ts.map +1 -0
  55. package/dist/codex/hooks-catalog.js +315 -0
  56. package/dist/codex/hooks-catalog.js.map +1 -0
  57. package/dist/codex/hooks-compatibility.d.ts +14 -0
  58. package/dist/codex/hooks-compatibility.d.ts.map +1 -0
  59. package/dist/codex/hooks-compatibility.js +196 -0
  60. package/dist/codex/hooks-compatibility.js.map +1 -0
  61. package/dist/codex/hooks-installer.d.ts +2 -49
  62. package/dist/codex/hooks-installer.d.ts.map +1 -1
  63. package/dist/codex/hooks-installer.js +5 -546
  64. package/dist/codex/hooks-installer.js.map +1 -1
  65. package/dist/codex/hooks-source-links.d.ts +11 -0
  66. package/dist/codex/hooks-source-links.d.ts.map +1 -0
  67. package/dist/codex/hooks-source-links.js +74 -0
  68. package/dist/codex/hooks-source-links.js.map +1 -0
  69. package/dist/codex/scripts/block-migration-edits.sh +2 -2
  70. package/dist/codex/scripts/block-suppress-directives.sh +3 -3
  71. package/dist/codex/scripts/format-on-edit.sh +2 -2
  72. package/dist/codex/scripts/lint-on-edit.sh +2 -2
  73. package/dist/codex/scripts/lisa-edit-gate.sh +19 -15
  74. package/dist/codex/scripts/rubocop-on-edit.sh +2 -2
  75. package/dist/codex/scripts/sg-scan-on-edit.sh +2 -2
  76. package/dist/configs/coverage-scope.d.ts +0 -23
  77. package/dist/configs/coverage-scope.d.ts.map +1 -1
  78. package/dist/configs/coverage-scope.js +2 -3
  79. package/dist/configs/coverage-scope.js.map +1 -1
  80. package/dist/configs/eslint/base.d.ts +2 -113
  81. package/dist/configs/eslint/base.d.ts.map +1 -1
  82. package/dist/configs/eslint/base.js +2 -165
  83. package/dist/configs/eslint/base.js.map +1 -1
  84. package/dist/configs/eslint/cdk.d.ts.map +1 -1
  85. package/dist/configs/eslint/cdk.js +82 -66
  86. package/dist/configs/eslint/cdk.js.map +1 -1
  87. package/dist/configs/eslint/expo-overrides.d.ts +103 -0
  88. package/dist/configs/eslint/expo-overrides.d.ts.map +1 -0
  89. package/dist/configs/eslint/expo-overrides.js +187 -0
  90. package/dist/configs/eslint/expo-overrides.js.map +1 -0
  91. package/dist/configs/eslint/expo.d.ts +2 -7
  92. package/dist/configs/eslint/expo.d.ts.map +1 -1
  93. package/dist/configs/eslint/expo.js +186 -258
  94. package/dist/configs/eslint/expo.js.map +1 -1
  95. package/dist/configs/eslint/nestjs.d.ts.map +1 -1
  96. package/dist/configs/eslint/nestjs.js +86 -70
  97. package/dist/configs/eslint/nestjs.js.map +1 -1
  98. package/dist/configs/eslint/process-environment-bans.d.ts +41 -0
  99. package/dist/configs/eslint/process-environment-bans.d.ts.map +1 -0
  100. package/dist/configs/eslint/process-environment-bans.js +50 -0
  101. package/dist/configs/eslint/process-environment-bans.js.map +1 -0
  102. package/dist/configs/eslint/shared-rules.d.ts +130 -0
  103. package/dist/configs/eslint/shared-rules.d.ts.map +1 -0
  104. package/dist/configs/eslint/shared-rules.js +233 -0
  105. package/dist/configs/eslint/shared-rules.js.map +1 -0
  106. package/dist/configs/eslint/typescript.d.ts.map +1 -1
  107. package/dist/configs/eslint/typescript.js +2 -4
  108. package/dist/configs/eslint/typescript.js.map +1 -1
  109. package/dist/configs/vitest/base.d.ts +2 -2
  110. package/dist/configs/vitest/base.d.ts.map +1 -1
  111. package/dist/configs/vitest/base.js +5 -5
  112. package/dist/configs/vitest/base.js.map +1 -1
  113. package/dist/configs/vitest/coverage-reports-directory.d.ts.map +1 -1
  114. package/dist/configs/vitest/coverage-reports-directory.js +3 -2
  115. package/dist/configs/vitest/coverage-reports-directory.js.map +1 -1
  116. package/dist/configs/vitest/refusal-announcement.js +2 -2
  117. package/dist/configs/vitest/refusal-announcement.js.map +1 -1
  118. package/dist/core/admission-lock.js +2 -3
  119. package/dist/core/admission-lock.js.map +1 -1
  120. package/dist/core/admission-state.d.ts.map +1 -1
  121. package/dist/core/admission-state.js +11 -5
  122. package/dist/core/admission-state.js.map +1 -1
  123. package/dist/core/admission.d.ts.map +1 -1
  124. package/dist/core/admission.js +2 -2
  125. package/dist/core/admission.js.map +1 -1
  126. package/dist/core/bootstrap-environment.d.ts.map +1 -1
  127. package/dist/core/bootstrap-environment.js +8 -5
  128. package/dist/core/bootstrap-environment.js.map +1 -1
  129. package/dist/core/downstream-names.d.ts.map +1 -1
  130. package/dist/core/downstream-names.js +48 -47
  131. package/dist/core/downstream-names.js.map +1 -1
  132. package/dist/core/effectiveness-store.d.ts.map +1 -1
  133. package/dist/core/effectiveness-store.js +3 -5
  134. package/dist/core/effectiveness-store.js.map +1 -1
  135. package/dist/core/gate-declaration-drift.d.ts.map +1 -1
  136. package/dist/core/gate-declaration-drift.js +46 -27
  137. package/dist/core/gate-declaration-drift.js.map +1 -1
  138. package/dist/core/kane-cli-process.d.ts.map +1 -1
  139. package/dist/core/kane-cli-process.js +46 -33
  140. package/dist/core/kane-cli-process.js.map +1 -1
  141. package/dist/core/kane-cli.d.ts.map +1 -1
  142. package/dist/core/kane-cli.js +3 -4
  143. package/dist/core/kane-cli.js.map +1 -1
  144. package/dist/core/lisa-agent-emit-extra.d.ts +75 -0
  145. package/dist/core/lisa-agent-emit-extra.d.ts.map +1 -0
  146. package/dist/core/lisa-agent-emit-extra.js +231 -0
  147. package/dist/core/lisa-agent-emit-extra.js.map +1 -0
  148. package/dist/core/lisa-agent-emit.d.ts +79 -0
  149. package/dist/core/lisa-agent-emit.d.ts.map +1 -0
  150. package/dist/core/lisa-agent-emit.js +224 -0
  151. package/dist/core/lisa-agent-emit.js.map +1 -0
  152. package/dist/core/lisa-deletions.d.ts +116 -0
  153. package/dist/core/lisa-deletions.d.ts.map +1 -0
  154. package/dist/core/lisa-deletions.js +316 -0
  155. package/dist/core/lisa-deletions.js.map +1 -0
  156. package/dist/core/lisa-file-results.d.ts +58 -0
  157. package/dist/core/lisa-file-results.d.ts.map +1 -0
  158. package/dist/core/lisa-file-results.js +173 -0
  159. package/dist/core/lisa-file-results.js.map +1 -0
  160. package/dist/core/lisa-maintenance.d.ts +139 -0
  161. package/dist/core/lisa-maintenance.d.ts.map +1 -0
  162. package/dist/core/lisa-maintenance.js +324 -0
  163. package/dist/core/lisa-maintenance.js.map +1 -0
  164. package/dist/core/lisa-owned-hash-ledger.d.ts +7 -5
  165. package/dist/core/lisa-owned-hash-ledger.d.ts.map +1 -1
  166. package/dist/core/lisa-owned-hash-ledger.js +44 -6036
  167. package/dist/core/lisa-owned-hash-ledger.js.map +1 -1
  168. package/dist/core/lisa-owned-hash-ledger.json +6021 -0
  169. package/dist/core/lisa-plugin-sync.d.ts +96 -0
  170. package/dist/core/lisa-plugin-sync.d.ts.map +1 -0
  171. package/dist/core/lisa-plugin-sync.js +216 -0
  172. package/dist/core/lisa-plugin-sync.js.map +1 -0
  173. package/dist/core/lisa-plugins.d.ts +42 -0
  174. package/dist/core/lisa-plugins.d.ts.map +1 -0
  175. package/dist/core/lisa-plugins.js +155 -0
  176. package/dist/core/lisa-plugins.js.map +1 -0
  177. package/dist/core/lisa-state.d.ts +202 -0
  178. package/dist/core/lisa-state.d.ts.map +1 -0
  179. package/dist/core/lisa-state.js +205 -0
  180. package/dist/core/lisa-state.js.map +1 -0
  181. package/dist/core/lisa-summary-stats.d.ts +74 -0
  182. package/dist/core/lisa-summary-stats.d.ts.map +1 -0
  183. package/dist/core/lisa-summary-stats.js +189 -0
  184. package/dist/core/lisa-summary-stats.js.map +1 -0
  185. package/dist/core/lisa-summary.d.ts +34 -0
  186. package/dist/core/lisa-summary.d.ts.map +1 -0
  187. package/dist/core/lisa-summary.js +144 -0
  188. package/dist/core/lisa-summary.js.map +1 -0
  189. package/dist/core/lisa-templates.d.ts +98 -0
  190. package/dist/core/lisa-templates.d.ts.map +1 -0
  191. package/dist/core/lisa-templates.js +251 -0
  192. package/dist/core/lisa-templates.js.map +1 -0
  193. package/dist/core/lisa.d.ts +14 -903
  194. package/dist/core/lisa.d.ts.map +1 -1
  195. package/dist/core/lisa.js +30 -2275
  196. package/dist/core/lisa.js.map +1 -1
  197. package/dist/core/nightly-e2e-guard-behavior-certificate.js +2 -2
  198. package/dist/core/plugin-command.d.ts.map +1 -1
  199. package/dist/core/plugin-command.js +117 -61
  200. package/dist/core/plugin-command.js.map +1 -1
  201. package/dist/core/template-ownership.d.ts.map +1 -1
  202. package/dist/core/template-ownership.js +0 -1
  203. package/dist/core/template-ownership.js.map +1 -1
  204. package/dist/core/upstream-attribution-body.d.ts +4 -11
  205. package/dist/core/upstream-attribution-body.d.ts.map +1 -1
  206. package/dist/core/upstream-attribution-body.js +61 -373
  207. package/dist/core/upstream-attribution-body.js.map +1 -1
  208. package/dist/core/upstream-attribution-fields.d.ts +40 -0
  209. package/dist/core/upstream-attribution-fields.d.ts.map +1 -0
  210. package/dist/core/upstream-attribution-fields.js +167 -0
  211. package/dist/core/upstream-attribution-fields.js.map +1 -0
  212. package/dist/core/upstream-attribution-files.d.ts +15 -0
  213. package/dist/core/upstream-attribution-files.d.ts.map +1 -0
  214. package/dist/core/upstream-attribution-files.js +156 -0
  215. package/dist/core/upstream-attribution-files.js.map +1 -0
  216. package/dist/core/upstream-attribution-guards.d.ts +80 -0
  217. package/dist/core/upstream-attribution-guards.d.ts.map +1 -0
  218. package/dist/core/upstream-attribution-guards.js +284 -0
  219. package/dist/core/upstream-attribution-guards.js.map +1 -0
  220. package/dist/core/upstream-evidence-manifest.d.ts +1 -1
  221. package/dist/core/upstream-evidence-manifest.d.ts.map +1 -1
  222. package/dist/core/upstream-evidence-manifest.js +67 -30435
  223. package/dist/core/upstream-evidence-manifest.js.map +1 -1
  224. package/dist/core/upstream-evidence-manifest.json +30518 -0
  225. package/dist/health/agentic-contract.d.ts +94 -0
  226. package/dist/health/agentic-contract.d.ts.map +1 -0
  227. package/dist/health/agentic-contract.js +2 -0
  228. package/dist/health/agentic-contract.js.map +1 -0
  229. package/dist/health/agentic-evidence.d.ts +16 -0
  230. package/dist/health/agentic-evidence.d.ts.map +1 -0
  231. package/dist/health/agentic-evidence.js +213 -0
  232. package/dist/health/agentic-evidence.js.map +1 -0
  233. package/dist/health/agentic.d.ts +11 -74
  234. package/dist/health/agentic.d.ts.map +1 -1
  235. package/dist/health/agentic.js +42 -216
  236. package/dist/health/agentic.js.map +1 -1
  237. package/dist/health/deadline.d.ts +4 -1
  238. package/dist/health/deadline.d.ts.map +1 -1
  239. package/dist/health/deadline.js +4 -3
  240. package/dist/health/deadline.js.map +1 -1
  241. package/dist/health/deterministic-inputs.d.ts.map +1 -1
  242. package/dist/health/deterministic-inputs.js +3 -11
  243. package/dist/health/deterministic-inputs.js.map +1 -1
  244. package/dist/health/deterministic-probes.d.ts +52 -0
  245. package/dist/health/deterministic-probes.d.ts.map +1 -0
  246. package/dist/health/deterministic-probes.js +142 -0
  247. package/dist/health/deterministic-probes.js.map +1 -0
  248. package/dist/health/deterministic.d.ts +2 -25
  249. package/dist/health/deterministic.d.ts.map +1 -1
  250. package/dist/health/deterministic.js +14 -106
  251. package/dist/health/deterministic.js.map +1 -1
  252. package/dist/health/finding-utils.d.ts +4 -3
  253. package/dist/health/finding-utils.d.ts.map +1 -1
  254. package/dist/health/finding-utils.js +4 -4
  255. package/dist/health/finding-utils.js.map +1 -1
  256. package/dist/health/governance-probes.d.ts +29 -24
  257. package/dist/health/governance-probes.d.ts.map +1 -1
  258. package/dist/health/governance-probes.js +29 -25
  259. package/dist/health/governance-probes.js.map +1 -1
  260. package/dist/health/hook-inspection.d.ts +4 -3
  261. package/dist/health/hook-inspection.d.ts.map +1 -1
  262. package/dist/health/hook-inspection.js +17 -11
  263. package/dist/health/hook-inspection.js.map +1 -1
  264. package/dist/health/plugin-inspection.d.ts +6 -4
  265. package/dist/health/plugin-inspection.d.ts.map +1 -1
  266. package/dist/health/plugin-inspection.js +10 -9
  267. package/dist/health/plugin-inspection.js.map +1 -1
  268. package/dist/health/prepare.js +24 -8
  269. package/dist/health/prepare.js.map +1 -1
  270. package/dist/health/project-probes.d.ts +14 -7
  271. package/dist/health/project-probes.d.ts.map +1 -1
  272. package/dist/health/project-probes.js +14 -9
  273. package/dist/health/project-probes.js.map +1 -1
  274. package/dist/health/ruleset-compare.d.ts +30 -0
  275. package/dist/health/ruleset-compare.d.ts.map +1 -0
  276. package/dist/health/ruleset-compare.js +143 -0
  277. package/dist/health/ruleset-compare.js.map +1 -0
  278. package/dist/health/ruleset-config-checks.d.ts +66 -0
  279. package/dist/health/ruleset-config-checks.d.ts.map +1 -0
  280. package/dist/health/ruleset-config-checks.js +190 -0
  281. package/dist/health/ruleset-config-checks.js.map +1 -0
  282. package/dist/health/ruleset-expected.d.ts +39 -0
  283. package/dist/health/ruleset-expected.d.ts.map +1 -0
  284. package/dist/health/ruleset-expected.js +181 -0
  285. package/dist/health/ruleset-expected.js.map +1 -0
  286. package/dist/health/ruleset-gh.d.ts +85 -0
  287. package/dist/health/ruleset-gh.d.ts.map +1 -0
  288. package/dist/health/ruleset-gh.js +177 -0
  289. package/dist/health/ruleset-gh.js.map +1 -0
  290. package/dist/health/ruleset-inspection.d.ts +13 -117
  291. package/dist/health/ruleset-inspection.d.ts.map +1 -1
  292. package/dist/health/ruleset-inspection.js +8 -738
  293. package/dist/health/ruleset-inspection.js.map +1 -1
  294. package/dist/health/ruleset-normalize.d.ts +32 -0
  295. package/dist/health/ruleset-normalize.d.ts.map +1 -0
  296. package/dist/health/ruleset-normalize.js +160 -0
  297. package/dist/health/ruleset-normalize.js.map +1 -0
  298. package/dist/health/template-compose.d.ts +9 -0
  299. package/dist/health/template-compose.d.ts.map +1 -0
  300. package/dist/health/template-compose.js +105 -0
  301. package/dist/health/template-compose.js.map +1 -0
  302. package/dist/health/template-inspection.d.ts +5 -52
  303. package/dist/health/template-inspection.d.ts.map +1 -1
  304. package/dist/health/template-inspection.js +13 -435
  305. package/dist/health/template-inspection.js.map +1 -1
  306. package/dist/health/template-plan.d.ts +33 -0
  307. package/dist/health/template-plan.d.ts.map +1 -0
  308. package/dist/health/template-plan.js +154 -0
  309. package/dist/health/template-plan.js.map +1 -0
  310. package/dist/health/template-shape.d.ts +19 -0
  311. package/dist/health/template-shape.d.ts.map +1 -0
  312. package/dist/health/template-shape.js +122 -0
  313. package/dist/health/template-shape.js.map +1 -0
  314. package/dist/health/workflow-excerpt.d.ts +15 -0
  315. package/dist/health/workflow-excerpt.d.ts.map +1 -0
  316. package/dist/health/workflow-excerpt.js +88 -0
  317. package/dist/health/workflow-excerpt.js.map +1 -0
  318. package/dist/health/workflow-inputs-inspection.d.ts +16 -0
  319. package/dist/health/workflow-inputs-inspection.d.ts.map +1 -0
  320. package/dist/health/workflow-inputs-inspection.js +116 -0
  321. package/dist/health/workflow-inputs-inspection.js.map +1 -0
  322. package/dist/opencode/plugin-templates/block-managed-file-edits.sh +201 -20
  323. package/dist/standards/capture.d.ts.map +1 -1
  324. package/dist/standards/capture.js +73 -25
  325. package/dist/standards/capture.js.map +1 -1
  326. package/dist/standards/contract.d.ts.map +1 -1
  327. package/dist/standards/contract.js +26 -9
  328. package/dist/standards/contract.js.map +1 -1
  329. package/dist/standards/git-state.d.ts.map +1 -1
  330. package/dist/standards/git-state.js +2 -2
  331. package/dist/standards/git-state.js.map +1 -1
  332. package/dist/standards/registry-checks.d.ts +34 -0
  333. package/dist/standards/registry-checks.d.ts.map +1 -0
  334. package/dist/standards/registry-checks.js +137 -0
  335. package/dist/standards/registry-checks.js.map +1 -0
  336. package/dist/standards/registry.d.ts +3 -13
  337. package/dist/standards/registry.d.ts.map +1 -1
  338. package/dist/standards/registry.js +105 -194
  339. package/dist/standards/registry.js.map +1 -1
  340. package/dist/standards/storage.js +8 -10
  341. package/dist/standards/storage.js.map +1 -1
  342. package/dist/strategies/deduplicate-arrays.d.ts +18 -0
  343. package/dist/strategies/deduplicate-arrays.d.ts.map +1 -0
  344. package/dist/strategies/deduplicate-arrays.js +25 -0
  345. package/dist/strategies/deduplicate-arrays.js.map +1 -0
  346. package/dist/strategies/package-lisa-detect.d.ts +10 -0
  347. package/dist/strategies/package-lisa-detect.d.ts.map +1 -0
  348. package/dist/strategies/package-lisa-detect.js +178 -0
  349. package/dist/strategies/package-lisa-detect.js.map +1 -0
  350. package/dist/strategies/package-lisa-direct-floors.d.ts +16 -0
  351. package/dist/strategies/package-lisa-direct-floors.d.ts.map +1 -0
  352. package/dist/strategies/package-lisa-direct-floors.js +37 -0
  353. package/dist/strategies/package-lisa-direct-floors.js.map +1 -0
  354. package/dist/strategies/package-lisa-host-pins.d.ts +43 -0
  355. package/dist/strategies/package-lisa-host-pins.d.ts.map +1 -0
  356. package/dist/strategies/package-lisa-host-pins.js +254 -0
  357. package/dist/strategies/package-lisa-host-pins.js.map +1 -0
  358. package/dist/strategies/package-lisa-manifest-guards.d.ts +59 -0
  359. package/dist/strategies/package-lisa-manifest-guards.d.ts.map +1 -0
  360. package/dist/strategies/package-lisa-manifest-guards.js +234 -0
  361. package/dist/strategies/package-lisa-manifest-guards.js.map +1 -0
  362. package/dist/strategies/package-lisa-pin-alignment.d.ts +34 -0
  363. package/dist/strategies/package-lisa-pin-alignment.d.ts.map +1 -0
  364. package/dist/strategies/package-lisa-pin-alignment.js +106 -0
  365. package/dist/strategies/package-lisa-pin-alignment.js.map +1 -0
  366. package/dist/strategies/package-lisa-script-notes.d.ts +19 -0
  367. package/dist/strategies/package-lisa-script-notes.d.ts.map +1 -0
  368. package/dist/strategies/package-lisa-script-notes.js +145 -0
  369. package/dist/strategies/package-lisa-script-notes.js.map +1 -0
  370. package/dist/strategies/package-lisa-template-apply.d.ts +53 -0
  371. package/dist/strategies/package-lisa-template-apply.d.ts.map +1 -0
  372. package/dist/strategies/package-lisa-template-apply.js +216 -0
  373. package/dist/strategies/package-lisa-template-apply.js.map +1 -0
  374. package/dist/strategies/package-lisa-template-merge.d.ts +42 -0
  375. package/dist/strategies/package-lisa-template-merge.d.ts.map +1 -0
  376. package/dist/strategies/package-lisa-template-merge.js +202 -0
  377. package/dist/strategies/package-lisa-template-merge.js.map +1 -0
  378. package/dist/strategies/package-lisa-types.d.ts +5 -0
  379. package/dist/strategies/package-lisa-types.d.ts.map +1 -1
  380. package/dist/strategies/package-lisa.d.ts +1 -195
  381. package/dist/strategies/package-lisa.d.ts.map +1 -1
  382. package/dist/strategies/package-lisa.js +27 -1333
  383. package/dist/strategies/package-lisa.js.map +1 -1
  384. package/dist/strategies/tagged-merge-sections.d.ts +68 -0
  385. package/dist/strategies/tagged-merge-sections.d.ts.map +1 -0
  386. package/dist/strategies/tagged-merge-sections.js +113 -0
  387. package/dist/strategies/tagged-merge-sections.js.map +1 -0
  388. package/dist/strategies/tagged-merge.d.ts +1 -90
  389. package/dist/strategies/tagged-merge.d.ts.map +1 -1
  390. package/dist/strategies/tagged-merge.js +19 -190
  391. package/dist/strategies/tagged-merge.js.map +1 -1
  392. package/dist/utils/bounded-stream.d.ts +30 -0
  393. package/dist/utils/bounded-stream.d.ts.map +1 -0
  394. package/dist/utils/bounded-stream.js +63 -0
  395. package/dist/utils/bounded-stream.js.map +1 -0
  396. package/dist/utils/fibonacci.d.ts +3 -3
  397. package/dist/utils/fibonacci.d.ts.map +1 -1
  398. package/dist/utils/fibonacci.js +48 -10
  399. package/dist/utils/fibonacci.js.map +1 -1
  400. package/dist/utils/memo.d.ts +25 -0
  401. package/dist/utils/memo.d.ts.map +1 -0
  402. package/dist/utils/memo.js +32 -0
  403. package/dist/utils/memo.js.map +1 -0
  404. package/dist/utils/postinstall-trampoline.d.ts.map +1 -1
  405. package/dist/utils/postinstall-trampoline.js +3 -20
  406. package/dist/utils/postinstall-trampoline.js.map +1 -1
  407. package/dist/utils/process-environment.d.ts +42 -0
  408. package/dist/utils/process-environment.d.ts.map +1 -0
  409. package/dist/utils/process-environment.js +52 -0
  410. package/dist/utils/process-environment.js.map +1 -0
  411. package/dist/utils/resolve-executable.d.ts +89 -0
  412. package/dist/utils/resolve-executable.d.ts.map +1 -0
  413. package/dist/utils/resolve-executable.js +224 -0
  414. package/dist/utils/resolve-executable.js.map +1 -0
  415. package/dist/utils/shell-command-line.d.ts +9 -0
  416. package/dist/utils/shell-command-line.d.ts.map +1 -0
  417. package/dist/utils/shell-command-line.js +43 -0
  418. package/dist/utils/shell-command-line.js.map +1 -0
  419. package/dist/utils/usage-accounting-totals.d.ts +19 -0
  420. package/dist/utils/usage-accounting-totals.d.ts.map +1 -0
  421. package/dist/utils/usage-accounting-totals.js +145 -0
  422. package/dist/utils/usage-accounting-totals.js.map +1 -0
  423. package/dist/utils/usage-accounting.d.ts +2 -14
  424. package/dist/utils/usage-accounting.d.ts.map +1 -1
  425. package/dist/utils/usage-accounting.js +2 -169
  426. package/dist/utils/usage-accounting.js.map +1 -1
  427. package/eslint-plugin-code-organization/__tests__/enforce-statement-order-react-violations.test.js +213 -0
  428. package/eslint-plugin-code-organization/__tests__/enforce-statement-order-valid.test.js +251 -0
  429. package/eslint-plugin-code-organization/__tests__/enforce-statement-order-violations.test.js +222 -0
  430. package/eslint-plugin-code-organization/__tests__/statement-order-tester.js +42 -0
  431. package/eslint-plugin-code-organization/rules/enforce-statement-order.js +6 -8
  432. package/expo/copy-overwrite/jest.setup.ts +11 -10
  433. package/expo/create-only/scripts/zap-baseline.sh +6 -18
  434. package/harper-fabric/create-only/scripts/zap-baseline.sh +7 -9
  435. package/nestjs/create-only/scripts/zap-baseline.sh +6 -7
  436. package/package.json +4 -4
  437. package/phaser/copy-overwrite/.husky/pre-push.verify +2 -0
  438. package/plugins/lisa/.claude-plugin/plugin.json +1 -1
  439. package/plugins/lisa/.codex-plugin/plugin.json +1 -1
  440. package/plugins/lisa/.codex-plugin/skills/lisa-setup-remote-env/assets/session-start.sh +18 -5
  441. package/plugins/lisa/hooks/block-managed-file-edits.sh +201 -20
  442. package/plugins/lisa/hooks/block-masked-exit-status.sh +1 -1
  443. package/plugins/lisa/hooks/block-no-verify.agy.sh +1 -1
  444. package/plugins/lisa/hooks/enforce-verification-gate.sh +1 -2
  445. package/plugins/lisa/hooks/ticket-sync-reminder.sh +2 -17
  446. package/plugins/lisa/hooks/track-plan-sessions.sh +7 -131
  447. package/plugins/lisa/scripts/remote-agent-aws-setup.sh +3 -1
  448. package/plugins/lisa/skills/lisa-setup-remote-env/assets/session-start.sh +18 -5
  449. package/plugins/lisa-agy/hooks/block-managed-file-edits.sh +201 -20
  450. package/plugins/lisa-agy/hooks/block-no-verify.agy.sh +1 -1
  451. package/plugins/lisa-agy/plugin.json +1 -1
  452. package/plugins/lisa-agy/scripts/remote-agent-aws-setup.sh +3 -1
  453. package/plugins/lisa-agy/skills/lisa-setup-remote-env/assets/session-start.sh +18 -5
  454. package/plugins/lisa-cdk/.claude-plugin/plugin.json +1 -1
  455. package/plugins/lisa-cdk/.codex-plugin/plugin.json +1 -1
  456. package/plugins/lisa-cdk-agy/plugin.json +1 -1
  457. package/plugins/lisa-cdk-copilot/.claude-plugin/plugin.json +1 -1
  458. package/plugins/lisa-cdk-cursor/.claude-plugin/plugin.json +1 -1
  459. package/plugins/lisa-cdk-devin/.claude-plugin/plugin.json +1 -1
  460. package/plugins/lisa-cdk-devin/.devin-plugin/plugin.json +1 -1
  461. package/plugins/lisa-copilot/.claude-plugin/plugin.json +1 -1
  462. package/plugins/lisa-copilot/hooks/block-managed-file-edits.sh +201 -20
  463. package/plugins/lisa-copilot/hooks/block-masked-exit-status.sh +1 -1
  464. package/plugins/lisa-copilot/hooks/enforce-verification-gate.sh +1 -2
  465. package/plugins/lisa-copilot/scripts/remote-agent-aws-setup.sh +3 -1
  466. package/plugins/lisa-copilot/skills/lisa-setup-remote-env/assets/session-start.sh +18 -5
  467. package/plugins/lisa-cursor/.claude-plugin/plugin.json +1 -1
  468. package/plugins/lisa-cursor/hooks/block-managed-file-edits.sh +201 -20
  469. package/plugins/lisa-cursor/hooks/block-masked-exit-status.sh +1 -1
  470. package/plugins/lisa-cursor/hooks/enforce-verification-gate.sh +1 -2
  471. package/plugins/lisa-cursor/scripts/remote-agent-aws-setup.sh +3 -1
  472. package/plugins/lisa-cursor/skills/lisa-setup-remote-env/assets/session-start.sh +18 -5
  473. package/plugins/lisa-devin/.claude-plugin/plugin.json +1 -1
  474. package/plugins/lisa-devin/.devin-plugin/plugin.json +1 -1
  475. package/plugins/lisa-devin/hooks/block-managed-file-edits.sh +201 -20
  476. package/plugins/lisa-devin/hooks/block-masked-exit-status.sh +1 -1
  477. package/plugins/lisa-devin/hooks/enforce-verification-gate.sh +1 -2
  478. package/plugins/lisa-devin/scripts/remote-agent-aws-setup.sh +3 -1
  479. package/plugins/lisa-devin/skills/lisa-setup-remote-env/assets/session-start.sh +18 -5
  480. package/plugins/lisa-expo/.claude-plugin/plugin.json +1 -1
  481. package/plugins/lisa-expo/.codex-plugin/plugin.json +1 -1
  482. package/plugins/lisa-expo/.codex-plugin/skills/building-native-ui/references/webgpu-three.md +19 -9
  483. package/plugins/lisa-expo/.codex-plugin/skills/expo-tailwind-setup/SKILL.md +15 -4
  484. package/plugins/lisa-expo/skills/building-native-ui/references/webgpu-three.md +19 -9
  485. package/plugins/lisa-expo/skills/expo-tailwind-setup/SKILL.md +15 -4
  486. package/plugins/lisa-expo-agy/plugin.json +1 -1
  487. package/plugins/lisa-expo-agy/skills/building-native-ui/references/webgpu-three.md +19 -9
  488. package/plugins/lisa-expo-agy/skills/expo-tailwind-setup/SKILL.md +15 -4
  489. package/plugins/lisa-expo-copilot/.claude-plugin/plugin.json +1 -1
  490. package/plugins/lisa-expo-copilot/skills/building-native-ui/references/webgpu-three.md +19 -9
  491. package/plugins/lisa-expo-copilot/skills/expo-tailwind-setup/SKILL.md +15 -4
  492. package/plugins/lisa-expo-cursor/.claude-plugin/plugin.json +1 -1
  493. package/plugins/lisa-expo-cursor/skills/building-native-ui/references/webgpu-three.md +19 -9
  494. package/plugins/lisa-expo-cursor/skills/expo-tailwind-setup/SKILL.md +15 -4
  495. package/plugins/lisa-expo-devin/.claude-plugin/plugin.json +1 -1
  496. package/plugins/lisa-expo-devin/.devin-plugin/plugin.json +1 -1
  497. package/plugins/lisa-expo-devin/skills/building-native-ui/references/webgpu-three.md +19 -9
  498. package/plugins/lisa-expo-devin/skills/expo-tailwind-setup/SKILL.md +15 -4
  499. package/plugins/lisa-harper-fabric/.claude-plugin/plugin.json +1 -1
  500. package/plugins/lisa-harper-fabric/.codex-plugin/plugin.json +1 -1
  501. package/plugins/lisa-harper-fabric/hooks/block-generated-artifact-edits.sh +196 -11
  502. package/plugins/lisa-harper-fabric/hooks/enforce-config-extensions.sh +1 -1
  503. package/plugins/lisa-harper-fabric-agy/plugin.json +1 -1
  504. package/plugins/lisa-harper-fabric-copilot/.claude-plugin/plugin.json +1 -1
  505. package/plugins/lisa-harper-fabric-copilot/hooks/block-generated-artifact-edits.sh +196 -11
  506. package/plugins/lisa-harper-fabric-copilot/hooks/enforce-config-extensions.sh +1 -1
  507. package/plugins/lisa-harper-fabric-cursor/.claude-plugin/plugin.json +1 -1
  508. package/plugins/lisa-harper-fabric-cursor/hooks/block-generated-artifact-edits.sh +196 -11
  509. package/plugins/lisa-harper-fabric-cursor/hooks/enforce-config-extensions.sh +1 -1
  510. package/plugins/lisa-harper-fabric-devin/.claude-plugin/plugin.json +1 -1
  511. package/plugins/lisa-harper-fabric-devin/.devin-plugin/plugin.json +1 -1
  512. package/plugins/lisa-harper-fabric-devin/hooks/block-generated-artifact-edits.sh +196 -11
  513. package/plugins/lisa-harper-fabric-devin/hooks/enforce-config-extensions.sh +1 -1
  514. package/plugins/lisa-nestjs/.claude-plugin/plugin.json +1 -1
  515. package/plugins/lisa-nestjs/.codex-plugin/plugin.json +1 -1
  516. package/plugins/lisa-nestjs/.codex-plugin/skills/nestjs-rules/SKILL.md +39 -26
  517. package/plugins/lisa-nestjs/.codex-plugin/skills/typeorm-patterns/references/observability-patterns.md +18 -58
  518. package/plugins/lisa-nestjs/hooks/block-migration-edits.sh +1 -1
  519. package/plugins/lisa-nestjs/hooks/lisa-edit-gate.sh +19 -15
  520. package/plugins/lisa-nestjs/skills/nestjs-rules/SKILL.md +39 -26
  521. package/plugins/lisa-nestjs/skills/typeorm-patterns/references/observability-patterns.md +18 -58
  522. package/plugins/lisa-nestjs-agy/plugin.json +1 -1
  523. package/plugins/lisa-nestjs-agy/skills/nestjs-rules/SKILL.md +39 -26
  524. package/plugins/lisa-nestjs-agy/skills/typeorm-patterns/references/observability-patterns.md +18 -58
  525. package/plugins/lisa-nestjs-copilot/.claude-plugin/plugin.json +1 -1
  526. package/plugins/lisa-nestjs-copilot/hooks/block-migration-edits.sh +1 -1
  527. package/plugins/lisa-nestjs-copilot/hooks/lisa-edit-gate.sh +19 -15
  528. package/plugins/lisa-nestjs-copilot/skills/nestjs-rules/SKILL.md +39 -26
  529. package/plugins/lisa-nestjs-copilot/skills/typeorm-patterns/references/observability-patterns.md +18 -58
  530. package/plugins/lisa-nestjs-cursor/.claude-plugin/plugin.json +1 -1
  531. package/plugins/lisa-nestjs-cursor/hooks/block-migration-edits.sh +1 -1
  532. package/plugins/lisa-nestjs-cursor/hooks/lisa-edit-gate.sh +19 -15
  533. package/plugins/lisa-nestjs-cursor/skills/nestjs-rules/SKILL.md +39 -26
  534. package/plugins/lisa-nestjs-cursor/skills/typeorm-patterns/references/observability-patterns.md +18 -58
  535. package/plugins/lisa-nestjs-devin/.claude-plugin/plugin.json +1 -1
  536. package/plugins/lisa-nestjs-devin/.devin-plugin/plugin.json +1 -1
  537. package/plugins/lisa-nestjs-devin/hooks/block-migration-edits.sh +1 -1
  538. package/plugins/lisa-nestjs-devin/hooks/lisa-edit-gate.sh +19 -15
  539. package/plugins/lisa-nestjs-devin/skills/nestjs-rules/SKILL.md +39 -26
  540. package/plugins/lisa-nestjs-devin/skills/typeorm-patterns/references/observability-patterns.md +18 -58
  541. package/plugins/lisa-phaser/.claude-plugin/plugin.json +1 -1
  542. package/plugins/lisa-phaser/.codex-plugin/plugin.json +1 -1
  543. package/plugins/lisa-phaser-agy/plugin.json +1 -1
  544. package/plugins/lisa-phaser-copilot/.claude-plugin/plugin.json +1 -1
  545. package/plugins/lisa-phaser-cursor/.claude-plugin/plugin.json +1 -1
  546. package/plugins/lisa-phaser-devin/.claude-plugin/plugin.json +1 -1
  547. package/plugins/lisa-phaser-devin/.devin-plugin/plugin.json +1 -1
  548. package/plugins/lisa-rails/.claude-plugin/plugin.json +1 -1
  549. package/plugins/lisa-rails/.codex-plugin/plugin.json +1 -1
  550. package/plugins/lisa-rails/hooks/lisa-edit-gate.sh +19 -15
  551. package/plugins/lisa-rails/hooks/rubocop-on-edit.sh +2 -2
  552. package/plugins/lisa-rails/hooks/sg-scan-on-edit.sh +3 -3
  553. package/plugins/lisa-rails-agy/plugin.json +1 -1
  554. package/plugins/lisa-rails-copilot/.claude-plugin/plugin.json +1 -1
  555. package/plugins/lisa-rails-copilot/hooks/lisa-edit-gate.sh +19 -15
  556. package/plugins/lisa-rails-copilot/hooks/rubocop-on-edit.sh +2 -2
  557. package/plugins/lisa-rails-copilot/hooks/sg-scan-on-edit.sh +3 -3
  558. package/plugins/lisa-rails-cursor/.claude-plugin/plugin.json +1 -1
  559. package/plugins/lisa-rails-cursor/hooks/lisa-edit-gate.sh +19 -15
  560. package/plugins/lisa-rails-cursor/hooks/rubocop-on-edit.sh +2 -2
  561. package/plugins/lisa-rails-cursor/hooks/sg-scan-on-edit.sh +3 -3
  562. package/plugins/lisa-rails-devin/.claude-plugin/plugin.json +1 -1
  563. package/plugins/lisa-rails-devin/.devin-plugin/plugin.json +1 -1
  564. package/plugins/lisa-rails-devin/hooks/lisa-edit-gate.sh +19 -15
  565. package/plugins/lisa-rails-devin/hooks/rubocop-on-edit.sh +2 -2
  566. package/plugins/lisa-rails-devin/hooks/sg-scan-on-edit.sh +3 -3
  567. package/plugins/lisa-typescript/.claude-plugin/plugin.json +1 -1
  568. package/plugins/lisa-typescript/.codex-plugin/plugin.json +1 -1
  569. package/plugins/lisa-typescript/hooks/block-suppress-directives.sh +2 -2
  570. package/plugins/lisa-typescript/hooks/format-on-edit.sh +2 -2
  571. package/plugins/lisa-typescript/hooks/lint-on-edit.sh +2 -2
  572. package/plugins/lisa-typescript/hooks/lisa-edit-gate.sh +19 -15
  573. package/plugins/lisa-typescript/hooks/sg-scan-on-edit.sh +3 -3
  574. package/plugins/lisa-typescript-agy/plugin.json +1 -1
  575. package/plugins/lisa-typescript-copilot/.claude-plugin/plugin.json +1 -1
  576. package/plugins/lisa-typescript-copilot/hooks/block-suppress-directives.sh +2 -2
  577. package/plugins/lisa-typescript-copilot/hooks/format-on-edit.sh +2 -2
  578. package/plugins/lisa-typescript-copilot/hooks/lint-on-edit.sh +2 -2
  579. package/plugins/lisa-typescript-copilot/hooks/lisa-edit-gate.sh +19 -15
  580. package/plugins/lisa-typescript-copilot/hooks/sg-scan-on-edit.sh +3 -3
  581. package/plugins/lisa-typescript-cursor/.claude-plugin/plugin.json +1 -1
  582. package/plugins/lisa-typescript-cursor/hooks/block-suppress-directives.sh +2 -2
  583. package/plugins/lisa-typescript-cursor/hooks/format-on-edit.sh +2 -2
  584. package/plugins/lisa-typescript-cursor/hooks/lint-on-edit.sh +2 -2
  585. package/plugins/lisa-typescript-cursor/hooks/lisa-edit-gate.sh +19 -15
  586. package/plugins/lisa-typescript-cursor/hooks/sg-scan-on-edit.sh +3 -3
  587. package/plugins/lisa-typescript-devin/.claude-plugin/plugin.json +1 -1
  588. package/plugins/lisa-typescript-devin/.devin-plugin/plugin.json +1 -1
  589. package/plugins/lisa-typescript-devin/hooks/block-suppress-directives.sh +2 -2
  590. package/plugins/lisa-typescript-devin/hooks/format-on-edit.sh +2 -2
  591. package/plugins/lisa-typescript-devin/hooks/lint-on-edit.sh +2 -2
  592. package/plugins/lisa-typescript-devin/hooks/lisa-edit-gate.sh +19 -15
  593. package/plugins/lisa-typescript-devin/hooks/sg-scan-on-edit.sh +3 -3
  594. package/plugins/lisa-wiki/.claude-plugin/plugin.json +1 -1
  595. package/plugins/lisa-wiki/.codex-plugin/plugin.json +1 -1
  596. package/plugins/lisa-wiki-agy/plugin.json +1 -1
  597. package/plugins/lisa-wiki-copilot/.claude-plugin/plugin.json +1 -1
  598. package/plugins/lisa-wiki-cursor/.claude-plugin/plugin.json +1 -1
  599. package/plugins/lisa-wiki-devin/.claude-plugin/plugin.json +1 -1
  600. package/plugins/lisa-wiki-devin/.devin-plugin/plugin.json +1 -1
  601. package/plugins/src/base/hooks/block-managed-file-edits.sh +201 -20
  602. package/plugins/src/base/hooks/block-masked-exit-status.sh +1 -1
  603. package/plugins/src/base/hooks/block-no-verify.agy.sh +1 -1
  604. package/plugins/src/base/hooks/enforce-verification-gate.sh +1 -2
  605. package/plugins/src/base/hooks/ticket-sync-reminder.sh +2 -17
  606. package/plugins/src/base/hooks/track-plan-sessions.sh +7 -131
  607. package/plugins/src/base/scripts/remote-agent-aws-setup.sh +3 -1
  608. package/plugins/src/base/skills/lisa-setup-remote-env/assets/session-start.sh +18 -5
  609. package/plugins/src/expo/skills/building-native-ui/references/webgpu-three.md +19 -9
  610. package/plugins/src/expo/skills/expo-tailwind-setup/SKILL.md +15 -4
  611. package/plugins/src/harper-fabric/hooks/block-generated-artifact-edits.sh +196 -11
  612. package/plugins/src/harper-fabric/hooks/enforce-config-extensions.sh +1 -1
  613. package/plugins/src/nestjs/hooks/block-migration-edits.sh +1 -1
  614. package/plugins/src/nestjs/hooks/lisa-edit-gate.sh +19 -15
  615. package/plugins/src/nestjs/skills/nestjs-rules/SKILL.md +39 -26
  616. package/plugins/src/nestjs/skills/typeorm-patterns/references/observability-patterns.md +18 -58
  617. package/plugins/src/rails/hooks/lisa-edit-gate.sh +19 -15
  618. package/plugins/src/rails/hooks/rubocop-on-edit.sh +2 -2
  619. package/plugins/src/rails/hooks/sg-scan-on-edit.sh +3 -3
  620. package/plugins/src/typescript/hooks/block-suppress-directives.sh +2 -2
  621. package/plugins/src/typescript/hooks/format-on-edit.sh +2 -2
  622. package/plugins/src/typescript/hooks/lint-on-edit.sh +2 -2
  623. package/plugins/src/typescript/hooks/lisa-edit-gate.sh +19 -15
  624. package/plugins/src/typescript/hooks/sg-scan-on-edit.sh +3 -3
  625. package/scripts/build-plugins.sh +1 -1
  626. package/scripts/check-derived-artifacts.mjs +2 -2
  627. package/scripts/check-generated-artifact-merge-coverage.mjs +45 -4
  628. package/scripts/check-orphan-test-processes.mjs +0 -1
  629. package/scripts/check-self-dependency-pin.mjs +0 -2
  630. package/scripts/claude-remote-setup.sh +12 -7
  631. package/scripts/cleanup-amplify-branches.sh +0 -1
  632. package/scripts/generate-export-surface.mjs +131 -61
  633. package/scripts/generate-lisa-owned-hash-ledger.mjs +87 -102
  634. package/scripts/generate-upstream-evidence-manifest.mjs +56 -49
  635. package/scripts/github-status-check.sh +5 -25
  636. package/scripts/install-claude-plugins.sh +10 -8
  637. package/scripts/lib/merge-generated-json.mjs +274 -0
  638. package/scripts/lib/upstream-manifest-staleness.mjs +38 -34
  639. package/scripts/lib/upstream-public-commits.mjs +35 -18
  640. package/scripts/lisa-commit-and-pr-local.sh +1 -1
  641. package/scripts/lisa-enforcement-fallback.sh +31 -32
  642. package/scripts/lisa-github-environments.sh +5 -1
  643. package/scripts/lisa-github-repo-settings.sh +5 -1
  644. package/scripts/lisa-github-repo-setup.sh +1 -2
  645. package/scripts/lisa-github-rulesets.sh +8 -8
  646. package/scripts/lisa-remote-env/session-start.sh +18 -5
  647. package/scripts/lisa-rollback-release.mjs +0 -2
  648. package/scripts/lisa-update-local.sh +1 -1
  649. package/scripts/merge-generated-artifact.mjs +18 -6
  650. package/scripts/raise-self-dependency-pin.mjs +0 -2
  651. package/scripts/run-artifact-checks.mjs +1 -1
  652. package/scripts/verify-packed-learnings-contract.mjs +36 -3
  653. package/scripts/verify-self-pin-raise.mjs +0 -2
  654. package/typescript/copy-contents/.husky/commit-msg +8 -2
  655. package/typescript/copy-contents/.husky/post-checkout +2 -0
  656. package/typescript/copy-contents/.husky/post-merge +2 -0
  657. package/typescript/copy-contents/.husky/pre-commit +10 -3
  658. package/typescript/copy-contents/.husky/pre-push +29 -16
  659. package/typescript/copy-contents/.husky/prepare-commit-msg +2 -0
  660. package/typescript/create-only/.husky/pre-push.local +2 -0
  661. package/eslint-plugin-code-organization/__tests__/enforce-statement-order.test.js +0 -643
package/dist/core/lisa.js CHANGED
@@ -1,222 +1,14 @@
1
- /* eslint-disable max-lines -- Main orchestrator class with apply/validate operations */
2
1
  import * as fse from "fs-extra";
3
- import { existsSync } from "node:fs";
4
- import { readFile, stat, unlink, writeFile } from "node:fs/promises";
5
- import * as path from "node:path";
2
+ import { stat } from "node:fs/promises";
6
3
  import pc from "picocolors";
7
- import { ensureRailsHooks, RAILS_HOOK_INSTALL_COMMAND, } from "../../scripts/lib/rails-hooks.mjs";
8
- import { getPackageVersion } from "../cli/version.js";
9
- import { RECONCILIATION_REPORT_SCHEMA_VERSION, recordReconciliationScheduled, recordReconciliationSpawnFailure, resolveReconciliationReportPath, } from "./reconciliation-report.js";
10
- import { installAgentsMd } from "../codex/agents-md-installer.js";
11
- import { installCodexProjectOverlay } from "../codex/project-overlay.js";
12
- import { installAgyPlugin } from "../agy/plugin-installer.js";
13
- import { collectLisaMcpServers, installAgyMcpConfig, resolveAgyMcpConfigPath, } from "../agy/mcp-installer.js";
14
- import { installCopilotPlugin } from "../copilot/plugin-installer.js";
15
- import { detectDevin, installDevinPlugin } from "../devin/plugin-installer.js";
16
- import { installDevinEnforcementFallback } from "../devin/enforcement-fallback-installer.js";
17
- import { installSonarIntegrations } from "../sonar/sonar-installer.js";
18
- import { repointSonarShims } from "../sonar/sonar-shim-repoint.js";
19
- import { installCopilotInstructions } from "../copilot/copilot-instructions-installer.js";
20
- import { readManagedManifest as readOpencodeManifest, writeManagedManifest as writeOpencodeManifest, } from "../opencode/manifest.js";
21
- import { installSkills as installOpencodeSkills } from "../opencode/skills-installer.js";
22
- import { installHooks as installOpencodeHooks } from "../opencode/hooks-installer.js";
23
- import { installSettings as installOpencodeSettings } from "../opencode/settings-installer.js";
24
- import { installOpencodeMcpConfig, resolveOpencodeConfigPath, } from "../opencode/mcp-installer.js";
25
- import { discoverAndInstallAgents as installOpencodeAgents } from "../opencode/agent-installer.js";
26
- import { discoverAndInstallCommands as installOpencodeCommands } from "../opencode/command-installer.js";
27
- import { installClaudeMd } from "../claude/claude-md-installer.js";
28
- import { isPostinstallSafeApply } from "./apply-mode.js";
29
4
  import { isLisaSourceRepo } from "./self-apply.js";
30
5
  import { DestinationNotDirectoryError, DestinationNotFoundError, UserAbortedError, } from "../errors/index.js";
31
- import { listFilesRecursive } from "../utils/file-operations.js";
32
- import { resolvePrimaryWorktreeRoot } from "../utils/linked-worktree.js";
33
- import { readMarketplaceCatalog } from "../utils/marketplace-manifest.js";
34
- import { describeSkippedPluginKey, partitionByLisaMarketplace, } from "./plugin-marketplace-filter.js";
35
- import { pruneDeadPluginRegistrations } from "./plugin-registration-prune.js";
36
- import { loadIgnorePatterns, } from "../utils/ignore-patterns.js";
37
- import { getLisaDistDir, hashFile, isRunningAsTrampoline, regenerateLockfilesInProcess, scheduleReconciliationChild, shouldSchedulePostinstallReconciliation, } from "../utils/postinstall-trampoline.js";
38
- import { COPY_STRATEGIES, createInitialCounters, harnessIncludesAgent, } from "./config.js";
39
- import { migrateInstructionFiles, relocateProjectLearningsLedger, } from "./instruction-files-migration.js";
40
- import { assertSafeLearningParents, resolveSafeLearningTarget, } from "./learnings-file-safety.js";
41
- import { APPLY_RECEIPT_DISPLAY_PATH } from "./apply-receipt.js";
42
- import { PLUGIN_LIST_MAX_CAPTURE_BYTES, PLUGIN_PROBE_TIMEOUT_MS, PLUGIN_PRUNE_TIMEOUT_MS, PLUGIN_REGISTRATION_TIMEOUT_MS, runPluginCommand, } from "./plugin-command.js";
43
- import { basisAuthorisesDeletion, resolveDeletionBasis, } from "./deletion-basis.js";
44
- import { findLocalWorkflowReferences } from "./workflow-reference-guard.js";
45
- import { findHostReferences, isShippedVersion, readRegularFile, retiredDigests, stillProved, } from "./retire-unmodified.js";
46
- import { classifyWorkflowForDeletion, describeRefusal, isWorkflowDeletionPath, } from "./workflow-deletion-ownership.js";
47
- import { dependencySettingsWarning, humanGateSettingsWarnings, readProjectConfig, resolveLegacyProjectLearningsFile, resolveProjectLearningsFile, } from "./project-config.js";
48
- import { decideTemplateOwnership, templateSkipDescription, } from "./template-ownership.js";
49
- /**
50
- * Log fragment used when a create-only instruction file already exists and is
51
- * therefore left untouched (the host owns it).
52
- */
53
- const HOST_OWNED_LABEL = "already present (host-owned)";
54
- const CREATE_ONLY_STRATEGY = "create-only";
55
- const COPY_CONTENTS_STRATEGY = "copy-contents";
56
- const PROJECT_LEARNINGS_TEMPLATE_PATH = path.join(".lisa", "PROJECT_LEARNINGS.md");
57
- /** Generic fallback when a plugin command has no readable error. */
58
- const PLUGIN_COMMAND_FAILED = "command failed";
6
+ import { hashFile } from "../utils/postinstall-trampoline.js";
7
+ import { LisaMaintenance } from "./lisa-maintenance.js";
59
8
  /**
60
9
  * Main Lisa orchestrator
61
10
  */
62
- export class Lisa {
63
- config;
64
- deps;
65
- counters = createInitialCounters();
66
- /**
67
- * Managed files this apply found out of date but could not update.
68
- *
69
- * Named so the summary can list them: a count alone tells an operator that
70
- * something did not land without telling them what, which is most of the way
71
- * back to the silence this exists to end.
72
- */
73
- stalePaths = [];
74
- /**
75
- * Lisa-owned artifacts this apply deliberately did not replace, each with the
76
- * reason spelled out for whoever reads the output.
77
- *
78
- * Full sentences rather than paths, because this is the one outcome an
79
- * operator cannot act on from the filename: "we left yours alone because it
80
- * defends something ours does not" is the entire message.
81
- */
82
- hostAheadNotes = [];
83
- /**
84
- * Templates this apply declined to write because they would have outranked
85
- * configuration the project already maintains, each with the reason.
86
- *
87
- * Full sentences for the same reason as {@link hostAheadNotes}: the filename
88
- * alone cannot convey it. The absent file is the *correct* outcome here, so
89
- * without the sentence an operator has nothing to distinguish "Lisa
90
- * deliberately stood down" from "the template never arrived".
91
- */
92
- shadowedNotes = [];
93
- /**
94
- * Every path this apply removed, and every workflow it refused to remove, as
95
- * operator-readable lines.
96
- *
97
- * Announced unconditionally — including the removals Lisa is entitled to
98
- * make. A destructive step nobody can see is half the defect in
99
- * CodySwannGT/lisa#3656: the deletions were correct-looking code doing exactly
100
- * what a manifest told them to, and the reason it cost a consumer three
101
- * workflows is that no human ever had the chance to disagree.
102
- *
103
- * Deliberately wider than the ownership gate. The gate is scoped to
104
- * `.github/workflows/` because a workflow's absence produces no signal
105
- * anywhere, but the manifests declare 255 paths and 213 of them are not
106
- * workflows — `.claude` trees, root-level `eslint-plugin-*` directories,
107
- * jest/vitest/tsconfig files — every one removed recursively by destination
108
- * path with the content never consulted. Announcing costs nothing and can
109
- * break no legitimate deletion, so there is no reason for those 213 to keep
110
- * going silently while this class of defect is being fixed.
111
- */
112
- deletionNotices = [];
113
- /**
114
- * Repo-relative paths this apply actually removed, workflow or not.
115
- *
116
- * The console copy of this list is the one an operator is meant to read, and
117
- * the one they demonstrably cannot. Two mechanisms guarantee it: a package
118
- * manager hides postinstall stdout, and the reconciliation trampoline is
119
- * spawned detached with `stdio: "ignore"` (`utils/postinstall-trampoline`) so
120
- * anything it writes is not merely easy to miss but PROVABLY unobservable.
121
- * An announcement that only exists on stdout is therefore not an
122
- * announcement. Persisting the list into the apply receipt is what survives
123
- * both, and follows `stale_paths` (#3033), added for the same reason.
124
- */
125
- deletedPaths = [];
126
- detectedTypes = [];
127
- ignorePatterns = {
128
- patterns: [],
129
- shouldIgnore: () => false,
130
- };
131
- /**
132
- * Paths marked for deletion by any detected project type's deletions.json.
133
- * Used to skip creating files that would just be deleted moments later (e.g.,
134
- * CDK inherits jest.* files from typescript but its own deletions.json removes
135
- * them — without this gate, Lisa creates then immediately deletes the files,
136
- * causing ENOENT races for any concurrent linter/file-watcher).
137
- */
138
- pendingDeletions = new Set();
139
- /**
140
- * Maps each relative path shipped by any type's `create-only/` tree to the
141
- * single type that "owns" it (most-specific wins). Computed once before
142
- * strategies run; consulted while processing `create-only` to suppress
143
- * parent-type sources for paths that a child type also ships.
144
- *
145
- * Motivating case: CDK projects detect as both `typescript` and `cdk`.
146
- * Both ship `.github/workflows/ci.yml` under their `create-only/` trees.
147
- * Without this map, typescript's bun-mode ci.yml runs first and creates
148
- * the file; cdk's npm-mode + determine_environment ci.yml then sees the
149
- * file already exists and is silently skipped — producing a CDK project
150
- * wired to use bun, which fails immediately in CI because CDK projects
151
- * have `engines.bun = "please-use-npm"` and only a `package-lock.json`.
152
- */
153
- createOnlyOwnership = new Map();
154
- /**
155
- * Maps each relative path shipped by any type's `copy-overwrite/` tree to the
156
- * single type that "owns" it (most-specific wins). Computed once before
157
- * strategies run; consulted while processing `copy-overwrite` to suppress
158
- * parent-type sources for paths that a child type also ships.
159
- *
160
- * Why this exists — crash safety: `copy-overwrite` always overwrites, so the
161
- * per-type outer loop in `processConfigurations` naturally lets the child win
162
- * by writing the parent's version first and then overwriting it. But that
163
- * leaves a window in which the destination holds the parent (typescript)
164
- * version of an overlapping path (e.g. `tsconfig.json`, `eslint.config.ts`)
165
- * before the child (expo/cdk/nestjs) phase overwrites it. If the process is
166
- * killed in that window — which is exactly what bun's lifecycle-script
167
- * handling did during postinstall — the project is left with TypeScript
168
- * configs clobbering the child stack's (Expo getting the typescript
169
- * `include` glob in tsconfig.json instead of its own).
170
- * That was the bug fixed by removing the postinstall apply in #318.
171
- *
172
- * Resolving ownership up front and writing each path exactly once (by its
173
- * most-specific type) eliminates the intermediate write entirely: a kill at
174
- * any point leaves either the pre-existing file or the correct final file,
175
- * never the parent-clobbered intermediate. This is the symmetric counterpart
176
- * to `createOnlyOwnership` (which exists for the opposite reason — create-only
177
- * skips existing files, so without help the parent would win).
178
- */
179
- copyOverwriteOwnership = new Map();
180
- /** Destination selected by the host project's projectRulesFile setting. */
181
- projectLearningsFile = PROJECT_LEARNINGS_TEMPLATE_PATH;
182
- /** Whether the canonical all/create-only learnings source is registered. */
183
- projectLearningsTemplateRegistered = false;
184
- /**
185
- * True when a populated legacy ledger exists and the new `.lisa/` destination
186
- * does not yet — the create-only strategy must NOT seed an empty ledger over
187
- * it, or the pending relocation would collide (both-exist no-clobber) and
188
- * strand the real entries at the raw-injected legacy path.
189
- */
190
- suppressLearningsSeedForRelocation = false;
191
- separator = "========================================";
192
- lisaignoreSuffix = "(.lisaignore)";
193
- /**
194
- * True when the destination is the Lisa source repo itself. A self-apply
195
- * skips deletions, template application, and postinstall injection while
196
- * still applying package.lisa.json dependency governance. See {@link isLisaSourceRepo}.
197
- */
198
- selfApply = false;
199
- /**
200
- * Initialize Lisa orchestrator
201
- * @param config - Configuration for the apply operation
202
- * @param deps - Injected service dependencies
203
- */
204
- constructor(config, deps) {
205
- this.config = config;
206
- this.deps = deps;
207
- }
208
- /**
209
- * Postinstall applies are intentionally narrow: they refresh governance
210
- * templates that must track dependency updates, but they must not regenerate
211
- * project-scoped agent surfaces. Agent trees are large, committed outputs and
212
- * are updated through an explicit `lisa apply` or cross-pollinate run. A
213
- * self-apply against the Lisa source repo also skips emit — those agent
214
- * surfaces are built from `plugins/src`, not regenerated by apply.
215
- * @returns True when the current apply should avoid agent-surface writes.
216
- */
217
- shouldSkipAgentEmitDuringPostinstall() {
218
- return isPostinstallSafeApply(this.config) || this.selfApply;
219
- }
11
+ export class Lisa extends LisaMaintenance {
220
12
  /**
221
13
  * Initialize services
222
14
  */
@@ -253,819 +45,44 @@ export class Lisa {
253
45
  }
254
46
  }
255
47
  /**
256
- * Process all configurations
257
- */
258
- async processConfigurations() {
259
- const { logger } = this.deps;
260
- // Load ignore patterns from destination project
261
- this.ignorePatterns = await loadIgnorePatterns(this.config.destDir);
262
- if (this.ignorePatterns.patterns.length > 0) {
263
- logger.info(`Loaded .lisaignore with ${this.ignorePatterns.patterns.length} pattern(s)`);
264
- }
265
- logger.info("Processing common configurations (all/)...");
266
- await this.processProjectType("all");
267
- for (const type of this.detectedTypes) {
268
- const typeDir = path.join(this.config.lisaDir, type);
269
- if (await fse.pathExists(typeDir)) {
270
- logger.info(`Processing ${type} configurations...`);
271
- await this.processProjectType(type);
272
- }
273
- else {
274
- logger.warn(`No configuration directory found for type: ${type}`);
275
- }
276
- }
277
- }
278
- /**
279
- * Pre-compute the set of paths marked for deletion across "all" and every
280
- * detected project type. This runs before strategy processing so the copy
281
- * strategies can skip creating files that are about to be deleted anyway.
282
- *
283
- * Motivating case: CDK inherits typescript/create-only, which ships
284
- * `jest.thresholds.json`. CDK's own `deletions.json` then removes it.
285
- * Without this gate, Lisa would create it and delete it in the same apply,
286
- * which causes ENOENT errors for any concurrent file-watcher/linter that
287
- * observed the briefly-existing file.
288
- *
289
- * The `keep` list in a deletions.json (e.g., expo keeps
290
- * `zap-baseline-expo.yml`) is honored — paths in `keep` are not treated as
291
- * pending-deletions, so they will still be created by upstream strategies.
292
- * @returns Promise that resolves once pending deletions have been collected
293
- */
294
- async loadPendingDeletions() {
295
- const pending = new Set();
296
- for (const type of ["all", ...this.detectedTypes]) {
297
- const paths = await this.readPendingDeletionsForType(type);
298
- for (const p of paths) {
299
- pending.add(path.normalize(p));
300
- }
301
- }
302
- this.pendingDeletions = pending;
303
- }
304
- /**
305
- * Resolve the host-owned learnings destination before template ownership is
306
- * computed. The canonical source stays at its stable package path while its
307
- * destination follows the configured project-rules directory.
308
- */
309
- async loadProjectLearningsFile() {
310
- const config = await readProjectConfig(this.config.destDir);
311
- const relativeFile = resolveProjectLearningsFile(config);
312
- const { root, target } = resolveSafeLearningTarget(this.config.destDir, relativeFile);
313
- await assertSafeLearningParents(root, path.dirname(target));
314
- this.projectLearningsFile = path.normalize(relativeFile);
315
- // Belt-and-braces against the fleet-upgrade defect: if a populated legacy
316
- // ledger exists and the destination does not, the create-only strategy must
317
- // not seed an empty ledger here — the relocation (which runs even on the
318
- // bootstrap/skip path) moves the real file into place instead.
319
- const legacyRelative = resolveLegacyProjectLearningsFile(config);
320
- this.suppressLearningsSeedForRelocation =
321
- legacyRelative !== relativeFile &&
322
- (await fse.pathExists(path.join(this.config.destDir, legacyRelative))) &&
323
- !(await fse.pathExists(target));
324
- }
325
- /**
326
- * Warn when `humanGate` or `dependencies.humanSignOff` holds a value outside
327
- * its closed vocabulary. The value is treated as its default rather than
328
- * failing the apply (see `project-config-dependencies` and
329
- * `project-config-human-gate`), so this warning is the only
330
- * place the CLI says the project did not get the setting it typed.
331
- */
332
- async reportInvalidDependencySettings() {
333
- const config = await readProjectConfig(this.config.destDir);
334
- // `humanGate` degrades the same way (CodySwannGT/lisa#4687): an invalid
335
- // mode resolves to "access-only", and this is where the CLI says so.
336
- for (const line of humanGateSettingsWarnings(config)) {
337
- this.deps.logger.warn(line);
338
- }
339
- const warning = dependencySettingsWarning(config);
340
- if (warning !== undefined)
341
- this.deps.logger.warn(warning);
342
- }
343
- /**
344
- * Pre-compute, for every relative path shipped by any type's `create-only/`
345
- * directory, which single type "owns" it. The owner is the most-specific
346
- * detected type — i.e., the last entry in [all, ...detectedTypes] (already
347
- * canonically ordered parent-before-child by `expandAndOrderTypes`).
348
- *
349
- * Why this is needed: the `create-only` strategy intentionally does nothing
350
- * when the destination file already exists. Combined with the per-type
351
- * outer loop in `processConfigurations`, that means the *first* type to
352
- * ship a `create-only/<path>` creates the file and every later type's
353
- * version is silently skipped. For paths that overlap between a parent
354
- * stack (typescript) and a child stack (cdk/expo/nestjs/npm-package), this
355
- * lets the parent win — the exact opposite of the rest of Lisa's
356
- * "child overrides parent" semantics. See `copy-overwrite` for comparison:
357
- * because it always overwrites, the per-type ordering naturally lets
358
- * children win. `create-only` needs explicit help.
359
- *
360
- * The fix: the orchestrator pre-computes this ownership map and, while
361
- * processing `create-only`, skips any source whose owning type isn't the
362
- * current one. The result is that exactly one source wins per path — the
363
- * most-specific detected type.
364
- * @returns Promise that resolves once ownership has been resolved
365
- */
366
- async loadCreateOnlyOwnership() {
367
- const ownership = new Map();
368
- for (const type of ["all", ...this.detectedTypes]) {
369
- const createOnlyDir = path.join(this.config.lisaDir, type, CREATE_ONLY_STRATEGY);
370
- if (!(await fse.pathExists(createOnlyDir))) {
371
- continue;
372
- }
373
- const files = await listFilesRecursive(createOnlyDir);
374
- for (const file of files) {
375
- const sourceRelativePath = path.relative(createOnlyDir, file);
376
- const relativePath = this.resolveTemplateDestination(sourceRelativePath, CREATE_ONLY_STRATEGY, type);
377
- // Later types overwrite earlier ones, so child wins over parent.
378
- ownership.set(relativePath, type);
379
- }
380
- }
381
- const canonicalSource = path.join(this.config.lisaDir, "all", CREATE_ONLY_STRATEGY, PROJECT_LEARNINGS_TEMPLATE_PATH);
382
- this.projectLearningsTemplateRegistered =
383
- await fse.pathExists(canonicalSource);
384
- if (this.projectLearningsTemplateRegistered) {
385
- // Durable project memory is a single contract, not a stack override.
386
- ownership.set(this.projectLearningsFile, "all");
387
- }
388
- this.createOnlyOwnership = ownership;
389
- }
390
- /**
391
- * Pre-compute, for every relative path shipped by any type's `copy-overwrite/`
392
- * directory, which single type "owns" it — the most-specific detected type
393
- * (last entry in [all, ...detectedTypes], already ordered parent-before-child).
394
- *
395
- * Consumed by `shouldProcessFile` to skip non-owning sources so each path is
396
- * written exactly once, by its winning stack. See the `copyOverwriteOwnership`
397
- * field doc for the crash-safety rationale (eliminating the parent-then-child
398
- * overwrite window that left half-applied configs when the process was killed
399
- * mid-apply during postinstall — the bug behind #318).
400
- * @returns Promise that resolves once ownership has been resolved
401
- */
402
- async loadCopyOverwriteOwnership() {
403
- const ownership = new Map();
404
- for (const type of ["all", ...this.detectedTypes]) {
405
- const copyOverwriteDir = path.join(this.config.lisaDir, type, "copy-overwrite");
406
- if (!(await fse.pathExists(copyOverwriteDir))) {
407
- continue;
408
- }
409
- const files = await listFilesRecursive(copyOverwriteDir);
410
- for (const file of files) {
411
- const relativePath = path.relative(copyOverwriteDir, file);
412
- // Later types overwrite earlier ones, so child wins over parent.
413
- ownership.set(relativePath, type);
414
- }
415
- }
416
- this.copyOverwriteOwnership = ownership;
417
- }
418
- /**
419
- * Read the set of paths a single type's deletions.json will delete,
420
- * filtered by the type's `keep` list. Returns an empty array when the file
421
- * is missing or malformed — a bad file cannot block strategy processing;
422
- * any validation errors are surfaced later by processDeletions itself.
423
- * @param type - Project type (e.g., "all", "cdk", "typescript")
424
- * @returns Array of relative paths marked for deletion
425
- */
426
- async readPendingDeletionsForType(type) {
427
- const deletionsPath = path.join(this.config.lisaDir, type, "deletions.json");
428
- if (!(await fse.pathExists(deletionsPath))) {
429
- return [];
430
- }
431
- try {
432
- const content = await readFile(deletionsPath, "utf-8");
433
- const deletions = JSON.parse(content);
434
- if (!Array.isArray(deletions.paths)) {
435
- return [];
436
- }
437
- const keepSet = new Set(deletions.keep ?? []);
438
- return deletions.paths.filter(p => !keepSet.has(p));
439
- }
440
- catch {
441
- return [];
442
- }
443
- }
444
- /**
445
- * Process deletions from deletions.json files
446
- */
447
- async processDeletions() {
448
- const { logger } = this.deps;
449
- // Process deletions for "all" and each detected type
450
- const typesToProcess = ["all", ...this.detectedTypes];
451
- for (const type of typesToProcess) {
452
- const deletionsPath = path.join(this.config.lisaDir, type, "deletions.json");
453
- if (await fse.pathExists(deletionsPath)) {
454
- logger.info(`Processing deletions for ${type}...`);
455
- await this.processDeletionsFile(deletionsPath);
456
- }
457
- }
458
- }
459
- /**
460
- * Process a single deletions.json file
461
- * @param deletionsPath - Path to the deletions.json file
462
- */
463
- async processDeletionsFile(deletionsPath) {
464
- const { logger } = this.deps;
465
- try {
466
- const content = await readFile(deletionsPath, "utf-8");
467
- const deletions = JSON.parse(content);
468
- if (!Array.isArray(deletions.paths)) {
469
- logger.warn(`Invalid deletions.json format: paths must be an array`);
470
- return;
471
- }
472
- const keepSet = new Set(deletions.keep ?? []);
473
- for (const relativePath of deletions.paths) {
474
- if (keepSet.has(relativePath)) {
475
- logger.info(`Kept (protected): ${relativePath}`);
476
- continue;
477
- }
478
- // "I cannot tell" is a THIRD answer, and it has to be, or the uncertain
479
- // case gets silently resolved as one of the other two. A manifest that
480
- // does not say why a path may go does not authorise removing it: the
481
- // cheap error is keeping a file, because a path wrongly kept is visible
482
- // and fixable while a path wrongly deleted is gone from someone else's
483
- // repository with no undo (CodySwannGT/lisa#3700).
484
- //
485
- // This is the runtime fail-safe, and it is deliberately not the same
486
- // mechanism as the authoring check. That one refuses an unclassified
487
- // entry at commit time; this one protects a consumer whatever manifest
488
- // they happen to have, including one authored before either existed.
489
- const basis = resolveDeletionBasis(deletions, relativePath);
490
- if (!basisAuthorisesDeletion(basis)) {
491
- const notice = `Kept (no declared basis): ${relativePath} — the manifest lists this path but does not say why it may be removed, so it was not.`;
492
- logger.warn(notice);
493
- // Recorded, not merely logged. This is the fail-closed branch, and on
494
- // the install path a branch whose only account of itself goes to a
495
- // hidden stream is indistinguishable from one that never ran
496
- // (CodySwannGT/lisa#4071).
497
- this.deletionNotices.push(notice);
498
- this.counters.skipped++;
499
- continue;
500
- }
501
- await this.processSingleDeletion(relativePath, deletions.force?.[relativePath], retiredDigests(deletions, relativePath));
502
- }
503
- }
504
- catch (error) {
505
- const message = error instanceof Error ? error.message : String(error);
506
- logger.warn(`Failed to process deletions file: ${message}`);
507
- }
508
- }
509
- /**
510
- * Process a single deletion path
511
- * @param relativePath - Relative path to delete
512
- * @param forcedReason - Why this removal overrides the workflow ownership gate, when it does
513
- * @param shipped - Digests of every version Lisa shipped, when the manifest retires this path only while unmodified
514
- */
515
- async processSingleDeletion(relativePath, forcedReason, shipped = null) {
516
- const { logger } = this.deps;
517
- const normalizedRelativePath = path.normalize(relativePath);
518
- if (this.projectLearningsTemplateRegistered &&
519
- normalizedRelativePath === this.projectLearningsFile) {
520
- logger.info(`Kept (host-owned project learnings): ${relativePath}`);
521
- this.counters.skipped++;
522
- return;
523
- }
524
- const targetPath = path.join(this.config.destDir, relativePath);
525
- const resolvedTarget = path.resolve(targetPath);
526
- const resolvedDest = path.resolve(this.config.destDir);
527
- // Explicit guard: disallow deleting the project root itself
528
- if (resolvedTarget === resolvedDest) {
529
- logger.warn(`Skipping deletion of project root directory: ${relativePath || "."}`);
530
- return;
531
- }
532
- // Safety check: only allow paths strictly inside destDir
533
- if (!resolvedTarget.startsWith(resolvedDest + path.sep)) {
534
- logger.warn(`Skipping deletion outside project directory: ${relativePath}`);
535
- return;
536
- }
537
- if (this.ignorePatterns.shouldIgnore(relativePath)) {
538
- logger.info(`Kept ${this.lisaignoreSuffix}: ${relativePath}`);
539
- this.counters.ignored++;
540
- return;
541
- }
542
- if (!(await fse.pathExists(targetPath))) {
543
- return;
544
- }
545
- const referencing = await findLocalWorkflowReferences(this.config.destDir, relativePath);
546
- if (referencing.length > 0) {
547
- logger.warn(`Kept (still called locally by ${referencing.join(", ")}): ${relativePath}`);
548
- this.counters.skipped++;
549
- return;
550
- }
551
- await this.deleteIfOwned(targetPath, relativePath, forcedReason, shipped);
552
- }
553
- /**
554
- * Apply the ownership proof a deletion needs, then delete.
555
- *
556
- * A path the manifest retires only while unmodified is proved by its bytes
557
- * (`mayRetireUnmodified`); every other path keeps the workflow ownership
558
- * gate. A `force` reason outranks both, as it always has.
559
- * @param targetPath - Absolute path to remove
560
- * @param relativePath - Repo-relative path, as the manifest spelled it
561
- * @param forcedReason - Why this removal overrides the ownership gate, when it does
562
- * @param shipped - Digests of every version Lisa shipped, when retired only while unmodified
563
- */
564
- async deleteIfOwned(targetPath, relativePath, forcedReason, shipped) {
565
- const retiring = forcedReason === undefined && shipped !== null;
566
- const allowed = retiring
567
- ? await this.mayRetireUnmodified(targetPath, relativePath, shipped)
568
- : await this.mayDeleteWorkflow(targetPath, relativePath, forcedReason);
569
- if (!allowed)
570
- return;
571
- await this.performDeletion(targetPath, relativePath, retiring ? "an unedited copy of a file Lisa retired" : forcedReason);
572
- }
573
- /**
574
- * Decide whether a path the manifest retires only while unmodified may go.
575
- *
576
- * The proof is the file's own bytes: a copy equal to a version Lisa shipped
577
- * holds nothing of the consumer's, whatever ownership header it carries —
578
- * see `core/retire-unmodified`. That proof stands in for the workflow
579
- * ownership gate, which would otherwise refuse every create-only seed. It
580
- * does not stand in for "nothing calls it", so a path the consumer's own
581
- * scripts or workflows still name is kept too.
582
- *
583
- * Every refusal is recorded as a notice, because a retired file left in
584
- * place is the consumer's to remove and they can only do that if told.
585
- * @param targetPath - Absolute path of the file on disk
586
- * @param relativePath - Repo-relative path the manifest named
587
- * @param shipped - Digests of every version Lisa shipped at this path
588
- * @returns Whether the deletion may proceed
589
- */
590
- async mayRetireUnmodified(targetPath, relativePath, shipped) {
591
- const keep = (reason) => {
592
- const notice = `Kept ${relativePath} — ${reason}`;
593
- this.deps.logger.warn(notice);
594
- this.deletionNotices.push(notice);
595
- this.counters.skipped++;
596
- return false;
597
- };
598
- const proof = await readRegularFile(targetPath);
599
- if (proof === null) {
600
- return keep("Lisa retired this path, but it is not a readable file here, so Lisa cannot prove it is the copy Lisa shipped. Remove it yourself if you no longer use it.");
601
- }
602
- if (!isShippedVersion(proof.bytes, shipped)) {
603
- return keep("Lisa retired this file, but your copy differs from every version Lisa shipped, so it may hold your changes. Delete it yourself once you no longer need it.");
604
- }
605
- const references = await findHostReferences(this.config.destDir, relativePath);
606
- if (references === null) {
607
- return keep("Lisa retired this file, but could not read your package.json or workflows to check that nothing still uses it. Delete it yourself once you have checked.");
608
- }
609
- if (references.length > 0) {
610
- return keep(`Lisa retired this file, but ${references.join(", ")} still names it. Remove that reference, then delete the file.`);
611
- }
612
- // The proof is re-checked last, immediately before removal: a file
613
- // replaced or edited while references were read is not the one proved.
614
- if (!(await stillProved(targetPath, proof))) {
615
- return keep("Lisa retired this file, but it changed while Lisa was checking it, so it was left in place. Re-run lisa apply, or delete it yourself.");
616
- }
617
- return true;
618
- }
619
- /**
620
- * Remove a path every guard has cleared, and say so.
621
- *
622
- * The announcement is not incidental to the removal — under
623
- * CodySwannGT/lisa#3656 it is half the fix, so it is emitted on the same
624
- * statement path that does the deleting and cannot be skipped while the
625
- * removal still happens.
626
- * @param targetPath - Absolute path to remove
627
- * @param relativePath - Repo-relative path, as the manifest spelled it
628
- * @param forcedReason - Why this removal overrode the ownership gate, when it did
629
- */
630
- async performDeletion(targetPath, relativePath, forcedReason) {
631
- const { logger } = this.deps;
632
- const verb = this.config.dryRun ? "Would delete" : "Deleted";
633
- const because = forcedReason === undefined ? "" : ` — ${forcedReason}`;
634
- const notice = `${verb}: ${relativePath}${because}`;
635
- if (this.config.dryRun) {
636
- logger.dry(notice);
637
- }
638
- else {
639
- await fse.remove(targetPath);
640
- logger.success(notice);
641
- }
642
- this.counters.deleted++;
643
- this.deletionNotices.push(notice);
644
- this.deletedPaths.push(relativePath);
645
- }
646
- /**
647
- * Decide whether a `.github/workflows/` deletion target is Lisa's to remove.
648
- *
649
- * A deletions manifest names paths, never bytes, so on its own it cannot tell
650
- * a retired Lisa workflow from an unrelated file a consumer authored at the
651
- * same path. The file's own ownership header can, and every workflow Lisa
652
- * ships carries one — see `core/workflow-deletion-ownership` for why that
653
- * header is the signal and the hash ledger is not.
654
- *
655
- * Unreadable is treated as unattributable rather than as an error: a
656
- * directory, a permissions failure, or bytes that are not text all mean Lisa
657
- * has no proof, and the safe response to no proof is to leave it alone.
658
- *
659
- * A manifest may override the gate per path by giving a reason in its
660
- * `force` map. That exists because two workflow removals already shipped on
661
- * owner rulings against files that were actively harmful (#3590, #3599), and
662
- * those have to reach an edited copy too. The override does not buy silence:
663
- * a forced removal is announced with its reason attached, which is more than
664
- * the unforced path used to manage.
665
- * @param targetPath - Absolute path of the file on disk
666
- * @param relativePath - Repo-relative path the manifest named
667
- * @param forcedReason - Why this removal overrides the gate, when it does
668
- * @returns Whether the deletion may proceed
669
- */
670
- async mayDeleteWorkflow(targetPath, relativePath, forcedReason) {
671
- if (!isWorkflowDeletionPath(relativePath) || forcedReason !== undefined) {
672
- return true;
673
- }
674
- const contents = await this.tryReadFile(targetPath);
675
- const verdict = contents === null
676
- ? { kind: "unattributable" }
677
- : classifyWorkflowForDeletion(contents);
678
- if (verdict.kind === "lisa-managed") {
679
- return true;
680
- }
681
- const notice = `Kept ${relativePath} — ${describeRefusal(verdict)}.`;
682
- this.deps.logger.warn(notice);
683
- this.deletionNotices.push(notice);
684
- this.counters.skipped++;
685
- return false;
686
- }
687
- /**
688
- * Invoke pre-strategy migration hooks so migrations can snapshot project state
689
- * before strategies overwrite or delete managed files.
690
- */
691
- async runMigrationsBeforeStrategies() {
692
- const { logger, migrationRegistry } = this.deps;
693
- const ctx = {
694
- projectDir: this.config.destDir,
695
- lisaDir: this.config.lisaDir,
696
- detectedTypes: this.detectedTypes,
697
- dryRun: this.config.dryRun,
698
- postinstallSafe: isPostinstallSafeApply(this.config),
699
- logger,
700
- };
701
- await migrationRegistry.runBeforeStrategies(ctx);
702
- }
703
- /**
704
- * Run all applicable migrations against the destination project
705
- */
706
- async processMigrations() {
707
- const { logger, migrationRegistry } = this.deps;
708
- const ctx = {
709
- projectDir: this.config.destDir,
710
- lisaDir: this.config.lisaDir,
711
- detectedTypes: this.detectedTypes,
712
- dryRun: this.config.dryRun,
713
- postinstallSafe: isPostinstallSafeApply(this.config),
714
- logger,
715
- };
716
- logger.info("Running migrations...");
717
- const results = await migrationRegistry.runAll(ctx);
718
- this.updateMigrationCounters(results);
719
- }
720
- /**
721
- * Update migration counters from aggregated migration results
722
- * @param results - Migration results to aggregate into counters
723
- */
724
- updateMigrationCounters(results) {
725
- for (const result of results) {
726
- if (result.action === "applied") {
727
- this.counters.migrationsApplied++;
728
- }
729
- else {
730
- this.counters.migrationsSkipped++;
731
- }
732
- }
733
- }
734
- /* v8 ignore start -- calls external CLI, covered by integration tests */
735
- /**
736
- * Register plugins from merged settings.json with Claude Code at project scope
48
+ * Validate destination directory exists and is a directory
737
49
  */
738
- async registerPlugins() {
739
- if (this.config.dryRun ||
740
- !harnessIncludesAgent(this.config.harness, "claude")) {
741
- return;
742
- }
743
- const settingsPath = path.join(this.config.destDir, ".claude", "settings.json");
744
- if (!(await fse.pathExists(settingsPath))) {
745
- return;
746
- }
747
- const settings = await readFile(settingsPath, "utf-8")
748
- .then(content => JSON.parse(content))
749
- .catch(() => null);
750
- if (!settings?.enabledPlugins) {
751
- return;
752
- }
753
- const plugins = Object.entries(settings.enabledPlugins)
754
- .filter(([, enabled]) => enabled === true)
755
- .map(([plugin]) => plugin);
756
- if (plugins.length === 0) {
757
- return;
758
- }
759
- const operationDeadline = Date.now() + PLUGIN_REGISTRATION_TIMEOUT_MS;
760
- const execAsync = async (command, options) => await runPluginCommand(command.split(" ").slice(1), {
761
- cwd: this.config.destDir,
762
- timeoutMs: Math.min(Number(options.timeout), operationDeadline - Date.now()),
763
- ...(typeof options.maxCaptureBytes === "number"
764
- ? { maxCaptureBytes: options.maxCaptureBytes }
765
- : {}),
766
- });
767
- try {
768
- await execAsync("claude --version", { timeout: PLUGIN_PROBE_TIMEOUT_MS });
50
+ async validateDestination() {
51
+ const { destDir } = this.config;
52
+ if (!(await fse.pathExists(destDir))) {
53
+ throw new DestinationNotFoundError(destDir);
769
54
  }
770
- catch (error) {
771
- this.reportPluginProbeFailure(error);
772
- return;
55
+ const stats = await stat(destDir);
56
+ if (!stats.isDirectory()) {
57
+ throw new DestinationNotDirectoryError(destDir);
773
58
  }
774
- await this.installPluginsAndUpdateMarketplace(execAsync, plugins);
775
- // After installs, on its own budget, so a long backlog of dead
776
- // registrations never starves this checkout's own registration (#4645).
777
- const pruneDeadline = Date.now() + PLUGIN_PRUNE_TIMEOUT_MS;
778
- await pruneDeadPluginRegistrations(this.config.destDir, {
779
- runClaude: async (args, cwd) => await runPluginCommand(args, {
780
- cwd,
781
- timeoutMs: Math.min(PLUGIN_PROBE_TIMEOUT_MS, pruneDeadline - Date.now()),
782
- maxCaptureBytes: PLUGIN_LIST_MAX_CAPTURE_BYTES,
783
- }),
784
- deadlineReached: () => Date.now() >= pruneDeadline,
785
- logger: this.deps.logger,
786
- });
787
59
  }
788
60
  /**
789
- * Distinguish a missing optional CLI from a failed or timed-out real probe.
790
- * @param error - Probe failure
61
+ * Check for uncommitted git changes and prompt user if dirty
791
62
  */
792
- reportPluginProbeFailure(error) {
793
- if (error.code === "ENOENT") {
794
- this.deps.logger.info("Claude CLI not found, skipping plugin registration");
63
+ async validateGitState() {
64
+ const { gitService, prompter, logger } = this.deps;
65
+ const { destDir } = this.config;
66
+ // Skip git check if not a git repository
67
+ if (!(await gitService.isRepository(destDir))) {
795
68
  return;
796
69
  }
797
- this.deps.logger.warn(`Claude CLI probe failed; plugin registration will retry (${error instanceof Error ? error.message : PLUGIN_COMMAND_FAILED})`);
798
- }
799
- /**
800
- * Install each plugin and refresh the Lisa marketplace cache.
801
- *
802
- * Version-gated (perf): `claude plugin marketplace update` is a network git
803
- * pull of the Lisa repo and every `claude plugin install` spawns the Claude
804
- * CLI (seconds each); re-running all of it on every apply made a single
805
- * `bun add` cost minutes across the repeated apply passes. A full sync
806
- * (marketplace refresh + install every plugin) still runs whenever the
807
- * installed Lisa version differs from the `.claude/.lisa-plugins-synced`
808
- * marker; between version changes only plugins missing for this project are
809
- * installed, so the self-heal property (a removed plugin comes back on the
810
- * next install) survives at the cost of one `claude plugin list` call.
811
- * @param execAsync - Promisified exec function for running shell commands
812
- * @param enabledPlugins - Plugin identifiers from enabledPlugins (e.g. "lisa@lisa")
813
- */
814
- async installPluginsAndUpdateMarketplace(execAsync, enabledPlugins) {
815
- const { logger } = this.deps;
816
- const validPluginName = /^[\w@./-]+$/;
817
- const plugins = await this.withoutUnavailableLisaPlugins(enabledPlugins);
818
- const { fullSync, toInstall, version, isLinkedWorktree } = await this.computePluginSyncPlan(execAsync, plugins);
819
- if (!fullSync && toInstall.length === 0) {
820
- if (isLinkedWorktree) {
821
- // Record the settled state on the worktree's own marker so repeat
822
- // applies (and health's root-confined marker probe) do not have to
823
- // re-derive it from the primary checkout.
824
- await this.writePluginSyncMarker(version);
825
- }
826
- logger.info(pc.gray(`Plugins already in sync for Lisa ${version}; skipping`));
70
+ // Skip git check when requested (e.g. during postinstall where lockfile is always dirty)
71
+ if (this.config.skipGitCheck) {
827
72
  return;
828
73
  }
829
- logger.info("Registering plugins with Claude Code (project scope)...");
830
- const sync = { succeeded: true };
831
- if (fullSync) {
832
- // Best-effort cache refresh. Individual plugin installs below will still
833
- // report whether the marketplace entry is available.
834
- sync.succeeded = await this.updateLisaMarketplace(execAsync, false);
835
- }
836
- for (const plugin of toInstall) {
837
- if (!validPluginName.test(plugin)) {
838
- logger.warn(`Skipping invalid plugin name: ${plugin}`);
839
- sync.succeeded = false;
840
- continue;
841
- }
842
- const installed = await this.installPlugin(execAsync, plugin);
843
- sync.succeeded = installed && sync.succeeded;
844
- }
845
- // Post-install refresh must run whenever installs happened: installing can
846
- // register the marketplace for the first time, and without a refresh newly
847
- // added skills are not discovered ("Unknown skill" in nightly CI — #320).
848
- const refreshed = await this.updateLisaMarketplace(execAsync, true);
849
- await this.recordPluginSyncOutcome(version, fullSync, sync.succeeded && refreshed);
850
- }
851
- /**
852
- * Drop enabled `<name>@lisa` keys the Lisa marketplace cannot supply, with
853
- * one warning each. A skip never counts against the sync, so a retired key
854
- * such as `typescript@lisa` no longer fails every apply (#4645). An
855
- * unreadable manifest skips nothing.
856
- * @param enabledPlugins - Plugin identifiers from enabledPlugins
857
- * @returns The identifiers worth attempting, in order
858
- */
859
- async withoutUnavailableLisaPlugins(enabledPlugins) {
860
- const { installable, skipped } = partitionByLisaMarketplace(enabledPlugins, await readMarketplaceCatalog(path.join(this.config.lisaDir, ".claude-plugin", "marketplace.json")));
861
- for (const key of skipped) {
862
- this.deps.logger.warn(describeSkippedPluginKey(key));
863
- }
864
- return installable;
865
- }
866
- /**
867
- * Record only a completed sync, keeping failures eligible for a later retry.
868
- * @param version - Current Lisa version
869
- * @param fullSync - Whether a version change required every plugin
870
- * @param completed - Whether all required commands succeeded
871
- */
872
- async recordPluginSyncOutcome(version, fullSync, completed) {
873
- if (!completed) {
874
- await this.invalidatePluginSyncMarker();
875
- this.deps.logger.warn("Plugin registration incomplete; retry on the next apply");
74
+ // Check for uncommitted changes
75
+ if (!(await gitService.isDirty(destDir))) {
876
76
  return;
877
77
  }
878
- if (fullSync) {
879
- // Always the project's OWN marker (destDir): a full sync run from a
880
- // linked worktree only reinstalled plugins for the worktree's
881
- // projectPath, so recording it against the primary checkout would let
882
- // the primary skip the forced reinstall it still needs after a
883
- // version bump.
884
- await this.writePluginSyncMarker(version);
885
- }
886
- }
887
- /** Remove only this project's marker so incomplete incremental syncs retry. */
888
- async invalidatePluginSyncMarker() {
889
- try {
890
- await unlink(this.pluginSyncMarkerPath());
891
- }
892
- catch (error) {
893
- if (error.code === "ENOENT")
894
- return;
895
- const message = error instanceof Error ? error.message : String(error);
896
- this.deps.logger.warn(`Could not invalidate plugin sync marker: ${message}`);
897
- }
898
- }
899
- /**
900
- * Decide whether this apply needs a full plugin sync and which plugins to
901
- * install.
902
- *
903
- * Linked worktrees inherit the primary checkout's sync state: the marker is
904
- * gitignored (it records this machine's `~/.claude` plugin state), so a
905
- * fresh agent worktree is always marker-less and would otherwise pay the
906
- * full sync — marketplace pulls plus a Claude CLI spawn per plugin — on
907
- * every ticket. When the primary checkout is already synced for this Lisa
908
- * version, the worktree has nothing left to do: the marketplace cache is
909
- * machine-global and per-worktree plugin registration is handled by the
910
- * coding agent's own startup (Claude Code auto-installs the committed
911
- * `enabledPlugins` for a new projectPath; Codex uses the project-local
912
- * `.codex-plugin` pointer instead of Claude project-scope registrations).
913
- * The #320 defense (refresh marketplace whenever installs happened) holds:
914
- * the skip path performs no installs.
915
- * @param execAsync - Promisified exec function for running shell commands
916
- * @param plugins - Plugin identifiers from enabledPlugins
917
- * @returns Sync plan: fullSync (version changed), plugins to install, the
918
- * current Lisa version, and whether destDir is a linked worktree
919
- */
920
- async computePluginSyncPlan(execAsync, plugins) {
921
- const version = getPackageVersion();
922
- const primaryRoot = await resolvePrimaryWorktreeRoot(this.config.destDir);
923
- const isLinkedWorktree = primaryRoot !== null;
924
- const readMarker = async (markerPath) => readFile(markerPath, "utf-8")
925
- .then(content => content.trim())
926
- .catch(() => null);
927
- const ownMarker = await readMarker(this.pluginSyncMarkerPath());
928
- const syncedVersion = ownMarker === version || primaryRoot === null
929
- ? ownMarker
930
- : await readMarker(path.join(primaryRoot, ".claude", ".lisa-plugins-synced"));
931
- const fullSync = syncedVersion !== version;
932
- if (isLinkedWorktree && !fullSync) {
933
- // Skip the `claude plugin list` probe too — registration for this
934
- // worktree's projectPath is deferred to the coding agent's startup.
935
- return { fullSync: false, toInstall: [], version, isLinkedWorktree };
936
- }
937
- const installed = fullSync
938
- ? null
939
- : await this.readInstalledPluginIds(execAsync);
940
- const toInstall = installed === null
941
- ? plugins
942
- : plugins.filter(plugin => !installed.has(plugin));
943
- return { fullSync, toInstall, version, isLinkedWorktree };
944
- }
945
- /**
946
- * Refresh the cached Lisa marketplace via the Claude CLI.
947
- * @param execAsync - Promisified exec function for running shell commands
948
- * @param announce - Whether to log the outcome (silent for the pre-install
949
- * best-effort refresh)
950
- * @returns Whether the refresh command succeeded
951
- */
952
- async updateLisaMarketplace(execAsync, announce) {
953
- const { logger } = this.deps;
954
- try {
955
- await execAsync("claude plugin marketplace update lisa", this.pluginExecOptions());
956
- if (announce) {
957
- logger.success("Updated marketplace: lisa");
958
- }
959
- return true;
960
- }
961
- catch (error) {
962
- if (announce) {
963
- logger.warn(`Could not update marketplace: lisa (${error instanceof Error ? error.message : PLUGIN_COMMAND_FAILED})`);
964
- }
965
- return false;
966
- }
967
- }
968
- /**
969
- * Install a single plugin at project scope via the Claude CLI.
970
- * @param execAsync - Promisified exec function for running shell commands
971
- * @param plugin - Plugin identifier (already validated)
972
- * @returns Whether the install command succeeded
973
- */
974
- async installPlugin(execAsync, plugin) {
975
- const { logger } = this.deps;
976
- try {
977
- await execAsync(`claude plugin install ${plugin} --scope project`, this.pluginExecOptions());
978
- logger.success(`Registered plugin: ${plugin}`);
979
- return true;
980
- }
981
- catch (error) {
982
- logger.warn(`Could not register plugin: ${plugin} (${error instanceof Error ? error.message : PLUGIN_COMMAND_FAILED})`);
983
- return false;
984
- }
985
- }
986
- /**
987
- * Exec options shared by all Claude CLI plugin commands.
988
- * @returns Options object with the project cwd and registration budget
989
- */
990
- pluginExecOptions() {
991
- return {
992
- cwd: this.config.destDir,
993
- timeout: PLUGIN_REGISTRATION_TIMEOUT_MS,
994
- };
995
- }
996
- /**
997
- * Absolute path of the plugin sync marker recording the last fully-synced
998
- * Lisa version for this project. Shared with install-claude-plugins.sh.
999
- * @returns Marker path under the project's .claude directory
1000
- */
1001
- pluginSyncMarkerPath() {
1002
- return path.join(this.config.destDir, ".claude", ".lisa-plugins-synced");
1003
- }
1004
- /**
1005
- * Absolute path of the host project's package.json.
1006
- * @returns package.json path under the destination directory
1007
- */
1008
- hostPackageJsonPath() {
1009
- return path.join(this.config.destDir, "package.json");
1010
- }
1011
- /**
1012
- * Read the plugin ids already installed for this project via
1013
- * `claude plugin list --json`.
1014
- * @param execAsync - Promisified exec function for running shell commands
1015
- * @returns Set of installed plugin ids, or null when the list cannot be
1016
- * obtained (older CLI, parse failure) so callers fall back to installing
1017
- * everything — the pre-existing behavior
1018
- */
1019
- async readInstalledPluginIds(execAsync) {
1020
- try {
1021
- const result = (await execAsync("claude plugin list --json", {
1022
- cwd: this.config.destDir,
1023
- timeout: PLUGIN_PROBE_TIMEOUT_MS,
1024
- maxCaptureBytes: PLUGIN_LIST_MAX_CAPTURE_BYTES,
1025
- }));
1026
- const parsed = JSON.parse(String(result.stdout ?? ""));
1027
- if (!Array.isArray(parsed)) {
1028
- return null;
1029
- }
1030
- const destPath = path.resolve(this.config.destDir);
1031
- const ids = parsed
1032
- .filter((entry) => typeof entry.id === "string" &&
1033
- entry.projectPath === destPath)
1034
- .map(entry => entry.id);
1035
- return new Set(ids);
1036
- }
1037
- catch {
1038
- return null;
1039
- }
1040
- }
1041
- /**
1042
- * Record the Lisa version whose plugin set was last fully synced.
1043
- *
1044
- * Writes through `node:fs/promises`. `writeFile` is one of the `graceful-fs`
1045
- * passthroughs Node's ESM loader does not expose on the `fs-extra` namespace,
1046
- * so `fse.writeFile(...)` was `undefined` in the shipped `dist/` and threw a
1047
- * `TypeError` into the catch below (#2487) — the marker was never written, and
1048
- * the version gate it feeds never once took effect.
1049
- *
1050
- * Failure stays non-fatal, but is no longer silent. The catch now reports the
1051
- * real error: a recovery path that says nothing cannot be distinguished from
1052
- * one that never ran, which is precisely how this went unnoticed. The wording
1053
- * matches the sibling best-effort plugin steps above.
1054
- * @param version - Lisa package version to record
1055
- * @returns Promise that resolves when the marker is written (best-effort)
1056
- */
1057
- async writePluginSyncMarker(version) {
1058
- try {
1059
- await fse.ensureDir(path.join(this.config.destDir, ".claude"));
1060
- await writeFile(this.pluginSyncMarkerPath(), `${version}\n`, "utf-8");
1061
- }
1062
- catch (error) {
1063
- // Best-effort: a missing marker only costs a redundant full sync next run.
1064
- const message = error instanceof Error ? error.message : String(error);
1065
- this.deps.logger.warn(`Could not record plugin sync marker: ${message}`);
78
+ const status = await gitService.getStatus(destDir);
79
+ logger.warn("Git working directory has uncommitted changes");
80
+ // Always prompt for dirty git, even in yesMode
81
+ const proceed = await prompter.confirmDirtyGit(status);
82
+ if (!proceed) {
83
+ throw new UserAbortedError("Aborted: please commit or stash your changes before running Lisa");
1066
84
  }
1067
85
  }
1068
- /* v8 ignore stop */
1069
86
  /**
1070
87
  * Finalize operation
1071
88
  * @returns Promise that resolves when finalization is complete
@@ -1076,26 +93,6 @@ export class Lisa {
1076
93
  await backupService.cleanup();
1077
94
  }
1078
95
  }
1079
- /**
1080
- * Install Rails wrappers through their manager after a real apply.
1081
- * Failure is reported without turning a usable agent checkout into a blocked
1082
- * startup; doctor and health independently report its actual installation.
1083
- * @returns Once the bounded installation attempt has settled
1084
- */
1085
- async installRailsGitHooks() {
1086
- if (this.config.dryRun ||
1087
- this.config.validateOnly ||
1088
- !this.detectedTypes.includes("rails"))
1089
- return;
1090
- try {
1091
- const result = await ensureRailsHooks(this.config.destDir);
1092
- if (result.status === "failed" && result.detail)
1093
- this.deps.logger.warn(result.detail);
1094
- }
1095
- catch {
1096
- this.deps.logger.warn(`Rails Git hooks could not be installed; run ${RAILS_HOOK_INSTALL_COMMAND}.`);
1097
- }
1098
- }
1099
96
  /**
1100
97
  * Create success result
1101
98
  * @returns Success result with operation counters and detected types
@@ -1199,1254 +196,12 @@ export class Lisa {
1199
196
  }
1200
197
  }
1201
198
  /**
1202
- * Sync lockfiles to package.json in-process when the postinstall trampoline
1203
- * will not run.
1204
- *
1205
- * The trampoline only fires when Lisa is invoked as a package-manager
1206
- * lifecycle script (postinstall, prepare, etc.). When users invoke Lisa
1207
- * manually after `npm install -D @codyswann/lisa@latest` — the recommended
1208
- * flow on plain-npm projects, where Lisa's postinstall is not auto-run —
1209
- * the trampoline never schedules and any package.json changes Lisa just
1210
- * made (e.g., adding `oxlint-tsgolint` via package.lisa.json merge) leave
1211
- * package-lock.json out of sync. The next `npm ci` in CI then fails with
1212
- * "lockfile out of sync".
1213
- *
1214
- * This method closes that gap by running the same lockfile-regeneration
1215
- * commands the trampoline child would have run, but synchronously in the
1216
- * current process. We skip when the trampoline IS scheduled (it will
1217
- * regenerate on its own after the parent PM exits) and when running as the
1218
- * trampoline child itself (the trampoline has its own regen step at the end).
1219
- * @param prePackageJsonHash - Hash of package.json captured before apply ran (null if file did not exist)
1220
- */
1221
- async reconcileLockfilesInProcess(prePackageJsonHash) {
1222
- if (this.config.dryRun)
1223
- return;
1224
- if (isRunningAsTrampoline())
1225
- return;
1226
- if (shouldSchedulePostinstallReconciliation(this.config.dryRun))
1227
- return;
1228
- const pkgPath = this.hostPackageJsonPath();
1229
- const postHash = hashFile(pkgPath);
1230
- if (prePackageJsonHash === null ||
1231
- postHash === null ||
1232
- prePackageJsonHash === postHash) {
1233
- return;
1234
- }
1235
- this.deps.logger.info(pc.cyan("Syncing lockfiles to match updated package.json..."));
1236
- await regenerateLockfilesInProcess(this.config.destDir);
1237
- }
1238
- /**
1239
- * Emit Codex-targeted artifacts (agents, hooks, settings) when the host
1240
- * project's harness includes Codex (`codex` or `fleet`). No-op for `claude`
1241
- * (default).
1242
- *
1243
- * Lisa writes the complete Codex surface and a filtered repository
1244
- * marketplace into the host. No user-wide plugin activation participates.
1245
- * Ownership is tracked via `.codex/.lisa-managed.json` so updates remove
1246
- * stale stack artifacts without touching host customizations.
1247
- */
1248
- async processCodexEmit() {
1249
- const { harness } = this.config;
1250
- if (!harnessIncludesAgent(harness, "codex")) {
1251
- return;
1252
- }
1253
- if (this.shouldSkipAgentEmitDuringPostinstall()) {
1254
- this.deps.logger.info(pc.gray("Codex emit: skipped during postinstall-safe apply"));
1255
- return;
1256
- }
1257
- if (this.config.dryRun) {
1258
- this.deps.logger.info(pc.gray("Codex emit: skipped (dry-run mode)"));
1259
- return;
1260
- }
1261
- const result = await installCodexProjectOverlay(this.config.lisaDir, this.config.destDir, this.detectedTypes);
1262
- const totalStale = result.staleAgentCount +
1263
- result.staleHookRuleCount +
1264
- result.staleSkillCount;
1265
- this.deps.logger.info(pc.cyan(`Codex emit: ${result.agentCount} agents, ${result.hookCount} repository enforcement fallback plus plugin-bundled hooks, ${result.modelVisibleSkillCount} native skills from ${result.marketplacePluginCount} project plugins, ${result.mcpServerCount} MCP servers, settings ${result.settingsCreated ? "created" : "merged"}${totalStale > 0
1266
- ? ` (${result.staleAgentCount} stale agents, ${result.staleHookRuleCount} stale hook/rule files, ${result.staleSkillCount} stale skills removed)`
1267
- : ""}`));
1268
- }
1269
- /**
1270
- * Emit Claude-Code-targeted artifacts when the harness includes Claude.
1271
- *
1272
- * Claude's primary distribution is the GitHub marketplace; the per-project
1273
- * artifacts Lisa writes are the canonical `AGENTS.md` and a thin `CLAUDE.md`
1274
- * that `@AGENTS.md`-imports it (Claude Code doesn't read AGENTS.md natively).
1275
- * Both are create-only and host-owned from creation onward. Skipped in dry-run
1276
- * mode and on harness modes that don't include Claude.
1277
- */
1278
- async processClaudeEmit() {
1279
- const { harness } = this.config;
1280
- if (!harnessIncludesAgent(harness, "claude")) {
1281
- return;
1282
- }
1283
- if (this.shouldSkipAgentEmitDuringPostinstall()) {
1284
- this.deps.logger.info(pc.gray("Claude emit: skipped during postinstall-safe apply"));
1285
- return;
1286
- }
1287
- if (this.config.dryRun) {
1288
- this.deps.logger.info(pc.gray("Claude emit: skipped (dry-run mode)"));
1289
- return;
1290
- }
1291
- // Ensure the canonical AGENTS.md exists first — it is the import target of
1292
- // the CLAUDE.md pointer.
1293
- const agentsResult = await installAgentsMd(this.config.destDir);
1294
- const result = await installClaudeMd(this.config.destDir);
1295
- this.deps.logger.info(pc.cyan(`Claude emit: AGENTS.md ${agentsResult.created ? "created" : HOST_OWNED_LABEL}, CLAUDE.md ${result.created ? "created (pointer → AGENTS.md)" : HOST_OWNED_LABEL}`));
1296
- }
1297
- /**
1298
- * Emit Antigravity-targeted artifacts when the harness includes agy.
1299
- *
1300
- * Runtime probes of agy 1.0.3 (ticket-1054) established how agy consumes each
1301
- * surface, so each is delivered the way agy actually reads it:
1302
- * 1. `agy plugin install` Lisa's variant from `plugins/lisa-agy/` (when agy
1303
- * is on PATH). This installs the variant into
1304
- * `~/.gemini/config/plugins/<variant>/`.
1305
- * 2. Hooks → PLUGIN-BUNDLED. agy loads a plugin's hooks from a `hooks.json`
1306
- * at the installed plugin ROOT, so the hooks config + agy-protocol script
1307
- * are emitted into the variant at BUILD time by
1308
- * generate-agy-plugin-artifacts.mjs and ride along with the plugin
1309
- * install above — nothing is written here. Only `block-no-verify`
1310
- * (PreToolUse) maps; SessionStart hooks aren't supported by agy.
1311
- * 3. MCP → USER-GLOBAL. agy ignores plugin-bundled MCP and only auto-loads
1312
- * `~/.gemini/config/mcp_config.json`, so `installAgyMcpConfig` writes
1313
- * there (servers collected from the built plugin `.mcp.json` files via
1314
- * `collectLisaMcpServers`, translated to agy's `serverUrl` shape,
1315
- * tagged-merge preserving host entries). Cross-project caveat: the most
1316
- * recent `lisa apply` carrying MCP wins globally.
1317
- * 4. Instruction file → the canonical create-only `AGENTS.md` (the same file
1318
- * every other agent reads), plus a bounded project-learnings bridge
1319
- * reconciled by `processInstructionFilesMigration`. Lisa does not bake
1320
- * eager rule bodies into AGENTS.md: a giant generated file is not worth
1321
- * carrying just to polyfill agy's headless (`-p`) mode, where SessionStart
1322
- * hooks don't fire. In interactive mode it still receives Lisa's plugin
1323
- * (skills/agents/MCP) above.
1324
- */
1325
- async processAgyEmit() {
1326
- const { harness } = this.config;
1327
- if (!harnessIncludesAgent(harness, "agy")) {
1328
- return;
1329
- }
1330
- if (this.shouldSkipAgentEmitDuringPostinstall()) {
1331
- this.deps.logger.info(pc.gray("agy emit: skipped during postinstall-safe apply"));
1332
- return;
1333
- }
1334
- if (this.config.dryRun) {
1335
- this.deps.logger.info(pc.gray("agy emit: skipped (dry-run mode)"));
1336
- return;
1337
- }
1338
- const pluginRoot = path.join(this.config.lisaDir, "plugins");
1339
- // Install the base variant plus the matching variant for each detected
1340
- // stack so agy reaches parity with Claude/Codex on stack-specific plugins.
1341
- const variantNames = [
1342
- "lisa-agy",
1343
- ...this.perAgentStackVariants(pluginRoot, "agy"),
1344
- ];
1345
- const pluginResults = [];
1346
- for (const variant of variantNames) {
1347
- pluginResults.push(await installAgyPlugin(pluginRoot, variant));
1348
- }
1349
- // MCP: agy ignores plugin-bundled MCP AND only auto-loads the USER-GLOBAL
1350
- // config (~/.gemini/config/mcp_config.json) — the project-scope
1351
- // `.agents/mcp_config.json` is never read by the agy CLI (verified-by-run,
1352
- // ticket-1054). So collect Lisa's servers from the built plugin .mcp.json
1353
- // files (base + detected stacks) and install them into the user-scope
1354
- // aggregate (translated to agy's serverUrl shape, tagged-merge preserving
1355
- // host entries). Caveat: this is shared across projects — the most recent
1356
- // `lisa apply` carrying MCP servers wins globally; host-authored entries are
1357
- // preserved by the _lisaManaged tagged-merge. Skip when no stack ships MCP.
1358
- const lisaMcpServers = collectLisaMcpServers(pluginRoot, this.detectedTypes);
1359
- // Always call installAgyMcpConfig — even when lisaMcpServers is empty —
1360
- // so the tagged-merge logic strips any previously-written _lisaManaged
1361
- // entries. Skipping on empty would leave stale managed entries behind
1362
- // from a previous `lisa apply` for a project that had MCP servers.
1363
- const mcpResult = await installAgyMcpConfig(lisaMcpServers, resolveAgyMcpConfigPath({ scope: "user" }));
1364
- const mcpServerCount = mcpResult.lisaEntryCount;
1365
- // Hooks: delivered as a plugin-bundled root hooks.json inside the installed
1366
- // agy variant (emitted at build time by generate-agy-plugin-artifacts.mjs,
1367
- // installed via `agy plugin install` above) — NOT written here at apply time.
1368
- // Instruction file: the canonical, create-only AGENTS.md. The bounded
1369
- // project-learnings bridge is reconciled after all emit paths run.
1370
- const agentsMdResult = await installAgentsMd(this.config.destDir);
1371
- const attempted = pluginResults.some(r => r.attempted);
1372
- const installedCount = pluginResults.filter(r => r.installed).length;
1373
- const pluginMessage = attempted
1374
- ? `${installedCount}/${variantNames.length} variants installed`
1375
- : "skipped (agy not on PATH)";
1376
- // Only mention MCP when servers were actually written.
1377
- const mcpMessage = mcpServerCount > 0
1378
- ? `, ${mcpServerCount} MCP server(s) → ~/.gemini/config/mcp_config.json`
1379
- : "";
1380
- this.deps.logger.info(pc.cyan(`agy emit: ${pluginMessage}, AGENTS.md ${agentsMdResult.created ? "created" : HOST_OWNED_LABEL}${mcpMessage}`));
1381
- }
1382
- /**
1383
- * Wire the official SonarQube MCP into each harness agent via the vendor's
1384
- * `sonar integrate <agent>`.
1385
- *
1386
- * Hard-gated inside {@link installSonarIntegrations}: a no-op unless the project
1387
- * opted in (`verification.sonar.enabled`) AND the `sonar` CLI is on PATH, so it
1388
- * never touches a project that only wants the CI SonarCloud gate. Kiro and
1389
- * Gemini are never wired — they are not Lisa-supported agents. Only the
1390
- * apply-time emit agents with a vendor integrate path are wired here (claude,
1391
- * codex, copilot, antigravity). Cursor (consumed natively, no apply-time emit)
1392
- * and OpenCode (no vendor integrate path) are wired by `/lisa:setup:sonar`.
1393
- */
1394
- async processSonarIntegration() {
1395
- const { harness } = this.config;
1396
- if (this.shouldSkipAgentEmitDuringPostinstall()) {
1397
- this.deps.logger.info(pc.gray("Sonar integrate: skipped during postinstall-safe apply"));
1398
- return;
1399
- }
1400
- if (this.config.dryRun) {
1401
- this.deps.logger.info(pc.gray("Sonar integrate: skipped (dry-run mode)"));
1402
- return;
1403
- }
1404
- // Map Lisa harness emit agents to the vendor's integrate agent names.
1405
- const candidates = [
1406
- [harnessIncludesAgent(harness, "claude"), "claude"],
1407
- [harnessIncludesAgent(harness, "codex"), "codex"],
1408
- [harnessIncludesAgent(harness, "copilot"), "copilot"],
1409
- [harnessIncludesAgent(harness, "agy"), "antigravity"],
1410
- ];
1411
- const vendorAgents = candidates
1412
- .filter(([included]) => included)
1413
- .map(([, name]) => name);
1414
- const result = await installSonarIntegrations(this.config.destDir, vendorAgents);
1415
- if (!result.enabled) {
1416
- return;
1417
- }
1418
- const failure = result.failed.length > 0 ? ` (failed: ${result.failed.join(", ")})` : "";
1419
- const message = result.attempted
1420
- ? `${result.integrated.length}/${vendorAgents.length} agent(s) wired${failure}`
1421
- : "skipped (sonar CLI not on PATH)";
1422
- this.deps.logger.info(pc.cyan(`Sonar integrate: ${message}`));
1423
- }
1424
- /**
1425
- * Per-agent stack variant directory names for the detected project types
1426
- * that have a built variant. Filters by on-disk existence so a detected type
1427
- * without a stack plugin (e.g. `npm-package`) is naturally skipped.
1428
- * @param pluginRoot - Absolute path to the `plugins/` directory.
1429
- * @param agent - Per-agent variant suffix (`agy` | `copilot` | `cursor`).
1430
- * @returns Variant directory names like `lisa-typescript-agy`.
1431
- */
1432
- perAgentStackVariants(pluginRoot, agent) {
1433
- return this.detectedTypes
1434
- .map(type => `lisa-${type}-${agent}`)
1435
- .filter(name => existsSync(path.join(pluginRoot, name)));
1436
- }
1437
- /**
1438
- * Emit GitHub-Copilot-targeted artifacts when the harness includes copilot.
1439
- *
1440
- * Three per-project actions:
1441
- * 1. `copilot plugin install lisa@CodySwannGT/lisa` (with local-path
1442
- * fallback when the marketplace path fails — currently does, pending
1443
- * the marketplace.json pluginRoot fix gated on Wave 2 spec step 8).
1444
- * 2. Ensure the canonical `AGENTS.md` exists (Copilot reads it natively).
1445
- * 3. Create-only write of `.github/copilot-instructions.md`.
1446
- */
1447
- async processCopilotEmit() {
1448
- const { harness } = this.config;
1449
- if (!harnessIncludesAgent(harness, "copilot")) {
1450
- return;
1451
- }
1452
- if (this.shouldSkipAgentEmitDuringPostinstall()) {
1453
- this.deps.logger.info(pc.gray("Copilot emit: skipped during postinstall-safe apply"));
1454
- return;
1455
- }
1456
- if (this.config.dryRun) {
1457
- this.deps.logger.info(pc.gray("Copilot emit: skipped (dry-run mode)"));
1458
- return;
1459
- }
1460
- const pluginRoot = path.join(this.config.lisaDir, "plugins");
1461
- // Base variant plus the matching variant for each detected stack.
1462
- const variantNames = [
1463
- "lisa-copilot",
1464
- ...this.perAgentStackVariants(pluginRoot, "copilot"),
1465
- ];
1466
- const pluginResults = [];
1467
- for (const variant of variantNames) {
1468
- pluginResults.push(await installCopilotPlugin(pluginRoot, variant));
1469
- }
1470
- // Copilot reads AGENTS.md natively at session start, so ensure the
1471
- // canonical file exists; copilot-instructions.md stays a thin host-owned
1472
- // file that points at it.
1473
- const copilotAgentsResult = await installAgentsMd(this.config.destDir);
1474
- const instructionsResult = await installCopilotInstructions(this.config.destDir);
1475
- const attempted = pluginResults.some(r => r.attempted);
1476
- const installedCount = pluginResults.filter(r => r.installed).length;
1477
- const via = pluginResults.find(r => r.installed)?.via ?? "local";
1478
- const pluginMessage = attempted
1479
- ? `${installedCount}/${variantNames.length} variants installed via ${via}`
1480
- : "skipped (copilot not on PATH)";
1481
- this.deps.logger.info(pc.cyan(`Copilot emit: ${pluginMessage}, AGENTS.md ${copilotAgentsResult.created ? "created" : HOST_OWNED_LABEL}, copilot-instructions ${instructionsResult.created ? "created" : HOST_OWNED_LABEL}`));
1482
- }
1483
- /**
1484
- * Emit Devin-CLI-targeted artifacts when the harness includes devin.
1485
- *
1486
- * Three per-project actions (CodySwannGT/lisa#4427):
1487
- * 1. `devin plugins install --local -y` Lisa's `lisa-devin` variant plus the
1488
- * matching stack variants, when `devin` is on PATH.
1489
- * 2. Reconcile `.devin/hooks.v1.json` with the repository enforcement
1490
- * fallback, which keeps the guards firing when the plugin is missing,
1491
- * disabled, or untrusted — and which is written whether or not `devin`
1492
- * is on this machine, because the clone travels to machines that have it.
1493
- * 3. Ensure the canonical `AGENTS.md` exists (Devin reads it natively).
1494
- *
1495
- * Documented gaps: Devin CLI has no native scheduler, so Lisa's recurring
1496
- * loops are triggered manually or through `scheduler: "github-actions"`; and
1497
- * Sonar has no Devin integrate path, so `processSonarIntegration` skips it.
1498
- */
1499
- async processDevinEmit() {
1500
- const { harness } = this.config;
1501
- if (!harnessIncludesAgent(harness, "devin")) {
1502
- return;
1503
- }
1504
- if (this.shouldSkipAgentEmitDuringPostinstall()) {
1505
- this.deps.logger.info(pc.gray("Devin emit: skipped during postinstall-safe apply"));
1506
- return;
1507
- }
1508
- if (this.config.dryRun) {
1509
- this.deps.logger.info(pc.gray("Devin emit: skipped (dry-run mode)"));
1510
- return;
1511
- }
1512
- const pluginRoot = path.join(this.config.lisaDir, "plugins");
1513
- const variantNames = [
1514
- "lisa-devin",
1515
- ...this.perAgentStackVariants(pluginRoot, "devin"),
1516
- ];
1517
- const detection = await detectDevin();
1518
- const devinOnPath = detection.available;
1519
- if (detection.error !== undefined) {
1520
- this.deps.logger.warn(`Devin emit: devin is on PATH but \`devin --version\` failed, so no plugins were installed: ${detection.error}`);
1521
- }
1522
- const pluginResults = [];
1523
- if (devinOnPath) {
1524
- for (const variant of variantNames) {
1525
- pluginResults.push(await installDevinPlugin(pluginRoot, variant));
1526
- }
1527
- }
1528
- const fallback = await installDevinEnforcementFallback(this.config.destDir);
1529
- const agentsResult = await installAgentsMd(this.config.destDir);
1530
- const installedCount = pluginResults.filter(r => r.installed).length;
1531
- const pluginMessage = devinOnPath
1532
- ? `${installedCount}/${variantNames.length} plugins installed`
1533
- : "plugins skipped (devin not on PATH)";
1534
- this.deps.logger.info(pc.cyan(`Devin emit: ${pluginMessage}, ${fallback.managedFiles.join(", ")} enforcement fallback reconciled, AGENTS.md ${agentsResult.created ? "created" : HOST_OWNED_LABEL}`));
1535
- for (const failure of pluginResults.filter(r => !r.installed)) {
1536
- this.deps.logger.warn(`Devin plugin install failed for ${failure.source ?? "unknown"}: ${failure.error ?? "unknown error"}`);
1537
- }
1538
- }
1539
- /**
1540
- * Install the four manifest-tracked OpenCode artifact sets and persist the
1541
- * ownership manifest.
1542
- *
1543
- * All three vendoring installers (skills, agents, commands) are gated on
1544
- * `detectedTypes`, matching the hooks installer below and the Codex overlay.
1545
- * OpenCode is the surface where Lisa copies its catalogue verbatim into the
1546
- * host repo, so an ungated emit would put Expo/React skills and Phaser
1547
- * game-design agents in front of a model working an unrelated stack (#3437).
1548
- *
1549
- * Each installer scopes its own stale cleanup to its `lisa-` namespace, so
1550
- * handing the full previous manifest to all four is safe.
1551
- * @returns The four install results, for logging and stale accounting.
1552
- */
1553
- async installOpencodeManagedArtifacts() {
1554
- const { lisaDir, destDir } = this.config;
1555
- const previous = await readOpencodeManifest(destDir);
1556
- const skillsResult = await installOpencodeSkills(lisaDir, destDir, previous.files, this.detectedTypes);
1557
- // Hooks: block-no-verify maps to opencode.json `permission.bash`; the
1558
- // runtime-behavior hooks ship as `.opencode/plugin/lisa-*.ts` modules.
1559
- const hooksResult = await installOpencodeHooks(lisaDir, destDir, this.detectedTypes, previous.files);
1560
- // OpenCode reads agents (`.opencode/agents/`) and commands
1561
- // (`.opencode/commands/`) natively. Emit both from Lisa's plugin sources.
1562
- const opencodeAgentsResult = await installOpencodeAgents(lisaDir, destDir, previous.files, this.detectedTypes);
1563
- const commandsResult = await installOpencodeCommands(lisaDir, destDir, previous.files, this.detectedTypes);
1564
- await writeOpencodeManifest(destDir, [
1565
- ...skillsResult.managedFiles,
1566
- ...hooksResult.managedFiles,
1567
- ...opencodeAgentsResult.managedFiles,
1568
- ...commandsResult.managedFiles,
1569
- ]);
1570
- return {
1571
- skillsResult,
1572
- hooksResult,
1573
- opencodeAgentsResult,
1574
- commandsResult,
1575
- };
1576
- }
1577
- /**
1578
- * Emit OpenCode-targeted artifacts when the harness includes OpenCode.
1579
- *
1580
- * OpenCode reads the open Agent Skills format, native agents
1581
- * (`.opencode/agents/`), native commands (`.opencode/commands/`), and
1582
- * `AGENTS.md` natively (opencode.ai/docs/skills, /docs/agents, /docs/commands,
1583
- * /docs/rules), so Lisa needs no transformed plugin variant. It writes:
1584
- * - skills (bundled + command-derived) into `.opencode/skills/lisa/`,
1585
- * - agents (Markdown, `lisa-` prefixed) into `.opencode/agents/`,
1586
- * - commands (Markdown, `lisa-` prefixed) into `.opencode/commands/`,
1587
- * and ensures the canonical `AGENTS.md` exists. Ownership of skills/agents/
1588
- * commands is tracked via `.opencode/.lisa-managed.json` so updates clean up
1589
- * stale artifacts without touching host customizations. Skipped in dry-run
1590
- * mode and on harness modes that don't include OpenCode.
1591
- */
1592
- async processOpencodeEmit() {
1593
- const { harness } = this.config;
1594
- if (!harnessIncludesAgent(harness, "opencode")) {
1595
- return;
1596
- }
1597
- if (this.shouldSkipAgentEmitDuringPostinstall()) {
1598
- this.deps.logger.info(pc.gray("OpenCode emit: skipped during postinstall-safe apply"));
1599
- return;
1600
- }
1601
- if (this.config.dryRun) {
1602
- this.deps.logger.info(pc.gray("OpenCode emit: skipped (dry-run mode)"));
1603
- return;
1604
- }
1605
- const { skillsResult, hooksResult, opencodeAgentsResult, commandsResult } = await this.installOpencodeManagedArtifacts();
1606
- // OpenCode reads AGENTS.md natively; ensure the canonical file exists. It is
1607
- // create-only and host-owned afterward, so it's not tracked in the manifest.
1608
- const agentsMdResult = await installAgentsMd(this.config.destDir);
1609
- // Config-level delivery (host-preserving merges into the project
1610
- // `opencode.json`, NOT tracked in the manifest — deleting a merged host file
1611
- // would be data loss). The hooks installer above already merged the
1612
- // `permission.bash` deny rules; settings + MCP merge their own keys and
1613
- // preserve everything else, so the three writers compose into one file.
1614
- // 1. Settings: force `share: "disabled"` so applying the fleet config can
1615
- // never publish a host's sessions via OpenCode's default-on, public
1616
- // share URLs. Other host keys are preserved.
1617
- // 2. MCP wrap: OpenCode ignores plugin-bundled MCP, so collect Lisa's
1618
- // servers from the built plugin `.mcp.json` files (base + detected
1619
- // stacks) and write them into the `mcp` key, translated to OpenCode's
1620
- // `type:"local"|"remote"` shape. Called unconditionally so stale
1621
- // `_lisaManaged` entries are stripped when a project drops MCP.
1622
- await installOpencodeSettings(this.config.destDir);
1623
- const pluginRoot = path.join(this.config.lisaDir, "plugins");
1624
- const lisaMcpServers = collectLisaMcpServers(pluginRoot, this.detectedTypes);
1625
- const mcpResult = await installOpencodeMcpConfig(lisaMcpServers, resolveOpencodeConfigPath(this.config.destDir));
1626
- const mcpMessage = mcpResult.lisaEntryCount > 0
1627
- ? `, ${mcpResult.lisaEntryCount} MCP server(s)`
1628
- : "";
1629
- const staleCount = skillsResult.deleted.length +
1630
- hooksResult.deleted.length +
1631
- opencodeAgentsResult.deleted.length +
1632
- commandsResult.deleted.length;
1633
- // The hooks installer is the first writer, so its `configCreated` flag
1634
- // reflects whether `opencode.json` existed before this emit.
1635
- this.deps.logger.info(pc.cyan(`OpenCode emit: ${skillsResult.installed.length} skills, ${hooksResult.pluginCount} plugin hooks, ${opencodeAgentsResult.installed.length} agents, ${commandsResult.installed.length} commands${staleCount > 0 ? ` (${staleCount} stale removed)` : ""}, AGENTS.md ${agentsMdResult.created ? "created" : HOST_OWNED_LABEL}, opencode.json ${hooksResult.configCreated ? "created" : "merged"}${mcpMessage}`));
1636
- }
1637
- /**
1638
- * Relocate a legacy `.claude/rules/PROJECT_LEARNINGS.md` ledger to the new
1639
- * cold `.lisa/PROJECT_LEARNINGS.md` BEFORE the create-only strategy would
1640
- * seed an empty ledger at the new path — otherwise both would exist and the
1641
- * real entries would be stranded at the legacy location.
1642
- *
1643
- * Runs even on the postinstall/bootstrap skip path: that guard exists to
1644
- * suppress agent-surface EMISSIONS, but moving machine-managed state under
1645
- * `.lisa/` is not an agent emission and is safe headless. Skipping it there
1646
- * was the exact defect that stranded populated legacy ledgers on the fleet
1647
- * upgrade path (create-only still seeds an empty `.lisa/` ledger, so every
1648
- * later run then hits the both-exist no-clobber warning). Only dry-run is
1649
- * exempt. Idempotent; logs one line on a move and one warning when both exist.
1650
- */
1651
- async processLearningsRelocation() {
1652
- if (this.config.dryRun) {
1653
- return;
1654
- }
1655
- const result = await relocateProjectLearningsLedger(this.config.destDir);
1656
- if (result.action !== undefined) {
1657
- this.deps.logger.info(pc.cyan(`Learnings ledger: ${result.action}`));
1658
- }
1659
- if (result.warning !== undefined) {
1660
- this.deps.logger.warn(`Learnings ledger: ${result.warning}`);
1661
- }
1662
- }
1663
- /**
1664
- * Reconcile the project's agent instruction files onto Lisa's canonical
1665
- * pattern after the per-harness emits run.
1666
- *
1667
- * The per-agent emits write `AGENTS.md` / `CLAUDE.md` create-only, so they
1668
- * can't repair files that already exist from older Lisa versions. This step
1669
- * runs the same non-destructive migration `lisa doctor` uses — stripping the
1670
- * legacy agy baked-rules block from an existing `AGENTS.md` and adding the
1671
- * `@AGENTS.md` import to an existing `CLAUDE.md`. Without it, updating an
1672
- * existing project would create a canonical `AGENTS.md` that its stale
1673
- * `CLAUDE.md` never imports.
1674
- *
1675
- * Harness-aware: a `CLAUDE.md` pointer is only *created* when the harness
1676
- * includes Claude, so a codex/cursor/copilot/agy-only project never gets a
1677
- * stray `CLAUDE.md`. An existing host-authored `CLAUDE.md` still gets the
1678
- * import regardless. Skipped in dry-run mode.
1679
- */
1680
- async processInstructionFilesMigration() {
1681
- if (this.config.dryRun) {
1682
- return;
1683
- }
1684
- if (this.shouldSkipAgentEmitDuringPostinstall()) {
1685
- return;
1686
- }
1687
- const result = await migrateInstructionFiles(this.config.destDir, {
1688
- createClaudePointer: harnessIncludesAgent(this.config.harness, "claude"),
1689
- // apply already relocated the ledger in processLearningsRelocation (an
1690
- // earlier phase); skip it here so a both-exist conflict warns only once.
1691
- relocateLearnings: false,
1692
- });
1693
- if (result.changed) {
1694
- this.deps.logger.info(pc.cyan(`Instruction files: ${result.actions.join("; ")}`));
1695
- }
1696
- }
1697
- /**
1698
- * Repoint `sonar integrate`-generated hook shims at Lisa's Sonar wrapper.
1699
- *
1700
- * CodySwannGT/lisa#4502. The vendor shim calls `sonar hook <event>` directly,
1701
- * so an unauthenticated CLI blocks every prompt; the wrapper Lisa ships
1702
- * resolves `SONARQUBE_CLI_TOKEN` and degrades that case to a warning. Only
1703
- * shims at documented locations whose body is recognisably the vendor's are
1704
- * rewritten, and only when the wrapper is present; comment-only edits to such
1705
- * a shim are not preserved. Deliberately NOT gated on
1706
- * `verification.sonar.enabled` or the CLI being on PATH: a shim committed
1707
- * earlier still runs whenever a developer has the CLI installed.
1708
- *
1709
- * Skipped in dry-run mode, and for postinstall-safe and self-apply runs —
1710
- * consistent with `processSonarIntegration`, which those runs also skip, so
1711
- * agent surfaces are only touched by a full apply; the next full apply
1712
- * repoints. A shim that cannot be rewritten, or that calls `sonar hook` in a
1713
- * shape Lisa does not recognise, is reported as a warning and the apply
1714
- * continues. Each shim is backed up before it is replaced, so a failure in
1715
- * a later apply step restores it along with everything else.
1716
- */
1717
- async processSonarShimRepoint() {
1718
- if (this.config.dryRun) {
1719
- return;
1720
- }
1721
- if (this.shouldSkipAgentEmitDuringPostinstall()) {
1722
- return;
1723
- }
1724
- const { backupService, logger } = this.deps;
1725
- // Back each shim up before it is replaced, so a later apply step failing
1726
- // rolls it back together with the wrapper it now points at.
1727
- const result = await repointSonarShims(this.config.destDir, {
1728
- beforeWrite: absolute => backupService.backup(absolute),
1729
- });
1730
- if (result.repointed.length > 0) {
1731
- logger.info(pc.cyan(`Sonar shims: repointed ${result.repointed.length} at the Lisa wrapper (${result.repointed.join(", ")})`));
1732
- }
1733
- for (const failed of result.failed) {
1734
- logger.warn(`Sonar shim ${failed} could not be repointed at the Lisa wrapper (not readable or writable, or reached through a symlinked folder outside the project); patch it by hand per lisa-setup-sonar §4a.`);
1735
- }
1736
- for (const stray of result.unrecognized) {
1737
- logger.warn(`Sonar shim ${stray} calls \`sonar hook\` in a form Lisa does not recognise, so it was left untouched; patch it by hand per lisa-setup-sonar §4a.`);
1738
- }
1739
- }
1740
- /**
1741
- * Schedule a reconciliation re-run when Lisa is invoked as a package-manager
1742
- * lifecycle script. Works around the fact that `bun add` (and similar
1743
- * package-manager mutations) cache package.json in memory at the start of
1744
- * the command and rewrite it at the end, clobbering any changes made by
1745
- * postinstall scripts.
1746
- *
1747
- * The trampoline is always fully detached so the package manager can exit
1748
- * normally; the child then detects the exit and re-runs Lisa. See
1749
- * utils/postinstall-trampoline.ts for details.
1750
- *
1751
- * Skipped when this apply did not mutate package.json: the trampoline exists
1752
- * solely to redo package.json changes that the parent package manager's
1753
- * end-of-command rewrite clobbers (#383). With no mutation there is nothing
1754
- * to clobber — the rewrite restores identical content — and scheduling a
1755
- * detached re-apply (plus its lockfile regen) is pure waste. File-based
1756
- * template writes are not clobbered and need no reconciliation.
1757
- * @param prePackageJsonHash - Hash of package.json captured before apply mutated anything (null if the file did not exist)
1758
- * @returns Promise that resolves immediately after the detached child is spawned
1759
- */
1760
- async schedulePostinstallReconciliation(prePackageJsonHash) {
1761
- const postHash = hashFile(this.hostPackageJsonPath());
1762
- if (prePackageJsonHash === postHash) {
1763
- this.deps.logger.info(pc.gray("Postinstall reconciliation skipped: package.json unchanged by this apply"));
1764
- return;
1765
- }
1766
- if (!shouldSchedulePostinstallReconciliation(this.config.dryRun)) {
1767
- return;
1768
- }
1769
- const lisaVersion = getPackageVersion();
1770
- // Written BEFORE the spawn on purpose: a spawn that never produces a child
1771
- // otherwise leaves nothing on disk at all, which is one of the two failure
1772
- // modes #2750 could not tell apart from success.
1773
- await recordReconciliationScheduled(this.config.destDir, lisaVersion);
1774
- try {
1775
- const lisaDistDir = getLisaDistDir(import.meta.url);
1776
- await scheduleReconciliationChild(this.config.destDir, lisaDistDir, process.ppid, {
1777
- reportPath: resolveReconciliationReportPath(this.config.destDir),
1778
- reportSchemaVersion: RECONCILIATION_REPORT_SCHEMA_VERSION,
1779
- lisaVersion,
1780
- // The content the package manager resolved its lockfile from. The
1781
- // child compares against THIS rather than against its own re-apply.
1782
- baselinePackageJsonHash: prePackageJsonHash,
1783
- });
1784
- }
1785
- catch (error) {
1786
- const message = error instanceof Error ? error.message : String(error);
1787
- await recordReconciliationSpawnFailure(this.config.destDir, lisaVersion, message);
1788
- this.deps.logger.warn(`Could not schedule postinstall reconciliation: ${message}`);
1789
- }
1790
- }
1791
- /**
1792
- * Validate compatibility without applying changes
1793
- * @returns Result of the validate operation
199
+ * Validate compatibility without applying changes
200
+ * @returns Result of the validate operation
1794
201
  */
1795
202
  async validate() {
1796
203
  // Validate mode is essentially a dry run
1797
204
  return this.apply();
1798
205
  }
1799
- /**
1800
- * Process all files for a given project type
1801
- * @param type Project type to process
1802
- */
1803
- async processProjectType(type) {
1804
- const { logger, strategyRegistry } = this.deps;
1805
- for (const strategy of COPY_STRATEGIES) {
1806
- // Self-apply (Lisa source repo) applies ONLY dependency governance via the
1807
- // package-lisa strategy — every other strategy would overwrite Lisa's own
1808
- // hand-authored source with the templates it ships.
1809
- if (this.selfApply && strategy !== "package-lisa") {
1810
- continue;
1811
- }
1812
- const srcDir = path.join(this.config.lisaDir, type, strategy);
1813
- if (await fse.pathExists(srcDir)) {
1814
- logger.info(`Processing ${type}/${strategy}...`);
1815
- await this.processDirectory(srcDir, strategyRegistry.get(strategy), type);
1816
- }
1817
- }
1818
- }
1819
- /**
1820
- * Process all files in a directory with the given strategy
1821
- * @param srcDir Source directory
1822
- * @param strategy Strategy to apply
1823
- * @param strategy.name Strategy name
1824
- * @param strategy.apply Apply function
1825
- * @param currentType Project type (e.g. "all", "typescript", "cdk") supplying these files
1826
- */
1827
- async processDirectory(srcDir, strategy, currentType) {
1828
- const allFiles = await listFilesRecursive(srcDir);
1829
- const files = allFiles
1830
- .map(srcFile => {
1831
- const sourceRelativePath = path.relative(srcDir, srcFile);
1832
- return {
1833
- srcFile,
1834
- relativePath: this.resolveTemplateDestination(sourceRelativePath, strategy.name, currentType),
1835
- };
1836
- })
1837
- .filter(({ relativePath }) => this.shouldProcessFile(relativePath, strategy.name, currentType));
1838
- const context = {
1839
- config: this.config,
1840
- // Installation's internal --yes is not an operator's consent. Resolve
1841
- // the declared safe-install mode separately from the git waiver, then
1842
- // carry that and the actual prompter's availability to strategies.
1843
- unattended: isPostinstallSafeApply(this.config) || this.deps.prompter.unattended,
1844
- backupFile: async (absolutePath) => {
1845
- await this.deps.backupService.backup(absolutePath);
1846
- await this.deps.backupService.persistentBackup(absolutePath);
1847
- },
1848
- forgetCreated: absolutePath => {
1849
- this.deps.backupService.forgetCreated(absolutePath);
1850
- },
1851
- promptOverwrite: async (relativePath, sourcePath, destPath) => {
1852
- return this.handleOverwritePrompt(relativePath, sourcePath, destPath);
1853
- },
1854
- };
1855
- for (const { srcFile, relativePath } of files) {
1856
- const destFile = path.join(this.config.destDir, relativePath);
1857
- const result = await strategy.apply(srcFile, destFile, relativePath, context);
1858
- this.updateCounters(result);
1859
- this.logResult(result);
1860
- }
1861
- }
1862
- /**
1863
- * Map the stable canonical learnings source to the project's configured
1864
- * sibling path. No other template source is redirected.
1865
- * @param sourceRelativePath - Path relative to the strategy source directory
1866
- * @param strategyName - Strategy delivering the source file
1867
- * @param currentType - Project type that owns the source directory
1868
- * @returns Destination path relative to the host project
1869
- */
1870
- resolveTemplateDestination(sourceRelativePath, strategyName, currentType) {
1871
- if (currentType === "all" &&
1872
- strategyName === CREATE_ONLY_STRATEGY &&
1873
- sourceRelativePath === PROJECT_LEARNINGS_TEMPLATE_PATH) {
1874
- return this.projectLearningsFile;
1875
- }
1876
- if (strategyName === COPY_CONTENTS_STRATEGY &&
1877
- path.basename(sourceRelativePath) === "gitignore") {
1878
- return path.join(path.dirname(sourceRelativePath), ".gitignore");
1879
- }
1880
- return sourceRelativePath;
1881
- }
1882
- /**
1883
- * Decide whether a candidate source file should be passed to its strategy.
1884
- * Centralizes three independent skip rules that all need to short-circuit
1885
- * before a strategy ever sees the file:
1886
- *
1887
- * 1. `.lisaignore` patterns from the destination project
1888
- * 2. Pending deletions from any detected type's `deletions.json`
1889
- * (avoids the create-then-delete ENOENT race)
1890
- * 3. Create-only ownership conflicts (parent stack ships a path that a
1891
- * child stack also ships under create-only — child wins)
1892
- * 4. Cross-strategy ownership conflicts (a child stack ships a create-only
1893
- * path that a parent stack ships under copy-overwrite — child wins before
1894
- * the parent can overwrite a host-owned or soon-to-be-created child file)
1895
- * 5. Copy-overwrite ownership conflicts (parent and child both ship a path
1896
- * under copy-overwrite — only the most-specific stack writes it, so there
1897
- * is no parent-then-child overwrite window; see copyOverwriteOwnership)
1898
- * @param relativePath - Path relative to the strategy's source directory
1899
- * @param strategyName - Name of the strategy that would apply the file
1900
- * @param currentType - Project type currently being processed
1901
- * @returns True if the strategy should apply the file, false to skip
1902
- */
1903
- shouldProcessFile(relativePath, strategyName, currentType) {
1904
- const decision = decideTemplateOwnership({
1905
- relativePath,
1906
- strategy: strategyName,
1907
- currentType,
1908
- orderedTypes: ["all", ...this.detectedTypes],
1909
- ignored: this.ignorePatterns.shouldIgnore(relativePath),
1910
- pendingDeletion: this.pendingDeletions.has(relativePath),
1911
- projectLearningsPath: this.projectLearningsTemplateRegistered
1912
- ? this.projectLearningsFile
1913
- : undefined,
1914
- suppressLearningsSeed: this.suppressLearningsSeedForRelocation,
1915
- createOnlyOwner: this.createOnlyOwnership.get(relativePath),
1916
- copyOverwriteOwner: this.copyOverwriteOwnership.get(relativePath),
1917
- });
1918
- if (decision.process)
1919
- return true;
1920
- if (decision.reason === "ignored") {
1921
- this.counters.ignored++;
1922
- this.logSkip("ignored", relativePath, "Ignored");
1923
- return false;
1924
- }
1925
- this.counters.skipped++;
1926
- const reason = templateSkipDescription(decision);
1927
- this.logSkip(reason, relativePath, `Skipped (${reason})`);
1928
- return false;
1929
- }
1930
- /**
1931
- * Emit a "would skip"/"skipped" log line in a single place so all the skip
1932
- * branches in `shouldProcessFile` stay symmetric.
1933
- * @param dryReason - Reason text for dry-run mode
1934
- * @param relativePath - Path being skipped
1935
- * @param applyMessage - Message to log when not in dry-run mode
1936
- */
1937
- logSkip(dryReason, relativePath, applyMessage) {
1938
- const { logger } = this.deps;
1939
- if (this.config.dryRun) {
1940
- logger.dry(`Would skip (${dryReason}): ${relativePath}`);
1941
- }
1942
- else {
1943
- logger.info(`${applyMessage}: ${relativePath}`);
1944
- }
1945
- }
1946
- /**
1947
- * Handle overwrite prompt for conflicting files
1948
- * @param relativePath Relative path of the file
1949
- * @param sourcePath Source file path
1950
- * @param destPath Destination file path
1951
- * @returns True if user approves overwrite
1952
- */
1953
- async handleOverwritePrompt(relativePath, sourcePath, destPath) {
1954
- const { logger, prompter } = this.deps;
1955
- const decision = await prompter.promptOverwrite(relativePath);
1956
- if (decision === "diff") {
1957
- // Show diff and re-prompt
1958
- await this.showDiff(sourcePath, destPath);
1959
- return this.handleOverwritePrompt(relativePath, sourcePath, destPath);
1960
- }
1961
- if (decision === "yes") {
1962
- logger.info(`Auto-accepting overwrite (non-interactive): ${relativePath}`);
1963
- return true;
1964
- }
1965
- return false;
1966
- }
1967
- /**
1968
- * Show diff between two files
1969
- * @param sourcePath Source file path
1970
- * @param destPath Destination file path
1971
- */
1972
- async showDiff(sourcePath, destPath) {
1973
- const { spawn } = await import("node:child_process");
1974
- return new Promise(resolve => {
1975
- console.log("--- Differences ---");
1976
- const diff = spawn("diff", [destPath, sourcePath], { stdio: "inherit" });
1977
- diff.on("close", () => {
1978
- console.log("-------------------");
1979
- resolve();
1980
- });
1981
- });
1982
- }
1983
- /**
1984
- * Update counters based on operation result
1985
- * @param result Operation result to count
1986
- */
1987
- updateCounters(result) {
1988
- switch (result.action) {
1989
- case "copied":
1990
- case "created":
1991
- this.counters.copied++;
1992
- break;
1993
- case "skipped":
1994
- this.counters.skipped++;
1995
- break;
1996
- case "stale":
1997
- this.counters.stale++;
1998
- this.stalePaths.push(result.relativePath);
1999
- break;
2000
- case "host-ahead":
2001
- this.counters.hostAhead++;
2002
- this.hostAheadNotes.push(result.note ?? `${result.relativePath}: kept your copy.`);
2003
- break;
2004
- case "shadowed":
2005
- this.counters.shadowed++;
2006
- this.shadowedNotes.push(result.note ??
2007
- `${result.relativePath}: not written — it would outrank your own config.`);
2008
- break;
2009
- case "overwritten":
2010
- this.counters.overwritten++;
2011
- break;
2012
- case "appended":
2013
- this.counters.appended++;
2014
- break;
2015
- case "merged":
2016
- this.counters.merged++;
2017
- break;
2018
- }
2019
- }
2020
- /**
2021
- * Log a message using appropriate logger method
2022
- * @param dryMsg Message for dry run mode
2023
- * @param successMsg Message for success mode
2024
- */
2025
- logMessage(dryMsg, successMsg) {
2026
- const { logger } = this.deps;
2027
- this.config.dryRun ? logger.dry(dryMsg) : logger.success(successMsg);
2028
- }
2029
- /**
2030
- * Log operation result
2031
- * @param result Result to log
2032
- */
2033
- logResult(result) {
2034
- switch (result.action) {
2035
- case "copied":
2036
- this.logMessage(`Would copy: ${result.relativePath}`, `Copied: ${result.relativePath}`);
2037
- this.logNote(result);
2038
- break;
2039
- case "created":
2040
- this.logMessage(`Would create: ${result.relativePath}`, `Created: ${result.relativePath}`);
2041
- break;
2042
- case "skipped":
2043
- // Silent about the file itself — nothing changed, and naming every
2044
- // untouched path would bury the run. But a note attached to a skipped
2045
- // result is not about the write: it is what the apply FOUND, such as a
2046
- // governed gate the project's own script no longer invokes. That
2047
- // condition persists across applies and reaches this branch on every
2048
- // one of them, so dropping it here is how a finding becomes permanently
2049
- // invisible.
2050
- this.logNote(result);
2051
- break;
2052
- case "stale":
2053
- this.deps.logger.warn(this.config.dryRun
2054
- ? `Out of date, would not be updated: ${result.relativePath}`
2055
- : `Out of date, not updated: ${result.relativePath}`);
2056
- break;
2057
- case "host-ahead":
2058
- this.deps.logger.warn(this.config.dryRun
2059
- ? `Would keep your copy: ${result.relativePath}`
2060
- : `Kept your copy: ${result.relativePath}`);
2061
- break;
2062
- case "shadowed":
2063
- // Warn, not info: the file is absent by design, and an operator who
2064
- // later wonders why the template never arrived needs this line to have
2065
- // been visible at the time.
2066
- this.deps.logger.warn(this.config.dryRun
2067
- ? `Would not write, your own config takes precedence: ${result.relativePath}`
2068
- : `Not written, your own config takes precedence: ${result.relativePath}`);
2069
- this.logNote(result);
2070
- break;
2071
- case "overwritten":
2072
- this.logMessage(`Would prompt to overwrite: ${result.relativePath}`, `Overwritten: ${result.relativePath}`);
2073
- break;
2074
- case "appended": {
2075
- const msg = `Appended ${result.linesAdded} lines to: ${result.relativePath}`;
2076
- this.logMessage(`Would ${msg}`, msg);
2077
- break;
2078
- }
2079
- case "merged":
2080
- this.logMessage(`Would merge: ${result.relativePath}`, `Merged: ${result.relativePath}`);
2081
- if (result.note !== undefined) {
2082
- this.logNote(result);
2083
- }
2084
- break;
2085
- }
2086
- }
2087
- /**
2088
- * Log an optional operation note.
2089
- * @param result Operation result that may carry an operator-readable note
2090
- */
2091
- logNote(result) {
2092
- if (result.note !== undefined) {
2093
- this.deps.logger.info(result.note);
2094
- }
2095
- }
2096
- /**
2097
- * Validate destination directory exists and is a directory
2098
- */
2099
- async validateDestination() {
2100
- const { destDir } = this.config;
2101
- if (!(await fse.pathExists(destDir))) {
2102
- throw new DestinationNotFoundError(destDir);
2103
- }
2104
- const stats = await stat(destDir);
2105
- if (!stats.isDirectory()) {
2106
- throw new DestinationNotDirectoryError(destDir);
2107
- }
2108
- }
2109
- /**
2110
- * Check for uncommitted git changes and prompt user if dirty
2111
- */
2112
- async validateGitState() {
2113
- const { gitService, prompter, logger } = this.deps;
2114
- const { destDir } = this.config;
2115
- // Skip git check if not a git repository
2116
- if (!(await gitService.isRepository(destDir))) {
2117
- return;
2118
- }
2119
- // Skip git check when requested (e.g. during postinstall where lockfile is always dirty)
2120
- if (this.config.skipGitCheck) {
2121
- return;
2122
- }
2123
- // Check for uncommitted changes
2124
- if (!(await gitService.isDirty(destDir))) {
2125
- return;
2126
- }
2127
- const status = await gitService.getStatus(destDir);
2128
- logger.warn("Git working directory has uncommitted changes");
2129
- // Always prompt for dirty git, even in yesMode
2130
- const proceed = await prompter.confirmDirtyGit(status);
2131
- if (!proceed) {
2132
- throw new UserAbortedError("Aborted: please commit or stash your changes before running Lisa");
2133
- }
2134
- }
2135
- /**
2136
- * Print header banner
2137
- */
2138
- printHeader() {
2139
- const { logger } = this.deps;
2140
- console.log("");
2141
- console.log(pc.blue(this.separator));
2142
- if (this.config.validateOnly) {
2143
- console.log(pc.blue(" Lisa Project Bootstrapper (VALIDATE)"));
2144
- }
2145
- else if (this.config.dryRun) {
2146
- console.log(pc.blue(" Lisa Project Bootstrapper (DRY RUN)"));
2147
- }
2148
- else {
2149
- console.log(pc.blue(" Lisa Project Bootstrapper"));
2150
- }
2151
- console.log(pc.blue(this.separator));
2152
- console.log("");
2153
- if (this.config.validateOnly) {
2154
- logger.info("Validate mode - checking project compatibility");
2155
- }
2156
- else if (this.config.dryRun) {
2157
- logger.warn("Dry run mode - no changes will be made");
2158
- }
2159
- logger.info(`Lisa directory: ${this.config.lisaDir}`);
2160
- logger.info(`Destination: ${this.config.destDir}`);
2161
- console.log("");
2162
- }
2163
- /**
2164
- * Print summary header with mode
2165
- */
2166
- printSummaryHeader() {
2167
- console.log("");
2168
- console.log(pc.green(this.separator));
2169
- if (this.config.validateOnly) {
2170
- console.log(pc.green(" Lisa Validation Complete"));
2171
- }
2172
- else if (this.config.dryRun) {
2173
- console.log(pc.green(" Lisa Dry Run Complete"));
2174
- }
2175
- else {
2176
- console.log(pc.green(" Lisa Installation Complete!"));
2177
- }
2178
- console.log(pc.green(this.separator));
2179
- console.log("");
2180
- }
2181
- /**
2182
- * Print a single stat line with color
2183
- * @param label - Stat label
2184
- * @param value - Stat value
2185
- * @param color - Color function from picocolors
2186
- * @param suffix - Optional suffix after the count
2187
- */
2188
- printStatLine(label, value, color, suffix = "") {
2189
- const suffixText = suffix ? ` ${suffix}` : "";
2190
- console.log(` ${color(label)} ${String(value).padStart(3)} files${suffixText}`);
2191
- }
2192
- /**
2193
- * Print summary statistics for validate mode
2194
- */
2195
- printValidateStats() {
2196
- const { copied, skipped, overwritten, appended, merged, deleted, ignored } = this.counters;
2197
- this.printStatLine("Compatible files: ", copied, pc.green);
2198
- this.printStatLine("Already present: ", skipped, pc.blue);
2199
- this.printStatLine("Would conflict: ", overwritten, pc.yellow);
2200
- this.printStatLine("Would append: ", appended, pc.blue);
2201
- this.printStatLine("Would merge: ", merged, pc.green);
2202
- this.printStatLine("Would delete: ", deleted, pc.red);
2203
- if (ignored > 0) {
2204
- this.printStatLine("Ignored: ", ignored, pc.magenta, this.lisaignoreSuffix);
2205
- }
2206
- }
2207
- /**
2208
- * Print summary statistics for dry-run mode
2209
- */
2210
- printDryRunStats() {
2211
- const { copied, skipped, overwritten, appended, merged, deleted, ignored } = this.counters;
2212
- this.printStatLine("Would copy: ", copied, pc.green);
2213
- this.printStatLine("Would skip: ", skipped, pc.blue, "(identical or create-only)");
2214
- this.printStatLine("Would prompt: ", overwritten, pc.yellow, "(differ)");
2215
- this.printStatLine("Out of date: ", this.counters.stale, pc.yellow, "(managed templates changed; would NOT be updated)");
2216
- this.printStatLine("Would append: ", appended, pc.blue, "(copy-contents)");
2217
- this.printStatLine("Would merge: ", merged, pc.green, "(JSON)");
2218
- this.printStatLine("Would delete: ", deleted, pc.red);
2219
- if (ignored > 0) {
2220
- this.printStatLine("Would ignore: ", ignored, pc.magenta, this.lisaignoreSuffix);
2221
- }
2222
- this.printStaleDetail();
2223
- this.printHostAheadDetail();
2224
- this.printShadowedDetail();
2225
- this.printDeletionDetail();
2226
- }
2227
- /**
2228
- * Print summary statistics for apply mode
2229
- */
2230
- printApplyStats() {
2231
- const { copied, skipped, overwritten, appended, merged, deleted, ignored } = this.counters;
2232
- this.printStatLine("Copied: ", copied, pc.green);
2233
- this.printStatLine("Skipped: ", skipped, pc.blue, "(identical or create-only)");
2234
- // Not every overwrite is a human saying yes: Lisa's own artifacts refresh
2235
- // on any apply, which is how a released guard fix reaches installed
2236
- // projects. Saying "user approved" here would misreport that as consent
2237
- // nobody gave.
2238
- this.printStatLine("Overwritten:", overwritten, pc.yellow, "(approved or Lisa-owned)");
2239
- this.printStatLine("Out of date:", this.counters.stale, pc.yellow, "(managed templates changed; NOT updated)");
2240
- this.printStatLine("Appended: ", appended, pc.blue, "(copy-contents)");
2241
- this.printStatLine("Merged: ", merged, pc.green, "(JSON merged)");
2242
- this.printStatLine("Deleted: ", deleted, pc.red);
2243
- if (ignored > 0) {
2244
- this.printStatLine("Ignored: ", ignored, pc.magenta, this.lisaignoreSuffix);
2245
- }
2246
- this.printStaleDetail();
2247
- this.printHostAheadDetail();
2248
- this.printShadowedDetail();
2249
- this.printDeletionDetail();
2250
- }
2251
- /**
2252
- * Name the out-of-date managed files and say how to update them.
2253
- *
2254
- * A bare count is not enough to act on. An operator taking an upgrade needs
2255
- * to see WHICH managed files the release changed and did not deliver —
2256
- * particularly the enforcement guards, where the gap is a security control
2257
- * that stayed on its old version while the release notes said otherwise.
2258
- */
2259
- printStaleDetail() {
2260
- if (this.counters.stale === 0)
2261
- return;
2262
- const { logger } = this.deps;
2263
- logger.warn(this.config.dryRun
2264
- ? `${this.counters.stale} managed file(s) changed upstream and would be left as-is:`
2265
- : `${this.counters.stale} managed file(s) changed upstream but were left as-is:`);
2266
- for (const relativePath of this.stalePaths) {
2267
- logger.warn(` ${relativePath}`);
2268
- }
2269
- logger.info("A non-interactive apply will not replace a file your project may have customised.");
2270
- logger.info("To take upstream's version of one, name it: `lisa apply . --refresh-templates=<path>`.");
2271
- logger.info("Name them ONE AT A TIME. Bare `--refresh-templates` is repo-wide and reverts every deliberate fork at once.");
2272
- logger.info("To keep yours instead, add the path to .lisaignore. Either way, decide — an unread file stops receiving upstream fixes, security fixes included.");
2273
- }
2274
- /**
2275
- * Report Lisa-owned artifacts this apply chose not to replace.
2276
- *
2277
- * Reported as good news, not as a warning about the project: keeping a guard
2278
- * that is stronger than Lisa's is the correct outcome, and phrasing it as a
2279
- * problem would push an operator to "fix" it by discarding their own
2280
- * hardening — the exact loss the check exists to prevent.
2281
- */
2282
- printHostAheadDetail() {
2283
- if (this.counters.hostAhead === 0)
2284
- return;
2285
- const { logger } = this.deps;
2286
- logger.info(`${this.counters.hostAhead} Lisa-owned file(s) look stronger in your project than in Lisa, so your version was kept:`);
2287
- for (const note of this.hostAheadNotes) {
2288
- logger.info(` ${note}`);
2289
- }
2290
- logger.info("Nothing is broken. Lisa only replaces one of its own files when it can prove your copy came from an older Lisa.");
2291
- }
2292
- /**
2293
- * Name every template this apply declined to write to avoid outranking the
2294
- * project's own configuration.
2295
- *
2296
- * Reported as good news for the same reason as {@link printHostAheadDetail}:
2297
- * the project's config surviving is the correct outcome. But it is stated at
2298
- * all because the *absence* of a file is invisible — a template that never
2299
- * arrives looks identical to one that was never shipped, and this is the only
2300
- * moment anything can say which happened (CodySwannGT/lisa#3501).
2301
- */
2302
- printShadowedDetail() {
2303
- if (this.counters.shadowed === 0)
2304
- return;
2305
- const { logger } = this.deps;
2306
- logger.info(`${this.counters.shadowed} template(s) were not written because this project already configures those tools itself:`);
2307
- for (const note of this.shadowedNotes) {
2308
- logger.info(` ${note}`);
2309
- }
2310
- logger.info("Nothing is broken. Lisa's file would have taken precedence over yours, so yours was left in charge.");
2311
- }
2312
- /**
2313
- * Name every path this apply removed, and every workflow it declined to.
2314
- *
2315
- * Deliberately unconditional on the removals, and deliberately wider than the
2316
- * ownership gate. Lisa is entitled to retire its own artifacts, and it still
2317
- * says so out loud, because the cost of an unannounced removal is not
2318
- * proportional to whether it was justified: a workflow that no longer exists
2319
- * cannot fail, so its absence produces no red check anywhere and reads
2320
- * exactly like a healthy repo (CodySwannGT/lisa#3656). The same is true, more
2321
- * quietly, of a deleted `.claude/skills/<name>` directory or a root-level
2322
- * `eslint-plugin-*` tree. Reviewing the upgrade diff has to be enough to
2323
- * notice, and that only works if the install told somebody.
2324
- */
2325
- printDeletionDetail() {
2326
- if (this.deletionNotices.length === 0)
2327
- return;
2328
- const { logger } = this.deps;
2329
- logger.warn("Files this run removed, and workflows it declined to remove:");
2330
- for (const notice of this.deletionNotices) {
2331
- logger.warn(` ${notice}`);
2332
- }
2333
- logger.info(`The removals are also recorded in ${APPLY_RECEIPT_DISPLAY_PATH}, because install output does not survive: package managers hide postinstall stdout and the reconciliation trampoline runs detached with stdio "ignore".`);
2334
- logger.info("A removed workflow takes its checks with it and cannot fail afterwards, so its absence looks exactly like a healthy repo. If any removed file was yours, restore it from git and add its path to .lisaignore — that is checked before every deletion, workflow or not.");
2335
- }
2336
- /**
2337
- * Print summary statistics
2338
- */
2339
- printSummaryStats() {
2340
- if (this.config.validateOnly) {
2341
- this.printValidateStats();
2342
- }
2343
- else if (this.config.dryRun) {
2344
- this.printDryRunStats();
2345
- }
2346
- else {
2347
- this.printApplyStats();
2348
- }
2349
- const { migrationsApplied } = this.counters;
2350
- if (migrationsApplied > 0) {
2351
- this.printStatLine("Migrations: ", migrationsApplied, pc.cyan, "applied");
2352
- }
2353
- }
2354
- /**
2355
- * Print project types
2356
- */
2357
- printProjectTypes() {
2358
- console.log("");
2359
- const allAndDetected = this.detectedTypes.length > 0
2360
- ? `all ${this.detectedTypes.join(" ")}`
2361
- : "all";
2362
- console.log(`Project types: ${pc.green(allAndDetected)}`);
2363
- console.log("");
2364
- }
2365
- /**
2366
- * Print validation result
2367
- */
2368
- printValidationResult() {
2369
- if (!this.config.validateOnly)
2370
- return;
2371
- const { logger } = this.deps;
2372
- const { overwritten } = this.counters;
2373
- if (overwritten > 0) {
2374
- logger.warn(`Validation found ${overwritten} file(s) that would conflict`);
2375
- console.log("Run without --validate to apply changes interactively");
2376
- }
2377
- else {
2378
- logger.success("Project is compatible with Lisa configurations");
2379
- }
2380
- }
2381
- /**
2382
- * Print summary
2383
- */
2384
- printSummary() {
2385
- this.printSummaryHeader();
2386
- this.printSummaryStats();
2387
- this.printProjectTypes();
2388
- this.printValidationResult();
2389
- }
2390
- /**
2391
- * Read a file's contents, returning null if the file does not exist or cannot be read.
2392
- * Used for optional file checks that should not interrupt the main flow on failure.
2393
- * @param filePath - Absolute path to the file to read
2394
- * @returns File contents as a string, or null if unavailable
2395
- */
2396
- async tryReadFile(filePath) {
2397
- try {
2398
- return await readFile(filePath, "utf-8");
2399
- }
2400
- catch {
2401
- return null;
2402
- }
2403
- }
2404
- /**
2405
- * Print migration notices when the project's ci.yml or deploy.yml still reference
2406
- * local quality/release workflows instead of the canonical Lisa repo versions.
2407
- * Printed after the update summary so users see it as a post-update action item.
2408
- * @param projectDir - The destination project directory to inspect
2409
- */
2410
- async printMigrationNotices(projectDir) {
2411
- const ciPath = path.join(projectDir, ".github", "workflows", "ci.yml");
2412
- const deployPath = path.join(projectDir, ".github", "workflows", "deploy.yml");
2413
- const [ciContent, deployContent] = await Promise.all([
2414
- this.tryReadFile(ciPath),
2415
- this.tryReadFile(deployPath),
2416
- ]);
2417
- const isRailsProject = this.detectedTypes.includes("rails");
2418
- const notices = [
2419
- ciContent?.includes("uses: ./.github/workflows/quality.yml") &&
2420
- !isRailsProject
2421
- ? " .github/workflows/ci.yml — change:\n uses: ./.github/workflows/quality.yml\n → uses: CodySwannGT/lisa/.github/workflows/quality.yml@main"
2422
- : null,
2423
- ciContent?.includes("uses: ./.github/workflows/quality.yml") &&
2424
- isRailsProject
2425
- ? " .github/workflows/ci.yml — change:\n uses: ./.github/workflows/quality.yml\n → uses: CodySwannGT/lisa/.github/workflows/quality-rails.yml@main"
2426
- : null,
2427
- deployContent?.includes("uses: ./.github/workflows/release.yml") &&
2428
- !isRailsProject
2429
- ? " .github/workflows/deploy.yml — change:\n uses: ./.github/workflows/release.yml\n → uses: CodySwannGT/lisa/.github/workflows/release.yml@main"
2430
- : null,
2431
- deployContent?.includes("uses: ./.github/workflows/release.yml") &&
2432
- isRailsProject
2433
- ? " .github/workflows/deploy.yml — change:\n uses: ./.github/workflows/release.yml\n → uses: CodySwannGT/lisa/.github/workflows/release-rails.yml@main"
2434
- : null,
2435
- ].filter((n) => n !== null);
2436
- if (notices.length === 0) {
2437
- return;
2438
- }
2439
- console.log("");
2440
- console.log(pc.yellow("⚠️ Action required: Update your CI/Deploy workflows to call the Lisa repo directly."));
2441
- console.log("");
2442
- console.log(notices.join("\n\n"));
2443
- console.log("");
2444
- console.log(" Write `@main` as shown. The next `lisa apply` rewrites it to the commit");
2445
- console.log(" your installed Lisa's version tag names and keeps it there, so this is a");
2446
- console.log(" one-time edit and the ref is maintained for you from then on. Until that");
2447
- console.log(" apply runs, `lisa doctor` will correctly report the ref as still mutable.");
2448
- console.log("");
2449
- }
2450
206
  }
2451
- /* eslint-enable max-lines -- Main orchestrator class with apply/validate operations */
2452
207
  //# sourceMappingURL=lisa.js.map