@oh-my-pi/pi-coding-agent 16.1.0 → 16.1.2

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 (76) hide show
  1. package/CHANGELOG.md +36 -1
  2. package/dist/cli.js +3134 -3158
  3. package/dist/types/cli/bench-cli.d.ts +2 -1
  4. package/dist/types/config/settings-schema.d.ts +28 -37
  5. package/dist/types/lsp/types.d.ts +5 -3
  6. package/dist/types/main.d.ts +2 -0
  7. package/dist/types/modes/components/assistant-message.d.ts +12 -0
  8. package/dist/types/modes/components/cache-invalidation-marker.d.ts +7 -2
  9. package/dist/types/modes/components/welcome.d.ts +1 -1
  10. package/dist/types/sdk.d.ts +19 -2
  11. package/dist/types/session/auth-broker-config.d.ts +33 -6
  12. package/dist/types/system-prompt.d.ts +5 -1
  13. package/dist/types/task/executor.d.ts +10 -0
  14. package/dist/types/tools/find.d.ts +0 -2
  15. package/dist/types/tools/search.d.ts +3 -3
  16. package/package.json +12 -12
  17. package/scripts/measure-prompt-tokens.ts +63 -0
  18. package/src/cli/bench-cli.ts +64 -3
  19. package/src/cli/startup-cwd.ts +3 -13
  20. package/src/config/settings-schema.ts +34 -37
  21. package/src/config/settings.ts +40 -0
  22. package/src/cursor.ts +1 -1
  23. package/src/debug/raw-sse-buffer.ts +31 -10
  24. package/src/eval/py/prelude.py +1 -1
  25. package/src/export/html/tool-views.generated.js +1 -1
  26. package/src/extensibility/extensions/runner.ts +8 -2
  27. package/src/internal-urls/docs-index.generated.txt +1 -1
  28. package/src/lsp/client.ts +9 -9
  29. package/src/lsp/types.ts +6 -3
  30. package/src/main.ts +29 -9
  31. package/src/modes/components/assistant-message.ts +86 -0
  32. package/src/modes/components/cache-invalidation-marker.ts +12 -2
  33. package/src/modes/components/settings-defs.ts +7 -0
  34. package/src/modes/components/tips.txt +2 -1
  35. package/src/modes/components/welcome.ts +86 -8
  36. package/src/modes/controllers/event-controller.ts +1 -1
  37. package/src/prompts/system/personalities/default.md +8 -16
  38. package/src/prompts/system/system-prompt.md +101 -115
  39. package/src/prompts/tools/ast-edit.md +10 -12
  40. package/src/prompts/tools/ast-grep.md +14 -18
  41. package/src/prompts/tools/bash.md +19 -21
  42. package/src/prompts/tools/browser.md +24 -24
  43. package/src/prompts/tools/checkpoint.md +0 -1
  44. package/src/prompts/tools/debug.md +11 -15
  45. package/src/prompts/tools/eval.md +27 -27
  46. package/src/prompts/tools/find.md +6 -10
  47. package/src/prompts/tools/github.md +11 -15
  48. package/src/prompts/tools/goal.md +0 -7
  49. package/src/prompts/tools/inspect-image.md +0 -1
  50. package/src/prompts/tools/irc.md +15 -24
  51. package/src/prompts/tools/job.md +5 -8
  52. package/src/prompts/tools/learn.md +2 -2
  53. package/src/prompts/tools/lsp.md +27 -30
  54. package/src/prompts/tools/manage-skill.md +4 -4
  55. package/src/prompts/tools/read.md +21 -23
  56. package/src/prompts/tools/replace.md +0 -1
  57. package/src/prompts/tools/resolve.md +4 -9
  58. package/src/prompts/tools/rewind.md +1 -1
  59. package/src/prompts/tools/search.md +8 -10
  60. package/src/prompts/tools/task.md +33 -38
  61. package/src/prompts/tools/todo.md +14 -18
  62. package/src/prompts/tools/web-search.md +0 -4
  63. package/src/prompts/tools/write.md +1 -1
  64. package/src/sdk.ts +49 -102
  65. package/src/session/agent-session.ts +23 -12
  66. package/src/session/auth-broker-config.ts +36 -76
  67. package/src/session/session-history-format.ts +1 -1
  68. package/src/session/session-manager.ts +33 -6
  69. package/src/system-prompt.ts +28 -8
  70. package/src/task/executor.ts +57 -0
  71. package/src/task/index.ts +15 -1
  72. package/src/tools/browser.ts +1 -1
  73. package/src/tools/eval.ts +1 -1
  74. package/src/tools/find.ts +4 -17
  75. package/src/tools/memory-edit.ts +1 -1
  76. package/src/tools/search.ts +5 -5
