intentdna 1.2.2 → 1.2.3

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 (180) hide show
  1. package/dist/audit/index.d.ts +0 -1
  2. package/dist/audit/index.js +0 -1
  3. package/dist/cli/commands/compile.d.ts +0 -1
  4. package/dist/cli/commands/compile.js +0 -1
  5. package/dist/cli/commands/epigenetic.d.ts +0 -1
  6. package/dist/cli/commands/epigenetic.js +0 -1
  7. package/dist/cli/commands/evolve.d.ts +0 -1
  8. package/dist/cli/commands/evolve.js +0 -1
  9. package/dist/cli/commands/guard.d.ts +0 -1
  10. package/dist/cli/commands/guard.js +0 -3
  11. package/dist/cli/commands/import.d.ts +0 -1
  12. package/dist/cli/commands/import.js +0 -1
  13. package/dist/cli/commands/init.d.ts +0 -1
  14. package/dist/cli/commands/init.js +0 -1
  15. package/dist/cli/commands/run.d.ts +0 -1
  16. package/dist/cli/commands/run.js +4 -27
  17. package/dist/cli/commands/show.d.ts +0 -1
  18. package/dist/cli/commands/show.js +0 -1
  19. package/dist/cli/commands/sync.d.ts +1 -1
  20. package/dist/cli/commands/sync.js +57 -32
  21. package/dist/cli/commands/validate.d.ts +0 -1
  22. package/dist/cli/commands/validate.js +0 -1
  23. package/dist/cli/commands/verify.d.ts +0 -1
  24. package/dist/cli/commands/verify.js +0 -1
  25. package/dist/cli/index.d.ts +0 -1
  26. package/dist/cli/index.js +2 -1
  27. package/dist/cli/util/format.d.ts +0 -1
  28. package/dist/cli/util/format.js +0 -1
  29. package/dist/cli/util/prompt.d.ts +0 -1
  30. package/dist/cli/util/prompt.js +0 -1
  31. package/dist/compiler/activate.d.ts +0 -1
  32. package/dist/compiler/activate.js +0 -1
  33. package/dist/compiler/cascade.d.ts +1 -3
  34. package/dist/compiler/cascade.js +1 -10
  35. package/dist/compiler/compile.d.ts +0 -1
  36. package/dist/compiler/compile.js +3 -17
  37. package/dist/compiler/index.d.ts +0 -1
  38. package/dist/compiler/index.js +0 -1
  39. package/dist/compiler/workflow.d.ts +0 -1
  40. package/dist/compiler/workflow.js +0 -2
  41. package/dist/evolution/collector.d.ts +0 -1
  42. package/dist/evolution/collector.js +0 -1
  43. package/dist/evolution/fitness.d.ts +0 -1
  44. package/dist/evolution/fitness.js +0 -1
  45. package/dist/evolution/index.d.ts +0 -1
  46. package/dist/evolution/index.js +0 -1
  47. package/dist/evolution/marker-gen.d.ts +0 -1
  48. package/dist/evolution/marker-gen.js +0 -1
  49. package/dist/evolution/store.d.ts +0 -1
  50. package/dist/evolution/store.js +0 -1
  51. package/dist/evolution/types.d.ts +0 -1
  52. package/dist/evolution/types.js +0 -1
  53. package/dist/hooks/cli.d.ts +17 -0
  54. package/dist/hooks/cli.js +134 -0
  55. package/dist/hooks/enforce.d.ts +68 -0
  56. package/dist/hooks/enforce.js +332 -0
  57. package/dist/hooks/index.d.ts +9 -0
  58. package/dist/hooks/index.js +12 -0
  59. package/dist/hooks/protocol.d.ts +70 -0
  60. package/dist/hooks/protocol.js +91 -0
  61. package/dist/hooks/state.d.ts +53 -0
  62. package/dist/hooks/state.js +93 -0
  63. package/dist/index.d.ts +0 -1
  64. package/dist/index.js +0 -1
  65. package/dist/log/logger.d.ts +0 -1
  66. package/dist/log/logger.js +0 -1
  67. package/dist/runtime/agent-md.d.ts +0 -1
  68. package/dist/runtime/agent-md.js +95 -105
  69. package/dist/runtime/claude-sdk.d.ts +0 -1
  70. package/dist/runtime/claude-sdk.js +0 -1
  71. package/dist/runtime/index.d.ts +3 -3
  72. package/dist/runtime/index.js +2 -2
  73. package/dist/runtime/markdown.d.ts +0 -1
  74. package/dist/runtime/markdown.js +0 -1
  75. package/dist/runtime/plugin-adapter.d.ts +42 -0
  76. package/dist/runtime/plugin-adapter.js +77 -0
  77. package/dist/runtime/settings-adapter.d.ts +8 -9
  78. package/dist/runtime/settings-adapter.js +57 -46
  79. package/dist/runtime/skill-adapter.d.ts +0 -1
  80. package/dist/runtime/skill-adapter.js +94 -71
  81. package/dist/runtime/workflow-runner.d.ts +0 -1
  82. package/dist/runtime/workflow-runner.js +0 -14
  83. package/dist/schema/index.d.ts +0 -1
  84. package/dist/schema/index.js +0 -1
  85. package/dist/schema/types.d.ts +14 -20
  86. package/dist/schema/types.js +0 -1
  87. package/dist/schema/validate.d.ts +0 -1
  88. package/dist/schema/validate.js +3 -19
  89. package/dist/schema/yaml-parser.d.ts +0 -1
  90. package/dist/schema/yaml-parser.js +0 -1
  91. package/dist/templates/code-review-pipeline.dna.yaml +0 -11
  92. package/dist/templates/flutter-behavior-lock.dna.yaml +0 -16
  93. package/dist/templates/flutter-refactoring-rescue.dna.yaml +0 -12
  94. package/dist/templates/flutter-rewrite.dna.yaml +0 -27
  95. package/dist/templates/full-pipeline.dna.yaml +0 -25
  96. package/dist/templates/multi-perspective-review.dna.yaml +0 -12
  97. package/dist/templates/subagent-parallel.dna.yaml +0 -16
  98. package/package.json +3 -2
  99. package/dist/audit/index.d.ts.map +0 -1
  100. package/dist/audit/index.js.map +0 -1
  101. package/dist/cli/commands/compile.d.ts.map +0 -1
  102. package/dist/cli/commands/compile.js.map +0 -1
  103. package/dist/cli/commands/epigenetic.d.ts.map +0 -1
  104. package/dist/cli/commands/epigenetic.js.map +0 -1
  105. package/dist/cli/commands/evolve.d.ts.map +0 -1
  106. package/dist/cli/commands/evolve.js.map +0 -1
  107. package/dist/cli/commands/guard.d.ts.map +0 -1
  108. package/dist/cli/commands/guard.js.map +0 -1
  109. package/dist/cli/commands/import.d.ts.map +0 -1
  110. package/dist/cli/commands/import.js.map +0 -1
  111. package/dist/cli/commands/init.d.ts.map +0 -1
  112. package/dist/cli/commands/init.js.map +0 -1
  113. package/dist/cli/commands/run.d.ts.map +0 -1
  114. package/dist/cli/commands/run.js.map +0 -1
  115. package/dist/cli/commands/show.d.ts.map +0 -1
  116. package/dist/cli/commands/show.js.map +0 -1
  117. package/dist/cli/commands/sync.d.ts.map +0 -1
  118. package/dist/cli/commands/sync.js.map +0 -1
  119. package/dist/cli/commands/validate.d.ts.map +0 -1
  120. package/dist/cli/commands/validate.js.map +0 -1
  121. package/dist/cli/commands/verify.d.ts.map +0 -1
  122. package/dist/cli/commands/verify.js.map +0 -1
  123. package/dist/cli/index.d.ts.map +0 -1
  124. package/dist/cli/index.js.map +0 -1
  125. package/dist/cli/util/format.d.ts.map +0 -1
  126. package/dist/cli/util/format.js.map +0 -1
  127. package/dist/cli/util/prompt.d.ts.map +0 -1
  128. package/dist/cli/util/prompt.js.map +0 -1
  129. package/dist/compiler/activate.d.ts.map +0 -1
  130. package/dist/compiler/activate.js.map +0 -1
  131. package/dist/compiler/cascade.d.ts.map +0 -1
  132. package/dist/compiler/cascade.js.map +0 -1
  133. package/dist/compiler/compile.d.ts.map +0 -1
  134. package/dist/compiler/compile.js.map +0 -1
  135. package/dist/compiler/index.d.ts.map +0 -1
  136. package/dist/compiler/index.js.map +0 -1
  137. package/dist/compiler/workflow.d.ts.map +0 -1
  138. package/dist/compiler/workflow.js.map +0 -1
  139. package/dist/evolution/collector.d.ts.map +0 -1
  140. package/dist/evolution/collector.js.map +0 -1
  141. package/dist/evolution/fitness.d.ts.map +0 -1
  142. package/dist/evolution/fitness.js.map +0 -1
  143. package/dist/evolution/index.d.ts.map +0 -1
  144. package/dist/evolution/index.js.map +0 -1
  145. package/dist/evolution/marker-gen.d.ts.map +0 -1
  146. package/dist/evolution/marker-gen.js.map +0 -1
  147. package/dist/evolution/store.d.ts.map +0 -1
  148. package/dist/evolution/store.js.map +0 -1
  149. package/dist/evolution/types.d.ts.map +0 -1
  150. package/dist/evolution/types.js.map +0 -1
  151. package/dist/index.d.ts.map +0 -1
  152. package/dist/index.js.map +0 -1
  153. package/dist/log/logger.d.ts.map +0 -1
  154. package/dist/log/logger.js.map +0 -1
  155. package/dist/runtime/agent-md.d.ts.map +0 -1
  156. package/dist/runtime/agent-md.js.map +0 -1
  157. package/dist/runtime/claude-sdk.d.ts.map +0 -1
  158. package/dist/runtime/claude-sdk.js.map +0 -1
  159. package/dist/runtime/hooks.d.ts +0 -67
  160. package/dist/runtime/hooks.d.ts.map +0 -1
  161. package/dist/runtime/hooks.js +0 -785
  162. package/dist/runtime/hooks.js.map +0 -1
  163. package/dist/runtime/index.d.ts.map +0 -1
  164. package/dist/runtime/index.js.map +0 -1
  165. package/dist/runtime/markdown.d.ts.map +0 -1
  166. package/dist/runtime/markdown.js.map +0 -1
  167. package/dist/runtime/settings-adapter.d.ts.map +0 -1
  168. package/dist/runtime/settings-adapter.js.map +0 -1
  169. package/dist/runtime/skill-adapter.d.ts.map +0 -1
  170. package/dist/runtime/skill-adapter.js.map +0 -1
  171. package/dist/runtime/workflow-runner.d.ts.map +0 -1
  172. package/dist/runtime/workflow-runner.js.map +0 -1
  173. package/dist/schema/index.d.ts.map +0 -1
  174. package/dist/schema/index.js.map +0 -1
  175. package/dist/schema/types.d.ts.map +0 -1
  176. package/dist/schema/types.js.map +0 -1
  177. package/dist/schema/validate.d.ts.map +0 -1
  178. package/dist/schema/validate.js.map +0 -1
  179. package/dist/schema/yaml-parser.d.ts.map +0 -1
  180. package/dist/schema/yaml-parser.js.map +0 -1
