@codyswann/lisa 8.7.1 → 8.9.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 (678) hide show
  1. package/README.md +21 -0
  2. package/all/copy-overwrite/scripts/lib/completion-authorization.mjs +54 -0
  3. package/all/copy-overwrite/scripts/lib/completion-proof-adapters.mjs +59 -0
  4. package/all/copy-overwrite/scripts/lib/completion-proof-markdown.mjs +1 -1
  5. package/all/copy-overwrite/scripts/lib/npm-update-helper-inventory.mjs +1 -0
  6. package/all/copy-overwrite/scripts/lib/release-switch.d.mts +91 -0
  7. package/all/copy-overwrite/scripts/lib/release-switch.mjs +1049 -0
  8. package/all/copy-overwrite/scripts/lisa-enforcement-fallback.sh +3 -3
  9. package/all/copy-overwrite/scripts/lisa-enforcement-freshness.mjs +1 -0
  10. package/all/copy-overwrite/scripts/lisa-gates.mjs +90 -5
  11. package/all/copy-overwrite/scripts/lisa-hooks/task-readiness-guard.sh +54 -0
  12. package/all/copy-overwrite/scripts/lisa-release-switch.mjs +203 -0
  13. package/all/copy-overwrite/scripts/npm-updater-helper-graph.json +18 -5
  14. package/dist/cli/doctor-release-setting.d.ts +8 -0
  15. package/dist/cli/doctor-release-setting.d.ts.map +1 -0
  16. package/dist/cli/doctor-release-setting.js +71 -0
  17. package/dist/cli/doctor-release-setting.js.map +1 -0
  18. package/dist/cli/doctor.d.ts.map +1 -1
  19. package/dist/cli/doctor.js +2 -0
  20. package/dist/cli/doctor.js.map +1 -1
  21. package/dist/controls/before-enforce-observe.d.ts +1 -1
  22. package/dist/controls/before-enforce-observe.d.ts.map +1 -1
  23. package/dist/controls/before-enforce-observe.js +3 -7
  24. package/dist/controls/before-enforce-observe.js.map +1 -1
  25. package/dist/controls/before-enforce-workspace.d.ts.map +1 -1
  26. package/dist/controls/before-enforce-workspace.js +16 -1
  27. package/dist/controls/before-enforce-workspace.js.map +1 -1
  28. package/dist/controls/commands/proof-check.d.ts +1 -1
  29. package/dist/controls/commands/proof-check.d.ts.map +1 -1
  30. package/dist/controls/commands/proof-check.js +11 -11
  31. package/dist/controls/commands/seed.d.ts.map +1 -1
  32. package/dist/controls/commands/seed.js +14 -30
  33. package/dist/controls/commands/seed.js.map +1 -1
  34. package/dist/controls/proof-check-plan.d.ts +5 -6
  35. package/dist/controls/proof-check-plan.d.ts.map +1 -1
  36. package/dist/controls/proof-check-plan.js +11 -10
  37. package/dist/controls/proof-check-plan.js.map +1 -1
  38. package/dist/controls/proof-check-report.d.ts.map +1 -1
  39. package/dist/controls/proof-check-report.js +2 -4
  40. package/dist/controls/proof-check-report.js.map +1 -1
  41. package/dist/controls/proof-copy-source.d.ts +24 -0
  42. package/dist/controls/proof-copy-source.d.ts.map +1 -0
  43. package/dist/controls/proof-copy-source.js +60 -0
  44. package/dist/controls/proof-copy-source.js.map +1 -0
  45. package/dist/controls/proof-copy-wording.d.ts +10 -1
  46. package/dist/controls/proof-copy-wording.d.ts.map +1 -1
  47. package/dist/controls/proof-copy-wording.js +23 -2
  48. package/dist/controls/proof-copy-wording.js.map +1 -1
  49. package/dist/controls/proof-copy-workspace.d.ts +4 -3
  50. package/dist/controls/proof-copy-workspace.d.ts.map +1 -1
  51. package/dist/controls/proof-copy-workspace.js +39 -23
  52. package/dist/controls/proof-copy-workspace.js.map +1 -1
  53. package/dist/controls/proof-copy.d.ts +1 -9
  54. package/dist/controls/proof-copy.d.ts.map +1 -1
  55. package/dist/controls/proof-copy.js +3 -45
  56. package/dist/controls/proof-copy.js.map +1 -1
  57. package/dist/controls/proof-half-run.d.ts +1 -1
  58. package/dist/controls/proof-half-run.d.ts.map +1 -1
  59. package/dist/controls/proof-half-run.js +6 -9
  60. package/dist/controls/proof-half-run.js.map +1 -1
  61. package/dist/controls/proof-plan.d.ts +17 -2
  62. package/dist/controls/proof-plan.d.ts.map +1 -1
  63. package/dist/controls/proof-plan.js +47 -3
  64. package/dist/controls/proof-plan.js.map +1 -1
  65. package/dist/controls/proof-push-fixture.d.ts +16 -0
  66. package/dist/controls/proof-push-fixture.d.ts.map +1 -0
  67. package/dist/controls/proof-push-fixture.js +137 -0
  68. package/dist/controls/proof-push-fixture.js.map +1 -0
  69. package/dist/controls/proof-types.d.ts +4 -0
  70. package/dist/controls/proof-types.d.ts.map +1 -1
  71. package/dist/controls/register-entries.d.ts.map +1 -1
  72. package/dist/controls/register-entries.js +23 -2
  73. package/dist/controls/register-entries.js.map +1 -1
  74. package/dist/controls/register-types.d.ts +4 -0
  75. package/dist/controls/register-types.d.ts.map +1 -1
  76. package/dist/controls/register-types.js.map +1 -1
  77. package/dist/controls/shipped-parts.d.ts +8 -6
  78. package/dist/controls/shipped-parts.d.ts.map +1 -1
  79. package/dist/controls/shipped-parts.js +19 -1
  80. package/dist/controls/shipped-parts.js.map +1 -1
  81. package/dist/controls/shipped-task-proofs.d.ts +24 -0
  82. package/dist/controls/shipped-task-proofs.d.ts.map +1 -0
  83. package/dist/controls/shipped-task-proofs.js +191 -0
  84. package/dist/controls/shipped-task-proofs.js.map +1 -0
  85. package/dist/core/lisa-owned-hash-ledger.json +148 -4
  86. package/dist/core/nightly-e2e-guard-behavior-certificate.js +2 -2
  87. package/dist/core/upstream-evidence-manifest.json +391 -66
  88. package/dist/migrations/ensure-seeded-gates.d.ts.map +1 -1
  89. package/dist/migrations/ensure-seeded-gates.js +4 -1
  90. package/dist/migrations/ensure-seeded-gates.js.map +1 -1
  91. package/dist/opencode/hooks-installer.d.ts.map +1 -1
  92. package/dist/opencode/hooks-installer.js +2 -0
  93. package/dist/opencode/hooks-installer.js.map +1 -1
  94. package/dist/opencode/plugin-catalog.d.ts.map +1 -1
  95. package/dist/opencode/plugin-catalog.js +5 -0
  96. package/dist/opencode/plugin-catalog.js.map +1 -1
  97. package/dist/opencode/plugin-templates/lisa-task-readiness.ts +47 -0
  98. package/dist/opencode/plugin-templates/task-readiness-guard.mjs +99 -0
  99. package/dist/opencode/plugin-templates/task-readiness-guard.sh +54 -0
  100. package/package.json +5 -4
  101. package/plugins/lisa/.claude-plugin/plugin.json +49 -2
  102. package/plugins/lisa/.codex-plugin/hooks.json +48 -1
  103. package/plugins/lisa/.codex-plugin/plugin.json +1 -1
  104. package/plugins/lisa/.codex-plugin/skills/lisa-atlassian-access/SKILL.md +13 -0
  105. package/plugins/lisa/.codex-plugin/skills/lisa-configure/SKILL.md +19 -7
  106. package/plugins/lisa/.codex-plugin/skills/lisa-doctor/SKILL.md +10 -0
  107. package/plugins/lisa/.codex-plugin/skills/lisa-drive-pr-to-merge/SKILL.md +9 -0
  108. package/plugins/lisa/.codex-plugin/skills/lisa-git-submit-pr/SKILL.md +1 -0
  109. package/plugins/lisa/.codex-plugin/skills/lisa-github-build-intake/SKILL.md +2 -0
  110. package/plugins/lisa/.codex-plugin/skills/lisa-github-claim/SKILL.md +2 -0
  111. package/plugins/lisa/.codex-plugin/skills/lisa-github-read-issue/SKILL.md +29 -0
  112. package/plugins/lisa/.codex-plugin/skills/lisa-github-read-issue/read-contract.mjs +70 -0
  113. package/plugins/lisa/.codex-plugin/skills/lisa-github-validate-issue/SKILL.md +27 -1
  114. package/plugins/lisa/.codex-plugin/skills/lisa-github-write-issue/SKILL.md +23 -0
  115. package/plugins/lisa/.codex-plugin/skills/lisa-implement/SKILL.md +15 -2
  116. package/plugins/lisa/.codex-plugin/skills/lisa-jira-build-intake/SKILL.md +2 -0
  117. package/plugins/lisa/.codex-plugin/skills/lisa-jira-claim/SKILL.md +2 -0
  118. package/plugins/lisa/.codex-plugin/skills/lisa-jira-read-ticket/SKILL.md +9 -0
  119. package/plugins/lisa/.codex-plugin/skills/lisa-jira-validate-ticket/SKILL.md +27 -1
  120. package/plugins/lisa/.codex-plugin/skills/lisa-jira-write-ticket/SKILL.md +23 -0
  121. package/plugins/lisa/.codex-plugin/skills/lisa-linear-access/SKILL.md +102 -103
  122. package/plugins/lisa/.codex-plugin/skills/lisa-linear-access/scripts/linear-graphql.sh +428 -0
  123. package/plugins/lisa/.codex-plugin/skills/lisa-linear-build-intake/SKILL.md +2 -0
  124. package/plugins/lisa/.codex-plugin/skills/lisa-linear-claim/SKILL.md +3 -1
  125. package/plugins/lisa/.codex-plugin/skills/lisa-linear-read-issue/SKILL.md +13 -0
  126. package/plugins/lisa/.codex-plugin/skills/lisa-linear-validate-issue/SKILL.md +26 -0
  127. package/plugins/lisa/.codex-plugin/skills/lisa-linear-write-issue/SKILL.md +27 -0
  128. package/plugins/lisa/.codex-plugin/skills/lisa-notion-access/SKILL.md +37 -0
  129. package/plugins/lisa/.codex-plugin/skills/lisa-notion-access/scripts/readiness-probe.mjs +83 -0
  130. package/plugins/lisa/.codex-plugin/skills/lisa-secrets-access/SKILL.md +8 -26
  131. package/plugins/lisa/.codex-plugin/skills/lisa-secrets-access/scripts/aws-bootstrap.mjs +89 -117
  132. package/plugins/lisa/.codex-plugin/skills/lisa-secrets-access/scripts/config-files.mjs +42 -0
  133. package/plugins/lisa/.codex-plugin/skills/lisa-secrets-access/scripts/config-layers.mjs +139 -0
  134. package/plugins/lisa/.codex-plugin/skills/lisa-secrets-access/scripts/materialize-secrets.mjs +138 -125
  135. package/plugins/lisa/.codex-plugin/skills/lisa-secrets-access/scripts/preflight-secrets.mjs +98 -10
  136. package/plugins/lisa/.codex-plugin/skills/lisa-secrets-access/scripts/providers.mjs +24 -1
  137. package/plugins/lisa/.codex-plugin/skills/lisa-secrets-access/scripts/routing-floor.mjs +21 -0
  138. package/plugins/lisa/.codex-plugin/skills/lisa-secrets-access/scripts/surfaces.mjs +111 -36
  139. package/plugins/lisa/.codex-plugin/skills/lisa-secrets-access/scripts/task-access.mjs +205 -0
  140. package/plugins/lisa/.codex-plugin/skills/lisa-secrets-access/scripts/task-action.mjs +218 -0
  141. package/plugins/lisa/.codex-plugin/skills/lisa-secrets-access/scripts/task-atlassian-native.mjs +181 -0
  142. package/plugins/lisa/.codex-plugin/skills/lisa-secrets-access/scripts/task-context-data.mjs +75 -0
  143. package/plugins/lisa/.codex-plugin/skills/lisa-secrets-access/scripts/task-context-write.mjs +158 -0
  144. package/plugins/lisa/.codex-plugin/skills/lisa-secrets-access/scripts/task-github.mjs +92 -0
  145. package/plugins/lisa/.codex-plugin/skills/lisa-secrets-access/scripts/task-intake-read.mjs +171 -0
  146. package/plugins/lisa/.codex-plugin/skills/lisa-secrets-access/scripts/task-intake.mjs +155 -0
  147. package/plugins/lisa/.codex-plugin/skills/lisa-secrets-access/scripts/task-native-context.mjs +71 -0
  148. package/plugins/lisa/.codex-plugin/skills/lisa-secrets-access/scripts/task-native-contract.mjs +156 -0
  149. package/plugins/lisa/.codex-plugin/skills/lisa-secrets-access/scripts/task-native-flow.mjs +253 -0
  150. package/plugins/lisa/.codex-plugin/skills/lisa-secrets-access/scripts/task-native-lifecycle.mjs +106 -0
  151. package/plugins/lisa/.codex-plugin/skills/lisa-secrets-access/scripts/task-native-state.mjs +171 -0
  152. package/plugins/lisa/.codex-plugin/skills/lisa-secrets-access/scripts/task-readiness.mjs +347 -0
  153. package/plugins/lisa/.codex-plugin/skills/lisa-secrets-access/scripts/task-requirements.mjs +279 -0
  154. package/plugins/lisa/.codex-plugin/skills/lisa-secrets-access/scripts/task-tracker-intake.mjs +463 -0
  155. package/plugins/lisa/.codex-plugin/skills/lisa-secrets-access/scripts/validate-config.mjs +2 -21
  156. package/plugins/lisa/.codex-plugin/skills/lisa-setup-linear/SKILL.md +2 -0
  157. package/plugins/lisa/.codex-plugin/skills/lisa-setup-remote-aws/SKILL.md +8 -0
  158. package/plugins/lisa/.codex-plugin/skills/lisa-task-decomposition/SKILL.md +1 -0
  159. package/plugins/lisa/.codex-plugin/skills/lisa-track/SKILL.md +13 -1
  160. package/plugins/lisa/.codex-plugin/skills/lisa-tracker-claim/SKILL.md +2 -0
  161. package/plugins/lisa/.codex-plugin/skills/lisa-verify/SKILL.md +4 -1
  162. package/plugins/lisa/hooks/inject-resolved-config.mjs +235 -3
  163. package/plugins/lisa/hooks/secrets-preflight.agy.sh +19 -0
  164. package/plugins/lisa/hooks/secrets-preflight.sh +42 -0
  165. package/plugins/lisa/hooks/task-readiness-guard.mjs +96 -0
  166. package/plugins/lisa/hooks/task-readiness-guard.sh +54 -0
  167. package/plugins/lisa/rules/eager/coding-philosophy.md +7 -6
  168. package/plugins/lisa/rules/reference/coding-philosophy.md +48 -0
  169. package/plugins/lisa/rules/reference/config-resolution.md +4 -1
  170. package/plugins/lisa/rules/reference/intent-routing.md +2 -2
  171. package/plugins/lisa/rules/reference/tool-access-gate.md +160 -0
  172. package/plugins/lisa/rules/reference/tracked-work.md +2 -0
  173. package/plugins/lisa/rules/reference/work-item-definition-of-ready.md +31 -0
  174. package/plugins/lisa/scripts/install-remote-agent-aws.mjs +3 -2
  175. package/plugins/lisa/scripts/remote-agent-aws-setup.sh +123 -10
  176. package/plugins/lisa/skills/lisa-atlassian-access/SKILL.md +13 -0
  177. package/plugins/lisa/skills/lisa-configure/SKILL.md +19 -7
  178. package/plugins/lisa/skills/lisa-doctor/SKILL.md +10 -0
  179. package/plugins/lisa/skills/lisa-drive-pr-to-merge/SKILL.md +9 -0
  180. package/plugins/lisa/skills/lisa-git-submit-pr/SKILL.md +1 -0
  181. package/plugins/lisa/skills/lisa-github-build-intake/SKILL.md +2 -0
  182. package/plugins/lisa/skills/lisa-github-claim/SKILL.md +2 -0
  183. package/plugins/lisa/skills/lisa-github-read-issue/SKILL.md +29 -0
  184. package/plugins/lisa/skills/lisa-github-read-issue/read-contract.mjs +70 -0
  185. package/plugins/lisa/skills/lisa-github-validate-issue/SKILL.md +27 -1
  186. package/plugins/lisa/skills/lisa-github-write-issue/SKILL.md +23 -0
  187. package/plugins/lisa/skills/lisa-implement/SKILL.md +15 -2
  188. package/plugins/lisa/skills/lisa-jira-build-intake/SKILL.md +2 -0
  189. package/plugins/lisa/skills/lisa-jira-claim/SKILL.md +2 -0
  190. package/plugins/lisa/skills/lisa-jira-read-ticket/SKILL.md +9 -0
  191. package/plugins/lisa/skills/lisa-jira-validate-ticket/SKILL.md +27 -1
  192. package/plugins/lisa/skills/lisa-jira-write-ticket/SKILL.md +23 -0
  193. package/plugins/lisa/skills/lisa-linear-access/SKILL.md +102 -103
  194. package/plugins/lisa/skills/lisa-linear-access/scripts/linear-graphql.sh +428 -0
  195. package/plugins/lisa/skills/lisa-linear-build-intake/SKILL.md +2 -0
  196. package/plugins/lisa/skills/lisa-linear-claim/SKILL.md +3 -1
  197. package/plugins/lisa/skills/lisa-linear-read-issue/SKILL.md +13 -0
  198. package/plugins/lisa/skills/lisa-linear-validate-issue/SKILL.md +26 -0
  199. package/plugins/lisa/skills/lisa-linear-write-issue/SKILL.md +27 -0
  200. package/plugins/lisa/skills/lisa-notion-access/SKILL.md +37 -0
  201. package/plugins/lisa/skills/lisa-notion-access/scripts/readiness-probe.mjs +83 -0
  202. package/plugins/lisa/skills/lisa-secrets-access/SKILL.md +8 -26
  203. package/plugins/lisa/skills/lisa-secrets-access/scripts/aws-bootstrap.mjs +89 -117
  204. package/plugins/lisa/skills/lisa-secrets-access/scripts/config-files.mjs +42 -0
  205. package/plugins/lisa/skills/lisa-secrets-access/scripts/config-layers.mjs +139 -0
  206. package/plugins/lisa/skills/lisa-secrets-access/scripts/materialize-secrets.mjs +138 -125
  207. package/plugins/lisa/skills/lisa-secrets-access/scripts/preflight-secrets.mjs +98 -10
  208. package/plugins/lisa/skills/lisa-secrets-access/scripts/providers.mjs +24 -1
  209. package/plugins/lisa/skills/lisa-secrets-access/scripts/routing-floor.mjs +21 -0
  210. package/plugins/lisa/skills/lisa-secrets-access/scripts/surfaces.mjs +111 -36
  211. package/plugins/lisa/skills/lisa-secrets-access/scripts/task-access.mjs +205 -0
  212. package/plugins/lisa/skills/lisa-secrets-access/scripts/task-action.mjs +218 -0
  213. package/plugins/lisa/skills/lisa-secrets-access/scripts/task-atlassian-native.mjs +181 -0
  214. package/plugins/lisa/skills/lisa-secrets-access/scripts/task-context-data.mjs +75 -0
  215. package/plugins/lisa/skills/lisa-secrets-access/scripts/task-context-write.mjs +158 -0
  216. package/plugins/lisa/skills/lisa-secrets-access/scripts/task-github.mjs +92 -0
  217. package/plugins/lisa/skills/lisa-secrets-access/scripts/task-intake-read.mjs +171 -0
  218. package/plugins/lisa/skills/lisa-secrets-access/scripts/task-intake.mjs +155 -0
  219. package/plugins/lisa/skills/lisa-secrets-access/scripts/task-native-context.mjs +71 -0
  220. package/plugins/lisa/skills/lisa-secrets-access/scripts/task-native-contract.mjs +156 -0
  221. package/plugins/lisa/skills/lisa-secrets-access/scripts/task-native-flow.mjs +253 -0
  222. package/plugins/lisa/skills/lisa-secrets-access/scripts/task-native-lifecycle.mjs +106 -0
  223. package/plugins/lisa/skills/lisa-secrets-access/scripts/task-native-state.mjs +171 -0
  224. package/plugins/lisa/skills/lisa-secrets-access/scripts/task-readiness.mjs +347 -0
  225. package/plugins/lisa/skills/lisa-secrets-access/scripts/task-requirements.mjs +279 -0
  226. package/plugins/lisa/skills/lisa-secrets-access/scripts/task-tracker-intake.mjs +463 -0
  227. package/plugins/lisa/skills/lisa-secrets-access/scripts/validate-config.mjs +2 -21
  228. package/plugins/lisa/skills/lisa-setup-linear/SKILL.md +2 -0
  229. package/plugins/lisa/skills/lisa-setup-remote-aws/SKILL.md +8 -0
  230. package/plugins/lisa/skills/lisa-task-decomposition/SKILL.md +1 -0
  231. package/plugins/lisa/skills/lisa-track/SKILL.md +13 -1
  232. package/plugins/lisa/skills/lisa-tracker-claim/SKILL.md +2 -0
  233. package/plugins/lisa/skills/lisa-verify/SKILL.md +4 -1
  234. package/plugins/lisa-agy/hooks/secrets-preflight.agy.sh +19 -0
  235. package/plugins/lisa-agy/hooks/secrets-preflight.sh +114 -0
  236. package/plugins/lisa-agy/hooks.json +13 -0
  237. package/plugins/lisa-agy/plugin.json +1 -1
  238. package/plugins/lisa-agy/scripts/install-remote-agent-aws.mjs +3 -2
  239. package/plugins/lisa-agy/scripts/remote-agent-aws-setup.sh +123 -10
  240. package/plugins/lisa-agy/skills/lisa-atlassian-access/SKILL.md +13 -0
  241. package/plugins/lisa-agy/skills/lisa-configure/SKILL.md +19 -7
  242. package/plugins/lisa-agy/skills/lisa-doctor/SKILL.md +10 -0
  243. package/plugins/lisa-agy/skills/lisa-drive-pr-to-merge/SKILL.md +9 -0
  244. package/plugins/lisa-agy/skills/lisa-git-submit-pr/SKILL.md +1 -0
  245. package/plugins/lisa-agy/skills/lisa-github-build-intake/SKILL.md +2 -0
  246. package/plugins/lisa-agy/skills/lisa-github-claim/SKILL.md +2 -0
  247. package/plugins/lisa-agy/skills/lisa-github-read-issue/SKILL.md +29 -0
  248. package/plugins/lisa-agy/skills/lisa-github-read-issue/read-contract.mjs +70 -0
  249. package/plugins/lisa-agy/skills/lisa-github-validate-issue/SKILL.md +27 -1
  250. package/plugins/lisa-agy/skills/lisa-github-write-issue/SKILL.md +23 -0
  251. package/plugins/lisa-agy/skills/lisa-implement/SKILL.md +15 -2
  252. package/plugins/lisa-agy/skills/lisa-jira-build-intake/SKILL.md +2 -0
  253. package/plugins/lisa-agy/skills/lisa-jira-claim/SKILL.md +2 -0
  254. package/plugins/lisa-agy/skills/lisa-jira-read-ticket/SKILL.md +9 -0
  255. package/plugins/lisa-agy/skills/lisa-jira-validate-ticket/SKILL.md +27 -1
  256. package/plugins/lisa-agy/skills/lisa-jira-write-ticket/SKILL.md +23 -0
  257. package/plugins/lisa-agy/skills/lisa-linear-access/SKILL.md +102 -103
  258. package/plugins/lisa-agy/skills/lisa-linear-access/scripts/linear-graphql.sh +428 -0
  259. package/plugins/lisa-agy/skills/lisa-linear-build-intake/SKILL.md +2 -0
  260. package/plugins/lisa-agy/skills/lisa-linear-claim/SKILL.md +3 -1
  261. package/plugins/lisa-agy/skills/lisa-linear-read-issue/SKILL.md +13 -0
  262. package/plugins/lisa-agy/skills/lisa-linear-validate-issue/SKILL.md +26 -0
  263. package/plugins/lisa-agy/skills/lisa-linear-write-issue/SKILL.md +27 -0
  264. package/plugins/lisa-agy/skills/lisa-notion-access/SKILL.md +37 -0
  265. package/plugins/lisa-agy/skills/lisa-notion-access/scripts/readiness-probe.mjs +83 -0
  266. package/plugins/lisa-agy/skills/lisa-secrets-access/SKILL.md +8 -26
  267. package/plugins/lisa-agy/skills/lisa-secrets-access/scripts/aws-bootstrap.mjs +89 -117
  268. package/plugins/lisa-agy/skills/lisa-secrets-access/scripts/config-files.mjs +42 -0
  269. package/plugins/lisa-agy/skills/lisa-secrets-access/scripts/config-layers.mjs +139 -0
  270. package/plugins/lisa-agy/skills/lisa-secrets-access/scripts/materialize-secrets.mjs +138 -125
  271. package/plugins/lisa-agy/skills/lisa-secrets-access/scripts/preflight-secrets.mjs +98 -10
  272. package/plugins/lisa-agy/skills/lisa-secrets-access/scripts/providers.mjs +24 -1
  273. package/plugins/lisa-agy/skills/lisa-secrets-access/scripts/routing-floor.mjs +21 -0
  274. package/plugins/lisa-agy/skills/lisa-secrets-access/scripts/surfaces.mjs +111 -36
  275. package/plugins/lisa-agy/skills/lisa-secrets-access/scripts/task-access.mjs +205 -0
  276. package/plugins/lisa-agy/skills/lisa-secrets-access/scripts/task-action.mjs +218 -0
  277. package/plugins/lisa-agy/skills/lisa-secrets-access/scripts/task-atlassian-native.mjs +181 -0
  278. package/plugins/lisa-agy/skills/lisa-secrets-access/scripts/task-context-data.mjs +75 -0
  279. package/plugins/lisa-agy/skills/lisa-secrets-access/scripts/task-context-write.mjs +158 -0
  280. package/plugins/lisa-agy/skills/lisa-secrets-access/scripts/task-github.mjs +92 -0
  281. package/plugins/lisa-agy/skills/lisa-secrets-access/scripts/task-intake-read.mjs +171 -0
  282. package/plugins/lisa-agy/skills/lisa-secrets-access/scripts/task-intake.mjs +155 -0
  283. package/plugins/lisa-agy/skills/lisa-secrets-access/scripts/task-native-context.mjs +71 -0
  284. package/plugins/lisa-agy/skills/lisa-secrets-access/scripts/task-native-contract.mjs +156 -0
  285. package/plugins/lisa-agy/skills/lisa-secrets-access/scripts/task-native-flow.mjs +253 -0
  286. package/plugins/lisa-agy/skills/lisa-secrets-access/scripts/task-native-lifecycle.mjs +106 -0
  287. package/plugins/lisa-agy/skills/lisa-secrets-access/scripts/task-native-state.mjs +171 -0
  288. package/plugins/lisa-agy/skills/lisa-secrets-access/scripts/task-readiness.mjs +347 -0
  289. package/plugins/lisa-agy/skills/lisa-secrets-access/scripts/task-requirements.mjs +279 -0
  290. package/plugins/lisa-agy/skills/lisa-secrets-access/scripts/task-tracker-intake.mjs +463 -0
  291. package/plugins/lisa-agy/skills/lisa-secrets-access/scripts/validate-config.mjs +2 -21
  292. package/plugins/lisa-agy/skills/lisa-setup-linear/SKILL.md +2 -0
  293. package/plugins/lisa-agy/skills/lisa-setup-remote-aws/SKILL.md +8 -0
  294. package/plugins/lisa-agy/skills/lisa-task-decomposition/SKILL.md +1 -0
  295. package/plugins/lisa-agy/skills/lisa-track/SKILL.md +13 -1
  296. package/plugins/lisa-agy/skills/lisa-tracker-claim/SKILL.md +2 -0
  297. package/plugins/lisa-agy/skills/lisa-verify/SKILL.md +4 -1
  298. package/plugins/lisa-cdk/.claude-plugin/plugin.json +1 -1
  299. package/plugins/lisa-cdk/.codex-plugin/plugin.json +1 -1
  300. package/plugins/lisa-cdk-agy/plugin.json +1 -1
  301. package/plugins/lisa-cdk-copilot/.claude-plugin/plugin.json +1 -1
  302. package/plugins/lisa-cdk-cursor/.claude-plugin/plugin.json +1 -1
  303. package/plugins/lisa-cdk-devin/.claude-plugin/plugin.json +1 -1
  304. package/plugins/lisa-cdk-devin/.devin-plugin/plugin.json +1 -1
  305. package/plugins/lisa-copilot/.claude-plugin/plugin.json +49 -2
  306. package/plugins/lisa-copilot/hooks/inject-resolved-config.mjs +235 -3
  307. package/plugins/lisa-copilot/hooks/secrets-preflight.sh +42 -0
  308. package/plugins/lisa-copilot/hooks/task-readiness-guard.mjs +96 -0
  309. package/plugins/lisa-copilot/hooks/task-readiness-guard.sh +54 -0
  310. package/plugins/lisa-copilot/rules/eager/coding-philosophy.md +7 -6
  311. package/plugins/lisa-copilot/rules/reference/coding-philosophy.md +48 -0
  312. package/plugins/lisa-copilot/rules/reference/config-resolution.md +4 -1
  313. package/plugins/lisa-copilot/rules/reference/intent-routing.md +2 -2
  314. package/plugins/lisa-copilot/rules/reference/tool-access-gate.md +160 -0
  315. package/plugins/lisa-copilot/rules/reference/tracked-work.md +2 -0
  316. package/plugins/lisa-copilot/rules/reference/work-item-definition-of-ready.md +31 -0
  317. package/plugins/lisa-copilot/scripts/install-remote-agent-aws.mjs +3 -2
  318. package/plugins/lisa-copilot/scripts/remote-agent-aws-setup.sh +123 -10
  319. package/plugins/lisa-copilot/skills/lisa-atlassian-access/SKILL.md +13 -0
  320. package/plugins/lisa-copilot/skills/lisa-configure/SKILL.md +19 -7
  321. package/plugins/lisa-copilot/skills/lisa-doctor/SKILL.md +10 -0
  322. package/plugins/lisa-copilot/skills/lisa-drive-pr-to-merge/SKILL.md +9 -0
  323. package/plugins/lisa-copilot/skills/lisa-git-submit-pr/SKILL.md +1 -0
  324. package/plugins/lisa-copilot/skills/lisa-github-build-intake/SKILL.md +2 -0
  325. package/plugins/lisa-copilot/skills/lisa-github-claim/SKILL.md +2 -0
  326. package/plugins/lisa-copilot/skills/lisa-github-read-issue/SKILL.md +29 -0
  327. package/plugins/lisa-copilot/skills/lisa-github-read-issue/read-contract.mjs +70 -0
  328. package/plugins/lisa-copilot/skills/lisa-github-validate-issue/SKILL.md +27 -1
  329. package/plugins/lisa-copilot/skills/lisa-github-write-issue/SKILL.md +23 -0
  330. package/plugins/lisa-copilot/skills/lisa-implement/SKILL.md +15 -2
  331. package/plugins/lisa-copilot/skills/lisa-jira-build-intake/SKILL.md +2 -0
  332. package/plugins/lisa-copilot/skills/lisa-jira-claim/SKILL.md +2 -0
  333. package/plugins/lisa-copilot/skills/lisa-jira-read-ticket/SKILL.md +9 -0
  334. package/plugins/lisa-copilot/skills/lisa-jira-validate-ticket/SKILL.md +27 -1
  335. package/plugins/lisa-copilot/skills/lisa-jira-write-ticket/SKILL.md +23 -0
  336. package/plugins/lisa-copilot/skills/lisa-linear-access/SKILL.md +102 -103
  337. package/plugins/lisa-copilot/skills/lisa-linear-access/scripts/linear-graphql.sh +428 -0
  338. package/plugins/lisa-copilot/skills/lisa-linear-build-intake/SKILL.md +2 -0
  339. package/plugins/lisa-copilot/skills/lisa-linear-claim/SKILL.md +3 -1
  340. package/plugins/lisa-copilot/skills/lisa-linear-read-issue/SKILL.md +13 -0
  341. package/plugins/lisa-copilot/skills/lisa-linear-validate-issue/SKILL.md +26 -0
  342. package/plugins/lisa-copilot/skills/lisa-linear-write-issue/SKILL.md +27 -0
  343. package/plugins/lisa-copilot/skills/lisa-notion-access/SKILL.md +37 -0
  344. package/plugins/lisa-copilot/skills/lisa-notion-access/scripts/readiness-probe.mjs +83 -0
  345. package/plugins/lisa-copilot/skills/lisa-secrets-access/SKILL.md +8 -26
  346. package/plugins/lisa-copilot/skills/lisa-secrets-access/scripts/aws-bootstrap.mjs +89 -117
  347. package/plugins/lisa-copilot/skills/lisa-secrets-access/scripts/config-files.mjs +42 -0
  348. package/plugins/lisa-copilot/skills/lisa-secrets-access/scripts/config-layers.mjs +139 -0
  349. package/plugins/lisa-copilot/skills/lisa-secrets-access/scripts/materialize-secrets.mjs +138 -125
  350. package/plugins/lisa-copilot/skills/lisa-secrets-access/scripts/preflight-secrets.mjs +98 -10
  351. package/plugins/lisa-copilot/skills/lisa-secrets-access/scripts/providers.mjs +24 -1
  352. package/plugins/lisa-copilot/skills/lisa-secrets-access/scripts/routing-floor.mjs +21 -0
  353. package/plugins/lisa-copilot/skills/lisa-secrets-access/scripts/surfaces.mjs +111 -36
  354. package/plugins/lisa-copilot/skills/lisa-secrets-access/scripts/task-access.mjs +205 -0
  355. package/plugins/lisa-copilot/skills/lisa-secrets-access/scripts/task-action.mjs +218 -0
  356. package/plugins/lisa-copilot/skills/lisa-secrets-access/scripts/task-atlassian-native.mjs +181 -0
  357. package/plugins/lisa-copilot/skills/lisa-secrets-access/scripts/task-context-data.mjs +75 -0
  358. package/plugins/lisa-copilot/skills/lisa-secrets-access/scripts/task-context-write.mjs +158 -0
  359. package/plugins/lisa-copilot/skills/lisa-secrets-access/scripts/task-github.mjs +92 -0
  360. package/plugins/lisa-copilot/skills/lisa-secrets-access/scripts/task-intake-read.mjs +171 -0
  361. package/plugins/lisa-copilot/skills/lisa-secrets-access/scripts/task-intake.mjs +155 -0
  362. package/plugins/lisa-copilot/skills/lisa-secrets-access/scripts/task-native-context.mjs +71 -0
  363. package/plugins/lisa-copilot/skills/lisa-secrets-access/scripts/task-native-contract.mjs +156 -0
  364. package/plugins/lisa-copilot/skills/lisa-secrets-access/scripts/task-native-flow.mjs +253 -0
  365. package/plugins/lisa-copilot/skills/lisa-secrets-access/scripts/task-native-lifecycle.mjs +106 -0
  366. package/plugins/lisa-copilot/skills/lisa-secrets-access/scripts/task-native-state.mjs +171 -0
  367. package/plugins/lisa-copilot/skills/lisa-secrets-access/scripts/task-readiness.mjs +347 -0
  368. package/plugins/lisa-copilot/skills/lisa-secrets-access/scripts/task-requirements.mjs +279 -0
  369. package/plugins/lisa-copilot/skills/lisa-secrets-access/scripts/task-tracker-intake.mjs +463 -0
  370. package/plugins/lisa-copilot/skills/lisa-secrets-access/scripts/validate-config.mjs +2 -21
  371. package/plugins/lisa-copilot/skills/lisa-setup-linear/SKILL.md +2 -0
  372. package/plugins/lisa-copilot/skills/lisa-setup-remote-aws/SKILL.md +8 -0
  373. package/plugins/lisa-copilot/skills/lisa-task-decomposition/SKILL.md +1 -0
  374. package/plugins/lisa-copilot/skills/lisa-track/SKILL.md +13 -1
  375. package/plugins/lisa-copilot/skills/lisa-tracker-claim/SKILL.md +2 -0
  376. package/plugins/lisa-copilot/skills/lisa-verify/SKILL.md +4 -1
  377. package/plugins/lisa-cursor/.claude-plugin/plugin.json +1 -1
  378. package/plugins/lisa-cursor/hooks/hooks.json +18 -1
  379. package/plugins/lisa-cursor/hooks/inject-resolved-config.mjs +235 -3
  380. package/plugins/lisa-cursor/hooks/secrets-preflight.sh +42 -0
  381. package/plugins/lisa-cursor/hooks/task-readiness-guard.mjs +96 -0
  382. package/plugins/lisa-cursor/hooks/task-readiness-guard.sh +54 -0
  383. package/plugins/lisa-cursor/rules/coding-philosophy-reference.mdc +48 -0
  384. package/plugins/lisa-cursor/rules/coding-philosophy.mdc +7 -6
  385. package/plugins/lisa-cursor/rules/config-resolution-reference.mdc +4 -1
  386. package/plugins/lisa-cursor/rules/intent-routing-reference.mdc +2 -2
  387. package/plugins/lisa-cursor/rules/tool-access-gate-reference.mdc +160 -0
  388. package/plugins/lisa-cursor/rules/tracked-work-reference.mdc +2 -0
  389. package/plugins/lisa-cursor/rules/work-item-definition-of-ready-reference.mdc +31 -0
  390. package/plugins/lisa-cursor/scripts/install-remote-agent-aws.mjs +3 -2
  391. package/plugins/lisa-cursor/scripts/remote-agent-aws-setup.sh +123 -10
  392. package/plugins/lisa-cursor/skills/lisa-atlassian-access/SKILL.md +13 -0
  393. package/plugins/lisa-cursor/skills/lisa-configure/SKILL.md +19 -7
  394. package/plugins/lisa-cursor/skills/lisa-doctor/SKILL.md +10 -0
  395. package/plugins/lisa-cursor/skills/lisa-drive-pr-to-merge/SKILL.md +9 -0
  396. package/plugins/lisa-cursor/skills/lisa-git-submit-pr/SKILL.md +1 -0
  397. package/plugins/lisa-cursor/skills/lisa-github-build-intake/SKILL.md +2 -0
  398. package/plugins/lisa-cursor/skills/lisa-github-claim/SKILL.md +2 -0
  399. package/plugins/lisa-cursor/skills/lisa-github-read-issue/SKILL.md +29 -0
  400. package/plugins/lisa-cursor/skills/lisa-github-read-issue/read-contract.mjs +70 -0
  401. package/plugins/lisa-cursor/skills/lisa-github-validate-issue/SKILL.md +27 -1
  402. package/plugins/lisa-cursor/skills/lisa-github-write-issue/SKILL.md +23 -0
  403. package/plugins/lisa-cursor/skills/lisa-implement/SKILL.md +15 -2
  404. package/plugins/lisa-cursor/skills/lisa-jira-build-intake/SKILL.md +2 -0
  405. package/plugins/lisa-cursor/skills/lisa-jira-claim/SKILL.md +2 -0
  406. package/plugins/lisa-cursor/skills/lisa-jira-read-ticket/SKILL.md +9 -0
  407. package/plugins/lisa-cursor/skills/lisa-jira-validate-ticket/SKILL.md +27 -1
  408. package/plugins/lisa-cursor/skills/lisa-jira-write-ticket/SKILL.md +23 -0
  409. package/plugins/lisa-cursor/skills/lisa-linear-access/SKILL.md +102 -103
  410. package/plugins/lisa-cursor/skills/lisa-linear-access/scripts/linear-graphql.sh +428 -0
  411. package/plugins/lisa-cursor/skills/lisa-linear-build-intake/SKILL.md +2 -0
  412. package/plugins/lisa-cursor/skills/lisa-linear-claim/SKILL.md +3 -1
  413. package/plugins/lisa-cursor/skills/lisa-linear-read-issue/SKILL.md +13 -0
  414. package/plugins/lisa-cursor/skills/lisa-linear-validate-issue/SKILL.md +26 -0
  415. package/plugins/lisa-cursor/skills/lisa-linear-write-issue/SKILL.md +27 -0
  416. package/plugins/lisa-cursor/skills/lisa-notion-access/SKILL.md +37 -0
  417. package/plugins/lisa-cursor/skills/lisa-notion-access/scripts/readiness-probe.mjs +83 -0
  418. package/plugins/lisa-cursor/skills/lisa-secrets-access/SKILL.md +8 -26
  419. package/plugins/lisa-cursor/skills/lisa-secrets-access/scripts/aws-bootstrap.mjs +89 -117
  420. package/plugins/lisa-cursor/skills/lisa-secrets-access/scripts/config-files.mjs +42 -0
  421. package/plugins/lisa-cursor/skills/lisa-secrets-access/scripts/config-layers.mjs +139 -0
  422. package/plugins/lisa-cursor/skills/lisa-secrets-access/scripts/materialize-secrets.mjs +138 -125
  423. package/plugins/lisa-cursor/skills/lisa-secrets-access/scripts/preflight-secrets.mjs +98 -10
  424. package/plugins/lisa-cursor/skills/lisa-secrets-access/scripts/providers.mjs +24 -1
  425. package/plugins/lisa-cursor/skills/lisa-secrets-access/scripts/routing-floor.mjs +21 -0
  426. package/plugins/lisa-cursor/skills/lisa-secrets-access/scripts/surfaces.mjs +111 -36
  427. package/plugins/lisa-cursor/skills/lisa-secrets-access/scripts/task-access.mjs +205 -0
  428. package/plugins/lisa-cursor/skills/lisa-secrets-access/scripts/task-action.mjs +218 -0
  429. package/plugins/lisa-cursor/skills/lisa-secrets-access/scripts/task-atlassian-native.mjs +181 -0
  430. package/plugins/lisa-cursor/skills/lisa-secrets-access/scripts/task-context-data.mjs +75 -0
  431. package/plugins/lisa-cursor/skills/lisa-secrets-access/scripts/task-context-write.mjs +158 -0
  432. package/plugins/lisa-cursor/skills/lisa-secrets-access/scripts/task-github.mjs +92 -0
  433. package/plugins/lisa-cursor/skills/lisa-secrets-access/scripts/task-intake-read.mjs +171 -0
  434. package/plugins/lisa-cursor/skills/lisa-secrets-access/scripts/task-intake.mjs +155 -0
  435. package/plugins/lisa-cursor/skills/lisa-secrets-access/scripts/task-native-context.mjs +71 -0
  436. package/plugins/lisa-cursor/skills/lisa-secrets-access/scripts/task-native-contract.mjs +156 -0
  437. package/plugins/lisa-cursor/skills/lisa-secrets-access/scripts/task-native-flow.mjs +253 -0
  438. package/plugins/lisa-cursor/skills/lisa-secrets-access/scripts/task-native-lifecycle.mjs +106 -0
  439. package/plugins/lisa-cursor/skills/lisa-secrets-access/scripts/task-native-state.mjs +171 -0
  440. package/plugins/lisa-cursor/skills/lisa-secrets-access/scripts/task-readiness.mjs +347 -0
  441. package/plugins/lisa-cursor/skills/lisa-secrets-access/scripts/task-requirements.mjs +279 -0
  442. package/plugins/lisa-cursor/skills/lisa-secrets-access/scripts/task-tracker-intake.mjs +463 -0
  443. package/plugins/lisa-cursor/skills/lisa-secrets-access/scripts/validate-config.mjs +2 -21
  444. package/plugins/lisa-cursor/skills/lisa-setup-linear/SKILL.md +2 -0
  445. package/plugins/lisa-cursor/skills/lisa-setup-remote-aws/SKILL.md +8 -0
  446. package/plugins/lisa-cursor/skills/lisa-task-decomposition/SKILL.md +1 -0
  447. package/plugins/lisa-cursor/skills/lisa-track/SKILL.md +13 -1
  448. package/plugins/lisa-cursor/skills/lisa-tracker-claim/SKILL.md +2 -0
  449. package/plugins/lisa-cursor/skills/lisa-verify/SKILL.md +4 -1
  450. package/plugins/lisa-devin/.claude-plugin/plugin.json +1 -1
  451. package/plugins/lisa-devin/.devin-plugin/plugin.json +1 -1
  452. package/plugins/lisa-devin/hooks/inject-resolved-config.mjs +235 -3
  453. package/plugins/lisa-devin/hooks/secrets-preflight.sh +42 -0
  454. package/plugins/lisa-devin/hooks/task-readiness-guard.mjs +96 -0
  455. package/plugins/lisa-devin/hooks/task-readiness-guard.sh +54 -0
  456. package/plugins/lisa-devin/hooks.json +43 -1
  457. package/plugins/lisa-devin/rules/eager/coding-philosophy.md +7 -6
  458. package/plugins/lisa-devin/rules/reference/coding-philosophy.md +48 -0
  459. package/plugins/lisa-devin/rules/reference/config-resolution.md +4 -1
  460. package/plugins/lisa-devin/rules/reference/intent-routing.md +2 -2
  461. package/plugins/lisa-devin/rules/reference/tool-access-gate.md +160 -0
  462. package/plugins/lisa-devin/rules/reference/tracked-work.md +2 -0
  463. package/plugins/lisa-devin/rules/reference/work-item-definition-of-ready.md +31 -0
  464. package/plugins/lisa-devin/scripts/install-remote-agent-aws.mjs +3 -2
  465. package/plugins/lisa-devin/scripts/remote-agent-aws-setup.sh +123 -10
  466. package/plugins/lisa-devin/skills/lisa-atlassian-access/SKILL.md +13 -0
  467. package/plugins/lisa-devin/skills/lisa-configure/SKILL.md +19 -7
  468. package/plugins/lisa-devin/skills/lisa-doctor/SKILL.md +10 -0
  469. package/plugins/lisa-devin/skills/lisa-drive-pr-to-merge/SKILL.md +9 -0
  470. package/plugins/lisa-devin/skills/lisa-git-submit-pr/SKILL.md +1 -0
  471. package/plugins/lisa-devin/skills/lisa-github-build-intake/SKILL.md +2 -0
  472. package/plugins/lisa-devin/skills/lisa-github-claim/SKILL.md +2 -0
  473. package/plugins/lisa-devin/skills/lisa-github-read-issue/SKILL.md +29 -0
  474. package/plugins/lisa-devin/skills/lisa-github-read-issue/read-contract.mjs +70 -0
  475. package/plugins/lisa-devin/skills/lisa-github-validate-issue/SKILL.md +27 -1
  476. package/plugins/lisa-devin/skills/lisa-github-write-issue/SKILL.md +23 -0
  477. package/plugins/lisa-devin/skills/lisa-implement/SKILL.md +15 -2
  478. package/plugins/lisa-devin/skills/lisa-jira-build-intake/SKILL.md +2 -0
  479. package/plugins/lisa-devin/skills/lisa-jira-claim/SKILL.md +2 -0
  480. package/plugins/lisa-devin/skills/lisa-jira-read-ticket/SKILL.md +9 -0
  481. package/plugins/lisa-devin/skills/lisa-jira-validate-ticket/SKILL.md +27 -1
  482. package/plugins/lisa-devin/skills/lisa-jira-write-ticket/SKILL.md +23 -0
  483. package/plugins/lisa-devin/skills/lisa-linear-access/SKILL.md +102 -103
  484. package/plugins/lisa-devin/skills/lisa-linear-access/scripts/linear-graphql.sh +428 -0
  485. package/plugins/lisa-devin/skills/lisa-linear-build-intake/SKILL.md +2 -0
  486. package/plugins/lisa-devin/skills/lisa-linear-claim/SKILL.md +3 -1
  487. package/plugins/lisa-devin/skills/lisa-linear-read-issue/SKILL.md +13 -0
  488. package/plugins/lisa-devin/skills/lisa-linear-validate-issue/SKILL.md +26 -0
  489. package/plugins/lisa-devin/skills/lisa-linear-write-issue/SKILL.md +27 -0
  490. package/plugins/lisa-devin/skills/lisa-notion-access/SKILL.md +37 -0
  491. package/plugins/lisa-devin/skills/lisa-notion-access/scripts/readiness-probe.mjs +83 -0
  492. package/plugins/lisa-devin/skills/lisa-secrets-access/SKILL.md +8 -26
  493. package/plugins/lisa-devin/skills/lisa-secrets-access/scripts/aws-bootstrap.mjs +89 -117
  494. package/plugins/lisa-devin/skills/lisa-secrets-access/scripts/config-files.mjs +42 -0
  495. package/plugins/lisa-devin/skills/lisa-secrets-access/scripts/config-layers.mjs +139 -0
  496. package/plugins/lisa-devin/skills/lisa-secrets-access/scripts/materialize-secrets.mjs +138 -125
  497. package/plugins/lisa-devin/skills/lisa-secrets-access/scripts/preflight-secrets.mjs +98 -10
  498. package/plugins/lisa-devin/skills/lisa-secrets-access/scripts/providers.mjs +24 -1
  499. package/plugins/lisa-devin/skills/lisa-secrets-access/scripts/routing-floor.mjs +21 -0
  500. package/plugins/lisa-devin/skills/lisa-secrets-access/scripts/surfaces.mjs +111 -36
  501. package/plugins/lisa-devin/skills/lisa-secrets-access/scripts/task-access.mjs +205 -0
  502. package/plugins/lisa-devin/skills/lisa-secrets-access/scripts/task-action.mjs +218 -0
  503. package/plugins/lisa-devin/skills/lisa-secrets-access/scripts/task-atlassian-native.mjs +181 -0
  504. package/plugins/lisa-devin/skills/lisa-secrets-access/scripts/task-context-data.mjs +75 -0
  505. package/plugins/lisa-devin/skills/lisa-secrets-access/scripts/task-context-write.mjs +158 -0
  506. package/plugins/lisa-devin/skills/lisa-secrets-access/scripts/task-github.mjs +92 -0
  507. package/plugins/lisa-devin/skills/lisa-secrets-access/scripts/task-intake-read.mjs +171 -0
  508. package/plugins/lisa-devin/skills/lisa-secrets-access/scripts/task-intake.mjs +155 -0
  509. package/plugins/lisa-devin/skills/lisa-secrets-access/scripts/task-native-context.mjs +71 -0
  510. package/plugins/lisa-devin/skills/lisa-secrets-access/scripts/task-native-contract.mjs +156 -0
  511. package/plugins/lisa-devin/skills/lisa-secrets-access/scripts/task-native-flow.mjs +253 -0
  512. package/plugins/lisa-devin/skills/lisa-secrets-access/scripts/task-native-lifecycle.mjs +106 -0
  513. package/plugins/lisa-devin/skills/lisa-secrets-access/scripts/task-native-state.mjs +171 -0
  514. package/plugins/lisa-devin/skills/lisa-secrets-access/scripts/task-readiness.mjs +347 -0
  515. package/plugins/lisa-devin/skills/lisa-secrets-access/scripts/task-requirements.mjs +279 -0
  516. package/plugins/lisa-devin/skills/lisa-secrets-access/scripts/task-tracker-intake.mjs +463 -0
  517. package/plugins/lisa-devin/skills/lisa-secrets-access/scripts/validate-config.mjs +2 -21
  518. package/plugins/lisa-devin/skills/lisa-setup-linear/SKILL.md +2 -0
  519. package/plugins/lisa-devin/skills/lisa-setup-remote-aws/SKILL.md +8 -0
  520. package/plugins/lisa-devin/skills/lisa-task-decomposition/SKILL.md +1 -0
  521. package/plugins/lisa-devin/skills/lisa-track/SKILL.md +13 -1
  522. package/plugins/lisa-devin/skills/lisa-tracker-claim/SKILL.md +2 -0
  523. package/plugins/lisa-devin/skills/lisa-verify/SKILL.md +4 -1
  524. package/plugins/lisa-expo/.claude-plugin/plugin.json +1 -1
  525. package/plugins/lisa-expo/.codex-plugin/plugin.json +1 -1
  526. package/plugins/lisa-expo-agy/plugin.json +1 -1
  527. package/plugins/lisa-expo-copilot/.claude-plugin/plugin.json +1 -1
  528. package/plugins/lisa-expo-cursor/.claude-plugin/plugin.json +1 -1
  529. package/plugins/lisa-expo-devin/.claude-plugin/plugin.json +1 -1
  530. package/plugins/lisa-expo-devin/.devin-plugin/plugin.json +1 -1
  531. package/plugins/lisa-harper-fabric/.claude-plugin/plugin.json +1 -1
  532. package/plugins/lisa-harper-fabric/.codex-plugin/plugin.json +1 -1
  533. package/plugins/lisa-harper-fabric-agy/plugin.json +1 -1
  534. package/plugins/lisa-harper-fabric-copilot/.claude-plugin/plugin.json +1 -1
  535. package/plugins/lisa-harper-fabric-cursor/.claude-plugin/plugin.json +1 -1
  536. package/plugins/lisa-harper-fabric-devin/.claude-plugin/plugin.json +1 -1
  537. package/plugins/lisa-harper-fabric-devin/.devin-plugin/plugin.json +1 -1
  538. package/plugins/lisa-nestjs/.claude-plugin/plugin.json +1 -1
  539. package/plugins/lisa-nestjs/.codex-plugin/plugin.json +1 -1
  540. package/plugins/lisa-nestjs-agy/plugin.json +1 -1
  541. package/plugins/lisa-nestjs-copilot/.claude-plugin/plugin.json +1 -1
  542. package/plugins/lisa-nestjs-cursor/.claude-plugin/plugin.json +1 -1
  543. package/plugins/lisa-nestjs-devin/.claude-plugin/plugin.json +1 -1
  544. package/plugins/lisa-nestjs-devin/.devin-plugin/plugin.json +1 -1
  545. package/plugins/lisa-phaser/.claude-plugin/plugin.json +1 -1
  546. package/plugins/lisa-phaser/.codex-plugin/plugin.json +1 -1
  547. package/plugins/lisa-phaser-agy/plugin.json +1 -1
  548. package/plugins/lisa-phaser-copilot/.claude-plugin/plugin.json +1 -1
  549. package/plugins/lisa-phaser-cursor/.claude-plugin/plugin.json +1 -1
  550. package/plugins/lisa-phaser-devin/.claude-plugin/plugin.json +1 -1
  551. package/plugins/lisa-phaser-devin/.devin-plugin/plugin.json +1 -1
  552. package/plugins/lisa-rails/.claude-plugin/plugin.json +1 -1
  553. package/plugins/lisa-rails/.codex-plugin/plugin.json +1 -1
  554. package/plugins/lisa-rails-agy/plugin.json +1 -1
  555. package/plugins/lisa-rails-copilot/.claude-plugin/plugin.json +1 -1
  556. package/plugins/lisa-rails-cursor/.claude-plugin/plugin.json +1 -1
  557. package/plugins/lisa-rails-devin/.claude-plugin/plugin.json +1 -1
  558. package/plugins/lisa-rails-devin/.devin-plugin/plugin.json +1 -1
  559. package/plugins/lisa-typescript/.claude-plugin/plugin.json +1 -1
  560. package/plugins/lisa-typescript/.codex-plugin/plugin.json +1 -1
  561. package/plugins/lisa-typescript-agy/plugin.json +1 -1
  562. package/plugins/lisa-typescript-copilot/.claude-plugin/plugin.json +1 -1
  563. package/plugins/lisa-typescript-cursor/.claude-plugin/plugin.json +1 -1
  564. package/plugins/lisa-typescript-devin/.claude-plugin/plugin.json +1 -1
  565. package/plugins/lisa-typescript-devin/.devin-plugin/plugin.json +1 -1
  566. package/plugins/lisa-wiki/.claude-plugin/plugin.json +1 -1
  567. package/plugins/lisa-wiki/.codex-plugin/plugin.json +1 -1
  568. package/plugins/lisa-wiki-agy/plugin.json +1 -1
  569. package/plugins/lisa-wiki-copilot/.claude-plugin/plugin.json +1 -1
  570. package/plugins/lisa-wiki-cursor/.claude-plugin/plugin.json +1 -1
  571. package/plugins/lisa-wiki-devin/.claude-plugin/plugin.json +1 -1
  572. package/plugins/lisa-wiki-devin/.devin-plugin/plugin.json +1 -1
  573. package/plugins/materialized-artifacts.json +2 -0
  574. package/plugins/src/base/.claude-plugin/plugin.json +25 -1
  575. package/plugins/src/base/hooks/inject-resolved-config.mjs +235 -3
  576. package/plugins/src/base/hooks/secrets-preflight.agy.sh +19 -0
  577. package/plugins/src/base/hooks/secrets-preflight.sh +42 -0
  578. package/plugins/src/base/hooks/task-readiness-guard.mjs +96 -0
  579. package/plugins/src/base/hooks/task-readiness-guard.sh +51 -0
  580. package/plugins/src/base/rules/eager/coding-philosophy.md +7 -6
  581. package/plugins/src/base/rules/reference/coding-philosophy.md +48 -0
  582. package/plugins/src/base/rules/reference/config-resolution.md +4 -1
  583. package/plugins/src/base/rules/reference/intent-routing.md +2 -2
  584. package/plugins/src/base/rules/reference/tool-access-gate.md +160 -0
  585. package/plugins/src/base/rules/reference/tracked-work.md +2 -0
  586. package/plugins/src/base/rules/reference/work-item-definition-of-ready.md +31 -0
  587. package/plugins/src/base/scripts/install-remote-agent-aws.mjs +3 -2
  588. package/plugins/src/base/scripts/remote-agent-aws-setup.sh +123 -10
  589. package/plugins/src/base/skills/lisa-atlassian-access/SKILL.md +13 -0
  590. package/plugins/src/base/skills/lisa-configure/SKILL.md +19 -7
  591. package/plugins/src/base/skills/lisa-doctor/SKILL.md +10 -0
  592. package/plugins/src/base/skills/lisa-drive-pr-to-merge/SKILL.md +9 -0
  593. package/plugins/src/base/skills/lisa-git-submit-pr/SKILL.md +1 -0
  594. package/plugins/src/base/skills/lisa-github-build-intake/SKILL.md +2 -0
  595. package/plugins/src/base/skills/lisa-github-claim/SKILL.md +2 -0
  596. package/plugins/src/base/skills/lisa-github-read-issue/SKILL.md +29 -0
  597. package/plugins/src/base/skills/lisa-github-read-issue/read-contract.mjs +70 -0
  598. package/plugins/src/base/skills/lisa-github-validate-issue/SKILL.md +27 -1
  599. package/plugins/src/base/skills/lisa-github-write-issue/SKILL.md +23 -0
  600. package/plugins/src/base/skills/lisa-implement/SKILL.md +15 -2
  601. package/plugins/src/base/skills/lisa-jira-build-intake/SKILL.md +2 -0
  602. package/plugins/src/base/skills/lisa-jira-claim/SKILL.md +2 -0
  603. package/plugins/src/base/skills/lisa-jira-read-ticket/SKILL.md +9 -0
  604. package/plugins/src/base/skills/lisa-jira-validate-ticket/SKILL.md +27 -1
  605. package/plugins/src/base/skills/lisa-jira-write-ticket/SKILL.md +23 -0
  606. package/plugins/src/base/skills/lisa-linear-access/SKILL.md +102 -103
  607. package/plugins/src/base/skills/lisa-linear-access/scripts/linear-graphql.sh +428 -0
  608. package/plugins/src/base/skills/lisa-linear-build-intake/SKILL.md +2 -0
  609. package/plugins/src/base/skills/lisa-linear-claim/SKILL.md +3 -1
  610. package/plugins/src/base/skills/lisa-linear-read-issue/SKILL.md +13 -0
  611. package/plugins/src/base/skills/lisa-linear-validate-issue/SKILL.md +26 -0
  612. package/plugins/src/base/skills/lisa-linear-write-issue/SKILL.md +27 -0
  613. package/plugins/src/base/skills/lisa-notion-access/SKILL.md +37 -0
  614. package/plugins/src/base/skills/lisa-notion-access/scripts/readiness-probe.mjs +83 -0
  615. package/plugins/src/base/skills/lisa-secrets-access/SKILL.md +8 -26
  616. package/plugins/src/base/skills/lisa-secrets-access/scripts/aws-bootstrap.mjs +89 -117
  617. package/plugins/src/base/skills/lisa-secrets-access/scripts/config-files.mjs +42 -0
  618. package/plugins/src/base/skills/lisa-secrets-access/scripts/config-layers.mjs +139 -0
  619. package/plugins/src/base/skills/lisa-secrets-access/scripts/materialize-secrets.mjs +138 -125
  620. package/plugins/src/base/skills/lisa-secrets-access/scripts/preflight-secrets.mjs +98 -10
  621. package/plugins/src/base/skills/lisa-secrets-access/scripts/providers.mjs +24 -1
  622. package/plugins/src/base/skills/lisa-secrets-access/scripts/routing-floor.mjs +21 -0
  623. package/plugins/src/base/skills/lisa-secrets-access/scripts/surfaces.mjs +111 -36
  624. package/plugins/src/base/skills/lisa-secrets-access/scripts/task-access.mjs +205 -0
  625. package/plugins/src/base/skills/lisa-secrets-access/scripts/task-action.mjs +218 -0
  626. package/plugins/src/base/skills/lisa-secrets-access/scripts/task-atlassian-native.mjs +181 -0
  627. package/plugins/src/base/skills/lisa-secrets-access/scripts/task-context-data.mjs +75 -0
  628. package/plugins/src/base/skills/lisa-secrets-access/scripts/task-context-write.mjs +158 -0
  629. package/plugins/src/base/skills/lisa-secrets-access/scripts/task-github.mjs +92 -0
  630. package/plugins/src/base/skills/lisa-secrets-access/scripts/task-intake-read.mjs +171 -0
  631. package/plugins/src/base/skills/lisa-secrets-access/scripts/task-intake.mjs +155 -0
  632. package/plugins/src/base/skills/lisa-secrets-access/scripts/task-native-context.mjs +71 -0
  633. package/plugins/src/base/skills/lisa-secrets-access/scripts/task-native-contract.mjs +156 -0
  634. package/plugins/src/base/skills/lisa-secrets-access/scripts/task-native-flow.mjs +253 -0
  635. package/plugins/src/base/skills/lisa-secrets-access/scripts/task-native-lifecycle.mjs +106 -0
  636. package/plugins/src/base/skills/lisa-secrets-access/scripts/task-native-state.mjs +171 -0
  637. package/plugins/src/base/skills/lisa-secrets-access/scripts/task-readiness.mjs +347 -0
  638. package/plugins/src/base/skills/lisa-secrets-access/scripts/task-requirements.mjs +279 -0
  639. package/plugins/src/base/skills/lisa-secrets-access/scripts/task-tracker-intake.mjs +463 -0
  640. package/plugins/src/base/skills/lisa-secrets-access/scripts/validate-config.mjs +2 -21
  641. package/plugins/src/base/skills/lisa-setup-linear/SKILL.md +2 -0
  642. package/plugins/src/base/skills/lisa-setup-remote-aws/SKILL.md +8 -0
  643. package/plugins/src/base/skills/lisa-task-decomposition/SKILL.md +1 -0
  644. package/plugins/src/base/skills/lisa-track/SKILL.md +13 -1
  645. package/plugins/src/base/skills/lisa-tracker-claim/SKILL.md +2 -0
  646. package/plugins/src/base/skills/lisa-verify/SKILL.md +4 -1
  647. package/scripts/build-plugins.sh +1 -1
  648. package/scripts/copy-opencode-plugin-templates.mjs +2 -0
  649. package/scripts/generate-agy-plugin-artifacts.mjs +8 -0
  650. package/scripts/lib/per-agent-hook-filter.mjs +1 -1
  651. package/scripts/lisa-enforcement-fallback.sh +3 -3
  652. package/scripts/lisa-enforcement-freshness.mjs +1 -0
  653. package/scripts/lisa-release-switch.mjs +9 -0
  654. package/scripts/two-channel-couplings.json +2 -2
  655. package/typescript/copy-overwrite/.prettierignore +2 -0
  656. package/typescript/create-only/.lisa/controls/proofs/lisa-typescript-code-style-slow.clean.patch +25 -0
  657. package/typescript/create-only/.lisa/controls/proofs/lisa-typescript-code-style-slow.violation.patch +28 -0
  658. package/typescript/create-only/.lisa/controls/proofs/lisa-typescript-code-style.clean.patch +13 -0
  659. package/typescript/create-only/.lisa/controls/proofs/lisa-typescript-code-style.violation.patch +13 -0
  660. package/typescript/create-only/.lisa/controls/proofs/lisa-typescript-coverage-adequacy.clean.patch +6 -0
  661. package/typescript/create-only/.lisa/controls/proofs/lisa-typescript-coverage-adequacy.violation.patch +7 -0
  662. package/typescript/create-only/.lisa/controls/proofs/lisa-typescript-dead-code.clean.patch +7 -0
  663. package/typescript/create-only/.lisa/controls/proofs/lisa-typescript-dead-code.violation.patch +7 -0
  664. package/typescript/create-only/.lisa/controls/proofs/lisa-typescript-dependency-vulnerability.clean.patch +6 -0
  665. package/typescript/create-only/.lisa/controls/proofs/lisa-typescript-dependency-vulnerability.violation.patch +6 -0
  666. package/typescript/create-only/.lisa/controls/proofs/lisa-typescript-format-conformance.clean.patch +8 -0
  667. package/typescript/create-only/.lisa/controls/proofs/lisa-typescript-format-conformance.violation.patch +7 -0
  668. package/typescript/create-only/.lisa/controls/proofs/lisa-typescript-structural-rules.clean.patch +14 -0
  669. package/typescript/create-only/.lisa/controls/proofs/lisa-typescript-structural-rules.violation.patch +14 -0
  670. package/typescript/create-only/.lisa/controls/proofs/lisa-typescript-test-correctness.clean.patch +10 -0
  671. package/typescript/create-only/.lisa/controls/proofs/lisa-typescript-test-correctness.violation.patch +10 -0
  672. package/typescript/create-only/.lisa/controls/proofs/lisa-typescript-test-integration.clean.patch +10 -0
  673. package/typescript/create-only/.lisa/controls/proofs/lisa-typescript-test-integration.violation.patch +10 -0
  674. package/typescript/create-only/.lisa/controls/proofs/lisa-typescript-traceability.clean.patch +6 -0
  675. package/typescript/create-only/.lisa/controls/proofs/lisa-typescript-traceability.violation.patch +6 -0
  676. package/typescript/create-only/.lisa/controls/proofs/lisa-typescript-type-correctness.clean.patch +10 -0
  677. package/typescript/create-only/.lisa/controls/proofs/lisa-typescript-type-correctness.violation.patch +10 -0
  678. package/typescript/package-lisa/package.lisa.json +2 -3
