@mytechtoday/augment-extensions 3.1.2 → 3.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (386) hide show
  1. package/AGENTS.md +127 -0
  2. package/README.md +1050 -32
  3. package/augment-extensions/coding-standards/java/CHANGELOG.md +12 -0
  4. package/augment-extensions/coding-standards/java/README.md +54 -0
  5. package/augment-extensions/coding-standards/java/examples/SearchRequest.java +13 -0
  6. package/augment-extensions/coding-standards/java/metadata.json +36 -0
  7. package/augment-extensions/coding-standards/java/module.json +35 -0
  8. package/augment-extensions/coding-standards/java/rules/language-and-api-design.md +45 -0
  9. package/augment-extensions/coding-standards/java/rules/reliability-and-concurrency.md +43 -0
  10. package/augment-extensions/coding-standards/java/rules/testing-tooling-and-security.md +39 -0
  11. package/augment-extensions/coding-standards/q/CHANGELOG.md +16 -0
  12. package/augment-extensions/coding-standards/q/README.md +53 -0
  13. package/augment-extensions/coding-standards/q/examples/ArrayAndTupleNamingConventions.qs +27 -0
  14. package/augment-extensions/coding-standards/q/examples/CallableAliasNamingConventions.qs +20 -0
  15. package/augment-extensions/coding-standards/q/examples/CircuitCompositionNamingConventions.qs +24 -0
  16. package/augment-extensions/coding-standards/q/examples/ConstantValueNamingConventions.qs +19 -0
  17. package/augment-extensions/coding-standards/q/examples/EntryPointAttributeNamingConventions.qs +17 -0
  18. package/augment-extensions/coding-standards/q/examples/FunctorApplicationInControlledCircuits.qs +84 -0
  19. package/augment-extensions/coding-standards/q/examples/FunctorSpecializationNamingConventions.qs +29 -0
  20. package/augment-extensions/coding-standards/q/examples/GenericTypeParameterNamingConventions.qs +20 -0
  21. package/augment-extensions/coding-standards/q/examples/HamiltonianOperatorNamingConventions.qs +24 -0
  22. package/augment-extensions/coding-standards/q/examples/MeasurementResultNamingConventions.qs +48 -0
  23. package/augment-extensions/coding-standards/q/examples/NamespaceNamingConventions.qs +30 -0
  24. package/augment-extensions/coding-standards/q/examples/OperationAndFunctionNamingConventions.qs +31 -0
  25. package/augment-extensions/coding-standards/q/examples/OracleCallableNamingConventions.qs +41 -0
  26. package/augment-extensions/coding-standards/q/examples/PauliBasisNamingConventions.qs +42 -0
  27. package/augment-extensions/coding-standards/q/examples/PauliOperatorNamingConventions.qs +24 -0
  28. package/augment-extensions/coding-standards/q/examples/QubitManagementAndTeleportation.qs +94 -0
  29. package/augment-extensions/coding-standards/q/examples/QubitNamingConventions.qs +53 -0
  30. package/augment-extensions/coding-standards/q/examples/QubitRegisterNamingConventions.qs +30 -0
  31. package/augment-extensions/coding-standards/q/examples/StateVectorNamingConventions.qs +23 -0
  32. package/augment-extensions/coding-standards/q/examples/UserDefinedTypeNamingConventions.qs +22 -0
  33. package/augment-extensions/coding-standards/q/examples/VariableAndParameterNamingConventions.qs +26 -0
  34. package/augment-extensions/coding-standards/q/examples/bell-state.qs +21 -0
  35. package/augment-extensions/coding-standards/q/metadata.json +38 -0
  36. package/augment-extensions/coding-standards/q/module.json +29 -0
  37. package/augment-extensions/coding-standards/q/rules/q-error-handling.md +143 -0
  38. package/augment-extensions/coding-standards/q/rules/q-naming-conventions.md +82 -0
  39. package/augment-extensions/coding-standards/q/rules/q-performance-optimization.md +10 -0
  40. package/augment-extensions/coding-standards/q/rules/q-qubit-management.md +10 -0
  41. package/augment-extensions/coding-standards/q/rules/q-security.md +10 -0
  42. package/augment-extensions/coding-standards/q/rules/q-standards.md +127 -0
  43. package/augment-extensions/coding-standards/q/rules/q-testing.md +10 -0
  44. package/augment-extensions/coding-standards/spring/CHANGELOG.md +12 -0
  45. package/augment-extensions/coding-standards/spring/README.md +61 -0
  46. package/augment-extensions/coding-standards/spring/examples/OrderController.java +40 -0
  47. package/augment-extensions/coding-standards/spring/metadata.json +39 -0
  48. package/augment-extensions/coding-standards/spring/module.json +38 -0
  49. package/augment-extensions/coding-standards/spring/rules/beans-configuration-and-boot.md +39 -0
  50. package/augment-extensions/coding-standards/spring/rules/data-testing-and-transactions.md +36 -0
  51. package/augment-extensions/coding-standards/spring/rules/production-operations.md +40 -0
  52. package/augment-extensions/coding-standards/spring/rules/web-apis-and-security.md +43 -0
  53. package/augment-extensions/visual-design/CHANGELOG.md +2 -2
  54. package/augment-extensions/visual-design/README.md +31 -8
  55. package/augment-extensions/visual-design/VERSION +1 -0
  56. package/augment-extensions/visual-design/__tests__/README.md +32 -18
  57. package/augment-extensions/visual-design/__tests__/guidance-contract.test.ts +355 -0
  58. package/augment-extensions/visual-design/__tests__/vendor-styles.test.ts +23 -5
  59. package/augment-extensions/visual-design/domains/other/dotnet-application.ts +1 -1
  60. package/augment-extensions/visual-design/domains/other/mobile-application.ts +3 -4
  61. package/augment-extensions/visual-design/domains/other/os-application.ts +1 -1
  62. package/augment-extensions/visual-design/domains/other/windows-platform.ts +1 -1
  63. package/augment-extensions/visual-design/domains/web-page-styles/amazon-cloudscape.ts +4 -4
  64. package/augment-extensions/visual-design/domains/web-page-styles/google-modern.ts +10 -10
  65. package/augment-extensions/visual-design/domains/web-page-styles/microsoft-fluent.ts +3 -3
  66. package/augment-extensions/visual-design/examples/README.md +2 -0
  67. package/augment-extensions/visual-design/examples/basic-usage.md +5 -3
  68. package/augment-extensions/visual-design/examples/vendor-comparison.md +2 -2
  69. package/augment-extensions/visual-design/guidelines/coverage-map.md +30 -0
  70. package/augment-extensions/visual-design/guidelines/design-levels.md +211 -0
  71. package/augment-extensions/visual-design/guidelines/index.md +5 -0
  72. package/augment-extensions/visual-design/metadata.json +26 -5
  73. package/augment-extensions/visual-design/module.json +39 -6
  74. package/augment-extensions/visual-design/rules/accessibility-and-color.md +51 -0
  75. package/augment-extensions/visual-design/rules/design-practice.md +55 -0
  76. package/augment-extensions/visual-design/rules/index.md +34 -0
  77. package/augment-extensions/visual-design/rules/platform-guidance.md +47 -0
  78. package/augment-extensions/visual-design/scripts/validate-guidance.cjs +233 -0
  79. package/augment-extensions/visual-design/skills/README.md +11 -0
  80. package/augment-extensions/visual-design/skills/design-brief.md +40 -0
  81. package/augment-extensions/visual-design/skills/design-review.md +38 -0
  82. package/augment-extensions/visual-design/skills/responsive-validation/SKILL.md +94 -0
  83. package/augment-extensions/visual-design/skills/responsive-validation/scripts/responsive-sweep.cjs +457 -0
  84. package/augment-extensions/visual-design/style-selector.ts +4 -4
  85. package/augment-extensions/visual-design/types.ts +101 -46
  86. package/augment-extensions/visual-design/visual-design-core.ts +8 -8
  87. package/augment-extensions/workflows/agent-engineering/README.md +67 -0
  88. package/augment-extensions/workflows/agent-engineering/examples/contracts.cjs +89 -0
  89. package/augment-extensions/workflows/agent-engineering/examples/demo.cjs +17 -0
  90. package/augment-extensions/workflows/agent-engineering/examples/evaluation-cases.json +7 -0
  91. package/augment-extensions/workflows/agent-engineering/examples/graphs.cjs +149 -0
  92. package/augment-extensions/workflows/agent-engineering/examples/loop.cjs +125 -0
  93. package/augment-extensions/workflows/agent-engineering/examples/recovery.cjs +51 -0
  94. package/augment-extensions/workflows/agent-engineering/examples/stub.cjs +11 -0
  95. package/augment-extensions/workflows/agent-engineering/examples/verify.cjs +21 -0
  96. package/augment-extensions/workflows/agent-engineering/module.json +24 -0
  97. package/augment-extensions/workflows/agent-engineering/rules/01-adoption.md +30 -0
  98. package/augment-extensions/workflows/agent-engineering/rules/02-agents.md +34 -0
  99. package/augment-extensions/workflows/agent-engineering/rules/03-contracts.md +34 -0
  100. package/augment-extensions/workflows/agent-engineering/rules/04-loops.md +39 -0
  101. package/augment-extensions/workflows/agent-engineering/rules/05-graphs.md +39 -0
  102. package/augment-extensions/workflows/agent-engineering/rules/06-improvement.md +38 -0
  103. package/augment-extensions/workflows/agent-engineering/schemas/contracts.schema.json +1 -0
  104. package/augment-extensions/workflows/agent-engineering/scripts/validate.cjs +32 -0
  105. package/augment-extensions/workflows/agent-engineering/sources.md +12 -0
  106. package/augment-extensions/workflows/agent-engineering/templates/agent.json +40 -0
  107. package/augment-extensions/workflows/agent-engineering/templates/check-tool.json +94 -0
  108. package/augment-extensions/workflows/agent-engineering/templates/evidence.json +29 -0
  109. package/augment-extensions/workflows/agent-engineering/templates/invocation.json +40 -0
  110. package/augment-extensions/workflows/agent-engineering/templates/node.json +27 -0
  111. package/augment-extensions/workflows/agent-engineering/templates/state.json +27 -0
  112. package/augment-extensions/workflows/agent-engineering/templates/task.json +40 -0
  113. package/augment-extensions/workflows/agent-engineering/templates/tool.json +52 -0
  114. package/augment-extensions/workflows/decision-layer/README.md +136 -0
  115. package/augment-extensions/workflows/decision-layer/examples/call-inventory.json +6 -0
  116. package/augment-extensions/workflows/decision-layer/examples/config.json +9 -0
  117. package/augment-extensions/workflows/decision-layer/examples/decision.json +13 -0
  118. package/augment-extensions/workflows/decision-layer/examples/labeled-cases.json +410 -0
  119. package/augment-extensions/workflows/decision-layer/examples/source.txt +3 -0
  120. package/augment-extensions/workflows/decision-layer/examples/task.json +8 -0
  121. package/augment-extensions/workflows/decision-layer/installation/package-lock.json +27 -0
  122. package/augment-extensions/workflows/decision-layer/installation/package.json +7 -0
  123. package/augment-extensions/workflows/decision-layer/installation/sources.json +18 -0
  124. package/augment-extensions/workflows/decision-layer/module.json +24 -0
  125. package/augment-extensions/workflows/decision-layer/rules/00-index.md +5 -0
  126. package/augment-extensions/workflows/decision-layer/rules/01-responsibilities.md +15 -0
  127. package/augment-extensions/workflows/decision-layer/rules/02-operation.md +13 -0
  128. package/augment-extensions/workflows/decision-layer/runtime/cli.cjs +70 -0
  129. package/augment-extensions/workflows/decision-layer/runtime/common.cjs +85 -0
  130. package/augment-extensions/workflows/decision-layer/runtime/contracts.d.ts +8 -0
  131. package/augment-extensions/workflows/decision-layer/runtime/decisions.cjs +198 -0
  132. package/augment-extensions/workflows/decision-layer/runtime/evaluate.cjs +61 -0
  133. package/augment-extensions/workflows/decision-layer/runtime/install.cjs +186 -0
  134. package/augment-extensions/workflows/decision-layer/runtime/integrations.cjs +64 -0
  135. package/augment-extensions/workflows/decision-layer/runtime/runner.cjs +201 -0
  136. package/augment-extensions/workflows/decision-layer/runtime/worker-child.cjs +15 -0
  137. package/augment-extensions/workflows/decision-layer/runtime/workers.cjs +15 -0
  138. package/augment-extensions/workflows/decision-layer/schemas/config.schema.json +27 -0
  139. package/augment-extensions/workflows/decision-layer/scripts/validate.cjs +16 -0
  140. package/augment-extensions/workflows/decision-layer/sources.md +25 -0
  141. package/cli/MODULES.md +804 -302
  142. package/cli/dist/__test_file-tracking.d.ts +2 -0
  143. package/cli/dist/__test_file-tracking.d.ts.map +1 -0
  144. package/cli/dist/__test_file-tracking.js +4 -0
  145. package/cli/dist/__test_file-tracking.js.map +1 -0
  146. package/cli/dist/adapters/banner.d.ts +62 -0
  147. package/cli/dist/adapters/banner.d.ts.map +1 -0
  148. package/cli/dist/adapters/banner.js +105 -0
  149. package/cli/dist/adapters/banner.js.map +1 -0
  150. package/cli/dist/adapters/claude-code.d.ts +13 -0
  151. package/cli/dist/adapters/claude-code.d.ts.map +1 -0
  152. package/cli/dist/adapters/claude-code.js +79 -0
  153. package/cli/dist/adapters/claude-code.js.map +1 -0
  154. package/cli/dist/adapters/copilot.d.ts +17 -0
  155. package/cli/dist/adapters/copilot.d.ts.map +1 -0
  156. package/cli/dist/adapters/copilot.js +81 -0
  157. package/cli/dist/adapters/copilot.js.map +1 -0
  158. package/cli/dist/adapters/cursor.d.ts +16 -0
  159. package/cli/dist/adapters/cursor.d.ts.map +1 -0
  160. package/cli/dist/adapters/cursor.js +99 -0
  161. package/cli/dist/adapters/cursor.js.map +1 -0
  162. package/cli/dist/adapters/index.d.ts +25 -0
  163. package/cli/dist/adapters/index.d.ts.map +1 -0
  164. package/cli/dist/adapters/index.js +59 -0
  165. package/cli/dist/adapters/index.js.map +1 -0
  166. package/cli/dist/adapters/types.d.ts +113 -0
  167. package/cli/dist/adapters/types.d.ts.map +1 -0
  168. package/cli/dist/adapters/types.js +13 -0
  169. package/cli/dist/adapters/types.js.map +1 -0
  170. package/cli/dist/adapters/windsurf.d.ts +14 -0
  171. package/cli/dist/adapters/windsurf.d.ts.map +1 -0
  172. package/cli/dist/adapters/windsurf.js +78 -0
  173. package/cli/dist/adapters/windsurf.js.map +1 -0
  174. package/cli/dist/analysis/ast-parser.d.ts.map +1 -1
  175. package/cli/dist/analysis/ast-parser.js +25 -9
  176. package/cli/dist/analysis/ast-parser.js.map +1 -1
  177. package/cli/dist/analysis/index.d.ts +1 -0
  178. package/cli/dist/analysis/index.d.ts.map +1 -1
  179. package/cli/dist/analysis/index.js +1 -0
  180. package/cli/dist/analysis/index.js.map +1 -1
  181. package/cli/dist/analysis/pattern-analyzer.d.ts +6 -0
  182. package/cli/dist/analysis/pattern-analyzer.d.ts.map +1 -0
  183. package/cli/dist/analysis/pattern-analyzer.js +100 -0
  184. package/cli/dist/analysis/pattern-analyzer.js.map +1 -0
  185. package/cli/dist/cli.js +67 -37
  186. package/cli/dist/cli.js.map +1 -1
  187. package/cli/dist/commands/code-analysis.d.ts.map +1 -1
  188. package/cli/dist/commands/code-analysis.js +22 -2
  189. package/cli/dist/commands/code-analysis.js.map +1 -1
  190. package/cli/dist/commands/decision.d.ts +4 -0
  191. package/cli/dist/commands/decision.d.ts.map +1 -0
  192. package/cli/dist/commands/decision.js +32 -0
  193. package/cli/dist/commands/decision.js.map +1 -0
  194. package/cli/dist/commands/export.d.ts +81 -0
  195. package/cli/dist/commands/export.d.ts.map +1 -0
  196. package/cli/dist/commands/export.js +334 -0
  197. package/cli/dist/commands/export.js.map +1 -0
  198. package/cli/dist/commands/gui-decision.d.ts +6 -0
  199. package/cli/dist/commands/gui-decision.d.ts.map +1 -0
  200. package/cli/dist/commands/gui-decision.js +189 -0
  201. package/cli/dist/commands/gui-decision.js.map +1 -0
  202. package/cli/dist/commands/gui-module-manager.d.ts +14 -0
  203. package/cli/dist/commands/gui-module-manager.d.ts.map +1 -0
  204. package/cli/dist/commands/gui-module-manager.js +326 -0
  205. package/cli/dist/commands/gui-module-manager.js.map +1 -0
  206. package/cli/dist/commands/gui.d.ts +5 -9
  207. package/cli/dist/commands/gui.d.ts.map +1 -1
  208. package/cli/dist/commands/gui.js +186 -231
  209. package/cli/dist/commands/gui.js.map +1 -1
  210. package/cli/dist/commands/init.d.ts +2 -0
  211. package/cli/dist/commands/init.d.ts.map +1 -1
  212. package/cli/dist/commands/init.js +84 -3
  213. package/cli/dist/commands/init.js.map +1 -1
  214. package/cli/dist/commands/lifecycle.d.ts +14 -0
  215. package/cli/dist/commands/lifecycle.d.ts.map +1 -0
  216. package/cli/dist/commands/lifecycle.js +463 -0
  217. package/cli/dist/commands/lifecycle.js.map +1 -0
  218. package/cli/dist/commands/link.d.ts +5 -0
  219. package/cli/dist/commands/link.d.ts.map +1 -1
  220. package/cli/dist/commands/link.js +137 -29
  221. package/cli/dist/commands/link.js.map +1 -1
  222. package/cli/dist/commands/list.js +2 -2
  223. package/cli/dist/commands/list.js.map +1 -1
  224. package/cli/dist/commands/mcp.d.ts +1 -2
  225. package/cli/dist/commands/mcp.d.ts.map +1 -1
  226. package/cli/dist/commands/mcp.js +20 -20
  227. package/cli/dist/commands/mcp.js.map +1 -1
  228. package/cli/dist/commands/module-management.d.ts +9 -0
  229. package/cli/dist/commands/module-management.d.ts.map +1 -0
  230. package/cli/dist/commands/module-management.js +420 -0
  231. package/cli/dist/commands/module-management.js.map +1 -0
  232. package/cli/dist/commands/search.js +1 -11
  233. package/cli/dist/commands/search.js.map +1 -1
  234. package/cli/dist/commands/self-remove.d.ts.map +1 -1
  235. package/cli/dist/commands/self-remove.js +98 -44
  236. package/cli/dist/commands/self-remove.js.map +1 -1
  237. package/cli/dist/commands/show.d.ts +1 -1
  238. package/cli/dist/commands/show.d.ts.map +1 -1
  239. package/cli/dist/commands/show.js +21 -10
  240. package/cli/dist/commands/show.js.map +1 -1
  241. package/cli/dist/commands/showCompleted.d.ts +1 -0
  242. package/cli/dist/commands/showCompleted.d.ts.map +1 -1
  243. package/cli/dist/commands/showCompleted.js +4 -3
  244. package/cli/dist/commands/showCompleted.js.map +1 -1
  245. package/cli/dist/commands/skill.d.ts +7 -1
  246. package/cli/dist/commands/skill.d.ts.map +1 -1
  247. package/cli/dist/commands/skill.js +79 -21
  248. package/cli/dist/commands/skill.js.map +1 -1
  249. package/cli/dist/commands/unlink.d.ts +2 -0
  250. package/cli/dist/commands/unlink.d.ts.map +1 -1
  251. package/cli/dist/commands/unlink.js +86 -44
  252. package/cli/dist/commands/unlink.js.map +1 -1
  253. package/cli/dist/commands/update.d.ts.map +1 -1
  254. package/cli/dist/commands/update.js +6 -16
  255. package/cli/dist/commands/update.js.map +1 -1
  256. package/cli/dist/commands/upgrade.d.ts +2 -0
  257. package/cli/dist/commands/upgrade.d.ts.map +1 -1
  258. package/cli/dist/commands/upgrade.js +22 -5
  259. package/cli/dist/commands/upgrade.js.map +1 -1
  260. package/cli/dist/commands/use.d.ts.map +1 -1
  261. package/cli/dist/commands/use.js +2 -68
  262. package/cli/dist/commands/use.js.map +1 -1
  263. package/cli/dist/core/compatibility-checker.d.ts +37 -1
  264. package/cli/dist/core/compatibility-checker.d.ts.map +1 -1
  265. package/cli/dist/core/compatibility-checker.js +133 -12
  266. package/cli/dist/core/compatibility-checker.js.map +1 -1
  267. package/cli/dist/gui/state/navigation-state.d.ts +20 -0
  268. package/cli/dist/gui/state/navigation-state.d.ts.map +1 -0
  269. package/cli/dist/gui/state/navigation-state.js +115 -0
  270. package/cli/dist/gui/state/navigation-state.js.map +1 -0
  271. package/cli/dist/gui/state/selection-state.d.ts +21 -0
  272. package/cli/dist/gui/state/selection-state.d.ts.map +1 -0
  273. package/cli/dist/gui/state/selection-state.js +117 -0
  274. package/cli/dist/gui/state/selection-state.js.map +1 -0
  275. package/cli/dist/lib/export-runner.d.ts +76 -0
  276. package/cli/dist/lib/export-runner.d.ts.map +1 -0
  277. package/cli/dist/lib/export-runner.js +111 -0
  278. package/cli/dist/lib/export-runner.js.map +1 -0
  279. package/cli/dist/lib/mcp-detection.d.ts +40 -0
  280. package/cli/dist/lib/mcp-detection.d.ts.map +1 -0
  281. package/cli/dist/lib/mcp-detection.js +167 -0
  282. package/cli/dist/lib/mcp-detection.js.map +1 -0
  283. package/cli/dist/lib/mirror-coordination.d.ts +57 -0
  284. package/cli/dist/lib/mirror-coordination.d.ts.map +1 -0
  285. package/cli/dist/lib/mirror-coordination.js +151 -0
  286. package/cli/dist/lib/mirror-coordination.js.map +1 -0
  287. package/cli/dist/lib/mirror-runner.d.ts +123 -0
  288. package/cli/dist/lib/mirror-runner.d.ts.map +1 -0
  289. package/cli/dist/lib/mirror-runner.js +579 -0
  290. package/cli/dist/lib/mirror-runner.js.map +1 -0
  291. package/cli/dist/lib/module-resolver.d.ts +65 -0
  292. package/cli/dist/lib/module-resolver.d.ts.map +1 -0
  293. package/cli/dist/lib/module-resolver.js +211 -0
  294. package/cli/dist/lib/module-resolver.js.map +1 -0
  295. package/cli/dist/lib/source-hash.d.ts +62 -0
  296. package/cli/dist/lib/source-hash.d.ts.map +1 -0
  297. package/cli/dist/lib/source-hash.js +99 -0
  298. package/cli/dist/lib/source-hash.js.map +1 -0
  299. package/cli/dist/types/coordination-export.d.ts +33 -0
  300. package/cli/dist/types/coordination-export.d.ts.map +1 -0
  301. package/cli/dist/types/coordination-export.js +28 -0
  302. package/cli/dist/types/coordination-export.js.map +1 -0
  303. package/cli/dist/types/gui.d.ts +4 -0
  304. package/cli/dist/types/gui.d.ts.map +1 -1
  305. package/cli/dist/types/lifecycle.d.ts +81 -0
  306. package/cli/dist/types/lifecycle.d.ts.map +1 -0
  307. package/cli/dist/types/lifecycle.js +3 -0
  308. package/cli/dist/types/lifecycle.js.map +1 -0
  309. package/cli/dist/utils/beads-sync.d.ts +4 -0
  310. package/cli/dist/utils/beads-sync.d.ts.map +1 -1
  311. package/cli/dist/utils/beads-sync.js.map +1 -1
  312. package/cli/dist/utils/catalog-sync.d.ts.map +1 -1
  313. package/cli/dist/utils/catalog-sync.js +41 -8
  314. package/cli/dist/utils/catalog-sync.js.map +1 -1
  315. package/cli/dist/utils/coordination-queries.d.ts +3 -0
  316. package/cli/dist/utils/coordination-queries.d.ts.map +1 -1
  317. package/cli/dist/utils/coordination-queries.js +2 -2
  318. package/cli/dist/utils/coordination-queries.js.map +1 -1
  319. package/cli/dist/utils/decision-runner.d.ts +18 -0
  320. package/cli/dist/utils/decision-runner.d.ts.map +1 -0
  321. package/cli/dist/utils/decision-runner.js +114 -0
  322. package/cli/dist/utils/decision-runner.js.map +1 -0
  323. package/cli/dist/utils/extensions-config.d.ts +29 -0
  324. package/cli/dist/utils/extensions-config.d.ts.map +1 -0
  325. package/cli/dist/utils/extensions-config.js +151 -0
  326. package/cli/dist/utils/extensions-config.js.map +1 -0
  327. package/cli/dist/utils/extractCommandHelp.d.ts +2 -2
  328. package/cli/dist/utils/extractCommandHelp.d.ts.map +1 -1
  329. package/cli/dist/utils/extractCommandHelp.js +10 -4
  330. package/cli/dist/utils/extractCommandHelp.js.map +1 -1
  331. package/cli/dist/utils/file-tracking.d.ts +4 -0
  332. package/cli/dist/utils/file-tracking.d.ts.map +1 -1
  333. package/cli/dist/utils/file-tracking.js +5 -5
  334. package/cli/dist/utils/file-tracking.js.map +1 -1
  335. package/cli/dist/utils/glob-match.d.ts +6 -0
  336. package/cli/dist/utils/glob-match.d.ts.map +1 -0
  337. package/cli/dist/utils/glob-match.js +8 -0
  338. package/cli/dist/utils/glob-match.js.map +1 -0
  339. package/cli/dist/utils/gui-helpers.d.ts.map +1 -1
  340. package/cli/dist/utils/gui-helpers.js +7 -3
  341. package/cli/dist/utils/gui-helpers.js.map +1 -1
  342. package/cli/dist/utils/inspection-cache.d.ts +8 -0
  343. package/cli/dist/utils/inspection-cache.d.ts.map +1 -1
  344. package/cli/dist/utils/inspection-cache.js +12 -0
  345. package/cli/dist/utils/inspection-cache.js.map +1 -1
  346. package/cli/dist/utils/inspection-handlers.d.ts.map +1 -1
  347. package/cli/dist/utils/inspection-handlers.js +230 -52
  348. package/cli/dist/utils/inspection-handlers.js.map +1 -1
  349. package/cli/dist/utils/install-rules.d.ts +15 -0
  350. package/cli/dist/utils/install-rules.d.ts.map +1 -1
  351. package/cli/dist/utils/install-rules.js +247 -0
  352. package/cli/dist/utils/install-rules.js.map +1 -1
  353. package/cli/dist/utils/interactive-prompt.d.ts +7 -0
  354. package/cli/dist/utils/interactive-prompt.d.ts.map +1 -0
  355. package/cli/dist/utils/interactive-prompt.js +41 -0
  356. package/cli/dist/utils/interactive-prompt.js.map +1 -0
  357. package/cli/dist/utils/lifecycle.d.ts +47 -0
  358. package/cli/dist/utils/lifecycle.d.ts.map +1 -0
  359. package/cli/dist/utils/lifecycle.js +841 -0
  360. package/cli/dist/utils/lifecycle.js.map +1 -0
  361. package/cli/dist/utils/mcp-integration.d.ts +24 -3
  362. package/cli/dist/utils/mcp-integration.d.ts.map +1 -1
  363. package/cli/dist/utils/mcp-integration.js +364 -151
  364. package/cli/dist/utils/mcp-integration.js.map +1 -1
  365. package/cli/dist/utils/module-system.d.ts +7 -0
  366. package/cli/dist/utils/module-system.d.ts.map +1 -1
  367. package/cli/dist/utils/module-system.js +137 -42
  368. package/cli/dist/utils/module-system.js.map +1 -1
  369. package/cli/dist/utils/modules-catalog.d.ts.map +1 -1
  370. package/cli/dist/utils/modules-catalog.js +5 -0
  371. package/cli/dist/utils/modules-catalog.js.map +1 -1
  372. package/cli/dist/utils/openspec-sync.d.ts +4 -0
  373. package/cli/dist/utils/openspec-sync.d.ts.map +1 -1
  374. package/cli/dist/utils/openspec-sync.js.map +1 -1
  375. package/cli/dist/utils/plugin-system.js +1 -1
  376. package/cli/dist/utils/plugin-system.js.map +1 -1
  377. package/cli/dist/utils/skill-system.d.ts +11 -0
  378. package/cli/dist/utils/skill-system.d.ts.map +1 -1
  379. package/cli/dist/utils/skill-system.js +101 -3
  380. package/cli/dist/utils/skill-system.js.map +1 -1
  381. package/cli/dist/utils/zip-archive.d.ts +25 -0
  382. package/cli/dist/utils/zip-archive.d.ts.map +1 -0
  383. package/cli/dist/utils/zip-archive.js +287 -0
  384. package/cli/dist/utils/zip-archive.js.map +1 -0
  385. package/modules.md +89 -6
  386. package/package.json +150 -135
