@agent-native/core 0.113.0 → 0.114.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/agent-native.eject.json +164 -0
- package/corpus/README.md +3 -3
- package/corpus/core/CHANGELOG.md +20 -0
- package/corpus/core/README.md +61 -174
- package/corpus/core/agent-native.eject.json +164 -0
- package/corpus/core/docs/content/agent-native-toolkit.mdx +38 -0
- package/corpus/core/docs/content/package-lifecycle.mdx +54 -4
- package/corpus/core/package.json +15 -2
- package/corpus/core/src/cli/eject.ts +1594 -0
- package/corpus/core/src/cli/index.ts +16 -0
- package/corpus/core/src/client/build-compatibility.ts +77 -0
- package/corpus/core/src/client/index.ts +4 -0
- package/corpus/core/src/client/resources/McpConnectionSuggestion.tsx +8 -2
- package/corpus/core/src/client/resources/McpIntegrationDialog.tsx +7 -2
- package/corpus/core/src/client/resources/ResourcesPanel.tsx +17 -3
- package/corpus/core/src/client/resources/index.ts +19 -0
- package/corpus/core/src/client/resources/mcp-integration-catalog.ts +9 -1
- package/corpus/core/src/client/resources/runtime.ts +1 -0
- package/corpus/core/src/client/route-chunk-recovery/index.ts +1 -0
- package/corpus/core/src/client/setup-connections/catalog.ts +6 -0
- package/corpus/core/src/client/setup-connections/index.ts +1 -0
- package/corpus/core/src/client/setup-connections/runtime.ts +1 -0
- package/corpus/core/src/client/use-action.ts +32 -1
- package/corpus/core/src/connections/catalog.ts +41 -24
- package/corpus/core/src/connections/index.ts +1 -0
- package/corpus/core/src/connections/runtime.ts +1 -0
- package/corpus/core/src/deploy/build.ts +4 -1
- package/corpus/core/src/eject/provider-api-definitions.ts +193 -0
- package/corpus/core/src/eject/remote-mcp-presets.ts +137 -0
- package/corpus/core/src/eject/setup-readiness-ui.tsx +29 -0
- package/corpus/core/src/eject/workspace-connections.ts +92 -0
- package/corpus/core/src/index.ts +1 -0
- package/corpus/core/src/integrations/adapter-overrides.ts +12 -0
- package/corpus/core/src/integrations/eject/messaging-adapters.ts +85 -0
- package/corpus/core/src/integrations/index.ts +5 -1
- package/corpus/core/src/integrations/plugin.ts +34 -12
- package/corpus/core/src/integrations/runtime.ts +1 -0
- package/corpus/core/src/integrations/types.ts +3 -1
- package/corpus/core/src/org/context.ts +56 -30
- package/corpus/core/src/package-lifecycle/eject-manifest.ts +345 -0
- package/corpus/core/src/package-lifecycle/index.ts +1 -0
- package/corpus/core/src/provider-api/index.ts +46 -12
- package/corpus/core/src/provider-api/runtime.ts +1 -0
- package/corpus/core/src/server/action-routes.ts +52 -2
- package/corpus/core/src/server/auth-plugin.ts +9 -4
- package/corpus/core/src/server/better-auth-instance.ts +5 -1
- package/corpus/core/src/setup-connections/index.ts +1 -0
- package/corpus/core/src/shared/mcp-embed-headers.ts +1 -1
- package/corpus/core/src/shared/merge-by-id.ts +14 -0
- package/corpus/core/src/templates/default/.agents/skills/agent-native-docs/SKILL.md +15 -13
- package/corpus/core/src/templates/default/.agents/skills/customizing-agent-native/SKILL.md +63 -20
- package/corpus/core/src/templates/default/.agents/skills/self-modifying-code/SKILL.md +9 -6
- package/corpus/core/src/templates/default/AGENTS.md +6 -5
- package/corpus/core/src/templates/headless/.agents/skills/agent-native-docs/SKILL.md +15 -13
- package/corpus/core/src/templates/headless/.agents/skills/customizing-agent-native/SKILL.md +63 -20
- package/corpus/core/src/templates/headless/AGENTS.md +5 -4
- package/corpus/core/src/templates/workspace-core/.agents/skills/agent-native-docs/SKILL.md +15 -13
- package/corpus/core/src/templates/workspace-core/.agents/skills/agent-native-toolkit/SKILL.md +3 -2
- package/corpus/core/src/templates/workspace-core/.agents/skills/customizing-agent-native/SKILL.md +63 -20
- package/corpus/core/src/templates/workspace-core/.agents/skills/self-modifying-code/SKILL.md +9 -6
- package/corpus/core/src/templates/workspace-core/AGENTS.md +4 -4
- package/corpus/core/src/templates/workspace-root/AGENTS.md +4 -4
- package/corpus/core/src/vite/client.ts +42 -2
- package/corpus/templates/analytics/.agents/skills/customizing-agent-native/SKILL.md +63 -20
- package/corpus/templates/analytics/.agents/skills/self-modifying-code/SKILL.md +9 -6
- package/corpus/templates/assets/.agents/skills/customizing-agent-native/SKILL.md +63 -20
- package/corpus/templates/assets/.agents/skills/self-modifying-code/SKILL.md +9 -6
- package/corpus/templates/brain/.agents/skills/customizing-agent-native/SKILL.md +63 -20
- package/corpus/templates/brain/.agents/skills/self-modifying-code/SKILL.md +9 -6
- package/corpus/templates/brain/actions/remediate-legacy-capture-audiences.ts +167 -0
- package/corpus/templates/brain/app/lib/brain-chat-readiness.ts +6 -0
- package/corpus/templates/brain/app/routes/_index.tsx +8 -0
- package/corpus/templates/brain/app/routes.ts +1 -0
- package/corpus/templates/brain/changelog/2026-07-19-ask-starts-immediately-when-builder-s-managed-ai-connection-.md +6 -0
- package/corpus/templates/brain/changelog/2026-07-19-slack-and-granola-backfills-now-process-captures-concurrentl.md +6 -0
- package/corpus/templates/brain/changelog/2026-07-19-source-review-settings-now-control-knowledge-approval.md +6 -0
- package/corpus/templates/brain/changelog/2026-07-19-the-manage-agent-page-now-opens-correctly-from-brain-navigat.md +6 -0
- package/corpus/templates/brain/server/db/schema.ts +3 -0
- package/corpus/templates/brain/server/lib/brain.ts +41 -2
- package/corpus/templates/brain/server/lib/connectors.ts +379 -113
- package/corpus/templates/brain/server/lib/meeting-audience.ts +38 -0
- package/corpus/templates/brain/server/plugins/db.ts +10 -0
- package/corpus/templates/brain/server/routes/api/_agent-native/brain/ingest.post.ts +6 -4
- package/corpus/templates/calendar/.agents/skills/customizing-agent-native/SKILL.md +63 -20
- package/corpus/templates/calendar/.agents/skills/self-modifying-code/SKILL.md +9 -6
- package/corpus/templates/chat/.agents/skills/agent-native-docs/SKILL.md +15 -13
- package/corpus/templates/chat/.agents/skills/customizing-agent-native/SKILL.md +63 -20
- package/corpus/templates/chat/.agents/skills/self-modifying-code/SKILL.md +9 -6
- package/corpus/templates/chat/AGENTS.md +3 -2
- package/corpus/templates/clips/.agents/skills/customizing-agent-native/SKILL.md +63 -20
- package/corpus/templates/clips/.agents/skills/self-modifying-code/SKILL.md +9 -6
- package/corpus/templates/content/.agents/skills/customizing-agent-native/SKILL.md +63 -20
- package/corpus/templates/content/.agents/skills/self-modifying-code/SKILL.md +9 -6
- package/corpus/templates/content/AGENTS.md +2 -0
- package/corpus/templates/content/actions/_content-database-personal-view.ts +49 -5
- package/corpus/templates/content/actions/_content-document-access.ts +21 -0
- package/corpus/templates/content/actions/_content-favorites.ts +91 -0
- package/corpus/templates/content/actions/_content-files.ts +79 -23
- package/corpus/templates/content/actions/_content-sidebar-state.ts +24 -0
- package/corpus/templates/content/actions/_content-space-access.ts +15 -17
- package/corpus/templates/content/actions/_content-space-catalog-guards.ts +20 -0
- package/corpus/templates/content/actions/_content-spaces.ts +364 -167
- package/corpus/templates/content/actions/_database-source-utils.ts +8 -0
- package/corpus/templates/content/actions/_database-utils.ts +249 -15
- package/corpus/templates/content/actions/_delete-content-space.ts +84 -0
- package/corpus/templates/content/actions/_files-system-properties.ts +499 -0
- package/corpus/templates/content/actions/_local-file-documents.ts +0 -1
- package/corpus/templates/content/actions/_property-utils.ts +18 -9
- package/corpus/templates/content/actions/bind-content-database-source-field.ts +3 -0
- package/corpus/templates/content/actions/configure-document-property.ts +3 -0
- package/corpus/templates/content/actions/create-content-database.ts +2 -2
- package/corpus/templates/content/actions/create-content-space.ts +34 -0
- package/corpus/templates/content/actions/create-document.ts +4 -1
- package/corpus/templates/content/actions/delete-content-space.ts +19 -0
- package/corpus/templates/content/actions/delete-database-items.ts +28 -1
- package/corpus/templates/content/actions/delete-document-property.ts +3 -0
- package/corpus/templates/content/actions/delete-document.ts +39 -2
- package/corpus/templates/content/actions/duplicate-database-item.ts +6 -0
- package/corpus/templates/content/actions/duplicate-database-items.ts +6 -0
- package/corpus/templates/content/actions/duplicate-document-property.ts +3 -0
- package/corpus/templates/content/actions/get-content-database.ts +11 -2
- package/corpus/templates/content/actions/get-content-sidebar-state.ts +23 -0
- package/corpus/templates/content/actions/get-document.ts +32 -7
- package/corpus/templates/content/actions/import-content-source.ts +33 -1
- package/corpus/templates/content/actions/list-content-spaces.ts +34 -2
- package/corpus/templates/content/actions/list-documents.ts +39 -7
- package/corpus/templates/content/actions/reorder-document-property.ts +9 -0
- package/corpus/templates/content/actions/set-document-property.ts +41 -23
- package/corpus/templates/content/actions/share-local-file-document.ts +15 -0
- package/corpus/templates/content/actions/submit-content-database-form.ts +7 -0
- package/corpus/templates/content/actions/sync-local-folder-source.ts +14 -0
- package/corpus/templates/content/actions/update-content-database-view.ts +1 -0
- package/corpus/templates/content/actions/update-content-sidebar-state.ts +27 -0
- package/corpus/templates/content/actions/update-document.ts +158 -66
- package/corpus/templates/content/app/components/EmptyState.tsx +4 -57
- package/corpus/templates/content/app/components/editor/CommentsSidebar.tsx +8 -1
- package/corpus/templates/content/app/components/editor/DocumentEditor.tsx +519 -178
- package/corpus/templates/content/app/components/editor/DocumentInfoPanel.tsx +39 -0
- package/corpus/templates/content/app/components/editor/DocumentProperties.tsx +1 -1
- package/corpus/templates/content/app/components/editor/DocumentToolbar.tsx +266 -7
- package/corpus/templates/content/app/components/editor/database/DatabaseView.tsx +430 -152
- package/corpus/templates/content/app/components/editor/database/sidebar.tsx +467 -66
- package/corpus/templates/content/app/components/editor/database/view-config.ts +9 -3
- package/corpus/templates/content/app/components/sidebar/DocumentSidebar.tsx +720 -196
- package/corpus/templates/content/app/components/sidebar/DocumentTreeItem.tsx +173 -1
- package/corpus/templates/content/app/components/sidebar/document-sidebar-sections.ts +1 -1
- package/corpus/templates/content/app/components/sidebar/select-content-space.ts +91 -16
- package/corpus/templates/content/app/entry.client.tsx +5 -1
- package/corpus/templates/content/app/hooks/use-content-database.ts +84 -3
- package/corpus/templates/content/app/hooks/use-content-spaces.ts +60 -2
- package/corpus/templates/content/app/hooks/use-create-page.ts +30 -0
- package/corpus/templates/content/app/hooks/use-documents.ts +270 -19
- package/corpus/templates/content/app/i18n-data.ts +243 -20
- package/corpus/templates/content/app/lib/local-folder-picker-safety.ts +54 -0
- package/corpus/templates/content/app/lib/local-folder-picker-support.ts +18 -0
- package/corpus/templates/content/app/routes/_app.favorites.tsx +30 -0
- package/corpus/templates/content/app/routes/_app.local-files.tsx +18 -6
- package/corpus/templates/content/changelog/2026-07-17-workspace-files-now-stay-in-a-loading-state-until-automatic-.md +6 -0
- package/corpus/templates/content/changelog/2026-07-17-workspace-switching-now-opens-the-selected-files-database-pr.md +6 -0
- package/corpus/templates/content/changelog/2026-07-17-workspaces-now-expand-above-their-own-files-list-without-dup.md +6 -0
- package/corpus/templates/content/changelog/2026-07-18-create-named-workspaces-each-with-its-own-private-files-data.md +6 -0
- package/corpus/templates/content/changelog/2026-07-18-favorites-align-with-workspace-and-file-rows-in-the-sidebar.md +6 -0
- package/corpus/templates/content/changelog/2026-07-18-local-folder-selection-no-longer-invokes-the-unsafe-native-p.md +6 -0
- package/corpus/templates/content/changelog/2026-07-18-made-content-workspaces-independently-expandable-restored-or.md +6 -0
- package/corpus/templates/content/changelog/2026-07-18-page-details-now-live-in-a-shared-info-and-comments-rail-dat.md +6 -0
- package/corpus/templates/content/changelog/2026-07-18-workspace-database-views-now-control-sidebar-workspace-navig.md +6 -0
- package/corpus/templates/content/changelog/2026-07-18-workspace-navigation-now-aligns-favorites-with-workspace-pag.md +6 -0
- package/corpus/templates/content/changelog/2026-07-19-favorites-now-open-as-a-table-and-compact-breadcrumbs-make-w.md +6 -0
- package/corpus/templates/content/changelog/2026-07-19-files-databases-now-start-unfiltered-sidebar-rows-exactly-fo.md +6 -0
- package/corpus/templates/content/changelog/2026-07-19-sidebar-page-trees-now-open-only-when-expanded-remember-thei.md +6 -0
- package/corpus/templates/content/changelog/2026-07-19-workspace-file-databases-now-use-the-workspace-name-open-as-.md +6 -0
- package/corpus/templates/content/changelog/2026-07-19-workspace-navigation-now-stays-stable-on-hover-uses-folder-i.md +6 -0
- package/corpus/templates/content/changelog/2026-07-19-workspace-rows-now-use-folder-icons-and-deleting-a-user-crea.md +6 -0
- package/corpus/templates/content/changelog/2026-07-19-workspaces-can-be-created-without-leaving-the-workspaces-dat.md +6 -0
- package/corpus/templates/content/e2e/global-setup.ts +3 -2
- package/corpus/templates/content/parity/matrix.md +28 -28
- package/corpus/templates/content/parity/matrix.ts +8 -2
- package/corpus/templates/content/server/db/index.ts +1 -0
- package/corpus/templates/content/server/db/schema.ts +10 -0
- package/corpus/templates/content/server/lib/documents.ts +12 -7
- package/corpus/templates/content/server/plugins/db.ts +17 -0
- package/corpus/templates/content/shared/api.ts +9 -0
- package/corpus/templates/content/shared/database-form.ts +11 -2
- package/corpus/templates/content/vite.config.ts +1 -0
- package/corpus/templates/design/.agents/skills/customizing-agent-native/SKILL.md +63 -20
- package/corpus/templates/design/.agents/skills/self-modifying-code/SKILL.md +9 -6
- package/corpus/templates/dispatch/.agents/skills/customizing-agent-native/SKILL.md +63 -20
- package/corpus/templates/dispatch/.agents/skills/self-modifying-code/SKILL.md +9 -6
- package/corpus/templates/forms/.agents/skills/customizing-agent-native/SKILL.md +63 -20
- package/corpus/templates/forms/.agents/skills/self-modifying-code/SKILL.md +9 -6
- package/corpus/templates/macros/.agents/skills/customizing-agent-native/SKILL.md +63 -20
- package/corpus/templates/mail/.agents/skills/customizing-agent-native/SKILL.md +63 -20
- package/corpus/templates/mail/.agents/skills/self-modifying-code/SKILL.md +9 -6
- package/corpus/templates/plan/.agents/skills/customizing-agent-native/SKILL.md +63 -20
- package/corpus/templates/plan/.agents/skills/self-modifying-code/SKILL.md +9 -6
- package/corpus/templates/slides/.agents/skills/customizing-agent-native/SKILL.md +63 -20
- package/corpus/templates/slides/.agents/skills/self-modifying-code/SKILL.md +9 -6
- package/corpus/templates/tasks/.agents/skills/agent-native-docs/SKILL.md +15 -13
- package/corpus/templates/tasks/.agents/skills/customizing-agent-native/SKILL.md +63 -20
- package/corpus/templates/tasks/.agents/skills/self-modifying-code/SKILL.md +9 -6
- package/corpus/toolkit/CHANGELOG.md +6 -0
- package/corpus/toolkit/agent-native.eject.json +411 -0
- package/corpus/toolkit/package.json +5 -2
- package/dist/cli/eject.d.ts +21 -0
- package/dist/cli/eject.d.ts.map +1 -0
- package/dist/cli/eject.js +1145 -0
- package/dist/cli/eject.js.map +1 -0
- package/dist/cli/index.js +15 -0
- package/dist/cli/index.js.map +1 -1
- package/dist/client/build-compatibility.d.ts +11 -0
- package/dist/client/build-compatibility.d.ts.map +1 -0
- package/dist/client/build-compatibility.js +56 -0
- package/dist/client/build-compatibility.js.map +1 -0
- package/dist/client/index.d.ts +1 -1
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +1 -1
- package/dist/client/index.js.map +1 -1
- package/dist/client/resources/McpConnectionSuggestion.d.ts +4 -3
- package/dist/client/resources/McpConnectionSuggestion.d.ts.map +1 -1
- package/dist/client/resources/McpConnectionSuggestion.js +3 -3
- package/dist/client/resources/McpConnectionSuggestion.js.map +1 -1
- package/dist/client/resources/McpIntegrationDialog.d.ts +4 -3
- package/dist/client/resources/McpIntegrationDialog.d.ts.map +1 -1
- package/dist/client/resources/McpIntegrationDialog.js +2 -2
- package/dist/client/resources/McpIntegrationDialog.js.map +1 -1
- package/dist/client/resources/ResourcesPanel.d.ts +4 -1
- package/dist/client/resources/ResourcesPanel.d.ts.map +1 -1
- package/dist/client/resources/ResourcesPanel.js +9 -7
- package/dist/client/resources/ResourcesPanel.js.map +1 -1
- package/dist/client/resources/index.d.ts +3 -0
- package/dist/client/resources/index.d.ts.map +1 -1
- package/dist/client/resources/index.js +3 -0
- package/dist/client/resources/index.js.map +1 -1
- package/dist/client/resources/mcp-integration-catalog.d.ts +2 -1
- package/dist/client/resources/mcp-integration-catalog.d.ts.map +1 -1
- package/dist/client/resources/mcp-integration-catalog.js +6 -2
- package/dist/client/resources/mcp-integration-catalog.js.map +1 -1
- package/dist/client/resources/runtime.d.ts +2 -0
- package/dist/client/resources/runtime.d.ts.map +1 -0
- package/dist/client/resources/runtime.js +2 -0
- package/dist/client/resources/runtime.js.map +1 -0
- package/dist/client/route-chunk-recovery/index.d.ts +1 -0
- package/dist/client/route-chunk-recovery/index.d.ts.map +1 -1
- package/dist/client/route-chunk-recovery/index.js +1 -0
- package/dist/client/route-chunk-recovery/index.js.map +1 -1
- package/dist/client/setup-connections/catalog.d.ts +2 -0
- package/dist/client/setup-connections/catalog.d.ts.map +1 -0
- package/dist/client/setup-connections/catalog.js +7 -0
- package/dist/client/setup-connections/catalog.js.map +1 -0
- package/dist/client/setup-connections/index.d.ts +1 -0
- package/dist/client/setup-connections/index.d.ts.map +1 -1
- package/dist/client/setup-connections/index.js +1 -0
- package/dist/client/setup-connections/index.js.map +1 -1
- package/dist/client/setup-connections/runtime.d.ts +2 -0
- package/dist/client/setup-connections/runtime.d.ts.map +1 -0
- package/dist/client/setup-connections/runtime.js +2 -0
- package/dist/client/setup-connections/runtime.js.map +1 -0
- package/dist/client/use-action.d.ts.map +1 -1
- package/dist/client/use-action.js +19 -1
- package/dist/client/use-action.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/connections/catalog.d.ts +5 -3
- package/dist/connections/catalog.d.ts.map +1 -1
- package/dist/connections/catalog.js +16 -8
- package/dist/connections/catalog.js.map +1 -1
- package/dist/connections/index.d.ts +1 -1
- package/dist/connections/index.d.ts.map +1 -1
- package/dist/connections/index.js +1 -1
- package/dist/connections/index.js.map +1 -1
- package/dist/connections/runtime.d.ts +2 -0
- package/dist/connections/runtime.d.ts.map +1 -0
- package/dist/connections/runtime.js +2 -0
- package/dist/connections/runtime.js.map +1 -0
- package/dist/deploy/build.js +2 -1
- package/dist/deploy/build.js.map +1 -1
- package/dist/eject/provider-api-definitions.d.ts +34 -0
- package/dist/eject/provider-api-definitions.d.ts.map +1 -0
- package/dist/eject/provider-api-definitions.js +88 -0
- package/dist/eject/provider-api-definitions.js.map +1 -0
- package/dist/eject/remote-mcp-presets.d.ts +17 -0
- package/dist/eject/remote-mcp-presets.d.ts.map +1 -0
- package/dist/eject/remote-mcp-presets.js +81 -0
- package/dist/eject/remote-mcp-presets.js.map +1 -0
- package/dist/eject/setup-readiness-ui.d.ts +7 -0
- package/dist/eject/setup-readiness-ui.d.ts.map +1 -0
- package/dist/eject/setup-readiness-ui.js +13 -0
- package/dist/eject/setup-readiness-ui.js.map +1 -0
- package/dist/eject/workspace-connections.d.ts +11 -0
- package/dist/eject/workspace-connections.d.ts.map +1 -0
- package/dist/eject/workspace-connections.js +47 -0
- package/dist/eject/workspace-connections.js.map +1 -0
- package/dist/file-upload/actions/upload-image.d.ts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/integrations/adapter-overrides.d.ts +3 -0
- package/dist/integrations/adapter-overrides.d.ts.map +1 -0
- package/dist/integrations/adapter-overrides.js +7 -0
- package/dist/integrations/adapter-overrides.js.map +1 -0
- package/dist/integrations/eject/messaging-adapters.d.ts +12 -0
- package/dist/integrations/eject/messaging-adapters.d.ts.map +1 -0
- package/dist/integrations/eject/messaging-adapters.js +49 -0
- package/dist/integrations/eject/messaging-adapters.js.map +1 -0
- package/dist/integrations/index.d.ts +3 -2
- package/dist/integrations/index.d.ts.map +1 -1
- package/dist/integrations/index.js +2 -1
- package/dist/integrations/index.js.map +1 -1
- package/dist/integrations/plugin.d.ts +32 -1
- package/dist/integrations/plugin.d.ts.map +1 -1
- package/dist/integrations/plugin.js +19 -12
- package/dist/integrations/plugin.js.map +1 -1
- package/dist/integrations/runtime.d.ts +2 -0
- package/dist/integrations/runtime.d.ts.map +1 -0
- package/dist/integrations/runtime.js +2 -0
- package/dist/integrations/runtime.js.map +1 -0
- package/dist/integrations/types.d.ts +3 -1
- package/dist/integrations/types.d.ts.map +1 -1
- package/dist/integrations/types.js.map +1 -1
- package/dist/notifications/routes.d.ts +2 -2
- package/dist/observability/routes.d.ts +5 -5
- package/dist/org/context.d.ts +4 -2
- package/dist/org/context.d.ts.map +1 -1
- package/dist/org/context.js +44 -22
- package/dist/org/context.js.map +1 -1
- package/dist/package-lifecycle/eject-manifest.d.ts +43 -0
- package/dist/package-lifecycle/eject-manifest.d.ts.map +1 -0
- package/dist/package-lifecycle/eject-manifest.js +219 -0
- package/dist/package-lifecycle/eject-manifest.js.map +1 -0
- package/dist/package-lifecycle/index.d.ts +1 -0
- package/dist/package-lifecycle/index.d.ts.map +1 -1
- package/dist/package-lifecycle/index.js +1 -0
- package/dist/package-lifecycle/index.js.map +1 -1
- package/dist/provider-api/actions/custom-provider-registration.d.ts +11 -11
- package/dist/provider-api/actions/provider-api.d.ts +11 -11
- package/dist/provider-api/index.d.ts +6 -2
- package/dist/provider-api/index.d.ts.map +1 -1
- package/dist/provider-api/index.js +25 -12
- package/dist/provider-api/index.js.map +1 -1
- package/dist/provider-api/runtime.d.ts +2 -0
- package/dist/provider-api/runtime.d.ts.map +1 -0
- package/dist/provider-api/runtime.js +2 -0
- package/dist/provider-api/runtime.js.map +1 -0
- package/dist/resources/handlers.d.ts +1 -1
- package/dist/server/action-routes.d.ts.map +1 -1
- package/dist/server/action-routes.js +32 -2
- package/dist/server/action-routes.js.map +1 -1
- package/dist/server/auth-plugin.d.ts.map +1 -1
- package/dist/server/auth-plugin.js +9 -5
- package/dist/server/auth-plugin.js.map +1 -1
- package/dist/server/better-auth-instance.d.ts.map +1 -1
- package/dist/server/better-auth-instance.js +4 -1
- package/dist/server/better-auth-instance.js.map +1 -1
- package/dist/setup-connections/index.d.ts +1 -1
- package/dist/setup-connections/index.d.ts.map +1 -1
- package/dist/setup-connections/index.js +1 -1
- package/dist/setup-connections/index.js.map +1 -1
- package/dist/shared/mcp-embed-headers.d.ts +1 -1
- package/dist/shared/mcp-embed-headers.d.ts.map +1 -1
- package/dist/shared/mcp-embed-headers.js +1 -1
- package/dist/shared/mcp-embed-headers.js.map +1 -1
- package/dist/shared/merge-by-id.d.ts +5 -0
- package/dist/shared/merge-by-id.d.ts.map +1 -0
- package/dist/shared/merge-by-id.js +7 -0
- package/dist/shared/merge-by-id.js.map +1 -0
- package/dist/templates/chat/.agents/skills/agent-native-docs/SKILL.md +15 -13
- package/dist/templates/chat/.agents/skills/customizing-agent-native/SKILL.md +63 -20
- package/dist/templates/chat/.agents/skills/self-modifying-code/SKILL.md +9 -6
- package/dist/templates/chat/AGENTS.md +3 -2
- package/dist/templates/default/.agents/skills/agent-native-docs/SKILL.md +15 -13
- package/dist/templates/default/.agents/skills/customizing-agent-native/SKILL.md +63 -20
- package/dist/templates/default/.agents/skills/self-modifying-code/SKILL.md +9 -6
- package/dist/templates/default/AGENTS.md +6 -5
- package/dist/templates/headless/.agents/skills/agent-native-docs/SKILL.md +15 -13
- package/dist/templates/headless/.agents/skills/customizing-agent-native/SKILL.md +63 -20
- package/dist/templates/headless/AGENTS.md +5 -4
- package/dist/templates/workspace-core/.agents/skills/agent-native-docs/SKILL.md +15 -13
- package/dist/templates/workspace-core/.agents/skills/agent-native-toolkit/SKILL.md +3 -2
- package/dist/templates/workspace-core/.agents/skills/customizing-agent-native/SKILL.md +63 -20
- package/dist/templates/workspace-core/.agents/skills/self-modifying-code/SKILL.md +9 -6
- package/dist/templates/workspace-core/AGENTS.md +4 -4
- package/dist/templates/workspace-root/AGENTS.md +4 -4
- package/dist/vite/client.d.ts +6 -0
- package/dist/vite/client.d.ts.map +1 -1
- package/dist/vite/client.js +30 -2
- package/dist/vite/client.js.map +1 -1
- package/docs/content/agent-native-toolkit.mdx +38 -0
- package/docs/content/package-lifecycle.mdx +54 -4
- package/package.json +15 -2
- package/src/a2a/agent-card.ts +83 -0
- package/src/a2a/artifact-response.ts +1648 -0
- package/src/a2a/auth-policy.ts +66 -0
- package/src/a2a/caller-auth.ts +102 -0
- package/src/a2a/client.ts +876 -0
- package/src/a2a/correlation.ts +50 -0
- package/src/a2a/handlers.ts +1285 -0
- package/src/a2a/index.ts +50 -0
- package/src/a2a/invoke.ts +348 -0
- package/src/a2a/response-text.ts +53 -0
- package/src/a2a/server.ts +586 -0
- package/src/a2a/task-store.ts +917 -0
- package/src/a2a/types.ts +221 -0
- package/src/a2a-claims.ts +52 -0
- package/src/action-change-marker.ts +74 -0
- package/src/action-ui.ts +38 -0
- package/src/action.ts +1406 -0
- package/src/adapters/cli/index.ts +6 -0
- package/src/adapters/cli/registry.ts +73 -0
- package/src/adapters/cli/shell-adapter.ts +92 -0
- package/src/adapters/cli/types.ts +27 -0
- package/src/agent/action-continuation-guidance.ts +38 -0
- package/src/agent/app-model-defaults.ts +201 -0
- package/src/agent/context-xray/actions/context-evict.ts +56 -0
- package/src/agent/context-xray/actions/context-manifest-get.ts +75 -0
- package/src/agent/context-xray/actions/context-pin.ts +56 -0
- package/src/agent/context-xray/actions/context-preview-get.ts +134 -0
- package/src/agent/context-xray/actions/context-report.ts +75 -0
- package/src/agent/context-xray/actions/context-restore.ts +51 -0
- package/src/agent/context-xray/actions/errors.ts +40 -0
- package/src/agent/context-xray/apply-directives.ts +137 -0
- package/src/agent/context-xray/directives-store.ts +178 -0
- package/src/agent/context-xray/identity.ts +37 -0
- package/src/agent/context-xray/manifest.ts +284 -0
- package/src/agent/context-xray/migrations.ts +32 -0
- package/src/agent/context-xray/plugin.ts +23 -0
- package/src/agent/context-xray/schema.ts +17 -0
- package/src/agent/context-xray/segments.ts +194 -0
- package/src/agent/context-xray/tokenize.ts +93 -0
- package/src/agent/default-model.ts +5 -0
- package/src/agent/durable-background.ts +547 -0
- package/src/agent/engine/ai-sdk-engine.ts +565 -0
- package/src/agent/engine/anthropic-engine.ts +320 -0
- package/src/agent/engine/builder-engine.ts +1110 -0
- package/src/agent/engine/builder-gateway-headers.ts +44 -0
- package/src/agent/engine/builtin.ts +122 -0
- package/src/agent/engine/context-directives-transform.ts +73 -0
- package/src/agent/engine/continuation-dispatch-retry.ts +168 -0
- package/src/agent/engine/credential-errors.ts +69 -0
- package/src/agent/engine/index.ts +54 -0
- package/src/agent/engine/openai-compatible-endpoint.ts +25 -0
- package/src/agent/engine/output-tokens.ts +181 -0
- package/src/agent/engine/provider-env-vars.ts +69 -0
- package/src/agent/engine/registry.ts +853 -0
- package/src/agent/engine/tool-call-journal-seed.ts +85 -0
- package/src/agent/engine/translate-ai-sdk.ts +407 -0
- package/src/agent/engine/translate-anthropic.ts +611 -0
- package/src/agent/engine/types.ts +310 -0
- package/src/agent/harness/acp-adapter.ts +893 -0
- package/src/agent/harness/acp-builtin.ts +70 -0
- package/src/agent/harness/ai-sdk-adapter.ts +509 -0
- package/src/agent/harness/background.ts +365 -0
- package/src/agent/harness/builtin.ts +50 -0
- package/src/agent/harness/index.ts +86 -0
- package/src/agent/harness/lifecycle.ts +498 -0
- package/src/agent/harness/registry.ts +97 -0
- package/src/agent/harness/runner.ts +182 -0
- package/src/agent/harness/store.ts +466 -0
- package/src/agent/harness/translate.ts +130 -0
- package/src/agent/harness/types.ts +129 -0
- package/src/agent/index.ts +32 -0
- package/src/agent/loop-settings.ts +186 -0
- package/src/agent/model-config.ts +363 -0
- package/src/agent/observational-memory/compactor.ts +78 -0
- package/src/agent/observational-memory/config.ts +78 -0
- package/src/agent/observational-memory/index.ts +79 -0
- package/src/agent/observational-memory/internal-run.ts +89 -0
- package/src/agent/observational-memory/message-text.ts +49 -0
- package/src/agent/observational-memory/migrations.ts +44 -0
- package/src/agent/observational-memory/observer.ts +128 -0
- package/src/agent/observational-memory/plugin.ts +35 -0
- package/src/agent/observational-memory/prompts.ts +53 -0
- package/src/agent/observational-memory/read.ts +131 -0
- package/src/agent/observational-memory/reflector.ts +119 -0
- package/src/agent/observational-memory/schema.ts +48 -0
- package/src/agent/observational-memory/store.ts +275 -0
- package/src/agent/observational-memory/types.ts +65 -0
- package/src/agent/processors.ts +209 -0
- package/src/agent/production-agent.ts +8254 -0
- package/src/agent/run-loop-with-resume.ts +394 -0
- package/src/agent/run-manager.ts +1825 -0
- package/src/agent/run-ownership.ts +75 -0
- package/src/agent/run-store.ts +2601 -0
- package/src/agent/runtime-context.ts +169 -0
- package/src/agent/thread-data-builder.ts +1584 -0
- package/src/agent/tool-call-journal.ts +368 -0
- package/src/agent/tool-error-redaction.ts +52 -0
- package/src/agent/tool-result-images.ts +178 -0
- package/src/agent/tool-search.ts +376 -0
- package/src/agent/types.ts +372 -0
- package/src/agent-native/index.ts +198 -0
- package/src/agent-web/config.ts +253 -0
- package/src/agent-web/generator.ts +382 -0
- package/src/agent-web/index.ts +36 -0
- package/src/appearance/actions/change-appearance.ts +35 -0
- package/src/application-state/emitter.ts +81 -0
- package/src/application-state/handlers.ts +121 -0
- package/src/application-state/index.ts +44 -0
- package/src/application-state/script-helpers.ts +155 -0
- package/src/application-state/store.ts +274 -0
- package/src/assets/branding/agent-native.icon/Assets/background.svg +3 -0
- package/src/assets/branding/agent-native.icon/Assets/foreground.svg +12 -0
- package/src/assets/branding/agent-native.icon/icon.json +49 -0
- package/src/assets/branding/favicon.png +0 -0
- package/src/assets/branding/favicon.svg +1 -0
- package/src/assets/branding/icon-on-dark.svg +10 -0
- package/src/assets/branding/icon-on-light.svg +10 -0
- package/src/assets/branding/mac-app-icon.svg +1 -0
- package/src/assets/branding/slack-bot/agent-native-1024.png +0 -0
- package/src/assets/branding/slack-bot/agent-native-512.png +0 -0
- package/src/assets/branding/tray-icon.svg +6 -0
- package/src/assets/branding/wordmark-on-dark.svg +21 -0
- package/src/assets/branding/wordmark-on-light.svg +21 -0
- package/src/assets/fonts/LICENSE_LIBERATION +96 -0
- package/src/assets/fonts/LICENSE_NOTO_NASKH_ARABIC +93 -0
- package/src/assets/fonts/LiberationSans-Bold.ttf +0 -0
- package/src/assets/fonts/LiberationSans-Regular.ttf +0 -0
- package/src/assets/fonts/NotoNaskhArabic-Variable.ttf +0 -0
- package/src/audit/actions/export-audit-events.ts +162 -0
- package/src/audit/actions/get-audit-event.ts +24 -0
- package/src/audit/actions/list-audit-events.ts +66 -0
- package/src/audit/cleanup-job.ts +100 -0
- package/src/audit/config.ts +90 -0
- package/src/audit/index.ts +43 -0
- package/src/audit/record.ts +180 -0
- package/src/audit/redact.ts +109 -0
- package/src/audit/store.ts +346 -0
- package/src/audit/types.ts +141 -0
- package/src/automation/index.ts +802 -0
- package/src/brand-kit/brand-signals.ts +124 -0
- package/src/brand-kit/fig/index.ts +64 -0
- package/src/brand-kit/index.ts +72 -0
- package/src/brand-kit/types.ts +113 -0
- package/src/browser-sessions/actions.ts +302 -0
- package/src/browser-sessions/routes.ts +234 -0
- package/src/browser-sessions/store.ts +679 -0
- package/src/browser-sessions/types.ts +84 -0
- package/src/changelog/parse.ts +328 -0
- package/src/chat-threads/emitter.ts +22 -0
- package/src/chat-threads/schema.ts +43 -0
- package/src/chat-threads/store.ts +1311 -0
- package/src/checkpoints/index.ts +15 -0
- package/src/checkpoints/service.ts +142 -0
- package/src/checkpoints/store.ts +153 -0
- package/src/cli/add.ts +425 -0
- package/src/cli/agent.ts +424 -0
- package/src/cli/agents.ts +122 -0
- package/src/cli/app-skill.ts +1455 -0
- package/src/cli/atomic-json-file.ts +324 -0
- package/src/cli/audit-agent-web.ts +324 -0
- package/src/cli/changelog.ts +199 -0
- package/src/cli/claude-code-participant.ts +515 -0
- package/src/cli/code-agent-commands.ts +270 -0
- package/src/cli/code-agent-connector.ts +1109 -0
- package/src/cli/code-agent-executor.ts +1970 -0
- package/src/cli/code-agent-output-smoother.ts +140 -0
- package/src/cli/code-agent-runs.concurrent-worker.ts +33 -0
- package/src/cli/code-agent-runs.ts +548 -0
- package/src/cli/code.ts +1805 -0
- package/src/cli/codex-cli-participant.ts +496 -0
- package/src/cli/connect.ts +2714 -0
- package/src/cli/content-local.ts +442 -0
- package/src/cli/context-xray-local.ts +2193 -0
- package/src/cli/create-workspace.ts +30 -0
- package/src/cli/create.ts +2247 -0
- package/src/cli/deploy-build.ts +50 -0
- package/src/cli/design-connect.ts +3187 -0
- package/src/cli/doctor.ts +472 -0
- package/src/cli/eject.ts +1594 -0
- package/src/cli/eval.ts +134 -0
- package/src/cli/gateway-helpers.ts +70 -0
- package/src/cli/index.ts +1217 -0
- package/src/cli/info.ts +105 -0
- package/src/cli/invoke.ts +288 -0
- package/src/cli/mcp-config-writers.ts +857 -0
- package/src/cli/mcp.ts +594 -0
- package/src/cli/migrate.ts +1813 -0
- package/src/cli/migration-codemod.ts +646 -0
- package/src/cli/multi-frontier-runs.ts +1952 -0
- package/src/cli/package-lifecycle.ts +823 -0
- package/src/cli/plan-blocks.ts +143 -0
- package/src/cli/plan-local.ts +3189 -0
- package/src/cli/plan-publish-store.ts +138 -0
- package/src/cli/pr-visual-recap-workflow.ts +2 -0
- package/src/cli/recap.ts +5 -0
- package/src/cli/setup-agents.ts +120 -0
- package/src/cli/skills-content/assets-skill.ts +83 -0
- package/src/cli/skills-content/canvas.ts +153 -0
- package/src/cli/skills-content/connection.ts +52 -0
- package/src/cli/skills-content/content-skill.ts +120 -0
- package/src/cli/skills-content/design-exploration-skill.ts +118 -0
- package/src/cli/skills-content/design-visual-edit-skill.ts +228 -0
- package/src/cli/skills-content/document-quality.ts +196 -0
- package/src/cli/skills-content/exemplar.ts +69 -0
- package/src/cli/skills-content/help.ts +77 -0
- package/src/cli/skills-content/index.ts +22 -0
- package/src/cli/skills-content/local-files.ts +100 -0
- package/src/cli/skills-content/plan-setup-auth.ts +80 -0
- package/src/cli/skills-content/visual-plan-skill.ts +493 -0
- package/src/cli/skills-content/visual-recap-skill.ts +553 -0
- package/src/cli/skills-content/visualize-repo-skill.ts +93 -0
- package/src/cli/skills-content/wireframe.ts +349 -0
- package/src/cli/skills.ts +4340 -0
- package/src/cli/sync-builder-starter-manifest.ts +631 -0
- package/src/cli/telemetry.ts +136 -0
- package/src/cli/templates-meta.ts +269 -0
- package/src/cli/upgrade.ts +956 -0
- package/src/cli/visualize-repo.ts +715 -0
- package/src/cli/workspace-dev.ts +1486 -0
- package/src/cli/workspacify.ts +258 -0
- package/src/client/AgentAskPopover.tsx +89 -0
- package/src/client/AgentChatHome.tsx +66 -0
- package/src/client/AgentNative.tsx +161 -0
- package/src/client/AgentNativeEmbedded.tsx +288 -0
- package/src/client/AgentNativeFrame.tsx +151 -0
- package/src/client/AgentPanel.tsx +3437 -0
- package/src/client/AgentTaskCard.tsx +273 -0
- package/src/client/AppearancePicker.tsx +79 -0
- package/src/client/AssistantChat.tsx +5793 -0
- package/src/client/ClientOnly.tsx +22 -0
- package/src/client/CommandMenu.tsx +726 -0
- package/src/client/ConnectBuilderCard.tsx +390 -0
- package/src/client/DefaultSpinner.tsx +47 -0
- package/src/client/ErrorBoundary.tsx +359 -0
- package/src/client/ErrorReportActions.tsx +69 -0
- package/src/client/FeedbackButton.tsx +553 -0
- package/src/client/HighlightedCodeBlock.tsx +173 -0
- package/src/client/IframeEmbed.tsx +151 -0
- package/src/client/KeepTabOpenNotice.tsx +181 -0
- package/src/client/MultiTabAssistantChat.tsx +2576 -0
- package/src/client/NewWorkspaceAppFlow.tsx +525 -0
- package/src/client/PoweredByBadge.tsx +284 -0
- package/src/client/RunStuckBanner.tsx +431 -0
- package/src/client/StarfieldBackground.tsx +466 -0
- package/src/client/Turnstile.tsx +125 -0
- package/src/client/active-run-state.ts +139 -0
- package/src/client/agent-chat/index.ts +279 -0
- package/src/client/agent-chat-adapter.ts +3692 -0
- package/src/client/agent-chat.ts +1233 -0
- package/src/client/agent-engine-key.ts +122 -0
- package/src/client/agent-page/AgentContextTab.tsx +487 -0
- package/src/client/agent-page/AgentEmptyState.tsx +44 -0
- package/src/client/agent-page/AgentJobsTab.tsx +441 -0
- package/src/client/agent-page/AgentTabFrame.tsx +39 -0
- package/src/client/agent-page/AgentTabsPage.tsx +1096 -0
- package/src/client/agent-page/types.ts +18 -0
- package/src/client/agent-page/use-jobs.ts +150 -0
- package/src/client/agent-sidebar-state.ts +166 -0
- package/src/client/analytics/index.ts +40 -0
- package/src/client/analytics-session.ts +70 -0
- package/src/client/analytics.ts +1757 -0
- package/src/client/api-path.ts +124 -0
- package/src/client/app-providers.tsx +230 -0
- package/src/client/appearance.ts +130 -0
- package/src/client/application-state.ts +154 -0
- package/src/client/assistant-ui-recovery.tsx +205 -0
- package/src/client/automation/index.ts +4 -0
- package/src/client/automation.ts +22 -0
- package/src/client/blocks/AiEditableField.tsx +30 -0
- package/src/client/blocks/BlockView.tsx +145 -0
- package/src/client/blocks/RegistryBlockDataProvider.tsx +121 -0
- package/src/client/blocks/SchemaBlockEditor.tsx +457 -0
- package/src/client/blocks/agent.ts +95 -0
- package/src/client/blocks/code-block-direction.ts +21 -0
- package/src/client/blocks/index.ts +308 -0
- package/src/client/blocks/library/AnnotatedCodeBlock.tsx +710 -0
- package/src/client/blocks/library/ApiEndpointBlock.tsx +1120 -0
- package/src/client/blocks/library/DataModelBlock.tsx +775 -0
- package/src/client/blocks/library/DiffBlock.tsx +1854 -0
- package/src/client/blocks/library/FileTreeBlock.tsx +868 -0
- package/src/client/blocks/library/HighlightedCode.tsx +260 -0
- package/src/client/blocks/library/JsonExplorerBlock.tsx +608 -0
- package/src/client/blocks/library/MermaidBlock.tsx +362 -0
- package/src/client/blocks/library/OpenApiSpecBlock.tsx +998 -0
- package/src/client/blocks/library/annotated-code.config.ts +101 -0
- package/src/client/blocks/library/annotation-rail.tsx +1020 -0
- package/src/client/blocks/library/api-endpoint.config.ts +207 -0
- package/src/client/blocks/library/block-copy.ts +399 -0
- package/src/client/blocks/library/callout.config.ts +57 -0
- package/src/client/blocks/library/callout.tsx +149 -0
- package/src/client/blocks/library/checklist.config.ts +56 -0
- package/src/client/blocks/library/checklist.tsx +208 -0
- package/src/client/blocks/library/code-filename-label.tsx +59 -0
- package/src/client/blocks/library/code-highlight.tsx +178 -0
- package/src/client/blocks/library/code-tabs.config.ts +70 -0
- package/src/client/blocks/library/code-tabs.tsx +606 -0
- package/src/client/blocks/library/code.config.ts +69 -0
- package/src/client/blocks/library/code.tsx +440 -0
- package/src/client/blocks/library/columns.config.ts +85 -0
- package/src/client/blocks/library/columns.tsx +334 -0
- package/src/client/blocks/library/data-model.config.ts +152 -0
- package/src/client/blocks/library/dev-doc-ui.tsx +191 -0
- package/src/client/blocks/library/diagram.config.ts +222 -0
- package/src/client/blocks/library/diagram.tsx +958 -0
- package/src/client/blocks/library/diff.config.ts +115 -0
- package/src/client/blocks/library/file-tree.config.ts +92 -0
- package/src/client/blocks/library/html.config.ts +79 -0
- package/src/client/blocks/library/html.tsx +258 -0
- package/src/client/blocks/library/json-explorer.config.ts +74 -0
- package/src/client/blocks/library/mermaid.config.ts +49 -0
- package/src/client/blocks/library/narrow-container.tsx +37 -0
- package/src/client/blocks/library/openapi-spec.config.ts +66 -0
- package/src/client/blocks/library/question-form.config.ts +127 -0
- package/src/client/blocks/library/question-form.tsx +944 -0
- package/src/client/blocks/library/sanitize-html.ts +343 -0
- package/src/client/blocks/library/server-specs.ts +338 -0
- package/src/client/blocks/library/specs.tsx +308 -0
- package/src/client/blocks/library/table.config.ts +61 -0
- package/src/client/blocks/library/table.tsx +449 -0
- package/src/client/blocks/library/tabs.config.ts +96 -0
- package/src/client/blocks/library/tabs.tsx +665 -0
- package/src/client/blocks/library/wireframe-icons.ts +210 -0
- package/src/client/blocks/library/wireframe-kit.tsx +1850 -0
- package/src/client/blocks/library/wireframe.config.ts +539 -0
- package/src/client/blocks/library/wireframe.tsx +535 -0
- package/src/client/blocks/mdx.ts +364 -0
- package/src/client/blocks/provider.tsx +51 -0
- package/src/client/blocks/registry.ts +83 -0
- package/src/client/blocks/schema-form/introspect.ts +201 -0
- package/src/client/blocks/server.ts +170 -0
- package/src/client/blocks/types.ts +415 -0
- package/src/client/browser-session-bridge.ts +548 -0
- package/src/client/browser-tab-id.ts +36 -0
- package/src/client/build-compatibility.ts +77 -0
- package/src/client/builder-frame.ts +194 -0
- package/src/client/builder-mark.tsx +21 -0
- package/src/client/changelog/Changelog.tsx +333 -0
- package/src/client/changelog/index.ts +1 -0
- package/src/client/chat/ChatHistoryList.tsx +7 -0
- package/src/client/chat/attachment-adapters.ts +426 -0
- package/src/client/chat/connectors.ts +1579 -0
- package/src/client/chat/index.ts +160 -0
- package/src/client/chat/markdown-renderer.tsx +693 -0
- package/src/client/chat/message-components.tsx +1326 -0
- package/src/client/chat/repo-helpers.ts +281 -0
- package/src/client/chat/run-recovery.tsx +994 -0
- package/src/client/chat/runtime.ts +1810 -0
- package/src/client/chat/tool-call-display.tsx +1270 -0
- package/src/client/chat/tool-render-registry.tsx +144 -0
- package/src/client/chat/use-agent-chat-lifecycle-tracking.ts +74 -0
- package/src/client/chat/use-reconnect-reader-owner.ts +28 -0
- package/src/client/chat/widgets/DataChartRenderer.tsx +242 -0
- package/src/client/chat/widgets/DataChartWidget.tsx +51 -0
- package/src/client/chat/widgets/DataInsightsWidget.tsx +59 -0
- package/src/client/chat/widgets/DataTableWidget.tsx +240 -0
- package/src/client/chat/widgets/InlineExtensionWidget.tsx +60 -0
- package/src/client/chat/widgets/builtin-tool-renderers.tsx +213 -0
- package/src/client/chat/widgets/data-widget-types.ts +1 -0
- package/src/client/chat/widgets/inline-extension-result.ts +86 -0
- package/src/client/chat-model-groups.ts +171 -0
- package/src/client/chat-thread-url.ts +11 -0
- package/src/client/chat-view-transition.ts +213 -0
- package/src/client/client-action.ts +21 -0
- package/src/client/client-bootstrap.ts +7 -0
- package/src/client/client-surface.ts +41 -0
- package/src/client/clipboard.ts +89 -0
- package/src/client/code-agent-chat-adapter.ts +537 -0
- package/src/client/collab/index.ts +60 -0
- package/src/client/command-navigation/index.ts +15 -0
- package/src/client/comments-review/index.ts +1 -0
- package/src/client/components/AgentPresenceChip.tsx +4 -0
- package/src/client/components/ApiKeySettings.tsx +309 -0
- package/src/client/components/CodeAgentIndicator.tsx +59 -0
- package/src/client/components/CodeRequiredDialog.tsx +470 -0
- package/src/client/components/LiveCursorOverlay.tsx +5 -0
- package/src/client/components/MissingKeyCard.tsx +61 -0
- package/src/client/components/PresenceBar.tsx +4 -0
- package/src/client/components/RecentEditHighlights.tsx +4 -0
- package/src/client/components/RemoteSelectionRings.tsx +5 -0
- package/src/client/components/icons/AgentNativeIcon.tsx +46 -0
- package/src/client/components/ui/dialog.tsx +1 -0
- package/src/client/components/ui/dropdown-menu.tsx +1 -0
- package/src/client/components/ui/hover-card.tsx +1 -0
- package/src/client/components/ui/message-scroller.tsx +131 -0
- package/src/client/components/ui/popover.tsx +1 -0
- package/src/client/components/ui/sheet.tsx +1 -0
- package/src/client/components/ui/tooltip.tsx +1 -0
- package/src/client/composer/index.ts +11 -0
- package/src/client/composer/runtime-adapters.tsx +123 -0
- package/src/client/composer/use-mention-search.ts +7 -0
- package/src/client/composer/wired-components.tsx +53 -0
- package/src/client/context-xray/ContextMeter.tsx +124 -0
- package/src/client/context-xray/ContextSegmentRow.tsx +27 -0
- package/src/client/context-xray/ContextTreemap.tsx +24 -0
- package/src/client/context-xray/ContextXRayPanel.tsx +59 -0
- package/src/client/context-xray/SegmentProvenancePopover.tsx +18 -0
- package/src/client/context-xray/format.ts +27 -0
- package/src/client/conversation/AgentConversation.tsx +555 -0
- package/src/client/conversation/code-agent-transcript.ts +283 -0
- package/src/client/conversation/index.ts +22 -0
- package/src/client/conversation/types.ts +85 -0
- package/src/client/conversation/use-near-bottom-autoscroll.ts +278 -0
- package/src/client/create-query-client.ts +86 -0
- package/src/client/db-admin/DataGrid.tsx +551 -0
- package/src/client/db-admin/DbAdminPage.tsx +218 -0
- package/src/client/db-admin/DevDatabaseLink.tsx +16 -0
- package/src/client/db-admin/EditableCell.tsx +451 -0
- package/src/client/db-admin/FilterBar.tsx +203 -0
- package/src/client/db-admin/ResultsGrid.tsx +114 -0
- package/src/client/db-admin/RowSidePanel.tsx +337 -0
- package/src/client/db-admin/SqlEditor.tsx +840 -0
- package/src/client/db-admin/TableBrowser.tsx +212 -0
- package/src/client/db-admin/TableEditor.tsx +760 -0
- package/src/client/db-admin/cell-format.ts +246 -0
- package/src/client/db-admin/changeset.ts +296 -0
- package/src/client/db-admin/export-utils.ts +78 -0
- package/src/client/db-admin/index.ts +33 -0
- package/src/client/db-admin/sql-storage.ts +134 -0
- package/src/client/db-admin/storage.ts +68 -0
- package/src/client/db-admin/useAgentSync.ts +226 -0
- package/src/client/db-admin/useDbAdmin.ts +294 -0
- package/src/client/dev-overlay/DevOverlay.tsx +576 -0
- package/src/client/dev-overlay/builtins.ts +40 -0
- package/src/client/dev-overlay/index.ts +23 -0
- package/src/client/dev-overlay/registry.ts +67 -0
- package/src/client/dev-overlay/types.ts +64 -0
- package/src/client/dev-overlay/use-dev-option.ts +78 -0
- package/src/client/dev-overlay/use-dev-overlay-shortcut.ts +31 -0
- package/src/client/dynamic-suggestions.ts +455 -0
- package/src/client/embed-auth.ts +544 -0
- package/src/client/embed.ts +54 -0
- package/src/client/error-capture.ts +690 -0
- package/src/client/error-format.ts +211 -0
- package/src/client/error-reporting.ts +100 -0
- package/src/client/extensions/AgentNativeExtensionFrame.e2e-host.tsx +136 -0
- package/src/client/extensions/AgentNativeExtensionFrame.tsx +708 -0
- package/src/client/extensions/EmbeddedExtension.tsx +604 -0
- package/src/client/extensions/ExtensionEditor.tsx +450 -0
- package/src/client/extensions/ExtensionQueryErrorState.tsx +47 -0
- package/src/client/extensions/ExtensionSlot.tsx +345 -0
- package/src/client/extensions/ExtensionViewer.tsx +1502 -0
- package/src/client/extensions/ExtensionViewerPage.tsx +32 -0
- package/src/client/extensions/ExtensionsListPage.tsx +432 -0
- package/src/client/extensions/ExtensionsSidebarSection.tsx +1259 -0
- package/src/client/extensions/InlineExtensionFrame.tsx +660 -0
- package/src/client/extensions/agent-native-extension-runtime.ts +495 -0
- package/src/client/extensions/delete-extension.ts +76 -0
- package/src/client/extensions/extension-load-error.ts +26 -0
- package/src/client/extensions/extension-order.ts +49 -0
- package/src/client/extensions/extension-popularity.ts +61 -0
- package/src/client/extensions/iframe-bridge.ts +377 -0
- package/src/client/extensions/index.ts +84 -0
- package/src/client/extensions/portable-extension.ts +712 -0
- package/src/client/feature-flags/FeatureFlagsPanel.tsx +519 -0
- package/src/client/feature-flags/helpers.ts +77 -0
- package/src/client/feature-flags/index.ts +13 -0
- package/src/client/feature-flags/types.ts +29 -0
- package/src/client/feature-flags/use-feature-flag.ts +26 -0
- package/src/client/feedback-context.ts +90 -0
- package/src/client/frame-protocol.ts +168 -0
- package/src/client/frame.ts +329 -0
- package/src/client/guided-questions.tsx +1152 -0
- package/src/client/history/VersionHistoryPanel.tsx +175 -0
- package/src/client/history/index.ts +21 -0
- package/src/client/history/use-history.ts +114 -0
- package/src/client/hooks/index.ts +46 -0
- package/src/client/host/index.ts +170 -0
- package/src/client/host-bridge.ts +1272 -0
- package/src/client/host-tools.ts +190 -0
- package/src/client/i18n.tsx +798 -0
- package/src/client/index.ts +370 -0
- package/src/client/integrations/IntegrationCard.tsx +186 -0
- package/src/client/integrations/IntegrationsPanel.tsx +633 -0
- package/src/client/integrations/api.ts +295 -0
- package/src/client/integrations/index.ts +29 -0
- package/src/client/integrations/useIntegrationStatus.ts +52 -0
- package/src/client/mcp-app-host.ts +720 -0
- package/src/client/mcp-apps/McpAppRenderer.tsx +760 -0
- package/src/client/navigation/index.ts +54 -0
- package/src/client/notifications/NotificationsBell.tsx +383 -0
- package/src/client/notifications/index.ts +1 -0
- package/src/client/observability/ObservabilityDashboard.tsx +890 -0
- package/src/client/observability/ThumbsFeedback.tsx +160 -0
- package/src/client/observability/index.ts +20 -0
- package/src/client/observability/useObservability.ts +266 -0
- package/src/client/onboarding/OnboardingBanner.tsx +73 -0
- package/src/client/onboarding/OnboardingPanel.tsx +1036 -0
- package/src/client/onboarding/SetupButton.tsx +64 -0
- package/src/client/onboarding/index.ts +25 -0
- package/src/client/onboarding/use-onboarding.ts +164 -0
- package/src/client/onboarding/use-preview-mode.ts +40 -0
- package/src/client/org/InvitationBanner.tsx +148 -0
- package/src/client/org/OrgSwitcher.tsx +754 -0
- package/src/client/org/RequireActiveOrg.tsx +337 -0
- package/src/client/org/TeamPage.tsx +1432 -0
- package/src/client/org/hooks.ts +359 -0
- package/src/client/org/index.ts +70 -0
- package/src/client/org/workspace-app-links.ts +367 -0
- package/src/client/org-team/index.ts +1 -0
- package/src/client/progress/RunsTray.tsx +680 -0
- package/src/client/progress/index.ts +1 -0
- package/src/client/require-session.tsx +142 -0
- package/src/client/resources/BuiltinCapabilityDetail.tsx +258 -0
- package/src/client/resources/McpConnectionSuggestion.tsx +276 -0
- package/src/client/resources/McpIntegrationDialog.tsx +808 -0
- package/src/client/resources/McpServerDetail.tsx +230 -0
- package/src/client/resources/ResourceEditor.tsx +872 -0
- package/src/client/resources/ResourceTree.tsx +860 -0
- package/src/client/resources/ResourcesPanel.tsx +1960 -0
- package/src/client/resources/index.ts +25 -0
- package/src/client/resources/mcp-integration-catalog.ts +771 -0
- package/src/client/resources/mcp-integration-logos.ts +108 -0
- package/src/client/resources/runtime.ts +1 -0
- package/src/client/resources/use-builtin-capabilities.ts +113 -0
- package/src/client/resources/use-mcp-servers.ts +217 -0
- package/src/client/resources/use-resources.ts +402 -0
- package/src/client/review/ReviewCommentComposer.tsx +123 -0
- package/src/client/review/ReviewStatusBadge.tsx +39 -0
- package/src/client/review/ReviewThreadPanel.tsx +625 -0
- package/src/client/review/index.ts +38 -0
- package/src/client/review/use-review.ts +186 -0
- package/src/client/route-chunk-recovery/index.ts +2 -0
- package/src/client/route-chunk-recovery.ts +331 -0
- package/src/client/route-state.ts +455 -0
- package/src/client/route-warmup.tsx +543 -0
- package/src/client/session-replay-iframe.e2e-host.tsx +100 -0
- package/src/client/session-replay.ts +3417 -0
- package/src/client/settings/AgentsSection.tsx +441 -0
- package/src/client/settings/AutomationsSection.tsx +516 -0
- package/src/client/settings/BackgroundAgentSection.tsx +189 -0
- package/src/client/settings/BrowserSection.tsx +110 -0
- package/src/client/settings/DemoModeSection.tsx +48 -0
- package/src/client/settings/SecretsSection.tsx +875 -0
- package/src/client/settings/SettingsPanel.tsx +3162 -0
- package/src/client/settings/SettingsSection.tsx +283 -0
- package/src/client/settings/SettingsTabsPage.tsx +592 -0
- package/src/client/settings/UsageSection.tsx +401 -0
- package/src/client/settings/VoiceTranscriptionSection.tsx +960 -0
- package/src/client/settings/agent-settings-search.ts +220 -0
- package/src/client/settings/index.ts +27 -0
- package/src/client/settings/useBuilderStatus.ts +1055 -0
- package/src/client/setup-connections/BuilderConnectCard.tsx +89 -0
- package/src/client/setup-connections/ProviderReadinessBadge.tsx +73 -0
- package/src/client/setup-connections/SetupConnectionsPage.tsx +94 -0
- package/src/client/setup-connections/catalog.ts +6 -0
- package/src/client/setup-connections/index.ts +47 -0
- package/src/client/setup-connections/runtime.ts +1 -0
- package/src/client/sharing/ShareButton.tsx +1748 -0
- package/src/client/sharing/ShareDialog.tsx +846 -0
- package/src/client/sharing/VisibilityBadge.tsx +4 -0
- package/src/client/sharing/index.ts +2 -0
- package/src/client/sse-event-processor.ts +2002 -0
- package/src/client/terminal/AgentTerminal.tsx +488 -0
- package/src/client/terminal/index.ts +7 -0
- package/src/client/theme.ts +27 -0
- package/src/client/tombstone/agent-presence-chip.ts +17 -0
- package/src/client/tombstone/editor.ts +265 -0
- package/src/client/tombstone/live-cursor-overlay.ts +21 -0
- package/src/client/tombstone/presence-bar.ts +17 -0
- package/src/client/tombstone/recent-edit-highlights.ts +17 -0
- package/src/client/tombstone/remote-selection-rings.ts +21 -0
- package/src/client/tombstone/rich-markdown-editor.ts +265 -0
- package/src/client/tombstone/ui-dialog.ts +49 -0
- package/src/client/tombstone/ui-dropdown-menu.ts +69 -0
- package/src/client/tombstone/ui-hover-card.ts +21 -0
- package/src/client/tombstone/ui-popover.ts +25 -0
- package/src/client/tombstone/ui-sheet.ts +49 -0
- package/src/client/tombstone/ui-tooltip.ts +29 -0
- package/src/client/tombstone/visual-style-controls.ts +61 -0
- package/src/client/tool-cells/BashCell.tsx +164 -0
- package/src/client/tool-cells/EditCell.tsx +303 -0
- package/src/client/tool-cells/FilesChangedSummary.tsx +208 -0
- package/src/client/tool-cells/WriteCell.tsx +145 -0
- package/src/client/tool-cells/index.ts +7 -0
- package/src/client/tool-display.ts +41 -0
- package/src/client/track.ts +57 -0
- package/src/client/transcription/BuilderTranscriptionCta.tsx +120 -0
- package/src/client/transcription/use-live-transcription.ts +292 -0
- package/src/client/ui/index.ts +55 -0
- package/src/client/uploads/index.ts +6 -0
- package/src/client/uploads/upload-editor-image.ts +79 -0
- package/src/client/uploads/use-upload-resource.ts +24 -0
- package/src/client/url-scrub.ts +51 -0
- package/src/client/use-action.ts +797 -0
- package/src/client/use-agent-chat-context.ts +63 -0
- package/src/client/use-agent-chat-home-handoff.ts +207 -0
- package/src/client/use-agent-chat.ts +53 -0
- package/src/client/use-agent-engine-configured.ts +211 -0
- package/src/client/use-avatar.ts +127 -0
- package/src/client/use-change-version.ts +150 -0
- package/src/client/use-chat-models.ts +252 -0
- package/src/client/use-chat-threads.ts +1262 -0
- package/src/client/use-db-sync.ts +1112 -0
- package/src/client/use-demo-mode-status.ts +30 -0
- package/src/client/use-dev-mode.ts +177 -0
- package/src/client/use-external-value.ts +40 -0
- package/src/client/use-pausing-interval.ts +65 -0
- package/src/client/use-pinch-zoom.ts +202 -0
- package/src/client/use-run-stuck-detection.ts +427 -0
- package/src/client/use-send-to-agent-chat.ts +85 -0
- package/src/client/use-session.ts +114 -0
- package/src/client/utils.ts +7 -0
- package/src/client/visual-style-controls.tsx +1 -0
- package/src/client/vite-dev-recovery-script.ts +226 -0
- package/src/client/voice-provider-status.ts +44 -0
- package/src/client/widgets/index.ts +41 -0
- package/src/code-agents/background-controller.ts +398 -0
- package/src/code-agents/background-run.ts +156 -0
- package/src/code-agents/index.ts +95 -0
- package/src/code-agents/prompt-attachments.ts +39 -0
- package/src/code-agents/transcript-normalizer.ts +750 -0
- package/src/code-agents/transcript-order.ts +73 -0
- package/src/coding-tools/index.ts +742 -0
- package/src/coding-tools/run-code.ts +1662 -0
- package/src/coding-tools/sandbox/adapter.ts +82 -0
- package/src/coding-tools/sandbox/background.ts +406 -0
- package/src/coding-tools/sandbox/executions-store.ts +517 -0
- package/src/coding-tools/sandbox/index.ts +132 -0
- package/src/coding-tools/sandbox/local-child-process-adapter.ts +217 -0
- package/src/collab/agent-identity.ts +5 -0
- package/src/collab/agent-presence.ts +341 -0
- package/src/collab/awareness-store.ts +196 -0
- package/src/collab/awareness.ts +317 -0
- package/src/collab/client-struct.ts +366 -0
- package/src/collab/client.ts +1205 -0
- package/src/collab/emitter.ts +31 -0
- package/src/collab/follow-mode.ts +107 -0
- package/src/collab/index.ts +151 -0
- package/src/collab/json-to-yjs.ts +504 -0
- package/src/collab/presence.ts +207 -0
- package/src/collab/recent-edits.ts +215 -0
- package/src/collab/routes.ts +191 -0
- package/src/collab/storage.ts +228 -0
- package/src/collab/struct-routes.ts +133 -0
- package/src/collab/text-to-yjs.ts +79 -0
- package/src/collab/undo.ts +432 -0
- package/src/collab/xml-ops.ts +68 -0
- package/src/collab/ydoc-manager.ts +544 -0
- package/src/command-navigation/actions.ts +100 -0
- package/src/command-navigation/index.ts +12 -0
- package/src/comments-review/index.ts +1 -0
- package/src/connections/catalog.ts +451 -0
- package/src/connections/index.ts +48 -0
- package/src/connections/reader.ts +911 -0
- package/src/connections/runtime.ts +1 -0
- package/src/credentials/index.ts +187 -0
- package/src/data-programs/actions.ts +335 -0
- package/src/data-programs/contract.ts +284 -0
- package/src/data-programs/execute.ts +693 -0
- package/src/data-programs/index.ts +72 -0
- package/src/data-programs/schema.ts +148 -0
- package/src/data-programs/store.ts +755 -0
- package/src/data-widgets/index.ts +376 -0
- package/src/db/client.ts +1627 -0
- package/src/db/create-get-db.ts +579 -0
- package/src/db/ddl-guard.ts +302 -0
- package/src/db/drizzle-config.ts +190 -0
- package/src/db/ensure-additive-columns.ts +430 -0
- package/src/db/index.ts +57 -0
- package/src/db/migrations.ts +691 -0
- package/src/db/request-telemetry.ts +154 -0
- package/src/db/runtime-diagnostics.ts +331 -0
- package/src/db/schema.ts +121 -0
- package/src/db/widen-columns.ts +75 -0
- package/src/db-admin/agent-tools.ts +202 -0
- package/src/db-admin/index.ts +26 -0
- package/src/db-admin/operations.ts +803 -0
- package/src/db-admin/routes.ts +174 -0
- package/src/db-admin/types.ts +110 -0
- package/src/demo/browser-state.ts +47 -0
- package/src/demo/fetch-interceptor.ts +175 -0
- package/src/demo/redact.ts +575 -0
- package/src/deploy/build.ts +3938 -0
- package/src/deploy/immutable-assets.ts +65 -0
- package/src/deploy/route-discovery.ts +458 -0
- package/src/deploy/workspace-core.ts +282 -0
- package/src/deploy/workspace-deploy.ts +1488 -0
- package/src/eject/provider-api-definitions.ts +193 -0
- package/src/eject/remote-mcp-presets.ts +137 -0
- package/src/eject/setup-readiness-ui.tsx +29 -0
- package/src/eject/workspace-connections.ts +92 -0
- package/src/embedding/agent.ts +159 -0
- package/src/embedding/bridge.ts +297 -0
- package/src/embedding/index.ts +43 -0
- package/src/embedding/protocol.ts +185 -0
- package/src/embedding/react.tsx +319 -0
- package/src/embeddings/index.ts +233 -0
- package/src/eval/agent-runner.ts +210 -0
- package/src/eval/define-eval.ts +55 -0
- package/src/eval/index.ts +49 -0
- package/src/eval/report.ts +75 -0
- package/src/eval/runner.ts +369 -0
- package/src/eval/scorer.ts +244 -0
- package/src/eval/types.ts +188 -0
- package/src/event-bus/bus.ts +140 -0
- package/src/event-bus/index.ts +3 -0
- package/src/event-bus/registry.ts +79 -0
- package/src/event-bus/types.ts +29 -0
- package/src/extensions/actions.ts +1636 -0
- package/src/extensions/change-marker.ts +54 -0
- package/src/extensions/content-patch.ts +468 -0
- package/src/extensions/fetch-tool.ts +461 -0
- package/src/extensions/html-shell.ts +803 -0
- package/src/extensions/local.ts +462 -0
- package/src/extensions/path.ts +40 -0
- package/src/extensions/proxy-security.ts +171 -0
- package/src/extensions/routes.ts +1080 -0
- package/src/extensions/schema.ts +269 -0
- package/src/extensions/session-replay-iframe.ts +131 -0
- package/src/extensions/slots/routes.ts +126 -0
- package/src/extensions/slots/schema.ts +87 -0
- package/src/extensions/slots/store.ts +450 -0
- package/src/extensions/store.ts +1347 -0
- package/src/extensions/theme.ts +114 -0
- package/src/extensions/url-safety.ts +316 -0
- package/src/extensions/web-content.ts +663 -0
- package/src/extensions/web-search-tool.ts +437 -0
- package/src/feature-flags/a2a-action-route.ts +56 -0
- package/src/feature-flags/actions/get-feature-flags.ts +24 -0
- package/src/feature-flags/actions/list-feature-flags.ts +69 -0
- package/src/feature-flags/actions/set-feature-flag.ts +89 -0
- package/src/feature-flags/index.ts +21 -0
- package/src/feature-flags/permissions.ts +53 -0
- package/src/feature-flags/plugin.ts +44 -0
- package/src/feature-flags/registry.ts +96 -0
- package/src/feature-flags/store.ts +176 -0
- package/src/file-upload/actions/upload-image.ts +213 -0
- package/src/file-upload/builder.ts +431 -0
- package/src/file-upload/index.ts +24 -0
- package/src/file-upload/pre-upload-attachments.ts +305 -0
- package/src/file-upload/registry.ts +125 -0
- package/src/file-upload/types.ts +89 -0
- package/src/guards/db-tool-scoping.ts +129 -0
- package/src/guards/index.ts +23 -0
- package/src/guards/no-drizzle-push.ts +116 -0
- package/src/guards/no-env-credentials.ts +229 -0
- package/src/guards/no-env-mutation.ts +114 -0
- package/src/guards/no-localhost-fallback.ts +124 -0
- package/src/guards/no-unscoped-credentials.ts +227 -0
- package/src/guards/no-unscoped-queries.ts +834 -0
- package/src/guards/scan-utils.ts +105 -0
- package/src/guards/types.ts +30 -0
- package/src/history/actions/create-resource-version.ts +92 -0
- package/src/history/actions/get-resource-version.ts +60 -0
- package/src/history/actions/list-resource-history.ts +53 -0
- package/src/history/actions/list-resource-versions.ts +43 -0
- package/src/history/actions/restore-resource-version.ts +96 -0
- package/src/history/index.ts +26 -0
- package/src/history/registry.ts +111 -0
- package/src/history/store.ts +379 -0
- package/src/history/types.ts +69 -0
- package/src/index.browser.ts +155 -0
- package/src/index.ts +408 -0
- package/src/ingestion/docx.ts +158 -0
- package/src/ingestion/figma-node-to-html.ts +1860 -0
- package/src/ingestion/figma.ts +548 -0
- package/src/ingestion/index.ts +107 -0
- package/src/ingestion/media.ts +264 -0
- package/src/ingestion/notion.ts +121 -0
- package/src/ingestion/office.ts +213 -0
- package/src/ingestion/orchestration.ts +160 -0
- package/src/ingestion/pptx.ts +331 -0
- package/src/ingestion/selection.ts +81 -0
- package/src/ingestion/website.ts +151 -0
- package/src/integrations/a2a-continuation-marker.ts +2 -0
- package/src/integrations/a2a-continuation-processor.ts +888 -0
- package/src/integrations/a2a-continuations-store.ts +643 -0
- package/src/integrations/adapter-overrides.ts +12 -0
- package/src/integrations/adapters/discord.ts +364 -0
- package/src/integrations/adapters/email.ts +1164 -0
- package/src/integrations/adapters/google-docs.ts +371 -0
- package/src/integrations/adapters/index.ts +29 -0
- package/src/integrations/adapters/microsoft-teams.ts +413 -0
- package/src/integrations/adapters/slack.ts +1914 -0
- package/src/integrations/adapters/telegram.ts +386 -0
- package/src/integrations/adapters/whatsapp.ts +358 -0
- package/src/integrations/awaiting-input-store.ts +130 -0
- package/src/integrations/catalog.ts +571 -0
- package/src/integrations/computer-supervision-store.ts +423 -0
- package/src/integrations/computer-supervision.ts +213 -0
- package/src/integrations/config-store.ts +131 -0
- package/src/integrations/controls-store.ts +187 -0
- package/src/integrations/eject/messaging-adapters.ts +85 -0
- package/src/integrations/google-docs-poller.ts +671 -0
- package/src/integrations/identity-links-store.ts +210 -0
- package/src/integrations/identity.ts +196 -0
- package/src/integrations/index.ts +220 -0
- package/src/integrations/installations-store.ts +677 -0
- package/src/integrations/integration-memory.ts +187 -0
- package/src/integrations/internal-token.ts +106 -0
- package/src/integrations/pending-tasks-retry-job.ts +286 -0
- package/src/integrations/pending-tasks-store.ts +468 -0
- package/src/integrations/plugin.ts +3048 -0
- package/src/integrations/remote-commands-store.ts +690 -0
- package/src/integrations/remote-devices-store.ts +492 -0
- package/src/integrations/remote-json-safety.ts +127 -0
- package/src/integrations/remote-push-delivery-job.ts +48 -0
- package/src/integrations/remote-push-delivery.ts +370 -0
- package/src/integrations/remote-push-store.ts +664 -0
- package/src/integrations/remote-retry-job.ts +55 -0
- package/src/integrations/remote-run-events-store.ts +222 -0
- package/src/integrations/remote-types.ts +186 -0
- package/src/integrations/runtime.ts +1 -0
- package/src/integrations/scope-store.ts +498 -0
- package/src/integrations/slack-manifest.ts +78 -0
- package/src/integrations/slack-oauth.ts +344 -0
- package/src/integrations/task-queue-stats.ts +144 -0
- package/src/integrations/thread-mapping-store.ts +134 -0
- package/src/integrations/types.ts +485 -0
- package/src/integrations/usage-budget-store.ts +906 -0
- package/src/integrations/webhook-delivery.ts +55 -0
- package/src/integrations/webhook-handler.ts +1939 -0
- package/src/jobs/actions/list-recurring-jobs.ts +105 -0
- package/src/jobs/actions/manage-recurring-job.ts +85 -0
- package/src/jobs/cron.ts +126 -0
- package/src/jobs/index.ts +9 -0
- package/src/jobs/scheduler.ts +703 -0
- package/src/jobs/tools.ts +367 -0
- package/src/local-artifacts/index.ts +1372 -0
- package/src/localization/actions/get-localization-preference.ts +24 -0
- package/src/localization/actions/set-localization-preference.ts +32 -0
- package/src/localization/default-messages.ts +1009 -0
- package/src/localization/index.ts +2 -0
- package/src/localization/server.ts +131 -0
- package/src/localization/shared.ts +208 -0
- package/src/mcp/actions/call-mcp-tool.ts +19 -0
- package/src/mcp/actions/create-org-service-token.ts +87 -0
- package/src/mcp/actions/list-mcp-tools.ts +18 -0
- package/src/mcp/actions/list-org-service-tokens.ts +44 -0
- package/src/mcp/actions/revoke-org-service-token.ts +30 -0
- package/src/mcp/actions/service-token-access.ts +121 -0
- package/src/mcp/ask-app-inline-tasks.ts +125 -0
- package/src/mcp/build-server.ts +2356 -0
- package/src/mcp/builtin-tools.ts +1506 -0
- package/src/mcp/connect-route.ts +1460 -0
- package/src/mcp/connect-store.ts +680 -0
- package/src/mcp/embed-app.ts +2051 -0
- package/src/mcp/embed-route.ts +84 -0
- package/src/mcp/external-agent-policy.ts +18 -0
- package/src/mcp/index.ts +47 -0
- package/src/mcp/oauth-route.ts +1016 -0
- package/src/mcp/oauth-store.ts +581 -0
- package/src/mcp/oauth-token.ts +227 -0
- package/src/mcp/org-directory.ts +343 -0
- package/src/mcp/route-paths.ts +34 -0
- package/src/mcp/screen-memory-stdio.ts +290 -0
- package/src/mcp/server.ts +507 -0
- package/src/mcp/stdio.ts +328 -0
- package/src/mcp/workspace-resolve.ts +261 -0
- package/src/mcp-client/app-api.ts +136 -0
- package/src/mcp-client/app-result.ts +64 -0
- package/src/mcp-client/builtin-capabilities.ts +146 -0
- package/src/mcp-client/builtin-store.ts +93 -0
- package/src/mcp-client/config.ts +281 -0
- package/src/mcp-client/errors.ts +54 -0
- package/src/mcp-client/hub-client.ts +172 -0
- package/src/mcp-client/hub-routes.ts +198 -0
- package/src/mcp-client/index.ts +504 -0
- package/src/mcp-client/manager.ts +968 -0
- package/src/mcp-client/oauth-client.ts +462 -0
- package/src/mcp-client/oauth-routes.ts +307 -0
- package/src/mcp-client/remote-store.ts +674 -0
- package/src/mcp-client/remote-url.ts +97 -0
- package/src/mcp-client/routes.ts +1093 -0
- package/src/mcp-client/screen-memory-local.ts +461 -0
- package/src/mcp-client/tool-policy.ts +182 -0
- package/src/mcp-client/visibility.ts +56 -0
- package/src/mcp-client/workspace-servers.ts +379 -0
- package/src/navigation/index.ts +170 -0
- package/src/notifications/actions.ts +151 -0
- package/src/notifications/channels.ts +410 -0
- package/src/notifications/index.ts +22 -0
- package/src/notifications/registry.ts +216 -0
- package/src/notifications/routes.ts +106 -0
- package/src/notifications/store.ts +236 -0
- package/src/notifications/types.ts +52 -0
- package/src/oauth-tokens/google-refresh.ts +175 -0
- package/src/oauth-tokens/index.ts +15 -0
- package/src/oauth-tokens/store.ts +384 -0
- package/src/observability/cleanup-job.ts +124 -0
- package/src/observability/evals.ts +507 -0
- package/src/observability/experiments.ts +359 -0
- package/src/observability/feedback.ts +332 -0
- package/src/observability/hosted-model-experiment.ts +118 -0
- package/src/observability/index.ts +62 -0
- package/src/observability/plugin.ts +31 -0
- package/src/observability/routes.ts +431 -0
- package/src/observability/sentiment.ts +261 -0
- package/src/observability/store.ts +1347 -0
- package/src/observability/traces.ts +789 -0
- package/src/observability/tracing.ts +157 -0
- package/src/observability/tracking-identity.ts +55 -0
- package/src/observability/types.ts +211 -0
- package/src/onboarding/default-steps.ts +428 -0
- package/src/onboarding/index.ts +22 -0
- package/src/onboarding/plugin.ts +262 -0
- package/src/onboarding/registry.ts +47 -0
- package/src/onboarding/types.ts +96 -0
- package/src/org/accept-pending.ts +98 -0
- package/src/org/auto-join-domain.ts +113 -0
- package/src/org/context.ts +640 -0
- package/src/org/free-email-providers.ts +124 -0
- package/src/org/handlers.ts +1153 -0
- package/src/org/index.ts +63 -0
- package/src/org/migrations.ts +105 -0
- package/src/org/permissions.ts +30 -0
- package/src/org/plugin.ts +255 -0
- package/src/org/schema.ts +28 -0
- package/src/org/types.ts +57 -0
- package/src/org-team/index.ts +1 -0
- package/src/package-lifecycle/deprecated-imports.ts +179 -0
- package/src/package-lifecycle/eject-manifest.ts +345 -0
- package/src/package-lifecycle/index.ts +7 -0
- package/src/package-lifecycle/manifest.ts +120 -0
- package/src/package-lifecycle/migration-manifest.ts +159 -0
- package/src/package-lifecycle/migration-message.ts +6 -0
- package/src/package-lifecycle/tombstone.ts +58 -0
- package/src/package-lifecycle/upgrade-error.ts +37 -0
- package/src/private-blob/index.ts +18 -0
- package/src/private-blob/registry.ts +242 -0
- package/src/private-blob/types.ts +55 -0
- package/src/progress/actions.ts +179 -0
- package/src/progress/index.ts +16 -0
- package/src/progress/registry.ts +127 -0
- package/src/progress/routes.ts +89 -0
- package/src/progress/store.ts +353 -0
- package/src/progress/types.ts +59 -0
- package/src/provider-api/actions/custom-provider-registration.ts +197 -0
- package/src/provider-api/actions/delete-staged-dataset.ts +5 -0
- package/src/provider-api/actions/github-repo-files.ts +266 -0
- package/src/provider-api/actions/list-staged-datasets.ts +5 -0
- package/src/provider-api/actions/provider-api-audit.ts +88 -0
- package/src/provider-api/actions/provider-api.ts +460 -0
- package/src/provider-api/actions/query-staged-dataset.ts +5 -0
- package/src/provider-api/actions/staged-datasets.ts +359 -0
- package/src/provider-api/corpus-jobs-store.ts +522 -0
- package/src/provider-api/corpus-jobs.ts +1817 -0
- package/src/provider-api/custom-registry.ts +456 -0
- package/src/provider-api/github-repo.ts +675 -0
- package/src/provider-api/gong.ts +108 -0
- package/src/provider-api/index.ts +5444 -0
- package/src/provider-api/quota-governor.ts +562 -0
- package/src/provider-api/runtime.ts +1 -0
- package/src/provider-api/staged-datasets-aggregate.ts +304 -0
- package/src/provider-api/staged-datasets-store.ts +441 -0
- package/src/provider-api/staging.ts +483 -0
- package/src/resources/agents.ts +65 -0
- package/src/resources/emitter.ts +54 -0
- package/src/resources/handlers.ts +728 -0
- package/src/resources/index.ts +4 -0
- package/src/resources/metadata.ts +252 -0
- package/src/resources/script-helpers.ts +160 -0
- package/src/resources/store.ts +1618 -0
- package/src/review/actions/consume-review-feedback.ts +48 -0
- package/src/review/actions/create-review-comment.ts +108 -0
- package/src/review/actions/delete-review-comment.ts +67 -0
- package/src/review/actions/get-review-feedback.ts +49 -0
- package/src/review/actions/list-review-comments.ts +87 -0
- package/src/review/actions/reply-review-comment.ts +118 -0
- package/src/review/actions/resolve-review-thread.ts +94 -0
- package/src/review/actions/send-review-thread-to-agent.ts +62 -0
- package/src/review/actions/set-review-status.ts +58 -0
- package/src/review/identity.ts +101 -0
- package/src/review/index.ts +45 -0
- package/src/review/mentions.ts +44 -0
- package/src/review/registry.ts +111 -0
- package/src/review/store.ts +997 -0
- package/src/review/types.ts +101 -0
- package/src/router/index.ts +24 -0
- package/src/scripts/agent-engines/list-agent-engines.ts +130 -0
- package/src/scripts/agent-engines/manage-agent-engine.ts +197 -0
- package/src/scripts/agent-engines/set-agent-engine.ts +84 -0
- package/src/scripts/agent-engines/test-agent-engine.ts +174 -0
- package/src/scripts/call-agent.ts +792 -0
- package/src/scripts/chat/index.ts +8 -0
- package/src/scripts/chat/open-chat.ts +56 -0
- package/src/scripts/chat/search-chats.ts +121 -0
- package/src/scripts/core-scripts.ts +22 -0
- package/src/scripts/db/check-scoping.ts +212 -0
- package/src/scripts/db/exec.ts +791 -0
- package/src/scripts/db/index.ts +19 -0
- package/src/scripts/db/migrate-encrypt-credentials.ts +223 -0
- package/src/scripts/db/migrate-encrypt-oauth-tokens.ts +213 -0
- package/src/scripts/db/migrate-user-api-keys.ts +257 -0
- package/src/scripts/db/patch.ts +820 -0
- package/src/scripts/db/query.ts +299 -0
- package/src/scripts/db/reset-dev-owner.ts +285 -0
- package/src/scripts/db/safety.ts +286 -0
- package/src/scripts/db/schema.ts +364 -0
- package/src/scripts/db/scoping.ts +341 -0
- package/src/scripts/db/sqlite-client.ts +78 -0
- package/src/scripts/db/tool-mode.ts +23 -0
- package/src/scripts/db/tool-schemas.ts +31 -0
- package/src/scripts/db/wipe-leaked-builder-keys.ts +201 -0
- package/src/scripts/dev/index.ts +296 -0
- package/src/scripts/dev/list-files.ts +119 -0
- package/src/scripts/dev/read-file.ts +77 -0
- package/src/scripts/dev/search-files.ts +151 -0
- package/src/scripts/dev/shell.ts +111 -0
- package/src/scripts/dev/write-file.ts +56 -0
- package/src/scripts/dev-session.ts +96 -0
- package/src/scripts/docs/index.ts +8 -0
- package/src/scripts/docs/search.ts +274 -0
- package/src/scripts/docs/source-search.ts +363 -0
- package/src/scripts/index.ts +15 -0
- package/src/scripts/manage-agent-loop-settings.ts +84 -0
- package/src/scripts/parse-args.ts +46 -0
- package/src/scripts/resources/delete-memory.ts +67 -0
- package/src/scripts/resources/delete.ts +69 -0
- package/src/scripts/resources/effective.ts +71 -0
- package/src/scripts/resources/index.ts +18 -0
- package/src/scripts/resources/list.ts +103 -0
- package/src/scripts/resources/migrate-learnings.ts +40 -0
- package/src/scripts/resources/read.ts +107 -0
- package/src/scripts/resources/save-memory.ts +99 -0
- package/src/scripts/resources/write.ts +158 -0
- package/src/scripts/runner.ts +339 -0
- package/src/scripts/utils.ts +130 -0
- package/src/search/index.ts +413 -0
- package/src/search-utils/index.ts +112 -0
- package/src/secrets/crypto.ts +228 -0
- package/src/secrets/index.ts +65 -0
- package/src/secrets/onboarding.ts +101 -0
- package/src/secrets/register-framework-secrets.ts +228 -0
- package/src/secrets/register.ts +129 -0
- package/src/secrets/routes.ts +697 -0
- package/src/secrets/schema.ts +52 -0
- package/src/secrets/storage.ts +561 -0
- package/src/secrets/substitution.ts +305 -0
- package/src/server/__snapshots__/agent-chat-plugin.surface.spec.ts.snap +150 -0
- package/src/server/action-change.ts +66 -0
- package/src/server/action-discovery.ts +774 -0
- package/src/server/action-routes.ts +658 -0
- package/src/server/agent-access.ts +72 -0
- package/src/server/agent-chat/action-filters-a2a.ts +339 -0
- package/src/server/agent-chat/browser-team-tools.ts +510 -0
- package/src/server/agent-chat/context-tools.ts +599 -0
- package/src/server/agent-chat/framework-prompts.ts +467 -0
- package/src/server/agent-chat/lazy-fs.ts +11 -0
- package/src/server/agent-chat/mcp-glue.ts +91 -0
- package/src/server/agent-chat/plugin-options.ts +379 -0
- package/src/server/agent-chat/process-run-failure.ts +62 -0
- package/src/server/agent-chat/prompt-resources.ts +1004 -0
- package/src/server/agent-chat/recurring-jobs-runtime.ts +80 -0
- package/src/server/agent-chat/request-surface.ts +71 -0
- package/src/server/agent-chat/run-code-tools.ts +67 -0
- package/src/server/agent-chat/script-entries.ts +796 -0
- package/src/server/agent-chat/shared-thread.ts +301 -0
- package/src/server/agent-chat/skill-frontmatter.ts +41 -0
- package/src/server/agent-chat-plugin.ts +5930 -0
- package/src/server/agent-discovery.ts +706 -0
- package/src/server/agent-engine-api-key-route.ts +236 -0
- package/src/server/agent-run-context.ts +204 -0
- package/src/server/agent-teams-run-queue.ts +344 -0
- package/src/server/agent-teams.ts +2257 -0
- package/src/server/agents-bundle.ts +464 -0
- package/src/server/analytics.ts +105 -0
- package/src/server/app-base-path.ts +79 -0
- package/src/server/app-name.ts +53 -0
- package/src/server/app-url.ts +184 -0
- package/src/server/attachment-actions.ts +276 -0
- package/src/server/attribution.ts +214 -0
- package/src/server/auth-marketing.ts +260 -0
- package/src/server/auth-plugin.ts +32 -0
- package/src/server/auth.ts +3803 -0
- package/src/server/better-auth-instance.ts +1201 -0
- package/src/server/builder-browser.ts +1701 -0
- package/src/server/builder-design-systems.ts +668 -0
- package/src/server/builder-space.ts +176 -0
- package/src/server/captcha.ts +63 -0
- package/src/server/capture-error.ts +64 -0
- package/src/server/cli-capture.ts +141 -0
- package/src/server/collab-plugin.ts +391 -0
- package/src/server/complete-text.ts +231 -0
- package/src/server/cookie-namespace.ts +159 -0
- package/src/server/core-routes-plugin.ts +4122 -0
- package/src/server/cors-origins.ts +60 -0
- package/src/server/create-server.ts +268 -0
- package/src/server/credential-provider.ts +1202 -0
- package/src/server/csrf.ts +229 -0
- package/src/server/date-utils.ts +42 -0
- package/src/server/deep-link.ts +119 -0
- package/src/server/derived-secret.ts +32 -0
- package/src/server/design-token-utils.ts +1032 -0
- package/src/server/desktop-sso.ts +83 -0
- package/src/server/edge.ts +69 -0
- package/src/server/email-actions.ts +218 -0
- package/src/server/email-template.ts +192 -0
- package/src/server/email-templates.ts +148 -0
- package/src/server/email.ts +219 -0
- package/src/server/embed-route.ts +283 -0
- package/src/server/embed-session.ts +805 -0
- package/src/server/embedded.ts +252 -0
- package/src/server/entry-server.tsx +154 -0
- package/src/server/framework-request-handler.ts +848 -0
- package/src/server/fusion-app.ts +447 -0
- package/src/server/google-auth-mode.ts +34 -0
- package/src/server/google-auth-plugin.ts +496 -0
- package/src/server/google-oauth-credentials.ts +128 -0
- package/src/server/google-oauth.ts +972 -0
- package/src/server/google-realtime-session.ts +182 -0
- package/src/server/h3-helpers.ts +174 -0
- package/src/server/http-response-telemetry.ts +396 -0
- package/src/server/identity-sso-store.ts +304 -0
- package/src/server/identity-sso.ts +514 -0
- package/src/server/index.ts +593 -0
- package/src/server/missing-key.ts +36 -0
- package/src/server/oauth-helpers.ts +44 -0
- package/src/server/oauth-public-origin.ts +44 -0
- package/src/server/oauth-return-url.ts +120 -0
- package/src/server/og-fonts-data.ts +15 -0
- package/src/server/og-fonts.ts +75 -0
- package/src/server/onboarding-html.ts +4040 -0
- package/src/server/open-route.ts +311 -0
- package/src/server/org-admin.ts +28 -0
- package/src/server/poll-events.ts +88 -0
- package/src/server/poll.ts +1224 -0
- package/src/server/prompts/framework-core-compact.ts +107 -0
- package/src/server/prompts/framework-core.ts +143 -0
- package/src/server/prompts/index.ts +16 -0
- package/src/server/prompts/model-overlays.ts +54 -0
- package/src/server/prompts/shared-rules.ts +104 -0
- package/src/server/realtime-voice.ts +967 -0
- package/src/server/recap-image-route.ts +242 -0
- package/src/server/recap-image-store.ts +185 -0
- package/src/server/request-context.ts +416 -0
- package/src/server/request-origin.ts +67 -0
- package/src/server/resources-plugin.ts +119 -0
- package/src/server/schema-prompt.ts +429 -0
- package/src/server/scoped-key-storage.ts +223 -0
- package/src/server/security-headers.ts +170 -0
- package/src/server/self-dispatch.ts +224 -0
- package/src/server/sentry-config.ts +73 -0
- package/src/server/sentry-plugin.ts +138 -0
- package/src/server/sentry.ts +444 -0
- package/src/server/short-lived-token.ts +170 -0
- package/src/server/social-og-image.ts +454 -0
- package/src/server/sse.ts +102 -0
- package/src/server/ssr-handler.ts +466 -0
- package/src/server/transcribe-voice.ts +1076 -0
- package/src/server/voice-providers-status.ts +118 -0
- package/src/server/workspace-oauth.ts +31 -0
- package/src/server/workspace-provider-oauth.ts +970 -0
- package/src/session-replay-iframe-protocol.ts +58 -0
- package/src/settings/handlers.ts +44 -0
- package/src/settings/index.ts +34 -0
- package/src/settings/org-settings.ts +83 -0
- package/src/settings/script-helpers.ts +24 -0
- package/src/settings/store.ts +247 -0
- package/src/settings/user-settings.ts +47 -0
- package/src/setup-connections/index.ts +90 -0
- package/src/setup-connections/onboarding.ts +47 -0
- package/src/shared/agent-access.ts +112 -0
- package/src/shared/agent-chat.ts +124 -0
- package/src/shared/agent-env.ts +46 -0
- package/src/shared/agent-readable-resource.ts +111 -0
- package/src/shared/agent-sidebar-url.ts +39 -0
- package/src/shared/cache-control.ts +25 -0
- package/src/shared/cloudflare-globals.d.ts +34 -0
- package/src/shared/context-xray.ts +172 -0
- package/src/shared/embed-auth.ts +6 -0
- package/src/shared/index.ts +83 -0
- package/src/shared/llm-connection.ts +42 -0
- package/src/shared/markdown-block-split.ts +129 -0
- package/src/shared/mcp-connect-content.ts +130 -0
- package/src/shared/mcp-embed-headers.ts +175 -0
- package/src/shared/mcp-integration-config.ts +101 -0
- package/src/shared/merge-by-id.ts +14 -0
- package/src/shared/oauth-state.ts +39 -0
- package/src/shared/reasoning-effort.ts +228 -0
- package/src/shared/route-warmup-config.ts +128 -0
- package/src/shared/runtime.ts +31 -0
- package/src/shared/social-meta.ts +82 -0
- package/src/shared/streaming-text-smoothing.ts +184 -0
- package/src/shared/truncate.ts +13 -0
- package/src/shared/workspace-app-audience.ts +177 -0
- package/src/shared/workspace-app-id.ts +54 -0
- package/src/sharing/access.ts +585 -0
- package/src/sharing/actions/create-agent-resource-link.ts +91 -0
- package/src/sharing/actions/extension-change.ts +22 -0
- package/src/sharing/actions/list-resource-shares.ts +93 -0
- package/src/sharing/actions/set-resource-visibility.ts +91 -0
- package/src/sharing/actions/share-resource.ts +322 -0
- package/src/sharing/actions/unshare-resource.ts +72 -0
- package/src/sharing/index.ts +35 -0
- package/src/sharing/registry.ts +201 -0
- package/src/sharing/schema.ts +99 -0
- package/src/styles/agent-conversation.css +766 -0
- package/src/styles/agent-native.css +938 -0
- package/src/styles/blocks.css +1717 -0
- package/src/styles/chat-history-list.css +1 -0
- package/src/styles/rich-markdown-editor.css +1 -0
- package/src/tailwind.preset.ts +140 -0
- package/src/templates/chat/.agents/skills/agent-native-docs/SKILL.md +15 -13
- package/src/templates/chat/.agents/skills/customizing-agent-native/SKILL.md +63 -20
- package/src/templates/chat/.agents/skills/self-modifying-code/SKILL.md +9 -6
- package/src/templates/chat/AGENTS.md +3 -2
- package/src/templates/default/.agents/skills/agent-native-docs/SKILL.md +15 -13
- package/src/templates/default/.agents/skills/customizing-agent-native/SKILL.md +63 -20
- package/src/templates/default/.agents/skills/self-modifying-code/SKILL.md +9 -6
- package/src/templates/default/AGENTS.md +6 -5
- package/src/templates/headless/.agents/skills/agent-native-docs/SKILL.md +15 -13
- package/src/templates/headless/.agents/skills/customizing-agent-native/SKILL.md +63 -20
- package/src/templates/headless/AGENTS.md +5 -4
- package/src/templates/workspace-core/.agents/skills/agent-native-docs/SKILL.md +15 -13
- package/src/templates/workspace-core/.agents/skills/agent-native-toolkit/SKILL.md +3 -2
- package/src/templates/workspace-core/.agents/skills/customizing-agent-native/SKILL.md +63 -20
- package/src/templates/workspace-core/.agents/skills/self-modifying-code/SKILL.md +9 -6
- package/src/templates/workspace-core/AGENTS.md +4 -4
- package/src/templates/workspace-root/AGENTS.md +4 -4
- package/src/terminal/cli-registry.ts +57 -0
- package/src/terminal/index.ts +22 -0
- package/src/terminal/pty-server.ts +389 -0
- package/src/terminal/terminal-plugin.ts +265 -0
- package/src/testing.ts +23 -0
- package/src/tracking/index.ts +10 -0
- package/src/tracking/providers.ts +422 -0
- package/src/tracking/registry.ts +102 -0
- package/src/tracking/route.ts +108 -0
- package/src/tracking/types.ts +16 -0
- package/src/transcription/builder-transcription.ts +118 -0
- package/src/triggers/actions/list-automations.ts +99 -0
- package/src/triggers/actions/manage-automation.ts +78 -0
- package/src/triggers/actions.ts +333 -0
- package/src/triggers/condition-evaluator.ts +163 -0
- package/src/triggers/dispatcher.ts +536 -0
- package/src/triggers/index.ts +13 -0
- package/src/triggers/routes.ts +322 -0
- package/src/triggers/types.ts +42 -0
- package/src/types/pglite.d.ts +26 -0
- package/src/usage/store.ts +698 -0
- package/src/vite/action-types-plugin.ts +481 -0
- package/src/vite/agent-web-plugin.ts +78 -0
- package/src/vite/agents-bundle-plugin.ts +185 -0
- package/src/vite/client.ts +3056 -0
- package/src/vite/index.ts +21 -0
- package/src/voice/index.ts +18 -0
- package/src/voice/voice-cleanup-prompt.ts +38 -0
- package/src/voice/voice-context.ts +217 -0
- package/src/voice/voice-replacements.ts +75 -0
- package/src/workspace-connections/credentials.ts +603 -0
- package/src/workspace-connections/index.ts +72 -0
- package/src/workspace-connections/lifecycle.ts +43 -0
- package/src/workspace-connections/store.ts +1943 -0
- package/src/workspace-files/index.ts +18 -0
- package/src/workspace-files/store.ts +339 -0
- package/src/workspace-files/tool.ts +266 -0
|
@@ -0,0 +1,1854 @@
|
|
|
1
|
+
import {
|
|
2
|
+
IconChevronRight,
|
|
3
|
+
IconColumns,
|
|
4
|
+
IconDotsVertical,
|
|
5
|
+
IconFileDiff,
|
|
6
|
+
IconList,
|
|
7
|
+
IconPlus,
|
|
8
|
+
IconTrash,
|
|
9
|
+
} from "@tabler/icons-react";
|
|
10
|
+
import { common, createLowlight } from "lowlight";
|
|
11
|
+
import {
|
|
12
|
+
useCallback,
|
|
13
|
+
useEffect,
|
|
14
|
+
useMemo,
|
|
15
|
+
useRef,
|
|
16
|
+
useState,
|
|
17
|
+
type RefObject,
|
|
18
|
+
type ReactNode,
|
|
19
|
+
} from "react";
|
|
20
|
+
|
|
21
|
+
import { cn } from "../../utils.js";
|
|
22
|
+
import { ltrCodeBlockProps } from "../code-block-direction.js";
|
|
23
|
+
import type {
|
|
24
|
+
BlockEditProps,
|
|
25
|
+
BlockReadProps,
|
|
26
|
+
BlockRenderContext,
|
|
27
|
+
} from "../types.js";
|
|
28
|
+
import {
|
|
29
|
+
AnnotationGutterMarker,
|
|
30
|
+
AnnotationHiddenStack,
|
|
31
|
+
AnnotationHoverCard,
|
|
32
|
+
AnnotationInlineOverlayStack,
|
|
33
|
+
anchorFromElements,
|
|
34
|
+
buildLineMarkerMap,
|
|
35
|
+
hasRailAnnotations,
|
|
36
|
+
resolveAnnotations,
|
|
37
|
+
useAnnotationMarginNotesAvailable,
|
|
38
|
+
useAnnotationHover,
|
|
39
|
+
type AnnotationMarginSide,
|
|
40
|
+
type AnnotationSide,
|
|
41
|
+
type ResolvedAnnotation,
|
|
42
|
+
} from "./annotation-rail.js";
|
|
43
|
+
import { DevInput, DevLabel, DevTextarea, DevSelect } from "./dev-doc-ui.js";
|
|
44
|
+
import type { DiffAnnotation, DiffData, DiffMode } from "./diff.config.js";
|
|
45
|
+
import { useInNarrowContainer } from "./narrow-container.js";
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* GitHub-style before/after diff block. The read renderer computes a line-level
|
|
49
|
+
* diff, then renders it either unified (one column, `+`/`−` gutters) or split
|
|
50
|
+
* (side-by-side). Long unchanged runs collapse into an expandable "N unchanged
|
|
51
|
+
* lines" row (progressive disclosure). The read surface keeps the GitHub diff
|
|
52
|
+
* shape while using the framework Tailwind theme tokens, so it follows each
|
|
53
|
+
* host app's light/dark appearance instead of bringing its own palette.
|
|
54
|
+
*
|
|
55
|
+
* Lives in core so any app can register the dev-doc block. The line differ is
|
|
56
|
+
* inlined (a small LCS-based `diffLines`) rather than pulling the `diff` package
|
|
57
|
+
* into core; the output shape (`{ value, added, removed }` change records) is
|
|
58
|
+
* identical to what the read renderer consumed before.
|
|
59
|
+
*
|
|
60
|
+
* Editing is panel-driven (config-style, like the HTML block): two monospace
|
|
61
|
+
* textareas (Before / After) plus filename, language, and mode controls.
|
|
62
|
+
*/
|
|
63
|
+
|
|
64
|
+
/* ── Inline line differ (LCS) — replaces jsdiff `diffLines` ─────────────────── */
|
|
65
|
+
|
|
66
|
+
interface Change {
|
|
67
|
+
value: string;
|
|
68
|
+
added?: boolean;
|
|
69
|
+
removed?: boolean;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Split text into lines, each KEEPING its trailing newline (so the change
|
|
74
|
+
* `value`s concatenate back to the original and `splitLines` below behaves the
|
|
75
|
+
* same as it did against jsdiff output).
|
|
76
|
+
*/
|
|
77
|
+
function toLineTokens(text: string): string[] {
|
|
78
|
+
if (text === "") return [];
|
|
79
|
+
const out: string[] = [];
|
|
80
|
+
let start = 0;
|
|
81
|
+
for (let i = 0; i < text.length; i += 1) {
|
|
82
|
+
if (text[i] === "\n") {
|
|
83
|
+
out.push(text.slice(start, i + 1));
|
|
84
|
+
start = i + 1;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
if (start < text.length) out.push(text.slice(start));
|
|
88
|
+
return out;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* A minimal line-level diff producing jsdiff-compatible `Change[]` records
|
|
93
|
+
* (`{ value }` for context, `{ value, added: true }`, `{ value, removed: true }`).
|
|
94
|
+
* Uses a classic LCS table over line tokens; the inputs here are short code
|
|
95
|
+
* snippets so the O(n·m) table is fine. Removed lines are emitted before added
|
|
96
|
+
* lines within a change region, matching jsdiff's ordering.
|
|
97
|
+
*/
|
|
98
|
+
export function diffLines(before: string, after: string): Change[] {
|
|
99
|
+
const a = toLineTokens(before);
|
|
100
|
+
const b = toLineTokens(after);
|
|
101
|
+
const n = a.length;
|
|
102
|
+
const m = b.length;
|
|
103
|
+
const cells = (n + 1) * (m + 1);
|
|
104
|
+
|
|
105
|
+
if (cells > MAX_DIFF_LCS_CELLS) {
|
|
106
|
+
return [
|
|
107
|
+
...(before ? [{ value: before, removed: true }] : []),
|
|
108
|
+
...(after ? [{ value: after, added: true }] : []),
|
|
109
|
+
];
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// LCS length table.
|
|
113
|
+
const lcs: number[][] = Array.from({ length: n + 1 }, () =>
|
|
114
|
+
new Array<number>(m + 1).fill(0),
|
|
115
|
+
);
|
|
116
|
+
for (let i = n - 1; i >= 0; i -= 1) {
|
|
117
|
+
for (let j = m - 1; j >= 0; j -= 1) {
|
|
118
|
+
lcs[i][j] =
|
|
119
|
+
a[i] === b[j]
|
|
120
|
+
? lcs[i + 1][j + 1] + 1
|
|
121
|
+
: Math.max(lcs[i + 1][j], lcs[i][j + 1]);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
const changes: Change[] = [];
|
|
126
|
+
// Push a token onto the last change if same kind, else open a new change.
|
|
127
|
+
const push = (value: string, kind: "context" | "added" | "removed") => {
|
|
128
|
+
const last = changes[changes.length - 1];
|
|
129
|
+
const sameKind =
|
|
130
|
+
last &&
|
|
131
|
+
Boolean(last.added) === (kind === "added") &&
|
|
132
|
+
Boolean(last.removed) === (kind === "removed");
|
|
133
|
+
if (sameKind) {
|
|
134
|
+
last.value += value;
|
|
135
|
+
} else {
|
|
136
|
+
changes.push({
|
|
137
|
+
value,
|
|
138
|
+
added: kind === "added" ? true : undefined,
|
|
139
|
+
removed: kind === "removed" ? true : undefined,
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
let i = 0;
|
|
145
|
+
let j = 0;
|
|
146
|
+
while (i < n && j < m) {
|
|
147
|
+
if (a[i] === b[j]) {
|
|
148
|
+
push(a[i], "context");
|
|
149
|
+
i += 1;
|
|
150
|
+
j += 1;
|
|
151
|
+
} else if (lcs[i + 1][j] >= lcs[i][j + 1]) {
|
|
152
|
+
push(a[i], "removed");
|
|
153
|
+
i += 1;
|
|
154
|
+
} else {
|
|
155
|
+
push(b[j], "added");
|
|
156
|
+
j += 1;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
while (i < n) {
|
|
160
|
+
push(a[i], "removed");
|
|
161
|
+
i += 1;
|
|
162
|
+
}
|
|
163
|
+
while (j < m) {
|
|
164
|
+
push(b[j], "added");
|
|
165
|
+
j += 1;
|
|
166
|
+
}
|
|
167
|
+
return changes;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/* ── Syntax highlighting ───────────────────────────────────────────────────── */
|
|
171
|
+
|
|
172
|
+
const lowlight = createLowlight(common);
|
|
173
|
+
|
|
174
|
+
type LowlightNode = {
|
|
175
|
+
type: string;
|
|
176
|
+
value?: string;
|
|
177
|
+
properties?: {
|
|
178
|
+
className?: string[] | string;
|
|
179
|
+
};
|
|
180
|
+
children?: LowlightNode[];
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
const LANGUAGE_ALIASES: Record<string, string> = {
|
|
184
|
+
cjs: "javascript",
|
|
185
|
+
cts: "typescript",
|
|
186
|
+
htm: "html",
|
|
187
|
+
js: "javascript",
|
|
188
|
+
jsonc: "json",
|
|
189
|
+
jsx: "jsx",
|
|
190
|
+
md: "markdown",
|
|
191
|
+
mdx: "markdown",
|
|
192
|
+
mjs: "javascript",
|
|
193
|
+
mts: "typescript",
|
|
194
|
+
py: "python",
|
|
195
|
+
rb: "ruby",
|
|
196
|
+
rs: "rust",
|
|
197
|
+
sh: "bash",
|
|
198
|
+
shell: "bash",
|
|
199
|
+
ts: "typescript",
|
|
200
|
+
tsx: "tsx",
|
|
201
|
+
yml: "yaml",
|
|
202
|
+
zsh: "bash",
|
|
203
|
+
};
|
|
204
|
+
|
|
205
|
+
const TOKEN_CLASS_NAMES: Record<string, string> = {
|
|
206
|
+
"hljs-addition": "text-emerald-700 dark:text-emerald-300",
|
|
207
|
+
"hljs-attr": "text-primary",
|
|
208
|
+
"hljs-attribute": "text-primary",
|
|
209
|
+
"hljs-built_in": "text-amber-700 dark:text-amber-300",
|
|
210
|
+
"hljs-bullet": "text-primary",
|
|
211
|
+
"hljs-comment": "text-muted-foreground italic",
|
|
212
|
+
"hljs-deletion": "text-destructive",
|
|
213
|
+
"hljs-doctag": "text-destructive",
|
|
214
|
+
"hljs-emphasis": "italic",
|
|
215
|
+
"hljs-formula": "text-destructive",
|
|
216
|
+
"hljs-keyword": "text-destructive",
|
|
217
|
+
"hljs-link": "text-primary underline-offset-2",
|
|
218
|
+
"hljs-literal": "text-primary",
|
|
219
|
+
"hljs-meta": "text-primary",
|
|
220
|
+
"hljs-meta-string": "text-emerald-700 dark:text-emerald-300",
|
|
221
|
+
"hljs-name": "text-emerald-700 dark:text-emerald-300",
|
|
222
|
+
"hljs-number": "text-primary",
|
|
223
|
+
"hljs-params": "text-primary",
|
|
224
|
+
"hljs-property": "text-primary",
|
|
225
|
+
"hljs-quote": "text-muted-foreground italic",
|
|
226
|
+
"hljs-regexp": "text-emerald-700 dark:text-emerald-300",
|
|
227
|
+
"hljs-section": "text-violet-700 dark:text-violet-300",
|
|
228
|
+
"hljs-selector-attr": "text-primary",
|
|
229
|
+
"hljs-selector-class": "text-emerald-700 dark:text-emerald-300",
|
|
230
|
+
"hljs-selector-id": "text-emerald-700 dark:text-emerald-300",
|
|
231
|
+
"hljs-selector-pseudo": "text-primary",
|
|
232
|
+
"hljs-selector-tag": "text-emerald-700 dark:text-emerald-300",
|
|
233
|
+
"hljs-string": "text-emerald-700 dark:text-emerald-300",
|
|
234
|
+
"hljs-strong": "font-semibold",
|
|
235
|
+
"hljs-subst": "text-destructive",
|
|
236
|
+
"hljs-symbol": "text-primary",
|
|
237
|
+
"hljs-tag": "text-emerald-700 dark:text-emerald-300",
|
|
238
|
+
"hljs-template-variable": "text-amber-700 dark:text-amber-300",
|
|
239
|
+
"hljs-title": "text-violet-700 dark:text-violet-300",
|
|
240
|
+
"hljs-type": "text-amber-700 dark:text-amber-300",
|
|
241
|
+
"hljs-variable": "text-amber-700 dark:text-amber-300",
|
|
242
|
+
language_: "text-amber-700 dark:text-amber-300",
|
|
243
|
+
};
|
|
244
|
+
|
|
245
|
+
function normalizeLanguage(value?: string | null): string | null {
|
|
246
|
+
const raw = value?.trim().toLowerCase();
|
|
247
|
+
if (!raw) return null;
|
|
248
|
+
const normalized = LANGUAGE_ALIASES[raw] ?? raw;
|
|
249
|
+
return lowlight.registered(normalized) ? normalized : null;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
function getLanguageFromFilename(filename?: string): string | null {
|
|
253
|
+
const basename = filename?.split("/").pop()?.toLowerCase();
|
|
254
|
+
if (!basename) return null;
|
|
255
|
+
if (basename === "dockerfile") return normalizeLanguage("bash");
|
|
256
|
+
if (basename === "makefile") return normalizeLanguage("makefile");
|
|
257
|
+
const ext = basename.includes(".") ? basename.split(".").pop() : basename;
|
|
258
|
+
return normalizeLanguage(ext);
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
function resolveDiffLanguage(data: DiffData): string {
|
|
262
|
+
return (
|
|
263
|
+
normalizeLanguage(data.language) ??
|
|
264
|
+
getLanguageFromFilename(data.filename) ??
|
|
265
|
+
"plaintext"
|
|
266
|
+
);
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
function tokenClassName(className?: string[] | string): string | undefined {
|
|
270
|
+
const classes = Array.isArray(className)
|
|
271
|
+
? className
|
|
272
|
+
: className
|
|
273
|
+
? className.split(/\s+/)
|
|
274
|
+
: [];
|
|
275
|
+
const mapped = classes
|
|
276
|
+
.map((name) => TOKEN_CLASS_NAMES[name])
|
|
277
|
+
.filter(Boolean)
|
|
278
|
+
.join(" ");
|
|
279
|
+
return mapped || undefined;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
function hastToReact(children: LowlightNode[], keyPrefix: string): ReactNode[] {
|
|
283
|
+
return children.map((node, index) => {
|
|
284
|
+
if (node.type === "text") return node.value ?? "";
|
|
285
|
+
if (node.type === "element") {
|
|
286
|
+
const key = `${keyPrefix}${index}`;
|
|
287
|
+
const renderedChildren = node.children?.length
|
|
288
|
+
? hastToReact(node.children, `${key}-`)
|
|
289
|
+
: null;
|
|
290
|
+
const className = tokenClassName(node.properties?.className);
|
|
291
|
+
if (className) {
|
|
292
|
+
return (
|
|
293
|
+
<span key={key} className={className}>
|
|
294
|
+
{renderedChildren}
|
|
295
|
+
</span>
|
|
296
|
+
);
|
|
297
|
+
}
|
|
298
|
+
return <span key={key}>{renderedChildren}</span>;
|
|
299
|
+
}
|
|
300
|
+
return null;
|
|
301
|
+
});
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
function SyntaxHighlightedLine({
|
|
305
|
+
code,
|
|
306
|
+
language,
|
|
307
|
+
}: {
|
|
308
|
+
code: string;
|
|
309
|
+
language: string;
|
|
310
|
+
}) {
|
|
311
|
+
const highlighted = useMemo(() => {
|
|
312
|
+
if (!code.trim() || language === "plaintext" || language === "text") {
|
|
313
|
+
return null;
|
|
314
|
+
}
|
|
315
|
+
try {
|
|
316
|
+
const tree = lowlight.highlight(language, code) as LowlightNode;
|
|
317
|
+
return hastToReact(tree.children ?? [], `${language}-`);
|
|
318
|
+
} catch {
|
|
319
|
+
return null;
|
|
320
|
+
}
|
|
321
|
+
}, [code, language]);
|
|
322
|
+
|
|
323
|
+
return <>{highlighted ?? code}</>;
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
/* ── Diff model ────────────────────────────────────────────────────────────── */
|
|
327
|
+
|
|
328
|
+
type DiffRowKind = "context" | "added" | "removed";
|
|
329
|
+
|
|
330
|
+
interface DiffRow {
|
|
331
|
+
kind: DiffRowKind;
|
|
332
|
+
/** Line number in the OLD file (omitted for added rows). */
|
|
333
|
+
oldNo?: number;
|
|
334
|
+
/** Line number in the NEW file (omitted for removed rows). */
|
|
335
|
+
newNo?: number;
|
|
336
|
+
text: string;
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
/** A contiguous run of context lines collapsed when longer than the threshold. */
|
|
340
|
+
interface CollapsedRun {
|
|
341
|
+
collapsed: true;
|
|
342
|
+
rows: DiffRow[];
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
type DiffSegment = DiffRow | CollapsedRun;
|
|
346
|
+
|
|
347
|
+
/** Which column a split-view row belongs to (the unified view passes nothing). */
|
|
348
|
+
type RowSide = "old" | "new";
|
|
349
|
+
|
|
350
|
+
/**
|
|
351
|
+
* Resolve the markers landing on a row. `side` scopes the lookup to one column
|
|
352
|
+
* in the split view (so a left cell only lights from `before` annotations and a
|
|
353
|
+
* right cell from `after`); the unified view omits it to merge both sides.
|
|
354
|
+
*/
|
|
355
|
+
type MarkersForRow = (
|
|
356
|
+
row: DiffRow,
|
|
357
|
+
side?: RowSide,
|
|
358
|
+
) => ResolvedAnnotation<DiffAnnotation>[];
|
|
359
|
+
|
|
360
|
+
/** The default side an annotation targets when `side` is omitted. */
|
|
361
|
+
function annotationSide(annotation: DiffAnnotation): "before" | "after" {
|
|
362
|
+
return annotation.side === "before" ? "before" : "after";
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
/**
|
|
366
|
+
* Count 1-based source lines in a side's text, matching how `buildRows` numbers
|
|
367
|
+
* `oldNo`/`newNo`: a trailing newline does not add a phantom final line.
|
|
368
|
+
*/
|
|
369
|
+
function countLines(text: string): number {
|
|
370
|
+
if (text === "") return 0;
|
|
371
|
+
return splitLines(text).length;
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
/** Number of context lines above which an unchanged run is collapsed. */
|
|
375
|
+
const COLLAPSE_THRESHOLD = 6;
|
|
376
|
+
/** Context lines kept visible at each edge of a collapsed run. */
|
|
377
|
+
const CONTEXT_EDGE = 3;
|
|
378
|
+
|
|
379
|
+
/**
|
|
380
|
+
* Split a change `value` into individual lines. Most hunks carry a trailing
|
|
381
|
+
* newline; drop the empty final element it produces so a 2-line change does not
|
|
382
|
+
* render a phantom 3rd blank line.
|
|
383
|
+
*/
|
|
384
|
+
function splitLines(value: string): string[] {
|
|
385
|
+
const lines = value.split("\n");
|
|
386
|
+
if (lines.length > 0 && lines[lines.length - 1] === "") lines.pop();
|
|
387
|
+
return lines;
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
/** Flatten change objects into numbered diff rows. */
|
|
391
|
+
function buildRows(changes: Change[]): DiffRow[] {
|
|
392
|
+
const rows: DiffRow[] = [];
|
|
393
|
+
let oldNo = 0;
|
|
394
|
+
let newNo = 0;
|
|
395
|
+
for (const change of changes) {
|
|
396
|
+
const lines = splitLines(change.value);
|
|
397
|
+
for (const text of lines) {
|
|
398
|
+
if (change.added) {
|
|
399
|
+
newNo += 1;
|
|
400
|
+
rows.push({ kind: "added", newNo, text });
|
|
401
|
+
} else if (change.removed) {
|
|
402
|
+
oldNo += 1;
|
|
403
|
+
rows.push({ kind: "removed", oldNo, text });
|
|
404
|
+
} else {
|
|
405
|
+
oldNo += 1;
|
|
406
|
+
newNo += 1;
|
|
407
|
+
rows.push({ kind: "context", oldNo, newNo, text });
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
return rows;
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
/**
|
|
415
|
+
* Group rows into segments, collapsing interior runs of >COLLAPSE_THRESHOLD
|
|
416
|
+
* context rows (keeping CONTEXT_EDGE visible at each side). Leading/trailing runs
|
|
417
|
+
* collapse too, but keep only the inner edge visible.
|
|
418
|
+
*
|
|
419
|
+
* `isAnchored` marks context rows that carry an annotation (or sit adjacent to
|
|
420
|
+
* one): an anchored row is NEVER hidden inside a collapsed run, so a note that
|
|
421
|
+
* targets an unchanged line stays reachable. An anchor splits its run into the
|
|
422
|
+
* separately-collapsible spans on either side of it, with CONTEXT_EDGE rows kept
|
|
423
|
+
* visible around the anchor.
|
|
424
|
+
*/
|
|
425
|
+
function segmentRows(
|
|
426
|
+
rows: DiffRow[],
|
|
427
|
+
isAnchored?: (row: DiffRow) => boolean,
|
|
428
|
+
): DiffSegment[] {
|
|
429
|
+
const segments: DiffSegment[] = [];
|
|
430
|
+
|
|
431
|
+
// Collapse one contiguous context run [from, to) that contains NO anchors.
|
|
432
|
+
const collapseRun = (run: DiffRow[], atStart: boolean, atEnd: boolean) => {
|
|
433
|
+
if (run.length <= COLLAPSE_THRESHOLD) {
|
|
434
|
+
for (const row of run) segments.push(row);
|
|
435
|
+
return;
|
|
436
|
+
}
|
|
437
|
+
const head = atStart ? [] : run.slice(0, CONTEXT_EDGE);
|
|
438
|
+
const tail = atEnd ? [] : run.slice(run.length - CONTEXT_EDGE);
|
|
439
|
+
const hidden = run.slice(head.length, run.length - tail.length);
|
|
440
|
+
for (const row of head) segments.push(row);
|
|
441
|
+
if (hidden.length > 0) segments.push({ collapsed: true, rows: hidden });
|
|
442
|
+
for (const row of tail) segments.push(row);
|
|
443
|
+
};
|
|
444
|
+
|
|
445
|
+
let i = 0;
|
|
446
|
+
while (i < rows.length) {
|
|
447
|
+
if (rows[i].kind !== "context") {
|
|
448
|
+
segments.push(rows[i]);
|
|
449
|
+
i += 1;
|
|
450
|
+
continue;
|
|
451
|
+
}
|
|
452
|
+
// Gather the full contiguous context run.
|
|
453
|
+
let j = i;
|
|
454
|
+
while (j < rows.length && rows[j].kind === "context") j += 1;
|
|
455
|
+
const fullRun = rows.slice(i, j);
|
|
456
|
+
const runAtStart = i === 0;
|
|
457
|
+
const runAtEnd = j === rows.length;
|
|
458
|
+
|
|
459
|
+
if (!isAnchored || !fullRun.some(isAnchored)) {
|
|
460
|
+
collapseRun(fullRun, runAtStart, runAtEnd);
|
|
461
|
+
} else {
|
|
462
|
+
// Walk the run, emitting anchored rows verbatim and collapsing the
|
|
463
|
+
// unanchored spans between them. An anchored row is always visible; the
|
|
464
|
+
// spans on each side of it collapse independently.
|
|
465
|
+
let spanStart = 0;
|
|
466
|
+
for (let k = 0; k <= fullRun.length; k += 1) {
|
|
467
|
+
const atAnchor = k < fullRun.length && isAnchored(fullRun[k]);
|
|
468
|
+
if (atAnchor || k === fullRun.length) {
|
|
469
|
+
const span = fullRun.slice(spanStart, k);
|
|
470
|
+
if (span.length > 0) {
|
|
471
|
+
collapseRun(
|
|
472
|
+
span,
|
|
473
|
+
runAtStart && spanStart === 0,
|
|
474
|
+
runAtEnd && k === fullRun.length,
|
|
475
|
+
);
|
|
476
|
+
}
|
|
477
|
+
if (k < fullRun.length) segments.push(fullRun[k]);
|
|
478
|
+
spanStart = k + 1;
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
i = j;
|
|
483
|
+
}
|
|
484
|
+
return segments;
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
/* ── Theme-aware row styling (light + dark) ────────────────────────────────── */
|
|
488
|
+
|
|
489
|
+
const ROW_BG: Record<DiffRowKind, string> = {
|
|
490
|
+
added: "bg-emerald-500/10 dark:bg-emerald-500/15",
|
|
491
|
+
removed: "bg-destructive/10",
|
|
492
|
+
context: "bg-background",
|
|
493
|
+
};
|
|
494
|
+
|
|
495
|
+
const GUTTER_BG: Record<DiffRowKind, string> = {
|
|
496
|
+
added: "bg-emerald-500/15 dark:bg-emerald-500/20",
|
|
497
|
+
removed: "bg-destructive/15",
|
|
498
|
+
context: "bg-muted/60",
|
|
499
|
+
};
|
|
500
|
+
|
|
501
|
+
const SIGN_COLOR: Record<DiffRowKind, string> = {
|
|
502
|
+
added: "text-emerald-700 dark:text-emerald-300",
|
|
503
|
+
removed: "text-destructive",
|
|
504
|
+
context: "text-muted-foreground",
|
|
505
|
+
};
|
|
506
|
+
|
|
507
|
+
const SIGN: Record<DiffRowKind, string> = {
|
|
508
|
+
added: "+",
|
|
509
|
+
removed: "−",
|
|
510
|
+
context: " ",
|
|
511
|
+
};
|
|
512
|
+
|
|
513
|
+
const LINE_NO_CLASS =
|
|
514
|
+
"select-none px-2 py-0 text-right font-mono [font-size:var(--plan-doc-code-size)] leading-5 text-muted-foreground tabular-nums";
|
|
515
|
+
|
|
516
|
+
const DIFF_LINE_CLASS =
|
|
517
|
+
"block min-w-max flex-1 whitespace-pre px-2 py-0 font-mono [font-size:var(--plan-doc-code-size)] leading-5 text-foreground";
|
|
518
|
+
|
|
519
|
+
const DEFAULT_VISIBLE_DIFF_LINES = 15;
|
|
520
|
+
const MAX_DIFF_LCS_CELLS = 1_000_000;
|
|
521
|
+
const DIFF_MODE_STORAGE_KEY = "agent-native:diff-view-mode";
|
|
522
|
+
const DIFF_MODE_STORAGE_EVENT = "agent-native:diff-view-mode-change";
|
|
523
|
+
|
|
524
|
+
/**
|
|
525
|
+
* Below this rendered container width (px) a diff drops side-by-side `split`
|
|
526
|
+
* mode and falls back to `unified`: split's two line-number gutters double the
|
|
527
|
+
* width the code needs, exactly where space is tightest (e.g. a diff nested in a
|
|
528
|
+
* vertical-tabs content column). Measured from the block's own box, not the
|
|
529
|
+
* viewport, so the fallback fires by available width at any nesting depth.
|
|
530
|
+
*/
|
|
531
|
+
const SPLIT_MIN_WIDTH = 560;
|
|
532
|
+
|
|
533
|
+
/**
|
|
534
|
+
* Observe the rendered inline width of an element. Returns a ref to attach plus
|
|
535
|
+
* the measured content-box width (null until the first ResizeObserver tick).
|
|
536
|
+
* Lets the diff pick an effective mode from the width it was actually handed — a
|
|
537
|
+
* measurement CSS container queries can't drive, since switching split↔unified
|
|
538
|
+
* is a structural (DOM) change, not a style toggle.
|
|
539
|
+
*/
|
|
540
|
+
function useContainerWidth<T extends HTMLElement>() {
|
|
541
|
+
const ref = useRef<T | null>(null);
|
|
542
|
+
const [width, setWidth] = useState<number | null>(null);
|
|
543
|
+
useEffect(() => {
|
|
544
|
+
const el = ref.current;
|
|
545
|
+
if (!el || typeof ResizeObserver === "undefined") return;
|
|
546
|
+
const observer = new ResizeObserver((entries) => {
|
|
547
|
+
const entry = entries[0];
|
|
548
|
+
if (entry) setWidth(entry.contentRect.width);
|
|
549
|
+
});
|
|
550
|
+
observer.observe(el);
|
|
551
|
+
return () => observer.disconnect();
|
|
552
|
+
}, []);
|
|
553
|
+
return [ref, width] as const;
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
function isDiffMode(value: unknown): value is DiffMode {
|
|
557
|
+
return value === "unified" || value === "split";
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
function readStoredDiffMode(): DiffMode | null {
|
|
561
|
+
if (typeof window === "undefined") return null;
|
|
562
|
+
try {
|
|
563
|
+
const value = window.localStorage?.getItem(DIFF_MODE_STORAGE_KEY);
|
|
564
|
+
return isDiffMode(value) ? value : null;
|
|
565
|
+
} catch {
|
|
566
|
+
return null;
|
|
567
|
+
}
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
function writeStoredDiffMode(mode: DiffMode): void {
|
|
571
|
+
if (typeof window === "undefined") return;
|
|
572
|
+
try {
|
|
573
|
+
window.localStorage?.setItem(DIFF_MODE_STORAGE_KEY, mode);
|
|
574
|
+
} catch {
|
|
575
|
+
// Storage may be unavailable in sandboxed/private contexts.
|
|
576
|
+
}
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
function dispatchDiffModeChange(mode: DiffMode): void {
|
|
580
|
+
if (typeof window === "undefined") return;
|
|
581
|
+
try {
|
|
582
|
+
window.dispatchEvent(
|
|
583
|
+
new CustomEvent<DiffMode>(DIFF_MODE_STORAGE_EVENT, { detail: mode }),
|
|
584
|
+
);
|
|
585
|
+
} catch {
|
|
586
|
+
// Best-effort sync; local component state and storage already changed.
|
|
587
|
+
}
|
|
588
|
+
}
|
|
589
|
+
|
|
590
|
+
function usePreferredDiffMode(authoredMode: DiffMode | undefined) {
|
|
591
|
+
const [mode, setMode] = useState<DiffMode>(authoredMode ?? "split");
|
|
592
|
+
|
|
593
|
+
useEffect(() => {
|
|
594
|
+
if (authoredMode) return;
|
|
595
|
+
const storedMode = readStoredDiffMode();
|
|
596
|
+
if (storedMode) setMode(storedMode);
|
|
597
|
+
}, [authoredMode]);
|
|
598
|
+
|
|
599
|
+
useEffect(() => {
|
|
600
|
+
if (authoredMode) return;
|
|
601
|
+
if (typeof window === "undefined") return;
|
|
602
|
+
|
|
603
|
+
const onStorage = (event: StorageEvent) => {
|
|
604
|
+
if (event.key !== DIFF_MODE_STORAGE_KEY) return;
|
|
605
|
+
if (isDiffMode(event.newValue)) setMode(event.newValue);
|
|
606
|
+
};
|
|
607
|
+
const onModeChange = (event: Event) => {
|
|
608
|
+
const mode = (event as CustomEvent<unknown>).detail;
|
|
609
|
+
if (isDiffMode(mode)) setMode(mode);
|
|
610
|
+
};
|
|
611
|
+
|
|
612
|
+
window.addEventListener("storage", onStorage);
|
|
613
|
+
window.addEventListener(DIFF_MODE_STORAGE_EVENT, onModeChange);
|
|
614
|
+
return () => {
|
|
615
|
+
window.removeEventListener("storage", onStorage);
|
|
616
|
+
window.removeEventListener(DIFF_MODE_STORAGE_EVENT, onModeChange);
|
|
617
|
+
};
|
|
618
|
+
}, [authoredMode]);
|
|
619
|
+
|
|
620
|
+
const setPreferredMode = useCallback((nextMode: DiffMode) => {
|
|
621
|
+
setMode(nextMode);
|
|
622
|
+
writeStoredDiffMode(nextMode);
|
|
623
|
+
dispatchDiffModeChange(nextMode);
|
|
624
|
+
}, []);
|
|
625
|
+
|
|
626
|
+
return [mode, setPreferredMode] as const;
|
|
627
|
+
}
|
|
628
|
+
|
|
629
|
+
function splitDiffFilename(filename?: string): {
|
|
630
|
+
basename: string;
|
|
631
|
+
directory: string | null;
|
|
632
|
+
} {
|
|
633
|
+
const value = filename?.trim() || "diff";
|
|
634
|
+
const segments = value.split("/").filter(Boolean);
|
|
635
|
+
const basename = segments[segments.length - 1] ?? value;
|
|
636
|
+
const directory =
|
|
637
|
+
segments.length > 1 ? segments.slice(0, -1).join("/") : null;
|
|
638
|
+
return { basename, directory };
|
|
639
|
+
}
|
|
640
|
+
|
|
641
|
+
function DiffLineText({ language, text }: { language: string; text: string }) {
|
|
642
|
+
const code = text || " ";
|
|
643
|
+
return (
|
|
644
|
+
<span className={DIFF_LINE_CLASS}>
|
|
645
|
+
<SyntaxHighlightedLine code={code} language={language} />
|
|
646
|
+
</span>
|
|
647
|
+
);
|
|
648
|
+
}
|
|
649
|
+
|
|
650
|
+
/* ── Read ──────────────────────────────────────────────────────────────────── */
|
|
651
|
+
|
|
652
|
+
function DiffRead({
|
|
653
|
+
data,
|
|
654
|
+
blockId,
|
|
655
|
+
title,
|
|
656
|
+
summary,
|
|
657
|
+
ctx,
|
|
658
|
+
}: BlockReadProps<DiffData>) {
|
|
659
|
+
// Default layout when none is authored is SPLIT so reviewers can compare
|
|
660
|
+
// before/after code side-by-side. An explicitly authored `mode` or stored
|
|
661
|
+
// viewer preference still wins, and truly narrow hosts can fall back below.
|
|
662
|
+
const inNarrowContainer = useInNarrowContainer();
|
|
663
|
+
const [mode, setMode] = usePreferredDiffMode(data.mode);
|
|
664
|
+
const [expanded, setExpanded] = useState<Set<number>>(() => new Set());
|
|
665
|
+
const [showAllRows, setShowAllRows] = useState(false);
|
|
666
|
+
const [containerRef, containerWidth] = useContainerWidth<HTMLElement>();
|
|
667
|
+
// On-hover popover (anchored to the right of the code) replaces the old
|
|
668
|
+
// persistent rail: nothing is shown when idle. `codeRef` measures the code
|
|
669
|
+
// box's right edge; `hover` carries the active index + captured geometry.
|
|
670
|
+
const hover = useAnnotationHover();
|
|
671
|
+
const { activeIndex } = hover;
|
|
672
|
+
const codeRef = useRef<HTMLDivElement | null>(null);
|
|
673
|
+
|
|
674
|
+
const rows = useMemo(
|
|
675
|
+
() => buildRows(diffLines(data.before, data.after)),
|
|
676
|
+
[data.before, data.after],
|
|
677
|
+
);
|
|
678
|
+
const language = useMemo(
|
|
679
|
+
() => resolveDiffLanguage(data),
|
|
680
|
+
[data.filename, data.language],
|
|
681
|
+
);
|
|
682
|
+
const fileParts = useMemo(
|
|
683
|
+
() => splitDiffFilename(data.filename),
|
|
684
|
+
[data.filename],
|
|
685
|
+
);
|
|
686
|
+
const splitLineCount = useMemo(() => pairSplitRows(rows).length, [rows]);
|
|
687
|
+
|
|
688
|
+
// Resolve annotations against the side they target. A `before` annotation's
|
|
689
|
+
// `lines` ref is clamped to the OLD file's line count and matched on `oldNo`;
|
|
690
|
+
// an `after` (default) ref to the NEW file and matched on `newNo`. Markers are
|
|
691
|
+
// authoring-order across BOTH sides so a note ↔ row ↔ rail card share one id.
|
|
692
|
+
const beforeLineCount = useMemo(() => countLines(data.before), [data.before]);
|
|
693
|
+
const afterLineCount = useMemo(() => countLines(data.after), [data.after]);
|
|
694
|
+
const showAnnotationOverlays = Boolean(ctx.showCodeAnnotationOverlays);
|
|
695
|
+
const annotationLayout = ctx.codeAnnotationLayout;
|
|
696
|
+
const annotationHoverSide = annotationLayout?.hoverSide ?? "right";
|
|
697
|
+
const annotationHoverFallbackSide =
|
|
698
|
+
annotationLayout?.hoverFallbackSide ?? "right";
|
|
699
|
+
const annotationMarginSide = annotationLayout?.marginSide ?? "auto";
|
|
700
|
+
const defaultVisibleAnnotations =
|
|
701
|
+
annotationLayout?.defaultVisibleAnnotations ??
|
|
702
|
+
(annotationLayout?.showByDefaultWhenRoom ? "all" : undefined);
|
|
703
|
+
const resolved = useMemo(
|
|
704
|
+
() =>
|
|
705
|
+
resolveAnnotations(data.annotations, (annotation) =>
|
|
706
|
+
annotationSide(annotation) === "before"
|
|
707
|
+
? beforeLineCount
|
|
708
|
+
: afterLineCount,
|
|
709
|
+
),
|
|
710
|
+
[data.annotations, beforeLineCount, afterLineCount],
|
|
711
|
+
);
|
|
712
|
+
const hasAnnotations = hasRailAnnotations(resolved);
|
|
713
|
+
const showMarginAnnotations = useAnnotationMarginNotesAvailable({
|
|
714
|
+
containerRef: codeRef,
|
|
715
|
+
enabled: Boolean(
|
|
716
|
+
hasAnnotations && !showAnnotationOverlays && defaultVisibleAnnotations,
|
|
717
|
+
),
|
|
718
|
+
side: annotationMarginSide,
|
|
719
|
+
preferredSide: annotationHoverSide,
|
|
720
|
+
});
|
|
721
|
+
const showPersistentAnnotations =
|
|
722
|
+
showAnnotationOverlays || showMarginAnnotations;
|
|
723
|
+
const persistentAnnotationIndexes = useMemo(() => {
|
|
724
|
+
if (!showMarginAnnotations || !defaultVisibleAnnotations) {
|
|
725
|
+
return new Set<number>();
|
|
726
|
+
}
|
|
727
|
+
const visible = resolved.filter((item) => item.range);
|
|
728
|
+
if (defaultVisibleAnnotations === "first") {
|
|
729
|
+
const first = visible[0];
|
|
730
|
+
return first ? new Set([first.index]) : new Set<number>();
|
|
731
|
+
}
|
|
732
|
+
return new Set(visible.map((item) => item.index));
|
|
733
|
+
}, [defaultVisibleAnnotations, resolved, showMarginAnnotations]);
|
|
734
|
+
const captureOverlayAnnotationIndex = useMemo(
|
|
735
|
+
() => resolved.find((item) => item.range)?.index ?? null,
|
|
736
|
+
[resolved],
|
|
737
|
+
);
|
|
738
|
+
// Effective render mode. Annotations live in a SEPARATE right-hand rail (not
|
|
739
|
+
// over the code), so they no longer force a mode. When no mode was authored, a
|
|
740
|
+
// truly narrow container still falls back to unified so split's doubled
|
|
741
|
+
// gutters never crush the code; an explicitly authored `mode` wins even in a
|
|
742
|
+
// narrow host. `canSplit` only hides the toggle for auto-mode narrow fallbacks.
|
|
743
|
+
const measuredNarrow =
|
|
744
|
+
containerWidth != null && containerWidth < SPLIT_MIN_WIDTH;
|
|
745
|
+
const narrow = data.mode == null && (measuredNarrow || inNarrowContainer);
|
|
746
|
+
const canSplit = !narrow;
|
|
747
|
+
const effectiveMode: DiffMode = canSplit ? mode : "unified";
|
|
748
|
+
|
|
749
|
+
// Annotations (diff): NO persistent column. Hovering a marked code line (or
|
|
750
|
+
// its numbered pip) opens THAT note's card as an on-hover popover anchored to
|
|
751
|
+
// the RIGHT of the code box, never over the code. The in-code pip stays as the
|
|
752
|
+
// anchor indicator + active-line highlight. `onRowEnter` captures the code
|
|
753
|
+
// box's right edge + the hovered row's vertical position to place the card;
|
|
754
|
+
// `onRowLeave` schedules a short-delay close so the pointer can cross the gap
|
|
755
|
+
// into the card (which cancels the close while hovered).
|
|
756
|
+
const onRowEnter = useCallback(
|
|
757
|
+
(index: number, rowEl: HTMLElement) => {
|
|
758
|
+
const startRow =
|
|
759
|
+
codeRef.current?.querySelector<HTMLElement>(
|
|
760
|
+
`[data-annot-row="${index}"]`,
|
|
761
|
+
) ?? rowEl;
|
|
762
|
+
const anchor = anchorFromElements(codeRef.current, startRow);
|
|
763
|
+
if (anchor) hover.open(index, anchor);
|
|
764
|
+
},
|
|
765
|
+
[hover],
|
|
766
|
+
);
|
|
767
|
+
const onRowLeave = useCallback(() => hover.scheduleClose(), [hover]);
|
|
768
|
+
const onRowClick = useCallback(
|
|
769
|
+
(index: number, rowEl: HTMLElement) => {
|
|
770
|
+
const startRow =
|
|
771
|
+
codeRef.current?.querySelector<HTMLElement>(
|
|
772
|
+
`[data-annot-row="${index}"]`,
|
|
773
|
+
) ?? rowEl;
|
|
774
|
+
const anchor = anchorFromElements(codeRef.current, startRow);
|
|
775
|
+
if (anchor) hover.open(index, anchor);
|
|
776
|
+
},
|
|
777
|
+
[hover],
|
|
778
|
+
);
|
|
779
|
+
// Side-scoped line → markers maps so a row only lights from its own side.
|
|
780
|
+
const beforeMarkers = useMemo(
|
|
781
|
+
() =>
|
|
782
|
+
buildLineMarkerMap(
|
|
783
|
+
resolved.filter((r) => annotationSide(r.annotation) === "before"),
|
|
784
|
+
),
|
|
785
|
+
[resolved],
|
|
786
|
+
);
|
|
787
|
+
const afterMarkers = useMemo(
|
|
788
|
+
() =>
|
|
789
|
+
buildLineMarkerMap(
|
|
790
|
+
resolved.filter((r) => annotationSide(r.annotation) !== "before"),
|
|
791
|
+
),
|
|
792
|
+
[resolved],
|
|
793
|
+
);
|
|
794
|
+
const markersForRow = useMemo<MarkersForRow>(() => {
|
|
795
|
+
return (row, side) => {
|
|
796
|
+
const out: ResolvedAnnotation<DiffAnnotation>[] = [];
|
|
797
|
+
if (
|
|
798
|
+
(side === undefined || side === "old") &&
|
|
799
|
+
row.oldNo != null &&
|
|
800
|
+
row.kind !== "added"
|
|
801
|
+
) {
|
|
802
|
+
out.push(...(beforeMarkers.get(row.oldNo) ?? []));
|
|
803
|
+
}
|
|
804
|
+
if (
|
|
805
|
+
(side === undefined || side === "new") &&
|
|
806
|
+
row.newNo != null &&
|
|
807
|
+
row.kind !== "removed"
|
|
808
|
+
) {
|
|
809
|
+
out.push(...(afterMarkers.get(row.newNo) ?? []));
|
|
810
|
+
}
|
|
811
|
+
return out;
|
|
812
|
+
};
|
|
813
|
+
}, [beforeMarkers, afterMarkers]);
|
|
814
|
+
// A context row that carries a marker is an anchor: never collapse it away.
|
|
815
|
+
const anchoredRow = useMemo(() => {
|
|
816
|
+
if (!hasAnnotations) return undefined;
|
|
817
|
+
return (row: DiffRow) => markersForRow(row).length > 0;
|
|
818
|
+
}, [hasAnnotations, markersForRow]);
|
|
819
|
+
|
|
820
|
+
// The resolved annotation whose card is currently shown on hover.
|
|
821
|
+
const activeItem = useMemo<ResolvedAnnotation<DiffAnnotation> | null>(
|
|
822
|
+
() =>
|
|
823
|
+
activeIndex == null
|
|
824
|
+
? null
|
|
825
|
+
: (resolved.find((item) => item.index === activeIndex) ?? null),
|
|
826
|
+
[activeIndex, resolved],
|
|
827
|
+
);
|
|
828
|
+
const activeItemIsPersistentlyVisible = Boolean(
|
|
829
|
+
activeItem &&
|
|
830
|
+
!showAnnotationOverlays &&
|
|
831
|
+
persistentAnnotationIndexes.has(activeItem.index),
|
|
832
|
+
);
|
|
833
|
+
|
|
834
|
+
const added = rows.filter((r) => r.kind === "added").length;
|
|
835
|
+
const removed = rows.filter((r) => r.kind === "removed").length;
|
|
836
|
+
const unchanged = data.before === data.after;
|
|
837
|
+
const totalVisibleLineCount =
|
|
838
|
+
effectiveMode === "split" ? splitLineCount : rows.length;
|
|
839
|
+
const shouldLimitRows = totalVisibleLineCount > DEFAULT_VISIBLE_DIFF_LINES;
|
|
840
|
+
// Never truncate away an annotated row: extend the window past the last one.
|
|
841
|
+
const collapsedRowLimit = useMemo(() => {
|
|
842
|
+
if (!shouldLimitRows) return undefined;
|
|
843
|
+
let limit = DEFAULT_VISIBLE_DIFF_LINES;
|
|
844
|
+
if (hasAnnotations) {
|
|
845
|
+
for (let idx = rows.length - 1; idx >= limit; idx -= 1) {
|
|
846
|
+
if (markersForRow(rows[idx]).length > 0) {
|
|
847
|
+
limit = idx + 1;
|
|
848
|
+
break;
|
|
849
|
+
}
|
|
850
|
+
}
|
|
851
|
+
}
|
|
852
|
+
return limit;
|
|
853
|
+
}, [shouldLimitRows, hasAnnotations, rows, markersForRow]);
|
|
854
|
+
const hasHiddenRows =
|
|
855
|
+
collapsedRowLimit != null && collapsedRowLimit < totalVisibleLineCount;
|
|
856
|
+
const rowLimit = showAllRows ? undefined : collapsedRowLimit;
|
|
857
|
+
const displayedRows =
|
|
858
|
+
effectiveMode === "unified" && rowLimit ? rows.slice(0, rowLimit) : rows;
|
|
859
|
+
|
|
860
|
+
const toggleRun = (index: number) =>
|
|
861
|
+
setExpanded((prev) => {
|
|
862
|
+
const next = new Set(prev);
|
|
863
|
+
if (next.has(index)) next.delete(index);
|
|
864
|
+
else next.add(index);
|
|
865
|
+
return next;
|
|
866
|
+
});
|
|
867
|
+
|
|
868
|
+
// The bordered code box. It always spans its full width — annotations surface
|
|
869
|
+
// as an on-hover popover anchored to this box's right edge, never as a column.
|
|
870
|
+
// `codeRef` measures that right edge for the popover's placement.
|
|
871
|
+
const diffBox = (
|
|
872
|
+
<div
|
|
873
|
+
ref={codeRef}
|
|
874
|
+
className="overflow-hidden rounded-md border border-border bg-background"
|
|
875
|
+
>
|
|
876
|
+
{/* Header: filename, path, +/− counts, mode toggle. */}
|
|
877
|
+
<div className="flex min-h-10 flex-wrap items-center gap-2 border-b border-border bg-muted/60 px-3 py-1.5">
|
|
878
|
+
<IconFileDiff className="size-4 shrink-0 text-muted-foreground" />
|
|
879
|
+
<span
|
|
880
|
+
className="flex min-w-0 flex-1 items-baseline gap-1.5 font-mono"
|
|
881
|
+
title={data.filename || undefined}
|
|
882
|
+
>
|
|
883
|
+
<span className="min-w-0 max-w-[16rem] truncate text-[13px] font-semibold leading-5 text-foreground">
|
|
884
|
+
{fileParts.basename}
|
|
885
|
+
</span>
|
|
886
|
+
{fileParts.directory && (
|
|
887
|
+
<span className="min-w-0 flex-1 truncate text-[11px] leading-5 text-muted-foreground/70">
|
|
888
|
+
{fileParts.directory}
|
|
889
|
+
</span>
|
|
890
|
+
)}
|
|
891
|
+
</span>
|
|
892
|
+
<span className="ml-1 flex shrink-0 items-center gap-2 font-mono text-xs">
|
|
893
|
+
<span className="text-emerald-700 dark:text-emerald-300">
|
|
894
|
+
+{added}
|
|
895
|
+
</span>
|
|
896
|
+
<span className="text-destructive">−{removed}</span>
|
|
897
|
+
</span>
|
|
898
|
+
{/* Mode toggle only when split is actually available: a narrow
|
|
899
|
+
container forces unified (split's doubled gutters would crush the
|
|
900
|
+
code), so the toggle would otherwise be a no-op. Annotations are an
|
|
901
|
+
on-hover popover now, so they work in both unified and split. */}
|
|
902
|
+
{canSplit && (
|
|
903
|
+
<div className="pointer-events-none ml-auto flex shrink-0 items-center overflow-hidden rounded-md border border-border bg-background opacity-0 transition-opacity group-hover/diff-block:pointer-events-auto group-hover/diff-block:opacity-100 group-focus-within/diff-block:pointer-events-auto group-focus-within/diff-block:opacity-100">
|
|
904
|
+
<ModeButton
|
|
905
|
+
active={mode === "unified"}
|
|
906
|
+
onClick={() => setMode("unified")}
|
|
907
|
+
icon={<IconList className="size-3.5" />}
|
|
908
|
+
label="Unified"
|
|
909
|
+
/>
|
|
910
|
+
<ModeButton
|
|
911
|
+
active={mode === "split"}
|
|
912
|
+
onClick={() => setMode("split")}
|
|
913
|
+
icon={<IconColumns className="size-3.5" />}
|
|
914
|
+
label="Split"
|
|
915
|
+
/>
|
|
916
|
+
</div>
|
|
917
|
+
)}
|
|
918
|
+
</div>
|
|
919
|
+
|
|
920
|
+
{/* Body. */}
|
|
921
|
+
{unchanged ? (
|
|
922
|
+
<div className="px-4 py-6 text-center font-mono text-sm text-muted-foreground">
|
|
923
|
+
No changes
|
|
924
|
+
</div>
|
|
925
|
+
) : effectiveMode === "split" ? (
|
|
926
|
+
<SplitView
|
|
927
|
+
rows={rows}
|
|
928
|
+
language={language}
|
|
929
|
+
rowLimit={rowLimit}
|
|
930
|
+
markersForRow={markersForRow}
|
|
931
|
+
activeIndex={activeIndex}
|
|
932
|
+
onRowEnter={onRowEnter}
|
|
933
|
+
onRowLeave={onRowLeave}
|
|
934
|
+
onRowClick={onRowClick}
|
|
935
|
+
showAnnotationOverlays={showPersistentAnnotations}
|
|
936
|
+
annotationOverlayMode={showAnnotationOverlays ? "capture" : "margin"}
|
|
937
|
+
annotationOverlaySide={
|
|
938
|
+
showAnnotationOverlays ? "right" : annotationMarginSide
|
|
939
|
+
}
|
|
940
|
+
annotationOverlayPreferredSide={annotationHoverSide}
|
|
941
|
+
annotationOverlayContainerRef={codeRef}
|
|
942
|
+
captureOverlayAnnotationIndex={captureOverlayAnnotationIndex}
|
|
943
|
+
persistentAnnotationIndexes={persistentAnnotationIndexes}
|
|
944
|
+
ctx={ctx}
|
|
945
|
+
/>
|
|
946
|
+
) : (
|
|
947
|
+
<UnifiedView
|
|
948
|
+
rows={displayedRows}
|
|
949
|
+
language={language}
|
|
950
|
+
expanded={expanded}
|
|
951
|
+
onToggleRun={toggleRun}
|
|
952
|
+
markersForRow={markersForRow}
|
|
953
|
+
anchoredRow={anchoredRow}
|
|
954
|
+
activeIndex={activeIndex}
|
|
955
|
+
onRowEnter={onRowEnter}
|
|
956
|
+
onRowLeave={onRowLeave}
|
|
957
|
+
onRowClick={onRowClick}
|
|
958
|
+
showAnnotationOverlays={showPersistentAnnotations}
|
|
959
|
+
annotationOverlayMode={showAnnotationOverlays ? "capture" : "margin"}
|
|
960
|
+
annotationOverlaySide={
|
|
961
|
+
showAnnotationOverlays ? "right" : annotationMarginSide
|
|
962
|
+
}
|
|
963
|
+
annotationOverlayPreferredSide={annotationHoverSide}
|
|
964
|
+
annotationOverlayContainerRef={codeRef}
|
|
965
|
+
captureOverlayAnnotationIndex={captureOverlayAnnotationIndex}
|
|
966
|
+
persistentAnnotationIndexes={persistentAnnotationIndexes}
|
|
967
|
+
ctx={ctx}
|
|
968
|
+
/>
|
|
969
|
+
)}
|
|
970
|
+
{!unchanged && hasHiddenRows && (
|
|
971
|
+
<button
|
|
972
|
+
type="button"
|
|
973
|
+
data-plan-interactive
|
|
974
|
+
aria-expanded={showAllRows}
|
|
975
|
+
onClick={() => setShowAllRows((current) => !current)}
|
|
976
|
+
className="flex h-7 w-full items-center justify-center gap-1.5 border-t border-border bg-background px-2 text-[11px] font-medium text-muted-foreground transition-colors hover:bg-muted/70 hover:text-foreground"
|
|
977
|
+
>
|
|
978
|
+
<IconChevronRight
|
|
979
|
+
className={cn(
|
|
980
|
+
"size-3 shrink-0 transition-transform",
|
|
981
|
+
showAllRows ? "-rotate-90" : "rotate-90",
|
|
982
|
+
)}
|
|
983
|
+
/>
|
|
984
|
+
{showAllRows
|
|
985
|
+
? "Show fewer"
|
|
986
|
+
: `Show all ${totalVisibleLineCount} lines`}
|
|
987
|
+
</button>
|
|
988
|
+
)}
|
|
989
|
+
</div>
|
|
990
|
+
);
|
|
991
|
+
|
|
992
|
+
return (
|
|
993
|
+
<section
|
|
994
|
+
{...ltrCodeBlockProps}
|
|
995
|
+
ref={containerRef}
|
|
996
|
+
className="relative plan-block group/diff-block"
|
|
997
|
+
data-block-id={blockId}
|
|
998
|
+
>
|
|
999
|
+
{title && <div className="plan-block-label">{title}</div>}
|
|
1000
|
+
{summary && (
|
|
1001
|
+
<p className="mb-3 text-sm leading-relaxed text-plan-muted">
|
|
1002
|
+
{summary}
|
|
1003
|
+
</p>
|
|
1004
|
+
)}
|
|
1005
|
+
{/* The diff keeps its full width — no persistent annotation column. The
|
|
1006
|
+
in-code numbered pips remain the hover anchors; notes live in a
|
|
1007
|
+
visually-hidden stack (a11y + tests) and surface ONE at a time as an
|
|
1008
|
+
on-hover popover anchored to the right of the code box. */}
|
|
1009
|
+
{diffBox}
|
|
1010
|
+
{hasAnnotations && (
|
|
1011
|
+
<AnnotationHiddenStack items={resolved} ctx={ctx} showMarker />
|
|
1012
|
+
)}
|
|
1013
|
+
{hasAnnotations &&
|
|
1014
|
+
!showAnnotationOverlays &&
|
|
1015
|
+
!activeItemIsPersistentlyVisible &&
|
|
1016
|
+
activeItem &&
|
|
1017
|
+
hover.anchor && (
|
|
1018
|
+
<AnnotationHoverCard
|
|
1019
|
+
item={activeItem}
|
|
1020
|
+
anchor={hover.anchor}
|
|
1021
|
+
ctx={ctx}
|
|
1022
|
+
showMarker
|
|
1023
|
+
preferredSide={annotationHoverSide}
|
|
1024
|
+
hoverFallbackSide={annotationHoverFallbackSide}
|
|
1025
|
+
onMouseEnter={hover.cancelClose}
|
|
1026
|
+
onMouseLeave={hover.scheduleClose}
|
|
1027
|
+
onClose={hover.closeForScroll}
|
|
1028
|
+
onInteractOutside={hover.close}
|
|
1029
|
+
/>
|
|
1030
|
+
)}
|
|
1031
|
+
</section>
|
|
1032
|
+
);
|
|
1033
|
+
}
|
|
1034
|
+
|
|
1035
|
+
function ModeButton({
|
|
1036
|
+
active,
|
|
1037
|
+
onClick,
|
|
1038
|
+
icon,
|
|
1039
|
+
label,
|
|
1040
|
+
}: {
|
|
1041
|
+
active: boolean;
|
|
1042
|
+
onClick: () => void;
|
|
1043
|
+
icon: ReactNode;
|
|
1044
|
+
label: string;
|
|
1045
|
+
}) {
|
|
1046
|
+
return (
|
|
1047
|
+
<button
|
|
1048
|
+
type="button"
|
|
1049
|
+
data-plan-interactive
|
|
1050
|
+
onClick={onClick}
|
|
1051
|
+
aria-pressed={active}
|
|
1052
|
+
className={cn(
|
|
1053
|
+
"flex cursor-pointer items-center gap-1 px-2 py-1 text-xs font-medium transition-colors",
|
|
1054
|
+
active
|
|
1055
|
+
? "bg-accent text-accent-foreground"
|
|
1056
|
+
: "text-muted-foreground hover:bg-muted/80 hover:text-foreground",
|
|
1057
|
+
)}
|
|
1058
|
+
>
|
|
1059
|
+
{icon}
|
|
1060
|
+
{label}
|
|
1061
|
+
</button>
|
|
1062
|
+
);
|
|
1063
|
+
}
|
|
1064
|
+
|
|
1065
|
+
/* ── Annotation wiring shared by both views ────────────────────────────────── */
|
|
1066
|
+
|
|
1067
|
+
/** Marker + hover props threaded into the unified/split rows. */
|
|
1068
|
+
interface RowAnnotationProps {
|
|
1069
|
+
markersForRow: MarkersForRow;
|
|
1070
|
+
anchoredRow?: (row: DiffRow) => boolean;
|
|
1071
|
+
activeIndex: number | null;
|
|
1072
|
+
showAnnotationOverlays: boolean;
|
|
1073
|
+
ctx: BlockRenderContext;
|
|
1074
|
+
/** Hovering an annotated row opens its popover, anchored to this row's box. */
|
|
1075
|
+
onRowEnter: (index: number, rowEl: HTMLElement) => void;
|
|
1076
|
+
/** Leaving an annotated row schedules the popover's close. */
|
|
1077
|
+
onRowLeave: () => void;
|
|
1078
|
+
/** Clicking/tapping an annotated row toggles its popover (for touch). */
|
|
1079
|
+
onRowClick: (index: number, rowEl: HTMLElement) => void;
|
|
1080
|
+
annotationOverlayMode: "capture" | "margin";
|
|
1081
|
+
annotationOverlaySide: AnnotationMarginSide;
|
|
1082
|
+
annotationOverlayPreferredSide: AnnotationSide;
|
|
1083
|
+
annotationOverlayContainerRef: RefObject<HTMLElement | null>;
|
|
1084
|
+
captureOverlayAnnotationIndex: number | null;
|
|
1085
|
+
persistentAnnotationIndexes: ReadonlySet<number>;
|
|
1086
|
+
}
|
|
1087
|
+
|
|
1088
|
+
/**
|
|
1089
|
+
* The numbered marker pip(s) for a row plus the active-state it derives. Returns
|
|
1090
|
+
* `null` when the row carries no annotation so unannotated diffs render an empty
|
|
1091
|
+
* marker column (or no column at all when the whole diff is unannotated).
|
|
1092
|
+
*/
|
|
1093
|
+
function rowMarkerInfo(
|
|
1094
|
+
markers: ResolvedAnnotation<DiffAnnotation>[],
|
|
1095
|
+
activeIndex: number | null,
|
|
1096
|
+
): { isActive: boolean; primaryIndex: number } | null {
|
|
1097
|
+
if (markers.length === 0) return null;
|
|
1098
|
+
const isActive = markers.some((m) => m.index === activeIndex);
|
|
1099
|
+
return { isActive, primaryIndex: markers[0].index };
|
|
1100
|
+
}
|
|
1101
|
+
|
|
1102
|
+
/** Shared amber wash for an annotated row, brighter when active. */
|
|
1103
|
+
function annotatedRowBg(
|
|
1104
|
+
info: { isActive: boolean } | null,
|
|
1105
|
+
persistentlyVisible = false,
|
|
1106
|
+
): string | null {
|
|
1107
|
+
if (!info) return null;
|
|
1108
|
+
if (info.isActive) {
|
|
1109
|
+
return "bg-amber-400/[0.12] dark:bg-amber-300/[0.10]";
|
|
1110
|
+
}
|
|
1111
|
+
return persistentlyVisible
|
|
1112
|
+
? "bg-amber-300/[0.14] dark:bg-amber-300/[0.10]"
|
|
1113
|
+
: "bg-amber-400/[0.045] dark:bg-amber-300/[0.045]";
|
|
1114
|
+
}
|
|
1115
|
+
|
|
1116
|
+
/**
|
|
1117
|
+
* Whether `row` is the FIRST line of `marker`'s resolved range. The numbered pip
|
|
1118
|
+
* renders only on this line, so a multi-line annotation shows a single marker at
|
|
1119
|
+
* the top of its span instead of repeating the same number down every line it
|
|
1120
|
+
* covers. The amber band still washes the whole range (via `annotatedRowBg`), so
|
|
1121
|
+
* the span stays visually grouped without the column of duplicate numbers.
|
|
1122
|
+
*/
|
|
1123
|
+
function isMarkerRangeStart(
|
|
1124
|
+
row: DiffRow,
|
|
1125
|
+
marker: ResolvedAnnotation<DiffAnnotation>,
|
|
1126
|
+
): boolean {
|
|
1127
|
+
if (!marker.range) return false;
|
|
1128
|
+
const lineNo =
|
|
1129
|
+
annotationSide(marker.annotation) === "before" ? row.oldNo : row.newNo;
|
|
1130
|
+
return lineNo === marker.range.start;
|
|
1131
|
+
}
|
|
1132
|
+
|
|
1133
|
+
/* ── Unified view ──────────────────────────────────────────────────────────── */
|
|
1134
|
+
|
|
1135
|
+
function UnifiedView({
|
|
1136
|
+
rows,
|
|
1137
|
+
language,
|
|
1138
|
+
expanded,
|
|
1139
|
+
onToggleRun,
|
|
1140
|
+
markersForRow,
|
|
1141
|
+
anchoredRow,
|
|
1142
|
+
activeIndex,
|
|
1143
|
+
onRowEnter,
|
|
1144
|
+
onRowLeave,
|
|
1145
|
+
onRowClick,
|
|
1146
|
+
showAnnotationOverlays,
|
|
1147
|
+
annotationOverlayMode,
|
|
1148
|
+
annotationOverlaySide,
|
|
1149
|
+
annotationOverlayPreferredSide,
|
|
1150
|
+
annotationOverlayContainerRef,
|
|
1151
|
+
captureOverlayAnnotationIndex,
|
|
1152
|
+
persistentAnnotationIndexes,
|
|
1153
|
+
ctx,
|
|
1154
|
+
}: {
|
|
1155
|
+
rows: DiffRow[];
|
|
1156
|
+
language: string;
|
|
1157
|
+
expanded: Set<number>;
|
|
1158
|
+
onToggleRun: (index: number) => void;
|
|
1159
|
+
} & RowAnnotationProps) {
|
|
1160
|
+
const segments = useMemo(
|
|
1161
|
+
() => segmentRows(rows, anchoredRow),
|
|
1162
|
+
[rows, anchoredRow],
|
|
1163
|
+
);
|
|
1164
|
+
// Any annotation present ⇒ reserve the marker column so rows stay aligned.
|
|
1165
|
+
const showMarkerColumn = useMemo(
|
|
1166
|
+
() => rows.some((row) => markersForRow(row).length > 0),
|
|
1167
|
+
[rows, markersForRow],
|
|
1168
|
+
);
|
|
1169
|
+
const rowProps = {
|
|
1170
|
+
language,
|
|
1171
|
+
markersForRow,
|
|
1172
|
+
activeIndex,
|
|
1173
|
+
onRowEnter,
|
|
1174
|
+
onRowLeave,
|
|
1175
|
+
onRowClick,
|
|
1176
|
+
showMarkerColumn,
|
|
1177
|
+
showAnnotationOverlays,
|
|
1178
|
+
annotationOverlayMode,
|
|
1179
|
+
annotationOverlaySide,
|
|
1180
|
+
annotationOverlayPreferredSide,
|
|
1181
|
+
annotationOverlayContainerRef,
|
|
1182
|
+
captureOverlayAnnotationIndex,
|
|
1183
|
+
persistentAnnotationIndexes,
|
|
1184
|
+
ctx,
|
|
1185
|
+
};
|
|
1186
|
+
let runIndex = 0;
|
|
1187
|
+
return (
|
|
1188
|
+
<div className="overflow-x-auto" data-code-surface>
|
|
1189
|
+
<div className="w-max min-w-full font-mono [font-size:var(--plan-doc-code-size)] leading-5">
|
|
1190
|
+
{segments.map((segment, idx) => {
|
|
1191
|
+
if ("collapsed" in segment) {
|
|
1192
|
+
const key = runIndex++;
|
|
1193
|
+
const open = expanded.has(key);
|
|
1194
|
+
return (
|
|
1195
|
+
<div key={`run-${key}`}>
|
|
1196
|
+
<CollapsedRow
|
|
1197
|
+
count={segment.rows.length}
|
|
1198
|
+
open={open}
|
|
1199
|
+
onClick={() => onToggleRun(key)}
|
|
1200
|
+
/>
|
|
1201
|
+
{open &&
|
|
1202
|
+
segment.rows.map((row, ri) => (
|
|
1203
|
+
<UnifiedRow
|
|
1204
|
+
key={`run-${key}-${ri}`}
|
|
1205
|
+
row={row}
|
|
1206
|
+
{...rowProps}
|
|
1207
|
+
/>
|
|
1208
|
+
))}
|
|
1209
|
+
</div>
|
|
1210
|
+
);
|
|
1211
|
+
}
|
|
1212
|
+
return <UnifiedRow key={idx} row={segment} {...rowProps} />;
|
|
1213
|
+
})}
|
|
1214
|
+
</div>
|
|
1215
|
+
</div>
|
|
1216
|
+
);
|
|
1217
|
+
}
|
|
1218
|
+
|
|
1219
|
+
function UnifiedRow({
|
|
1220
|
+
language,
|
|
1221
|
+
row,
|
|
1222
|
+
markersForRow,
|
|
1223
|
+
activeIndex,
|
|
1224
|
+
onRowEnter,
|
|
1225
|
+
onRowLeave,
|
|
1226
|
+
onRowClick,
|
|
1227
|
+
showMarkerColumn,
|
|
1228
|
+
showAnnotationOverlays,
|
|
1229
|
+
annotationOverlayMode,
|
|
1230
|
+
annotationOverlaySide,
|
|
1231
|
+
annotationOverlayPreferredSide,
|
|
1232
|
+
annotationOverlayContainerRef,
|
|
1233
|
+
captureOverlayAnnotationIndex,
|
|
1234
|
+
persistentAnnotationIndexes,
|
|
1235
|
+
ctx,
|
|
1236
|
+
}: {
|
|
1237
|
+
language: string;
|
|
1238
|
+
row: DiffRow;
|
|
1239
|
+
markersForRow: MarkersForRow;
|
|
1240
|
+
activeIndex: number | null;
|
|
1241
|
+
onRowEnter: (index: number, rowEl: HTMLElement) => void;
|
|
1242
|
+
onRowLeave: () => void;
|
|
1243
|
+
onRowClick: (index: number, rowEl: HTMLElement) => void;
|
|
1244
|
+
showMarkerColumn: boolean;
|
|
1245
|
+
showAnnotationOverlays: boolean;
|
|
1246
|
+
annotationOverlayMode: "capture" | "margin";
|
|
1247
|
+
annotationOverlaySide: AnnotationMarginSide;
|
|
1248
|
+
annotationOverlayPreferredSide: AnnotationSide;
|
|
1249
|
+
annotationOverlayContainerRef: RefObject<HTMLElement | null>;
|
|
1250
|
+
captureOverlayAnnotationIndex: number | null;
|
|
1251
|
+
persistentAnnotationIndexes: ReadonlySet<number>;
|
|
1252
|
+
ctx: BlockRenderContext;
|
|
1253
|
+
}) {
|
|
1254
|
+
const markers = markersForRow(row);
|
|
1255
|
+
const info = rowMarkerInfo(markers, activeIndex);
|
|
1256
|
+
const startMarker = markers.find((marker) => isMarkerRangeStart(row, marker));
|
|
1257
|
+
const primaryIndex = startMarker?.index ?? info?.primaryIndex;
|
|
1258
|
+
const overlayItems =
|
|
1259
|
+
showAnnotationOverlays &&
|
|
1260
|
+
startMarker &&
|
|
1261
|
+
(annotationOverlayMode === "capture"
|
|
1262
|
+
? startMarker.index === captureOverlayAnnotationIndex
|
|
1263
|
+
: persistentAnnotationIndexes.has(startMarker.index))
|
|
1264
|
+
? [startMarker]
|
|
1265
|
+
: [];
|
|
1266
|
+
const rowHasPersistentAnnotation = markers.some((marker) =>
|
|
1267
|
+
persistentAnnotationIndexes.has(marker.index),
|
|
1268
|
+
);
|
|
1269
|
+
return (
|
|
1270
|
+
<div
|
|
1271
|
+
data-annot-row={startMarker ? startMarker.index : undefined}
|
|
1272
|
+
tabIndex={info ? 0 : undefined}
|
|
1273
|
+
role={info ? "button" : undefined}
|
|
1274
|
+
aria-expanded={info ? info.isActive : undefined}
|
|
1275
|
+
className={cn(
|
|
1276
|
+
"relative flex min-h-5 min-w-full",
|
|
1277
|
+
info && "cursor-pointer",
|
|
1278
|
+
ROW_BG[row.kind],
|
|
1279
|
+
annotatedRowBg(info, rowHasPersistentAnnotation),
|
|
1280
|
+
)}
|
|
1281
|
+
onMouseEnter={
|
|
1282
|
+
info && primaryIndex != null
|
|
1283
|
+
? (event) => onRowEnter(primaryIndex, event.currentTarget)
|
|
1284
|
+
: undefined
|
|
1285
|
+
}
|
|
1286
|
+
onMouseLeave={info ? () => onRowLeave() : undefined}
|
|
1287
|
+
onClick={
|
|
1288
|
+
info && primaryIndex != null
|
|
1289
|
+
? (event) => onRowClick(primaryIndex, event.currentTarget)
|
|
1290
|
+
: undefined
|
|
1291
|
+
}
|
|
1292
|
+
onKeyDown={
|
|
1293
|
+
info && primaryIndex != null
|
|
1294
|
+
? (event) => {
|
|
1295
|
+
if (event.key !== "Enter" && event.key !== " ") return;
|
|
1296
|
+
event.preventDefault();
|
|
1297
|
+
onRowClick(primaryIndex, event.currentTarget);
|
|
1298
|
+
}
|
|
1299
|
+
: undefined
|
|
1300
|
+
}
|
|
1301
|
+
onFocus={
|
|
1302
|
+
info && primaryIndex != null
|
|
1303
|
+
? (event) => onRowEnter(primaryIndex, event.currentTarget)
|
|
1304
|
+
: undefined
|
|
1305
|
+
}
|
|
1306
|
+
onBlur={info ? () => onRowLeave() : undefined}
|
|
1307
|
+
>
|
|
1308
|
+
<span className={cn(LINE_NO_CLASS, "w-[52px]")}>{row.oldNo ?? ""}</span>
|
|
1309
|
+
<span className={cn(LINE_NO_CLASS, "w-[52px]")}>{row.newNo ?? ""}</span>
|
|
1310
|
+
<span
|
|
1311
|
+
className={cn(
|
|
1312
|
+
"w-6 shrink-0 select-none py-0 text-center font-semibold leading-5",
|
|
1313
|
+
GUTTER_BG[row.kind],
|
|
1314
|
+
SIGN_COLOR[row.kind],
|
|
1315
|
+
)}
|
|
1316
|
+
>
|
|
1317
|
+
{SIGN[row.kind]}
|
|
1318
|
+
</span>
|
|
1319
|
+
{showMarkerColumn && (
|
|
1320
|
+
<MarkerCell
|
|
1321
|
+
startMarker={startMarker}
|
|
1322
|
+
active={
|
|
1323
|
+
startMarker != null &&
|
|
1324
|
+
(startMarker.index === activeIndex ||
|
|
1325
|
+
persistentAnnotationIndexes.has(startMarker.index))
|
|
1326
|
+
}
|
|
1327
|
+
/>
|
|
1328
|
+
)}
|
|
1329
|
+
<DiffLineText text={row.text} language={language} />
|
|
1330
|
+
{overlayItems.length > 0 && (
|
|
1331
|
+
<AnnotationInlineOverlayStack
|
|
1332
|
+
items={overlayItems}
|
|
1333
|
+
ctx={ctx}
|
|
1334
|
+
showMarker
|
|
1335
|
+
containerRef={annotationOverlayContainerRef}
|
|
1336
|
+
mode={annotationOverlayMode}
|
|
1337
|
+
side={annotationOverlaySide}
|
|
1338
|
+
preferredSide={annotationOverlayPreferredSide}
|
|
1339
|
+
/>
|
|
1340
|
+
)}
|
|
1341
|
+
</div>
|
|
1342
|
+
);
|
|
1343
|
+
}
|
|
1344
|
+
|
|
1345
|
+
/**
|
|
1346
|
+
* The fixed-width marker column rendered between the sign gutter and the code.
|
|
1347
|
+
* `startMarker` is set only on the FIRST line of an annotation's range, so the
|
|
1348
|
+
* numbered pip appears once at the top of a span; every other row (the rest of a
|
|
1349
|
+
* span, and every unannotated row in a diff that has annotations) renders an
|
|
1350
|
+
* empty spacer so the code text stays aligned.
|
|
1351
|
+
*/
|
|
1352
|
+
function MarkerCell({
|
|
1353
|
+
startMarker,
|
|
1354
|
+
active,
|
|
1355
|
+
}: {
|
|
1356
|
+
startMarker?: ResolvedAnnotation<DiffAnnotation>;
|
|
1357
|
+
active: boolean;
|
|
1358
|
+
}) {
|
|
1359
|
+
return (
|
|
1360
|
+
<span className="flex w-6 shrink-0 select-none items-center justify-center py-0">
|
|
1361
|
+
{startMarker != null && (
|
|
1362
|
+
<AnnotationGutterMarker marker={startMarker.marker} active={active} />
|
|
1363
|
+
)}
|
|
1364
|
+
</span>
|
|
1365
|
+
);
|
|
1366
|
+
}
|
|
1367
|
+
|
|
1368
|
+
function CollapsedRow({
|
|
1369
|
+
count,
|
|
1370
|
+
open,
|
|
1371
|
+
onClick,
|
|
1372
|
+
}: {
|
|
1373
|
+
count: number;
|
|
1374
|
+
open: boolean;
|
|
1375
|
+
onClick: () => void;
|
|
1376
|
+
}) {
|
|
1377
|
+
return (
|
|
1378
|
+
<button
|
|
1379
|
+
type="button"
|
|
1380
|
+
data-plan-interactive
|
|
1381
|
+
onClick={onClick}
|
|
1382
|
+
className="flex w-full cursor-pointer items-center gap-2 border-y border-border bg-muted/70 px-3 py-1 text-left text-xs text-muted-foreground transition-colors hover:bg-muted hover:text-foreground"
|
|
1383
|
+
>
|
|
1384
|
+
<IconDotsVertical className="size-3.5 shrink-0" />
|
|
1385
|
+
<span>
|
|
1386
|
+
{open ? "Hide" : "Show"} {count} unchanged line
|
|
1387
|
+
{count === 1 ? "" : "s"}
|
|
1388
|
+
</span>
|
|
1389
|
+
</button>
|
|
1390
|
+
);
|
|
1391
|
+
}
|
|
1392
|
+
|
|
1393
|
+
/* ── Split (side-by-side) view ─────────────────────────────────────────────── */
|
|
1394
|
+
|
|
1395
|
+
interface SplitRow {
|
|
1396
|
+
left?: DiffRow;
|
|
1397
|
+
right?: DiffRow;
|
|
1398
|
+
}
|
|
1399
|
+
|
|
1400
|
+
/**
|
|
1401
|
+
* Pair removed lines (left) with added lines (right) so a modification shows the
|
|
1402
|
+
* old and new side by side; context lines mirror on both columns. Leftover adds
|
|
1403
|
+
* or removes fall through as half-empty rows (GitHub split behavior).
|
|
1404
|
+
*/
|
|
1405
|
+
function pairSplitRows(rows: DiffRow[]): SplitRow[] {
|
|
1406
|
+
const out: SplitRow[] = [];
|
|
1407
|
+
let i = 0;
|
|
1408
|
+
while (i < rows.length) {
|
|
1409
|
+
const row = rows[i];
|
|
1410
|
+
if (row.kind === "context") {
|
|
1411
|
+
out.push({ left: row, right: row });
|
|
1412
|
+
i += 1;
|
|
1413
|
+
continue;
|
|
1414
|
+
}
|
|
1415
|
+
// Collect a contiguous block of removed-then-added rows.
|
|
1416
|
+
const removed: DiffRow[] = [];
|
|
1417
|
+
const added: DiffRow[] = [];
|
|
1418
|
+
while (i < rows.length && rows[i].kind === "removed")
|
|
1419
|
+
removed.push(rows[i++]);
|
|
1420
|
+
while (i < rows.length && rows[i].kind === "added") added.push(rows[i++]);
|
|
1421
|
+
const max = Math.max(removed.length, added.length);
|
|
1422
|
+
for (let k = 0; k < max; k += 1) {
|
|
1423
|
+
out.push({ left: removed[k], right: added[k] });
|
|
1424
|
+
}
|
|
1425
|
+
}
|
|
1426
|
+
return out;
|
|
1427
|
+
}
|
|
1428
|
+
|
|
1429
|
+
function SplitView({
|
|
1430
|
+
language,
|
|
1431
|
+
rowLimit,
|
|
1432
|
+
rows,
|
|
1433
|
+
markersForRow,
|
|
1434
|
+
activeIndex,
|
|
1435
|
+
onRowEnter,
|
|
1436
|
+
onRowLeave,
|
|
1437
|
+
onRowClick,
|
|
1438
|
+
showAnnotationOverlays,
|
|
1439
|
+
annotationOverlayMode,
|
|
1440
|
+
annotationOverlaySide,
|
|
1441
|
+
annotationOverlayPreferredSide,
|
|
1442
|
+
annotationOverlayContainerRef,
|
|
1443
|
+
captureOverlayAnnotationIndex,
|
|
1444
|
+
persistentAnnotationIndexes,
|
|
1445
|
+
ctx,
|
|
1446
|
+
}: {
|
|
1447
|
+
language: string;
|
|
1448
|
+
rowLimit?: number;
|
|
1449
|
+
rows: DiffRow[];
|
|
1450
|
+
} & Omit<RowAnnotationProps, "anchoredRow">) {
|
|
1451
|
+
const pairs = useMemo(() => pairSplitRows(rows), [rows]);
|
|
1452
|
+
const displayedPairs = rowLimit ? pairs.slice(0, rowLimit) : pairs;
|
|
1453
|
+
// Reserve the marker column on a side only if any visible row there has one.
|
|
1454
|
+
const showOldMarkers = useMemo(
|
|
1455
|
+
() =>
|
|
1456
|
+
displayedPairs.some(
|
|
1457
|
+
(pair) => pair.left && markersForRow(pair.left, "old").length > 0,
|
|
1458
|
+
),
|
|
1459
|
+
[displayedPairs, markersForRow],
|
|
1460
|
+
);
|
|
1461
|
+
const showNewMarkers = useMemo(
|
|
1462
|
+
() =>
|
|
1463
|
+
displayedPairs.some(
|
|
1464
|
+
(pair) => pair.right && markersForRow(pair.right, "new").length > 0,
|
|
1465
|
+
),
|
|
1466
|
+
[displayedPairs, markersForRow],
|
|
1467
|
+
);
|
|
1468
|
+
const cellProps = {
|
|
1469
|
+
language,
|
|
1470
|
+
markersForRow,
|
|
1471
|
+
activeIndex,
|
|
1472
|
+
onRowEnter,
|
|
1473
|
+
onRowLeave,
|
|
1474
|
+
onRowClick,
|
|
1475
|
+
showAnnotationOverlays,
|
|
1476
|
+
annotationOverlayMode,
|
|
1477
|
+
annotationOverlaySide,
|
|
1478
|
+
annotationOverlayPreferredSide,
|
|
1479
|
+
annotationOverlayContainerRef,
|
|
1480
|
+
captureOverlayAnnotationIndex,
|
|
1481
|
+
persistentAnnotationIndexes,
|
|
1482
|
+
ctx,
|
|
1483
|
+
};
|
|
1484
|
+
return (
|
|
1485
|
+
<div
|
|
1486
|
+
className="flex w-full bg-background font-mono [font-size:var(--plan-doc-code-size)] leading-5"
|
|
1487
|
+
data-code-surface
|
|
1488
|
+
>
|
|
1489
|
+
<div className="min-w-0 flex-1 overflow-x-auto border-r border-border">
|
|
1490
|
+
<div className="inline-block min-w-full">
|
|
1491
|
+
{displayedPairs.map((pair, idx) => (
|
|
1492
|
+
<SplitCell
|
|
1493
|
+
key={`old-${idx}`}
|
|
1494
|
+
row={pair.left}
|
|
1495
|
+
side="old"
|
|
1496
|
+
showMarkerColumn={showOldMarkers}
|
|
1497
|
+
{...cellProps}
|
|
1498
|
+
/>
|
|
1499
|
+
))}
|
|
1500
|
+
</div>
|
|
1501
|
+
</div>
|
|
1502
|
+
<div className="min-w-0 flex-1 overflow-x-auto">
|
|
1503
|
+
<div className="inline-block min-w-full">
|
|
1504
|
+
{displayedPairs.map((pair, idx) => (
|
|
1505
|
+
<SplitCell
|
|
1506
|
+
key={`new-${idx}`}
|
|
1507
|
+
row={pair.right}
|
|
1508
|
+
side="new"
|
|
1509
|
+
showMarkerColumn={showNewMarkers}
|
|
1510
|
+
{...cellProps}
|
|
1511
|
+
/>
|
|
1512
|
+
))}
|
|
1513
|
+
</div>
|
|
1514
|
+
</div>
|
|
1515
|
+
</div>
|
|
1516
|
+
);
|
|
1517
|
+
}
|
|
1518
|
+
|
|
1519
|
+
function SplitCell({
|
|
1520
|
+
language,
|
|
1521
|
+
row,
|
|
1522
|
+
side,
|
|
1523
|
+
markersForRow,
|
|
1524
|
+
activeIndex,
|
|
1525
|
+
onRowEnter,
|
|
1526
|
+
onRowLeave,
|
|
1527
|
+
onRowClick,
|
|
1528
|
+
showMarkerColumn,
|
|
1529
|
+
showAnnotationOverlays,
|
|
1530
|
+
annotationOverlayMode,
|
|
1531
|
+
annotationOverlaySide,
|
|
1532
|
+
annotationOverlayPreferredSide,
|
|
1533
|
+
annotationOverlayContainerRef,
|
|
1534
|
+
captureOverlayAnnotationIndex,
|
|
1535
|
+
persistentAnnotationIndexes,
|
|
1536
|
+
ctx,
|
|
1537
|
+
}: {
|
|
1538
|
+
language: string;
|
|
1539
|
+
row?: DiffRow;
|
|
1540
|
+
side: RowSide;
|
|
1541
|
+
markersForRow: MarkersForRow;
|
|
1542
|
+
activeIndex: number | null;
|
|
1543
|
+
onRowEnter: (index: number, rowEl: HTMLElement) => void;
|
|
1544
|
+
onRowLeave: () => void;
|
|
1545
|
+
onRowClick: (index: number, rowEl: HTMLElement) => void;
|
|
1546
|
+
showMarkerColumn: boolean;
|
|
1547
|
+
showAnnotationOverlays: boolean;
|
|
1548
|
+
annotationOverlayMode: "capture" | "margin";
|
|
1549
|
+
annotationOverlaySide: AnnotationMarginSide;
|
|
1550
|
+
annotationOverlayPreferredSide: AnnotationSide;
|
|
1551
|
+
annotationOverlayContainerRef: RefObject<HTMLElement | null>;
|
|
1552
|
+
captureOverlayAnnotationIndex: number | null;
|
|
1553
|
+
persistentAnnotationIndexes: ReadonlySet<number>;
|
|
1554
|
+
ctx: BlockRenderContext;
|
|
1555
|
+
}) {
|
|
1556
|
+
if (!row) {
|
|
1557
|
+
return (
|
|
1558
|
+
<div className="flex min-h-5 min-w-full bg-muted/40 opacity-70">
|
|
1559
|
+
<span className={cn(LINE_NO_CLASS, "w-[52px]")} />
|
|
1560
|
+
<span className="w-6 shrink-0 bg-muted/60" />
|
|
1561
|
+
{showMarkerColumn && <span className="w-6 shrink-0" />}
|
|
1562
|
+
<span className={DIFF_LINE_CLASS}> </span>
|
|
1563
|
+
</div>
|
|
1564
|
+
);
|
|
1565
|
+
}
|
|
1566
|
+
const sign = side === "old" ? "−" : "+";
|
|
1567
|
+
const showSign = row.kind !== "context";
|
|
1568
|
+
const markers = markersForRow(row, side);
|
|
1569
|
+
const info = rowMarkerInfo(markers, activeIndex);
|
|
1570
|
+
const startMarker = markers.find((marker) => isMarkerRangeStart(row, marker));
|
|
1571
|
+
const primaryIndex = startMarker?.index ?? info?.primaryIndex;
|
|
1572
|
+
const overlayItems =
|
|
1573
|
+
showAnnotationOverlays &&
|
|
1574
|
+
startMarker &&
|
|
1575
|
+
(annotationOverlayMode === "capture"
|
|
1576
|
+
? startMarker.index === captureOverlayAnnotationIndex
|
|
1577
|
+
: persistentAnnotationIndexes.has(startMarker.index))
|
|
1578
|
+
? [startMarker]
|
|
1579
|
+
: [];
|
|
1580
|
+
const rowHasPersistentAnnotation = markers.some((marker) =>
|
|
1581
|
+
persistentAnnotationIndexes.has(marker.index),
|
|
1582
|
+
);
|
|
1583
|
+
return (
|
|
1584
|
+
<div
|
|
1585
|
+
data-annot-row={startMarker ? startMarker.index : undefined}
|
|
1586
|
+
tabIndex={info ? 0 : undefined}
|
|
1587
|
+
role={info ? "button" : undefined}
|
|
1588
|
+
aria-expanded={info ? info.isActive : undefined}
|
|
1589
|
+
className={cn(
|
|
1590
|
+
"relative flex min-h-5 min-w-full",
|
|
1591
|
+
info && "cursor-pointer",
|
|
1592
|
+
ROW_BG[row.kind],
|
|
1593
|
+
annotatedRowBg(info, rowHasPersistentAnnotation),
|
|
1594
|
+
)}
|
|
1595
|
+
onMouseEnter={
|
|
1596
|
+
info && primaryIndex != null
|
|
1597
|
+
? (event) => onRowEnter(primaryIndex, event.currentTarget)
|
|
1598
|
+
: undefined
|
|
1599
|
+
}
|
|
1600
|
+
onMouseLeave={info ? () => onRowLeave() : undefined}
|
|
1601
|
+
onClick={
|
|
1602
|
+
info && primaryIndex != null
|
|
1603
|
+
? (event) => onRowClick(primaryIndex, event.currentTarget)
|
|
1604
|
+
: undefined
|
|
1605
|
+
}
|
|
1606
|
+
onKeyDown={
|
|
1607
|
+
info && primaryIndex != null
|
|
1608
|
+
? (event) => {
|
|
1609
|
+
if (event.key !== "Enter" && event.key !== " ") return;
|
|
1610
|
+
event.preventDefault();
|
|
1611
|
+
onRowClick(primaryIndex, event.currentTarget);
|
|
1612
|
+
}
|
|
1613
|
+
: undefined
|
|
1614
|
+
}
|
|
1615
|
+
onFocus={
|
|
1616
|
+
info && primaryIndex != null
|
|
1617
|
+
? (event) => onRowEnter(primaryIndex, event.currentTarget)
|
|
1618
|
+
: undefined
|
|
1619
|
+
}
|
|
1620
|
+
onBlur={info ? () => onRowLeave() : undefined}
|
|
1621
|
+
>
|
|
1622
|
+
<span className={cn(LINE_NO_CLASS, "w-[52px]")}>
|
|
1623
|
+
{side === "old" ? (row.oldNo ?? "") : (row.newNo ?? "")}
|
|
1624
|
+
</span>
|
|
1625
|
+
<span
|
|
1626
|
+
className={cn(
|
|
1627
|
+
"w-6 shrink-0 select-none py-0 text-center font-semibold leading-5",
|
|
1628
|
+
GUTTER_BG[row.kind],
|
|
1629
|
+
SIGN_COLOR[row.kind],
|
|
1630
|
+
)}
|
|
1631
|
+
>
|
|
1632
|
+
{showSign ? sign : " "}
|
|
1633
|
+
</span>
|
|
1634
|
+
{showMarkerColumn && (
|
|
1635
|
+
<MarkerCell
|
|
1636
|
+
startMarker={startMarker}
|
|
1637
|
+
active={
|
|
1638
|
+
startMarker != null &&
|
|
1639
|
+
(startMarker.index === activeIndex ||
|
|
1640
|
+
persistentAnnotationIndexes.has(startMarker.index))
|
|
1641
|
+
}
|
|
1642
|
+
/>
|
|
1643
|
+
)}
|
|
1644
|
+
<DiffLineText text={row.text} language={language} />
|
|
1645
|
+
{overlayItems.length > 0 && (
|
|
1646
|
+
<AnnotationInlineOverlayStack
|
|
1647
|
+
items={overlayItems}
|
|
1648
|
+
ctx={ctx}
|
|
1649
|
+
showMarker
|
|
1650
|
+
containerRef={annotationOverlayContainerRef}
|
|
1651
|
+
mode={annotationOverlayMode}
|
|
1652
|
+
side={annotationOverlaySide}
|
|
1653
|
+
preferredSide={annotationOverlayPreferredSide}
|
|
1654
|
+
/>
|
|
1655
|
+
)}
|
|
1656
|
+
</div>
|
|
1657
|
+
);
|
|
1658
|
+
}
|
|
1659
|
+
|
|
1660
|
+
/* ── Edit (panel) ──────────────────────────────────────────────────────────── */
|
|
1661
|
+
|
|
1662
|
+
const codeAreaClass =
|
|
1663
|
+
"min-h-[140px] font-mono [font-size:var(--plan-code-size)] leading-5";
|
|
1664
|
+
|
|
1665
|
+
function DiffEdit({ data, onChange, editable }: BlockEditProps<DiffData>) {
|
|
1666
|
+
const patch = (next: Partial<DiffData>) => onChange({ ...data, ...next });
|
|
1667
|
+
const mode: DiffMode = data.mode ?? "split";
|
|
1668
|
+
const annotations = data.annotations ?? [];
|
|
1669
|
+
|
|
1670
|
+
const updateAnnotation = (index: number, next: Partial<DiffAnnotation>) =>
|
|
1671
|
+
patch({
|
|
1672
|
+
annotations: annotations.map((annotation, i) =>
|
|
1673
|
+
i === index ? { ...annotation, ...next } : annotation,
|
|
1674
|
+
),
|
|
1675
|
+
});
|
|
1676
|
+
|
|
1677
|
+
const removeAnnotation = (index: number) =>
|
|
1678
|
+
patch({ annotations: annotations.filter((_, i) => i !== index) });
|
|
1679
|
+
|
|
1680
|
+
const addAnnotation = () => {
|
|
1681
|
+
if (annotations.length >= 80) return; // schema max
|
|
1682
|
+
patch({
|
|
1683
|
+
annotations: [
|
|
1684
|
+
...annotations,
|
|
1685
|
+
{ side: "after", lines: "1", label: "", note: "" },
|
|
1686
|
+
],
|
|
1687
|
+
});
|
|
1688
|
+
};
|
|
1689
|
+
|
|
1690
|
+
return (
|
|
1691
|
+
<div className="flex flex-col gap-3" data-plan-interactive>
|
|
1692
|
+
<div className="grid gap-3 sm:grid-cols-2">
|
|
1693
|
+
<div className="flex flex-col gap-1.5">
|
|
1694
|
+
<DevLabel htmlFor="diff-filename" className="text-xs">
|
|
1695
|
+
Filename
|
|
1696
|
+
</DevLabel>
|
|
1697
|
+
<DevInput
|
|
1698
|
+
id="diff-filename"
|
|
1699
|
+
value={data.filename ?? ""}
|
|
1700
|
+
placeholder="src/add.ts"
|
|
1701
|
+
disabled={!editable}
|
|
1702
|
+
onChange={(event) =>
|
|
1703
|
+
patch({ filename: event.target.value || undefined })
|
|
1704
|
+
}
|
|
1705
|
+
/>
|
|
1706
|
+
</div>
|
|
1707
|
+
<div className="flex flex-col gap-1.5">
|
|
1708
|
+
<DevLabel htmlFor="diff-language" className="text-xs">
|
|
1709
|
+
Language
|
|
1710
|
+
</DevLabel>
|
|
1711
|
+
<DevInput
|
|
1712
|
+
id="diff-language"
|
|
1713
|
+
value={data.language ?? ""}
|
|
1714
|
+
placeholder="ts"
|
|
1715
|
+
disabled={!editable}
|
|
1716
|
+
onChange={(event) =>
|
|
1717
|
+
patch({ language: event.target.value || undefined })
|
|
1718
|
+
}
|
|
1719
|
+
/>
|
|
1720
|
+
</div>
|
|
1721
|
+
</div>
|
|
1722
|
+
|
|
1723
|
+
<div className="flex flex-col gap-1.5">
|
|
1724
|
+
<DevLabel className="text-xs">Layout</DevLabel>
|
|
1725
|
+
<DevSelect
|
|
1726
|
+
value={mode}
|
|
1727
|
+
disabled={!editable}
|
|
1728
|
+
onValueChange={(value) => patch({ mode: value as DiffMode })}
|
|
1729
|
+
options={[
|
|
1730
|
+
{ value: "unified", label: "Unified" },
|
|
1731
|
+
{ value: "split", label: "Split (side-by-side)" },
|
|
1732
|
+
]}
|
|
1733
|
+
/>
|
|
1734
|
+
</div>
|
|
1735
|
+
|
|
1736
|
+
<div className="flex flex-col gap-1.5">
|
|
1737
|
+
<DevLabel htmlFor="diff-before" className="text-xs">
|
|
1738
|
+
Before
|
|
1739
|
+
</DevLabel>
|
|
1740
|
+
<DevTextarea
|
|
1741
|
+
id="diff-before"
|
|
1742
|
+
spellCheck={false}
|
|
1743
|
+
className={codeAreaClass}
|
|
1744
|
+
value={data.before}
|
|
1745
|
+
disabled={!editable}
|
|
1746
|
+
onChange={(event) => patch({ before: event.target.value })}
|
|
1747
|
+
/>
|
|
1748
|
+
</div>
|
|
1749
|
+
|
|
1750
|
+
<div className="flex flex-col gap-1.5">
|
|
1751
|
+
<DevLabel htmlFor="diff-after" className="text-xs">
|
|
1752
|
+
After
|
|
1753
|
+
</DevLabel>
|
|
1754
|
+
<DevTextarea
|
|
1755
|
+
id="diff-after"
|
|
1756
|
+
spellCheck={false}
|
|
1757
|
+
className={codeAreaClass}
|
|
1758
|
+
value={data.after}
|
|
1759
|
+
disabled={!editable}
|
|
1760
|
+
onChange={(event) => patch({ after: event.target.value })}
|
|
1761
|
+
/>
|
|
1762
|
+
</div>
|
|
1763
|
+
|
|
1764
|
+
<div className="flex flex-col gap-2">
|
|
1765
|
+
<div className="flex items-center justify-between">
|
|
1766
|
+
<DevLabel className="text-xs">Annotations</DevLabel>
|
|
1767
|
+
{editable && annotations.length < 80 && (
|
|
1768
|
+
<button
|
|
1769
|
+
type="button"
|
|
1770
|
+
data-plan-interactive
|
|
1771
|
+
onClick={addAnnotation}
|
|
1772
|
+
className="flex cursor-pointer items-center gap-1 rounded-md px-2 py-1 text-xs font-medium text-plan-muted transition-colors hover:bg-plan-block/60 hover:text-plan-text"
|
|
1773
|
+
>
|
|
1774
|
+
<IconPlus className="size-3.5" />
|
|
1775
|
+
Add annotation
|
|
1776
|
+
</button>
|
|
1777
|
+
)}
|
|
1778
|
+
</div>
|
|
1779
|
+
{annotations.length === 0 && (
|
|
1780
|
+
<p className="text-xs text-plan-muted">
|
|
1781
|
+
No annotations yet. Add one to anchor a note to a line range on the
|
|
1782
|
+
before or after side.
|
|
1783
|
+
</p>
|
|
1784
|
+
)}
|
|
1785
|
+
{annotations.map((annotation, index) => (
|
|
1786
|
+
<div
|
|
1787
|
+
key={index}
|
|
1788
|
+
className="flex flex-col gap-2 rounded-md border border-plan-line bg-plan-block/30 p-2"
|
|
1789
|
+
>
|
|
1790
|
+
<div className="grid gap-2 sm:grid-cols-[110px_110px_minmax(0,1fr)_auto]">
|
|
1791
|
+
<DevSelect
|
|
1792
|
+
aria-label={`Annotation ${index + 1} side`}
|
|
1793
|
+
value={annotation.side ?? "after"}
|
|
1794
|
+
disabled={!editable}
|
|
1795
|
+
onValueChange={(value) =>
|
|
1796
|
+
updateAnnotation(index, {
|
|
1797
|
+
side: value as DiffAnnotation["side"],
|
|
1798
|
+
})
|
|
1799
|
+
}
|
|
1800
|
+
options={[
|
|
1801
|
+
{ value: "after", label: "After" },
|
|
1802
|
+
{ value: "before", label: "Before" },
|
|
1803
|
+
]}
|
|
1804
|
+
/>
|
|
1805
|
+
<DevInput
|
|
1806
|
+
aria-label={`Annotation ${index + 1} lines`}
|
|
1807
|
+
value={annotation.lines}
|
|
1808
|
+
placeholder="3-5"
|
|
1809
|
+
disabled={!editable}
|
|
1810
|
+
onChange={(event) =>
|
|
1811
|
+
updateAnnotation(index, { lines: event.target.value })
|
|
1812
|
+
}
|
|
1813
|
+
/>
|
|
1814
|
+
<DevInput
|
|
1815
|
+
aria-label={`Annotation ${index + 1} label`}
|
|
1816
|
+
value={annotation.label ?? ""}
|
|
1817
|
+
placeholder="Label (optional)"
|
|
1818
|
+
disabled={!editable}
|
|
1819
|
+
onChange={(event) =>
|
|
1820
|
+
updateAnnotation(index, {
|
|
1821
|
+
label: event.target.value || undefined,
|
|
1822
|
+
})
|
|
1823
|
+
}
|
|
1824
|
+
/>
|
|
1825
|
+
{editable && (
|
|
1826
|
+
<button
|
|
1827
|
+
type="button"
|
|
1828
|
+
data-plan-interactive
|
|
1829
|
+
aria-label={`Remove annotation ${index + 1}`}
|
|
1830
|
+
onClick={() => removeAnnotation(index)}
|
|
1831
|
+
className="flex size-9 shrink-0 cursor-pointer items-center justify-center rounded-md text-plan-muted transition-colors hover:bg-muted hover:text-foreground"
|
|
1832
|
+
>
|
|
1833
|
+
<IconTrash className="size-4" />
|
|
1834
|
+
</button>
|
|
1835
|
+
)}
|
|
1836
|
+
</div>
|
|
1837
|
+
<DevTextarea
|
|
1838
|
+
aria-label={`Annotation ${index + 1} note`}
|
|
1839
|
+
className="min-h-[60px] text-sm"
|
|
1840
|
+
value={annotation.note}
|
|
1841
|
+
placeholder="Explain what these lines do…"
|
|
1842
|
+
disabled={!editable}
|
|
1843
|
+
onChange={(event) =>
|
|
1844
|
+
updateAnnotation(index, { note: event.target.value })
|
|
1845
|
+
}
|
|
1846
|
+
/>
|
|
1847
|
+
</div>
|
|
1848
|
+
))}
|
|
1849
|
+
</div>
|
|
1850
|
+
</div>
|
|
1851
|
+
);
|
|
1852
|
+
}
|
|
1853
|
+
|
|
1854
|
+
export { DiffRead, DiffEdit };
|