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
|
@@ -0,0 +1,432 @@
|
|
|
1
|
+
import { createReadStream, existsSync, readdirSync, realpathSync, statSync } from 'node:fs';
|
|
2
|
+
import { homedir } from 'node:os';
|
|
3
|
+
import { basename, isAbsolute, join, relative, resolve, sep } from 'node:path';
|
|
4
|
+
import { fileURLToPath } from 'node:url';
|
|
5
|
+
import { InputError, NotFoundError, openDb, pageOffset, pagination, searchLimit } from './common.js';
|
|
6
|
+
import { memoryHosts } from './memory-config.js';
|
|
7
|
+
function object(value) {
|
|
8
|
+
return value && typeof value === 'object' && !Array.isArray(value) ? value : undefined;
|
|
9
|
+
}
|
|
10
|
+
function projectContains(root, cwd) {
|
|
11
|
+
if (typeof cwd !== 'string' || !isAbsolute(cwd))
|
|
12
|
+
return false;
|
|
13
|
+
const path = relative(root, existsSync(cwd) ? realpathSync(cwd) : cwd);
|
|
14
|
+
return path !== '..' && !path.startsWith(`..${sep}`) && !isAbsolute(path);
|
|
15
|
+
}
|
|
16
|
+
async function* transcriptRows(path, from, size) {
|
|
17
|
+
if (from >= size)
|
|
18
|
+
return;
|
|
19
|
+
let offset = from;
|
|
20
|
+
let parts = [];
|
|
21
|
+
const stream = createReadStream(path, { start: from, end: size - 1 });
|
|
22
|
+
for await (const chunk of stream) {
|
|
23
|
+
let start = 0;
|
|
24
|
+
for (let end = chunk.indexOf(10, start); end >= 0; end = chunk.indexOf(10, start)) {
|
|
25
|
+
parts.push(chunk.subarray(start, end));
|
|
26
|
+
const line = Buffer.concat(parts);
|
|
27
|
+
const text = line.toString('utf8').replace(/^\uFEFF/, '');
|
|
28
|
+
const rowOffset = offset;
|
|
29
|
+
offset += line.length + 1;
|
|
30
|
+
parts = [];
|
|
31
|
+
start = end + 1;
|
|
32
|
+
if (!text.trim())
|
|
33
|
+
continue;
|
|
34
|
+
let row;
|
|
35
|
+
try {
|
|
36
|
+
row = object(JSON.parse(text));
|
|
37
|
+
}
|
|
38
|
+
catch {
|
|
39
|
+
throw new InputError(`Invalid transcript JSON at byte ${rowOffset}`);
|
|
40
|
+
}
|
|
41
|
+
yield { row, start: rowOffset, end: offset };
|
|
42
|
+
}
|
|
43
|
+
if (start < chunk.length)
|
|
44
|
+
parts.push(chunk.subarray(start));
|
|
45
|
+
}
|
|
46
|
+
// 活跃会话可能还在写入最后一行,下一次从已提交的位置重新读取。
|
|
47
|
+
}
|
|
48
|
+
function readableText(value) {
|
|
49
|
+
return typeof value === 'string' && value.trim().length > 0;
|
|
50
|
+
}
|
|
51
|
+
function messageText(parts, kind) {
|
|
52
|
+
if (!Array.isArray(parts))
|
|
53
|
+
return '';
|
|
54
|
+
return parts.flatMap(part => {
|
|
55
|
+
if (part?.type !== kind || !readableText(part.text))
|
|
56
|
+
return [];
|
|
57
|
+
if (kind === 'input_text' && /^(?:# AGENTS\.md instructions for |<(?:environment_context|recommended_plugins)>)/.test(part.text.trimStart()))
|
|
58
|
+
return [];
|
|
59
|
+
return [part.text];
|
|
60
|
+
}).join('\n');
|
|
61
|
+
}
|
|
62
|
+
async function codexSession({ path, session }, root, size) {
|
|
63
|
+
for await (const { row } of transcriptRows(path, 0, size)) {
|
|
64
|
+
const header = row?.type === 'session_meta' ? object(row.payload) : undefined;
|
|
65
|
+
if (header && readableText(header.id) && (session === undefined || session === header.id) &&
|
|
66
|
+
projectContains(root, header.cwd) && object(header.source)?.subagent === undefined)
|
|
67
|
+
return header.id;
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
function codexMessage({ row, start }, session, path) {
|
|
72
|
+
const payload = object(row?.payload);
|
|
73
|
+
if (row?.type !== 'response_item' || payload?.type !== 'message' || !readableText(row.timestamp))
|
|
74
|
+
return;
|
|
75
|
+
const role = payload.role;
|
|
76
|
+
if (role !== 'user' && role !== 'assistant')
|
|
77
|
+
return;
|
|
78
|
+
const content = messageText(payload.content, role === 'user' ? 'input_text' : 'output_text');
|
|
79
|
+
if (content)
|
|
80
|
+
return { id: `codex:${session}:${start}`, role, timestamp: row.timestamp, content, location: { path, byteOffset: start } };
|
|
81
|
+
}
|
|
82
|
+
function codexCompletedMessage({ row, start }, session, path) {
|
|
83
|
+
const payload = object(row?.payload);
|
|
84
|
+
if (row?.type === 'event_msg' && payload?.type === 'task_complete' && !payload.error &&
|
|
85
|
+
readableText(payload.last_agent_message) && readableText(row.timestamp)) {
|
|
86
|
+
return { id: `codex:${session}:${start}`, role: 'assistant', timestamp: row.timestamp,
|
|
87
|
+
content: payload.last_agent_message, location: { path, byteOffset: start } };
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
async function* codexTurns({ path, lastAssistant }, session, offset, size) {
|
|
91
|
+
let messages = [];
|
|
92
|
+
for await (const entry of transcriptRows(path, offset, size)) {
|
|
93
|
+
const payload = object(entry.row?.payload);
|
|
94
|
+
if (entry.row?.type === 'event_msg' && (payload?.type === 'task_started' || payload?.type === 'turn_aborted'))
|
|
95
|
+
messages = [];
|
|
96
|
+
const item = codexMessage(entry, session, path);
|
|
97
|
+
if (item?.role === 'user') {
|
|
98
|
+
messages.push(item);
|
|
99
|
+
continue;
|
|
100
|
+
}
|
|
101
|
+
const final = item && payload?.phase !== 'commentary' && (payload?.phase === 'final_answer' || item.content === lastAssistant)
|
|
102
|
+
? item : codexCompletedMessage(entry, session, path);
|
|
103
|
+
if (!final || !messages.length)
|
|
104
|
+
continue;
|
|
105
|
+
messages.push(final);
|
|
106
|
+
yield { end: entry.end, messages };
|
|
107
|
+
messages = [];
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
function claudeChat(row) {
|
|
111
|
+
if (!row || (row.type !== 'user' && row.type !== 'assistant') ||
|
|
112
|
+
row.isSidechain || row.isMeta || row.isCompactSummary || row.isApiErrorMessage)
|
|
113
|
+
return;
|
|
114
|
+
const message = object(row.message);
|
|
115
|
+
if (message?.role === row.type)
|
|
116
|
+
return { role: row.type, message };
|
|
117
|
+
}
|
|
118
|
+
async function claudeSession({ path, session }, root, size) {
|
|
119
|
+
for await (const { row } of transcriptRows(path, 0, size)) {
|
|
120
|
+
if (!row || !claudeChat(row) || !readableText(row.sessionId) || !readableText(row.cwd))
|
|
121
|
+
continue;
|
|
122
|
+
if ((session === undefined || row.sessionId === session) && projectContains(root, row.cwd))
|
|
123
|
+
return row.sessionId;
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
function claudeMessage({ row, start }, session, path) {
|
|
128
|
+
const chat = row?.sessionId === session ? claudeChat(row) : undefined;
|
|
129
|
+
if (!chat || !readableText(row?.timestamp))
|
|
130
|
+
return;
|
|
131
|
+
const parts = chat.message.content;
|
|
132
|
+
const content = typeof parts === 'string' ? parts : messageText(parts, 'text');
|
|
133
|
+
const hasToolData = Array.isArray(parts) && parts.some(part => ['tool_result', 'tool_use', 'server_tool_use'].includes(part?.type));
|
|
134
|
+
if (chat.role === 'user' && (hasToolData || !content.trim()))
|
|
135
|
+
return;
|
|
136
|
+
const id = `claude:${session}:${readableText(row.uuid) ? row.uuid : start}`;
|
|
137
|
+
return { item: { id, role: chat.role, timestamp: row.timestamp, content, location: { path, byteOffset: start } },
|
|
138
|
+
key: chat.message.id, stopReason: chat.message.stop_reason, hasToolData };
|
|
139
|
+
}
|
|
140
|
+
async function* claudeTurns({ path, lastAssistant }, session, offset, size) {
|
|
141
|
+
let users = [];
|
|
142
|
+
let reply;
|
|
143
|
+
const ready = () => reply?.complete || (reply && reply.messages.map(message => message.content).join('\n') === lastAssistant);
|
|
144
|
+
for await (const entry of transcriptRows(path, offset, size)) {
|
|
145
|
+
const chat = claudeMessage(entry, session, path);
|
|
146
|
+
if (!chat)
|
|
147
|
+
continue;
|
|
148
|
+
const { item, key, stopReason, hasToolData } = chat;
|
|
149
|
+
if (item.role === 'user' || (reply && reply.key !== key)) {
|
|
150
|
+
if (reply && users.length && ready()) {
|
|
151
|
+
yield { end: reply.end, messages: [...users, ...reply.messages] };
|
|
152
|
+
users = [];
|
|
153
|
+
}
|
|
154
|
+
reply = undefined;
|
|
155
|
+
}
|
|
156
|
+
if (item.role === 'user') {
|
|
157
|
+
users.push(item);
|
|
158
|
+
continue;
|
|
159
|
+
}
|
|
160
|
+
if (hasToolData || stopReason === 'tool_use') {
|
|
161
|
+
reply = undefined;
|
|
162
|
+
continue;
|
|
163
|
+
}
|
|
164
|
+
if (!item.content.trim() || !users.length)
|
|
165
|
+
continue;
|
|
166
|
+
reply ??= { key, messages: [], end: entry.end, complete: false };
|
|
167
|
+
reply.messages.push(item);
|
|
168
|
+
reply.end = entry.end;
|
|
169
|
+
reply.complete ||= ['end_turn', 'stop_sequence'].includes(String(stopReason));
|
|
170
|
+
}
|
|
171
|
+
if (reply && users.length && ready())
|
|
172
|
+
yield { end: reply.end, messages: [...users, ...reply.messages] };
|
|
173
|
+
}
|
|
174
|
+
function agyMessage({ row, start }, session, path) {
|
|
175
|
+
if (!row || typeof row.step_index !== 'number' || !Number.isSafeInteger(row.step_index) ||
|
|
176
|
+
row.status !== 'DONE' || !readableText(row.created_at) || !readableText(row.content))
|
|
177
|
+
return;
|
|
178
|
+
const id = `agy:${session}:${row.step_index}`;
|
|
179
|
+
const location = { path, byteOffset: start };
|
|
180
|
+
if (row.type === 'USER_INPUT' && row.source === 'USER_EXPLICIT') {
|
|
181
|
+
// Antigravity 的完整日志会把宿主附加说明拼在用户正文之外。
|
|
182
|
+
const wrapped = /^<USER_REQUEST>\r?\n([\s\S]*?)\r?\n<\/USER_REQUEST>(?=\s*(?:<(?:ADDITIONAL_METADATA|USER_SETTINGS_CHANGE)>|$))/.exec(row.content);
|
|
183
|
+
const content = wrapped?.[1] ?? row.content;
|
|
184
|
+
if (readableText(content))
|
|
185
|
+
return { step: row.step_index, hasToolData: false,
|
|
186
|
+
item: { id, role: 'user', timestamp: row.created_at, content, location } };
|
|
187
|
+
}
|
|
188
|
+
else if (row.type === 'PLANNER_RESPONSE' && row.source === 'MODEL') {
|
|
189
|
+
return { step: row.step_index, hasToolData: Array.isArray(row.tool_calls) && row.tool_calls.length > 0,
|
|
190
|
+
item: { id, role: 'assistant', timestamp: row.created_at, content: row.content, location } };
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
async function* agyTurns({ path }, session, offset, size) {
|
|
194
|
+
let messages = [];
|
|
195
|
+
for await (const entry of transcriptRows(path, 0, size)) {
|
|
196
|
+
const chat = agyMessage(entry, session, path);
|
|
197
|
+
if (!chat || chat.step < offset)
|
|
198
|
+
continue;
|
|
199
|
+
if (chat.item.role === 'user')
|
|
200
|
+
messages.push(chat.item);
|
|
201
|
+
else if (messages.length && !chat.hasToolData) {
|
|
202
|
+
messages.push(chat.item);
|
|
203
|
+
yield { end: chat.step + 1, messages };
|
|
204
|
+
messages = [];
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
const turnReaders = { codex: codexTurns, claude: claudeTurns, agy: agyTurns };
|
|
209
|
+
async function importTranscript(host, transcript, { root, memory, model }) {
|
|
210
|
+
const info = statSync(transcript.path);
|
|
211
|
+
if (!info.isFile())
|
|
212
|
+
throw new InputError('Transcript must be a file');
|
|
213
|
+
const session = host === 'codex' ? await codexSession(transcript, root, info.size)
|
|
214
|
+
: host === 'claude' ? await claudeSession(transcript, root, info.size) : transcript.session;
|
|
215
|
+
if (!session)
|
|
216
|
+
return;
|
|
217
|
+
let offset = memory.extractionOffset(host, session);
|
|
218
|
+
if (host !== 'agy' && offset > info.size)
|
|
219
|
+
throw new InputError('Transcript is shorter than its saved extraction offset');
|
|
220
|
+
let remembered = 0;
|
|
221
|
+
let processed = 0;
|
|
222
|
+
for await (const turn of turnReaders[host](transcript, session, offset, info.size)) {
|
|
223
|
+
if (memory.extractionOffset(host, session) === offset) {
|
|
224
|
+
const records = await memory.extractIncremental(turn.messages, {
|
|
225
|
+
source: host, from: offset, to: turn.end, llm: model(), session, mode: 'code',
|
|
226
|
+
});
|
|
227
|
+
if (records) {
|
|
228
|
+
remembered += records.length;
|
|
229
|
+
processed++;
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
offset = turn.end;
|
|
233
|
+
}
|
|
234
|
+
return { session, processed, remembered };
|
|
235
|
+
}
|
|
236
|
+
export async function handleMemoryHook(host, input, options) {
|
|
237
|
+
const event = object(input);
|
|
238
|
+
const root = realpathSync(options.root);
|
|
239
|
+
if (host === 'agy') {
|
|
240
|
+
if (readableText(event?.conversationId) && readableText(event.transcriptPath) && !event.error &&
|
|
241
|
+
projectContains(root, event.cwd ?? (Array.isArray(event.workspacePaths) ? event.workspacePaths[0] : undefined))) {
|
|
242
|
+
await importTranscript(host, { path: event.transcriptPath, session: event.conversationId }, { ...options, root });
|
|
243
|
+
}
|
|
244
|
+
return { decision: 'stop' };
|
|
245
|
+
}
|
|
246
|
+
if (event?.hook_event_name === 'Stop' && readableText(event.transcript_path) && readableText(event.session_id) &&
|
|
247
|
+
projectContains(root, event.cwd)) {
|
|
248
|
+
await importTranscript(host, { path: event.transcript_path, session: event.session_id,
|
|
249
|
+
lastAssistant: readableText(event.last_assistant_message) ? event.last_assistant_message : undefined }, { ...options, root });
|
|
250
|
+
}
|
|
251
|
+
return {};
|
|
252
|
+
}
|
|
253
|
+
function workspacePath(uri) {
|
|
254
|
+
if (!uri.startsWith('file:'))
|
|
255
|
+
return;
|
|
256
|
+
try {
|
|
257
|
+
return fileURLToPath(uri);
|
|
258
|
+
}
|
|
259
|
+
catch (error) {
|
|
260
|
+
if (!(error instanceof TypeError))
|
|
261
|
+
throw error;
|
|
262
|
+
// 宿主可能保留其他平台上的路径,当前系统只能导入能解析的工作区。
|
|
263
|
+
return;
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
function* agyTranscripts(root, session, full) {
|
|
267
|
+
const seen = new Set();
|
|
268
|
+
for (const dirName of ['antigravity-cli', 'antigravity']) {
|
|
269
|
+
const home = join(homedir(), '.gemini', dirName);
|
|
270
|
+
const index = join(home, 'conversation_summaries.db');
|
|
271
|
+
if (!existsSync(index))
|
|
272
|
+
continue;
|
|
273
|
+
const db = openDb(index, true);
|
|
274
|
+
try {
|
|
275
|
+
const select = db.prepare(`SELECT conversation_id, workspace_uris FROM conversation_summaries
|
|
276
|
+
WHERE coalesce(parent_conversation_id, '') = ''${session === undefined ? '' : ' AND conversation_id = ?'}`);
|
|
277
|
+
for (const row of select.iterate(...(session === undefined ? [] : [session]))) {
|
|
278
|
+
const { conversation_id: id, workspace_uris: raw } = row;
|
|
279
|
+
if (typeof id !== 'string' || !/^[\w-]+$/.test(id) || seen.has(id) || !readableText(raw))
|
|
280
|
+
continue;
|
|
281
|
+
const uris = JSON.parse(raw);
|
|
282
|
+
if (!Array.isArray(uris) || typeof uris[0] !== 'string' || !projectContains(root, workspacePath(uris[0])))
|
|
283
|
+
continue;
|
|
284
|
+
const directory = join(home, 'brain', id, '.system_generated', 'logs');
|
|
285
|
+
const names = full ? ['transcript_full.jsonl', 'transcript.jsonl'] : ['transcript.jsonl'];
|
|
286
|
+
const path = names.map(name => join(directory, name)).find(existsSync);
|
|
287
|
+
if (path) {
|
|
288
|
+
seen.add(id);
|
|
289
|
+
yield { path, session: id };
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
finally {
|
|
294
|
+
db.close();
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
function* savedTranscripts(host, root, session, full = false) {
|
|
299
|
+
if (host === 'agy')
|
|
300
|
+
return yield* agyTranscripts(root, session, full);
|
|
301
|
+
if (host === 'claude') {
|
|
302
|
+
const projects = join(process.env.CLAUDE_CONFIG_DIR || join(homedir(), '.claude'), 'projects');
|
|
303
|
+
if (!existsSync(projects))
|
|
304
|
+
return;
|
|
305
|
+
for (const project of readdirSync(projects, { withFileTypes: true })) {
|
|
306
|
+
if (!project.isDirectory())
|
|
307
|
+
continue;
|
|
308
|
+
const directory = join(projects, project.name);
|
|
309
|
+
for (const entry of readdirSync(directory, { withFileTypes: true })) {
|
|
310
|
+
if (entry.isFile() && entry.name.endsWith('.jsonl') && (!session || basename(entry.name, '.jsonl') === session)) {
|
|
311
|
+
yield { path: join(directory, entry.name), session: session ?? basename(entry.name, '.jsonl') };
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
return;
|
|
316
|
+
}
|
|
317
|
+
const home = resolve(process.env.CODEX_HOME || join(homedir(), '.codex'));
|
|
318
|
+
for (const name of ['sessions', 'archived_sessions']) {
|
|
319
|
+
const directory = join(home, name);
|
|
320
|
+
if (!existsSync(directory))
|
|
321
|
+
continue;
|
|
322
|
+
for (const entry of readdirSync(directory, { recursive: true, withFileTypes: true })) {
|
|
323
|
+
if (entry.isFile() && /^rollout-.*\.jsonl$/.test(entry.name) && (!session || entry.name.endsWith(`-${session}.jsonl`))) {
|
|
324
|
+
yield { path: join(entry.parentPath, entry.name), session };
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
async function locateConversation(root, session, hosts) {
|
|
330
|
+
const matches = [];
|
|
331
|
+
for (const host of hosts) {
|
|
332
|
+
for (const transcript of savedTranscripts(host, root, session, true)) {
|
|
333
|
+
const info = statSync(transcript.path, { throwIfNoEntry: false });
|
|
334
|
+
if (!info?.isFile())
|
|
335
|
+
continue;
|
|
336
|
+
const id = host === 'codex' ? await codexSession(transcript, root, info.size)
|
|
337
|
+
: host === 'claude' ? await claudeSession(transcript, root, info.size) : transcript.session;
|
|
338
|
+
if (id !== session)
|
|
339
|
+
continue;
|
|
340
|
+
matches.push({ host, path: transcript.path, size: info.size });
|
|
341
|
+
break;
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
if (!matches.length)
|
|
345
|
+
throw new NotFoundError(`Conversation is unavailable in this project: ${session}`);
|
|
346
|
+
if (matches.length > 1)
|
|
347
|
+
throw new InputError('Conversation exists in more than one host; specify --host');
|
|
348
|
+
return matches[0];
|
|
349
|
+
}
|
|
350
|
+
export async function readMemoryConversation(target, options) {
|
|
351
|
+
const limit = searchLimit(options.limit);
|
|
352
|
+
if (options.page !== undefined)
|
|
353
|
+
pageOffset(options.page, limit);
|
|
354
|
+
const memory = options.memory.get(target);
|
|
355
|
+
const session = memory?.session ?? target;
|
|
356
|
+
if (!session)
|
|
357
|
+
throw new NotFoundError('Memory has no conversation session');
|
|
358
|
+
const sources = memory ? options.memory.sources(memory.id) : [];
|
|
359
|
+
const anchor = sources.find(source => source.role === 'user')?.id ?? sources[0]?.id ?? memory?.sourceMessageIds[0];
|
|
360
|
+
const hint = memoryHosts.find(host => anchor?.startsWith(`${host}:`));
|
|
361
|
+
const selected = options.host ?? hint;
|
|
362
|
+
const { host, path, size } = await locateConversation(realpathSync(options.root), session, selected ? [selected] : memoryHosts);
|
|
363
|
+
let page = options.page ?? (anchor ? undefined : 1);
|
|
364
|
+
let anchorPage;
|
|
365
|
+
let previous;
|
|
366
|
+
let messages = [];
|
|
367
|
+
const firstPage = [];
|
|
368
|
+
let count = 0;
|
|
369
|
+
let hasNext = false;
|
|
370
|
+
for await (const entry of transcriptRows(path, 0, size)) {
|
|
371
|
+
const completed = host === 'codex' ? codexCompletedMessage(entry, session, path) : undefined;
|
|
372
|
+
const item = host === 'codex' ? completed ?? codexMessage(entry, session, path)
|
|
373
|
+
: host === 'claude' ? claudeMessage(entry, session, path)?.item : agyMessage(entry, session, path)?.item;
|
|
374
|
+
if (!item?.content.trim())
|
|
375
|
+
continue;
|
|
376
|
+
// Codex 的回合完成事件有时复述上一条回复。该事件的来源 ID 仍能定位到同一页。
|
|
377
|
+
const repeated = completed && previous?.role === 'assistant' && previous.content === completed.content;
|
|
378
|
+
const position = repeated ? count - 1 : count;
|
|
379
|
+
const currentPage = Math.floor(position / limit) + 1;
|
|
380
|
+
if (!repeated && page === undefined && position % limit === 0)
|
|
381
|
+
messages = [];
|
|
382
|
+
if (item.id === anchor) {
|
|
383
|
+
anchorPage = currentPage;
|
|
384
|
+
page ??= currentPage;
|
|
385
|
+
}
|
|
386
|
+
if (repeated)
|
|
387
|
+
continue;
|
|
388
|
+
if (page !== undefined && currentPage > page) {
|
|
389
|
+
hasNext = true;
|
|
390
|
+
break;
|
|
391
|
+
}
|
|
392
|
+
previous = item;
|
|
393
|
+
count++;
|
|
394
|
+
if (count <= limit)
|
|
395
|
+
firstPage.push(item);
|
|
396
|
+
if (page === undefined || currentPage === page)
|
|
397
|
+
messages.push(item);
|
|
398
|
+
}
|
|
399
|
+
if (page === undefined) {
|
|
400
|
+
page = 1;
|
|
401
|
+
messages = firstPage;
|
|
402
|
+
hasNext = count > limit;
|
|
403
|
+
}
|
|
404
|
+
return { host, session, ...(memory && { memoryId: memory.id }), ...(anchor && { anchor: { messageId: anchor, page: anchorPage ?? null } }),
|
|
405
|
+
pagination: pagination(page, limit, hasNext), messages };
|
|
406
|
+
}
|
|
407
|
+
export async function syncMemoryHost(host, options, session) {
|
|
408
|
+
const root = realpathSync(options.root);
|
|
409
|
+
const sessions = new Set();
|
|
410
|
+
const failures = [];
|
|
411
|
+
let processed = 0;
|
|
412
|
+
let remembered = 0;
|
|
413
|
+
try {
|
|
414
|
+
for (const transcript of savedTranscripts(host, root, session)) {
|
|
415
|
+
try {
|
|
416
|
+
const result = await importTranscript(host, transcript, { ...options, root });
|
|
417
|
+
if (!result)
|
|
418
|
+
continue;
|
|
419
|
+
sessions.add(result.session);
|
|
420
|
+
processed += result.processed;
|
|
421
|
+
remembered += result.remembered;
|
|
422
|
+
}
|
|
423
|
+
catch (error) {
|
|
424
|
+
failures.push({ path: transcript.path, error: error instanceof Error ? error.message : String(error) });
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
catch (error) {
|
|
429
|
+
failures.push({ path: host, error: error instanceof Error ? error.message : String(error) });
|
|
430
|
+
}
|
|
431
|
+
return { sessions: sessions.size, processed, remembered, failures };
|
|
432
|
+
}
|
package/dist/memory.d.ts
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import type { AgentMemoryPrompt } from './agent-memory-prompts.js';
|
|
2
|
+
import { type MemorySource } from './memory-evidence.js';
|
|
3
|
+
import type { LlmClient } from './upstream/llm.js';
|
|
4
|
+
import type { KnowledgeReads } from './knowledge-reads.js';
|
|
5
|
+
export type { MemorySource } from './memory-evidence.js';
|
|
6
|
+
export interface ConversationMessage {
|
|
7
|
+
id: string;
|
|
8
|
+
role: 'user' | 'assistant' | 'system' | 'tool';
|
|
9
|
+
timestamp: number | string;
|
|
10
|
+
content: string;
|
|
11
|
+
location?: {
|
|
12
|
+
path: string;
|
|
13
|
+
byteOffset: number;
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
export interface MemoryInput {
|
|
17
|
+
id?: string;
|
|
18
|
+
content: string;
|
|
19
|
+
type?: string;
|
|
20
|
+
scene?: string;
|
|
21
|
+
session?: string;
|
|
22
|
+
priority?: number;
|
|
23
|
+
sourceMessageIds?: string[];
|
|
24
|
+
embedding?: ArrayLike<number>;
|
|
25
|
+
}
|
|
26
|
+
export interface MemoryRecord {
|
|
27
|
+
id: string;
|
|
28
|
+
content: string;
|
|
29
|
+
type: string;
|
|
30
|
+
scene: string;
|
|
31
|
+
session: string;
|
|
32
|
+
priority: number;
|
|
33
|
+
sourceMessageIds: string[];
|
|
34
|
+
exactValues?: string[];
|
|
35
|
+
sourceMessageScope?: 'messages' | 'turn';
|
|
36
|
+
createdAt: string;
|
|
37
|
+
updatedAt: string;
|
|
38
|
+
version: number;
|
|
39
|
+
}
|
|
40
|
+
export interface MemorySearchOptions {
|
|
41
|
+
limit?: number;
|
|
42
|
+
page?: number;
|
|
43
|
+
type?: string;
|
|
44
|
+
scene?: string;
|
|
45
|
+
session?: string;
|
|
46
|
+
embedding?: ArrayLike<number>;
|
|
47
|
+
}
|
|
48
|
+
export interface MemoryStoreOptions {
|
|
49
|
+
namespace?: string;
|
|
50
|
+
embed?: (text: string) => Promise<ArrayLike<number>>;
|
|
51
|
+
}
|
|
52
|
+
interface ExtractionOptions {
|
|
53
|
+
llm: LlmClient;
|
|
54
|
+
session: string;
|
|
55
|
+
mode?: 'chat' | 'code';
|
|
56
|
+
agentMemoryPrompt?: AgentMemoryPrompt;
|
|
57
|
+
systemPrompt?: string;
|
|
58
|
+
}
|
|
59
|
+
type Hit = MemoryRecord & {
|
|
60
|
+
score: number;
|
|
61
|
+
};
|
|
62
|
+
export declare class MemoryStore {
|
|
63
|
+
private readonly db;
|
|
64
|
+
private readonly namespace;
|
|
65
|
+
private readonly embed?;
|
|
66
|
+
constructor(path: string, options?: MemoryStoreOptions);
|
|
67
|
+
close(): void;
|
|
68
|
+
put(input: MemoryInput): Promise<MemoryRecord>;
|
|
69
|
+
putMany(inputs: MemoryInput[]): Promise<MemoryRecord[]>;
|
|
70
|
+
private writeMany;
|
|
71
|
+
get(id: string, options?: {
|
|
72
|
+
knowledgeReads?: KnowledgeReads;
|
|
73
|
+
fromSearchId?: string;
|
|
74
|
+
}): MemoryRecord | undefined;
|
|
75
|
+
sources(id: string): MemorySource[];
|
|
76
|
+
delete(id: string): boolean;
|
|
77
|
+
search(query: string, options?: MemorySearchOptions): Promise<{
|
|
78
|
+
pagination?: {
|
|
79
|
+
page: number;
|
|
80
|
+
limit: number;
|
|
81
|
+
previousPage: number | null;
|
|
82
|
+
nextPage: number | null;
|
|
83
|
+
} | undefined;
|
|
84
|
+
strategy: "exact" | "hybrid" | "fts" | "embedding";
|
|
85
|
+
results: Hit[];
|
|
86
|
+
}>;
|
|
87
|
+
extract(messages: ConversationMessage[], options: ExtractionOptions): Promise<MemoryRecord[]>;
|
|
88
|
+
extractionOffset(source: string, session: string): number;
|
|
89
|
+
extractIncremental(messages: ConversationMessage[], options: ExtractionOptions & {
|
|
90
|
+
source: string;
|
|
91
|
+
from: number;
|
|
92
|
+
to: number;
|
|
93
|
+
}): Promise<MemoryRecord[] | undefined>;
|
|
94
|
+
}
|
|
95
|
+
export declare function extractMemoryInputs(messages: ConversationMessage[], options: ExtractionOptions): Promise<MemoryInput[]>;
|
|
96
|
+
export declare function validateConversationMessages(messages: readonly ConversationMessage[]): Set<string>;
|