@cydm/pie 2.7.19 → 2.8.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.
Files changed (30) hide show
  1. package/README.md +6 -6
  2. package/dist/builtin/extensions/ask-user/README.md +117 -0
  3. package/dist/builtin/extensions/ask-user/index.js +3 -3
  4. package/dist/builtin/extensions/cron/index.js +166 -23
  5. package/dist/builtin/extensions/im-forward/README.md +297 -0
  6. package/dist/builtin/extensions/im-forward/index.js +319 -42
  7. package/dist/builtin/extensions/init/index.js +0 -6
  8. package/dist/builtin/extensions/mcp-adapter/README.md +27 -0
  9. package/dist/builtin/extensions/memory/index.js +323 -0
  10. package/dist/builtin/extensions/memory/package.json +18 -0
  11. package/dist/builtin/extensions/pie-ipc/README.md +21 -0
  12. package/dist/builtin/extensions/pie-ipc/index.js +16 -16
  13. package/dist/builtin/extensions/plan-mode/METHOD.md +70 -0
  14. package/dist/builtin/extensions/plan-mode/index.js +149 -82
  15. package/dist/builtin/extensions/subagent/README.md +315 -0
  16. package/dist/builtin/extensions/subagent/index.js +7 -5
  17. package/dist/builtin/extensions/todo/index.js +3 -3
  18. package/dist/builtin/skills/chrome-devtools-axi/chrome-devtools-axi-bridge.js +1 -1
  19. package/dist/builtin/skills/chrome-devtools-axi/chrome-devtools-axi-runtime.js +1 -1
  20. package/dist/builtin/skills/chrome-devtools-axi/{chunk-U75F4DPF.js → chunk-BNSAEVRT.js} +201 -77
  21. package/dist/builtin/skills/chrome-devtools-axi/{cli-4ITIR57L.js → cli-AO2ZTPRM.js} +57 -202
  22. package/dist/chunks/chunk-5353DEEC.js +130 -0
  23. package/dist/chunks/{chunk-2H2DD22Z.js → chunk-HGC25NYB.js} +1 -1
  24. package/dist/chunks/{chunk-X7UO6BA6.js → chunk-JNOFHHLZ.js} +156 -65
  25. package/dist/chunks/{chunk-UDCGB3LZ.js → chunk-LJXHECZ7.js} +12183 -10951
  26. package/dist/chunks/{chunk-TGCI5M6R.js → chunk-NEES4EBX.js} +19 -141
  27. package/dist/chunks/{src-GX4UBAYF.js → src-5XOKRS6F.js} +2 -2
  28. package/dist/chunks/{test-stream-AKIZNFCM.js → test-stream-5SDHKKDB.js} +1 -1
  29. package/dist/cli.js +127 -96
  30. package/package.json +2 -2
@@ -1,4 +1,8 @@
1
1
  import { createRequire as __createRequire } from "node:module"; const require = __createRequire(import.meta.url);
2
+ import {
3
+ getBuiltinDir,
4
+ getConfigDir
5
+ } from "./chunk-5353DEEC.js";
2
6
  import {
3
7
  classifyShellCommand,
4
8
  createSharedWebFetchTool,
@@ -7,129 +11,16 @@ import {
7
11
  defaultShellKindForPlatform,
8
12
  interpretShellExit,
9
13
  requestInteraction
10
- } from "./chunk-UDCGB3LZ.js";
14
+ } from "./chunk-LJXHECZ7.js";
11
15
  import {
12
16
  EMPTY_ASSISTANT_CONTENT_ERROR,
13
17
  OPENAI_COMPAT_PROTOCOL_ERROR_CODE,
14
18
  getLogger
15
- } from "./chunk-X7UO6BA6.js";
19
+ } from "./chunk-JNOFHHLZ.js";
16
20
  import {
17
21
  Type
18
22
  } from "./chunk-XXGYUYXI.js";
19
23
 
