@warpgogol/forge 9.2.3 → 9.3.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 (247) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/bin/cli.ts +3 -2
  3. package/dist/bin/cli.js +3 -2
  4. package/dist/bin/cli.js.map +1 -1
  5. package/dist/os/adr/handlers/implement-stamp.d.ts +6 -0
  6. package/dist/os/adr/handlers/implement-stamp.d.ts.map +1 -1
  7. package/dist/os/adr/handlers/implement-stamp.js +23 -15
  8. package/dist/os/adr/handlers/implement-stamp.js.map +1 -1
  9. package/dist/os/checks/handlers/counters-journal.d.ts.map +1 -1
  10. package/dist/os/checks/handlers/counters-journal.js +9 -1
  11. package/dist/os/checks/handlers/counters-journal.js.map +1 -1
  12. package/dist/os/core/core.module.d.ts.map +1 -1
  13. package/dist/os/core/core.module.js +27 -36
  14. package/dist/os/core/core.module.js.map +1 -1
  15. package/dist/os/core/lock-holder.d.ts +32 -0
  16. package/dist/os/core/lock-holder.d.ts.map +1 -0
  17. package/dist/os/core/lock-holder.js +81 -0
  18. package/dist/os/core/lock-holder.js.map +1 -0
  19. package/dist/os/core/stamp-lock.d.ts +30 -0
  20. package/dist/os/core/stamp-lock.d.ts.map +1 -0
  21. package/dist/os/core/stamp-lock.js +112 -0
  22. package/dist/os/core/stamp-lock.js.map +1 -0
  23. package/dist/os/flow/digest.d.ts +19 -0
  24. package/dist/os/flow/digest.d.ts.map +1 -1
  25. package/dist/os/flow/digest.js +33 -4
  26. package/dist/os/flow/digest.js.map +1 -1
  27. package/dist/os/flow/flow.module.d.ts.map +1 -1
  28. package/dist/os/flow/flow.module.js +61 -6
  29. package/dist/os/flow/flow.module.js.map +1 -1
  30. package/dist/os/flow/handlers/flow-cut.d.ts +8 -0
  31. package/dist/os/flow/handlers/flow-cut.d.ts.map +1 -1
  32. package/dist/os/flow/handlers/flow-cut.js +91 -5
  33. package/dist/os/flow/handlers/flow-cut.js.map +1 -1
  34. package/dist/os/flow/handlers/flow-digest.d.ts.map +1 -1
  35. package/dist/os/flow/handlers/flow-digest.js +6 -0
  36. package/dist/os/flow/handlers/flow-digest.js.map +1 -1
  37. package/dist/os/flow/handlers/flow-discard.d.ts.map +1 -1
  38. package/dist/os/flow/handlers/flow-discard.js +17 -13
  39. package/dist/os/flow/handlers/flow-discard.js.map +1 -1
  40. package/dist/os/flow/handlers/flow-fix.d.ts.map +1 -1
  41. package/dist/os/flow/handlers/flow-fix.js +99 -10
  42. package/dist/os/flow/handlers/flow-fix.js.map +1 -1
  43. package/dist/os/flow/handlers/flow-integrate.d.ts.map +1 -1
  44. package/dist/os/flow/handlers/flow-integrate.js +32 -15
  45. package/dist/os/flow/handlers/flow-integrate.js.map +1 -1
  46. package/dist/os/flow/handlers/flow-publication-retire.d.ts +17 -0
  47. package/dist/os/flow/handlers/flow-publication-retire.d.ts.map +1 -0
  48. package/dist/os/flow/handlers/flow-publication-retire.js +132 -0
  49. package/dist/os/flow/handlers/flow-publication-retire.js.map +1 -0
  50. package/dist/os/flow/handlers/flow-push.d.ts +7 -0
  51. package/dist/os/flow/handlers/flow-push.d.ts.map +1 -1
  52. package/dist/os/flow/handlers/flow-push.js +106 -15
  53. package/dist/os/flow/handlers/flow-push.js.map +1 -1
  54. package/dist/os/flow/locks.d.ts +6 -1
  55. package/dist/os/flow/locks.d.ts.map +1 -1
  56. package/dist/os/flow/locks.js +53 -23
  57. package/dist/os/flow/locks.js.map +1 -1
  58. package/dist/os/flow/publication-order.d.ts +25 -0
  59. package/dist/os/flow/publication-order.d.ts.map +1 -0
  60. package/dist/os/flow/publication-order.js +75 -0
  61. package/dist/os/flow/publication-order.js.map +1 -0
  62. package/dist/os/flow/publish.d.ts +18 -0
  63. package/dist/os/flow/publish.d.ts.map +1 -1
  64. package/dist/os/flow/publish.js +58 -2
  65. package/dist/os/flow/publish.js.map +1 -1
  66. package/dist/os/flow/registry.d.ts +1 -1
  67. package/dist/os/flow/registry.d.ts.map +1 -1
  68. package/dist/os/flow/registry.js +2 -1
  69. package/dist/os/flow/registry.js.map +1 -1
  70. package/dist/os/flow/release-tags.d.ts +1 -0
  71. package/dist/os/flow/release-tags.d.ts.map +1 -1
  72. package/dist/os/flow/release-tags.js +5 -4
  73. package/dist/os/flow/release-tags.js.map +1 -1
  74. package/dist/os/flow/scripts.d.ts +1 -1
  75. package/dist/os/flow/scripts.d.ts.map +1 -1
  76. package/dist/os/flow/scripts.js +1 -0
  77. package/dist/os/flow/scripts.js.map +1 -1
  78. package/dist/os/flow/task-files.d.ts +11 -0
  79. package/dist/os/flow/task-files.d.ts.map +1 -0
  80. package/dist/os/flow/task-files.js +51 -0
  81. package/dist/os/flow/task-files.js.map +1 -0
  82. package/dist/os/flow/tests/helpers.d.ts +4 -1
  83. package/dist/os/flow/tests/helpers.d.ts.map +1 -1
  84. package/dist/os/flow/tests/helpers.js +9 -5
  85. package/dist/os/flow/tests/helpers.js.map +1 -1
  86. package/dist/os/mission/handlers/archive.d.ts.map +1 -1
  87. package/dist/os/mission/handlers/archive.js +30 -74
  88. package/dist/os/mission/handlers/archive.js.map +1 -1
  89. package/dist/os/mission/lockfile.d.ts +21 -0
  90. package/dist/os/mission/lockfile.d.ts.map +1 -0
  91. package/dist/os/mission/lockfile.js +76 -0
  92. package/dist/os/mission/lockfile.js.map +1 -0
  93. package/dist/os/mission/mission.module.d.ts.map +1 -1
  94. package/dist/os/mission/mission.module.js +2 -1
  95. package/dist/os/mission/mission.module.js.map +1 -1
  96. package/dist/os/rfc/handlers/implement-stamp.d.ts +6 -0
  97. package/dist/os/rfc/handlers/implement-stamp.d.ts.map +1 -1
  98. package/dist/os/rfc/handlers/implement-stamp.js +24 -19
  99. package/dist/os/rfc/handlers/implement-stamp.js.map +1 -1
  100. package/dist/os/system/handlers/outbox-validate.d.ts +8 -0
  101. package/dist/os/system/handlers/outbox-validate.d.ts.map +1 -0
  102. package/dist/os/system/handlers/outbox-validate.js +102 -0
  103. package/dist/os/system/handlers/outbox-validate.js.map +1 -0
  104. package/dist/os/system/handlers/system-map-validate.d.ts +13 -0
  105. package/dist/os/system/handlers/system-map-validate.d.ts.map +1 -0
  106. package/dist/os/system/handlers/system-map-validate.js +78 -0
  107. package/dist/os/system/handlers/system-map-validate.js.map +1 -0
  108. package/dist/os/system/handlers/system-outbox-scan.d.ts +10 -0
  109. package/dist/os/system/handlers/system-outbox-scan.d.ts.map +1 -0
  110. package/dist/os/system/handlers/system-outbox-scan.js +195 -0
  111. package/dist/os/system/handlers/system-outbox-scan.js.map +1 -0
  112. package/dist/os/system/handlers/system-task-collect.d.ts +13 -0
  113. package/dist/os/system/handlers/system-task-collect.d.ts.map +1 -0
  114. package/dist/os/system/handlers/system-task-collect.js +238 -0
  115. package/dist/os/system/handlers/system-task-collect.js.map +1 -0
  116. package/dist/os/system/handlers/system-task-create.d.ts +32 -0
  117. package/dist/os/system/handlers/system-task-create.d.ts.map +1 -0
  118. package/dist/os/system/handlers/system-task-create.js +216 -0
  119. package/dist/os/system/handlers/system-task-create.js.map +1 -0
  120. package/dist/os/system/handlers/system-task-dispatch.d.ts +14 -0
  121. package/dist/os/system/handlers/system-task-dispatch.d.ts.map +1 -0
  122. package/dist/os/system/handlers/system-task-dispatch.js +290 -0
  123. package/dist/os/system/handlers/system-task-dispatch.js.map +1 -0
  124. package/dist/os/system/handlers/system-task-move.d.ts +12 -0
  125. package/dist/os/system/handlers/system-task-move.d.ts.map +1 -0
  126. package/dist/os/system/handlers/system-task-move.js +217 -0
  127. package/dist/os/system/handlers/system-task-move.js.map +1 -0
  128. package/dist/os/system/handlers/system-task-status.d.ts +20 -0
  129. package/dist/os/system/handlers/system-task-status.d.ts.map +1 -0
  130. package/dist/os/system/handlers/system-task-status.js +139 -0
  131. package/dist/os/system/handlers/system-task-status.js.map +1 -0
  132. package/dist/os/system/handlers/system-versionset-record.d.ts +12 -0
  133. package/dist/os/system/handlers/system-versionset-record.d.ts.map +1 -0
  134. package/dist/os/system/handlers/system-versionset-record.js +332 -0
  135. package/dist/os/system/handlers/system-versionset-record.js.map +1 -0
  136. package/dist/os/system/index.d.ts +6 -0
  137. package/dist/os/system/index.d.ts.map +1 -0
  138. package/dist/os/system/index.js +18 -0
  139. package/dist/os/system/index.js.map +1 -0
  140. package/dist/os/system/outbox-schema.d.ts +30 -0
  141. package/dist/os/system/outbox-schema.d.ts.map +1 -0
  142. package/dist/os/system/outbox-schema.js +29 -0
  143. package/dist/os/system/outbox-schema.js.map +1 -0
  144. package/dist/os/system/repo.d.ts +64 -0
  145. package/dist/os/system/repo.d.ts.map +1 -0
  146. package/dist/os/system/repo.js +364 -0
  147. package/dist/os/system/repo.js.map +1 -0
  148. package/dist/os/system/scenario-schemas.d.ts +26 -0
  149. package/dist/os/system/scenario-schemas.d.ts.map +1 -0
  150. package/dist/os/system/scenario-schemas.js +53 -0
  151. package/dist/os/system/scenario-schemas.js.map +1 -0
  152. package/dist/os/system/schemas.d.ts +63 -0
  153. package/dist/os/system/schemas.d.ts.map +1 -0
  154. package/dist/os/system/schemas.js +83 -0
  155. package/dist/os/system/schemas.js.map +1 -0
  156. package/dist/os/system/system.module.d.ts +3 -0
  157. package/dist/os/system/system.module.d.ts.map +1 -0
  158. package/dist/os/system/system.module.js +429 -0
  159. package/dist/os/system/system.module.js.map +1 -0
  160. package/dist/os/system/task-schemas.d.ts +108 -0
  161. package/dist/os/system/task-schemas.d.ts.map +1 -0
  162. package/dist/os/system/task-schemas.js +152 -0
  163. package/dist/os/system/task-schemas.js.map +1 -0
  164. package/dist/os/system/task-store.d.ts +41 -0
  165. package/dist/os/system/task-store.d.ts.map +1 -0
  166. package/dist/os/system/task-store.js +142 -0
  167. package/dist/os/system/task-store.js.map +1 -0
  168. package/dist/os/system/tests/helpers.d.ts +30 -0
  169. package/dist/os/system/tests/helpers.d.ts.map +1 -0
  170. package/dist/os/system/tests/helpers.js +178 -0
  171. package/dist/os/system/tests/helpers.js.map +1 -0
  172. package/dist/src/index.d.ts +3 -0
  173. package/dist/src/index.d.ts.map +1 -1
  174. package/dist/src/index.js +5 -4
  175. package/dist/src/index.js.map +1 -1
  176. package/os/adr/handlers/implement-stamp-lock.test.ts +90 -0
  177. package/os/adr/handlers/implement-stamp.ts +29 -20
  178. package/os/checks/handlers/counters-journal.test.ts +10 -0
  179. package/os/checks/handlers/counters-journal.ts +8 -1
  180. package/os/core/core.module.ts +32 -36
  181. package/os/core/lock-holder.ts +88 -0
  182. package/os/core/stamp-lock.ts +142 -0
  183. package/os/flow/digest.ts +46 -4
  184. package/os/flow/flow.module.ts +62 -6
  185. package/os/flow/handlers/flow-cut.ts +118 -5
  186. package/os/flow/handlers/flow-digest.ts +6 -0
  187. package/os/flow/handlers/flow-discard.ts +22 -13
  188. package/os/flow/handlers/flow-fix.ts +116 -10
  189. package/os/flow/handlers/flow-integrate.ts +31 -15
  190. package/os/flow/handlers/flow-publication-retire.ts +156 -0
  191. package/os/flow/handlers/flow-push.ts +128 -13
  192. package/os/flow/locks.ts +75 -25
  193. package/os/flow/publication-order.ts +99 -0
  194. package/os/flow/publish.ts +73 -2
  195. package/os/flow/registry.ts +5 -2
  196. package/os/flow/release-tags.ts +5 -4
  197. package/os/flow/scripts.ts +2 -0
  198. package/os/flow/task-files.ts +59 -0
  199. package/os/flow/tests/flow-cut-prepare.test.ts +298 -0
  200. package/os/flow/tests/flow-cut.test.ts +5 -1
  201. package/os/flow/tests/flow-publication-retire.test.ts +191 -0
  202. package/os/flow/tests/flow-push-supersede.test.ts +221 -0
  203. package/os/flow/tests/flow-task-files.test.ts +59 -0
  204. package/os/flow/tests/helpers.ts +9 -5
  205. package/os/flow/tests/locks.test.ts +219 -0
  206. package/os/flow/tests/publication-order.test.ts +102 -0
  207. package/os/mission/handlers/archive.test.ts +97 -52
  208. package/os/mission/handlers/archive.ts +31 -76
  209. package/os/mission/lockfile.ts +84 -0
  210. package/os/mission/mission.module.ts +2 -1
  211. package/os/rfc/handlers/implement-stamp-lock.test.ts +133 -0
  212. package/os/rfc/handlers/implement-stamp.ts +30 -24
  213. package/os/system/handlers/outbox-validate.ts +120 -0
  214. package/os/system/handlers/system-map-validate.ts +107 -0
  215. package/os/system/handlers/system-outbox-scan.ts +320 -0
  216. package/os/system/handlers/system-task-collect.ts +305 -0
  217. package/os/system/handlers/system-task-create.ts +271 -0
  218. package/os/system/handlers/system-task-dispatch.ts +387 -0
  219. package/os/system/handlers/system-task-move.ts +353 -0
  220. package/os/system/handlers/system-task-status.ts +176 -0
  221. package/os/system/handlers/system-versionset-record.ts +476 -0
  222. package/os/system/index.ts +47 -0
  223. package/os/system/outbox-schema.ts +47 -0
  224. package/os/system/repo.ts +451 -0
  225. package/os/system/scenario-schemas.ts +62 -0
  226. package/os/system/schemas.ts +102 -0
  227. package/os/system/system.module.ts +449 -0
  228. package/os/system/task-schemas.ts +190 -0
  229. package/os/system/task-store.ts +184 -0
  230. package/os/system/tests/helpers.ts +189 -0
  231. package/os/system/tests/outbox-validate.test.ts +92 -0
  232. package/os/system/tests/system-map-validate.test.ts +321 -0
  233. package/os/system/tests/system-outbox-scan.test.ts +273 -0
  234. package/os/system/tests/system-profile.test.ts +90 -0
  235. package/os/system/tests/system-task-collect.test.ts +293 -0
  236. package/os/system/tests/system-task-dispatch.test.ts +279 -0
  237. package/os/system/tests/system-task-status.test.ts +153 -0
  238. package/os/system/tests/system-task.test.ts +330 -0
  239. package/os/system/tests/system-versionset.test.ts +314 -0
  240. package/package.json +33 -1
  241. package/profiles/system.yaml +650 -0
  242. package/skills/fo/fo-outbox/SKILL.md +71 -0
  243. package/skills/fo/fo-system-dispatch/SKILL.md +65 -0
  244. package/skills/fo/fo-task-run/SKILL.md +75 -0
  245. package/src/index.ts +11 -4
  246. package/src/tests/fixtures/agents-generate-business-before.txt +6 -0
  247. package/src/tests/profile-schema.test.ts +2 -1