@@ -106,4 +106,3 @@ export declare function generateAuditSummary(logDir: string, from: string, to: s
106
106
  * Render audit summary as markdown.
107
107
  */
108
108
  export declare function renderAuditReport(summary: AuditSummary): string;
109
- //# sourceMappingURL=index.d.ts.map
@@ -141,4 +141,3 @@ export function renderAuditReport(summary) {
141
141
  }
142
142
  return lines.join("\n");
143
143
  }
144
- //# sourceMappingURL=index.js.map
@@ -11,4 +11,3 @@ export interface CompileOptions {
11
11
  ir: boolean;
12
12
  }
13
13
  export declare function runCompile(opts: CompileOptions): Promise<number>;
14
- //# sourceMappingURL=compile.d.ts.map
@@ -86,4 +86,3 @@ export async function runCompile(opts) {
86
86
  return 1;
87
87
  }
88
88
  }
89
- //# sourceMappingURL=compile.js.map
@@ -17,4 +17,3 @@ export interface EpigeneticOptions {
17
17
  json?: boolean;
18
18
  }
19
19
  export declare function runEpigenetic(opts: EpigeneticOptions): Promise<number>;
20
- //# sourceMappingURL=epigenetic.d.ts.map
@@ -109,4 +109,3 @@ async function doMarkers(engine, opts) {
109
109
  }