20
- // src/config.ts
21
- import { existsSync, mkdirSync, readFileSync, renameSync } from "fs";
22
- import { homedir } from "os";
23
- import { dirname, join } from "path";
24
- import { fileURLToPath } from "url";
25
- var __filename = fileURLToPath(import.meta.url);
26
- var __dirname = dirname(__filename);
27
- var isBunRuntime = !!process.versions.bun;
28
- function getPackageDir() {
29
- const envDir = process.env.PIE_PACKAGE_DIR;
30
- if (envDir) {
31
- if (envDir === "~") return homedir();
32
- if (envDir.startsWith("~/")) return homedir() + envDir.slice(1);
33
- return envDir;
34
- }
35
- let dir = __dirname;
36
- while (dir !== dirname(dir)) {
37
- if (existsSync(join(dir, "package.json"))) {
38
- return dir;
39
- }
40
- dir = dirname(dir);
41
- }
42
- return __dirname;
43
- }
44
- function getThemesDir() {
45
- const packageDir = getPackageDir();
46
- const srcOrDist = existsSync(join(packageDir, "src")) ? "src" : "dist";
47
- return join(packageDir, srcOrDist, "theme");
48
- }
49
- function getBuiltinDir() {
50
- const packageDir = getPackageDir();
51
- const distBuiltinDir = join(packageDir, "dist", "builtin");
52
- if (existsSync(distBuiltinDir)) {
53
- return distBuiltinDir;
54
- }
55
- return join(packageDir, "builtin");
56
- }
57
- function getPackageJsonPath() {
58
- return join(getPackageDir(), "package.json");
59
- }
60
- var pkg = JSON.parse(readFileSync(getPackageJsonPath(), "utf-8"));
61
- var CONFIG_DIR_NAME = ".pie";
62
- var VERSION = pkg.version;
63
- var ENV_AGENT_DIR = "PIE_CODING_AGENT_DIR";
64
- function getConfigDir() {
65
- const envDir = process.env[ENV_AGENT_DIR];
66
- if (envDir) {
67
- if (envDir === "~") return homedir();
68
- if (envDir.startsWith("~/")) return homedir() + envDir.slice(1);
69
- return envDir;
70
- }
71
- return join(homedir(), CONFIG_DIR_NAME);
72
- }
73
- function getAgentDir() {
74
- return getConfigDir();
75
- }
76
- function getCustomThemesDir() {
77
- return join(getConfigDir(), "themes");
78
- }
79
- function getSettingsPath() {
80
- return join(getConfigDir(), "settings.json");
81
- }
82
- function getProjectSettingsPath(cwd) {
83
- return join(cwd, CONFIG_DIR_NAME, "settings.json");
84
- }
85
- function getSessionsDir() {
86
- return join(getConfigDir(), "sessions");
87
- }
88
- function getLogsDir() {
89
- return join(getConfigDir(), "logs");
90
- }
91
- function getRuntimeLogPath() {
92
- return join(getLogsDir(), "pie-cli.log");
93
- }
94
- function migrateConfigFromAgentDir() {
95
- const oldAgentDir = join(homedir(), CONFIG_DIR_NAME, "agent");
96
- const newConfigDir = getConfigDir();
97
- if (!existsSync(oldAgentDir)) {
98
- return;
99
- }
100
- if (!existsSync(newConfigDir)) {
101
- mkdirSync(newConfigDir, { recursive: true });
102
- }
103
- const filesToMigrate = [
104
- "keybindings.json",
105
- "settings.json",
106
- "pie-debug.log"
107
- ];
108
- for (const file of filesToMigrate) {
109
- const oldPath = join(oldAgentDir, file);
110
- const newPath = file === "pie-debug.log" ? getRuntimeLogPath() : join(newConfigDir, file);
111
- if (existsSync(oldPath) && !existsSync(newPath)) {
112
- try {
113
- if (file === "pie-debug.log") {
114
- mkdirSync(getLogsDir(), { recursive: true });
115
- }
116
- renameSync(oldPath, newPath);
117
- console.log(`[Config] Migrated ${file} to ${newPath}`);
118
- } catch (e) {
119
- }
120
- }
121
- }
122
- const oldThemesDir = join(oldAgentDir, "themes");
123
- const newThemesDir = getCustomThemesDir();
124
- if (existsSync(oldThemesDir) && !existsSync(newThemesDir)) {
125
- try {
126
- renameSync(oldThemesDir, newThemesDir);
127
- console.log(`[Config] Migrated themes to ${newThemesDir}`);
128
- } catch (e) {
129
- }
130
- }
131
- }
132
-
133
24
  // src/runtime/retry-policy.ts
134
25
  var TRANSIENT_NETWORK_ERROR_PATTERN = /sse stream aborted|sse stream closed before end|sse stream ended before response completed|responses stream ended without a terminal event|(?:read\s+)?ECONNRESET|ETIMEDOUT|EAI_AGAIN|ENOTFOUND|ECONNREFUSED|(?:read\s+|write\s+)?EPIPE|socket hang up|request timeout|websocket upgrade refused|websocket handshake|websocket connection failed|websocket transport failed|connection closed before opening|client network socket disconnected before secure TLS connection was established|connection.?error|connection.?refused|other side closed|fetch failed|upstream.?connect|reset before headers|terminated/i;
135
26
  var TLS_VALIDATION_ERROR_PATTERN = /certificate (?:has )?expired|certificate is not yet valid|unable to verify (?:the first certificate|certificate)|unable to get (?:local )?issuer certificate|self[-_ ]signed cert(?:ificate)?|CERT_HAS_EXPIRED|SELF_SIGNED_CERT|does not match certificate's altnames|ERR_TLS_CERT_ALTNAME_INVALID/i;