@@ -0,0 +1,650 @@
1
+ schema: forge/stack-profile@1
2
+ id: system
3
+ displayName: System repository
4
+ detect:
5
+ anyOf:
6
+ - system.marker
7
+ workspace:
8
+ dirs:
9
+ - docs
10
+ - scripts
11
+ - tools
12
+ - system
13
+ - system/decisions
14
+ - system/scenarios
15
+ - system/version-sets
16
+ - queue/tasks
17
+ - queue/briefs
18
+ - queue/reports
19
+ files:
20
+ - path: system/system.yaml
21
+ content: |
22
+ schema: forge/system@1
23
+ id: __PROJECT_NAME__
24
+ name: __PROJECT_NAME__
25
+ owners:
26
+ - operator
27
+ - path: system/products.yaml
28
+ content: |
29
+ schema: forge/system-products@1
30
+ products: []
31
+ - path: system/edges.yaml
32
+ content: |
33
+ schema: forge/system-edges@1
34
+ allowed: []
35
+ forbidden: []
36
+ - path: system/decisions/.gitkeep
37
+ content: |
38
+ - path: system/scenarios/.gitkeep
39
+ content: |
40
+ - path: system/version-sets/.gitkeep
41
+ content: |
42
+ - path: queue/tasks/.gitkeep
43
+ content: |
44
+ - path: queue/briefs/.gitkeep
45
+ content: |
46
+ - path: queue/reports/.gitkeep
47
+ content: |
48
+ - path: .vscode/extensions.json
49
+ content: |
50
+ {
51
+ "recommendations": [
52
+ "dbaeumer.vscode-eslint",
53
+ "esbenp.prettier-vscode",
54
+ "github.vscode-github-actions",
55
+ "mechatroner.rainbow-csv"
56
+ ]
57
+ }
58
+ - path: .gitignore
59
+ content: |
60
+ node_modules
61
+ dist
62
+ .turbo
63
+ .cache
64
+ operator-profile.md
65
+ system/products.local.yaml
66
+ .forge/task/
67
+ - path: .github/workflows/ci.yml
68
+ content: |
69
+ name: CI
70
+
71
+ on:
72
+ pull_request:
73
+ push:
74
+ branches: [main]
75
+ workflow_dispatch:
76
+
77
+ concurrency:
78
+ group: ${{ github.workflow }}-${{ github.ref }}
79
+ cancel-in-progress: ${{ github.event_name == 'pull_request' }}
80
+
81
+ permissions:
82
+ contents: read
83
+
84
+ jobs:
85
+ ci:
86
+ runs-on: ubuntu-latest
87
+ timeout-minutes: 15
88
+ name: Lint, type-check, test
89
+ env:
90
+ TZ: UTC
91
+
92
+ steps:
93
+ - name: Checkout
94
+ uses: actions/checkout@v5
95
+
96
+ - name: Enable Corepack
97
+ run: corepack enable
98
+
99
+ - name: Setup Node.js
100
+ uses: actions/setup-node@v5
101
+ with:
102
+ node-version: "24"
103
+ cache: "pnpm"
104
+
105
+ - name: Install dependencies
106
+ run: pnpm install --frozen-lockfile
107
+
108
+ - name: Forge doctor
109
+ run: pnpm exec forge doctor
110
+
111
+ - name: Format check
112
+ run: pnpm format:check
113
+
114
+ - name: Test
115
+ run: pnpm test
116
+
117
+ # Windows CI (optional — uncomment if Windows checks are needed):
118
+ #
119
+ # windows-ci:
120
+ # runs-on: windows-latest
121
+ # name: Lint, type-check, test (Windows)
122
+ # env:
123
+ # GIT_CONFIG_COUNT: 1
124
+ # GIT_CONFIG_KEY_0: core.longpaths
125
+ # GIT_CONFIG_VALUE_0: "true"
126
+ # steps:
127
+ # - name: Checkout
128
+ # uses: actions/checkout@v5
129
+ # - name: Enable Corepack
130
+ # run: corepack enable
131
+ # - name: Setup Node.js
132
+ # uses: actions/setup-node@v5
133
+ # with:
134
+ # node-version: "24"
135
+ # cache: "pnpm"
136
+ # - name: Install dependencies
137
+ # run: pnpm install --frozen-lockfile
138
+ # - name: Format check
139
+ # run: pnpm format:check
140
+ # - name: Test
141
+ # run: pnpm test
142
+ #
143
+ # The GIT_CONFIG_COUNT env block MUST be set before the checkout step
144
+ # so git can handle long file paths during clone on Windows.
145
+ # Do not add Windows to the matrix "just in case" — it requires
146
+ # separate path-length and platform-specific dependency verification.
147
+ - path: package.json
148
+ content: |
149
+ {
150
+ "name": "__PROJECT_NAME__",
151
+ "version": "0.1.0",
152
+ "private": true,
153
+ "type": "module",
154
+ "engines": {
155
+ "node": ">=24 <25"
156
+ },
157
+ "scripts": {
158
+ "clean": "node scripts/clean.mjs",
159
+ "format": "prettier --write .",
160
+ "format:check": "prettier --check .",
161
+ "test": "vitest run --passWithNoTests",
162
+ "upgrade-packages": "pnpm up"
163
+ }
164
+ }
165
+ - path: scripts/clean.mjs
166
+ content: |
167
+ import { readdir, rm } from "node:fs/promises";
168
+ import { join } from "node:path";
169
+ import { fileURLToPath } from "node:url";
170
+
171
+ const TARGETS = new Set(["node_modules", ".turbo", "dist", ".astro", ".cache", ".wrangler"]);
172
+
173
+ const repoRoot = join(fileURLToPath(import.meta.url), "..", "..");
174
+
175
+ async function walk(dir, toDelete) {
176
+ const entries = await readdir(dir, { withFileTypes: true });
177
+ for (const entry of entries) {
178
+ if (!entry.isDirectory()) continue;
179
+ const name = entry.name;
180
+ const fullPath = join(dir, name);
181
+ if (TARGETS.has(name)) {
182
+ toDelete.push(fullPath);
183
+ continue;
184
+ }
185
+ await walk(fullPath, toDelete);
186
+ }
187
+ }
188
+
189
+ const toDelete = [];
190
+ await walk(repoRoot, toDelete);
191
+
192
+ if (toDelete.length === 0) {
193
+ console.log("Nothing to clean.");
194
+ process.exit(0);
195
+ }
196
+
197
+ await Promise.all(toDelete.map((p) => rm(p, { recursive: true, force: true })));
198
+
199
+ for (const p of toDelete) {
200
+ console.log("deleted", p.replace(repoRoot + "/", ""));
201
+ }
202
+
203
+ console.log(`Cleaned ${toDelete.length} directories.`)
204
+ - path: tools/kernel.config.ts
205
+ content: |
206
+ import { defineKernelConfig } from "@warpgogol/werkstatt-engine/kernel/types";
207
+ import { forgeModuleLoaders } from "@warpgogol/werkstatt-engine/kernel/module-map";
208
+
209
+ export default defineKernelConfig({
210
+ name: "__PROJECT_NAME__",
211
+ description: "__PROJECT_NAME__ workshop",
212
+ moduleLoaders: {
213
+ // Forge governance modules — single-sourced in
214
+ // @warpgogol/werkstatt-engine/kernel/module-map (WORKSHOP_MODULE_MAP.forge).
215
+ // Do not add forge loaders here; new forge modules join the map once.
216
+ ...forgeModuleLoaders(),
217
+ },
218
+ });
219
+ - path: .npmrc
220
+ content: |
221
+ # @warpgogol scoped registry — replace YOUR_NPM_TOKEN with a valid npm read token
222
+ @warpgogol:registry=https://registry.npmjs.org/
223
+ //registry.npmjs.org/:_authToken=YOUR_NPM_TOKEN
224
+ # Auto-approve build scripts so operators aren't prompted during install
225
+ dangerously-allow-all-builds=true
226
+ - path: eslint.config.js
227
+ content: |
228
+ export default [
229
+ {
230
+ rules: {},
231
+ },
232
+ ];
233
+ - path: .prettierrc.mjs
234
+ content: |
235
+ export default {
236
+ semi: true,
237
+ singleQuote: false,
238
+ trailingComma: "all",
239
+ printWidth: 100,
240
+ tabWidth: 2,
241
+ };
242
+ - path: .gitattributes
243
+ content: |
244
+ # No LFS patterns for this stack
245
+ - path: scripts/git-guard.sh
246
+ content: |
247
+ #!/bin/bash
248
+ # git-guard.sh — shell function that intercepts destructive git commands.
249
+ # Sourced by ~/.zshenv (via setup-git-guards.sh).
250
+ # Guards (only active in repos containing scripts/git-guard.sh):
251
+ # git stash, git reset --hard, git checkout --, git checkout -f,
252
+ # git switch -f, git clean -f, git restore
253
+ # Override: ALLOW_DESTRUCTIVE_GIT=1 git stash
254
+
255
+ export FORGE_GIT_GUARD=1
256
+
257
+ _git_guard_find_root() {
258
+ local _repo_root _dir
259
+ _repo_root="$(command git rev-parse --show-toplevel 2>/dev/null || echo "")"
260
+ if [ -z "$_repo_root" ]; then echo ""; return; fi
261
+ if [ -f "$_repo_root/scripts/git-guard.sh" ]; then echo "$_repo_root"; return; fi
262
+ _dir="$(dirname "$_repo_root")"
263
+ while [ -n "$_dir" ] && [ "$_dir" != "/" ]; do
264
+ if [ -f "$_dir/scripts/git-guard.sh" ]; then echo "$_dir"; return; fi
265
+ _dir="$(dirname "$_dir")"
266
+ done
267
+ echo ""
268
+ }
269
+
270
+ git() {
271
+ local _guard_root
272
+ _guard_root="$(_git_guard_find_root)"
273
+ if [ -z "$_guard_root" ] || [ -n "${ALLOW_DESTRUCTIVE_GIT:-}" ]; then
274
+ command git "$@"; return $?
275
+ fi
276
+ local _all_args=("$@") _i=0 _cmd="" _cmd_index=0
277
+ while [ "$_i" -lt "${#_all_args[@]}" ]; do
278
+ local _arg="${_all_args[$_i]}"
279
+ case "$_arg" in
280
+ -C|-c|--git-dir|--work-tree|--namespace) _i=$((_i + 2)); continue ;;
281
+ -*) _i=$((_i + 1)); continue ;;
282
+ esac
283
+ _cmd="$_arg"; _cmd_index="$_i"; break
284
+ done
285
+ local _sub_args=() _j=$((_cmd_index + 1))
286
+ while [ "$_j" -lt "${#_all_args[@]}" ]; do
287
+ _sub_args+=("${_all_args[$_j]}"); _j=$((_j + 1))
288
+ done
289
+ case "$_cmd" in
290
+ stash)
291
+ echo "BLOCKED: git stash is disabled in agent sessions." >&2
292
+ echo "Set ALLOW_DESTRUCTIVE_GIT=1 to override." >&2; return 1 ;;
293
+ reset)
294
+ for _arg in "${_sub_args[@]}"; do
295
+ if [ "$_arg" = "--hard" ] || [[ "$_arg" == --hard=* ]]; then
296
+ echo "BLOCKED: git reset --hard is disabled." >&2; return 1
297
+ fi
298
+ done; command git "$@"; return $? ;;
299
+ checkout)
300
+ for _arg in "${_sub_args[@]}"; do
301
+ if [ "$_arg" = "--" ]; then
302
+ echo "BLOCKED: git checkout -- is disabled." >&2; return 1
303
+ fi
304
+ case "$_arg" in -f*|--force*)
305
+ echo "BLOCKED: git checkout -f is disabled." >&2; return 1 ;;
306
+ esac
307
+ done; command git "$@"; return $? ;;
308
+ switch)
309
+ for _arg in "${_sub_args[@]}"; do
310
+ case "$_arg" in -f*|--force*)
311
+ echo "BLOCKED: git switch -f is disabled." >&2; return 1 ;;
312
+ esac
313
+ done; command git "$@"; return $? ;;
314
+ restore)
315
+ echo "BLOCKED: git restore is disabled." >&2; return 1 ;;
316
+ clean)
317
+ for _arg in "${_sub_args[@]}"; do
318
+ case "$_arg" in -f*|--force*)
319
+ echo "BLOCKED: git clean -f is disabled." >&2; return 1 ;;
320
+ esac
321
+ done; command git "$@"; return $? ;;
322
+ *) command git "$@"; return $? ;;
323
+ esac
324
+ }
325
+ - path: scripts/setup-git-guards.sh
326
+ content: |
327
+ #!/bin/bash
328
+ # setup-git-guards.sh — install shell function guards for destructive git ops.
329
+ # Auto-detects shell: zsh → ~/.zshenv, bash → ~/.bashrc (Git Bash on Windows).
330
+ set -euo pipefail
331
+ repo_root="$(git rev-parse --show-toplevel 2>/dev/null || echo "")"
332
+ if [ -z "$repo_root" ]; then echo "ERROR: not inside a git repository" >&2; exit 1; fi
333
+ guard_script="$repo_root/scripts/git-guard.sh"
334
+ marker="# forge-git-guard"
335
+ # Auto-detect target profile file based on current shell
336
+ case "${SHELL:-}" in
337
+ *zsh*) profile_file="${HOME}/.zshenv" ;;
338
+ *bash*) profile_file="${HOME}/.bashrc" ;;
339
+ *) profile_file="${HOME}/.bashrc" ;;
340
+ esac
341
+ mode="${1:-install}"
342
+ case "$mode" in
343
+ install)
344
+ if [ ! -f "$guard_script" ]; then echo "ERROR: $guard_script not found" >&2; exit 1; fi
345
+ chmod +x "$guard_script" 2>/dev/null || true
346
+ if [ -f "$profile_file" ]; then
347
+ tmp="$(mktemp)"
348
+ awk -v marker="$marker" '$0 == marker { skip=2; next } skip > 0 { skip--; next } { print }' "$profile_file" > "$tmp" || true
349
+ mv "$tmp" "$profile_file" 2>/dev/null || true
350
+ fi
351
+ echo "" >> "$profile_file"
352
+ echo "$marker" >> "$profile_file"
353
+ echo "[ -f \"$guard_script\" ] && source \"$guard_script\"" >> "$profile_file"
354
+ echo "Git guards installed into $profile_file. Restart your shell or run: source $guard_script" ;;
355
+ --verify)
356
+ if [ -z "${FORGE_GIT_GUARD:-}" ]; then echo "MISSING: git guard not loaded" >&2; exit 1; fi
357
+ if ! grep -qF "$marker" "$profile_file" 2>/dev/null; then echo "MISSING: guard not in $profile_file" >&2; exit 1; fi
358
+ echo "OK: git guards installed and loaded" ;;
359
+ --remove)
360
+ if [ -f "$profile_file" ]; then
361
+ tmp="$(mktemp)"
362
+ awk -v marker="$marker" '$0 == marker { skip=2; next } skip > 0 { skip--; next } { print }' "$profile_file" > "$tmp" || true
363
+ mv "$tmp" "$profile_file" 2>/dev/null || true
364
+ fi
365
+ echo "Git guards removed from $profile_file" ;;
366
+ *) echo "Usage: bash scripts/setup-git-guards.sh [install|--verify|--remove]" >&2; exit 1 ;;
367
+ esac
368
+ - path: scripts/clean-stale-stashes.sh
369
+ content: |
370
+ #!/bin/bash
371
+ # clean-stale-stashes.sh — detect and optionally drop stale git stash entries.
372
+ # Usage: bash scripts/clean-stale-stashes.sh [--drop|--drop-all]
373
+ set -euo pipefail
374
+ repo_root="$(git rev-parse --show-toplevel 2>/dev/null || echo "")"
375
+ if [ -z "$repo_root" ]; then echo "ERROR: not inside a git repository" >&2; exit 1; fi
376
+ mode="report"
377
+ if [ "${1:-}" = "--drop" ]; then mode="drop"; elif [ "${1:-}" = "--drop-all" ]; then mode="drop-all"; fi
378
+ stash_count="$(git -C "$repo_root" stash list 2>/dev/null | wc -l)"
379
+ if [ "$stash_count" -eq 0 ]; then exit 0; fi
380
+ stale_indices=() total="$stash_count"
381
+ for ((i = 0; i < total; i++)); do
382
+ ref="stash@{$i}"
383
+ if [ "$mode" = "drop-all" ]; then stale_indices+=("$i"); continue; fi
384
+ tracked_changes="$(git -C "$repo_root" stash show "$ref" --stat 2>/dev/null || true)"
385
+ untracked_files="$(git -C "$repo_root" stash show --include-untracked "$ref" --stat 2>/dev/null || true)"
386
+ if [ -z "$tracked_changes" ] && [ -z "$untracked_files" ]; then stale_indices+=("$i"); continue; fi
387
+ if [ -z "$tracked_changes" ] && [ -n "$untracked_files" ]; then
388
+ all_committed=true
389
+ while IFS= read -r filepath; do
390
+ [ -z "$filepath" ] && continue
391
+ if ! git -C "$repo_root" cat-file -e "HEAD:$filepath" 2>/dev/null; then all_committed=false; break; fi
392
+ done < <(git -C "$repo_root" stash show --include-untracked "$ref" --name-only 2>/dev/null || true)
393
+ if [ "$all_committed" = true ]; then stale_indices+=("$i"); fi
394
+ fi
395
+ done
396
+ if [ ${#stale_indices[@]} -eq 0 ]; then exit 0; fi
397
+ if [ "$mode" = "report" ]; then
398
+ echo "STALE STASH ENTRIES DETECTED (${#stale_indices[@]} of $stash_count):"
399
+ for idx in "${stale_indices[@]}"; do
400
+ echo " stash@{$idx}: $(git -C "$repo_root" stash list | sed -n "$((idx + 1))p")"
401
+ done
402
+ echo "Clean with: bash scripts/clean-stale-stashes.sh --drop"; exit 1
403
+ fi
404
+ if [ "$mode" = "drop-all" ]; then git -C "$repo_root" stash clear; echo "Dropped all $stash_count entries."; exit 0; fi
405
+ for ((i = ${#stale_indices[@]} - 1; i >= 0; i--)); do
406
+ idx="${stale_indices[$i]}"
407
+ git -C "$repo_root" stash drop "stash@{$idx}" 2>/dev/null || true
408
+ done
409
+ echo "Dropped ${#stale_indices[@]} stale entry/entries."; exit 0
410
+ - path: scripts/check-clean-trees.sh
411
+ content: |
412
+ #!/bin/bash
413
+ # check-clean-trees.sh — verify all git trees are clean.
414
+ # Checks repo root + all nested .git directories up to 3 levels deep.
415
+ set -euo pipefail
416
+ repo_root="$(git rev-parse --show-toplevel 2>/dev/null || echo "")"
417
+ if [ -z "$repo_root" ]; then echo "ERROR: not inside a git repository" >&2; exit 1; fi
418
+ dirty=0 output=""
419
+ main_status="$(git -C "$repo_root" status --short 2>/dev/null || true)"
420
+ if [ -n "$main_status" ]; then
421
+ output+="DIRTY: $repo_root\n$(printf '%s\n' "$main_status" | sed 's/^/ /')\n"
422
+ dirty=1
423
+ fi
424
+ while IFS= read -r gitdir; do
425
+ nested_root="$(dirname "$gitdir")"
426
+ [ "$nested_root" = "$repo_root" ] && continue
427
+ nested_status="$(git -C "$nested_root" status --short 2>/dev/null || true)"
428
+ if [ -n "$nested_status" ]; then
429
+ output+="DIRTY: $nested_root\n$(printf '%s\n' "$nested_status" | sed 's/^/ /')\n"
430
+ dirty=1
431
+ fi
432
+ done < <(find "$repo_root" -maxdepth 3 -name ".git" -type d 2>/dev/null | head -20)
433
+ if [ "$dirty" -eq 1 ]; then
434
+ echo -e "$output" | head -40
435
+ echo "---"
436
+ echo "Uncommitted changes detected. Commit session-attributed changes before"
437
+ echo "session end; leave files you did not produce untouched and report them."
438
+ exit 1
439
+ fi
440
+ exit 0
441
+ - path: hooks/pre-user-prompt.sh
442
+ content: |
443
+ #!/bin/bash
444
+ # Pre-user-prompt hook: session-end protocol + stale-stash + git-guard checks.
445
+ # Requires jq for JSON payload parsing.
446
+ set -euo pipefail
447
+ payload="$(cat)"
448
+ user_prompt="$(printf '%s' "$payload" | jq -r '.tool_info.user_prompt // empty' 2>/dev/null || true)"
449
+ if [ -z "$user_prompt" ]; then exit 0; fi
450
+ repo_root="$(git rev-parse --show-toplevel 2>/dev/null || echo "")"
451
+ if [ -n "$repo_root" ] && [ -x "$repo_root/scripts/clean-stale-stashes.sh" ]; then
452
+ stash_output="$("$repo_root/scripts/clean-stale-stashes.sh" 2>&1 || true)"
453
+ if [ -n "$stash_output" ]; then
454
+ echo "⚠️ STALE GIT STASH DETECTED" >&2
455
+ echo "$stash_output" >&2
456
+ echo "Clean with: bash scripts/clean-stale-stashes.sh --drop" >&2
457
+ echo "" >&2
458
+ fi
459
+ fi
460
+ if [ -n "$repo_root" ] && [ -f "$repo_root/scripts/git-guard.sh" ]; then
461
+ if [ -z "${FORGE_GIT_GUARD:-}" ]; then
462
+ echo "⚠️ GIT GUARD NOT LOADED — destructive git operations are NOT blocked." >&2
463
+ echo "Run: source $repo_root/scripts/git-guard.sh" >&2
464
+ echo "" >&2
465
+ fi
466
+ fi
467
+ session_end_phrases=("Завершаем эту сессию" "Завершаем сессию" "Заканчиваем сессию" "Завершить сессию" "End session" "Wrap up" "Session end" "/session-end")
468
+ matched=""
469
+ for phrase in "${session_end_phrases[@]}"; do
470
+ if printf '%s' "$user_prompt" | grep -qiF "$phrase"; then matched="$phrase"; break; fi
471
+ done
472
+ if [ -z "$matched" ]; then exit 0; fi
473
+ cat >&2 <<EOF
474
+ SESSION-END PROTOCOL TRIGGERED (matched: "$matched")
475
+ The user's original message was:
476
+ > $user_prompt
477
+ You MUST invoke the fo-session-retro skill via the skill tool BEFORE producing
478
+ any other output. This is a NON-NEGOTIABLE BLOCKED GATE per PREFERENCES.md.
479
+ DO NOT produce a closing summary or ad-hoc output. The closing block must come
480
+ from fo-session-retro's report.
481
+ Protocol steps:
482
+ 1. Verify clean working trees — run: bash scripts/check-clean-trees.sh
483
+ Commit session-attributed changes; leave unattributed files untouched and report them.
484
+ 2. Invoke fo-session-retro via the skill tool
485
+ 3. The retro skill's report IS the session-end output
486
+ EOF
487
+ if [ -n "$repo_root" ] && [ -x "$repo_root/scripts/check-clean-trees.sh" ]; then
488
+ tree_output="$("$repo_root/scripts/check-clean-trees.sh" 2>&1 || true)"
489
+ if [ -n "$tree_output" ]; then echo "" >&2; echo "$tree_output" >&2; fi
490
+ fi
491
+ exit 2
492
+ - path: hooks/pre-user-prompt-wrapper.mjs
493
+ content: |
494
+ #!/usr/bin/env node
495
+ // pre-user-prompt-wrapper.mjs — cross-platform wrapper for pre-user-prompt.sh.
496
+ // Detects bash availability, prints one-time warning if bash not found,
497
+ // then delegates to bash hooks/pre-user-prompt.sh with stdin piped.
498
+ import { execFileSync, spawn } from "node:child_process";
499
+ import { existsSync, mkdirSync, writeFileSync } from "node:fs";
500
+ import { dirname, join } from "node:path";
501
+ import { fileURLToPath } from "node:url";
502
+
503
+ const __dirname = dirname(fileURLToPath(import.meta.url));
504
+ const scriptPath = join(__dirname, "pre-user-prompt.sh");
505
+ const cacheDir = join(__dirname, "..", ".cache");
506
+ const warningFlag = join(cacheDir, "git-guard-warning-sent");
507
+
508
+ // If pre-user-prompt.sh doesn't exist, silently exit
509
+ if (!existsSync(scriptPath)) {
510
+ process.exit(0);
511
+ }
512
+
513
+ // Check if bash is available
514
+ let bashAvailable = false;
515
+ try {
516
+ execFileSync("bash", ["--version"], { stdio: "ignore" });
517
+ bashAvailable = true;
518
+ } catch {
519
+ bashAvailable = false;
520
+ }
521
+
522
+ if (!bashAvailable) {
523
+ // Print one-time warning if not already sent
524
+ if (!existsSync(warningFlag)) {
525
+ console.error("⚠️ bash not found — pre-user-prompt hook is disabled.");
526
+ console.error("Install Git Bash (Git for Windows) or WSL to enable agent-safety hooks.");
527
+ console.error("");
528
+ try {
529
+ mkdirSync(cacheDir, { recursive: true });
530
+ writeFileSync(warningFlag, new Date().toISOString(), "utf8");
531
+ } catch {
532
+ // Best-effort — don't crash if cache dir is not writable
533
+ }
534
+ }
535
+ process.exit(0);
536
+ }
537
+
538
+ // Delegate to bash script with stdin piped
539
+ const child = spawn("bash", [scriptPath], { stdio: ["inherit", "inherit", "inherit"] });
540
+ child.on("exit", (code) => {
541
+ process.exit(code ?? 0);
542
+ });
543
+ - path: .windsurf/hooks.json
544
+ content: |
545
+ {
546
+ "hooks": {
547
+ "pre_user_prompt": [
548
+ {
549
+ "command": "node \"${ROOT_WORKSPACE_PATH:-$PWD}/hooks/pre-user-prompt-wrapper.mjs\"",
550
+ "show_output": true
551
+ }
552
+ ]
553
+ }
554
+ }
555
+ - path: .forge/pinned.yaml
556
+ content: |
557
+ # Pinned foundation files (DNA-62, RFC-0733)
558
+ # Protect mode: warns on delete/move. Freeze mode: blocks modify too.
559
+ entries:
560
+ - path: tools/kernel.config.ts
561
+ mode: protect
562
+ - path: forge.yaml
563
+ mode: protect
564
+ - path: pnpm-workspace.yaml
565
+ mode: protect
566
+ - path: turbo.json
567
+ mode: protect
568
+ - path: tsconfig.base.json
569
+ mode: protect
570
+ - path: scripts/git-guard.sh
571
+ mode: protect
572
+ - path: scripts/setup-git-guards.sh
573
+ mode: protect
574
+ - path: hooks/pre-user-prompt.sh
575
+ mode: protect
576
+ - path: hooks/pre-user-prompt-wrapper.mjs
577
+ mode: protect
578
+ - path: README.md
579
+ content: |
580
+ # __PROJECT_NAME__
581
+
582
+ A Warpgogol workshop powered by the Forge engine.
583
+
584
+ ## Prerequisites
585
+
586
+ - Node.js 24+
587
+ - pnpm 10+
588
+ - jq (for pre-user-prompt hook)
589
+ - On Windows: Git Bash or WSL (for shell scripts)
590
+
591
+ ## Setup
592
+
593
+ ### 1. Configure npm token
594
+
595
+ This workshop depends on private @warpgogol packages. Edit `.npmrc` and replace `YOUR_NPM_TOKEN` with a valid npm read token:
596
+
597
+ ```sh
598
+ sed -i 's/YOUR_NPM_TOKEN/your_actual_token/' .npmrc
599
+ ```
600
+
601
+ ### 2. Install dependencies
602
+
603
+ ```sh
604
+ pnpm install
605
+ ```
606
+
607
+ ### 3. Install git guards (recommended)
608
+
609
+ Git guards prevent AI agents from running destructive git commands (`git stash`, `git reset --hard`, `git checkout --`, `git restore`, `git clean -f`):
610
+
611
+ ```sh
612
+ bash scripts/setup-git-guards.sh
613
+ ```
614
+
615
+ This installs a shell function into your shell profile (`~/.zshenv` for zsh, `~/.bashrc` for bash/Git Bash). Restart your shell or run `source scripts/git-guard.sh`.
616
+
617
+ > **Windows**: Git guards require Git Bash (included with Git for Windows). Run `bash scripts/setup-git-guards.sh` from Git Bash. If bash is not in PATH, the pre-user-prompt hook wrapper prints a one-time warning. Install `jq` via `winget install jqlang.jq` or `choco install jq`.
618
+
619
+ ### 4. Verify the workshop
620
+
621
+ ```sh
622
+ pnpm exec forge doctor
623
+ pnpm exec forge validate
624
+ ```
625
+
626
+ ## Stack
627
+
628
+ - Engine: @warpgogol/forge
629
+ - Stack profile: system
630
+ - path: hooks/worktree-setup.sh
631
+ content: |
632
+ #!/bin/sh
633
+ # worktree-setup for a flow session worktree (RFC-1487, RFC-1500).
634
+ # Nothing to prepare in this stack — sessions reuse the primary's tooling.
635
+ set -eu
636
+ exit 0
637
+ - path: hooks/integration-gate.sh
638
+ content: |
639
+ #!/bin/sh
640
+ # Integration gate for flow.integrate (RFC-1487, RFC-1500).
641
+ # cwd: the worktree under judgment; non-zero exit refuses.
642
+ set -eu
643
+ if [ -e node_modules/.bin/forge ]; then
644
+ pnpm exec forge validate
645
+ else
646
+ echo "integration-gate: forge is not installed — skipping validation" >&2
647
+ exit 0
648
+ fi
649
+ install:
650
+ - pnpm add -wD @warpgogol/forge prettier vitest