intentdna 1.7.4 → 1.8.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 (152) hide show
  1. package/.claude-plugin/marketplace.json +2 -2
  2. package/.claude-plugin/plugin.json +1 -1
  3. package/LICENSE +201 -0
  4. package/README.md +143 -194
  5. package/dist/assets/candidates.d.ts +124 -0
  6. package/dist/assets/candidates.js +1249 -0
  7. package/dist/assets/catalog.d.ts +101 -0
  8. package/dist/assets/catalog.js +311 -0
  9. package/dist/assets/evidence.d.ts +93 -0
  10. package/dist/assets/evidence.js +391 -0
  11. package/dist/assets/index.d.ts +4 -0
  12. package/dist/assets/index.js +4 -0
  13. package/dist/assets/metadata.d.ts +19 -0
  14. package/dist/assets/metadata.js +227 -0
  15. package/dist/cli/commands/assets.d.ts +65 -0
  16. package/dist/cli/commands/assets.js +2871 -0
  17. package/dist/cli/commands/auth.d.ts +322 -0
  18. package/dist/cli/commands/auth.js +1592 -0
  19. package/dist/cli/commands/cloud-auth-guidance.d.ts +2 -0
  20. package/dist/cli/commands/cloud-auth-guidance.js +4 -0
  21. package/dist/cli/commands/cloud.d.ts +1359 -0
  22. package/dist/cli/commands/cloud.js +8364 -0
  23. package/dist/cli/commands/evolve.js +18 -2
  24. package/dist/cli/commands/generate.js +25 -2
  25. package/dist/cli/commands/guard.d.ts +1 -1
  26. package/dist/cli/commands/guard.js +1 -1
  27. package/dist/cli/commands/guide.d.ts +15 -0
  28. package/dist/cli/commands/guide.js +1747 -0
  29. package/dist/cli/commands/init.d.ts +12 -0
  30. package/dist/cli/commands/init.js +95 -60
  31. package/dist/cli/commands/org.d.ts +16 -0
  32. package/dist/cli/commands/org.js +2393 -0
  33. package/dist/cli/commands/release.d.ts +59 -0
  34. package/dist/cli/commands/release.js +716 -0
  35. package/dist/cli/commands/report.d.ts +82 -0
  36. package/dist/cli/commands/report.js +1516 -0
  37. package/dist/cli/commands/run.d.ts +6 -1
  38. package/dist/cli/commands/run.js +95 -26
  39. package/dist/cli/commands/sync.d.ts +8 -1
  40. package/dist/cli/commands/sync.js +436 -141
  41. package/dist/cli/commands/templates.d.ts +64 -0
  42. package/dist/cli/commands/templates.js +2151 -1
  43. package/dist/cli/commands/workflow.d.ts +26 -0
  44. package/dist/cli/commands/workflow.js +3053 -0
  45. package/dist/cli/index.js +719 -42
  46. package/dist/compiler/cascade.js +4 -9
  47. package/dist/compiler/compile.js +1 -0
  48. package/dist/governance/evidence-capture-attribution.d.ts +12 -0
  49. package/dist/governance/evidence-capture-attribution.js +46 -0
  50. package/dist/governance/index.d.ts +2 -0
  51. package/dist/governance/index.js +1 -0
  52. package/dist/hooks/cli.d.ts +6 -0
  53. package/dist/hooks/cli.js +168 -12
  54. package/dist/hooks/enforce.d.ts +1 -0
  55. package/dist/hooks/protocol.d.ts +1 -1
  56. package/dist/hooks/protocol.js +1 -1
  57. package/dist/hooks/state.d.ts +41 -0
  58. package/dist/hooks/state.js +126 -2
  59. package/dist/index.d.ts +3 -0
  60. package/dist/index.js +3 -0
  61. package/dist/mcp/tools-state.js +2 -0
  62. package/dist/organization/index.d.ts +121 -0
  63. package/dist/organization/index.js +413 -0
  64. package/dist/runtime/claude-sync-target.d.ts +49 -0
  65. package/dist/runtime/claude-sync-target.js +280 -0
  66. package/dist/runtime/codex-adapter.d.ts +254 -0
  67. package/dist/runtime/codex-adapter.js +1204 -0
  68. package/dist/runtime/codex-sync-target.d.ts +33 -0
  69. package/dist/runtime/codex-sync-target.js +241 -0
  70. package/dist/runtime/index.d.ts +8 -0
  71. package/dist/runtime/index.js +4 -0
  72. package/dist/runtime/output-artifact-registry.d.ts +1 -1
  73. package/dist/runtime/output-artifact-registry.js +2 -0
  74. package/dist/runtime/settings-adapter.d.ts +1 -1
  75. package/dist/runtime/settings-adapter.js +1 -1
  76. package/dist/runtime/skill-adapter.d.ts +5 -1
  77. package/dist/runtime/skill-adapter.js +120 -34
  78. package/dist/runtime/sync-artifact-registry.d.ts +99 -0
  79. package/dist/runtime/sync-artifact-registry.js +194 -0
  80. package/dist/runtime/sync-target-plan.d.ts +45 -0
  81. package/dist/runtime/sync-target-plan.js +19 -0
  82. package/dist/schema/controller-registry.d.ts +8 -1
  83. package/dist/schema/controller-registry.js +8 -0
  84. package/dist/schema/types.d.ts +35 -23
  85. package/dist/schema/types.js +10 -1
  86. package/dist/schema/validate.js +22 -22
  87. package/dist/schema/validators/controllers.js +38 -20
  88. package/dist/schema/workflow-authoring-contract.d.ts +29 -0
  89. package/dist/schema/workflow-authoring-contract.js +109 -0
  90. package/dist/schema/yaml-parser.js +18 -0
  91. package/dist/templates/api-backend.dna.yaml +19 -0
  92. package/dist/templates/brainstorming-first.dna.yaml +19 -0
  93. package/dist/templates/code-cleanup.dna.yaml +19 -0
  94. package/dist/templates/code-review-pipeline.dna.yaml +18 -0
  95. package/dist/templates/documentation-writer.dna.yaml +19 -0
  96. package/dist/templates/flutter-behavior-lock.dna.yaml +19 -0
  97. package/dist/templates/flutter-refactoring-rescue.dna.yaml +19 -0
  98. package/dist/templates/flutter-rewrite-diagnosis-review.dna.yaml +210 -0
  99. package/dist/templates/flutter-rewrite-fix-review-loop.dna.yaml +260 -0
  100. package/dist/templates/flutter-rewrite-new.dna.yaml +506 -0
  101. package/dist/templates/flutter-rewrite.dna.yaml +20 -0
  102. package/dist/templates/frontend-quality.dna.yaml +19 -0
  103. package/dist/templates/full-pipeline.dna.yaml +20 -0
  104. package/dist/templates/marketplace.d.ts +92 -0
  105. package/dist/templates/marketplace.js +502 -0
  106. package/dist/templates/metadata.d.ts +25 -0
  107. package/dist/templates/metadata.js +136 -3
  108. package/dist/templates/mobile-dev.dna.yaml +19 -0
  109. package/dist/templates/multi-agent-handoff-coordination.dna.yaml +156 -0
  110. package/dist/templates/multi-perspective-review.dna.yaml +19 -0
  111. package/dist/templates/persistent-executor.dna.yaml +19 -0
  112. package/dist/templates/qa-loop.dna.yaml +18 -0
  113. package/dist/templates/release-evidence-gate.dna.yaml +131 -0
  114. package/dist/templates/requirements-gate.dna.yaml +19 -0
  115. package/dist/templates/research-orchestration.dna.yaml +19 -0
  116. package/dist/templates/root-cause-analysis.dna.yaml +19 -0
  117. package/dist/templates/safe-refactoring.dna.yaml +321 -0
  118. package/dist/templates/secure-dev.dna.yaml +19 -0
  119. package/dist/templates/subagent-parallel.dna.yaml +19 -0
  120. package/dist/templates/systematic-debugging.dna.yaml +19 -0
  121. package/dist/templates/tdd-strict.dna.yaml +19 -0
  122. package/dist/templates/ui-visual-regression-qa.dna.yaml +133 -0
  123. package/dist/templates/workflow-author.dna.yaml +302 -0
  124. package/dist/templates/workflow-blocked-scope-triage.dna.yaml +242 -0
  125. package/dist/templates/workflow-completion-audit.dna.yaml +254 -0
  126. package/dist/templates/workflow-cross-boundary-resource-approval.dna.yaml +249 -0
  127. package/dist/templates/workflow-evidence-review.dna.yaml +198 -0
  128. package/dist/templates/workflow-module-inventory.dna.yaml +257 -0
  129. package/dist/templates/workflow-runtime-smoke-review.dna.yaml +252 -0
  130. package/dist/templates/workflow-verification-command-routing.dna.yaml +278 -0
  131. package/dist/workflow/authoring-packet.d.ts +67 -0
  132. package/dist/workflow/authoring-packet.js +218 -0
  133. package/dist/workflow/draft.d.ts +159 -0
  134. package/dist/workflow/draft.js +800 -0
  135. package/dist/workflow/index.d.ts +3 -0
  136. package/dist/workflow/index.js +3 -0
  137. package/dist/workflow/suggestion-review.d.ts +65 -0
  138. package/dist/workflow/suggestion-review.js +245 -0
  139. package/package.json +1 -1
  140. package/spec/README.md +15 -48
  141. package/spec/codex-adapter-contract.md +176 -0
  142. package/spec/sync-target-plan.md +158 -0
  143. package/spec/workflow-capability-ir.md +153 -0
  144. package/spec/agent-dispatch-fix.md +0 -116
  145. package/spec/control-plane-convergence-handoff-2026-04-24.md +0 -432
  146. package/spec/flutter-rewrite-template-optimization.md +0 -301
  147. package/spec/foundation-hardening.md +0 -178
  148. package/spec/hooks-infra-harness-hardening.md +0 -741
  149. package/spec/multi-config.md +0 -172
  150. package/spec/parallel-isolation.md +0 -268
  151. package/spec/template-version-namespace-fix.md +0 -653
  152. package/spec/workflow-pipeline.md +0 -101
