@hassangameryt/freeflow 0.8.0 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (290) hide show
  1. package/.agents/plugins/marketplace.json +2 -2
  2. package/.claude-plugin/marketplace.json +1 -1
  3. package/.claude-plugin/plugin.json +2 -2
  4. package/.codex-plugin/plugin.json +3 -3
  5. package/.cursor-plugin/plugin.json +1 -1
  6. package/README.md +96 -149
  7. package/capabilities/cognitive-routing/SKILL.md +21 -129
  8. package/capabilities/cognitive-routing/references/coordinator.md +163 -0
  9. package/capabilities/cognitive-routing/references/worker.md +38 -0
  10. package/capabilities/compaction/SKILL.md +3 -3
  11. package/capabilities/compaction/references/summary-format.md +26 -15
  12. package/capabilities/messaging/SKILL.md +49 -0
  13. package/capabilities/task-memory/SKILL.md +87 -0
  14. package/command-surface.json +6 -54
  15. package/gemini-extension.json +1 -1
  16. package/hooks/claude/hooks.json +13 -3
  17. package/hooks/codex/hooks.json +2 -1
  18. package/hooks/shared/runtime-context.mjs +69 -77
  19. package/package.json +25 -8
  20. package/pi-extension/dist/ask-user/ask.js +108 -0
  21. package/pi-extension/dist/ask-user/form.js +250 -0
  22. package/pi-extension/dist/ask-user/questions.js +66 -0
  23. package/pi-extension/dist/ask-user/tool.js +124 -0
  24. package/pi-extension/dist/cognitive-routing/assembler.js +35 -11
  25. package/pi-extension/dist/cognitive-routing/bootstrap.js +90 -0
  26. package/pi-extension/dist/cognitive-routing/config.js +3 -4
  27. package/pi-extension/dist/cognitive-routing/event-store.js +4 -1
  28. package/pi-extension/dist/cognitive-routing/gate.js +20 -5
  29. package/pi-extension/dist/cognitive-routing/handlers.js +15 -13
  30. package/pi-extension/dist/cognitive-routing/model-control.js +17 -8
  31. package/pi-extension/dist/cognitive-routing/projection.js +23 -6
  32. package/pi-extension/dist/cognitive-routing/provenance.js +3 -1
  33. package/pi-extension/dist/cognitive-routing/render.js +15 -15
  34. package/pi-extension/dist/cognitive-routing/runtime.js +4 -2
  35. package/pi-extension/dist/cognitive-routing/schemas.js +4 -4
  36. package/pi-extension/dist/cognitive-routing/session.js +3 -1
  37. package/pi-extension/dist/cognitive-routing/sources.js +29 -4
  38. package/pi-extension/dist/cognitive-routing/state.js +18 -8
  39. package/pi-extension/dist/cognitive-routing/status.js +4 -3
  40. package/pi-extension/dist/cognitive-routing/tools.js +29 -15
  41. package/pi-extension/dist/cognitive-routing/types.js +10 -1
  42. package/pi-extension/dist/compaction/carry.js +36 -22
  43. package/pi-extension/dist/compaction/config.js +4 -2
  44. package/pi-extension/dist/compaction/controller.js +52 -29
  45. package/pi-extension/dist/compaction/harness.js +19 -3
  46. package/pi-extension/dist/compaction/results.js +14 -13
  47. package/pi-extension/dist/compaction/tool.js +6 -6
  48. package/pi-extension/dist/host/catalog.js +20 -35
  49. package/pi-extension/dist/host/config-validation.js +233 -0
  50. package/pi-extension/dist/host/config.js +78 -91
  51. package/pi-extension/dist/host/inbound.js +142 -0
  52. package/pi-extension/dist/host/projection-tags.js +1 -1
  53. package/pi-extension/dist/host/prompts.js +24 -13
  54. package/pi-extension/dist/host/read-only-session.js +6 -1
  55. package/pi-extension/dist/host/request-history.js +7 -3
  56. package/pi-extension/dist/host/rows.js +25 -0
  57. package/pi-extension/dist/host/runtime-state.js +17 -2
  58. package/pi-extension/dist/host/section-keeper.js +85 -0
  59. package/pi-extension/dist/host/settings/freeflow-command.js +846 -93
  60. package/pi-extension/dist/host/settings/settings-view.js +27 -8
  61. package/pi-extension/dist/host/status.js +19 -5
  62. package/pi-extension/dist/index.js +638 -72
  63. package/pi-extension/dist/messaging/config.js +27 -0
  64. package/pi-extension/dist/messaging/messaging.js +398 -0
  65. package/pi-extension/dist/messaging/registry.js +57 -0
  66. package/pi-extension/dist/messaging/render.js +90 -0
  67. package/pi-extension/dist/messaging/tools.js +109 -0
  68. package/pi-extension/dist/messaging/transport.js +101 -0
  69. package/pi-extension/dist/provider-support/cache/keepalive.js +16 -4
  70. package/pi-extension/dist/task-memory/config.js +49 -0
  71. package/pi-extension/dist/task-memory/registry.js +119 -0
  72. package/pi-extension/dist/task-memory/render.js +107 -0
  73. package/pi-extension/dist/task-memory/runtime.js +994 -0
  74. package/pi-extension/dist/task-memory/tool.js +233 -0
  75. package/pi-extension/dist/tool-execution/apply-patch/tool.js +1 -1
  76. package/pi-extension/dist/tool-execution/background.js +220 -28
  77. package/pi-extension/dist/tool-execution/config.js +14 -3
  78. package/pi-extension/dist/tool-execution/file-tracking.js +24 -4
  79. package/pi-extension/dist/tool-execution/guidance-notices.js +124 -0
  80. package/pi-extension/dist/tool-execution/skill-reads.js +143 -0
  81. package/pi-extension/dist/tool-execution/tools.js +2 -2
  82. package/runtime/prompts/cognitive-routing.md +4 -4
  83. package/runtime/prompts/core.md +24 -14
  84. package/runtime/prompts/interaction-contract.md +7 -4
  85. package/runtime/prompts/tool-execution.md +3 -16
  86. package/runtime/prompts/working-method.md +16 -99
  87. package/skills/deliver-work/SKILL.md +76 -0
  88. package/skills/deliver-work/references/branch-closeout.md +134 -0
  89. package/skills/deliver-work/references/commit.md +83 -0
  90. package/skills/deliver-work/references/launch.md +94 -0
  91. package/skills/deliver-work/references/release.md +85 -0
  92. package/skills/deliver-work/scripts/commit-state.mjs +139 -0
  93. package/skills/deliver-work/scripts/delivery-state.mjs +107 -0
  94. package/skills/deliver-work/scripts/lib/git-state.mjs +178 -0
  95. package/skills/deliver-work/scripts/push-route.mjs +122 -0
  96. package/skills/deliver-work/scripts/release-preflight.mjs +177 -0
  97. package/skills/discuss-work/SKILL.md +148 -0
  98. package/skills/{discuss → discuss-work}/references/discussion-continuity.md +10 -27
  99. package/skills/discuss-work/references/learning-action.md +36 -0
  100. package/skills/discuss-work/scripts/choices.mjs +101 -0
  101. package/skills/discuss-work/scripts/lib/choices.mjs +159 -0
  102. package/skills/evaluate-behavior/SKILL.md +107 -0
  103. package/skills/evaluate-behavior/references/authoring.md +381 -0
  104. package/skills/evaluate-behavior/references/coding-tasks.md +145 -0
  105. package/skills/evaluate-behavior/references/conversations-pipelines-judges.md +177 -0
  106. package/skills/evaluate-behavior/references/design-and-measurement.md +273 -0
  107. package/skills/evaluate-behavior/references/running-and-evidence.md +245 -0
  108. package/skills/evaluate-behavior/scripts/claude-guard.mjs +76 -0
  109. package/skills/evaluate-behavior/scripts/guard-rules.mjs +309 -0
  110. package/skills/evaluate-behavior/scripts/lib/agreement.mjs +90 -0
  111. package/skills/evaluate-behavior/scripts/lib/arms.mjs +55 -0
  112. package/skills/evaluate-behavior/scripts/lib/budget.mjs +87 -0
  113. package/skills/evaluate-behavior/scripts/lib/build-source.mjs +287 -0
  114. package/skills/evaluate-behavior/scripts/lib/clear.mjs +74 -0
  115. package/skills/evaluate-behavior/scripts/lib/container.mjs +395 -0
  116. package/skills/evaluate-behavior/scripts/lib/decision.mjs +418 -0
  117. package/skills/evaluate-behavior/scripts/lib/definitions.mjs +1072 -0
  118. package/skills/evaluate-behavior/scripts/lib/freeflow.mjs +103 -0
  119. package/skills/evaluate-behavior/scripts/lib/grade-command.mjs +591 -0
  120. package/skills/evaluate-behavior/scripts/lib/grade-comparison.mjs +90 -0
  121. package/skills/{evaluate-skill → evaluate-behavior}/scripts/lib/grade-interaction.mjs +19 -18
  122. package/skills/{evaluate-skill → evaluate-behavior}/scripts/lib/grade-support.mjs +32 -5
  123. package/skills/{evaluate-skill → evaluate-behavior}/scripts/lib/grade-workspace.mjs +28 -12
  124. package/skills/evaluate-behavior/scripts/lib/grade.mjs +101 -0
  125. package/skills/evaluate-behavior/scripts/lib/hooks.mjs +98 -0
  126. package/skills/evaluate-behavior/scripts/lib/hosts/claude-code/confinement.mjs +196 -0
  127. package/skills/evaluate-behavior/scripts/lib/hosts/claude-code/constraints.mjs +111 -0
  128. package/skills/evaluate-behavior/scripts/lib/hosts/claude-code/index.mjs +48 -0
  129. package/skills/evaluate-behavior/scripts/lib/hosts/claude-code/isolation.mjs +74 -0
  130. package/skills/evaluate-behavior/scripts/lib/hosts/claude-code/launch.mjs +123 -0
  131. package/skills/evaluate-behavior/scripts/lib/hosts/claude-code/model-call.mjs +73 -0
  132. package/skills/evaluate-behavior/scripts/lib/hosts/claude-code/recorder.mjs +178 -0
  133. package/skills/evaluate-behavior/scripts/lib/hosts/claude-code/session.mjs +494 -0
  134. package/skills/evaluate-behavior/scripts/lib/hosts/claude-code/skills.mjs +81 -0
  135. package/skills/evaluate-behavior/scripts/lib/hosts/index.mjs +31 -0
  136. package/skills/evaluate-behavior/scripts/lib/hosts/names.mjs +3 -0
  137. package/skills/evaluate-behavior/scripts/lib/hosts/pi/confinement.mjs +173 -0
  138. package/skills/evaluate-behavior/scripts/lib/hosts/pi/host.mjs +148 -0
  139. package/skills/evaluate-behavior/scripts/lib/hosts/pi/index.mjs +70 -0
  140. package/skills/evaluate-behavior/scripts/lib/hosts/pi/isolation.mjs +81 -0
  141. package/skills/evaluate-behavior/scripts/lib/hosts/pi/model-call.mjs +79 -0
  142. package/skills/evaluate-behavior/scripts/lib/hosts/pi/process.mjs +241 -0
  143. package/skills/{evaluate-skill/scripts/lib → evaluate-behavior/scripts/lib/hosts/pi}/rpc.mjs +144 -26
  144. package/skills/evaluate-behavior/scripts/lib/identity.mjs +82 -0
  145. package/skills/evaluate-behavior/scripts/lib/judge.mjs +688 -0
  146. package/skills/evaluate-behavior/scripts/lib/metrics.mjs +332 -0
  147. package/skills/evaluate-behavior/scripts/lib/model-call.mjs +17 -0
  148. package/skills/evaluate-behavior/scripts/lib/participants.mjs +616 -0
  149. package/skills/{evaluate-skill → evaluate-behavior}/scripts/lib/process.mjs +22 -0
  150. package/skills/evaluate-behavior/scripts/lib/queue.mjs +54 -0
  151. package/skills/evaluate-behavior/scripts/lib/reference.mjs +343 -0
  152. package/skills/evaluate-behavior/scripts/lib/reuse.mjs +277 -0
  153. package/skills/evaluate-behavior/scripts/lib/review.mjs +933 -0
  154. package/skills/evaluate-behavior/scripts/lib/runner.mjs +732 -0
  155. package/skills/{evaluate-skill → evaluate-behavior}/scripts/lib/sandbox.mjs +119 -14
  156. package/skills/evaluate-behavior/scripts/lib/scan-shell.mjs +457 -0
  157. package/skills/evaluate-behavior/scripts/lib/scan.mjs +479 -0
  158. package/skills/evaluate-behavior/scripts/lib/seal.mjs +91 -0
  159. package/skills/evaluate-behavior/scripts/lib/shell.mjs +560 -0
  160. package/skills/evaluate-behavior/scripts/lib/source-override.mjs +64 -0
  161. package/skills/evaluate-behavior/scripts/lib/subject-file.mjs +88 -0
  162. package/skills/{evaluate-skill/scripts/lib/pi.mjs → evaluate-behavior/scripts/lib/subject.mjs} +235 -265
  163. package/skills/evaluate-behavior/scripts/lib/task-copy.mjs +124 -0
  164. package/skills/evaluate-behavior/scripts/lib/trials.mjs +524 -0
  165. package/skills/evaluate-behavior/scripts/lib/validity.mjs +68 -0
  166. package/skills/evaluate-behavior/scripts/lib/view-html.mjs +454 -0
  167. package/skills/{evaluate-skill → evaluate-behavior}/scripts/lib/view.mjs +159 -18
  168. package/skills/{evaluate-skill → evaluate-behavior}/scripts/pi-command-tool.mjs +21 -6
  169. package/skills/evaluate-behavior/scripts/pi-container-route.mjs +23 -0
  170. package/skills/evaluate-behavior/scripts/pi-guard.mjs +77 -0
  171. package/skills/evaluate-behavior/scripts/pi-login-refresh.mjs +31 -0
  172. package/skills/evaluate-behavior/scripts/skill-eval.mjs +586 -0
  173. package/skills/execute-work/SKILL.md +96 -104
  174. package/skills/execute-work/references/code-practices.md +27 -51
  175. package/skills/execute-work/references/design.md +271 -0
  176. package/skills/execute-work/references/diagnose.md +117 -0
  177. package/skills/execute-work/references/migration.md +108 -0
  178. package/skills/execute-work/references/simplify.md +65 -0
  179. package/skills/execute-work/scripts/self-review.mjs +422 -0
  180. package/skills/execute-work/scripts/touch-map.mjs +290 -0
  181. package/skills/review-work/SKILL.md +89 -65
  182. package/skills/review-work/references/adjudication.md +94 -0
  183. package/skills/review-work/references/artifact.md +198 -0
  184. package/skills/review-work/references/evals-and-judges.md +66 -0
  185. package/skills/review-work/references/work.md +177 -0
  186. package/skills/review-work/scripts/check-brief.mjs +128 -0
  187. package/skills/review-work/scripts/review-packet.mjs +233 -0
  188. package/skills/setup-freeflow/SKILL.md +68 -17
  189. package/skills/track-work/SKILL.md +52 -20
  190. package/skills/track-work/references/handoff.md +190 -0
  191. package/skills/track-work/references/projects.md +51 -0
  192. package/skills/track-work/references/working-record-format.md +36 -18
  193. package/skills/track-work/scripts/lib/document.mjs +17 -13
  194. package/skills/track-work/scripts/lib/format.mjs +2 -0
  195. package/skills/track-work/scripts/lib/recover.mjs +254 -0
  196. package/skills/track-work/scripts/lib/registry.mjs +656 -0
  197. package/skills/track-work/scripts/lib/search.mjs +40 -0
  198. package/skills/track-work/scripts/lib/store.mjs +46 -15
  199. package/skills/track-work/scripts/lib/views.mjs +50 -1
  200. package/skills/track-work/scripts/working-record.mjs +232 -13
  201. package/skills/verify-work/SKILL.md +45 -37
  202. package/skills/verify-work/references/feature-map.md +120 -0
  203. package/skills/verify-work/references/runtime-evidence.md +203 -0
  204. package/skills/verify-work/references/test-design.md +25 -6
  205. package/skills/verify-work/scripts/test-changes.mjs +246 -0
  206. package/skills/write-docs/SKILL.md +113 -25
  207. package/skills/write-docs/references/documentation-shapes.md +68 -3
  208. package/skills/write-docs/references/spec-and-plan-shapes.md +308 -0
  209. package/skills/write-docs/scripts/artifact-check.mjs +148 -0
  210. package/skills/write-docs/scripts/docs-check.mjs +96 -6
  211. package/skills/write-docs/scripts/plan-lint.mjs +123 -0
  212. package/skills/write-skill/SKILL.md +92 -52
  213. package/skills/write-skill/references/activation-and-wording.md +143 -0
  214. package/skills/write-skill/references/placement-and-dependencies.md +154 -0
  215. package/skills/write-skill/scripts/lib/compare.mjs +701 -0
  216. package/skills/write-skill/scripts/lib/skill-author.mjs +197 -3
  217. package/skills/write-skill/scripts/skill-author.mjs +51 -8
  218. package/capabilities/cognitive-routing/references/both-mode.md +0 -36
  219. package/capabilities/cognitive-routing/references/executor-mode.md +0 -48
  220. package/capabilities/cognitive-routing/references/helper-mode.md +0 -47
  221. package/plugin.json +0 -33
  222. package/skills/action-selection/SKILL.md +0 -92
  223. package/skills/action-selection/references/trajectory-stalls.md +0 -73
  224. package/skills/bypass/SKILL.md +0 -153
  225. package/skills/commit-work/SKILL.md +0 -93
  226. package/skills/commit-work/references/git-state-edges.md +0 -94
  227. package/skills/commit-work/references/simple-push.md +0 -94
  228. package/skills/commit-work/references/staging-decisions.md +0 -106
  229. package/skills/decision-gate/SKILL.md +0 -87
  230. package/skills/design-for-depth/SKILL.md +0 -108
  231. package/skills/design-for-depth/references/design-pressure-signals.md +0 -84
  232. package/skills/design-for-depth/references/implementation-decisions.md +0 -76
  233. package/skills/design-for-depth/references/interface-design-loop.md +0 -105
  234. package/skills/design-for-depth/references/module-and-dependency-design.md +0 -117
  235. package/skills/design-for-depth/references/state-and-failure-boundaries.md +0 -125
  236. package/skills/diagnose-failure/SKILL.md +0 -140
  237. package/skills/diagnose-failure/references/diagnostic-loop-catalog.md +0 -50
  238. package/skills/diagnose-failure/references/flaky-and-performance-diagnosis.md +0 -51
  239. package/skills/discuss/SKILL.md +0 -140
  240. package/skills/evaluate-skill/SKILL.md +0 -188
  241. package/skills/evaluate-skill/references/evaluation-definition-schema.md +0 -415
  242. package/skills/evaluate-skill/references/evaluation-design.md +0 -112
  243. package/skills/evaluate-skill/references/execution-and-evidence.md +0 -111
  244. package/skills/evaluate-skill/references/review-and-revision.md +0 -94
  245. package/skills/evaluate-skill/scripts/lib/definitions.mjs +0 -448
  246. package/skills/evaluate-skill/scripts/lib/grade-comparison.mjs +0 -60
  247. package/skills/evaluate-skill/scripts/lib/grade.mjs +0 -64
  248. package/skills/evaluate-skill/scripts/lib/review.mjs +0 -196
  249. package/skills/evaluate-skill/scripts/lib/runner.mjs +0 -405
  250. package/skills/evaluate-skill/scripts/lib/trials.mjs +0 -103
  251. package/skills/evaluate-skill/scripts/pi-guard.mjs +0 -181
  252. package/skills/evaluate-skill/scripts/skill-eval.mjs +0 -182
  253. package/skills/execute-work/references/execute-work-edges.md +0 -78
  254. package/skills/finish-branch/SKILL.md +0 -117
  255. package/skills/finish-branch/references/integration-options.md +0 -80
  256. package/skills/handoff/SKILL.md +0 -82
  257. package/skills/handoff/references/handoff-templates.md +0 -150
  258. package/skills/launch-work/SKILL.md +0 -116
  259. package/skills/launch-work/references/launch-readiness.md +0 -85
  260. package/skills/migration-work/SKILL.md +0 -115
  261. package/skills/migration-work/references/migration-lifecycle.md +0 -82
  262. package/skills/release-work/SKILL.md +0 -118
  263. package/skills/release-work/references/release-evidence.md +0 -78
  264. package/skills/review-artifact/SKILL.md +0 -143
  265. package/skills/review-artifact/references/adjudicate-artifact-review.md +0 -101
  266. package/skills/review-artifact/references/independent-artifact-reviewer-contract.md +0 -159
  267. package/skills/review-work/references/adjudicate-work-review.md +0 -97
  268. package/skills/review-work/references/independent-work-reviewer-contract.md +0 -139
  269. package/skills/review-work/references/security-risk-lens.md +0 -67
  270. package/skills/setup-freeflow/references/activation-contract.md +0 -103
  271. package/skills/setup-freeflow/references/host-setup.md +0 -67
  272. package/skills/simplify-code/SKILL.md +0 -85
  273. package/skills/simplify-code/references/simplification-patterns.md +0 -70
  274. package/skills/verify-work/references/browser-runtime-evidence.md +0 -51
  275. package/skills/verify-work/references/integration-evidence.md +0 -49
  276. package/skills/verify-work/references/performance-evidence.md +0 -59
  277. package/skills/workflow/SKILL.md +0 -171
  278. package/skills/workflow/references/domain-skill-composition.md +0 -45
  279. package/skills/write-plan/SKILL.md +0 -92
  280. package/skills/write-plan/references/plan-shapes.md +0 -156
  281. package/skills/write-skill/references/activation-boundaries.md +0 -106
  282. package/skills/write-skill/references/agent-first-instructions.md +0 -133
  283. package/skills/write-skill/references/progressive-disclosure.md +0 -129
  284. package/skills/write-skill/references/skill-dependency-graphs.md +0 -192
  285. package/skills/write-spec/SKILL.md +0 -85
  286. package/skills/write-spec/references/artifact-standards.md +0 -86
  287. package/skills/write-spec/references/decision-records.md +0 -80
  288. package/skills/write-spec/references/spec-shapes.md +0 -143
  289. /package/skills/{evaluate-skill → evaluate-behavior}/scripts/lib/evidence.mjs +0 -0
  290. /package/skills/{evaluate-skill → evaluate-behavior}/scripts/pi-observer.mjs +0 -0
