@winding-labs/zest 0.0.0-stage → 0.2.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.md ADDED
@@ -0,0 +1,8 @@
1
+ Copyright (c) 2026 Winding.ai. All rights reserved.
2
+
3
+ Use of this software is governed by the terms of service at
4
+ https://meetzest.com/terms and the privacy policy at
5
+ https://meetzest.com/privacy.
6
+
7
+ Third-party components included in this distribution are listed in
8
+ THIRD-PARTY-NOTICES.md and remain subject to their own licences.
package/README.md CHANGED
@@ -1,3 +1,18 @@
1
- # Temporary Holding Version
1
+ # Zest CLI
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Measure your AI coding sessions with [Zest](https://meetzest.com). One command installs the Zest plugin of each AI coding tool you pick (Claude Code, Codex, Grok Build, Hermes, opencode, Freebuff):
4
+
5
+ ```sh
6
+ npx @winding-labs/zest
7
+ ```
8
+
9
+ It works on macOS, Linux and Windows (x64) and needs Node.js 18 or newer for the installer only. The CLI itself is a standalone binary in `~/.zest/bin/zest` (`%USERPROFILE%\.zest\bin\zest.exe` on Windows, added to your user PATH — open a new terminal afterwards), verified against SHA256 checksums shipped in the npm package. The CLI's own collector runs only for a tool moved to it with `zest enable` (an opt-in still in testing): it starts with that tool's sessions and stops after the last one closes.
10
+
11
+ - `zest status` — sign-in, collector and per-tool state
12
+ - `zest update` — update now (the CLI also updates itself; set `ZEST_NO_AUTO_UPDATE=1` to turn that off)
13
+ - `zest pause` / `zest resume` — stop or restart uploads
14
+ - `npx @winding-labs/zest --uninstall` — stop collecting and remove the hooks, shims and the binary
15
+
16
+ Each plugin signs in once inside its tool; the installer prints the command. `zest enable <tool> --replace-plugin` moves a tool to the CLI instead: it uploads what the plugin still holds and turns it off, so sessions are never collected twice. Only sessions started after setup are collected.
17
+
18
+ Binaries for each release are attached to this repository's [releases](https://github.com/Winding-Labs/zest-cli/releases).
package/bin/zest.js ADDED
@@ -0,0 +1,298 @@
1
+ #!/usr/bin/env node
2
+
3
+ // src/bootstrap.ts
4
+ import { spawnSync as spawnSync3 } from "node:child_process";
5
+ import {
6
+ chmodSync as chmodSync2,
7
+ copyFileSync,
8
+ existsSync as existsSync2,
9
+ lstatSync,
10
+ mkdirSync as mkdirSync2,
11
+ readdirSync as readdirSync2,
12
+ readlinkSync,
13
+ renameSync as renameSync2,
14
+ rmSync as rmSync2,
15
+ symlinkSync,
16
+ writeFileSync as writeFileSync2
17
+ } from "node:fs";
18
+ import { homedir as homedir2 } from "node:os";
19
+ import { delimiter, dirname as dirname2, join as join3 } from "node:path";
20
+
21
+ // ../../packages/plugin-common/release/prefetch.ts
22
+ import { spawnSync } from "node:child_process";
23
+ import { createHash } from "node:crypto";
24
+ import {
25
+ chmodSync,
26
+ createReadStream,
27
+ createWriteStream,
28
+ existsSync,
29
+ mkdirSync,
30
+ readdirSync,
31
+ readFileSync,
32
+ renameSync,
33
+ rmSync,
34
+ writeFileSync
35
+ } from "node:fs";
36
+ import { homedir } from "node:os";
37
+ import { dirname, join, resolve, sep } from "node:path";
38
+ import { pipeline } from "node:stream/promises";
39
+ import { createGunzip } from "node:zlib";
40
+ function getCacheBase(namespace) {
41
+ return join(homedir(), ".zest", "bin", namespace);
42
+ }
43
+ var DOWNLOAD_TIMEOUT_MS = 5 * 60000;
44
+ function getPlatformKey() {
45
+ const os = process.platform;
46
+ const arch = process.arch;
47
+ if (os === "darwin" && arch === "arm64")
48
+ return "darwin-arm64";
49
+ if (os === "darwin" && arch === "x64")
50
+ return "darwin-x64";
51
+ if (os === "linux" && arch === "x64")
52
+ return "linux-x64";
53
+ if (os === "linux" && arch === "arm64")
54
+ return "linux-arm64";
55
+ if (os === "win32" && arch === "x64")
56
+ return "win-x64";
57
+ return "";
58
+ }
59
+ function getBinaryName(prefix, platform) {
60
+ return platform === "win-x64" ? `${prefix}win-x64.exe` : `${prefix}${platform}`;
61
+ }
62
+ function extractZipToFile(zipPath, destPath) {
63
+ const unzip = spawnSync("unzip", ["-p", zipPath], {
64
+ encoding: "buffer",
65
+ maxBuffer: 256 * 1024 * 1024
66
+ });
67
+ if (unzip.status === 0 && unzip.stdout && unzip.stdout.length > 0) {
68
+ writeFileSync(destPath, unzip.stdout);
69
+ return;
70
+ }
71
+ const tar = spawnSync("tar", ["-xOf", zipPath], {
72
+ encoding: "buffer",
73
+ maxBuffer: 256 * 1024 * 1024
74
+ });
75
+ if (tar.status === 0 && tar.stdout && tar.stdout.length > 0) {
76
+ writeFileSync(destPath, tar.stdout);
77
+ return;
78
+ }
79
+ const detail = [unzip.stderr, tar.stderr].map((buf) => buf?.toString().trim()).filter(Boolean).join("; ");
80
+ throw new Error(`zip extract failed${detail ? `: ${detail}` : ""}`);
81
+ }
82
+ async function downloadAndVerify(url, expectedSha, destDir, binName, fetchFn = fetch, userAgent = "zest-daemon") {
83
+ mkdirSync(destDir, { recursive: true });
84
+ const tempDl = join(destDir, `.download.${process.pid}`);
85
+ const tempBin = join(destDir, `.bin.${process.pid}`);
86
+ try {
87
+ const controller = new AbortController;
88
+ const timer = setTimeout(() => controller.abort(), DOWNLOAD_TIMEOUT_MS);
89
+ try {
90
+ const res = await fetchFn(url, {
91
+ signal: controller.signal,
92
+ headers: { "User-Agent": userAgent }
93
+ });
94
+ if (!res.ok)
95
+ throw new Error(`HTTP ${res.status}`);
96
+ const fileStream = createWriteStream(tempDl);
97
+ await pipeline(res.body, fileStream);
98
+ } finally {
99
+ clearTimeout(timer);
100
+ }
101
+ if (url.endsWith(".zip")) {
102
+ extractZipToFile(tempDl, tempBin);
103
+ } else {
104
+ const gunzip = createGunzip();
105
+ const outStream = createWriteStream(tempBin);
106
+ await pipeline(createReadStream(tempDl), gunzip, outStream);
107
+ }
108
+ rmSync(tempDl, { force: true });
109
+ const hash = createHash("sha256");
110
+ await pipeline(createReadStream(tempBin), hash);
111
+ const actual = hash.digest("hex");
112
+ if (actual !== expectedSha) {
113
+ rmSync(tempBin, { force: true });
114
+ throw new Error(`SHA256 mismatch: expected ${expectedSha}, got ${actual}`);
115
+ }
116
+ const finalPath = join(destDir, binName);
117
+ renameSync(tempBin, finalPath);
118
+ chmodSync(finalPath, 493);
119
+ } catch (err) {
120
+ rmSync(tempDl, { force: true });
121
+ rmSync(tempBin, { force: true });
122
+ throw err;
123
+ }
124
+ }
125
+ function gc(cacheBase, pinnedVersion, prefetchedVersion, currentVersion, logFn) {
126
+ const keep = new Set([pinnedVersion, prefetchedVersion, currentVersion]);
127
+ try {
128
+ for (const entry of readdirSync(cacheBase, { withFileTypes: true })) {
129
+ if (!entry.isDirectory())
130
+ continue;
131
+ if (entry.name.startsWith("."))
132
+ continue;
133
+ if (keep.has(entry.name))
134
+ continue;
135
+ const versionDir = join(cacheBase, entry.name);
136
+ if (existsSync(join(versionDir, ".download-lock")))
137
+ continue;
138
+ rmSync(versionDir, { recursive: true, force: true });
139
+ }
140
+ } catch (error) {
141
+ logFn?.("warn", "Prefetch GC failed", { cacheBase, error });
142
+ }
143
+ }
144
+
145
+ // ../../packages/plugin-common/src/utils/processes.ts
146
+ import { join as join2 } from "node:path";
147
+ function windowsSystemBinary(...parts) {
148
+ return join2(process.env.SystemRoot || "C:\\Windows", "System32", ...parts);
149
+ }
150
+ var windowsPowerShell = () => windowsSystemBinary("WindowsPowerShell", "v1.0", "powershell.exe");
151
+
152
+ // ../../packages/plugin-common/src/utils/spawn-hidden.ts
153
+ var HIDDEN_LAUNCHER_FILENAME = "launch-hidden.vbs";
154
+ var HIDDEN_LAUNCHER_VBS = [
155
+ "' Launch a program hidden and detached (no console flash). Args: <exe> [args...]",
156
+ "Dim args, cmd, i",
157
+ "Set args = WScript.Arguments",
158
+ 'cmd = ""',
159
+ "For i = 0 To args.Count - 1",
160
+ ' If i > 0 Then cmd = cmd & " "',
161
+ ' cmd = cmd & """" & args(i) & """"',
162
+ "Next",
163
+ 'CreateObject("WScript.Shell").Run cmd, 0, False',
164
+ ""
165
+ ].join(`\r
166
+ `);
167
+
168
+ // src/platform/windows-path.ts
169
+ import { spawnSync as spawnSync2 } from "node:child_process";
170
+ function userPathScript(add, first = false) {
171
+ return `
172
+ $ErrorActionPreference = 'Stop'
173
+ $dir = $env:ZEST_PATH_DIR.TrimEnd('\\')
174
+ $key = Get-Item 'HKCU:\\Environment'
175
+ $raw = $key.GetValue('Path', '', 'DoNotExpandEnvironmentNames')
176
+ $parts = @($raw -split ';' | Where-Object { $_ -and [Environment]::ExpandEnvironmentVariables($_).TrimEnd('\\') -ne $dir })
177
+ if (${add ? "$true" : "$false"}) { $parts = ${first ? "@($dir) + $parts" : "$parts + $dir"} }
178
+ Set-ItemProperty -Path 'HKCU:\\Environment' -Name Path -Value ($parts -join ';') -Type ExpandString
179
+ [Environment]::SetEnvironmentVariable('ZEST_PATH_CHANGED', '1', 'User')
180
+ [Environment]::SetEnvironmentVariable('ZEST_PATH_CHANGED', $null, 'User')
181
+ `;
182
+ }
183
+ function editUserPath(dir, add, first = false) {
184
+ const result = spawnSync2(windowsPowerShell(), [
185
+ "-NoProfile",
186
+ "-NonInteractive",
187
+ "-ExecutionPolicy",
188
+ "Bypass",
189
+ "-Command",
190
+ userPathScript(add, first)
191
+ ], { env: { ...process.env, ZEST_PATH_DIR: dir }, windowsHide: true, timeout: 30000 });
192
+ return result.status === 0;
193
+ }
194
+ var addToUserPath = (dir, first = false) => editUserPath(dir, true, first);
195
+
196
+ // src/bootstrap.ts
197
+ var REPO = "Winding-Labs/zest-cli";
198
+ var VERSION = "0.2.0";
199
+ var ASSETS = JSON.parse('{"darwin-arm64":{"file":"zest-darwin-arm64.gz","sha256":"297c5aa5381658c4e1b8f4e575efe5843239a67fac25d5eed738b00ba977b2c1"},"darwin-x64":{"file":"zest-darwin-x64.gz","sha256":"4fcddd9336866be0b7ecdb6068650efb81d09324e909ee1e436de3f3821e89a3"},"linux-arm64":{"file":"zest-linux-arm64.gz","sha256":"9f79e07724ab87ae13577a1505ca83f9e15d9e3a7b12116bce4f17f3e46e53e7"},"linux-x64":{"file":"zest-linux-x64.gz","sha256":"d6682c1fd7fc74898a4b4ba8d2f657368a7bf2dc2060b647f882c29013f8dee8"},"win-x64":{"file":"zest-win-x64.exe.zip","sha256":"245e1ec5572cc7dc9380e0b9aa4cd02e29af34955da5baf5d89f1b9a7c73968d"}}');
200
+ function linkOnPath(target) {
201
+ const dir = join3(homedir2(), ".local", "bin");
202
+ const link = join3(dir, "zest");
203
+ try {
204
+ const existing = lstatSync(link, { throwIfNoEntry: false });
205
+ if (existing) {
206
+ if (!existing.isSymbolicLink() || readlinkSync(link) !== target)
207
+ return `${link} already exists and is not Zest's; run ${target} directly.`;
208
+ return onPath(dir) ? null : `add ${dir} to PATH to run it as zest.`;
209
+ }
210
+ mkdirSync2(dir, { recursive: true });
211
+ symlinkSync(target, link);
212
+ return onPath(dir) ? null : `add ${dir} to PATH to run it as zest.`;
213
+ } catch {
214
+ return `run ${target} directly.`;
215
+ }
216
+ }
217
+ var windows = process.platform === "win32";
218
+ var samePath = (a, b) => windows ? a.replace(/[\\/]+$/, "").toLowerCase() === b.replace(/[\\/]+$/, "").toLowerCase() : a === b;
219
+ var onPath = (dir) => (process.env.PATH ?? "").split(delimiter).some((entry) => samePath(entry, dir));
220
+ function addOnWindowsPath(target) {
221
+ const dir = dirname2(target);
222
+ if (onPath(dir))
223
+ return null;
224
+ return addToUserPath(dir) ? "open a new terminal to run it as zest." : `add ${dir} to your PATH to run it as zest.`;
225
+ }
226
+ function replaceWindowsExecutable(temp, stable) {
227
+ const aside = `${stable}.${process.pid}.old`;
228
+ for (let attempt = 0;; attempt++) {
229
+ try {
230
+ if (existsSync2(stable))
231
+ renameSync2(stable, aside);
232
+ renameSync2(temp, stable);
233
+ return;
234
+ } catch (error) {
235
+ if (attempt >= 20) {
236
+ if (!existsSync2(stable) && existsSync2(aside))
237
+ renameSync2(aside, stable);
238
+ rmSync2(temp, { force: true });
239
+ throw new Error(`could not replace ${stable} (${error.message}); close other zest processes and run it again`);
240
+ }
241
+ Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, 250);
242
+ }
243
+ }
244
+ }
245
+ function removeOldExecutables(dir) {
246
+ for (const name of readdirSync2(dir)) {
247
+ if (!name.startsWith("zest.exe.") || !(name.endsWith(".old") || name.endsWith(".new")))
248
+ continue;
249
+ try {
250
+ rmSync2(join3(dir, name), { force: true });
251
+ } catch {}
252
+ }
253
+ }
254
+ async function main() {
255
+ const stable = join3(homedir2(), ".zest", "bin", windows ? "zest.exe" : "zest");
256
+ const given = process.argv.slice(2);
257
+ const args = ["install", ...given[0] === "install" ? given.slice(1) : given];
258
+ if (args.includes("--uninstall")) {
259
+ if (existsSync2(stable))
260
+ return spawnSync3(stable, args, { stdio: "inherit" }).status ?? 1;
261
+ console.log("Zest CLI is not installed.");
262
+ return 0;
263
+ }
264
+ const platform = getPlatformKey();
265
+ const asset = ASSETS[platform];
266
+ if (!asset) {
267
+ console.error(`Zest CLI has no build for ${process.platform}-${process.arch} yet. Install a plugin per tool: https://meetzest.com/docs`);
268
+ return 1;
269
+ }
270
+ const cacheBase = getCacheBase("cli");
271
+ const binName = getBinaryName("zest-", platform);
272
+ const cached = join3(cacheBase, VERSION, binName);
273
+ if (!existsSync2(cached)) {
274
+ console.log(`Downloading Zest CLI ${VERSION}…`);
275
+ await downloadAndVerify(`${process.env.ZEST_DOWNLOAD_BASE_URL || `https://github.com/${REPO}/releases/download/v${VERSION}`}/${asset.file}`, asset.sha256, join3(cacheBase, VERSION), binName, fetch, `zest-installer/${VERSION}`);
276
+ }
277
+ mkdirSync2(dirname2(stable), { recursive: true });
278
+ if (windows)
279
+ removeOldExecutables(dirname2(stable));
280
+ const temp = `${stable}.${process.pid}.new`;
281
+ copyFileSync(cached, temp);
282
+ chmodSync2(temp, 493);
283
+ if (windows) {
284
+ replaceWindowsExecutable(temp, stable);
285
+ removeOldExecutables(dirname2(stable));
286
+ writeFileSync2(join3(dirname2(stable), HIDDEN_LAUNCHER_FILENAME), HIDDEN_LAUNCHER_VBS);
287
+ } else
288
+ renameSync2(temp, stable);
289
+ gc(cacheBase, VERSION, VERSION, VERSION);
290
+ const hint = windows ? addOnWindowsPath(stable) : linkOnPath(stable);
291
+ if (hint)
292
+ console.log(`Zest CLI is at ${stable}; ${hint}`);
293
+ return spawnSync3(stable, args, { stdio: "inherit" }).status ?? 1;
294
+ }
295
+ main().then((code) => process.exit(code), (error) => {
296
+ console.error(`Zest CLI could not be installed: ${error instanceof Error ? error.message : error}`);
297
+ process.exit(1);
298
+ });
package/package.json CHANGED
@@ -1,6 +1,24 @@
1
1
  {
2
2
  "name": "@winding-labs/zest",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.2.0",
4
+ "description": "Measure your AI coding sessions with Zest",
5
+ "type": "module",
6
+ "bin": {
7
+ "zest": "bin/zest.js"
8
+ },
9
+ "engines": {
10
+ "node": ">=18"
11
+ },
12
+ "files": [
13
+ "bin"
14
+ ],
15
+ "homepage": "https://meetzest.com",
16
+ "repository": {
17
+ "type": "git",
18
+ "url": "git+https://github.com/Winding-Labs/zest-cli.git"
19
+ },
20
+ "license": "SEE LICENSE IN LICENSE.md",
21
+ "publishConfig": {
22
+ "access": "public"
23
+ }
24
+ }