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.
- package/LICENSE +27 -0
- package/README.md +195 -2
- package/dist/agent-memory-prompts.d.ts +13 -0
- package/dist/agent-memory-prompts.js +55 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +6 -0
- package/dist/closeout.d.ts +105 -0
- package/dist/closeout.js +473 -0
- package/dist/code.d.ts +39 -0
- package/dist/code.js +124 -0
- package/dist/codex-memory.d.ts +24 -0
- package/dist/codex-memory.js +217 -0
- package/dist/common.d.ts +16 -0
- package/dist/common.js +52 -0
- package/dist/context-envelope.d.ts +59 -0
- package/dist/context-envelope.js +23 -0
- package/dist/host-adapters.d.ts +34 -0
- package/dist/host-adapters.js +151 -0
- package/dist/http.d.ts +3 -0
- package/dist/http.js +90 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.js +13 -0
- package/dist/knowledge-cli.d.ts +198 -0
- package/dist/knowledge-cli.js +761 -0
- package/dist/knowledge-reads.d.ts +72 -0
- package/dist/knowledge-reads.js +201 -0
- package/dist/memory-config.d.ts +44 -0
- package/dist/memory-config.js +204 -0
- package/dist/memory-evidence.d.ts +13 -0
- package/dist/memory-evidence.js +40 -0
- package/dist/memory-history.d.ts +46 -0
- package/dist/memory-history.js +432 -0
- package/dist/memory.d.ts +96 -0
- package/dist/memory.js +362 -0
- package/dist/retrospective.d.ts +57 -0
- package/dist/retrospective.js +240 -0
- package/dist/search.d.ts +36 -0
- package/dist/search.js +112 -0
- package/dist/skill-addition.d.ts +25 -0
- package/dist/skill-addition.js +89 -0
- package/dist/skill-design.d.ts +96 -0
- package/dist/skill-design.js +226 -0
- package/dist/skill-replay.d.ts +55 -0
- package/dist/skill-replay.js +448 -0
- package/dist/skill-route.d.ts +30 -0
- package/dist/skill-route.js +75 -0
- package/dist/transcript-evidence.d.ts +3 -0
- package/dist/transcript-evidence.js +58 -0
- package/dist/upstream/chunker.d.ts +24 -0
- package/dist/upstream/chunker.js +96 -0
- package/dist/upstream/file-protocol.d.ts +45 -0
- package/dist/upstream/file-protocol.js +117 -0
- package/dist/upstream/frontmatter.d.ts +47 -0
- package/dist/upstream/frontmatter.js +86 -0
- package/dist/upstream/graph-search.d.ts +33 -0
- package/dist/upstream/graph-search.js +67 -0
- package/dist/upstream/l1-extraction.d.ts +26 -0
- package/dist/upstream/l1-extraction.js +405 -0
- package/dist/upstream/llm.d.ts +8 -0
- package/dist/upstream/llm.js +1 -0
- package/dist/upstream/merge.d.ts +50 -0
- package/dist/upstream/merge.js +153 -0
- package/dist/upstream/prompts.d.ts +53 -0
- package/dist/upstream/prompts.js +181 -0
- package/dist/upstream/search-utils.d.ts +34 -0
- package/dist/upstream/search-utils.js +55 -0
- package/dist/upstream/slug.d.ts +26 -0
- package/dist/upstream/slug.js +103 -0
- package/dist/upstream/template.d.ts +29 -0
- package/dist/upstream/template.js +80 -0
- package/dist/upstream/tokenize.d.ts +4 -0
- package/dist/upstream/tokenize.js +29 -0
- package/dist/wiki-change.d.ts +76 -0
- package/dist/wiki-change.js +299 -0
- package/dist/wiki-entry.d.ts +26 -0
- package/dist/wiki-entry.js +93 -0
- package/dist/wiki-ingest.d.ts +12 -0
- package/dist/wiki-ingest.js +126 -0
- package/dist/wiki-migration.d.ts +16 -0
- package/dist/wiki-migration.js +268 -0
- package/dist/wiki-tokens.d.ts +1 -0
- package/dist/wiki-tokens.js +46 -0
- package/dist/wiki.d.ts +103 -0
- package/dist/wiki.js +330 -0
- package/dist/workflow-cli.d.ts +2 -0
- package/dist/workflow-cli.js +319 -0
- package/dist/workflow-install.d.ts +37 -0
- package/dist/workflow-install.js +148 -0
- package/dist/workflow-knowledge.d.ts +18 -0
- package/dist/workflow-knowledge.js +32 -0
- package/dist/workflow-mcp.d.ts +2 -0
- package/dist/workflow-mcp.js +137 -0
- package/dist/workflow-names.d.ts +4 -0
- package/dist/workflow-names.js +31 -0
- package/dist/workflow-runtime.d.ts +735 -0
- package/dist/workflow-runtime.js +747 -0
- package/dist/workflow-skills.d.ts +48 -0
- package/dist/workflow-skills.js +141 -0
- package/docs/images/impeccable-skill.png +0 -0
- package/docs/images/workflow-overview.png +0 -0
- package/docs/images/workflow-skills.png +0 -0
- package/package.json +77 -4
- package/skills/ew-impeccable/LICENSE +191 -0
- package/skills/ew-impeccable/NOTICE.md +19 -0
- package/skills/ew-impeccable/SKILL.md +91 -0
- package/skills/ew-impeccable/UPSTREAM.md +23 -0
- package/skills/ew-impeccable/reference/adapt.md +314 -0
- package/skills/ew-impeccable/reference/adapt.native.md +60 -0
- package/skills/ew-impeccable/reference/android.md +46 -0
- package/skills/ew-impeccable/reference/animate.md +91 -0
- package/skills/ew-impeccable/reference/audit.md +138 -0
- package/skills/ew-impeccable/reference/audit.native.md +141 -0
- package/skills/ew-impeccable/reference/bolder.md +35 -0
- package/skills/ew-impeccable/reference/clarify.md +96 -0
- package/skills/ew-impeccable/reference/colorize.md +88 -0
- package/skills/ew-impeccable/reference/craft-floor.md +44 -0
- package/skills/ew-impeccable/reference/craft.md +5 -0
- package/skills/ew-impeccable/reference/critique.md +808 -0
- package/skills/ew-impeccable/reference/degraded/asset-producer.md +36 -0
- package/skills/ew-impeccable/reference/degraded/documenter.md +23 -0
- package/skills/ew-impeccable/reference/degraded/finish-reviewer.md +72 -0
- package/skills/ew-impeccable/reference/degraded/manual-edit-applier.md +91 -0
- package/skills/ew-impeccable/reference/delight.md +72 -0
- package/skills/ew-impeccable/reference/distill.md +113 -0
- package/skills/ew-impeccable/reference/doctor.md +56 -0
- package/skills/ew-impeccable/reference/document.md +418 -0
- package/skills/ew-impeccable/reference/extract.md +68 -0
- package/skills/ew-impeccable/reference/harden.md +338 -0
- package/skills/ew-impeccable/reference/hooks.md +113 -0
- package/skills/ew-impeccable/reference/init.md +133 -0
- package/skills/ew-impeccable/reference/ios.md +51 -0
- package/skills/ew-impeccable/reference/layout.md +86 -0
- package/skills/ew-impeccable/reference/live-setup.md +102 -0
- package/skills/ew-impeccable/reference/live.md +326 -0
- package/skills/ew-impeccable/reference/new-work.md +209 -0
- package/skills/ew-impeccable/reference/onboard.md +236 -0
- package/skills/ew-impeccable/reference/operate.md +61 -0
- package/skills/ew-impeccable/reference/optimize.md +260 -0
- package/skills/ew-impeccable/reference/overdrive.md +127 -0
- package/skills/ew-impeccable/reference/polish.md +105 -0
- package/skills/ew-impeccable/reference/quieter.md +101 -0
- package/skills/ew-impeccable/reference/routing.md +20 -0
- package/skills/ew-impeccable/reference/shape.md +59 -0
- package/skills/ew-impeccable/reference/typeset.md +82 -0
- package/skills/ew-impeccable/reference/visualize.md +46 -0
- package/skills/ew-impeccable/scripts/build-phase.mjs +1022 -0
- package/skills/ew-impeccable/scripts/command-metadata.json +94 -0
- package/skills/ew-impeccable/scripts/comp-diff.mjs +391 -0
- package/skills/ew-impeccable/scripts/comp-spec.mjs +513 -0
- package/skills/ew-impeccable/scripts/concept-seed.mjs +814 -0
- package/skills/ew-impeccable/scripts/context-signals.mjs +325 -0
- package/skills/ew-impeccable/scripts/context.mjs +1521 -0
- package/skills/ew-impeccable/scripts/critique-storage.mjs +473 -0
- package/skills/ew-impeccable/scripts/data/font-index-failures.json +121 -0
- package/skills/ew-impeccable/scripts/data/font-index.json +1 -0
- package/skills/ew-impeccable/scripts/detect-csp.mjs +246 -0
- package/skills/ew-impeccable/scripts/detect.mjs +30 -0
- package/skills/ew-impeccable/scripts/detector/browser/injected/index.mjs +2580 -0
- package/skills/ew-impeccable/scripts/detector/cli/main.mjs +498 -0
- package/skills/ew-impeccable/scripts/detector/design-system.mjs +1311 -0
- package/skills/ew-impeccable/scripts/detector/detect-antipatterns-browser.js +9486 -0
- package/skills/ew-impeccable/scripts/detector/detect-antipatterns.mjs +51 -0
- package/skills/ew-impeccable/scripts/detector/engines/browser/detect-url.mjs +434 -0
- package/skills/ew-impeccable/scripts/detector/engines/regex/detect-text.mjs +1439 -0
- package/skills/ew-impeccable/scripts/detector/engines/static-html/css-cascade.mjs +1242 -0
- package/skills/ew-impeccable/scripts/detector/engines/static-html/detect-html.mjs +263 -0
- package/skills/ew-impeccable/scripts/detector/engines/visual/screenshot-contrast.mjs +189 -0
- package/skills/ew-impeccable/scripts/detector/findings.mjs +23 -0
- package/skills/ew-impeccable/scripts/detector/node/file-system.mjs +225 -0
- package/skills/ew-impeccable/scripts/detector/profile/profiler.mjs +166 -0
- package/skills/ew-impeccable/scripts/detector/registry/antipatterns.mjs +636 -0
- package/skills/ew-impeccable/scripts/detector/rules/checks.mjs +5750 -0
- package/skills/ew-impeccable/scripts/detector/shared/color.mjs +596 -0
- package/skills/ew-impeccable/scripts/detector/shared/constants.mjs +127 -0
- package/skills/ew-impeccable/scripts/detector/shared/fonts.mjs +30 -0
- package/skills/ew-impeccable/scripts/detector/shared/inline-ignores.mjs +148 -0
- package/skills/ew-impeccable/scripts/detector/shared/page.mjs +7 -0
- package/skills/ew-impeccable/scripts/detector/vendor/MDN-DATA-LICENSE +116 -0
- package/skills/ew-impeccable/scripts/detector/vendor/THIRD_PARTY_LICENSES.md +227 -0
- package/skills/ew-impeccable/scripts/detector/vendor/static-html-parser.build-entry.txt +11 -0
- package/skills/ew-impeccable/scripts/detector/vendor/static-html-parser.bundle.mjs +9121 -0
- package/skills/ew-impeccable/scripts/doctor.mjs +330 -0
- package/skills/ew-impeccable/scripts/embed-prompt.mjs +166 -0
- package/skills/ew-impeccable/scripts/font-match.mjs +457 -0
- package/skills/ew-impeccable/scripts/generate-image.mjs +447 -0
- package/skills/ew-impeccable/scripts/hook-admin.mjs +829 -0
- package/skills/ew-impeccable/scripts/hook-before-edit.mjs +538 -0
- package/skills/ew-impeccable/scripts/hook-lib.mjs +2493 -0
- package/skills/ew-impeccable/scripts/hook.mjs +79 -0
- package/skills/ew-impeccable/scripts/lib/artifact-schema.mjs +93 -0
- package/skills/ew-impeccable/scripts/lib/composition-catalog.mjs +200 -0
- package/skills/ew-impeccable/scripts/lib/concept-catalog.mjs +395 -0
- package/skills/ew-impeccable/scripts/lib/design-parser.mjs +880 -0
- package/skills/ew-impeccable/scripts/lib/font-fingerprint.mjs +564 -0
- package/skills/ew-impeccable/scripts/lib/font-index.mjs +130 -0
- package/skills/ew-impeccable/scripts/lib/hero-checks.mjs +246 -0
- package/skills/ew-impeccable/scripts/lib/image-metrics.mjs +306 -0
- package/skills/ew-impeccable/scripts/lib/impeccable-config.mjs +640 -0
- package/skills/ew-impeccable/scripts/lib/impeccable-paths.mjs +137 -0
- package/skills/ew-impeccable/scripts/lib/is-generated.mjs +72 -0
- package/skills/ew-impeccable/scripts/lib/live-path-globs.mjs +37 -0
- package/skills/ew-impeccable/scripts/lib/open-system-browser.mjs +26 -0
- package/skills/ew-impeccable/scripts/lib/png.mjs +281 -0
- package/skills/ew-impeccable/scripts/lib/provider.mjs +5 -0
- package/skills/ew-impeccable/scripts/lib/raster.mjs +194 -0
- package/skills/ew-impeccable/scripts/lib/roll-selection.mjs +369 -0
- package/skills/ew-impeccable/scripts/lib/staleness-deep.mjs +491 -0
- package/skills/ew-impeccable/scripts/lib/staleness-notice.mjs +169 -0
- package/skills/ew-impeccable/scripts/lib/staleness.mjs +532 -0
- package/skills/ew-impeccable/scripts/lib/surface-briefs.mjs +149 -0
- package/skills/ew-impeccable/scripts/lib/target-args.mjs +42 -0
- package/skills/ew-impeccable/scripts/lib/target-slug.mjs +33 -0
- package/skills/ew-impeccable/scripts/lib/template-extensions.mjs +146 -0
- package/skills/ew-impeccable/scripts/live/accept-css.mjs +617 -0
- package/skills/ew-impeccable/scripts/live/accept-verify.mjs +60 -0
- package/skills/ew-impeccable/scripts/live/browser-script-parts.mjs +84 -0
- package/skills/ew-impeccable/scripts/live/completion.mjs +28 -0
- package/skills/ew-impeccable/scripts/live/event-validation.mjs +199 -0
- package/skills/ew-impeccable/scripts/live/frameworks/astro.mjs +47 -0
- package/skills/ew-impeccable/scripts/live/frameworks/detect-utils.mjs +73 -0
- package/skills/ew-impeccable/scripts/live/frameworks/index.mjs +143 -0
- package/skills/ew-impeccable/scripts/live/frameworks/journal.mjs +197 -0
- package/skills/ew-impeccable/scripts/live/frameworks/nextjs.mjs +49 -0
- package/skills/ew-impeccable/scripts/live/frameworks/nuxt.mjs +161 -0
- package/skills/ew-impeccable/scripts/live/frameworks/script-src.mjs +17 -0
- package/skills/ew-impeccable/scripts/live/frameworks/static-html.mjs +26 -0
- package/skills/ew-impeccable/scripts/live/frameworks/sveltekit.mjs +71 -0
- package/skills/ew-impeccable/scripts/live/frameworks/tag-strategy.mjs +247 -0
- package/skills/ew-impeccable/scripts/live/frameworks/tanstack-start.mjs +70 -0
- package/skills/ew-impeccable/scripts/live/frameworks/vite-generic.mjs +42 -0
- package/skills/ew-impeccable/scripts/live/generation-preflight.mjs +149 -0
- package/skills/ew-impeccable/scripts/live/insert-ui.mjs +458 -0
- package/skills/ew-impeccable/scripts/live/instructions.mjs +142 -0
- package/skills/ew-impeccable/scripts/live/manual-apply.mjs +939 -0
- package/skills/ew-impeccable/scripts/live/manual-edit-routes.mjs +357 -0
- package/skills/ew-impeccable/scripts/live/manual-edits-buffer.mjs +152 -0
- package/skills/ew-impeccable/scripts/live/poll-lanes.mjs +14 -0
- package/skills/ew-impeccable/scripts/live/project-ignores.mjs +139 -0
- package/skills/ew-impeccable/scripts/live/roots.mjs +508 -0
- package/skills/ew-impeccable/scripts/live/session-store.mjs +563 -0
- package/skills/ew-impeccable/scripts/live/source-lock.mjs +105 -0
- package/skills/ew-impeccable/scripts/live/source-search.mjs +105 -0
- package/skills/ew-impeccable/scripts/live/svelte-ast.mjs +969 -0
- package/skills/ew-impeccable/scripts/live/svelte-component.mjs +1366 -0
- package/skills/ew-impeccable/scripts/live/sveltekit-adapter.mjs +304 -0
- package/skills/ew-impeccable/scripts/live/tanstack-adapter.mjs +259 -0
- package/skills/ew-impeccable/scripts/live/ui-surfaces.mjs +75 -0
- package/skills/ew-impeccable/scripts/live/vocabulary.mjs +171 -0
- package/skills/ew-impeccable/scripts/live-accept.mjs +938 -0
- package/skills/ew-impeccable/scripts/live-browser-dom.js +167 -0
- package/skills/ew-impeccable/scripts/live-browser-ignores.js +242 -0
- package/skills/ew-impeccable/scripts/live-browser-session.js +144 -0
- package/skills/ew-impeccable/scripts/live-browser.js +12851 -0
- package/skills/ew-impeccable/scripts/live-commit-manual-edits.mjs +1200 -0
- package/skills/ew-impeccable/scripts/live-complete.mjs +107 -0
- package/skills/ew-impeccable/scripts/live-copy-edit-agent.mjs +800 -0
- package/skills/ew-impeccable/scripts/live-discard-manual-edits.mjs +51 -0
- package/skills/ew-impeccable/scripts/live-inject.mjs +463 -0
- package/skills/ew-impeccable/scripts/live-insert.mjs +292 -0
- package/skills/ew-impeccable/scripts/live-manual-edit-evidence.mjs +368 -0
- package/skills/ew-impeccable/scripts/live-poll.mjs +430 -0
- package/skills/ew-impeccable/scripts/live-resume.mjs +123 -0
- package/skills/ew-impeccable/scripts/live-server.mjs +1698 -0
- package/skills/ew-impeccable/scripts/live-status.mjs +71 -0
- package/skills/ew-impeccable/scripts/live-target.mjs +30 -0
- package/skills/ew-impeccable/scripts/live-wrap.mjs +927 -0
- package/skills/ew-impeccable/scripts/live.mjs +334 -0
- package/skills/ew-impeccable/scripts/modern-screenshot.umd.js +14 -0
- package/skills/ew-impeccable/scripts/palette.mjs +628 -0
- package/skills/ew-impeccable/scripts/pin.mjs +352 -0
- package/skills/ew-impeccable/scripts/serve-question.mjs +1783 -0
- package/skills/ew-impeccable/scripts/surface-brief.mjs +74 -0
- package/skills/ew-knowledge/SKILL.md +35 -0
- package/skills/ew-knowledge/references/closeout-protocol.md +68 -0
- package/skills/ew-knowledge/references/knowledge-route.md +73 -0
- package/skills/ew-knowledge/references/wiki-maintenance.md +27 -0
- package/skills/ew-odyssey/SKILL.md +106 -0
- package/skills/ew-odyssey/references/audit-artifacts.md +7 -0
- package/skills/ew-odyssey/references/odyssey-base.md +104 -0
- package/skills/ew-odyssey/references/odyssey-debug.md +264 -0
- package/skills/ew-odyssey/references/odyssey-defensive.md +351 -0
- package/skills/ew-odyssey/references/odyssey-improve.md +230 -0
- package/skills/ew-odyssey/references/odyssey-planex.md +294 -0
- package/skills/ew-odyssey/references/odyssey-review.md +233 -0
- package/skills/ew-odyssey/references/odyssey-security.md +231 -0
- package/skills/ew-odyssey/references/odyssey-ui.md +232 -0
- package/skills/ew-odyssey/references/prepare/odyssey-debug.md +102 -0
- package/skills/ew-odyssey/references/prepare/odyssey-defensive.md +117 -0
- package/skills/ew-odyssey/references/prepare/odyssey-improve.md +95 -0
- package/skills/ew-odyssey/references/prepare/odyssey-planex.md +105 -0
- package/skills/ew-odyssey/references/prepare/odyssey-review.md +105 -0
- package/skills/ew-odyssey/references/prepare/odyssey-security.md +91 -0
- package/skills/ew-odyssey/references/prepare/odyssey-ui.md +88 -0
- package/skills/ew-odyssey/references/runtime-adapters.md +31 -0
- package/skills/ew-orchestrate/SKILL.md +89 -0
- package/skills/ew-orchestrate/references/auto-policy.md +66 -0
- package/skills/ew-orchestrate/references/boundary-grill.md +51 -0
- package/skills/ew-orchestrate/references/companion-route.md +40 -0
- package/skills/ew-orchestrate/references/ew-orchestrate.md +44 -0
- package/skills/ew-orchestrate/references/goal.md +51 -0
- package/skills/ew-orchestrate/references/orchestrator-run-loop.md +33 -0
- package/skills/ew-orchestrate/references/planning.md +54 -0
- package/skills/ew-orchestrate/steps/ew-analyze/SKILL.md +70 -0
- package/skills/ew-orchestrate/steps/ew-analyze/references/issue-gaps-analyze.md +24 -0
- package/skills/ew-orchestrate/steps/ew-analyze/references/prepare.md +8 -0
- package/skills/ew-orchestrate/steps/ew-analyze/references/workflow.md +138 -0
- package/skills/ew-orchestrate/steps/ew-auto-test/SKILL.md +80 -0
- package/skills/ew-orchestrate/steps/ew-auto-test/references/prepare.md +23 -0
- package/skills/ew-orchestrate/steps/ew-auto-test/references/workflow.md +31 -0
- package/skills/ew-orchestrate/steps/ew-blueprint/SKILL.md +122 -0
- package/skills/ew-orchestrate/steps/ew-blueprint/references/prepare.md +21 -0
- package/skills/ew-orchestrate/steps/ew-blueprint/references/workflow.md +28 -0
- package/skills/ew-orchestrate/steps/ew-brainstorm/SKILL.md +49 -0
- package/skills/ew-orchestrate/steps/ew-companion/SKILL.md +50 -0
- package/skills/ew-orchestrate/steps/ew-debug/SKILL.md +85 -0
- package/skills/ew-orchestrate/steps/ew-debug/references/prepare.md +27 -0
- package/skills/ew-orchestrate/steps/ew-debug/references/workflow.md +31 -0
- package/skills/ew-orchestrate/steps/ew-execute/SKILL.md +74 -0
- package/skills/ew-orchestrate/steps/ew-execute/references/prepare.md +27 -0
- package/skills/ew-orchestrate/steps/ew-execute/references/workflow.md +87 -0
- package/skills/ew-orchestrate/steps/ew-grill/SKILL.md +62 -0
- package/skills/ew-orchestrate/steps/ew-grill/references/prepare.md +26 -0
- package/skills/ew-orchestrate/steps/ew-grill/references/workflow.md +31 -0
- package/skills/ew-orchestrate/steps/ew-init/SKILL.md +56 -0
- package/skills/ew-orchestrate/steps/ew-init/references/prepare.md +25 -0
- package/skills/ew-orchestrate/steps/ew-init/references/workflow.md +28 -0
- package/skills/ew-orchestrate/steps/ew-plan/SKILL.md +131 -0
- package/skills/ew-orchestrate/steps/ew-plan/references/prepare.md +8 -0
- package/skills/ew-orchestrate/steps/ew-plan/references/tdd.md +53 -0
- package/skills/ew-orchestrate/steps/ew-plan/references/workflow.md +100 -0
- package/skills/ew-orchestrate/steps/ew-retrospective/SKILL.md +68 -0
- package/skills/ew-orchestrate/steps/ew-retrospective/references/prepare.md +18 -0
- package/skills/ew-orchestrate/steps/ew-retrospective/references/workflow.md +34 -0
- package/skills/ew-orchestrate/steps/ew-review/SKILL.md +45 -0
- package/skills/ew-orchestrate/steps/ew-review/references/prepare.md +17 -0
- package/skills/ew-orchestrate/steps/ew-review/references/workflow.md +116 -0
- package/skills/ew-orchestrate/steps/ew-roadmap/SKILL.md +62 -0
- package/skills/ew-orchestrate/steps/ew-roadmap/references/prepare.md +27 -0
- package/skills/ew-orchestrate/steps/ew-roadmap/references/workflow.md +28 -0
- package/skills/ew-orchestrate/steps/ew-test/SKILL.md +99 -0
- package/skills/ew-orchestrate/steps/ew-test/references/prepare.md +23 -0
- package/skills/ew-orchestrate/steps/ew-test/references/workflow.md +23 -0
- package/skills/ew-orchestrate/steps/ew-verify/SKILL.md +73 -0
- package/skills/ew-orchestrate/steps/ew-verify/references/prepare.md +21 -0
- package/skills/ew-orchestrate/steps/ew-verify/references/workflow.md +29 -0
- package/skills/ew-skill-design/SKILL.md +30 -0
- package/skills/ew-skill-design/references/package-contract.md +40 -0
- package/skills/ew-skill-design/references/validation.md +21 -0
- package/skills/team-swarm/SKILL.md +68 -0
- package/skills/team-swarm/references/mcp-coordination.md +14 -0
- package/skills/team-swarm/roles/analyst/role.md +181 -0
- package/skills/team-swarm/roles/ant/role.md +149 -0
- package/skills/team-swarm/roles/coordinator/commands/converge.md +112 -0
- package/skills/team-swarm/roles/coordinator/commands/init-swarm.md +136 -0
- package/skills/team-swarm/roles/coordinator/commands/iterate.md +171 -0
- package/skills/team-swarm/roles/coordinator/role.md +170 -0
- package/skills/team-swarm/roles/scorer/role.md +150 -0
- package/skills/team-swarm/scripts/aco.py +646 -0
- package/skills/team-swarm/scripts/pheromone.py +144 -0
- package/skills/team-swarm/scripts/scoring.py +111 -0
- package/skills/team-swarm/scripts/test_aco.py +606 -0
- package/skills/team-swarm/specs/ant-output-schema.md +127 -0
- package/skills/team-swarm/specs/convergence-criteria.md +108 -0
- package/skills/team-swarm/specs/pheromone-schema.md +125 -0
- package/skills/team-swarm/specs/swarm-config-template.json +71 -0
- package/skills/team-swarm/specs/swarm-protocol.md +119 -0
- package/skills/workflow-evolve/SKILL.md +64 -0
- package/skills/workflow-evolve/references/agy-gate.md +27 -0
- package/skills/workflow-evolve/references/auto-loop.md +23 -0
- package/skills/workflow-evolve/references/history-review.md +15 -0
- package/skills/workflow-evolve/scripts/codex-memory-replay.mjs +86 -0
- package/skills/workflow-evolve/scripts/codex-replay.mjs +1 -0
- package/skills/workflow-evolve/scripts/evolve-loop.mjs +260 -0
- package/skills/workflow-evolve/scripts/memory-codex-mcp.mjs +124 -0
- package/workflows/index.json +33 -0
package/dist/closeout.js
ADDED
|
@@ -0,0 +1,473 @@
|
|
|
1
|
+
import { createHash, randomUUID } from 'node:crypto';
|
|
2
|
+
import { lstatSync, mkdirSync, readFileSync, readdirSync, renameSync, rmSync, writeFileSync } from 'node:fs';
|
|
3
|
+
import { basename, dirname, join } from 'node:path';
|
|
4
|
+
import { stringify } from 'yaml';
|
|
5
|
+
import { buildCloseoutHarvestPrompt, buildWikiRelationPrompt } from './agent-memory-prompts.js';
|
|
6
|
+
import { InputError, NotFoundError, openDb, requireText, transaction } from './common.js';
|
|
7
|
+
import { extractMemoryInputs, validateConversationMessages } from './memory.js';
|
|
8
|
+
import { parseFrontmatter, readSources } from './upstream/frontmatter.js';
|
|
9
|
+
import { unionSources } from './upstream/merge.js';
|
|
10
|
+
import { readCompletionTranscriptRefs, readTranscriptSnapshots } from './transcript-evidence.js';
|
|
11
|
+
import { applyWikiChange, proposeWikiChange } from './wiki-change.js';
|
|
12
|
+
import { formatKnowledgeReadsMessage, validateKnowledgeReads } from './knowledge-reads.js';
|
|
13
|
+
const terminalStatuses = new Set(['succeeded', 'failed', 'cancelled']);
|
|
14
|
+
const maintenanceSkills = new Set(['ew-knowledge', 'workflow-closeout', 'workflow-evolve']);
|
|
15
|
+
async function compareReferences(wiki, content, model) {
|
|
16
|
+
if (!lstatSync(wiki.indexPath, { throwIfNoEntry: false })?.isFile())
|
|
17
|
+
return undefined;
|
|
18
|
+
const matches = wiki.search(content, { limit: 5 }).results
|
|
19
|
+
.map(hit => wiki.getEntry(hit.id))
|
|
20
|
+
.filter((entry) => entry?.entry?.status === 'active');
|
|
21
|
+
if (!matches.length)
|
|
22
|
+
return undefined;
|
|
23
|
+
const promptSpec = buildWikiRelationPrompt();
|
|
24
|
+
const response = await model().chat({
|
|
25
|
+
system: promptSpec.system,
|
|
26
|
+
prompt: JSON.stringify({ content, entries: matches.map(entry => ({
|
|
27
|
+
id: entry.id, body: entry.body, scope: entry.entry?.scope,
|
|
28
|
+
})) }),
|
|
29
|
+
label: promptSpec.label,
|
|
30
|
+
});
|
|
31
|
+
const json = response.replace(/<think>[\s\S]*?<\/think>\s*/g, '').match(/\[[\s\S]*\]/)?.[0];
|
|
32
|
+
if (!json)
|
|
33
|
+
throw new InputError('Wiki comparison did not return a JSON array');
|
|
34
|
+
const known = new Map(matches.map(entry => [entry.id, entry]));
|
|
35
|
+
const related = [];
|
|
36
|
+
for (const value of JSON.parse(json)) {
|
|
37
|
+
const { id, relation } = object(value);
|
|
38
|
+
if (typeof id !== 'string' || (relation !== 'conflict' && relation !== 'overlap'))
|
|
39
|
+
continue;
|
|
40
|
+
const entry = known.get(id);
|
|
41
|
+
if (entry && !related.some(item => item.id === id))
|
|
42
|
+
related.push({ id, relation, sources: entry.sources });
|
|
43
|
+
}
|
|
44
|
+
return related.length ? related : undefined;
|
|
45
|
+
}
|
|
46
|
+
function appendReferenceSources(wiki, candidate) {
|
|
47
|
+
if (!candidate.matched_entry || candidate.related_entries?.length)
|
|
48
|
+
return false;
|
|
49
|
+
const entry = wiki.getEntry(candidate.matched_entry);
|
|
50
|
+
if (!entry || entry.entry?.mode !== 'reference' || entry.entry.status !== 'active' ||
|
|
51
|
+
!entry.entry.scope.includes('project') ||
|
|
52
|
+
entry.body.trim() !== candidate.content.trim())
|
|
53
|
+
return false;
|
|
54
|
+
const file = join(wiki.root, entry.path);
|
|
55
|
+
if (!lstatSync(file).isFile())
|
|
56
|
+
throw new InputError(`Invalid Wiki entry file: ${entry.id}`);
|
|
57
|
+
const original = readFileSync(file, 'utf8');
|
|
58
|
+
const { frontmatter, body, hasFrontmatter } = parseFrontmatter(original);
|
|
59
|
+
if (!hasFrontmatter || frontmatter.locked === true || frontmatter.mode !== 'reference' ||
|
|
60
|
+
!Array.isArray(frontmatter.scope) || !frontmatter.scope.includes('project') ||
|
|
61
|
+
frontmatter.status !== 'active' || body.trim() !== candidate.content.trim())
|
|
62
|
+
return false;
|
|
63
|
+
const sources = readSources(original);
|
|
64
|
+
const merged = unionSources(sources, candidate.sources);
|
|
65
|
+
if (merged.every((source, index) => source === sources[index]) && merged.length === sources.length)
|
|
66
|
+
return true;
|
|
67
|
+
const temporary = join(dirname(file), `.${randomUUID()}.tmp`);
|
|
68
|
+
try {
|
|
69
|
+
writeFileSync(temporary, `---\n${stringify({ ...frontmatter, sources: merged })}---\n${body}`, { flag: 'wx' });
|
|
70
|
+
if (readFileSync(file, 'utf8') !== original)
|
|
71
|
+
throw new InputError(`Wiki entry changed: ${entry.id}`);
|
|
72
|
+
renameSync(temporary, file);
|
|
73
|
+
return true;
|
|
74
|
+
}
|
|
75
|
+
finally {
|
|
76
|
+
rmSync(temporary, { force: true });
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
function object(value) {
|
|
80
|
+
if (!value || typeof value !== 'object' || Array.isArray(value))
|
|
81
|
+
throw new InputError('Invalid completion record');
|
|
82
|
+
return value;
|
|
83
|
+
}
|
|
84
|
+
function appendRunEvidence(completion, directory) {
|
|
85
|
+
const known = new Set(completion.messages.map(message => message.id));
|
|
86
|
+
for (const { receipt, result } of readSessionTransitions(directory)) {
|
|
87
|
+
if (typeof result.run_id !== 'string' ||
|
|
88
|
+
(receipt.target_type === 'orchestration' && receipt.target_id !== completion.session) ||
|
|
89
|
+
(receipt.target_type === 'run' && receipt.target_id !== result.run_id) ||
|
|
90
|
+
(receipt.target_type !== 'orchestration' && receipt.target_type !== 'run'))
|
|
91
|
+
continue;
|
|
92
|
+
const run = result.run_id;
|
|
93
|
+
const timestamp = requireText(receipt.recorded_at, 'Run transition time');
|
|
94
|
+
const sealed = result.status === 'sealed' &&
|
|
95
|
+
((receipt.target_type === 'orchestration' && result.operation === 'run-complete-and-seal') ||
|
|
96
|
+
(receipt.target_type === 'run' && result.operation === 'run-recovery-seal'));
|
|
97
|
+
if (sealed && typeof result.summary === 'string') {
|
|
98
|
+
const id = `run:${run}:summary`;
|
|
99
|
+
if (!known.has(id)) {
|
|
100
|
+
completion.messages.push({ id, role: 'tool', timestamp, content: `Run ${run} completed. Summary: ${requireText(result.summary, 'Run summary')}.` });
|
|
101
|
+
known.add(id);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
if (sealed && result.knowledge_reads !== undefined) {
|
|
105
|
+
const knowledgeReads = validateKnowledgeReads(result.knowledge_reads);
|
|
106
|
+
const id = `run:${run}:knowledge-reads`;
|
|
107
|
+
if (!known.has(id)) {
|
|
108
|
+
completion.messages.push({ id, role: 'tool', timestamp, content: formatKnowledgeReadsMessage(knowledgeReads) });
|
|
109
|
+
known.add(id);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
export function parseReceipt(value) {
|
|
115
|
+
const receipt = object(value);
|
|
116
|
+
if (receipt.schema_version === 'evolve-session-completion/1.0') {
|
|
117
|
+
if (!Array.isArray(receipt.messages))
|
|
118
|
+
throw new InputError('Invalid Evolve Session completion');
|
|
119
|
+
return {
|
|
120
|
+
id: requireText(receipt.id, 'completion ID'), session: requireText(receipt.session_id, 'Session ID'),
|
|
121
|
+
timestamp: requireText(receipt.recorded_at, 'completion time'), messages: receipt.messages,
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
if (receipt.schema_version === 'skill-completion/1.0') {
|
|
125
|
+
if (!terminalStatuses.has(receipt.status) || !Array.isArray(receipt.messages)) {
|
|
126
|
+
throw new InputError('Invalid Skill completion');
|
|
127
|
+
}
|
|
128
|
+
const skill = receipt.skill_id === undefined && receipt.skill_version === undefined ? {} : {
|
|
129
|
+
skill: {
|
|
130
|
+
id: requireText(receipt.skill_id, 'Skill ID'),
|
|
131
|
+
version: requireText(receipt.skill_version, 'Skill version'),
|
|
132
|
+
status: receipt.status,
|
|
133
|
+
},
|
|
134
|
+
};
|
|
135
|
+
return {
|
|
136
|
+
id: requireText(receipt.id, 'completion ID'),
|
|
137
|
+
session: requireText(receipt.execution_id, 'execution ID'),
|
|
138
|
+
timestamp: requireText(receipt.recorded_at, 'completion time'),
|
|
139
|
+
messages: receipt.messages,
|
|
140
|
+
...(receipt.knowledge_reads === undefined ? {} : { knowledgeReads: validateKnowledgeReads(receipt.knowledge_reads) }),
|
|
141
|
+
...skill,
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
const result = object(receipt.result);
|
|
145
|
+
if (receipt.schema_version !== 'transition-receipt/2.0' ||
|
|
146
|
+
receipt.target_type !== 'orchestration' || result.status !== 'completed') {
|
|
147
|
+
throw new InputError('Expected a Maestro Session completion receipt');
|
|
148
|
+
}
|
|
149
|
+
const id = requireText(receipt.transition_id, 'transition ID');
|
|
150
|
+
const session = requireText(receipt.session_id, 'Session ID');
|
|
151
|
+
if (receipt.target_id !== session)
|
|
152
|
+
throw new InputError('Session completion target does not match');
|
|
153
|
+
const timestamp = requireText(receipt.recorded_at, 'completion time');
|
|
154
|
+
const messages = Array.isArray(result.evolve_evidence)
|
|
155
|
+
? result.evolve_evidence.map((value, index) => {
|
|
156
|
+
const evidence = object(value);
|
|
157
|
+
return {
|
|
158
|
+
id: requireText(evidence.id, `evidence ID ${index}`),
|
|
159
|
+
role: 'tool',
|
|
160
|
+
timestamp,
|
|
161
|
+
content: requireText(evidence.content, `evidence content ${index}`),
|
|
162
|
+
};
|
|
163
|
+
}) : [];
|
|
164
|
+
return { id, session, timestamp, messages };
|
|
165
|
+
}
|
|
166
|
+
export function readSessionTransitions(directory) {
|
|
167
|
+
const receipts = join(directory, 'receipts');
|
|
168
|
+
const transitions = join(receipts, 'transitions');
|
|
169
|
+
const requests = join(receipts, 'requests');
|
|
170
|
+
for (const path of [receipts, transitions]) {
|
|
171
|
+
const info = lstatSync(path, { throwIfNoEntry: false });
|
|
172
|
+
if (!info)
|
|
173
|
+
return [];
|
|
174
|
+
if (!info.isDirectory())
|
|
175
|
+
throw new InputError(`Invalid Session receipt directory: ${path}`);
|
|
176
|
+
}
|
|
177
|
+
const session = basename(directory);
|
|
178
|
+
return readdirSync(transitions, { withFileTypes: true }).sort((left, right) => left.name.localeCompare(right.name)).flatMap(entry => {
|
|
179
|
+
const match = /^(\d{12})-(tr_[a-z0-9-]+)\.json$/i.exec(entry.name);
|
|
180
|
+
if (!match)
|
|
181
|
+
return [];
|
|
182
|
+
if (!entry.isFile())
|
|
183
|
+
throw new InputError(`Invalid Session transition file: ${entry.name}`);
|
|
184
|
+
const receipt = object(JSON.parse(readFileSync(join(transitions, entry.name), 'utf8')));
|
|
185
|
+
const requestId = requireText(receipt.request_id, 'request ID');
|
|
186
|
+
const participant = requireText(receipt.participant_id, 'participant ID');
|
|
187
|
+
const before = receipt.revision_before;
|
|
188
|
+
if (receipt.schema_version !== 'transition-receipt/2.0' || receipt.session_id !== session ||
|
|
189
|
+
receipt.activity_revision !== Number(match[1]) || Number(match[1]) < 1 || receipt.transition_id !== match[2] ||
|
|
190
|
+
typeof before !== 'number' || !Number.isSafeInteger(before) || before < 0 || receipt.revision_after !== before + 1 ||
|
|
191
|
+
requestId !== receipt.request_id || /[\\/<>:"|?*\p{Cc}]/u.test(requestId) ||
|
|
192
|
+
/[. ]$/.test(requestId) || /^(?:con|prn|aux|nul|com[1-9]|lpt[1-9])(?:\..*)?$/i.test(requestId)) {
|
|
193
|
+
throw new InputError(`Session transition identity mismatch: ${entry.name}`);
|
|
194
|
+
}
|
|
195
|
+
const requestPath = join(requests, `${requestId}.json`);
|
|
196
|
+
if (!lstatSync(requests, { throwIfNoEntry: false })?.isDirectory() ||
|
|
197
|
+
!lstatSync(requestPath, { throwIfNoEntry: false })?.isFile()) {
|
|
198
|
+
throw new InputError(`Session transition has no matching request receipt: ${entry.name}`);
|
|
199
|
+
}
|
|
200
|
+
const request = object(JSON.parse(readFileSync(requestPath, 'utf8')));
|
|
201
|
+
if (request.schema_version !== 'request-receipt/2.0' || request.request_id !== requestId ||
|
|
202
|
+
request.participant_id !== participant || request.transition_receipt_ref !== `receipts/transitions/${entry.name}` ||
|
|
203
|
+
typeof request.payload_hash !== 'string' || !/^sha256:[a-f0-9]{64}$/.test(request.payload_hash)) {
|
|
204
|
+
throw new InputError(`Invalid Session request receipt: ${requestId}`);
|
|
205
|
+
}
|
|
206
|
+
return [{ receipt, result: object(receipt.result), id: match[2] }];
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
export function* readCompletionReceipts(sourceRoot, session, transition) {
|
|
210
|
+
const sessions = join(sourceRoot, '.workflow', 'sessions');
|
|
211
|
+
if (!lstatSync(sessions, { throwIfNoEntry: false })?.isDirectory()) {
|
|
212
|
+
throw new InputError('Cannot locate the Maestro Sessions directory');
|
|
213
|
+
}
|
|
214
|
+
for (const entry of readdirSync(sessions, { withFileTypes: true })) {
|
|
215
|
+
if (!entry.isDirectory() || (session !== undefined && entry.name !== session))
|
|
216
|
+
continue;
|
|
217
|
+
const directory = join(sessions, entry.name);
|
|
218
|
+
for (const { receipt, result } of readSessionTransitions(directory)) {
|
|
219
|
+
if (receipt.target_type !== 'orchestration' || receipt.target_id !== entry.name ||
|
|
220
|
+
result.status !== 'completed' || (transition !== undefined && receipt.transition_id !== transition))
|
|
221
|
+
continue;
|
|
222
|
+
yield { directory, receipt };
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
function closeoutId(project, receipt) {
|
|
227
|
+
return createHash('sha256').update(JSON.stringify([project, receipt])).digest('hex');
|
|
228
|
+
}
|
|
229
|
+
function skillCompletionId(project, execution) {
|
|
230
|
+
return `skill-${closeoutId(project, execution)}`;
|
|
231
|
+
}
|
|
232
|
+
function ledgerPath(wiki) {
|
|
233
|
+
return join(wiki.root, '.agent-memory', 'closeout.db');
|
|
234
|
+
}
|
|
235
|
+
function closeoutColumns(db) {
|
|
236
|
+
return new Set(db.prepare('PRAGMA table_info(closeouts)').all().map(column => column.name));
|
|
237
|
+
}
|
|
238
|
+
function ensureCloseoutsTable(db) {
|
|
239
|
+
db.exec(`CREATE TABLE IF NOT EXISTS closeouts (
|
|
240
|
+
id TEXT PRIMARY KEY, payload_hash TEXT NOT NULL, candidates TEXT NOT NULL,
|
|
241
|
+
session_id TEXT, receipt_id TEXT
|
|
242
|
+
)`);
|
|
243
|
+
const columns = closeoutColumns(db);
|
|
244
|
+
if (!columns.has('session_id'))
|
|
245
|
+
addCloseoutColumn(db, 'session_id');
|
|
246
|
+
if (!columns.has('receipt_id'))
|
|
247
|
+
addCloseoutColumn(db, 'receipt_id');
|
|
248
|
+
}
|
|
249
|
+
function addCloseoutColumn(db, column) {
|
|
250
|
+
try {
|
|
251
|
+
db.exec(`ALTER TABLE closeouts ADD COLUMN ${column} TEXT`);
|
|
252
|
+
}
|
|
253
|
+
catch (error) {
|
|
254
|
+
if (!(error instanceof Error) || !/duplicate column name/i.test(error.message))
|
|
255
|
+
throw error;
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
export function readHarvest(wiki, project, receipt) {
|
|
259
|
+
const id = closeoutId(requireText(project, 'source project ID'), requireText(receipt, 'completion receipt ID'));
|
|
260
|
+
const path = ledgerPath(wiki);
|
|
261
|
+
if (!lstatSync(path, { throwIfNoEntry: false })?.isFile())
|
|
262
|
+
throw new NotFoundError('Completion has not been harvested');
|
|
263
|
+
const db = openDb(path, true);
|
|
264
|
+
try {
|
|
265
|
+
if (!db.prepare("SELECT 1 FROM sqlite_master WHERE name = 'closeouts' AND type = 'table'").get()) {
|
|
266
|
+
throw new NotFoundError('Completion has not been harvested');
|
|
267
|
+
}
|
|
268
|
+
const columns = closeoutColumns(db);
|
|
269
|
+
const metadata = columns.has('session_id') && columns.has('receipt_id') ? ', session_id, receipt_id' : '';
|
|
270
|
+
const row = db.prepare(`SELECT candidates${metadata} FROM closeouts WHERE id = ?`).get(id);
|
|
271
|
+
if (!row)
|
|
272
|
+
throw new NotFoundError('Completion has not been harvested');
|
|
273
|
+
return {
|
|
274
|
+
id,
|
|
275
|
+
candidates: JSON.parse(String(row.candidates)),
|
|
276
|
+
...(row.session_id ? { session_id: row.session_id } : {}),
|
|
277
|
+
...(row.receipt_id ? { receipt_id: row.receipt_id } : {}),
|
|
278
|
+
};
|
|
279
|
+
}
|
|
280
|
+
finally {
|
|
281
|
+
db.close();
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
export function recordSkillCompletion(wiki, project, input) {
|
|
285
|
+
project = requireText(project, 'source project ID');
|
|
286
|
+
const execution = requireText(input.execution, 'Skill execution ID');
|
|
287
|
+
const skill = requireText(input.skill, 'Skill ID');
|
|
288
|
+
const version = requireText(input.version, 'Skill version');
|
|
289
|
+
if (!terminalStatuses.has(input.status))
|
|
290
|
+
throw new InputError('Expected succeeded, failed, or cancelled Skill status');
|
|
291
|
+
if (maintenanceSkills.has(skill))
|
|
292
|
+
return { ignored: 'maintenance-skill' };
|
|
293
|
+
if (input.session !== undefined)
|
|
294
|
+
return { ignored: 'session-owned', session: requireText(input.session, 'Session ID') };
|
|
295
|
+
validateConversationMessages(input.messages);
|
|
296
|
+
const messages = input.messages.map(({ id, role, timestamp, content }) => ({ id, role, timestamp, content }));
|
|
297
|
+
const id = skillCompletionId(project, execution);
|
|
298
|
+
const payload = {
|
|
299
|
+
schema_version: 'skill-completion/1.0', id, execution_id: execution, skill_id: skill,
|
|
300
|
+
skill_version: version, status: input.status, messages,
|
|
301
|
+
...(input.knowledgeReads ? { knowledge_reads: validateKnowledgeReads(input.knowledgeReads) } : {}),
|
|
302
|
+
};
|
|
303
|
+
const normalized = JSON.stringify(payload);
|
|
304
|
+
const path = ledgerPath(wiki);
|
|
305
|
+
mkdirSync(dirname(path), { recursive: true });
|
|
306
|
+
const db = openDb(path);
|
|
307
|
+
try {
|
|
308
|
+
db.exec(`CREATE TABLE IF NOT EXISTS skill_completions (
|
|
309
|
+
id TEXT PRIMARY KEY, project TEXT NOT NULL, payload TEXT NOT NULL, recorded_at TEXT NOT NULL
|
|
310
|
+
)`);
|
|
311
|
+
return transaction(db, () => {
|
|
312
|
+
const row = db.prepare('SELECT payload, recorded_at FROM skill_completions WHERE id = ?').get(id);
|
|
313
|
+
if (row && row.payload !== normalized)
|
|
314
|
+
throw new InputError(`Skill completion changed: ${execution}`);
|
|
315
|
+
const recorded_at = row ? String(row.recorded_at) : new Date().toISOString();
|
|
316
|
+
if (!row)
|
|
317
|
+
db.prepare('INSERT INTO skill_completions VALUES (?, ?, ?, ?)').run(id, project, normalized, recorded_at);
|
|
318
|
+
return { receipt: { ...payload, recorded_at } };
|
|
319
|
+
});
|
|
320
|
+
}
|
|
321
|
+
finally {
|
|
322
|
+
db.close();
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
export function readSkillCompletions(wiki, project, id) {
|
|
326
|
+
const path = ledgerPath(wiki);
|
|
327
|
+
if (!lstatSync(path, { throwIfNoEntry: false })?.isFile())
|
|
328
|
+
return [];
|
|
329
|
+
const db = openDb(path, true);
|
|
330
|
+
try {
|
|
331
|
+
if (!db.prepare("SELECT 1 FROM sqlite_master WHERE name = 'skill_completions' AND type = 'table'").get())
|
|
332
|
+
return [];
|
|
333
|
+
const columns = 'SELECT id, payload, recorded_at FROM skill_completions WHERE project = ?';
|
|
334
|
+
const receipts = id === undefined
|
|
335
|
+
? db.prepare(columns + ' ORDER BY recorded_at, id').all(project)
|
|
336
|
+
: db.prepare(columns + ' AND id = ?').all(project, id);
|
|
337
|
+
return receipts.map(row => ({ id: String(row.id), receipt: {
|
|
338
|
+
...object(JSON.parse(String(row.payload))), recorded_at: row.recorded_at,
|
|
339
|
+
} }));
|
|
340
|
+
}
|
|
341
|
+
finally {
|
|
342
|
+
db.close();
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
export function readSkillExecution(wiki, project, execution) {
|
|
346
|
+
const id = skillCompletionId(project, execution);
|
|
347
|
+
const saved = readSkillCompletions(wiki, project, id)[0];
|
|
348
|
+
if (!saved)
|
|
349
|
+
throw new NotFoundError('Standalone Skill completion receipt not found');
|
|
350
|
+
const completion = parseReceipt(saved.receipt);
|
|
351
|
+
if (completion.id !== id || completion.session !== execution || !completion.skill) {
|
|
352
|
+
throw new InputError('Standalone Skill receipt does not match the recorded execution');
|
|
353
|
+
}
|
|
354
|
+
return { ...completion, skill: completion.skill };
|
|
355
|
+
}
|
|
356
|
+
export async function harvestCompletion(wiki, project, value, model, sessionDirectory) {
|
|
357
|
+
const completion = parseReceipt(value);
|
|
358
|
+
const receipt = object(value);
|
|
359
|
+
if (receipt.schema_version === 'transition-receipt/2.0') {
|
|
360
|
+
const refs = object(receipt.result).evolve_transcript_refs;
|
|
361
|
+
if (refs !== undefined) {
|
|
362
|
+
if (!sessionDirectory)
|
|
363
|
+
throw new InputError('Use closeout session to resolve anchored transcript evidence from the Maestro project');
|
|
364
|
+
completion.messages.push(...readTranscriptSnapshots(sessionDirectory, readCompletionTranscriptRefs(refs)));
|
|
365
|
+
}
|
|
366
|
+
if (sessionDirectory)
|
|
367
|
+
appendRunEvidence(completion, sessionDirectory);
|
|
368
|
+
}
|
|
369
|
+
return harvestResolvedCompletion(wiki, project, completion, model);
|
|
370
|
+
}
|
|
371
|
+
async function harvestResolvedCompletion(wiki, project, completion, model) {
|
|
372
|
+
project = requireText(project, 'source project ID');
|
|
373
|
+
if (completion.skill && maintenanceSkills.has(completion.skill.id)) {
|
|
374
|
+
throw new InputError('Maintenance Skill completions are excluded from harvesting');
|
|
375
|
+
}
|
|
376
|
+
if (!Number.isFinite(Date.parse(completion.timestamp)))
|
|
377
|
+
throw new InputError('Invalid completion time');
|
|
378
|
+
const identity = closeoutId(project, completion.id);
|
|
379
|
+
const payloadHash = createHash('sha256').update(JSON.stringify(completion)).digest('hex');
|
|
380
|
+
const ledger = ledgerPath(wiki);
|
|
381
|
+
mkdirSync(dirname(ledger), { recursive: true });
|
|
382
|
+
const db = openDb(ledger);
|
|
383
|
+
try {
|
|
384
|
+
ensureCloseoutsTable(db);
|
|
385
|
+
const lookup = db.prepare('SELECT payload_hash, candidates FROM closeouts WHERE id = ?');
|
|
386
|
+
const metadata = { session_id: completion.session, receipt_id: completion.id };
|
|
387
|
+
const previous = () => {
|
|
388
|
+
const row = lookup.get(identity);
|
|
389
|
+
if (!row)
|
|
390
|
+
return undefined;
|
|
391
|
+
if (row.payload_hash !== payloadHash)
|
|
392
|
+
throw new InputError(`Completion receipt changed: ${completion.id}`);
|
|
393
|
+
return JSON.parse(String(row.candidates));
|
|
394
|
+
};
|
|
395
|
+
const saved = previous();
|
|
396
|
+
if (saved)
|
|
397
|
+
return { id: identity, replayed: true, candidates: saved, ...metadata };
|
|
398
|
+
const extracted = completion.messages.length ? await extractMemoryInputs(completion.messages, {
|
|
399
|
+
llm: model(), session: completion.session, agentMemoryPrompt: buildCloseoutHarvestPrompt(),
|
|
400
|
+
}) : [];
|
|
401
|
+
const proposals = [];
|
|
402
|
+
for (const item of extracted) {
|
|
403
|
+
if (!item.sourceMessageIds?.length)
|
|
404
|
+
continue;
|
|
405
|
+
proposals.push({
|
|
406
|
+
id: createHash('sha256').update(JSON.stringify([identity, item.id])).digest('hex'),
|
|
407
|
+
content: item.content,
|
|
408
|
+
sources: item.sourceMessageIds.map(source => `receipt:${project}:${completion.id}#${source}`),
|
|
409
|
+
related: wiki.getEntriesByExactBody(item.content).length === 0 ? await compareReferences(wiki, item.content, model) : undefined,
|
|
410
|
+
});
|
|
411
|
+
}
|
|
412
|
+
const result = transaction(db, () => {
|
|
413
|
+
const replay = previous();
|
|
414
|
+
if (replay)
|
|
415
|
+
return { id: identity, replayed: true, candidates: replay };
|
|
416
|
+
const candidates = proposals.map(({ related, ...proposal }) => {
|
|
417
|
+
const exact = wiki.getEntriesByExactBody(proposal.content);
|
|
418
|
+
return {
|
|
419
|
+
...proposal,
|
|
420
|
+
matched_entry: exact.length === 1 ? exact[0].id : null,
|
|
421
|
+
...(exact.length > 1 || related ? {
|
|
422
|
+
related_entries: [
|
|
423
|
+
...(exact.length > 1 ? exact.map(({ id, sources }) => ({ id, sources, relation: 'same_content' })) : []),
|
|
424
|
+
...(related ?? []).filter(entry => !exact.some(hit => hit.id === entry.id)),
|
|
425
|
+
],
|
|
426
|
+
} : {}),
|
|
427
|
+
};
|
|
428
|
+
});
|
|
429
|
+
const pending = candidates.filter(candidate => !appendReferenceSources(wiki, candidate));
|
|
430
|
+
if (pending.length !== candidates.length)
|
|
431
|
+
wiki.build();
|
|
432
|
+
db.prepare('INSERT INTO closeouts (id, payload_hash, candidates, session_id, receipt_id) VALUES (?, ?, ?, ?, ?)')
|
|
433
|
+
.run(identity, payloadHash, JSON.stringify(pending), metadata.session_id, metadata.receipt_id);
|
|
434
|
+
return { id: identity, replayed: false, candidates: pending, ...metadata };
|
|
435
|
+
});
|
|
436
|
+
return result;
|
|
437
|
+
}
|
|
438
|
+
finally {
|
|
439
|
+
db.close();
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
export function readCloseoutCandidate(wiki, closeoutId, candidateId) {
|
|
443
|
+
if (!/^[a-f0-9]{64}$/.test(closeoutId) || !/^[a-f0-9]{64}$/.test(candidateId)) {
|
|
444
|
+
throw new InputError('Expected exact closeout and candidate IDs');
|
|
445
|
+
}
|
|
446
|
+
const ledger = ledgerPath(wiki);
|
|
447
|
+
const db = openDb(ledger, true);
|
|
448
|
+
let candidate;
|
|
449
|
+
try {
|
|
450
|
+
const row = db.prepare('SELECT candidates FROM closeouts WHERE id = ?').get(closeoutId);
|
|
451
|
+
if (row)
|
|
452
|
+
candidate = JSON.parse(String(row.candidates)).find(item => item.id === candidateId);
|
|
453
|
+
}
|
|
454
|
+
finally {
|
|
455
|
+
db.close();
|
|
456
|
+
}
|
|
457
|
+
if (!candidate)
|
|
458
|
+
throw new InputError('Candidate does not belong to the selected closeout');
|
|
459
|
+
return candidate;
|
|
460
|
+
}
|
|
461
|
+
export function publishReference(wiki, closeoutId, candidateId, title) {
|
|
462
|
+
title = requireText(title, 'reference title');
|
|
463
|
+
const candidate = readCloseoutCandidate(wiki, closeoutId, candidateId);
|
|
464
|
+
const id = `entries/${candidateId}`;
|
|
465
|
+
if (candidate.matched_entry || candidate.related_entries?.length) {
|
|
466
|
+
throw new InputError('Candidate has related Wiki entries; review the relationship and stage a Wiki change');
|
|
467
|
+
}
|
|
468
|
+
const proposal = proposeWikiChange(wiki, {
|
|
469
|
+
operation: 'create', entry: id, title, mode: 'reference', body: candidate.content,
|
|
470
|
+
}, [], { closeout: closeoutId, id: candidate.id, sources: candidate.sources, related: [] });
|
|
471
|
+
const applied = applyWikiChange(wiki, proposal.id);
|
|
472
|
+
return { id, replayed: applied.replayed };
|
|
473
|
+
}
|
package/dist/code.d.ts
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { Edge } from '@colbymchenry/codegraph';
|
|
2
|
+
export declare class CodeGraph {
|
|
3
|
+
readonly root: string;
|
|
4
|
+
private readonly autoRefresh;
|
|
5
|
+
constructor(root: string, { autoRefresh }?: {
|
|
6
|
+
autoRefresh?: boolean;
|
|
7
|
+
});
|
|
8
|
+
static hasIndex(root: string): boolean;
|
|
9
|
+
build(): Promise<{
|
|
10
|
+
filesErrored: number;
|
|
11
|
+
errors: import("@colbymchenry/codegraph").ExtractionError[];
|
|
12
|
+
nodeCount: number;
|
|
13
|
+
edgeCount: number;
|
|
14
|
+
fileCount: number;
|
|
15
|
+
nodesByKind: Record<import("@colbymchenry/codegraph").NodeKind, number>;
|
|
16
|
+
edgesByKind: Record<import("@colbymchenry/codegraph").EdgeKind, number>;
|
|
17
|
+
filesByLanguage: Record<import("@colbymchenry/codegraph").Language, number>;
|
|
18
|
+
dbSizeBytes: number;
|
|
19
|
+
lastUpdated: number;
|
|
20
|
+
}>;
|
|
21
|
+
sync(): Promise<import("@colbymchenry/codegraph").SyncResult>;
|
|
22
|
+
refresh(): Promise<void>;
|
|
23
|
+
search(query: string, limit?: number): Promise<import("@colbymchenry/codegraph").SearchResult[]>;
|
|
24
|
+
neighbors(id: string, direction: 'callers' | 'callees', depth?: number): Promise<{
|
|
25
|
+
node: import("@colbymchenry/codegraph").Node;
|
|
26
|
+
edge: Edge;
|
|
27
|
+
}[]>;
|
|
28
|
+
trace(from: string, to: string, edgeKinds?: Edge['kind'][]): Promise<{
|
|
29
|
+
node: import("@colbymchenry/codegraph").Node;
|
|
30
|
+
edge: Edge | null;
|
|
31
|
+
}[] | null>;
|
|
32
|
+
private requireNode;
|
|
33
|
+
private indexAll;
|
|
34
|
+
private syncGraph;
|
|
35
|
+
private read;
|
|
36
|
+
private withFreshGraph;
|
|
37
|
+
private withGraph;
|
|
38
|
+
private write;
|
|
39
|
+
}
|
package/dist/code.js
ADDED
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
// Adapts TencentDB Agent Memory's MemoryKnowledge code graph bridge (MIT).
|
|
2
|
+
import { mkdirSync, realpathSync, statSync } from 'node:fs';
|
|
3
|
+
import { createRequire } from 'node:module';
|
|
4
|
+
import { join } from 'node:path';
|
|
5
|
+
import { InputError, NotFoundError, requireText, searchLimit } from './common.js';
|
|
6
|
+
const require = createRequire(import.meta.url);
|
|
7
|
+
const writes = new Map();
|
|
8
|
+
function sdk() {
|
|
9
|
+
return require('@colbymchenry/codegraph');
|
|
10
|
+
}
|
|
11
|
+
export class CodeGraph {
|
|
12
|
+
root;
|
|
13
|
+
autoRefresh;
|
|
14
|
+
constructor(root, { autoRefresh = false } = {}) {
|
|
15
|
+
this.root = realpathSync(root);
|
|
16
|
+
if (!statSync(this.root).isDirectory())
|
|
17
|
+
throw new InputError('Code root must be a directory');
|
|
18
|
+
this.autoRefresh = autoRefresh;
|
|
19
|
+
}
|
|
20
|
+
static hasIndex(root) {
|
|
21
|
+
return sdk().isInitialized(root);
|
|
22
|
+
}
|
|
23
|
+
async build() {
|
|
24
|
+
return this.write(() => this.withGraph(async (graph, created) => {
|
|
25
|
+
const result = await this.indexAll(graph);
|
|
26
|
+
// SDK 全量索引会保留已删除文件的节点,复用增量扫描对齐文件系统。
|
|
27
|
+
if (!created)
|
|
28
|
+
await this.syncGraph(graph);
|
|
29
|
+
return { ...graph.getStats(), filesErrored: result.filesErrored, errors: result.errors };
|
|
30
|
+
}, true));
|
|
31
|
+
}
|
|
32
|
+
async sync() {
|
|
33
|
+
return this.write(() => this.withGraph(graph => this.syncGraph(graph)));
|
|
34
|
+
}
|
|
35
|
+
async refresh() {
|
|
36
|
+
await this.withFreshGraph(() => undefined);
|
|
37
|
+
}
|
|
38
|
+
async search(query, limit) {
|
|
39
|
+
const text = requireText(query, 'query');
|
|
40
|
+
const maxResults = searchLimit(limit);
|
|
41
|
+
return this.read(graph => graph.searchNodes(text, { limit: maxResults }));
|
|
42
|
+
}
|
|
43
|
+
async neighbors(id, direction, depth = 1) {
|
|
44
|
+
if (direction !== 'callers' && direction !== 'callees') {
|
|
45
|
+
throw new InputError('direction must be callers or callees');
|
|
46
|
+
}
|
|
47
|
+
if (!Number.isInteger(depth) || depth < 1 || depth > 5) {
|
|
48
|
+
throw new InputError('depth must be an integer between 1 and 5');
|
|
49
|
+
}
|
|
50
|
+
return this.read(graph => {
|
|
51
|
+
this.requireNode(graph, id);
|
|
52
|
+
return direction === 'callers' ? graph.getCallers(id, depth) : graph.getCallees(id, depth);
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
async trace(from, to, edgeKinds) {
|
|
56
|
+
return this.read(graph => {
|
|
57
|
+
this.requireNode(graph, from);
|
|
58
|
+
this.requireNode(graph, to);
|
|
59
|
+
return graph.findPath(from, to, edgeKinds);
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
requireNode(graph, id) {
|
|
63
|
+
if (!graph.getNode(id))
|
|
64
|
+
throw new NotFoundError(`Code symbol not found: ${id}`);
|
|
65
|
+
}
|
|
66
|
+
async indexAll(graph) {
|
|
67
|
+
const result = await graph.indexAll();
|
|
68
|
+
if (!result.success)
|
|
69
|
+
throw new Error(result.errors.map(error => error.message).join('\n') || 'Code indexing failed');
|
|
70
|
+
return result;
|
|
71
|
+
}
|
|
72
|
+
async syncGraph(graph) {
|
|
73
|
+
// SDK 拿不到文件锁时会直接返回空结果,扫描回调用于区分正常空项目。
|
|
74
|
+
let started = false;
|
|
75
|
+
const result = await graph.sync({ onProgress: () => { started = true; } });
|
|
76
|
+
if (!started)
|
|
77
|
+
throw new Error('CodeGraph index is locked by another process');
|
|
78
|
+
return result;
|
|
79
|
+
}
|
|
80
|
+
read(run) {
|
|
81
|
+
return this.autoRefresh ? this.withFreshGraph(run) : this.withGraph(run);
|
|
82
|
+
}
|
|
83
|
+
withFreshGraph(run) {
|
|
84
|
+
return this.write(() => this.withGraph(async (graph, created) => {
|
|
85
|
+
if (created)
|
|
86
|
+
await this.indexAll(graph);
|
|
87
|
+
else
|
|
88
|
+
await this.syncGraph(graph);
|
|
89
|
+
return run(graph);
|
|
90
|
+
}, true));
|
|
91
|
+
}
|
|
92
|
+
async withGraph(run, initialize = false) {
|
|
93
|
+
const { CodeGraph, FileLock, getCodeGraphDir, isInitialized } = sdk();
|
|
94
|
+
let created;
|
|
95
|
+
if (initialize) {
|
|
96
|
+
const dir = getCodeGraphDir(this.root);
|
|
97
|
+
mkdirSync(dir, { recursive: true });
|
|
98
|
+
// 数据库创建用独立短锁,索引和增量同步由 SDK 自己加锁。
|
|
99
|
+
created = new FileLock(join(dir, 'evolve-init.lock')).withLock(() => isInitialized(this.root) ? undefined : CodeGraph.initSync(this.root));
|
|
100
|
+
}
|
|
101
|
+
else if (!isInitialized(this.root)) {
|
|
102
|
+
throw new NotFoundError('Code index missing. Run code build first.');
|
|
103
|
+
}
|
|
104
|
+
const graph = created ?? await CodeGraph.open(this.root);
|
|
105
|
+
try {
|
|
106
|
+
return await run(graph, created !== undefined);
|
|
107
|
+
}
|
|
108
|
+
finally {
|
|
109
|
+
graph.close();
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
async write(run) {
|
|
113
|
+
const previous = writes.get(this.root) ?? Promise.resolve();
|
|
114
|
+
const current = previous.then(run, run);
|
|
115
|
+
writes.set(this.root, current);
|
|
116
|
+
try {
|
|
117
|
+
return await current;
|
|
118
|
+
}
|
|
119
|
+
finally {
|
|
120
|
+
if (writes.get(this.root) === current)
|
|
121
|
+
writes.delete(this.root);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { MemoryStore } from './memory.js';
|
|
2
|
+
import type { LlmClient } from './upstream/llm.js';
|
|
3
|
+
export declare function installCodexMemoryHook(root: string): {
|
|
4
|
+
path: string;
|
|
5
|
+
changed: boolean;
|
|
6
|
+
};
|
|
7
|
+
interface ImportOptions {
|
|
8
|
+
root: string;
|
|
9
|
+
memory: MemoryStore;
|
|
10
|
+
model: () => LlmClient;
|
|
11
|
+
session?: string;
|
|
12
|
+
lastAssistant?: string;
|
|
13
|
+
}
|
|
14
|
+
export declare function handleCodexMemoryHook(input: unknown, options: ImportOptions): Promise<void>;
|
|
15
|
+
export declare function syncCodexMemory(options: ImportOptions): Promise<{
|
|
16
|
+
sessions: number;
|
|
17
|
+
processed: number;
|
|
18
|
+
remembered: number;
|
|
19
|
+
failures: {
|
|
20
|
+
path: string;
|
|
21
|
+
error: string;
|
|
22
|
+
}[];
|
|
23
|
+
}>;
|
|
24
|
+
export {};
|