@turri-dev/cli 0.4.3-next.8482fed → 0.4.3-next.a60ada5

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.
@@ -13,8 +13,14 @@ export type TabAction = {
13
13
  };
14
14
  /** Shared by ×, /chat close and alt+w. The last person's chat stays open even if the sentinel has its own tab. */
15
15
  export declare function closeTerminalChat(session: TurriCore, id: string): Promise<void>;
16
+ interface PanelState {
17
+ notifications: number;
18
+ open: boolean;
19
+ busy: boolean;
20
+ }
16
21
  export interface ChatTabs extends Component {
17
22
  pointer: PointerHover;
18
23
  }
19
24
  /** Mouse positions, like the layout, are in terminal cells, not string offsets. */
20
- export declare function chatTabs(chats: () => ChatInfo[], style: ButtonPaint, pick: (action: TabAction) => void): ChatTabs;
25
+ export declare function chatTabs(chats: () => ChatInfo[], style: ButtonPaint, pick: (action: TabAction) => void, panel?: () => PanelState): ChatTabs;
26
+ export {};
package/dist/chat-tabs.js CHANGED
@@ -22,11 +22,15 @@ export async function closeTerminalChat(session, id) {
22
22
  return session.notify("This is the only chat - /quit leaves turri.", "info");
23
23
  await session.close(id);
24
24
  }
