oxe-cc 0.9.3 → 1.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (319) hide show
  1. package/.cursor/commands/oxe-ask.md +1 -1
  2. package/.cursor/commands/oxe-capabilities.md +1 -1
  3. package/.cursor/commands/oxe-checkpoint.md +1 -1
  4. package/.cursor/commands/oxe-compact.md +1 -1
  5. package/.cursor/commands/oxe-dashboard.md +1 -1
  6. package/.cursor/commands/oxe-debug.md +1 -1
  7. package/.cursor/commands/oxe-discuss.md +1 -1
  8. package/.cursor/commands/oxe-execute.md +2 -2
  9. package/.cursor/commands/oxe-forensics.md +1 -1
  10. package/.cursor/commands/oxe-help.md +1 -1
  11. package/.cursor/commands/oxe-loop.md +1 -1
  12. package/.cursor/commands/oxe-milestone.md +1 -1
  13. package/.cursor/commands/oxe-next.md +1 -1
  14. package/.cursor/commands/oxe-obs.md +1 -1
  15. package/.cursor/commands/oxe-plan-agent.md +1 -1
  16. package/.cursor/commands/oxe-plan.md +1 -1
  17. package/.cursor/commands/oxe-project.md +1 -1
  18. package/.cursor/commands/oxe-quick.md +1 -1
  19. package/.cursor/commands/oxe-research.md +1 -1
  20. package/.cursor/commands/oxe-retro.md +1 -1
  21. package/.cursor/commands/oxe-review-pr.md +1 -1
  22. package/.cursor/commands/oxe-route.md +1 -1
  23. package/.cursor/commands/oxe-scan.md +1 -1
  24. package/.cursor/commands/oxe-security.md +1 -1
  25. package/.cursor/commands/oxe-session.md +2 -2
  26. package/.cursor/commands/oxe-ship.md +45 -0
  27. package/.cursor/commands/oxe-skill.md +1 -1
  28. package/.cursor/commands/oxe-spec.md +1 -1
  29. package/.cursor/commands/oxe-ui-review.md +1 -1
  30. package/.cursor/commands/oxe-ui-spec.md +1 -1
  31. package/.cursor/commands/oxe-update.md +1 -1
  32. package/.cursor/commands/oxe-validate-gaps.md +1 -1
  33. package/.cursor/commands/oxe-verify.md +1 -1
  34. package/.cursor/commands/oxe-workstream.md +1 -1
  35. package/.cursor/commands/oxe.md +4 -4
  36. package/.github/copilot-instructions.md +91 -1
  37. package/.github/prompts/oxe-ask.prompt.md +1 -1
  38. package/.github/prompts/oxe-capabilities.prompt.md +1 -1
  39. package/.github/prompts/oxe-checkpoint.prompt.md +1 -1
  40. package/.github/prompts/oxe-compact.prompt.md +1 -1
  41. package/.github/prompts/oxe-dashboard.prompt.md +1 -1
  42. package/.github/prompts/oxe-debug.prompt.md +1 -1
  43. package/.github/prompts/oxe-discuss.prompt.md +1 -1
  44. package/.github/prompts/oxe-execute.prompt.md +2 -2
  45. package/.github/prompts/oxe-forensics.prompt.md +1 -1
  46. package/.github/prompts/oxe-help.prompt.md +1 -1
  47. package/.github/prompts/oxe-loop.prompt.md +1 -1
  48. package/.github/prompts/oxe-milestone.prompt.md +1 -1
  49. package/.github/prompts/oxe-next.prompt.md +1 -1
  50. package/.github/prompts/oxe-obs.prompt.md +1 -1
  51. package/.github/prompts/oxe-plan-agent.prompt.md +1 -1
  52. package/.github/prompts/oxe-plan.prompt.md +1 -1
  53. package/.github/prompts/oxe-project.prompt.md +1 -1
  54. package/.github/prompts/oxe-quick.prompt.md +1 -1
  55. package/.github/prompts/oxe-research.prompt.md +1 -1
  56. package/.github/prompts/oxe-retro.prompt.md +1 -1
  57. package/.github/prompts/oxe-review-pr.prompt.md +1 -1
  58. package/.github/prompts/oxe-route.prompt.md +1 -1
  59. package/.github/prompts/oxe-scan.prompt.md +1 -1
  60. package/.github/prompts/oxe-security.prompt.md +1 -1
  61. package/.github/prompts/oxe-session.prompt.md +2 -2
  62. package/.github/prompts/oxe-ship.prompt.md +45 -0
  63. package/.github/prompts/oxe-skill.prompt.md +1 -1
  64. package/.github/prompts/oxe-spec.prompt.md +1 -1
  65. package/.github/prompts/oxe-ui-review.prompt.md +1 -1
  66. package/.github/prompts/oxe-ui-spec.prompt.md +1 -1
  67. package/.github/prompts/oxe-update.prompt.md +1 -1
  68. package/.github/prompts/oxe-validate-gaps.prompt.md +1 -1
  69. package/.github/prompts/oxe-verify.prompt.md +1 -1
  70. package/.github/prompts/oxe-workstream.prompt.md +1 -1
  71. package/.github/prompts/oxe.prompt.md +3 -3
  72. package/AGENTS.md +43 -28
  73. package/CHANGELOG.md +158 -0
  74. package/README.md +72 -50
  75. package/bin/banner.txt +1 -1
  76. package/bin/lib/oxe-dashboard.cjs +9 -7
  77. package/bin/lib/oxe-operational.cjs +569 -4
  78. package/bin/lib/oxe-project-health.cjs +1 -1
  79. package/bin/oxe-cc.js +141 -57
  80. package/commands/oxe/ask.md +5 -1
  81. package/commands/oxe/checkpoint.md +1 -1
  82. package/commands/oxe/compact.md +1 -1
  83. package/commands/oxe/debug.md +1 -1
  84. package/commands/oxe/execute.md +2 -2
  85. package/commands/oxe/forensics.md +1 -1
  86. package/commands/oxe/loop.md +1 -1
  87. package/commands/oxe/milestone.md +1 -1
  88. package/commands/oxe/next.md +1 -1
  89. package/commands/oxe/obs.md +1 -1
  90. package/commands/oxe/oxe.md +3 -3
  91. package/commands/oxe/project.md +1 -1
  92. package/commands/oxe/research.md +1 -1
  93. package/commands/oxe/retro.md +1 -1
  94. package/commands/oxe/review-pr.md +1 -1
  95. package/commands/oxe/route.md +1 -1
  96. package/commands/oxe/scan.md +1 -1
  97. package/commands/oxe/security.md +1 -1
  98. package/commands/oxe/session.md +2 -2
  99. package/commands/oxe/ship.md +49 -0
  100. package/commands/oxe/spec.md +2 -2
  101. package/commands/oxe/ui-review.md +1 -1
  102. package/commands/oxe/ui-spec.md +1 -1
  103. package/commands/oxe/validate-gaps.md +1 -1
  104. package/commands/oxe/verify.md +2 -2
  105. package/commands/oxe/workstream.md +1 -1
  106. package/lib/runtime/audit/audit-trail.d.ts +71 -0
  107. package/lib/runtime/audit/audit-trail.js +154 -0
  108. package/lib/runtime/audit/index.d.ts +2 -0
  109. package/lib/runtime/audit/index.js +18 -0
  110. package/lib/runtime/audit/policy-pack.d.ts +15 -0
  111. package/lib/runtime/audit/policy-pack.js +57 -0
  112. package/lib/runtime/compiler/graph-compiler.d.ts +83 -0
  113. package/lib/runtime/compiler/graph-compiler.js +135 -0
  114. package/lib/runtime/compiler/index.d.ts +1 -0
  115. package/lib/runtime/compiler/index.js +17 -0
  116. package/lib/runtime/context/context-pack-builder.d.ts +51 -0
  117. package/lib/runtime/context/context-pack-builder.js +178 -0
  118. package/lib/runtime/context/context-pack-store.d.ts +38 -0
  119. package/lib/runtime/context/context-pack-store.js +142 -0
  120. package/lib/runtime/context/context-profiles.d.ts +11 -0
  121. package/lib/runtime/context/context-profiles.js +51 -0
  122. package/lib/runtime/context/index.d.ts +3 -0
  123. package/lib/runtime/context/index.js +19 -0
  124. package/lib/runtime/decision/decision-engine.d.ts +43 -0
  125. package/lib/runtime/decision/decision-engine.js +127 -0
  126. package/lib/runtime/decision/decision-memo.d.ts +53 -0
  127. package/lib/runtime/decision/decision-memo.js +173 -0
  128. package/lib/runtime/decision/index.d.ts +2 -0
  129. package/lib/runtime/decision/index.js +18 -0
  130. package/lib/runtime/delivery/branch-manager.d.ts +19 -0
  131. package/lib/runtime/delivery/branch-manager.js +78 -0
  132. package/lib/runtime/delivery/ci-checks.d.ts +34 -0
  133. package/lib/runtime/delivery/ci-checks.js +209 -0
  134. package/lib/runtime/delivery/index.d.ts +4 -0
  135. package/lib/runtime/delivery/index.js +20 -0
  136. package/lib/runtime/delivery/pr-manager.d.ts +30 -0
  137. package/lib/runtime/delivery/pr-manager.js +82 -0
  138. package/lib/runtime/delivery/promotion-pipeline.d.ts +39 -0
  139. package/lib/runtime/delivery/promotion-pipeline.js +127 -0
  140. package/lib/runtime/events/bus.d.ts +9 -0
  141. package/lib/runtime/events/bus.js +63 -0
  142. package/lib/runtime/events/catalog.d.ts +3 -0
  143. package/lib/runtime/events/catalog.js +30 -0
  144. package/lib/runtime/events/envelope.d.ts +13 -0
  145. package/lib/runtime/events/envelope.js +2 -0
  146. package/lib/runtime/events/index.d.ts +3 -0
  147. package/lib/runtime/events/index.js +19 -0
  148. package/lib/runtime/evidence/evidence-store.d.ts +22 -0
  149. package/lib/runtime/evidence/evidence-store.js +106 -0
  150. package/lib/runtime/evidence/index.d.ts +1 -0
  151. package/lib/runtime/evidence/index.js +17 -0
  152. package/lib/runtime/gate/gate-manager.d.ts +39 -0
  153. package/lib/runtime/gate/gate-manager.js +104 -0
  154. package/lib/runtime/gate/index.d.ts +1 -0
  155. package/lib/runtime/gate/index.js +17 -0
  156. package/lib/runtime/index.d.ts +19 -0
  157. package/lib/runtime/index.js +44 -0
  158. package/lib/runtime/models/attempt.d.ts +12 -0
  159. package/lib/runtime/models/attempt.js +2 -0
  160. package/lib/runtime/models/evidence.d.ts +9 -0
  161. package/lib/runtime/models/evidence.js +2 -0
  162. package/lib/runtime/models/gate-decision.d.ts +10 -0
  163. package/lib/runtime/models/gate-decision.js +2 -0
  164. package/lib/runtime/models/index.d.ts +8 -0
  165. package/lib/runtime/models/index.js +24 -0
  166. package/lib/runtime/models/run.d.ts +13 -0
  167. package/lib/runtime/models/run.js +2 -0
  168. package/lib/runtime/models/session.d.ts +10 -0
  169. package/lib/runtime/models/session.js +2 -0
  170. package/lib/runtime/models/verification-result.d.ts +9 -0
  171. package/lib/runtime/models/verification-result.js +2 -0
  172. package/lib/runtime/models/work-item.d.ts +15 -0
  173. package/lib/runtime/models/work-item.js +2 -0
  174. package/lib/runtime/models/workspace.d.ts +25 -0
  175. package/lib/runtime/models/workspace.js +2 -0
  176. package/lib/runtime/plugins/capability-matrix.d.ts +20 -0
  177. package/lib/runtime/plugins/capability-matrix.js +59 -0
  178. package/lib/runtime/plugins/index.d.ts +4 -0
  179. package/lib/runtime/plugins/index.js +20 -0
  180. package/lib/runtime/plugins/plugin-abi.d.ts +76 -0
  181. package/lib/runtime/plugins/plugin-abi.js +2 -0
  182. package/lib/runtime/plugins/plugin-manifest.d.ts +22 -0
  183. package/lib/runtime/plugins/plugin-manifest.js +91 -0
  184. package/lib/runtime/plugins/plugin-registry.d.ts +21 -0
  185. package/lib/runtime/plugins/plugin-registry.js +119 -0
  186. package/lib/runtime/policy/index.d.ts +1 -0
  187. package/lib/runtime/policy/index.js +17 -0
  188. package/lib/runtime/policy/policy-engine.d.ts +67 -0
  189. package/lib/runtime/policy/policy-engine.js +171 -0
  190. package/lib/runtime/projection/index.d.ts +1 -0
  191. package/lib/runtime/projection/index.js +17 -0
  192. package/lib/runtime/projection/projection-engine.d.ts +11 -0
  193. package/lib/runtime/projection/projection-engine.js +218 -0
  194. package/lib/runtime/reducers/debug-reducer.d.ts +10 -0
  195. package/lib/runtime/reducers/debug-reducer.js +30 -0
  196. package/lib/runtime/reducers/index.d.ts +2 -0
  197. package/lib/runtime/reducers/index.js +18 -0
  198. package/lib/runtime/reducers/run-state-reducer.d.ts +46 -0
  199. package/lib/runtime/reducers/run-state-reducer.js +226 -0
  200. package/lib/runtime/scheduler/agent-registry.d.ts +44 -0
  201. package/lib/runtime/scheduler/agent-registry.js +96 -0
  202. package/lib/runtime/scheduler/agent-roles.d.ts +54 -0
  203. package/lib/runtime/scheduler/agent-roles.js +62 -0
  204. package/lib/runtime/scheduler/index.d.ts +4 -0
  205. package/lib/runtime/scheduler/index.js +20 -0
  206. package/lib/runtime/scheduler/multi-agent-coordinator.d.ts +36 -0
  207. package/lib/runtime/scheduler/multi-agent-coordinator.js +253 -0
  208. package/lib/runtime/scheduler/run-journal.d.ts +18 -0
  209. package/lib/runtime/scheduler/run-journal.js +54 -0
  210. package/lib/runtime/scheduler/scheduler.d.ts +49 -0
  211. package/lib/runtime/scheduler/scheduler.js +324 -0
  212. package/lib/runtime/verification/index.d.ts +2 -0
  213. package/lib/runtime/verification/index.js +18 -0
  214. package/lib/runtime/verification/verification-compiler.d.ts +56 -0
  215. package/lib/runtime/verification/verification-compiler.js +147 -0
  216. package/lib/runtime/verification/verification-manifest.d.ts +58 -0
  217. package/lib/runtime/verification/verification-manifest.js +129 -0
  218. package/lib/runtime/workspace/index.d.ts +5 -0
  219. package/lib/runtime/workspace/index.js +24 -0
  220. package/lib/runtime/workspace/strategies/ephemeral-container.d.ts +22 -0
  221. package/lib/runtime/workspace/strategies/ephemeral-container.js +109 -0
  222. package/lib/runtime/workspace/strategies/git-worktree.d.ts +12 -0
  223. package/lib/runtime/workspace/strategies/git-worktree.js +79 -0
  224. package/lib/runtime/workspace/strategies/inplace.d.ts +10 -0
  225. package/lib/runtime/workspace/strategies/inplace.js +37 -0
  226. package/lib/runtime/workspace/workspace-manager.d.ts +13 -0
  227. package/lib/runtime/workspace/workspace-manager.js +2 -0
  228. package/lib/sdk/index.cjs +24 -7
  229. package/lib/sdk/index.d.ts +17 -7
  230. package/oxe/workflows/ask.md +4 -0
  231. package/oxe/workflows/checkpoint.md +14 -10
  232. package/oxe/workflows/debug.md +19 -15
  233. package/oxe/workflows/execute.md +30 -2
  234. package/oxe/workflows/forensics.md +13 -9
  235. package/oxe/workflows/help.md +97 -49
  236. package/oxe/workflows/loop.md +17 -13
  237. package/oxe/workflows/obs.md +4 -0
  238. package/oxe/workflows/oxe.md +64 -31
  239. package/oxe/workflows/project.md +6 -1
  240. package/oxe/workflows/references/workflow-runtime-contracts.json +23 -0
  241. package/oxe/workflows/research.md +32 -28
  242. package/oxe/workflows/retro.md +4 -0
  243. package/oxe/workflows/review-pr.md +15 -11
  244. package/oxe/workflows/scan.md +4 -0
  245. package/oxe/workflows/security.md +14 -10
  246. package/oxe/workflows/session.md +17 -1
  247. package/oxe/workflows/ship.md +142 -0
  248. package/oxe/workflows/spec.md +15 -0
  249. package/oxe/workflows/ui-review.md +20 -16
  250. package/oxe/workflows/ui-spec.md +7 -3
  251. package/oxe/workflows/validate-gaps.md +13 -9
  252. package/oxe/workflows/verify.md +42 -3
  253. package/package.json +9 -3
  254. package/packages/runtime/package.json +17 -0
  255. package/packages/runtime/src/audit/audit-trail.ts +243 -0
  256. package/packages/runtime/src/audit/index.ts +2 -0
  257. package/packages/runtime/src/audit/policy-pack.ts +62 -0
  258. package/packages/runtime/src/compiler/graph-compiler.ts +245 -0
  259. package/packages/runtime/src/compiler/index.ts +1 -0
  260. package/packages/runtime/src/context/context-pack-builder.ts +259 -0
  261. package/packages/runtime/src/context/context-pack-store.ts +197 -0
  262. package/packages/runtime/src/context/context-profiles.ts +60 -0
  263. package/packages/runtime/src/context/index.ts +3 -0
  264. package/packages/runtime/src/decision/decision-engine.ts +174 -0
  265. package/packages/runtime/src/decision/decision-memo.ts +211 -0
  266. package/packages/runtime/src/decision/index.ts +2 -0
  267. package/packages/runtime/src/delivery/branch-manager.ts +84 -0
  268. package/packages/runtime/src/delivery/ci-checks.ts +252 -0
  269. package/packages/runtime/src/delivery/index.ts +4 -0
  270. package/packages/runtime/src/delivery/pr-manager.ts +112 -0
  271. package/packages/runtime/src/delivery/promotion-pipeline.ts +180 -0
  272. package/packages/runtime/src/events/bus.ts +92 -0
  273. package/packages/runtime/src/events/catalog.ts +29 -0
  274. package/packages/runtime/src/events/envelope.ts +14 -0
  275. package/packages/runtime/src/events/index.ts +3 -0
  276. package/packages/runtime/src/evidence/evidence-store.ts +130 -0
  277. package/packages/runtime/src/evidence/index.ts +1 -0
  278. package/packages/runtime/src/gate/gate-manager.ts +137 -0
  279. package/packages/runtime/src/gate/index.ts +1 -0
  280. package/packages/runtime/src/index.ts +37 -0
  281. package/packages/runtime/src/models/attempt.ts +19 -0
  282. package/packages/runtime/src/models/evidence.ts +21 -0
  283. package/packages/runtime/src/models/gate-decision.ts +21 -0
  284. package/packages/runtime/src/models/index.ts +8 -0
  285. package/packages/runtime/src/models/run.ts +24 -0
  286. package/packages/runtime/src/models/session.ts +11 -0
  287. package/packages/runtime/src/models/verification-result.ts +10 -0
  288. package/packages/runtime/src/models/work-item.ts +25 -0
  289. package/packages/runtime/src/models/workspace.ts +28 -0
  290. package/packages/runtime/src/plugins/capability-matrix.ts +83 -0
  291. package/packages/runtime/src/plugins/index.ts +4 -0
  292. package/packages/runtime/src/plugins/plugin-abi.ts +95 -0
  293. package/packages/runtime/src/plugins/plugin-manifest.ts +113 -0
  294. package/packages/runtime/src/plugins/plugin-registry.ts +124 -0
  295. package/packages/runtime/src/policy/index.ts +1 -0
  296. package/packages/runtime/src/policy/policy-engine.ts +244 -0
  297. package/packages/runtime/src/projection/index.ts +1 -0
  298. package/packages/runtime/src/projection/projection-engine.ts +249 -0
  299. package/packages/runtime/src/reducers/debug-reducer.ts +36 -0
  300. package/packages/runtime/src/reducers/index.ts +2 -0
  301. package/packages/runtime/src/reducers/run-state-reducer.ts +269 -0
  302. package/packages/runtime/src/scheduler/agent-registry.ts +132 -0
  303. package/packages/runtime/src/scheduler/agent-roles.ts +109 -0
  304. package/packages/runtime/src/scheduler/index.ts +4 -0
  305. package/packages/runtime/src/scheduler/multi-agent-coordinator.ts +333 -0
  306. package/packages/runtime/src/scheduler/run-journal.ts +62 -0
  307. package/packages/runtime/src/scheduler/scheduler.ts +441 -0
  308. package/packages/runtime/src/verification/index.ts +2 -0
  309. package/packages/runtime/src/verification/verification-compiler.ts +225 -0
  310. package/packages/runtime/src/verification/verification-manifest.ts +192 -0
  311. package/packages/runtime/src/workspace/index.ts +5 -0
  312. package/packages/runtime/src/workspace/strategies/ephemeral-container.ts +121 -0
  313. package/packages/runtime/src/workspace/strategies/git-worktree.ts +77 -0
  314. package/packages/runtime/src/workspace/strategies/inplace.ts +35 -0
  315. package/packages/runtime/src/workspace/workspace-manager.ts +15 -0
  316. package/packages/runtime/tsconfig.json +17 -0
  317. package/vscode-extension/oxe-agents-0.9.2.vsix +0 -0
  318. package/vscode-extension/oxe-agents-1.0.0.vsix +0 -0
  319. package/vscode-extension/package.json +1 -1
