@cydm/pie 4.11.0 → 4.12.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.
Files changed (39) hide show
  1. package/dist/builtin/extensions/ask-user/index.js +2 -2
  2. package/dist/builtin/extensions/cron/index.js +1 -1
  3. package/dist/builtin/extensions/im-forward/index.js +8724 -7393
  4. package/dist/builtin/extensions/mcp-adapter/index.js +1 -1
  5. package/dist/builtin/extensions/memory/index.js +171 -66
  6. package/dist/builtin/extensions/pie-ipc/index.js +1 -1
  7. package/dist/builtin/extensions/pie-proc/index.js +533 -50
  8. package/dist/builtin/extensions/plan-mode/index.js +2 -2
  9. package/dist/builtin/extensions/subagent/README.md +1 -1
  10. package/dist/builtin/extensions/subagent/index.js +3 -3
  11. package/dist/builtin/extensions/todo/index.js +2 -2
  12. package/dist/chunks/{auth-storage-C3FZMT7J.js → auth-storage-IJEJ2TGE.js} +1 -1
  13. package/dist/chunks/chunk-26ILLZKQ.js +400 -0
  14. package/dist/chunks/{chunk-OU33ROFD.js → chunk-3GG342QY.js} +78 -78
  15. package/dist/chunks/{chunk-IZKHSUNQ.js → chunk-CAPBTMLI.js} +18 -1
  16. package/dist/chunks/{chunk-B5GKDXVG.js → chunk-IZ4DYCJ7.js} +246 -80
  17. package/dist/chunks/{chunk-HK3FHIAH.js → chunk-KW46ND3S.js} +1999 -767
  18. package/dist/chunks/{chunk-SW2E33UL.js → chunk-LMDWWT43.js} +123 -4
  19. package/dist/chunks/{chunk-EWPPGYBU.js → chunk-OGGL6LUN.js} +55 -16
  20. package/dist/chunks/chunk-Q4NJEPIZ.js +210 -0
  21. package/dist/chunks/{chunk-KWK7KTSZ.js → chunk-Q5PSWX3B.js} +3 -3
  22. package/dist/chunks/{chunk-BTUMBUDU.js → chunk-QSXBPTOA.js} +1 -1
  23. package/dist/chunks/{chunk-5QMS6RQC.js → chunk-SXBX2P5R.js} +160 -5
  24. package/dist/chunks/{chunk-7LICWWUE.js → chunk-W37NAT3N.js} +2 -2
  25. package/dist/chunks/chunk-WTBLV6F5.js +476 -0
  26. package/dist/chunks/{chunk-BB7ETSJK.js → chunk-Y6AVNVOD.js} +150 -4
  27. package/dist/chunks/chunk-ZB5FVHI7.js +618 -0
  28. package/dist/chunks/{host-image-fallback-3TEMOQM5.js → host-image-fallback-NXY36VO2.js} +1 -1
  29. package/dist/chunks/{manager-cli-BXI4UFTJ.js → manager-cli-OTIMAWO6.js} +280 -299
  30. package/dist/chunks/{manager-upgrade-XPFXKO7A.js → manager-upgrade-DYRQ7YZ5.js} +101 -69
  31. package/dist/chunks/memory-git-C3S276QJ.js +19 -0
  32. package/dist/chunks/{model-registry-MGZO2RBN.js → model-registry-QNEPISBJ.js} +11 -3
  33. package/dist/chunks/{read-file-understanding-N2ZZQLTZ.js → read-file-understanding-ZCBNCQHG.js} +3 -3
  34. package/dist/chunks/{src-F5N6O2HR.js → src-7CU7OTQS.js} +36 -36
  35. package/dist/chunks/{src-3PSR2AAX.js → src-7MZZJVOG.js} +1 -1
  36. package/dist/cli.js +740 -512
  37. package/package.json +2 -2
  38. package/dist/chunks/chunk-L7XXKNZW.js +0 -386
  39. package/dist/chunks/chunk-ZPJ3BNQB.js +0 -126
