dreamteamer 0.49.0 → 0.50.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 (977) hide show
  1. package/bin/dreamteamer.js +163 -87
  2. package/collections/modules.collection.yaml +4 -0
  3. package/dist/api.d.ts +89 -0
  4. package/dist/api.js +139 -0
  5. package/dist/changes/commitPending.d.ts +28 -0
  6. package/dist/changes/commitPending.js +658 -0
  7. package/dist/changes/composeSubject.d.ts +9 -0
  8. package/dist/changes/composeSubject.js +19 -0
  9. package/dist/changes/consts.d.ts +11 -0
  10. package/dist/changes/consts.js +19 -0
  11. package/dist/changes/deriveEvents.d.ts +19 -0
  12. package/dist/changes/deriveEvents.js +118 -0
  13. package/dist/changes/foldChanges.d.ts +13 -0
  14. package/dist/changes/foldChanges.js +47 -0
  15. package/dist/changes/groupChanges.d.ts +6 -0
  16. package/dist/changes/groupChanges.js +23 -0
  17. package/dist/changes/layerOf.d.ts +6 -0
  18. package/dist/changes/layerOf.js +12 -0
  19. package/dist/changes/lib/reportLine.d.ts +7 -0
  20. package/dist/changes/lib/reportLine.js +14 -0
  21. package/dist/changes/printChanges.d.ts +11 -0
  22. package/dist/changes/printChanges.js +20 -0
  23. package/dist/changes/recordChanges.d.ts +21 -0
  24. package/dist/changes/recordChanges.js +32 -0
  25. package/dist/changes/rowChanges.d.ts +7 -0
  26. package/dist/changes/rowChanges.js +27 -0
  27. package/dist/changes/types.d.ts +28 -0
  28. package/dist/changes/types.js +1 -0
  29. package/dist/check/check.d.ts +11 -0
  30. package/dist/check/check.js +555 -0
  31. package/dist/check/checkAlone.d.ts +9 -0
  32. package/dist/check/checkAlone.js +200 -0
  33. package/dist/check/consts.d.ts +1 -0
  34. package/dist/check/consts.js +3 -0
  35. package/dist/check/engineRun.d.ts +3 -0
  36. package/dist/check/engineRun.js +20 -0
  37. package/dist/check/freshWorkspace.d.ts +5 -0
  38. package/dist/check/freshWorkspace.js +24 -0
  39. package/dist/check/isStale.d.ts +3 -0
  40. package/dist/check/isStale.js +2 -0
  41. package/dist/check/symlinkedChildRoots.d.ts +3 -0
  42. package/dist/check/symlinkedChildRoots.js +13 -0
  43. package/dist/check/unreadData.d.ts +7 -0
  44. package/dist/check/unreadData.js +113 -0
  45. package/dist/cli.d.ts +21 -0
  46. package/dist/cli.js +151 -0
  47. package/dist/collections/addField.d.ts +23 -0
  48. package/dist/collections/addField.js +28 -0
  49. package/dist/collections/collectionsCommand.d.ts +7 -0
  50. package/dist/collections/collectionsCommand.js +357 -0
  51. package/dist/collections/createCollection.d.ts +21 -0
  52. package/dist/collections/createCollection.js +134 -0
  53. package/dist/collections/lib/applyRewrites.d.ts +4 -0
  54. package/dist/collections/lib/applyRewrites.js +26 -0
  55. package/dist/collections/lib/consts.d.ts +18 -0
  56. package/dist/collections/lib/consts.js +56 -0
  57. package/dist/collections/lib/declaringSource.d.ts +18 -0
  58. package/dist/collections/lib/declaringSource.js +44 -0
  59. package/dist/collections/lib/descriptorSources.d.ts +4 -0
  60. package/dist/collections/lib/descriptorSources.js +16 -0
  61. package/dist/collections/lib/fieldRenameWalk.d.ts +10 -0
  62. package/dist/collections/lib/fieldRenameWalk.js +50 -0
  63. package/dist/collections/lib/mixinDeclaring.d.ts +7 -0
  64. package/dist/collections/lib/mixinDeclaring.js +13 -0
  65. package/dist/collections/lib/mixinSources.d.ts +6 -0
  66. package/dist/collections/lib/mixinSources.js +18 -0
  67. package/dist/collections/lib/mixinsListedBy.d.ts +3 -0
  68. package/dist/collections/lib/mixinsListedBy.js +14 -0
  69. package/dist/collections/lib/placeField.d.ts +7 -0
  70. package/dist/collections/lib/placeField.js +19 -0
  71. package/dist/collections/lib/positionLines.d.ts +10 -0
  72. package/dist/collections/lib/positionLines.js +7 -0
  73. package/dist/collections/lib/qualify.d.ts +2 -0
  74. package/dist/collections/lib/qualify.js +5 -0
  75. package/dist/collections/lib/recordRewrites.d.ts +5 -0
  76. package/dist/collections/lib/recordRewrites.js +27 -0
  77. package/dist/collections/lib/removeFieldPlan.d.ts +26 -0
  78. package/dist/collections/lib/removeFieldPlan.js +57 -0
  79. package/dist/collections/lib/renameFieldPlan.d.ts +12 -0
  80. package/dist/collections/lib/renameFieldPlan.js +18 -0
  81. package/dist/collections/lib/renameInConstraint.d.ts +2 -0
  82. package/dist/collections/lib/renameInConstraint.js +45 -0
  83. package/dist/collections/lib/renameInDisplay.d.ts +2 -0
  84. package/dist/collections/lib/renameInDisplay.js +52 -0
  85. package/dist/collections/lib/renameInTemplate.d.ts +3 -0
  86. package/dist/collections/lib/renameInTemplate.js +12 -0
  87. package/dist/collections/lib/renameKeys.d.ts +13 -0
  88. package/dist/collections/lib/renameKeys.js +31 -0
  89. package/dist/collections/lib/renameMirrorOf.d.ts +3 -0
  90. package/dist/collections/lib/renameMirrorOf.js +10 -0
  91. package/dist/collections/lib/renameOwnField.d.ts +3 -0
  92. package/dist/collections/lib/renameOwnField.js +30 -0
  93. package/dist/collections/lib/renameValueInCondition.d.ts +4 -0
  94. package/dist/collections/lib/renameValueInCondition.js +42 -0
  95. package/dist/collections/lib/renameValueInConstraint.d.ts +3 -0
  96. package/dist/collections/lib/renameValueInConstraint.js +19 -0
  97. package/dist/collections/lib/renameValueInSubschema.d.ts +3 -0
  98. package/dist/collections/lib/renameValueInSubschema.js +24 -0
  99. package/dist/collections/lib/renameValuePlan.d.ts +13 -0
  100. package/dist/collections/lib/renameValuePlan.js +33 -0
  101. package/dist/collections/lib/reportMirror.d.ts +8 -0
  102. package/dist/collections/lib/reportMirror.js +19 -0
  103. package/dist/collections/lib/types.d.ts +36 -0
  104. package/dist/collections/lib/types.js +1 -0
  105. package/dist/collections/lib/upsertField.d.ts +22 -0
  106. package/dist/collections/lib/upsertField.js +39 -0
  107. package/dist/collections/lib/valueRenameWalk.d.ts +4 -0
  108. package/dist/collections/lib/valueRenameWalk.js +60 -0
  109. package/dist/collections/lib/viewSources.d.ts +6 -0
  110. package/dist/collections/lib/viewSources.js +20 -0
  111. package/dist/collections/lib/walkFilter.d.ts +3 -0
  112. package/dist/collections/lib/walkFilter.js +25 -0
  113. package/dist/collections/lib/walkSources.d.ts +17 -0
  114. package/dist/collections/lib/walkSources.js +80 -0
  115. package/dist/collections/moveCollection.d.ts +42 -0
  116. package/dist/collections/moveCollection.js +176 -0
  117. package/dist/collections/removeCollection.d.ts +8 -0
  118. package/dist/collections/removeCollection.js +40 -0
  119. package/dist/collections/removeField.d.ts +30 -0
  120. package/dist/collections/removeField.js +150 -0
  121. package/dist/collections/renameCollection.d.ts +55 -0
  122. package/dist/collections/renameCollection.js +492 -0
  123. package/dist/collections/renameField.d.ts +32 -0
  124. package/dist/collections/renameField.js +49 -0
  125. package/dist/collections/renameValue.d.ts +29 -0
  126. package/dist/collections/renameValue.js +35 -0
  127. package/dist/collections/setCollectionScalars.d.ts +32 -0
  128. package/dist/collections/setCollectionScalars.js +248 -0
  129. package/dist/collections/updateField.d.ts +27 -0
  130. package/dist/collections/updateField.js +20 -0
  131. package/dist/commands/addCommand.d.ts +1 -0
  132. package/dist/commands/addCommand.js +2 -0
  133. package/dist/commands/addFieldCommand.d.ts +1 -0
  134. package/dist/commands/addFieldCommand.js +2 -0
  135. package/dist/commands/changesCommand.d.ts +10 -0
  136. package/dist/commands/changesCommand.js +37 -0
  137. package/dist/commands/checkCommand.d.ts +1 -0
  138. package/dist/commands/checkCommand.js +22 -0
  139. package/dist/commands/commitCommand.d.ts +6 -0
  140. package/dist/commands/commitCommand.js +89 -0
  141. package/dist/commands/compileCommand.d.ts +2 -0
  142. package/dist/commands/compileCommand.js +35 -0
  143. package/dist/commands/diffCommand.d.ts +1 -0
  144. package/dist/commands/diffCommand.js +2 -0
  145. package/dist/commands/doctorCommand.d.ts +1 -0
  146. package/dist/commands/doctorCommand.js +14 -0
  147. package/dist/commands/exportsCommand.d.ts +1 -0
  148. package/dist/commands/exportsCommand.js +10 -0
  149. package/dist/commands/fmtCommand.d.ts +1 -0
  150. package/dist/commands/fmtCommand.js +27 -0
  151. package/dist/commands/getCommand.d.ts +1 -0
  152. package/dist/commands/getCommand.js +2 -0
  153. package/dist/commands/helpCommand.d.ts +5 -0
  154. package/dist/commands/helpCommand.js +27 -0
  155. package/dist/commands/historyCommand.d.ts +1 -0
  156. package/dist/commands/historyCommand.js +2 -0
  157. package/dist/commands/initCommand.d.ts +2 -0
  158. package/dist/commands/initCommand.js +17 -0
  159. package/dist/commands/installCommand.d.ts +1 -0
  160. package/dist/commands/installCommand.js +12 -0
  161. package/dist/commands/lib/fieldVerb.d.ts +12 -0
  162. package/dist/commands/lib/fieldVerb.js +26 -0
  163. package/dist/commands/lib/recordVerb.d.ts +2 -0
  164. package/dist/commands/lib/recordVerb.js +53 -0
  165. package/dist/commands/lib/unknownVerb.d.ts +14 -0
  166. package/dist/commands/lib/unknownVerb.js +74 -0
  167. package/dist/commands/lib/verify.d.ts +3 -0
  168. package/dist/commands/lib/verify.js +4 -0
  169. package/dist/commands/listCommand.d.ts +1 -0
  170. package/dist/commands/listCommand.js +2 -0
  171. package/dist/commands/nextCommand.d.ts +1 -0
  172. package/dist/commands/nextCommand.js +2 -0
  173. package/dist/commands/relationsCommand.d.ts +11 -0
  174. package/dist/commands/relationsCommand.js +186 -0
  175. package/dist/commands/relocateCommand.d.ts +1 -0
  176. package/dist/commands/relocateCommand.js +39 -0
  177. package/dist/commands/renameCommand.d.ts +1 -0
  178. package/dist/commands/renameCommand.js +2 -0
  179. package/dist/commands/renameFieldCommand.d.ts +1 -0
  180. package/dist/commands/renameFieldCommand.js +2 -0
  181. package/dist/commands/renameValueCommand.d.ts +1 -0
  182. package/dist/commands/renameValueCommand.js +2 -0
  183. package/dist/commands/reorderCommand.d.ts +1 -0
  184. package/dist/commands/reorderCommand.js +2 -0
  185. package/dist/commands/resolveCommand.d.ts +15 -0
  186. package/dist/commands/resolveCommand.js +69 -0
  187. package/dist/commands/revertCommand.d.ts +1 -0
  188. package/dist/commands/revertCommand.js +2 -0
  189. package/dist/commands/rmCommand.d.ts +1 -0
  190. package/dist/commands/rmCommand.js +2 -0
  191. package/dist/commands/rmFieldCommand.d.ts +1 -0
  192. package/dist/commands/rmFieldCommand.js +2 -0
  193. package/dist/commands/runCommand.d.ts +5 -0
  194. package/dist/commands/runCommand.js +9 -0
  195. package/dist/commands/setCommand.d.ts +1 -0
  196. package/dist/commands/setCommand.js +2 -0
  197. package/dist/commands/setFieldCommand.d.ts +1 -0
  198. package/dist/commands/setFieldCommand.js +2 -0
  199. package/dist/commands/setupCommand.d.ts +5 -0
  200. package/dist/commands/setupCommand.js +196 -0
  201. package/dist/commands/statusCommand.d.ts +1 -0
  202. package/dist/commands/statusCommand.js +16 -0
  203. package/dist/commands/updateCommand.d.ts +1 -0
  204. package/dist/commands/updateCommand.js +18 -0
  205. package/dist/commands/valuesCommand.d.ts +1 -0
  206. package/dist/commands/valuesCommand.js +2 -0
  207. package/dist/commands/versionCommand.d.ts +2 -0
  208. package/dist/commands/versionCommand.js +7 -0
  209. package/dist/compile/compile.d.ts +24 -0
  210. package/dist/compile/compile.js +1553 -0
  211. package/dist/compile/consts.d.ts +52 -0
  212. package/dist/compile/consts.js +120 -0
  213. package/dist/compile/ensureEditorRecommendation.d.ts +1 -0
  214. package/dist/compile/ensureEditorRecommendation.js +31 -0
  215. package/dist/compile/isV2.d.ts +2 -0
  216. package/dist/compile/isV2.js +1 -0
  217. package/dist/compile/kindDir.d.ts +11 -0
  218. package/dist/compile/kindDir.js +19 -0
  219. package/dist/compile/lib/bindingErrors.d.ts +11 -0
  220. package/dist/compile/lib/bindingErrors.js +47 -0
  221. package/dist/compile/lib/buildCollectionsIndex.d.ts +8 -0
  222. package/dist/compile/lib/buildCollectionsIndex.js +49 -0
  223. package/dist/compile/lib/buildModulesIndex.d.ts +9 -0
  224. package/dist/compile/lib/buildModulesIndex.js +54 -0
  225. package/dist/compile/lib/compileCollections.d.ts +74 -0
  226. package/dist/compile/lib/compileCollections.js +614 -0
  227. package/dist/compile/lib/consts.d.ts +5 -0
  228. package/dist/compile/lib/consts.js +10 -0
  229. package/dist/compile/lib/ensureEnvExample.d.ts +28 -0
  230. package/dist/compile/lib/ensureEnvExample.js +79 -0
  231. package/dist/compile/lib/ensureGitignored.d.ts +6 -0
  232. package/dist/compile/lib/ensureGitignored.js +16 -0
  233. package/dist/compile/lib/filterFields.d.ts +5 -0
  234. package/dist/compile/lib/filterFields.js +17 -0
  235. package/dist/compile/lib/harnessMarkers.d.ts +2 -0
  236. package/dist/compile/lib/harnessMarkers.js +4 -0
  237. package/dist/compile/lib/mergeMixins.d.ts +14 -0
  238. package/dist/compile/lib/mergeMixins.js +55 -0
  239. package/dist/compile/lib/mergeOverlays.d.ts +6 -0
  240. package/dist/compile/lib/mergeOverlays.js +37 -0
  241. package/dist/compile/lib/nameErrors.d.ts +6 -0
  242. package/dist/compile/lib/nameErrors.js +57 -0
  243. package/dist/compile/lib/namespaceProblems.d.ts +8 -0
  244. package/dist/compile/lib/namespaceProblems.js +34 -0
  245. package/dist/compile/lib/overlayView.d.ts +2 -0
  246. package/dist/compile/lib/overlayView.js +17 -0
  247. package/dist/compile/lib/renderContributions.d.ts +14 -0
  248. package/dist/compile/lib/renderContributions.js +50 -0
  249. package/dist/compile/lib/resolveFields.d.ts +21 -0
  250. package/dist/compile/lib/resolveFields.js +232 -0
  251. package/dist/compile/lib/runHarnessAdapters.d.ts +19 -0
  252. package/dist/compile/lib/runHarnessAdapters.js +590 -0
  253. package/dist/compile/lib/shapeErrors.d.ts +3 -0
  254. package/dist/compile/lib/shapeErrors.js +64 -0
  255. package/dist/compile/lib/storageOverlaps.d.ts +17 -0
  256. package/dist/compile/lib/storageOverlaps.js +26 -0
  257. package/dist/compile/lib/subpathProblem.d.ts +6 -0
  258. package/dist/compile/lib/subpathProblem.js +14 -0
  259. package/dist/compile/lib/toJsonSchema.d.ts +9 -0
  260. package/dist/compile/lib/toJsonSchema.js +100 -0
  261. package/dist/compile/lib/types.d.ts +46 -0
  262. package/dist/compile/lib/types.js +1 -0
  263. package/dist/compile/lib/unqualifiedProblems.d.ts +6 -0
  264. package/dist/compile/lib/unqualifiedProblems.js +18 -0
  265. package/dist/compile/lib/viewDisplay.d.ts +6 -0
  266. package/dist/compile/lib/viewDisplay.js +21 -0
  267. package/dist/compile/lib/viewErrors.d.ts +20 -0
  268. package/dist/compile/lib/viewErrors.js +143 -0
  269. package/dist/compile/lib/writeLine.d.ts +12 -0
  270. package/dist/compile/lib/writeLine.js +31 -0
  271. package/dist/compile/sha256.d.ts +1 -0
  272. package/dist/compile/sha256.js +2 -0
  273. package/dist/compile/stagedKindDir.d.ts +18 -0
  274. package/dist/compile/stagedKindDir.js +32 -0
  275. package/dist/compile/staleness.d.ts +11 -0
  276. package/dist/compile/staleness.js +118 -0
  277. package/dist/compile/toPosix.d.ts +2 -0
  278. package/dist/compile/toPosix.js +3 -0
  279. package/dist/compile/types.d.ts +39 -0
  280. package/dist/compile/types.js +1 -0
  281. package/dist/compile/v1ManifestRefusal.d.ts +8 -0
  282. package/dist/compile/v1ManifestRefusal.js +16 -0
  283. package/dist/compile/v1Refusal.d.ts +2 -0
  284. package/dist/compile/v1Refusal.js +5 -0
  285. package/dist/compile/views.d.ts +2 -0
  286. package/dist/compile/views.js +3 -0
  287. package/dist/compile/warnIfStale.d.ts +3 -0
  288. package/dist/compile/warnIfStale.js +10 -0
  289. package/dist/coreVerbs.d.ts +6 -0
  290. package/dist/coreVerbs.js +50 -0
  291. package/dist/doctor/consts.d.ts +10 -0
  292. package/dist/doctor/consts.js +10 -0
  293. package/dist/doctor/doctorBoard.d.ts +7 -0
  294. package/dist/doctor/doctorBoard.js +97 -0
  295. package/dist/doctor/renderBoard.d.ts +2 -0
  296. package/dist/doctor/renderBoard.js +9 -0
  297. package/dist/doctor/types.d.ts +7 -0
  298. package/dist/doctor/types.js +1 -0
  299. package/dist/entities/createSkill.d.ts +12 -0
  300. package/dist/entities/createSkill.js +56 -0
  301. package/dist/entities/entitiesCommand.d.ts +7 -0
  302. package/dist/entities/entitiesCommand.js +97 -0
  303. package/dist/entities/lib/consts.d.ts +2 -0
  304. package/dist/entities/lib/consts.js +2 -0
  305. package/dist/entities/lib/entitySource.d.ts +10 -0
  306. package/dist/entities/lib/entitySource.js +17 -0
  307. package/dist/entities/lib/refuseBuiltSkill.d.ts +9 -0
  308. package/dist/entities/lib/refuseBuiltSkill.js +23 -0
  309. package/dist/entities/lib/refuseHandAuthored.d.ts +7 -0
  310. package/dist/entities/lib/refuseHandAuthored.js +15 -0
  311. package/dist/entities/lib/setFrontmatterKey.d.ts +8 -0
  312. package/dist/entities/lib/setFrontmatterKey.js +21 -0
  313. package/dist/entities/removeEntity.d.ts +7 -0
  314. package/dist/entities/removeEntity.js +35 -0
  315. package/dist/entities/renameEntity.d.ts +11 -0
  316. package/dist/entities/renameEntity.js +51 -0
  317. package/dist/entities/setEntityFrontmatter.d.ts +9 -0
  318. package/dist/entities/setEntityFrontmatter.js +58 -0
  319. package/dist/exports/planExports.d.ts +10 -0
  320. package/dist/exports/planExports.js +72 -0
  321. package/dist/exports/runExports.d.ts +7 -0
  322. package/dist/exports/runExports.js +95 -0
  323. package/dist/exports/serializeExports.d.ts +6 -0
  324. package/dist/exports/serializeExports.js +17 -0
  325. package/dist/extensions/consts.d.ts +1 -0
  326. package/dist/extensions/consts.js +1 -0
  327. package/dist/extensions/declaredExtensions.d.ts +17 -0
  328. package/dist/extensions/declaredExtensions.js +85 -0
  329. package/dist/extensions/extensions.d.ts +21 -0
  330. package/dist/extensions/extensions.js +24 -0
  331. package/dist/extensions/lib/consts.d.ts +2 -0
  332. package/dist/extensions/lib/consts.js +2 -0
  333. package/dist/extensions/lib/validateSetup.d.ts +15 -0
  334. package/dist/extensions/lib/validateSetup.js +128 -0
  335. package/dist/extensions/loadExtensions.d.ts +14 -0
  336. package/dist/extensions/loadExtensions.js +146 -0
  337. package/dist/extensions/manifestViolations.d.ts +11 -0
  338. package/dist/extensions/manifestViolations.js +17 -0
  339. package/dist/fmt/formatDescriptors.d.ts +20 -0
  340. package/dist/fmt/formatDescriptors.js +67 -0
  341. package/dist/fmt/formatSource.d.ts +7 -0
  342. package/dist/fmt/formatSource.js +50 -0
  343. package/dist/init/consts.d.ts +1 -0
  344. package/dist/init/consts.js +1 -0
  345. package/dist/init/escapes.d.ts +2 -0
  346. package/dist/init/escapes.js +64 -0
  347. package/dist/init/init.d.ts +7 -0
  348. package/dist/init/init.js +152 -0
  349. package/dist/init/initCommand.d.ts +30 -0
  350. package/dist/init/initCommand.js +407 -0
  351. package/dist/init/initFootprint.d.ts +6 -0
  352. package/dist/init/initFootprint.js +19 -0
  353. package/dist/init/seedBlock.d.ts +7 -0
  354. package/dist/init/seedBlock.js +37 -0
  355. package/dist/install/applyInstall.d.ts +15 -0
  356. package/dist/install/applyInstall.js +190 -0
  357. package/dist/install/buildClone.d.ts +5 -0
  358. package/dist/install/buildClone.js +22 -0
  359. package/dist/install/commitOf.d.ts +1 -0
  360. package/dist/install/commitOf.js +2 -0
  361. package/dist/install/declaredDeps.d.ts +3 -0
  362. package/dist/install/declaredDeps.js +2 -0
  363. package/dist/install/indexFolder.d.ts +6 -0
  364. package/dist/install/indexFolder.js +32 -0
  365. package/dist/install/install.d.ts +8 -0
  366. package/dist/install/install.js +177 -0
  367. package/dist/install/installCheckout.d.ts +15 -0
  368. package/dist/install/installCheckout.js +142 -0
  369. package/dist/install/installClone.d.ts +6 -0
  370. package/dist/install/installClone.js +32 -0
  371. package/dist/install/installCommand.d.ts +15 -0
  372. package/dist/install/installCommand.js +61 -0
  373. package/dist/install/installModules.d.ts +17 -0
  374. package/dist/install/installModules.js +208 -0
  375. package/dist/install/installedModules.d.ts +12 -0
  376. package/dist/install/installedModules.js +27 -0
  377. package/dist/install/isLink.d.ts +1 -0
  378. package/dist/install/isLink.js +9 -0
  379. package/dist/install/lib/readTarballManifest.d.ts +6 -0
  380. package/dist/install/lib/readTarballManifest.js +27 -0
  381. package/dist/install/npmAndCompile.d.ts +35 -0
  382. package/dist/install/npmAndCompile.js +151 -0
  383. package/dist/install/observeState.d.ts +29 -0
  384. package/dist/install/observeState.js +98 -0
  385. package/dist/install/offRef.d.ts +7 -0
  386. package/dist/install/offRef.js +19 -0
  387. package/dist/install/planInstall.d.ts +9 -0
  388. package/dist/install/planInstall.js +73 -0
  389. package/dist/install/presetMembers.d.ts +17 -0
  390. package/dist/install/presetMembers.js +25 -0
  391. package/dist/install/readHookInput.d.ts +17 -0
  392. package/dist/install/readHookInput.js +29 -0
  393. package/dist/install/readSpecManifest.d.ts +12 -0
  394. package/dist/install/readSpecManifest.js +55 -0
  395. package/dist/install/readStdin.d.ts +12 -0
  396. package/dist/install/readStdin.js +25 -0
  397. package/dist/install/resolveClosure.d.ts +21 -0
  398. package/dist/install/resolveClosure.js +69 -0
  399. package/dist/install/resolves.d.ts +8 -0
  400. package/dist/install/resolves.js +9 -0
  401. package/dist/install/types.d.ts +26 -0
  402. package/dist/install/types.js +1 -0
  403. package/dist/install/versions.d.ts +12 -0
  404. package/dist/install/versions.js +25 -0
  405. package/dist/lib/alreadyThat.d.ts +5 -0
  406. package/dist/lib/alreadyThat.js +8 -0
  407. package/dist/lib/appendMissing.d.ts +1 -0
  408. package/dist/lib/appendMissing.js +7 -0
  409. package/dist/lib/atomicWrite.d.ts +1 -0
  410. package/dist/lib/atomicWrite.js +9 -0
  411. package/dist/lib/baseDescriptorSource.d.ts +18 -0
  412. package/dist/lib/baseDescriptorSource.js +52 -0
  413. package/dist/lib/childEnv.d.ts +12 -0
  414. package/dist/lib/childEnv.js +16 -0
  415. package/dist/lib/collectionSourceFile.d.ts +26 -0
  416. package/dist/lib/collectionSourceFile.js +56 -0
  417. package/dist/lib/consts.d.ts +93 -0
  418. package/dist/lib/consts.js +180 -0
  419. package/dist/lib/dryRunPlan.d.ts +21 -0
  420. package/dist/lib/dryRunPlan.js +23 -0
  421. package/dist/lib/editWorkspacePkg.d.ts +8 -0
  422. package/dist/lib/editWorkspacePkg.js +19 -0
  423. package/dist/lib/emit.d.ts +32 -0
  424. package/dist/lib/emit.js +46 -0
  425. package/dist/lib/emitDocument.d.ts +6 -0
  426. package/dist/lib/emitDocument.js +61 -0
  427. package/dist/lib/endOf.d.ts +11 -0
  428. package/dist/lib/endOf.js +25 -0
  429. package/dist/lib/escapeRe.d.ts +2 -0
  430. package/dist/lib/escapeRe.js +2 -0
  431. package/dist/lib/fieldFromFlags.d.ts +13 -0
  432. package/dist/lib/fieldFromFlags.js +195 -0
  433. package/dist/lib/gatedTreeOp.d.ts +30 -0
  434. package/dist/lib/gatedTreeOp.js +59 -0
  435. package/dist/lib/git/commitArg.d.ts +1 -0
  436. package/dist/lib/git/commitArg.js +13 -0
  437. package/dist/lib/git/defaultGit.d.ts +1 -0
  438. package/dist/lib/git/defaultGit.js +20 -0
  439. package/dist/lib/git/describeCheckout.d.ts +9 -0
  440. package/dist/lib/git/describeCheckout.js +45 -0
  441. package/dist/lib/git/gitOk.d.ts +2 -0
  442. package/dist/lib/git/gitOk.js +11 -0
  443. package/dist/lib/git/inProgress.d.ts +5 -0
  444. package/dist/lib/git/inProgress.js +28 -0
  445. package/dist/lib/git/repoRootOf.d.ts +6 -0
  446. package/dist/lib/git/repoRootOf.js +20 -0
  447. package/dist/lib/git/tryGit.d.ts +1 -0
  448. package/dist/lib/git/tryGit.js +10 -0
  449. package/dist/lib/isEntityKind.d.ts +2 -0
  450. package/dist/lib/isEntityKind.js +3 -0
  451. package/dist/lib/nearest.d.ts +5 -0
  452. package/dist/lib/nearest.js +21 -0
  453. package/dist/lib/need.d.ts +1 -0
  454. package/dist/lib/need.js +5 -0
  455. package/dist/lib/npm/exact.d.ts +5 -0
  456. package/dist/lib/npm/exact.js +5 -0
  457. package/dist/lib/npm/npmFloor.d.ts +2 -0
  458. package/dist/lib/npm/npmFloor.js +18 -0
  459. package/dist/lib/npm/resolveNpm.d.ts +10 -0
  460. package/dist/lib/npm/resolveNpm.js +35 -0
  461. package/dist/lib/npm/satisfies.d.ts +11 -0
  462. package/dist/lib/npm/satisfies.js +66 -0
  463. package/dist/lib/oneValue.d.ts +7 -0
  464. package/dist/lib/oneValue.js +12 -0
  465. package/dist/lib/pairs.d.ts +5 -0
  466. package/dist/lib/pairs.js +15 -0
  467. package/dist/lib/parseArgs.d.ts +17 -0
  468. package/dist/lib/parseArgs.js +36 -0
  469. package/dist/lib/refuseUnknownFlags.d.ts +3 -0
  470. package/dist/lib/refuseUnknownFlags.js +53 -0
  471. package/dist/lib/rel.d.ts +1 -0
  472. package/dist/lib/rel.js +3 -0
  473. package/dist/lib/schema-ops.d.ts +105 -0
  474. package/dist/lib/schema-ops.js +177 -0
  475. package/dist/lib/singular.d.ts +1 -0
  476. package/dist/lib/singular.js +23 -0
  477. package/dist/lib/stripMeta.d.ts +2 -0
  478. package/dist/lib/stripMeta.js +2 -0
  479. package/dist/lib/symlinkBelow.d.ts +13 -0
  480. package/dist/lib/symlinkBelow.js +33 -0
  481. package/dist/lib/types.d.ts +22 -0
  482. package/dist/lib/types.js +1 -0
  483. package/dist/lib/walk.d.ts +5 -0
  484. package/dist/lib/walk.js +21 -0
  485. package/dist/lib/writeSource.d.ts +7 -0
  486. package/dist/lib/writeSource.js +77 -0
  487. package/dist/lib/yaml.d.ts +18 -0
  488. package/dist/lib/yaml.js +26 -0
  489. package/dist/modules/createModule.d.ts +16 -0
  490. package/dist/modules/createModule.js +136 -0
  491. package/dist/modules/lib/consts.d.ts +10 -0
  492. package/dist/modules/lib/consts.js +17 -0
  493. package/dist/modules/lib/extensionText.d.ts +3 -0
  494. package/dist/modules/lib/extensionText.js +36 -0
  495. package/dist/modules/lib/readmeText.d.ts +6 -0
  496. package/dist/modules/lib/readmeText.js +25 -0
  497. package/dist/modules/lib/scaffoldKey.d.ts +2 -0
  498. package/dist/modules/lib/scaffoldKey.js +2 -0
  499. package/dist/modules/lib/testText.d.ts +7 -0
  500. package/dist/modules/lib/testText.js +19 -0
  501. package/dist/modules/modulesCommand.d.ts +4 -0
  502. package/dist/modules/modulesCommand.js +121 -0
  503. package/dist/modules/removeModule.d.ts +25 -0
  504. package/dist/modules/removeModule.js +94 -0
  505. package/dist/modules/renameModule.d.ts +15 -0
  506. package/dist/modules/renameModule.js +109 -0
  507. package/dist/modules/runModuleScript.d.ts +17 -0
  508. package/dist/modules/runModuleScript.js +100 -0
  509. package/dist/modules/setModule.d.ts +9 -0
  510. package/dist/modules/setModule.js +88 -0
  511. package/dist/openWorkspace.d.ts +12 -0
  512. package/dist/openWorkspace.js +22 -0
  513. package/dist/record/bodyField.d.ts +2 -0
  514. package/dist/record/bodyField.js +4 -0
  515. package/dist/record/collectRefFields.d.ts +3 -0
  516. package/dist/record/collectRefFields.js +16 -0
  517. package/dist/record/consts.d.ts +43 -0
  518. package/dist/record/consts.js +85 -0
  519. package/dist/record/descriptor.d.ts +44 -0
  520. package/dist/record/descriptor.js +56 -0
  521. package/dist/record/displayOf.d.ts +3 -0
  522. package/dist/record/displayOf.js +13 -0
  523. package/dist/record/expectedMirrors.d.ts +10 -0
  524. package/dist/record/expectedMirrors.js +27 -0
  525. package/dist/record/exportsContext.d.ts +17 -0
  526. package/dist/record/exportsContext.js +62 -0
  527. package/dist/record/fields.d.ts +9 -0
  528. package/dist/record/fields.js +30 -0
  529. package/dist/record/idFromRecordPath.d.ts +16 -0
  530. package/dist/record/idFromRecordPath.js +28 -0
  531. package/dist/record/lib/applyFilter.d.ts +5 -0
  532. package/dist/record/lib/applyFilter.js +32 -0
  533. package/dist/record/lib/consts.d.ts +7 -0
  534. package/dist/record/lib/consts.js +7 -0
  535. package/dist/record/lib/enumChoices.d.ts +2 -0
  536. package/dist/record/lib/enumChoices.js +16 -0
  537. package/dist/record/lib/fmtDate.d.ts +1 -0
  538. package/dist/record/lib/fmtDate.js +18 -0
  539. package/dist/record/lib/placedChildAt.d.ts +10 -0
  540. package/dist/record/lib/placedChildAt.js +25 -0
  541. package/dist/record/lib/rootRecords.d.ts +8 -0
  542. package/dist/record/lib/rootRecords.js +37 -0
  543. package/dist/record/lib/types.d.ts +6 -0
  544. package/dist/record/lib/types.js +1 -0
  545. package/dist/record/namespace.d.ts +22 -0
  546. package/dist/record/namespace.js +36 -0
  547. package/dist/record/nav.d.ts +41 -0
  548. package/dist/record/nav.js +237 -0
  549. package/dist/record/normalizeNamespaces.d.ts +8 -0
  550. package/dist/record/normalizeNamespaces.js +20 -0
  551. package/dist/record/outsideRefs.d.ts +19 -0
  552. package/dist/record/outsideRefs.js +34 -0
  553. package/dist/record/ownerIdOf.d.ts +11 -0
  554. package/dist/record/ownerIdOf.js +12 -0
  555. package/dist/record/ownersReadIn.d.ts +9 -0
  556. package/dist/record/ownersReadIn.js +11 -0
  557. package/dist/record/parentFolders.d.ts +6 -0
  558. package/dist/record/parentFolders.js +18 -0
  559. package/dist/record/parseRecordText.d.ts +2 -0
  560. package/dist/record/parseRecordText.js +19 -0
  561. package/dist/record/parseRef.d.ts +11 -0
  562. package/dist/record/parseRef.js +27 -0
  563. package/dist/record/parseTemplate.d.ts +3 -0
  564. package/dist/record/parseTemplate.js +24 -0
  565. package/dist/record/pathToRecord.d.ts +9 -0
  566. package/dist/record/pathToRecord.js +39 -0
  567. package/dist/record/placedRecords.d.ts +8 -0
  568. package/dist/record/placedRecords.js +22 -0
  569. package/dist/record/placement.d.ts +15 -0
  570. package/dist/record/placement.js +19 -0
  571. package/dist/record/presentation.d.ts +3 -0
  572. package/dist/record/presentation.js +236 -0
  573. package/dist/record/readExports.d.ts +2 -0
  574. package/dist/record/readExports.js +14 -0
  575. package/dist/record/records.d.ts +15 -0
  576. package/dist/record/records.js +53 -0
  577. package/dist/record/ref.d.ts +12 -0
  578. package/dist/record/ref.js +26 -0
  579. package/dist/record/regenerate.d.ts +18 -0
  580. package/dist/record/regenerate.js +56 -0
  581. package/dist/record/relationsOf.d.ts +3 -0
  582. package/dist/record/relationsOf.js +33 -0
  583. package/dist/record/renderDisplay.d.ts +13 -0
  584. package/dist/record/renderDisplay.js +33 -0
  585. package/dist/record/sees.d.ts +6 -0
  586. package/dist/record/sees.js +7 -0
  587. package/dist/record/serialize.d.ts +2 -0
  588. package/dist/record/serialize.js +35 -0
  589. package/dist/record/splitRef.d.ts +10 -0
  590. package/dist/record/splitRef.js +23 -0
  591. package/dist/record/storageOf.d.ts +3 -0
  592. package/dist/record/storageOf.js +40 -0
  593. package/dist/record/template.d.ts +12 -0
  594. package/dist/record/template.js +28 -0
  595. package/dist/record/temporal.d.ts +2 -0
  596. package/dist/record/temporal.js +8 -0
  597. package/dist/record/types.d.ts +76 -0
  598. package/dist/record/types.js +1 -0
  599. package/dist/record/unknownOperators.d.ts +5 -0
  600. package/dist/record/unknownOperators.js +25 -0
  601. package/dist/record/unknownTokens.d.ts +5 -0
  602. package/dist/record/unknownTokens.js +17 -0
  603. package/dist/record/validateTemplate.d.ts +14 -0
  604. package/dist/record/validateTemplate.js +36 -0
  605. package/dist/record/valuesAt.d.ts +2 -0
  606. package/dist/record/valuesAt.js +11 -0
  607. package/dist/records/commandsFor.d.ts +18 -0
  608. package/dist/records/commandsFor.js +65 -0
  609. package/dist/records/distinctValues.d.ts +16 -0
  610. package/dist/records/distinctValues.js +63 -0
  611. package/dist/records/history.d.ts +19 -0
  612. package/dist/records/history.js +35 -0
  613. package/dist/records/historyDiff.d.ts +7 -0
  614. package/dist/records/historyDiff.js +14 -0
  615. package/dist/records/lib/coerceArrays.d.ts +3 -0
  616. package/dist/records/lib/coerceArrays.js +26 -0
  617. package/dist/records/lib/compareValues.d.ts +8 -0
  618. package/dist/records/lib/compareValues.js +21 -0
  619. package/dist/records/lib/consts.d.ts +3 -0
  620. package/dist/records/lib/consts.js +3 -0
  621. package/dist/records/lib/contributedNotes.d.ts +14 -0
  622. package/dist/records/lib/contributedNotes.js +28 -0
  623. package/dist/records/lib/fmtCell.d.ts +1 -0
  624. package/dist/records/lib/fmtCell.js +1 -0
  625. package/dist/records/lib/keyBetween.d.ts +2 -0
  626. package/dist/records/lib/keyBetween.js +4 -0
  627. package/dist/records/lib/landedIn.d.ts +9 -0
  628. package/dist/records/lib/landedIn.js +13 -0
  629. package/dist/records/lib/listColumns.d.ts +3 -0
  630. package/dist/records/lib/listColumns.js +6 -0
  631. package/dist/records/lib/looseEq.d.ts +6 -0
  632. package/dist/records/lib/looseEq.js +6 -0
  633. package/dist/records/lib/matchesFilter.d.ts +2 -0
  634. package/dist/records/lib/matchesFilter.js +151 -0
  635. package/dist/records/lib/narrowRows.d.ts +16 -0
  636. package/dist/records/lib/narrowRows.js +79 -0
  637. package/dist/records/lib/parseTemporal.d.ts +9 -0
  638. package/dist/records/lib/parseTemporal.js +27 -0
  639. package/dist/records/lib/placementKey.d.ts +12 -0
  640. package/dist/records/lib/placementKey.js +31 -0
  641. package/dist/records/lib/recordResolver.d.ts +8 -0
  642. package/dist/records/lib/recordResolver.js +35 -0
  643. package/dist/records/lib/sortRows.d.ts +6 -0
  644. package/dist/records/lib/sortRows.js +20 -0
  645. package/dist/records/lib/sourceHintFor.d.ts +3 -0
  646. package/dist/records/lib/sourceHintFor.js +12 -0
  647. package/dist/records/lib/tokenValue.d.ts +3 -0
  648. package/dist/records/lib/tokenValue.js +17 -0
  649. package/dist/records/lib/trackedPaths.d.ts +14 -0
  650. package/dist/records/lib/trackedPaths.js +29 -0
  651. package/dist/records/lib/whereKeys.d.ts +8 -0
  652. package/dist/records/lib/whereKeys.js +2 -0
  653. package/dist/records/nextCommand.d.ts +4 -0
  654. package/dist/records/nextCommand.js +53 -0
  655. package/dist/records/recordsCommand.d.ts +7 -0
  656. package/dist/records/recordsCommand.js +291 -0
  657. package/dist/records-api.d.ts +42 -0
  658. package/dist/records-api.js +41 -0
  659. package/dist/repos/lib/relPath.d.ts +1 -0
  660. package/dist/repos/lib/relPath.js +6 -0
  661. package/dist/repos/lib/repoPath.d.ts +3 -0
  662. package/dist/repos/lib/repoPath.js +11 -0
  663. package/dist/repos/listRepos.d.ts +12 -0
  664. package/dist/repos/listRepos.js +28 -0
  665. package/dist/repos/materializeRepo.d.ts +9 -0
  666. package/dist/repos/materializeRepo.js +26 -0
  667. package/dist/repos/repos.d.ts +14 -0
  668. package/dist/repos/repos.js +17 -0
  669. package/dist/repos/reposCommand.d.ts +4 -0
  670. package/dist/repos/reposCommand.js +28 -0
  671. package/dist/repos/types.d.ts +29 -0
  672. package/dist/repos/types.js +1 -0
  673. package/dist/runtime/consts.d.ts +12 -0
  674. package/dist/runtime/consts.js +12 -0
  675. package/dist/runtime/exportsFacts.d.ts +17 -0
  676. package/dist/runtime/exportsFacts.js +10 -0
  677. package/dist/runtime/loadDescriptors.d.ts +8 -0
  678. package/dist/runtime/loadDescriptors.js +46 -0
  679. package/dist/runtime/runtime.d.ts +35 -0
  680. package/dist/runtime/runtime.js +66 -0
  681. package/dist/runtime/sourceRoots.d.ts +10 -0
  682. package/dist/runtime/sourceRoots.js +22 -0
  683. package/dist/scripts/migrate-descriptors-v2.js +1248 -0
  684. package/dist/scripts/migrate-stubs.js +170 -0
  685. package/dist/setup/consts.d.ts +2 -0
  686. package/dist/setup/consts.js +2 -0
  687. package/dist/setup/fillInputs.d.ts +28 -0
  688. package/dist/setup/fillInputs.js +142 -0
  689. package/dist/setup/fold.d.ts +6 -0
  690. package/dist/setup/fold.js +30 -0
  691. package/dist/setup/lib/consent.d.ts +9 -0
  692. package/dist/setup/lib/consent.js +14 -0
  693. package/dist/setup/lib/env-write.d.ts +6 -0
  694. package/dist/setup/lib/env-write.js +10 -0
  695. package/dist/setup/lib/envSpans.d.ts +17 -0
  696. package/dist/setup/lib/envSpans.js +27 -0
  697. package/dist/setup/lib/fingerprint.d.ts +2 -0
  698. package/dist/setup/lib/fingerprint.js +21 -0
  699. package/dist/setup/lib/gitExposure.d.ts +8 -0
  700. package/dist/setup/lib/gitExposure.js +50 -0
  701. package/dist/setup/lib/judgeEnvAction.d.ts +25 -0
  702. package/dist/setup/lib/judgeEnvAction.js +60 -0
  703. package/dist/setup/lib/leftoverTemps.d.ts +2 -0
  704. package/dist/setup/lib/leftoverTemps.js +15 -0
  705. package/dist/setup/lib/redact.d.ts +7 -0
  706. package/dist/setup/lib/redact.js +28 -0
  707. package/dist/setup/lib/secretPathProblem.d.ts +2 -0
  708. package/dist/setup/lib/secretPathProblem.js +16 -0
  709. package/dist/setup/lib/setEnvValues.d.ts +12 -0
  710. package/dist/setup/lib/setEnvValues.js +57 -0
  711. package/dist/setup/lib/setup-contract.d.ts +5 -0
  712. package/dist/setup/lib/setup-contract.js +2 -0
  713. package/dist/setup/lib/validateEnvAction.d.ts +16 -0
  714. package/dist/setup/lib/validateEnvAction.js +25 -0
  715. package/dist/setup/lib/writeEnvAtomic.d.ts +7 -0
  716. package/dist/setup/lib/writeEnvAtomic.js +60 -0
  717. package/dist/setup/parseAllow.d.ts +8 -0
  718. package/dist/setup/parseAllow.js +20 -0
  719. package/dist/setup/parseInputFlags.d.ts +3 -0
  720. package/dist/setup/parseInputFlags.js +17 -0
  721. package/dist/setup/printUnitResults.d.ts +3 -0
  722. package/dist/setup/printUnitResults.js +23 -0
  723. package/dist/setup/renderStatusLines.d.ts +2 -0
  724. package/dist/setup/renderStatusLines.js +14 -0
  725. package/dist/setup/runUnit.d.ts +21 -0
  726. package/dist/setup/runUnit.js +204 -0
  727. package/dist/setup/safeInspect.d.ts +7 -0
  728. package/dist/setup/safeInspect.js +28 -0
  729. package/dist/setup/setup.d.ts +14 -0
  730. package/dist/setup/setup.js +28 -0
  731. package/dist/setup/setupAndCommit.d.ts +28 -0
  732. package/dist/setup/setupAndCommit.js +103 -0
  733. package/dist/setup/statusLines.d.ts +6 -0
  734. package/dist/setup/statusLines.js +90 -0
  735. package/dist/setup/ttyIO.d.ts +5 -0
  736. package/dist/setup/ttyIO.js +25 -0
  737. package/dist/setup/types.d.ts +65 -0
  738. package/dist/setup/types.js +1 -0
  739. package/dist/setup/unitEnvFor.d.ts +11 -0
  740. package/dist/setup/unitEnvFor.js +29 -0
  741. package/dist/setup/units.d.ts +4 -0
  742. package/dist/setup/units.js +7 -0
  743. package/dist/statusCommand.d.ts +2 -0
  744. package/dist/statusCommand.js +249 -0
  745. package/dist/store/Store.d.ts +561 -0
  746. package/dist/store/Store.js +744 -0
  747. package/dist/store/add.d.ts +14 -0
  748. package/dist/store/add.js +92 -0
  749. package/dist/store/addFile.d.ts +7 -0
  750. package/dist/store/addFile.js +43 -0
  751. package/dist/store/addedDates.d.ts +2 -0
  752. package/dist/store/addedDates.js +44 -0
  753. package/dist/store/createdOf.d.ts +3 -0
  754. package/dist/store/createdOf.js +20 -0
  755. package/dist/store/external.d.ts +8 -0
  756. package/dist/store/external.js +18 -0
  757. package/dist/store/findInboundRefs.d.ts +2 -0
  758. package/dist/store/findInboundRefs.js +13 -0
  759. package/dist/store/gitHead.d.ts +2 -0
  760. package/dist/store/gitHead.js +13 -0
  761. package/dist/store/ids.d.ts +2 -0
  762. package/dist/store/ids.js +19 -0
  763. package/dist/store/lib/applyMirrorEdits.d.ts +7 -0
  764. package/dist/store/lib/applyMirrorEdits.js +125 -0
  765. package/dist/store/lib/assertUnambiguous.d.ts +2 -0
  766. package/dist/store/lib/assertUnambiguous.js +11 -0
  767. package/dist/store/lib/checkRefs.d.ts +7 -0
  768. package/dist/store/lib/checkRefs.js +65 -0
  769. package/dist/store/lib/commit.d.ts +3 -0
  770. package/dist/store/lib/commit.js +40 -0
  771. package/dist/store/lib/commitIn.d.ts +3 -0
  772. package/dist/store/lib/commitIn.js +37 -0
  773. package/dist/store/lib/dirTreeStamps.d.ts +7 -0
  774. package/dist/store/lib/dirTreeStamps.js +33 -0
  775. package/dist/store/lib/filePath.d.ts +3 -0
  776. package/dist/store/lib/filePath.js +32 -0
  777. package/dist/store/lib/generateId.d.ts +4 -0
  778. package/dist/store/lib/generateId.js +72 -0
  779. package/dist/store/lib/gitDateToStamp.d.ts +6 -0
  780. package/dist/store/lib/gitDateToStamp.js +8 -0
  781. package/dist/store/lib/idsKey.d.ts +3 -0
  782. package/dist/store/lib/idsKey.js +23 -0
  783. package/dist/store/lib/indexAdd.d.ts +5 -0
  784. package/dist/store/lib/indexAdd.js +41 -0
  785. package/dist/store/lib/mirrorRemedy.d.ts +19 -0
  786. package/dist/store/lib/mirrorRemedy.js +24 -0
  787. package/dist/store/lib/moveRecord.d.ts +4 -0
  788. package/dist/store/lib/moveRecord.js +29 -0
  789. package/dist/store/lib/normalizeRecord.d.ts +2 -0
  790. package/dist/store/lib/normalizeRecord.js +28 -0
  791. package/dist/store/lib/normalizeTemporal.d.ts +10 -0
  792. package/dist/store/lib/normalizeTemporal.js +38 -0
  793. package/dist/store/lib/pathAt.d.ts +3 -0
  794. package/dist/store/lib/pathAt.js +29 -0
  795. package/dist/store/lib/placedChildrenIn.d.ts +8 -0
  796. package/dist/store/lib/placedChildrenIn.js +18 -0
  797. package/dist/store/lib/placementOfFile.d.ts +11 -0
  798. package/dist/store/lib/placementOfFile.js +20 -0
  799. package/dist/store/lib/pruneEmptyDirs.d.ts +8 -0
  800. package/dist/store/lib/pruneEmptyDirs.js +20 -0
  801. package/dist/store/lib/qualifyBareRefs.d.ts +3 -0
  802. package/dist/store/lib/qualifyBareRefs.js +16 -0
  803. package/dist/store/lib/recordFileName.d.ts +3 -0
  804. package/dist/store/lib/recordFileName.js +6 -0
  805. package/dist/store/lib/refuseDuplicateValues.d.ts +3 -0
  806. package/dist/store/lib/refuseDuplicateValues.js +16 -0
  807. package/dist/store/lib/refuseEngineWrites.d.ts +3 -0
  808. package/dist/store/lib/refuseEngineWrites.js +12 -0
  809. package/dist/store/lib/refuseMirrorWrites.d.ts +2 -0
  810. package/dist/store/lib/refuseMirrorWrites.js +8 -0
  811. package/dist/store/lib/snapshot.d.ts +17 -0
  812. package/dist/store/lib/snapshot.js +60 -0
  813. package/dist/store/lib/validate.d.ts +6 -0
  814. package/dist/store/lib/validate.js +33 -0
  815. package/dist/store/lib/walkIds.d.ts +3 -0
  816. package/dist/store/lib/walkIds.js +54 -0
  817. package/dist/store/lib/walkRoot.d.ts +3 -0
  818. package/dist/store/lib/walkRoot.js +24 -0
  819. package/dist/store/lib/writableDescriptor.d.ts +3 -0
  820. package/dist/store/lib/writableDescriptor.js +15 -0
  821. package/dist/store/recordFiles.d.ts +2 -0
  822. package/dist/store/recordFiles.js +27 -0
  823. package/dist/store/recordRoot.d.ts +3 -0
  824. package/dist/store/recordRoot.js +26 -0
  825. package/dist/store/relocate.d.ts +9 -0
  826. package/dist/store/relocate.js +52 -0
  827. package/dist/store/relocatePlan.d.ts +5 -0
  828. package/dist/store/relocatePlan.js +79 -0
  829. package/dist/store/rename.d.ts +8 -0
  830. package/dist/store/rename.js +95 -0
  831. package/dist/store/revert.d.ts +7 -0
  832. package/dist/store/revert.js +86 -0
  833. package/dist/store/rewriteRefsBatch.d.ts +3 -0
  834. package/dist/store/rewriteRefsBatch.js +142 -0
  835. package/dist/store/rm.d.ts +7 -0
  836. package/dist/store/rm.js +187 -0
  837. package/dist/store/set.d.ts +6 -0
  838. package/dist/store/set.js +80 -0
  839. package/dist/store/types.d.ts +40 -0
  840. package/dist/store/types.js +1 -0
  841. package/dist/store/vouched.d.ts +13 -0
  842. package/dist/store/vouched.js +31 -0
  843. package/dist/store/withWriteLock.d.ts +2 -0
  844. package/dist/store/withWriteLock.js +40 -0
  845. package/dist/store/writeLockPath.d.ts +2 -0
  846. package/dist/store/writeLockPath.js +20 -0
  847. package/dist/targetCommand.d.ts +2 -0
  848. package/dist/targetCommand.js +45 -0
  849. package/dist/testing.d.ts +23 -0
  850. package/dist/testing.js +85 -0
  851. package/dist/types.d.ts +699 -0
  852. package/dist/types.js +1 -0
  853. package/dist/ui-views/lib/assignPath.d.ts +17 -0
  854. package/dist/ui-views/lib/assignPath.js +34 -0
  855. package/dist/ui-views/lib/assignViewValue.d.ts +5 -0
  856. package/dist/ui-views/lib/assignViewValue.js +9 -0
  857. package/dist/ui-views/lib/consts.d.ts +21 -0
  858. package/dist/ui-views/lib/consts.js +27 -0
  859. package/dist/ui-views/lib/parseViewValue.d.ts +6 -0
  860. package/dist/ui-views/lib/parseViewValue.js +50 -0
  861. package/dist/ui-views/lib/viewOverlayOf.d.ts +2 -0
  862. package/dist/ui-views/lib/viewOverlayOf.js +19 -0
  863. package/dist/ui-views/moveUiView.d.ts +31 -0
  864. package/dist/ui-views/moveUiView.js +56 -0
  865. package/dist/ui-views/removeUiView.d.ts +6 -0
  866. package/dist/ui-views/removeUiView.js +17 -0
  867. package/dist/ui-views/saveUiView.d.ts +25 -0
  868. package/dist/ui-views/saveUiView.js +80 -0
  869. package/dist/ui-views/uiViewsCommand.d.ts +4 -0
  870. package/dist/ui-views/uiViewsCommand.js +118 -0
  871. package/dist/update/parseUpdateArgs.d.ts +9 -0
  872. package/dist/update/parseUpdateArgs.js +32 -0
  873. package/dist/update/update.d.ts +7 -0
  874. package/dist/update/update.js +57 -0
  875. package/dist/update/updateModules.d.ts +19 -0
  876. package/dist/update/updateModules.js +221 -0
  877. package/dist/update-setup.d.ts +1 -0
  878. package/dist/update-setup.js +14 -0
  879. package/dist/usage.d.ts +1 -0
  880. package/dist/usage.js +281 -0
  881. package/dist/workspace/commitByRepo.d.ts +4 -0
  882. package/dist/workspace/commitByRepo.js +51 -0
  883. package/dist/workspace/declaredGitModules.d.ts +51 -0
  884. package/dist/workspace/declaredGitModules.js +89 -0
  885. package/dist/workspace/discoverModules.d.ts +23 -0
  886. package/dist/workspace/discoverModules.js +123 -0
  887. package/dist/workspace/envContext.d.ts +3 -0
  888. package/dist/workspace/envContext.js +11 -0
  889. package/dist/workspace/findWorkspace.d.ts +2 -0
  890. package/dist/workspace/findWorkspace.js +49 -0
  891. package/dist/workspace/layerEntries.d.ts +16 -0
  892. package/dist/workspace/layerEntries.js +36 -0
  893. package/dist/workspace/lib/aheadCount.d.ts +6 -0
  894. package/dist/workspace/lib/aheadCount.js +29 -0
  895. package/dist/workspace/lib/assertCommentsKept.d.ts +16 -0
  896. package/dist/workspace/lib/assertCommentsKept.js +27 -0
  897. package/dist/workspace/lib/isTracked.d.ts +2 -0
  898. package/dist/workspace/lib/isTracked.js +14 -0
  899. package/dist/workspace/lib/shortHead.d.ts +1 -0
  900. package/dist/workspace/lib/shortHead.js +10 -0
  901. package/dist/workspace/moduleRows.d.ts +7 -0
  902. package/dist/workspace/moduleRows.js +9 -0
  903. package/dist/workspace/navFragments.d.ts +54 -0
  904. package/dist/workspace/navFragments.js +223 -0
  905. package/dist/workspace/parseEnvValues.d.ts +1 -0
  906. package/dist/workspace/parseEnvValues.js +13 -0
  907. package/dist/workspace/renderTemplate.d.ts +2 -0
  908. package/dist/workspace/renderTemplate.js +26 -0
  909. package/dist/workspace/reportCommits.d.ts +10 -0
  910. package/dist/workspace/reportCommits.js +18 -0
  911. package/dist/workspace/types.d.ts +90 -0
  912. package/dist/workspace/types.js +1 -0
  913. package/dist/workspace/writeGated.d.ts +9 -0
  914. package/dist/workspace/writeGated.js +128 -0
  915. package/package.json +45 -22
  916. package/skills/using-dreamteamer/SKILL.md +1 -1
  917. package/skills/using-dreamteamer/references/collections.md +1 -1
  918. package/skills/using-dreamteamer/references/skills.md +7 -0
  919. package/skills/using-dreamteamer/references/ui-views.md +2 -2
  920. package/skills/using-dreamteamer/references/writing-a-module.md +14 -0
  921. package/scripts/migrate-descriptors-v2.mjs +0 -795
  922. package/scripts/migrate-stubs.mjs +0 -98
  923. package/src/api.d.ts +0 -154
  924. package/src/api.js +0 -109
  925. package/src/check-alone.js +0 -171
  926. package/src/check.js +0 -427
  927. package/src/checkout.js +0 -705
  928. package/src/cli.js +0 -1000
  929. package/src/collections-cli.js +0 -1352
  930. package/src/commit.js +0 -611
  931. package/src/compile-collections.js +0 -481
  932. package/src/compile.js +0 -1498
  933. package/src/descriptor-v2.js +0 -167
  934. package/src/descriptor.js +0 -99
  935. package/src/doctor.js +0 -69
  936. package/src/env-vars.js +0 -59
  937. package/src/env-write.js +0 -162
  938. package/src/events.js +0 -204
  939. package/src/exports-cli.js +0 -91
  940. package/src/exports.js +0 -162
  941. package/src/extensions.js +0 -228
  942. package/src/field-values.js +0 -70
  943. package/src/fields.js +0 -255
  944. package/src/filter.js +0 -154
  945. package/src/fractional-index.js +0 -44
  946. package/src/harnesses.js +0 -649
  947. package/src/history.js +0 -90
  948. package/src/init.js +0 -473
  949. package/src/install-modules.js +0 -430
  950. package/src/namespace.js +0 -215
  951. package/src/nav-fragments.js +0 -190
  952. package/src/nav.js +0 -185
  953. package/src/placement.js +0 -219
  954. package/src/presentation.js +0 -182
  955. package/src/record-commands.js +0 -94
  956. package/src/records-api.d.ts +0 -210
  957. package/src/records-api.js +0 -41
  958. package/src/records.js +0 -109
  959. package/src/ref.js +0 -39
  960. package/src/relations.js +0 -62
  961. package/src/runtime.js +0 -160
  962. package/src/scaffold-templates.js +0 -85
  963. package/src/schema-ops.js +0 -2959
  964. package/src/semver.js +0 -36
  965. package/src/setup-contract.js +0 -101
  966. package/src/setup.js +0 -518
  967. package/src/store.js +0 -1940
  968. package/src/template.js +0 -201
  969. package/src/temporal.js +0 -157
  970. package/src/testing.d.ts +0 -29
  971. package/src/testing.js +0 -86
  972. package/src/unread-data.js +0 -74
  973. package/src/update-setup.js +0 -22
  974. package/src/update.js +0 -138
  975. package/src/views.js +0 -206
  976. package/src/workspace.js +0 -214
  977. package/src/yaml.js +0 -251
