@codyswann/lisa 4.100.6 → 4.101.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (97) hide show
  1. package/all/copy-overwrite/scripts/lisa-gates.mjs +13 -8
  2. package/all/copy-overwrite/scripts/npm-updater-helper-graph.json +1 -1
  3. package/dist/codex/scripts/block-migration-edits.sh +39 -64
  4. package/dist/core/lisa-owned-hash-ledger.d.ts.map +1 -1
  5. package/dist/core/lisa-owned-hash-ledger.js +6 -0
  6. package/dist/core/lisa-owned-hash-ledger.js.map +1 -1
  7. package/dist/core/nightly-e2e-guard-behavior-certificate.js +2 -2
  8. package/dist/core/upstream-evidence-manifest.d.ts.map +1 -1
  9. package/dist/core/upstream-evidence-manifest.js +10 -6
  10. package/dist/core/upstream-evidence-manifest.js.map +1 -1
  11. package/dist/opencode/plugin-templates/lisa-block-migration-edits.ts +31 -32
  12. package/package.json +4 -4
  13. package/plugins/lisa/.claude-plugin/plugin.json +1 -1
  14. package/plugins/lisa/.codex-plugin/plugin.json +1 -1
  15. package/plugins/lisa-agy/plugin.json +1 -1
  16. package/plugins/lisa-cdk/.claude-plugin/plugin.json +1 -1
  17. package/plugins/lisa-cdk/.codex-plugin/plugin.json +1 -1
  18. package/plugins/lisa-cdk-agy/plugin.json +1 -1
  19. package/plugins/lisa-cdk-copilot/.claude-plugin/plugin.json +1 -1
  20. package/plugins/lisa-cdk-cursor/.claude-plugin/plugin.json +1 -1
  21. package/plugins/lisa-cdk-devin/.claude-plugin/plugin.json +1 -1
  22. package/plugins/lisa-cdk-devin/.devin-plugin/plugin.json +1 -1
  23. package/plugins/lisa-copilot/.claude-plugin/plugin.json +1 -1
  24. package/plugins/lisa-cursor/.claude-plugin/plugin.json +1 -1
  25. package/plugins/lisa-devin/.claude-plugin/plugin.json +1 -1
  26. package/plugins/lisa-devin/.devin-plugin/plugin.json +1 -1
  27. package/plugins/lisa-expo/.claude-plugin/plugin.json +1 -1
  28. package/plugins/lisa-expo/.codex-plugin/plugin.json +1 -1
  29. package/plugins/lisa-expo-agy/plugin.json +1 -1
  30. package/plugins/lisa-expo-copilot/.claude-plugin/plugin.json +1 -1
  31. package/plugins/lisa-expo-cursor/.claude-plugin/plugin.json +1 -1
  32. package/plugins/lisa-expo-devin/.claude-plugin/plugin.json +1 -1
  33. package/plugins/lisa-expo-devin/.devin-plugin/plugin.json +1 -1
  34. package/plugins/lisa-harper-fabric/.claude-plugin/plugin.json +1 -1
  35. package/plugins/lisa-harper-fabric/.codex-plugin/plugin.json +1 -1
  36. package/plugins/lisa-harper-fabric-agy/plugin.json +1 -1
  37. package/plugins/lisa-harper-fabric-copilot/.claude-plugin/plugin.json +1 -1
  38. package/plugins/lisa-harper-fabric-cursor/.claude-plugin/plugin.json +1 -1
  39. package/plugins/lisa-harper-fabric-devin/.claude-plugin/plugin.json +1 -1
  40. package/plugins/lisa-harper-fabric-devin/.devin-plugin/plugin.json +1 -1
  41. package/plugins/lisa-nestjs/.claude-plugin/plugin.json +2 -2
  42. package/plugins/lisa-nestjs/.codex-plugin/plugin.json +2 -2
  43. package/plugins/lisa-nestjs/.codex-plugin/skills/nestjs-rules/SKILL.md +14 -7
  44. package/plugins/lisa-nestjs/hooks/block-migration-edits.sh +47 -77
  45. package/plugins/lisa-nestjs/skills/nestjs-rules/SKILL.md +14 -7
  46. package/plugins/lisa-nestjs-agy/plugin.json +2 -2
  47. package/plugins/lisa-nestjs-agy/skills/nestjs-rules/SKILL.md +14 -7
  48. package/plugins/lisa-nestjs-copilot/.claude-plugin/plugin.json +2 -2
  49. package/plugins/lisa-nestjs-copilot/hooks/block-migration-edits.sh +47 -77
  50. package/plugins/lisa-nestjs-copilot/skills/nestjs-rules/SKILL.md +14 -7
  51. package/plugins/lisa-nestjs-cursor/.claude-plugin/plugin.json +2 -2
  52. package/plugins/lisa-nestjs-cursor/hooks/block-migration-edits.sh +47 -77
  53. package/plugins/lisa-nestjs-cursor/skills/nestjs-rules/SKILL.md +14 -7
  54. package/plugins/lisa-nestjs-devin/.claude-plugin/plugin.json +2 -2
  55. package/plugins/lisa-nestjs-devin/.devin-plugin/plugin.json +2 -2
  56. package/plugins/lisa-nestjs-devin/hooks/block-migration-edits.sh +47 -77
  57. package/plugins/lisa-nestjs-devin/skills/nestjs-rules/SKILL.md +14 -7
  58. package/plugins/lisa-openclaw/.claude-plugin/plugin.json +1 -1
  59. package/plugins/lisa-openclaw/.codex-plugin/plugin.json +1 -1
  60. package/plugins/lisa-openclaw-agy/plugin.json +1 -1
  61. package/plugins/lisa-openclaw-copilot/.claude-plugin/plugin.json +1 -1
  62. package/plugins/lisa-openclaw-cursor/.claude-plugin/plugin.json +1 -1
  63. package/plugins/lisa-openclaw-devin/.claude-plugin/plugin.json +1 -1
  64. package/plugins/lisa-openclaw-devin/.devin-plugin/plugin.json +1 -1
  65. package/plugins/lisa-phaser/.claude-plugin/plugin.json +1 -1
  66. package/plugins/lisa-phaser/.codex-plugin/plugin.json +1 -1
  67. package/plugins/lisa-phaser-agy/plugin.json +1 -1
  68. package/plugins/lisa-phaser-copilot/.claude-plugin/plugin.json +1 -1
  69. package/plugins/lisa-phaser-cursor/.claude-plugin/plugin.json +1 -1
  70. package/plugins/lisa-phaser-devin/.claude-plugin/plugin.json +1 -1
  71. package/plugins/lisa-phaser-devin/.devin-plugin/plugin.json +1 -1
  72. package/plugins/lisa-rails/.claude-plugin/plugin.json +1 -1
  73. package/plugins/lisa-rails/.codex-plugin/plugin.json +1 -1
  74. package/plugins/lisa-rails-agy/plugin.json +1 -1
  75. package/plugins/lisa-rails-copilot/.claude-plugin/plugin.json +1 -1
  76. package/plugins/lisa-rails-cursor/.claude-plugin/plugin.json +1 -1
  77. package/plugins/lisa-rails-devin/.claude-plugin/plugin.json +1 -1
  78. package/plugins/lisa-rails-devin/.devin-plugin/plugin.json +1 -1
  79. package/plugins/lisa-typescript/.claude-plugin/plugin.json +1 -1
  80. package/plugins/lisa-typescript/.codex-plugin/plugin.json +1 -1
  81. package/plugins/lisa-typescript-agy/plugin.json +1 -1
  82. package/plugins/lisa-typescript-copilot/.claude-plugin/plugin.json +1 -1
  83. package/plugins/lisa-typescript-cursor/.claude-plugin/plugin.json +1 -1
  84. package/plugins/lisa-typescript-devin/.claude-plugin/plugin.json +1 -1
  85. package/plugins/lisa-typescript-devin/.devin-plugin/plugin.json +1 -1
  86. package/plugins/lisa-wiki/.claude-plugin/plugin.json +1 -1
  87. package/plugins/lisa-wiki/.codex-plugin/plugin.json +1 -1
  88. package/plugins/lisa-wiki-agy/plugin.json +1 -1
  89. package/plugins/lisa-wiki-copilot/.claude-plugin/plugin.json +1 -1
  90. package/plugins/lisa-wiki-cursor/.claude-plugin/plugin.json +1 -1
  91. package/plugins/lisa-wiki-devin/.claude-plugin/plugin.json +1 -1
  92. package/plugins/lisa-wiki-devin/.devin-plugin/plugin.json +1 -1
  93. package/plugins/src/nestjs/.claude-plugin/plugin.json +1 -1
  94. package/plugins/src/nestjs/hooks/block-migration-edits.sh +47 -77
  95. package/plugins/src/nestjs/skills/nestjs-rules/SKILL.md +14 -7
  96. package/scripts/generate-codex-plugin-artifacts.mjs +1 -1
  97. package/ui/index.html +1 -1