110
110
  return 0;
111
111
  }
112
- //# sourceMappingURL=epigenetic.js.map
@@ -9,4 +9,3 @@ export interface EvolveOptions {
9
9
  storeDir?: string;
10
10
  }
11
11
  export declare function runEvolve(opts: EvolveOptions): Promise<number>;
12
- //# sourceMappingURL=evolve.d.ts.map
@@ -49,4 +49,3 @@ export async function runEvolve(opts) {
49
49
  return 1;
50
50
  }
51
51
  }
52
- //# sourceMappingURL=evolve.js.map
@@ -19,4 +19,3 @@ export interface GuardOptions {
19
19
  remove: boolean;
20
20
  }
21
21
  export declare function runGuard(opts: GuardOptions): Promise<number>;
22
- //# sourceMappingURL=guard.d.ts.map
@@ -177,7 +177,6 @@ export async function runGuard(opts) {
177
177
  const r = await runSync({
178
178
  files: [], target: "claude-md",
179
179
  inject: join(cwd, "CLAUDE.md"),
180
- hooksDir: join(cwd, ".claude", "hooks"),
181
180
  evolve: false, remove: true,
182
181
  });
183
182
  if (r !== 0)
@@ -215,7 +214,6 @@ export async function runGuard(opts) {
215
214
  files: [tmpFile],
216
215
  target: "claude-md",
217
216
  inject: join(cwd, "CLAUDE.md"),
218
- hooksDir: join(cwd, ".claude", "hooks"),
219
217
  evolve: false, remove: false,
220
218
  });
221
219
  if (r !== 0)
@@ -254,4 +252,3 @@ export async function runGuard(opts) {
254
252
  await rm(tmpFile, { force: true });
255
253
  }
256
254
  }
257
- //# sourceMappingURL=guard.js.map
@@ -68,4 +68,3 @@ export declare function parseClaudeMD(content: string): {
68
68
  export declare function importHarness(dir: string): Promise<ImportResult>;
69
69
  export declare function generateDNAYaml(result: ImportResult, projectName?: string): string;
70
70
  export declare function runImport(opts: ImportOptions): Promise<number>;
71
- //# sourceMappingURL=import.d.ts.map
@@ -426,4 +426,3 @@ async function safeReaddir(path) {
426
426
  return [];
427
427
  }
428
428
  }
429
- //# sourceMappingURL=import.js.map
@@ -12,4 +12,3 @@ export interface InitOptions {
12
12
  upgrade?: string | boolean;
13
13
  }
14
14
  export declare function runInit(opts: InitOptions): Promise<number>;
15
- //# sourceMappingURL=init.d.ts.map
@@ -364,4 +364,3 @@ export async function runInit(opts) {
364
364
  return 1;
365
365
  }
366
366
  }
