tencil 0.4.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/react.d.mts CHANGED
@@ -1,13 +1,20 @@
1
+ import { t as TencilCloudOptions } from "./cloud-Ez2olqK0.mjs";
1
2
  //#region src/integrations/react.d.ts
2
3
  /**
3
4
  * Loads the Tencil overlay in development from the daemon on the machine
4
- * serving the page (`npx tencil start`). Renders nothing in production;
5
- * without a running daemon the script simply doesn't load.
5
+ * serving the page (`npx tencil start`); without a running daemon the script
6
+ * simply doesn't load.
7
+ *
8
+ * Outside development it renders nothing, unless TENCIL_CLOUD is set for a
9
+ * preview deployment: then it loads the overlay from Tencil Cloud. That needs
10
+ * the env at render time, so keep `<Tencil />` in a server component (the root
11
+ * layout or `_document`).
6
12
  *
7
13
  * <body>{children}<Tencil /></body>
8
14
  */
9
- export declare function Tencil({ port }: {
15
+ export declare function Tencil({ port, cloud }: {
10
16
  port?: number;
17
+ cloud?: TencilCloudOptions;
11
18
  }): import("react").DetailedReactHTMLElement<{
12
19
  id: string;
13
20
  dangerouslySetInnerHTML: {
package/dist/react.mjs CHANGED
@@ -1,18 +1,33 @@
1
+ import { n as cloudLoader, r as resolveCloudBuild } from "./cloud-CiwIrP1h.mjs";
1
2
  import { n as overlayLoader, t as DEFAULT_DAEMON_PORT } from "./loader-BevujQ44.mjs";
2
3
  import { createElement } from "react";
3
4
  //#region src/integrations/react.ts
5
+ let warned = false;
4
6
  /**
5
7
  * Loads the Tencil overlay in development from the daemon on the machine
6
- * serving the page (`npx tencil start`). Renders nothing in production;
7
- * without a running daemon the script simply doesn't load.
8
+ * serving the page (`npx tencil start`); without a running daemon the script
9
+ * simply doesn't load.
10
+ *
11
+ * Outside development it renders nothing, unless TENCIL_CLOUD is set for a
12
+ * preview deployment: then it loads the overlay from Tencil Cloud. That needs
13
+ * the env at render time, so keep `<Tencil />` in a server component (the root
14
+ * layout or `_document`).
8
15
  *
9
16
  * <body>{children}<Tencil /></body>
10
17
  */
11
- function Tencil({ port = DEFAULT_DAEMON_PORT }) {
12
- if (process.env.NODE_ENV !== "development") return null;
18
+ function Tencil({ port = DEFAULT_DAEMON_PORT, cloud }) {
19
+ if (process.env.NODE_ENV === "development") return script(overlayLoader(port));
20
+ const resolved = resolveCloudBuild(typeof process === "undefined" ? {} : process.env, cloud);
21
+ if (resolved.kind === "refused" && !warned) {
22
+ warned = true;
23
+ console.warn(`[tencil] Not loading Tencil Cloud. ${resolved.reason}`);
24
+ }
25
+ return resolved.kind === "on" ? script(cloudLoader(resolved)) : null;
26
+ }
27
+ function script(code) {
13
28
  return createElement("script", {
14
29
  id: "tencil-loader",
15
- dangerouslySetInnerHTML: { __html: overlayLoader(port) }
30
+ dangerouslySetInnerHTML: { __html: code }
16
31
  });
17
32
  }
18
33
  //#endregion
@@ -64,11 +64,24 @@ const ImageAttachment = z.object({
64
64
  ]),
65
65
  dataUrl: z.string().startsWith("data:image/").max(14e6)
66
66
  });
67
+ /**
68
+ * The code a page was built from, set by Tencil Cloud builds (`TENCIL_CLOUD`).
69
+ * Local pages have none: the daemon finds their project from the dev server.
70
+ */
71
+ const BuildInfo = z.object({
72
+ /** Project key from the Tencil Cloud dashboard. */
73
+ projectKey: z.string().min(1).max(64),
74
+ /** `owner/name` on GitHub. */
75
+ repo: z.string().min(3).max(200),
76
+ branch: z.string().min(1).max(255),
77
+ sha: z.string().min(7).max(64)
78
+ });
67
79
  const ClientMessage = z.discriminatedUnion("type", [
68
80
  z.object({
69
81
  type: z.literal("hello"),
70
82
  protocol: z.literal(1),
71
- pageUrl: z.string()
83
+ pageUrl: z.string(),
84
+ build: BuildInfo.optional()
72
85
  }),
73
86
  z.object({
74
87
  type: z.literal("thread.create"),
@@ -3032,7 +3045,7 @@ function errorMessage(error) {
3032
3045
  }
3033
3046
  //#endregion
3034
3047
  //#region src/version.ts
3035
- const VERSION = "0.4.0";
3048
+ const VERSION = "0.5.0";
3036
3049
  //#endregion
3037
3050
  //#region src/daemon/thread-store.ts
3038
3051
  const StoreFile = z.object({
package/dist/vite.d.mts CHANGED
@@ -1,8 +1,11 @@
1
+ import { t as TencilCloudOptions } from "./cloud-Ez2olqK0.mjs";
1
2
  //#region src/integrations/vite.d.ts
2
3
  /** Structural subset of Vite's Plugin type, so `vite` stays an optional peer. */
3
4
  interface VitePlugin {
4
5
  name: string;
5
- apply: 'serve';
6
+ apply(config: unknown, env: {
7
+ command: 'build' | 'serve';
8
+ }): boolean;
6
9
  transformIndexHtml(): Array<{
7
10
  tag: string;
8
11
  children: string;
@@ -13,10 +16,18 @@ interface VitePlugin {
13
16
  export interface TencilViteOptions {
14
17
  /** Port of the Tencil daemon. Defaults to TENCIL_PORT or 4747. */
15
18
  port?: number;
19
+ /**
20
+ * Tencil Cloud for preview builds. On when TENCIL_CLOUD holds a project key;
21
+ * repo, branch and commit come from the host. Production builds never load it.
22
+ */
23
+ cloud?: TencilCloudOptions;
16
24
  }
17
25
  /**
18
- * Dev-only: loads the overlay from the Tencil daemon on the machine serving the
19
- * page (`npx tencil start`). Without a running daemon nothing appears.
26
+ * In development: loads the overlay from the Tencil daemon on the machine serving
27
+ * the page (`npx tencil start`). Without a running daemon nothing appears.
28
+ *
29
+ * In a build: nothing, unless TENCIL_CLOUD is set for a preview deployment; then
30
+ * the page loads the overlay from Tencil Cloud.
20
31
  */
21
32
  export default function tencil(options?: TencilViteOptions): VitePlugin;
22
33
  //#endregion
package/dist/vite.mjs CHANGED
@@ -1,17 +1,32 @@
1
+ import { n as cloudLoader, r as resolveCloudBuild } from "./cloud-CiwIrP1h.mjs";
1
2
  import { n as overlayLoader } from "./loader-BevujQ44.mjs";
2
3
  //#region src/integrations/vite.ts
3
4
  /** Vite's dev client, which every dev page loads, whether or not it has an index.html. */
4
5
  const VITE_CLIENT = /vite\/dist\/client\/(?:client|bundledDevClient)\.mjs$/;
5
6
  /**
6
- * Dev-only: loads the overlay from the Tencil daemon on the machine serving the
7
- * page (`npx tencil start`). Without a running daemon nothing appears.
7
+ * In development: loads the overlay from the Tencil daemon on the machine serving
8
+ * the page (`npx tencil start`). Without a running daemon nothing appears.
9
+ *
10
+ * In a build: nothing, unless TENCIL_CLOUD is set for a preview deployment; then
11
+ * the page loads the overlay from Tencil Cloud.
8
12
  */
9
13
  function tencil(options = {}) {
10
- const loader = overlayLoader(options.port ?? Number(process.env.TENCIL_PORT ?? 4747));
14
+ const port = options.port ?? Number(process.env.TENCIL_PORT ?? 4747);
15
+ let loader = overlayLoader(port);
16
+ let command = "serve";
11
17
  return {
12
18
  name: "tencil",
13
- apply: "serve",
19
+ apply(_config, env) {
20
+ command = env.command;
21
+ if (command === "serve") return true;
22
+ const cloud = resolveCloudBuild(process.env, options.cloud);
23
+ report(cloud);
24
+ if (cloud.kind !== "on") return false;
25
+ loader = cloudLoader(cloud);
26
+ return true;
27
+ },
14
28
  transform(code, id) {
29
+ if (command !== "serve") return void 0;
15
30
  return VITE_CLIENT.test(id) ? `${code}\n${loader}\n` : void 0;
16
31
  },
17
32
  transformIndexHtml() {
@@ -23,5 +38,9 @@ function tencil(options = {}) {
23
38
  }
24
39
  };
25
40
  }
41
+ function report(cloud) {
42
+ if (cloud.kind === "refused") console.warn(`[tencil] Not loading Tencil Cloud in this build. ${cloud.reason}`);
43
+ else if (cloud.kind === "on") console.log(`[tencil] Tencil Cloud on for ${cloud.build.repo}@${cloud.build.branch} (${cloud.build.sha.slice(0, 7)}).`);
44
+ }
26
45
  //#endregion
27
46
  export { tencil as default };
package/package.json CHANGED
@@ -1,17 +1,17 @@
1
1
  {
2
2
  "name": "tencil",
3
- "version": "0.4.0",
3
+ "version": "0.5.0",
4
4
  "description": "Point at any element of your running app and tell your coding agent what to fix.",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Pixel Perfect Agency",
7
7
  "homepage": "https://tencil.dev",
8
8
  "repository": {
9
9
  "type": "git",
10
- "url": "git+https://github.com/pixel-perfect-agency/tencil.git",
10
+ "url": "git+https://github.com/tencildev/tencil.git",
11
11
  "directory": "packages/tencil"
12
12
  },
13
13
  "bugs": {
14
- "url": "https://github.com/pixel-perfect-agency/tencil/issues"
14
+ "url": "https://github.com/tencildev/tencil/issues"
15
15
  },
16
16
  "keywords": [
17
17
  "agent",