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,330 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Modified for Self-Evolving Workflow. See UPSTREAM.md.
|
|
3
|
+
/**
|
|
4
|
+
* Deep staleness pass over Impeccable's own project artifacts.
|
|
5
|
+
*
|
|
6
|
+
* node doctor.mjs # human-readable report
|
|
7
|
+
* node doctor.mjs --json # machine-readable, for the skill command
|
|
8
|
+
* node doctor.mjs --fix # apply the mechanical migrations only
|
|
9
|
+
* node doctor.mjs --target <path> # pick a monorepo workspace
|
|
10
|
+
*
|
|
11
|
+
* The boot check in context.mjs reports what a session can afford to measure.
|
|
12
|
+
* This runs everything: git drift, per-workspace sweep, ignore-list validation
|
|
13
|
+
* against the live rule registry, hook script resolution.
|
|
14
|
+
*
|
|
15
|
+
* `--fix` is deliberately narrow. It performs only the migrations marked
|
|
16
|
+
* severity 'auto', the ones with no judgment in them: stamp the product record,
|
|
17
|
+
* move a sidecar out of a retired location. Anything that needs an answer from
|
|
18
|
+
* the user (a platform value, whether an inherited record still describes an
|
|
19
|
+
* app, whether a document has drifted from the code) is reported and left
|
|
20
|
+
* alone. Exit code is 0 unless the run itself failed; findings are not errors.
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
import fs from 'node:fs';
|
|
24
|
+
import path from 'node:path';
|
|
25
|
+
import { fileURLToPath } from 'node:url';
|
|
26
|
+
|
|
27
|
+
import { loadContext, extractPlatform, resolveTargetSelection } from './context.mjs';
|
|
28
|
+
import { parseTargetOptions } from './lib/target-args.mjs';
|
|
29
|
+
import { IMPECCABLE_COMMAND, IMPECCABLE_PROVIDER_ID } from './lib/provider.mjs';
|
|
30
|
+
import { parseDesignMd } from './lib/design-parser.mjs';
|
|
31
|
+
import {
|
|
32
|
+
PRODUCT_SCHEMA_VERSION,
|
|
33
|
+
readProductSchemaVersion,
|
|
34
|
+
stampProductSchema,
|
|
35
|
+
} from './lib/artifact-schema.mjs';
|
|
36
|
+
import {
|
|
37
|
+
collectBootFindingGroups,
|
|
38
|
+
checkNativePlatformEvidence,
|
|
39
|
+
designSidecarCandidatesFor,
|
|
40
|
+
} from './lib/staleness.mjs';
|
|
41
|
+
import {
|
|
42
|
+
checkDesignCoverage,
|
|
43
|
+
checkDesignDrift,
|
|
44
|
+
checkDetectorIgnores,
|
|
45
|
+
checkHookInstallation,
|
|
46
|
+
checkLegacyLiveState,
|
|
47
|
+
checkWorkspaces,
|
|
48
|
+
loadKnownRuleIds,
|
|
49
|
+
} from './lib/staleness-deep.mjs';
|
|
50
|
+
|
|
51
|
+
const SCRIPTS_DIR = path.dirname(fileURLToPath(import.meta.url));
|
|
52
|
+
|
|
53
|
+
function safeRead(filePath) {
|
|
54
|
+
try {
|
|
55
|
+
return fs.readFileSync(filePath, 'utf-8');
|
|
56
|
+
} catch {
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function parseArgs(argv) {
|
|
62
|
+
const passthrough = [];
|
|
63
|
+
const flags = { json: false, fix: false, help: false };
|
|
64
|
+
for (const arg of argv) {
|
|
65
|
+
if (arg === '--json') flags.json = true;
|
|
66
|
+
else if (arg === '--fix') flags.fix = true;
|
|
67
|
+
else if (arg === '--help' || arg === '-h') flags.help = true;
|
|
68
|
+
else passthrough.push(arg);
|
|
69
|
+
}
|
|
70
|
+
return { flags, targetOptions: parseTargetOptions(passthrough, { strict: true }) };
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function usage() {
|
|
74
|
+
return [
|
|
75
|
+
`Usage: node doctor.mjs [--json] [--fix] [--target <path>]`,
|
|
76
|
+
'',
|
|
77
|
+
"Report drift between this project's Impeccable artifacts and what the",
|
|
78
|
+
'Evolve-bundled core reads: PRODUCT.md, DESIGN.md and its sidecar,',
|
|
79
|
+
'.impeccable/config.json, surface briefs, and the design hook.',
|
|
80
|
+
'',
|
|
81
|
+
' --json Emit findings as JSON.',
|
|
82
|
+
' --fix Apply the mechanical migrations (severity "auto") only.',
|
|
83
|
+
' --target <path> Select a workspace in a monorepo.',
|
|
84
|
+
].join('\n');
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
async function collect(cwd, targetOptions) {
|
|
88
|
+
const ctx = loadContext(cwd, targetOptions);
|
|
89
|
+
const projectRoot = ctx.projectRoot || cwd;
|
|
90
|
+
const absProductPath = ctx.productPath ? path.resolve(cwd, ctx.productPath) : null;
|
|
91
|
+
const absDesignPath = ctx.designPath ? path.resolve(cwd, ctx.designPath) : null;
|
|
92
|
+
const sidecarCandidates = designSidecarCandidatesFor(projectRoot, ctx.contextDir);
|
|
93
|
+
const knownRuleIds = await loadKnownRuleIds(SCRIPTS_DIR);
|
|
94
|
+
|
|
95
|
+
const selection = resolveTargetSelection(cwd, targetOptions);
|
|
96
|
+
const workspaceCandidates = selection?.targetCandidates || [];
|
|
97
|
+
|
|
98
|
+
const workspaceResult = checkWorkspaces({
|
|
99
|
+
repoRoot: ctx.repoRoot,
|
|
100
|
+
candidates: workspaceCandidates,
|
|
101
|
+
checkNativePlatformEvidence,
|
|
102
|
+
extractPlatform,
|
|
103
|
+
readFile: safeRead,
|
|
104
|
+
});
|
|
105
|
+
const bootFindings = collectBootFindingGroups(ctx, {
|
|
106
|
+
absDesignPath,
|
|
107
|
+
sidecarCandidates,
|
|
108
|
+
projectRootPatterns: readProjectRootPatterns(ctx.repoRoot),
|
|
109
|
+
targetCandidates: workspaceCandidates,
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
const findings = [
|
|
113
|
+
...bootFindings.product,
|
|
114
|
+
...bootFindings.nativePlatform,
|
|
115
|
+
...bootFindings.designSidecar,
|
|
116
|
+
...checkDesignDrift({ designPath: absDesignPath, projectRoot }),
|
|
117
|
+
...checkDesignCoverage({ design: ctx.design, designPath: ctx.designPath, parseDesignMd }),
|
|
118
|
+
...bootFindings.config,
|
|
119
|
+
...bootFindings.buildPath,
|
|
120
|
+
...checkDetectorIgnores({ projectRoot, knownRuleIds }),
|
|
121
|
+
...bootFindings.surfaceBriefs,
|
|
122
|
+
...checkHookInstallation({
|
|
123
|
+
projectRoot,
|
|
124
|
+
repoRoot: ctx.repoRoot,
|
|
125
|
+
providerId: IMPECCABLE_PROVIDER_ID,
|
|
126
|
+
}),
|
|
127
|
+
...checkLegacyLiveState({ projectRoot }),
|
|
128
|
+
...bootFindings.projectRoots,
|
|
129
|
+
...workspaceResult.findings,
|
|
130
|
+
];
|
|
131
|
+
|
|
132
|
+
return {
|
|
133
|
+
ctx,
|
|
134
|
+
projectRoot,
|
|
135
|
+
absProductPath,
|
|
136
|
+
sidecarCandidates,
|
|
137
|
+
findings,
|
|
138
|
+
workspaces: workspaceResult.workspaces,
|
|
139
|
+
ruleRegistryAvailable: knownRuleIds !== null,
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
// Read straight from disk rather than importing context.mjs's private reader.
|
|
144
|
+
// Only the positive/negative pattern strings matter here.
|
|
145
|
+
function readProjectRootPatterns(repoRoot) {
|
|
146
|
+
if (!repoRoot) return [];
|
|
147
|
+
const patterns = [];
|
|
148
|
+
for (const name of ['config.json', 'config.local.json']) {
|
|
149
|
+
try {
|
|
150
|
+
const raw = JSON.parse(fs.readFileSync(path.join(repoRoot, '.impeccable', name), 'utf-8'));
|
|
151
|
+
if (Array.isArray(raw?.projectRoots)) {
|
|
152
|
+
for (const entry of raw.projectRoots) {
|
|
153
|
+
if (typeof entry === 'string' && entry.trim()) patterns.push(entry.trim());
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
} catch { /* missing or malformed: nothing to check */ }
|
|
157
|
+
}
|
|
158
|
+
return patterns;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* Apply the migrations that carry no decision. Returns what was done and what
|
|
163
|
+
* was deliberately left for the user.
|
|
164
|
+
*/
|
|
165
|
+
function applyFixes(report) {
|
|
166
|
+
const applied = [];
|
|
167
|
+
const skipped = [];
|
|
168
|
+
|
|
169
|
+
for (const entry of report.findings) {
|
|
170
|
+
if (entry.severity !== 'auto') {
|
|
171
|
+
skipped.push({ id: entry.id, reason: 'needs a decision from the user' });
|
|
172
|
+
continue;
|
|
173
|
+
}
|
|
174
|
+
if (entry.id === 'design-sidecar-legacy-path') {
|
|
175
|
+
const canonical = report.sidecarCandidates[0];
|
|
176
|
+
const present = report.sidecarCandidates.find((candidate) => fs.existsSync(candidate));
|
|
177
|
+
if (!canonical || !present || path.resolve(canonical) === path.resolve(present)) continue;
|
|
178
|
+
if (fs.existsSync(canonical)) {
|
|
179
|
+
skipped.push({ id: entry.id, reason: `${rel(canonical, report.projectRoot)} already exists; not overwriting` });
|
|
180
|
+
continue;
|
|
181
|
+
}
|
|
182
|
+
fs.mkdirSync(path.dirname(canonical), { recursive: true });
|
|
183
|
+
fs.renameSync(present, canonical);
|
|
184
|
+
applied.push(`Moved ${rel(present, report.projectRoot)} to ${rel(canonical, report.projectRoot)}.`);
|
|
185
|
+
continue;
|
|
186
|
+
}
|
|
187
|
+
if (entry.id === 'legacy-live-state') {
|
|
188
|
+
// Reported, never deleted here: a running live session still reads these,
|
|
189
|
+
// and losing session state to a doctor run is a worse outcome than a
|
|
190
|
+
// stale file. The report says what to remove and when.
|
|
191
|
+
skipped.push({ id: entry.id, reason: 'delete by hand once no live session is running' });
|
|
192
|
+
continue;
|
|
193
|
+
}
|
|
194
|
+
skipped.push({ id: entry.id, reason: 'no automatic migration implemented' });
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
// Stamping the product record is additive and safe, and it is what stops a
|
|
198
|
+
// later version proposing an interview the user has already sat through.
|
|
199
|
+
const productPath = report.absProductPath;
|
|
200
|
+
if (productPath && report.ctx.product && readProductSchemaVersion(report.ctx.product) === null
|
|
201
|
+
&& !report.findings.some((entry) => entry.id === 'product-schema-legacy')) {
|
|
202
|
+
fs.writeFileSync(productPath, stampProductSchema(report.ctx.product), 'utf-8');
|
|
203
|
+
applied.push(`Stamped ${rel(productPath, report.projectRoot)} as product-schema ${PRODUCT_SCHEMA_VERSION}.`);
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
return { applied, skipped };
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
function rel(filePath, root) {
|
|
210
|
+
const value = path.relative(root, filePath);
|
|
211
|
+
return value && !value.startsWith('..') ? value.split(path.sep).join('/') : filePath;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
const SEVERITY_LABEL = {
|
|
215
|
+
auto: 'automatic',
|
|
216
|
+
mention: 'worth saying',
|
|
217
|
+
route: 'needs a command',
|
|
218
|
+
};
|
|
219
|
+
|
|
220
|
+
function renderText(report, fixes) {
|
|
221
|
+
const lines = [];
|
|
222
|
+
const { findings } = report;
|
|
223
|
+
|
|
224
|
+
lines.push(`Impeccable doctor: ${rel(report.projectRoot, process.cwd()) || '.'}`);
|
|
225
|
+
if (report.ctx.isMonorepo) {
|
|
226
|
+
lines.push(`Monorepo, repo root ${rel(report.ctx.repoRoot, process.cwd()) || '.'}.`);
|
|
227
|
+
}
|
|
228
|
+
lines.push('');
|
|
229
|
+
|
|
230
|
+
if (!findings.length) {
|
|
231
|
+
lines.push('No drift found. Every artifact matches what this version reads.');
|
|
232
|
+
} else {
|
|
233
|
+
const order = ['route', 'mention', 'auto'];
|
|
234
|
+
for (const severity of order) {
|
|
235
|
+
const group = findings.filter((entry) => entry.severity === severity);
|
|
236
|
+
if (!group.length) continue;
|
|
237
|
+
lines.push(`${SEVERITY_LABEL[severity]} (${group.length}):`);
|
|
238
|
+
for (const entry of group) {
|
|
239
|
+
lines.push(` ${entry.id}${entry.path ? ` [${entry.path}]` : ''}`);
|
|
240
|
+
lines.push(` ${entry.summary}`);
|
|
241
|
+
lines.push(` → ${entry.fix}`);
|
|
242
|
+
}
|
|
243
|
+
lines.push('');
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
if (report.workspaces.length) {
|
|
248
|
+
lines.push('Workspaces:');
|
|
249
|
+
for (const workspace of report.workspaces) {
|
|
250
|
+
lines.push(` ${workspace.path} product: ${workspace.productStatus}`
|
|
251
|
+
+ ` design: ${workspace.designStatus}`
|
|
252
|
+
+ `${workspace.platform ? ` platform: ${workspace.platform}` : ''}`);
|
|
253
|
+
}
|
|
254
|
+
lines.push('');
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
if (!report.ruleRegistryAvailable) {
|
|
258
|
+
lines.push('Note: the bundled detector could not be resolved, so ignored rule ids were not validated.');
|
|
259
|
+
lines.push('');
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
if (fixes) {
|
|
263
|
+
lines.push(fixes.applied.length ? 'Applied:' : 'Applied nothing.');
|
|
264
|
+
for (const entry of fixes.applied) lines.push(` ${entry}`);
|
|
265
|
+
const held = fixes.skipped.filter((entry) => entry.reason !== 'needs a decision from the user');
|
|
266
|
+
if (held.length) {
|
|
267
|
+
lines.push('Left alone:');
|
|
268
|
+
for (const entry of held) lines.push(` ${entry.id}: ${entry.reason}`);
|
|
269
|
+
}
|
|
270
|
+
} else if (findings.some((entry) => entry.severity === 'auto')) {
|
|
271
|
+
lines.push(`Run \`node doctor.mjs --fix\` to apply the automatic migrations, `
|
|
272
|
+
+ `or \`${IMPECCABLE_COMMAND} doctor\` to work through all of them.`);
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
return lines.join('\n');
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
async function cli() {
|
|
279
|
+
let parsed;
|
|
280
|
+
try {
|
|
281
|
+
parsed = parseArgs(process.argv.slice(2));
|
|
282
|
+
} catch (err) {
|
|
283
|
+
process.stderr.write(`${err.message}\n`);
|
|
284
|
+
process.exit(1);
|
|
285
|
+
}
|
|
286
|
+
if (parsed.flags.help) {
|
|
287
|
+
process.stdout.write(`${usage()}\n`);
|
|
288
|
+
return;
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
const report = await collect(process.cwd(), parsed.targetOptions);
|
|
292
|
+
const fixes = parsed.flags.fix ? applyFixes(report) : null;
|
|
293
|
+
|
|
294
|
+
if (parsed.flags.json) {
|
|
295
|
+
process.stdout.write(`${JSON.stringify({
|
|
296
|
+
projectRoot: report.projectRoot,
|
|
297
|
+
repoRoot: report.ctx.repoRoot,
|
|
298
|
+
isMonorepo: report.ctx.isMonorepo,
|
|
299
|
+
productPath: report.ctx.productPath,
|
|
300
|
+
designPath: report.ctx.designPath,
|
|
301
|
+
platform: report.ctx.platform,
|
|
302
|
+
ruleRegistryAvailable: report.ruleRegistryAvailable,
|
|
303
|
+
findings: report.findings,
|
|
304
|
+
workspaces: report.workspaces,
|
|
305
|
+
...(fixes ? { fixes } : {}),
|
|
306
|
+
}, null, 2)}\n`);
|
|
307
|
+
return;
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
process.stdout.write(`${renderText(report, fixes)}\n`);
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
function invokedAsScript() {
|
|
314
|
+
const arg = process.argv[1];
|
|
315
|
+
if (!arg) return false;
|
|
316
|
+
try {
|
|
317
|
+
return fs.realpathSync(arg) === fs.realpathSync(fileURLToPath(import.meta.url));
|
|
318
|
+
} catch {
|
|
319
|
+
return false;
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
if (invokedAsScript()) {
|
|
324
|
+
cli().catch((err) => {
|
|
325
|
+
process.stderr.write(`impeccable doctor failed: ${err?.message || err}\n`);
|
|
326
|
+
process.exit(1);
|
|
327
|
+
});
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
export { collect, applyFixes, renderText };
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Embed a generation prompt into an image so the intent travels with the file,
|
|
3
|
+
// across harnesses and machines. Read it back with --read.
|
|
4
|
+
//
|
|
5
|
+
// node embed-prompt.mjs <image> --prompt "the prompt text"
|
|
6
|
+
// node embed-prompt.mjs <image> --prompt-file prompt.txt
|
|
7
|
+
// node embed-prompt.mjs <image> --read
|
|
8
|
+
// node embed-prompt.mjs --scan <dir...> # list rasters missing a prompt; exit 3 when any
|
|
9
|
+
//
|
|
10
|
+
// Formats: PNG (tEXt chunk, keyword "impeccable:prompt"), JPEG (COM segment).
|
|
11
|
+
// WebP and anything else fall back to a `<image>.json` sidecar; --read checks
|
|
12
|
+
// the sidecar for every format, so the fallback stays recoverable. Embedding
|
|
13
|
+
// rewrites a few MB at most: latency is milliseconds, generation is minutes.
|
|
14
|
+
// Caveat worth knowing: image optimizers in build pipelines often strip
|
|
15
|
+
// metadata from their OUTPUT files; the intent lives on the source asset,
|
|
16
|
+
// which is the one a builder reads.
|
|
17
|
+
|
|
18
|
+
import fs from 'node:fs';
|
|
19
|
+
import zlib from 'node:zlib';
|
|
20
|
+
|
|
21
|
+
const KEYWORD = 'impeccable:prompt';
|
|
22
|
+
const args = process.argv.slice(2);
|
|
23
|
+
const file = args.find(a => !a.startsWith('--'));
|
|
24
|
+
const argOf = (name) => { const i = args.indexOf(name); return i !== -1 ? args[i + 1] : null; };
|
|
25
|
+
|
|
26
|
+
function imageType(buffer) {
|
|
27
|
+
if (buffer.length > 8 && buffer.readUInt32BE(0) === 0x89504e47) return 'png';
|
|
28
|
+
if (buffer.length > 3 && buffer[0] === 0xff && buffer[1] === 0xd8) return 'jpeg';
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function readPrompt(imagePath, buffer = fs.readFileSync(imagePath)) {
|
|
33
|
+
const type = imageType(buffer);
|
|
34
|
+
let prompt = type === 'png' ? parsePng(buffer).prompt : type === 'jpeg' ? readJpegCom(buffer) : null;
|
|
35
|
+
if (prompt == null && fs.existsSync(`${imagePath}.json`)) {
|
|
36
|
+
try { prompt = JSON.parse(fs.readFileSync(`${imagePath}.json`, 'utf8')).prompt ?? null; } catch { /* stays null */ }
|
|
37
|
+
}
|
|
38
|
+
return prompt;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
if (args.includes('--scan')) {
|
|
42
|
+
const targets = args.filter(a => !a.startsWith('--'));
|
|
43
|
+
if (targets.length === 0) { console.error('embed-prompt: --scan needs at least one directory'); process.exit(1); }
|
|
44
|
+
const RASTER = /\.(png|jpe?g|webp)$/i;
|
|
45
|
+
const rasters = [];
|
|
46
|
+
const walk = (p, isRoot) => {
|
|
47
|
+
const stat = fs.statSync(p);
|
|
48
|
+
if (stat.isDirectory()) {
|
|
49
|
+
const base = p.replace(/\/+$/, '').split('/').pop();
|
|
50
|
+
// Skip installed deps and hidden dirs found during the walk, but honor a
|
|
51
|
+
// hidden dir the caller passed explicitly (e.g. .impeccable/mocks).
|
|
52
|
+
if (!isRoot && (base === 'node_modules' || base.startsWith('.'))) return;
|
|
53
|
+
for (const entry of fs.readdirSync(p)) walk(`${p.replace(/\/+$/, '')}/${entry}`, false);
|
|
54
|
+
} else if (RASTER.test(p)) {
|
|
55
|
+
rasters.push(p);
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
for (const target of targets) {
|
|
59
|
+
if (!fs.existsSync(target)) { console.error(`embed-prompt: no such path ${target}`); process.exit(1); }
|
|
60
|
+
walk(target, true);
|
|
61
|
+
}
|
|
62
|
+
let missing = 0;
|
|
63
|
+
for (const raster of rasters) {
|
|
64
|
+
if (readPrompt(raster) == null) { console.log(`MISSING: ${raster}`); missing++; }
|
|
65
|
+
}
|
|
66
|
+
console.log(`SCAN: ${rasters.length} raster${rasters.length === 1 ? '' : 's'}, ${missing} missing`);
|
|
67
|
+
process.exit(missing > 0 ? 3 : 0);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
if (!file || !fs.existsSync(file)) { console.error('embed-prompt: image file required'); process.exit(1); }
|
|
71
|
+
|
|
72
|
+
const buf = fs.readFileSync(file);
|
|
73
|
+
const type = imageType(buf);
|
|
74
|
+
|
|
75
|
+
const crcTable = (() => {
|
|
76
|
+
const t = new Uint32Array(256);
|
|
77
|
+
for (let n = 0; n < 256; n++) { let c = n; for (let k = 0; k < 8; k++) c = c & 1 ? 0xedb88320 ^ (c >>> 1) : c >>> 1; t[n] = c >>> 0; }
|
|
78
|
+
return t;
|
|
79
|
+
})();
|
|
80
|
+
const crc32 = (data) => { let c = 0xffffffff; for (const b of data) c = crcTable[(c ^ b) & 0xff] ^ (c >>> 8); return (c ^ 0xffffffff) >>> 0; };
|
|
81
|
+
|
|
82
|
+
function pngChunk(type, data) {
|
|
83
|
+
const out = Buffer.alloc(12 + data.length);
|
|
84
|
+
out.writeUInt32BE(data.length, 0);
|
|
85
|
+
out.write(type, 4, 'ascii');
|
|
86
|
+
data.copy(out, 8);
|
|
87
|
+
out.writeUInt32BE(crc32(Buffer.concat([Buffer.from(type, 'ascii'), data])), 8 + data.length);
|
|
88
|
+
return out;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function parsePng(buffer) {
|
|
92
|
+
const chunks = [];
|
|
93
|
+
let prompt = null;
|
|
94
|
+
let offset = 8;
|
|
95
|
+
while (offset + 12 <= buffer.length) {
|
|
96
|
+
const length = buffer.readUInt32BE(offset);
|
|
97
|
+
const type = buffer.toString('ascii', offset + 4, offset + 8);
|
|
98
|
+
const data = buffer.subarray(offset + 8, offset + 8 + length);
|
|
99
|
+
const nul = data.indexOf(0);
|
|
100
|
+
const promptChunk = (type === 'tEXt' || type === 'zTXt')
|
|
101
|
+
&& nul !== -1 && data.toString('latin1', 0, nul) === KEYWORD;
|
|
102
|
+
if (prompt == null && promptChunk) {
|
|
103
|
+
prompt = type === 'tEXt'
|
|
104
|
+
? data.toString('utf8', nul + 1)
|
|
105
|
+
: zlib.inflateSync(data.subarray(nul + 2)).toString('utf8');
|
|
106
|
+
}
|
|
107
|
+
chunks.push({ offset, type, promptChunk, bytes: buffer.subarray(offset, offset + 12 + length) });
|
|
108
|
+
offset += 12 + length;
|
|
109
|
+
}
|
|
110
|
+
return { chunks, prompt };
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
function readJpegCom(b) {
|
|
114
|
+
let off = 2;
|
|
115
|
+
while (off + 4 <= b.length && b[off] === 0xff) {
|
|
116
|
+
const marker = b[off + 1];
|
|
117
|
+
if (marker === 0xda) break; // start of scan: no more segments
|
|
118
|
+
const len = b.readUInt16BE(off + 2);
|
|
119
|
+
if (marker === 0xfe) {
|
|
120
|
+
const text = b.toString('utf8', off + 4, off + 2 + len);
|
|
121
|
+
if (text.startsWith(KEYWORD + '\0')) return text.slice(KEYWORD.length + 1);
|
|
122
|
+
}
|
|
123
|
+
off += 2 + len;
|
|
124
|
+
}
|
|
125
|
+
return null;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
const sidecar = `${file}.json`;
|
|
129
|
+
if (args.includes('--read')) {
|
|
130
|
+
const prompt = readPrompt(file, buf);
|
|
131
|
+
if (prompt == null) { console.error('embed-prompt: no embedded prompt found'); process.exit(2); }
|
|
132
|
+
console.log(prompt);
|
|
133
|
+
process.exit(0);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
const promptFile = argOf('--prompt-file');
|
|
137
|
+
const prompt = argOf('--prompt') ?? (promptFile ? fs.readFileSync(promptFile, 'utf8') : null);
|
|
138
|
+
if (!prompt) { console.error('embed-prompt: --prompt or --prompt-file required'); process.exit(1); }
|
|
139
|
+
|
|
140
|
+
if (type === 'png') {
|
|
141
|
+
// Insert (or replace) our tEXt chunk immediately before IEND.
|
|
142
|
+
const { chunks, prompt: existingPrompt } = parsePng(buf);
|
|
143
|
+
const iend = chunks.find((chunk) => chunk.type === 'IEND')?.offset ?? -1;
|
|
144
|
+
if (iend < 8) { console.error('embed-prompt: malformed PNG'); process.exit(1); }
|
|
145
|
+
// Drop any existing chunk with our keyword to keep embedding idempotent.
|
|
146
|
+
const replacing = existingPrompt != null;
|
|
147
|
+
const body = replacing
|
|
148
|
+
? Buffer.concat(chunks
|
|
149
|
+
.filter((chunk) => chunk.offset < iend && !chunk.promptChunk)
|
|
150
|
+
.map((chunk) => chunk.bytes))
|
|
151
|
+
: buf.subarray(8, iend);
|
|
152
|
+
const promptChunk = pngChunk('tEXt', Buffer.concat([Buffer.from(KEYWORD, 'latin1'), Buffer.from([0]), Buffer.from(prompt, 'utf8')]));
|
|
153
|
+
const end = replacing ? pngChunk('IEND', Buffer.alloc(0)) : buf.subarray(iend);
|
|
154
|
+
fs.writeFileSync(file, Buffer.concat([buf.subarray(0, 8), body, promptChunk, end]));
|
|
155
|
+
console.log(`EMBEDDED: ${file} (png tEXt, ${prompt.length} chars)`);
|
|
156
|
+
} else if (type === 'jpeg') {
|
|
157
|
+
const seg = Buffer.from(`${KEYWORD}\0${prompt}`, 'utf8');
|
|
158
|
+
if (seg.length + 2 > 0xffff) { console.error('embed-prompt: prompt too long for a JPEG segment'); process.exit(1); }
|
|
159
|
+
const com = Buffer.alloc(4 + seg.length);
|
|
160
|
+
com[0] = 0xff; com[1] = 0xfe; com.writeUInt16BE(seg.length + 2, 2); seg.copy(com, 4);
|
|
161
|
+
fs.writeFileSync(file, Buffer.concat([buf.subarray(0, 2), com, buf.subarray(2)]));
|
|
162
|
+
console.log(`EMBEDDED: ${file} (jpeg COM, ${prompt.length} chars)`);
|
|
163
|
+
} else {
|
|
164
|
+
fs.writeFileSync(sidecar, JSON.stringify({ prompt, createdAt: new Date().toISOString() }, null, 2));
|
|
165
|
+
console.log(`EMBEDDED: ${sidecar} (sidecar fallback for this format)`);
|
|
166
|
+
}
|