@bastani/atomic 0.9.13 → 0.9.14-alpha.2
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/CHANGELOG.md +58 -0
- package/README.md +3 -3
- package/dist/builtin/intercom/package.json +2 -2
- package/dist/builtin/mcp/package.json +3 -3
- package/dist/builtin/subagents/CHANGELOG.md +14 -0
- package/dist/builtin/subagents/README.md +6 -4
- package/dist/builtin/subagents/agents/code-simplifier.md +1 -1
- package/dist/builtin/subagents/agents/codebase-analyzer.md +1 -1
- package/dist/builtin/subagents/agents/codebase-locator.md +1 -1
- package/dist/builtin/subagents/agents/codebase-online-researcher.md +1 -1
- package/dist/builtin/subagents/agents/codebase-pattern-finder.md +1 -1
- package/dist/builtin/subagents/agents/codebase-research-analyzer.md +1 -1
- package/dist/builtin/subagents/agents/codebase-research-locator.md +1 -1
- package/dist/builtin/subagents/agents/debugger.md +1 -1
- package/dist/builtin/subagents/agents/worker.md +1 -1
- package/dist/builtin/subagents/package.json +6 -5
- package/dist/builtin/subagents/src/agents/agent-discovery.ts +17 -11
- package/dist/builtin/subagents/src/agents/agent-loaders.ts +115 -43
- package/dist/builtin/subagents/src/agents/agent-management-helpers.ts +10 -8
- package/dist/builtin/subagents/src/agents/agent-management.ts +8 -7
- package/dist/builtin/subagents/src/agents/agent-overrides.ts +2 -2
- package/dist/builtin/subagents/src/agents/agent-scope.ts +1 -1
- package/dist/builtin/subagents/src/agents/agent-selection.ts +1 -1
- package/dist/builtin/subagents/src/agents/agent-serializer.ts +24 -3
- package/dist/builtin/subagents/src/agents/agent-types.ts +3 -1
- package/dist/builtin/subagents/src/agents/agents.ts +7 -5
- package/dist/builtin/subagents/src/agents/frontmatter.ts +67 -22
- package/dist/builtin/subagents/src/agents/identity.ts +1 -1
- package/dist/builtin/subagents/src/agents/skills-paths.ts +1 -1
- package/dist/builtin/subagents/src/agents/skills.ts +64 -6
- package/dist/builtin/subagents/src/extension/config.ts +1 -1
- package/dist/builtin/subagents/src/extension/control-notices.ts +2 -2
- package/dist/builtin/subagents/src/extension/doctor.ts +15 -5
- package/dist/builtin/subagents/src/extension/fanout-child.ts +12 -12
- package/dist/builtin/subagents/src/extension/index.ts +23 -23
- package/dist/builtin/subagents/src/extension/notification-content.ts +1 -1
- package/dist/builtin/subagents/src/extension/schemas.ts +1 -1
- package/dist/builtin/subagents/src/extension/startup-maintenance.ts +3 -3
- package/dist/builtin/subagents/src/intercom/intercom-bridge.ts +3 -3
- package/dist/builtin/subagents/src/intercom/result-intercom.ts +1 -1
- package/dist/builtin/subagents/src/intercom/supervisor-authorization.ts +1 -1
- package/dist/builtin/subagents/src/runs/foreground/completion-notification.ts +2 -2
- package/dist/builtin/subagents/src/runs/foreground/execution-detach-reservations.ts +1 -1
- package/dist/builtin/subagents/src/runs/foreground/execution-intercom-detach.ts +3 -3
- package/dist/builtin/subagents/src/runs/foreground/execution-run-sync.ts +1 -1
- package/dist/builtin/subagents/src/runs/foreground/execution-updates.ts +2 -2
- package/dist/builtin/subagents/src/runs/foreground/execution-utils.ts +1 -1
- package/dist/builtin/subagents/src/runs/foreground/execution.ts +2 -2
- package/dist/builtin/subagents/src/runs/foreground/inprocess-run-sync.ts +27 -11
- package/dist/builtin/subagents/src/runs/foreground/notify.ts +3 -3
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-context.ts +11 -11
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-input.ts +3 -3
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-parallel-task.ts +15 -14
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-parallel.ts +19 -19
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-runtime.ts +2 -2
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-single.ts +14 -13
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-status.ts +9 -9
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-types.ts +7 -7
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-worktree.ts +6 -6
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor.ts +24 -23
- package/dist/builtin/subagents/src/runs/inprocess/control-registry.ts +1 -1
- package/dist/builtin/subagents/src/runs/inprocess/control-status.ts +3 -3
- package/dist/builtin/subagents/src/runs/inprocess/index.ts +3 -3
- package/dist/builtin/subagents/src/runs/inprocess/prompt-behavior.ts +17 -8
- package/dist/builtin/subagents/src/runs/inprocess/runner.ts +60 -12
- package/dist/builtin/subagents/src/runs/inprocess/runtime-support/nested-api.ts +8 -8
- package/dist/builtin/subagents/src/runs/inprocess/runtime-support/nested-control.ts +3 -3
- package/dist/builtin/subagents/src/runs/inprocess/runtime-support/nested-core.ts +4 -4
- package/dist/builtin/subagents/src/runs/inprocess/runtime-support/nested-projection.ts +4 -4
- package/dist/builtin/subagents/src/runs/inprocess/runtime-support/nested-registry.ts +5 -5
- package/dist/builtin/subagents/src/runs/inprocess/runtime-support/nested-rendering.ts +3 -3
- package/dist/builtin/subagents/src/runs/inprocess/runtime-support/nested-sanitize.ts +3 -3
- package/dist/builtin/subagents/src/runs/inprocess.ts +1 -1
- package/dist/builtin/subagents/src/runs/shared/long-running-guard.ts +1 -1
- package/dist/builtin/subagents/src/runs/shared/mcp-direct-tool-allowlist.ts +1 -1
- package/dist/builtin/subagents/src/runs/shared/model-candidate-filter.ts +3 -3
- package/dist/builtin/subagents/src/runs/shared/model-fallback.ts +2 -2
- package/dist/builtin/subagents/src/runs/shared/parallel-utils.ts +1 -1
- package/dist/builtin/subagents/src/runs/shared/single-output.ts +1 -1
- package/dist/builtin/subagents/src/runs/shared/subagent-control.ts +1 -1
- package/dist/builtin/subagents/src/shared/artifacts.ts +2 -2
- package/dist/builtin/subagents/src/shared/event-jsonl-writer.ts +1 -1
- package/dist/builtin/subagents/src/shared/fast-mode.ts +1 -1
- package/dist/builtin/subagents/src/shared/formatters.ts +2 -2
- package/dist/builtin/subagents/src/shared/jsonl-writer.ts +1 -1
- package/dist/builtin/subagents/src/shared/model-resolution.ts +1 -1
- package/dist/builtin/subagents/src/shared/session-tokens.ts +1 -1
- package/dist/builtin/subagents/src/shared/settings.ts +4 -4
- package/dist/builtin/subagents/src/shared/status-format.ts +1 -1
- package/dist/builtin/subagents/src/shared/types-config.ts +16 -4
- package/dist/builtin/subagents/src/shared/types-depth.ts +1 -1
- package/dist/builtin/subagents/src/shared/types-nested.ts +1 -1
- package/dist/builtin/subagents/src/shared/types-output.ts +1 -1
- package/dist/builtin/subagents/src/shared/types-results.ts +1 -1
- package/dist/builtin/subagents/src/shared/types-runtime.ts +1 -1
- package/dist/builtin/subagents/src/shared/types.ts +6 -6
- package/dist/builtin/subagents/src/shared/utils.ts +3 -3
- package/dist/builtin/subagents/src/slash/prompt-template-bridge.ts +1 -1
- package/dist/builtin/subagents/src/slash/slash-bridge.ts +3 -3
- package/dist/builtin/subagents/src/slash/slash-commands.ts +6 -6
- package/dist/builtin/subagents/src/slash/slash-live-state.ts +3 -3
- package/dist/builtin/subagents/src/tui/render-event-formatting.ts +2 -2
- package/dist/builtin/subagents/src/tui/render-layout.ts +1 -1
- package/dist/builtin/subagents/src/tui/render-progress.ts +2 -2
- package/dist/builtin/subagents/src/tui/render-result-compact.ts +7 -7
- package/dist/builtin/subagents/src/tui/render-result.ts +10 -10
- package/dist/builtin/subagents/src/tui/render-stable-output.ts +1 -1
- package/dist/builtin/subagents/src/tui/render-status-progress.ts +5 -5
- package/dist/builtin/subagents/src/tui/render.ts +4 -4
- package/dist/builtin/web-access/package.json +2 -2
- package/dist/builtin/workflows/CHANGELOG.md +57 -0
- package/dist/builtin/workflows/README.md +39 -8
- package/dist/builtin/workflows/builtin/adversarial-verification-runner.ts +16 -5
- package/dist/builtin/workflows/builtin/adversarial-verification.ts +4 -0
- package/dist/builtin/workflows/builtin/classify-and-act.ts +4 -0
- package/dist/builtin/workflows/builtin/fan-out-and-synthesize.ts +4 -0
- package/dist/builtin/workflows/builtin/generate-and-filter-runner.ts +12 -4
- package/dist/builtin/workflows/builtin/generate-and-filter.ts +4 -0
- package/dist/builtin/workflows/builtin/goal-models.ts +8 -10
- package/dist/builtin/workflows/builtin/goal.ts +4 -0
- package/dist/builtin/workflows/builtin/index.d.ts +0 -4
- package/dist/builtin/workflows/builtin/loop-until-done-runner.ts +4 -2
- package/dist/builtin/workflows/builtin/loop-until-done.ts +4 -0
- package/dist/builtin/workflows/builtin/open-claude-design-live-protocol.ts +305 -0
- package/dist/builtin/workflows/builtin/open-claude-design-phases.ts +115 -171
- package/dist/builtin/workflows/builtin/open-claude-design-runner.ts +9 -25
- package/dist/builtin/workflows/builtin/open-claude-design-setup.ts +19 -86
- package/dist/builtin/workflows/builtin/open-claude-design-utils.ts +0 -6
- package/dist/builtin/workflows/builtin/open-claude-design.d.ts +0 -5
- package/dist/builtin/workflows/builtin/open-claude-design.ts +11 -15
- package/dist/builtin/workflows/builtin/ralph-models.ts +24 -29
- package/dist/builtin/workflows/builtin/ralph.ts +4 -0
- package/dist/builtin/workflows/builtin/tournament-runner.ts +6 -3
- package/dist/builtin/workflows/builtin/tournament.ts +4 -0
- package/dist/builtin/workflows/package.json +2 -2
- package/dist/builtin/workflows/skills/impeccable/SKILL.md +3 -3
- package/dist/builtin/workflows/skills/impeccable/agents/impeccable_asset_producer.toml +25 -31
- package/dist/builtin/workflows/skills/impeccable/agents/impeccable_documenter.toml +1 -0
- package/dist/builtin/workflows/skills/impeccable/agents/impeccable_finish_reviewer.toml +16 -10
- package/dist/builtin/workflows/skills/impeccable/agents/impeccable_manual_edit_applier.toml +2 -2
- package/dist/builtin/workflows/skills/impeccable/reference/android.md +6 -0
- package/dist/builtin/workflows/skills/impeccable/reference/animate.md +3 -0
- package/dist/builtin/workflows/skills/impeccable/reference/bolder.md +3 -1
- package/dist/builtin/workflows/skills/impeccable/reference/craft-floor.md +6 -1
- package/dist/builtin/workflows/skills/impeccable/reference/critique.md +18 -2
- package/dist/builtin/workflows/skills/impeccable/reference/degraded/asset-producer.md +24 -30
- package/dist/builtin/workflows/skills/impeccable/reference/degraded/documenter.md +1 -0
- package/dist/builtin/workflows/skills/impeccable/reference/degraded/finish-reviewer.md +16 -10
- package/dist/builtin/workflows/skills/impeccable/reference/degraded/manual-edit-applier.md +2 -2
- package/dist/builtin/workflows/skills/impeccable/reference/distill.md +1 -1
- package/dist/builtin/workflows/skills/impeccable/reference/doctor.md +1 -0
- package/dist/builtin/workflows/skills/impeccable/reference/document.md +1 -1
- package/dist/builtin/workflows/skills/impeccable/reference/extract.md +1 -1
- package/dist/builtin/workflows/skills/impeccable/reference/hooks.md +12 -6
- package/dist/builtin/workflows/skills/impeccable/reference/init.md +12 -3
- package/dist/builtin/workflows/skills/impeccable/reference/ios.md +6 -0
- package/dist/builtin/workflows/skills/impeccable/reference/live-setup.md +102 -0
- package/dist/builtin/workflows/skills/impeccable/reference/live.md +113 -521
- package/dist/builtin/workflows/skills/impeccable/reference/new-work.md +39 -26
- package/dist/builtin/workflows/skills/impeccable/reference/overdrive.md +1 -1
- package/dist/builtin/workflows/skills/impeccable/reference/polish.md +3 -3
- package/dist/builtin/workflows/skills/impeccable/reference/quieter.md +1 -1
- package/dist/builtin/workflows/skills/impeccable/reference/visualize.md +25 -11
- package/dist/builtin/workflows/skills/impeccable/scripts/concept-seed.mjs +332 -221
- package/dist/builtin/workflows/skills/impeccable/scripts/context-signals.mjs +10 -19
- package/dist/builtin/workflows/skills/impeccable/scripts/context.mjs +91 -38
- package/dist/builtin/workflows/skills/impeccable/scripts/critique-storage.mjs +19 -10
- package/dist/builtin/workflows/skills/impeccable/scripts/detector/browser/injected/index.mjs +56 -6
- package/dist/builtin/workflows/skills/impeccable/scripts/detector/cli/main.mjs +10 -16
- package/dist/builtin/workflows/skills/impeccable/scripts/detector/design-system.mjs +140 -2
- package/dist/builtin/workflows/skills/impeccable/scripts/detector/detect-antipatterns-browser.js +1174 -694
- package/dist/builtin/workflows/skills/impeccable/scripts/detector/detect-antipatterns.mjs +1 -0
- package/dist/builtin/workflows/skills/impeccable/scripts/detector/engines/browser/detect-url.mjs +5 -1
- package/dist/builtin/workflows/skills/impeccable/scripts/detector/engines/regex/detect-text.mjs +431 -45
- package/dist/builtin/workflows/skills/impeccable/scripts/detector/engines/static-html/css-cascade.mjs +10 -1
- package/dist/builtin/workflows/skills/impeccable/scripts/detector/engines/static-html/detect-html.mjs +47 -6
- package/dist/builtin/workflows/skills/impeccable/scripts/detector/node/file-system.mjs +23 -22
- package/dist/builtin/workflows/skills/impeccable/scripts/detector/registry/antipatterns.mjs +0 -10
- package/dist/builtin/workflows/skills/impeccable/scripts/detector/rules/checks.mjs +384 -384
- package/dist/builtin/workflows/skills/impeccable/scripts/detector/shared/color.mjs +466 -2
- package/dist/builtin/workflows/skills/impeccable/scripts/doctor.mjs +2 -0
- package/dist/builtin/workflows/skills/impeccable/scripts/embed-prompt.mjs +270 -0
- package/dist/builtin/workflows/skills/impeccable/scripts/generate-image.mjs +51 -6
- package/dist/builtin/workflows/skills/impeccable/scripts/hook-admin.mjs +70 -10
- package/dist/builtin/workflows/skills/impeccable/scripts/hook-lib.mjs +336 -90
- package/dist/builtin/workflows/skills/impeccable/scripts/lib/composition-catalog.mjs +38 -3
- package/dist/builtin/workflows/skills/impeccable/scripts/lib/concept-catalog.mjs +77 -11
- package/dist/builtin/workflows/skills/impeccable/scripts/lib/design-parser.mjs +102 -19
- package/dist/builtin/workflows/skills/impeccable/scripts/lib/impeccable-config.mjs +44 -59
- package/dist/builtin/workflows/skills/impeccable/scripts/lib/is-generated.mjs +3 -0
- package/dist/builtin/workflows/skills/impeccable/scripts/lib/open-system-browser.mjs +57 -0
- package/dist/builtin/workflows/skills/impeccable/scripts/lib/roll-selection.mjs +369 -0
- package/dist/builtin/workflows/skills/impeccable/scripts/lib/staleness-deep.mjs +31 -3
- package/dist/builtin/workflows/skills/impeccable/scripts/lib/staleness.mjs +73 -2
- package/dist/builtin/workflows/skills/impeccable/scripts/live/accept-css.mjs +617 -0
- package/dist/builtin/workflows/skills/impeccable/scripts/live/accept-verify.mjs +71 -0
- package/dist/builtin/workflows/skills/impeccable/scripts/live/browser-script-parts.mjs +29 -2
- package/dist/builtin/workflows/skills/impeccable/scripts/live/event-validation.mjs +54 -7
- package/dist/builtin/workflows/skills/impeccable/scripts/live/frameworks/astro.mjs +47 -0
- package/dist/builtin/workflows/skills/impeccable/scripts/live/frameworks/detect-utils.mjs +157 -0
- package/dist/builtin/workflows/skills/impeccable/scripts/live/frameworks/index.mjs +143 -0
- package/dist/builtin/workflows/skills/impeccable/scripts/live/frameworks/journal.mjs +205 -0
- package/dist/builtin/workflows/skills/impeccable/scripts/live/frameworks/nextjs.mjs +49 -0
- package/dist/builtin/workflows/skills/impeccable/scripts/live/frameworks/nuxt.mjs +170 -0
- package/dist/builtin/workflows/skills/impeccable/scripts/live/frameworks/script-src.mjs +26 -0
- package/dist/builtin/workflows/skills/impeccable/scripts/live/frameworks/static-html.mjs +26 -0
- package/dist/builtin/workflows/skills/impeccable/scripts/live/frameworks/sveltekit.mjs +71 -0
- package/dist/builtin/workflows/skills/impeccable/scripts/live/frameworks/tag-strategy.mjs +247 -0
- package/dist/builtin/workflows/skills/impeccable/scripts/live/frameworks/tanstack-start.mjs +70 -0
- package/dist/builtin/workflows/skills/impeccable/scripts/live/frameworks/vite-generic.mjs +42 -0
- package/dist/builtin/workflows/skills/impeccable/scripts/live/instructions.mjs +169 -0
- package/dist/builtin/workflows/skills/impeccable/scripts/live/roots.mjs +670 -0
- package/dist/builtin/workflows/skills/impeccable/scripts/live/session-store.mjs +232 -35
- package/dist/builtin/workflows/skills/impeccable/scripts/live/svelte-ast.mjs +969 -0
- package/dist/builtin/workflows/skills/impeccable/scripts/live/svelte-component.mjs +621 -74
- package/dist/builtin/workflows/skills/impeccable/scripts/live/sveltekit-adapter.mjs +66 -28
- package/dist/builtin/workflows/skills/impeccable/scripts/live/tanstack-adapter.mjs +12 -12
- package/dist/builtin/workflows/skills/impeccable/scripts/live/ui-surfaces.mjs +75 -0
- package/dist/builtin/workflows/skills/impeccable/scripts/live/vocabulary.mjs +135 -0
- package/dist/builtin/workflows/skills/impeccable/scripts/live-accept.mjs +23 -37
- package/dist/builtin/workflows/skills/impeccable/scripts/live-browser.js +945 -115
- package/dist/builtin/workflows/skills/impeccable/scripts/live-complete.mjs +33 -1
- package/dist/builtin/workflows/skills/impeccable/scripts/live-copy-edit-agent.mjs +132 -15
- package/dist/builtin/workflows/skills/impeccable/scripts/live-inject.mjs +173 -425
- package/dist/builtin/workflows/skills/impeccable/scripts/live-insert.mjs +2 -0
- package/dist/builtin/workflows/skills/impeccable/scripts/live-poll.mjs +16 -3
- package/dist/builtin/workflows/skills/impeccable/scripts/live-resume.mjs +39 -10
- package/dist/builtin/workflows/skills/impeccable/scripts/live-server.mjs +194 -27
- package/dist/builtin/workflows/skills/impeccable/scripts/live-status.mjs +10 -4
- package/dist/builtin/workflows/skills/impeccable/scripts/live-wrap.mjs +50 -31
- package/dist/builtin/workflows/skills/impeccable/scripts/live.mjs +91 -28
- package/dist/builtin/workflows/skills/impeccable/scripts/pin.mjs +8 -5
- package/dist/builtin/workflows/skills/impeccable/scripts/serve-question.mjs +759 -109
- package/dist/builtin/workflows/src/authoring/workflow.ts +9 -0
- package/dist/builtin/workflows/src/authoring.d.ts +3 -0
- package/dist/builtin/workflows/src/durable/completed-catalog.ts +23 -2
- package/dist/builtin/workflows/src/durable/dbos-backend.ts +30 -17
- package/dist/builtin/workflows/src/durable/dbos-envelope.ts +14 -0
- package/dist/builtin/workflows/src/durable/dbos-lifecycle.ts +60 -57
- package/dist/builtin/workflows/src/durable/dbos-process-owner.ts +87 -0
- package/dist/builtin/workflows/src/durable/dbos-registration-diagnostics.ts +113 -0
- package/dist/builtin/workflows/src/durable/factory.ts +11 -8
- package/dist/builtin/workflows/src/durable/tool-failure-checkpoint.ts +5 -0
- package/dist/builtin/workflows/src/durable/tool-primitive.ts +186 -20
- package/dist/builtin/workflows/src/durable/types.ts +4 -0
- package/dist/builtin/workflows/src/durable/workflow-heartbeat-anchor.ts +153 -0
- package/dist/builtin/workflows/src/engine/run-durable-stage-session.ts +28 -0
- package/dist/builtin/workflows/src/engine/run-tool-control-registry.ts +9 -1
- package/dist/builtin/workflows/src/engine/run.ts +1 -0
- package/dist/builtin/workflows/src/extension/adopt-session-run-state.ts +20 -0
- package/dist/builtin/workflows/src/extension/background-ui-adapter.ts +9 -30
- package/dist/builtin/workflows/src/extension/extension-factory.ts +3 -0
- package/dist/builtin/workflows/src/extension/extension-lifecycle.ts +28 -10
- package/dist/builtin/workflows/src/extension/extension-runtime-state.ts +138 -0
- package/dist/builtin/workflows/src/extension/index.bundle.mjs +3365 -1341
- package/dist/builtin/workflows/src/extension/workflow-heartbeat-delivery.ts +197 -0
- package/dist/builtin/workflows/src/extension/workflow-heartbeat-notice.ts +115 -0
- package/dist/builtin/workflows/src/extension/workflow-heartbeat-scheduler.ts +962 -0
- package/dist/builtin/workflows/src/extension/workflow-prompts.ts +4 -1
- package/dist/builtin/workflows/src/extension/workflow-schema.ts +29 -5
- package/dist/builtin/workflows/src/extension/workflow-tool-send.ts +32 -1
- package/dist/builtin/workflows/src/runs/background/cancellation-registry.ts +10 -1
- package/dist/builtin/workflows/src/runs/background/job-tracker.ts +10 -1
- package/dist/builtin/workflows/src/runs/foreground/executor-prompt-nodes.ts +16 -11
- package/dist/builtin/workflows/src/runs/foreground/stage-control-registry.ts +31 -1
- package/dist/builtin/workflows/src/runs/foreground/stage-runner-context.ts +41 -10
- package/dist/builtin/workflows/src/runs/foreground/stage-runner-messages.ts +48 -0
- package/dist/builtin/workflows/src/runs/foreground/stage-runner-output.ts +4 -1
- package/dist/builtin/workflows/src/runs/foreground/stage-runner-structured-output.ts +45 -12
- package/dist/builtin/workflows/src/sdk-surface.ts +9 -0
- package/dist/builtin/workflows/src/shared/authoring-contract-ui.d.ts +10 -0
- package/dist/builtin/workflows/src/shared/authoring-contract-ui.ts +10 -0
- package/dist/builtin/workflows/src/shared/graph-store-snapshot.ts +14 -2
- package/dist/builtin/workflows/src/shared/persistence-restore.ts +12 -0
- package/dist/builtin/workflows/src/shared/prompt-answer.ts +130 -0
- package/dist/builtin/workflows/src/shared/session-scoped-singleton.ts +98 -0
- package/dist/builtin/workflows/src/shared/stage-ui-broker.ts +9 -1
- package/dist/builtin/workflows/src/shared/store-factory.ts +9 -1
- package/dist/builtin/workflows/src/shared/store-public-types.ts +2 -1
- package/dist/builtin/workflows/src/shared/store-tool-node-methods.ts +7 -0
- package/dist/builtin/workflows/src/shared/store-types.ts +18 -1
- package/dist/builtin/workflows/src/shared/tool-payload-bounds.ts +576 -0
- package/dist/builtin/workflows/src/shared/workflow-authoring-types.d.ts +1 -0
- package/dist/builtin/workflows/src/shared/workflow-authoring-types.ts +1 -0
- package/dist/builtin/workflows/src/shared/workflow-heartbeat-contract.d.ts +21 -0
- package/dist/builtin/workflows/src/shared/workflow-heartbeat-contract.ts +25 -0
- package/dist/builtin/workflows/src/tui/graph-theme.ts +8 -1
- package/dist/builtin/workflows/src/tui/graph-view-constants.ts +11 -0
- package/dist/builtin/workflows/src/tui/graph-view-input.ts +100 -5
- package/dist/builtin/workflows/src/tui/graph-view-layout.ts +42 -11
- package/dist/builtin/workflows/src/tui/graph-view-render-helpers.ts +55 -6
- package/dist/builtin/workflows/src/tui/graph-view-render.ts +71 -6
- package/dist/builtin/workflows/src/tui/graph-view-state.ts +43 -0
- package/dist/builtin/workflows/src/tui/keybindings-adapter.ts +2 -0
- package/dist/builtin/workflows/src/tui/node-card.ts +5 -1
- package/dist/builtin/workflows/src/tui/stage-chat-view-archive-history.ts +11 -2
- package/dist/builtin/workflows/src/tui/stage-chat-view.ts +36 -10
- package/dist/builtin/workflows/src/tui/switcher.ts +11 -4
- package/dist/builtin/workflows/src/tui/tool-detail.ts +348 -0
- package/dist/builtin/workflows/src/tui/workflow-status.ts +5 -2
- package/dist/cli/args.d.ts +1 -0
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js +11 -0
- package/dist/cli/args.js.map +1 -1
- package/dist/cli/auth-check.d.ts +1 -1
- package/dist/cli/auth-check.js.map +1 -1
- package/dist/cli/credential-print.d.ts +1 -1
- package/dist/cli/credential-print.js.map +1 -1
- package/dist/cli/list-models.d.ts +1 -1
- package/dist/cli/list-models.js.map +1 -1
- package/dist/cli/startup-ui.d.ts +9 -0
- package/dist/cli/startup-ui.d.ts.map +1 -1
- package/dist/cli/startup-ui.js +7 -1
- package/dist/cli/startup-ui.js.map +1 -1
- package/dist/core/agent-session-custom-message-commit.js +2 -2
- package/dist/core/agent-session-custom-message-commit.js.map +1 -1
- package/dist/core/agent-session-export.d.ts +6 -1
- package/dist/core/agent-session-export.d.ts.map +1 -1
- package/dist/core/agent-session-export.js +6 -3
- package/dist/core/agent-session-export.js.map +1 -1
- package/dist/core/agent-session-extension-bindings.d.ts.map +1 -1
- package/dist/core/agent-session-extension-bindings.js +6 -4
- package/dist/core/agent-session-extension-bindings.js.map +1 -1
- package/dist/core/agent-session-methods.d.ts +5 -2
- package/dist/core/agent-session-methods.d.ts.map +1 -1
- package/dist/core/agent-session-methods.js.map +1 -1
- package/dist/core/agent-session-prompt.d.ts +12 -1
- package/dist/core/agent-session-prompt.d.ts.map +1 -1
- package/dist/core/agent-session-prompt.js +31 -10
- package/dist/core/agent-session-prompt.js.map +1 -1
- package/dist/core/agent-session-runtime-auth.js.map +1 -1
- package/dist/core/agent-session-services.d.ts +1 -1
- package/dist/core/agent-session-services.js.map +1 -1
- package/dist/core/agent-session-skill-block.d.ts +1 -0
- package/dist/core/agent-session-skill-block.d.ts.map +1 -1
- package/dist/core/agent-session-skill-block.js +18 -2
- package/dist/core/agent-session-skill-block.js.map +1 -1
- package/dist/core/agent-session-state.d.ts.map +1 -1
- package/dist/core/agent-session-state.js +2 -1
- package/dist/core/agent-session-state.js.map +1 -1
- package/dist/core/agent-session-types.d.ts +2 -1
- package/dist/core/agent-session-types.d.ts.map +1 -1
- package/dist/core/agent-session-types.js.map +1 -1
- package/dist/core/agent-session.d.ts +1 -1
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/atomic-guide-command.js +2 -2
- package/dist/core/atomic-guide-command.js.map +1 -1
- package/dist/core/builtin-packages.d.ts.map +1 -1
- package/dist/core/builtin-packages.js +0 -6
- package/dist/core/builtin-packages.js.map +1 -1
- package/dist/core/cloudflare-gateway-binding.d.ts +11 -0
- package/dist/core/cloudflare-gateway-binding.d.ts.map +1 -0
- package/dist/core/cloudflare-gateway-binding.js +11 -0
- package/dist/core/cloudflare-gateway-binding.js.map +1 -0
- package/dist/core/codex-fast-mode-transport.d.ts +12 -0
- package/dist/core/codex-fast-mode-transport.d.ts.map +1 -0
- package/dist/core/codex-fast-mode-transport.js +130 -0
- package/dist/core/codex-fast-mode-transport.js.map +1 -0
- package/dist/core/codex-fast-mode.d.ts +20 -6
- package/dist/core/codex-fast-mode.d.ts.map +1 -1
- package/dist/core/codex-fast-mode.js +111 -3
- package/dist/core/codex-fast-mode.js.map +1 -1
- package/dist/core/diagnostics.d.ts +4 -0
- package/dist/core/diagnostics.d.ts.map +1 -1
- package/dist/core/diagnostics.js.map +1 -1
- package/dist/core/event-bus.d.ts +12 -0
- package/dist/core/event-bus.d.ts.map +1 -1
- package/dist/core/event-bus.js +22 -0
- package/dist/core/event-bus.js.map +1 -1
- package/dist/core/experimental.d.ts +25 -0
- package/dist/core/experimental.d.ts.map +1 -1
- package/dist/core/experimental.js +24 -0
- package/dist/core/experimental.js.map +1 -1
- package/dist/core/export-html/template-js/tree-filter-render.js +4 -3
- package/dist/core/export-html/template.js +4 -3
- package/dist/core/extension-session-state.d.ts +28 -0
- package/dist/core/extension-session-state.d.ts.map +1 -0
- package/dist/core/extension-session-state.js +55 -0
- package/dist/core/extension-session-state.js.map +1 -0
- package/dist/core/extensions/api-types.d.ts +6 -0
- package/dist/core/extensions/api-types.d.ts.map +1 -1
- package/dist/core/extensions/api-types.js.map +1 -1
- package/dist/core/extensions/context-types.d.ts +4 -0
- package/dist/core/extensions/context-types.d.ts.map +1 -1
- package/dist/core/extensions/context-types.js.map +1 -1
- package/dist/core/extensions/index.d.ts +1 -0
- package/dist/core/extensions/index.d.ts.map +1 -1
- package/dist/core/extensions/index.js +1 -0
- package/dist/core/extensions/index.js.map +1 -1
- package/dist/core/extensions/loader-api.d.ts +1 -1
- package/dist/core/extensions/loader-api.d.ts.map +1 -1
- package/dist/core/extensions/loader-api.js +16 -10
- package/dist/core/extensions/loader-api.js.map +1 -1
- package/dist/core/extensions/loader-virtual-modules.d.ts.map +1 -1
- package/dist/core/extensions/loader-virtual-modules.js +12 -1
- package/dist/core/extensions/loader-virtual-modules.js.map +1 -1
- package/dist/core/extensions/runner-context.d.ts +2 -0
- package/dist/core/extensions/runner-context.d.ts.map +1 -1
- package/dist/core/extensions/runner-context.js +8 -0
- package/dist/core/extensions/runner-context.js.map +1 -1
- package/dist/core/extensions/runner.d.ts +1 -0
- package/dist/core/extensions/runner.d.ts.map +1 -1
- package/dist/core/extensions/runner.js +3 -0
- package/dist/core/extensions/runner.js.map +1 -1
- package/dist/core/extensions/runtime-types.d.ts +3 -0
- package/dist/core/extensions/runtime-types.d.ts.map +1 -1
- package/dist/core/extensions/runtime-types.js.map +1 -1
- package/dist/core/extensions/ui-types.d.ts +26 -0
- package/dist/core/extensions/ui-types.d.ts.map +1 -1
- package/dist/core/extensions/ui-types.js +17 -1
- package/dist/core/extensions/ui-types.js.map +1 -1
- package/dist/core/http-dispatcher.d.ts.map +1 -1
- package/dist/core/http-dispatcher.js +5 -0
- package/dist/core/http-dispatcher.js.map +1 -1
- package/dist/core/keybindings.d.ts +24 -0
- package/dist/core/keybindings.d.ts.map +1 -1
- package/dist/core/keybindings.js +6 -0
- package/dist/core/keybindings.js.map +1 -1
- package/dist/core/model-config.d.ts +5 -0
- package/dist/core/model-config.d.ts.map +1 -1
- package/dist/core/model-config.js +1 -0
- package/dist/core/model-config.js.map +1 -1
- package/dist/core/model-registry.d.ts +1 -1
- package/dist/core/model-registry.js.map +1 -1
- package/dist/core/model-resolver-cli.d.ts +1 -1
- package/dist/core/model-resolver-cli.js.map +1 -1
- package/dist/core/model-resolver-defaults.js +3 -3
- package/dist/core/model-resolver-defaults.js.map +1 -1
- package/dist/core/model-resolver-initial.d.ts +1 -1
- package/dist/core/model-resolver-initial.js.map +1 -1
- package/dist/core/model-resolver-scope.d.ts +1 -1
- package/dist/core/model-resolver-scope.js.map +1 -1
- package/dist/core/model-runtime.d.ts +54 -0
- package/dist/core/model-runtime.d.ts.map +1 -1
- package/dist/core/model-runtime.js +96 -13
- package/dist/core/model-runtime.js.map +1 -1
- package/dist/core/oauth-login.js.map +1 -1
- package/dist/core/project-trust.d.ts +10 -0
- package/dist/core/project-trust.d.ts.map +1 -1
- package/dist/core/project-trust.js +12 -0
- package/dist/core/project-trust.js.map +1 -1
- package/dist/core/resource-loader-assets.d.ts.map +1 -1
- package/dist/core/resource-loader-assets.js +14 -5
- package/dist/core/resource-loader-assets.js.map +1 -1
- package/dist/core/resource-loader-core.d.ts +3 -0
- package/dist/core/resource-loader-core.d.ts.map +1 -1
- package/dist/core/resource-loader-core.js +5 -0
- package/dist/core/resource-loader-core.js.map +1 -1
- package/dist/core/resource-loader-internals.d.ts +2 -0
- package/dist/core/resource-loader-internals.d.ts.map +1 -1
- package/dist/core/resource-loader-internals.js.map +1 -1
- package/dist/core/resource-loader-reload.d.ts.map +1 -1
- package/dist/core/resource-loader-reload.js +2 -0
- package/dist/core/resource-loader-reload.js.map +1 -1
- package/dist/core/resource-loader-types.d.ts +2 -0
- package/dist/core/resource-loader-types.d.ts.map +1 -1
- package/dist/core/resource-loader-types.js.map +1 -1
- package/dist/core/resource-loader.d.ts +2 -0
- package/dist/core/resource-loader.d.ts.map +1 -1
- package/dist/core/resource-loader.js +1 -0
- package/dist/core/resource-loader.js.map +1 -1
- package/dist/core/sdk-types.d.ts +7 -6
- package/dist/core/sdk-types.d.ts.map +1 -1
- package/dist/core/sdk-types.js.map +1 -1
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +17 -6
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/session-manager-core.d.ts +7 -1
- package/dist/core/session-manager-core.d.ts.map +1 -1
- package/dist/core/session-manager-core.js +11 -2
- package/dist/core/session-manager-core.js.map +1 -1
- package/dist/core/session-manager-entries.d.ts +2 -2
- package/dist/core/session-manager-entries.d.ts.map +1 -1
- package/dist/core/session-manager-entries.js +6 -4
- package/dist/core/session-manager-entries.js.map +1 -1
- package/dist/core/session-manager-list.d.ts.map +1 -1
- package/dist/core/session-manager-list.js +5 -1
- package/dist/core/session-manager-list.js.map +1 -1
- package/dist/core/session-manager-types.d.ts +25 -2
- package/dist/core/session-manager-types.d.ts.map +1 -1
- package/dist/core/session-manager-types.js.map +1 -1
- package/dist/core/session-manager.d.ts +1 -1
- package/dist/core/session-manager.d.ts.map +1 -1
- package/dist/core/session-manager.js.map +1 -1
- package/dist/core/settings-manager-basic-accessors.d.ts +1 -0
- package/dist/core/settings-manager-basic-accessors.d.ts.map +1 -1
- package/dist/core/settings-manager-basic-accessors.js +8 -0
- package/dist/core/settings-manager-basic-accessors.js.map +1 -1
- package/dist/core/settings-manager-ui-accessors.d.ts +3 -1
- package/dist/core/settings-manager-ui-accessors.d.ts.map +1 -1
- package/dist/core/settings-manager-ui-accessors.js +9 -0
- package/dist/core/settings-manager-ui-accessors.js.map +1 -1
- package/dist/core/settings-manager.d.ts +1 -1
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/settings-types.d.ts +4 -0
- package/dist/core/settings-types.d.ts.map +1 -1
- package/dist/core/settings-types.js.map +1 -1
- package/dist/core/skill-catalog.d.ts +35 -0
- package/dist/core/skill-catalog.d.ts.map +1 -0
- package/dist/core/skill-catalog.js +264 -0
- package/dist/core/skill-catalog.js.map +1 -0
- package/dist/core/skills-async.d.ts.map +1 -1
- package/dist/core/skills-async.js +12 -6
- package/dist/core/skills-async.js.map +1 -1
- package/dist/core/skills.d.ts +2 -0
- package/dist/core/skills.d.ts.map +1 -1
- package/dist/core/skills.js +8 -5
- package/dist/core/skills.js.map +1 -1
- package/dist/core/slash-commands.d.ts.map +1 -1
- package/dist/core/slash-commands.js +1 -5
- package/dist/core/slash-commands.js.map +1 -1
- package/dist/core/system-prompt.js +2 -2
- package/dist/core/system-prompt.js.map +1 -1
- package/dist/core/tools/ask-user-question/ask-user-question.d.ts +25 -2
- package/dist/core/tools/ask-user-question/ask-user-question.d.ts.map +1 -1
- package/dist/core/tools/ask-user-question/ask-user-question.js +47 -18
- package/dist/core/tools/ask-user-question/ask-user-question.js.map +1 -1
- package/dist/core/tools/ask-user-question/view/components/multi-select-view.d.ts.map +1 -1
- package/dist/core/tools/ask-user-question/view/components/multi-select-view.js +5 -2
- package/dist/core/tools/ask-user-question/view/components/multi-select-view.js.map +1 -1
- package/dist/core/tools/ask-user-question/view/components/submit-picker.d.ts.map +1 -1
- package/dist/core/tools/ask-user-question/view/components/submit-picker.js +3 -1
- package/dist/core/tools/ask-user-question/view/components/submit-picker.js.map +1 -1
- package/dist/core/tools/ask-user-question/view/components/wrapping-select.d.ts.map +1 -1
- package/dist/core/tools/ask-user-question/view/components/wrapping-select.js +8 -1
- package/dist/core/tools/ask-user-question/view/components/wrapping-select.js.map +1 -1
- package/dist/core/tools/bash.d.ts.map +1 -1
- package/dist/core/tools/bash.js +2 -0
- package/dist/core/tools/bash.js.map +1 -1
- package/dist/core/tools/edit.d.ts.map +1 -1
- package/dist/core/tools/edit.js +2 -0
- package/dist/core/tools/edit.js.map +1 -1
- package/dist/core/tools/find.d.ts.map +1 -1
- package/dist/core/tools/find.js +3 -1
- package/dist/core/tools/find.js.map +1 -1
- package/dist/core/tools/grep.js +1 -1
- package/dist/core/tools/grep.js.map +1 -1
- package/dist/core/tools/hashline-engine/format.d.ts +2 -0
- package/dist/core/tools/hashline-engine/format.d.ts.map +1 -1
- package/dist/core/tools/hashline-engine/format.js +4 -2
- package/dist/core/tools/hashline-engine/format.js.map +1 -1
- package/dist/core/tools/hashline-engine/messages.d.ts +2 -0
- package/dist/core/tools/hashline-engine/messages.d.ts.map +1 -1
- package/dist/core/tools/hashline-engine/messages.js +4 -2
- package/dist/core/tools/hashline-engine/messages.js.map +1 -1
- package/dist/core/tools/hashline-engine/parser.d.ts.map +1 -1
- package/dist/core/tools/hashline-engine/parser.js +16 -4
- package/dist/core/tools/hashline-engine/parser.js.map +1 -1
- package/dist/core/tools/hashline-engine/tokenizer.d.ts.map +1 -1
- package/dist/core/tools/hashline-engine/tokenizer.js +37 -27
- package/dist/core/tools/hashline-engine/tokenizer.js.map +1 -1
- package/dist/core/tools/hashline.d.ts.map +1 -1
- package/dist/core/tools/hashline.js +8 -2
- package/dist/core/tools/hashline.js.map +1 -1
- package/dist/core/tools/ls.d.ts.map +1 -1
- package/dist/core/tools/ls.js +2 -0
- package/dist/core/tools/ls.js.map +1 -1
- package/dist/core/tools/read.d.ts.map +1 -1
- package/dist/core/tools/read.js +8 -1
- package/dist/core/tools/read.js.map +1 -1
- package/dist/core/tools/search.d.ts.map +1 -1
- package/dist/core/tools/search.js +2 -0
- package/dist/core/tools/search.js.map +1 -1
- package/dist/core/tools/todos.d.ts +3 -12
- package/dist/core/tools/todos.d.ts.map +1 -1
- package/dist/core/tools/todos.js +19 -4
- package/dist/core/tools/todos.js.map +1 -1
- package/dist/core/tools/write.d.ts.map +1 -1
- package/dist/core/tools/write.js +2 -0
- package/dist/core/tools/write.js.map +1 -1
- package/dist/index-extensions.d.ts +1 -1
- package/dist/index-extensions.d.ts.map +1 -1
- package/dist/index-extensions.js +1 -1
- package/dist/index-extensions.js.map +1 -1
- package/dist/index.d.ts +8 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -2
- package/dist/index.js.map +1 -1
- package/dist/main-runtime-api-key.d.ts +1 -1
- package/dist/main-runtime-api-key.js.map +1 -1
- package/dist/main-session-options.d.ts +1 -1
- package/dist/main-session-options.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +10 -2
- package/dist/main.js.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-rendering.js +1 -1
- package/dist/modes/interactive/components/chat-session-host-rendering.js.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-state.d.ts +8 -0
- package/dist/modes/interactive/components/chat-session-host-state.d.ts.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-state.js +8 -0
- package/dist/modes/interactive/components/chat-session-host-state.js.map +1 -1
- package/dist/modes/interactive/components/chat-session-host.d.ts +26 -0
- package/dist/modes/interactive/components/chat-session-host.d.ts.map +1 -1
- package/dist/modes/interactive/components/chat-session-host.js +38 -0
- package/dist/modes/interactive/components/chat-session-host.js.map +1 -1
- package/dist/modes/interactive/components/chat-transcript.d.ts +37 -0
- package/dist/modes/interactive/components/chat-transcript.d.ts.map +1 -1
- package/dist/modes/interactive/components/chat-transcript.js +54 -1
- package/dist/modes/interactive/components/chat-transcript.js.map +1 -1
- package/dist/modes/interactive/components/fast-mode-selector.js +1 -1
- package/dist/modes/interactive/components/fast-mode-selector.js.map +1 -1
- package/dist/modes/interactive/components/model-selector.d.ts +1 -1
- package/dist/modes/interactive/components/model-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/model-selector.js +2 -1
- package/dist/modes/interactive/components/model-selector.js.map +1 -1
- package/dist/modes/interactive/components/oauth-selector.d.ts +1 -1
- package/dist/modes/interactive/components/oauth-selector.js.map +1 -1
- package/dist/modes/interactive/components/reserved-bottom-overlay.d.ts +95 -0
- package/dist/modes/interactive/components/reserved-bottom-overlay.d.ts.map +1 -0
- package/dist/modes/interactive/components/reserved-bottom-overlay.js +234 -0
- package/dist/modes/interactive/components/reserved-bottom-overlay.js.map +1 -0
- package/dist/modes/interactive/components/session-selector-search.d.ts +4 -0
- package/dist/modes/interactive/components/session-selector-search.d.ts.map +1 -1
- package/dist/modes/interactive/components/session-selector-search.js +4 -0
- package/dist/modes/interactive/components/session-selector-search.js.map +1 -1
- package/dist/modes/interactive/components/settings-selector-handlers.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-selector-handlers.js +3 -0
- package/dist/modes/interactive/components/settings-selector-handlers.js.map +1 -1
- package/dist/modes/interactive/components/settings-selector-items.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-selector-items.js +7 -0
- package/dist/modes/interactive/components/settings-selector-items.js.map +1 -1
- package/dist/modes/interactive/components/settings-selector-types.d.ts +3 -1
- package/dist/modes/interactive/components/settings-selector-types.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-selector-types.js.map +1 -1
- package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
- package/dist/modes/interactive/components/tool-execution.js +12 -1
- package/dist/modes/interactive/components/tool-execution.js.map +1 -1
- package/dist/modes/interactive/interactive-auth-login.js.map +1 -1
- package/dist/modes/interactive/interactive-auth-routing.js.map +1 -1
- package/dist/modes/interactive/interactive-autocomplete.js +5 -4
- package/dist/modes/interactive/interactive-autocomplete.js.map +1 -1
- package/dist/modes/interactive/interactive-bash-compact.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-bash-compact.js +2 -2
- package/dist/modes/interactive/interactive-bash-compact.js.map +1 -1
- package/dist/modes/interactive/interactive-extension-custom-ui.js +94 -6
- package/dist/modes/interactive/interactive-extension-custom-ui.js.map +1 -1
- package/dist/modes/interactive/interactive-mode-base.d.ts +41 -3
- package/dist/modes/interactive/interactive-mode-base.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode-base.js +80 -11
- package/dist/modes/interactive/interactive-mode-base.js.map +1 -1
- package/dist/modes/interactive/interactive-mode-surface.d.ts +9 -1
- package/dist/modes/interactive/interactive-mode-surface.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode-surface.js.map +1 -1
- package/dist/modes/interactive/interactive-mode-types.d.ts +2 -0
- package/dist/modes/interactive/interactive-mode-types.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode-types.js.map +1 -1
- package/dist/modes/interactive/interactive-model-catalog-startup.d.ts +8 -1
- package/dist/modes/interactive/interactive-model-catalog-startup.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-model-catalog-startup.js +13 -3
- package/dist/modes/interactive/interactive-model-catalog-startup.js.map +1 -1
- package/dist/modes/interactive/interactive-model-routing.js +3 -4
- package/dist/modes/interactive/interactive-model-routing.js.map +1 -1
- package/dist/modes/interactive/interactive-render-chat.js +6 -0
- package/dist/modes/interactive/interactive-render-chat.js.map +1 -1
- package/dist/modes/interactive/interactive-resource-disclosure.js +2 -2
- package/dist/modes/interactive/interactive-resource-disclosure.js.map +1 -1
- package/dist/modes/interactive/interactive-selectors.js +7 -3
- package/dist/modes/interactive/interactive-selectors.js.map +1 -1
- package/dist/modes/interactive/interactive-session-runtime.js +7 -1
- package/dist/modes/interactive/interactive-session-runtime.js.map +1 -1
- package/dist/modes/interactive/interactive-slash-commands.js +2 -2
- package/dist/modes/interactive/interactive-slash-commands.js.map +1 -1
- package/dist/modes/interactive/interactive-startup.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-startup.js +34 -9
- package/dist/modes/interactive/interactive-startup.js.map +1 -1
- package/dist/modes/interactive/interactive-tui.d.ts +21 -1
- package/dist/modes/interactive/interactive-tui.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-tui.js +140 -38
- package/dist/modes/interactive/interactive-tui.js.map +1 -1
- package/dist/modes/interactive/model-catalog-refresh.d.ts +17 -0
- package/dist/modes/interactive/model-catalog-refresh.d.ts.map +1 -0
- package/dist/modes/interactive/model-catalog-refresh.js +84 -0
- package/dist/modes/interactive/model-catalog-refresh.js.map +1 -0
- package/dist/modes/interactive/theme/dark.json +2 -0
- package/dist/modes/interactive/theme/light.json +2 -0
- package/dist/modes/interactive/theme/theme-class.d.ts +12 -3
- package/dist/modes/interactive/theme/theme-class.d.ts.map +1 -1
- package/dist/modes/interactive/theme/theme-class.js +6 -1
- package/dist/modes/interactive/theme/theme-class.js.map +1 -1
- package/dist/modes/interactive/theme/theme-controller.d.ts +10 -2
- package/dist/modes/interactive/theme/theme-controller.d.ts.map +1 -1
- package/dist/modes/interactive/theme/theme-controller.js +23 -10
- package/dist/modes/interactive/theme/theme-controller.js.map +1 -1
- package/dist/modes/interactive/theme/theme-loading.d.ts.map +1 -1
- package/dist/modes/interactive/theme/theme-loading.js +1 -0
- package/dist/modes/interactive/theme/theme-loading.js.map +1 -1
- package/dist/modes/interactive/theme/theme-schema.d.ts +8 -0
- package/dist/modes/interactive/theme/theme-schema.d.ts.map +1 -1
- package/dist/modes/interactive/theme/theme-schema.js +3 -1
- package/dist/modes/interactive/theme/theme-schema.js.map +1 -1
- package/dist/modes/interactive/theme/theme-schema.json +9 -1
- package/dist/modes/interactive-engine/engine-custom-ui.d.ts +2 -0
- package/dist/modes/interactive-engine/engine-custom-ui.d.ts.map +1 -1
- package/dist/modes/interactive-engine/engine-custom-ui.js +1 -0
- package/dist/modes/interactive-engine/engine-custom-ui.js.map +1 -1
- package/dist/modes/interactive-engine/protocol.d.ts +1 -0
- package/dist/modes/interactive-engine/protocol.d.ts.map +1 -1
- package/dist/modes/interactive-engine/protocol.js +1 -0
- package/dist/modes/interactive-engine/protocol.js.map +1 -1
- package/dist/modes/interactive-engine/remote-component.d.ts +3 -1
- package/dist/modes/interactive-engine/remote-component.d.ts.map +1 -1
- package/dist/modes/interactive-engine/remote-component.js +3 -2
- package/dist/modes/interactive-engine/remote-component.js.map +1 -1
- package/dist/modes/json-event.d.ts +6 -1
- package/dist/modes/json-event.d.ts.map +1 -1
- package/dist/modes/json-event.js +17 -2
- package/dist/modes/json-event.js.map +1 -1
- package/dist/modes/rpc/rpc-client.js.map +1 -1
- package/dist/modes/rpc/rpc-command-handler.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-command-handler.js +5 -4
- package/dist/modes/rpc/rpc-command-handler.js.map +1 -1
- package/dist/modes/rpc/rpc-provider-auth.js.map +1 -1
- package/dist/modes/rpc/rpc-responses.js.map +1 -1
- package/dist/modes/rpc/rpc-types.d.ts +1 -1
- package/dist/modes/rpc/rpc-types.js.map +1 -1
- package/dist/package-manager-cli.js.map +1 -1
- package/dist/server/create-harness.d.ts.map +1 -1
- package/dist/server/create-harness.js +11 -0
- package/dist/server/create-harness.js.map +1 -1
- package/dist/utils/abort.d.ts +9 -0
- package/dist/utils/abort.d.ts.map +1 -0
- package/dist/utils/abort.js +19 -0
- package/dist/utils/abort.js.map +1 -0
- package/dist/utils/tools-manager.d.ts +16 -1
- package/dist/utils/tools-manager.d.ts.map +1 -1
- package/dist/utils/tools-manager.js +19 -19
- package/dist/utils/tools-manager.js.map +1 -1
- package/docs/custom-provider.md +9 -8
- package/docs/development.md +0 -1
- package/docs/docs.json +0 -1
- package/docs/environment-variables.md +3 -0
- package/docs/extensions.md +100 -2
- package/docs/json.md +3 -1
- package/docs/keybindings.md +8 -3
- package/docs/models/artificial-analysis-index.md +2 -2
- package/docs/models/model-selection.md +32 -23
- package/docs/models/pareto-efficiency.md +25 -24
- package/docs/providers.md +95 -2
- package/docs/quickstart.md +4 -2
- package/docs/rpc.md +21 -7
- package/docs/sdk.md +26 -1
- package/docs/session-format.md +5 -2
- package/docs/settings.md +34 -3
- package/docs/skills.md +16 -1
- package/docs/terminal-setup.md +15 -2
- package/docs/themes.md +22 -4
- package/docs/tools.md +3 -1
- package/docs/tui.md +2 -0
- package/docs/usage.md +5 -4
- package/docs/workflows.md +96 -19
- package/npm-shrinkwrap.json +211 -232
- package/package.json +8 -8
- package/dist/builtin/i-have-adhd/CHANGELOG.md +0 -30
- package/dist/builtin/i-have-adhd/LICENSE +0 -21
- package/dist/builtin/i-have-adhd/README.md +0 -18
- package/dist/builtin/i-have-adhd/index.ts +0 -238
- package/dist/builtin/i-have-adhd/package.json +0 -56
- package/dist/builtin/i-have-adhd/skills/i-have-adhd/SKILL.md +0 -140
- package/dist/builtin/workflows/builtin/open-claude-design-feedback.ts +0 -359
- package/dist/builtin/workflows/skills/impeccable/scripts/live/ui-core.mjs +0 -180
- package/docs/i-have-adhd.md +0 -36
|
@@ -10,9 +10,38 @@ import fs from 'node:fs';
|
|
|
10
10
|
import path from 'node:path';
|
|
11
11
|
import os from 'node:os';
|
|
12
12
|
import { createHash } from 'node:crypto';
|
|
13
|
-
|
|
13
|
+
import {
|
|
14
|
+
analyzeSvelteMarkup,
|
|
15
|
+
buildPropsScriptV2,
|
|
16
|
+
loadSvelteCompiler,
|
|
17
|
+
restoreSvelteMarkup,
|
|
18
|
+
} from './svelte-ast.mjs';
|
|
19
|
+
import {
|
|
20
|
+
bakeParamValues,
|
|
21
|
+
collectAllSelectors,
|
|
22
|
+
collectUnusedSelectors,
|
|
23
|
+
normalizeSelector,
|
|
24
|
+
parseStylesheet,
|
|
25
|
+
pruneUnusedSelectors,
|
|
26
|
+
reconcileCss,
|
|
27
|
+
serializeNodes,
|
|
28
|
+
splitSelectorList,
|
|
29
|
+
} from './accept-css.mjs';
|
|
30
|
+
import { verifyAcceptedSource } from './accept-verify.mjs';
|
|
31
|
+
|
|
32
|
+
// Preview modules stay under node_modules on purpose: SvelteKit restricts
|
|
33
|
+
// vite's server.fs.allow to src/lib, src/routes, .svelte-kit, and
|
|
34
|
+
// node_modules, so an .impeccable/ tree under the app root 403s (verified
|
|
35
|
+
// against a real SvelteKit dev server). Staleness from node_modules being
|
|
36
|
+
// unwatched is solved by REVISIONED module paths instead: every publish
|
|
37
|
+
// snapshots the variant files into a fresh r<N>/ directory and the browser
|
|
38
|
+
// imports from there, so a republished fix can never be pinned by a
|
|
39
|
+
// transform cache keyed on the old path.
|
|
14
40
|
export const SVELTE_COMPONENT_ROOT = 'node_modules/.impeccable-live';
|
|
41
|
+
// A short-lived interim location; swept so no project keeps a stray tree.
|
|
42
|
+
export const LEGACY_SVELTE_COMPONENT_ROOT = '.impeccable/live/previews';
|
|
15
43
|
export const SVELTE_RUNTIME_FILE = `${SVELTE_COMPONENT_ROOT}/__runtime.js`;
|
|
44
|
+
export const SVELTE_PROBE_FILE = `${SVELTE_COMPONENT_ROOT}/__probe.js`;
|
|
16
45
|
export const DEFERRED_ACCEPTS_FILE = '.impeccable/live/deferred-svelte-component-accepts.json';
|
|
17
46
|
|
|
18
47
|
const MUSTACHE_RE = /\{([^{}]+)\}/g;
|
|
@@ -32,9 +61,18 @@ export function manifestPathForSession(id, cwd = process.cwd()) {
|
|
|
32
61
|
|
|
33
62
|
export function ensureRuntimeHelper(cwd = process.cwd()) {
|
|
34
63
|
const file = path.join(cwd, SVELTE_RUNTIME_FILE);
|
|
35
|
-
if (fs.existsSync(file)) return file;
|
|
36
64
|
fs.mkdirSync(path.dirname(file), { recursive: true });
|
|
37
|
-
fs.
|
|
65
|
+
if (!fs.existsSync(file)) {
|
|
66
|
+
fs.writeFileSync(file, `export { mount, unmount } from 'svelte';\n`, 'utf-8');
|
|
67
|
+
}
|
|
68
|
+
// Attach-time probe: the browser imports this through the dev server before
|
|
69
|
+
// the first mount. A 404 here means the resolved app root and the dev
|
|
70
|
+
// server's root disagree, and the session fails with a named error instead
|
|
71
|
+
// of a silent fall-back to the picker at first variant.
|
|
72
|
+
const probe = path.join(cwd, SVELTE_PROBE_FILE);
|
|
73
|
+
if (!fs.existsSync(probe)) {
|
|
74
|
+
fs.writeFileSync(probe, `export const impeccableLivePreviewProbe = true;\n`, 'utf-8');
|
|
75
|
+
}
|
|
38
76
|
return file;
|
|
39
77
|
}
|
|
40
78
|
|
|
@@ -147,13 +185,19 @@ export function parseSvelteComponentFile(content) {
|
|
|
147
185
|
return { markup, cssLines, styleBlock };
|
|
148
186
|
}
|
|
149
187
|
|
|
188
|
+
// A JSDoc `@type` directly before a destructuring declaration is JSDoc cast
|
|
189
|
+
// syntax, and Svelte 5.50+ re-emits it onto the template's own declaration as
|
|
190
|
+
// `var /** @type {...} */ (h1) = root()`, which does not parse. The browser's
|
|
191
|
+
// import of the variant then fails with "Unexpected token '('" and the session
|
|
192
|
+
// shows nothing. `@typedef` documents the same shape without being a cast.
|
|
193
|
+
// tests/live-svelte-props-script.test.mjs compiles and parses what this emits.
|
|
150
194
|
function buildPropsScript(contract) {
|
|
151
195
|
if (contract.length === 0) {
|
|
152
|
-
return '<script>\n /** @
|
|
196
|
+
return '<script>\n /** @typedef {Record<string, never>} Props */\n let {} = $props();\n</script>\n';
|
|
153
197
|
}
|
|
154
198
|
const names = contract.map((c) => c.prop).join(', ');
|
|
155
199
|
const typeFields = contract.map((c) => ` ${c.prop}: string;`).join('\n');
|
|
156
|
-
return `<script>\n /** @
|
|
200
|
+
return `<script>\n /** @typedef {{\n${typeFields}\n }} Props */\n let { ${names} } = $props();\n</script>\n`;
|
|
157
201
|
}
|
|
158
202
|
|
|
159
203
|
function buildVariantStub(variantNum, originalWithProps, contract) {
|
|
@@ -167,6 +211,14 @@ function buildInsertVariantStub(variantNum) {
|
|
|
167
211
|
return `${buildPropsScript([])}<div class="impeccable-insert-preview">Insert variant ${variantNum}</div>\n\n<style>\n .impeccable-insert-preview { display: block; }\n</style>\n`;
|
|
168
212
|
}
|
|
169
213
|
|
|
214
|
+
/**
|
|
215
|
+
* Scaffold a component-preview session. The scaffold is AST-based: the app's
|
|
216
|
+
* own svelte compiler parses the selected markup, control-flow blocks are
|
|
217
|
+
* preserved (an each collection crosses the prop contract as ONE structured
|
|
218
|
+
* prop, its loop body verbatim), and constructs a detached preview cannot
|
|
219
|
+
* support return `{ fallback: 'source-preview', reason }` so the caller keeps
|
|
220
|
+
* the markup inside the route file instead of shipping a wrong preview.
|
|
221
|
+
*/
|
|
170
222
|
export function scaffoldSvelteComponentSession({
|
|
171
223
|
id,
|
|
172
224
|
count,
|
|
@@ -176,25 +228,55 @@ export function scaffoldSvelteComponentSession({
|
|
|
176
228
|
originalLines,
|
|
177
229
|
cwd = process.cwd(),
|
|
178
230
|
}) {
|
|
231
|
+
const originalMarkup = originalLines.join('\n');
|
|
232
|
+
|
|
233
|
+
const compiler = loadSvelteCompiler(cwd);
|
|
234
|
+
if (!compiler) {
|
|
235
|
+
return { fallback: 'source-preview', reason: 'svelte 5 compiler not resolvable from the app root' };
|
|
236
|
+
}
|
|
237
|
+
const analysis = analyzeSvelteMarkup(originalMarkup, compiler.parse);
|
|
238
|
+
if (!analysis.ok) {
|
|
239
|
+
return { fallback: 'source-preview', reason: analysis.reason };
|
|
240
|
+
}
|
|
241
|
+
|
|
179
242
|
ensureRuntimeHelper(cwd);
|
|
180
243
|
const dir = componentSessionDir(id, cwd);
|
|
181
244
|
fs.mkdirSync(dir, { recursive: true });
|
|
182
245
|
|
|
183
|
-
const
|
|
184
|
-
const
|
|
185
|
-
|
|
246
|
+
const contract = analysis.contract;
|
|
247
|
+
const seeded = extractMatchingSourceCss(
|
|
248
|
+
safeReadSource(path.resolve(cwd, sourceFile)),
|
|
249
|
+
originalMarkup,
|
|
250
|
+
);
|
|
251
|
+
const seededCss = seeded.css;
|
|
252
|
+
// The preview compiles in isolation, so NONE of these source rules applied
|
|
253
|
+
// to what the user approved. Accept enforces that preview truth: any of
|
|
254
|
+
// them the variant does not re-declare is superseded and removed, instead
|
|
255
|
+
// of re-attaching to the accepted markup through kept class names (the
|
|
256
|
+
// ".decisions grid grabs the new board" failure). Only the CLASS-matched
|
|
257
|
+
// selectors are candidates; tag rules style shared route elements.
|
|
258
|
+
const seededSelectors = [...seeded.supersedable];
|
|
186
259
|
|
|
187
260
|
const manifest = {
|
|
188
261
|
id,
|
|
189
262
|
previewMode: 'svelte-component',
|
|
263
|
+
contractVersion: 2,
|
|
190
264
|
sourceFile: sourceFile.split(path.sep).join('/'),
|
|
191
265
|
sourceStartLine,
|
|
192
266
|
sourceEndLine,
|
|
193
267
|
count,
|
|
194
268
|
propContract: contract,
|
|
195
269
|
originalMarkup,
|
|
270
|
+
seededSelectors,
|
|
196
271
|
componentDir: path.relative(cwd, dir).split(path.sep).join('/'),
|
|
272
|
+
// Absolute paths let the browser fall back to /@fs/ imports when the dev
|
|
273
|
+
// server's base or root makes root-relative URLs miss, and probe whether
|
|
274
|
+
// the preview tree is reachable at all before blaming a variant.
|
|
275
|
+
componentDirAbs: dir.split(path.sep).join('/'),
|
|
197
276
|
runtimeModule: `/${SVELTE_RUNTIME_FILE}`,
|
|
277
|
+
runtimeModuleAbs: path.join(cwd, SVELTE_RUNTIME_FILE).split(path.sep).join('/'),
|
|
278
|
+
probeModule: `/${SVELTE_PROBE_FILE}`,
|
|
279
|
+
probeModuleAbs: path.join(cwd, SVELTE_PROBE_FILE).split(path.sep).join('/'),
|
|
198
280
|
};
|
|
199
281
|
|
|
200
282
|
fs.writeFileSync(path.join(dir, 'manifest.json'), JSON.stringify(manifest, null, 2) + '\n', 'utf-8');
|
|
@@ -202,7 +284,7 @@ export function scaffoldSvelteComponentSession({
|
|
|
202
284
|
for (let n = 1; n <= count; n++) {
|
|
203
285
|
const variantFile = path.join(dir, `v${n}.svelte`);
|
|
204
286
|
if (!fs.existsSync(variantFile)) {
|
|
205
|
-
fs.writeFileSync(variantFile,
|
|
287
|
+
fs.writeFileSync(variantFile, buildVariantStubV2(n, analysis.markupWithProps, contract, seededCss), 'utf-8');
|
|
206
288
|
}
|
|
207
289
|
}
|
|
208
290
|
|
|
@@ -211,7 +293,98 @@ export function scaffoldSvelteComponentSession({
|
|
|
211
293
|
manifestFile: path.relative(cwd, path.join(dir, 'manifest.json')).split(path.sep).join('/'),
|
|
212
294
|
componentDir: manifest.componentDir,
|
|
213
295
|
propContract: contract,
|
|
296
|
+
// Inlined so the generate event's scaffold payload carries the stub
|
|
297
|
+
// shape; the agent edits vN.svelte in place instead of spending reads on
|
|
298
|
+
// the manifest and stub files (or deleting and recreating them).
|
|
299
|
+
stubMarkup: analysis.markupWithProps,
|
|
300
|
+
seededCss,
|
|
301
|
+
};
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
function safeReadSource(filePath) {
|
|
305
|
+
try { return fs.readFileSync(filePath, 'utf-8'); } catch { return ''; }
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
function escapeSelectorToken(token) {
|
|
309
|
+
return String(token).replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
/**
|
|
313
|
+
* Seed variant stubs with the source component's rules that already style the
|
|
314
|
+
* selected markup, so variants start from the real cascade (a detached
|
|
315
|
+
* preview inherits none of the route's compile-scoped CSS) instead of
|
|
316
|
+
* reimplementing it blind.
|
|
317
|
+
*
|
|
318
|
+
* Returns { css, supersedable }. `css` is every matching rule (class OR tag
|
|
319
|
+
* matched). `supersedable` holds only the CLASS-matched selectors: those are
|
|
320
|
+
* the accept-time removal candidates. Tag selectors (h1, a, p) style shared
|
|
321
|
+
* elements across the whole route, so they seed the preview but are never
|
|
322
|
+
* candidates for removal.
|
|
323
|
+
*/
|
|
324
|
+
export function extractMatchingSourceCss(routeSource, originalMarkup) {
|
|
325
|
+
const empty = { css: '', supersedable: new Set() };
|
|
326
|
+
const styleMatch = String(routeSource || '').match(/<style\b[^>]*>([\s\S]*?)<\/style\s*>/i);
|
|
327
|
+
if (!styleMatch) return empty;
|
|
328
|
+
const classNames = new Set();
|
|
329
|
+
const classRe = /class\s*=\s*(["'])(.*?)\1/g;
|
|
330
|
+
let m;
|
|
331
|
+
while ((m = classRe.exec(originalMarkup))) {
|
|
332
|
+
for (const cls of m[2].split(/\s+/)) if (cls && !cls.includes('{')) classNames.add(cls);
|
|
333
|
+
}
|
|
334
|
+
const tagRe = /<([a-z][a-z0-9-]*)/gi;
|
|
335
|
+
const tags = new Set();
|
|
336
|
+
while ((m = tagRe.exec(originalMarkup))) tags.add(m[1].toLowerCase());
|
|
337
|
+
if (classNames.size === 0 && tags.size === 0) return empty;
|
|
338
|
+
|
|
339
|
+
// Token-boundary matching, never substring: `.btn` must not match
|
|
340
|
+
// `.btn-primary`, and `.stage` must not match `.stages`. A substring hit
|
|
341
|
+
// seeds a rule that never styled the pick, and a falsely seeded selector
|
|
342
|
+
// becomes an accept-time DELETION of a hand-written rule.
|
|
343
|
+
const classRes = [...classNames].map((cls) => new RegExp('\\.' + escapeSelectorToken(cls) + '(?![A-Za-z0-9_-])'));
|
|
344
|
+
const tagRes = [...tags].map((tag) => new RegExp('(^|[\\s>+~,(])' + escapeSelectorToken(tag) + '(?![A-Za-z0-9_-])', 'i'));
|
|
345
|
+
const classMatches = (selector) => classRes.some((re) => re.test(selector));
|
|
346
|
+
const tagMatches = (selector) => tagRes.some((re) => re.test(selector));
|
|
347
|
+
|
|
348
|
+
const supersedable = new Set();
|
|
349
|
+
const ruleMatches = (prelude) => {
|
|
350
|
+
let matched = false;
|
|
351
|
+
for (const selector of splitSelectorList(prelude)) {
|
|
352
|
+
if (classMatches(selector)) {
|
|
353
|
+
matched = true;
|
|
354
|
+
supersedable.add(normalizeSelector(selector));
|
|
355
|
+
} else if (tagMatches(selector)) {
|
|
356
|
+
matched = true;
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
return matched;
|
|
360
|
+
};
|
|
361
|
+
|
|
362
|
+
const pick = (nodes) => {
|
|
363
|
+
const kept = [];
|
|
364
|
+
for (const node of nodes) {
|
|
365
|
+
if (node.type === 'rule' && ruleMatches(node.prelude)) kept.push(node);
|
|
366
|
+
else if (node.type === 'at' && node.children) {
|
|
367
|
+
const children = pick(node.children);
|
|
368
|
+
if (children.length) kept.push({ ...node, children });
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
return kept;
|
|
214
372
|
};
|
|
373
|
+
return { css: serializeNodes(pick(parseStylesheet(styleMatch[1]))), supersedable };
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
function buildVariantStubV2(variantNum, markupWithProps, contract, seededCss) {
|
|
377
|
+
const propsComment = contract.length > 0
|
|
378
|
+
? `\n<!-- Props: ${contract.map((c) => `${c.prop} (${c.kind}) <- {${c.expr}}`).join(', ')} -->\n`
|
|
379
|
+
: '';
|
|
380
|
+
// The guard comments must never contain the literal "<style" character
|
|
381
|
+
// sequence: agents (and the fake test agent) locate the style block with
|
|
382
|
+
// string searches, and a mention inside a comment truncates their surgery
|
|
383
|
+
// mid-comment.
|
|
384
|
+
const css = seededCss
|
|
385
|
+
? `\n<style>\n /* Variant ${variantNum}: seeded from the route's current rules; restyle or delete freely.\n ALL rules go inside THIS block. Svelte allows exactly one top-level style\n element per component; appending a second one is a compile error. */\n${seededCss.split('\n').map((l) => (l.trim() ? ' ' + l : '')).join('\n')}\n</style>\n`
|
|
386
|
+
: `\n<style>\n /* Variant ${variantNum}: add all CSS inside THIS block. Svelte allows exactly\n one top-level style element; a second one is a compile error. */\n</style>\n`;
|
|
387
|
+
return `${buildPropsScriptV2(contract)}${propsComment}${markupWithProps.trim()}\n${css}`;
|
|
215
388
|
}
|
|
216
389
|
|
|
217
390
|
export function scaffoldSvelteComponentInsertSession({
|
|
@@ -244,7 +417,11 @@ export function scaffoldSvelteComponentInsertSession({
|
|
|
244
417
|
count,
|
|
245
418
|
propContract: [],
|
|
246
419
|
componentDir: path.relative(cwd, dir).split(path.sep).join('/'),
|
|
420
|
+
componentDirAbs: dir.split(path.sep).join('/'),
|
|
247
421
|
runtimeModule: `/${SVELTE_RUNTIME_FILE}`,
|
|
422
|
+
runtimeModuleAbs: path.join(cwd, SVELTE_RUNTIME_FILE).split(path.sep).join('/'),
|
|
423
|
+
probeModule: `/${SVELTE_PROBE_FILE}`,
|
|
424
|
+
probeModuleAbs: path.join(cwd, SVELTE_PROBE_FILE).split(path.sep).join('/'),
|
|
248
425
|
};
|
|
249
426
|
|
|
250
427
|
fs.writeFileSync(path.join(dir, 'manifest.json'), JSON.stringify(manifest, null, 2) + '\n', 'utf-8');
|
|
@@ -269,16 +446,24 @@ export function findSvelteComponentManifest(id, cwd = process.cwd()) {
|
|
|
269
446
|
if (fs.existsSync(direct)) {
|
|
270
447
|
return readManifest(direct);
|
|
271
448
|
}
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
449
|
+
// Legacy location: a session scaffolded by an older version can still be
|
|
450
|
+
// accepted after an upgrade.
|
|
451
|
+
const legacyDirect = path.join(cwd, LEGACY_SVELTE_COMPONENT_ROOT, id, 'manifest.json');
|
|
452
|
+
if (fs.existsSync(legacyDirect)) {
|
|
453
|
+
return readManifest(legacyDirect);
|
|
454
|
+
}
|
|
455
|
+
for (const rootRel of [SVELTE_COMPONENT_ROOT, LEGACY_SVELTE_COMPONENT_ROOT]) {
|
|
456
|
+
const root = path.join(cwd, rootRel);
|
|
457
|
+
if (!fs.existsSync(root)) continue;
|
|
458
|
+
for (const entry of fs.readdirSync(root, { withFileTypes: true })) {
|
|
459
|
+
if (!entry.isDirectory()) continue;
|
|
460
|
+
const candidate = path.join(root, entry.name, 'manifest.json');
|
|
461
|
+
if (!fs.existsSync(candidate)) continue;
|
|
462
|
+
try {
|
|
463
|
+
const manifest = readManifest(candidate);
|
|
464
|
+
if (manifest?.id === id) return { ...manifest, manifestPath: candidate };
|
|
465
|
+
} catch { /* skip */ }
|
|
466
|
+
}
|
|
282
467
|
}
|
|
283
468
|
return null;
|
|
284
469
|
}
|
|
@@ -482,35 +667,6 @@ function rewriteParamSelectors(selector, paramValues) {
|
|
|
482
667
|
return { keep, selector: next };
|
|
483
668
|
}
|
|
484
669
|
|
|
485
|
-
function splitSelectorList(prelude) {
|
|
486
|
-
const selectors = [];
|
|
487
|
-
let start = 0;
|
|
488
|
-
let bracket = 0;
|
|
489
|
-
let paren = 0;
|
|
490
|
-
let quote = null;
|
|
491
|
-
for (let i = 0; i < prelude.length; i++) {
|
|
492
|
-
const ch = prelude[i];
|
|
493
|
-
if (quote) {
|
|
494
|
-
if (ch === '\\') i++;
|
|
495
|
-
else if (ch === quote) quote = null;
|
|
496
|
-
continue;
|
|
497
|
-
}
|
|
498
|
-
if (ch === '"' || ch === "'") {
|
|
499
|
-
quote = ch;
|
|
500
|
-
continue;
|
|
501
|
-
}
|
|
502
|
-
if (ch === '[') bracket++;
|
|
503
|
-
else if (ch === ']') bracket = Math.max(0, bracket - 1);
|
|
504
|
-
else if (ch === '(') paren++;
|
|
505
|
-
else if (ch === ')') paren = Math.max(0, paren - 1);
|
|
506
|
-
else if (ch === ',' && bracket === 0 && paren === 0) {
|
|
507
|
-
selectors.push(prelude.slice(start, i));
|
|
508
|
-
start = i + 1;
|
|
509
|
-
}
|
|
510
|
-
}
|
|
511
|
-
selectors.push(prelude.slice(start));
|
|
512
|
-
return selectors;
|
|
513
|
-
}
|
|
514
670
|
|
|
515
671
|
function selectorHasVariant(selector, variantNum) {
|
|
516
672
|
return variantSelectorRegex(variantNum).test(selector);
|
|
@@ -558,10 +714,24 @@ export function inlineSvelteComponentAccept(manifest, variantNum, paramValues =
|
|
|
558
714
|
|
|
559
715
|
const rootTag = matchOpeningTag(markup)?.tag || 'div';
|
|
560
716
|
const contract = manifest.propContract || [];
|
|
717
|
+
const compiler = loadSvelteCompiler(cwd);
|
|
561
718
|
const mergedMarkup = mergeOriginalTopLevelAttrs(markup, manifest.originalMarkup || '');
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
719
|
+
|
|
720
|
+
// Restore props back to route expressions. Contract v2 restores through the
|
|
721
|
+
// AST so a prop used without braces (each headers, attribute positions)
|
|
722
|
+
// still maps back to its original expression; v1 falls back to the textual
|
|
723
|
+
// placeholder swap.
|
|
724
|
+
let restoredText;
|
|
725
|
+
if (Number(manifest.contractVersion) === 2 && compiler) {
|
|
726
|
+
const restored = restoreSvelteMarkup(mergedMarkup, contract, compiler.parse);
|
|
727
|
+
if (!restored.ok) {
|
|
728
|
+
return { handled: false, error: 'Accepted variant does not parse: ' + restored.reason, ...resultBase };
|
|
729
|
+
}
|
|
730
|
+
restoredText = restored.markup;
|
|
731
|
+
} else {
|
|
732
|
+
restoredText = substitutePropsWithExprs(mergedMarkup, contract);
|
|
733
|
+
}
|
|
734
|
+
const restoredMarkup = restoredText.split('\n').map((line) => line.trimEnd());
|
|
565
735
|
|
|
566
736
|
const sourceContent = fs.readFileSync(sourceFile, 'utf-8');
|
|
567
737
|
const sourceLines = sourceContent.split('\n');
|
|
@@ -572,10 +742,7 @@ export function inlineSvelteComponentAccept(manifest, variantNum, paramValues =
|
|
|
572
742
|
}
|
|
573
743
|
|
|
574
744
|
const indent = sourceLines[start].match(/^(\s*)/)?.[1] || '';
|
|
575
|
-
const indentedMarkup = restoredMarkup
|
|
576
|
-
if (line.trim() === '') return '';
|
|
577
|
-
return indent + line.trimStart();
|
|
578
|
-
});
|
|
745
|
+
const indentedMarkup = reindentPreservingStructure(restoredMarkup, indent);
|
|
579
746
|
|
|
580
747
|
let newLines = [
|
|
581
748
|
...sourceLines.slice(0, start),
|
|
@@ -583,25 +750,242 @@ export function inlineSvelteComponentAccept(manifest, variantNum, paramValues =
|
|
|
583
750
|
...sourceLines.slice(end + 1),
|
|
584
751
|
];
|
|
585
752
|
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
753
|
+
// Selectors that were already unused before this accept are the user's
|
|
754
|
+
// pre-existing code; the pruning pass must not touch them.
|
|
755
|
+
const preUnused = compiler ? collectUnusedSelectors(sourceContent, compiler.compile) : new Set();
|
|
756
|
+
|
|
757
|
+
// Bake params (declared kinds from params.json drive branch pruning), then
|
|
758
|
+
// MERGE into the component's existing style block: matching selectors are
|
|
759
|
+
// replaced, new ones appended. Appending alone is how superseded rules used
|
|
760
|
+
// to survive their own replacement.
|
|
761
|
+
const declaredParams = readDeclaredParams(manifest, variantNum, cwd);
|
|
762
|
+
let variantCss = cssLines.join('\n');
|
|
763
|
+
if (/data-impeccable-variant|impeccable-variant-ready/.test(variantCss)) {
|
|
764
|
+
// Defensive: strip preview-wrapper selectors that authoring rules forbid
|
|
765
|
+
// on this path but an off-spec agent may still emit.
|
|
766
|
+
variantCss = sanitizeAcceptedSvelteCss(cssLines, variantNum, paramValues, rootTag).join('\n');
|
|
767
|
+
}
|
|
768
|
+
const bakedCss = bakeParamValues(variantCss, declaredParams, paramValues || {});
|
|
769
|
+
const cssStats = { replaced: 0, appended: 0, pruned: [], superseded: [] };
|
|
770
|
+
if (bakedCss.trim()) {
|
|
771
|
+
const merged = mergeCssIntoSvelteSource(newLines.join('\n'), bakedCss);
|
|
772
|
+
newLines = merged.text.split('\n');
|
|
773
|
+
cssStats.replaced = merged.replaced;
|
|
774
|
+
cssStats.appended = merged.appended;
|
|
775
|
+
}
|
|
776
|
+
|
|
777
|
+
let finalText = newLines.join('\n');
|
|
778
|
+
|
|
779
|
+
// Preview truth: the detached preview never applied the source rules that
|
|
780
|
+
// styled the replaced selection, so the user approved a design without
|
|
781
|
+
// them. Any seeded selector the variant did not re-declare is superseded;
|
|
782
|
+
// left in place it re-attaches through kept class names (the accepted root
|
|
783
|
+
// keeps its original classes) and re-layouts markup it no longer owns.
|
|
784
|
+
//
|
|
785
|
+
// Removal is bounded by ownership: a selector whose classes are still used
|
|
786
|
+
// by route markup OUTSIDE the replaced region does not belong to the pick
|
|
787
|
+
// alone, and removing it would strip styling from markup this accept never
|
|
788
|
+
// touched. Keeping it risks a visible re-attachment quirk on the accepted
|
|
789
|
+
// region; deleting it breaks the rest of the route. Keep it.
|
|
790
|
+
// Atomic hardening: a single-pass regex cannot strip `<style>` blocks safely.
|
|
791
|
+
// One replacement over nested or malformed openers leaves style text behind,
|
|
792
|
+
// and that text then feeds the class scan below as if it were live markup
|
|
793
|
+
// (CodeQL js/incomplete-multi-character-sanitization). Reuse the scanner that
|
|
794
|
+
// already backs parseSvelteComponentFile: it consumes each block to its real
|
|
795
|
+
// closer and repeats until none remain, so partial matches cannot survive.
|
|
796
|
+
const outsideMarkup = stripNamedBlocks(
|
|
797
|
+
[...sourceLines.slice(0, start), ...sourceLines.slice(end + 1)].join('\n'),
|
|
798
|
+
['style'],
|
|
799
|
+
);
|
|
800
|
+
const outsideClasses = new Set();
|
|
801
|
+
{
|
|
802
|
+
const attrRe = /class\s*=\s*(["'])(.*?)\1/g;
|
|
803
|
+
let cm;
|
|
804
|
+
while ((cm = attrRe.exec(outsideMarkup))) {
|
|
805
|
+
for (const cls of cm[2].split(/\s+/)) if (cls && !cls.includes('{')) outsideClasses.add(cls);
|
|
806
|
+
}
|
|
807
|
+
const directiveRe = /class:([A-Za-z0-9_-]+)/g;
|
|
808
|
+
while ((cm = directiveRe.exec(outsideMarkup))) outsideClasses.add(cm[1]);
|
|
809
|
+
}
|
|
810
|
+
const usedOutsideReplacedRegion = (selector) => {
|
|
811
|
+
const classTokenRe = /\.([A-Za-z0-9_-]+)/g;
|
|
812
|
+
let tm;
|
|
813
|
+
while ((tm = classTokenRe.exec(selector))) {
|
|
814
|
+
if (outsideClasses.has(tm[1])) return true;
|
|
815
|
+
}
|
|
816
|
+
return false;
|
|
817
|
+
};
|
|
818
|
+
const incomingSelectors = collectAllSelectors(bakedCss);
|
|
819
|
+
const superseded = (manifest.seededSelectors || [])
|
|
820
|
+
.map((selector) => normalizeSelector(selector))
|
|
821
|
+
.filter((selector) => selector && !incomingSelectors.has(selector) && !usedOutsideReplacedRegion(selector));
|
|
822
|
+
if (superseded.length > 0) {
|
|
823
|
+
const scrubbed = removeSelectorsFromSvelteSource(finalText, new Set(superseded));
|
|
824
|
+
finalText = scrubbed.text;
|
|
825
|
+
cssStats.superseded = scrubbed.removed;
|
|
826
|
+
}
|
|
827
|
+
|
|
828
|
+
if (compiler) {
|
|
829
|
+
const pruned = pruneUnusedSelectors(finalText, compiler.compile, { skipSelectors: preUnused });
|
|
830
|
+
finalText = pruned.source;
|
|
831
|
+
cssStats.pruned = pruned.removed;
|
|
832
|
+
}
|
|
833
|
+
|
|
834
|
+
// Postcondition: no selector from the user's pre-accept CSS may vanish
|
|
835
|
+
// unless the compiler-driven prune or the preview-truth supersession
|
|
836
|
+
// deliberately removed it. This turns any parser or reconciler defect into
|
|
837
|
+
// a loud refusal instead of silent damage to a hand-written style block.
|
|
838
|
+
const lostSelectors = findLostSelectors(sourceContent, finalText, [
|
|
839
|
+
...cssStats.pruned,
|
|
840
|
+
...cssStats.superseded,
|
|
841
|
+
]);
|
|
842
|
+
if (lostSelectors.length > 0) {
|
|
843
|
+
return {
|
|
844
|
+
handled: false,
|
|
845
|
+
error: 'CSS reconciliation would lose selectors from the existing style block: '
|
|
846
|
+
+ lostSelectors.join(', ')
|
|
847
|
+
+ '. Source not modified; accept the variant manually.',
|
|
848
|
+
mode: 'error',
|
|
849
|
+
...resultBase,
|
|
850
|
+
};
|
|
590
851
|
}
|
|
591
852
|
|
|
592
853
|
try {
|
|
593
|
-
fs.writeFileSync(sourceFile,
|
|
854
|
+
fs.writeFileSync(sourceFile, finalText, 'utf-8');
|
|
594
855
|
} catch (err) {
|
|
595
856
|
return { handled: false, error: 'Failed to write Svelte source: ' + err.message, ...resultBase };
|
|
596
857
|
}
|
|
597
858
|
removeSvelteComponentSession(manifest.id, cwd);
|
|
598
859
|
|
|
860
|
+
const verify = verifyAcceptedSource(finalText);
|
|
599
861
|
return {
|
|
600
862
|
handled: true,
|
|
863
|
+
css: cssStats,
|
|
864
|
+
verify,
|
|
601
865
|
...resultBase,
|
|
602
866
|
};
|
|
603
867
|
}
|
|
604
868
|
|
|
869
|
+
/** Re-indent a block onto `indent` while preserving its internal structure. */
|
|
870
|
+
export function reindentPreservingStructure(lines, indent) {
|
|
871
|
+
const nonEmpty = lines.filter((line) => line.trim() !== '');
|
|
872
|
+
if (nonEmpty.length === 0) return lines.map(() => '');
|
|
873
|
+
const minIndent = Math.min(...nonEmpty.map((line) => (line.match(/^\s*/) || [''])[0].length));
|
|
874
|
+
return lines.map((line) => {
|
|
875
|
+
if (line.trim() === '') return '';
|
|
876
|
+
const current = (line.match(/^\s*/) || [''])[0].length;
|
|
877
|
+
return indent + line.slice(Math.min(minIndent, current));
|
|
878
|
+
});
|
|
879
|
+
}
|
|
880
|
+
|
|
881
|
+
function styleBlockText(sourceText) {
|
|
882
|
+
const match = String(sourceText || '').match(/<style\b[^>]*>([\s\S]*?)<\/style\s*>/i);
|
|
883
|
+
return match ? match[1] : '';
|
|
884
|
+
}
|
|
885
|
+
|
|
886
|
+
/**
|
|
887
|
+
* Remove every rule whose (normalized) selector list is fully contained in
|
|
888
|
+
* `selectors` from the component's style block, at any at-rule nesting depth.
|
|
889
|
+
* Rules that mix doomed and surviving selectors keep the survivors.
|
|
890
|
+
*/
|
|
891
|
+
export function removeSelectorsFromSvelteSource(sourceText, selectors) {
|
|
892
|
+
const text = String(sourceText || '');
|
|
893
|
+
const styleRe = /<style\b[^>]*>([\s\S]*?)<\/style\s*>/gi;
|
|
894
|
+
let lastMatch = null;
|
|
895
|
+
let m;
|
|
896
|
+
while ((m = styleRe.exec(text))) lastMatch = m;
|
|
897
|
+
if (!lastMatch) return { text, removed: [] };
|
|
898
|
+
|
|
899
|
+
const removed = [];
|
|
900
|
+
const transform = (nodes) => {
|
|
901
|
+
const kept = [];
|
|
902
|
+
for (const node of nodes) {
|
|
903
|
+
if (node.type === 'rule') {
|
|
904
|
+
const survivors = [];
|
|
905
|
+
for (const selector of splitSelectorList(node.prelude)) {
|
|
906
|
+
if (selectors.has(normalizeSelector(selector))) removed.push(normalizeSelector(selector));
|
|
907
|
+
else survivors.push(selector);
|
|
908
|
+
}
|
|
909
|
+
if (survivors.length > 0) kept.push({ ...node, prelude: survivors.join(', ') });
|
|
910
|
+
} else if (node.type === 'at' && node.children) {
|
|
911
|
+
const children = transform(node.children);
|
|
912
|
+
if (children.length > 0) kept.push({ ...node, children });
|
|
913
|
+
} else {
|
|
914
|
+
kept.push(node);
|
|
915
|
+
}
|
|
916
|
+
}
|
|
917
|
+
return kept;
|
|
918
|
+
};
|
|
919
|
+
|
|
920
|
+
const nodes = transform(parseStylesheet(lastMatch[1]));
|
|
921
|
+
if (removed.length === 0) return { text, removed };
|
|
922
|
+
const openTag = lastMatch[0].slice(0, lastMatch[0].indexOf('>') + 1);
|
|
923
|
+
const rebuilt = `${openTag}\n${serializeNodes(nodes).split('\n').map((l) => (l.trim() ? ' ' + l : '')).join('\n')}\n</style>`;
|
|
924
|
+
return {
|
|
925
|
+
text: text.slice(0, lastMatch.index) + rebuilt + text.slice(lastMatch.index + lastMatch[0].length),
|
|
926
|
+
removed,
|
|
927
|
+
};
|
|
928
|
+
}
|
|
929
|
+
|
|
930
|
+
export function findLostSelectors(beforeSource, afterSource, prunedSelectors = []) {
|
|
931
|
+
const before = collectAllSelectors(styleBlockText(beforeSource));
|
|
932
|
+
const after = collectAllSelectors(styleBlockText(afterSource));
|
|
933
|
+
const pruned = new Set((prunedSelectors || []).map((s) => normalizeSelector(s)));
|
|
934
|
+
const lost = [];
|
|
935
|
+
for (const selector of before) {
|
|
936
|
+
if (!after.has(selector) && !pruned.has(selector)) lost.push(selector);
|
|
937
|
+
}
|
|
938
|
+
return lost;
|
|
939
|
+
}
|
|
940
|
+
|
|
941
|
+
function readDeclaredParams(manifest, variantNum, cwd) {
|
|
942
|
+
try {
|
|
943
|
+
const raw = JSON.parse(fs.readFileSync(path.join(cwd, manifest.componentDir, 'params.json'), 'utf-8'));
|
|
944
|
+
const list = raw?.[String(variantNum)];
|
|
945
|
+
return Array.isArray(list) ? list : [];
|
|
946
|
+
} catch {
|
|
947
|
+
return [];
|
|
948
|
+
}
|
|
949
|
+
}
|
|
950
|
+
|
|
951
|
+
/**
|
|
952
|
+
* Merge CSS into a svelte component's top-level style block (created when
|
|
953
|
+
* absent), replacing rules whose selectors match and appending the rest.
|
|
954
|
+
*/
|
|
955
|
+
export function mergeCssIntoSvelteSource(sourceText, incomingCss) {
|
|
956
|
+
const text = String(sourceText || '');
|
|
957
|
+
const styleRe = /<style\b[^>]*>([\s\S]*?)<\/style\s*>/gi;
|
|
958
|
+
let lastMatch = null;
|
|
959
|
+
let m;
|
|
960
|
+
while ((m = styleRe.exec(text))) lastMatch = m;
|
|
961
|
+
|
|
962
|
+
if (!lastMatch) {
|
|
963
|
+
const { css, replaced, appended } = reconcileCss('', incomingCss);
|
|
964
|
+
return {
|
|
965
|
+
text: `${text.replace(/\s*$/, '')}\n\n<style>\n${indentCssBlock(css)}\n</style>\n`,
|
|
966
|
+
replaced,
|
|
967
|
+
appended,
|
|
968
|
+
};
|
|
969
|
+
}
|
|
970
|
+
|
|
971
|
+
const inner = lastMatch[1];
|
|
972
|
+
const { css, replaced, appended } = reconcileCss(inner, incomingCss);
|
|
973
|
+
const openTag = lastMatch[0].slice(0, lastMatch[0].indexOf('>') + 1);
|
|
974
|
+
const replacedBlock = `${openTag}\n${indentCssBlock(css)}\n</style>`;
|
|
975
|
+
return {
|
|
976
|
+
text: text.slice(0, lastMatch.index) + replacedBlock + text.slice(lastMatch.index + lastMatch[0].length),
|
|
977
|
+
replaced,
|
|
978
|
+
appended,
|
|
979
|
+
};
|
|
980
|
+
}
|
|
981
|
+
|
|
982
|
+
function indentCssBlock(css) {
|
|
983
|
+
return String(css || '')
|
|
984
|
+
.split('\n')
|
|
985
|
+
.map((line) => (line.trim() === '' ? '' : ' ' + line))
|
|
986
|
+
.join('\n');
|
|
987
|
+
}
|
|
988
|
+
|
|
605
989
|
function inlineSvelteComponentInsertAccept({
|
|
606
990
|
manifest,
|
|
607
991
|
markup,
|
|
@@ -632,10 +1016,7 @@ function inlineSvelteComponentInsertAccept({
|
|
|
632
1016
|
|
|
633
1017
|
const nearbyLine = sourceLines[insertIndex] ?? sourceLines[insertIndex - 1] ?? '';
|
|
634
1018
|
const indent = nearbyLine.match(/^(\s*)/)?.[1] || '';
|
|
635
|
-
const indentedMarkup = restoredMarkup
|
|
636
|
-
if (line.trim() === '') return '';
|
|
637
|
-
return indent + line.trimStart();
|
|
638
|
-
});
|
|
1019
|
+
const indentedMarkup = reindentPreservingStructure(restoredMarkup, indent);
|
|
639
1020
|
|
|
640
1021
|
let newLines = [
|
|
641
1022
|
...sourceLines.slice(0, insertIndex),
|
|
@@ -643,10 +1024,15 @@ function inlineSvelteComponentInsertAccept({
|
|
|
643
1024
|
...sourceLines.slice(insertIndex),
|
|
644
1025
|
];
|
|
645
1026
|
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
1027
|
+
let variantCss = cssLines.join('\n');
|
|
1028
|
+
if (/data-impeccable-variant|impeccable-variant-ready/.test(variantCss)) {
|
|
1029
|
+
variantCss = sanitizeAcceptedSvelteCss(cssLines, variantNum, paramValues, rootTag).join('\n');
|
|
1030
|
+
}
|
|
1031
|
+
const declaredParams = readDeclaredParams(manifest, variantNum, cwd);
|
|
1032
|
+
const bakedCss = bakeParamValues(variantCss, declaredParams, paramValues || {});
|
|
1033
|
+
if (bakedCss.trim()) {
|
|
1034
|
+
const merged = mergeCssIntoSvelteSource(newLines.join('\n'), bakedCss);
|
|
1035
|
+
newLines = merged.text.split('\n');
|
|
650
1036
|
}
|
|
651
1037
|
|
|
652
1038
|
try {
|
|
@@ -656,8 +1042,10 @@ function inlineSvelteComponentInsertAccept({
|
|
|
656
1042
|
}
|
|
657
1043
|
removeSvelteComponentSession(manifest.id, cwd);
|
|
658
1044
|
|
|
1045
|
+
const verify = verifyAcceptedSource(newLines.join('\n'));
|
|
659
1046
|
return {
|
|
660
1047
|
handled: true,
|
|
1048
|
+
verify,
|
|
661
1049
|
...resultBase,
|
|
662
1050
|
};
|
|
663
1051
|
}
|
|
@@ -757,18 +1145,177 @@ export function removeSvelteComponentSession(id, cwd = process.cwd()) {
|
|
|
757
1145
|
} catch { /* non-fatal */ }
|
|
758
1146
|
}
|
|
759
1147
|
|
|
1148
|
+
/**
|
|
1149
|
+
* Compile-check every variant component of a session with the app's own
|
|
1150
|
+
* compiler, BEFORE the browser ever imports them. A variant that does not
|
|
1151
|
+
* compile (the classic: a second top-level <style> appended next to the
|
|
1152
|
+
* seeded one) used to surface as a red Vite overlay in the user's page plus
|
|
1153
|
+
* a mount-failure round trip; bounced at publish time it is a private
|
|
1154
|
+
* agent-side fix with the exact file and line.
|
|
1155
|
+
*
|
|
1156
|
+
* What this deliberately does NOT prove is that the emitted module is valid
|
|
1157
|
+
* JavaScript, and issue #580 was exactly that gap: valid .svelte source whose
|
|
1158
|
+
* generated JS did not parse, so this check passed and the browser's import
|
|
1159
|
+
* failed with "Unexpected token '('". Two reasons it cannot close the gap, both
|
|
1160
|
+
* structural rather than oversights:
|
|
1161
|
+
*
|
|
1162
|
+
* - `generate: false` produces no JS to inspect, and generating it here would
|
|
1163
|
+
* spend a full codegen per variant on the publish path.
|
|
1164
|
+
* - `loadSvelteCompiler` reaches the compiler through createRequire, which
|
|
1165
|
+
* Svelte's export map routes to a prebuilt CJS build. The dev server
|
|
1166
|
+
* imports `src/compiler` instead, and only that path uses the app's
|
|
1167
|
+
* installed printer (esrap). The two can disagree, so even a generated
|
|
1168
|
+
* check here would be checking a different compiler than the one whose
|
|
1169
|
+
* output the browser runs.
|
|
1170
|
+
*
|
|
1171
|
+
* tests/live-svelte-props-script.test.mjs covers the emitted JS, importing the
|
|
1172
|
+
* compiler as ESM so it sees what the dev server sees.
|
|
1173
|
+
*/
|
|
1174
|
+
export function compileCheckVariants(id, cwd = process.cwd()) {
|
|
1175
|
+
const manifest = findSvelteComponentManifest(id, cwd);
|
|
1176
|
+
if (!manifest || !manifest.manifestPath) return { ok: true, failures: [], checked: 0 };
|
|
1177
|
+
const compiler = loadSvelteCompiler(cwd);
|
|
1178
|
+
if (!compiler || typeof compiler.compile !== 'function') return { ok: true, failures: [], checked: 0 };
|
|
1179
|
+
const sessionDir = path.dirname(manifest.manifestPath);
|
|
1180
|
+
const failures = [];
|
|
1181
|
+
let checked = 0;
|
|
1182
|
+
let entries = [];
|
|
1183
|
+
try { entries = fs.readdirSync(sessionDir); } catch { return { ok: true, failures: [], checked: 0 }; }
|
|
1184
|
+
for (const name of entries) {
|
|
1185
|
+
if (!/^v\d+\.svelte$/.test(name)) continue;
|
|
1186
|
+
checked++;
|
|
1187
|
+
try {
|
|
1188
|
+
compiler.compile(fs.readFileSync(path.join(sessionDir, name), 'utf-8'), { generate: false });
|
|
1189
|
+
} catch (err) {
|
|
1190
|
+
failures.push({
|
|
1191
|
+
file: `${manifest.componentDir}/${name}`,
|
|
1192
|
+
line: err?.start?.line ?? null,
|
|
1193
|
+
column: err?.start?.column ?? null,
|
|
1194
|
+
message: String(err?.message || err).split('\n')[0].slice(0, 300),
|
|
1195
|
+
});
|
|
1196
|
+
}
|
|
1197
|
+
}
|
|
1198
|
+
return { ok: failures.length === 0, failures, checked };
|
|
1199
|
+
}
|
|
1200
|
+
|
|
1201
|
+
/**
|
|
1202
|
+
* Snapshot the agent-authored variant files into a fresh revision directory
|
|
1203
|
+
* and stamp the manifest. Called by the server on every publish (`done`
|
|
1204
|
+
* reply) for a component session; the browser imports from the revision dir,
|
|
1205
|
+
* so the dev server can never serve a stale compile of a republished file.
|
|
1206
|
+
*/
|
|
1207
|
+
export function bumpSvelteComponentPreviewRevision(id, cwd = process.cwd()) {
|
|
1208
|
+
const manifest = findSvelteComponentManifest(id, cwd);
|
|
1209
|
+
if (!manifest || !manifest.manifestPath) return null;
|
|
1210
|
+
const sessionDir = path.dirname(manifest.manifestPath);
|
|
1211
|
+
const revision = Number(manifest.revision || 0) + 1;
|
|
1212
|
+
const revDirName = `r${revision}`;
|
|
1213
|
+
const revDir = path.join(sessionDir, revDirName);
|
|
1214
|
+
try {
|
|
1215
|
+
fs.mkdirSync(revDir, { recursive: true });
|
|
1216
|
+
let entries = [];
|
|
1217
|
+
try { entries = fs.readdirSync(sessionDir, { withFileTypes: true }); } catch { /* empty */ }
|
|
1218
|
+
for (const entry of entries) {
|
|
1219
|
+
if (!entry.isFile()) continue;
|
|
1220
|
+
if (entry.name === 'manifest.json') continue;
|
|
1221
|
+
fs.copyFileSync(path.join(sessionDir, entry.name), path.join(revDir, entry.name));
|
|
1222
|
+
}
|
|
1223
|
+
// Previous revision dirs are dead the moment a new one exists.
|
|
1224
|
+
for (const entry of entries) {
|
|
1225
|
+
if (entry.isDirectory() && /^r\d+$/.test(entry.name) && entry.name !== revDirName) {
|
|
1226
|
+
try { fs.rmSync(path.join(sessionDir, entry.name), { recursive: true, force: true }); } catch { /* non-fatal */ }
|
|
1227
|
+
}
|
|
1228
|
+
}
|
|
1229
|
+
const relSessionDir = path.relative(cwd, sessionDir).split(path.sep).join('/');
|
|
1230
|
+
const updated = {
|
|
1231
|
+
...manifest,
|
|
1232
|
+
revision,
|
|
1233
|
+
revisionDir: `${relSessionDir}/${revDirName}`,
|
|
1234
|
+
revisionDirAbs: revDir.split(path.sep).join('/'),
|
|
1235
|
+
};
|
|
1236
|
+
delete updated.manifestPath;
|
|
1237
|
+
fs.writeFileSync(manifest.manifestPath, JSON.stringify(updated, null, 2) + '\n', 'utf-8');
|
|
1238
|
+
return { revision, revisionDir: updated.revisionDir };
|
|
1239
|
+
} catch {
|
|
1240
|
+
return null;
|
|
1241
|
+
}
|
|
1242
|
+
}
|
|
1243
|
+
|
|
1244
|
+
/**
|
|
1245
|
+
* Stop-path sweep. The whole `node_modules/.impeccable-live` tree is
|
|
1246
|
+
* impeccable-owned and gitignored, so once no session should survive there is
|
|
1247
|
+
* nothing left worth keeping: the per-session dirs, the generated
|
|
1248
|
+
* `__runtime.js`, and the parent directory all go. The old per-entry loop
|
|
1249
|
+
* skipped `__*` entries and the parent, which left the runtime shim and an
|
|
1250
|
+
* empty directory in every project that ever ran live mode once.
|
|
1251
|
+
*/
|
|
760
1252
|
export function removeAllSvelteComponentSessions(cwd = process.cwd()) {
|
|
761
|
-
const
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
if (!entry.isDirectory()) continue;
|
|
765
|
-
if (entry.name.startsWith('__')) continue;
|
|
1253
|
+
for (const rootRel of [SVELTE_COMPONENT_ROOT, LEGACY_SVELTE_COMPONENT_ROOT]) {
|
|
1254
|
+
const root = path.join(cwd, rootRel);
|
|
1255
|
+
if (!fs.existsSync(root)) continue;
|
|
766
1256
|
try {
|
|
767
|
-
fs.rmSync(
|
|
1257
|
+
fs.rmSync(root, { recursive: true, force: true });
|
|
768
1258
|
} catch { /* non-fatal */ }
|
|
769
1259
|
}
|
|
770
1260
|
}
|
|
771
1261
|
|
|
1262
|
+
/**
|
|
1263
|
+
* Boot-path sweep. A restart must not delete the tree wholesale: sessions
|
|
1264
|
+
* recorded in the session store may still be mid-generation. Remove only the
|
|
1265
|
+
* session dirs whose id has no active snapshot, then drop `__runtime.js` and
|
|
1266
|
+
* the parent directory when nothing is left to serve.
|
|
1267
|
+
*
|
|
1268
|
+
* @param {Iterable<string>} activeIds session ids that must be preserved
|
|
1269
|
+
* @returns {{ removed: string[], removedRoot: boolean, kept: string[] }}
|
|
1270
|
+
*/
|
|
1271
|
+
export function sweepInactiveSvelteComponentSessions(activeIds = [], cwd = process.cwd()) {
|
|
1272
|
+
const result = { removed: [], removedRoot: false, kept: [] };
|
|
1273
|
+
const active = new Set();
|
|
1274
|
+
for (const id of activeIds || []) {
|
|
1275
|
+
if (typeof id === 'string' && id) active.add(id);
|
|
1276
|
+
}
|
|
1277
|
+
|
|
1278
|
+
for (const rootRel of [SVELTE_COMPONENT_ROOT, LEGACY_SVELTE_COMPONENT_ROOT]) {
|
|
1279
|
+
const root = path.join(cwd, rootRel);
|
|
1280
|
+
if (!fs.existsSync(root)) continue;
|
|
1281
|
+
|
|
1282
|
+
let entries;
|
|
1283
|
+
try {
|
|
1284
|
+
entries = fs.readdirSync(root, { withFileTypes: true });
|
|
1285
|
+
} catch {
|
|
1286
|
+
continue;
|
|
1287
|
+
}
|
|
1288
|
+
|
|
1289
|
+
let keptHere = 0;
|
|
1290
|
+
for (const entry of entries) {
|
|
1291
|
+
if (!entry.isDirectory()) continue;
|
|
1292
|
+
if (entry.name.startsWith('__')) continue;
|
|
1293
|
+
if (active.has(entry.name)) {
|
|
1294
|
+
result.kept.push(entry.name);
|
|
1295
|
+
keptHere++;
|
|
1296
|
+
continue;
|
|
1297
|
+
}
|
|
1298
|
+
try {
|
|
1299
|
+
fs.rmSync(path.join(root, entry.name), { recursive: true, force: true });
|
|
1300
|
+
result.removed.push(entry.name);
|
|
1301
|
+
} catch {
|
|
1302
|
+
// Could not remove it, so it still occupies the tree; treat it as kept
|
|
1303
|
+
// so the parent directory is not torn out from under it.
|
|
1304
|
+
result.kept.push(entry.name);
|
|
1305
|
+
keptHere++;
|
|
1306
|
+
}
|
|
1307
|
+
}
|
|
1308
|
+
|
|
1309
|
+
if (keptHere === 0) {
|
|
1310
|
+
try {
|
|
1311
|
+
fs.rmSync(root, { recursive: true, force: true });
|
|
1312
|
+
result.removedRoot = true;
|
|
1313
|
+
} catch { /* non-fatal */ }
|
|
1314
|
+
}
|
|
1315
|
+
}
|
|
1316
|
+
return result;
|
|
1317
|
+
}
|
|
1318
|
+
|
|
772
1319
|
export function deferredAcceptsPath(cwd = process.cwd()) {
|
|
773
1320
|
const key = createHash('sha1').update(path.resolve(cwd)).digest('hex').slice(0, 16);
|
|
774
1321
|
return path.join(os.tmpdir(), 'impeccable-live', key, 'deferred-svelte-component-accepts.json');
|