@agent-native/core 0.121.2 → 0.122.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/README.md +4 -12
- package/corpus/README.md +2 -2
- package/corpus/core/CHANGELOG.md +148 -0
- package/corpus/core/docs/content/actions.mdx +2 -2
- package/corpus/core/docs/content/agent-surfaces.mdx +1 -1
- package/corpus/core/docs/content/authentication.mdx +2 -0
- package/corpus/core/docs/content/deployment.mdx +36 -0
- package/corpus/core/docs/content/http-api.mdx +266 -0
- package/corpus/core/docs/content/syncing-template-changes.mdx +159 -0
- package/corpus/core/package.json +2 -1
- package/corpus/core/src/a2a/activity.ts +38 -27
- package/corpus/core/src/a2a/client.ts +57 -4
- package/corpus/core/src/agent/engine/builder-engine.ts +35 -4
- package/corpus/core/src/agent/run-manager.ts +20 -1
- package/corpus/core/src/agent/run-store.ts +4 -1
- package/corpus/core/src/agent/types.ts +28 -8
- package/corpus/core/src/chat-threads/store.ts +45 -0
- package/corpus/core/src/checkpoints/index.ts +2 -0
- package/corpus/core/src/checkpoints/route-match.ts +13 -0
- package/corpus/core/src/cli/create.ts +105 -17
- package/corpus/core/src/cli/index.ts +20 -0
- package/corpus/core/src/cli/template-baseline.ts +410 -0
- package/corpus/core/src/cli/template-sync.ts +1004 -0
- package/corpus/core/src/cli/templates-meta.ts +1 -0
- package/corpus/core/src/client/AssistantChat.tsx +38 -12
- package/corpus/core/src/client/NewWorkspaceAppFlow.tsx +75 -10
- package/corpus/core/src/client/chat/message-components.tsx +127 -66
- package/corpus/core/src/client/chat/tool-call-display.tsx +29 -5
- package/corpus/core/src/client/error-format.ts +18 -0
- package/corpus/core/src/client/org/OrgSwitcher.tsx +30 -8
- package/corpus/core/src/client/org/TeamPage.tsx +7 -6
- package/corpus/core/src/client/settings/SettingsPanel.tsx +9 -9
- package/corpus/core/src/client/settings/SettingsTabsPage.tsx +12 -2
- package/corpus/core/src/client/sse-event-processor.ts +3 -0
- package/corpus/core/src/data-widgets/index.ts +41 -0
- package/corpus/core/src/deploy/build.ts +11 -9
- package/corpus/core/src/extensions/url-safety.ts +67 -4
- package/corpus/core/src/integrations/webhook-handler.ts +63 -9
- package/corpus/core/src/org/auto-join-domain.ts +4 -3
- package/corpus/core/src/org/context.ts +108 -39
- package/corpus/core/src/org/index.ts +5 -0
- package/corpus/core/src/org/service-identity.ts +60 -0
- package/corpus/core/src/provider-api/index.ts +22 -1
- package/corpus/core/src/scripts/docs/search.ts +12 -1
- package/corpus/core/src/server/agent-chat/context-tools.ts +9 -4
- package/corpus/core/src/server/agent-chat/framework-prompts.ts +38 -66
- package/corpus/core/src/server/agent-chat-plugin.ts +17 -10
- package/corpus/core/src/server/agents-bundle.ts +84 -5
- package/corpus/core/src/server/auth.ts +4 -3
- package/corpus/core/src/server/builder-browser.ts +47 -19
- package/corpus/core/src/server/core-routes-plugin.ts +2 -2
- package/corpus/core/src/server/credential-provider.ts +209 -68
- package/corpus/core/src/server/index.ts +3 -0
- package/corpus/core/src/server/prompts/framework-core-compact.ts +6 -13
- package/corpus/core/src/server/prompts/framework-core.ts +9 -21
- package/corpus/core/src/server/prompts/index.ts +0 -1
- package/corpus/core/src/server/prompts/shared-rules.ts +19 -11
- package/corpus/core/src/server/ssr-handler.ts +13 -2
- package/corpus/core/src/settings/user-settings.ts +13 -1
- package/corpus/core/src/shared/cache-control.ts +141 -0
- package/corpus/core/src/templates/chat/.agents/skills/upgrade-agent-native/SKILL.md +24 -2
- package/corpus/core/src/templates/chat/_gitignore +1 -0
- package/corpus/core/src/templates/chat/app/components/layout/Sidebar.tsx +0 -7
- package/corpus/core/src/templates/default/.agents/skills/upgrade-agent-native/SKILL.md +24 -2
- package/corpus/core/src/templates/default/app/root.tsx +1 -1
- package/corpus/core/src/templates/default/public/manifest.json +2 -2
- package/corpus/core/src/templates/headless/.agents/skills/upgrade-agent-native/SKILL.md +24 -2
- package/corpus/core/src/templates/workspace-core/.agents/skills/performance/SKILL.md +19 -0
- package/corpus/core/src/templates/workspace-core/.agents/skills/upgrade-agent-native/SKILL.md +24 -2
- package/corpus/core/src/templates/workspace-core/.agents/skills/visual-answer/SKILL.md +1 -0
- package/corpus/core/src/vite/agents-bundle-plugin.ts +7 -6
- package/corpus/core/src/vite/client.ts +69 -3
- package/corpus/templates/analytics/.agents/skills/adhoc-analysis/SKILL.md +4 -5
- package/corpus/templates/analytics/.agents/skills/admin-surfaces/SKILL.md +55 -0
- package/corpus/templates/analytics/.agents/skills/dashboard-management/SKILL.md +10 -0
- package/corpus/templates/analytics/.agents/skills/dashboard-management/references/template-catalog-and-demo.md +62 -0
- package/corpus/templates/analytics/.agents/skills/dashboard-ops/SKILL.md +85 -0
- package/corpus/templates/analytics/.agents/skills/data-querying/SKILL.md +27 -2
- package/corpus/templates/analytics/.agents/skills/data-querying/references/inline-chart-embeds.md +139 -0
- package/corpus/templates/analytics/.agents/skills/monitoring/SKILL.md +77 -0
- package/corpus/templates/analytics/.agents/skills/upgrade-agent-native/SKILL.md +24 -2
- package/corpus/templates/analytics/AGENTS.md +91 -563
- package/corpus/templates/analytics/_gitignore +1 -0
- package/corpus/templates/analytics/actions/bigquery.ts +12 -4
- package/corpus/templates/analytics/actions/generate-chart.ts +5 -5
- package/corpus/templates/analytics/app/components/dashboard/SqlChart.tsx +30 -1
- package/corpus/templates/analytics/app/components/layout/Sidebar.tsx +1 -23
- package/corpus/templates/analytics/app/pages/adhoc/sql-dashboard/DashboardFilterBar.tsx +3 -0
- package/corpus/templates/analytics/app/pages/adhoc/sql-dashboard/SqlChartCard.tsx +1 -1
- package/corpus/templates/analytics/app/pages/adhoc/sql-dashboard/index.tsx +1 -0
- package/corpus/templates/analytics/app/routes/_index.tsx +1 -1
- package/corpus/templates/analytics/changelog/2026-07-24-analytics-finds-saved-dashboards-and-queries-far-more-reliab.md +6 -0
- package/corpus/templates/analytics/changelog/2026-07-24-notion-access-errors-now-explain-that-a-page-needs-sharing-w.md +6 -0
- package/corpus/templates/analytics/changelog/2026-07-25-app-branding-now-uses-the-product-name-without-the-agent-nat.md +6 -0
- package/corpus/templates/analytics/changelog/2026-07-25-settings-navigation-now-keeps-manage-agent-as-a-dedicated-li.md +6 -0
- package/corpus/templates/analytics/package.json +1 -1
- package/corpus/templates/analytics/public/manifest.json +1 -1
- package/corpus/templates/analytics/server/lib/agent-chat-plan-mode.ts +7 -0
- package/corpus/templates/analytics/server/lib/analytics-query-catalog.ts +191 -30
- package/corpus/templates/analytics/server/lib/bigquery.ts +11 -1
- package/corpus/templates/analytics/server/lib/notion.ts +15 -4
- package/corpus/templates/analytics/server/plugins/agent-chat.ts +10 -0
- package/corpus/templates/analytics/server/plugins/auth.ts +1 -1
- package/corpus/templates/assets/.agents/skills/upgrade-agent-native/SKILL.md +24 -2
- package/corpus/templates/assets/app/components/layout/Sidebar.tsx +0 -2
- package/corpus/templates/assets/app/routes/_index.tsx +1 -1
- package/corpus/templates/assets/changelog/2026-07-25-app-branding-now-uses-the-product-name-without-the-agent-nat.md +6 -0
- package/corpus/templates/assets/changelog/2026-07-25-settings-navigation-now-keeps-manage-agent-as-a-dedicated-li.md +6 -0
- package/corpus/templates/assets/server/plugins/auth.ts +1 -1
- package/corpus/templates/brain/.agents/skills/upgrade-agent-native/SKILL.md +24 -2
- package/corpus/templates/brain/_gitignore +1 -0
- package/corpus/templates/brain/app/lib/brain.ts +0 -7
- package/corpus/templates/brain/app/routes/_index.tsx +1 -2
- package/corpus/templates/brain/changelog/2026-07-25-app-branding-now-uses-the-product-name-without-the-agent-nat.md +6 -0
- package/corpus/templates/brain/changelog/2026-07-25-settings-navigation-now-keeps-manage-agent-as-a-dedicated-li.md +6 -0
- package/corpus/templates/brain/package.json +1 -1
- package/corpus/templates/brain/public/manifest.json +1 -1
- package/corpus/templates/brain/server/plugins/auth.ts +1 -1
- package/corpus/templates/calendar/.agents/skills/upgrade-agent-native/SKILL.md +24 -2
- package/corpus/templates/calendar/_gitignore +1 -0
- package/corpus/templates/calendar/app/components/layout/Sidebar.tsx +0 -6
- package/corpus/templates/calendar/app/routes/_app._index.tsx +1 -1
- package/corpus/templates/calendar/changelog/2026-07-25-app-branding-now-uses-the-product-name-without-the-agent-nat.md +6 -0
- package/corpus/templates/calendar/changelog/2026-07-25-settings-navigation-now-keeps-manage-agent-as-a-dedicated-li.md +6 -0
- package/corpus/templates/calendar/package.json +1 -1
- package/corpus/templates/calendar/public/manifest.json +1 -1
- package/corpus/templates/calendar/server/plugins/auth.ts +1 -1
- package/corpus/templates/chat/.agents/skills/upgrade-agent-native/SKILL.md +24 -2
- package/corpus/templates/chat/_gitignore +1 -0
- package/corpus/templates/chat/app/components/layout/Sidebar.tsx +0 -7
- package/corpus/templates/chat/changelog/2026-07-25-settings-navigation-now-keeps-manage-agent-as-a-dedicated-li.md +6 -0
- package/corpus/templates/clips/.agents/skills/upgrade-agent-native/SKILL.md +24 -2
- package/corpus/templates/clips/.agents/skills/video-sharing/SKILL.md +34 -0
- package/corpus/templates/clips/AGENTS.md +5 -4
- package/corpus/templates/clips/_gitignore +1 -0
- package/corpus/templates/clips/actions/cleanup-transcript.ts +5 -0
- package/corpus/templates/clips/actions/get-recording-insights.ts +44 -8
- package/corpus/templates/clips/actions/get-recording-player-data.ts +39 -70
- package/corpus/templates/clips/actions/import-loom-recording.ts +53 -98
- package/corpus/templates/clips/actions/lib/loom-import-job.ts +260 -0
- package/corpus/templates/clips/actions/list-clip-views.ts +2 -4
- package/corpus/templates/clips/actions/list-recordings.ts +69 -19
- package/corpus/templates/clips/actions/list-viewers.ts +5 -2
- package/corpus/templates/clips/actions/regenerate-summary.ts +5 -1
- package/corpus/templates/clips/actions/request-transcript.ts +28 -1
- package/corpus/templates/clips/app/components/editor/stitch-manager.tsx +21 -1
- package/corpus/templates/clips/app/components/library/library-layout.tsx +0 -7
- package/corpus/templates/clips/app/components/meetings/quick-ask-sidebar.tsx +14 -1
- package/corpus/templates/clips/app/components/player/insights-panel.tsx +8 -20
- package/corpus/templates/clips/app/components/player/recording-views-badge.tsx +335 -0
- package/corpus/templates/clips/app/components/player/video-player.tsx +13 -8
- package/corpus/templates/clips/app/components/sharing/share-ui.tsx +2 -1
- package/corpus/templates/clips/app/i18n/en-US.ts +13 -2
- package/corpus/templates/clips/app/lib/capture-permissions.ts +110 -0
- package/corpus/templates/clips/app/lib/recording-link.ts +32 -0
- package/corpus/templates/clips/app/routes/_app.library._index.tsx +1 -1
- package/corpus/templates/clips/app/routes/_app.meetings.$meetingId.tsx +27 -0
- package/corpus/templates/clips/app/routes/_index.tsx +1 -1
- package/corpus/templates/clips/app/routes/r.$recordingId.tsx +52 -15
- package/corpus/templates/clips/app/routes/record.tsx +82 -31
- package/corpus/templates/clips/app/routes/share.$shareId.tsx +42 -31
- package/corpus/templates/clips/changelog/2026-07-24-clip-pages-now-show-a-view-count-with-viewer-avatars-next-to.md +6 -0
- package/corpus/templates/clips/changelog/2026-07-24-clip-summaries-read-like-a-description-you-d-write-yourself-.md +6 -0
- package/corpus/templates/clips/changelog/2026-07-24-clip-view-counts-now-separate-human-views-from-agent-views-s.md +6 -0
- package/corpus/templates/clips/changelog/2026-07-24-clips-actions-can-now-be-called-by-org-service-tokens-so-ext.md +6 -0
- package/corpus/templates/clips/changelog/2026-07-24-clips-no-longer-briefly-shows-a-dock-icon-while-launching.md +6 -0
- package/corpus/templates/clips/changelog/2026-07-24-fixed-owner-and-editor-share-links-redirecting-to-the-record.md +6 -0
- package/corpus/templates/clips/changelog/2026-07-24-meeting-and-note-recordings-now-start-as-a-compact-pill-on-t.md +6 -0
- package/corpus/templates/clips/changelog/2026-07-24-new-clips-now-copy-a-shareable-link-instead-of-the-owner-onl.md +6 -0
- package/corpus/templates/clips/changelog/2026-07-24-opening-a-share-link-as-the-clip-s-owner-now-goes-straight-t.md +6 -0
- package/corpus/templates/clips/changelog/2026-07-24-permissions-and-rewind-controls-now-use-compact-consistent-h.md +6 -0
- package/corpus/templates/clips/changelog/2026-07-24-quitting-the-desktop-app-no-longer-shows-a-false-macos-crash.md +6 -0
- package/corpus/templates/clips/changelog/2026-07-24-screen-recording-permission-errors-now-name-the-exact-app-to.md +6 -0
- package/corpus/templates/clips/changelog/2026-07-24-the-desktop-app-now-copies-a-new-clip-s-share-link-to-your-c.md +6 -0
- package/corpus/templates/clips/changelog/2026-07-24-the-recording-toolbar-now-stays-above-other-apps-including-o.md +6 -0
- package/corpus/templates/clips/changelog/2026-07-24-transcript-captions-now-use-real-speech-timings-instead-of-a.md +6 -0
- package/corpus/templates/clips/changelog/2026-07-24-video-playback-no-longer-stutters-and-replays-the-last-momen.md +6 -0
- package/corpus/templates/clips/changelog/2026-07-25-app-branding-now-uses-the-product-name-without-the-agent-nat.md +6 -0
- package/corpus/templates/clips/changelog/2026-07-25-settings-navigation-now-keeps-manage-agent-as-a-dedicated-li.md +6 -0
- package/corpus/templates/clips/chrome-extension/src/background.ts +17 -1
- package/corpus/templates/clips/desktop/package.json +2 -0
- package/corpus/templates/clips/desktop/src/app.tsx +89 -0
- package/corpus/templates/clips/desktop/src/hooks/useMeetingTranscription.ts +9 -3
- package/corpus/templates/clips/desktop/src/lib/audio-meter.ts +51 -0
- package/corpus/templates/clips/desktop/src/lib/native-notification.ts +44 -0
- package/corpus/templates/clips/desktop/src/lib/recording-link.ts +67 -0
- package/corpus/templates/clips/desktop/src/overlays/live-audio-bars.tsx +35 -35
- package/corpus/templates/clips/desktop/src/overlays/live-transcript.tsx +3 -2
- package/corpus/templates/clips/desktop/src/overlays/recording-pill.tsx +47 -46
- package/corpus/templates/clips/desktop/src/styles.css +127 -78
- package/corpus/templates/clips/desktop/src-tauri/Cargo.toml +7 -0
- package/corpus/templates/clips/desktop/src-tauri/Info.plist +6 -0
- package/corpus/templates/clips/desktop/src-tauri/capabilities/default.json +1 -0
- package/corpus/templates/clips/desktop/src-tauri/src/clips/mod.rs +7 -3
- package/corpus/templates/clips/desktop/src-tauri/src/lib.rs +4 -1
- package/corpus/templates/clips/desktop/src-tauri/src/main.rs +8 -0
- package/corpus/templates/clips/desktop/src-tauri/src/recording_indicator.rs +21 -10
- package/corpus/templates/clips/desktop/src-tauri/src/util.rs +40 -0
- package/corpus/templates/clips/server/db/schema.ts +27 -0
- package/corpus/templates/clips/server/lib/agent-views.ts +145 -0
- package/corpus/templates/clips/server/lib/post-finalize-dispatch.ts +2 -1
- package/corpus/templates/clips/server/lib/public-agent-context.ts +7 -0
- package/corpus/templates/clips/server/lib/recording-share-grant.ts +79 -0
- package/corpus/templates/clips/server/lib/recordings.ts +51 -3
- package/corpus/templates/clips/server/plugins/auth.ts +1 -1
- package/corpus/templates/clips/server/plugins/db.ts +31 -0
- package/corpus/templates/clips/server/routes/api/_agent-native-background/post-finalize-worker.post.ts +56 -3
- package/corpus/templates/clips/server/routes/api/public-recording.get.ts +49 -17
- package/corpus/templates/clips/shared/recording-link.ts +43 -0
- package/corpus/templates/clips/shared/share-attribution.ts +4 -0
- package/corpus/templates/clips/shared/share-dashboard-redirect.ts +42 -0
- package/corpus/templates/clips/shared/view-analytics.ts +26 -0
- package/corpus/templates/content/.agents/skills/content/SKILL.md +5 -0
- package/corpus/templates/content/.agents/skills/content/references/local-file-mode.md +135 -0
- package/corpus/templates/content/.agents/skills/document-editing/SKILL.md +12 -0
- package/corpus/templates/content/.agents/skills/document-editing/references/databases.md +238 -0
- package/corpus/templates/content/.agents/skills/document-editing/references/document-behavior.md +91 -0
- package/corpus/templates/content/.agents/skills/upgrade-agent-native/SKILL.md +24 -2
- package/corpus/templates/content/AGENTS.md +62 -583
- package/corpus/templates/content/_gitignore +1 -0
- package/corpus/templates/content/app/components/sidebar/DocumentSidebar.tsx +1 -39
- package/corpus/templates/content/app/routes/_app._index.tsx +1 -2
- package/corpus/templates/content/changelog/2026-07-25-app-branding-now-uses-the-product-name-without-the-agent-nat.md +6 -0
- package/corpus/templates/content/changelog/2026-07-25-settings-navigation-now-keeps-manage-agent-as-a-dedicated-li.md +6 -0
- package/corpus/templates/content/package.json +1 -1
- package/corpus/templates/content/public/manifest.json +1 -1
- package/corpus/templates/content/server/plugins/auth.ts +1 -1
- package/corpus/templates/design/.agents/skills/creative-context/SKILL.md +11 -0
- package/corpus/templates/design/.agents/skills/design-generation/SKILL.md +50 -8
- package/corpus/templates/design/.agents/skills/design-generation/references/code-layers.md +81 -0
- package/corpus/templates/design/.agents/skills/design-generation/references/code-workspace.md +42 -0
- package/corpus/templates/design/.agents/skills/design-generation/references/editor-extensions.md +34 -0
- package/corpus/templates/design/.agents/skills/responsive-breakpoints/SKILL.md +4 -1
- package/corpus/templates/design/.agents/skills/upgrade-agent-native/SKILL.md +24 -2
- package/corpus/templates/design/.agents/skills/visual-edit/SKILL.md +17 -0
- package/corpus/templates/design/.generated/bridge/editor-chrome.generated.ts +8196 -0
- package/corpus/templates/design/.generated/bridge/embedded-wheel.generated.ts +265 -0
- package/corpus/templates/design/.generated/bridge/hit-test.generated.ts +642 -0
- package/corpus/templates/design/.generated/bridge/motion-preview.generated.ts +571 -0
- package/corpus/templates/design/.generated/bridge/nav.generated.ts +91 -0
- package/corpus/templates/design/.generated/bridge/sample.generated.ts +23 -0
- package/corpus/templates/design/.generated/bridge/shader-fill-preview.generated.ts +263 -0
- package/corpus/templates/design/.generated/bridge/shader-runtime.generated.ts +518 -0
- package/corpus/templates/design/.generated/bridge/tweak.generated.ts +20 -0
- package/corpus/templates/design/.generated/bridge/zoom.generated.ts +32 -0
- package/corpus/templates/design/AGENTS.md +88 -503
- package/corpus/templates/design/_gitignore +1 -0
- package/corpus/templates/design/app/components/layout/Sidebar.tsx +0 -2
- package/corpus/templates/design/app/routes/_index.tsx +1 -1
- package/corpus/templates/design/changelog/2026-07-25-app-branding-now-uses-the-product-name-without-the-agent-nat.md +6 -0
- package/corpus/templates/design/changelog/2026-07-25-settings-navigation-now-keeps-manage-agent-as-a-dedicated-li.md +6 -0
- package/corpus/templates/design/server/plugins/auth.ts +1 -1
- package/corpus/templates/dispatch/.agents/skills/upgrade-agent-native/SKILL.md +24 -2
- package/corpus/templates/dispatch/_gitignore +1 -0
- package/corpus/templates/dispatch/app/dispatch-extensions.tsx +1 -10
- package/corpus/templates/dispatch/app/routes/overview.tsx +1 -1
- package/corpus/templates/dispatch/changelog/2026-07-24-signing-in-now-puts-you-in-your-companys-workspace.md +6 -0
- package/corpus/templates/dispatch/changelog/2026-07-25-app-branding-now-uses-the-product-name-without-the-agent-nat.md +6 -0
- package/corpus/templates/dispatch/changelog/2026-07-25-settings-navigation-now-keeps-manage-agent-as-a-dedicated-li.md +6 -0
- package/corpus/templates/dispatch/package.json +1 -1
- package/corpus/templates/dispatch/public/manifest.json +1 -1
- package/corpus/templates/forms/.agents/skills/upgrade-agent-native/SKILL.md +24 -2
- package/corpus/templates/forms/_gitignore +1 -0
- package/corpus/templates/forms/app/components/layout/Sidebar.tsx +0 -35
- package/corpus/templates/forms/changelog/2026-07-25-app-branding-now-uses-the-product-name-without-the-agent-nat.md +6 -0
- package/corpus/templates/forms/changelog/2026-07-25-settings-navigation-now-keeps-manage-agent-as-a-dedicated-li.md +6 -0
- package/corpus/templates/forms/package.json +1 -1
- package/corpus/templates/forms/public/manifest.json +1 -1
- package/corpus/templates/forms/server/lib/public-form-ssr.ts +2 -2
- package/corpus/templates/forms/server/plugins/auth.ts +1 -1
- package/corpus/templates/macros/.agents/skills/upgrade-agent-native/SKILL.md +24 -2
- package/corpus/templates/macros/_gitignore +1 -0
- package/corpus/templates/macros/app/components/layout/AppLayout.tsx +0 -2
- package/corpus/templates/macros/changelog/2026-07-25-app-branding-now-uses-the-product-name-without-the-agent-nat.md +6 -0
- package/corpus/templates/macros/changelog/2026-07-25-settings-navigation-now-keeps-manage-agent-as-a-dedicated-li.md +6 -0
- package/corpus/templates/macros/package.json +1 -1
- package/corpus/templates/macros/server/plugins/auth.ts +2 -2
- package/corpus/templates/mail/.agents/skills/upgrade-agent-native/SKILL.md +24 -2
- package/corpus/templates/mail/_gitignore +1 -0
- package/corpus/templates/mail/app/components/layout/AppLayout.tsx +0 -39
- package/corpus/templates/mail/app/routes/$view.$threadId.tsx +1 -1
- package/corpus/templates/mail/app/routes/$view.tsx +1 -1
- package/corpus/templates/mail/app/routes/_index.tsx +1 -1
- package/corpus/templates/mail/changelog/2026-07-25-app-branding-now-uses-the-product-name-without-the-agent-nat.md +6 -0
- package/corpus/templates/mail/changelog/2026-07-25-settings-navigation-now-keeps-manage-agent-as-a-dedicated-li.md +6 -0
- package/corpus/templates/mail/package.json +1 -1
- package/corpus/templates/mail/public/manifest.json +1 -1
- package/corpus/templates/mail/server/plugins/auth.ts +1 -1
- package/corpus/templates/plan/.agents/skills/upgrade-agent-native/SKILL.md +24 -2
- package/corpus/templates/plan/_gitignore +1 -0
- package/corpus/templates/plan/agent-native.app-skill.json +1 -1
- package/corpus/templates/plan/app/components/layout/Sidebar.tsx +4 -9
- package/corpus/templates/plan/app/lib/app-config.ts +1 -1
- package/corpus/templates/plan/changelog/2026-07-25-app-branding-now-uses-the-product-name-without-the-agent-nat.md +6 -0
- package/corpus/templates/plan/changelog/2026-07-25-settings-navigation-now-keeps-manage-agent-as-a-dedicated-li.md +6 -0
- package/corpus/templates/plan/package.json +1 -1
- package/corpus/templates/plan/public/manifest.json +1 -1
- package/corpus/templates/plan/server/plugins/auth.ts +1 -1
- package/corpus/templates/slides/.agents/skills/upgrade-agent-native/SKILL.md +24 -2
- package/corpus/templates/slides/_gitignore +1 -0
- package/corpus/templates/slides/app/components/layout/Sidebar.tsx +0 -2
- package/corpus/templates/slides/app/routes/_index.tsx +1 -1
- package/corpus/templates/slides/changelog/2026-07-25-app-branding-now-uses-the-product-name-without-the-agent-nat.md +6 -0
- package/corpus/templates/slides/changelog/2026-07-25-settings-navigation-now-keeps-manage-agent-as-a-dedicated-li.md +6 -0
- package/corpus/templates/slides/package.json +1 -1
- package/corpus/templates/slides/public/manifest.json +1 -1
- package/corpus/templates/slides/server/plugins/auth.ts +1 -1
- package/corpus/templates/slides/server/plugins/db.ts +4 -0
- package/corpus/templates/tasks/.agents/skills/upgrade-agent-native/SKILL.md +24 -2
- package/corpus/templates/tasks/AGENTS.md +1 -1
- package/corpus/templates/tasks/_gitignore +1 -0
- package/dist/a2a/activity.d.ts +4 -1
- package/dist/a2a/activity.d.ts.map +1 -1
- package/dist/a2a/activity.js +27 -16
- package/dist/a2a/activity.js.map +1 -1
- package/dist/a2a/client.d.ts.map +1 -1
- package/dist/a2a/client.js +58 -4
- package/dist/a2a/client.js.map +1 -1
- package/dist/agent/engine/builder-engine.d.ts +1 -0
- package/dist/agent/engine/builder-engine.d.ts.map +1 -1
- package/dist/agent/engine/builder-engine.js +31 -4
- package/dist/agent/engine/builder-engine.js.map +1 -1
- package/dist/agent/run-manager.d.ts.map +1 -1
- package/dist/agent/run-manager.js +18 -1
- package/dist/agent/run-manager.js.map +1 -1
- package/dist/agent/run-store.d.ts +1 -0
- package/dist/agent/run-store.d.ts.map +1 -1
- package/dist/agent/run-store.js +2 -1
- package/dist/agent/run-store.js.map +1 -1
- package/dist/agent/types.d.ts +12 -1
- package/dist/agent/types.d.ts.map +1 -1
- package/dist/agent/types.js +21 -1
- package/dist/agent/types.js.map +1 -1
- package/dist/chat-threads/store.d.ts +10 -0
- package/dist/chat-threads/store.d.ts.map +1 -1
- package/dist/chat-threads/store.js +41 -0
- package/dist/chat-threads/store.js.map +1 -1
- package/dist/checkpoints/index.d.ts +1 -0
- package/dist/checkpoints/index.d.ts.map +1 -1
- package/dist/checkpoints/index.js +1 -0
- package/dist/checkpoints/index.js.map +1 -1
- package/dist/checkpoints/route-match.d.ts +8 -0
- package/dist/checkpoints/route-match.d.ts.map +1 -0
- package/dist/checkpoints/route-match.js +13 -0
- package/dist/checkpoints/route-match.js.map +1 -0
- package/dist/cli/create.d.ts +35 -4
- package/dist/cli/create.d.ts.map +1 -1
- package/dist/cli/create.js +69 -19
- package/dist/cli/create.js.map +1 -1
- package/dist/cli/index.js +19 -0
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/template-baseline.d.ts +54 -0
- package/dist/cli/template-baseline.d.ts.map +1 -0
- package/dist/cli/template-baseline.js +334 -0
- package/dist/cli/template-baseline.js.map +1 -0
- package/dist/cli/template-sync.d.ts +57 -0
- package/dist/cli/template-sync.d.ts.map +1 -0
- package/dist/cli/template-sync.js +787 -0
- package/dist/cli/template-sync.js.map +1 -0
- package/dist/cli/templates-meta.d.ts.map +1 -1
- package/dist/cli/templates-meta.js +1 -0
- package/dist/cli/templates-meta.js.map +1 -1
- package/dist/client/AssistantChat.d.ts +2 -1
- package/dist/client/AssistantChat.d.ts.map +1 -1
- package/dist/client/AssistantChat.js +38 -10
- package/dist/client/AssistantChat.js.map +1 -1
- package/dist/client/NewWorkspaceAppFlow.d.ts.map +1 -1
- package/dist/client/NewWorkspaceAppFlow.js +32 -2
- package/dist/client/NewWorkspaceAppFlow.js.map +1 -1
- package/dist/client/chat/message-components.d.ts +20 -0
- package/dist/client/chat/message-components.d.ts.map +1 -1
- package/dist/client/chat/message-components.js +81 -46
- package/dist/client/chat/message-components.js.map +1 -1
- package/dist/client/chat/tool-call-display.d.ts.map +1 -1
- package/dist/client/chat/tool-call-display.js +14 -6
- package/dist/client/chat/tool-call-display.js.map +1 -1
- package/dist/client/error-format.d.ts.map +1 -1
- package/dist/client/error-format.js +13 -0
- package/dist/client/error-format.js.map +1 -1
- package/dist/client/org/OrgSwitcher.d.ts +8 -1
- package/dist/client/org/OrgSwitcher.d.ts.map +1 -1
- package/dist/client/org/OrgSwitcher.js +3 -2
- 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 +1 -1
- package/dist/client/org/TeamPage.js.map +1 -1
- package/dist/client/settings/SettingsPanel.js +9 -9
- package/dist/client/settings/SettingsPanel.js.map +1 -1
- package/dist/client/settings/SettingsTabsPage.d.ts.map +1 -1
- package/dist/client/settings/SettingsTabsPage.js +7 -4
- package/dist/client/settings/SettingsTabsPage.js.map +1 -1
- package/dist/client/sse-event-processor.d.ts.map +1 -1
- package/dist/client/sse-event-processor.js +3 -0
- package/dist/client/sse-event-processor.js.map +1 -1
- package/dist/collab/awareness.d.ts +2 -2
- package/dist/collab/awareness.d.ts.map +1 -1
- package/dist/collab/struct-routes.d.ts +1 -1
- package/dist/data-widgets/index.d.ts +3 -0
- package/dist/data-widgets/index.d.ts.map +1 -1
- package/dist/data-widgets/index.js +33 -0
- package/dist/data-widgets/index.js.map +1 -1
- package/dist/deploy/build.d.ts.map +1 -1
- package/dist/deploy/build.js +11 -7
- package/dist/deploy/build.js.map +1 -1
- package/dist/eject/provider-api-definitions.d.ts +1 -0
- package/dist/eject/provider-api-definitions.d.ts.map +1 -1
- package/dist/extensions/url-safety.d.ts +9 -16
- package/dist/extensions/url-safety.d.ts.map +1 -1
- package/dist/extensions/url-safety.js +48 -4
- package/dist/extensions/url-safety.js.map +1 -1
- package/dist/file-upload/actions/upload-image.d.ts +1 -1
- package/dist/integrations/webhook-handler.d.ts.map +1 -1
- package/dist/integrations/webhook-handler.js +46 -9
- package/dist/integrations/webhook-handler.js.map +1 -1
- package/dist/notifications/routes.d.ts +2 -2
- package/dist/observability/routes.d.ts +3 -3
- package/dist/org/auto-join-domain.d.ts +3 -2
- package/dist/org/auto-join-domain.d.ts.map +1 -1
- package/dist/org/auto-join-domain.js +1 -1
- package/dist/org/auto-join-domain.js.map +1 -1
- package/dist/org/context.d.ts.map +1 -1
- package/dist/org/context.js +84 -28
- package/dist/org/context.js.map +1 -1
- package/dist/org/index.d.ts +1 -0
- package/dist/org/index.d.ts.map +1 -1
- package/dist/org/index.js +1 -0
- package/dist/org/index.js.map +1 -1
- package/dist/org/service-identity.d.ts +43 -0
- package/dist/org/service-identity.d.ts.map +1 -0
- package/dist/org/service-identity.js +34 -0
- package/dist/org/service-identity.js.map +1 -0
- package/dist/provider-api/actions/custom-provider-registration.d.ts +14 -14
- package/dist/provider-api/actions/provider-api.d.ts +13 -11
- package/dist/provider-api/actions/provider-api.d.ts.map +1 -1
- package/dist/provider-api/index.d.ts +4 -0
- package/dist/provider-api/index.d.ts.map +1 -1
- package/dist/provider-api/index.js +17 -1
- package/dist/provider-api/index.js.map +1 -1
- package/dist/scripts/docs/search.d.ts.map +1 -1
- package/dist/scripts/docs/search.js +12 -1
- package/dist/scripts/docs/search.js.map +1 -1
- package/dist/server/agent-chat/context-tools.d.ts.map +1 -1
- package/dist/server/agent-chat/context-tools.js +3 -3
- package/dist/server/agent-chat/context-tools.js.map +1 -1
- package/dist/server/agent-chat/framework-prompts.d.ts +8 -3
- package/dist/server/agent-chat/framework-prompts.d.ts.map +1 -1
- package/dist/server/agent-chat/framework-prompts.js +33 -62
- package/dist/server/agent-chat/framework-prompts.js.map +1 -1
- package/dist/server/agent-chat-plugin.d.ts.map +1 -1
- package/dist/server/agent-chat-plugin.js +16 -10
- 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 +18 -0
- package/dist/server/agents-bundle.d.ts.map +1 -1
- package/dist/server/agents-bundle.js +70 -4
- package/dist/server/agents-bundle.js.map +1 -1
- package/dist/server/auth.d.ts.map +1 -1
- package/dist/server/auth.js +4 -3
- package/dist/server/auth.js.map +1 -1
- package/dist/server/builder-browser.d.ts.map +1 -1
- package/dist/server/builder-browser.js +43 -19
- package/dist/server/builder-browser.js.map +1 -1
- package/dist/server/core-routes-plugin.js +2 -2
- package/dist/server/core-routes-plugin.js.map +1 -1
- package/dist/server/credential-provider.d.ts +38 -2
- package/dist/server/credential-provider.d.ts.map +1 -1
- package/dist/server/credential-provider.js +142 -64
- package/dist/server/credential-provider.js.map +1 -1
- package/dist/server/index.d.ts +1 -1
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +1 -1
- package/dist/server/index.js.map +1 -1
- package/dist/server/prompts/framework-core-compact.d.ts +1 -1
- package/dist/server/prompts/framework-core-compact.d.ts.map +1 -1
- package/dist/server/prompts/framework-core-compact.js +7 -13
- package/dist/server/prompts/framework-core-compact.js.map +1 -1
- package/dist/server/prompts/framework-core.d.ts +1 -1
- package/dist/server/prompts/framework-core.d.ts.map +1 -1
- package/dist/server/prompts/framework-core.js +10 -21
- package/dist/server/prompts/framework-core.js.map +1 -1
- package/dist/server/prompts/index.d.ts +1 -1
- package/dist/server/prompts/index.d.ts.map +1 -1
- package/dist/server/prompts/index.js +1 -1
- package/dist/server/prompts/index.js.map +1 -1
- package/dist/server/prompts/shared-rules.d.ts +16 -10
- package/dist/server/prompts/shared-rules.d.ts.map +1 -1
- package/dist/server/prompts/shared-rules.js +19 -10
- package/dist/server/prompts/shared-rules.js.map +1 -1
- package/dist/server/ssr-handler.d.ts +1 -1
- package/dist/server/ssr-handler.d.ts.map +1 -1
- package/dist/server/ssr-handler.js +10 -3
- package/dist/server/ssr-handler.js.map +1 -1
- package/dist/server/transcribe-voice.d.ts +1 -1
- package/dist/settings/user-settings.d.ts.map +1 -1
- package/dist/settings/user-settings.js +13 -1
- package/dist/settings/user-settings.js.map +1 -1
- package/dist/shared/cache-control.d.ts +52 -0
- package/dist/shared/cache-control.d.ts.map +1 -1
- package/dist/shared/cache-control.js +107 -0
- package/dist/shared/cache-control.js.map +1 -1
- package/dist/templates/chat/.agents/skills/upgrade-agent-native/SKILL.md +24 -2
- package/dist/templates/chat/_gitignore +1 -0
- package/dist/templates/chat/app/components/layout/Sidebar.tsx +0 -7
- package/dist/templates/chat/changelog/2026-07-25-settings-navigation-now-keeps-manage-agent-as-a-dedicated-li.md +6 -0
- package/dist/templates/default/.agents/skills/upgrade-agent-native/SKILL.md +24 -2
- package/dist/templates/default/app/root.tsx +1 -1
- package/dist/templates/default/public/manifest.json +2 -2
- package/dist/templates/headless/.agents/skills/upgrade-agent-native/SKILL.md +24 -2
- package/dist/templates/workspace-core/.agents/skills/performance/SKILL.md +19 -0
- package/dist/templates/workspace-core/.agents/skills/upgrade-agent-native/SKILL.md +24 -2
- package/dist/templates/workspace-core/.agents/skills/visual-answer/SKILL.md +1 -0
- package/dist/vite/agents-bundle-plugin.d.ts.map +1 -1
- package/dist/vite/agents-bundle-plugin.js +8 -7
- package/dist/vite/agents-bundle-plugin.js.map +1 -1
- package/dist/vite/client.d.ts.map +1 -1
- package/dist/vite/client.js +66 -1
- package/dist/vite/client.js.map +1 -1
- package/docs/content/actions.mdx +2 -2
- package/docs/content/agent-surfaces.mdx +1 -1
- package/docs/content/authentication.mdx +2 -0
- package/docs/content/deployment.mdx +36 -0
- package/docs/content/http-api.mdx +266 -0
- package/docs/content/syncing-template-changes.mdx +159 -0
- package/package.json +4 -3
- package/src/a2a/activity.ts +38 -27
- package/src/a2a/client.ts +57 -4
- package/src/agent/engine/builder-engine.ts +35 -4
- package/src/agent/run-manager.ts +20 -1
- package/src/agent/run-store.ts +4 -1
- package/src/agent/types.ts +28 -8
- package/src/chat-threads/store.ts +45 -0
- package/src/checkpoints/index.ts +2 -0
- package/src/checkpoints/route-match.ts +13 -0
- package/src/cli/create.ts +105 -17
- package/src/cli/index.ts +20 -0
- package/src/cli/template-baseline.ts +410 -0
- package/src/cli/template-sync.ts +1004 -0
- package/src/cli/templates-meta.ts +1 -0
- package/src/client/AssistantChat.tsx +38 -12
- package/src/client/NewWorkspaceAppFlow.tsx +75 -10
- package/src/client/chat/message-components.tsx +127 -66
- package/src/client/chat/tool-call-display.tsx +29 -5
- package/src/client/error-format.ts +18 -0
- package/src/client/org/OrgSwitcher.tsx +30 -8
- package/src/client/org/TeamPage.tsx +7 -6
- package/src/client/settings/SettingsPanel.tsx +9 -9
- package/src/client/settings/SettingsTabsPage.tsx +12 -2
- package/src/client/sse-event-processor.ts +3 -0
- package/src/data-widgets/index.ts +41 -0
- package/src/deploy/build.ts +11 -9
- package/src/extensions/url-safety.ts +67 -4
- package/src/integrations/webhook-handler.ts +63 -9
- package/src/org/auto-join-domain.ts +4 -3
- package/src/org/context.ts +108 -39
- package/src/org/index.ts +5 -0
- package/src/org/service-identity.ts +60 -0
- package/src/provider-api/index.ts +22 -1
- package/src/scripts/docs/search.ts +12 -1
- package/src/server/__snapshots__/agent-chat-plugin.surface.spec.ts.snap +25 -36
- package/src/server/agent-chat/context-tools.ts +9 -4
- package/src/server/agent-chat/framework-prompts.ts +38 -66
- package/src/server/agent-chat-plugin.ts +17 -10
- package/src/server/agents-bundle.ts +84 -5
- package/src/server/auth.ts +4 -3
- package/src/server/builder-browser.ts +47 -19
- package/src/server/core-routes-plugin.ts +2 -2
- package/src/server/credential-provider.ts +209 -68
- package/src/server/index.ts +3 -0
- package/src/server/prompts/framework-core-compact.ts +6 -13
- package/src/server/prompts/framework-core.ts +9 -21
- package/src/server/prompts/index.ts +0 -1
- package/src/server/prompts/shared-rules.ts +19 -11
- package/src/server/ssr-handler.ts +13 -2
- package/src/settings/user-settings.ts +13 -1
- package/src/shared/cache-control.ts +141 -0
- package/src/templates/chat/.agents/skills/upgrade-agent-native/SKILL.md +24 -2
- package/src/templates/chat/_gitignore +1 -0
- package/src/templates/chat/app/components/layout/Sidebar.tsx +0 -7
- package/src/templates/chat/changelog/2026-07-25-settings-navigation-now-keeps-manage-agent-as-a-dedicated-li.md +6 -0
- package/src/templates/default/.agents/skills/upgrade-agent-native/SKILL.md +24 -2
- package/src/templates/default/app/root.tsx +1 -1
- package/src/templates/default/public/manifest.json +2 -2
- package/src/templates/headless/.agents/skills/upgrade-agent-native/SKILL.md +24 -2
- package/src/templates/workspace-core/.agents/skills/performance/SKILL.md +19 -0
- package/src/templates/workspace-core/.agents/skills/upgrade-agent-native/SKILL.md +24 -2
- package/src/templates/workspace-core/.agents/skills/visual-answer/SKILL.md +1 -0
- package/src/vite/agents-bundle-plugin.ts +7 -6
- package/src/vite/client.ts +69 -3
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The framework mount shim normally rewrites `event.path` to the mount-relative
|
|
3
|
+
* remainder ("/restore"), but it falls back to the unstripped request path when
|
|
4
|
+
* `event.url` is read-only on the host runtime. Accept both so a restore POST
|
|
5
|
+
* never silently 405s.
|
|
6
|
+
*/
|
|
7
|
+
export function isCheckpointRestorePath(path: string | undefined): boolean {
|
|
8
|
+
if (!path) return false;
|
|
9
|
+
return (
|
|
10
|
+
/(^|\/)checkpoints\/restore(?:[/?]|$)/.test(path) ||
|
|
11
|
+
/^\/?restore(?:[/?]|$)/.test(path)
|
|
12
|
+
);
|
|
13
|
+
}
|
|
@@ -637,7 +637,7 @@ async function scaffoldOneAppIntoWorkspace(
|
|
|
637
637
|
);
|
|
638
638
|
|
|
639
639
|
try {
|
|
640
|
-
await scaffoldAppTemplate(appDir, templateName);
|
|
640
|
+
const resolution = await scaffoldAppTemplate(appDir, templateName);
|
|
641
641
|
replacePlaceholders(
|
|
642
642
|
appDir,
|
|
643
643
|
appName,
|
|
@@ -655,7 +655,10 @@ async function scaffoldOneAppIntoWorkspace(
|
|
|
655
655
|
dispatchDependencyVersion: getDispatchDependencyVersion(),
|
|
656
656
|
toolkitDependencyVersion: getToolkitDependencyVersion(),
|
|
657
657
|
});
|
|
658
|
-
fixPackageJsonName(appDir, appName, templateName
|
|
658
|
+
fixPackageJsonName(appDir, appName, templateName, {
|
|
659
|
+
...resolution,
|
|
660
|
+
shape: "workspace",
|
|
661
|
+
});
|
|
659
662
|
fixWebManifestName(appDir, appName, templateName);
|
|
660
663
|
rewriteNetlifyToml(appDir, appName, "workspace");
|
|
661
664
|
renameGitignore(appDir);
|
|
@@ -736,9 +739,9 @@ async function createStandaloneApp(
|
|
|
736
739
|
: `Downloading the ${template} template from GitHub...`,
|
|
737
740
|
);
|
|
738
741
|
try {
|
|
739
|
-
await scaffoldAppTemplate(targetDir, template);
|
|
742
|
+
const resolution = await scaffoldAppTemplate(targetDir, template);
|
|
740
743
|
s.message(`Setting up ${name}…`);
|
|
741
|
-
postProcessStandalone(name, targetDir, template);
|
|
744
|
+
postProcessStandalone(name, targetDir, template, resolution);
|
|
742
745
|
s.stop("App created!");
|
|
743
746
|
} catch (err: any) {
|
|
744
747
|
s.stop("Failed to create app.");
|
|
@@ -789,6 +792,17 @@ function cleanupOnFailure(targetDir: string): void {
|
|
|
789
792
|
* Shared scaffolding helpers
|
|
790
793
|
* ───────────────────────────────────────────────────────────────────────── */
|
|
791
794
|
|
|
795
|
+
/** Where a scaffolded template's bytes came from, recorded so
|
|
796
|
+
* `agent-native template sync` can reproduce them later. */
|
|
797
|
+
export interface ScaffoldTemplateResolution {
|
|
798
|
+
templateRef?: string;
|
|
799
|
+
templateSource?: "github" | "bundled" | "local-checkout";
|
|
800
|
+
}
|
|
801
|
+
|
|
802
|
+
export interface ScaffoldProvenance extends ScaffoldTemplateResolution {
|
|
803
|
+
shape?: "workspace" | "standalone";
|
|
804
|
+
}
|
|
805
|
+
|
|
792
806
|
/**
|
|
793
807
|
* Scaffold a single app template into `targetDir`. Resolves:
|
|
794
808
|
* - "headless" / legacy "blank" → bundled action-first template
|
|
@@ -799,7 +813,7 @@ function cleanupOnFailure(targetDir: string): void {
|
|
|
799
813
|
async function scaffoldAppTemplate(
|
|
800
814
|
targetDir: string,
|
|
801
815
|
template: string,
|
|
802
|
-
): Promise<
|
|
816
|
+
): Promise<ScaffoldTemplateResolution> {
|
|
803
817
|
fs.mkdirSync(path.dirname(targetDir), { recursive: true });
|
|
804
818
|
|
|
805
819
|
// Normalize legacy / renamed aliases.
|
|
@@ -814,13 +828,16 @@ async function scaffoldAppTemplate(
|
|
|
814
828
|
);
|
|
815
829
|
}
|
|
816
830
|
copyDir(headlessDir, targetDir);
|
|
817
|
-
return
|
|
831
|
+
return {
|
|
832
|
+
templateSource: "bundled",
|
|
833
|
+
templateRef: getGitHubTemplateRefCandidates()[0],
|
|
834
|
+
};
|
|
818
835
|
}
|
|
819
836
|
|
|
820
837
|
if (resolved.startsWith("github:")) {
|
|
821
838
|
const repo = resolved.slice("github:".length);
|
|
822
839
|
await downloadGitHubRepo(repo, targetDir);
|
|
823
|
-
return;
|
|
840
|
+
return {};
|
|
824
841
|
}
|
|
825
842
|
|
|
826
843
|
if (!getTemplate(resolved)) {
|
|
@@ -836,13 +853,29 @@ async function scaffoldAppTemplate(
|
|
|
836
853
|
const localTemplate = findLocalTemplate(sourceTemplate);
|
|
837
854
|
if (localTemplate) {
|
|
838
855
|
copyDir(localTemplate, targetDir);
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
targetDir,
|
|
844
|
-
);
|
|
856
|
+
return {
|
|
857
|
+
templateSource: localTemplateSourceKind(localTemplate),
|
|
858
|
+
templateRef: getGitHubTemplateRefCandidates()[0],
|
|
859
|
+
};
|
|
845
860
|
}
|
|
861
|
+
const templateRef = await downloadGitHubSubdir(
|
|
862
|
+
REPO,
|
|
863
|
+
`${TEMPLATES_DIR}/${sourceTemplate}`,
|
|
864
|
+
targetDir,
|
|
865
|
+
);
|
|
866
|
+
return { templateSource: "github", templateRef };
|
|
867
|
+
}
|
|
868
|
+
|
|
869
|
+
/** A template dir inside the installed core package ships with the CLI;
|
|
870
|
+
* anything above it belongs to a framework checkout. */
|
|
871
|
+
function localTemplateSourceKind(
|
|
872
|
+
localTemplate: string,
|
|
873
|
+
): "bundled" | "local-checkout" {
|
|
874
|
+
const packageRoot = path.resolve(__dirname, "../..");
|
|
875
|
+
const rel = path.relative(packageRoot, path.resolve(localTemplate));
|
|
876
|
+
return rel && !rel.startsWith("..") && !path.isAbsolute(rel)
|
|
877
|
+
? "bundled"
|
|
878
|
+
: "local-checkout";
|
|
846
879
|
}
|
|
847
880
|
|
|
848
881
|
function templateSourceName(name: string): string {
|
|
@@ -1000,6 +1033,17 @@ async function scaffoldRequiredPackages(
|
|
|
1000
1033
|
}
|
|
1001
1034
|
}
|
|
1002
1035
|
}
|
|
1036
|
+
// These packages' `exports` maps point at `./dist/*`, and `dist/` is
|
|
1037
|
+
// gitignored (never committed), so a scaffolded workspace must build
|
|
1038
|
+
// it on install. pnpm always runs `prepare` for workspace packages,
|
|
1039
|
+
// unlike `postinstall`, so this is the reliable hook.
|
|
1040
|
+
if (
|
|
1041
|
+
pkg.scripts &&
|
|
1042
|
+
typeof pkg.scripts.build === "string" &&
|
|
1043
|
+
!pkg.scripts.prepare
|
|
1044
|
+
) {
|
|
1045
|
+
pkg.scripts.prepare = "npm run build";
|
|
1046
|
+
}
|
|
1003
1047
|
fs.writeFileSync(pkgJsonPath, JSON.stringify(pkg, null, 2) + "\n");
|
|
1004
1048
|
} catch {}
|
|
1005
1049
|
}
|
|
@@ -1039,12 +1083,16 @@ function postProcessStandalone(
|
|
|
1039
1083
|
name: string,
|
|
1040
1084
|
targetDir: string,
|
|
1041
1085
|
templateName?: string,
|
|
1086
|
+
resolution?: ScaffoldTemplateResolution,
|
|
1042
1087
|
): void {
|
|
1043
1088
|
const appTitle = appTitleForScaffold(name);
|
|
1044
1089
|
replacePlaceholders(targetDir, name, appTitle);
|
|
1045
1090
|
rewriteTrackingAppId(targetDir, name, templateName);
|
|
1046
1091
|
rewriteAgentChatAppId(targetDir, name, templateName);
|
|
1047
|
-
fixPackageJsonName(targetDir, name, templateName
|
|
1092
|
+
fixPackageJsonName(targetDir, name, templateName, {
|
|
1093
|
+
...resolution,
|
|
1094
|
+
shape: "standalone",
|
|
1095
|
+
});
|
|
1048
1096
|
fixWebManifestName(targetDir, name, templateName);
|
|
1049
1097
|
rewriteNetlifyToml(targetDir, name, "standalone");
|
|
1050
1098
|
|
|
@@ -1393,6 +1441,19 @@ export {
|
|
|
1393
1441
|
startShapePromptOptions as _startShapePromptOptions,
|
|
1394
1442
|
shouldSkipScaffoldEntry as _shouldSkipScaffoldEntry,
|
|
1395
1443
|
tarExtractArgs as _tarExtractArgs,
|
|
1444
|
+
downloadGitHubSubdir as _downloadGitHubSubdir,
|
|
1445
|
+
findLocalTemplate as _findLocalTemplate,
|
|
1446
|
+
templateSourceName as _templateSourceName,
|
|
1447
|
+
normalizeTemplateName as _normalizeTemplateName,
|
|
1448
|
+
appTitleForScaffold as _appTitleForScaffold,
|
|
1449
|
+
replacePlaceholders as _replacePlaceholders,
|
|
1450
|
+
rewriteTrackingAppId as _rewriteTrackingAppId,
|
|
1451
|
+
rewriteAgentChatAppId as _rewriteAgentChatAppId,
|
|
1452
|
+
fixWebManifestName as _fixWebManifestName,
|
|
1453
|
+
copyDir as _copyDir,
|
|
1454
|
+
localTemplateSourceKind as _localTemplateSourceKind,
|
|
1455
|
+
REPO as _REPO,
|
|
1456
|
+
TEMPLATES_DIR as _TEMPLATES_DIR,
|
|
1396
1457
|
};
|
|
1397
1458
|
|
|
1398
1459
|
/* ─────────────────────────────────────────────────────────────────────────
|
|
@@ -1479,13 +1540,17 @@ async function downloadAndExtract(
|
|
|
1479
1540
|
}
|
|
1480
1541
|
}
|
|
1481
1542
|
|
|
1543
|
+
/** Resolves to the ref that actually succeeded so callers can record it. */
|
|
1482
1544
|
async function downloadGitHubSubdir(
|
|
1483
1545
|
repo: string,
|
|
1484
1546
|
subdir: string,
|
|
1485
1547
|
targetDir: string,
|
|
1486
|
-
|
|
1548
|
+
refOverride?: string[],
|
|
1549
|
+
): Promise<string> {
|
|
1487
1550
|
validateRepoName(repo);
|
|
1488
|
-
const refs =
|
|
1551
|
+
const refs = refOverride?.length
|
|
1552
|
+
? refOverride
|
|
1553
|
+
: getGitHubTemplateRefCandidates();
|
|
1489
1554
|
if (refs.length === 0) {
|
|
1490
1555
|
throw new Error(
|
|
1491
1556
|
"Cannot download first-party scaffold files without a versioned @agent-native/core package.",
|
|
@@ -1510,7 +1575,7 @@ async function downloadGitHubSubdir(
|
|
|
1510
1575
|
);
|
|
1511
1576
|
}
|
|
1512
1577
|
copyDir(srcDir, targetDir);
|
|
1513
|
-
return;
|
|
1578
|
+
return ref;
|
|
1514
1579
|
} catch (err) {
|
|
1515
1580
|
errors.push(
|
|
1516
1581
|
` ${ref}: ${err instanceof Error ? err.message.split("\n")[0] : String(err)}`,
|
|
@@ -1678,6 +1743,7 @@ function fixPackageJsonName(
|
|
|
1678
1743
|
appDir: string,
|
|
1679
1744
|
name: string,
|
|
1680
1745
|
templateName?: string,
|
|
1746
|
+
provenance?: ScaffoldProvenance,
|
|
1681
1747
|
): void {
|
|
1682
1748
|
const pkgPath = path.join(appDir, "package.json");
|
|
1683
1749
|
if (!fs.existsSync(pkgPath)) return;
|
|
@@ -1706,9 +1772,18 @@ function fixPackageJsonName(
|
|
|
1706
1772
|
!Array.isArray(pkg["agent-native"])
|
|
1707
1773
|
? pkg["agent-native"]
|
|
1708
1774
|
: {};
|
|
1775
|
+
const coreVersion = getCorePackageVersion();
|
|
1709
1776
|
agentNative.scaffold = {
|
|
1710
1777
|
template: trackingTemplateName(templateName),
|
|
1711
1778
|
frameworkSkills: scaffoldGuidance,
|
|
1779
|
+
...(provenance?.templateRef
|
|
1780
|
+
? { templateRef: provenance.templateRef }
|
|
1781
|
+
: {}),
|
|
1782
|
+
...(provenance?.templateSource
|
|
1783
|
+
? { templateSource: provenance.templateSource }
|
|
1784
|
+
: {}),
|
|
1785
|
+
...(coreVersion ? { coreVersion } : {}),
|
|
1786
|
+
...(provenance?.shape ? { shape: provenance.shape } : {}),
|
|
1712
1787
|
};
|
|
1713
1788
|
pkg["agent-native"] = agentNative;
|
|
1714
1789
|
}
|
|
@@ -2286,6 +2361,19 @@ function shouldSkipScaffoldEntry(name: string, srcPath?: string): boolean {
|
|
|
2286
2361
|
) {
|
|
2287
2362
|
return true;
|
|
2288
2363
|
}
|
|
2364
|
+
// `.generated/bridge` is committed source, not a build artifact: the design
|
|
2365
|
+
// app imports it at module load, so skipping it yields a workspace that 500s
|
|
2366
|
+
// on every page. Everything else under `.generated` is regenerated at dev time.
|
|
2367
|
+
if (pathParts?.at(-2) === ".generated") {
|
|
2368
|
+
return name !== "bridge";
|
|
2369
|
+
}
|
|
2370
|
+
if (
|
|
2371
|
+
name === ".generated" &&
|
|
2372
|
+
srcPath &&
|
|
2373
|
+
fs.existsSync(path.join(srcPath, "bridge"))
|
|
2374
|
+
) {
|
|
2375
|
+
return false;
|
|
2376
|
+
}
|
|
2289
2377
|
if (
|
|
2290
2378
|
name === "node_modules" ||
|
|
2291
2379
|
name === ".agent-native" ||
|
|
@@ -884,6 +884,21 @@ switch (command) {
|
|
|
884
884
|
break;
|
|
885
885
|
}
|
|
886
886
|
|
|
887
|
+
case "template": {
|
|
888
|
+
// Pull later upstream first-party template changes into a generated app
|
|
889
|
+
// via a 3-way merge against the tree it was scaffolded from.
|
|
890
|
+
import("./template-sync.js")
|
|
891
|
+
.then(async (m) => {
|
|
892
|
+
const code = await m.runTemplate(args);
|
|
893
|
+
process.exit(code);
|
|
894
|
+
})
|
|
895
|
+
.catch((err) => {
|
|
896
|
+
console.error(err?.message ?? err);
|
|
897
|
+
process.exit(1);
|
|
898
|
+
});
|
|
899
|
+
break;
|
|
900
|
+
}
|
|
901
|
+
|
|
887
902
|
case "doctor": {
|
|
888
903
|
// Scan app source for security-critical guard invariants (see
|
|
889
904
|
// `agent-native doctor --help`). For dependency-pin health, see
|
|
@@ -1243,6 +1258,11 @@ Usage:
|
|
|
1243
1258
|
skills, and typecheck. Prefer this over
|
|
1244
1259
|
patching core/dispatch. 'upgrade check' is
|
|
1245
1260
|
doctor-only.
|
|
1261
|
+
agent-native template <cmd> Pull later upstream template changes into an
|
|
1262
|
+
app generated from a first-party template, via
|
|
1263
|
+
a 3-way merge against the tree it was
|
|
1264
|
+
scaffolded from. cmds: status | diff | sync |
|
|
1265
|
+
baseline | accept. Run after 'upgrade'.
|
|
1246
1266
|
agent-native add-app [name] Add one or more apps to the current workspace
|
|
1247
1267
|
agent-native workspace-dev Start the multi-app workspace gateway
|
|
1248
1268
|
agent-native deploy Build & deploy every app in the workspace to
|
|
@@ -0,0 +1,410 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Baseline store for `agent-native template`.
|
|
3
|
+
*
|
|
4
|
+
* A baseline is the pristine upstream tree an app was generated from — the
|
|
5
|
+
* "base" side of the 3-way merge. It is stored as a git ref under
|
|
6
|
+
* `refs/agent-native/template-baseline/<app-path>` so it never shows up as
|
|
7
|
+
* working-tree files, and as a gzipped tar under `.agent-native/` only when
|
|
8
|
+
* the app is not inside a git repository at all.
|
|
9
|
+
*
|
|
10
|
+
* Every git operation here is plumbing driven by a throwaway `GIT_INDEX_FILE`
|
|
11
|
+
* and an out-of-tree `--work-tree`. Nothing in this file may move HEAD, touch
|
|
12
|
+
* the user's index, or write into their working tree.
|
|
13
|
+
*/
|
|
14
|
+
import { execFileSync } from "node:child_process";
|
|
15
|
+
import fs from "node:fs";
|
|
16
|
+
import os from "node:os";
|
|
17
|
+
import path from "node:path";
|
|
18
|
+
|
|
19
|
+
export type BaselineSlot = "baseline" | "pending";
|
|
20
|
+
|
|
21
|
+
export interface BaselineStore {
|
|
22
|
+
appDir: string;
|
|
23
|
+
/** Absolute `.git` directory, or null when the app is not in a repo. */
|
|
24
|
+
gitDir: string | null;
|
|
25
|
+
/** Absolute work-tree root, or null when the app is not in a repo. */
|
|
26
|
+
repoRoot: string | null;
|
|
27
|
+
/** Repo-relative posix prefix the app lives at ("" when app === repo root). */
|
|
28
|
+
prefix: string;
|
|
29
|
+
/** Stable id used in ref names and tarball filenames. */
|
|
30
|
+
slug: string;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export interface BaselineWriteMeta {
|
|
34
|
+
template: string;
|
|
35
|
+
templateRef: string;
|
|
36
|
+
coreVersion?: string;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export interface BaselineWriteResult {
|
|
40
|
+
kind: "git-ref" | "tarball";
|
|
41
|
+
/** Ref name or tarball path. */
|
|
42
|
+
location: string;
|
|
43
|
+
/** Commit sha for git refs. */
|
|
44
|
+
commit?: string;
|
|
45
|
+
configuredRefspecs: string[];
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const REF_NAMESPACE = "refs/agent-native";
|
|
49
|
+
const GIT_IDENTITY = {
|
|
50
|
+
GIT_AUTHOR_NAME: "agent-native",
|
|
51
|
+
GIT_AUTHOR_EMAIL: "noreply@agent-native.com",
|
|
52
|
+
GIT_COMMITTER_NAME: "agent-native",
|
|
53
|
+
GIT_COMMITTER_EMAIL: "noreply@agent-native.com",
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
export function resolveBaselineStore(appDir: string): BaselineStore {
|
|
57
|
+
// git reports realpaths; comparing against a symlinked temp path (macOS
|
|
58
|
+
// /var → /private/var) would compute a nonsense repo-relative prefix.
|
|
59
|
+
const resolved = realpath(path.resolve(appDir));
|
|
60
|
+
const gitDir = findGitDir(resolved);
|
|
61
|
+
const repoRoot = gitDir ? findRepoRoot(resolved) : null;
|
|
62
|
+
const prefix =
|
|
63
|
+
repoRoot && repoRoot !== resolved
|
|
64
|
+
? path.relative(repoRoot, resolved).split(path.sep).join("/")
|
|
65
|
+
: "";
|
|
66
|
+
return {
|
|
67
|
+
appDir: resolved,
|
|
68
|
+
gitDir,
|
|
69
|
+
repoRoot,
|
|
70
|
+
prefix,
|
|
71
|
+
slug: sanitizeRefPath(prefix || path.basename(resolved)),
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export function baselineRefName(
|
|
76
|
+
store: BaselineStore,
|
|
77
|
+
slot: BaselineSlot,
|
|
78
|
+
): string {
|
|
79
|
+
return `${REF_NAMESPACE}/template-${slot}/${store.slug}`;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export function baselineTarballPath(
|
|
83
|
+
store: BaselineStore,
|
|
84
|
+
slot: BaselineSlot,
|
|
85
|
+
): string {
|
|
86
|
+
return path.join(
|
|
87
|
+
store.appDir,
|
|
88
|
+
".agent-native",
|
|
89
|
+
`template-${slot}`,
|
|
90
|
+
`${path.basename(store.appDir)}.tar.gz`,
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export function baselineExists(
|
|
95
|
+
store: BaselineStore,
|
|
96
|
+
slot: BaselineSlot,
|
|
97
|
+
): boolean {
|
|
98
|
+
if (store.gitDir)
|
|
99
|
+
return revParse(store, baselineRefName(store, slot)) !== null;
|
|
100
|
+
return fs.existsSync(baselineTarballPath(store, slot));
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export function baselineDescription(
|
|
104
|
+
store: BaselineStore,
|
|
105
|
+
slot: BaselineSlot,
|
|
106
|
+
): string | null {
|
|
107
|
+
if (!store.gitDir) {
|
|
108
|
+
const file = baselineTarballPath(store, slot);
|
|
109
|
+
return fs.existsSync(file) ? file : null;
|
|
110
|
+
}
|
|
111
|
+
const ref = baselineRefName(store, slot);
|
|
112
|
+
const commit = revParse(store, ref);
|
|
113
|
+
if (!commit) return null;
|
|
114
|
+
const subject = git(store, ["log", "-1", "--format=%s", commit]).trim();
|
|
115
|
+
return `${ref} (${commit.slice(0, 12)}) ${subject}`;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Snapshot `sourceDir` into the baseline store. Writes through a temporary
|
|
120
|
+
* index and an out-of-tree work-tree so HEAD, the real index, and the working
|
|
121
|
+
* tree are untouched.
|
|
122
|
+
*/
|
|
123
|
+
export function writeBaseline(
|
|
124
|
+
store: BaselineStore,
|
|
125
|
+
sourceDir: string,
|
|
126
|
+
slot: BaselineSlot,
|
|
127
|
+
meta: BaselineWriteMeta,
|
|
128
|
+
): BaselineWriteResult {
|
|
129
|
+
if (!store.gitDir) {
|
|
130
|
+
const file = baselineTarballPath(store, slot);
|
|
131
|
+
fs.mkdirSync(path.dirname(file), { recursive: true });
|
|
132
|
+
execFileSync("tar", ["-czf", file, "-C", sourceDir, "."], {
|
|
133
|
+
stdio: "pipe",
|
|
134
|
+
});
|
|
135
|
+
return { kind: "tarball", location: file, configuredRefspecs: [] };
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
const stage = fs.mkdtempSync(path.join(os.tmpdir(), "an-template-baseline-"));
|
|
139
|
+
try {
|
|
140
|
+
const stageRoot = path.join(stage, "tree");
|
|
141
|
+
const target = store.prefix
|
|
142
|
+
? path.join(stageRoot, ...store.prefix.split("/"))
|
|
143
|
+
: stageRoot;
|
|
144
|
+
fs.mkdirSync(target, { recursive: true });
|
|
145
|
+
copyPlainTree(sourceDir, target);
|
|
146
|
+
|
|
147
|
+
const indexFile = path.join(stage, "index");
|
|
148
|
+
const env = { ...process.env, ...GIT_IDENTITY, GIT_INDEX_FILE: indexFile };
|
|
149
|
+
// --force: the app's own .gitignore lives inside the staged tree and would
|
|
150
|
+
// otherwise drop scaffolded files from the baseline.
|
|
151
|
+
git(store, ["--work-tree", stageRoot, "add", "-A", "--force", "."], {
|
|
152
|
+
cwd: stageRoot,
|
|
153
|
+
env,
|
|
154
|
+
});
|
|
155
|
+
const tree = git(store, ["write-tree"], { cwd: stageRoot, env }).trim();
|
|
156
|
+
|
|
157
|
+
const ref = baselineRefName(store, slot);
|
|
158
|
+
const parent = revParse(store, ref);
|
|
159
|
+
const message = [
|
|
160
|
+
`agent-native template ${slot}: ${meta.template}`,
|
|
161
|
+
"",
|
|
162
|
+
`template: ${meta.template}`,
|
|
163
|
+
`templateRef: ${meta.templateRef}`,
|
|
164
|
+
`coreVersion: ${meta.coreVersion ?? "unknown"}`,
|
|
165
|
+
`path: ${store.prefix || "."}`,
|
|
166
|
+
].join("\n");
|
|
167
|
+
const commit = git(
|
|
168
|
+
store,
|
|
169
|
+
["commit-tree", tree, ...(parent ? ["-p", parent] : []), "-m", message],
|
|
170
|
+
{ cwd: stageRoot, env },
|
|
171
|
+
).trim();
|
|
172
|
+
|
|
173
|
+
git(store, ["update-ref", ref, commit, ...(parent ? [parent] : [])]);
|
|
174
|
+
return {
|
|
175
|
+
kind: "git-ref",
|
|
176
|
+
location: ref,
|
|
177
|
+
commit,
|
|
178
|
+
configuredRefspecs: parent ? [] : ensureBaselineRefspecs(store),
|
|
179
|
+
};
|
|
180
|
+
} finally {
|
|
181
|
+
fs.rmSync(stage, { recursive: true, force: true });
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/** Point `slot` at whatever `from` currently points at. */
|
|
186
|
+
export function promoteBaseline(
|
|
187
|
+
store: BaselineStore,
|
|
188
|
+
from: BaselineSlot,
|
|
189
|
+
to: BaselineSlot,
|
|
190
|
+
): boolean {
|
|
191
|
+
if (!store.gitDir) {
|
|
192
|
+
const src = baselineTarballPath(store, from);
|
|
193
|
+
if (!fs.existsSync(src)) return false;
|
|
194
|
+
const dst = baselineTarballPath(store, to);
|
|
195
|
+
fs.mkdirSync(path.dirname(dst), { recursive: true });
|
|
196
|
+
fs.copyFileSync(src, dst);
|
|
197
|
+
fs.rmSync(src, { force: true });
|
|
198
|
+
return true;
|
|
199
|
+
}
|
|
200
|
+
const commit = revParse(store, baselineRefName(store, from));
|
|
201
|
+
if (!commit) return false;
|
|
202
|
+
git(store, ["update-ref", baselineRefName(store, to), commit]);
|
|
203
|
+
git(store, ["update-ref", "-d", baselineRefName(store, from)]);
|
|
204
|
+
return true;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
export function clearBaseline(store: BaselineStore, slot: BaselineSlot): void {
|
|
208
|
+
if (!store.gitDir) {
|
|
209
|
+
fs.rmSync(baselineTarballPath(store, slot), { force: true });
|
|
210
|
+
return;
|
|
211
|
+
}
|
|
212
|
+
if (revParse(store, baselineRefName(store, slot))) {
|
|
213
|
+
git(store, ["update-ref", "-d", baselineRefName(store, slot)]);
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* Extract a stored baseline into a fresh temp directory whose root is the app
|
|
219
|
+
* root. Returns null when the slot is empty. Callers own the returned dir.
|
|
220
|
+
*/
|
|
221
|
+
export function materializeBaseline(
|
|
222
|
+
store: BaselineStore,
|
|
223
|
+
slot: BaselineSlot,
|
|
224
|
+
): string | null {
|
|
225
|
+
const out = fs.mkdtempSync(path.join(os.tmpdir(), "an-template-base-"));
|
|
226
|
+
try {
|
|
227
|
+
if (!store.gitDir) {
|
|
228
|
+
const file = baselineTarballPath(store, slot);
|
|
229
|
+
if (!fs.existsSync(file)) {
|
|
230
|
+
fs.rmSync(out, { recursive: true, force: true });
|
|
231
|
+
return null;
|
|
232
|
+
}
|
|
233
|
+
execFileSync("tar", ["-xzf", file, "-C", out], { stdio: "pipe" });
|
|
234
|
+
return out;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
const ref = baselineRefName(store, slot);
|
|
238
|
+
if (!revParse(store, ref)) {
|
|
239
|
+
fs.rmSync(out, { recursive: true, force: true });
|
|
240
|
+
return null;
|
|
241
|
+
}
|
|
242
|
+
const tarPath = path.join(out, ".baseline.tar");
|
|
243
|
+
const args = ["archive", "--format=tar", "-o", tarPath, ref];
|
|
244
|
+
if (store.prefix) args.push("--", store.prefix);
|
|
245
|
+
git(store, args);
|
|
246
|
+
const strip = store.prefix ? store.prefix.split("/").length : 0;
|
|
247
|
+
execFileSync(
|
|
248
|
+
"tar",
|
|
249
|
+
[
|
|
250
|
+
"-xf",
|
|
251
|
+
tarPath,
|
|
252
|
+
"-C",
|
|
253
|
+
out,
|
|
254
|
+
...(strip ? [`--strip-components=${strip}`] : []),
|
|
255
|
+
],
|
|
256
|
+
{ stdio: "pipe" },
|
|
257
|
+
);
|
|
258
|
+
fs.rmSync(tarPath, { force: true });
|
|
259
|
+
return out;
|
|
260
|
+
} catch (err) {
|
|
261
|
+
fs.rmSync(out, { recursive: true, force: true });
|
|
262
|
+
throw err;
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
/**
|
|
267
|
+
* Teach the repo's remote to carry `refs/agent-native/*` so baselines survive
|
|
268
|
+
* clone and push. Returns the refspecs it actually added.
|
|
269
|
+
*/
|
|
270
|
+
export function ensureBaselineRefspecs(store: BaselineStore): string[] {
|
|
271
|
+
if (!store.gitDir) return [];
|
|
272
|
+
const remotes = git(store, ["remote"])
|
|
273
|
+
.split("\n")
|
|
274
|
+
.map((line) => line.trim())
|
|
275
|
+
.filter(Boolean);
|
|
276
|
+
if (remotes.length === 0) return [];
|
|
277
|
+
const remote = remotes.includes("origin") ? "origin" : remotes[0]!;
|
|
278
|
+
const spec = "+refs/agent-native/*:refs/agent-native/*";
|
|
279
|
+
const added: string[] = [];
|
|
280
|
+
for (const key of ["fetch", "push"] as const) {
|
|
281
|
+
const existing = gitAllowFail(store, [
|
|
282
|
+
"config",
|
|
283
|
+
"--get-all",
|
|
284
|
+
`remote.${remote}.${key}`,
|
|
285
|
+
]);
|
|
286
|
+
if (existing.split("\n").some((line) => line.trim() === spec)) continue;
|
|
287
|
+
git(store, ["config", "--add", `remote.${remote}.${key}`, spec]);
|
|
288
|
+
added.push(`remote.${remote}.${key}`);
|
|
289
|
+
}
|
|
290
|
+
return added;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
/** Uncommitted changes under the app dir, as porcelain lines. */
|
|
294
|
+
export function appDirtyPaths(store: BaselineStore): string[] {
|
|
295
|
+
if (!store.gitDir) return [];
|
|
296
|
+
const out = gitAllowFail(store, [
|
|
297
|
+
"status",
|
|
298
|
+
"--porcelain",
|
|
299
|
+
"--",
|
|
300
|
+
store.prefix || ".",
|
|
301
|
+
]);
|
|
302
|
+
return out
|
|
303
|
+
.split("\n")
|
|
304
|
+
.map((line) => line.trim())
|
|
305
|
+
.filter(Boolean);
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
/* ─────────────────────────────────────────────────────────────────────────
|
|
309
|
+
* Internals
|
|
310
|
+
* ───────────────────────────────────────────────────────────────────────── */
|
|
311
|
+
|
|
312
|
+
function git(
|
|
313
|
+
store: BaselineStore,
|
|
314
|
+
args: string[],
|
|
315
|
+
options: { cwd?: string; env?: NodeJS.ProcessEnv } = {},
|
|
316
|
+
): string {
|
|
317
|
+
return execFileSync("git", ["--git-dir", store.gitDir!, ...args], {
|
|
318
|
+
// Without an explicit work tree, `--git-dir` makes git treat cwd as the
|
|
319
|
+
// work-tree root, which turns every sibling path into a phantom deletion.
|
|
320
|
+
cwd: options.cwd ?? store.repoRoot ?? store.appDir,
|
|
321
|
+
encoding: "utf-8",
|
|
322
|
+
env: options.env ?? { ...process.env, ...GIT_IDENTITY },
|
|
323
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
324
|
+
maxBuffer: 256 * 1024 * 1024,
|
|
325
|
+
});
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
function gitAllowFail(store: BaselineStore, args: string[]): string {
|
|
329
|
+
try {
|
|
330
|
+
return git(store, args);
|
|
331
|
+
} catch {
|
|
332
|
+
return "";
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
function revParse(store: BaselineStore, ref: string): string | null {
|
|
337
|
+
if (!store.gitDir) return null;
|
|
338
|
+
const out = gitAllowFail(store, ["rev-parse", "--verify", "--quiet", ref]);
|
|
339
|
+
return out.trim() || null;
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
function realpath(dir: string): string {
|
|
343
|
+
try {
|
|
344
|
+
return fs.realpathSync(dir);
|
|
345
|
+
} catch {
|
|
346
|
+
return dir;
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
function findGitDir(dir: string): string | null {
|
|
351
|
+
try {
|
|
352
|
+
return execFileSync("git", ["rev-parse", "--absolute-git-dir"], {
|
|
353
|
+
cwd: dir,
|
|
354
|
+
encoding: "utf-8",
|
|
355
|
+
stdio: ["ignore", "pipe", "ignore"],
|
|
356
|
+
}).trim();
|
|
357
|
+
} catch {
|
|
358
|
+
return null;
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
function findRepoRoot(dir: string): string | null {
|
|
363
|
+
try {
|
|
364
|
+
return execFileSync("git", ["rev-parse", "--show-toplevel"], {
|
|
365
|
+
cwd: dir,
|
|
366
|
+
encoding: "utf-8",
|
|
367
|
+
stdio: ["ignore", "pipe", "ignore"],
|
|
368
|
+
}).trim();
|
|
369
|
+
} catch {
|
|
370
|
+
return null;
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
/** Copy regular files and directories only. Symlinks are never part of a
|
|
375
|
+
* baseline: they are agent-tool conveniences, not upstream content. */
|
|
376
|
+
function copyPlainTree(src: string, dest: string): void {
|
|
377
|
+
fs.mkdirSync(dest, { recursive: true });
|
|
378
|
+
for (const entry of fs.readdirSync(src, { withFileTypes: true })) {
|
|
379
|
+
if (entry.isSymbolicLink()) continue;
|
|
380
|
+
const from = path.join(src, entry.name);
|
|
381
|
+
const to = path.join(dest, entry.name);
|
|
382
|
+
if (entry.isDirectory()) {
|
|
383
|
+
if (entry.name === ".git") continue;
|
|
384
|
+
copyPlainTree(from, to);
|
|
385
|
+
} else if (entry.isFile()) {
|
|
386
|
+
fs.copyFileSync(from, to);
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
/** Make each path segment safe for `git check-ref-format`. */
|
|
392
|
+
export function sanitizeRefPath(value: string): string {
|
|
393
|
+
const segments = value
|
|
394
|
+
.split("/")
|
|
395
|
+
.map((segment) => sanitizeRefSegment(segment))
|
|
396
|
+
.filter(Boolean);
|
|
397
|
+
return segments.length > 0 ? segments.join("/") : "app";
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
function sanitizeRefSegment(segment: string): string {
|
|
401
|
+
let out = segment
|
|
402
|
+
// eslint-disable-next-line no-control-regex
|
|
403
|
+
.replace(/[\u0000-\u0020\u007f~^:?*\[\\]/g, "-")
|
|
404
|
+
.replace(/\.\.+/g, "-")
|
|
405
|
+
.replace(/@\{/g, "-");
|
|
406
|
+
while (out.startsWith(".")) out = out.slice(1);
|
|
407
|
+
while (out.endsWith(".")) out = out.slice(0, -1);
|
|
408
|
+
if (out.endsWith(".lock")) out = `${out.slice(0, -".lock".length)}-lock`;
|
|
409
|
+
return out;
|
|
410
|
+
}
|