tencil 0.3.1 → 0.4.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 +202 -21
- package/NOTICE +2 -0
- package/README.md +24 -13
- package/THIRD_PARTY_NOTICES.md +56 -11
- package/dist/cli.mjs +97 -19
- package/dist/index.d.mts +116 -40
- package/dist/index.mjs +2 -2
- package/dist/overlay.global.js +149 -37
- package/dist/{server-PYBcw-eR.mjs → server-9m0nvaLs.mjs} +484 -117
- package/package.json +10 -8
package/LICENSE
CHANGED
|
@@ -1,21 +1,202 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
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
package/README.md
CHANGED
|
@@ -12,20 +12,25 @@ Think Vercel Comments, except the reviewer on the other side is an agent.
|
|
|
12
12
|
|
|
13
13
|
```
|
|
14
14
|
your dev site (any origin on localhost) your machine
|
|
15
|
-
┌────────────────────────────────────┐ ws ┌─────────────────────┐ ws/rpc
|
|
16
|
-
│ overlay (Preact, shadow DOM) │ ──────▶ │ tencil daemon │ ─────────▶ │ T3 Code
|
|
17
|
-
│ • picker, pins, threads, inbox │ ◀────── │ • holds credentials│ ◀───────── │ (threads)
|
|
18
|
-
│ • React source via owner stacks │ │ • provider adapters│
|
|
19
|
-
└────────────────────────────────────┘ │ • pin store │
|
|
20
|
-
|
|
15
|
+
┌────────────────────────────────────┐ ws ┌─────────────────────┐ ws/rpc ┌─────────────┐
|
|
16
|
+
│ overlay (Preact, shadow DOM) │ ──────▶ │ tencil daemon │ ─────────▶ │ T3 Code │
|
|
17
|
+
│ • picker, pins, threads, inbox │ ◀────── │ • holds credentials│ ◀───────── │ (threads) │
|
|
18
|
+
│ • React source via owner stacks │ │ • provider adapters│ └─────────────┘
|
|
19
|
+
└────────────────────────────────────┘ │ • pin store │ Agent SDK ┌─────────────┐
|
|
20
|
+
│ │ ──────────▶ │ Claude Code │
|
|
21
|
+
└─────────────────────┘ │ (sessions) │
|
|
22
|
+
└─────────────┘
|
|
21
23
|
```
|
|
22
24
|
|
|
23
|
-
|
|
24
|
-
that matches your dev site's folder, so you can continue any
|
|
25
|
+
Tencil works with two agents. With **T3 Code**, every pin is a real T3 Code thread
|
|
26
|
+
in the project that matches your dev site's folder, so you can continue any
|
|
27
|
+
conversation there. With **Claude Code**, the daemon runs Claude Code itself and
|
|
28
|
+
every pin is a Claude Code session you can resume in a terminal.
|
|
25
29
|
|
|
26
30
|
## Quick start
|
|
27
31
|
|
|
28
|
-
You need
|
|
32
|
+
You need [T3 Code](https://github.com/pingdotgg/t3code) (the desktop app, running) or
|
|
33
|
+
[Claude Code](https://docs.claude.com/en/docs/claude-code) (installed and logged in).
|
|
29
34
|
|
|
30
35
|
```sh
|
|
31
36
|
cd your-app
|
|
@@ -33,7 +38,7 @@ npx tencil
|
|
|
33
38
|
```
|
|
34
39
|
|
|
35
40
|
The first time, this sets up your machine: it asks whether Tencil should start
|
|
36
|
-
when you log in (yes by default) and pairs with
|
|
41
|
+
when you log in (yes by default), picks your agent and, for T3 Code, pairs with it. Then it adds Tencil to
|
|
37
42
|
the project in the current folder. In other projects it only does the second part.
|
|
38
43
|
Start your dev server as usual and press <kbd>C</kbd> on the page.
|
|
39
44
|
|
|
@@ -51,9 +56,9 @@ When a page connects, the daemon works out which project it belongs to:
|
|
|
51
56
|
|
|
52
57
|
1. **the dev server's folder**, found from the port the page is served on;
|
|
53
58
|
2. if that fails (Docker, remote dev), the overlay asks **"Which project is this
|
|
54
|
-
page?"**
|
|
59
|
+
page?"** and remembers the answer.
|
|
55
60
|
|
|
56
|
-
Each project gets its own
|
|
61
|
+
Each project gets its own agent connection and pins, all served by the one daemon.
|
|
57
62
|
|
|
58
63
|
### What `init` adds
|
|
59
64
|
|
|
@@ -119,10 +124,11 @@ is running when the daemon stops is lost; the pin turns red and you can follow u
|
|
|
119
124
|
| Cancel | <kbd>Esc</kbd> |
|
|
120
125
|
| Follow up | Open a pin and reply; the same agent thread continues |
|
|
121
126
|
| Continue an existing thread | In the composer, switch **→ New thread** to any thread in the project; the element becomes its next message |
|
|
122
|
-
| Open any project thread | Inbox → **T3 Code**
|
|
127
|
+
| Open any project thread | Inbox → the agent's tab (**T3 Code** or **Claude Code**); the thread docks on the right so you can read, reply and stop while using the page |
|
|
123
128
|
| Stop the agent | **Stop** while a pin is working |
|
|
124
129
|
| All pins | Inbox button, filter by page or show resolved |
|
|
125
130
|
| Continue in T3 Code | External-link icon on a pin |
|
|
131
|
+
| Continue in Claude Code | `claude --resume <id>` in the project's folder |
|
|
126
132
|
|
|
127
133
|
Pins show their state: spinning while the agent works, blue when done, amber when
|
|
128
134
|
the agent waits for approval, red on errors, grey once resolved.
|
|
@@ -171,3 +177,8 @@ The bridge can make an agent edit your code, so it is locked down by default:
|
|
|
171
177
|
held to `--allow-origin`, but a non-browser client can claim any Origin, so only
|
|
172
178
|
listen on a network you trust (such as your tailnet).
|
|
173
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).
|
package/THIRD_PARTY_NOTICES.md
CHANGED
|
@@ -1,16 +1,61 @@
|
|
|
1
1
|
# Third-party notices
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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
|
-
| [
|
|
10
|
-
| [
|
|
11
|
-
| [
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
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,5 +1,5 @@
|
|
|
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-
|
|
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-9m0nvaLs.mjs";
|
|
3
3
|
import { execFileSync, spawn, spawnSync } from "node:child_process";
|
|
4
4
|
import { cpSync, existsSync, mkdirSync, openSync, readFileSync, rmSync, writeFileSync } from "node:fs";
|
|
5
5
|
import { readFile, readdir, writeFile } from "node:fs/promises";
|
|
@@ -9,6 +9,24 @@ import { fileURLToPath } from "node:url";
|
|
|
9
9
|
import { homedir } from "node:os";
|
|
10
10
|
import pc from "picocolors";
|
|
11
11
|
import { createInterface } from "node:readline/promises";
|
|
12
|
+
//#region src/cli/format.ts
|
|
13
|
+
function time() {
|
|
14
|
+
return (/* @__PURE__ */ new Date()).toLocaleTimeString([], {
|
|
15
|
+
hour: "2-digit",
|
|
16
|
+
minute: "2-digit",
|
|
17
|
+
second: "2-digit"
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
/** When an older Tencil (a stale npx cache) finds a newer daemon running, it leaves it alone. */
|
|
21
|
+
function newerDaemonLine(newer, port) {
|
|
22
|
+
return ` ${pc.yellow("!")} Tencil ${newer} is already running on port ${port}. This is ${VERSION}, which is older, so it's left alone: use ${pc.cyan("npx tencil@latest")}.`;
|
|
23
|
+
}
|
|
24
|
+
/** Print the update notice, if the registry answered in time. */
|
|
25
|
+
async function printUpdateNotice(notice, log) {
|
|
26
|
+
const text = await notice;
|
|
27
|
+
if (text) log(` ${pc.cyan("↑")} ${text}\n`);
|
|
28
|
+
}
|
|
29
|
+
//#endregion
|
|
12
30
|
//#region src/service/daemon-command.ts
|
|
13
31
|
function daemonArgs(command) {
|
|
14
32
|
return [
|
|
@@ -20,6 +38,42 @@ function daemonArgs(command) {
|
|
|
20
38
|
];
|
|
21
39
|
}
|
|
22
40
|
//#endregion
|
|
41
|
+
//#region src/service/versions.ts
|
|
42
|
+
/** Compare dotted versions by number (pre-release tags ignored): below 0, 0 or above 0. */
|
|
43
|
+
function compareVersions(a, b) {
|
|
44
|
+
const parts = (version) => version.split("-")[0]?.split(".").map(Number) ?? [];
|
|
45
|
+
const [left, right] = [parts(a), parts(b)];
|
|
46
|
+
for (let i = 0; i < Math.max(left.length, right.length); i++) {
|
|
47
|
+
const difference = (left[i] ?? 0) - (right[i] ?? 0);
|
|
48
|
+
if (difference) return difference;
|
|
49
|
+
}
|
|
50
|
+
return 0;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* npx reuses what it cached for `npx tencil`, so an older Tencil can run after
|
|
54
|
+
* a newer one was set up. It must never replace that newer daemon.
|
|
55
|
+
*/
|
|
56
|
+
function isNewerThanThis(version) {
|
|
57
|
+
return version !== void 0 && compareVersions(version, VERSION) > 0;
|
|
58
|
+
}
|
|
59
|
+
var NewerDaemonError = class extends Error {
|
|
60
|
+
constructor(running) {
|
|
61
|
+
super(`Tencil ${running} is already running and this is ${VERSION}, which is older. Run \`npx tencil@latest\` instead.`);
|
|
62
|
+
this.name = "NewerDaemonError";
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
/** The newest published Tencil, or undefined when the registry doesn't answer quickly. */
|
|
66
|
+
async function latestVersion() {
|
|
67
|
+
const response = await fetch("https://registry.npmjs.org/tencil/latest", { signal: AbortSignal.timeout(1500) }).catch(() => void 0);
|
|
68
|
+
if (!response?.ok) return void 0;
|
|
69
|
+
return (await response.json().catch(() => void 0))?.version;
|
|
70
|
+
}
|
|
71
|
+
/** A one-line nudge when a newer Tencil is published. */
|
|
72
|
+
async function updateNotice() {
|
|
73
|
+
const latest = await latestVersion();
|
|
74
|
+
return latest && isNewerThanThis(latest) ? `Tencil ${latest} is out (this is ${VERSION}): npx tencil@latest` : void 0;
|
|
75
|
+
}
|
|
76
|
+
//#endregion
|
|
23
77
|
//#region src/service/background.ts
|
|
24
78
|
/**
|
|
25
79
|
* Start the daemon in the background unless it already runs. A daemon from an
|
|
@@ -29,6 +83,11 @@ function daemonArgs(command) {
|
|
|
29
83
|
*/
|
|
30
84
|
async function startInBackground(command, dataDir) {
|
|
31
85
|
const running = await probeDaemon(command.port);
|
|
86
|
+
if (running && isNewerThanThis(running.version)) return {
|
|
87
|
+
status: "running",
|
|
88
|
+
pid: running.pid,
|
|
89
|
+
newer: running.version
|
|
90
|
+
};
|
|
32
91
|
const flags = command.args?.length ? command.args : running?.flags ?? [];
|
|
33
92
|
if (running && running.version === VERSION && sameFlags(running.flags, flags)) return {
|
|
34
93
|
status: "running",
|
|
@@ -370,6 +429,7 @@ function runtimeInstallArgs(dataDir, spec, port = DEFAULT_PORT) {
|
|
|
370
429
|
*/
|
|
371
430
|
async function enableAutostart(command, dataDir, from) {
|
|
372
431
|
const running = await probeDaemon(command.port);
|
|
432
|
+
if (running && isNewerThanThis(running.version)) throw new NewerDaemonError(running.version);
|
|
373
433
|
const args = command.args?.length ? command.args : running?.flags ?? [];
|
|
374
434
|
let cli = command.cli;
|
|
375
435
|
if (isPackageInstall(cli)) {
|
|
@@ -401,13 +461,19 @@ async function enableAutostart(command, dataDir, from) {
|
|
|
401
461
|
*/
|
|
402
462
|
async function ensureDaemon(command, dataDir) {
|
|
403
463
|
if (!isServiceInstalled(command.port)) {
|
|
404
|
-
const { status } = await startInBackground(command, dataDir);
|
|
464
|
+
const { status, newer } = await startInBackground(command, dataDir);
|
|
405
465
|
return {
|
|
406
466
|
status,
|
|
407
|
-
autostart: false
|
|
467
|
+
autostart: false,
|
|
468
|
+
newer
|
|
408
469
|
};
|
|
409
470
|
}
|
|
410
471
|
const running = await probeDaemon(command.port);
|
|
472
|
+
if (running && isNewerThanThis(running.version)) return {
|
|
473
|
+
status: "running",
|
|
474
|
+
autostart: true,
|
|
475
|
+
newer: running.version
|
|
476
|
+
};
|
|
411
477
|
const flags = command.args?.length ? command.args : running?.flags ?? [];
|
|
412
478
|
if (running && running.version === VERSION && sameFlags(running.flags, flags)) return {
|
|
413
479
|
status: "running",
|
|
@@ -868,7 +934,7 @@ async function runInit(options) {
|
|
|
868
934
|
if (options.daemon) {
|
|
869
935
|
const result = await ensureDaemon(options.daemon, defaultDataDir());
|
|
870
936
|
autostart = result.autostart;
|
|
871
|
-
log(` ${pc.green("✓")} Tencil ${result.status === "running" ? "is running" : result.status} on port ${options.daemon.port}.`);
|
|
937
|
+
log(result.newer ? newerDaemonLine(result.newer, options.daemon.port) : ` ${pc.green("✓")} Tencil ${result.status === "running" ? "is running" : result.status} on port ${options.daemon.port}.`);
|
|
872
938
|
}
|
|
873
939
|
if (!options.skipPair) await prepareProvider(await chooseProvider({
|
|
874
940
|
yes: options.yes,
|
|
@@ -1002,15 +1068,6 @@ async function connect(input, t3Url) {
|
|
|
1002
1068
|
console.log(`\n ${pc.green("✓")} Paired with T3 Code at ${target.baseUrl} ${pc.dim(`(valid until ${new Date(credential.expiresAt).toLocaleDateString()})`)}\n`);
|
|
1003
1069
|
}
|
|
1004
1070
|
//#endregion
|
|
1005
|
-
//#region src/cli/format.ts
|
|
1006
|
-
function time() {
|
|
1007
|
-
return (/* @__PURE__ */ new Date()).toLocaleTimeString([], {
|
|
1008
|
-
hour: "2-digit",
|
|
1009
|
-
minute: "2-digit",
|
|
1010
|
-
second: "2-digit"
|
|
1011
|
-
});
|
|
1012
|
-
}
|
|
1013
|
-
//#endregion
|
|
1014
1071
|
//#region src/cli/options.ts
|
|
1015
1072
|
const RUNTIME_MODES = [
|
|
1016
1073
|
"approval-required",
|
|
@@ -1095,19 +1152,31 @@ async function runDaemon(values, port, provider, t3Url, runtimeMode) {
|
|
|
1095
1152
|
async function setup(command, options = {}) {
|
|
1096
1153
|
const log = (message) => console.log(message);
|
|
1097
1154
|
log(`\n ${pc.bold("Tencil")} setup ${pc.dim(`v${VERSION}`)}\n`);
|
|
1155
|
+
const notice = updateNotice();
|
|
1098
1156
|
await prepareProvider(await chooseProvider({
|
|
1099
1157
|
...options,
|
|
1100
1158
|
log
|
|
1101
1159
|
}), options.t3Url, log);
|
|
1102
1160
|
await setUpMachine(command, options, log);
|
|
1103
|
-
log(
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1161
|
+
log(await nextSteps(options.root));
|
|
1162
|
+
await printUpdateNotice(notice, log);
|
|
1163
|
+
}
|
|
1164
|
+
/** What to do next, for the folder setup ran in. */
|
|
1165
|
+
async function nextSteps(root) {
|
|
1166
|
+
const plan = root && existsSync(join(root, "package.json")) ? await planInit(root).catch(() => void 0) : void 0;
|
|
1167
|
+
const name = pc.bold(basename(root ?? ""));
|
|
1168
|
+
const devServer = `start its dev server and press ${pc.bold("C")} on the page.`;
|
|
1169
|
+
if (plan && plan.framework.kind !== "unknown") return plan.edits.length === 0 && plan.manual.length === 0 ? `\n ${pc.green("✓")} ${name} already loads Tencil: ${devServer}\n To add Tencil to another project, run ${pc.cyan("npx tencil")} in its folder.\n` : `\n Next, add Tencil to ${name}: ${pc.cyan("npx tencil")}\n Then ${devServer}\n`;
|
|
1170
|
+
return `\n Next, in each project: ${pc.cyan("npx tencil")}\n Then ${devServer}\n`;
|
|
1107
1171
|
}
|
|
1108
1172
|
/** Ask about starting at login (yes by default), then start the daemon that way. */
|
|
1109
1173
|
async function setUpMachine(command, options, log) {
|
|
1110
1174
|
const dataDir = defaultDataDir();
|
|
1175
|
+
const running = await probeDaemon(command.port);
|
|
1176
|
+
if (running && isNewerThanThis(running.version)) {
|
|
1177
|
+
log(newerDaemonLine(running.version, command.port));
|
|
1178
|
+
return;
|
|
1179
|
+
}
|
|
1111
1180
|
if (options.yes || !process.stdin.isTTY ? true : await confirm("Start Tencil automatically when you log in?")) {
|
|
1112
1181
|
log(pc.dim(" Setting up the login service…"));
|
|
1113
1182
|
try {
|
|
@@ -1139,6 +1208,7 @@ async function confirm(question) {
|
|
|
1139
1208
|
async function quickstart(command, options) {
|
|
1140
1209
|
const log = (message) => console.log(message);
|
|
1141
1210
|
log(`\n ${pc.bold("Tencil")} ${pc.dim(`v${VERSION}`)}\n`);
|
|
1211
|
+
const notice = updateNotice();
|
|
1142
1212
|
await prepareProvider(await chooseProvider({
|
|
1143
1213
|
...options,
|
|
1144
1214
|
log
|
|
@@ -1147,8 +1217,9 @@ async function quickstart(command, options) {
|
|
|
1147
1217
|
else {
|
|
1148
1218
|
const result = await ensureDaemon(command, defaultDataDir());
|
|
1149
1219
|
const verb = result.status === "running" ? "is running" : result.status;
|
|
1150
|
-
log(` ${pc.green("✓")} Tencil ${verb} on port ${command.port}${result.autostart ? pc.dim(" (starts at login)") : ""}`);
|
|
1220
|
+
log(result.newer ? newerDaemonLine(result.newer, command.port) : ` ${pc.green("✓")} Tencil ${verb} on port ${command.port}${result.autostart ? pc.dim(" (starts at login)") : ""}`);
|
|
1151
1221
|
}
|
|
1222
|
+
await printUpdateNotice(notice, log);
|
|
1152
1223
|
const framework = await detectFramework(options.root);
|
|
1153
1224
|
if (framework.kind !== "unknown" || existsSync(join(options.root, "package.json"))) {
|
|
1154
1225
|
const apps = framework.kind === "unknown" ? await findApps(options.root) : [];
|
|
@@ -1191,7 +1262,12 @@ async function service(action, command, from) {
|
|
|
1191
1262
|
//#endregion
|
|
1192
1263
|
//#region src/cli/commands/start.ts
|
|
1193
1264
|
async function start(command) {
|
|
1265
|
+
const notice = updateNotice();
|
|
1194
1266
|
const result = await ensureDaemon(command, defaultDataDir());
|
|
1267
|
+
if (result.newer) {
|
|
1268
|
+
console.log(`\n${newerDaemonLine(result.newer, command.port)}\n`);
|
|
1269
|
+
return;
|
|
1270
|
+
}
|
|
1195
1271
|
const verb = result.status === "running" ? "is running" : result.status;
|
|
1196
1272
|
console.log(`
|
|
1197
1273
|
${pc.green("●")} ${pc.bold("Tencil")} ${verb} ${pc.dim(`(v${VERSION}, port ${command.port})`)}
|
|
@@ -1199,6 +1275,7 @@ async function start(command) {
|
|
|
1199
1275
|
Open a project's dev server and press ${pc.bold("C")} on the page. Projects need the
|
|
1200
1276
|
overlay loaded once: run ${pc.cyan("npx tencil")} in the project.${result.autostart ? "" : `\n ${pc.dim(`Start it automatically at login: ${pc.cyan("npx tencil setup")}`)}`}
|
|
1201
1277
|
`);
|
|
1278
|
+
await printUpdateNotice(notice, console.log);
|
|
1202
1279
|
}
|
|
1203
1280
|
//#endregion
|
|
1204
1281
|
//#region src/cli/commands/status.ts
|
|
@@ -1331,7 +1408,8 @@ async function main() {
|
|
|
1331
1408
|
case "setup": return setup(daemonCommand, {
|
|
1332
1409
|
yes: values.yes,
|
|
1333
1410
|
from: values.from,
|
|
1334
|
-
t3Url
|
|
1411
|
+
t3Url,
|
|
1412
|
+
root: resolve(values.root ?? process.cwd())
|
|
1335
1413
|
});
|
|
1336
1414
|
case "stop":
|
|
1337
1415
|
if (isServiceInstalled(port)) {
|