@phren/cli 0.1.44 → 0.1.46

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 (94) hide show
  1. package/dist/agents/providers/herdr.d.ts +18 -0
  2. package/dist/agents/providers/herdr.js +94 -0
  3. package/dist/agents/providers/spawner.d.ts +13 -0
  4. package/dist/agents/providers/spawner.js +63 -0
  5. package/dist/agents/registry.d.ts +28 -0
  6. package/dist/agents/registry.js +82 -0
  7. package/dist/agents/types.d.ts +51 -0
  8. package/dist/agents/types.js +42 -0
  9. package/dist/cli/actions.d.ts +1 -1
  10. package/dist/cli/actions.js +7 -2
  11. package/dist/cli/config-proactivity.d.ts +6 -6
  12. package/dist/cli/hooks.d.ts +1 -1
  13. package/dist/cli/hooks.js +14 -3
  14. package/dist/cli/search.js +29 -0
  15. package/dist/cli/session-stop.d.ts +1 -1
  16. package/dist/cli/session-tool-hook.d.ts +1 -1
  17. package/dist/cli-registry.d.ts +1 -1
  18. package/dist/cli-registry.js +2 -1
  19. package/dist/content/learning.js +24 -1
  20. package/dist/data/access.js +2 -1
  21. package/dist/generated/memory-ui-graph.browser.js +482 -319
  22. package/dist/governance/locks.js +6 -0
  23. package/dist/graph-core/index.d.ts +2 -0
  24. package/dist/graph-core/index.js +2 -0
  25. package/dist/graph-core/model.d.ts +84 -0
  26. package/dist/graph-core/model.js +445 -0
  27. package/dist/graph-core/types.d.ts +110 -0
  28. package/dist/graph-core/types.js +43 -0
  29. package/dist/index.js +4 -1
  30. package/dist/init/init-uninstall.d.ts +1 -0
  31. package/dist/init/init-uninstall.js +1 -1
  32. package/dist/init/setup.js +11 -4
  33. package/dist/link/context.js +2 -1
  34. package/dist/link/link.js +3 -2
  35. package/dist/link/skills.js +2 -1
  36. package/dist/memory-ui-graph.runtime.js +482 -319
  37. package/dist/phren-art.d.ts +7 -0
  38. package/dist/phren-art.js +6 -41
  39. package/dist/phren-core.d.ts +16 -0
  40. package/dist/phren-core.js +21 -0
  41. package/dist/phren-paths.js +8 -4
  42. package/dist/profile-store.js +3 -2
  43. package/dist/project-config.js +2 -1
  44. package/dist/shared/index.js +1 -1
  45. package/dist/shared/lookup-tail.d.ts +35 -0
  46. package/dist/shared/lookup-tail.js +100 -0
  47. package/dist/shared/retrieval.d.ts +28 -0
  48. package/dist/shared/retrieval.js +45 -0
  49. package/dist/shell/entry.d.ts +3 -3
  50. package/dist/shell/entry.js +19 -44
  51. package/dist/shell/graph/agents.d.ts +48 -0
  52. package/dist/shell/graph/agents.js +152 -0
  53. package/dist/shell/graph/canvas.d.ts +64 -0
  54. package/dist/shell/graph/canvas.js +256 -0
  55. package/dist/shell/graph/controller.d.ts +202 -0
  56. package/dist/shell/graph/controller.js +782 -0
  57. package/dist/shell/graph/glyphs.d.ts +12 -0
  58. package/dist/shell/graph/glyphs.js +31 -0
  59. package/dist/shell/graph/graph-view.d.ts +19 -0
  60. package/dist/shell/graph/graph-view.js +585 -0
  61. package/dist/shell/graph/layout.d.ts +87 -0
  62. package/dist/shell/graph/layout.js +335 -0
  63. package/dist/shell/graph/watch.d.ts +71 -0
  64. package/dist/shell/graph/watch.js +153 -0
  65. package/dist/shell/input.d.ts +3 -0
  66. package/dist/shell/input.js +26 -4
  67. package/dist/shell/intro.d.ts +37 -0
  68. package/dist/shell/intro.js +82 -0
  69. package/dist/shell/logo-fx.d.ts +35 -0
  70. package/dist/shell/logo-fx.js +128 -0
  71. package/dist/shell/render.d.ts +2 -2
  72. package/dist/shell/render.js +15 -28
  73. package/dist/shell/shell.d.ts +15 -1
  74. package/dist/shell/shell.js +50 -7
  75. package/dist/shell/startup.d.ts +40 -0
  76. package/dist/shell/startup.js +113 -0
  77. package/dist/shell/state-store.d.ts +1 -1
  78. package/dist/shell/state-store.js +1 -1
  79. package/dist/shell/types.js +1 -0
  80. package/dist/shell/view.d.ts +3 -0
  81. package/dist/shell/view.js +72 -63
  82. package/dist/store-registry.js +3 -3
  83. package/dist/test-global-setup.d.ts +1 -0
  84. package/dist/test-global-setup.js +22 -0
  85. package/dist/tool-registry.js +1 -0
  86. package/dist/ui/data.d.ts +15 -7
  87. package/dist/ui/data.js +102 -3
  88. package/dist/ui/server.js +6 -56
  89. package/dist/utils-fts.js +2 -1
  90. package/dist/utils-helpers.d.ts +1 -0
  91. package/dist/utils-helpers.js +6 -0
  92. package/dist/utils.d.ts +1 -1
  93. package/dist/utils.js +1 -1
  94. package/package.json +11 -7
