zcode-app-cli 3.3.6-2 → 3.3.6-4
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/README.md +14 -3
- package/bin/zcode.js +34 -4
- package/package.json +1 -1
- package/vendor/extraction.json +1 -1
- package/vendor/node_modules/@zcode/tui/dist/index.js +47 -7
package/README.md
CHANGED
|
@@ -26,11 +26,14 @@ Using `@latest` is intentional because the App-aligned release format uses a
|
|
|
26
26
|
SemVer prerelease segment such as `3.3.5-2`. The tag always points to the
|
|
27
27
|
newest validated App-plus-build release.
|
|
28
28
|
|
|
29
|
-
Interactive startup checks the npm `latest` tag at most once every 20 hours
|
|
29
|
+
Interactive startup checks the npm `latest` tag at most once every 20 hours for
|
|
30
|
+
each installed package version. Installing a different package build triggers
|
|
31
|
+
one fresh check even when an older cache entry is still within that window.
|
|
30
32
|
A cached newer version is shown as a non-blocking update card with the exact
|
|
31
33
|
install command and release-notes link. Missing or stale cache data is refreshed
|
|
32
|
-
in the background
|
|
33
|
-
delays the editor. Set
|
|
34
|
+
in the background, and a newly discovered update is shown in the current
|
|
35
|
+
session, so registry latency or failure never delays the editor. Set
|
|
36
|
+
`ZCODE_DISABLE_UPDATE_CHECK=1` or
|
|
34
37
|
`NO_UPDATE_NOTIFIER=1` to disable the check; CI environments skip it
|
|
35
38
|
automatically.
|
|
36
39
|
|
|
@@ -549,6 +552,14 @@ zcode --prompt "Explain this repository"
|
|
|
549
552
|
zcode app-server
|
|
550
553
|
```
|
|
551
554
|
|
|
555
|
+
`zcode version`, `zcode --version` and `zcode -v` identify both packaged
|
|
556
|
+
layers explicitly:
|
|
557
|
+
|
|
558
|
+
```text
|
|
559
|
+
zcode-app-cli 3.3.6-3
|
|
560
|
+
zcode-runtime 0.15.2
|
|
561
|
+
```
|
|
562
|
+
|
|
552
563
|
## Remote extraction
|
|
553
564
|
|
|
554
565
|
The same path used by CI can be run locally:
|
package/bin/zcode.js
CHANGED
|
@@ -619,24 +619,44 @@ async function runZaiOAuthLogin(options) {
|
|
|
619
619
|
//#region src/launcher.ts
|
|
620
620
|
const packageRoot = join(dirname(fileURLToPath(import.meta.url)), "..");
|
|
621
621
|
const packageManifestPath = join(packageRoot, "package.json");
|
|
622
|
+
const extractionMetadataPath = join(packageRoot, "vendor", "extraction.json");
|
|
622
623
|
const runtimePath = join(packageRoot, "vendor", "zcode.cjs");
|
|
623
624
|
const launcherPath = join(packageRoot, "bin", "zcode.js");
|
|
624
625
|
const defaultModelRetryMaxRetries = "5";
|
|
626
|
+
const versionArguments = /* @__PURE__ */ new Set([
|
|
627
|
+
"version",
|
|
628
|
+
"--version",
|
|
629
|
+
"-v"
|
|
630
|
+
]);
|
|
625
631
|
function resolveModelRetryMaxRetries(env) {
|
|
626
632
|
return env.ZCODE_MODEL_RETRY_MAX_RETRIES?.trim() || defaultModelRetryMaxRetries;
|
|
627
633
|
}
|
|
628
634
|
function resolveNodeExecutable() {
|
|
629
635
|
return process.env.ZCODE_NODE?.trim() || process.execPath;
|
|
630
636
|
}
|
|
631
|
-
function
|
|
637
|
+
function safeVersion(value) {
|
|
638
|
+
const version = typeof value === "string" ? value.trim() : "";
|
|
639
|
+
return /^[0-9A-Za-z][0-9A-Za-z.+-]{0,63}$/u.test(version) ? version : void 0;
|
|
640
|
+
}
|
|
641
|
+
function readJsonVersion(path, key) {
|
|
632
642
|
try {
|
|
633
|
-
|
|
634
|
-
const version = typeof manifest.version === "string" ? manifest.version.trim() : "";
|
|
635
|
-
return /^[0-9A-Za-z][0-9A-Za-z.+-]{0,63}$/u.test(version) ? version : void 0;
|
|
643
|
+
return safeVersion(JSON.parse(readFileSync(path, "utf8"))[key]);
|
|
636
644
|
} catch {
|
|
637
645
|
return;
|
|
638
646
|
}
|
|
639
647
|
}
|
|
648
|
+
function readDistributionVersion(manifestPath = packageManifestPath) {
|
|
649
|
+
return readJsonVersion(manifestPath, "version");
|
|
650
|
+
}
|
|
651
|
+
function readRuntimeVersion(metadataPath = extractionMetadataPath) {
|
|
652
|
+
return readJsonVersion(metadataPath, "cliVersion");
|
|
653
|
+
}
|
|
654
|
+
function isVersionInvocation(args) {
|
|
655
|
+
return args.length === 1 && versionArguments.has(args[0]);
|
|
656
|
+
}
|
|
657
|
+
function formatVersionOutput(distributionVersion, runtimeVersion) {
|
|
658
|
+
return [`zcode-app-cli ${safeVersion(distributionVersion) ?? "unknown"}`, `zcode-runtime ${safeVersion(runtimeVersion) ?? "unknown"}`].join("\n");
|
|
659
|
+
}
|
|
640
660
|
function normalizeLoginArgs(args) {
|
|
641
661
|
if (args.length === 1 && args[0] === "login") return {
|
|
642
662
|
args,
|
|
@@ -736,6 +756,16 @@ async function main(args) {
|
|
|
736
756
|
console.error("ZCode runtime is missing. Reinstall the package or run `bun run sync:local` in the source checkout.");
|
|
737
757
|
return 1;
|
|
738
758
|
}
|
|
759
|
+
if (isVersionInvocation(args)) {
|
|
760
|
+
const distributionVersion = readDistributionVersion();
|
|
761
|
+
const runtimeVersion = readRuntimeVersion();
|
|
762
|
+
if (!distributionVersion || !runtimeVersion) {
|
|
763
|
+
console.error("Unable to read npm package or bundled runtime version metadata.");
|
|
764
|
+
return 1;
|
|
765
|
+
}
|
|
766
|
+
console.log(formatVersionOutput(distributionVersion, runtimeVersion));
|
|
767
|
+
return 0;
|
|
768
|
+
}
|
|
739
769
|
try {
|
|
740
770
|
await ensureUserConfig();
|
|
741
771
|
} catch (error) {
|
package/package.json
CHANGED
package/vendor/extraction.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"appVersion": "3.3.6",
|
|
3
3
|
"cliVersion": "0.15.2",
|
|
4
|
-
"extractedAt": "2026-07-
|
|
4
|
+
"extractedAt": "2026-07-17T04:19:33.517Z",
|
|
5
5
|
"sha512": "NwQzSBf+Q5FR3VWwAEQUeALHR9jvDjRT7PJLVQ4iLOyTxPm7Lt8kMQbQXI7MJ/wEDQ0EK3FBBjJQVlJiC4Kgsw==",
|
|
6
6
|
"source": "https://cdn-zcode.z.ai/zcode/electron/releases/3.3.6/linux-x64/ZCode-3.3.6-linux-x64.deb",
|
|
7
7
|
"tui": {
|
|
@@ -276,7 +276,9 @@ function parseUpdateCache(value) {
|
|
|
276
276
|
const cache = value;
|
|
277
277
|
if (typeof cache.latestVersion !== "string" || !parseReleaseVersion(cache.latestVersion)) return void 0;
|
|
278
278
|
if (typeof cache.lastCheckedAt !== "string" || !Number.isFinite(Date.parse(cache.lastCheckedAt))) return void 0;
|
|
279
|
+
if (cache.checkedVersion !== void 0 && (typeof cache.checkedVersion !== "string" || !parseReleaseVersion(cache.checkedVersion))) return;
|
|
279
280
|
return {
|
|
281
|
+
checkedVersion: cache.checkedVersion,
|
|
280
282
|
latestVersion: cache.latestVersion,
|
|
281
283
|
lastCheckedAt: cache.lastCheckedAt
|
|
282
284
|
};
|
|
@@ -295,13 +297,17 @@ async function readStartupUpdate(options) {
|
|
|
295
297
|
const cache = await readUpdateCache(cachePath);
|
|
296
298
|
const now = options.now ?? Date.now();
|
|
297
299
|
const checkedAt = cache ? Date.parse(cache.lastCheckedAt) : NaN;
|
|
298
|
-
const refreshRequired = !cache || checkedAt < now - 72e6;
|
|
300
|
+
const refreshRequired = !cache || cache.checkedVersion !== options.currentVersion || checkedAt < now - 72e6;
|
|
299
301
|
return {
|
|
300
|
-
availableVersion: cache
|
|
302
|
+
availableVersion: cache ? availableUpdateVersion(options.currentVersion, cache.latestVersion) : void 0,
|
|
301
303
|
cachePath,
|
|
302
304
|
refreshRequired
|
|
303
305
|
};
|
|
304
306
|
}
|
|
307
|
+
function availableUpdateVersion(currentVersion, latestVersion) {
|
|
308
|
+
if (!parseReleaseVersion(currentVersion) || !parseReleaseVersion(latestVersion)) return void 0;
|
|
309
|
+
return compareReleaseVersions(latestVersion, currentVersion) > 0 ? latestVersion : void 0;
|
|
310
|
+
}
|
|
305
311
|
async function writeUpdateCache(cachePath, cache) {
|
|
306
312
|
const directory = dirname(cachePath);
|
|
307
313
|
const temporaryPath = join(directory, `.version.${process.pid}.${randomUUID()}.tmp`);
|
|
@@ -341,6 +347,7 @@ async function refreshUpdateCache(options) {
|
|
|
341
347
|
const latestVersion = typeof body === "object" && body !== null && !Array.isArray(body) ? body.version : void 0;
|
|
342
348
|
if (typeof latestVersion !== "string" || !parseReleaseVersion(latestVersion)) throw new Error("npm registry returned an invalid release version.");
|
|
343
349
|
await writeUpdateCache(options.cachePath, {
|
|
350
|
+
checkedVersion: options.currentVersion,
|
|
344
351
|
latestVersion,
|
|
345
352
|
lastCheckedAt: new Date(options.now ?? Date.now()).toISOString()
|
|
346
353
|
});
|
|
@@ -156892,6 +156899,26 @@ function isWindowedComponent(component) {
|
|
|
156892
156899
|
}
|
|
156893
156900
|
//#endregion
|
|
156894
156901
|
//#region packages/zcode-tui/src/choice-dialog.ts
|
|
156902
|
+
var ChoiceItemDetails = class {
|
|
156903
|
+
item;
|
|
156904
|
+
theme;
|
|
156905
|
+
constructor(item, theme) {
|
|
156906
|
+
this.item = item;
|
|
156907
|
+
this.theme = theme;
|
|
156908
|
+
}
|
|
156909
|
+
render(width) {
|
|
156910
|
+
const safeWidth = Math.max(1, width);
|
|
156911
|
+
const preview = this.item.preview?.render(safeWidth) ?? [];
|
|
156912
|
+
return [
|
|
156913
|
+
...wrapTerminalText(this.theme.bold(this.item.label), safeWidth),
|
|
156914
|
+
...this.item.description ? wrapTerminalText(this.theme.muted(this.item.description), safeWidth) : [],
|
|
156915
|
+
...preview.length > 0 ? ["", ...preview] : []
|
|
156916
|
+
];
|
|
156917
|
+
}
|
|
156918
|
+
invalidate() {
|
|
156919
|
+
this.item.preview?.invalidate?.();
|
|
156920
|
+
}
|
|
156921
|
+
};
|
|
156895
156922
|
var ChoiceDialog = class {
|
|
156896
156923
|
title;
|
|
156897
156924
|
prompt;
|
|
@@ -157060,6 +157087,7 @@ function choose(ui, host, theme, options) {
|
|
|
157060
157087
|
if (options.items.length === 0) return Promise.resolve(null);
|
|
157061
157088
|
return new Promise((resolve) => {
|
|
157062
157089
|
const choicesByValue = /* @__PURE__ */ new Map();
|
|
157090
|
+
const detailsByValue = /* @__PURE__ */ new Map();
|
|
157063
157091
|
const searchableItems = options.items.map((item, index) => {
|
|
157064
157092
|
const safeItem = {
|
|
157065
157093
|
...item,
|
|
@@ -157068,21 +157096,23 @@ function choose(ui, host, theme, options) {
|
|
|
157068
157096
|
};
|
|
157069
157097
|
const value = `${safeItem.label}\u0000${index}`;
|
|
157070
157098
|
choicesByValue.set(value, safeItem);
|
|
157099
|
+
if (options.showSelectedItemDetails) detailsByValue.set(value, new ChoiceItemDetails(safeItem, theme));
|
|
157071
157100
|
return {
|
|
157072
157101
|
value,
|
|
157073
157102
|
label: safeItem.label,
|
|
157074
157103
|
description: safeItem.description
|
|
157075
157104
|
};
|
|
157076
157105
|
});
|
|
157077
|
-
const
|
|
157106
|
+
const hasDetails = Boolean(options.content || options.showSelectedItemDetails || options.items.some((item) => item.preview));
|
|
157107
|
+
const maxVisible = Math.max(1, Math.min(8, searchableItems.length, Math.floor(Math.max(2, ui.terminal.rows - 8) / (hasDetails ? 2 : 1))));
|
|
157078
157108
|
const list = new SelectList(searchableItems, maxVisible, theme.select);
|
|
157079
157109
|
list.setSelectedIndex(options.selectedIndex ?? 0);
|
|
157080
157110
|
const maxContentLines = Math.max(0, ui.terminal.rows - maxVisible - 9);
|
|
157081
157111
|
const maxExpandedContentLines = Math.max(2, maxContentLines, ui.terminal.rows - 8);
|
|
157082
|
-
const hasDetails = Boolean(options.content || options.items.some((item) => item.preview));
|
|
157083
157112
|
const dialog = new ChoiceDialog(sanitizeTerminalText(options.title, { preserveSgr: false }), sanitizeTerminalText(options.prompt, { preserveSgr: false }), sanitizeTerminalText(options.help ?? (hasDetails ? "Type to filter · Up/Down choose · Ctrl+O details · PgUp/PgDn scroll · Enter confirm · Esc cancel" : "Type to filter · Up/Down choose · Enter confirm · Esc cancel · Ctrl+U clear"), { preserveSgr: false }), list, theme, options.content, sanitizeTerminalText(options.contentLabel ?? "Details", { preserveSgr: false }), maxContentLines, maxExpandedContentLines);
|
|
157084
157113
|
const previewFor = (item) => {
|
|
157085
|
-
|
|
157114
|
+
if (!item) return void 0;
|
|
157115
|
+
return options.showSelectedItemDetails ? detailsByValue.get(item.value) : choicesByValue.get(item.value)?.preview;
|
|
157086
157116
|
};
|
|
157087
157117
|
dialog.setSelectionPreview(previewFor(list.getSelectedItem()));
|
|
157088
157118
|
let settled = false;
|
|
@@ -163428,6 +163458,7 @@ const toolLifecycleEventKinds = /* @__PURE__ */ new Set([
|
|
|
163428
163458
|
]);
|
|
163429
163459
|
const terminalThemeQueryTimeoutMs = 100;
|
|
163430
163460
|
const exitUsageQueryTimeoutMs = 250;
|
|
163461
|
+
const updateAvailableBlockId = "update_available";
|
|
163431
163462
|
function modelRetryProgress(event, phase) {
|
|
163432
163463
|
const retryNumber = phase === "started" ? Math.max(1, (event.attempt ?? 2) - 1) : Math.max(1, (event.nextAttempt ?? (event.attempt ?? 1) + 1) - 1);
|
|
163433
163464
|
const maxRetries = event.maxRetries ?? (event.maxAttempts !== void 0 ? Math.max(1, event.maxAttempts - 1) : void 0);
|
|
@@ -164585,8 +164616,8 @@ var ZCodeTui = class {
|
|
|
164585
164616
|
this.ui.requestRender();
|
|
164586
164617
|
}
|
|
164587
164618
|
addUpdateAvailable(currentVersion, latestVersion) {
|
|
164588
|
-
this.currentToolGroup = void 0;
|
|
164589
164619
|
this.transcript.addBlock(new UpdateAvailableView(this.theme, currentVersion, latestVersion), {
|
|
164620
|
+
id: updateAvailableBlockId,
|
|
164590
164621
|
kind: "update",
|
|
164591
164622
|
searchText: `Update available: ${currentVersion} -> ${latestVersion}\n${updateCommand}`
|
|
164592
164623
|
});
|
|
@@ -164594,12 +164625,17 @@ var ZCodeTui = class {
|
|
|
164594
164625
|
}
|
|
164595
164626
|
startUpdateRefresh(updateCheck) {
|
|
164596
164627
|
if (!updateCheck?.refreshRequired || !this.distributionVersion) return;
|
|
164628
|
+
const currentVersion = this.distributionVersion;
|
|
164597
164629
|
const controller = new AbortController();
|
|
164598
164630
|
this.updateCheckAbortController = controller;
|
|
164599
164631
|
refreshUpdateCache({
|
|
164600
164632
|
cachePath: updateCheck.cachePath,
|
|
164601
|
-
currentVersion
|
|
164633
|
+
currentVersion,
|
|
164602
164634
|
signal: controller.signal
|
|
164635
|
+
}).then((latestVersion) => {
|
|
164636
|
+
const availableVersion = availableUpdateVersion(currentVersion, latestVersion);
|
|
164637
|
+
if (availableVersion) this.addUpdateAvailable(currentVersion, availableVersion);
|
|
164638
|
+
else if (updateCheck.availableVersion && this.transcript.removeBlock(updateAvailableBlockId)) this.ui.requestRender();
|
|
164603
164639
|
}).catch(() => {}).finally(() => {
|
|
164604
164640
|
if (this.updateCheckAbortController === controller) this.updateCheckAbortController = void 0;
|
|
164605
164641
|
});
|
|
@@ -165101,6 +165137,8 @@ var ZCodeTui = class {
|
|
|
165101
165137
|
label: "Other…",
|
|
165102
165138
|
description: "Enter a different answer"
|
|
165103
165139
|
}],
|
|
165140
|
+
contentLabel: "Option details",
|
|
165141
|
+
showSelectedItemDetails: true,
|
|
165104
165142
|
signal
|
|
165105
165143
|
});
|
|
165106
165144
|
if (!selected) return null;
|
|
@@ -165137,6 +165175,8 @@ var ZCodeTui = class {
|
|
|
165137
165175
|
description: `${selected.size + (custom ? 1 : 0)} selected`
|
|
165138
165176
|
}
|
|
165139
165177
|
],
|
|
165178
|
+
contentLabel: "Option details",
|
|
165179
|
+
showSelectedItemDetails: true,
|
|
165140
165180
|
signal
|
|
165141
165181
|
});
|
|
165142
165182
|
if (!choice) return null;
|