wingfoil 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (339) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +334 -0
  3. package/dist/cli/error.d.ts +11 -0
  4. package/dist/cli/error.d.ts.map +1 -0
  5. package/dist/cli/error.js +27 -0
  6. package/dist/cli/error.js.map +1 -0
  7. package/dist/cli/exit.d.ts +19 -0
  8. package/dist/cli/exit.d.ts.map +1 -0
  9. package/dist/cli/exit.js +14 -0
  10. package/dist/cli/exit.js.map +1 -0
  11. package/dist/cli/index.d.ts +28 -0
  12. package/dist/cli/index.d.ts.map +1 -0
  13. package/dist/cli/index.js +36 -0
  14. package/dist/cli/index.js.map +1 -0
  15. package/dist/cli/init-command.d.ts +34 -0
  16. package/dist/cli/init-command.d.ts.map +1 -0
  17. package/dist/cli/init-command.js +100 -0
  18. package/dist/cli/init-command.js.map +1 -0
  19. package/dist/cli/mcp-command.d.ts +24 -0
  20. package/dist/cli/mcp-command.d.ts.map +1 -0
  21. package/dist/cli/mcp-command.js +42 -0
  22. package/dist/cli/mcp-command.js.map +1 -0
  23. package/dist/cli/output.d.ts +13 -0
  24. package/dist/cli/output.d.ts.map +1 -0
  25. package/dist/cli/output.js +28 -0
  26. package/dist/cli/output.js.map +1 -0
  27. package/dist/cli/program.d.ts +12 -0
  28. package/dist/cli/program.d.ts.map +1 -0
  29. package/dist/cli/program.js +279 -0
  30. package/dist/cli/program.js.map +1 -0
  31. package/dist/cli/registrar.d.ts +69 -0
  32. package/dist/cli/registrar.d.ts.map +1 -0
  33. package/dist/cli/registrar.js +82 -0
  34. package/dist/cli/registrar.js.map +1 -0
  35. package/dist/cli.d.ts +3 -0
  36. package/dist/cli.d.ts.map +1 -0
  37. package/dist/cli.js +45 -0
  38. package/dist/cli.js.map +1 -0
  39. package/dist/core/approval-authority.d.ts +83 -0
  40. package/dist/core/approval-authority.d.ts.map +1 -0
  41. package/dist/core/approval-authority.js +112 -0
  42. package/dist/core/approval-authority.js.map +1 -0
  43. package/dist/core/builtin-asset.d.ts +71 -0
  44. package/dist/core/builtin-asset.d.ts.map +1 -0
  45. package/dist/core/builtin-asset.js +137 -0
  46. package/dist/core/builtin-asset.js.map +1 -0
  47. package/dist/core/builtin-integrity.d.ts +32 -0
  48. package/dist/core/builtin-integrity.d.ts.map +1 -0
  49. package/dist/core/builtin-integrity.js +148 -0
  50. package/dist/core/builtin-integrity.js.map +1 -0
  51. package/dist/core/confinement.d.ts +57 -0
  52. package/dist/core/confinement.d.ts.map +1 -0
  53. package/dist/core/confinement.js +108 -0
  54. package/dist/core/confinement.js.map +1 -0
  55. package/dist/core/context.d.ts +187 -0
  56. package/dist/core/context.d.ts.map +1 -0
  57. package/dist/core/context.js +192 -0
  58. package/dist/core/context.js.map +1 -0
  59. package/dist/core/directive-assign.d.ts +131 -0
  60. package/dist/core/directive-assign.d.ts.map +1 -0
  61. package/dist/core/directive-assign.js +352 -0
  62. package/dist/core/directive-assign.js.map +1 -0
  63. package/dist/core/directives-list.d.ts +80 -0
  64. package/dist/core/directives-list.d.ts.map +1 -0
  65. package/dist/core/directives-list.js +148 -0
  66. package/dist/core/directives-list.js.map +1 -0
  67. package/dist/core/exit-code.d.ts +85 -0
  68. package/dist/core/exit-code.d.ts.map +1 -0
  69. package/dist/core/exit-code.js +163 -0
  70. package/dist/core/exit-code.js.map +1 -0
  71. package/dist/core/git-identity.d.ts +32 -0
  72. package/dist/core/git-identity.d.ts.map +1 -0
  73. package/dist/core/git-identity.js +72 -0
  74. package/dist/core/git-identity.js.map +1 -0
  75. package/dist/core/index.d.ts +388 -0
  76. package/dist/core/index.d.ts.map +1 -0
  77. package/dist/core/index.js +1331 -0
  78. package/dist/core/index.js.map +1 -0
  79. package/dist/core/init.d.ts +78 -0
  80. package/dist/core/init.d.ts.map +1 -0
  81. package/dist/core/init.js +167 -0
  82. package/dist/core/init.js.map +1 -0
  83. package/dist/core/loaders.d.ts +174 -0
  84. package/dist/core/loaders.d.ts.map +1 -0
  85. package/dist/core/loaders.js +364 -0
  86. package/dist/core/loaders.js.map +1 -0
  87. package/dist/core/memory-add-type.d.ts +43 -0
  88. package/dist/core/memory-add-type.d.ts.map +1 -0
  89. package/dist/core/memory-add-type.js +151 -0
  90. package/dist/core/memory-add-type.js.map +1 -0
  91. package/dist/core/memory-transition.d.ts +111 -0
  92. package/dist/core/memory-transition.d.ts.map +1 -0
  93. package/dist/core/memory-transition.js +269 -0
  94. package/dist/core/memory-transition.js.map +1 -0
  95. package/dist/core/registry.d.ts +189 -0
  96. package/dist/core/registry.d.ts.map +1 -0
  97. package/dist/core/registry.js +66 -0
  98. package/dist/core/registry.js.map +1 -0
  99. package/dist/core/relevance.d.ts +86 -0
  100. package/dist/core/relevance.d.ts.map +1 -0
  101. package/dist/core/relevance.js +258 -0
  102. package/dist/core/relevance.js.map +1 -0
  103. package/dist/core/require-reason.d.ts +27 -0
  104. package/dist/core/require-reason.d.ts.map +1 -0
  105. package/dist/core/require-reason.js +95 -0
  106. package/dist/core/require-reason.js.map +1 -0
  107. package/dist/core/types.d.ts +45 -0
  108. package/dist/core/types.d.ts.map +1 -0
  109. package/dist/core/types.js +22 -0
  110. package/dist/core/types.js.map +1 -0
  111. package/dist/core/usage-error.d.ts +20 -0
  112. package/dist/core/usage-error.d.ts.map +1 -0
  113. package/dist/core/usage-error.js +29 -0
  114. package/dist/core/usage-error.js.map +1 -0
  115. package/dist/core/write-guard.d.ts +99 -0
  116. package/dist/core/write-guard.d.ts.map +1 -0
  117. package/dist/core/write-guard.js +247 -0
  118. package/dist/core/write-guard.js.map +1 -0
  119. package/dist/directives/create.d.ts +47 -0
  120. package/dist/directives/create.d.ts.map +1 -0
  121. package/dist/directives/create.js +82 -0
  122. package/dist/directives/create.js.map +1 -0
  123. package/dist/directives/index.d.ts +20 -0
  124. package/dist/directives/index.d.ts.map +1 -0
  125. package/dist/directives/index.js +32 -0
  126. package/dist/directives/index.js.map +1 -0
  127. package/dist/directives/roles-edit.d.ts +53 -0
  128. package/dist/directives/roles-edit.d.ts.map +1 -0
  129. package/dist/directives/roles-edit.js +286 -0
  130. package/dist/directives/roles-edit.js.map +1 -0
  131. package/dist/directives/schema.d.ts +65 -0
  132. package/dist/directives/schema.d.ts.map +1 -0
  133. package/dist/directives/schema.js +68 -0
  134. package/dist/directives/schema.js.map +1 -0
  135. package/dist/dna/edit.d.ts +61 -0
  136. package/dist/dna/edit.d.ts.map +1 -0
  137. package/dist/dna/edit.js +429 -0
  138. package/dist/dna/edit.js.map +1 -0
  139. package/dist/dna/index.d.ts +24 -0
  140. package/dist/dna/index.d.ts.map +1 -0
  141. package/dist/dna/index.js +59 -0
  142. package/dist/dna/index.js.map +1 -0
  143. package/dist/dna/mutate.d.ts +74 -0
  144. package/dist/dna/mutate.d.ts.map +1 -0
  145. package/dist/dna/mutate.js +318 -0
  146. package/dist/dna/mutate.js.map +1 -0
  147. package/dist/dna/path.d.ts +175 -0
  148. package/dist/dna/path.d.ts.map +1 -0
  149. package/dist/dna/path.js +289 -0
  150. package/dist/dna/path.js.map +1 -0
  151. package/dist/dna/roles.d.ts +57 -0
  152. package/dist/dna/roles.d.ts.map +1 -0
  153. package/dist/dna/roles.js +50 -0
  154. package/dist/dna/roles.js.map +1 -0
  155. package/dist/dna/schema.d.ts +172 -0
  156. package/dist/dna/schema.d.ts.map +1 -0
  157. package/dist/dna/schema.js +182 -0
  158. package/dist/dna/schema.js.map +1 -0
  159. package/dist/dna/set.d.ts +145 -0
  160. package/dist/dna/set.d.ts.map +1 -0
  161. package/dist/dna/set.js +428 -0
  162. package/dist/dna/set.js.map +1 -0
  163. package/dist/mcp/dna-resource.d.ts +16 -0
  164. package/dist/mcp/dna-resource.d.ts.map +1 -0
  165. package/dist/mcp/dna-resource.js +56 -0
  166. package/dist/mcp/dna-resource.js.map +1 -0
  167. package/dist/mcp/index.d.ts +49 -0
  168. package/dist/mcp/index.d.ts.map +1 -0
  169. package/dist/mcp/index.js +60 -0
  170. package/dist/mcp/index.js.map +1 -0
  171. package/dist/mcp/memory-resource.d.ts +17 -0
  172. package/dist/mcp/memory-resource.d.ts.map +1 -0
  173. package/dist/mcp/memory-resource.js +133 -0
  174. package/dist/mcp/memory-resource.js.map +1 -0
  175. package/dist/mcp/prompt.d.ts +48 -0
  176. package/dist/mcp/prompt.d.ts.map +1 -0
  177. package/dist/mcp/prompt.js +176 -0
  178. package/dist/mcp/prompt.js.map +1 -0
  179. package/dist/mcp/read-only.d.ts +42 -0
  180. package/dist/mcp/read-only.d.ts.map +1 -0
  181. package/dist/mcp/read-only.js +93 -0
  182. package/dist/mcp/read-only.js.map +1 -0
  183. package/dist/mcp/registrar.d.ts +54 -0
  184. package/dist/mcp/registrar.d.ts.map +1 -0
  185. package/dist/mcp/registrar.js +72 -0
  186. package/dist/mcp/registrar.js.map +1 -0
  187. package/dist/mcp/server.d.ts +58 -0
  188. package/dist/mcp/server.d.ts.map +1 -0
  189. package/dist/mcp/server.js +64 -0
  190. package/dist/mcp/server.js.map +1 -0
  191. package/dist/mcp/workflow-resource.d.ts +17 -0
  192. package/dist/mcp/workflow-resource.d.ts.map +1 -0
  193. package/dist/mcp/workflow-resource.js +63 -0
  194. package/dist/mcp/workflow-resource.js.map +1 -0
  195. package/dist/memory/add.d.ts +50 -0
  196. package/dist/memory/add.d.ts.map +1 -0
  197. package/dist/memory/add.js +131 -0
  198. package/dist/memory/add.js.map +1 -0
  199. package/dist/memory/audit.d.ts +177 -0
  200. package/dist/memory/audit.d.ts.map +1 -0
  201. package/dist/memory/audit.js +287 -0
  202. package/dist/memory/audit.js.map +1 -0
  203. package/dist/memory/commit-message.d.ts +146 -0
  204. package/dist/memory/commit-message.d.ts.map +1 -0
  205. package/dist/memory/commit-message.js +203 -0
  206. package/dist/memory/commit-message.js.map +1 -0
  207. package/dist/memory/entry.d.ts +56 -0
  208. package/dist/memory/entry.d.ts.map +1 -0
  209. package/dist/memory/entry.js +28 -0
  210. package/dist/memory/entry.js.map +1 -0
  211. package/dist/memory/frontmatter-edit.d.ts +68 -0
  212. package/dist/memory/frontmatter-edit.d.ts.map +1 -0
  213. package/dist/memory/frontmatter-edit.js +333 -0
  214. package/dist/memory/frontmatter-edit.js.map +1 -0
  215. package/dist/memory/git-log.d.ts +32 -0
  216. package/dist/memory/git-log.d.ts.map +1 -0
  217. package/dist/memory/git-log.js +100 -0
  218. package/dist/memory/git-log.js.map +1 -0
  219. package/dist/memory/history.d.ts +142 -0
  220. package/dist/memory/history.d.ts.map +1 -0
  221. package/dist/memory/history.js +250 -0
  222. package/dist/memory/history.js.map +1 -0
  223. package/dist/memory/index.d.ts +58 -0
  224. package/dist/memory/index.d.ts.map +1 -0
  225. package/dist/memory/index.js +107 -0
  226. package/dist/memory/index.js.map +1 -0
  227. package/dist/memory/query.d.ts +150 -0
  228. package/dist/memory/query.d.ts.map +1 -0
  229. package/dist/memory/query.js +307 -0
  230. package/dist/memory/query.js.map +1 -0
  231. package/dist/memory/reject.d.ts +11 -0
  232. package/dist/memory/reject.d.ts.map +1 -0
  233. package/dist/memory/reject.js +32 -0
  234. package/dist/memory/reject.js.map +1 -0
  235. package/dist/memory/schema.d.ts +104 -0
  236. package/dist/memory/schema.d.ts.map +1 -0
  237. package/dist/memory/schema.js +161 -0
  238. package/dist/memory/schema.js.map +1 -0
  239. package/dist/memory/state-machine.d.ts +166 -0
  240. package/dist/memory/state-machine.d.ts.map +1 -0
  241. package/dist/memory/state-machine.js +431 -0
  242. package/dist/memory/state-machine.js.map +1 -0
  243. package/dist/memory/submit.d.ts +11 -0
  244. package/dist/memory/submit.d.ts.map +1 -0
  245. package/dist/memory/submit.js +44 -0
  246. package/dist/memory/submit.js.map +1 -0
  247. package/dist/storage/builtin-directives.d.ts +54 -0
  248. package/dist/storage/builtin-directives.d.ts.map +1 -0
  249. package/dist/storage/builtin-directives.js +152 -0
  250. package/dist/storage/builtin-directives.js.map +1 -0
  251. package/dist/storage/commit.d.ts +92 -0
  252. package/dist/storage/commit.d.ts.map +1 -0
  253. package/dist/storage/commit.js +201 -0
  254. package/dist/storage/commit.js.map +1 -0
  255. package/dist/storage/confinement.d.ts +93 -0
  256. package/dist/storage/confinement.d.ts.map +1 -0
  257. package/dist/storage/confinement.js +164 -0
  258. package/dist/storage/confinement.js.map +1 -0
  259. package/dist/storage/document.d.ts +27 -0
  260. package/dist/storage/document.d.ts.map +1 -0
  261. package/dist/storage/document.js +52 -0
  262. package/dist/storage/document.js.map +1 -0
  263. package/dist/storage/errors.d.ts +36 -0
  264. package/dist/storage/errors.d.ts.map +1 -0
  265. package/dist/storage/errors.js +46 -0
  266. package/dist/storage/errors.js.map +1 -0
  267. package/dist/storage/frontmatter.d.ts +27 -0
  268. package/dist/storage/frontmatter.d.ts.map +1 -0
  269. package/dist/storage/frontmatter.js +37 -0
  270. package/dist/storage/frontmatter.js.map +1 -0
  271. package/dist/storage/git-root.d.ts +17 -0
  272. package/dist/storage/git-root.d.ts.map +1 -0
  273. package/dist/storage/git-root.js +49 -0
  274. package/dist/storage/git-root.js.map +1 -0
  275. package/dist/storage/index.d.ts +29 -0
  276. package/dist/storage/index.d.ts.map +1 -0
  277. package/dist/storage/index.js +66 -0
  278. package/dist/storage/index.js.map +1 -0
  279. package/dist/storage/init-state.d.ts +9 -0
  280. package/dist/storage/init-state.d.ts.map +1 -0
  281. package/dist/storage/init-state.js +24 -0
  282. package/dist/storage/init-state.js.map +1 -0
  283. package/dist/storage/layout.d.ts +51 -0
  284. package/dist/storage/layout.d.ts.map +1 -0
  285. package/dist/storage/layout.js +88 -0
  286. package/dist/storage/layout.js.map +1 -0
  287. package/dist/storage/memory-path.d.ts +72 -0
  288. package/dist/storage/memory-path.d.ts.map +1 -0
  289. package/dist/storage/memory-path.js +127 -0
  290. package/dist/storage/memory-path.js.map +1 -0
  291. package/dist/storage/snapshot.d.ts +16 -0
  292. package/dist/storage/snapshot.d.ts.map +1 -0
  293. package/dist/storage/snapshot.js +72 -0
  294. package/dist/storage/snapshot.js.map +1 -0
  295. package/dist/storage/templates.d.ts +88 -0
  296. package/dist/storage/templates.d.ts.map +1 -0
  297. package/dist/storage/templates.js +422 -0
  298. package/dist/storage/templates.js.map +1 -0
  299. package/dist/validation/error-mapper.d.ts +16 -0
  300. package/dist/validation/error-mapper.d.ts.map +1 -0
  301. package/dist/validation/error-mapper.js +18 -0
  302. package/dist/validation/error-mapper.js.map +1 -0
  303. package/dist/validation/errors.d.ts +69 -0
  304. package/dist/validation/errors.d.ts.map +1 -0
  305. package/dist/validation/errors.js +69 -0
  306. package/dist/validation/errors.js.map +1 -0
  307. package/dist/validation/id.d.ts +16 -0
  308. package/dist/validation/id.d.ts.map +1 -0
  309. package/dist/validation/id.js +177 -0
  310. package/dist/validation/id.js.map +1 -0
  311. package/dist/validation/index.d.ts +18 -0
  312. package/dist/validation/index.d.ts.map +1 -0
  313. package/dist/validation/index.js +37 -0
  314. package/dist/validation/index.js.map +1 -0
  315. package/dist/validation/secret-scan.d.ts +129 -0
  316. package/dist/validation/secret-scan.d.ts.map +1 -0
  317. package/dist/validation/secret-scan.js +367 -0
  318. package/dist/validation/secret-scan.js.map +1 -0
  319. package/dist/validation/two-pass.d.ts +24 -0
  320. package/dist/validation/two-pass.d.ts.map +1 -0
  321. package/dist/validation/two-pass.js +24 -0
  322. package/dist/validation/two-pass.js.map +1 -0
  323. package/dist/validation/warning.d.ts +31 -0
  324. package/dist/validation/warning.d.ts.map +1 -0
  325. package/dist/validation/warning.js +81 -0
  326. package/dist/validation/warning.js.map +1 -0
  327. package/dist/validation/yaml.d.ts +9 -0
  328. package/dist/validation/yaml.d.ts.map +1 -0
  329. package/dist/validation/yaml.js +30 -0
  330. package/dist/validation/yaml.js.map +1 -0
  331. package/dist/workflow/index.d.ts +10 -0
  332. package/dist/workflow/index.d.ts.map +1 -0
  333. package/dist/workflow/index.js +16 -0
  334. package/dist/workflow/index.js.map +1 -0
  335. package/dist/workflow/schema.d.ts +89 -0
  336. package/dist/workflow/schema.d.ts.map +1 -0
  337. package/dist/workflow/schema.js +73 -0
  338. package/dist/workflow/schema.js.map +1 -0
  339. package/package.json +78 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/storage/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,eAAO,MAAM,WAAW,EAAG,SAAkB,CAAC;AAE9C,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAChG,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/C,YAAY,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AACpE,OAAO,EAAE,WAAW,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AACnE,YAAY,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACxD,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACrE,YAAY,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AACzF,OAAO,EAAE,mBAAmB,EAAE,YAAY,EAAE,WAAW,EAAE,cAAc,EAAE,cAAc,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAC9I,YAAY,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AACzF,YAAY,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAC7C,OAAO,EACL,SAAS,EACT,cAAc,EACd,gBAAgB,EAChB,eAAe,EACf,gBAAgB,EAChB,wBAAwB,EACxB,sBAAsB,EACtB,sBAAsB,EACtB,qBAAqB,GACtB,MAAM,aAAa,CAAC;AACrB,YAAY,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAClG,OAAO,EAAE,2BAA2B,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC9G,YAAY,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AACrE,OAAO,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AACrE,YAAY,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC"}