@@ -0,0 +1,1049 @@
1
+ // This file is managed by Lisa and IS replaced on each `lisa` run.
2
+ // Do not edit directly — durable changes belong upstream in Lisa.
3
+
4
+ /**
5
+ * The always-promotable contract (CodySwannGT/lisa#5188): one definition of
6
+ * the project setting, the work-item declaration and the checks built on them.
7
+ *
8
+ * The rule: whatever is on a shared branch can be promoted to the next
9
+ * environment as it stands. Most changes meet it by being complete and proven
10
+ * when they merge. Only new behavior that merges before it is finished or
11
+ * verified is switched off, and that switch is removed afterwards.
12
+ *
13
+ * Three things live here so that the validators, the writers, the completion
14
+ * checker, the doctor check and the session-start hook cannot drift apart:
15
+ *
16
+ * 1. `release.*` in `.lisa.config.json`. `release.liveUsers` is a fact about
17
+ * the project, not an "off" flag for a rule: a project with no users has
18
+ * nothing to protect. Absent means the project HAS live users, and a value
19
+ * that is not a boolean is reported and treated as `true`, the stricter
20
+ * option (the same convention as `workItem.estimate.required`).
21
+ * 2. The `## Release Switch` declaration on a work item: live, or switched off
22
+ * behind a named switch that a named work item removes.
23
+ * 3. The switch-removal check: a work item that owns the removal of a switch
24
+ * is not finished while tracked source still references that switch.
25
+ *
26
+ * Lisa deliberately knows nothing about any flag service. A project names its
27
+ * mechanism; this module only carries the name to the agent.
28
+ * @module scripts/lib/release-switch
29
+ */
30
+ import { spawnSync } from "node:child_process";
31
+ import { existsSync, readFileSync } from "node:fs";
32
+ import { join } from "node:path";
33
+
34
+ import {
35
+ headingKey,
36
+ markdownSection,
37
+ topLevelLines,
38
+ } from "./completion-proof-markdown.mjs";
39
+
40
+ /** Heading of the work-item section that carries the declaration. */
41
+ export const RELEASE_SWITCH_HEADING = "Release Switch";
42
+
43
+ /** The decision class a project lists in `humanGate.humanOnly` to reserve the production turn-on for a person. */
44
+ export const RELEASE_DECISION_CLASS = "feature-release";
45
+
46
+ /** What an agent uses when a project names no mechanism: a plain configuration value that defaults to off. */
47
+ export const FALLBACK_MECHANISM = "config-value";
48
+
49
+ /** The exact text of the live declaration. */
50
+ export const LIVE_DECLARATION = "Live — complete and proven at merge";
51
+
52
+ /** A switch-removal owner written as the item itself. */
53
+ export const THIS_ITEM = "this item";
54
+
55
+ /** Thrown for input this module cannot act on; the CLI maps it to exit 2. */
56
+ export class ReleaseSwitchError extends Error {}
57
+
58
+ const SWITCH_NAME = /^[A-Za-z0-9][A-Za-z0-9._:/-]{2,63}$/;
59
+ // One small pattern per tracker shape (owner/repo#12, #12, ENG-12) instead of
60
+ // one alternation: each stays linear to match and readable on its own.
61
+ const WORK_ITEM_REF_FORMS = [
62
+ /^[\w.-]+\/[\w.-]+#[1-9]\d*$/,
63
+ /^#[1-9]\d*$/,
64
+ /^[A-Z][A-Z0-9]+-[1-9]\d*$/,
65
+ ];
66
+ const isWorkItemRef = value =>
67
+ WORK_ITEM_REF_FORMS.some(form => form.test(value));
68
+ // The rendered form uses an em dash. An en dash, a hyphen and a double hyphen
69
+ // are read as the same thing, because that is what people and editors type.
70
+ const LIVE = /^Live\s*(?:--|[—–-])\s*complete and proven at merge\.?$/i;
71
+ const SWITCHED_OFF_LABEL = "switched off";
72
+ const REMOVED_BY_LABEL = "removed by";
73
+ const DASHES = ["--", "—", "–", "-"];
74
+
75
+ /**
76
+ * The text after `<label> —`, read with string operations so a long or odd
77
+ * line cannot make a pattern backtrack.
78
+ * @param {string} line - One declaration line.
79
+ * @param {string} label - Lower-case label the line must start with.
80
+ * @returns {string|null} Trimmed remainder, or `null` when the line has another shape.
81
+ */
82
+ function afterLabel(line, label) {
83
+ if (!line.toLowerCase().startsWith(label)) return null;
84
+ const rest = line.slice(label.length).trimStart();
85
+ const dash = DASHES.find(candidate => rest.startsWith(candidate));
86
+ return dash === undefined ? null : rest.slice(dash.length).trim();
87
+ }
88
+
89
+ // JIRA descriptions are written in wiki markup, where a section heading is
90
+ // `h2. Name` and not `## Name`. Both spellings are the same heading here, so a
91
+ // ticket in the JIRA writer's own shape is read like any other.
92
+ //
93
+ // Wiki code blocks (`{code}` … `{code}`) are deliberately NOT understood. An
94
+ // earlier version skipped headings quoted inside them, and every way of
95
+ // pairing the markers could be fooled into hiding the real declaration below a
96
+ // stray one, which let the done gate close an item whose switch was still in
97
+ // use. Without it, a ticket that quotes the section inside a wiki code block
98
+ // has two declarations and is refused as ambiguous: it fails closed.
99
+ const WIKI_HEADING = /^h([1-6])\.[ \t]+/;
100
+
101
+ /**
102
+ * A body with wiki-markup headings rewritten as markdown ones, line for line.
103
+ * @param {string} body - Work-item body.
104
+ * @returns {string} The same lines, with `hN. ` headings as `#` headings.
105
+ */
106
+ function markdownHeadings(body) {
107
+ return body
108
+ .split("\n")
109
+ .map(line => {
110
+ const wiki = WIKI_HEADING.exec(line);
111
+ return wiki
112
+ ? `${"#".repeat(Number(wiki[1]))} ${line.slice(wiki[0].length)}`
113
+ : line;
114
+ })
115
+ .join("\n");
116
+ }
117
+
118
+ // A `None —` declaration is how `## Target Backend Environment` says the item
119
+ // changes no runtime behavior (or is a container). The em dash is the machine
120
+ // discriminator the validators already use (gate S8).
121
+ const NO_RUNTIME = /^None\s*[—-]/i;
122
+
123
+ const isObject = value =>
124
+ value !== null && typeof value === "object" && !Array.isArray(value);
125
+
126
+ /**
127
+ * A rejected setting value as it may be shown to a person or put in a
128
+ * session's context. An object or a list is named by its kind only: whatever
129
+ * someone put inside a setting that should have been a word or a yes/no is not
130
+ * ours to print, and it could be a credential.
131
+ * @param {unknown} value - The value a project declared.
132
+ * @returns {string} Text safe to show.
133
+ */
134
+ export function shown(value) {
135
+ if (Array.isArray(value)) return "a list";
136
+ if (value !== null && typeof value === "object") return "an object";
137
+ if (typeof value !== "string") return JSON.stringify(value);
138
+ // A mistyped yes/no or mechanism name is a short plain word, and showing it
139
+ // helps ("no", "false", "hosted flags"). Anything else is not what belonged
140
+ // in the setting, and it is described, never quoted: a URL with a password
141
+ // in it stays a credential however much of it is cut off.
142
+ return PLAIN_WORD.test(value)
143
+ ? JSON.stringify(value)
144
+ : `a string of ${value.length} characters`;
145
+ }
146
+
147
+ /** A short value made only of letters, digits, spaces, dots, underscores and hyphens. */
148
+ const PLAIN_WORD = /^[\w .-]{0,40}$/;
149
+
150
+ const text = value =>
151
+ typeof value === "string" && value.trim().length > 0 ? value.trim() : null;
152
+
153
+ const readJson = path =>
154
+ existsSync(path) ? JSON.parse(readFileSync(path, "utf8")) : {};
155
+
156
+ /**
157
+ * The project's Lisa config with `.lisa.config.local.json` layered on top,
158
+ * key by key. One reader for the CLI and the doctor check, so the two cannot
159
+ * disagree about which file wins.
160
+ * @param {string} cwd - Project root.
161
+ * @returns {object} Effective config.
162
+ */
163
+ export function readProjectConfig(cwd) {
164
+ const merge = (base, override) => {
165
+ // Only an ABSENT local key falls back. A local `null` is a declared value
166
+ // (an invalid one), read the same way the session-start hook and the
167
+ // completion checker read it.
168
+ if (override === undefined) return base;
169
+ if (!isObject(base) || !isObject(override)) return override;
170
+ const keys = new Set([...Object.keys(base), ...Object.keys(override)]);
171
+ return Object.fromEntries(
172
+ [...keys].map(key => [
173
+ key,
174
+ key in override ? merge(base[key], override[key]) : base[key],
175
+ ])
176
+ );
177
+ };
178
+ const committed = readJson(join(cwd, ".lisa.config.json"));
179
+ // A config file that is not an object is handed back as it is, so the
180
+ // problem can be reported; merging would quietly turn it into `{}`.
181
+ if (!isObject(committed)) return committed;
182
+ return merge(committed, readJson(join(cwd, ".lisa.config.local.json")));
183
+ }
184
+
185
+ /**
186
+ * Problems for keys a settings block carries that Lisa does not read.
187
+ * @param {object} block - The settings block.
188
+ * @param {string[]} known - Keys Lisa reads.
189
+ * @param {string} path - Dotted path of the block, for the message.
190
+ * @returns {string[]} One problem per unknown key.
191
+ */
192
+ function unknownKeys(block, known, path) {
193
+ return Object.keys(block)
194
+ .filter(key => !known.includes(key) && !key.startsWith("_"))
195
+ .map(key => {
196
+ const near = known.find(
197
+ candidate => candidate.toLowerCase() === key.toLowerCase()
198
+ );
199
+ return `${path}.${key} is not a setting Lisa reads${near ? `; did you mean ${path}.${near}?` : `; the settings are ${known.map(name => `${path}.${name}`).join(" and ")}.`}`;
200
+ });
201
+ }
202
+
203
+ /**
204
+ * The comparable form of a decision class: lower case, with hyphens,
205
+ * underscores and slashes read as spaces. It mirrors `normalizeGateText` in
206
+ * the plugin's `intake-blocker-reprobe.mjs` (not importable from a shipped
207
+ * script), which is what decides whether a hold naming the class is valid; a
208
+ * test pins the two together. Without it `"Feature Release"` would hold a
209
+ * ticket for a person while this module told the agent to go ahead.
210
+ * @param {unknown} value - A decision class as a project wrote it.
211
+ * @returns {string} Normalized text.
212
+ */
213
+ function decisionClassKey(value) {
214
+ return String(value ?? "")
215
+ .toLowerCase()
216
+ .replace(/[-_/]+/g, " ")
217
+ .replace(/[^a-z0-9' ]+/g, " ")
218
+ .replace(/'/g, "")
219
+ .replace(/\s+/g, " ")
220
+ .trim();
221
+ }
222
+
223
+ /**
224
+ * Who turns a finished, switched-off feature on in production: the agent,
225
+ * unless the project reserved that decision for a person by listing
226
+ * `feature-release` in `humanGate.humanOnly`.
227
+ * @param {object} [config] - Effective project config.
228
+ * @returns {"agent"|"human"} Who performs the turn-on.
229
+ */
230
+ export function turnOnOwner(config = {}) {
231
+ const declared = config?.humanGate?.humanOnly;
232
+ // A project that wrote the class as a bare string meant to reserve the step.
233
+ // Reading that as "not reserved" would hand a production turn-on to the
234
+ // agent because of a typing mistake, so it is read as a one-item list here
235
+ // and reported by {@link turnOnProblems}.
236
+ const reserved = (
237
+ Array.isArray(declared)
238
+ ? declared
239
+ : typeof declared === "string"
240
+ ? [declared]
241
+ : []
242
+ ).filter(entry => typeof entry === "string");
243
+ const wanted = decisionClassKey(RELEASE_DECISION_CLASS);
244
+ return reserved.some(entry => decisionClassKey(entry) === wanted)
245
+ ? "human"
246
+ : "agent";
247
+ }
248
+
249
+ /**
250
+ * Problems with how the project reserved decisions for a person, as far as
251
+ * they affect the production turn-on.
252
+ * @param {object} [config] - Effective project config.
253
+ * @returns {string[]} Problems, empty when `humanGate.humanOnly` is absent or a list.
254
+ */
255
+ export function turnOnProblems(config = {}) {
256
+ const declared = config?.humanGate?.humanOnly;
257
+ if (Array.isArray(declared))
258
+ // An entry that is not text names no decision class. It is reported and
259
+ // skipped, so one bad entry cannot hide a valid reservation beside it.
260
+ return declared.some(entry => typeof entry !== "string")
261
+ ? [
262
+ `humanGate.humanOnly holds an entry that is not text; each entry is a decision class such as "${RELEASE_DECISION_CLASS}". That entry is ignored.`,
263
+ ]
264
+ : [];
265
+ return declared === undefined
266
+ ? []
267
+ : [
268
+ `humanGate.humanOnly is ${shown(declared)}, which is not a list; write it as a list such as ["${RELEASE_DECISION_CLASS}"]. Until then the production turn-on is treated as ${turnOnOwner(config) === "human" ? "reserved for a person" : "the agent's"}.`,
269
+ ];
270
+ }
271
+
272
+ /**
273
+ * Every problem with how a project set this rule up: invalid `release.*`
274
+ * values, a `humanGate.humanOnly` that is not a list, and a production branch
275
+ * that cannot be read while the project is marked as having no live users (the
276
+ * notice that keeps that opt-out visible could then never print). One list for
277
+ * the CLI and the doctor check, so neither reports less than the other.
278
+ * @param {object} [config] - Effective project config.
279
+ * @returns {string[]} Problems, empty when the setup is sound.
280
+ */
281
+ export function setupProblems(config = {}) {
282
+ if (!isObject(config))
283
+ return [
284
+ "The Lisa configuration is not a JSON object, so no release setting can be read from it; the project is treated as having live users.",
285
+ ];
286
+ const setting = resolveReleaseSetting(config);
287
+ return [
288
+ ...setting.problems,
289
+ ...turnOnProblems(config),
290
+ ...(!setting.liveUsers && productionBranch(config) === null
291
+ ? [
292
+ "release.liveUsers is false, but deploy.branches does not name one production branch (it has no production environment, or prod and production name different branches), so the notice on production deployments cannot be printed.",
293
+ ]
294
+ : []),
295
+ ];
296
+ }
297
+
298
+ /**
299
+ * Resolve `release.*` from an effective project config.
300
+ *
301
+ * Nothing here throws on a bad value: a malformed setting is reported in
302
+ * `problems` and the stricter reading is used, so one typo cannot silently
303
+ * turn the rule off, and cannot stop a session either.
304
+ * @param {object} [config] - Effective `.lisa.config.json` (local overrides applied).
305
+ * @returns {{liveUsers: boolean, liveUsersSource: "declared"|"default"|"invalid", mechanism: string, mechanismSource: "declared"|"default", guide: string|null, problems: string[]}} Resolved setting.
306
+ */
307
+ export function resolveReleaseSetting(config = {}) {
308
+ const declared = isObject(config) ? config.release : undefined;
309
+ const block = isObject(declared) ? declared : {};
310
+ const switchBlock = isObject(block.switch) ? block.switch : {};
311
+ const liveDeclared = Object.hasOwn(block, "liveUsers");
312
+ const liveValid = typeof block.liveUsers === "boolean";
313
+ const mechanism = text(switchBlock.mechanism);
314
+ const problems = [
315
+ ...(declared === undefined || isObject(declared)
316
+ ? []
317
+ : [
318
+ `release is ${shown(declared)}, which is not an object; treated as not set.`,
319
+ ]),
320
+ ...(liveDeclared && !liveValid
321
+ ? [
322
+ `release.liveUsers is ${shown(block.liveUsers)}, which is not true or false; treated as true (the project has live users).`,
323
+ ]
324
+ : []),
325
+ ...(block.switch === undefined || isObject(block.switch)
326
+ ? []
327
+ : [
328
+ `release.switch is ${shown(block.switch)}, which is not an object; treated as not set.`,
329
+ ]),
330
+ ...["mechanism", "guide"].flatMap(key =>
331
+ Object.hasOwn(switchBlock, key) && text(switchBlock[key]) === null
332
+ ? [
333
+ `release.switch.${key} is ${shown(switchBlock[key])}, which is not a non-empty string; treated as not set.`,
334
+ ]
335
+ : []
336
+ ),
337
+ // A misspelt key is the quiet way to believe the rule is off when it is
338
+ // not, so every key Lisa does not read is named.
339
+ ...unknownKeys(block, ["liveUsers", "switch"], "release"),
340
+ ...unknownKeys(switchBlock, ["mechanism", "guide"], "release.switch"),
341
+ ];
342
+ return {
343
+ liveUsers: liveValid ? block.liveUsers : true,
344
+ liveUsersSource: !liveDeclared
345
+ ? "default"
346
+ : liveValid
347
+ ? "declared"
348
+ : "invalid",
349
+ mechanism: mechanism ?? FALLBACK_MECHANISM,
350
+ mechanismSource: mechanism === null ? "default" : "declared",
351
+ guide: text(switchBlock.guide),
352
+ problems,
353
+ };
354
+ }
355
+
356
+ /**
357
+ * Whether an item changes runtime behavior, read off its stored
358
+ * `## Target Backend Environment` declaration.
359
+ *
360
+ * An absent section is `underivable`, never "no": reading absence as "no" is
361
+ * the assumption that once made the environment gates undecidable on a live
362
+ * item, and this gate inherits the same case table on purpose.
363
+ * @param {string} body - Work-item body.
364
+ * @returns {"runtime"|"none"|"underivable"} The item's scope.
365
+ */
366
+ export function runtimeScope(body) {
367
+ const declaration = markdownSection(
368
+ markdownHeadings(body),
369
+ "Target Backend Environment"
370
+ );
371
+ if (declaration === "") return "underivable";
372
+ return NO_RUNTIME.test(declaration) ? "none" : "runtime";
373
+ }
374
+
375
+ /**
376
+ * Parse the switched-off form's tail: `<switch>; removed by <owner>`.
377
+ * @param {string} tail - Text after `Switched off —`.
378
+ * @returns {{mode: "off", switchName: string, removedBy: string} | {mode: "invalid", problems: string[]}} Parsed form.
379
+ */
380
+ function parseSwitchedOff(tail) {
381
+ const [nameText = "", ...rest] = tail.split(";");
382
+ const switchName = nameText.trim();
383
+ const ownerText = rest.join(";").trim();
384
+ const named =
385
+ ownerText.toLowerCase().startsWith(REMOVED_BY_LABEL) &&
386
+ /\s/.test(ownerText[REMOVED_BY_LABEL.length] ?? "");
387
+ const removedBy = named
388
+ ? ownerText.slice(REMOVED_BY_LABEL.length).trim().replace(/\.$/, "")
389
+ : "";
390
+ const ownerValid =
391
+ removedBy.toLowerCase() === THIS_ITEM || isWorkItemRef(removedBy);
392
+ const problems = [
393
+ ...(SWITCH_NAME.test(switchName)
394
+ ? []
395
+ : [
396
+ switchName === ""
397
+ ? "It names no switch."
398
+ : `Switch name ${JSON.stringify(switchName)} must be 3 to 64 letters, digits, dots, colons, slashes, underscores or hyphens, with no spaces.`,
399
+ ]),
400
+ ...(ownerValid
401
+ ? []
402
+ : [
403
+ removedBy === ""
404
+ ? `It does not say which work item removes the switch: end it with "; removed by ${THIS_ITEM}" or "; removed by <work-item ref>".`
405
+ : `${JSON.stringify(removedBy)} is not "${THIS_ITEM}" or a work-item reference such as #123, owner/repo#123 or ENG-123.`,
406
+ ]),
407
+ ];
408
+ return problems.length
409
+ ? { mode: "invalid", problems }
410
+ : {
411
+ mode: "off",
412
+ switchName,
413
+ removedBy:
414
+ removedBy.toLowerCase() === THIS_ITEM ? THIS_ITEM : removedBy,
415
+ };
416
+ }
417
+
418
+ /**
419
+ * Parse one declaration line.
420
+ * @param {string} line - The declaration, trimmed.
421
+ * @returns {{mode: "live"} | {mode: "off", switchName: string, removedBy: string} | {mode: "invalid", problems: string[]}} Parsed form.
422
+ */
423
+ function parseDeclarationLine(line) {
424
+ if (LIVE.test(line)) return { mode: "live" };
425
+ const off = afterLabel(line, SWITCHED_OFF_LABEL);
426
+ if (off !== null) return parseSwitchedOff(off);
427
+ return {
428
+ mode: "invalid",
429
+ problems: [`${JSON.stringify(line)} is neither of the two forms.`],
430
+ };
431
+ }
432
+
433
+ /**
434
+ * The declaration heading, folded the way the shared section reader folds it.
435
+ * Lookup, replacement and extraction all use this one comparison: a heading the
436
+ * reader accepts (closing hashes after a tab, odd spacing, another case) that a
437
+ * second comparison missed would read as "no declaration", and an item with no
438
+ * declaration owes nothing.
439
+ */
440
+ const HEADING_KEY = headingKey(`## ${RELEASE_SWITCH_HEADING}`);
441
+
442
+ const WIKI_BLOCK_KINDS = ["code", "noformat"];
443
+
444
+ /**
445
+ * The wiki code-block markers on a line, left to right, as block kinds.
446
+ * `{code}`, `{code:java}` and `{noformat}` are markers; anything else is text.
447
+ * @param {string} line - One body line.
448
+ * @returns {string[]} `code` or `noformat` for each marker, in order.
449
+ */
450
+ function wikiMarkers(line) {
451
+ return line
452
+ .split("{")
453
+ .slice(1)
454
+ .flatMap(piece => {
455
+ const kind = WIKI_BLOCK_KINDS.find(
456
+ name => piece.startsWith(`${name}}`) || piece.startsWith(`${name}:`)
457
+ );
458
+ return kind && piece.includes("}") ? [kind] : [];
459
+ });
460
+ }
461
+
462
+ /**
463
+ * The wiki block that is still open after these lines, if any.
464
+ *
465
+ * It follows JIRA's own rule: outside a block, a marker opens a block of its
466
+ * kind; inside one, only a marker of the SAME kind closes it, and the other
467
+ * kind is text. Counting markers instead cannot tell `{noformat}{code}` (one
468
+ * open block with text in it) from two blocks.
469
+ * @param {string[]} lines - Body lines above the point in question.
470
+ * @returns {string|null} `code`, `noformat`, or `null` when no block is open.
471
+ */
472
+ function openWikiBlock(lines) {
473
+ return lines
474
+ .flatMap(wikiMarkers)
475
+ .reduce(
476
+ (open, kind) => (open === null ? kind : open === kind ? null : open),
477
+ /** @type {string|null} */ (null)
478
+ );
479
+ }
480
+
481
+ /**
482
+ * Where an item's `## Release Switch` section is and what it holds.
483
+ *
484
+ * Three states matter and must not collapse into each other: no section at all
485
+ * (a legacy item, or a live one nobody declared), a section whose text can be
486
+ * read, and a section that is there but cannot be trusted. The last has two
487
+ * forms. A blank section is unreadable, not evidence that the item removes
488
+ * nothing. And in a JIRA ticket, a section whose `h2.` heading sits inside a
489
+ * `{code}` or `{noformat}` block that is still open may be a quoted example.
490
+ * It is refused as ambiguous: never trusted as the declaration, and never read
491
+ * as absent (which is how an earlier version let a stray marker hide a real
492
+ * declaration from the done gate).
493
+ * @param {string} body - Work-item body.
494
+ * @returns {null | {text: string, problem: string|null}} `null` when there is no section.
495
+ */
496
+ function declarationState(body) {
497
+ const lines = body
498
+ .split("\n")
499
+ .map(line => (line.endsWith("\r") ? line.slice(0, -1) : line));
500
+ const normalized = markdownHeadings(lines.join("\n"));
501
+ const lineAt = offset => normalized.slice(0, offset).split("\n").length - 1;
502
+ const match = topLevelLines(normalized)
503
+ .filter(row => row.heading)
504
+ .map(row => ({ line: lineAt(row.start), name: headingKey(row.text) }))
505
+ .find(({ name }) => name === HEADING_KEY);
506
+ if (!match) return null;
507
+ // Duplicate sections are refused here, by the shared section reader.
508
+ const text = markdownSection(normalized, RELEASE_SWITCH_HEADING, {
509
+ anyCase: true,
510
+ });
511
+ if (
512
+ WIKI_HEADING.test(lines[match.line]) &&
513
+ openWikiBlock(lines.slice(0, match.line)) !== null
514
+ )
515
+ return {
516
+ text,
517
+ problem:
518
+ "The section follows an unclosed {code} or {noformat} marker, so it may be a quoted example and not the declaration. Close or remove that marker, or move the section above it.",
519
+ };
520
+ return {
521
+ text,
522
+ problem:
523
+ text === ""
524
+ ? "The section is empty. Write the declaration on one line."
525
+ : null,
526
+ };
527
+ }
528
+
529
+ /**
530
+ * Parse an item's `## Release Switch` declaration.
531
+ *
532
+ * The declaration is the whole section, on one line: a second line could say
533
+ * anything, and a checker that read only the first would pass an item whose
534
+ * real plan is in the part it skipped.
535
+ * @param {string} body - Work-item body.
536
+ * @returns {null | {mode: "live"} | {mode: "off", switchName: string, removedBy: string} | {mode: "invalid", problems: string[]}} `null` when the section is absent.
537
+ */
538
+ export function parseDeclaration(body) {
539
+ const state = declarationState(body);
540
+ if (state === null) return null;
541
+ if (state.problem !== null)
542
+ return { mode: "invalid", problems: [state.problem] };
543
+ if (state.text.includes("\n"))
544
+ return {
545
+ mode: "invalid",
546
+ problems: [
547
+ "The declaration must be the only line in the section; move any explanation into Technical Approach.",
548
+ ],
549
+ };
550
+ return parseDeclarationLine(state.text);
551
+ }
552
+
553
+ const VALID_FORMS = [
554
+ ` ${LIVE_DECLARATION}`,
555
+ ` Switched off — <switch-name>; removed by ${THIS_ITEM}`,
556
+ " Switched off — <switch-name>; removed by <work-item ref>",
557
+ ];
558
+
559
+ const HOW_TO_CHOOSE =
560
+ "Ask one question: if this were promoted to production right now, would a user see something unfinished or unproven? If no, it is live and needs no switch (bug fixes, small tweaks, refactors and dependency updates are live). If yes, it is switched off.";
561
+
562
+ /**
563
+ * Gate S22: does this item say how it is safe to promote?
564
+ *
565
+ * `existing` separates the two populations the readiness gates already treat
566
+ * differently. A proposed item with no declaration fails, because the writer
567
+ * can still add one. An item already in the tracker with none is not
568
+ * applicable: failing it would turn every legacy queue red for a section
569
+ * nobody had a way to add.
570
+ * @param {string} body - Work-item body.
571
+ * @param {{liveUsers: boolean}} setting - Resolved `release.*` setting.
572
+ * @param {{existing?: boolean}} [options] - Whether the item is already stored in the tracker.
573
+ * @returns {{verdict: "PASS"|"FAIL"|"N/A", lines: string[]}} Verdict and reader-facing lines.
574
+ */
575
+ export function checkDeclaration(body, setting, { existing = false } = {}) {
576
+ if (!setting.liveUsers)
577
+ return {
578
+ verdict: "N/A",
579
+ lines: [
580
+ "This project is marked as having no live users (release.liveUsers is false), so no declaration is needed.",
581
+ ],
582
+ };
583
+ const scope = runtimeScope(body);
584
+ if (scope === "none")
585
+ return {
586
+ verdict: "N/A",
587
+ lines: [
588
+ "The item changes no runtime behavior (or is a container), so there is nothing to promote.",
589
+ ],
590
+ };
591
+ const declaration = parseDeclaration(body);
592
+ if (declaration === null) {
593
+ if (existing || scope === "underivable")
594
+ return {
595
+ verdict: existing ? "N/A" : "FAIL",
596
+ lines: existing
597
+ ? [
598
+ `This existing item has no ## ${RELEASE_SWITCH_HEADING} section. Repair note: whoever claims it adds one of:`,
599
+ ...VALID_FORMS,
600
+ ]
601
+ : [
602
+ "The item has no ## Target Backend Environment section, so whether it changes runtime behavior cannot be read. Add that section first.",
603
+ ],
604
+ };
605
+ return {
606
+ verdict: "FAIL",
607
+ lines: [
608
+ `The item changes runtime behavior but has no ## ${RELEASE_SWITCH_HEADING} section saying how it is safe to promote. Add the section with exactly one of:`,
609
+ ...VALID_FORMS,
610
+ HOW_TO_CHOOSE,
611
+ ],
612
+ };
613
+ }
614
+ if (declaration.mode === "invalid")
615
+ return {
616
+ verdict: "FAIL",
617
+ lines: [
618
+ `The ## ${RELEASE_SWITCH_HEADING} declaration is not valid.`,
619
+ ...declaration.problems,
620
+ "Valid forms:",
621
+ ...VALID_FORMS,
622
+ ],
623
+ };
624
+ return {
625
+ verdict: "PASS",
626
+ lines: [
627
+ declaration.mode === "live"
628
+ ? "Declared live: complete and proven at merge, no switch."
629
+ : `Declared switched off behind ${JSON.stringify(declaration.switchName)}; removed by ${declaration.removedBy}.`,
630
+ ],
631
+ };
632
+ }
633
+
634
+ /**
635
+ * Render the `## Release Switch` section.
636
+ * @param {{mode: string, switchName?: string, removedBy?: string}} input - `live`, or `off` with a switch and its removal owner.
637
+ * @returns {string} The section, ending in a newline.
638
+ */
639
+ export function renderDeclaration({ mode, switchName, removedBy = THIS_ITEM }) {
640
+ if (mode === "live")
641
+ return `## ${RELEASE_SWITCH_HEADING}\n\n${LIVE_DECLARATION}\n`;
642
+ if (mode !== "off")
643
+ throw new ReleaseSwitchError(
644
+ `--mode must be live or off, not ${JSON.stringify(mode ?? "")}.`
645
+ );
646
+ const parsed = parseSwitchedOff(
647
+ `${switchName ?? ""}; removed by ${removedBy}`
648
+ );
649
+ if (parsed.mode === "invalid")
650
+ throw new ReleaseSwitchError(parsed.problems.join(" "));
651
+ return `## ${RELEASE_SWITCH_HEADING}\n\nSwitched off — ${parsed.switchName}; removed by ${parsed.removedBy}\n`;
652
+ }
653
+
654
+ /**
655
+ * What survives of an old section when its declaration is replaced: every line
656
+ * after the declaration line itself. Deleting them would lose text a person
657
+ * put there (or the closing marker of a block the line sat in); keeping them
658
+ * means the checker still says they must move.
659
+ * @param {string[]} lines - The old section's lines, heading excluded.
660
+ * @returns {string[]} Lines to keep, with no blank edges.
661
+ */
662
+ function keptAfterDeclaration(lines) {
663
+ const first = lines.findIndex(line => line.trim() !== "");
664
+ if (first < 0) return [];
665
+ const rest = lines.slice(first + 1);
666
+ const start = rest.findIndex(line => line.trim() !== "");
667
+ if (start < 0) return [];
668
+ const end = rest.findLastIndex(line => line.trim() !== "");
669
+ return rest.slice(start, end + 1);
670
+ }
671
+
672
+ /**
673
+ * Put a rendered declaration into a body, replacing the one that is there.
674
+ *
675
+ * The section is found the way the parser finds it: top-level headings only, so
676
+ * a quoted example inside a code fence or a comment is never rewritten. The
677
+ * body keeps its own line endings and its own heading spelling (`## Name`, or
678
+ * `h2. Name` in JIRA wiki markup).
679
+ * @param {string} body - Work-item body.
680
+ * @param {string} section - Output of {@link renderDeclaration}.
681
+ * @returns {string} Body with exactly one declaration.
682
+ */
683
+ export function upsertDeclaration(body, section) {
684
+ const eol = body.includes("\r\n") ? "\r\n" : "\n";
685
+ const lines = body
686
+ .split("\n")
687
+ .map(line => (line.endsWith("\r") ? line.slice(0, -1) : line));
688
+ const normalized = markdownHeadings(lines.join("\n"));
689
+ const lineAt = offset => normalized.slice(0, offset).split("\n").length - 1;
690
+ const headings = topLevelLines(normalized)
691
+ .filter(row => row.heading)
692
+ .map(row => ({ line: lineAt(row.start), name: headingKey(row.text) }));
693
+ const wiki = headings.some(({ line }) => WIKI_HEADING.test(lines[line]));
694
+ const declaration = section.trimEnd().split("\n").at(-1);
695
+ const rendered = [
696
+ `${wiki ? "h2." : "##"} ${RELEASE_SWITCH_HEADING}`,
697
+ "",
698
+ declaration,
699
+ ];
700
+ const matches = headings.filter(({ name }) => name === HEADING_KEY);
701
+ if (matches.length > 1)
702
+ throw new ReleaseSwitchError(
703
+ `The body has more than one ${RELEASE_SWITCH_HEADING} section; remove the extra copies first.`
704
+ );
705
+ if (matches.length === 0)
706
+ return written(
707
+ `${lines.join(eol).trimEnd()}${eol}${eol}${rendered.join(eol)}${eol}`,
708
+ declaration
709
+ );
710
+ const start = matches[0].line;
711
+ const next = headings.find(({ line }) => line > start);
712
+ const end = next ? next.line : lines.length;
713
+ const old = lines.slice(start + 1, end);
714
+ // The first line is what gets replaced. If it opens a code block, replacing
715
+ // it would leave the block's closing marker behind to open a new one, and
716
+ // every section after it would stop being read.
717
+ const first = (old.find(line => line.trim() !== "") ?? "").trim();
718
+ if (
719
+ first.startsWith("```") ||
720
+ first.startsWith("~~~") ||
721
+ first.startsWith("<!--") ||
722
+ wikiMarkers(first).length > 0
723
+ )
724
+ throw new ReleaseSwitchError(
725
+ `The ${RELEASE_SWITCH_HEADING} section starts with a code block or a comment. Move it out of the section, then render again.`
726
+ );
727
+ return written(
728
+ [
729
+ ...lines.slice(0, start),
730
+ ...rendered,
731
+ ...(keptAfterDeclaration(old).length
732
+ ? ["", ...keptAfterDeclaration(old)]
733
+ : []),
734
+ ...(end < lines.length ? ["", ...lines.slice(end)] : [""]),
735
+ ].join(eol),
736
+ declaration
737
+ );
738
+ }
739
+
740
+ /**
741
+ * A body the declaration was just written into, proven readable.
742
+ *
743
+ * A write that the reader cannot see is worse than no write: the caller is told
744
+ * the item now has a declaration and the gate then reports it missing. That is
745
+ * what happens when the body ends inside an unclosed code fence or HTML
746
+ * comment, or when a wiki heading lands under an unclosed code marker. So the
747
+ * result is read back, and a declaration that did not come back is an error
748
+ * naming what to fix.
749
+ * @param {string} body - The body after the write.
750
+ * @param {string} declaration - The line that was written.
751
+ * @returns {string} The same body.
752
+ */
753
+ function written(body, declaration) {
754
+ const state = declarationState(body);
755
+ const [firstLine = ""] = (state?.text ?? "").split("\n");
756
+ if (
757
+ state === null ||
758
+ state.problem !== null ||
759
+ firstLine.trim() !== declaration
760
+ )
761
+ throw new ReleaseSwitchError(
762
+ `The ${RELEASE_SWITCH_HEADING} section could not be written where it would be read${state?.problem ? `: ${state.problem}` : ": the body ends inside an unclosed code block or comment. Close it, then render again."}`
763
+ );
764
+ return body;
765
+ }
766
+
767
+ /**
768
+ * The switch this item must remove before it can finish, if any.
769
+ *
770
+ * The readiness gate is strict about the section's shape; this is deliberately
771
+ * not. It reads the FIRST line of the section, so text that later landed under
772
+ * the declaration (a trailer appended to the end of the body, a note) cannot
773
+ * make the obligation disappear. A first line that is neither form is reported
774
+ * as `invalid`: an item whose declaration cannot be read is not known to be
775
+ * free of a switch, and the done gate refuses it until the line is corrected.
776
+ * @param {string} body - Work-item body.
777
+ * @param {string} [ref] - The item's own reference, so `removed by <own ref>` counts too.
778
+ * @returns {null | {switchName: string} | {invalid: string[]}} The obligation, `null` when there is none, or why the declaration cannot be read.
779
+ */
780
+ export function removalObligation(body, ref) {
781
+ const state = declarationState(body);
782
+ if (state === null) return null;
783
+ if (state.problem !== null) return { invalid: [state.problem] };
784
+ const [firstLine = ""] = state.text
785
+ .split("\n")
786
+ .map(line => line.trim())
787
+ .filter(Boolean);
788
+ const declaration = parseDeclarationLine(firstLine);
789
+ if (declaration.mode === "invalid") return { invalid: declaration.problems };
790
+ if (declaration.mode !== "off") return null;
791
+ // Tracker references are not case-sensitive (owner/Repo#7 is owner/repo#7),
792
+ // and a remover this item fails to recognise as itself is a gate that never
793
+ // fires.
794
+ const own = [THIS_ITEM, ref, ref?.replace(/^[^#]*(?=#)/, "")]
795
+ .filter(Boolean)
796
+ .map(value => value.toLowerCase());
797
+ return own.includes(declaration.removedBy.toLowerCase())
798
+ ? { switchName: declaration.switchName }
799
+ : null;
800
+ }
801
+
802
+ // A search "in cwd" means cwd's repository. Git run from inside a hook inherits
803
+ // GIT_DIR and friends, which would silently point this search at the hook's
804
+ // repository instead, so those are dropped.
805
+ const gitEnvironment = () =>
806
+ Object.fromEntries(
807
+ Object.entries(process.env).filter(
808
+ ([name]) =>
809
+ ![
810
+ "GIT_DIR",
811
+ "GIT_WORK_TREE",
812
+ "GIT_INDEX_FILE",
813
+ "GIT_COMMON_DIR",
814
+ ].includes(name)
815
+ )
816
+ );
817
+
818
+ /**
819
+ * Run git and return its output, or throw with the exit status and stderr.
820
+ *
821
+ * Anything git says on stderr is a failure here, whatever the exit status. A
822
+ * search that could not read part of a tree can still exit 0 or 1, and "no
823
+ * match" from a search that skipped an unreadable file is not an answer.
824
+ * @param {string[]} args - Git arguments.
825
+ * @param {string} cwd - Directory to run in.
826
+ * @returns {string} Standard output.
827
+ */
828
+ function git(args, cwd) {
829
+ const result = spawnSync("git", args, {
830
+ cwd,
831
+ env: gitEnvironment(),
832
+ encoding: "utf8",
833
+ stdio: ["ignore", "pipe", "pipe"],
834
+ maxBuffer: 64 * 1024 * 1024,
835
+ });
836
+ const stderr = result.stderr ?? "";
837
+ if (result.status === 0 && stderr.trim() === "") return result.stdout ?? "";
838
+ throw Object.assign(new Error(stderr || String(result.error ?? "")), {
839
+ status: result.status,
840
+ stderr,
841
+ });
842
+ }
843
+
844
+ const CHANGELOG_FILE = /^changelog(?:\.(?:md|markdown|txt|rst|adoc))?$/i;
845
+
846
+ /**
847
+ * Files that are records of work and are never executed, so a mention in one
848
+ * cannot keep a switch alive:
849
+ *
850
+ * - committed evidence, `evidence/<ticket>/…` at the repository root. The
851
+ * read-back that proves a switch is off in production names the switch.
852
+ * - a changelog (`CHANGELOG`, `CHANGELOG.md`, …), which says what was removed.
853
+ * - Lisa's own machine state under `.lisa/`, such as the learnings ledger.
854
+ *
855
+ * Everything inside those two folders is treated as a record, code included,
856
+ * so nothing that reads a switch belongs there. A submodule that is not
857
+ * checked out has no files to search and is not reported.
858
+ *
859
+ * Everything else counts, prose included: Markdown and MDX can carry template
860
+ * conditionals, a text file can be a flag list, and `ChangelogPage.tsx` or a
861
+ * script sitting directly in `evidence/` is code. This is one definition of
862
+ * "record" for every switch, not a list anyone adds a failing file to.
863
+ * @param {string} path - Repository-relative path.
864
+ * @returns {boolean} True when the file can hold a reference that matters.
865
+ */
866
+ function isSource(path) {
867
+ const segments = path.split("/");
868
+ const evidence = segments[0] === "evidence" && segments.length >= 3;
869
+ const machineState = segments[0] === ".lisa" && segments.length >= 2;
870
+ return !(
871
+ evidence ||
872
+ machineState ||
873
+ CHANGELOG_FILE.test(segments.at(-1) ?? "")
874
+ );
875
+ }
876
+
877
+ /**
878
+ * An extended regular expression that matches the switch name as a whole
879
+ * token: not glued to a letter or digit on either side. `new-checkout` then
880
+ * matches `flags["new-checkout"]`, `new-checkout.enabled` and
881
+ * `new-checkout_v2`, and does not match the unrelated `renew-checkout-banner`.
882
+ * @param {string} switchName - A validated switch name.
883
+ * @returns {string} Pattern for `git grep -E`.
884
+ */
885
+ const tokenPattern = switchName =>
886
+ `(^|[^A-Za-z0-9])${switchName.replaceAll(".", "[.]")}($|[^A-Za-z0-9])`;
887
+
888
+ /**
889
+ * Git's own switch for ignoring local replacement refs. With one in place, a
890
+ * search "at commit X" would read whatever tree X was locally replaced by,
891
+ * while the caller reports X: the proof's commit would not be the one searched.
892
+ */
893
+ export const NO_REPLACE = "--no-replace-objects";
894
+
895
+ /**
896
+ * The root of the repository `cwd` is in.
897
+ * @param {Function} run - Git runner.
898
+ * @param {string} cwd - A directory inside the repository.
899
+ * @param {Function} failed - Builds the error for a search that cannot run.
900
+ * @returns {string} Absolute path of the repository root.
901
+ */
902
+ function repositoryRoot(run, cwd, failed) {
903
+ try {
904
+ return run([NO_REPLACE, "rev-parse", "--show-toplevel"], cwd).trim();
905
+ } catch (error) {
906
+ throw failed(error);
907
+ }
908
+ }
909
+
910
+ /**
911
+ * Tracked source files that still reference a switch.
912
+ *
913
+ * It searches `revision` when one is given (the production commit after a
914
+ * merge) and the working tree otherwise, always from the repository root, in
915
+ * any letter case. `git grep` exits 1 for "no match", which is the answer and
916
+ * not an error; anything else is surfaced, because a search that could not run
917
+ * must never read as "the switch is gone".
918
+ *
919
+ * What it cannot find is a different spelling of the same switch
920
+ * (`NEW_CHECKOUT` for `new-checkout`): a project uses one spelling everywhere.
921
+ * @param {string} switchName - Switch to look for, matched as a whole token.
922
+ * @param {{cwd?: string, revision?: string, run?: Function}} [options] - Where to search; `run` is injectable for tests.
923
+ * @returns {string[]} Repository-relative paths, sorted.
924
+ */
925
+ export function switchReferences(
926
+ switchName,
927
+ { cwd = process.cwd(), revision, run = git } = {}
928
+ ) {
929
+ if (!SWITCH_NAME.test(switchName))
930
+ throw new ReleaseSwitchError(
931
+ `${JSON.stringify(switchName)} is not a valid switch name.`
932
+ );
933
+ const failed = error =>
934
+ new ReleaseSwitchError(
935
+ `Could not search tracked source for ${JSON.stringify(switchName)}: ${String(error?.stderr || error?.message || error).trim()}`
936
+ );
937
+ // The search runs from the repository root with no pathspec at all. Git run
938
+ // from a subfolder searches only that folder, and the `:/` pathspec that
939
+ // would widen it stops meaning "the root" when a hook or alias runs under
940
+ // `git --literal-pathspecs`; either way a switch still in use elsewhere would
941
+ // be reported as gone.
942
+ // A value that starts with a dash would be read by git as an option.
943
+ if (revision !== undefined && !/^[A-Za-z0-9]/.test(revision))
944
+ throw new ReleaseSwitchError(
945
+ `${JSON.stringify(revision)} is not a revision this search accepts.`
946
+ );
947
+ const root = repositoryRoot(run, cwd, failed);
948
+ // The closing `--` with nothing after it still means "the whole tree", and
949
+ // it makes git read the value before it as a revision or fail: without it a
950
+ // folder that happens to carry the same name would be searched instead, and
951
+ // the answer would be "not referenced" for a tree that was never looked at.
952
+ const args = [
953
+ NO_REPLACE,
954
+ "-C",
955
+ root,
956
+ "grep",
957
+ "-l",
958
+ "-i",
959
+ "-E",
960
+ "-z",
961
+ "--full-name",
962
+ "--recurse-submodules",
963
+ "-e",
964
+ tokenPattern(switchName),
965
+ ...(revision ? [revision] : []),
966
+ "--",
967
+ ];
968
+ try {
969
+ return run(args, cwd)
970
+ .split("\0")
971
+ .filter(Boolean)
972
+ .map(path => (revision ? path.slice(revision.length + 1) : path))
973
+ .filter(isSource)
974
+ .sort((left, right) => left.localeCompare(right));
975
+ } catch (error) {
976
+ // Exit 1 with nothing on stderr is git's "no match". Exit 1 WITH a
977
+ // diagnostic is a read that failed partway, and is not a clean answer.
978
+ if (error?.status === 1 && String(error.stderr ?? "").trim() === "")
979
+ return [];
980
+ throw failed(error);
981
+ }
982
+ }
983
+
984
+ const HEADS_PREFIX = "refs/heads/";
985
+
986
+ /**
987
+ * A branch name without the `refs/heads/` prefix some tools report.
988
+ * @param {unknown} value - Branch as configured or as reported.
989
+ * @returns {string} Short branch name, or "" when there is none.
990
+ */
991
+ const branchName = value => {
992
+ const trimmed = typeof value === "string" ? value.trim() : "";
993
+ return trimmed.startsWith(HEADS_PREFIX)
994
+ ? trimmed.slice(HEADS_PREFIX.length)
995
+ : trimmed;
996
+ };
997
+
998
+ /**
999
+ * The branch that deploys to production.
1000
+ *
1001
+ * It reads `deploy.branches` the way the completion checker does, so the two
1002
+ * agree on what "production" is: environment names are not case-sensitive, a
1003
+ * `refs/heads/` prefix is ignored, and a project that configures no deploy
1004
+ * branches at all deploys production from its default branch
1005
+ * (`policy.repository.default_branch`, else `main`). `prod` and `production`
1006
+ * are the same environment; when a project configures both and they name
1007
+ * different branches, it means two things and neither is guessed.
1008
+ * @param {object} [config] - Effective project config.
1009
+ * @returns {string|null} Branch name, or `null` when it cannot be read.
1010
+ */
1011
+ export function productionBranch(config = {}) {
1012
+ const configured = isObject(config?.deploy?.branches)
1013
+ ? Object.entries(config.deploy.branches)
1014
+ : [];
1015
+ const mapped = configured
1016
+ .map(([environment, branch]) => [
1017
+ String(environment).trim().toLowerCase(),
1018
+ branchName(branch),
1019
+ ])
1020
+ .filter(([, branch]) => branch !== "");
1021
+ if (mapped.length === 0)
1022
+ return branchName(config?.policy?.repository?.default_branch) || "main";
1023
+ const production = new Set(
1024
+ mapped
1025
+ .filter(([environment]) => ["production", "prod"].includes(environment))
1026
+ .map(([, branch]) => branch)
1027
+ );
1028
+ return production.size === 1 ? [...production][0] : null;
1029
+ }
1030
+
1031
+ /**
1032
+ * The plain-English notice for a production deployment in a project that is
1033
+ * marked as having no live users. It keeps the opt-out visible on the one day
1034
+ * it matters most, launch day, without ever blocking a deployment.
1035
+ * @param {object} config - Effective project config.
1036
+ * @param {string} base - Branch the deployment came from.
1037
+ * @returns {string|null} The notice, or `null` when none applies.
1038
+ */
1039
+ export function productionNotice(config, base) {
1040
+ const setting = resolveReleaseSetting(config);
1041
+ const branch = branchName(base);
1042
+ if (setting.liveUsers || branch === "" || branch !== productionBranch(config))
1043
+ return null;
1044
+ return [
1045
+ `Notice: this project is marked as having no live users (release.liveUsers is false in its Lisa configuration: .lisa.config.json, or the local override .lisa.config.local.json), so Lisa's always-promotable rule is off here.`,
1046
+ `This deployment from ${branch} went to production, and unfinished work can reach production without being switched off.`,
1047
+ "When the project launches, set release.liveUsers to true or remove the line. Nothing was blocked.",
1048
+ ].join("\n");
1049
+ }