@@ -342,44 +342,38 @@ export const SETTINGS_SCHEMA = {
342
342
  },
343
343
 
344
344
  // macOS power assertions (caffeinate flags). No-op on other platforms.
345
- "power.preventIdleSleep": {
346
- type: "boolean",
347
- default: true,
348
- ui: {
349
- tab: "interaction",
350
- group: "Power (macOS)",
351
- label: "Prevent Idle Sleep",
352
- description: "Keep the system awake while a session is open (caffeinate -i)",
353
- },
354
- },
355
- "power.preventSystemSleep": {
356
- type: "boolean",
357
- default: false,
358
- ui: {
359
- tab: "interaction",
360
- group: "Power (macOS)",
361
- label: "Prevent System Sleep on AC",
362
- description: "Block all system sleep while on AC power (caffeinate -s)",
363
- },
364
- },
365
- "power.declareUserActive": {
366
- type: "boolean",
367
- default: false,
368
- ui: {
369
- tab: "interaction",
370
- group: "Power (macOS)",
371
- label: "Declare User Active",
372
- description: "Keep the display lit and treat the user as active (caffeinate -u)",
373
- },
374
- },
375
- "power.preventDisplaySleep": {
376
- type: "boolean",
377
- default: false,
345
+ "power.sleepPrevention": {
346
+ type: "enum",
347
+ values: ["off", "idle", "display", "system"] as const,
348
+ default: "idle",
378
349
  ui: {
379
350
  tab: "interaction",
380
351
  group: "Power (macOS)",
381
- label: "Prevent Display Sleep",
382
- description: "Keep the display from idle-sleeping while a session is open (caffeinate -d)",
352
+ label: "Sleep Prevention",
353
+ description:
354
+ "Prevent macOS sleep during active sessions. Each level is cumulative — it adds the flags of all lower levels.",
355
+ options: [
356
+ {
357
+ value: "off",
358
+ label: "Off",
359
+ description: "Do not prevent any sleep",
360
+ },
361
+ {
362
+ value: "idle",
363
+ label: "Prevent Idle Sleep",
364
+ description: "Keep the system awake while a session is open (caffeinate -i)",
365
+ },
366
+ {
367
+ value: "display",
368
+ label: "Prevent Display Sleep",
369
+ description: "Also keep the display from idle-sleeping (caffeinate -i -d)",
370
+ },
371
+ {
372
+ value: "system",
373
+ label: "Prevent System Sleep",
374
+ description: "Also block all system sleep on AC and declare the user active (caffeinate -i -d -s -u)",
375
+ },
376
+ ],
383
377
  },
384
378
  },
385
379
  "advisor.enabled": {
@@ -401,6 +395,7 @@ export const SETTINGS_SCHEMA = {
401
395
  group: "Advisor",
402
396
  label: "Advisor for Subagents",
403
397
  description: "Also enable the advisor on spawned task/eval subagents.",
398
+ condition: "advisorEnabled",
404
399
  },
405
400
  },
406
401
  "advisor.syncBacklog": {
@@ -413,6 +408,7 @@ export const SETTINGS_SCHEMA = {
413
408
  label: "Advisor Sync Backlog",
414
409
  description:
415
410
  "Pause the main agent for up to 30 seconds if the advisor falls behind by this many turns. Off disables catch-up delays.",
411
+ condition: "advisorEnabled",
416
412
  },
417
413
  },
418
414
  "advisor.immuneTurns": {
@@ -432,6 +428,7 @@ export const SETTINGS_SCHEMA = {
432
428
  { value: "4", label: "4 turns" },
433
429
  { value: "5", label: "5 turns" },
434
430
  ],
431
+ condition: "advisorEnabled",
435
432
  },
436
433
  },
