@prestyj/cli 5.33.0 → 5.34.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 (218) hide show
  1. package/README.md +16 -16
  2. package/dist/app-sidecar/app-settings.js +3 -0
  3. package/dist/app-sidecar/app-settings.js.map +1 -1
  4. package/dist/app-sidecar/autopilot-runner.d.ts +7 -0
  5. package/dist/app-sidecar/autopilot-runner.js +79 -19
  6. package/dist/app-sidecar/autopilot-runner.js.map +1 -1
  7. package/dist/app-sidecar/live-preview/dev-url.d.ts +32 -0
  8. package/dist/app-sidecar/live-preview/dev-url.js +97 -0
  9. package/dist/app-sidecar/live-preview/dev-url.js.map +1 -0
  10. package/dist/app-sidecar/live-preview/frame-server.d.ts +31 -0
  11. package/dist/app-sidecar/live-preview/frame-server.js +193 -0
  12. package/dist/app-sidecar/live-preview/frame-server.js.map +1 -0
  13. package/dist/app-sidecar/live-preview/manager.d.ts +44 -0
  14. package/dist/app-sidecar/live-preview/manager.js +215 -0
  15. package/dist/app-sidecar/live-preview/manager.js.map +1 -0
  16. package/dist/app-sidecar/live-preview/proxy.d.ts +30 -0
  17. package/dist/app-sidecar/live-preview/proxy.js +235 -0
  18. package/dist/app-sidecar/live-preview/proxy.js.map +1 -0
  19. package/dist/app-sidecar/live-preview/routes.d.ts +4 -0
  20. package/dist/app-sidecar/live-preview/routes.js +52 -0
  21. package/dist/app-sidecar/live-preview/routes.js.map +1 -0
  22. package/dist/app-sidecar/live-preview/servers.d.ts +36 -0
  23. package/dist/app-sidecar/live-preview/servers.js +228 -0
  24. package/dist/app-sidecar/live-preview/servers.js.map +1 -0
  25. package/dist/app-sidecar/mcp-routes.js +9 -0
  26. package/dist/app-sidecar/mcp-routes.js.map +1 -1
  27. package/dist/app-sidecar/mcp-shell-command.d.ts +36 -0
  28. package/dist/app-sidecar/mcp-shell-command.js +302 -0
  29. package/dist/app-sidecar/mcp-shell-command.js.map +1 -0
  30. package/dist/app-sidecar/mcp-sync.d.ts +18 -0
  31. package/dist/app-sidecar/mcp-sync.js +38 -0
  32. package/dist/app-sidecar/mcp-sync.js.map +1 -0
  33. package/dist/app-sidecar/prompt-routes.js +31 -26
  34. package/dist/app-sidecar/prompt-routes.js.map +1 -1
  35. package/dist/app-sidecar/route-context.d.ts +3 -1
  36. package/dist/app-sidecar/run-control-routes.js +8 -1
  37. package/dist/app-sidecar/run-control-routes.js.map +1 -1
  38. package/dist/app-sidecar/shell-routes.js +7 -0
  39. package/dist/app-sidecar/shell-routes.js.map +1 -1
  40. package/dist/app-sidecar/task-routes.js +1 -1
  41. package/dist/app-sidecar/task-routes.js.map +1 -1
  42. package/dist/app-sidecar/workspace-routes.js +35 -37
  43. package/dist/app-sidecar/workspace-routes.js.map +1 -1
  44. package/dist/app-sidecar.js +136 -38
  45. package/dist/app-sidecar.js.map +1 -1
  46. package/dist/cli/mcp.js +19 -5
  47. package/dist/cli/mcp.js.map +1 -1
  48. package/dist/cli/shared.js +4 -0
  49. package/dist/cli/shared.js.map +1 -1
  50. package/dist/cli.js +13 -3
  51. package/dist/cli.js.map +1 -1
  52. package/dist/config.js +2 -0
  53. package/dist/config.js.map +1 -1
  54. package/dist/core/agent-session/mcp-tools.d.ts +17 -0
  55. package/dist/core/agent-session/mcp-tools.js +31 -0
  56. package/dist/core/agent-session/mcp-tools.js.map +1 -1
  57. package/dist/core/agent-session/verification-tracker.js +2 -10
  58. package/dist/core/agent-session/verification-tracker.js.map +1 -1
  59. package/dist/core/agent-session.d.ts +29 -0
  60. package/dist/core/agent-session.js +196 -11
  61. package/dist/core/agent-session.js.map +1 -1
  62. package/dist/core/agents.d.ts +0 -10
  63. package/dist/core/agents.js +5 -1
  64. package/dist/core/agents.js.map +1 -1
  65. package/dist/core/ask-user.d.ts +2 -0
  66. package/dist/core/ask-user.js +8 -1
  67. package/dist/core/ask-user.js.map +1 -1
  68. package/dist/core/checklist-items.d.ts +2 -2
  69. package/dist/core/checklist-items.js +14 -2
  70. package/dist/core/checklist-items.js.map +1 -1
  71. package/dist/core/checklist-prompt.d.ts +1 -1
  72. package/dist/core/checklist-prompt.js +1 -1
  73. package/dist/core/claude-code/complete.d.ts +2 -0
  74. package/dist/core/claude-code/complete.js +3 -0
  75. package/dist/core/claude-code/complete.js.map +1 -1
  76. package/dist/core/claude-code/transcripts.d.ts +29 -0
  77. package/dist/core/claude-code/transcripts.js +117 -0
  78. package/dist/core/claude-code/transcripts.js.map +1 -0
  79. package/dist/core/codex-request-shape.js +1 -1
  80. package/dist/core/compaction/compactor.d.ts +2 -0
  81. package/dist/core/compaction/compactor.js +7 -3
  82. package/dist/core/compaction/compactor.js.map +1 -1
  83. package/dist/core/compaction/plan-step-policy.d.ts +1 -1
  84. package/dist/core/compaction/plan-step-policy.js +1 -1
  85. package/dist/core/compaction/policy.js +3 -2
  86. package/dist/core/compaction/policy.js.map +1 -1
  87. package/dist/core/compaction/tool-result-pruner.d.ts +12 -2
  88. package/dist/core/compaction/tool-result-pruner.js +14 -3
  89. package/dist/core/compaction/tool-result-pruner.js.map +1 -1
  90. package/dist/core/extensions/plugin-bundles.d.ts +0 -9
  91. package/dist/core/extensions/plugin-bundles.js +0 -185
  92. package/dist/core/extensions/plugin-bundles.js.map +1 -1
  93. package/dist/core/goals-store.d.ts +0 -2
  94. package/dist/core/goals-store.js +0 -5
  95. package/dist/core/goals-store.js.map +1 -1
  96. package/dist/core/live-preview.d.ts +24 -0
  97. package/dist/core/live-preview.js +76 -0
  98. package/dist/core/live-preview.js.map +1 -0
  99. package/dist/core/mcp/client.d.ts +9 -0
  100. package/dist/core/mcp/client.js +58 -5
  101. package/dist/core/mcp/client.js.map +1 -1
  102. package/dist/core/mcp/oauth-provider.d.ts +7 -1
  103. package/dist/core/mcp/oauth-provider.js +11 -4
  104. package/dist/core/mcp/oauth-provider.js.map +1 -1
  105. package/dist/core/mcp/oauth-store.d.ts +6 -0
  106. package/dist/core/mcp/oauth-store.js +14 -0
  107. package/dist/core/mcp/oauth-store.js.map +1 -1
  108. package/dist/core/mcp/parse-add-command.d.ts +29 -3
  109. package/dist/core/mcp/parse-add-command.js +196 -26
  110. package/dist/core/mcp/parse-add-command.js.map +1 -1
  111. package/dist/core/mcp/store.d.ts +16 -0
  112. package/dist/core/mcp/store.js +28 -0
  113. package/dist/core/mcp/store.js.map +1 -1
  114. package/dist/core/mcp/types.d.ts +9 -0
  115. package/dist/core/nolan-ask-answer.d.ts +24 -0
  116. package/dist/core/nolan-ask-answer.js +96 -0
  117. package/dist/core/nolan-ask-answer.js.map +1 -0
  118. package/dist/core/nolan-context.d.ts +20 -0
  119. package/dist/core/nolan-context.js +55 -0
  120. package/dist/core/nolan-context.js.map +1 -1
  121. package/dist/core/nolan-prompt.js +6 -0
  122. package/dist/core/nolan-prompt.js.map +1 -1
  123. package/dist/core/opencode-catalog-store.d.ts +20 -0
  124. package/dist/core/opencode-catalog-store.js +82 -0
  125. package/dist/core/opencode-catalog-store.js.map +1 -0
  126. package/dist/core/package-cooldown.d.ts +0 -2
  127. package/dist/core/package-cooldown.js +0 -4
  128. package/dist/core/package-cooldown.js.map +1 -1
  129. package/dist/core/process-manager.d.ts +1 -1
  130. package/dist/core/process-manager.js +1 -1
  131. package/dist/core/prompt-commands.js +66 -33
  132. package/dist/core/prompt-commands.js.map +1 -1
  133. package/dist/core/runtime-mode.d.ts +0 -8
  134. package/dist/core/runtime-mode.js.map +1 -1
  135. package/dist/core/session-history.js +15 -3
  136. package/dist/core/session-history.js.map +1 -1
  137. package/dist/core/session-manager.d.ts +5 -0
  138. package/dist/core/session-manager.js +12 -7
  139. package/dist/core/session-manager.js.map +1 -1
  140. package/dist/core/session-storage.d.ts +0 -2
  141. package/dist/core/session-storage.js +0 -2
  142. package/dist/core/session-storage.js.map +1 -1
  143. package/dist/core/settings-manager.d.ts +2 -0
  144. package/dist/core/settings-manager.js +3 -1
  145. package/dist/core/settings-manager.js.map +1 -1
  146. package/dist/core/shell-path.d.ts +2 -0
  147. package/dist/core/shell-path.js +10 -1
  148. package/dist/core/shell-path.js.map +1 -1
  149. package/dist/core/skills.d.ts +2 -0
  150. package/dist/core/skills.js +5 -0
  151. package/dist/core/skills.js.map +1 -1
  152. package/dist/core/subagent-policy.js +1 -1
  153. package/dist/core/subagent-policy.js.map +1 -1
  154. package/dist/core/task-store.d.ts +0 -1
  155. package/dist/core/task-store.js +0 -3
  156. package/dist/core/task-store.js.map +1 -1
  157. package/dist/core/trophies/catalog-more.js +3 -3
  158. package/dist/core/trophies/catalog-more.js.map +1 -1
  159. package/dist/core/trophies/catalog.js +3 -3
  160. package/dist/core/trophies/catalog.js.map +1 -1
  161. package/dist/modes/acp-mode.d.ts +1 -1
  162. package/dist/motion-agent/motion-review.d.ts +0 -75
  163. package/dist/motion-agent/motion-review.js +0 -189
  164. package/dist/motion-agent/motion-review.js.map +1 -1
  165. package/dist/system-prompt.d.ts +5 -1
  166. package/dist/system-prompt.js +14 -7
  167. package/dist/system-prompt.js.map +1 -1
  168. package/dist/test-support/system-tools.d.ts +6 -0
  169. package/dist/test-support/system-tools.js +36 -0
  170. package/dist/test-support/system-tools.js.map +1 -0
  171. package/dist/tools/ask-user.js +2 -1
  172. package/dist/tools/ask-user.js.map +1 -1
  173. package/dist/tools/bash.d.ts +2 -2
  174. package/dist/tools/bash.js +363 -358
  175. package/dist/tools/bash.js.map +1 -1
  176. package/dist/tools/live-preview.d.ts +21 -0
  177. package/dist/tools/live-preview.js +37 -0
  178. package/dist/tools/live-preview.js.map +1 -0
  179. package/dist/tools/path-utils.d.ts +0 -15
  180. package/dist/tools/path-utils.js +0 -17
  181. package/dist/tools/path-utils.js.map +1 -1
  182. package/dist/tools/truncate.d.ts +0 -2
  183. package/dist/tools/truncate.js +0 -2
  184. package/dist/tools/truncate.js.map +1 -1
  185. package/dist/tools/web-fetch.d.ts +7 -1
  186. package/dist/tools/web-fetch.js +15 -4
  187. package/dist/tools/web-fetch.js.map +1 -1
  188. package/dist/ui/App.js +0 -1
  189. package/dist/ui/App.js.map +1 -1
  190. package/dist/ui/app-items.d.ts +0 -2
  191. package/dist/ui/app-items.js +0 -2
  192. package/dist/ui/app-items.js.map +1 -1
  193. package/dist/ui/components/Footer.js +4 -4
  194. package/dist/ui/components/Footer.js.map +1 -1
  195. package/dist/ui/components/ModelSelector.js +2 -0
  196. package/dist/ui/components/ModelSelector.js.map +1 -1
  197. package/dist/ui/constants/figures.d.ts +0 -8
  198. package/dist/ui/constants/figures.js +0 -8
  199. package/dist/ui/constants/figures.js.map +1 -1
  200. package/dist/ui/layout-decisions.d.ts +0 -5
  201. package/dist/ui/layout-decisions.js +1 -10
  202. package/dist/ui/layout-decisions.js.map +1 -1
  203. package/dist/ui/terminal-history-status-renderers.d.ts +0 -1
  204. package/dist/ui/terminal-history-status-renderers.js +0 -12
  205. package/dist/ui/terminal-history-status-renderers.js.map +1 -1
  206. package/dist/ui/transcript/presentation.d.ts +1 -2
  207. package/dist/ui/transcript/presentation.js +0 -4
  208. package/dist/ui/transcript/presentation.js.map +1 -1
  209. package/dist/utils/image.d.ts +0 -4
  210. package/dist/utils/image.js +0 -10
  211. package/dist/utils/image.js.map +1 -1
  212. package/dist/web.d.ts +5 -0
  213. package/dist/web.js +5 -0
  214. package/dist/web.js.map +1 -0
  215. package/package.json +9 -5
  216. package/dist/motion-agent/motion-review-gate.d.ts +0 -48
  217. package/dist/motion-agent/motion-review-gate.js +0 -88
  218. package/dist/motion-agent/motion-review-gate.js.map +0 -1