@@ -1,18 +1,23 @@
1
1
  /**
2
- * Lisa-managed OpenCode plugin (tool.execute.before).
2
+ * Lisa-managed OpenCode plugin (tool.execute.after).
3
3
  *
4
- * Blocks edits to TypeORM migration files. Use `bun run migration:generate`
5
- * to regenerate from entity diffs instead — hand-written migrations drift from
6
- * entity metadata and break the schema/migration contract.
4
+ * WARNS after an edit/write to a TypeORM migration file; it never cancels the
5
+ * edit. The name is historical — renaming it would orphan installed copies.
7
6
  *
8
- * Port of Lisa's Codex hook `block-migration-edits.sh`. OpenCode exposes only
9
- * `edit` / `write` filesystem tools (no `apply_patch`), so the file path comes
10
- * straight from `output.args.filePath`. Throwing in `tool.execute.before`
11
- * cancels the tool call and surfaces the message to the agent (verified-by-run
12
- * on opencode 1.16.2).
13
- * This adapter does not delegate to a project's migration-provenance check;
14
- * unlike the Claude and Codex adapters, it cannot permit those exceptions.
15
- * It neither verifies human approval nor inspects Bash writes.
7
+ * Why a warning (operator decision, 2026-11-08): the risk of a hand-written
8
+ * migration is drift from the entity definitions, and it only exists when the
9
+ * change could have been expressed in an entity. View options, grants,
10
+ * functions, policies, backfills and seed data cannot be, so refusing every
11
+ * migration edit blocked legitimate work.
12
+ *
13
+ * Port of Lisa's Codex hook `block-migration-edits.sh`. `tool.execute.before`
14
+ * can only cancel a call (by throwing) — it has no channel for a message that
15
+ * lets the call proceed — so the warning moves to `tool.execute.after`, which
16
+ * appends it to the tool's output text, the part the agent reads. Appending to
17
+ * `output.output` is the documented plugin API but is NOT yet verified-by-run
18
+ * here; when the field is not a string the plugin stays silent rather than
19
+ * failing a write it was only meant to annotate.
20
+ * This adapter does not delegate to a project's migration-provenance check.
16
21
  *
17
22
  * NOTE: This file is a template Lisa copies verbatim into a host project's
18
23
  * `.opencode/plugin/`. It is intentionally excluded from this repo's tsconfig
@@ -24,29 +29,23 @@ export /**
24
29
  const LisaBlockMigrationEdits = async () => {
25
30
  const MIGRATION_RE = /\/migrations\/[^/]*\d[^/]*-[^/]*\.ts$/;
26
31
  return {
27
- "tool.execute.before": async (
28
- input: { tool: string },
29
- output: { args?: { filePath?: string } }
32
+ "tool.execute.after": async (
33
+ input: { tool: string; args?: { filePath?: string } },
34
+ output: { output?: unknown }
30
35
  ) => {
31
36
  if (input.tool !== "edit" && input.tool !== "write") return;
32
- const filePath = String(output.args?.filePath ?? "");
37
+ const filePath = String(input.args?.filePath ?? "");
33
38
  if (!filePath || !MIGRATION_RE.test(filePath)) return;
34
- throw new Error(
35
- [
36
- `block-migration-edits: refusing to modify ${filePath}.`,
37
- "",
38
- "TypeORM migrations must be regenerated from entity diffs:",
39
- " bun run migration:generate -- src/database/migrations/<descriptive-name>",
40
- "",
41
- "Out-of-band migrations (backfills, seed data, maintenance) cannot",
42
- "always come from entity diffs. Document their rationale and verification.",
43
- "",
44
- "This OpenCode adapter only inspects edit/write and cannot verify",
45
- "human approval. It does not yet support the project migration-provenance",
46
- "exception check available in the Claude and Codex adapters, so it keeps",
47
- "refusing this edit. Do not switch tools to evade the refusal.",
48
- ].join("\n")
49
- );
39
+ if (typeof output.output !== "string") return;
40
+ output.output = [
41
+ output.output,
42
+ "",
43
+ `block-migration-edits: you wrote a TypeORM migration directly (${filePath}). This is allowed, but check:`,
44
+ "- Entity files are the source of truth for the database schema.",
45
+ "- If this change can be expressed in an entity (columns, indexes, relations, constraints), edit the entity instead and run: bun run migration:generate --name=<Name>",
46
+ "- If it can't (view options, grants, functions, policies, backfills, seed data), writing the migration directly is fine.",
47
+ "- If you write it by hand, document why in the migration's class comment (a generated migration needs no such note).",
48
+ ].join("\n");
50
49
  },
51
50
  };
52
51
  };
package/package.json CHANGED
@@ -196,7 +196,7 @@
196
196
  "qs": "^6.16.0"
197
197
  },
198
198
  "name": "@codyswann/lisa",
199
- "version": "4.100.6",
199
+ "version": "4.101.1",
200
200
  "description": "Governance-as-code for AI coding agents: turns a repository into agent-operated software factories with guardrails, guidance and automated enforcement for Claude Code, Codex, Cursor, OpenCode, Antigravity, Copilot and Devin",
201
201
  "main": "dist/index.js",
202
202
  "exports": {
@@ -359,7 +359,7 @@
359
359
  "test": "tests"
360
360
  },
361
361
  "types": "./dist/index.d.ts",
362
- "lisaReleaseCommit": "9d5301d6753ad024f88893f71d5c5ce6870ece15",
363
- "gitHead": "9d5301d6753ad024f88893f71d5c5ce6870ece15",
364
- "lisaReleaseTag": "v4.100.6"
362
+ "lisaReleaseCommit": "3d4d55ea0ac810e9ad76a33e6a11e305db56b601",
363
+ "gitHead": "3d4d55ea0ac810e9ad76a33e6a11e305db56b601",
364
+ "lisaReleaseTag": "v4.101.1"
365
365
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa",
3
- "version": "4.100.6",
3
+ "version": "4.101.1",
4
4
  "description": "Universal governance — agents, skills, commands, hooks, and rules for all projects",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa",
3
- "version": "4.100.6",
3
+ "version": "4.101.1",
4
4
  "description": "Universal governance: agents, skills, commands, hooks, and rules for all projects.",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa",
3
- "version": "4.100.6",
3
+ "version": "4.101.1",
4
4
  "description": "Universal governance — agents, skills, commands, hooks, and rules for all projects",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-cdk",
3
- "version": "4.100.6",
3
+ "version": "4.101.1",
4
4
  "description": "AWS CDK-specific plugin",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-cdk",
3
- "version": "4.100.6",
3
+ "version": "4.101.1",
4
4
  "description": "AWS CDK-specific Lisa plugin.",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-cdk",
3
- "version": "4.100.6",
3
+ "version": "4.101.1",
4
4
  "description": "AWS CDK-specific plugin",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-cdk",
3
- "version": "4.100.6",
3
+ "version": "4.101.1",
4
4
  "description": "AWS CDK-specific plugin",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-cdk",
3
- "version": "4.100.6",
3
+ "version": "4.101.1",
4
4
  "description": "AWS CDK-specific plugin",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-cdk",
3
- "version": "4.100.6",
3
+ "version": "4.101.1",
4
4
  "description": "AWS CDK-specific plugin",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-cdk",
3
- "version": "4.100.6",
3
+ "version": "4.101.1",
4
4
  "description": "AWS CDK-specific plugin",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa",
3
- "version": "4.100.6",
3
+ "version": "4.101.1",
4
4
  "description": "Universal governance — agents, skills, commands, hooks, and rules for all projects",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa",
3
- "version": "4.100.6",
3
+ "version": "4.101.1",
4
4
  "description": "Universal governance — agents, skills, commands, hooks, and rules for all projects",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa",
3
- "version": "4.100.6",
3
+ "version": "4.101.1",
4
4
  "description": "Universal governance — agents, skills, commands, hooks, and rules for all projects",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa",
3
- "version": "4.100.6",
3
+ "version": "4.101.1",
4
4
  "description": "Universal governance — agents, skills, commands, hooks, and rules for all projects",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-expo",
3
- "version": "4.100.6",
3
+ "version": "4.101.1",
4
4
  "description": "Expo/React Native-specific skills, agents, rules, and MCP servers",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-expo",
3
- "version": "4.100.6",
3
+ "version": "4.101.1",
4
4
  "description": "Expo and React Native-specific skills, agents, rules, and MCP servers.",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-expo",
3
- "version": "4.100.6",
3
+ "version": "4.101.1",
4
4
  "description": "Expo/React Native-specific skills, agents, rules, and MCP servers",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-expo",
3
- "version": "4.100.6",
3
+ "version": "4.101.1",
4
4
  "description": "Expo/React Native-specific skills, agents, rules, and MCP servers",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-expo",
3
- "version": "4.100.6",
3
+ "version": "4.101.1",
4
4
  "description": "Expo/React Native-specific skills, agents, rules, and MCP servers",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-expo",
3
- "version": "4.100.6",
3
+ "version": "4.101.1",
4
4
  "description": "Expo/React Native-specific skills, agents, rules, and MCP servers",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-expo",
3
- "version": "4.100.6",
3
+ "version": "4.101.1",
4
4
  "description": "Expo/React Native-specific skills, agents, rules, and MCP servers",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-harper-fabric",
3
- "version": "4.100.6",
3
+ "version": "4.101.1",
4
4
  "description": "Harper/Fabric-specific rules for TypeScript component apps",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-harper-fabric",
3
- "version": "4.100.6",
3
+ "version": "4.101.1",
4
4
  "description": "Harper/Fabric-specific Lisa rules for TypeScript component apps.",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-harper-fabric",
3
- "version": "4.100.6",
3
+ "version": "4.101.1",
4
4
  "description": "Harper/Fabric-specific rules for TypeScript component apps",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-harper-fabric",
3
- "version": "4.100.6",
3
+ "version": "4.101.1",
4
4
  "description": "Harper/Fabric-specific rules for TypeScript component apps",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-harper-fabric",
3
- "version": "4.100.6",
3
+ "version": "4.101.1",
4
4
  "description": "Harper/Fabric-specific rules for TypeScript component apps",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-harper-fabric",
3
- "version": "4.100.6",
3
+ "version": "4.101.1",
4
4
  "description": "Harper/Fabric-specific rules for TypeScript component apps",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-harper-fabric",
3
- "version": "4.100.6",
3
+ "version": "4.101.1",
4
4
  "description": "Harper/Fabric-specific rules for TypeScript component apps",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "lisa-nestjs",
3
- "version": "4.100.6",
4
- "description": "NestJS-specific skills (GraphQL, TypeORM) and hooks (migration write-protection)",
3
+ "version": "4.101.1",
4
+ "description": "NestJS-specific skills (GraphQL, TypeORM) and hooks (hand-written migration warning)",
5
5
  "author": {
6
6
  "name": "Cody Swann"
7
7
  },
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "lisa-nestjs",
3
- "version": "4.100.6",
4
- "description": "NestJS-specific skills and migration write-protection hooks.",
3
+ "version": "4.101.1",
4
+ "description": "NestJS-specific skills and a hand-written migration warning hook.",
5
5
  "author": {
6
6
  "name": "Cody Swann"
7
7
  },
@@ -47,7 +47,7 @@ The `--no-spec` flag is used because this project follows TDD (Test-Driven Devel
47
47
 
48
48
  ### Entity Files Are the Source of Truth
49
49
 
50
- In this project, **entity files (`src/database/entities/*.ts`) are the single source of truth for the database schema**. Migrations are a derived artifact — TypeORM diffs the entity metadata against the current database and emits the migration for you. The workflow is always:
50
+ In this project, **entity files (`src/database/entities/*.ts`) are the single source of truth for the database schema**. Migrations are a derived artifact — TypeORM diffs the entity metadata against the current database and emits the migration for you. For any change an entity can express, the workflow is:
51
51
 
52
52
  1. Edit the entity file to express the desired schema.
53
53
  2. Run `bun run migration:generate --name=<DescriptiveName>` to produce the migration from the diff.
@@ -61,23 +61,30 @@ Use `migration:generate` from `package.json` for changes represented by entity m
61
61
  bun run migration:generate --name=<DescriptiveName>
62
62
  ```
63
63
 
64
- ### Out-of-Band Migrations (Seed Data, Backfills)
64
+ ### Hand-Written Migrations
65
65
 
66
- Some changes genuinely cannot be derived from entity diffs:
66
+ Some changes cannot be expressed in an entity, so they cannot come from an entity diff:
67
67
 
68
+ - **Database objects TypeORM does not model** (view options, grants, functions, row-level security policies)
68
69
  - **Seed data** (reference rows, lookup tables, initial admin user)
69
70
  - **Data backfills** (populating a new column from existing rows)
70
71
  - **Data transformations** (splitting a column, normalizing values)
71
72
  - **One-off cleanup** (deleting orphaned rows before a constraint is added)
72
73
  - **Database maintenance** (refreshing planner statistics with `ANALYZE`)
73
74
 
74
- Use the project's established migration process for these cases. Document the rationale and verification in the migration's class comment so future readers understand why it was not generated. Apply the authorization already given for the work; the default edit hook does not record or verify human approval.
75
-
76
- A project that supports direct migration edits can declare its own `migration-provenance` check at `pre-tool` in `.lisa.config.json`. The Claude and Codex hooks run that check for the targeted migration and permit the edit only when it passes. The check must validate the project's migration policy; an unconditional success command proves nothing. Without a declared check, the built-in still refuses the edit. OpenCode's migration adapter currently does not support this exception path and continues to refuse it.
75
+ Writing these migrations directly is fine. The rule is: if the change can be expressed in an entity, edit the entity and run `bun run migration:generate --name=<Name>`; if it can't, write the migration. A hand-written migration documents why it was written by hand, and how it was verified, in its class comment so future readers understand why it was not generated. A generated migration needs no such note.
77
76
 
78
77
  ### Enforcement
79
78
 
80
- The `lisa-nestjs` plugin's default `PreToolUse` hook (`block-migration-edits.sh`) refuses `Write`/`Edit` on paths matching `**/migrations/*.ts` or `**/migrations/*.js`. Codex also inspects `apply_patch`; its migration matcher and OpenCode's matcher cover numbered TypeScript migration filenames. These are direct-edit checks, not an audit of migration authorship: they do not inspect Bash writes. Do not switch tools to evade a refusal. Use the supported project check where available.
79
+ The `lisa-nestjs` plugin's default `PreToolUse` hook (`block-migration-edits.sh`) **warns but does not refuse** `Write`/`Edit` on paths matching `**/migrations/*.ts` or `**/migrations/*.js`. On Claude Code the warning reaches the agent as `additionalContext` and the edit continues through the normal permission flow. The hook keeps its historical name. The point of the warning is drift: a hand-written migration for a change an entity could express will drift from the entity definitions.
80
+
81
+ Per-agent delivery:
82
+
83
+ - **Claude Code** (and the Cursor, Copilot and Devin variants built from the same script): warning as PreToolUse JSON `additionalContext`. Without `jq` the hook cannot parse the payload, so it permits the edit with a note on stderr instead of the warning.
84
+ - **Codex**: also inspects `apply_patch` and matches numbered TypeScript migration filenames. Codex does not honor `additionalContext` on PreToolUse, so the warning is written to stderr and is not known to reach the model.
85
+ - **OpenCode**: `tool.execute.after` appends the warning to the edit/write tool output after the write.
86
+
87
+ A project that wants to enforce its own migration policy can declare a `migration-provenance` check at `pre-tool` in `.lisa.config.json`. The Claude and Codex hooks run that check for the targeted migration instead of warning, and refuse the edit when it fails. The check must validate the project's migration policy; an unconditional success command proves nothing. The declared check needs `jq`: without it the hooks cannot read the target path, so they permit the edit without running the check and say so on stderr. OpenCode's adapter does not run the declared check.
81
88
 
82
89
  ### Why Auto-Generation
83
90
 
@@ -2,47 +2,43 @@
2
2
  # This file is managed by Lisa.
3
3
  # Do not edit directly — changes will be overwritten on the next `lisa` run.
4
4
 
5
- # PreToolUse hook: block Write/Edit on TypeORM migration files by default.
6
- # This scopes direct edit tools; it does not verify approval or establish the
7
- # provenance of files written through other tools.
8
- # NestJS projects must use `bun run migration:generate` to create migrations
9
- # from entity diffs. Hand-written migrations drift from entity metadata and
10
- # break the schema/migration contract.
11
- # Reference: https://docs.claude.com/en/docs/claude-code/hooks
12
- # Exit code 2 blocks the tool call and surfaces stderr to Claude.
5
+ # PreToolUse hook: WARN on Write/Edit to TypeORM migration files, then let the
6
+ # edit through. The name is historical; renaming it would orphan every
7
+ # installed copy and every `migration-provenance` declaration that points here.
13
8
  #
14
- # WHAT A REFUSAL HOOK OWES THAT AN ON-EDIT HOOK DOES NOT. The five PostToolUse
15
- # scripts may bail out when they cannot run: the write has already happened and
16
- # a skipped lint is a missed report. This one decides whether the write happens
17
- # at all, so a bail-out is a PERMIT — it lets through exactly the edit it exists
18
- # to stop, while reporting success. Every exit below is therefore one of three
19
- # things and never a fourth: out of scope (nothing to judge), judged by the
20
- # project's declared task, or judged by the built-in. "Could not judge" refuses.
9
+ # WHY A WARNING AND NOT A REFUSAL (operator decision, 2026-11-08). The risk a
10
+ # hand-written migration carries is drift from the entity definitions, and
11
+ # that risk only exists when the change COULD have been expressed in an
12
+ # entity. Plenty of migrations cannot be: view options, grants, functions,
13
+ # policies, backfills, seed data. Refusing all of them blocked legitimate work
14
+ # without making the entity route any more likely, so the hook now tells the
15
+ # agent where the change belongs and trusts it to choose.
16
+ # Reference: https://code.claude.com/docs/en/hooks#pretooluse-decision-control
17
+ #
18
+ # HOW THE WARNING REACHES THE MODEL. stderr on exit 0 is not shown to the
19
+ # model, so the warning is printed as PreToolUse JSON on stdout, in
20
+ # `hookSpecificOutput.additionalContext`. No `permissionDecision` is emitted:
21
+ # "allow" would also skip the user's permission prompt, which is a wider
22
+ # grant than "this edit is not refused" and not one this hook is entitled to
23
+ # make. Without a decision the call continues through the normal permission
24
+ # flow.
21
25
 
22
26
  JSON_INPUT=$(cat)
23
27
 
24
28
  # Project rule (host rules, .agents/rules/): never parse JSON in shell with
25
29
  # grep/sed/cut/awk — always use jq.
26
30
  #
27
- # FAIL CLOSED, reversed from the `exit 0` this shipped with. Without jq the
28
- # payload cannot be read at all, so the hook cannot tell a migration edit from
29
- # any other write — and it said so on stderr while permitting the edit anyway,
30
- # which is a guard announcing that it did not check and then waving the write
31
- # through. The refusal is unscoped for the same reason: with no parse there is
32
- # no path to scope it to.
31
+ # Without jq the payload cannot be parsed, so this hook cannot tell a migration
32
+ # edit from any other write, and cannot emit the JSON warning either. It used
33
+ # to fail closed here, which was right while the in-scope answer was "refuse":
34
+ # a bail-out would have permitted exactly the edit the hook existed to stop.
35
+ # The in-scope answer is now "permit with a warning", so permitting here loses
36
+ # only the warning, while refusing would block every write in the project
37
+ # because a WARNING could not be delivered. The stderr note names jq so the
38
+ # operator can see why the warning (and a declared gate) went unconsulted.
33
39
  if ! command -v jq >/dev/null 2>&1; then
34
- cat >&2 <<'MSG'
35
- ❌ Blocked: block-migration-edits cannot inspect this write.
36
-
37
- `jq` is not installed, so the tool payload cannot be parsed — this hook cannot
38
- tell whether the write targets a TypeORM migration. It refuses rather than
39
- permitting an edit it was unable to check.
40
-
41
- Install jq (`brew install jq`, `apt-get install jq`), or declare the
42
- `migration-provenance` gate at `pre-tool` in .lisa.config.json to have your own
43
- check decide instead.
44
- MSG
45
- exit 2
40
+ echo "block-migration-edits: jq is not installed, so this write was not inspected and is permitted without the migration warning, and a declared migration-provenance gate was NOT consulted. Install jq (brew install jq / apt-get install jq) to restore both." >&2
41
+ exit 0
46
42
  fi
47
43
 
48
44
  FILE_PATH=$(printf '%s' "$JSON_INPUT" | jq -r '.tool_input.file_path // empty')
@@ -64,25 +60,17 @@ esac
64
60
  LISA_HOOK_DIR="$(cd "$(dirname "$0")" 2>/dev/null && pwd)"
65
61
 
66
62
  # ---------------------------------------------------------------------------
67
- # Gate façade. The project's declaration decides BEFORE the built-in refuses.
68
- # Full contract, and why an undeclared project sees no change at all, in
69
- # lisa-edit-gate.sh beside this file.
70
- #
71
- # THE WORKING DIRECTORY IS PART OF THE WIRING HERE, which is why this hook was
72
- # left out of the change that wired the five on-edit ones. Those hooks already
73
- # `cd "$CLAUDE_PROJECT_DIR"` to run a tool against the tree; this one acts on
74
- # the payload and never establishes a directory at all. The helper resolves
75
- # .lisa.config.json and the gate registry RELATIVE to the current directory, so
76
- # without the `cd` it would read whatever directory the harness happened to
77
- # launch in and report "nothing declared" for a project that had declared.
63
+ # Gate façade. A project that declares `migration-provenance` at `pre-tool`
64
+ # decides these edits itself, and its decision is a real one: the declared
65
+ # task's non-zero exit refuses the write, a zero exit permits it. Full
66
+ # contract in lisa-edit-gate.sh beside this file.
78
67
  #
79
- # The `cd` is safe for the built-in below because the built-in reads only the
80
- # path out of the payload — nothing it does depends on the working directory.
81
- # That is what keeps an undeclared project on exactly the command, and exactly
82
- # the exit status, it had before.
83
- #
84
- # A project may supply its own `migration-provenance` check for these edits.
85
- # The built-in only refuses the scoped Write/Edit calls.
68
+ # THE WORKING DIRECTORY IS PART OF THE WIRING HERE. The helper resolves
69
+ # .lisa.config.json and the gate registry RELATIVE to the current directory,
70
+ # and a PreToolUse hook establishes none, so without the `cd` it would read
71
+ # whatever directory the harness launched in and report "nothing declared" for
72
+ # a project that had declared. The built-in below reads only the path out of
73
+ # the payload, so the `cd` cannot change what it does.
86
74
  # ---------------------------------------------------------------------------
87
75
  if [ -n "${CLAUDE_PROJECT_DIR:-}" ] &&
88
76
  [ -f "$LISA_HOOK_DIR/lisa-edit-gate.sh" ] &&
@@ -90,36 +78,18 @@ if [ -n "${CLAUDE_PROJECT_DIR:-}" ] &&
90
78
  # shellcheck source=/dev/null
91
79
  . "$LISA_HOOK_DIR/lisa-edit-gate.sh"
92
80
  if LISA_GATE_COMMANDS="$(lisa_edit_gate_tasks pre-tool migration-provenance)"; then
93
- # The declared task's own exit status decides the write: non-zero refuses,
94
- # exactly as the built-in's outright refusal does. A project that declares
95
- # this gate is saying its own check knows which migrations came from the
96
- # model, which is the judgement the built-in makes by refusing them all.
97
81
  lisa_edit_gate_run "$FILE_PATH" "$LISA_GATE_COMMANDS"
98
82
  exit $?
99
83
  fi
100
84
  fi
101
85
 
102
- cat >&2 <<EOF
103
- ❌ Blocked: This default hook refuses Write/Edit on TypeORM migration files.
104
-
105
- File: $FILE_PATH
106
-
107
- Entity files (src/database/entities/*.ts) are the single source of
108
- truth for the database schema in this project. Migrations are a derived
109
- artifact — generate them from entity diffs:
110
-
111
- 1. Edit the entity to express the desired schema.
112
- 2. Run: bun run migration:generate --name=<DescriptiveName>
113
- 3. Review the generated migration; commit entity + migration together.
86
+ WARNING="block-migration-edits: you are writing a TypeORM migration directly (${FILE_PATH}). This is allowed, but check first:
114
87
 
115
- Out-of-band migrations (backfills, seed data, maintenance) cannot always
116
- come from entity diffs. A project that supports these edits can declare a
117
- \`migration-provenance\` check at \`pre-tool\` in .lisa.config.json. The hook
118
- runs that check and uses its result to permit or refuse the edit.
88
+ - Entity files are the source of truth for the database schema.
89
+ - If this change can be expressed in an entity (columns, indexes, relations, constraints), edit the entity instead and run: bun run migration:generate --name=<Name>
90
+ - If it can't (view options, grants, functions, policies, backfills, seed data), writing the migration directly is fine.
91
+ - If you write it by hand, document why in the migration's class comment (a generated migration needs no such note)."
119
92
 
120
- Document the migration's rationale and verification in its class comment.
121
- This default hook cannot verify human approval and does not inspect Bash
122
- writes. Do not switch tools to evade its refusal. See the nestjs-rules skill
123
- for the supported project-check path.
124
- EOF
125
- exit 2
93
+ jq -n --arg ctx "$WARNING" \
94
+ '{hookSpecificOutput: {hookEventName: "PreToolUse", additionalContext: $ctx}}'
95
+ exit 0