367
- //# sourceMappingURL=init.js.map
@@ -56,4 +56,3 @@ export declare function executeGroup(group: ParallelGroup, allSteps: WorkflowSte
56
56
  export declare function checkRetryNeeded(stepResults: Map<string, StepResult>, transitions: TransitionRule[]): boolean;
57
57
  export declare function runRun(opts: RunOptions): Promise<number>;
58
58
  export {};
59
- //# sourceMappingURL=run.d.ts.map
@@ -13,7 +13,7 @@ import { loadDNA, compileFromFiles } from "../../compiler/index.js";
13
13
  import { cascadeDNA } from "../../compiler/cascade.js";
14
14
  import { compileWorkflow } from "../../compiler/workflow.js";
15
15
  import { compileAllRolesToAgentMD, writeAgentMDFiles, toKebabCase, } from "../../runtime/agent-md.js";
16
- import { compileToHooks, writeHookScripts } from "../../runtime/hooks.js";
16
+ import { createCompiledIR, writeCompiledIR } from "../../runtime/plugin-adapter.js";
17
17
  // ── Template & Condition Helpers ───────────────────────────
18
18
  /**
19
19
  * Replace {{var}} placeholders in a template string.
@@ -127,21 +127,6 @@ export async function executeStep(step, vars, opts) {
127
127
  "--no-session-persistence",
128
128
  ];
129
129
  log(`Running step: ${step.id} (agent: ${agentName})`);
130
- // Write mode file if step declares a mode
131
- if (step.mode) {
132
- const modeData = JSON.stringify({
133
- active_mode: step.mode,
134
- set_at: new Date().toISOString(),
135
- set_by: `run:${step.id}`,
136
- });
137
- try {
138
- const { mkdir: mkdirAsync, writeFile: writeFileAsync } = await import("node:fs/promises");
139
- await mkdirAsync(".dna", { recursive: true });
140
- await writeFileAsync(".dna/mode", modeData, "utf-8");
141
- log(`Mode set: ${step.mode}`);
142
- }
143
- catch { /* best effort */ }
144
- }
145
130
  try {
146
131
  const output = await spawnAsync("claude", args, prompt);
147
132
  await writeFile(resultFile, output, "utf-8");
@@ -271,7 +256,6 @@ export async function runRun(opts) {
271
256
  const maxBudget = opts.maxBudget ?? 5;
272
257
  const permissionMode = opts.permissionMode ?? "bypassPermissions";
273
258
  const agentsDir = opts.agentsDir ?? ".claude/agents";
274
- const hooksDir = opts.hooksDir ?? ".claude/hooks";
275
259
  try {
276
260
  // ── Step 1: Load & compile DNA ───────────────────────
277
261
  log("Loading DNA files...");
@@ -311,9 +295,9 @@ export async function runRun(opts) {
311
295
  const agentResults = compileAllRolesToAgentMD(cascaded.roles, ir);
312
296
  await writeAgentMDFiles(agentResults, agentsDir);
313
297
  log(`Generated ${agentResults.length} agent file(s) in ${agentsDir}`);
314
- const hookScripts = compileToHooks(ir);
315
- await writeHookScripts(hooksDir, hookScripts);
316
- log(`Generated hook scripts in ${hooksDir}`);
298
+ const hookScripts = createCompiledIR(ir, cascaded.roles);
299
+ await writeCompiledIR(process.cwd(), hookScripts);
300
+ log("Synced compiled IR for dna-hook enforcement");
317
301
  // ── Step 5: Prepare log directory ────────────────────
318
302
  const timestamp = new Date().toISOString().replace(/[:.]/g, "-");
319
303
  const logDir = opts.logDir ?? join(".intentdna", "runs", `${opts.workflowName}-${timestamp}`);
@@ -367,12 +351,6 @@ export async function runRun(opts) {
367
351
  // All passed
368
352
  break;
369
353
  }
370
- // Clean up mode file after workflow completes
371
- try {
372
- const { rm: rmAsync } = await import("node:fs/promises");
373
- await rmAsync(".dna/mode", { force: true });
374
- }
375
- catch { /* best effort */ }
376
354
  return printSummary(stepResults, round, logDir, 0);
377
355
  }
378
356
  catch (err) {
@@ -428,4 +406,3 @@ function printSummary(results, rounds, logDir, exitCode) {
428
406
  process.stderr.write(`\nTotal: ${passed} passed, ${failed} failed, ${skipped} skipped\n`);
429
407
  return exitCode;
430
408
  }
431
- //# sourceMappingURL=run.js.map
@@ -9,4 +9,3 @@ export interface ShowOptions {
9
9
  json: boolean;
10
10
  }
11
11
  export declare function runShow(opts: ShowOptions): Promise<number>;
12
- //# sourceMappingURL=show.d.ts.map
@@ -75,4 +75,3 @@ export async function runShow(opts) {
75
75
  return 1;
76
76
  }
77
77
  }
78
- //# sourceMappingURL=show.js.map
@@ -26,6 +26,6 @@ export interface SyncOptions {
26
26
  settingsPath?: string;
27
27
  lockFile?: string;
28
28
  remove: boolean;
29
+ plugin?: boolean;
29
30
  }
30
31
  export declare function runSync(opts: SyncOptions): Promise<number>;
31
- //# sourceMappingURL=sync.d.ts.map
@@ -17,11 +17,11 @@ import { fileURLToPath } from "node:url";
17
17
  import { createInterface } from "node:readline";
18
18
  import { loadDNA, compileFromFiles } from "../../compiler/index.js";
19
19
  import { compileToMarkdown, injectIntoFile, removeFromFile } from "../../runtime/markdown.js";
20
- import { compileToHooks, writeHookScripts, removeHookScripts } from "../../runtime/hooks.js";
21
20
  import { compileAllRolesToAgentMD, writeAgentMDFiles, removeAgentMDFiles } from "../../runtime/agent-md.js";
22
21
  import { removeWorkflowScripts } from "../../runtime/workflow-runner.js";
23
22
  import { compileWorkflowToSkill, writeSkillFiles } from "../../runtime/skill-adapter.js";
24
- import { compileSettingsFromHooks, mergeSettingsFile } from "../../runtime/settings-adapter.js";
23
+ import { compilePluginSettings, detectEnabledEvents, mergeSettingsFile } from "../../runtime/settings-adapter.js";
24
+ import { createCompiledIR, writeCompiledIR } from "../../runtime/plugin-adapter.js";
25
25
  import { cascadeDNA } from "../../compiler/cascade.js";
26
26
  import { EvolutionEngine } from "../../evolution/index.js";
27
27
  const VALID_TARGETS = ["claude-md", "soul-md", "cursorrules", "system-prompt"];
@@ -35,6 +35,33 @@ async function fileExists(path) {
35
35
  }
36
36
  }
37
37
  const DNA_SENTINEL = "intentdna:managed";
38
+ const LEGACY_BASH_HOOKS = [
39
+ "dna-pre-tool-use.sh",
40
+ "dna-post-tool-use.sh",
41
+ "dna-user-prompt-submit.sh",
42
+ "dna-subagent-stop.sh",
43
+ "dna-pre-compact.sh",
44
+ "dna-notification.sh",
45
+ ];
46
+ /**
47
+ * Remove legacy bash hook scripts written by previous Intent DNA versions.
48
+ * Only removes files that contain the sentinel comment.
49
+ */
50
+ async function removeLegacyBashHooks(hooksDir) {
51
+ let removed = 0;
52
+ for (const file of LEGACY_BASH_HOOKS) {
53
+ const path = resolve(hooksDir, file);
54
+ try {
55
+ const content = await readFile(path, "utf-8");
56
+ if (content.includes("intentdna:managed")) {
57
+ await unlink(path);
58
+ removed++;
59
+ }
60
+ }
61
+ catch { /* File doesn't exist, skip */ }
62
+ }
63
+ return removed;
64
+ }
38
65
  /**
39
66
  * Remove stale DNA-managed files from a directory.
40
67
  * Scans for files/dirs containing the sentinel marker and deletes them.
@@ -212,11 +239,10 @@ export async function runSync(opts) {
212
239
  const hasClaudeMd = await fileExists(resolve(cwd, "CLAUDE.md"));
213
240
  if (hasClaudeDir || hasClaudeMd || opts.files.length > 0) {
214
241
  opts.inject = resolve(cwd, "CLAUDE.md");
215
- opts.hooksDir = resolve(cwd, ".claude", "hooks");
216
242
  opts.agentsDir = resolve(cwd, ".claude", "agents");
217
243
  opts.skillsDir = resolve(cwd, ".claude", "skills");
218
244
  opts.settingsPath = resolve(cwd, ".claude", "settings.json");
219
- process.stderr.write(`Auto-detect: Claude Code → CLAUDE.md + hooks + agents + skills + settings\n`);
245
+ process.stderr.write(`Auto-detect: Claude Code → CLAUDE.md + agents + skills + settings\n`);
220
246
  }
221
247
  }
222
248
  // Handle --remove
@@ -235,12 +261,12 @@ export async function runSync(opts) {
235
261
  }
236
262
  }
237
263
  if (opts.hooksDir) {
238
- const count = await removeHookScripts(opts.hooksDir);
264
+ const count = await removeLegacyBashHooks(opts.hooksDir);
239
265
  if (count > 0) {
240
- process.stderr.write(`Removed ${count} Intent DNA hook script(s) from ${opts.hooksDir}\n`);
266
+ process.stderr.write(`Removed ${count} legacy bash hook(s) from ${opts.hooksDir}\n`);
241
267
  }
242
268
  else {
243
- process.stderr.write(`No Intent DNA hook scripts found in ${opts.hooksDir}\n`);
269
+ process.stderr.write(`No legacy bash hooks found in ${opts.hooksDir}\n`);
244
270
  }
245
271
  }
246
272
  if (opts.agentsDir) {
@@ -314,24 +340,32 @@ export async function runSync(opts) {
314
340
  }
315
341
  trackedOutputs.push(resolve(opts.inject));
316
342
  }
317
- // Step 4: Generate hook scripts
318
- if (opts.hooksDir) {
319
- const scripts = compileToHooks(ir);
320
- const written = await writeHookScripts(opts.hooksDir, scripts);
321
- if (written.length > 0) {
322
- process.stderr.write(`Generated ${written.length} hook script(s) in ${opts.hooksDir}\n`);
323
- for (const f of written) {
324
- process.stderr.write(` ${f}\n`);
325
- }
326
- trackedOutputs.push(...written.map(f => resolve(f)));
327
- // Report role scope information
328
- if (ir.roles_scope_map && ir.roles_scope_map.length > 0) {
329
- const roleNames = ir.roles_scope_map.map(r => r.role_name).join(", ");
330
- process.stderr.write(` ${ir.roles_scope_map.length} role scope(s) compiled: ${roleNames}\n`);
343
+ // Step 3.5: Plugin mode — write IR + register dna-hook
344
+ if (opts.plugin) {
345
+ const cwd = process.cwd();
346
+ // Write compiled IR
347
+ const dnas = await Promise.all(expandedFiles.map(loadDNA));
348
+ const cascadedForIR = cascadeDNA(dnas);
349
+ const roles = cascadedForIR.roles;
350
+ const compiled = createCompiledIR(ir, roles);
351
+ const irPath = await writeCompiledIR(cwd, compiled);
352
+ process.stderr.write(`Plugin: wrote ${irPath}\n`);
353
+ trackedOutputs.push(resolve(irPath));
354
+ // Register dna-hook events in settings.json
355
+ if (opts.settingsPath) {
356
+ const enabledEvents = detectEnabledEvents(ir);
357
+ if (enabledEvents.length > 0) {
358
+ const pluginSettings = compilePluginSettings(enabledEvents);
359
+ await mergeSettingsFile(pluginSettings, opts.settingsPath);
360
+ process.stderr.write(`Plugin: registered ${enabledEvents.length} dna-hook event(s) in ${opts.settingsPath}\n`);
361
+ trackedOutputs.push(resolve(opts.settingsPath));
331
362
  }
332
363
  }
333
- else {
334
- process.stderr.write(`No hook-enforceable constraints found\n`);
364
+ // Clean up old bash hooks if they exist
365
+ const oldHooksDir = resolve(cwd, ".claude", "hooks");
366
+ const removed = await removeLegacyBashHooks(oldHooksDir);
367
+ if (removed > 0) {
368
+ process.stderr.write(`Plugin: cleaned ${removed} legacy bash hook(s) from ${oldHooksDir}\n`);
335
369
  }
336
370
  }
337
371
  // Step 5: Generate agent MD files
@@ -436,14 +470,6 @@ export async function runSync(opts) {
436
470
  }
437
471
  }
438
472
  }
439
- // Step 8: Generate/merge settings file
440
- if (opts.settingsPath && opts.hooksDir) {
441
- const hookScripts = compileToHooks(ir);
442
- const dnaSettings = compileSettingsFromHooks(opts.hooksDir, hookScripts);
443
- await mergeSettingsFile(dnaSettings, opts.settingsPath);
444
- process.stderr.write(`Merged DNA hook config into ${opts.settingsPath}\n`);
445
- trackedOutputs.push(resolve(opts.settingsPath));
446
- }
447
473
  // Also output the compiled content to stderr for visibility
448
474
  const directiveCount = ir.prompt_directives.length;
449
475
  const gateCount = ir.pre_execution_gates.length;
@@ -462,4 +488,3 @@ export async function runSync(opts) {
462
488
  return 1;
463
489
  }
464
490
  }
465
- //# sourceMappingURL=sync.js.map
@@ -8,4 +8,3 @@ export interface ValidateOptions {
8
8
  quiet: boolean;
9
9
  }
10
10
  export declare function runValidate(opts: ValidateOptions): Promise<number>;
11
- //# sourceMappingURL=validate.d.ts.map
@@ -27,4 +27,3 @@ export async function runValidate(opts) {
27
27
  }
28
28
  return allValid ? 0 : 1;
29
29
  }
30
- //# sourceMappingURL=validate.js.map
@@ -30,4 +30,3 @@ export declare function sha256(content: string): string;
30
30
  export declare function parseLockFile(raw: string): LockFile;
31
31
  export declare function verifyLock(lock: LockFile): Promise<VerifyResult[]>;
32
32
  export declare function runVerify(opts: VerifyOptions): Promise<number>;
33
- //# sourceMappingURL=verify.d.ts.map
@@ -99,4 +99,3 @@ export async function runVerify(opts) {
99
99
  return 0;
100
100
  }
101
101
  }
102
- //# sourceMappingURL=verify.js.map
@@ -12,4 +12,3 @@
12
12
  * help Show this help message
13
13
  */
14
14
  export {};
15
- //# sourceMappingURL=index.d.ts.map
package/dist/cli/index.js CHANGED
@@ -87,6 +87,7 @@ async function main() {
87
87
  settings: { type: "string" },
88
88
  lock: { type: "string", default: ".dna/lock" },
89
89
  remove: { type: "boolean", default: false },
90
+ plugin: { type: "boolean", default: false },
90
91
  },
91
92
  allowPositionals: true,
92
93
  strict: false,
@@ -108,6 +109,7 @@ async function main() {
108
109
  settingsPath: values.settings,
109
110
  lockFile: values.lock,
110
111
  remove: values.remove,
112
+ plugin: values.plugin,
111
113
  });
112
114
  process.exit(code);
113
115
  break;
@@ -363,4 +365,3 @@ main().catch((err) => {
363
365
  process.stderr.write(`Fatal: ${err instanceof Error ? err.message : String(err)}\n`);
364
366
  process.exit(1);
365
367
  });
366
- //# sourceMappingURL=index.js.map
@@ -21,4 +21,3 @@ export declare function formatCodon(codon: Codon): string;
21
21
  * Format a gene with its expression state for display.
22
22
  */
23
23
  export declare function formatGene(name: string, gene: ActivatedGene): string;
24
- //# sourceMappingURL=format.d.ts.map
@@ -64,4 +64,3 @@ export function formatGene(name, gene) {
64
64
  }
65
65
  return lines.join("\n");
66
66
  }
