tencil 0.3.2 → 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/LICENSE CHANGED
@@ -1,21 +1,202 @@
1
- MIT License
2
-
3
- Copyright (c) 2026 Pixel Perfect Agency
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
package/NOTICE ADDED
@@ -0,0 +1,2 @@
1
+ Tencil
2
+ Copyright 2026 Pixel Perfect Agency
package/README.md CHANGED
@@ -177,3 +177,8 @@ The bridge can make an agent edit your code, so it is locked down by default:
177
177
  held to `--allow-origin`, but a non-browser client can claim any Origin, so only
178
178
  listen on a network you trust (such as your tailnet).
179
179
  - Agent replies are rendered as text nodes (no `innerHTML`).
180
+
181
+ ## License
182
+
183
+ Apache-2.0. See [LICENSE](LICENSE), [NOTICE](NOTICE) and, for bundled third-party code,
184
+ [THIRD_PARTY_NOTICES.md](THIRD_PARTY_NOTICES.md).
@@ -1,16 +1,61 @@
1
1
  # Third-party notices
2
2
 
3
- The published `tencil` package bundles code from the projects below. Each is
4
- used under the license shown; full license texts are available in the linked
5
- repositories.
3
+ Tencil is licensed under the Apache License 2.0. The published `tencil` package
4
+ also contains code from the projects below, each used under the MIT License.
5
+
6
+ ## Bundled
7
+
8
+ Compiled into `dist/overlay.global.js` (the browser overlay):
9
+
10
+ | Project | Version | Copyright | Used for |
11
+ | --- | --- | --- | --- |
12
+ | [Preact](https://github.com/preactjs/preact) | 11 | Copyright (c) 2015-present Jason Miller | Overlay UI |
13
+ | [@preact/signals](https://github.com/preactjs/signals) | 2 | Copyright (c) 2022-present Preact Team | Overlay state |
14
+ | [@preact/signals-core](https://github.com/preactjs/signals) | 1 | Copyright (c) 2022-present Preact Team | Overlay state (used by @preact/signals) |
15
+ | [bippy](https://github.com/aidenybai/bippy) | 0.7 | Copyright 2024-present Aiden Bai | React component and source lookup |
16
+ | [modern-screenshot](https://github.com/qq15725/modern-screenshot) | 4 | Copyright (c) 2021-present wxm | Element screenshots |
17
+ | [T3 Code](https://github.com/pingdotgg/t3code) | n/a | Copyright (c) 2026 T3 Tools Inc. | Agent icons (T3 Code, Codex, Claude, Cursor) shown in the thread list, from `apps/web/src/components/Icons.tsx` and `T3Wordmark.tsx` |
18
+
19
+ The product names and logos shown by those icons belong to their owners.
20
+
21
+ Each of these projects is distributed under the following license, with the
22
+ copyright line from the table above:
23
+
24
+ ```
25
+ MIT License
26
+
27
+ Copyright (c) <year> <copyright holders>
28
+
29
+ Permission is hereby granted, free of charge, to any person obtaining a copy
30
+ of this software and associated documentation files (the "Software"), to deal
31
+ in the Software without restriction, including without limitation the rights
32
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
33
+ copies of the Software, and to permit persons to whom the Software is
34
+ furnished to do so, subject to the following conditions:
35
+
36
+ The above copyright notice and this permission notice shall be included in all
37
+ copies or substantial portions of the Software.
38
+
39
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
40
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
41
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
42
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
43
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
44
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
45
+ SOFTWARE.
46
+ ```
47
+
48
+ ## Dependencies
49
+
50
+ Installed next to `tencil` by npm, not bundled; each ships its own license:
6
51
 
7
52
  | Project | License | Used for |
8
53
  | --- | --- | --- |
9
- | [Preact](https://github.com/preactjs/preact) | MIT | Overlay UI |
10
- | [@preact/signals](https://github.com/preactjs/signals) | MIT | Overlay state |
11
- | [bippy](https://github.com/aidenybai/bippy) | MIT | React component and source lookup |
12
- | [modern-screenshot](https://github.com/qq15725/modern-screenshot) | MIT | Element screenshots |
13
- | [T3 Code](https://github.com/pingdotgg/t3code) | MIT | Agent icons (Codex, Claude, Cursor) shown in the thread list |
14
- | [ws](https://github.com/websockets/ws) | MIT | Bridge WebSocket server (dependency) |
15
- | [zod](https://github.com/colinhacks/zod) | MIT | Message validation (dependency) |
16
- | [picocolors](https://github.com/alexeyraspopov/picocolors) | ISC | CLI colors (dependency) |
54
+ | [ws](https://github.com/websockets/ws) | MIT | Bridge WebSocket server |
55
+ | [zod](https://github.com/colinhacks/zod) | MIT | Message validation |
56
+ | [picocolors](https://github.com/alexeyraspopov/picocolors) | ISC | CLI colors |
57
+
58
+ The [Claude Agent SDK](https://www.npmjs.com/package/@anthropic-ai/claude-agent-sdk)
59
+ is an optional peer dependency. Tencil neither bundles nor ships it: it is loaded
60
+ from next to Tencil, or installed into Tencil's config folder on first use of the
61
+ Claude Code provider, under Anthropic's own terms.
package/dist/cli.mjs CHANGED
@@ -1,7 +1,8 @@
1
1
  #!/usr/bin/env node
2
- import { _ as parsePairingInput, a as detectAgents, c as savedProvider, f as VERSION, g as exchangePairingCredential, h as createLocalPairingCode, i as PROVIDERS, m as DEFAULT_T3_URL, n as probeDaemon, o as providerLabel, p as CredentialStore, r as startDaemon, s as saveProvider, t as DEFAULT_PORT, u as defaultDataDir, v as withoutNpmEnv, y as loadAgentSdk } from "./server-Bxj8yTb3.mjs";
2
+ import { _ as parsePairingInput, a as detectAgents, c as savedProvider, f as VERSION, g as exchangePairingCredential, h as createLocalPairingCode, i as PROVIDERS, m as DEFAULT_T3_URL, n as probeDaemon, o as providerLabel, p as CredentialStore, r as startDaemon, s as saveProvider, t as DEFAULT_PORT, u as defaultDataDir, v as withoutNpmEnv, y as loadAgentSdk } from "./server-DZUEgjla.mjs";
3
+ import { t as DEFAULT_CLOUD_URL } from "./cloud-CiwIrP1h.mjs";
3
4
  import { execFileSync, spawn, spawnSync } from "node:child_process";
4
- import { cpSync, existsSync, mkdirSync, openSync, readFileSync, rmSync, writeFileSync } from "node:fs";
5
+ import { existsSync, mkdirSync, openSync, readFileSync, rmSync, writeFileSync } from "node:fs";
5
6
  import { readFile, readdir, writeFile } from "node:fs/promises";
6
7
  import { basename, dirname, join, relative, resolve } from "node:path";
7
8
  import { parseArgs } from "node:util";
@@ -668,14 +669,6 @@ function skipString(source, start) {
668
669
  else if (source[i] === quote) return i;
669
670
  return source.length;
670
671
  }
671
- /** Projects set up while Tencil was called Fixhere (up to 0.2.0) import it under the old name. */
672
- function usesFixhere(source) {
673
- return /(['"])fixhere\/(?:react|vite)\1/.test(source);
674
- }
675
- /** Point a Fixhere integration at Tencil: `fixhere/react` → `tencil/react`, `<Fixhere />` → `<Tencil />`. */
676
- function renameFromFixhere(source) {
677
- return source.replace(/(['"])fixhere\/(react|vite)\1/g, "$1tencil/$2$1").replace(/\bFixhere\b/g, "Tencil").replace(/\bimport\s+fixhere\b/g, "import tencil").replace(/\bfixhere\(/g, "tencil(");
678
- }
679
672
  //#endregion
680
673
  //#region src/init/detect-framework.ts
681
674
  /** Inspect a project folder to decide how Tencil should be wired in. */
@@ -788,9 +781,6 @@ function installCommand(manager, spec) {
788
781
  ]];
789
782
  }
790
783
  }
791
- function uninstallCommand(manager, name) {
792
- return manager === "npm" ? ["npm", ["uninstall", name]] : [manager, ["remove", name]];
793
- }
794
784
  function variants(bases, extensions) {
795
785
  return bases.flatMap((base) => extensions.map((ext) => `${base}.${ext}`));
796
786
  }
@@ -858,15 +848,7 @@ async function planInit(root) {
858
848
  const edit = async (path, codemod, instruction) => {
859
849
  if (!path) return void manual.push(instruction);
860
850
  const before = await readFile(path, "utf8");
861
- if (usesFixhere(before)) {
862
- edits.push({
863
- path,
864
- before,
865
- after: renameFromFixhere(before)
866
- });
867
- return;
868
- }
869
- if (/(?:tencil|fixhere)\.js/.test(before)) {
851
+ if (/tencil\.js/.test(before)) {
870
852
  manual.push(`${relative(root, path)} loads tencil.js by hand. Replace that tag with \`<Tencil />\` from \`tencil/react\` so the bridge's port is picked up automatically.`);
871
853
  return;
872
854
  }
@@ -928,8 +910,8 @@ async function runInit(options) {
928
910
  for (const edit of plan.edits) await writeFile(edit.path, edit.after);
929
911
  if (!options.skipInstall && plan.framework.kind !== "unknown") {
930
912
  if (!await hasDependency(options.root, "tencil") || options.from) install(options, log);
931
- if (await hasDependency(options.root, "fixhere")) uninstall(options, "fixhere", log);
932
913
  }
914
+ if (options.cloud) return logCloudSteps(plan.framework, log);
933
915
  let autostart = false;
934
916
  if (options.daemon) {
935
917
  const result = await ensureDaemon(options.daemon, defaultDataDir());
@@ -945,6 +927,16 @@ async function runInit(options) {
945
927
  if (options.daemon && !autostart) log(pc.dim(" Start Tencil at login: npx tencil setup"));
946
928
  log("");
947
929
  }
930
+ /** What's left to do in Tencil Cloud and the host once the code is in place. */
931
+ function logCloudSteps(framework, log) {
932
+ const env = pc.cyan("TENCIL_CLOUD=<project key>");
933
+ log(` ${pc.green("✓")} The overlay loads from Tencil Cloud on preview builds that set ${env}.`);
934
+ log(` 1. Create a project at ${pc.cyan(DEFAULT_CLOUD_URL)} and copy its key.`);
935
+ log(` 2. Add ${env} to your host's ${pc.bold("Preview")} environment only (Vercel: Settings → Environment Variables).`);
936
+ log(" 3. Redeploy a preview. Production deployments never load the overlay.");
937
+ if (framework.kind === "next-app" || framework.kind === "next-pages") log(pc.dim(" Keep <Tencil /> in a server component: it reads TENCIL_CLOUD when the page renders."));
938
+ log("");
939
+ }
948
940
  /** Already a dependency (and no other package asked for with `--from`)? */
949
941
  async function hasDependency(root, name) {
950
942
  try {
@@ -954,16 +946,6 @@ async function hasDependency(root, name) {
954
946
  return false;
955
947
  }
956
948
  }
957
- function uninstall(options, name, log) {
958
- const [command, args] = uninstallCommand(detectPackageManager(options.root), name);
959
- log(` ${pc.dim(`$ ${command} ${args.join(" ")}`)}`);
960
- spawnSync(command, args, {
961
- cwd: options.root,
962
- stdio: "inherit",
963
- shell: process.platform === "win32",
964
- env: withoutNpmEnv()
965
- });
966
- }
967
949
  function install(options, log) {
968
950
  const [command, args] = installCommand(detectPackageManager(options.root), options.from ?? "tencil");
969
951
  log(` ${pc.dim(`$ ${command} ${args.join(" ")}`)}`);
@@ -983,64 +965,6 @@ function describe(framework) {
983
965
  }
984
966
  }
985
967
  //#endregion
986
- //#region src/service/migrate-from-fixhere.ts
987
- /** What Fixhere (Tencil's name up to 0.2.0) called its login service. */
988
- function fixhereServiceNames(port = DEFAULT_PORT) {
989
- const names = [{
990
- label: "dev.fixhere.daemon",
991
- unit: "fixhere.service",
992
- task: "Fixhere"
993
- }];
994
- if (port !== 4747) names.push({
995
- label: `dev.fixhere.daemon.${port}`,
996
- unit: `fixhere-${port}.service`,
997
- task: `Fixhere ${port}`
998
- });
999
- return names;
1000
- }
1001
- /** Files that move to Tencil's data folder: pins, pairing, settings. Not the runtime copy or logs. */
1002
- function carriesOver(path) {
1003
- const name = basename(path);
1004
- return !/^runtime(-\d+)?$/.test(name) && name !== "daemon.log";
1005
- }
1006
- /**
1007
- * Move a Fixhere install over to Tencil, once: copy its data folder, remove its
1008
- * login service and stop its daemon, which would otherwise hold the port.
1009
- */
1010
- async function migrateFromFixhere(port, dataDir, log) {
1011
- const steps = [];
1012
- const oldDir = join(dirname(dataDir), "fixhere");
1013
- if (existsSync(oldDir) && !existsSync(dataDir)) {
1014
- cpSync(oldDir, dataDir, {
1015
- recursive: true,
1016
- filter: carriesOver
1017
- });
1018
- steps.push("pins and pairing");
1019
- }
1020
- for (const names of fixhereServiceNames(port)) {
1021
- if (servicePort(readServiceDefinition(names)) !== port) continue;
1022
- removeService(names);
1023
- steps.push("login service");
1024
- }
1025
- if (await stopFixhereDaemon(port)) steps.push("daemon");
1026
- if (steps.length) log(`\n ${pc.green("✓")} Moved Fixhere over to Tencil ${pc.dim(`(${[...new Set(steps)].join(", ")})`)}`);
1027
- }
1028
- /** A Fixhere daemon on `port` answers /health as "fixhere"; stop it so Tencil can listen. */
1029
- async function stopFixhereDaemon(port) {
1030
- const health = await fetch(`http://127.0.0.1:${port}/health`, { signal: AbortSignal.timeout(1500) }).then((response) => response.json()).catch(() => void 0);
1031
- if (health?.name !== "fixhere" || !health.pid) return false;
1032
- try {
1033
- process.kill(health.pid, "SIGTERM");
1034
- } catch {
1035
- return false;
1036
- }
1037
- for (let attempt = 0; attempt < 50; attempt++) {
1038
- await new Promise((resolve) => setTimeout(resolve, 100));
1039
- if (!await fetch(`http://127.0.0.1:${port}/health`, { signal: AbortSignal.timeout(500) }).catch(() => void 0)) return true;
1040
- }
1041
- return true;
1042
- }
1043
- //#endregion
1044
968
  //#region src/cli/commands/connect.ts
1045
969
  async function connect(input, t3Url) {
1046
970
  const store = new CredentialStore();
@@ -1327,18 +1251,12 @@ ${pc.dim("Setup and init options")}
1327
1251
  --dry-run Show the changes without writing them
1328
1252
  --skip-install Don't install the tencil package
1329
1253
  --skip-pair Don't pair with T3 Code
1254
+ --cloud init: set up for Tencil Cloud previews (no daemon on this machine)
1330
1255
  --from <spec> Package to install instead of "tencil" (e.g. a local path)
1331
1256
 
1332
1257
  -h, --help Show help
1333
1258
  -v, --version Show version
1334
1259
  `;
1335
- /** Commands that start or install the daemon. */
1336
- const SETS_UP = [
1337
- "setup",
1338
- "start",
1339
- "init",
1340
- "service"
1341
- ];
1342
1260
  async function main() {
1343
1261
  const { values, positionals } = parseArgs({
1344
1262
  allowPositionals: true,
@@ -1366,6 +1284,7 @@ async function main() {
1366
1284
  "dry-run": { type: "boolean" },
1367
1285
  "skip-install": { type: "boolean" },
1368
1286
  "skip-pair": { type: "boolean" },
1287
+ cloud: { type: "boolean" },
1369
1288
  from: { type: "string" },
1370
1289
  help: {
1371
1290
  type: "boolean",
@@ -1393,7 +1312,6 @@ async function main() {
1393
1312
  port,
1394
1313
  args: forwardedFlags(values)
1395
1314
  };
1396
- if (command === void 0 || SETS_UP.includes(command)) await migrateFromFixhere(port, defaultDataDir(), console.log);
1397
1315
  switch (command) {
1398
1316
  case void 0: return quickstart(daemonCommand, {
1399
1317
  root: resolve(values.root ?? process.cwd()),
@@ -1430,8 +1348,9 @@ async function main() {
1430
1348
  skipPair: values["skip-pair"],
1431
1349
  from: values.from,
1432
1350
  port,
1433
- daemon: daemonCommand,
1434
- t3Url
1351
+ daemon: values.cloud ? void 0 : daemonCommand,
1352
+ t3Url,
1353
+ cloud: values.cloud
1435
1354
  });
1436
1355
  default:
1437
1356
  console.error(`Unknown command "${command}"\n${HELP}`);
@@ -0,0 +1,104 @@
1
+ //#region src/integrations/cloud.ts
2
+ /** Where Tencil Cloud serves the overlay and its bridge. */
3
+ const DEFAULT_CLOUD_URL = "https://cloud.tencil.dev";
4
+ const PROJECT_KEY = /^[A-Za-z0-9_-]{8,64}$/;
5
+ const REPO = /^[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+$/;
6
+ const SHA = /^[0-9a-f]{7,64}$/i;
7
+ /**
8
+ * Whether this build loads the overlay from Tencil Cloud. Only when a project key
9
+ * is set, and never for a production deployment: the overlay lets reviewers make
10
+ * an agent change the code, so it belongs on previews only. Repo, branch and
11
+ * commit come from the host (Vercel, Netlify, Cloudflare Pages, GitHub Actions),
12
+ * so the cloud knows which code the page was built from.
13
+ */
14
+ function resolveCloudBuild(env, options = {}) {
15
+ const projectKey = options.project ?? env.TENCIL_CLOUD;
16
+ if (!projectKey) return { kind: "off" };
17
+ if (!PROJECT_KEY.test(projectKey)) return {
18
+ kind: "refused",
19
+ reason: "TENCIL_CLOUD is not a Tencil Cloud project key."
20
+ };
21
+ const production = productionDeployment(env);
22
+ if (production) return {
23
+ kind: "refused",
24
+ reason: `${production}: the overlay only loads on previews.`
25
+ };
26
+ const repo = options.repo ?? env.TENCIL_CLOUD_REPO ?? hostRepo(env);
27
+ const branch = options.branch ?? env.TENCIL_CLOUD_BRANCH ?? hostBranch(env);
28
+ const sha = options.sha ?? env.TENCIL_CLOUD_SHA ?? hostSha(env);
29
+ const missing = [
30
+ !repo && "repository",
31
+ !branch && "branch",
32
+ !sha && "commit"
33
+ ].filter(Boolean);
34
+ if (missing.length) return {
35
+ kind: "refused",
36
+ reason: `No ${missing.join(", ")} found for this build. Set TENCIL_CLOUD_REPO, TENCIL_CLOUD_BRANCH and TENCIL_CLOUD_SHA.`
37
+ };
38
+ if (!REPO.test(repo)) return {
39
+ kind: "refused",
40
+ reason: `"${repo}" is not a GitHub repository (owner/name).`
41
+ };
42
+ if (!SHA.test(sha)) return {
43
+ kind: "refused",
44
+ reason: `"${sha}" is not a commit hash.`
45
+ };
46
+ const url = (options.url ?? env.TENCIL_CLOUD_URL ?? "https://cloud.tencil.dev").replace(/\/+$/, "");
47
+ if (!/^https?:\/\//.test(url)) return {
48
+ kind: "refused",
49
+ reason: `TENCIL_CLOUD_URL "${url}" is not an http(s) URL.`
50
+ };
51
+ return {
52
+ kind: "on",
53
+ url,
54
+ build: {
55
+ projectKey,
56
+ repo,
57
+ branch,
58
+ sha: sha.toLowerCase()
59
+ }
60
+ };
61
+ }
62
+ /** The host's name for a production deployment, if this is one. */
63
+ function productionDeployment(env) {
64
+ if (env.VERCEL_ENV === "production") return "VERCEL_ENV is production";
65
+ if (env.NETLIFY && env.CONTEXT === "production") return "Netlify CONTEXT is production";
66
+ if (env.TENCIL_CLOUD_ENV === "production") return "TENCIL_CLOUD_ENV is production";
67
+ }
68
+ function hostRepo(env) {
69
+ if (env.VERCEL_GIT_REPO_OWNER && env.VERCEL_GIT_REPO_SLUG) return `${env.VERCEL_GIT_REPO_OWNER}/${env.VERCEL_GIT_REPO_SLUG}`;
70
+ if (env.GITHUB_REPOSITORY) return env.GITHUB_REPOSITORY;
71
+ return (env.REPOSITORY_URL?.match(/github\.com[/:]([^/]+\/[^/]+?)(?:\.git)?$/))?.[1];
72
+ }
73
+ function hostBranch(env) {
74
+ return env.VERCEL_GIT_COMMIT_REF ?? env.CF_PAGES_BRANCH ?? (env.NETLIFY ? env.HEAD : void 0) ?? env.GITHUB_HEAD_REF ?? env.GITHUB_REF_NAME;
75
+ }
76
+ function hostSha(env) {
77
+ return env.VERCEL_GIT_COMMIT_SHA ?? env.CF_PAGES_COMMIT_SHA ?? (env.NETLIFY ? env.COMMIT_REF : void 0) ?? env.GITHUB_SHA;
78
+ }
79
+ /** A JSON string literal that is also safe inside an inline `<script>`. */
80
+ function scriptString(value) {
81
+ return JSON.stringify(value).replace(/</g, "\\u003c");
82
+ }
83
+ /**
84
+ * Browser code that loads the overlay from Tencil Cloud. The script tag carries
85
+ * the build, which the overlay passes on when it connects.
86
+ */
87
+ function cloudLoader({ url, build }) {
88
+ return `;(() => {
89
+ if (typeof document === "undefined") return;
90
+ const src = ${scriptString(`${url}/tencil.js`)};
91
+ if (document.querySelector('script[src="' + src + '"]')) return;
92
+ const script = document.createElement("script");
93
+ script.src = src;
94
+ script.async = true;
95
+ script.dataset.bridge = ${scriptString(url)};
96
+ script.dataset.tencilProject = ${scriptString(build.projectKey)};
97
+ script.dataset.tencilRepo = ${scriptString(build.repo)};
98
+ script.dataset.tencilBranch = ${scriptString(build.branch)};
99
+ script.dataset.tencilSha = ${scriptString(build.sha)};
100
+ document.head.appendChild(script);
101
+ })();`;
102
+ }
103
+ //#endregion
104
+ export { cloudLoader as n, resolveCloudBuild as r, DEFAULT_CLOUD_URL as t };
@@ -0,0 +1,14 @@
1
+ import "./index-DzR4m_IL.mjs";
2
+ //#region src/integrations/cloud.d.ts
3
+ interface TencilCloudOptions {
4
+ /** Project key from the Tencil Cloud dashboard. Defaults to TENCIL_CLOUD. */
5
+ project?: string;
6
+ /** `owner/name` on GitHub. Defaults to the host's git env vars. */
7
+ repo?: string;
8
+ branch?: string;
9
+ sha?: string;
10
+ /** Tencil Cloud itself; only for testing against a local one. Defaults to TENCIL_CLOUD_URL. */
11
+ url?: string;
12
+ }
13
+ //#endregion
14
+ export { TencilCloudOptions as t };