25
- function layout(chats, width) {
25
+ function layout(chats, width, state) {
26
26
  if (width <= 0)
27
27
  return [];
28
28
  // Keep the panel button at the right edge while chat titles grow and shrink on the left.
29
- const panel = width >= 30 ? " ***plain › " : width >= 14 ? " ***plain " : width >= 6 ? "≡" : "";
29
+ const pending = state?.notifications ?? 0;
30
+ const badge = pending && width >= 30 ? ` · ${pending > 99 ? "99+" : pending}` : "";
31
+ const arrow = state?.open ? "‹" : "›";
32
+ const spin = state?.busy ? spinner(Date.now()) : "";
33
+ const panel = width >= 24 ? ` ${spin && `${spin} `}***plain${badge} ${arrow} ` : width >= 14 ? `${spin}***plain ${arrow}` : width >= 6 ? `${spin}${arrow}` : "";
30
34
  const panelWidth = visibleWidth(panel);
31
35
  const chatWidth = width - (panel ? panelWidth + 1 : 0);
32
36
  // Reserve + and a close target per tab before spending cells on padding, gaps and titles.
@@ -51,17 +55,17 @@ function layout(chats, width) {
51
55
  parts.push({ text: plus, action: { kind: "open" } });
52
56
  if (panel) {
53
57
  const used = parts.reduce((cells, part) => cells + visibleWidth(part.text), 0);
54
- parts.push({ text: " ".repeat(width - used - panelWidth) }, { text: panel, action: { kind: "plain" } });
58
+ parts.push({ text: " ".repeat(width - used - panelWidth) }, { text: panel, action: { kind: "plain" }, role: state?.busy ? "regenerating" : "panel" });
55
59
  }
56
60
  return parts;
57
61
  }
58
62
  /** Mouse positions, like the layout, are in terminal cells, not string offsets. */
59
- export function chatTabs(chats, style, pick) {
63
+ export function chatTabs(chats, style, pick, panel) {
60
64
  let pressed;
61
65
  return {
62
66
  pointer: new PointerHover(),
63
67
  render(width) {
64
- return [layout(chats(), width).map((part) => part.action ? style(part.text, part.shown === true, this.pointer.target === buttonKey(part.action), buttonRole[part.action.kind]) : part.text).join("")];
68
+ return [layout(chats(), width, panel?.()).map((part) => part.action ? style(part.text, part.shown === true, this.pointer.target === buttonKey(part.action), part.role ?? buttonRole[part.action.kind]) : part.text).join("")];
65
69
  },
66
70
  handleMouse(event) {
67
71
  const move = event.type === "move";
@@ -71,7 +75,7 @@ export function chatTabs(chats, style, pick) {
71
75
  if (!move)
72
76
  pressed = undefined;
73
77
  let x = 0;
74
- for (const part of layout(chats(), event.width)) {
78
+ for (const part of layout(chats(), event.width, panel?.())) {
75
79
  const end = x + visibleWidth(part.text);
76
80
  if (event.x >= x && event.x < end && part.action) {
77
81
  const key = buttonKey(part.action);
@@ -70,10 +70,13 @@ export function driveTerminal(core, options = {}) {
70
70
  if (switching || runtime === undefined)
71
71
  return;
72
72
  if (action.kind === "plain")
73
- return core.shownChat()?.instance?.openPlainPanel?.();
73
+ return core.shownChat()?.instance?.plainPanel?.toggle();
74
74
  switching = true;
75
75
  const change = action.kind === "open" ? core.open() : action.kind === "close" ? closeTerminalChat(core, action.id) : core.show(action.id);
76
76
  void change.catch((error) => core.notify(error instanceof Error ? error.message : String(error), "warning")).finally(() => { switching = false; });
77
+ }, () => {
78
+ const panel = core.shownChat()?.instance?.plainPanel;
79
+ return { notifications: core.notifications.count, open: panel?.open() === true, busy: panel?.busy() === true };
77
80
  });
78
81
  const header = chatTabHeader(tabs);
79
82
  const addEntry = prototype.addCustomEntryToChat;
@@ -90,7 +93,7 @@ export function driveTerminal(core, options = {}) {
90
93
  const unwatch = header.watch(this, tui);
91
94
  let ticker;
92
95
  const refresh = () => {
93
- if (core.chats().some((chat) => chat.status === "working")) {
96
+ if (core.shownChat()?.instance?.plainPanel?.busy() || core.chats().some((chat) => chat.status === "working")) {
94
97
  ticker ??= setInterval(() => tui.requestRender(), 250).unref();
95
98
  }
96
99
  else {
package/dist/chats.d.ts CHANGED
@@ -2,9 +2,10 @@ import type { AgentSession, ExtensionAPI, ExtensionContext, ExtensionFactory, Ex
2
2
  import { type ChatScope } from "./chat-scope.ts";
3
3
  import { type RunRecord } from "./chat-records.ts";
4
4
  import { type ChatUi } from "./chat-ui.ts";
5
+ import { TerminalNotifications } from "./terminal-notifications.ts";
5
6
  import { type SentinelSetting } from "./config.ts";
6
7
  import type { AskUserIO } from "./ask.ts";
7
- import type { Job, JobRegistry } from "./regenerate/jobs.ts";
8
+ import { type Job, type JobRegistry } from "./regenerate/jobs.ts";
8
9
  import type { Launch } from "./launch-track.ts";
9
10
  import type { ToolDefinition } from "@earendil-works/pi-coding-agent";
10
11
  import { type ChatRole, type Conclusion, type Notice, type NoticeAnswer, type NoticeInput, type SentinelCheck } from "./notice.ts";
@@ -77,7 +78,7 @@ export interface TurriHost {
77
78
  * The host shows the person each pulse that lands and each of the sentinel's conclusions itself - its own
78
79
  * notifications, from onJobChange and onConcluded. With the sentinel on, the chat the person is in is then told of both
79
80
  * without a turn of its own: its agent knows what landed and what the sentinel found when the person asks, and does
80
- * not say it again in the conversation. Unset, it says both, as in the terminal.
81
+ * not say it again in the conversation. Unset in a host, it says both.
81
82
  */
82
83
  pulseEndsShown?: boolean;
83
84
  /**
@@ -102,8 +103,12 @@ export interface TurriHost {
102
103
  }
103
104
  /** What a chat's extension does for its chat when the session asks. */
104
105
  export interface ChatInstance {
105
- /** The terminal header's button: open the project's spec map beside this chat. */
106
- openPlainPanel?(): void;
106
+ /** The terminal header's toggle. Visibility is independent of which side has the keys. */
107
+ plainPanel?: {
108
+ open(): boolean;
109
+ busy(): boolean;
110
+ toggle(): void;
111
+ };
107
112
  /** A pulse it asked for ended: said in the chat, and its agent told, to react to it. */
108
113
  announce(job: Job): void;
109
114
  /**
@@ -141,8 +146,6 @@ export interface ChatInstance {
141
146
  concluded(conclusion: Conclusion): void;
142
147
  /** The person answered a notice with something to do: the chat's agent started on it. */
143
148
  act(task: string): void;
144
- /** The jobs changed: what it draws of them is drawn again. */
145
- jobsChanged(): void;
146
149
  /** How hard the chat's model thinks now: sub-agents started from it think as hard. */
147
150
  thinkingLevel(): string | undefined;
148
151
  /** The chat's context, as its tools get it - for its model and its providers. */
@@ -191,6 +194,8 @@ export interface ChatState {
191
194
  unsubscribe?: () => void;
192
195
  }
193
196
  export interface TurriCore {
197
+ /** Shared by all the terminal's chats. */
198
+ readonly notifications: TerminalNotifications;
194
199
  readonly cwd: string;
195
200
  readonly host: TurriHost;
196
201
  readonly jobs: JobRegistry;
@@ -269,8 +274,6 @@ export interface TurriCore {
269
274
  * `refused`: `ignore` on one that is not ignorable.
270
275
  */
271
276
  answer(id: string, answer: NoticeAnswer): "done" | "dismissed" | "ignored" | "refused" | "missing" | "over";
272
- /** For the extension: the jobs changed - every chat draws them again. */
273
- jobsChanged(): void;
274
277
  /** The chat whose work this is, else the one shown: its instance. */
275
278
  instanceInScope(): ChatInstance | undefined;
276
279
  setDriver(driver: ChatDriver): void;
package/dist/chats.js CHANGED
@@ -3,8 +3,10 @@ import { existsSync } from "node:fs";
3
3
  import { currentChat, inChat } from "./chat-scope.js";
4
4
  import { adoptRun, forgetChat, forgetSessionFile, recordRun } from "./chat-records.js";
5
5
  import { createChatUi } from "./chat-ui.js";
6
+ import { TerminalNotifications } from "./terminal-notifications.js";
6
7
  import { debugMode } from "./config.js";
7
8
  import { firstLine, record } from "./regenerate/ledger.js";
9
+ import { pulseName, formatDuration } from "./regenerate/jobs.js";
8
10
  import { newNotice, noticeTask, SENTINEL, sentinelStartChoice, wentWrong } from "./notice.js";
9
11
  /**
10
12
  * The chats of a turri session.
@@ -204,6 +206,7 @@ export function createChats(options) {
204
206
  });
205
207
  };
206
208
  const core = {
209
+ notifications: new TerminalNotifications(),
207
210
  cwd,
208
211
  host,
209
212
  jobs,
@@ -385,6 +388,11 @@ export function createChats(options) {
385
388
  },
386
389
  sentinelOn: () => driver !== undefined && wantsSentinel(),
387
390
  jobFinished(job) {
391
+ if (core.terminal) {
392
+ const result = job.status === "succeeded" ? wentWrong(job) ? "did not pass" : "finished" : job.status;
393
+ core.notifications.add(`${pulseName(job)} · ${result} after ${formatDuration(job)}`, job.error ?? job.report ?? job.note ?? "");
394
+ changed();
395
+ }
388
396
  // The question was settled in config.turri.yaml while it was open: what it held goes as the file now says.
389
397
  if (consent === "asking" && setting() !== "ask")
390
398
  settleStart(setting() === true ? "given" : "declined", "superseded");
@@ -451,16 +459,6 @@ export function createChats(options) {
451
459
  sentinelChecks(check);
452
460
  return { check: check.id };
453
461
  },
454
- jobsChanged() {
455
- for (const chat of chats) {
456
- try {
457
- chat.instance?.jobsChanged();
458
- }
459
- catch {
460
- /* a chat let go draws nothing */
461
- }
462
- }
463
- },
464
462
  notice(input) {
465
463
  // A check's notice is about its module.
466
464
  const about = input.check !== undefined ? checks.get(input.check) : undefined;
@@ -479,7 +477,13 @@ export function createChats(options) {
479
477
  const { ignorable, ...rest } = input;
480
478
  const notice = newNotice(ignorable === true && input.kind === undefined ? input : rest, target.id);
481
479
  open.push(notice);
482
- if (target.id !== shownId)
480
+ if (core.terminal) {
481
+ // notify_person may omit the id; the sentinel still has exactly one review in progress.
482
+ const work = checking?.work;
483
+ const about = work && currentChat()?.id === sentinelChat()?.id ? ("pulse" in work ? { job: work.pulse.id } : { check: work.check.id }) : undefined;
484
+ core.notifications.put(notice, about);
485
+ }
486
+ else if (target.id !== shownId)
483
487
  target.unread = true;
484
488
  inChat(target.scope, () => record({ kind: "notice.put", notice: notice.id, severity: notice.severity, ...(notice.module !== undefined ? { module: notice.module } : {}) }, { project: cwd }));
485
489
  try {
@@ -511,7 +515,9 @@ export function createChats(options) {
511
515
  const module = conclusion.module ?? job?.module ?? check?.module;
512
516
  const pulse = conclusion.pulse ?? job?.pulse;
513
517
  const told = { ...conclusion, ...(module !== undefined ? { module } : {}), ...(pulse !== undefined ? { pulse } : {}) };
514
- if (target.id !== shownId)
518
+ if (core.terminal)
519
+ core.notifications.concluded(told);
520
+ else if (target.id !== shownId)
515
521
  target.unread = true;
516
522
  inChat(target.scope, () => record({ kind: "sentinel.concluded", verdict: told.verdict, ...(module !== undefined ? { module } : {}), ...(told.check !== undefined ? { check: told.check } : {}) }, { project: cwd, ...(told.job !== undefined ? { job: told.job } : {}) }));
517
523
  try {
@@ -543,7 +549,7 @@ export function createChats(options) {
543
549
  options.ignored?.(notice);
544
550
  }
545
551
  catch (error) {
546
- core.notify(`The sentinel's guidance could not be written: ${error instanceof Error ? error.message : String(error)}`, "warning");
552
+ sentinelMessage(`The sentinel's guidance could not be written: ${error instanceof Error ? error.message : String(error)}`, "warning");
547
553
  }
548
554
  over(notice, "ignored");
549
555
  return "ignored";
@@ -603,6 +609,8 @@ export function createChats(options) {
603
609
  }
604
610
  if (chat !== undefined)
605
611
  inChat(chat.scope, () => record({ kind: "notice.over", notice: notice.id, state }, { project: cwd }));
612
+ if (core.terminal)
613
+ changed();
606
614
  }
607
615
  /** A pulse ended, told to the chat that asked for it - as without a sentinel - or the chat shown, when that one is closed. */
608
616
  function toAsker(job) {
@@ -704,7 +712,7 @@ export function createChats(options) {
704
712
  const asked = chats.find((chat) => chat.id === job.chat && chat.role !== SENTINEL);
705
713
  const where = personFacing(asked);
706
714
  if (where !== undefined) {
707
- if (where.id !== shownId)
715
+ if (where.id !== shownId && !core.terminal)
708
716
  where.unread = true;
709
717
  try {
710
718
  where.instance?.landed(job, { tell: !wentWrong(job) });
@@ -739,7 +747,7 @@ export function createChats(options) {
739
747
  }
740
748
  catch (error) {
741
749
  const why = error instanceof Error ? error.message : String(error);
742
- core.notify(`The sentinel could not be opened: ${why}`, "warning");
750
+ sentinelMessage(`The sentinel could not be opened: ${why}`, "warning");
743
751
  failed(why);
744
752
  return undefined;
745
753
  }
@@ -750,10 +758,16 @@ export function createChats(options) {
750
758
  function unchecked(check, why) {
751
759
  core.concluded({ check: check.id, module: check.module, verdict: "unchecked", summary: `Not checked: ${why}.` });
752
760
  }
761
+ function sentinelMessage(message, level) {
762
+ if (!core.terminal)
763
+ return core.notify(message, level);
764
+ core.notifications.add(message, "");
765
+ changed();
766
+ }
753
767
  /** The sentinel's work, after what it was given before. */
754
768
  function toSentinel(work) {
755
769
  sentinelWork = sentinelWork.then(work).catch((error) => {
756
- core.notify(`The sentinel: ${error instanceof Error ? error.message : String(error)}`, "warning");
770
+ sentinelMessage(`The sentinel: ${error instanceof Error ? error.message : String(error)}`, "warning");
757
771
  });
758
772
  }
759
773
  /**
@@ -788,7 +802,7 @@ export function createChats(options) {
788
802
  async function refuse(sentinel, work, why) {
789
803
  const module = codebaseOf(work);
790
804
  inChat(sentinel.scope, () => record({ kind: "sentinel.refused", ...(module !== undefined ? { module } : {}), ...("check" in work ? { check: work.check.id } : {}), why: firstLine(why, 300) }, { project: cwd, ...("pulse" in work ? { job: work.pulse.id } : {}) }));
791
- if ("pulse" in work)
805
+ if ("pulse" in work && !core.terminal)
792
806
  core.notify(`The sentinel cannot check pulse ${work.pulse.id}: ${why}`, "error");
793
807
  core.concluded({
794
808
  ...("pulse" in work ? { job: work.pulse.id } : { check: work.check.id }),
@@ -823,7 +837,7 @@ export function createChats(options) {
823
837
  await sentinel.instance.briefCheck(check, where !== undefined ? { focused: titleFor(where) } : {});
824
838
  }
825
839
  catch (error) {
826
- core.notify(`The sentinel could not be told of check ${check.id}: ${error instanceof Error ? error.message : String(error)}`, "warning");
840
+ sentinelMessage(`The sentinel could not be told of check ${check.id}: ${error instanceof Error ? error.message : String(error)}`, "warning");
827
841
  checking = undefined;
828
842
  }
829
843
  changed();
@@ -856,7 +870,7 @@ export function createChats(options) {
856
870
  });
857
871
  }
858
872
  catch (error) {
859
- core.notify(`The sentinel could not be told of ${job.id}: ${error instanceof Error ? error.message : String(error)}`, "warning");
873
+ sentinelMessage(`The sentinel could not be told of ${job.id}: ${error instanceof Error ? error.message : String(error)}`, "warning");
860
874
  checking = undefined;
861
875
  }
862
876
  changed();
@@ -933,7 +947,7 @@ export function createChats(options) {
933
947
  catch (error) {
934
948
  Object.assign(chat, old);
935
949
  follow(chat);
936
- core.notify(`The sentinel goes on in the conversation it had - a new one could not be started: ${error instanceof Error ? error.message : String(error)}`, "warning");
950
+ sentinelMessage(`The sentinel goes on in the conversation it had - a new one could not be started: ${error instanceof Error ? error.message : String(error)}`, "warning");
937
951
  return;
938
952
  }
939
953
  const fresh = chat.session;
@@ -162,6 +162,7 @@ export { fromWorkingDir };
162
162
  */
163
163
  export declare function pulseEndNote(job: Job, options?: {
164
164
  launching?: boolean;
165
+ quiet?: boolean;
165
166
  }): string;
166
167
  /**
167
168
  * What the agent is to do with a job that just ended, unasked: what the project's guidance says to do then, or else say
package/dist/extension.js CHANGED
@@ -48,7 +48,7 @@ import { didNotLand } from "./regenerate/failure-reports.js";
48
48
  import { conformanceRefusal, createWorkLoop, TestingStepsMissing, describeModules, isUpToDate } from "./regenerate/loop.js";
49
49
  import { brandNeon, brandPink, plainPaint } from "./regenerate/plain-palette.js";
50
50
  import { halfBlocks, JELLYFISH_FRAME_MS, JELLYFISH_REST, JELLYFISH_SEQUENCE, JELLYFISH_TEXT_FRAMES } from "./jellyfish.js";
51
- import { createJobPanel, didNotPass, keyPressed, PANEL_KEY, spinner } from "./regenerate/job-panel.js";
51
+ import { didNotPass, PANEL_KEY, spinner } from "./regenerate/job-panel.js";
52
52
  import { clickToFocus, dockedWidth, narrowChat, shade, shadeChat } from "./regenerate/panel-dock.js";
53
53
  import { overPictureRow, PICTURE_AT } from "./picture-row.js";
54
54
  import { padScreen, paddedColumns, paddedRows, SCREEN_PADDING } from "./screen-padding.js";
@@ -56,6 +56,7 @@ import { skillAboutLine, skillProgressLine } from "./skill-progress.js";
56
56
  import { createSidePanel } from "./regenerate/side-panel.js";
57
57
  import { createSpecMapSource, defaultMapFiles } from "./regenerate/spec-map.js";
58
58
  import { createSpecMapState } from "./regenerate/spec-map-view.js";
59
+ import { notificationView } from "./terminal-notifications.js";
59
60
  import { createJobsTreeState, selectJob } from "./regenerate/jobs-tree.js";
60
61
  import { describeDiagnosis, diagnoseFailure } from "./regenerate/diagnose.js";
61
62
  import { HISTORY_DIR, historyLog } from "./regenerate/lineage.js";
@@ -301,12 +302,29 @@ export function createTurriCore(host = {}, options = {}) {
301
302
  // The AWS region the project's Bedrock models need, before any model is called - a host has no shell to export it in.
302
303
  applyBedrockRegion(cwd);
303
304
  let core;
305
+ // One activity light for every chat. Only plan changes need to read the plan; streaming job updates do not.
306
+ let planning = false;
307
+ const running = new Set();
308
+ const busy = () => planning || running.size > 0;
309
+ const updateActivity = (job) => {
310
+ if (!core?.terminal)
311
+ return;
312
+ const before = busy();
313
+ if (!job)
314
+ planning = workLoops.get(jobs)?.loop.planned().some((row) => row.planning !== undefined) ?? false;
315
+ else if (job.status === "running" && (job.kind === "regenerate" || job.kind === "conformance"))
316
+ running.add(job.id);
317
+ else
318
+ running.delete(job.id);
319
+ if (busy() !== before)
320
+ core.changed();
321
+ };
304
322
  // Finished work is announced twice, to two audiences, because pi treats them differently - see ChatInstance.announce:
305
323
  // in the chat that asked for it, or the one shown when that is closed.
306
324
  const jobs = createJobRegistry({
307
- // The loop's plan changed - a module being planned, or planned: the live panel shows it at once.
325
+ // The planner can be at work before the registry has its first pulse.
308
326
  onNotify: () => {
309
- core?.jobsChanged();
327
+ updateActivity();
310
328
  host.onPlanChange?.();
311
329
  },
312
330
  // A job that fails is run once more; failing again, it and every job behind it fail, and the
@@ -328,16 +346,16 @@ export function createTurriCore(host = {}, options = {}) {
328
346
  return diagnosis !== undefined ? describeDiagnosis(diagnosis) : undefined;
329
347
  },
330
348
  onChange: (job) => {
331
- core?.jobsChanged();
349
+ updateActivity(job);
332
350
  host.onJobChange?.(job);
333
351
  },
334
352
  onFinish: (job) => {
335
- core?.jobsChanged();
353
+ updateActivity(job);
336
354
  host.onJobChange?.(job);
337
355
  // Queued again as another job: that one says how it went.
338
356
  if (job.replacedBy !== undefined)
339
357
  return;
340
- // Gone wrong: the next ctrl+h opens on it - the live panel that showed it is gone with the last pulse.
358
+ // Gone wrong: the next ctrl+h opens on it.
341
359
  if (job.status === "failed" || job.status === "stopped" || didNotPass(job))
342
360
  needsLooking.set(jobs, job.id);
343
361
  core?.jobFinished(job);
@@ -350,7 +368,6 @@ export function createTurriCore(host = {}, options = {}) {
350
368
  jobs,
351
369
  model: (plainFile) => launchModel(workLoops.get(jobs)?.from.ctx, plainFile),
352
370
  onChange: (launch) => {
353
- core?.jobsChanged();
354
371
  try {
355
372
  host.onLaunch?.(launch);
356
373
  }
@@ -366,7 +383,7 @@ export function createTurriCore(host = {}, options = {}) {
366
383
  launches,
367
384
  host,
368
385
  jobs,
369
- extension: (pi, link) => turriExtension(pi, core, link),
386
+ extension: (pi, link) => turriExtension(pi, core, link, busy),
370
387
  // A finished pulse goes to the sentinel when the project wants one - read as each pulse finishes - the person asked
371
388
  // first under `sentinel: ask`, and what they choose for the project written.
372
389
  sentinel: () => sentinelSetting(cwd),
@@ -434,7 +451,7 @@ export function sessionLoop(session) {
434
451
  * turri's extension, built into one chat of the session: its tools, commands and handlers run in the chat's scope -
435
452
  * its id on the pulses it asks for - on the session's job registry and work loop.
436
453
  */
437
- function turriExtension(api, session, link) {
454
+ function turriExtension(api, session, link, busy) {
438
455
  const pi = scopedToChat(api, link.scope);
439
456
  const { cwd, host, jobs } = session;
440
457
  // The session's sentinel: its own prompt and tools - the project to read, notices, its guidance - and nothing that
@@ -449,8 +466,6 @@ function turriExtension(api, session, link) {
449
466
  const dialogs = link.dialogs ?? host.dialogs;
450
467
  // turri's own skills, and the project's - .turri/skills, .agents/skills (skills.ts).
451
468
  const discoveredSkills = discoverSkills(PACKAGE_ROOT, cwd);
452
- // What the background work is doing right now, drawn above the editor while it runs.
453
- const panel = createJobPanel(() => shownJobs(jobs));
454
469
  // The chat's context, as its tools and handlers were last given it: for its model and its providers.
455
470
  let lastContext;
456
471
  const contextNow = () => {
@@ -471,7 +486,8 @@ function turriExtension(api, session, link) {
471
486
  // does what the project's guidance says to do then (launch what was built, say), or says
472
487
  // what finished. In the chat that asked for the pulse, shown or not.
473
488
  const announce = (job) => {
474
- announceJob(pi, job);
489
+ if (!session.terminal)
490
+ announceJob(pi, job);
475
491
  // A pulse a call of this chat waits for is told in that call's reply: a turn of its own would say it again.
476
492
  if (toldByWaitingCall(jobs, job) && job.specConflict === undefined)
477
493
  return;
@@ -487,12 +503,13 @@ function turriExtension(api, session, link) {
487
503
  catch {
488
504
  /* a config that cannot be read launches nothing */
489
505
  }
506
+ const quiet = session.terminal && job.status === "succeeded" && !didNotPass(job);
490
507
  void pi.sendMessage({
491
508
  customType: "turri_job",
492
- content: pulseEndNote(job, { launching }),
509
+ content: pulseEndNote(job, { launching, quiet }),
493
510
  display: false,
494
511
  details: { jobId: job.id, status: job.status },
495
- }, { triggerTurn: true, deliverAs: "followUp" });
512
+ }, quiet ? { triggerTurn: false } : { triggerTurn: true, deliverAs: "followUp" });
496
513
  };
497
514
  // The sentinel's: what a pulse that ended is, told to its agent in a conversation of its own for the pulse. The hidden
498
515
  // message is the conversation's first entry - a host splits the sentinel's work by pulse on it - so the pulse's end is
@@ -537,13 +554,14 @@ function turriExtension(api, session, link) {
537
554
  // it landed and what the sentinel does with it - and nothing more: the pulse is the sentinel's. ***plain that
538
555
  // contradicts itself is put to the person at once, by turri itself, as the chat would have been started on it.
539
556
  const landed = (job, options = {}) => {
540
- announceJob(pi, job);
557
+ if (!session.terminal)
558
+ announceJob(pi, job);
541
559
  if (job.specConflict !== undefined)
542
560
  session.notice(specConflictNotice(job, specConflictTask(job.specConflict)));
543
561
  if (options.tell !== true || toldByWaitingCall(jobs, job))
544
562
  return;
545
563
  // A host that shows the person the pulse's end itself: the chat knows of it - in order, with no turn of its own.
546
- const shown = host.pulseEndsShown === true;
564
+ const shown = session.terminal || host.pulseEndsShown === true;
547
565
  let launching = false;
548
566
  try {
549
567
  launching = readProjectConfig(cwd, job.configModule).launchAfterPulse === true;
@@ -555,10 +573,17 @@ function turriExtension(api, session, link) {
555
573
  };
556
574
  const notices = noticeDialogs(pi, session, link, contextNow);
557
575
  link.live({
558
- openPlainPanel: () => {
559
- const ctx = contextNow();
560
- if (ctx?.hasUI)
561
- sidePanelOf(jobs, cwd).open(ctx, "map", "beside");
576
+ plainPanel: {
577
+ busy,
578
+ open: () => sidePanelOf(session).visible(),
579
+ toggle: () => {
580
+ const panel = sidePanelOf(session);
581
+ if (panel.visible())
582
+ return panel.close();
583
+ const ctx = contextNow();
584
+ if (ctx?.hasUI)
585
+ panel.open(ctx, "map", "beside");
586
+ },
562
587
  },
563
588
  announce,
564
589
  landed,
@@ -572,7 +597,6 @@ function turriExtension(api, session, link) {
572
597
  act: (task) => {
573
598
  void pi.sendMessage({ customType: "turri_notice_answer", content: task, display: false }, { triggerTurn: true, deliverAs: "followUp" });
574
599
  },
575
- jobsChanged: () => panel.refresh(),
576
600
  thinkingLevel: () => pi.getThinkingLevel(),
577
601
  context: contextNow,
578
602
  });
@@ -625,7 +649,7 @@ function turriExtension(api, session, link) {
625
649
  TOOLS_NOT_CLI,
626
650
  NEW_PROJECT,
627
651
  CAPTURE_HINT,
628
- pulseEndsBlock(session.sentinelOn()),
652
+ pulseEndsBlock(session.sentinelOn(), session.terminal),
629
653
  // Conformance tests - what they are, whether they are on here, and how they are turned on: every turn, read afresh.
630
654
  conformanceBlock(conformanceTestsOnIn(cwd)),
631
655
  projectConfigBlock(cwd),
@@ -717,31 +741,9 @@ function turriExtension(api, session, link) {
717
741
  };
718
742
  pi.on("agent_end", endTurnCapture);
719
743
  pi.on("agent_settled", endTurnCapture);
720
- pi.on("session_start", (_event, ctx) => {
721
- if (!ctx.hasUI)
722
- return;
723
- panel.attach({
724
- setWidget: (key, content, options) => {
725
- try {
726
- ctx.ui.setWidget(key, content, options);
727
- }
728
- catch {
729
- /* rebuilt by pi since: its new extension draws the panel */
730
- }
731
- },
732
- getToolsExpanded: () => {
733
- try {
734
- return ctx.ui.getToolsExpanded();
735
- }
736
- catch {
737
- return false;
738
- }
739
- },
740
- });
741
- });
742
744
  registerBranding(pi, discoveredSkills);
743
745
  registerInterviewLog(pi);
744
- registerJobTools(pi, jobs, cwd);
746
+ registerJobTools(pi, session);
745
747
  // The skills the person starts themselves - a project's, marked command-only: each has its command, and cultivate starts it only
746
748
  // once its command is typed, or picked among the options the conversation offers with ask_user.
747
749
  const gate = createCommandGate();
@@ -2001,7 +2003,8 @@ const needsLooking = new WeakMap();
2001
2003
  /** What heads a pulse told from the ledger: it is not this session's, and the facts are all there is of it. */
2002
2004
  const pastPulseNote = "A pulse of an earlier session, as the ledger recorded it - facts, not its transcript. Its whole log is the file it names, " +
2003
2005
  "for the read tool.";
2004
- function registerJobTools(pi, jobs, cwd) {
2006
+ function registerJobTools(pi, session) {
2007
+ const { jobs, cwd } = session;
2005
2008
  pi.registerTool(doctorTool({ cwd }));
2006
2009
  pi.registerTool({
2007
2010
  name: "pulses",
@@ -2082,8 +2085,6 @@ function registerJobTools(pi, jobs, cwd) {
2082
2085
  return { content: [{ type: "text", text }], details: { status: job.status } };
2083
2086
  },
2084
2087
  });
2085
- // The panel is compact and ctrl+o only lasts as long as the work does. This is the whole
2086
- // list, finished jobs included, put in the transcript where it stays.
2087
2088
  pi.registerCommand("halt", {
2088
2089
  description: "Halt a queued or running pulse, a module's planned pulses, a launch, or what a launch started: /halt [pulse id | module | launched <name | module>]",
2089
2090
  handler: async (args, ctx) => {
@@ -2161,8 +2162,14 @@ function registerJobTools(pi, jobs, cwd) {
2161
2162
  // While the panel has the keys, every key is its own.
2162
2163
  // The side panel is the session's, one for every chat: it stays on the screen - beside the chat or over it - as
2163
2164
  // another chat is shown, and what it says to a chat it says to the one shown.
2164
- const sidePanel = sidePanelOf(jobs, cwd);
2165
+ const sidePanel = sidePanelOf(session);
2165
2166
  const openPanel = sidePanel.open;
2167
+ if (session.terminal)
2168
+ pi.registerCommand("notifications", {
2169
+ description: "Open the side panel on finished pulses and sentinel notices",
2170
+ handler: async (_args, ctx) => { if (ctx.hasUI)
2171
+ openPanel(ctx, "notifications", "beside"); },
2172
+ });
2166
2173
  pi.on("session_start", () => {
2167
2174
  sidePanel.say = (text) => pi.sendUserMessage(text, { deliverAs: "followUp" });
2168
2175
  });
@@ -2249,6 +2256,8 @@ export function pulseEndNote(job, options = {}) {
2249
2256
  : job.status === "stopped"
2250
2257
  ? `Pulse ${job.id} (${job.kind}) was stopped after ${formatDuration(job)}. ${job.error ?? STOPPED_ON_REQUEST}${job.error === undefined || job.error === STOPPED_ON_REQUEST ? " The person stopped it; what it was building counts as not built." : ""}`
2251
2258
  : `Pulse ${job.id} (${job.kind}) failed after ${formatDuration(job)}.\n\n${job.error ?? ""}`;
2259
+ if (options.quiet)
2260
+ return `${head}\n\nThis result is in notifications. It needs no announcement in the chat.`;
2252
2261
  const landed = job.status === "succeeded" && job.details?.landed === true;
2253
2262
  if (!landed || options.launching !== true)
2254
2263
  return `${head}\n\n${JOB_FINISHED_REACTION}`;
@@ -2296,12 +2305,15 @@ export const JOB_FINISHED_REACTION = [
2296
2305
  ].join("\n");
2297
2306
  const sidePanels = new WeakMap();
2298
2307
  /** The side panel of the session these jobs are, made as a chat first asks for it. */
2299
- function sidePanelOf(jobs, cwd) {
2308
+ function sidePanelOf(session) {
2309
+ const { jobs, cwd } = session;
2300
2310
  const known = sidePanels.get(jobs);
2301
2311
  if (known !== undefined)
2302
2312
  return known;
2303
2313
  const self = {
2304
2314
  open: (ctx, view, placement) => openPanel(ctx, view, placement),
2315
+ visible: () => panel !== undefined && panel.handle?.isHidden() !== true,
2316
+ close: () => panel?.close(),
2305
2317
  shown: () => panel !== undefined && panel.keys,
2306
2318
  };
2307
2319
  sidePanels.set(jobs, self);
@@ -2340,8 +2352,6 @@ function sidePanelOf(jobs, cwd) {
2340
2352
  });
2341
2353
  /** Open the side panel - on the view named, or as it was left. */
2342
2354
  const openPanel = (ctx, view, placement) => {
2343
- // Found: ctrl+h under the job panel stops breathing.
2344
- keyPressed("peek");
2345
2355
  if (view !== undefined)
2346
2356
  mapState.view = view;
2347
2357
  // A pulse that failed or stopped since the panel was last opened: opened as it is, it is on that pulse - what went
@@ -2424,6 +2434,7 @@ function sidePanelOf(jobs, cwd) {
2424
2434
  // Opened, it reads the files again at once: they may have changed while it was closed.
2425
2435
  specMap.refresh();
2426
2436
  const view = createSidePanel({
2437
+ ...(session.terminal ? { notifications: notificationView(session, { accent: (text) => theme.fg("accent", text), muted: (text) => theme.fg("muted", text), bold: (text) => theme.bold(text) }, back) } : {}),
2427
2438
  pointer: terminalPointer(tui.terminal),
2428
2439
  tabLabel: (text, active, hovered, role) => buttonLabel(theme, text, active, hovered, role),
2429
2440
  jobs: () => shownJobs(jobs),
package/dist/pi-launch.js CHANGED
@@ -15,6 +15,7 @@ import { withoutResumeLine } from "./resume-line.js";
15
15
  import { lastRun } from "./chat-records.js";
16
16
  import { driveTerminal } from "./chat-terminal.js";
17
17
  import { takeOverSettings } from "./pi-settings.js";
18
+ import { quietBrandThemeOverrides } from "./pi-themes.js";
18
19
  import turri, { createTurriCore, processSession } from "./extension.js";
19
20
  /**
20
21
  * pi, started the way its own CLI starts it, for `turri`.
@@ -45,6 +46,7 @@ ProcessTerminal.prototype.setTitle = function (title) {
45
46
  SettingsManager.prototype.getFullscreenExitOutput = () => "resume-hint";
46
47
  // /settings is turri's, pi's own menu the last entry of it (pi-settings.ts).
47
48
  takeOverSettings();
49
+ quietBrandThemeOverrides();
48
50
  const write = process.stdout.write.bind(process.stdout);
49
51
  process.stdout.write = ((chunk, ...rest) => write(typeof chunk === "string" ? withoutResumeLine(chunk) : chunk, ...rest));
50
52
  // pi's own keys stand: a new line is shift+enter or ctrl+j. turri's side panel is on ctrl+h (job-panel.ts PANEL_KEY).
@@ -0,0 +1,3 @@
1
+ /** pi already picks the project's theme over the user's, then turri's bundled fallback. In the chat these copies
2
+ * of a brand theme are expected; a broken file or a clash with a theme from elsewhere is still worth showing. */
3
+ export declare function quietBrandThemeOverrides(cwd?: string, agentDir?: string): void;