@@ -0,0 +1,173 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.StrategySelector = void 0;
7
+ exports.buildBlastRadius = buildBlastRadius;
8
+ exports.buildRollbackPlan = buildRollbackPlan;
9
+ exports.buildMemo = buildMemo;
10
+ exports.saveMemo = saveMemo;
11
+ exports.loadMemo = loadMemo;
12
+ exports.listMemos = listMemos;
13
+ const crypto_1 = __importDefault(require("crypto"));
14
+ const path_1 = __importDefault(require("path"));
15
+ const fs_1 = __importDefault(require("fs"));
16
+ // ─── BlastRadius estimation ───────────────────────────────────────────────────
17
+ function deriveSubsystems(mutationScope) {
18
+ const seen = new Set();
19
+ for (const p of mutationScope) {
20
+ const parts = p.replace(/\\/g, '/').split('/');
21
+ if (parts.length >= 2)
22
+ seen.add(parts[0]);
23
+ else
24
+ seen.add(p);
25
+ }
26
+ return [...seen];
27
+ }
28
+ function estimateRiskScore(mutationScope, retryCount, riskLevel) {
29
+ let score = 0;
30
+ score += Math.min(0.4, mutationScope.length * 0.05);
31
+ score += retryCount > 0 ? Math.min(0.2, retryCount * 0.05) : 0;
32
+ switch (riskLevel) {
33
+ case 'critical':
34
+ score += 0.4;
35
+ break;
36
+ case 'high':
37
+ score += 0.3;
38
+ break;
39
+ case 'medium':
40
+ score += 0.15;
41
+ break;
42
+ case 'low':
43
+ score += 0.05;
44
+ break;
45
+ default: break;
46
+ }
47
+ return Math.min(1, score);
48
+ }
49
+ function buildBlastRadius(mutationScope, retryCount, riskLevel) {
50
+ const risk_score = estimateRiskScore(mutationScope, retryCount, riskLevel);
51
+ return {
52
+ estimated_files: mutationScope.length,
53
+ subsystems: deriveSubsystems(mutationScope),
54
+ risk_score: Math.round(risk_score * 100) / 100,
55
+ reversible: riskLevel !== 'critical' && mutationScope.length <= 10,
56
+ };
57
+ }
58
+ // ─── RollbackPlan ─────────────────────────────────────────────────────────────
59
+ function buildRollbackPlan(blastRadius, retryCount) {
60
+ if (blastRadius.risk_score >= 0.7 || !blastRadius.reversible) {
61
+ return {
62
+ strategy: 'restore_workspace',
63
+ steps: ['snapshot workspace before mutation', 'restore snapshot on failure', 'verify clean state'],
64
+ estimated_cost: 'high',
65
+ preconditions: ['workspace snapshot available', 'no shared-state mutations'],
66
+ };
67
+ }
68
+ if (retryCount > 1 || blastRadius.estimated_files > 5) {
69
+ return {
70
+ strategy: 'revert_commit',
71
+ steps: ['record commit SHA before change', 'git revert on failure'],
72
+ estimated_cost: 'medium',
73
+ preconditions: ['git repo initialized', 'changes committed atomically'],
74
+ };
75
+ }
76
+ return {
77
+ strategy: 'undo_patch',
78
+ steps: ['apply inverse patch'],
79
+ estimated_cost: 'low',
80
+ preconditions: ['original file state recorded'],
81
+ };
82
+ }
83
+ // ─── StrategySelector ────────────────────────────────────────────────────────
84
+ class StrategySelector {
85
+ select(mutationScope, retryCount, riskLevel) {
86
+ if (riskLevel === 'critical')
87
+ return 'feature_flag';
88
+ if (retryCount > 1)
89
+ return 'minimal_patch';
90
+ if (mutationScope.length > 8)
91
+ return 'isolated_refactor';
92
+ if (riskLevel === 'high')
93
+ return 'feature_flag';
94
+ if (mutationScope.length > 3)
95
+ return 'expand_contract';
96
+ if (mutationScope.length === 0)
97
+ return 'no_op';
98
+ return 'minimal_patch';
99
+ }
100
+ alternatives(chosen, mutationScope, riskLevel) {
101
+ const all = ['minimal_patch', 'isolated_refactor', 'expand_contract', 'feature_flag', 'no_op'];
102
+ return all
103
+ .filter((s) => s !== chosen)
104
+ .map((s) => ({ strategy: s, reason: this.rejectionReason(s, chosen, mutationScope, riskLevel) }));
105
+ }
106
+ rejectionReason(s, chosen, mutationScope, riskLevel) {
107
+ switch (s) {
108
+ case 'no_op': return 'mutation scope is non-empty; no-op would not satisfy requirements';
109
+ case 'feature_flag': return riskLevel !== 'critical' && riskLevel !== 'high' ? 'risk level does not warrant feature flag overhead' : `${chosen} preferred for scope size`;
110
+ case 'isolated_refactor': return mutationScope.length <= 8 ? 'scope is small enough for simpler strategy' : `${chosen} preferred`;
111
+ case 'expand_contract': return 'expand-contract requires coordinated deployment; overhead not justified here';
112
+ case 'minimal_patch': return `${chosen} preferred due to scope or risk level`;
113
+ default: return 'not applicable';
114
+ }
115
+ }
116
+ }
117
+ exports.StrategySelector = StrategySelector;
118
+ function buildMemo(input) {
119
+ const selector = new StrategySelector();
120
+ const chosen = selector.select(input.mutation_scope, input.retry_count, input.risk_level);
121
+ const blast_radius = buildBlastRadius(input.mutation_scope, input.retry_count, input.risk_level);
122
+ const rollback_plan = buildRollbackPlan(blast_radius, input.retry_count);
123
+ const alternatives_rejected = selector.alternatives(chosen, input.mutation_scope, input.risk_level);
124
+ return {
125
+ memo_id: `memo-${crypto_1.default.randomBytes(4).toString('hex')}`,
126
+ work_item_id: input.work_item_id,
127
+ run_id: input.run_id,
128
+ problem_summary: input.problem_summary,
129
+ chosen_strategy: chosen,
130
+ alternatives_rejected,
131
+ blast_radius,
132
+ rollback_plan,
133
+ min_evidence_required: input.min_evidence_required ?? [],
134
+ confidence: input.confidence ?? (1 - blast_radius.risk_score),
135
+ created_at: new Date().toISOString(),
136
+ };
137
+ }
138
+ function memoDir(projectRoot, runId) {
139
+ return path_1.default.join(projectRoot, '.oxe', 'runs', runId, 'memos');
140
+ }
141
+ function saveMemo(projectRoot, memo) {
142
+ const dir = memoDir(projectRoot, memo.run_id);
143
+ fs_1.default.mkdirSync(dir, { recursive: true });
144
+ fs_1.default.writeFileSync(path_1.default.join(dir, `${memo.memo_id}.json`), JSON.stringify(memo, null, 2), 'utf8');
145
+ }
146
+ function loadMemo(projectRoot, runId, memoId) {
147
+ const p = path_1.default.join(memoDir(projectRoot, runId), `${memoId}.json`);
148
+ if (!fs_1.default.existsSync(p))
149
+ return null;
150
+ try {
151
+ return JSON.parse(fs_1.default.readFileSync(p, 'utf8'));
152
+ }
153
+ catch {
154
+ return null;
155
+ }
156
+ }
157
+ function listMemos(projectRoot, runId) {
158
+ const dir = memoDir(projectRoot, runId);
159
+ if (!fs_1.default.existsSync(dir))
160
+ return [];
161
+ return fs_1.default
162
+ .readdirSync(dir)
163
+ .filter((f) => f.endsWith('.json'))
164
+ .map((f) => {
165
+ try {
166
+ return JSON.parse(fs_1.default.readFileSync(path_1.default.join(dir, f), 'utf8'));
167
+ }
168
+ catch {
169
+ return null;
170
+ }
171
+ })
172
+ .filter((m) => m !== null);
173
+ }
@@ -0,0 +1,2 @@
1
+ export * from './decision-engine';
2
+ export * from './decision-memo';
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./decision-engine"), exports);
18
+ __exportStar(require("./decision-memo"), exports);
@@ -0,0 +1,19 @@
1
+ export interface BranchInfo {
2
+ name: string;
3
+ current: boolean;
4
+ commit: string;
5
+ }
6
+ export declare class BranchManager {
7
+ private readonly projectRoot;
8
+ constructor(projectRoot: string);
9
+ currentBranch(): string;
10
+ currentCommit(): string;
11
+ createSessionBranch(sessionId: string): string;
12
+ createOxeBranch(name: string, base?: string): string;
13
+ switchTo(branchName: string): void;
14
+ deleteBranch(name: string, force?: boolean): void;
15
+ listOxeBranches(): BranchInfo[];
16
+ mergeWorktreeBranch(worktreeBranch: string, targetBranch: string): void;
17
+ branchExists(name: string): boolean;
18
+ private git;
19
+ }
@@ -0,0 +1,78 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BranchManager = void 0;
4
+ const child_process_1 = require("child_process");
5
+ class BranchManager {
6
+ constructor(projectRoot) {
7
+ this.projectRoot = projectRoot;
8
+ }
9
+ currentBranch() {
10
+ return this.git(['rev-parse', '--abbrev-ref', 'HEAD']).trim();
11
+ }
12
+ currentCommit() {
13
+ return this.git(['rev-parse', 'HEAD']).trim();
14
+ }
15
+ createSessionBranch(sessionId) {
16
+ const name = `oxe/${sessionId}`;
17
+ this.git(['checkout', '-b', name]);
18
+ return name;
19
+ }
20
+ createOxeBranch(name, base) {
21
+ const fullName = name.startsWith('oxe/') ? name : `oxe/${name}`;
22
+ if (base) {
23
+ this.git(['checkout', '-b', fullName, base]);
24
+ }
25
+ else {
26
+ this.git(['checkout', '-b', fullName]);
27
+ }
28
+ return fullName;
29
+ }
30
+ switchTo(branchName) {
31
+ this.git(['checkout', branchName]);
32
+ }
33
+ deleteBranch(name, force = false) {
34
+ const flag = force ? '-D' : '-d';
35
+ this.git(['branch', flag, name]);
36
+ }
37
+ listOxeBranches() {
38
+ const raw = this.git(['branch', '--list', 'oxe/*', '--format=%(refname:short) %(objectname:short) %(HEAD)']);
39
+ return raw
40
+ .split('\n')
41
+ .filter(Boolean)
42
+ .map((line) => {
43
+ const parts = line.trim().split(/\s+/);
44
+ return {
45
+ name: parts[0],
46
+ commit: parts[1] ?? '',
47
+ current: parts[2] === '*',
48
+ };
49
+ });
50
+ }
51
+ mergeWorktreeBranch(worktreeBranch, targetBranch) {
52
+ const saved = this.currentBranch();
53
+ try {
54
+ this.git(['checkout', targetBranch]);
55
+ this.git(['merge', '--no-ff', worktreeBranch, '-m', `oxe: merge ${worktreeBranch}`]);
56
+ }
57
+ finally {
58
+ try {
59
+ this.git(['checkout', saved]);
60
+ }
61
+ catch { /* best effort */ }
62
+ }
63
+ }
64
+ branchExists(name) {
65
+ const result = (0, child_process_1.spawnSync)('git', ['rev-parse', '--verify', name], {
66
+ cwd: this.projectRoot,
67
+ encoding: 'utf8',
68
+ });
69
+ return result.status === 0;
70
+ }
71
+ git(args) {
72
+ return (0, child_process_1.execFileSync)('git', args, {
73
+ cwd: this.projectRoot,
74
+ encoding: 'utf8',
75
+ });
76
+ }
77
+ }
78
+ exports.BranchManager = BranchManager;
@@ -0,0 +1,34 @@
1
+ import type { EvidenceStore } from '../evidence/evidence-store';
2
+ export type CICheckStatus = 'pass' | 'fail' | 'skip' | 'error';
3
+ export interface CICheckContext {
4
+ projectRoot: string;
5
+ sessionId: string | null;
6
+ runId?: string;
7
+ evidenceStore?: EvidenceStore;
8
+ }
9
+ export interface CICheckResult {
10
+ check: string;
11
+ status: CICheckStatus;
12
+ message: string;
13
+ details?: unknown;
14
+ }
15
+ export interface CICheck {
16
+ name: string;
17
+ description: string;
18
+ run(ctx: CICheckContext): Promise<CICheckResult>;
19
+ }
20
+ export declare const planConsistencyCheck: CICheck;
21
+ export declare const verifyAcceptanceCheck: CICheck;
22
+ export declare const policyCheck: CICheck;
23
+ export declare const securityBaselineCheck: CICheck;
24
+ export declare const runtimeEvidenceIntegrityCheck: CICheck;
25
+ export declare const OXE_CI_CHECKS: CICheck[];
26
+ export declare function runCIChecks(ctx: CICheckContext, checks?: CICheck[]): Promise<CICheckResult[]>;
27
+ export declare function summarizeCIResults(results: CICheckResult[]): {
28
+ total: number;
29
+ pass: number;
30
+ fail: number;
31
+ skip: number;
32
+ error: number;
33
+ allPassed: boolean;
34
+ };
@@ -0,0 +1,209 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.OXE_CI_CHECKS = exports.runtimeEvidenceIntegrityCheck = exports.securityBaselineCheck = exports.policyCheck = exports.verifyAcceptanceCheck = exports.planConsistencyCheck = void 0;
7
+ exports.runCIChecks = runCIChecks;
8
+ exports.summarizeCIResults = summarizeCIResults;
9
+ const fs_1 = __importDefault(require("fs"));
10
+ const path_1 = __importDefault(require("path"));
11
+ // ─── Check: plan-consistency ─────────────────────────────────────────────────
12
+ exports.planConsistencyCheck = {
13
+ name: 'oxe-plan-consistency',
14
+ description: 'Verifies ACTIVE-RUN.json exists and has a compiled ExecutionGraph',
15
+ async run(ctx) {
16
+ const activeRunPath = ctx.sessionId
17
+ ? path_1.default.join(ctx.projectRoot, '.oxe', ctx.sessionId, 'execution', 'ACTIVE-RUN.json')
18
+ : path_1.default.join(ctx.projectRoot, '.oxe', 'ACTIVE-RUN.json');
19
+ if (!fs_1.default.existsSync(activeRunPath)) {
20
+ return { check: this.name, status: 'skip', message: 'No ACTIVE-RUN.json found' };
21
+ }
22
+ try {
23
+ const raw = JSON.parse(fs_1.default.readFileSync(activeRunPath, 'utf8'));
24
+ const hasGraph = raw.compiled_graph && typeof raw.compiled_graph === 'object';
25
+ const hasRunId = typeof raw.run_id === 'string';
26
+ if (!hasRunId) {
27
+ return { check: this.name, status: 'fail', message: 'ACTIVE-RUN.json missing run_id', details: raw };
28
+ }
29
+ if (!hasGraph) {
30
+ return { check: this.name, status: 'fail', message: 'No compiled ExecutionGraph found in ACTIVE-RUN.json', details: { run_id: raw.run_id } };
31
+ }
32
+ return { check: this.name, status: 'pass', message: `Run ${String(raw.run_id)} has compiled graph` };
33
+ }
34
+ catch (err) {
35
+ return { check: this.name, status: 'error', message: `Failed to parse ACTIVE-RUN.json: ${String(err)}` };
36
+ }
37
+ },
38
+ };
39
+ // ─── Check: verify-acceptance ────────────────────────────────────────────────
40
+ exports.verifyAcceptanceCheck = {
41
+ name: 'oxe-verify-acceptance',
42
+ description: 'Checks that VERIFY.md exists and contains no failed criteria',
43
+ async run(ctx) {
44
+ const verifyPath = ctx.sessionId
45
+ ? path_1.default.join(ctx.projectRoot, '.oxe', ctx.sessionId, 'verification', 'VERIFY.md')
46
+ : path_1.default.join(ctx.projectRoot, '.oxe', 'VERIFY.md');
47
+ if (!fs_1.default.existsSync(verifyPath)) {
48
+ return { check: this.name, status: 'skip', message: 'No VERIFY.md found — run /oxe-verify first' };
49
+ }
50
+ const content = fs_1.default.readFileSync(verifyPath, 'utf8');
51
+ const failLines = content.split('\n').filter((l) => l.includes('✗ FAIL'));
52
+ const passLines = content.split('\n').filter((l) => l.includes('✓ PASS'));
53
+ if (failLines.length > 0) {
54
+ return {
55
+ check: this.name,
56
+ status: 'fail',
57
+ message: `${failLines.length} acceptance criteria failed`,
58
+ details: { failed: failLines, passed: passLines.length },
59
+ };
60
+ }
61
+ if (passLines.length === 0) {
62
+ return { check: this.name, status: 'skip', message: 'VERIFY.md has no pass/fail markers' };
63
+ }
64
+ return { check: this.name, status: 'pass', message: `${passLines.length} acceptance criteria passed` };
65
+ },
66
+ };
67
+ // ─── Check: policy ───────────────────────────────────────────────────────────
68
+ exports.policyCheck = {
69
+ name: 'oxe-policy',
70
+ description: 'Checks that no gates are pending (unresolved human approval)',
71
+ async run(ctx) {
72
+ const gatesPath = ctx.sessionId
73
+ ? path_1.default.join(ctx.projectRoot, '.oxe', ctx.sessionId, 'execution', 'GATES.json')
74
+ : path_1.default.join(ctx.projectRoot, '.oxe', 'execution', 'GATES.json');
75
+ if (!fs_1.default.existsSync(gatesPath)) {
76
+ return { check: this.name, status: 'pass', message: 'No pending gates' };
77
+ }
78
+ try {
79
+ const gates = JSON.parse(fs_1.default.readFileSync(gatesPath, 'utf8'));
80
+ const pending = gates.filter((g) => g.status === 'pending');
81
+ if (pending.length > 0) {
82
+ return {
83
+ check: this.name,
84
+ status: 'fail',
85
+ message: `${pending.length} unresolved gate(s)`,
86
+ details: pending.map((g) => ({ gate_id: g.gate_id, scope: g.scope })),
87
+ };
88
+ }
89
+ return { check: this.name, status: 'pass', message: 'All gates resolved' };
90
+ }
91
+ catch (err) {
92
+ return { check: this.name, status: 'error', message: `Failed to read GATES.json: ${String(err)}` };
93
+ }
94
+ },
95
+ };
96
+ // ─── Check: security-baseline ────────────────────────────────────────────────
97
+ const SECRET_PATTERNS = [
98
+ /(?:password|passwd|secret|api[_-]?key|auth[_-]?token)\s*[:=]\s*['"]?\S{8,}/i,
99
+ /(?:AKIA|ASIA)[A-Z0-9]{16}/,
100
+ /-----BEGIN (?:RSA|EC|OPENSSH) PRIVATE KEY-----/,
101
+ ];
102
+ exports.securityBaselineCheck = {
103
+ name: 'oxe-security-baseline',
104
+ description: 'Scans evidence artifacts for common secret patterns',
105
+ async run(ctx) {
106
+ if (!ctx.evidenceStore || !ctx.runId) {
107
+ return { check: this.name, status: 'skip', message: 'No evidence store or run ID provided' };
108
+ }
109
+ const evidenceDir = path_1.default.join(ctx.projectRoot, '.oxe', 'evidence', 'runs', ctx.runId);
110
+ if (!fs_1.default.existsSync(evidenceDir)) {
111
+ return { check: this.name, status: 'skip', message: 'No evidence found for this run' };
112
+ }
113
+ const findings = [];
114
+ walkDir(evidenceDir, (filePath) => {
115
+ if (filePath.endsWith('.json') || filePath.endsWith('.patch') || filePath.endsWith('.txt')) {
116
+ try {
117
+ const content = fs_1.default.readFileSync(filePath, 'utf8');
118
+ for (const pattern of SECRET_PATTERNS) {
119
+ if (pattern.test(content)) {
120
+ findings.push(`${path_1.default.basename(filePath)}: matches pattern ${pattern.source.slice(0, 40)}`);
121
+ break;
122
+ }
123
+ }
124
+ }
125
+ catch { /* skip unreadable */ }
126
+ }
127
+ });
128
+ if (findings.length > 0) {
129
+ return { check: this.name, status: 'fail', message: `Secret patterns detected in ${findings.length} evidence file(s)`, details: findings };
130
+ }
131
+ return { check: this.name, status: 'pass', message: 'No secret patterns detected in evidence' };
132
+ },
133
+ };
134
+ // ─── Check: runtime-evidence-integrity ───────────────────────────────────────
135
+ exports.runtimeEvidenceIntegrityCheck = {
136
+ name: 'oxe-runtime-evidence-integrity',
137
+ description: 'Validates that all evidence index files are valid JSON and files exist on disk',
138
+ async run(ctx) {
139
+ if (!ctx.runId) {
140
+ return { check: this.name, status: 'skip', message: 'No run ID provided' };
141
+ }
142
+ const runEvidenceDir = path_1.default.join(ctx.projectRoot, '.oxe', 'evidence', 'runs', ctx.runId);
143
+ if (!fs_1.default.existsSync(runEvidenceDir)) {
144
+ return { check: this.name, status: 'skip', message: 'No evidence directory for this run' };
145
+ }
146
+ const errors = [];
147
+ let indexCount = 0;
148
+ let evidenceCount = 0;
149
+ walkDir(runEvidenceDir, (filePath) => {
150
+ if (path_1.default.basename(filePath) !== 'index.json')
151
+ return;
152
+ indexCount++;
153
+ try {
154
+ const items = JSON.parse(fs_1.default.readFileSync(filePath, 'utf8'));
155
+ for (const item of items) {
156
+ evidenceCount++;
157
+ const absPath = path_1.default.join(ctx.projectRoot, item.path);
158
+ if (!fs_1.default.existsSync(absPath)) {
159
+ errors.push(`Missing file for ${item.evidence_id}: ${item.path}`);
160
+ }
161
+ }
162
+ }
163
+ catch (err) {
164
+ errors.push(`Corrupt index at ${filePath}: ${String(err)}`);
165
+ }
166
+ });
167
+ if (errors.length > 0) {
168
+ return { check: this.name, status: 'fail', message: `${errors.length} integrity error(s)`, details: errors };
169
+ }
170
+ return {
171
+ check: this.name,
172
+ status: indexCount === 0 ? 'skip' : 'pass',
173
+ message: `${evidenceCount} evidence artifact(s) across ${indexCount} index(es) — all valid`,
174
+ };
175
+ },
176
+ };
177
+ // ─── Suite ───────────────────────────────────────────────────────────────────
178
+ exports.OXE_CI_CHECKS = [
179
+ exports.planConsistencyCheck,
180
+ exports.verifyAcceptanceCheck,
181
+ exports.policyCheck,
182
+ exports.securityBaselineCheck,
183
+ exports.runtimeEvidenceIntegrityCheck,
184
+ ];
185
+ async function runCIChecks(ctx, checks = exports.OXE_CI_CHECKS) {
186
+ const results = [];
187
+ for (const check of checks) {
188
+ results.push(await check.run(ctx));
189
+ }
190
+ return results;
191
+ }
192
+ function summarizeCIResults(results) {
193
+ const counts = { total: results.length, pass: 0, fail: 0, skip: 0, error: 0 };
194
+ for (const r of results)
195
+ counts[r.status]++;
196
+ return { ...counts, allPassed: counts.fail === 0 && counts.error === 0 };
197
+ }
198
+ // ─── Helpers ─────────────────────────────────────────────────────────────────
199
+ function walkDir(dir, visitor) {
200
+ if (!fs_1.default.existsSync(dir))
201
+ return;
202
+ for (const entry of fs_1.default.readdirSync(dir, { withFileTypes: true })) {
203
+ const full = path_1.default.join(dir, entry.name);
204
+ if (entry.isDirectory())
205
+ walkDir(full, visitor);
206
+ else
207
+ visitor(full);
208
+ }
209
+ }
@@ -0,0 +1,4 @@
1
+ export * from './branch-manager';
2
+ export * from './pr-manager';
3
+ export * from './ci-checks';
4
+ export * from './promotion-pipeline';
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./branch-manager"), exports);
18
+ __exportStar(require("./pr-manager"), exports);
19
+ __exportStar(require("./ci-checks"), exports);
20
+ __exportStar(require("./promotion-pipeline"), exports);
@@ -0,0 +1,30 @@
1
+ export interface PRDraftOptions {
2
+ title: string;
3
+ body: string;
4
+ base?: string;
5
+ head?: string;
6
+ draft?: boolean;
7
+ }
8
+ export interface PRInfo {
9
+ number: number;
10
+ title: string;
11
+ url: string;
12
+ state: string;
13
+ draft: boolean;
14
+ head: string;
15
+ base: string;
16
+ }
17
+ export interface PRResult {
18
+ success: boolean;
19
+ url?: string;
20
+ error?: string;
21
+ pr?: PRInfo;
22
+ }
23
+ export declare class PRManager {
24
+ private readonly projectRoot;
25
+ constructor(projectRoot: string);
26
+ isAvailable(): boolean;
27
+ createDraft(opts: PRDraftOptions): PRResult;
28
+ view(prNumberOrUrl: string | number): PRResult;
29
+ mergePR(prNumber: number, method?: 'merge' | 'squash' | 'rebase'): PRResult;
30
+ }
@@ -0,0 +1,82 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PRManager = void 0;
4
+ const child_process_1 = require("child_process");
5
+ function isGhAvailable(cwd) {
6
+ const result = (0, child_process_1.spawnSync)('gh', ['--version'], { cwd, encoding: 'utf8' });
7
+ return result.status === 0;
8
+ }
9
+ class PRManager {
10
+ constructor(projectRoot) {
11
+ this.projectRoot = projectRoot;
12
+ }
13
+ isAvailable() {
14
+ return isGhAvailable(this.projectRoot);
15
+ }
16
+ createDraft(opts) {
17
+ if (!this.isAvailable()) {
18
+ return { success: false, error: 'gh CLI not available — install from https://cli.github.com' };
19
+ }
20
+ const args = [
21
+ 'pr', 'create',
22
+ '--title', opts.title,
23
+ '--body', opts.body,
24
+ ];
25
+ if (opts.draft !== false)
26
+ args.push('--draft');
27
+ if (opts.base)
28
+ args.push('--base', opts.base);
29
+ if (opts.head)
30
+ args.push('--head', opts.head);
31
+ const result = (0, child_process_1.spawnSync)('gh', args, {
32
+ cwd: this.projectRoot,
33
+ encoding: 'utf8',
34
+ });
35
+ if (result.status !== 0) {
36
+ return { success: false, error: result.stderr?.trim() ?? 'gh pr create failed' };
37
+ }
38
+ const url = result.stdout?.trim();
39
+ return { success: true, url };
40
+ }
41
+ view(prNumberOrUrl) {
42
+ if (!this.isAvailable()) {
43
+ return { success: false, error: 'gh CLI not available' };
44
+ }
45
+ const result = (0, child_process_1.spawnSync)('gh', ['pr', 'view', String(prNumberOrUrl), '--json', 'number,title,url,state,isDraft,headRefName,baseRefName'], { cwd: this.projectRoot, encoding: 'utf8' });
46
+ if (result.status !== 0) {
47
+ return { success: false, error: result.stderr?.trim() };
48
+ }
49
+ try {
50
+ const raw = JSON.parse(result.stdout);
51
+ return {
52
+ success: true,
53
+ url: raw.url,
54
+ pr: {
55
+ number: raw.number,
56
+ title: raw.title,
57
+ url: raw.url,
58
+ state: raw.state.toLowerCase(),
59
+ draft: raw.isDraft,
60
+ head: raw.headRefName,
61
+ base: raw.baseRefName,
62
+ },
63
+ };
64
+ }
65
+ catch {
66
+ return { success: false, error: 'Failed to parse gh output' };
67
+ }
68
+ }
69
+ mergePR(prNumber, method = 'merge') {
70
+ if (!this.isAvailable()) {
71
+ return { success: false, error: 'gh CLI not available' };
72
+ }
73
+ const result = (0, child_process_1.spawnSync)('gh', ['pr', 'merge', String(prNumber), `--${method}`, '--delete-branch'], {
74
+ cwd: this.projectRoot,
75
+ encoding: 'utf8',
76
+ });
77
+ return result.status === 0
78
+ ? { success: true }
79
+ : { success: false, error: result.stderr?.trim() };
80
+ }
81
+ }
82
+ exports.PRManager = PRManager;