@prestyj/cli 5.30.3 → 5.32.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/dist/app-sidecar/goal-routes.d.ts +2 -22
  2. package/dist/app-sidecar/goal-routes.js +12 -93
  3. package/dist/app-sidecar/goal-routes.js.map +1 -1
  4. package/dist/app-sidecar/history-routes.js +1 -2
  5. package/dist/app-sidecar/history-routes.js.map +1 -1
  6. package/dist/app-sidecar/prompt-routes.js +1 -2
  7. package/dist/app-sidecar/prompt-routes.js.map +1 -1
  8. package/dist/app-sidecar/run-control-routes.d.ts +14 -0
  9. package/dist/app-sidecar/run-control-routes.js +61 -22
  10. package/dist/app-sidecar/run-control-routes.js.map +1 -1
  11. package/dist/app-sidecar/session-routes.js +5 -1
  12. package/dist/app-sidecar/session-routes.js.map +1 -1
  13. package/dist/app-sidecar/task-routes.js +22 -0
  14. package/dist/app-sidecar/task-routes.js.map +1 -1
  15. package/dist/app-sidecar.js +6 -7
  16. package/dist/app-sidecar.js.map +1 -1
  17. package/dist/core/agent-session.d.ts +17 -0
  18. package/dist/core/agent-session.js +48 -12
  19. package/dist/core/agent-session.js.map +1 -1
  20. package/dist/core/custom-commands.d.ts +6 -0
  21. package/dist/core/custom-commands.js +17 -0
  22. package/dist/core/custom-commands.js.map +1 -1
  23. package/dist/core/goal-run-marker.d.ts +32 -0
  24. package/dist/core/goal-run-marker.js +178 -0
  25. package/dist/core/goal-run-marker.js.map +1 -0
  26. package/dist/core/goal-summary.d.ts +32 -0
  27. package/dist/core/goal-summary.js +110 -0
  28. package/dist/core/goal-summary.js.map +1 -0
  29. package/dist/core/plan-handoff.d.ts +8 -0
  30. package/dist/core/plan-handoff.js +11 -0
  31. package/dist/core/plan-handoff.js.map +1 -1
  32. package/dist/core/resolve-start.d.ts +2 -0
  33. package/dist/core/resolve-start.js +34 -5
  34. package/dist/core/resolve-start.js.map +1 -1
  35. package/dist/core/subagent-policy.js +4 -1
  36. package/dist/core/subagent-policy.js.map +1 -1
  37. package/dist/goals-agent/goals-agent.js +43 -1
  38. package/dist/goals-agent/goals-agent.js.map +1 -1
  39. package/dist/modes/acp-autopilot.d.ts +27 -0
  40. package/dist/modes/acp-autopilot.js +54 -0
  41. package/dist/modes/acp-autopilot.js.map +1 -0
  42. package/dist/modes/acp-goals.d.ts +52 -0
  43. package/dist/modes/acp-goals.js +102 -0
  44. package/dist/modes/acp-goals.js.map +1 -0
  45. package/dist/modes/acp-mode.d.ts +128 -3
  46. package/dist/modes/acp-mode.js +1086 -52
  47. package/dist/modes/acp-mode.js.map +1 -1
  48. package/dist/tools/grep-scan.d.ts +96 -0
  49. package/dist/tools/grep-scan.js +283 -0
  50. package/dist/tools/grep-scan.js.map +1 -0
  51. package/dist/tools/grep.d.ts +10 -0
  52. package/dist/tools/grep.js +418 -10
  53. package/dist/tools/grep.js.map +1 -1
  54. package/dist/ui/components/Footer.js +4 -0
  55. package/dist/ui/components/Footer.js.map +1 -1
  56. package/dist/utils/git-overview.d.ts +41 -0
  57. package/dist/utils/git-overview.js +146 -0
  58. package/dist/utils/git-overview.js.map +1 -0
  59. package/package.json +4 -4
@@ -5,10 +5,10 @@ import { flagUntrustedToolResult } from "./injection-detect.js";
5
5
  import { COMPLETION_REVIEW_STATE_KIND, } from "./completion-review.js";
