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,137 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { resolveProjectRoot } from '../context.mjs';
|
|
4
|
+
import { designSidecarCandidatesFor } from './staleness.mjs';
|
|
5
|
+
export { IMPECCABLE_COMMAND_PREFIX } from './provider.mjs';
|
|
6
|
+
|
|
7
|
+
export const IMPECCABLE_DIR = '.impeccable';
|
|
8
|
+
export const LIVE_DIR = 'live';
|
|
9
|
+
export const CRITIQUE_DIR = 'critique';
|
|
10
|
+
|
|
11
|
+
export function getImpeccableDir(cwd = process.cwd(), options = {}) {
|
|
12
|
+
return path.join(resolveProjectRoot(cwd, options), IMPECCABLE_DIR);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function getDesignSidecarPath(cwd = process.cwd(), options = {}) {
|
|
16
|
+
return path.join(getImpeccableDir(cwd, options), 'design.json');
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function getDesignSidecarCandidates(cwd = process.cwd(), contextDir = cwd, options = {}) {
|
|
20
|
+
return designSidecarCandidatesFor(resolveProjectRoot(cwd, options), contextDir);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function resolveDesignSidecarPath(cwd = process.cwd(), contextDir = cwd, options = {}) {
|
|
24
|
+
return firstExisting(getDesignSidecarCandidates(cwd, contextDir, options));
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function getLiveDir(cwd = process.cwd(), options = {}) {
|
|
28
|
+
return path.join(getImpeccableDir(cwd, options), LIVE_DIR);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export function getLiveConfigPath(cwd = process.cwd(), options = {}) {
|
|
32
|
+
return path.join(getLiveDir(cwd, options), 'config.json');
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export function getLegacyLiveConfigPath(scriptsDir) {
|
|
36
|
+
return path.join(scriptsDir, 'config.json');
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export function resolveLiveConfigPath({ cwd = process.cwd(), scriptsDir, env = process.env, targetPath } = {}) {
|
|
40
|
+
if (env.IMPECCABLE_LIVE_CONFIG && env.IMPECCABLE_LIVE_CONFIG.trim()) {
|
|
41
|
+
const configured = env.IMPECCABLE_LIVE_CONFIG.trim();
|
|
42
|
+
return path.isAbsolute(configured) ? configured : path.resolve(cwd, configured);
|
|
43
|
+
}
|
|
44
|
+
const primary = getLiveConfigPath(cwd, { targetPath });
|
|
45
|
+
if (fs.existsSync(primary)) return primary;
|
|
46
|
+
if (scriptsDir) {
|
|
47
|
+
const legacy = getLegacyLiveConfigPath(scriptsDir);
|
|
48
|
+
if (fs.existsSync(legacy)) return legacy;
|
|
49
|
+
}
|
|
50
|
+
return primary;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export function getLiveServerPath(cwd = process.cwd(), options = {}) {
|
|
54
|
+
return path.join(getLiveDir(cwd, options), 'server.json');
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export function getLegacyLiveServerPath(cwd = process.cwd(), options = {}) {
|
|
58
|
+
return path.join(resolveProjectRoot(cwd, options), '.impeccable-live.json');
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export function readLiveServerInfo(cwd = process.cwd(), options = {}) {
|
|
62
|
+
for (const filePath of [getLiveServerPath(cwd, options), getLegacyLiveServerPath(cwd, options)]) {
|
|
63
|
+
try {
|
|
64
|
+
const info = JSON.parse(fs.readFileSync(filePath, 'utf-8'));
|
|
65
|
+
if (info && typeof info.pid === 'number' && !isLiveServerPidReachable(info.pid)) {
|
|
66
|
+
try { fs.unlinkSync(filePath); } catch {}
|
|
67
|
+
continue;
|
|
68
|
+
}
|
|
69
|
+
return { info, path: filePath };
|
|
70
|
+
} catch {
|
|
71
|
+
/* try next */
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return null;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export function isLiveServerPidReachable(pid) {
|
|
78
|
+
try {
|
|
79
|
+
process.kill(pid, 0);
|
|
80
|
+
return true;
|
|
81
|
+
} catch (err) {
|
|
82
|
+
// ESRCH means "no such process". EPERM means the process exists but this
|
|
83
|
+
// user cannot signal it, so the live server info is still valid.
|
|
84
|
+
return err?.code !== 'ESRCH';
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export function writeLiveServerInfo(cwd = process.cwd(), info, options = {}) {
|
|
89
|
+
const filePath = getLiveServerPath(cwd, options);
|
|
90
|
+
fs.mkdirSync(path.dirname(filePath), { recursive: true });
|
|
91
|
+
fs.writeFileSync(filePath, JSON.stringify(info));
|
|
92
|
+
return filePath;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export function removeLiveServerInfo(cwd = process.cwd(), options = {}) {
|
|
96
|
+
for (const filePath of [getLiveServerPath(cwd, options), getLegacyLiveServerPath(cwd, options)]) {
|
|
97
|
+
try { fs.unlinkSync(filePath); } catch {}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Session IDs become path segments (journals, snapshots, accept receipts,
|
|
103
|
+
* preview manifests, generated component dirs). They arrive from CLI `--id`
|
|
104
|
+
* arguments and HTTP payloads, so anything containing a separator or `..` must
|
|
105
|
+
* be rejected before it reaches path.join, which would happily escape
|
|
106
|
+
* `.impeccable/live/`. Real IDs are 8 hex chars; the tests use short slugs.
|
|
107
|
+
*/
|
|
108
|
+
export function safeSessionId(id) {
|
|
109
|
+
if (typeof id !== 'string' || !/^[A-Za-z0-9_-]{1,128}$/.test(id)) {
|
|
110
|
+
throw new Error('invalid session id: ' + id);
|
|
111
|
+
}
|
|
112
|
+
return id;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export function getLiveSessionsDir(cwd = process.cwd(), options = {}) {
|
|
116
|
+
return path.join(getLiveDir(cwd, options), 'sessions');
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
export function getLegacyLiveSessionsDir(cwd = process.cwd(), options = {}) {
|
|
120
|
+
return path.join(resolveProjectRoot(cwd, options), '.impeccable-live', 'sessions');
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
export function getLiveAnnotationsDir(cwd = process.cwd(), options = {}) {
|
|
124
|
+
return path.join(getLiveDir(cwd, options), 'annotations');
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
export function getCritiqueDir(cwd = process.cwd(), options = {}) {
|
|
128
|
+
return path.join(getImpeccableDir(cwd, options), CRITIQUE_DIR);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
export function getLegacyLiveAnnotationsDir(cwd = process.cwd(), options = {}) {
|
|
132
|
+
return path.join(resolveProjectRoot(cwd, options), '.impeccable-live', 'annotations');
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
function firstExisting(paths) {
|
|
136
|
+
return paths.find((filePath) => fs.existsSync(filePath)) || null;
|
|
137
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Decide whether a given file is "generated" (regenerated by a build step,
|
|
3
|
+
* unsafe to write variants into) or "source" (safe to edit, changes persist).
|
|
4
|
+
*
|
|
5
|
+
* Why this matters: when the user picks an element on a page whose underlying
|
|
6
|
+
* file is regenerated by a build step (e.g. `scripts/build-sub-pages.js`
|
|
7
|
+
* rewriting `public/docs/*.html`), writing variants or accepted changes into
|
|
8
|
+
* that file is silent data loss — the next build wipes them.
|
|
9
|
+
*
|
|
10
|
+
* Signals, in order of reliability:
|
|
11
|
+
* 1. Git check-ignore: gitignored files are assumed generated.
|
|
12
|
+
* 2. File-header markers ("GENERATED", "DO NOT EDIT", "AUTO-GENERATED")
|
|
13
|
+
* within the first ~300 characters — catches non-git projects.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
import { execFileSync } from 'node:child_process';
|
|
17
|
+
import fs from 'node:fs';
|
|
18
|
+
import path from 'node:path';
|
|
19
|
+
|
|
20
|
+
const HEADER_SCAN_BYTES = 300;
|
|
21
|
+
const HEADER_MARKERS = [
|
|
22
|
+
/@generated\b/i,
|
|
23
|
+
/\bGENERATED\s+FILE\b/,
|
|
24
|
+
/\bAUTO-?GENERATED\b/i,
|
|
25
|
+
/\bDO\s+NOT\s+EDIT\b/i,
|
|
26
|
+
];
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* @param {string} filePath - absolute or cwd-relative path
|
|
30
|
+
* @param {object} [options]
|
|
31
|
+
* @param {string} [options.cwd] - project root (defaults to process.cwd())
|
|
32
|
+
*/
|
|
33
|
+
export function isGeneratedFile(filePath, options = {}) {
|
|
34
|
+
const cwd = options.cwd || process.cwd();
|
|
35
|
+
const absPath = path.isAbsolute(filePath) ? filePath : path.resolve(cwd, filePath);
|
|
36
|
+
|
|
37
|
+
if (isGitIgnored(absPath, cwd)) return true;
|
|
38
|
+
if (hasGeneratedHeader(absPath)) return true;
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function isGitIgnored(absPath, cwd) {
|
|
43
|
+
try {
|
|
44
|
+
// argv form, never a shell: this runs on every file the live-mode source
|
|
45
|
+
// walk reaches, so a hostile filename embedding $(...) or backticks must
|
|
46
|
+
// not be interpretable (issue #476). JSON.stringify is not shell quoting.
|
|
47
|
+
execFileSync('git', ['check-ignore', '--quiet', absPath], {
|
|
48
|
+
cwd,
|
|
49
|
+
stdio: 'ignore',
|
|
50
|
+
});
|
|
51
|
+
return true; // exit 0 = ignored
|
|
52
|
+
} catch (err) {
|
|
53
|
+
// Exit code 1 = not ignored. Exit code 128 = not a git repo or other error.
|
|
54
|
+
// In both cases, treat as "not known to be ignored."
|
|
55
|
+
return false;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function hasGeneratedHeader(absPath) {
|
|
60
|
+
let fd;
|
|
61
|
+
try {
|
|
62
|
+
fd = fs.openSync(absPath, 'r');
|
|
63
|
+
const buf = Buffer.alloc(HEADER_SCAN_BYTES);
|
|
64
|
+
const bytesRead = fs.readSync(fd, buf, 0, HEADER_SCAN_BYTES, 0);
|
|
65
|
+
const head = buf.slice(0, bytesRead).toString('utf-8');
|
|
66
|
+
return HEADER_MARKERS.some((re) => re.test(head));
|
|
67
|
+
} catch {
|
|
68
|
+
return false;
|
|
69
|
+
} finally {
|
|
70
|
+
if (fd !== undefined) { try { fs.closeSync(fd); } catch {} }
|
|
71
|
+
}
|
|
72
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Convert a live-config glob pattern to a RegExp.
|
|
3
|
+
*
|
|
4
|
+
* Supports `**` across path segments, `*` within one segment, and `?` for one
|
|
5
|
+
* character. Callers normalize project-relative paths to forward slashes.
|
|
6
|
+
*/
|
|
7
|
+
export function livePathGlobToRegex(pattern) {
|
|
8
|
+
let re = '';
|
|
9
|
+
let i = 0;
|
|
10
|
+
while (i < pattern.length) {
|
|
11
|
+
const c = pattern[i];
|
|
12
|
+
if (c === '*') {
|
|
13
|
+
if (pattern[i + 1] === '*') {
|
|
14
|
+
if (pattern[i + 2] === '/') {
|
|
15
|
+
re += '(?:.*/)?';
|
|
16
|
+
i += 3;
|
|
17
|
+
} else {
|
|
18
|
+
re += '.*';
|
|
19
|
+
i += 2;
|
|
20
|
+
}
|
|
21
|
+
} else {
|
|
22
|
+
re += '[^/]*';
|
|
23
|
+
i += 1;
|
|
24
|
+
}
|
|
25
|
+
} else if (c === '?') {
|
|
26
|
+
re += '[^/]';
|
|
27
|
+
i += 1;
|
|
28
|
+
} else if (/[.+^${}()|[\]\\]/.test(c)) {
|
|
29
|
+
re += `\\${c}`;
|
|
30
|
+
i += 1;
|
|
31
|
+
} else {
|
|
32
|
+
re += c;
|
|
33
|
+
i += 1;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return new RegExp(`^${re}$`);
|
|
37
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { spawn } from 'node:child_process';
|
|
2
|
+
|
|
3
|
+
export function browserOpenCommand(url, {
|
|
4
|
+
platform = process.platform,
|
|
5
|
+
comspec = process.env.ComSpec || process.env.COMSPEC || 'cmd.exe',
|
|
6
|
+
} = {}) {
|
|
7
|
+
if (platform === 'darwin') return { command: 'open', args: [url] };
|
|
8
|
+
if (platform === 'win32') return { command: comspec, args: ['/c', 'start', '', url] };
|
|
9
|
+
return { command: 'xdg-open', args: [url] };
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function openSystemBrowser(url, {
|
|
13
|
+
platform = process.platform,
|
|
14
|
+
comspec = process.env.ComSpec || process.env.COMSPEC || 'cmd.exe',
|
|
15
|
+
spawnImpl = spawn,
|
|
16
|
+
} = {}) {
|
|
17
|
+
const { command, args } = browserOpenCommand(url, { platform, comspec });
|
|
18
|
+
try {
|
|
19
|
+
const child = spawnImpl(command, args, { stdio: 'ignore', detached: true });
|
|
20
|
+
child.on('error', () => {});
|
|
21
|
+
child.unref();
|
|
22
|
+
return true;
|
|
23
|
+
} catch {
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -0,0 +1,281 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Dependency-free PNG decode/encode for the skill scripts.
|
|
3
|
+
*
|
|
4
|
+
* decodePng(buffer) -> { width, height, data } where data is RGBA8 (Uint8Array,
|
|
5
|
+
* width*height*4). Handles every color type (0, 2, 3, 4, 6), bit depths 1-16
|
|
6
|
+
* (16-bit is reduced to 8), all five filters, and Adam7 interlacing.
|
|
7
|
+
*
|
|
8
|
+
* encodePng({ width, height, data }) -> Buffer, RGBA8 in, 8-bit RGBA PNG out.
|
|
9
|
+
*
|
|
10
|
+
* Kept small on purpose: the skill scripts ship without npm dependencies, and
|
|
11
|
+
* comps (gpt-image PNGs) and screenshots (Playwright / harness PNGs) are the
|
|
12
|
+
* only formats the comp-fidelity tooling has to read.
|
|
13
|
+
*/
|
|
14
|
+
import zlib from 'node:zlib';
|
|
15
|
+
import fs from 'node:fs';
|
|
16
|
+
import { execFileSync } from 'node:child_process';
|
|
17
|
+
|
|
18
|
+
const SIGNATURE = Buffer.from([0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a]);
|
|
19
|
+
|
|
20
|
+
const crcTable = (() => {
|
|
21
|
+
const t = new Uint32Array(256);
|
|
22
|
+
for (let n = 0; n < 256; n++) {
|
|
23
|
+
let c = n;
|
|
24
|
+
for (let k = 0; k < 8; k++) c = c & 1 ? 0xedb88320 ^ (c >>> 1) : c >>> 1;
|
|
25
|
+
t[n] = c >>> 0;
|
|
26
|
+
}
|
|
27
|
+
return t;
|
|
28
|
+
})();
|
|
29
|
+
|
|
30
|
+
function crc32(data) {
|
|
31
|
+
let c = 0xffffffff;
|
|
32
|
+
for (let i = 0; i < data.length; i++) c = crcTable[(c ^ data[i]) & 0xff] ^ (c >>> 8);
|
|
33
|
+
return (c ^ 0xffffffff) >>> 0;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export function isPng(buf) {
|
|
37
|
+
return buf && buf.length > 8 && buf.subarray(0, 8).equals(SIGNATURE);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function readChunks(buf) {
|
|
41
|
+
const chunks = [];
|
|
42
|
+
let pos = 8;
|
|
43
|
+
while (pos + 8 <= buf.length) {
|
|
44
|
+
const length = buf.readUInt32BE(pos);
|
|
45
|
+
const type = buf.toString('latin1', pos + 4, pos + 8);
|
|
46
|
+
const data = buf.subarray(pos + 8, pos + 8 + length);
|
|
47
|
+
chunks.push({ type, data });
|
|
48
|
+
pos += 12 + length;
|
|
49
|
+
if (type === 'IEND') break;
|
|
50
|
+
}
|
|
51
|
+
return chunks;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const CHANNELS = { 0: 1, 2: 3, 3: 1, 4: 2, 6: 4 };
|
|
55
|
+
|
|
56
|
+
function paeth(a, b, c) {
|
|
57
|
+
const p = a + b - c;
|
|
58
|
+
const pa = Math.abs(p - a), pb = Math.abs(p - b), pc = Math.abs(p - c);
|
|
59
|
+
if (pa <= pb && pa <= pc) return a;
|
|
60
|
+
if (pb <= pc) return b;
|
|
61
|
+
return c;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/** Unfilter one pass of scanlines in place; returns the raw (unfiltered) bytes. */
|
|
65
|
+
function unfilter(raw, width, height, bpp, bitDepth, channels) {
|
|
66
|
+
const stride = Math.ceil((width * channels * bitDepth) / 8);
|
|
67
|
+
const out = new Uint8Array(stride * height);
|
|
68
|
+
let inPos = 0;
|
|
69
|
+
let prev = null;
|
|
70
|
+
for (let y = 0; y < height; y++) {
|
|
71
|
+
const filter = raw[inPos++];
|
|
72
|
+
const line = out.subarray(y * stride, (y + 1) * stride);
|
|
73
|
+
line.set(raw.subarray(inPos, inPos + stride));
|
|
74
|
+
inPos += stride;
|
|
75
|
+
switch (filter) {
|
|
76
|
+
case 0: break;
|
|
77
|
+
case 1: for (let i = bpp; i < stride; i++) line[i] = (line[i] + line[i - bpp]) & 0xff; break;
|
|
78
|
+
case 2: if (prev) for (let i = 0; i < stride; i++) line[i] = (line[i] + prev[i]) & 0xff; break;
|
|
79
|
+
case 3:
|
|
80
|
+
for (let i = 0; i < stride; i++) {
|
|
81
|
+
const left = i >= bpp ? line[i - bpp] : 0;
|
|
82
|
+
const up = prev ? prev[i] : 0;
|
|
83
|
+
line[i] = (line[i] + ((left + up) >> 1)) & 0xff;
|
|
84
|
+
}
|
|
85
|
+
break;
|
|
86
|
+
case 4:
|
|
87
|
+
for (let i = 0; i < stride; i++) {
|
|
88
|
+
const left = i >= bpp ? line[i - bpp] : 0;
|
|
89
|
+
const up = prev ? prev[i] : 0;
|
|
90
|
+
const ul = prev && i >= bpp ? prev[i - bpp] : 0;
|
|
91
|
+
line[i] = (line[i] + paeth(left, up, ul)) & 0xff;
|
|
92
|
+
}
|
|
93
|
+
break;
|
|
94
|
+
default: throw new Error(`png: unknown filter ${filter} on row ${y}`);
|
|
95
|
+
}
|
|
96
|
+
prev = line;
|
|
97
|
+
}
|
|
98
|
+
return { bytes: out, stride, consumed: inPos };
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/** Read sample `index` (0-based across the row) from a packed scanline. */
|
|
102
|
+
function sampleReader(bitDepth) {
|
|
103
|
+
if (bitDepth === 8) return (line, i) => line[i];
|
|
104
|
+
if (bitDepth === 16) return (line, i) => line[i * 2]; // high byte
|
|
105
|
+
const perByte = 8 / bitDepth;
|
|
106
|
+
const mask = (1 << bitDepth) - 1;
|
|
107
|
+
const scale = 255 / mask;
|
|
108
|
+
return (line, i) => {
|
|
109
|
+
const byte = line[(i / perByte) | 0];
|
|
110
|
+
const shift = 8 - bitDepth * ((i % perByte) + 1);
|
|
111
|
+
return Math.round(((byte >> shift) & mask) * scale);
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
function writePixels(dst, dstWidth, bytes, stride, passWidth, passHeight, colorType, bitDepth, palette, trns, mapX, mapY) {
|
|
116
|
+
const channels = CHANNELS[colorType];
|
|
117
|
+
const read = sampleReader(bitDepth);
|
|
118
|
+
const rawIndex = bitDepth < 8 ? (line, i) => {
|
|
119
|
+
const perByte = 8 / bitDepth;
|
|
120
|
+
const mask = (1 << bitDepth) - 1;
|
|
121
|
+
const byte = line[(i / perByte) | 0];
|
|
122
|
+
const shift = 8 - bitDepth * ((i % perByte) + 1);
|
|
123
|
+
return (byte >> shift) & mask;
|
|
124
|
+
} : read;
|
|
125
|
+
for (let y = 0; y < passHeight; y++) {
|
|
126
|
+
const line = bytes.subarray(y * stride, (y + 1) * stride);
|
|
127
|
+
const dy = mapY(y);
|
|
128
|
+
for (let x = 0; x < passWidth; x++) {
|
|
129
|
+
const dx = mapX(x);
|
|
130
|
+
const o = (dy * dstWidth + dx) * 4;
|
|
131
|
+
let r, g, b, a = 255;
|
|
132
|
+
switch (colorType) {
|
|
133
|
+
case 0: {
|
|
134
|
+
r = g = b = read(line, x);
|
|
135
|
+
if (trns && trns.gray === rawIndex(line, x)) a = 0;
|
|
136
|
+
break;
|
|
137
|
+
}
|
|
138
|
+
case 2: {
|
|
139
|
+
r = read(line, x * 3); g = read(line, x * 3 + 1); b = read(line, x * 3 + 2);
|
|
140
|
+
break;
|
|
141
|
+
}
|
|
142
|
+
case 3: {
|
|
143
|
+
const idx = rawIndex(line, x);
|
|
144
|
+
r = palette[idx * 3]; g = palette[idx * 3 + 1]; b = palette[idx * 3 + 2];
|
|
145
|
+
if (trns && trns.alpha && idx < trns.alpha.length) a = trns.alpha[idx];
|
|
146
|
+
break;
|
|
147
|
+
}
|
|
148
|
+
case 4: {
|
|
149
|
+
r = g = b = read(line, x * 2); a = read(line, x * 2 + 1);
|
|
150
|
+
break;
|
|
151
|
+
}
|
|
152
|
+
case 6: {
|
|
153
|
+
r = read(line, x * 4); g = read(line, x * 4 + 1); b = read(line, x * 4 + 2); a = read(line, x * 4 + 3);
|
|
154
|
+
break;
|
|
155
|
+
}
|
|
156
|
+
default: throw new Error(`png: unsupported color type ${colorType}`);
|
|
157
|
+
}
|
|
158
|
+
dst[o] = r; dst[o + 1] = g; dst[o + 2] = b; dst[o + 3] = a;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
return channels;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
export function decodePng(buf) {
|
|
165
|
+
if (!isPng(buf)) throw new Error('png: not a PNG (bad signature)');
|
|
166
|
+
const chunks = readChunks(buf);
|
|
167
|
+
const ihdr = chunks.find((c) => c.type === 'IHDR');
|
|
168
|
+
if (!ihdr) throw new Error('png: missing IHDR');
|
|
169
|
+
const width = ihdr.data.readUInt32BE(0);
|
|
170
|
+
const height = ihdr.data.readUInt32BE(4);
|
|
171
|
+
const bitDepth = ihdr.data[8];
|
|
172
|
+
const colorType = ihdr.data[9];
|
|
173
|
+
const interlace = ihdr.data[12];
|
|
174
|
+
const channels = CHANNELS[colorType];
|
|
175
|
+
if (!channels) throw new Error(`png: unsupported color type ${colorType}`);
|
|
176
|
+
const palChunk = chunks.find((c) => c.type === 'PLTE');
|
|
177
|
+
const palette = palChunk ? palChunk.data : null;
|
|
178
|
+
const trnsChunk = chunks.find((c) => c.type === 'tRNS');
|
|
179
|
+
let trns = null;
|
|
180
|
+
if (trnsChunk) {
|
|
181
|
+
if (colorType === 3) trns = { alpha: trnsChunk.data };
|
|
182
|
+
else if (colorType === 0) trns = { gray: trnsChunk.data.readUInt16BE(0) >> (bitDepth === 16 ? 8 : 0) };
|
|
183
|
+
}
|
|
184
|
+
const idat = Buffer.concat(chunks.filter((c) => c.type === 'IDAT').map((c) => c.data));
|
|
185
|
+
const raw = zlib.inflateSync(idat);
|
|
186
|
+
const bpp = Math.max(1, Math.ceil((channels * bitDepth) / 8));
|
|
187
|
+
const data = new Uint8Array(width * height * 4);
|
|
188
|
+
const text = {};
|
|
189
|
+
for (const c of chunks) {
|
|
190
|
+
if (c.type === 'tEXt') {
|
|
191
|
+
const z = c.data.indexOf(0);
|
|
192
|
+
if (z > 0) text[c.data.toString('latin1', 0, z)] = c.data.toString('utf8', z + 1);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
if (interlace === 0) {
|
|
197
|
+
const { bytes, stride } = unfilter(raw, width, height, bpp, bitDepth, channels);
|
|
198
|
+
writePixels(data, width, bytes, stride, width, height, colorType, bitDepth, palette, trns, (x) => x, (y) => y);
|
|
199
|
+
} else {
|
|
200
|
+
// Adam7
|
|
201
|
+
const passes = [
|
|
202
|
+
[0, 0, 8, 8], [4, 0, 8, 8], [0, 4, 4, 8], [2, 0, 4, 4], [0, 2, 2, 4], [1, 0, 2, 2], [0, 1, 1, 2],
|
|
203
|
+
];
|
|
204
|
+
let offset = 0;
|
|
205
|
+
for (const [sx, sy, dx, dy] of passes) {
|
|
206
|
+
const pw = Math.ceil((width - sx) / dx);
|
|
207
|
+
const ph = Math.ceil((height - sy) / dy);
|
|
208
|
+
if (pw <= 0 || ph <= 0) continue;
|
|
209
|
+
const { bytes, stride, consumed } = unfilter(raw.subarray(offset), pw, ph, bpp, bitDepth, channels);
|
|
210
|
+
offset += consumed;
|
|
211
|
+
writePixels(data, width, bytes, stride, pw, ph, colorType, bitDepth, palette, trns, (x) => sx + x * dx, (y) => sy + y * dy);
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
return { width, height, data, text };
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
function chunk(type, data) {
|
|
218
|
+
const len = Buffer.alloc(4);
|
|
219
|
+
len.writeUInt32BE(data.length, 0);
|
|
220
|
+
const typeBuf = Buffer.from(type, 'latin1');
|
|
221
|
+
const crc = Buffer.alloc(4);
|
|
222
|
+
crc.writeUInt32BE(crc32(Buffer.concat([typeBuf, data])), 0);
|
|
223
|
+
return Buffer.concat([len, typeBuf, data, crc]);
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
* Encode RGBA8 to PNG. `text` (optional) is a map of tEXt keyword -> value.
|
|
228
|
+
* Uses filter type 0 on every row: comps and screenshots compress fine and the
|
|
229
|
+
* encoder stays trivial.
|
|
230
|
+
*/
|
|
231
|
+
export function encodePng({ width, height, data }, { text = null, level = 6 } = {}) {
|
|
232
|
+
if (data.length !== width * height * 4) throw new Error(`png: data length ${data.length} != ${width}x${height}x4`);
|
|
233
|
+
const stride = width * 4;
|
|
234
|
+
const raw = Buffer.alloc((stride + 1) * height);
|
|
235
|
+
for (let y = 0; y < height; y++) {
|
|
236
|
+
raw[y * (stride + 1)] = 0;
|
|
237
|
+
raw.set(data.subarray(y * stride, (y + 1) * stride), y * (stride + 1) + 1);
|
|
238
|
+
}
|
|
239
|
+
const ihdr = Buffer.alloc(13);
|
|
240
|
+
ihdr.writeUInt32BE(width, 0);
|
|
241
|
+
ihdr.writeUInt32BE(height, 4);
|
|
242
|
+
ihdr[8] = 8; ihdr[9] = 6; ihdr[10] = 0; ihdr[11] = 0; ihdr[12] = 0;
|
|
243
|
+
const parts = [SIGNATURE, chunk('IHDR', ihdr)];
|
|
244
|
+
if (text) {
|
|
245
|
+
for (const [k, v] of Object.entries(text)) {
|
|
246
|
+
parts.push(chunk('tEXt', Buffer.concat([Buffer.from(k, 'latin1'), Buffer.from([0]), Buffer.from(String(v), 'utf8')])));
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
parts.push(chunk('IDAT', zlib.deflateSync(raw, { level })));
|
|
250
|
+
parts.push(chunk('IEND', Buffer.alloc(0)));
|
|
251
|
+
return Buffer.concat(parts);
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
/**
|
|
255
|
+
* Read any raster the comp pipeline meets (PNG natively; WebP / JPEG / GIF /
|
|
256
|
+
* AVIF through a converter on PATH) as RGBA. Non-PNG input is converted to a
|
|
257
|
+
* sibling cache file `<name>.<ext>.png` next to the source, never in place:
|
|
258
|
+
* a session that overwrites `comp.webp` with PNG bytes leaves a file the
|
|
259
|
+
* next tool cannot trust and a transcript replay cannot reconstruct.
|
|
260
|
+
* Returns { image, path } where path is the PNG actually decoded.
|
|
261
|
+
*/
|
|
262
|
+
export function loadRaster(file) {
|
|
263
|
+
const buf = fs.readFileSync(file);
|
|
264
|
+
if (isPng(buf)) return { image: decodePng(buf), path: file };
|
|
265
|
+
const cache = `${file}.png`;
|
|
266
|
+
if (fs.existsSync(cache)) {
|
|
267
|
+
try { const b = fs.readFileSync(cache); if (isPng(b)) return { image: decodePng(b), path: cache }; } catch { /* reconvert */ }
|
|
268
|
+
}
|
|
269
|
+
const attempts = [
|
|
270
|
+
['dwebp', [file, '-o', cache]],
|
|
271
|
+
['sips', ['-s', 'format', 'png', file, '--out', cache]],
|
|
272
|
+
['magick', [file, cache]],
|
|
273
|
+
['convert', [file, cache]],
|
|
274
|
+
];
|
|
275
|
+
let lastErr = null;
|
|
276
|
+
for (const [cmd, args] of attempts) {
|
|
277
|
+
try { execFileSync(cmd, args, { stdio: 'ignore' }); const b = fs.readFileSync(cache); if (isPng(b)) return { image: decodePng(b), path: cache }; }
|
|
278
|
+
catch (e) { lastErr = e; }
|
|
279
|
+
}
|
|
280
|
+
throw new Error(`png: ${file} is not a PNG and no converter (dwebp, sips, magick, convert) could produce ${cache}${lastErr ? `: ${lastErr.message}` : ''}`);
|
|
281
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
// Self-Evolving Workflow vendors the Impeccable core and exposes it through one canonical
|
|
2
|
+
// command instead of a separately installed upstream skill.
|
|
3
|
+
export const IMPECCABLE_COMMAND_PREFIX = "/";
|
|
4
|
+
export const IMPECCABLE_PROVIDER_ID = "evolve";
|
|
5
|
+
export const IMPECCABLE_COMMAND = `${IMPECCABLE_COMMAND_PREFIX}ew-impeccable`;
|