@@ -0,0 +1,1553 @@
1
+ import path from "node:path";
2
+ import fs from "node:fs";
3
+ import { execFileSync } from "node:child_process";
4
+ import { fieldsOf, targetsOf } from "../record/descriptor.js";
5
+ import { displayOf } from "../record/displayOf.js";
6
+ import { ensureEditorRecommendation } from "./ensureEditorRecommendation.js";
7
+ import { ensureEnvExample } from "./lib/ensureEnvExample.js";
8
+ import { layerEntries } from "../workspace/layerEntries.js";
9
+ import { namespaceProblems } from "./lib/namespaceProblems.js";
10
+ import { normalizeNamespaces } from "../record/normalizeNamespaces.js";
11
+ import { parseEnvValues } from "../workspace/parseEnvValues.js";
12
+ import { placedRecords } from "../record/placedRecords.js";
13
+ import { storageOf } from "../record/storageOf.js";
14
+ import { slug } from "../record/template.js";
15
+ import { unqualifiedProblems } from "./lib/unqualifiedProblems.js";
16
+ import { walk } from "../lib/walk.js";
17
+ import { ensureGitignored } from "./lib/ensureGitignored.js";
18
+ import { dump, load } from "../lib/yaml.js";
19
+ import { loadDescriptors as loadCompiledDescriptors } from "../runtime/loadDescriptors.js";
20
+ import { engineId, engineVersion, readManifest, runtimeDir } from "../runtime/runtime.js";
21
+ import { DERIVED_KINDS, STALE_RUNTIME } from "../runtime/consts.js";
22
+ import { KINDS } from "./consts.js";
23
+ import { MANIFEST_KEYS, SCRIPT_NAME } from "./consts.js";
24
+ import { bindingErrors } from "./lib/bindingErrors.js";
25
+ import { compileCollections } from "./lib/compileCollections.js";
26
+ import { discoverModules } from "../workspace/discoverModules.js";
27
+ import { excludedFromKind } from "../extensions/extensions.js";
28
+ import { BEGIN, END, INSTRUCTIONS_BEGIN, INSTRUCTIONS_END } from "./consts.js";
29
+ import { overlayView } from "./lib/overlayView.js";
30
+ import { renderContributions } from "./lib/renderContributions.js";
31
+ import { repoRootOf } from "../lib/git/repoRootOf.js";
32
+ import { runHarnessAdapters } from "./lib/runHarnessAdapters.js";
33
+ import { satisfies } from "../lib/npm/satisfies.js";
34
+ import { EXACT } from "../lib/npm/exact.js";
35
+ import { kindDir } from "./kindDir.js";
36
+ import { stagedKindDir } from "./stagedKindDir.js";
37
+ import { sha256 } from "./sha256.js";
38
+ import { toPosix } from "./toPosix.js";
39
+ // each lives in its own file so a caller that needs only it — `staleness`, which every record verb
40
+ // reaches through warnIfStale — does not load the compiler; re-exported for the existing importers
41
+ export { kindDir, sha256, toPosix };
42
+ export { warnIfStale } from "./warnIfStale.js";
43
+ import { v1ManifestRefusal } from "./v1ManifestRefusal.js";
44
+ import { v1Refusal } from "./v1Refusal.js";
45
+ import { viewDisplay } from "./lib/viewDisplay.js";
46
+ import { viewErrors } from "./lib/viewErrors.js";
47
+ import { CHANNEL_LABEL, INSTRUCTIONS_SOURCE } from "./consts.js";
48
+ /**
49
+ * Identifier → display label: `finance-accounts` → "Finance Accounts".
50
+ *
51
+ * The ONE derivation of a label from an id. compile resolves it INTO the descriptor so that no
52
+ * surface re-implements it — the same lesson as `storage.base`, which lived as a re-derived path
53
+ * test in five places before it became a field. An authored `title` always wins over this.
54
+ *
55
+ * `/` is a separator because a collection id may contain one (`titles.ts` splits routes on that
56
+ * assumption). Field names cannot, which is why the extension's browser-side copy of this rule
57
+ * (`webview/src/lib/format-title.ts`, which cannot import node code) stays byte-compatible for the
58
+ * only comparison that matters — the round-trip guard in schema-ops.js.
59
+ */
60
+ function titleCase(id) {
61
+ return String(id)
62
+ .split(/[_\-\s/]+/)
63
+ .filter(Boolean)
64
+ .map(word => word.charAt(0).toUpperCase() + word.slice(1))
65
+ .join(" ");
66
+ }
67
+ const FOLDER_KINDS = new Set(["skills"]);
68
+ // folder-shape entities: copy the whole record folder
69
+ /** Every contributed kind of the workspace's loaded extensions, as `{ kind, exclude, extension }`. */
70
+ const contributedKinds = (ws) => (ws.extensions ?? []).flatMap(e => e.sourceKinds ?? []);
71
+ /** Built-in kinds, then contributed ones. */
72
+ export const kindsOf = (ws) => [...KINDS, ...contributedKinds(ws).map(k => k.kind)];
73
+ // DERIVED_KINDS (projected, not staged) lives in runtime.js — the boundary both halves read. Not in
74
+ // KINDS on purpose: a module folder named `modules/` would be nonsense, and `isSystem` below keys
75
+ // off KINDS to decide `storage.base`, so a `modules` collection landing on `base: workspace` would
76
+ // point the store at the SOURCE directory and read every module folder as a record.
77
+ function bothLayouts(root, kind) {
78
+ return fs.existsSync(path.join(root, kind)) && fs.existsSync(path.join(root, "system", kind));
79
+ }
80
+ /**
81
+ * Folders a module may hold that are not sources. With kinds at the module root, "not a kind" can no
82
+ * longer mean "ignore it" — that is precisely how a kind the engine stopped knowing (`workflows`,
83
+ * removed 2026-07-31) sat in a module for two days while compile reported ✔ and a README described a
84
+ * pipeline nothing read (decision 156).
85
+ *
86
+ * So the root is ENUMERATED and an unrecognised folder is an ERROR. This list covers what a package
87
+ * generically contains; anything else the module declares in its own package.json
88
+ * (`dreamteamer.ignore`). That is real per-module variance — `services` has `dashboard/`, `agentlog`
89
+ * has `data/` — not a layout knob every module would set identically.
90
+ */
91
+ /**
92
+ * `bin/*` files of a module root, module-relative and sorted — dotfiles and subfolders (lib/,
93
+ * parsers/) excluded. Empty when there is no bin/.
94
+ */
95
+ function binEntries(moduleRoot) {
96
+ const dir = path.join(moduleRoot, "bin");
97
+ if (!fs.existsSync(dir))
98
+ return [];
99
+ return fs
100
+ .readdirSync(dir, { withFileTypes: true })
101
+ .filter(e => e.isFile() && !e.name.startsWith("."))
102
+ .map(e => `bin/${e.name}`)
103
+ .sort();
104
+ }
105
+ const NON_SOURCE_DIRS = new Set([
106
+ "node_modules",
107
+ "data",
108
+ "state",
109
+ "media",
110
+ "bin",
111
+ "src",
112
+ "lib",
113
+ "scripts",
114
+ "ui",
115
+ "studio", // the module's UI bundle — 'studio' is the pre-archive name, kept as a fallback
116
+ "docs",
117
+ "dist",
118
+ "build",
119
+ "test",
120
+ "tests",
121
+ "coverage",
122
+ "system", // 'system': the pre-flatten layout
123
+ ]);
124
+ /**
125
+ * Unrecognised source-root folders in a module, or [] for the workspace root (a vault legitimately
126
+ * holds arbitrary directories — this gate is about PACKAGES, whose folders all mean something).
127
+ *
128
+ * ⚠ `system/` is enumerated TOO, under the same rule. It is in NON_SOURCE_DIRS so the root pass
129
+ * waves it through, and that waved through everything BELOW it — so `system/gizmos/probe.gizmo.yaml`
130
+ * compiled ✔ in silence while the identical folder at the module root hard-errored. That is exactly
131
+ * the decision-156 shape the root gate exists to prevent, surviving one level down: `kindDir` still
132
+ * reads `system/<kind>` as the pre-flatten fallback, so a kind the engine stopped knowing is just as
133
+ * invisible there as it ever was at the root, and the half-migrated module is the likeliest place
134
+ * for one to be. Known kinds under `system/` keep compiling — the fallback is deliberate and stays
135
+ * (CLAUDE.md); only UNKNOWN folders become errors, and `dreamteamer.ignore` excuses them in both
136
+ * places with one entry.
137
+ */
138
+ function strayKindDirs(source, wsRoot, declaredIgnore, kinds) {
139
+ if (path.resolve(source.root) === path.resolve(wsRoot))
140
+ return [];
141
+ const allow = new Set([...kinds, ...NON_SOURCE_DIRS, ...declaredIgnore]);
142
+ const dirsIn = (dir, prefix = "") => (fs.existsSync(dir) ? fs.readdirSync(dir, { withFileTypes: true }) : [])
143
+ .filter(e => e.isDirectory() && !e.name.startsWith(".") && !allow.has(e.name))
144
+ .map(e => `${prefix}${e.name}`);
145
+ return [
146
+ ...dirsIn(source.root),
147
+ // The SAME allow set one level down — a generic package folder reads the same wherever the
148
+ // module put it, and one `ignore` entry covers both spellings rather than two.
149
+ ...dirsIn(path.join(source.root, "system"), "system/"),
150
+ ].sort();
151
+ }
152
+ /** A manifest path that stays inside its package: relative, non-empty, no `..` segment. */
153
+ function insidePackage(p) {
154
+ return (typeof p === "string" && !!p && !path.isAbsolute(p) && !path.posix.isAbsolute(p) && !p.split(/[\\/]/).includes(".."));
155
+ }
156
+ /** A module's record id: its package name with the npm scope stripped, so `@dreamteamer/crm` is `crm`. */
157
+ export const moduleIdOf = (n) => slug(String(n).replace(/^@[^/]+\//, ""));
158
+ /**
159
+ * A module's `location` — the folder its sources sit in. `root` is the classic layout, where the
160
+ * workspace's own sources are at its root rather than under `modules/<id>/`; discovery reports that
161
+ * as the `inline` channel with `root === '.'`, which is the one case the label table cannot see.
162
+ */
163
+ export const locationOf = (source, wsRoot) => path.resolve(source.root) === path.resolve(wsRoot) ? "root" : (CHANNEL_LABEL[source.channel] ?? source.channel);
164
+ // A module with `owns-data: true` keeps its records BESIDE ITSELF rather than in the
165
+ // workspace's data/. The descriptor still says `data/<collection>`; compile is what turns
166
+ // that into a path, so the module never names its host.
167
+ /**
168
+ * Why a module's clone could NOT hold records, or null when it can. Decided from the CHANNEL, never
169
+ * by asking git — compile shells out to git nowhere and must keep working in a freshly-`init`ed
170
+ * directory that is not a repo yet. Asked by the module flag and by a descriptor's `storage.owner`
171
+ * alike, so an npm module shipping an owned collection fails the same way.
172
+ */
173
+ function unownableBecause(source, rel) {
174
+ if (source.channel === "npm")
175
+ return `module "${source.name}" is installed under node_modules/ — that path is never committed, so its records could not be saved. Vendor it into modules/ or install it as a git module.`;
176
+ if (source.channel === "git" && !fs.existsSync(path.join(source.root, ".git")))
177
+ return `${rel(source.root)} is not a git clone — git_modules/ is gitignored by the workspace, so its records could never be committed.`;
178
+ return null;
179
+ }
180
+ /**
181
+ * modules whose collections default to `storage.owner: module` (`owns_data: true`), by module
182
+ * name → {root, channel}. Records that could never be committed are a compile ERROR, not a silent zero.
183
+ */
184
+ function dataOwningModules(sources, fail, rel) {
185
+ const owners = new Map();
186
+ for (const s of sources) {
187
+ let mpkg;
188
+ try {
189
+ mpkg = JSON.parse(fs.readFileSync(path.join(s.root, "package.json"), "utf8"));
190
+ }
191
+ catch {
192
+ continue;
193
+ }
194
+ const flag = mpkg.dreamteamer?.owns_data;
195
+ if (flag === undefined || flag === false)
196
+ continue;
197
+ if (flag !== true)
198
+ fail(`module "${s.name}": "owns_data" must be true or false (got ${JSON.stringify(flag)})`);
199
+ const why = unownableBecause(s, rel);
200
+ if (why)
201
+ fail(`module "${s.name}" sets owns_data, but ${why}`);
202
+ owners.set(s.name, { root: s.root, channel: s.channel });
203
+ }
204
+ return owners;
205
+ }
206
+ /**
207
+ * A layer's data folder, from the clone's own manifest (its `data_path`), default `data`. The clone
208
+ * may be absent — a fresh checkout before `dreamteamer install` — and then the default stands.
209
+ */
210
+ function layerDataPath(root, name) {
211
+ try {
212
+ return (JSON.parse(fs.readFileSync(path.join(root, "git_modules", name, "package.json"), "utf8")).dreamteamer
213
+ ?.data_path ?? "data");
214
+ }
215
+ catch {
216
+ return "data";
217
+ }
218
+ }
219
+ function shadowWarning({ name, winner, loser }) {
220
+ return `⚠ module ${name}: ${CHANNEL_LABEL[winner]} copy shadows ${CHANNEL_LABEL[loser]} copy`;
221
+ }
222
+ /** The `name` in a folder's package.json, or null — an absent clone or an unreadable file is unknown. */
223
+ function pkgNameAt(dir) {
224
+ try {
225
+ return JSON.parse(fs.readFileSync(path.join(dir, "package.json"), "utf8")).name ?? null;
226
+ }
227
+ catch {
228
+ return null;
229
+ }
230
+ }
231
+ export function compile(ws) {
232
+ const { root, pkg } = ws;
233
+ const extensions = ws.extensions ?? [];
234
+ const contributed = contributedKinds(ws);
235
+ const kinds = kindsOf(ws);
236
+ const RUNTIME = runtimeDir(root);
237
+ // read BEFORE anything below replaces the runtime: an extension's analysis compares against it,
238
+ // and the harness pass prunes what it listed
239
+ const prevManifest = readManifest(root);
240
+ const config = pkg.dreamteamer ?? {};
241
+ const harnesses = config.harnesses ?? ["claude-code"];
242
+ // workspace-relative and POSIX on every OS: these paths are stored (manifest sources, module
243
+ // records, storage paths) and compared with `/`-joined prefixes — see addEntry
244
+ const rel = (p) => toPosix(path.relative(root, p));
245
+ /**
246
+ * ⚠ YAML, WITH THE FILE IN THE MESSAGE. js-yaml reports `line:column` and a snippet and never a
247
+ * path, so one stray tab in a workspace of a hundred sources was an mtime bisect. Every parse of
248
+ * a MODULE SOURCE goes through here; the projected records compile dumps itself do not need it.
249
+ */
250
+ const loadSource = (text, srcPath) => {
251
+ try {
252
+ return load(text);
253
+ }
254
+ catch (e) {
255
+ return fail(`${srcPath}: ${e.message}`);
256
+ }
257
+ };
258
+ /**
259
+ * An EMPTY source is never intentional, and every reader indexes straight into what it parses.
260
+ * The collection case died with a bare "Cannot read properties of undefined" naming no file; a
261
+ * 0-byte ui-view was worse — compile said ✔ and `check` caught it one gate later, naming the
262
+ * COMPILED artifact under `.dreamteamer/`, which nobody can edit and the next compile overwrites.
263
+ * Refuse here, the last layer that still knows which module file the bytes came from.
264
+ * ⚠ ENTITY FILES ONLY. A skill is a FOLDER: its `SKILL.md` is the entity and is covered, while a
265
+ * placeholder under `references/` is the author's business, not the compiler's.
266
+ */
267
+ const refuseEmptySource = (srcPath) => {
268
+ if (fs.readFileSync(srcPath, "utf8").trim() === "") {
269
+ fail(`${rel(srcPath)}: source is empty — there is nothing to compile. Delete the file, or write one.`);
270
+ }
271
+ };
272
+ // discover sources: channel modules then the workspace's own
273
+ const { modules: discovered, shadows, disabledModules, layerRefusals } = discoverModules(root, pkg);
274
+ for (const r of layerRefusals)
275
+ fail(r);
276
+ for (const s of shadows)
277
+ console.warn(shadowWarning(s));
278
+ const sources = [...discovered];
279
+ // workspace-owned sources: either at the root (classic layout) or in the designated
280
+ // workspace module under modules/ (config `workspace-module` — "the workspace is itself a
281
+ // module", made literal). when the key is set the root is NOT read, so the two layouts can
282
+ // never fork — and a stray source folder up there is a loud error rather than a silent drop.
283
+ if (!config.workspace_module) {
284
+ sources.push({ name: pkg.name, root, channel: "inline" });
285
+ }
286
+ else {
287
+ const strays = [];
288
+ if (fs.existsSync(path.join(root, "system")) && [...walk(path.join(root, "system"))].length)
289
+ strays.push("system/");
290
+ for (const kind of kinds) {
291
+ const dir = path.join(root, kind);
292
+ if (fs.existsSync(dir) && [...walk(dir)].length)
293
+ strays.push(`${kind}/`);
294
+ }
295
+ if (strays.length) {
296
+ fail(`the workspace root contains sources (${strays.join(", ")}) but workspace_module="${config.workspace_module}" is set — they would be silently ignored.\n move them into modules/${config.workspace_module}/ (decision 22).`);
297
+ }
298
+ }
299
+ // engine floors: a module whose `dreamteamer.engine` excludes this engine is REFUSED whole —
300
+ // none of its content compiles, since it may use what this engine cannot read; the rest does
301
+ const engineVer = engineVersion();
302
+ const refused = new Map(); // module name -> the range it declares
303
+ for (const source of [...sources]) {
304
+ if (source.root === root)
305
+ continue;
306
+ let range;
307
+ try {
308
+ range = JSON.parse(fs.readFileSync(path.join(source.root, "package.json"), "utf8")).dreamteamer?.engine;
309
+ }
310
+ catch {
311
+ continue;
312
+ }
313
+ if (!range || satisfies(engineVer, range) !== false)
314
+ continue;
315
+ refused.set(source.name, range);
316
+ sources.splice(sources.indexOf(source), 1);
317
+ console.warn(`✖ module ${source.name} needs engine "${range}" — this is ${engineVer}, so none of its content is compiled. Upgrade dreamteamer, or disable the module.`);
318
+ }
319
+ // module package pass: env declarations; a missing secret warns, never fails
320
+ // A module's record id: the npm scope stripped, so `@dreamteamer/crm` reads as `crm` — which is
321
+ // what every message in this engine already calls it. Defined HERE, above the namespace pass,
322
+ // because a namespace error has to name the module by the id the fix is typed with.
323
+ const moduleId = moduleIdOf;
324
+ // A layer's workspace module (`module: true`) must answer to an id of its own: `default` is the ROLE
325
+ // every workspace's own module carries, and an id another module holds would merge two modules' records.
326
+ for (const s of sources.filter(x => x.layer)) {
327
+ const at = `git_modules.${s.layer}.module`;
328
+ const id = moduleId(s.name);
329
+ if (id === "default")
330
+ fail(`${at}: the clone's workspace module is "default" — the role name every workspace's own module carries, so it cannot be told apart from this one's. Name the project's module after the project (its workspace_module, and the folder under modules/).`);
331
+ const other = sources.find(o => o !== s && moduleId(o.name) === id);
332
+ if (other)
333
+ fail(`${at}: the clone's workspace module "${id}" collides with module "${other.name}" at ${rel(other.root) || "."} — a module id names one module. Rename one of them.`);
334
+ }
335
+ const channelOf = new Map(sources.map(s => [s.name, s.channel]));
336
+ const declaredEnv = new Map(); // env key -> [module names]
337
+ const requestedVars = new Map(); // var a module READS through ${env:…} -> [module names]
338
+ const envMeta = new Map(); // env key or var -> { description, example } — the first module to say wins
339
+ const moduleIgnores = new Map(); // module name -> non-source folders it declares (strayKindDirs)
340
+ const moduleDeps = new Map(); // module name -> [module names] — HARD, must be acyclic
341
+ const modulePeers = new Map(); // module name -> [collection names] — SOFT, cannot cycle
342
+ const moduleNamespaces = new Map(); // module name -> [namespaces it DECLARES] (§8, option A)
343
+ const moduleVersions = new Map(); // module name -> its package.json version
344
+ const moduleFloors = new Map(); // module name -> npm `peerDependencies` — a version floor on a sibling module
345
+ const modulePresets = new Map(); // module preset name -> { member name: exact version } (CR-dt-008)
346
+ const moduleLocalAssets = []; // {rel, owner, base} — validated with the workspace's own, below
347
+ // the package.json `dreamteamer` block is a closed set of snake_case keys, the workspace's and
348
+ // every module's alike — a key outside it is a typo or a spelling this engine does not read
349
+ const refuseUnknownKeys = (block, where) => {
350
+ const bad = Object.keys(block ?? {}).filter(k => !MANIFEST_KEYS.includes(k));
351
+ // a kebab-case spelling of a key this engine reads is the v1 manifest: the converter rewrites it
352
+ const v1 = v1ManifestRefusal(block, where);
353
+ if (v1)
354
+ fail(v1);
355
+ if (bad.length)
356
+ fail(`${where}: unknown dreamteamer key(s) ${bad.join(", ")} — the keys are ${MANIFEST_KEYS.join(" · ")}`);
357
+ };
358
+ refuseUnknownKeys(config, "package.json");
359
+ const moduleOnly = ["preset", "nav", "skills", "scripts"].filter(k => config[k] !== undefined);
360
+ if (moduleOnly.length)
361
+ fail(`package.json: dreamteamer.${moduleOnly.join(" and dreamteamer.")} belong${moduleOnly.length === 1 ? "s" : ""} to a module package, not the workspace — the workspace's own module is modules/${config.workspace_module ?? "default"}`);
362
+ for (const source of sources) {
363
+ let mpkg;
364
+ try {
365
+ mpkg = JSON.parse(fs.readFileSync(path.join(source.root, "package.json"), "utf8"));
366
+ }
367
+ catch {
368
+ continue;
369
+ }
370
+ if (source.root !== root && mpkg.dreamteamer)
371
+ refuseUnknownKeys(mpkg.dreamteamer, rel(path.join(source.root, "package.json")));
372
+ const ignore = mpkg.dreamteamer?.ignore;
373
+ if (ignore !== undefined) {
374
+ if (!Array.isArray(ignore))
375
+ fail(`module "${source.name}": "ignore" must be a list of folder names (got ${JSON.stringify(ignore)})`);
376
+ moduleIgnores.set(source.name, ignore.map(String));
377
+ }
378
+ // npm's TERMINOLOGY, deliberately not npm's namespace: these live under `dreamteamer` so
379
+ // npm's own resolver never tries to fetch an inline or git-channel module.
380
+ for (const [key, sink] of [
381
+ ["dependencies", moduleDeps],
382
+ ["peer_collections", modulePeers],
383
+ ]) {
384
+ const decl = mpkg.dreamteamer?.[key];
385
+ if (decl === undefined)
386
+ continue;
387
+ if (!Array.isArray(decl) || decl.some(v => typeof v !== "string")) {
388
+ fail(`module "${source.name}": dreamteamer.${key} must be a list of ${key === "dependencies" ? "module names" : "collection names"} (got ${JSON.stringify(decl)})`);
389
+ }
390
+ sink.set(source.name, decl);
391
+ }
392
+ // §8: A MODULE DECLARES THE NAMESPACES IT OWNS. Reversed from "the workspace only, never a
393
+ // module", whose real reason (a module could rename where another module's records live) is
394
+ // kept by the single-owner rule and the use-requires-dependency rule below — while the rule it
395
+ // replaces made decision 130's own acceptance test unpassable for any namespaced module.
396
+ const ns = mpkg.dreamteamer?.namespaces;
397
+ if (ns !== undefined) {
398
+ if (!Array.isArray(ns) || ns.some(v => typeof v !== "string")) {
399
+ fail(`module "${source.name}": dreamteamer.namespaces must be a list of namespace names (got ${JSON.stringify(ns)})`);
400
+ }
401
+ moduleNamespaces.set(source.name, ns);
402
+ }
403
+ // A MODULE PRESET (CR-dt-008): `preset` maps member module names to EXACT versions — the set
404
+ // `dt install` pins and `dt update` moves. It lists modules and ships no sources of its own.
405
+ // `nav` names the package's nav fragment, a path inside the package.
406
+ if (source.root !== root) {
407
+ const preset = mpkg.dreamteamer?.preset;
408
+ if (preset !== undefined) {
409
+ if (!preset || typeof preset !== "object" || Array.isArray(preset))
410
+ fail(`module "${source.name}": dreamteamer.preset must map module names to exact versions (got ${JSON.stringify(preset)})`);
411
+ for (const [member, v] of Object.entries(preset)) {
412
+ if (typeof v !== "string" || !EXACT.test(v))
413
+ fail(`module "${source.name}": dreamteamer.preset["${member}"] must be an exact version (got ${JSON.stringify(v)})`);
414
+ }
415
+ // every folder compile would read from a package: the kind folders (an extension's kinds
416
+ // too), a modules/ bundle, and a UI bundle (ui/, or its pre-archive name studio/)
417
+ const shipped = [...new Set([...KINDS, ...kinds]), "modules", "ui", "studio"].find(k => fs.existsSync(k === "modules" || k === "ui" || k === "studio" ? path.join(source.root, k) : stagedKindDir(source.root, k)));
418
+ if (shipped)
419
+ fail(`module "${source.name}": a module preset lists modules; it ships none (found ${shipped}/)`);
420
+ modulePresets.set(source.name, preset);
421
+ }
422
+ const nav = mpkg.dreamteamer?.nav;
423
+ if (nav !== undefined && !insidePackage(nav)) {
424
+ fail(`module "${source.name}": dreamteamer.nav must be a relative path inside the package (got ${JSON.stringify(nav)})`);
425
+ }
426
+ // `skills` names the BUILD folder the module's skills stage from (stagedKindDir). A clone or a
427
+ // copy nobody built has none, and staging an absent folder would compile ✔ with every skill of
428
+ // the module gone — the decision-156 shape — so a missing or empty one is refused, naming it.
429
+ const skills = mpkg.dreamteamer?.skills;
430
+ if (skills !== undefined) {
431
+ if (!insidePackage(skills))
432
+ fail(`module "${source.name}": dreamteamer.skills must be a relative path inside the package — the folder its build writes the skills to, e.g. "dist/skills" (got ${JSON.stringify(skills)})`);
433
+ const dir = path.join(source.root, skills);
434
+ const held = fs.existsSync(dir) && fs.statSync(dir).isDirectory() ? fs.readdirSync(dir) : null;
435
+ if (!held?.some(n => !n.startsWith(".")))
436
+ fail(`module "${source.name}": dreamteamer.skills names ${rel(dir)}/, which is ${held ? "empty" : "missing"} — it is the module's build output. Run the module's build (\`npm run build\` in ${rel(source.root) || "."}), then compile again.`);
437
+ }
438
+ // `scripts` maps a NAME to a file of the package — what `dt run <module> <name>` runs. Its
439
+ // shape is held here with the other keys; whether the file exists is `dt run`'s to say, since
440
+ // nothing compile stages depends on it.
441
+ const scripts = mpkg.dreamteamer?.scripts;
442
+ if (scripts !== undefined) {
443
+ if (!scripts || typeof scripts !== "object" || Array.isArray(scripts))
444
+ fail(`module "${source.name}": dreamteamer.scripts must map script names to files of the package, e.g. { "check-records": "dist/bin/check-records.js" } (got ${JSON.stringify(scripts)})`);
445
+ for (const [name, file] of Object.entries(scripts)) {
446
+ if (!SCRIPT_NAME.test(name))
447
+ fail(`module "${source.name}": dreamteamer.scripts name "${name}" — a script name is lowercase letters, digits and single hyphens`);
448
+ if (!insidePackage(file))
449
+ fail(`module "${source.name}": dreamteamer.scripts["${name}"] must be a relative path inside the package (got ${JSON.stringify(file)})`);
450
+ }
451
+ }
452
+ }
453
+ if (source.root !== root) {
454
+ moduleVersions.set(source.name, mpkg.version);
455
+ if (mpkg.peerDependencies && typeof mpkg.peerDependencies === "object")
456
+ moduleFloors.set(source.name, mpkg.peerDependencies);
457
+ }
458
+ const range = mpkg.dreamteamer?.engine;
459
+ if (range && satisfies(engineVer, range) === null)
460
+ console.warn(`⚠ module ${source.name}: engine range "${range}" not understood by the built-in checker (see src/lib/npm/satisfies.ts) — not verified`);
461
+ // `dreamteamer.env` (keys the module needs) and, in a module, `dreamteamer.vars` (the
462
+ // `${env:…}` vars it reads): each entry a bare name or `{ name, description, example }`, so
463
+ // `.env.example` says what a value looks like. A module only REQUESTS a var — the workspace's
464
+ // own list is the allow-list, so a module can never add a key to what `dt resolve` renders.
465
+ for (const key of source.root === root ? ["env"] : ["env", "vars"]) {
466
+ const decl = mpkg.dreamteamer?.[key] ?? [];
467
+ const sink = key === "env" ? declaredEnv : requestedVars;
468
+ if (!Array.isArray(decl))
469
+ fail(`module "${source.name}": dreamteamer.${key} must be a list of key names or { name, description, example } objects (got ${JSON.stringify(decl)})`);
470
+ for (const entry of decl) {
471
+ const k = typeof entry === "string" ? entry : entry?.name;
472
+ if (typeof k !== "string" || !/^[A-Za-z_][A-Za-z0-9_]*$/.test(k))
473
+ fail(`module "${source.name}": dreamteamer.${key} entry ${JSON.stringify(entry)} — a key is an identifier (A-Z, 0-9, _) as a string or as { name, description, example }`);
474
+ if (!sink.has(k))
475
+ sink.set(k, []);
476
+ sink.get(k).push(source.name);
477
+ if (typeof entry === "object" && !envMeta.has(k))
478
+ envMeta.set(k, {
479
+ description: entry.description ? String(entry.description) : undefined,
480
+ example: entry.example !== undefined ? String(entry.example) : undefined,
481
+ });
482
+ }
483
+ }
484
+ // Gathered here because mpkg is already parsed; refused below, next to the workspace's own
485
+ // declaration. The classic layout pushes the ROOT itself as an inline source, whose
486
+ // package.json IS `config` — reading it here too would report every workspace-level
487
+ // declaration twice, under the wrong owner.
488
+ if (source.root !== root) {
489
+ for (const rel of mpkg.dreamteamer?.local_assets ?? [])
490
+ moduleLocalAssets.push({ rel, owner: source.name, base: source.root });
491
+ }
492
+ }
493
+ // `dreamteamer.vars` is the WORKSPACE's own declaration (root package.json, not a module's): the
494
+ // keys a `${env:NAME}` template is allowed to name. Same missing-key question as
495
+ // `dreamteamer.env`, one .env parse, two warnings — a module needs its key to RUN, a var is
496
+ // needed the moment someone calls `dt resolve`, and only the workspace can declare one.
497
+ if (config.vars !== undefined && (!Array.isArray(config.vars) || config.vars.some(v => typeof v !== "string"))) {
498
+ fail(`dreamteamer.vars must be a list of env key names (got ${JSON.stringify(config.vars)})`);
499
+ }
500
+ const declaredVars = config.vars ?? [];
501
+ for (const [k, mods] of requestedVars) {
502
+ if (!declaredVars.includes(k))
503
+ for (const mod of mods)
504
+ console.warn(`⚠ module ${mod} reads \${env:${k}} — add it to the workspace's dreamteamer.vars`);
505
+ }
506
+ // ⚠ THE ONE PARSE of .env, shared with the collections pass: an env-pointed `storage.path`
507
+ // renders against exactly the values the warnings below name keys from. Values never reach any
508
+ // output or the manifest; a rendered storage path is the one thing a value becomes, and it lands
509
+ // only in the gitignored runtime. `declared` is the workspace's own list plus every module's
510
+ // request — the descriptor that names a var is the request to render it (compile-collections).
511
+ const envPath = path.join(root, ".env");
512
+ const parsedEnv = parseEnvValues(fs.existsSync(envPath) ? fs.readFileSync(envPath, "utf8") : "");
513
+ const storageVars = {
514
+ env: parsedEnv,
515
+ workspaceFolder: root,
516
+ declared: new Set([...declaredVars, ...requestedVars.keys()]),
517
+ };
518
+ if (declaredEnv.size || declaredVars.length) {
519
+ // .env is parsed for KEY names ONLY — values never reach any output or the manifest
520
+ if (!fs.existsSync(envPath)) {
521
+ if (declaredEnv.size)
522
+ console.warn(`⚠ no .env — modules declare env keys: ${[...declaredEnv.keys()].join(", ")} (see .env.example)`);
523
+ if (declaredVars.length)
524
+ console.warn(`⚠ no .env — dreamteamer.vars declares ${declaredVars.join(", ")}, so no \${env:…} template can render here (see .env.example)`);
525
+ }
526
+ else {
527
+ // ⚠ THE ONE PARSER, not a key regex of our own. This used to hand-roll
528
+ // `/^\s*(?:export\s+)?([A-Za-z_][A-Za-z0-9_]*)\s*=/`, which accepted two lines
529
+ // `parseEnvValues` deliberately drops (`KEY =value`, and an indented key) and scanned a
530
+ // quoted value's continuation lines for keys. Either disagreement produces the worst
531
+ // pairing there is: compile says nothing and then `dt resolve` answers "no value in
532
+ // .env" about a line the operator is looking straight at. Values are read here and
533
+ // never printed — the warnings below name keys only.
534
+ // A key present with an EMPTY (or whitespace-only) value is treated as absent, same as
535
+ // resolve's renderTemplate — `FILES_FOLDER=` must warn here exactly as `FILES_FOLDER`
536
+ // missing entirely would, or compile says nothing and resolve fails on the same line.
537
+ const present = new Set([...parsedEnv].filter(([, v]) => v.trim() !== "").map(([k]) => k));
538
+ for (const [k, mods] of declaredEnv) {
539
+ if (present.has(k))
540
+ continue;
541
+ const about = envMeta.get(k)?.description ? ` (${envMeta.get(k).description})` : "";
542
+ for (const mod of mods)
543
+ console.warn(`⚠ module ${mod} declares env key ${k}${about} — missing from .env (see .env.example)`);
544
+ }
545
+ for (const k of declaredVars) {
546
+ if (present.has(k))
547
+ continue;
548
+ console.warn(`⚠ dreamteamer.vars declares ${k} — missing from .env, so \${env:${k}} cannot render on this machine`);
549
+ }
550
+ }
551
+ }
552
+ // Two root files kept current on every compile, both cheap and both about the FIRST run of a
553
+ // stranger: `.env.example` lists every declared key with its description, so the warning above
554
+ // points at a file that actually names them; `.vscode/extensions.json` recommends the editor
555
+ // extension, so the first window offers it. Both are append/merge-only — nothing authored moves.
556
+ {
557
+ // one entry per key: a key one package declares as env and another requests as a var is one block
558
+ const byKey = new Map();
559
+ for (const [key, mods] of [...declaredEnv, ...requestedVars]) {
560
+ let e = byKey.get(key);
561
+ if (!e) {
562
+ e = { key, modules: [], ...(envMeta.get(key) ?? {}) };
563
+ byKey.set(key, e);
564
+ }
565
+ for (const m of mods)
566
+ if (!e.modules.includes(m))
567
+ e.modules.push(m);
568
+ }
569
+ // the workspace's own declarations are never dropped; and a declared module not on disk yet (a git
570
+ // module before `dt install`, a dependency before `npm install`) would drop keys it still declares
571
+ const ownEnv = config.env ?? [];
572
+ const keep = [
573
+ ...declaredVars,
574
+ ...ownEnv.flatMap(e => typeof e === "string"
575
+ ? [e]
576
+ : e && typeof e === "object" && "name" in e && typeof e.name === "string"
577
+ ? [e.name]
578
+ : []),
579
+ ];
580
+ const complete = !Object.keys(config.git_modules ?? {}).some(n => !fs.existsSync(path.join(root, "git_modules", n))) &&
581
+ !Object.keys(pkg.dependencies ?? {}).some(n => !fs.existsSync(path.join(root, "node_modules", n, "package.json")));
582
+ const env = ensureEnvExample(root, [...byKey.values()], "# secrets for skills and modules go here (copy to .env; .env is never committed).\n# modules declare the env keys they require in their package.json dreamteamer.env list.\n", { keep, complete });
583
+ if (env.added.length)
584
+ console.log(`✔ .env.example now names ${env.added.join(", ")}`);
585
+ for (const k of env.moved)
586
+ console.log(`✔ .env.example re-attributes ${k} (now declared by ${byKey.get(k).modules.join(", ")})`);
587
+ for (const k of env.dropped)
588
+ console.log(`✔ .env.example drops ${k} — no installed package declares it`);
589
+ ensureEditorRecommendation(root);
590
+ }
591
+ // local-assets and postinstall: what `dt install` will do to a checkout
592
+ // `local-assets` are the gitignored heavy folders a checkout SHARES by symlink instead of
593
+ // duplicating — a browser profile dir, a model cache. Declared, never discovered. Every
594
+ // refusal below is something the installer would otherwise hit at RUN time, on a machine nobody
595
+ // is watching; the compiler is where a declaration is cheap to fix. (`src/checkout.ts` refuses
596
+ // the escaping rel a second time when the plan is built — a runtime that writes a symlink
597
+ // outside the root must not wait for the compiler to be run.)
598
+ const ENGINE_OWNED = new Set([".env", "node_modules", ".dreamteamer", ".git"]);
599
+ const gitQ = (args) => {
600
+ try {
601
+ execFileSync("git", args, { cwd: root, stdio: "ignore" });
602
+ return true;
603
+ }
604
+ catch {
605
+ return false;
606
+ }
607
+ };
608
+ for (const a of [
609
+ ...(config.local_assets ?? []).map(rel => ({ rel, owner: "workspace", base: root })),
610
+ ...moduleLocalAssets,
611
+ ]) {
612
+ const abs = path.resolve(a.base, a.rel), rel = path.relative(root, abs);
613
+ if (a.owner !== "workspace" && path.relative(a.base, abs).startsWith(".."))
614
+ fail(`local_assets: "${a.rel}" (module ${a.owner}) escapes its module with .. — declare it at the workspace level instead`);
615
+ // The workspace-level twin, and it earns its own line: a rel that climbs out of the ROOT
616
+ // otherwise reached the gitignore check below, which cannot see a path outside the repo and
617
+ // so told the operator to ignore something git will never match. `checkout.js` refuses the
618
+ // same shape when the plan is built.
619
+ if (rel.startsWith(".."))
620
+ fail(`local_assets: "${a.rel}" escapes the workspace root with .. — a local asset must be a path INSIDE the workspace`);
621
+ if (ENGINE_OWNED.has(rel.split(path.sep)[0]))
622
+ fail(`local_assets: "${rel}" is engine-owned — install links .env and installs node_modules itself; never declare them`);
623
+ if (gitQ(["ls-files", "--error-unmatch", rel]))
624
+ fail(`local_assets: "${rel}" is tracked — a tracked path needs no link and a link would shadow it`);
625
+ // ⚠ WITHOUT a trailing slash, and the message has to say so: a dir-only pattern (`.profiles/`)
626
+ // matches neither a symlink nor a path that does not exist yet (measured, git 2.50) — and a
627
+ // shared asset is exactly those two shapes, a symlink in every non-primary checkout and
628
+ // absent before the first install.
629
+ if (!gitQ(["check-ignore", "-q", rel]))
630
+ fail(`local_assets: "${rel}" is not gitignored — add it to .gitignore WITHOUT a trailing slash (a worktree holds it as a symlink, and a dir-only pattern ignores neither a symlink nor an absent path); a shared asset must never be committed`);
631
+ }
632
+ if (config.postinstall != null && typeof config.postinstall !== "string")
633
+ fail("dreamteamer.postinstall must be a single shell string");
634
+ // `dependencies` names MODULES and must be acyclic. `peer_collections` names COLLECTIONS and
635
+ // therefore cannot cycle at all — which is the whole reason it exists: two modules that each
636
+ // reference a concept the other owns (crm needs `products`, rnd needs `contacts`) would be an
637
+ // unbreakable ring under module-named deps, and are two independent peer declarations here.
638
+ const moduleNames = new Set(sources.map(s => s.name));
639
+ for (const [mod, deps] of moduleDeps) {
640
+ for (const dep of deps) {
641
+ if (dep === mod)
642
+ fail(`module "${mod}" declares itself as a dependency`);
643
+ if (refused.has(dep))
644
+ fail(`module "${mod}" depends on "${dep}", which needs engine "${refused.get(dep)}" — this is ${engineVer}. Upgrade dreamteamer, or disable both.`);
645
+ if (!moduleNames.has(dep)) {
646
+ fail(`module "${mod}" depends on "${dep}", which is not installed — modules present: ${[...moduleNames].sort().join(", ")}\n run: dt install ${dep}`);
647
+ }
648
+ }
649
+ }
650
+ // A module preset's absent member is a WARNING, never a failure: the preset is a list, and the
651
+ // operator may have uninstalled a member on purpose.
652
+ for (const [mod, members] of modulePresets) {
653
+ for (const [member, v] of Object.entries(members)) {
654
+ if (!moduleNames.has(member))
655
+ console.warn(`⚠ module preset ${moduleId(mod)} names ${member} ${v}, which is not installed — dt install ${member}`);
656
+ }
657
+ }
658
+ // npm's `peerDependencies` naming ANOTHER discovered module is a VERSION FLOOR: npm refuses the install
659
+ // below it, and this refuses the channels npm never saw — a git_modules clone, an inline copy, an
660
+ // install that went around the peer check. An absent sibling is `dependencies`' business, not this one's.
661
+ {
662
+ const byName = new Map(sources.map(s => [s.name, s]));
663
+ const misses = [];
664
+ for (const [mod, floors] of moduleFloors)
665
+ for (const [dep, range] of Object.entries(floors)) {
666
+ const sib = byName.get(dep), have = moduleVersions.get(dep);
667
+ if (!sib || dep === mod)
668
+ continue;
669
+ const ok = satisfies(have, range);
670
+ if (ok === null)
671
+ console.warn(`⚠ module ${mod}: peerDependencies range "${range}" for "${dep}" (${have ?? "no version"}) not understood by the built-in checker (see src/lib/npm/satisfies.ts) — not verified`);
672
+ else if (!ok)
673
+ misses.push(`module "${mod}" ${moduleVersions.get(mod)} needs "${dep}" ${range} (its peerDependencies) — this workspace has ${have}, from ${CHANNEL_LABEL[sib.channel]}.\n fix: ${dep === "dreamteamer" ? `dt update --engine (the engine is the workspace's pin; init and install never change it)` : sib.channel === "npm" ? `npm install "${dep}@${range}"` : `bring ${rel(sib.root)} to a version in ${range}`}`);
674
+ }
675
+ if (misses.length)
676
+ fail(misses.join("\n"));
677
+ }
678
+ // DFS with an explicit path so the error can print the ring rather than just naming one module
679
+ {
680
+ const state = new Map(); // name -> 'open' | 'done'
681
+ const visit = (mod, trail) => {
682
+ if (state.get(mod) === "done")
683
+ return;
684
+ if (state.get(mod) === "open") {
685
+ const ring = [...trail.slice(trail.indexOf(mod)), mod];
686
+ fail(`cyclic module dependencies: ${ring.join(" → ")}\n a reference to a CONCEPT another module owns belongs in dreamteamer.peer_collections (a collection name), which cannot cycle.`);
687
+ }
688
+ state.set(mod, "open");
689
+ for (const dep of moduleDeps.get(mod) ?? [])
690
+ visit(dep, [...trail, mod]);
691
+ state.set(mod, "done");
692
+ };
693
+ for (const mod of moduleDeps.keys())
694
+ visit(mod, []);
695
+ }
696
+ const dataOwners = dataOwningModules(sources, fail, rel);
697
+ let layers;
698
+ try {
699
+ layers = layerEntries(pkg, root).map(l => ({
700
+ ...l,
701
+ root: path.posix.join("git_modules", l.name),
702
+ dataPath: layerDataPath(root, l.name),
703
+ }));
704
+ }
705
+ catch (e) {
706
+ fail(e.message);
707
+ }
708
+ for (const l of layers)
709
+ if (!fs.existsSync(path.join(root, l.root)))
710
+ console.warn(`⚠ layer ${l.name} (${l.root}) is not installed — its records are not read; run dreamteamer install`);
711
+ const disabled = new Set(config.disable ?? []);
712
+ const disabledHits = new Set(disabledModules); // bare entries were applied at discovery
713
+ /** entries: runtime-relative path -> { sources: [workspace-relative], bytes } */
714
+ const entries = new Map();
715
+ /** ui-view sources carrying `overlay: true` — merged onto their base after discovery */
716
+ const viewOverlays = [];
717
+ const isViewOverlay = (srcPath) => {
718
+ const text = fs.readFileSync(srcPath, "utf8");
719
+ // the regex is only a cheap pre-filter, so it must not be stricter than YAML: a trailing comment
720
+ // or space on the flag line still carries the flag (the parsed value is what decides)
721
+ return /^overlay:\s*true\b/m.test(text) && loadSource(text, rel(srcPath))?.overlay === true;
722
+ };
723
+ const counts = {};
724
+ /** collection descriptors collected per name, a base and its overlays: name -> [{src, doc, moduleName}] */
725
+ const descriptorGroups = new Map();
726
+ // ⚠ A runtime key is a POSIX path on every OS. Every reader of `entries` — the mixin, skill,
727
+ // command and ui-view passes below, the harness adapters, extensions — matches it with `/`, and
728
+ // `path.join` spells it with `\` on Windows, where no mixin loaded and the collections and skills
729
+ // indexes came out empty.
730
+ function addEntry(runtimePath, srcPath) {
731
+ runtimePath = toPosix(runtimePath);
732
+ if (entries.has(runtimePath)) {
733
+ const [, kind, entity] = /^([^/]+)\/([^/]+)/.exec(runtimePath) ?? [];
734
+ const entityId = (entity ?? "").replace(/\.[^.]+\.(yaml|md|json)$/, "");
735
+ const prev = entries.get(runtimePath).sources[0].path;
736
+ fail(`name collision on ${kind?.replace(/s$/, "") ?? "entity"} "${entityId}"
737
+ - ${prev}
738
+ - ${rel(srcPath)}
739
+ identity entities are never merged or shadowed (a collection declares \`overlay: true\` to add to another module's).
740
+ either rename yours, or disable one: add "${kind}/${entityId}" to dreamteamer.disable in package.json.`);
741
+ }
742
+ const bytes = fs.readFileSync(srcPath);
743
+ entries.set(runtimePath, { sources: [{ path: rel(srcPath), hash: sha256(bytes) }], bytes });
744
+ }
745
+ /** module names that actually put something into the compiled runtime — see the warning below */
746
+ const contributedBy = new Set();
747
+ for (const source of sources) {
748
+ // an unrecognised folder at a module root is a typo'd kind or a kind the engine dropped —
749
+ // both of which used to compile ✔ and contribute nothing (see NON_SOURCE_DIRS)
750
+ const strays = strayKindDirs(source, root, moduleIgnores.get(source.name) ?? [], kinds);
751
+ if (strays.length) {
752
+ // `ignore` matches a FOLDER NAME, at the root and under `system/` alike, so the remedy has
753
+ // to quote the bare name — suggesting "system/gizmos" would print an entry that matches
754
+ // nothing and send the reader back for a second compile to find that out.
755
+ const ignorable = [...new Set(strays.map(s => s.replace(/^system\//, "")))];
756
+ fail(`module "${source.name}" (${rel(source.root)}) has folder(s) that are not a known kind: ${strays.join(", ")}
757
+ known kinds: ${kinds.join(", ")}${contributed.length ? "" : `\n a kind an extension adds (proofs/, for one) is known only while that extension is installed or its module is present`}
758
+ if these are not sources, declare them: "dreamteamer": { "ignore": [${ignorable.map(s => `"${s}"`).join(", ")}] } in ${rel(path.join(source.root, "package.json"))}`);
759
+ }
760
+ for (const kind of kinds) {
761
+ const srcDir = stagedKindDir(source.root, kind);
762
+ // a half-moved module compiles its flat half and drops the rest — say so rather than
763
+ // reporting ✔ over a silent partial read (the decision-156 failure shape). A declared build
764
+ // folder is read instead of either spelling, so it has no half.
765
+ if (srcDir === kindDir(source.root, kind) && bothLayouts(source.root, kind)) {
766
+ console.warn(`⚠ module ${source.name}: both ${kind}/ and system/${kind}/ exist — the flat copy wins and system/${kind}/ is NOT compiled. finish the move.`);
767
+ }
768
+ if (!fs.existsSync(srcDir))
769
+ continue;
770
+ counts[kind] ??= 0;
771
+ // `collections/` is enumerated RECURSIVELY, so a namespaced descriptor can be authored at
772
+ // `collections/health/doctors.collection.yaml` — mirroring where it lands in the runtime and
773
+ // letting a workspace group its descriptors the same way its data is grouped.
774
+ //
775
+ // ⚠ This is load-bearing, not cosmetic. `schema-ops` derives a descriptor's source path from
776
+ // its name, so `add-field` on `health/doctors` writes the nested path; with a flat readdir
777
+ // that file was written, silently skipped, and the verb reported ✔ while changing nothing —
778
+ // the decision-156 shape again. Every other kind stays flat: their ids are single segments.
779
+ const names = kind === "collections"
780
+ ? [...walk(srcDir)].map(f => path.relative(srcDir, f).split(path.sep).join("/"))
781
+ : fs.readdirSync(srcDir).sort();
782
+ for (const name of names) {
783
+ if (name.startsWith("."))
784
+ continue;
785
+ if (excludedFromKind(contributed, kind, name))
786
+ continue;
787
+ const entityId = name.replace(/\.[^.]+\.(yaml|md|json)$/, "");
788
+ // an entity entry is `<kind>/<id>` — a record reference — and names that entity in any module
789
+ if (disabled.has(`${kind}/${entityId}`)) {
790
+ disabledHits.add(`${kind}/${entityId}`);
791
+ continue;
792
+ }
793
+ const srcPath = path.join(srcDir, name);
794
+ const isDir = fs.statSync(srcPath).isDirectory();
795
+ if (kind === "collections" && !isDir) {
796
+ // a base and its overlays merge — collect per collection name
797
+ const bytes = fs.readFileSync(srcPath);
798
+ // A `touch`ed file on the way to writing one is the ordinary way to arrive here. The
799
+ // descriptor keeps its own wording — it is the one kind that can say what is missing.
800
+ if (bytes.toString("utf8").trim() === "") {
801
+ fail(`${rel(srcPath)}: collection source is empty — a descriptor needs at least 'name' and 'fields'. Delete the file, or write one.`);
802
+ }
803
+ const doc = loadSource(bytes.toString("utf8"), rel(srcPath));
804
+ // a scalar or a list parses fine and then reads as undefined on every key below
805
+ if (doc == null || typeof doc !== "object" || Array.isArray(doc)) {
806
+ fail(`${rel(srcPath)}: collection source is not a mapping — a descriptor needs at least 'name' and 'fields'.`);
807
+ }
808
+ // a v1 source is refused with every other one, in one message (compile-collections.js)
809
+ if (!doc.name)
810
+ fail(`${rel(srcPath)}: descriptor needs 'name'`);
811
+ if (!descriptorGroups.has(doc.name))
812
+ descriptorGroups.set(doc.name, []);
813
+ descriptorGroups
814
+ .get(doc.name)
815
+ // a mapping with a name — compile-collections validates the rest, every file at once
816
+ .push({
817
+ src: { path: rel(srcPath), hash: sha256(bytes) },
818
+ doc: doc,
819
+ moduleName: source.name,
820
+ });
821
+ contributedBy.add(source.name);
822
+ }
823
+ else if (FOLDER_KINDS.has(kind) && isDir) {
824
+ // the folder's ENTITY file, not its payload — see refuseEmptySource
825
+ const entityFile = path.join(srcPath, "SKILL.md");
826
+ if (fs.existsSync(entityFile))
827
+ refuseEmptySource(entityFile);
828
+ for (const file of walk(srcPath)) {
829
+ addEntry(path.join(kind, name, path.relative(srcPath, file)), file);
830
+ contributedBy.add(source.name);
831
+ }
832
+ counts[kind]++;
833
+ }
834
+ else if (!isDir) {
835
+ refuseEmptySource(srcPath);
836
+ // a view OVERLAY is merged onto the view it names once every source is in (below), so
837
+ // discovery order between the two modules never decides which is the base
838
+ if (kind === "ui-views" && isViewOverlay(srcPath)) {
839
+ viewOverlays.push({ runtimePath: toPosix(path.join(kind, name)), srcPath, moduleName: source.name });
840
+ contributedBy.add(source.name);
841
+ continue;
842
+ }
843
+ addEntry(path.join(kind, name), srcPath);
844
+ contributedBy.add(source.name);
845
+ counts[kind]++;
846
+ }
847
+ else {
848
+ // nested dirs for file-shape kinds (e.g. date-partitioned) — recurse
849
+ for (const file of walk(srcPath)) {
850
+ refuseEmptySource(file);
851
+ addEntry(path.join(kind, path.relative(srcDir, file)), file);
852
+ contributedBy.add(source.name);
853
+ counts[kind]++;
854
+ }
855
+ }
856
+ }
857
+ }
858
+ }
859
+ // ui-view overlays: a same-id view carrying `overlay: true` MERGES onto the shipped one
860
+ // The way a collection overlay refines a descriptor it does not own, so a workspace changes a
861
+ // package's view in the few lines that differ instead of copying it (and losing every later fix
862
+ // the package ships). DEEP, overlay wins at the leaves, a list is replaced whole, and `null`
863
+ // REMOVES the key — the one spelling an overlay has for "the package sets this; I do not". A
864
+ // view without the flag and the same id is still the collision `addEntry` names.
865
+ const ownerOf = (file) => sources
866
+ .map(s => ({ s, at: rel(s.root) }))
867
+ .filter(({ at }) => !at || file.startsWith(`${at}/`))
868
+ .sort((a, b) => b.at.length - a.at.length)[0]?.s;
869
+ for (const o of viewOverlays) {
870
+ const e = entries.get(o.runtimePath);
871
+ const id = path.posix.basename(o.runtimePath).replace(/\.ui-view\.yaml$/, "");
872
+ if (!e)
873
+ fail(`${rel(o.srcPath)}: an overlay of ui-view "${id}" (overlay: true), but no module ships a view "${id}" — drop \`overlay: true\` to make it a view of its own, or install the module that ships it.`);
874
+ const bytes = fs.readFileSync(o.srcPath);
875
+ const { overlay: _flag, ...ov } = loadSource(bytes.toString("utf8"), rel(o.srcPath)) ?? {};
876
+ const merged = overlayView(loadSource(e.bytes.toString("utf8"), e.sources[0].path) ?? {}, ov);
877
+ e.bytes = Buffer.from(dump(merged));
878
+ e.sources.push({ path: rel(o.srcPath), hash: sha256(bytes) });
879
+ e.module ??= moduleId(ownerOf(e.sources[0].path)?.name ?? "");
880
+ (e.overlaidBy ??= []).push(moduleId(o.moduleName));
881
+ }
882
+ // modules ship a PRE-BUILT app.js that registers components/layouts against the surface's
883
+ // registry (design "the UI": components are module code, never records). staged under
884
+ // .dreamteamer/ui/<module>/app.js; the VS Code extension reads it off disk (decision 48) and
885
+ // the legacy server served it at /ui. `dist/app.js` (a built bundle) wins over `app.js`
886
+ // (plain-JS, host-provided Vue).
887
+ //
888
+ // `ui/` is the name — it matches where the bundle STAGES and what it is. `studio/` is the
889
+ // original name and stays a fallback: the studio it referred to is archived (decisions 51, 93),
890
+ // so the folder was named after a surface that no longer exists. Both are in NON_SOURCE_DIRS,
891
+ // so neither trips the unknown-folder gate (decision 179).
892
+ const uiModules = [];
893
+ const uiOwners = new Map(); // shortName -> module name, for a readable collision error
894
+ for (const source of sources) {
895
+ const cand = ["ui/dist/app.js", "ui/app.js", "studio/dist/app.js", "studio/app.js"]
896
+ .map(p => path.join(source.root, p))
897
+ .find(p => fs.existsSync(p));
898
+ if (!cand)
899
+ continue;
900
+ // short name = full package name, url-safe: "@" stripped, "/" → "--"
901
+ // (@a/crm and @b/crm used to both stage ui/crm — audit finding 4). unscoped
902
+ // names are unchanged, so existing /ui/<name>/app.js paths survive.
903
+ const shortName = source.name.replace(/^@/, "").replace(/\//g, "--");
904
+ const prevOwner = uiOwners.get(shortName);
905
+ if (prevOwner)
906
+ fail(`ui bundle collision: modules "${prevOwner}" and "${source.name}" both stage ui/${shortName}/app.js — rename one package.`);
907
+ uiOwners.set(shortName, source.name);
908
+ addEntry(path.join("ui", shortName, "app.js"), cand);
909
+ uiModules.push(shortName);
910
+ // A UI bundle IS a contribution. Counting it here is what keeps the warning below honest —
911
+ // a module whose whole purpose is a layout used to be told it "contributed no recognised
912
+ // sources" while its layout was rendering in the app.
913
+ contributedBy.add(source.name);
914
+ }
915
+ // A module that ships only folders the engine does not recognise compiles ✔ and contributes
916
+ // NOTHING. Warn; do not fail, since a module that is temporarily source-free is the
917
+ // operator's business, not the compiler's. Runs AFTER UI staging so a UI-only module counts.
918
+ // ⚠ A module with a scaffolded-but-EMPTY kind folder is a module being AUTHORED, not a mistake.
919
+ // `add modules` creates exactly that shape — eight empty kind folders — and a verb whose own
920
+ // output triggers a warning reads as a broken install. The warning's remaining job is the case it
921
+ // was written for: a module that ships nothing the engine recognises AT ALL, which is what
922
+ // decision 156 cost two days. `kindDir` returns the flat path when neither layout exists, so this
923
+ // is a genuine existence test on either spelling.
924
+ const extensionNames = new Set(extensions.map(e => e.name));
925
+ for (const source of sources) {
926
+ if (contributedBy.has(source.name) || extensionNames.has(source.name) || modulePresets.has(source.name))
927
+ continue;
928
+ if (kinds.some(k => fs.existsSync(stagedKindDir(source.root, k))))
929
+ continue;
930
+ console.warn(`⚠ module "${source.name}" (${rel(source.root)}) contributed no recognised sources — its folder names must match a known kind (${kinds.join(", ")}) or it must ship a UI bundle at ui/app.js`);
931
+ }
932
+ // An npm-installed module's `data/` is read by NOTHING: no root points into node_modules/, because
933
+ // records there could never be committed (owns_data and `storage.owner: module` are refused for npm
934
+ // above). A package shipping one — seed records, a stale copy — compiled ✔ and its records silently
935
+ // never appeared. Say so, naming the package and the folder. A module whose OWN script reads the
936
+ // folder (a workflow installer copying templates out of it) declares it: `"ignore": ["data"]`.
937
+ for (const source of sources) {
938
+ if (source.channel !== "npm" || (moduleIgnores.get(source.name) ?? []).includes("data"))
939
+ continue;
940
+ const data = path.join(source.root, "data");
941
+ let holds = false;
942
+ try {
943
+ holds = fs.readdirSync(data, { recursive: true, withFileTypes: true }).some(e => e.isFile());
944
+ }
945
+ catch {
946
+ /* no data/ */
947
+ }
948
+ if (holds)
949
+ console.warn(`⚠ module ${source.name} ships ${rel(data)}/ and nothing reads it — a module installed from npm cannot hold records (node_modules/ is never committed), so no collection reads that folder. Vendor the module into modules/ or install it as a git module to keep records in it; if one of its own scripts reads the folder, declare "dreamteamer": { "ignore": ["data"] } in its package.json.`);
950
+ }
951
+ // mixins (descriptor v2): partial descriptors merged into the collections that list them
952
+ const mixinDocs = new Map(); // id -> doc (with `src` for staleness)
953
+ for (const [rt, entry] of entries) {
954
+ const m = /^mixins\/(.+)\.mixin\.yaml$/.exec(rt);
955
+ if (!m)
956
+ continue;
957
+ const doc = loadSource(entry.bytes.toString("utf8"), entry.sources[0].path);
958
+ if (!doc || typeof doc !== "object")
959
+ fail(`${entry.sources[0].path}: a mixin is a mapping`);
960
+ const bad = Object.keys(doc).filter(k => !["name", "description", "use_when", "fields", "storage", "ids", "display", "constraints"].includes(k));
961
+ if (bad.length)
962
+ fail(`${entry.sources[0].path}: unknown key(s) ${bad.join(", ")} — a mixin carries name · description · use_when · fields · storage · ids · display · constraints`);
963
+ if (doc.name !== m[1])
964
+ fail(`${entry.sources[0].path}: name "${doc.name}" must equal the file's id "${m[1]}"`);
965
+ if (!String(doc.description ?? "").trim())
966
+ console.warn(`⚠ mixin ${m[1]} has no description — it renders as a bare name in the orientation block every session loads`);
967
+ mixinDocs.set(m[1], { ...doc, src: entry.sources[0] });
968
+ }
969
+ // namespaces: the UNION of every module's declaration plus the workspace's (§8)
970
+ //
971
+ // This used to be "the workspace package.json only, never per-module", and the reason was real: a
972
+ // module that can declare a namespace can rename where another module's records live. What it
973
+ // cost was decision 130's own acceptance test — "a module compiles alone in a bare workspace" —
974
+ // which no NAMESPACED module could ever pass, because the consuming workspace had to edit its
975
+ // manifest before the module would compile. That is precisely the coupling the rule forbids.
976
+ //
977
+ // Three rules keep the protection:
978
+ // 1. ONE OWNER per namespace. Two modules declaring it is a hard error naming both.
979
+ // 2. USING one requires the dependency (checked per collection, below) — otherwise the union
980
+ // would let a second module squat in the first's namespace silently. Before the union, B
981
+ // alone simply failed loudly, and that accident was the safer behaviour.
982
+ // 3. A WORKSPACE declaration duplicating a module's is a WARNING. Every existing workspace
983
+ // declares at the workspace level, and an upgrade must not brick compile.
984
+ //
985
+ // The resolved set is STAMPED INTO THE MANIFEST, so `namespace.js`, `parseRef`, the store, `check`
986
+ // and the extension are all unchanged — they read the artifact, exactly as they read
987
+ // `storage.base`. Config rather than records for the same bootstrap reason `git-modules` is: a
988
+ // reference has to be parseable before anything has been compiled.
989
+ const nsOwners = new Map(); // namespace -> the module NAME that declares it
990
+ for (const source of sources) {
991
+ for (const ns of normalizeNamespaces(moduleNamespaces.get(source.name))) {
992
+ const prev = nsOwners.get(ns);
993
+ if (prev && prev !== source.name) {
994
+ fail(`namespace "${ns}" is declared by ${moduleId(prev)} AND ${moduleId(source.name)} — one owner. Remove it from one (dt set modules/<m> namespaces=…).`);
995
+ }
996
+ nsOwners.set(ns, source.name);
997
+ }
998
+ }
999
+ for (const ns of normalizeNamespaces(config.namespaces)) {
1000
+ const owner = nsOwners.get(ns);
1001
+ if (!owner)
1002
+ continue;
1003
+ console.warn(`⚠ namespace "${ns}" is declared both by module ${moduleId(owner)} and at the workspace level — the module's declaration is the one that TRAVELS, so the workspace copy is redundant. Drop it: dt set modules/${moduleId(owner)} namespaces=${ns}`);
1004
+ }
1005
+ const namespaces = normalizeNamespaces([...nsOwners.keys(), ...(config.namespaces ?? [])]);
1006
+ const collectionNames = [...descriptorGroups.keys()];
1007
+ for (const p of namespaceProblems(namespaces, collectionNames))
1008
+ fail(p);
1009
+ // The silent failure this whole feature had to fix: a slash in a collection name used to compile
1010
+ // clean, land at `.dreamteamer/collections/<ns>/<name>.collection.yaml`, and then vanish — the
1011
+ // descriptor loader read one directory level, so the collection was simply absent from the
1012
+ // runtime while compile reported ✔ (the same shape as decision 156).
1013
+ // ⚠ THE STATED TRADE (§8): the namespace set is now a function of the INSTALLED MODULE SET, so
1014
+ // removing or disabling a namespace-owning module re-splits every reference into it. The record
1015
+ // layer's sentence is correct and cannot know that — `namespace.js` is pure and must stay so — so
1016
+ // the module half is appended here, where the module set is in hand.
1017
+ for (const p of unqualifiedProblems(collectionNames, namespaces)) {
1018
+ const guess = /but "([^"]+)" is not declared/.exec(p)?.[1];
1019
+ const gone = guess && prevManifestNamespaces(root).includes(guess) ? guess : null;
1020
+ fail(gone
1021
+ ? `${p}\n ⚠ "${gone}" WAS declared in the previous compile — by a module you just removed or disabled. Re-install it, or declare the namespace where the collection now lives: dt set modules/<m> namespaces=${gone}`
1022
+ : p);
1023
+ }
1024
+ // collections: descriptor format v2, the only format read
1025
+ // The engine's own collections are an implicit dependency of every module: the entity kinds the
1026
+ // compiler materializes, plus `repos` (because `install repos/<id>` clones them).
1027
+ const CORE_COLLECTIONS = new Set([...kinds, ...DERIVED_KINDS, "repos"]);
1028
+ const engineName = engineId().replace(/@[^@]*$/, "");
1029
+ const wsDir = config.workspace_module;
1030
+ const wsModuleName = wsDir ? sources.find(s => rel(s.root) === path.posix.join("modules", wsDir))?.name : pkg.name;
1031
+ // a declared git module whose clone is absent is an UNINSTALLED workspace (a fresh clone), so a
1032
+ // collection error there is named with the install, not left reading as a broken reference
1033
+ const uninstalled = Object.keys(config.git_modules ?? {}).filter(n => !fs.existsSync(path.join(root, "git_modules", n)));
1034
+ const collectionsFail = (msg) => fail(uninstalled.length
1035
+ ? `${msg}\n run \`dreamteamer install\` first — dreamteamer.git_modules declares ${uninstalled.join(", ")}, and no clone of ${uninstalled.length === 1 ? "it" : "them"} is on disk yet`
1036
+ : msg);
1037
+ const { compiled: compiledColls, inert: inertSources, moduleColls, layerReads, } = compileCollections({
1038
+ groups: descriptorGroups,
1039
+ mixins: mixinDocs,
1040
+ namespaces,
1041
+ nsOwners,
1042
+ runtimeKinds: new Set([...kinds, ...DERIVED_KINDS]),
1043
+ core: CORE_COLLECTIONS,
1044
+ moduleDeps,
1045
+ modulePresets,
1046
+ modulePeers,
1047
+ channelOf,
1048
+ wsModuleName,
1049
+ engineName,
1050
+ dataOwners,
1051
+ moduleSources: new Map(sources.map(s => [s.name, s])),
1052
+ unownableBecause,
1053
+ layers,
1054
+ repoOf: moduleRoot => repoRootOf(moduleRoot, root),
1055
+ rel,
1056
+ root,
1057
+ dataPath: config.data_path ?? "data",
1058
+ vars: storageVars,
1059
+ moduleId,
1060
+ fail: collectionsFail,
1061
+ warn: m => console.warn(m),
1062
+ });
1063
+ refusePlacementTransitions(root, compiledColls);
1064
+ counts.collections = 0;
1065
+ const mergedCount = [...compiledColls.values()].filter(c => c.compiled.overlaid_by.length).length;
1066
+ for (const [name, c] of compiledColls) {
1067
+ entries.set(path.posix.join("collections", `${name}.collection.yaml`), {
1068
+ sources: c.sources,
1069
+ bytes: Buffer.from(dump(c.doc, { noRefs: true })),
1070
+ });
1071
+ counts.collections++;
1072
+ }
1073
+ // One record per discovered module, written from what discovery and the package pass already
1074
+ // established. `package.json` remains the source of truth and compile keeps reading it — this
1075
+ // is a photograph, never an input (see collections/modules.collection.yaml for why it earns a
1076
+ // place in core at all).
1077
+ //
1078
+ // The id strips an npm scope so `@dreamteamer/crm` reads as `crm`, which is what every message
1079
+ // in this engine already calls it. A collision is a hard failure rather than a silent overwrite:
1080
+ // two modules answering to one id would make `dependencies` ambiguous, and an ambiguous edge is
1081
+ // worse than no diagram.
1082
+ const idByModule = new Map();
1083
+ for (const source of sources) {
1084
+ const id = moduleId(source.name);
1085
+ const clash = idByModule.get(id);
1086
+ if (clash && clash !== source.name)
1087
+ fail(`modules "${clash}" and "${source.name}" both resolve to the id "${id}" — rename one.`);
1088
+ idByModule.set(id, source.name);
1089
+ }
1090
+ const presetProjection = (names) => {
1091
+ const installed = names.filter(n => sources.some(s => s.name === n)).length;
1092
+ return {
1093
+ preset: true,
1094
+ members: names.map(n => `modules/${moduleId(n)}`),
1095
+ preset_summary: `preset · ${names.length} members · ${installed} installed`,
1096
+ };
1097
+ };
1098
+ for (const source of sources) {
1099
+ const id = moduleId(source.name);
1100
+ let pkg = {};
1101
+ try {
1102
+ pkg = JSON.parse(fs.readFileSync(path.join(source.root, "package.json"), "utf8"));
1103
+ }
1104
+ catch {
1105
+ /* inline workspace source */
1106
+ }
1107
+ const mpkg = pkg.dreamteamer ?? {};
1108
+ // What this module is FOR, in one line. `dreamteamer.description` wins; npm's own top-level
1109
+ // `description` is the fallback, because it is the one place a package author already writes
1110
+ // that sentence — six modules on one dogfood workspace had authored it THERE and every
1111
+ // `dt list modules` row read `-` for description. There is no derivation past that and there
1112
+ // should not be: a module is the only place that knows.
1113
+ const description = [mpkg.description, pkg.description].find(s => typeof s === "string" && s.trim());
1114
+ // A module with no sentence renders as a bare title at the head of its section in the
1115
+ // orientation block — the one place a session learns what an AREA of the workspace is for.
1116
+ // Same shape as the per-collection warning: non-blocking, named per offender.
1117
+ if (!description)
1118
+ console.warn(`⚠ module ${source.name} has no description — set "description" in its package.json; it heads its own section in the orientation block every session loads`);
1119
+ const record = {
1120
+ name: source.name,
1121
+ // Authored wins; the derived fallback title-cases the id the same way a collection's
1122
+ // `title` is derived. `@dreamteamer/crm` -> "Crm" until crm declares "CRM" — which is
1123
+ // the point: the module is the only place that knows.
1124
+ title: typeof mpkg.title === "string" && mpkg.title ? mpkg.title : titleCase(id),
1125
+ ...(description ? { description } : {}),
1126
+ // §8: the namespaces THIS module declares — projected from its package.json, so
1127
+ // `dt list modules` answers "who owns hr?" without reading seven package.json files.
1128
+ ...(normalizeNamespaces(mpkg.namespaces).length ? { namespaces: normalizeNamespaces(mpkg.namespaces) } : {}),
1129
+ // §10: the folder name, not an internal channel word. `dt status` then reads
1130
+ // `hr git_modules @ 3f2a1c (dirty)` and needs no legend.
1131
+ location: locationOf(source, root),
1132
+ path: rel(source.root) || ".",
1133
+ // The module's RUNNABLE entry points — `bin/<file>`, the folder NON_SOURCE_DIRS waves through.
1134
+ // Skills and commands render into the orientation block; a module whose procedure is a
1135
+ // script did not, so a session planned `dt add` writes the tooling forbids. This is the
1136
+ // POINTER that the procedure exists, never its arguments — those stay in the skill.
1137
+ ...(binEntries(source.root).length ? { bin: binEntries(source.root) } : {}),
1138
+ // ...and the scripts it runs BY NAME (`dt run <id> <name>`), the pointer that survives a module
1139
+ // moving its code into dist/ — where `bin/` no longer exists to be listed.
1140
+ ...(mpkg.scripts && Object.keys(mpkg.scripts).length ? { scripts: Object.keys(mpkg.scripts).sort() } : {}),
1141
+ ...(mpkg.owns_data === true ? { owns_data: true } : {}),
1142
+ // Declared module names become record IDS here, because that is what a reference
1143
+ // resolves against. An undeclared/unknown name would dangle, and `check` would say so —
1144
+ // but compile has already failed on that case (the acyclicity pass resolves every one).
1145
+ // ⚠ A reference VALUE is `<collection>/<id>`, never a bare id — `check` rejects the bare
1146
+ // form, which is exactly what it did to the first pass of this projection (63 violations).
1147
+ ...(moduleDeps.get(source.name)?.length
1148
+ ? { dependencies: moduleDeps.get(source.name).map(n => `modules/${moduleId(n)}`) }
1149
+ : {}),
1150
+ ...(modulePeers.get(source.name)?.length
1151
+ ? { peer_collections: modulePeers.get(source.name).map(c => `collections/${c}`) }
1152
+ : {}),
1153
+ ...(moduleColls.get(source.name)?.size
1154
+ ? { collections: [...moduleColls.get(source.name)].sort().map(c => `collections/${c}`) }
1155
+ : {}),
1156
+ // A MODULE PRESET (CR-dt-008): its members as references, and how many of them are here.
1157
+ ...(modulePresets.has(source.name) ? presetProjection(Object.keys(modulePresets.get(source.name))) : {}),
1158
+ };
1159
+ const bytes = Buffer.from(dump(record));
1160
+ // ⚠ The source hash is the hash of the SOURCE FILE, not of the projected record. Hashing the
1161
+ // output made every source "differ" on the next run, so `staleness` reported the workspace
1162
+ // stale immediately after a clean compile — the one signal that has to stay trustworthy.
1163
+ const pkgPath = path.join(source.root, "package.json");
1164
+ const pkgBytes = fs.existsSync(pkgPath) ? fs.readFileSync(pkgPath) : bytes;
1165
+ entries.set(path.posix.join("modules", `${id}.module.yaml`), {
1166
+ sources: [{ path: rel(pkgPath), hash: sha256(pkgBytes) }],
1167
+ bytes,
1168
+ });
1169
+ counts.modules = (counts.modules ?? 0) + 1;
1170
+ }
1171
+ // ONE source, rendered verbatim into every harness's instruction file. It is registered as a
1172
+ // manifest entry for exactly one reason: `staleness` walks manifest sources, so a file that is
1173
+ // not one can be edited forever without `dt status` ever saying the harness files lag it — and a
1174
+ // silent lag on the file carrying the operator's rules is the worst possible thing to be silent
1175
+ // about. The runtime copy is never read by anything; the manifest ENTRY is the whole point.
1176
+ // uppercase, like the harness files it feeds; the readdir — not existsSync — because on a
1177
+ // case-insensitive filesystem `dreamteamer.md` and `DREAMTEAMER.md` are one path
1178
+ if (fs.readdirSync(root).includes("dreamteamer.md"))
1179
+ fail(`the instructions source is DREAMTEAMER.md, and dreamteamer.md is not read — rename it (git mv dreamteamer.md DREAMTEAMER.md; on a case-insensitive filesystem go through a temporary name), then compile.`);
1180
+ const instructionsPath = path.join(root, INSTRUCTIONS_SOURCE);
1181
+ if (fs.existsSync(instructionsPath)) {
1182
+ const bytes = fs.readFileSync(instructionsPath);
1183
+ refuseManagedMarkers(bytes.toString("utf8"), rel(instructionsPath));
1184
+ entries.set("instructions.md", { sources: [{ path: rel(instructionsPath), hash: sha256(bytes) }], bytes });
1185
+ }
1186
+ // unresolved references are compile errors (an agent's declared skills)
1187
+ const skillIds = new Set([...entries.keys()].filter(k => k.startsWith("skills/")).map(k => k.split("/")[1]));
1188
+ for (const [rt, e] of entries) {
1189
+ // A SKILL whose frontmatter is not YAML compiled ✔ and was refused one gate later by `check`,
1190
+ // naming the compiled copy under .dreamteamer/ that nobody can edit — found when an installed
1191
+ // package shipped a description holding `: `. Parsed here, where the source path is known.
1192
+ if (/^skills\/[^/]+\/SKILL\.md$/.test(rt)) {
1193
+ const fm = /^---\r?\n([\s\S]*?)\r?\n---/.exec(e.bytes.toString("utf8"));
1194
+ if (fm)
1195
+ loadSource(fm[1], e.sources[0].path);
1196
+ }
1197
+ if (rt.startsWith("agents/")) {
1198
+ const fm = /^---\r?\n([\s\S]*?)\r?\n---/.exec(e.bytes.toString("utf8"));
1199
+ const doc = fm ? loadSource(fm[1], e.sources[0].path) : {};
1200
+ for (const sk of doc.skills ?? []) {
1201
+ if (!skillIds.has(String(sk).replace(/^skills\//, "")))
1202
+ fail(`${rt}: references unknown skill "${sk}"`);
1203
+ }
1204
+ }
1205
+ }
1206
+ if (disabledHits.size < disabled.size) {
1207
+ for (const d of disabled)
1208
+ if (!disabledHits.has(d))
1209
+ console.warn(`⚠ dreamteamer.disable entry "${d}" matched nothing`);
1210
+ }
1211
+ // ui-views and command-bindings: validated against the collection each one names
1212
+ // `layout` is not validated: the engine validates a value only where it interprets it, and a layout
1213
+ // id is opaque payload for whichever surface renders it (an unregistered one degrades there). Filter
1214
+ // operators, field names and templates the engine does interpret, so a typo fails here rather than
1215
+ // as a view that draws nothing or a gate that never opens. A view's compiled file is its source plus
1216
+ // `compiled.display`: its display merged over its collection's.
1217
+ const collectionOf = (ref) => {
1218
+ const name = String(ref ?? "").replace(/^collections\//, "");
1219
+ const e = name && entries.get(path.posix.join("collections", `${name}.collection.yaml`));
1220
+ return e ? load(e.bytes.toString("utf8")) : null;
1221
+ };
1222
+ const fieldsKnown = (d) => d ? fieldsOf(d) : undefined;
1223
+ // a module declaring a peer that is not installed may name a field that peer's overlay adds
1224
+ const lenientFor = (file) => {
1225
+ const owner = sources
1226
+ .map(s => ({ s, at: rel(s.root) }))
1227
+ .filter(({ at }) => !at || file.startsWith(`${at}/`))
1228
+ .sort((a, b) => b.at.length - a.at.length)[0]?.s;
1229
+ return (modulePeers.get(owner?.name) ?? []).some(p => !descriptorGroups.has(p));
1230
+ };
1231
+ const v1Sources = [];
1232
+ for (const [rt, e] of entries) {
1233
+ if (!rt.startsWith("ui-views/"))
1234
+ continue;
1235
+ const file = e.sources[0].path;
1236
+ const view = loadSource(e.bytes.toString("utf8"), file);
1237
+ const d = view?.collection ? collectionOf(view.collection) : null;
1238
+ const groupFields = (f) => {
1239
+ const t = d && f ? targetsOf(fieldsOf(d)[f]) : null;
1240
+ return Array.isArray(t) && t.length === 1 ? fieldsKnown(collectionOf(`collections/${t[0]}`)) : undefined;
1241
+ };
1242
+ const { errors, warnings, v1 } = viewErrors(view, {
1243
+ file,
1244
+ fields: fieldsKnown(d),
1245
+ groupFields,
1246
+ lenient: lenientFor(file),
1247
+ });
1248
+ if (v1) {
1249
+ v1Sources.push(file);
1250
+ continue;
1251
+ }
1252
+ if (errors.length)
1253
+ fail(errors.join("\n "));
1254
+ for (const w of warnings)
1255
+ console.warn(`⚠ ${w}`);
1256
+ const text = e.bytes.toString("utf8");
1257
+ const provenance = e.overlaidBy ? { module: e.module, overlaid_by: e.overlaidBy } : {};
1258
+ e.bytes = Buffer.from(`${text}${text.endsWith("\n") ? "" : "\n"}${dump({ compiled: { display: viewDisplay(d ? displayOf(d) : {}, view), ...provenance } })}`);
1259
+ }
1260
+ // a command's id is its path under commands/, folders included: `commands/rnd/design.command.md` is
1261
+ // `rnd/design`, typed as `/rnd:design` — the folder is the namespace, as claude-code already reads it
1262
+ const commandIds = new Set([...entries.keys()]
1263
+ .filter(k => k.startsWith("commands/"))
1264
+ .map(k => k.slice("commands/".length).replace(/\.command\.md$/, "")));
1265
+ for (const [rt, e] of entries) {
1266
+ if (!rt.startsWith("command-bindings/"))
1267
+ continue;
1268
+ const file = e.sources[0].path;
1269
+ const b = loadSource(e.bytes.toString("utf8"), file);
1270
+ if (bindingErrors(b, { file }).v1) {
1271
+ v1Sources.push(file);
1272
+ continue;
1273
+ }
1274
+ const cmd = String(b?.command ?? "").replace(/^commands\//, "");
1275
+ if (!cmd || !commandIds.has(cmd))
1276
+ fail(`${rt}: references unknown command "${b?.command ?? ""}"`);
1277
+ const coll = String(b?.collection ?? "").replace(/^collections\//, "");
1278
+ if (!coll || !descriptorGroups.has(coll))
1279
+ fail(`${rt}: references unknown collection "${b?.collection ?? ""}"`);
1280
+ const { errors, warnings } = bindingErrors(b, {
1281
+ file,
1282
+ fields: fieldsKnown(collectionOf(coll)),
1283
+ lenient: lenientFor(file),
1284
+ });
1285
+ if (errors.length)
1286
+ fail(errors.join("\n "));
1287
+ for (const w of warnings)
1288
+ console.warn(`⚠ ${w}`);
1289
+ }
1290
+ if (v1Sources.length)
1291
+ fail(v1Refusal(v1Sources.sort()));
1292
+ // After the whole compile is assembled and BEFORE any output is replaced: an extension that owns a
1293
+ // source kind judges its entries against the final merged schemas (proofs name artifacts and filter
1294
+ // on fields, so only the assembled workspace can say whether they mean anything). The draft is data
1295
+ // only — no filesystem writer, no Store, no environment VALUES, key names only. An error fails the
1296
+ // compile exactly like a built-in check; notes print after the summary.
1297
+ const notes = [];
1298
+ if (extensions.some(e => e.analyze)) {
1299
+ const descriptors = new Map();
1300
+ for (const [rt, e] of entries) {
1301
+ if (!rt.startsWith("collections/"))
1302
+ continue;
1303
+ const doc = load(e.bytes.toString("utf8"));
1304
+ if (doc?.name)
1305
+ descriptors.set(doc.name, doc);
1306
+ }
1307
+ const draft = Object.freeze({
1308
+ entries,
1309
+ descriptors,
1310
+ modules: sources.map(s => ({
1311
+ id: moduleId(s.name),
1312
+ name: s.name,
1313
+ root: rel(s.root) || ".",
1314
+ channel: s.channel,
1315
+ })),
1316
+ declaredVars: [...declaredVars],
1317
+ declaredEnv: [...declaredEnv.keys()],
1318
+ previousManifest: prevManifest,
1319
+ parse: (rt) => loadSource(entries.get(rt).bytes.toString("utf8"), entries.get(rt).sources[0].path),
1320
+ });
1321
+ for (const ext of extensions) {
1322
+ if (!ext.analyze)
1323
+ continue;
1324
+ const out = (ext.analyze(draft) ?? {});
1325
+ if (out.errors?.length)
1326
+ fail(out.errors.join("\n "));
1327
+ for (const w of out.warnings ?? [])
1328
+ console.warn(`⚠ ${w}`);
1329
+ notes.push(...(out.notes ?? []));
1330
+ }
1331
+ }
1332
+ // extension code for the harness pass, run BEFORE anything is replaced
1333
+ // A contributed renderer that throws must leave the last good runtime and every harness file
1334
+ // byte-for-byte as they were — so it runs here, on data, and the write pass below only writes.
1335
+ let contributions;
1336
+ try {
1337
+ contributions = renderContributions({ entries, harnesses, version: engineVer, extensions });
1338
+ }
1339
+ catch (e) {
1340
+ fail(e.message);
1341
+ }
1342
+ // mkdir the runtime ROOT unconditionally: with zero entries nothing below created it, so the
1343
+ // manifest write at the end failed ENOENT — `init` followed by `compile` in a fresh workspace
1344
+ // crashed on the one path a new user takes first.
1345
+ fs.mkdirSync(RUNTIME, { recursive: true });
1346
+ // clear each kind's folder, plus `system/` — a runtime compiled by a pre-flatten engine has the
1347
+ // whole tree under there, and leaving it would keep stale descriptors on disk beside the fresh
1348
+ // ones. Never `rm -rf` the runtime root itself: it also holds the write lock.
1349
+ // ⚠ DERIVED_KINDS too, not just KINDS. `modules/` is projected rather than staged, so it was not
1350
+ // in this loop and never got cleared — a module that was RENAMED or REMOVED left its old record
1351
+ // behind forever, listing collections that no longer exist. `check` reads those records like any
1352
+ // other, so it surfaced as a dangling reference in a file nobody had touched, twice in one day
1353
+ // (the workspace module's own record after it was renamed, and a domain module's after it was
1354
+ // folded into another). The
1355
+ // runtime is build output; stale build output is the compiler's problem, not the reader's.
1356
+ // ⚠ AND every kind the PREVIOUS compile staged: an extension uninstalled since then leaves its
1357
+ // compiled folder behind otherwise, read by nothing and listed by `dt list` for ever.
1358
+ const prevKinds = (prevManifest?.["source-kinds"] ?? [])
1359
+ .map(k => k.kind)
1360
+ .filter(k => typeof k === "string" && /^[a-z][a-z0-9-]*$/.test(k));
1361
+ for (const kind of new Set([...kinds, ...DERIVED_KINDS, ...prevKinds]))
1362
+ fs.rmSync(path.join(RUNTIME, kind), { recursive: true, force: true });
1363
+ fs.rmSync(path.join(RUNTIME, "system"), { recursive: true, force: true });
1364
+ fs.rmSync(path.join(RUNTIME, "ui"), { recursive: true, force: true });
1365
+ for (const [rt, e] of entries) {
1366
+ const dest = path.join(RUNTIME, rt);
1367
+ fs.mkdirSync(path.dirname(dest), { recursive: true });
1368
+ fs.writeFileSync(dest, e.bytes);
1369
+ }
1370
+ // What the harness blocks should TELL an agent about where sources live — measured, not assumed.
1371
+ // A workspace still on the nested layout was being handed prose naming the flat one, and that
1372
+ // block is the first thing a session reads.
1373
+ const anyFlat = sources.some(s => kinds.some(k => fs.existsSync(path.join(s.root, k))));
1374
+ const anyNested = sources.some(s => kinds.some(k => fs.existsSync(path.join(s.root, "system", k))));
1375
+ const sourceLayout = anyFlat && anyNested ? "mixed" : anyNested ? "nested" : "flat";
1376
+ const { outputs: adapterOutputs, blocks: adapterBlocks, summary: harnessSummary, } = runHarnessAdapters({
1377
+ root,
1378
+ entries,
1379
+ harnesses,
1380
+ prevManifest,
1381
+ sourceLayout,
1382
+ namespaces,
1383
+ version: engineVer,
1384
+ workspaceModule: config.workspace_module ?? "",
1385
+ extensions,
1386
+ kinds: contributed.map(k => k.kind),
1387
+ contributions,
1388
+ });
1389
+ // the root harness files are build output: gitignored, so a bare clone gets them from `compile`
1390
+ {
1391
+ const added = ensureGitignored(root, [...new Set(adapterBlocks)].filter(f => !f.includes("/")));
1392
+ if (added.length)
1393
+ console.log(`✔ .gitignore now ignores ${added.join(", ")} — generated by compile; \`git rm --cached\` them once if they were tracked`);
1394
+ }
1395
+ const manifest = {
1396
+ compiled: new Date().toISOString(),
1397
+ host: engineId(),
1398
+ // ⚠ THE VERSION AS A PLAIN SEMVER, beside `host`, for a consumer that has to COMPARE it.
1399
+ //
1400
+ // The VS Code extension pins a HARD MINIMUM engine version and refuses to load below it with
1401
+ // a clear message — a version check rather than a capability handshake, because a handshake
1402
+ // answers "can you do X" one capability at a time and the failure it has to prevent is
1403
+ // structural: an extension built against this wave's exports calling into a 0.17 engine
1404
+ // throws out of `activate()` before the tree view exists, which VS Code renders as its
1405
+ // `viewsWelcome` text — the symptom naming the one thing that is definitely fine.
1406
+ //
1407
+ // `host` cannot serve: it is `name@version` and needs parsing, and a consumer that parses a
1408
+ // display string is a consumer that breaks when the display changes. The other two pin
1409
+ // surfaces are `engineVersion()` (in-process) and `dt --version` (a subprocess).
1410
+ engine: engineVer,
1411
+ // The declared namespace list, carried across the boundary so the RECORD layer can split a
1412
+ // reference without importing the compiler or re-reading package.json — the same reason
1413
+ // `storage.base` is a field instead of a path test. An older runtime has no key here, which
1414
+ // reads as "no namespaces", which is exactly right for a workspace that never declared any.
1415
+ namespaces,
1416
+ // What the record layer needs to judge an exports manifest (cr-dt-004) without reading package.json:
1417
+ // this workspace's package name, and per layer its package name, data folder, the folders read from
1418
+ // it and whether `records:` narrows it — completeness itself is judged at run time, on the disk.
1419
+ package: pkg.name ?? null,
1420
+ data_path: config.data_path ?? "data",
1421
+ layers: layers.map(l => ({
1422
+ name: l.name,
1423
+ root: l.root,
1424
+ data: path.posix.join(l.root, l.dataPath),
1425
+ package: pkgNameAt(path.join(root, l.root)),
1426
+ reads: layerReads.get(l.name) ?? [],
1427
+ narrowed: !!l.records || !!l.skipsSome,
1428
+ })),
1429
+ // The extensions this runtime was compiled WITH, and the source kinds they staged — so the next
1430
+ // compile can prune a kind whose extension is gone, and `staleness` can walk a contributed kind
1431
+ // without loading any extension code.
1432
+ ...(extensions.length ? { extensions: extensions.map(e => ({ name: e.name, version: e.version })) } : {}),
1433
+ ...(contributed.length
1434
+ ? { "source-kinds": contributed.map(k => ({ kind: k.kind, exclude: k.exclude, extension: k.extension })) }
1435
+ : {}),
1436
+ // ⚠ BOTH KEYS FOR ONE RELEASE. `location` is the new spelling; `channel` stays so a reader
1437
+ // that has not moved — `runtime.sourceRoots`'s npm filter, and the extension — keeps working
1438
+ // against a runtime this engine compiled. Removed in 0.20.0.
1439
+ modules: sources.map(s => ({
1440
+ name: s.name,
1441
+ location: locationOf(s, root),
1442
+ channel: s.channel,
1443
+ root: rel(s.root) || ".",
1444
+ })),
1445
+ ui: uiModules.sort(),
1446
+ // modules refused for their engine floor — staleness does not report their files as new
1447
+ ...(refused.size ? { refused: [...refused].map(([name, engine]) => ({ name, engine })) } : {}),
1448
+ // overlays of a peer nobody installed: compiled into nothing, still sources — staleness knows them
1449
+ ...(inertSources.length ? { inert: inertSources } : {}),
1450
+ "adapter-outputs": adapterOutputs.sort(),
1451
+ // the root files whose managed BLOCK this compile rewrote — never pruned
1452
+ "adapter-blocks": adapterBlocks.sort(),
1453
+ entries: Object.fromEntries([...entries].map(([rt, e]) => [rt, { sources: e.sources, hash: sha256(e.bytes) }]) // sources: [{path, hash}] — per-SOURCE hashes power staleness
1454
+ ),
1455
+ };
1456
+ fs.writeFileSync(path.join(RUNTIME, "manifest.yaml"), dump(manifest));
1457
+ const summary = kinds
1458
+ .filter(k => counts[k])
1459
+ .map(k => `${counts[k]} ${k}${k === "collections" && mergedCount ? ` (${mergedCount} merged)` : ""}`)
1460
+ .join(", ");
1461
+ const sourceLabel = config.workspace_module
1462
+ ? `${sources.length} module(s) (workspace_module: ${config.workspace_module})`
1463
+ : `${sources.length - 1} module(s) + workspace`;
1464
+ console.log(`✔ compiled ${summary || "nothing"} from ${sourceLabel} → .dreamteamer`);
1465
+ for (const line of harnessSummary)
1466
+ console.log(`✔ harness ${line}`);
1467
+ for (const n of notes)
1468
+ console.log(n);
1469
+ return 0;
1470
+ }
1471
+ /**
1472
+ * What the PREVIOUS compile resolved, for the one message that needs to know a namespace has just
1473
+ * disappeared rather than never existing. Read off the runtime on disk, which at this point in
1474
+ * compile is still the old one.
1475
+ */
1476
+ function prevManifestNamespaces(root) {
1477
+ return normalizeNamespaces(readManifest(root)?.namespaces);
1478
+ }
1479
+ /**
1480
+ * A `storage.under` that is REMOVED or CHANGED while records still sit under the old declaration is
1481
+ * refused. The compiled descriptor is the only thing that knows where those records are: the moment it
1482
+ * is rewritten, listing, check and relocate all read the new layout and the old child folders fall out
1483
+ * of every walk. So the runtime about to be replaced is read first, and a transition with records in
1484
+ * the way names the safe order: `relocate --to-root` under the OLD declaration, then compile, then
1485
+ * `relocate`. Adding `under` moves nothing out of sight and is not refused.
1486
+ */
1487
+ function refusePlacementTransitions(root, compiledColls) {
1488
+ // a runtime an older engine wrote has no `compiled` blocks to compare against; the converter carries
1489
+ // placement over unchanged, so there is no transition to refuse
1490
+ let previous;
1491
+ try {
1492
+ previous = loadCompiledDescriptors(root);
1493
+ }
1494
+ catch (e) {
1495
+ if (e.message === STALE_RUNTIME)
1496
+ return;
1497
+ throw e;
1498
+ }
1499
+ if (!previous)
1500
+ return;
1501
+ for (const [name, c] of compiledColls) {
1502
+ const prev = previous.get(name);
1503
+ const was = storageOf(prev).under;
1504
+ if (!was?.collection || !was.subfolder)
1505
+ continue;
1506
+ const parent = previous.get(was.collection);
1507
+ if (!parent)
1508
+ continue;
1509
+ const now = c.storage.under ? { ...c.storage.under, collection: c.compiled.under_collection } : null;
1510
+ const newParentPath = now ? compiledColls.get(now.collection)?.storage.path : null;
1511
+ const parentPath = storageOf(parent).path;
1512
+ const same = now && now.collection === was.collection && now.subfolder === was.subfolder && newParentPath === parentPath;
1513
+ if (same)
1514
+ continue;
1515
+ let n = 0;
1516
+ for (const r of placedRecords(prev, path.join(root, storageOf(prev).path), path.join(root, parentPath)))
1517
+ if (r.parentId !== null)
1518
+ n++;
1519
+ if (!n)
1520
+ continue;
1521
+ const what = !now
1522
+ ? "storage.under was removed"
1523
+ : now.collection !== was.collection || now.subfolder !== was.subfolder
1524
+ ? `storage.under changed (${was.subfolder} → ${now.subfolder})`
1525
+ : `${was.collection}'s storage.path changed (${parentPath} → ${newParentPath})`;
1526
+ fail(`collection "${name}": ${what}, but ${n} ${name} record(s) still sit inside ${was.collection} folders (${parentPath}/<id>/${was.subfolder}/) — compiling would stop every reader seeing them. First move them out under the CURRENT declaration: dreamteamer relocate ${name} --to-root, then compile${now ? `, then dreamteamer relocate ${name} to place them again` : ""}.`);
1527
+ }
1528
+ }
1529
+ /**
1530
+ * a bad source THROWS (review finding 8: process.exit killed --watch on the first typo
1531
+ * and made server-triggered recompiles impossible). the CLI boundary prints and exits.
1532
+ */
1533
+ export class CompileError extends Error {
1534
+ }
1535
+ const MANAGED_MARKERS = [
1536
+ ["the orientation block", BEGIN],
1537
+ ["the orientation block", END],
1538
+ ["the instructions block", INSTRUCTIONS_BEGIN],
1539
+ ["the instructions block", INSTRUCTIONS_END],
1540
+ ];
1541
+ function refuseManagedMarkers(text, srcPath) {
1542
+ const lines = text.split("\n");
1543
+ for (const [i, line] of lines.entries()) {
1544
+ for (const [which, marker] of MANAGED_MARKERS) {
1545
+ if (!line.includes(marker))
1546
+ continue;
1547
+ fail(`${srcPath}:${i + 1}: contains the managed marker ${marker}, which delimits ${which} in the harness files. This source is rendered verbatim into that block, so the quoted copy is found before the real delimiter and the block is rewritten around the wrong place. Describe the block instead of quoting its marker.`);
1548
+ }
1549
+ }
1550
+ }
1551
+ function fail(msg) {
1552
+ throw new CompileError(`compile error: ${msg}`);
1553
+ }