@hassangameryt/freeflow 0.4.0 → 0.6.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 (285) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/.claude-plugin/plugin.json +2 -1
  3. package/.codex-plugin/plugin.json +2 -1
  4. package/README.md +150 -155
  5. package/capabilities/cognitive-routing/SKILL.md +229 -0
  6. package/capabilities/context-virtualization/SKILL.md +103 -0
  7. package/capabilities/conversation-history/SKILL.md +53 -0
  8. package/command-surface.json +17 -13
  9. package/hooks/freeflow-runtime-context.mjs +393 -159
  10. package/hooks/hooks.json +26 -1
  11. package/hooks/tests/check-runtime-context-hook.sh +223 -54
  12. package/package.json +25 -16
  13. package/pi-extension/dist/cognitive-routing/commands.js +96 -0
  14. package/pi-extension/dist/cognitive-routing/config.js +236 -0
  15. package/pi-extension/dist/cognitive-routing/controller.js +862 -0
  16. package/pi-extension/dist/cognitive-routing/history.js +439 -0
  17. package/pi-extension/dist/cognitive-routing/host.js +126 -0
  18. package/pi-extension/dist/cognitive-routing/runtime.js +43 -0
  19. package/pi-extension/dist/cognitive-routing/tool.js +211 -0
  20. package/pi-extension/dist/cognitive-routing/types.js +6 -0
  21. package/pi-extension/dist/context-virtualization/commands.js +89 -0
  22. package/pi-extension/dist/context-virtualization/projector.js +42 -0
  23. package/pi-extension/dist/context-virtualization/runtime.js +356 -0
  24. package/pi-extension/dist/context-virtualization/state.js +57 -0
  25. package/pi-extension/dist/context-virtualization/types.js +10 -0
  26. package/pi-extension/dist/conversation-history/passages.js +66 -0
  27. package/pi-extension/dist/conversation-history/ranking.js +105 -0
  28. package/pi-extension/dist/conversation-history/runtime.js +226 -0
  29. package/pi-extension/dist/conversation-history/search.js +56 -0
  30. package/pi-extension/dist/conversation-history/types.js +1 -0
  31. package/pi-extension/dist/freeflow-context/resolver.js +120 -0
  32. package/pi-extension/dist/freeflow-context/runtime.js +80 -0
  33. package/pi-extension/dist/freeflow-context/source-projector.js +95 -0
  34. package/pi-extension/dist/freeflow-context/tool.js +308 -0
  35. package/pi-extension/dist/freeflow-context/types.js +12 -0
  36. package/pi-extension/dist/freeflow-context/visibility.js +28 -0
  37. package/pi-extension/dist/index.js +516 -98
  38. package/pi-extension/dist/runtime/runtime-context.js +318 -271
  39. package/pi-extension/dist/runtime/runtime-identity.js +5 -0
  40. package/pi-extension/dist/settings/settings-tui.js +78 -0
  41. package/pi-extension/dist/settings/settings-ui.js +593 -563
  42. package/pi-extension/dist/ui/text-component.js +57 -0
  43. package/pi-extension/src/cognitive-routing/commands.ts +119 -0
  44. package/pi-extension/src/cognitive-routing/config.ts +307 -0
  45. package/pi-extension/src/cognitive-routing/controller.ts +1118 -0
  46. package/pi-extension/src/cognitive-routing/history.ts +638 -0
  47. package/pi-extension/src/cognitive-routing/host.ts +172 -0
  48. package/pi-extension/src/cognitive-routing/runtime.ts +57 -0
  49. package/pi-extension/src/cognitive-routing/tool.ts +272 -0
  50. package/pi-extension/src/cognitive-routing/types.ts +89 -0
  51. package/pi-extension/src/context-virtualization/commands.ts +111 -0
  52. package/pi-extension/src/context-virtualization/projector.ts +62 -0
  53. package/pi-extension/src/context-virtualization/runtime.ts +406 -0
  54. package/pi-extension/src/context-virtualization/state.ts +79 -0
  55. package/pi-extension/src/context-virtualization/types.ts +92 -0
  56. package/pi-extension/src/conversation-history/passages.ts +81 -0
  57. package/pi-extension/src/conversation-history/ranking.ts +155 -0
  58. package/pi-extension/src/conversation-history/runtime.ts +250 -0
  59. package/pi-extension/src/conversation-history/search.ts +79 -0
  60. package/pi-extension/src/conversation-history/types.ts +31 -0
  61. package/pi-extension/src/freeflow-context/resolver.ts +139 -0
  62. package/pi-extension/src/freeflow-context/runtime.ts +100 -0
  63. package/pi-extension/src/freeflow-context/source-projector.ts +106 -0
  64. package/pi-extension/src/freeflow-context/tool.ts +360 -0
  65. package/pi-extension/src/freeflow-context/types.ts +70 -0
  66. package/pi-extension/src/freeflow-context/visibility.ts +53 -0
  67. package/pi-extension/src/index.ts +553 -101
  68. package/pi-extension/src/runtime/runtime-context.ts +339 -281
  69. package/pi-extension/src/runtime/runtime-identity.ts +8 -0
  70. package/pi-extension/src/settings/settings-tui.ts +93 -0
  71. package/pi-extension/src/settings/settings-ui.ts +700 -613
  72. package/pi-extension/src/ui/text-component.ts +66 -0
  73. package/pi-extension/tests/cognitive-routing/commands.test.js +134 -0
  74. package/pi-extension/tests/cognitive-routing/controller.test.js +1099 -0
  75. package/pi-extension/tests/cognitive-routing/extension-lifecycle.test.js +1071 -0
  76. package/pi-extension/tests/cognitive-routing/history.test.js +274 -0
  77. package/pi-extension/tests/cognitive-routing/host-fixture.js +4 -0
  78. package/pi-extension/tests/cognitive-routing/host-identity.test.js +63 -0
  79. package/pi-extension/tests/cognitive-routing/profile-resolution.test.js +236 -0
  80. package/pi-extension/tests/cognitive-routing/tool.test.js +230 -0
  81. package/pi-extension/tests/context-virtualization/extension.test.js +749 -0
  82. package/pi-extension/tests/context-virtualization/projector.test.js +110 -0
  83. package/pi-extension/tests/context-virtualization/runtime.test.js +216 -0
  84. package/pi-extension/tests/conversation-history/runtime.test.js +98 -0
  85. package/pi-extension/tests/conversation-history/search.test.js +97 -0
  86. package/pi-extension/tests/integration/pi-extension.test.js +928 -2047
  87. package/pi-extension/tests/integration/prompt-architecture.test.js +305 -0
  88. package/runtime/prompts/cognitive-routing.md +9 -0
  89. package/runtime/prompts/context-virtualization.md +3 -0
  90. package/runtime/prompts/conversation-history.md +3 -0
  91. package/runtime/prompts/core.md +13 -0
  92. package/runtime/prompts/interaction-contract.md +7 -0
  93. package/runtime/prompts/skills.md +65 -0
  94. package/skills/action-selection/SKILL.md +91 -0
  95. package/skills/bypass/SKILL.md +3 -2
  96. package/skills/commit-work/SKILL.md +1 -1
  97. package/skills/commit-work/references/staging-decisions.md +1 -1
  98. package/skills/decision-gate/SKILL.md +1 -1
  99. package/skills/design-for-depth/SKILL.md +14 -33
  100. package/skills/design-for-depth/references/design-pressure-signals.md +1 -1
  101. package/skills/design-for-depth/references/interface-design-loop.md +1 -1
  102. package/skills/design-for-depth/references/software-design-philosophy.md +1 -1
  103. package/skills/diagnose-failure/SKILL.md +20 -14
  104. package/skills/diagnose-failure/references/diagnostic-loop-catalog.md +1 -3
  105. package/skills/diagnose-failure/references/{flaky-and-performance.md → flaky-and-performance-diagnosis.md} +1 -1
  106. package/skills/discuss/SKILL.md +34 -22
  107. package/skills/discuss/references/discussion-continuity.md +71 -0
  108. package/skills/evaluate-skill/SKILL.md +5 -5
  109. package/skills/evaluate-skill/references/{definition-schema.md → evaluation-definition-schema.md} +42 -2
  110. package/skills/evaluate-skill/references/execution-and-evidence.md +8 -3
  111. package/skills/evaluate-skill/scripts/lib/definitions.mjs +114 -3
  112. package/skills/evaluate-skill/scripts/lib/grade-interaction.mjs +156 -1
  113. package/skills/evaluate-skill/scripts/lib/grade.mjs +9 -1
  114. package/skills/evaluate-skill/scripts/lib/pi.mjs +147 -32
  115. package/skills/evaluate-skill/scripts/lib/rpc.mjs +4 -4
  116. package/skills/evaluate-skill/scripts/lib/runner.mjs +36 -14
  117. package/skills/evaluate-skill/scripts/lib/sandbox.mjs +92 -0
  118. package/skills/evaluate-skill/scripts/pi-guard.mjs +1 -1
  119. package/skills/evaluate-skill/scripts/pi-observer.mjs +66 -0
  120. package/skills/evaluate-skill/scripts/skill-eval.mjs +6 -5
  121. package/skills/execute-work/SKILL.md +18 -15
  122. package/skills/execute-work/references/code-practices.md +1 -1
  123. package/skills/execute-work/references/execute-work-edges.md +42 -0
  124. package/skills/finish-branch/SKILL.md +2 -2
  125. package/skills/finish-branch/references/integration-options.md +1 -1
  126. package/skills/handoff/SKILL.md +3 -3
  127. package/skills/launch-work/SKILL.md +1 -1
  128. package/skills/launch-work/references/launch-readiness.md +2 -2
  129. package/skills/migration-work/SKILL.md +2 -2
  130. package/skills/migration-work/references/migration-lifecycle.md +1 -1
  131. package/skills/mode-contract/SKILL.md +32 -10
  132. package/skills/release-work/SKILL.md +1 -1
  133. package/skills/release-work/references/release-evidence.md +1 -1
  134. package/skills/review-artifact/SKILL.md +28 -26
  135. package/skills/review-work/SKILL.md +28 -26
  136. package/skills/review-work/references/{reviewer-prompt.md → independent-work-reviewer-contract.md} +1 -1
  137. package/skills/review-work/references/security-risk-lens.md +1 -1
  138. package/skills/setup-freeflow/SKILL.md +6 -10
  139. package/skills/setup-freeflow/references/activation-contract.md +5 -10
  140. package/skills/setup-freeflow/references/host-setup.md +3 -7
  141. package/skills/simplify-code/SKILL.md +1 -1
  142. package/skills/simplify-code/references/simplification-patterns.md +1 -1
  143. package/skills/tdd/SKILL.md +18 -38
  144. package/skills/tdd/references/test-design.md +2 -2
  145. package/skills/track-work/SKILL.md +362 -58
  146. package/skills/track-work/scripts/lib/codec.mjs +570 -0
  147. package/skills/track-work/scripts/lib/commands.mjs +568 -0
  148. package/skills/track-work/scripts/lib/contract.mjs +303 -0
  149. package/skills/track-work/scripts/lib/model.mjs +506 -0
  150. package/skills/track-work/scripts/lib/operations.mjs +965 -0
  151. package/skills/track-work/scripts/lib/record-store.mjs +264 -0
  152. package/skills/track-work/scripts/lib/result.mjs +37 -0
  153. package/skills/track-work/scripts/lib/rewrites.mjs +740 -0
  154. package/skills/track-work/scripts/lib/schema.mjs +277 -0
  155. package/skills/track-work/scripts/lib/source-inventory.mjs +162 -0
  156. package/skills/track-work/scripts/lib/views.mjs +443 -0
  157. package/skills/track-work/scripts/lib/workspace.mjs +134 -0
  158. package/skills/track-work/scripts/working-record.mjs +122 -0
  159. package/skills/verify-work/SKILL.md +14 -2
  160. package/skills/verify-work/references/browser-runtime-evidence.md +1 -1
  161. package/skills/verify-work/references/integration-evidence.md +1 -1
  162. package/skills/verify-work/references/performance-evidence.md +1 -1
  163. package/skills/workflow/SKILL.md +105 -53
  164. package/skills/workflow/references/domain-skill-composition.md +22 -42
  165. package/skills/write-plan/SKILL.md +1 -1
  166. package/skills/write-skill/SKILL.md +3 -2
  167. package/skills/write-skill/references/progressive-disclosure.md +17 -3
  168. package/pi-extension/dist/output-router/host-producer-identification.js +0 -232
  169. package/pi-extension/dist/output-router/native-safety-net.js +0 -216
  170. package/pi-extension/dist/output-router/observed-tool-routing.js +0 -122
  171. package/pi-extension/dist/output-router/renderers.js +0 -1023
  172. package/pi-extension/dist/output-router/router-tools.js +0 -554
  173. package/pi-extension/dist/output-router/schemas.js +0 -383
  174. package/pi-extension/dist/output-router/status.js +0 -744
  175. package/pi-extension/dist/output-router/utils.js +0 -502
  176. package/pi-extension/src/output-router/host-producer-identification.ts +0 -256
  177. package/pi-extension/src/output-router/native-safety-net.ts +0 -248
  178. package/pi-extension/src/output-router/observed-tool-routing.ts +0 -134
  179. package/pi-extension/src/output-router/renderers.ts +0 -1108
  180. package/pi-extension/src/output-router/router-tools.ts +0 -579
  181. package/pi-extension/src/output-router/schemas.ts +0 -387
  182. package/pi-extension/src/output-router/status.ts +0 -791
  183. package/pi-extension/src/output-router/utils.ts +0 -554
  184. package/pi-extension/tests/output-router/observed-producers.test.js +0 -132
  185. package/pi-extension/tests/output-router/search.test.js +0 -722
  186. package/router/dist/benchmarks/benchmark-harness.d.ts +0 -35
  187. package/router/dist/benchmarks/benchmark-harness.js +0 -92
  188. package/router/dist/benchmarks/benchmarks.d.ts +0 -109
  189. package/router/dist/benchmarks/benchmarks.js +0 -979
  190. package/router/dist/benchmarks/codex-qa-benchmarks.d.ts +0 -95
  191. package/router/dist/benchmarks/codex-qa-benchmarks.js +0 -500
  192. package/router/dist/benchmarks/command-benchmarks.d.ts +0 -143
  193. package/router/dist/benchmarks/command-benchmarks.js +0 -698
  194. package/router/dist/benchmarks/context-mode-normalized-benchmarks.d.ts +0 -82
  195. package/router/dist/benchmarks/context-mode-normalized-benchmarks.js +0 -773
  196. package/router/dist/benchmarks/context-mode-real-deep-benchmark.d.ts +0 -132
  197. package/router/dist/benchmarks/context-mode-real-deep-benchmark.js +0 -1380
  198. package/router/dist/benchmarks/context-saving-baseline.d.ts +0 -60
  199. package/router/dist/benchmarks/context-saving-baseline.js +0 -470
  200. package/router/dist/benchmarks/index-benchmarks.d.ts +0 -103
  201. package/router/dist/benchmarks/index-benchmarks.js +0 -862
  202. package/router/dist/benchmarks/storage-policy-benchmarks.d.ts +0 -101
  203. package/router/dist/benchmarks/storage-policy-benchmarks.js +0 -618
  204. package/router/dist/benchmarks/vault-index-benchmarks.d.ts +0 -56
  205. package/router/dist/benchmarks/vault-index-benchmarks.js +0 -322
  206. package/router/dist/config/config.d.ts +0 -103
  207. package/router/dist/config/config.js +0 -632
  208. package/router/dist/config/router-contract.d.ts +0 -10
  209. package/router/dist/config/router-contract.js +0 -54
  210. package/router/dist/config/schema.d.ts +0 -27
  211. package/router/dist/config/schema.js +0 -648
  212. package/router/dist/config/types.d.ts +0 -573
  213. package/router/dist/config/types.js +0 -41
  214. package/router/dist/evidence/bounded-evidence.d.ts +0 -40
  215. package/router/dist/evidence/bounded-evidence.js +0 -323
  216. package/router/dist/evidence/evidence-range-selector.d.ts +0 -24
  217. package/router/dist/evidence/evidence-range-selector.js +0 -232
  218. package/router/dist/evidence/evidence-search.d.ts +0 -27
  219. package/router/dist/evidence/evidence-search.js +0 -490
  220. package/router/dist/evidence/evidence.d.ts +0 -38
  221. package/router/dist/evidence/evidence.js +0 -200
  222. package/router/dist/evidence/failure-contracts.d.ts +0 -37
  223. package/router/dist/evidence/failure-contracts.js +0 -166
  224. package/router/dist/evidence/line-ranges.d.ts +0 -24
  225. package/router/dist/evidence/line-ranges.js +0 -22
  226. package/router/dist/experiments/local-index.d.ts +0 -64
  227. package/router/dist/experiments/local-index.js +0 -581
  228. package/router/dist/index.d.ts +0 -30
  229. package/router/dist/index.js +0 -32
  230. package/router/dist/local/local-traversal.d.ts +0 -18
  231. package/router/dist/local/local-traversal.js +0 -334
  232. package/router/dist/processing/engine.d.ts +0 -132
  233. package/router/dist/processing/engine.js +0 -533
  234. package/router/dist/processing/reducers.d.ts +0 -280
  235. package/router/dist/processing/reducers.js +0 -1673
  236. package/router/dist/processing/renderers.d.ts +0 -31
  237. package/router/dist/processing/renderers.js +0 -195
  238. package/router/dist/processing/scripts.d.ts +0 -91
  239. package/router/dist/processing/scripts.js +0 -386
  240. package/router/dist/repo/repo-traversal.d.ts +0 -18
  241. package/router/dist/repo/repo-traversal.js +0 -245
  242. package/router/dist/routing/observed-reducers.d.ts +0 -41
  243. package/router/dist/routing/observed-reducers.js +0 -661
  244. package/router/dist/routing/observed-routing.d.ts +0 -26
  245. package/router/dist/routing/observed-routing.js +0 -378
  246. package/router/dist/routing/parsers.d.ts +0 -16
  247. package/router/dist/routing/parsers.js +0 -521
  248. package/router/dist/routing/run-filters.d.ts +0 -60
  249. package/router/dist/routing/run-filters.js +0 -238
  250. package/router/dist/routing/run-reducers.d.ts +0 -49
  251. package/router/dist/routing/run-reducers.js +0 -122
  252. package/router/dist/sandbox/adapter-roots.d.ts +0 -46
  253. package/router/dist/sandbox/adapter-roots.js +0 -66
  254. package/router/dist/sandbox/eryx-python-adapter.d.ts +0 -13
  255. package/router/dist/sandbox/eryx-python-adapter.js +0 -868
  256. package/router/dist/sandbox/jq-wasm-adapter.d.ts +0 -9
  257. package/router/dist/sandbox/jq-wasm-adapter.js +0 -429
  258. package/router/dist/sandbox/quickjs-wasi-adapter.d.ts +0 -13
  259. package/router/dist/sandbox/quickjs-wasi-adapter.js +0 -384
  260. package/router/dist/sandbox/script-sandbox.d.ts +0 -134
  261. package/router/dist/sandbox/script-sandbox.js +0 -337
  262. package/router/dist/setup/script-transform-adapters.d.ts +0 -32
  263. package/router/dist/setup/script-transform-adapters.js +0 -278
  264. package/router/dist/tools/batch.d.ts +0 -33
  265. package/router/dist/tools/batch.js +0 -586
  266. package/router/dist/tools/run.d.ts +0 -62
  267. package/router/dist/tools/run.js +0 -1304
  268. package/router/dist/tools/search.d.ts +0 -66
  269. package/router/dist/tools/search.js +0 -1364
  270. package/router/dist/transform/engine.d.ts +0 -168
  271. package/router/dist/transform/engine.js +0 -2072
  272. package/router/dist/vault/vault-index.d.ts +0 -125
  273. package/router/dist/vault/vault-index.js +0 -416
  274. package/router/dist/vault/vault.d.ts +0 -138
  275. package/router/dist/vault/vault.js +0 -630
  276. package/runtime/interaction-contract.md +0 -16
  277. package/skills/discuss/references/checkpoints.md +0 -66
  278. package/skills/execute-work/references/execution-loop.md +0 -77
  279. package/skills/output-router/SKILL.md +0 -206
  280. package/skills/output-router/references/safety-policy.md +0 -40
  281. package/skills/setup-freeflow/references/output-router-setup.md +0 -110
  282. package/skills/track-work/references/working-record-schema.md +0 -378
  283. package/skills/workflow/references/workflow-loop.md +0 -92
  284. /package/skills/handoff/references/{templates.md → handoff-templates.md} +0 -0
  285. /package/skills/review-artifact/references/{reviewer-prompt.md → independent-artifact-reviewer-contract.md} +0 -0
