@agent-native/core 0.40.2 → 0.41.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -1
- package/dist/cli/create.d.ts.map +1 -1
- package/dist/cli/create.js +57 -0
- package/dist/cli/create.js.map +1 -1
- package/dist/cli/index.js +16 -0
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/pr-visual-recap-workflow.d.ts +11 -0
- package/dist/cli/pr-visual-recap-workflow.d.ts.map +1 -0
- package/dist/cli/pr-visual-recap-workflow.js +11 -0
- package/dist/cli/pr-visual-recap-workflow.js.map +1 -0
- package/dist/cli/recap.d.ts +52 -0
- package/dist/cli/recap.d.ts.map +1 -0
- package/dist/cli/recap.js +581 -0
- package/dist/cli/recap.js.map +1 -0
- package/dist/cli/skills.d.ts +17 -4
- package/dist/cli/skills.d.ts.map +1 -1
- package/dist/cli/skills.js +60 -16
- package/dist/cli/skills.js.map +1 -1
- package/dist/cli/templates-meta.js +1 -1
- package/dist/cli/templates-meta.js.map +1 -1
- package/dist/cli/workspacify.d.ts.map +1 -1
- package/dist/cli/workspacify.js +19 -4
- package/dist/cli/workspacify.js.map +1 -1
- package/dist/client/blocks/index.d.ts +3 -0
- package/dist/client/blocks/index.d.ts.map +1 -1
- package/dist/client/blocks/index.js +3 -0
- package/dist/client/blocks/index.js.map +1 -1
- package/dist/client/blocks/library/AnnotatedCodeBlock.d.ts +6 -0
- package/dist/client/blocks/library/AnnotatedCodeBlock.d.ts.map +1 -0
- package/dist/client/blocks/library/AnnotatedCodeBlock.js +134 -0
- package/dist/client/blocks/library/AnnotatedCodeBlock.js.map +1 -0
- package/dist/client/blocks/library/HighlightedCode.d.ts +21 -1
- package/dist/client/blocks/library/HighlightedCode.d.ts.map +1 -1
- package/dist/client/blocks/library/HighlightedCode.js +86 -4
- package/dist/client/blocks/library/HighlightedCode.js.map +1 -1
- package/dist/client/blocks/library/annotated-code.config.d.ts +58 -0
- package/dist/client/blocks/library/annotated-code.config.d.ts.map +1 -0
- package/dist/client/blocks/library/annotated-code.config.js +53 -0
- package/dist/client/blocks/library/annotated-code.config.js.map +1 -0
- package/dist/client/blocks/library/checklist.js +2 -2
- package/dist/client/blocks/library/checklist.js.map +1 -1
- package/dist/client/blocks/library/code-highlight.d.ts +16 -0
- package/dist/client/blocks/library/code-highlight.d.ts.map +1 -0
- package/dist/client/blocks/library/code-highlight.js +160 -0
- package/dist/client/blocks/library/code-highlight.js.map +1 -0
- package/dist/client/blocks/library/code-tabs.config.d.ts +6 -0
- package/dist/client/blocks/library/code-tabs.config.d.ts.map +1 -1
- package/dist/client/blocks/library/code-tabs.config.js +1 -0
- package/dist/client/blocks/library/code-tabs.config.js.map +1 -1
- package/dist/client/blocks/library/code-tabs.d.ts.map +1 -1
- package/dist/client/blocks/library/code-tabs.js +35 -5
- package/dist/client/blocks/library/code-tabs.js.map +1 -1
- package/dist/client/blocks/library/code.config.d.ts +43 -0
- package/dist/client/blocks/library/code.config.d.ts.map +1 -0
- package/dist/client/blocks/library/code.config.js +34 -0
- package/dist/client/blocks/library/code.config.js.map +1 -0
- package/dist/client/blocks/library/code.d.ts +3 -0
- package/dist/client/blocks/library/code.d.ts.map +1 -0
- package/dist/client/blocks/library/code.js +95 -0
- package/dist/client/blocks/library/code.js.map +1 -0
- package/dist/client/blocks/library/dev-doc-ui.d.ts +2 -1
- package/dist/client/blocks/library/dev-doc-ui.d.ts.map +1 -1
- package/dist/client/blocks/library/dev-doc-ui.js +2 -1
- package/dist/client/blocks/library/dev-doc-ui.js.map +1 -1
- package/dist/client/blocks/library/server-specs.d.ts.map +1 -1
- package/dist/client/blocks/library/server-specs.js +21 -0
- package/dist/client/blocks/library/server-specs.js.map +1 -1
- package/dist/client/blocks/library/specs.d.ts +1 -1
- package/dist/client/blocks/library/specs.d.ts.map +1 -1
- package/dist/client/blocks/library/specs.js +30 -2
- package/dist/client/blocks/library/specs.js.map +1 -1
- package/dist/client/blocks/server.d.ts +1 -0
- package/dist/client/blocks/server.d.ts.map +1 -1
- package/dist/client/blocks/server.js +1 -0
- package/dist/client/blocks/server.js.map +1 -1
- package/dist/client/blocks/types.d.ts +1 -1
- package/dist/client/blocks/types.js.map +1 -1
- package/dist/client/extensions/ExtensionsListPage.d.ts.map +1 -1
- package/dist/client/extensions/ExtensionsListPage.js +28 -13
- package/dist/client/extensions/ExtensionsListPage.js.map +1 -1
- package/dist/client/extensions/ExtensionsSidebarSection.d.ts.map +1 -1
- package/dist/client/extensions/ExtensionsSidebarSection.js +31 -9
- package/dist/client/extensions/ExtensionsSidebarSection.js.map +1 -1
- package/dist/client/rich-markdown-editor/CodeBlockNode.d.ts +49 -0
- package/dist/client/rich-markdown-editor/CodeBlockNode.d.ts.map +1 -0
- package/dist/client/rich-markdown-editor/CodeBlockNode.js +126 -0
- package/dist/client/rich-markdown-editor/CodeBlockNode.js.map +1 -0
- package/dist/client/rich-markdown-editor/RegistryBlockNode.d.ts.map +1 -1
- package/dist/client/rich-markdown-editor/RegistryBlockNode.js +26 -3
- package/dist/client/rich-markdown-editor/RegistryBlockNode.js.map +1 -1
- package/dist/client/rich-markdown-editor/RichMarkdownEditor.d.ts +1 -1
- package/dist/client/rich-markdown-editor/extensions.d.ts.map +1 -1
- package/dist/client/rich-markdown-editor/extensions.js +8 -8
- package/dist/client/rich-markdown-editor/extensions.js.map +1 -1
- package/dist/client/rich-markdown-editor/index.d.ts +1 -0
- package/dist/client/rich-markdown-editor/index.d.ts.map +1 -1
- package/dist/client/rich-markdown-editor/index.js +1 -0
- package/dist/client/rich-markdown-editor/index.js.map +1 -1
- package/dist/client/rich-markdown-editor/registrySlashCommands.d.ts.map +1 -1
- package/dist/client/rich-markdown-editor/registrySlashCommands.js +1 -0
- package/dist/client/rich-markdown-editor/registrySlashCommands.js.map +1 -1
- package/dist/extensions/actions.d.ts.map +1 -1
- package/dist/extensions/actions.js +63 -2
- package/dist/extensions/actions.js.map +1 -1
- package/dist/extensions/routes.d.ts.map +1 -1
- package/dist/extensions/routes.js +24 -3
- package/dist/extensions/routes.js.map +1 -1
- package/dist/extensions/schema.d.ts +43 -2
- package/dist/extensions/schema.d.ts.map +1 -1
- package/dist/extensions/schema.js +12 -0
- package/dist/extensions/schema.js.map +1 -1
- package/dist/extensions/store.d.ts +20 -0
- package/dist/extensions/store.d.ts.map +1 -1
- package/dist/extensions/store.js +82 -3
- package/dist/extensions/store.js.map +1 -1
- package/dist/server/auth.d.ts.map +1 -1
- package/dist/server/auth.js +13 -0
- 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 +11 -0
- package/dist/server/core-routes-plugin.js.map +1 -1
- package/dist/server/recap-image-route.d.ts +8 -0
- package/dist/server/recap-image-route.d.ts.map +1 -0
- package/dist/server/recap-image-route.js +200 -0
- package/dist/server/recap-image-route.js.map +1 -0
- package/dist/server/recap-image-store.d.ts +41 -0
- package/dist/server/recap-image-store.d.ts.map +1 -0
- package/dist/server/recap-image-store.js +138 -0
- package/dist/server/recap-image-store.js.map +1 -0
- package/dist/styles/rich-markdown-editor.css +66 -17
- package/dist/templates/default/pnpm-workspace.yaml +7 -0
- package/dist/templates/workspace-root/package.json +0 -5
- package/dist/templates/workspace-root/pnpm-workspace.yaml +14 -0
- package/docs/content/cloneable-saas.md +10 -0
- package/docs/content/external-agents.md +4 -7
- package/docs/content/faq.md +10 -0
- package/docs/content/getting-started.md +11 -0
- package/docs/content/pr-visual-recap.md +103 -0
- package/docs/content/skills-guide.md +1 -3
- package/docs/content/template-assets.md +1 -4
- package/docs/content/template-design.md +0 -57
- package/docs/content/template-plan.md +22 -18
- package/docs/content/visual-plans.md +10 -7
- package/docs/content/what-is-agent-native.md +2 -0
- package/package.json +5 -1
- package/src/templates/default/pnpm-workspace.yaml +7 -0
- package/src/templates/workspace-root/package.json +0 -5
- package/src/templates/workspace-root/pnpm-workspace.yaml +14 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,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AAChD,CAAC;AAED,gEAAgE;AAChE,MAAM,UAAU,gBAAgB;IAC9B,OAAO,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;AACtC,CAAC","sourcesContent":["/**\n * First-party template metadata used by the `agent-native` CLI.\n *\n * This file is intentionally inlined here (rather than imported from a\n * separate workspace package) so that the published `@agent-native/core`\n * has no `workspace:*` runtime dependencies. Without this inlining, `npx\n * @agent-native/core create ...` fails on a fresh machine with:\n *\n * npm error code EUNSUPPORTEDPROTOCOL\n * npm error Unsupported URL Type \"workspace:\": workspace:*\n *\n * Keep this list in sync with `packages/shared-app-config/templates.ts`,\n * which serves the same metadata to the desktop / mobile / frame packages\n * that always run inside the workspace. Duplication is intentional: the\n * CLI must remain installable outside the monorepo.\n */\n\nexport interface TemplateMeta {\n /** Directory name under templates/ and package name */\n name: string;\n /** Display name in pickers */\n label: string;\n /** One-line description shown in the picker */\n hint: string;\n /** Longer description (optional) */\n description?: string;\n /** Tabler icon name used in the desktop sidebar */\n icon: string;\n /** Hex accent color */\n color: string;\n /** CSS-safe RGB triplet (e.g. \"59 130 246\") */\n colorRgb: string;\n /** Dev server port for desktop `pnpm dev` */\n devPort: number;\n /** Production URL when running as a first-party app on agent-native.com */\n prodUrl?: string;\n /** Default URL path when deployed in a workspace (defaults to \"/<name>\") */\n prodPath?: string;\n /** Default mode when added to desktop app */\n defaultMode?: \"dev\" | \"prod\";\n /** Hide from pickers but still scaffoldable via explicit --template */\n hidden?: boolean;\n /** Include as a built-in connected A2A agent even when hidden from pickers */\n defaultAgent?: boolean;\n /** Always scaffold without prompting (e.g. starter as fallback) */\n alwaysAvailable?: boolean;\n /** Internal workspace packages this template depends on (e.g. \"scheduling\") */\n requiredPackages?: string[];\n /** Core app — featured in the CLI picker, homepage, and docs gallery */\n core?: boolean;\n}\n\nexport const TEMPLATES: TemplateMeta[] = [\n {\n name: \"calendar\",\n label: \"Calendar\",\n hint: \"Agent-native Google Calendar — manage events, sync, and public booking\",\n icon: \"CalendarDays\",\n color: \"#00B5FF\",\n colorRgb: \"0 181 255\",\n devPort: 8082,\n prodUrl: \"https://calendar.agent-native.com\",\n defaultMode: \"prod\",\n requiredPackages: [\"scheduling\"],\n core: true,\n },\n {\n name: \"content\",\n label: \"Content\",\n hint: \"Agent-native Notion/Google Docs — write and organize with agent assistance\",\n icon: \"FileText\",\n color: \"#10B981\",\n colorRgb: \"16 185 129\",\n devPort: 8083,\n prodUrl: \"https://content.agent-native.com\",\n defaultMode: \"prod\",\n core: true,\n },\n {\n name: \"plan\",\n label: \"Plans\",\n hint: \"Agent-native HTML plans with diagrams, wireframes, prototypes, annotations, sharing, and proof gates\",\n icon: \"FileText\",\n color: \"#52525B\",\n colorRgb: \"82 82 91\",\n devPort: 8105,\n prodUrl: \"https://plan.agent-native.com\",\n defaultMode: \"prod\",\n core: true,\n },\n {\n name: \"slides\",\n label: \"Slides\",\n hint: \"Agent-native Google Slides — generate and edit React presentations\",\n icon: \"GalleryHorizontal\",\n color: \"#EC4899\",\n colorRgb: \"236 72 153\",\n devPort: 8086,\n prodUrl: \"https://slides.agent-native.com\",\n defaultMode: \"prod\",\n requiredPackages: [\"pinpoint\"],\n core: true,\n },\n {\n name: \"videos\",\n label: \"Video\",\n hint: \"Agent-native video editing with Remotion\",\n icon: \"Video\",\n color: \"#EF4444\",\n colorRgb: \"239 68 68\",\n devPort: 8087,\n prodUrl: \"https://videos.agent-native.com\",\n defaultMode: \"prod\",\n requiredPackages: [\"pinpoint\"],\n },\n {\n name: \"analytics\",\n label: \"Analytics\",\n hint: \"Agent-native Amplitude/Mixpanel — connect data sources, prompt for charts\",\n icon: \"BarChart2\",\n color: \"#F59E0B\",\n colorRgb: \"245 158 11\",\n devPort: 8088,\n prodUrl: \"https://analytics.agent-native.com\",\n defaultMode: \"prod\",\n core: true,\n },\n {\n name: \"mail\",\n label: \"Mail\",\n hint: \"Agent-native Superhuman — email client with keyboard shortcuts and AI triage\",\n icon: \"Mail\",\n color: \"#3B82F6\",\n colorRgb: \"59 130 246\",\n devPort: 8085,\n prodUrl: \"https://mail.agent-native.com\",\n defaultMode: \"prod\",\n core: true,\n },\n {\n name: \"dispatch\",\n label: \"Dispatch\",\n hint: \"Central Slack/Telegram router with jobs, memory, approvals, and A2A delegation\",\n icon: \"MessageCircle\",\n color: \"#14B8A6\",\n colorRgb: \"20 184 166\",\n devPort: 8092,\n prodUrl: \"https://dispatch.agent-native.com\",\n defaultMode: \"prod\",\n core: true,\n },\n {\n name: \"forms\",\n label: \"Forms\",\n hint: \"Agent-native form builder — create, edit, and manage forms\",\n icon: \"ClipboardList\",\n color: \"#06B6D4\",\n colorRgb: \"6 182 212\",\n devPort: 8084,\n prodUrl: \"https://forms.agent-native.com\",\n defaultMode: \"prod\",\n core: true,\n },\n {\n name: \"starter\",\n label: \"Starter\",\n hint: \"Minimal scaffold with the agent chat and core architecture wired up\",\n icon: \"Code\",\n color: \"#71717A\",\n colorRgb: \"113 113 122\",\n devPort: 8089,\n defaultMode: \"prod\",\n alwaysAvailable: true,\n core: true,\n hidden: true,\n },\n {\n name: \"clips\",\n label: \"Clips\",\n hint: \"Screen recording, meeting notes, and voice dictation — all with AI\",\n icon: \"ScreenShare\",\n color: \"#0EA5E9\",\n colorRgb: \"14 165 233\",\n devPort: 8094,\n prodUrl: \"https://clips.agent-native.com\",\n defaultMode: \"prod\",\n core: true,\n },\n {\n name: \"brain\",\n label: \"Brain\",\n hint: \"Cited company memory from Slack, meetings, transcripts, and decisions\",\n icon: \"Brain\",\n color: \"#8B5CF6\",\n colorRgb: \"139 92 246\",\n devPort: 8102,\n prodUrl: \"https://brain.agent-native.com\",\n defaultMode: \"prod\",\n defaultAgent: true,\n core: true,\n },\n {\n name: \"design\",\n label: \"Design\",\n hint: \"Agent-native design tool — create and edit visual designs with agent assistance\",\n icon: \"Brush\",\n color: \"#F472B6\",\n colorRgb: \"244 114 182\",\n devPort: 8099,\n prodUrl: \"https://design.agent-native.com\",\n defaultMode: \"prod\",\n requiredPackages: [\"pinpoint\", \"embedding\"],\n core: true,\n },\n {\n name: \"assets\",\n label: \"Assets\",\n hint: \"Digital asset manager — upload, organize, search, and generate on-brand images and videos\",\n icon: \"Photo\",\n color: \"#0F766E\",\n colorRgb: \"15 118 110\",\n devPort: 8100,\n prodUrl: \"https://assets.agent-native.com\",\n defaultMode: \"prod\",\n defaultAgent: true,\n core: true,\n },\n {\n name: \"macros\",\n label: \"Macros\",\n hint: \"Internal template — not shown in pickers\",\n icon: \"Code\",\n color: \"#71717A\",\n colorRgb: \"113 113 122\",\n devPort: 8093,\n prodUrl: \"https://macros.agent-native.com\",\n hidden: true,\n defaultMode: \"dev\",\n },\n];\n\n/** Return templates visible in user-facing pickers (excludes hidden). */\nexport function visibleTemplates(): TemplateMeta[] {\n return TEMPLATES.filter((t) => !t.hidden);\n}\n\n/** Return core templates — the featured set shown in CLI pickers by default. */\nexport function coreTemplates(): TemplateMeta[] {\n return TEMPLATES.filter((t) => t.core);\n}\n\n/** Lookup by name. Returns undefined for unknown names. */\nexport function getTemplate(name: string): TemplateMeta | undefined {\n // Tolerate legacy / renamed aliases.\n if (name === \"video\") name = \"videos\";\n if (name === \"image\" || name === \"images\" || name === \"asset\") {\n name = \"assets\";\n }\n if (name === \"contracts\" || name === \"visual-plans\") name = \"plan\";\n return TEMPLATES.find((t) => t.name === name);\n}\n\n/** Names of all templates (including hidden) for validation. */\nexport function allTemplateNames(): string[] {\n return TEMPLATES.map((t) => t.name);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"templates-meta.js","sourceRoot":"","sources":["../../src/cli/templates-meta.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAqCH,MAAM,CAAC,MAAM,SAAS,GAAmB;IACvC;QACE,IAAI,EAAE,UAAU;QAChB,KAAK,EAAE,UAAU;QACjB,IAAI,EAAE,wEAAwE;QAC9E,IAAI,EAAE,cAAc;QACpB,KAAK,EAAE,SAAS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;QACf,IAAI,EAAE,0CAA0C;QAChD,IAAI,EAAE,MAAM;QACZ,KAAK,EAAE,SAAS;QAChB,QAAQ,EAAE,aAAa;QACvB,OAAO,EAAE,IAAI;QACb,OAAO,EAAE,iCAAiC;QAC1C,MAAM,EAAE,IAAI;QACZ,WAAW,EAAE,KAAK;KACnB;CACF,CAAC;AAEF,yEAAyE;AACzE,MAAM,UAAU,gBAAgB;IAC9B,OAAO,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;AAC5C,CAAC;AAED,gFAAgF;AAChF,MAAM,UAAU,aAAa;IAC3B,OAAO,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;AACzC,CAAC;AAED,2DAA2D;AAC3D,MAAM,UAAU,WAAW,CAAC,IAAY;IACtC,qCAAqC;IACrC,IAAI,IAAI,KAAK,OAAO;QAAE,IAAI,GAAG,QAAQ,CAAC;IACtC,IAAI,IAAI,KAAK,OAAO,IAAI,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,OAAO,EAAE,CAAC;QAC9D,IAAI,GAAG,QAAQ,CAAC;IAClB,CAAC;IACD,IAAI,IAAI,KAAK,WAAW,IAAI,IAAI,KAAK,cAAc;QAAE,IAAI,GAAG,MAAM,CAAC;IACnE,OAAO,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC;AAChD,CAAC;AAED,gEAAgE;AAChE,MAAM,UAAU,gBAAgB;IAC9B,OAAO,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;AACtC,CAAC","sourcesContent":["/**\n * First-party template metadata used by the `agent-native` CLI.\n *\n * This file is intentionally inlined here (rather than imported from a\n * separate workspace package) so that the published `@agent-native/core`\n * has no `workspace:*` runtime dependencies. Without this inlining, `npx\n * @agent-native/core create ...` fails on a fresh machine with:\n *\n * npm error code EUNSUPPORTEDPROTOCOL\n * npm error Unsupported URL Type \"workspace:\": workspace:*\n *\n * Keep this list in sync with `packages/shared-app-config/templates.ts`,\n * which serves the same metadata to the desktop / mobile / frame packages\n * that always run inside the workspace. Duplication is intentional: the\n * CLI must remain installable outside the monorepo.\n */\n\nexport interface TemplateMeta {\n /** Directory name under templates/ and package name */\n name: string;\n /** Display name in pickers */\n label: string;\n /** One-line description shown in the picker */\n hint: string;\n /** Longer description (optional) */\n description?: string;\n /** Tabler icon name used in the desktop sidebar */\n icon: string;\n /** Hex accent color */\n color: string;\n /** CSS-safe RGB triplet (e.g. \"59 130 246\") */\n colorRgb: string;\n /** Dev server port for desktop `pnpm dev` */\n devPort: number;\n /** Production URL when running as a first-party app on agent-native.com */\n prodUrl?: string;\n /** Default URL path when deployed in a workspace (defaults to \"/<name>\") */\n prodPath?: string;\n /** Default mode when added to desktop app */\n defaultMode?: \"dev\" | \"prod\";\n /** Hide from pickers but still scaffoldable via explicit --template */\n hidden?: boolean;\n /** Include as a built-in connected A2A agent even when hidden from pickers */\n defaultAgent?: boolean;\n /** Always scaffold without prompting (e.g. starter as fallback) */\n alwaysAvailable?: boolean;\n /** Internal workspace packages this template depends on (e.g. \"scheduling\") */\n requiredPackages?: string[];\n /** Core app — featured in the CLI picker, homepage, and docs gallery */\n core?: boolean;\n}\n\nexport const TEMPLATES: TemplateMeta[] = [\n {\n name: \"calendar\",\n label: \"Calendar\",\n hint: \"Agent-native Google Calendar — manage events, sync, and public booking\",\n icon: \"CalendarDays\",\n color: \"#00B5FF\",\n colorRgb: \"0 181 255\",\n devPort: 8082,\n prodUrl: \"https://calendar.agent-native.com\",\n defaultMode: \"prod\",\n requiredPackages: [\"scheduling\"],\n core: true,\n },\n {\n name: \"content\",\n label: \"Content\",\n hint: \"Agent-native Notion/Google Docs — write and organize with agent assistance\",\n icon: \"FileText\",\n color: \"#10B981\",\n colorRgb: \"16 185 129\",\n devPort: 8083,\n prodUrl: \"https://content.agent-native.com\",\n defaultMode: \"prod\",\n core: true,\n },\n {\n name: \"plan\",\n label: \"Plan\",\n hint: \"Agent-native HTML plans with diagrams, wireframes, prototypes, annotations, sharing, and proof gates\",\n icon: \"FileText\",\n color: \"#52525B\",\n colorRgb: \"82 82 91\",\n devPort: 8105,\n prodUrl: \"https://plan.agent-native.com\",\n defaultMode: \"prod\",\n core: true,\n },\n {\n name: \"slides\",\n label: \"Slides\",\n hint: \"Agent-native Google Slides — generate and edit React presentations\",\n icon: \"GalleryHorizontal\",\n color: \"#EC4899\",\n colorRgb: \"236 72 153\",\n devPort: 8086,\n prodUrl: \"https://slides.agent-native.com\",\n defaultMode: \"prod\",\n requiredPackages: [\"pinpoint\"],\n core: true,\n },\n {\n name: \"videos\",\n label: \"Video\",\n hint: \"Agent-native video editing with Remotion\",\n icon: \"Video\",\n color: \"#EF4444\",\n colorRgb: \"239 68 68\",\n devPort: 8087,\n prodUrl: \"https://videos.agent-native.com\",\n defaultMode: \"prod\",\n requiredPackages: [\"pinpoint\"],\n },\n {\n name: \"analytics\",\n label: \"Analytics\",\n hint: \"Agent-native Amplitude/Mixpanel — connect data sources, prompt for charts\",\n icon: \"BarChart2\",\n color: \"#F59E0B\",\n colorRgb: \"245 158 11\",\n devPort: 8088,\n prodUrl: \"https://analytics.agent-native.com\",\n defaultMode: \"prod\",\n core: true,\n },\n {\n name: \"mail\",\n label: \"Mail\",\n hint: \"Agent-native Superhuman — email client with keyboard shortcuts and AI triage\",\n icon: \"Mail\",\n color: \"#3B82F6\",\n colorRgb: \"59 130 246\",\n devPort: 8085,\n prodUrl: \"https://mail.agent-native.com\",\n defaultMode: \"prod\",\n core: true,\n },\n {\n name: \"dispatch\",\n label: \"Dispatch\",\n hint: \"Central Slack/Telegram router with jobs, memory, approvals, and A2A delegation\",\n icon: \"MessageCircle\",\n color: \"#14B8A6\",\n colorRgb: \"20 184 166\",\n devPort: 8092,\n prodUrl: \"https://dispatch.agent-native.com\",\n defaultMode: \"prod\",\n core: true,\n },\n {\n name: \"forms\",\n label: \"Forms\",\n hint: \"Agent-native form builder — create, edit, and manage forms\",\n icon: \"ClipboardList\",\n color: \"#06B6D4\",\n colorRgb: \"6 182 212\",\n devPort: 8084,\n prodUrl: \"https://forms.agent-native.com\",\n defaultMode: \"prod\",\n core: true,\n },\n {\n name: \"starter\",\n label: \"Starter\",\n hint: \"Minimal scaffold with the agent chat and core architecture wired up\",\n icon: \"Code\",\n color: \"#71717A\",\n colorRgb: \"113 113 122\",\n devPort: 8089,\n defaultMode: \"prod\",\n alwaysAvailable: true,\n core: true,\n hidden: true,\n },\n {\n name: \"clips\",\n label: \"Clips\",\n hint: \"Screen recording, meeting notes, and voice dictation — all with AI\",\n icon: \"ScreenShare\",\n color: \"#0EA5E9\",\n colorRgb: \"14 165 233\",\n devPort: 8094,\n prodUrl: \"https://clips.agent-native.com\",\n defaultMode: \"prod\",\n core: true,\n },\n {\n name: \"brain\",\n label: \"Brain\",\n hint: \"Cited company memory from Slack, meetings, transcripts, and decisions\",\n icon: \"Brain\",\n color: \"#8B5CF6\",\n colorRgb: \"139 92 246\",\n devPort: 8102,\n prodUrl: \"https://brain.agent-native.com\",\n defaultMode: \"prod\",\n defaultAgent: true,\n core: true,\n },\n {\n name: \"design\",\n label: \"Design\",\n hint: \"Agent-native design tool — create and edit visual designs with agent assistance\",\n icon: \"Brush\",\n color: \"#F472B6\",\n colorRgb: \"244 114 182\",\n devPort: 8099,\n prodUrl: \"https://design.agent-native.com\",\n defaultMode: \"prod\",\n requiredPackages: [\"pinpoint\", \"embedding\"],\n core: true,\n },\n {\n name: \"assets\",\n label: \"Assets\",\n hint: \"Digital asset manager — upload, organize, search, and generate on-brand images and videos\",\n icon: \"Photo\",\n color: \"#0F766E\",\n colorRgb: \"15 118 110\",\n devPort: 8100,\n prodUrl: \"https://assets.agent-native.com\",\n defaultMode: \"prod\",\n defaultAgent: true,\n core: true,\n },\n {\n name: \"macros\",\n label: \"Macros\",\n hint: \"Internal template — not shown in pickers\",\n icon: \"Code\",\n color: \"#71717A\",\n colorRgb: \"113 113 122\",\n devPort: 8093,\n prodUrl: \"https://macros.agent-native.com\",\n hidden: true,\n defaultMode: \"dev\",\n },\n];\n\n/** Return templates visible in user-facing pickers (excludes hidden). */\nexport function visibleTemplates(): TemplateMeta[] {\n return TEMPLATES.filter((t) => !t.hidden);\n}\n\n/** Return core templates — the featured set shown in CLI pickers by default. */\nexport function coreTemplates(): TemplateMeta[] {\n return TEMPLATES.filter((t) => t.core);\n}\n\n/** Lookup by name. Returns undefined for unknown names. */\nexport function getTemplate(name: string): TemplateMeta | undefined {\n // Tolerate legacy / renamed aliases.\n if (name === \"video\") name = \"videos\";\n if (name === \"image\" || name === \"images\" || name === \"asset\") {\n name = \"assets\";\n }\n if (name === \"contracts\" || name === \"visual-plans\") name = \"plan\";\n return TEMPLATES.find((t) => t.name === name);\n}\n\n/** Names of all templates (including hidden) for validation. */\nexport function allTemplateNames(): string[] {\n return TEMPLATES.map((t) => t.name);\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workspacify.d.ts","sourceRoot":"","sources":["../../src/cli/workspacify.ts"],"names":[],"mappings":"AA2BA,MAAM,WAAW,kBAAkB;IACjC,wEAAwE;IACxE,MAAM,EAAE,MAAM,CAAC;IACf,6BAA6B;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,kEAAkE;IAClE,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,+BAA+B;IAC/B,aAAa,EAAE,MAAM,CAAC;IACtB,gEAAgE;IAChE,iBAAiB,EAAE,MAAM,CAAC;IAC1B,wEAAwE;IACxE,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,+DAA+D;IAC/D,yBAAyB,CAAC,EAAE,MAAM,CAAC;CACpC;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE,kBAAkB,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"workspacify.d.ts","sourceRoot":"","sources":["../../src/cli/workspacify.ts"],"names":[],"mappings":"AA2BA,MAAM,WAAW,kBAAkB;IACjC,wEAAwE;IACxE,MAAM,EAAE,MAAM,CAAC;IACf,6BAA6B;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,kEAAkE;IAClE,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,+BAA+B;IAC/B,aAAa,EAAE,MAAM,CAAC;IACtB,gEAAgE;IAChE,iBAAiB,EAAE,MAAM,CAAC;IAC1B,wEAAwE;IACxE,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,+DAA+D;IAC/D,yBAAyB,CAAC,EAAE,MAAM,CAAC;CACpC;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE,kBAAkB,GAAG,IAAI,CA8G7D;AA2DD;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,iBAAiB,EAAE,MAAM,GAAG,MAAM,CAGrE"}
|
package/dist/cli/workspacify.js
CHANGED
|
@@ -70,6 +70,13 @@ export function workspacifyApp(opts) {
|
|
|
70
70
|
delete pkg.pnpm;
|
|
71
71
|
}
|
|
72
72
|
}
|
|
73
|
+
// Pin @assistant-ui/store and @assistant-ui/tap so pre-existing workspaces
|
|
74
|
+
// whose root pnpm-workspace.yaml pre-dates this fix are still protected.
|
|
75
|
+
// The constraints exclude the breaking store@0.2.14/tap@0.6.0 combination
|
|
76
|
+
// that causes Vite pre-bundling failures via a missing ./react-shim export.
|
|
77
|
+
pkg.devDependencies = pkg.devDependencies ?? {};
|
|
78
|
+
pkg.devDependencies["@assistant-ui/store"] ??= ">=0.2.9 <0.2.14";
|
|
79
|
+
pkg.devDependencies["@assistant-ui/tap"] ??= "^0.5.14";
|
|
73
80
|
fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2) + "\n");
|
|
74
81
|
}
|
|
75
82
|
catch {
|
|
@@ -79,12 +86,20 @@ export function workspacifyApp(opts) {
|
|
|
79
86
|
// 2) Remove standalone-only files that would confuse the workspace layout.
|
|
80
87
|
for (const f of [
|
|
81
88
|
"learnings.defaults.md",
|
|
82
|
-
//
|
|
83
|
-
//
|
|
89
|
+
// pnpm-workspace.yaml marks a directory as a pnpm workspace root.
|
|
90
|
+
// Leaving it in an app directory nested under a parent workspace causes
|
|
91
|
+
// ERR_PNPM_WORKSPACE_PKG_NOT_FOUND when the app depends on workspace:*
|
|
92
|
+
// packages (e.g. @<scope>/shared). Overrides belong at the workspace root.
|
|
93
|
+
"pnpm-workspace.yaml",
|
|
84
94
|
]) {
|
|
85
95
|
const p = path.join(appDir, f);
|
|
86
|
-
|
|
87
|
-
fs.
|
|
96
|
+
try {
|
|
97
|
+
if (fs.existsSync(p))
|
|
98
|
+
fs.unlinkSync(p);
|
|
99
|
+
}
|
|
100
|
+
catch {
|
|
101
|
+
// Non-fatal: leave the file in place.
|
|
102
|
+
}
|
|
88
103
|
}
|
|
89
104
|
// 3) Templates document action commands from the framework repo layout.
|
|
90
105
|
// Workspace apps live under apps/<name>, so point every agent at the
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workspacify.js","sourceRoot":"","sources":["../../src/cli/workspacify.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,MAAM,2BAA2B,GAAG,QAAQ,CAAC;AAmB7C,MAAM,UAAU,cAAc,CAAC,IAAwB;IACrD,MAAM,EAAE,MAAM,EAAE,iBAAiB,EAAE,GAAG,IAAI,CAAC;IAC3C,MAAM,qBAAqB,GAAG,IAAI,CAAC,qBAAqB,IAAI,QAAQ,CAAC;IACrE,MAAM,yBAAyB,GAAG,IAAI,CAAC,yBAAyB,IAAI,QAAQ,CAAC;IAE7E,oEAAoE;IACpE,qEAAqE;IACrE,4DAA4D;IAC5D,oEAAoE;IACpE,6EAA6E;IAC7E,M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,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,eAAe,CAAC,CAAC;IAC1D,EAAE,CAAC,aAAa,CACd,UAAU,EACV;QACE,UAAU;QACV,0BAA0B;QAC1B,kCAAkC;QAClC,gCAAgC;QAChC,qCAAqC;QACrC,oCAAoC,IAAI,CAAC,SAAS,CAAC,GAAG,iBAAiB,SAAS,CAAC,GAAG;QACpF,qEAAqE;QACrE,EAAE;QACF,qHAAqH;QACrH,mBAAmB;QACnB,YAAY,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,GAAG;QACpC,4DAA4D;QAC5D,qCAAqC;QACrC,EAAE;QACF,qEAAqE;QACrE,+FAA+F;QAC/F,qCAAqC;QACrC,EAAE;KACH,CAAC,IAAI,CAAC,IAAI,CAAC,CACb,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,mBAAmB,CAAC,iBAAyB;IAC3D,MAAM,CAAC,GAAG,iBAAiB,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC;IACjD,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;AACvB,CAAC","sourcesContent":["/**\n * Transform a standalone template directory into a workspace app in place.\n *\n * Called after copying any template under `apps/<name>/` inside an enterprise\n * workspace. The transform:\n *\n * 1. Rewrites package.json:\n * - @agent-native/core and package-backed apps stay as regular npm deps\n * - Adds @<workspace-scope>/shared as a workspace:* dep so the app\n * inherits shared plugins/skills/AGENTS.md via the three-layer model.\n * 2. Removes files that only make sense in standalone apps\n * (`learnings.defaults.md`, etc.).\n * 3. Replaces starter's stock auth/chat wrappers with inherited wrappers so\n * the workspace core can own those plugin slots while framework defaults\n * still mount when the workspace core is empty.\n * 4. Leaves app source code untouched. The three-layer framework\n * auto-discovers workspace-core via `agent-native.workspaceCore` in the\n * workspace root package.json — no per-app wiring needed.\n *\n * This means any first-party template under templates/* is usable as a\n * workspace app without maintaining a parallel copy.\n */\nimport fs from \"fs\";\nimport path from \"path\";\n\nconst POSTGRES_DEPENDENCY_VERSION = \"^3.4.9\";\n\nexport interface WorkspacifyOptions {\n /** Target app directory (already populated with the copied template) */\n appDir: string;\n /** App name (e.g. \"mail\") */\n appName: string;\n /** Source template name (e.g. \"starter\" when appName is \"crm\") */\n templateName?: string;\n /** Workspace root directory */\n workspaceRoot: string;\n /** Shared workspace package name (e.g. \"@my-company/shared\") */\n workspaceCoreName: string;\n /** Version range to use for the published @agent-native/core package */\n coreDependencyVersion?: string;\n /** Version range to use for the package-backed Dispatch app */\n dispatchDependencyVersion?: string;\n}\n\nexport function workspacifyApp(opts: WorkspacifyOptions): void {\n const { appDir, workspaceCoreName } = opts;\n const coreDependencyVersion = opts.coreDependencyVersion ?? \"latest\";\n const dispatchDependencyVersion = opts.dispatchDependencyVersion ?? \"latest\";\n\n // 1) Rewrite package.json to add the workspace core dep and resolve\n // @agent-native/core / @agent-native/dispatch workspace:* refs to\n // published package ranges. Other workspace:* deps (e.g.\n // @agent-native/scheduling) stay as-is — they resolve within the\n // workspace because the required package is scaffolded alongside the app.\n const pkgPath = path.join(appDir, \"package.json\");\n if (fs.existsSync(pkgPath)) {\n try {\n const pkg = JSON.parse(fs.readFileSync(pkgPath, \"utf-8\"));\n for (const depType of [\n \"dependencies\",\n \"devDependencies\",\n \"peerDependencies\",\n ] as const) {\n const deps = pkg[depType];\n if (!deps) continue;\n for (const [key, val] of Object.entries(deps)) {\n if (typeof val === \"string\" && val.startsWith(\"workspace:\")) {\n if (key === \"@agent-native/core\") {\n deps[key] = coreDependencyVersion;\n }\n if (key === \"@agent-native/dispatch\") {\n deps[key] = dispatchDependencyVersion;\n }\n }\n }\n }\n // Ensure the dependency on the workspace shared package is present.\n pkg.dependencies = pkg.dependencies ?? {};\n pkg.dependencies[workspaceCoreName] = \"workspace:*\";\n // Core loads postgres-js lazily when DATABASE_URL points at Postgres.\n // Add the runtime package to workspace apps so production bundles do\n // not fail only after a hosted Postgres database is configured.\n pkg.dependencies.postgres ??= POSTGRES_DEPENDENCY_VERSION;\n // pnpm build-script approvals belong at the workspace root. Leaving the\n // template's per-app setting in place makes pnpm warn on every install.\n if (pkg.pnpm && typeof pkg.pnpm === \"object\") {\n delete pkg.pnpm.onlyBuiltDependencies;\n if (Object.keys(pkg.pnpm).length === 0) {\n delete pkg.pnpm;\n }\n }\n fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2) + \"\\n\");\n } catch {\n // Non-fatal: leave package.json unchanged.\n }\n }\n\n // 2) Remove standalone-only files that would confuse the workspace layout.\n for (const f of [\n \"learnings.defaults.md\",\n // If the template shipped its own workspace marker / stray monorepo\n // files, strip them here too.\n ]) {\n const p = path.join(appDir, f);\n if (fs.existsSync(p)) fs.unlinkSync(p);\n }\n\n // 3) Templates document action commands from the framework repo layout.\n // Workspace apps live under apps/<name>, so point every agent at the\n // generated app directory instead.\n const agentsPath = path.join(appDir, \"AGENTS.md\");\n if (fs.existsSync(agentsPath)) {\n try {\n let content = fs.readFileSync(agentsPath, \"utf-8\");\n content = content\n .replace(\n \"The terminal cwd is the framework root. Always `cd` to this template's root before running any action:\",\n `The terminal cwd is the workspace root. Always \\`cd\\` to this app's root before running any action:`,\n )\n .replace(\n /cd templates\\/[^ \\n]+ && pnpm action/g,\n `cd apps/${opts.appName} && pnpm action`,\n );\n fs.writeFileSync(agentsPath, content);\n } catch {\n // Non-fatal: leave AGENTS.md unchanged.\n }\n }\n\n if ((opts.templateName ?? opts.appName) === \"starter\") {\n writeInheritedStarterPlugin(appDir, workspaceCoreName, {\n fileName: \"auth.ts\",\n exportName: \"defaultAuthPlugin\",\n });\n writeInheritedStarterAgentChatPlugin(\n appDir,\n workspaceCoreName,\n opts.appName,\n );\n }\n}\n\nfunction writeInheritedStarterPlugin(\n appDir: string,\n workspaceCoreName: string,\n opts: { fileName: string; exportName: string },\n): void {\n const pluginsDir = path.join(appDir, \"server\", \"plugins\");\n fs.mkdirSync(pluginsDir, { recursive: true });\n const pluginPath = path.join(pluginsDir, opts.fileName);\n fs.writeFileSync(\n pluginPath,\n [\n `import { ${opts.exportName} as frameworkDefault } from \"@agent-native/core/server\";`,\n `import * as workspaceServer from ${JSON.stringify(`${workspaceCoreName}/server`)};`,\n \"\",\n `const workspacePlugin = (workspaceServer as Record<string, unknown>).${opts.exportName};`,\n \"\",\n 'export default typeof workspacePlugin === \"function\"',\n \" ? workspacePlugin\",\n \" : frameworkDefault;\",\n \"\",\n ].join(\"\\n\"),\n );\n}\n\nfunction writeInheritedStarterAgentChatPlugin(\n appDir: string,\n workspaceCoreName: string,\n appId: string,\n): void {\n const pluginsDir = path.join(appDir, \"server\", \"plugins\");\n fs.mkdirSync(pluginsDir, { recursive: true });\n const pluginPath = path.join(pluginsDir, \"agent-chat.ts\");\n fs.writeFileSync(\n pluginPath,\n [\n `import {`,\n ` createAgentChatPlugin,`,\n ` loadActionsFromStaticRegistry,`,\n ` type AgentChatPluginOptions,`,\n `} from \"@agent-native/core/server\";`,\n `import * as workspaceServer from ${JSON.stringify(`${workspaceCoreName}/server`)};`,\n `import actionsRegistry from \"../../.generated/actions-registry.js\";`,\n \"\",\n `const createWorkspaceAgentChatPlugin = (workspaceServer as Record<string, unknown>).createWorkspaceAgentChatPlugin;`,\n `const options = {`,\n ` appId: ${JSON.stringify(appId)},`,\n ` actions: loadActionsFromStaticRegistry(actionsRegistry),`,\n `} satisfies AgentChatPluginOptions;`,\n \"\",\n `export default typeof createWorkspaceAgentChatPlugin === \"function\"`,\n ` ? (createWorkspaceAgentChatPlugin as (options: AgentChatPluginOptions) => unknown)(options)`,\n ` : createAgentChatPlugin(options);`,\n \"\",\n ].join(\"\\n\"),\n );\n}\n\n/**\n * Parse a workspace core package name into its npm scope.\n * \"@my-company/shared\" → \"my-company\"\n * \"shared\" → \"\" (no scope — shouldn't happen)\n */\nexport function parseWorkspaceScope(workspaceCoreName: string): string {\n const m = workspaceCoreName.match(/^@([^/]+)\\//);\n return m ? m[1] : \"\";\n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B;QACnB,YAAY,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,GAAG;QACpC,4DAA4D;QAC5D,qCAAqC;QACrC,EAAE;QACF,qEAAqE;QACrE,+FAA+F;QAC/F,qCAAqC;QACrC,EAAE;KACH,CAAC,IAAI,CAAC,IAAI,CAAC,CACb,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,mBAAmB,CAAC,iBAAyB;IAC3D,MAAM,CAAC,GAAG,iBAAiB,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC;IACjD,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;AACvB,CAAC","sourcesContent":["/**\n * Transform a standalone template directory into a workspace app in place.\n *\n * Called after copying any template under `apps/<name>/` inside an enterprise\n * workspace. The transform:\n *\n * 1. Rewrites package.json:\n * - @agent-native/core and package-backed apps stay as regular npm deps\n * - Adds @<workspace-scope>/shared as a workspace:* dep so the app\n * inherits shared plugins/skills/AGENTS.md via the three-layer model.\n * 2. Removes files that only make sense in standalone apps\n * (`learnings.defaults.md`, etc.).\n * 3. Replaces starter's stock auth/chat wrappers with inherited wrappers so\n * the workspace core can own those plugin slots while framework defaults\n * still mount when the workspace core is empty.\n * 4. Leaves app source code untouched. The three-layer framework\n * auto-discovers workspace-core via `agent-native.workspaceCore` in the\n * workspace root package.json — no per-app wiring needed.\n *\n * This means any first-party template under templates/* is usable as a\n * workspace app without maintaining a parallel copy.\n */\nimport fs from \"fs\";\nimport path from \"path\";\n\nconst POSTGRES_DEPENDENCY_VERSION = \"^3.4.9\";\n\nexport interface WorkspacifyOptions {\n /** Target app directory (already populated with the copied template) */\n appDir: string;\n /** App name (e.g. \"mail\") */\n appName: string;\n /** Source template name (e.g. \"starter\" when appName is \"crm\") */\n templateName?: string;\n /** Workspace root directory */\n workspaceRoot: string;\n /** Shared workspace package name (e.g. \"@my-company/shared\") */\n workspaceCoreName: string;\n /** Version range to use for the published @agent-native/core package */\n coreDependencyVersion?: string;\n /** Version range to use for the package-backed Dispatch app */\n dispatchDependencyVersion?: string;\n}\n\nexport function workspacifyApp(opts: WorkspacifyOptions): void {\n const { appDir, workspaceCoreName } = opts;\n const coreDependencyVersion = opts.coreDependencyVersion ?? \"latest\";\n const dispatchDependencyVersion = opts.dispatchDependencyVersion ?? \"latest\";\n\n // 1) Rewrite package.json to add the workspace core dep and resolve\n // @agent-native/core / @agent-native/dispatch workspace:* refs to\n // published package ranges. Other workspace:* deps (e.g.\n // @agent-native/scheduling) stay as-is — they resolve within the\n // workspace because the required package is scaffolded alongside the app.\n const pkgPath = path.join(appDir, \"package.json\");\n if (fs.existsSync(pkgPath)) {\n try {\n const pkg = JSON.parse(fs.readFileSync(pkgPath, \"utf-8\"));\n for (const depType of [\n \"dependencies\",\n \"devDependencies\",\n \"peerDependencies\",\n ] as const) {\n const deps = pkg[depType];\n if (!deps) continue;\n for (const [key, val] of Object.entries(deps)) {\n if (typeof val === \"string\" && val.startsWith(\"workspace:\")) {\n if (key === \"@agent-native/core\") {\n deps[key] = coreDependencyVersion;\n }\n if (key === \"@agent-native/dispatch\") {\n deps[key] = dispatchDependencyVersion;\n }\n }\n }\n }\n // Ensure the dependency on the workspace shared package is present.\n pkg.dependencies = pkg.dependencies ?? {};\n pkg.dependencies[workspaceCoreName] = \"workspace:*\";\n // Core loads postgres-js lazily when DATABASE_URL points at Postgres.\n // Add the runtime package to workspace apps so production bundles do\n // not fail only after a hosted Postgres database is configured.\n pkg.dependencies.postgres ??= POSTGRES_DEPENDENCY_VERSION;\n // pnpm build-script approvals belong at the workspace root. Leaving the\n // template's per-app setting in place makes pnpm warn on every install.\n if (pkg.pnpm && typeof pkg.pnpm === \"object\") {\n delete pkg.pnpm.onlyBuiltDependencies;\n if (Object.keys(pkg.pnpm).length === 0) {\n delete pkg.pnpm;\n }\n }\n // Pin @assistant-ui/store and @assistant-ui/tap so pre-existing workspaces\n // whose root pnpm-workspace.yaml pre-dates this fix are still protected.\n // The constraints exclude the breaking store@0.2.14/tap@0.6.0 combination\n // that causes Vite pre-bundling failures via a missing ./react-shim export.\n pkg.devDependencies = pkg.devDependencies ?? {};\n pkg.devDependencies[\"@assistant-ui/store\"] ??= \">=0.2.9 <0.2.14\";\n pkg.devDependencies[\"@assistant-ui/tap\"] ??= \"^0.5.14\";\n fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2) + \"\\n\");\n } catch {\n // Non-fatal: leave package.json unchanged.\n }\n }\n\n // 2) Remove standalone-only files that would confuse the workspace layout.\n for (const f of [\n \"learnings.defaults.md\",\n // pnpm-workspace.yaml marks a directory as a pnpm workspace root.\n // Leaving it in an app directory nested under a parent workspace causes\n // ERR_PNPM_WORKSPACE_PKG_NOT_FOUND when the app depends on workspace:*\n // packages (e.g. @<scope>/shared). Overrides belong at the workspace root.\n \"pnpm-workspace.yaml\",\n ]) {\n const p = path.join(appDir, f);\n try {\n if (fs.existsSync(p)) fs.unlinkSync(p);\n } catch {\n // Non-fatal: leave the file in place.\n }\n }\n\n // 3) Templates document action commands from the framework repo layout.\n // Workspace apps live under apps/<name>, so point every agent at the\n // generated app directory instead.\n const agentsPath = path.join(appDir, \"AGENTS.md\");\n if (fs.existsSync(agentsPath)) {\n try {\n let content = fs.readFileSync(agentsPath, \"utf-8\");\n content = content\n .replace(\n \"The terminal cwd is the framework root. Always `cd` to this template's root before running any action:\",\n `The terminal cwd is the workspace root. Always \\`cd\\` to this app's root before running any action:`,\n )\n .replace(\n /cd templates\\/[^ \\n]+ && pnpm action/g,\n `cd apps/${opts.appName} && pnpm action`,\n );\n fs.writeFileSync(agentsPath, content);\n } catch {\n // Non-fatal: leave AGENTS.md unchanged.\n }\n }\n\n if ((opts.templateName ?? opts.appName) === \"starter\") {\n writeInheritedStarterPlugin(appDir, workspaceCoreName, {\n fileName: \"auth.ts\",\n exportName: \"defaultAuthPlugin\",\n });\n writeInheritedStarterAgentChatPlugin(\n appDir,\n workspaceCoreName,\n opts.appName,\n );\n }\n}\n\nfunction writeInheritedStarterPlugin(\n appDir: string,\n workspaceCoreName: string,\n opts: { fileName: string; exportName: string },\n): void {\n const pluginsDir = path.join(appDir, \"server\", \"plugins\");\n fs.mkdirSync(pluginsDir, { recursive: true });\n const pluginPath = path.join(pluginsDir, opts.fileName);\n fs.writeFileSync(\n pluginPath,\n [\n `import { ${opts.exportName} as frameworkDefault } from \"@agent-native/core/server\";`,\n `import * as workspaceServer from ${JSON.stringify(`${workspaceCoreName}/server`)};`,\n \"\",\n `const workspacePlugin = (workspaceServer as Record<string, unknown>).${opts.exportName};`,\n \"\",\n 'export default typeof workspacePlugin === \"function\"',\n \" ? workspacePlugin\",\n \" : frameworkDefault;\",\n \"\",\n ].join(\"\\n\"),\n );\n}\n\nfunction writeInheritedStarterAgentChatPlugin(\n appDir: string,\n workspaceCoreName: string,\n appId: string,\n): void {\n const pluginsDir = path.join(appDir, \"server\", \"plugins\");\n fs.mkdirSync(pluginsDir, { recursive: true });\n const pluginPath = path.join(pluginsDir, \"agent-chat.ts\");\n fs.writeFileSync(\n pluginPath,\n [\n `import {`,\n ` createAgentChatPlugin,`,\n ` loadActionsFromStaticRegistry,`,\n ` type AgentChatPluginOptions,`,\n `} from \"@agent-native/core/server\";`,\n `import * as workspaceServer from ${JSON.stringify(`${workspaceCoreName}/server`)};`,\n `import actionsRegistry from \"../../.generated/actions-registry.js\";`,\n \"\",\n `const createWorkspaceAgentChatPlugin = (workspaceServer as Record<string, unknown>).createWorkspaceAgentChatPlugin;`,\n `const options = {`,\n ` appId: ${JSON.stringify(appId)},`,\n ` actions: loadActionsFromStaticRegistry(actionsRegistry),`,\n `} satisfies AgentChatPluginOptions;`,\n \"\",\n `export default typeof createWorkspaceAgentChatPlugin === \"function\"`,\n ` ? (createWorkspaceAgentChatPlugin as (options: AgentChatPluginOptions) => unknown)(options)`,\n ` : createAgentChatPlugin(options);`,\n \"\",\n ].join(\"\\n\"),\n );\n}\n\n/**\n * Parse a workspace core package name into its npm scope.\n * \"@my-company/shared\" → \"my-company\"\n * \"shared\" → \"\" (no scope — shouldn't happen)\n */\nexport function parseWorkspaceScope(workspaceCoreName: string): string {\n const m = workspaceCoreName.match(/^@([^/]+)\\//);\n return m ? m[1] : \"\";\n}\n"]}
|
|
@@ -29,6 +29,7 @@ export { tableBlock } from "./library/table.js";
|
|
|
29
29
|
export { tableSchema, tableMdx, type TableData, } from "./library/table.config.js";
|
|
30
30
|
export { codeTabsBlock } from "./library/code-tabs.js";
|
|
31
31
|
export { codeTabsSchema, codeTabsMdx, type CodeTabsData, type CodeTabsTab, } from "./library/code-tabs.config.js";
|
|
32
|
+
export { CodeSurface, HighlightedCode, prettyLanguageName, DEFAULT_CODE_MAX_LINES, } from "./library/HighlightedCode.js";
|
|
32
33
|
export { htmlBlock, HtmlReadBlock, HtmlEditBlock } from "./library/html.js";
|
|
33
34
|
export { htmlSchema, htmlMdx, type HtmlBlockData, } from "./library/html.config.js";
|
|
34
35
|
export { tabsBlock, TabsBlockReader, TabsBlockEditor } from "./library/tabs.js";
|
|
@@ -47,6 +48,8 @@ export { FileTreeRead, FileTreeEdit } from "./library/FileTreeBlock.js";
|
|
|
47
48
|
export { fileTreeSchema, fileTreeMdx, FILE_TREE_CHANGES, type FileTreeData, type FileTreeEntry, type FileTreeChange, } from "./library/file-tree.config.js";
|
|
48
49
|
export { JsonExplorerRead, JsonExplorerEdit, } from "./library/JsonExplorerBlock.js";
|
|
49
50
|
export { jsonExplorerSchema, jsonExplorerMdx, type JsonExplorerData, } from "./library/json-explorer.config.js";
|
|
51
|
+
export { AnnotatedCodeRead, AnnotatedCodeEdit, } from "./library/AnnotatedCodeBlock.js";
|
|
52
|
+
export { annotatedCodeSchema, annotatedCodeMdx, type AnnotatedCodeData, type AnnotatedCodeAnnotation, } from "./library/annotated-code.config.js";
|
|
50
53
|
export { OpenApiSpecRead, OpenApiSpecEdit, } from "./library/OpenApiSpecBlock.js";
|
|
51
54
|
export { openApiSpecSchema, openApiSpecMdx, type OpenApiSpecData, } from "./library/openapi-spec.config.js";
|
|
52
55
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/client/blocks/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,OAAO,EACL,WAAW,EACX,KAAK,SAAS,EACd,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,KAAK,kBAAkB,EACvB,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,KAAK,YAAY,EACjB,KAAK,WAAW,EAChB,KAAK,uBAAuB,EAC5B,KAAK,oBAAoB,EACzB,KAAK,kBAAkB,EACvB,KAAK,mBAAmB,GACzB,MAAM,YAAY,CAAC;AAGpB,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC9D,OAAO,EACL,qBAAqB,EACrB,gBAAgB,EAChB,wBAAwB,GACzB,MAAM,eAAe,CAAC;AAGvB,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAC7D,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAG3D,OAAO,EACL,QAAQ,EACR,QAAQ,EACR,UAAU,EACV,KAAK,SAAS,EACd,KAAK,eAAe,GACrB,MAAM,6BAA6B,CAAC;AAGrC,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;AAGlB,OAAO,EACL,sBAAsB,EACtB,8BAA8B,EAC9B,KAAK,aAAa,GACnB,MAAM,YAAY,CAAC;AAMpB,OAAO,EACL,iBAAiB,EACjB,q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AiB,EACjB,cAAc,EACd,oBAAoB,EACpB,mBAAmB,EACnB,KAAK,eAAe,EACpB,KAAK,iBAAiB,EACtB,KAAK,gBAAgB,EACrB,KAAK,kBAAkB,EACvB,KAAK,mBAAmB,EACxB,KAAK,gBAAgB,GACtB,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC3E,OAAO,EACL,eAAe,EACf,YAAY,EACZ,yBAAyB,EACzB,KAAK,aAAa,EAClB,KAAK,eAAe,EACpB,KAAK,cAAc,EACnB,KAAK,iBAAiB,EACtB,KAAK,qBAAqB,GAC3B,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,EACL,UAAU,EACV,OAAO,EACP,KAAK,QAAQ,EACb,KAAK,QAAQ,GACd,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AACxE,OAAO,EACL,cAAc,EACd,WAAW,EACX,iBAAiB,EACjB,KAAK,YAAY,EACjB,KAAK,aAAa,EAClB,KAAK,cAAc,GACpB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACL,gBAAgB,EAChB,gBAAgB,GACjB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EACL,kBAAkB,EAClB,eAAe,EACf,KAAK,gBAAgB,GACtB,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EACL,eAAe,EACf,eAAe,GAChB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACL,iBAAiB,EACjB,cAAc,EACd,KAAK,eAAe,GACrB,MAAM,kCAAkC,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/client/blocks/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,OAAO,EACL,WAAW,EACX,KAAK,SAAS,EACd,KAAK,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tB,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC3E,OAAO,EACL,eAAe,EACf,YAAY,EACZ,yBAAyB,EACzB,KAAK,aAAa,EAClB,KAAK,eAAe,EACpB,KAAK,cAAc,EACnB,KAAK,iBAAiB,EACtB,KAAK,qBAAqB,GAC3B,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,EACL,UAAU,EACV,OAAO,EACP,KAAK,QAAQ,EACb,KAAK,QAAQ,GACd,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AACxE,OAAO,EACL,cAAc,EACd,WAAW,EACX,iBAAiB,EACjB,KAAK,YAAY,EACjB,KAAK,aAAa,EAClB,KAAK,cAAc,GACpB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACL,gBAAgB,EAChB,gBAAgB,GACjB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EACL,kBAAkB,EAClB,eAAe,EACf,KAAK,gBAAgB,GACtB,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EACL,iBAAiB,EACjB,iBAAiB,GAClB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EACL,mBAAmB,EACnB,gBAAgB,EAChB,KAAK,iBAAiB,EACtB,KAAK,uBAAuB,GAC7B,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EACL,eAAe,EACf,eAAe,GAChB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACL,iBAAiB,EACjB,cAAc,EACd,KAAK,eAAe,GACrB,MAAM,kCAAkC,CAAC"}
|
|
@@ -41,6 +41,7 @@ export { tableBlock } from "./library/table.js";
|
|
|
41
41
|
export { tableSchema, tableMdx, } from "./library/table.config.js";
|
|
42
42
|
export { codeTabsBlock } from "./library/code-tabs.js";
|
|
43
43
|
export { codeTabsSchema, codeTabsMdx, } from "./library/code-tabs.config.js";
|
|
44
|
+
export { CodeSurface, HighlightedCode, prettyLanguageName, DEFAULT_CODE_MAX_LINES, } from "./library/HighlightedCode.js";
|
|
44
45
|
export { htmlBlock, HtmlReadBlock, HtmlEditBlock } from "./library/html.js";
|
|
45
46
|
export { htmlSchema, htmlMdx, } from "./library/html.config.js";
|
|
46
47
|
export { tabsBlock, TabsBlockReader, TabsBlockEditor } from "./library/tabs.js";
|
|
@@ -63,6 +64,8 @@ export { FileTreeRead, FileTreeEdit } from "./library/FileTreeBlock.js";
|
|
|
63
64
|
export { fileTreeSchema, fileTreeMdx, FILE_TREE_CHANGES, } from "./library/file-tree.config.js";
|
|
64
65
|
export { JsonExplorerRead, JsonExplorerEdit, } from "./library/JsonExplorerBlock.js";
|
|
65
66
|
export { jsonExplorerSchema, jsonExplorerMdx, } from "./library/json-explorer.config.js";
|
|
67
|
+
export { AnnotatedCodeRead, AnnotatedCodeEdit, } from "./library/AnnotatedCodeBlock.js";
|
|
68
|
+
export { annotatedCodeSchema, annotatedCodeMdx, } from "./library/annotated-code.config.js";
|
|
66
69
|
export { OpenApiSpecRead, OpenApiSpecEdit, } from "./library/OpenApiSpecBlock.js";
|
|
67
70
|
export { openApiSpecSchema, openApiSpecMdx, } from "./library/openapi-spec.config.js";
|
|
68
71
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/client/blocks/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,oBAAoB;AACpB,OAAO,EACL,WAAW,GAcZ,MAAM,YAAY,CAAC;AAEpB,0BAA0B;AAC1B,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC9D,OAAO,EACL,qBAAqB,EACrB,gBAAgB,EAChB,wBAAwB,GACzB,MAAM,eAAe,CAAC;AAEvB,YAAY;AACZ,OAAO,EAAE,SA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,CAAC;AAClC,OAAO,EACL,YAAY,EACZ,kBAAkB,EAClB,kBAAkB,GACnB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,aAAa,EACb,UAAU,GAGX,MAAM,6BAA6B,CAAC;AAErC,0EAA0E;AAC1E,gFAAgF;AAChF,uEAAuE;AACvE,qDAAqD;AACrD,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACrE,OAAO,EACL,aAAa,EACb,UAAU,GAEX,MAAM,6BAA6B,CAAC;AACrC,OAAO,EACL,eAAe,EACf,eAAe,GAChB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACL,iBAAiB,EACjB,cAAc,EACd,oBAAoB,EACpB,mBAAmB,GAOpB,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC3E,OAAO,EACL,eAAe,EACf,YAAY,EACZ,yBAAyB,GAM1B,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,EACL,UAAU,EACV,OAAO,GAGR,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AACxE,OAAO,EACL,cAAc,EACd,WAAW,EACX,iBAAiB,GAIlB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACL,gBAAgB,EAChB,gBAAgB,GACjB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EACL,kBAAkB,EAClB,eAAe,GAEhB,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EACL,eAAe,EACf,eAAe,GAChB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACL,iBAAiB,EACjB,cAAc,GAEf,MAAM,kCAAkC,CAAC","sourcesContent":["/**\n * `@agent-native/core/blocks` — the first-party block registry.\n *\n * A block registry unifies structured document blocks under one `defineBlock`\n * contract: a zod `schema` for the data, an `mdx` config for byte-stable MDX\n * round-trip, a `Read` renderer, an optional `Edit` (auto-generated from the\n * schema when omitted), and `placement` (top-level and/or inline). Apps create a\n * `BlockRegistry`, register the core standard library plus their own specs, and\n * render through `BlockView` inside a `BlockRegistryProvider`. The renderer\n * checks the registry first and falls back to legacy code for unregistered\n * types, so existing documents keep working unchanged.\n *\n * This entry includes the React surface. For server/agent code that must stay\n * React-free, import from `@agent-native/core/blocks/server`.\n */\n\n// Types + authoring\nexport {\n defineBlock,\n type BlockSpec,\n type BlockPlacement,\n type BlockMdxConfig,\n type BlockAttrReader,\n type BlockRenderContext,\n type BlockReadProps,\n type BlockEditProps,\n type MdxAttrValue,\n type NestedBlock,\n type BlockAiFieldActionProps,\n type BlockContainerRegion,\n type BlockContainerSpec,\n type BlockDataChangeMeta,\n} from \"./types.js\";\n\n// Registry + provisioning\nexport { BlockRegistry, registerBlocks } from \"./registry.js\";\nexport {\n BlockRegistryProvider,\n useBlockRegistry,\n useOptionalBlockRegistry,\n} from \"./provider.js\";\n\n// Rendering\nexport { BlockView, blockEditSurface } from \"./BlockView.js\";\nexport { AiEditableFieldLabel } from \"./AiEditableField.js\";\nexport { SchemaBlockEditor } from \"./SchemaBlockEditor.js\";\n\n// Schema-form helpers\nexport {\n markdown,\n richtext,\n introspect,\n type FieldKind,\n type FieldDescriptor,\n} from \"./schema-form/introspect.js\";\n\n// MDX round-trip (registry-driven serialize/parse + shared encoder primitives)\nexport {\n prop,\n escapeAttr,\n jsonExpression,\n attributeValue,\n createAttrReader,\n serializeSpecBlock,\n parseSpecBlock,\n type MdxJsxNode,\n type MdxAttrNode,\n type SerializableBlock,\n type ParsedBlockBase,\n} from \"./mdx.js\";\n\n// Agent schema export\nexport {\n describeBlocksForAgent,\n renderBlockVocabularyReference,\n type BlockAgentDoc,\n} from \"./agent.js\";\n\n// Standard library registration. Apps call `registerLibraryBlocks(registry)` to\n// register the whole standard library (the pre-built specs + dev-doc specs) in\n// one place, then register only their app-specific blocks on top.\n// `libraryBlockSpecs` is the underlying ordered array.\nexport {\n libraryBlockSpecs,\n registerLibraryBlocks,\n type LibraryBlockOverrides,\n} from \"./library/specs.js\";\n\n// Standard block library (React specs). Apps register these in their browser\n// registry alongside their own app-specific blocks.\nexport {\n checklistBlock,\n ChecklistBlock,\n ChecklistEditor,\n} from \"./library/checklist.js\";\nexport {\n checklistSchema,\n checklistMdx,\n type ChecklistData,\n type ChecklistItem,\n} from \"./library/checklist.config.js\";\nexport { tableBlock } from \"./library/table.js\";\nexport {\n tableSchema,\n tableMdx,\n type TableData,\n} from \"./library/table.config.js\";\nexport { codeTabsBlock } from \"./library/code-tabs.js\";\nexport {\n codeTabsSchema,\n codeTabsMdx,\n type CodeTabsData,\n type CodeTabsTab,\n} from \"./library/code-tabs.config.js\";\nexport { htmlBlock, HtmlReadBlock, HtmlEditBlock } from \"./library/html.js\";\nexport {\n htmlSchema,\n htmlMdx,\n type HtmlBlockData,\n} from \"./library/html.config.js\";\nexport { tabsBlock, TabsBlockReader, TabsBlockEditor } from \"./library/tabs.js\";\nexport {\n tabsSchema,\n tabsMdx,\n type TabsData,\n type TabsOrientation,\n type TabsTab,\n} from \"./library/tabs.config.js\";\nexport {\n columnsBlock,\n ColumnsBlockReader,\n ColumnsBlockEditor,\n} from \"./library/columns.js\";\nexport {\n columnsSchema,\n columnsMdx,\n type ColumnsData,\n type ColumnsColumn,\n} from \"./library/columns.config.js\";\n\n// Dev-doc block library (React `Read`/`Edit` renderers + their React-free\n// schema/MDX config). Apps register these alongside their own blocks, supplying\n// app-specific spec metadata (label/description/editSurface/empty) via\n// `defineBlock`. Mirrors the standard library above.\nexport { MermaidRead, MermaidEdit } from \"./library/MermaidBlock.js\";\nexport {\n mermaidSchema,\n mermaidMdx,\n type MermaidData,\n} from \"./library/mermaid.config.js\";\nexport {\n ApiEndpointRead,\n ApiEndpointEdit,\n} from \"./library/ApiEndpointBlock.js\";\nexport {\n apiEndpointSchema,\n apiEndpointMdx,\n API_ENDPOINT_METHODS,\n API_PARAM_LOCATIONS,\n type ApiEndpointData,\n type ApiEndpointMethod,\n type ApiEndpointParam,\n type ApiEndpointRequest,\n type ApiEndpointResponse,\n type ApiParamLocation,\n} from \"./library/api-endpoint.config.js\";\nexport { DataModelRead, DataModelEdit } from \"./library/DataModelBlock.js\";\nexport {\n dataModelSchema,\n dataModelMdx,\n DATA_MODEL_RELATION_KINDS,\n type DataModelData,\n type DataModelEntity,\n type DataModelField,\n type DataModelRelation,\n type DataModelRelationKind,\n} from \"./library/data-model.config.js\";\nexport { DiffRead, DiffEdit } from \"./library/DiffBlock.js\";\nexport {\n diffSchema,\n diffMdx,\n type DiffData,\n type DiffMode,\n} from \"./library/diff.config.js\";\nexport { FileTreeRead, FileTreeEdit } from \"./library/FileTreeBlock.js\";\nexport {\n fileTreeSchema,\n fileTreeMdx,\n FILE_TREE_CHANGES,\n type FileTreeData,\n type FileTreeEntry,\n type FileTreeChange,\n} from \"./library/file-tree.config.js\";\nexport {\n JsonExplorerRead,\n JsonExplorerEdit,\n} from \"./library/JsonExplorerBlock.js\";\nexport {\n jsonExplorerSchema,\n jsonExplorerMdx,\n type JsonExplorerData,\n} from \"./library/json-explorer.config.js\";\nexport {\n OpenApiSpecRead,\n OpenApiSpecEdit,\n} from \"./library/OpenApiSpecBlock.js\";\nexport {\n openApiSpecSchema,\n openApiSpecMdx,\n type OpenApiSpecData,\n} from \"./library/openapi-spec.config.js\";\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/client/blocks/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,oBAAoB;AACpB,OAAO,EACL,WAAW,GAcZ,MAAM,YAAY,CAAC;AAEpB,0BAA0B;AAC1B,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC9D,OAAO,EACL,qBAAqB,EACrB,gBAAgB,EAChB,wBAAwB,GACzB,MAAM,eAAe,CAAC;AAEvB,YAA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B,GAGjB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EACL,eAAe,EACf,eAAe,GAChB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACL,iBAAiB,EACjB,cAAc,GAEf,MAAM,kCAAkC,CAAC","sourcesContent":["/**\n * `@agent-native/core/blocks` — the first-party block registry.\n *\n * A block registry unifies structured document blocks under one `defineBlock`\n * contract: a zod `schema` for the data, an `mdx` config for byte-stable MDX\n * round-trip, a `Read` renderer, an optional `Edit` (auto-generated from the\n * schema when omitted), and `placement` (top-level and/or inline). Apps create a\n * `BlockRegistry`, register the core standard library plus their own specs, and\n * render through `BlockView` inside a `BlockRegistryProvider`. The renderer\n * checks the registry first and falls back to legacy code for unregistered\n * types, so existing documents keep working unchanged.\n *\n * This entry includes the React surface. For server/agent code that must stay\n * React-free, import from `@agent-native/core/blocks/server`.\n */\n\n// Types + authoring\nexport {\n defineBlock,\n type BlockSpec,\n type BlockPlacement,\n type BlockMdxConfig,\n type BlockAttrReader,\n type BlockRenderContext,\n type BlockReadProps,\n type BlockEditProps,\n type MdxAttrValue,\n type NestedBlock,\n type BlockAiFieldActionProps,\n type BlockContainerRegion,\n type BlockContainerSpec,\n type BlockDataChangeMeta,\n} from \"./types.js\";\n\n// Registry + provisioning\nexport { BlockRegistry, registerBlocks } from \"./registry.js\";\nexport {\n BlockRegistryProvider,\n useBlockRegistry,\n useOptionalBlockRegistry,\n} from \"./provider.js\";\n\n// Rendering\nexport { BlockView, blockEditSurface } from \"./BlockView.js\";\nexport { AiEditableFieldLabel } from \"./AiEditableField.js\";\nexport { SchemaBlockEditor } from \"./SchemaBlockEditor.js\";\n\n// Schema-form helpers\nexport {\n markdown,\n richtext,\n introspect,\n type FieldKind,\n type FieldDescriptor,\n} from \"./schema-form/introspect.js\";\n\n// MDX round-trip (registry-driven serialize/parse + shared encoder primitives)\nexport {\n prop,\n escapeAttr,\n jsonExpression,\n attributeValue,\n createAttrReader,\n serializeSpecBlock,\n parseSpecBlock,\n type MdxJsxNode,\n type MdxAttrNode,\n type SerializableBlock,\n type ParsedBlockBase,\n} from \"./mdx.js\";\n\n// Agent schema export\nexport {\n describeBlocksForAgent,\n renderBlockVocabularyReference,\n type BlockAgentDoc,\n} from \"./agent.js\";\n\n// Standard library registration. Apps call `registerLibraryBlocks(registry)` to\n// register the whole standard library (the pre-built specs + dev-doc specs) in\n// one place, then register only their app-specific blocks on top.\n// `libraryBlockSpecs` is the underlying ordered array.\nexport {\n libraryBlockSpecs,\n registerLibraryBlocks,\n type LibraryBlockOverrides,\n} from \"./library/specs.js\";\n\n// Standard block library (React specs). Apps register these in their browser\n// registry alongside their own app-specific blocks.\nexport {\n checklistBlock,\n ChecklistBlock,\n ChecklistEditor,\n} from \"./library/checklist.js\";\nexport {\n checklistSchema,\n checklistMdx,\n type ChecklistData,\n type ChecklistItem,\n} from \"./library/checklist.config.js\";\nexport { tableBlock } from \"./library/table.js\";\nexport {\n tableSchema,\n tableMdx,\n type TableData,\n} from \"./library/table.config.js\";\nexport { codeTabsBlock } from \"./library/code-tabs.js\";\nexport {\n codeTabsSchema,\n codeTabsMdx,\n type CodeTabsData,\n type CodeTabsTab,\n} from \"./library/code-tabs.config.js\";\nexport {\n CodeSurface,\n HighlightedCode,\n prettyLanguageName,\n DEFAULT_CODE_MAX_LINES,\n} from \"./library/HighlightedCode.js\";\nexport { htmlBlock, HtmlReadBlock, HtmlEditBlock } from \"./library/html.js\";\nexport {\n htmlSchema,\n htmlMdx,\n type HtmlBlockData,\n} from \"./library/html.config.js\";\nexport { tabsBlock, TabsBlockReader, TabsBlockEditor } from \"./library/tabs.js\";\nexport {\n tabsSchema,\n tabsMdx,\n type TabsData,\n type TabsOrientation,\n type TabsTab,\n} from \"./library/tabs.config.js\";\nexport {\n columnsBlock,\n ColumnsBlockReader,\n ColumnsBlockEditor,\n} from \"./library/columns.js\";\nexport {\n columnsSchema,\n columnsMdx,\n type ColumnsData,\n type ColumnsColumn,\n} from \"./library/columns.config.js\";\n\n// Dev-doc block library (React `Read`/`Edit` renderers + their React-free\n// schema/MDX config). Apps register these alongside their own blocks, supplying\n// app-specific spec metadata (label/description/editSurface/empty) via\n// `defineBlock`. Mirrors the standard library above.\nexport { MermaidRead, MermaidEdit } from \"./library/MermaidBlock.js\";\nexport {\n mermaidSchema,\n mermaidMdx,\n type MermaidData,\n} from \"./library/mermaid.config.js\";\nexport {\n ApiEndpointRead,\n ApiEndpointEdit,\n} from \"./library/ApiEndpointBlock.js\";\nexport {\n apiEndpointSchema,\n apiEndpointMdx,\n API_ENDPOINT_METHODS,\n API_PARAM_LOCATIONS,\n type ApiEndpointData,\n type ApiEndpointMethod,\n type ApiEndpointParam,\n type ApiEndpointRequest,\n type ApiEndpointResponse,\n type ApiParamLocation,\n} from \"./library/api-endpoint.config.js\";\nexport { DataModelRead, DataModelEdit } from \"./library/DataModelBlock.js\";\nexport {\n dataModelSchema,\n dataModelMdx,\n DATA_MODEL_RELATION_KINDS,\n type DataModelData,\n type DataModelEntity,\n type DataModelField,\n type DataModelRelation,\n type DataModelRelationKind,\n} from \"./library/data-model.config.js\";\nexport { DiffRead, DiffEdit } from \"./library/DiffBlock.js\";\nexport {\n diffSchema,\n diffMdx,\n type DiffData,\n type DiffMode,\n} from \"./library/diff.config.js\";\nexport { FileTreeRead, FileTreeEdit } from \"./library/FileTreeBlock.js\";\nexport {\n fileTreeSchema,\n fileTreeMdx,\n FILE_TREE_CHANGES,\n type FileTreeData,\n type FileTreeEntry,\n type FileTreeChange,\n} from \"./library/file-tree.config.js\";\nexport {\n JsonExplorerRead,\n JsonExplorerEdit,\n} from \"./library/JsonExplorerBlock.js\";\nexport {\n jsonExplorerSchema,\n jsonExplorerMdx,\n type JsonExplorerData,\n} from \"./library/json-explorer.config.js\";\nexport {\n AnnotatedCodeRead,\n AnnotatedCodeEdit,\n} from \"./library/AnnotatedCodeBlock.js\";\nexport {\n annotatedCodeSchema,\n annotatedCodeMdx,\n type AnnotatedCodeData,\n type AnnotatedCodeAnnotation,\n} from \"./library/annotated-code.config.js\";\nexport {\n OpenApiSpecRead,\n OpenApiSpecEdit,\n} from \"./library/OpenApiSpecBlock.js\";\nexport {\n openApiSpecSchema,\n openApiSpecMdx,\n type OpenApiSpecData,\n} from \"./library/openapi-spec.config.js\";\n"]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { BlockEditProps, BlockReadProps } from "../types.js";
|
|
2
|
+
import type { AnnotatedCodeData } from "./annotated-code.config.js";
|
|
3
|
+
declare function AnnotatedCodeRead({ data, blockId, title, summary, ctx, }: BlockReadProps<AnnotatedCodeData>): import("react/jsx-runtime").JSX.Element;
|
|
4
|
+
declare function AnnotatedCodeEdit({ data, onChange, editable, }: BlockEditProps<AnnotatedCodeData>): import("react/jsx-runtime").JSX.Element;
|
|
5
|
+
export { AnnotatedCodeRead, AnnotatedCodeEdit };
|
|
6
|
+
//# sourceMappingURL=AnnotatedCodeBlock.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AnnotatedCodeBlock.d.ts","sourceRoot":"","sources":["../../../../src/client/blocks/library/AnnotatedCodeBlock.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAClE,OAAO,KAAK,EAEV,iBAAiB,EAClB,MAAM,4BAA4B,CAAC;AAsEpC,iBAAS,iBAAiB,CAAC,EACzB,IAAI,EACJ,OAAO,EACP,KAAK,EACL,OAAO,EACP,GAAG,GACJ,EAAE,cAAc,CAAC,iBAAiB,CAAC,2CA2KnC;AAMD,iBAAS,iBAAiB,CAAC,EACzB,IAAI,EACJ,QAAQ,EACR,QAAQ,GACT,EAAE,cAAc,CAAC,iBAAiB,CAAC,2CAiJnC;AAED,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,CAAC"}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useMemo, useState } from "react";
|
|
3
|
+
import { IconCode, IconPlus, IconTrash } from "@tabler/icons-react";
|
|
4
|
+
import { cn } from "../../utils.js";
|
|
5
|
+
import { highlightCode, inferLanguageFromFilename, normalizeCodeLanguage, } from "./code-highlight.js";
|
|
6
|
+
import { DevInput, DevLabel, DevTextarea } from "./dev-doc-ui.js";
|
|
7
|
+
/**
|
|
8
|
+
* "Explain this code" walkthrough block: a standard syntax-highlighted code
|
|
9
|
+
* surface on the left with line-anchored annotation cards on the right (the
|
|
10
|
+
* Stripe-docs / Sourcegraph layout). Each annotated line range gets a subtle
|
|
11
|
+
* highlight band + an accent rail down the gutter; its card shows the `lines`
|
|
12
|
+
* range, optional `label`, and the always-visible markdown `note` (via
|
|
13
|
+
* `ctx.renderMarkdown`). Hovering a card highlights its lines and vice-versa.
|
|
14
|
+
*
|
|
15
|
+
* Syntax highlighting reuses the shared `highlightCode` lowlight helper (the same
|
|
16
|
+
* colorful palette as the `code-tabs` block) per line, so it matches the app's
|
|
17
|
+
* standard code styling and supports per-line bands without an async loader. The
|
|
18
|
+
* surface uses the plan `--plan-code*`/`--plan-*` tokens and Tailwind `dark:`
|
|
19
|
+
* pairs, so it reads correctly in BOTH light and dark mode. Code lines render as
|
|
20
|
+
* `<span>`s (never one `<pre>` per line) so they don't pick up document
|
|
21
|
+
* code/pre chrome. Lives in core so any app can register the dev-doc block.
|
|
22
|
+
*
|
|
23
|
+
* Editing is panel-driven (config-style, like the diff/HTML blocks): a monospace
|
|
24
|
+
* code Textarea, filename/language Inputs, and add/remove-able annotation rows.
|
|
25
|
+
*/
|
|
26
|
+
/* ── Line-ref parsing ──────────────────────────────────────────────────────── */
|
|
27
|
+
/**
|
|
28
|
+
* Parse a 1-based `lines` ref (`"3"` or `"3-5"`) into an inclusive `[start,end]`
|
|
29
|
+
* pair, clamped to `[1, lineCount]`. Returns `null` for malformed or fully
|
|
30
|
+
* out-of-range refs so callers can ignore them gracefully. A reversed range
|
|
31
|
+
* (`"5-3"`) is normalized; a partially out-of-range range is clamped.
|
|
32
|
+
*/
|
|
33
|
+
function parseLineRange(ref, lineCount) {
|
|
34
|
+
const match = /^\s*(\d+)\s*(?:-\s*(\d+)\s*)?$/.exec(ref);
|
|
35
|
+
if (!match)
|
|
36
|
+
return null;
|
|
37
|
+
let start = Number.parseInt(match[1], 10);
|
|
38
|
+
let end = match[2] != null ? Number.parseInt(match[2], 10) : start;
|
|
39
|
+
if (!Number.isFinite(start) || !Number.isFinite(end))
|
|
40
|
+
return null;
|
|
41
|
+
if (start > end)
|
|
42
|
+
[start, end] = [end, start];
|
|
43
|
+
// Fully outside the file → ignore.
|
|
44
|
+
if (end < 1 || start > lineCount)
|
|
45
|
+
return null;
|
|
46
|
+
return { start: Math.max(1, start), end: Math.min(lineCount, end) };
|
|
47
|
+
}
|
|
48
|
+
/** Human label for a resolved annotation's line span ("Line 8" / "Lines 3–6"). */
|
|
49
|
+
function rangeLabel(item) {
|
|
50
|
+
if (!item.range)
|
|
51
|
+
return `Lines ${item.annotation.lines}`;
|
|
52
|
+
return item.range.start === item.range.end
|
|
53
|
+
? `Line ${item.range.start}`
|
|
54
|
+
: `Lines ${item.range.start}–${item.range.end}`;
|
|
55
|
+
}
|
|
56
|
+
/* ── Read ──────────────────────────────────────────────────────────────────── */
|
|
57
|
+
function AnnotatedCodeRead({ data, blockId, title, summary, ctx, }) {
|
|
58
|
+
const [activeIndex, setActiveIndex] = useState(null);
|
|
59
|
+
const lines = useMemo(() => data.code.replace(/\n$/, "").split("\n"), [data.code]);
|
|
60
|
+
const lineCount = lines.length;
|
|
61
|
+
const language = useMemo(() => normalizeCodeLanguage(data.language) ??
|
|
62
|
+
inferLanguageFromFilename(data.filename), [data.language, data.filename]);
|
|
63
|
+
// Highlight each line once; empty lines keep their height with a NBSP.
|
|
64
|
+
const highlightedLines = useMemo(() => lines.map((text) => (text.length ? highlightCode(text, language) : " ")), [lines, language]);
|
|
65
|
+
const resolved = useMemo(() => (data.annotations ?? []).map((annotation, index) => ({
|
|
66
|
+
index,
|
|
67
|
+
marker: index + 1,
|
|
68
|
+
annotation,
|
|
69
|
+
range: parseLineRange(annotation.lines, lineCount),
|
|
70
|
+
})), [data.annotations, lineCount]);
|
|
71
|
+
// line number (1-based) → resolved annotations covering it.
|
|
72
|
+
const lineMarkers = useMemo(() => {
|
|
73
|
+
const map = new Map();
|
|
74
|
+
for (const item of resolved) {
|
|
75
|
+
if (!item.range)
|
|
76
|
+
continue;
|
|
77
|
+
for (let n = item.range.start; n <= item.range.end; n += 1) {
|
|
78
|
+
const list = map.get(n) ?? [];
|
|
79
|
+
list.push(item);
|
|
80
|
+
map.set(n, list);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
return map;
|
|
84
|
+
}, [resolved]);
|
|
85
|
+
const sideAnnotations = resolved.filter((item) => item.range);
|
|
86
|
+
const hasAnnotations = sideAnnotations.length > 0;
|
|
87
|
+
const langChip = data.language?.trim();
|
|
88
|
+
const codeSurface = (_jsxs("div", { className: "overflow-hidden rounded-xl border border-plan-line bg-plan-code", children: [(data.filename || langChip) && (_jsxs("div", { className: "flex items-center gap-2 border-b border-plan-line bg-plan-block/50 px-3.5 py-2", children: [_jsx(IconCode, { className: "size-3.5 shrink-0 text-plan-muted" }), _jsx("span", { className: "min-w-0 flex-1 truncate font-mono text-[13px] font-medium text-plan-code-text", children: data.filename || "snippet" }), langChip && (_jsx("span", { className: "shrink-0 rounded border border-plan-line px-1.5 py-0.5 font-mono text-[10px] uppercase tracking-wide text-plan-muted", children: langChip }))] })), _jsx("div", { className: "overflow-x-auto py-1.5", children: _jsx("div", { className: "min-w-full font-mono text-[12.5px] leading-[22px]", children: lines.map((_text, idx) => {
|
|
89
|
+
const lineNo = idx + 1;
|
|
90
|
+
const markers = lineMarkers.get(lineNo);
|
|
91
|
+
const isAnnotated = !!markers?.length;
|
|
92
|
+
const isActive = activeIndex != null &&
|
|
93
|
+
!!markers?.some((m) => m.index === activeIndex);
|
|
94
|
+
return (_jsxs("div", { className: cn("flex w-full", isActive
|
|
95
|
+
? "bg-amber-400/20 dark:bg-amber-300/15"
|
|
96
|
+
: isAnnotated
|
|
97
|
+
? "bg-amber-400/[0.07] dark:bg-amber-300/[0.07]"
|
|
98
|
+
: null), onMouseEnter: isAnnotated && markers
|
|
99
|
+
? () => setActiveIndex(markers[0].index)
|
|
100
|
+
: undefined, onMouseLeave: isAnnotated ? () => setActiveIndex(null) : undefined, children: [_jsx("span", { "aria-hidden": true, className: cn("w-[3px] shrink-0 self-stretch", isAnnotated
|
|
101
|
+
? isActive
|
|
102
|
+
? "bg-amber-500 dark:bg-amber-400"
|
|
103
|
+
: "bg-amber-400/45 dark:bg-amber-300/35"
|
|
104
|
+
: null) }), _jsx("span", { className: "w-11 shrink-0 select-none px-3 text-right text-[11px] tabular-nums text-plan-muted/60", children: lineNo }), _jsx("span", { className: "flex-1 whitespace-pre pr-4 text-plan-code-text", children: highlightedLines[idx] })] }, lineNo));
|
|
105
|
+
}) }) })] }));
|
|
106
|
+
return (_jsxs("section", { className: "plan-block", "data-block-id": blockId, children: [title && _jsx("div", { className: "plan-block-label", children: title }), hasAnnotations ? (_jsxs("div", { className: "grid items-start gap-3 md:grid-cols-[minmax(0,1fr)_minmax(190px,250px)]", children: [codeSurface, _jsx("div", { className: "flex flex-col gap-2.5", children: sideAnnotations.map((item) => {
|
|
107
|
+
const isActive = activeIndex === item.index;
|
|
108
|
+
return (_jsxs("div", { onMouseEnter: () => setActiveIndex(item.index), onMouseLeave: () => setActiveIndex(null), className: cn("rounded-lg border px-3.5 py-2.5 transition-colors", isActive
|
|
109
|
+
? "border-amber-400/70 bg-amber-50 dark:border-amber-300/40 dark:bg-amber-300/[0.08]"
|
|
110
|
+
: "border-plan-line bg-plan-block/40 hover:border-amber-400/50"), children: [_jsxs("div", { className: "flex flex-wrap items-baseline gap-x-2 gap-y-0.5", children: [_jsx("span", { className: "text-[11px] font-semibold uppercase tracking-wide text-plan-muted", children: rangeLabel(item) }), item.annotation.label && (_jsx("span", { className: "text-[13px] font-semibold text-plan-text", children: item.annotation.label }))] }), _jsx("div", { className: "plan-annotation-note mt-1 text-[13px] leading-relaxed text-plan-text/85", children: ctx.renderMarkdown ? (ctx.renderMarkdown(item.annotation.note)) : (_jsx("p", { children: item.annotation.note })) })] }, item.index));
|
|
111
|
+
}) })] })) : (codeSurface), summary && _jsx("p", { className: "mt-5 text-plan-muted", children: summary })] }));
|
|
112
|
+
}
|
|
113
|
+
/* ── Edit (panel) ──────────────────────────────────────────────────────────── */
|
|
114
|
+
const codeAreaClass = "min-h-[160px] font-mono text-xs leading-5";
|
|
115
|
+
function AnnotatedCodeEdit({ data, onChange, editable, }) {
|
|
116
|
+
const annotations = data.annotations ?? [];
|
|
117
|
+
const patch = (next) => onChange({ ...data, ...next });
|
|
118
|
+
const updateAnnotation = (index, next) => patch({
|
|
119
|
+
annotations: annotations.map((annotation, i) => i === index ? { ...annotation, ...next } : annotation),
|
|
120
|
+
});
|
|
121
|
+
const removeAnnotation = (index) => patch({ annotations: annotations.filter((_, i) => i !== index) });
|
|
122
|
+
const addAnnotation = () => {
|
|
123
|
+
if (annotations.length >= 80)
|
|
124
|
+
return; // schema max
|
|
125
|
+
patch({
|
|
126
|
+
annotations: [...annotations, { lines: "1", label: "", note: "" }],
|
|
127
|
+
});
|
|
128
|
+
};
|
|
129
|
+
return (_jsxs("div", { className: "flex flex-col gap-3", "data-plan-interactive": true, children: [_jsxs("div", { className: "grid gap-3 sm:grid-cols-2", children: [_jsxs("div", { className: "flex flex-col gap-1.5", children: [_jsx(DevLabel, { htmlFor: "annotated-code-filename", className: "text-xs", children: "Filename" }), _jsx(DevInput, { id: "annotated-code-filename", value: data.filename ?? "", placeholder: "src/server/auth.ts", disabled: !editable, onChange: (event) => patch({ filename: event.target.value || undefined }) })] }), _jsxs("div", { className: "flex flex-col gap-1.5", children: [_jsx(DevLabel, { htmlFor: "annotated-code-language", className: "text-xs", children: "Language" }), _jsx(DevInput, { id: "annotated-code-language", value: data.language ?? "", placeholder: "ts", disabled: !editable, onChange: (event) => patch({ language: event.target.value || undefined }) })] })] }), _jsxs("div", { className: "flex flex-col gap-1.5", children: [_jsx(DevLabel, { htmlFor: "annotated-code-code", className: "text-xs", children: "Code" }), _jsx(DevTextarea, { id: "annotated-code-code", spellCheck: false, className: codeAreaClass, value: data.code, disabled: !editable, onChange: (event) => patch({ code: event.target.value }) })] }), _jsxs("div", { className: "flex flex-col gap-2", children: [_jsxs("div", { className: "flex items-center justify-between", children: [_jsx(DevLabel, { className: "text-xs", children: "Annotations" }), editable && annotations.length < 80 && (_jsxs("button", { type: "button", "data-plan-interactive": true, onClick: addAnnotation, 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", children: [_jsx(IconPlus, { className: "size-3.5" }), "Add annotation"] }))] }), annotations.length === 0 && (_jsx("p", { className: "text-xs text-plan-muted", children: "No annotations yet. Add one to anchor a note to a line range." })), annotations.map((annotation, index) => (_jsxs("div", { className: "flex flex-col gap-2 rounded-md border border-plan-line bg-plan-block/30 p-2", children: [_jsxs("div", { className: "grid gap-2 sm:grid-cols-[120px_minmax(0,1fr)_auto]", children: [_jsx(DevInput, { "aria-label": `Annotation ${index + 1} lines`, value: annotation.lines, placeholder: "3-5", disabled: !editable, onChange: (event) => updateAnnotation(index, { lines: event.target.value }) }), _jsx(DevInput, { "aria-label": `Annotation ${index + 1} label`, value: annotation.label ?? "", placeholder: "Label (optional)", disabled: !editable, onChange: (event) => updateAnnotation(index, {
|
|
130
|
+
label: event.target.value || undefined,
|
|
131
|
+
}) }), editable && (_jsx("button", { type: "button", "data-plan-interactive": true, "aria-label": `Remove annotation ${index + 1}`, onClick: () => removeAnnotation(index), 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", children: _jsx(IconTrash, { className: "size-4" }) }))] }), _jsx(DevTextarea, { "aria-label": `Annotation ${index + 1} note`, className: "min-h-[60px] text-sm", value: annotation.note, placeholder: "Explain what these lines do\u2026", disabled: !editable, onChange: (event) => updateAnnotation(index, { note: event.target.value }) })] }, index)))] })] }));
|
|
132
|
+
}
|
|
133
|
+
export { AnnotatedCodeRead, AnnotatedCodeEdit };
|
|
134
|
+
//# sourceMappingURL=AnnotatedCodeBlock.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AnnotatedCodeBlock.js","sourceRoot":"","sources":["../../../../src/client/blocks/library/AnnotatedCodeBlock.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC1C,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AACpE,OAAO,EAAE,EAAE,EAAE,MAAM,gBAAgB,CAAC;AAMpC,OAAO,EACL,aAAa,EACb,yBAAyB,EACzB,qBAAqB,GACtB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAElE;;;;;;;;;;;;;;;;;;GAkBG;AAEH,kFAAkF;AAElF;;;;;GAKG;AACH,SAAS,cAAc,CACrB,GAAW,EACX,SAAiB;IAEjB,MAAM,KAAK,GAAG,gCAAgC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACzD,IAAI,CAAC,KAAK;QAAE,OAAO,IAAI,CAAC;IACxB,IAAI,KAAK,GAAG,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IAC1C,IAAI,GAAG,GAAG,KAAK,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;IACnE,IAAI,CAA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IAAI,EACtB,WAAW,EAAC,mCAA8B,EAC1C,QAAQ,EAAE,CAAC,QAAQ,EACnB,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE,CAClB,gBAAgB,CAAC,KAAK,EAAE,EAAE,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,GAEvD,KA7CG,KAAK,CA8CN,CACP,CAAC,IACE,IACF,CACP,CAAC;AACJ,CAAC;AAED,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,CAAC","sourcesContent":["import { useMemo, useState } from \"react\";\nimport { IconCode, IconPlus, IconTrash } from \"@tabler/icons-react\";\nimport { cn } from \"../../utils.js\";\nimport type { BlockEditProps, BlockReadProps } from \"../types.js\";\nimport type {\n AnnotatedCodeAnnotation,\n AnnotatedCodeData,\n} from \"./annotated-code.config.js\";\nimport {\n highlightCode,\n inferLanguageFromFilename,\n normalizeCodeLanguage,\n} from \"./code-highlight.js\";\nimport { DevInput, DevLabel, DevTextarea } from \"./dev-doc-ui.js\";\n\n/**\n * \"Explain this code\" walkthrough block: a standard syntax-highlighted code\n * surface on the left with line-anchored annotation cards on the right (the\n * Stripe-docs / Sourcegraph layout). Each annotated line range gets a subtle\n * highlight band + an accent rail down the gutter; its card shows the `lines`\n * range, optional `label`, and the always-visible markdown `note` (via\n * `ctx.renderMarkdown`). Hovering a card highlights its lines and vice-versa.\n *\n * Syntax highlighting reuses the shared `highlightCode` lowlight helper (the same\n * colorful palette as the `code-tabs` block) per line, so it matches the app's\n * standard code styling and supports per-line bands without an async loader. The\n * surface uses the plan `--plan-code*`/`--plan-*` tokens and Tailwind `dark:`\n * pairs, so it reads correctly in BOTH light and dark mode. Code lines render as\n * `<span>`s (never one `<pre>` per line) so they don't pick up document\n * code/pre chrome. Lives in core so any app can register the dev-doc block.\n *\n * Editing is panel-driven (config-style, like the diff/HTML blocks): a monospace\n * code Textarea, filename/language Inputs, and add/remove-able annotation rows.\n */\n\n/* ── Line-ref parsing ──────────────────────────────────────────────────────── */\n\n/**\n * Parse a 1-based `lines` ref (`\"3\"` or `\"3-5\"`) into an inclusive `[start,end]`\n * pair, clamped to `[1, lineCount]`. Returns `null` for malformed or fully\n * out-of-range refs so callers can ignore them gracefully. A reversed range\n * (`\"5-3\"`) is normalized; a partially out-of-range range is clamped.\n */\nfunction parseLineRange(\n ref: string,\n lineCount: number,\n): { start: number; end: number } | null {\n const match = /^\\s*(\\d+)\\s*(?:-\\s*(\\d+)\\s*)?$/.exec(ref);\n if (!match) return null;\n let start = Number.parseInt(match[1], 10);\n let end = match[2] != null ? Number.parseInt(match[2], 10) : start;\n if (!Number.isFinite(start) || !Number.isFinite(end)) return null;\n if (start > end) [start, end] = [end, start];\n // Fully outside the file → ignore.\n if (end < 1 || start > lineCount) return null;\n return { start: Math.max(1, start), end: Math.min(lineCount, end) };\n}\n\ninterface ResolvedAnnotation {\n /** Index in the original `annotations` array (stable hover key). */\n index: number;\n /** 1-based marker number (authoring order). */\n marker: number;\n annotation: AnnotatedCodeAnnotation;\n range: { start: number; end: number } | null;\n}\n\n/** Human label for a resolved annotation's line span (\"Line 8\" / \"Lines 3–6\"). */\nfunction rangeLabel(item: ResolvedAnnotation): string {\n if (!item.range) return `Lines ${item.annotation.lines}`;\n return item.range.start === item.range.end\n ? `Line ${item.range.start}`\n : `Lines ${item.range.start}–${item.range.end}`;\n}\n\n/* ── Read ──────────────────────────────────────────────────────────────────── */\n\nfunction AnnotatedCodeRead({\n data,\n blockId,\n title,\n summary,\n ctx,\n}: BlockReadProps<AnnotatedCodeData>) {\n const [activeIndex, setActiveIndex] = useState<number | null>(null);\n\n const lines = useMemo(\n () => data.code.replace(/\\n$/, \"\").split(\"\\n\"),\n [data.code],\n );\n const lineCount = lines.length;\n\n const language = useMemo(\n () =>\n normalizeCodeLanguage(data.language) ??\n inferLanguageFromFilename(data.filename),\n [data.language, data.filename],\n );\n\n // Highlight each line once; empty lines keep their height with a NBSP.\n const highlightedLines = useMemo(\n () =>\n lines.map((text) => (text.length ? highlightCode(text, language) : \" \")),\n [lines, language],\n );\n\n const resolved = useMemo<ResolvedAnnotation[]>(\n () =>\n (data.annotations ?? []).map((annotation, index) => ({\n index,\n marker: index + 1,\n annotation,\n range: parseLineRange(annotation.lines, lineCount),\n })),\n [data.annotations, lineCount],\n );\n\n // line number (1-based) → resolved annotations covering it.\n const lineMarkers = useMemo(() => {\n const map = new Map<number, ResolvedAnnotation[]>();\n for (const item of resolved) {\n if (!item.range) continue;\n for (let n = item.range.start; n <= item.range.end; n += 1) {\n const list = map.get(n) ?? [];\n list.push(item);\n map.set(n, list);\n }\n }\n return map;\n }, [resolved]);\n\n const sideAnnotations = resolved.filter((item) => item.range);\n const hasAnnotations = sideAnnotations.length > 0;\n const langChip = data.language?.trim();\n\n const codeSurface = (\n <div className=\"overflow-hidden rounded-xl border border-plan-line bg-plan-code\">\n {(data.filename || langChip) && (\n <div className=\"flex items-center gap-2 border-b border-plan-line bg-plan-block/50 px-3.5 py-2\">\n <IconCode className=\"size-3.5 shrink-0 text-plan-muted\" />\n <span className=\"min-w-0 flex-1 truncate font-mono text-[13px] font-medium text-plan-code-text\">\n {data.filename || \"snippet\"}\n </span>\n {langChip && (\n <span className=\"shrink-0 rounded border border-plan-line px-1.5 py-0.5 font-mono text-[10px] uppercase tracking-wide text-plan-muted\">\n {langChip}\n </span>\n )}\n </div>\n )}\n <div className=\"overflow-x-auto py-1.5\">\n <div className=\"min-w-full font-mono text-[12.5px] leading-[22px]\">\n {lines.map((_text, idx) => {\n const lineNo = idx + 1;\n const markers = lineMarkers.get(lineNo);\n const isAnnotated = !!markers?.length;\n const isActive =\n activeIndex != null &&\n !!markers?.some((m) => m.index === activeIndex);\n return (\n <div\n key={lineNo}\n className={cn(\n \"flex w-full\",\n isActive\n ? \"bg-amber-400/20 dark:bg-amber-300/15\"\n : isAnnotated\n ? \"bg-amber-400/[0.07] dark:bg-amber-300/[0.07]\"\n : null,\n )}\n onMouseEnter={\n isAnnotated && markers\n ? () => setActiveIndex(markers[0].index)\n : undefined\n }\n onMouseLeave={\n isAnnotated ? () => setActiveIndex(null) : undefined\n }\n >\n {/* Accent rail: amber on annotated lines, brighter when active. */}\n <span\n aria-hidden\n className={cn(\n \"w-[3px] shrink-0 self-stretch\",\n isAnnotated\n ? isActive\n ? \"bg-amber-500 dark:bg-amber-400\"\n : \"bg-amber-400/45 dark:bg-amber-300/35\"\n : null,\n )}\n />\n <span className=\"w-11 shrink-0 select-none px-3 text-right text-[11px] tabular-nums text-plan-muted/60\">\n {lineNo}\n </span>\n <span className=\"flex-1 whitespace-pre pr-4 text-plan-code-text\">\n {highlightedLines[idx]}\n </span>\n </div>\n );\n })}\n </div>\n </div>\n </div>\n );\n\n return (\n <section className=\"plan-block\" data-block-id={blockId}>\n {title && <div className=\"plan-block-label\">{title}</div>}\n {hasAnnotations ? (\n <div className=\"grid items-start gap-3 md:grid-cols-[minmax(0,1fr)_minmax(190px,250px)]\">\n {codeSurface}\n <div className=\"flex flex-col gap-2.5\">\n {sideAnnotations.map((item) => {\n const isActive = activeIndex === item.index;\n return (\n <div\n key={item.index}\n onMouseEnter={() => setActiveIndex(item.index)}\n onMouseLeave={() => setActiveIndex(null)}\n className={cn(\n \"rounded-lg border px-3.5 py-2.5 transition-colors\",\n isActive\n ? \"border-amber-400/70 bg-amber-50 dark:border-amber-300/40 dark:bg-amber-300/[0.08]\"\n : \"border-plan-line bg-plan-block/40 hover:border-amber-400/50\",\n )}\n >\n <div className=\"flex flex-wrap items-baseline gap-x-2 gap-y-0.5\">\n <span className=\"text-[11px] font-semibold uppercase tracking-wide text-plan-muted\">\n {rangeLabel(item)}\n </span>\n {item.annotation.label && (\n <span className=\"text-[13px] font-semibold text-plan-text\">\n {item.annotation.label}\n </span>\n )}\n </div>\n <div className=\"plan-annotation-note mt-1 text-[13px] leading-relaxed text-plan-text/85\">\n {ctx.renderMarkdown ? (\n ctx.renderMarkdown(item.annotation.note)\n ) : (\n <p>{item.annotation.note}</p>\n )}\n </div>\n </div>\n );\n })}\n </div>\n </div>\n ) : (\n codeSurface\n )}\n {summary && <p className=\"mt-5 text-plan-muted\">{summary}</p>}\n </section>\n );\n}\n\n/* ── Edit (panel) ──────────────────────────────────────────────────────────── */\n\nconst codeAreaClass = \"min-h-[160px] font-mono text-xs leading-5\";\n\nfunction AnnotatedCodeEdit({\n data,\n onChange,\n editable,\n}: BlockEditProps<AnnotatedCodeData>) {\n const annotations = data.annotations ?? [];\n const patch = (next: Partial<AnnotatedCodeData>) =>\n onChange({ ...data, ...next });\n\n const updateAnnotation = (\n index: number,\n next: Partial<AnnotatedCodeAnnotation>,\n ) =>\n patch({\n annotations: annotations.map((annotation, i) =>\n i === index ? { ...annotation, ...next } : annotation,\n ),\n });\n\n const removeAnnotation = (index: number) =>\n patch({ annotations: annotations.filter((_, i) => i !== index) });\n\n const addAnnotation = () => {\n if (annotations.length >= 80) return; // schema max\n patch({\n annotations: [...annotations, { lines: \"1\", label: \"\", note: \"\" }],\n });\n };\n\n return (\n <div className=\"flex flex-col gap-3\" data-plan-interactive>\n <div className=\"grid gap-3 sm:grid-cols-2\">\n <div className=\"flex flex-col gap-1.5\">\n <DevLabel htmlFor=\"annotated-code-filename\" className=\"text-xs\">\n Filename\n </DevLabel>\n <DevInput\n id=\"annotated-code-filename\"\n value={data.filename ?? \"\"}\n placeholder=\"src/server/auth.ts\"\n disabled={!editable}\n onChange={(event) =>\n patch({ filename: event.target.value || undefined })\n }\n />\n </div>\n <div className=\"flex flex-col gap-1.5\">\n <DevLabel htmlFor=\"annotated-code-language\" className=\"text-xs\">\n Language\n </DevLabel>\n <DevInput\n id=\"annotated-code-language\"\n value={data.language ?? \"\"}\n placeholder=\"ts\"\n disabled={!editable}\n onChange={(event) =>\n patch({ language: event.target.value || undefined })\n }\n />\n </div>\n </div>\n\n <div className=\"flex flex-col gap-1.5\">\n <DevLabel htmlFor=\"annotated-code-code\" className=\"text-xs\">\n Code\n </DevLabel>\n <DevTextarea\n id=\"annotated-code-code\"\n spellCheck={false}\n className={codeAreaClass}\n value={data.code}\n disabled={!editable}\n onChange={(event) => patch({ code: event.target.value })}\n />\n </div>\n\n <div className=\"flex flex-col gap-2\">\n <div className=\"flex items-center justify-between\">\n <DevLabel className=\"text-xs\">Annotations</DevLabel>\n {editable && annotations.length < 80 && (\n <button\n type=\"button\"\n data-plan-interactive\n onClick={addAnnotation}\n 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\"\n >\n <IconPlus className=\"size-3.5\" />\n Add annotation\n </button>\n )}\n </div>\n {annotations.length === 0 && (\n <p className=\"text-xs text-plan-muted\">\n No annotations yet. Add one to anchor a note to a line range.\n </p>\n )}\n {annotations.map((annotation, index) => (\n <div\n key={index}\n className=\"flex flex-col gap-2 rounded-md border border-plan-line bg-plan-block/30 p-2\"\n >\n <div className=\"grid gap-2 sm:grid-cols-[120px_minmax(0,1fr)_auto]\">\n <DevInput\n aria-label={`Annotation ${index + 1} lines`}\n value={annotation.lines}\n placeholder=\"3-5\"\n disabled={!editable}\n onChange={(event) =>\n updateAnnotation(index, { lines: event.target.value })\n }\n />\n <DevInput\n aria-label={`Annotation ${index + 1} label`}\n value={annotation.label ?? \"\"}\n placeholder=\"Label (optional)\"\n disabled={!editable}\n onChange={(event) =>\n updateAnnotation(index, {\n label: event.target.value || undefined,\n })\n }\n />\n {editable && (\n <button\n type=\"button\"\n data-plan-interactive\n aria-label={`Remove annotation ${index + 1}`}\n onClick={() => removeAnnotation(index)}\n 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\"\n >\n <IconTrash className=\"size-4\" />\n </button>\n )}\n </div>\n <DevTextarea\n aria-label={`Annotation ${index + 1} note`}\n className=\"min-h-[60px] text-sm\"\n value={annotation.note}\n placeholder=\"Explain what these lines do…\"\n disabled={!editable}\n onChange={(event) =>\n updateAnnotation(index, { note: event.target.value })\n }\n />\n </div>\n ))}\n </div>\n </div>\n );\n}\n\nexport { AnnotatedCodeRead, AnnotatedCodeEdit };\n"]}
|
|
@@ -1,10 +1,30 @@
|
|
|
1
|
+
export declare function prettyLanguageName(language?: string | null): string | null;
|
|
1
2
|
export declare function HighlightedCode({ code, language, }: {
|
|
2
3
|
code: string;
|
|
3
4
|
language?: string;
|
|
4
5
|
}): import("react/jsx-runtime").JSX.Element;
|
|
5
|
-
|
|
6
|
+
/**
|
|
7
|
+
* Default number of code lines shown before a code surface collapses behind a
|
|
8
|
+
* "Show N more lines" toggle. Long code panes (read view, code tabs, API specs)
|
|
9
|
+
* stay scannable instead of dominating the document, matching the rest of the
|
|
10
|
+
* plan's progressively-disclosed surfaces.
|
|
11
|
+
*/
|
|
12
|
+
export declare const DEFAULT_CODE_MAX_LINES = 30;
|
|
13
|
+
/**
|
|
14
|
+
* Read-only code surface used across the plan blocks (code tabs, API specs) and
|
|
15
|
+
* the markdown read view. Syntax-highlights via {@link HighlightedCode} (Shiki,
|
|
16
|
+
* client-only with a plain `<pre>` SSR fallback), follows the current
|
|
17
|
+
* light/dark `--plan-code` palette, and collapses to `maxLines` with an
|
|
18
|
+
* expand/collapse toggle so long snippets do not run away.
|
|
19
|
+
*
|
|
20
|
+
* `maxLines` of `0` / `null` disables collapsing (show everything). The default
|
|
21
|
+
* is {@link DEFAULT_CODE_MAX_LINES}; the surface only collapses when the code is
|
|
22
|
+
* actually longer than that.
|
|
23
|
+
*/
|
|
24
|
+
export declare function CodeSurface({ code, language, maxLines, className, }: {
|
|
6
25
|
code: string;
|
|
7
26
|
language?: string;
|
|
27
|
+
maxLines?: number | null;
|
|
8
28
|
className?: string;
|
|
9
29
|
}): import("react/jsx-runtime").JSX.Element;
|
|
10
30
|
//# sourceMappingURL=HighlightedCode.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HighlightedCode.d.ts","sourceRoot":"","sources":["../../../../src/client/blocks/library/HighlightedCode.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"HighlightedCode.d.ts","sourceRoot":"","sources":["../../../../src/client/blocks/library/HighlightedCode.tsx"],"names":[],"mappings":"AA+GA,wBAAgB,kBAAkB,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,GAAG,IAAI,CAS1E;AAED,wBAAgB,eAAe,CAAC,EAC9B,IAAI,EACJ,QAAQ,GACT,EAAE;IACD,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,2CA2CA;AAED;;;;;GAKG;AACH,eAAO,MAAM,sBAAsB,KAAK,CAAC;AAEzC;;;;;;;;;;GAUG;AACH,wBAAgB,WAAW,CAAC,EAC1B,IAAI,EACJ,QAAQ,EACR,QAAiC,EACjC,SAAS,GACV,EAAE;IACD,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,2CAkDA"}
|