6
6
  import { SlashCommandRegistry, createBuiltinCommands, } from "./slash-commands.js";
7
7
  import { PROMPT_COMMANDS, getPromptCommand } from "./prompt-commands.js";
8
- import { loadCustomCommands } from "./custom-commands.js";
8
+ import { loadWorkspaceCustomCommands } from "./custom-commands.js";
9
9
  import { expandPromptCommand } from "./prompt-command-expansion.js";
10
10
  import { SettingsManager } from "./settings-manager.js";
11
- import { AuthStorage } from "./auth-storage.js";
11
+ import { AuthStorage, NotLoggedInError } from "./auth-storage.js";
12
12
  import { dualAuthProvider } from "@prestyj/core";
13
13
  import { getClaudeCliUserAgent, recordRequiredClaudeCodeVersion } from "./claude-code-version.js";
14
14
  import { kimiCodingHeaders, isKimiCodingEndpoint } from "./oauth/kimi.js";
@@ -561,7 +561,6 @@ export class AgentSession {
561
561
  const helpCmd = this.slashCommands.get("help");
562
562
  if (helpCmd) {
563
563
  const registry = this.slashCommands;
564
- const cwd = this.cwd;
565
564
  helpCmd.execute = async () => {
566
565
  const all = registry.getAll();
567
566
  const lines = all.map((c) => ` /${c.name}${c.aliases.length ? ` (${c.aliases.map((a) => "/" + a).join(", ")})` : ""} — ${c.description}`);
@@ -571,7 +570,7 @@ export class AgentSession {
571
570
  lines.push(` /${cmd.name}${cmd.aliases.length ? ` (${cmd.aliases.map((a) => "/" + a).join(", ")})` : ""} — ${cmd.description}`);
572
571
  }
573
572
  }
574
- const customCmds = await loadCustomCommands(cwd);
573
+ const customCmds = await this.loadCustomCommands();
575
574
  if (customCmds.length > 0) {
576
575
  lines.push("", "Custom commands:");
577
576
  for (const cmd of customCmds)
@@ -779,7 +778,7 @@ export class AgentSession {
779
778
  return null;
780
779
  // EZ Coder alone can resolve its prompt-template and project commands.
781
780
  const builtinPromptCmd = coderCommands ? getPromptCommand(parsed.name) : undefined;
782
- const customCmds = coderCommands ? await loadCustomCommands(this.cwd) : [];
781
+ const customCmds = coderCommands ? await this.loadCustomCommands() : [];
783
782
  const customPromptCmd = !builtinPromptCmd
784
783
  ? customCmds.find((c) => c.name === parsed.name)
785
784
  : undefined;
@@ -1512,12 +1511,27 @@ export class AgentSession {
1512
1511
  async runLoop(options = {}) {
1513
1512
  this.prewarmController?.abort();
1514
1513
  this.runLoopDepth++;
1514
+ if (this.runLoopDepth === 1)
1515
+ this.notifyRunActive(true);
1515
1516
  try {
1516
1517
  await this.runLoopInner(options);
1517
1518
  }
1518
1519
  finally {
1519
1520
  this.runLoopDepth--;
1520
1521
  this.lastRealRequestAt = Date.now();
1522
+ if (this.runLoopDepth === 0)
1523
+ this.notifyRunActive(false);
1524
+ }
1525
+ }
1526
+ /** `opts.onRunActive`, never allowed to throw into the run. */
1527
+ notifyRunActive(active) {
1528
+ try {
1529
+ this.opts.onRunActive?.(active);
1530
+ }
1531
+ catch (err) {
1532
+ log("WARN", "session", "onRunActive listener threw", {
1533
+ message: err instanceof Error ? err.message : String(err),
1534
+ });
1521
1535
  }
1522
1536
  }
1523
1537
  /** Auto-compact if needed, run agent loop with auth retry, and persist messages. */
@@ -2838,6 +2852,14 @@ export class AgentSession {
2838
2852
  getAdditionalRoots() {
2839
2853
  return [...this.additionalRoots];
2840
2854
  }
2855
+ /**
2856
+ * The custom `.ezcoder/commands` slash commands this session can run: the
2857
+ * project's, then those of every added root (a goal's attached repos too).
2858
+ * Read fresh, so a new command file is picked up without a restart.
2859
+ */
2860
+ loadCustomCommands() {
2861
+ return loadWorkspaceCustomCommands([this.cwd, ...this.additionalRoots]);
2862
+ }
2841
2863
  /**
2842
2864
  * Add another workspace root. Tools already accept absolute paths, so this
2843
2865
  * only widens the write guard and tells the model the root exists. Rebuilding
@@ -3613,16 +3635,28 @@ export class AgentSession {
3613
3635
  }
3614
3636
  // Auto-compact on load if the restored session exceeds the context window.
3615
3637
  // Without this, huge sessions (1M+ tokens) get loaded into memory and OOM.
3616
- const creds = await this.authStorage.resolveCredentials(this.provider, {
3617
- storageKeys: this.currentAuthStorageKeys(),
3638
+ // Credentials only refine the context window here (OpenAI OAuth's Codex
3639
+ // window). A missing login must not make the old conversation unopenable —
3640
+ // the user can switch to a model they're signed in to once it's loaded;
3641
+ // the first prompt still fails cleanly through the run's auth handling.
3642
+ const creds = await this.authStorage
3643
+ .resolveCredentials(this.provider, { storageKeys: this.currentAuthStorageKeys() })
3644
+ .catch((err) => {
3645
+ if (!(err instanceof NotLoggedInError))
3646
+ throw err;
3647
+ log("WARN", "session", "Resuming without credentials for the session model", {
3648
+ provider: this.provider,
3649
+ model: this.model,
3650
+ });
3651
+ return undefined;
3618
3652
  });
3619
3653
  // Cache for sync callers (see field doc) so the app-sidecar's footer shows
3620
3654
  // the right context window immediately on resume, before any prompt runs
3621
3655
  // runLoop() and would otherwise be the first to set this.
3622
- this.lastAccountId = creds.accountId;
3656
+ this.lastAccountId = creds?.accountId;
3623
3657
  const contextWindow = getContextWindow(this.model, {
3624
3658
  provider: this.provider,
3625
- accountId: creds.accountId,
3659
+ accountId: creds?.accountId,
3626
3660
  });
3627
3661
  this.sessionId = loaded.header.id;
3628
3662
  this.setSessionPath(loaded.path);
@@ -3632,20 +3666,22 @@ export class AgentSession {
3632
3666
  model: this.model,
3633
3667
  contextWindow,
3634
3668
  threshold: this.settingsManager.get("compactThreshold"),
3635
- accountId: creds.accountId,
3669
+ accountId: creds?.accountId,
3636
3670
  approvedPlanPath: this.approvedPlanPath,
3637
3671
  });
3638
3672
  log("INFO", "compaction", "Restore compaction decision", {
3639
3673
  provider: this.provider,
3640
3674
  model: this.model,
3641
- transport: this.provider === "openai" && creds.accountId ? "codex_oauth" : "public_api",
3675
+ transport: this.provider === "openai" && creds?.accountId ? "codex_oauth" : "public_api",
3642
3676
  contextWindow: String(contextWindow),
3643
3677
  activeTokens: "estimated",
3644
3678
  triggerLimit: String(loadPolicy.targetTokens),
3645
3679
  });
3646
3680
  const needsLoadCompaction = this.settingsManager.get("autoCompact") &&
3647
3681
  shouldCompact(this.messages, contextWindow, loadPolicy.threshold, undefined, loadPolicy.targetTokens);
3648
- if (needsLoadCompaction && this.opts.deferLoadCompaction) {
3682
+ // Without credentials the summary call can't run now; defer it to the first
3683
+ // prompt, by which point the user has picked a model they're signed in to.
3684
+ if (needsLoadCompaction && (this.opts.deferLoadCompaction || !creds)) {
3649
3685
  // Canonicalize again immediately before the first prompt is persisted:
3650
3686
  // another process may create the shared checkpoint after this load.
3651
3687
  this.deferredCompactionPending = true;