@@ -69,6 +69,98 @@ export async function materializeFixture({ fixture, workspace }) {
69
69
  return { ...fixture, materializedPath };
70
70
  }
71
71
 
72
+ export async function prepareRuntime({ runtime, root, groupDirectory }) {
73
+ const canonicalRoot = await realpath(root);
74
+ const runtimeRoot = path.join(groupDirectory, "resources", "runtime", "extensions");
75
+ await mkdir(runtimeRoot, { recursive: true });
76
+ const bundles = [];
77
+
78
+ for (const [index, bundle] of runtime.extensions.entries()) {
79
+ const bundleRoot = path.join(runtimeRoot, String(index));
80
+ await mkdir(bundleRoot, { recursive: true });
81
+ const resources = [];
82
+ for (const declaredPath of bundle.resources) {
83
+ resources.push(
84
+ await snapshotWorkingTreeResource({
85
+ canonicalRoot,
86
+ declaredPath,
87
+ destination: path.join(bundleRoot, declaredPath),
88
+ requireDirectory: true,
89
+ label: "runtime resource",
90
+ }),
91
+ );
92
+ }
93
+ const root = await realpath(bundleRoot);
94
+ const entry = await realpath(path.join(root, bundle.entry)).catch(() => null);
95
+ if (entry === null || !isContained(root, entry)) {
96
+ throw new Error(`declared runtime entry is missing or escapes its bundle: ${bundle.entry}`);
97
+ }
98
+ const entryStat = await lstat(entry);
99
+ if (!entryStat.isFile()) throw new Error(`declared runtime entry is not a file: ${bundle.entry}`);
100
+ if (!resources.some((resource) => isContained(resource.path, entry))) {
101
+ throw new Error(`declared runtime entry is not contained by a resource: ${bundle.entry}`);
102
+ }
103
+ bundles.push({
104
+ entry,
105
+ root,
106
+ resources,
107
+ });
108
+ }
109
+
110
+ return {
111
+ host: runtime.host,
112
+ session: runtime.session,
113
+ environment: { ...runtime.environment },
114
+ extensions: bundles,
115
+ };
116
+ }
117
+
118
+ export async function materializeRuntime({ runtime, variantDirectory }) {
119
+ const runtimeRoot = path.join(variantDirectory, "resources", "runtime", "extensions");
120
+ await mkdir(runtimeRoot, { recursive: true });
121
+ const bundles = [];
122
+
123
+ for (const [index, bundle] of runtime.extensions.entries()) {
124
+ const destination = path.join(runtimeRoot, String(index));
125
+ await cp(bundle.root, destination, {
126
+ recursive: true,
127
+ dereference: false,
128
+ errorOnExist: true,
129
+ force: false,
130
+ });
131
+ const root = await realpath(destination);
132
+ const resources = [];
133
+ for (const resource of bundle.resources) {
134
+ const resourceRoot = await realpath(path.join(root, resource.declaredPath));
135
+ const files = await fingerprintDirectory(resourceRoot);
136
+ if (JSON.stringify(files) !== JSON.stringify(resource.files)) {
137
+ throw new Error(`declared runtime resource changed while being copied: ${resource.declaredPath}`);
138
+ }
139
+ resources.push({ ...resource, path: resourceRoot, files });
140
+ }
141
+ const entry = await realpath(path.join(root, path.relative(bundle.root, bundle.entry)));
142
+ bundles.push({ ...bundle, entry, root, resources });
143
+ }
144
+
145
+ return {
146
+ host: runtime.host,
147
+ session: runtime.session,
148
+ environment: { ...runtime.environment },
149
+ extensions: bundles,
150
+ };
151
+ }
152
+
153
+ export async function verifyRuntime(runtime) {
154
+ for (const bundle of runtime.extensions) {
155
+ for (const resource of bundle.resources) {
156
+ const current = await fingerprintDirectory(resource.path);
157
+ if (JSON.stringify(current) !== JSON.stringify(resource.files)) {
158
+ throw new Error(`declared runtime resource changed during subject execution: ${resource.declaredPath}`);
159
+ }
160
+ }
161
+ }
162
+ }
163
+
72
164
  export async function materializeEnvironment({ environment, root, variantDirectory }) {
73
165
  const canonicalRoot = await realpath(root);
74
166
  let source;
@@ -15,7 +15,7 @@ function parseStringArray(value) {
15
15
 
16
16
  function isContained(root, target) {
17
17
  const relative = path.relative(root, target);
18
- return relative === "" || (!relative.startsWith("..") && !path.isAbsolute(relative));
18
+ return relative === "" || (!relative.startsWith(`..${path.sep}`) && relative !== ".." && !path.isAbsolute(relative));
19
19
  }
20
20
 
21
21
  function resolveWritablePath(cwd, requested) {
@@ -0,0 +1,66 @@
1
+ import { appendFileSync } from "node:fs";
2
+
3
+ const outputPath = process.env.SKILL_EVAL_CONTEXT_OBSERVATION_PATH;
4
+ let turn = 0;
5
+ let requestInTurn = 0;
6
+ let providerRequest = 0;
7
+
8
+ function textFromContent(content) {
9
+ if (typeof content === "string") return content;
10
+ if (!Array.isArray(content)) return "";
11
+ return content
12
+ .map((block) => {
13
+ if (!block || typeof block !== "object") return "";
14
+ if (block.type === "text" && typeof block.text === "string") return block.text;
15
+ if (block.type === "image" && typeof block.mimeType === "string") return `[image:${block.mimeType}]`;
16
+ return "";
17
+ })
18
+ .filter(Boolean)
19
+ .join("\n");
20
+ }
21
+
22
+ function append(event) {
23
+ if (!outputPath) return;
24
+ appendFileSync(outputPath, `${JSON.stringify({ timestamp: new Date().toISOString(), turn, ...event })}\n`, "utf8");
25
+ }
26
+
27
+ export default function skillEvaluationObserver(pi) {
28
+ pi.on("before_agent_start", (event, ctx) => {
29
+ turn += 1;
30
+ requestInTurn = 0;
31
+ const systemPrompt =
32
+ typeof event?.systemPrompt === "string" ? event.systemPrompt : String(ctx?.getSystemPrompt?.() ?? "");
33
+ append({
34
+ kind: "context",
35
+ surface: "system-prompt",
36
+ prompt: typeof event?.prompt === "string" ? event.prompt : null,
37
+ characters: systemPrompt.length,
38
+ text: systemPrompt,
39
+ systemPrompt,
40
+ });
41
+ });
42
+
43
+ pi.on("context", (event) => {
44
+ providerRequest += 1;
45
+ requestInTurn += 1;
46
+ const messages = Array.isArray(event?.messages) ? event.messages : [];
47
+ const normalized = messages.map((message) => ({
48
+ role: message?.role ?? null,
49
+ toolName: message?.toolName ?? null,
50
+ text: textFromContent(message?.content),
51
+ }));
52
+ const text = normalized
53
+ .map((message) => message.text)
54
+ .filter(Boolean)
55
+ .join("\n");
56
+ append({
57
+ kind: "context",
58
+ surface: "provider-context",
59
+ providerRequest,
60
+ requestInTurn,
61
+ characters: text.length,
62
+ text,
63
+ messages: normalized,
64
+ });
65
+ });
66
+ }
@@ -34,8 +34,9 @@ Selection:
34
34
  Current run support:
35
35
  Description and explicit-body groups with prompt or ordered turns
36
36
  Working-tree or Git-backed ordered skills/context; optional fresh fixture copies
37
- Description tools: read; body tools: read, write, edit
38
- Deterministic reads, paths, changed paths, text, JSON, and factual comparisons
37
+ Description tools: read; body tools: read, write, edit, or declared extension tools
38
+ Runtime profiles: Pi or PiFlow hosts, ordered immutable extension bundles, environment overrides
39
+ Deterministic reads, paths, changed paths, text, JSON, tool calls, context observations, and factual comparisons
39
40
  Ordered suites run serially and continue after isolated variant, group, or post-processing failures
40
41
  Grade-first views show compact criterion details, usage, and result-relative artifact paths
41
42
  `,
@@ -71,9 +72,7 @@ function parseOperation(values) {
71
72
 
72
73
  if (!command || command === "--help" || command === "-h") {
73
74
  printUsage();
74
- } else if (!commands.has(command)) {
75
- fail(`Unknown command: ${command}`);
76
- } else {
75
+ } else if (commands.has(command)) {
77
76
  try {
78
77
  const operation = parseOperation(argv.slice(1));
79
78
  if (command === "view") {
@@ -98,4 +97,6 @@ if (!command || command === "--help" || command === "-h") {
98
97
  } catch (error) {
99
98
  fail(error instanceof Error ? error.message : String(error), 1);
100
99
  }
100
+ } else {
101
+ fail(`Unknown command: ${command}`);
101
102
  }
@@ -5,28 +5,28 @@ description: Use when executing or resuming implementation, fixes, prototypes, d
5
5
 
6
6
  # Execute Work
7
7
 
8
- Carry out concrete work through bounded actions and fresh evidence only when it was requested or approved and the effective mode permits mutation.
8
+ Carry out concrete work through bounded actions and fresh evidence only when it was requested or approved and the effective mode permits its effects.
9
9
 
10
- A **slice** is one coherent result tracked and reviewed as a unit. A **bounded action** is one implementation, experiment, correction, or observation inside that slice. One slice may span multiple Feedback Loop iterations and owning skills while its intended result remains coherent.
10
+ A Slice is the shared coherent outcome. Execute Work owns each **bounded action**—one implementation, experiment, correction, or observation—inside it. A Slice need not have durable task memory; when one does, Track Work records its Current Slice.
11
11
 
12
- Read [the execution loop](references/execution-loop.md) when work spans multiple actions or slices, resumes from prior state, needs a specialized method, reaches a checkpoint, or reveals follow-on work.
12
+ Read [Execute Work edges](references/execute-work-edges.md) when work resumes from prior state, crosses a Slice boundary, reaches a selected checkpoint, or reveals separately controlled follow-on work.
13
13
 
14
14
  ## Follow The Execution Route
15
15
 
16
16
  Use this as a directed map, not a fixed phase sequence:
17
17
 
18
18
  ```text
19
- [Requested or approved concrete work; effective mode permits mutation]
19
+ [Requested or approved concrete work; effective mode permits its effects]
20
20
  -> [Orient and establish the current slice]
21
21
  -> [Take one bounded action]
22
22
  -> [Test or observe]
23
23
  -> [Verify what the evidence proves]
24
24
  -> clear local defect -> correct -> test or observe again
25
25
  -> unclear, repeated, or route-changing result -> Workflow
26
- -> supported -> silent self-review -> freeze
26
+ -> supported -> silent self-review -> freeze before acceptance or reuse
27
27
  -> [Route]
28
28
  -> more accepted work in this slice -> next bounded action
29
- -> coherent boundary extension -> approve and record when needed -> next action
29
+ -> coherent boundary extension -> Workflow -> covered and recorded when needed -> next action
30
30
  -> distinct result, authority, or evidence boundary -> Workflow
31
31
  -> approved checkpoint due -> owning skill -> route again
32
32
  -> supported exit -> report
@@ -40,10 +40,10 @@ Establish:
40
40
 
41
41
  - intended result and the source that supports it;
42
42
  - current slice, accepted scope, and relevant live state;
43
+ - the current authority envelope, due checkpoints, and separately controlled boundaries;
43
44
  - direct check or observation that can disagree with the result;
44
- - stop conditions, due checkpoints, and authority boundaries.
45
45
 
46
- A clear user request can be enough. A small self-contained change needs no Spec, Plan, or Working Record merely because execution was selected.
46
+ Execute Work inherits the authority envelope established by Workflow; selecting this method does not create execution authority. A small self-contained change needs no Spec, Plan, or Working Record merely because execution was selected.
47
47
 
48
48
  Inspect relevant code, tests, docs, policies, artifacts, repository state, and current external constraints before relying on memory. When sources materially conflict or the intended result is unsafe to infer, return the evidence to [Workflow](../workflow/SKILL.md) rather than choosing silently.
49
49
 
@@ -56,11 +56,14 @@ Choose the smallest coherent action that can produce the intended result or usef
56
56
  - keep unrelated and later work outside it;
57
57
  - choose reversible local details from repository conventions;
58
58
  - let an experiment fail safely and preserve its discard, revise, or promote condition;
59
+ - keep every experiment and observation inside the authority envelope;
59
60
  - use only specialized methods and domain guidance that the concrete boundary needs.
60
61
 
62
+ When several environment actions or observers could produce useful evidence, or the likely action is broad, use [Action Selection](../action-selection/SKILL.md) to choose and bound one interaction. Execute Work keeps ownership of the intended result and accepted effects; Action Selection returns the observation or bounded effect. Skip it when the next action is already known, mechanical, and directly verifiable.
63
+
61
64
  When an accepted behavior change, bug correction with a supported cause, consequential rule, or behavior-preserving refactor benefits from a failing check first, use [TDD](../tdd/SKILL.md) for that bounded action before changing production behavior.
62
65
 
63
- Before work changes the intended result, scope, authority, evidence boundary, or stop conditions, decide through Workflow whether it is an accepted extension or a new slice. When a Working Record exists, use Track Work to record an accepted extension before executing it. Do not let a series of “small” additions silently replace the original result.
66
+ Before work changes the intended result, scope, permitted effects, evidence boundary, stop condition, or authority source, decide through Workflow whether it is an accepted extension or a new slice. When a Working Record exists, use Track Work to record an accepted extension before executing it. Do not let a series of “small” additions silently replace the original result.
64
67
 
65
68
  ## Execute For The Required Boundary
66
69
 
@@ -68,21 +71,21 @@ Match implementation and evidence to the work. Code may need behavior tests or r
68
71
 
69
72
  Do not rewrite tests, checks, Specs, Plans, policies, or accepted behavior merely to make implementation pass. Determine whether the implementation, evidence, environment, or source is wrong before changing what defines success.
70
73
 
71
- When writing or changing code, read [Code Practices](references/code-practices.md). Prefer clear ownership, names, and failure behavior. Comment only non-obvious rationale, constraints, invariants, or temporary behavior with a real exit condition.
74
+ Before writing or changing code, read [Code Practices](references/code-practices.md). Prefer clear ownership, names, and failure behavior. Comment only non-obvious rationale, constraints, invariants, or temporary behavior with a real exit condition.
72
75
 
73
76
  Handle an edge case only when accepted behavior, observed evidence, or material safety requires it. If expected behavior is undefined and would change observable behavior or scope, return it to Workflow. When related patches keep adding states, flags, or caller coordination, stop and return the shared pressure rather than extending the patch stream.
74
77
 
75
78
  ## Close Each Evidence Iteration
76
79
 
77
- After each meaningful bounded action:
80
+ After every bounded action:
78
81
 
79
82
  1. run the focused tests or observations appropriate to its claim;
80
83
  2. use [Verify Work](../verify-work/SKILL.md) when the claim or observing boundary needs its fuller method;
81
- 3. when supported, use [Review Work](../review-work/SKILL.md) for silent self-review;
82
- 4. correct clear local issues within existing authority and re-verify;
83
- 5. freeze the supported state and return route-changing evidence to Workflow.
84
+ 3. once initial evidence supports the result, use [Review Work](../review-work/SKILL.md) for silent self-review;
85
+ 4. correct clear local issues within existing authority and re-verify the affected boundary;
86
+ 5. confirm the final state has no unresolved material issue, freeze it, and only then accept, reuse, or report the result.
84
87
 
85
- A failed or inconclusive check does not prove the design or source is wrong. Correct a clear local defect; use [Diagnose Failure](../diagnose-failure/SKILL.md) when the cause is unclear or failure repeats.
88
+ Self-review remains inside the bounded action rather than creating another action or review cycle. A failed or inconclusive check does not prove the design or source is wrong. Correct a clear local defect; use [Diagnose Failure](../diagnose-failure/SKILL.md) when the cause is unclear or failure repeats.
86
89
 
87
90
  Further polish, advisory warnings, unrelated issues, and review findings without mutation authority are feedback to classify, not permission to keep editing.
88
91
 
@@ -1,6 +1,6 @@
1
1
  # Code Practices
2
2
 
3
- Read this when an Execute Work slice writes or changes code. Follow the repository's language, style, testing, and documentation conventions before generic advice.
3
+ Read this before an Execute Work slice writes or changes code. Follow the repository's language, style, testing, and documentation conventions before generic advice.
4
4
 
5
5
  ## Make Intent Legible
6
6
 
@@ -0,0 +1,42 @@
1
+ # Execute Work Edges
2
+
3
+ Read this after [Execute Work](../SKILL.md) when work resumes from prior state, crosses a Slice boundary, reaches a selected checkpoint, or reveals separately controlled follow-on work. Execute Work owns the normal action, evidence, method, and continuation loop; this reference covers exceptional transitions.
4
+
5
+ ## Resume Safely
6
+
7
+ Reopen the source that established the work and inspect live state. When durable task memory exists, request the bounded `resume` view through [Track Work](../../track-work/SKILL.md), then retrieve exact entities only when the next decision needs them.
8
+
9
+ Re-establish authority from the current conversation and still-valid approval. A summary, Plan, Handoff, Working Record, or another conversation branch preserves context but does not create current authority or prove progress.
10
+
11
+ Preserve supported work and resume the same Slice only while its intended result, authority, evidence boundary, and stop condition remain coherent. Otherwise return the changed boundary to [Workflow](../../workflow/SKILL.md).
12
+
13
+ ## Cross A Slice Boundary Deliberately
14
+
15
+ Before beginning a distinct result, independently useful evidence boundary, uncovered effect, changed strategy, or separately controlled action:
16
+
17
+ 1. stop the current action stream;
18
+ 2. preserve the supported result and live evidence;
19
+ 3. return the boundary change to Workflow;
20
+ 4. reconcile the current Slice through Track Work when one exists;
21
+ 5. begin another Slice only after its outcome and authority are established.
22
+
23
+ A verification run, self-review, review report, method change, or pause does not create or close a Slice by itself.
24
+
25
+ ## Route A Selected Checkpoint
26
+
27
+ When an approved checkpoint becomes due, stop before dependent work, use its owner, and return the result to Workflow. If its condition no longer holds, return the deviation instead of forcing the checkpoint.
28
+
29
+ A checkpoint result may support continuation, correction, another route, deferment, or stopping. It does not authorize the next lifecycle stage. Track Work preserves selected and resolved checkpoint state when durable memory exists.
30
+
31
+ ## Separate Follow-On Work
32
+
33
+ Use the owning method only after Workflow confirms its boundary and authority:
34
+
35
+ - [Commit Work](../../commit-work/SKILL.md) for an authorized local checkpoint or simple push;
36
+ - [Migration Work](../../migration-work/SKILL.md) for accepted consumer, state, or traffic movement;
37
+ - [Finish Branch](../../finish-branch/SKILL.md) for integration, preservation, discard, or cleanup;
38
+ - [Release Work](../../release-work/SKILL.md) for versioned publication;
39
+ - [Launch Work](../../launch-work/SKILL.md) for production exposure or recovery;
40
+ - [Handoff](../../handoff/SKILL.md) for point-in-time continuation transfer.
41
+
42
+ A useful follow-on result is not implicit authority. Return to Workflow when its scope, evidence, destination, or stop condition is not already covered.
@@ -23,7 +23,7 @@ Before offering or executing a route, inspect:
23
23
 
24
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
25
 
26
- Read [integration options](references/integration-options.md) when 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.
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
27
 
28
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
29
 
@@ -99,7 +99,7 @@ Do not run destructive reset, clean, branch deletion, worktree removal, remote d
99
99
 
100
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
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) and [staging decisions](../commit-work/references/staging-decisions.md). Preserve branch state before re-entering another owning activity.
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
103
 
104
104
  ## Report The Chosen Outcome
105
105
 
@@ -1,6 +1,6 @@
1
1
  # Integration Options
2
2
 
3
- Use this after inspecting branch, base, remote, dirty state, verification, and workspace ownership.
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
4
 
5
5
  ## Local Integration
6
6
 
@@ -19,7 +19,7 @@ A handoff is memory, not authority. It may record where approval or authority ca
19
19
 
20
20
  Do not silently promote ephemeral context into repository memory. Ask one direct question when the destination changes durability, privacy, repository state, intended audience, or authority and the user has not chosen.
21
21
 
22
- Read [handoff templates](references/templates.md) after the transfer shape and recipient are clear.
22
+ Read [Handoff Templates](references/handoff-templates.md) after the transfer shape, recipient, and purpose are clear.
23
23
 
24
24
  ## Prepare From Live State
25
25
 
@@ -77,8 +77,8 @@ Stop when safe transfer would require inventing intent, authority, evidence, des
77
77
 
78
78
  When resuming:
79
79
 
80
- 1. Reopen the named source truth, Working Record when present, and current worktree state.
81
- 2. Verify important completion, evidence, review, commit, and artifact-identity claims before repeating them.
80
+ 1. Reopen the named source truth, the Working Record's bounded `resume` view when present, and current worktree state.
81
+ 2. Retrieve exact Working Record entities only when needed, then verify important completion, evidence, review, commit, and artifact-identity claims before repeating them.
82
82
  3. Compare the recorded route, decisions, and assumptions with live evidence.
83
83
  4. Preserve what still holds and identify only the invalidated layer.
84
84
  5. Return the live state and supported next action to [Workflow](../workflow/SKILL.md).
@@ -15,7 +15,7 @@ Loading this skill, preparing launch options, or approving a general implementat
15
15
 
16
16
  Use [Decision Gate](../decision-gate/SKILL.md) when deployment, exposure, rollback, destructive migration, launch window, acceptable degradation, user communication, or recovery direction remains a user-owned choice.
17
17
 
18
- Read [launch readiness](references/launch-readiness.md) when selecting risk lenses, operational evidence, rollout stages, or recovery checks. Use [Release Work](../release-work/SKILL.md) when a versioned artifact must be published first. Use [Migration Work](../migration-work/SKILL.md) when the launch transitions data, traffic, consumers, configuration, or compatibility contracts between old and replacement paths with migration or removal obligations.
18
+ Before selecting risk lenses, operational evidence, rollout stages, or recovery checks, read [launch readiness](references/launch-readiness.md). Use [Release Work](../release-work/SKILL.md) when a versioned artifact must be published first. Use [Migration Work](../migration-work/SKILL.md) when the launch transitions data, traffic, consumers, configuration, or compatibility contracts between old and replacement paths with migration or removal obligations.
19
19
 
20
20
  ## Define The Launch Contract
21
21
 
@@ -1,6 +1,6 @@
1
1
  # Launch Readiness
2
2
 
3
- Use only the lenses relevant to the production change. This is not a universal checklist.
3
+ Read this before selecting risk lenses, operational evidence, rollout stages, or recovery checks. Use only the lenses relevant to the production change; this is not a universal checklist.
4
4
 
5
5
  ## Identity And Ownership
6
6
 
@@ -34,7 +34,7 @@ When Workflow selects a security-focused review, read the [security risk lens](.
34
34
  - Critical latency, throughput, saturation, queue, storage, and dependency limits have evidence.
35
35
  - Advance and abort criteria are relative to accepted SLOs, historical baseline, or owner-approved thresholds.
36
36
 
37
- Read [performance evidence](../../verify-work/references/performance-evidence.md) for readiness and improvement claims. Read [flaky and performance diagnosis](../../diagnose-failure/references/flaky-and-performance.md) only when a regression lacks a supported cause.
37
+ Read [performance evidence](../../verify-work/references/performance-evidence.md) for readiness and improvement claims. Read [Flaky and Performance Diagnosis](../../diagnose-failure/references/flaky-and-performance-diagnosis.md) only when a regression lacks a supported cause.
38
38
 
39
39
  ## Accessibility And User Experience
40
40
 
@@ -26,6 +26,8 @@ When replacement behavior, interfaces, ownership, or failure semantics remain un
26
26
 
27
27
  ## Define The Migration Contract
28
28
 
29
+ Before choosing migration shape or units, compatibility, cutover evidence, rollback or forward recovery, or removal proof, read [the migration lifecycle](references/migration-lifecycle.md). Use only the stages required by the accepted migration; do not force every migration through one sequence.
30
+
29
31
  Before moving anything, establish:
30
32
 
31
33
  ```text
@@ -42,8 +44,6 @@ Owner decisions and stop conditions:
42
44
  Approved stages and scope:
43
45
  ```
44
46
 
45
- Read [the migration lifecycle](references/migration-lifecycle.md) when choosing an API, code, configuration, dependency, feature, traffic, or data shape. Use only the stages required by the accepted migration; do not force every migration through one sequence.
46
-
47
47
  Treat undocumented observable behavior as a possible consumer dependency until evidence says otherwise. Do not preserve every quirk automatically; surface consequential differences for decision.
48
48
 
49
49
  ## Prepare The Replacement
@@ -1,6 +1,6 @@
1
1
  # Migration Lifecycle
2
2
 
3
- Read this when choosing migration units, compatibility shape, cutover evidence, rollback, or removal proof.
3
+ Read this before choosing migration shape or units, compatibility, cutover evidence, rollback or forward recovery, or removal proof.
4
4
 
5
5
  ## Migration Shapes
6
6
 
@@ -7,7 +7,7 @@ description: Use when choosing, changing, or explaining how Freeflow mode applie
7
7
 
8
8
  Apply the effective Freeflow mode without inferring a different mode from the task. Freeflow has exactly three mode values: `conversation`, `workflow`, and `strict-workflow`.
9
9
 
10
- A mode changes how work proceeds; it does not authorize work, resolve a user-owned decision, or override live evidence.
10
+ A mode changes how work proceeds; it does not authorize work, widen the current authority envelope, resolve a user-owned decision, or override live evidence.
11
11
 
12
12
  ## Establish The Active Mode
13
13
 
@@ -27,15 +27,15 @@ Task shape does not change mode. A question during Workflow stays in Workflow; a
27
27
 
28
28
  ### Conversation
29
29
 
30
- Answer, discuss, critique, explore, and perform requested read-only inspection.
30
+ Answer, discuss, critique, explore, and inspect existing evidence or sources without exercising target behavior or intentionally changing task state.
31
31
 
32
- Do not mutate files, repository state, external systems, or durable artifacts. If the user requests mutation, explain the boundary and ask them to switch to `workflow` or `strict-workflow` through the host's mode control before proceeding.
32
+ Conversation permits passive observation only for task work. Active evidence generation and mutation or delivery require `workflow` or `strict-workflow` plus authority. If the user requests one, explain the mode boundary and ask them to switch through the host's mode control before proceeding.
33
33
 
34
34
  Ask only what the answer needs. Conversation mode does not require workflow artifacts, checkpoints, plans, specs, or independent review.
35
35
 
36
36
  ### Workflow
37
37
 
38
- Use the adaptive [Workflow](../workflow/SKILL.md) for consequential or mutating work. Inspect or ask when ambiguity changes the next action, create durable artifacts only when they preserve needed state or decisions, and verify claims against fresh evidence.
38
+ Use the adaptive [Workflow](../workflow/SKILL.md) for active evidence generation and consequential or mutating work. Inspect or ask when ambiguity changes the next action, create durable artifacts only when they preserve needed state or decisions, and verify claims against fresh evidence.
39
39
 
40
40
  Workflow mode does not itself authorize a slice or require every lifecycle phase.
41
41
 
@@ -55,27 +55,49 @@ The user owns mode changes. Recommend `strict-workflow` when risk warrants it, b
55
55
 
56
56
  A task type, risk classification, direct skill call, or workflow route does not switch mode. Invoking an execution skill during Conversation still does not authorize mutation.
57
57
 
58
- Use host-native mode control when available. In Pi:
58
+ Use host-managed session control so the change takes effect before the model acts. A clear natural-language instruction may use the same control. Questions, examples, hypotheses, and tentative language do not change mode.
59
59
 
60
60
  ```text
61
- /freeflow mode
61
+ Switch to conversation mode. -> session override
62
+ Use strict-workflow for this session. -> session override
63
+ Should we switch to strict-workflow? -> answer or discuss; no override
64
+ Suppose the mode were conversation. -> discussion; no override
65
+ ```
66
+
67
+ Host-native controls are:
68
+
69
+ ```text
70
+ Pi:
62
71
  /freeflow mode conversation
63
72
  /freeflow mode workflow
64
73
  /freeflow mode strict-workflow
65
74
  /freeflow mode reset
75
+
76
+ Claude:
77
+ /freeflow:mode-contract <conversation|workflow|strict-workflow|reset>
78
+
79
+ Codex:
80
+ $mode-contract <conversation|workflow|strict-workflow|reset>
66
81
  ```
67
82
 
68
- Pi handles these commands before the model runs. The three setting commands create a session override; `reset` clears it and returns to the configured default, including a personal override when present. `/freeflow mode` inspects or selects mode according to host UI support.
83
+ Claude and Codex persist their override in plugin-owned session state keyed by the host session identifier. Pi persists it in branch-aware Pi session state. The override survives ordinary turns and supported resume, clear, and compact boundaries for that session; `reset` clears it and returns to the configured default. A new session starts from configured state.
69
84
 
70
- For a natural-language request to change Pi session mode, direct the user to the native command. Do not claim runtime state changed until the host reports the new effective mode.
85
+ Treat only runtime-reported effective state as proof that the control succeeded. If the host reports missing session identity, unavailable writable plugin state, disabled Skills, or another failure, say that mode did not change. Do not compensate by editing a configured default.
71
86
 
72
87
  Mention mode only when the user asks, configuration is being discussed, or it changes the next action.
73
88
 
74
89
  ## Change Defaults Separately
75
90
 
76
- A persistent default change is not a session-mode change. An unqualified personal default request targets `.freeflow/local.json`; changing the shared repository default requires explicit repository, team, or shared-default wording.
91
+ A persistent default change is not a session-mode change. Determine which configured layer the user means before editing:
92
+
93
+ - explicit **personal** or **local** default targets `.freeflow/local.json`;
94
+ - explicit **shared**, **repository**, or **team** default targets `.freeflow/config.json`;
95
+ - an unqualified “change the default mode” request leaves that scope user-owned—ask one direct local-versus-repository question and wait;
96
+ - “global” is not a defined Freeflow layer—ask whether the user means this checkout's personal default or the shared repository default.
97
+
98
+ Do not infer the target from which file already exists or from the current mode. Preserve unrelated settings in the selected layer.
77
99
 
78
- In Pi, use `/freeflow mode` or `/freeflow settings session` for a temporary mode override, `/freeflow settings` for personal overrides, and `/freeflow settings repo` for shared defaults. In another host, use its native settings when available or update only the explicitly selected valid layer while preserving unrelated settings.
100
+ In Pi, `/freeflow settings` edits personal overrides and `/freeflow settings repo` edits shared defaults. In another host, an agent may update only the explicitly selected valid configuration layer. Session controls never modify either file.
79
101
 
80
102
  For agent-performed config edits, obey the effective mode when one exists. Conversation remains read-only. When no mode is effective because Freeflow is unconfigured, inactive, blocked by invalid config, or Skills are dormant, an explicit configuration or [Setup Freeflow](../setup-freeflow/SKILL.md) request governs the selected change; any dormant resolved mode is neither authority nor prohibition. User-operated host controls change their own state before the model continues.
81
103
 
@@ -22,7 +22,7 @@ Use [Decision Gate](../decision-gate/SKILL.md) when the route depends on an unre
22
22
  - yanking, deprecating, replacing, or republishing an artifact;
23
23
  - release branches, history rewriting, or recovery from partial publication.
24
24
 
25
- Do not impose semantic versioning when the project uses another scheme. Read [release evidence](references/release-evidence.md) when version, source, artifact, tag, publication, or recovery identity matters.
25
+ Do not impose semantic versioning when the project uses another scheme. Before defining or changing version, source, artifact, tag, publication, or recovery identity, read [release evidence](references/release-evidence.md).
26
26
 
27
27
  ## Define The Release Contract
28
28
 
@@ -1,6 +1,6 @@
1
1
  # Release Evidence
2
2
 
3
- Read this when version, source, artifact, tag, publication, or recovery identity matters.
3
+ Read this before defining or changing version, source, artifact, tag, publication, or recovery identity.
4
4
 
5
5
  ## Version Basis
6
6