67
- //# sourceMappingURL=format.js.map
@@ -8,4 +8,3 @@ export declare function askString(question: string, defaultVal?: string): Promis
8
8
  export declare function askNumber(question: string, defaultVal: number): Promise<number>;
9
9
  export declare function askChoice(question: string, choices: string[], defaultVal?: string): Promise<string>;
10
10
  export declare function askYesNo(question: string, defaultVal: boolean): Promise<boolean>;
11
- //# sourceMappingURL=prompt.d.ts.map
@@ -48,4 +48,3 @@ export async function askYesNo(question, defaultVal) {
48
48
  return defaultVal;
49
49
  return answer.toLowerCase().startsWith("y");
50
50
  }
51
- //# sourceMappingURL=prompt.js.map
@@ -26,4 +26,3 @@ export interface ActivatedGene {
26
26
  * Returns the final gene expression state ready for compilation to IR.
27
27
  */
28
28
  export declare function activateDNA(cascaded: CascadedDNA, contextName?: string | null, activeRole?: string | null): ActivatedDNA;
29
- //# sourceMappingURL=activate.d.ts.map
@@ -138,4 +138,3 @@ export function activateDNA(cascaded, contextName = null, activeRole = null) {
138
138
  source_ids: cascaded.source_ids,
139
139
  };
140
140
  }