package/dist/cli.js CHANGED
@@ -3,7 +3,7 @@ import { createRequire as __createRequire } from "node:module"; const require =
3
3
  import {
4
4
  AuthStorage,
5
5
  FileAuthStorageBackend
6
- } from "./chunks/chunk-SW2E33UL.js";
6
+ } from "./chunks/chunk-LMDWWT43.js";
7
7
  import {
8
8
  FileCache,
9
9
  FileManager,
@@ -19,22 +19,27 @@ import {
19
19
  normalizeFileManagerPlatform,
20
20
  resolvePath,
21
21
  understandReadFile
22
- } from "./chunks/chunk-BTUMBUDU.js";
22
+ } from "./chunks/chunk-QSXBPTOA.js";
23
23
  import {
24
+ MEMORY_DISTILL_RETRYABLE_EXIT_CODE,
25
+ acquireDistillLock,
26
+ createExcludeCwdFilter,
27
+ createWikiModelCall,
24
28
  distillExitCode,
25
29
  distillWorkerLogPath,
30
+ isTransientDistillError,
31
+ isWikiDreamResultRetryable,
26
32
  readDistillWorkerLog,
27
33
  runDistillAuto,
28
34
  runDistillWorkerMain,
29
35
  spawnDistillAutoWorker,
30
36
  spawnDistillWorker
31
- } from "./chunks/chunk-L7XXKNZW.js";
37
+ } from "./chunks/chunk-WTBLV6F5.js";
32
38
  import {
33
- SessionOwnershipLifecycle,
34
- claimSessionOwnership,
35
- liveSessionHolder,
36
- sessionOwnerAlive
37
- } from "./chunks/chunk-KWK7KTSZ.js";
39
+ commitCuratedMemoryBestEffort,
40
+ isMemoryGitInitialized,
41
+ readCuratedMemoryGitLog
42
+ } from "./chunks/chunk-26ILLZKQ.js";
38
43
  import {
39
44
  CLI_RETRY_MAX_RETRIES,
40
45
  classifyCliFailure,
@@ -51,14 +56,15 @@ import {
51
56
  logTransportLifecycle,
52
57
  setYoloGrantListener,
53
58
  truncateHeadTail
54
- } from "./chunks/chunk-7LICWWUE.js";
59
+ } from "./chunks/chunk-W37NAT3N.js";
55
60
  import {
56
61
  BUILTIN_TOOL_CAPABILITY_METADATA,
62
+ DEFAULT_WIKI_LIMITS,
57
63
  MemoryStore,
64
+ WikiStore,
58
65
  abortExecutionState,
59
66
  buildExecutionReminder,
60
67
  buildToolsPromptSection,
61
- consumptionSummary,
62
68
  continueExecutionState,
63
69
  createEmptyExecutionState,
64
70
  createExecutionStateStore,
@@ -69,6 +75,8 @@ import {
69
75
  createSharedWebSearchTool,
70
76
  createTodoWidgetView,
71
77
  createTwoFilesPatch,
78
+ datesBetween,
79
+ estimateWikiTokens,
72
80
  evaluateTodoClosureAfterCompletedTurn,
73
81
  evaluateTodoClosureAfterFailedTurn,
74
82
  formatSkillSummariesForPrompt,
@@ -76,10 +84,13 @@ import {
76
84
  maybeAdvanceTodoExecutionState,
77
85
  pauseExecutionState,
78
86
  restoreExecutionState,
87
+ runWikiBootstrap,
88
+ runWikiDream,
89
+ runWikiGc,
79
90
  shouldPreserveExecutionStateForUserText,
80
91
  supersedeExecutionState,
81
92
  todayKey
82
- } from "./chunks/chunk-HK3FHIAH.js";
93
+ } from "./chunks/chunk-KW46ND3S.js";
83
94
  import {
84
95
  AGENTS_CONTEXT_FILE_NAME,
85
96
  AgentSessionController,
@@ -119,13 +130,19 @@ import {
119
130
  setEnablementInMap,
120
131
  setExtensionEnabledInSettings,
121
132
  verifyPreparedCompactionCommit
122
- } from "./chunks/chunk-5QMS6RQC.js";
133
+ } from "./chunks/chunk-SXBX2P5R.js";
123
134
  import "./chunks/chunk-BQWHLYYZ.js";
124
135
  import "./chunks/chunk-F7EBZTZO.js";
125
- import "./chunks/chunk-ZPJ3BNQB.js";
136
+ import {
137
+ SessionOwnershipLifecycle,
138
+ claimSessionOwnership,
139
+ liveSessionHolder,
140
+ sessionOwnerAlive
141
+ } from "./chunks/chunk-Q5PSWX3B.js";
142
+ import "./chunks/chunk-Q4NJEPIZ.js";
126
143
  import {
127
144
  ModelRegistry
128
- } from "./chunks/chunk-B5GKDXVG.js";
145
+ } from "./chunks/chunk-IZ4DYCJ7.js";
129
146
  import {
130
147
  VERSION,
131
148
  getAgentDir,
@@ -1059,15 +1076,15 @@ var require_route = __commonJS({
1059
1076
  };
1060
1077
  }
1061
1078
  function wrapConversion(toModel, graph) {
1062
- const path28 = [graph[toModel].parent, toModel];
1079
+ const path29 = [graph[toModel].parent, toModel];
1063
1080
  let fn = conversions[graph[toModel].parent][toModel];
1064
1081
  let cur = graph[toModel].parent;
1065
1082
  while (graph[cur].parent) {
1066
- path28.unshift(graph[cur].parent);
1083
+ path29.unshift(graph[cur].parent);
1067
1084
  fn = link(conversions[graph[cur].parent][cur], fn);
1068
1085
  cur = graph[cur].parent;
1069
1086
  }
1070
- fn.conversion = path28;
1087
+ fn.conversion = path29;
1071
1088
  return fn;
1072
1089
  }
1073
1090
  module.exports = function(fromModel) {
@@ -44107,17 +44124,17 @@ var require_visit = __commonJS({
44107
44124
  visit.BREAK = BREAK;
44108
44125
  visit.SKIP = SKIP;
44109
44126
  visit.REMOVE = REMOVE;
44110
- function visit_(key, node, visitor, path28) {
44111
- const ctrl = callVisitor(key, node, visitor, path28);
44127
+ function visit_(key, node, visitor, path29) {
44128
+ const ctrl = callVisitor(key, node, visitor, path29);
44112
44129
  if (identity.isNode(ctrl) || identity.isPair(ctrl)) {
44113
- replaceNode(key, path28, ctrl);
44114
- return visit_(key, ctrl, visitor, path28);
44130
+ replaceNode(key, path29, ctrl);
44131
+ return visit_(key, ctrl, visitor, path29);
44115
44132
  }
44116
44133
  if (typeof ctrl !== "symbol") {
44117
44134
  if (identity.isCollection(node)) {
44118
- path28 = Object.freeze(path28.concat(node));
44135
+ path29 = Object.freeze(path29.concat(node));
44119
44136
  for (let i = 0; i < node.items.length; ++i) {
44120
- const ci = visit_(i, node.items[i], visitor, path28);
44137
+ const ci = visit_(i, node.items[i], visitor, path29);
44121
44138
  if (typeof ci === "number")
44122
44139
  i = ci - 1;
44123
44140
  else if (ci === BREAK)
@@ -44128,13 +44145,13 @@ var require_visit = __commonJS({
44128
44145
  }
44129
44146
  }
44130
44147
  } else if (identity.isPair(node)) {
44131
- path28 = Object.freeze(path28.concat(node));
44132
- const ck = visit_("key", node.key, visitor, path28);
44148
+ path29 = Object.freeze(path29.concat(node));
44149
+ const ck = visit_("key", node.key, visitor, path29);
44133
44150
  if (ck === BREAK)
44134
44151
  return BREAK;
44135
44152
  else if (ck === REMOVE)
44136
44153
  node.key = null;
44137
- const cv = visit_("value", node.value, visitor, path28);
44154
+ const cv = visit_("value", node.value, visitor, path29);
44138
44155
  if (cv === BREAK)
44139
44156
  return BREAK;
44140
44157
  else if (cv === REMOVE)
@@ -44155,17 +44172,17 @@ var require_visit = __commonJS({
44155
44172
  visitAsync.BREAK = BREAK;
44156
44173
  visitAsync.SKIP = SKIP;
44157
44174
  visitAsync.REMOVE = REMOVE;
44158
- async function visitAsync_(key, node, visitor, path28) {
44159
- const ctrl = await callVisitor(key, node, visitor, path28);
44175
+ async function visitAsync_(key, node, visitor, path29) {
44176
+ const ctrl = await callVisitor(key, node, visitor, path29);
44160
44177
  if (identity.isNode(ctrl) || identity.isPair(ctrl)) {
44161
- replaceNode(key, path28, ctrl);
44162
- return visitAsync_(key, ctrl, visitor, path28);
44178
+ replaceNode(key, path29, ctrl);
44179
+ return visitAsync_(key, ctrl, visitor, path29);
44163
44180
  }
44164
44181
  if (typeof ctrl !== "symbol") {
44165
44182
  if (identity.isCollection(node)) {
44166
- path28 = Object.freeze(path28.concat(node));
44183
+ path29 = Object.freeze(path29.concat(node));
44167
44184
  for (let i = 0; i < node.items.length; ++i) {
44168
- const ci = await visitAsync_(i, node.items[i], visitor, path28);
44185
+ const ci = await visitAsync_(i, node.items[i], visitor, path29);
44169
44186
  if (typeof ci === "number")
44170
44187
  i = ci - 1;
44171
44188
  else if (ci === BREAK)
@@ -44176,13 +44193,13 @@ var require_visit = __commonJS({
44176
44193
  }
44177
44194
  }
44178
44195
  } else if (identity.isPair(node)) {
44179
- path28 = Object.freeze(path28.concat(node));
44180
- const ck = await visitAsync_("key", node.key, visitor, path28);
44196
+ path29 = Object.freeze(path29.concat(node));
44197
+ const ck = await visitAsync_("key", node.key, visitor, path29);
44181
44198
  if (ck === BREAK)
44182
44199
  return BREAK;
44183
44200
  else if (ck === REMOVE)
44184
44201
  node.key = null;
44185
- const cv = await visitAsync_("value", node.value, visitor, path28);
44202
+ const cv = await visitAsync_("value", node.value, visitor, path29);
44186
44203
  if (cv === BREAK)
44187
44204
  return BREAK;
44188
44205
  else if (cv === REMOVE)
@@ -44209,23 +44226,23 @@ var require_visit = __commonJS({
44209
44226
  }
44210
44227
  return visitor;
44211
44228
  }
44212
- function callVisitor(key, node, visitor, path28) {
44229
+ function callVisitor(key, node, visitor, path29) {
44213
44230
  if (typeof visitor === "function")
44214
- return visitor(key, node, path28);
44231
+ return visitor(key, node, path29);
44215
44232
  if (identity.isMap(node))
44216
- return visitor.Map?.(key, node, path28);
44233
+ return visitor.Map?.(key, node, path29);
44217
44234
  if (identity.isSeq(node))
44218
- return visitor.Seq?.(key, node, path28);
44235
+ return visitor.Seq?.(key, node, path29);
44219
44236
  if (identity.isPair(node))
44220
- return visitor.Pair?.(key, node, path28);
44237
+ return visitor.Pair?.(key, node, path29);
44221
44238
  if (identity.isScalar(node))
44222
- return visitor.Scalar?.(key, node, path28);
44239
+ return visitor.Scalar?.(key, node, path29);
44223
44240
  if (identity.isAlias(node))
44224
- return visitor.Alias?.(key, node, path28);
44241
+ return visitor.Alias?.(key, node, path29);
44225
44242
  return void 0;
44226
44243
  }
44227
- function replaceNode(key, path28, node) {
44228
- const parent = path28[path28.length - 1];
44244
+ function replaceNode(key, path29, node) {
44245
+ const parent = path29[path29.length - 1];
44229
44246
  if (identity.isCollection(parent)) {
44230
44247
  parent.items[key] = node;
44231
44248
  } else if (identity.isPair(parent)) {
@@ -44833,10 +44850,10 @@ var require_Collection = __commonJS({
44833
44850
  var createNode = require_createNode();
44834
44851
  var identity = require_identity();
44835
44852
  var Node = require_Node();
44836
- function collectionFromPath(schema, path28, value) {
44853
+ function collectionFromPath(schema, path29, value) {
44837
44854
  let v2 = value;
44838
- for (let i = path28.length - 1; i >= 0; --i) {
44839
- const k2 = path28[i];
44855
+ for (let i = path29.length - 1; i >= 0; --i) {
44856
+ const k2 = path29[i];
44840
44857
  if (typeof k2 === "number" && Number.isInteger(k2) && k2 >= 0) {
44841
44858
  const a = [];
44842
44859
  a[k2] = v2;
@@ -44855,7 +44872,7 @@ var require_Collection = __commonJS({
44855
44872
  sourceObjects: /* @__PURE__ */ new Map()
44856
44873
  });
44857
44874
  }
44858
- var isEmptyPath = (path28) => path28 == null || typeof path28 === "object" && !!path28[Symbol.iterator]().next().done;
44875
+ var isEmptyPath = (path29) => path29 == null || typeof path29 === "object" && !!path29[Symbol.iterator]().next().done;
44859
44876
  var Collection = class extends Node.NodeBase {
44860
44877
  constructor(type, schema) {
44861
44878
  super(type);
@@ -44885,11 +44902,11 @@ var require_Collection = __commonJS({
44885
44902
  * be a Pair instance or a `{ key, value }` object, which may not have a key
44886
44903
  * that already exists in the map.
44887
44904
  */
44888
- addIn(path28, value) {
44889
- if (isEmptyPath(path28))
44905
+ addIn(path29, value) {
44906
+ if (isEmptyPath(path29))
44890
44907
  this.add(value);
44891
44908
  else {
44892
- const [key, ...rest] = path28;
44909
+ const [key, ...rest] = path29;
44893
44910
  const node = this.get(key, true);
44894
44911
  if (identity.isCollection(node))
44895
44912
  node.addIn(rest, value);
@@ -44903,8 +44920,8 @@ var require_Collection = __commonJS({
44903
44920
  * Removes a value from the collection.
44904
44921
  * @returns `true` if the item was found and removed.
44905
44922
  */
44906
- deleteIn(path28) {
44907
- const [key, ...rest] = path28;
44923
+ deleteIn(path29) {
44924
+ const [key, ...rest] = path29;
44908
44925
  if (rest.length === 0)
44909
44926
  return this.delete(key);
44910
44927
  const node = this.get(key, true);
@@ -44918,8 +44935,8 @@ var require_Collection = __commonJS({
44918
44935
  * scalar values from their surrounding node; to disable set `keepScalar` to
44919
44936
  * `true` (collections are always returned intact).
44920
44937
  */
44921
- getIn(path28, keepScalar) {
44922
- const [key, ...rest] = path28;
44938
+ getIn(path29, keepScalar) {
44939
+ const [key, ...rest] = path29;
44923
44940
  const node = this.get(key, true);
44924
44941
  if (rest.length === 0)
44925
44942
  return !keepScalar && identity.isScalar(node) ? node.value : node;
@@ -44937,8 +44954,8 @@ var require_Collection = __commonJS({
44937
44954
  /**
44938
44955
  * Checks if the collection includes a value with the key `key`.
44939
44956
  */
44940
- hasIn(path28) {
44941
- const [key, ...rest] = path28;
44957
+ hasIn(path29) {
44958
+ const [key, ...rest] = path29;
44942
44959
  if (rest.length === 0)
44943
44960
  return this.has(key);
44944
44961
  const node = this.get(key, true);
@@ -44948,8 +44965,8 @@ var require_Collection = __commonJS({
44948
44965
  * Sets a value in this collection. For `!!set`, `value` needs to be a
44949
44966
  * boolean to add/remove the item from the set.
44950
44967
  */
44951
- setIn(path28, value) {
44952
- const [key, ...rest] = path28;
44968
+ setIn(path29, value) {
44969
+ const [key, ...rest] = path29;
44953
44970
  if (rest.length === 0) {
44954
44971
  this.set(key, value);
44955
44972
  } else {
@@ -47461,9 +47478,9 @@ var require_Document = __commonJS({
47461
47478
  this.contents.add(value);
47462
47479
  }
47463
47480
  /** Adds a value to the document. */
47464
- addIn(path28, value) {
47481
+ addIn(path29, value) {
47465
47482
  if (assertCollection(this.contents))
47466
- this.contents.addIn(path28, value);
47483
+ this.contents.addIn(path29, value);
47467
47484
  }
47468
47485
  /**
47469
47486
  * Create a new `Alias` node, ensuring that the target `node` has the required anchor.
@@ -47538,14 +47555,14 @@ var require_Document = __commonJS({
47538
47555
  * Removes a value from the document.
47539
47556
  * @returns `true` if the item was found and removed.
47540
47557
  */
47541
- deleteIn(path28) {
47542
- if (Collection.isEmptyPath(path28)) {
47558
+ deleteIn(path29) {
47559
+ if (Collection.isEmptyPath(path29)) {
47543
47560
  if (this.contents == null)
47544
47561
  return false;
47545
47562
  this.contents = null;
47546
47563
  return true;
47547
47564
  }
47548
- return assertCollection(this.contents) ? this.contents.deleteIn(path28) : false;
47565
+ return assertCollection(this.contents) ? this.contents.deleteIn(path29) : false;
47549
47566
  }
47550
47567
  /**
47551
47568
  * Returns item at `key`, or `undefined` if not found. By default unwraps
@@ -47560,10 +47577,10 @@ var require_Document = __commonJS({
47560
47577
  * scalar values from their surrounding node; to disable set `keepScalar` to
47561
47578
  * `true` (collections are always returned intact).
47562
47579
  */
47563
- getIn(path28, keepScalar) {
47564
- if (Collection.isEmptyPath(path28))
47580
+ getIn(path29, keepScalar) {
47581
+ if (Collection.isEmptyPath(path29))
47565
47582
  return !keepScalar && identity.isScalar(this.contents) ? this.contents.value : this.contents;
47566
- return identity.isCollection(this.contents) ? this.contents.getIn(path28, keepScalar) : void 0;
47583
+ return identity.isCollection(this.contents) ? this.contents.getIn(path29, keepScalar) : void 0;
47567
47584
  }
47568
47585
  /**
47569
47586
  * Checks if the document includes a value with the key `key`.
@@ -47574,10 +47591,10 @@ var require_Document = __commonJS({
47574
47591
  /**
47575
47592
  * Checks if the document includes a value at `path`.
47576
47593
  */
47577
- hasIn(path28) {
47578
- if (Collection.isEmptyPath(path28))
47594
+ hasIn(path29) {
47595
+ if (Collection.isEmptyPath(path29))
47579
47596
  return this.contents !== void 0;
47580
- return identity.isCollection(this.contents) ? this.contents.hasIn(path28) : false;
47597
+ return identity.isCollection(this.contents) ? this.contents.hasIn(path29) : false;
47581
47598
  }
47582
47599
  /**
47583
47600
  * Sets a value in this document. For `!!set`, `value` needs to be a
@@ -47594,13 +47611,13 @@ var require_Document = __commonJS({
47594
47611
  * Sets a value in this document. For `!!set`, `value` needs to be a
47595
47612
  * boolean to add/remove the item from the set.
47596
47613
  */
47597
- setIn(path28, value) {
47598
- if (Collection.isEmptyPath(path28)) {
47614
+ setIn(path29, value) {
47615
+ if (Collection.isEmptyPath(path29)) {
47599
47616
  this.contents = value;
47600
47617
  } else if (this.contents == null) {
47601
- this.contents = Collection.collectionFromPath(this.schema, Array.from(path28), value);
47618
+ this.contents = Collection.collectionFromPath(this.schema, Array.from(path29), value);
47602
47619
  } else if (assertCollection(this.contents)) {
47603
- this.contents.setIn(path28, value);
47620
+ this.contents.setIn(path29, value);
47604
47621
  }
47605
47622
  }
47606
47623
  /**
@@ -49557,9 +49574,9 @@ var require_cst_visit = __commonJS({
49557
49574
  visit.BREAK = BREAK;
49558
49575
  visit.SKIP = SKIP;
49559
49576
  visit.REMOVE = REMOVE;
49560
- visit.itemAtPath = (cst, path28) => {
49577
+ visit.itemAtPath = (cst, path29) => {
49561
49578
  let item = cst;
49562
- for (const [field, index] of path28) {
49579
+ for (const [field, index] of path29) {
49563
49580
  const tok = item?.[field];
49564
49581
  if (tok && "items" in tok) {
49565
49582
  item = tok.items[index];
@@ -49568,23 +49585,23 @@ var require_cst_visit = __commonJS({
49568
49585
  }
49569
49586
  return item;
49570
49587
  };
49571
- visit.parentCollection = (cst, path28) => {
49572
- const parent = visit.itemAtPath(cst, path28.slice(0, -1));
49573
- const field = path28[path28.length - 1][0];
49588
+ visit.parentCollection = (cst, path29) => {
49589
+ const parent = visit.itemAtPath(cst, path29.slice(0, -1));
49590
+ const field = path29[path29.length - 1][0];
49574
49591
  const coll = parent?.[field];
49575
49592
  if (coll && "items" in coll)
49576
49593
  return coll;
49577
49594
  throw new Error("Parent collection not found");
49578
49595
  };
49579
- function _visit(path28, item, visitor) {
49580
- let ctrl = visitor(item, path28);
49596
+ function _visit(path29, item, visitor) {
49597
+ let ctrl = visitor(item, path29);
49581
49598
  if (typeof ctrl === "symbol")
49582
49599
  return ctrl;
49583
49600
  for (const field of ["key", "value"]) {
49584
49601
  const token = item[field];
49585
49602
  if (token && "items" in token) {
49586
49603
  for (let i = 0; i < token.items.length; ++i) {
49587
- const ci = _visit(Object.freeze(path28.concat([[field, i]])), token.items[i], visitor);
49604
+ const ci = _visit(Object.freeze(path29.concat([[field, i]])), token.items[i], visitor);
49588
49605
  if (typeof ci === "number")
49589
49606
  i = ci - 1;
49590
49607
  else if (ci === BREAK)
@@ -49595,10 +49612,10 @@ var require_cst_visit = __commonJS({
49595
49612
  }
49596
49613
  }
49597
49614
  if (typeof ctrl === "function" && field === "key")
49598
- ctrl = ctrl(item, path28);
49615
+ ctrl = ctrl(item, path29);
49599
49616
  }
49600
49617
  }
49601
- return typeof ctrl === "function" ? ctrl(item, path28) : ctrl;
49618
+ return typeof ctrl === "function" ? ctrl(item, path29) : ctrl;
49602
49619
  }
49603
49620
  exports.visit = visit;
49604
49621
  }
@@ -50883,14 +50900,14 @@ var require_parser2 = __commonJS({
50883
50900
  case "scalar":
50884
50901
  case "single-quoted-scalar":
50885
50902
  case "double-quoted-scalar": {
50886
- const fs25 = this.flowScalar(this.type);
50903
+ const fs26 = this.flowScalar(this.type);
50887
50904
  if (atNextItem || it.value) {
50888
- map.items.push({ start, key: fs25, sep: [] });
50905
+ map.items.push({ start, key: fs26, sep: [] });
50889
50906
  this.onKeyLine = true;
50890
50907
  } else if (it.sep) {
50891
- this.stack.push(fs25);
50908
+ this.stack.push(fs26);
50892
50909
  } else {
50893
- Object.assign(it, { key: fs25, sep: [] });
50910
+ Object.assign(it, { key: fs26, sep: [] });
50894
50911
  this.onKeyLine = true;
50895
50912
  }
50896
50913
  return;
@@ -51018,13 +51035,13 @@ var require_parser2 = __commonJS({
51018
51035
  case "scalar":
51019
51036
  case "single-quoted-scalar":
51020
51037
  case "double-quoted-scalar": {
51021
- const fs25 = this.flowScalar(this.type);
51038
+ const fs26 = this.flowScalar(this.type);
51022
51039
  if (!it || it.value)
51023
- fc.items.push({ start: [], key: fs25, sep: [] });
51040
+ fc.items.push({ start: [], key: fs26, sep: [] });
51024
51041
  else if (it.sep)
51025
- this.stack.push(fs25);
51042
+ this.stack.push(fs26);
51026
51043
  else
51027
- Object.assign(it, { key: fs25, sep: [] });
51044
+ Object.assign(it, { key: fs26, sep: [] });
51028
51045
  return;
51029
51046
  }
51030
51047
  case "flow-map-end":
@@ -51333,8 +51350,8 @@ var require_dist2 = __commonJS({
51333
51350
  });
51334
51351
 
51335
51352
  // src/cli.ts
51336
- import * as fs24 from "fs";
51337
- import * as path27 from "path";
51353
+ import * as fs25 from "fs";
51354
+ import * as path28 from "path";
51338
51355
 
51339
51356
  // src/debug/file-logger.ts
51340
51357
  import * as fs from "fs";
@@ -54287,10 +54304,196 @@ function runCapabilitiesCommand(args) {
54287
54304
  console.log(formatCapabilitiesHelp(report));
54288
54305
  }
54289
54306
 
54290
- // src/commands/memory-cli.ts
54307
+ // src/commands/memory-wiki-cli.ts
54291
54308
  import * as fs5 from "node:fs";
54292
- import { homedir as homedir2 } from "node:os";
54293
54309
  import * as path5 from "node:path";
54310
+ function parseFlag(args, name) {
54311
+ const idx = args.indexOf(name);
54312
+ if (idx === -1) return {};
54313
+ const val = args[idx + 1];
54314
+ if (val === void 0 || val.startsWith("-")) {
54315
+ return { error: `${name} requires a value` };
54316
+ }
54317
+ return { value: val };
54318
+ }
54319
+ function appendLog(memoryRoot, line) {
54320
+ try {
54321
+ fs5.mkdirSync(memoryRoot, { recursive: true });
54322
+ fs5.appendFileSync(distillWorkerLogPath(memoryRoot), `[${(/* @__PURE__ */ new Date()).toISOString()}] ${line}
54323
+ `);
54324
+ } catch {
54325
+ }
54326
+ }
54327
+ async function runWikiCommand(args, memoryRoot) {
54328
+ const [sub, ...rest] = args;
54329
+ const modelFlag = parseFlag(rest, "--model");
54330
+ if (modelFlag.error) {
54331
+ console.error(`pie memory wiki: ${modelFlag.error}`);
54332
+ process.exitCode = 2;
54333
+ return;
54334
+ }
54335
+ const sessionsDirFlag = parseFlag(rest, "--sessions-dir");
54336
+ if (sessionsDirFlag.error) {
54337
+ console.error(`pie memory wiki: ${sessionsDirFlag.error}`);
54338
+ process.exitCode = 2;
54339
+ return;
54340
+ }
54341
+ const dateFlag = parseFlag(rest, "--date");
54342
+ if (dateFlag.error) {
54343
+ console.error(`pie memory wiki: ${dateFlag.error}`);
54344
+ process.exitCode = 2;
54345
+ return;
54346
+ }
54347
+ const daysFlag = parseFlag(rest, "--days");
54348
+ if (daysFlag.error) {
54349
+ console.error(`pie memory wiki: ${daysFlag.error}`);
54350
+ process.exitCode = 2;
54351
+ return;
54352
+ }
54353
+ if (sub === "status" || sub === void 0) {
54354
+ const wiki = new WikiStore(memoryRoot);
54355
+ const active = wiki.listActivePages();
54356
+ const archived = wiki.listArchivedPages();
54357
+ const meta = wiki.readMeta();
54358
+ const idx = wiki.readPage("index.md") ?? "";
54359
+ console.log(`wiki root: ${wiki.wikiDir}`);
54360
+ console.log(`status: ${wiki.exists() ? "active" : "not bootstrapped (run `pie memory wiki bootstrap`)"}`);
54361
+ console.log(`pages: ${active.length}/${DEFAULT_WIKI_LIMITS.maxActivePages} active, ${archived.length} archived`);
54362
+ if (idx) console.log(`index.md: ~${estimateWikiTokens(idx)}/${DEFAULT_WIKI_LIMITS.maxIndexTokens} tokens (${idx.split("\n").length - 1} lines)`);
54363
+ if (meta.lastBootstrapAt) console.log(`last bootstrap: ${new Date(meta.lastBootstrapAt).toISOString()}`);
54364
+ if (meta.lastDreamAt) console.log(`last dream: ${new Date(meta.lastDreamAt).toISOString()}`);
54365
+ if (meta.lastGcAt) console.log(`last gc: ${new Date(meta.lastGcAt).toISOString()}`);
54366
+ console.log(`curated git: ${isMemoryGitInitialized(memoryRoot) ? "initialized" : "not initialized"}`);
54367
+ for (const rel of active) {
54368
+ const body = wiki.readPage(rel) ?? "";
54369
+ const lines = body.split(/\r?\n/).length - 1;
54370
+ console.log(` - ${rel} (${lines} lines, ${body.length} chars)`);
54371
+ }
54372
+ return;
54373
+ }
54374
+ if (sub === "log") {
54375
+ const nFlag = parseFlag(rest, "-n");
54376
+ const limit = nFlag.value ? Number(nFlag.value) : 10;
54377
+ const lines = readCuratedMemoryGitLog(memoryRoot, Number.isFinite(limit) ? limit : 10);
54378
+ console.log(lines.length === 0 ? "No curated memory git commits yet." : lines.join("\n"));
54379
+ return;
54380
+ }
54381
+ if (sub === "bootstrap") {
54382
+ const release = acquireDistillLock(memoryRoot);
54383
+ if (!release) {
54384
+ console.error("pie memory wiki bootstrap: busy (another memory worker holds the lock)");
54385
+ process.exitCode = 75;
54386
+ return;
54387
+ }
54388
+ try {
54389
+ const registry = new ModelRegistry(AuthStorage.create());
54390
+ const balancedCall = createWikiModelCall(registry, "balanced", modelFlag.value);
54391
+ const result = await runWikiBootstrap({ memoryRoot, balancedCall });
54392
+ appendLog(memoryRoot, `[wiki] bootstrap ok=${result.ok} written=${result.written.length}${result.error ? ` error=${result.error}` : ""}`);
54393
+ if (!result.ok) {
54394
+ const err = result.error ?? "unknown";
54395
+ console.error(`wiki bootstrap failed: ${err}`);
54396
+ if (result.violations?.length) console.error(result.violations.join("\n"));
54397
+ process.exitCode = !result.violations?.length && isTransientDistillError(err) ? MEMORY_DISTILL_RETRYABLE_EXIT_CODE : 1;
54398
+ return;
54399
+ }
54400
+ const git = commitCuratedMemoryBestEffort(memoryRoot, `wiki(bootstrap): ${todayKey()} (${result.written.length} pages)`);
54401
+ console.log(`wiki bootstrap ok: ${result.written.length} page(s) written (${result.written.join(", ")})`);
54402
+ for (const s of result.summaries) console.log(` - ${s}`);
54403
+ console.log(git.committed ? `curated git commit: ${git.sha}` : `curated git: skipped (${git.reason})`);
54404
+ } finally {
54405
+ release();
54406
+ }
54407
+ return;
54408
+ }
54409
+ if (sub === "dream") {
54410
+ const release = acquireDistillLock(memoryRoot);
54411
+ if (!release) {
54412
+ console.error("pie memory wiki dream: busy (another memory worker holds the lock)");
54413
+ process.exitCode = 75;
54414
+ return;
54415
+ }
54416
+ try {
54417
+ const now = Date.now();
54418
+ let dates;
54419
+ if (dateFlag.value) {
54420
+ dates = [dateFlag.value];
54421
+ } else {
54422
+ const days = Math.min(Math.max(1, Number(daysFlag.value ?? 2) || 2), 14);
54423
+ const fromTs = now - (days - 1) * 24 * 60 * 60 * 1e3;
54424
+ dates = datesBetween(fromTs, now);
54425
+ }
54426
+ const registry = new ModelRegistry(AuthStorage.create());
54427
+ const lightCall = createWikiModelCall(registry, "light", modelFlag.value);
54428
+ const balancedCall = createWikiModelCall(registry, "balanced", modelFlag.value);
54429
+ const sessionsDir = sessionsDirFlag.value ? path5.resolve(sessionsDirFlag.value) : getSessionsDir();
54430
+ const cwdFilter = await createExcludeCwdFilter();
54431
+ const result = await runWikiDream({
54432
+ sessionStore: new FileSessionStore(sessionsDir),
54433
+ memoryRoot,
54434
+ dates,
54435
+ lightCall,
54436
+ balancedCall,
54437
+ cwdFilter,
54438
+ log: (m2) => appendLog(memoryRoot, m2)
54439
+ });
54440
+ appendLog(memoryRoot, `[wiki] dream dates=${dates.join(",")} ok=${result.ok} sessions=${result.sessionsHarvested} signals=${result.signalsAuthenticated} written=${result.written.length}${result.error ? ` error=${result.error}` : ""}`);
54441
+ const summaryNote = result.summaries[0] ?? `${result.written.length} pages`;
54442
+ const git = result.written.length > 0 || result.archived.length > 0 ? commitCuratedMemoryBestEffort(memoryRoot, `wiki(dream): ${dates.join(",")} \u2014 ${summaryNote}`) : { committed: false, reason: "no-changes" };
54443
+ if (!result.ok) {
54444
+ const err = result.error ?? "unknown";
54445
+ if (result.written.length > 0) {
54446
+ console.log(`wiki dream partial progress (${dates.join(", ")}): wrote ${result.written.length} page(s); ${git.committed ? `curated git commit: ${git.sha}` : `curated git: ${git.reason}`}`);
54447
+ }
54448
+ const isOverflow = err.startsWith("wiki dream batch overflow");
54449
+ console.error(isOverflow ? `wiki dream deferred (${err}) \u2014 re-run the same command to process remaining session(s)` : `wiki dream failed: ${err}`);
54450
+ if (result.violations?.length) console.error(result.violations.join("\n"));
54451
+ process.exitCode = isWikiDreamResultRetryable(result) ? MEMORY_DISTILL_RETRYABLE_EXIT_CODE : 1;
54452
+ return;
54453
+ }
54454
+ console.log(`wiki dream ok (${dates.join(", ")}): harvested ${result.sessionsHarvested} session(s), ${result.signalsAuthenticated} verified signal(s), wrote ${result.written.length} page(s)`);
54455
+ for (const s of result.summaries) console.log(` - ${s}`);
54456
+ console.log(git.committed ? `curated git commit: ${git.sha}` : `curated git: ${git.reason}`);
54457
+ } finally {
54458
+ release();
54459
+ }
54460
+ return;
54461
+ }
54462
+ if (sub === "gc") {
54463
+ const release = acquireDistillLock(memoryRoot);
54464
+ if (!release) {
54465
+ console.error("pie memory wiki gc: busy (another memory worker holds the lock)");
54466
+ process.exitCode = 75;
54467
+ return;
54468
+ }
54469
+ try {
54470
+ const registry = new ModelRegistry(AuthStorage.create());
54471
+ const balancedCall = createWikiModelCall(registry, "balanced", modelFlag.value);
54472
+ const result = await runWikiGc({ memoryRoot, balancedCall });
54473
+ appendLog(memoryRoot, `[wiki] gc ok=${result.ok} archived=${result.archivedInactive.length} expired=${result.expiredAnchorsFound.length} compressed=${result.compressedPages.length}${result.error ? ` error=${result.error}` : ""}`);
54474
+ const git = result.archivedInactive.length > 0 || result.compressedPages.length > 0 ? commitCuratedMemoryBestEffort(memoryRoot, `wiki(gc): ${todayKey()} (archived ${result.archivedInactive.length}, pruned ${result.compressedPages.length})`) : { committed: false, reason: "no-changes" };
54475
+ if (!result.ok) {
54476
+ const err = result.error ?? "unknown";
54477
+ console.error(`wiki gc failed: ${err}`);
54478
+ process.exitCode = isTransientDistillError(err) ? MEMORY_DISTILL_RETRYABLE_EXIT_CODE : 1;
54479
+ return;
54480
+ }
54481
+ console.log(`wiki gc ok: archived ${result.archivedInactive.length} inactive project(s), found ${result.expiredAnchorsFound.length} expired anchor(s), compressed ${result.compressedPages.length} page(s)`);
54482
+ for (const s of result.summaries) console.log(` - ${s}`);
54483
+ console.log(git.committed ? `curated git commit: ${git.sha}` : `curated git: ${git.reason}`);
54484
+ } finally {
54485
+ release();
54486
+ }
54487
+ return;
54488
+ }
54489
+ console.error(`pie memory wiki: unknown subcommand "${sub}". Use: bootstrap | dream | gc | status | log`);
54490
+ process.exitCode = 2;
54491
+ }
54492
+
54493
+ // src/commands/memory-cli.ts
54494
+ import * as fs6 from "node:fs";
54495
+ import { homedir as homedir2 } from "node:os";
54496
+ import * as path6 from "node:path";
54294
54497
  import { pathToFileURL } from "node:url";
54295
54498
  var DATE_RE = /^\d{4}-\d{2}-\d{2}$/;
54296
54499
  var MEMORY_MANAGER = "memory";
@@ -54303,6 +54506,8 @@ Usage:
54303
54506
  pie memory schedule on [--time HH:MM] | off | status daily managed cron job
54304
54507
  pie memory status [--memory-root <dir>] per-date checkpoints + failures
54305
54508
  pie memory log [--memory-root <dir>] [-n <lines>] tail the worker log
54509
+ pie memory wiki bootstrap | dream | gc | status | log [options] structured wiki & dreaming
54510
+ pie memory dream [--date YYYY-MM-DD | --days N] [--model <p/m>] shortcut for wiki dream
54306
54511
 
54307
54512
  The default date is yesterday (local). --auto covers the last 7 days.`);
54308
54513
  process.exit(code);
@@ -54333,7 +54538,7 @@ function findUnknownMemoryFlag(args, valueFlags, booleanFlags = []) {
54333
54538
  }
54334
54539
  return void 0;
54335
54540
  }
54336
- function parseFlag(args, name) {
54541
+ function parseFlag2(args, name) {
54337
54542
  const prefix = `${name}=`;
54338
54543
  for (const arg of args) {
54339
54544
  if (arg.startsWith(prefix)) {
@@ -54352,7 +54557,7 @@ function parseFlag(args, name) {
54352
54557
  return {};
54353
54558
  }
54354
54559
  function parseDateFlag(args) {
54355
- const parsed = parseFlag(args, "--date");
54560
+ const parsed = parseFlag2(args, "--date");
54356
54561
  if (parsed.error) return parsed;
54357
54562
  if (parsed.value === void 0) return {};
54358
54563
  if (!DATE_RE.test(parsed.value)) {
@@ -54366,25 +54571,25 @@ function parseDateFlag(args) {
54366
54571
  return { value: parsed.value };
54367
54572
  }
54368
54573
  function parseMemoryRootFlag(args) {
54369
- const parsed = parseFlag(args, "--memory-root");
54574
+ const parsed = parseFlag2(args, "--memory-root");
54370
54575
  if (parsed.error) return parsed;
54371
54576
  if (parsed.value !== void 0 && parsed.value.length === 0) return { error: "--memory-root requires a value" };
54372
54577
  return parsed;
54373
54578
  }
54374
54579
  function parseSessionsDirFlag(args) {
54375
- const parsed = parseFlag(args, "--sessions-dir");
54580
+ const parsed = parseFlag2(args, "--sessions-dir");
54376
54581
  if (parsed.error) return parsed;
54377
54582
  if (parsed.value !== void 0) {
54378
- if (!path5.isAbsolute(parsed.value)) {
54583
+ if (!path6.isAbsolute(parsed.value)) {
54379
54584
  return { error: `--sessions-dir must be an absolute path, got "${parsed.value}"` };
54380
54585
  }
54381
- return { value: path5.resolve(parsed.value) };
54586
+ return { value: path6.resolve(parsed.value) };
54382
54587
  }
54383
54588
  return {};
54384
54589
  }
54385
54590
  function parseLogLimit(args) {
54386
54591
  for (const name of ["-n", "--lines"]) {
54387
- const parsed = parseFlag(args, name);
54592
+ const parsed = parseFlag2(args, name);
54388
54593
  if (parsed.error) return { value: 20, error: parsed.error };
54389
54594
  if (parsed.value === void 0) continue;
54390
54595
  if (!/^\d+$/.test(parsed.value)) return { value: 20, error: `${name} must be a positive integer, got "${parsed.value}"` };
@@ -54399,12 +54604,18 @@ function die(message) {
54399
54604
  async function runMemoryCommand(args) {
54400
54605
  const [sub, ...rest] = args;
54401
54606
  if (sub === void 0 || sub === "help" || sub === "--help" || sub === "-h") usage(sub === void 0 ? 2 : 0);
54402
- if ((sub === "distill" || sub === "schedule" || sub === "status" || sub === "log") && (rest.includes("--help") || rest.includes("-h"))) {
54607
+ if ((sub === "distill" || sub === "schedule" || sub === "status" || sub === "log" || sub === "wiki" || sub === "dream") && (rest.includes("--help") || rest.includes("-h"))) {
54403
54608
  usage(0);
54404
54609
  }
54405
54610
  const rootFlag = parseMemoryRootFlag(args);
54406
54611
  if (rootFlag.error) die(rootFlag.error);
54407
- const root = rootFlag.value ?? path5.join(getConfigDir(), "memory");
54612
+ const root = rootFlag.value ?? path6.join(getConfigDir(), "memory");
54613
+ if (sub === "wiki") {
54614
+ return runWikiCommand(rest, root);
54615
+ }
54616
+ if (sub === "dream") {
54617
+ return runWikiCommand(["dream", ...rest], root);
54618
+ }
54408
54619
  if (sub === "schedule") {
54409
54620
  if (rootFlag.value !== void 0) die("--memory-root is not supported for 'schedule' (the managed job always distills the default memory root)");
54410
54621
  return runScheduleCommand(rest);
@@ -54449,9 +54660,9 @@ async function runMemoryCommand(args) {
54449
54660
  return;
54450
54661
  }
54451
54662
  const date = dateFlag.value ?? yesterdayKey();
54452
- const store = new MemoryStore(root);
54453
- if (store.hasRun(date)) {
54454
- console.log(`memory distill ${date}: already distilled (checkpoint present)`);
54663
+ const wiki = new WikiStore(root);
54664
+ if (wiki.hasDreamedDate(date)) {
54665
+ console.log(`memory distill ${date}: already dreamed (checkpoint present)`);
54455
54666
  return;
54456
54667
  }
54457
54668
  const spawned = spawnDistillWorker(root, date, sessionsDirFlag.value);
@@ -54463,22 +54674,32 @@ async function runMemoryCommand(args) {
54463
54674
  const unknown = findUnknownMemoryFlag(rest, ["--memory-root"]);
54464
54675
  if (unknown) die(`unknown option "${unknown}" for 'status' (run \`pie memory --help\` for usage)`);
54465
54676
  const store = new MemoryStore(root);
54466
- const runs = Object.entries(store.loadState().runs).sort(([a], [b2]) => a < b2 ? 1 : -1);
54677
+ const wiki = new WikiStore(root);
54678
+ const meta = wiki.readMeta();
54679
+ const active = wiki.listActivePages();
54680
+ const archived = wiki.listArchivedPages();
54681
+ const idx = wiki.readPage("index.md") ?? "";
54467
54682
  const schedule = describeMemorySchedule();
54468
- if (schedule) console.log(`schedule: ${schedule}`);
54469
- const latestOk = runs.find(([, run]) => run.ops !== void 0 && (run.failures ?? 0) === 0);
54470
- if (latestOk) console.log(`last successful distillation: ${latestOk[0]} (${new Date(latestOk[1].ranAt).toISOString()})`);
54471
- else console.log("last successful distillation: none recorded (check `pie memory log` for failures)");
54472
- for (const line of consumptionSummary(store.loadEntries())) console.log(line);
54473
- if (runs.length === 0) {
54474
- console.log("No distillation runs recorded yet.");
54475
- return;
54476
- }
54477
- for (const [date, run] of runs) {
54478
- const failures = run.failures;
54479
- const failureNote = failures && failures > 0 ? ` \xB7 failed ${failures}\xD7${run.lastError ? `: ${run.lastError}` : ""}` : "";
54480
- console.log(`${date}: ${run.ops} ops at ${new Date(run.ranAt).toISOString()}${run.gated ? " (gated)" : ""}${failureNote}`);
54481
- }
54683
+ if (schedule) {
54684
+ if (schedule.includes("(blocked:")) {
54685
+ console.log(`WARNING: memory schedule is BLOCKED \u2014 ${schedule}. Inspect \`pie memory log\` and resume via \`/panel\` Cron or \`pie memory schedule on\`.`);
54686
+ }
54687
+ console.log(`schedule: ${schedule}`);
54688
+ }
54689
+ console.log(`wiki: ${wiki.exists() ? "active" : "not bootstrapped"} (${active.length}/${DEFAULT_WIKI_LIMITS.maxActivePages} active, ${archived.length} archived)`);
54690
+ if (idx) console.log(`index.md: ~${estimateWikiTokens(idx)}/${DEFAULT_WIKI_LIMITS.maxIndexTokens} tokens`);
54691
+ console.log(`last dream: ${meta.lastDreamAt ? new Date(meta.lastDreamAt).toISOString() : "none recorded"}`);
54692
+ if (meta.lastGcAt) console.log(`last gc: ${new Date(meta.lastGcAt).toISOString()}`);
54693
+ if (meta.lastDreamError) {
54694
+ const when = meta.lastDreamFailedAt ? new Date(meta.lastDreamFailedAt).toISOString() : "unknown";
54695
+ console.log(`last dream error (${meta.lastDreamFailedDate ?? "?"} at ${when}): ${meta.lastDreamError}`);
54696
+ }
54697
+ const dreamed = [...meta.dreamedDates ?? []].sort().reverse();
54698
+ if (dreamed.length > 0) console.log(`recent dreamed dates: ${dreamed.slice(0, 7).join(", ")}`);
54699
+ console.log(`curated git: ${isMemoryGitInitialized(root) ? "initialized" : "not initialized"}`);
54700
+ const entries = store.loadEntries();
54701
+ const prefs = entries.filter((e) => e.surface === "user").length;
54702
+ console.log(`explicit memories: ${entries.length} total (${prefs} user preferences)`);
54482
54703
  return;
54483
54704
  }
54484
54705
  if (sub === "log") {
@@ -54493,20 +54714,20 @@ async function runMemoryCommand(args) {
54493
54714
  usage(2);
54494
54715
  }
54495
54716
  async function cronStore() {
54496
- const entryUrl = pathToFileURL(path5.join(getBuiltinDir(), "extensions", "cron", "index.js")).href;
54717
+ const entryUrl = pathToFileURL(path6.join(getBuiltinDir(), "extensions", "cron", "index.js")).href;
54497
54718
  const { Store, configPath } = await import(entryUrl);
54498
54719
  return { Store, configPath };
54499
54720
  }
54500
54721
  function resolvedSessionsDirOverride() {
54501
54722
  const override = process.env.PIE_SESSIONS_DIR;
54502
54723
  if (!override) return void 0;
54503
- if (override === "~") return path5.join(homedir2(), "sessions");
54504
- if (override.startsWith("~/")) return path5.join(homedir2(), override.slice(2));
54505
- if (!path5.isAbsolute(override)) return void 0;
54506
- return path5.resolve(override);
54724
+ if (override === "~") return path6.join(homedir2(), "sessions");
54725
+ if (override.startsWith("~/")) return path6.join(homedir2(), override.slice(2));
54726
+ if (!path6.isAbsolute(override)) return void 0;
54727
+ return path6.resolve(override);
54507
54728
  }
54508
54729
  function managedMemoryCommand() {
54509
- const entry = process.argv[1] ? path5.resolve(process.argv[1]) : null;
54730
+ const entry = process.argv[1] ? path6.resolve(process.argv[1]) : null;
54510
54731
  if (!entry) throw new Error("cannot determine the CLI entrypoint for the managed schedule");
54511
54732
  const loaderArgs = [];
54512
54733
  for (let i = 0; i < process.execArgv.length; i++) {
@@ -54525,7 +54746,7 @@ function managedMemoryCommand() {
54525
54746
  "--worker",
54526
54747
  "--auto",
54527
54748
  "--memory-root",
54528
- path5.join(getConfigDir(), "memory"),
54749
+ path6.join(getConfigDir(), "memory"),
54529
54750
  ...sessionsDir ? ["--sessions-dir", sessionsDir] : []
54530
54751
  ];
54531
54752
  }
@@ -54539,8 +54760,8 @@ function timeToCron(value) {
54539
54760
  }
54540
54761
  function describeMemorySchedule() {
54541
54762
  try {
54542
- const statePath = path5.join(getConfigDir(), "cron", "state.json");
54543
- const raw = JSON.parse(fs5.readFileSync(statePath, "utf8"));
54763
+ const statePath = path6.join(getConfigDir(), "cron", "state.json");
54764
+ const raw = JSON.parse(fs6.readFileSync(statePath, "utf8"));
54544
54765
  const mine = (raw.jobs ?? []).find((job) => job.sessionId === "process" && (() => {
54545
54766
  try {
54546
54767
  return JSON.parse(job.prompt).managedBy === MEMORY_MANAGER;
@@ -54558,11 +54779,11 @@ function describeMemorySchedule() {
54558
54779
  async function runScheduleCommand(rest) {
54559
54780
  const [action, ...flags] = rest;
54560
54781
  const { Store, configPath } = await cronStore();
54561
- const store = new Store(path5.join(configPath(), "cron"));
54782
+ const store = new Store(path6.join(configPath(), "cron"));
54562
54783
  if (action === "on") {
54563
54784
  const unknown = findUnknownMemoryFlag(flags, ["--time"]);
54564
54785
  if (unknown) die(`unknown option "${unknown}" for 'schedule on' (run \`pie memory --help\` for usage)`);
54565
- const timeFlag = parseFlag(flags, "--time");
54786
+ const timeFlag = parseFlag2(flags, "--time");
54566
54787
  if (timeFlag.error) die(timeFlag.error);
54567
54788
  const time = timeFlag.value ?? "09:00";
54568
54789
  const cron = timeToCron(time);
@@ -54630,8 +54851,8 @@ function yesterdayKey() {
54630
54851
 
54631
54852
  // src/commands/session-resume-restart.ts
54632
54853
  import { spawn } from "node:child_process";
54633
- import * as fs6 from "node:fs";
54634
- import * as path6 from "node:path";
54854
+ import * as fs7 from "node:fs";
54855
+ import * as path7 from "node:path";
54635
54856
 
54636
54857
  // src/commands/session-resume-cwd.ts
54637
54858
  import { createRequire as createRequire2 } from "node:module";
@@ -54717,7 +54938,7 @@ function resolveResumeRestart(inputs) {
54717
54938
  if (typeof recorded !== "string" || recorded.length === 0) {
54718
54939
  return { action: "none", reason: "no-cwd-in-metadata" };
54719
54940
  }
54720
- const resolve8 = (p) => {
54941
+ const resolve9 = (p) => {
54721
54942
  const realpath = inputs.realpath ?? defaultRealpath;
54722
54943
  try {
54723
54944
  return realpath(p);
@@ -54725,8 +54946,8 @@ function resolveResumeRestart(inputs) {
54725
54946
  return p;
54726
54947
  }
54727
54948
  };
54728
- const here = resolve8(inputs.cwd);
54729
- const target = resolve8(recorded);
54949
+ const here = resolve9(inputs.cwd);
54950
+ const target = resolve9(recorded);
54730
54951
  if (here === target) {
54731
54952
  return { action: "none", reason: "same-dir" };
54732
54953
  }
@@ -54758,7 +54979,7 @@ function resolveResumeRestart(inputs) {
54758
54979
  // src/commands/session-resume-restart.ts
54759
54980
  function readResumeChdirSetting() {
54760
54981
  try {
54761
- const parsed = JSON.parse(fs6.readFileSync(getSettingsPath(), "utf8"));
54982
+ const parsed = JSON.parse(fs7.readFileSync(getSettingsPath(), "utf8"));
54762
54983
  if (!parsed || typeof parsed !== "object") return true;
54763
54984
  const session = parsed.session;
54764
54985
  if (!session || typeof session !== "object" || Array.isArray(session)) return true;
@@ -54775,19 +54996,19 @@ function readResumeChdirSetting() {
54775
54996
  var DROPPED_ENV_KEYS = /* @__PURE__ */ new Set();
54776
54997
  function anchorAgentDirForChild(env) {
54777
54998
  const value = env["PIE_CODING_AGENT_DIR"];
54778
- if (value === void 0 || value === "" || value === "~" || value.startsWith("~/") || path6.isAbsolute(value)) {
54999
+ if (value === void 0 || value === "" || value === "~" || value.startsWith("~/") || path7.isAbsolute(value)) {
54779
55000
  return env;
54780
55001
  }
54781
- return { ...env, PIE_CODING_AGENT_DIR: path6.resolve(process.cwd(), value) };
55002
+ return { ...env, PIE_CODING_AGENT_DIR: path7.resolve(process.cwd(), value) };
54782
55003
  }
54783
55004
  var LOADER_FLAGS = /* @__PURE__ */ new Set(["--import", "--require", "-r", "--experimental-loader", "--loader"]);
54784
55005
  var CALLER_FILE_FLAGS = /* @__PURE__ */ new Set(["--developer-instructions-file", "--extension-path"]);
54785
55006
  function anchorRestartOperands(argv, cwd = process.cwd(), loader = false) {
54786
55007
  const flags = loader ? LOADER_FLAGS : CALLER_FILE_FLAGS;
54787
55008
  const anchor = (value) => {
54788
- if (!value || path6.isAbsolute(value) || /^[a-zA-Z][\w+.-]*:/.test(value) || value.startsWith("\\\\")) return value;
55009
+ if (!value || path7.isAbsolute(value) || /^[a-zA-Z][\w+.-]*:/.test(value) || value.startsWith("\\\\")) return value;
54789
55010
  if (loader && !/^\.{1,2}[\\/]/.test(value)) return value;
54790
- return path6.resolve(cwd, value);
55011
+ return path7.resolve(cwd, value);
54791
55012
  };
54792
55013
  const out = [...argv];
54793
55014
  for (let i = 0; i < out.length; i++) {
@@ -54864,7 +55085,7 @@ async function performResumeRestart(decision, onSpawnFailure) {
54864
55085
  console.error(decision.banner);
54865
55086
  emitOsc7Cwd(decision.targetCwd);
54866
55087
  };
54867
- return await new Promise((resolve8) => {
55088
+ return await new Promise((resolve9) => {
54868
55089
  const child = spawn(process.execPath, [...anchorRestartOperands(process.execArgv, process.cwd(), true), process.argv[1] ?? ".", ...anchorRestartOperands(decision.childArgv)], {
54869
55090
  cwd: decision.targetCwd,
54870
55091
  stdio: "inherit",
@@ -54874,24 +55095,24 @@ async function performResumeRestart(decision, onSpawnFailure) {
54874
55095
  child.on("spawn", () => announce());
54875
55096
  child.on("error", (error) => {
54876
55097
  onSpawnFailure(`could not restart in ${decision.targetCwd} (${error.message}); continuing in ${process.cwd()}`);
54877
- resolve8(null);
55098
+ resolve9(null);
54878
55099
  });
54879
55100
  child.on("exit", (code, signal) => {
54880
55101
  if (signal) {
54881
55102
  process.kill(process.pid, signal);
54882
55103
  return;
54883
55104
  }
54884
- resolve8(code ?? 0);
55105
+ resolve9(code ?? 0);
54885
55106
  });
54886
55107
  });
54887
55108
  }
54888
55109
 
54889
55110
  // src/commands/sessions.ts
54890
- import fs8 from "node:fs";
55111
+ import fs9 from "node:fs";
54891
55112
 
54892
55113
  // src/session-control.ts
54893
- import fs7 from "fs";
54894
- import * as path7 from "node:path";
55114
+ import fs8 from "fs";
55115
+ import * as path8 from "node:path";
54895
55116
  var SessionControlError = class extends Error {
54896
55117
  constructor(code, message, recoverable = sessionControlErrorRecoverable(code)) {
54897
55118
  super(message);
@@ -54916,16 +55137,16 @@ function safeSessionDirName(sessionId) {
54916
55137
  return sessionId.replace(/[^a-zA-Z0-9_-]/g, "_");
54917
55138
  }
54918
55139
  function canonicalSessionDir(sessionsDir, sessionId) {
54919
- const dir = path7.join(sessionsDir, safeSessionDirName(sessionId));
55140
+ const dir = path8.join(sessionsDir, safeSessionDirName(sessionId));
54920
55141
  try {
54921
- if (!fs7.existsSync(dir)) return null;
54922
- return fs7.realpathSync(dir);
55142
+ if (!fs8.existsSync(dir)) return null;
55143
+ return fs8.realpathSync(dir);
54923
55144
  } catch {
54924
55145
  return null;
54925
55146
  }
54926
55147
  }
54927
55148
  function publishJournalPath(sessionsDir, safeTargetId) {
54928
- return path7.join(sessionsDir, PUBLISH_JOURNAL_DIR, `${safeTargetId}.json`);
55149
+ return path8.join(sessionsDir, PUBLISH_JOURNAL_DIR, `${safeTargetId}.json`);
54929
55150
  }
54930
55151
  var FSYNC_UNSUPPORTED_CODES = /* @__PURE__ */ new Set(["EPERM", "EINVAL", "ENOTSUP", "EOPNOTSUPP", "EACCES", "EBADF"]);
54931
55152
  var fsyncDirectoryFaultForTests = {};
@@ -54933,11 +55154,11 @@ function fsyncDirectory(dirPath) {
54933
55154
  try {
54934
55155
  const injected = fsyncDirectoryFaultForTests.fault?.(dirPath);
54935
55156
  if (injected) throw injected;
54936
- const fd = fs7.openSync(dirPath, "r");
55157
+ const fd = fs8.openSync(dirPath, "r");
54937
55158
  try {
54938
- fs7.fsyncSync(fd);
55159
+ fs8.fsyncSync(fd);
54939
55160
  } finally {
54940
- fs7.closeSync(fd);
55161
+ fs8.closeSync(fd);
54941
55162
  }
54942
55163
  } catch (error) {
54943
55164
  const code = error?.code;
@@ -54946,24 +55167,24 @@ function fsyncDirectory(dirPath) {
54946
55167
  }
54947
55168
  }
54948
55169
  function writePublishJournal(journalPath, record) {
54949
- const journalDir = path7.dirname(journalPath);
54950
- fs7.mkdirSync(journalDir, { recursive: true });
55170
+ const journalDir = path8.dirname(journalPath);
55171
+ fs8.mkdirSync(journalDir, { recursive: true });
54951
55172
  const tempPath = `${journalPath}.tmp`;
54952
- fs7.writeFileSync(tempPath, JSON.stringify(record, void 0, " "));
54953
- const tempFd = fs7.openSync(tempPath, "r+");
55173
+ fs8.writeFileSync(tempPath, JSON.stringify(record, void 0, " "));
55174
+ const tempFd = fs8.openSync(tempPath, "r+");
54954
55175
  try {
54955
- fs7.fsyncSync(tempFd);
55176
+ fs8.fsyncSync(tempFd);
54956
55177
  } finally {
54957
- fs7.closeSync(tempFd);
55178
+ fs8.closeSync(tempFd);
54958
55179
  }
54959
- fs7.renameSync(tempPath, journalPath);
55180
+ fs8.renameSync(tempPath, journalPath);
54960
55181
  fsyncDirectory(journalDir);
54961
- fsyncDirectory(path7.dirname(journalDir));
55182
+ fsyncDirectory(path8.dirname(journalDir));
54962
55183
  }
54963
55184
  function markPublishJournalFailed(journalPath) {
54964
55185
  if (!journalPath) return;
54965
55186
  try {
54966
- const record = JSON.parse(fs7.readFileSync(journalPath, "utf8"));
55187
+ const record = JSON.parse(fs8.readFileSync(journalPath, "utf8"));
54967
55188
  if (record?.v !== 1 || typeof record.failedAt === "number") return;
54968
55189
  writePublishJournal(journalPath, { ...record, failedAt: Date.now() });
54969
55190
  } catch {
@@ -54972,7 +55193,7 @@ function markPublishJournalFailed(journalPath) {
54972
55193
  function clearPublishJournal(journalPath) {
54973
55194
  if (!journalPath) return;
54974
55195
  try {
54975
- fs7.rmSync(journalPath, { force: true });
55196
+ fs8.rmSync(journalPath, { force: true });
54976
55197
  } catch {
54977
55198
  }
54978
55199
  }
@@ -55264,10 +55485,10 @@ function buildForkResult(params) {
55264
55485
  }
55265
55486
  function recoverInterruptedPublishes(params) {
55266
55487
  const outcomes = [];
55267
- const journalDir = path7.join(params.sessionsDir, PUBLISH_JOURNAL_DIR);
55488
+ const journalDir = path8.join(params.sessionsDir, PUBLISH_JOURNAL_DIR);
55268
55489
  let entries;
55269
55490
  try {
55270
- entries = fs7.readdirSync(journalDir);
55491
+ entries = fs8.readdirSync(journalDir);
55271
55492
  } catch {
55272
55493
  return outcomes;
55273
55494
  }
@@ -55275,20 +55496,20 @@ function recoverInterruptedPublishes(params) {
55275
55496
  if (!entry.endsWith(".json")) continue;
55276
55497
  outcomes.push(recoverOnePublishJournal({
55277
55498
  sessionsDir: params.sessionsDir,
55278
- journalPath: path7.join(journalDir, entry),
55499
+ journalPath: path8.join(journalDir, entry),
55279
55500
  warn: params.warn
55280
55501
  }));
55281
55502
  }
55282
55503
  return outcomes;
55283
55504
  }
55284
55505
  function recoverOnePublishJournal(params) {
55285
- const journalName = path7.basename(params.journalPath);
55506
+ const journalName = path8.basename(params.journalPath);
55286
55507
  const warn = (message) => {
55287
55508
  (params.warn ?? ((text) => console.warn(text)))(message);
55288
55509
  };
55289
55510
  let record;
55290
55511
  try {
55291
- const parsed = JSON.parse(fs7.readFileSync(params.journalPath, "utf8"));
55512
+ const parsed = JSON.parse(fs8.readFileSync(params.journalPath, "utf8"));
55292
55513
  const safeId = /^[a-zA-Z0-9_-]+$/;
55293
55514
  if (parsed?.v !== 1 || !safeId.test(parsed.targetId ?? "") || !safeId.test(parsed.stagingId ?? "") || !((parsed.backupDir ?? null) === null || safeId.test(parsed.backupDir)) || !((parsed.failedAt ?? void 0) === void 0 || typeof parsed.failedAt === "number")) {
55294
55515
  throw new Error("journal record has unexpected shape");
@@ -55301,17 +55522,17 @@ function recoverOnePublishJournal(params) {
55301
55522
  }
55302
55523
  const entryKind = (id) => {
55303
55524
  try {
55304
- return fs7.lstatSync(path7.join(params.sessionsDir, id)).isDirectory() ? "directory" : "aliased";
55525
+ return fs8.lstatSync(path8.join(params.sessionsDir, id)).isDirectory() ? "directory" : "aliased";
55305
55526
  } catch (error) {
55306
55527
  const code = error?.code;
55307
55528
  return code === "ENOENT" ? "absent" : "unknown";
55308
55529
  }
55309
55530
  };
55310
55531
  const removeSessionDir = (id) => {
55311
- fs7.rmSync(path7.join(params.sessionsDir, id), { recursive: true, force: true });
55532
+ fs8.rmSync(path8.join(params.sessionsDir, id), { recursive: true, force: true });
55312
55533
  };
55313
55534
  const removeJournal = () => {
55314
- fs7.rmSync(params.journalPath, { force: true });
55535
+ fs8.rmSync(params.journalPath, { force: true });
55315
55536
  };
55316
55537
  const targetKind = entryKind(record.targetId);
55317
55538
  const backupKind = record.backupDir ? entryKind(record.backupDir) : "absent";
@@ -55337,9 +55558,9 @@ function recoverOnePublishJournal(params) {
55337
55558
  return { action: "publish-completed", targetId: record.targetId };
55338
55559
  }
55339
55560
  if (!targetExists && backupExists && record.backupDir) {
55340
- fs7.renameSync(
55341
- path7.join(params.sessionsDir, record.backupDir),
55342
- path7.join(params.sessionsDir, record.targetId)
55561
+ fs8.renameSync(
55562
+ path8.join(params.sessionsDir, record.backupDir),
55563
+ path8.join(params.sessionsDir, record.targetId)
55343
55564
  );
55344
55565
  fsyncDirectory(params.sessionsDir);
55345
55566
  if (stagingExists) {
@@ -55704,7 +55925,7 @@ function cwdMatches(sessionCwd, requestedCwd) {
55704
55925
  }
55705
55926
  function realpathOrInput(value) {
55706
55927
  try {
55707
- return fs8.realpathSync.native(value);
55928
+ return fs9.realpathSync.native(value);
55708
55929
  } catch {
55709
55930
  return value;
55710
55931
  }
@@ -55775,9 +55996,9 @@ function isRecord2(value) {
55775
55996
  }
55776
55997
 
55777
55998
  // src/extensions/loader.ts
55778
- import * as fs9 from "node:fs";
55999
+ import * as fs10 from "node:fs";
55779
56000
  import * as os2 from "os";
55780
- import * as path8 from "path";
56001
+ import * as path9 from "path";
55781
56002
  import { pathToFileURL as pathToFileURL2 } from "node:url";
55782
56003
 
55783
56004
  // src/extensions/types.ts
@@ -55808,19 +56029,19 @@ var CommandTree = class {
55808
56029
  * register(["session", "new"], { description, handler })
55809
56030
  * register(["tools", "subagent", "spawn", "local"], { description, handler })
55810
56031
  */
55811
- register(path28, info) {
55812
- if (path28.length === 0) {
56032
+ register(path29, info) {
56033
+ if (path29.length === 0) {
55813
56034
  throw new Error("Command path cannot be empty");
55814
56035
  }
55815
56036
  let current = this.root;
55816
56037
  const fullPath = [];
55817
- for (let i = 0; i < path28.length; i++) {
55818
- const segment = path28[i];
56038
+ for (let i = 0; i < path29.length; i++) {
56039
+ const segment = path29[i];
55819
56040
  fullPath.push(segment);
55820
56041
  if (!current.children) {
55821
56042
  current.children = [];
55822
56043
  }
55823
- const isLast = i === path28.length - 1;
56044
+ const isLast = i === path29.length - 1;
55824
56045
  let node = current.children.find((n) => n.name === segment);
55825
56046
  if (!node) {
55826
56047
  const categoryDesc = DEFAULT_CATEGORY_DESCRIPTIONS[fullPath.join("/")] ?? `${segment} commands`;
@@ -55851,31 +56072,31 @@ var CommandTree = class {
55851
56072
  /**
55852
56073
  * Find a node by path
55853
56074
  */
55854
- find(path28) {
55855
- if (path28.length === 0) {
56075
+ find(path29) {
56076
+ if (path29.length === 0) {
55856
56077
  return this.root;
55857
56078
  }
55858
- const key = path28.join("/");
56079
+ const key = path29.join("/");
55859
56080
  return this.pathCache.get(key) || null;
55860
56081
  }
55861
56082
  /**
55862
56083
  * Get children of a path
55863
56084
  */
55864
- getChildren(path28) {
55865
- const node = this.find(path28);
56085
+ getChildren(path29) {
56086
+ const node = this.find(path29);
55866
56087
  return (node?.children || []).filter((child) => !child.hidden);
55867
56088
  }
55868
56089
  /**
55869
56090
  * Check if a path exists (as category or command)
55870
56091
  */
55871
- exists(path28) {
55872
- return this.find(path28) !== null;
56092
+ exists(path29) {
56093
+ return this.find(path29) !== null;
55873
56094
  }
55874
56095
  /**
55875
56096
  * Check if path is a category (has children)
55876
56097
  */
55877
- isCategory(path28) {
55878
- const node = this.find(path28);
56098
+ isCategory(path29) {
56099
+ const node = this.find(path29);
55879
56100
  return node?.isCategory || false;
55880
56101
  }
55881
56102
  /**
@@ -55968,8 +56189,8 @@ var CommandTree = class {
55968
56189
  * Supports dot notation: "tools.subagent.spawn.local"
55969
56190
  */
55970
56191
  registerFromPath(pathStr, info) {
55971
- const path28 = pathStr.split(/[./]/).filter(Boolean);
55972
- this.register(path28, info);
56192
+ const path29 = pathStr.split(/[./]/).filter(Boolean);
56193
+ this.register(path29, info);
55973
56194
  }
55974
56195
  };
55975
56196
  var commandTree = new CommandTree();
@@ -56051,13 +56272,13 @@ function createExtensionContext(extension, cwd, uiContext, abortFn, isIdleFn, ca
56051
56272
  actions?.sendUserMessage(content);
56052
56273
  },
56053
56274
  ...actions?.attachLocalFile ? {
56054
- attachLocalFile: (path28, displayName) => actions.attachLocalFile(path28, displayName)
56275
+ attachLocalFile: (path29, displayName) => actions.attachLocalFile(path29, displayName)
56055
56276
  } : {},
56056
56277
  ...actions?.beginUserInput ? {
56057
56278
  beginUserInput: (isCurrent) => actions.beginUserInput(isCurrent)
56058
56279
  } : {},
56059
56280
  ...actions?.attachLocalFileAndSubmit ? {
56060
- attachLocalFileAndSubmit: (path28, displayName, submitText) => actions.attachLocalFileAndSubmit(path28, displayName, submitText)
56281
+ attachLocalFileAndSubmit: (path29, displayName, submitText) => actions.attachLocalFileAndSubmit(path29, displayName, submitText)
56061
56282
  } : {},
56062
56283
  setPlanMode(enabled, options) {
56063
56284
  actions?.setPlanMode(enabled, options);
@@ -56179,19 +56400,19 @@ function createExtension(extensionPath, resolvedPath, identity, source) {
56179
56400
  }
56180
56401
  function expandPath(p) {
56181
56402
  if (p.startsWith("~/")) {
56182
- return path8.join(os2.homedir(), p.slice(2));
56403
+ return path9.join(os2.homedir(), p.slice(2));
56183
56404
  }
56184
56405
  if (p.startsWith("~")) {
56185
- return path8.join(os2.homedir(), p.slice(1));
56406
+ return path9.join(os2.homedir(), p.slice(1));
56186
56407
  }
56187
56408
  return p;
56188
56409
  }
56189
56410
  function resolvePath2(extPath, cwd) {
56190
56411
  const expanded = expandPath(extPath);
56191
- if (path8.isAbsolute(expanded)) {
56412
+ if (path9.isAbsolute(expanded)) {
56192
56413
  return expanded;
56193
56414
  }
56194
- return path8.resolve(cwd, expanded);
56415
+ return path9.resolve(cwd, expanded);
56195
56416
  }
56196
56417
  async function loadExtensionModule(extensionPath) {
56197
56418
  try {
@@ -56211,14 +56432,14 @@ function normalizeExtensionImportPath(extensionPath) {
56211
56432
  if (/^[a-zA-Z]:[\\/]/.test(extensionPath)) {
56212
56433
  return pathToFileURL2(extensionPath, { windows: true }).href;
56213
56434
  }
56214
- if (path8.isAbsolute(extensionPath)) {
56435
+ if (path9.isAbsolute(extensionPath)) {
56215
56436
  return pathToFileURL2(extensionPath).href;
56216
56437
  }
56217
56438
  return extensionPath;
56218
56439
  }
56219
56440
  async function loadExtension(extensionPath, cwd, uiContext, abortFn, isIdleFn, capabilities, actions, discovered, logSink) {
56220
56441
  const resolvedPath = resolvePath2(extensionPath, cwd);
56221
- if (!fs9.existsSync(resolvedPath)) {
56442
+ if (!fs10.existsSync(resolvedPath)) {
56222
56443
  return { extension: null, error: `Extension not found: ${extensionPath}` };
56223
56444
  }
56224
56445
  try {
@@ -56244,17 +56465,17 @@ async function loadExtension(extensionPath, cwd, uiContext, abortFn, isIdleFn, c
56244
56465
  }
56245
56466
  }
56246
56467
  function discoverExtensionsInDir(dir, source) {
56247
- if (!fs9.existsSync(dir)) {
56468
+ if (!fs10.existsSync(dir)) {
56248
56469
  return [];
56249
56470
  }
56250
56471
  const discovered = [];
56251
56472
  try {
56252
- const entries = fs9.readdirSync(dir, { withFileTypes: true });
56473
+ const entries = fs10.readdirSync(dir, { withFileTypes: true });
56253
56474
  for (const entry of entries) {
56254
56475
  if (entry.name.endsWith(".disabled")) {
56255
56476
  continue;
56256
56477
  }
56257
- const entryPath = path8.join(dir, entry.name);
56478
+ const entryPath = path9.join(dir, entry.name);
56258
56479
  if (entry.isFile() && (entry.name.endsWith(".cjs") || entry.name.endsWith(".js") || entry.name.endsWith(".ts"))) {
56259
56480
  discovered.push({
56260
56481
  entryPath,
@@ -56264,14 +56485,14 @@ function discoverExtensionsInDir(dir, source) {
56264
56485
  continue;
56265
56486
  }
56266
56487
  if (entry.isDirectory()) {
56267
- const packageJsonPath = path8.join(entryPath, "package.json");
56488
+ const packageJsonPath = path9.join(entryPath, "package.json");
56268
56489
  let packageIdentity;
56269
56490
  let packageDescription;
56270
56491
  let packageMainPath;
56271
56492
  let packageDefaultEnablement;
56272
- if (fs9.existsSync(packageJsonPath)) {
56493
+ if (fs10.existsSync(packageJsonPath)) {
56273
56494
  try {
56274
- const pkg = JSON.parse(fs9.readFileSync(packageJsonPath, "utf-8"));
56495
+ const pkg = JSON.parse(fs10.readFileSync(packageJsonPath, "utf-8"));
56275
56496
  const manifest = pkg.pie && typeof pkg.pie === "object" && !Array.isArray(pkg.pie) ? pkg.pie : void 0;
56276
56497
  packageIdentity = resolveExtensionIdentity({
56277
56498
  pieName: typeof manifest?.name === "string" ? manifest.name : void 0,
@@ -56281,8 +56502,8 @@ function discoverExtensionsInDir(dir, source) {
56281
56502
  packageDescription = typeof pkg.description === "string" ? pkg.description : void 0;
56282
56503
  if (manifest?.defaultEnablement === false) packageDefaultEnablement = false;
56283
56504
  if (typeof manifest?.main === "string" && manifest.main.trim().length > 0) {
56284
- const candidate = path8.resolve(entryPath, manifest.main);
56285
- if (fs9.existsSync(candidate)) {
56505
+ const candidate = path9.resolve(entryPath, manifest.main);
56506
+ if (fs10.existsSync(candidate)) {
56286
56507
  packageMainPath = candidate;
56287
56508
  }
56288
56509
  }
@@ -56299,8 +56520,8 @@ function discoverExtensionsInDir(dir, source) {
56299
56520
  });
56300
56521
  continue;
56301
56522
  }
56302
- const indexCjs = path8.join(entryPath, "index.cjs");
56303
- if (fs9.existsSync(indexCjs)) {
56523
+ const indexCjs = path9.join(entryPath, "index.cjs");
56524
+ if (fs10.existsSync(indexCjs)) {
56304
56525
  discovered.push({
56305
56526
  entryPath: indexCjs,
56306
56527
  source,
@@ -56310,8 +56531,8 @@ function discoverExtensionsInDir(dir, source) {
56310
56531
  });
56311
56532
  continue;
56312
56533
  }
56313
- const indexJs = path8.join(entryPath, "index.js");
56314
- if (fs9.existsSync(indexJs)) {
56534
+ const indexJs = path9.join(entryPath, "index.js");
56535
+ if (fs10.existsSync(indexJs)) {
56315
56536
  discovered.push({
56316
56537
  entryPath: indexJs,
56317
56538
  source,
@@ -56321,8 +56542,8 @@ function discoverExtensionsInDir(dir, source) {
56321
56542
  });
56322
56543
  continue;
56323
56544
  }
56324
- const indexTs = path8.join(entryPath, "index.ts");
56325
- if (fs9.existsSync(indexTs)) {
56545
+ const indexTs = path9.join(entryPath, "index.ts");
56546
+ if (fs10.existsSync(indexTs)) {
56326
56547
  discovered.push({
56327
56548
  entryPath: indexTs,
56328
56549
  source,
@@ -56344,21 +56565,21 @@ function collectDiscoveredExtensions(configuredPaths, cwd, options) {
56344
56565
  const errors = [];
56345
56566
  if (!options?.noExtensions) {
56346
56567
  if (!options?.noBuiltinExtensions) {
56347
- const builtinExtDir = path8.join(getBuiltinDir(), "extensions");
56568
+ const builtinExtDir = path9.join(getBuiltinDir(), "extensions");
56348
56569
  discovered.push(...discoverExtensionsInDir(builtinExtDir, "builtin"));
56349
56570
  }
56350
- const globalExtDir = path8.join(os2.homedir(), ".pie", "extensions");
56571
+ const globalExtDir = path9.join(os2.homedir(), ".pie", "extensions");
56351
56572
  discovered.push(...discoverExtensionsInDir(globalExtDir, "global"));
56352
- const localExtDir = path8.join(cwd, ".pie", "extensions");
56573
+ const localExtDir = path9.join(cwd, ".pie", "extensions");
56353
56574
  discovered.push(...discoverExtensionsInDir(localExtDir, "project"));
56354
56575
  }
56355
56576
  for (const p of configuredPaths) {
56356
56577
  const resolved = resolvePath2(p, cwd);
56357
- if (!fs9.existsSync(resolved)) {
56578
+ if (!fs10.existsSync(resolved)) {
56358
56579
  errors.push({ path: p, error: `Extension path not found: ${p}` });
56359
56580
  continue;
56360
56581
  }
56361
- if (!fs9.statSync(resolved).isDirectory()) {
56582
+ if (!fs10.statSync(resolved).isDirectory()) {
56362
56583
  errors.push({ path: p, error: `Extension path must be a directory: ${p}` });
56363
56584
  continue;
56364
56585
  }
@@ -58316,9 +58537,9 @@ var KillRing = class {
58316
58537
  };
58317
58538
 
58318
58539
  // ../../packages/tui/src/tui.ts
58319
- import * as fs10 from "node:fs";
58540
+ import * as fs11 from "node:fs";
58320
58541
  import * as os3 from "node:os";
58321
- import * as path9 from "node:path";
58542
+ import * as path10 from "node:path";
58322
58543
 
58323
58544
  // ../../packages/tui/src/terminal-image.ts
58324
58545
  var cachedCapabilities = null;
@@ -58891,7 +59112,7 @@ var TUI = class extends Container {
58891
59112
  this.reportOverflowed = true;
58892
59113
  if (process.env.PIE_CRASH_LOG_DISABLED === "1") return;
58893
59114
  try {
58894
- const crashLogPath = path9.join(os3.homedir(), ".pie", "pie-crash.log");
59115
+ const crashLogPath = path10.join(os3.homedir(), ".pie", "pie-crash.log");
58895
59116
  const crashData = [
58896
59117
  `Over-wide render at ${(/* @__PURE__ */ new Date()).toISOString()} (truncated, not fatal)`,
58897
59118
  `Terminal width: ${width}`,
@@ -58901,8 +59122,8 @@ var TUI = class extends Container {
58901
59122
  ...lines.map((candidate, index) => `[${index}] (w=${visibleWidth(candidate)}) ${candidate}`),
58902
59123
  ""
58903
59124
  ].join("\n");
58904
- fs10.mkdirSync(path9.dirname(crashLogPath), { recursive: true });
58905
- fs10.writeFileSync(crashLogPath, crashData);
59125
+ fs11.mkdirSync(path10.dirname(crashLogPath), { recursive: true });
59126
+ fs11.writeFileSync(crashLogPath, crashData);
58906
59127
  } catch {
58907
59128
  }
58908
59129
  }
@@ -59131,11 +59352,11 @@ var TUI = class extends Container {
59131
59352
  const debugRedraw = process.env.PIE_DEBUG_REDRAW === "1";
59132
59353
  const logRedraw = (reason) => {
59133
59354
  if (!debugRedraw) return;
59134
- const logPath = path9.join(os3.homedir(), ".pie", "logs", "pie-cli.log");
59135
- fs10.mkdirSync(path9.dirname(logPath), { recursive: true });
59355
+ const logPath = path10.join(os3.homedir(), ".pie", "logs", "pie-cli.log");
59356
+ fs11.mkdirSync(path10.dirname(logPath), { recursive: true });
59136
59357
  const msg = `[${(/* @__PURE__ */ new Date()).toISOString()}] [DEBUG] [ui] fullRender: ${reason} (prev=${this.previousLines.length}, new=${newLines.length}, height=${height})
59137
59358
  `;
59138
- fs10.appendFileSync(logPath, msg);
59359
+ fs11.appendFileSync(logPath, msg);
59139
59360
  };
59140
59361
  if (this.previousLines.length === 0 && !widthChanged) {
59141
59362
  logRedraw("first render");
@@ -59247,8 +59468,8 @@ var TUI = class extends Container {
59247
59468
  buffer += "\x1B[?2026l";
59248
59469
  if (process.env.PIE_TUI_DEBUG === "1") {
59249
59470
  const debugDir = "/tmp/tui";
59250
- fs10.mkdirSync(debugDir, { recursive: true });
59251
- const debugPath = path9.join(debugDir, `render-${Date.now()}-${Math.random().toString(36).slice(2)}.log`);
59471
+ fs11.mkdirSync(debugDir, { recursive: true });
59472
+ const debugPath = path10.join(debugDir, `render-${Date.now()}-${Math.random().toString(36).slice(2)}.log`);
59252
59473
  const debugData = [
59253
59474
  `firstChanged: ${firstChanged}`,
59254
59475
  `viewportTop: ${viewportTop}`,
@@ -59271,7 +59492,7 @@ var TUI = class extends Container {
59271
59492
  "=== buffer ===",
59272
59493
  JSON.stringify(buffer)
59273
59494
  ].join("\n");
59274
- fs10.writeFileSync(debugPath, debugData);
59495
+ fs11.writeFileSync(debugPath, debugData);
59275
59496
  }
59276
59497
  this.terminal.write(buffer);
59277
59498
  this.cursorRow = Math.max(0, newLines.length - 1);
@@ -63887,7 +64108,7 @@ var StdinBuffer = class extends EventEmitter {
63887
64108
  };
63888
64109
 
63889
64110
  // ../../packages/tui/src/terminal.ts
63890
- import * as fs11 from "node:fs";
64111
+ import * as fs12 from "node:fs";
63891
64112
  import { createRequire as createRequire3 } from "node:module";
63892
64113
 
63893
64114
  // ../../packages/tui/src/osc-5522.ts
@@ -64013,14 +64234,14 @@ var Osc5522Client = class {
64013
64234
  */
64014
64235
  async querySupport(timeoutMs = SUPPORT_TIMEOUT_MS) {
64015
64236
  if (this.supportMode !== "unknown") return this.supportMode === "supported";
64016
- return new Promise((resolve8) => {
64237
+ return new Promise((resolve9) => {
64017
64238
  let settled = false;
64018
64239
  const settle = (supported) => {
64019
64240
  if (settled) return;
64020
64241
  settled = true;
64021
64242
  clearTimeout(timer);
64022
64243
  this.pendingSupportResolve = void 0;
64023
- resolve8(supported);
64244
+ resolve9(supported);
64024
64245
  };
64025
64246
  const timer = setTimeout(() => settle(false), timeoutMs);
64026
64247
  this.pendingSupportResolve = settle;
@@ -64044,8 +64265,8 @@ var Osc5522Client = class {
64044
64265
  chunks: [],
64045
64266
  totalBytes: 0
64046
64267
  };
64047
- const promise = new Promise((resolve8) => {
64048
- session.resolve = resolve8;
64268
+ const promise = new Promise((resolve9) => {
64269
+ session.resolve = resolve9;
64049
64270
  });
64050
64271
  session.timer = setTimeout(() => {
64051
64272
  this.finishFor(session, { ok: false, kind: "timeout", message: "Terminal did not respond to the clipboard read in time." });
@@ -64305,7 +64526,7 @@ var ProcessTerminal = class _ProcessTerminal {
64305
64526
  const timeLeft = endTime - now;
64306
64527
  if (timeLeft <= 0) break;
64307
64528
  if (now - lastDataTime >= idleMs) break;
64308
- await new Promise((resolve8) => setTimeout(resolve8, Math.min(idleMs, timeLeft)));
64529
+ await new Promise((resolve9) => setTimeout(resolve9, Math.min(idleMs, timeLeft)));
64309
64530
  }
64310
64531
  } finally {
64311
64532
  process.stdin.removeListener("data", onData);
@@ -64339,7 +64560,7 @@ var ProcessTerminal = class _ProcessTerminal {
64339
64560
  process.stdout.write(data);
64340
64561
  if (this.writeLogPath) {
64341
64562
  try {
64342
- fs11.appendFileSync(this.writeLogPath, data, { encoding: "utf8" });
64563
+ fs12.appendFileSync(this.writeLogPath, data, { encoding: "utf8" });
64343
64564
  } catch {
64344
64565
  }
64345
64566
  }
@@ -64632,13 +64853,13 @@ var ExtensionRunner = class {
64632
64853
  getActiveTools: () => this.actions.getActiveTools(),
64633
64854
  sendUserMessage: (content) => this.actions.sendUserMessage(content),
64634
64855
  ...this.actions.attachLocalFile ? {
64635
- attachLocalFile: (path28, displayName) => this.actions.attachLocalFile(path28, displayName)
64856
+ attachLocalFile: (path29, displayName) => this.actions.attachLocalFile(path29, displayName)
64636
64857
  } : {},
64637
64858
  ...this.actions.beginUserInput ? {
64638
64859
  beginUserInput: (isCurrent) => this.actions.beginUserInput(isCurrent)
64639
64860
  } : {},
64640
64861
  ...this.actions.attachLocalFileAndSubmit ? {
64641
- attachLocalFileAndSubmit: (path28, displayName, submitText) => this.actions.attachLocalFileAndSubmit(path28, displayName, submitText)
64862
+ attachLocalFileAndSubmit: (path29, displayName, submitText) => this.actions.attachLocalFileAndSubmit(path29, displayName, submitText)
64642
64863
  } : {},
64643
64864
  setPlanMode: (enabled, options) => this.actions.setPlanMode(enabled, options),
64644
64865
  setExecutionReminder: (text) => this.actions.setExecutionReminder(text),
@@ -65078,10 +65299,10 @@ var KeybindingsManager = class _KeybindingsManager {
65078
65299
  static inMemory(config = {}) {
65079
65300
  return new _KeybindingsManager(config);
65080
65301
  }
65081
- static loadFromFile(path28) {
65082
- if (!existsSync6(path28)) return {};
65302
+ static loadFromFile(path29) {
65303
+ if (!existsSync6(path29)) return {};
65083
65304
  try {
65084
- return JSON.parse(readFileSync8(path28, "utf-8"));
65305
+ return JSON.parse(readFileSync8(path29, "utf-8"));
65085
65306
  } catch {
65086
65307
  return {};
65087
65308
  }
@@ -65130,19 +65351,19 @@ var KeybindingsManager = class _KeybindingsManager {
65130
65351
  };
65131
65352
 
65132
65353
  // src/project-knowledge.ts
65133
- import fs12 from "node:fs";
65134
- import path10 from "node:path";
65354
+ import fs13 from "node:fs";
65355
+ import path11 from "node:path";
65135
65356
  function collectAncestorAgentsFiles(cwd) {
65136
- const resolvedCwd = path10.resolve(cwd || process.cwd());
65357
+ const resolvedCwd = path11.resolve(cwd || process.cwd());
65137
65358
  const projectRoot = resolveCliProjectRoot(resolvedCwd);
65138
65359
  const candidates = [];
65139
65360
  let current = resolvedCwd;
65140
65361
  while (true) {
65141
- candidates.unshift(path10.join(current, AGENTS_CONTEXT_FILE_NAME));
65362
+ candidates.unshift(path11.join(current, AGENTS_CONTEXT_FILE_NAME));
65142
65363
  if (current === projectRoot) {
65143
65364
  break;
65144
65365
  }
65145
- const parent = path10.dirname(current);
65366
+ const parent = path11.dirname(current);
65146
65367
  if (parent === current) {
65147
65368
  break;
65148
65369
  }
@@ -65150,13 +65371,13 @@ function collectAncestorAgentsFiles(cwd) {
65150
65371
  }
65151
65372
  const files = [];
65152
65373
  for (const candidate of candidates) {
65153
- if (!fs12.existsSync(candidate)) {
65374
+ if (!fs13.existsSync(candidate)) {
65154
65375
  continue;
65155
65376
  }
65156
65377
  try {
65157
65378
  files.push({
65158
- path: path10.relative(resolvedCwd, candidate) || AGENTS_CONTEXT_FILE_NAME,
65159
- content: fs12.readFileSync(candidate, "utf-8")
65379
+ path: path11.relative(resolvedCwd, candidate) || AGENTS_CONTEXT_FILE_NAME,
65380
+ content: fs13.readFileSync(candidate, "utf-8")
65160
65381
  });
65161
65382
  } catch {
65162
65383
  }
@@ -65168,8 +65389,8 @@ function buildCliProjectContextSection(cwd) {
65168
65389
  }
65169
65390
 
65170
65391
  // src/theme/theme.ts
65171
- import * as fs13 from "node:fs";
65172
- import * as path11 from "node:path";
65392
+ import * as fs14 from "node:fs";
65393
+ import * as path12 from "node:path";
65173
65394
 
65174
65395
  // ../../node_modules/@sinclair/typebox/build/esm/compiler/compiler.mjs
65175
65396
  var TypeCheck = class {
@@ -66061,11 +66282,11 @@ var BUILTIN_THEMES;
66061
66282
  function getBuiltinThemes() {
66062
66283
  if (!BUILTIN_THEMES) {
66063
66284
  const themesDir = getThemesDir();
66064
- const darkPath = path11.join(themesDir, "dark.json");
66065
- const lightPath = path11.join(themesDir, "light.json");
66285
+ const darkPath = path12.join(themesDir, "dark.json");
66286
+ const lightPath = path12.join(themesDir, "light.json");
66066
66287
  BUILTIN_THEMES = {
66067
- dark: JSON.parse(fs13.readFileSync(darkPath, "utf-8")),
66068
- light: JSON.parse(fs13.readFileSync(lightPath, "utf-8"))
66288
+ dark: JSON.parse(fs14.readFileSync(darkPath, "utf-8")),
66289
+ light: JSON.parse(fs14.readFileSync(lightPath, "utf-8"))
66069
66290
  };
66070
66291
  }
66071
66292
  return BUILTIN_THEMES;
@@ -66073,8 +66294,8 @@ function getBuiltinThemes() {
66073
66294
  function getAvailableThemes() {
66074
66295
  const themes = new Set(Object.keys(getBuiltinThemes()));
66075
66296
  const customThemesDir = getCustomThemesDir();
66076
- if (fs13.existsSync(customThemesDir)) {
66077
- const files = fs13.readdirSync(customThemesDir);
66297
+ if (fs14.existsSync(customThemesDir)) {
66298
+ const files = fs14.readdirSync(customThemesDir);
66078
66299
  for (const file of files) {
66079
66300
  if (file.endsWith(".json")) {
66080
66301
  themes.add(file.slice(0, -5));
@@ -66135,18 +66356,18 @@ function loadThemeJson(name) {
66135
66356
  }
66136
66357
  const registeredTheme = registeredThemes.get(name);
66137
66358
  if (registeredTheme?.sourcePath) {
66138
- const content2 = fs13.readFileSync(registeredTheme.sourcePath, "utf-8");
66359
+ const content2 = fs14.readFileSync(registeredTheme.sourcePath, "utf-8");
66139
66360
  return parseThemeJsonContent(registeredTheme.sourcePath, content2);
66140
66361
  }
66141
66362
  if (registeredTheme) {
66142
66363
  throw new Error(`Theme "${name}" does not have a source path for export`);
66143
66364
  }
66144
66365
  const customThemesDir = getCustomThemesDir();
66145
- const themePath = path11.join(customThemesDir, `${name}.json`);
66146
- if (!fs13.existsSync(themePath)) {
66366
+ const themePath = path12.join(customThemesDir, `${name}.json`);
66367
+ if (!fs14.existsSync(themePath)) {
66147
66368
  throw new Error(`Theme not found: ${name}`);
66148
66369
  }
66149
- const content = fs13.readFileSync(themePath, "utf-8");
66370
+ const content = fs14.readFileSync(themePath, "utf-8");
66150
66371
  return parseThemeJsonContent(name, content);
66151
66372
  }
66152
66373
  function createTheme(themeJson, mode, sourcePath) {
@@ -66267,12 +66488,12 @@ function startThemeWatcher() {
66267
66488
  return;
66268
66489
  }
66269
66490
  const customThemesDir = getCustomThemesDir();
66270
- const themeFile = path11.join(customThemesDir, `${currentThemeName}.json`);
66271
- if (!fs13.existsSync(themeFile)) {
66491
+ const themeFile = path12.join(customThemesDir, `${currentThemeName}.json`);
66492
+ if (!fs14.existsSync(themeFile)) {
66272
66493
  return;
66273
66494
  }
66274
66495
  try {
66275
- themeWatcher = fs13.watch(themeFile, (eventType) => {
66496
+ themeWatcher = fs14.watch(themeFile, (eventType) => {
66276
66497
  if (eventType === "change") {
66277
66498
  setTimeout(() => {
66278
66499
  try {
@@ -66285,7 +66506,7 @@ function startThemeWatcher() {
66285
66506
  }, 100);
66286
66507
  } else if (eventType === "rename") {
66287
66508
  setTimeout(() => {
66288
- if (!fs13.existsSync(themeFile)) {
66509
+ if (!fs14.existsSync(themeFile)) {
66289
66510
  currentThemeName = "dark";
66290
66511
  setGlobalTheme(loadTheme("dark"));
66291
66512
  if (themeWatcher) {
@@ -66466,9 +66687,9 @@ function getSettingsListTheme() {
66466
66687
 
66467
66688
  // src/skills/loader.ts
66468
66689
  var import_yaml = __toESM(require_dist2(), 1);
66469
- import * as fs14 from "fs";
66690
+ import * as fs15 from "fs";
66470
66691
  import * as os4 from "os";
66471
- import * as path12 from "path";
66692
+ import * as path13 from "path";
66472
66693
  function parseSkillDescription(content) {
66473
66694
  content = content.replace(/^\uFEFF/, "").replace(/\r\n/g, "\n");
66474
66695
  const frontmatterMatch = content.match(/^---\n([\s\S]*?)\n---(?:\n|$)/);
@@ -66492,19 +66713,19 @@ function parseSkillDescription(content) {
66492
66713
  }
66493
66714
  var USER_CONTROLLED_SOURCES = /* @__PURE__ */ new Set(["user-agents", "user"]);
66494
66715
  function pathIsInside(child, parent) {
66495
- const relative3 = path12.relative(parent, child);
66496
- return relative3 !== "" && !relative3.startsWith(`..${path12.sep}`) && relative3 !== ".." && !path12.isAbsolute(relative3);
66716
+ const relative3 = path13.relative(parent, child);
66717
+ return relative3 !== "" && !relative3.startsWith(`..${path13.sep}`) && relative3 !== ".." && !path13.isAbsolute(relative3);
66497
66718
  }
66498
66719
  function resolveSkillSymlink(fullPath, dir, source) {
66499
66720
  let target;
66500
66721
  let stats;
66501
66722
  try {
66502
- target = fs14.realpathSync(fullPath);
66503
- stats = fs14.statSync(target);
66723
+ target = fs15.realpathSync(fullPath);
66724
+ stats = fs15.statSync(target);
66504
66725
  } catch {
66505
66726
  return { error: `broken skill symlink: ${fullPath}` };
66506
66727
  }
66507
- if (!USER_CONTROLLED_SOURCES.has(source) && !pathIsInside(target, fs14.realpathSync(dir))) {
66728
+ if (!USER_CONTROLLED_SOURCES.has(source) && !pathIsInside(target, fs15.realpathSync(dir))) {
66508
66729
  return { error: `skill symlink escapes the "${source}" layer (not loaded): ${fullPath} -> ${target}` };
66509
66730
  }
66510
66731
  return { target, isDirectory: stats.isDirectory(), isFile: stats.isFile() };
@@ -66512,13 +66733,13 @@ function resolveSkillSymlink(fullPath, dir, source) {
66512
66733
  function loadSkillsFromDir(dir, source) {
66513
66734
  const skills = [];
66514
66735
  const diagnostics = [];
66515
- if (!fs14.existsSync(dir)) {
66736
+ if (!fs15.existsSync(dir)) {
66516
66737
  return { skills, diagnostics };
66517
66738
  }
66518
- const entries = fs14.readdirSync(dir, { withFileTypes: true });
66739
+ const entries = fs15.readdirSync(dir, { withFileTypes: true });
66519
66740
  for (const entry of entries) {
66520
66741
  if (entry.name.startsWith(".")) continue;
66521
- const fullPath = path12.join(dir, entry.name);
66742
+ const fullPath = path13.join(dir, entry.name);
66522
66743
  let entryPath = fullPath;
66523
66744
  let entryIsDirectory = entry.isDirectory();
66524
66745
  let entryIsFile = entry.isFile();
@@ -66533,10 +66754,10 @@ function loadSkillsFromDir(dir, source) {
66533
66754
  entryIsFile = resolved.isFile;
66534
66755
  }
66535
66756
  if (entryIsDirectory) {
66536
- const skillMdPath = path12.join(entryPath, "SKILL.md");
66537
- if (fs14.existsSync(skillMdPath)) {
66757
+ const skillMdPath = path13.join(entryPath, "SKILL.md");
66758
+ if (fs15.existsSync(skillMdPath)) {
66538
66759
  try {
66539
- const content = fs14.readFileSync(skillMdPath, "utf-8");
66760
+ const content = fs15.readFileSync(skillMdPath, "utf-8");
66540
66761
  const description = parseSkillDescription(content);
66541
66762
  skills.push({
66542
66763
  name: entry.name,
@@ -66557,7 +66778,7 @@ function loadSkillsFromDir(dir, source) {
66557
66778
  } else if (entryIsFile && entry.name.endsWith(".md")) {
66558
66779
  const name = entry.name.slice(0, -3);
66559
66780
  try {
66560
- const content = fs14.readFileSync(entryPath, "utf-8");
66781
+ const content = fs15.readFileSync(entryPath, "utf-8");
66561
66782
  const description = parseSkillDescription(content);
66562
66783
  skills.push({
66563
66784
  name,
@@ -66565,7 +66786,7 @@ function loadSkillsFromDir(dir, source) {
66565
66786
  content,
66566
66787
  filePath: entryPath,
66567
66788
  source,
66568
- baseDir: path12.dirname(entryPath)
66789
+ baseDir: path13.dirname(entryPath)
66569
66790
  });
66570
66791
  } catch (e) {
66571
66792
  diagnostics.push({
@@ -66579,18 +66800,18 @@ function loadSkillsFromDir(dir, source) {
66579
66800
  return { skills, diagnostics };
66580
66801
  }
66581
66802
  function discoverAgentsSkillsDirs(cwd) {
66582
- const resolvedCwd = path12.resolve(cwd || process.cwd());
66803
+ const resolvedCwd = path13.resolve(cwd || process.cwd());
66583
66804
  const projectRoot = resolveCliProjectRoot(resolvedCwd);
66584
66805
  const projectAgentsDirs = [];
66585
66806
  let current = projectRoot;
66586
66807
  while (true) {
66587
- projectAgentsDirs.push(path12.join(current, ".agents", "skills"));
66808
+ projectAgentsDirs.push(path13.join(current, ".agents", "skills"));
66588
66809
  if (current === resolvedCwd) break;
66589
- const child = path12.relative(current, resolvedCwd).split(path12.sep)[0];
66810
+ const child = path13.relative(current, resolvedCwd).split(path13.sep)[0];
66590
66811
  if (!child) break;
66591
- current = path12.join(current, child);
66812
+ current = path13.join(current, child);
66592
66813
  }
66593
- return { userAgentsDir: path12.join(os4.homedir(), ".agents", "skills"), projectAgentsDirs };
66814
+ return { userAgentsDir: path13.join(os4.homedir(), ".agents", "skills"), projectAgentsDirs };
66594
66815
  }
66595
66816
  function buildSkillDirs(options) {
66596
66817
  const { userAgentsDir, projectAgentsDirs } = discoverAgentsSkillsDirs(options.cwd);
@@ -66835,8 +67056,8 @@ function createIsolatedRegexSession(pattern, ignoreCase) {
66835
67056
  let initError;
66836
67057
  let readyResolve;
66837
67058
  let readyReject;
66838
- const ready = new Promise((resolve8, reject) => {
66839
- readyResolve = resolve8;
67059
+ const ready = new Promise((resolve9, reject) => {
67060
+ readyResolve = resolve9;
66840
67061
  readyReject = reject;
66841
67062
  });
66842
67063
  void ready.catch(() => void 0);
@@ -66858,7 +67079,7 @@ function createIsolatedRegexSession(pattern, ignoreCase) {
66858
67079
  if (initError) throw initError;
66859
67080
  if (signal?.aborted) throw new Error("Operation aborted");
66860
67081
  const id = nextId++;
66861
- return new Promise((resolve8, reject) => {
67082
+ return new Promise((resolve9, reject) => {
66862
67083
  let settled = false;
66863
67084
  const finish = (error, matches) => {
66864
67085
  if (settled) return;
@@ -66868,7 +67089,7 @@ function createIsolatedRegexSession(pattern, ignoreCase) {
66868
67089
  worker.off("message", onMessage);
66869
67090
  worker.off("error", onWorkerError);
66870
67091
  if (error) reject(error);
66871
- else resolve8(matches ?? []);
67092
+ else resolve9(matches ?? []);
66872
67093
  };
66873
67094
  const terminate = (error) => {
66874
67095
  disposed = true;
@@ -66949,14 +67170,14 @@ function createCliFileSystemTools(cwd, options) {
66949
67170
  }
66950
67171
 
66951
67172
  // src/file-access-context.ts
66952
- import * as path13 from "node:path";
67173
+ import * as path14 from "node:path";
66953
67174
  function uniqueNormalizedPaths(paths) {
66954
67175
  const seen = /* @__PURE__ */ new Set();
66955
67176
  const result = [];
66956
67177
  for (const entry of paths) {
66957
67178
  const trimmed = String(entry || "").trim();
66958
67179
  if (!trimmed) continue;
66959
- const normalized = path13.normalize(trimmed);
67180
+ const normalized = path14.normalize(trimmed);
66960
67181
  if (seen.has(normalized)) continue;
66961
67182
  seen.add(normalized);
66962
67183
  result.push(normalized);
@@ -67333,29 +67554,29 @@ var ExecutionStateManager = class {
67333
67554
  };
67334
67555
 
67335
67556
  // src/session-trace.ts
67336
- import * as fs15 from "node:fs";
67337
- import * as path14 from "node:path";
67557
+ import * as fs16 from "node:fs";
67558
+ import * as path15 from "node:path";
67338
67559
  var traceTempSequence = 0;
67339
67560
  async function saveTraceFileBestEffort(tracePath, content) {
67340
67561
  const tempPath = `${tracePath}.${process.pid}.${Date.now()}.${traceTempSequence++}.tmp`;
67341
67562
  try {
67342
- await fs15.promises.writeFile(tempPath, content, "utf8");
67563
+ await fs16.promises.writeFile(tempPath, content, "utf8");
67343
67564
  try {
67344
- await fs15.promises.rename(tempPath, tracePath);
67565
+ await fs16.promises.rename(tempPath, tracePath);
67345
67566
  return;
67346
67567
  } catch {
67347
67568
  const stagedPath = `${tracePath}.${process.pid}.${Date.now()}.staged`;
67348
67569
  try {
67349
- await fs15.promises.copyFile(tempPath, stagedPath);
67350
- await fs15.promises.rename(stagedPath, tracePath);
67570
+ await fs16.promises.copyFile(tempPath, stagedPath);
67571
+ await fs16.promises.rename(stagedPath, tracePath);
67351
67572
  } catch {
67352
67573
  try {
67353
- await fs15.promises.unlink(stagedPath);
67574
+ await fs16.promises.unlink(stagedPath);
67354
67575
  } catch {
67355
67576
  }
67356
67577
  } finally {
67357
67578
  try {
67358
- await fs15.promises.unlink(tempPath);
67579
+ await fs16.promises.unlink(tempPath);
67359
67580
  } catch {
67360
67581
  }
67361
67582
  }
@@ -67368,16 +67589,16 @@ var SessionTraceWriter = class extends SessionTraceSnapshotWriter {
67368
67589
  super({
67369
67590
  getSessionId: () => sessionManager.getActiveSessionId(),
67370
67591
  loadTrace: (sessionId) => {
67371
- const tracePath = path14.join(sessionsDir, `${sessionId}.trace.json`);
67372
- if (!fs15.existsSync(tracePath)) return null;
67592
+ const tracePath = path15.join(sessionsDir, `${sessionId}.trace.json`);
67593
+ if (!fs16.existsSync(tracePath)) return null;
67373
67594
  try {
67374
- return JSON.parse(fs15.readFileSync(tracePath, "utf8"));
67595
+ return JSON.parse(fs16.readFileSync(tracePath, "utf8"));
67375
67596
  } catch {
67376
67597
  return null;
67377
67598
  }
67378
67599
  },
67379
67600
  saveTraceJson: (json, sessionId) => {
67380
- const tracePath = path14.join(sessionsDir, `${sessionId}.trace.json`);
67601
+ const tracePath = path15.join(sessionsDir, `${sessionId}.trace.json`);
67381
67602
  return saveTraceFileBestEffort(tracePath, json);
67382
67603
  },
67383
67604
  saveTrace: () => void 0
@@ -67506,10 +67727,10 @@ function applyContextSignalsWithTrace(host) {
67506
67727
  }
67507
67728
 
67508
67729
  // src/app/session-takeover.ts
67509
- import * as fs16 from "node:fs";
67730
+ import * as fs17 from "node:fs";
67510
67731
  import * as net from "node:net";
67511
67732
  import * as os5 from "node:os";
67512
- import * as path15 from "node:path";
67733
+ import * as path16 from "node:path";
67513
67734
  import * as readline from "node:readline";
67514
67735
  import { createHmac, randomUUID } from "node:crypto";
67515
67736
  function ipcDiscoveryDir() {
@@ -67517,11 +67738,11 @@ function ipcDiscoveryDir() {
67517
67738
  let root;
67518
67739
  if (raw !== void 0) {
67519
67740
  const home = os5.homedir() || process.env.HOME || process.env.USERPROFILE || "/tmp";
67520
- root = raw === "~" ? home : raw.startsWith("~/") ? path15.join(home, raw.slice(2)) : path15.resolve(raw);
67741
+ root = raw === "~" ? home : raw.startsWith("~/") ? path16.join(home, raw.slice(2)) : path16.resolve(raw);
67521
67742
  } else {
67522
67743
  root = getConfigDir();
67523
67744
  }
67524
- return path15.join(root, "run", "ipc");
67745
+ return path16.join(root, "run", "ipc");
67525
67746
  }
67526
67747
  function isPidAlive(pid) {
67527
67748
  if (!Number.isSafeInteger(pid) || pid <= 1) return false;
@@ -67536,11 +67757,11 @@ function findLivePeerForHolder(sessionId, holderPid) {
67536
67757
  if (!sessionId || !isPidAlive(holderPid)) return void 0;
67537
67758
  try {
67538
67759
  const dir = ipcDiscoveryDir();
67539
- if (!fs16.existsSync(dir)) return void 0;
67540
- for (const file of fs16.readdirSync(dir)) {
67760
+ if (!fs17.existsSync(dir)) return void 0;
67761
+ for (const file of fs17.readdirSync(dir)) {
67541
67762
  if (!file.endsWith(".json")) continue;
67542
67763
  try {
67543
- const parsed = JSON.parse(fs16.readFileSync(path15.join(dir, file), "utf8"));
67764
+ const parsed = JSON.parse(fs17.readFileSync(path16.join(dir, file), "utf8"));
67544
67765
  if (parsed.sessionId !== sessionId || parsed.pid !== holderPid) continue;
67545
67766
  if (typeof parsed.instanceId !== "string" || !parsed.instanceId || typeof parsed.port !== "number" || !Number.isInteger(parsed.port) || parsed.port <= 0 || typeof parsed.secret !== "string" || !parsed.secret) {
67546
67767
  continue;
@@ -67566,7 +67787,7 @@ function findLivePeerForHolder(sessionId, holderPid) {
67566
67787
  }
67567
67788
  function sendLoopbackPeerControl(opts) {
67568
67789
  const timeoutMs = opts.timeoutMs ?? 3e3;
67569
- return new Promise((resolve8) => {
67790
+ return new Promise((resolve9) => {
67570
67791
  const id = randomUUID();
67571
67792
  const envelope = {
67572
67793
  v: 2,
@@ -67607,7 +67828,7 @@ function sendLoopbackPeerControl(opts) {
67607
67828
  settled = true;
67608
67829
  clearTimeout(timer);
67609
67830
  socket.destroy();
67610
- resolve8(result);
67831
+ resolve9(result);
67611
67832
  };
67612
67833
  const timer = setTimeout(() => finish({ ok: false, message: `IPC control "${opts.control}" timed out` }), timeoutMs);
67613
67834
  const socket = net.createConnection(opts.peer.port, "127.0.0.1", () => {
@@ -67697,7 +67918,7 @@ async function takeoverIdleHeadlessWorker(opts) {
67697
67918
  if (owner && owner.pid !== opts.peer.pid) {
67698
67919
  return { ok: false, reason: `session was claimed by another host (pid ${owner.pid}, ${owner.holder})` };
67699
67920
  }
67700
- await new Promise((resolve8) => setTimeout(resolve8, 100));
67921
+ await new Promise((resolve9) => setTimeout(resolve9, 100));
67701
67922
  }
67702
67923
  return { ok: false, reason: `worker "${opts.peer.displayName}" (pid ${opts.peer.pid}) did not exit within ${Math.round(timeoutMs / 1e3)}s` };
67703
67924
  }
@@ -67716,13 +67937,13 @@ function formatNonTakeoverableHolderError(inspection) {
67716
67937
  async function promptCliTakeoverConfirm(sessionId, workerName, pid) {
67717
67938
  if (!process.stdin.isTTY) return false;
67718
67939
  const rl = readline.createInterface({ input: process.stdin, output: process.stderr });
67719
- return new Promise((resolve8) => {
67940
+ return new Promise((resolve9) => {
67720
67941
  rl.question(
67721
67942
  `Session "${sessionId}" is held by idle headless worker "${workerName}" (pid ${pid}). Take over and stop the worker? [y/N] `,
67722
67943
  (answer) => {
67723
67944
  rl.close();
67724
67945
  const normalized = answer.trim().toLowerCase();
67725
- resolve8(normalized === "y" || normalized === "yes");
67946
+ resolve9(normalized === "y" || normalized === "yes");
67726
67947
  }
67727
67948
  );
67728
67949
  });
@@ -67746,7 +67967,7 @@ async function attemptStartupIdleTakeover(opts) {
67746
67967
  import * as os8 from "os";
67747
67968
 
67748
67969
  // src/components/session-selector.ts
67749
- import * as path16 from "node:path";
67970
+ import * as path17 from "node:path";
67750
67971
  function formatDate(timestamp) {
67751
67972
  const date = new Date(timestamp);
67752
67973
  const now = /* @__PURE__ */ new Date();
@@ -67777,7 +67998,7 @@ function getPathFlavor(value, peer) {
67777
67998
  return "posix";
67778
67999
  }
67779
68000
  function getPathApi(flavor) {
67780
- return flavor === "windows" ? path16.win32 : path16.posix;
68001
+ return flavor === "windows" ? path17.win32 : path17.posix;
67781
68002
  }
67782
68003
  function normalizeForComparison(value, flavor) {
67783
68004
  const pathApi = getPathApi(flavor);
@@ -68070,10 +68291,10 @@ function parseProjectContextSection(section) {
68070
68291
  const parts = section.split(/^### (.+)$/m);
68071
68292
  const files = [];
68072
68293
  for (let i = 1; i + 1 < parts.length + 1; i += 2) {
68073
- const path28 = (parts[i] ?? "").trim();
68294
+ const path29 = (parts[i] ?? "").trim();
68074
68295
  const content = (parts[i + 1] ?? "").trim();
68075
- if (!path28 || !content) continue;
68076
- files.push({ path: path28, content });
68296
+ if (!path29 || !content) continue;
68297
+ files.push({ path: path29, content });
68077
68298
  }
68078
68299
  return files;
68079
68300
  }
@@ -69612,7 +69833,7 @@ function renderExecutionWidgetLines(steps, activeTheme = theme) {
69612
69833
 
69613
69834
  // src/utils/progress-text.ts
69614
69835
  import * as os6 from "node:os";
69615
- import * as path17 from "node:path";
69836
+ import * as path18 from "node:path";
69616
69837
  function isCuratedProgressDetails(details) {
69617
69838
  return typeof details === "object" && details !== null && "increment" in details;
69618
69839
  }
@@ -69634,8 +69855,8 @@ function compactCalmPath(raw) {
69634
69855
  const trimmed = raw.trim();
69635
69856
  if (!trimmed) return "";
69636
69857
  const cwd = process.cwd();
69637
- if (cwd && (trimmed === cwd || trimmed.startsWith(`${cwd}${path17.sep}`))) {
69638
- const rel = path17.relative(cwd, trimmed);
69858
+ if (cwd && (trimmed === cwd || trimmed.startsWith(`${cwd}${path18.sep}`))) {
69859
+ const rel = path18.relative(cwd, trimmed);
69639
69860
  return rel || ".";
69640
69861
  }
69641
69862
  const home = os6.homedir();
@@ -69719,13 +69940,13 @@ function formatSize2(bytes) {
69719
69940
  }
69720
69941
  var DEFAULT_MAX_BYTES = 102400;
69721
69942
  var DEFAULT_MAX_LINES = 100;
69722
- function shortenPath(path28) {
69723
- if (typeof path28 !== "string") return "";
69943
+ function shortenPath(path29) {
69944
+ if (typeof path29 !== "string") return "";
69724
69945
  const home = os7.homedir();
69725
- if (path28.startsWith(home)) {
69726
- return `~${path28.slice(home.length)}`;
69946
+ if (path29.startsWith(home)) {
69947
+ return `~${path29.slice(home.length)}`;
69727
69948
  }
69728
- return path28;
69949
+ return path29;
69729
69950
  }
69730
69951
  function replaceTabs(text) {
69731
69952
  return text.replace(/\t/g, " ");
@@ -69861,14 +70082,14 @@ ${renderManageTodoListResult(this.result, { expanded: this.expanded }, theme)}`;
69861
70082
  }
69862
70083
  } else if (this.toolName === "read_file") {
69863
70084
  const rawPath = str(this.args?.file_path ?? this.args?.path);
69864
- const path28 = rawPath !== null ? shortenPath(rawPath) : null;
70085
+ const path29 = rawPath !== null ? shortenPath(rawPath) : null;
69865
70086
  const offset = typeof this.args?.offset === "number" ? this.args.offset : void 0;
69866
70087
  const limit = typeof this.args?.limit === "number" ? this.args.limit : void 0;
69867
70088
  let pathDisplay;
69868
- if (path28 === null) {
70089
+ if (path29 === null) {
69869
70090
  pathDisplay = invalidArg;
69870
- } else if (path28) {
69871
- pathDisplay = theme.fg("accent", path28);
70091
+ } else if (path29) {
70092
+ pathDisplay = theme.fg("accent", path29);
69872
70093
  } else {
69873
70094
  const partialPath = partialStr(this.args?.file_path ?? this.args?.path);
69874
70095
  pathDisplay = theme.fg("toolOutput", partialPath);
@@ -69915,12 +70136,12 @@ ${renderManageTodoListResult(this.result, { expanded: this.expanded }, theme)}`;
69915
70136
  } else if (this.toolName === "write_file") {
69916
70137
  const rawPath = str(this.args?.file_path ?? this.args?.path);
69917
70138
  const fileContent = str(this.args?.content);
69918
- const path28 = rawPath !== null ? shortenPath(rawPath) : null;
70139
+ const path29 = rawPath !== null ? shortenPath(rawPath) : null;
69919
70140
  let pathDisplay;
69920
- if (path28 === null) {
70141
+ if (path29 === null) {
69921
70142
  pathDisplay = invalidArg;
69922
- } else if (path28) {
69923
- pathDisplay = theme.fg("accent", path28);
70143
+ } else if (path29) {
70144
+ pathDisplay = theme.fg("accent", path29);
69924
70145
  } else {
69925
70146
  const partialPath = partialStr(this.args?.file_path ?? this.args?.path);
69926
70147
  pathDisplay = theme.fg("toolOutput", partialPath);
@@ -69957,12 +70178,12 @@ ${theme.fg("error", errorText)}`;
69957
70178
  }
69958
70179
  } else if (this.toolName === "edit_file") {
69959
70180
  const rawPath = str(this.args?.file_path ?? this.args?.path);
69960
- const path28 = rawPath !== null ? shortenPath(rawPath) : null;
70181
+ const path29 = rawPath !== null ? shortenPath(rawPath) : null;
69961
70182
  let pathDisplay;
69962
- if (path28 === null) {
70183
+ if (path29 === null) {
69963
70184
  pathDisplay = invalidArg;
69964
- } else if (path28) {
69965
- pathDisplay = theme.fg("accent", path28);
70185
+ } else if (path29) {
70186
+ pathDisplay = theme.fg("accent", path29);
69966
70187
  } else {
69967
70188
  const partialPath = partialStr(this.args?.file_path ?? this.args?.path);
69968
70189
  pathDisplay = theme.fg("toolOutput", partialPath);
@@ -69987,7 +70208,7 @@ ${theme.fg("error", errorText)}`;
69987
70208
  const diff = this.result.details.diff;
69988
70209
  const firstChangedLine = this.result.details.firstChangedLine;
69989
70210
  if (firstChangedLine) {
69990
- text = `${theme.fg("toolTitle", theme.bold("edit_file"))} ${theme.fg("accent", path28 || rawPath)}${theme.fg("warning", `:${firstChangedLine}`)}`;
70211
+ text = `${theme.fg("toolTitle", theme.bold("edit_file"))} ${theme.fg("accent", path29 || rawPath)}${theme.fg("warning", `:${firstChangedLine}`)}`;
69991
70212
  }
69992
70213
  const lines = diff.split("\n");
69993
70214
  const maxLines = this.expanded ? lines.length : 15;
@@ -70007,7 +70228,7 @@ ${theme.fg("error", errorText)}`;
70007
70228
  const diff = generateEditDiff(oldText, newText, rawPath);
70008
70229
  const firstChangedLine = findFirstChangedLine(oldText, newText);
70009
70230
  if (firstChangedLine) {
70010
- text = `${theme.fg("toolTitle", theme.bold("edit_file"))} ${theme.fg("accent", path28 || rawPath)}${theme.fg("warning", `:${firstChangedLine}`)}`;
70231
+ text = `${theme.fg("toolTitle", theme.bold("edit_file"))} ${theme.fg("accent", path29 || rawPath)}${theme.fg("warning", `:${firstChangedLine}`)}`;
70011
70232
  }
70012
70233
  const lines = diff.split("\n");
70013
70234
  const maxLines = this.expanded ? lines.length : 15;
@@ -70026,9 +70247,9 @@ ${theme.fg("error", errorText)}`;
70026
70247
  }
70027
70248
  } else if (this.toolName === "list_dir") {
70028
70249
  const rawPath = str(this.args?.path);
70029
- const path28 = rawPath !== null ? shortenPath(rawPath || ".") : null;
70250
+ const path29 = rawPath !== null ? shortenPath(rawPath || ".") : null;
70030
70251
  const limit = this.args?.limit;
70031
- text = `${theme.fg("toolTitle", theme.bold("list_dir"))} ${path28 === null ? invalidArg : theme.fg("accent", path28)}`;
70252
+ text = `${theme.fg("toolTitle", theme.bold("list_dir"))} ${path29 === null ? invalidArg : theme.fg("accent", path29)}`;
70032
70253
  if (limit !== void 0) {
70033
70254
  text += theme.fg("toolOutput", ` (limit ${limit})`);
70034
70255
  }
@@ -70064,9 +70285,9 @@ ${theme.fg("warning", `[Truncated: ${warnings.join(", ")}]`)}`;
70064
70285
  } else if (this.toolName === "find_files") {
70065
70286
  const pattern = str(this.args?.pattern);
70066
70287
  const rawPath = str(this.args?.path);
70067
- const path28 = rawPath !== null ? shortenPath(rawPath || ".") : null;
70288
+ const path29 = rawPath !== null ? shortenPath(rawPath || ".") : null;
70068
70289
  const limit = this.args?.limit;
70069
- text = theme.fg("toolTitle", theme.bold("find_files")) + " " + (pattern === null ? invalidArg : theme.fg("accent", pattern || "")) + theme.fg("toolOutput", ` in ${path28 === null ? invalidArg : path28}`);
70290
+ text = theme.fg("toolTitle", theme.bold("find_files")) + " " + (pattern === null ? invalidArg : theme.fg("accent", pattern || "")) + theme.fg("toolOutput", ` in ${path29 === null ? invalidArg : path29}`);
70070
70291
  if (limit !== void 0) {
70071
70292
  text += theme.fg("toolOutput", ` (limit ${limit})`);
70072
70293
  }
@@ -70102,10 +70323,10 @@ ${theme.fg("warning", `[Truncated: ${warnings.join(", ")}]`)}`;
70102
70323
  } else if (this.toolName === "grep_text") {
70103
70324
  const pattern = str(this.args?.pattern);
70104
70325
  const rawPath = str(this.args?.path);
70105
- const path28 = rawPath !== null ? shortenPath(rawPath || ".") : null;
70326
+ const path29 = rawPath !== null ? shortenPath(rawPath || ".") : null;
70106
70327
  const glob = str(this.args?.glob);
70107
70328
  const limit = this.args?.limit;
70108
- text = theme.fg("toolTitle", theme.bold("grep_text")) + " " + (pattern === null ? invalidArg : theme.fg("accent", `/${pattern || ""}/`)) + theme.fg("toolOutput", ` in ${path28 === null ? invalidArg : path28}`);
70329
+ text = theme.fg("toolTitle", theme.bold("grep_text")) + " " + (pattern === null ? invalidArg : theme.fg("accent", `/${pattern || ""}/`)) + theme.fg("toolOutput", ` in ${path29 === null ? invalidArg : path29}`);
70109
70330
  if (glob) {
70110
70331
  text += theme.fg("toolOutput", ` (${glob})`);
70111
70332
  }
@@ -70533,13 +70754,13 @@ async function handleResumeCommand(host) {
70533
70754
  });
70534
70755
  }
70535
70756
  function promptTakeoverConfirmation(host, workerName, pid) {
70536
- return new Promise((resolve8) => {
70757
+ return new Promise((resolve9) => {
70537
70758
  let settled = false;
70538
70759
  const finish = (accepted, done) => {
70539
70760
  if (settled) return;
70540
70761
  settled = true;
70541
70762
  done();
70542
- resolve8(accepted);
70763
+ resolve9(accepted);
70543
70764
  };
70544
70765
  host.showSelector((done) => {
70545
70766
  const container = new Container();
@@ -70899,8 +71120,8 @@ async function forkAtEntry(host, entryId) {
70899
71120
  host.showError("Failed to branch at entry");
70900
71121
  return;
70901
71122
  }
70902
- const path28 = host.sessionManager.getPathSummaries(entryId);
70903
- const pathNames = path28.map((summary) => summary.role || summary.type).join(" \u2192 ");
71123
+ const path29 = host.sessionManager.getPathSummaries(entryId);
71124
+ const pathNames = path29.map((summary) => summary.role || summary.type).join(" \u2192 ");
70904
71125
  const messages = host.sessionManager.getMessages();
70905
71126
  host.syncAgentFromActiveSession(messages);
70906
71127
  await host.syncSessionScopedState(messages);
@@ -70914,7 +71135,7 @@ async function forkAtEntry(host, entryId) {
70914
71135
  host.updatePendingMessagesDisplay();
70915
71136
  host.renderMessageHistory(messages);
70916
71137
  await host.sessionManager.save();
70917
- host.showStatus(`Branched at: ${pathNames} (${path28.length} messages). Continue to add to this branch.`);
71138
+ host.showStatus(`Branched at: ${pathNames} (${path29.length} messages). Continue to add to this branch.`);
70918
71139
  } catch (error) {
70919
71140
  host.showError(
70920
71141
  `Failed to branch: ${error instanceof Error ? error.message : String(error)}`
@@ -70943,10 +71164,10 @@ async function navigateToEntry(host, entryId) {
70943
71164
  host.sessionManager.save().catch((err) => {
70944
71165
  console.error("[Session] Save after navigation failed:", err);
70945
71166
  });
70946
- const path28 = host.sessionManager.getPathSummaries(entryId);
71167
+ const path29 = host.sessionManager.getPathSummaries(entryId);
70947
71168
  const summary = host.sessionManager.getEntrySummary(entryId);
70948
71169
  const role = summary?.role || summary?.type || "entry";
70949
- host.showStatus(`Switched to branch: ${role} (${path28.length} entries in path)`);
71170
+ host.showStatus(`Switched to branch: ${role} (${path29.length} entries in path)`);
70950
71171
  } catch (error) {
70951
71172
  host.showError(
70952
71173
  `Failed to navigate: ${error instanceof Error ? error.message : String(error)}`
@@ -71315,7 +71536,7 @@ var SettingsSelectorComponent = class extends Container {
71315
71536
  };
71316
71537
 
71317
71538
  // src/components/extension-selector.ts
71318
- import * as path18 from "node:path";
71539
+ import * as path19 from "node:path";
71319
71540
  var ExtensionSelectorComponent = class extends Container {
71320
71541
  selectList;
71321
71542
  shortcuts;
@@ -71371,8 +71592,8 @@ function selectRuntimeExtensionWinners(infos) {
71371
71592
  return reversed.reverse();
71372
71593
  }
71373
71594
  function unidentifiedLabel(info) {
71374
- const parentName = path18.basename(path18.dirname(info.entryPath));
71375
- const fileName = path18.basename(info.entryPath);
71595
+ const parentName = path19.basename(path19.dirname(info.entryPath));
71596
+ const fileName = path19.basename(info.entryPath);
71376
71597
  return `(unidentified) ${parentName || fileName}`;
71377
71598
  }
71378
71599
  var ExtensionEnablementSelectorComponent = class extends Container {
@@ -71620,10 +71841,10 @@ var shutdowns = /* @__PURE__ */ new WeakMap();
71620
71841
  function shutdownInteractiveHost(host, idleTimeoutMs = 5e3) {
71621
71842
  const existing = shutdowns.get(host);
71622
71843
  if (existing) return existing;
71623
- let resolve8;
71844
+ let resolve9;
71624
71845
  let reject;
71625
71846
  const shutdown = new Promise((done, fail) => {
71626
- resolve8 = done;
71847
+ resolve9 = done;
71627
71848
  reject = fail;
71628
71849
  });
71629
71850
  shutdowns.set(host, shutdown);
@@ -71674,7 +71895,7 @@ function shutdownInteractiveHost(host, idleTimeoutMs = 5e3) {
71674
71895
  errors.push(error);
71675
71896
  }
71676
71897
  if (errors.length) throw new AggregateError(errors, "Interactive shutdown failed.");
71677
- })().then(resolve8, reject);
71898
+ })().then(resolve9, reject);
71678
71899
  return shutdown;
71679
71900
  }
71680
71901
 
@@ -72459,7 +72680,7 @@ async function handleCacheTest(host) {
72459
72680
  host.chatContainer.addChild(new Text(theme.fg("dim", ` ${summarizeUsage(result1.usage)}`), 1, 0));
72460
72681
  host.chatContainer.addChild(new Text(theme.fg("dim", " Waiting 2s before replaying identical request..."), 1, 0));
72461
72682
  host.ui.requestRender();
72462
- await new Promise((resolve8) => setTimeout(resolve8, 2e3));
72683
+ await new Promise((resolve9) => setTimeout(resolve9, 2e3));
72463
72684
  host.chatContainer.addChild(new Text(theme.fg("accent", "Request 2/2: replaying identical request..."), 1, 0));
72464
72685
  host.ui.requestRender();
72465
72686
  result2 = await completeSimple(model, context, options);
@@ -72520,9 +72741,9 @@ async function handleCacheTest(host) {
72520
72741
  }
72521
72742
 
72522
72743
  // src/commands/interactive-skill-commands.ts
72523
- import * as fs17 from "fs";
72744
+ import * as fs18 from "fs";
72524
72745
  import * as os9 from "os";
72525
- import * as path19 from "path";
72746
+ import * as path20 from "path";
72526
72747
 
72527
72748
  // src/commands/subagent-command.ts
72528
72749
  async function handleSubagentCommand(host, args) {
@@ -72659,9 +72880,9 @@ function handleSkillsCommand(host) {
72659
72880
  });
72660
72881
  }
72661
72882
  function discoverSkills(host) {
72662
- const builtinDir = path19.join(getBuiltinDir(), "skills");
72663
- const userDir = path19.join(os9.homedir(), ".pie", "skills");
72664
- const projectDir = path19.join(process.cwd(), ".pie", "skills");
72883
+ const builtinDir = path20.join(getBuiltinDir(), "skills");
72884
+ const userDir = path20.join(os9.homedir(), ".pie", "skills");
72885
+ const projectDir = path20.join(process.cwd(), ".pie", "skills");
72665
72886
  return loadSkills({ dirs: buildSkillDirs({ builtinDir, userDir, projectDir, cwd: process.cwd() }) });
72666
72887
  }
72667
72888
  function listDiscoveredSkills(host) {
@@ -72793,7 +73014,7 @@ function expandSkillCommand(host, text) {
72793
73014
  const skill = host.skills.find((s) => s.name === skillName);
72794
73015
  if (!skill) return text;
72795
73016
  try {
72796
- const content = fs17.readFileSync(skill.filePath, "utf-8");
73017
+ const content = fs18.readFileSync(skill.filePath, "utf-8");
72797
73018
  const body = host.stripFrontmatter(content).trim();
72798
73019
  const skillBlock = `<skill name="${skill.name}" location="${skill.filePath}">
72799
73020
  References are relative to ${skill.baseDir}.
@@ -72820,9 +73041,9 @@ async function handleSkillToggleCommand(host, args, enabled) {
72820
73041
  host.showError(`Usage: /skills/${enabled ? "enable" : "disable"} <name>`);
72821
73042
  return;
72822
73043
  }
72823
- const builtinDir = path19.join(getBuiltinDir(), "skills");
72824
- const userDir = path19.join(os9.homedir(), ".pie", "skills");
72825
- const projectDir = path19.join(process.cwd(), ".pie", "skills");
73044
+ const builtinDir = path20.join(getBuiltinDir(), "skills");
73045
+ const userDir = path20.join(os9.homedir(), ".pie", "skills");
73046
+ const projectDir = path20.join(process.cwd(), ".pie", "skills");
72826
73047
  const discovered = loadSkills({ dirs: buildSkillDirs({ builtinDir, userDir, projectDir, cwd: process.cwd() }) }).skills;
72827
73048
  if (!discovered.some((skill) => skill.name === name)) {
72828
73049
  host.showError(`Skill not found: ${name}`);
@@ -72888,17 +73109,17 @@ async function handleSkillsCreate(host, args) {
72888
73109
  if (!description) {
72889
73110
  description = `Skill for ${name}`;
72890
73111
  }
72891
- const skillsDir = path19.join(os9.homedir(), ".pie", "skills");
72892
- const skillDir = path19.join(skillsDir, name);
72893
- const skillFile = path19.join(skillDir, "SKILL.md");
73112
+ const skillsDir = path20.join(os9.homedir(), ".pie", "skills");
73113
+ const skillDir = path20.join(skillsDir, name);
73114
+ const skillFile = path20.join(skillDir, "SKILL.md");
72894
73115
  debugLog2(`Creating at: ${skillFile}`);
72895
- if (fs17.existsSync(skillDir)) {
73116
+ if (fs18.existsSync(skillDir)) {
72896
73117
  host.showError(`Skill "${name}" already exists at ${skillDir}`);
72897
73118
  return;
72898
73119
  }
72899
- fs17.mkdirSync(skillDir, { recursive: true });
73120
+ fs18.mkdirSync(skillDir, { recursive: true });
72900
73121
  const template = createSkillTemplate(name, description);
72901
- fs17.writeFileSync(skillFile, template, "utf-8");
73122
+ fs18.writeFileSync(skillFile, template, "utf-8");
72902
73123
  debugLog2("Successfully created skill");
72903
73124
  host.chatContainer.addChild(new Spacer(1));
72904
73125
  host.chatContainer.addChild(new Text(theme.fg("accent", `\u2713 Created skill: ${name}`), 1, 0));
@@ -74732,14 +74953,14 @@ var BUILTIN_COMMAND_CATALOG = [
74732
74953
  { path: ["debugs", "boot"], description: "Boot composition pipeline: how the runtime was assembled", headless: "requires-ui" },
74733
74954
  { path: ["settings", "quit"], description: "Exit Pie", headless: "requires-ui" }
74734
74955
  ];
74735
- function findBuiltinCommand(path28) {
74736
- return BUILTIN_COMMAND_CATALOG.find((entry) => entry.path.join("/") === path28);
74737
- }
74738
- function headlessRefusalFor(path28) {
74739
- const entry = findBuiltinCommand(path28);
74740
- if (!entry) return `unknown command: ${path28}`;
74741
- if (entry.headless === "category") return `"${path28}" is a command category; pick a sub-command`;
74742
- if (entry.headless === "requires-ui") return `"${path28}" needs an interactive terminal; not available on a background worker`;
74956
+ function findBuiltinCommand(path29) {
74957
+ return BUILTIN_COMMAND_CATALOG.find((entry) => entry.path.join("/") === path29);
74958
+ }
74959
+ function headlessRefusalFor(path29) {
74960
+ const entry = findBuiltinCommand(path29);
74961
+ if (!entry) return `unknown command: ${path29}`;
74962
+ if (entry.headless === "category") return `"${path29}" is a command category; pick a sub-command`;
74963
+ if (entry.headless === "requires-ui") return `"${path29}" needs an interactive terminal; not available on a background worker`;
74743
74964
  return void 0;
74744
74965
  }
74745
74966
  function registerHeadlessBuiltinCommands(tree, executors) {
@@ -75855,7 +76076,7 @@ function setupInteractiveEditorSubmitHandler(host) {
75855
76076
  host.chatContainer.addChild(userMsg);
75856
76077
  clearAcceptedDraft(host.editor, submittedRevision);
75857
76078
  host.ui.requestRender();
75858
- await new Promise((resolve8) => setImmediate(resolve8));
76079
+ await new Promise((resolve9) => setImmediate(resolve9));
75859
76080
  let finalContent = messageContent;
75860
76081
  const reminderPrefix = host.executionState.getReminder() ?? host.executionReminder;
75861
76082
  const combinedPrefix = [reminderPrefix].filter((value) => Boolean(value)).join("");
@@ -75900,8 +76121,8 @@ function setupInteractiveEditorSubmitHandler(host) {
75900
76121
  }
75901
76122
 
75902
76123
  // src/input/interactive-file-pipeline.ts
75903
- import * as fs20 from "fs";
75904
- import * as path22 from "path";
76124
+ import * as fs21 from "fs";
76125
+ import * as path23 from "path";
75905
76126
 
75906
76127
  // src/components/file-picker.ts
75907
76128
  var FilePickerComponent = class extends Container {
@@ -76122,8 +76343,8 @@ var FilePickerComponent = class extends Container {
76122
76343
  };
76123
76344
 
76124
76345
  // src/files/commands/file-commands.ts
76125
- import * as fs18 from "node:fs";
76126
- import * as path20 from "node:path";
76346
+ import * as fs19 from "node:fs";
76347
+ import * as path21 from "node:path";
76127
76348
  var FileCommands = class {
76128
76349
  context;
76129
76350
  constructor(context) {
@@ -76139,11 +76360,11 @@ var FileCommands = class {
76139
76360
  return;
76140
76361
  }
76141
76362
  const filePath = resolvePath(parsed.path);
76142
- if (!fs18.existsSync(filePath)) {
76363
+ if (!fs19.existsSync(filePath)) {
76143
76364
  this.context.showError(`File not found: ${parsed.path}`);
76144
76365
  return;
76145
76366
  }
76146
- this.context.showStatus(`Uploading ${path20.basename(filePath)}...`);
76367
+ this.context.showStatus(`Uploading ${path21.basename(filePath)}...`);
76147
76368
  try {
76148
76369
  const result = await this.context.fileManager.upload(filePath, {
76149
76370
  purpose: parsed.purpose,
@@ -76178,7 +76399,7 @@ var FileCommands = class {
76178
76399
  return;
76179
76400
  }
76180
76401
  const resolvedPath = resolvePath(filePath);
76181
- if (!fs18.existsSync(resolvedPath)) {
76402
+ if (!fs19.existsSync(resolvedPath)) {
76182
76403
  this.context.showError(`File not found: ${filePath}`);
76183
76404
  return;
76184
76405
  }
@@ -76209,7 +76430,7 @@ var FileCommands = class {
76209
76430
  return;
76210
76431
  }
76211
76432
  const resolvedPath = resolvePath(parsed.path);
76212
- if (!fs18.existsSync(resolvedPath)) {
76433
+ if (!fs19.existsSync(resolvedPath)) {
76213
76434
  this.context.showError(`File not found: ${parsed.path}`);
76214
76435
  return;
76215
76436
  }
@@ -76687,9 +76908,9 @@ var FileStatusMonitor = class {
76687
76908
  };
76688
76909
 
76689
76910
  // src/files/mention/mention-handler.ts
76690
- import * as fs19 from "node:fs";
76911
+ import * as fs20 from "node:fs";
76691
76912
  import { randomUUID as randomUUID2 } from "node:crypto";
76692
- import * as path21 from "node:path";
76913
+ import * as path22 from "node:path";
76693
76914
  var MentionHandler = class {
76694
76915
  fileManager;
76695
76916
  onShowPicker;
@@ -76744,7 +76965,7 @@ var MentionHandler = class {
76744
76965
  navigateBrowseParent() {
76745
76966
  const currentDir = this.getBrowserDirectory();
76746
76967
  if (!currentDir) return;
76747
- const parentDir = path21.dirname(currentDir);
76968
+ const parentDir = path22.dirname(currentDir);
76748
76969
  if (parentDir === currentDir) return;
76749
76970
  this.browsingDirectory = parentDir;
76750
76971
  this.showMentionPicker("");
@@ -76764,7 +76985,7 @@ var MentionHandler = class {
76764
76985
  if (option.type === "parent") {
76765
76986
  const currentDir = this.getBrowserDirectory();
76766
76987
  if (currentDir) {
76767
- this.browsingDirectory = path21.dirname(currentDir);
76988
+ this.browsingDirectory = path22.dirname(currentDir);
76768
76989
  this.showMentionPicker("");
76769
76990
  this.isPickerVisible = true;
76770
76991
  }
@@ -76802,14 +77023,14 @@ var MentionHandler = class {
76802
77023
  * picker-selected file, so submit-time queueing and attachment resolution
76803
77024
  * behave identically.
76804
77025
  */
76805
- async attachLocalFile(path28, displayName, pendingMention, isCurrent) {
76806
- return this.attachFileFromPath(path28, { sourceName: displayName, queryToken: pendingMention, isCurrent });
77026
+ async attachLocalFile(path29, displayName, pendingMention, isCurrent) {
77027
+ return this.attachFileFromPath(path29, { sourceName: displayName, queryToken: pendingMention, isCurrent });
76807
77028
  }
76808
77029
  /** Prepare a message-owned mention without reading or mutating the editor.
76809
77030
  * Errors propagate to the caller; no caption-only submission on failure. */
76810
77031
  async prepareLocalFile(filePath, displayName, isCurrent = () => true) {
76811
77032
  if (!isCurrent()) return void 0;
76812
- const sourceName = displayName ?? path21.basename(filePath);
77033
+ const sourceName = displayName ?? path22.basename(filePath);
76813
77034
  const result = await this.prepareFile(filePath, sourceName);
76814
77035
  if (!isCurrent() || !result.success) return void 0;
76815
77036
  return this.formatMention(result.name, result.fileId);
@@ -76839,12 +77060,12 @@ var MentionHandler = class {
76839
77060
  * mention, stage or upload the file, then replace the pending mention with
76840
77061
  * the final one (or remove it on failure).
76841
77062
  */
76842
- async attachFileFromPath(path28, options) {
76843
- const sourceName = options.sourceName ?? path28.split(/[\\/]/).pop() ?? path28;
77063
+ async attachFileFromPath(path29, options) {
77064
+ const sourceName = options.sourceName ?? path29.split(/[\\/]/).pop() ?? path29;
76844
77065
  this.pendingUploadCount += 1;
76845
77066
  const pendingMention = options.queryToken?.includes("pending:clipboard-") ? options.queryToken : this.formatPendingMention(sourceName);
76846
77067
  this.onInsertMention(pendingMention, options.queryToken);
76847
- const pendingStatusKey = `${path28}:${Date.now()}:${Math.random().toString(36).slice(2, 8)}`;
77068
+ const pendingStatusKey = `${path29}:${Date.now()}:${Math.random().toString(36).slice(2, 8)}`;
76848
77069
  try {
76849
77070
  if (options.cacheStatus === "uploaded") {
76850
77071
  this.pushPendingStatus(
@@ -76859,7 +77080,7 @@ var MentionHandler = class {
76859
77080
  } else {
76860
77081
  this.pushPendingStatus(pendingStatusKey, `Preparing ${sourceName}...`);
76861
77082
  }
76862
- const mimeType = FileCache.getMimeType(path28);
77083
+ const mimeType = FileCache.getMimeType(path29);
76863
77084
  const isMedia = mimeType.startsWith("image/") || mimeType.startsWith("video/");
76864
77085
  const shouldStageLocally = !isMedia || !this.fileManager.hasAdapter();
76865
77086
  if (isMedia && shouldStageLocally) {
@@ -76872,7 +77093,7 @@ var MentionHandler = class {
76872
77093
  this.formatUploadProgress(sourceName, progress, stage)
76873
77094
  );
76874
77095
  };
76875
- const result = await this.prepareFile(path28, sourceName, onProgress);
77096
+ const result = await this.prepareFile(path29, sourceName, onProgress);
76876
77097
  if (options.isCurrent && !options.isCurrent()) return false;
76877
77098
  if (result.success) {
76878
77099
  const mention = this.formatMention(result.name, result.fileId);
@@ -76954,7 +77175,7 @@ var MentionHandler = class {
76954
77175
  id: part.content,
76955
77176
  name: part.name || fileInfo.name,
76956
77177
  mimeType: fileInfo.mimeType,
76957
- ext: path21.extname(part.name || fileInfo.name).toLowerCase(),
77178
+ ext: path22.extname(part.name || fileInfo.name).toLowerCase(),
76958
77179
  size: fileInfo.size,
76959
77180
  source: fileInfo.platforms.length > 0 ? "session" : "local",
76960
77181
  fileId: part.content,
@@ -77112,11 +77333,11 @@ var MentionHandler = class {
77112
77333
  }
77113
77334
  if (this.isPath(query)) {
77114
77335
  const resolvedPath = resolvePath(query);
77115
- if (fs19.existsSync(resolvedPath)) {
77116
- const stats = fs19.statSync(resolvedPath);
77336
+ if (fs20.existsSync(resolvedPath)) {
77337
+ const stats = fs20.statSync(resolvedPath);
77117
77338
  if (stats.isFile()) {
77118
77339
  const type = FileCache.getFileTypeFromName(resolvedPath);
77119
- const name = path21.basename(resolvedPath);
77340
+ const name = path22.basename(resolvedPath);
77120
77341
  if (!seenNames.has(name.toLowerCase())) {
77121
77342
  options.push({
77122
77343
  type: "upload",
@@ -77137,16 +77358,16 @@ var MentionHandler = class {
77137
77358
  return void 0;
77138
77359
  }
77139
77360
  const queryPath = this.isPath(query) ? resolvePath(query) : void 0;
77140
- const filter = queryPath ? fs19.existsSync(queryPath) && fs19.statSync(queryPath).isDirectory() ? "" : path21.basename(queryPath) : query;
77361
+ const filter = queryPath ? fs20.existsSync(queryPath) && fs20.statSync(queryPath).isDirectory() ? "" : path22.basename(queryPath) : query;
77141
77362
  const entries = this.fileManager.listPathEntries(currentDir, filter);
77142
77363
  const options = [];
77143
77364
  const homeDir = process.env.HOME || "";
77144
77365
  const displayDir = currentDir.startsWith(homeDir) ? `~${currentDir.slice(homeDir.length)}` : currentDir;
77145
- if (path21.dirname(currentDir) !== currentDir) {
77366
+ if (path22.dirname(currentDir) !== currentDir) {
77146
77367
  options.push({
77147
77368
  type: "parent",
77148
77369
  name: "..",
77149
- path: path21.dirname(currentDir),
77370
+ path: path22.dirname(currentDir),
77150
77371
  icon: "\u21A9",
77151
77372
  meta: "Parent directory"
77152
77373
  });
@@ -77178,10 +77399,10 @@ var MentionHandler = class {
77178
77399
  getBrowserDirectory(query = this.currentQuery) {
77179
77400
  if (this.isPath(query)) {
77180
77401
  const resolvedPath = resolvePath(query);
77181
- if (fs19.existsSync(resolvedPath) && fs19.statSync(resolvedPath).isDirectory()) {
77402
+ if (fs20.existsSync(resolvedPath) && fs20.statSync(resolvedPath).isDirectory()) {
77182
77403
  return resolvedPath;
77183
77404
  }
77184
- return path21.dirname(resolvedPath);
77405
+ return path22.dirname(resolvedPath);
77185
77406
  }
77186
77407
  return this.browsingDirectory;
77187
77408
  }
@@ -77268,8 +77489,8 @@ async function initializeFileManager(host) {
77268
77489
  sessionId,
77269
77490
  platform: platform2,
77270
77491
  apiKey: host.options.apiKey,
77271
- baseDir: path22.join(host.options.configDir, "files"),
77272
- sessionsDir: path22.join(host.options.configDir, "sessions")
77492
+ baseDir: path23.join(host.options.configDir, "files"),
77493
+ sessionsDir: path23.join(host.options.configDir, "sessions")
77273
77494
  });
77274
77495
  switch (getFileManagerAdapterKind(platform2)) {
77275
77496
  case "kimi":
@@ -77549,13 +77770,13 @@ function convertPreparedAttachmentItems(items) {
77549
77770
  break;
77550
77771
  case "image": {
77551
77772
  if (!item.data && !item.path) return void 0;
77552
- const data = item.data ?? fs20.readFileSync(item.path, "base64");
77773
+ const data = item.data ?? fs21.readFileSync(item.path, "base64");
77553
77774
  converted.push({ type: "image", data, mimeType: item.mimeType });
77554
77775
  break;
77555
77776
  }
77556
77777
  case "video": {
77557
77778
  if (!item.data && !item.path) return void 0;
77558
- const data = item.data ?? fs20.readFileSync(item.path, "base64");
77779
+ const data = item.data ?? fs21.readFileSync(item.path, "base64");
77559
77780
  converted.push({ type: "video", data, mimeType: item.mimeType });
77560
77781
  break;
77561
77782
  }
@@ -77703,7 +77924,7 @@ function isSpawnFailure(outcome) {
77703
77924
  return !outcome.ok;
77704
77925
  }
77705
77926
  function defaultSpawnFn(file, args, spawnImpl = spawn3, maxBytes = MAX_IMAGE_BYTES, timeoutMs = COMMAND_TIMEOUT_MS) {
77706
- return new Promise((resolve8) => {
77927
+ return new Promise((resolve9) => {
77707
77928
  let child;
77708
77929
  try {
77709
77930
  child = spawnImpl(file, args, {
@@ -77711,7 +77932,7 @@ function defaultSpawnFn(file, args, spawnImpl = spawn3, maxBytes = MAX_IMAGE_BYT
77711
77932
  windowsHide: true
77712
77933
  });
77713
77934
  } catch (err) {
77714
- resolve8({ ok: false, error: "spawn-failed", message: err instanceof Error ? err.message : String(err) });
77935
+ resolve9({ ok: false, error: "spawn-failed", message: err instanceof Error ? err.message : String(err) });
77715
77936
  return;
77716
77937
  }
77717
77938
  let settled = false;
@@ -77725,13 +77946,13 @@ function defaultSpawnFn(file, args, spawnImpl = spawn3, maxBytes = MAX_IMAGE_BYT
77725
77946
  child.kill("SIGKILL");
77726
77947
  } catch {
77727
77948
  }
77728
- resolve8({ ok: false, error: "timeout" });
77949
+ resolve9({ ok: false, error: "timeout" });
77729
77950
  }, timeoutMs);
77730
77951
  child.on("error", (err) => {
77731
77952
  if (settled) return;
77732
77953
  settled = true;
77733
77954
  clearTimeout(timer);
77734
- resolve8({ ok: false, error: err.code === "ENOENT" ? "not-found" : "spawn-failed", message: err.message });
77955
+ resolve9({ ok: false, error: err.code === "ENOENT" ? "not-found" : "spawn-failed", message: err.message });
77735
77956
  });
77736
77957
  child.stdout?.on("data", (chunk) => {
77737
77958
  if (settled) return;
@@ -77739,7 +77960,7 @@ function defaultSpawnFn(file, args, spawnImpl = spawn3, maxBytes = MAX_IMAGE_BYT
77739
77960
  settled = true;
77740
77961
  clearTimeout(timer);
77741
77962
  stdoutChunks.length = 0;
77742
- resolve8({ ok: false, error: "too-large" });
77963
+ resolve9({ ok: false, error: "too-large" });
77743
77964
  try {
77744
77965
  child.kill("SIGKILL");
77745
77966
  } catch {
@@ -77756,7 +77977,7 @@ function defaultSpawnFn(file, args, spawnImpl = spawn3, maxBytes = MAX_IMAGE_BYT
77756
77977
  if (settled) return;
77757
77978
  settled = true;
77758
77979
  clearTimeout(timer);
77759
- resolve8({ ok: true, result: { code: code ?? -1, stdout: Buffer.concat(stdoutChunks, stdoutBytes), stderr: stderrText } });
77980
+ resolve9({ ok: true, result: { code: code ?? -1, stdout: Buffer.concat(stdoutChunks, stdoutBytes), stderr: stderrText } });
77760
77981
  });
77761
77982
  });
77762
77983
  }
@@ -77772,23 +77993,23 @@ var TempImageResources = class {
77772
77993
  this.directory = mkdtempSync(join14(tmpdir(), "pie-clipboard-"));
77773
77994
  if (process.platform !== "win32") chmodSync(this.directory, 448);
77774
77995
  }
77775
- const path28 = this.injectedPath ? this.injectedPath(ext) : join14(this.directory, `image${ext}`);
77776
- const fd = openSync2(path28, "wx", 384);
77777
- this.files.add(path28);
77996
+ const path29 = this.injectedPath ? this.injectedPath(ext) : join14(this.directory, `image${ext}`);
77997
+ const fd = openSync2(path29, "wx", 384);
77998
+ this.files.add(path29);
77778
77999
  try {
77779
78000
  if (process.platform !== "win32") fchmodSync(fd, 384);
77780
78001
  } finally {
77781
78002
  closeSync2(fd);
77782
78003
  }
77783
- return path28;
78004
+ return path29;
77784
78005
  };
77785
78006
  cleanup = () => {
77786
- for (const path28 of this.files) {
78007
+ for (const path29 of this.files) {
77787
78008
  try {
77788
- unlinkSync2(path28);
77789
- this.files.delete(path28);
78009
+ unlinkSync2(path29);
78010
+ this.files.delete(path29);
77790
78011
  } catch (err) {
77791
- if (err.code === "ENOENT") this.files.delete(path28);
78012
+ if (err.code === "ENOENT") this.files.delete(path29);
77792
78013
  }
77793
78014
  }
77794
78015
  if (this.directory) {
@@ -78013,20 +78234,20 @@ function writeImageBytes(bytes, declaredMime, mkTempPath) {
78013
78234
  mimeType
78014
78235
  };
78015
78236
  }
78016
- function finalizeTempImage(path28, mimeType) {
78237
+ function finalizeTempImage(path29, mimeType) {
78017
78238
  let bytes;
78018
78239
  try {
78019
- if (!existsSync14(path28)) {
78240
+ if (!existsSync14(path29)) {
78020
78241
  return { ok: false, kind: "no-image", message: "Clipboard does not contain an image." };
78021
78242
  }
78022
- const size = statSync5(path28).size;
78243
+ const size = statSync5(path29).size;
78023
78244
  if (size === 0) {
78024
78245
  return { ok: false, kind: "no-image", message: "Clipboard does not contain an image." };
78025
78246
  }
78026
78247
  if (size > MAX_IMAGE_BYTES) {
78027
78248
  return { ok: false, kind: "too-large", message: `Clipboard image is too large (${formatBytes2(size)}).` };
78028
78249
  }
78029
- bytes = readFileSync15(path28);
78250
+ bytes = readFileSync15(path29);
78030
78251
  } catch (err) {
78031
78252
  return { ok: false, kind: "failed", message: `Failed to read clipboard image: ${errorMessage4(err)}` };
78032
78253
  }
@@ -78034,7 +78255,7 @@ function finalizeTempImage(path28, mimeType) {
78034
78255
  if (!detected) {
78035
78256
  return { ok: false, kind: "no-image", message: "Clipboard does not contain a supported image (PNG/JPEG)." };
78036
78257
  }
78037
- return { ok: true, path: path28, mimeType: detected };
78258
+ return { ok: true, path: path29, mimeType: detected };
78038
78259
  }
78039
78260
  function detectMimeFromMagic(bytes) {
78040
78261
  if (bytes.length >= 8 && bytes[0] === 137 && bytes[1] === 80 && bytes[2] === 78 && bytes[3] === 71) {
@@ -78102,11 +78323,11 @@ function terminalResultToClipboardResult(result) {
78102
78323
  let dir;
78103
78324
  try {
78104
78325
  dir = mkdtempSync2(join15(tmpdir2(), "pie-osc5522-"));
78105
- const path28 = join15(dir, formatPastedImageName(/* @__PURE__ */ new Date(), ext));
78106
- writeFileSync8(path28, result.bytes);
78326
+ const path29 = join15(dir, formatPastedImageName(/* @__PURE__ */ new Date(), ext));
78327
+ writeFileSync8(path29, result.bytes);
78107
78328
  return {
78108
78329
  ok: true,
78109
- path: path28,
78330
+ path: path29,
78110
78331
  mimeType: result.mimeType,
78111
78332
  cleanup: () => {
78112
78333
  try {
@@ -79539,11 +79760,11 @@ var HierarchicalSelectorComponent = class extends Container {
79539
79760
  // src/runtime/interactive-ui-helpers.ts
79540
79761
  function showHierarchicalMenu(host, initialPath = []) {
79541
79762
  const basePath = [...initialPath];
79542
- const showAtPath = (path28) => {
79763
+ const showAtPath = (path29) => {
79543
79764
  host.showSelector((done) => {
79544
79765
  const selector = new HierarchicalSelectorComponent({
79545
79766
  tree: commandTree,
79546
- path: path28,
79767
+ path: path29,
79547
79768
  basePath,
79548
79769
  onNavigate: (newPath) => {
79549
79770
  done();
@@ -79731,7 +79952,7 @@ async function recoverHardStalledTurn(host, stalledMs) {
79731
79952
  try {
79732
79953
  await Promise.race([
79733
79954
  host.agentSessionController?.waitForIdle() ?? Promise.resolve(),
79734
- new Promise((resolve8) => setTimeout(resolve8, 2e3))
79955
+ new Promise((resolve9) => setTimeout(resolve9, 2e3))
79735
79956
  ]);
79736
79957
  } catch (error) {
79737
79958
  host.logDebug("continuation_timeout:hard_stall_wait_failed", {
@@ -80540,7 +80761,7 @@ async function handleDirectBash(host, command, options = {}) {
80540
80761
  child.stderr.on("data", (data) => {
80541
80762
  output.append(data.toString());
80542
80763
  });
80543
- return new Promise((resolve8) => {
80764
+ return new Promise((resolve9) => {
80544
80765
  let settled = false;
80545
80766
  const finish = (code) => {
80546
80767
  if (settled) return;
@@ -80553,7 +80774,7 @@ async function handleDirectBash(host, command, options = {}) {
80553
80774
  }
80554
80775
  host.chatContainer.addChild(new Spacer(1));
80555
80776
  host.ui.requestRender();
80556
- resolve8();
80777
+ resolve9();
80557
80778
  };
80558
80779
  child.on("error", (error) => {
80559
80780
  output.append(error.message);
@@ -80610,14 +80831,14 @@ function installInteractiveInteractionHandler(host) {
80610
80831
  if (!("timeoutMs" in request) || !request.timeoutMs || request.timeoutMs <= 0) {
80611
80832
  return { value: await createPromise(controller.signal), timedOut: false };
80612
80833
  }
80613
- return await new Promise((resolve8, reject) => {
80834
+ return await new Promise((resolve9, reject) => {
80614
80835
  const timer = setTimeout(() => {
80615
80836
  controller.abort();
80616
- resolve8({ timedOut: true });
80837
+ resolve9({ timedOut: true });
80617
80838
  }, request.timeoutMs);
80618
80839
  createPromise(controller.signal).then((value) => {
80619
80840
  clearTimeout(timer);
80620
- resolve8({ value, timedOut: false });
80841
+ resolve9({ value, timedOut: false });
80621
80842
  }).catch((error) => {
80622
80843
  clearTimeout(timer);
80623
80844
  reject(error);
@@ -80765,12 +80986,12 @@ function showExtensionNotification(host, message, type = "info", opts) {
80765
80986
  host.ui.requestRender();
80766
80987
  }
80767
80988
  function showExtensionSelector2(host, title, options, opts) {
80768
- return new Promise((resolve8) => {
80989
+ return new Promise((resolve9) => {
80769
80990
  const promptLine = title.split("\n")[0].trim() || title.trim();
80770
80991
  host.showStatus(`Waiting for selection: ${promptLine}`);
80771
80992
  if (opts?.signal?.aborted) {
80772
80993
  host.clearStatusLine?.();
80773
- resolve8(void 0);
80994
+ resolve9(void 0);
80774
80995
  return;
80775
80996
  }
80776
80997
  const settle = (option) => {
@@ -80780,12 +81001,12 @@ function showExtensionSelector2(host, title, options, opts) {
80780
81001
  host.showStatus(`${promptLine} \u2192 ${option}`);
80781
81002
  }
80782
81003
  host.restoreEditor();
80783
- resolve8(option);
81004
+ resolve9(option);
80784
81005
  };
80785
81006
  const onAbort = () => {
80786
81007
  host.clearStatusLine?.();
80787
81008
  host.restoreEditor();
80788
- resolve8(void 0);
81009
+ resolve9(void 0);
80789
81010
  };
80790
81011
  opts?.signal?.addEventListener("abort", onAbort, { once: true });
80791
81012
  const selector = new ExtensionSelectorComponent(
@@ -80820,17 +81041,17 @@ ${message}`, options, opts);
80820
81041
  return { confirmed: result === "Yes" };
80821
81042
  }
80822
81043
  function showExtensionInput(host, title, placeholder, opts) {
80823
- return new Promise((resolve8) => {
81044
+ return new Promise((resolve9) => {
80824
81045
  host.showStatus(`Waiting for input: ${title}`);
80825
81046
  if (opts?.signal?.aborted) {
80826
81047
  host.clearStatusLine?.();
80827
- resolve8(void 0);
81048
+ resolve9(void 0);
80828
81049
  return;
80829
81050
  }
80830
81051
  const settle = (value) => {
80831
81052
  host.clearStatusLine?.();
80832
81053
  host.restoreEditor();
80833
- resolve8(value);
81054
+ resolve9(value);
80834
81055
  };
80835
81056
  const onAbort = () => settle(void 0);
80836
81057
  opts?.signal?.addEventListener("abort", onAbort, { once: true });
@@ -80854,12 +81075,12 @@ function showExtensionInput(host, title, placeholder, opts) {
80854
81075
  });
80855
81076
  }
80856
81077
  function showExtensionEditor(host, title, prefill, opts) {
80857
- return new Promise((resolve8) => {
81078
+ return new Promise((resolve9) => {
80858
81079
  host.showStatus(`Waiting for input: ${title}`);
80859
81080
  const settle = (value) => {
80860
81081
  host.clearStatusLine?.();
80861
81082
  host.restoreEditor();
80862
- resolve8(value);
81083
+ resolve9(value);
80863
81084
  };
80864
81085
  const onAbort = () => settle(void 0);
80865
81086
  opts?.signal?.addEventListener("abort", onAbort, { once: true });
@@ -80906,14 +81127,14 @@ function showExtensionEditor(host, title, prefill, opts) {
80906
81127
  }
80907
81128
  function showExtensionCustom(host, factory, options) {
80908
81129
  const savedText = host.editor.getText();
80909
- return new Promise((resolve8, reject) => {
81130
+ return new Promise((resolve9, reject) => {
80910
81131
  let closed = false;
80911
81132
  const close = (result) => {
80912
81133
  if (closed) return;
80913
81134
  closed = true;
80914
81135
  host.restoreEditor();
80915
81136
  host.editor.setText(savedText);
80916
- resolve8(result);
81137
+ resolve9(result);
80917
81138
  };
80918
81139
  Promise.resolve(factory(host.ui, theme, close)).then((component) => {
80919
81140
  if (closed) return;
@@ -80948,7 +81169,8 @@ async function loginExtensionProvider(options) {
80948
81169
  }
80949
81170
  async function runExtensionProviderLogin(options) {
80950
81171
  const { provider, modelRegistry, authStorage, requestInteraction: requestInteraction2 } = options;
80951
- const oauth = modelRegistry.getExtensionOAuth(provider);
81172
+ const binding = typeof modelRegistry.getExtensionOAuthBinding === "function" ? modelRegistry.getExtensionOAuthBinding(provider) : void 0;
81173
+ const oauth = binding?.oauth ?? modelRegistry.getExtensionOAuth(provider);
80952
81174
  if (!oauth) return false;
80953
81175
  const credentials = await oauth.login({
80954
81176
  onAuth: ({ url }) => {
@@ -80972,8 +81194,14 @@ ${url}`,
80972
81194
  return response.value;
80973
81195
  }
80974
81196
  });
80975
- authStorage.setOAuthCredentials(provider, credentials);
80976
- authStorage.setRuntimeApiKey(provider, credentials.access);
81197
+ if (binding && typeof modelRegistry.commitExtensionOAuthCredentials === "function") {
81198
+ if (!modelRegistry.commitExtensionOAuthCredentials(provider, binding, credentials)) {
81199
+ return false;
81200
+ }
81201
+ } else {
81202
+ authStorage.setOAuthCredentials(provider, credentials);
81203
+ authStorage.setRuntimeApiKey(provider, credentials.access);
81204
+ }
80977
81205
  const errors = authStorage.drainErrors();
80978
81206
  if (errors.length > 0) {
80979
81207
  throw new Error(`Failed to persist ${oauth.name} credentials: ${errors[0].message}`);
@@ -81241,17 +81469,17 @@ async function loadInteractiveExtensions(host) {
81241
81469
  void host.editor.onSubmit(content);
81242
81470
  }
81243
81471
  },
81244
- attachLocalFile: async (path28, displayName) => {
81472
+ attachLocalFile: async (path29, displayName) => {
81245
81473
  const handler = host.attachmentMentionHandler?.();
81246
81474
  if (!handler) return false;
81247
- return handler.attachLocalFile(path28, displayName);
81475
+ return handler.attachLocalFile(path29, displayName);
81248
81476
  },
81249
81477
  beginUserInput: (isCurrent) => beginUserInput(host, isCurrent),
81250
- attachLocalFileAndSubmit: async (path28, displayName, submitText) => {
81478
+ attachLocalFileAndSubmit: async (path29, displayName, submitText) => {
81251
81479
  const scope = beginUserInput(host);
81252
81480
  if (!scope) return false;
81253
81481
  try {
81254
- return await scope.submit(submitText, [{ path: path28, displayName }]);
81482
+ return await scope.submit(submitText, [{ path: path29, displayName }]);
81255
81483
  } finally {
81256
81484
  scope.dispose();
81257
81485
  }
@@ -81521,8 +81749,8 @@ async function loadInteractiveExtensions(host) {
81521
81749
  host.extensionRunner.setUIContext(host.extensionUIContext);
81522
81750
  await restoreExtensionProviderCredentials(host.options.modelRegistry);
81523
81751
  if (process.env.PIE_VERBOSE) {
81524
- for (const { path: path28, error } of errors) {
81525
- console.error(`[Extension] Failed to load ${path28}: ${error}`);
81752
+ for (const { path: path29, error } of errors) {
81753
+ console.error(`[Extension] Failed to load ${path29}: ${error}`);
81526
81754
  }
81527
81755
  }
81528
81756
  const policyContext = () => ({
@@ -81578,7 +81806,7 @@ async function loadInteractiveExtensions(host) {
81578
81806
  // src/extensions/interactive-runtime-reload.ts
81579
81807
  import { AsyncLocalStorage } from "async_hooks";
81580
81808
  import * as os10 from "os";
81581
- import * as path23 from "path";
81809
+ import * as path24 from "path";
81582
81810
  var runtimeReloadContext = new AsyncLocalStorage();
81583
81811
  var activeReloadTokens = /* @__PURE__ */ new WeakMap();
81584
81812
  async function reloadInteractiveRuntime(host) {
@@ -81613,9 +81841,9 @@ async function reloadInteractiveRuntime(host) {
81613
81841
  }
81614
81842
  }
81615
81843
  async function reloadInteractiveRuntimeWhileLocked(host) {
81616
- const builtinDir = path23.join(getBuiltinDir(), "skills");
81617
- const userDir = path23.join(os10.homedir(), ".pie", "skills");
81618
- const projectDir = path23.join(host.options.cwd, ".pie", "skills");
81844
+ const builtinDir = path24.join(getBuiltinDir(), "skills");
81845
+ const userDir = path24.join(os10.homedir(), ".pie", "skills");
81846
+ const projectDir = path24.join(host.options.cwd, ".pie", "skills");
81619
81847
  const { skills, diagnostics } = loadSkills({
81620
81848
  dirs: buildSkillDirs({ builtinDir, userDir, projectDir, cwd: host.options.cwd })
81621
81849
  });
@@ -82396,7 +82624,7 @@ var InteractiveMode = class {
82396
82624
  /** Live mention handler for extension-driven attachments (duck-typed onto
82397
82625
  * InteractiveExtensionLoaderHost); undefined while attachments init. */
82398
82626
  async describeImageFile(filePath, displayName) {
82399
- const { describeImageViaUnderstandingChain } = await import("./chunks/host-image-fallback-3TEMOQM5.js");
82627
+ const { describeImageViaUnderstandingChain } = await import("./chunks/host-image-fallback-NXY36VO2.js");
82400
82628
  return describeImageViaUnderstandingChain({ modelRegistry: this.options.modelRegistry, getAgentModel: () => this.agent?.state.model, filePath, displayName });
82401
82629
  }
82402
82630
  activeModelInputs() {
@@ -82466,17 +82694,17 @@ var InteractiveMode = class {
82466
82694
  };
82467
82695
 
82468
82696
  // src/app/runtime-composition.ts
82469
- import { existsSync as existsSync15, mkdirSync as mkdirSync7 } from "fs";
82697
+ import { existsSync as existsSync15, mkdirSync as mkdirSync8 } from "fs";
82470
82698
 
82471
82699
  // src/app/manager-service-bootstrap.ts
82472
- import * as fs21 from "fs";
82473
- import * as path24 from "path";
82700
+ import * as fs22 from "fs";
82701
+ import * as path25 from "path";
82474
82702
  function applyManagerServiceBootstrapEnv() {
82475
82703
  if (process.env.PIE_PROC_CURATED_NAME !== "manager") return;
82476
82704
  if (process.env.PIE_MANAGER_BOOTSTRAP) return;
82477
82705
  try {
82478
- const workspaceConfigPath = path24.join(process.cwd(), "config.json");
82479
- const parsed = JSON.parse(fs21.readFileSync(workspaceConfigPath, "utf8"));
82706
+ const workspaceConfigPath = path25.join(process.cwd(), "config.json");
82707
+ const parsed = JSON.parse(fs22.readFileSync(workspaceConfigPath, "utf8"));
82480
82708
  const provider = typeof parsed.provider === "string" ? parsed.provider.trim() : "";
82481
82709
  const modelId = typeof parsed.modelId === "string" ? parsed.modelId.trim() : "";
82482
82710
  if (provider && modelId) {
@@ -82490,7 +82718,7 @@ function applyManagerServiceBootstrapEnv() {
82490
82718
 
82491
82719
  // src/app/runtime-composition.ts
82492
82720
  import { randomUUID as randomUUID3 } from "crypto";
82493
- import * as path25 from "path";
82721
+ import * as path26 from "path";
82494
82722
 
82495
82723
  // src/app/initial-session.ts
82496
82724
  var CliSessionResumeError = class extends Error {
@@ -82543,13 +82771,13 @@ var CliMissingApiKeyError = class extends Error {
82543
82771
  function getCliRuntimePaths() {
82544
82772
  const configDir = getConfigDir();
82545
82773
  const sessionsDir = getSessionsDir();
82546
- const skillsDir = path25.join(configDir, "skills");
82547
- const builtinSkillsDir = path25.join(getBuiltinDir(), "skills");
82774
+ const skillsDir = path26.join(configDir, "skills");
82775
+ const builtinSkillsDir = path26.join(getBuiltinDir(), "skills");
82548
82776
  return { configDir, sessionsDir, skillsDir, builtinSkillsDir };
82549
82777
  }
82550
82778
  function ensureCliRuntimePaths(paths = getCliRuntimePaths()) {
82551
82779
  if (!existsSync15(paths.skillsDir)) {
82552
- mkdirSync7(paths.skillsDir, { recursive: true });
82780
+ mkdirSync8(paths.skillsDir, { recursive: true });
82553
82781
  }
82554
82782
  return paths;
82555
82783
  }
@@ -82666,7 +82894,7 @@ async function composeCliRuntime(params) {
82666
82894
  fileLogger.log("cli", `Using API key for provider ${provider}`, {
82667
82895
  keyPrefix: apiKey ? maskApiKey2(apiKey) : "none"
82668
82896
  });
82669
- const projectSkillsDir = path25.join(cwd, ".pie", "skills");
82897
+ const projectSkillsDir = path26.join(cwd, ".pie", "skills");
82670
82898
  const { skills: discoveredSkills, diagnostics } = loadSkills({
82671
82899
  dirs: buildSkillDirs({
82672
82900
  builtinDir: paths.builtinSkillsDir,
@@ -83254,7 +83482,7 @@ async function runPrintMode(params) {
83254
83482
  import readline2 from "node:readline";
83255
83483
 
83256
83484
  // src/app/json-events-output.ts
83257
- import * as fs22 from "node:fs";
83485
+ import * as fs23 from "node:fs";
83258
83486
 
83259
83487
  // src/app/jsonl-writer.ts
83260
83488
  function createJsonlWriter(io) {
@@ -83423,7 +83651,7 @@ process.stdout.on("error", (error) => {
83423
83651
  });
83424
83652
  var writeJsonl = createJsonlWriter({
83425
83653
  isTTY: () => !!process.stdout.isTTY,
83426
- writeSync: (buffer, offset) => fs22.writeSync(1, buffer, offset, buffer.length - offset),
83654
+ writeSync: (buffer, offset) => fs23.writeSync(1, buffer, offset, buffer.length - offset),
83427
83655
  writeAsync: (buffer) => process.stdout.write(buffer)
83428
83656
  });
83429
83657
  function writeEvent(event) {
@@ -84331,7 +84559,7 @@ async function loadJsonModeExtensions(params) {
84331
84559
  if (errors.length) {
84332
84560
  await runner.dispose("shutdown");
84333
84561
  throw new Error(
84334
- errors.map(({ path: path28, error }) => `${path28}: ${error}`).join("\n")
84562
+ errors.map(({ path: path29, error }) => `${path29}: ${error}`).join("\n")
84335
84563
  );
84336
84564
  }
84337
84565
  registerHeadlessBuiltinCommands(commandTree, {
@@ -84381,7 +84609,7 @@ async function loadJsonModeExtensions(params) {
84381
84609
  }
84382
84610
  async function describeImageViaUnderstanding(params, filePath, displayName) {
84383
84611
  try {
84384
- const { understandReadFile: understandReadFile2 } = await import("./chunks/read-file-understanding-N2ZZQLTZ.js");
84612
+ const { understandReadFile: understandReadFile2 } = await import("./chunks/read-file-understanding-ZCBNCQHG.js");
84385
84613
  const ext = filePath.toLowerCase().split(".").pop() ?? "";
84386
84614
  const mime = ext === "png" ? "image/png" : ext === "gif" ? "image/gif" : ext === "webp" ? "image/webp" : "image/jpeg";
84387
84615
  const agentModel = params.getAgent?.()?.state?.model;
@@ -84465,8 +84693,8 @@ async function runJsonEventsMode(params) {
84465
84693
  let rawBridgeQueue = Promise.resolve();
84466
84694
  function enqueueBridgeEmission(emission) {
84467
84695
  const run = async () => {
84468
- const deadline = new Promise((resolve8) => {
84469
- const t = setTimeout(resolve8, 1e4);
84696
+ const deadline = new Promise((resolve9) => {
84697
+ const t = setTimeout(resolve9, 1e4);
84470
84698
  t.unref?.();
84471
84699
  });
84472
84700
  await Promise.race([emission().catch(() => void 0), deadline]);
@@ -84572,7 +84800,7 @@ async function runJsonEventsMode(params) {
84572
84800
  });
84573
84801
  }
84574
84802
  function delay(ms) {
84575
- return new Promise((resolve8) => setTimeout(resolve8, Math.max(0, ms)));
84803
+ return new Promise((resolve9) => setTimeout(resolve9, Math.max(0, ms)));
84576
84804
  }
84577
84805
  function touch() {
84578
84806
  if (activeTurn) {
@@ -85166,13 +85394,13 @@ async function runJsonEventsMode(params) {
85166
85394
  if (params.mockResponse !== void 0) return;
85167
85395
  if (!params.createRuntime && !params.runtime) return;
85168
85396
  try {
85169
- await new Promise((resolve8, reject) => {
85397
+ await new Promise((resolve9, reject) => {
85170
85398
  const timer = setTimeout(
85171
85399
  () => reject(new Error("prewarm timeout")),
85172
85400
  prewarmTimeoutMs
85173
85401
  );
85174
85402
  timer.unref?.();
85175
- void ensureRuntime().then(resolve8, reject).finally(() => clearTimeout(timer));
85403
+ void ensureRuntime().then(resolve9, reject).finally(() => clearTimeout(timer));
85176
85404
  });
85177
85405
  } catch (error) {
85178
85406
  handleFatalStartupError(error);
@@ -85237,7 +85465,7 @@ async function runJsonEventsMode(params) {
85237
85465
  writeEvent({ type: "extension.load_failed", message: String(e?.message ?? e) });
85238
85466
  return { extensions: [], errors: [] };
85239
85467
  });
85240
- for (const { path: path28, error } of uncErrors) writeEvent({ type: "extension.load_failed", message: `${path28}: ${error}` });
85468
+ for (const { path: path29, error } of uncErrors) writeEvent({ type: "extension.load_failed", message: `${path29}: ${error}` });
85241
85469
  if (uncExtensions.length && !extensionRunner) {
85242
85470
  const runner = new ExtensionRunner(uncExtensions, { cwd: runtime.cwd }, {
85243
85471
  isIdle: () => controller ? hostIsIdle(controller) : true,
@@ -85580,8 +85808,8 @@ async function runJsonEventsMode(params) {
85580
85808
  return;
85581
85809
  }
85582
85810
  let releaseReady;
85583
- const ready = new Promise((resolve8) => {
85584
- releaseReady = resolve8;
85811
+ const ready = new Promise((resolve9) => {
85812
+ releaseReady = resolve9;
85585
85813
  });
85586
85814
  activeTurn = {
85587
85815
  ready,
@@ -86043,19 +86271,19 @@ async function runJsonEventsMode(params) {
86043
86271
  }
86044
86272
 
86045
86273
  // src/developer-instructions.ts
86046
- import * as fs23 from "fs";
86047
- import * as path26 from "path";
86274
+ import * as fs24 from "fs";
86275
+ import * as path27 from "path";
86048
86276
  var MAX_DEVELOPER_INSTRUCTIONS_CHARS = 64e3;
86049
86277
  function readTextFileBounded(filePath) {
86050
- const resolved = path26.resolve(filePath);
86051
- const stat = fs23.statSync(resolved);
86278
+ const resolved = path27.resolve(filePath);
86279
+ const stat = fs24.statSync(resolved);
86052
86280
  if (!stat.isFile()) {
86053
86281
  throw new Error(`Developer instructions file is not a regular file: ${filePath}`);
86054
86282
  }
86055
86283
  if (stat.size > MAX_DEVELOPER_INSTRUCTIONS_CHARS * 4) {
86056
86284
  throw new Error(`Developer instructions file is too large: ${filePath}`);
86057
86285
  }
86058
- return fs23.readFileSync(resolved, "utf8");
86286
+ return fs24.readFileSync(resolved, "utf8");
86059
86287
  }
86060
86288
  function collectFlagValues(args, flag) {
86061
86289
  const values = [];
@@ -86184,8 +86412,8 @@ var logError = (msg, err) => {
86184
86412
  const logPath = getRuntimeLogPath();
86185
86413
  const timestamp = (/* @__PURE__ */ new Date()).toISOString();
86186
86414
  const stack = err instanceof Error ? err.stack || "" : "";
86187
- fs24.mkdirSync(path27.dirname(logPath), { recursive: true });
86188
- fs24.appendFileSync(logPath, `[${timestamp}] ${msg}
86415
+ fs25.mkdirSync(path28.dirname(logPath), { recursive: true });
86416
+ fs25.appendFileSync(logPath, `[${timestamp}] ${msg}
86189
86417
  ${stack}
86190
86418
 
86191
86419
  `);
@@ -86359,9 +86587,9 @@ async function startChat(initialPrompt, testCommand, explicitSessionId, explicit
86359
86587
  if (testCommand) {
86360
86588
  await interactive.run();
86361
86589
  console.log(`[TEST] Auto-executing command: ${testCommand}`);
86362
- await new Promise((resolve8) => setTimeout(resolve8, 500));
86590
+ await new Promise((resolve9) => setTimeout(resolve9, 500));
86363
86591
  await interactive.executeCommand(testCommand);
86364
- await new Promise((resolve8) => setTimeout(resolve8, 2e3));
86592
+ await new Promise((resolve9) => setTimeout(resolve9, 2e3));
86365
86593
  console.log("[TEST] Command executed, exiting...");
86366
86594
  process.exit(0);
86367
86595
  return;
@@ -86431,7 +86659,7 @@ async function main() {
86431
86659
  if (sub === STABLE_CLI_COMMANDS.models || sub === STABLE_CLI_COMMANDS.manager) {
86432
86660
  try {
86433
86661
  if (sub === STABLE_CLI_COMMANDS.models) await runModelsCommand(subArgs);
86434
- else await (await import("./chunks/manager-cli-BXI4UFTJ.js")).runManagerCommand(subArgs);
86662
+ else await (await import("./chunks/manager-cli-OTIMAWO6.js")).runManagerCommand(subArgs);
86435
86663
  } catch (error) {
86436
86664
  console.error(error instanceof Error ? error.message : String(error));
86437
86665
  process.exitCode = 1;