@@ -27,7 +27,7 @@ import { RunLifecycle } from "./core/run-lifecycle.js";
27
27
  import { RunClaim } from "./core/run-claim.js";
28
28
  import { IdleWakeController } from "./core/idle-wake.js";
29
29
  import { IMPLEMENT_PLAN_PROMPT as SHARED_IMPLEMENT_PLAN_PROMPT, PLAN_SUBMITTED_FOR_REVIEW, shouldOfferPendingPlan, } from "./core/plan-handoff.js";
30
- import { discoverSkillsWithBlocked } from "./core/skills.js";
30
+ import { discoverSkillsWithBlocked, loadBundledSkill } from "./core/skills.js";
31
31
  import { chatWorkspaceDir, createChatAgent, parseChatAgentId, switchChatAgent, } from "./chat-agents/index.js";
32
32
  import { createMotionAgentSession } from "./motion-agent/motion-agent.js";
33
33
  import { buildJiwaTools, JiwaStore } from "./chat-agents/jiwa.js";
@@ -43,6 +43,7 @@ import { pruneCheckpointSessions } from "./core/checkpoint-store.js";
43
43
  import { dualAuthProvider, discoverLocalModels, findProbedModel, isLocalModelId, formatLocalModelId, parseLocalModelId, probeEndpoint, ollamaServedContext, toModelInfo as localModelInfo, } from "@prestyj/core";