@@ -44,17 +44,23 @@ export interface ColorPalette {
44
44
  primary: ColorDefinition;
45
45
  secondary?: ColorDefinition;
46
46
  accent?: ColorDefinition;
47
- neutral: ColorDefinition[];
48
- semantic: SemanticColors;
49
- accessibility: AccessibilityRequirements;
47
+ tertiary?: ColorDefinition;
48
+ error?: ColorDefinition;
49
+ neutral: ColorDefinition | ColorDefinition[];
50
+ neutralVariant?: ColorDefinition;
51
+ semantic?: SemanticColors;
52
+ accessibility?: AccessibilityRequirements;
50
53
  }
51
54
 
52
55
  export interface ColorDefinition {
53
56
  name: string;
54
57
  hex: string;
55
- rgb: RGB;
56
- hsl: HSL;
58
+ rgb: RGB | string;
59
+ hsl?: HSL;
60
+ usage?: string;
61
+ accessibility?: string;
57
62
  variants?: ColorVariant[];
63
+ tones?: Record<string, string> | Record<number, string>;
58
64
  }
59
65
 
60
66
  export interface RGB {
@@ -75,17 +81,30 @@ export interface ColorVariant {
75
81
  usage: string;
76
82
  }
77
83
 
84
+ export interface SemanticColorDefinition {
85
+ hex: string;
86
+ usage?: string;
87
+ }
88
+
89
+ export type SemanticColorValue = string | SemanticColorDefinition;
90
+
78
91
  export interface SemanticColors {
79
- success: string;
80
- warning: string;
81
- error: string;
82
- info: string;
92
+ success: SemanticColorValue;
93
+ warning: SemanticColorValue;
94
+ error: SemanticColorValue;
95
+ info: SemanticColorValue;
83
96
  }
84
97
 
85
98
  export interface AccessibilityRequirements {
86
- minContrastRatio: number;
87
- wcagLevel: 'A' | 'AA' | 'AAA';
99
+ /** Legacy intent metadata. Measure rendered color pairs before making a conformance claim. */
100
+ minContrastRatio?: number;
101
+ minimumContrast?: number;
102
+ targetContrast?: number;
103
+ /** A declared review target, not evidence that the full product meets this level. */
104
+ wcagLevel?: 'A' | 'AA' | 'AAA';
105
+ /** Palette metadata only. Test actual themes and states for the target users. */
88
106
  colorBlindSafe: boolean;
107
+ guidelines?: string[];
89
108
  }
90
109
 
91
110
  // ============================================================================
@@ -93,11 +112,13 @@ export interface AccessibilityRequirements {
93
112
  // ============================================================================
94
113
 
95
114
  export interface TypographyRules {
96
- fontFamilies: FontFamily[];
97
- typeScale: TypeScale;
98
- hierarchy: TypographyHierarchy;
99
- lineHeight: LineHeightRules;
100
- letterSpacing: LetterSpacingRules;
115
+ fontFamilies: FontFamilies;
116
+ typeScale?: TypeScale;
117
+ hierarchy?: TypographyHierarchy;
118
+ lineHeight?: LineHeightRules;
119
+ letterSpacing?: LetterSpacingRules;
120
+ scale?: ScaleSystem;
121
+ guidelines?: string[];
101
122
  }
102
123
 
103
124
  export interface FontFamily {
@@ -108,12 +129,46 @@ export interface FontFamily {
108
129
  usage: string;
109
130
  }
110
131
 
111
- export interface TypeScale {
132
+ export interface FontFamilySet {
133
+ primary: string;
134
+ secondary: string;
135
+ monospace: string;
136
+ }
137
+
138
+ export type FontFamilies = FontFamily[] | FontFamilySet;
139
+
140
+ export interface NamedTypeScale {
141
+ displayLarge: TypographyStyle;
142
+ displayMedium: TypographyStyle;
143
+ displaySmall: TypographyStyle;
144
+ headlineLarge: TypographyStyle;
145
+ headlineMedium: TypographyStyle;
146
+ headlineSmall: TypographyStyle;
147
+ titleLarge: TypographyStyle;
148
+ titleMedium: TypographyStyle;
149
+ titleSmall: TypographyStyle;
150
+ bodyLarge: TypographyStyle;
151
+ bodyMedium: TypographyStyle;
152
+ bodySmall: TypographyStyle;
153
+ labelLarge: TypographyStyle;
154
+ labelMedium: TypographyStyle;
155
+ labelSmall: TypographyStyle;
156
+ }
157
+
158
+ export interface NumericTypeScale {
112
159
  base: number;
113
160
  ratio: number;
114
161
  sizes: Record<string, number>;
115
162
  }
116
163
 
164
+ export type TypeScale = NamedTypeScale | NumericTypeScale;
165
+
166
+ export interface ScaleSystem {
167
+ base: number;
168
+ ratio: number;
169
+ sizes: number[];
170
+ }
171
+
117
172
  export interface TypographyHierarchy {
118
173
  h1: TypographyStyle;
119
174
  h2: TypographyStyle;
@@ -122,15 +177,17 @@ export interface TypographyHierarchy {
122
177
  h5: TypographyStyle;
123
178
  h6: TypographyStyle;
124
179
  body: TypographyStyle;
125
- caption: TypographyStyle;
180
+ caption?: TypographyStyle;
181
+ small?: TypographyStyle;
126
182
  }
127
183
 
128
184
  export interface TypographyStyle {
129
185
  fontSize: string;
130
186
  fontWeight: number;
131
- lineHeight: number;
187
+ lineHeight: number | string;
132
188
  letterSpacing?: string;
133
189
  textTransform?: 'none' | 'uppercase' | 'lowercase' | 'capitalize';
190
+ usage?: string;
134
191
  }
135
192
 
136
193
  export interface LineHeightRules {
@@ -152,8 +209,10 @@ export interface LetterSpacingRules {
152
209
  export interface LayoutSystem {
153
210
  grid: GridSystem;
154
211
  spacing: SpacingSystem;
155
- breakpoints: Breakpoints;
156
- containers: ContainerRules;
212
+ breakpoints?: Breakpoints;
213
+ containers?: ContainerRules;
214
+ containerWidths?: Record<string, string>;
215
+ guidelines?: string[];
157
216
  }
158
217
 
159
218
  export interface GridSystem {
@@ -161,21 +220,19 @@ export interface GridSystem {
161
220
  gutter: string;
162
221
  margin: string;
163
222
  maxWidth?: string;
223
+ breakpoints?: Breakpoints;
164
224
  }
165
225
 
166
226
  export interface SpacingSystem {
167
- base: number;
227
+ base?: number;
228
+ unit?: number;
168
229
  scale: number[];
169
- tokens: Record<string, string>;
230
+ tokens?: Record<string, string>;
231
+ guidelines?: string[];
170
232
  }
171
233
 
172
234
  export interface Breakpoints {
173
- xs: string;
174
- sm: string;
175
- md: string;
176
- lg: string;
177
- xl: string;
178
- xxl?: string;
235
+ [breakpoint: string]: string;
179
236
  }
180
237
 
181
238
  export interface ContainerRules {
@@ -190,22 +247,19 @@ export interface ContainerRules {
190
247
  export interface MotionSystem {
191
248
  durations: DurationTokens;
192
249
  easings: EasingTokens;
193
- animations: AnimationPreset[];
250
+ animations?: AnimationPreset[];
251
+ patterns?: Record<string, MotionPattern>;
252
+ guidelines?: string[];
194
253
  }
195
254
 
196
- export interface DurationTokens {
197
- instant: string;
198
- fast: string;
199
- normal: string;
200
- slow: string;
201
- }
255
+ export type DurationTokens = Record<string, string>;
256
+
257
+ export type EasingTokens = Record<string, string>;
202
258
 
203
- export interface EasingTokens {
204
- linear: string;
205
- easeIn: string;
206
- easeOut: string;
207
- easeInOut: string;
208
- spring?: string;
259
+ export interface MotionPattern {
260
+ duration: string;
261
+ easing: string;
262
+ properties: string[];
209
263
  }
210
264
 
211
265
  export interface AnimationPreset {
@@ -220,12 +274,13 @@ export interface AnimationPreset {
220
274
  // ============================================================================
221
275
 
222
276
  export interface ElevationSystem {
223
- levels: ElevationLevel[];
224
- shadows: ShadowTokens;
277
+ levels: ElevationLevel[] | Record<string, ElevationLevel>;
278
+ shadows?: ShadowTokens;
279
+ guidelines?: string[];
225
280
  }
226
281
 
227
282
  export interface ElevationLevel {
228
- level: number;
283
+ level?: number;
229
284
  shadow: string;
230
285
  usage: string;
231
286
  }
@@ -290,7 +345,7 @@ export interface DomainStyle {
290
345
  export interface StyleSelector {
291
346
  vendorPriority: string[];
292
347
  fallbackChain: string[];
293
- selectStyle(preferences?: StylePreferences): VendorStyle | DomainStyle;
348
+ selectStyle(preferences?: StylePreferences): VendorStyle;
294
349
  }
295
350
 
296
351
  export interface StylePreferences {
@@ -24,7 +24,7 @@ export const DESIGN_ELEMENTS: DesignElement[] = [
24
24
  aspects: [
25
25
  'Color theory (primary, secondary, tertiary)',
26
26
  'Color harmony (complementary, analogous, triadic)',
27
- 'Contrast ratios (WCAG AA: 4.5:1 for text, AAA: 7:1)',
27
+ 'Text contrast thresholds by text size and conformance target',
28
28
  'Color psychology and emotional impact',
29
29
  'Accessibility (color blindness, high contrast modes)',
30
30
  'Brand color consistency'
@@ -170,7 +170,7 @@ export const DESIGN_PRINCIPLES: DesignPrinciple[] = [
170
170
  'Size contrast: Large vs small elements',
171
171
  'Shape contrast: Geometric vs organic forms',
172
172
  'Texture contrast: Smooth vs rough surfaces',
173
- 'Ensure sufficient contrast for accessibility (WCAG AA: 4.5:1)',
173
+ 'Check text and non-text contrast against the applicable criteria',
174
174
  'Use contrast to guide attention and create focal points'
175
175
  ]
176
176
  },
@@ -243,7 +243,7 @@ export const DESIGN_PRINCIPLES: DesignPrinciple[] = [
243
243
  'Use white space to create visual hierarchy',
244
244
  'Increase white space for premium/luxury feel',
245
245
  'Reduce clutter by embracing emptiness',
246
- 'White space is not wasted space—it enhances comprehension'
246
+ 'White space is not wasted space; it enhances comprehension'
247
247
  ]
248
248
  },
249
249
  {
@@ -262,13 +262,13 @@ export const DESIGN_PRINCIPLES: DesignPrinciple[] = [
262
262
  name: 'Accessibility',
263
263
  description: 'Designing for all users, including those with disabilities',
264
264
  guidelines: [
265
- 'WCAG 2.1 Level AA compliance minimum',
266
- 'Color contrast ratios: 4.5:1 for text, 3:1 for UI components',
265
+ 'Use the product and applicable accessibility conformance target; review current criteria',
266
+ 'Check text and non-text contrast using the applicable size, state, and exception rules',
267
267
  'Keyboard navigation support (tab order, focus states)',
268
268
  'Screen reader compatibility (semantic HTML, ARIA labels)',
269
269
  'Responsive text sizing (rem units, no fixed px)',
270
270
  'Support for reduced motion preferences',
271
- 'Touch targets minimum 44x44px (iOS) or 48x48px (Android)'
271
+ 'Distinguish platform-recommended touch targets from WCAG CSS-pixel target-size criteria'
272
272
  ]
273
273
  },
274
274
  {
@@ -276,7 +276,7 @@ export const DESIGN_PRINCIPLES: DesignPrinciple[] = [
276
276
  description: 'Adapting design to different screen sizes and devices',
277
277
  guidelines: [
278
278
  'Mobile-first approach (design for smallest screen first)',
279
- 'Breakpoints: 320px (mobile), 768px (tablet), 1024px (desktop), 1440px (large)',
279
+ 'Choose breakpoints where content or interaction needs a different arrangement',
280
280
  'Fluid typography (clamp, vw units)',
281
281
  'Flexible layouts (CSS Grid, Flexbox)',
282
282
  'Responsive images (srcset, picture element)',
@@ -332,7 +332,7 @@ export const SKILL_CATEGORIES: SkillCategory[] = [
332
332
  'User flows and journey mapping',
333
333
  'Wireframing and prototyping',
334
334
  'Usability testing',
335
- 'Accessibility design (WCAG compliance)',
335
+ 'Accessibility design against the product target',
336
336
  'Interaction design patterns',
337
337
  'Content strategy',
338
338
  'Error prevention and recovery',
@@ -0,0 +1,67 @@
1
+ # Agent Engineering
2
+
3
+ ## Overview
4
+
5
+ Reusable guidance for creating agents and designing the harness, loop, and graph around them. Start with one task and a check that can reject a bad result. Add machinery only for an observed need. This module supplies static rules and local executable fixtures, not an orchestration service.
6
+
7
+ ## Contents
8
+
9
+ - [Responsibilities and adoption](rules/01-adoption.md)
10
+ - [Agent roles, delegation, and ownership](rules/02-agents.md)
11
+ - [Contracts, evidence, and trust](rules/03-contracts.md)
12
+ - [Bounded loops and recovery](rules/04-loops.md)
13
+ - [Graphs and durable state](rules/05-graphs.md)
14
+ - [Controlled improvement and evaluation](rules/06-improvement.md)
15
+ - [Source review and attribution](sources.md)
16
+ - [Machine-readable schemas](schemas/contracts.schema.json)
17
+ - [Agent](templates/agent.json), [invocation](templates/invocation.json), [task](templates/task.json), [tool](templates/tool.json), [checker tool](templates/check-tool.json), [node](templates/node.json), [evidence](templates/evidence.json), and [state](templates/state.json) templates
18
+ - [Loop controller](examples/loop.cjs), [graph examples](examples/graphs.cjs), [recovery and replay](examples/recovery.cjs), [saved cases](examples/evaluation-cases.json)
19
+ - [Executable demo](examples/demo.cjs) and [module validator](scripts/validate.cjs)
20
+
21
+ ## Installation
22
+
23
+ ```bash
24
+ augx link workflows/agent-engineering
25
+ augx show workflows/agent-engineering rules/01-adoption.md
26
+ ```
27
+
28
+ Linking loads static guidance. It does not execute examples or change permissions. Use the CLI from a checkout or installed package that contains this module. Existing installed releases will not discover unpublished source changes.
29
+
30
+ ## Usage
31
+
32
+ From this module directory, with Node.js and the package's existing Ajv dependency installed:
33
+
34
+ ```bash
35
+ node scripts/validate.cjs
36
+ node examples/demo.cjs loop repair ./local-repair
37
+ node examples/demo.cjs loop exhaust ./local-exhaust
38
+ node examples/demo.cjs loop stall ./local-stall
39
+ node examples/demo.cjs loop denied ./local-denied
40
+ node examples/demo.cjs loop error ./local-error
41
+ node examples/demo.cjs loop transient ./local-transient
42
+ node examples/demo.cjs loop timeout ./local-timeout
43
+ node examples/demo.cjs graph chain ./local-chain
44
+ node examples/demo.cjs graph router ./local-router
45
+ node examples/demo.cjs graph fan-out ./local-join
46
+ node examples/demo.cjs graph cycle ./local-cycle
47
+ ```
48
+
49
+ Use a new explicitly chosen disposable directory for each scenario. Repeating a command resumes its compatible checkpoint and preserves accounting. Exit 0 means the selected fixture succeeded, 1 means a terminal non-success, and 2 means invalid input, an ownership conflict, incompatible state, or a filesystem failure requiring local inspection. Ctrl+C requests cancellation and kills a running loop subprocess. No external handoff is sent.
50
+
51
+ Example loop defaults are five total attempts, twelve subprocess calls, five seconds including downtime, 750 milliseconds per call, two rounds without improved score, and one worker. The `exhaust` CLI scenario narrows attempts to two to expose exhaustion before stall. The independent checker rejects the first `repair` candidate and accepts the repaired candidate. Check records bind the file bytes, contract, protected code, and caller-supplied revision. The revision is a fixture identity; an adapter must supply the actual repository revision and dirty-candidate digest.
52
+
53
+ The controller owns `state.json`, `receipt.json`, and `handoff.json`; the worker can only return a small candidate for the controller to write to `candidate.json`. Graph examples use `graph-state.json` and `graph-receipt.json`. All joins require every named branch. Fan-out is intentionally executed sequentially, demonstrating the same data contract without native subagents. Branch outputs survive later branch failures for inspection; failed graphs require a reviewed repair plan rather than automatic terminal-state reset.
54
+
55
+ ## Limits and Recovery
56
+
57
+ These are deterministic fixtures, not provider or production evidence. No provider token, request-price, or monetary cap is claimed: no provider is called. Actual adapters must reserve aggregate requests and tokens, reconcile measured usage including failures, and enforce spend externally where possible. Report unknown cost as unknown.
58
+
59
+ There is no OS sandbox. Fixed subprocesses receive no inherited credentials, but a same-user hostile process could alter files or race path checks. Trusted graph handlers must honor cancellation; JavaScript cannot forcibly stop an arbitrary synchronous handler. Use isolated processes or containers with enforced filesystem, network, credential, and process restrictions before executing untrusted code. Full external diagnostics must remain in a separately protected, redacted local artifact; the demo's small typed outputs are its complete diagnostics and are capped at 32 KiB.
60
+
61
+ Atomic checkpoints use a temporary file, fsync, rename, checksum, and an exclusive writer lock. A crash can consume allocation without producing output. Never refund counters automatically. Preserve corrupt checkpoints and incomplete temporary files, inspect the candidate and last durable evidence, then start a new run directory with a reviewed contract. A stale lock is not a lease: inspect its PID, confirm no writer remains, and explicitly remove only that lock after reconciliation. Do not clear locks by age. File fsync and rename are not a promise against every filesystem or power failure.
62
+
63
+ Graph handlers and runtime contracts are version-bound. The scheduler supports DAGs and bounded single-node repair cycles; multi-node cycles need a different scheduler. Callers must version closed-over handler configuration in the revision. For real external effects, use service-supported idempotency or reconcile the service state after a crash. [localEffect](examples/recovery.cjs) demonstrates duplicate-trigger and crash-window reconciliation for a local artifact only. No exactly-once guarantee is made.
64
+
65
+ ## Character Count
66
+
67
+ The loader counts UTF-8-decoded JavaScript string lengths across every module file, including this README, schema, examples, and manifest. `node scripts/validate.cjs --update-count` reconciles the self-inclusive manifest count; plain validation is read-only. Export aggregation reads `rules/`, so example state, templates, source references, and saved evaluation cases are not inserted into native rule surfaces. Keep execution directories outside the module when using it from a checkout.
@@ -0,0 +1,89 @@
1
+ 'use strict';
2
+ const fs = require('fs');
3
+ const path = require('path');
4
+ const crypto = require('crypto');
5
+ const Ajv = require('ajv');
6
+ const schema = require('../schemas/contracts.schema.json');
7
+ const ajv = new Ajv({ allErrors: true, strict: true });
8
+ ajv.addSchema(schema, 'contracts');
9
+ const validators = new Map();
10
+ const hash = value => crypto.createHash('sha256').update(typeof value === 'string' ? value : JSON.stringify(value)).digest('hex');
11
+
12
+ function validate(kind, value) {
13
+ if (!validators.has(kind)) validators.set(kind, ajv.compile({ $ref: `contracts#/definitions/${kind}` }));
14
+ const check = validators.get(kind);
15
+ if (!check(value)) throw new Error(`Invalid ${kind}: ${ajv.errorsText(check.errors)}`);
16
+ for (const name of ['inputSchema', 'outputSchema']) if (value[name]) ajv.compile(value[name]);
17
+ return value;
18
+ }
19
+
20
+ function checkSchema(schemaValue, value) {
21
+ const check = ajv.compile(schemaValue);
22
+ if (!check(value)) throw new Error('Payload does not match schema');
23
+ return value;
24
+ }
25
+
26
+ function safePath(root, relative) {
27
+ if (typeof relative !== 'string' || !/^[a-zA-Z0-9_.\/-]+$/.test(relative) || relative.includes('\\') || path.isAbsolute(relative)) throw new Error('Unsafe path');
28
+ const segments = relative.split('/');
29
+ if (segments.some(s => !s || s === '.' || s === '..' || /[. ]$/.test(s) || /^(con|prn|aux|nul|com[1-9]|lpt[1-9])(?:\.|$)/i.test(s))) throw new Error('Unsafe path');
30
+ const base = fs.realpathSync(root);
31
+ let current = base;
32
+ for (const segment of segments) {
33
+ current = path.join(current, segment);
34
+ if (fs.existsSync(current) || fs.lstatSync(path.dirname(current)).isSymbolicLink()) {
35
+ if (fs.lstatSync(current).isSymbolicLink()) throw new Error('Symlink path denied');
36
+ const rel = path.relative(base, fs.realpathSync(current));
37
+ if (rel.startsWith('..') || path.isAbsolute(rel)) throw new Error('Path escape');
38
+ }
39
+ }
40
+ return current;
41
+ }
42
+
43
+ function atomic(root, name, value) {
44
+ const destination = safePath(root, name);
45
+ const temporary = safePath(root, `${name}.${crypto.randomBytes(6).toString('hex')}.tmp`);
46
+ const fd = fs.openSync(temporary, 'wx', 0o600);
47
+ try { fs.writeFileSync(fd, JSON.stringify(value, null, 2) + '\n'); fs.fsyncSync(fd); }
48
+ finally { fs.closeSync(fd); }
49
+ fs.renameSync(temporary, destination);
50
+ }
51
+
52
+ function read(root, name) {
53
+ const file = safePath(root, name);
54
+ if (fs.statSync(file).size > 262144) throw new Error('Oversized local state');
55
+ return JSON.parse(fs.readFileSync(file, 'utf8'));
56
+ }
57
+
58
+ function validateTask(task) {
59
+ validate('task', task);
60
+ if (task.writePaths.length !== 1 || task.writePaths[0] !== 'candidate.json' || task.readPaths.some(p => p !== 'candidate.json') || task.requiredChecks.join() !== 'sorted-unique' || task.approvals.length || task.budget.maxWorkers !== 1 || task.budget.maxAttempts > 5 || task.budget.maxCalls > 12 || task.budget.wallMs > 5000 || task.budget.callMs > 750 || task.budget.stallRounds > 2) throw new Error('Reference policy denied task');
61
+ return task;
62
+ }
63
+
64
+ function writeCandidate(root, task, requested, candidate) {
65
+ validateTask(task);
66
+ if (!task.writePaths.includes(requested) || requested !== 'candidate.json') throw new Error('Write permission denied');
67
+ checkSchema({ type: 'array', maxItems: 8, items: { type: 'string', enum: ['a', 'b', 'c'] } }, candidate);
68
+ atomic(root, requested, candidate);
69
+ }
70
+
71
+ function claim(packets, task) {
72
+ validateTask(task);
73
+ const paths = new Set();
74
+ let calls = 0;
75
+ for (const packet of packets) {
76
+ validate('invocation', packet);
77
+ if (packet.task !== task.id || packet.allocation.timeoutMs > task.budget.callMs || packet.tools.some(t => !['stub', 'check'].includes(t))) throw new Error('Delegation permission denied');
78
+ calls += packet.allocation.calls;
79
+ for (const p of packet.writePaths) {
80
+ if (!task.writePaths.includes(p) || paths.has(p.toLowerCase())) throw new Error('Write ownership conflict');
81
+ paths.add(p.toLowerCase());
82
+ }
83
+ }
84
+ if (packets.length > task.budget.maxWorkers) throw new Error('Worker limit exceeded');
85
+ if (calls > task.budget.maxCalls) throw new Error('Shared allocation exceeded');
86
+ return { mode: 'sequential', owners: packets.map(p => p.owner), reservedCalls: calls };
87
+ }
88
+
89
+ module.exports = { validate, checkSchema, hash, safePath, atomic, read, validateTask, writeCandidate, claim };
@@ -0,0 +1,17 @@
1
+ 'use strict';
2
+ const path = require('path');
3
+ const { runLoop } = require('./loop.cjs');
4
+ const { exampleGraph, runGraph } = require('./graphs.cjs');
5
+ async function main() {
6
+ const [kind = 'loop', mode = 'repair', destination] = process.argv.slice(2);
7
+ if (!destination) throw new Error('Usage: node examples/demo.cjs <loop|graph> <mode|shape> <explicit-local-directory>');
8
+ const root = path.resolve(destination);
9
+ const controller = new AbortController();
10
+ process.once('SIGINT', () => controller.abort());
11
+ const baseline = require('../templates/task.json');
12
+ const task = mode === 'exhaust' ? { ...baseline, budget: { ...baseline.budget, maxAttempts: 2 } } : baseline;
13
+ const result = kind === 'loop' ? await runLoop({ root, task, mode, signal: controller.signal }) : kind === 'graph' ? await runGraph({ ...exampleGraph(mode), root, signal: controller.signal }) : (() => { throw new Error('Invalid example kind'); })();
14
+ process.stdout.write(JSON.stringify({ outcome: result.status, root, evidence: 'local-deterministic-fixture' }) + '\n');
15
+ process.exitCode = result.status === 'success' ? 0 : 1;
16
+ }
17
+ main().catch(() => { process.stderr.write('Example rejected input or checkpoint; inspect local files without overwriting them.\n'); process.exitCode = 2; });
@@ -0,0 +1,7 @@
1
+ [
2
+ { "candidate": ["a", "b", "c"], "expected": true },
3
+ { "candidate": ["c", "a", "a"], "expected": false },
4
+ { "candidate": [], "expected": false },
5
+ { "candidate": ["a", "b"], "expected": false },
6
+ { "candidate": ["a", "b", "c", "c"], "expected": false }
7
+ ]
@@ -0,0 +1,149 @@
1
+ 'use strict';
2
+ const fs = require('fs');
3
+ const { validate, checkSchema, hash, atomic, read, safePath } = require('./contracts.cjs');
4
+
5
+ function validateGraph(graph) {
6
+ validate('graph', graph);
7
+ const ids = new Set(graph.nodes.map(n => n.id));
8
+ if (ids.size !== graph.nodes.length || !ids.has(graph.entry) || !graph.terminals.length || graph.terminals.some(t => !ids.has(t))) throw new Error('Invalid node identifiers');
9
+ for (const n of graph.nodes) {
10
+ // Compile both schemas even if a router never selects this node.
11
+ const Ajv = require('ajv'); const ajv = new Ajv({ strict: true });
12
+ ajv.compile(n.inputSchema); ajv.compile(n.outputSchema);
13
+ if (n.dependencies.some(d => !ids.has(d) || d === n.id) || n.allocation.timeoutMs > 750) throw new Error('Invalid dependencies or allocation');
14
+ if (n.acceptance === 'all-required' && !n.dependencies.length) throw new Error('Join requires explicit branches');
15
+ }
16
+ const seenEdges = new Set();
17
+ for (const e of graph.edges) {
18
+ const key = [e.to, e.artifact, e.condition].join(':');
19
+ if (!ids.has(e.from) || !ids.has(e.to) || seenEdges.has(key)) throw new Error('Invalid or ambiguous edge');
20
+ seenEdges.add(key);
21
+ if (graph.terminals.includes(e.from) || (e.from === e.to && (e.condition === 'always' || graph.nodes.find(n => n.id === e.from).dependencies.length))) throw new Error('Invalid terminal or cycle edge');
22
+ }
23
+ // The reference supports DAGs plus bounded single-node repair cycles.
24
+ const active = new Set(); const complete = new Set();
25
+ const acyclic = id => {
26
+ if (active.has(id)) throw new Error('Multi-node cycles require a different scheduler');
27
+ if (complete.has(id)) return;
28
+ active.add(id);
29
+ for (const e of graph.edges) if (e.from === id && e.to !== id) acyclic(e.to);
30
+ active.delete(id); complete.add(id);
31
+ };
32
+ acyclic(graph.entry);
33
+ const visit = (start, reverse) => {
34
+ const found = new Set(); const queue = [...start];
35
+ while (queue.length) { const id = queue.shift(); if (found.has(id)) continue; found.add(id); for (const e of graph.edges) if ((reverse ? e.to : e.from) === id) queue.push(reverse ? e.from : e.to); }
36
+ return found;
37
+ };
38
+ if (visit([graph.entry], false).size !== ids.size || visit(graph.terminals, true).size !== ids.size) throw new Error('Unreachable node or terminal');
39
+ for (const n of graph.nodes) if (n.dependencies.some(d => !graph.edges.some(e => e.from === d && e.to === n.id))) throw new Error('Join dependency has no artifact edge');
40
+ for (const n of graph.nodes) if (n.id !== graph.entry && (n.inputSchema.required || []).some(key => !graph.edges.some(e => e.to === n.id && e.artifact === key))) throw new Error('Required input has no artifact edge');
41
+ return graph;
42
+ }
43
+
44
+ async function runGraph({ graph, handlers, root, revision = 'fixture-v1', input = { seed: ['c', 'a', 'a', 'b'] }, now = Date.now, signal, pauseAfter = Infinity }) {
45
+ validateGraph(graph);
46
+ if (!root || !handlers || graph.nodes.some(n => typeof handlers[n.id] !== 'function')) throw new Error('Explicit local root and trusted handlers required');
47
+ fs.mkdirSync(root, { recursive: true });
48
+ const lock = safePath(root, 'graph.lock'); const fd = fs.openSync(lock, 'wx');
49
+ try {
50
+ const policy = hash([fs.readFileSync(__filename, 'utf8'), fs.readFileSync(require.resolve('./contracts.cjs'), 'utf8'), fs.readFileSync(require.resolve('../schemas/contracts.schema.json'), 'utf8'), Object.keys(handlers).sort().map(id => [id, handlers[id].toString()])]);
51
+ const contract = hash([graph, input, revision, policy]);
52
+ let s;
53
+ if (fs.existsSync(safePath(root, 'graph-state.json'))) {
54
+ const record = read(root, 'graph-state.json'); s = validate('graphState', record.state);
55
+ if (record.checksum !== hash(s) || s.version !== 1 || s.contract !== contract || s.revision !== revision || !Number.isInteger(s.steps) || s.steps < 0 || s.steps > Math.min(12, graph.maxSteps) || s.deadline !== s.startedAt + 5000 || !['running', 'success', 'error', 'cancelled', 'exhausted'].includes(s.status)) throw new Error('Incompatible graph checkpoint');
56
+ for (const [id, output] of Object.entries(s.outputs)) {
57
+ const node = graph.nodes.find(n => n.id === id);
58
+ if (!node) throw new Error('Unknown checkpoint node');
59
+ checkSchema(node.outputSchema, output);
60
+ if (s.digests[id] !== hash(output)) throw new Error('Stale graph artifact');
61
+ }
62
+ if (s.status === 'success' && (!Object.keys(s.outputs).some(id => graph.terminals.includes(id)) || s.pending.length)) throw new Error('Incomplete graph success');
63
+ } else {
64
+ s = { version: 1, contract, revision, startedAt: now(), deadline: 0, steps: 0, visits: {}, outputs: {}, digests: {}, pending: [{ id: graph.entry, input }], status: 'running', trace: [], reason: 'dispatch' };
65
+ s.deadline = s.startedAt + 5000;
66
+ }
67
+ const persist = () => { validate('graphState', s); atomic(root, 'graph-state.json', { checksum: hash(s), state: s }); };
68
+ let rounds = 0;
69
+ while (s.status === 'running' && s.pending.length && rounds++ < pauseAfter) {
70
+ if (signal?.aborted) { s.status = 'cancelled'; s.reason = 'cancelled'; break; }
71
+ if (now() >= s.deadline || s.steps >= Math.min(12, graph.maxSteps)) { s.status = 'exhausted'; s.reason = 'shared-allocation'; break; }
72
+ const index = s.pending.findIndex(p => graph.nodes.find(n => n.id === p.id)?.dependencies.every(d => Object.hasOwnProperty.call(s.outputs, d)));
73
+ if (index < 0) { s.status = 'error'; s.reason = 'missing-required-branch'; break; }
74
+ const packet = s.pending[index];
75
+ const node = graph.nodes.find(n => n.id === packet.id);
76
+ s.visits[node.id] = (s.visits[node.id] || 0) + 1;
77
+ if (s.visits[node.id] > graph.maxVisits) { s.status = 'exhausted'; s.reason = 'bounded-cycle'; break; }
78
+ s.steps++;
79
+ persist(); // Leave packet pending until its output is durably recorded.
80
+ try {
81
+ checkSchema(node.inputSchema, packet.input);
82
+ const controller = new AbortController();
83
+ const abort = () => controller.abort(); signal?.addEventListener('abort', abort, { once: true });
84
+ let timer;
85
+ let result;
86
+ try {
87
+ result = await Promise.race([
88
+ Promise.resolve().then(() => handlers[node.id](packet.input, { signal: controller.signal, visit: s.visits[node.id] })),
89
+ new Promise((_, reject) => { timer = setTimeout(() => { controller.abort(); reject(new Error('node-timeout')); }, Math.max(1, Math.min(node.allocation.timeoutMs, s.deadline - now()))); controller.signal.addEventListener('abort', () => reject(new Error('cancelled-or-timeout')), { once: true }); })
90
+ ]);
91
+ } finally { clearTimeout(timer); signal?.removeEventListener('abort', abort); }
92
+ if (signal?.aborted) { s.status = 'cancelled'; s.reason = 'cancelled'; break; }
93
+ if (now() >= s.deadline) { s.status = 'exhausted'; s.reason = 'deadline'; break; }
94
+ if (!result || !Object.hasOwnProperty.call(result, 'value') || !['always', 'valid', 'invalid', 'left', 'right'].includes(result.route || 'always')) throw new Error('invalid-route');
95
+ checkSchema(node.outputSchema, result.value);
96
+ s.outputs[node.id] = result.value; s.digests[node.id] = hash(result.value);
97
+ s.pending.splice(index, 1);
98
+ const edges = graph.edges.filter(e => e.from === node.id && (e.condition === 'always' || e.condition === result.route));
99
+ if (!edges.length && !graph.terminals.includes(node.id)) throw new Error('route-has-no-edge');
100
+ for (const edge of edges) {
101
+ let target = s.pending.find(p => p.id === edge.to);
102
+ if (!target) { target = { id: edge.to, input: {} }; s.pending.push(target); }
103
+ target.input[edge.artifact] = result.value;
104
+ }
105
+ s.trace.push({ node: node.id, step: s.steps, contract, artifact: hash(result.value), route: result.route || 'always', elapsedMs: now() - s.startedAt, calls: s.steps, outcome: 'schema-accepted' });
106
+ persist();
107
+ } catch {
108
+ s.status = signal?.aborted ? 'cancelled' : 'error'; s.reason = node.failureRoute === 'handoff' ? 'local-handoff-required' : 'node-rejected';
109
+ }
110
+ }
111
+ if (s.status === 'running' && !s.pending.length) {
112
+ s.status = graph.terminals.some(t => Object.hasOwnProperty.call(s.outputs, t)) ? 'success' : 'error';
113
+ s.reason = s.status === 'success' ? 'selected-terminal-reached' : 'missing-terminal';
114
+ }
115
+ persist();
116
+ if (s.status !== 'running') atomic(root, 'graph-receipt.json', { outcome: s.status, changedArtifacts: ['graph-state.json'], verifiedChecks: ['Schemas and selected transitions'], unverified: ['Provider quality', 'Parallel scheduling', 'OS isolation'], remainingRisk: 'Trusted handlers must honor cancellation; use process isolation for untrusted code', nextOwner: 'controller', nextAction: s.reason, calls: s.steps });
117
+ return s;
118
+ } finally { fs.closeSync(fd); fs.unlinkSync(lock); }
119
+ }
120
+
121
+ function exampleGraph(shape) {
122
+ const list = { type: 'array', items: { type: 'string' }, maxItems: 8 };
123
+ const input = key => ({ type: 'object', additionalProperties: false, properties: { [key]: list }, required: [key] });
124
+ const node = (id, schema, dependencies = []) => ({ id, responsibility: `Produce ${id} artifact`, executor: 'code', inputSchema: schema, outputSchema: list, dependencies, acceptance: dependencies.length ? 'all-required' : 'schema', failureRoute: 'handoff', allocation: { calls: 1, timeoutMs: 100 } });
125
+ const edge = (from, to, artifact, condition = 'always') => ({ from, to, artifact, condition });
126
+ const g = { version: 1, id: shape, entry: 'start', terminals: ['done'], maxSteps: 10, maxVisits: 3, joinPolicy: 'all-required', nodes: [node('start', input('seed'))], edges: [] };
127
+ const handlers = { start: x => ({ value: x.seed }), done: x => ({ value: Object.values(x).flat() }) };
128
+ if (shape === 'chain') {
129
+ g.nodes.push(node('normalize', input('raw')), node('done', input('normalized')));
130
+ g.edges.push(edge('start', 'normalize', 'raw'), edge('normalize', 'done', 'normalized'));
131
+ handlers.normalize = x => ({ value: [...new Set(x.raw)].sort() });
132
+ } else if (shape === 'router') {
133
+ g.terminals = ['left', 'right'];
134
+ g.nodes.push(node('left', input('selected')), node('right', input('selected')));
135
+ g.edges.push(edge('start', 'left', 'selected', 'left'), edge('start', 'right', 'selected', 'right'));
136
+ handlers.start = x => ({ value: x.seed, route: x.seed.length < 5 ? 'left' : 'right' });
137
+ handlers.left = handlers.right = x => ({ value: x.selected });
138
+ } else if (shape === 'fan-out') {
139
+ g.nodes.push(node('left', input('source')), node('right', input('source')), node('done', { type: 'object', additionalProperties: false, properties: { left: list, right: list }, required: ['left', 'right'] }, ['left', 'right']));
140
+ g.edges.push(edge('start', 'left', 'source'), edge('start', 'right', 'source'), edge('left', 'done', 'left'), edge('right', 'done', 'right'));
141
+ handlers.left = x => ({ value: [...new Set(x.source)] }); handlers.right = x => ({ value: [...x.source].sort() });
142
+ } else if (shape === 'cycle') {
143
+ g.nodes.push(node('repair', input('candidate')), node('done', input('checked')));
144
+ g.edges.push(edge('start', 'repair', 'candidate'), edge('repair', 'repair', 'candidate', 'invalid'), edge('repair', 'done', 'checked', 'valid'));
145
+ handlers.repair = (x, context) => ({ value: context.visit === 1 ? x.candidate : [...new Set(x.candidate)].sort(), route: context.visit === 1 ? 'invalid' : 'valid' });
146
+ } else throw new Error('Unknown graph shape');
147
+ return { graph: validateGraph(g), handlers };
148
+ }
149
+ module.exports = { validateGraph, runGraph, exampleGraph };