@agent-native/core 0.80.8 → 0.80.10
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 +19 -0
- package/corpus/core/docs/content/locales/ar-SA/template-design.mdx +6 -0
- package/corpus/core/docs/content/locales/de-DE/template-design.mdx +8 -0
- package/corpus/core/docs/content/locales/es-ES/template-design.mdx +10 -2
- package/corpus/core/docs/content/locales/fr-FR/template-design.mdx +10 -2
- package/corpus/core/docs/content/locales/hi-IN/template-design.mdx +7 -0
- package/corpus/core/docs/content/locales/ja-JP/template-design.mdx +7 -0
- package/corpus/core/docs/content/locales/ko-KR/template-design.mdx +7 -0
- package/corpus/core/docs/content/locales/pt-BR/template-design.mdx +9 -2
- package/corpus/core/docs/content/locales/zh-CN/template-design.mdx +6 -0
- package/corpus/core/docs/content/locales/zh-TW/template-design.mdx +6 -0
- package/corpus/core/docs/content/template-design.mdx +9 -2
- package/corpus/core/package.json +1 -1
- package/corpus/core/src/cli/design-connect.ts +28 -2
- package/corpus/core/src/cli/mcp.ts +10 -0
- package/corpus/core/src/cli/skills.ts +103 -36
- package/corpus/core/src/client/error-format.ts +25 -0
- package/corpus/core/src/client/extensions/ExtensionViewer.tsx +13 -11
- package/corpus/core/src/client/guided-questions.tsx +32 -4
- package/corpus/core/src/client/onboarding/OnboardingPanel.tsx +33 -1
- package/corpus/core/src/client/resources/BuiltinCapabilityDetail.tsx +8 -0
- package/corpus/core/src/client/resources/use-builtin-capabilities.ts +4 -2
- package/corpus/core/src/client/session-replay.ts +34 -0
- package/corpus/core/src/client/sharing/ShareButton.tsx +106 -21
- package/corpus/core/src/coding-tools/index.ts +1 -1
- package/corpus/core/src/mcp/index.ts +2 -0
- package/corpus/core/src/mcp/screen-memory-stdio.ts +290 -0
- package/corpus/core/src/mcp-client/builtin-capabilities.ts +13 -1
- package/corpus/core/src/mcp-client/index.ts +9 -0
- package/corpus/core/src/mcp-client/screen-memory-local.ts +461 -0
- package/corpus/core/src/onboarding/types.ts +7 -0
- package/corpus/core/src/server/agent-chat-plugin.ts +25 -0
- package/corpus/core/src/server/agents-bundle.ts +35 -7
- package/corpus/core/src/styles/agent-native.css +5 -0
- package/corpus/core/src/templates/default/app/global.css +35 -35
- package/corpus/templates/analytics/AGENTS.md +6 -0
- package/corpus/templates/analytics/actions/github-repo-files.ts +9 -0
- package/corpus/templates/analytics/app/components/layout/Layout.tsx +4 -4
- package/corpus/templates/analytics/app/global.css +144 -40
- package/corpus/templates/analytics/app/pages/adhoc/explorer/index.tsx +1 -1
- package/corpus/templates/analytics/app/pages/adhoc/explorer-dashboard/ChartCard.tsx +1 -1
- package/corpus/templates/analytics/app/pages/adhoc/explorer-dashboard/index.tsx +1 -1
- package/corpus/templates/analytics/app/pages/sessions/SessionDetailPage.tsx +4 -4
- package/corpus/templates/analytics/app/pages/sessions/SessionsPage.tsx +9 -9
- package/corpus/templates/analytics/changelog/2026-06-29-agents-can-search-and-read-connected-github-repositories-whe.md +6 -0
- package/corpus/templates/analytics/changelog/2026-06-29-sessions-and-explorer-layouts-adapt-when-the-agent-sidebar-is.md +6 -0
- package/corpus/templates/assets/app/components/layout/Layout.tsx +3 -1
- package/corpus/templates/assets/app/components/library/LibraryPresetGrid.tsx +1 -1
- package/corpus/templates/assets/app/global.css +99 -35
- package/corpus/templates/assets/app/routes/asset.$id.tsx +2 -2
- package/corpus/templates/assets/app/routes/brand-kits.$id.tsx +4 -4
- package/corpus/templates/assets/app/routes/library.tsx +4 -4
- package/corpus/templates/assets/changelog/2026-06-29-asset-library-and-detail-layouts-adapt-when-the-agent-sidebar.md +6 -0
- package/corpus/templates/brain/app/components/layout/Layout.tsx +1 -1
- package/corpus/templates/brain/app/global.css +63 -35
- package/corpus/templates/brain/app/routes/search.tsx +1 -1
- package/corpus/templates/brain/app/routes/settings.tsx +1 -1
- package/corpus/templates/brain/app/routes/sources.tsx +2 -2
- package/corpus/templates/brain/changelog/2026-06-29-search-settings-and-source-layouts-adapt-when-the-agent-sidebar.md +6 -0
- package/corpus/templates/calendar/app/components/calendar/EventDetailPanel.tsx +4 -4
- package/corpus/templates/calendar/app/components/calendar/FindTimePanel.tsx +3 -2
- package/corpus/templates/calendar/app/components/layout/AppLayout.tsx +4 -2
- package/corpus/templates/calendar/app/global.css +69 -35
- package/corpus/templates/calendar/changelog/2026-06-29-event-and-find-time-layouts-adapt-when-the-agent-sidebar-is.md +6 -0
- package/corpus/templates/chat/app/components/layout/Layout.tsx +1 -1
- package/corpus/templates/chat/app/global.css +35 -35
- package/corpus/templates/chat/changelog/2026-06-29-chat-layouts-adapt-when-the-agent-sidebar-is-open.md +6 -0
- package/corpus/templates/clips/AGENTS.md +13 -0
- package/corpus/templates/clips/actions/get-screen-memory-status.ts +12 -0
- package/corpus/templates/clips/actions/query-screen-memory-context.ts +29 -0
- package/corpus/templates/clips/actions/view-screen.ts +2 -2
- package/corpus/templates/clips/app/components/library/library-layout.tsx +1 -1
- package/corpus/templates/clips/app/global.css +47 -35
- package/corpus/templates/clips/app/routes/_app.meetings.$meetingId.tsx +3 -3
- package/corpus/templates/clips/app/routes/r.$recordingId.tsx +45 -18
- package/corpus/templates/clips/changelog/2026-06-29-meeting-detail-layouts-adapt-when-the-agent-sidebar-is-open.md +6 -0
- package/corpus/templates/clips/changelog/2026-06-29-screen-memory-keeps-a-local-rolling-screen-buffer-for-agent-context.md +5 -0
- package/corpus/templates/clips/changelog/2026-06-29-video-chat-is-easier-to-find-on-recording-pages-and-s3-setup.md +6 -0
- package/corpus/templates/clips/chrome-extension/src/styles.css +39 -39
- package/corpus/templates/clips/desktop/src/app.tsx +290 -1
- package/corpus/templates/clips/desktop/src/shared/config.ts +83 -0
- package/corpus/templates/clips/desktop/src/styles.css +67 -52
- package/corpus/templates/clips/desktop/src-tauri/src/config.rs +50 -0
- package/corpus/templates/clips/desktop/src-tauri/src/lib.rs +17 -0
- package/corpus/templates/clips/desktop/src-tauri/src/native_screen.rs +13 -13
- package/corpus/templates/clips/desktop/src-tauri/src/screen_memory.rs +990 -0
- package/corpus/templates/clips/server/plugins/onboarding.ts +2 -0
- package/corpus/templates/content/app/components/editor/database/DatabaseView.tsx +3 -3
- package/corpus/templates/content/app/components/layout/Layout.tsx +1 -1
- package/corpus/templates/content/app/global.css +29 -15
- package/corpus/templates/content/changelog/2026-06-29-database-gallery-layouts-adapt-when-the-agent-sidebar-is-open.md +6 -0
- package/corpus/templates/design/.agents/skills/design-generation/SKILL.md +25 -20
- package/corpus/templates/design/.agents/skills/design-systems/SKILL.md +8 -0
- package/corpus/templates/design/.agents/skills/export-handoff/SKILL.md +8 -0
- package/corpus/templates/design/.agents/skills/visual-edit/SKILL.md +13 -0
- package/corpus/templates/design/AGENTS.md +20 -12
- package/corpus/templates/design/CODE_NATIVE_DESIGN_STUDIO_IMPLEMENTATION_PLAN.md +1054 -0
- package/corpus/templates/design/DESIGN-STUDIO-PLAN.md +717 -0
- package/corpus/templates/design/actions/add-breakpoint.ts +143 -0
- package/corpus/templates/design/actions/add-localhost-screens.ts +5 -0
- package/corpus/templates/design/actions/apply-a11y-fix.ts +317 -0
- package/corpus/templates/design/actions/apply-component-prop-edit.ts +433 -0
- package/corpus/templates/design/actions/apply-design-state.ts +200 -0
- package/corpus/templates/design/actions/apply-design-token-edit.ts +202 -0
- package/corpus/templates/design/actions/apply-motion-edit.ts +450 -0
- package/corpus/templates/design/actions/apply-shader-fill.ts +404 -0
- package/corpus/templates/design/actions/apply-visual-edit.ts +214 -8
- package/corpus/templates/design/actions/capture-design-state.ts +224 -0
- package/corpus/templates/design/actions/connect-builder-app.ts +162 -0
- package/corpus/templates/design/actions/create-component.ts +447 -0
- package/corpus/templates/design/actions/create-design-branch.ts +263 -0
- package/corpus/templates/design/actions/create-design-state.ts +162 -0
- package/corpus/templates/design/actions/delete-design-state.ts +55 -0
- package/corpus/templates/design/actions/deploy-design-preview.ts +275 -0
- package/corpus/templates/design/actions/export-coding-handoff.ts +12 -4
- package/corpus/templates/design/actions/generate-design.ts +6 -21
- package/corpus/templates/design/actions/generate-screens.ts +43 -2
- package/corpus/templates/design/actions/get-component-details.ts +242 -0
- package/corpus/templates/design/actions/get-design-branch-diff.ts +362 -0
- package/corpus/templates/design/actions/get-design-review.ts +314 -0
- package/corpus/templates/design/actions/get-design-surface-index.ts +582 -0
- package/corpus/templates/design/actions/get-design.ts +1 -0
- package/corpus/templates/design/actions/get-motion-timeline.ts +99 -0
- package/corpus/templates/design/actions/index-components.ts +258 -0
- package/corpus/templates/design/actions/index-design-tokens.ts +273 -0
- package/corpus/templates/design/actions/list-design-extensions.ts +309 -0
- package/corpus/templates/design/actions/list-design-source-capabilities.ts +153 -0
- package/corpus/templates/design/actions/list-design-states.ts +72 -0
- package/corpus/templates/design/actions/migrate-inline-design-to-app.ts +298 -0
- package/corpus/templates/design/actions/open-component-source.ts +237 -0
- package/corpus/templates/design/actions/present-design-variants.ts +355 -30
- package/corpus/templates/design/actions/preview-component-prop-edit.ts +254 -0
- package/corpus/templates/design/actions/preview-design-token-edit.ts +113 -0
- package/corpus/templates/design/actions/preview-shader-fill.ts +189 -0
- package/corpus/templates/design/actions/remove-breakpoint.ts +103 -0
- package/corpus/templates/design/actions/remove-motion-timeline.ts +196 -0
- package/corpus/templates/design/actions/run-design-audit.ts +421 -0
- package/corpus/templates/design/actions/run-design-extension-action.ts +284 -0
- package/corpus/templates/design/actions/set-active-breakpoint.ts +39 -0
- package/corpus/templates/design/actions/view-screen.ts +75 -31
- package/corpus/templates/design/app/components/design/DesignCanvas.tsx +1738 -135
- package/corpus/templates/design/app/components/design/DesignEditorSkeleton.tsx +1 -1
- package/corpus/templates/design/app/components/design/DesignExtensionsPanel.tsx +632 -43
- package/corpus/templates/design/app/components/design/DrawOverlay.tsx +1 -1
- package/corpus/templates/design/app/components/design/EditPanel.tsx +1873 -132
- package/corpus/templates/design/app/components/design/LayersPanel.tsx +384 -219
- package/corpus/templates/design/app/components/design/LocalSourceEditBanner.tsx +157 -0
- package/corpus/templates/design/app/components/design/MotionDock.tsx +1062 -0
- package/corpus/templates/design/app/components/design/MultiScreenCanvas.tsx +2103 -295
- package/corpus/templates/design/app/components/design/QuestionFlow.tsx +83 -206
- package/corpus/templates/design/app/components/design/ReviewPanel.tsx +759 -0
- package/corpus/templates/design/app/components/design/StatesPanel.tsx +579 -0
- package/corpus/templates/design/app/components/design/TokensPanel.tsx +573 -0
- package/corpus/templates/design/app/components/design/TweaksPanel.tsx +1 -1
- package/corpus/templates/design/app/components/design/canvas-primitive-style.ts +241 -0
- package/corpus/templates/design/app/components/design/index.ts +16 -1
- package/corpus/templates/design/app/components/design/inspector/AutoLayoutMatrix.tsx +238 -137
- package/corpus/templates/design/app/components/design/inspector/DesignColorPicker.tsx +188 -14
- package/corpus/templates/design/app/components/design/inspector/ExportSettingsPanel.tsx +24 -5
- package/corpus/templates/design/app/components/design/inspector/ImageFillControls.tsx +57 -1
- package/corpus/templates/design/app/components/design/inspector/InspectorAiActions.tsx +145 -0
- package/corpus/templates/design/app/components/design/inspector/SHADER_INTEGRATION.md +42 -12
- package/corpus/templates/design/app/components/design/inspector/ScrubInput.tsx +37 -12
- package/corpus/templates/design/app/components/design/inspector/index.ts +1 -0
- package/corpus/templates/design/app/components/design/inspector/scrub-input-utils.ts +12 -5
- package/corpus/templates/design/app/components/design/types.ts +9 -0
- package/corpus/templates/design/app/components/layout/Layout.tsx +23 -5
- package/corpus/templates/design/app/components/visual-editor/DrawOverlay.tsx +1 -1
- package/corpus/templates/design/app/global.css +77 -49
- package/corpus/templates/design/app/hooks/use-question-flow.ts +2 -2
- package/corpus/templates/design/app/hooks/useAgentEditRequest.ts +131 -0
- package/corpus/templates/design/app/hooks/useDesignHotkeys.ts +11 -2
- package/corpus/templates/design/app/i18n/zh-TW.ts +34 -0
- package/corpus/templates/design/app/i18n-data.ts +314 -3
- package/corpus/templates/design/app/pages/DesignEditor.tsx +4929 -892
- package/corpus/templates/design/app/root.tsx +1 -1
- package/corpus/templates/design/changelog/2026-06-29-added-a-review-panel-in-the-design-editor-s-inspector-with-a.md +6 -0
- package/corpus/templates/design/changelog/2026-06-29-containers-no-longer-block-selecting-nested-elements-and-nor.md +6 -0
- package/corpus/templates/design/changelog/2026-06-29-copying-and-pasting-layers-no-longer-shows-success-notificat.md +6 -0
- package/corpus/templates/design/changelog/2026-06-29-design-agents-now-generate-and-refine-variants-from-stronger.md +6 -0
- package/corpus/templates/design/changelog/2026-06-29-design-inspector-controls-now-match-figmas-softer-dark-chrome.md +6 -0
- package/corpus/templates/design/changelog/2026-06-29-design-questions-now-appear-as-a-cleaner-canvas-intake-with-.md +6 -0
- package/corpus/templates/design/changelog/2026-06-29-design-variant-directions-now-appear-as-board-screens-with-chat-buttons.md +5 -0
- package/corpus/templates/design/changelog/2026-06-29-device-presets-in-all-screens-view-resize-the-selected-previ.md +6 -0
- package/corpus/templates/design/changelog/2026-06-29-element-selection-no-longer-snaps-back-to-the-previous-layer.md +6 -0
- package/corpus/templates/design/changelog/2026-06-29-frame-resize-measurements-now-stay-beside-the-cursor-while-d.md +6 -0
- package/corpus/templates/design/changelog/2026-06-29-inspector-number-fields-have-cleaner-tooltips-and-draggable-.md +6 -0
- package/corpus/templates/design/changelog/2026-06-29-layer-and-canvas-drags-keep-the-layer-list-stable-while-chan.md +6 -0
- package/corpus/templates/design/changelog/2026-06-29-layer-locking-layer-nesting-generated-question-intake-and-im.md +6 -0
- package/corpus/templates/design/changelog/2026-06-29-layer-moves-can-be-undone-and-redone-without-flashing-the-ca.md +6 -0
- package/corpus/templates/design/changelog/2026-06-29-layer-names-in-the-sidebar-can-scroll-horizontally-instead-o.md +6 -0
- package/corpus/templates/design/changelog/2026-06-29-layer-nesting-in-the-sidebar-now-uses-tighter-spacing-so-nam.md +6 -0
- package/corpus/templates/design/changelog/2026-06-29-layers-no-longer-repeat-document-wrapper-rows-when-a-screen-.md +6 -0
- package/corpus/templates/design/changelog/2026-06-29-overview-previews-now-keep-element-hover-and-selection-tied-.md +6 -0
- package/corpus/templates/design/changelog/2026-06-29-pressing-escape-now-cancels-a-stuck-screen-drag-in-the-overv.md +6 -0
- package/corpus/templates/design/changelog/2026-06-29-screen-overview-is-easier-to-find-and-named-screens-open-dir.md +6 -0
- package/corpus/templates/design/changelog/2026-06-29-screen-overview-only-highlights-screens-when-the-frame-or-ti.md +6 -0
- package/corpus/templates/design/changelog/2026-06-29-screen-overview-previews-now-resize-to-match-the-selected-de.md +6 -0
- package/corpus/templates/design/changelog/2026-06-29-screen-overview-selection-now-uses-a-pointer-cursor-instead-.md +6 -0
- package/corpus/templates/design/changelog/2026-06-29-screen-overview-selection-outlines-now-stay-locked-to-the-se.md +6 -0
- package/corpus/templates/design/changelog/2026-06-29-screen-overview-zoom-now-reports-real-screen-scale-separatel.md +6 -0
- package/corpus/templates/design/changelog/2026-06-29-screen-overview-zooming-feels-smoother-and-selection-outline.md +6 -0
- package/corpus/templates/design/changelog/2026-06-29-screen-overview-zooming-now-stays-on-the-overview-canvas-ins.md +6 -0
- package/corpus/templates/design/changelog/2026-06-29-screen-previews-use-a-single-blue-hover-border-in-all-screen.md +6 -0
- package/corpus/templates/design/changelog/2026-06-29-selected-containers-show-draggable-padding-and-gap-guides-on.md +6 -0
- package/corpus/templates/design/changelog/2026-06-29-selecting-a-nested-layer-from-all-screens-now-keeps-you-in-a.md +6 -0
- package/corpus/templates/design/changelog/2026-06-29-share-now-groups-link-sharing-exports-and-agent-handoff.md +6 -0
- package/corpus/templates/design/changelog/2026-06-29-the-design-editor-adds-a-studio-layer-with-tokens-respon.md +6 -0
- package/corpus/templates/design/changelog/2026-06-29-the-design-editor-loading-skeleton-now-uses-a-softer-charcoa.md +6 -0
- package/corpus/templates/design/changelog/2026-06-29-the-device-preview-menu-now-sits-next-to-the-preview-button-.md +6 -0
- package/corpus/templates/design/changelog/2026-06-29-the-inspector-stays-read-only-while-an-empty-design-is-still.md +6 -0
- package/corpus/templates/design/changelog/2026-06-29-the-missing-design-view-now-matches-the-rest-of-the-editor-c.md +6 -0
- package/corpus/templates/design/changelog/2026-06-29-the-pen-tool-icon-and-tool-option-menus-better-match-the-edi.md +6 -0
- package/corpus/templates/design/changelog/2026-06-29-typography-controls-now-keep-the-font-name-visible-and-move-.md +6 -0
- package/corpus/templates/design/changelog/2026-06-30-accessibility-findings-now-offer-a-one-click-fix.md +6 -0
- package/corpus/templates/design/changelog/2026-06-30-component-instances-now-have-editable-props-in-the-inspe.md +6 -0
- package/corpus/templates/design/changelog/2026-06-30-inspect-code-now-shows-the-elements-opening-tag-at-a-gla.md +6 -0
- package/corpus/templates/design/changelog/2026-06-30-shader-fill-presets-can-now-be-applied-to-an-element.md +6 -0
- package/corpus/templates/design/changelog/2026-06-30-the-motion-timeline-can-now-add-a-track-to-any-element-a.md +6 -0
- package/corpus/templates/design/changelog/2026-06-30-visual-editor-selection-layer-paint-and-drawing-controls-are-more-reliable.md +6 -0
- package/corpus/templates/design/e2e/README.md +3 -3
- package/corpus/templates/design/e2e/global-setup.ts +11 -22
- package/corpus/templates/design/e2e/helpers.ts +128 -11
- package/corpus/templates/design/playwright.config.ts +9 -3
- package/corpus/templates/design/server/db/schema.ts +123 -0
- package/corpus/templates/design/server/lib/coding-handoff.ts +126 -2
- package/corpus/templates/design/server/plugins/core-routes.ts +1 -2
- package/corpus/templates/design/server/plugins/db.ts +90 -0
- package/corpus/templates/design/server/routes/api/design-handoff/[id].zip.get.ts +86 -0
- package/corpus/templates/design/shared/builder-app.ts +297 -0
- package/corpus/templates/design/shared/capability-resolver.ts +123 -0
- package/corpus/templates/design/shared/capture-sanitize.ts +70 -0
- package/corpus/templates/design/shared/code-layer.ts +1141 -93
- package/corpus/templates/design/shared/component-model.ts +239 -0
- package/corpus/templates/design/shared/design-review.ts +275 -0
- package/corpus/templates/design/shared/design-source-capabilities.ts +286 -0
- package/corpus/templates/design/shared/design-state.ts +112 -0
- package/corpus/templates/design/shared/design-surface-index.ts +258 -0
- package/corpus/templates/design/shared/generation-session.ts +41 -0
- package/corpus/templates/design/shared/motion-compiler.ts +278 -0
- package/corpus/templates/design/shared/motion-timeline.ts +193 -0
- package/corpus/templates/design/shared/responsive-classes.ts +452 -0
- package/corpus/templates/design/shared/shader-fill.ts +323 -0
- package/corpus/templates/design/shared/source-mode.ts +245 -0
- package/corpus/templates/dispatch/app/global.css +79 -35
- package/corpus/templates/dispatch/app/routes/integrations.tsx +8 -7
- package/corpus/templates/dispatch/changelog/2026-06-29-integration-layouts-adapt-when-the-agent-sidebar-is-open.md +6 -0
- package/corpus/templates/forms/app/components/layout/Layout.tsx +6 -2
- package/corpus/templates/forms/app/global.css +64 -35
- package/corpus/templates/forms/app/pages/FormsListPage.tsx +2 -2
- package/corpus/templates/forms/app/pages/ResponseInsightsPage.tsx +3 -3
- package/corpus/templates/forms/changelog/2026-06-29-form-list-and-insight-layouts-adapt-when-the-agent-sidebar.md +6 -0
- package/corpus/templates/macros/app/components/layout/AppLayout.tsx +3 -1
- package/corpus/templates/macros/app/global.css +25 -9
- package/corpus/templates/macros/changelog/2026-06-29-macro-layouts-adapt-when-the-agent-sidebar-is-open.md +6 -0
- package/corpus/templates/mail/app/components/layout/AppLayout.tsx +6 -2
- package/corpus/templates/mail/app/global.css +42 -36
- package/corpus/templates/mail/app/pages/InboxPage.tsx +1 -1
- package/corpus/templates/mail/changelog/2026-06-29-the-contact-panel-now-adapts-to-the-available-mail-pane-width.md +6 -0
- package/corpus/templates/plan/app/components/layout/Layout.tsx +3 -1
- package/corpus/templates/plan/app/components/plan/CanvasArea.tsx +6 -2
- package/corpus/templates/plan/app/components/plan/DocumentArea.tsx +6 -7
- package/corpus/templates/plan/app/global.css +74 -42
- package/corpus/templates/plan/changelog/2026-06-29-plan-canvases-open-without-an-initial-pan-and-zoom-flicker.md +6 -0
- package/corpus/templates/plan/changelog/2026-06-29-plan-document-blocks-adapt-to-the-available-document-width.md +6 -0
- package/corpus/templates/plan/changelog/2026-06-29-plan-titles-and-summaries-can-be-edited-inline-without-focus.md +6 -0
- package/corpus/templates/slides/app/components/layout/Layout.tsx +3 -1
- package/corpus/templates/slides/app/global.css +49 -33
- package/corpus/templates/slides/changelog/2026-06-29-slide-layouts-adapt-when-the-agent-sidebar-is-open.md +6 -0
- package/corpus/templates/videos/app/components/layout/Layout.tsx +3 -1
- package/corpus/templates/videos/app/global.css +35 -35
- package/corpus/templates/videos/changelog/2026-06-29-video-layouts-adapt-when-the-agent-sidebar-is-open.md +6 -0
- package/dist/cli/design-connect.d.ts.map +1 -1
- package/dist/cli/design-connect.js +28 -2
- package/dist/cli/design-connect.js.map +1 -1
- package/dist/cli/mcp.d.ts.map +1 -1
- package/dist/cli/mcp.js +10 -0
- package/dist/cli/mcp.js.map +1 -1
- package/dist/cli/skills.d.ts.map +1 -1
- package/dist/cli/skills.js +95 -33
- package/dist/cli/skills.js.map +1 -1
- package/dist/client/error-format.d.ts.map +1 -1
- package/dist/client/error-format.js +17 -0
- package/dist/client/error-format.js.map +1 -1
- package/dist/client/extensions/ExtensionViewer.d.ts.map +1 -1
- package/dist/client/extensions/ExtensionViewer.js +3 -4
- package/dist/client/extensions/ExtensionViewer.js.map +1 -1
- package/dist/client/guided-questions.d.ts +4 -0
- package/dist/client/guided-questions.d.ts.map +1 -1
- package/dist/client/guided-questions.js +16 -7
- package/dist/client/guided-questions.js.map +1 -1
- package/dist/client/onboarding/OnboardingPanel.js +26 -1
- package/dist/client/onboarding/OnboardingPanel.js.map +1 -1
- package/dist/client/resources/BuiltinCapabilityDetail.d.ts.map +1 -1
- package/dist/client/resources/BuiltinCapabilityDetail.js +1 -1
- package/dist/client/resources/BuiltinCapabilityDetail.js.map +1 -1
- package/dist/client/resources/use-builtin-capabilities.d.ts +1 -1
- package/dist/client/resources/use-builtin-capabilities.d.ts.map +1 -1
- package/dist/client/resources/use-builtin-capabilities.js +2 -1
- package/dist/client/resources/use-builtin-capabilities.js.map +1 -1
- package/dist/client/session-replay.d.ts.map +1 -1
- package/dist/client/session-replay.js +31 -0
- package/dist/client/session-replay.js.map +1 -1
- package/dist/client/sharing/ShareButton.d.ts +14 -0
- package/dist/client/sharing/ShareButton.d.ts.map +1 -1
- package/dist/client/sharing/ShareButton.js +36 -7
- package/dist/client/sharing/ShareButton.js.map +1 -1
- package/dist/coding-tools/index.js +1 -1
- package/dist/coding-tools/index.js.map +1 -1
- package/dist/mcp/index.d.ts +2 -0
- package/dist/mcp/index.d.ts.map +1 -1
- package/dist/mcp/index.js +1 -0
- package/dist/mcp/index.js.map +1 -1
- package/dist/mcp/screen-memory-stdio.d.ts +6 -0
- package/dist/mcp/screen-memory-stdio.d.ts.map +1 -0
- package/dist/mcp/screen-memory-stdio.js +213 -0
- package/dist/mcp/screen-memory-stdio.js.map +1 -0
- package/dist/mcp-client/builtin-capabilities.d.ts +1 -1
- package/dist/mcp-client/builtin-capabilities.d.ts.map +1 -1
- package/dist/mcp-client/builtin-capabilities.js +10 -0
- package/dist/mcp-client/builtin-capabilities.js.map +1 -1
- package/dist/mcp-client/index.d.ts +1 -0
- package/dist/mcp-client/index.d.ts.map +1 -1
- package/dist/mcp-client/index.js +1 -0
- package/dist/mcp-client/index.js.map +1 -1
- package/dist/mcp-client/screen-memory-local.d.ts +61 -0
- package/dist/mcp-client/screen-memory-local.d.ts.map +1 -0
- package/dist/mcp-client/screen-memory-local.js +336 -0
- package/dist/mcp-client/screen-memory-local.js.map +1 -0
- package/dist/observability/routes.d.ts +3 -3
- package/dist/onboarding/types.d.ts +7 -0
- package/dist/onboarding/types.d.ts.map +1 -1
- package/dist/onboarding/types.js.map +1 -1
- package/dist/server/agent-chat-plugin.d.ts.map +1 -1
- package/dist/server/agent-chat-plugin.js +26 -0
- 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/agents-bundle.d.ts.map +1 -1
- package/dist/server/agents-bundle.js +22 -7
- package/dist/server/agents-bundle.js.map +1 -1
- package/dist/styles/agent-native.css +5 -0
- package/dist/templates/default/app/global.css +35 -35
- package/docs/content/locales/ar-SA/template-design.mdx +6 -0
- package/docs/content/locales/de-DE/template-design.mdx +8 -0
- package/docs/content/locales/es-ES/template-design.mdx +10 -2
- package/docs/content/locales/fr-FR/template-design.mdx +10 -2
- package/docs/content/locales/hi-IN/template-design.mdx +7 -0
- package/docs/content/locales/ja-JP/template-design.mdx +7 -0
- package/docs/content/locales/ko-KR/template-design.mdx +7 -0
- package/docs/content/locales/pt-BR/template-design.mdx +9 -2
- package/docs/content/locales/zh-CN/template-design.mdx +6 -0
- package/docs/content/locales/zh-TW/template-design.mdx +6 -0
- package/docs/content/template-design.mdx +9 -2
- package/package.json +1 -1
- package/src/templates/default/app/global.css +35 -35
- package/corpus/templates/design/app/components/design/VariantGrid.tsx +0 -189
- package/corpus/templates/design/app/components/design/VariantHandoffCard.tsx +0 -115
- package/corpus/templates/design/app/hooks/use-variant-flow.ts +0 -342
|
@@ -1 +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;IACl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AQ,EAAE,SAAS,EAAE,QAAQ,CAAU,EAAE,CAAC;YAC9D,OAAO,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;QAC7B,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import fsSync from \"node:fs\";\nimport fs from \"node:fs/promises\";\nimport http, {\n type IncomingMessage,\n type Server,\n type ServerResponse,\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"]}
|
|
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;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CAAC;IACjD,OAAO,CAAC,KAAK,CAAC,aAAa,QAAQ,CAAC,SAAS,gBAAgB,CAAC,CAAC;IAC/D,OAAO,CAAC,KAAK,CAAC,aAAa,QAAQ,CAAC,UAAU,EAAE,CAAC,CAAC;IAClD,OAAO,CAAC,KAAK,CAAC,aAAa,QAAQ,CAAC,YAAY,EAAE,CAAC,CAAC;IAEpD,OAAO,MAAM,IAAI,OAAO,CAAS,CAAC,OAAO,EAAE,EAAE;QAC3C,MAAM,IAAI,GAAG,GAAG,EAAE;YAChB,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;QACxC,CAAC,CAAC;QACF,KAAK,MAAM,MAAM,IAAI,CAAC,QAAQ,EAAE,SAAS,EAAE,QAAQ,CAAU,EAAE,CAAC;YAC9D,OAAO,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;QAC7B,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import fsSync from \"node:fs\";\nimport fs from \"node:fs/promises\";\nimport http, {\n type IncomingMessage,\n type Server,\n type ServerResponse,\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 : operation === \"resolveNodeToFile\"\n ? // resolveNodeToFile maps a runtime DOM node id (from the editor's\n // 'select' payload) to { file, line, component } provenance. The\n // bridge endpoint exists; per-element provenance data must be\n // emitted by the connected app at build time — see the provenance\n // note in the help text below.\n \"Requires the connected app to emit data-source-file / data-source-line / data-component-name attributes (e.g. via @vitejs/plugin-react jsxDEV or a Babel source plugin).\"\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\nElement provenance (resolveNodeToFile):\n The design editor can map a selected DOM element back to its source file,\n line, and React component name when the connected app emits provenance\n attributes at build time. Add one of the following to your app's build:\n\n • @vitejs/plugin-react with jsxDEV enabled (development mode default):\n Sets data-source-file and data-source-line on each JSX element\n automatically when using the Babel transform.\n\n • A Babel source plugin (e.g. babel-plugin-react-source or a custom plugin):\n Emits data-source-file=\"src/Button.tsx\" data-source-line=\"12\"\n data-source-column=\"4\" data-component-name=\"Button\" on each element.\n\n • data-loc=\"src/Button.tsx:12:4\" shorthand attribute (Babel source convention):\n The bridge parses this as { sourceFile, line, column } automatically.\n\n Without these attributes the editor still works; provenance is simply absent.\n Cross-origin localhost iframes cannot be read regardless of attributes (CSP).`);\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/mcp.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mcp.d.ts","sourceRoot":"","sources":["../../src/cli/mcp.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;
|
|
1
|
+
{"version":3,"file":"mcp.d.ts","sourceRoot":"","sources":["../../src/cli/mcp.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAkiBH,wBAAsB,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAkC1D"}
|
package/dist/cli/mcp.js
CHANGED
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
import crypto from "node:crypto";
|
|
16
16
|
import fs from "node:fs";
|
|
17
17
|
import path from "node:path";
|
|
18
|
+
import { runScreenMemoryMCPStdio } from "../mcp/screen-memory-stdio.js";
|
|
18
19
|
import { runMCPStdio } from "../mcp/stdio.js";
|
|
19
20
|
import { findWorkspaceRoot, resolveLocalAppOrigin, resolveWorkspace, } from "../mcp/workspace-resolve.js";
|
|
20
21
|
import { CLIENTS, buildCodexHttpBlock, buildCodexLocalBlock, buildHttpMcpEntryForClient, buildLocalMcpEntryForClient, codexConfigPath, codexHasBlock, configPathFor as clientConfigPathFor, hasJsonMcpEntryForClient, writeCodexBlock, writeFileAtomic, writeJsonMcpEntryForClient, } from "./mcp-config-writers.js";
|
|
@@ -37,6 +38,8 @@ function parseArgs(argv) {
|
|
|
37
38
|
out.app = v;
|
|
38
39
|
else if ((v = eat("--port")) !== undefined)
|
|
39
40
|
out.port = Number(v);
|
|
41
|
+
else if ((v = eat("--dir")) !== undefined)
|
|
42
|
+
out.screenMemoryDir = v;
|
|
40
43
|
else if ((v = eat("--scope")) !== undefined)
|
|
41
44
|
out.scope = v;
|
|
42
45
|
else if (a === "--standalone")
|
|
@@ -405,6 +408,10 @@ Usage:
|
|
|
405
408
|
Run the MCP stdio transport (what client configs spawn).
|
|
406
409
|
Default: proxy to the running local app; --standalone builds from disk.
|
|
407
410
|
|
|
411
|
+
npx @agent-native/core@latest mcp screen-memory [--dir <path>]
|
|
412
|
+
Run the local Clips Screen Memory stdio server.
|
|
413
|
+
Defaults to the Clips app-data screen-memory folder.
|
|
414
|
+
|
|
408
415
|
npx @agent-native/core@latest mcp install --client <c> [--app <id>] [--scope user|project]
|
|
409
416
|
Provision a token and write the client's MCP config (idempotent).
|
|
410
417
|
Clients: claude-code, codex, cowork, cursor, opencode, github-copilot
|
|
@@ -424,6 +431,9 @@ export async function runMcp(args) {
|
|
|
424
431
|
case "serve":
|
|
425
432
|
await cmdServe(p);
|
|
426
433
|
return;
|
|
434
|
+
case "screen-memory":
|
|
435
|
+
await runScreenMemoryMCPStdio({ storeDir: p.screenMemoryDir });
|
|
436
|
+
return;
|
|
427
437
|
case "install":
|
|
428
438
|
await cmdInstall(p);
|
|
429
439
|
return;
|
package/dist/cli/mcp.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mcp.js","sourceRoot":"","sources":["../../src/cli/mcp.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,MAAM,MAAM,aAAa,CAAC;AACjC,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EACL,iBAAiB,EACjB,qBAAqB,EACrB,gBAAgB,GACjB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EACL,OAAO,EAEP,mBAAmB,EACnB,oBAAoB,EACpB,0BAA0B,EAC1B,2BAA2B,EAC3B,eAAe,EACf,aAAa,EACb,aAAa,IAAI,mBAAmB,EACpC,wBAAwB,EACxB,eAAe,EACf,eAAe,EACf,0BAA0B,GAC3B,MAAM,yBAAyB,CAAC;AAEjC,MAAM,kBAAkB,GAAG,cAAc,CAAC;AAY1C,SAAS,SAAS,CAAC,IAAc;IAC/B,MAAM,GAAG,GAAe,EAAE,CAAC,EAAE,EAAE,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC;IACpE,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACrC,MAAM,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,MAAM,GAAG,GAAG,CAAC,IAAY,EAAsB,EAAE;YAC/C,IAAI,CAAC,KAAK,IAAI;gBAAE,OAAO,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;YACjC,IAAI,CAAC,CAAC,UAAU,CAA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,MAAM,CAAC,2BAA2B,GAAG,EAAE,CAAC,CAAC;YACzC,MAAM,CAAC,IAAI,CAAC,CAAC;YACb,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACpB,CAAC;AACH,CAAC","sourcesContent":["/**\n * `agent-native mcp <subcommand>` — connect external coding agents (Claude\n * Code desktop & CLI, Claude Cowork, Codex, Cursor, OpenCode, GitHub Copilot /\n * VS Code) to this agent-native app/workspace over MCP.\n *\n * serve Run the MCP stdio transport (this is what client configs spawn).\n * install Provision a token + write the client's MCP config idempotently.\n * uninstall Remove the named entry from a client's MCP config.\n * status Print resolved MCP URL/port, token state, and per-client entries.\n * token Print or rotate the local ACCESS_TOKEN in the workspace .env.\n *\n * Node-only CLI module. Hand-rolled `.env` upsert + minimal TOML block merge\n * keep this dependency-free (no new npm deps).\n */\n\nimport crypto from \"node:crypto\";\nimport fs from \"node:fs\";\nimport path from \"node:path\";\n\nimport { runMCPStdio } from \"../mcp/stdio.js\";\nimport {\n findWorkspaceRoot,\n resolveLocalAppOrigin,\n resolveWorkspace,\n} from \"../mcp/workspace-resolve.js\";\nimport {\n CLIENTS,\n type ClientId,\n buildCodexHttpBlock,\n buildCodexLocalBlock,\n buildHttpMcpEntryForClient,\n buildLocalMcpEntryForClient,\n codexConfigPath,\n codexHasBlock,\n configPathFor as clientConfigPathFor,\n hasJsonMcpEntryForClient,\n writeCodexBlock,\n writeFileAtomic,\n writeJsonMcpEntryForClient,\n} from \"./mcp-config-writers.js\";\n\nconst SERVER_NAME_PREFIX = \"agent-native\";\n\ninterface ParsedArgs {\n _: string[];\n client?: string;\n app?: string;\n port?: number;\n scope?: string;\n standalone: boolean;\n rotate: boolean;\n}\n\nfunction parseArgs(argv: string[]): ParsedArgs {\n const out: ParsedArgs = { _: [], standalone: false, rotate: false };\n for (let i = 0; i < argv.length; i++) {\n const a = argv[i];\n const eat = (flag: string): string | undefined => {\n if (a === flag) return argv[++i];\n if (a.startsWith(`${flag}=`)) return a.slice(flag.length + 1);\n return undefined;\n };\n let v: string | undefined;\n if ((v = eat(\"--client\")) !== undefined) out.client = v;\n else if ((v = eat(\"--app\")) !== undefined) out.app = v;\n else if ((v = eat(\"--port\")) !== undefined) out.port = Number(v);\n else if ((v = eat(\"--scope\")) !== undefined) out.scope = v;\n else if (a === \"--standalone\") out.standalone = true;\n else if (a === \"--rotate\") out.rotate = true;\n else if (!a.startsWith(\"-\")) out._.push(a);\n }\n return out;\n}\n\nfunction logErr(msg: string): void {\n process.stderr.write(`${msg}\\n`);\n}\nfunction logOut(msg: string): void {\n process.stdout.write(`${msg}\\n`);\n}\n\n// ---------------------------------------------------------------------------\n// .env token provisioning (local dev) — hand-rolled idempotent upsert\n// ---------------------------------------------------------------------------\n\n/** Workspace root (or cwd for a standalone app) — where .env lives. */\nfunction envBaseDir(cwd = process.cwd()): string {\n return findWorkspaceRoot(cwd) ?? path.resolve(cwd);\n}\n\n/** Prefer .env.local, else .env. Returns the path we should write to. */\nfunction envFilePath(baseDir: string): string {\n const local = path.join(baseDir, \".env.local\");\n if (fs.existsSync(local)) return local;\n return path.join(baseDir, \".env\");\n}\n\nfunction readEnvFile(file: string): string {\n try {\n return fs.readFileSync(file, \"utf-8\");\n } catch {\n return \"\";\n }\n}\n\n/** Read a single key from a dotenv-format string (last assignment wins). */\nfunction getEnvValue(content: string, key: string): string | undefined {\n let found: string | undefined;\n for (const line of content.split(/\\r?\\n/)) {\n const m = line.match(/^\\s*([A-Z0-9_]+)\\s*=\\s*(.*)\\s*$/i);\n if (m && m[1] === key) {\n found = m[2].replace(/^[\"']|[\"']$/g, \"\");\n }\n }\n return found;\n}\n\n/**\n * Idempotently set `key=value` in the dotenv file. If the key already exists\n * we leave it untouched unless `force` is set (used by `token --rotate`).\n * Never clobbers an existing token implicitly.\n */\nfunction upsertEnv(\n file: string,\n key: string,\n value: string,\n force = false,\n): { changed: boolean; value: string } {\n const content = readEnvFile(file);\n const existing = getEnvValue(content, key);\n if (existing && !force) return { changed: false, value: existing };\n\n const line = `${key}=${value}`;\n let next: string;\n if (new RegExp(`^\\\\s*${key}\\\\s*=`, \"m\").test(content)) {\n next = content.replace(new RegExp(`^\\\\s*${key}\\\\s*=.*$`, \"m\"), line);\n } else {\n next =\n content.length === 0\n ? `${line}\\n`\n : `${content.replace(/\\n*$/, \"\")}\\n${line}\\n`;\n }\n writeFileAtomic(file, next);\n return { changed: true, value };\n}\n\nfunction generateToken(): string {\n return crypto.randomBytes(24).toString(\"base64url\");\n}\n\n/**\n * Ensure a local ACCESS_TOKEN exists in the workspace .env and return it.\n * Existing tokens are reused (never clobbered). Set `rotate` to replace it.\n */\nfunction ensureLocalToken(\n cwd: string,\n rotate = false,\n): { token: string; file: string; created: boolean } {\n const baseDir = envBaseDir(cwd);\n const file = envFilePath(baseDir);\n const content = readEnvFile(file);\n const existing = getEnvValue(content, \"ACCESS_TOKEN\");\n if (existing && !rotate) {\n return { token: existing, file, created: false };\n }\n const token = generateToken();\n upsertEnv(file, \"ACCESS_TOKEN\", token, true);\n return { token, file, created: true };\n}\n\n// ---------------------------------------------------------------------------\n// Hosted vs local detection\n// ---------------------------------------------------------------------------\n\n/**\n * Detect a hosted deployment URL. When the workspace .env points at a hosted\n * origin (APP_URL / BETTER_AUTH_URL with a non-localhost host) we write an\n * `http` client entry pointing at `<origin>/_agent-native/mcp` with a JWT\n * bearer instead of a stdio entry.\n */\nfunction detectHostedUrl(cwd: string): string | undefined {\n const baseDir = envBaseDir(cwd);\n const content =\n readEnvFile(path.join(baseDir, \".env.local\")) +\n \"\\n\" +\n readEnvFile(path.join(baseDir, \".env\"));\n for (const key of [\"AGENT_NATIVE_MCP_URL\", \"APP_URL\", \"BETTER_AUTH_URL\"]) {\n const v = getEnvValue(content, key);\n if (!v) continue;\n try {\n const u = new URL(v);\n if (!/^(localhost|127\\.0\\.0\\.1|\\[::1\\])$/.test(u.hostname)) {\n return `${u.origin}/_agent-native/mcp`;\n }\n } catch {\n // not a URL — skip\n }\n }\n return undefined;\n}\n\nasync function mintHostedJwt(cwd: string): Promise<string | undefined> {\n // Reuse the existing A2A signer — do not reinvent JWT minting.\n const owner =\n process.env.AGENT_NATIVE_OWNER_EMAIL ||\n process.env.OWNER_EMAIL ||\n \"owner@localhost\";\n let fileA2ASecret: string | undefined;\n if (!process.env.A2A_SECRET) {\n const baseDir = envBaseDir(cwd);\n const content =\n readEnvFile(path.join(baseDir, \".env.local\")) +\n \"\\n\" +\n readEnvFile(path.join(baseDir, \".env\"));\n fileA2ASecret = getEnvValue(content, \"A2A_SECRET\");\n }\n try {\n const { signA2AToken } = await import(\"../a2a/client.js\");\n return await signA2AToken(\n owner,\n undefined,\n process.env.A2A_SECRET || fileA2ASecret,\n {\n preferGlobalSecret: true,\n expiresIn: \"30d\",\n },\n );\n } catch (err: any) {\n logErr(\n ` Could not mint a hosted JWT (${err?.message ?? err}). ` +\n `Set A2A_SECRET in your workspace .env, or use the local stdio entry.`,\n );\n return undefined;\n }\n}\n\n// ---------------------------------------------------------------------------\n// Client config entries\n// ---------------------------------------------------------------------------\n\ninterface ServerEntryInputs {\n serverName: string;\n appId: string;\n token?: string;\n ownerEmail?: string;\n hostedUrl?: string;\n standalone: boolean;\n}\n\nfunction mcpServeArgs(i: ServerEntryInputs): string[] {\n const args = [\"mcp\", \"serve\"];\n if (i.appId) args.push(\"--app\", i.appId);\n if (i.standalone) args.push(\"--standalone\");\n return args;\n}\n\nfunction mcpServeEnv(i: ServerEntryInputs): Record<string, string> {\n const env: Record<string, string> = {};\n if (i.token) env.ACCESS_TOKEN = i.token;\n if (i.ownerEmail) env.AGENT_NATIVE_OWNER_EMAIL = i.ownerEmail;\n return env;\n}\n\nfunction buildJsonServerEntry(\n client: ClientId,\n i: ServerEntryInputs,\n): Record<string, unknown> {\n if (i.hostedUrl) {\n return buildHttpMcpEntryForClient(client, i.hostedUrl, i.token);\n }\n return buildLocalMcpEntryForClient(client, mcpServeArgs(i), mcpServeEnv(i));\n}\n\nfunction buildCodexBlock(name: string, i: ServerEntryInputs): string {\n if (i.hostedUrl) {\n return buildCodexHttpBlock(name, i.hostedUrl, i.token);\n }\n return buildCodexLocalBlock(name, mcpServeArgs(i), mcpServeEnv(i));\n}\n\n// ---------------------------------------------------------------------------\n// Per-client install/uninstall/status\n// ---------------------------------------------------------------------------\n\nfunction configPathFor(\n client: ClientId,\n cwd: string,\n scope: string | undefined,\n): string {\n return clientConfigPathFor(client, envBaseDir(cwd), scope);\n}\n\nfunction serverNameFor(appId: string): string {\n return `${SERVER_NAME_PREFIX}-${appId}`;\n}\n\n// Clients advertised in usage/help and listed by status. Excludes the legacy\n// `claude-code-cli` alias so only a single \"Claude Code\" appears (it is still\n// accepted via --client and collapses to claude-code).\nconst SELECTABLE_CLIENTS: ClientId[] = CLIENTS.filter(\n (c) => c !== \"claude-code-cli\",\n);\n\nfunction normalizeClientId(raw: string | undefined): ClientId | null {\n const value = (raw ?? \"\").toLowerCase();\n if (\n value === \"claude\" ||\n value === \"claude-code-desktop\" ||\n value === \"claude-code-cli\"\n ) {\n return \"claude-code\";\n }\n if (value === \"open-code\") return \"opencode\";\n if (value === \"copilot\" || value === \"vscode\" || value === \"vs-code\") {\n return \"github-copilot\";\n }\n return (CLIENTS as string[]).includes(value) ? (value as ClientId) : null;\n}\n\nfunction installForClient(\n client: ClientId,\n inputs: ServerEntryInputs,\n cwd: string,\n scope: string | undefined,\n): string {\n const name = inputs.serverName;\n const file = configPathFor(client, cwd, scope);\n if (client === \"codex\") {\n writeCodexBlock(file, name, buildCodexBlock(name, inputs));\n } else {\n writeJsonMcpEntryForClient(\n client,\n file,\n name,\n buildJsonServerEntry(client, inputs),\n );\n }\n return file;\n}\n\nfunction uninstallForClient(\n client: ClientId,\n appId: string,\n cwd: string,\n scope: string | undefined,\n): { file: string; removed: boolean } {\n const name = serverNameFor(appId);\n const file = configPathFor(client, cwd, scope);\n if (client === \"codex\") {\n const had = codexHasBlock(file, name);\n if (had) writeCodexBlock(file, name, null);\n return { file, removed: had };\n }\n const had = hasJsonMcpEntryForClient(client, file, name);\n if (had) writeJsonMcpEntryForClient(client, file, name, null);\n return { file, removed: had };\n}\n\nfunction clientHasEntry(client: ClientId, appId: string, cwd: string): boolean {\n const name = serverNameFor(appId);\n if (client === \"codex\") return codexHasBlock(codexConfigPath(), name);\n if (client === \"cowork\") {\n return hasJsonMcpEntryForClient(\n client,\n configPathFor(client, cwd, undefined),\n name,\n );\n }\n return (\n hasJsonMcpEntryForClient(\n client,\n configPathFor(client, cwd, \"project\"),\n name,\n ) ||\n hasJsonMcpEntryForClient(client, configPathFor(client, cwd, \"user\"), name)\n );\n}\n\n// ---------------------------------------------------------------------------\n// Subcommands\n// ---------------------------------------------------------------------------\n\nasync function cmdServe(p: ParsedArgs): Promise<void> {\n await runMCPStdio({\n appId: p.app,\n port: p.port,\n standalone: p.standalone,\n });\n}\n\nasync function cmdInstall(p: ParsedArgs): Promise<void> {\n const client = normalizeClientId(p.client);\n if (!client) {\n logErr(\n `Usage: npx @agent-native/core@latest mcp install --client ${SELECTABLE_CLIENTS.join(\"|\")} ` +\n `[--app <id>] [--scope user|project]`,\n );\n process.exit(1);\n }\n const cwd = process.cwd();\n\n // Resolve which app this entry targets (default = workspace default app).\n let appId = p.app;\n if (!appId) {\n try {\n const resolved = await resolveLocalAppOrigin({ cwd });\n appId = resolved.appId;\n } catch {\n appId = \"app\";\n }\n }\n const serverName = serverNameFor(appId);\n\n const hostedUrl = detectHostedUrl(cwd);\n const ownerEmail = process.env.AGENT_NATIVE_OWNER_EMAIL;\n\n let token: string | undefined;\n if (hostedUrl) {\n token = await mintHostedJwt(cwd);\n logOut(`Detected hosted deployment: ${hostedUrl}`);\n } else {\n const t = ensureLocalToken(cwd, false);\n token = t.token;\n logOut(\n t.created\n ? `Provisioned ACCESS_TOKEN in ${t.file}`\n : `Reusing existing ACCESS_TOKEN from ${t.file}`,\n );\n }\n\n const inputs: ServerEntryInputs = {\n serverName,\n appId: appId!,\n token,\n ownerEmail,\n hostedUrl,\n standalone: p.standalone,\n };\n\n const file = installForClient(client, inputs, cwd, p.scope);\n logOut(`Installed \"${serverName}\" for ${client} → ${file}`);\n logOut(\n hostedUrl\n ? ` Mode: http (${hostedUrl})`\n : ` Mode: stdio (npx @agent-native/core@latest mcp serve --app ${appId}${\n p.standalone ? \" --standalone\" : \"\"\n })`,\n );\n logOut(` Restart ${client} to pick up the new MCP server.`);\n}\n\nfunction cmdUninstall(p: ParsedArgs): void {\n const client = normalizeClientId(p.client);\n if (!client) {\n logErr(\n `Usage: npx @agent-native/core@latest mcp uninstall --client ${SELECTABLE_CLIENTS.join(\"|\")} ` +\n `[--app <id>]`,\n );\n process.exit(1);\n }\n const cwd = process.cwd();\n const appId = p.app ?? \"app\";\n const { file, removed } = uninstallForClient(client, appId, cwd, p.scope);\n logOut(\n removed\n ? `Removed \"${serverNameFor(appId)}\" from ${client} → ${file}`\n : `No \"${serverNameFor(appId)}\" entry found for ${client} (${file}) — nothing to do.`,\n );\n}\n\nasync function cmdStatus(): Promise<void> {\n const cwd = process.cwd();\n let appId = \"app\";\n let origin = \"(app not running)\";\n let port: number | undefined;\n try {\n const resolved = await resolveLocalAppOrigin({ cwd });\n appId = resolved.appId;\n origin = resolved.origin;\n const ws = await resolveWorkspace(cwd);\n port = ws.apps.find((a) => a.id === appId)?.port;\n } catch (err: any) {\n logErr(` Could not resolve app: ${err?.message ?? err}`);\n }\n\n const hostedUrl = detectHostedUrl(cwd);\n const baseDir = envBaseDir(cwd);\n const envContent =\n readEnvFile(path.join(baseDir, \".env.local\")) +\n \"\\n\" +\n readEnvFile(path.join(baseDir, \".env\"));\n const hasToken = !!getEnvValue(envContent, \"ACCESS_TOKEN\");\n const hasA2A =\n !!process.env.A2A_SECRET || !!getEnvValue(envContent, \"A2A_SECRET\");\n\n logOut(`Agent-Native MCP status`);\n logOut(` App: ${appId}`);\n logOut(\n hostedUrl\n ? ` MCP URL: ${hostedUrl} (hosted)`\n : ` MCP URL: ${origin}/_agent-native/mcp${\n port ? ` (port ${port})` : \"\"\n }`,\n );\n logOut(` ACCESS_TOKEN: ${hasToken ? \"set\" : \"not set\"} (.env)`);\n logOut(` A2A_SECRET: ${hasA2A ? \"set\" : \"not set\"}`);\n logOut(` Clients:`);\n for (const client of SELECTABLE_CLIENTS) {\n const present = clientHasEntry(client, appId, cwd);\n logOut(` ${client.padEnd(18)} ${present ? \"configured\" : \"—\"}`);\n }\n}\n\nfunction cmdToken(p: ParsedArgs): void {\n const cwd = process.cwd();\n const t = ensureLocalToken(cwd, p.rotate);\n logOut(\n p.rotate\n ? `Rotated ACCESS_TOKEN in ${t.file}`\n : t.created\n ? `Provisioned ACCESS_TOKEN in ${t.file}`\n : `ACCESS_TOKEN (${t.file}):`,\n );\n logOut(t.token);\n if (p.rotate) {\n logOut(\n ` Re-run \\`npx @agent-native/core@latest mcp install --client <c>\\` so client configs ` +\n `pick up the new token.`,\n );\n }\n}\n\nconst HELP = `npx @agent-native/core@latest mcp — connect external coding agents over MCP\n\nUsage:\n npx @agent-native/core@latest mcp serve [--app <id>] [--port <n>] [--standalone]\n Run the MCP stdio transport (what client configs spawn).\n Default: proxy to the running local app; --standalone builds from disk.\n\n npx @agent-native/core@latest mcp install --client <c> [--app <id>] [--scope user|project]\n Provision a token and write the client's MCP config (idempotent).\n Clients: claude-code, codex, cowork, cursor, opencode, github-copilot\n\n npx @agent-native/core@latest mcp uninstall --client <c> [--app <id>]\n Remove the named MCP entry from a client's config (idempotent).\n\n npx @agent-native/core@latest mcp status\n Show resolved MCP URL/port, token state, and per-client entries.\n\n npx @agent-native/core@latest mcp token [--rotate]\n Print (or rotate) the local ACCESS_TOKEN in the workspace .env.`;\n\nexport async function runMcp(args: string[]): Promise<void> {\n const p = parseArgs(args);\n const sub = p._[0];\n\n switch (sub) {\n case \"serve\":\n await cmdServe(p);\n return;\n case \"install\":\n await cmdInstall(p);\n return;\n case \"uninstall\":\n cmdUninstall(p);\n return;\n case \"status\":\n await cmdStatus();\n return;\n case \"token\":\n cmdToken(p);\n return;\n case undefined:\n case \"--help\":\n case \"-h\":\n case \"help\":\n logOut(HELP);\n return;\n default:\n logErr(`Unknown mcp subcommand: ${sub}`);\n logOut(HELP);\n process.exit(1);\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"mcp.js","sourceRoot":"","sources":["../../src/cli/mcp.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,MAAM,MAAM,aAAa,CAAC;AACjC,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,uBAAuB,EAAE,MAAM,+BAA+B,CAAC;AACxE,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EACL,iBAAiB,EACjB,qBAAqB,EACrB,gBAAgB,GACjB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EACL,OAAO,EAEP,mBAAmB,EACnB,oBAAoB,EACpB,0BAA0B,EAC1B,2BAA2B,EAC3B,eAAe,EACf,aAAa,EACb,aAAa,IAAI,mBAAmB,EACpC,wBAAwB,EACxB,eAAe,EACf,eAAe,EACf,0BAA0B,GAC3B,MAAM,yBAAyB,CAAC;AAEjC,MAAM,kBAAkB,GAAG,cAAc,CAAC;AAa1C,SAAS,SAAS,CAAC,IAAc;IAC/B,MAAM,GAAG,GAAe,EAAE,CAAC,EAAE,EAAE,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC;IACpE,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACrC,MAAM,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,MAAM,GAAG,GAAG,CAAC,IAAY,EAAsB,EAAE;YAC/C,IAAI,CAAC,KAAK,IAAI;gBAAE,OAAO,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;YACjC,IAAI,CAAC,CAAC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,MAAM,SAAS,EAAE,CAAC;YAClB,OAAO;QACT,KAAK,OAAO;YACV,QAAQ,CAAC,CAAC,CAAC,CAAC;YACZ,OAAO;QACT,KAAK,SAAS,CAAC;QACf,KAAK,QAAQ,CAAC;QACd,KAAK,IAAI,CAAC;QACV,KAAK,MAAM;YACT,MAAM,CAAC,IAAI,CAAC,CAAC;YACb,OAAO;QACT;YACE,MAAM,CAAC,2BAA2B,GAAG,EAAE,CAAC,CAAC;YACzC,MAAM,CAAC,IAAI,CAAC,CAAC;YACb,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACpB,CAAC;AACH,CAAC","sourcesContent":["/**\n * `agent-native mcp <subcommand>` — connect external coding agents (Claude\n * Code desktop & CLI, Claude Cowork, Codex, Cursor, OpenCode, GitHub Copilot /\n * VS Code) to this agent-native app/workspace over MCP.\n *\n * serve Run the MCP stdio transport (this is what client configs spawn).\n * install Provision a token + write the client's MCP config idempotently.\n * uninstall Remove the named entry from a client's MCP config.\n * status Print resolved MCP URL/port, token state, and per-client entries.\n * token Print or rotate the local ACCESS_TOKEN in the workspace .env.\n *\n * Node-only CLI module. Hand-rolled `.env` upsert + minimal TOML block merge\n * keep this dependency-free (no new npm deps).\n */\n\nimport crypto from \"node:crypto\";\nimport fs from \"node:fs\";\nimport path from \"node:path\";\n\nimport { runScreenMemoryMCPStdio } from \"../mcp/screen-memory-stdio.js\";\nimport { runMCPStdio } from \"../mcp/stdio.js\";\nimport {\n findWorkspaceRoot,\n resolveLocalAppOrigin,\n resolveWorkspace,\n} from \"../mcp/workspace-resolve.js\";\nimport {\n CLIENTS,\n type ClientId,\n buildCodexHttpBlock,\n buildCodexLocalBlock,\n buildHttpMcpEntryForClient,\n buildLocalMcpEntryForClient,\n codexConfigPath,\n codexHasBlock,\n configPathFor as clientConfigPathFor,\n hasJsonMcpEntryForClient,\n writeCodexBlock,\n writeFileAtomic,\n writeJsonMcpEntryForClient,\n} from \"./mcp-config-writers.js\";\n\nconst SERVER_NAME_PREFIX = \"agent-native\";\n\ninterface ParsedArgs {\n _: string[];\n client?: string;\n app?: string;\n port?: number;\n screenMemoryDir?: string;\n scope?: string;\n standalone: boolean;\n rotate: boolean;\n}\n\nfunction parseArgs(argv: string[]): ParsedArgs {\n const out: ParsedArgs = { _: [], standalone: false, rotate: false };\n for (let i = 0; i < argv.length; i++) {\n const a = argv[i];\n const eat = (flag: string): string | undefined => {\n if (a === flag) return argv[++i];\n if (a.startsWith(`${flag}=`)) return a.slice(flag.length + 1);\n return undefined;\n };\n let v: string | undefined;\n if ((v = eat(\"--client\")) !== undefined) out.client = v;\n else if ((v = eat(\"--app\")) !== undefined) out.app = v;\n else if ((v = eat(\"--port\")) !== undefined) out.port = Number(v);\n else if ((v = eat(\"--dir\")) !== undefined) out.screenMemoryDir = v;\n else if ((v = eat(\"--scope\")) !== undefined) out.scope = v;\n else if (a === \"--standalone\") out.standalone = true;\n else if (a === \"--rotate\") out.rotate = true;\n else if (!a.startsWith(\"-\")) out._.push(a);\n }\n return out;\n}\n\nfunction logErr(msg: string): void {\n process.stderr.write(`${msg}\\n`);\n}\nfunction logOut(msg: string): void {\n process.stdout.write(`${msg}\\n`);\n}\n\n// ---------------------------------------------------------------------------\n// .env token provisioning (local dev) — hand-rolled idempotent upsert\n// ---------------------------------------------------------------------------\n\n/** Workspace root (or cwd for a standalone app) — where .env lives. */\nfunction envBaseDir(cwd = process.cwd()): string {\n return findWorkspaceRoot(cwd) ?? path.resolve(cwd);\n}\n\n/** Prefer .env.local, else .env. Returns the path we should write to. */\nfunction envFilePath(baseDir: string): string {\n const local = path.join(baseDir, \".env.local\");\n if (fs.existsSync(local)) return local;\n return path.join(baseDir, \".env\");\n}\n\nfunction readEnvFile(file: string): string {\n try {\n return fs.readFileSync(file, \"utf-8\");\n } catch {\n return \"\";\n }\n}\n\n/** Read a single key from a dotenv-format string (last assignment wins). */\nfunction getEnvValue(content: string, key: string): string | undefined {\n let found: string | undefined;\n for (const line of content.split(/\\r?\\n/)) {\n const m = line.match(/^\\s*([A-Z0-9_]+)\\s*=\\s*(.*)\\s*$/i);\n if (m && m[1] === key) {\n found = m[2].replace(/^[\"']|[\"']$/g, \"\");\n }\n }\n return found;\n}\n\n/**\n * Idempotently set `key=value` in the dotenv file. If the key already exists\n * we leave it untouched unless `force` is set (used by `token --rotate`).\n * Never clobbers an existing token implicitly.\n */\nfunction upsertEnv(\n file: string,\n key: string,\n value: string,\n force = false,\n): { changed: boolean; value: string } {\n const content = readEnvFile(file);\n const existing = getEnvValue(content, key);\n if (existing && !force) return { changed: false, value: existing };\n\n const line = `${key}=${value}`;\n let next: string;\n if (new RegExp(`^\\\\s*${key}\\\\s*=`, \"m\").test(content)) {\n next = content.replace(new RegExp(`^\\\\s*${key}\\\\s*=.*$`, \"m\"), line);\n } else {\n next =\n content.length === 0\n ? `${line}\\n`\n : `${content.replace(/\\n*$/, \"\")}\\n${line}\\n`;\n }\n writeFileAtomic(file, next);\n return { changed: true, value };\n}\n\nfunction generateToken(): string {\n return crypto.randomBytes(24).toString(\"base64url\");\n}\n\n/**\n * Ensure a local ACCESS_TOKEN exists in the workspace .env and return it.\n * Existing tokens are reused (never clobbered). Set `rotate` to replace it.\n */\nfunction ensureLocalToken(\n cwd: string,\n rotate = false,\n): { token: string; file: string; created: boolean } {\n const baseDir = envBaseDir(cwd);\n const file = envFilePath(baseDir);\n const content = readEnvFile(file);\n const existing = getEnvValue(content, \"ACCESS_TOKEN\");\n if (existing && !rotate) {\n return { token: existing, file, created: false };\n }\n const token = generateToken();\n upsertEnv(file, \"ACCESS_TOKEN\", token, true);\n return { token, file, created: true };\n}\n\n// ---------------------------------------------------------------------------\n// Hosted vs local detection\n// ---------------------------------------------------------------------------\n\n/**\n * Detect a hosted deployment URL. When the workspace .env points at a hosted\n * origin (APP_URL / BETTER_AUTH_URL with a non-localhost host) we write an\n * `http` client entry pointing at `<origin>/_agent-native/mcp` with a JWT\n * bearer instead of a stdio entry.\n */\nfunction detectHostedUrl(cwd: string): string | undefined {\n const baseDir = envBaseDir(cwd);\n const content =\n readEnvFile(path.join(baseDir, \".env.local\")) +\n \"\\n\" +\n readEnvFile(path.join(baseDir, \".env\"));\n for (const key of [\"AGENT_NATIVE_MCP_URL\", \"APP_URL\", \"BETTER_AUTH_URL\"]) {\n const v = getEnvValue(content, key);\n if (!v) continue;\n try {\n const u = new URL(v);\n if (!/^(localhost|127\\.0\\.0\\.1|\\[::1\\])$/.test(u.hostname)) {\n return `${u.origin}/_agent-native/mcp`;\n }\n } catch {\n // not a URL — skip\n }\n }\n return undefined;\n}\n\nasync function mintHostedJwt(cwd: string): Promise<string | undefined> {\n // Reuse the existing A2A signer — do not reinvent JWT minting.\n const owner =\n process.env.AGENT_NATIVE_OWNER_EMAIL ||\n process.env.OWNER_EMAIL ||\n \"owner@localhost\";\n let fileA2ASecret: string | undefined;\n if (!process.env.A2A_SECRET) {\n const baseDir = envBaseDir(cwd);\n const content =\n readEnvFile(path.join(baseDir, \".env.local\")) +\n \"\\n\" +\n readEnvFile(path.join(baseDir, \".env\"));\n fileA2ASecret = getEnvValue(content, \"A2A_SECRET\");\n }\n try {\n const { signA2AToken } = await import(\"../a2a/client.js\");\n return await signA2AToken(\n owner,\n undefined,\n process.env.A2A_SECRET || fileA2ASecret,\n {\n preferGlobalSecret: true,\n expiresIn: \"30d\",\n },\n );\n } catch (err: any) {\n logErr(\n ` Could not mint a hosted JWT (${err?.message ?? err}). ` +\n `Set A2A_SECRET in your workspace .env, or use the local stdio entry.`,\n );\n return undefined;\n }\n}\n\n// ---------------------------------------------------------------------------\n// Client config entries\n// ---------------------------------------------------------------------------\n\ninterface ServerEntryInputs {\n serverName: string;\n appId: string;\n token?: string;\n ownerEmail?: string;\n hostedUrl?: string;\n standalone: boolean;\n}\n\nfunction mcpServeArgs(i: ServerEntryInputs): string[] {\n const args = [\"mcp\", \"serve\"];\n if (i.appId) args.push(\"--app\", i.appId);\n if (i.standalone) args.push(\"--standalone\");\n return args;\n}\n\nfunction mcpServeEnv(i: ServerEntryInputs): Record<string, string> {\n const env: Record<string, string> = {};\n if (i.token) env.ACCESS_TOKEN = i.token;\n if (i.ownerEmail) env.AGENT_NATIVE_OWNER_EMAIL = i.ownerEmail;\n return env;\n}\n\nfunction buildJsonServerEntry(\n client: ClientId,\n i: ServerEntryInputs,\n): Record<string, unknown> {\n if (i.hostedUrl) {\n return buildHttpMcpEntryForClient(client, i.hostedUrl, i.token);\n }\n return buildLocalMcpEntryForClient(client, mcpServeArgs(i), mcpServeEnv(i));\n}\n\nfunction buildCodexBlock(name: string, i: ServerEntryInputs): string {\n if (i.hostedUrl) {\n return buildCodexHttpBlock(name, i.hostedUrl, i.token);\n }\n return buildCodexLocalBlock(name, mcpServeArgs(i), mcpServeEnv(i));\n}\n\n// ---------------------------------------------------------------------------\n// Per-client install/uninstall/status\n// ---------------------------------------------------------------------------\n\nfunction configPathFor(\n client: ClientId,\n cwd: string,\n scope: string | undefined,\n): string {\n return clientConfigPathFor(client, envBaseDir(cwd), scope);\n}\n\nfunction serverNameFor(appId: string): string {\n return `${SERVER_NAME_PREFIX}-${appId}`;\n}\n\n// Clients advertised in usage/help and listed by status. Excludes the legacy\n// `claude-code-cli` alias so only a single \"Claude Code\" appears (it is still\n// accepted via --client and collapses to claude-code).\nconst SELECTABLE_CLIENTS: ClientId[] = CLIENTS.filter(\n (c) => c !== \"claude-code-cli\",\n);\n\nfunction normalizeClientId(raw: string | undefined): ClientId | null {\n const value = (raw ?? \"\").toLowerCase();\n if (\n value === \"claude\" ||\n value === \"claude-code-desktop\" ||\n value === \"claude-code-cli\"\n ) {\n return \"claude-code\";\n }\n if (value === \"open-code\") return \"opencode\";\n if (value === \"copilot\" || value === \"vscode\" || value === \"vs-code\") {\n return \"github-copilot\";\n }\n return (CLIENTS as string[]).includes(value) ? (value as ClientId) : null;\n}\n\nfunction installForClient(\n client: ClientId,\n inputs: ServerEntryInputs,\n cwd: string,\n scope: string | undefined,\n): string {\n const name = inputs.serverName;\n const file = configPathFor(client, cwd, scope);\n if (client === \"codex\") {\n writeCodexBlock(file, name, buildCodexBlock(name, inputs));\n } else {\n writeJsonMcpEntryForClient(\n client,\n file,\n name,\n buildJsonServerEntry(client, inputs),\n );\n }\n return file;\n}\n\nfunction uninstallForClient(\n client: ClientId,\n appId: string,\n cwd: string,\n scope: string | undefined,\n): { file: string; removed: boolean } {\n const name = serverNameFor(appId);\n const file = configPathFor(client, cwd, scope);\n if (client === \"codex\") {\n const had = codexHasBlock(file, name);\n if (had) writeCodexBlock(file, name, null);\n return { file, removed: had };\n }\n const had = hasJsonMcpEntryForClient(client, file, name);\n if (had) writeJsonMcpEntryForClient(client, file, name, null);\n return { file, removed: had };\n}\n\nfunction clientHasEntry(client: ClientId, appId: string, cwd: string): boolean {\n const name = serverNameFor(appId);\n if (client === \"codex\") return codexHasBlock(codexConfigPath(), name);\n if (client === \"cowork\") {\n return hasJsonMcpEntryForClient(\n client,\n configPathFor(client, cwd, undefined),\n name,\n );\n }\n return (\n hasJsonMcpEntryForClient(\n client,\n configPathFor(client, cwd, \"project\"),\n name,\n ) ||\n hasJsonMcpEntryForClient(client, configPathFor(client, cwd, \"user\"), name)\n );\n}\n\n// ---------------------------------------------------------------------------\n// Subcommands\n// ---------------------------------------------------------------------------\n\nasync function cmdServe(p: ParsedArgs): Promise<void> {\n await runMCPStdio({\n appId: p.app,\n port: p.port,\n standalone: p.standalone,\n });\n}\n\nasync function cmdInstall(p: ParsedArgs): Promise<void> {\n const client = normalizeClientId(p.client);\n if (!client) {\n logErr(\n `Usage: npx @agent-native/core@latest mcp install --client ${SELECTABLE_CLIENTS.join(\"|\")} ` +\n `[--app <id>] [--scope user|project]`,\n );\n process.exit(1);\n }\n const cwd = process.cwd();\n\n // Resolve which app this entry targets (default = workspace default app).\n let appId = p.app;\n if (!appId) {\n try {\n const resolved = await resolveLocalAppOrigin({ cwd });\n appId = resolved.appId;\n } catch {\n appId = \"app\";\n }\n }\n const serverName = serverNameFor(appId);\n\n const hostedUrl = detectHostedUrl(cwd);\n const ownerEmail = process.env.AGENT_NATIVE_OWNER_EMAIL;\n\n let token: string | undefined;\n if (hostedUrl) {\n token = await mintHostedJwt(cwd);\n logOut(`Detected hosted deployment: ${hostedUrl}`);\n } else {\n const t = ensureLocalToken(cwd, false);\n token = t.token;\n logOut(\n t.created\n ? `Provisioned ACCESS_TOKEN in ${t.file}`\n : `Reusing existing ACCESS_TOKEN from ${t.file}`,\n );\n }\n\n const inputs: ServerEntryInputs = {\n serverName,\n appId: appId!,\n token,\n ownerEmail,\n hostedUrl,\n standalone: p.standalone,\n };\n\n const file = installForClient(client, inputs, cwd, p.scope);\n logOut(`Installed \"${serverName}\" for ${client} → ${file}`);\n logOut(\n hostedUrl\n ? ` Mode: http (${hostedUrl})`\n : ` Mode: stdio (npx @agent-native/core@latest mcp serve --app ${appId}${\n p.standalone ? \" --standalone\" : \"\"\n })`,\n );\n logOut(` Restart ${client} to pick up the new MCP server.`);\n}\n\nfunction cmdUninstall(p: ParsedArgs): void {\n const client = normalizeClientId(p.client);\n if (!client) {\n logErr(\n `Usage: npx @agent-native/core@latest mcp uninstall --client ${SELECTABLE_CLIENTS.join(\"|\")} ` +\n `[--app <id>]`,\n );\n process.exit(1);\n }\n const cwd = process.cwd();\n const appId = p.app ?? \"app\";\n const { file, removed } = uninstallForClient(client, appId, cwd, p.scope);\n logOut(\n removed\n ? `Removed \"${serverNameFor(appId)}\" from ${client} → ${file}`\n : `No \"${serverNameFor(appId)}\" entry found for ${client} (${file}) — nothing to do.`,\n );\n}\n\nasync function cmdStatus(): Promise<void> {\n const cwd = process.cwd();\n let appId = \"app\";\n let origin = \"(app not running)\";\n let port: number | undefined;\n try {\n const resolved = await resolveLocalAppOrigin({ cwd });\n appId = resolved.appId;\n origin = resolved.origin;\n const ws = await resolveWorkspace(cwd);\n port = ws.apps.find((a) => a.id === appId)?.port;\n } catch (err: any) {\n logErr(` Could not resolve app: ${err?.message ?? err}`);\n }\n\n const hostedUrl = detectHostedUrl(cwd);\n const baseDir = envBaseDir(cwd);\n const envContent =\n readEnvFile(path.join(baseDir, \".env.local\")) +\n \"\\n\" +\n readEnvFile(path.join(baseDir, \".env\"));\n const hasToken = !!getEnvValue(envContent, \"ACCESS_TOKEN\");\n const hasA2A =\n !!process.env.A2A_SECRET || !!getEnvValue(envContent, \"A2A_SECRET\");\n\n logOut(`Agent-Native MCP status`);\n logOut(` App: ${appId}`);\n logOut(\n hostedUrl\n ? ` MCP URL: ${hostedUrl} (hosted)`\n : ` MCP URL: ${origin}/_agent-native/mcp${\n port ? ` (port ${port})` : \"\"\n }`,\n );\n logOut(` ACCESS_TOKEN: ${hasToken ? \"set\" : \"not set\"} (.env)`);\n logOut(` A2A_SECRET: ${hasA2A ? \"set\" : \"not set\"}`);\n logOut(` Clients:`);\n for (const client of SELECTABLE_CLIENTS) {\n const present = clientHasEntry(client, appId, cwd);\n logOut(` ${client.padEnd(18)} ${present ? \"configured\" : \"—\"}`);\n }\n}\n\nfunction cmdToken(p: ParsedArgs): void {\n const cwd = process.cwd();\n const t = ensureLocalToken(cwd, p.rotate);\n logOut(\n p.rotate\n ? `Rotated ACCESS_TOKEN in ${t.file}`\n : t.created\n ? `Provisioned ACCESS_TOKEN in ${t.file}`\n : `ACCESS_TOKEN (${t.file}):`,\n );\n logOut(t.token);\n if (p.rotate) {\n logOut(\n ` Re-run \\`npx @agent-native/core@latest mcp install --client <c>\\` so client configs ` +\n `pick up the new token.`,\n );\n }\n}\n\nconst HELP = `npx @agent-native/core@latest mcp — connect external coding agents over MCP\n\nUsage:\n npx @agent-native/core@latest mcp serve [--app <id>] [--port <n>] [--standalone]\n Run the MCP stdio transport (what client configs spawn).\n Default: proxy to the running local app; --standalone builds from disk.\n\n npx @agent-native/core@latest mcp screen-memory [--dir <path>]\n Run the local Clips Screen Memory stdio server.\n Defaults to the Clips app-data screen-memory folder.\n\n npx @agent-native/core@latest mcp install --client <c> [--app <id>] [--scope user|project]\n Provision a token and write the client's MCP config (idempotent).\n Clients: claude-code, codex, cowork, cursor, opencode, github-copilot\n\n npx @agent-native/core@latest mcp uninstall --client <c> [--app <id>]\n Remove the named MCP entry from a client's config (idempotent).\n\n npx @agent-native/core@latest mcp status\n Show resolved MCP URL/port, token state, and per-client entries.\n\n npx @agent-native/core@latest mcp token [--rotate]\n Print (or rotate) the local ACCESS_TOKEN in the workspace .env.`;\n\nexport async function runMcp(args: string[]): Promise<void> {\n const p = parseArgs(args);\n const sub = p._[0];\n\n switch (sub) {\n case \"serve\":\n await cmdServe(p);\n return;\n case \"screen-memory\":\n await runScreenMemoryMCPStdio({ storeDir: p.screenMemoryDir });\n return;\n case \"install\":\n await cmdInstall(p);\n return;\n case \"uninstall\":\n cmdUninstall(p);\n return;\n case \"status\":\n await cmdStatus();\n return;\n case \"token\":\n cmdToken(p);\n return;\n case undefined:\n case \"--help\":\n case \"-h\":\n case \"help\":\n logOut(HELP);\n return;\n default:\n logErr(`Unknown mcp subcommand: ${sub}`);\n logOut(HELP);\n process.exit(1);\n }\n}\n"]}
|
package/dist/cli/skills.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"skills.d.ts","sourceRoot":"","sources":["../../src/cli/skills.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AASH,OAAO,EAKL,KAAK,gBAAgB,EAEtB,MAAM,gBAAgB,CAAC;AAUxB,OAAO,EAAW,KAAK,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAGjE,OAAO,EAAsB,KAAK,YAAY,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"skills.d.ts","sourceRoot":"","sources":["../../src/cli/skills.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AASH,OAAO,EAKL,KAAK,gBAAgB,EAEtB,MAAM,gBAAgB,CAAC;AAUxB,OAAO,EAAW,KAAK,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAGjE,OAAO,EAAsB,KAAK,YAAY,EAAE,MAAM,gBAAgB,CAA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gB,CA8GhE;AAkiBD,wBAAsB,mBAAmB,CACvC,MAAM,EAAE,gBAAgB,EACxB,OAAO,GAAE,gBAAqB,GAC7B,OAAO,CAAC,eAAe,CAAC,CA6Y1B;AA2QD,wBAAsB,SAAS,CAC7B,IAAI,EAAE,MAAM,EAAE,EACd,OAAO,GAAE,gBAAqB,GAC7B,OAAO,CAAC,IAAI,CAAC,CA8Zf"}
|
package/dist/cli/skills.js
CHANGED
|
@@ -303,17 +303,18 @@ iteration, or a human-in-the-loop choice among design directions.
|
|
|
303
303
|
- Use \`create-design\` first to create a project shell. Do not report the
|
|
304
304
|
design as ready until it has renderable HTML.
|
|
305
305
|
- For open-ended UX exploration, generate distinct, complete HTML directions
|
|
306
|
-
(2-5, three by default) and call \`present-design-variants\`.
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
306
|
+
(2-5, three by default) and call \`present-design-variants\`. Design saves
|
|
307
|
+
every option as a normal screen on the overview board and renders an inline
|
|
308
|
+
chat choice with one button per screen name. After the user picks, delete the
|
|
309
|
+
unchosen variant screens and continue from the kept screen.
|
|
310
|
+
- If the chat choice buttons are not available in the host, ask the user to
|
|
311
|
+
tell you the screen name they prefer. The variants are already real screens
|
|
312
|
+
on the board, so do not ask them to paste HTML or copy a generated handoff
|
|
313
|
+
summary.
|
|
314
314
|
- For direct refinements to an already chosen direction, call
|
|
315
|
-
\`get-design-snapshot\`, edit from the current tuned HTML,
|
|
316
|
-
\`generate-design
|
|
315
|
+
\`get-design-snapshot\`, edit from the current tuned HTML, and use
|
|
316
|
+
\`edit-design\` for surgical changes. Use \`generate-design\` for new files
|
|
317
|
+
or larger structural rewrites.
|
|
317
318
|
- Use \`export-coding-handoff\` when the user wants to implement the chosen
|
|
318
319
|
design in a codebase.
|
|
319
320
|
|
|
@@ -327,8 +328,29 @@ iteration, or a human-in-the-loop choice among design directions.
|
|
|
327
328
|
4. For product UI redesigns, prefer cleaner hierarchy, progressive disclosure,
|
|
328
329
|
and realistic controls over decorative mockups.
|
|
329
330
|
5. After \`present-design-variants\`, wait for the user's pick before
|
|
330
|
-
generating the next version.
|
|
331
|
-
|
|
331
|
+
generating the next version. Keep the chosen screen, delete the other
|
|
332
|
+
variant screens, then refine that direction with \`generate-design\` or
|
|
333
|
+
\`edit-design\`.
|
|
334
|
+
|
|
335
|
+
## Design Quality Bar
|
|
336
|
+
|
|
337
|
+
- Before generating, name the concrete audience, the screen's primary job, and
|
|
338
|
+
the visual thesis. If the brief is vague, make a reasonable choice and state
|
|
339
|
+
it instead of producing a generic dashboard/landing-page default.
|
|
340
|
+
- For existing products, inspect the current screen, design system, tokens,
|
|
341
|
+
component language, or codebase context before inventing a new direction.
|
|
342
|
+
- Make each direction distinct in structure and behavior, not just palette.
|
|
343
|
+
Give every variant one memorable signature choice, then keep the surrounding
|
|
344
|
+
chrome disciplined.
|
|
345
|
+
- Treat copy, data, and imagery as design material. Use realistic domain
|
|
346
|
+
content and first-party/generated assets when images matter; avoid lorem
|
|
347
|
+
ipsum, vague SaaS filler, and decorative placeholder boxes.
|
|
348
|
+
- Build to a quiet quality floor: responsive desktop/mobile layout, visible
|
|
349
|
+
keyboard focus, useful loading/empty/error states for app UI, and reduced
|
|
350
|
+
motion support when custom motion is present.
|
|
351
|
+
- After broad generation or refinement, inspect the rendered Design surface or
|
|
352
|
+
a screenshot-capable host before calling it ready. Fix obvious hierarchy,
|
|
353
|
+
overflow, contrast, broken interaction, and placeholder-content issues first.
|
|
332
354
|
|
|
333
355
|
## Cross-App Use
|
|
334
356
|
|
|
@@ -361,6 +383,8 @@ name: visual-edit
|
|
|
361
383
|
description: >-
|
|
362
384
|
Open a running local app in Design overview mode as URL-backed iframe screens
|
|
363
385
|
for visual editing, flow review, duplication, and route-state exploration.
|
|
386
|
+
Use when the user asks to inspect, compare, or edit a real local app visually
|
|
387
|
+
in Design.
|
|
364
388
|
metadata:
|
|
365
389
|
visibility: exported
|
|
366
390
|
---
|
|
@@ -388,6 +412,28 @@ iframe-backed screens on the infinite canvas.
|
|
|
388
412
|
\`localhost:1234/onboarding/1\` means
|
|
389
413
|
\`http://localhost:1234/onboarding/1\`.
|
|
390
414
|
|
|
415
|
+
## Review Quality
|
|
416
|
+
|
|
417
|
+
- Treat the running app as the truth. Preserve its component language, tokens,
|
|
418
|
+
route state, and real content unless the user explicitly asks for a new visual
|
|
419
|
+
direction.
|
|
420
|
+
- Use multiple URL states to reveal meaningful UX moments: empty/loading/error
|
|
421
|
+
states, focused panels, modals, responsive breakpoints, and completed flow
|
|
422
|
+
steps when those matter to the review.
|
|
423
|
+
- For visual edits, compare before/after at the relevant viewport sizes and
|
|
424
|
+
check key hover/focus/scroll states when the app exposes them.
|
|
425
|
+
|
|
426
|
+
## Account And Sharing Model
|
|
427
|
+
|
|
428
|
+
- The \`/visual-edit\` entry route can open before the viewer signs in. Public
|
|
429
|
+
\`/design/:id\` editor links can also render read-only public designs without a
|
|
430
|
+
session.
|
|
431
|
+
- Do not attempt anonymous write actions. Bridge registration, design creation,
|
|
432
|
+
screen placement, generation, saving, and sharing are account-backed. If a
|
|
433
|
+
signed-out visitor wants to save or share, send them through the framework
|
|
434
|
+
sign-in return flow, then save or copy the design into that account before
|
|
435
|
+
opening the share dialog.
|
|
436
|
+
|
|
391
437
|
## Required Local Bridge
|
|
392
438
|
|
|
393
439
|
From the target app repo, make sure its dev server is running, then run:
|
|
@@ -3023,26 +3069,40 @@ function latestSkillBundlesForTargets(appSkillIds) {
|
|
|
3023
3069
|
return out;
|
|
3024
3070
|
}
|
|
3025
3071
|
function writeSkillFolder(dir, bundle, installedAt = new Date().toISOString()) {
|
|
3026
|
-
|
|
3027
|
-
|
|
3028
|
-
|
|
3029
|
-
|
|
3030
|
-
fs.mkdirSync(
|
|
3031
|
-
|
|
3032
|
-
|
|
3033
|
-
|
|
3034
|
-
|
|
3035
|
-
|
|
3036
|
-
|
|
3037
|
-
|
|
3038
|
-
|
|
3039
|
-
|
|
3040
|
-
|
|
3041
|
-
|
|
3042
|
-
|
|
3043
|
-
|
|
3044
|
-
|
|
3045
|
-
|
|
3072
|
+
const parent = path.dirname(dir);
|
|
3073
|
+
const tempDir = path.join(parent, `.${path.basename(dir)}.${process.pid}.${Date.now()}.tmp`);
|
|
3074
|
+
try {
|
|
3075
|
+
fs.rmSync(tempDir, { recursive: true, force: true });
|
|
3076
|
+
fs.mkdirSync(tempDir, { recursive: true });
|
|
3077
|
+
for (const [rel, content] of Object.entries(bundle.files)) {
|
|
3078
|
+
const target = path.join(tempDir, rel);
|
|
3079
|
+
fs.mkdirSync(path.dirname(target), { recursive: true });
|
|
3080
|
+
fs.writeFileSync(target, content, "utf-8");
|
|
3081
|
+
}
|
|
3082
|
+
const metadata = {
|
|
3083
|
+
schemaVersion: 1,
|
|
3084
|
+
source: "agent-native",
|
|
3085
|
+
appSkillId: bundle.appSkillId,
|
|
3086
|
+
displayName: bundle.displayName,
|
|
3087
|
+
skillName: bundle.skillName,
|
|
3088
|
+
contentHash: bundle.contentHash,
|
|
3089
|
+
mcpUrl: bundle.mcpUrl,
|
|
3090
|
+
installedAt,
|
|
3091
|
+
installCommand: `npx @agent-native/core@latest skills add ${bundle.skillName}`,
|
|
3092
|
+
updateCommand: `npx @agent-native/core@latest skills update ${bundle.skillName}`,
|
|
3093
|
+
...(bundle.planMode ? { planMode: bundle.planMode } : {}),
|
|
3094
|
+
};
|
|
3095
|
+
fs.writeFileSync(path.join(tempDir, AGENT_NATIVE_SKILL_METADATA_FILE), `${JSON.stringify(metadata, null, 2)}\n`, "utf-8");
|
|
3096
|
+
fs.rmSync(dir, { recursive: true, force: true });
|
|
3097
|
+
fs.renameSync(tempDir, dir);
|
|
3098
|
+
}
|
|
3099
|
+
catch (error) {
|
|
3100
|
+
try {
|
|
3101
|
+
fs.rmSync(tempDir, { recursive: true, force: true });
|
|
3102
|
+
}
|
|
3103
|
+
catch { }
|
|
3104
|
+
throw new Error(`Cannot write Agent Native skill folder ${dir}: ${error?.message ?? error}`, { cause: error });
|
|
3105
|
+
}
|
|
3046
3106
|
}
|
|
3047
3107
|
function isJsonRecord(value) {
|
|
3048
3108
|
return Boolean(value && typeof value === "object" && !Array.isArray(value));
|
|
@@ -5321,7 +5381,9 @@ function runSkillsStatusOrUpdate(parsed, options, update) {
|
|
|
5321
5381
|
const target = parsed.target ? ` for ${parsed.target}` : "";
|
|
5322
5382
|
const hint = isScaffoldGuidanceTarget(parsed.target)
|
|
5323
5383
|
? `Run this from a generated Agent Native app or workspace root.\n`
|
|
5324
|
-
:
|
|
5384
|
+
: update
|
|
5385
|
+
? `The update command only refreshes skill folders that already exist; it does not do first-time install, MCP registration, or auth. Run "npx @agent-native/core@latest skills add ${parsed.target ?? "visual-plan"}" for one-step setup.\n`
|
|
5386
|
+
: `Run "npx @agent-native/core@latest skills add ${parsed.target ?? "visual-plan"}" to install one.\n`;
|
|
5325
5387
|
process.stdout.write(`No installed Agent Native skill copies found${target}.\n${hint}`);
|
|
5326
5388
|
return;
|
|
5327
5389
|
}
|