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,217 @@
|
|
|
1
|
+
import { randomUUID } from 'node:crypto';
|
|
2
|
+
import { createReadStream, existsSync, mkdirSync, readFileSync, readdirSync, realpathSync, renameSync, rmSync, statSync, writeFileSync, } from 'node:fs';
|
|
3
|
+
import { homedir } from 'node:os';
|
|
4
|
+
import { isAbsolute, join, relative, resolve, sep } from 'node:path';
|
|
5
|
+
import { fileURLToPath } from 'node:url';
|
|
6
|
+
import { InputError } from './common.js';
|
|
7
|
+
const source = 'codex';
|
|
8
|
+
const statusMessage = 'Extracting Agent Memory from Codex';
|
|
9
|
+
function object(value) {
|
|
10
|
+
return value && typeof value === 'object' && !Array.isArray(value) ? value : undefined;
|
|
11
|
+
}
|
|
12
|
+
function projectContains(root, cwd) {
|
|
13
|
+
if (typeof cwd !== 'string' || !isAbsolute(cwd))
|
|
14
|
+
return false;
|
|
15
|
+
const path = relative(root, existsSync(cwd) ? realpathSync(cwd) : cwd);
|
|
16
|
+
return path !== '..' && !path.startsWith(`..${sep}`) && !isAbsolute(path);
|
|
17
|
+
}
|
|
18
|
+
function quoteCommand(args) {
|
|
19
|
+
if (process.platform === 'win32')
|
|
20
|
+
return '& ' + args.map(arg => `'${arg.replaceAll("'", "''")}'`).join(' ');
|
|
21
|
+
return args.map(arg => `'${arg.replaceAll("'", "'\\''")}'`).join(' ');
|
|
22
|
+
}
|
|
23
|
+
export function installCodexMemoryHook(root) {
|
|
24
|
+
const directory = join(root, '.codex');
|
|
25
|
+
const path = join(directory, 'hooks.json');
|
|
26
|
+
const previous = existsSync(path) ? readFileSync(path, 'utf8') : undefined;
|
|
27
|
+
const config = previous === undefined ? {} : object(JSON.parse(previous.replace(/^\uFEFF/, '')));
|
|
28
|
+
const hooks = config?.hooks === undefined ? {} : object(config.hooks);
|
|
29
|
+
const stop = hooks?.Stop ?? [];
|
|
30
|
+
if (!config || !hooks || !Array.isArray(stop))
|
|
31
|
+
throw new InputError('Invalid Codex hooks configuration');
|
|
32
|
+
const entry = {
|
|
33
|
+
type: 'command',
|
|
34
|
+
command: quoteCommand([process.execPath, fileURLToPath(new URL('./cli.js', import.meta.url)), 'memory', 'codex-hook', '--root', root]),
|
|
35
|
+
timeout: 150,
|
|
36
|
+
statusMessage,
|
|
37
|
+
};
|
|
38
|
+
const ownEntries = stop.flatMap(group => Array.isArray(group?.hooks) ? group.hooks.filter(isMemoryHook) : []);
|
|
39
|
+
if (ownEntries.length === 1 && JSON.stringify(ownEntries[0]) === JSON.stringify(entry))
|
|
40
|
+
return { path, changed: false };
|
|
41
|
+
const otherGroups = stop.flatMap(group => {
|
|
42
|
+
if (!Array.isArray(group?.hooks) || !group.hooks.some(isMemoryHook))
|
|
43
|
+
return [group];
|
|
44
|
+
const remaining = group.hooks.filter((hook) => !isMemoryHook(hook));
|
|
45
|
+
return remaining.length ? [{ ...group, hooks: remaining }] : [];
|
|
46
|
+
});
|
|
47
|
+
mkdirSync(directory, { recursive: true });
|
|
48
|
+
const temporary = join(directory, `.${randomUUID()}.tmp`);
|
|
49
|
+
try {
|
|
50
|
+
const updated = { ...config, hooks: { ...hooks, Stop: [...otherGroups, { hooks: [entry] }] } };
|
|
51
|
+
writeFileSync(temporary, JSON.stringify(updated, null, 2) + '\n', { flag: 'wx' });
|
|
52
|
+
if ((existsSync(path) ? readFileSync(path, 'utf8') : undefined) !== previous) {
|
|
53
|
+
throw new InputError('Codex hooks configuration changed during installation');
|
|
54
|
+
}
|
|
55
|
+
renameSync(temporary, path);
|
|
56
|
+
return { path, changed: true };
|
|
57
|
+
}
|
|
58
|
+
finally {
|
|
59
|
+
rmSync(temporary, { force: true });
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
function isMemoryHook(value) {
|
|
63
|
+
const hook = object(value);
|
|
64
|
+
return hook?.statusMessage === statusMessage && typeof hook.command === 'string' && hook.command.includes('codex-hook');
|
|
65
|
+
}
|
|
66
|
+
async function* transcriptRows(path, from, size) {
|
|
67
|
+
if (from >= size)
|
|
68
|
+
return;
|
|
69
|
+
let offset = from;
|
|
70
|
+
let parts = [];
|
|
71
|
+
const stream = createReadStream(path, { start: from, end: size - 1 });
|
|
72
|
+
for await (const chunk of stream) {
|
|
73
|
+
let start = 0;
|
|
74
|
+
for (let end = chunk.indexOf(10, start); end >= 0; end = chunk.indexOf(10, start)) {
|
|
75
|
+
parts.push(chunk.subarray(start, end));
|
|
76
|
+
const line = Buffer.concat(parts);
|
|
77
|
+
const text = line.toString('utf8').replace(/^\uFEFF/, '');
|
|
78
|
+
const rowOffset = offset;
|
|
79
|
+
offset += line.length + 1;
|
|
80
|
+
parts = [];
|
|
81
|
+
start = end + 1;
|
|
82
|
+
if (!text.trim())
|
|
83
|
+
continue;
|
|
84
|
+
let row;
|
|
85
|
+
try {
|
|
86
|
+
row = object(JSON.parse(text));
|
|
87
|
+
}
|
|
88
|
+
catch {
|
|
89
|
+
throw new InputError(`Invalid Codex transcript JSON at byte ${rowOffset}`);
|
|
90
|
+
}
|
|
91
|
+
yield { row, start: rowOffset, end: offset };
|
|
92
|
+
}
|
|
93
|
+
if (start < chunk.length)
|
|
94
|
+
parts.push(chunk.subarray(start));
|
|
95
|
+
}
|
|
96
|
+
// 活跃会话可能还在写入最后一行,下一次从已提交的位置重新读取。
|
|
97
|
+
}
|
|
98
|
+
function readableText(value) {
|
|
99
|
+
return typeof value === 'string' && value.trim().length > 0;
|
|
100
|
+
}
|
|
101
|
+
function messageText(parts, kind) {
|
|
102
|
+
if (!Array.isArray(parts))
|
|
103
|
+
return '';
|
|
104
|
+
return parts.flatMap(part => {
|
|
105
|
+
if (part?.type !== kind || !readableText(part.text))
|
|
106
|
+
return [];
|
|
107
|
+
if (kind === 'input_text' && /^(?:# AGENTS\.md instructions for |<environment_context>)/.test(part.text.trimStart()))
|
|
108
|
+
return [];
|
|
109
|
+
return [part.text];
|
|
110
|
+
}).join('\n');
|
|
111
|
+
}
|
|
112
|
+
async function importTranscript(path, options) {
|
|
113
|
+
const info = statSync(path);
|
|
114
|
+
if (!info.isFile())
|
|
115
|
+
throw new InputError('Codex transcript must be a file');
|
|
116
|
+
let header;
|
|
117
|
+
for await (const { row } of transcriptRows(path, 0, info.size)) {
|
|
118
|
+
if (row?.type === 'session_meta')
|
|
119
|
+
header = object(row.payload);
|
|
120
|
+
break;
|
|
121
|
+
}
|
|
122
|
+
const session = header?.id;
|
|
123
|
+
if (!header || !readableText(session) || (options.session !== undefined && options.session !== session) ||
|
|
124
|
+
!projectContains(options.root, header.cwd) || object(header.source)?.subagent !== undefined)
|
|
125
|
+
return;
|
|
126
|
+
let offset = options.memory.extractionOffset(source, session);
|
|
127
|
+
if (offset > info.size)
|
|
128
|
+
throw new InputError('Codex transcript is shorter than its saved extraction offset');
|
|
129
|
+
let messages = [];
|
|
130
|
+
let remembered = 0;
|
|
131
|
+
let processed = 0;
|
|
132
|
+
for await (const { row, start, end } of transcriptRows(path, offset, info.size)) {
|
|
133
|
+
const payload = object(row?.payload);
|
|
134
|
+
if (!payload || !row)
|
|
135
|
+
continue;
|
|
136
|
+
let final = '';
|
|
137
|
+
if (row.type === 'event_msg') {
|
|
138
|
+
if (payload.type === 'task_started' || payload.type === 'turn_aborted')
|
|
139
|
+
messages = [];
|
|
140
|
+
if (payload.type === 'task_complete' && !payload.error && readableText(payload.last_agent_message)) {
|
|
141
|
+
final = payload.last_agent_message;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
else if (row.type === 'response_item' && payload.type === 'message') {
|
|
145
|
+
if (payload.role === 'user') {
|
|
146
|
+
const content = messageText(payload.content, 'input_text');
|
|
147
|
+
if (content && readableText(row.timestamp)) {
|
|
148
|
+
messages.push({ id: `codex:${session}:${start}`, role: 'user', timestamp: row.timestamp, content });
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
else if (payload.role === 'assistant' && payload.phase !== 'commentary') {
|
|
152
|
+
const content = messageText(payload.content, 'output_text');
|
|
153
|
+
if (payload.phase === 'final_answer' || content === options.lastAssistant)
|
|
154
|
+
final = content;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
if (!final || !messages.length || !readableText(row.timestamp))
|
|
158
|
+
continue;
|
|
159
|
+
messages.push({ id: `codex:${session}:${start}`, role: 'assistant', timestamp: row.timestamp, content: final });
|
|
160
|
+
if (options.memory.extractionOffset(source, session) === offset) {
|
|
161
|
+
const records = await options.memory.extractIncremental(messages, {
|
|
162
|
+
source, from: offset, to: end, llm: options.model(), session, mode: 'code',
|
|
163
|
+
});
|
|
164
|
+
if (records) {
|
|
165
|
+
remembered += records.length;
|
|
166
|
+
processed++;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
offset = end;
|
|
170
|
+
messages = [];
|
|
171
|
+
}
|
|
172
|
+
return { session, processed, remembered };
|
|
173
|
+
}
|
|
174
|
+
export async function handleCodexMemoryHook(input, options) {
|
|
175
|
+
const event = object(input);
|
|
176
|
+
if (event?.hook_event_name !== 'Stop' || !readableText(event.transcript_path) || !readableText(event.session_id))
|
|
177
|
+
return;
|
|
178
|
+
const root = realpathSync(options.root);
|
|
179
|
+
if (!projectContains(root, event.cwd))
|
|
180
|
+
return;
|
|
181
|
+
await importTranscript(event.transcript_path, {
|
|
182
|
+
...options, root, session: event.session_id,
|
|
183
|
+
lastAssistant: readableText(event.last_assistant_message) ? event.last_assistant_message : undefined,
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
export async function syncCodexMemory(options) {
|
|
187
|
+
const root = realpathSync(options.root);
|
|
188
|
+
const home = resolve(process.env.CODEX_HOME || join(homedir(), '.codex'));
|
|
189
|
+
const sessions = new Set();
|
|
190
|
+
const failures = [];
|
|
191
|
+
let processed = 0;
|
|
192
|
+
let remembered = 0;
|
|
193
|
+
for (const name of ['sessions', 'archived_sessions']) {
|
|
194
|
+
const directory = join(home, name);
|
|
195
|
+
if (!existsSync(directory))
|
|
196
|
+
continue;
|
|
197
|
+
for (const entry of readdirSync(directory, { recursive: true, withFileTypes: true })) {
|
|
198
|
+
if (!entry.isFile() || !/^rollout-.*\.jsonl$/.test(entry.name))
|
|
199
|
+
continue;
|
|
200
|
+
if (options.session && !entry.name.endsWith(`-${options.session}.jsonl`))
|
|
201
|
+
continue;
|
|
202
|
+
const path = join(entry.parentPath, entry.name);
|
|
203
|
+
try {
|
|
204
|
+
const result = await importTranscript(path, { ...options, root });
|
|
205
|
+
if (!result)
|
|
206
|
+
continue;
|
|
207
|
+
sessions.add(result.session);
|
|
208
|
+
processed += result.processed;
|
|
209
|
+
remembered += result.remembered;
|
|
210
|
+
}
|
|
211
|
+
catch (error) {
|
|
212
|
+
failures.push({ path, error: error instanceof Error ? error.message : String(error) });
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
return { sessions: sessions.size, processed, remembered, failures };
|
|
217
|
+
}
|
package/dist/common.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { DatabaseSync } from 'node:sqlite';
|
|
2
|
+
export declare class InputError extends Error {
|
|
3
|
+
}
|
|
4
|
+
export declare class NotFoundError extends Error {
|
|
5
|
+
}
|
|
6
|
+
export declare function requireText(value: unknown, label: string): string;
|
|
7
|
+
export declare function searchLimit(limit?: number): number;
|
|
8
|
+
export declare function pageOffset(page: number, limit: number): number;
|
|
9
|
+
export declare function pagination(page: number, limit: number, hasNext: boolean): {
|
|
10
|
+
page: number;
|
|
11
|
+
limit: number;
|
|
12
|
+
previousPage: number | null;
|
|
13
|
+
nextPage: number | null;
|
|
14
|
+
};
|
|
15
|
+
export declare function openDb(path: string, readOnly?: boolean): DatabaseSync;
|
|
16
|
+
export declare function transaction<T>(db: DatabaseSync, run: () => T): T;
|
package/dist/common.js
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { DatabaseSync } from 'node:sqlite';
|
|
2
|
+
export class InputError extends Error {
|
|
3
|
+
}
|
|
4
|
+
export class NotFoundError extends Error {
|
|
5
|
+
}
|
|
6
|
+
export function requireText(value, label) {
|
|
7
|
+
if (typeof value !== 'string' || !value.trim()) {
|
|
8
|
+
throw new InputError(`${label} must be a non-empty string`);
|
|
9
|
+
}
|
|
10
|
+
return value.trim();
|
|
11
|
+
}
|
|
12
|
+
export function searchLimit(limit = 10) {
|
|
13
|
+
if (!Number.isInteger(limit) || limit < 1 || limit > 100) {
|
|
14
|
+
throw new InputError('limit must be an integer between 1 and 100');
|
|
15
|
+
}
|
|
16
|
+
return limit;
|
|
17
|
+
}
|
|
18
|
+
export function pageOffset(page, limit) {
|
|
19
|
+
const offset = (page - 1) * limit;
|
|
20
|
+
if (!Number.isSafeInteger(page) || page < 1 || !Number.isSafeInteger(offset + limit)) {
|
|
21
|
+
throw new InputError('page must be a positive integer with a supported offset');
|
|
22
|
+
}
|
|
23
|
+
return offset;
|
|
24
|
+
}
|
|
25
|
+
export function pagination(page, limit, hasNext) {
|
|
26
|
+
return { page, limit, previousPage: page > 1 ? page - 1 : null, nextPage: hasNext ? page + 1 : null };
|
|
27
|
+
}
|
|
28
|
+
export function openDb(path, readOnly = false) {
|
|
29
|
+
const db = new DatabaseSync(path, { readOnly });
|
|
30
|
+
try {
|
|
31
|
+
db.exec('PRAGMA busy_timeout = 5000');
|
|
32
|
+
if (!readOnly)
|
|
33
|
+
db.exec('PRAGMA journal_mode = WAL');
|
|
34
|
+
return db;
|
|
35
|
+
}
|
|
36
|
+
catch (error) {
|
|
37
|
+
db.close();
|
|
38
|
+
throw error;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
export function transaction(db, run) {
|
|
42
|
+
db.exec('BEGIN IMMEDIATE');
|
|
43
|
+
try {
|
|
44
|
+
const result = run();
|
|
45
|
+
db.exec('COMMIT');
|
|
46
|
+
return result;
|
|
47
|
+
}
|
|
48
|
+
catch (error) {
|
|
49
|
+
db.exec('ROLLBACK');
|
|
50
|
+
throw error;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
export declare const AGENT_MEMORY_ENVELOPE_VERSION = "agent-memory-envelope/1.0";
|
|
2
|
+
export declare const AGENT_MEMORY_TRUST_BOUNDARY = "untrusted_evidence_data_only";
|
|
3
|
+
export declare const AGENT_MEMORY_CONTEXT_LEVEL = "L3";
|
|
4
|
+
export type MemoryAuthority = 'binding' | 'advisory' | 'unverified_episodic';
|
|
5
|
+
export interface AgentMemoryContextScope {
|
|
6
|
+
repository_id?: string;
|
|
7
|
+
session_id?: string;
|
|
8
|
+
run_id?: string;
|
|
9
|
+
task_kind?: string;
|
|
10
|
+
paths?: string[];
|
|
11
|
+
}
|
|
12
|
+
export interface AgentMemoryConstraint {
|
|
13
|
+
knowledge_id: string;
|
|
14
|
+
title: string;
|
|
15
|
+
mode: 'constraint';
|
|
16
|
+
authority: 'binding';
|
|
17
|
+
scope: string[];
|
|
18
|
+
categories?: string[];
|
|
19
|
+
content: string;
|
|
20
|
+
content_sha256?: string;
|
|
21
|
+
sources?: string[];
|
|
22
|
+
source_count?: number;
|
|
23
|
+
}
|
|
24
|
+
export interface AgentMemoryReference {
|
|
25
|
+
knowledge_id: string;
|
|
26
|
+
title: string;
|
|
27
|
+
mode: 'reference';
|
|
28
|
+
authority: 'advisory';
|
|
29
|
+
score: number;
|
|
30
|
+
hop: number;
|
|
31
|
+
snippet: string;
|
|
32
|
+
sources: string[];
|
|
33
|
+
related_knowledge_ids: string[];
|
|
34
|
+
}
|
|
35
|
+
export interface AgentMemoryWorkingMemory {
|
|
36
|
+
memory_id: string;
|
|
37
|
+
session_id: string;
|
|
38
|
+
type: string;
|
|
39
|
+
authority: 'unverified_episodic';
|
|
40
|
+
content: string;
|
|
41
|
+
source_ids: string[];
|
|
42
|
+
linked_knowledge_id?: string | null;
|
|
43
|
+
}
|
|
44
|
+
export interface AgentMemoryEnvelope {
|
|
45
|
+
schema_version: typeof AGENT_MEMORY_ENVELOPE_VERSION;
|
|
46
|
+
trust_boundary: typeof AGENT_MEMORY_TRUST_BOUNDARY;
|
|
47
|
+
memory_level: typeof AGENT_MEMORY_CONTEXT_LEVEL;
|
|
48
|
+
context_scope: AgentMemoryContextScope;
|
|
49
|
+
constraints: AgentMemoryConstraint[];
|
|
50
|
+
references: AgentMemoryReference[];
|
|
51
|
+
working_memories: AgentMemoryWorkingMemory[];
|
|
52
|
+
}
|
|
53
|
+
export interface AgentMemoryEnvelopeInput {
|
|
54
|
+
contextScope?: AgentMemoryContextScope;
|
|
55
|
+
constraints?: AgentMemoryConstraint[];
|
|
56
|
+
references?: AgentMemoryReference[];
|
|
57
|
+
workingMemories?: AgentMemoryWorkingMemory[];
|
|
58
|
+
}
|
|
59
|
+
export declare function createAgentMemoryEnvelope(input?: AgentMemoryEnvelopeInput): AgentMemoryEnvelope;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export const AGENT_MEMORY_ENVELOPE_VERSION = 'agent-memory-envelope/1.0';
|
|
2
|
+
export const AGENT_MEMORY_TRUST_BOUNDARY = 'untrusted_evidence_data_only';
|
|
3
|
+
export const AGENT_MEMORY_CONTEXT_LEVEL = 'L3';
|
|
4
|
+
function paths(values) {
|
|
5
|
+
if (!values?.length)
|
|
6
|
+
return undefined;
|
|
7
|
+
return [...new Set(values.map(value => value.trim()).filter(Boolean))];
|
|
8
|
+
}
|
|
9
|
+
export function createAgentMemoryEnvelope(input = {}) {
|
|
10
|
+
const contextScope = input.contextScope ?? {};
|
|
11
|
+
return {
|
|
12
|
+
schema_version: AGENT_MEMORY_ENVELOPE_VERSION,
|
|
13
|
+
trust_boundary: AGENT_MEMORY_TRUST_BOUNDARY,
|
|
14
|
+
memory_level: AGENT_MEMORY_CONTEXT_LEVEL,
|
|
15
|
+
context_scope: {
|
|
16
|
+
...contextScope,
|
|
17
|
+
...(paths(contextScope.paths) ? { paths: paths(contextScope.paths) } : {}),
|
|
18
|
+
},
|
|
19
|
+
constraints: [...(input.constraints ?? [])],
|
|
20
|
+
references: [...(input.references ?? [])],
|
|
21
|
+
working_memories: [...(input.workingMemories ?? [])],
|
|
22
|
+
};
|
|
23
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { ConversationMessage } from './memory.js';
|
|
2
|
+
export type HostKind = 'codex' | 'agy' | 'claude';
|
|
3
|
+
export interface HostTranscriptAdapter {
|
|
4
|
+
kind: HostKind;
|
|
5
|
+
parse(value: unknown, index: number, capturedAt: string): ConversationMessage | undefined;
|
|
6
|
+
}
|
|
7
|
+
export interface HostTranscriptCapture {
|
|
8
|
+
host_kind: HostKind;
|
|
9
|
+
host_session_id: string;
|
|
10
|
+
messages: ConversationMessage[];
|
|
11
|
+
snapshots: TranscriptEvidenceSnapshot[];
|
|
12
|
+
refs: string[];
|
|
13
|
+
}
|
|
14
|
+
export interface TranscriptEvidenceSnapshot {
|
|
15
|
+
schema_version: 'transcript-evidence/1.0';
|
|
16
|
+
sha256: string;
|
|
17
|
+
normalized_sha256: string;
|
|
18
|
+
host_kind: HostKind;
|
|
19
|
+
host_session_id: string;
|
|
20
|
+
entry_id: string;
|
|
21
|
+
quote: string;
|
|
22
|
+
captured_at: string;
|
|
23
|
+
file_name: string;
|
|
24
|
+
ref: string;
|
|
25
|
+
}
|
|
26
|
+
export declare const hostTranscriptAdapters: Record<HostKind, HostTranscriptAdapter>;
|
|
27
|
+
export declare function isHostKind(value: unknown): value is HostKind;
|
|
28
|
+
export declare function captureHostTranscript(input: {
|
|
29
|
+
hostKind: HostKind;
|
|
30
|
+
session: string;
|
|
31
|
+
source: string;
|
|
32
|
+
capturedAt?: string;
|
|
33
|
+
}): HostTranscriptCapture;
|
|
34
|
+
export declare function writeHostTranscriptEvidence(directory: string, capture: HostTranscriptCapture): string[];
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import { createHash, randomUUID } from 'node:crypto';
|
|
2
|
+
import { existsSync, mkdirSync, readFileSync, renameSync, rmSync, writeFileSync } from 'node:fs';
|
|
3
|
+
import { dirname, join } from 'node:path';
|
|
4
|
+
import { InputError, requireText } from './common.js';
|
|
5
|
+
function object(value) {
|
|
6
|
+
return value && typeof value === 'object' && !Array.isArray(value) ? value : undefined;
|
|
7
|
+
}
|
|
8
|
+
function text(value) {
|
|
9
|
+
if (typeof value === 'string' && value.trim())
|
|
10
|
+
return value.trim();
|
|
11
|
+
if (Array.isArray(value)) {
|
|
12
|
+
const parts = value.map(text).filter((part) => Boolean(part));
|
|
13
|
+
return parts.length ? parts.join('\n') : undefined;
|
|
14
|
+
}
|
|
15
|
+
const record = object(value);
|
|
16
|
+
if (!record)
|
|
17
|
+
return undefined;
|
|
18
|
+
for (const key of ['text', 'value', 'output_text', 'content']) {
|
|
19
|
+
const valueText = text(record[key]);
|
|
20
|
+
if (valueText)
|
|
21
|
+
return valueText;
|
|
22
|
+
}
|
|
23
|
+
return undefined;
|
|
24
|
+
}
|
|
25
|
+
function nestedRecord(value) {
|
|
26
|
+
for (const key of ['message', 'item', 'event']) {
|
|
27
|
+
const nested = object(value[key]);
|
|
28
|
+
if (nested)
|
|
29
|
+
return { ...value, ...nested };
|
|
30
|
+
}
|
|
31
|
+
return value;
|
|
32
|
+
}
|
|
33
|
+
function role(value) {
|
|
34
|
+
const candidate = value.role;
|
|
35
|
+
if (candidate === 'user' || candidate === 'assistant' || candidate === 'system' || candidate === 'tool') {
|
|
36
|
+
return candidate;
|
|
37
|
+
}
|
|
38
|
+
const type = typeof value.type === 'string' ? value.type.toLowerCase() : '';
|
|
39
|
+
if (type.includes('user'))
|
|
40
|
+
return 'user';
|
|
41
|
+
if (type.includes('assistant') || type.includes('response'))
|
|
42
|
+
return 'assistant';
|
|
43
|
+
return 'tool';
|
|
44
|
+
}
|
|
45
|
+
function safePart(value, label) {
|
|
46
|
+
const textValue = requireText(value, label);
|
|
47
|
+
if (/[:\p{Cc}]/u.test(textValue))
|
|
48
|
+
throw new InputError(`${label} contains a colon or control character`);
|
|
49
|
+
return textValue;
|
|
50
|
+
}
|
|
51
|
+
function parseHostMessage(value, kind, index, capturedAt) {
|
|
52
|
+
const record = object(value);
|
|
53
|
+
if (!record)
|
|
54
|
+
return undefined;
|
|
55
|
+
const merged = nestedRecord(record);
|
|
56
|
+
const content = text(merged.content ?? merged.text ?? merged.output_text);
|
|
57
|
+
if (!content)
|
|
58
|
+
return undefined;
|
|
59
|
+
const rawId = merged.id ?? merged.message_id ?? `${kind}-${index + 1}`;
|
|
60
|
+
const id = safePart(String(rawId).replace(/[:\p{Cc}]/gu, '-'), 'transcript entry ID');
|
|
61
|
+
const timestamp = typeof merged.timestamp === 'string' || typeof merged.timestamp === 'number'
|
|
62
|
+
? merged.timestamp : capturedAt;
|
|
63
|
+
return {
|
|
64
|
+
id,
|
|
65
|
+
role: role(merged),
|
|
66
|
+
timestamp,
|
|
67
|
+
content,
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
function adapter(kind) {
|
|
71
|
+
return { kind, parse: (value, index, capturedAt) => parseHostMessage(value, kind, index, capturedAt) };
|
|
72
|
+
}
|
|
73
|
+
export const hostTranscriptAdapters = {
|
|
74
|
+
codex: adapter('codex'),
|
|
75
|
+
agy: adapter('agy'),
|
|
76
|
+
claude: adapter('claude'),
|
|
77
|
+
};
|
|
78
|
+
export function isHostKind(value) {
|
|
79
|
+
return value === 'codex' || value === 'agy' || value === 'claude';
|
|
80
|
+
}
|
|
81
|
+
function locatorHash(hostKind, session, entry) {
|
|
82
|
+
return createHash('sha256').update([hostKind, session, entry].join('\0')).digest('hex').slice(0, 16);
|
|
83
|
+
}
|
|
84
|
+
function snapshotFor(hostKind, session, message, capturedAt) {
|
|
85
|
+
const quote = requireText(message.content, 'transcript quote');
|
|
86
|
+
const sha256 = createHash('sha256').update(quote).digest('hex');
|
|
87
|
+
const suffix = locatorHash(hostKind, session, message.id);
|
|
88
|
+
return {
|
|
89
|
+
schema_version: 'transcript-evidence/1.0',
|
|
90
|
+
sha256,
|
|
91
|
+
normalized_sha256: sha256,
|
|
92
|
+
host_kind: hostKind,
|
|
93
|
+
host_session_id: session,
|
|
94
|
+
entry_id: message.id,
|
|
95
|
+
quote,
|
|
96
|
+
captured_at: capturedAt,
|
|
97
|
+
file_name: `${sha256}-${suffix}.json`,
|
|
98
|
+
ref: `transcript:${hostKind}:${session}:${message.id}:${sha256.slice(0, 16)}`,
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
export function captureHostTranscript(input) {
|
|
102
|
+
const adapter = hostTranscriptAdapters[input.hostKind];
|
|
103
|
+
const session = safePart(input.session, 'host session');
|
|
104
|
+
const capturedAt = input.capturedAt ?? new Date().toISOString();
|
|
105
|
+
const messages = [];
|
|
106
|
+
const lines = readFileSync(input.source, 'utf8').split(/\r?\n/);
|
|
107
|
+
for (const [index, line] of lines.entries()) {
|
|
108
|
+
if (!line.trim())
|
|
109
|
+
continue;
|
|
110
|
+
let value;
|
|
111
|
+
try {
|
|
112
|
+
value = JSON.parse(line);
|
|
113
|
+
}
|
|
114
|
+
catch (error) {
|
|
115
|
+
throw new InputError(`Invalid ${input.hostKind} transcript JSON at line ${index + 1}: ${error instanceof Error ? error.message : String(error)}`);
|
|
116
|
+
}
|
|
117
|
+
const message = adapter.parse(value, index, capturedAt);
|
|
118
|
+
if (message)
|
|
119
|
+
messages.push(message);
|
|
120
|
+
}
|
|
121
|
+
const ids = new Set(messages.map(message => message.id));
|
|
122
|
+
if (ids.size !== messages.length)
|
|
123
|
+
throw new InputError(`Duplicate ${input.hostKind} transcript entry ID`);
|
|
124
|
+
const snapshots = messages.map(message => snapshotFor(input.hostKind, session, message, capturedAt));
|
|
125
|
+
return { host_kind: input.hostKind, host_session_id: session, messages, snapshots, refs: snapshots.map(snapshot => snapshot.ref) };
|
|
126
|
+
}
|
|
127
|
+
export function writeHostTranscriptEvidence(directory, capture) {
|
|
128
|
+
mkdirSync(directory, { recursive: true });
|
|
129
|
+
const paths = [];
|
|
130
|
+
for (const snapshot of capture.snapshots) {
|
|
131
|
+
const target = join(directory, snapshot.file_name);
|
|
132
|
+
const temporary = join(dirname(target), `.${randomUUID()}.tmp`);
|
|
133
|
+
const { file_name: _fileName, ref: _ref, ...payload } = snapshot;
|
|
134
|
+
const serialized = `${JSON.stringify(payload)}\n`;
|
|
135
|
+
if (existsSync(target)) {
|
|
136
|
+
if (readFileSync(target, 'utf8') !== serialized)
|
|
137
|
+
throw new InputError(`Transcript evidence changed: ${snapshot.file_name}`);
|
|
138
|
+
paths.push(target);
|
|
139
|
+
continue;
|
|
140
|
+
}
|
|
141
|
+
try {
|
|
142
|
+
writeFileSync(temporary, serialized, { flag: 'wx' });
|
|
143
|
+
renameSync(temporary, target);
|
|
144
|
+
paths.push(target);
|
|
145
|
+
}
|
|
146
|
+
finally {
|
|
147
|
+
rmSync(temporary, { force: true });
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
return paths;
|
|
151
|
+
}
|
package/dist/http.d.ts
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { type SearchSources } from './search.js';
|
|
2
|
+
/** GET /search or /context with q, scope, limit and optional Wiki/Memory filters. */
|
|
3
|
+
export declare function createSearchServer(sources: SearchSources): import("http").Server<typeof import("http").IncomingMessage, typeof import("http").ServerResponse>;
|
package/dist/http.js
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { createServer } from 'node:http';
|
|
2
|
+
import { InputError, NotFoundError } from './common.js';
|
|
3
|
+
import { context as buildContext, parseScope, search } from './search.js';
|
|
4
|
+
import { isRepositoryId, isWikiCategory } from './wiki-entry.js';
|
|
5
|
+
import { KnowledgeReads } from './knowledge-reads.js';
|
|
6
|
+
/** GET /search or /context with q, scope, limit and optional Wiki/Memory filters. */
|
|
7
|
+
export function createSearchServer(sources) {
|
|
8
|
+
const server = createServer(async (request, response) => {
|
|
9
|
+
response.setHeader('Content-Type', 'application/json; charset=utf-8');
|
|
10
|
+
response.setHeader('Cache-Control', 'no-store');
|
|
11
|
+
const send = (status, payload) => {
|
|
12
|
+
response.writeHead(status);
|
|
13
|
+
response.end(JSON.stringify(payload));
|
|
14
|
+
};
|
|
15
|
+
try {
|
|
16
|
+
const url = new URL(request.url ?? '/', 'http://localhost');
|
|
17
|
+
if (url.pathname !== '/search' && url.pathname !== '/context')
|
|
18
|
+
return send(404, { error: 'Route not found' });
|
|
19
|
+
if (request.method !== 'GET') {
|
|
20
|
+
response.setHeader('Allow', 'GET');
|
|
21
|
+
return send(405, { error: 'Use GET /search or /context' });
|
|
22
|
+
}
|
|
23
|
+
const params = url.searchParams;
|
|
24
|
+
const scope = parseScope(params.get('scope') ?? 'all');
|
|
25
|
+
const limit = params.has('limit') ? Number(params.get('limit')) : undefined;
|
|
26
|
+
const knowledgeReads = params.get('trace') === 'true' || params.get('trace') === '1' ? new KnowledgeReads() : undefined;
|
|
27
|
+
const withTrace = (payload) => {
|
|
28
|
+
if (!knowledgeReads)
|
|
29
|
+
return payload;
|
|
30
|
+
return payload && typeof payload === 'object' && !Array.isArray(payload)
|
|
31
|
+
? { ...payload, knowledge_reads: knowledgeReads.toJSON() }
|
|
32
|
+
: { result: payload, knowledge_reads: knowledgeReads.toJSON() };
|
|
33
|
+
};
|
|
34
|
+
const categories = params.getAll('category');
|
|
35
|
+
const validCategories = categories.filter(isWikiCategory);
|
|
36
|
+
if (validCategories.length !== categories.length)
|
|
37
|
+
throw new InputError('Unknown Wiki context category');
|
|
38
|
+
const repository = params.get('repository') ?? undefined;
|
|
39
|
+
if (repository !== undefined && !isRepositoryId(repository))
|
|
40
|
+
throw new InputError('Expected a persisted repository UUID');
|
|
41
|
+
if (url.pathname === '/context') {
|
|
42
|
+
return send(200, withTrace(await buildContext(sources, params.get('q') ?? '', {
|
|
43
|
+
limit,
|
|
44
|
+
context: {
|
|
45
|
+
task: params.get('task') ?? undefined,
|
|
46
|
+
paths: params.getAll('path'),
|
|
47
|
+
categories: validCategories.length ? validCategories : undefined,
|
|
48
|
+
repository,
|
|
49
|
+
keyword: params.get('keyword') ?? undefined,
|
|
50
|
+
includePathScoped: params.get('include_path_scoped') === 'true' || params.get('include_path_scoped') === '1',
|
|
51
|
+
},
|
|
52
|
+
wiki: { hop: params.has('hop') ? Number(params.get('hop')) : undefined },
|
|
53
|
+
memory: {
|
|
54
|
+
type: params.get('type') ?? undefined,
|
|
55
|
+
scene: params.get('scene') ?? undefined,
|
|
56
|
+
session: params.get('memory_session') ?? undefined,
|
|
57
|
+
},
|
|
58
|
+
includeWorkingMemory: params.get('include_memory') === 'true' || params.get('include_memory') === '1',
|
|
59
|
+
knowledgeReads,
|
|
60
|
+
contextScope: {
|
|
61
|
+
...(params.get('session') ? { session_id: params.get('session') } : {}),
|
|
62
|
+
...(params.get('task') ? { task_kind: params.get('task') } : {}),
|
|
63
|
+
...(params.getAll('path').length ? { paths: params.getAll('path') } : {}),
|
|
64
|
+
},
|
|
65
|
+
})));
|
|
66
|
+
}
|
|
67
|
+
const results = await search(sources, params.get('q') ?? '', {
|
|
68
|
+
scope,
|
|
69
|
+
limit,
|
|
70
|
+
wiki: { hop: params.has('hop') ? Number(params.get('hop')) : undefined },
|
|
71
|
+
memory: {
|
|
72
|
+
type: params.get('type') ?? undefined,
|
|
73
|
+
scene: params.get('scene') ?? undefined,
|
|
74
|
+
session: params.get('session') ?? undefined,
|
|
75
|
+
},
|
|
76
|
+
knowledgeReads,
|
|
77
|
+
});
|
|
78
|
+
send(200, withTrace(results));
|
|
79
|
+
}
|
|
80
|
+
catch (error) {
|
|
81
|
+
if (error instanceof InputError)
|
|
82
|
+
return send(400, { error: error.message });
|
|
83
|
+
if (error instanceof NotFoundError)
|
|
84
|
+
return send(404, { error: error.message });
|
|
85
|
+
send(500, { error: 'Search failed' });
|
|
86
|
+
server.emit('searchError', error);
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
return server;
|
|
90
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export { CodeGraph } from './code.js';
|
|
2
|
+
export { AGENT_MEMORY_ENVELOPE_VERSION, AGENT_MEMORY_CONTEXT_LEVEL, AGENT_MEMORY_TRUST_BOUNDARY, createAgentMemoryEnvelope, type AgentMemoryConstraint, type AgentMemoryContextScope, type AgentMemoryEnvelope, type AgentMemoryEnvelopeInput, type AgentMemoryReference, type AgentMemoryWorkingMemory, type MemoryAuthority, } from './context-envelope.js';
|
|
3
|
+
export { AGENT_MEMORY_PROMPT_VERSION, buildCloseoutHarvestPrompt, buildSessionSignalPrompt, buildWikiMergePrompt, buildWikiRelationPrompt, createAgentMemoryPrompt, type AgentMemoryPrompt, type AgentMemoryPromptKind, } from './agent-memory-prompts.js';
|
|
4
|
+
export { Wiki, type WikiHit, type WikiReadOptions, type WikiSearchOptions } from './wiki.js';
|
|
5
|
+
export type { WikiContext, WikiEntryMetadata } from './wiki-entry.js';
|
|
6
|
+
export { reviewSession, reviewSkillExecution, type ReviewedRun, type SkillSignal } from './retrospective.js';
|
|
7
|
+
export { draftSkillAddition, type SkillPriority } from './skill-addition.js';
|
|
8
|
+
export { decideSkillRoute, type SkillRetentionRoute, type SkillRouteContext, type SkillRouteDecision } from './skill-route.js';
|
|
9
|
+
export { applySkillDesign, createSkillDesignTask, readSkillDesignTask, replaySkillDesign, reviewSkillDesign, runSkillDesign, type SkillDesignReceipt, type SkillDesignTask, } from './skill-design.js';
|
|
10
|
+
export type { WikiIngestOptions } from './wiki-ingest.js';
|
|
11
|
+
export { MemoryStore, type MemoryInput, type MemoryRecord, type MemorySearchOptions, type MemoryStoreOptions, type ConversationMessage, type MemorySource } from './memory.js';
|
|
12
|
+
export { context, search, type ContextOptions, type SearchSources, type SearchScope, type SearchOptions, type SearchResults, } from './search.js';
|
|
13
|
+
export { createSearchServer } from './http.js';
|
|
14
|
+
export { KNOWLEDGE_READS_VERSION, KnowledgeReads, contentSha256, validateKnowledgeReads, type KnowledgeConstraintInput, type KnowledgeConstraintRecord, type KnowledgeReadInput, type KnowledgeReadKind, type KnowledgeReadRecord, type KnowledgeReadsReceipt, type KnowledgeSearchInput, type KnowledgeSearchRecord, type KnowledgeSearchSource, } from './knowledge-reads.js';
|
|
15
|
+
export { InputError, NotFoundError } from './common.js';
|
|
16
|
+
export type { LlmClient, ChatParams } from './upstream/llm.js';
|