@cydm/pie 4.5.0 → 4.5.1

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.
@@ -1,7 +1,7 @@
1
1
  import { createRequire as __createRequire } from "node:module"; const require = __createRequire(import.meta.url);
2
2
  import {
3
3
  readProcessCommandLine
4
- } from "./chunk-X6LBWHK3.js";
4
+ } from "./chunk-7RJXKN7N.js";
5
5
  import {
6
6
  VERSION
7
7
  } from "./chunk-CBDQJMUI.js";
@@ -39,17 +39,35 @@ function versionDiffers(a, b) {
39
39
  const canon = (v) => v.trim().replace(/^v/, "").split("+")[0];
40
40
  return canon(a) !== canon(b);
41
41
  }
42
- function resolveNpm(nodePath) {
43
- const prefix = path.dirname(path.dirname(nodePath));
44
- for (const npmCli of [
42
+ function resolveNpm(nodePath, platform = process.platform, env = process.env) {
43
+ const nodeDir = path.dirname(nodePath);
44
+ const prefix = path.dirname(nodeDir);
45
+ const windows = platform === "win32";
46
+ const candidates = [
47
+ path.join(nodeDir, "node_modules", "npm", "bin", "npm-cli.js"),
45
48
  path.join(prefix, "lib", "node_modules", "npm", "bin", "npm-cli.js"),
46
49
  path.join(prefix, "node_modules", "npm", "bin", "npm-cli.js")
47
- ]) {
48
- if (fs.existsSync(npmCli)) return { command: nodePath, prefixArgs: [npmCli], reason: `node + ${npmCli}` };
50
+ ];
51
+ if (windows) {
52
+ const searchPath = Object.entries(env).find(([key]) => key.toUpperCase() === "PATH")?.[1] ?? "";
53
+ for (const dir of searchPath.split(";").filter(Boolean)) {
54
+ candidates.push(path.resolve(dir.replace(/^"(.*)"$/, "$1"), "node_modules", "npm", "bin", "npm-cli.js"));
55
+ }
56
+ }
57
+ const isFile = (file) => {
58
+ try {
59
+ return fs.statSync(file).isFile();
60
+ } catch {
61
+ return false;
62
+ }
63
+ };
64
+ for (const npmCli of candidates) {
65
+ if (isFile(npmCli)) return { command: nodePath, prefixArgs: [npmCli], reason: `node + ${npmCli}` };
49
66
  }
50
- const sibling = path.join(path.dirname(nodePath), "npm");
51
- if (fs.existsSync(sibling)) return { command: sibling, prefixArgs: [], reason: `sibling ${sibling}` };
52
- return { command: "npm", prefixArgs: [], reason: "PATH npm" };
67
+ const binary = windows ? "npm.exe" : "npm";
68
+ const sibling = path.join(nodeDir, binary);
69
+ if (isFile(sibling)) return { command: sibling, prefixArgs: [], reason: `sibling ${sibling}` };
70
+ return { command: binary, prefixArgs: [], reason: `PATH ${binary}` };
53
71
  }
54
72
  function runNpm(plan, args, timeoutMs) {
55
73
  const child = spawnSync(plan.command, [...plan.prefixArgs, ...args], {
@@ -61,7 +79,9 @@ function runNpm(plan, args, timeoutMs) {
61
79
  });
62
80
  const sanitize = (text) => text.replace(/[^\x20-\x7e\n\t]/g, "?").trim();
63
81
  const stdout = sanitize(child.stdout ?? "");
64
- const stderr = sanitize(child.stderr ?? "");
82
+ const error = child.error;
83
+ const spawnError = error ? [error.code, error.message].filter(Boolean).join(": ") : "";
84
+ const stderr = sanitize([child.stderr ?? "", spawnError].filter(Boolean).join("\n"));
65
85
  const lines = [stdout, stderr].join("\n").split("\n").filter(Boolean);
66
86
  return { code: child.status, stdout, stderr, tail: lines.slice(-8).join("\n").slice(0, 1200) };
67
87
  }
@@ -491,8 +511,8 @@ function cliEffects(paths, log) {
491
511
  restartDetail = `${r.stdout ?? ""}${r.stderr ?? ""}`.trim();
492
512
  restartFailed = r.status !== 0;
493
513
  } else if (process.platform === "win32") {
494
- spawnSync("schtasks", ["/End", "/TN", "dev.pie.manager"], { encoding: "utf8", timeout: 2e4 });
495
- const r = spawnSync("schtasks", ["/Run", "/TN", "dev.pie.manager"], { encoding: "utf8", timeout: 2e4 });
514
+ spawnSync("schtasks", ["/End", "/TN", "dev.pie.manager"], { encoding: "utf8", timeout: 2e4, windowsHide: true });
515
+ const r = spawnSync("schtasks", ["/Run", "/TN", "dev.pie.manager"], { encoding: "utf8", timeout: 2e4, windowsHide: true });
496
516
  restartDetail = `${r.stdout ?? ""}${r.stderr ?? ""}`.trim();
497
517
  restartFailed = r.status !== 0;
498
518
  } else {
package/dist/cli.js CHANGED
@@ -66231,7 +66231,7 @@ function normalizeFileManagerPlatform(platform2) {
66231
66231
  return platform2;
66232
66232
  }
66233
66233
  function getProviderDisplayName(platform2) {
66234
- if (!platform2) return "\u5F53\u524D\u5E73\u53F0";
66234
+ if (!platform2) return "Current platform";
66235
66235
  const normalized = normalizeFileManagerPlatform(platform2);
66236
66236
  return PLATFORM_DISPLAY_NAMES[normalized] || normalized;
66237
66237
  }
@@ -72621,7 +72621,7 @@ async function loadSession(host, sessionId) {
72621
72621
  try {
72622
72622
  const claim = claimSessionOwnership(sessionId, process.env.PIE_IPC_DISPLAY_NAME || `tui-pid-${process.pid}`);
72623
72623
  if ("holder" in claim) {
72624
- host.showError(`\u4F1A\u8BDD\u88AB\u5360\u7528\uFF08pid ${claim.holder.pid} ${claim.holder.holder}\uFF09\u2014\u2014\u540C\u4E00\u4F1A\u8BDD\u4E0D\u5141\u8BB8\u4E24\u4E2A\u6D3B\u8DC3\u5199\u5165\u8005`);
72624
+ host.showError(`Session is in use (pid ${claim.holder.pid}, ${claim.holder.holder}): only one active writer is allowed per session.`);
72625
72625
  return;
72626
72626
  }
72627
72627
  const success = await host.sessionManager.loadSession(sessionId);
@@ -79306,7 +79306,7 @@ async function tryBuildAttachmentContentFromExtensions(host, text) {
79306
79306
  }
79307
79307
  content.push(...fallback.content);
79308
79308
  if (fallback.processingFiles.length > 0) {
79309
- warnings.push(`\u6587\u4EF6\u5904\u7406\u4E2D: ${fallback.processingFiles.join(", ")}`);
79309
+ warnings.push(`Files are still processing: ${fallback.processingFiles.join(", ")}`);
79310
79310
  }
79311
79311
  usedAttachmentPipeline = true;
79312
79312
  }
@@ -80666,6 +80666,8 @@ function setupUI(host) {
80666
80666
  host.footer = new FooterComponent(host.footerData);
80667
80667
  host.footer.setOnRequestRender(() => host.ui.requestRender());
80668
80668
  host.footer.setAutoCompactEnabled(host.options.settingsManager.getAutoCompactEnabled());
80669
+ const usage2 = calculateContextUsage(host);
80670
+ const contextWindow = host.options.model?.contextWindow ?? 0;
80669
80671
  host.footer.setState({
80670
80672
  modelName: host.options.model ? `${host.options.model.provider}/${host.options.model.id}` : "unknown",
80671
80673
  status: "ready",
@@ -80673,7 +80675,15 @@ function setupUI(host) {
80673
80675
  calmMode: host.calmMode,
80674
80676
  yoloMode: Boolean(host.yoloMode),
80675
80677
  thinkingLevel: host.thinkingLevel,
80676
- contextWindow: host.options.model?.contextWindow ?? 0
80678
+ inputTokens: usage2.input,
80679
+ outputTokens: usage2.output,
80680
+ cacheRead: usage2.cacheRead,
80681
+ cacheWrite: usage2.cacheWrite,
80682
+ cacheWriteLong: usage2.cacheWriteLong,
80683
+ cost: usage2.cost,
80684
+ costEstimated: usage2.costEstimated,
80685
+ contextPercent: contextWindow > 0 && usage2.tokens !== null ? usage2.tokens / contextWindow * 100 : 0,
80686
+ contextWindow
80677
80687
  });
80678
80688
  onThemeChange(() => {
80679
80689
  host.streamingComponent?.invalidate();
@@ -80706,6 +80716,7 @@ function setupUI(host) {
80706
80716
  host.ui.addChild(host.footer);
80707
80717
  host.ui.addChild(host.editorContainer);
80708
80718
  host.ui.setFocus(host.editor);
80719
+ host.renderMessageHistory(host.sessionManager.getMessages());
80709
80720
  }
80710
80721
  function setupAutocomplete(host) {
80711
80722
  const provider = {
@@ -82450,7 +82461,7 @@ var kimiNativeAttachmentHandler = {
82450
82461
  if (!fileId) {
82451
82462
  return {
82452
82463
  items: [{ type: "text", text: `[${attachment.id}]` }],
82453
- warnings: ["\u9644\u4EF6\u7F3A\u5C11 fileId\uFF0C\u65E0\u6CD5\u8D70 Kimi \u539F\u751F\u5F15\u7528"]
82464
+ warnings: ["Attachment is missing fileId; Kimi native references are unavailable."]
82454
82465
  };
82455
82466
  }
82456
82467
  const modality = getModality(attachment.mimeType);
@@ -87263,7 +87274,7 @@ async function main() {
87263
87274
  return;
87264
87275
  }
87265
87276
  if (args[0] === STABLE_CLI_COMMANDS.manager) {
87266
- const { runManagerCommand } = await import("./chunks/manager-cli-2ATPC47M.js");
87277
+ const { runManagerCommand } = await import("./chunks/manager-cli-T26F3FUW.js");
87267
87278
  try {
87268
87279
  await runManagerCommand(args.slice(1));
87269
87280
  } catch (error) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cydm/pie",
3
- "version": "4.5.0",
3
+ "version": "4.5.1",
4
4
  "description": "Pie AI Agent CLI",
5
5
  "type": "module",
6
6
  "bin": {