self-evolving-workflow 0.0.0-stage → 0.1.4

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 (375) hide show
  1. package/LICENSE +27 -0
  2. package/README.md +195 -2
  3. package/dist/agent-memory-prompts.d.ts +13 -0
  4. package/dist/agent-memory-prompts.js +55 -0
  5. package/dist/cli.d.ts +2 -0
  6. package/dist/cli.js +6 -0
  7. package/dist/closeout.d.ts +105 -0
  8. package/dist/closeout.js +473 -0
  9. package/dist/code.d.ts +39 -0
  10. package/dist/code.js +124 -0
  11. package/dist/codex-memory.d.ts +24 -0
  12. package/dist/codex-memory.js +217 -0
  13. package/dist/common.d.ts +16 -0
  14. package/dist/common.js +52 -0
  15. package/dist/context-envelope.d.ts +59 -0
  16. package/dist/context-envelope.js +23 -0
  17. package/dist/host-adapters.d.ts +34 -0
  18. package/dist/host-adapters.js +151 -0
  19. package/dist/http.d.ts +3 -0
  20. package/dist/http.js +90 -0
  21. package/dist/index.d.ts +16 -0
  22. package/dist/index.js +13 -0
  23. package/dist/knowledge-cli.d.ts +198 -0
  24. package/dist/knowledge-cli.js +761 -0
  25. package/dist/knowledge-reads.d.ts +72 -0
  26. package/dist/knowledge-reads.js +201 -0
  27. package/dist/memory-config.d.ts +44 -0
  28. package/dist/memory-config.js +204 -0
  29. package/dist/memory-evidence.d.ts +13 -0
  30. package/dist/memory-evidence.js +40 -0
  31. package/dist/memory-history.d.ts +46 -0
  32. package/dist/memory-history.js +432 -0
  33. package/dist/memory.d.ts +96 -0
  34. package/dist/memory.js +362 -0
  35. package/dist/retrospective.d.ts +57 -0
  36. package/dist/retrospective.js +240 -0
  37. package/dist/search.d.ts +36 -0
  38. package/dist/search.js +112 -0
  39. package/dist/skill-addition.d.ts +25 -0
  40. package/dist/skill-addition.js +89 -0
  41. package/dist/skill-design.d.ts +96 -0
  42. package/dist/skill-design.js +226 -0
  43. package/dist/skill-replay.d.ts +55 -0
  44. package/dist/skill-replay.js +448 -0
  45. package/dist/skill-route.d.ts +30 -0
  46. package/dist/skill-route.js +75 -0
  47. package/dist/transcript-evidence.d.ts +3 -0
  48. package/dist/transcript-evidence.js +58 -0
  49. package/dist/upstream/chunker.d.ts +24 -0
  50. package/dist/upstream/chunker.js +96 -0
  51. package/dist/upstream/file-protocol.d.ts +45 -0
  52. package/dist/upstream/file-protocol.js +117 -0
  53. package/dist/upstream/frontmatter.d.ts +47 -0
  54. package/dist/upstream/frontmatter.js +86 -0
  55. package/dist/upstream/graph-search.d.ts +33 -0
  56. package/dist/upstream/graph-search.js +67 -0
  57. package/dist/upstream/l1-extraction.d.ts +26 -0
  58. package/dist/upstream/l1-extraction.js +405 -0
  59. package/dist/upstream/llm.d.ts +8 -0
  60. package/dist/upstream/llm.js +1 -0
  61. package/dist/upstream/merge.d.ts +50 -0
  62. package/dist/upstream/merge.js +153 -0
  63. package/dist/upstream/prompts.d.ts +53 -0
  64. package/dist/upstream/prompts.js +181 -0
  65. package/dist/upstream/search-utils.d.ts +34 -0
  66. package/dist/upstream/search-utils.js +55 -0
  67. package/dist/upstream/slug.d.ts +26 -0
  68. package/dist/upstream/slug.js +103 -0
  69. package/dist/upstream/template.d.ts +29 -0
  70. package/dist/upstream/template.js +80 -0
  71. package/dist/upstream/tokenize.d.ts +4 -0
  72. package/dist/upstream/tokenize.js +29 -0
  73. package/dist/wiki-change.d.ts +76 -0
  74. package/dist/wiki-change.js +299 -0
  75. package/dist/wiki-entry.d.ts +26 -0
  76. package/dist/wiki-entry.js +93 -0
  77. package/dist/wiki-ingest.d.ts +12 -0
  78. package/dist/wiki-ingest.js +126 -0
  79. package/dist/wiki-migration.d.ts +16 -0
  80. package/dist/wiki-migration.js +268 -0
  81. package/dist/wiki-tokens.d.ts +1 -0
  82. package/dist/wiki-tokens.js +46 -0
  83. package/dist/wiki.d.ts +103 -0
  84. package/dist/wiki.js +330 -0
  85. package/dist/workflow-cli.d.ts +2 -0
  86. package/dist/workflow-cli.js +319 -0
  87. package/dist/workflow-install.d.ts +37 -0
  88. package/dist/workflow-install.js +148 -0
  89. package/dist/workflow-knowledge.d.ts +18 -0
  90. package/dist/workflow-knowledge.js +32 -0
  91. package/dist/workflow-mcp.d.ts +2 -0
  92. package/dist/workflow-mcp.js +137 -0
  93. package/dist/workflow-names.d.ts +4 -0
  94. package/dist/workflow-names.js +31 -0
  95. package/dist/workflow-runtime.d.ts +735 -0
  96. package/dist/workflow-runtime.js +747 -0
  97. package/dist/workflow-skills.d.ts +48 -0
  98. package/dist/workflow-skills.js +141 -0
  99. package/docs/images/impeccable-skill.png +0 -0
  100. package/docs/images/workflow-overview.png +0 -0
  101. package/docs/images/workflow-skills.png +0 -0
  102. package/package.json +77 -4
  103. package/skills/ew-impeccable/LICENSE +191 -0
  104. package/skills/ew-impeccable/NOTICE.md +19 -0
  105. package/skills/ew-impeccable/SKILL.md +91 -0
  106. package/skills/ew-impeccable/UPSTREAM.md +23 -0
  107. package/skills/ew-impeccable/reference/adapt.md +314 -0
  108. package/skills/ew-impeccable/reference/adapt.native.md +60 -0
  109. package/skills/ew-impeccable/reference/android.md +46 -0
  110. package/skills/ew-impeccable/reference/animate.md +91 -0
  111. package/skills/ew-impeccable/reference/audit.md +138 -0
  112. package/skills/ew-impeccable/reference/audit.native.md +141 -0
  113. package/skills/ew-impeccable/reference/bolder.md +35 -0
  114. package/skills/ew-impeccable/reference/clarify.md +96 -0
  115. package/skills/ew-impeccable/reference/colorize.md +88 -0
  116. package/skills/ew-impeccable/reference/craft-floor.md +44 -0
  117. package/skills/ew-impeccable/reference/craft.md +5 -0
  118. package/skills/ew-impeccable/reference/critique.md +808 -0
  119. package/skills/ew-impeccable/reference/degraded/asset-producer.md +36 -0
  120. package/skills/ew-impeccable/reference/degraded/documenter.md +23 -0
  121. package/skills/ew-impeccable/reference/degraded/finish-reviewer.md +72 -0
  122. package/skills/ew-impeccable/reference/degraded/manual-edit-applier.md +91 -0
  123. package/skills/ew-impeccable/reference/delight.md +72 -0
  124. package/skills/ew-impeccable/reference/distill.md +113 -0
  125. package/skills/ew-impeccable/reference/doctor.md +56 -0
  126. package/skills/ew-impeccable/reference/document.md +418 -0
  127. package/skills/ew-impeccable/reference/extract.md +68 -0
  128. package/skills/ew-impeccable/reference/harden.md +338 -0
  129. package/skills/ew-impeccable/reference/hooks.md +113 -0
  130. package/skills/ew-impeccable/reference/init.md +133 -0
  131. package/skills/ew-impeccable/reference/ios.md +51 -0
  132. package/skills/ew-impeccable/reference/layout.md +86 -0
  133. package/skills/ew-impeccable/reference/live-setup.md +102 -0
  134. package/skills/ew-impeccable/reference/live.md +326 -0
  135. package/skills/ew-impeccable/reference/new-work.md +209 -0
  136. package/skills/ew-impeccable/reference/onboard.md +236 -0
  137. package/skills/ew-impeccable/reference/operate.md +61 -0
  138. package/skills/ew-impeccable/reference/optimize.md +260 -0
  139. package/skills/ew-impeccable/reference/overdrive.md +127 -0
  140. package/skills/ew-impeccable/reference/polish.md +105 -0
  141. package/skills/ew-impeccable/reference/quieter.md +101 -0
  142. package/skills/ew-impeccable/reference/routing.md +20 -0
  143. package/skills/ew-impeccable/reference/shape.md +59 -0
  144. package/skills/ew-impeccable/reference/typeset.md +82 -0
  145. package/skills/ew-impeccable/reference/visualize.md +46 -0
  146. package/skills/ew-impeccable/scripts/build-phase.mjs +1022 -0
  147. package/skills/ew-impeccable/scripts/command-metadata.json +94 -0
  148. package/skills/ew-impeccable/scripts/comp-diff.mjs +391 -0
  149. package/skills/ew-impeccable/scripts/comp-spec.mjs +513 -0
  150. package/skills/ew-impeccable/scripts/concept-seed.mjs +814 -0
  151. package/skills/ew-impeccable/scripts/context-signals.mjs +325 -0
  152. package/skills/ew-impeccable/scripts/context.mjs +1521 -0
  153. package/skills/ew-impeccable/scripts/critique-storage.mjs +473 -0
  154. package/skills/ew-impeccable/scripts/data/font-index-failures.json +121 -0
  155. package/skills/ew-impeccable/scripts/data/font-index.json +1 -0
  156. package/skills/ew-impeccable/scripts/detect-csp.mjs +246 -0
  157. package/skills/ew-impeccable/scripts/detect.mjs +30 -0
  158. package/skills/ew-impeccable/scripts/detector/browser/injected/index.mjs +2580 -0
  159. package/skills/ew-impeccable/scripts/detector/cli/main.mjs +498 -0
  160. package/skills/ew-impeccable/scripts/detector/design-system.mjs +1311 -0
  161. package/skills/ew-impeccable/scripts/detector/detect-antipatterns-browser.js +9486 -0
  162. package/skills/ew-impeccable/scripts/detector/detect-antipatterns.mjs +51 -0
  163. package/skills/ew-impeccable/scripts/detector/engines/browser/detect-url.mjs +434 -0
  164. package/skills/ew-impeccable/scripts/detector/engines/regex/detect-text.mjs +1439 -0
  165. package/skills/ew-impeccable/scripts/detector/engines/static-html/css-cascade.mjs +1242 -0
  166. package/skills/ew-impeccable/scripts/detector/engines/static-html/detect-html.mjs +263 -0
  167. package/skills/ew-impeccable/scripts/detector/engines/visual/screenshot-contrast.mjs +189 -0
  168. package/skills/ew-impeccable/scripts/detector/findings.mjs +23 -0
  169. package/skills/ew-impeccable/scripts/detector/node/file-system.mjs +225 -0
  170. package/skills/ew-impeccable/scripts/detector/profile/profiler.mjs +166 -0
  171. package/skills/ew-impeccable/scripts/detector/registry/antipatterns.mjs +636 -0
  172. package/skills/ew-impeccable/scripts/detector/rules/checks.mjs +5750 -0
  173. package/skills/ew-impeccable/scripts/detector/shared/color.mjs +596 -0
  174. package/skills/ew-impeccable/scripts/detector/shared/constants.mjs +127 -0
  175. package/skills/ew-impeccable/scripts/detector/shared/fonts.mjs +30 -0
  176. package/skills/ew-impeccable/scripts/detector/shared/inline-ignores.mjs +148 -0
  177. package/skills/ew-impeccable/scripts/detector/shared/page.mjs +7 -0
  178. package/skills/ew-impeccable/scripts/detector/vendor/MDN-DATA-LICENSE +116 -0
  179. package/skills/ew-impeccable/scripts/detector/vendor/THIRD_PARTY_LICENSES.md +227 -0
  180. package/skills/ew-impeccable/scripts/detector/vendor/static-html-parser.build-entry.txt +11 -0
  181. package/skills/ew-impeccable/scripts/detector/vendor/static-html-parser.bundle.mjs +9121 -0
  182. package/skills/ew-impeccable/scripts/doctor.mjs +330 -0
  183. package/skills/ew-impeccable/scripts/embed-prompt.mjs +166 -0
  184. package/skills/ew-impeccable/scripts/font-match.mjs +457 -0
  185. package/skills/ew-impeccable/scripts/generate-image.mjs +447 -0
  186. package/skills/ew-impeccable/scripts/hook-admin.mjs +829 -0
  187. package/skills/ew-impeccable/scripts/hook-before-edit.mjs +538 -0
  188. package/skills/ew-impeccable/scripts/hook-lib.mjs +2493 -0
  189. package/skills/ew-impeccable/scripts/hook.mjs +79 -0
  190. package/skills/ew-impeccable/scripts/lib/artifact-schema.mjs +93 -0
  191. package/skills/ew-impeccable/scripts/lib/composition-catalog.mjs +200 -0
  192. package/skills/ew-impeccable/scripts/lib/concept-catalog.mjs +395 -0
  193. package/skills/ew-impeccable/scripts/lib/design-parser.mjs +880 -0
  194. package/skills/ew-impeccable/scripts/lib/font-fingerprint.mjs +564 -0
  195. package/skills/ew-impeccable/scripts/lib/font-index.mjs +130 -0
  196. package/skills/ew-impeccable/scripts/lib/hero-checks.mjs +246 -0
  197. package/skills/ew-impeccable/scripts/lib/image-metrics.mjs +306 -0
  198. package/skills/ew-impeccable/scripts/lib/impeccable-config.mjs +640 -0
  199. package/skills/ew-impeccable/scripts/lib/impeccable-paths.mjs +137 -0
  200. package/skills/ew-impeccable/scripts/lib/is-generated.mjs +72 -0
  201. package/skills/ew-impeccable/scripts/lib/live-path-globs.mjs +37 -0
  202. package/skills/ew-impeccable/scripts/lib/open-system-browser.mjs +26 -0
  203. package/skills/ew-impeccable/scripts/lib/png.mjs +281 -0
  204. package/skills/ew-impeccable/scripts/lib/provider.mjs +5 -0
  205. package/skills/ew-impeccable/scripts/lib/raster.mjs +194 -0
  206. package/skills/ew-impeccable/scripts/lib/roll-selection.mjs +369 -0
  207. package/skills/ew-impeccable/scripts/lib/staleness-deep.mjs +491 -0
  208. package/skills/ew-impeccable/scripts/lib/staleness-notice.mjs +169 -0
  209. package/skills/ew-impeccable/scripts/lib/staleness.mjs +532 -0
  210. package/skills/ew-impeccable/scripts/lib/surface-briefs.mjs +149 -0
  211. package/skills/ew-impeccable/scripts/lib/target-args.mjs +42 -0
  212. package/skills/ew-impeccable/scripts/lib/target-slug.mjs +33 -0
  213. package/skills/ew-impeccable/scripts/lib/template-extensions.mjs +146 -0
  214. package/skills/ew-impeccable/scripts/live/accept-css.mjs +617 -0
  215. package/skills/ew-impeccable/scripts/live/accept-verify.mjs +60 -0
  216. package/skills/ew-impeccable/scripts/live/browser-script-parts.mjs +84 -0
  217. package/skills/ew-impeccable/scripts/live/completion.mjs +28 -0
  218. package/skills/ew-impeccable/scripts/live/event-validation.mjs +199 -0
  219. package/skills/ew-impeccable/scripts/live/frameworks/astro.mjs +47 -0
  220. package/skills/ew-impeccable/scripts/live/frameworks/detect-utils.mjs +73 -0
  221. package/skills/ew-impeccable/scripts/live/frameworks/index.mjs +143 -0
  222. package/skills/ew-impeccable/scripts/live/frameworks/journal.mjs +197 -0
  223. package/skills/ew-impeccable/scripts/live/frameworks/nextjs.mjs +49 -0
  224. package/skills/ew-impeccable/scripts/live/frameworks/nuxt.mjs +161 -0
  225. package/skills/ew-impeccable/scripts/live/frameworks/script-src.mjs +17 -0
  226. package/skills/ew-impeccable/scripts/live/frameworks/static-html.mjs +26 -0
  227. package/skills/ew-impeccable/scripts/live/frameworks/sveltekit.mjs +71 -0
  228. package/skills/ew-impeccable/scripts/live/frameworks/tag-strategy.mjs +247 -0
  229. package/skills/ew-impeccable/scripts/live/frameworks/tanstack-start.mjs +70 -0
  230. package/skills/ew-impeccable/scripts/live/frameworks/vite-generic.mjs +42 -0
  231. package/skills/ew-impeccable/scripts/live/generation-preflight.mjs +149 -0
  232. package/skills/ew-impeccable/scripts/live/insert-ui.mjs +458 -0
  233. package/skills/ew-impeccable/scripts/live/instructions.mjs +142 -0
  234. package/skills/ew-impeccable/scripts/live/manual-apply.mjs +939 -0
  235. package/skills/ew-impeccable/scripts/live/manual-edit-routes.mjs +357 -0
  236. package/skills/ew-impeccable/scripts/live/manual-edits-buffer.mjs +152 -0
  237. package/skills/ew-impeccable/scripts/live/poll-lanes.mjs +14 -0
  238. package/skills/ew-impeccable/scripts/live/project-ignores.mjs +139 -0
  239. package/skills/ew-impeccable/scripts/live/roots.mjs +508 -0
  240. package/skills/ew-impeccable/scripts/live/session-store.mjs +563 -0
  241. package/skills/ew-impeccable/scripts/live/source-lock.mjs +105 -0
  242. package/skills/ew-impeccable/scripts/live/source-search.mjs +105 -0
  243. package/skills/ew-impeccable/scripts/live/svelte-ast.mjs +969 -0
  244. package/skills/ew-impeccable/scripts/live/svelte-component.mjs +1366 -0
  245. package/skills/ew-impeccable/scripts/live/sveltekit-adapter.mjs +304 -0
  246. package/skills/ew-impeccable/scripts/live/tanstack-adapter.mjs +259 -0
  247. package/skills/ew-impeccable/scripts/live/ui-surfaces.mjs +75 -0
  248. package/skills/ew-impeccable/scripts/live/vocabulary.mjs +171 -0
  249. package/skills/ew-impeccable/scripts/live-accept.mjs +938 -0
  250. package/skills/ew-impeccable/scripts/live-browser-dom.js +167 -0
  251. package/skills/ew-impeccable/scripts/live-browser-ignores.js +242 -0
  252. package/skills/ew-impeccable/scripts/live-browser-session.js +144 -0
  253. package/skills/ew-impeccable/scripts/live-browser.js +12851 -0
  254. package/skills/ew-impeccable/scripts/live-commit-manual-edits.mjs +1200 -0
  255. package/skills/ew-impeccable/scripts/live-complete.mjs +107 -0
  256. package/skills/ew-impeccable/scripts/live-copy-edit-agent.mjs +800 -0
  257. package/skills/ew-impeccable/scripts/live-discard-manual-edits.mjs +51 -0
  258. package/skills/ew-impeccable/scripts/live-inject.mjs +463 -0
  259. package/skills/ew-impeccable/scripts/live-insert.mjs +292 -0
  260. package/skills/ew-impeccable/scripts/live-manual-edit-evidence.mjs +368 -0
  261. package/skills/ew-impeccable/scripts/live-poll.mjs +430 -0
  262. package/skills/ew-impeccable/scripts/live-resume.mjs +123 -0
  263. package/skills/ew-impeccable/scripts/live-server.mjs +1698 -0
  264. package/skills/ew-impeccable/scripts/live-status.mjs +71 -0
  265. package/skills/ew-impeccable/scripts/live-target.mjs +30 -0
  266. package/skills/ew-impeccable/scripts/live-wrap.mjs +927 -0
  267. package/skills/ew-impeccable/scripts/live.mjs +334 -0
  268. package/skills/ew-impeccable/scripts/modern-screenshot.umd.js +14 -0
  269. package/skills/ew-impeccable/scripts/palette.mjs +628 -0
  270. package/skills/ew-impeccable/scripts/pin.mjs +352 -0
  271. package/skills/ew-impeccable/scripts/serve-question.mjs +1783 -0
  272. package/skills/ew-impeccable/scripts/surface-brief.mjs +74 -0
  273. package/skills/ew-knowledge/SKILL.md +35 -0
  274. package/skills/ew-knowledge/references/closeout-protocol.md +68 -0
  275. package/skills/ew-knowledge/references/knowledge-route.md +73 -0
  276. package/skills/ew-knowledge/references/wiki-maintenance.md +27 -0
  277. package/skills/ew-odyssey/SKILL.md +106 -0
  278. package/skills/ew-odyssey/references/audit-artifacts.md +7 -0
  279. package/skills/ew-odyssey/references/odyssey-base.md +104 -0
  280. package/skills/ew-odyssey/references/odyssey-debug.md +264 -0
  281. package/skills/ew-odyssey/references/odyssey-defensive.md +351 -0
  282. package/skills/ew-odyssey/references/odyssey-improve.md +230 -0
  283. package/skills/ew-odyssey/references/odyssey-planex.md +294 -0
  284. package/skills/ew-odyssey/references/odyssey-review.md +233 -0
  285. package/skills/ew-odyssey/references/odyssey-security.md +231 -0
  286. package/skills/ew-odyssey/references/odyssey-ui.md +232 -0
  287. package/skills/ew-odyssey/references/prepare/odyssey-debug.md +102 -0
  288. package/skills/ew-odyssey/references/prepare/odyssey-defensive.md +117 -0
  289. package/skills/ew-odyssey/references/prepare/odyssey-improve.md +95 -0
  290. package/skills/ew-odyssey/references/prepare/odyssey-planex.md +105 -0
  291. package/skills/ew-odyssey/references/prepare/odyssey-review.md +105 -0
  292. package/skills/ew-odyssey/references/prepare/odyssey-security.md +91 -0
  293. package/skills/ew-odyssey/references/prepare/odyssey-ui.md +88 -0
  294. package/skills/ew-odyssey/references/runtime-adapters.md +31 -0
  295. package/skills/ew-orchestrate/SKILL.md +89 -0
  296. package/skills/ew-orchestrate/references/auto-policy.md +66 -0
  297. package/skills/ew-orchestrate/references/boundary-grill.md +51 -0
  298. package/skills/ew-orchestrate/references/companion-route.md +40 -0
  299. package/skills/ew-orchestrate/references/ew-orchestrate.md +44 -0
  300. package/skills/ew-orchestrate/references/goal.md +51 -0
  301. package/skills/ew-orchestrate/references/orchestrator-run-loop.md +33 -0
  302. package/skills/ew-orchestrate/references/planning.md +54 -0
  303. package/skills/ew-orchestrate/steps/ew-analyze/SKILL.md +70 -0
  304. package/skills/ew-orchestrate/steps/ew-analyze/references/issue-gaps-analyze.md +24 -0
  305. package/skills/ew-orchestrate/steps/ew-analyze/references/prepare.md +8 -0
  306. package/skills/ew-orchestrate/steps/ew-analyze/references/workflow.md +138 -0
  307. package/skills/ew-orchestrate/steps/ew-auto-test/SKILL.md +80 -0
  308. package/skills/ew-orchestrate/steps/ew-auto-test/references/prepare.md +23 -0
  309. package/skills/ew-orchestrate/steps/ew-auto-test/references/workflow.md +31 -0
  310. package/skills/ew-orchestrate/steps/ew-blueprint/SKILL.md +122 -0
  311. package/skills/ew-orchestrate/steps/ew-blueprint/references/prepare.md +21 -0
  312. package/skills/ew-orchestrate/steps/ew-blueprint/references/workflow.md +28 -0
  313. package/skills/ew-orchestrate/steps/ew-brainstorm/SKILL.md +49 -0
  314. package/skills/ew-orchestrate/steps/ew-companion/SKILL.md +50 -0
  315. package/skills/ew-orchestrate/steps/ew-debug/SKILL.md +85 -0
  316. package/skills/ew-orchestrate/steps/ew-debug/references/prepare.md +27 -0
  317. package/skills/ew-orchestrate/steps/ew-debug/references/workflow.md +31 -0
  318. package/skills/ew-orchestrate/steps/ew-execute/SKILL.md +74 -0
  319. package/skills/ew-orchestrate/steps/ew-execute/references/prepare.md +27 -0
  320. package/skills/ew-orchestrate/steps/ew-execute/references/workflow.md +87 -0
  321. package/skills/ew-orchestrate/steps/ew-grill/SKILL.md +62 -0
  322. package/skills/ew-orchestrate/steps/ew-grill/references/prepare.md +26 -0
  323. package/skills/ew-orchestrate/steps/ew-grill/references/workflow.md +31 -0
  324. package/skills/ew-orchestrate/steps/ew-init/SKILL.md +56 -0
  325. package/skills/ew-orchestrate/steps/ew-init/references/prepare.md +25 -0
  326. package/skills/ew-orchestrate/steps/ew-init/references/workflow.md +28 -0
  327. package/skills/ew-orchestrate/steps/ew-plan/SKILL.md +131 -0
  328. package/skills/ew-orchestrate/steps/ew-plan/references/prepare.md +8 -0
  329. package/skills/ew-orchestrate/steps/ew-plan/references/tdd.md +53 -0
  330. package/skills/ew-orchestrate/steps/ew-plan/references/workflow.md +100 -0
  331. package/skills/ew-orchestrate/steps/ew-retrospective/SKILL.md +68 -0
  332. package/skills/ew-orchestrate/steps/ew-retrospective/references/prepare.md +18 -0
  333. package/skills/ew-orchestrate/steps/ew-retrospective/references/workflow.md +34 -0
  334. package/skills/ew-orchestrate/steps/ew-review/SKILL.md +45 -0
  335. package/skills/ew-orchestrate/steps/ew-review/references/prepare.md +17 -0
  336. package/skills/ew-orchestrate/steps/ew-review/references/workflow.md +116 -0
  337. package/skills/ew-orchestrate/steps/ew-roadmap/SKILL.md +62 -0
  338. package/skills/ew-orchestrate/steps/ew-roadmap/references/prepare.md +27 -0
  339. package/skills/ew-orchestrate/steps/ew-roadmap/references/workflow.md +28 -0
  340. package/skills/ew-orchestrate/steps/ew-test/SKILL.md +99 -0
  341. package/skills/ew-orchestrate/steps/ew-test/references/prepare.md +23 -0
  342. package/skills/ew-orchestrate/steps/ew-test/references/workflow.md +23 -0
  343. package/skills/ew-orchestrate/steps/ew-verify/SKILL.md +73 -0
  344. package/skills/ew-orchestrate/steps/ew-verify/references/prepare.md +21 -0
  345. package/skills/ew-orchestrate/steps/ew-verify/references/workflow.md +29 -0
  346. package/skills/ew-skill-design/SKILL.md +30 -0
  347. package/skills/ew-skill-design/references/package-contract.md +40 -0
  348. package/skills/ew-skill-design/references/validation.md +21 -0
  349. package/skills/team-swarm/SKILL.md +68 -0
  350. package/skills/team-swarm/references/mcp-coordination.md +14 -0
  351. package/skills/team-swarm/roles/analyst/role.md +181 -0
  352. package/skills/team-swarm/roles/ant/role.md +149 -0
  353. package/skills/team-swarm/roles/coordinator/commands/converge.md +112 -0
  354. package/skills/team-swarm/roles/coordinator/commands/init-swarm.md +136 -0
  355. package/skills/team-swarm/roles/coordinator/commands/iterate.md +171 -0
  356. package/skills/team-swarm/roles/coordinator/role.md +170 -0
  357. package/skills/team-swarm/roles/scorer/role.md +150 -0
  358. package/skills/team-swarm/scripts/aco.py +646 -0
  359. package/skills/team-swarm/scripts/pheromone.py +144 -0
  360. package/skills/team-swarm/scripts/scoring.py +111 -0
  361. package/skills/team-swarm/scripts/test_aco.py +606 -0
  362. package/skills/team-swarm/specs/ant-output-schema.md +127 -0
  363. package/skills/team-swarm/specs/convergence-criteria.md +108 -0
  364. package/skills/team-swarm/specs/pheromone-schema.md +125 -0
  365. package/skills/team-swarm/specs/swarm-config-template.json +71 -0
  366. package/skills/team-swarm/specs/swarm-protocol.md +119 -0
  367. package/skills/workflow-evolve/SKILL.md +64 -0
  368. package/skills/workflow-evolve/references/agy-gate.md +27 -0
  369. package/skills/workflow-evolve/references/auto-loop.md +23 -0
  370. package/skills/workflow-evolve/references/history-review.md +15 -0
  371. package/skills/workflow-evolve/scripts/codex-memory-replay.mjs +86 -0
  372. package/skills/workflow-evolve/scripts/codex-replay.mjs +1 -0
  373. package/skills/workflow-evolve/scripts/evolve-loop.mjs +260 -0
  374. package/skills/workflow-evolve/scripts/memory-codex-mcp.mjs +124 -0
  375. package/workflows/index.json +33 -0
