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,761 @@
|
|
|
1
|
+
import { existsSync, lstatSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
|
|
2
|
+
import { dirname, join, resolve } from 'node:path';
|
|
3
|
+
import { parseArgs } from 'node:util';
|
|
4
|
+
import { CodeGraph } from './code.js';
|
|
5
|
+
import { configureMemory, installCodexMemoryHook, memoryHosts, memoryModelSettings, parseMemoryHosts } from './memory-config.js';
|
|
6
|
+
import { handleMemoryHook, readMemoryConversation, syncMemoryHost } from './memory-history.js';
|
|
7
|
+
import { InputError, requireText } from './common.js';
|
|
8
|
+
import { createSearchServer } from './http.js';
|
|
9
|
+
import { MemoryStore } from './memory.js';
|
|
10
|
+
import { context as buildContext, parseScope, search } from './search.js';
|
|
11
|
+
import { Wiki } from './wiki.js';
|
|
12
|
+
import { harvestCompletion, publishReference, readCloseoutCandidate, readCompletionReceipts, readHarvest, readSkillCompletions, recordSkillCompletion, } from './closeout.js';
|
|
13
|
+
import { reviewSession, reviewSkillExecution } from './retrospective.js';
|
|
14
|
+
import { draftSkillAddition } from './skill-addition.js';
|
|
15
|
+
import { changeSkillVersion, replaySkillAddition } from './skill-replay.js';
|
|
16
|
+
import { migrateLegacyWiki, validateWikiMemberUid } from './wiki-migration.js';
|
|
17
|
+
import { isRepositoryId, isWikiCategory } from './wiki-entry.js';
|
|
18
|
+
import { applyWikiChange, listWikiChanges, proposeWikiChange } from './wiki-change.js';
|
|
19
|
+
import { KnowledgeReads, validateKnowledgeReads } from './knowledge-reads.js';
|
|
20
|
+
import { decideSkillRoute } from './skill-route.js';
|
|
21
|
+
import { evolveSessionReceipt, readEvolveSessions, workflowDbPath } from './workflow-runtime.js';
|
|
22
|
+
import { applySkillDesign, createSkillDesignTask, readSkillDesignTask, replaySkillDesign, reviewSkillDesign, runSkillDesign, } from './skill-design.js';
|
|
23
|
+
export function knowledgeHelp(invocation) {
|
|
24
|
+
const skills = invocation === 'evolve' ? 'skills' : 'evolve';
|
|
25
|
+
return `Usage: ${invocation} <command> [options]
|
|
26
|
+
|
|
27
|
+
code build|sync Build or update the project's code graph
|
|
28
|
+
code search <query> Find code symbols
|
|
29
|
+
code callers|callees <symbol-id> Follow call edges (--depth 1)
|
|
30
|
+
code trace <from-id> <to-id> Find a path between code symbols
|
|
31
|
+
wiki build Index Markdown pages under wiki/
|
|
32
|
+
wiki ingest <file.md|file.txt> Generate and merge wiki pages
|
|
33
|
+
wiki search <query> Search wiki pages (--hop 0)
|
|
34
|
+
wiki get <id> Read a Wiki entry, including history (--resolved for scoped reference)
|
|
35
|
+
wiki references <query> Search active applicable references (--repository, --task, --path)
|
|
36
|
+
wiki reference <id> Compatibility alias for wiki get <id> --resolved
|
|
37
|
+
wiki constraints Resolve active constraints (--task, --path, --category, --repository, --keyword)
|
|
38
|
+
wiki migrate <legacy-root> Preview legacy Wiki migration (--project, --scope project|global|team|personal, --uid, --knowhow-only, --apply)
|
|
39
|
+
wiki propose <change.json> Stage create, update, promote, or retire (--evidence or --closeout and --candidate)
|
|
40
|
+
wiki changes [change-id] Read change previews and application receipts (--entry)
|
|
41
|
+
wiki apply <change-id> Apply an approved Wiki change
|
|
42
|
+
closeout harvest <receipt.json|id> Extract Wiki candidates from a receipt or recorded Skill completion (--project)
|
|
43
|
+
closeout session <id> Harvest a committed Session receipt (--project, --receipt)
|
|
44
|
+
closeout skill <execution-id> Record and harvest a standalone Skill completion
|
|
45
|
+
(--skill, --skill-version, --status, --transcript, --knowledge-receipt, --project, --record-only)
|
|
46
|
+
closeout resume <receipt-id> Compatibility alias for closeout harvest <receipt-id>
|
|
47
|
+
closeout scan [source-project-root] Reconcile committed Session and standalone Skill receipts (--project)
|
|
48
|
+
closeout show <receipt-id> Show harvested candidates (--project)
|
|
49
|
+
closeout route <closeout-id> <candidate-id> Decide Wiki, Skill addition, or meta Skill design
|
|
50
|
+
closeout publish <closeout-id> <candidate-id> <title>
|
|
51
|
+
Publish a reviewed reference
|
|
52
|
+
session review <id> Review Session signals (--transcript <messages.json>)
|
|
53
|
+
${skills} review <execution-id> Review a standalone Skill receipt (--project <id>)
|
|
54
|
+
${skills} draft <SKILL.md> <instruction> Draft a Skill addition (--priority high|normal|low, --evidence <ref>, --when)
|
|
55
|
+
${skills} replay <draft.json> Compare baseline and candidate (--runner <script>, --scenarios <json>)
|
|
56
|
+
${skills} apply|rollback <receipt-id> Apply a validated version or revert it
|
|
57
|
+
skill-design task <task-id> Read a generated meta Skill design task
|
|
58
|
+
skill-design run <task-id> Run the explicit meta Skill design runner (--runner)
|
|
59
|
+
skill-design review <design-id> Review the generated design against its baseline
|
|
60
|
+
skill-design replay <design-id> Replay the reviewed design (--runner, --scenarios)
|
|
61
|
+
skill-design apply|rollback <design-id> Apply or roll back the replayed design
|
|
62
|
+
memory put <text> Save a memory (--id, --type, --scene, --session, --priority)
|
|
63
|
+
memory extract <messages.json> Extract L1 memories (--session required, --mode chat|code)
|
|
64
|
+
memory config Configure project extraction in the terminal (Codex, Claude Code, Antigravity CLI)
|
|
65
|
+
(--host codex|claude|agy|all|off, --base-url, --model, --yes)
|
|
66
|
+
memory sync Extract saved project chats (--host codex|claude|agy|all, --session)
|
|
67
|
+
memory codex-install Install the project's Codex Stop hook (review it in Codex to enable)
|
|
68
|
+
memory codex-sync Extract saved Codex chats for this project (--session to select one)
|
|
69
|
+
memory get|delete <id> Read or delete a memory
|
|
70
|
+
memory sources <id> Read a memory's original messages and transcript locations
|
|
71
|
+
memory search <query> Search memory (--type, --scene, --session, --page, --limit)
|
|
72
|
+
Returns short previews and shared command arguments for agents
|
|
73
|
+
memory conversation <session-or-memory-id> View a conversation page (--host, --page, --limit)
|
|
74
|
+
A memory ID opens the source page
|
|
75
|
+
search <query> Search available indexes (--scope all|code|wiki|memory)
|
|
76
|
+
context <query> Build Agent Memory context envelope (--scope all|code|wiki|memory, --include-memory)
|
|
77
|
+
serve Serve GET /search on 127.0.0.1 (--port 4310)
|
|
78
|
+
|
|
79
|
+
Options:
|
|
80
|
+
--root <dir> Code project root and parent of wiki/ (default current directory)
|
|
81
|
+
--wiki-root <dir> Override the parent of wiki/
|
|
82
|
+
--db <path> Memory DB (default <root>/.agent-memory/memory.db)
|
|
83
|
+
--namespace <name> Memory namespace (default default)
|
|
84
|
+
--memory-session <id> Memory session filter (context uses this instead of its context session)
|
|
85
|
+
--context-file <path> Load shared task, path and Wiki filters from JSON
|
|
86
|
+
--trace Include knowledge_reads search/read evidence in the result
|
|
87
|
+
--reads <path> Load and persist a knowledge_reads receipt across CLI calls
|
|
88
|
+
--trace-file <path> Compatibility alias for --reads
|
|
89
|
+
--from-search <id> Associate an exact read with an earlier search ID
|
|
90
|
+
--resolved Read Wiki references using the active scope context
|
|
91
|
+
--json Return raw memory search results or conversation pages. Output is always JSON
|
|
92
|
+
--limit <n> Maximum results per source (default 10)
|
|
93
|
+
--help Show this message
|
|
94
|
+
|
|
95
|
+
Set an OpenAI-compatible chat endpoint with memory config or AGENT_MEMORY_LLM_BASE_URL and AGENT_MEMORY_LLM_MODEL.
|
|
96
|
+
Use AGENT_MEMORY_LLM_API_KEY for endpoint authentication if required. Message files contain
|
|
97
|
+
an array of {id, role, timestamp, content}. Commands return JSON on stdout.
|
|
98
|
+
For a follow-up, append commands.get, sources, conversation or page to commands.prefix.
|
|
99
|
+
Replace each {"arg":"id"} or {"arg":"host"} with the selected result's field and
|
|
100
|
+
{"arg":"page"} with the previous or next page number.
|
|
101
|
+
`;
|
|
102
|
+
}
|
|
103
|
+
export const knowledgeOptions = {
|
|
104
|
+
root: { type: 'string' },
|
|
105
|
+
'wiki-root': { type: 'string' },
|
|
106
|
+
db: { type: 'string' },
|
|
107
|
+
namespace: { type: 'string' },
|
|
108
|
+
scope: { type: 'string' },
|
|
109
|
+
limit: { type: 'string' },
|
|
110
|
+
page: { type: 'string' },
|
|
111
|
+
depth: { type: 'string' },
|
|
112
|
+
hop: { type: 'string' },
|
|
113
|
+
type: { type: 'string' },
|
|
114
|
+
scene: { type: 'string' },
|
|
115
|
+
session: { type: 'string' },
|
|
116
|
+
'memory-session': { type: 'string' },
|
|
117
|
+
'context-file': { type: 'string' },
|
|
118
|
+
id: { type: 'string' },
|
|
119
|
+
priority: { type: 'string' },
|
|
120
|
+
port: { type: 'string' },
|
|
121
|
+
mode: { type: 'string' },
|
|
122
|
+
host: { type: 'string' },
|
|
123
|
+
'base-url': { type: 'string' },
|
|
124
|
+
model: { type: 'string' },
|
|
125
|
+
yes: { type: 'boolean' },
|
|
126
|
+
skill: { type: 'string' }, // 收尾路由和执行回执的 Skill 标识,旧查询也可携带。
|
|
127
|
+
task: { type: 'string' },
|
|
128
|
+
category: { type: 'string', multiple: true },
|
|
129
|
+
keyword: { type: 'string' },
|
|
130
|
+
repository: { type: 'string' },
|
|
131
|
+
'include-path-scoped': { type: 'boolean' },
|
|
132
|
+
'include-memory': { type: 'boolean' },
|
|
133
|
+
trace: { type: 'boolean' },
|
|
134
|
+
'trace-file': { type: 'string' },
|
|
135
|
+
reads: { type: 'string' },
|
|
136
|
+
'from-search': { type: 'string' },
|
|
137
|
+
resolved: { type: 'boolean' },
|
|
138
|
+
path: { type: 'string', multiple: true },
|
|
139
|
+
history: { type: 'boolean' },
|
|
140
|
+
project: { type: 'string' },
|
|
141
|
+
uid: { type: 'string' },
|
|
142
|
+
'knowhow-only': { type: 'boolean' },
|
|
143
|
+
apply: { type: 'boolean' },
|
|
144
|
+
transcript: { type: 'string' },
|
|
145
|
+
'knowledge-receipt': { type: 'string' },
|
|
146
|
+
receipt: { type: 'string' },
|
|
147
|
+
'skill-version': { type: 'string' },
|
|
148
|
+
'repeat-count': { type: 'string' },
|
|
149
|
+
'step-count': { type: 'string' },
|
|
150
|
+
'signal-kind': { type: 'string', multiple: true },
|
|
151
|
+
'cross-skill': { type: 'boolean' },
|
|
152
|
+
'new-contract': { type: 'boolean' },
|
|
153
|
+
'new-artifacts': { type: 'boolean' },
|
|
154
|
+
'requires-routing': { type: 'boolean' },
|
|
155
|
+
'skill-intent': { type: 'boolean' },
|
|
156
|
+
status: { type: 'string' },
|
|
157
|
+
'record-only': { type: 'boolean' },
|
|
158
|
+
evidence: { type: 'string', multiple: true },
|
|
159
|
+
entry: { type: 'string' },
|
|
160
|
+
closeout: { type: 'string' },
|
|
161
|
+
candidate: { type: 'string' },
|
|
162
|
+
when: { type: 'string' },
|
|
163
|
+
runner: { type: 'string' },
|
|
164
|
+
scenarios: { type: 'string' },
|
|
165
|
+
help: { type: 'boolean', short: 'h' },
|
|
166
|
+
json: { type: 'boolean' },
|
|
167
|
+
};
|
|
168
|
+
function createModelClient(root) {
|
|
169
|
+
const settings = memoryModelSettings(root);
|
|
170
|
+
const url = new URL(requireText(settings.baseUrl, 'LLM base URL (memory config or AGENT_MEMORY_LLM_BASE_URL)'));
|
|
171
|
+
if (!['http:', 'https:'].includes(url.protocol))
|
|
172
|
+
throw new InputError('LLM endpoint must use HTTP or HTTPS');
|
|
173
|
+
url.pathname = url.pathname.replace(/\/$/, '') + '/chat/completions';
|
|
174
|
+
const model = requireText(settings.model, 'LLM model (memory config or AGENT_MEMORY_LLM_MODEL)');
|
|
175
|
+
const key = process.env.AGENT_MEMORY_LLM_API_KEY;
|
|
176
|
+
return {
|
|
177
|
+
async chat({ system, prompt }) {
|
|
178
|
+
const response = await fetch(url, {
|
|
179
|
+
method: 'POST',
|
|
180
|
+
headers: { 'Content-Type': 'application/json', ...(key && { Authorization: `Bearer ${key}` }) },
|
|
181
|
+
body: JSON.stringify({ model, messages: [{ role: 'system', content: system }, { role: 'user', content: prompt }] }),
|
|
182
|
+
signal: AbortSignal.timeout(120_000),
|
|
183
|
+
});
|
|
184
|
+
if (!response.ok)
|
|
185
|
+
throw new Error(`LLM request failed (HTTP ${response.status})`);
|
|
186
|
+
const data = await response.json();
|
|
187
|
+
return requireText(data.choices?.[0]?.message?.content, 'LLM response content');
|
|
188
|
+
},
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
function readContextFile(path) {
|
|
192
|
+
const value = JSON.parse(readFileSync(path, 'utf8').replace(/^\uFEFF/, ''));
|
|
193
|
+
if (!value || typeof value !== 'object' || Array.isArray(value))
|
|
194
|
+
throw new InputError('Context file must contain a JSON object');
|
|
195
|
+
const input = value;
|
|
196
|
+
const list = (field) => {
|
|
197
|
+
if (input[field] === undefined)
|
|
198
|
+
return undefined;
|
|
199
|
+
if (!Array.isArray(input[field]) || input[field].some(item => typeof item !== 'string' || !item.trim())) {
|
|
200
|
+
throw new InputError(`Context file ${field} must be a list of non-empty strings`);
|
|
201
|
+
}
|
|
202
|
+
return [...new Set(input[field].map(item => item.trim()))];
|
|
203
|
+
};
|
|
204
|
+
const text = (field) => {
|
|
205
|
+
if (input[field] === undefined)
|
|
206
|
+
return undefined;
|
|
207
|
+
if (typeof input[field] !== 'string' || !input[field].trim())
|
|
208
|
+
throw new InputError(`Context file ${field} must be a non-empty string`);
|
|
209
|
+
return input[field].trim();
|
|
210
|
+
};
|
|
211
|
+
if (input.includePathScoped !== undefined && typeof input.includePathScoped !== 'boolean') {
|
|
212
|
+
throw new InputError('Context file includePathScoped must be boolean');
|
|
213
|
+
}
|
|
214
|
+
return {
|
|
215
|
+
task: text('task'), paths: list('paths'), categories: list('categories'),
|
|
216
|
+
repository: text('repository'), keyword: text('keyword'),
|
|
217
|
+
...(input.includePathScoped === undefined ? {} : { includePathScoped: input.includePathScoped }),
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
function cliWikiContext(values) {
|
|
221
|
+
const file = typeof values['context-file'] === 'string' ? readContextFile(values['context-file']) : {};
|
|
222
|
+
const paths = Array.isArray(values.path) ? values.path : file.paths;
|
|
223
|
+
const categories = Array.isArray(values.category) ? values.category : file.categories;
|
|
224
|
+
return {
|
|
225
|
+
task: typeof values.task === 'string' ? values.task : file.task,
|
|
226
|
+
paths, categories,
|
|
227
|
+
repository: typeof values.repository === 'string' ? values.repository : file.repository,
|
|
228
|
+
keyword: typeof values.keyword === 'string' ? values.keyword : file.keyword,
|
|
229
|
+
includePathScoped: typeof values['include-path-scoped'] === 'boolean'
|
|
230
|
+
? values['include-path-scoped'] : file.includePathScoped,
|
|
231
|
+
};
|
|
232
|
+
}
|
|
233
|
+
function commandFlags(flags) {
|
|
234
|
+
return Object.entries(flags).flatMap(([key, value]) => {
|
|
235
|
+
if (value === undefined || value === false)
|
|
236
|
+
return [];
|
|
237
|
+
if (value === true)
|
|
238
|
+
return [`--${key}`];
|
|
239
|
+
if (String(value).startsWith('-'))
|
|
240
|
+
return [`--${key}=${value}`];
|
|
241
|
+
return [`--${key}`, String(value)];
|
|
242
|
+
});
|
|
243
|
+
}
|
|
244
|
+
function hasOtherPage(pagination) {
|
|
245
|
+
return pagination.previousPage !== null || pagination.nextPage !== null;
|
|
246
|
+
}
|
|
247
|
+
export async function runKnowledgeCli(argv, invocation = 'agent-memory') {
|
|
248
|
+
const { values, positionals } = parseArgs({ args: argv, options: knowledgeOptions, allowPositionals: true });
|
|
249
|
+
if (values.help || !positionals.length) {
|
|
250
|
+
process.stdout.write(knowledgeHelp(invocation));
|
|
251
|
+
return;
|
|
252
|
+
}
|
|
253
|
+
const [command, action, ...args] = positionals;
|
|
254
|
+
const root = resolve(values.root ?? '.');
|
|
255
|
+
const modelClient = () => createModelClient(root);
|
|
256
|
+
const contextValues = cliWikiContext(values);
|
|
257
|
+
const wiki = new Wiki(values['wiki-root'] ?? root);
|
|
258
|
+
const autoRefresh = invocation === 'evolve';
|
|
259
|
+
const openCode = () => new CodeGraph(root, { autoRefresh });
|
|
260
|
+
const db = values.db ?? join(root, '.agent-memory', 'memory.db');
|
|
261
|
+
const openMemory = () => new MemoryStore(db, { namespace: values.namespace });
|
|
262
|
+
const limit = values.limit === undefined ? undefined : Number(values.limit);
|
|
263
|
+
const wikiOptions = { limit, hop: values.hop === undefined ? undefined : Number(values.hop), includeHistory: values.history };
|
|
264
|
+
const memorySession = values['memory-session'] ?? (command === 'memory' || command === 'search' ? values.session : undefined);
|
|
265
|
+
const memoryOptions = { limit, type: values.type, scene: values.scene, session: memorySession };
|
|
266
|
+
if (values.reads !== undefined && values['trace-file'] !== undefined && values.reads !== values['trace-file']) {
|
|
267
|
+
throw new InputError('Use either --reads or --trace-file, not both');
|
|
268
|
+
}
|
|
269
|
+
const traceFile = values.reads ?? values['trace-file'];
|
|
270
|
+
const initialTrace = traceFile && existsSync(traceFile)
|
|
271
|
+
? validateKnowledgeReads(JSON.parse(readFileSync(traceFile, 'utf8').replace(/^\uFEFF/, '')))
|
|
272
|
+
: undefined;
|
|
273
|
+
const knowledgeReads = values.trace || traceFile
|
|
274
|
+
? new KnowledgeReads(initialTrace)
|
|
275
|
+
: undefined;
|
|
276
|
+
const print = (result, compact = false) => process.stdout.write(JSON.stringify(result, null, compact ? 0 : 2) + '\n');
|
|
277
|
+
const withTrace = (result) => {
|
|
278
|
+
if (!knowledgeReads)
|
|
279
|
+
return result;
|
|
280
|
+
if (traceFile) {
|
|
281
|
+
mkdirSync(dirname(resolve(traceFile)), { recursive: true });
|
|
282
|
+
writeFileSync(traceFile, JSON.stringify(knowledgeReads.toJSON(), null, 2) + '\n');
|
|
283
|
+
}
|
|
284
|
+
return result && typeof result === 'object' && !Array.isArray(result)
|
|
285
|
+
? { ...result, knowledge_reads: knowledgeReads.toJSON() }
|
|
286
|
+
: { result, knowledge_reads: knowledgeReads.toJSON() };
|
|
287
|
+
};
|
|
288
|
+
function sourcesFor(scope) {
|
|
289
|
+
const useCode = command !== 'context' &&
|
|
290
|
+
(scope === 'code' || (scope === 'all' && (autoRefresh || CodeGraph.hasIndex(root))));
|
|
291
|
+
return {
|
|
292
|
+
code: useCode ? openCode() : undefined,
|
|
293
|
+
wiki: scope === 'wiki' || (scope === 'all' && existsSync(wiki.indexPath)) ? wiki : undefined,
|
|
294
|
+
memory: scope === 'memory' || (scope === 'all' && (db === ':memory:' || existsSync(db))) ? openMemory() : undefined,
|
|
295
|
+
};
|
|
296
|
+
}
|
|
297
|
+
if (command === 'serve') {
|
|
298
|
+
const port = Number(values.port ?? '4310');
|
|
299
|
+
if (action !== undefined || !Number.isInteger(port) || port < 0 || port > 65535) {
|
|
300
|
+
throw new InputError(`Usage: ${invocation} serve [--port 0..65535]`);
|
|
301
|
+
}
|
|
302
|
+
const sources = sourcesFor(parseScope(values.scope ?? 'all'));
|
|
303
|
+
const server = createSearchServer(sources);
|
|
304
|
+
server.on('searchError', (error) => console.error(error));
|
|
305
|
+
server.on('close', () => sources.memory?.close());
|
|
306
|
+
server.on('error', error => {
|
|
307
|
+
console.error(error.message);
|
|
308
|
+
process.exitCode = 1;
|
|
309
|
+
server.close();
|
|
310
|
+
});
|
|
311
|
+
for (const signal of ['SIGINT', 'SIGTERM'])
|
|
312
|
+
process.once(signal, () => server.close());
|
|
313
|
+
server.listen(port, '127.0.0.1', () => {
|
|
314
|
+
const address = server.address();
|
|
315
|
+
if (address && typeof address === 'object')
|
|
316
|
+
print({ url: `http://127.0.0.1:${address.port}/search` });
|
|
317
|
+
});
|
|
318
|
+
return;
|
|
319
|
+
}
|
|
320
|
+
if (command === 'search') {
|
|
321
|
+
const query = requireText([action, ...args].join(' '), 'query');
|
|
322
|
+
const scope = parseScope(values.scope ?? 'all');
|
|
323
|
+
const sources = sourcesFor(scope);
|
|
324
|
+
try {
|
|
325
|
+
print(withTrace(await search(sources, query, {
|
|
326
|
+
scope, limit, wiki: wikiOptions, memory: memoryOptions, knowledgeReads,
|
|
327
|
+
})));
|
|
328
|
+
}
|
|
329
|
+
finally {
|
|
330
|
+
sources.memory?.close();
|
|
331
|
+
}
|
|
332
|
+
return;
|
|
333
|
+
}
|
|
334
|
+
if (command === 'context') {
|
|
335
|
+
const query = requireText([action, ...args].join(' '), 'query');
|
|
336
|
+
const scope = parseScope(values.scope ?? 'all');
|
|
337
|
+
if (contextValues.categories && !contextValues.categories.every(isWikiCategory)) {
|
|
338
|
+
throw new InputError('Unknown Wiki context category');
|
|
339
|
+
}
|
|
340
|
+
if (contextValues.repository !== undefined && !isRepositoryId(contextValues.repository)) {
|
|
341
|
+
throw new InputError('Expected a persisted repository UUID');
|
|
342
|
+
}
|
|
343
|
+
const sources = sourcesFor(scope);
|
|
344
|
+
try {
|
|
345
|
+
print(withTrace(await buildContext(sources, query, {
|
|
346
|
+
limit,
|
|
347
|
+
context: {
|
|
348
|
+
task: contextValues.task,
|
|
349
|
+
paths: contextValues.paths,
|
|
350
|
+
categories: contextValues.categories,
|
|
351
|
+
repository: contextValues.repository,
|
|
352
|
+
keyword: contextValues.keyword,
|
|
353
|
+
includePathScoped: contextValues.includePathScoped,
|
|
354
|
+
},
|
|
355
|
+
wiki: wikiOptions,
|
|
356
|
+
memory: memoryOptions,
|
|
357
|
+
includeWorkingMemory: values['include-memory'],
|
|
358
|
+
knowledgeReads,
|
|
359
|
+
contextScope: {
|
|
360
|
+
...(values.session ? { session_id: values.session } : {}),
|
|
361
|
+
...(contextValues.task ? { task_kind: contextValues.task } : {}),
|
|
362
|
+
...(contextValues.paths?.length ? { paths: contextValues.paths } : {}),
|
|
363
|
+
},
|
|
364
|
+
})));
|
|
365
|
+
}
|
|
366
|
+
finally {
|
|
367
|
+
sources.memory?.close();
|
|
368
|
+
}
|
|
369
|
+
return;
|
|
370
|
+
}
|
|
371
|
+
if (command === 'code') {
|
|
372
|
+
const code = openCode();
|
|
373
|
+
switch (action) {
|
|
374
|
+
case 'build': return print(await code.build());
|
|
375
|
+
case 'sync': return print(await code.sync());
|
|
376
|
+
case 'search': {
|
|
377
|
+
const query = args.join(' ');
|
|
378
|
+
const result = await code.search(query, limit);
|
|
379
|
+
if (knowledgeReads)
|
|
380
|
+
knowledgeReads.recordSearch({
|
|
381
|
+
source: 'code', query,
|
|
382
|
+
returnedIds: result.flatMap(item => typeof item.node?.id === 'string' ? [item.node.id] : []),
|
|
383
|
+
});
|
|
384
|
+
return print(withTrace(result));
|
|
385
|
+
}
|
|
386
|
+
case 'callers':
|
|
387
|
+
case 'callees': return print(await code.neighbors(requireText(args[0], 'symbol id'), action, Number(values.depth ?? '1')));
|
|
388
|
+
case 'trace': return print(await code.trace(requireText(args[0], 'from id'), requireText(args[1], 'to id')));
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
if (command === 'wiki') {
|
|
392
|
+
switch (action) {
|
|
393
|
+
case 'build': return print(wiki.build());
|
|
394
|
+
case 'search': {
|
|
395
|
+
const query = args.join(' ');
|
|
396
|
+
const result = wiki.search(query, wikiOptions);
|
|
397
|
+
if (knowledgeReads)
|
|
398
|
+
knowledgeReads.recordSearch({
|
|
399
|
+
source: 'wiki', query, filters: wikiOptions, returnedIds: result.results.map(hit => hit.id),
|
|
400
|
+
});
|
|
401
|
+
return print(withTrace(result));
|
|
402
|
+
}
|
|
403
|
+
case 'get':
|
|
404
|
+
if (!values.resolved)
|
|
405
|
+
return print(withTrace(wiki.getEntry(requireText(args[0], 'wiki entry ID'), {
|
|
406
|
+
knowledgeReads, fromSearchId: values['from-search'],
|
|
407
|
+
})));
|
|
408
|
+
case 'constraints':
|
|
409
|
+
case 'references':
|
|
410
|
+
case 'reference': {
|
|
411
|
+
const categories = contextValues.categories;
|
|
412
|
+
const repository = contextValues.repository;
|
|
413
|
+
if (categories && !categories.every(isWikiCategory)) {
|
|
414
|
+
throw new InputError(action === 'constraints' ? 'Unknown Wiki constraint category' : 'Unknown Wiki reference category');
|
|
415
|
+
}
|
|
416
|
+
if (repository !== undefined && !isRepositoryId(repository))
|
|
417
|
+
throw new InputError('Expected a persisted repository UUID');
|
|
418
|
+
const context = { task: contextValues.task, paths: contextValues.paths,
|
|
419
|
+
categories: categories, repository, keyword: contextValues.keyword };
|
|
420
|
+
if (action === 'references') {
|
|
421
|
+
const query = args.join(' ');
|
|
422
|
+
const result = wiki.references(query, context, wikiOptions);
|
|
423
|
+
if (knowledgeReads)
|
|
424
|
+
knowledgeReads.recordSearch({
|
|
425
|
+
source: 'wiki_references', query, filters: { ...context, ...wikiOptions },
|
|
426
|
+
returnedIds: result.results.map(hit => hit.id),
|
|
427
|
+
});
|
|
428
|
+
return print(withTrace(result));
|
|
429
|
+
}
|
|
430
|
+
if (action === 'reference' || (action === 'get' && values.resolved)) {
|
|
431
|
+
return print(withTrace(wiki.getReference(requireText(args[0], 'Wiki entry ID'), context, {
|
|
432
|
+
knowledgeReads, fromSearchId: values['from-search'],
|
|
433
|
+
})));
|
|
434
|
+
}
|
|
435
|
+
const result = wiki.constraints({ ...context, includePathScoped: contextValues.includePathScoped });
|
|
436
|
+
if (knowledgeReads)
|
|
437
|
+
for (const constraint of result) {
|
|
438
|
+
knowledgeReads.bindConstraint({
|
|
439
|
+
knowledgeId: constraint.id, scope: constraint.entry?.scope ?? [],
|
|
440
|
+
categories: constraint.entry?.categories, content: constraint.body,
|
|
441
|
+
});
|
|
442
|
+
}
|
|
443
|
+
return print(withTrace(result));
|
|
444
|
+
}
|
|
445
|
+
case 'migrate': {
|
|
446
|
+
const scope = values.scope ?? 'project';
|
|
447
|
+
if (scope !== 'project' && scope !== 'global' && scope !== 'team' && scope !== 'personal') {
|
|
448
|
+
throw new InputError('Expected Wiki migration scope project, global, team, or personal');
|
|
449
|
+
}
|
|
450
|
+
const source = resolve(requireText(args[0], 'legacy source root'));
|
|
451
|
+
const uid = scope === 'personal' ? validateWikiMemberUid(values.uid) : undefined;
|
|
452
|
+
const collab = join(root, '.workflow', 'collab');
|
|
453
|
+
if (!values['wiki-root'] && (scope === 'team' || scope === 'personal')) {
|
|
454
|
+
const parents = [join(root, '.workflow'), collab];
|
|
455
|
+
if (uid)
|
|
456
|
+
parents.push(join(collab, 'personal'), join(collab, 'personal', uid));
|
|
457
|
+
for (const parent of parents) {
|
|
458
|
+
const info = lstatSync(parent, { throwIfNoEntry: false });
|
|
459
|
+
if (info && !info.isDirectory())
|
|
460
|
+
throw new InputError(`Invalid Wiki migration directory: ${parent}`);
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
const layerRoot = scope === 'global' ? source : scope === 'team' ? collab
|
|
464
|
+
: uid ? join(collab, 'personal', uid) : root;
|
|
465
|
+
const destination = new Wiki(values['wiki-root'] ?? layerRoot);
|
|
466
|
+
return print(migrateLegacyWiki(destination, source, requireText(values.project, 'legacy project ID'), values.apply, {
|
|
467
|
+
scope, uid, knowhowOnly: values['knowhow-only'],
|
|
468
|
+
}));
|
|
469
|
+
}
|
|
470
|
+
case 'propose': {
|
|
471
|
+
const change = JSON.parse(readFileSync(requireText(args[0], 'change file'), 'utf8').replace(/^\uFEFF/, ''));
|
|
472
|
+
const evidence = values.evidence ?? [];
|
|
473
|
+
if (values.closeout !== undefined || values.candidate !== undefined) {
|
|
474
|
+
const closeout = requireText(values.closeout, 'closeout ID');
|
|
475
|
+
const candidate = readCloseoutCandidate(wiki, closeout, requireText(values.candidate, 'candidate ID'));
|
|
476
|
+
return print(proposeWikiChange(wiki, change, evidence, {
|
|
477
|
+
closeout, id: candidate.id, sources: candidate.sources,
|
|
478
|
+
related: [...(candidate.matched_entry ? [candidate.matched_entry] : []),
|
|
479
|
+
...(candidate.related_entries ?? []).map(entry => entry.id)],
|
|
480
|
+
}));
|
|
481
|
+
}
|
|
482
|
+
return print(proposeWikiChange(wiki, change, evidence));
|
|
483
|
+
}
|
|
484
|
+
case 'changes': return print(listWikiChanges(wiki, { id: args[0], entry: values.entry }));
|
|
485
|
+
case 'apply': return print(applyWikiChange(wiki, requireText(args[0], 'Wiki change ID')));
|
|
486
|
+
case 'ingest': return print(await wiki.ingest(requireText(args[0], 'source file'), { llm: modelClient() }));
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
if (command === 'closeout') {
|
|
490
|
+
if (action === 'publish')
|
|
491
|
+
return print(publishReference(wiki, requireText(args[0], 'closeout ID'), requireText(args[1], 'candidate ID'), args.slice(2).join(' ')));
|
|
492
|
+
if (action === 'route') {
|
|
493
|
+
const candidate = readCloseoutCandidate(wiki, requireText(args[0], 'closeout ID'), requireText(args[1], 'candidate ID'));
|
|
494
|
+
const closeoutId = requireText(args[0], 'closeout ID');
|
|
495
|
+
const candidateId = requireText(args[1], 'candidate ID');
|
|
496
|
+
const decision = decideSkillRoute({
|
|
497
|
+
content: candidate.content,
|
|
498
|
+
sources: candidate.sources,
|
|
499
|
+
matchedEntry: candidate.matched_entry,
|
|
500
|
+
relatedEntries: candidate.related_entries?.map(entry => entry.id),
|
|
501
|
+
skillId: values.skill,
|
|
502
|
+
skillVersion: values['skill-version'],
|
|
503
|
+
signalKinds: values['signal-kind'],
|
|
504
|
+
repeatCount: values['repeat-count'] === undefined ? undefined : Number(values['repeat-count']),
|
|
505
|
+
stepCount: values['step-count'] === undefined ? undefined : Number(values['step-count']),
|
|
506
|
+
crossSkill: values['cross-skill'],
|
|
507
|
+
requiresNewContract: values['new-contract'],
|
|
508
|
+
requiresNewArtifacts: values['new-artifacts'],
|
|
509
|
+
requiresRouting: values['requires-routing'],
|
|
510
|
+
explicitSkillIntent: values['skill-intent'],
|
|
511
|
+
});
|
|
512
|
+
if (decision.route !== 'skill-design')
|
|
513
|
+
return print(decision);
|
|
514
|
+
if (!values.skill)
|
|
515
|
+
throw new InputError('Skill-design route requires --skill <skill-id> for the replay/apply chain');
|
|
516
|
+
const task = createSkillDesignTask(root, {
|
|
517
|
+
closeoutId, candidateId, content: candidate.content, sources: candidate.sources,
|
|
518
|
+
decision, skillId: values.skill, skillVersion: values['skill-version'],
|
|
519
|
+
});
|
|
520
|
+
return print({ ...decision, design_task: task });
|
|
521
|
+
}
|
|
522
|
+
const project = requireText(values.project, 'source project ID');
|
|
523
|
+
if (action === 'harvest' || action === 'resume') {
|
|
524
|
+
const source = requireText(args[0], action === 'harvest' ? 'receipt path or ID' : 'receipt ID');
|
|
525
|
+
if (action === 'harvest' && existsSync(source)) {
|
|
526
|
+
return print(await harvestCompletion(wiki, project, JSON.parse(readFileSync(source, 'utf8').replace(/^\uFEFF/, '')), modelClient));
|
|
527
|
+
}
|
|
528
|
+
const saved = readSkillCompletions(wiki, project, source)[0];
|
|
529
|
+
if (!saved)
|
|
530
|
+
throw new InputError(`Standalone Skill completion receipt not found: ${source}`);
|
|
531
|
+
return print(await harvestCompletion(wiki, project, saved.receipt, modelClient));
|
|
532
|
+
}
|
|
533
|
+
if (action === 'show')
|
|
534
|
+
return print(readHarvest(wiki, project, requireText(args[0], 'completion receipt ID')));
|
|
535
|
+
if (action === 'session') {
|
|
536
|
+
const session = requireText(args[0], 'Session ID');
|
|
537
|
+
const [native] = readEvolveSessions(root, session);
|
|
538
|
+
if (native) {
|
|
539
|
+
const receipt = evolveSessionReceipt(native);
|
|
540
|
+
if (values.receipt && values.receipt !== receipt.id)
|
|
541
|
+
throw new InputError('Evolve Session receipt ID mismatch');
|
|
542
|
+
return print(await harvestCompletion(wiki, project, receipt, modelClient));
|
|
543
|
+
}
|
|
544
|
+
const receipts = [...readCompletionReceipts(root, session, values.receipt)];
|
|
545
|
+
if (receipts.length !== 1) {
|
|
546
|
+
throw new InputError(`Expected one committed completion receipt for ${session}, found ${receipts.length}`);
|
|
547
|
+
}
|
|
548
|
+
const [{ receipt, directory }] = receipts;
|
|
549
|
+
return print(await harvestCompletion(wiki, project, receipt, modelClient, directory));
|
|
550
|
+
}
|
|
551
|
+
if (action === 'skill') {
|
|
552
|
+
const transcript = values.transcript ? JSON.parse(readFileSync(values.transcript, 'utf8').replace(/^\uFEFF/, '')) : [];
|
|
553
|
+
if (!Array.isArray(transcript))
|
|
554
|
+
throw new InputError('Transcript must be a JSON message array');
|
|
555
|
+
const knowledgeReads = values['knowledge-receipt']
|
|
556
|
+
? validateKnowledgeReads(JSON.parse(readFileSync(values['knowledge-receipt'], 'utf8').replace(/^\uFEFF/, '')))
|
|
557
|
+
: undefined;
|
|
558
|
+
const recorded = recordSkillCompletion(wiki, project, {
|
|
559
|
+
execution: requireText(args[0], 'Skill execution ID'),
|
|
560
|
+
skill: requireText(values.skill, 'Skill ID'), version: requireText(values['skill-version'], 'Skill version'),
|
|
561
|
+
status: requireText(values.status, 'Skill status'), messages: transcript, session: values.session, knowledgeReads,
|
|
562
|
+
});
|
|
563
|
+
if (!('receipt' in recorded))
|
|
564
|
+
return print(recorded);
|
|
565
|
+
if (values['record-only'])
|
|
566
|
+
return print({ receipt: recorded.receipt.id });
|
|
567
|
+
return print({ receipt: recorded.receipt.id, ...await harvestCompletion(wiki, project, recorded.receipt, modelClient) });
|
|
568
|
+
}
|
|
569
|
+
if (action === 'scan') {
|
|
570
|
+
const results = [];
|
|
571
|
+
const errors = [];
|
|
572
|
+
const sessionSource = args[0] ?? root;
|
|
573
|
+
const hasHistoricalSessions = existsSync(join(sessionSource, '.workflow', 'sessions'));
|
|
574
|
+
if (args[0] && !hasHistoricalSessions && !existsSync(workflowDbPath(sessionSource))) {
|
|
575
|
+
throw new InputError('Cannot locate Evolve or historical Sessions in the source project');
|
|
576
|
+
}
|
|
577
|
+
const sessionReceipts = hasHistoricalSessions
|
|
578
|
+
? readCompletionReceipts(sessionSource) : [];
|
|
579
|
+
const consume = async (id, receipt, directory) => {
|
|
580
|
+
try {
|
|
581
|
+
results.push(await harvestCompletion(wiki, project, receipt, modelClient, directory));
|
|
582
|
+
}
|
|
583
|
+
catch (error) {
|
|
584
|
+
errors.push({ receipt: id, error: error instanceof Error ? error.message : String(error) });
|
|
585
|
+
}
|
|
586
|
+
};
|
|
587
|
+
for (const { receipt, directory } of sessionReceipts) {
|
|
588
|
+
await consume(requireText(receipt.transition_id, 'transition ID'), receipt, directory);
|
|
589
|
+
}
|
|
590
|
+
for (const session of readEvolveSessions(sessionSource).filter(item => item.status === 'completed')) {
|
|
591
|
+
const receipt = evolveSessionReceipt(session);
|
|
592
|
+
await consume(receipt.id, receipt);
|
|
593
|
+
}
|
|
594
|
+
for (const { id, receipt } of readSkillCompletions(wiki, project)) {
|
|
595
|
+
await consume(id, receipt);
|
|
596
|
+
}
|
|
597
|
+
if (errors.length > 0) {
|
|
598
|
+
process.exitCode = 1;
|
|
599
|
+
return print({ results, errors });
|
|
600
|
+
}
|
|
601
|
+
return print(results);
|
|
602
|
+
}
|
|
603
|
+
}
|
|
604
|
+
if (command === 'session' && action === 'review') {
|
|
605
|
+
const transcript = values.transcript ? JSON.parse(readFileSync(values.transcript, 'utf8')) : undefined;
|
|
606
|
+
if (transcript !== undefined && !Array.isArray(transcript))
|
|
607
|
+
throw new InputError('Transcript must be a JSON message array');
|
|
608
|
+
return print(await reviewSession(root, requireText(args[0], 'Session ID'), { model: modelClient, transcript }));
|
|
609
|
+
}
|
|
610
|
+
if (command === 'evolve' && action === 'review') {
|
|
611
|
+
return print(await reviewSkillExecution(wiki, requireText(values.project, 'source project ID'), requireText(args[0], 'Skill execution ID'), modelClient));
|
|
612
|
+
}
|
|
613
|
+
if (command === 'evolve' && action === 'draft') {
|
|
614
|
+
const priority = values.priority;
|
|
615
|
+
if (priority !== 'high' && priority !== 'normal' && priority !== 'low')
|
|
616
|
+
throw new InputError('Unknown Skill priority');
|
|
617
|
+
return print(draftSkillAddition({
|
|
618
|
+
entry: requireText(args[0], 'Skill entry path'),
|
|
619
|
+
priority,
|
|
620
|
+
instruction: args.slice(1).join(' '),
|
|
621
|
+
sources: values.evidence ?? [],
|
|
622
|
+
when: values.when,
|
|
623
|
+
}));
|
|
624
|
+
}
|
|
625
|
+
if (command === 'evolve' && action === 'replay') {
|
|
626
|
+
const draft = JSON.parse(readFileSync(requireText(args[0], 'draft file'), 'utf8').replace(/^\uFEFF/, ''));
|
|
627
|
+
const scenarios = JSON.parse(readFileSync(requireText(values.scenarios, 'scenarios file'), 'utf8').replace(/^\uFEFF/, ''));
|
|
628
|
+
return print(replaySkillAddition(root, draft, { runner: requireText(values.runner, 'replay runner'), scenarios }));
|
|
629
|
+
}
|
|
630
|
+
if (command === 'evolve' && (action === 'apply' || action === 'rollback')) {
|
|
631
|
+
return print(changeSkillVersion(root, requireText(args[0], 'replay receipt ID'), action === 'rollback'));
|
|
632
|
+
}
|
|
633
|
+
if (command === 'skill-design') {
|
|
634
|
+
if (action === 'task')
|
|
635
|
+
return print(readSkillDesignTask(root, requireText(args[0], 'Skill design task ID')));
|
|
636
|
+
if (action === 'run')
|
|
637
|
+
return print(runSkillDesign(root, requireText(args[0], 'Skill design task ID'), requireText(values.runner, 'design runner')));
|
|
638
|
+
if (action === 'review')
|
|
639
|
+
return print(reviewSkillDesign(root, requireText(args[0], 'Skill design receipt ID')));
|
|
640
|
+
if (action === 'replay') {
|
|
641
|
+
const scenarios = JSON.parse(readFileSync(requireText(values.scenarios, 'scenarios file'), 'utf8').replace(/^\uFEFF/, ''));
|
|
642
|
+
return print(replaySkillDesign(root, requireText(args[0], 'Skill design receipt ID'), {
|
|
643
|
+
runner: requireText(values.runner, 'replay runner'), scenarios,
|
|
644
|
+
}));
|
|
645
|
+
}
|
|
646
|
+
if (action === 'apply' || action === 'rollback') {
|
|
647
|
+
return print(applySkillDesign(root, requireText(args[0], 'Skill design receipt ID'), action === 'rollback'));
|
|
648
|
+
}
|
|
649
|
+
}
|
|
650
|
+
if (command === 'memory' && action === 'config')
|
|
651
|
+
return print(await configureMemory(root, {
|
|
652
|
+
host: values.host, baseUrl: values['base-url'], model: values.model, yes: values.yes,
|
|
653
|
+
}));
|
|
654
|
+
if (command === 'memory' && action === 'codex-install')
|
|
655
|
+
return print(installCodexMemoryHook(root));
|
|
656
|
+
if (command === 'memory' && ['put', 'get', 'sources', 'delete', 'search', 'conversation', 'extract', 'codex-hook', 'host-hook', 'codex-sync', 'sync'].includes(action)) {
|
|
657
|
+
const memory = openMemory();
|
|
658
|
+
const page = values.page === undefined ? undefined : Number(values.page);
|
|
659
|
+
const memoryPrefix = () => [invocation, 'memory', ...commandFlags({
|
|
660
|
+
root, db: values.db === undefined || db === ':memory:' ? values.db : resolve(db), namespace: values.namespace,
|
|
661
|
+
})];
|
|
662
|
+
try {
|
|
663
|
+
switch (action) {
|
|
664
|
+
case 'put': return print(await memory.put({
|
|
665
|
+
content: args.join(' '), id: values.id, type: values.type, scene: values.scene, session: values.session,
|
|
666
|
+
priority: values.priority === undefined ? undefined : Number(values.priority),
|
|
667
|
+
}));
|
|
668
|
+
case 'get': return print(withTrace(memory.get(requireText(args[0], 'id'), {
|
|
669
|
+
knowledgeReads, fromSearchId: values['from-search'],
|
|
670
|
+
}) ?? null));
|
|
671
|
+
case 'sources': return print(memory.sources(requireText(args[0], 'memory ID')));
|
|
672
|
+
case 'delete': return print({ deleted: memory.delete(requireText(args[0], 'id')) });
|
|
673
|
+
case 'search': {
|
|
674
|
+
const query = requireText(args.join(' '), 'query');
|
|
675
|
+
const filters = { ...memoryOptions, page: values.json ? page : page ?? 1 };
|
|
676
|
+
const result = await memory.search(query, filters);
|
|
677
|
+
const searchId = knowledgeReads?.recordSearch({
|
|
678
|
+
source: 'memory', query, filters, returnedIds: result.results.map(hit => hit.id),
|
|
679
|
+
});
|
|
680
|
+
const { pagination } = result;
|
|
681
|
+
if (values.json || !pagination)
|
|
682
|
+
return print(withTrace(result));
|
|
683
|
+
const results = result.results.map(hit => {
|
|
684
|
+
const content = hit.content.replace(/^(.{160}).+/su, '$1…');
|
|
685
|
+
const host = hit.session && (memoryHosts.find(host => hit.sourceMessageIds.some(id => id.startsWith(`${host}:${hit.session}:`)))
|
|
686
|
+
?? memoryHosts.find(host => memory.extractionOffset(host, hit.session) > 0));
|
|
687
|
+
return { id: hit.id, content, ...(hit.sourceMessageScope && { sources: true }), ...(host && { host }) };
|
|
688
|
+
});
|
|
689
|
+
const reads = traceFile ? resolve(traceFile) : undefined;
|
|
690
|
+
const commands = results.length || hasOtherPage(pagination) ? {
|
|
691
|
+
prefix: memoryPrefix(),
|
|
692
|
+
...(results.length > 0 && { get: ['get', ...commandFlags({ reads, 'from-search': reads ? searchId : undefined }), '--', { arg: 'id' }] }),
|
|
693
|
+
...(results.some(hit => hit.sources) && { sources: ['sources', '--', { arg: 'id' }] }),
|
|
694
|
+
...(results.some(hit => hit.host) && { conversation: ['conversation', '--host', { arg: 'host' }, '--', { arg: 'id' }] }),
|
|
695
|
+
...(hasOtherPage(pagination) && { page: ['search', ...commandFlags({
|
|
696
|
+
type: filters.type, scene: filters.scene, 'memory-session': filters.session,
|
|
697
|
+
limit: pagination.limit, reads, trace: values.trace,
|
|
698
|
+
}), '--page', { arg: 'page' }, '--', query] }),
|
|
699
|
+
} : undefined;
|
|
700
|
+
return print(withTrace({ strategy: result.strategy, results, pagination, commands }), true);
|
|
701
|
+
}
|
|
702
|
+
case 'conversation': {
|
|
703
|
+
const hosts = values.host === undefined ? [] : parseMemoryHosts(values.host);
|
|
704
|
+
if (hosts.length > 1)
|
|
705
|
+
throw new InputError('Choose one host for the conversation');
|
|
706
|
+
const target = requireText(args[0], 'session or memory ID');
|
|
707
|
+
const result = await readMemoryConversation(target, {
|
|
708
|
+
root, memory, host: hosts[0], page, limit: memoryOptions.limit,
|
|
709
|
+
});
|
|
710
|
+
if (values.json)
|
|
711
|
+
return print(result);
|
|
712
|
+
const commands = hasOtherPage(result.pagination) ? {
|
|
713
|
+
prefix: memoryPrefix(),
|
|
714
|
+
page: ['conversation', '--host', result.host, '--limit', String(result.pagination.limit), '--page', { arg: 'page' }, '--', target],
|
|
715
|
+
} : undefined;
|
|
716
|
+
return print({ ...result, commands }, true);
|
|
717
|
+
}
|
|
718
|
+
case 'extract': {
|
|
719
|
+
const messages = JSON.parse(readFileSync(requireText(args[0], 'messages file'), 'utf8').replace(/^\uFEFF/, ''));
|
|
720
|
+
if (!Array.isArray(messages))
|
|
721
|
+
throw new InputError('Messages file must contain a JSON array');
|
|
722
|
+
const mode = values.mode ?? 'chat';
|
|
723
|
+
if (mode !== 'chat' && mode !== 'code')
|
|
724
|
+
throw new InputError('mode must be chat or code');
|
|
725
|
+
return print(await memory.extract(messages, {
|
|
726
|
+
session: requireText(values.session, 'session'), mode, llm: modelClient(),
|
|
727
|
+
}));
|
|
728
|
+
}
|
|
729
|
+
case 'codex-hook':
|
|
730
|
+
case 'host-hook': {
|
|
731
|
+
const hosts = parseMemoryHosts(action === 'codex-hook' ? 'codex' : requireText(values.host, 'host'));
|
|
732
|
+
if (hosts.length !== 1)
|
|
733
|
+
throw new InputError('Choose one host for the hook');
|
|
734
|
+
const input = JSON.parse(readFileSync(0, 'utf8').replace(/^\uFEFF/, ''));
|
|
735
|
+
return print(await handleMemoryHook(hosts[0], input, { root, memory, model: modelClient }));
|
|
736
|
+
}
|
|
737
|
+
case 'codex-sync': {
|
|
738
|
+
const result = await syncMemoryHost('codex', { root, memory, model: modelClient }, values.session);
|
|
739
|
+
if (result.failures.length)
|
|
740
|
+
process.exitCode = 1;
|
|
741
|
+
return print(result);
|
|
742
|
+
}
|
|
743
|
+
case 'sync': {
|
|
744
|
+
const hosts = parseMemoryHosts(values.host ?? 'all');
|
|
745
|
+
const results = [];
|
|
746
|
+
for (const host of hosts) {
|
|
747
|
+
const result = await syncMemoryHost(host, { root, memory, model: modelClient }, values.session);
|
|
748
|
+
if (result.failures.length)
|
|
749
|
+
process.exitCode = 1;
|
|
750
|
+
results.push({ host, ...result });
|
|
751
|
+
}
|
|
752
|
+
return print({ hosts: results });
|
|
753
|
+
}
|
|
754
|
+
}
|
|
755
|
+
}
|
|
756
|
+
finally {
|
|
757
|
+
memory.close();
|
|
758
|
+
}
|
|
759
|
+
}
|
|
760
|
+
throw new InputError(`Unknown command. Run ${invocation} --help`);
|
|
761
|
+
}
|