@@ -0,0 +1,280 @@
1
+ import { mkdir, readFile, unlink, writeFile } from "node:fs/promises";
2
+ import { dirname, resolve } from "node:path";
3
+ import { createCompiledIR, writeCompiledIR } from "./plugin-adapter.js";
4
+ import { compilePluginSettings, detectEnabledEvents, mergeSettingsFile, recommendHookTimeouts } from "./settings-adapter.js";
5
+ import { formatSyncTargetPlanDiagnostics } from "./sync-target-plan.js";
6
+ const LEGACY_BASH_HOOKS = [
7
+ "dna-pre-tool-use.sh",
8
+ "dna-post-tool-use.sh",
9
+ "dna-user-prompt-submit.sh",
10
+ "dna-subagent-stop.sh",
11
+ "dna-pre-compact.sh",
12
+ "dna-notification.sh",
13
+ ];
14
+ /**
15
+ * Remove legacy bash hook scripts written by previous Intent DNA versions.
16
+ * Only removes files that contain the sentinel comment.
17
+ */
18
+ export async function removeLegacyBashHooks(hooksDir) {
19
+ const removed = [];
20
+ for (const file of LEGACY_BASH_HOOKS) {
21
+ const path = resolve(hooksDir, file);
22
+ try {
23
+ const content = await readFile(path, "utf-8");
24
+ if (content.includes("intentdna:managed")) {
25
+ await unlink(path);
26
+ removed.push(path);
27
+ }
28
+ }
29
+ catch { /* File doesn't exist, skip */ }
30
+ }
31
+ return removed;
32
+ }
33
+ function createSettingsHookRegistration(ir, mode, settingsPath) {
34
+ if (mode !== "bin" || !settingsPath)
35
+ return undefined;
36
+ const enabledEvents = detectEnabledEvents(ir);
37
+ if (enabledEvents.length === 0)
38
+ return undefined;
39
+ return {
40
+ path: settingsPath,
41
+ enabledEvents,
42
+ settings: compilePluginSettings(enabledEvents, 10, recommendHookTimeouts(ir)),
43
+ };
44
+ }
45
+ export function createClaudeCoreSyncTargetPlan(options) {
46
+ const compiledIR = createCompiledIR(options.ir, options.roles);
47
+ const compiledIRPath = resolve(options.projectDir, ".dna", "compiled", "ir.json");
48
+ const legacyHooksDir = resolve(options.projectDir, ".claude", "hooks");
49
+ const mcpConfigPath = resolve(options.projectDir, ".claude", ".mcp.json");
50
+ const settingsHookRegistration = createSettingsHookRegistration(options.ir, options.mode, options.settingsPath);
51
+ const plannedArtifacts = [
52
+ {
53
+ artifact: "compiled-ir",
54
+ outputArtifact: "compiled-ir",
55
+ kind: "claude_compiled_ir",
56
+ path: compiledIRPath,
57
+ ownership: "diagnostic",
58
+ trackedByLock: true,
59
+ },
60
+ {
61
+ artifact: "mcp-config",
62
+ outputArtifact: "mcp-config",
63
+ kind: "claude_builtin_mcp_config",
64
+ path: mcpConfigPath,
65
+ ownership: "merge_preserve_user",
66
+ trackedByLock: false,
67
+ },
68
+ ];
69
+ if (settingsHookRegistration) {
70
+ plannedArtifacts.push({
71
+ artifact: "settings-hooks",
72
+ outputArtifact: "settings-hooks",
73
+ kind: "claude_settings_hooks",
74
+ path: settingsHookRegistration.path,
75
+ ownership: "merge_preserve_user",
76
+ trackedByLock: true,
77
+ });
78
+ }
79
+ return {
80
+ target: "claude_code",
81
+ compiledIR,
82
+ compiledIRPath,
83
+ legacyHooksDir,
84
+ mcpConfigPath,
85
+ settingsHookRegistration,
86
+ pluginSkipsSettings: options.mode === "plugin" && !!options.settingsPath,
87
+ plannedArtifacts,
88
+ capabilityReport: createClaudeCapabilityReport(plannedArtifacts, options.mode, settingsHookRegistration),
89
+ evidencePlan: createClaudeEvidencePlan(plannedArtifacts),
90
+ warnings: [],
91
+ unsupported: [
92
+ "native_rollback_or_compensation",
93
+ "native_logic_equivalence_validation",
94
+ "sync_time_artifacts_are_not_runtime_enforcement",
95
+ ],
96
+ };
97
+ }
98
+ function createClaudeCapabilityReport(plannedArtifacts, mode, settingsHookRegistration) {
99
+ const artifactPaths = plannedArtifacts.map((artifact) => artifact.path);
100
+ const settingsPath = settingsHookRegistration?.path;
101
+ const settingsHookSurface = settingsPath
102
+ ? [`Claude Code settings hooks: ${settingsPath}`]
103
+ : mode === "plugin"
104
+ ? ["Claude Code plugin-managed hooks"]
105
+ : [];
106
+ const hookEvidenceRefs = settingsHookRegistration?.enabledEvents.length
107
+ ? ["claude-settings-hooks"]
108
+ : mode === "plugin"
109
+ ? ["claude-plugin-hooks"]
110
+ : [];
111
+ const capabilities = {
112
+ intent_lock: {
113
+ status: "partial",
114
+ surfaces: [".dna/compiled/ir.json"],
115
+ evidenceRefs: ["compiled-ir"],
116
+ notes: ["Compiled IR preserves prompt directives for Claude Code surfaces, but runtime adherence still requires execution evidence."],
117
+ },
118
+ boundary_constraint: {
119
+ status: settingsHookSurface.length > 0 ? "partial" : "unknown",
120
+ surfaces: [...settingsHookSurface, ".dna/compiled/ir.json"],
121
+ evidenceRefs: [...hookEvidenceRefs, "compiled-ir"],
122
+ notes: ["Claude core sync can register legacy hook surfaces and compiled IR; exact enforcement depends on the active Claude Code harness mode."],
123
+ },
124
+ context_control: {
125
+ status: "partial",
126
+ surfaces: [".dna/compiled/ir.json"],
127
+ evidenceRefs: ["compiled-ir"],
128
+ notes: ["Context requirements are compiled as policy data; dynamic context selection is outside this sync target."],
129
+ },
130
+ tool_policy: {
131
+ status: settingsHookSurface.length > 0 ? "partial" : "unknown",
132
+ surfaces: [...settingsHookSurface, ".dna/compiled/ir.json"],
133
+ evidenceRefs: [...hookEvidenceRefs, "compiled-ir"],
134
+ notes: ["Tool policy can be represented through compiled IR and hook settings, but this planner does not claim full tool-path parity."],
135
+ },
136
+ approval_gate: {
137
+ status: settingsHookSurface.length > 0 ? "partial" : "unknown",
138
+ surfaces: settingsHookSurface,
139
+ evidenceRefs: hookEvidenceRefs,
140
+ notes: ["Approval-like gates depend on configured Claude hook events and remain runtime-specific."],
141
+ },
142
+ checkpoint: {
143
+ status: "partial",
144
+ surfaces: artifactPaths,
145
+ evidenceRefs: ["compiled-ir", ...hookEvidenceRefs],
146
+ notes: ["Checkpoints are represented in compiled IR and hook registration, not as completed runtime proof."],
147
+ },
148
+ completion_check: {
149
+ status: "partial",
150
+ surfaces: artifactPaths,
151
+ evidenceRefs: ["compiled-ir", ...hookEvidenceRefs],
152
+ notes: ["Completion checks require runtime verifier output before they become evidence."],
153
+ },
154
+ artifact_handoff: {
155
+ status: "partial",
156
+ surfaces: artifactPaths,
157
+ evidenceRefs: ["compiled-ir", "mcp-config"],
158
+ notes: ["Generated artifacts and MCP registration provide handoff surfaces while preserving user-owned config by merge."],
159
+ },
160
+ isolation: {
161
+ status: "unknown",
162
+ surfaces: [],
163
+ evidenceRefs: [],
164
+ notes: ["Workflow isolation can be declared in DNA, but Claude core sync planning does not prove runtime isolation."],
165
+ },
166
+ dry_run: {
167
+ status: "supported",
168
+ surfaces: ["dna sync --dry-run Claude core target plan"],
169
+ evidenceRefs: ["claude-sync-target-plan"],
170
+ notes: ["Dry-run reports planned Claude core artifacts, capability posture, and unsupported gaps without writing files."],
171
+ },
172
+ rollback_or_compensation: {
173
+ status: "unsupported",
174
+ surfaces: [],
175
+ evidenceRefs: ["native_rollback_or_compensation"],
176
+ notes: ["Claude core sync has no native rollback or compensation contract for completed side effects."],
177
+ },
178
+ trace: {
179
+ status: "partial",
180
+ surfaces: artifactPaths,
181
+ evidenceRefs: ["RuntimeDecisionEvent", "compiled-ir"],
182
+ notes: ["RuntimeDecisionEvent remains the primary trace contract; sync artifacts are diagnostic context only."],
183
+ },
184
+ runtime_decision_evidence: {
185
+ status: "partial",
186
+ surfaces: artifactPaths,
187
+ evidenceRefs: ["RuntimeDecisionEvent", "compiled-ir"],
188
+ notes: ["Sync-time artifacts must not be upgraded to runtime evidence without RuntimeDecisionEvent provenance."],
189
+ },
190
+ logic_equivalence_validation: {
191
+ status: "unknown",
192
+ surfaces: ["Workflow verifier specs and external test commands"],
193
+ evidenceRefs: ["verifier_specs", "RuntimeDecisionEvent"],
194
+ notes: ["Equivalence validation is workflow-level proof, not a native Claude core sync capability."],
195
+ },
196
+ };
197
+ return {
198
+ adapter: "claude_code",
199
+ runtime: "claude_code",
200
+ capabilities,
201
+ unsupported: [
202
+ "native_rollback_or_compensation",
203
+ "native_logic_equivalence_validation",
204
+ "sync_time_artifacts_are_not_runtime_enforcement",
205
+ ],
206
+ };
207
+ }
208
+ function createClaudeEvidencePlan(plannedArtifacts) {
209
+ return {
210
+ primary: "RuntimeDecisionEvent",
211
+ diagnosticArtifacts: plannedArtifacts.map((artifact) => artifact.path),
212
+ classification: "diagnostic_only",
213
+ notes: [
214
+ "Compiled IR and Claude Code settings are sync-time artifacts; RuntimeDecisionEvent remains the runtime evidence contract.",
215
+ "Claude Code core target planning preserves user-owned MCP and settings content by merging generated entries.",
216
+ ],
217
+ };
218
+ }
219
+ async function registerDNAMCPServer(projectDir) {
220
+ const mcpJsonPath = resolve(projectDir, ".claude", ".mcp.json");
221
+ let existing = {};
222
+ try {
223
+ const raw = await readFile(mcpJsonPath, "utf-8");
224
+ existing = JSON.parse(raw);
225
+ }
226
+ catch { /* doesn't exist yet */ }
227
+ const mcpServers = (existing.mcpServers ?? {});
228
+ if (mcpServers["intentdna"])
229
+ return { path: mcpJsonPath, registered: false };
230
+ mcpServers["intentdna"] = {
231
+ command: "dna-mcp",
232
+ args: ["--project-dir", projectDir],
233
+ };
234
+ existing.mcpServers = mcpServers;
235
+ await mkdir(dirname(mcpJsonPath), { recursive: true });
236
+ await writeFile(mcpJsonPath, JSON.stringify(existing, null, 2) + "\n", "utf-8");
237
+ return { path: mcpJsonPath, registered: true };
238
+ }
239
+ export async function executeClaudeCoreSyncTargetPlan(plan, projectDir) {
240
+ const messages = [];
241
+ const writtenIrPath = await writeCompiledIR(projectDir, plan.compiledIR);
242
+ messages.push(`Wrote compiled IR: ${writtenIrPath}`);
243
+ const removedLegacyHooks = await removeLegacyBashHooks(plan.legacyHooksDir);
244
+ if (removedLegacyHooks.length > 0) {
245
+ messages.push(`Cleaned ${removedLegacyHooks.length} legacy bash hook(s) from ${plan.legacyHooksDir}`);
246
+ }
247
+ const mcp = await registerDNAMCPServer(projectDir);
248
+ if (mcp.registered) {
249
+ messages.push(`MCP: registered dna-mcp server in ${mcp.path}`);
250
+ }
251
+ if (plan.settingsHookRegistration) {
252
+ await mergeSettingsFile(plan.settingsHookRegistration.settings, plan.settingsHookRegistration.path);
253
+ messages.push(`Bin mode: registered ${plan.settingsHookRegistration.enabledEvents.length} hook event(s) in ${plan.settingsHookRegistration.path}`);
254
+ }
255
+ else if (plan.pluginSkipsSettings) {
256
+ messages.push("Plugin mode: hooks managed by plugin framework (skipping settings.json)");
257
+ }
258
+ return { messages, removedLegacyHooks };
259
+ }
260
+ export function formatClaudeCoreSyncTargetPlanDryRun(plan) {
261
+ const lines = [
262
+ `Dry-run: would write compiled IR: ${plan.compiledIRPath}`,
263
+ `Dry-run: would clean legacy bash hooks in ${plan.legacyHooksDir}`,
264
+ `Dry-run: would register dna-mcp server in ${plan.mcpConfigPath}`,
265
+ ];
266
+ if (plan.settingsHookRegistration) {
267
+ lines.push(`Dry-run: would register ${plan.settingsHookRegistration.enabledEvents.length} hook event(s) in ${plan.settingsHookRegistration.path}`);
268
+ }
269
+ else if (plan.pluginSkipsSettings) {
270
+ lines.push("Plugin mode: hooks managed by plugin framework (skipping settings.json)");
271
+ }
272
+ const capabilityEntries = Object.entries(plan.capabilityReport.capabilities)
273
+ .sort(([left], [right]) => left.localeCompare(right));
274
+ lines.push("Claude core capability report:");
275
+ for (const [capability, entry] of capabilityEntries) {
276
+ const surfaces = entry.surfaces.length > 0 ? entry.surfaces.join(", ") : "no Claude core sync surface";
277
+ lines.push(` - ${capability}: ${entry.status} via ${surfaces}`);
278
+ }
279
+ return `${lines.join("\n")}\n${formatSyncTargetPlanDiagnostics(plan)}`;
280
+ }
@@ -0,0 +1,254 @@
1
+ import { type RuntimeDecision, type RuntimeDecisionEvent, type RuntimeEvidenceRef } from "../governance/index.js";
2
+ import type { ConstraintIR } from "../schema/types.js";
3
+ import type { HookOutput } from "../hooks/protocol.js";
4
+ import { type EvidenceCaptureResult, type EvidenceCaptureRetry } from "../hooks/state.js";
5
+ export declare const CODEX_ADAPTER_MINIMUM_VERSION = "0.134.0";
6
+ export declare const CODEX_NATIVE_HOOK_EVENTS: readonly ["SessionStart", "PreToolUse", "PostToolUse", "UserPromptSubmit", "PreCompact", "PostCompact", "Stop"];
7
+ export type CodexNativeHookEvent = typeof CODEX_NATIVE_HOOK_EVENTS[number];
8
+ export type CodexHookInstallMode = "plugin_scoped" | "project_fallback" | "managed" | "none";
9
+ export type CodexAdapterSupportStatus = "supported" | "partial" | "unknown" | "unsupported";
10
+ export type CodexEvidenceClassification = "enterprise_evidence" | "diagnostic_only" | "unsupported";
11
+ export interface CodexCommandHook {
12
+ type: "command";
13
+ command: string;
14
+ timeout?: number;
15
+ statusMessage?: string;
16
+ }
17
+ export interface CodexHookGroup {
18
+ matcher?: string;
19
+ hooks: CodexCommandHook[];
20
+ }
21
+ export interface CodexHooksConfig {
22
+ hooks: Partial<Record<CodexNativeHookEvent, CodexHookGroup[]>>;
23
+ state?: Record<string, CodexHookTrustState>;
24
+ }
25
+ export interface CodexHookTrustState {
26
+ trusted_hash: string;
27
+ }
28
+ export interface CodexRuntimeProbe {
29
+ executable_path: string | null;
30
+ version: string | null;
31
+ minimum_version: string;
32
+ satisfies_minimum_version: boolean;
33
+ exec_json_available: boolean;
34
+ execpolicy_check_available: boolean;
35
+ output_schema_available: boolean;
36
+ classification: CodexEvidenceClassification;
37
+ reason: string;
38
+ }
39
+ export interface CodexInstallModeSemantics {
40
+ mode: CodexHookInstallMode;
41
+ writes_plugin_artifacts: boolean;
42
+ writes_project_fallback: boolean;
43
+ writes_trust_state: boolean;
44
+ support_status: CodexAdapterSupportStatus;
45
+ classification: CodexEvidenceClassification;
46
+ reason: string;
47
+ }
48
+ export interface CodexTrustVerificationInput {
49
+ hookInstallMode: CodexHookInstallMode;
50
+ probe: CodexRuntimeProbe;
51
+ expectedTrustState: Record<string, CodexHookTrustState>;
52
+ actualTrustState?: Record<string, CodexHookTrustState>;
53
+ runtimeExecutionVerified?: boolean;
54
+ provenanceComplete?: boolean;
55
+ }
56
+ export interface CodexTrustVerification {
57
+ trusted: boolean;
58
+ support_status: CodexAdapterSupportStatus;
59
+ classification: CodexEvidenceClassification;
60
+ evidence_refs: RuntimeEvidenceRef[];
61
+ reasons: string[];
62
+ }
63
+ export interface CodexPluginManifest {
64
+ name: string;
65
+ version: string;
66
+ description: string;
67
+ hooks: string;
68
+ }
69
+ export interface CodexInstructionArtifact {
70
+ path: string;
71
+ content: string;
72
+ }
73
+ export interface CodexPolicyMapArtifact {
74
+ path: string;
75
+ content: CodexPolicyMap;
76
+ }
77
+ export interface CodexPolicyMapEntry {
78
+ source: string;
79
+ codex_surface: string;
80
+ support_status: CodexAdapterSupportStatus;
81
+ evidence_ref: string;
82
+ notes: string[];
83
+ }
84
+ export interface CodexPolicyMap {
85
+ schema_version: "intentdna.codex_policy_map.v1";
86
+ generated_at: string;
87
+ adapter: "codex_cli";
88
+ entries: CodexPolicyMapEntry[];
89
+ unsupported: string[];
90
+ }
91
+ export interface CodexAdapterArtifacts {
92
+ pluginManifest: CodexPluginManifest;
93
+ pluginHooks: CodexHooksConfig;
94
+ fallbackHooks: CodexHooksConfig;
95
+ instruction: CodexInstructionArtifact;
96
+ policyMap: CodexPolicyMapArtifact;
97
+ trustState: Record<string, CodexHookTrustState>;
98
+ evidence: CodexAdapterEvidence;
99
+ }
100
+ export interface CodexAdapterEvidence {
101
+ schema_version: "intentdna.codex_adapter_evidence.v1";
102
+ generated_at: string;
103
+ adapter: "codex_cli";
104
+ minimum_codex_version: string;
105
+ hook_install_mode: CodexHookInstallMode;
106
+ install_mode_semantics: CodexInstallModeSemantics;
107
+ runtime_probe?: CodexRuntimeProbe;
108
+ trust_verification?: CodexTrustVerification;
109
+ dispatcher_command: string;
110
+ dispatcher_script: string;
111
+ plugin_hooks_path: string;
112
+ instruction_path: string;
113
+ policy_map_path: string;
114
+ fallback_hooks_path: string;
115
+ fallback_config_path: string;
116
+ generated_events: CodexNativeHookEvent[];
117
+ trust_state: Record<string, CodexHookTrustState>;
118
+ support_status: Record<string, CodexAdapterSupportStatus>;
119
+ unsupported: string[];
120
+ notes: string[];
121
+ }
122
+ export interface CompileCodexAdapterOptions {
123
+ adapterRoot: string;
124
+ dispatcherScript: string;
125
+ dispatcherCommand?: string;
126
+ nodePath?: string;
127
+ pluginName?: string;
128
+ pluginVersion?: string;
129
+ pluginDescription?: string;
130
+ pluginHooksPath?: string;
131
+ instructionPath?: string;
132
+ policyMapPath?: string;
133
+ fallbackHooksPath?: string;
134
+ fallbackConfigPath?: string;
135
+ hookInstallMode?: CodexHookInstallMode;
136
+ generatedAt?: string;
137
+ }
138
+ export interface CodexDecisionMappingInput {
139
+ ir: ConstraintIR;
140
+ decision: RuntimeDecision;
141
+ decisionReason: string;
142
+ hookEvent?: CodexNativeHookEvent | string;
143
+ hookInstallMode?: CodexHookInstallMode;
144
+ hookTrusted?: boolean;
145
+ codexVersion?: string;
146
+ sessionId?: string;
147
+ runId?: string;
148
+ stepId?: string;
149
+ toolName?: string;
150
+ actionKind?: string;
151
+ resourceRef?: string;
152
+ agentId?: string;
153
+ agentRole?: string;
154
+ agentType?: string;
155
+ sessionAgent?: string;
156
+ orgId?: string;
157
+ teamId?: string;
158
+ userId?: string;
159
+ projectId?: string;
160
+ evidenceRefs?: RuntimeEvidenceRef[];
161
+ eventId?: string;
162
+ timestamp?: string;
163
+ }
164
+ export interface CodexHookInput {
165
+ event: CodexNativeHookEvent | "PermissionRequest" | string;
166
+ session_id?: string;
167
+ run_id?: string;
168
+ agent_id?: string;
169
+ agent_role?: string;
170
+ agent_type?: string;
171
+ subagent_id?: string;
172
+ tool_name?: string;
173
+ command?: string;
174
+ cwd?: string;
175
+ resource_ref?: string;
176
+ result?: EvidenceCaptureResult;
177
+ exit_code?: number;
178
+ duration_ms?: number;
179
+ retry?: EvidenceCaptureRetry;
180
+ payload: Record<string, unknown>;
181
+ }
182
+ export interface CodexHookRunnerOptions {
183
+ ir: ConstraintIR;
184
+ hookInstallMode: CodexHookInstallMode;
185
+ hookTrusted: boolean;
186
+ codexVersion?: string;
187
+ projectDir: string;
188
+ sessionId?: string;
189
+ runId?: string;
190
+ stepId?: string;
191
+ orgId?: string;
192
+ teamId?: string;
193
+ userId?: string;
194
+ projectId?: string;
195
+ workflowAsset?: string;
196
+ workflowId?: string;
197
+ timestamp?: string;
198
+ appendEvent?: boolean;
199
+ }
200
+ export interface CodexHookRunnerResult {
201
+ output: HookOutput;
202
+ decision: RuntimeDecision;
203
+ classification: CodexEvidenceClassification;
204
+ event?: RuntimeDecisionEvent;
205
+ reasons: string[];
206
+ }
207
+ export interface CodexExecJsonEvent {
208
+ raw: Record<string, unknown>;
209
+ }
210
+ export interface CodexDogfoodResult {
211
+ probe: CodexRuntimeProbe;
212
+ status: "completed" | "skipped" | "failed" | "timeout";
213
+ classification: CodexEvidenceClassification;
214
+ command: string[];
215
+ events: CodexExecJsonEvent[];
216
+ stdout: string;
217
+ stderr: string;
218
+ reason: string;
219
+ }
220
+ export interface RunCodexDogfoodOptions {
221
+ projectDir: string;
222
+ prompt?: string;
223
+ executablePath?: string;
224
+ timeoutMs?: number;
225
+ extraArgs?: string[];
226
+ env?: NodeJS.ProcessEnv;
227
+ }
228
+ export declare function probeCodexRuntime(options?: {
229
+ executablePath?: string;
230
+ envPath?: string;
231
+ }): Promise<CodexRuntimeProbe>;
232
+ export declare function runCodexExecDogfood(options: RunCodexDogfoodOptions): Promise<CodexDogfoodResult>;
233
+ export declare function withCodexDogfoodEvidence(evidence: CodexAdapterEvidence, dogfood: CodexDogfoodResult): CodexAdapterEvidence;
234
+ export declare function codexInstallModeSemantics(mode: CodexHookInstallMode): CodexInstallModeSemantics;
235
+ export declare function buildCodexDispatcherCommand(options: CompileCodexAdapterOptions): string;
236
+ export declare function codexHookTrustedHash(identity: unknown): string;
237
+ export declare function compileCodexPluginManifest(options: CompileCodexAdapterOptions): CodexPluginManifest;
238
+ export declare function compileCodexHooksConfig(options: CompileCodexAdapterOptions): CodexHooksConfig;
239
+ export declare function compileCodexInstructionArtifact(ir: ConstraintIR, options: CompileCodexAdapterOptions): CodexInstructionArtifact;
240
+ export declare function compileCodexPolicyMapArtifact(ir: ConstraintIR, options: CompileCodexAdapterOptions): CodexPolicyMapArtifact;
241
+ export declare function buildCodexHookTrustState(hooksPath: string, hooksConfig: CodexHooksConfig): Record<string, CodexHookTrustState>;
242
+ export declare function verifyCodexHookTrust(input: CodexTrustVerificationInput): CodexTrustVerification;
243
+ export declare function compileCodexAdapterArtifacts(ir: ConstraintIR, options: CompileCodexAdapterOptions): CodexAdapterArtifacts;
244
+ export declare function mergeCodexFallbackHooks(existingContent: string | null | undefined, generated: CodexHooksConfig, dispatcherCommand: string): CodexHooksConfig;
245
+ export declare function removeCodexFallbackHooks(existingContent: string | null | undefined, dispatcherCommand: string): CodexHooksConfig | null;
246
+ export declare function codexTrustStateToml(trustState: Record<string, CodexHookTrustState>): string;
247
+ export declare function mergeCodexTrustStateConfig(existingContent: string | null | undefined, trustState: Record<string, CodexHookTrustState>): string;
248
+ export declare function removeCodexTrustStateConfig(existingContent: string | null | undefined): string;
249
+ export declare function writeCodexAdapterArtifacts(projectDir: string, artifacts: CodexAdapterArtifacts): Promise<string[]>;
250
+ export declare function removeCodexAdapterArtifacts(projectDir: string, dispatcherCommand: string, artifacts?: CodexAdapterArtifacts): Promise<string[]>;
251
+ export declare function appendCodexRuntimeDecisionEvent(projectDir: string, event: RuntimeDecisionEvent, sessionId?: string): Promise<void>;
252
+ export declare function normalizeCodexHookInput(rawInput: unknown, fallbackEvent?: string): CodexHookInput;
253
+ export declare function runCodexHook(rawInput: unknown, options: CodexHookRunnerOptions): Promise<CodexHookRunnerResult>;
254
+ export declare function mapCodexDecisionEvent(input: CodexDecisionMappingInput): RuntimeDecisionEvent;