@agent-native/core 0.37.3 → 0.38.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +19 -6
- package/dist/action.d.ts +60 -2
- package/dist/action.d.ts.map +1 -1
- package/dist/action.js +6 -2
- package/dist/action.js.map +1 -1
- package/dist/agent/production-agent.d.ts +12 -6
- package/dist/agent/production-agent.d.ts.map +1 -1
- package/dist/agent/production-agent.js +161 -11
- package/dist/agent/production-agent.js.map +1 -1
- package/dist/agent/types.d.ts +2 -0
- package/dist/agent/types.d.ts.map +1 -1
- package/dist/agent/types.js.map +1 -1
- package/dist/catalog.json +2 -2
- package/dist/cli/connect.d.ts.map +1 -1
- package/dist/cli/connect.js +15 -0
- package/dist/cli/connect.js.map +1 -1
- package/dist/cli/index.js +10 -6
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/plan-publish-store.d.ts +52 -0
- package/dist/cli/plan-publish-store.d.ts.map +1 -0
- package/dist/cli/plan-publish-store.js +103 -0
- package/dist/cli/plan-publish-store.js.map +1 -0
- package/dist/cli/skills.d.ts +29 -4
- package/dist/cli/skills.d.ts.map +1 -1
- package/dist/cli/skills.js +851 -275
- package/dist/cli/skills.js.map +1 -1
- package/dist/cli/templates-meta.js +12 -12
- package/dist/cli/templates-meta.js.map +1 -1
- package/dist/client/AssistantChat.d.ts +3 -1
- package/dist/client/AssistantChat.d.ts.map +1 -1
- package/dist/client/AssistantChat.js +65 -15
- package/dist/client/AssistantChat.js.map +1 -1
- package/dist/client/MultiTabAssistantChat.d.ts.map +1 -1
- package/dist/client/MultiTabAssistantChat.js +20 -2
- package/dist/client/MultiTabAssistantChat.js.map +1 -1
- package/dist/client/agent-chat-adapter.d.ts.map +1 -1
- package/dist/client/agent-chat-adapter.js +12 -0
- package/dist/client/agent-chat-adapter.js.map +1 -1
- package/dist/client/agent-engine-key.d.ts +24 -0
- package/dist/client/agent-engine-key.d.ts.map +1 -0
- package/dist/client/agent-engine-key.js +49 -0
- package/dist/client/agent-engine-key.js.map +1 -0
- package/dist/client/analytics.d.ts.map +1 -1
- package/dist/client/analytics.js +34 -0
- package/dist/client/analytics.js.map +1 -1
- package/dist/client/blocks/BlockView.d.ts +26 -0
- package/dist/client/blocks/BlockView.d.ts.map +1 -0
- package/dist/client/blocks/BlockView.js +24 -0
- package/dist/client/blocks/BlockView.js.map +1 -0
- package/dist/client/blocks/SchemaBlockEditor.d.ts +25 -0
- package/dist/client/blocks/SchemaBlockEditor.d.ts.map +1 -0
- package/dist/client/blocks/SchemaBlockEditor.js +72 -0
- package/dist/client/blocks/SchemaBlockEditor.js.map +1 -0
- package/dist/client/blocks/agent.d.ts +30 -0
- package/dist/client/blocks/agent.d.ts.map +1 -0
- package/dist/client/blocks/agent.js +61 -0
- package/dist/client/blocks/agent.js.map +1 -0
- package/dist/client/blocks/index.d.ts +34 -0
- package/dist/client/blocks/index.d.ts.map +1 -0
- package/dist/client/blocks/index.js +42 -0
- package/dist/client/blocks/index.js.map +1 -0
- package/dist/client/blocks/library/checklist.config.d.ts +36 -0
- package/dist/client/blocks/library/checklist.config.d.ts.map +1 -0
- package/dist/client/blocks/library/checklist.config.js +25 -0
- package/dist/client/blocks/library/checklist.config.js.map +1 -0
- package/dist/client/blocks/library/checklist.d.ts +26 -0
- package/dist/client/blocks/library/checklist.d.ts.map +1 -0
- package/dist/client/blocks/library/checklist.js +76 -0
- package/dist/client/blocks/library/checklist.js.map +1 -0
- package/dist/client/blocks/library/code-tabs.config.d.ts +36 -0
- package/dist/client/blocks/library/code-tabs.config.d.ts.map +1 -0
- package/dist/client/blocks/library/code-tabs.config.js +30 -0
- package/dist/client/blocks/library/code-tabs.config.js.map +1 -0
- package/dist/client/blocks/library/code-tabs.d.ts +3 -0
- package/dist/client/blocks/library/code-tabs.d.ts.map +1 -0
- package/dist/client/blocks/library/code-tabs.js +165 -0
- package/dist/client/blocks/library/code-tabs.js.map +1 -0
- package/dist/client/blocks/library/html.config.d.ts +37 -0
- package/dist/client/blocks/library/html.config.d.ts.map +1 -0
- package/dist/client/blocks/library/html.config.js +46 -0
- package/dist/client/blocks/library/html.config.js.map +1 -0
- package/dist/client/blocks/library/html.d.ts +21 -0
- package/dist/client/blocks/library/html.d.ts.map +1 -0
- package/dist/client/blocks/library/html.js +69 -0
- package/dist/client/blocks/library/html.js.map +1 -0
- package/dist/client/blocks/library/table.config.d.ts +30 -0
- package/dist/client/blocks/library/table.config.d.ts.map +1 -0
- package/dist/client/blocks/library/table.config.js +22 -0
- package/dist/client/blocks/library/table.config.js.map +1 -0
- package/dist/client/blocks/library/table.d.ts +8 -0
- package/dist/client/blocks/library/table.d.ts.map +1 -0
- package/dist/client/blocks/library/table.js +107 -0
- package/dist/client/blocks/library/table.js.map +1 -0
- package/dist/client/blocks/library/tabs.config.d.ts +56 -0
- package/dist/client/blocks/library/tabs.config.d.ts.map +1 -0
- package/dist/client/blocks/library/tabs.config.js +36 -0
- package/dist/client/blocks/library/tabs.config.js.map +1 -0
- package/dist/client/blocks/library/tabs.d.ts +20 -0
- package/dist/client/blocks/library/tabs.d.ts.map +1 -0
- package/dist/client/blocks/library/tabs.js +123 -0
- package/dist/client/blocks/library/tabs.js.map +1 -0
- package/dist/client/blocks/mdx.d.ts +74 -0
- package/dist/client/blocks/mdx.d.ts.map +1 -0
- package/dist/client/blocks/mdx.js +205 -0
- package/dist/client/blocks/mdx.js.map +1 -0
- package/dist/client/blocks/provider.d.ts +25 -0
- package/dist/client/blocks/provider.d.ts.map +1 -0
- package/dist/client/blocks/provider.js +19 -0
- package/dist/client/blocks/provider.js.map +1 -0
- package/dist/client/blocks/registry.d.ts +24 -0
- package/dist/client/blocks/registry.d.ts.map +1 -0
- package/dist/client/blocks/registry.js +50 -0
- package/dist/client/blocks/registry.js.map +1 -0
- package/dist/client/blocks/schema-form/introspect.d.ts +31 -0
- package/dist/client/blocks/schema-form/introspect.d.ts.map +1 -0
- package/dist/client/blocks/schema-form/introspect.js +164 -0
- package/dist/client/blocks/schema-form/introspect.js.map +1 -0
- package/dist/client/blocks/server.d.ts +22 -0
- package/dist/client/blocks/server.d.ts.map +1 -0
- package/dist/client/blocks/server.js +25 -0
- package/dist/client/blocks/server.js.map +1 -0
- package/dist/client/blocks/types.d.ts +212 -0
- package/dist/client/blocks/types.d.ts.map +1 -0
- package/dist/client/blocks/types.js +5 -0
- package/dist/client/blocks/types.js.map +1 -0
- package/dist/client/composer/ComposerPlusMenu.js +10 -1
- package/dist/client/composer/ComposerPlusMenu.js.map +1 -1
- package/dist/client/guided-questions.d.ts +68 -0
- package/dist/client/guided-questions.d.ts.map +1 -1
- package/dist/client/guided-questions.js +158 -3
- package/dist/client/guided-questions.js.map +1 -1
- package/dist/client/index.d.ts +5 -1
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +15 -1
- package/dist/client/index.js.map +1 -1
- package/dist/client/rich-markdown-editor/BubbleToolbar.d.ts +37 -0
- package/dist/client/rich-markdown-editor/BubbleToolbar.d.ts.map +1 -0
- package/dist/client/rich-markdown-editor/BubbleToolbar.js +161 -0
- package/dist/client/rich-markdown-editor/BubbleToolbar.js.map +1 -0
- package/dist/client/rich-markdown-editor/ImageExtension.d.ts +63 -0
- package/dist/client/rich-markdown-editor/ImageExtension.d.ts.map +1 -0
- package/dist/client/rich-markdown-editor/ImageExtension.js +242 -0
- package/dist/client/rich-markdown-editor/ImageExtension.js.map +1 -0
- package/dist/client/rich-markdown-editor/RichMarkdownEditor.d.ts +51 -0
- package/dist/client/rich-markdown-editor/RichMarkdownEditor.d.ts.map +1 -0
- package/dist/client/rich-markdown-editor/RichMarkdownEditor.js +37 -0
- package/dist/client/rich-markdown-editor/RichMarkdownEditor.js.map +1 -0
- package/dist/client/rich-markdown-editor/SharedRichEditor.d.ts +61 -0
- package/dist/client/rich-markdown-editor/SharedRichEditor.d.ts.map +1 -0
- package/dist/client/rich-markdown-editor/SharedRichEditor.js +121 -0
- package/dist/client/rich-markdown-editor/SharedRichEditor.js.map +1 -0
- package/dist/client/rich-markdown-editor/SlashCommandMenu.d.ts +36 -0
- package/dist/client/rich-markdown-editor/SlashCommandMenu.d.ts.map +1 -0
- package/dist/client/rich-markdown-editor/SlashCommandMenu.js +193 -0
- package/dist/client/rich-markdown-editor/SlashCommandMenu.js.map +1 -0
- package/dist/client/rich-markdown-editor/extensions.d.ts +166 -0
- package/dist/client/rich-markdown-editor/extensions.d.ts.map +1 -0
- package/dist/client/rich-markdown-editor/extensions.js +222 -0
- package/dist/client/rich-markdown-editor/extensions.js.map +1 -0
- package/dist/client/rich-markdown-editor/index.d.ts +9 -0
- package/dist/client/rich-markdown-editor/index.d.ts.map +1 -0
- package/dist/client/rich-markdown-editor/index.js +9 -0
- package/dist/client/rich-markdown-editor/index.js.map +1 -0
- package/dist/client/rich-markdown-editor/uploadEditorImage.d.ts +18 -0
- package/dist/client/rich-markdown-editor/uploadEditorImage.d.ts.map +1 -0
- package/dist/client/rich-markdown-editor/uploadEditorImage.js +57 -0
- package/dist/client/rich-markdown-editor/uploadEditorImage.js.map +1 -0
- package/dist/client/rich-markdown-editor/useCollabReconcile.d.ts +91 -0
- package/dist/client/rich-markdown-editor/useCollabReconcile.d.ts.map +1 -0
- package/dist/client/rich-markdown-editor/useCollabReconcile.js +342 -0
- package/dist/client/rich-markdown-editor/useCollabReconcile.js.map +1 -0
- package/dist/client/track.d.ts +25 -0
- package/dist/client/track.d.ts.map +1 -0
- package/dist/client/track.js +53 -0
- package/dist/client/track.js.map +1 -0
- package/dist/client/use-action.d.ts.map +1 -1
- package/dist/client/use-action.js +6 -0
- package/dist/client/use-action.js.map +1 -1
- package/dist/client/use-session.d.ts +3 -2
- package/dist/client/use-session.d.ts.map +1 -1
- package/dist/client/use-session.js +3 -2
- package/dist/client/use-session.js.map +1 -1
- package/dist/deploy/build.d.ts +5 -0
- package/dist/deploy/build.d.ts.map +1 -1
- package/dist/deploy/build.js +67 -1
- package/dist/deploy/build.js.map +1 -1
- package/dist/extensions/schema.d.ts +1 -1
- package/dist/mcp/build-server.d.ts.map +1 -1
- package/dist/mcp/build-server.js +9 -2
- package/dist/mcp/build-server.js.map +1 -1
- package/dist/mcp/server.d.ts +1 -1
- package/dist/mcp/server.d.ts.map +1 -1
- package/dist/mcp/server.js +35 -2
- package/dist/mcp/server.js.map +1 -1
- package/dist/provider-api/index.d.ts +1 -1
- package/dist/provider-api/index.d.ts.map +1 -1
- package/dist/scripts/docs/search.d.ts.map +1 -1
- package/dist/scripts/docs/search.js +5 -2
- package/dist/scripts/docs/search.js.map +1 -1
- package/dist/scripts/runner.d.ts.map +1 -1
- package/dist/scripts/runner.js +16 -3
- package/dist/scripts/runner.js.map +1 -1
- package/dist/server/action-discovery.d.ts.map +1 -1
- package/dist/server/action-discovery.js +2 -0
- package/dist/server/action-discovery.js.map +1 -1
- package/dist/server/action-routes.d.ts.map +1 -1
- package/dist/server/action-routes.js +30 -4
- package/dist/server/action-routes.js.map +1 -1
- package/dist/server/agent-chat-plugin.d.ts.map +1 -1
- package/dist/server/agent-chat-plugin.js +65 -19
- package/dist/server/agent-chat-plugin.js.map +1 -1
- package/dist/server/agent-teams.d.ts.map +1 -1
- package/dist/server/agent-teams.js +8 -1
- package/dist/server/agent-teams.js.map +1 -1
- package/dist/server/agents-bundle.d.ts +27 -1
- package/dist/server/agents-bundle.d.ts.map +1 -1
- package/dist/server/agents-bundle.js +41 -3
- package/dist/server/agents-bundle.js.map +1 -1
- package/dist/server/auth.d.ts.map +1 -1
- package/dist/server/auth.js +76 -3
- package/dist/server/auth.js.map +1 -1
- package/dist/server/core-routes-plugin.d.ts.map +1 -1
- package/dist/server/core-routes-plugin.js +60 -0
- package/dist/server/core-routes-plugin.js.map +1 -1
- package/dist/server/onboarding-html.d.ts.map +1 -1
- package/dist/server/onboarding-html.js +160 -22
- package/dist/server/onboarding-html.js.map +1 -1
- package/dist/server/sentry.d.ts.map +1 -1
- package/dist/server/sentry.js +6 -0
- package/dist/server/sentry.js.map +1 -1
- package/dist/server/social-og-image.d.ts +2 -1
- package/dist/server/social-og-image.d.ts.map +1 -1
- package/dist/server/social-og-image.js +24 -4
- package/dist/server/social-og-image.js.map +1 -1
- package/dist/sharing/schema.d.ts +1 -1
- package/dist/styles/agent-native.css +1 -0
- package/dist/styles/rich-markdown-editor.css +439 -0
- package/dist/templates/default/.agents/skills/actions/SKILL.md +4 -1
- package/dist/templates/default/.agents/skills/security/SKILL.md +13 -4
- package/dist/templates/default/.agents/skills/storing-data/SKILL.md +15 -3
- package/dist/templates/default/AGENTS.md +1 -0
- package/dist/templates/default/DEVELOPING.md +2 -0
- package/dist/templates/workspace-core/.agents/skills/a2a-protocol/SKILL.md +10 -3
- package/dist/templates/workspace-core/.agents/skills/actions/SKILL.md +98 -10
- package/dist/templates/workspace-core/.agents/skills/adding-a-feature/SKILL.md +45 -3
- package/dist/templates/workspace-core/.agents/skills/address-feedback/SKILL.md +2 -0
- package/dist/templates/workspace-core/.agents/skills/authentication/SKILL.md +37 -4
- package/dist/templates/workspace-core/.agents/skills/automations/SKILL.md +9 -4
- package/dist/templates/workspace-core/.agents/skills/capture-learnings/SKILL.md +2 -0
- package/dist/templates/workspace-core/.agents/skills/client-methods/SKILL.md +106 -0
- package/dist/templates/workspace-core/.agents/skills/client-methods/references/legacy-client-fetch-audit-2026-06-03.md +53 -0
- package/dist/templates/workspace-core/.agents/skills/client-side-routing/SKILL.md +2 -0
- package/dist/templates/workspace-core/.agents/skills/context-awareness/SKILL.md +62 -61
- package/dist/templates/workspace-core/.agents/skills/context-xray/SKILL.md +47 -0
- package/dist/templates/workspace-core/.agents/skills/create-skill/SKILL.md +28 -0
- package/dist/templates/workspace-core/.agents/skills/delegate-to-agent/SKILL.md +52 -1
- package/dist/templates/workspace-core/.agents/skills/extension-points/SKILL.md +2 -0
- package/dist/templates/workspace-core/.agents/skills/extensions/SKILL.md +95 -433
- package/dist/templates/workspace-core/.agents/skills/extensions/references/api.md +285 -0
- package/dist/templates/workspace-core/.agents/skills/extensions/references/examples.md +259 -0
- package/dist/templates/workspace-core/.agents/skills/external-agents/SKILL.md +398 -0
- package/dist/templates/workspace-core/.agents/skills/external-agents/references/mcp-apps-embedding.md +157 -0
- package/dist/templates/workspace-core/.agents/skills/frontend-design/SKILL.md +17 -0
- package/dist/templates/workspace-core/.agents/skills/integration-webhooks/SKILL.md +13 -2
- package/dist/templates/workspace-core/.agents/skills/mvp-followup/SKILL.md +51 -0
- package/dist/templates/workspace-core/.agents/skills/observability/SKILL.md +14 -4
- package/dist/templates/workspace-core/.agents/skills/onboarding/SKILL.md +13 -1
- package/dist/templates/workspace-core/.agents/skills/portability/SKILL.md +27 -5
- package/dist/templates/workspace-core/.agents/skills/qa/SKILL.md +24 -8
- package/dist/templates/workspace-core/.agents/skills/real-time-collab/SKILL.md +53 -7
- package/dist/templates/workspace-core/.agents/skills/real-time-sync/SKILL.md +43 -10
- package/dist/templates/workspace-core/.agents/skills/recurring-jobs/SKILL.md +2 -0
- package/dist/templates/workspace-core/.agents/skills/secrets/SKILL.md +43 -14
- package/dist/templates/workspace-core/.agents/skills/security/SKILL.md +50 -1
- package/dist/templates/workspace-core/.agents/skills/self-modifying-code/SKILL.md +4 -2
- package/dist/templates/workspace-core/.agents/skills/server-plugins/SKILL.md +11 -1
- package/dist/templates/workspace-core/.agents/skills/shadcn-ui/SKILL.md +15 -0
- package/dist/templates/workspace-core/.agents/skills/sharing/SKILL.md +5 -1
- package/dist/templates/workspace-core/.agents/skills/storing-data/SKILL.md +48 -19
- package/dist/templates/workspace-core/.agents/skills/tracking/SKILL.md +7 -3
- package/dist/templates/workspace-core/.agents/skills/voice-transcription/SKILL.md +13 -6
- package/dist/templates/workspace-core/.agents/skills/writing-agent-instructions/SKILL.md +236 -0
- package/dist/templates/workspace-core/AGENTS.md +5 -1
- package/dist/templates/workspace-root/AGENTS.md +5 -2
- package/dist/tracking/route.d.ts +43 -0
- package/dist/tracking/route.d.ts.map +1 -0
- package/dist/tracking/route.js +85 -0
- package/dist/tracking/route.js.map +1 -0
- package/dist/vite/client.d.ts.map +1 -1
- package/dist/vite/client.js +15 -0
- package/dist/vite/client.js.map +1 -1
- package/docs/content/a2a-protocol.md +18 -4
- package/docs/content/actions.md +87 -0
- package/docs/content/agent-mentions.md +2 -1
- package/docs/content/authentication.md +2 -1
- package/docs/content/client.md +64 -13
- package/docs/content/cloneable-saas.md +1 -1
- package/docs/content/code-agents-ui.md +17 -11
- package/docs/content/context-awareness.md +23 -28
- package/docs/content/creating-templates.md +1 -1
- package/docs/content/drop-in-agent.md +2 -0
- package/docs/content/getting-started.md +2 -2
- package/docs/content/key-concepts.md +2 -2
- package/docs/content/messaging.md +57 -15
- package/docs/content/migration-workbench.md +1 -1
- package/docs/content/multi-app-workspace.md +1 -1
- package/docs/content/multi-tenancy.md +17 -15
- package/docs/content/real-time-collaboration.md +1 -1
- package/docs/content/recurring-jobs.md +1 -1
- package/docs/content/security.md +2 -2
- package/docs/content/server.md +4 -4
- package/docs/content/skills-guide.md +30 -0
- package/docs/content/template-analytics.md +2 -2
- package/docs/content/template-assets.md +17 -1
- package/docs/content/template-brain.md +2 -2
- package/docs/content/template-calendar.md +1 -1
- package/docs/content/template-clips.md +3 -3
- package/docs/content/template-content.md +2 -2
- package/docs/content/template-design.md +2 -2
- package/docs/content/template-dispatch.md +3 -3
- package/docs/content/template-forms.md +14 -2
- package/docs/content/template-mail.md +1 -3
- package/docs/content/template-plan.md +118 -0
- package/docs/content/template-slides.md +5 -4
- package/docs/content/template-starter.md +4 -4
- package/docs/content/template-videos.md +6 -11
- package/docs/content/tracking.md +21 -1
- package/docs/content/visual-plans.md +72 -0
- package/docs/content/workspace.md +9 -9
- package/package.json +26 -11
- package/src/templates/default/.agents/skills/actions/SKILL.md +4 -1
- package/src/templates/default/.agents/skills/security/SKILL.md +13 -4
- package/src/templates/default/.agents/skills/storing-data/SKILL.md +15 -3
- package/src/templates/default/AGENTS.md +1 -0
- package/src/templates/default/DEVELOPING.md +2 -0
- package/src/templates/workspace-core/.agents/skills/a2a-protocol/SKILL.md +10 -3
- package/src/templates/workspace-core/.agents/skills/actions/SKILL.md +98 -10
- package/src/templates/workspace-core/.agents/skills/adding-a-feature/SKILL.md +45 -3
- package/src/templates/workspace-core/.agents/skills/address-feedback/SKILL.md +2 -0
- package/src/templates/workspace-core/.agents/skills/authentication/SKILL.md +37 -4
- package/src/templates/workspace-core/.agents/skills/automations/SKILL.md +9 -4
- package/src/templates/workspace-core/.agents/skills/capture-learnings/SKILL.md +2 -0
- package/src/templates/workspace-core/.agents/skills/client-methods/SKILL.md +106 -0
- package/src/templates/workspace-core/.agents/skills/client-methods/references/legacy-client-fetch-audit-2026-06-03.md +53 -0
- package/src/templates/workspace-core/.agents/skills/client-side-routing/SKILL.md +2 -0
- package/src/templates/workspace-core/.agents/skills/context-awareness/SKILL.md +62 -61
- package/src/templates/workspace-core/.agents/skills/context-xray/SKILL.md +47 -0
- package/src/templates/workspace-core/.agents/skills/create-skill/SKILL.md +28 -0
- package/src/templates/workspace-core/.agents/skills/delegate-to-agent/SKILL.md +52 -1
- package/src/templates/workspace-core/.agents/skills/extension-points/SKILL.md +2 -0
- package/src/templates/workspace-core/.agents/skills/extensions/SKILL.md +95 -433
- package/src/templates/workspace-core/.agents/skills/extensions/references/api.md +285 -0
- package/src/templates/workspace-core/.agents/skills/extensions/references/examples.md +259 -0
- package/src/templates/workspace-core/.agents/skills/external-agents/SKILL.md +398 -0
- package/src/templates/workspace-core/.agents/skills/external-agents/references/mcp-apps-embedding.md +157 -0
- package/src/templates/workspace-core/.agents/skills/frontend-design/SKILL.md +17 -0
- package/src/templates/workspace-core/.agents/skills/integration-webhooks/SKILL.md +13 -2
- package/src/templates/workspace-core/.agents/skills/mvp-followup/SKILL.md +51 -0
- package/src/templates/workspace-core/.agents/skills/observability/SKILL.md +14 -4
- package/src/templates/workspace-core/.agents/skills/onboarding/SKILL.md +13 -1
- package/src/templates/workspace-core/.agents/skills/portability/SKILL.md +27 -5
- package/src/templates/workspace-core/.agents/skills/qa/SKILL.md +24 -8
- package/src/templates/workspace-core/.agents/skills/real-time-collab/SKILL.md +53 -7
- package/src/templates/workspace-core/.agents/skills/real-time-sync/SKILL.md +43 -10
- package/src/templates/workspace-core/.agents/skills/recurring-jobs/SKILL.md +2 -0
- package/src/templates/workspace-core/.agents/skills/secrets/SKILL.md +43 -14
- package/src/templates/workspace-core/.agents/skills/security/SKILL.md +50 -1
- package/src/templates/workspace-core/.agents/skills/self-modifying-code/SKILL.md +4 -2
- package/src/templates/workspace-core/.agents/skills/server-plugins/SKILL.md +11 -1
- package/src/templates/workspace-core/.agents/skills/shadcn-ui/SKILL.md +15 -0
- package/src/templates/workspace-core/.agents/skills/sharing/SKILL.md +5 -1
- package/src/templates/workspace-core/.agents/skills/storing-data/SKILL.md +48 -19
- package/src/templates/workspace-core/.agents/skills/tracking/SKILL.md +7 -3
- package/src/templates/workspace-core/.agents/skills/voice-transcription/SKILL.md +13 -6
- package/src/templates/workspace-core/.agents/skills/writing-agent-instructions/SKILL.md +236 -0
- package/src/templates/workspace-core/AGENTS.md +5 -1
- package/src/templates/workspace-root/AGENTS.md +5 -2
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Registry-driven MDX serialize/parse, plus the shared encoder primitives that
|
|
3
|
+
* are the round-trip contract. This module is React-free so the server MDX
|
|
4
|
+
* adapter (`plan-mdx.ts`) and the agent schema export can import it. The encoder
|
|
5
|
+
* + estree literal walker are kept BYTE-FOR-BYTE identical to the originals in
|
|
6
|
+
* `plan-mdx.ts` — `plan-mdx.ts` re-imports them so nothing else there changes
|
|
7
|
+
* and stored `.mdx` files round-trip the same.
|
|
8
|
+
*/
|
|
9
|
+
/* -------------------------------------------------------------------------- */
|
|
10
|
+
/* Serialize-side encoder primitives (moved verbatim from plan-mdx.ts) */
|
|
11
|
+
/* -------------------------------------------------------------------------- */
|
|
12
|
+
export function jsonExpression(value) {
|
|
13
|
+
return JSON.stringify(value, null, 2);
|
|
14
|
+
}
|
|
15
|
+
export function escapeAttr(value) {
|
|
16
|
+
return value
|
|
17
|
+
.replace(/&/g, "&")
|
|
18
|
+
.replace(/"/g, """)
|
|
19
|
+
.replace(/</g, "<")
|
|
20
|
+
.replace(/>/g, ">");
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Encode a single attribute. Returns "" (the attribute is dropped) for
|
|
24
|
+
* undefined/null; a bare/`={false}` flag for booleans; `={n}` for numbers; a
|
|
25
|
+
* quoted string when it matches the safe charset and is short, else a JSON
|
|
26
|
+
* expression. Objects/arrays always serialize as a JSON expression.
|
|
27
|
+
*/
|
|
28
|
+
export function prop(name, value) {
|
|
29
|
+
if (value === undefined || value === null)
|
|
30
|
+
return "";
|
|
31
|
+
if (typeof value === "boolean") {
|
|
32
|
+
return value ? ` ${name}` : ` ${name}={false}`;
|
|
33
|
+
}
|
|
34
|
+
if (typeof value === "number")
|
|
35
|
+
return ` ${name}={${value}}`;
|
|
36
|
+
if (typeof value === "string") {
|
|
37
|
+
if (/^[\w .:/@#,+()[\]-]+$/.test(value) && value.length < 140) {
|
|
38
|
+
return ` ${name}="${escapeAttr(value)}"`;
|
|
39
|
+
}
|
|
40
|
+
return ` ${name}={${jsonExpression(value)}}`;
|
|
41
|
+
}
|
|
42
|
+
return ` ${name}={${jsonExpression(value)}}`;
|
|
43
|
+
}
|
|
44
|
+
function findAttribute(node, name) {
|
|
45
|
+
return node.attributes?.find((attr) => attr.type === "mdxJsxAttribute" && attr.name === name);
|
|
46
|
+
}
|
|
47
|
+
export function attributeValue(attr) {
|
|
48
|
+
if (!attr)
|
|
49
|
+
return undefined;
|
|
50
|
+
if (attr.value === null || attr.value === undefined)
|
|
51
|
+
return true;
|
|
52
|
+
if (typeof attr.value === "string")
|
|
53
|
+
return attr.value;
|
|
54
|
+
const astValue = literalExpressionValue(attr.value);
|
|
55
|
+
if (astValue !== undefined)
|
|
56
|
+
return astValue;
|
|
57
|
+
const expression = attr.value.value.trim();
|
|
58
|
+
if (!expression)
|
|
59
|
+
return undefined;
|
|
60
|
+
if (expression === "undefined")
|
|
61
|
+
return undefined;
|
|
62
|
+
try {
|
|
63
|
+
return JSON.parse(expression);
|
|
64
|
+
}
|
|
65
|
+
catch {
|
|
66
|
+
throw new Error(`Unsupported MDX attribute expression for "${attr.name}": {${expression}}. Use literal values or valid JSON.`);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
function literalExpressionValue(expression) {
|
|
70
|
+
const estree = expression.data
|
|
71
|
+
?.estree;
|
|
72
|
+
const statement = estree?.body?.[0];
|
|
73
|
+
if (!statement || statement.type !== "ExpressionStatement")
|
|
74
|
+
return undefined;
|
|
75
|
+
return literalNodeValue(statement.expression);
|
|
76
|
+
}
|
|
77
|
+
function literalNodeValue(node) {
|
|
78
|
+
if (!node)
|
|
79
|
+
return undefined;
|
|
80
|
+
if (node.type === "Literal")
|
|
81
|
+
return node.value;
|
|
82
|
+
if (node.type === "ArrayExpression") {
|
|
83
|
+
return (node.elements ?? []).map((item) => literalNodeValue(item));
|
|
84
|
+
}
|
|
85
|
+
if (node.type === "ObjectExpression") {
|
|
86
|
+
const out = {};
|
|
87
|
+
for (const property of node.properties ?? []) {
|
|
88
|
+
if (property.type !== "Property" || property.computed)
|
|
89
|
+
return undefined;
|
|
90
|
+
const key = property.key;
|
|
91
|
+
const rawKey = key?.type === "Identifier"
|
|
92
|
+
? key.name
|
|
93
|
+
: key?.type === "Literal" && typeof key.value === "string"
|
|
94
|
+
? key.value
|
|
95
|
+
: undefined;
|
|
96
|
+
if (!rawKey)
|
|
97
|
+
return undefined;
|
|
98
|
+
const value = literalNodeValue(property.value);
|
|
99
|
+
if (value !== undefined)
|
|
100
|
+
out[rawKey] = value;
|
|
101
|
+
}
|
|
102
|
+
return out;
|
|
103
|
+
}
|
|
104
|
+
if (node.type === "UnaryExpression") {
|
|
105
|
+
const value = literalNodeValue(node.argument);
|
|
106
|
+
if (typeof value !== "number")
|
|
107
|
+
return undefined;
|
|
108
|
+
if (node.operator === "-")
|
|
109
|
+
return -value;
|
|
110
|
+
if (node.operator === "+")
|
|
111
|
+
return value;
|
|
112
|
+
}
|
|
113
|
+
if (node.type === "Identifier") {
|
|
114
|
+
if (node.name === "undefined")
|
|
115
|
+
return undefined;
|
|
116
|
+
if (node.name === "NaN")
|
|
117
|
+
return Number.NaN;
|
|
118
|
+
if (node.name === "Infinity")
|
|
119
|
+
return Infinity;
|
|
120
|
+
}
|
|
121
|
+
return undefined;
|
|
122
|
+
}
|
|
123
|
+
/** Build a {@link BlockAttrReader} bound to one parsed JSX node. */
|
|
124
|
+
export function createAttrReader(node) {
|
|
125
|
+
const read = (name) => attributeValue(findAttribute(node, name));
|
|
126
|
+
return {
|
|
127
|
+
raw: read,
|
|
128
|
+
string(name) {
|
|
129
|
+
const value = read(name);
|
|
130
|
+
return typeof value === "string" ? value : undefined;
|
|
131
|
+
},
|
|
132
|
+
number(name) {
|
|
133
|
+
const value = read(name);
|
|
134
|
+
return typeof value === "number" ? value : undefined;
|
|
135
|
+
},
|
|
136
|
+
bool(name) {
|
|
137
|
+
const value = read(name);
|
|
138
|
+
return typeof value === "boolean" ? value : undefined;
|
|
139
|
+
},
|
|
140
|
+
array(name) {
|
|
141
|
+
const value = read(name);
|
|
142
|
+
return Array.isArray(value) ? value : undefined;
|
|
143
|
+
},
|
|
144
|
+
object(name) {
|
|
145
|
+
const value = read(name);
|
|
146
|
+
return value && typeof value === "object" ? value : undefined;
|
|
147
|
+
},
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Serialize a block to its MDX element using its spec. Byte output MUST match
|
|
152
|
+
* the legacy `serializeBlock` for every converted block: base attrs
|
|
153
|
+
* (`id,title,summary,editable`) first, then the spec's `toAttrs` in insertion
|
|
154
|
+
* order, then either nested children, prose children, or self-closing.
|
|
155
|
+
*/
|
|
156
|
+
export function serializeSpecBlock(spec, block) {
|
|
157
|
+
const base = prop("id", block.id) +
|
|
158
|
+
prop("title", block.title) +
|
|
159
|
+
prop("summary", block.summary) +
|
|
160
|
+
prop("editable", block.editable);
|
|
161
|
+
const attrs = spec.mdx.toAttrs(block.data);
|
|
162
|
+
const childrenField = spec.mdx.childrenField;
|
|
163
|
+
const attrStr = Object.entries(attrs)
|
|
164
|
+
.filter(([key]) => key !== childrenField)
|
|
165
|
+
.map(([key, value]) => prop(key, value))
|
|
166
|
+
.join("");
|
|
167
|
+
const tag = spec.mdx.tag;
|
|
168
|
+
// Custom nested-MDX children (e.g. wireframe Screen/kit tree).
|
|
169
|
+
if (spec.mdx.serializeChildren) {
|
|
170
|
+
return `<${tag}${base}${attrStr}>\n${spec.mdx.serializeChildren(block.data)}\n</${tag}>`;
|
|
171
|
+
}
|
|
172
|
+
// Prose children (rich-text, callout): body is a trimmed markdown string.
|
|
173
|
+
if (childrenField) {
|
|
174
|
+
const body = String(block.data[childrenField] ?? "").trim();
|
|
175
|
+
return `<${tag}${base}${attrStr}>\n\n${body}\n\n</${tag}>`;
|
|
176
|
+
}
|
|
177
|
+
// Self-closing structured block.
|
|
178
|
+
return `<${tag}${base}${attrStr} />`;
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Parse one MDX JSX node into a block via the registry, if its tag is
|
|
182
|
+
* registered. Returns `null` for unregistered tags so the caller can fall back
|
|
183
|
+
* to its legacy parser. `base` is the already-extracted id/title/summary/
|
|
184
|
+
* editable; `children` is the stringified prose children.
|
|
185
|
+
*/
|
|
186
|
+
export function parseSpecBlock(registry, node, base, children, idContext) {
|
|
187
|
+
const tag = node.name;
|
|
188
|
+
if (!tag)
|
|
189
|
+
return null;
|
|
190
|
+
const spec = registry.getByTag(tag);
|
|
191
|
+
if (!spec)
|
|
192
|
+
return null;
|
|
193
|
+
const reader = createAttrReader(node);
|
|
194
|
+
let data;
|
|
195
|
+
if (spec.mdx.parseChildren) {
|
|
196
|
+
const fromAttrs = spec.mdx.fromAttrs(reader, children);
|
|
197
|
+
const fromChildren = spec.mdx.parseChildren(node.children ?? [], `${idContext}-${base.id}`);
|
|
198
|
+
data = { ...fromAttrs, ...fromChildren };
|
|
199
|
+
}
|
|
200
|
+
else {
|
|
201
|
+
data = spec.mdx.fromAttrs(reader, children);
|
|
202
|
+
}
|
|
203
|
+
return { type: spec.type, data };
|
|
204
|
+
}
|
|
205
|
+
//# sourceMappingURL=mdx.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mdx.js","sourceRoot":"","sources":["../../../src/client/blocks/mdx.ts"],"names":[],"mappings":"AAGA;;;;;;;GAOG;AAEH,gFAAgF;AAChF,gFAAgF;AAChF,gFAAgF;AAEhF,MAAM,UAAU,cAAc,CAAC,KAAc;IAC3C,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;AACxC,CAAC;AAED,MAAM,UAAU,UAAU,CAAC,KAAa;IACtC,OAAO,KAAK;SACT,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC;SACtB,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC;SACvB,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC;SACrB,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;AAC3B,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,IAAI,CAAC,IAAY,EAAE,KAAc;IAC/C,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI;QAAE,OAAO,EAAE,CAAC;IACrD,IAAI,OAAO,KAAK,KAAK,SAAS,EAAE,CAAC;QAC/B,OAAO,KAAK,CAAC,CAAC,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,IAAI,UAAU,CAAC;IACjD,CAAC;IACD,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,IAAI,IAAI,KAAK,KAAK,GAAG,CAAC;IAC5D,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,IAAI,uBAAuB,CAAC,IAAI,CAAC,KAAK,C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I,CAAC;IACtB,IAAI,CAAC,GAAG;QAAE,OAAO,IAAI,CAAC;IACtB,MAAM,IAAI,GAAG,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;IACpC,IAAI,CAAC,IAAI;QAAE,OAAO,IAAI,CAAC;IAEvB,MAAM,MAAM,GAAG,gBAAgB,CAAC,IAAI,CAAC,CAAC;IACtC,IAAI,IAAa,CAAC;IAClB,IAAI,IAAI,CAAC,GAAG,CAAC,aAAa,EAAE,CAAC;QAC3B,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;QACvD,MAAM,YAAY,GAAG,IAAI,CAAC,GAAG,CAAC,aAAa,CACzC,IAAI,CAAC,QAAQ,IAAI,EAAE,EACnB,GAAG,SAAS,IAAI,IAAI,CAAC,EAAE,EAAE,CAC1B,CAAC;QACF,IAAI,GAAG,EAAE,GAAI,SAAoB,EAAE,GAAI,YAAuB,EAAE,CAAC;IACnE,CAAC;SAAM,CAAC;QACN,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;IAC9C,CAAC;IACD,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC;AACnC,CAAC","sourcesContent":["import type { BlockSpec, BlockAttrReader, MdxAttrValue } from \"./types.js\";\nimport type { BlockRegistry } from \"./registry.js\";\n\n/**\n * Registry-driven MDX serialize/parse, plus the shared encoder primitives that\n * are the round-trip contract. This module is React-free so the server MDX\n * adapter (`plan-mdx.ts`) and the agent schema export can import it. The encoder\n * + estree literal walker are kept BYTE-FOR-BYTE identical to the originals in\n * `plan-mdx.ts` — `plan-mdx.ts` re-imports them so nothing else there changes\n * and stored `.mdx` files round-trip the same.\n */\n\n/* -------------------------------------------------------------------------- */\n/* Serialize-side encoder primitives (moved verbatim from plan-mdx.ts) */\n/* -------------------------------------------------------------------------- */\n\nexport function jsonExpression(value: unknown): string {\n return JSON.stringify(value, null, 2);\n}\n\nexport function escapeAttr(value: string): string {\n return value\n .replace(/&/g, \"&\")\n .replace(/\"/g, \""\")\n .replace(/</g, \"<\")\n .replace(/>/g, \">\");\n}\n\n/**\n * Encode a single attribute. Returns \"\" (the attribute is dropped) for\n * undefined/null; a bare/`={false}` flag for booleans; `={n}` for numbers; a\n * quoted string when it matches the safe charset and is short, else a JSON\n * expression. Objects/arrays always serialize as a JSON expression.\n */\nexport function prop(name: string, value: unknown): string {\n if (value === undefined || value === null) return \"\";\n if (typeof value === \"boolean\") {\n return value ? ` ${name}` : ` ${name}={false}`;\n }\n if (typeof value === \"number\") return ` ${name}={${value}}`;\n if (typeof value === \"string\") {\n if (/^[\\w .:/@#,+()[\\]-]+$/.test(value) && value.length < 140) {\n return ` ${name}=\"${escapeAttr(value)}\"`;\n }\n return ` ${name}={${jsonExpression(value)}}`;\n }\n return ` ${name}={${jsonExpression(value)}}`;\n}\n\n/* -------------------------------------------------------------------------- */\n/* Parse-side attribute resolution (moved verbatim from plan-mdx.ts) */\n/* -------------------------------------------------------------------------- */\n\n/** Minimal MDX AST node shape (subset of the remark-mdx jsx element). */\nexport type MdxAttrNode = {\n type: string;\n name?: string;\n value?: string | null | MdxAttrExpression;\n};\n\ntype MdxAttrExpression = {\n type: string;\n value: string;\n data?: unknown;\n};\n\ntype EstreeNode = {\n type: string;\n value?: unknown;\n name?: string;\n expression?: EstreeNode;\n body?: EstreeNode[];\n elements?: Array<EstreeNode | null>;\n properties?: EstreeNode[];\n key?: EstreeNode;\n computed?: boolean;\n argument?: EstreeNode;\n operator?: string;\n};\n\nexport type MdxJsxNode = {\n type: string;\n name?: string;\n attributes?: MdxAttrNode[];\n children?: unknown[];\n [key: string]: unknown;\n};\n\nfunction findAttribute(\n node: MdxJsxNode,\n name: string,\n): MdxAttrNode | undefined {\n return node.attributes?.find(\n (attr) => attr.type === \"mdxJsxAttribute\" && attr.name === name,\n );\n}\n\nexport function attributeValue(attr: MdxAttrNode | undefined): unknown {\n if (!attr) return undefined;\n if (attr.value === null || attr.value === undefined) return true;\n if (typeof attr.value === \"string\") return attr.value;\n const astValue = literalExpressionValue(attr.value);\n if (astValue !== undefined) return astValue;\n const expression = attr.value.value.trim();\n if (!expression) return undefined;\n if (expression === \"undefined\") return undefined;\n try {\n return JSON.parse(expression);\n } catch {\n throw new Error(\n `Unsupported MDX attribute expression for \"${attr.name}\": {${expression}}. Use literal values or valid JSON.`,\n );\n }\n}\n\nfunction literalExpressionValue(expression: MdxAttrExpression): unknown {\n const estree = (expression.data as { estree?: EstreeNode } | undefined)\n ?.estree;\n const statement = estree?.body?.[0];\n if (!statement || statement.type !== \"ExpressionStatement\") return undefined;\n return literalNodeValue(statement.expression);\n}\n\nfunction literalNodeValue(node: EstreeNode | undefined | null): unknown {\n if (!node) return undefined;\n if (node.type === \"Literal\") return node.value;\n if (node.type === \"ArrayExpression\") {\n return (node.elements ?? []).map((item) => literalNodeValue(item));\n }\n if (node.type === \"ObjectExpression\") {\n const out: Record<string, unknown> = {};\n for (const property of node.properties ?? []) {\n if (property.type !== \"Property\" || property.computed) return undefined;\n const key = property.key;\n const rawKey =\n key?.type === \"Identifier\"\n ? key.name\n : key?.type === \"Literal\" && typeof key.value === \"string\"\n ? key.value\n : undefined;\n if (!rawKey) return undefined;\n const value = literalNodeValue(property.value as EstreeNode | undefined);\n if (value !== undefined) out[rawKey] = value;\n }\n return out;\n }\n if (node.type === \"UnaryExpression\") {\n const value = literalNodeValue(node.argument);\n if (typeof value !== \"number\") return undefined;\n if (node.operator === \"-\") return -value;\n if (node.operator === \"+\") return value;\n }\n if (node.type === \"Identifier\") {\n if (node.name === \"undefined\") return undefined;\n if (node.name === \"NaN\") return Number.NaN;\n if (node.name === \"Infinity\") return Infinity;\n }\n return undefined;\n}\n\n/** Build a {@link BlockAttrReader} bound to one parsed JSX node. */\nexport function createAttrReader(node: MdxJsxNode): BlockAttrReader {\n const read = (name: string) => attributeValue(findAttribute(node, name));\n return {\n raw: read,\n string(name) {\n const value = read(name);\n return typeof value === \"string\" ? value : undefined;\n },\n number(name) {\n const value = read(name);\n return typeof value === \"number\" ? value : undefined;\n },\n bool(name) {\n const value = read(name);\n return typeof value === \"boolean\" ? value : undefined;\n },\n array(name) {\n const value = read(name);\n return Array.isArray(value) ? (value as never[]) : undefined;\n },\n object(name) {\n const value = read(name);\n return value && typeof value === \"object\" ? (value as never) : undefined;\n },\n };\n}\n\n/* -------------------------------------------------------------------------- */\n/* Registry serialize / parse */\n/* -------------------------------------------------------------------------- */\n\n/** The base-attribute + body shape every block carries. */\nexport interface SerializableBlock {\n id: string;\n title?: string;\n summary?: string;\n editable?: boolean;\n data: unknown;\n}\n\n/** Base block attributes parsed from a node, before the type-specific data. */\nexport interface ParsedBlockBase {\n id: string;\n title?: string;\n summary?: string;\n editable?: boolean;\n}\n\n/**\n * Serialize a block to its MDX element using its spec. Byte output MUST match\n * the legacy `serializeBlock` for every converted block: base attrs\n * (`id,title,summary,editable`) first, then the spec's `toAttrs` in insertion\n * order, then either nested children, prose children, or self-closing.\n */\nexport function serializeSpecBlock(\n spec: BlockSpec<any>,\n block: SerializableBlock,\n): string {\n const base =\n prop(\"id\", block.id) +\n prop(\"title\", block.title) +\n prop(\"summary\", block.summary) +\n prop(\"editable\", block.editable);\n\n const attrs = spec.mdx.toAttrs(block.data);\n const childrenField = spec.mdx.childrenField;\n const attrStr = Object.entries(attrs)\n .filter(([key]) => key !== childrenField)\n .map(([key, value]) => prop(key, value as MdxAttrValue | undefined))\n .join(\"\");\n\n const tag = spec.mdx.tag;\n\n // Custom nested-MDX children (e.g. wireframe Screen/kit tree).\n if (spec.mdx.serializeChildren) {\n return `<${tag}${base}${attrStr}>\\n${spec.mdx.serializeChildren(block.data)}\\n</${tag}>`;\n }\n\n // Prose children (rich-text, callout): body is a trimmed markdown string.\n if (childrenField) {\n const body = String(\n (block.data as Record<string, unknown>)[childrenField] ?? \"\",\n ).trim();\n return `<${tag}${base}${attrStr}>\\n\\n${body}\\n\\n</${tag}>`;\n }\n\n // Self-closing structured block.\n return `<${tag}${base}${attrStr} />`;\n}\n\n/**\n * Parse one MDX JSX node into a block via the registry, if its tag is\n * registered. Returns `null` for unregistered tags so the caller can fall back\n * to its legacy parser. `base` is the already-extracted id/title/summary/\n * editable; `children` is the stringified prose children.\n */\nexport function parseSpecBlock(\n registry: BlockRegistry,\n node: MdxJsxNode,\n base: ParsedBlockBase,\n children: string,\n idContext: string,\n): { type: string; data: unknown } | null {\n const tag = node.name;\n if (!tag) return null;\n const spec = registry.getByTag(tag);\n if (!spec) return null;\n\n const reader = createAttrReader(node);\n let data: unknown;\n if (spec.mdx.parseChildren) {\n const fromAttrs = spec.mdx.fromAttrs(reader, children);\n const fromChildren = spec.mdx.parseChildren(\n node.children ?? [],\n `${idContext}-${base.id}`,\n );\n data = { ...(fromAttrs as object), ...(fromChildren as object) };\n } else {\n data = spec.mdx.fromAttrs(reader, children);\n }\n return { type: spec.type, data };\n}\n"]}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
|
+
import type { BlockRegistry } from "./registry.js";
|
|
3
|
+
import type { BlockRenderContext } from "./types.js";
|
|
4
|
+
/**
|
|
5
|
+
* React provision for the block registry. The registry itself is a per-app
|
|
6
|
+
* module singleton (so the server MDX serializer/parser and the agent schema
|
|
7
|
+
* export can import it outside React); this thin context threads that singleton
|
|
8
|
+
* plus the runtime {@link BlockRenderContext} (asset resolver, action caller,
|
|
9
|
+
* inline markdown editor, …) into the renderer, and lets tests swap registries.
|
|
10
|
+
*/
|
|
11
|
+
interface BlockRegistryValue {
|
|
12
|
+
registry: BlockRegistry;
|
|
13
|
+
ctx: BlockRenderContext;
|
|
14
|
+
}
|
|
15
|
+
export declare function BlockRegistryProvider({ registry, ctx, children, }: {
|
|
16
|
+
registry: BlockRegistry;
|
|
17
|
+
ctx: BlockRenderContext;
|
|
18
|
+
children: ReactNode;
|
|
19
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
20
|
+
/** Read the active registry + render context. Throws outside a provider. */
|
|
21
|
+
export declare function useBlockRegistry(): BlockRegistryValue;
|
|
22
|
+
/** Read the active registry + render context, or `null` outside a provider. */
|
|
23
|
+
export declare function useOptionalBlockRegistry(): BlockRegistryValue | null;
|
|
24
|
+
export {};
|
|
25
|
+
//# sourceMappingURL=provider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../../src/client/blocks/provider.tsx"],"names":[],"mappings":"AAAA,OAAO,EAA6B,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAClE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAErD;;;;;;GAMG;AAEH,UAAU,kBAAkB;IAC1B,QAAQ,EAAE,aAAa,CAAC;IACxB,GAAG,EAAE,kBAAkB,CAAC;CACzB;AAID,wBAAgB,qBAAqB,CAAC,EACpC,QAAQ,EACR,GAAG,EACH,QAAQ,GACT,EAAE;IACD,QAAQ,EAAE,aAAa,CAAC;IACxB,GAAG,EAAE,kBAAkB,CAAC;IACxB,QAAQ,EAAE,SAAS,CAAC;CACrB,2CAMA;AAED,4EAA4E;AAC5E,wBAAgB,gBAAgB,IAAI,kBAAkB,CAQrD;AAED,+EAA+E;AAC/E,wBAAgB,wBAAwB,IAAI,kBAAkB,GAAG,IAAI,CAEpE"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { createContext, useContext } from "react";
|
|
3
|
+
const BlockRegistryContext = createContext(null);
|
|
4
|
+
export function BlockRegistryProvider({ registry, ctx, children, }) {
|
|
5
|
+
return (_jsx(BlockRegistryContext.Provider, { value: { registry, ctx }, children: children }));
|
|
6
|
+
}
|
|
7
|
+
/** Read the active registry + render context. Throws outside a provider. */
|
|
8
|
+
export function useBlockRegistry() {
|
|
9
|
+
const value = useContext(BlockRegistryContext);
|
|
10
|
+
if (!value) {
|
|
11
|
+
throw new Error("useBlockRegistry must be used inside a <BlockRegistryProvider>.");
|
|
12
|
+
}
|
|
13
|
+
return value;
|
|
14
|
+
}
|
|
15
|
+
/** Read the active registry + render context, or `null` outside a provider. */
|
|
16
|
+
export function useOptionalBlockRegistry() {
|
|
17
|
+
return useContext(BlockRegistryContext);
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=provider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provider.js","sourceRoot":"","sources":["../../../src/client/blocks/provider.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,aAAa,EAAE,UAAU,EAAkB,MAAM,OAAO,CAAC;AAiBlE,MAAM,oBAAoB,GAAG,aAAa,CAA4B,IAAI,CAAC,CAAC;AAE5E,MAAM,UAAU,qBAAqB,CAAC,EACpC,QAAQ,EACR,GAAG,EACH,QAAQ,GAKT;IACC,OAAO,CACL,KAAC,oBAAoB,CAAC,QAAQ,IAAC,KAAK,EAAE,EAAE,QAAQ,EAAE,GAAG,EAAE,YACpD,QAAQ,GACqB,CACjC,CAAC;AACJ,CAAC;AAED,4EAA4E;AAC5E,MAAM,UAAU,gBAAgB;IAC9B,MAAM,KAAK,GAAG,UAAU,CAAC,oBAAoB,CAAC,CAAC;IAC/C,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,MAAM,IAAI,KAAK,CACb,iEAAiE,CAClE,CAAC;IACJ,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,+EAA+E;AAC/E,MAAM,UAAU,wBAAwB;IACtC,OAAO,UAAU,CAAC,oBAAoB,CAAC,CAAC;AAC1C,CAAC","sourcesContent":["import { createContext, useContext, type ReactNode } from \"react\";\nimport type { BlockRegistry } from \"./registry.js\";\nimport type { BlockRenderContext } from \"./types.js\";\n\n/**\n * React provision for the block registry. The registry itself is a per-app\n * module singleton (so the server MDX serializer/parser and the agent schema\n * export can import it outside React); this thin context threads that singleton\n * plus the runtime {@link BlockRenderContext} (asset resolver, action caller,\n * inline markdown editor, …) into the renderer, and lets tests swap registries.\n */\n\ninterface BlockRegistryValue {\n registry: BlockRegistry;\n ctx: BlockRenderContext;\n}\n\nconst BlockRegistryContext = createContext<BlockRegistryValue | null>(null);\n\nexport function BlockRegistryProvider({\n registry,\n ctx,\n children,\n}: {\n registry: BlockRegistry;\n ctx: BlockRenderContext;\n children: ReactNode;\n}) {\n return (\n <BlockRegistryContext.Provider value={{ registry, ctx }}>\n {children}\n </BlockRegistryContext.Provider>\n );\n}\n\n/** Read the active registry + render context. Throws outside a provider. */\nexport function useBlockRegistry(): BlockRegistryValue {\n const value = useContext(BlockRegistryContext);\n if (!value) {\n throw new Error(\n \"useBlockRegistry must be used inside a <BlockRegistryProvider>.\",\n );\n }\n return value;\n}\n\n/** Read the active registry + render context, or `null` outside a provider. */\nexport function useOptionalBlockRegistry(): BlockRegistryValue | null {\n return useContext(BlockRegistryContext);\n}\n"]}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { BlockSpec, BlockPlacement } from "./types.js";
|
|
2
|
+
/**
|
|
3
|
+
* In-memory block registry. Holds two lookups: by runtime `type` (render +
|
|
4
|
+
* serialize side) and by MDX `tag` (parse side). The registry is a plain object
|
|
5
|
+
* usable both inside React (via the context provider) and outside it (the
|
|
6
|
+
* server MDX serializer/parser, agent schema export) — mirroring how the legacy
|
|
7
|
+
* `BLOCK_COMPONENTS` set and `serializeBlock`/`parseBlock` are plain functions.
|
|
8
|
+
*/
|
|
9
|
+
export declare class BlockRegistry {
|
|
10
|
+
private byType;
|
|
11
|
+
private byTag;
|
|
12
|
+
register(spec: BlockSpec<any>): void;
|
|
13
|
+
get(type: string): BlockSpec<any> | undefined;
|
|
14
|
+
getByTag(tag: string): BlockSpec<any> | undefined;
|
|
15
|
+
has(type: string): boolean;
|
|
16
|
+
hasTag(tag: string): boolean;
|
|
17
|
+
/** All registered MDX tags — replaces the hardcoded `BLOCK_COMPONENTS` set. */
|
|
18
|
+
tags(): Set<string>;
|
|
19
|
+
/** All registered specs, optionally filtered by placement. */
|
|
20
|
+
list(placement?: BlockPlacement): BlockSpec<any>[];
|
|
21
|
+
}
|
|
22
|
+
/** Register a batch of specs in order. */
|
|
23
|
+
export declare function registerBlocks(registry: BlockRegistry, specs: BlockSpec<any>[]): void;
|
|
24
|
+
//# sourceMappingURL=registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../../src/client/blocks/registry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAE5D;;;;;;GAMG;AACH,qBAAa,aAAa;IACxB,OAAO,CAAC,MAAM,CAAqC;IACnD,OAAO,CAAC,KAAK,CAAqC;IAElD,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC,GAAG,CAAC,GAAG,IAAI;IAWpC,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC,GAAG,CAAC,GAAG,SAAS;IAI7C,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,CAAC,GAAG,CAAC,GAAG,SAAS;IAIjD,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAI1B,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO;IAI5B,+EAA+E;IAC/E,IAAI,IAAI,GAAG,CAAC,MAAM,CAAC;IAInB,8DAA8D;IAC9D,IAAI,CAAC,SAAS,CAAC,EAAE,cAAc,GAAG,SAAS,CAAC,GAAG,CAAC,EAAE;CAMnD;AAED,0CAA0C;AAC1C,wBAAgB,cAAc,CAC5B,QAAQ,EAAE,aAAa,EACvB,KAAK,EAAE,SAAS,CAAC,GAAG,CAAC,EAAE,GACtB,IAAI,CAEN"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* In-memory block registry. Holds two lookups: by runtime `type` (render +
|
|
3
|
+
* serialize side) and by MDX `tag` (parse side). The registry is a plain object
|
|
4
|
+
* usable both inside React (via the context provider) and outside it (the
|
|
5
|
+
* server MDX serializer/parser, agent schema export) — mirroring how the legacy
|
|
6
|
+
* `BLOCK_COMPONENTS` set and `serializeBlock`/`parseBlock` are plain functions.
|
|
7
|
+
*/
|
|
8
|
+
export class BlockRegistry {
|
|
9
|
+
byType = new Map();
|
|
10
|
+
byTag = new Map();
|
|
11
|
+
register(spec) {
|
|
12
|
+
if (this.byType.has(spec.type)) {
|
|
13
|
+
throw new Error(`Block type "${spec.type}" is already registered.`);
|
|
14
|
+
}
|
|
15
|
+
if (this.byTag.has(spec.mdx.tag)) {
|
|
16
|
+
throw new Error(`Block MDX tag "${spec.mdx.tag}" is already registered.`);
|
|
17
|
+
}
|
|
18
|
+
this.byType.set(spec.type, spec);
|
|
19
|
+
this.byTag.set(spec.mdx.tag, spec);
|
|
20
|
+
}
|
|
21
|
+
get(type) {
|
|
22
|
+
return this.byType.get(type);
|
|
23
|
+
}
|
|
24
|
+
getByTag(tag) {
|
|
25
|
+
return this.byTag.get(tag);
|
|
26
|
+
}
|
|
27
|
+
has(type) {
|
|
28
|
+
return this.byType.has(type);
|
|
29
|
+
}
|
|
30
|
+
hasTag(tag) {
|
|
31
|
+
return this.byTag.has(tag);
|
|
32
|
+
}
|
|
33
|
+
/** All registered MDX tags — replaces the hardcoded `BLOCK_COMPONENTS` set. */
|
|
34
|
+
tags() {
|
|
35
|
+
return new Set(this.byTag.keys());
|
|
36
|
+
}
|
|
37
|
+
/** All registered specs, optionally filtered by placement. */
|
|
38
|
+
list(placement) {
|
|
39
|
+
const all = [...this.byType.values()];
|
|
40
|
+
return placement
|
|
41
|
+
? all.filter((spec) => spec.placement.includes(placement))
|
|
42
|
+
: all;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
/** Register a batch of specs in order. */
|
|
46
|
+
export function registerBlocks(registry, specs) {
|
|
47
|
+
for (const spec of specs)
|
|
48
|
+
registry.register(spec);
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../../../src/client/blocks/registry.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,MAAM,OAAO,aAAa;IAChB,MAAM,GAAG,IAAI,GAAG,EAA0B,CAAC;IAC3C,KAAK,GAAG,IAAI,GAAG,EAA0B,CAAC;IAElD,QAAQ,CAAC,IAAoB;QAC3B,IAAI,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;YAC/B,MAAM,IAAI,KAAK,CAAC,eAAe,IAAI,CAAC,IAAI,0BAA0B,CAAC,CAAC;QACtE,CAAC;QACD,IAAI,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;YACjC,MAAM,IAAI,KAAK,CAAC,kBAAkB,IAAI,CAAC,GAAG,CAAC,GAAG,0BAA0B,CAAC,CAAC;QAC5E,CAAC;QACD,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;QACjC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;IACrC,CAAC;IAED,GAAG,CAAC,IAAY;QACd,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAC/B,CAAC;IAED,QAAQ,CAAC,GAAW;QAClB,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAC7B,CAAC;IAED,GAAG,CAAC,IAAY;QACd,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAC/B,CAAC;IAED,MAAM,CAAC,GAAW;QAChB,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAC7B,CAAC;IAED,+EAA+E;IAC/E,IAAI;QACF,OAAO,IAAI,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC;IACpC,CAAC;IAED,8DAA8D;IAC9D,IAAI,CAAC,SAA0B;QAC7B,MAAM,GAAG,GAAG,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC;QACtC,OAAO,SAAS;YACd,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;YAC1D,CAAC,CAAC,GAAG,CAAC;IACV,CAAC;CACF;AAED,0CAA0C;AAC1C,MAAM,UAAU,cAAc,CAC5B,QAAuB,EACvB,KAAuB;IAEvB,KAAK,MAAM,IAAI,IAAI,KAAK;QAAE,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;AACpD,CAAC","sourcesContent":["import type { BlockSpec, BlockPlacement } from \"./types.js\";\n\n/**\n * In-memory block registry. Holds two lookups: by runtime `type` (render +\n * serialize side) and by MDX `tag` (parse side). The registry is a plain object\n * usable both inside React (via the context provider) and outside it (the\n * server MDX serializer/parser, agent schema export) — mirroring how the legacy\n * `BLOCK_COMPONENTS` set and `serializeBlock`/`parseBlock` are plain functions.\n */\nexport class BlockRegistry {\n private byType = new Map<string, BlockSpec<any>>();\n private byTag = new Map<string, BlockSpec<any>>();\n\n register(spec: BlockSpec<any>): void {\n if (this.byType.has(spec.type)) {\n throw new Error(`Block type \"${spec.type}\" is already registered.`);\n }\n if (this.byTag.has(spec.mdx.tag)) {\n throw new Error(`Block MDX tag \"${spec.mdx.tag}\" is already registered.`);\n }\n this.byType.set(spec.type, spec);\n this.byTag.set(spec.mdx.tag, spec);\n }\n\n get(type: string): BlockSpec<any> | undefined {\n return this.byType.get(type);\n }\n\n getByTag(tag: string): BlockSpec<any> | undefined {\n return this.byTag.get(tag);\n }\n\n has(type: string): boolean {\n return this.byType.has(type);\n }\n\n hasTag(tag: string): boolean {\n return this.byTag.has(tag);\n }\n\n /** All registered MDX tags — replaces the hardcoded `BLOCK_COMPONENTS` set. */\n tags(): Set<string> {\n return new Set(this.byTag.keys());\n }\n\n /** All registered specs, optionally filtered by placement. */\n list(placement?: BlockPlacement): BlockSpec<any>[] {\n const all = [...this.byType.values()];\n return placement\n ? all.filter((spec) => spec.placement.includes(placement))\n : all;\n }\n}\n\n/** Register a batch of specs in order. */\nexport function registerBlocks(\n registry: BlockRegistry,\n specs: BlockSpec<any>[],\n): void {\n for (const spec of specs) registry.register(spec);\n}\n"]}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { type ZodType, type ZodTypeAny } from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* Tag a string schema so the auto-editor renders it with the shared inline
|
|
4
|
+
* rich-markdown editor (Notion-style editing) instead of a plain textarea.
|
|
5
|
+
* Survives `.optional()` because `unwrap` reads the inner description.
|
|
6
|
+
*/
|
|
7
|
+
export declare function markdown(schema?: ZodTypeAny): ZodTypeAny;
|
|
8
|
+
/** Alias for {@link markdown} — tags a string field as rich text. */
|
|
9
|
+
export declare function richtext(schema?: ZodTypeAny): ZodTypeAny;
|
|
10
|
+
export type FieldKind = "markdown" | "richtext" | "text" | "longtext" | "number" | "boolean" | "enum" | "array" | "object" | "unsupported";
|
|
11
|
+
export interface FieldDescriptor {
|
|
12
|
+
key: string;
|
|
13
|
+
/** Humanized key for the field label. */
|
|
14
|
+
label: string;
|
|
15
|
+
kind: FieldKind;
|
|
16
|
+
optional: boolean;
|
|
17
|
+
enumValues?: string[];
|
|
18
|
+
/** Element schema for arrays / inner schema for objects. */
|
|
19
|
+
inner?: ZodTypeAny;
|
|
20
|
+
/** Element descriptors for object fields (one level of nesting). */
|
|
21
|
+
fields?: FieldDescriptor[];
|
|
22
|
+
/** Description tag, when present (used to detect markdown/richtext). */
|
|
23
|
+
description?: string;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Introspect a block's `data` schema into a flat list of field descriptors. The
|
|
27
|
+
* input is unwrapped to its object schema first (so an `.optional()`-wrapped or
|
|
28
|
+
* `.refine()`-wrapped object still yields its fields).
|
|
29
|
+
*/
|
|
30
|
+
export declare function introspect(schema: ZodType<unknown>): FieldDescriptor[];
|
|
31
|
+
//# sourceMappingURL=introspect.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"introspect.d.ts","sourceRoot":"","sources":["../../../../src/client/blocks/schema-form/introspect.ts"],"names":[],"mappings":"AAAA,OAAO,EAAK,KAAK,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,KAAK,CAAC;AAiBvD;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,MAAM,GAAE,UAAuB,GAAG,UAAU,CAEpE;AAED,qEAAqE;AACrE,wBAAgB,QAAQ,CAAC,MAAM,GAAE,UAAuB,GAAG,UAAU,CAEpE;AAED,MAAM,MAAM,SAAS,GACjB,UAAU,GACV,UAAU,GACV,MAAM,GACN,UAAU,GACV,QAAQ,GACR,SAAS,GACT,MAAM,GACN,OAAO,GACP,QAAQ,GACR,aAAa,CAAC;AAElB,MAAM,WAAW,eAAe;IAC9B,GAAG,EAAE,MAAM,CAAC;IACZ,yCAAyC;IACzC,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,SAAS,CAAC;IAChB,QAAQ,EAAE,OAAO,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB,4DAA4D;IAC5D,KAAK,CAAC,EAAE,UAAU,CAAC;IACnB,oEAAoE;IACpE,MAAM,CAAC,EAAE,eAAe,EAAE,CAAC;IAC3B,wEAAwE;IACxE,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAsID;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG,eAAe,EAAE,CAKtE"}
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* Schema introspection for the auto-editor. Walks a block's zod `data` schema
|
|
4
|
+
* and classifies each top-level field into a {@link FieldKind} the
|
|
5
|
+
* `SchemaBlockEditor` knows how to render.
|
|
6
|
+
*
|
|
7
|
+
* zod v4 note: schemas expose `_def.type` (a string discriminator) rather than
|
|
8
|
+
* v3's `typeName`. Object shape is `_def.shape`, array element is `_def.element`,
|
|
9
|
+
* enum options are `.options`. `.describe()` does NOT propagate through
|
|
10
|
+
* `.optional()`/`.default()`/`.nullable()` to the outer schema, so `unwrap`
|
|
11
|
+
* inherits the innermost description while peeling wrapper layers.
|
|
12
|
+
*/
|
|
13
|
+
const MD_TAG = "x-an-field:markdown";
|
|
14
|
+
const RT_TAG = "x-an-field:richtext";
|
|
15
|
+
/**
|
|
16
|
+
* Tag a string schema so the auto-editor renders it with the shared inline
|
|
17
|
+
* rich-markdown editor (Notion-style editing) instead of a plain textarea.
|
|
18
|
+
* Survives `.optional()` because `unwrap` reads the inner description.
|
|
19
|
+
*/
|
|
20
|
+
export function markdown(schema = z.string()) {
|
|
21
|
+
return schema.describe(MD_TAG);
|
|
22
|
+
}
|
|
23
|
+
/** Alias for {@link markdown} — tags a string field as rich text. */
|
|
24
|
+
export function richtext(schema = z.string()) {
|
|
25
|
+
return schema.describe(RT_TAG);
|
|
26
|
+
}
|
|
27
|
+
function defType(schema) {
|
|
28
|
+
return schema?._def?.type;
|
|
29
|
+
}
|
|
30
|
+
/** Peel optional/default/nullable/refine wrappers; keep the innermost description. */
|
|
31
|
+
function unwrap(schema) {
|
|
32
|
+
let current = schema;
|
|
33
|
+
let optional = false;
|
|
34
|
+
let description = current?.description;
|
|
35
|
+
// Bound the loop so a malformed schema can never spin forever.
|
|
36
|
+
for (let i = 0; i < 12; i++) {
|
|
37
|
+
const type = defType(current);
|
|
38
|
+
const inner = current._def
|
|
39
|
+
?.innerType;
|
|
40
|
+
if (type === "optional" || type === "nullable" || type === "nullish") {
|
|
41
|
+
optional = true;
|
|
42
|
+
}
|
|
43
|
+
else if (type === "default" || type === "catch" || type === "readonly") {
|
|
44
|
+
// not optional per se, but a wrapper to peel
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
break;
|
|
48
|
+
}
|
|
49
|
+
if (!inner)
|
|
50
|
+
break;
|
|
51
|
+
current = inner;
|
|
52
|
+
description = description ?? current.description;
|
|
53
|
+
}
|
|
54
|
+
return { schema: current, optional, description };
|
|
55
|
+
}
|
|
56
|
+
function humanize(key) {
|
|
57
|
+
return key
|
|
58
|
+
.replace(/[_-]+/g, " ")
|
|
59
|
+
.replace(/([a-z])([A-Z])/g, "$1 $2")
|
|
60
|
+
.replace(/^\w/, (c) => c.toUpperCase());
|
|
61
|
+
}
|
|
62
|
+
function classify(schema, description) {
|
|
63
|
+
if (description === MD_TAG)
|
|
64
|
+
return "markdown";
|
|
65
|
+
if (description === RT_TAG)
|
|
66
|
+
return "richtext";
|
|
67
|
+
const type = defType(schema);
|
|
68
|
+
switch (type) {
|
|
69
|
+
case "string": {
|
|
70
|
+
// A long max length implies a textarea; otherwise a single-line input.
|
|
71
|
+
const checks = schema._def
|
|
72
|
+
?.checks;
|
|
73
|
+
const max = readMaxLength(checks);
|
|
74
|
+
return max !== undefined && max > 240 ? "longtext" : "text";
|
|
75
|
+
}
|
|
76
|
+
case "number":
|
|
77
|
+
case "bigint":
|
|
78
|
+
return "number";
|
|
79
|
+
case "boolean":
|
|
80
|
+
return "boolean";
|
|
81
|
+
case "enum":
|
|
82
|
+
return "enum";
|
|
83
|
+
case "array":
|
|
84
|
+
return "array";
|
|
85
|
+
case "object":
|
|
86
|
+
return "object";
|
|
87
|
+
default:
|
|
88
|
+
return "unsupported";
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
function readMaxLength(checks) {
|
|
92
|
+
if (!checks)
|
|
93
|
+
return undefined;
|
|
94
|
+
for (const check of checks) {
|
|
95
|
+
const def = check?._zod?.def;
|
|
96
|
+
if (def?.check === "max_length" && typeof def.maximum === "number") {
|
|
97
|
+
return def.maximum;
|
|
98
|
+
}
|
|
99
|
+
// Fallback for shapes that expose the bound directly.
|
|
100
|
+
const direct = check;
|
|
101
|
+
if (direct?.kind === "max" && typeof direct.value === "number") {
|
|
102
|
+
return direct.value;
|
|
103
|
+
}
|
|
104
|
+
if (typeof direct?.maximum === "number")
|
|
105
|
+
return direct.maximum;
|
|
106
|
+
}
|
|
107
|
+
return undefined;
|
|
108
|
+
}
|
|
109
|
+
function objectShape(schema) {
|
|
110
|
+
const rawShape = schema._def?.shape;
|
|
111
|
+
if (!rawShape)
|
|
112
|
+
return null;
|
|
113
|
+
const shape = typeof rawShape === "function" ? rawShape() : rawShape;
|
|
114
|
+
return shape && typeof shape === "object"
|
|
115
|
+
? shape
|
|
116
|
+
: null;
|
|
117
|
+
}
|
|
118
|
+
function describeField(key, raw) {
|
|
119
|
+
const { schema, optional, description } = unwrap(raw);
|
|
120
|
+
const kind = classify(schema, description);
|
|
121
|
+
const descriptor = {
|
|
122
|
+
key,
|
|
123
|
+
label: humanize(key),
|
|
124
|
+
kind,
|
|
125
|
+
optional,
|
|
126
|
+
description,
|
|
127
|
+
};
|
|
128
|
+
if (kind === "enum") {
|
|
129
|
+
const options = schema.options;
|
|
130
|
+
descriptor.enumValues = Array.isArray(options)
|
|
131
|
+
? options.map((value) => String(value))
|
|
132
|
+
: [];
|
|
133
|
+
}
|
|
134
|
+
else if (kind === "array") {
|
|
135
|
+
const element = schema._def
|
|
136
|
+
?.element;
|
|
137
|
+
descriptor.inner = element;
|
|
138
|
+
const elementShape = element ? objectShape(unwrap(element).schema) : null;
|
|
139
|
+
if (elementShape) {
|
|
140
|
+
descriptor.fields = Object.entries(elementShape).map(([childKey, child]) => describeField(childKey, child));
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
else if (kind === "object") {
|
|
144
|
+
descriptor.inner = schema;
|
|
145
|
+
const shape = objectShape(schema);
|
|
146
|
+
if (shape) {
|
|
147
|
+
descriptor.fields = Object.entries(shape).map(([childKey, child]) => describeField(childKey, child));
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
return descriptor;
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Introspect a block's `data` schema into a flat list of field descriptors. The
|
|
154
|
+
* input is unwrapped to its object schema first (so an `.optional()`-wrapped or
|
|
155
|
+
* `.refine()`-wrapped object still yields its fields).
|
|
156
|
+
*/
|
|
157
|
+
export function introspect(schema) {
|
|
158
|
+
const { schema: unwrapped } = unwrap(schema);
|
|
159
|
+
const shape = objectShape(unwrapped);
|
|
160
|
+
if (!shape)
|
|
161
|
+
return [];
|
|
162
|
+
return Object.entries(shape).map(([key, child]) => describeField(key, child));
|
|
163
|
+
}
|
|
164
|
+
//# sourceMappingURL=introspect.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"introspect.js","sourceRoot":"","sources":["../../../../src/client/blocks/schema-form/introspect.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAiC,MAAM,KAAK,CAAC;AAEvD;;;;;;;;;;GAUG;AAEH,MAAM,MAAM,GAAG,qBAAqB,CAAC;AACrC,MAAM,MAAM,GAAG,qBAAqB,CAAC;AAErC;;;;GAIG;AACH,MAAM,UAAU,QAAQ,CAAC,SAAqB,CAAC,CAAC,MAAM,EAAE;IACtD,OAAO,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;AACjC,CAAC;AAED,qEAAqE;AACrE,MAAM,UAAU,QAAQ,CAAC,SAAqB,CAAC,CAAC,MAAM,EAAE;IACtD,OAAO,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;AACjC,CAAC;AA6BD,SAAS,OAAO,CAAC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AAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,aAAa,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC,CAAC;AAChF,CAAC","sourcesContent":["import { z, type ZodType, type ZodTypeAny } from \"zod\";\n\n/**\n * Schema introspection for the auto-editor. Walks a block's zod `data` schema\n * and classifies each top-level field into a {@link FieldKind} the\n * `SchemaBlockEditor` knows how to render.\n *\n * zod v4 note: schemas expose `_def.type` (a string discriminator) rather than\n * v3's `typeName`. Object shape is `_def.shape`, array element is `_def.element`,\n * enum options are `.options`. `.describe()` does NOT propagate through\n * `.optional()`/`.default()`/`.nullable()` to the outer schema, so `unwrap`\n * inherits the innermost description while peeling wrapper layers.\n */\n\nconst MD_TAG = \"x-an-field:markdown\";\nconst RT_TAG = \"x-an-field:richtext\";\n\n/**\n * Tag a string schema so the auto-editor renders it with the shared inline\n * rich-markdown editor (Notion-style editing) instead of a plain textarea.\n * Survives `.optional()` because `unwrap` reads the inner description.\n */\nexport function markdown(schema: ZodTypeAny = z.string()): ZodTypeAny {\n return schema.describe(MD_TAG);\n}\n\n/** Alias for {@link markdown} — tags a string field as rich text. */\nexport function richtext(schema: ZodTypeAny = z.string()): ZodTypeAny {\n return schema.describe(RT_TAG);\n}\n\nexport type FieldKind =\n | \"markdown\"\n | \"richtext\"\n | \"text\"\n | \"longtext\"\n | \"number\"\n | \"boolean\"\n | \"enum\"\n | \"array\"\n | \"object\"\n | \"unsupported\";\n\nexport interface FieldDescriptor {\n key: string;\n /** Humanized key for the field label. */\n label: string;\n kind: FieldKind;\n optional: boolean;\n enumValues?: string[];\n /** Element schema for arrays / inner schema for objects. */\n inner?: ZodTypeAny;\n /** Element descriptors for object fields (one level of nesting). */\n fields?: FieldDescriptor[];\n /** Description tag, when present (used to detect markdown/richtext). */\n description?: string;\n}\n\nfunction defType(schema: ZodTypeAny): string | undefined {\n return (schema?._def as { type?: string } | undefined)?.type;\n}\n\n/** Peel optional/default/nullable/refine wrappers; keep the innermost description. */\nfunction unwrap(schema: ZodTypeAny): {\n schema: ZodTypeAny;\n optional: boolean;\n description?: string;\n} {\n let current = schema;\n let optional = false;\n let description: string | undefined = current?.description;\n // Bound the loop so a malformed schema can never spin forever.\n for (let i = 0; i < 12; i++) {\n const type = defType(current);\n const inner = (current._def as { innerType?: ZodTypeAny } | undefined)\n ?.innerType;\n if (type === \"optional\" || type === \"nullable\" || type === \"nullish\") {\n optional = true;\n } else if (type === \"default\" || type === \"catch\" || type === \"readonly\") {\n // not optional per se, but a wrapper to peel\n } else {\n break;\n }\n if (!inner) break;\n current = inner;\n description = description ?? current.description;\n }\n return { schema: current, optional, description };\n}\n\nfunction humanize(key: string): string {\n return key\n .replace(/[_-]+/g, \" \")\n .replace(/([a-z])([A-Z])/g, \"$1 $2\")\n .replace(/^\\w/, (c) => c.toUpperCase());\n}\n\nfunction classify(schema: ZodTypeAny, description?: string): FieldKind {\n if (description === MD_TAG) return \"markdown\";\n if (description === RT_TAG) return \"richtext\";\n const type = defType(schema);\n switch (type) {\n case \"string\": {\n // A long max length implies a textarea; otherwise a single-line input.\n const checks = (schema._def as { checks?: unknown[] } | undefined)\n ?.checks;\n const max = readMaxLength(checks);\n return max !== undefined && max > 240 ? \"longtext\" : \"text\";\n }\n case \"number\":\n case \"bigint\":\n return \"number\";\n case \"boolean\":\n return \"boolean\";\n case \"enum\":\n return \"enum\";\n case \"array\":\n return \"array\";\n case \"object\":\n return \"object\";\n default:\n return \"unsupported\";\n }\n}\n\nfunction readMaxLength(checks: unknown[] | undefined): number | undefined {\n if (!checks) return undefined;\n for (const check of checks) {\n const def = (\n check as { _zod?: { def?: { check?: string; maximum?: number } } }\n )?._zod?.def;\n if (def?.check === \"max_length\" && typeof def.maximum === \"number\") {\n return def.maximum;\n }\n // Fallback for shapes that expose the bound directly.\n const direct = check as { kind?: string; value?: number; maximum?: number };\n if (direct?.kind === \"max\" && typeof direct.value === \"number\") {\n return direct.value;\n }\n if (typeof direct?.maximum === \"number\") return direct.maximum;\n }\n return undefined;\n}\n\nfunction objectShape(schema: ZodTypeAny): Record<string, ZodTypeAny> | null {\n const rawShape = (schema._def as { shape?: unknown } | undefined)?.shape;\n if (!rawShape) return null;\n const shape = typeof rawShape === \"function\" ? rawShape() : rawShape;\n return shape && typeof shape === \"object\"\n ? (shape as Record<string, ZodTypeAny>)\n : null;\n}\n\nfunction describeField(key: string, raw: ZodTypeAny): FieldDescriptor {\n const { schema, optional, description } = unwrap(raw);\n const kind = classify(schema, description);\n const descriptor: FieldDescriptor = {\n key,\n label: humanize(key),\n kind,\n optional,\n description,\n };\n if (kind === \"enum\") {\n const options = (schema as { options?: unknown[] }).options;\n descriptor.enumValues = Array.isArray(options)\n ? options.map((value) => String(value))\n : [];\n } else if (kind === \"array\") {\n const element = (schema._def as { element?: ZodTypeAny } | undefined)\n ?.element;\n descriptor.inner = element;\n const elementShape = element ? objectShape(unwrap(element).schema) : null;\n if (elementShape) {\n descriptor.fields = Object.entries(elementShape).map(\n ([childKey, child]) => describeField(childKey, child),\n );\n }\n } else if (kind === \"object\") {\n descriptor.inner = schema;\n const shape = objectShape(schema);\n if (shape) {\n descriptor.fields = Object.entries(shape).map(([childKey, child]) =>\n describeField(childKey, child),\n );\n }\n }\n return descriptor;\n}\n\n/**\n * Introspect a block's `data` schema into a flat list of field descriptors. The\n * input is unwrapped to its object schema first (so an `.optional()`-wrapped or\n * `.refine()`-wrapped object still yields its fields).\n */\nexport function introspect(schema: ZodType<unknown>): FieldDescriptor[] {\n const { schema: unwrapped } = unwrap(schema as ZodTypeAny);\n const shape = objectShape(unwrapped);\n if (!shape) return [];\n return Object.entries(shape).map(([key, child]) => describeField(key, child));\n}\n"]}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@agent-native/core/blocks/server` — the React-free subset of the block
|
|
3
|
+
* registry for server / agent code (MDX serialize/parse, the registry, schema
|
|
4
|
+
* introspection, the `markdown()` helper, agent schema export). Importing this
|
|
5
|
+
* entry never pulls React into the server bundle.
|
|
6
|
+
*
|
|
7
|
+
* A `BlockSpec` carries React (`Read`/`Edit`) and pure (`schema`/`mdx`) parts in
|
|
8
|
+
* the same object; the server path only touches `spec.schema` / `spec.mdx`. The
|
|
9
|
+
* app's registry module is shared by browser and server, but the server only
|
|
10
|
+
* ever calls these React-free functions on it.
|
|
11
|
+
*/
|
|
12
|
+
export { defineBlock, type BlockSpec, type BlockPlacement, type BlockMdxConfig, type BlockAttrReader, type MdxAttrValue, type NestedBlock, } from "./types.js";
|
|
13
|
+
export { BlockRegistry, registerBlocks } from "./registry.js";
|
|
14
|
+
export { markdown, richtext, introspect, type FieldKind, type FieldDescriptor, } from "./schema-form/introspect.js";
|
|
15
|
+
export { prop, escapeAttr, jsonExpression, attributeValue, createAttrReader, serializeSpecBlock, parseSpecBlock, type MdxJsxNode, type MdxAttrNode, type SerializableBlock, type ParsedBlockBase, } from "./mdx.js";
|
|
16
|
+
export { describeBlocksForAgent, renderBlockVocabularyReference, type BlockAgentDoc, } from "./agent.js";
|
|
17
|
+
export { checklistSchema, checklistMdx, type ChecklistData, type ChecklistItem, } from "./library/checklist.config.js";
|
|
18
|
+
export { tableSchema, tableMdx, type TableData, } from "./library/table.config.js";
|
|
19
|
+
export { codeTabsSchema, codeTabsMdx, type CodeTabsData, type CodeTabsTab, } from "./library/code-tabs.config.js";
|
|
20
|
+
export { htmlSchema, htmlMdx, type HtmlBlockData, } from "./library/html.config.js";
|
|
21
|
+
export { tabsSchema, tabsMdx, type TabsData, type TabsTab, } from "./library/tabs.config.js";
|
|
22
|
+
//# sourceMappingURL=server.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../../src/client/blocks/server.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EACL,WAAW,EACX,KAAK,SAAS,EACd,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,KAAK,YAAY,EACjB,KAAK,WAAW,GACjB,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAE9D,OAAO,EACL,QAAQ,EACR,QAAQ,EACR,UAAU,EACV,KAAK,SAAS,EACd,KAAK,eAAe,GACrB,MAAM,6BAA6B,CAAC;AAErC,OAAO,EACL,IAAI,EACJ,UAAU,EACV,cAAc,EACd,cAAc,EACd,gBAAgB,EAChB,kBAAkB,EAClB,cAAc,EACd,KAAK,UAAU,EACf,KAAK,WAAW,EAChB,KAAK,iBAAiB,EACtB,KAAK,eAAe,GACrB,MAAM,UAAU,CAAC;AAElB,OAAO,EACL,sBAAsB,EACtB,8BAA8B,EAC9B,KAAK,aAAa,GACnB,MAAM,YAAY,CAAC;AAKpB,OAAO,EACL,eAAe,EACf,YAAY,EACZ,KAAK,aAAa,EAClB,KAAK,aAAa,GACnB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACL,WAAW,EACX,QAAQ,EACR,KAAK,SAAS,GACf,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACL,cAAc,EACd,WAAW,EACX,KAAK,YAAY,EACjB,KAAK,WAAW,GACjB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACL,UAAU,EACV,OAAO,EACP,KAAK,aAAa,GACnB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,UAAU,EACV,OAAO,EACP,KAAK,QAAQ,EACb,KAAK,OAAO,GACb,MAAM,0BAA0B,CAAC"}
|