44
44
  import { listAllEndpoints, listCustomEndpoints, syncEndpointCredentials, } from "./core/local-endpoint-store.js";
45
45
  import { loadOpenRouterCatalog } from "./core/openrouter-catalog-store.js";
46
+ import { openCodeCatalogs } from "./core/opencode-catalog-store.js";
46
47
  import { AUTH_PROVIDERS, authPriorityNote, describeAuthMethods, } from "./core/auth-providers.js";
47
48
  import { ensureAppDirs, loadSavedSettings } from "./config.js";
48
49
  import { SettingsManager } from "./core/settings-manager.js";
@@ -87,7 +88,12 @@ import { handleAuthRoutes } from "./app-sidecar/auth-routes.js";
87
88
  import { handleIntegrationRoutes } from "./app-sidecar/integration-routes.js";
88
89
  import { handleMcpRoutes } from "./app-sidecar/mcp-routes.js";
89
90
  import { finishShellRun, handleShellRoutes } from "./app-sidecar/shell-routes.js";
91
+ import { createLivePreviewManager, findLivePreviewAssets, } from "./app-sidecar/live-preview/manager.js";
92
+ import { handleLivePreviewRoutes } from "./app-sidecar/live-preview/routes.js";
93
+ import { findProjectServers, probePort } from "./app-sidecar/live-preview/servers.js";
94
+ import { createLivePreviewTool } from "./tools/live-preview.js";
90
95
  import { ShellRunner } from "./app-sidecar/shell-runs.js";
