Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
162 changes: 4 additions & 158 deletions packages/core/src/canvas/canvasTemplates.ts

Large diffs are not rendered by default.

7 changes: 2 additions & 5 deletions packages/core/src/canvas/canvasTemplatesService.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import { freeformSystemPromptFor } from "@posthog/shared/canvas-freeform-prompt";
import { injectable } from "inversify";
import {
BUILT_IN_TEMPLATES,
type CanvasTemplate,
freeformSystemPromptFor,
} from "./canvasTemplates";
import { BUILT_IN_TEMPLATES, type CanvasTemplate } from "./canvasTemplates";
import type { ICanvasTemplatesService } from "./services";
import type { CanvasTemplateSummary } from "./templateSchemas";

Expand Down
3 changes: 2 additions & 1 deletion packages/core/src/canvas/dashboardsService.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { AuthService } from "@posthog/core/auth/auth";
import { AUTH_SERVICE } from "@posthog/core/auth/auth.module";
import { FREEFORM_TEMPLATE_ID } from "@posthog/shared/canvas-freeform-prompt";
import { inject, injectable } from "inversify";
import type {
DashboardFileMeta,
Expand All @@ -11,7 +12,7 @@ import {
type DesktopFsClient,
type FsEntryBase,
} from "./desktopFsClient";
import { FREEFORM_TEMPLATE_ID, type FreeformVersion } from "./freeformSchemas";
import type { FreeformVersion } from "./freeformSchemas";
import { fetchCurrentUser } from "./posthogApi";

// Desktop file-system "type" tag for a dashboard entry. Channels are `folder`
Expand Down
1 change: 0 additions & 1 deletion packages/core/src/canvas/freeformSchemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { z } from "zod";

// The template id for freeform-React canvases. Stored on a canvas's meta so the
// generation path can resolve the right system prompt.
export const FREEFORM_TEMPLATE_ID = "freeform";

// A single point in a freeform canvas's edit history. Every agent turn appends
// one full-file snapshot (Q7: full-file rewrite); the user can revert to any of
Expand Down
12 changes: 12 additions & 0 deletions packages/shared/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,18 @@
"types": "./dist/index.d.ts",
"import": "./dist/index.js"
},
"./canvas-freeform-prompt": {
"types": "./dist/canvas-freeform-prompt.d.ts",
"import": "./dist/canvas-freeform-prompt.js"
},
"./canvas-freeform-whitelist": {
"types": "./dist/canvas-freeform-whitelist.d.ts",
"import": "./dist/canvas-freeform-whitelist.js"
},
"./canvas-freeform-starter": {
"types": "./dist/canvas-freeform-starter.d.ts",
"import": "./dist/canvas-freeform-starter.js"
},
"./analytics-events": {
"types": "./dist/analytics-events.d.ts",
"import": "./dist/analytics-events.js"
Expand Down
163 changes: 163 additions & 0 deletions packages/shared/src/canvas-freeform-prompt.ts

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
buildImportMap,
checkFreeformImports,
FREEFORM_WHITELIST,
} from "./freeformWhitelist";
} from "./canvas-freeform-whitelist";

describe("checkFreeformImports", () => {
it("accepts whitelisted imports", () => {
Expand Down
3 changes: 3 additions & 0 deletions packages/shared/tsup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ export default defineConfig({
"src/index.ts",
"src/agent-platform-types.ts",
"src/analytics-events.ts",
"src/canvas-freeform-prompt.ts",
"src/canvas-freeform-starter.ts",
"src/canvas-freeform-whitelist.ts",
"src/constants.ts",
"src/deeplink.ts",
"src/dismissalReasons.ts",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
FileIcon,
ShapesIcon,
} from "@phosphor-icons/react";
import { FREEFORM_TEMPLATE_ID } from "@posthog/core/canvas/freeformSchemas";
import { FREEFORM_TEMPLATE_ID } from "@posthog/shared/canvas-freeform-prompt";
import type { ReactNode } from "react";

// A canvas's leading icon, chosen from its template so the tree and header read
Expand Down
2 changes: 1 addition & 1 deletion packages/ui/src/features/canvas/freeform/sandboxRuntime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
FREEFORM_ESM_HOST,
FREEFORM_POSTHOG_JS_URL,
FREEFORM_QUILL_CSS_URLS,
} from "@posthog/core/canvas/freeformWhitelist";
} from "@posthog/shared/canvas-freeform-whitelist";

// Builds the HTML document loaded into the freeform-canvas sandbox iframe.
//
Expand Down
4 changes: 2 additions & 2 deletions packages/ui/src/features/canvas/freeformPrompt.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { freeformSystemPromptFor } from "@posthog/core/canvas/canvasTemplates";
import { FREEFORM_STARTER_CODE } from "@posthog/core/canvas/freeformStarter";
import { freeformSystemPromptFor } from "@posthog/shared/canvas-freeform-prompt";
import { FREEFORM_STARTER_CODE } from "@posthog/shared/canvas-freeform-starter";

// Builds the prompt for the task that generates a freeform (React) canvas. Like
// CONTEXT.md generation, this runs as a normal repo-less agent task (no repo
Expand Down
Loading