@@ -64,6 +64,11 @@ export async function executePalette(host, input) {
64
64
  host.setMessage(` ${TAB_ICONS.Health} Health`);
65
65
  return;
66
66
  }
67
+ if (command === "graph" || command === "map") {
68
+ host.setView("Graph");
69
+ host.setMessage(` ${TAB_ICONS.Graph} Graph`);
70
+ return;
71
+ }
67
72
  if (command === "open") {
68
73
  const project = parts[1];
69
74
  if (!project) {
@@ -463,7 +468,7 @@ export async function executePalette(host, input) {
463
468
  }
464
469
  function suggestCommand(input) {
465
470
  const known = [
466
- "help", "projects", "tasks", "task", "findings", "review queue", "machines", "health",
471
+ "help", "projects", "tasks", "task", "findings", "review queue", "machines", "health", "graph",
467
472
  "open", "search", "add", "complete", "move", "reprioritize", "pin", "unpin", "context",
468
473
  "work next", "tidy", "find add", "find remove", "machine map", "profile add-project", "profile remove-project",
469
474
  "run fix", "relink", "rerun hooks", "update", "govern", "consolidate",
@@ -482,7 +487,7 @@ function suggestCommand(input) {
482
487
  }
483
488
  export function completeInput(line, phrenPath, profile, state) {
484
489
  const commands = [
485
- ":projects", ":tasks", ":task", ":findings", ":review queue", ":machines", ":health",
490
+ ":projects", ":tasks", ":task", ":findings", ":review queue", ":machines", ":health", ":graph",
486
491
  ":open", ":search", ":add", ":complete", ":move", ":reprioritize", ":pin",
487
492
  ":unpin", ":context", ":work next", ":tidy", ":find add", ":find remove",
488
493
  ":machine map",
@@ -580,6 +585,9 @@ export function getListItems(phrenPath, profile, state, healthLineCount) {
580
585
  }
581
586
  case "Health":
582
587
  return Array.from({ length: Math.max(1, healthLineCount) }, (_, i) => ({ id: String(i) }));
588
+ case "Graph":
589
+ // The graph manages its own selection; the list cursor has nothing to walk.
590
+ return [];
583
591
  default:
584
592
  return [];
585
593
  }
@@ -799,6 +807,13 @@ export function applyViewShortcut(host, key) {
799
807
  host.setMessage(` ${TAB_ICONS.Health} Health ${style.dim("(esc to return)")}`);
800
808
  return true;
801
809
  }
810
+ // No message: the bottom bar already says this, and in the Graph view a
811
+ // spare row is worth more than a reminder.
812
+ if (key === "g") {
813
+ host.setView("Graph");
814
+ host.setMessage("");
815
+ return true;
816
+ }
802
817
  return false;
803
818
  }
804
819
  // ── Navigate-mode key handler ─────────────────────────────────────────────────
@@ -806,6 +821,13 @@ export async function handleNavigateKey(host, rawKey) {
806
821
  // Terminals in application-cursor mode send SS3 (ESC O A) instead of CSI
807
822
  // (ESC [ A) for the arrow keys; normalise so both spellings navigate.
808
823
  const key = /^\x1bO[A-D]$/.test(rawKey) ? `\x1b[${rawKey[2]}` : rawKey;
824
+ // The graph view owns arrows, Enter, /, Esc-layering and its own letters;
825
+ // anything it declines (q, :, ?, view shortcuts, a final Esc) falls through.
826
+ if (host.state.view === "Graph") {
827
+ const handled = host.graph().handleKey(key, host);
828
+ if (handled !== undefined)
829
+ return handled;
830
+ }
809
831
  if (key === "\x1b[A") {
810
832
  host.moveCursor(-1);
811
833
  showCursorPosition(host);
@@ -917,7 +939,7 @@ export async function handleNavigateKey(host, rawKey) {
917
939
  }
918
940
  // ── Tab switching ─────────────────────────────────────────────────────────────
919
941
  function nextTab(host) {
920
- if (host.state.view === "Projects" || host.state.view === "Health")
942
+ if (host.state.view === "Projects" || host.state.view === "Health" || host.state.view === "Graph")
921
943
  return;
922
944
  const idx = SUB_VIEWS.indexOf(host.state.view);
923
945
  const next = SUB_VIEWS[(idx + 1) % SUB_VIEWS.length];
@@ -927,7 +949,7 @@ function nextTab(host) {
927
949
  }
928
950
  }
929
951
  function prevTab(host) {
930
- if (host.state.view === "Projects" || host.state.view === "Health")
952
+ if (host.state.view === "Projects" || host.state.view === "Health" || host.state.view === "Graph")
931
953
  return;
932
954
  const idx = SUB_VIEWS.indexOf(host.state.view);
933
955
  const prev = SUB_VIEWS[(idx - 1 + SUB_VIEWS.length) % SUB_VIEWS.length];
@@ -0,0 +1,37 @@
1
+ /**
2
+ * The phren splash: mascot + wordmark text effect, shared by every terminal
3
+ * host (the interactive shell, phren-agent, anything embedding phren).
4
+ *
5
+ * The shell drives it from its own intro policy (once per version, always,
6
+ * off); other hosts call `playSplash` directly. Everything is injectable so
7
+ * the sequence can be tested without a terminal or real time.
8
+ */
9
+ export type KeypressWaiter = () => Promise<void>;
10
+ export interface SplashOptions {
11
+ version: string;
12
+ /** Replaces "local memory for working agents" beside the wordmark. */
13
+ tagline?: string;
14
+ /** Dimmed line under the splash ("Press any key to enter"). */
15
+ hint?: string;
16
+ /** Play the decrypt reveal; otherwise open on the finished wordmark. */
17
+ reveal?: boolean;
18
+ /** Hold with the shimmer for this long after the reveal. */
19
+ dwellMs?: number;
20
+ /** Hold until this resolves instead of a fixed dwell. */
21
+ waitForKeypress?: KeypressWaiter;
22
+ /** Wrap in the alternate screen — for hosts that are not already fullscreen. */
23
+ fullscreen?: boolean;
24
+ /** Injection points for tests. */
25
+ paint?: (frame: string) => void;
26
+ sleep?: (ms: number) => Promise<void>;
27
+ isTTY?: boolean;
28
+ screen?: {
29
+ enter: () => void;
30
+ exit: () => void;
31
+ };
32
+ }
33
+ /**
34
+ * Play the splash and return when it is dismissed. Does nothing when stdout
35
+ * is not a terminal.
36
+ */
37
+ export declare function playSplash(opts: SplashOptions): Promise<void>;
@@ -0,0 +1,82 @@
1
+ /**
2
+ * The phren splash: mascot + wordmark text effect, shared by every terminal
3
+ * host (the interactive shell, phren-agent, anything embedding phren).
4
+ *
5
+ * The shell drives it from its own intro policy (once per version, always,
6
+ * off); other hosts call `playSplash` directly. Everything is injectable so
7
+ * the sequence can be tested without a terminal or real time.
8
+ */
9
+ import { createPhrenAnimator } from "../phren-art.js";
10
+ import { LOGO_REVEAL_FRAMES, LOGO_REVEAL_FRAME_MS, LOGO_SHIMMER_FRAME_MS, logoRevealFrame, logoShimmerFrame, } from "./logo-fx.js";
11
+ import { composeStartupFrame, enterFullscreen, exitFullscreen, fitFrame, paintFrame, shellStartupFrames, style, } from "./render.js";
12
+ const NARROW_STAGE_MS = 160;
13
+ function realSleep(ms) {
14
+ return new Promise((resolve) => setTimeout(resolve, ms));
15
+ }
16
+ /**
17
+ * Play the splash and return when it is dismissed. Does nothing when stdout
18
+ * is not a terminal.
19
+ */
20
+ export async function playSplash(opts) {
21
+ const isTTY = opts.isTTY ?? Boolean(process.stdout.isTTY);
22
+ if (!isTTY)
23
+ return;
24
+ const paint = opts.paint ?? paintFrame;
25
+ const sleep = opts.sleep ?? realSleep;
26
+ const screen = opts.screen ?? { enter: enterFullscreen, exit: exitFullscreen };
27
+ const hint = opts.hint ? style.dim(opts.hint) : undefined;
28
+ const dwellMs = opts.dwellMs ?? 0;
29
+ if (opts.fullscreen)
30
+ screen.enter();
31
+ const animator = createPhrenAnimator({ facing: "right" });
32
+ animator.start();
33
+ let shimmerTick = 0;
34
+ const frame = (logo, withHint = true) => {
35
+ paint(fitFrame(composeStartupFrame(animator.getFrame(), opts.version, withHint ? hint : undefined, logo ?? logoShimmerFrame(shimmerTick++), opts.tagline)));
36
+ };
37
+ try {
38
+ if (opts.reveal) {
39
+ // Terminals too narrow for the wordmark get the staged text reveal instead.
40
+ const stages = shellStartupFrames(opts.version, opts.tagline);
41
+ if (stages.length > 1) {
42
+ for (const stage of stages.slice(0, -1)) {
43
+ paint(stage);
44
+ await sleep(NARROW_STAGE_MS);
45
+ }
46
+ }
47
+ else {
48
+ for (let i = 0; i < LOGO_REVEAL_FRAMES; i++) {
49
+ frame(logoRevealFrame(i / (LOGO_REVEAL_FRAMES - 1)), false);
50
+ await sleep(LOGO_REVEAL_FRAME_MS);
51
+ }
52
+ }
53
+ }
54
+ if (opts.waitForKeypress) {
55
+ const interval = setInterval(() => frame(), LOGO_SHIMMER_FRAME_MS);
56
+ frame();
57
+ try {
58
+ await opts.waitForKeypress();
59
+ }
60
+ finally {
61
+ clearInterval(interval);
62
+ }
63
+ }
64
+ else if (dwellMs > 0) {
65
+ const start = Date.now();
66
+ let elapsed = 0;
67
+ do {
68
+ frame();
69
+ await sleep(LOGO_SHIMMER_FRAME_MS);
70
+ elapsed = opts.sleep ? elapsed + LOGO_SHIMMER_FRAME_MS : Date.now() - start;
71
+ } while (elapsed < dwellMs);
72
+ }
73
+ else {
74
+ frame();
75
+ }
76
+ }
77
+ finally {
78
+ animator.stop();
79
+ if (opts.fullscreen)
80
+ screen.exit();
81
+ }
82
+ }
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Text effects for the phren wordmark on the shell splash.
3
+ *
4
+ * Inspired by TerminalTextEffects: the block-letter logo is revealed with a
5
+ * "decrypt" scramble that settles cell by cell into the real glyphs, and the
6
+ * finished wordmark carries a slow light-beam shimmer while the splash holds.
7
+ *
8
+ * Two rules keep the letters intact:
9
+ * - scramble glyphs come only from the same box-drawing / block family the
10
+ * logo already uses, so every cell stays one column wide;
11
+ * - every frame is a pure function of (progress, cell) with hash-based
12
+ * jitter, so the reveal is deterministic and the final frame equals the
13
+ * plain gradient logo exactly.
14
+ *
15
+ * This module is imported by render.ts and must not import from it.
16
+ */
17
+ export declare const PHREN_LOGO: string[];
18
+ export declare const PHREN_GRADIENT: string[];
19
+ /** Frames in the reveal and the delay between them. ~1s total. */
20
+ export declare const LOGO_REVEAL_FRAMES = 22;
21
+ export declare const LOGO_REVEAL_FRAME_MS = 45;
22
+ export declare const LOGO_SHIMMER_FRAME_MS = 110;
23
+ /** The finished wordmark: identical colours to `gradient(line)` in render.ts. */
24
+ export declare function logoPlain(): string[];
25
+ /**
26
+ * Decrypt reveal at `progress` in [0, 1]. Cells settle left to right with
27
+ * per-cell jitter; a settling cell flashes white for a moment; unsettled
28
+ * cells churn through scramble glyphs. At progress >= 1 this is `logoPlain()`.
29
+ */
30
+ export declare function logoRevealFrame(progress: number): string[];
31
+ /**
32
+ * A soft beam of light sweeping across the finished wordmark. `tick` is any
33
+ * increasing integer; the sweep loops with a pause between passes.
34
+ */
35
+ export declare function logoShimmerFrame(tick: number): string[];
@@ -0,0 +1,128 @@
1
+ /**
2
+ * Text effects for the phren wordmark on the shell splash.
3
+ *
4
+ * Inspired by TerminalTextEffects: the block-letter logo is revealed with a
5
+ * "decrypt" scramble that settles cell by cell into the real glyphs, and the
6
+ * finished wordmark carries a slow light-beam shimmer while the splash holds.
7
+ *
8
+ * Two rules keep the letters intact:
9
+ * - scramble glyphs come only from the same box-drawing / block family the
10
+ * logo already uses, so every cell stays one column wide;
11
+ * - every frame is a pure function of (progress, cell) with hash-based
12
+ * jitter, so the reveal is deterministic and the final frame equals the
13
+ * plain gradient logo exactly.
14
+ *
15
+ * This module is imported by render.ts and must not import from it.
16
+ */
17
+ const RESET = "\x1b[0m";
18
+ // Block-letter logo for the splash.
19
+ export const PHREN_LOGO = [
20
+ "██████╗ ██╗ ██╗██████╗ ███████╗███╗ ██╗",
21
+ "██╔══██╗██║ ██║██╔══██╗██╔════╝████╗ ██║",
22
+ "██████╔╝███████║██████╔╝█████╗ ██╔██╗ ██║",
23
+ "██╔═══╝ ██╔══██║██╔══██╗██╔══╝ ██║╚██╗██║",
24
+ "██║ ██║ ██║██║ ██║███████╗██║ ╚████║",
25
+ "╚═╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═══╝",
26
+ ];
27
+ // Neural gradient palette: purple → blue → cyan (256-color ANSI)
28
+ export const PHREN_GRADIENT = [
29
+ "\x1b[38;5;93m", // vivid purple
30
+ "\x1b[38;5;99m", // purple-blue
31
+ "\x1b[38;5;105m", // blue-purple
32
+ "\x1b[38;5;111m", // sky blue
33
+ "\x1b[38;5;75m", // dodger blue
34
+ "\x1b[38;5;81m", // cyan-blue
35
+ "\x1b[38;5;87m", // bright cyan
36
+ ];
37
+ /** Glyphs the scramble may show: the logo's own alphabet plus shade blocks. All one cell wide. */
38
+ const SCRAMBLE_POOL = [..."░▒▓█▀▄╗╔╝╚║═╬╪╫┼"];
39
+ /** Dim greys the unsettled cells cycle through. */
40
+ const SCRAMBLE_COLORS = ["\x1b[38;5;238m", "\x1b[38;5;240m", "\x1b[38;5;243m", "\x1b[38;5;245m"];
41
+ const FLASH = "\x1b[38;5;231m";
42
+ const SHIMMER = ["\x1b[38;5;123m", "\x1b[38;5;159m", "\x1b[38;5;195m", "\x1b[38;5;159m", "\x1b[38;5;123m"];
43
+ /** Frames in the reveal and the delay between them. ~1s total. */
44
+ export const LOGO_REVEAL_FRAMES = 22;
45
+ export const LOGO_REVEAL_FRAME_MS = 45;
46
+ export const LOGO_SHIMMER_FRAME_MS = 110;
47
+ function hash(a, b, c) {
48
+ let h = 2166136261;
49
+ for (const v of [a, b, c]) {
50
+ h ^= v + 0x9e3779b9;
51
+ h = Math.imul(h, 16777619);
52
+ }
53
+ return (h >>> 0) / 4294967296;
54
+ }
55
+ /**
56
+ * Split a logo line into cells with the same colour assignment `gradient()`
57
+ * in render.ts uses (bucket by position among non-space characters).
58
+ */
59
+ function cells(line) {
60
+ const chars = [...line];
61
+ const nonSpace = chars.filter((ch) => !/\s/.test(ch)).length;
62
+ let vi = 0;
63
+ return chars.map((ch) => {
64
+ if (/\s/.test(ch))
65
+ return { ch, colorIdx: -1, along: 0 };
66
+ const colorIdx = Math.min(Math.floor((vi * PHREN_GRADIENT.length) / nonSpace), PHREN_GRADIENT.length - 1);
67
+ const along = nonSpace > 1 ? vi / (nonSpace - 1) : 0;
68
+ vi++;
69
+ return { ch, colorIdx, along };
70
+ });
71
+ }
72
+ const LOGO_CELLS = PHREN_LOGO.map(cells);
73
+ function paint(row, color) {
74
+ let out = "";
75
+ let current = "";
76
+ row.forEach((cell, col) => {
77
+ if (cell.colorIdx < 0) {
78
+ out += cell.ch;
79
+ return;
80
+ }
81
+ const { ch, sgr } = color(cell, col);
82
+ if (sgr !== current) {
83
+ out += sgr;
84
+ current = sgr;
85
+ }
86
+ out += ch;
87
+ });
88
+ return out + RESET;
89
+ }
90
+ /** The finished wordmark: identical colours to `gradient(line)` in render.ts. */
91
+ export function logoPlain() {
92
+ return LOGO_CELLS.map((row) => paint(row, (cell) => ({ ch: cell.ch, sgr: PHREN_GRADIENT[cell.colorIdx] })));
93
+ }
94
+ /**
95
+ * Decrypt reveal at `progress` in [0, 1]. Cells settle left to right with
96
+ * per-cell jitter; a settling cell flashes white for a moment; unsettled
97
+ * cells churn through scramble glyphs. At progress >= 1 this is `logoPlain()`.
98
+ */
99
+ export function logoRevealFrame(progress) {
100
+ const p = Math.max(0, Math.min(1, progress));
101
+ const tick = Math.floor(p * 40);
102
+ return LOGO_CELLS.map((row, r) => paint(row, (cell, c) => {
103
+ const settleAt = cell.along * 0.72 + hash(r, c, 1) * 0.24;
104
+ if (p >= 1 || p >= settleAt + 0.07)
105
+ return { ch: cell.ch, sgr: PHREN_GRADIENT[cell.colorIdx] };
106
+ if (p >= settleAt)
107
+ return { ch: cell.ch, sgr: FLASH };
108
+ const glyph = SCRAMBLE_POOL[Math.floor(hash(r, c, tick) * SCRAMBLE_POOL.length)];
109
+ const shade = SCRAMBLE_COLORS[Math.floor(hash(c, r, tick + 7) * SCRAMBLE_COLORS.length)];
110
+ return { ch: glyph, sgr: shade };
111
+ }));
112
+ }
113
+ /**
114
+ * A soft beam of light sweeping across the finished wordmark. `tick` is any
115
+ * increasing integer; the sweep loops with a pause between passes.
116
+ */
117
+ export function logoShimmerFrame(tick) {
118
+ const width = Math.max(...PHREN_LOGO.map((line) => [...line].length));
119
+ const period = width + 26;
120
+ const x = ((tick * 2) % period) - 8;
121
+ return LOGO_CELLS.map((row, r) => paint(row, (cell, c) => {
122
+ // The beam leans like a slash: each row is offset one column.
123
+ const d = c + r - x;
124
+ if (d >= -2 && d <= 2)
125
+ return { ch: cell.ch, sgr: SHIMMER[d + 2] };
126
+ return { ch: cell.ch, sgr: PHREN_GRADIENT[cell.colorIdx] };
127
+ }));
128
+ }
@@ -72,12 +72,12 @@ export declare function paintFrame(frame: string): void;
72
72
  * scrolls every later cursor-home repaint lands on shifted rows, stacking the
73
73
  * frames on top of each other.
74
74
  */
75
- export declare function composeStartupFrame(artLines: string[], version: string, hint?: string): string[];
75
+ export declare function composeStartupFrame(artLines: string[], version: string, hint?: string, logo?: string[], tagline?: string): string[];
76
76
  /**
77
77
  * Clamp a frame to the terminal before painting: truncate each line to the
78
78
  * render width, erase whatever the previous frame left to the right of it, and
79
79
  * drop rows past the bottom so the frame can never scroll the screen.
80
80
  */
81
81
  export declare function fitFrame(lines: string[]): string;
82
- export declare function shellStartupFrames(version: string): string[];
82
+ export declare function shellStartupFrames(version: string, tagline?: string): string[];
83
83
  export {};
@@ -190,16 +190,8 @@ export function wrapSegments(segments, cols, opts = {}) {
190
190
  return lines.slice(0, maxLines).join("\n");
191
191
  }
192
192
  // ── Phren theme ────────────────────────────────────────────────────────────
193
- // Neural gradient palette: purple → blue → cyan (256-color ANSI)
194
- const PHREN_GRADIENT = [
195
- "\x1b[38;5;93m", // vivid purple
196
- "\x1b[38;5;99m", // purple-blue
197
- "\x1b[38;5;105m", // blue-purple
198
- "\x1b[38;5;111m", // sky blue
199
- "\x1b[38;5;75m", // dodger blue
200
- "\x1b[38;5;81m", // cyan-blue
201
- "\x1b[38;5;87m", // bright cyan
202
- ];
193
+ // The wordmark and its gradient live with the splash text effects.
194
+ import { PHREN_GRADIENT, PHREN_LOGO } from "./logo-fx.js";
203
195
  // Apply gradient coloring across non-whitespace characters
204
196
  export function gradient(text, colors = PHREN_GRADIENT) {
205
197
  const plain = stripAnsi(text);
@@ -221,15 +213,6 @@ export function gradient(text, colors = PHREN_GRADIENT) {
221
213
  }
222
214
  return result + RESET;
223
215
  }
224
- // Block-letter logo for startup animation
225
- const PHREN_LOGO = [
226
- "██████╗ ██╗ ██╗██████╗ ███████╗███╗ ██╗",
227
- "██╔══██╗██║ ██║██╔══██╗██╔════╝████╗ ██║",
228
- "██████╔╝███████║██████╔╝█████╗ ██╔██╗ ██║",
229
- "██╔═══╝ ██╔══██║██╔══██╗██╔══╝ ██║╚██╗██║",
230
- "██║ ██║ ██║██║ ██║███████╗██║ ╚████║",
231
- "╚═╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═══╝",
232
- ];
233
216
  import { PHREN_ART as PHREN_STARTUP_ART } from "../phren-art.js";
234
217
  // ── Line-based viewport: edge-triggered scroll (stable, no jumpiness) ─────────
235
218
  export function lineViewport(allLines, cursorFirstLine, cursorLastLine, height, prevStart) {
@@ -267,6 +250,9 @@ export function shellHelpText() {
267
250
  ` ${style.bold("Tasks")} ${k("a")} ${d("add task")} ${k("d")} ${d("toggle active/queue")} ${k("↵")} ${d("mark complete")}`,
268
251
  ` ${style.bold("Findings")} ${k("a")} ${d("tell phren")} ${k("d")} ${d("delete selected")}`,
269
252
  ` ${style.bold("Review Queue")} ${k("↵")} ${d("inspect selected item")} ${d("(read-only)")}`,
253
+ ` ${style.bold("Graph")} ${k("↑↓←→")} ${d("walk")} ${k("1-9")} ${d("neighbour")} ${k("↵")} ${d("select / focus")} ${k("w")} ${d("watch")}`,
254
+ ` ${" ".repeat(13)}${k("/")} ${d("search")} ${k("n N")} ${d("next / prev hit")} ${k("f")} ${d("filter")} ${k("[ ]")} ${d("project")}`,
255
+ ` ${" ".repeat(13)}${k("+ -")} ${d("zoom")} ${k("0")} ${d("fit")} ${k("r")} ${d("re-lay out")} ${k("⇧↑↓←→")} ${d("pan")} ${k("o")} ${d("3D viewer")}`,
270
256
  ` ${style.bold("Skills")} ${k("t")} ${d("toggle enabled")} ${k("d")} ${d("remove")}`,
271
257
  "",
272
258
  hdr("Palette commands (:cmd)"),
@@ -356,8 +342,8 @@ const LOGO_WIDTH = Math.max(...PHREN_LOGO.map(displayWidth));
356
342
  * The wordmark line, split onto two rows when the terminal is too narrow to
357
343
  * carry the tagline alongside the version badge.
358
344
  */
359
- function startupInfoLines(version, available) {
360
- const tagline = style.dim("local memory for working agents");
345
+ function startupInfoLines(version, available, taglineText = "local memory for working agents") {
346
+ const tagline = style.dim(taglineText);
361
347
  const head = `${gradient("◆")} ${style.bold("phren")} ${badge(`v${version}`, style.boldBlue)}`;
362
348
  const single = `${head} ${tagline}`;
363
349
  return displayWidth(single) <= available ? [single] : [head, tagline];
@@ -374,17 +360,18 @@ function startupInfoLines(version, available) {
374
360
  * scrolls every later cursor-home repaint lands on shifted rows, stacking the
375
361
  * frames on top of each other.
376
362
  */
377
- export function composeStartupFrame(artLines, version, hint) {
363
+ export function composeStartupFrame(artLines, version, hint, logo, tagline) {
378
364
  const cols = renderWidth();
379
365
  const rows = process.stdout.rows || 24;
380
- const logoLines = PHREN_LOGO.map(line => gradient(line));
366
+ // A text-effect frame of the wordmark may be supplied; otherwise the plain gradient.
367
+ const logoLines = logo ?? PHREN_LOGO.map(line => gradient(line));
381
368
  const hintLines = hint ? ["", ` ${hint}`] : [];
382
369
  // One blank line above, one below, plus the hint block.
383
370
  const budget = rows - 2 - hintLines.length;
384
- const stackedInfo = startupInfoLines(version, cols - 2).map(line => ` ${line}`);
371
+ const stackedInfo = startupInfoLines(version, cols - 2, tagline).map(line => ` ${line}`);
385
372
  const sideBySide = () => {
386
373
  // Logo is 6 lines; the leading blanks centre it against the character.
387
- const rightSide = ["", "", ...logoLines, "", ...startupInfoLines(version, cols - ART_WIDTH - ART_GAP)];
374
+ const rightSide = ["", "", ...logoLines, "", ...startupInfoLines(version, cols - ART_WIDTH - ART_GAP, tagline)];
388
375
  const lines = [];
389
376
  for (let i = 0; i < Math.max(artLines.length, rightSide.length); i++) {
390
377
  // padToWidth measures display cells; String.padEnd counts the art's ANSI
@@ -419,15 +406,15 @@ export function fitFrame(lines) {
419
406
  .map(line => truncateLine(line, cols) + "\x1b[K")
420
407
  .join("\n");
421
408
  }
422
- export function shellStartupFrames(version) {
409
+ export function shellStartupFrames(version, tagline) {
423
410
  const cols = process.stdout.columns || 80;
424
411
  if (cols >= 44) {
425
- return [fitFrame(composeStartupFrame(PHREN_STARTUP_ART, version))];
412
+ return [fitFrame(composeStartupFrame(PHREN_STARTUP_ART, version, undefined, undefined, tagline))];
426
413
  }
427
414
  // Narrow terminal: progressive text reveal with gradient
428
415
  const stages = ["p", "phr", "phren"];
429
416
  const spinners = ["◜", "◠", "◝"];
430
- const infoLines = startupInfoLines(version, renderWidth() - 2).map(line => ` ${line}`);
417
+ const infoLines = startupInfoLines(version, renderWidth() - 2, tagline).map(line => ` ${line}`);
431
418
  return stages.map((stage, i) => fitFrame([
432
419
  "",
433
420
  ` ${gradient(stage)} ${style.dim(spinners[i])}`,
@@ -1,5 +1,7 @@
1
1
  import { type ShellView, type ShellDeps, type DoctorResultLike } from "./types.js";
2
2
  export type { ShellView, ShellDeps } from "./types.js";
3
+ import type { ShellStartup } from "./startup.js";
4
+ import { GraphController } from "./graph/controller.js";
3
5
  export declare class PhrenShell {
4
6
  readonly phrenPath: string;
5
7
  readonly profile: string;
@@ -22,12 +24,23 @@ export declare class PhrenShell {
22
24
  private viewScrollMap;
23
25
  private healthLineCount;
24
26
  private _subsectionsCache;
27
+ private _graph?;
28
+ private repaintHandler;
29
+ /** `--live` / `--no-live`; undefined leaves watch mode at its default. */
30
+ private graphLive?;
25
31
  get mode(): "navigate" | "input";
26
32
  get inputBuffer(): string;
27
33
  get filter(): string | undefined;
28
- constructor(phrenPath: string, profile: string, deps?: ShellDeps);
34
+ constructor(phrenPath: string, profile: string, deps?: ShellDeps, startup?: ShellStartup);
29
35
  close(): void;
30
36
  setMessage(msg: string): void;
37
+ /**
38
+ * Let the host (entry.ts) hand over a way to repaint on the shell's own
39
+ * initiative — the graph view uses it to animate its layout settling and
40
+ * to show a build that finished while nothing was typed.
41
+ */
42
+ setRepaintHandler(handler: (() => void) | null): void;
43
+ graph(): GraphController;
31
44
  confirmThen(label: string, action: () => void): void;
32
45
  setView(view: ShellView): void;
33
46
  setFilter(value: string): void;
@@ -59,3 +72,4 @@ export declare class PhrenShell {
59
72
  completeInput(line: string): string[];
60
73
  }
61
74
  export { startShell } from "./entry.js";
75
+ export type { ShellStartup } from "./startup.js";
@@ -9,6 +9,7 @@ import { runDoctor } from "../link/link.js";
9
9
  import { renderShell, } from "./view.js";
10
10
  import { executePalette, completeInput as completeInputFn, getListItems, handleNavigateKey, applyViewShortcut, } from "./input.js";
11
11
  import { errorMessage } from "../utils.js";
12
+ import { GraphController } from "./graph/controller.js";
12
13
  /** Remove the final character, keeping surrogate pairs and combining marks intact. */
13
14
  function dropLastCharacter(s) {
14
15
  if (!s)
@@ -39,6 +40,10 @@ export class PhrenShell {
39
40
  viewScrollMap = {};
40
41
  healthLineCount = 0;
41
42
  _subsectionsCache = null;
43
+ _graph;
44
+ repaintHandler = null;
45
+ /** `--live` / `--no-live`; undefined leaves watch mode at its default. */
46
+ graphLive;
42
47
  get mode() { return this.navMode; }
43
48
  get inputBuffer() { return this.inputBuf; }
44
49
  get filter() { return this.state.filter; }
@@ -47,23 +52,50 @@ export class PhrenShell {
47
52
  runRelink: defaultRunRelink,
48
53
  runHooks: defaultRunHooks,
49
54
  runUpdate: defaultRunUpdate,
50
- }) {
55
+ }, startup = {}) {
51
56
  this.phrenPath = phrenPath;
52
57
  this.profile = profile;
53
58
  this.deps = deps;
54
59
  this.state = loadShellState(phrenPath);
55
- this.state.view = "Projects";
56
- this.message = this.state.project
57
- ? ` Dashboard ready — active context ${style.boldCyan(this.state.project)}`
58
- : ` Dashboard ready — choose a project with ${style.boldCyan("↵")} or stay global`;
60
+ // A deep link (`phren shell --view tasks --here`) wins over the view the
61
+ // last session happened to leave behind; without one we always land home.
62
+ if (startup.project)
63
+ this.state.project = startup.project;
64
+ this.graphLive = startup.live;
65
+ this.state.view = startup.view ?? "Projects";
66
+ this.message = startup.notice
67
+ ? ` ${style.yellow("⚠")} ${startup.notice}`
68
+ : this.state.view === "Graph"
69
+ ? ""
70
+ : this.state.project
71
+ ? ` Dashboard ready — active context ${style.boldCyan(this.state.project)}`
72
+ : ` Dashboard ready — choose a project with ${style.boldCyan("↵")} or stay global`;
59
73
  }
60
- close() { saveShellState(this.phrenPath, this.state); }
74
+ close() { this._graph?.dispose(); saveShellState(this.phrenPath, this.state); }
61
75
  setMessage(msg) { this.message = msg; }
76
+ /**
77
+ * Let the host (entry.ts) hand over a way to repaint on the shell's own
78
+ * initiative — the graph view uses it to animate its layout settling and
79
+ * to show a build that finished while nothing was typed.
80
+ */
81
+ setRepaintHandler(handler) {
82
+ this.repaintHandler = handler;
83
+ this._graph?.setRepaintHook(handler);
84
+ }
85
+ graph() {
86
+ if (!this._graph) {
87
+ this._graph = new GraphController(this.phrenPath, this.profile, { watchEnabled: this.graphLive });
88
+ this._graph.setRepaintHook(this.repaintHandler);
89
+ }
90
+ return this._graph;
91
+ }
62
92
  confirmThen(label, action) {
63
93
  this.pendingConfirm = { label, action };
64
94
  this.setMessage(`${label} ${style.boldCyan("y")} ${style.dim("confirm")} ${style.boldCyan("n")} ${style.dim("cancel")}`);
65
95
  }
66
96
  setView(view) {
97
+ if (this.state.view === "Graph" && view !== "Graph")
98
+ this._graph?.stopAnimation();
67
99
  this.state.view = view;
68
100
  this.viewScrollMap[view] = 0;
69
101
  saveShellState(this.phrenPath, this.state);
@@ -126,7 +158,7 @@ export class PhrenShell {
126
158
  this.navMode = "navigate";
127
159
  this.inputBuf = "";
128
160
  this.inputCtx = "";
129
- if (!buf.trim() && ctx !== "command") {
161
+ if (!buf.trim() && ctx !== "command" && ctx !== "graph-search") {
130
162
  this.setMessage(" Nothing entered.");
131
163
  return;
132
164
  }
@@ -134,6 +166,15 @@ export class PhrenShell {
134
166
  case "filter":
135
167
  this.setFilter(buf);
136
168
  break;
169
+ case "graph-search": {
170
+ const graph = this.graph();
171
+ const best = graph.applySearch(buf);
172
+ if (best)
173
+ this.setMessage(` ${style.yellow(`1/${graph.search.results.length}`)} ${graph.describe(best).trimStart()}`);
174
+ else
175
+ this.setMessage(buf.trim() ? ` ${style.dim("no matches for")} ${style.yellow(buf.trim())}` : ` ${style.dim("search cleared")}`);
176
+ break;
177
+ }
137
178
  case "command":
138
179
  await this.runPalette(buf.startsWith(":") ? buf.slice(1) : buf);
139
180
  break;
@@ -236,6 +277,7 @@ export class PhrenShell {
236
277
  phrenPath: this.phrenPath, profile: this.profile, state: this.state,
237
278
  currentCursor: () => this.currentCursor(), currentScroll: () => this.currentScroll(),
238
279
  setScroll: (n) => this.setScroll(n),
280
+ graph: () => this.graph(),
239
281
  };
240
282
  return renderShell(ctx, this.navMode, this.inputCtx, this.inputBuf, this.showHelp, this.message, () => this.doctorSnapshot(), this._subsectionsCache, (n) => { this.healthLineCount = n; }, (c) => { this._subsectionsCache = c; });
241
283
  }
@@ -261,6 +303,7 @@ export class PhrenShell {
261
303
  moveCursor: (delta) => this.moveCursor(delta),
262
304
  getListItems: () => this.getListItems(),
263
305
  startInput: (ctx, initial) => this.startInput(ctx, initial),
306
+ graph: () => this.graph(),
264
307
  };
265
308
  }
266
309
  // ── Palette (delegates to shell-input.ts) ──────────────────────────────