@agent-native/core 0.91.2 → 0.92.1
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 +31 -0
- package/corpus/core/docs/content/faq.mdx +17 -0
- package/corpus/core/docs/content/notifications.mdx +12 -6
- package/corpus/core/package.json +1 -1
- package/corpus/core/src/agent/production-agent.ts +140 -46
- package/corpus/core/src/agent/tool-search.ts +71 -4
- package/corpus/core/src/application-state/store.ts +12 -1
- package/corpus/core/src/cli/index.ts +20 -0
- package/corpus/core/src/cli/upgrade.ts +798 -0
- package/corpus/core/src/client/AssistantChat.tsx +28 -15
- package/corpus/core/src/client/HighlightedCodeBlock.tsx +20 -3
- package/corpus/core/src/client/PoweredByBadge.tsx +1 -8
- package/corpus/core/src/client/agent-chat-adapter.ts +68 -16
- package/corpus/core/src/client/chat/message-components.tsx +85 -8
- package/corpus/core/src/client/chat/tool-call-display.tsx +355 -144
- package/corpus/core/src/client/chat/widgets/DataTableWidget.tsx +52 -1
- package/corpus/core/src/client/code-agent-chat-adapter.ts +2 -9
- package/corpus/core/src/client/db-admin/TableEditor.tsx +49 -0
- package/corpus/core/src/client/db-admin/export-utils.ts +13 -4
- package/corpus/core/src/client/db-admin/useAgentSync.ts +72 -0
- package/corpus/core/src/client/error-capture.ts +69 -7
- package/corpus/core/src/client/extensions/EmbeddedExtension.tsx +5 -1
- package/corpus/core/src/client/extensions/ExtensionViewer.tsx +53 -8
- package/corpus/core/src/client/extensions/InlineExtensionFrame.tsx +5 -1
- package/corpus/core/src/client/extensions/portable-extension.ts +1 -0
- package/corpus/core/src/client/org/OrgSwitcher.tsx +12 -9
- package/corpus/core/src/client/org/TeamPage.tsx +77 -71
- package/corpus/core/src/client/session-replay.ts +3 -97
- package/corpus/core/src/client/settings/SettingsPanel.tsx +738 -441
- package/corpus/core/src/client/settings/SettingsSection.tsx +161 -17
- package/corpus/core/src/client/settings/SettingsTabsPage.tsx +25 -9
- package/corpus/core/src/client/sse-event-processor.ts +29 -2
- package/corpus/core/src/db-admin/agent-tools.ts +8 -2
- package/corpus/core/src/db-admin/operations.ts +116 -4
- package/corpus/core/src/db-admin/routes.ts +1 -0
- package/corpus/core/src/db-admin/types.ts +4 -0
- package/corpus/core/src/extensions/actions.ts +113 -5
- package/corpus/core/src/extensions/html-shell.ts +5 -4
- package/corpus/core/src/extensions/routes.ts +10 -0
- package/corpus/core/src/navigation/index.ts +1 -1
- package/corpus/core/src/notifications/channels.ts +88 -25
- package/corpus/core/src/notifications/registry.ts +17 -3
- package/corpus/core/src/notifications/types.ts +4 -1
- package/corpus/core/src/resources/handlers.ts +10 -8
- package/corpus/core/src/server/agent-chat-plugin.ts +7 -3
- package/corpus/core/src/server/poll.ts +293 -8
- package/corpus/core/src/server/request-context.ts +7 -0
- package/corpus/core/src/styles/agent-conversation.css +1 -1
- package/corpus/core/src/styles/agent-native.css +27 -0
- package/corpus/core/src/templates/default/.agents/skills/actions/SKILL.md +5 -0
- package/corpus/core/src/templates/default/.agents/skills/adding-a-feature/SKILL.md +5 -0
- package/corpus/core/src/templates/default/.agents/skills/real-time-sync/SKILL.md +1 -1
- package/corpus/core/src/templates/default/.agents/skills/security/SKILL.md +7 -0
- package/corpus/core/src/templates/default/.agents/skills/self-modifying-code/SKILL.md +20 -2
- package/corpus/core/src/templates/default/.agents/skills/storing-data/SKILL.md +5 -1
- package/corpus/core/src/templates/default/.agents/skills/upgrade-agent-native/SKILL.md +87 -0
- package/corpus/core/src/templates/default/AGENTS.md +14 -5
- package/corpus/core/src/templates/default/package.json +2 -1
- package/corpus/core/src/templates/headless/.agents/skills/upgrade-agent-native/SKILL.md +87 -0
- package/corpus/core/src/templates/headless/AGENTS.md +13 -3
- package/corpus/core/src/templates/headless/package.json +1 -0
- package/corpus/core/src/templates/workspace-core/.agents/skills/actions/SKILL.md +5 -0
- package/corpus/core/src/templates/workspace-core/.agents/skills/adding-a-feature/SKILL.md +5 -0
- package/corpus/core/src/templates/workspace-core/.agents/skills/context-awareness/SKILL.md +4 -0
- package/corpus/core/src/templates/workspace-core/.agents/skills/extensions/SKILL.md +6 -0
- package/corpus/core/src/templates/workspace-core/.agents/skills/performance/SKILL.md +4 -0
- package/corpus/core/src/templates/workspace-core/.agents/skills/real-time-sync/SKILL.md +1 -1
- package/corpus/core/src/templates/workspace-core/.agents/skills/security/SKILL.md +7 -0
- package/corpus/core/src/templates/workspace-core/.agents/skills/self-modifying-code/SKILL.md +20 -2
- package/corpus/core/src/templates/workspace-core/.agents/skills/storing-data/SKILL.md +5 -1
- package/corpus/core/src/templates/workspace-core/.agents/skills/upgrade-agent-native/SKILL.md +87 -0
- package/corpus/core/src/templates/workspace-core/AGENTS.md +7 -1
- package/corpus/core/src/templates/workspace-root/AGENTS.md +17 -5
- package/corpus/core/src/templates/workspace-root/package.json +1 -0
- package/corpus/templates/analytics/.agents/skills/actions/SKILL.md +5 -0
- package/corpus/templates/analytics/.agents/skills/dashboard-management/SKILL.md +10 -0
- package/corpus/templates/analytics/.agents/skills/real-time-sync/SKILL.md +1 -1
- package/corpus/templates/analytics/.agents/skills/security/SKILL.md +7 -0
- package/corpus/templates/analytics/.agents/skills/self-modifying-code/SKILL.md +20 -2
- package/corpus/templates/analytics/.agents/skills/session-replay/SKILL.md +5 -6
- package/corpus/templates/analytics/.agents/skills/storing-data/SKILL.md +5 -1
- package/corpus/templates/analytics/.agents/skills/upgrade-agent-native/SKILL.md +87 -0
- package/corpus/templates/analytics/AGENTS.md +39 -18
- package/corpus/templates/analytics/actions/capture-test-error.ts +4 -0
- package/corpus/templates/analytics/actions/get-analytics-alert-rule-defaults.ts +23 -0
- package/corpus/templates/analytics/actions/get-error-issue.ts +1 -1
- package/corpus/templates/analytics/actions/list-analysis-revisions.ts +40 -0
- package/corpus/templates/analytics/actions/list-dashboard-revisions.ts +40 -0
- package/corpus/templates/analytics/actions/list-dashboard-usage-stats.ts +299 -0
- package/corpus/templates/analytics/actions/navigate.ts +4 -2
- package/corpus/templates/analytics/actions/restore-analysis-revision.ts +43 -0
- package/corpus/templates/analytics/actions/restore-dashboard-revision.ts +68 -0
- package/corpus/templates/analytics/actions/save-analytics-alert-rule.ts +14 -0
- package/corpus/templates/analytics/actions/save-monitor.ts +15 -1
- package/corpus/templates/analytics/actions/view-screen.ts +24 -0
- package/corpus/templates/analytics/app/components/analysis/AnalysisHistoryPanel.tsx +181 -0
- package/corpus/templates/analytics/app/components/dashboard/DashboardHistoryPanel.tsx +184 -0
- package/corpus/templates/analytics/app/components/dashboard/DataTable.tsx +41 -6
- package/corpus/templates/analytics/app/components/dashboard/SqlChart.tsx +122 -11
- package/corpus/templates/analytics/app/components/layout/CommandPalette.tsx +22 -16
- package/corpus/templates/analytics/app/components/layout/Header.tsx +1 -1
- package/corpus/templates/analytics/app/components/layout/Sidebar.tsx +27 -21
- package/corpus/templates/analytics/app/hooks/use-analysis-revisions.ts +43 -0
- package/corpus/templates/analytics/app/hooks/use-dashboard-chat-context.ts +110 -0
- package/corpus/templates/analytics/app/hooks/use-dashboard-revisions.ts +43 -0
- package/corpus/templates/analytics/app/hooks/use-navigation-state.ts +8 -3
- package/corpus/templates/analytics/app/i18n/zh-TW.ts +64 -2
- package/corpus/templates/analytics/app/i18n-data.ts +783 -3
- package/corpus/templates/analytics/app/pages/Agents.tsx +359 -19
- package/corpus/templates/analytics/app/pages/Settings.tsx +3 -2
- package/corpus/templates/analytics/app/pages/adhoc/explorer-dashboard/index.tsx +34 -1
- package/corpus/templates/analytics/app/pages/adhoc/sql-dashboard/index.tsx +28 -0
- package/corpus/templates/analytics/app/pages/analyses/AnalysisDetail.tsx +18 -1
- package/corpus/templates/analytics/app/pages/monitoring/ErrorsPanel.tsx +7 -10
- package/corpus/templates/analytics/app/pages/monitoring/MonitoringPage.tsx +8 -2
- package/corpus/templates/analytics/app/pages/monitoring/errors/IssueDetail.tsx +479 -23
- package/corpus/templates/analytics/app/pages/monitoring/errors/IssueList.tsx +0 -9
- package/corpus/templates/analytics/app/pages/monitoring/errors/i18n.ts +11 -0
- package/corpus/templates/analytics/app/pages/monitoring/errors/types.ts +9 -1
- package/corpus/templates/analytics/app/pages/monitoring/uptime/MonitorFormPage.tsx +157 -35
- package/corpus/templates/analytics/app/pages/monitoring/uptime/i18n.ts +17 -2
- package/corpus/templates/analytics/app/pages/monitoring/uptime/types.ts +4 -0
- package/corpus/templates/analytics/app/pages/sessions/SessionDetailPage.tsx +80 -220
- package/corpus/templates/analytics/app/pages/sessions/SessionsPage.tsx +9 -99
- package/corpus/templates/analytics/app/pages/settings/AlertRulesSettingsCard.tsx +262 -104
- package/corpus/templates/analytics/app/routes/team.tsx +1 -1
- package/corpus/templates/analytics/changelog/2026-07-08-admins-can-audit-dashboard-usage-ownership-and-cleanup-signa.md +6 -0
- package/corpus/templates/analytics/changelog/2026-07-08-agent-monitoring-stays-available-to-non-admins.md +6 -0
- package/corpus/templates/analytics/changelog/2026-07-08-alert-rules-are-easier-to-scan-expand-and-edit-from-settings.md +6 -0
- package/corpus/templates/analytics/changelog/2026-07-08-analytics-alert-forms-remember-last-email-recipients.md +6 -0
- package/corpus/templates/analytics/changelog/2026-07-08-analytics-alert-rules-can-now-use-per-rule-slack-and-webhook.md +6 -0
- package/corpus/templates/analytics/changelog/2026-07-08-dashboard-history-and-chat-context.md +5 -0
- package/corpus/templates/analytics/changelog/2026-07-08-dashboard-tables-keep-their-size-while-loading.md +6 -0
- package/corpus/templates/analytics/changelog/2026-07-08-dashboard-usage-now-counts-explorer-dashboard-traffic.md +6 -0
- package/corpus/templates/analytics/changelog/2026-07-08-demo-mode-session-emails-are-filtered-and-anonymized.md +6 -0
- package/corpus/templates/analytics/changelog/2026-07-08-error-issue-detail-adds-stack-traces-and-frequency-bars.md +6 -0
- package/corpus/templates/analytics/changelog/2026-07-08-error-issue-detail-now-shows-the-latest-occurrence-message-a.md +6 -0
- package/corpus/templates/analytics/changelog/2026-07-08-monitoring-errors-only-show-test-action-when-empty.md +6 -0
- package/corpus/templates/analytics/changelog/2026-07-08-monitoring-uptime-and-errors-tabs-now-clearly-show-which-view-is-active.md +6 -0
- package/corpus/templates/analytics/changelog/2026-07-08-production-session-replay-now-requires-private-blob-storage-.md +6 -0
- package/corpus/templates/analytics/changelog/2026-07-08-session-replay-uses-stock-rrweb-sizing-again-so-recorded.md +6 -0
- package/corpus/templates/analytics/changelog/2026-07-08-shared-extension-links-now-show-a-clear-message-when-you-do-.md +6 -0
- package/corpus/templates/analytics/changelog/2026-07-08-sidebar-dashboard-menus-now-open-above-the-dashboard-canvas.md +6 -0
- package/corpus/templates/analytics/changelog/2026-07-08-team-settings-show-access-controls-next-to-member-lists.md +6 -0
- package/corpus/templates/analytics/changelog/2026-07-08-uptime-alerting-clarifies-in-app-inbox-vs-email-and-lets-you-paste-slack-or-webhook-urls-per-monitor.md +6 -0
- package/corpus/templates/analytics/changelog/2026-07-08-uptime-monitors-now-use-a-10-second-request-timeout-by-defau.md +6 -0
- package/corpus/templates/analytics/docs/uptime-monitoring.md +13 -11
- package/corpus/templates/analytics/server/db/schema-monitoring.ts +5 -1
- package/corpus/templates/analytics/server/db/schema.ts +56 -0
- package/corpus/templates/analytics/server/lib/analytics-alerts.ts +92 -0
- package/corpus/templates/analytics/server/lib/dashboards-store.ts +334 -5
- package/corpus/templates/analytics/server/lib/error-capture.ts +231 -36
- package/corpus/templates/analytics/server/lib/session-replay.ts +114 -8
- package/corpus/templates/analytics/server/lib/uptime-monitors.ts +65 -16
- package/corpus/templates/analytics/server/plugins/db.ts +122 -2
- package/corpus/templates/analytics/server/routes/api/dashboard-agent-context.json.get.ts +1 -0
- package/corpus/templates/assets/.agents/skills/actions/SKILL.md +5 -0
- package/corpus/templates/assets/.agents/skills/real-time-sync/SKILL.md +1 -1
- package/corpus/templates/assets/.agents/skills/security/SKILL.md +7 -0
- package/corpus/templates/assets/.agents/skills/self-modifying-code/SKILL.md +20 -2
- package/corpus/templates/assets/.agents/skills/storing-data/SKILL.md +5 -1
- package/corpus/templates/assets/.agents/skills/upgrade-agent-native/SKILL.md +87 -0
- package/corpus/templates/assets/AGENTS.md +4 -0
- package/corpus/templates/assets/app/routes/settings.tsx +1 -1
- package/corpus/templates/assets/app/routes/team.tsx +1 -1
- package/corpus/templates/brain/.agents/skills/actions/SKILL.md +5 -0
- package/corpus/templates/brain/.agents/skills/adding-a-feature/SKILL.md +5 -0
- package/corpus/templates/brain/.agents/skills/real-time-sync/SKILL.md +1 -1
- package/corpus/templates/brain/.agents/skills/security/SKILL.md +7 -0
- package/corpus/templates/brain/.agents/skills/self-modifying-code/SKILL.md +20 -2
- package/corpus/templates/brain/.agents/skills/upgrade-agent-native/SKILL.md +87 -0
- package/corpus/templates/brain/AGENTS.md +4 -0
- package/corpus/templates/brain/app/routes/team.tsx +1 -1
- package/corpus/templates/calendar/.agents/skills/actions/SKILL.md +5 -0
- package/corpus/templates/calendar/.agents/skills/real-time-sync/SKILL.md +1 -1
- package/corpus/templates/calendar/.agents/skills/security/SKILL.md +7 -0
- package/corpus/templates/calendar/.agents/skills/self-modifying-code/SKILL.md +20 -2
- package/corpus/templates/calendar/.agents/skills/storing-data/SKILL.md +5 -1
- package/corpus/templates/calendar/.agents/skills/upgrade-agent-native/SKILL.md +87 -0
- package/corpus/templates/calendar/AGENTS.md +4 -0
- package/corpus/templates/calendar/app/components/calendar/DayView.tsx +11 -2
- package/corpus/templates/calendar/app/components/calendar/EventDetailPopover.tsx +21 -8
- package/corpus/templates/calendar/app/components/calendar/MonthView.tsx +7 -1
- package/corpus/templates/calendar/app/components/calendar/WeekView.tsx +11 -2
- package/corpus/templates/calendar/app/lib/popover-click-guard.ts +48 -4
- package/corpus/templates/calendar/app/pages/Settings.tsx +1 -1
- package/corpus/templates/calendar/app/routes/_app.team.tsx +1 -1
- package/corpus/templates/calendar/changelog/2026-07-08-clicking-empty-calendar-space-closes-an-open-event-popover-b.md +6 -0
- package/corpus/templates/chat/.agents/skills/actions/SKILL.md +5 -0
- package/corpus/templates/chat/.agents/skills/adding-a-feature/SKILL.md +5 -0
- package/corpus/templates/chat/.agents/skills/real-time-sync/SKILL.md +1 -1
- package/corpus/templates/chat/.agents/skills/security/SKILL.md +7 -0
- package/corpus/templates/chat/.agents/skills/self-modifying-code/SKILL.md +20 -2
- package/corpus/templates/chat/.agents/skills/upgrade-agent-native/SKILL.md +87 -0
- package/corpus/templates/chat/AGENTS.md +4 -0
- package/corpus/templates/chat/app/hooks/use-navigation-state.ts +1 -1
- package/corpus/templates/chat/app/routes/settings.tsx +2 -2
- package/corpus/templates/chat/app/routes/team.tsx +1 -1
- package/corpus/templates/clips/.agents/skills/actions/SKILL.md +5 -0
- package/corpus/templates/clips/.agents/skills/security/SKILL.md +7 -0
- package/corpus/templates/clips/.agents/skills/self-modifying-code/SKILL.md +20 -2
- package/corpus/templates/clips/.agents/skills/upgrade-agent-native/SKILL.md +87 -0
- package/corpus/templates/clips/AGENTS.md +4 -0
- package/corpus/templates/clips/actions/finalize-recording.ts +9 -3
- package/corpus/templates/clips/actions/set-thumbnail.ts +11 -2
- package/corpus/templates/clips/app/components/meetings/canvas-editor.tsx +1 -7
- package/corpus/templates/clips/app/components/player/player-controls.tsx +21 -13
- package/corpus/templates/clips/app/components/player/video-player.tsx +30 -75
- package/corpus/templates/clips/app/i18n/ar-SA.ts +6 -5
- package/corpus/templates/clips/app/i18n/de-DE.ts +6 -6
- package/corpus/templates/clips/app/i18n/en-US.ts +6 -5
- package/corpus/templates/clips/app/i18n/es-ES.ts +6 -5
- package/corpus/templates/clips/app/i18n/fr-FR.ts +6 -6
- package/corpus/templates/clips/app/i18n/hi-IN.ts +6 -5
- package/corpus/templates/clips/app/i18n/ja-JP.ts +6 -5
- package/corpus/templates/clips/app/i18n/ko-KR.ts +6 -5
- package/corpus/templates/clips/app/i18n/pt-BR.ts +6 -5
- package/corpus/templates/clips/app/i18n/zh-CN.ts +6 -5
- package/corpus/templates/clips/app/i18n/zh-TW.ts +6 -5
- package/corpus/templates/clips/app/routes/_app.meetings.$meetingId.tsx +51 -118
- package/corpus/templates/clips/changelog/2026-07-08-desktop-meeting-notes-stay-active-from-tray-and-shortcut-controls.md +6 -0
- package/corpus/templates/clips/changelog/2026-07-08-desktop-meeting-popovers-can-start-notes-and-join-the-meetin.md +6 -0
- package/corpus/templates/clips/changelog/2026-07-08-hosted-clip-uploads-now-clear-failed-buffered-chunks.md +6 -0
- package/corpus/templates/clips/changelog/2026-07-08-hosted-recording-uploads-now-avoid-sql-chunk-storage.md +6 -0
- package/corpus/templates/clips/changelog/2026-07-08-meeting-notes-keep-their-recording-state-when-the-desktop.md +6 -0
- package/corpus/templates/clips/changelog/2026-07-08-meeting-recaps-now-keep-summaries-action-items-and-transcrip.md +6 -0
- package/corpus/templates/clips/changelog/2026-07-08-meeting-reminder-dropdowns-now-expand-fully-instead-of-being.md +6 -0
- package/corpus/templates/clips/changelog/2026-07-08-video-playback-controls-now-match-loom-style-5-second-skips-.md +6 -0
- package/corpus/templates/clips/desktop/src/app.tsx +123 -3
- package/corpus/templates/clips/desktop/src/hooks/useMeetingTranscription.ts +15 -1
- package/corpus/templates/clips/desktop/src/overlays/meeting-notification.tsx +23 -0
- package/corpus/templates/clips/desktop/src/styles.css +23 -1
- package/corpus/templates/clips/desktop/src-tauri/src/adhoc_meetings_watcher.rs +1 -3
- package/corpus/templates/clips/desktop/src-tauri/src/clips/mod.rs +40 -6
- package/corpus/templates/clips/desktop/src-tauri/src/lib.rs +4 -2
- package/corpus/templates/clips/desktop/src-tauri/src/meetings_watcher.rs +3 -5
- package/corpus/templates/clips/desktop/src-tauri/src/native_screen.rs +23 -19
- package/corpus/templates/clips/desktop/src-tauri/src/shortcuts.rs +3 -3
- package/corpus/templates/clips/desktop/src-tauri/src/silence_detector.rs +0 -1
- package/corpus/templates/clips/desktop/src-tauri/src/state.rs +5 -0
- package/corpus/templates/clips/desktop/src-tauri/src/tray.rs +18 -6
- package/corpus/templates/clips/server/lib/recording-upload-state.ts +63 -0
- package/corpus/templates/clips/server/lib/video-storage.ts +4 -0
- package/corpus/templates/clips/server/routes/api/recordings/[recordingId]/thumbnail.post.ts +19 -13
- package/corpus/templates/clips/server/routes/api/uploads/[recordingId]/chunk.post.ts +40 -1
- package/corpus/templates/content/.agents/skills/actions/SKILL.md +5 -0
- package/corpus/templates/content/.agents/skills/real-time-sync/SKILL.md +1 -1
- package/corpus/templates/content/.agents/skills/security/SKILL.md +7 -0
- package/corpus/templates/content/.agents/skills/self-modifying-code/SKILL.md +20 -2
- package/corpus/templates/content/.agents/skills/storing-data/SKILL.md +5 -1
- package/corpus/templates/content/.agents/skills/upgrade-agent-native/SKILL.md +87 -0
- package/corpus/templates/content/AGENTS.md +4 -0
- package/corpus/templates/content/actions/_batch-utils.ts +8 -0
- package/corpus/templates/content/actions/_builder-cms-read-client.ts +7 -5
- package/corpus/templates/content/actions/_database-source-utils.ts +776 -319
- package/corpus/templates/content/actions/_database-utils.ts +6 -1
- package/corpus/templates/content/actions/_property-utils.ts +168 -0
- package/corpus/templates/content/actions/add-content-database-source-field-property.ts +19 -12
- package/corpus/templates/content/actions/bind-content-database-source-field.ts +19 -12
- package/corpus/templates/content/actions/delete-document.ts +9 -13
- package/corpus/templates/content/actions/refresh-content-database-source.ts +5 -5
- package/corpus/templates/content/app/components/editor/body-hydration.ts +35 -11
- package/corpus/templates/content/app/components/editor/database/DatabaseView.tsx +47 -5
- package/corpus/templates/content/app/hooks/use-documents.ts +8 -2
- package/corpus/templates/content/app/routes/_app.settings.tsx +2 -2
- package/corpus/templates/content/app/routes/_app.team.tsx +1 -1
- package/corpus/templates/content/changelog/2026-07-08-builder-source-sync-now-completes-reliably-on-hosted-databases.md +6 -0
- package/corpus/templates/content/changelog/2026-07-08-fixed-builder-database-sync-so-large-sources-continue-past-t.md +6 -0
- package/corpus/templates/content/server/plugins/db.ts +19 -0
- package/corpus/templates/design/.agents/skills/actions/SKILL.md +5 -0
- package/corpus/templates/design/.agents/skills/security/SKILL.md +7 -0
- package/corpus/templates/design/.agents/skills/self-modifying-code/SKILL.md +20 -2
- package/corpus/templates/design/.agents/skills/upgrade-agent-native/SKILL.md +87 -0
- package/corpus/templates/design/AGENTS.md +4 -0
- package/corpus/templates/design/actions/take-design-screenshot.ts +12 -9
- package/corpus/templates/design/app/components/design/inspector/ImageFillControls.tsx +57 -13
- package/corpus/templates/design/app/routes/team.tsx +1 -1
- package/corpus/templates/design/changelog/2026-07-08-local-images-added-to-designs-now-upload-to-file-storage-ins.md +6 -0
- package/corpus/templates/dispatch/.agents/skills/actions/SKILL.md +5 -0
- package/corpus/templates/dispatch/.agents/skills/security/SKILL.md +7 -0
- package/corpus/templates/dispatch/.agents/skills/self-modifying-code/SKILL.md +20 -2
- package/corpus/templates/dispatch/.agents/skills/upgrade-agent-native/SKILL.md +87 -0
- package/corpus/templates/dispatch/AGENTS.md +4 -0
- package/corpus/templates/dispatch/app/hooks/use-navigation-state.ts +1 -1
- package/corpus/templates/dispatch/app/routes/settings.tsx +2 -2
- package/corpus/templates/dispatch/app/routes/team.tsx +1 -1
- package/corpus/templates/forms/.agents/skills/actions/SKILL.md +5 -0
- package/corpus/templates/forms/.agents/skills/real-time-sync/SKILL.md +1 -1
- package/corpus/templates/forms/.agents/skills/security/SKILL.md +7 -0
- package/corpus/templates/forms/.agents/skills/self-modifying-code/SKILL.md +20 -2
- package/corpus/templates/forms/.agents/skills/storing-data/SKILL.md +5 -1
- package/corpus/templates/forms/.agents/skills/upgrade-agent-native/SKILL.md +87 -0
- package/corpus/templates/forms/AGENTS.md +4 -0
- package/corpus/templates/forms/app/routes/_app.settings.tsx +2 -2
- package/corpus/templates/forms/app/routes/_app.team.tsx +1 -1
- package/corpus/templates/forms/shared/navigation.ts +1 -1
- package/corpus/templates/macros/.agents/skills/security/SKILL.md +7 -0
- package/corpus/templates/macros/.agents/skills/upgrade-agent-native/SKILL.md +87 -0
- package/corpus/templates/macros/AGENTS.md +4 -0
- package/corpus/templates/macros/app/routes/settings.tsx +2 -2
- package/corpus/templates/macros/app/routes/team.tsx +1 -1
- package/corpus/templates/mail/.agents/skills/actions/SKILL.md +5 -0
- package/corpus/templates/mail/.agents/skills/email-drafts/SKILL.md +1 -1
- package/corpus/templates/mail/.agents/skills/real-time-sync/SKILL.md +1 -1
- package/corpus/templates/mail/.agents/skills/security/SKILL.md +7 -0
- package/corpus/templates/mail/.agents/skills/self-modifying-code/SKILL.md +20 -2
- package/corpus/templates/mail/.agents/skills/storing-data/SKILL.md +5 -1
- package/corpus/templates/mail/.agents/skills/upgrade-agent-native/SKILL.md +87 -0
- package/corpus/templates/mail/AGENTS.md +4 -0
- package/corpus/templates/mail/changelog/2026-07-08-mail-attachments-in-hosted-environments-now-require-file-sto.md +6 -0
- package/corpus/templates/mail/server/handlers/media.ts +26 -1
- package/corpus/templates/mail/server/lib/outgoing-email.ts +24 -1
- package/corpus/templates/mail/server/lib/upload-store.ts +2 -1
- package/corpus/templates/plan/.agents/skills/actions/SKILL.md +5 -0
- package/corpus/templates/plan/.agents/skills/adding-a-feature/SKILL.md +5 -0
- package/corpus/templates/plan/.agents/skills/real-time-sync/SKILL.md +1 -1
- package/corpus/templates/plan/.agents/skills/security/SKILL.md +7 -0
- package/corpus/templates/plan/.agents/skills/self-modifying-code/SKILL.md +20 -2
- package/corpus/templates/plan/.agents/skills/upgrade-agent-native/SKILL.md +87 -0
- package/corpus/templates/plan/AGENTS.md +4 -0
- package/corpus/templates/plan/app/hooks/use-navigation-state.ts +1 -1
- package/corpus/templates/plan/app/routes/settings.tsx +2 -2
- package/corpus/templates/plan/app/routes/team.tsx +1 -1
- package/corpus/templates/plan/changelog/2026-07-08-hosted-plan-images-now-require-connected-storage.md +6 -0
- package/corpus/templates/plan/server/lib/plan-assets.ts +33 -4
- package/corpus/templates/slides/.agents/skills/actions/SKILL.md +5 -0
- package/corpus/templates/slides/.agents/skills/security/SKILL.md +7 -0
- package/corpus/templates/slides/.agents/skills/self-modifying-code/SKILL.md +20 -2
- package/corpus/templates/slides/.agents/skills/upgrade-agent-native/SKILL.md +87 -0
- package/corpus/templates/slides/AGENTS.md +4 -0
- package/corpus/templates/slides/actions/generate-image-api.ts +15 -3
- package/corpus/templates/slides/app/routes/settings.tsx +2 -2
- package/corpus/templates/slides/app/routes/team.tsx +1 -1
- package/corpus/templates/slides/changelog/2026-07-08-generated-slide-images-now-return-hosted-file-storage-urls-i.md +6 -0
- package/corpus/templates/slides/shared/api.ts +1 -1
- package/corpus/templates/videos/.agents/skills/upgrade-agent-native/SKILL.md +87 -0
- package/corpus/templates/voice/.agents/skills/upgrade-agent-native/SKILL.md +87 -0
- package/dist/agent/production-agent.d.ts +5 -1
- package/dist/agent/production-agent.d.ts.map +1 -1
- package/dist/agent/production-agent.js +112 -42
- package/dist/agent/production-agent.js.map +1 -1
- package/dist/agent/tool-search.d.ts +2 -0
- package/dist/agent/tool-search.d.ts.map +1 -1
- package/dist/agent/tool-search.js +60 -4
- package/dist/agent/tool-search.js.map +1 -1
- package/dist/application-state/store.d.ts.map +1 -1
- package/dist/application-state/store.js +8 -2
- package/dist/application-state/store.js.map +1 -1
- package/dist/cli/index.js +19 -0
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/upgrade.d.ts +100 -0
- package/dist/cli/upgrade.d.ts.map +1 -0
- package/dist/cli/upgrade.js +678 -0
- package/dist/cli/upgrade.js.map +1 -0
- package/dist/client/AssistantChat.d.ts.map +1 -1
- package/dist/client/AssistantChat.js +25 -14
- package/dist/client/AssistantChat.js.map +1 -1
- package/dist/client/HighlightedCodeBlock.d.ts +2 -0
- package/dist/client/HighlightedCodeBlock.d.ts.map +1 -1
- package/dist/client/HighlightedCodeBlock.js +10 -1
- package/dist/client/HighlightedCodeBlock.js.map +1 -1
- package/dist/client/PoweredByBadge.d.ts +1 -1
- package/dist/client/PoweredByBadge.d.ts.map +1 -1
- package/dist/client/PoweredByBadge.js +3 -9
- package/dist/client/PoweredByBadge.js.map +1 -1
- package/dist/client/agent-chat-adapter.d.ts.map +1 -1
- package/dist/client/agent-chat-adapter.js +60 -13
- package/dist/client/agent-chat-adapter.js.map +1 -1
- package/dist/client/chat/message-components.d.ts.map +1 -1
- package/dist/client/chat/message-components.js +61 -8
- package/dist/client/chat/message-components.js.map +1 -1
- package/dist/client/chat/tool-call-display.d.ts +12 -0
- package/dist/client/chat/tool-call-display.d.ts.map +1 -1
- package/dist/client/chat/tool-call-display.js +136 -42
- package/dist/client/chat/tool-call-display.js.map +1 -1
- package/dist/client/chat/widgets/DataTableWidget.d.ts.map +1 -1
- package/dist/client/chat/widgets/DataTableWidget.js +19 -2
- package/dist/client/chat/widgets/DataTableWidget.js.map +1 -1
- package/dist/client/code-agent-chat-adapter.js +2 -9
- package/dist/client/code-agent-chat-adapter.js.map +1 -1
- package/dist/client/db-admin/TableEditor.d.ts.map +1 -1
- package/dist/client/db-admin/TableEditor.js +19 -2
- package/dist/client/db-admin/TableEditor.js.map +1 -1
- package/dist/client/db-admin/export-utils.d.ts +2 -0
- package/dist/client/db-admin/export-utils.d.ts.map +1 -1
- package/dist/client/db-admin/export-utils.js +11 -3
- package/dist/client/db-admin/export-utils.js.map +1 -1
- package/dist/client/db-admin/useAgentSync.d.ts.map +1 -1
- package/dist/client/db-admin/useAgentSync.js +63 -0
- package/dist/client/db-admin/useAgentSync.js.map +1 -1
- package/dist/client/error-capture.d.ts.map +1 -1
- package/dist/client/error-capture.js +41 -7
- package/dist/client/error-capture.js.map +1 -1
- package/dist/client/extensions/EmbeddedExtension.d.ts.map +1 -1
- package/dist/client/extensions/EmbeddedExtension.js +3 -1
- package/dist/client/extensions/EmbeddedExtension.js.map +1 -1
- package/dist/client/extensions/ExtensionViewer.d.ts.map +1 -1
- package/dist/client/extensions/ExtensionViewer.js +32 -5
- package/dist/client/extensions/ExtensionViewer.js.map +1 -1
- package/dist/client/extensions/InlineExtensionFrame.d.ts.map +1 -1
- package/dist/client/extensions/InlineExtensionFrame.js +3 -1
- package/dist/client/extensions/InlineExtensionFrame.js.map +1 -1
- package/dist/client/extensions/portable-extension.d.ts.map +1 -1
- package/dist/client/extensions/portable-extension.js +1 -0
- package/dist/client/extensions/portable-extension.js.map +1 -1
- package/dist/client/org/OrgSwitcher.d.ts +1 -1
- package/dist/client/org/OrgSwitcher.d.ts.map +1 -1
- package/dist/client/org/OrgSwitcher.js +11 -6
- package/dist/client/org/OrgSwitcher.js.map +1 -1
- package/dist/client/org/TeamPage.d.ts.map +1 -1
- package/dist/client/org/TeamPage.js +5 -5
- package/dist/client/org/TeamPage.js.map +1 -1
- package/dist/client/session-replay.d.ts +0 -8
- package/dist/client/session-replay.d.ts.map +1 -1
- package/dist/client/session-replay.js +3 -80
- package/dist/client/session-replay.js.map +1 -1
- package/dist/client/settings/SettingsPanel.d.ts.map +1 -1
- package/dist/client/settings/SettingsPanel.js +89 -33
- package/dist/client/settings/SettingsPanel.js.map +1 -1
- package/dist/client/settings/SettingsSection.d.ts +19 -4
- package/dist/client/settings/SettingsSection.d.ts.map +1 -1
- package/dist/client/settings/SettingsSection.js +33 -4
- package/dist/client/settings/SettingsSection.js.map +1 -1
- package/dist/client/settings/SettingsTabsPage.d.ts.map +1 -1
- package/dist/client/settings/SettingsTabsPage.js +21 -10
- package/dist/client/settings/SettingsTabsPage.js.map +1 -1
- package/dist/client/sse-event-processor.d.ts +9 -0
- package/dist/client/sse-event-processor.d.ts.map +1 -1
- package/dist/client/sse-event-processor.js +20 -2
- package/dist/client/sse-event-processor.js.map +1 -1
- package/dist/db-admin/agent-tools.d.ts.map +1 -1
- package/dist/db-admin/agent-tools.js +7 -2
- package/dist/db-admin/agent-tools.js.map +1 -1
- package/dist/db-admin/operations.d.ts.map +1 -1
- package/dist/db-admin/operations.js +90 -4
- package/dist/db-admin/operations.js.map +1 -1
- package/dist/db-admin/routes.d.ts.map +1 -1
- package/dist/db-admin/routes.js +1 -0
- package/dist/db-admin/routes.js.map +1 -1
- package/dist/db-admin/types.d.ts +4 -0
- package/dist/db-admin/types.d.ts.map +1 -1
- package/dist/db-admin/types.js.map +1 -1
- package/dist/extensions/actions.d.ts.map +1 -1
- package/dist/extensions/actions.js +85 -5
- package/dist/extensions/actions.js.map +1 -1
- package/dist/extensions/html-shell.d.ts +5 -4
- package/dist/extensions/html-shell.d.ts.map +1 -1
- package/dist/extensions/html-shell.js.map +1 -1
- package/dist/extensions/routes.d.ts.map +1 -1
- package/dist/extensions/routes.js +8 -0
- package/dist/extensions/routes.js.map +1 -1
- package/dist/navigation/index.d.ts +1 -1
- package/dist/navigation/index.d.ts.map +1 -1
- package/dist/navigation/index.js +1 -1
- package/dist/navigation/index.js.map +1 -1
- package/dist/notifications/channels.d.ts +8 -3
- package/dist/notifications/channels.d.ts.map +1 -1
- package/dist/notifications/channels.js +61 -22
- package/dist/notifications/channels.js.map +1 -1
- package/dist/notifications/registry.d.ts.map +1 -1
- package/dist/notifications/registry.js +14 -3
- package/dist/notifications/registry.js.map +1 -1
- package/dist/notifications/types.d.ts +4 -1
- package/dist/notifications/types.d.ts.map +1 -1
- package/dist/notifications/types.js.map +1 -1
- package/dist/resources/handlers.d.ts +5 -0
- package/dist/resources/handlers.d.ts.map +1 -1
- package/dist/resources/handlers.js +9 -8
- package/dist/resources/handlers.js.map +1 -1
- package/dist/server/agent-chat-plugin.d.ts +5 -1
- package/dist/server/agent-chat-plugin.d.ts.map +1 -1
- package/dist/server/agent-chat-plugin.js +2 -2
- 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/poll.d.ts +12 -4
- package/dist/server/poll.d.ts.map +1 -1
- package/dist/server/poll.js +236 -9
- package/dist/server/poll.js.map +1 -1
- package/dist/server/request-context.d.ts +7 -0
- package/dist/server/request-context.d.ts.map +1 -1
- package/dist/server/request-context.js.map +1 -1
- package/dist/styles/agent-conversation.css +1 -1
- package/dist/styles/agent-native.css +27 -0
- package/dist/templates/default/.agents/skills/actions/SKILL.md +5 -0
- package/dist/templates/default/.agents/skills/adding-a-feature/SKILL.md +5 -0
- package/dist/templates/default/.agents/skills/real-time-sync/SKILL.md +1 -1
- package/dist/templates/default/.agents/skills/security/SKILL.md +7 -0
- package/dist/templates/default/.agents/skills/self-modifying-code/SKILL.md +20 -2
- package/dist/templates/default/.agents/skills/storing-data/SKILL.md +5 -1
- package/dist/templates/default/.agents/skills/upgrade-agent-native/SKILL.md +87 -0
- package/dist/templates/default/AGENTS.md +14 -5
- package/dist/templates/default/package.json +2 -1
- package/dist/templates/headless/.agents/skills/upgrade-agent-native/SKILL.md +87 -0
- package/dist/templates/headless/AGENTS.md +13 -3
- package/dist/templates/headless/package.json +1 -0
- package/dist/templates/workspace-core/.agents/skills/actions/SKILL.md +5 -0
- package/dist/templates/workspace-core/.agents/skills/adding-a-feature/SKILL.md +5 -0
- package/dist/templates/workspace-core/.agents/skills/context-awareness/SKILL.md +4 -0
- package/dist/templates/workspace-core/.agents/skills/extensions/SKILL.md +6 -0
- package/dist/templates/workspace-core/.agents/skills/performance/SKILL.md +4 -0
- package/dist/templates/workspace-core/.agents/skills/real-time-sync/SKILL.md +1 -1
- package/dist/templates/workspace-core/.agents/skills/security/SKILL.md +7 -0
- package/dist/templates/workspace-core/.agents/skills/self-modifying-code/SKILL.md +20 -2
- package/dist/templates/workspace-core/.agents/skills/storing-data/SKILL.md +5 -1
- package/dist/templates/workspace-core/.agents/skills/upgrade-agent-native/SKILL.md +87 -0
- package/dist/templates/workspace-core/AGENTS.md +7 -1
- package/dist/templates/workspace-root/AGENTS.md +17 -5
- package/dist/templates/workspace-root/package.json +1 -0
- package/docs/content/faq.mdx +17 -0
- package/docs/content/notifications.mdx +12 -6
- package/package.json +2 -2
- package/src/templates/default/.agents/skills/actions/SKILL.md +5 -0
- package/src/templates/default/.agents/skills/adding-a-feature/SKILL.md +5 -0
- package/src/templates/default/.agents/skills/real-time-sync/SKILL.md +1 -1
- package/src/templates/default/.agents/skills/security/SKILL.md +7 -0
- package/src/templates/default/.agents/skills/self-modifying-code/SKILL.md +20 -2
- package/src/templates/default/.agents/skills/storing-data/SKILL.md +5 -1
- package/src/templates/default/.agents/skills/upgrade-agent-native/SKILL.md +87 -0
- package/src/templates/default/AGENTS.md +14 -5
- package/src/templates/default/package.json +2 -1
- package/src/templates/headless/.agents/skills/upgrade-agent-native/SKILL.md +87 -0
- package/src/templates/headless/AGENTS.md +13 -3
- package/src/templates/headless/package.json +1 -0
- package/src/templates/workspace-core/.agents/skills/actions/SKILL.md +5 -0
- package/src/templates/workspace-core/.agents/skills/adding-a-feature/SKILL.md +5 -0
- package/src/templates/workspace-core/.agents/skills/context-awareness/SKILL.md +4 -0
- package/src/templates/workspace-core/.agents/skills/extensions/SKILL.md +6 -0
- package/src/templates/workspace-core/.agents/skills/performance/SKILL.md +4 -0
- package/src/templates/workspace-core/.agents/skills/real-time-sync/SKILL.md +1 -1
- package/src/templates/workspace-core/.agents/skills/security/SKILL.md +7 -0
- package/src/templates/workspace-core/.agents/skills/self-modifying-code/SKILL.md +20 -2
- package/src/templates/workspace-core/.agents/skills/storing-data/SKILL.md +5 -1
- package/src/templates/workspace-core/.agents/skills/upgrade-agent-native/SKILL.md +87 -0
- package/src/templates/workspace-core/AGENTS.md +7 -1
- package/src/templates/workspace-root/AGENTS.md +17 -5
- package/src/templates/workspace-root/package.json +1 -0
- package/corpus/templates/analytics/changelog/2026-07-08-session-replay-clamps-ultra-wide-viewports-while-keeping-the.md +0 -6
|
@@ -0,0 +1,798 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `agent-native upgrade` — bring an existing Agent Native app/workspace current.
|
|
3
|
+
*
|
|
4
|
+
* Older branches often break after a core bump. Agents then invent
|
|
5
|
+
* `pnpm.overrides` / patches against `@agent-native/*` (especially dispatch),
|
|
6
|
+
* which makes things worse. This command is the supported path:
|
|
7
|
+
*
|
|
8
|
+
* 1. Doctor: refuse or warn on framework overrides/patches
|
|
9
|
+
* 2. Bump `@agent-native/*` deps to `latest` (unless file:/link:/workspace:)
|
|
10
|
+
* 3. Install
|
|
11
|
+
* 4. Refresh scaffold skills (`skills update scaffold --project`)
|
|
12
|
+
* 5. Verify with typecheck when available
|
|
13
|
+
*
|
|
14
|
+
* On failure: print the error and stop. Do not patch framework packages.
|
|
15
|
+
*/
|
|
16
|
+
import { spawnSync, type SpawnSyncReturns } from "node:child_process";
|
|
17
|
+
import fs from "node:fs";
|
|
18
|
+
import path from "node:path";
|
|
19
|
+
import { fileURLToPath } from "node:url";
|
|
20
|
+
|
|
21
|
+
const AGENT_NATIVE_SCOPE = "@agent-native/";
|
|
22
|
+
const PINNABLE_VERSION = "latest";
|
|
23
|
+
|
|
24
|
+
export type UpgradeCommand = "run" | "check" | "help";
|
|
25
|
+
|
|
26
|
+
export interface UpgradeCliOptions {
|
|
27
|
+
command: UpgradeCommand;
|
|
28
|
+
cwd?: string;
|
|
29
|
+
dryRun?: boolean;
|
|
30
|
+
skipInstall?: boolean;
|
|
31
|
+
skipVerify?: boolean;
|
|
32
|
+
skipSkills?: boolean;
|
|
33
|
+
json?: boolean;
|
|
34
|
+
help?: boolean;
|
|
35
|
+
/** Force past doctor findings that would otherwise block (not recommended). */
|
|
36
|
+
force?: boolean;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export interface PackageJsonLike {
|
|
40
|
+
name?: string;
|
|
41
|
+
version?: string;
|
|
42
|
+
dependencies?: Record<string, string>;
|
|
43
|
+
devDependencies?: Record<string, string>;
|
|
44
|
+
optionalDependencies?: Record<string, string>;
|
|
45
|
+
peerDependencies?: Record<string, string>;
|
|
46
|
+
pnpm?: {
|
|
47
|
+
overrides?: Record<string, string>;
|
|
48
|
+
patchedDependencies?: Record<string, string>;
|
|
49
|
+
};
|
|
50
|
+
overrides?: Record<string, string>;
|
|
51
|
+
resolutions?: Record<string, string>;
|
|
52
|
+
scripts?: Record<string, string>;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export interface FrameworkOverrideFinding {
|
|
56
|
+
file: string;
|
|
57
|
+
field: string;
|
|
58
|
+
key: string;
|
|
59
|
+
value: string;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export interface AgentNativeDepBump {
|
|
63
|
+
file: string;
|
|
64
|
+
section: "dependencies" | "devDependencies" | "optionalDependencies";
|
|
65
|
+
name: string;
|
|
66
|
+
from: string;
|
|
67
|
+
to: string;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export interface UpgradeProject {
|
|
71
|
+
root: string;
|
|
72
|
+
kind: "standalone" | "workspace";
|
|
73
|
+
packageFiles: string[];
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export interface UpgradeDoctorReport {
|
|
77
|
+
project: UpgradeProject;
|
|
78
|
+
findings: FrameworkOverrideFinding[];
|
|
79
|
+
bumps: AgentNativeDepBump[];
|
|
80
|
+
installedCoreVersion: string | null;
|
|
81
|
+
cliCoreVersion: string | null;
|
|
82
|
+
scaffoldStaleHint: boolean;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export interface UpgradeRunResult {
|
|
86
|
+
ok: boolean;
|
|
87
|
+
dryRun: boolean;
|
|
88
|
+
doctor: UpgradeDoctorReport;
|
|
89
|
+
steps: Array<{
|
|
90
|
+
id: string;
|
|
91
|
+
status: "ok" | "skipped" | "failed" | "planned";
|
|
92
|
+
detail?: string;
|
|
93
|
+
}>;
|
|
94
|
+
message: string;
|
|
95
|
+
exitCode: number;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export interface UpgradeIo {
|
|
99
|
+
log: (message: string) => void;
|
|
100
|
+
err: (message: string) => void;
|
|
101
|
+
spawn: (
|
|
102
|
+
command: string,
|
|
103
|
+
args: string[],
|
|
104
|
+
options: { cwd: string; stdio?: "inherit" | "pipe" },
|
|
105
|
+
) => SpawnSyncReturns<string | Buffer>;
|
|
106
|
+
runSkillsUpdate: (cwd: string) => Promise<void>;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
const defaultIo: UpgradeIo = {
|
|
110
|
+
log: (message) => console.log(message),
|
|
111
|
+
err: (message) => console.error(message),
|
|
112
|
+
spawn: (command, args, options) =>
|
|
113
|
+
spawnSync(command, args, {
|
|
114
|
+
cwd: options.cwd,
|
|
115
|
+
stdio: options.stdio ?? "inherit",
|
|
116
|
+
encoding: "utf-8",
|
|
117
|
+
shell: process.platform === "win32",
|
|
118
|
+
}),
|
|
119
|
+
runSkillsUpdate: async (cwd) => {
|
|
120
|
+
const { runSkills } = await import("./skills.js");
|
|
121
|
+
const previous = process.cwd();
|
|
122
|
+
process.chdir(cwd);
|
|
123
|
+
try {
|
|
124
|
+
await runSkills(["update", "scaffold", "--project"]);
|
|
125
|
+
} finally {
|
|
126
|
+
process.chdir(previous);
|
|
127
|
+
}
|
|
128
|
+
},
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
export function parseUpgradeArgs(argv: string[]): UpgradeCliOptions {
|
|
132
|
+
const opts: UpgradeCliOptions = { command: "run" };
|
|
133
|
+
for (let i = 0; i < argv.length; i++) {
|
|
134
|
+
const arg = argv[i];
|
|
135
|
+
if (arg === "check" || arg === "doctor") {
|
|
136
|
+
opts.command = "check";
|
|
137
|
+
} else if (arg === "help" || arg === "--help" || arg === "-h") {
|
|
138
|
+
opts.command = "help";
|
|
139
|
+
opts.help = true;
|
|
140
|
+
} else if (arg === "--dry-run") {
|
|
141
|
+
opts.dryRun = true;
|
|
142
|
+
} else if (arg === "--skip-install") {
|
|
143
|
+
opts.skipInstall = true;
|
|
144
|
+
} else if (arg === "--skip-verify") {
|
|
145
|
+
opts.skipVerify = true;
|
|
146
|
+
} else if (arg === "--skip-skills") {
|
|
147
|
+
opts.skipSkills = true;
|
|
148
|
+
} else if (arg === "--json") {
|
|
149
|
+
opts.json = true;
|
|
150
|
+
} else if (arg === "--force") {
|
|
151
|
+
opts.force = true;
|
|
152
|
+
} else if (arg === "--cwd" && argv[i + 1]) {
|
|
153
|
+
opts.cwd = argv[++i];
|
|
154
|
+
} else if (arg.startsWith("--cwd=")) {
|
|
155
|
+
opts.cwd = arg.slice("--cwd=".length);
|
|
156
|
+
} else if (!arg.startsWith("-")) {
|
|
157
|
+
// Ignore unknown positional for forward-compat; help covers usage.
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
return opts;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
export function printUpgradeHelp(io: Pick<UpgradeIo, "log"> = defaultIo): void {
|
|
164
|
+
io.log(
|
|
165
|
+
[
|
|
166
|
+
"Usage:",
|
|
167
|
+
" agent-native upgrade Bring this app/workspace to current @agent-native/*",
|
|
168
|
+
" agent-native upgrade check Doctor only: overrides, patches, pending bumps",
|
|
169
|
+
" agent-native upgrade --dry-run Show the plan without writing or installing",
|
|
170
|
+
"",
|
|
171
|
+
"Options:",
|
|
172
|
+
" --skip-install Bump package.json only; do not run the package manager",
|
|
173
|
+
" --skip-skills Skip `skills update scaffold --project`",
|
|
174
|
+
" --skip-verify Skip typecheck after upgrade",
|
|
175
|
+
" --force Continue even when framework overrides/patches are present",
|
|
176
|
+
" --json Machine-readable report",
|
|
177
|
+
" --cwd <dir> Run against a project root other than the current directory",
|
|
178
|
+
"",
|
|
179
|
+
"On failure: report the error and stop. Do NOT add pnpm.overrides,",
|
|
180
|
+
"patchedDependencies, or local patches against @agent-native/* packages.",
|
|
181
|
+
"Do NOT edit node_modules/@agent-native/* or invent dispatch/core behavior",
|
|
182
|
+
"overrides. Revert those changes and re-run `agent-native upgrade`.",
|
|
183
|
+
].join("\n"),
|
|
184
|
+
);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
function readJsonFile(filePath: string): PackageJsonLike | null {
|
|
188
|
+
try {
|
|
189
|
+
return JSON.parse(fs.readFileSync(filePath, "utf-8")) as PackageJsonLike;
|
|
190
|
+
} catch {
|
|
191
|
+
return null;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
function writeJsonFile(filePath: string, value: PackageJsonLike): void {
|
|
196
|
+
fs.writeFileSync(filePath, `${JSON.stringify(value, null, 2)}\n`);
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
export function isAgentNativePackageName(name: string): boolean {
|
|
200
|
+
return name === "@agent-native" || name.startsWith(AGENT_NATIVE_SCOPE);
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
export function isPinnedOrLocalVersion(version: string): boolean {
|
|
204
|
+
const v = version.trim();
|
|
205
|
+
return (
|
|
206
|
+
v.startsWith("file:") ||
|
|
207
|
+
v.startsWith("link:") ||
|
|
208
|
+
v.startsWith("workspace:") ||
|
|
209
|
+
v.startsWith("portal:") ||
|
|
210
|
+
v.startsWith("git+") ||
|
|
211
|
+
v.startsWith("github:") ||
|
|
212
|
+
v.startsWith("http:") ||
|
|
213
|
+
v.startsWith("https:")
|
|
214
|
+
);
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
export function shouldBumpAgentNativeVersion(version: string): boolean {
|
|
218
|
+
if (isPinnedOrLocalVersion(version)) return false;
|
|
219
|
+
return version.trim() !== PINNABLE_VERSION;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
function collectOverrideFindings(
|
|
223
|
+
file: string,
|
|
224
|
+
pkg: PackageJsonLike,
|
|
225
|
+
): FrameworkOverrideFinding[] {
|
|
226
|
+
const findings: FrameworkOverrideFinding[] = [];
|
|
227
|
+
const tables: Array<{
|
|
228
|
+
field: string;
|
|
229
|
+
map: Record<string, string> | undefined;
|
|
230
|
+
}> = [
|
|
231
|
+
{ field: "pnpm.overrides", map: pkg.pnpm?.overrides },
|
|
232
|
+
{ field: "pnpm.patchedDependencies", map: pkg.pnpm?.patchedDependencies },
|
|
233
|
+
{ field: "overrides", map: pkg.overrides },
|
|
234
|
+
{ field: "resolutions", map: pkg.resolutions },
|
|
235
|
+
];
|
|
236
|
+
for (const table of tables) {
|
|
237
|
+
if (!table.map) continue;
|
|
238
|
+
for (const [key, value] of Object.entries(table.map)) {
|
|
239
|
+
// Keys may be bare (`@agent-native/core`) or versioned
|
|
240
|
+
// (`@agent-native/core@1.2.3` for patchedDependencies).
|
|
241
|
+
if (key.includes(AGENT_NATIVE_SCOPE) || isAgentNativePackageName(key)) {
|
|
242
|
+
findings.push({ file, field: table.field, key, value: String(value) });
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
return findings;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
function collectBumps(
|
|
250
|
+
file: string,
|
|
251
|
+
pkg: PackageJsonLike,
|
|
252
|
+
): AgentNativeDepBump[] {
|
|
253
|
+
const bumps: AgentNativeDepBump[] = [];
|
|
254
|
+
const sections = [
|
|
255
|
+
"dependencies",
|
|
256
|
+
"devDependencies",
|
|
257
|
+
"optionalDependencies",
|
|
258
|
+
] as const;
|
|
259
|
+
for (const section of sections) {
|
|
260
|
+
const deps = pkg[section];
|
|
261
|
+
if (!deps) continue;
|
|
262
|
+
for (const [name, version] of Object.entries(deps)) {
|
|
263
|
+
if (!isAgentNativePackageName(name)) continue;
|
|
264
|
+
if (!shouldBumpAgentNativeVersion(version)) continue;
|
|
265
|
+
bumps.push({
|
|
266
|
+
file,
|
|
267
|
+
section,
|
|
268
|
+
name,
|
|
269
|
+
from: version,
|
|
270
|
+
to: PINNABLE_VERSION,
|
|
271
|
+
});
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
return bumps;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
function applyBumps(pkg: PackageJsonLike, bumps: AgentNativeDepBump[]): void {
|
|
278
|
+
for (const bump of bumps) {
|
|
279
|
+
const section = pkg[bump.section];
|
|
280
|
+
if (!section) continue;
|
|
281
|
+
if (section[bump.name] === bump.from) {
|
|
282
|
+
section[bump.name] = bump.to;
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
export function detectUpgradeProject(cwd: string): UpgradeProject | null {
|
|
288
|
+
const start = path.resolve(cwd);
|
|
289
|
+
let dir = start;
|
|
290
|
+
while (true) {
|
|
291
|
+
const pkgPath = path.join(dir, "package.json");
|
|
292
|
+
if (fs.existsSync(pkgPath)) {
|
|
293
|
+
const pkg = readJsonFile(pkgPath);
|
|
294
|
+
const hasCore =
|
|
295
|
+
Boolean(pkg?.dependencies?.["@agent-native/core"]) ||
|
|
296
|
+
Boolean(pkg?.devDependencies?.["@agent-native/core"]);
|
|
297
|
+
const workspaceYaml = path.join(dir, "pnpm-workspace.yaml");
|
|
298
|
+
const isWorkspace = fs.existsSync(workspaceYaml);
|
|
299
|
+
if (hasCore || isWorkspace) {
|
|
300
|
+
const packageFiles = [pkgPath];
|
|
301
|
+
if (isWorkspace) {
|
|
302
|
+
packageFiles.push(...workspacePackageFiles(dir, workspaceYaml));
|
|
303
|
+
}
|
|
304
|
+
return {
|
|
305
|
+
root: dir,
|
|
306
|
+
kind: isWorkspace ? "workspace" : "standalone",
|
|
307
|
+
packageFiles: Array.from(new Set(packageFiles)),
|
|
308
|
+
};
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
const parent = path.dirname(dir);
|
|
312
|
+
if (parent === dir) break;
|
|
313
|
+
dir = parent;
|
|
314
|
+
}
|
|
315
|
+
return null;
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
function workspacePackageFiles(root: string, workspaceYaml: string): string[] {
|
|
319
|
+
const patterns = parseWorkspacePackagePatterns(workspaceYaml);
|
|
320
|
+
const included = new Set<string>();
|
|
321
|
+
const excluded = new Set<string>();
|
|
322
|
+
for (const rawPattern of patterns) {
|
|
323
|
+
const exclude = rawPattern.startsWith("!");
|
|
324
|
+
const pattern = exclude ? rawPattern.slice(1) : rawPattern;
|
|
325
|
+
const files = packageFilesForWorkspacePattern(root, pattern);
|
|
326
|
+
for (const file of files) {
|
|
327
|
+
if (exclude) excluded.add(file);
|
|
328
|
+
else included.add(file);
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
return Array.from(included)
|
|
332
|
+
.filter((file) => !excluded.has(file))
|
|
333
|
+
.sort();
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
function parseWorkspacePackagePatterns(workspaceYaml: string): string[] {
|
|
337
|
+
let text = "";
|
|
338
|
+
try {
|
|
339
|
+
text = fs.readFileSync(workspaceYaml, "utf-8");
|
|
340
|
+
} catch {
|
|
341
|
+
return ["apps/*", "packages/*"];
|
|
342
|
+
}
|
|
343
|
+
const patterns: string[] = [];
|
|
344
|
+
let inPackages = false;
|
|
345
|
+
for (const line of text.split(/\r?\n/)) {
|
|
346
|
+
const trimmed = line.trim();
|
|
347
|
+
if (!trimmed || trimmed.startsWith("#")) continue;
|
|
348
|
+
if (/^[A-Za-z0-9_-]+:/.test(trimmed)) {
|
|
349
|
+
inPackages = trimmed === "packages:";
|
|
350
|
+
continue;
|
|
351
|
+
}
|
|
352
|
+
if (!inPackages || !trimmed.startsWith("-")) continue;
|
|
353
|
+
const pattern = trimmed
|
|
354
|
+
.slice(1)
|
|
355
|
+
.trim()
|
|
356
|
+
.replace(/^['"]|['"]$/g, "");
|
|
357
|
+
if (pattern) patterns.push(pattern);
|
|
358
|
+
}
|
|
359
|
+
return patterns.length ? patterns : ["apps/*", "packages/*"];
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
function packageFilesForWorkspacePattern(
|
|
363
|
+
root: string,
|
|
364
|
+
pattern: string,
|
|
365
|
+
): string[] {
|
|
366
|
+
const normalized = pattern.replace(/\\/g, "/").replace(/\/+$/g, "");
|
|
367
|
+
if (!normalized || normalized.includes("node_modules")) return [];
|
|
368
|
+
if (normalized.endsWith("/**")) {
|
|
369
|
+
return collectPackageFilesRecursive(
|
|
370
|
+
path.join(root, normalized.slice(0, -3)),
|
|
371
|
+
);
|
|
372
|
+
}
|
|
373
|
+
if (normalized.endsWith("/*")) {
|
|
374
|
+
const base = path.join(root, normalized.slice(0, -2));
|
|
375
|
+
if (!fs.existsSync(base)) return [];
|
|
376
|
+
return fs
|
|
377
|
+
.readdirSync(base, { withFileTypes: true })
|
|
378
|
+
.filter((entry) => entry.isDirectory())
|
|
379
|
+
.map((entry) => path.join(base, entry.name, "package.json"))
|
|
380
|
+
.filter((file) => fs.existsSync(file));
|
|
381
|
+
}
|
|
382
|
+
if (normalized.includes("*")) {
|
|
383
|
+
return collectPackageFilesRecursive(
|
|
384
|
+
path.join(root, normalized.split("*")[0]),
|
|
385
|
+
);
|
|
386
|
+
}
|
|
387
|
+
const file = path.join(root, normalized, "package.json");
|
|
388
|
+
return fs.existsSync(file) ? [file] : [];
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
function collectPackageFilesRecursive(dir: string): string[] {
|
|
392
|
+
if (!fs.existsSync(dir)) return [];
|
|
393
|
+
const files: string[] = [];
|
|
394
|
+
for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
|
|
395
|
+
if (!entry.isDirectory()) continue;
|
|
396
|
+
if (entry.name === "node_modules" || entry.name === ".git") continue;
|
|
397
|
+
const child = path.join(dir, entry.name);
|
|
398
|
+
const pkg = path.join(child, "package.json");
|
|
399
|
+
if (fs.existsSync(pkg)) files.push(pkg);
|
|
400
|
+
files.push(...collectPackageFilesRecursive(child));
|
|
401
|
+
}
|
|
402
|
+
return files;
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
function resolveInstalledPackageVersion(
|
|
406
|
+
projectRoot: string,
|
|
407
|
+
packageName: string,
|
|
408
|
+
): string | null {
|
|
409
|
+
let dir = projectRoot;
|
|
410
|
+
while (true) {
|
|
411
|
+
const candidate = path.join(
|
|
412
|
+
dir,
|
|
413
|
+
"node_modules",
|
|
414
|
+
...packageName.split("/"),
|
|
415
|
+
"package.json",
|
|
416
|
+
);
|
|
417
|
+
if (fs.existsSync(candidate)) {
|
|
418
|
+
const pkg = readJsonFile(candidate);
|
|
419
|
+
return typeof pkg?.version === "string" ? pkg.version : null;
|
|
420
|
+
}
|
|
421
|
+
const parent = path.dirname(dir);
|
|
422
|
+
if (parent === dir) break;
|
|
423
|
+
dir = parent;
|
|
424
|
+
}
|
|
425
|
+
return null;
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
function readCliCoreVersion(): string | null {
|
|
429
|
+
try {
|
|
430
|
+
const here = path.dirname(fileURLToPath(import.meta.url));
|
|
431
|
+
const pkgPath = path.resolve(here, "../../package.json");
|
|
432
|
+
const pkg = readJsonFile(pkgPath);
|
|
433
|
+
return typeof pkg?.version === "string" ? pkg.version : null;
|
|
434
|
+
} catch {
|
|
435
|
+
return null;
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
function detectPackageManager(projectRoot: string): "pnpm" | "npm" | "yarn" {
|
|
440
|
+
if (fs.existsSync(path.join(projectRoot, "pnpm-lock.yaml"))) return "pnpm";
|
|
441
|
+
if (fs.existsSync(path.join(projectRoot, "yarn.lock"))) return "yarn";
|
|
442
|
+
if (fs.existsSync(path.join(projectRoot, "package-lock.json"))) return "npm";
|
|
443
|
+
// Prefer pnpm for Agent Native scaffolds.
|
|
444
|
+
return "pnpm";
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
function installArgs(pm: "pnpm" | "npm" | "yarn"): string[] {
|
|
448
|
+
if (pm === "npm") return ["install"];
|
|
449
|
+
if (pm === "yarn") return ["install"];
|
|
450
|
+
return ["install"];
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
export function buildUpgradeDoctorReport(
|
|
454
|
+
project: UpgradeProject,
|
|
455
|
+
): UpgradeDoctorReport {
|
|
456
|
+
const findings: FrameworkOverrideFinding[] = [];
|
|
457
|
+
const bumps: AgentNativeDepBump[] = [];
|
|
458
|
+
for (const file of project.packageFiles) {
|
|
459
|
+
const pkg = readJsonFile(file);
|
|
460
|
+
if (!pkg) continue;
|
|
461
|
+
findings.push(...collectOverrideFindings(file, pkg));
|
|
462
|
+
bumps.push(...collectBumps(file, pkg));
|
|
463
|
+
}
|
|
464
|
+
const installedCoreVersion = resolveInstalledPackageVersion(
|
|
465
|
+
project.root,
|
|
466
|
+
"@agent-native/core",
|
|
467
|
+
);
|
|
468
|
+
const cliCoreVersion = readCliCoreVersion();
|
|
469
|
+
const skillsUpdateScript = project.packageFiles.some((file) => {
|
|
470
|
+
const pkg = readJsonFile(file);
|
|
471
|
+
return Boolean(pkg?.scripts?.["skills:update"]);
|
|
472
|
+
});
|
|
473
|
+
return {
|
|
474
|
+
project,
|
|
475
|
+
findings,
|
|
476
|
+
bumps,
|
|
477
|
+
installedCoreVersion,
|
|
478
|
+
cliCoreVersion,
|
|
479
|
+
scaffoldStaleHint: skillsUpdateScript || bumps.length > 0,
|
|
480
|
+
};
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
function relativeTo(root: string, file: string): string {
|
|
484
|
+
const rel = path.relative(root, file);
|
|
485
|
+
return rel || ".";
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
function formatDoctorHuman(report: UpgradeDoctorReport): string {
|
|
489
|
+
const lines: string[] = [];
|
|
490
|
+
lines.push(`Project: ${report.project.root} (${report.project.kind})`);
|
|
491
|
+
if (report.installedCoreVersion) {
|
|
492
|
+
lines.push(`Installed @agent-native/core: ${report.installedCoreVersion}`);
|
|
493
|
+
} else {
|
|
494
|
+
lines.push("Installed @agent-native/core: (not found in node_modules)");
|
|
495
|
+
}
|
|
496
|
+
if (report.cliCoreVersion) {
|
|
497
|
+
lines.push(`CLI package version: ${report.cliCoreVersion}`);
|
|
498
|
+
}
|
|
499
|
+
if (report.findings.length === 0) {
|
|
500
|
+
lines.push("Framework overrides/patches: none");
|
|
501
|
+
} else {
|
|
502
|
+
lines.push("Framework overrides/patches:");
|
|
503
|
+
for (const finding of report.findings) {
|
|
504
|
+
lines.push(
|
|
505
|
+
` - ${relativeTo(report.project.root, finding.file)} ${finding.field}["${finding.key}"] = ${finding.value}`,
|
|
506
|
+
);
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
if (report.bumps.length === 0) {
|
|
510
|
+
lines.push("Pending @agent-native/* bumps: none");
|
|
511
|
+
} else {
|
|
512
|
+
lines.push("Pending @agent-native/* bumps:");
|
|
513
|
+
for (const bump of report.bumps) {
|
|
514
|
+
lines.push(
|
|
515
|
+
` - ${relativeTo(report.project.root, bump.file)} ${bump.name}: ${bump.from} → ${bump.to}`,
|
|
516
|
+
);
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
return lines.join("\n");
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
const FAILURE_GUIDANCE = [
|
|
523
|
+
"Upgrade failed. Do not paper over this with framework patches.",
|
|
524
|
+
"Never add pnpm.overrides / patchedDependencies / resolutions for @agent-native/*.",
|
|
525
|
+
"Never edit node_modules/@agent-native/* or invent local dispatch/core behavior overrides.",
|
|
526
|
+
"Revert those changes if present, fix the app-level compile/runtime error, then re-run:",
|
|
527
|
+
" npx @agent-native/core@latest upgrade",
|
|
528
|
+
].join("\n");
|
|
529
|
+
|
|
530
|
+
export async function runUpgrade(
|
|
531
|
+
argv: string[],
|
|
532
|
+
io: UpgradeIo = defaultIo,
|
|
533
|
+
): Promise<number> {
|
|
534
|
+
const opts = parseUpgradeArgs(argv);
|
|
535
|
+
if (opts.help || opts.command === "help") {
|
|
536
|
+
printUpgradeHelp(io);
|
|
537
|
+
return 0;
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
const cwd = path.resolve(opts.cwd ?? process.cwd());
|
|
541
|
+
const project = detectUpgradeProject(cwd);
|
|
542
|
+
if (!project) {
|
|
543
|
+
const message =
|
|
544
|
+
"No Agent Native app/workspace found. Run from an app or workspace root that depends on @agent-native/core.";
|
|
545
|
+
if (opts.json) {
|
|
546
|
+
io.err(JSON.stringify({ ok: false, message }, null, 2));
|
|
547
|
+
} else {
|
|
548
|
+
io.err(message);
|
|
549
|
+
}
|
|
550
|
+
return 1;
|
|
551
|
+
}
|
|
552
|
+
|
|
553
|
+
const doctor = buildUpgradeDoctorReport(project);
|
|
554
|
+
if (opts.command === "check") {
|
|
555
|
+
if (opts.json) {
|
|
556
|
+
io.log(
|
|
557
|
+
JSON.stringify({ ok: doctor.findings.length === 0, doctor }, null, 2),
|
|
558
|
+
);
|
|
559
|
+
} else {
|
|
560
|
+
io.log(formatDoctorHuman(doctor));
|
|
561
|
+
if (doctor.findings.length > 0) {
|
|
562
|
+
io.err("");
|
|
563
|
+
io.err(FAILURE_GUIDANCE);
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
return doctor.findings.length > 0 ? 1 : 0;
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
const result: UpgradeRunResult = {
|
|
570
|
+
ok: true,
|
|
571
|
+
dryRun: Boolean(opts.dryRun),
|
|
572
|
+
doctor,
|
|
573
|
+
steps: [],
|
|
574
|
+
message: "",
|
|
575
|
+
exitCode: 0,
|
|
576
|
+
};
|
|
577
|
+
|
|
578
|
+
if (doctor.findings.length > 0 && !opts.force) {
|
|
579
|
+
result.ok = false;
|
|
580
|
+
result.exitCode = 1;
|
|
581
|
+
result.message =
|
|
582
|
+
"Blocked: framework overrides/patches for @agent-native/* are present. Remove them, then re-run upgrade (or pass --force to continue unsafely).";
|
|
583
|
+
result.steps.push({
|
|
584
|
+
id: "doctor",
|
|
585
|
+
status: "failed",
|
|
586
|
+
detail: result.message,
|
|
587
|
+
});
|
|
588
|
+
if (opts.json) {
|
|
589
|
+
io.err(JSON.stringify(result, null, 2));
|
|
590
|
+
} else {
|
|
591
|
+
io.log(formatDoctorHuman(doctor));
|
|
592
|
+
io.err("");
|
|
593
|
+
io.err(result.message);
|
|
594
|
+
io.err("");
|
|
595
|
+
io.err(FAILURE_GUIDANCE);
|
|
596
|
+
}
|
|
597
|
+
return 1;
|
|
598
|
+
}
|
|
599
|
+
|
|
600
|
+
result.steps.push({
|
|
601
|
+
id: "doctor",
|
|
602
|
+
status: doctor.findings.length > 0 ? "ok" : "ok",
|
|
603
|
+
detail:
|
|
604
|
+
doctor.findings.length > 0
|
|
605
|
+
? "Continuing with --force despite framework overrides/patches"
|
|
606
|
+
: "No framework overrides/patches",
|
|
607
|
+
});
|
|
608
|
+
|
|
609
|
+
// Apply package.json bumps.
|
|
610
|
+
if (doctor.bumps.length === 0) {
|
|
611
|
+
result.steps.push({
|
|
612
|
+
id: "bump",
|
|
613
|
+
status: "skipped",
|
|
614
|
+
detail: "All @agent-native/* deps already use latest or local pins",
|
|
615
|
+
});
|
|
616
|
+
} else if (opts.dryRun) {
|
|
617
|
+
result.steps.push({
|
|
618
|
+
id: "bump",
|
|
619
|
+
status: "planned",
|
|
620
|
+
detail: doctor.bumps
|
|
621
|
+
.map(
|
|
622
|
+
(b) =>
|
|
623
|
+
`${relativeTo(project.root, b.file)} ${b.name}: ${b.from} → ${b.to}`,
|
|
624
|
+
)
|
|
625
|
+
.join("; "),
|
|
626
|
+
});
|
|
627
|
+
} else {
|
|
628
|
+
const byFile = new Map<string, AgentNativeDepBump[]>();
|
|
629
|
+
for (const bump of doctor.bumps) {
|
|
630
|
+
const list = byFile.get(bump.file) ?? [];
|
|
631
|
+
list.push(bump);
|
|
632
|
+
byFile.set(bump.file, list);
|
|
633
|
+
}
|
|
634
|
+
for (const [file, bumps] of byFile) {
|
|
635
|
+
const pkg = readJsonFile(file);
|
|
636
|
+
if (!pkg) continue;
|
|
637
|
+
applyBumps(pkg, bumps);
|
|
638
|
+
writeJsonFile(file, pkg);
|
|
639
|
+
}
|
|
640
|
+
result.steps.push({
|
|
641
|
+
id: "bump",
|
|
642
|
+
status: "ok",
|
|
643
|
+
detail: `Updated ${doctor.bumps.length} @agent-native/* dependency pin(s)`,
|
|
644
|
+
});
|
|
645
|
+
}
|
|
646
|
+
|
|
647
|
+
// Install.
|
|
648
|
+
if (opts.skipInstall) {
|
|
649
|
+
result.steps.push({
|
|
650
|
+
id: "install",
|
|
651
|
+
status: "skipped",
|
|
652
|
+
detail: "--skip-install",
|
|
653
|
+
});
|
|
654
|
+
} else if (opts.dryRun) {
|
|
655
|
+
result.steps.push({
|
|
656
|
+
id: "install",
|
|
657
|
+
status: "planned",
|
|
658
|
+
detail: `${detectPackageManager(project.root)} install`,
|
|
659
|
+
});
|
|
660
|
+
} else {
|
|
661
|
+
const pm = detectPackageManager(project.root);
|
|
662
|
+
const spawned = io.spawn(pm, installArgs(pm), {
|
|
663
|
+
cwd: project.root,
|
|
664
|
+
stdio: opts.json ? "pipe" : "inherit",
|
|
665
|
+
});
|
|
666
|
+
if (spawned.status !== 0) {
|
|
667
|
+
result.ok = false;
|
|
668
|
+
result.exitCode = spawned.status ?? 1;
|
|
669
|
+
result.message = `${pm} install failed`;
|
|
670
|
+
result.steps.push({
|
|
671
|
+
id: "install",
|
|
672
|
+
status: "failed",
|
|
673
|
+
detail: result.message,
|
|
674
|
+
});
|
|
675
|
+
emitResult(io, opts, result);
|
|
676
|
+
return result.exitCode;
|
|
677
|
+
}
|
|
678
|
+
result.steps.push({ id: "install", status: "ok", detail: `${pm} install` });
|
|
679
|
+
}
|
|
680
|
+
|
|
681
|
+
// Skills refresh.
|
|
682
|
+
if (opts.skipSkills) {
|
|
683
|
+
result.steps.push({
|
|
684
|
+
id: "skills",
|
|
685
|
+
status: "skipped",
|
|
686
|
+
detail: "--skip-skills",
|
|
687
|
+
});
|
|
688
|
+
} else if (opts.dryRun) {
|
|
689
|
+
result.steps.push({
|
|
690
|
+
id: "skills",
|
|
691
|
+
status: "planned",
|
|
692
|
+
detail: "skills update scaffold --project",
|
|
693
|
+
});
|
|
694
|
+
} else {
|
|
695
|
+
try {
|
|
696
|
+
await io.runSkillsUpdate(project.root);
|
|
697
|
+
result.steps.push({
|
|
698
|
+
id: "skills",
|
|
699
|
+
status: "ok",
|
|
700
|
+
detail: "skills update scaffold --project",
|
|
701
|
+
});
|
|
702
|
+
} catch (err) {
|
|
703
|
+
result.ok = false;
|
|
704
|
+
result.exitCode = 1;
|
|
705
|
+
result.message = `skills update failed: ${err instanceof Error ? err.message : String(err)}`;
|
|
706
|
+
result.steps.push({
|
|
707
|
+
id: "skills",
|
|
708
|
+
status: "failed",
|
|
709
|
+
detail: result.message,
|
|
710
|
+
});
|
|
711
|
+
emitResult(io, opts, result);
|
|
712
|
+
return result.exitCode;
|
|
713
|
+
}
|
|
714
|
+
}
|
|
715
|
+
|
|
716
|
+
// Verify.
|
|
717
|
+
if (opts.skipVerify) {
|
|
718
|
+
result.steps.push({
|
|
719
|
+
id: "verify",
|
|
720
|
+
status: "skipped",
|
|
721
|
+
detail: "--skip-verify",
|
|
722
|
+
});
|
|
723
|
+
} else if (opts.dryRun) {
|
|
724
|
+
result.steps.push({
|
|
725
|
+
id: "verify",
|
|
726
|
+
status: "planned",
|
|
727
|
+
detail: "typecheck (when available)",
|
|
728
|
+
});
|
|
729
|
+
} else {
|
|
730
|
+
const rootPkg = readJsonFile(path.join(project.root, "package.json"));
|
|
731
|
+
const hasTypecheck = Boolean(rootPkg?.scripts?.typecheck);
|
|
732
|
+
if (!hasTypecheck) {
|
|
733
|
+
result.steps.push({
|
|
734
|
+
id: "verify",
|
|
735
|
+
status: "skipped",
|
|
736
|
+
detail: "no typecheck script",
|
|
737
|
+
});
|
|
738
|
+
} else {
|
|
739
|
+
const pm = detectPackageManager(project.root);
|
|
740
|
+
const args =
|
|
741
|
+
pm === "npm"
|
|
742
|
+
? ["run", "typecheck"]
|
|
743
|
+
: pm === "yarn"
|
|
744
|
+
? ["typecheck"]
|
|
745
|
+
: ["typecheck"];
|
|
746
|
+
const spawned = io.spawn(pm, args, {
|
|
747
|
+
cwd: project.root,
|
|
748
|
+
stdio: opts.json ? "pipe" : "inherit",
|
|
749
|
+
});
|
|
750
|
+
if (spawned.status !== 0) {
|
|
751
|
+
result.ok = false;
|
|
752
|
+
result.exitCode = spawned.status ?? 1;
|
|
753
|
+
result.message = "typecheck failed";
|
|
754
|
+
result.steps.push({
|
|
755
|
+
id: "verify",
|
|
756
|
+
status: "failed",
|
|
757
|
+
detail: result.message,
|
|
758
|
+
});
|
|
759
|
+
emitResult(io, opts, result);
|
|
760
|
+
return result.exitCode;
|
|
761
|
+
}
|
|
762
|
+
result.steps.push({ id: "verify", status: "ok", detail: "typecheck" });
|
|
763
|
+
}
|
|
764
|
+
}
|
|
765
|
+
|
|
766
|
+
result.message = opts.dryRun
|
|
767
|
+
? "Dry run complete. Re-run without --dry-run to apply."
|
|
768
|
+
: "Upgrade complete. If the app still fails to run, fix app-level code — do not patch @agent-native/*.";
|
|
769
|
+
emitResult(io, opts, result);
|
|
770
|
+
return 0;
|
|
771
|
+
}
|
|
772
|
+
|
|
773
|
+
function emitResult(
|
|
774
|
+
io: UpgradeIo,
|
|
775
|
+
opts: UpgradeCliOptions,
|
|
776
|
+
result: UpgradeRunResult,
|
|
777
|
+
): void {
|
|
778
|
+
if (opts.json) {
|
|
779
|
+
const sink = result.ok ? io.log : io.err;
|
|
780
|
+
sink(JSON.stringify(result, null, 2));
|
|
781
|
+
return;
|
|
782
|
+
}
|
|
783
|
+
io.log(formatDoctorHuman(result.doctor));
|
|
784
|
+
io.log("");
|
|
785
|
+
for (const step of result.steps) {
|
|
786
|
+
io.log(
|
|
787
|
+
`[${step.status}] ${step.id}${step.detail ? ` — ${step.detail}` : ""}`,
|
|
788
|
+
);
|
|
789
|
+
}
|
|
790
|
+
io.log("");
|
|
791
|
+
if (result.ok) {
|
|
792
|
+
io.log(result.message);
|
|
793
|
+
} else {
|
|
794
|
+
io.err(result.message);
|
|
795
|
+
io.err("");
|
|
796
|
+
io.err(FAILURE_GUIDANCE);
|
|
797
|
+
}
|
|
798
|
+
}
|