@@ -0,0 +1,66 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.serializeSnapshot = exports.computeStateSnapshot = exports.builtinDirectiveMd = exports.BUILTIN_DIRECTIVE_IDS = exports.BUILTIN_DIRECTIVE_TEMPLATES = exports.BUILTIN_WORKFLOWS_DIR = exports.BUILTIN_DIRECTIVES_DIR = exports.builtinTemplateSources = exports.initProjectCommitMessage = exports.templateScaffold = exports.resolveTemplate = exports.DEFAULT_TEMPLATE = exports.TEMPLATE_NAMES = exports.TEMPLATES = exports.INIT_COMMIT_MESSAGE = exports.WINGFOIL_DIR = exports.scaffoldFiles = exports.initStorage = exports.readPathAtRev = exports.pathPorcelainStatus = exports.listPathsAtRev = exports.EMPTY_TREE_SHA = exports.commitPaths = exports.commitParent = exports.changedPathsBetween = exports.writeDocument = exports.removeDocument = exports.documentExists = exports.readDocument = exports.splitFrontmatter = exports.extractFrontmatter = exports.resolveRealPathInRoot = exports.escapesRoot = exports.resolveMemoryPath = exports.renderMemoryPath = exports.detectInitState = exports.resolveProjectRoot = exports.findGitRoot = exports.E_MISSING_PATH_VALUE = exports.E_NOT_AT_GIT_ROOT = exports.E_NO_GIT_ROOT = exports.StorageError = exports.MODULE_NAME = void 0;
4
+ /**
5
+ * `storage` module — git-backed file storage (YAML + Markdown); single source of truth
6
+ * (REQ-SYS-01, task-003-git-backed-sot). Single entry point for: resolving the WingFoil project
7
+ * root, detecting initialization state, rendering a Memory type's `path` pattern
8
+ * (spec-001-memory-yaml-schema) against concrete values, reading/writing document bytes, and
9
+ * computing the whole-project state snapshot the REQ-SYS-01 fit criterion is stated in terms of.
10
+ */
11
+ exports.MODULE_NAME = 'storage';
12
+ var errors_1 = require("./errors");
13
+ Object.defineProperty(exports, "StorageError", { enumerable: true, get: function () { return errors_1.StorageError; } });
14
+ Object.defineProperty(exports, "E_NO_GIT_ROOT", { enumerable: true, get: function () { return errors_1.E_NO_GIT_ROOT; } });
15
+ Object.defineProperty(exports, "E_NOT_AT_GIT_ROOT", { enumerable: true, get: function () { return errors_1.E_NOT_AT_GIT_ROOT; } });
16
+ Object.defineProperty(exports, "E_MISSING_PATH_VALUE", { enumerable: true, get: function () { return errors_1.E_MISSING_PATH_VALUE; } });
17
+ var git_root_1 = require("./git-root");
18
+ Object.defineProperty(exports, "findGitRoot", { enumerable: true, get: function () { return git_root_1.findGitRoot; } });
19
+ Object.defineProperty(exports, "resolveProjectRoot", { enumerable: true, get: function () { return git_root_1.resolveProjectRoot; } });
20
+ var init_state_1 = require("./init-state");
21
+ Object.defineProperty(exports, "detectInitState", { enumerable: true, get: function () { return init_state_1.detectInitState; } });
22
+ var memory_path_1 = require("./memory-path");
23
+ Object.defineProperty(exports, "renderMemoryPath", { enumerable: true, get: function () { return memory_path_1.renderMemoryPath; } });
24
+ Object.defineProperty(exports, "resolveMemoryPath", { enumerable: true, get: function () { return memory_path_1.resolveMemoryPath; } });
25
+ var confinement_1 = require("./confinement");
26
+ Object.defineProperty(exports, "escapesRoot", { enumerable: true, get: function () { return confinement_1.escapesRoot; } });
27
+ Object.defineProperty(exports, "resolveRealPathInRoot", { enumerable: true, get: function () { return confinement_1.resolveRealPathInRoot; } });
28
+ var frontmatter_1 = require("./frontmatter");
29
+ Object.defineProperty(exports, "extractFrontmatter", { enumerable: true, get: function () { return frontmatter_1.extractFrontmatter; } });
30
+ Object.defineProperty(exports, "splitFrontmatter", { enumerable: true, get: function () { return frontmatter_1.splitFrontmatter; } });
31
+ var document_1 = require("./document");
32
+ Object.defineProperty(exports, "readDocument", { enumerable: true, get: function () { return document_1.readDocument; } });
33
+ Object.defineProperty(exports, "documentExists", { enumerable: true, get: function () { return document_1.documentExists; } });
34
+ Object.defineProperty(exports, "removeDocument", { enumerable: true, get: function () { return document_1.removeDocument; } });
35
+ Object.defineProperty(exports, "writeDocument", { enumerable: true, get: function () { return document_1.writeDocument; } });
36
+ var commit_1 = require("./commit");
37
+ Object.defineProperty(exports, "changedPathsBetween", { enumerable: true, get: function () { return commit_1.changedPathsBetween; } });
38
+ Object.defineProperty(exports, "commitParent", { enumerable: true, get: function () { return commit_1.commitParent; } });
39
+ Object.defineProperty(exports, "commitPaths", { enumerable: true, get: function () { return commit_1.commitPaths; } });
40
+ Object.defineProperty(exports, "EMPTY_TREE_SHA", { enumerable: true, get: function () { return commit_1.EMPTY_TREE_SHA; } });
41
+ Object.defineProperty(exports, "listPathsAtRev", { enumerable: true, get: function () { return commit_1.listPathsAtRev; } });
42
+ Object.defineProperty(exports, "pathPorcelainStatus", { enumerable: true, get: function () { return commit_1.pathPorcelainStatus; } });
43
+ Object.defineProperty(exports, "readPathAtRev", { enumerable: true, get: function () { return commit_1.readPathAtRev; } });
44
+ var layout_1 = require("./layout");
45
+ Object.defineProperty(exports, "initStorage", { enumerable: true, get: function () { return layout_1.initStorage; } });
46
+ Object.defineProperty(exports, "scaffoldFiles", { enumerable: true, get: function () { return layout_1.scaffoldFiles; } });
47
+ Object.defineProperty(exports, "WINGFOIL_DIR", { enumerable: true, get: function () { return layout_1.WINGFOIL_DIR; } });
48
+ Object.defineProperty(exports, "INIT_COMMIT_MESSAGE", { enumerable: true, get: function () { return layout_1.INIT_COMMIT_MESSAGE; } });
49
+ var templates_1 = require("./templates");
50
+ Object.defineProperty(exports, "TEMPLATES", { enumerable: true, get: function () { return templates_1.TEMPLATES; } });
51
+ Object.defineProperty(exports, "TEMPLATE_NAMES", { enumerable: true, get: function () { return templates_1.TEMPLATE_NAMES; } });
52
+ Object.defineProperty(exports, "DEFAULT_TEMPLATE", { enumerable: true, get: function () { return templates_1.DEFAULT_TEMPLATE; } });
53
+ Object.defineProperty(exports, "resolveTemplate", { enumerable: true, get: function () { return templates_1.resolveTemplate; } });
54
+ Object.defineProperty(exports, "templateScaffold", { enumerable: true, get: function () { return templates_1.templateScaffold; } });
55
+ Object.defineProperty(exports, "initProjectCommitMessage", { enumerable: true, get: function () { return templates_1.initProjectCommitMessage; } });
56
+ Object.defineProperty(exports, "builtinTemplateSources", { enumerable: true, get: function () { return templates_1.builtinTemplateSources; } });
57
+ Object.defineProperty(exports, "BUILTIN_DIRECTIVES_DIR", { enumerable: true, get: function () { return templates_1.BUILTIN_DIRECTIVES_DIR; } });
58
+ Object.defineProperty(exports, "BUILTIN_WORKFLOWS_DIR", { enumerable: true, get: function () { return templates_1.BUILTIN_WORKFLOWS_DIR; } });
59
+ var builtin_directives_1 = require("./builtin-directives");
60
+ Object.defineProperty(exports, "BUILTIN_DIRECTIVE_TEMPLATES", { enumerable: true, get: function () { return builtin_directives_1.BUILTIN_DIRECTIVE_TEMPLATES; } });
61
+ Object.defineProperty(exports, "BUILTIN_DIRECTIVE_IDS", { enumerable: true, get: function () { return builtin_directives_1.BUILTIN_DIRECTIVE_IDS; } });
62
+ Object.defineProperty(exports, "builtinDirectiveMd", { enumerable: true, get: function () { return builtin_directives_1.builtinDirectiveMd; } });
63
+ var snapshot_1 = require("./snapshot");
64
+ Object.defineProperty(exports, "computeStateSnapshot", { enumerable: true, get: function () { return snapshot_1.computeStateSnapshot; } });
65
+ Object.defineProperty(exports, "serializeSnapshot", { enumerable: true, get: function () { return snapshot_1.serializeSnapshot; } });
66
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/storage/index.ts"],"names":[],"mappings":";;;AAAA;;;;;;GAMG;AACU,QAAA,WAAW,GAAG,SAAkB,CAAC;AAE9C,mCAAgG;AAAvF,sGAAA,YAAY,OAAA;AAAE,uGAAA,aAAa,OAAA;AAAE,2GAAA,iBAAiB,OAAA;AAAE,8GAAA,oBAAoB,OAAA;AAC7E,uCAA6D;AAApD,uGAAA,WAAW,OAAA;AAAE,8GAAA,kBAAkB,OAAA;AACxC,2CAA+C;AAAtC,6GAAA,eAAe,OAAA;AAExB,6CAAoE;AAA3D,+GAAA,gBAAgB,OAAA;AAAE,gHAAA,iBAAiB,OAAA;AAC5C,6CAAmE;AAA1D,0GAAA,WAAW,OAAA;AAAE,oHAAA,qBAAqB,OAAA;AAE3C,6CAAqE;AAA5D,iHAAA,kBAAkB,OAAA;AAAE,+GAAA,gBAAgB,OAAA;AAE7C,uCAAyF;AAAhF,wGAAA,YAAY,OAAA;AAAE,0GAAA,cAAc,OAAA;AAAE,0GAAA,cAAc,OAAA;AAAE,yGAAA,aAAa,OAAA;AACpE,mCAA8I;AAArI,6GAAA,mBAAmB,OAAA;AAAE,sGAAA,YAAY,OAAA;AAAE,qGAAA,WAAW,OAAA;AAAE,wGAAA,cAAc,OAAA;AAAE,wGAAA,cAAc,OAAA;AAAE,6GAAA,mBAAmB,OAAA;AAAE,uGAAA,aAAa,OAAA;AAE3H,mCAAyF;AAAhF,qGAAA,WAAW,OAAA;AAAE,uGAAA,aAAa,OAAA;AAAE,sGAAA,YAAY,OAAA;AAAE,6GAAA,mBAAmB,OAAA;AAEtE,yCAUqB;AATnB,sGAAA,SAAS,OAAA;AACT,2GAAA,cAAc,OAAA;AACd,6GAAA,gBAAgB,OAAA;AAChB,4GAAA,eAAe,OAAA;AACf,6GAAA,gBAAgB,OAAA;AAChB,qHAAA,wBAAwB,OAAA;AACxB,mHAAA,sBAAsB,OAAA;AACtB,mHAAA,sBAAsB,OAAA;AACtB,kHAAA,qBAAqB,OAAA;AAGvB,2DAA8G;AAArG,iIAAA,2BAA2B,OAAA;AAAE,2HAAA,qBAAqB,OAAA;AAAE,wHAAA,kBAAkB,OAAA;AAE/E,uCAAqE;AAA5D,gHAAA,oBAAoB,OAAA;AAAE,6GAAA,iBAAiB,OAAA"}
@@ -0,0 +1,9 @@
1
+ /** The three states a project can be in relative to WingFoil initialization (spec-011). */
2
+ export type InitState = 'absent' | 'incomplete' | 'initialized';
3
+ /**
4
+ * Detect whether `root` (a resolved project root — see {@link resolveProjectRoot} in
5
+ * `./git-root`) is already WingFoil-initialized: `.wingfoil/` must exist AND contain at least one
6
+ * entry. No other marker file is consulted.
7
+ */
8
+ export declare function detectInitState(root: string): InitState;
9
+ //# sourceMappingURL=init-state.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"init-state.d.ts","sourceRoot":"","sources":["../../src/storage/init-state.ts"],"names":[],"mappings":"AASA,2FAA2F;AAC3F,MAAM,MAAM,SAAS,GAAG,QAAQ,GAAG,YAAY,GAAG,aAAa,CAAC;AAEhE;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,CAKvD"}
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.detectInitState = detectInitState;
4
+ /**
5
+ * Initialization-marker detection (task-003-git-backed-sot, REQ-SYS-01, spec-011-storage-layout
6
+ * "Initialization-marker detection algorithm"). Intentionally shallow — top-level non-emptiness
7
+ * only; deep validation of individual pillar files is each pillar's own schema-load responsibility
8
+ * (REQ-SYS-02), not this check's job.
9
+ */
10
+ const fs_1 = require("fs");
11
+ const path_1 = require("path");
12
+ /**
13
+ * Detect whether `root` (a resolved project root — see {@link resolveProjectRoot} in
14
+ * `./git-root`) is already WingFoil-initialized: `.wingfoil/` must exist AND contain at least one
15
+ * entry. No other marker file is consulted.
16
+ */
17
+ function detectInitState(root) {
18
+ const wingfoilDir = (0, path_1.join)(root, '.wingfoil');
19
+ if (!(0, fs_1.existsSync)(wingfoilDir))
20
+ return 'absent';
21
+ const entries = (0, fs_1.readdirSync)(wingfoilDir);
22
+ return entries.length > 0 ? 'initialized' : 'incomplete';
23
+ }
24
+ //# sourceMappingURL=init-state.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"init-state.js","sourceRoot":"","sources":["../../src/storage/init-state.ts"],"names":[],"mappings":";;AAiBA,0CAKC;AAtBD;;;;;GAKG;AACH,2BAA6C;AAC7C,+BAA4B;AAK5B;;;;GAIG;AACH,SAAgB,eAAe,CAAC,IAAY;IAC1C,MAAM,WAAW,GAAG,IAAA,WAAI,EAAC,IAAI,EAAE,WAAW,CAAC,CAAC;IAC5C,IAAI,CAAC,IAAA,eAAU,EAAC,WAAW,CAAC;QAAE,OAAO,QAAQ,CAAC;IAC9C,MAAM,OAAO,GAAG,IAAA,gBAAW,EAAC,WAAW,CAAC,CAAC;IACzC,OAAO,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,YAAY,CAAC;AAC3D,CAAC"}
@@ -0,0 +1,51 @@
1
+ /** The WingFoil root directory name, relative to the project (git) root (spec-011-storage-layout). */
2
+ export declare const WINGFOIL_DIR = ".wingfoil";
3
+ /** Default git subject for the one commit `initStorage` produces (overridable via `initStorage`). */
4
+ export declare const INIT_COMMIT_MESSAGE = "chore(wingfoil): initialize .wingfoil/ storage (P1.1)";
5
+ /** One file to scaffold: a root-relative (POSIX) path under `.wingfoil/` and its initial content. */
6
+ export interface ScaffoldFile {
7
+ /** Path relative to the project root, always under `.wingfoil/`, POSIX-separated. */
8
+ readonly path: string;
9
+ /** Initial file content written verbatim (bytes-only — see {@link writeDocument}). */
10
+ readonly content: string;
11
+ }
12
+ /**
13
+ * The default `.wingfoil/` skeleton: exactly the files the P1.1 acceptance contract
14
+ * (P1.1-git-backed-storage.feature scenario 1) and the P3.5 directive-layout contract
15
+ * (p3-directives/P3.5-project-directives.feature scenario 1) require, in a fixed, hand-written order.
16
+ * Pure and deterministic — no wall-clock, no environment read — so repeated calls are byte-identical
17
+ * (REQ-SYS-07) and callers may compare/diff the set safely.
18
+ *
19
+ * That order is stable but is NOT a lexical sort, which is worth stating because the literal below
20
+ * reads like one: `'.'` (0x2E) sorts before `'/'` (0x2F), so sorting these paths would put
21
+ * `.wingfoil/memory.yaml` BEFORE `.wingfoil/memory/.gitkeep` — the reverse of the order written here.
22
+ * Determinism never depended on the list being sorted, only on it being fixed, which a literal is; so
23
+ * this is a property callers must not assume, not a defect to "fix" by sorting. Contrast
24
+ * `templateScaffold` (./templates), which genuinely does sort its output.
25
+ *
26
+ * `directives/` is split into `built-in/` and `custom/` per spec-011-storage-layout, each reserved by
27
+ * its own `.gitkeep`: P3.5 requires BOTH subfolders to be tracked by git, and git tracks files rather
28
+ * than directories, so one placeholder per subfolder is the minimum that discharges it
29
+ * (task-054-project-directives).
30
+ *
31
+ * That split is also why `initWingfoilStorage` (`src/core/init.ts`) runs the REQ-SEC-10 built-in
32
+ * integrity guard over this list before writing it: `directives/built-in/` is a built-in ASSET
33
+ * directory, so anything non-dotfile ever added here must be schema-checked first. Adding such a file
34
+ * needs no edit there — `builtinTemplateSources` derives the checked set from whatever this function
35
+ * returns (bug-018-init-storage-bypasses-integrity-guard).
36
+ *
37
+ * `workflows/{built-in,custom}/` is deliberately NOT part of this skeleton: it is P4.17 ground, and
38
+ * the complete spec-011 layout is `templateScaffold`'s job (see ./templates).
39
+ */
40
+ export declare function scaffoldFiles(): ScaffoldFile[];
41
+ /**
42
+ * Write every file in `files` (default: {@link scaffoldFiles}) under `root` and stage exactly those
43
+ * paths as a **single** commit (via {@link commitPaths}), returning the new commit's sha.
44
+ *
45
+ * Pure mechanism: it assumes `root` is already a validated git root (the "not a git repository" guard
46
+ * and the git-identity pre-flight live in the `CoreResult` wrapper, `src/core/init.ts`, so both the
47
+ * CLI and MCP surfaces enforce them identically — REQ-SYS-05). Only the given paths are staged, never
48
+ * `git add -A`, so no unrelated working-tree change is swept into the init commit.
49
+ */
50
+ export declare function initStorage(root: string, files?: readonly ScaffoldFile[], message?: string): string;
51
+ //# sourceMappingURL=layout.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"layout.d.ts","sourceRoot":"","sources":["../../src/storage/layout.ts"],"names":[],"mappings":"AAkBA,sGAAsG;AACtG,eAAO,MAAM,YAAY,cAAc,CAAC;AAExC,qGAAqG;AACrG,eAAO,MAAM,mBAAmB,0DAA0D,CAAC;AAE3F,qGAAqG;AACrG,MAAM,WAAW,YAAY;IAC3B,qFAAqF;IACrF,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,sFAAsF;IACtF,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B;AAYD;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,aAAa,IAAI,YAAY,EAAE,CAS9C;AAED;;;;;;;;GAQG;AACH,wBAAgB,WAAW,CACzB,IAAI,EAAE,MAAM,EACZ,KAAK,GAAE,SAAS,YAAY,EAAoB,EAChD,OAAO,GAAE,MAA4B,GACpC,MAAM,CAKR"}
@@ -0,0 +1,88 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.INIT_COMMIT_MESSAGE = exports.WINGFOIL_DIR = void 0;
4
+ exports.scaffoldFiles = scaffoldFiles;
5
+ exports.initStorage = initStorage;
6
+ /**
7
+ * `.wingfoil/` layout scaffolding + init routine (task-018-implement-git-backed-storage, P1.1,
8
+ * REQ-SYS-01 git-backed single source of truth, REQ-SYS-02 decoupled pillars; spec-011-storage-layout).
9
+ *
10
+ * This owns the *mechanism* of laying down and committing the `.wingfoil/` skeleton — the reusable
11
+ * substrate `wingfoil init` (task-029) builds its interactive wizard on top of. It deliberately does
12
+ * NOT implement the CLI command, prompt for values, or populate the full spec-011 layout with real
13
+ * pillar content: `scaffoldFiles()` returns only the minimal committed skeleton the P1.1 acceptance
14
+ * contract requires (`dna.yaml`/`memory.yaml`/`workflows.yaml` + the `memory/` and
15
+ * `directives/{built-in,custom}/` subfolders), and `initStorage` takes an optional `files` override so
16
+ * task-029's wizard can pass its own richer, spec-011-complete file set (with real content) through
17
+ * the exact same write+commit path.
18
+ */
19
+ const path_1 = require("path");
20
+ const commit_1 = require("./commit");
21
+ const document_1 = require("./document");
22
+ /** The WingFoil root directory name, relative to the project (git) root (spec-011-storage-layout). */
23
+ exports.WINGFOIL_DIR = '.wingfoil';
24
+ /** Default git subject for the one commit `initStorage` produces (overridable via `initStorage`). */
25
+ exports.INIT_COMMIT_MESSAGE = 'chore(wingfoil): initialize .wingfoil/ storage (P1.1)';
26
+ // Placeholder pillar-config stubs. Minimal, valid-YAML skeletons only — the real DNA/Memory/Workflow
27
+ // schemas are populated by their owning tasks / task-029's wizard, not by this foundational layout.
28
+ const DNA_STUB = 'version: 1\n# Project DNA (P2.4) — populated by `wingfoil init` / task-025.\n';
29
+ const MEMORY_STUB = 'version: 1\ntypes: {}\n# Memory registry (P1.13) — populated by task-029.\n';
30
+ const WORKFLOWS_STUB = 'version: 1\nincludes: []\n# Workflow config (P4.1) — populated by task-029.\n';
31
+ // Git does not track empty directories, so each required subfolder carries a `.gitkeep` placeholder;
32
+ // this makes `memory/` and `directives/{built-in,custom}/` real, committed, git-tracked directories
33
+ // (P1.1 scenario 1; P3.5 scenario 1's "And both are tracked by git" — see `scaffoldFiles`).
34
+ const GITKEEP = '';
35
+ /**
36
+ * The default `.wingfoil/` skeleton: exactly the files the P1.1 acceptance contract
37
+ * (P1.1-git-backed-storage.feature scenario 1) and the P3.5 directive-layout contract
38
+ * (p3-directives/P3.5-project-directives.feature scenario 1) require, in a fixed, hand-written order.
39
+ * Pure and deterministic — no wall-clock, no environment read — so repeated calls are byte-identical
40
+ * (REQ-SYS-07) and callers may compare/diff the set safely.
41
+ *
42
+ * That order is stable but is NOT a lexical sort, which is worth stating because the literal below
43
+ * reads like one: `'.'` (0x2E) sorts before `'/'` (0x2F), so sorting these paths would put
44
+ * `.wingfoil/memory.yaml` BEFORE `.wingfoil/memory/.gitkeep` — the reverse of the order written here.
45
+ * Determinism never depended on the list being sorted, only on it being fixed, which a literal is; so
46
+ * this is a property callers must not assume, not a defect to "fix" by sorting. Contrast
47
+ * `templateScaffold` (./templates), which genuinely does sort its output.
48
+ *
49
+ * `directives/` is split into `built-in/` and `custom/` per spec-011-storage-layout, each reserved by
50
+ * its own `.gitkeep`: P3.5 requires BOTH subfolders to be tracked by git, and git tracks files rather
51
+ * than directories, so one placeholder per subfolder is the minimum that discharges it
52
+ * (task-054-project-directives).
53
+ *
54
+ * That split is also why `initWingfoilStorage` (`src/core/init.ts`) runs the REQ-SEC-10 built-in
55
+ * integrity guard over this list before writing it: `directives/built-in/` is a built-in ASSET
56
+ * directory, so anything non-dotfile ever added here must be schema-checked first. Adding such a file
57
+ * needs no edit there — `builtinTemplateSources` derives the checked set from whatever this function
58
+ * returns (bug-018-init-storage-bypasses-integrity-guard).
59
+ *
60
+ * `workflows/{built-in,custom}/` is deliberately NOT part of this skeleton: it is P4.17 ground, and
61
+ * the complete spec-011 layout is `templateScaffold`'s job (see ./templates).
62
+ */
63
+ function scaffoldFiles() {
64
+ return [
65
+ { path: `${exports.WINGFOIL_DIR}/directives/built-in/.gitkeep`, content: GITKEEP },
66
+ { path: `${exports.WINGFOIL_DIR}/directives/custom/.gitkeep`, content: GITKEEP },
67
+ { path: `${exports.WINGFOIL_DIR}/dna.yaml`, content: DNA_STUB },
68
+ { path: `${exports.WINGFOIL_DIR}/memory/.gitkeep`, content: GITKEEP },
69
+ { path: `${exports.WINGFOIL_DIR}/memory.yaml`, content: MEMORY_STUB },
70
+ { path: `${exports.WINGFOIL_DIR}/workflows.yaml`, content: WORKFLOWS_STUB },
71
+ ];
72
+ }
73
+ /**
74
+ * Write every file in `files` (default: {@link scaffoldFiles}) under `root` and stage exactly those
75
+ * paths as a **single** commit (via {@link commitPaths}), returning the new commit's sha.
76
+ *
77
+ * Pure mechanism: it assumes `root` is already a validated git root (the "not a git repository" guard
78
+ * and the git-identity pre-flight live in the `CoreResult` wrapper, `src/core/init.ts`, so both the
79
+ * CLI and MCP surfaces enforce them identically — REQ-SYS-05). Only the given paths are staged, never
80
+ * `git add -A`, so no unrelated working-tree change is swept into the init commit.
81
+ */
82
+ function initStorage(root, files = scaffoldFiles(), message = exports.INIT_COMMIT_MESSAGE) {
83
+ for (const file of files) {
84
+ (0, document_1.writeDocument)((0, path_1.join)(root, file.path), file.content);
85
+ }
86
+ return (0, commit_1.commitPaths)(root, files.map((file) => file.path), message);
87
+ }
88
+ //# sourceMappingURL=layout.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"layout.js","sourceRoot":"","sources":["../../src/storage/layout.ts"],"names":[],"mappings":";;;AAsEA,sCASC;AAWD,kCASC;AAnGD;;;;;;;;;;;;GAYG;AACH,+BAA4B;AAE5B,qCAAuC;AACvC,yCAA2C;AAE3C,sGAAsG;AACzF,QAAA,YAAY,GAAG,WAAW,CAAC;AAExC,qGAAqG;AACxF,QAAA,mBAAmB,GAAG,uDAAuD,CAAC;AAU3F,qGAAqG;AACrG,oGAAoG;AACpG,MAAM,QAAQ,GAAG,+EAA+E,CAAC;AACjG,MAAM,WAAW,GAAG,6EAA6E,CAAC;AAClG,MAAM,cAAc,GAAG,+EAA+E,CAAC;AACvG,qGAAqG;AACrG,oGAAoG;AACpG,4FAA4F;AAC5F,MAAM,OAAO,GAAG,EAAE,CAAC;AAEnB;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,SAAgB,aAAa;IAC3B,OAAO;QACL,EAAE,IAAI,EAAE,GAAG,oBAAY,+BAA+B,EAAE,OAAO,EAAE,OAAO,EAAE;QAC1E,EAAE,IAAI,EAAE,GAAG,oBAAY,6BAA6B,EAAE,OAAO,EAAE,OAAO,EAAE;QACxE,EAAE,IAAI,EAAE,GAAG,oBAAY,WAAW,EAAE,OAAO,EAAE,QAAQ,EAAE;QACvD,EAAE,IAAI,EAAE,GAAG,oBAAY,kBAAkB,EAAE,OAAO,EAAE,OAAO,EAAE;QAC7D,EAAE,IAAI,EAAE,GAAG,oBAAY,cAAc,EAAE,OAAO,EAAE,WAAW,EAAE;QAC7D,EAAE,IAAI,EAAE,GAAG,oBAAY,iBAAiB,EAAE,OAAO,EAAE,cAAc,EAAE;KACpE,CAAC;AACJ,CAAC;AAED;;;;;;;;GAQG;AACH,SAAgB,WAAW,CACzB,IAAY,EACZ,QAAiC,aAAa,EAAE,EAChD,UAAkB,2BAAmB;IAErC,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,IAAA,wBAAa,EAAC,IAAA,WAAI,EAAC,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;IACrD,CAAC;IACD,OAAO,IAAA,oBAAW,EAAC,IAAI,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,OAAO,CAAC,CAAC;AACpE,CAAC"}
@@ -0,0 +1,72 @@
1
+ /**
2
+ * Render a `path` pattern against a set of concrete placeholder values.
3
+ *
4
+ * @throws {@link StorageError} `E_MISSING_PATH_VALUE` naming every `{placeholder}` in `pattern`
5
+ * that has no corresponding key in `values` (all missing values are reported together, not just
6
+ * the first).
7
+ */
8
+ export declare function renderMemoryPath(pattern: string, values: Record<string, string>): string;
9
+ /** Render `pattern` (see {@link renderMemoryPath}) and resolve it to an absolute path under `root`. */
10
+ export declare function resolveMemoryPath(root: string, pattern: string, values: Record<string, string>): string;
11
+ /**
12
+ * Render + resolve a Memory-entry path (see {@link resolveMemoryPath}) **and enforce storage
13
+ * confinement (REQ-SEC-06)**: the absolute target must be strictly inside the project `root`.
14
+ * `path.join`/`resolve` normalize `../`, so a crafted `id` (or any placeholder value) containing
15
+ * traversal could otherwise steer the write outside the managed, git-tracked store that REQ-SYS-01
16
+ * establishes as project truth — this refuses that **before** returning a path, so no caller ever
17
+ * writes outside the root.
18
+ *
19
+ * The boundary itself is {@link escapesRoot} (`./confinement.ts`), shared with every other store so
20
+ * that "inside the project root" has one definition. It is asked **twice, about two resolutions of
21
+ * the same path**, because a string and a filesystem answer different questions and a Memory write
22
+ * has to survive both (`task-105`, `bug-117-memory-add-writes-outside-the-project-root-through-a-symlinked-store`):
23
+ *
24
+ * 1. **Textually** (`task-017`) — what the rendered pattern *says*. An ordinary `../` smuggled
25
+ * through a placeholder value is caught by **either** check, so that case alone would not justify
26
+ * keeping this one. What only this check decides is the **laundered** traversal: with a symlink
27
+ * outside the root pointing back into it, `resolveRealPathInRoot(root, '…/../../link/x.md')`
28
+ * reports `within: true` for a string that plainly climbs out of the project. The string is what
29
+ * the project declared, and a link that whoever owns the directory *above* the root can repoint
30
+ * at any moment does not get to ratify it. Pinned by `refuses a rendered traversal that the
31
+ * filesystem would launder back inside the root`
32
+ * (`test/storage/memory-path-confinement.test.ts`) — deleting this check reds that test and, of
33
+ * the 35 tests in the five suites over this path, only that one.
34
+ * 2. **On the filesystem** ({@link resolveRealPathInRoot}) — where the write will actually land. A
35
+ * symlinked type directory puts the document outside the root with no traversal anywhere in the
36
+ * string, so the textual answer is "inside" and the write is outside; that is `bug-044`'s
37
+ * crossing in the store REQ-SEC-06 is written for. A filesystem answer exists even for a path not
38
+ * yet created: `resolveRealPathInRoot` resolves as far as the filesystem goes and keeps the
39
+ * missing tail verbatim, which is exactly this case — the document is about to be created.
40
+ *
41
+ * The second read resolves against the **working tree** rather than `HEAD`, deliberately and against
42
+ * `command-baseline`'s general rule for a gating read. The argument is `task-102`'s, recorded in
43
+ * `dl-086-a-guard-over-a-filesystem-effect-resolves-on-the-filesystem` (`in-discussion`) and not
44
+ * re-derived here: what this predicts is where `writeFileSync` will land, and it follows the symlinks
45
+ * that are on disk, not the ones a commit records.
46
+ *
47
+ * **The target's parent is resolved; its own name is not** — the asymmetry is
48
+ * {@link resolveRealPathInRoot}'s contract (see that function), and it is the reason this returns a
49
+ * path spelled under `root` **as the caller gave it** rather than under the real root: `commitPaths`
50
+ * runs `git -C <root>` and callers take `relative(root, …)`, so re-spelling a legitimate path would
51
+ * take it out of the repository's own vocabulary.
52
+ *
53
+ * Unresolved is not the same as unexamined, and on this path it could not be (task-106,
54
+ * `bug-120-a-symlinked-document-leaf-is-followed-by-the-write`). Every caller of this function
55
+ * writes — `writeMemoryEntry` (`../memory/entry.ts`) and `memoryAddFn` (`../core/index.ts`), which
56
+ * resolves the same path a second time to guard it — and `writeFileSync` **follows** a symlinked
57
+ * leaf, so accepting one put an element outside the project root and a `wf(<type>): add <id>`
58
+ * subject in history for it. A third check therefore refuses a target whose own name is a link
59
+ * ({@link targetIsSymlink}), without resolving it: where the link points is not judged, so the
60
+ * `bug-044` case that keeps a symlinked file *removable* is untouched — that is a delete, and this
61
+ * resolver serves no deletes. `dl-086` carries the baseline argument for both.
62
+ *
63
+ * @returns the absolute, confinement-verified target path, spelled under `root`.
64
+ * @throws {@link StorageError} `E_PATH_ESCAPES_ROOT` (message: {@link CONFINEMENT_MESSAGE} plus the
65
+ * two spellings of the path, since the two differing is the finding) when the resolved path is the
66
+ * root itself, escapes it textually, or lands outside it on the filesystem.
67
+ * @throws {@link StorageError} `E_TARGET_IS_SYMLINK` (message: `symlinkTargetRefusal`, shared with
68
+ * the transition verbs' `CoreResult` refusal) when the target itself is a symbolic link —
69
+ * including a **dangling** one, which `existsSync` cannot see.
70
+ */
71
+ export declare function resolveConfinedMemoryPath(root: string, pattern: string, values: Record<string, string>): string;
72
+ //# sourceMappingURL=memory-path.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"memory-path.d.ts","sourceRoot":"","sources":["../../src/storage/memory-path.ts"],"names":[],"mappings":"AAsBA;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM,CAiBxF;AAED,uGAAuG;AACvG,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAC7B,MAAM,CAER;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2DG;AACH,wBAAgB,yBAAyB,CACvC,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAC7B,MAAM,CAsBR"}
@@ -0,0 +1,127 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.renderMemoryPath = renderMemoryPath;
4
+ exports.resolveMemoryPath = resolveMemoryPath;
5
+ exports.resolveConfinedMemoryPath = resolveConfinedMemoryPath;
6
+ /**
7
+ * Memory document path resolution (task-003-git-backed-sot, spec-001-memory-yaml-schema
8
+ * `MemoryTypeEntry.path`). A type's `path` pattern (e.g. `docs/04_memory/{release}/{id}.md` for
9
+ * `task`) MAY contain named placeholders besides `{id}`; spec-001 says those are "resolved by the
10
+ * Workflow pillar from the active `element:` chain before the ID engine runs". This module is the
11
+ * one place that renders any such pattern against concrete values — no other code may hardcode a
12
+ * Memory document path.
13
+ *
14
+ * This does not itself generate `{id}` from a counter — that is the ID-generation engine's job
15
+ * (`src/validation/id.ts`, task-002-validation-id-engine); callers pass the already-generated id in
16
+ * `values` like any other placeholder.
17
+ */
18
+ const path_1 = require("path");
19
+ const confinement_1 = require("./confinement");
20
+ const errors_1 = require("./errors");
21
+ /** Exact confinement-violation message required by REQ-SEC-06's fit criterion — do not reword. */
22
+ const CONFINEMENT_MESSAGE = 'Memory entries must reside within the project root';
23
+ const PLACEHOLDER_RE = /\{([^{}]+)\}/g;
24
+ /**
25
+ * Render a `path` pattern against a set of concrete placeholder values.
26
+ *
27
+ * @throws {@link StorageError} `E_MISSING_PATH_VALUE` naming every `{placeholder}` in `pattern`
28
+ * that has no corresponding key in `values` (all missing values are reported together, not just
29
+ * the first).
30
+ */
31
+ function renderMemoryPath(pattern, values) {
32
+ const missing = [];
33
+ const rendered = pattern.replace(PLACEHOLDER_RE, (_match, token) => {
34
+ const value = values[token];
35
+ if (value === undefined) {
36
+ missing.push(token);
37
+ return '';
38
+ }
39
+ return value;
40
+ });
41
+ if (missing.length > 0) {
42
+ throw new errors_1.StorageError(errors_1.E_MISSING_PATH_VALUE, `path pattern "${pattern}" is missing value(s) for: ${missing.join(', ')}`);
43
+ }
44
+ return rendered;
45
+ }
46
+ /** Render `pattern` (see {@link renderMemoryPath}) and resolve it to an absolute path under `root`. */
47
+ function resolveMemoryPath(root, pattern, values) {
48
+ return (0, path_1.join)(root, renderMemoryPath(pattern, values));
49
+ }
50
+ /**
51
+ * Render + resolve a Memory-entry path (see {@link resolveMemoryPath}) **and enforce storage
52
+ * confinement (REQ-SEC-06)**: the absolute target must be strictly inside the project `root`.
53
+ * `path.join`/`resolve` normalize `../`, so a crafted `id` (or any placeholder value) containing
54
+ * traversal could otherwise steer the write outside the managed, git-tracked store that REQ-SYS-01
55
+ * establishes as project truth — this refuses that **before** returning a path, so no caller ever
56
+ * writes outside the root.
57
+ *
58
+ * The boundary itself is {@link escapesRoot} (`./confinement.ts`), shared with every other store so
59
+ * that "inside the project root" has one definition. It is asked **twice, about two resolutions of
60
+ * the same path**, because a string and a filesystem answer different questions and a Memory write
61
+ * has to survive both (`task-105`, `bug-117-memory-add-writes-outside-the-project-root-through-a-symlinked-store`):
62
+ *
63
+ * 1. **Textually** (`task-017`) — what the rendered pattern *says*. An ordinary `../` smuggled
64
+ * through a placeholder value is caught by **either** check, so that case alone would not justify
65
+ * keeping this one. What only this check decides is the **laundered** traversal: with a symlink
66
+ * outside the root pointing back into it, `resolveRealPathInRoot(root, '…/../../link/x.md')`
67
+ * reports `within: true` for a string that plainly climbs out of the project. The string is what
68
+ * the project declared, and a link that whoever owns the directory *above* the root can repoint
69
+ * at any moment does not get to ratify it. Pinned by `refuses a rendered traversal that the
70
+ * filesystem would launder back inside the root`
71
+ * (`test/storage/memory-path-confinement.test.ts`) — deleting this check reds that test and, of
72
+ * the 35 tests in the five suites over this path, only that one.
73
+ * 2. **On the filesystem** ({@link resolveRealPathInRoot}) — where the write will actually land. A
74
+ * symlinked type directory puts the document outside the root with no traversal anywhere in the
75
+ * string, so the textual answer is "inside" and the write is outside; that is `bug-044`'s
76
+ * crossing in the store REQ-SEC-06 is written for. A filesystem answer exists even for a path not
77
+ * yet created: `resolveRealPathInRoot` resolves as far as the filesystem goes and keeps the
78
+ * missing tail verbatim, which is exactly this case — the document is about to be created.
79
+ *
80
+ * The second read resolves against the **working tree** rather than `HEAD`, deliberately and against
81
+ * `command-baseline`'s general rule for a gating read. The argument is `task-102`'s, recorded in
82
+ * `dl-086-a-guard-over-a-filesystem-effect-resolves-on-the-filesystem` (`in-discussion`) and not
83
+ * re-derived here: what this predicts is where `writeFileSync` will land, and it follows the symlinks
84
+ * that are on disk, not the ones a commit records.
85
+ *
86
+ * **The target's parent is resolved; its own name is not** — the asymmetry is
87
+ * {@link resolveRealPathInRoot}'s contract (see that function), and it is the reason this returns a
88
+ * path spelled under `root` **as the caller gave it** rather than under the real root: `commitPaths`
89
+ * runs `git -C <root>` and callers take `relative(root, …)`, so re-spelling a legitimate path would
90
+ * take it out of the repository's own vocabulary.
91
+ *
92
+ * Unresolved is not the same as unexamined, and on this path it could not be (task-106,
93
+ * `bug-120-a-symlinked-document-leaf-is-followed-by-the-write`). Every caller of this function
94
+ * writes — `writeMemoryEntry` (`../memory/entry.ts`) and `memoryAddFn` (`../core/index.ts`), which
95
+ * resolves the same path a second time to guard it — and `writeFileSync` **follows** a symlinked
96
+ * leaf, so accepting one put an element outside the project root and a `wf(<type>): add <id>`
97
+ * subject in history for it. A third check therefore refuses a target whose own name is a link
98
+ * ({@link targetIsSymlink}), without resolving it: where the link points is not judged, so the
99
+ * `bug-044` case that keeps a symlinked file *removable* is untouched — that is a delete, and this
100
+ * resolver serves no deletes. `dl-086` carries the baseline argument for both.
101
+ *
102
+ * @returns the absolute, confinement-verified target path, spelled under `root`.
103
+ * @throws {@link StorageError} `E_PATH_ESCAPES_ROOT` (message: {@link CONFINEMENT_MESSAGE} plus the
104
+ * two spellings of the path, since the two differing is the finding) when the resolved path is the
105
+ * root itself, escapes it textually, or lands outside it on the filesystem.
106
+ * @throws {@link StorageError} `E_TARGET_IS_SYMLINK` (message: `symlinkTargetRefusal`, shared with
107
+ * the transition verbs' `CoreResult` refusal) when the target itself is a symbolic link —
108
+ * including a **dangling** one, which `existsSync` cannot see.
109
+ */
110
+ function resolveConfinedMemoryPath(root, pattern, values) {
111
+ const resolvedRoot = (0, path_1.resolve)(root);
112
+ const rendered = renderMemoryPath(pattern, values);
113
+ const target = (0, path_1.resolve)(resolvedRoot, rendered);
114
+ if ((0, confinement_1.escapesRoot)(resolvedRoot, target)) {
115
+ throw new errors_1.StorageError(errors_1.E_PATH_ESCAPES_ROOT, `${CONFINEMENT_MESSAGE}: '${rendered}' resolves to '${target}', outside the project root.`);
116
+ }
117
+ const onDisk = (0, confinement_1.resolveRealPathInRoot)(resolvedRoot, rendered);
118
+ if (!onDisk.within) {
119
+ throw new errors_1.StorageError(errors_1.E_PATH_ESCAPES_ROOT, `${CONFINEMENT_MESSAGE}: '${rendered}' resolves to '${onDisk.real}', outside the project root — ` +
120
+ 'a directory on the way to it is a symlink leaving the project.');
121
+ }
122
+ if ((0, confinement_1.targetIsSymlink)(target)) {
123
+ throw new errors_1.StorageError(errors_1.E_TARGET_IS_SYMLINK, (0, confinement_1.symlinkTargetRefusal)('create', rendered));
124
+ }
125
+ return target;
126
+ }
127
+ //# sourceMappingURL=memory-path.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"memory-path.js","sourceRoot":"","sources":["../../src/storage/memory-path.ts"],"names":[],"mappings":";;AA6BA,4CAiBC;AAGD,8CAMC;AA8DD,8DA0BC;AA/ID;;;;;;;;;;;GAWG;AACH,+BAAqC;AAErC,+CAA0G;AAC1G,qCAAwG;AAExG,kGAAkG;AAClG,MAAM,mBAAmB,GAAG,oDAAoD,CAAC;AAEjF,MAAM,cAAc,GAAG,eAAe,CAAC;AAEvC;;;;;;GAMG;AACH,SAAgB,gBAAgB,CAAC,OAAe,EAAE,MAA8B;IAC9E,MAAM,OAAO,GAAa,EAAE,CAAC;IAC7B,MAAM,QAAQ,GAAG,OAAO,CAAC,OAAO,CAAC,cAAc,EAAE,CAAC,MAAM,EAAE,KAAa,EAAE,EAAE;QACzE,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;QAC5B,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YACxB,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YACpB,OAAO,EAAE,CAAC;QACZ,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC,CAAC,CAAC;IACH,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACvB,MAAM,IAAI,qBAAY,CACpB,6BAAoB,EACpB,iBAAiB,OAAO,8BAA8B,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAC3E,CAAC;IACJ,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,uGAAuG;AACvG,SAAgB,iBAAiB,CAC/B,IAAY,EACZ,OAAe,EACf,MAA8B;IAE9B,OAAO,IAAA,WAAI,EAAC,IAAI,EAAE,gBAAgB,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC;AACvD,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2DG;AACH,SAAgB,yBAAyB,CACvC,IAAY,EACZ,OAAe,EACf,MAA8B;IAE9B,MAAM,YAAY,GAAG,IAAA,cAAO,EAAC,IAAI,CAAC,CAAC;IACnC,MAAM,QAAQ,GAAG,gBAAgB,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IACnD,MAAM,MAAM,GAAG,IAAA,cAAO,EAAC,YAAY,EAAE,QAAQ,CAAC,CAAC;IAC/C,IAAI,IAAA,yBAAW,EAAC,YAAY,EAAE,MAAM,CAAC,EAAE,CAAC;QACtC,MAAM,IAAI,qBAAY,CACpB,4BAAmB,EACnB,GAAG,mBAAmB,MAAM,QAAQ,kBAAkB,MAAM,8BAA8B,CAC3F,CAAC;IACJ,CAAC;IACD,MAAM,MAAM,GAAG,IAAA,mCAAqB,EAAC,YAAY,EAAE,QAAQ,CAAC,CAAC;IAC7D,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;QACnB,MAAM,IAAI,qBAAY,CACpB,4BAAmB,EACnB,GAAG,mBAAmB,MAAM,QAAQ,kBAAkB,MAAM,CAAC,IAAI,gCAAgC;YAC/F,gEAAgE,CACnE,CAAC;IACJ,CAAC;IACD,IAAI,IAAA,6BAAe,EAAC,MAAM,CAAC,EAAE,CAAC;QAC5B,MAAM,IAAI,qBAAY,CAAC,4BAAmB,EAAE,IAAA,kCAAoB,EAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC;IACxF,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -0,0 +1,16 @@
1
+ /** One entry of a state snapshot: a root-relative, POSIX-separated path and its recorded content. */
2
+ export interface SnapshotEntry {
3
+ /** Path relative to the project root, always POSIX-separated (`/`) regardless of platform. */
4
+ readonly path: string;
5
+ /** Full raw content for `.wingfoil/**` files; frontmatter-only text for Memory `.md` documents. */
6
+ readonly content: string;
7
+ }
8
+ /**
9
+ * Compute a deterministic snapshot of all git-backed WingFoil state under `root` (a resolved
10
+ * project root — see `./git-root`). No file outside `.wingfoil/` and `docs/04_memory/**\/*.md` is
11
+ * read; no cache is kept between calls.
12
+ */
13
+ export declare function computeStateSnapshot(root: string): SnapshotEntry[];
14
+ /** Deterministic string serialization of a snapshot, for byte-identical comparison (REQ-SYS-01). */
15
+ export declare function serializeSnapshot(entries: readonly SnapshotEntry[]): string;
16
+ //# sourceMappingURL=snapshot.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"snapshot.d.ts","sourceRoot":"","sources":["../../src/storage/snapshot.ts"],"names":[],"mappings":"AAoBA,qGAAqG;AACrG,MAAM,WAAW,aAAa;IAC5B,8FAA8F;IAC9F,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,mGAAmG;IACnG,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B;AA8BD;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,aAAa,EAAE,CAclE;AAED,oGAAoG;AACpG,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,SAAS,aAAa,EAAE,GAAG,MAAM,CAE3E"}
@@ -0,0 +1,72 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.computeStateSnapshot = computeStateSnapshot;
4
+ exports.serializeSnapshot = serializeSnapshot;
5
+ /**
6
+ * State snapshot (task-003-git-backed-sot) — the direct implementation of REQ-SYS-01's SARD fit
7
+ * criterion (docs/02_requirements/03_sard/01_architecture.md):
8
+ *
9
+ * "A fresh git clone of the repository reconstructs 100% of Memory/DNA/Directives/Workflow state
10
+ * with no external data source; a state dump before and after clone is byte-identical."
11
+ *
12
+ * `computeStateSnapshot` is a pure function of what's on disk under `root`: every file under
13
+ * `.wingfoil/` in full (DNA/Directives/Workflow config, per spec-011-storage-layout's directory
14
+ * layout) plus every `docs/04_memory/**\/*.md` document's frontmatter only (Memory content — state
15
+ * lives in frontmatter, CLAUDE.md §5 / REQ-STATE-01/-02, so the body text isn't part of "state").
16
+ * It holds no module-level cache and consults nothing outside `root`, so recomputing it — from the
17
+ * original working copy, from a fresh clone, or from a freshly re-imported module — always yields
18
+ * the same result for the same on-disk bytes.
19
+ */
20
+ const fs_1 = require("fs");
21
+ const path_1 = require("path");
22
+ const frontmatter_1 = require("./frontmatter");
23
+ function toPosixRelative(root, absolute) {
24
+ return (0, path_1.relative)(root, absolute).split(path_1.sep).join('/');
25
+ }
26
+ /**
27
+ * Recursively list every regular file under `dir`, as root-relative POSIX paths, sorted
28
+ * lexicographically. Directory-entry order from `readdirSync` is not guaranteed stable across
29
+ * filesystems/platforms, so traversal always sorts explicitly (REQ-SYS-07: no unordered iteration
30
+ * in a context-building path) rather than trusting it. Returns `[]` if `dir` doesn't exist.
31
+ */
32
+ function listFilesSorted(root, dir) {
33
+ if (!(0, fs_1.existsSync)(dir) || !(0, fs_1.statSync)(dir).isDirectory())
34
+ return [];
35
+ const out = [];
36
+ const walk = (current) => {
37
+ for (const entry of (0, fs_1.readdirSync)(current).sort()) {
38
+ const full = (0, path_1.join)(current, entry);
39
+ if ((0, fs_1.statSync)(full).isDirectory()) {
40
+ walk(full);
41
+ }
42
+ else {
43
+ out.push(full);
44
+ }
45
+ }
46
+ };
47
+ walk(dir);
48
+ return out.map((absolute) => toPosixRelative(root, absolute)).sort();
49
+ }
50
+ /**
51
+ * Compute a deterministic snapshot of all git-backed WingFoil state under `root` (a resolved
52
+ * project root — see `./git-root`). No file outside `.wingfoil/` and `docs/04_memory/**\/*.md` is
53
+ * read; no cache is kept between calls.
54
+ */
55
+ function computeStateSnapshot(root) {
56
+ const entries = [];
57
+ for (const path of listFilesSorted(root, (0, path_1.join)(root, '.wingfoil'))) {
58
+ entries.push({ path, content: (0, fs_1.readFileSync)((0, path_1.join)(root, path), 'utf-8') });
59
+ }
60
+ for (const path of listFilesSorted(root, (0, path_1.join)(root, 'docs', '04_memory'))) {
61
+ if (!path.endsWith('.md'))
62
+ continue;
63
+ const raw = (0, fs_1.readFileSync)((0, path_1.join)(root, path), 'utf-8');
64
+ entries.push({ path, content: (0, frontmatter_1.extractFrontmatter)(raw) ?? '' });
65
+ }
66
+ return entries.sort((a, b) => (a.path < b.path ? -1 : a.path > b.path ? 1 : 0));
67
+ }
68
+ /** Deterministic string serialization of a snapshot, for byte-identical comparison (REQ-SYS-01). */
69
+ function serializeSnapshot(entries) {
70
+ return entries.map((entry) => `${entry.path}\n${entry.content}`).join('\n---ENTRY---\n');
71
+ }
72
+ //# sourceMappingURL=snapshot.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"snapshot.js","sourceRoot":"","sources":["../../src/storage/snapshot.ts"],"names":[],"mappings":";;AA6DA,oDAcC;AAGD,8CAEC;AAhFD;;;;;;;;;;;;;;GAcG;AACH,2BAAqE;AACrE,+BAA2C;AAE3C,+CAAmD;AAUnD,SAAS,eAAe,CAAC,IAAY,EAAE,QAAgB;IACrD,OAAO,IAAA,eAAQ,EAAC,IAAI,EAAE,QAAQ,CAAC,CAAC,KAAK,CAAC,UAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACvD,CAAC;AAED;;;;;GAKG;AACH,SAAS,eAAe,CAAC,IAAY,EAAE,GAAW;IAChD,IAAI,CAAC,IAAA,eAAU,EAAC,GAAG,CAAC,IAAI,CAAC,IAAA,aAAQ,EAAC,GAAG,CAAC,CAAC,WAAW,EAAE;QAAE,OAAO,EAAE,CAAC;IAEhE,MAAM,GAAG,GAAa,EAAE,CAAC;IACzB,MAAM,IAAI,GAAG,CAAC,OAAe,EAAQ,EAAE;QACrC,KAAK,MAAM,KAAK,IAAI,IAAA,gBAAW,EAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC;YAChD,MAAM,IAAI,GAAG,IAAA,WAAI,EAAC,OAAO,EAAE,KAAK,CAAC,CAAC;YAClC,IAAI,IAAA,aAAQ,EAAC,IAAI,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC;gBACjC,IAAI,CAAC,IAAI,CAAC,CAAC;YACb,CAAC;iBAAM,CAAC;gBACN,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YACjB,CAAC;QACH,CAAC;IACH,CAAC,CAAC;IACF,IAAI,CAAC,GAAG,CAAC,CAAC;IACV,OAAO,GAAG,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,eAAe,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;AACvE,CAAC;AAED;;;;GAIG;AACH,SAAgB,oBAAoB,CAAC,IAAY;IAC/C,MAAM,OAAO,GAAoB,EAAE,CAAC;IAEpC,KAAK,MAAM,IAAI,IAAI,eAAe,CAAC,IAAI,EAAE,IAAA,WAAI,EAAC,IAAI,EAAE,WAAW,CAAC,CAAC,EAAE,CAAC;QAClE,OAAO,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,IAAA,iBAAY,EAAC,IAAA,WAAI,EAAC,IAAI,EAAE,IAAI,CAAC,EAAE,OAAO,CAAC,EAAE,CAAC,CAAC;IAC3E,CAAC;IAED,KAAK,MAAM,IAAI,IAAI,eAAe,CAAC,IAAI,EAAE,IAAA,WAAI,EAAC,IAAI,EAAE,MAAM,EAAE,WAAW,CAAC,CAAC,EAAE,CAAC;QAC1E,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC;YAAE,SAAS;QACpC,MAAM,GAAG,GAAG,IAAA,iBAAY,EAAC,IAAA,WAAI,EAAC,IAAI,EAAE,IAAI,CAAC,EAAE,OAAO,CAAC,CAAC;QACpD,OAAO,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,IAAA,gCAAkB,EAAC,GAAG,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;IACjE,CAAC;IAED,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAClF,CAAC;AAED,oGAAoG;AACpG,SAAgB,iBAAiB,CAAC,OAAiC;IACjE,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,GAAG,KAAK,CAAC,IAAI,KAAK,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;AAC3F,CAAC"}