141
- //# sourceMappingURL=activate.js.map
@@ -10,12 +10,11 @@
10
10
  * - attract/repel: same target accumulates, different targets independent
11
11
  * - amplify/suppress: factors multiply (1.5x × 2.0x = 3.0x)
12
12
  */
13
- import type { IntentDNA, Gene, ContextRegion, EpigeneticMarker, RoleDef, WorkflowDef, ModeDef } from "../schema/types.js";
13
+ import type { IntentDNA, Gene, ContextRegion, EpigeneticMarker, RoleDef, WorkflowDef } from "../schema/types.js";
14
14
  export interface CascadedDNA {
15
15
  genes: Record<string, Gene>;
16
16
  contexts: Record<string, ContextRegion>;
17
17
  roles: Record<string, RoleDef>;
18
- modes: Record<string, ModeDef>;
19
18
  workflows: Record<string, WorkflowDef>;
20
19
  epigenetic_markers: EpigeneticMarker[];
21
20
  source_ids: string[];
@@ -31,4 +30,3 @@ export interface CascadedDNA {
31
30
  * - Same namespace: higher priority replaces (expected cascade behavior)
32
31
  */
33
32
  export declare function cascadeDNA(layers: IntentDNA[]): CascadedDNA;
34
- //# sourceMappingURL=cascade.d.ts.map
@@ -81,7 +81,6 @@ function prefixWorkflowRoles(wf, ns) {
81
81
  steps: wf.steps.map((step) => ({
82
82
  ...step,
83
83
  role: `${ns}_${step.role}`,
84
- mode: step.mode ? `${ns}_${step.mode}` : undefined,
85
84
  })),
86
85
  };
87
86
  }
@@ -101,7 +100,6 @@ export function cascadeDNA(layers) {
101
100
  const mergedGenes = {};
102
101
  const mergedContexts = {};
103
102
  const mergedRoles = {};
104
- const mergedModes = {};
105
103
  const mergedWorkflows = {};
106
104
  const allMarkers = [];
107
105
  const sourceIds = [];
@@ -126,12 +124,7 @@ export function cascadeDNA(layers) {
126
124
  const key = ns ? `${ns}_${name}` : name;
127
125
  mergedRoles[key] = role;
128
126
  }
129
- // Merge modes: namespace-prefixed keys coexist, same-namespace overrides
130
- for (const [name, mode] of Object.entries(dna.modes ?? {})) {
131
- const key = ns ? `${ns}_${name}` : name;
132
- mergedModes[key] = mode;
133
- }
134
- // Merge workflows: namespace-prefixed keys + step role/mode references
127
+ // Merge workflows: namespace-prefixed keys + step role references
135
128
  const normalized = normalizeWorkflowsFromDNA(dna);
136
129
  for (const [name, wf] of Object.entries(normalized)) {
137
130
  if (ns) {
@@ -151,10 +144,8 @@ export function cascadeDNA(layers) {
151
144
  genes: mergedGenes,
152
145
  contexts: mergedContexts,
153
146
  roles: mergedRoles,
154
- modes: mergedModes,
155
147
  workflows: mergedWorkflows,
156
148
  epigenetic_markers: allMarkers,
157
149
  source_ids: sourceIds,
158
150
  };
159
151
  }
160
- //# sourceMappingURL=cascade.js.map
@@ -14,4 +14,3 @@ import type { CascadedDNA } from "./cascade.js";
14
14
  * Compile activated DNA into a Constraint IR.
15
15
  */
16
16
  export declare function compileDNA(activated: ActivatedDNA, cascaded?: CascadedDNA): ConstraintIR;
17
- //# sourceMappingURL=compile.d.ts.map
@@ -198,26 +198,14 @@ export function compileDNA(activated, cascaded) {
198
198
  }
199
199
  }
200
200
  }
201
- // Build mode_constraints from all cascaded modes
202
- const modeConstraints = [];
203
- if (cascaded?.modes) {
204
- for (const [name, mode] of Object.entries(cascaded.modes)) {
205
- modeConstraints.push({
206
- mode_name: name,
207
- description: mode.description,
208
- tool_deny: mode.tool_permissions?.deny,
209
- scope_write: mode.scope?.write,
210
- });
211
- }
212
- }
213
- // Build step_checkpoints from all workflow steps that have checkpoints + a mode
201
+ // Build step_checkpoints from all workflow steps that have checkpoints
214
202
  const stepCheckpoints = [];
215
203
  const allWorkflows = Object.values(cascaded?.workflows ?? {});
216
204
  for (const wf of allWorkflows) {
217
205
  for (const step of wf.steps ?? []) {
218
- if (step.checkpoints && step.checkpoints.length > 0 && step.mode) {
206
+ if (step.checkpoints && step.checkpoints.length > 0) {
219
207
  stepCheckpoints.push({
220
- step_mode: step.mode,
208
+ step_role: step.role,
221
209
  step_id: step.id,
222
210
  checkpoints: [...step.checkpoints],
223
211
  });
@@ -240,8 +228,6 @@ export function compileDNA(activated, cascaded) {
240
228
  role_tool_permissions: roleToolPermissions,
241
229
  role_scope: roleScope,
242
230
  roles_scope_map: rolesScopeMap.length > 0 ? rolesScopeMap : undefined,
243
- mode_constraints: modeConstraints.length > 0 ? modeConstraints : undefined,
244
231
  step_checkpoints: stepCheckpoints.length > 0 ? stepCheckpoints : undefined,
245
232
  };
246
233
  }
247
- //# sourceMappingURL=compile.js.map
@@ -25,4 +25,3 @@ export interface CompileOptions {
25
25
  * Optionally injects stored epigenetic markers from the evolution engine.
26
26
  */
27
27
  export declare function compileFromFiles(filePaths: string[], contextOrOptions?: string | CompileOptions): Promise<ConstraintIR>;
28
- //# sourceMappingURL=index.d.ts.map
@@ -48,4 +48,3 @@ export async function compileFromFiles(filePaths, contextOrOptions) {
48
48
  const activated = activateDNA(cascaded, opts.context ?? null, opts.role ?? null);
49
49
  return compileDNA(activated, cascaded);
50
50
  }
51
- //# sourceMappingURL=index.js.map
@@ -34,4 +34,3 @@ export interface CompileWorkflowResult {
34
34
  * Returns a result object with either a plan or errors.
35
35
  */
36
36
  export declare function compileWorkflow(workflow: WorkflowDef, options?: CompileWorkflowOptions): CompileWorkflowResult;
37
- //# sourceMappingURL=workflow.d.ts.map
@@ -166,7 +166,6 @@ function toWorkflowStep(def) {
166
166
  return {
167
167
  id: def.id,
168
168
  role: def.role,
169
- mode: def.mode ?? null,
170
169
  description: def.description ?? def.id,
171
170
  optional: def.optional ?? false,
172
171
  run_if: resolveRunIf(def.run_if),
@@ -273,4 +272,3 @@ export function compileWorkflow(workflow, options) {
273
272
  }
274
273
  return { ok: true, plan, errors: [] };
275
274
  }
276
- //# sourceMappingURL=workflow.js.map
@@ -49,4 +49,3 @@ export interface OutcomeSummary {
49
49
  oldest: string | null;
50
50
  newest: string | null;
51
51
  }
52
- //# sourceMappingURL=collector.d.ts.map
@@ -69,4 +69,3 @@ export class OutcomeCollector {
69
69
  };
70
70
  }
71
71
  }
72
- //# sourceMappingURL=collector.js.map
@@ -30,4 +30,3 @@ export declare function computeModulationFactor(geneName: string, outcomes: Exec
30
30
  * Returns 0-1 where 0 means fully decayed.
31
31
  */
32
32
  export declare function computeMarkerStrength(marker: EpigeneticMarker): number;
33
- //# sourceMappingURL=fitness.d.ts.map
@@ -93,4 +93,3 @@ export function computeMarkerStrength(marker) {
93
93
  // Decay per 30-day period
94
94
  return Math.pow(marker.decay, markerAge / 30);
95
95
  }
96
- //# sourceMappingURL=fitness.js.map
@@ -50,4 +50,3 @@ export declare class EvolutionEngine {
50
50
  */
51
51
  summary(dnaId: string): Promise<OutcomeSummary>;
52
52
  }
53
- //# sourceMappingURL=index.d.ts.map
@@ -66,4 +66,3 @@ export class EvolutionEngine {
66
66
  return this.collector.getSummary(dnaId);
67
67
  }
68
68
  }
69
- //# sourceMappingURL=index.js.map
@@ -28,4 +28,3 @@ export interface MarkerChange {
28
28
  feedback_count: number;
29
29
  needed?: number;
30
30
  }
31
- //# sourceMappingURL=marker-gen.d.ts.map
@@ -138,4 +138,3 @@ export function describeMarkerChanges(outcomes, existingMarkers, config = {}) {
138
138
  }
139
139
  return changes;
140
140
  }
141
- //# sourceMappingURL=marker-gen.js.map
@@ -21,4 +21,3 @@ export declare class EvolutionStore {
21
21
  loadMarkers(dnaId: string): Promise<EpigeneticMarker[]>;
22
22
  saveMarkers(dnaId: string, markers: EpigeneticMarker[]): Promise<void>;
23
23
  }
24
- //# sourceMappingURL=store.d.ts.map
@@ -75,4 +75,3 @@ export class EvolutionStore {
75
75
  await writeFile(this.markersPath(dnaId), JSON.stringify(markers, null, 2), "utf-8");
76
76
  }
77
77
  }
78
- //# sourceMappingURL=store.js.map