@tiic-tech/openworkflow 0.1.1 → 0.1.2

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 (213) hide show
  1. package/dist/adapters/codex/src/cleanCodexAdapter.js +4 -1
  2. package/dist/adapters/codex/src/cleanCodexAdapter.js.map +1 -1
  3. package/dist/adapters/codex/src/constants.d.ts +1 -0
  4. package/dist/adapters/codex/src/constants.js +2 -0
  5. package/dist/adapters/codex/src/constants.js.map +1 -0
  6. package/dist/adapters/codex/src/generateCommands.js +14 -9
  7. package/dist/adapters/codex/src/generateCommands.js.map +1 -1
  8. package/dist/adapters/codex/src/generateSkills.js +13 -0
  9. package/dist/adapters/codex/src/generateSkills.js.map +1 -1
  10. package/dist/adapters/codex/src/generatedFiles.js +1 -1
  11. package/dist/adapters/codex/src/manifest.js +11 -2
  12. package/dist/adapters/codex/src/manifest.js.map +1 -1
  13. package/dist/adapters/codex/src/templates.d.ts +0 -1
  14. package/dist/adapters/codex/src/templates.js +0 -1
  15. package/dist/adapters/codex/src/templates.js.map +1 -1
  16. package/dist/adapters/src/registry.d.ts +20 -0
  17. package/dist/adapters/src/registry.js +81 -0
  18. package/dist/adapters/src/registry.js.map +1 -0
  19. package/dist/cli/src/commands/brief.d.ts +46 -0
  20. package/dist/cli/src/commands/brief.js +294 -0
  21. package/dist/cli/src/commands/brief.js.map +1 -0
  22. package/dist/cli/src/commands/check.d.ts +42 -0
  23. package/dist/cli/src/commands/check.js +326 -0
  24. package/dist/cli/src/commands/check.js.map +1 -0
  25. package/dist/cli/src/commands/clean.js +46 -1
  26. package/dist/cli/src/commands/clean.js.map +1 -1
  27. package/dist/cli/src/commands/context.d.ts +1 -0
  28. package/dist/cli/src/commands/context.js +471 -0
  29. package/dist/cli/src/commands/context.js.map +1 -0
  30. package/dist/cli/src/commands/doctor.js +122 -12
  31. package/dist/cli/src/commands/doctor.js.map +1 -1
  32. package/dist/cli/src/commands/draft.d.ts +1 -0
  33. package/dist/cli/src/commands/draft.js +175 -0
  34. package/dist/cli/src/commands/draft.js.map +1 -0
  35. package/dist/cli/src/commands/gitAutomation.d.ts +1 -0
  36. package/dist/cli/src/commands/gitAutomation.js +378 -0
  37. package/dist/cli/src/commands/gitAutomation.js.map +1 -0
  38. package/dist/cli/src/commands/handoff.d.ts +22 -0
  39. package/dist/cli/src/commands/handoff.js +122 -0
  40. package/dist/cli/src/commands/handoff.js.map +1 -0
  41. package/dist/cli/src/commands/init.js +52 -1
  42. package/dist/cli/src/commands/init.js.map +1 -1
  43. package/dist/cli/src/commands/inspect.d.ts +23 -0
  44. package/dist/cli/src/commands/inspect.js +157 -0
  45. package/dist/cli/src/commands/inspect.js.map +1 -0
  46. package/dist/cli/src/commands/register.d.ts +1 -0
  47. package/dist/cli/src/commands/register.js +251 -0
  48. package/dist/cli/src/commands/register.js.map +1 -0
  49. package/dist/cli/src/commands/resume.d.ts +59 -0
  50. package/dist/cli/src/commands/resume.js +280 -0
  51. package/dist/cli/src/commands/resume.js.map +1 -0
  52. package/dist/cli/src/commands/shared.js +6 -2
  53. package/dist/cli/src/commands/shared.js.map +1 -1
  54. package/dist/cli/src/commands/summaries.d.ts +1 -0
  55. package/dist/cli/src/commands/summaries.js +77 -0
  56. package/dist/cli/src/commands/summaries.js.map +1 -0
  57. package/dist/cli/src/commands/summarize.d.ts +1 -0
  58. package/dist/cli/src/commands/summarize.js +316 -0
  59. package/dist/cli/src/commands/summarize.js.map +1 -0
  60. package/dist/cli/src/commands/sync.js +135 -12
  61. package/dist/cli/src/commands/sync.js.map +1 -1
  62. package/dist/cli/src/commands/validate.js +25 -1
  63. package/dist/cli/src/commands/validate.js.map +1 -1
  64. package/dist/cli/src/dev/verifyAgentE2E.d.ts +2 -0
  65. package/dist/cli/src/dev/verifyAgentE2E.js +391 -0
  66. package/dist/cli/src/dev/verifyAgentE2E.js.map +1 -0
  67. package/dist/cli/src/dev/verifyCleanCommand.js +213 -2
  68. package/dist/cli/src/dev/verifyCleanCommand.js.map +1 -1
  69. package/dist/cli/src/dev/verifyRuntimeSurface.js +4940 -54
  70. package/dist/cli/src/dev/verifyRuntimeSurface.js.map +1 -1
  71. package/dist/cli/src/dev/verifyWorkflowE2E.js +477 -45
  72. package/dist/cli/src/dev/verifyWorkflowE2E.js.map +1 -1
  73. package/dist/cli/src/index.js +184 -6
  74. package/dist/cli/src/index.js.map +1 -1
  75. package/dist/cli/src/report.d.ts +26 -0
  76. package/dist/cli/src/report.js +17 -0
  77. package/dist/cli/src/report.js.map +1 -0
  78. package/dist/core/src/artifacts/readiness.d.ts +7 -0
  79. package/dist/core/src/artifacts/readiness.js +240 -0
  80. package/dist/core/src/artifacts/readiness.js.map +1 -0
  81. package/dist/core/src/artifacts/registry.d.ts +9 -2
  82. package/dist/core/src/artifacts/registry.js +687 -60
  83. package/dist/core/src/artifacts/registry.js.map +1 -1
  84. package/dist/core/src/commands/registry.js +1425 -146
  85. package/dist/core/src/commands/registry.js.map +1 -1
  86. package/dist/core/src/contracts/index.d.ts +1 -1
  87. package/dist/core/src/fs/index.d.ts +24 -0
  88. package/dist/core/src/fs/index.js +48 -1
  89. package/dist/core/src/fs/index.js.map +1 -1
  90. package/dist/core/src/git/autonomousSimulator.d.ts +46 -0
  91. package/dist/core/src/git/autonomousSimulator.js +163 -0
  92. package/dist/core/src/git/autonomousSimulator.js.map +1 -0
  93. package/dist/core/src/git/branchIdentity.d.ts +19 -0
  94. package/dist/core/src/git/branchIdentity.js +75 -0
  95. package/dist/core/src/git/branchIdentity.js.map +1 -0
  96. package/dist/core/src/git/draftPrPilot.d.ts +47 -0
  97. package/dist/core/src/git/draftPrPilot.js +196 -0
  98. package/dist/core/src/git/draftPrPilot.js.map +1 -0
  99. package/dist/core/src/git/localEvidenceReader.d.ts +21 -0
  100. package/dist/core/src/git/localEvidenceReader.js +142 -0
  101. package/dist/core/src/git/localEvidenceReader.js.map +1 -0
  102. package/dist/core/src/git/localGitAutomation.d.ts +68 -0
  103. package/dist/core/src/git/localGitAutomation.js +470 -0
  104. package/dist/core/src/git/localGitAutomation.js.map +1 -0
  105. package/dist/core/src/git/mergeReadinessCheckpoint.d.ts +31 -0
  106. package/dist/core/src/git/mergeReadinessCheckpoint.js +110 -0
  107. package/dist/core/src/git/mergeReadinessCheckpoint.js.map +1 -0
  108. package/dist/core/src/git/prReadySummary.d.ts +16 -0
  109. package/dist/core/src/git/prReadySummary.js +144 -0
  110. package/dist/core/src/git/prReadySummary.js.map +1 -0
  111. package/dist/core/src/git/remoteReadonlyPlanner.d.ts +60 -0
  112. package/dist/core/src/git/remoteReadonlyPlanner.js +223 -0
  113. package/dist/core/src/git/remoteReadonlyPlanner.js.map +1 -0
  114. package/dist/core/src/onboarding/agentsGuide.d.ts +32 -0
  115. package/dist/core/src/onboarding/agentsGuide.js +164 -0
  116. package/dist/core/src/onboarding/agentsGuide.js.map +1 -0
  117. package/dist/core/src/validators/validateOpenWorkflow.js +1331 -15
  118. package/dist/core/src/validators/validateOpenWorkflow.js.map +1 -1
  119. package/dist/core/src/validators/validateRepositoryContracts.js +2321 -306
  120. package/dist/core/src/validators/validateRepositoryContracts.js.map +1 -1
  121. package/dist/core/src/workflow/cleanOpenWorkflow.d.ts +2 -0
  122. package/dist/core/src/workflow/cleanOpenWorkflow.js +97 -8
  123. package/dist/core/src/workflow/cleanOpenWorkflow.js.map +1 -1
  124. package/dist/core/src/workflow/doctorOpenWorkflow.d.ts +7 -0
  125. package/dist/core/src/workflow/doctorOpenWorkflow.js +26 -0
  126. package/dist/core/src/workflow/doctorOpenWorkflow.js.map +1 -0
  127. package/dist/core/src/workflow/initOpenWorkflow.d.ts +7 -0
  128. package/dist/core/src/workflow/initOpenWorkflow.js +96 -8
  129. package/dist/core/src/workflow/initOpenWorkflow.js.map +1 -1
  130. package/dist/core/src/workflow/planningQueueResume.d.ts +105 -0
  131. package/dist/core/src/workflow/planningQueueResume.js +596 -0
  132. package/dist/core/src/workflow/planningQueueResume.js.map +1 -0
  133. package/dist/core/src/workflow/readWorkflowConfig.d.ts +6 -0
  134. package/dist/core/src/workflow/readWorkflowConfig.js +28 -0
  135. package/dist/core/src/workflow/readWorkflowConfig.js.map +1 -0
  136. package/dist/core/src/workflow/summaryHealth.d.ts +60 -0
  137. package/dist/core/src/workflow/summaryHealth.js +713 -0
  138. package/dist/core/src/workflow/summaryHealth.js.map +1 -0
  139. package/dist/core/src/workflow/syncOpenWorkflow.d.ts +22 -0
  140. package/dist/core/src/workflow/syncOpenWorkflow.js +235 -0
  141. package/dist/core/src/workflow/syncOpenWorkflow.js.map +1 -0
  142. package/package.json +2 -1
  143. package/references/artifact-authoring-templates.md +14 -12
  144. package/references/artifact-instruction-envelope.md +133 -0
  145. package/references/coder-continuous-growth-loop.md +68 -0
  146. package/references/gh-operation-governance.md +114 -0
  147. package/references/git-automation-governance.md +324 -0
  148. package/references/git-version-control-governance.md +227 -0
  149. package/references/internal-coder-protocol.md +202 -0
  150. package/references/issue-governance.md +115 -0
  151. package/references/planning-artifact-contracts.md +595 -0
  152. package/references/planning-skill-runtime-exposure.md +159 -0
  153. package/references/proto-redesign-artifact-contracts.md +217 -0
  154. package/references/proto2html-artifact-contracts.md +113 -0
  155. package/references/skill-system-lifecycle.md +198 -0
  156. package/references/validation-trust-domains.md +286 -0
  157. package/references/workflow-blueprint-runtime-alignment.md +287 -0
  158. package/schemas/atom-tasks.schema.json +101 -0
  159. package/schemas/candidate-changes.schema.json +323 -0
  160. package/schemas/current-state.schema.json +113 -0
  161. package/schemas/html-prototype.schema.json +288 -0
  162. package/schemas/openworkflow-contract.schema.json +9 -1
  163. package/schemas/proto-prompt-pack.schema.json +1333 -0
  164. package/schemas/prototype-evidence.schema.json +684 -142
  165. package/schemas/selected-change.schema.json +104 -0
  166. package/schemas/validation-target.schema.json +187 -1
  167. package/schemas/validation.schema.json +187 -1
  168. package/schemas/vision-session.schema.json +151 -0
  169. package/skills/analyze-changes/SKILL.md +92 -0
  170. package/skills/analyze-changes/agents/openai.yaml +4 -0
  171. package/skills/analyze-changes/references/analysis-protocol.md +116 -0
  172. package/skills/build-proto-prompt/SKILL.md +125 -0
  173. package/skills/build-proto-prompt/references/output-boundary.md +54 -0
  174. package/skills/build-proto-prompt/references/prompt-pack-compiler-protocol.md +80 -0
  175. package/skills/build-prototype/SKILL.md +162 -38
  176. package/skills/build-prototype/agents/openai.yaml +2 -2
  177. package/skills/build-prototype/references/philosophy-engine.md +61 -0
  178. package/skills/build-prototype/references/strategic-prompt-pack-protocol.md +365 -0
  179. package/skills/build-prototype/references/vision2prompt/01_input_contract.md +84 -0
  180. package/skills/build-prototype/references/vision2prompt/02_vision_decomposition.md +108 -0
  181. package/skills/build-prototype/references/vision2prompt/03_strategy_hypothesis_generation.md +89 -0
  182. package/skills/build-prototype/references/vision2prompt/04_product_system_extraction.md +78 -0
  183. package/skills/build-prototype/references/vision2prompt/05_prototype_prompt_schema.md +189 -0
  184. package/skills/build-prototype/references/vision2prompt/06_output_templates.md +125 -0
  185. package/skills/build-prototype/references/vision2prompt/07_quality_rubric.md +171 -0
  186. package/skills/build-validation/SKILL.md +136 -54
  187. package/skills/build-validation/references/prototype-validation-target-rubric.md +35 -0
  188. package/skills/build-validation/references/return-to-vision-gate.md +32 -0
  189. package/skills/build-vision/SKILL.md +192 -0
  190. package/skills/build-vision/references/proto-readiness-rubric.md +48 -0
  191. package/skills/build-vision/references/vision-interview-protocol.md +48 -0
  192. package/skills/coder/SKILL.md +204 -0
  193. package/skills/decompose-to-changes/SKILL.md +176 -0
  194. package/skills/decompose-to-changes/agents/openai.yaml +4 -0
  195. package/skills/decompose-to-changes/references/decomposition-protocol.md +278 -0
  196. package/skills/prompt2proto/SKILL.md +157 -0
  197. package/skills/prompt2proto/agents/openai.yaml +4 -0
  198. package/skills/prompt2proto/references/00_role_philosophy_engine.md +96 -0
  199. package/skills/prompt2proto/references/01_input_contract.md +53 -0
  200. package/skills/prompt2proto/references/02_prompt_pack_readiness.md +50 -0
  201. package/skills/prompt2proto/references/03_visual_translation_workflow.md +64 -0
  202. package/skills/prompt2proto/references/04_output_contract.md +67 -0
  203. package/skills/prompt2proto/references/05_quality_rubric.md +46 -0
  204. package/skills/proto2html/SKILL.md +136 -0
  205. package/skills/proto2html/agents/openai.yaml +4 -0
  206. package/skills/proto2html/references/proto2html-protocol.md +115 -0
  207. package/skills/run-team/SKILL.md +4 -0
  208. package/skills/select-change/SKILL.md +200 -0
  209. package/skills/select-change/agents/openai.yaml +4 -0
  210. package/skills/select-change/references/selection-protocol.md +281 -0
  211. package/skills/tune-prototype/SKILL.md +121 -0
  212. package/skills/tune-prototype/agents/openai.yaml +4 -0
  213. package/skills/tune-prototype/references/refined-prompt-pack-protocol.md +161 -0
