intentdna 1.7.5 → 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.
- package/.claude-plugin/marketplace.json +2 -2
- package/.claude-plugin/plugin.json +1 -1
- package/LICENSE +201 -0
- package/README.md +143 -194
- package/dist/assets/candidates.d.ts +124 -0
- package/dist/assets/candidates.js +1249 -0
- package/dist/assets/catalog.d.ts +101 -0
- package/dist/assets/catalog.js +311 -0
- package/dist/assets/evidence.d.ts +93 -0
- package/dist/assets/evidence.js +391 -0
- package/dist/assets/index.d.ts +4 -0
- package/dist/assets/index.js +4 -0
- package/dist/assets/metadata.d.ts +19 -0
- package/dist/assets/metadata.js +227 -0
- package/dist/cli/commands/assets.d.ts +65 -0
- package/dist/cli/commands/assets.js +2871 -0
- package/dist/cli/commands/auth.d.ts +322 -0
- package/dist/cli/commands/auth.js +1592 -0
- package/dist/cli/commands/cloud-auth-guidance.d.ts +2 -0
- package/dist/cli/commands/cloud-auth-guidance.js +4 -0
- package/dist/cli/commands/cloud.d.ts +1359 -0
- package/dist/cli/commands/cloud.js +8364 -0
- package/dist/cli/commands/evolve.js +18 -2
- package/dist/cli/commands/generate.js +25 -2
- package/dist/cli/commands/guard.d.ts +1 -1
- package/dist/cli/commands/guard.js +1 -1
- package/dist/cli/commands/guide.d.ts +15 -0
- package/dist/cli/commands/guide.js +1747 -0
- package/dist/cli/commands/init.d.ts +12 -0
- package/dist/cli/commands/init.js +95 -60
- package/dist/cli/commands/org.d.ts +16 -0
- package/dist/cli/commands/org.js +2393 -0
- package/dist/cli/commands/release.d.ts +59 -0
- package/dist/cli/commands/release.js +716 -0
- package/dist/cli/commands/report.d.ts +82 -0
- package/dist/cli/commands/report.js +1516 -0
- package/dist/cli/commands/run.d.ts +6 -1
- package/dist/cli/commands/run.js +95 -26
- package/dist/cli/commands/sync.d.ts +8 -1
- package/dist/cli/commands/sync.js +436 -141
- package/dist/cli/commands/templates.d.ts +64 -0
- package/dist/cli/commands/templates.js +2151 -1
- package/dist/cli/commands/workflow.d.ts +26 -0
- package/dist/cli/commands/workflow.js +3053 -0
- package/dist/cli/index.js +703 -36
- package/dist/compiler/cascade.js +4 -9
- package/dist/compiler/compile.js +1 -0
- package/dist/governance/evidence-capture-attribution.d.ts +12 -0
- package/dist/governance/evidence-capture-attribution.js +46 -0
- package/dist/governance/index.d.ts +2 -0
- package/dist/governance/index.js +1 -0
- package/dist/hooks/cli.d.ts +5 -0
- package/dist/hooks/cli.js +149 -5
- package/dist/hooks/enforce.d.ts +1 -0
- package/dist/hooks/protocol.d.ts +1 -1
- package/dist/hooks/protocol.js +1 -1
- package/dist/hooks/state.d.ts +41 -0
- package/dist/hooks/state.js +126 -2
- package/dist/index.d.ts +3 -0
- package/dist/index.js +3 -0
- package/dist/mcp/tools-state.js +2 -0
- package/dist/organization/index.d.ts +121 -0
- package/dist/organization/index.js +413 -0
- package/dist/runtime/claude-sync-target.d.ts +49 -0
- package/dist/runtime/claude-sync-target.js +280 -0
- package/dist/runtime/codex-adapter.d.ts +254 -0
- package/dist/runtime/codex-adapter.js +1204 -0
- package/dist/runtime/codex-sync-target.d.ts +33 -0
- package/dist/runtime/codex-sync-target.js +241 -0
- package/dist/runtime/index.d.ts +8 -0
- package/dist/runtime/index.js +4 -0
- package/dist/runtime/output-artifact-registry.d.ts +1 -1
- package/dist/runtime/output-artifact-registry.js +2 -0
- package/dist/runtime/settings-adapter.d.ts +1 -1
- package/dist/runtime/settings-adapter.js +1 -1
- package/dist/runtime/skill-adapter.d.ts +5 -1
- package/dist/runtime/skill-adapter.js +120 -34
- package/dist/runtime/sync-artifact-registry.d.ts +99 -0
- package/dist/runtime/sync-artifact-registry.js +194 -0
- package/dist/runtime/sync-target-plan.d.ts +45 -0
- package/dist/runtime/sync-target-plan.js +19 -0
- package/dist/schema/controller-registry.d.ts +8 -1
- package/dist/schema/controller-registry.js +8 -0
- package/dist/schema/types.d.ts +35 -23
- package/dist/schema/types.js +10 -1
- package/dist/schema/validate.js +22 -22
- package/dist/schema/validators/controllers.js +38 -20
- package/dist/schema/workflow-authoring-contract.d.ts +29 -0
- package/dist/schema/workflow-authoring-contract.js +109 -0
- package/dist/schema/yaml-parser.js +18 -0
- package/dist/templates/api-backend.dna.yaml +19 -0
- package/dist/templates/brainstorming-first.dna.yaml +19 -0
- package/dist/templates/code-cleanup.dna.yaml +19 -0
- package/dist/templates/code-review-pipeline.dna.yaml +18 -0
- package/dist/templates/documentation-writer.dna.yaml +19 -0
- package/dist/templates/flutter-behavior-lock.dna.yaml +19 -0
- package/dist/templates/flutter-refactoring-rescue.dna.yaml +19 -0
- package/dist/templates/flutter-rewrite-diagnosis-review.dna.yaml +210 -0
- package/dist/templates/flutter-rewrite-fix-review-loop.dna.yaml +260 -0
- package/dist/templates/flutter-rewrite-new.dna.yaml +506 -0
- package/dist/templates/flutter-rewrite.dna.yaml +20 -0
- package/dist/templates/frontend-quality.dna.yaml +19 -0
- package/dist/templates/full-pipeline.dna.yaml +20 -0
- package/dist/templates/marketplace.d.ts +92 -0
- package/dist/templates/marketplace.js +502 -0
- package/dist/templates/metadata.d.ts +25 -0
- package/dist/templates/metadata.js +136 -3
- package/dist/templates/mobile-dev.dna.yaml +19 -0
- package/dist/templates/multi-agent-handoff-coordination.dna.yaml +156 -0
- package/dist/templates/multi-perspective-review.dna.yaml +19 -0
- package/dist/templates/persistent-executor.dna.yaml +19 -0
- package/dist/templates/qa-loop.dna.yaml +18 -0
- package/dist/templates/release-evidence-gate.dna.yaml +131 -0
- package/dist/templates/requirements-gate.dna.yaml +19 -0
- package/dist/templates/research-orchestration.dna.yaml +19 -0
- package/dist/templates/root-cause-analysis.dna.yaml +19 -0
- package/dist/templates/safe-refactoring.dna.yaml +321 -0
- package/dist/templates/secure-dev.dna.yaml +19 -0
- package/dist/templates/subagent-parallel.dna.yaml +19 -0
- package/dist/templates/systematic-debugging.dna.yaml +19 -0
- package/dist/templates/tdd-strict.dna.yaml +19 -0
- package/dist/templates/ui-visual-regression-qa.dna.yaml +133 -0
- package/dist/templates/workflow-author.dna.yaml +302 -0
- package/dist/templates/workflow-blocked-scope-triage.dna.yaml +242 -0
- package/dist/templates/workflow-completion-audit.dna.yaml +254 -0
- package/dist/templates/workflow-cross-boundary-resource-approval.dna.yaml +249 -0
- package/dist/templates/workflow-evidence-review.dna.yaml +198 -0
- package/dist/templates/workflow-module-inventory.dna.yaml +257 -0
- package/dist/templates/workflow-runtime-smoke-review.dna.yaml +252 -0
- package/dist/templates/workflow-verification-command-routing.dna.yaml +278 -0
- package/dist/workflow/authoring-packet.d.ts +67 -0
- package/dist/workflow/authoring-packet.js +218 -0
- package/dist/workflow/draft.d.ts +159 -0
- package/dist/workflow/draft.js +800 -0
- package/dist/workflow/index.d.ts +3 -0
- package/dist/workflow/index.js +3 -0
- package/dist/workflow/suggestion-review.d.ts +65 -0
- package/dist/workflow/suggestion-review.js +245 -0
- package/package.json +1 -1
- package/spec/README.md +15 -48
- package/spec/codex-adapter-contract.md +176 -0
- package/spec/sync-target-plan.md +158 -0
- package/spec/workflow-capability-ir.md +153 -0
- package/spec/agent-dispatch-fix.md +0 -116
- package/spec/control-plane-convergence-handoff-2026-04-24.md +0 -432
- package/spec/flutter-rewrite-template-optimization.md +0 -301
- package/spec/foundation-hardening.md +0 -178
- package/spec/hooks-infra-harness-hardening.md +0 -741
- package/spec/multi-config.md +0 -172
- package/spec/parallel-isolation.md +0 -268
- package/spec/template-version-namespace-fix.md +0 -653
- package/spec/workflow-pipeline.md +0 -101
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { ConstraintIR } from "../schema/types.js";
|
|
2
|
+
import { type CodexAdapterArtifacts, type CodexHookInstallMode } from "./codex-adapter.js";
|
|
3
|
+
import type { AdapterCapabilityReport, CapabilityReportEntry, EvidencePlan, PlannedArtifact, SyncTargetPlan } from "./sync-target-plan.js";
|
|
4
|
+
export interface CodexSyncTargetPlanOptions {
|
|
5
|
+
hookInstallMode?: CodexHookInstallMode;
|
|
6
|
+
packageVersion: string;
|
|
7
|
+
}
|
|
8
|
+
export type CodexPlannedArtifact = PlannedArtifact;
|
|
9
|
+
export type CodexCapabilityReportEntry = CapabilityReportEntry;
|
|
10
|
+
export type CodexAdapterCapabilityReport = AdapterCapabilityReport & {
|
|
11
|
+
adapter: "codex_cli";
|
|
12
|
+
runtime: "codex_cli";
|
|
13
|
+
};
|
|
14
|
+
export type CodexEvidencePlan = EvidencePlan;
|
|
15
|
+
export interface CodexSyncTargetPlan extends SyncTargetPlan {
|
|
16
|
+
target: "codex_cli";
|
|
17
|
+
hookInstallMode: CodexHookInstallMode;
|
|
18
|
+
artifacts: CodexAdapterArtifacts;
|
|
19
|
+
plannedArtifacts: CodexPlannedArtifact[];
|
|
20
|
+
capabilityReport: CodexAdapterCapabilityReport;
|
|
21
|
+
evidencePlan: CodexEvidencePlan;
|
|
22
|
+
warnings: string[];
|
|
23
|
+
unsupported: string[];
|
|
24
|
+
}
|
|
25
|
+
export interface ExecuteCodexSyncTargetPlanOptions {
|
|
26
|
+
projectDir: string;
|
|
27
|
+
dogfood?: boolean;
|
|
28
|
+
}
|
|
29
|
+
export declare function createCodexSyncTargetPlan(ir: ConstraintIR, options: CodexSyncTargetPlanOptions): CodexSyncTargetPlan;
|
|
30
|
+
export declare function executeCodexSyncTargetPlan(plan: CodexSyncTargetPlan, options: ExecuteCodexSyncTargetPlanOptions): Promise<string[]>;
|
|
31
|
+
export declare function codexSyncDispatcherCommand(): string;
|
|
32
|
+
export declare function removeCodexSyncTargetArtifacts(projectDir: string): Promise<string[]>;
|
|
33
|
+
export declare function formatCodexSyncTargetPlanSummary(plan: CodexSyncTargetPlan): string;
|
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
import { dirname, resolve } from "node:path";
|
|
2
|
+
import { fileURLToPath } from "node:url";
|
|
3
|
+
import { compileCodexAdapterArtifacts, removeCodexAdapterArtifacts, runCodexExecDogfood, withCodexDogfoodEvidence, writeCodexAdapterArtifacts, } from "./codex-adapter.js";
|
|
4
|
+
import { formatSyncTargetPlanDiagnostics } from "./sync-target-plan.js";
|
|
5
|
+
const PACKAGE_ROOT = resolve(dirname(fileURLToPath(import.meta.url)), "..", "..");
|
|
6
|
+
const CODEX_DISPATCHER_SCRIPT = "dist/hooks/cli.js";
|
|
7
|
+
function plannedArtifacts(artifacts) {
|
|
8
|
+
const plans = [
|
|
9
|
+
{
|
|
10
|
+
kind: "codex_instruction",
|
|
11
|
+
path: artifacts.instruction.path,
|
|
12
|
+
ownership: "intentdna_owned",
|
|
13
|
+
trackedByLock: true,
|
|
14
|
+
outputArtifact: "codex-adapter",
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
kind: "codex_policy_map",
|
|
18
|
+
path: artifacts.policyMap.path,
|
|
19
|
+
ownership: "diagnostic",
|
|
20
|
+
trackedByLock: true,
|
|
21
|
+
outputArtifact: "codex-adapter",
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
kind: "codex_adapter_evidence",
|
|
25
|
+
path: ".dna/compiled/codex-adapter-evidence.json",
|
|
26
|
+
ownership: "diagnostic",
|
|
27
|
+
trackedByLock: true,
|
|
28
|
+
outputArtifact: "codex-adapter",
|
|
29
|
+
},
|
|
30
|
+
];
|
|
31
|
+
if (artifacts.evidence.install_mode_semantics.writes_project_fallback) {
|
|
32
|
+
plans.push({
|
|
33
|
+
kind: "codex_fallback_hooks",
|
|
34
|
+
path: artifacts.evidence.fallback_hooks_path,
|
|
35
|
+
ownership: "merge_preserve_user",
|
|
36
|
+
trackedByLock: true,
|
|
37
|
+
outputArtifact: "codex-adapter",
|
|
38
|
+
}, {
|
|
39
|
+
kind: "codex_fallback_trust_state",
|
|
40
|
+
path: artifacts.evidence.fallback_config_path,
|
|
41
|
+
ownership: "merge_preserve_user",
|
|
42
|
+
trackedByLock: true,
|
|
43
|
+
outputArtifact: "codex-adapter",
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
if (artifacts.evidence.install_mode_semantics.writes_plugin_artifacts) {
|
|
47
|
+
plans.push({
|
|
48
|
+
kind: "codex_plugin_manifest",
|
|
49
|
+
path: "codex-plugin/.codex-plugin/plugin.json",
|
|
50
|
+
ownership: "intentdna_owned",
|
|
51
|
+
trackedByLock: true,
|
|
52
|
+
outputArtifact: "codex-adapter",
|
|
53
|
+
}, {
|
|
54
|
+
kind: "codex_plugin_hooks",
|
|
55
|
+
path: "codex-plugin/hooks/hooks.json",
|
|
56
|
+
ownership: "intentdna_owned",
|
|
57
|
+
trackedByLock: true,
|
|
58
|
+
outputArtifact: "codex-adapter",
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
return plans;
|
|
62
|
+
}
|
|
63
|
+
function supportStatus(status, keys, fallback = "unknown") {
|
|
64
|
+
const values = keys.map((key) => status[key]).filter((value) => value !== undefined);
|
|
65
|
+
if (values.includes("partial"))
|
|
66
|
+
return "partial";
|
|
67
|
+
if (values.includes("supported"))
|
|
68
|
+
return "supported";
|
|
69
|
+
if (values.includes("unsupported"))
|
|
70
|
+
return "unsupported";
|
|
71
|
+
return values[0] ?? fallback;
|
|
72
|
+
}
|
|
73
|
+
function capabilityReport(artifacts) {
|
|
74
|
+
const status = artifacts.evidence.support_status;
|
|
75
|
+
const instructionPath = artifacts.evidence.instruction_path;
|
|
76
|
+
const capabilities = {
|
|
77
|
+
intent_lock: {
|
|
78
|
+
status: supportStatus(status, ["prompt_directives"]),
|
|
79
|
+
surfaces: [instructionPath],
|
|
80
|
+
evidenceRefs: ["codex-instruction-artifact"],
|
|
81
|
+
notes: ["Prompt directives are rendered as Codex instructions and remain soft guidance until paired with runtime evidence."],
|
|
82
|
+
},
|
|
83
|
+
boundary_constraint: {
|
|
84
|
+
status: supportStatus(status, ["role_scope", "pre_execution_gates"]),
|
|
85
|
+
surfaces: ["Codex permissions/rules plus PreToolUse hook diagnostics"],
|
|
86
|
+
evidenceRefs: ["codex-role-scope-map", "codex-pre-tool-use-hook"],
|
|
87
|
+
notes: ["Scope constraints require concrete Codex permission and hook coverage for each runtime path."],
|
|
88
|
+
},
|
|
89
|
+
context_control: {
|
|
90
|
+
status: supportStatus(status, ["context_injections"]),
|
|
91
|
+
surfaces: [instructionPath],
|
|
92
|
+
evidenceRefs: ["codex-context-instruction-artifact"],
|
|
93
|
+
notes: ["Static context can be injected into instructions; dynamic context control remains event-limited."],
|
|
94
|
+
},
|
|
95
|
+
tool_policy: {
|
|
96
|
+
status: supportStatus(status, ["tool_filters", "role_tool_permissions"]),
|
|
97
|
+
surfaces: ["Codex execpolicy/rules and PreToolUse hook subset"],
|
|
98
|
+
evidenceRefs: ["codex-tool-filter-map", "codex-role-scope-map"],
|
|
99
|
+
notes: ["Non-Bash and unsupported tool paths stay explicit in unsupported gaps."],
|
|
100
|
+
},
|
|
101
|
+
approval_gate: {
|
|
102
|
+
status: supportStatus(status, ["pre_execution_gates", "permission_request"]),
|
|
103
|
+
surfaces: ["PreToolUse hook", "PermissionRequest unsupported fixture"],
|
|
104
|
+
evidenceRefs: ["codex-pre-tool-use-hook"],
|
|
105
|
+
notes: ["PreToolUse gates can diagnose or block supported paths; native permission-request parity is not claimed."],
|
|
106
|
+
},
|
|
107
|
+
checkpoint: {
|
|
108
|
+
status: supportStatus(status, ["post_execution_validators"]),
|
|
109
|
+
surfaces: ["PostToolUse/Stop validation evidence"],
|
|
110
|
+
evidenceRefs: ["codex-validation-hook"],
|
|
111
|
+
notes: ["Validation hooks can record evidence but cannot reverse completed side effects."],
|
|
112
|
+
},
|
|
113
|
+
completion_check: {
|
|
114
|
+
status: supportStatus(status, ["post_execution_validators"]),
|
|
115
|
+
surfaces: ["PostToolUse/Stop validation evidence"],
|
|
116
|
+
evidenceRefs: ["codex-validation-hook"],
|
|
117
|
+
notes: ["Completion checks remain partial until verifier outcomes are backed by RuntimeDecisionEvent provenance."],
|
|
118
|
+
},
|
|
119
|
+
artifact_handoff: {
|
|
120
|
+
status: "partial",
|
|
121
|
+
surfaces: [...new Set([artifacts.policyMap.path, artifacts.evidence.policy_map_path, artifacts.evidence.dispatcher_script])],
|
|
122
|
+
evidenceRefs: ["codex-policy-map", "codex-adapter-evidence"],
|
|
123
|
+
notes: ["Generated artifacts describe handoff surfaces but are diagnostic artifacts, not policy truth."],
|
|
124
|
+
},
|
|
125
|
+
isolation: {
|
|
126
|
+
status: "unknown",
|
|
127
|
+
surfaces: ["Codex sandbox flags are execution-time choices outside sync artifact generation"],
|
|
128
|
+
evidenceRefs: [],
|
|
129
|
+
notes: ["Workflow isolation requirements can be declared, but this sync target does not yet prove runtime sandbox isolation."],
|
|
130
|
+
},
|
|
131
|
+
dry_run: {
|
|
132
|
+
status: "supported",
|
|
133
|
+
surfaces: ["dna sync --dry-run Codex target plan"],
|
|
134
|
+
evidenceRefs: ["codex-sync-target-plan"],
|
|
135
|
+
notes: ["Dry-run reports planned Codex artifacts, support posture, evidence classification, and unsupported gaps without writing files."],
|
|
136
|
+
},
|
|
137
|
+
rollback_or_compensation: {
|
|
138
|
+
status: "unsupported",
|
|
139
|
+
surfaces: [],
|
|
140
|
+
evidenceRefs: ["post_execution_side_effect_rollback"],
|
|
141
|
+
notes: ["Codex validation hooks can observe outcomes but cannot roll back completed side effects."],
|
|
142
|
+
},
|
|
143
|
+
trace: {
|
|
144
|
+
status: supportStatus(status, ["runtime_decision_event"]),
|
|
145
|
+
surfaces: ["RuntimeDecisionEvent state writer", ".dna/compiled/codex-adapter-evidence.json"],
|
|
146
|
+
evidenceRefs: ["RuntimeDecisionEvent", "codex-adapter-evidence"],
|
|
147
|
+
notes: ["Adapter evidence is trace-adjacent diagnostic data; RuntimeDecisionEvent remains the primary trace contract."],
|
|
148
|
+
},
|
|
149
|
+
runtime_decision_evidence: {
|
|
150
|
+
status: supportStatus(status, ["runtime_decision_event"]),
|
|
151
|
+
surfaces: ["appendRuntimeDecisionEvent", ".dna/compiled/codex-adapter-evidence.json"],
|
|
152
|
+
evidenceRefs: ["RuntimeDecisionEvent", "codex-adapter-evidence"],
|
|
153
|
+
notes: ["Diagnostic adapter evidence must not be upgraded to enterprise evidence without trusted RuntimeDecisionEvent provenance."],
|
|
154
|
+
},
|
|
155
|
+
logic_equivalence_validation: {
|
|
156
|
+
status: "unknown",
|
|
157
|
+
surfaces: ["Workflow verifier specs and external test commands"],
|
|
158
|
+
evidenceRefs: ["verifier_specs", "RuntimeDecisionEvent"],
|
|
159
|
+
notes: ["Equivalence validation is a workflow capability, not a Codex-native sync artifact; concrete proof must come from verifier execution evidence."],
|
|
160
|
+
},
|
|
161
|
+
};
|
|
162
|
+
return {
|
|
163
|
+
adapter: "codex_cli",
|
|
164
|
+
runtime: "codex_cli",
|
|
165
|
+
capabilities,
|
|
166
|
+
unsupported: artifacts.evidence.unsupported,
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
function evidencePlan(artifacts) {
|
|
170
|
+
return {
|
|
171
|
+
primary: "RuntimeDecisionEvent",
|
|
172
|
+
diagnosticArtifacts: [
|
|
173
|
+
artifacts.evidence.policy_map_path,
|
|
174
|
+
".dna/compiled/codex-adapter-evidence.json",
|
|
175
|
+
artifacts.evidence.instruction_path,
|
|
176
|
+
],
|
|
177
|
+
classification: artifacts.evidence.trust_verification?.classification ?? artifacts.evidence.install_mode_semantics.classification,
|
|
178
|
+
notes: artifacts.evidence.notes,
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
export function createCodexSyncTargetPlan(ir, options) {
|
|
182
|
+
const hookInstallMode = options.hookInstallMode ?? "project_fallback";
|
|
183
|
+
const artifacts = compileCodexAdapterArtifacts(ir, {
|
|
184
|
+
adapterRoot: PACKAGE_ROOT,
|
|
185
|
+
dispatcherScript: CODEX_DISPATCHER_SCRIPT,
|
|
186
|
+
hookInstallMode,
|
|
187
|
+
pluginVersion: options.packageVersion,
|
|
188
|
+
});
|
|
189
|
+
return {
|
|
190
|
+
target: "codex_cli",
|
|
191
|
+
hookInstallMode,
|
|
192
|
+
artifacts,
|
|
193
|
+
plannedArtifacts: plannedArtifacts(artifacts),
|
|
194
|
+
capabilityReport: capabilityReport(artifacts),
|
|
195
|
+
evidencePlan: evidencePlan(artifacts),
|
|
196
|
+
warnings: artifacts.evidence.notes,
|
|
197
|
+
unsupported: artifacts.evidence.unsupported,
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
export async function executeCodexSyncTargetPlan(plan, options) {
|
|
201
|
+
let artifacts = plan.artifacts;
|
|
202
|
+
if (options.dogfood) {
|
|
203
|
+
const dogfood = await runCodexExecDogfood({ projectDir: options.projectDir });
|
|
204
|
+
artifacts = { ...artifacts, evidence: withCodexDogfoodEvidence(artifacts.evidence, dogfood) };
|
|
205
|
+
}
|
|
206
|
+
return writeCodexAdapterArtifacts(options.projectDir, artifacts);
|
|
207
|
+
}
|
|
208
|
+
export function codexSyncDispatcherCommand() {
|
|
209
|
+
return createCodexSyncTargetPlan({
|
|
210
|
+
source_dna_ids: [],
|
|
211
|
+
compiled_at: new Date().toISOString(),
|
|
212
|
+
prompt_directives: [],
|
|
213
|
+
tool_filters: [],
|
|
214
|
+
pre_execution_gates: [],
|
|
215
|
+
post_execution_validators: [],
|
|
216
|
+
context_injections: [],
|
|
217
|
+
}, {
|
|
218
|
+
packageVersion: "0.0.0",
|
|
219
|
+
}).artifacts.evidence.dispatcher_command;
|
|
220
|
+
}
|
|
221
|
+
export async function removeCodexSyncTargetArtifacts(projectDir) {
|
|
222
|
+
return removeCodexAdapterArtifacts(projectDir, codexSyncDispatcherCommand());
|
|
223
|
+
}
|
|
224
|
+
export function formatCodexSyncTargetPlanSummary(plan) {
|
|
225
|
+
const lines = [
|
|
226
|
+
`Codex target support posture: ${plan.artifacts.evidence.install_mode_semantics.support_status}`,
|
|
227
|
+
`Codex evidence plan: primary=${plan.evidencePlan.primary}, classification=${plan.evidencePlan.classification}`,
|
|
228
|
+
`Codex planned artifacts: ${plan.plannedArtifacts.length}`,
|
|
229
|
+
];
|
|
230
|
+
for (const artifact of plan.plannedArtifacts) {
|
|
231
|
+
lines.push(` - ${artifact.kind}: ${artifact.path} (${artifact.ownership})`);
|
|
232
|
+
}
|
|
233
|
+
const capabilityEntries = Object.entries(plan.capabilityReport.capabilities)
|
|
234
|
+
.sort(([left], [right]) => left.localeCompare(right));
|
|
235
|
+
lines.push("Codex capability report:");
|
|
236
|
+
for (const [capability, entry] of capabilityEntries) {
|
|
237
|
+
const surfaces = entry.surfaces.length > 0 ? entry.surfaces.join(", ") : "no Codex sync surface";
|
|
238
|
+
lines.push(` - ${capability}: ${entry.status} via ${surfaces}`);
|
|
239
|
+
}
|
|
240
|
+
return `${lines.join("\n")}\n${formatSyncTargetPlanDiagnostics(plan)}`;
|
|
241
|
+
}
|
package/dist/runtime/index.d.ts
CHANGED
|
@@ -7,3 +7,11 @@ export type { WorkflowShellOptions, WorkflowShellResult } from "./workflow-runne
|
|
|
7
7
|
export { createCompiledIR, writeCompiledIR, loadCompiledIR, removeCompiledIR, } from "./plugin-adapter.js";
|
|
8
8
|
export type { CompiledIRFile } from "./plugin-adapter.js";
|
|
9
9
|
export { compilePluginSettings, detectEnabledEvents, } from "./settings-adapter.js";
|
|
10
|
+
export { CODEX_ADAPTER_MINIMUM_VERSION, CODEX_NATIVE_HOOK_EVENTS, appendCodexRuntimeDecisionEvent, buildCodexDispatcherCommand, buildCodexHookTrustState, codexHookTrustedHash, codexInstallModeSemantics, codexTrustStateToml, compileCodexAdapterArtifacts, compileCodexHooksConfig, compileCodexInstructionArtifact, compileCodexPluginManifest, compileCodexPolicyMapArtifact, mapCodexDecisionEvent, mergeCodexFallbackHooks, mergeCodexTrustStateConfig, normalizeCodexHookInput, probeCodexRuntime, runCodexExecDogfood, removeCodexAdapterArtifacts, removeCodexFallbackHooks, removeCodexTrustStateConfig, runCodexHook, withCodexDogfoodEvidence, verifyCodexHookTrust, writeCodexAdapterArtifacts, } from "./codex-adapter.js";
|
|
11
|
+
export type { CodexAdapterArtifacts, CodexAdapterEvidence, CodexAdapterSupportStatus, CodexCommandHook, CodexDecisionMappingInput, CodexDogfoodResult, CodexEvidenceClassification, CodexExecJsonEvent, CodexHookGroup, CodexHookInput, CodexHookInstallMode, CodexHookRunnerOptions, CodexHookRunnerResult, CodexHookTrustState, CodexHooksConfig, CodexInstallModeSemantics, CodexInstructionArtifact, CodexNativeHookEvent, CodexPluginManifest, CodexPolicyMap, CodexPolicyMapArtifact, CodexPolicyMapEntry, CodexRuntimeProbe, CodexTrustVerification, RunCodexDogfoodOptions, CodexTrustVerificationInput, CompileCodexAdapterOptions, } from "./codex-adapter.js";
|
|
12
|
+
export { codexSyncDispatcherCommand, createCodexSyncTargetPlan, executeCodexSyncTargetPlan, formatCodexSyncTargetPlanSummary, removeCodexSyncTargetArtifacts, } from "./codex-sync-target.js";
|
|
13
|
+
export type { CodexAdapterCapabilityReport, CodexCapabilityReportEntry, CodexEvidencePlan, CodexPlannedArtifact, CodexSyncTargetPlan, CodexSyncTargetPlanOptions, ExecuteCodexSyncTargetPlanOptions, } from "./codex-sync-target.js";
|
|
14
|
+
export { createClaudeCoreSyncTargetPlan, executeClaudeCoreSyncTargetPlan, formatClaudeCoreSyncTargetPlanDryRun, removeLegacyBashHooks, } from "./claude-sync-target.js";
|
|
15
|
+
export type { ClaudeCoreAdapterCapabilityReport, ClaudeCoreCapabilityReportEntry, ClaudeCorePlannedArtifact, ClaudeCoreSyncTargetPlan, ClaudeCoreSyncTargetPlanOptions, ClaudeSettingsHookRegistration, ClaudeSyncMode, ExecuteClaudeCoreSyncTargetPlanResult, } from "./claude-sync-target.js";
|
|
16
|
+
export type { AdapterCapabilityReport, CapabilityReportEntry, CapabilitySupportStatus, EvidenceClassification, EvidencePlan, PlannedArtifact, SyncTarget, SyncTargetMode, SyncTargetPlan, } from "./sync-target-plan.js";
|
|
17
|
+
export { formatSyncTargetPlanDiagnostics, trackedOutputsForSyncTargetPlan, } from "./sync-target-plan.js";
|
package/dist/runtime/index.js
CHANGED
|
@@ -3,3 +3,7 @@ export { compileRoleToAgentMD, compileAllRolesToAgentMD, writeAgentMDFiles, remo
|
|
|
3
3
|
export { compileWorkflowToShell, writeWorkflowScript, removeWorkflowScripts, } from "./workflow-runner.js";
|
|
4
4
|
export { createCompiledIR, writeCompiledIR, loadCompiledIR, removeCompiledIR, } from "./plugin-adapter.js";
|
|
5
5
|
export { compilePluginSettings, detectEnabledEvents, } from "./settings-adapter.js";
|
|
6
|
+
export { CODEX_ADAPTER_MINIMUM_VERSION, CODEX_NATIVE_HOOK_EVENTS, appendCodexRuntimeDecisionEvent, buildCodexDispatcherCommand, buildCodexHookTrustState, codexHookTrustedHash, codexInstallModeSemantics, codexTrustStateToml, compileCodexAdapterArtifacts, compileCodexHooksConfig, compileCodexInstructionArtifact, compileCodexPluginManifest, compileCodexPolicyMapArtifact, mapCodexDecisionEvent, mergeCodexFallbackHooks, mergeCodexTrustStateConfig, normalizeCodexHookInput, probeCodexRuntime, runCodexExecDogfood, removeCodexAdapterArtifacts, removeCodexFallbackHooks, removeCodexTrustStateConfig, runCodexHook, withCodexDogfoodEvidence, verifyCodexHookTrust, writeCodexAdapterArtifacts, } from "./codex-adapter.js";
|
|
7
|
+
export { codexSyncDispatcherCommand, createCodexSyncTargetPlan, executeCodexSyncTargetPlan, formatCodexSyncTargetPlanSummary, removeCodexSyncTargetArtifacts, } from "./codex-sync-target.js";
|
|
8
|
+
export { createClaudeCoreSyncTargetPlan, executeClaudeCoreSyncTargetPlan, formatClaudeCoreSyncTargetPlanDryRun, removeLegacyBashHooks, } from "./claude-sync-target.js";
|
|
9
|
+
export { formatSyncTargetPlanDiagnostics, trackedOutputsForSyncTargetPlan, } from "./sync-target-plan.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const SYNC_OUTPUT_ARTIFACT_IDS: readonly ["markdown-injection", "compiled-ir", "settings-hooks", "agents", "workflows", "skills-controllers", "mcp-config", "lock-file"];
|
|
1
|
+
export declare const SYNC_OUTPUT_ARTIFACT_IDS: readonly ["markdown-injection", "compiled-ir", "settings-hooks", "agents", "workflows", "skills-controllers", "mcp-config", "codex-adapter", "lock-file"];
|
|
2
2
|
export type SyncOutputArtifactId = typeof SYNC_OUTPUT_ARTIFACT_IDS[number];
|
|
3
3
|
export interface SyncOutputArtifactMetadata {
|
|
4
4
|
id: SyncOutputArtifactId;
|
|
@@ -6,6 +6,7 @@ export const SYNC_OUTPUT_ARTIFACT_IDS = [
|
|
|
6
6
|
"workflows",
|
|
7
7
|
"skills-controllers",
|
|
8
8
|
"mcp-config",
|
|
9
|
+
"codex-adapter",
|
|
9
10
|
"lock-file",
|
|
10
11
|
];
|
|
11
12
|
export const SYNC_OUTPUT_ARTIFACT_REGISTRY = [
|
|
@@ -16,6 +17,7 @@ export const SYNC_OUTPUT_ARTIFACT_REGISTRY = [
|
|
|
16
17
|
{ id: "workflows", order: 60, label: "Workflows", trackedByLock: true },
|
|
17
18
|
{ id: "skills-controllers", order: 70, label: "Skills and controllers", trackedByLock: true },
|
|
18
19
|
{ id: "mcp-config", order: 80, label: "MCP config", trackedByLock: false },
|
|
20
|
+
{ id: "codex-adapter", order: 85, label: "Codex adapter", trackedByLock: true },
|
|
19
21
|
{ id: "lock-file", order: 90, label: "Lock file", trackedByLock: false },
|
|
20
22
|
];
|
|
21
23
|
const ARTIFACT_BY_ID = new Map(SYNC_OUTPUT_ARTIFACT_REGISTRY.map((entry) => [entry.id, entry]));
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Compiles DNA hook events into Claude Code settings.json
|
|
5
5
|
* hook configurations for the dna-hook binary.
|
|
6
6
|
*
|
|
7
|
-
* See docs/references/cc-source-analysis.md §2 for the full hook event catalog.
|
|
7
|
+
* See docs/archive/2026H1/references/cc-source-analysis.md §2 for the full hook event catalog.
|
|
8
8
|
*/
|
|
9
9
|
import { type SettingsHookEventKey } from "../hooks/event-registry.js";
|
|
10
10
|
export type HookEventKey = SettingsHookEventKey;
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Compiles DNA hook events into Claude Code settings.json
|
|
5
5
|
* hook configurations for the dna-hook binary.
|
|
6
6
|
*
|
|
7
|
-
* See docs/references/cc-source-analysis.md §2 for the full hook event catalog.
|
|
7
|
+
* See docs/archive/2026H1/references/cc-source-analysis.md §2 for the full hook event catalog.
|
|
8
8
|
*/
|
|
9
9
|
import { readFile, writeFile } from "node:fs/promises";
|
|
10
10
|
import { getHookEventBySettingsKey, settingsHookEventKeys } from "../hooks/event-registry.js";
|
|
@@ -45,7 +45,11 @@ export interface SkillResult {
|
|
|
45
45
|
bodyFileName?: string;
|
|
46
46
|
mapEntry?: SkillMapEntry;
|
|
47
47
|
}
|
|
48
|
+
export type WorkflowSkillSurface = "claude_code" | "codex_cli";
|
|
49
|
+
export interface WorkflowSkillOptions {
|
|
50
|
+
surface?: WorkflowSkillSurface;
|
|
51
|
+
}
|
|
48
52
|
export declare function compileControllerToSkill(controllerKey: string, controller: ControllerDef, variables?: Record<string, string>, workflows?: Record<string, WorkflowDef>): SkillResult;
|
|
49
|
-
export declare function compileWorkflowToSkill(plan: WorkflowPlan, roles: Record<string, RoleDef>, ir?: ConstraintIR, variables?: Record<string, string
|
|
53
|
+
export declare function compileWorkflowToSkill(plan: WorkflowPlan, roles: Record<string, RoleDef>, ir?: ConstraintIR, variables?: Record<string, string>, options?: WorkflowSkillOptions): SkillResult;
|
|
50
54
|
export declare function writeSkillFiles(results: SkillResult[], outputDir: string): Promise<string[]>;
|
|
51
55
|
export declare function removeSkillFiles(outputDir: string): Promise<number>;
|
|
@@ -19,26 +19,54 @@ function resolveContainedPath(baseDir, ...segments) {
|
|
|
19
19
|
}
|
|
20
20
|
return target;
|
|
21
21
|
}
|
|
22
|
+
function isHumanRole(role) {
|
|
23
|
+
return role?.model?.trim().toLowerCase() === "human";
|
|
24
|
+
}
|
|
25
|
+
function isInteractiveRole(role) {
|
|
26
|
+
return role?.model?.trim().toLowerCase() === "interactive";
|
|
27
|
+
}
|
|
22
28
|
// ── Compile Controller → Skill ─────────────────────────────
|
|
23
29
|
export function compileControllerToSkill(controllerKey, controller, variables, workflows) {
|
|
24
30
|
const kindMetadata = getControllerKindMetadata(controller.kind);
|
|
25
31
|
if (!kindMetadata?.supportsSkillGeneration) {
|
|
26
32
|
throw new Error(`Unsupported controller kind: ${controller.kind}`);
|
|
27
33
|
}
|
|
34
|
+
const diagnosisWorkflowName = controller.diagnosis_workflow;
|
|
35
|
+
const fixWorkflowName = controller.fix_workflow;
|
|
36
|
+
const diagnosisArtifactPath = controller.diagnosis_artifact_path;
|
|
37
|
+
const diagnosisReviewArtifactPath = controller.diagnosis_review_artifact_path;
|
|
38
|
+
const reviewArtifactPath = controller.review_artifact_path;
|
|
39
|
+
const analyzerRole = controller.roles.analyzer;
|
|
40
|
+
const analysisReviewerRole = controller.roles.analysis_reviewer;
|
|
41
|
+
const surgeonRole = controller.roles.surgeon;
|
|
42
|
+
const fixReviewerRole = controller.roles.fix_reviewer;
|
|
43
|
+
const testRunnerRole = controller.roles.test_runner;
|
|
44
|
+
if (!diagnosisWorkflowName ||
|
|
45
|
+
!fixWorkflowName ||
|
|
46
|
+
!diagnosisArtifactPath ||
|
|
47
|
+
!diagnosisReviewArtifactPath ||
|
|
48
|
+
!reviewArtifactPath ||
|
|
49
|
+
!analyzerRole ||
|
|
50
|
+
!analysisReviewerRole ||
|
|
51
|
+
!surgeonRole ||
|
|
52
|
+
!fixReviewerRole ||
|
|
53
|
+
!testRunnerRole) {
|
|
54
|
+
throw new Error(`Controller '${controllerKey}' is missing fix-loop skill generation fields`);
|
|
55
|
+
}
|
|
28
56
|
const skillName = `dna-${toKebabCase(controllerKey)}`;
|
|
29
57
|
assertSafeGeneratedName(skillName, "skill name");
|
|
30
|
-
const analyzerAgent = `dna-${toKebabCase(
|
|
31
|
-
const analysisReviewerAgent = `dna-${toKebabCase(
|
|
32
|
-
const surgeonAgent = `dna-${toKebabCase(
|
|
33
|
-
const fixReviewerAgent = `dna-${toKebabCase(
|
|
34
|
-
const testRunnerAgent = `dna-${toKebabCase(
|
|
35
|
-
const diagnosisWorkflow = workflows?.[
|
|
36
|
-
const fixWorkflow = workflows?.[
|
|
37
|
-
const diagnosisAnalyzeStep = requireStepByRole(diagnosisWorkflow,
|
|
38
|
-
const diagnosisReviewStep = requireStepByRole(diagnosisWorkflow,
|
|
39
|
-
const fixBugsStep = requireStepByRole(fixWorkflow,
|
|
40
|
-
const reviewChangesStep = requireStepByRole(fixWorkflow,
|
|
41
|
-
const verifyReportStep = requireStepByRole(fixWorkflow,
|
|
58
|
+
const analyzerAgent = `dna-${toKebabCase(analyzerRole)}`;
|
|
59
|
+
const analysisReviewerAgent = `dna-${toKebabCase(analysisReviewerRole)}`;
|
|
60
|
+
const surgeonAgent = `dna-${toKebabCase(surgeonRole)}`;
|
|
61
|
+
const fixReviewerAgent = `dna-${toKebabCase(fixReviewerRole)}`;
|
|
62
|
+
const testRunnerAgent = `dna-${toKebabCase(testRunnerRole)}`;
|
|
63
|
+
const diagnosisWorkflow = workflows?.[diagnosisWorkflowName];
|
|
64
|
+
const fixWorkflow = workflows?.[fixWorkflowName];
|
|
65
|
+
const diagnosisAnalyzeStep = requireStepByRole(diagnosisWorkflow, analyzerRole, diagnosisWorkflowName);
|
|
66
|
+
const diagnosisReviewStep = requireStepByRole(diagnosisWorkflow, analysisReviewerRole, diagnosisWorkflowName);
|
|
67
|
+
const fixBugsStep = requireStepByRole(fixWorkflow, surgeonRole, fixWorkflowName);
|
|
68
|
+
const reviewChangesStep = requireStepByRole(fixWorkflow, fixReviewerRole, fixWorkflowName);
|
|
69
|
+
const verifyReportStep = requireStepByRole(fixWorkflow, testRunnerRole, fixWorkflowName);
|
|
42
70
|
const stepPrompt = (step) => step.prompt || step.description || "";
|
|
43
71
|
const policy = normalizeControllerPolicy(controller);
|
|
44
72
|
const lines = [];
|
|
@@ -63,8 +91,8 @@ export function compileControllerToSkill(controllerKey, controller, variables, w
|
|
|
63
91
|
lines.push("<Controller>");
|
|
64
92
|
lines.push(`kind: ${controller.kind}`);
|
|
65
93
|
lines.push(`max_rounds: ${controller.max_rounds}`);
|
|
66
|
-
lines.push(`diagnosis_workflow: ${
|
|
67
|
-
lines.push(`fix_workflow: ${
|
|
94
|
+
lines.push(`diagnosis_workflow: ${diagnosisWorkflowName}`);
|
|
95
|
+
lines.push(`fix_workflow: ${fixWorkflowName}`);
|
|
68
96
|
lines.push(`progress_artifact_path: ${controller.progress_artifact_path}`);
|
|
69
97
|
lines.push("</Controller>");
|
|
70
98
|
lines.push("");
|
|
@@ -74,8 +102,8 @@ export function compileControllerToSkill(controllerKey, controller, variables, w
|
|
|
74
102
|
lines.push(" - If it contains '/', '.', '..', spaces, braces, glob characters, or path separators, stop with the configured stop report.");
|
|
75
103
|
lines.push(" - Do not read or write controller artifacts until the module argument is safe.");
|
|
76
104
|
lines.push("1. Check diagnosis artifact freshness before any fix round.");
|
|
77
|
-
lines.push(` - Diagnosis artifact: ${
|
|
78
|
-
lines.push(` - Diagnosis review artifact: ${
|
|
105
|
+
lines.push(` - Diagnosis artifact: ${diagnosisArtifactPath}`);
|
|
106
|
+
lines.push(` - Diagnosis review artifact: ${diagnosisReviewArtifactPath}`);
|
|
79
107
|
lines.push("2. Create a stable controller_run_id once for this invocation before using any artifact path.");
|
|
80
108
|
lines.push(" - Reuse the same controller_run_id in every child Agent prompt and in every progress validation.");
|
|
81
109
|
lines.push(" - Do not regenerate controller_run_id inside fix rounds.");
|
|
@@ -289,9 +317,9 @@ function renderControllerPolicyLines(lines, controller) {
|
|
|
289
317
|
function renderControllerPolicyText(text, controller) {
|
|
290
318
|
const replacements = {
|
|
291
319
|
"$progress_artifact_path": controller.progress_artifact_path,
|
|
292
|
-
"$diagnosis_artifact_path": controller.diagnosis_artifact_path,
|
|
293
|
-
"$diagnosis_review_artifact_path": controller.diagnosis_review_artifact_path,
|
|
294
|
-
"$review_artifact_path": controller.review_artifact_path,
|
|
320
|
+
"$diagnosis_artifact_path": controller.diagnosis_artifact_path ?? "",
|
|
321
|
+
"$diagnosis_review_artifact_path": controller.diagnosis_review_artifact_path ?? "",
|
|
322
|
+
"$review_artifact_path": controller.review_artifact_path ?? "",
|
|
295
323
|
};
|
|
296
324
|
let rendered = text;
|
|
297
325
|
for (const [token, value] of Object.entries(replacements)) {
|
|
@@ -381,9 +409,10 @@ function workflowSkillMapEntry(skillName, dirName, plan) {
|
|
|
381
409
|
produces,
|
|
382
410
|
};
|
|
383
411
|
}
|
|
384
|
-
export function compileWorkflowToSkill(plan, roles, ir, variables) {
|
|
412
|
+
export function compileWorkflowToSkill(plan, roles, ir, variables, options) {
|
|
385
413
|
const lines = [];
|
|
386
414
|
const skillName = `dna-${toKebabCase(plan.name)}`;
|
|
415
|
+
const surface = options?.surface ?? "claude_code";
|
|
387
416
|
assertSafeGeneratedName(skillName, "skill name");
|
|
388
417
|
// Frontmatter
|
|
389
418
|
lines.push("---");
|
|
@@ -492,8 +521,10 @@ export function compileWorkflowToSkill(plan, roles, ir, variables) {
|
|
|
492
521
|
lines.push("</Advisory_Context>");
|
|
493
522
|
lines.push("");
|
|
494
523
|
}
|
|
495
|
-
// Steps —
|
|
524
|
+
// Steps — agent-owned steps are delegated; human-owned steps stay in the main session.
|
|
496
525
|
const usedRoles = new Set(plan.steps.map((s) => s.role));
|
|
526
|
+
const hasHumanSteps = plan.steps.some((step) => isHumanRole(roles[step.role]));
|
|
527
|
+
const hasInteractiveSteps = plan.steps.some((step) => isInteractiveRole(roles[step.role]));
|
|
497
528
|
// Pre-compute handoff targets: steps that are pointed to by another step's handoff_to
|
|
498
529
|
const handoffTargets = new Set();
|
|
499
530
|
for (const step of plan.steps) {
|
|
@@ -508,6 +539,8 @@ export function compileWorkflowToSkill(plan, roles, ir, variables) {
|
|
|
508
539
|
stepNumber++;
|
|
509
540
|
const step = plan.steps.find((s) => s.id === stepId);
|
|
510
541
|
const agentType = `dna-${toKebabCase(step.role)}`;
|
|
542
|
+
const humanOwned = isHumanRole(roles[step.role]);
|
|
543
|
+
const interactiveOwned = isInteractiveRole(roles[step.role]);
|
|
511
544
|
const runIf = step.run_if ? `\n **Condition**: ${step.run_if}` : "";
|
|
512
545
|
const optional = step.optional ? " (optional)" : "";
|
|
513
546
|
// Build agent prompt: anti-recursion + role identity + task
|
|
@@ -536,14 +569,34 @@ export function compileWorkflowToSkill(plan, roles, ir, variables) {
|
|
|
536
569
|
lines.push(`${stepNumber}. **${step.id}**${optional}`);
|
|
537
570
|
lines.push(` ${step.description}${runIf}`);
|
|
538
571
|
lines.push("");
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
572
|
+
if (humanOwned) {
|
|
573
|
+
lines.push(" **Human-owned gate (`model: human`)**");
|
|
574
|
+
lines.push(` Ask the user in the main session: ${step.prompt || step.description}`);
|
|
575
|
+
lines.push(" Do not delegate this decision, infer approval, or continue from silence. Continue only after an explicit human response.");
|
|
576
|
+
}
|
|
577
|
+
else if (interactiveOwned) {
|
|
578
|
+
lines.push(" **Main-session external-agent step (`model: interactive`)**");
|
|
579
|
+
lines.push(` Perform directly in the main session: ${step.prompt || step.description}`);
|
|
580
|
+
lines.push(" This step may interview the user or edit the candidate YAML inside its declared scope. Do not delegate away the conversation context.");
|
|
581
|
+
}
|
|
582
|
+
else if (surface === "codex_cli") {
|
|
583
|
+
lines.push(" Delegate to a Codex native subagent with this role contract; do not discard the role boundaries:");
|
|
584
|
+
lines.push(" ```text");
|
|
585
|
+
lines.push(` role: ${agentType}`);
|
|
586
|
+
lines.push(` prompt: ${agentPrompt}`);
|
|
587
|
+
lines.push(" ```");
|
|
588
|
+
lines.push(" Wait for the subagent to complete and read its output before proceeding.");
|
|
589
|
+
}
|
|
590
|
+
else {
|
|
591
|
+
lines.push(` Execute with Agent tool — DO NOT perform this work yourself:`);
|
|
592
|
+
lines.push(` \`\`\``);
|
|
593
|
+
lines.push(` Agent(`);
|
|
594
|
+
lines.push(` subagent_type="${agentType}",`);
|
|
595
|
+
lines.push(` prompt="${agentPrompt}"`);
|
|
596
|
+
lines.push(` )`);
|
|
597
|
+
lines.push(` \`\`\``);
|
|
598
|
+
lines.push(` Wait for agent to complete. Read the output before proceeding.`);
|
|
599
|
+
}
|
|
547
600
|
if (step.handoff?.produces && step.handoff.produces.length > 0) {
|
|
548
601
|
const artifacts = step.handoff.produces.map(p => p.description).join(", ");
|
|
549
602
|
lines.push(` Verify produced artifacts: ${artifacts}`);
|
|
@@ -565,14 +618,39 @@ export function compileWorkflowToSkill(plan, roles, ir, variables) {
|
|
|
565
618
|
}
|
|
566
619
|
lines.push("</Steps>");
|
|
567
620
|
lines.push("");
|
|
568
|
-
|
|
621
|
+
if (plan.retry.max_retries > 0) {
|
|
622
|
+
lines.push("<Retry_Policy>");
|
|
623
|
+
lines.push(`- max_retries: ${plan.retry.max_retries}`);
|
|
624
|
+
lines.push(`- retry_from: ${plan.retry.retry_from ?? "first_failed_step"}`);
|
|
625
|
+
lines.push(`- backoff: ${plan.retry.backoff}`);
|
|
626
|
+
lines.push("- On a blocking checkpoint or validator failure, preserve the exact diagnostics and return them to the retry_from step.");
|
|
627
|
+
lines.push("- Repeat only the retry slice and its dependent steps; do not continue to save, adoption, or sync while validation is red.");
|
|
628
|
+
lines.push("- Stop and report the remaining diagnostics when the retry budget is exhausted.");
|
|
629
|
+
lines.push("</Retry_Policy>");
|
|
630
|
+
lines.push("");
|
|
631
|
+
}
|
|
632
|
+
// Execution Policy — force delegation while preserving explicit human gates.
|
|
569
633
|
lines.push("<Execution_Policy>");
|
|
570
|
-
|
|
634
|
+
if (surface === "codex_cli") {
|
|
635
|
+
lines.push("- **CRITICAL**: Delegate each delegated-agent step to a Codex native subagent using the specified role contract. Do not collapse distinct roles into an unreviewed single pass.");
|
|
636
|
+
}
|
|
637
|
+
else {
|
|
638
|
+
lines.push(hasHumanSteps || hasInteractiveSteps
|
|
639
|
+
? "- **CRITICAL**: Each delegated-agent step MUST be executed by spawning an Agent using the Agent tool with the specified subagent_type. DO NOT perform delegated-agent work directly in the main session."
|
|
640
|
+
: "- **CRITICAL**: Each step MUST be executed by spawning an Agent using the Agent tool with the specified subagent_type. DO NOT perform any step's work directly in the main session.");
|
|
641
|
+
}
|
|
571
642
|
lines.push("- Use the task tracker to track each step only as pending/in_progress/completed; use deleted only for skipped dependent tasks.");
|
|
572
|
-
lines.push(
|
|
643
|
+
lines.push(hasHumanSteps
|
|
644
|
+
? "- Proceed automatically between non-human steps, but stop at every `model: human` step and require an explicit user response before continuing."
|
|
645
|
+
: "- After completing each step, immediately proceed to the next — do not stop, summarize, or wait for confirmation.");
|
|
646
|
+
if (hasInteractiveSteps) {
|
|
647
|
+
lines.push("- Execute `model: interactive` steps in the main session so interview answers and candidate edits remain in the user-visible conversation.");
|
|
648
|
+
}
|
|
573
649
|
lines.push("- If a step cannot complete, do not use a failed status. Keep the current task in_progress or record the blocker in the task description/output, delete skipped dependent tasks, and continue only to non-dependent steps.");
|
|
574
|
-
lines.push(
|
|
575
|
-
|
|
650
|
+
lines.push(hasHumanSteps
|
|
651
|
+
? "- Never auto-approve, delegate, or synthesize a human-owned decision."
|
|
652
|
+
: "- Do not ask the user for permission between steps — the workflow is pre-approved.");
|
|
653
|
+
lines.push("- Wait for each delegated agent to complete and read its output before proceeding to the next step.");
|
|
576
654
|
lines.push("</Execution_Policy>");
|
|
577
655
|
lines.push("");
|
|
578
656
|
// Tool_Usage — only if roles have permissions or scope
|
|
@@ -585,9 +663,15 @@ export function compileWorkflowToSkill(plan, roles, ir, variables) {
|
|
|
585
663
|
const denied = role.tool_permissions?.deny?.join(", ") || "none";
|
|
586
664
|
const writeScope = role.scope?.write?.join(", ") || "none";
|
|
587
665
|
toolUsageLines.push(`### ${roleName}`);
|
|
666
|
+
toolUsageLines.push(`- Owner: ${isHumanRole(role) ? "human" : isInteractiveRole(role) ? "main_session_external_agent" : "delegated_agent"}`);
|
|
667
|
+
toolUsageLines.push(`- Description: ${role.description}`);
|
|
588
668
|
toolUsageLines.push(`- Allowed: ${allowed}`);
|
|
589
669
|
toolUsageLines.push(`- Denied: ${denied}`);
|
|
590
670
|
toolUsageLines.push(`- Write scope: ${writeScope}`);
|
|
671
|
+
for (const instruction of role.instructions ?? [])
|
|
672
|
+
toolUsageLines.push(`- Instruction: ${instruction}`);
|
|
673
|
+
for (const criterion of role.success_criteria ?? [])
|
|
674
|
+
toolUsageLines.push(`- Success criterion: ${criterion}`);
|
|
591
675
|
}
|
|
592
676
|
if (toolUsageLines.length > 0) {
|
|
593
677
|
lines.push("<Tool_Usage>");
|
|
@@ -631,6 +715,8 @@ export function compileWorkflowToSkill(plan, roles, ir, variables) {
|
|
|
631
715
|
for (const cp of step.checkpoints) {
|
|
632
716
|
const action = cp.action || "block";
|
|
633
717
|
lines.push(`- ${cp.assert}: ${cp.message} (${action})`);
|
|
718
|
+
if (cp.command)
|
|
719
|
+
lines.push(` command: ${cp.command}`);
|
|
634
720
|
}
|
|
635
721
|
}
|
|
636
722
|
lines.push("</Checkpoints>");
|