@@ -339,9 +230,9 @@ function createTraceTransportSink(noteRuntimeEvent) {
339
230
 
340
231
  // src/capabilities/bash/index.ts
341
232
  import { spawn, spawnSync } from "child_process";
342
- import { closeSync, createWriteStream, existsSync as existsSync2, openSync, statSync, unlinkSync, writeFileSync } from "fs";
233
+ import { closeSync, createWriteStream, existsSync, openSync, statSync, unlinkSync, writeFileSync } from "fs";
343
234
  import { tmpdir } from "os";
344
- import { join as join2, resolve as resolve2 } from "path";
235
+ import { join, resolve } from "path";
345
236
  import { createHash, randomBytes } from "crypto";
346
237
 
347
238
  // src/capabilities/bash/truncate.ts
@@ -811,8 +702,8 @@ function resolveWindowsBashPath() {
811
702
  if (!resolved) {
812
703
  const programFiles = [process.env.PROGRAMFILES, process.env["PROGRAMFILES(X86)"]].filter((value) => Boolean(value));
813
704
  for (const root of programFiles) {
814
- const candidate = join2(root, "Git", "bin", "bash.exe");
815
- if (existsSync2(candidate)) {
705
+ const candidate = join(root, "Git", "bin", "bash.exe");
706
+ if (existsSync(candidate)) {
816
707
  resolved = candidate;
817
708
  break;
818
709
  }
@@ -859,7 +750,7 @@ function notifyYoloGrantAwarded(grantMs) {
859
750
  }
860
751
  }
861
752
  function validateWorkingDirectory(cwd) {
862
- if (!existsSync2(cwd)) {
753
+ if (!existsSync(cwd)) {
863
754
  throw new Error(`Invalid bash cwd: ${cwd} does not exist. Use the current workspace path or pass an existing directory in cwd.`);
864
755
  }
865
756
  let stat;
@@ -874,11 +765,11 @@ function validateWorkingDirectory(cwd) {
874
765
  }
875
766
  function normalizeWorkingDirectory(cwd, defaultCwd) {
876
767
  const requestedCwd = typeof cwd === "string" && cwd.trim().length > 0 ? cwd.trim() : void 0;
877
- return resolve2(requestedCwd ?? defaultCwd ?? process.cwd());
768
+ return resolve(requestedCwd ?? defaultCwd ?? process.cwd());
878
769
  }
879
770
  function getTempFilePath() {
880
771
  const id = randomBytes(8).toString("hex");
881
- return join2(tmpdir(), `pie-bash-${id}.log`);
772
+ return join(tmpdir(), `pie-bash-${id}.log`);
882
773
  }
883
774
  var retainedOutputArtifacts = /* @__PURE__ */ new Set();
884
775
  function getErrorCode(error) {
@@ -940,7 +831,7 @@ function cleanupBashOutputArtifacts() {
940
831
  process.once("exit", cleanupBashOutputArtifacts);
941
832
  function finishTempFileStream(stream) {
942
833
  if (!stream || stream.closed) return Promise.resolve();
943
- return new Promise((resolve3, reject) => {
834
+ return new Promise((resolve2, reject) => {
944
835
  let done = false;
945
836
  const timer = setTimeout(() => {
946
837
  stream.destroy(new Error("Timed out flushing shell output."));
@@ -954,7 +845,7 @@ function finishTempFileStream(stream) {
954
845
  if (done) return;
955
846
  done = true;
956
847
  cleanup();
957
- resolve3();
848
+ resolve2();
958
849
  };
959
850
  const onError = (error) => {
960
851
  if (done) return;
@@ -1149,7 +1040,7 @@ function createBashTool(defaultCwd, options) {
1149
1040
  }
1150
1041
  const timeoutPolicy = resolveTimeoutPolicy(timeout);
1151
1042
  const timeoutMs = timeoutPolicy.effectiveSeconds * 1e3;
1152
- return new Promise((resolve3, reject) => {
1043
+ return new Promise((resolve2, reject) => {
1153
1044
  if (signal?.aborted) {
1154
1045
  reject(new Error("Operation aborted"));
1155
1046
  return;
@@ -1469,7 +1360,7 @@ ${commandNonzeroHint}`;
1469
1360
  outputText += "\n\n[Repeat hint: this exact command already returned the same result in this session. If it proves the task, stop; otherwise change the command or inspect a different file/range.]";
1470
1361
  }
1471
1362
  const content = [{ type: "text", text: outputText }];
1472
- resolve3({ content, details, isError: outcome.toolFailure });
1363
+ resolve2({ content, details, isError: outcome.toolFailure });
1473
1364
  } catch (error) {
1474
1365
  discardOutputArtifact(tempFilePath, tempFileStream);
1475
1366
  reject(error);
@@ -1513,7 +1404,7 @@ function resolveMcpScript() {
1513
1404
  }
1514
1405
  function runAxi(args, options = {}) {
1515
1406
  const timeoutMs = options.timeoutMs ?? 6e4;
1516
- return new Promise((resolve3, reject) => {
1407
+ return new Promise((resolve2, reject) => {
1517
1408
  const child = spawn2(process.execPath, [resolveAxiCli(), ...args], {
1518
1409
  stdio: ["ignore", "pipe", "pipe"],
1519
1410
  shell: false,
@@ -1540,7 +1431,7 @@ function runAxi(args, options = {}) {
1540
1431
  });
1541
1432
  child.on("close", (code) => {
1542
1433
  clearTimeout(timer);
1543
- if (code === 0) resolve3(stdout.trim());
1434
+ if (code === 0) resolve2(stdout.trim());
1544
1435
  else reject(new Error((stderr || stdout || `chrome-devtools-axi exited with ${code}`).trim()));
1545
1436
  });
1546
1437
  });
@@ -1751,19 +1642,6 @@ function createCliHostCapabilities(cwd, options = {}) {
1751
1642
  }
1752
1643
 
1753
1644
  export {
1754
- getPackageDir,
1755
- getThemesDir,
1756
- getBuiltinDir,
1757
- VERSION,
1758
- getConfigDir,
1759
- getAgentDir,
1760
- getCustomThemesDir,
1761
- getSettingsPath,
1762
- getProjectSettingsPath,
1763
- getSessionsDir,
1764
- getLogsDir,
1765
- getRuntimeLogPath,
1766
- migrateConfigFromAgentDir,
1767
1645
  createCliWebResearchHealthStore,
1768
1646
  truncateHeadTail,
1769
1647
  formatSize,
@@ -8,8 +8,8 @@ import {
8
8
  createToolCallerIdentity,
9
9
  getAgentFailureMetadata,
10
10
  getToolCallerIdentity
11
- } from "./chunk-2H2DD22Z.js";
12
- import "./chunk-X7UO6BA6.js";
11
+ } from "./chunk-HGC25NYB.js";
12
+ import "./chunk-JNOFHHLZ.js";
13
13
  import "./chunk-XXGYUYXI.js";
14
14
  import "./chunk-LZQXQOPJ.js";
15
15
  export {
@@ -1,7 +1,7 @@
1
1
  import { createRequire as __createRequire } from "node:module"; const require = __createRequire(import.meta.url);
2
2
  import {
3
3
  EventStream
4
- } from "./chunk-X7UO6BA6.js";
4
+ } from "./chunk-JNOFHHLZ.js";
5
5
  import "./chunk-XXGYUYXI.js";
6
6
  import "./chunk-LZQXQOPJ.js";
7
7
 
package/dist/cli.js CHANGED
@@ -2,7 +2,6 @@
2
2
  import { createRequire as __createRequire } from "node:module"; const require = __createRequire(import.meta.url);
3
3
  import {
4
4
  CLI_RETRY_MAX_RETRIES,
5
- VERSION,
6
5
  classifyCliFailure,
7
6
  cleanupBashOutputArtifacts,
8
7
  createBashTool,
@@ -12,6 +11,14 @@ import {
12
11
  createTraceTransportSink,
13
12
  createTransportDiagnosticsStreamFn,
14
13
  formatSize,
14
+ isCliContextOverflowError,
15
+ isCliRetryableError,
16
+ logTransportLifecycle,
17
+ setYoloGrantListener,
18
+ truncateHeadTail
19
+ } from "./chunks/chunk-NEES4EBX.js";
20
+ import {
21
+ VERSION,
15
22
  getAgentDir,
16
23
  getBuiltinDir,
17
24
  getConfigDir,
@@ -23,13 +30,8 @@ import {
23
30
  getSessionsDir,
24
31
  getSettingsPath,
25
32
  getThemesDir,
26
- isCliContextOverflowError,
27
- isCliRetryableError,
28
- logTransportLifecycle,
29
- migrateConfigFromAgentDir,
30
- setYoloGrantListener,
31
- truncateHeadTail
32
- } from "./chunks/chunk-TGCI5M6R.js";
33
+ migrateConfigFromAgentDir
34
+ } from "./chunks/chunk-5353DEEC.js";
33
35
  import {
34
36
  AGENTS_CONTEXT_FILE_NAME,
35
37
  AgentSessionController,
@@ -91,8 +93,8 @@ import {
91
93
  shouldPreserveExecutionStateForUserText,
92
94
  supersedeExecutionState,
93
95
  verifyPreparedCompactionCommit
94
- } from "./chunks/chunk-UDCGB3LZ.js";
95
- import "./chunks/chunk-2H2DD22Z.js";
96
+ } from "./chunks/chunk-LJXHECZ7.js";
97
+ import "./chunks/chunk-HGC25NYB.js";
96
98
  import {
97
99
  Deref,
98
100
  Errors,
@@ -115,7 +117,7 @@ import {
115
117
  sortToolModelCandidatesByCapability,
116
118
  streamSimple,
117
119
  type_exports
118
- } from "./chunks/chunk-X7UO6BA6.js";
120
+ } from "./chunks/chunk-JNOFHHLZ.js";
119
121
  import {
120
122
  IsArray,
121
123
  IsBigInt,
@@ -56506,6 +56508,10 @@ function createExtensionContext(extension, cwd, uiContext, abortFn, isIdleFn, ha
56506
56508
  } else {
56507
56509
  throw new Error("Command must have path, category, or name");
56508
56510
  }
56511
+ if (cmdPath.length < 2 || cmdPath[0] !== "tools") {
56512
+ const identity = extension.identity ?? extension.path;
56513
+ throw new Error(`Extension "${identity}" cannot register /${cmdPath.join("/")}: extension commands must use /tools/<name>[/...]`);
56514
+ }
56509
56515
  const finalName = cmdPath[cmdPath.length - 1];
56510
56516
  const registeredCmd = {
56511
56517
  name: finalName,
@@ -65563,23 +65569,6 @@ function buildCliProjectContextSection(cwd) {
65563
65569
  return buildProjectContextSection(collectAncestorAgentsFiles(cwd));
65564
65570
  }
65565
65571
 
65566
- // src/runtime/computer-use-owner.ts
65567
- var COMPUTER_USE_OWNER_ENV = "PIE_COMPUTER_USE_OWNER_ID";
65568
- var COMPUTER_USE_EXECUTION_ENV = "PIE_COMPUTER_USE_EXECUTION_ID";
65569
- var COMPUTER_USE_STANDALONE_OWNER = "standalone";
65570
- var OWNER_PATTERN = /^[A-Za-z0-9][A-Za-z0-9._:@-]{0,255}$/;
65571
- function normalizeComputerUseOwner(value) {
65572
- if (typeof value !== "string") return COMPUTER_USE_STANDALONE_OWNER;
65573
- const trimmed = value.trim();
65574
- if (!trimmed) return COMPUTER_USE_STANDALONE_OWNER;
65575
- return OWNER_PATTERN.test(trimmed) ? trimmed : COMPUTER_USE_STANDALONE_OWNER;
65576
- }
65577
- function computerUseOwnerEnv(ownerId, executionId) {
65578
- const env = { [COMPUTER_USE_OWNER_ENV]: normalizeComputerUseOwner(ownerId) };
65579
- if (executionId) env[COMPUTER_USE_EXECUTION_ENV] = executionId;
65580
- return env;
65581
- }
65582
-
65583
65572
  // src/theme/theme.ts
65584
65573
  import * as fs13 from "node:fs";
65585
65574
  import * as path11 from "node:path";
@@ -67168,6 +67157,48 @@ function validateSkillName(name) {
67168
67157
  return { valid: true };
67169
67158
  }
67170
67159
 
67160
+ // src/runtime/yolo-grant.ts
67161
+ var YoloGrantTracker = class {
67162
+ untilMs = 0;
67163
+ isActive(now = Date.now()) {
67164
+ return this.untilMs > now;
67165
+ }
67166
+ remainingMs(now = Date.now()) {
67167
+ return Math.max(0, this.untilMs - now);
67168
+ }
67169
+ award(grantMs, now = Date.now()) {
67170
+ this.untilMs = now + Math.max(0, grantMs);
67171
+ }
67172
+ expire() {
67173
+ this.untilMs = 0;
67174
+ }
67175
+ /** Revoke the active grant and report whether revocation changed live state. */
67176
+ revoke() {
67177
+ const wasActive = this.isActive();
67178
+ this.expire();
67179
+ return wasActive;
67180
+ }
67181
+ /** Expiry timestamp (0 when no grant is held); useful for display. */
67182
+ get until() {
67183
+ return this.untilMs;
67184
+ }
67185
+ };
67186
+ function renderYoloGrantBanner(grantMs, sink) {
67187
+ const minutes = Math.max(1, Math.round(grantMs / 6e4));
67188
+ sink.addChild(new Spacer(1));
67189
+ sink.addChild(
67190
+ new Text(theme.fg("warning", `\u26A0\uFE0F YOLO granted for ${minutes} min (high-risk commands skip confirmation)`), 1, 0)
67191
+ );
67192
+ sink.addChild(new Spacer(1));
67193
+ }
67194
+ function parseYoloGrantMs(options, selected) {
67195
+ const yoloOption = options.find((option) => /^\s*yolo(\s*\(|\s|$)/i.test(option));
67196
+ if (!yoloOption || selected !== yoloOption) return void 0;
67197
+ const minutesMatch = /\(\s*(\d+(?:\.\d+)?)\s*min/i.exec(yoloOption);
67198
+ const minutes = minutesMatch ? Number(minutesMatch[1]) : 5;
67199
+ return Math.round(minutes * 6e4);
67200
+ }
67201
+
67171
67202
  // src/capabilities/read-file-understanding.ts
67172
67203
  import * as path21 from "node:path";
67173
67204
  import * as fs22 from "node:fs/promises";
@@ -70511,46 +70542,52 @@ function buildInteractiveFilesystemToolOptions(host, allowlistedDirs) {
70511
70542
  };
70512
70543
  }
70513
70544
 
70514
- // src/runtime/yolo-grant.ts
70515
- var YoloGrantTracker = class {
70516
- untilMs = 0;
70517
- isActive(now = Date.now()) {
70518
- return this.untilMs > now;
70519
- }
70520
- remainingMs(now = Date.now()) {
70521
- return Math.max(0, this.untilMs - now);
70522
- }
70523
- award(grantMs, now = Date.now()) {
70524
- this.untilMs = now + Math.max(0, grantMs);
70525
- }
70526
- expire() {
70527
- this.untilMs = 0;
70528
- }
70529
- /** Revoke the active grant and report whether revocation changed live state. */
70530
- revoke() {
70531
- const wasActive = this.isActive();
70532
- this.expire();
70533
- return wasActive;
70534
- }
70535
- /** Expiry timestamp (0 when no grant is held); useful for display. */
70536
- get until() {
70537
- return this.untilMs;
70538
- }
70539
- };
70540
- function renderYoloGrantBanner(grantMs, sink) {
70541
- const minutes = Math.max(1, Math.round(grantMs / 6e4));
70542
- sink.addChild(new Spacer(1));
70543
- sink.addChild(
70544
- new Text(theme.fg("warning", `\u26A0\uFE0F YOLO granted for ${minutes} min (high-risk commands skip confirmation)`), 1, 0)
70545
- );
70546
- sink.addChild(new Spacer(1));
70545
+ // src/runtime/computer-use-owner.ts
70546
+ var COMPUTER_USE_OWNER_ENV = "PIE_COMPUTER_USE_OWNER_ID";
70547
+ var COMPUTER_USE_EXECUTION_ENV = "PIE_COMPUTER_USE_EXECUTION_ID";
70548
+ var COMPUTER_USE_STANDALONE_OWNER = "standalone";
70549
+ var OWNER_PATTERN = /^[A-Za-z0-9][A-Za-z0-9._:@-]{0,255}$/;
70550
+ function normalizeComputerUseOwner(value) {
70551
+ if (typeof value !== "string") return COMPUTER_USE_STANDALONE_OWNER;
70552
+ const trimmed = value.trim();
70553
+ if (!trimmed) return COMPUTER_USE_STANDALONE_OWNER;
70554
+ return OWNER_PATTERN.test(trimmed) ? trimmed : COMPUTER_USE_STANDALONE_OWNER;
70547
70555
  }
70548
- function parseYoloGrantMs(options, selected) {
70549
- const yoloOption = options.find((option) => /^\s*yolo(\s*\(|\s|$)/i.test(option));
70550
- if (!yoloOption || selected !== yoloOption) return void 0;
70551
- const minutesMatch = /\(\s*(\d+(?:\.\d+)?)\s*min/i.exec(yoloOption);
70552
- const minutes = minutesMatch ? Number(minutesMatch[1]) : 5;
70553
- return Math.round(minutes * 6e4);
70556
+ function computerUseOwnerEnv(ownerId, executionId) {
70557
+ const env = { [COMPUTER_USE_OWNER_ENV]: normalizeComputerUseOwner(ownerId) };
70558
+ if (executionId) env[COMPUTER_USE_EXECUTION_ENV] = executionId;
70559
+ return env;
70560
+ }
70561
+
70562
+ // src/runtime/interactive-tool-rebuild.ts
70563
+ function rebuildInteractiveSkillAwareTools(host, sourceTools) {
70564
+ const preservedTools = sourceTools.filter(
70565
+ (tool) => !CLI_FILESYSTEM_TOOL_NAMES.includes(tool.name) && tool.name !== "bash" && tool.name !== "shell"
70566
+ );
70567
+ const bashTool = createBashTool(host.cwd, {
70568
+ isYoloMode: () => host.yoloMode || host.yoloGrantActive(),
70569
+ getEnv: () => computerUseOwnerEnv(host.getActiveSessionId() || COMPUTER_USE_STANDALONE_OWNER, String(process.pid))
70570
+ });
70571
+ const fileSystemToolOptions = (allowlistedDirs) => buildInteractiveFilesystemToolOptions({
70572
+ ...host,
70573
+ getPlanPolicyContext: () => ({
70574
+ mode: host.planModeEnabled ? "plan" : "normal",
70575
+ yoloMode: host.yoloMode,
70576
+ confirmationPolicy: "allow"
70577
+ })
70578
+ }, allowlistedDirs);
70579
+ const normalFsTools = createCliFileSystemTools(host.cwd, fileSystemToolOptions([host.configDir]));
70580
+ const currentFsTools = host.yoloMode ? createCliFileSystemTools(host.cwd, fileSystemToolOptions(["/"])) : normalFsTools;
70581
+ return {
70582
+ currentTools: createPolicyEnforcedTools(
70583
+ [...currentFsTools, bashTool, ...preservedTools],
70584
+ { getContext: () => host.getPolicyContext() }
70585
+ ),
70586
+ originalTools: createPolicyEnforcedTools(
70587
+ [...normalFsTools, bashTool, ...preservedTools],
70588
+ { getContext: () => host.getPolicyContext() }
70589
+ )
70590
+ };
70554
70591
  }
70555
70592
 
70556
70593
  // src/execution/state-manager.ts
@@ -77549,7 +77586,7 @@ function buildRuntimeModeContext(state) {
77549
77586
  ];
77550
77587
  if (state.planMode === "planning") {
77551
77588
  lines.push(
77552
- "- Plan mode: active (workspace read-only; plan_scratch permits session-local temporary drafts; submit the finished plan by calling plan_submit with the ordered steps for user approval)."
77589
+ "- Plan mode: active \u2014 DISCUSSION FIRST (workspace read-only; plan_scratch permits session-local temporary drafts). Grilling: interview the user in ROUNDS; each round asks every frontier question (whose prerequisites are settled), numbered (\u2753 Qn / \u27A1\uFE0F recommended answer); wait for answers before the next round; find facts yourself with read-only tools, never ask the user what you could look up; challenge wording that conflicts with settled terms. Do NOT output a plan or call plan_submit until the user explicitly asks for the plan (e.g. \u201C\u8F93\u51FA\u8BA1\u5212\u201D / \u201Cgive me the plan\u201D / /tools/plan/submit); when unsure whether they asked, ask back. When asked: decompose into MVP steps \u2014 each independently verifiable (verify criterion, ideally one command), scoped (files it touches, \u201C(new)\u201D for to-be-created), and stable (later steps build on earlier ones, no rework); one step at a time with [DONE:n]+[VERIFIED:n], failed verify stops the ladder (Retry/Revise/Abort, never Skip)."
77553
77590
  );
77554
77591
  if (state.planDisabledToolNames.length > 0) {
77555
77592
  lines.push(
@@ -77567,7 +77604,7 @@ function buildRuntimeModeContext(state) {
77567
77604
  const transitionText = {
77568
77605
  entered_yolo: "YOLO mode was just enabled for this turn.",
77569
77606
  exited_yolo: "YOLO mode was just disabled; do not assume previous absolute-path access still applies.",
77570
- entered_plan: "Plan mode was just enabled; analyze and plan without changing the workspace. Use plan_scratch for temporary drafts, then submit the finished plan by calling plan_submit with the ordered steps for user approval.",
77607
+ entered_plan: "Plan mode was just enabled \u2014 discussion-first: grill the user in rounds (numbered frontier questions + recommended answers); do not output a plan until explicitly asked. Use plan_scratch for drafts.",
77571
77608
  exited_plan: "Plan mode was just disabled; execution tools may be used when the task requires them."
77572
77609
  };
77573
77610
  lines.push(`- Transition: ${transitionText[state.pendingTransition]}`);
@@ -83621,14 +83658,11 @@ var InteractiveMode = class {
83621
83658
  confirmationPolicy: "allow"
83622
83659
  });
83623
83660
  rebuildSkillAwareTools(sourceTools) {
83624
- const preservedTools = sourceTools.filter(
83625
- (tool) => !CLI_FILESYSTEM_TOOL_NAMES.includes(tool.name) && tool.name !== "bash" && tool.name !== "shell"
83626
- );
83627
- const bashTool = createBashTool(this.options.cwd, {
83628
- isYoloMode: () => this.yoloMode || this.yoloGrant.isActive(),
83629
- getEnv: () => computerUseOwnerEnv(this.sessionManager.getActiveSessionId() || COMPUTER_USE_STANDALONE_OWNER, String(process.pid))
83630
- });
83631
- const fileSystemToolOptions = (allowlistedDirs) => buildInteractiveFilesystemToolOptions({
83661
+ return rebuildInteractiveSkillAwareTools(this.toolRebuildHost, sourceTools);
83662
+ }
83663
+ /** Adapter view over live mode/model state for the extracted tool rebuild. */
83664
+ get toolRebuildHost() {
83665
+ return {
83632
83666
  cwd: this.options.cwd,
83633
83667
  configDir: this.options.configDir,
83634
83668
  fileObservationState: this.options.fileObservationState,
@@ -83641,19 +83675,11 @@ var InteractiveMode = class {
83641
83675
  mode: this.planModeEnabled ? "plan" : "normal",
83642
83676
  yoloMode: this.yoloMode,
83643
83677
  confirmationPolicy: "allow"
83644
- })
83645
- }, allowlistedDirs);
83646
- const normalFsTools = createCliFileSystemTools(this.options.cwd, fileSystemToolOptions([this.options.configDir]));
83647
- const currentFsTools = this.yoloMode ? createCliFileSystemTools(this.options.cwd, fileSystemToolOptions(["/"])) : normalFsTools;
83648
- return {
83649
- currentTools: createPolicyEnforcedTools(
83650
- [...currentFsTools, bashTool, ...preservedTools],
83651
- { getContext: this.getPolicyContext }
83652
- ),
83653
- originalTools: createPolicyEnforcedTools(
83654
- [...normalFsTools, bashTool, ...preservedTools],
83655
- { getContext: this.getPolicyContext }
83656
- )
83678
+ }),
83679
+ yoloMode: this.yoloMode,
83680
+ planModeEnabled: this.planModeEnabled,
83681
+ yoloGrantActive: () => this.yoloGrant.isActive(),
83682
+ getPolicyContext: this.getPolicyContext
83657
83683
  };
83658
83684
  }
83659
83685
  resetFileObservationState() {
@@ -83772,7 +83798,7 @@ var InteractiveMode = class {
83772
83798
  async init() {
83773
83799
  const activeSession = this.sessionManager.getActiveSession();
83774
83800
  this.thinkingLevel = resolveInitialThinkingLevel({ session: activeSession, settingsManager: this.options.settingsManager });
83775
- const { Agent } = await import("./chunks/src-GX4UBAYF.js");
83801
+ const { Agent } = await import("./chunks/src-5XOKRS6F.js");
83776
83802
  this.agent = new Agent({
83777
83803
  initialState: {
83778
83804
  systemPrompt: this.buildSystemPrompt(),
@@ -84095,7 +84121,12 @@ var InteractiveMode = class {
84095
84121
  "/skills/create",
84096
84122
  "/skills/use",
84097
84123
  "/tools/subagent",
84098
- "/sessions/fork"
84124
+ "/sessions/fork",
84125
+ // Plan submit/revise return agent-turn instructions the hierarchical
84126
+ // menu would otherwise discard: route them into the editor so the
84127
+ // input pipeline's result-processing handles them like typed commands.
84128
+ "/tools/plan/submit",
84129
+ "/tools/plan/revise"
84099
84130
  ];
84100
84131
  return interactiveCommands.some((cmd) => commandPath.startsWith(cmd));
84101
84132
  }
@@ -84665,7 +84696,7 @@ async function runPrintMode(params) {
84665
84696
  `);
84666
84697
  console.log("Assistant: ");
84667
84698
  }
84668
- const { Agent: AgentClass } = await import("./chunks/src-GX4UBAYF.js");
84699
+ const { Agent: AgentClass } = await import("./chunks/src-5XOKRS6F.js");
84669
84700
  let agent;
84670
84701
  const printModeExtensions = await loadPrintModeExtensions({
84671
84702
  cwd: runtime.cwd,
@@ -85560,7 +85591,7 @@ async function runJsonEventsMode(params) {
85560
85591
  const sideTrace = trace;
85561
85592
  const sideApiKey = runtime.apiKey;
85562
85593
  const snapshot = structuredClone(parent.state.messages);
85563
- const { Agent: AgentClass } = await import("./chunks/src-GX4UBAYF.js");
85594
+ const { Agent: AgentClass } = await import("./chunks/src-5XOKRS6F.js");
85564
85595
  const sideAgent = new AgentClass({
85565
85596
  initialState: {
85566
85597
  systemPrompt: parent.state.systemPrompt,
@@ -85924,7 +85955,7 @@ async function runJsonEventsMode(params) {
85924
85955
  if (runtime.initialModel.unconfigured || controller) {
85925
85956
  return;
85926
85957
  }
85927
- const { Agent: AgentClass } = await import("./chunks/src-GX4UBAYF.js");
85958
+ const { Agent: AgentClass } = await import("./chunks/src-5XOKRS6F.js");
85928
85959
  if (runtimeClosing) return;
85929
85960
  const compositionRegistry = createCliHostEnvelopeRegistry();
85930
85961
  const jsonModeExtensions = await loadJsonModeExtensions({ runtime, envelopeRegistry: compositionRegistry, getAgent: () => agent });
@@ -86612,7 +86643,7 @@ async function runWithJsonEventsConsoleIsolation(fn) {
86612
86643
  }
86613
86644
  async function createCliTestStreamFnFromEnv() {
86614
86645
  if (!process.env.PIE_TEST_MOCK_STREAM_SEQUENCE) return void 0;
86615
- return (await import("./chunks/test-stream-AKIZNFCM.js")).createTestStreamFnFromSequenceEnv();
86646
+ return (await import("./chunks/test-stream-5SDHKKDB.js")).createTestStreamFnFromSequenceEnv();
86616
86647
  }
86617
86648
  function resolveJsonEventsDetailFlag() {
86618
86649
  for (let index = 0; index < process.argv.length; index += 1) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cydm/pie",
3
- "version": "2.7.19",
3
+ "version": "2.8.0",
4
4
  "description": "Pie AI Agent CLI",
5
5
  "type": "module",
6
6
  "bin": {
@@ -17,7 +17,7 @@
17
17
  "validate:models": "tsx scripts/validate-models-config.ts",
18
18
  "test": "npm run test:offline",
19
19
  "test:offline:build": "node ../../scripts/build-unity-test-deps.mjs && npm run build",
20
- "test:skill-regressions": "node --test --import tsx test/bash-lifecycle.test.ts test/bash-powershell-display.test.ts test/skill-creator-runner.test.ts test/tui-use-contract.test.ts test/tui-use-runtime.test.ts test/browser-runtime.test.ts test/axi-stop-semantics.test.ts test/computer-use-axi.test.ts test/computer-evidence.test.ts test/interactive-lifecycle.test.ts",
20
+ "test:skill-regressions": "node --test --import tsx test/bash-lifecycle.test.ts test/bash-powershell-display.test.ts test/skill-creator-runner.test.ts test/tui-use-contract.test.ts test/tui-use-runtime.test.ts test/browser-runtime.test.ts test/axi-stop-semantics.test.ts test/axi-page-routing.test.ts test/computer-use-axi.test.ts test/computer-evidence.test.ts test/interactive-lifecycle.test.ts",
21
21
  "test:offline:post": "node --test --import tsx test/remote-model-catalog.test.ts",
22
22
  "test:offline": "node ../../scripts/run-cli-offline.mjs",
23
23
  "test:offline:main": "node --test --test-concurrency=2 --import tsx test/cli-attention.test.ts test/cron.test.ts test/cron-concurrency.test.ts test/cron-dogfood.test.ts test/cron.terminal.test.ts test/cron-journey.terminal.test.ts test/builtin-extensions.test.ts test/im-forward.test.ts test/im-forward-cli.test.ts test/im-forward-integration.test.ts test/im-forward-dogfood.terminal.test.ts test/extension-user-input.test.ts test/pie-ipc-pure.test.ts test/pie-ipc-discovery.test.ts test/pie-ipc-transport.test.ts test/pie-ipc-delivery.test.ts test/pie-ipc-extension.test.ts test/pie-ipc-e2e.test.ts test/pie-ipc-security.test.ts test/pie-ipc-dogfood.test.ts test/pie-ipc-host.terminal.test.ts test/core-services.test.ts test/cli.test.ts test/cli-auto-compaction.test.ts test/execution-state-manager.test.ts test/queued-steer-execution-state.test.ts test/todo-steering-ownership.test.ts test/architecture-boundaries.test.ts test/attachment-resolver.test.ts test/kimi-attachment-provider.test.ts test/document-attachment-extension.test.ts test/auto-compact-overflow.test.ts test/auto-compaction-ui.test.ts test/tool-compaction-dogfood.terminal.test.ts test/hierarchical-command-system.test.ts test/mcp-adapter.test.ts test/herdr-agent-state.test.ts test/extensions-enablement.test.ts test/extension-selector-shortcuts.test.ts test/skill-tool-enablement.test.ts test/message-queue-unit.test.ts test/evals-harness.test.ts test/session-trace.test.ts test/json-events-sidechat-diagnostics.test.ts test/json-events-prewarm-shutdown.test.ts test/json-envelope-composition.test.ts test/subagent-session-store.test.ts test/runtime-mode-context.test.ts test/tool-policy.test.ts test/retry-policy.test.ts test/yolo-command.test.ts test/footer-lifecycle.test.ts test/footer-waiting-for-user.test.ts test/files-utils.test.ts test/source-size-guard.test.ts test/runtime-logger.test.ts test/release-readiness.test.ts test/package-artifacts.test.ts test/init-extension-contract.test.ts test/skills-runtime.test.ts test/skills-agents-discovery.test.ts test/skills-symlink.test.ts test/model-overrides.test.ts test/auth-storage.test.ts test/extension-register-provider.test.ts test/extension-reload.test.ts test/extension-terminal-input.test.ts test/extension-session-before-events.test.ts test/extension-widgets.test.ts test/extension-render-hint.test.ts test/extension-oauth-restore.test.ts test/cross-host-parity.test.ts test/tool-name-rendering.test.ts test/session-selector.test.ts test/tree-selector-pagination.test.ts test/context-report.test.ts test/context-signals.test.ts test/plan-cache-stability.test.ts test/cache-invalidation-trace.test.ts test/cache-retention.test.ts test/trace-report.test.ts test/boot-report.test.ts test/compaction-diff.test.ts test/entry-body-and-usage.test.ts test/session-control.test.ts test/terminal-title.test.ts test/interactive-controller-title.test.ts test/todo-title.terminal.test.ts test/host-envelope-dogfood.terminal.test.ts test/host-envelope-cross-mode.test.ts test/host-envelope-registry-lifecycle.test.ts test/host-envelope-migration-roundtrip.test.ts test/host-envelope-intake-order.test.ts test/plan-mode-extension.test.ts test/extension-interaction-signals.test.ts test/rendered-page-reader.test.ts test/tools-registry.test.ts test/system-prompt-contract.test.ts test/bash-yolo.test.ts test/bash-contract.test.ts test/bash-confirm-pending.test.ts test/interaction-status-lifecycle.test.ts test/bash-process-group.test.ts test/bash-artifact-sink.test.ts test/direct-bash.test.ts test/terminal-bell.test.ts test/ctrl-d-exit.test.ts test/session-display-title.test.ts test/calm-mode.test.ts test/stream-render-throttle.test.ts test/assistant-message-performance.test.ts test/message-display-resync.test.ts test/project-root.test.ts test/guard-advisory-context.test.ts test/clear-command-usage.test.ts test/daily-agent-smoke.terminal.test.ts test/slash-menu-toggles.terminal.test.ts test/cli-args.test.ts test/extensions-configured-paths.test.ts test/extensions-loader-path.test.ts test/file-picker.test.ts test/interrupt-recovery.test.ts test/mention-insert-regression.test.ts test/image-paste.test.ts test/clipboard-read-image.test.ts test/clipboard-races.test.ts test/clipboard-dogfood.terminal.test.ts test/mention-picker-navigation.test.ts test/pie-unity-rpc-skill.test.ts test/skill-creator-scripts.test.ts test/interactive-compact-command.test.ts test/computer-use-broker.test.ts test/computer-use-review-regressions.test.ts test/computer-use-safety.test.ts ../../scripts/node-test-diagnostics.test.js ../../scripts/offline-test-runner.test.js ../../scripts/unity-consumer.test.mjs ../../scripts/owned-process-cleanup.test.mjs",