437
434
  shellPath: { type: "string", default: undefined },
@@ -851,7 +848,7 @@ export const SETTINGS_SCHEMA = {
851
848
 
852
849
  "display.cacheMissMarker": {
853
850
  type: "boolean",
854
- default: true,
851
+ default: false,
855
852
  ui: {
856
853
  tab: "appearance",
857
854
  group: "Display",
@@ -927,7 +924,7 @@ export const SETTINGS_SCHEMA = {
927
924
 
928
925
  inlineToolDescriptors: {
929
926
  type: "boolean",
930
- default: true,
927
+ default: false,
931
928
  ui: {
932
929
  tab: "model",
933
930
  group: "Prompt",
@@ -909,6 +909,46 @@ export class Settings {
909
909
  }
910
910
  }
911
911
 
912
+ // power.preventIdleSleep / power.preventSystemSleep / power.declareUserActive
913
+ // / power.preventDisplaySleep (four booleans) → power.sleepPrevention enum.
914
+ // The enum is cumulative: each level adds the flags of all lower levels.
915
+ // Migration picks the highest level whose condition is met, scanning from
916
+ // most to least aggressive so a single enum value captures the old state.
917
+ if (
918
+ !("sleepPrevention" in ((raw.power as Record<string, unknown>) ?? {})) &&
919
+ raw["power.sleepPrevention"] === undefined
920
+ ) {
921
+ const powerObj = raw.power as Record<string, unknown> | undefined;
922
+ const getFlag = (key: string): boolean | undefined => {
923
+ const nested = powerObj?.[key];
924
+ const flat = raw[`power.${key}`];
925
+ const value = nested ?? flat;
926
+ return typeof value === "boolean" ? value : undefined;
927
+ };
928
+ const idle = getFlag("preventIdleSleep");
929
+ const system = getFlag("preventSystemSleep");
930
+ const user = getFlag("declareUserActive");
931
+ const display = getFlag("preventDisplaySleep");
932
+ const anySet = idle !== undefined || system !== undefined || user !== undefined || display !== undefined;
933
+ if (anySet) {
934
+ const mode = system || user ? "system" : display ? "display" : idle !== false ? "idle" : "off";
935
+ const powerRoot = (powerObj ?? {}) as Record<string, unknown>;
936
+ powerRoot.sleepPrevention = mode;
937
+ raw.power = powerRoot;
938
+ }
939
+ // Clean up old keys (nested + flat)
940
+ if (powerObj) {
941
+ delete powerObj.preventIdleSleep;
942
+ delete powerObj.preventSystemSleep;
943
+ delete powerObj.declareUserActive;
944
+ delete powerObj.preventDisplaySleep;
945
+ }
946
+ delete raw["power.preventIdleSleep"];
947
+ delete raw["power.preventSystemSleep"];
948
+ delete raw["power.declareUserActive"];
949
+ delete raw["power.preventDisplaySleep"];
950
+ }
951
+
912
952
  return raw;
913
953
  }
914
954
 
package/src/cursor.ts CHANGED
@@ -181,7 +181,7 @@ export class CursorExecHandlers implements ICursorExecHandlers {
181
181
  const toolResultMessage = await executeTool(this.options, "search", toolCallId, {
182
182
  pattern: args.pattern,
183
183
  paths: [searchPath],
184
- i: args.caseInsensitive || undefined,
184
+ case: args.caseInsensitive === true ? false : undefined,
185
185
  });
186
186
  return toolResultMessage;
187
187
  }
@@ -119,9 +119,16 @@ export class RawSseDebugBuffer {
119
119
  #records: RawSseDebugRecord[] = [];
120
120
  // Parallel to `#records`: `#recordChars[i]` is the precomputed char count
121
121
  // for `#records[i]`. Kept in lockstep by `#append` (push both) and
122
- // `#enforceLimits` (shift both). See the comment above the class for why
123
- // this is a sidecar array instead of a per-record property.
122
+ // `#enforceLimits` (advance `#head` to evict, then `slice` both together
123
+ // when compacting). See the comment above the class for why this is a
124
+ // sidecar array instead of a per-record property.
124
125
  #recordChars: number[] = [];
126
+ // Head-index ring over `#records`/`#recordChars`: index of the oldest live
127
+ // record. Eviction advances `#head` (amortized O(1)) rather than an O(n)
128
+ // front `shift()`; the dead `[0, #head)` prefix is reclaimed lazily by
129
+ // `#enforceLimits`. Live count is `#records.length - #head`; the live
130
+ // records are `#records[#head ..]`.
131
+ #head = 0;
125
132
  #totalChars = 0;
126
133
  #droppedRecords = 0;
127
134
  #droppedChars = 0;
@@ -181,7 +188,7 @@ export class RawSseDebugBuffer {
181
188
 
182
189
  snapshot(): RawSseDebugSnapshot {
183
190
  return {
184
- records: [...this.#records],
191
+ records: this.#records.slice(this.#head),
185
192
  droppedRecords: this.#droppedRecords,
186
193
  droppedChars: this.#droppedChars,
187
194
  totalEvents: this.#totalEvents,
@@ -190,9 +197,12 @@ export class RawSseDebugBuffer {
190
197
  }
191
198
 
192
199
  toRawText(): string {
193
- // Reads the live array directly: `rawRecordText` only computes a string
194
- // from each record, so no caller-visible mutation is possible.
195
- const body = this.#records.map(rawRecordText).join("\n");
200
+ // Reads the live window directly: `rawRecordText` only computes a string
201
+ // from each record, so no caller-visible mutation is possible. With a
202
+ // non-empty dead prefix we map a slice past `#head`; `#head === 0` (the
203
+ // common case) maps `#records` in place with no extra copy.
204
+ const live = this.#head === 0 ? this.#records : this.#records.slice(this.#head);
205
+ const body = live.map(rawRecordText).join("\n");
196
206
  if (this.#droppedRecords === 0) return body;
197
207
  const dropped = `: omp-debug-dropped records=${this.#droppedRecords} chars=${this.#droppedChars}\n\n`;
198
208
  return body.length > 0 ? `${dropped}${body}` : dropped;
@@ -208,14 +218,25 @@ export class RawSseDebugBuffer {
208
218
  }
209
219
 
210
220
  #enforceLimits(): void {
211
- while (this.#records.length > MAX_RAW_SSE_EVENTS || this.#totalChars > MAX_RAW_SSE_CHARS) {
212
- if (this.#records.length === 0) return;
213
- this.#records.shift();
214
- const chars = this.#recordChars.shift() ?? 0;
221
+ while (this.#records.length - this.#head > MAX_RAW_SSE_EVENTS || this.#totalChars > MAX_RAW_SSE_CHARS) {
222
+ if (this.#records.length - this.#head === 0) break;
223
+ const chars = this.#recordChars[this.#head] ?? 0;
224
+ this.#head += 1;
215
225
  this.#totalChars = Math.max(0, this.#totalChars - chars);
216
226
  this.#droppedRecords += 1;
217
227
  this.#droppedChars += chars;
218
228
  }
229
+ // Reclaim the consumed `[0, #head)` prefix once it grows large: one O(n)
230
+ // memmove amortized over many O(1) evictions, bounding the backing arrays
231
+ // to ~2x the live window. `#head >= MAX_RAW_SSE_EVENTS` covers the
232
+ // full-record-count steady state; `#head > liveCount` covers a small live
233
+ // window held by a few large records under the char budget.
234
+ const liveCount = this.#records.length - this.#head;
235
+ if (this.#head >= MAX_RAW_SSE_EVENTS || this.#head > liveCount) {
236
+ this.#records = this.#records.slice(this.#head);
237
+ this.#recordChars = this.#recordChars.slice(this.#head);
238
+ this.#head = 0;
239
+ }
219
240
  }
220
241
 
221
242
  #emit(): void {
@@ -5,7 +5,7 @@ if "__omp_prelude_loaded__" not in globals():
5
5
  from pathlib import Path
6
6
  import os, json, math, re
7
7
  from urllib.parse import unquote
8
- INTENT_FIELD = "_i"
8
+ INTENT_FIELD = "i"
9
9
 
10
10
  # __omp_display is injected by runner.py before the prelude executes; it
11
11
  # mirrors IPython's display() semantics with the same MIME bundle output.