@agent-native/core 0.127.1 → 0.128.0
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/corpus/README.md +2 -2
- package/corpus/core/CHANGELOG.md +92 -0
- package/corpus/core/README.md +5 -26
- package/corpus/core/docs/content/actions.mdx +47 -4
- package/corpus/core/docs/content/native-chat-ui.mdx +7 -0
- package/corpus/core/docs/content/organizations-teams-permissions.mdx +109 -3
- package/corpus/core/docs/content/template-design-collaboration-and-full-apps.mdx +15 -0
- package/corpus/core/docs/content/toolkit-org-team.mdx +72 -12
- package/corpus/core/package.json +1 -1
- package/corpus/core/src/a2a/artifact-response.ts +36 -29
- package/corpus/core/src/action.ts +83 -2
- package/corpus/core/src/chat-threads/store.ts +48 -43
- package/corpus/core/src/cli/skills-content/design-visual-edit-skill.ts +46 -3
- package/corpus/core/src/cli/template-sync.ts +96 -0
- package/corpus/core/src/client/AgentPanel.tsx +26 -6
- package/corpus/core/src/client/AssistantChat.tsx +63 -7
- package/corpus/core/src/client/DefaultSpinner.tsx +29 -0
- package/corpus/core/src/client/org/TeamPage.tsx +161 -6
- package/corpus/core/src/client/org/hooks.ts +67 -0
- package/corpus/core/src/client/org/index.ts +9 -0
- package/corpus/core/src/client/transcription/use-live-transcription.ts +62 -10
- package/corpus/core/src/db/client.ts +42 -3
- package/corpus/core/src/db/ensure-additive-columns.ts +60 -33
- package/corpus/core/src/deploy/build.ts +31 -2
- package/corpus/core/src/mcp-client/routes.ts +10 -1
- package/corpus/core/src/org/app-roles-handlers.ts +152 -0
- package/corpus/core/src/org/app-roles.ts +355 -0
- package/corpus/core/src/org/index.ts +27 -1
- package/corpus/core/src/org/migrations.ts +22 -0
- package/corpus/core/src/org/plugin.ts +27 -0
- package/corpus/core/src/org/schema.ts +15 -0
- package/corpus/core/src/scripts/docs/search.ts +17 -0
- package/corpus/core/src/scripts/docs/source-search.ts +10 -0
- package/corpus/core/src/server/agent-chat/script-entries.ts +3 -0
- package/corpus/core/src/server/agent-chat-plugin.ts +53 -52
- package/corpus/core/src/server/builder-design-systems.ts +1 -1
- package/corpus/core/src/server/core-routes-plugin.ts +6 -1
- package/corpus/core/src/server/framework-request-handler.ts +44 -6
- package/corpus/core/src/templates/default/.agents/skills/actions/SKILL.md +32 -0
- package/corpus/core/src/templates/default/.agents/skills/adding-a-feature/SKILL.md +7 -0
- package/corpus/core/src/templates/default/.agents/skills/security/SKILL.md +31 -0
- package/corpus/core/src/templates/headless/.agents/skills/actions/SKILL.md +32 -0
- package/corpus/core/src/templates/workspace-core/.agents/skills/actions/SKILL.md +32 -0
- package/corpus/core/src/templates/workspace-core/.agents/skills/adding-a-feature/SKILL.md +7 -0
- package/corpus/core/src/templates/workspace-core/.agents/skills/authentication/SKILL.md +40 -0
- package/corpus/core/src/templates/workspace-core/.agents/skills/security/SKILL.md +31 -0
- package/corpus/core/src/templates/workspace-core/.agents/skills/sharing/SKILL.md +4 -0
- package/corpus/templates/analytics/.agents/skills/actions/SKILL.md +32 -0
- package/corpus/templates/analytics/.agents/skills/security/SKILL.md +31 -0
- package/corpus/templates/analytics/.agents/skills/sharing/SKILL.md +4 -0
- package/corpus/templates/analytics/actions/data-source-status.ts +21 -12
- package/corpus/templates/analytics/app/global.css +7 -7
- package/corpus/templates/analytics/app/i18n-data.ts +30 -0
- package/corpus/templates/analytics/app/lib/data-source-status.ts +2 -1
- package/corpus/templates/analytics/app/pages/DataSources.tsx +54 -10
- package/corpus/templates/analytics/changelog/2026-07-28-analytics-pages-load-reliably-with-large-dashboard-workspaces.md +6 -0
- package/corpus/templates/analytics/changelog/2026-07-28-dashboard-loading-shimmer-now-flows-smoothly-in-one-directi.md +6 -0
- package/corpus/templates/analytics/server/lib/first-party-dashboard-repair.ts +5 -4
- package/corpus/templates/analytics/server/plugins/agent-chat.ts +54 -42
- package/corpus/templates/analytics/server/plugins/db.ts +1 -18
- package/corpus/templates/assets/.agents/skills/actions/SKILL.md +32 -0
- package/corpus/templates/assets/.agents/skills/security/SKILL.md +31 -0
- package/corpus/templates/assets/.agents/skills/sharing/SKILL.md +4 -0
- package/corpus/templates/brain/.agents/skills/actions/SKILL.md +32 -0
- package/corpus/templates/brain/.agents/skills/adding-a-feature/SKILL.md +7 -0
- package/corpus/templates/brain/.agents/skills/security/SKILL.md +31 -0
- package/corpus/templates/brain/.agents/skills/sharing/SKILL.md +4 -0
- package/corpus/templates/calendar/.agents/skills/actions/SKILL.md +32 -0
- package/corpus/templates/calendar/.agents/skills/security/SKILL.md +31 -0
- package/corpus/templates/calendar/.agents/skills/sharing/SKILL.md +4 -0
- package/corpus/templates/chat/.agents/skills/actions/SKILL.md +32 -0
- package/corpus/templates/chat/.agents/skills/adding-a-feature/SKILL.md +7 -0
- package/corpus/templates/chat/.agents/skills/security/SKILL.md +31 -0
- package/corpus/templates/chat/.agents/skills/sharing/SKILL.md +4 -0
- package/corpus/templates/chat/_gitignore +2 -0
- package/corpus/templates/clips/.agents/skills/actions/SKILL.md +32 -0
- package/corpus/templates/clips/.agents/skills/security/SKILL.md +31 -0
- package/corpus/templates/clips/actions/request-transcript.ts +77 -11
- package/corpus/templates/clips/actions/save-browser-transcript.ts +28 -7
- package/corpus/templates/clips/app/routes/record.tsx +11 -3
- package/corpus/templates/clips/changelog/2026-07-28-browser-recordings-no-longer-save-a-truncated-transcript-as-.md +6 -0
- package/corpus/templates/clips/changelog/2026-07-28-browser-recordings-no-longer-stop-transcribing-partway-throu.md +6 -0
- package/corpus/templates/clips/changelog/2026-07-28-desktop-full-screen-clips-now-get-an-instant-local-transcrip.md +6 -0
- package/corpus/templates/clips/changelog/2026-07-28-long-transcriptions-no-longer-show-a-false-transcription-sto.md +6 -0
- package/corpus/templates/clips/changelog/2026-07-28-restarting-for-an-update-now-installs-the-newest-release-ins.md +6 -0
- package/corpus/templates/clips/changelog/2026-07-28-the-meeting-recording-pill-now-anchors-to-the-right-edge-of-.md +6 -0
- package/corpus/templates/clips/desktop/src/lib/audio-meter.ts +31 -2
- package/corpus/templates/clips/desktop/src/lib/recorder.ts +114 -13
- package/corpus/templates/clips/desktop/src/lib/updater.ts +12 -4
- package/corpus/templates/clips/desktop/src/overlays/live-audio-bars.tsx +40 -15
- package/corpus/templates/clips/desktop/src/styles.css +10 -7
- package/corpus/templates/clips/desktop/src-tauri/src/recording_indicator.rs +21 -14
- package/corpus/templates/clips/shared/transcript-status.ts +10 -0
- package/corpus/templates/content/.agents/skills/actions/SKILL.md +32 -0
- package/corpus/templates/content/.agents/skills/security/SKILL.md +31 -0
- package/corpus/templates/content/.agents/skills/sharing/SKILL.md +4 -0
- package/corpus/templates/crm/.agents/skills/sharing/SKILL.md +4 -0
- package/corpus/templates/design/.agents/skills/actions/SKILL.md +32 -0
- package/corpus/templates/design/.agents/skills/design-generation/SKILL.md +23 -0
- package/corpus/templates/design/.agents/skills/security/SKILL.md +31 -0
- package/corpus/templates/design/.agents/skills/sharing/SKILL.md +4 -0
- package/corpus/templates/design/.agents/skills/visual-edit/SKILL.md +46 -3
- package/corpus/templates/design/.generated/bridge/editor-chrome.generated.ts +7 -5
- package/corpus/templates/design/actions/create-file.ts +15 -0
- package/corpus/templates/design/actions/generate-design.ts +40 -0
- package/corpus/templates/design/actions/present-design-variants.ts +16 -0
- package/corpus/templates/design/app/components/design/CanvasContextMenu.tsx +2 -2
- package/corpus/templates/design/app/components/design/bridge/editor-chrome.bridge.ts +7 -4
- package/corpus/templates/design/app/components/design/keyboard-shortcuts.ts +1 -1
- package/corpus/templates/design/app/hooks/useDesignHotkeys.ts +10 -4
- package/corpus/templates/design/app/lib/design-ui-events.ts +5 -0
- package/corpus/templates/design/app/pages/design-editor/save-failure.ts +7 -1
- package/corpus/templates/design/app/root.tsx +18 -1
- package/corpus/templates/design/changelog/2026-07-28-generated-designs-with-malformed-html-are-now-rejected-at-sa.md +6 -0
- package/corpus/templates/design/changelog/2026-07-28-show-or-hide-design-editing-chrome-with-cmd-on-apple-devices.md +6 -0
- package/corpus/templates/design/server/source-workspace.ts +1 -0
- package/corpus/templates/design/shared/html-integrity.ts +608 -18
- package/corpus/templates/dispatch/.agents/skills/actions/SKILL.md +32 -0
- package/corpus/templates/dispatch/.agents/skills/security/SKILL.md +31 -0
- package/corpus/templates/dispatch/.agents/skills/sharing/SKILL.md +4 -0
- package/corpus/templates/forms/.agents/skills/actions/SKILL.md +32 -0
- package/corpus/templates/forms/.agents/skills/security/SKILL.md +31 -0
- package/corpus/templates/forms/.agents/skills/sharing/SKILL.md +4 -0
- package/corpus/templates/macros/.agents/skills/security/SKILL.md +31 -0
- package/corpus/templates/macros/.agents/skills/sharing/SKILL.md +4 -0
- package/corpus/templates/mail/.agents/skills/actions/SKILL.md +32 -0
- package/corpus/templates/mail/.agents/skills/security/SKILL.md +31 -0
- package/corpus/templates/mail/.agents/skills/sharing/SKILL.md +4 -0
- package/corpus/templates/plan/.agents/skills/actions/SKILL.md +32 -0
- package/corpus/templates/plan/.agents/skills/adding-a-feature/SKILL.md +7 -0
- package/corpus/templates/plan/.agents/skills/security/SKILL.md +31 -0
- package/corpus/templates/plan/.agents/skills/sharing/SKILL.md +4 -0
- package/corpus/templates/slides/.agents/skills/actions/SKILL.md +32 -0
- package/corpus/templates/slides/.agents/skills/security/SKILL.md +31 -0
- package/corpus/templates/slides/.agents/skills/sharing/SKILL.md +4 -0
- package/corpus/templates/slides/app/components/deck/DeckCard.tsx +2 -6
- package/corpus/templates/tasks/.agents/skills/actions/SKILL.md +32 -0
- package/corpus/templates/tasks/.agents/skills/adding-a-feature/SKILL.md +7 -0
- package/corpus/templates/tasks/.agents/skills/security/SKILL.md +31 -0
- package/corpus/templates/tasks/.agents/skills/sharing/SKILL.md +4 -0
- package/dist/a2a/artifact-response.d.ts.map +1 -1
- package/dist/a2a/artifact-response.js +30 -29
- package/dist/a2a/artifact-response.js.map +1 -1
- package/dist/action.d.ts +36 -0
- package/dist/action.d.ts.map +1 -1
- package/dist/action.js +37 -2
- package/dist/action.js.map +1 -1
- package/dist/chat-threads/store.d.ts +12 -0
- package/dist/chat-threads/store.d.ts.map +1 -1
- package/dist/chat-threads/store.js +48 -42
- package/dist/chat-threads/store.js.map +1 -1
- package/dist/cli/skills-content/design-visual-edit-skill.d.ts +1 -1
- package/dist/cli/skills-content/design-visual-edit-skill.d.ts.map +1 -1
- package/dist/cli/skills-content/design-visual-edit-skill.js +46 -3
- package/dist/cli/skills-content/design-visual-edit-skill.js.map +1 -1
- package/dist/cli/template-sync.d.ts.map +1 -1
- package/dist/cli/template-sync.js +88 -0
- package/dist/cli/template-sync.js.map +1 -1
- package/dist/client/AgentPanel.d.ts +3 -1
- package/dist/client/AgentPanel.d.ts.map +1 -1
- package/dist/client/AgentPanel.js +11 -9
- package/dist/client/AgentPanel.js.map +1 -1
- package/dist/client/AssistantChat.d.ts.map +1 -1
- package/dist/client/AssistantChat.js +57 -6
- package/dist/client/AssistantChat.js.map +1 -1
- package/dist/client/DefaultSpinner.d.ts +7 -0
- package/dist/client/DefaultSpinner.d.ts.map +1 -1
- package/dist/client/DefaultSpinner.js +25 -1
- package/dist/client/DefaultSpinner.js.map +1 -1
- package/dist/client/org/TeamPage.d.ts +13 -1
- package/dist/client/org/TeamPage.d.ts.map +1 -1
- package/dist/client/org/TeamPage.js +41 -11
- package/dist/client/org/TeamPage.js.map +1 -1
- package/dist/client/org/hooks.d.ts +37 -0
- package/dist/client/org/hooks.d.ts.map +1 -1
- package/dist/client/org/hooks.js +37 -0
- package/dist/client/org/hooks.js.map +1 -1
- package/dist/client/org/index.d.ts +3 -2
- package/dist/client/org/index.d.ts.map +1 -1
- package/dist/client/org/index.js +1 -1
- package/dist/client/org/index.js.map +1 -1
- package/dist/client/transcription/use-live-transcription.d.ts +8 -0
- package/dist/client/transcription/use-live-transcription.d.ts.map +1 -1
- package/dist/client/transcription/use-live-transcription.js +38 -11
- package/dist/client/transcription/use-live-transcription.js.map +1 -1
- package/dist/collab/routes.d.ts +1 -1
- package/dist/collab/struct-routes.d.ts +1 -1
- package/dist/db/client.d.ts +12 -0
- package/dist/db/client.d.ts.map +1 -1
- package/dist/db/client.js +40 -3
- package/dist/db/client.js.map +1 -1
- package/dist/db/ensure-additive-columns.d.ts.map +1 -1
- package/dist/db/ensure-additive-columns.js +54 -32
- package/dist/db/ensure-additive-columns.js.map +1 -1
- package/dist/deploy/build.d.ts +1 -0
- package/dist/deploy/build.d.ts.map +1 -1
- package/dist/deploy/build.js +23 -2
- package/dist/deploy/build.js.map +1 -1
- package/dist/mcp-client/routes.d.ts +3 -1
- package/dist/mcp-client/routes.d.ts.map +1 -1
- package/dist/mcp-client/routes.js +8 -2
- package/dist/mcp-client/routes.js.map +1 -1
- package/dist/notifications/routes.d.ts +1 -1
- package/dist/observability/routes.d.ts +3 -3
- package/dist/org/app-roles-handlers.d.ts +27 -0
- package/dist/org/app-roles-handlers.d.ts.map +1 -0
- package/dist/org/app-roles-handlers.js +125 -0
- package/dist/org/app-roles-handlers.js.map +1 -0
- package/dist/org/app-roles.d.ts +136 -0
- package/dist/org/app-roles.d.ts.map +1 -0
- package/dist/org/app-roles.js +216 -0
- package/dist/org/app-roles.js.map +1 -0
- package/dist/org/index.d.ts +4 -1
- package/dist/org/index.d.ts.map +1 -1
- package/dist/org/index.js +3 -1
- package/dist/org/index.js.map +1 -1
- package/dist/org/migrations.d.ts.map +1 -1
- package/dist/org/migrations.js +22 -0
- package/dist/org/migrations.js.map +1 -1
- package/dist/org/plugin.d.ts +2 -0
- package/dist/org/plugin.d.ts.map +1 -1
- package/dist/org/plugin.js +20 -0
- package/dist/org/plugin.js.map +1 -1
- package/dist/org/schema.d.ts +143 -0
- package/dist/org/schema.d.ts.map +1 -1
- package/dist/org/schema.js +14 -0
- package/dist/org/schema.js.map +1 -1
- package/dist/provider-api/actions/custom-provider-registration.d.ts +4 -4
- package/dist/provider-api/actions/provider-api.d.ts +12 -12
- package/dist/resources/handlers.d.ts +1 -1
- package/dist/scripts/docs/search.d.ts.map +1 -1
- package/dist/scripts/docs/search.js +15 -0
- package/dist/scripts/docs/search.js.map +1 -1
- package/dist/scripts/docs/source-search.d.ts +7 -0
- package/dist/scripts/docs/source-search.d.ts.map +1 -1
- package/dist/scripts/docs/source-search.js +9 -0
- package/dist/scripts/docs/source-search.js.map +1 -1
- package/dist/server/agent-chat/script-entries.d.ts.map +1 -1
- package/dist/server/agent-chat/script-entries.js +3 -0
- package/dist/server/agent-chat/script-entries.js.map +1 -1
- package/dist/server/agent-chat-plugin.d.ts.map +1 -1
- package/dist/server/agent-chat-plugin.js +46 -48
- package/dist/server/agent-chat-plugin.js.map +1 -1
- package/dist/server/agent-engine-api-key-route.d.ts +1 -1
- package/dist/server/builder-design-systems.js +1 -1
- package/dist/server/builder-design-systems.js.map +1 -1
- package/dist/server/core-routes-plugin.d.ts.map +1 -1
- package/dist/server/core-routes-plugin.js +6 -1
- package/dist/server/core-routes-plugin.js.map +1 -1
- package/dist/server/framework-request-handler.d.ts.map +1 -1
- package/dist/server/framework-request-handler.js +42 -6
- package/dist/server/framework-request-handler.js.map +1 -1
- package/dist/server/transcribe-voice.d.ts +1 -1
- package/dist/templates/chat/.agents/skills/actions/SKILL.md +32 -0
- package/dist/templates/chat/.agents/skills/adding-a-feature/SKILL.md +7 -0
- package/dist/templates/chat/.agents/skills/security/SKILL.md +31 -0
- package/dist/templates/chat/.agents/skills/sharing/SKILL.md +4 -0
- package/dist/templates/chat/_gitignore +2 -0
- package/dist/templates/default/.agents/skills/actions/SKILL.md +32 -0
- package/dist/templates/default/.agents/skills/adding-a-feature/SKILL.md +7 -0
- package/dist/templates/default/.agents/skills/security/SKILL.md +31 -0
- package/dist/templates/headless/.agents/skills/actions/SKILL.md +32 -0
- package/dist/templates/workspace-core/.agents/skills/actions/SKILL.md +32 -0
- package/dist/templates/workspace-core/.agents/skills/adding-a-feature/SKILL.md +7 -0
- package/dist/templates/workspace-core/.agents/skills/authentication/SKILL.md +40 -0
- package/dist/templates/workspace-core/.agents/skills/security/SKILL.md +31 -0
- package/dist/templates/workspace-core/.agents/skills/sharing/SKILL.md +4 -0
- package/docs/content/actions.mdx +47 -4
- package/docs/content/native-chat-ui.mdx +7 -0
- package/docs/content/organizations-teams-permissions.mdx +109 -3
- package/docs/content/template-design-collaboration-and-full-apps.mdx +15 -0
- package/docs/content/toolkit-org-team.mdx +72 -12
- package/package.json +1 -1
- package/src/a2a/artifact-response.ts +36 -29
- package/src/action.ts +83 -2
- package/src/chat-threads/store.ts +48 -43
- package/src/cli/skills-content/design-visual-edit-skill.ts +46 -3
- package/src/cli/template-sync.ts +96 -0
- package/src/client/AgentPanel.tsx +26 -6
- package/src/client/AssistantChat.tsx +63 -7
- package/src/client/DefaultSpinner.tsx +29 -0
- package/src/client/org/TeamPage.tsx +161 -6
- package/src/client/org/hooks.ts +67 -0
- package/src/client/org/index.ts +9 -0
- package/src/client/transcription/use-live-transcription.ts +62 -10
- package/src/db/client.ts +42 -3
- package/src/db/ensure-additive-columns.ts +60 -33
- package/src/deploy/build.ts +31 -2
- package/src/mcp-client/routes.ts +10 -1
- package/src/org/app-roles-handlers.ts +152 -0
- package/src/org/app-roles.ts +355 -0
- package/src/org/index.ts +27 -1
- package/src/org/migrations.ts +22 -0
- package/src/org/plugin.ts +27 -0
- package/src/org/schema.ts +15 -0
- package/src/scripts/docs/search.ts +17 -0
- package/src/scripts/docs/source-search.ts +10 -0
- package/src/server/agent-chat/script-entries.ts +3 -0
- package/src/server/agent-chat-plugin.ts +53 -52
- package/src/server/builder-design-systems.ts +1 -1
- package/src/server/core-routes-plugin.ts +6 -1
- package/src/server/framework-request-handler.ts +44 -6
- package/src/templates/chat/.agents/skills/actions/SKILL.md +32 -0
- package/src/templates/chat/.agents/skills/adding-a-feature/SKILL.md +7 -0
- package/src/templates/chat/.agents/skills/security/SKILL.md +31 -0
- package/src/templates/chat/.agents/skills/sharing/SKILL.md +4 -0
- package/src/templates/chat/_gitignore +2 -0
- package/src/templates/default/.agents/skills/actions/SKILL.md +32 -0
- package/src/templates/default/.agents/skills/adding-a-feature/SKILL.md +7 -0
- package/src/templates/default/.agents/skills/security/SKILL.md +31 -0
- package/src/templates/headless/.agents/skills/actions/SKILL.md +32 -0
- package/src/templates/workspace-core/.agents/skills/actions/SKILL.md +32 -0
- package/src/templates/workspace-core/.agents/skills/adding-a-feature/SKILL.md +7 -0
- package/src/templates/workspace-core/.agents/skills/authentication/SKILL.md +40 -0
- package/src/templates/workspace-core/.agents/skills/security/SKILL.md +31 -0
- package/src/templates/workspace-core/.agents/skills/sharing/SKILL.md +4 -0
- package/corpus/core/src/templates/chat/.agents/skills/actions/SKILL.md +0 -530
- package/corpus/core/src/templates/chat/.agents/skills/adding-a-feature/SKILL.md +0 -191
- package/corpus/core/src/templates/chat/.agents/skills/agent-native-docs/SKILL.md +0 -115
- package/corpus/core/src/templates/chat/.agents/skills/agent-native-toolkit/SKILL.md +0 -177
- package/corpus/core/src/templates/chat/.agents/skills/capture-learnings/SKILL.md +0 -89
- package/corpus/core/src/templates/chat/.agents/skills/create-skill/SKILL.md +0 -221
- package/corpus/core/src/templates/chat/.agents/skills/customizing-agent-native/SKILL.md +0 -220
- package/corpus/core/src/templates/chat/.agents/skills/delegate-to-agent/SKILL.md +0 -263
- package/corpus/core/src/templates/chat/.agents/skills/feature-flags/SKILL.md +0 -169
- package/corpus/core/src/templates/chat/.agents/skills/frontend-design/SKILL.md +0 -174
- package/corpus/core/src/templates/chat/.agents/skills/real-time-sync/SKILL.md +0 -232
- package/corpus/core/src/templates/chat/.agents/skills/security/SKILL.md +0 -282
- package/corpus/core/src/templates/chat/.agents/skills/self-modifying-code/SKILL.md +0 -119
- package/corpus/core/src/templates/chat/.agents/skills/shadcn-ui/SKILL.md +0 -123
- package/corpus/core/src/templates/chat/.agents/skills/upgrade-agent-native/SKILL.md +0 -122
- package/corpus/core/src/templates/chat/.env.example +0 -5
- package/corpus/core/src/templates/chat/.ignore +0 -0
- package/corpus/core/src/templates/chat/.oxfmtrc.json +0 -8
- package/corpus/core/src/templates/chat/AGENTS.md +0 -77
- package/corpus/core/src/templates/chat/CHANGELOG.md +0 -10
- package/corpus/core/src/templates/chat/DEVELOPING.md +0 -185
- package/corpus/core/src/templates/chat/README.md +0 -32
- package/corpus/core/src/templates/chat/_gitignore +0 -44
- package/corpus/core/src/templates/chat/actions/hello.ts +0 -13
- package/corpus/core/src/templates/chat/actions/navigate.ts +0 -41
- package/corpus/core/src/templates/chat/actions/run.ts +0 -2
- package/corpus/core/src/templates/chat/actions/view-screen.ts +0 -31
- package/corpus/core/src/templates/chat/app/components/layout/Header.tsx +0 -60
- package/corpus/core/src/templates/chat/app/components/layout/Layout.tsx +0 -188
- package/corpus/core/src/templates/chat/app/components/layout/Sidebar.tsx +0 -505
- package/corpus/core/src/templates/chat/app/components/ui/button.tsx +0 -1
- package/corpus/core/src/templates/chat/app/components/ui/card.tsx +0 -1
- package/corpus/core/src/templates/chat/app/components/ui/dropdown-menu.tsx +0 -1
- package/corpus/core/src/templates/chat/app/components/ui/input.tsx +0 -1
- package/corpus/core/src/templates/chat/app/components/ui/label.tsx +0 -1
- package/corpus/core/src/templates/chat/app/components/ui/sheet.tsx +0 -1
- package/corpus/core/src/templates/chat/app/components/ui/toolkit-provider.tsx +0 -17
- package/corpus/core/src/templates/chat/app/components/ui/tooltip.tsx +0 -1
- package/corpus/core/src/templates/chat/app/design-system.ts +0 -3
- package/corpus/core/src/templates/chat/app/entry.client.tsx +0 -22
- package/corpus/core/src/templates/chat/app/entry.server.tsx +0 -10
- package/corpus/core/src/templates/chat/app/global.css +0 -93
- package/corpus/core/src/templates/chat/app/hooks/use-navigation-state.ts +0 -93
- package/corpus/core/src/templates/chat/app/i18n/ar-SA.ts +0 -68
- package/corpus/core/src/templates/chat/app/i18n/de-DE.ts +0 -71
- package/corpus/core/src/templates/chat/app/i18n/en-US.ts +0 -70
- package/corpus/core/src/templates/chat/app/i18n/es-ES.ts +0 -71
- package/corpus/core/src/templates/chat/app/i18n/fr-FR.ts +0 -71
- package/corpus/core/src/templates/chat/app/i18n/hi-IN.ts +0 -69
- package/corpus/core/src/templates/chat/app/i18n/index.ts +0 -34
- package/corpus/core/src/templates/chat/app/i18n/ja-JP.ts +0 -70
- package/corpus/core/src/templates/chat/app/i18n/ko-KR.ts +0 -70
- package/corpus/core/src/templates/chat/app/i18n/pt-BR.ts +0 -71
- package/corpus/core/src/templates/chat/app/i18n/zh-CN.ts +0 -66
- package/corpus/core/src/templates/chat/app/i18n/zh-TW.ts +0 -66
- package/corpus/core/src/templates/chat/app/i18n-data.ts +0 -556
- package/corpus/core/src/templates/chat/app/lib/agent-page.tsx +0 -49
- package/corpus/core/src/templates/chat/app/lib/app-config.ts +0 -11
- package/corpus/core/src/templates/chat/app/lib/tab-id.ts +0 -1
- package/corpus/core/src/templates/chat/app/lib/utils.ts +0 -1
- package/corpus/core/src/templates/chat/app/root.tsx +0 -173
- package/corpus/core/src/templates/chat/app/routes/_index.tsx +0 -94
- package/corpus/core/src/templates/chat/app/routes/agent.tsx +0 -24
- package/corpus/core/src/templates/chat/app/routes/chat.$threadId.tsx +0 -1
- package/corpus/core/src/templates/chat/app/routes/database.tsx +0 -17
- package/corpus/core/src/templates/chat/app/routes/extensions.$id.$slug.tsx +0 -2
- package/corpus/core/src/templates/chat/app/routes/extensions.$id.tsx +0 -11
- package/corpus/core/src/templates/chat/app/routes/extensions._index.tsx +0 -11
- package/corpus/core/src/templates/chat/app/routes/extensions.tsx +0 -5
- package/corpus/core/src/templates/chat/app/routes/observability.tsx +0 -19
- package/corpus/core/src/templates/chat/app/routes/settings.tsx +0 -89
- package/corpus/core/src/templates/chat/app/routes/team.tsx +0 -11
- package/corpus/core/src/templates/chat/app/routes.ts +0 -4
- package/corpus/core/src/templates/chat/app/vite-env.d.ts +0 -6
- package/corpus/core/src/templates/chat/changelog/2026-06-24-a-new-settings-page-gives-quick-access-to-language-workspace.md +0 -6
- package/corpus/core/src/templates/chat/changelog/2026-06-24-added-a-language-picker-and-localized-app-chrome-for-support.md +0 -6
- package/corpus/core/src/templates/chat/changelog/2026-06-27-traditional-chinese-copy-uses-taiwan-terminology.md +0 -6
- package/corpus/core/src/templates/chat/changelog/2026-06-28-left-sidebar-collapse-motion-and-footer-chrome-are-quieter.md +0 -6
- package/corpus/core/src/templates/chat/changelog/2026-06-29-chat-layouts-adapt-when-the-agent-sidebar-is-open.md +0 -6
- package/corpus/core/src/templates/chat/changelog/2026-07-08-settings-are-cleaner-and-searchable.md +0 -5
- package/corpus/core/src/templates/chat/changelog/2026-07-10-chat-now-makes-ai-connection-setup-clear-without-shifting-th.md +0 -6
- package/corpus/core/src/templates/chat/changelog/2026-07-13-a-full-agent-page-now-brings-context-files-connections-jobs-.md +0 -6
- package/corpus/core/src/templates/chat/changelog/2026-07-14-chat-opens-reliably-on-hosted-deployments-instead-of-failing.md +0 -6
- package/corpus/core/src/templates/chat/changelog/2026-07-14-fixed-chat-template-startup-with-older-core-versions.md +0 -6
- package/corpus/core/src/templates/chat/changelog/2026-07-15-chat-navigation-focuses-on-chat-and-agent.md +0 -6
- package/corpus/core/src/templates/chat/changelog/2026-07-17-the-agent-chat-sidebar-stays-closed-until-you-open-it-or-sta.md +0 -6
- package/corpus/core/src/templates/chat/changelog/2026-07-22-compact-sidebar-footer.md +0 -6
- package/corpus/core/src/templates/chat/changelog/2026-07-22-full-page-chat-keeps-the-active-conversation-when-moving-to-.md +0 -6
- package/corpus/core/src/templates/chat/changelog/2026-07-22-manage-agent-navigation-now-uses-the-connected-nodes-icon.md +0 -6
- package/corpus/core/src/templates/chat/changelog/2026-07-22-recent-chats-are-easier-to-scan-and-expand.md +0 -6
- package/corpus/core/src/templates/chat/changelog/2026-07-23-full-page-chat-is-better-centered-with-quieter-chat-history-.md +0 -6
- package/corpus/core/src/templates/chat/changelog/2026-07-24-borderless-secondary-surfaces.md +0 -6
- package/corpus/core/src/templates/chat/changelog/2026-07-24-sidebar-footer-controls-follow-a-consistent-order.md +0 -6
- package/corpus/core/src/templates/chat/changelog/2026-07-25-settings-navigation-now-keeps-manage-agent-as-a-dedicated-li.md +0 -6
- package/corpus/core/src/templates/chat/components.json +0 -20
- package/corpus/core/src/templates/chat/learnings.defaults.md +0 -5
- package/corpus/core/src/templates/chat/netlify.toml +0 -11
- package/corpus/core/src/templates/chat/package.json +0 -92
- package/corpus/core/src/templates/chat/public/agent-native-icon-dark.svg +0 -10
- package/corpus/core/src/templates/chat/public/agent-native-icon-light.svg +0 -10
- package/corpus/core/src/templates/chat/public/agent-native-logo-dark.svg +0 -21
- package/corpus/core/src/templates/chat/public/agent-native-logo-light.svg +0 -21
- package/corpus/core/src/templates/chat/public/favicon.svg +0 -1
- package/corpus/core/src/templates/chat/public/icon-180.svg +0 -1
- package/corpus/core/src/templates/chat/public/icon-192.svg +0 -1
- package/corpus/core/src/templates/chat/public/icon-512.svg +0 -1
- package/corpus/core/src/templates/chat/public/manifest.json +0 -21
- package/corpus/core/src/templates/chat/react-router.config.ts +0 -7
- package/corpus/core/src/templates/chat/server/middleware/auth.ts +0 -15
- package/corpus/core/src/templates/chat/server/plugins/agent-chat.ts +0 -21
- package/corpus/core/src/templates/chat/server/plugins/auth.ts +0 -17
- package/corpus/core/src/templates/chat/server/routes/[...page].get.ts +0 -5
- package/corpus/core/src/templates/chat/ssr-entry.ts +0 -15
- package/corpus/core/src/templates/chat/tsconfig.json +0 -21
- package/corpus/core/src/templates/chat/vite.config.ts +0 -19
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const DESIGN_VISUAL_EDIT_SKILL_MD = "---\nname: visual-edit\ndescription: >-\n Open a running local app in Design overview mode as URL-backed iframe screens\n for visual editing, flow review, duplication, and route-state exploration.\n Use when the user asks to inspect, compare, or edit a real local app visually\n in Design.\nmetadata:\n visibility: exported\n---\n\n# Visual Edit\n\nUse `/visual-edit` when the user wants to inspect or edit a real local app\nvisually instead of generating standalone Alpine HTML. The source of truth is\nthe running localhost app plus its route URLs. Design shows those routes as\niframe-backed screens on the infinite canvas.\n\n## Installing this skill for an external MCP host\n\nThe hosted install path\n(`npx @agent-native/core@latest skills add visual-edit`, or `design` for the\nfull Design bundle) installs the exported instructions and registers the\nhosted Design MCP connector together. The open Skills CLI path\n(`npx skills@latest add BuilderIO/agent-native --skill visual-edit`) installs\nexported instructions only, with no MCP connector registration.\n\n## Core Model\n\n- Each screen is a URL-backed iframe, not copied HTML.\n- Each screen keeps URL metadata: `connectionId`, `routeId`, `path`,\n `url`, `bridgeUrl`, title, and viewport size.\n- Localhost Edit mode renders the running app through the local bridge as a live\n iframe with the same editor bridge used by HTML designs. It is not a frozen\n static DOM snapshot.\n- The live editor is same-origin through the local bridge proxy. This boots\n CSR apps and root-relative assets, but it is still a localhost editing proxy:\n app-origin cookies, WebSockets/HMR, SSE, and non-GET app API calls may need a\n future dev-server/plugin integration for perfect parity with the app's own\n origin.\n- Interact mode renders the app's normal URL so app navigation, scrolling,\n links, and form controls behave as they would in the browser.\n- While a localhost screen has pending live visual edits, do not switch back to\n Interact until the user either applies the edits to source or explicitly\n aborts/discards the preview.\n- Start in Design's screen overview mode. In overview, screens are static\n design frames; full-screen focus is for scrolling and app interaction.\n- Alt-drag duplicates a screen. For localhost screens, duplication copies the\n iframe frame and URL metadata; change the copy's path/query for a new state.\n- Flow visualization is multiple URL states: `/checkout?step=shipping`,\n `/checkout?step=payment`, `/checkout?step=done`, etc.\n- When the user gives a named flow or numbered screen list, preserve that order\n and create one screen per URL/path. Shorthand like\n `localhost:1234/onboarding/1` means\n `http://localhost:1234/onboarding/1`.\n\n## Select And Reprompt\n\nWhen a chat message begins with `[Reprompt selection]`, the selected subtree is\na hard write boundary. The only mutation path is `propose-node-rewrite` with\nthe exact `repromptId`, target, and `baseVersionHash` captured in\n`design-reprompt-pending:<designId>:<fileId>`. Never use `apply-visual-edit`,\n`apply-source-edit`, `write-source`, `write-local-file`, `edit-design`, or any\nother content-writing action for that request. Clarifying questions are allowed,\nbut a requested change must remain a proposal.\n\nProduce one variant by default. Produce two or three only when the instruction\nasks for options. A retry includes `priorProposalId`; keep the same target and\nbase version, incorporate the feedback, and call `propose-node-rewrite` again.\nThe UI previews the returned subtree without persisting it.\n\nUse `resolve-node-rewrite` for the accept/reject lifecycle. Accept applies the\nchosen variant as one version-checked inline/Yjs content transaction so one\nundo restores the prior structure; reject clears the proposal without changing\ncontent. For conversational resolution such as \"apply the second one,\" call\n`view-screen`, read the active `design.reprompt.proposal`, and pass its\n`proposalId` plus the zero-based `variantIndex` to `resolve-node-rewrite`.\n\n## Review Quality\n\n- Treat the running app as the truth. Preserve its component language, tokens,\n route state, and real content unless the user explicitly asks for a new visual\n direction.\n- Use multiple URL states to reveal meaningful UX moments: empty/loading/error\n states, focused panels, modals, responsive breakpoints, and completed flow\n steps when those matter to the review.\n- For visual edits, compare before/after at the relevant viewport sizes and\n check key hover/focus/scroll states when the app exposes them.\n\n## Account And Sharing Model\n\n- The `/visual-edit` entry route can open before the viewer signs in. Public\n `/design/:id` editor links can also render read-only public designs without a\n session.\n- Prefer links returned by Design actions or `/_agent-native/open` deep links.\n Do not surface URLs with `_session=` tokens. Query sessions are only a\n fallback after normal cookie resolution, so an existing browser session can\n still open the design as a different user and show \"Design not found\".\n- Do not attempt anonymous write actions. Bridge registration, design creation,\n screen placement, generation, saving, and sharing are account-backed. If a\n signed-out visitor wants to save or share, send them through the framework\n sign-in return flow, then save or copy the design into that account before\n opening the share dialog.\n\n## Required Local Bridge\n\nThe live-edit bridge is unlocked by a shared secret (the \"bridge token\") that\nmust match on two sides: the local bridge process, and the user's connection row\nin Design (which the browser reads to authorize `/live-edit-bridge`,\n`/read-file`, `/write-file`). Get them to match by letting the\n**authenticated** `open-visual-edit` action mint the token, then starting the\nbridge with it. This is the only ordering that works for the remote-MCP flow \u2014\nthe bridge cannot push its own token to the server without a CLI auth token, so\nthe server mints instead and the bridge adopts.\n\nFrom the target app repo, make sure its dev server is running, then:\n\n**1. Discover routes without starting a durable bridge** (one-shot, exits):\n\n```bash\nnpx @agent-native/core@latest design connect --url http://localhost:5173 --root . --json\n```\n\nThis prints the manifest (routes + capabilities). Parse it to build\n`routeManifest` for the next step. (Skip this if the user already gave explicit\npaths/URLs to place.)\n\nInside the agent-native monorepo itself, use the workspace CLI instead of\n`npx` \u2014 `npx` installs the last published `@agent-native/core`, which will not\ncontain local changes and costs a slow install on every call:\n\n```bash\npnpm dev:cli design connect --url http://localhost:5173 --root templates/<app> --json\n```\n\n**2. Call `open-visual-edit`** (see Action Flow below) with NO `bridgeToken`.\nThe server mints one, stores it on the user's connection row, copies it into the\nplaced screens' metadata, and returns it to you as `bridgeToken`. Capture it.\n\n**3. Start the persistent bridge adopting that token** (single line; prefer the\nenv var so the secret does not appear in `ps`):\n\n```bash\nAGENT_NATIVE_BRIDGE_TOKEN=\"<bridgeToken from step 2>\" npx @agent-native/core@latest design connect --url http://localhost:5173 --root . --daemon\n```\n\n(Equivalently, pass `--bridge-token <token>`.) This starts a detached bridge on\n`http://127.0.0.1:7331`, adopts the server-minted token \u2014 so bridge and row\nagree and live-edit authorizes with no self-registration \u2014 and stays alive after\nthe command exits.\n\nFor a manual health/manifest check on the running bridge:\n\n```bash\ncurl http://127.0.0.1:7331/health\n```\n\n`/health` needs no token. The full manifest at `/manifest.json` is\npreview-token protected, so an unauthenticated `curl` of it returns\n`{\"ok\":false,\"error\":\"invalid or missing preview token\"}` \u2014 that response means\nthe bridge is up, not that it is broken.\n\nOnly use `--json` for the step-1 route probe. Never use `--json`, `--once`,\nor `--dry-run` for the durable step-3 bridge: they print the manifest and exit,\nso Design falls back to a non-editable live iframe.\n\nThe bridge listens on a single fixed port (7331) and refuses to start for a\nsecond, different app. It is detached with no log file, so if `--daemon` reports\na timeout, check for a stale process (`lsof -ti:7331`) before retrying.\n\n## Action Flow\n\nPrefer the single authenticated `open-visual-edit` action. It registers or\nrefreshes the localhost bridge connection, mints and stores the bridge token,\ncreates or reuses a Design project, places URL-backed screens, stores the active\nvisual-edit context, and navigates to overview mode in one call. This avoids\ncreating a private design under a synthetic CLI user and then handing the browser\na tokenized URL that may be shadowed by an existing session.\n\nCall it BEFORE starting the durable bridge (step 3 above): it does not contact\nthe bridge, so the bridge need not be running yet, and you need its returned\n`bridgeToken` to start the bridge with a matching secret. Omit `bridgeToken`\non the call so the server mints one.\n\n```bash\npnpm action open-visual-edit '{\n \"title\": \"Docs homepage visual edit\",\n \"devServerUrl\": \"http://localhost:5173\",\n \"bridgeUrl\": \"http://127.0.0.1:7331\",\n \"rootPath\": \"/absolute/path/to/app\",\n \"routeManifest\": { \"...\": \"from /manifest.json\" },\n \"paths\": [\"/\", \"/pricing\", \"/checkout?step=payment\"]\n}'\n```\n\nThe action returns `designId`, `connectionId`, `bridgeToken`, `screens`,\n`urlPath`, and `openUrl`. Keep `designId`/`connectionId` in the chat context\nfor follow-ups, and pass `bridgeToken` to `design connect` (step 3) to start\nthe bridge. On follow-up calls reusing an existing `connectionId`, the same\ntoken is returned (it is minted once and reused), so the running bridge stays\nvalid.\n\n### Desktop and mobile side by side\n\nPass `viewports` to place every requested route once per viewport. Frames lay\nout as a grid: one row per route, one column per viewport. Presets are\n`desktop` (1280x900), `laptop` (1440x900), `tablet` (834x1112), and `mobile`\n(390x844); an explicit `{ \"label\": \"...\", \"width\": N, \"height\": N }` also works.\n\n```bash\npnpm action open-visual-edit '{\n \"title\": \"Tasks responsive visual edit\",\n \"devServerUrl\": \"http://localhost:5173\",\n \"bridgeUrl\": \"http://127.0.0.1:7331\",\n \"rootPath\": \"/absolute/path/to/app\",\n \"paths\": [\"/tasks\", \"/inbox\"],\n \"viewports\": [\"desktop\", \"mobile\"]\n}'\n```\n\nPrefer this over two separate calls with `defaultWidth`/`defaultHeight`: it\nkeeps each route's viewports aligned in a row and titles them\n`Tasks \u2014 Desktop` / `Tasks \u2014 Mobile` so the canvas reads clearly. `viewports`\noverrides `defaultWidth`/`defaultHeight`. With no `routes`/`paths`, it expands\nevery route in the localhost manifest, which is usually far more frames than\nthe user wants \u2014 name the paths.\n\n### Adding more page frames later\n\nCall `open-visual-edit` again with the same `designId` and `connectionId` and\nonly the new paths. Existing frames for the same route and viewport are\nrefreshed in place rather than duplicated, and a frame the user has dragged or\nresized keeps its position unless you explicitly pass `x`/`y`/`width`/`height`.\n\n```bash\npnpm action open-visual-edit '{\n \"designId\": \"<existing-design-id>\",\n \"connectionId\": \"<existing-connection-id>\",\n \"devServerUrl\": \"http://localhost:5173\",\n \"paths\": [\"/settings\", \"/team\"],\n \"startY\": 2200\n}'\n```\n\nDo NOT add `defaultWidth`/`defaultHeight` just to restate the default size:\nsupplying either one marks the viewport as explicitly requested, which\noverwrites frame sizes the user has already adjusted on the canvas.\n\nFor a numbered flow the user describes in chat, keep the labels and order:\n\n```bash\npnpm action open-visual-edit '{\n \"designId\": \"<existing-design-id>\",\n \"connectionId\": \"<existing-connection-id>\",\n \"devServerUrl\": \"http://localhost:1234\",\n \"routes\": [\n { \"url\": \"localhost:1234/onboarding/1\", \"title\": \"Screen 1\" },\n { \"url\": \"localhost:1234/onboarding/2\", \"title\": \"Screen 2\" },\n { \"url\": \"localhost:1234/onboarding/3\", \"title\": \"Screen 3\" }\n ]\n}'\n```\n\nIf no `routes` or `paths` are supplied, `open-visual-edit` uses every route\nfrom the localhost manifest.\n\nFallback, only when `open-visual-edit` is unavailable:\n\n1. Register or refresh the bridge with `connect-localhost`, passing the\n `/manifest.json` result as `routeManifest` and `capabilities`.\n2. Create or reuse a Design project with `create-design`.\n3. Place URL-backed screens with `add-localhost-screens`.\n4. Navigate to overview mode with `navigate`.\n\n## Open The Design Surface\n\n- Use the `link`, `deepLink`, or MCP App embed returned by Design actions so\n the user sees the canvas. In Codex Desktop or VS Code, prefer opening that\n Design URL in the available preview/webview panel; otherwise surface the\n \"Open design\" link.\n- Return or open the `openUrl` / action link, not a hand-built\n `/design/:id?_session=...` URL.\n- If the user is working in VS Code, the Agent Native extension can open the\n same URL via\n `vscode://builder.agent-native/open?url=<encoded-design-url>`. Its\n `Agent Native: Open Design Canvas` command also starts the local bridge and\n opens hosted Design in the VS Code side panel.\n- After `open-visual-edit`, confirm the Design editor is in overview mode\n with the requested URL-backed frames visible, and that they render the app\n rather than a spinner. Do not stop at \"screens added\" when the user asked to\n inspect or edit visually.\n\n## Applying Visual Edits Back To Source\n\nCanvas edits on a localhost screen do not write source as you make them. They\naccumulate as pending edits and the editor shows an \"Apply with Design agent\"\nbutton in the bottom-right corner of the canvas. Clicking it hands a structured\nprompt to the Design agent chat, which performs the real source write.\n\n- Style, text, and drag/drop structure edits all collect into the same pending\n batch, so the user can make several changes and apply once.\n- After the write lands, the target app's own dev-server HMR refreshes the\n frames \u2014 no manual reload. If frames do not refresh, the write did not land;\n say so rather than assuming.\n- The separate disk-icon \"Apply to source\" button is the deterministic\n whole-file HTML/CSS writer. It is intentionally disabled for compiled\n `.jsx`/`.tsx` routes \u2014 those must go through the agent path above.\n\n## Editing URLs\n\nKeep localhost screens as URL files plus `screenMetadata[fileId]`. Do not\nreplace them with copied `srcdoc` HTML unless the user explicitly asks for a\nfrozen snapshot. To change a state, rerun `open-visual-edit` with the new\npath/query or duplicate the screen and update the copy's URL metadata.\n\n## Local Files in the Code Tab\n\nOnce a connection is registered, the design editor's Code panel (left rail \u2192\nCode, or `navigate --view editor --designId <id> --leftPanel code`) shows a\nlocal-files workspace root for that connection next to the design's own files.\nTreat that root like VS Code opened at the connected project directory: file\ntree, search, open/edit, and save are backed by the real local files. It lists\nthe connected app's text/code files through the bridge\n(`list-local-files` / `read-local-file`); build output, `node_modules`,\n`.git`, and secret-looking paths (`.env*`, key files) are always excluded.\n\n- Browsing and reading need only editor access on the design plus the running\n bridge.\n- Saving goes through `write-local-file`: the first save opens the\n write-consent dialog (an 8-hour, folder-scoped grant) and retries\n automatically once granted. Only text/code files are writable; secret paths\n are always blocked.\n- If the agent calls `write-local-file` directly (not through a UI save) and it\n fails with \"no write-consent grant\", call `request-localhost-write-consent`.\n It opens the write-consent dialog in the editor, or reports `alreadyGranted`\n if one already exists. Granting is human-only \u2014\n `grant-localhost-write-consent` is hidden from agents, so you cannot approve\n it yourself. Tell the user to click \"Allow writes\", then retry\n `write-local-file` once. Do not keep retrying blindly: the write stays\n blocked until the user approves.\n- Saves are conflict-checked against the file's on-disk version \u2014 a file that\n changed since it was read fails with a version conflict instead of being\n overwritten.\n\n## React Source Writeback\n\n- Use compiler/debug provenance (project-relative file, line, column,\n component, and runtime multiplicity) to locate React/TSX source. Treat it as\n evidence, not as permission for a generic AST structural transform.\n- A single-instance leaf text edit, literal `className`/`class` edit, or flat\n literal `style={{ ... }}` property may use `apply-visual-edit` with a\n `local-file` source and exact `target.sourceAnchor`. Preview first (omit\n `persist`), inspect `proposedDiff`, then call with `persist: true`.\n- Reparenting, grouping/ungrouping, wrappers, dynamic expressions, repeated\n `.map()` instances, shared components, breakpoint-scoped edits, and\n cross-file changes go through the coding agent with exact subject/target\n anchors and their runtime relationship. `apply-visual-edit` refuses these\n with `status: \"needsAgent\"` rather than guessing.\n- Before each write, read the file and pass its exact `versionHash` to\n `write-local-file` with `requireExpectedVersionHash: true`; on conflict,\n re-read and re-plan. Keep the optimistic preview until HMR/runtime confirms\n the result. Human write consent remains mandatory and agents cannot grant it.\n\n## Verification\n\n- `list-localhost-connections` returns the expected connection and routes.\n- The Design editor opens in overview mode.\n- Every requested screen renders the intended localhost URL, showing real app\n content rather than an endless loading spinner.\n- Alt-dragging a screen copies the URL-backed frame, not an inline HTML clone.\n- A query/path edit changes only the target screen's URL metadata and iframe.\n- The Code tab shows a local-files root for the connection and opens its files.\n";
|
|
1
|
+
export declare const DESIGN_VISUAL_EDIT_SKILL_MD = "---\nname: visual-edit\ndescription: >-\n Open a running local app in Design overview mode as URL-backed iframe screens\n for visual editing, flow review, duplication, and route-state exploration.\n Use when the user asks to inspect, compare, or edit a real local app visually\n in Design.\nmetadata:\n visibility: exported\n---\n\n# Visual Edit\n\nUse `/visual-edit` when the user wants to inspect or edit a real local app\nvisually instead of generating standalone Alpine HTML. The source of truth is\nthe running localhost app plus its route URLs. Design shows those routes as\niframe-backed screens on the infinite canvas.\n\n## Installing this skill for an external MCP host\n\nThe hosted install path\n(`npx @agent-native/core@latest skills add visual-edit`, or `design` for the\nfull Design bundle) installs the exported instructions and registers the\nhosted Design MCP connector together. The open Skills CLI path\n(`npx skills@latest add BuilderIO/agent-native --skill visual-edit`) installs\nexported instructions only, with no MCP connector registration.\n\n## Put Design Beside The Chat\n\nAfter `open-visual-edit` returns `openUrl`, open that URL in the coding host's\ninline browser when one is available. This is the preferred working surface:\nthe user can keep Design's canvas beside the conversation, inspect the same\nscreens as the agent, and iterate without switching apps.\n\n- In Codex Desktop, use the in-app Browser tool to open `openUrl`. The built-in\n browser is the right surface for localhost and public pages that should stay\n inside the app.\n- In Claude Code Desktop's Code tab, open or preview `openUrl` in the Browser\n pane. Ask Claude to preview it rather than opening the system browser.\n- In VS Code, use the Agent Native Design webview/deep link described below.\n- Inline browser availability is host-dependent. CLI, remote, or restricted\n sessions may not expose one. If the inline surface is unavailable or disabled,\n return the normal **Open design** link instead of claiming it opened.\n\nPrefer the host's browser/preview tool over telling the user to press a keyboard\nshortcut. Keep the canvas pane beside chat when the host supports rearrangeable\npanes.\n\nInside Design, use **Show/Hide UI** from the `Cmd+K` menu or press\n`Cmd+Shift+\\` on Apple platforms / `Ctrl+Shift+\\` elsewhere to toggle all\nediting chrome so only the canvas remains. The same action is available from\nDesign's empty-canvas context menu.\n\n## Core Model\n\n- Each screen is a URL-backed iframe, not copied HTML.\n- Each screen keeps URL metadata: `connectionId`, `routeId`, `path`,\n `url`, `bridgeUrl`, title, and viewport size.\n- Localhost Edit mode renders the running app through the local bridge as a live\n iframe with the same editor bridge used by HTML designs. It is not a frozen\n static DOM snapshot.\n- The live editor is same-origin through the local bridge proxy. This boots\n CSR apps and root-relative assets, but it is still a localhost editing proxy:\n app-origin cookies, WebSockets/HMR, SSE, and non-GET app API calls may need a\n future dev-server/plugin integration for perfect parity with the app's own\n origin.\n- Interact mode renders the app's normal URL so app navigation, scrolling,\n links, and form controls behave as they would in the browser.\n- While a localhost screen has pending live visual edits, do not switch back to\n Interact until the user either applies the edits to source or explicitly\n aborts/discards the preview.\n- Start in Design's screen overview mode. In overview, screens are static\n design frames; full-screen focus is for scrolling and app interaction.\n- Alt-drag duplicates a screen. For localhost screens, duplication copies the\n iframe frame and URL metadata; change the copy's path/query for a new state.\n- Flow visualization is multiple URL states: `/checkout?step=shipping`,\n `/checkout?step=payment`, `/checkout?step=done`, etc.\n- When the user gives a named flow or numbered screen list, preserve that order\n and create one screen per URL/path. Shorthand like\n `localhost:1234/onboarding/1` means\n `http://localhost:1234/onboarding/1`.\n\n## Useful Canvas Sets\n\nTranslate the user's requested review into the smallest useful set of frames:\n\n- **Multi-step flow:** one ordered frame per route or query state, such as cart,\n shipping, payment, and confirmation.\n- **Multiple pages:** one frame per meaningful route, such as home, pricing,\n docs, and account settings.\n- **Responsive comparison:** repeat the same route at the requested desktop,\n tablet, and mobile viewports so they align in one row.\n- **State review:** repeat a route for meaningful URL-addressable states such as\n empty, loading, error, modal-open, or selected-item views.\n\nDo not expand every discovered route or every viewport unless the user asks for\nan exhaustive audit. Preserve the user's labels and sequence so the canvas reads\nlike the workflow they described.\n\n## Select And Reprompt\n\nWhen a chat message begins with `[Reprompt selection]`, the selected subtree is\na hard write boundary. The only mutation path is `propose-node-rewrite` with\nthe exact `repromptId`, target, and `baseVersionHash` captured in\n`design-reprompt-pending:<designId>:<fileId>`. Never use `apply-visual-edit`,\n`apply-source-edit`, `write-source`, `write-local-file`, `edit-design`, or any\nother content-writing action for that request. Clarifying questions are allowed,\nbut a requested change must remain a proposal.\n\nProduce one variant by default. Produce two or three only when the instruction\nasks for options. A retry includes `priorProposalId`; keep the same target and\nbase version, incorporate the feedback, and call `propose-node-rewrite` again.\nThe UI previews the returned subtree without persisting it.\n\nUse `resolve-node-rewrite` for the accept/reject lifecycle. Accept applies the\nchosen variant as one version-checked inline/Yjs content transaction so one\nundo restores the prior structure; reject clears the proposal without changing\ncontent. For conversational resolution such as \"apply the second one,\" call\n`view-screen`, read the active `design.reprompt.proposal`, and pass its\n`proposalId` plus the zero-based `variantIndex` to `resolve-node-rewrite`.\n\n## Review Quality\n\n- Treat the running app as the truth. Preserve its component language, tokens,\n route state, and real content unless the user explicitly asks for a new visual\n direction.\n- Use multiple URL states to reveal meaningful UX moments: empty/loading/error\n states, focused panels, modals, responsive breakpoints, and completed flow\n steps when those matter to the review.\n- For visual edits, compare before/after at the relevant viewport sizes and\n check key hover/focus/scroll states when the app exposes them.\n\n## Account And Sharing Model\n\n- The `/visual-edit` entry route can open before the viewer signs in. Public\n `/design/:id` editor links can also render read-only public designs without a\n session.\n- Prefer links returned by Design actions or `/_agent-native/open` deep links.\n Do not surface URLs with `_session=` tokens. Query sessions are only a\n fallback after normal cookie resolution, so an existing browser session can\n still open the design as a different user and show \"Design not found\".\n- Do not attempt anonymous write actions. Bridge registration, design creation,\n screen placement, generation, saving, and sharing are account-backed. If a\n signed-out visitor wants to save or share, send them through the framework\n sign-in return flow, then save or copy the design into that account before\n opening the share dialog.\n\n## Required Local Bridge\n\nThe live-edit bridge is unlocked by a shared secret (the \"bridge token\") that\nmust match on two sides: the local bridge process, and the user's connection row\nin Design (which the browser reads to authorize `/live-edit-bridge`,\n`/read-file`, `/write-file`). Get them to match by letting the\n**authenticated** `open-visual-edit` action mint the token, then starting the\nbridge with it. This is the only ordering that works for the remote-MCP flow \u2014\nthe bridge cannot push its own token to the server without a CLI auth token, so\nthe server mints instead and the bridge adopts.\n\nFrom the target app repo, make sure its dev server is running, then:\n\n**1. Discover routes without starting a durable bridge** (one-shot, exits):\n\n```bash\nnpx @agent-native/core@latest design connect --url http://localhost:5173 --root . --json\n```\n\nThis prints the manifest (routes + capabilities). Parse it to build\n`routeManifest` for the next step. (Skip this if the user already gave explicit\npaths/URLs to place.)\n\nInside the agent-native monorepo itself, use the workspace CLI instead of\n`npx` \u2014 `npx` installs the last published `@agent-native/core`, which will not\ncontain local changes and costs a slow install on every call:\n\n```bash\npnpm dev:cli design connect --url http://localhost:5173 --root templates/<app> --json\n```\n\n**2. Call `open-visual-edit`** (see Action Flow below) with NO `bridgeToken`.\nThe server mints one, stores it on the user's connection row, copies it into the\nplaced screens' metadata, and returns it to you as `bridgeToken`. Capture it.\n\n**3. Start the persistent bridge adopting that token** (single line; prefer the\nenv var so the secret does not appear in `ps`):\n\n```bash\nAGENT_NATIVE_BRIDGE_TOKEN=\"<bridgeToken from step 2>\" npx @agent-native/core@latest design connect --url http://localhost:5173 --root . --daemon\n```\n\n(Equivalently, pass `--bridge-token <token>`.) This starts a detached bridge on\n`http://127.0.0.1:7331`, adopts the server-minted token \u2014 so bridge and row\nagree and live-edit authorizes with no self-registration \u2014 and stays alive after\nthe command exits.\n\nFor a manual health/manifest check on the running bridge:\n\n```bash\ncurl http://127.0.0.1:7331/health\n```\n\n`/health` needs no token. The full manifest at `/manifest.json` is\npreview-token protected, so an unauthenticated `curl` of it returns\n`{\"ok\":false,\"error\":\"invalid or missing preview token\"}` \u2014 that response means\nthe bridge is up, not that it is broken.\n\nOnly use `--json` for the step-1 route probe. Never use `--json`, `--once`,\nor `--dry-run` for the durable step-3 bridge: they print the manifest and exit,\nso Design falls back to a non-editable live iframe.\n\nThe bridge listens on a single fixed port (7331) and refuses to start for a\nsecond, different app. It is detached with no log file, so if `--daemon` reports\na timeout, check for a stale process (`lsof -ti:7331`) before retrying.\n\n## Action Flow\n\nPrefer the single authenticated `open-visual-edit` action. It registers or\nrefreshes the localhost bridge connection, mints and stores the bridge token,\ncreates or reuses a Design project, places URL-backed screens, stores the active\nvisual-edit context, and navigates to overview mode in one call. This avoids\ncreating a private design under a synthetic CLI user and then handing the browser\na tokenized URL that may be shadowed by an existing session.\n\nCall it BEFORE starting the durable bridge (step 3 above): it does not contact\nthe bridge, so the bridge need not be running yet, and you need its returned\n`bridgeToken` to start the bridge with a matching secret. Omit `bridgeToken`\non the call so the server mints one.\n\n```bash\npnpm action open-visual-edit '{\n \"title\": \"Docs homepage visual edit\",\n \"devServerUrl\": \"http://localhost:5173\",\n \"bridgeUrl\": \"http://127.0.0.1:7331\",\n \"rootPath\": \"/absolute/path/to/app\",\n \"routeManifest\": { \"...\": \"from /manifest.json\" },\n \"paths\": [\"/\", \"/pricing\", \"/checkout?step=payment\"]\n}'\n```\n\nThe action returns `designId`, `connectionId`, `bridgeToken`, `screens`,\n`urlPath`, and `openUrl`. Keep `designId`/`connectionId` in the chat context\nfor follow-ups, and pass `bridgeToken` to `design connect` (step 3) to start\nthe bridge. On follow-up calls reusing an existing `connectionId`, the same\ntoken is returned (it is minted once and reused), so the running bridge stays\nvalid.\n\n### Desktop and mobile side by side\n\nPass `viewports` to place every requested route once per viewport. Frames lay\nout as a grid: one row per route, one column per viewport. Presets are\n`desktop` (1280x900), `laptop` (1440x900), `tablet` (834x1112), and `mobile`\n(390x844); an explicit `{ \"label\": \"...\", \"width\": N, \"height\": N }` also works.\n\n```bash\npnpm action open-visual-edit '{\n \"title\": \"Tasks responsive visual edit\",\n \"devServerUrl\": \"http://localhost:5173\",\n \"bridgeUrl\": \"http://127.0.0.1:7331\",\n \"rootPath\": \"/absolute/path/to/app\",\n \"paths\": [\"/tasks\", \"/inbox\"],\n \"viewports\": [\"desktop\", \"mobile\"]\n}'\n```\n\nPrefer this over two separate calls with `defaultWidth`/`defaultHeight`: it\nkeeps each route's viewports aligned in a row and titles them\n`Tasks \u2014 Desktop` / `Tasks \u2014 Mobile` so the canvas reads clearly. `viewports`\noverrides `defaultWidth`/`defaultHeight`. With no `routes`/`paths`, it expands\nevery route in the localhost manifest, which is usually far more frames than\nthe user wants \u2014 name the paths.\n\n### Adding more page frames later\n\nCall `open-visual-edit` again with the same `designId` and `connectionId` and\nonly the new paths. Existing frames for the same route and viewport are\nrefreshed in place rather than duplicated, and a frame the user has dragged or\nresized keeps its position unless you explicitly pass `x`/`y`/`width`/`height`.\n\n```bash\npnpm action open-visual-edit '{\n \"designId\": \"<existing-design-id>\",\n \"connectionId\": \"<existing-connection-id>\",\n \"devServerUrl\": \"http://localhost:5173\",\n \"paths\": [\"/settings\", \"/team\"],\n \"startY\": 2200\n}'\n```\n\nDo NOT add `defaultWidth`/`defaultHeight` just to restate the default size:\nsupplying either one marks the viewport as explicitly requested, which\noverwrites frame sizes the user has already adjusted on the canvas.\n\nFor a numbered flow the user describes in chat, keep the labels and order:\n\n```bash\npnpm action open-visual-edit '{\n \"designId\": \"<existing-design-id>\",\n \"connectionId\": \"<existing-connection-id>\",\n \"devServerUrl\": \"http://localhost:1234\",\n \"routes\": [\n { \"url\": \"localhost:1234/onboarding/1\", \"title\": \"Screen 1\" },\n { \"url\": \"localhost:1234/onboarding/2\", \"title\": \"Screen 2\" },\n { \"url\": \"localhost:1234/onboarding/3\", \"title\": \"Screen 3\" }\n ]\n}'\n```\n\nIf no `routes` or `paths` are supplied, `open-visual-edit` uses every route\nfrom the localhost manifest.\n\nFallback, only when `open-visual-edit` is unavailable:\n\n1. Register or refresh the bridge with `connect-localhost`, passing the\n `/manifest.json` result as `routeManifest` and `capabilities`.\n2. Create or reuse a Design project with `create-design`.\n3. Place URL-backed screens with `add-localhost-screens`.\n4. Navigate to overview mode with `navigate`.\n\n## Open The Design Surface\n\n- Use the `link`, `deepLink`, or MCP App embed returned by Design actions so\n the user sees the canvas. Follow **Put Design Beside The Chat**: prefer the\n host's inline Browser, preview, or webview panel; otherwise surface the\n **Open design** link.\n- Return or open the `openUrl` / action link, not a hand-built\n `/design/:id?_session=...` URL.\n- If the user is working in VS Code, the Agent Native extension can open the\n same URL via\n `vscode://builder.agent-native/open?url=<encoded-design-url>`. Its\n `Agent Native: Open Design Canvas` command also starts the local bridge and\n opens hosted Design in the VS Code side panel.\n- After `open-visual-edit`, confirm the Design editor is in overview mode\n with the requested URL-backed frames visible, and that they render the app\n rather than a spinner. Do not stop at \"screens added\" when the user asked to\n inspect or edit visually.\n\n## Applying Visual Edits Back To Source\n\nCanvas edits on a localhost screen do not write source as you make them. They\naccumulate as pending edits and the editor shows an \"Apply with Design agent\"\nbutton in the bottom-right corner of the canvas. Clicking it hands a structured\nprompt to the Design agent chat, which performs the real source write.\n\n- Style, text, and drag/drop structure edits all collect into the same pending\n batch, so the user can make several changes and apply once.\n- After the write lands, the target app's own dev-server HMR refreshes the\n frames \u2014 no manual reload. If frames do not refresh, the write did not land;\n say so rather than assuming.\n- The separate disk-icon \"Apply to source\" button is the deterministic\n whole-file HTML/CSS writer. It is intentionally disabled for compiled\n `.jsx`/`.tsx` routes \u2014 those must go through the agent path above.\n\n## Editing URLs\n\nKeep localhost screens as URL files plus `screenMetadata[fileId]`. Do not\nreplace them with copied `srcdoc` HTML unless the user explicitly asks for a\nfrozen snapshot. To change a state, rerun `open-visual-edit` with the new\npath/query or duplicate the screen and update the copy's URL metadata.\n\n## Local Files in the Code Tab\n\nOnce a connection is registered, the design editor's Code panel (left rail \u2192\nCode, or `navigate --view editor --designId <id> --leftPanel code`) shows a\nlocal-files workspace root for that connection next to the design's own files.\nTreat that root like VS Code opened at the connected project directory: file\ntree, search, open/edit, and save are backed by the real local files. It lists\nthe connected app's text/code files through the bridge\n(`list-local-files` / `read-local-file`); build output, `node_modules`,\n`.git`, and secret-looking paths (`.env*`, key files) are always excluded.\n\n- Browsing and reading need only editor access on the design plus the running\n bridge.\n- Saving goes through `write-local-file`: the first save opens the\n write-consent dialog (an 8-hour, folder-scoped grant) and retries\n automatically once granted. Only text/code files are writable; secret paths\n are always blocked.\n- If the agent calls `write-local-file` directly (not through a UI save) and it\n fails with \"no write-consent grant\", call `request-localhost-write-consent`.\n It opens the write-consent dialog in the editor, or reports `alreadyGranted`\n if one already exists. Granting is human-only \u2014\n `grant-localhost-write-consent` is hidden from agents, so you cannot approve\n it yourself. Tell the user to click \"Allow writes\", then retry\n `write-local-file` once. Do not keep retrying blindly: the write stays\n blocked until the user approves.\n- Saves are conflict-checked against the file's on-disk version \u2014 a file that\n changed since it was read fails with a version conflict instead of being\n overwritten.\n\n## React Source Writeback\n\n- Use compiler/debug provenance (project-relative file, line, column,\n component, and runtime multiplicity) to locate React/TSX source. Treat it as\n evidence, not as permission for a generic AST structural transform.\n- A single-instance leaf text edit, literal `className`/`class` edit, or flat\n literal `style={{ ... }}` property may use `apply-visual-edit` with a\n `local-file` source and exact `target.sourceAnchor`. Preview first (omit\n `persist`), inspect `proposedDiff`, then call with `persist: true`.\n- Reparenting, grouping/ungrouping, wrappers, dynamic expressions, repeated\n `.map()` instances, shared components, breakpoint-scoped edits, and\n cross-file changes go through the coding agent with exact subject/target\n anchors and their runtime relationship. `apply-visual-edit` refuses these\n with `status: \"needsAgent\"` rather than guessing.\n- Before each write, read the file and pass its exact `versionHash` to\n `write-local-file` with `requireExpectedVersionHash: true`; on conflict,\n re-read and re-plan. Keep the optimistic preview until HMR/runtime confirms\n the result. Human write consent remains mandatory and agents cannot grant it.\n\n## Verification\n\n- `list-localhost-connections` returns the expected connection and routes.\n- The Design editor opens in overview mode.\n- Every requested screen renders the intended localhost URL, showing real app\n content rather than an endless loading spinner.\n- Alt-dragging a screen copies the URL-backed frame, not an inline HTML clone.\n- A query/path edit changes only the target screen's URL metadata and iframe.\n- The Code tab shows a local-files root for the connection and opens its files.\n";
|
|
2
2
|
//# sourceMappingURL=design-visual-edit-skill.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"design-visual-edit-skill.d.ts","sourceRoot":"","sources":["../../../src/cli/skills-content/design-visual-edit-skill.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,2BAA2B,
|
|
1
|
+
{"version":3,"file":"design-visual-edit-skill.d.ts","sourceRoot":"","sources":["../../../src/cli/skills-content/design-visual-edit-skill.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,2BAA2B,yzoBA+ZvC,CAAC"}
|
|
@@ -25,6 +25,32 @@ hosted Design MCP connector together. The open Skills CLI path
|
|
|
25
25
|
(\`npx skills@latest add BuilderIO/agent-native --skill visual-edit\`) installs
|
|
26
26
|
exported instructions only, with no MCP connector registration.
|
|
27
27
|
|
|
28
|
+
## Put Design Beside The Chat
|
|
29
|
+
|
|
30
|
+
After \`open-visual-edit\` returns \`openUrl\`, open that URL in the coding host's
|
|
31
|
+
inline browser when one is available. This is the preferred working surface:
|
|
32
|
+
the user can keep Design's canvas beside the conversation, inspect the same
|
|
33
|
+
screens as the agent, and iterate without switching apps.
|
|
34
|
+
|
|
35
|
+
- In Codex Desktop, use the in-app Browser tool to open \`openUrl\`. The built-in
|
|
36
|
+
browser is the right surface for localhost and public pages that should stay
|
|
37
|
+
inside the app.
|
|
38
|
+
- In Claude Code Desktop's Code tab, open or preview \`openUrl\` in the Browser
|
|
39
|
+
pane. Ask Claude to preview it rather than opening the system browser.
|
|
40
|
+
- In VS Code, use the Agent Native Design webview/deep link described below.
|
|
41
|
+
- Inline browser availability is host-dependent. CLI, remote, or restricted
|
|
42
|
+
sessions may not expose one. If the inline surface is unavailable or disabled,
|
|
43
|
+
return the normal **Open design** link instead of claiming it opened.
|
|
44
|
+
|
|
45
|
+
Prefer the host's browser/preview tool over telling the user to press a keyboard
|
|
46
|
+
shortcut. Keep the canvas pane beside chat when the host supports rearrangeable
|
|
47
|
+
panes.
|
|
48
|
+
|
|
49
|
+
Inside Design, use **Show/Hide UI** from the \`Cmd+K\` menu or press
|
|
50
|
+
\`Cmd+Shift+\\\` on Apple platforms / \`Ctrl+Shift+\\\` elsewhere to toggle all
|
|
51
|
+
editing chrome so only the canvas remains. The same action is available from
|
|
52
|
+
Design's empty-canvas context menu.
|
|
53
|
+
|
|
28
54
|
## Core Model
|
|
29
55
|
|
|
30
56
|
- Each screen is a URL-backed iframe, not copied HTML.
|
|
@@ -54,6 +80,23 @@ exported instructions only, with no MCP connector registration.
|
|
|
54
80
|
\`localhost:1234/onboarding/1\` means
|
|
55
81
|
\`http://localhost:1234/onboarding/1\`.
|
|
56
82
|
|
|
83
|
+
## Useful Canvas Sets
|
|
84
|
+
|
|
85
|
+
Translate the user's requested review into the smallest useful set of frames:
|
|
86
|
+
|
|
87
|
+
- **Multi-step flow:** one ordered frame per route or query state, such as cart,
|
|
88
|
+
shipping, payment, and confirmation.
|
|
89
|
+
- **Multiple pages:** one frame per meaningful route, such as home, pricing,
|
|
90
|
+
docs, and account settings.
|
|
91
|
+
- **Responsive comparison:** repeat the same route at the requested desktop,
|
|
92
|
+
tablet, and mobile viewports so they align in one row.
|
|
93
|
+
- **State review:** repeat a route for meaningful URL-addressable states such as
|
|
94
|
+
empty, loading, error, modal-open, or selected-item views.
|
|
95
|
+
|
|
96
|
+
Do not expand every discovered route or every viewport unless the user asks for
|
|
97
|
+
an exhaustive audit. Preserve the user's labels and sequence so the canvas reads
|
|
98
|
+
like the workflow they described.
|
|
99
|
+
|
|
57
100
|
## Select And Reprompt
|
|
58
101
|
|
|
59
102
|
When a chat message begins with \`[Reprompt selection]\`, the selected subtree is
|
|
@@ -275,9 +318,9 @@ Fallback, only when \`open-visual-edit\` is unavailable:
|
|
|
275
318
|
## Open The Design Surface
|
|
276
319
|
|
|
277
320
|
- Use the \`link\`, \`deepLink\`, or MCP App embed returned by Design actions so
|
|
278
|
-
the user sees the canvas.
|
|
279
|
-
|
|
280
|
-
|
|
321
|
+
the user sees the canvas. Follow **Put Design Beside The Chat**: prefer the
|
|
322
|
+
host's inline Browser, preview, or webview panel; otherwise surface the
|
|
323
|
+
**Open design** link.
|
|
281
324
|
- Return or open the \`openUrl\` / action link, not a hand-built
|
|
282
325
|
\`/design/:id?_session=...\` URL.
|
|
283
326
|
- If the user is working in VS Code, the Agent Native extension can open the
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"design-visual-edit-skill.js","sourceRoot":"","sources":["../../../src/cli/skills-content/design-visual-edit-skill.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,2BAA2B,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAoX1C,CAAC","sourcesContent":["export const DESIGN_VISUAL_EDIT_SKILL_MD = `---\nname: visual-edit\ndescription: >-\n Open a running local app in Design overview mode as URL-backed iframe screens\n for visual editing, flow review, duplication, and route-state exploration.\n Use when the user asks to inspect, compare, or edit a real local app visually\n in Design.\nmetadata:\n visibility: exported\n---\n\n# Visual Edit\n\nUse \\`/visual-edit\\` when the user wants to inspect or edit a real local app\nvisually instead of generating standalone Alpine HTML. The source of truth is\nthe running localhost app plus its route URLs. Design shows those routes as\niframe-backed screens on the infinite canvas.\n\n## Installing this skill for an external MCP host\n\nThe hosted install path\n(\\`npx @agent-native/core@latest skills add visual-edit\\`, or \\`design\\` for the\nfull Design bundle) installs the exported instructions and registers the\nhosted Design MCP connector together. The open Skills CLI path\n(\\`npx skills@latest add BuilderIO/agent-native --skill visual-edit\\`) installs\nexported instructions only, with no MCP connector registration.\n\n## Core Model\n\n- Each screen is a URL-backed iframe, not copied HTML.\n- Each screen keeps URL metadata: \\`connectionId\\`, \\`routeId\\`, \\`path\\`,\n \\`url\\`, \\`bridgeUrl\\`, title, and viewport size.\n- Localhost Edit mode renders the running app through the local bridge as a live\n iframe with the same editor bridge used by HTML designs. It is not a frozen\n static DOM snapshot.\n- The live editor is same-origin through the local bridge proxy. This boots\n CSR apps and root-relative assets, but it is still a localhost editing proxy:\n app-origin cookies, WebSockets/HMR, SSE, and non-GET app API calls may need a\n future dev-server/plugin integration for perfect parity with the app's own\n origin.\n- Interact mode renders the app's normal URL so app navigation, scrolling,\n links, and form controls behave as they would in the browser.\n- While a localhost screen has pending live visual edits, do not switch back to\n Interact until the user either applies the edits to source or explicitly\n aborts/discards the preview.\n- Start in Design's screen overview mode. In overview, screens are static\n design frames; full-screen focus is for scrolling and app interaction.\n- Alt-drag duplicates a screen. For localhost screens, duplication copies the\n iframe frame and URL metadata; change the copy's path/query for a new state.\n- Flow visualization is multiple URL states: \\`/checkout?step=shipping\\`,\n \\`/checkout?step=payment\\`, \\`/checkout?step=done\\`, etc.\n- When the user gives a named flow or numbered screen list, preserve that order\n and create one screen per URL/path. Shorthand like\n \\`localhost:1234/onboarding/1\\` means\n \\`http://localhost:1234/onboarding/1\\`.\n\n## Select And Reprompt\n\nWhen a chat message begins with \\`[Reprompt selection]\\`, the selected subtree is\na hard write boundary. The only mutation path is \\`propose-node-rewrite\\` with\nthe exact \\`repromptId\\`, target, and \\`baseVersionHash\\` captured in\n\\`design-reprompt-pending:<designId>:<fileId>\\`. Never use \\`apply-visual-edit\\`,\n\\`apply-source-edit\\`, \\`write-source\\`, \\`write-local-file\\`, \\`edit-design\\`, or any\nother content-writing action for that request. Clarifying questions are allowed,\nbut a requested change must remain a proposal.\n\nProduce one variant by default. Produce two or three only when the instruction\nasks for options. A retry includes \\`priorProposalId\\`; keep the same target and\nbase version, incorporate the feedback, and call \\`propose-node-rewrite\\` again.\nThe UI previews the returned subtree without persisting it.\n\nUse \\`resolve-node-rewrite\\` for the accept/reject lifecycle. Accept applies the\nchosen variant as one version-checked inline/Yjs content transaction so one\nundo restores the prior structure; reject clears the proposal without changing\ncontent. For conversational resolution such as \"apply the second one,\" call\n\\`view-screen\\`, read the active \\`design.reprompt.proposal\\`, and pass its\n\\`proposalId\\` plus the zero-based \\`variantIndex\\` to \\`resolve-node-rewrite\\`.\n\n## Review Quality\n\n- Treat the running app as the truth. Preserve its component language, tokens,\n route state, and real content unless the user explicitly asks for a new visual\n direction.\n- Use multiple URL states to reveal meaningful UX moments: empty/loading/error\n states, focused panels, modals, responsive breakpoints, and completed flow\n steps when those matter to the review.\n- For visual edits, compare before/after at the relevant viewport sizes and\n check key hover/focus/scroll states when the app exposes them.\n\n## Account And Sharing Model\n\n- The \\`/visual-edit\\` entry route can open before the viewer signs in. Public\n \\`/design/:id\\` editor links can also render read-only public designs without a\n session.\n- Prefer links returned by Design actions or \\`/_agent-native/open\\` deep links.\n Do not surface URLs with \\`_session=\\` tokens. Query sessions are only a\n fallback after normal cookie resolution, so an existing browser session can\n still open the design as a different user and show \"Design not found\".\n- Do not attempt anonymous write actions. Bridge registration, design creation,\n screen placement, generation, saving, and sharing are account-backed. If a\n signed-out visitor wants to save or share, send them through the framework\n sign-in return flow, then save or copy the design into that account before\n opening the share dialog.\n\n## Required Local Bridge\n\nThe live-edit bridge is unlocked by a shared secret (the \"bridge token\") that\nmust match on two sides: the local bridge process, and the user's connection row\nin Design (which the browser reads to authorize \\`/live-edit-bridge\\`,\n\\`/read-file\\`, \\`/write-file\\`). Get them to match by letting the\n**authenticated** \\`open-visual-edit\\` action mint the token, then starting the\nbridge with it. This is the only ordering that works for the remote-MCP flow —\nthe bridge cannot push its own token to the server without a CLI auth token, so\nthe server mints instead and the bridge adopts.\n\nFrom the target app repo, make sure its dev server is running, then:\n\n**1. Discover routes without starting a durable bridge** (one-shot, exits):\n\n\\`\\`\\`bash\nnpx @agent-native/core@latest design connect --url http://localhost:5173 --root . --json\n\\`\\`\\`\n\nThis prints the manifest (routes + capabilities). Parse it to build\n\\`routeManifest\\` for the next step. (Skip this if the user already gave explicit\npaths/URLs to place.)\n\nInside the agent-native monorepo itself, use the workspace CLI instead of\n\\`npx\\` — \\`npx\\` installs the last published \\`@agent-native/core\\`, which will not\ncontain local changes and costs a slow install on every call:\n\n\\`\\`\\`bash\npnpm dev:cli design connect --url http://localhost:5173 --root templates/<app> --json\n\\`\\`\\`\n\n**2. Call \\`open-visual-edit\\`** (see Action Flow below) with NO \\`bridgeToken\\`.\nThe server mints one, stores it on the user's connection row, copies it into the\nplaced screens' metadata, and returns it to you as \\`bridgeToken\\`. Capture it.\n\n**3. Start the persistent bridge adopting that token** (single line; prefer the\nenv var so the secret does not appear in \\`ps\\`):\n\n\\`\\`\\`bash\nAGENT_NATIVE_BRIDGE_TOKEN=\"<bridgeToken from step 2>\" npx @agent-native/core@latest design connect --url http://localhost:5173 --root . --daemon\n\\`\\`\\`\n\n(Equivalently, pass \\`--bridge-token <token>\\`.) This starts a detached bridge on\n\\`http://127.0.0.1:7331\\`, adopts the server-minted token — so bridge and row\nagree and live-edit authorizes with no self-registration — and stays alive after\nthe command exits.\n\nFor a manual health/manifest check on the running bridge:\n\n\\`\\`\\`bash\ncurl http://127.0.0.1:7331/health\n\\`\\`\\`\n\n\\`/health\\` needs no token. The full manifest at \\`/manifest.json\\` is\npreview-token protected, so an unauthenticated \\`curl\\` of it returns\n\\`{\"ok\":false,\"error\":\"invalid or missing preview token\"}\\` — that response means\nthe bridge is up, not that it is broken.\n\nOnly use \\`--json\\` for the step-1 route probe. Never use \\`--json\\`, \\`--once\\`,\nor \\`--dry-run\\` for the durable step-3 bridge: they print the manifest and exit,\nso Design falls back to a non-editable live iframe.\n\nThe bridge listens on a single fixed port (7331) and refuses to start for a\nsecond, different app. It is detached with no log file, so if \\`--daemon\\` reports\na timeout, check for a stale process (\\`lsof -ti:7331\\`) before retrying.\n\n## Action Flow\n\nPrefer the single authenticated \\`open-visual-edit\\` action. It registers or\nrefreshes the localhost bridge connection, mints and stores the bridge token,\ncreates or reuses a Design project, places URL-backed screens, stores the active\nvisual-edit context, and navigates to overview mode in one call. This avoids\ncreating a private design under a synthetic CLI user and then handing the browser\na tokenized URL that may be shadowed by an existing session.\n\nCall it BEFORE starting the durable bridge (step 3 above): it does not contact\nthe bridge, so the bridge need not be running yet, and you need its returned\n\\`bridgeToken\\` to start the bridge with a matching secret. Omit \\`bridgeToken\\`\non the call so the server mints one.\n\n\\`\\`\\`bash\npnpm action open-visual-edit '{\n \"title\": \"Docs homepage visual edit\",\n \"devServerUrl\": \"http://localhost:5173\",\n \"bridgeUrl\": \"http://127.0.0.1:7331\",\n \"rootPath\": \"/absolute/path/to/app\",\n \"routeManifest\": { \"...\": \"from /manifest.json\" },\n \"paths\": [\"/\", \"/pricing\", \"/checkout?step=payment\"]\n}'\n\\`\\`\\`\n\nThe action returns \\`designId\\`, \\`connectionId\\`, \\`bridgeToken\\`, \\`screens\\`,\n\\`urlPath\\`, and \\`openUrl\\`. Keep \\`designId\\`/\\`connectionId\\` in the chat context\nfor follow-ups, and pass \\`bridgeToken\\` to \\`design connect\\` (step 3) to start\nthe bridge. On follow-up calls reusing an existing \\`connectionId\\`, the same\ntoken is returned (it is minted once and reused), so the running bridge stays\nvalid.\n\n### Desktop and mobile side by side\n\nPass \\`viewports\\` to place every requested route once per viewport. Frames lay\nout as a grid: one row per route, one column per viewport. Presets are\n\\`desktop\\` (1280x900), \\`laptop\\` (1440x900), \\`tablet\\` (834x1112), and \\`mobile\\`\n(390x844); an explicit \\`{ \"label\": \"...\", \"width\": N, \"height\": N }\\` also works.\n\n\\`\\`\\`bash\npnpm action open-visual-edit '{\n \"title\": \"Tasks responsive visual edit\",\n \"devServerUrl\": \"http://localhost:5173\",\n \"bridgeUrl\": \"http://127.0.0.1:7331\",\n \"rootPath\": \"/absolute/path/to/app\",\n \"paths\": [\"/tasks\", \"/inbox\"],\n \"viewports\": [\"desktop\", \"mobile\"]\n}'\n\\`\\`\\`\n\nPrefer this over two separate calls with \\`defaultWidth\\`/\\`defaultHeight\\`: it\nkeeps each route's viewports aligned in a row and titles them\n\\`Tasks — Desktop\\` / \\`Tasks — Mobile\\` so the canvas reads clearly. \\`viewports\\`\noverrides \\`defaultWidth\\`/\\`defaultHeight\\`. With no \\`routes\\`/\\`paths\\`, it expands\nevery route in the localhost manifest, which is usually far more frames than\nthe user wants — name the paths.\n\n### Adding more page frames later\n\nCall \\`open-visual-edit\\` again with the same \\`designId\\` and \\`connectionId\\` and\nonly the new paths. Existing frames for the same route and viewport are\nrefreshed in place rather than duplicated, and a frame the user has dragged or\nresized keeps its position unless you explicitly pass \\`x\\`/\\`y\\`/\\`width\\`/\\`height\\`.\n\n\\`\\`\\`bash\npnpm action open-visual-edit '{\n \"designId\": \"<existing-design-id>\",\n \"connectionId\": \"<existing-connection-id>\",\n \"devServerUrl\": \"http://localhost:5173\",\n \"paths\": [\"/settings\", \"/team\"],\n \"startY\": 2200\n}'\n\\`\\`\\`\n\nDo NOT add \\`defaultWidth\\`/\\`defaultHeight\\` just to restate the default size:\nsupplying either one marks the viewport as explicitly requested, which\noverwrites frame sizes the user has already adjusted on the canvas.\n\nFor a numbered flow the user describes in chat, keep the labels and order:\n\n\\`\\`\\`bash\npnpm action open-visual-edit '{\n \"designId\": \"<existing-design-id>\",\n \"connectionId\": \"<existing-connection-id>\",\n \"devServerUrl\": \"http://localhost:1234\",\n \"routes\": [\n { \"url\": \"localhost:1234/onboarding/1\", \"title\": \"Screen 1\" },\n { \"url\": \"localhost:1234/onboarding/2\", \"title\": \"Screen 2\" },\n { \"url\": \"localhost:1234/onboarding/3\", \"title\": \"Screen 3\" }\n ]\n}'\n\\`\\`\\`\n\nIf no \\`routes\\` or \\`paths\\` are supplied, \\`open-visual-edit\\` uses every route\nfrom the localhost manifest.\n\nFallback, only when \\`open-visual-edit\\` is unavailable:\n\n1. Register or refresh the bridge with \\`connect-localhost\\`, passing the\n \\`/manifest.json\\` result as \\`routeManifest\\` and \\`capabilities\\`.\n2. Create or reuse a Design project with \\`create-design\\`.\n3. Place URL-backed screens with \\`add-localhost-screens\\`.\n4. Navigate to overview mode with \\`navigate\\`.\n\n## Open The Design Surface\n\n- Use the \\`link\\`, \\`deepLink\\`, or MCP App embed returned by Design actions so\n the user sees the canvas. In Codex Desktop or VS Code, prefer opening that\n Design URL in the available preview/webview panel; otherwise surface the\n \"Open design\" link.\n- Return or open the \\`openUrl\\` / action link, not a hand-built\n \\`/design/:id?_session=...\\` URL.\n- If the user is working in VS Code, the Agent Native extension can open the\n same URL via\n \\`vscode://builder.agent-native/open?url=<encoded-design-url>\\`. Its\n \\`Agent Native: Open Design Canvas\\` command also starts the local bridge and\n opens hosted Design in the VS Code side panel.\n- After \\`open-visual-edit\\`, confirm the Design editor is in overview mode\n with the requested URL-backed frames visible, and that they render the app\n rather than a spinner. Do not stop at \"screens added\" when the user asked to\n inspect or edit visually.\n\n## Applying Visual Edits Back To Source\n\nCanvas edits on a localhost screen do not write source as you make them. They\naccumulate as pending edits and the editor shows an \"Apply with Design agent\"\nbutton in the bottom-right corner of the canvas. Clicking it hands a structured\nprompt to the Design agent chat, which performs the real source write.\n\n- Style, text, and drag/drop structure edits all collect into the same pending\n batch, so the user can make several changes and apply once.\n- After the write lands, the target app's own dev-server HMR refreshes the\n frames — no manual reload. If frames do not refresh, the write did not land;\n say so rather than assuming.\n- The separate disk-icon \"Apply to source\" button is the deterministic\n whole-file HTML/CSS writer. It is intentionally disabled for compiled\n \\`.jsx\\`/\\`.tsx\\` routes — those must go through the agent path above.\n\n## Editing URLs\n\nKeep localhost screens as URL files plus \\`screenMetadata[fileId]\\`. Do not\nreplace them with copied \\`srcdoc\\` HTML unless the user explicitly asks for a\nfrozen snapshot. To change a state, rerun \\`open-visual-edit\\` with the new\npath/query or duplicate the screen and update the copy's URL metadata.\n\n## Local Files in the Code Tab\n\nOnce a connection is registered, the design editor's Code panel (left rail →\nCode, or \\`navigate --view editor --designId <id> --leftPanel code\\`) shows a\nlocal-files workspace root for that connection next to the design's own files.\nTreat that root like VS Code opened at the connected project directory: file\ntree, search, open/edit, and save are backed by the real local files. It lists\nthe connected app's text/code files through the bridge\n(\\`list-local-files\\` / \\`read-local-file\\`); build output, \\`node_modules\\`,\n\\`.git\\`, and secret-looking paths (\\`.env*\\`, key files) are always excluded.\n\n- Browsing and reading need only editor access on the design plus the running\n bridge.\n- Saving goes through \\`write-local-file\\`: the first save opens the\n write-consent dialog (an 8-hour, folder-scoped grant) and retries\n automatically once granted. Only text/code files are writable; secret paths\n are always blocked.\n- If the agent calls \\`write-local-file\\` directly (not through a UI save) and it\n fails with \"no write-consent grant\", call \\`request-localhost-write-consent\\`.\n It opens the write-consent dialog in the editor, or reports \\`alreadyGranted\\`\n if one already exists. Granting is human-only —\n \\`grant-localhost-write-consent\\` is hidden from agents, so you cannot approve\n it yourself. Tell the user to click \"Allow writes\", then retry\n \\`write-local-file\\` once. Do not keep retrying blindly: the write stays\n blocked until the user approves.\n- Saves are conflict-checked against the file's on-disk version — a file that\n changed since it was read fails with a version conflict instead of being\n overwritten.\n\n## React Source Writeback\n\n- Use compiler/debug provenance (project-relative file, line, column,\n component, and runtime multiplicity) to locate React/TSX source. Treat it as\n evidence, not as permission for a generic AST structural transform.\n- A single-instance leaf text edit, literal \\`className\\`/\\`class\\` edit, or flat\n literal \\`style={{ ... }}\\` property may use \\`apply-visual-edit\\` with a\n \\`local-file\\` source and exact \\`target.sourceAnchor\\`. Preview first (omit\n \\`persist\\`), inspect \\`proposedDiff\\`, then call with \\`persist: true\\`.\n- Reparenting, grouping/ungrouping, wrappers, dynamic expressions, repeated\n \\`.map()\\` instances, shared components, breakpoint-scoped edits, and\n cross-file changes go through the coding agent with exact subject/target\n anchors and their runtime relationship. \\`apply-visual-edit\\` refuses these\n with \\`status: \"needsAgent\"\\` rather than guessing.\n- Before each write, read the file and pass its exact \\`versionHash\\` to\n \\`write-local-file\\` with \\`requireExpectedVersionHash: true\\`; on conflict,\n re-read and re-plan. Keep the optimistic preview until HMR/runtime confirms\n the result. Human write consent remains mandatory and agents cannot grant it.\n\n## Verification\n\n- \\`list-localhost-connections\\` returns the expected connection and routes.\n- The Design editor opens in overview mode.\n- Every requested screen renders the intended localhost URL, showing real app\n content rather than an endless loading spinner.\n- Alt-dragging a screen copies the URL-backed frame, not an inline HTML clone.\n- A query/path edit changes only the target screen's URL metadata and iframe.\n- The Code tab shows a local-files root for the connection and opens its files.\n`;\n"]}
|
|
1
|
+
{"version":3,"file":"design-visual-edit-skill.js","sourceRoot":"","sources":["../../../src/cli/skills-content/design-visual-edit-skill.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,2BAA2B,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+Z1C,CAAC","sourcesContent":["export const DESIGN_VISUAL_EDIT_SKILL_MD = `---\nname: visual-edit\ndescription: >-\n Open a running local app in Design overview mode as URL-backed iframe screens\n for visual editing, flow review, duplication, and route-state exploration.\n Use when the user asks to inspect, compare, or edit a real local app visually\n in Design.\nmetadata:\n visibility: exported\n---\n\n# Visual Edit\n\nUse \\`/visual-edit\\` when the user wants to inspect or edit a real local app\nvisually instead of generating standalone Alpine HTML. The source of truth is\nthe running localhost app plus its route URLs. Design shows those routes as\niframe-backed screens on the infinite canvas.\n\n## Installing this skill for an external MCP host\n\nThe hosted install path\n(\\`npx @agent-native/core@latest skills add visual-edit\\`, or \\`design\\` for the\nfull Design bundle) installs the exported instructions and registers the\nhosted Design MCP connector together. The open Skills CLI path\n(\\`npx skills@latest add BuilderIO/agent-native --skill visual-edit\\`) installs\nexported instructions only, with no MCP connector registration.\n\n## Put Design Beside The Chat\n\nAfter \\`open-visual-edit\\` returns \\`openUrl\\`, open that URL in the coding host's\ninline browser when one is available. This is the preferred working surface:\nthe user can keep Design's canvas beside the conversation, inspect the same\nscreens as the agent, and iterate without switching apps.\n\n- In Codex Desktop, use the in-app Browser tool to open \\`openUrl\\`. The built-in\n browser is the right surface for localhost and public pages that should stay\n inside the app.\n- In Claude Code Desktop's Code tab, open or preview \\`openUrl\\` in the Browser\n pane. Ask Claude to preview it rather than opening the system browser.\n- In VS Code, use the Agent Native Design webview/deep link described below.\n- Inline browser availability is host-dependent. CLI, remote, or restricted\n sessions may not expose one. If the inline surface is unavailable or disabled,\n return the normal **Open design** link instead of claiming it opened.\n\nPrefer the host's browser/preview tool over telling the user to press a keyboard\nshortcut. Keep the canvas pane beside chat when the host supports rearrangeable\npanes.\n\nInside Design, use **Show/Hide UI** from the \\`Cmd+K\\` menu or press\n\\`Cmd+Shift+\\\\\\` on Apple platforms / \\`Ctrl+Shift+\\\\\\` elsewhere to toggle all\nediting chrome so only the canvas remains. The same action is available from\nDesign's empty-canvas context menu.\n\n## Core Model\n\n- Each screen is a URL-backed iframe, not copied HTML.\n- Each screen keeps URL metadata: \\`connectionId\\`, \\`routeId\\`, \\`path\\`,\n \\`url\\`, \\`bridgeUrl\\`, title, and viewport size.\n- Localhost Edit mode renders the running app through the local bridge as a live\n iframe with the same editor bridge used by HTML designs. It is not a frozen\n static DOM snapshot.\n- The live editor is same-origin through the local bridge proxy. This boots\n CSR apps and root-relative assets, but it is still a localhost editing proxy:\n app-origin cookies, WebSockets/HMR, SSE, and non-GET app API calls may need a\n future dev-server/plugin integration for perfect parity with the app's own\n origin.\n- Interact mode renders the app's normal URL so app navigation, scrolling,\n links, and form controls behave as they would in the browser.\n- While a localhost screen has pending live visual edits, do not switch back to\n Interact until the user either applies the edits to source or explicitly\n aborts/discards the preview.\n- Start in Design's screen overview mode. In overview, screens are static\n design frames; full-screen focus is for scrolling and app interaction.\n- Alt-drag duplicates a screen. For localhost screens, duplication copies the\n iframe frame and URL metadata; change the copy's path/query for a new state.\n- Flow visualization is multiple URL states: \\`/checkout?step=shipping\\`,\n \\`/checkout?step=payment\\`, \\`/checkout?step=done\\`, etc.\n- When the user gives a named flow or numbered screen list, preserve that order\n and create one screen per URL/path. Shorthand like\n \\`localhost:1234/onboarding/1\\` means\n \\`http://localhost:1234/onboarding/1\\`.\n\n## Useful Canvas Sets\n\nTranslate the user's requested review into the smallest useful set of frames:\n\n- **Multi-step flow:** one ordered frame per route or query state, such as cart,\n shipping, payment, and confirmation.\n- **Multiple pages:** one frame per meaningful route, such as home, pricing,\n docs, and account settings.\n- **Responsive comparison:** repeat the same route at the requested desktop,\n tablet, and mobile viewports so they align in one row.\n- **State review:** repeat a route for meaningful URL-addressable states such as\n empty, loading, error, modal-open, or selected-item views.\n\nDo not expand every discovered route or every viewport unless the user asks for\nan exhaustive audit. Preserve the user's labels and sequence so the canvas reads\nlike the workflow they described.\n\n## Select And Reprompt\n\nWhen a chat message begins with \\`[Reprompt selection]\\`, the selected subtree is\na hard write boundary. The only mutation path is \\`propose-node-rewrite\\` with\nthe exact \\`repromptId\\`, target, and \\`baseVersionHash\\` captured in\n\\`design-reprompt-pending:<designId>:<fileId>\\`. Never use \\`apply-visual-edit\\`,\n\\`apply-source-edit\\`, \\`write-source\\`, \\`write-local-file\\`, \\`edit-design\\`, or any\nother content-writing action for that request. Clarifying questions are allowed,\nbut a requested change must remain a proposal.\n\nProduce one variant by default. Produce two or three only when the instruction\nasks for options. A retry includes \\`priorProposalId\\`; keep the same target and\nbase version, incorporate the feedback, and call \\`propose-node-rewrite\\` again.\nThe UI previews the returned subtree without persisting it.\n\nUse \\`resolve-node-rewrite\\` for the accept/reject lifecycle. Accept applies the\nchosen variant as one version-checked inline/Yjs content transaction so one\nundo restores the prior structure; reject clears the proposal without changing\ncontent. For conversational resolution such as \"apply the second one,\" call\n\\`view-screen\\`, read the active \\`design.reprompt.proposal\\`, and pass its\n\\`proposalId\\` plus the zero-based \\`variantIndex\\` to \\`resolve-node-rewrite\\`.\n\n## Review Quality\n\n- Treat the running app as the truth. Preserve its component language, tokens,\n route state, and real content unless the user explicitly asks for a new visual\n direction.\n- Use multiple URL states to reveal meaningful UX moments: empty/loading/error\n states, focused panels, modals, responsive breakpoints, and completed flow\n steps when those matter to the review.\n- For visual edits, compare before/after at the relevant viewport sizes and\n check key hover/focus/scroll states when the app exposes them.\n\n## Account And Sharing Model\n\n- The \\`/visual-edit\\` entry route can open before the viewer signs in. Public\n \\`/design/:id\\` editor links can also render read-only public designs without a\n session.\n- Prefer links returned by Design actions or \\`/_agent-native/open\\` deep links.\n Do not surface URLs with \\`_session=\\` tokens. Query sessions are only a\n fallback after normal cookie resolution, so an existing browser session can\n still open the design as a different user and show \"Design not found\".\n- Do not attempt anonymous write actions. Bridge registration, design creation,\n screen placement, generation, saving, and sharing are account-backed. If a\n signed-out visitor wants to save or share, send them through the framework\n sign-in return flow, then save or copy the design into that account before\n opening the share dialog.\n\n## Required Local Bridge\n\nThe live-edit bridge is unlocked by a shared secret (the \"bridge token\") that\nmust match on two sides: the local bridge process, and the user's connection row\nin Design (which the browser reads to authorize \\`/live-edit-bridge\\`,\n\\`/read-file\\`, \\`/write-file\\`). Get them to match by letting the\n**authenticated** \\`open-visual-edit\\` action mint the token, then starting the\nbridge with it. This is the only ordering that works for the remote-MCP flow —\nthe bridge cannot push its own token to the server without a CLI auth token, so\nthe server mints instead and the bridge adopts.\n\nFrom the target app repo, make sure its dev server is running, then:\n\n**1. Discover routes without starting a durable bridge** (one-shot, exits):\n\n\\`\\`\\`bash\nnpx @agent-native/core@latest design connect --url http://localhost:5173 --root . --json\n\\`\\`\\`\n\nThis prints the manifest (routes + capabilities). Parse it to build\n\\`routeManifest\\` for the next step. (Skip this if the user already gave explicit\npaths/URLs to place.)\n\nInside the agent-native monorepo itself, use the workspace CLI instead of\n\\`npx\\` — \\`npx\\` installs the last published \\`@agent-native/core\\`, which will not\ncontain local changes and costs a slow install on every call:\n\n\\`\\`\\`bash\npnpm dev:cli design connect --url http://localhost:5173 --root templates/<app> --json\n\\`\\`\\`\n\n**2. Call \\`open-visual-edit\\`** (see Action Flow below) with NO \\`bridgeToken\\`.\nThe server mints one, stores it on the user's connection row, copies it into the\nplaced screens' metadata, and returns it to you as \\`bridgeToken\\`. Capture it.\n\n**3. Start the persistent bridge adopting that token** (single line; prefer the\nenv var so the secret does not appear in \\`ps\\`):\n\n\\`\\`\\`bash\nAGENT_NATIVE_BRIDGE_TOKEN=\"<bridgeToken from step 2>\" npx @agent-native/core@latest design connect --url http://localhost:5173 --root . --daemon\n\\`\\`\\`\n\n(Equivalently, pass \\`--bridge-token <token>\\`.) This starts a detached bridge on\n\\`http://127.0.0.1:7331\\`, adopts the server-minted token — so bridge and row\nagree and live-edit authorizes with no self-registration — and stays alive after\nthe command exits.\n\nFor a manual health/manifest check on the running bridge:\n\n\\`\\`\\`bash\ncurl http://127.0.0.1:7331/health\n\\`\\`\\`\n\n\\`/health\\` needs no token. The full manifest at \\`/manifest.json\\` is\npreview-token protected, so an unauthenticated \\`curl\\` of it returns\n\\`{\"ok\":false,\"error\":\"invalid or missing preview token\"}\\` — that response means\nthe bridge is up, not that it is broken.\n\nOnly use \\`--json\\` for the step-1 route probe. Never use \\`--json\\`, \\`--once\\`,\nor \\`--dry-run\\` for the durable step-3 bridge: they print the manifest and exit,\nso Design falls back to a non-editable live iframe.\n\nThe bridge listens on a single fixed port (7331) and refuses to start for a\nsecond, different app. It is detached with no log file, so if \\`--daemon\\` reports\na timeout, check for a stale process (\\`lsof -ti:7331\\`) before retrying.\n\n## Action Flow\n\nPrefer the single authenticated \\`open-visual-edit\\` action. It registers or\nrefreshes the localhost bridge connection, mints and stores the bridge token,\ncreates or reuses a Design project, places URL-backed screens, stores the active\nvisual-edit context, and navigates to overview mode in one call. This avoids\ncreating a private design under a synthetic CLI user and then handing the browser\na tokenized URL that may be shadowed by an existing session.\n\nCall it BEFORE starting the durable bridge (step 3 above): it does not contact\nthe bridge, so the bridge need not be running yet, and you need its returned\n\\`bridgeToken\\` to start the bridge with a matching secret. Omit \\`bridgeToken\\`\non the call so the server mints one.\n\n\\`\\`\\`bash\npnpm action open-visual-edit '{\n \"title\": \"Docs homepage visual edit\",\n \"devServerUrl\": \"http://localhost:5173\",\n \"bridgeUrl\": \"http://127.0.0.1:7331\",\n \"rootPath\": \"/absolute/path/to/app\",\n \"routeManifest\": { \"...\": \"from /manifest.json\" },\n \"paths\": [\"/\", \"/pricing\", \"/checkout?step=payment\"]\n}'\n\\`\\`\\`\n\nThe action returns \\`designId\\`, \\`connectionId\\`, \\`bridgeToken\\`, \\`screens\\`,\n\\`urlPath\\`, and \\`openUrl\\`. Keep \\`designId\\`/\\`connectionId\\` in the chat context\nfor follow-ups, and pass \\`bridgeToken\\` to \\`design connect\\` (step 3) to start\nthe bridge. On follow-up calls reusing an existing \\`connectionId\\`, the same\ntoken is returned (it is minted once and reused), so the running bridge stays\nvalid.\n\n### Desktop and mobile side by side\n\nPass \\`viewports\\` to place every requested route once per viewport. Frames lay\nout as a grid: one row per route, one column per viewport. Presets are\n\\`desktop\\` (1280x900), \\`laptop\\` (1440x900), \\`tablet\\` (834x1112), and \\`mobile\\`\n(390x844); an explicit \\`{ \"label\": \"...\", \"width\": N, \"height\": N }\\` also works.\n\n\\`\\`\\`bash\npnpm action open-visual-edit '{\n \"title\": \"Tasks responsive visual edit\",\n \"devServerUrl\": \"http://localhost:5173\",\n \"bridgeUrl\": \"http://127.0.0.1:7331\",\n \"rootPath\": \"/absolute/path/to/app\",\n \"paths\": [\"/tasks\", \"/inbox\"],\n \"viewports\": [\"desktop\", \"mobile\"]\n}'\n\\`\\`\\`\n\nPrefer this over two separate calls with \\`defaultWidth\\`/\\`defaultHeight\\`: it\nkeeps each route's viewports aligned in a row and titles them\n\\`Tasks — Desktop\\` / \\`Tasks — Mobile\\` so the canvas reads clearly. \\`viewports\\`\noverrides \\`defaultWidth\\`/\\`defaultHeight\\`. With no \\`routes\\`/\\`paths\\`, it expands\nevery route in the localhost manifest, which is usually far more frames than\nthe user wants — name the paths.\n\n### Adding more page frames later\n\nCall \\`open-visual-edit\\` again with the same \\`designId\\` and \\`connectionId\\` and\nonly the new paths. Existing frames for the same route and viewport are\nrefreshed in place rather than duplicated, and a frame the user has dragged or\nresized keeps its position unless you explicitly pass \\`x\\`/\\`y\\`/\\`width\\`/\\`height\\`.\n\n\\`\\`\\`bash\npnpm action open-visual-edit '{\n \"designId\": \"<existing-design-id>\",\n \"connectionId\": \"<existing-connection-id>\",\n \"devServerUrl\": \"http://localhost:5173\",\n \"paths\": [\"/settings\", \"/team\"],\n \"startY\": 2200\n}'\n\\`\\`\\`\n\nDo NOT add \\`defaultWidth\\`/\\`defaultHeight\\` just to restate the default size:\nsupplying either one marks the viewport as explicitly requested, which\noverwrites frame sizes the user has already adjusted on the canvas.\n\nFor a numbered flow the user describes in chat, keep the labels and order:\n\n\\`\\`\\`bash\npnpm action open-visual-edit '{\n \"designId\": \"<existing-design-id>\",\n \"connectionId\": \"<existing-connection-id>\",\n \"devServerUrl\": \"http://localhost:1234\",\n \"routes\": [\n { \"url\": \"localhost:1234/onboarding/1\", \"title\": \"Screen 1\" },\n { \"url\": \"localhost:1234/onboarding/2\", \"title\": \"Screen 2\" },\n { \"url\": \"localhost:1234/onboarding/3\", \"title\": \"Screen 3\" }\n ]\n}'\n\\`\\`\\`\n\nIf no \\`routes\\` or \\`paths\\` are supplied, \\`open-visual-edit\\` uses every route\nfrom the localhost manifest.\n\nFallback, only when \\`open-visual-edit\\` is unavailable:\n\n1. Register or refresh the bridge with \\`connect-localhost\\`, passing the\n \\`/manifest.json\\` result as \\`routeManifest\\` and \\`capabilities\\`.\n2. Create or reuse a Design project with \\`create-design\\`.\n3. Place URL-backed screens with \\`add-localhost-screens\\`.\n4. Navigate to overview mode with \\`navigate\\`.\n\n## Open The Design Surface\n\n- Use the \\`link\\`, \\`deepLink\\`, or MCP App embed returned by Design actions so\n the user sees the canvas. Follow **Put Design Beside The Chat**: prefer the\n host's inline Browser, preview, or webview panel; otherwise surface the\n **Open design** link.\n- Return or open the \\`openUrl\\` / action link, not a hand-built\n \\`/design/:id?_session=...\\` URL.\n- If the user is working in VS Code, the Agent Native extension can open the\n same URL via\n \\`vscode://builder.agent-native/open?url=<encoded-design-url>\\`. Its\n \\`Agent Native: Open Design Canvas\\` command also starts the local bridge and\n opens hosted Design in the VS Code side panel.\n- After \\`open-visual-edit\\`, confirm the Design editor is in overview mode\n with the requested URL-backed frames visible, and that they render the app\n rather than a spinner. Do not stop at \"screens added\" when the user asked to\n inspect or edit visually.\n\n## Applying Visual Edits Back To Source\n\nCanvas edits on a localhost screen do not write source as you make them. They\naccumulate as pending edits and the editor shows an \"Apply with Design agent\"\nbutton in the bottom-right corner of the canvas. Clicking it hands a structured\nprompt to the Design agent chat, which performs the real source write.\n\n- Style, text, and drag/drop structure edits all collect into the same pending\n batch, so the user can make several changes and apply once.\n- After the write lands, the target app's own dev-server HMR refreshes the\n frames — no manual reload. If frames do not refresh, the write did not land;\n say so rather than assuming.\n- The separate disk-icon \"Apply to source\" button is the deterministic\n whole-file HTML/CSS writer. It is intentionally disabled for compiled\n \\`.jsx\\`/\\`.tsx\\` routes — those must go through the agent path above.\n\n## Editing URLs\n\nKeep localhost screens as URL files plus \\`screenMetadata[fileId]\\`. Do not\nreplace them with copied \\`srcdoc\\` HTML unless the user explicitly asks for a\nfrozen snapshot. To change a state, rerun \\`open-visual-edit\\` with the new\npath/query or duplicate the screen and update the copy's URL metadata.\n\n## Local Files in the Code Tab\n\nOnce a connection is registered, the design editor's Code panel (left rail →\nCode, or \\`navigate --view editor --designId <id> --leftPanel code\\`) shows a\nlocal-files workspace root for that connection next to the design's own files.\nTreat that root like VS Code opened at the connected project directory: file\ntree, search, open/edit, and save are backed by the real local files. It lists\nthe connected app's text/code files through the bridge\n(\\`list-local-files\\` / \\`read-local-file\\`); build output, \\`node_modules\\`,\n\\`.git\\`, and secret-looking paths (\\`.env*\\`, key files) are always excluded.\n\n- Browsing and reading need only editor access on the design plus the running\n bridge.\n- Saving goes through \\`write-local-file\\`: the first save opens the\n write-consent dialog (an 8-hour, folder-scoped grant) and retries\n automatically once granted. Only text/code files are writable; secret paths\n are always blocked.\n- If the agent calls \\`write-local-file\\` directly (not through a UI save) and it\n fails with \"no write-consent grant\", call \\`request-localhost-write-consent\\`.\n It opens the write-consent dialog in the editor, or reports \\`alreadyGranted\\`\n if one already exists. Granting is human-only —\n \\`grant-localhost-write-consent\\` is hidden from agents, so you cannot approve\n it yourself. Tell the user to click \"Allow writes\", then retry\n \\`write-local-file\\` once. Do not keep retrying blindly: the write stays\n blocked until the user approves.\n- Saves are conflict-checked against the file's on-disk version — a file that\n changed since it was read fails with a version conflict instead of being\n overwritten.\n\n## React Source Writeback\n\n- Use compiler/debug provenance (project-relative file, line, column,\n component, and runtime multiplicity) to locate React/TSX source. Treat it as\n evidence, not as permission for a generic AST structural transform.\n- A single-instance leaf text edit, literal \\`className\\`/\\`class\\` edit, or flat\n literal \\`style={{ ... }}\\` property may use \\`apply-visual-edit\\` with a\n \\`local-file\\` source and exact \\`target.sourceAnchor\\`. Preview first (omit\n \\`persist\\`), inspect \\`proposedDiff\\`, then call with \\`persist: true\\`.\n- Reparenting, grouping/ungrouping, wrappers, dynamic expressions, repeated\n \\`.map()\\` instances, shared components, breakpoint-scoped edits, and\n cross-file changes go through the coding agent with exact subject/target\n anchors and their runtime relationship. \\`apply-visual-edit\\` refuses these\n with \\`status: \"needsAgent\"\\` rather than guessing.\n- Before each write, read the file and pass its exact \\`versionHash\\` to\n \\`write-local-file\\` with \\`requireExpectedVersionHash: true\\`; on conflict,\n re-read and re-plan. Keep the optimistic preview until HMR/runtime confirms\n the result. Human write consent remains mandatory and agents cannot grant it.\n\n## Verification\n\n- \\`list-localhost-connections\\` returns the expected connection and routes.\n- The Design editor opens in overview mode.\n- Every requested screen renders the intended localhost URL, showing real app\n content rather than an endless loading spinner.\n- Alt-dragging a screen copies the URL-backed frame, not an inline HTML clone.\n- A query/path edit changes only the target screen's URL metadata and iframe.\n- The Code tab shows a local-files root for the connection and opens its files.\n`;\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"template-sync.d.ts","sourceRoot":"","sources":["../../src/cli/template-sync.ts"],"names":[],"mappings":"AA0DA,MAAM,WAAW,UAAU;IACzB,GAAG,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IAC/B,GAAG,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;CAChC;AAmBD,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,cAAc,CAAC,EAAE,QAAQ,GAAG,SAAS,GAAG,gBAAgB,CAAC;IACzD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,KAAK,CAAC,EAAE,WAAW,GAAG,YAAY,CAAC;CACpC;AAED,MAAM,WAAW,SAAS;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,WAAW,GAAG,YAAY,CAAC;IAClC,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,UAAU,EAAE,kBAAkB,CAAC;CAChC;AAED,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,6EAA6E;IAC7E,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IACnB,KAAK,EAAE,WAAW,GAAG,YAAY,CAAC;IAClC,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,iBAAiB;IAChC,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,QAAQ,GAAG,SAAS,GAAG,gBAAgB,CAAC;CACjD;AAED,MAAM,WAAW,mBAAmB;IAClC,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,SAAS,EAAE,MAAM,EAAE,CAAC;CACrB;AAMD;;;GAGG;AACH,wBAAsB,mBAAmB,CACvC,IAAI,EAAE,kBAAkB,GACvB,OAAO,CAAC,iBAAiB,CAAC,CAsE5B;AAMD,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAUpD;AAED,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC,CAmB5D;AAED,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,MAAM,EACjB,OAAO,GAAE;IAAE,MAAM,CAAC,EAAE,OAAO,CAAA;CAAO,GACjC,mBAAmB,CAuErB;AA2CD,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,kBAAkB,CAOjE;AAED,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,EAAE,CAkCxE;AAyDD,wBAAsB,WAAW,CAC/B,IAAI,EAAE,MAAM,EAAE,EACd,EAAE,GAAE,UAAsB,GACzB,OAAO,CAAC,MAAM,CAAC,
|
|
1
|
+
{"version":3,"file":"template-sync.d.ts","sourceRoot":"","sources":["../../src/cli/template-sync.ts"],"names":[],"mappings":"AA0DA,MAAM,WAAW,UAAU;IACzB,GAAG,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IAC/B,GAAG,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;CAChC;AAmBD,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,cAAc,CAAC,EAAE,QAAQ,GAAG,SAAS,GAAG,gBAAgB,CAAC;IACzD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,KAAK,CAAC,EAAE,WAAW,GAAG,YAAY,CAAC;CACpC;AAED,MAAM,WAAW,SAAS;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,WAAW,GAAG,YAAY,CAAC;IAClC,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,UAAU,EAAE,kBAAkB,CAAC;CAChC;AAED,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,6EAA6E;IAC7E,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IACnB,KAAK,EAAE,WAAW,GAAG,YAAY,CAAC;IAClC,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,iBAAiB;IAChC,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,QAAQ,GAAG,SAAS,GAAG,gBAAgB,CAAC;CACjD;AAED,MAAM,WAAW,mBAAmB;IAClC,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,SAAS,EAAE,MAAM,EAAE,CAAC;CACrB;AAMD;;;GAGG;AACH,wBAAsB,mBAAmB,CACvC,IAAI,EAAE,kBAAkB,GACvB,OAAO,CAAC,iBAAiB,CAAC,CAsE5B;AAMD,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAUpD;AAED,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC,CAmB5D;AAED,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,MAAM,EACjB,OAAO,GAAE;IAAE,MAAM,CAAC,EAAE,OAAO,CAAA;CAAO,GACjC,mBAAmB,CAuErB;AA2CD,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,kBAAkB,CAOjE;AAED,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,EAAE,CAkCxE;AAyDD,wBAAsB,WAAW,CAC/B,IAAI,EAAE,MAAM,EAAE,EACd,EAAE,GAAE,UAAsB,GACzB,OAAO,CAAC,MAAM,CAAC,CAuDjB"}
|
|
@@ -340,6 +340,17 @@ export async function runTemplate(args, io = defaultIO) {
|
|
|
340
340
|
return command ? 0 : 1;
|
|
341
341
|
}
|
|
342
342
|
const rest = args.slice(1);
|
|
343
|
+
// `materialize` produces a fresh post-processed template tree at --out; it has
|
|
344
|
+
// no existing app to resolve, so it runs before target resolution.
|
|
345
|
+
if (command === "materialize") {
|
|
346
|
+
try {
|
|
347
|
+
return await materializeCommand(rest, io);
|
|
348
|
+
}
|
|
349
|
+
catch (err) {
|
|
350
|
+
io.err(err instanceof Error ? err.message : String(err));
|
|
351
|
+
return 1;
|
|
352
|
+
}
|
|
353
|
+
}
|
|
343
354
|
const appArg = positionalArgs(rest)[0];
|
|
344
355
|
const flags = {
|
|
345
356
|
to: flagValue(rest, "--to"),
|
|
@@ -388,6 +399,80 @@ async function runForTarget(command, target, flags, io) {
|
|
|
388
399
|
return 1;
|
|
389
400
|
}
|
|
390
401
|
}
|
|
402
|
+
/**
|
|
403
|
+
* Write the post-processed template tree to a directory — the pristine,
|
|
404
|
+
* template-derived output `create` would produce (no install/git/skills).
|
|
405
|
+
* `--to` defaults to the local template (walked up from the package); pass a ref
|
|
406
|
+
* to fetch from GitHub instead.
|
|
407
|
+
*/
|
|
408
|
+
async function materializeCommand(rest, io) {
|
|
409
|
+
const outDir = flagValue(rest, "--out");
|
|
410
|
+
const template = flagValue(rest, "--template");
|
|
411
|
+
const name = flagValue(rest, "--name");
|
|
412
|
+
const ref = flagValue(rest, "--to") ?? null;
|
|
413
|
+
if (!outDir) {
|
|
414
|
+
io.err("template materialize requires --out <dir>.");
|
|
415
|
+
return 1;
|
|
416
|
+
}
|
|
417
|
+
if (!template) {
|
|
418
|
+
io.err("template materialize requires --template <name>.");
|
|
419
|
+
return 1;
|
|
420
|
+
}
|
|
421
|
+
// Stage into a unique sibling dir, then swap it in crash-safely: move the old
|
|
422
|
+
// tree aside, move the staged tree in, and restore the old one if that fails.
|
|
423
|
+
// Directory replacement isn't atomic on POSIX (you can't rename onto a non-empty
|
|
424
|
+
// dir), so the old tree is only ever moved — never deleted before the new one is
|
|
425
|
+
// in place — and a crash between the two renames leaves it recoverable under
|
|
426
|
+
// `backup`. Unique same-filesystem siblings keep each rename atomic and
|
|
427
|
+
// collision-free.
|
|
428
|
+
const parent = path.dirname(path.resolve(outDir));
|
|
429
|
+
fs.mkdirSync(parent, { recursive: true });
|
|
430
|
+
const tmp = fs.mkdtempSync(path.join(parent, ".template-materialize-"));
|
|
431
|
+
// `backup` is a unique dir too, so a concurrent process can't occupy the path;
|
|
432
|
+
// renaming a directory onto an existing *empty* dir is a valid replace on POSIX,
|
|
433
|
+
// so the `hadOld` rename below still lands cleanly on it.
|
|
434
|
+
const backup = fs.mkdtempSync(path.join(parent, ".template-materialize-backup-"));
|
|
435
|
+
let backupHoldsOriginal = false;
|
|
436
|
+
try {
|
|
437
|
+
const result = await materializeTemplate({
|
|
438
|
+
appName: name ?? template,
|
|
439
|
+
template,
|
|
440
|
+
ref,
|
|
441
|
+
shape: "standalone",
|
|
442
|
+
destDir: tmp,
|
|
443
|
+
});
|
|
444
|
+
const hadOld = fs.existsSync(outDir);
|
|
445
|
+
if (hadOld) {
|
|
446
|
+
fs.renameSync(outDir, backup);
|
|
447
|
+
backupHoldsOriginal = true;
|
|
448
|
+
}
|
|
449
|
+
try {
|
|
450
|
+
fs.renameSync(tmp, outDir);
|
|
451
|
+
backupHoldsOriginal = false;
|
|
452
|
+
}
|
|
453
|
+
catch (err) {
|
|
454
|
+
if (hadOld) {
|
|
455
|
+
fs.renameSync(backup, outDir);
|
|
456
|
+
backupHoldsOriginal = false;
|
|
457
|
+
}
|
|
458
|
+
throw err;
|
|
459
|
+
}
|
|
460
|
+
io.out(`Materialized "${template}" (${result.source}@${result.ref}) to ${outDir}.`);
|
|
461
|
+
return 0;
|
|
462
|
+
}
|
|
463
|
+
finally {
|
|
464
|
+
fs.rmSync(tmp, { recursive: true, force: true });
|
|
465
|
+
// If restoring from `backup` above itself threw, `backupHoldsOriginal` is still
|
|
466
|
+
// true and `backup` is the only remaining copy of the pre-existing output —
|
|
467
|
+
// leave it on disk instead of deleting the last copy of the user's data.
|
|
468
|
+
if (!backupHoldsOriginal) {
|
|
469
|
+
fs.rmSync(backup, { recursive: true, force: true });
|
|
470
|
+
}
|
|
471
|
+
else {
|
|
472
|
+
io.err(`Failed to restore ${outDir}; the previous contents were preserved at ${backup}.`);
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
}
|
|
391
476
|
function templateName(target, flags) {
|
|
392
477
|
const name = flags.template ?? target.provenance.template;
|
|
393
478
|
if (!name) {
|
|
@@ -777,6 +862,9 @@ function templateUsage() {
|
|
|
777
862
|
" baseline [app] Record a baseline for an app scaffolded before",
|
|
778
863
|
" provenance existed [--ref <ref>] [--template <name>]",
|
|
779
864
|
" accept [app] Advance the baseline after resolving conflicts",
|
|
865
|
+
" materialize --template <name> --out <dir>",
|
|
866
|
+
" Write the post-processed template tree to a dir",
|
|
867
|
+
" (no app needed) [--name <appName>] [--to <ref>]",
|
|
780
868
|
"",
|
|
781
869
|
"With no [app], operates on the current app, or on every app in a workspace",
|
|
782
870
|
"when run from the workspace root. --to defaults to the ref matching the",
|