@@ -1,181 +0,0 @@
1
- import { createHash } from "node:crypto";
2
- import { lstatSync, readFileSync, realpathSync } from "node:fs";
3
- import path from "node:path";
4
-
5
- const PATH_TOOLS = new Set(["read", "write", "edit"]);
6
-
7
- function parseStringArray(value) {
8
- try {
9
- const parsed = JSON.parse(value ?? "[]");
10
- return Array.isArray(parsed) && parsed.every((entry) => typeof entry === "string") ? parsed : [];
11
- } catch {
12
- return [];
13
- }
14
- }
15
-
16
- function isContained(root, target) {
17
- const relative = path.relative(root, target);
18
- return relative === "" || (!relative.startsWith(`..${path.sep}`) && relative !== ".." && !path.isAbsolute(relative));
19
- }
20
-
21
- function resolveWritablePath(cwd, requested) {
22
- const absolute = path.resolve(cwd, requested);
23
- /** @type {string[]} */
24
- const missingSegments = [];
25
- let candidate = absolute;
26
- while (true) {
27
- try {
28
- return path.join(realpathSync(candidate), ...missingSegments);
29
- } catch {
30
- try {
31
- lstatSync(candidate);
32
- throw new Error(`Existing writable path cannot be resolved: ${requested}`);
33
- } catch (error) {
34
- if (error?.code !== "ENOENT" && error?.code !== "ENOTDIR") throw error;
35
- }
36
- const parent = path.dirname(candidate);
37
- if (parent === candidate) throw new Error(`Cannot resolve writable path: ${requested}`);
38
- missingSegments.unshift(path.basename(candidate));
39
- candidate = parent;
40
- }
41
- }
42
- }
43
-
44
- function escapeXml(value) {
45
- const entities = { "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;", "'": "&apos;" };
46
- return value.replace(/[&<>"']/g, (character) => entities[character]);
47
- }
48
-
49
- function loadDeclaredContext(manifestPath) {
50
- if (!manifestPath) return [];
51
- let manifest;
52
- try {
53
- manifest = JSON.parse(readFileSync(manifestPath, "utf8"));
54
- } catch (error) {
55
- throw new Error(
56
- `Declared context manifest cannot be read: ${error instanceof Error ? error.message : String(error)}`,
57
- );
58
- }
59
- if (manifest?.schema_version !== 1 || !Array.isArray(manifest.entries)) {
60
- throw new Error("Declared context manifest must use schema_version 1 and contain entries");
61
- }
62
- for (const entry of manifest.entries) {
63
- if (typeof entry?.declaredPath !== "string" || !Array.isArray(entry.files)) {
64
- throw new Error("Declared context manifest entry is malformed");
65
- }
66
- for (const file of entry.files) {
67
- if (
68
- typeof file?.path !== "string" ||
69
- typeof file.sha256 !== "string" ||
70
- typeof file.content !== "string" ||
71
- createHash("sha256").update(file.content).digest("hex") !== file.sha256
72
- ) {
73
- throw new Error(`Declared context file is malformed or changed: ${file?.path ?? "unknown"}`);
74
- }
75
- }
76
- }
77
- return manifest.entries;
78
- }
79
-
80
- function buildSubjectSystemPrompt(options, declaredContext) {
81
- const tools = options.selectedTools ?? [];
82
- const toolLines = tools.map((tool) => `- ${tool}: ${options.toolSnippets?.[tool] ?? "Declared evaluation tool"}`);
83
- const lines = [
84
- "You are an expert coding assistant operating inside pi, a coding agent harness.",
85
- "Help the user with the task using only the tools and resources listed below.",
86
- "",
87
- "Available tools:",
88
- ...(toolLines.length > 0 ? toolLines : ["(none)"]),
89
- "",
90
- "Guidelines:",
91
- "- Use read to load a skill's SKILL.md when the task matches its description.",
92
- "- Resolve relative skill resources from the skill directory.",
93
- "- Be concise in your response.",
94
- ];
95
- const skills = (options.skills ?? []).filter((skill) => !skill.disableModelInvocation);
96
- if (skills.length > 0) {
97
- lines.push("", "<available_skills>");
98
- for (const skill of skills) {
99
- lines.push(
100
- " <skill>",
101
- ` <name>${escapeXml(skill.name)}</name>`,
102
- ` <description>${escapeXml(skill.description)}</description>`,
103
- ` <location>${escapeXml(skill.filePath)}</location>`,
104
- " </skill>",
105
- );
106
- }
107
- lines.push("</available_skills>");
108
- }
109
- if (declaredContext.length > 0) lines.push("", renderDeclaredContext(declaredContext));
110
- lines.push(`Current working directory: ${options.cwd}`);
111
- return lines.join("\n");
112
- }
113
-
114
- function renderDeclaredContext(declaredContext) {
115
- const lines = ["<declared_context>"];
116
- for (const entry of declaredContext) {
117
- lines.push(` <context declared-path="${escapeXml(entry.declaredPath)}">`);
118
- for (const file of entry.files) {
119
- lines.push(` <file path="${escapeXml(file.path)}">\n${file.content}</file>`);
120
- }
121
- lines.push(" </context>");
122
- }
123
- lines.push("</declared_context>");
124
- return lines.join("\n");
125
- }
126
-
127
- // "isolated" replaces the host prompt with an evaluator-owned one; "host" keeps the host's own prompt
128
- // (and anything declared extensions compose onto it) so evidence reflects the production prompt.
129
- function beforeAgentStartHandler(promptMode, declaredContext) {
130
- if (promptMode === "isolated") {
131
- return (event) => ({ systemPrompt: buildSubjectSystemPrompt(event.systemPromptOptions, declaredContext) });
132
- }
133
- return (event) =>
134
- declaredContext.length === 0
135
- ? undefined
136
- : { systemPrompt: `${event.systemPrompt}\n\n${renderDeclaredContext(declaredContext)}` };
137
- }
138
-
139
- export default function registerSkillEvalGuard(pi) {
140
- const allowedRoots = parseStringArray(process.env.SKILL_EVAL_ALLOWED_ROOTS).map((root) => realpathSync(root));
141
- const writableRootValue = process.env.SKILL_EVAL_WRITABLE_ROOT;
142
- if (!writableRootValue) throw new Error("SKILL_EVAL_WRITABLE_ROOT is required");
143
- const writableRoot = realpathSync(writableRootValue);
144
- const allowedTools = new Set(parseStringArray(process.env.SKILL_EVAL_ALLOWED_TOOLS));
145
- const declaredContext = loadDeclaredContext(process.env.SKILL_EVAL_CONTEXT_MANIFEST);
146
- const promptMode = process.env.SKILL_EVAL_PROMPT_MODE || "isolated";
147
- if (promptMode !== "isolated" && promptMode !== "host") {
148
- throw new Error(`SKILL_EVAL_PROMPT_MODE must be isolated or host: ${promptMode}`);
149
- }
150
-
151
- pi.on("before_agent_start", beforeAgentStartHandler(promptMode, declaredContext));
152
-
153
- pi.on("tool_call", (event, ctx) => {
154
- if (!allowedTools.has(event.toolName)) {
155
- return { block: true, reason: `Tool is not declared for this evaluation: ${event.toolName}` };
156
- }
157
- if (!PATH_TOOLS.has(event.toolName)) return undefined;
158
- if (typeof event.input?.path !== "string") {
159
- return { block: true, reason: `${event.toolName} requires a path inside the evaluation environment` };
160
- }
161
-
162
- const requested = event.input.path.startsWith("@") ? event.input.path.slice(1) : event.input.path;
163
- let canonical;
164
- try {
165
- canonical =
166
- event.toolName === "write"
167
- ? resolveWritablePath(ctx.cwd, requested)
168
- : realpathSync(path.resolve(ctx.cwd, requested));
169
- } catch {
170
- return {
171
- block: true,
172
- reason: `${event.toolName} path cannot be resolved inside the evaluation environment: ${requested}`,
173
- };
174
- }
175
- const roots = event.toolName === "read" ? allowedRoots : [writableRoot];
176
- if (!roots.some((root) => isContained(root, canonical))) {
177
- return { block: true, reason: `${event.toolName} path escapes the evaluation environment: ${requested}` };
178
- }
179
- return undefined;
180
- });
181
- }
@@ -1,182 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- import { runEvaluation } from "./lib/runner.mjs";
4
- import { reviewResult } from "./lib/review.mjs";
5
- import { runTrials } from "./lib/trials.mjs";
6
- import { renderResult } from "./lib/view.mjs";
7
-
8
- const OPTIONS = {
9
- run: ["--group", "--variant", "--trials", "--max-cost"],
10
- view: ["--group", "--variant"],
11
- review: ["--group", "--model", "--thinking"],
12
- };
13
- const argv = process.argv.slice(2);
14
- const [command] = argv;
15
-
16
- function printUsage() {
17
- process.stdout.write(
18
- `Usage:
19
- skill-eval run <suite-or-group-path> [options]
20
- skill-eval view <result-id-or-directory> [options]
21
- skill-eval review <result-id-or-directory> --model <provider/model> [options]
22
-
23
- Commands:
24
- run Execute selected evaluation groups
25
- view Render selected stored evidence or a trial aggregate
26
- review Record an advisory, variant-blind model answer to each group's review questions
27
-
28
- Selectors:
29
- --group <id-or-position>
30
- --variant <baseline|candidate> (run, view)
31
-
32
- Run options:
33
- --trials <n> Run n independent complete invocations and record an aggregate
34
- --max-cost <total> Stop starting subjects once host-reported cost reaches the total
35
-
36
- Review options:
37
- --model <provider/model> Required reviewer model
38
- --thinking <level> Optional reviewer thinking level
39
-
40
- Paths:
41
- Definition paths resolve from the current working directory.
42
- Suite group references resolve relative to the suite file.
43
- Results are stored under <cwd>/.skill-eval/runs/<result-id>.
44
- view accepts a stored result or aggregate ID or an explicit directory.
45
-
46
- Selection:
47
- No selectors choose every suite group and both variants.
48
- --group is invalid for a direct group definition or result.
49
-
50
- Current run support:
51
- Description and explicit-body groups with prompt or ordered turns
52
- Working-tree or Git-backed ordered skills/context; optional fresh fixture copies
53
- Description tools: read; body tools: read, write, edit, run_command for declared commands, or declared extension tools
54
- Runtime profiles: Pi hosts, isolated or host system prompt, ordered immutable extension bundles, environment overrides
55
- Deterministic reads, paths, changed paths, text, JSON, tool calls, context observations, and factual comparisons
56
- Ordered suites run serially and continue after isolated variant, group, or post-processing failures
57
- Grade-first views show compact criterion details, usage, and result-relative artifact paths
58
- `,
59
- );
60
- }
61
-
62
- function fail(message, exitCode = 2) {
63
- process.stderr.write(`${message}\n`);
64
- process.exitCode = exitCode;
65
- }
66
-
67
- function parseOperation(values) {
68
- const [target, ...options] = values;
69
- if (!target) throw new Error(`skill-eval ${command} requires a target`);
70
- const allowed = OPTIONS[command];
71
- const parsed = { group: null, variant: null, trials: null, maxCost: null, model: null, thinking: null };
72
- const keys = {
73
- "--group": "group",
74
- "--variant": "variant",
75
- "--trials": "trials",
76
- "--max-cost": "maxCost",
77
- "--model": "model",
78
- "--thinking": "thinking",
79
- };
80
- for (let index = 0; index < options.length; index += 1) {
81
- const option = options[index];
82
- const value = options[index + 1];
83
- if (!allowed.includes(option)) throw new Error(`Unknown option: ${option}`);
84
- if (!value || value.startsWith("--")) throw new Error(`${option} requires a value`);
85
- const key = keys[option];
86
- if (parsed[key] !== null) throw new Error(`${option} may be supplied only once`);
87
- parsed[key] = value;
88
- index += 1;
89
- }
90
- let trials = 1;
91
- if (parsed.trials !== null) {
92
- trials = Number(parsed.trials);
93
- if (!/^\d+$/.test(parsed.trials) || trials < 1) throw new Error("--trials must be a positive integer");
94
- }
95
- let maxCost = null;
96
- if (parsed.maxCost !== null) {
97
- maxCost = Number(parsed.maxCost);
98
- if (!Number.isFinite(maxCost) || maxCost <= 0) throw new Error("--max-cost must be a positive number");
99
- }
100
- if (command === "review" && parsed.model === null) throw new Error("skill-eval review requires --model");
101
- return {
102
- target,
103
- selectors: { group: parsed.group, variant: parsed.variant },
104
- trials,
105
- maxCost,
106
- model: parsed.model,
107
- thinking: parsed.thinking,
108
- };
109
- }
110
-
111
- async function withCancellation(run) {
112
- const controller = new AbortController();
113
- const abort = () => controller.abort();
114
- process.once("SIGINT", abort);
115
- process.once("SIGTERM", abort);
116
- try {
117
- return await run(controller.signal);
118
- } finally {
119
- process.removeListener("SIGINT", abort);
120
- process.removeListener("SIGTERM", abort);
121
- }
122
- }
123
-
124
- function printResult(result) {
125
- process.stdout.write(`Result: ${result.id}\nPath: ${result.path}\nState: ${result.state}\n`);
126
- }
127
-
128
- async function run(operation) {
129
- const root = process.cwd();
130
- await withCancellation(async (signal) => {
131
- if (operation.trials === 1) {
132
- const budget = operation.maxCost === null ? null : { maxCost: operation.maxCost, spent: 0, exhausted: false };
133
- const result = await runEvaluation(operation.target, operation.selectors, { root, signal, budget });
134
- printResult(result);
135
- if (result.state !== "complete") process.exitCode = 1;
136
- return;
137
- }
138
- const aggregate = await runTrials(operation.target, operation.selectors, {
139
- root,
140
- signal,
141
- trials: operation.trials,
142
- maxCost: operation.maxCost,
143
- onTrial: printResult,
144
- });
145
- process.stdout.write(`Aggregate: ${aggregate.id}\nPath: ${aggregate.path}\nState: ${aggregate.state}\n`);
146
- if (aggregate.state !== "complete") process.exitCode = 1;
147
- });
148
- }
149
-
150
- async function review(operation) {
151
- const outcome = await withCancellation((signal) =>
152
- reviewResult(operation.target, operation.selectors, {
153
- root: process.cwd(),
154
- signal,
155
- model: operation.model,
156
- thinking: operation.thinking,
157
- }),
158
- );
159
- for (const group of outcome.groups) {
160
- process.stdout.write(`Review ${group.id}: ${group.state}${group.artifact ? ` (${group.artifact})` : ""}\n`);
161
- }
162
- if (outcome.groups.some((group) => group.state === "review-error")) process.exitCode = 1;
163
- }
164
-
165
- if (!command || command === "--help" || command === "-h") {
166
- printUsage();
167
- } else if (Object.hasOwn(OPTIONS, command)) {
168
- try {
169
- const operation = parseOperation(argv.slice(1));
170
- if (command === "view") {
171
- process.stdout.write(await renderResult(operation.target, operation.selectors, { root: process.cwd() }));
172
- } else if (command === "review") {
173
- await review(operation);
174
- } else {
175
- await run(operation);
176
- }
177
- } catch (error) {
178
- fail(error instanceof Error ? error.message : String(error), 1);
179
- }
180
- } else {
181
- fail(`Unknown command: ${command}`);
182
- }
@@ -1,78 +0,0 @@
1
- # Execute Work Edges
2
-
3
- Read this when execution resumes from uncertain prior state, changes the Slice boundary, reaches a selected checkpoint, or exposes separately controlled follow-on work.
4
-
5
- This reference is judgment: adapt it to the work. Its binding statements restate [Execute Work](../SKILL.md) or Workflow Rules.
6
-
7
- The main skill owns the normal bounded-action loop. This reference covers transitions that leave, resume, or constrain that loop.
8
-
9
- ## Resume Safely
10
-
11
- Recover the source that established the accepted work and compare it with relevant live state.
12
-
13
- When durable memory exists, enter [Track Work](../../track-work/SKILL.md) and use its required recovery route before relying on or mutating the Working Record. Memory preserves context; it does not prove live state or recreate authority.
14
-
15
- Resume the same Slice only while its intended result, authority, evidence boundary, and stop condition remain coherent. Otherwise preserve supported work and return the changed boundary to [Workflow](../../workflow/SKILL.md).
16
-
17
- Recover the user-facing return condition separately from the next internal action. A supported record may preserve approval for the remaining task, but a proposed next action is not that approval. After reconstruction, continue covered work rather than returning solely because a context boundary occurred.
18
-
19
- Do not restart discovery, repeat supported work, or infer progress from summaries, Plans, records, handoffs, staged files, or partial artifacts.
20
-
21
- ## Distinguish Adaptation From Boundary Change
22
-
23
- Routine changes to local mechanics, implementation order, tools, and focused checks remain inside the current bounded action when they preserve:
24
-
25
- - the accepted result;
26
- - permitted effects;
27
- - source truth;
28
- - the required observing boundary;
29
- - the stop condition.
30
-
31
- A mechanical read of a known caller or a local correction may remain inside execution. If new evidence invalidates the implementation premise, stop dependent edits and re-establish the approach; do not hide renewed investigation inside a patch stream.
32
-
33
- Before following a new prerequisite, identify whether it blocks the required outcome, the chosen approach, or only the current observer. Preserve acceptance, compare supported in-scope remedies, and return to Workflow when the remedy changes behavior, scope, persistence, compatibility, public interfaces, risk, evidence quality, or another user-owned outcome.
34
-
35
- Keep an accepted extension in the current Slice only when its result remains coherent, explicit authority covers the added effects, and the combined boundary can still be verified as one unit. When a Working Record exists, Track Work records the extension before execution.
36
-
37
- Use another Slice when the work has a distinct result, authority source, evidence boundary, independently useful outcome, or explicit abandonment of the original result. Context pressure may require an earlier safe continuation boundary without inventing a completed result or new Slice.
38
-
39
- A whole-task agreement may already cover later Slices. Return their selection and lifecycle to Workflow and Track Work without requesting redundant user permission. A selected checkpoint or the agreed user-facing endpoint still stops dependent work.
40
-
41
- ## Route A Selected Checkpoint
42
-
43
- A checkpoint is due only when Workflow, an approved Plan, repository policy, or explicit discussion selected it.
44
-
45
- Stop before dependent work, use the checkpoint’s owner, and return its result to Workflow:
46
-
47
- - [Decision Gate](../../decision-gate/SKILL.md) for a selected user decision;
48
- - [Review Work](../../review-work/SKILL.md) for selected independent judgment;
49
- - [Commit Work](../../commit-work/SKILL.md) for an authorized local commit;
50
- - [Handoff](../../handoff/SKILL.md) for selected continuity transfer;
51
- - [Finish Branch](../../finish-branch/SKILL.md), [Release Work](../../release-work/SKILL.md), or [Launch Work](../../launch-work/SKILL.md) for their separately authorized boundaries.
52
-
53
- When durable memory exists, Track Work preserves the checkpoint’s selection, condition, result, and task effect. Its Checkpoint types map to these owners:
54
-
55
- | Type | Owner |
56
- | --- | --- |
57
- | `preserve` | Commit Work |
58
- | `publish` | Commit Work for a simple push; otherwise Finish Branch or Release Work |
59
- | `review` | Review Work or Review Artifact |
60
- | `decision` | Decision Gate |
61
- | `continuity` | Handoff |
62
-
63
- Do not create a checkpoint merely because an action or Slice ended. Do not force a stale checkpoint when its condition, evidence, or protected boundary no longer holds; return the discrepancy for a supported cancellation, replacement, deferral, or revision before dependent work.
64
-
65
- ## Separate Follow-On Work
66
-
67
- Useful follow-on work is not implied authority.
68
-
69
- Return it to Workflow before using:
70
-
71
- - Commit Work for an unselected commit or push;
72
- - [Migration Work](../../migration-work/SKILL.md) for consumer, state, or traffic movement;
73
- - Finish Branch for integration, preservation, discard, or branch cleanup;
74
- - Release Work for versioned publication;
75
- - Launch Work for production exposure, rollback, or recovery;
76
- - Handoff for point-in-time continuation transfer.
77
-
78
- Preserve the supported execution result before routing away. A follow-on owner does not retroactively change the completed action or Current Slice.
@@ -1,117 +0,0 @@
1
- ---
2
- name: finish-branch
3
- description: Use when deciding how to integrate, preserve, or discard work on a branch or isolated checkout.
4
- ---
5
-
6
- # Finish Branch
7
-
8
- Close a branch or isolated checkout without confusing readiness, integration, publication, and cleanup authority.
9
-
10
- A verified branch does not authorize merge or push. A chosen integration route does not automatically authorize branch deletion, worktree removal, release, or deployment.
11
-
12
- ## Inspect The Exact State
13
-
14
- Before offering or executing a route, inspect:
15
-
16
- - current branch, detached state, repository root, and worktree ownership;
17
- - base branch or merge base supported by repository evidence;
18
- - commits and diff relative to the base;
19
- - staged, unstaged, and untracked work;
20
- - upstream, remote, and ahead/behind state;
21
- - fresh verification, silent self-review, and any selected independent-review status;
22
- - CI, policy, or repository gates relevant to the intended route.
23
-
24
- Do not infer the base, remote destination, pull-request target, or workspace owner when the wrong choice could lose work or affect collaborators.
25
-
26
- After inspecting branch, base, remote, dirty state, verification, and workspace ownership, read [integration options](references/integration-options.md) before choosing local integration, pull request, preservation, discard, or cleanup. Use [Commit Work](../commit-work/SKILL.md) when the selected route requires a local commit or simple push; do not commit merely to make branch status look finished.
27
-
28
- Use [Release Work](../release-work/SKILL.md) for a separately approved versioned release and [Launch Work](../launch-work/SKILL.md) for a separately approved production deployment or rollout.
29
-
30
- ## Keep Route Authority Explicit
31
-
32
- Loading this skill, asking whether a branch is ready, or approving a general implementation Plan does not authorize merge, rebase, push, pull-request creation, branch deletion, worktree removal, discard, force push, release, or deployment.
33
-
34
- The user owns whether to:
35
-
36
- - integrate locally and by which repository-supported method;
37
- - push or create/update a normal or draft pull request;
38
- - preserve the branch, worktree, or dirty state;
39
- - discard commits or uncommitted work;
40
- - delete local or remote branches;
41
- - rewrite or force-push history;
42
- - clean up a checkout or worktree.
43
-
44
- Present only routes supported by the observed state. Do not force a fixed menu when an option is impossible, unsafe, or irrelevant. Approval of one route covers only the scope shown and accepted.
45
-
46
- ## State Readiness Honestly
47
-
48
- Present a branch as ready for its intended integration boundary only when:
49
-
50
- - the accepted branch outcome is clear;
51
- - intended commits and remaining dirty state are known;
52
- - fresh direct evidence supports the branch claim;
53
- - silent self-review has no unresolved material issue;
54
- - any selected independent review is resolved for the unchanged state;
55
- - no source conflict, owner decision, required evidence gap, or repository gate blocks the route.
56
-
57
- Read [Verify Work](../verify-work/SKILL.md) when matching branch-readiness claims to evidence. A feature-branch pass does not prove the integrated result.
58
-
59
- Unverified or failing work may still be preserved, handed off, or shared through an explicitly approved draft route. State the gaps; do not describe it as integration-ready.
60
-
61
- ## Execute Only The Chosen Route
62
-
63
- ### Local Integration
64
-
65
- - refresh base evidence without overwriting local work;
66
- - use the repository's accepted merge or rebase policy;
67
- - stop when a conflict requires a behavior, source, or owner decision;
68
- - verify the integrated result on the resulting base state;
69
- - delete branch or worktree state only when cleanup was included in the approved route and integration verification succeeded.
70
-
71
- ### Pull Request
72
-
73
- - inspect remote and upstream state before pushing;
74
- - push only intended commits to the accepted destination;
75
- - create or update the pull request using repository conventions;
76
- - mark incomplete or failing work as draft when that is the approved route;
77
- - report CI, review, merge, migration, release, or launch requirements still pending;
78
- - preserve the worktree when iteration or feedback may continue.
79
-
80
- A pull-request URL proves creation, not readiness or merge.
81
-
82
- ### Preserve
83
-
84
- Report the branch, worktree, commit and dirty state, evidence status, reason preserved, and next approved route. Read [Handoff](../handoff/SKILL.md) only when continuation needs durable transfer context.
85
-
86
- ### Discard
87
-
88
- Before destructive action, state exactly which commits, paths, branches, worktrees, and remote state would be lost and what remains recoverable. Require explicit confirmation for that concrete scope.
89
-
90
- Do not treat “finish,” “clean up,” a menu number, or approval of integration as confirmation for broader destruction.
91
-
92
- ## Protect Workspace Ownership
93
-
94
- Do not remove a worktree, checkout, session, or harness state you did not create or are not authorized to manage. If ownership is unclear, preserve it and report the uncertainty.
95
-
96
- Do not run destructive reset, clean, branch deletion, worktree removal, remote deletion, or force push merely to produce a clean status.
97
-
98
- ## Return Conflicts And Failures
99
-
100
- Resolve a conflict locally only when both sides' intended behavior is settled and the resolution is mechanical. Return behavior, source-truth, API, data, security, compatibility, or architecture conflicts to [Workflow](../workflow/SKILL.md).
101
-
102
- Use [Diagnose Failure](../diagnose-failure/SKILL.md) when integrated checks fail without a supported cause. Return mixed or unrelated branch contents to [Commit Work](../commit-work/SKILL.md), which owns staging decisions. Preserve branch state before re-entering another owning activity.
103
-
104
- ## Report The Chosen Outcome
105
-
106
- Report:
107
-
108
- - branch, base, and selected route;
109
- - commit and dirty state handled or preserved;
110
- - integration, push, or pull-request result;
111
- - verification on the final observed state;
112
- - selected-review and repository-gate status;
113
- - cleanup performed or deliberately omitted;
114
- - unresolved CI, review, migration, release, or deployment work;
115
- - recoverability and next approved route.
116
-
117
- Branch closeout is complete only for the chosen route. A pushed branch is not merged, a merged branch is not released, and a released artifact is not deployed.
@@ -1,80 +0,0 @@
1
- # Integration Options
2
-
3
- Read this after inspecting branch, base, remote, dirty state, verification, and workspace ownership and before choosing local integration, pull request, preservation, discard, or cleanup.
4
-
5
- ## Local Integration
6
-
7
- Appropriate when the user wants the branch integrated locally and repository policy permits it.
8
-
9
- Before cleanup:
10
-
11
- 1. preserve or resolve dirty state deliberately;
12
- 2. update base evidence safely;
13
- 3. integrate without rewriting unrelated history;
14
- 4. run the checks that prove the combined result;
15
- 5. inspect final log and status;
16
- 6. remove branch/worktree state only after success.
17
-
18
- A feature-branch pass does not prove the merged result.
19
-
20
- ## Pull Request
21
-
22
- Appropriate when review, CI, collaboration, protected branches, or remote integration owns the next gate.
23
-
24
- Capture:
25
-
26
- - target branch and commit range;
27
- - intended push/upstream behavior;
28
- - PR summary and source requirements;
29
- - verification already run;
30
- - known residuals, migrations, rollout, or compatibility notes;
31
- - required reviewers or checks from repo policy.
32
-
33
- A draft pull request may preserve or share incomplete work when that route is explicitly approved. State failing or unavailable evidence. Do not claim merge readiness from a pull-request URL alone.
34
-
35
- ## Keep For Later
36
-
37
- Appropriate when work is valid but integration is deferred, feedback is expected, or environment ownership prevents cleanup.
38
-
39
- Report:
40
-
41
- ```text
42
- Branch / worktree:
43
- Commit and dirty state:
44
- Review / verification:
45
- Reason preserved:
46
- Next action:
47
- Stop conditions:
48
- ```
49
-
50
- ## Discard
51
-
52
- Classify what is recoverable before deleting:
53
-
54
- - uncommitted changes may be unrecoverable;
55
- - local commits may be recoverable through reflog for a limited time;
56
- - pushed commits may affect collaborators;
57
- - worktrees may be harness-owned;
58
- - remote branch deletion has a different scope from local cleanup.
59
-
60
- Show the exact destructive operations and require explicit confirmation that matches their scope.
61
-
62
- ## Detached Or Managed Checkouts
63
-
64
- Do not assume a detached checkout is disposable. It may be owned by an IDE, CI system, coding harness, or external worktree manager.
65
-
66
- Offer only routes supported by that environment, such as creating a named branch, preserving the checkout, exporting a patch, or asking the harness to close it.
67
-
68
- ## Conflict Handling
69
-
70
- Mechanical conflict resolution is safe only when both sides' intended behavior is already settled.
71
-
72
- Stop when conflict resolution would choose between:
73
-
74
- - competing product or API behavior;
75
- - changed tests versus changed implementation;
76
- - incompatible migrations or data ownership;
77
- - security, privacy, billing, permissions, or compatibility policies;
78
- - two architecture directions.
79
-
80
- Return the conflict and evidence to Workflow. The next route may be review, diagnosis, Decision Gate, Spec revision, or Plan revision—not “take ours” or “take theirs.”