@agent-native/core 0.79.27 → 0.80.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 +26 -0
- package/corpus/core/docs/content/locales/ar-SA/template-design.mdx +41 -0
- package/corpus/core/docs/content/locales/de-DE/template-design.mdx +51 -0
- package/corpus/core/docs/content/locales/es-ES/template-design.mdx +50 -0
- package/corpus/core/docs/content/locales/fr-FR/template-design.mdx +49 -0
- package/corpus/core/docs/content/locales/hi-IN/template-design.mdx +44 -0
- package/corpus/core/docs/content/locales/ja-JP/template-design.mdx +46 -0
- package/corpus/core/docs/content/locales/ko-KR/template-design.mdx +44 -0
- package/corpus/core/docs/content/locales/pt-BR/template-design.mdx +48 -0
- package/corpus/core/docs/content/locales/zh-CN/template-design.mdx +36 -0
- package/corpus/core/docs/content/locales/zh-TW/template-design.mdx +38 -0
- package/corpus/core/docs/content/template-design.mdx +45 -0
- package/corpus/core/package.json +2 -1
- package/corpus/core/src/agent/engine/index.ts +1 -0
- package/corpus/core/src/agent/engine/registry.ts +40 -0
- package/corpus/core/src/agent/production-agent.ts +6 -2
- package/corpus/core/src/cli/design-connect.ts +490 -0
- package/corpus/core/src/cli/index.ts +16 -0
- package/corpus/core/src/cli/skills.ts +126 -3
- package/corpus/core/src/client/AssistantChat.tsx +43 -7
- package/corpus/core/src/client/agent-chat.ts +27 -3
- package/corpus/core/src/client/blocks/library/MermaidBlock.tsx +1 -1
- package/corpus/core/src/client/blocks/library/diagram.tsx +2 -2
- package/corpus/core/src/client/blocks/library/wireframe.tsx +1 -1
- package/corpus/core/src/client/chat/message-components.tsx +1 -1
- package/corpus/core/src/client/chat-model-groups.ts +1 -2
- package/corpus/core/src/client/components/LiveCursorOverlay.tsx +33 -66
- package/corpus/core/src/client/composer/TiptapComposer.tsx +99 -24
- package/corpus/core/src/client/composer/useVoiceDictation.ts +429 -260
- package/corpus/core/src/client/frame-protocol.ts +17 -2
- package/corpus/core/src/client/rich-markdown-editor/RegistryBlockNode.tsx +2 -2
- package/corpus/core/src/client/sharing/ShareButton.tsx +20 -15
- package/corpus/core/src/client/use-agent-engine-configured.ts +80 -28
- package/corpus/core/src/server/transcribe-voice.ts +57 -22
- package/corpus/core/src/shared/mcp-embed-headers.ts +23 -1
- package/corpus/core/src/styles/agent-native.css +56 -7
- package/corpus/core/src/templates/workspace-core/.agents/skills/voice-transcription/SKILL.md +10 -0
- package/corpus/core/src/vite/client.ts +2 -0
- package/corpus/core/src/voice/index.ts +18 -0
- package/corpus/core/src/voice/voice-cleanup-prompt.ts +38 -0
- package/corpus/core/src/voice/voice-context.ts +217 -0
- package/corpus/core/src/voice/voice-replacements.ts +75 -0
- package/corpus/templates/analytics/AGENTS.md +4 -3
- package/corpus/templates/analytics/actions/list-session-recordings.ts +6 -1
- package/corpus/templates/analytics/app/components/layout/Sidebar.tsx +557 -400
- package/corpus/templates/analytics/app/global.css +0 -4
- package/corpus/templates/analytics/app/i18n/zh-TW.ts +2 -0
- package/corpus/templates/analytics/app/i18n-data.ts +20 -0
- package/corpus/templates/analytics/app/pages/adhoc/sql-dashboard/index.tsx +33 -8
- package/corpus/templates/analytics/app/pages/sessions/SessionDetailPage.tsx +7 -0
- package/corpus/templates/analytics/app/pages/sessions/SessionsPage.tsx +7 -0
- package/corpus/templates/analytics/changelog/2026-06-28-ask-tab-now-matches-the-darker-app-background.md +6 -0
- package/corpus/templates/analytics/changelog/2026-06-28-dashboard-email-reports-now-use-cleaner-light-mode-snapshots.md +6 -0
- package/corpus/templates/analytics/changelog/2026-06-28-left-sidebar-collapses-into-an-animated-icon-rail.md +6 -0
- package/corpus/templates/analytics/changelog/2026-06-28-sessions-now-show-only-signed-in-recordings-with-playable-re.md +6 -0
- package/corpus/templates/analytics/seeds/dashboards/agent-native-templates-first-party.json +3 -3
- package/corpus/templates/analytics/server/lib/dashboard-report.ts +29 -7
- package/corpus/templates/analytics/server/lib/first-party-metric-catalog.ts +5 -2
- package/corpus/templates/analytics/server/lib/session-replay.ts +24 -4
- package/corpus/templates/assets/app/components/layout/Sidebar.tsx +4 -4
- package/corpus/templates/assets/changelog/2026-06-28-left-sidebar-collapse-motion-and-footer-chrome-are-quieter.md +6 -0
- package/corpus/templates/brain/app/components/layout/Layout.tsx +29 -2
- package/corpus/templates/brain/app/components/layout/Sidebar.tsx +131 -42
- package/corpus/templates/brain/app/i18n/zh-TW.ts +2 -0
- package/corpus/templates/brain/app/i18n-data.ts +20 -0
- package/corpus/templates/brain/changelog/2026-06-28-left-sidebar-collapses-into-an-animated-icon-rail.md +6 -0
- package/corpus/templates/calendar/app/components/layout/AppLayout.tsx +29 -1
- package/corpus/templates/calendar/app/components/layout/Sidebar.tsx +417 -299
- package/corpus/templates/calendar/app/i18n/zh-TW.ts +2 -0
- package/corpus/templates/calendar/app/i18n-data.ts +20 -0
- package/corpus/templates/calendar/changelog/2026-06-28-left-sidebar-collapses-into-an-animated-icon-rail.md +6 -0
- package/corpus/templates/chat/app/components/layout/Sidebar.tsx +6 -19
- package/corpus/templates/chat/changelog/2026-06-28-left-sidebar-collapse-motion-and-footer-chrome-are-quieter.md +6 -0
- package/corpus/templates/clips/AGENTS.md +4 -0
- package/corpus/templates/clips/actions/cleanup-transcript.ts +39 -9
- package/corpus/templates/clips/actions/finalize-meeting.ts +81 -12
- package/corpus/templates/clips/actions/lib/agents-md-context.ts +4 -1
- package/corpus/templates/clips/app/components/library/library-layout.tsx +3 -3
- package/corpus/templates/clips/app/components/meetings/share-meeting-dialog.tsx +1 -1
- package/corpus/templates/clips/app/components/player/share-dialog.tsx +2 -2
- package/corpus/templates/clips/changelog/2026-06-28-left-sidebar-footer-controls-use-less-divider-chrome.md +6 -0
- package/corpus/templates/clips/desktop/src/lib/personal-vocabulary.ts +13 -8
- package/corpus/templates/clips/desktop/src/lib/voice-dictation.ts +60 -1
- package/corpus/templates/content/app/components/editor/DocumentDatabase.tsx +1 -1
- package/corpus/templates/content/app/components/editor/database/DatabaseView.tsx +1 -1
- package/corpus/templates/content/app/components/sidebar/DocumentSidebar.tsx +5 -5
- package/corpus/templates/content/changelog/2026-06-28-left-sidebar-collapse-motion-and-footer-chrome-are-quieter.md +6 -0
- package/corpus/templates/design/.agents/skills/visual-edit/SKILL.md +137 -0
- package/corpus/templates/design/AGENTS.md +95 -5
- package/corpus/templates/design/DESIGN.md +82 -0
- package/corpus/templates/design/DEVELOPING.md +43 -0
- package/corpus/templates/design/actions/add-localhost-screens.ts +426 -0
- package/corpus/templates/design/actions/apply-shader.ts +277 -0
- package/corpus/templates/design/actions/apply-visual-edit.ts +303 -0
- package/corpus/templates/design/actions/connect-localhost.ts +183 -0
- package/corpus/templates/design/actions/edit-design.ts +195 -42
- package/corpus/templates/design/actions/generate-design.ts +71 -1
- package/corpus/templates/design/actions/generate-screens.ts +193 -0
- package/corpus/templates/design/actions/get-code-layer-projection.ts +191 -0
- package/corpus/templates/design/actions/get-shader.ts +119 -0
- package/corpus/templates/design/actions/list-localhost-connections.ts +95 -0
- package/corpus/templates/design/actions/navigate.ts +55 -2
- package/corpus/templates/design/actions/view-screen.ts +68 -1
- package/corpus/templates/design/agent-native.app-skill.json +10 -0
- package/corpus/templates/design/app/components/design/CanvasContextMenu.tsx +761 -0
- package/corpus/templates/design/app/components/design/DesignCanvas.tsx +2057 -103
- package/corpus/templates/design/app/components/design/DesignEditorSkeleton.tsx +74 -38
- package/corpus/templates/design/app/components/design/DesignExtensionsPanel.tsx +399 -0
- package/corpus/templates/design/app/components/design/EditPanel.tsx +3185 -439
- package/corpus/templates/design/app/components/design/LayersPanel.tsx +1124 -0
- package/corpus/templates/design/app/components/design/MultiScreenCanvas.tsx +3116 -147
- package/corpus/templates/design/app/components/design/QuestionFlow.tsx +700 -13
- package/corpus/templates/design/app/components/design/TweaksPanel.tsx +107 -63
- package/corpus/templates/design/app/components/design/index.ts +0 -5
- package/corpus/templates/design/app/components/design/inspector/AlignmentMatrix.tsx +286 -0
- package/corpus/templates/design/app/components/design/inspector/AutoLayoutMatrix.tsx +699 -0
- package/corpus/templates/design/app/components/design/inspector/ConstraintsWidget.tsx +461 -0
- package/corpus/templates/design/app/components/design/inspector/ExportSettingsPanel.tsx +166 -0
- package/corpus/templates/design/app/components/design/inspector/FigmaColorPicker.tsx +1420 -0
- package/corpus/templates/design/app/components/design/inspector/SHADER_INTEGRATION.md +420 -0
- package/corpus/templates/design/app/components/design/inspector/ScrubInput.tsx +215 -0
- package/corpus/templates/design/app/components/design/inspector/ShaderControls.stories.tsx +71 -0
- package/corpus/templates/design/app/components/design/inspector/ShaderControls.tsx +518 -0
- package/corpus/templates/design/app/components/design/inspector/ShaderEffectRow.tsx +106 -0
- package/corpus/templates/design/app/components/design/inspector/figma-icons.tsx +361 -0
- package/corpus/templates/design/app/components/design/inspector/index.ts +60 -0
- package/corpus/templates/design/app/components/design/inspector/scrub-input-utils.ts +201 -0
- package/corpus/templates/design/app/components/design/types.ts +23 -0
- package/corpus/templates/design/app/components/layout/Layout.tsx +24 -13
- package/corpus/templates/design/app/components/layout/Sidebar.tsx +4 -4
- package/corpus/templates/design/app/components/visual-editor/CanvasCommentPins.tsx +474 -36
- package/corpus/templates/design/app/components/visual-editor/DrawOverlay.tsx +22 -5
- package/corpus/templates/design/app/components/visual-editor/SaveStatusIndicator.tsx +24 -11
- package/corpus/templates/design/app/global.css +121 -3
- package/corpus/templates/design/app/hooks/use-agent-generating.ts +4 -0
- package/corpus/templates/design/app/hooks/use-navigation-state.ts +130 -8
- package/corpus/templates/design/app/hooks/useDesignHotkeys.ts +329 -0
- package/corpus/templates/design/app/i18n/zh-TW.ts +264 -0
- package/corpus/templates/design/app/i18n-data.ts +2790 -1
- package/corpus/templates/design/app/pages/DesignEditor.tsx +5108 -851
- package/corpus/templates/design/changelog/2026-06-28-annotate-mode-now-combines-drawing-and-comment-pins-in-one-c.md +6 -0
- package/corpus/templates/design/changelog/2026-06-28-design-editor-panel-borders-are-cleaner-so-the-canvas-edge-s.md +6 -0
- package/corpus/templates/design/changelog/2026-06-28-drawing-prompts-now-reliably-open-and-submit-to-the-design-a.md +6 -0
- package/corpus/templates/design/changelog/2026-06-28-editor-app-menus-now-use-an-outline-agent-native-mark-with-b.md +6 -0
- package/corpus/templates/design/changelog/2026-06-28-figma-style-code-design-mode.md +6 -0
- package/corpus/templates/design/changelog/2026-06-28-layer-selection-now-updates-chat-context-without-opening-the.md +6 -0
- package/corpus/templates/design/changelog/2026-06-28-layer-selections-now-preserve-hidden-and-locked-canvas-state.md +6 -0
- package/corpus/templates/design/changelog/2026-06-28-left-sidebar-collapse-motion-and-footer-chrome-are-quieter.md +6 -0
- package/corpus/templates/design/changelog/2026-06-28-live-cursors-now-keep-names-beside-a-cleaner-pointer-marker.md +6 -0
- package/corpus/templates/design/changelog/2026-06-28-mode-switching-now-lives-in-a-compact-bottom-right-icon-dock.md +6 -0
- package/corpus/templates/design/changelog/2026-06-28-screen-overview-now-handles-zooming-drawing-opening-and-dele.md +6 -0
- package/corpus/templates/design/changelog/2026-06-28-screen-overview-now-selects-screens-on-click-and-opens-them-.md +6 -0
- package/corpus/templates/design/changelog/2026-06-28-screen-overview-zooms-into-the-active-screen-with-smoother-e.md +6 -0
- package/corpus/templates/design/changelog/2026-06-28-selected-element-chips-in-chat-are-shorter-and-easier-to-sca.md +6 -0
- package/corpus/templates/design/changelog/2026-06-28-the-design-editor-toolbar-is-more-compact-and-the-app-menu-m.md +6 -0
- package/corpus/templates/design/changelog/2026-06-28-tweaks-now-live-at-the-top-of-the-design-sidebar-instead-of-.md +6 -0
- package/corpus/templates/design/changelog/2026-06-28-tweaks-now-live-in-the-right-inspector-beside-the-design-tab.md +6 -0
- package/corpus/templates/design/changelog/2026-06-29-active-sidebar-rows-use-soft-highlights.md +6 -0
- package/corpus/templates/design/changelog/2026-06-29-agents-can-now-open-screen-overview-focus-screens-and-add.md +6 -0
- package/corpus/templates/design/changelog/2026-06-29-design-agents-now-edit-broad-copy-changes-more-reliably.md +6 -0
- package/corpus/templates/design/changelog/2026-06-29-design-editor-extensions-now-run-inline-beside-the-artboard.md +6 -0
- package/corpus/templates/design/changelog/2026-06-29-sidebars-use-darker-chrome-and-chat-warns-immediately.md +6 -0
- package/corpus/templates/design/changelog/2026-06-29-visual-edit-can-open-localhost-routes-as-url-backed-screens.md +6 -0
- package/corpus/templates/design/package.json +1 -0
- package/corpus/templates/design/server/db/schema.ts +26 -0
- package/corpus/templates/design/server/lib/design-snapshot.ts +1 -1
- package/corpus/templates/design/server/plugins/agent-chat.ts +3 -0
- package/corpus/templates/design/shared/api.ts +27 -0
- package/corpus/templates/design/shared/canvas-frames.ts +103 -0
- package/corpus/templates/design/shared/canvas-math.ts +1058 -0
- package/corpus/templates/design/shared/code-layer.ts +2212 -0
- package/corpus/templates/design/shared/color-utils.ts +180 -0
- package/corpus/templates/design/shared/generation-session.ts +61 -0
- package/corpus/templates/design/shared/shader-presets.ts +782 -0
- package/corpus/templates/design/shared/shader-safety.ts +137 -0
- package/corpus/templates/design/shared/source-mode.ts +237 -0
- package/corpus/templates/forms/app/components/layout/Sidebar.tsx +149 -6
- package/corpus/templates/forms/app/i18n/ar-SA.ts +2 -0
- package/corpus/templates/forms/app/i18n/de-DE.ts +2 -0
- package/corpus/templates/forms/app/i18n/en-US.ts +2 -0
- package/corpus/templates/forms/app/i18n/es-ES.ts +2 -0
- package/corpus/templates/forms/app/i18n/fr-FR.ts +2 -0
- package/corpus/templates/forms/app/i18n/hi-IN.ts +2 -0
- package/corpus/templates/forms/app/i18n/ja-JP.ts +2 -0
- package/corpus/templates/forms/app/i18n/ko-KR.ts +2 -0
- package/corpus/templates/forms/app/i18n/pt-BR.ts +2 -0
- package/corpus/templates/forms/app/i18n/zh-CN.ts +2 -0
- package/corpus/templates/forms/app/i18n/zh-TW.ts +2 -0
- package/corpus/templates/forms/changelog/2026-06-28-left-sidebar-collapses-into-an-animated-icon-rail.md +6 -0
- package/corpus/templates/macros/app/components/layout/AppLayout.tsx +2 -2
- package/corpus/templates/macros/changelog/2026-06-28-left-sidebar-footer-controls-use-less-divider-chrome.md +6 -0
- package/corpus/templates/mail/app/components/layout/AppLayout.tsx +408 -247
- package/corpus/templates/mail/app/i18n/ar-SA.ts +4 -0
- package/corpus/templates/mail/app/i18n/de-DE.ts +4 -0
- package/corpus/templates/mail/app/i18n/en-US.ts +4 -0
- package/corpus/templates/mail/app/i18n/es-ES.ts +4 -0
- package/corpus/templates/mail/app/i18n/fr-FR.ts +4 -0
- package/corpus/templates/mail/app/i18n/hi-IN.ts +4 -0
- package/corpus/templates/mail/app/i18n/ja-JP.ts +4 -0
- package/corpus/templates/mail/app/i18n/ko-KR.ts +4 -0
- package/corpus/templates/mail/app/i18n/pt-BR.ts +4 -0
- package/corpus/templates/mail/app/i18n/zh-CN.ts +4 -0
- package/corpus/templates/mail/app/i18n/zh-TW.ts +4 -0
- package/corpus/templates/mail/changelog/2026-06-28-pinned-sidebar-collapses-into-an-animated-icon-rail.md +6 -0
- package/corpus/templates/plan/app/components/layout/Sidebar.tsx +6 -8
- package/corpus/templates/plan/app/components/plan/wireframe/Wireframe.tsx +1 -1
- package/corpus/templates/plan/app/global.css +61 -78
- package/corpus/templates/plan/app/pages/PlansPage.tsx +8 -0
- package/corpus/templates/plan/changelog/2026-06-28-left-sidebar-collapse-motion-and-footer-chrome-are-quieter.md +6 -0
- package/corpus/templates/plan/changelog/2026-06-28-plans-use-the-shared-neutral-light-and-dark-theme.md +6 -0
- package/corpus/templates/plan/changelog/2026-06-28-sending-open-feedback-from-a-plan-now-opens-the-inline-plan-.md +6 -0
- package/corpus/templates/slides/app/components/layout/Sidebar.tsx +5 -5
- package/corpus/templates/slides/changelog/2026-06-28-left-sidebar-collapse-motion-and-footer-chrome-are-quieter.md +6 -0
- package/corpus/templates/videos/app/components/Sidebar.tsx +2 -2
- package/corpus/templates/videos/app/components/layout/Layout.tsx +29 -2
- package/corpus/templates/videos/app/components/layout/NavSidebar.tsx +113 -30
- package/corpus/templates/videos/app/i18n/ar-SA.ts +2 -0
- package/corpus/templates/videos/app/i18n/de-DE.ts +2 -0
- package/corpus/templates/videos/app/i18n/en-US.ts +2 -0
- package/corpus/templates/videos/app/i18n/es-ES.ts +2 -0
- package/corpus/templates/videos/app/i18n/fr-FR.ts +2 -0
- package/corpus/templates/videos/app/i18n/hi-IN.ts +2 -0
- package/corpus/templates/videos/app/i18n/ja-JP.ts +2 -0
- package/corpus/templates/videos/app/i18n/ko-KR.ts +2 -0
- package/corpus/templates/videos/app/i18n/pt-BR.ts +2 -0
- package/corpus/templates/videos/app/i18n/zh-CN.ts +2 -0
- package/corpus/templates/videos/app/i18n/zh-TW.ts +2 -0
- package/corpus/templates/videos/changelog/2026-06-28-left-sidebar-collapses-into-an-animated-icon-rail.md +6 -0
- package/dist/agent/engine/index.d.ts +1 -1
- package/dist/agent/engine/index.d.ts.map +1 -1
- package/dist/agent/engine/index.js +1 -1
- package/dist/agent/engine/index.js.map +1 -1
- package/dist/agent/engine/registry.d.ts +9 -0
- package/dist/agent/engine/registry.d.ts.map +1 -1
- package/dist/agent/engine/registry.js +37 -0
- package/dist/agent/engine/registry.js.map +1 -1
- package/dist/agent/production-agent.d.ts.map +1 -1
- package/dist/agent/production-agent.js +4 -3
- package/dist/agent/production-agent.js.map +1 -1
- package/dist/cli/design-connect.d.ts +52 -0
- package/dist/cli/design-connect.d.ts.map +1 -0
- package/dist/cli/design-connect.js +409 -0
- package/dist/cli/design-connect.js.map +1 -0
- package/dist/cli/index.js +15 -0
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/skills.d.ts +3 -0
- package/dist/cli/skills.d.ts.map +1 -1
- package/dist/cli/skills.js +121 -3
- package/dist/cli/skills.js.map +1 -1
- package/dist/client/AssistantChat.d.ts.map +1 -1
- package/dist/client/AssistantChat.js +38 -8
- package/dist/client/AssistantChat.js.map +1 -1
- package/dist/client/agent-chat.d.ts +6 -0
- package/dist/client/agent-chat.d.ts.map +1 -1
- package/dist/client/agent-chat.js +17 -3
- package/dist/client/agent-chat.js.map +1 -1
- package/dist/client/blocks/library/MermaidBlock.js +1 -1
- package/dist/client/blocks/library/MermaidBlock.js.map +1 -1
- package/dist/client/blocks/library/diagram.js +1 -1
- package/dist/client/blocks/library/diagram.js.map +1 -1
- package/dist/client/blocks/library/wireframe.js +1 -1
- package/dist/client/blocks/library/wireframe.js.map +1 -1
- package/dist/client/chat/message-components.js +1 -1
- package/dist/client/chat/message-components.js.map +1 -1
- package/dist/client/chat-model-groups.d.ts.map +1 -1
- package/dist/client/chat-model-groups.js +1 -2
- package/dist/client/chat-model-groups.js.map +1 -1
- package/dist/client/components/LiveCursorOverlay.d.ts +1 -2
- package/dist/client/components/LiveCursorOverlay.d.ts.map +1 -1
- package/dist/client/components/LiveCursorOverlay.js +19 -40
- package/dist/client/components/LiveCursorOverlay.js.map +1 -1
- package/dist/client/composer/TiptapComposer.d.ts +3 -1
- package/dist/client/composer/TiptapComposer.d.ts.map +1 -1
- package/dist/client/composer/TiptapComposer.js +86 -24
- package/dist/client/composer/TiptapComposer.js.map +1 -1
- package/dist/client/composer/useVoiceDictation.d.ts +9 -0
- package/dist/client/composer/useVoiceDictation.d.ts.map +1 -1
- package/dist/client/composer/useVoiceDictation.js +154 -32
- package/dist/client/composer/useVoiceDictation.js.map +1 -1
- package/dist/client/frame-protocol.d.ts +17 -2
- package/dist/client/frame-protocol.d.ts.map +1 -1
- package/dist/client/frame-protocol.js.map +1 -1
- package/dist/client/rich-markdown-editor/RegistryBlockNode.js +2 -2
- package/dist/client/rich-markdown-editor/RegistryBlockNode.js.map +1 -1
- package/dist/client/sharing/ShareButton.d.ts +2 -0
- package/dist/client/sharing/ShareButton.d.ts.map +1 -1
- package/dist/client/sharing/ShareButton.js +7 -6
- package/dist/client/sharing/ShareButton.js.map +1 -1
- package/dist/client/use-agent-engine-configured.d.ts +5 -0
- package/dist/client/use-agent-engine-configured.d.ts.map +1 -1
- package/dist/client/use-agent-engine-configured.js +51 -25
- package/dist/client/use-agent-engine-configured.js.map +1 -1
- package/dist/collab/awareness.d.ts +2 -2
- package/dist/collab/awareness.d.ts.map +1 -1
- package/dist/collab/routes.d.ts +1 -1
- package/dist/file-upload/actions/upload-image.d.ts +2 -2
- package/dist/notifications/routes.d.ts +3 -3
- package/dist/observability/routes.d.ts +8 -8
- package/dist/progress/routes.d.ts +1 -1
- package/dist/server/agent-engine-api-key-route.d.ts +1 -1
- package/dist/server/transcribe-voice.d.ts.map +1 -1
- package/dist/server/transcribe-voice.js +40 -24
- package/dist/server/transcribe-voice.js.map +1 -1
- package/dist/shared/mcp-embed-headers.d.ts +1 -0
- package/dist/shared/mcp-embed-headers.d.ts.map +1 -1
- package/dist/shared/mcp-embed-headers.js +20 -1
- package/dist/shared/mcp-embed-headers.js.map +1 -1
- package/dist/styles/agent-native.css +56 -7
- package/dist/templates/workspace-core/.agents/skills/voice-transcription/SKILL.md +10 -0
- package/dist/vite/client.d.ts.map +1 -1
- package/dist/vite/client.js +2 -0
- package/dist/vite/client.js.map +1 -1
- package/dist/voice/index.d.ts +5 -0
- package/dist/voice/index.d.ts.map +1 -0
- package/dist/voice/index.js +4 -0
- package/dist/voice/index.js.map +1 -0
- package/dist/voice/voice-cleanup-prompt.d.ts +6 -0
- package/dist/voice/voice-cleanup-prompt.d.ts.map +1 -0
- package/dist/voice/voice-cleanup-prompt.js +26 -0
- package/dist/voice/voice-cleanup-prompt.js.map +1 -0
- package/dist/voice/voice-context.d.ts +25 -0
- package/dist/voice/voice-context.d.ts.map +1 -0
- package/dist/voice/voice-context.js +156 -0
- package/dist/voice/voice-context.js.map +1 -0
- package/dist/voice/voice-replacements.d.ts +4 -0
- package/dist/voice/voice-replacements.d.ts.map +1 -0
- package/dist/voice/voice-replacements.js +52 -0
- package/dist/voice/voice-replacements.js.map +1 -0
- package/docs/content/locales/ar-SA/template-design.mdx +41 -0
- package/docs/content/locales/de-DE/template-design.mdx +51 -0
- package/docs/content/locales/es-ES/template-design.mdx +50 -0
- package/docs/content/locales/fr-FR/template-design.mdx +49 -0
- package/docs/content/locales/hi-IN/template-design.mdx +44 -0
- package/docs/content/locales/ja-JP/template-design.mdx +46 -0
- package/docs/content/locales/ko-KR/template-design.mdx +44 -0
- package/docs/content/locales/pt-BR/template-design.mdx +48 -0
- package/docs/content/locales/zh-CN/template-design.mdx +36 -0
- package/docs/content/locales/zh-TW/template-design.mdx +38 -0
- package/docs/content/template-design.mdx +45 -0
- package/package.json +2 -1
- package/src/templates/workspace-core/.agents/skills/voice-transcription/SKILL.md +10 -0
- package/corpus/templates/design/app/components/design/DesignToolbar.tsx +0 -339
- package/corpus/templates/design/app/components/design/PresentMode.tsx +0 -68
- package/corpus/templates/design/app/components/design/ViewportTabs.tsx +0 -149
- package/corpus/templates/design/app/components/design/ZoomControls.tsx +0 -157
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { type Server } from "node:http";
|
|
2
|
+
declare const BRIDGE_OPERATIONS: readonly ["select", "resolveNodeToFile", "readFile", "applyEdit", "writeFile", "captureSnapshot", "captureState"];
|
|
3
|
+
type BridgeOperation = (typeof BRIDGE_OPERATIONS)[number];
|
|
4
|
+
export interface DesignConnectArgs {
|
|
5
|
+
url?: string;
|
|
6
|
+
port: number;
|
|
7
|
+
root: string;
|
|
8
|
+
routeManifest?: string;
|
|
9
|
+
json: boolean;
|
|
10
|
+
once: boolean;
|
|
11
|
+
dryRun: boolean;
|
|
12
|
+
help: boolean;
|
|
13
|
+
}
|
|
14
|
+
export interface DesignConnectRoute {
|
|
15
|
+
id: string;
|
|
16
|
+
path: string;
|
|
17
|
+
title: string;
|
|
18
|
+
sourceFile?: string;
|
|
19
|
+
sourceKind: "react-router" | "html" | "manual";
|
|
20
|
+
}
|
|
21
|
+
export interface DesignConnectManifest {
|
|
22
|
+
version: 1;
|
|
23
|
+
source: "agent-native-design-connect";
|
|
24
|
+
sourceType: "localhost";
|
|
25
|
+
localOnly: true;
|
|
26
|
+
devServerUrl: string;
|
|
27
|
+
bridgeUrl: string;
|
|
28
|
+
rootPath: string;
|
|
29
|
+
routeManifestPath: string;
|
|
30
|
+
routeManifestCreated: boolean;
|
|
31
|
+
routes: DesignConnectRoute[];
|
|
32
|
+
routeCount: number;
|
|
33
|
+
generatedAt: string;
|
|
34
|
+
capabilities: Array<{
|
|
35
|
+
operation: BridgeOperation;
|
|
36
|
+
status: "available" | "planned" | "disabled";
|
|
37
|
+
reason?: string;
|
|
38
|
+
}>;
|
|
39
|
+
}
|
|
40
|
+
export interface DesignConnectBridge {
|
|
41
|
+
server: Server;
|
|
42
|
+
manifest: DesignConnectManifest;
|
|
43
|
+
}
|
|
44
|
+
export declare function parseDesignConnectArgs(argv: string[]): DesignConnectArgs;
|
|
45
|
+
export declare function discoverDesignRoutes(root: string): DesignConnectRoute[];
|
|
46
|
+
export declare function prepareDesignConnectManifest(options?: Partial<DesignConnectArgs> & {
|
|
47
|
+
root?: string;
|
|
48
|
+
}): Promise<DesignConnectManifest>;
|
|
49
|
+
export declare function startDesignConnectBridge(manifest: DesignConnectManifest): Promise<DesignConnectBridge>;
|
|
50
|
+
export declare function runDesign(argv: string[]): Promise<number>;
|
|
51
|
+
export {};
|
|
52
|
+
//# sourceMappingURL=design-connect.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"design-connect.d.ts","sourceRoot":"","sources":["../../src/cli/design-connect.ts"],"names":[],"mappings":"AAEA,OAAa,EAEX,KAAK,MAAM,EAEZ,MAAM,WAAW,CAAC;AAcnB,QAAA,MAAM,iBAAiB,YACrB,QAAQ,EACR,mBAAmB,EACnB,UAAU,EACV,WAAW,EACX,WAAW,EACX,iBAAiB,EACjB,cAAc,CACN,CAAC;AAEX,KAAK,eAAe,GAAG,CAAC,OAAO,iBAAiB,CAAC,CAAC,MAAM,CAAC,CAAC;AAE1D,MAAM,WAAW,iBAAiB;IAChC,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IAC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AE,OAAO,CAAC,iBAAiB,CAAC,GAAG;IAAE,IAAI,CAAC,EAAE,MAAM,CAAA;CAAO,GAC3D,OAAO,CAAC,qBAAqB,CAAC,CA0ChC;AAiBD,wBAAsB,wBAAwB,CAC5C,QAAQ,EAAE,qBAAqB,GAC9B,OAAO,CAAC,mBAAmB,CAAC,CAwC9B;AAgBD,wBAAsB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,mBA0C7C"}
|
|
@@ -0,0 +1,409 @@
|
|
|
1
|
+
import fsSync from "node:fs";
|
|
2
|
+
import fs from "node:fs/promises";
|
|
3
|
+
import http from "node:http";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
const DEFAULT_BRIDGE_PORT = 7331;
|
|
6
|
+
const ROUTE_MANIFEST_FILE = path.join(".agent-native", "design-routes.json");
|
|
7
|
+
const DEFAULT_DEV_SERVER_CANDIDATES = [
|
|
8
|
+
"http://127.0.0.1:5173",
|
|
9
|
+
"http://localhost:5173",
|
|
10
|
+
"http://127.0.0.1:3000",
|
|
11
|
+
"http://localhost:3000",
|
|
12
|
+
"http://127.0.0.1:8080",
|
|
13
|
+
"http://localhost:8080",
|
|
14
|
+
];
|
|
15
|
+
const BRIDGE_OPERATIONS = [
|
|
16
|
+
"select",
|
|
17
|
+
"resolveNodeToFile",
|
|
18
|
+
"readFile",
|
|
19
|
+
"applyEdit",
|
|
20
|
+
"writeFile",
|
|
21
|
+
"captureSnapshot",
|
|
22
|
+
"captureState",
|
|
23
|
+
];
|
|
24
|
+
function stringFlagValue(argv, index, flag) {
|
|
25
|
+
const value = argv[index + 1];
|
|
26
|
+
if (!value || value.startsWith("-")) {
|
|
27
|
+
throw new Error(`${flag} requires a value`);
|
|
28
|
+
}
|
|
29
|
+
return value;
|
|
30
|
+
}
|
|
31
|
+
function normalizeSlash(value) {
|
|
32
|
+
return value.replace(/\\/g, "/");
|
|
33
|
+
}
|
|
34
|
+
function normalizeHttpUrl(value) {
|
|
35
|
+
const raw = value.trim();
|
|
36
|
+
const withProtocol = /^[a-z]+:\/\//i.test(raw) ? raw : `http://${raw}`;
|
|
37
|
+
const parsed = new URL(withProtocol);
|
|
38
|
+
if (parsed.protocol !== "http:" && parsed.protocol !== "https:") {
|
|
39
|
+
throw new Error("--url must be an http(s) URL");
|
|
40
|
+
}
|
|
41
|
+
parsed.hash = "";
|
|
42
|
+
return parsed.toString().replace(/\/$/, "");
|
|
43
|
+
}
|
|
44
|
+
export function parseDesignConnectArgs(argv) {
|
|
45
|
+
const args = argv[0] === "connect" ? argv.slice(1) : argv;
|
|
46
|
+
const parsed = {
|
|
47
|
+
port: DEFAULT_BRIDGE_PORT,
|
|
48
|
+
root: process.cwd(),
|
|
49
|
+
json: false,
|
|
50
|
+
once: false,
|
|
51
|
+
dryRun: false,
|
|
52
|
+
help: false,
|
|
53
|
+
};
|
|
54
|
+
for (let index = 0; index < args.length; index += 1) {
|
|
55
|
+
const arg = args[index];
|
|
56
|
+
if (arg === "help" || arg === "--help" || arg === "-h") {
|
|
57
|
+
parsed.help = true;
|
|
58
|
+
}
|
|
59
|
+
else if (arg === "--url") {
|
|
60
|
+
parsed.url = stringFlagValue(args, index, arg);
|
|
61
|
+
index += 1;
|
|
62
|
+
}
|
|
63
|
+
else if (arg.startsWith("--url=")) {
|
|
64
|
+
parsed.url = arg.slice("--url=".length);
|
|
65
|
+
}
|
|
66
|
+
else if (arg === "--port") {
|
|
67
|
+
parsed.port = Number.parseInt(stringFlagValue(args, index, arg), 10);
|
|
68
|
+
index += 1;
|
|
69
|
+
}
|
|
70
|
+
else if (arg.startsWith("--port=")) {
|
|
71
|
+
parsed.port = Number.parseInt(arg.slice("--port=".length), 10);
|
|
72
|
+
}
|
|
73
|
+
else if (arg === "--root") {
|
|
74
|
+
parsed.root = stringFlagValue(args, index, arg);
|
|
75
|
+
index += 1;
|
|
76
|
+
}
|
|
77
|
+
else if (arg.startsWith("--root=")) {
|
|
78
|
+
parsed.root = arg.slice("--root=".length);
|
|
79
|
+
}
|
|
80
|
+
else if (arg === "--route-manifest") {
|
|
81
|
+
parsed.routeManifest = stringFlagValue(args, index, arg);
|
|
82
|
+
index += 1;
|
|
83
|
+
}
|
|
84
|
+
else if (arg.startsWith("--route-manifest=")) {
|
|
85
|
+
parsed.routeManifest = arg.slice("--route-manifest=".length);
|
|
86
|
+
}
|
|
87
|
+
else if (arg === "--json") {
|
|
88
|
+
parsed.json = true;
|
|
89
|
+
parsed.once = true;
|
|
90
|
+
}
|
|
91
|
+
else if (arg === "--once") {
|
|
92
|
+
parsed.once = true;
|
|
93
|
+
}
|
|
94
|
+
else if (arg === "--dry-run") {
|
|
95
|
+
parsed.dryRun = true;
|
|
96
|
+
parsed.once = true;
|
|
97
|
+
}
|
|
98
|
+
else if (arg.startsWith("-")) {
|
|
99
|
+
throw new Error(`Unknown option: ${arg}`);
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
throw new Error(`Unexpected argument: ${arg}`);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
if (!Number.isInteger(parsed.port) || parsed.port <= 0) {
|
|
106
|
+
throw new Error("--port must be a positive integer");
|
|
107
|
+
}
|
|
108
|
+
parsed.root = path.resolve(parsed.root);
|
|
109
|
+
parsed.url = parsed.url ? normalizeHttpUrl(parsed.url) : undefined;
|
|
110
|
+
return parsed;
|
|
111
|
+
}
|
|
112
|
+
function routeId(routePath) {
|
|
113
|
+
if (routePath === "/")
|
|
114
|
+
return "route-root";
|
|
115
|
+
const slug = routePath
|
|
116
|
+
.replace(/^\/+/, "")
|
|
117
|
+
.replace(/[^a-zA-Z0-9]+/g, "-")
|
|
118
|
+
.replace(/^-+|-+$/g, "")
|
|
119
|
+
.toLowerCase();
|
|
120
|
+
return slug ? `route-${slug}` : "route-wildcard";
|
|
121
|
+
}
|
|
122
|
+
function titleFromRoutePath(routePath) {
|
|
123
|
+
if (routePath === "/")
|
|
124
|
+
return "Home";
|
|
125
|
+
if (routePath === "/*" || routePath === "*")
|
|
126
|
+
return "Wildcard";
|
|
127
|
+
return (routePath
|
|
128
|
+
.replace(/^\/+/, "")
|
|
129
|
+
.replace(/[:$]/g, "")
|
|
130
|
+
.replace(/[-_/]+/g, " ")
|
|
131
|
+
.replace(/\s+/g, " ")
|
|
132
|
+
.trim()
|
|
133
|
+
.replace(/\b\w/g, (char) => char.toUpperCase()) || "Screen");
|
|
134
|
+
}
|
|
135
|
+
function walkFiles(dir, files = []) {
|
|
136
|
+
if (!fsSync.existsSync(dir))
|
|
137
|
+
return files;
|
|
138
|
+
for (const entry of fsSync.readdirSync(dir, { withFileTypes: true })) {
|
|
139
|
+
if (entry.name === "node_modules" || entry.name === ".git")
|
|
140
|
+
continue;
|
|
141
|
+
const absolute = path.join(dir, entry.name);
|
|
142
|
+
if (entry.isDirectory()) {
|
|
143
|
+
walkFiles(absolute, files);
|
|
144
|
+
}
|
|
145
|
+
else {
|
|
146
|
+
files.push(absolute);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
return files;
|
|
150
|
+
}
|
|
151
|
+
function routePathFromReactRouterFile(filePath, routesDir) {
|
|
152
|
+
const withoutExt = normalizeSlash(path.relative(routesDir, filePath)).replace(/\.[cm]?[jt]sx?$/, "");
|
|
153
|
+
const parts = [];
|
|
154
|
+
for (const segment of withoutExt.split("/")) {
|
|
155
|
+
for (const token of segment.split(".")) {
|
|
156
|
+
if (!token || token === "route" || token === "index")
|
|
157
|
+
continue;
|
|
158
|
+
if (token === "_index")
|
|
159
|
+
continue;
|
|
160
|
+
if (token.startsWith("_"))
|
|
161
|
+
continue;
|
|
162
|
+
const pathToken = token.endsWith("_") ? token.slice(0, -1) : token;
|
|
163
|
+
if (pathToken === "$") {
|
|
164
|
+
parts.push("*");
|
|
165
|
+
}
|
|
166
|
+
else if (pathToken.startsWith("$")) {
|
|
167
|
+
const param = pathToken.slice(1) || "param";
|
|
168
|
+
parts.push(`:${param}`);
|
|
169
|
+
}
|
|
170
|
+
else {
|
|
171
|
+
parts.push(pathToken);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
return `/${parts.join("/")}`.replace(/\/+/g, "/");
|
|
176
|
+
}
|
|
177
|
+
export function discoverDesignRoutes(root) {
|
|
178
|
+
const absoluteRoot = path.resolve(root);
|
|
179
|
+
const routeDirs = [
|
|
180
|
+
path.join(absoluteRoot, "app", "routes"),
|
|
181
|
+
path.join(absoluteRoot, "src", "routes"),
|
|
182
|
+
path.join(absoluteRoot, "pages"),
|
|
183
|
+
].filter((dir) => fsSync.existsSync(dir));
|
|
184
|
+
const routes = new Map();
|
|
185
|
+
for (const routeDir of routeDirs) {
|
|
186
|
+
for (const file of walkFiles(routeDir)) {
|
|
187
|
+
if (!/\.[cm]?[jt]sx?$/.test(file))
|
|
188
|
+
continue;
|
|
189
|
+
if (/\.test\.|\.spec\./.test(file))
|
|
190
|
+
continue;
|
|
191
|
+
const pathName = routePathFromReactRouterFile(file, routeDir);
|
|
192
|
+
routes.set(pathName, {
|
|
193
|
+
id: routeId(pathName),
|
|
194
|
+
path: pathName,
|
|
195
|
+
title: titleFromRoutePath(pathName),
|
|
196
|
+
sourceFile: normalizeSlash(path.relative(absoluteRoot, file)),
|
|
197
|
+
sourceKind: "react-router",
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
if (routes.size === 0) {
|
|
202
|
+
for (const dir of [absoluteRoot, path.join(absoluteRoot, "public")]) {
|
|
203
|
+
for (const file of walkFiles(dir)) {
|
|
204
|
+
if (!file.endsWith(".html"))
|
|
205
|
+
continue;
|
|
206
|
+
const rel = normalizeSlash(path.relative(dir, file));
|
|
207
|
+
const pathName = rel === "index.html" ? "/" : `/${rel.replace(/\.html$/, "")}`;
|
|
208
|
+
routes.set(pathName, {
|
|
209
|
+
id: routeId(pathName),
|
|
210
|
+
path: pathName,
|
|
211
|
+
title: titleFromRoutePath(pathName),
|
|
212
|
+
sourceFile: normalizeSlash(path.relative(absoluteRoot, file)),
|
|
213
|
+
sourceKind: "html",
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
return [...routes.values()].sort((a, b) => {
|
|
219
|
+
if (a.path === "/")
|
|
220
|
+
return -1;
|
|
221
|
+
if (b.path === "/")
|
|
222
|
+
return 1;
|
|
223
|
+
return a.path.localeCompare(b.path);
|
|
224
|
+
});
|
|
225
|
+
}
|
|
226
|
+
async function probeDevServer(url) {
|
|
227
|
+
const controller = new AbortController();
|
|
228
|
+
const timeout = setTimeout(() => controller.abort(), 800);
|
|
229
|
+
try {
|
|
230
|
+
const response = await fetch(url, {
|
|
231
|
+
method: "GET",
|
|
232
|
+
signal: controller.signal,
|
|
233
|
+
});
|
|
234
|
+
return response.status < 500;
|
|
235
|
+
}
|
|
236
|
+
catch {
|
|
237
|
+
return false;
|
|
238
|
+
}
|
|
239
|
+
finally {
|
|
240
|
+
clearTimeout(timeout);
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
async function resolveDevServerUrl(url) {
|
|
244
|
+
if (url)
|
|
245
|
+
return normalizeHttpUrl(url);
|
|
246
|
+
for (const candidate of DEFAULT_DEV_SERVER_CANDIDATES) {
|
|
247
|
+
if (await probeDevServer(candidate))
|
|
248
|
+
return candidate;
|
|
249
|
+
}
|
|
250
|
+
return DEFAULT_DEV_SERVER_CANDIDATES[0];
|
|
251
|
+
}
|
|
252
|
+
async function ensureRouteManifest(options) {
|
|
253
|
+
const manifestPath = path.isAbsolute(options.routeManifestPath)
|
|
254
|
+
? options.routeManifestPath
|
|
255
|
+
: path.join(options.root, options.routeManifestPath);
|
|
256
|
+
if (fsSync.existsSync(manifestPath)) {
|
|
257
|
+
return { path: manifestPath, created: false };
|
|
258
|
+
}
|
|
259
|
+
if (!options.dryRun) {
|
|
260
|
+
await fs.mkdir(path.dirname(manifestPath), { recursive: true });
|
|
261
|
+
await fs.writeFile(manifestPath, `${JSON.stringify({
|
|
262
|
+
version: 1,
|
|
263
|
+
sourceType: "localhost",
|
|
264
|
+
devServerUrl: options.devServerUrl,
|
|
265
|
+
rootPath: options.root,
|
|
266
|
+
routes: options.routes,
|
|
267
|
+
generatedAt: new Date().toISOString(),
|
|
268
|
+
}, null, 2)}\n`, "utf8");
|
|
269
|
+
}
|
|
270
|
+
return { path: manifestPath, created: !options.dryRun };
|
|
271
|
+
}
|
|
272
|
+
export async function prepareDesignConnectManifest(options = {}) {
|
|
273
|
+
const root = path.resolve(options.root ?? process.cwd());
|
|
274
|
+
const port = options.port ?? DEFAULT_BRIDGE_PORT;
|
|
275
|
+
const devServerUrl = await resolveDevServerUrl(options.url);
|
|
276
|
+
const bridgeUrl = `http://127.0.0.1:${port}`;
|
|
277
|
+
const routes = discoverDesignRoutes(root);
|
|
278
|
+
const routeManifest = await ensureRouteManifest({
|
|
279
|
+
root,
|
|
280
|
+
routeManifestPath: options.routeManifest ?? ROUTE_MANIFEST_FILE,
|
|
281
|
+
routes,
|
|
282
|
+
devServerUrl,
|
|
283
|
+
dryRun: Boolean(options.dryRun),
|
|
284
|
+
});
|
|
285
|
+
const generatedAt = new Date().toISOString();
|
|
286
|
+
return {
|
|
287
|
+
version: 1,
|
|
288
|
+
source: "agent-native-design-connect",
|
|
289
|
+
sourceType: "localhost",
|
|
290
|
+
localOnly: true,
|
|
291
|
+
devServerUrl,
|
|
292
|
+
bridgeUrl,
|
|
293
|
+
rootPath: root,
|
|
294
|
+
routeManifestPath: routeManifest.path,
|
|
295
|
+
routeManifestCreated: routeManifest.created,
|
|
296
|
+
routes,
|
|
297
|
+
routeCount: routes.length,
|
|
298
|
+
generatedAt,
|
|
299
|
+
capabilities: BRIDGE_OPERATIONS.map((operation) => ({
|
|
300
|
+
operation,
|
|
301
|
+
status: operation === "readFile" ||
|
|
302
|
+
operation === "applyEdit" ||
|
|
303
|
+
operation === "writeFile"
|
|
304
|
+
? "planned"
|
|
305
|
+
: "available",
|
|
306
|
+
reason: operation === "writeFile"
|
|
307
|
+
? "The bridge advertises the contract before enabling local file writes."
|
|
308
|
+
: undefined,
|
|
309
|
+
})),
|
|
310
|
+
};
|
|
311
|
+
}
|
|
312
|
+
function sendJson(res, statusCode, body) {
|
|
313
|
+
res.writeHead(statusCode, {
|
|
314
|
+
"content-type": "application/json; charset=utf-8",
|
|
315
|
+
"access-control-allow-origin": "*",
|
|
316
|
+
"access-control-allow-methods": "GET, OPTIONS",
|
|
317
|
+
"access-control-allow-headers": "content-type",
|
|
318
|
+
"access-control-allow-private-network": "true",
|
|
319
|
+
});
|
|
320
|
+
res.end(`${JSON.stringify(body, null, 2)}\n`);
|
|
321
|
+
}
|
|
322
|
+
export async function startDesignConnectBridge(manifest) {
|
|
323
|
+
const server = http.createServer((req, res) => {
|
|
324
|
+
if (req.method === "OPTIONS") {
|
|
325
|
+
sendJson(res, 204, {});
|
|
326
|
+
return;
|
|
327
|
+
}
|
|
328
|
+
const pathname = new URL(req.url ?? "/", manifest.bridgeUrl).pathname;
|
|
329
|
+
if (pathname === "/" || pathname === "/manifest.json") {
|
|
330
|
+
sendJson(res, 200, manifest);
|
|
331
|
+
return;
|
|
332
|
+
}
|
|
333
|
+
if (pathname === "/routes.json") {
|
|
334
|
+
sendJson(res, 200, {
|
|
335
|
+
version: 1,
|
|
336
|
+
sourceType: "localhost",
|
|
337
|
+
devServerUrl: manifest.devServerUrl,
|
|
338
|
+
rootPath: manifest.rootPath,
|
|
339
|
+
routes: manifest.routes,
|
|
340
|
+
generatedAt: manifest.generatedAt,
|
|
341
|
+
});
|
|
342
|
+
return;
|
|
343
|
+
}
|
|
344
|
+
if (pathname === "/health") {
|
|
345
|
+
sendJson(res, 200, { ok: true, source: manifest.source });
|
|
346
|
+
return;
|
|
347
|
+
}
|
|
348
|
+
sendJson(res, 404, { ok: false, error: "not found" });
|
|
349
|
+
});
|
|
350
|
+
await new Promise((resolve, reject) => {
|
|
351
|
+
server.once("error", reject);
|
|
352
|
+
server.listen(new URL(manifest.bridgeUrl).port, "127.0.0.1", () => {
|
|
353
|
+
server.off("error", reject);
|
|
354
|
+
resolve();
|
|
355
|
+
});
|
|
356
|
+
});
|
|
357
|
+
return { server, manifest };
|
|
358
|
+
}
|
|
359
|
+
function printHelp() {
|
|
360
|
+
console.log(`Usage:
|
|
361
|
+
agent-native design connect [options]
|
|
362
|
+
|
|
363
|
+
Options:
|
|
364
|
+
--url <url> Dev server URL to inspect (auto-detected if omitted)
|
|
365
|
+
--port <number> Local bridge port (default ${DEFAULT_BRIDGE_PORT})
|
|
366
|
+
--root <path> App/repo root for route discovery (default cwd)
|
|
367
|
+
--route-manifest <path> Non-destructive route manifest output path
|
|
368
|
+
--json Print the manifest JSON and exit
|
|
369
|
+
--once Prepare/scaffold the manifest and exit
|
|
370
|
+
--dry-run Print what would be exposed without writing files`);
|
|
371
|
+
}
|
|
372
|
+
export async function runDesign(argv) {
|
|
373
|
+
const subcommand = argv[0];
|
|
374
|
+
if (subcommand !== "connect") {
|
|
375
|
+
if (subcommand === "help" ||
|
|
376
|
+
subcommand === "--help" ||
|
|
377
|
+
subcommand === "-h") {
|
|
378
|
+
printHelp();
|
|
379
|
+
return 0;
|
|
380
|
+
}
|
|
381
|
+
console.error("Usage: agent-native design connect [options]");
|
|
382
|
+
return 1;
|
|
383
|
+
}
|
|
384
|
+
const parsed = parseDesignConnectArgs(argv);
|
|
385
|
+
if (parsed.help) {
|
|
386
|
+
printHelp();
|
|
387
|
+
return 0;
|
|
388
|
+
}
|
|
389
|
+
const manifest = await prepareDesignConnectManifest(parsed);
|
|
390
|
+
if (parsed.json || parsed.once || parsed.dryRun) {
|
|
391
|
+
console.log(JSON.stringify(manifest, null, 2));
|
|
392
|
+
return 0;
|
|
393
|
+
}
|
|
394
|
+
const bridge = await startDesignConnectBridge(manifest);
|
|
395
|
+
console.error("Design localhost bridge running");
|
|
396
|
+
console.error(`Bridge: ${manifest.bridgeUrl}`);
|
|
397
|
+
console.error(`Manifest: ${manifest.bridgeUrl}/manifest.json`);
|
|
398
|
+
console.error(`Routes: ${manifest.routeCount}`);
|
|
399
|
+
console.error(`Dev URL: ${manifest.devServerUrl}`);
|
|
400
|
+
return await new Promise((resolve) => {
|
|
401
|
+
const stop = () => {
|
|
402
|
+
bridge.server.close(() => resolve(0));
|
|
403
|
+
};
|
|
404
|
+
for (const signal of ["SIGINT", "SIGTERM", "SIGHUP"]) {
|
|
405
|
+
process.once(signal, stop);
|
|
406
|
+
}
|
|
407
|
+
});
|
|
408
|
+
}
|
|
409
|
+
//# sourceMappingURL=design-connect.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"design-connect.js","sourceRoot":"","sources":["../../src/cli/design-connect.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,SAAS,CAAC;AAC7B,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAClC,OAAO,IAIN,MAAM,WAAW,CAAC;AACnB,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,MAAM,mBAAmB,GAAG,IAAI,CAAC;AACjC,MAAM,mBAAmB,GAAG,IAAI,CAAC,IAAI,CAAC,eAAe,EAAE,oBAAoB,CAAC,CAAC;AAC7E,MAAM,6BAA6B,GAAG;IACpC,uBAAuB;IACvB,uBAAuB;IACvB,uBAAuB;IACvB,uBAAuB;IACvB,uBAAuB;IACvB,uBAAuB;CACxB,CAAC;AAEF,MAAM,iBAAiB,GAAG;IACxB,QAAQ;IACR,mBAAmB;IACnB,UAAU;IACV,WAAW;IACX,WAAW;IACX,iBAAiB;IACjB,cAAc;CACN,CAAC;AAgDX,SAAS,eAAe,CAAC,IAAc,EAAE,KAAa,EAAE,IAAY;IAClE,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC;IAC9B,IAAI,CAAC,KAAK,IAAI,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;QACpC,MAAM,IAAI,KAAK,CAAC,GAAG,IAAI,mBAAmB,CAAC,CAAC;IAC9C,CAAC;IACD,OAAO,KAAK,CAAC;AACf,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\n} from \"node:http\";\nimport path from \"node:path\";\n\nconst DEFAULT_BRIDGE_PORT = 7331;\nconst ROUTE_MANIFEST_FILE = path.join(\".agent-native\", \"design-routes.json\");\nconst DEFAULT_DEV_SERVER_CANDIDATES = [\n \"http://127.0.0.1:5173\",\n \"http://localhost:5173\",\n \"http://127.0.0.1:3000\",\n \"http://localhost:3000\",\n \"http://127.0.0.1:8080\",\n \"http://localhost:8080\",\n];\n\nconst BRIDGE_OPERATIONS = [\n \"select\",\n \"resolveNodeToFile\",\n \"readFile\",\n \"applyEdit\",\n \"writeFile\",\n \"captureSnapshot\",\n \"captureState\",\n] as const;\n\ntype BridgeOperation = (typeof BRIDGE_OPERATIONS)[number];\n\nexport interface DesignConnectArgs {\n url?: string;\n port: number;\n root: string;\n routeManifest?: string;\n json: boolean;\n once: boolean;\n dryRun: boolean;\n help: boolean;\n}\n\nexport interface DesignConnectRoute {\n id: string;\n path: string;\n title: string;\n sourceFile?: string;\n sourceKind: \"react-router\" | \"html\" | \"manual\";\n}\n\nexport interface DesignConnectManifest {\n version: 1;\n source: \"agent-native-design-connect\";\n sourceType: \"localhost\";\n localOnly: true;\n devServerUrl: string;\n bridgeUrl: string;\n rootPath: string;\n routeManifestPath: string;\n routeManifestCreated: boolean;\n routes: DesignConnectRoute[];\n routeCount: number;\n generatedAt: string;\n capabilities: Array<{\n operation: BridgeOperation;\n status: \"available\" | \"planned\" | \"disabled\";\n reason?: string;\n }>;\n}\n\nexport interface DesignConnectBridge {\n server: Server;\n manifest: DesignConnectManifest;\n}\n\nfunction stringFlagValue(argv: string[], index: number, flag: string) {\n const value = argv[index + 1];\n if (!value || value.startsWith(\"-\")) {\n throw new Error(`${flag} requires a value`);\n }\n return value;\n}\n\nfunction normalizeSlash(value: string) {\n return value.replace(/\\\\/g, \"/\");\n}\n\nfunction normalizeHttpUrl(value: string): string {\n const raw = value.trim();\n const withProtocol = /^[a-z]+:\\/\\//i.test(raw) ? raw : `http://${raw}`;\n const parsed = new URL(withProtocol);\n if (parsed.protocol !== \"http:\" && parsed.protocol !== \"https:\") {\n throw new Error(\"--url must be an http(s) URL\");\n }\n parsed.hash = \"\";\n return parsed.toString().replace(/\\/$/, \"\");\n}\n\nexport function parseDesignConnectArgs(argv: string[]): DesignConnectArgs {\n const args = argv[0] === \"connect\" ? argv.slice(1) : argv;\n const parsed: DesignConnectArgs = {\n port: DEFAULT_BRIDGE_PORT,\n root: process.cwd(),\n json: false,\n once: false,\n dryRun: false,\n help: false,\n };\n\n for (let index = 0; index < args.length; index += 1) {\n const arg = args[index]!;\n if (arg === \"help\" || arg === \"--help\" || arg === \"-h\") {\n parsed.help = true;\n } else if (arg === \"--url\") {\n parsed.url = stringFlagValue(args, index, arg);\n index += 1;\n } else if (arg.startsWith(\"--url=\")) {\n parsed.url = arg.slice(\"--url=\".length);\n } else if (arg === \"--port\") {\n parsed.port = Number.parseInt(stringFlagValue(args, index, arg), 10);\n index += 1;\n } else if (arg.startsWith(\"--port=\")) {\n parsed.port = Number.parseInt(arg.slice(\"--port=\".length), 10);\n } else if (arg === \"--root\") {\n parsed.root = stringFlagValue(args, index, arg);\n index += 1;\n } else if (arg.startsWith(\"--root=\")) {\n parsed.root = arg.slice(\"--root=\".length);\n } else if (arg === \"--route-manifest\") {\n parsed.routeManifest = stringFlagValue(args, index, arg);\n index += 1;\n } else if (arg.startsWith(\"--route-manifest=\")) {\n parsed.routeManifest = arg.slice(\"--route-manifest=\".length);\n } else if (arg === \"--json\") {\n parsed.json = true;\n parsed.once = true;\n } else if (arg === \"--once\") {\n parsed.once = true;\n } else if (arg === \"--dry-run\") {\n parsed.dryRun = true;\n parsed.once = true;\n } else if (arg.startsWith(\"-\")) {\n throw new Error(`Unknown option: ${arg}`);\n } else {\n throw new Error(`Unexpected argument: ${arg}`);\n }\n }\n\n if (!Number.isInteger(parsed.port) || parsed.port <= 0) {\n throw new Error(\"--port must be a positive integer\");\n }\n parsed.root = path.resolve(parsed.root);\n parsed.url = parsed.url ? normalizeHttpUrl(parsed.url) : undefined;\n return parsed;\n}\n\nfunction routeId(routePath: string): string {\n if (routePath === \"/\") return \"route-root\";\n const slug = routePath\n .replace(/^\\/+/, \"\")\n .replace(/[^a-zA-Z0-9]+/g, \"-\")\n .replace(/^-+|-+$/g, \"\")\n .toLowerCase();\n return slug ? `route-${slug}` : \"route-wildcard\";\n}\n\nfunction titleFromRoutePath(routePath: string): string {\n if (routePath === \"/\") return \"Home\";\n if (routePath === \"/*\" || routePath === \"*\") return \"Wildcard\";\n return (\n routePath\n .replace(/^\\/+/, \"\")\n .replace(/[:$]/g, \"\")\n .replace(/[-_/]+/g, \" \")\n .replace(/\\s+/g, \" \")\n .trim()\n .replace(/\\b\\w/g, (char) => char.toUpperCase()) || \"Screen\"\n );\n}\n\nfunction walkFiles(dir: string, files: string[] = []): string[] {\n if (!fsSync.existsSync(dir)) return files;\n for (const entry of fsSync.readdirSync(dir, { withFileTypes: true })) {\n if (entry.name === \"node_modules\" || entry.name === \".git\") continue;\n const absolute = path.join(dir, entry.name);\n if (entry.isDirectory()) {\n walkFiles(absolute, files);\n } else {\n files.push(absolute);\n }\n }\n return files;\n}\n\nfunction routePathFromReactRouterFile(filePath: string, routesDir: string) {\n const withoutExt = normalizeSlash(path.relative(routesDir, filePath)).replace(\n /\\.[cm]?[jt]sx?$/,\n \"\",\n );\n const parts: string[] = [];\n for (const segment of withoutExt.split(\"/\")) {\n for (const token of segment.split(\".\")) {\n if (!token || token === \"route\" || token === \"index\") continue;\n if (token === \"_index\") continue;\n if (token.startsWith(\"_\")) continue;\n const pathToken = token.endsWith(\"_\") ? token.slice(0, -1) : token;\n if (pathToken === \"$\") {\n parts.push(\"*\");\n } else if (pathToken.startsWith(\"$\")) {\n const param = pathToken.slice(1) || \"param\";\n parts.push(`:${param}`);\n } else {\n parts.push(pathToken);\n }\n }\n }\n return `/${parts.join(\"/\")}`.replace(/\\/+/g, \"/\");\n}\n\nexport function discoverDesignRoutes(root: string): DesignConnectRoute[] {\n const absoluteRoot = path.resolve(root);\n const routeDirs = [\n path.join(absoluteRoot, \"app\", \"routes\"),\n path.join(absoluteRoot, \"src\", \"routes\"),\n path.join(absoluteRoot, \"pages\"),\n ].filter((dir) => fsSync.existsSync(dir));\n const routes = new Map<string, DesignConnectRoute>();\n\n for (const routeDir of routeDirs) {\n for (const file of walkFiles(routeDir)) {\n if (!/\\.[cm]?[jt]sx?$/.test(file)) continue;\n if (/\\.test\\.|\\.spec\\./.test(file)) continue;\n const pathName = routePathFromReactRouterFile(file, routeDir);\n routes.set(pathName, {\n id: routeId(pathName),\n path: pathName,\n title: titleFromRoutePath(pathName),\n sourceFile: normalizeSlash(path.relative(absoluteRoot, file)),\n sourceKind: \"react-router\",\n });\n }\n }\n\n if (routes.size === 0) {\n for (const dir of [absoluteRoot, path.join(absoluteRoot, \"public\")]) {\n for (const file of walkFiles(dir)) {\n if (!file.endsWith(\".html\")) continue;\n const rel = normalizeSlash(path.relative(dir, file));\n const pathName =\n rel === \"index.html\" ? \"/\" : `/${rel.replace(/\\.html$/, \"\")}`;\n routes.set(pathName, {\n id: routeId(pathName),\n path: pathName,\n title: titleFromRoutePath(pathName),\n sourceFile: normalizeSlash(path.relative(absoluteRoot, file)),\n sourceKind: \"html\",\n });\n }\n }\n }\n\n return [...routes.values()].sort((a, b) => {\n if (a.path === \"/\") return -1;\n if (b.path === \"/\") return 1;\n return a.path.localeCompare(b.path);\n });\n}\n\nasync function probeDevServer(url: string): Promise<boolean> {\n const controller = new AbortController();\n const timeout = setTimeout(() => controller.abort(), 800);\n try {\n const response = await fetch(url, {\n method: \"GET\",\n signal: controller.signal,\n });\n return response.status < 500;\n } catch {\n return false;\n } finally {\n clearTimeout(timeout);\n }\n}\n\nasync function resolveDevServerUrl(url?: string): Promise<string> {\n if (url) return normalizeHttpUrl(url);\n for (const candidate of DEFAULT_DEV_SERVER_CANDIDATES) {\n if (await probeDevServer(candidate)) return candidate;\n }\n return DEFAULT_DEV_SERVER_CANDIDATES[0]!;\n}\n\nasync function ensureRouteManifest(options: {\n root: string;\n routeManifestPath: string;\n routes: DesignConnectRoute[];\n devServerUrl: string;\n dryRun: boolean;\n}): Promise<{ path: string; created: boolean }> {\n const manifestPath = path.isAbsolute(options.routeManifestPath)\n ? options.routeManifestPath\n : path.join(options.root, options.routeManifestPath);\n if (fsSync.existsSync(manifestPath)) {\n return { path: manifestPath, created: false };\n }\n if (!options.dryRun) {\n await fs.mkdir(path.dirname(manifestPath), { recursive: true });\n await fs.writeFile(\n manifestPath,\n `${JSON.stringify(\n {\n version: 1,\n sourceType: \"localhost\",\n devServerUrl: options.devServerUrl,\n rootPath: options.root,\n routes: options.routes,\n generatedAt: new Date().toISOString(),\n },\n null,\n 2,\n )}\\n`,\n \"utf8\",\n );\n }\n return { path: manifestPath, created: !options.dryRun };\n}\n\nexport async function prepareDesignConnectManifest(\n options: Partial<DesignConnectArgs> & { root?: string } = {},\n): Promise<DesignConnectManifest> {\n const root = path.resolve(options.root ?? process.cwd());\n const port = options.port ?? DEFAULT_BRIDGE_PORT;\n const devServerUrl = await resolveDevServerUrl(options.url);\n const bridgeUrl = `http://127.0.0.1:${port}`;\n const routes = discoverDesignRoutes(root);\n const routeManifest = await ensureRouteManifest({\n root,\n routeManifestPath: options.routeManifest ?? ROUTE_MANIFEST_FILE,\n routes,\n devServerUrl,\n dryRun: Boolean(options.dryRun),\n });\n const generatedAt = new Date().toISOString();\n\n return {\n version: 1,\n source: \"agent-native-design-connect\",\n sourceType: \"localhost\",\n localOnly: true,\n devServerUrl,\n bridgeUrl,\n rootPath: root,\n routeManifestPath: routeManifest.path,\n routeManifestCreated: routeManifest.created,\n routes,\n routeCount: routes.length,\n generatedAt,\n capabilities: BRIDGE_OPERATIONS.map((operation) => ({\n operation,\n status:\n operation === \"readFile\" ||\n operation === \"applyEdit\" ||\n operation === \"writeFile\"\n ? \"planned\"\n : \"available\",\n reason:\n operation === \"writeFile\"\n ? \"The bridge advertises the contract before enabling local file writes.\"\n : undefined,\n })),\n };\n}\n\nfunction sendJson(\n res: ServerResponse,\n statusCode: number,\n body: Record<string, unknown>,\n) {\n res.writeHead(statusCode, {\n \"content-type\": \"application/json; charset=utf-8\",\n \"access-control-allow-origin\": \"*\",\n \"access-control-allow-methods\": \"GET, OPTIONS\",\n \"access-control-allow-headers\": \"content-type\",\n \"access-control-allow-private-network\": \"true\",\n });\n res.end(`${JSON.stringify(body, null, 2)}\\n`);\n}\n\nexport async function startDesignConnectBridge(\n manifest: DesignConnectManifest,\n): Promise<DesignConnectBridge> {\n const server = http.createServer(\n (req: IncomingMessage, res: ServerResponse) => {\n if (req.method === \"OPTIONS\") {\n sendJson(res, 204, {});\n return;\n }\n const pathname = new URL(req.url ?? \"/\", manifest.bridgeUrl).pathname;\n if (pathname === \"/\" || pathname === \"/manifest.json\") {\n sendJson(res, 200, manifest as unknown as Record<string, unknown>);\n return;\n }\n if (pathname === \"/routes.json\") {\n sendJson(res, 200, {\n version: 1,\n sourceType: \"localhost\",\n devServerUrl: manifest.devServerUrl,\n rootPath: manifest.rootPath,\n routes: manifest.routes,\n generatedAt: manifest.generatedAt,\n });\n return;\n }\n if (pathname === \"/health\") {\n sendJson(res, 200, { ok: true, source: manifest.source });\n return;\n }\n sendJson(res, 404, { ok: false, error: \"not found\" });\n },\n );\n\n await new Promise<void>((resolve, reject) => {\n server.once(\"error\", reject);\n server.listen(new URL(manifest.bridgeUrl).port, \"127.0.0.1\", () => {\n server.off(\"error\", reject);\n resolve();\n });\n });\n\n return { server, manifest };\n}\n\nfunction printHelp() {\n console.log(`Usage:\n agent-native design connect [options]\n\nOptions:\n --url <url> Dev server URL to inspect (auto-detected if omitted)\n --port <number> Local bridge port (default ${DEFAULT_BRIDGE_PORT})\n --root <path> App/repo root for route discovery (default cwd)\n --route-manifest <path> Non-destructive route manifest output path\n --json Print the manifest JSON and exit\n --once Prepare/scaffold the manifest and exit\n --dry-run Print what would be exposed without writing files`);\n}\n\nexport async function runDesign(argv: string[]) {\n const subcommand = argv[0];\n if (subcommand !== \"connect\") {\n if (\n subcommand === \"help\" ||\n subcommand === \"--help\" ||\n subcommand === \"-h\"\n ) {\n printHelp();\n return 0;\n }\n console.error(\"Usage: agent-native design connect [options]\");\n return 1;\n }\n\n const parsed = parseDesignConnectArgs(argv);\n if (parsed.help) {\n printHelp();\n return 0;\n }\n\n const manifest = await prepareDesignConnectManifest(parsed);\n if (parsed.json || parsed.once || parsed.dryRun) {\n console.log(JSON.stringify(manifest, null, 2));\n return 0;\n }\n\n const bridge = await startDesignConnectBridge(manifest);\n console.error(\"Design localhost bridge running\");\n console.error(`Bridge: ${manifest.bridgeUrl}`);\n console.error(`Manifest: ${manifest.bridgeUrl}/manifest.json`);\n console.error(`Routes: ${manifest.routeCount}`);\n console.error(`Dev URL: ${manifest.devServerUrl}`);\n\n return await new Promise<number>((resolve) => {\n const stop = () => {\n bridge.server.close(() => resolve(0));\n };\n for (const signal of [\"SIGINT\", \"SIGTERM\", \"SIGHUP\"] as const) {\n process.once(signal, stop);\n }\n });\n}\n"]}
|
package/dist/cli/index.js
CHANGED
|
@@ -651,6 +651,18 @@ switch (command) {
|
|
|
651
651
|
});
|
|
652
652
|
break;
|
|
653
653
|
}
|
|
654
|
+
case "design": {
|
|
655
|
+
import("./design-connect.js")
|
|
656
|
+
.then(async (m) => {
|
|
657
|
+
const code = await m.runDesign(args);
|
|
658
|
+
process.exit(code);
|
|
659
|
+
})
|
|
660
|
+
.catch((err) => {
|
|
661
|
+
console.error(err?.message ?? err);
|
|
662
|
+
process.exit(1);
|
|
663
|
+
});
|
|
664
|
+
break;
|
|
665
|
+
}
|
|
654
666
|
case "recap": {
|
|
655
667
|
// PR visual recap helpers used by the GitHub Action. Promoted to the CLI
|
|
656
668
|
// so an installed repo's workflow can call `agent-native recap …` instead
|
|
@@ -822,6 +834,9 @@ Usage:
|
|
|
822
834
|
Launch Content in local-file mode for a local
|
|
823
835
|
docs/content folder. Use --no-open, --port N,
|
|
824
836
|
or --profile docs/no-bookkeeping as needed.
|
|
837
|
+
agent-native design connect Start a localhost Design bridge for a running
|
|
838
|
+
dev server. Use --url, --port, --root, or
|
|
839
|
+
--json to print the route/source manifest.
|
|
825
840
|
agent-native recap <cmd> PR visual recap setup and GitHub Action helpers.
|
|
826
841
|
Run 'agent-native recap help' for subcommands.
|
|
827
842
|
agent-native plan <cmd> Plan helpers for block catalogs and local files.
|