@@ -0,0 +1,196 @@
1
+ import { execFile } from "node:child_process";
2
+ import { mkdir, mkdtemp, readFile, rm, writeFile } from "node:fs/promises";
3
+ import { tmpdir } from "node:os";
4
+ import { dirname, isAbsolute, join, relative, resolve } from "node:path";
5
+ import { createHash } from "node:crypto";
6
+ import { promisify } from "node:util";
7
+ import { planRemoteReadonly } from "./remoteReadonlyPlanner.js";
8
+ import { dumpYaml } from "../contracts/yaml.js";
9
+ const execFileAsync = promisify(execFile);
10
+ export async function pilotDraftPr(options) {
11
+ const remotePlan = await planRemoteReadonly(options);
12
+ const target = {
13
+ remote: remotePlan.targetIdentity.remote,
14
+ base: remotePlan.targetIdentity.base,
15
+ branch: remotePlan.targetIdentity.branch,
16
+ branchMatchesCurrent: remotePlan.targetIdentity.branchMatchesCurrent,
17
+ branchOwnsPlan: remotePlan.targetIdentity.branchOwnsPlan,
18
+ };
19
+ const prSummaryPath = remotePlan.localState.prSummaryPath;
20
+ const prSummary = remotePlan.localState.prSummaryExists ? await readFile(join(options.root, prSummaryPath), "utf8") : "";
21
+ const managedBody = prSummary ? managedPrBody(remotePlan.planId, prSummary) : null;
22
+ const bodyDigest = managedBody ? digest(managedBody) : null;
23
+ const existingPr = remotePlan.prState.items[0];
24
+ const title = options.title ?? `OpenWorkflow ${remotePlan.planId}`;
25
+ const preview = managedBody ? previewCommand(existingPr, target.branch, target.base, title) : null;
26
+ const operationKind = preview ? draftPrOperation(existingPr) : "none";
27
+ const approvalEvidence = options.approvalEvidence?.trim() || null;
28
+ const auditEvidencePath = options.auditEvidencePath ?? defaultAuditEvidencePath(options.queuePath);
29
+ const blockers = [
30
+ ...remotePlan.blockers,
31
+ ...(!remotePlan.remoteState.branchHead ? [`remote branch head is required before draft PR pilot: ${target.remote}/${target.branch}`] : []),
32
+ ...(!managedBody ? [`PR-ready summary body is required: ${prSummaryPath}`] : []),
33
+ ...(!options.dryRun && !options.allowDraftPr ? ["draft PR mutation requires --allow-draft-pr together with --write"] : []),
34
+ ...(!options.dryRun && !approvalEvidence ? ["draft PR mutation requires --approval-evidence naming explicit operation-level approval"] : []),
35
+ ];
36
+ if (blockers.length > 0 || options.dryRun) {
37
+ const outcome = blockers.length > 0 ? "blocked" : options.dryRun ? "preview" : "no-op";
38
+ return {
39
+ ok: blockers.length === 0,
40
+ mode: "draft-pr-pilot",
41
+ mutation_performed: false,
42
+ remotePlanOk: remotePlan.ok,
43
+ blockers,
44
+ warnings: [
45
+ ...remotePlan.warnings,
46
+ ...(options.dryRun ? ["draft-pr pilot dry-run did not create or edit a PR"] : []),
47
+ ],
48
+ target,
49
+ branchIdentity: remotePlan.targetIdentity.branchIdentity,
50
+ bodyDigest,
51
+ managedBodyPreview: managedBody,
52
+ preview,
53
+ operation: {
54
+ kind: operationKind,
55
+ outcome,
56
+ approvalEvidence,
57
+ auditEvidencePath: null,
58
+ targetPr: existingPrTarget(existingPr),
59
+ },
60
+ prUrl: null,
61
+ rollbackPlan: rollbackPlan(existingPr),
62
+ };
63
+ }
64
+ await ensurePathInsideRoot(options.root, auditEvidencePath);
65
+ const prUrl = await runGhPrMutation(options.root, preview, managedBody);
66
+ const operationOutcome = operationKind === "edit" ? "edited" : operationKind === "create" ? "created" : "no-op";
67
+ await writeDraftPrAuditEvidence(options.root, auditEvidencePath, {
68
+ schema_version: "0.1.0",
69
+ contract_type: "audit",
70
+ artifact_type: "draft_pr_operation_evidence",
71
+ plan_id: remotePlan.planId,
72
+ queue_path: options.queuePath,
73
+ operation_kind: operationKind,
74
+ target: {
75
+ remote: target.remote,
76
+ branch: target.branch,
77
+ base: target.base,
78
+ pr_url: prUrl ?? stringValue(existingPr?.url),
79
+ pr_number: existingPr?.number ? String(existingPr.number) : null,
80
+ },
81
+ body_digest: bodyDigest,
82
+ approval_source: approvalEvidence,
83
+ timestamp: new Date().toISOString(),
84
+ result: {
85
+ mutation_performed: true,
86
+ outcome: operationOutcome,
87
+ pr_url: prUrl,
88
+ },
89
+ rollback_guidance: rollbackPlan(existingPr),
90
+ });
91
+ return {
92
+ ok: true,
93
+ mode: "draft-pr-pilot",
94
+ mutation_performed: true,
95
+ remotePlanOk: remotePlan.ok,
96
+ blockers: [],
97
+ warnings: remotePlan.warnings,
98
+ target,
99
+ branchIdentity: remotePlan.targetIdentity.branchIdentity,
100
+ bodyDigest,
101
+ managedBodyPreview: managedBody,
102
+ preview,
103
+ operation: {
104
+ kind: operationKind,
105
+ outcome: operationOutcome,
106
+ approvalEvidence,
107
+ auditEvidencePath,
108
+ targetPr: prUrl ?? existingPrTarget(existingPr),
109
+ },
110
+ prUrl,
111
+ rollbackPlan: rollbackPlan(existingPr),
112
+ };
113
+ }
114
+ function previewCommand(existingPr, branch, base, title) {
115
+ if (existingPr?.number) {
116
+ return {
117
+ command: "gh",
118
+ args: ["pr", "edit", String(existingPr.number), "--title", title, "--body-file", "<managed-body-file>"],
119
+ };
120
+ }
121
+ return {
122
+ command: "gh",
123
+ args: ["pr", "create", "--draft", "--base", base, "--head", branch, "--title", title, "--body-file", "<managed-body-file>"],
124
+ };
125
+ }
126
+ function draftPrOperation(existingPr) {
127
+ return existingPr?.number ? "edit" : "create";
128
+ }
129
+ async function runGhPrMutation(root, preview, managedBody) {
130
+ if (!preview || !managedBody) {
131
+ return null;
132
+ }
133
+ const tempRoot = await mkdtemp(join(tmpdir(), "openworkflow-draft-pr-"));
134
+ const bodyPath = join(tempRoot, "body.md");
135
+ try {
136
+ await writeFile(bodyPath, managedBody, "utf8");
137
+ const args = preview.args.map((arg) => arg === "<managed-body-file>" ? bodyPath : arg);
138
+ const { stdout } = await execFileAsync(preview.command, args, { cwd: root });
139
+ return stdout.trim().split("\n").find((line) => line.startsWith("http")) ?? null;
140
+ }
141
+ finally {
142
+ await rm(tempRoot, { recursive: true, force: true });
143
+ }
144
+ }
145
+ async function writeDraftPrAuditEvidence(root, path, evidence) {
146
+ const outputPath = await ensurePathInsideRoot(root, path);
147
+ await mkdir(dirname(outputPath), { recursive: true });
148
+ await writeFile(outputPath, dumpYaml(evidence), "utf8");
149
+ }
150
+ async function ensurePathInsideRoot(root, path) {
151
+ const rootPath = resolve(root);
152
+ const outputPath = resolve(rootPath, path);
153
+ const relativePath = relative(rootPath, outputPath);
154
+ if (!relativePath || relativePath.startsWith("..") || isAbsolute(relativePath)) {
155
+ throw new Error(`draft PR audit evidence path escapes root: ${path}`);
156
+ }
157
+ await mkdir(dirname(outputPath), { recursive: true });
158
+ return outputPath;
159
+ }
160
+ function managedPrBody(planId, summary) {
161
+ const content = summary.trim();
162
+ const contentDigest = digest(content);
163
+ return [
164
+ `<!-- openworkflow:managed:start plan=${planId} digest=${contentDigest} -->`,
165
+ content,
166
+ "<!-- openworkflow:managed:end -->",
167
+ "",
168
+ ].join("\n");
169
+ }
170
+ function digest(content) {
171
+ return createHash("sha256").update(content).digest("hex");
172
+ }
173
+ function defaultAuditEvidencePath(queuePath) {
174
+ const parts = queuePath.split("/");
175
+ parts[parts.length - 1] = "DRAFT_PR_OPERATION_EVIDENCE.yaml";
176
+ return parts.join("/");
177
+ }
178
+ function existingPrTarget(existingPr) {
179
+ return stringValue(existingPr?.url) ?? (existingPr?.number ? `PR #${String(existingPr.number)}` : null);
180
+ }
181
+ function stringValue(value) {
182
+ return typeof value === "string" && value.length > 0 ? value : null;
183
+ }
184
+ function rollbackPlan(existingPr) {
185
+ if (existingPr?.number) {
186
+ return [
187
+ `restore the previous managed PR body section for PR #${String(existingPr.number)}`,
188
+ "if restore is unsafe, leave a follow-up comment and stop for human review",
189
+ ];
190
+ }
191
+ return [
192
+ "close the draft PR if it was created with the wrong branch, base, or body",
193
+ "do not merge or mark ready for review from the pilot",
194
+ ];
195
+ }
196
+ //# sourceMappingURL=draftPrPilot.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"draftPrPilot.js","sourceRoot":"","sources":["../../../../packages/core/src/git/draftPrPilot.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC3E,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACzE,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAEtC,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAEhD,MAAM,aAAa,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAC;AAiD1C,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,OAA4B;IAC7D,MAAM,UAAU,GAAG,MAAM,kBAAkB,CAAC,OAAO,CAAC,CAAC;IACrD,MAAM,MAAM,GAAG;QACb,MAAM,EAAE,UAAU,CAAC,cAAc,CAAC,MAAM;QACxC,IAAI,EAAE,UAAU,CAAC,cAAc,CAAC,IAAI;QACpC,MAAM,EAAE,UAAU,CAAC,cAAc,CAAC,MAAM;QACxC,oBAAoB,EAAE,UAAU,CAAC,cAAc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C,CAAC;AAC5D,CAAC;AAED,SAAS,wBAAwB,CAAC,SAAiB;IACjD,MAAM,KAAK,GAAG,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACnC,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,GAAG,kCAAkC,CAAC;IAC7D,OAAO,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACzB,CAAC;AAED,SAAS,gBAAgB,CAAC,UAA+C;IACvE,OAAO,WAAW,CAAC,UAAU,EAAE,GAAG,CAAC,IAAI,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC,CAAC,OAAO,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;AAC1G,CAAC;AAED,SAAS,WAAW,CAAC,KAAc;IACjC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC;AACtE,CAAC;AAED,SAAS,YAAY,CAAC,UAA+C;IACnE,IAAI,UAAU,EAAE,MAAM,EAAE,CAAC;QACvB,OAAO;YACL,wDAAwD,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE;YACnF,2EAA2E;SAC5E,CAAC;IACJ,CAAC;IACD,OAAO;QACL,2EAA2E;QAC3E,sDAAsD;KACvD,CAAC;AACJ,CAAC"}
@@ -0,0 +1,21 @@
1
+ export interface LocalGitCommitEvidence {
2
+ candidate_id: string;
3
+ selected_change_id: string | null;
4
+ hash: string;
5
+ role: "legacy" | "primary" | "evidence" | "head";
6
+ evidence_path: string | null;
7
+ source: "completion_evidence" | "local_commit_evidence";
8
+ }
9
+ export interface LocalGitValidationEvidence {
10
+ candidate_id: string;
11
+ selected_change_id: string | null;
12
+ value: string;
13
+ evidence_path: string | null;
14
+ source: "queue_validation" | "completion_evidence" | "local_commit_evidence";
15
+ }
16
+ export interface LocalGitEvidenceReport {
17
+ commitEvidence: LocalGitCommitEvidence[];
18
+ validationEvidence: LocalGitValidationEvidence[];
19
+ warnings: string[];
20
+ }
21
+ export declare function readLocalGitEvidence(root: string, queue: Record<string, unknown>): Promise<LocalGitEvidenceReport>;
@@ -0,0 +1,142 @@
1
+ import { readFile } from "node:fs/promises";
2
+ import { parseYaml } from "../contracts/yaml.js";
3
+ import { resolveLocalReference } from "../fs/index.js";
4
+ export async function readLocalGitEvidence(root, queue) {
5
+ const commitEvidence = [];
6
+ const validationEvidence = [];
7
+ const warnings = [];
8
+ const seenCommits = new Set();
9
+ const seenValidation = new Set();
10
+ const addCommit = (item) => {
11
+ const key = `${item.candidate_id}\0${item.selected_change_id ?? ""}\0${item.hash}\0${item.role}\0${item.evidence_path ?? ""}`;
12
+ if (!seenCommits.has(key)) {
13
+ seenCommits.add(key);
14
+ commitEvidence.push(item);
15
+ }
16
+ };
17
+ const addValidation = (item) => {
18
+ const key = `${item.candidate_id}\0${item.selected_change_id ?? ""}\0${item.value}\0${item.evidence_path ?? ""}`;
19
+ if (!seenValidation.has(key)) {
20
+ seenValidation.add(key);
21
+ validationEvidence.push(item);
22
+ }
23
+ };
24
+ for (const item of array(record(queue.validation).commands_run)) {
25
+ const value = String(item).trim();
26
+ if (value.length > 0) {
27
+ addValidation({
28
+ candidate_id: "queue",
29
+ selected_change_id: null,
30
+ value,
31
+ evidence_path: null,
32
+ source: "queue_validation",
33
+ });
34
+ }
35
+ }
36
+ for (const candidate of array(queue.changes).map(record)) {
37
+ const candidateId = stringValue(candidate.id) ?? "unknown";
38
+ const selectedChangeId = stringValue(record(candidate.selection).selected_change_id);
39
+ for (const rawEvidence of array(record(candidate.completion).evidence).map(String)) {
40
+ const evidence = rawEvidence.trim();
41
+ if (evidence.startsWith("commit:")) {
42
+ const hash = evidence.replace(/^commit:\s*/, "").trim();
43
+ if (hash.length > 0) {
44
+ addCommit({
45
+ candidate_id: candidateId,
46
+ selected_change_id: selectedChangeId,
47
+ hash,
48
+ role: "legacy",
49
+ evidence_path: null,
50
+ source: "completion_evidence",
51
+ });
52
+ }
53
+ continue;
54
+ }
55
+ if (evidence.startsWith("validation:")) {
56
+ const value = evidence.replace(/^validation:\s*/, "").trim();
57
+ if (value.length > 0) {
58
+ addValidation({
59
+ candidate_id: candidateId,
60
+ selected_change_id: selectedChangeId,
61
+ value,
62
+ evidence_path: null,
63
+ source: "completion_evidence",
64
+ });
65
+ }
66
+ continue;
67
+ }
68
+ if (!evidence.endsWith("LOCAL_COMMIT_EVIDENCE.yaml")) {
69
+ continue;
70
+ }
71
+ const localEvidence = await readLocalCommitEvidence(root, evidence);
72
+ warnings.push(...localEvidence.warnings.map((warning) => `${candidateId}: ${warning}`));
73
+ if (!localEvidence.record) {
74
+ continue;
75
+ }
76
+ const evidenceSelectedChangeId = stringValue(localEvidence.record.selected_change_id) ?? selectedChangeId;
77
+ addCommitFields(addCommit, candidateId, evidenceSelectedChangeId, evidence, localEvidence.record);
78
+ for (const item of array(localEvidence.record.validation_evidence)) {
79
+ const value = String(item).trim();
80
+ if (value.length > 0) {
81
+ addValidation({
82
+ candidate_id: candidateId,
83
+ selected_change_id: evidenceSelectedChangeId,
84
+ value,
85
+ evidence_path: evidence,
86
+ source: "local_commit_evidence",
87
+ });
88
+ }
89
+ }
90
+ }
91
+ }
92
+ return { commitEvidence, validationEvidence, warnings };
93
+ }
94
+ async function readLocalCommitEvidence(root, evidencePath) {
95
+ const resolution = resolveLocalReference(root, evidencePath);
96
+ if (resolution.kind !== "local") {
97
+ return { record: null, warnings: [`commit evidence path is not a repo-local file: ${evidencePath}`] };
98
+ }
99
+ if (!resolution.exists) {
100
+ return { record: null, warnings: [`commit evidence path does not exist: ${evidencePath}`] };
101
+ }
102
+ try {
103
+ const parsed = record(parseYaml(await readFile(resolution.path, "utf8")));
104
+ if (stringValue(parsed.planning_artifact_type) !== "implementation_evidence") {
105
+ return { record: null, warnings: [`commit evidence path is not implementation_evidence: ${evidencePath}`] };
106
+ }
107
+ return { record: parsed, warnings: [] };
108
+ }
109
+ catch (error) {
110
+ return { record: null, warnings: [`could not read commit evidence ${evidencePath}: ${error instanceof Error ? error.message : String(error)}`] };
111
+ }
112
+ }
113
+ function addCommitFields(addCommit, candidateId, selectedChangeId, evidencePath, evidence) {
114
+ const fields = [
115
+ { key: "primary_commit", role: "primary" },
116
+ { key: "evidence_commit", role: "evidence" },
117
+ { key: "head_commit", role: "head" },
118
+ ];
119
+ for (const field of fields) {
120
+ const hash = stringValue(evidence[field.key]);
121
+ if (hash) {
122
+ addCommit({
123
+ candidate_id: candidateId,
124
+ selected_change_id: selectedChangeId,
125
+ hash,
126
+ role: field.role,
127
+ evidence_path: evidencePath,
128
+ source: "local_commit_evidence",
129
+ });
130
+ }
131
+ }
132
+ }
133
+ function record(value) {
134
+ return value && typeof value === "object" && !Array.isArray(value) ? value : {};
135
+ }
136
+ function array(value) {
137
+ return Array.isArray(value) ? value : [];
138
+ }
139
+ function stringValue(value) {
140
+ return typeof value === "string" && value.length > 0 ? value : null;
141
+ }
142
+ //# sourceMappingURL=localEvidenceReader.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"localEvidenceReader.js","sourceRoot":"","sources":["../../../../packages/core/src/git/localEvidenceReader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AAyBvD,MAAM,CAAC,KAAK,UAAU,oBAAoB,CAAC,IAAY,EAAE,KAA8B;IACrF,MAAM,cAAc,GAA6B,EAAE,CAAC;IACpD,MAAM,kBAAkB,GAAiC,EAAE,CAAC;IAC5D,MAAM,QAAQ,GAAa,EAAE,CAAC;IAC9B,MAAM,WAAW,GAAG,IAAI,GAAG,EAAU,CAAC;IACtC,MAAM,cAAc,GAAG,IAAI,GAAG,EAAU,CAAC;IAEzC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AAE,IAAI,EAAE,SAAS,EAAE;QAC1C,EAAE,GAAG,EAAE,iBAAiB,EAAE,IAAI,EAAE,UAAU,EAAE;QAC5C,EAAE,GAAG,EAAE,aAAa,EAAE,IAAI,EAAE,MAAM,EAAE;KACrC,CAAC;IACF,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QAC3B,MAAM,IAAI,GAAG,WAAW,CAAC,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC;QAC9C,IAAI,IAAI,EAAE,CAAC;YACT,SAAS,CAAC;gBACR,YAAY,EAAE,WAAW;gBACzB,kBAAkB,EAAE,gBAAgB;gBACpC,IAAI;gBACJ,IAAI,EAAE,KAAK,CAAC,IAAI;gBAChB,aAAa,EAAE,YAAY;gBAC3B,MAAM,EAAE,uBAAuB;aAChC,CAAC,CAAC;QACL,CAAC;IACH,CAAC;AACH,CAAC;AAED,SAAS,MAAM,CAAC,KAAc;IAC5B,OAAO,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAgC,CAAC,CAAC,CAAC,EAAE,CAAC;AAC7G,CAAC;AAED,SAAS,KAAK,CAAC,KAAc;IAC3B,OAAO,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;AAC3C,CAAC;AAED,SAAS,WAAW,CAAC,KAAc;IACjC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC;AACtE,CAAC"}
@@ -0,0 +1,68 @@
1
+ import { type BranchIdentityAssessment, type BranchIdentityException } from "./branchIdentity.js";
2
+ export type LocalFeatBranchAction = "already_on_branch" | "checkout_existing_branch" | "create_branch";
3
+ export type SelectedChangeCommitAction = "commit_selected_change";
4
+ export interface LocalGitCommandPreview {
5
+ command: "git";
6
+ args: string[];
7
+ }
8
+ export interface EnsureLocalFeatBranchOptions {
9
+ root: string;
10
+ planId?: string;
11
+ branchBoundary: string;
12
+ dryRun?: boolean;
13
+ branchIdentityException?: BranchIdentityException | null;
14
+ }
15
+ export interface EnsureLocalFeatBranchResult {
16
+ ok: boolean;
17
+ dryRun: boolean;
18
+ branchBoundary: string;
19
+ currentBranch: string | null;
20
+ branchMatchesCurrent: boolean | null;
21
+ branchOwnsPlan: boolean | null;
22
+ branchIdentity: BranchIdentityAssessment | null;
23
+ dirtyPaths: string[];
24
+ action: LocalFeatBranchAction | null;
25
+ preview: LocalGitCommandPreview | null;
26
+ errors: string[];
27
+ warnings: string[];
28
+ }
29
+ export interface CommitSelectedChangeOptions {
30
+ root: string;
31
+ planId: string;
32
+ candidateId: string;
33
+ selectedChangeId: string;
34
+ branchBoundary?: string;
35
+ allowedPaths: string[];
36
+ validationEvidence: string[];
37
+ commitMessage: string;
38
+ dryRun?: boolean;
39
+ evidencePath?: string;
40
+ commitEvidence?: boolean;
41
+ requireEvidenceBackfill?: boolean;
42
+ queuePath?: string;
43
+ selectedChangePath?: string;
44
+ branchIdentityException?: BranchIdentityException | null;
45
+ }
46
+ export interface CommitSelectedChangeResult {
47
+ ok: boolean;
48
+ dryRun: boolean;
49
+ planId: string;
50
+ candidateId: string;
51
+ selectedChangeId: string;
52
+ currentBranch: string | null;
53
+ dirtyPaths: string[];
54
+ includedPaths: string[];
55
+ unrelatedDirtyPaths: string[];
56
+ validationEvidence: string[];
57
+ action: SelectedChangeCommitAction | null;
58
+ preview: LocalGitCommandPreview | null;
59
+ primaryCommit: string | null;
60
+ evidenceCommit: string | null;
61
+ headCommit: string | null;
62
+ evidencePath: string | null;
63
+ evidenceBackfilledPaths: string[];
64
+ errors: string[];
65
+ warnings: string[];
66
+ }
67
+ export declare function ensureLocalFeatBranch(options: EnsureLocalFeatBranchOptions): Promise<EnsureLocalFeatBranchResult>;
68
+ export declare function commitSelectedChange(options: CommitSelectedChangeOptions): Promise<CommitSelectedChangeResult>;