96
+ import { syncMcpServerAcross } from "./app-sidecar/mcp-sync.js";
91
97
  import { createHfPullManager } from "./app-sidecar/hf-pull-manager.js";
92
98
  import { keepAwake } from "./app-sidecar/keep-awake.js";
93
99
  import { createAutopilotRunner } from "./app-sidecar/autopilot-runner.js";
@@ -235,6 +241,11 @@ async function main() {
235
241
  error: err instanceof Error ? err.message : String(err),
236
242
  });
237
243
  });
244
+ // OpenCode's cached model lists; `/models` reads them again when stale.
245
+ void openCodeCatalogs.load().then((installed) => {
246
+ if (installed)
247
+ broadcastAll("models_change", {});
248
+ });
238
249
  const sessionIdsAt = (cwd) => {
239
250
  const target = path.resolve(cwd);
240
251
  return [...sessions.values()]
@@ -242,6 +253,8 @@ async function main() {
242
253
  .map((ctx) => ctx.id)
243
254
  .sort();
244
255
  };
256
+ /** Apply a saved MCP server change to every open window, no restart needed. */
257
+ const syncMcpServer = (name) => syncMcpServerAcross(sessions.values(), name, paths.settingsFile);
245
258
  /** Whether any live window session in `cwd` is working right now. */
246
259
  const busyAt = (cwd) => {
247
260
  const target = path.resolve(cwd);
@@ -286,6 +299,62 @@ async function main() {
286
299
  ctx.broadcast("trophies", { ...snapshot, origin: ctx.id === originId });
287
300
  });
288
301
  const { subscriptionUsage } = createUsageService(auth);
302
+ /** Create a session and register it under a fresh id (a window's, or a live preview's). */
303
+ const openSession = async (opts, { preview = false } = {}) => {
304
+ const id = randomUUID();
305
+ const ctx = await createSession({
306
+ auth,
307
+ paths,
308
+ progress,
309
+ trophies,
310
+ memoryStore,
311
+ jiwaStore,
312
+ broadcastAll,
313
+ oauthInFlightProviders,
314
+ repoPolls,
315
+ sessionIdsAt,
316
+ busyAt,
317
+ syncMcpServer,
318
+ // The preview's own session has no window to preview from.
319
+ ...(preview
320
+ ? {}
321
+ : {
322
+ livePreview: async (sessionId, url) => {
323
+ const window = sessions.get(sessionId);
324
+ if (!window)
325
+ throw new Error("This window's session is gone.");
326
+ return livePreview.start(window, url ? { url } : {});
327
+ },
328
+ }),
329
+ }, { id, ...opts });
330
+ sessions.set(id, ctx);
331
+ log("INFO", "app-sidecar", "session created", {
332
+ id,
333
+ mode: opts.mode,
334
+ chatAgent: opts.chatAgent,
335
+ cwd: opts.cwd,
336
+ });
337
+ return ctx;
338
+ };
339
+ const closeSession = async (id) => {
340
+ const ctx = sessions.get(id);
341
+ if (!ctx)
342
+ return;
343
+ sessions.delete(id);
344
+ log("INFO", "app-sidecar", "session disposed", { id });
345
+ await ctx.dispose().catch(() => { });
346
+ };
347
+ // Live preview: one per window, each with its own session in the window's project.
348
+ const livePreview = createLivePreviewManager({
349
+ assetsDir: findLivePreviewAssets(),
350
+ scan: (cwd) => findProjectServers(cwd),
351
+ probe: (port) => probePort(port),
352
+ createSession: (cwd) => openSession({ mode: "code", chatAgent: parseChatAgentId(undefined), cwd }, { preview: true }),
353
+ closeSession,
354
+ usage: subscriptionUsage,
355
+ log: (message, fields) => log("INFO", "live-preview", message, fields),
356
+ onChange: (windowId, status) => sessions.get(windowId)?.broadcast("live_preview", status),
357
+ });
289
358
  // git status / GitHub counts / CI pollers, one per repo however many windows
290
359
  // have it open (each window used to run its own).
291
360
  const repoPolls = createRepoPolls();
@@ -351,33 +420,13 @@ async function main() {
351
420
  ? body.cwd
352
421
  : (process.env.GG_APP_CWD ?? process.cwd());
353
422
  const sessionPath = typeof body.sessionPath === "string" && body.sessionPath ? body.sessionPath : undefined;
354
- const id = randomUUID();
355
423
  try {
356
- const ctx = await createSession({
357
- auth,
358
- paths,
359
- progress,
360
- trophies,
361
- memoryStore,
362
- jiwaStore,
363
- broadcastAll,
364
- oauthInFlightProviders,
365
- repoPolls,
366
- sessionIdsAt,
367
- busyAt,
368
- }, { id, mode, chatAgent, cwd: sessionCwd, sessionPath });
369
- sessions.set(id, ctx);
370
- log("INFO", "app-sidecar", "session created", {
371
- id,
372
- mode,
373
- chatAgent,
374
- cwd: sessionCwd,
375
- });
424
+ const ctx = await openSession({ mode, chatAgent, cwd: sessionCwd, sessionPath });
376
425
  // The conversation file too, so the app can reopen this exact
377
426
  // session if the daemon restarts (a new session has no path yet
378
427
  // on the app's side).
379
428
  daemonJson(res, 200, {
380
- sessionId: id,
429
+ sessionId: ctx.id,
381
430
  sessionPath: ctx.session.getState().sessionPath ?? null,
382
431
  });
383
432
  }
@@ -392,12 +441,9 @@ async function main() {
392
441
  // Dispose a session: DELETE /session/:id.
393
442
  if (method === "DELETE" && url.startsWith("/session/")) {
394
443
  const id = decodeURIComponent(url.slice("/session/".length));
395
- const ctx = sessions.get(id);
396
- if (ctx) {
397
- sessions.delete(id);
398
- void ctx.dispose().catch(() => { });
399
- log("INFO", "app-sidecar", "session disposed", { id });
400
- }
444
+ // A closing window takes its live preview (and the preview's session) with it.
445
+ void livePreview.onSessionClosed(id);
446
+ void closeSession(id);
401
447
  daemonJson(res, 200, { ok: true });
402
448
  return;
403
449
  }
@@ -472,6 +518,8 @@ async function main() {
472
518
  daemonJson(res, 404, { error: "unknown session" });
473
519
  return;
474
520
  }
521
+ if (handleLivePreviewRoutes(livePreview, ctx, req, res, url, method))
522
+ return;
475
523
  ctx.handle(req, res, url, method);
476
524
  }
477
525
  server.listen(port, host, () => {
@@ -502,6 +550,8 @@ async function main() {
502
550
  keepAwake.dispose();
503
551
  // Close the ~/.ezcoder progress fs.watch handle.
504
552
  progress.dispose();
553
+ // Previews first: they close their own sessions, which then aren't disposed twice.
554
+ await livePreview.stopAll().catch(() => { });
505
555
  await Promise.all([...sessions.values()].map((c) => c.dispose().catch(() => { })));
506
556
  server.close();
507
557
  },
@@ -533,6 +583,8 @@ async function main() {
533
583
  }, 1_000);
534
584
  parentWatch.unref?.();
535
585
  }
586
+ /** Daemon-wide: the last local-model scan result that was logged. */
587
+ let lastLocalScanSummary;
536
588
  /**
537
589
  * Build one in-process agent session: its AgentSession, SSE client set, event
538
590
  * bridge, task runner, auth/login bridge, and the full HTTP route table exposed
@@ -541,7 +593,7 @@ async function main() {
541
593
  * logger, PATH, shared auth file, and radio live at the daemon level.
542
594
  */
543
595
  async function createSession(deps, opts) {
544
- const { auth, progress, trophies, memoryStore, jiwaStore, broadcastAll, oauthInFlightProviders, repoPolls, sessionIdsAt, busyAt, } = deps;
596
+ const { auth, progress, trophies, memoryStore, jiwaStore, broadcastAll, oauthInFlightProviders, repoPolls, sessionIdsAt, busyAt, syncMcpServer, } = deps;
545
597
  const paths = deps.paths;
546
598
  const mode = opts.mode;
547
599
  let chatAgent = opts.chatAgent;
@@ -670,7 +722,12 @@ async function createSession(deps, opts) {
670
722
  // run-all, a scheduled prompt).
671
723
  let scheduledRunActive = false;
672
724
  const asks = createAskUserBridge({
673
- broadcast: (prompt) => broadcast("ask_user", prompt),
725
+ broadcast: (prompt) => {
726
+ broadcast("ask_user", prompt);
727
+ // Code windows only: GG Goals' start card and chat/motion stay with the user.
728
+ if (autopilot && mode !== "chat" && mode !== "motion" && !goal)
729
+ nolanAnswerAsk(prompt);
730
+ },
674
731
  timeoutMs: () => askSoftDeadlineMs(autopilot || autopilotActive || taskRunAll || scheduledRunActive),
675
732
  onTimeout: (prompt) => {
676
733
  log("WARN", "app-sidecar", "ask_user deadline passed; agent proceeding", { id: prompt.id });
@@ -720,6 +777,32 @@ async function createSession(deps, opts) {
720
777
  return;
721
778
  await startGoalFrom({ action: "answer", answers: { message: text } }, []);
722
779
  };
780
+ // Autopilot: Nolan answers a card in the user's place or leaves it to them.
781
+ // The user can still answer first; the first answer wins. A failure only
782
+ // leaves the card with the user, who can still answer, so no error frame.
783
+ const isAskPending = (id) => asks.openPrompts().some((open) => open.prompt.id === id && !open.deferred);
784
+ const nolanAnswerAsk = (prompt) => {
785
+ answerAskWithNolan(prompt, () => isAskPending(prompt.id)).then((reply) => {
786
+ if (!reply)
787
+ return;
788
+ if (reply.kind === "human") {
789
+ if (asks.openIds().includes(prompt.id)) {
790
+ broadcast("ask_user_left", { id: prompt.id, reason: reply.reason });
791
+ }
792
+ return;
793
+ }
794
+ // Past the deadline the agent already moved on: drop Nolan's answer.
795
+ if (!isAskPending(prompt.id))
796
+ return;
797
+ if (asks.settle(prompt.id, { action: "answer", answers: reply.answers, by: "ken" })) {
798
+ log("INFO", "app-sidecar", "ken answered ask_user", { id: prompt.id });
799
+ broadcast("ask_user_answered", { id: prompt.id, answers: reply.answers, by: "ken" });
800
+ }
801
+ }, (err) => log("WARN", "app-sidecar", "ken couldn't answer ask_user", {
802
+ id: prompt.id,
803
+ error: err instanceof Error ? err.message : String(err),
804
+ }));
805
+ };
723
806
  const askUserTool = createAskUserTool(async (request) => {
724
807
  const result = await asks.park(request);
725
808
  await startGoalFrom(result, request.questions);
@@ -761,10 +844,15 @@ async function createSession(deps, opts) {
761
844
  projectDir: cwd,
762
845
  workspaceOnly: true,
763
846
  });
847
+ // GG's own guide is the one built-in skill Chat gets: people ask it how the app works.
848
+ // A workspace skill with the same name still wins.
849
+ const guide = chatSkills.skills.some((s) => s.name === "ez-guide")
850
+ ? undefined
851
+ : await loadBundledSkill("ez-guide");
764
852
  session = createChatAgent(chatAgent, {
765
853
  ...baseSessionOptions,
766
854
  sessionsDir: paths.sessionsDir,
767
- skills: chatSkills.skills,
855
+ skills: guide ? [...chatSkills.skills, guide] : chatSkills.skills,
768
856
  blockedSkills: chatSkills.blocked,
769
857
  additionalTools: [
770
858
  askUserTool,
@@ -812,9 +900,12 @@ async function createSession(deps, opts) {
812
900
  });
813
901
  }
814
902
  else {
903
+ const startLivePreview = deps.livePreview;
815
904
  session = new AgentSession({
816
905
  ...baseSessionOptions,
817
- additionalTools: [askUserTool],
906
+ additionalTools: startLivePreview
907
+ ? [askUserTool, createLivePreviewTool((url) => startLivePreview(opts.id, url))]
908
+ : [askUserTool],
818
909
  // A run must not end mid-plan with nothing submitted: nobody could review it.
819
910
  planSubmissionGate: true,
820
911
  // Plan mode belongs only to the coding agent.
@@ -938,10 +1029,13 @@ async function createSession(deps, opts) {
938
1029
  await syncEndpointCredentials(probes.filter((probe) => probe.reachable).map((probe) => probe.endpoint));
939
1030
  clearRuntimeModels((m) => m.provider === "local");
940
1031
  registerRuntimeModels(models);
941
- log("INFO", "app-sidecar", "local model scan", {
942
- reachable: probes.filter((p) => p.reachable).length + "/" + probes.length,
943
- models: String(models.length),
944
- });
1032
+ const reachable = probes.filter((p) => p.reachable).length + "/" + probes.length;
1033
+ // Every window re-scans; only a changed result is news.
1034
+ const summary = `${reachable} ${models.length}`;
1035
+ if (summary !== lastLocalScanSummary) {
1036
+ lastLocalScanSummary = summary;
1037
+ log("INFO", "app-sidecar", "local model scan", { reachable, models: String(models.length) });
1038
+ }
945
1039
  return probes;
946
1040
  }
947
1041
  /** Endpoint rows + models, in the shape the Local models UI renders. */
@@ -1843,7 +1937,7 @@ async function createSession(deps, opts) {
1843
1937
  // approve a plan, so tasks implement directly instead of hanging on review.
1844
1938
  let taskRunActive = false;
1845
1939
  // Moved to app-sidecar/autopilot-runner.ts
1846
- const { runAutopilotCycle, runStrandedQueue, runTasks } = createAutopilotRunner({
1940
+ const { answerAskWithNolan, runAutopilotCycle, runStrandedQueue, runTasks } = createAutopilotRunner({
1847
1941
  get taskRunActive() {
1848
1942
  return taskRunActive;
1849
1943
  },
@@ -2000,6 +2094,9 @@ async function createSession(deps, opts) {
2000
2094
  set taskRunAll(v) {
2001
2095
  taskRunAll = v;
2002
2096
  },
2097
+ get runClaim() {
2098
+ return runClaim;
2099
+ },
2003
2100
  });
2004
2101
  // ── Idle wake for background alerts ────────────────────────
2005
2102
  // A background task that fails, or a child agent that finishes, after the
@@ -2298,6 +2395,7 @@ async function createSession(deps, opts) {
2298
2395
  sessionId: opts.id,
2299
2396
  sessionIdsAt,
2300
2397
  busyAt,
2398
+ syncMcpServer,
2301
2399
  get goal() {
2302
2400
  return goal;
2303
2401
  },