@@ -0,0 +1,181 @@
1
+ // From TencentDB Agent Memory 42d4cde (MIT).
2
+ /**
3
+ * prompts.ts — 摄取提示词(分析 / 系统 / 生成)。
4
+ *
5
+ * 描述角色(wiki 维护者)、页面类型与目录约定(OKF type)、FILE 块输出协议、
6
+ * wikilink 约定、去重更新策略、输出语言策略。依据本仓库 PRD/INTERFACE。
7
+ *
8
+ * 支持两种摄取流程(PRD §4.2):
9
+ * - 单阶段:源全文 + 模板 + 已有页清单 → 直接产出 FILE 块(buildGeneratePrompt)。
10
+ * - 两阶段(OQ-4):先「分析」(buildAnalysisPrompt) 产出结构化抽取计划,
11
+ * 再「生成」(buildGenerateFromAnalysisPrompt) 依据分析产出 FILE 块。
12
+ * 好处:把"抽什么"与"落盘格式"解耦,质量更稳、格式更规整。
13
+ */
14
+ import { createAgentMemoryPrompt } from "../agent-memory-prompts.js";
15
+ /** 把已有页清单格式化为列表文本(供分析/生成阶段复用)。 */
16
+ function formatExistingPages(existingPages) {
17
+ return existingPages.length > 0
18
+ ? existingPages
19
+ .map((p) => `- [${p.type}] ${p.relPath}${p.title ? ` — ${p.title}` : ""}${p.description ? `(${p.description})` : ""}`)
20
+ .join("\n")
21
+ : "(wiki is empty — this is the first source)";
22
+ }
23
+ // ─── 阶段 A:分析 ────────────────────────────────────────────
24
+ /** 分析阶段系统提示词:扮演"抽取规划者",只产出结构化分析,不写页面。 */
25
+ export function buildAnalysisSystemPrompt(template) {
26
+ return createAgentMemoryPrompt('wiki-analysis', `You are a knowledge base analyst. Your job is to read a source document and plan how to integrate it into
27
+ the existing wiki. You do NOT write final pages — you only produce a structured "extraction plan" for the
28
+ next (generation) stage.
29
+
30
+ ## Wiki Purpose
31
+ ${template.purpose}
32
+
33
+ ## Extraction Schema
34
+ ${template.schema}
35
+
36
+ ## Your Analysis Output (markdown, structured, concise)
37
+ 1. **Source Summary**: Summarize this source in 2–4 sentences.
38
+ 2. **Entities**: Concrete entities (people, products, systems, organizations, etc.) in the source. For each, give a name and a one-sentence key point.
39
+ 3. **Concepts**: Abstract concepts (theories, methods, mechanisms, etc.) in the source. For each, give a name and a one-sentence key point.
40
+ 4. **Relationship to Existing Pages**: Which entities/concepts already appear in the existing page list (update/merge rather than create new), and which are brand new.
41
+ 5. **Suggested Cross-References**: Which entity/concept pairs should be connected via [[wikilink]].
42
+
43
+ ## Granularity
44
+
45
+ Decide whether a subject deserves its own page by asking:
46
+
47
+ 1. **Independent identity** — can this subject be defined and understood on its own, without relying on its parent context?
48
+ 2. **Distinct relationships** — does it have meaningful relationships to other entities/concepts beyond just belonging to its parent?
49
+ 3. **Substantial content** — is there enough to say about it to fill more than a one-sentence stub?
50
+
51
+ → If all three are true, create a dedicated page.
52
+ → If the subject is merely a member, sub-operation, or property that has no identity outside its parent, list it as a subsection or list item within the parent's page instead.
53
+
54
+ Output only the analysis itself — no FILE blocks, no final page content. Match the source document's primary language.`).system;
55
+ }
56
+ /** 构造分析阶段用户提示词。 */
57
+ export function buildAnalysisPrompt(args) {
58
+ const { sourceName, sourceText, existingPages } = args;
59
+ return `## Source to analyze: ${sourceName}
60
+
61
+ ## Existing wiki pages (for deciding what to update vs. create)
62
+ ${formatExistingPages(existingPages)}
63
+
64
+ ## Source Document
65
+ ${sourceText}
66
+
67
+ ---
68
+ Produce the structured extraction plan following the rules above.`;
69
+ }
70
+ // ─── 系统提示词(生成阶段共用:格式契约 + 输出协议) ──────────
71
+ /** 构造系统提示词:角色、格式契约、输出协议。 */
72
+ export function buildSystemPrompt(template) {
73
+ return createAgentMemoryPrompt('wiki-generate', `You are a meticulous knowledge base (wiki) maintainer. Your job is to read source documents
74
+ provided by the user and integrate their knowledge into a persistent, cumulative markdown wiki —
75
+ extracting entities and concepts, building cross-references, and updating existing pages, rather than
76
+ simply paraphrasing the source.
77
+
78
+ ## Wiki Purpose
79
+ ${template.purpose}
80
+
81
+ ## Extraction Schema
82
+ ${template.schema}
83
+
84
+ ## Page Format (MUST be followed strictly)
85
+ Each wiki page is "YAML frontmatter + markdown body". Frontmatter is wrapped in \`---\` at the top:
86
+ - type: REQUIRED. Values: source | entity | concept | comparison | synthesis, etc. Determines the page's directory.
87
+ - title: Human-readable title.
88
+ - description: One-sentence summary (used for index and search snippets).
89
+ - sources: Array of raw source filenames this page draws from (e.g. ["redis.md"]). Must be accurate.
90
+ - tags: Optional, short cross-category labels.
91
+ - timestamp: Optional, ISO 8601 last-modified time.
92
+ - Do NOT output a \`locked\` field.
93
+
94
+ Body guidelines:
95
+ - Link between entities/concepts using [[wikilink]], e.g. [[Redis]], [[Cache]]. Use these liberally.
96
+ - **Wikilink consistency**: Inside the brackets, write only the target page's title (e.g. [[Gateway]],
97
+ [[Consistent Hashing]]). Do NOT include \`.md\` suffix, \`wiki/\` or slash paths, or filename slugs.
98
+ When referencing an existing page, use its title.
99
+ - Use structured sections where applicable: # Schema / # Examples / # Citations, lists, and tables.
100
+ - **Consistent language**: Use the same primary language as the source document throughout (title, body,
101
+ wikilinks, descriptions). Avoid mixing languages.
102
+
103
+ ## Output Protocol (FILE blocks, MUST be followed strictly)
104
+ You cannot write files directly. Wrap each page to be written in the following boundary markers:
105
+
106
+ <<<FILE path="wiki/<dir>/<slug>.md">>>
107
+ ---
108
+ type: ...
109
+ title: ...
110
+ ---
111
+
112
+ body...
113
+ <<<END>>>
114
+
115
+ Directory conventions (use plural directory names):
116
+ - source → wiki/sources/
117
+ - entity → wiki/entities/
118
+ - concept → wiki/concepts/
119
+ - comparison → wiki/comparisons/
120
+ - synthesis → wiki/synthesis/
121
+
122
+ Rules:
123
+ - A single reply may contain multiple FILE blocks.
124
+ - path must be inside wiki/. Use stable slugs for filenames (lowercase, spaces→hyphens).
125
+ - You MUST produce at least one type: source summary page.
126
+ - For notable entities/concepts in the source, produce or update corresponding entity/concept pages.
127
+ - Do NOT output any explanatory text outside of FILE blocks.`).system;
128
+ }
129
+ /** 构造生成提示词(单阶段):源全文 + 已有页清单 + 待更新页原文。 */
130
+ export function buildGeneratePrompt(args) {
131
+ const { sourceName, sourceText, existingPages, pagesToUpdate } = args;
132
+ const existingList = formatExistingPages(existingPages);
133
+ const updateSection = pagesToUpdate && pagesToUpdate.length > 0
134
+ ? `\n## Pages to Update (preserve existing facts while merging new information — output the merged full page)\n` +
135
+ pagesToUpdate
136
+ .map((p) => `### ${p.relPath}\n\`\`\`\n${p.content}\n\`\`\``)
137
+ .join("\n\n")
138
+ : "";
139
+ return `## Source to ingest: ${sourceName}
140
+
141
+ ## Existing wiki pages (for deciding what to create vs. update, to avoid duplicates)
142
+ ${existingList}
143
+ ${updateSection}
144
+
145
+ ## Source Document
146
+ ${sourceText}
147
+
148
+ ---
149
+ Read the source, follow the format and protocol in the system prompt, and output FILE blocks:
150
+ 1. MUST include one type: source summary page (path like wiki/sources/<slug>.md).
151
+ 2. For key entities/concepts in the source, produce or update corresponding entity/concept pages.
152
+ 3. If an entity already appears in the existing page list, reuse its path for merging — do NOT create a near-duplicate page.
153
+ 4. Use [[wikilink]] generously between pages.
154
+ Output ONLY FILE blocks — no extra commentary.`;
155
+ }
156
+ // ─── 阶段 B:基于分析的生成(OQ-4) ──────────────────────────
157
+ /**
158
+ * 构造"生成阶段"用户提示词(两阶段流程):以分析结果为主输入,
159
+ * 仍附源全文供查证细节。让 LLM 据此产出 FILE 块。
160
+ */
161
+ export function buildGenerateFromAnalysisPrompt(args) {
162
+ const { sourceName, sourceText, analysis, existingPages } = args;
163
+ return `## Source to ingest: ${sourceName}
164
+
165
+ ## Extraction Plan (from analysis stage — generate pages based on this)
166
+ ${analysis}
167
+
168
+ ## Existing wiki pages (reuse paths for merging — avoid duplicates)
169
+ ${formatExistingPages(existingPages)}
170
+
171
+ ## Source Document (for detail verification)
172
+ ${sourceText}
173
+
174
+ ---
175
+ Based on the Extraction Plan above, follow the format and protocol in the system prompt, and output FILE blocks:
176
+ 1. MUST include one type: source summary page (path like wiki/sources/<slug>.md).
177
+ 2. For the entities/concepts listed in the extraction plan, produce or update corresponding entity/concept pages.
178
+ 3. Items marked as "already exist" in the plan should reuse their existing paths for merging — do NOT create near-duplicates.
179
+ 4. Follow the cross-reference suggestions in the plan — use [[wikilink]] generously.
180
+ Output ONLY FILE blocks — no extra commentary.`;
181
+ }
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Search utilities — shared helpers for memory search across backends.
3
+ *
4
+ * Contains:
5
+ * - RRF (Reciprocal Rank Fusion) merge — used by SQLite hybrid search
6
+ * (eliminates the 3x duplication in auto-recall, memory-search, conversation-search)
7
+ * - FTS query building — re-exported from sqlite for convenience
8
+ */
9
+ /**
10
+ * Standard RRF constant from the original RRF paper.
11
+ * Higher k → more weight on lower-ranked items (smoother distribution).
12
+ */
13
+ export declare const RRF_K = 60;
14
+ /**
15
+ * Merge multiple ranked lists via Reciprocal Rank Fusion.
16
+ *
17
+ * Each item's RRF score = sum over all lists of 1/(k + rank + 1).
18
+ * Items appearing in multiple lists get their scores summed.
19
+ *
20
+ * @param lists Array of ranked lists. Each list must have items with an `id` field.
21
+ * @param k RRF constant (default: 60).
22
+ * @returns Merged list sorted by descending RRF score, with `rrfScore` attached.
23
+ *
24
+ * @example
25
+ * ```ts
26
+ * const merged = rrfMerge(
27
+ * [ftsResults, vecResults],
28
+ * (item) => item.record_id,
29
+ * );
30
+ * ```
31
+ */
32
+ export declare function rrfMerge<T>(lists: T[][], getId: (item: T) => string, k?: number): Array<T & {
33
+ rrfScore: number;
34
+ }>;
@@ -0,0 +1,55 @@
1
+ // From TencentDB Agent Memory 42d4cde (MIT).
2
+ /**
3
+ * Search utilities — shared helpers for memory search across backends.
4
+ *
5
+ * Contains:
6
+ * - RRF (Reciprocal Rank Fusion) merge — used by SQLite hybrid search
7
+ * (eliminates the 3x duplication in auto-recall, memory-search, conversation-search)
8
+ * - FTS query building — re-exported from sqlite for convenience
9
+ */
10
+ // ============================
11
+ // RRF (Reciprocal Rank Fusion)
12
+ // ============================
13
+ /**
14
+ * Standard RRF constant from the original RRF paper.
15
+ * Higher k → more weight on lower-ranked items (smoother distribution).
16
+ */
17
+ export const RRF_K = 60;
18
+ /**
19
+ * Merge multiple ranked lists via Reciprocal Rank Fusion.
20
+ *
21
+ * Each item's RRF score = sum over all lists of 1/(k + rank + 1).
22
+ * Items appearing in multiple lists get their scores summed.
23
+ *
24
+ * @param lists Array of ranked lists. Each list must have items with an `id` field.
25
+ * @param k RRF constant (default: 60).
26
+ * @returns Merged list sorted by descending RRF score, with `rrfScore` attached.
27
+ *
28
+ * @example
29
+ * ```ts
30
+ * const merged = rrfMerge(
31
+ * [ftsResults, vecResults],
32
+ * (item) => item.record_id,
33
+ * );
34
+ * ```
35
+ */
36
+ export function rrfMerge(lists, getId, k = RRF_K) {
37
+ const map = new Map();
38
+ for (const list of lists) {
39
+ for (let rank = 0; rank < list.length; rank++) {
40
+ const item = list[rank];
41
+ const id = getId(item);
42
+ const score = 1 / (k + rank + 1);
43
+ const existing = map.get(id);
44
+ if (existing) {
45
+ existing.rrfScore += score;
46
+ }
47
+ else {
48
+ map.set(id, { item, rrfScore: score });
49
+ }
50
+ }
51
+ }
52
+ return [...map.values()]
53
+ .sort((a, b) => b.rrfScore - a.rrfScore)
54
+ .map(({ item, rrfScore }) => ({ ...item, rrfScore }));
55
+ }
@@ -0,0 +1,26 @@
1
+ /**
2
+ * slug.ts — 实体名 → 稳定文件名 slug
3
+ *
4
+ * dedup(去重合并)的基础:同一实体名两次摄取必须产出同一 slug,
5
+ * 这样第二次摄取能命中已存在的 `wiki/<type>/<slug>.md` 走合并而非新建。
6
+ *
7
+ * 规则(PRD FR-4 / INTERFACE §2,源中英混合):
8
+ * - 英文/数字:转小写,空格与标点转连字符,去首尾/重复连字符。
9
+ * - 中文(CJK):保留汉字本身,只去空格(不转拼音、不丢弃)。
10
+ * - 混合:分别按上面规则处理后拼接(`Redis 主从` → `redis-主从`)。
11
+ */
12
+ /**
13
+ * 把实体名/标题归一化为稳定 slug。
14
+ *
15
+ * 实现策略:逐字符扫描,分成「CJK 段」与「拉丁/数字段」交替的 token,
16
+ * 段之间用连字符连接;拉丁段转小写;其余字符(空格、标点)都视作段边界。
17
+ */
18
+ export declare function slugify(input: string): string;
19
+ /** 把 type 映射到目录名;未知但合法的 type 以自身作 generic 目录,非法值归 other。 */
20
+ export declare function dirForType(type: string): string;
21
+ /**
22
+ * 计算某页的 wiki 相对路径(含 `wiki/` 前缀),用于落盘与 dedup 命中。
23
+ * @param type 页面类型(source/entity/concept/...)
24
+ * @param title 实体名/标题
25
+ */
26
+ export declare function pageRelPath(type: string, title: string): string;
@@ -0,0 +1,103 @@
1
+ // From TencentDB Agent Memory 42d4cde (MIT).
2
+ /**
3
+ * slug.ts — 实体名 → 稳定文件名 slug
4
+ *
5
+ * dedup(去重合并)的基础:同一实体名两次摄取必须产出同一 slug,
6
+ * 这样第二次摄取能命中已存在的 `wiki/<type>/<slug>.md` 走合并而非新建。
7
+ *
8
+ * 规则(PRD FR-4 / INTERFACE §2,源中英混合):
9
+ * - 英文/数字:转小写,空格与标点转连字符,去首尾/重复连字符。
10
+ * - 中文(CJK):保留汉字本身,只去空格(不转拼音、不丢弃)。
11
+ * - 混合:分别按上面规则处理后拼接(`Redis 主从` → `redis-主从`)。
12
+ */
13
+ // CJK 统一表意文字(含扩展 A)+ 常见中文标点不在此列(标点按分隔符处理)。
14
+ const CJK_RE = /[\u3400-\u4dbf\u4e00-\u9fff\uf900-\ufaff]/;
15
+ function isCjkChar(ch) {
16
+ return CJK_RE.test(ch);
17
+ }
18
+ function isAlnumChar(ch) {
19
+ return /[a-zA-Z0-9]/.test(ch);
20
+ }
21
+ /**
22
+ * 把实体名/标题归一化为稳定 slug。
23
+ *
24
+ * 实现策略:逐字符扫描,分成「CJK 段」与「拉丁/数字段」交替的 token,
25
+ * 段之间用连字符连接;拉丁段转小写;其余字符(空格、标点)都视作段边界。
26
+ */
27
+ export function slugify(input) {
28
+ const trimmed = (input ?? "").trim();
29
+ if (!trimmed)
30
+ return "";
31
+ const tokens = [];
32
+ let buf = "";
33
+ let bufKind = null;
34
+ const flush = () => {
35
+ if (buf) {
36
+ tokens.push(bufKind === "latin" ? buf.toLowerCase() : buf);
37
+ buf = "";
38
+ }
39
+ bufKind = null;
40
+ };
41
+ for (const ch of trimmed) {
42
+ if (isCjkChar(ch)) {
43
+ if (bufKind !== "cjk")
44
+ flush();
45
+ bufKind = "cjk";
46
+ buf += ch;
47
+ }
48
+ else if (isAlnumChar(ch)) {
49
+ if (bufKind !== "latin")
50
+ flush();
51
+ bufKind = "latin";
52
+ buf += ch;
53
+ }
54
+ else {
55
+ // 空格 / 标点 / 其它 → 段边界
56
+ flush();
57
+ }
58
+ }
59
+ flush();
60
+ // 用连字符拼接,去重复/首尾连字符。
61
+ return tokens.join("-").replace(/-+/g, "-").replace(/^-|-$/g, "");
62
+ }
63
+ /**
64
+ * 给定页面类型与标题,返回 wiki 内的相对路径(不含前导 `wiki/`)。
65
+ * 例如 type="entity", title="Redis Cluster" → "entities/redis-cluster.md"
66
+ *
67
+ * type → 目录的映射对齐现有 manager 的目录约定(entities/concepts/sources/...)。
68
+ */
69
+ const TYPE_DIR = {
70
+ source: "sources",
71
+ entity: "entities",
72
+ concept: "concepts",
73
+ comparison: "comparisons",
74
+ synthesis: "synthesis",
75
+ thesis: "synthesis",
76
+ methodology: "concepts",
77
+ finding: "synthesis",
78
+ };
79
+ /**
80
+ * 合法 type 的值域:type 是 OKF 分类标签,不是路径,只可能是标识符。
81
+ * 任何含 `/`、`.`(含 `..`)或其它字符的值都不是合法分类,一律归到 other 目录。
82
+ */
83
+ const SAFE_TYPE_RE = /^[a-z0-9_-]+$/;
84
+ /** 把 type 映射到目录名;未知但合法的 type 以自身作 generic 目录,非法值归 other。 */
85
+ export function dirForType(type) {
86
+ const key = (type ?? "").trim().toLowerCase();
87
+ // hasOwn 而非索引取值:避免 "__proto__"/"constructor" 命中 Object 原型链上的成员。
88
+ if (Object.hasOwn(TYPE_DIR, key))
89
+ return TYPE_DIR[key];
90
+ if (!SAFE_TYPE_RE.test(key))
91
+ return "other";
92
+ return key;
93
+ }
94
+ /**
95
+ * 计算某页的 wiki 相对路径(含 `wiki/` 前缀),用于落盘与 dedup 命中。
96
+ * @param type 页面类型(source/entity/concept/...)
97
+ * @param title 实体名/标题
98
+ */
99
+ export function pageRelPath(type, title) {
100
+ const slug = slugify(title);
101
+ const dir = dirForType(type);
102
+ return `wiki/${dir}/${slug}.md`;
103
+ }
@@ -0,0 +1,29 @@
1
+ /**
2
+ * template.ts — 读取 wiki/schema.md 与 wiki/purpose.md 作为抽取模板(FR-4b)。
3
+ *
4
+ * 这两个文件让用户/调用方自定义"这个 wiki 想抽什么、怎么组织":
5
+ * - purpose.md:声明 wiki 的目标领域与用途。
6
+ * - schema.md:声明抽取偏好(想要哪些页面类型、关注字段、命名/语言约定)。
7
+ *
8
+ * ingest 时把它们「原样拼进 system prompt」(不强制机器解析骨架,容错)。
9
+ * 为空/不存在时用领域中立的默认骨架兜底,保证开箱即用。
10
+ *
11
+ * 注意:init 已存在的默认文件(manager.initWikiProject)可能只是空壳
12
+ * (如仅 `# Wiki Schema\n\nDefine ... here.`),这类视为"无有效内容",用默认。
13
+ */
14
+ export interface WikiTemplate {
15
+ /** purpose.md 的有效正文(去 frontmatter),无则为默认。 */
16
+ purpose: string;
17
+ /** schema.md 的有效正文(去 frontmatter),无则为默认。 */
18
+ schema: string;
19
+ /** 是否使用了用户自定义内容(用于日志/调试)。 */
20
+ customized: boolean;
21
+ }
22
+ /** Default purpose — software engineering knowledge base. */
23
+ export declare const DEFAULT_PURPOSE = "This knowledge base accumulates and organizes engineering knowledge of software systems,\nincluding system architecture, module design, data flow, deployment models, permission models, etc.\nBy ingesting requirement documents, architecture designs, meeting notes, RFCs, technical decisions and other\nsource documents, it builds a structured, cross-referenced knowledge graph to help team members quickly\nunderstand the system landscape and the rationale behind design decisions.";
24
+ /** Default schema skeleton — software engineering knowledge base. */
25
+ export declare const DEFAULT_SCHEMA = "# Page types\n- entity \u2014 a concrete component or role in the system; must declare a kind field\n- concept \u2014 an abstract design idea (system architecture, module boundaries, data flow, deployment model, permission model, evaluation framework, etc.)\n- source \u2014 one summary page per ingested source document; must declare a source_type field\nOther types (comparison, synthesis, etc.) may be created as needed.\n\n# Fields / sections per type\n- entity:\n - kind: module | service | platform | external_system | user_role | other (required)\n - definition: responsibility / purpose\n - key attributes: key properties\n - relationships: relationships to other entities\n- concept:\n - definition: concept definition\n - significance: importance / role\n - related entities: associated entities\n - common topics: system architecture, module boundaries, data flow, deployment model, permission model, evaluation framework\n- source:\n - source_type: requirement | architecture | meeting | rfc | decision | other (required)\n - source document summary\n- Use OKF sections where applicable: # Schema / # Examples / # Citations\n\n# Naming & language\n- slug: lowercase, spaces\u2192hyphens\n- Output language: follow the source document \u2014 do not switch";
26
+ /**
27
+ * 加载抽取模板。存在且有实质内容则用用户的;否则用领域中立默认。
28
+ */
29
+ export declare function loadTemplate(projectPath: string): WikiTemplate;
@@ -0,0 +1,80 @@
1
+ // From TencentDB Agent Memory 42d4cde (MIT).
2
+ /**
3
+ * template.ts — 读取 wiki/schema.md 与 wiki/purpose.md 作为抽取模板(FR-4b)。
4
+ *
5
+ * 这两个文件让用户/调用方自定义"这个 wiki 想抽什么、怎么组织":
6
+ * - purpose.md:声明 wiki 的目标领域与用途。
7
+ * - schema.md:声明抽取偏好(想要哪些页面类型、关注字段、命名/语言约定)。
8
+ *
9
+ * ingest 时把它们「原样拼进 system prompt」(不强制机器解析骨架,容错)。
10
+ * 为空/不存在时用领域中立的默认骨架兜底,保证开箱即用。
11
+ *
12
+ * 注意:init 已存在的默认文件(manager.initWikiProject)可能只是空壳
13
+ * (如仅 `# Wiki Schema\n\nDefine ... here.`),这类视为"无有效内容",用默认。
14
+ */
15
+ import { readFileSync, existsSync } from "node:fs";
16
+ import { join } from "node:path";
17
+ import { parseFrontmatter } from "./frontmatter.js";
18
+ /** Default purpose — software engineering knowledge base. */
19
+ export const DEFAULT_PURPOSE = `This knowledge base accumulates and organizes engineering knowledge of software systems,
20
+ including system architecture, module design, data flow, deployment models, permission models, etc.
21
+ By ingesting requirement documents, architecture designs, meeting notes, RFCs, technical decisions and other
22
+ source documents, it builds a structured, cross-referenced knowledge graph to help team members quickly
23
+ understand the system landscape and the rationale behind design decisions.`;
24
+ /** Default schema skeleton — software engineering knowledge base. */
25
+ export const DEFAULT_SCHEMA = `# Page types
26
+ - entity — a concrete component or role in the system; must declare a kind field
27
+ - concept — an abstract design idea (system architecture, module boundaries, data flow, deployment model, permission model, evaluation framework, etc.)
28
+ - source — one summary page per ingested source document; must declare a source_type field
29
+ Other types (comparison, synthesis, etc.) may be created as needed.
30
+
31
+ # Fields / sections per type
32
+ - entity:
33
+ - kind: module | service | platform | external_system | user_role | other (required)
34
+ - definition: responsibility / purpose
35
+ - key attributes: key properties
36
+ - relationships: relationships to other entities
37
+ - concept:
38
+ - definition: concept definition
39
+ - significance: importance / role
40
+ - related entities: associated entities
41
+ - common topics: system architecture, module boundaries, data flow, deployment model, permission model, evaluation framework
42
+ - source:
43
+ - source_type: requirement | architecture | meeting | rfc | decision | other (required)
44
+ - source document summary
45
+ - Use OKF sections where applicable: # Schema / # Examples / # Citations
46
+
47
+ # Naming & language
48
+ - slug: lowercase, spaces→hyphens
49
+ - Output language: follow the source document — do not switch`;
50
+ /** 判断一段正文是否"有实质内容"(排除 init 写入的空壳占位)。 */
51
+ function hasMeaningfulContent(body) {
52
+ const stripped = body
53
+ .replace(/^#.*$/gm, "") // 去掉标题行
54
+ .replace(/Define\b[^.。]*[.。]?/gi, "") // 去掉 "Define ..." 占位句(init 默认壳)
55
+ .replace(/\s+/g, "");
56
+ return stripped.length >= 8;
57
+ }
58
+ function readTemplateFile(projectPath, name) {
59
+ const full = join(projectPath, "wiki", name);
60
+ if (!existsSync(full))
61
+ return null;
62
+ const content = readFileSync(full, "utf-8");
63
+ const { body } = parseFrontmatter(content);
64
+ const trimmed = body.trim();
65
+ if (!trimmed || !hasMeaningfulContent(trimmed))
66
+ return null;
67
+ return trimmed;
68
+ }
69
+ /**
70
+ * 加载抽取模板。存在且有实质内容则用用户的;否则用领域中立默认。
71
+ */
72
+ export function loadTemplate(projectPath) {
73
+ const purpose = readTemplateFile(projectPath, "purpose.md");
74
+ const schema = readTemplateFile(projectPath, "schema.md");
75
+ return {
76
+ purpose: purpose ?? DEFAULT_PURPOSE,
77
+ schema: schema ?? DEFAULT_SCHEMA,
78
+ customized: purpose != null || schema != null,
79
+ };
80
+ }
@@ -0,0 +1,4 @@
1
+ export declare const ZH_STOP_WORDS: Set<string>;
2
+ export declare function buildFtsQuery(text: string): string | null;
3
+ export declare function tokenizeForFts(text: string): string;
4
+ export declare function bm25RankToScore(rank: number): number;
@@ -0,0 +1,29 @@
1
+ // Derived from TencentDB Agent Memory MemoryCore/src/core/store/tokenize.ts (MIT).
2
+ import { Jieba } from '@node-rs/jieba';
3
+ import { dict } from '@node-rs/jieba/dict.js';
4
+ const jieba = Jieba.withDict(dict);
5
+ export const ZH_STOP_WORDS = new Set([
6
+ "的", "了", "在", "是", "我", "有", "和", "就", "不", "人", "都", "一",
7
+ "一个", "上", "也", "很", "到", "说", "要", "去", "你", "会", "着",
8
+ "没有", "看", "好", "自己", "这", "他", "她", "它", "们", "那",
9
+ "吗", "吧", "呢", "啊", "呀", "哦", "嗯",
10
+ ]);
11
+ export function buildFtsQuery(text) {
12
+ const words = jieba.cutForSearch(text, true)
13
+ .map(word => word.trim())
14
+ .filter(word => /[\p{L}\p{N}]/u.test(word) && !ZH_STOP_WORDS.has(word));
15
+ const terms = [...new Set(words)].map(word => `"${word.replaceAll('"', '""')}"`);
16
+ return terms.length ? terms.join(' OR ') : null;
17
+ }
18
+ export function tokenizeForFts(text) {
19
+ return jieba.cutForSearch(text, true).join(' ');
20
+ }
21
+ export function bm25RankToScore(rank) {
22
+ if (!Number.isFinite(rank))
23
+ return 1 / (1 + 999);
24
+ if (rank < 0) {
25
+ const relevance = -rank;
26
+ return relevance / (1 + relevance);
27
+ }
28
+ return 1 / (1 + rank);
29
+ }
@@ -0,0 +1,76 @@
1
+ import type { Wiki } from './wiki.js';
2
+ type Operation = 'create' | 'update' | 'promote' | 'retire';
3
+ type State = 'pending' | 'applying' | 'applied';
4
+ export declare function proposeWikiChange(wiki: Wiki, value: unknown, evidence: readonly string[], candidate?: {
5
+ closeout: string;
6
+ id: string;
7
+ sources: readonly string[];
8
+ related: string[];
9
+ }): {
10
+ applied_at?: string | undefined;
11
+ review?: {
12
+ relationship: "overlap" | "conflict" | "independent";
13
+ rationale: string;
14
+ related: string[];
15
+ } | undefined;
16
+ candidate?: {
17
+ closeout: string;
18
+ id: string;
19
+ } | undefined;
20
+ id: string;
21
+ entry: string;
22
+ operation: Operation;
23
+ state: State;
24
+ sources: string[];
25
+ baseline_sha256: string | null;
26
+ result_sha256: string;
27
+ before: string | null;
28
+ after: string;
29
+ };
30
+ export declare function applyWikiChange(wiki: Wiki, id: string): {
31
+ replayed: boolean;
32
+ applied_at?: string | undefined;
33
+ review?: {
34
+ relationship: "overlap" | "conflict" | "independent";
35
+ rationale: string;
36
+ related: string[];
37
+ } | undefined;
38
+ candidate?: {
39
+ closeout: string;
40
+ id: string;
41
+ } | undefined;
42
+ id: string;
43
+ entry: string;
44
+ operation: Operation;
45
+ state: State;
46
+ sources: string[];
47
+ baseline_sha256: string | null;
48
+ result_sha256: string;
49
+ before: string | null;
50
+ after: string;
51
+ };
52
+ export declare function listWikiChanges(wiki: Wiki, selection?: {
53
+ id?: string;
54
+ entry?: string;
55
+ }): {
56
+ applied_at?: string | undefined;
57
+ review?: {
58
+ relationship: "overlap" | "conflict" | "independent";
59
+ rationale: string;
60
+ related: string[];
61
+ } | undefined;
62
+ candidate?: {
63
+ closeout: string;
64
+ id: string;
65
+ } | undefined;
66
+ id: string;
67
+ entry: string;
68
+ operation: Operation;
69
+ state: State;
70
+ sources: string[];
71
+ baseline_sha256: string | null;
72
+ result_sha256: string;
73
+ before: string | null;
74
+ after: string;
75
+ }[];
76
+ export {};