@agent-native/core 0.121.1 → 0.122.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/corpus/README.md +2 -2
- package/corpus/core/CHANGELOG.md +145 -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/getting-started.mdx +477 -115
- 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/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/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/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/default/.agents/skills/upgrade-agent-native/SKILL.md +24 -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 +5 -0
- 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/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/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/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/assets/.agents/skills/upgrade-agent-native/SKILL.md +24 -2
- package/corpus/templates/brain/.agents/skills/upgrade-agent-native/SKILL.md +24 -2
- package/corpus/templates/brain/_gitignore +1 -0
- package/corpus/templates/calendar/.agents/skills/upgrade-agent-native/SKILL.md +24 -2
- package/corpus/templates/calendar/_gitignore +1 -0
- package/corpus/templates/chat/.agents/skills/upgrade-agent-native/SKILL.md +24 -2
- package/corpus/templates/chat/_gitignore +1 -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/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/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.meetings.$meetingId.tsx +27 -0
- package/corpus/templates/clips/app/routes/r.$recordingId.tsx +46 -15
- package/corpus/templates/clips/app/routes/record.tsx +77 -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/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 +25 -0
- package/corpus/templates/clips/server/lib/agent-views.ts +145 -0
- 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/db.ts +23 -0
- 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/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/dispatch/.agents/skills/upgrade-agent-native/SKILL.md +24 -2
- package/corpus/templates/dispatch/_gitignore +1 -0
- package/corpus/templates/dispatch/changelog/2026-07-24-signing-in-now-puts-you-in-your-companys-workspace.md +6 -0
- package/corpus/templates/forms/.agents/skills/upgrade-agent-native/SKILL.md +24 -2
- package/corpus/templates/forms/_gitignore +1 -0
- package/corpus/templates/forms/server/lib/public-form-ssr.ts +2 -2
- package/corpus/templates/macros/.agents/skills/upgrade-agent-native/SKILL.md +24 -2
- package/corpus/templates/macros/_gitignore +1 -0
- package/corpus/templates/mail/.agents/skills/upgrade-agent-native/SKILL.md +24 -2
- package/corpus/templates/mail/_gitignore +1 -0
- package/corpus/templates/plan/.agents/skills/upgrade-agent-native/SKILL.md +24 -2
- package/corpus/templates/plan/_gitignore +1 -0
- package/corpus/templates/slides/.agents/skills/upgrade-agent-native/SKILL.md +24 -2
- package/corpus/templates/slides/_gitignore +1 -0
- 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/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/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/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/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 +3 -3
- 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/resources/handlers.d.ts +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/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/default/.agents/skills/upgrade-agent-native/SKILL.md +24 -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 +2 -0
- 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/getting-started.mdx +477 -115
- 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/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/sse-event-processor.ts +3 -0
- package/src/data-widgets/index.ts +41 -0
- package/src/deploy/build.ts +11 -9
- 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/default/.agents/skills/upgrade-agent-native/SKILL.md +24 -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 +5 -0
|
@@ -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
|
+
}
|