@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.
- package/dist/agents/providers/herdr.d.ts +18 -0
- package/dist/agents/providers/herdr.js +94 -0
- package/dist/agents/providers/spawner.d.ts +13 -0
- package/dist/agents/providers/spawner.js +63 -0
- package/dist/agents/registry.d.ts +28 -0
- package/dist/agents/registry.js +82 -0
- package/dist/agents/types.d.ts +51 -0
- package/dist/agents/types.js +42 -0
- package/dist/cli/actions.d.ts +1 -1
- package/dist/cli/actions.js +7 -2
- package/dist/cli/config-proactivity.d.ts +6 -6
- package/dist/cli/hooks.d.ts +1 -1
- package/dist/cli/hooks.js +14 -3
- package/dist/cli/search.js +29 -0
- package/dist/cli/session-stop.d.ts +1 -1
- package/dist/cli/session-tool-hook.d.ts +1 -1
- package/dist/cli-registry.d.ts +1 -1
- package/dist/cli-registry.js +2 -1
- package/dist/content/learning.js +24 -1
- package/dist/data/access.js +2 -1
- package/dist/generated/memory-ui-graph.browser.js +482 -319
- package/dist/governance/locks.js +6 -0
- package/dist/graph-core/index.d.ts +2 -0
- package/dist/graph-core/index.js +2 -0
- package/dist/graph-core/model.d.ts +84 -0
- package/dist/graph-core/model.js +445 -0
- package/dist/graph-core/types.d.ts +110 -0
- package/dist/graph-core/types.js +43 -0
- package/dist/index.js +4 -1
- package/dist/init/init-uninstall.d.ts +1 -0
- package/dist/init/init-uninstall.js +1 -1
- package/dist/init/setup.js +11 -4
- package/dist/link/context.js +2 -1
- package/dist/link/link.js +3 -2
- package/dist/link/skills.js +2 -1
- package/dist/memory-ui-graph.runtime.js +482 -319
- package/dist/phren-art.d.ts +7 -0
- package/dist/phren-art.js +6 -41
- package/dist/phren-core.d.ts +16 -0
- package/dist/phren-core.js +21 -0
- package/dist/phren-paths.js +8 -4
- package/dist/profile-store.js +3 -2
- package/dist/project-config.js +2 -1
- package/dist/shared/index.js +1 -1
- package/dist/shared/lookup-tail.d.ts +35 -0
- package/dist/shared/lookup-tail.js +100 -0
- package/dist/shared/retrieval.d.ts +28 -0
- package/dist/shared/retrieval.js +45 -0
- package/dist/shell/entry.d.ts +3 -3
- package/dist/shell/entry.js +19 -44
- package/dist/shell/graph/agents.d.ts +48 -0
- package/dist/shell/graph/agents.js +152 -0
- package/dist/shell/graph/canvas.d.ts +64 -0
- package/dist/shell/graph/canvas.js +256 -0
- package/dist/shell/graph/controller.d.ts +202 -0
- package/dist/shell/graph/controller.js +782 -0
- package/dist/shell/graph/glyphs.d.ts +12 -0
- package/dist/shell/graph/glyphs.js +31 -0
- package/dist/shell/graph/graph-view.d.ts +19 -0
- package/dist/shell/graph/graph-view.js +585 -0
- package/dist/shell/graph/layout.d.ts +87 -0
- package/dist/shell/graph/layout.js +335 -0
- package/dist/shell/graph/watch.d.ts +71 -0
- package/dist/shell/graph/watch.js +153 -0
- package/dist/shell/input.d.ts +3 -0
- package/dist/shell/input.js +26 -4
- package/dist/shell/intro.d.ts +37 -0
- package/dist/shell/intro.js +82 -0
- package/dist/shell/logo-fx.d.ts +35 -0
- package/dist/shell/logo-fx.js +128 -0
- package/dist/shell/render.d.ts +2 -2
- package/dist/shell/render.js +15 -28
- package/dist/shell/shell.d.ts +15 -1
- package/dist/shell/shell.js +50 -7
- package/dist/shell/startup.d.ts +40 -0
- package/dist/shell/startup.js +113 -0
- package/dist/shell/state-store.d.ts +1 -1
- package/dist/shell/state-store.js +1 -1
- package/dist/shell/types.js +1 -0
- package/dist/shell/view.d.ts +3 -0
- package/dist/shell/view.js +72 -63
- package/dist/store-registry.js +3 -3
- package/dist/test-global-setup.d.ts +1 -0
- package/dist/test-global-setup.js +22 -0
- package/dist/tool-registry.js +1 -0
- package/dist/ui/data.d.ts +15 -7
- package/dist/ui/data.js +102 -3
- package/dist/ui/server.js +6 -56
- package/dist/utils-fts.js +2 -1
- package/dist/utils-helpers.d.ts +1 -0
- package/dist/utils-helpers.js +6 -0
- package/dist/utils.d.ts +1 -1
- package/dist/utils.js +1 -1
- package/package.json +11 -7
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Deep links into the shell: `phren shell --view tasks --here` opens straight
|
|
3
|
+
* on a project's task list instead of the Projects home screen.
|
|
4
|
+
*
|
|
5
|
+
* This exists so an outside launcher — the Herdr plugin, a tmux binding, an
|
|
6
|
+
* editor task — can put the user where they meant to be in one keypress.
|
|
7
|
+
*/
|
|
8
|
+
import type { ShellView } from "./types.js";
|
|
9
|
+
export interface ShellStartup {
|
|
10
|
+
view?: ShellView;
|
|
11
|
+
project?: string;
|
|
12
|
+
/** Graph watch mode. Undefined leaves the default (on). */
|
|
13
|
+
live?: boolean;
|
|
14
|
+
/** Shown on the shell's message line — fullscreen mode eats anything printed before launch. */
|
|
15
|
+
notice?: string;
|
|
16
|
+
}
|
|
17
|
+
export interface ShellStartupArgs {
|
|
18
|
+
view?: string;
|
|
19
|
+
project?: string;
|
|
20
|
+
here?: boolean;
|
|
21
|
+
live?: boolean;
|
|
22
|
+
unknown?: string;
|
|
23
|
+
}
|
|
24
|
+
export declare function normalizeShellView(raw: string | undefined): ShellView | undefined;
|
|
25
|
+
export declare const SHELL_VIEW_ALIASES: string[];
|
|
26
|
+
/** Parse `--view`/`--project`/`--here`, in both `--flag value` and `--flag=value` form. */
|
|
27
|
+
export declare function parseShellArgs(args: string[]): ShellStartupArgs;
|
|
28
|
+
/**
|
|
29
|
+
* Turn parsed flags into the state the shell should open in. An unresolvable
|
|
30
|
+
* view or project is dropped rather than fatal — a deep link that misses should
|
|
31
|
+
* still land you in the shell, on the home screen, with everything else intact.
|
|
32
|
+
*/
|
|
33
|
+
export declare function resolveShellStartup(parsed: ShellStartupArgs, opts: {
|
|
34
|
+
phrenPath: string;
|
|
35
|
+
profile?: string;
|
|
36
|
+
cwd?: string;
|
|
37
|
+
}): {
|
|
38
|
+
startup: ShellStartup;
|
|
39
|
+
warnings: string[];
|
|
40
|
+
};
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Deep links into the shell: `phren shell --view tasks --here` opens straight
|
|
3
|
+
* on a project's task list instead of the Projects home screen.
|
|
4
|
+
*
|
|
5
|
+
* This exists so an outside launcher — the Herdr plugin, a tmux binding, an
|
|
6
|
+
* editor task — can put the user where they meant to be in one keypress.
|
|
7
|
+
*/
|
|
8
|
+
import { detectProject } from "../shared/index.js";
|
|
9
|
+
/** Spelling of a view a person would actually type, mapped to the canonical name. */
|
|
10
|
+
const VIEW_ALIASES = {
|
|
11
|
+
projects: "Projects",
|
|
12
|
+
project: "Projects",
|
|
13
|
+
tasks: "Tasks",
|
|
14
|
+
task: "Tasks",
|
|
15
|
+
todo: "Tasks",
|
|
16
|
+
todos: "Tasks",
|
|
17
|
+
findings: "Findings",
|
|
18
|
+
finding: "Findings",
|
|
19
|
+
memory: "Findings",
|
|
20
|
+
review: "Review Queue",
|
|
21
|
+
"review queue": "Review Queue",
|
|
22
|
+
"review-queue": "Review Queue",
|
|
23
|
+
queue: "Review Queue",
|
|
24
|
+
skills: "Skills",
|
|
25
|
+
skill: "Skills",
|
|
26
|
+
hooks: "Hooks",
|
|
27
|
+
hook: "Hooks",
|
|
28
|
+
health: "Health",
|
|
29
|
+
doctor: "Health",
|
|
30
|
+
graph: "Graph",
|
|
31
|
+
map: "Graph",
|
|
32
|
+
network: "Graph",
|
|
33
|
+
machines: "Machines/Profiles",
|
|
34
|
+
profiles: "Machines/Profiles",
|
|
35
|
+
"machines/profiles": "Machines/Profiles",
|
|
36
|
+
};
|
|
37
|
+
export function normalizeShellView(raw) {
|
|
38
|
+
if (!raw)
|
|
39
|
+
return undefined;
|
|
40
|
+
return VIEW_ALIASES[raw.trim().toLowerCase()];
|
|
41
|
+
}
|
|
42
|
+
export const SHELL_VIEW_ALIASES = Object.keys(VIEW_ALIASES);
|
|
43
|
+
/** Views that render nothing useful until a project is in context. */
|
|
44
|
+
const PROJECT_SCOPED_VIEWS = new Set(["Tasks", "Findings", "Review Queue", "Skills"]);
|
|
45
|
+
/** Parse `--view`/`--project`/`--here`, in both `--flag value` and `--flag=value` form. */
|
|
46
|
+
export function parseShellArgs(args) {
|
|
47
|
+
const parsed = {};
|
|
48
|
+
for (let i = 0; i < args.length; i++) {
|
|
49
|
+
const arg = args[i];
|
|
50
|
+
const eq = arg.indexOf("=");
|
|
51
|
+
const flag = eq === -1 ? arg : arg.slice(0, eq);
|
|
52
|
+
const inline = eq === -1 ? undefined : arg.slice(eq + 1);
|
|
53
|
+
// `--view tasks` consumes the next argv entry; `--view=tasks` does not.
|
|
54
|
+
const take = () => (inline !== undefined ? inline : args[++i]);
|
|
55
|
+
switch (flag) {
|
|
56
|
+
case "--view":
|
|
57
|
+
parsed.view = take();
|
|
58
|
+
break;
|
|
59
|
+
case "--project":
|
|
60
|
+
parsed.project = take();
|
|
61
|
+
break;
|
|
62
|
+
case "--here":
|
|
63
|
+
parsed.here = true;
|
|
64
|
+
break;
|
|
65
|
+
case "--live":
|
|
66
|
+
parsed.live = true;
|
|
67
|
+
break;
|
|
68
|
+
case "--no-live":
|
|
69
|
+
parsed.live = false;
|
|
70
|
+
break;
|
|
71
|
+
default:
|
|
72
|
+
if (flag.startsWith("-") && parsed.unknown === undefined)
|
|
73
|
+
parsed.unknown = flag;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
return parsed;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Turn parsed flags into the state the shell should open in. An unresolvable
|
|
80
|
+
* view or project is dropped rather than fatal — a deep link that misses should
|
|
81
|
+
* still land you in the shell, on the home screen, with everything else intact.
|
|
82
|
+
*/
|
|
83
|
+
export function resolveShellStartup(parsed, opts) {
|
|
84
|
+
const warnings = [];
|
|
85
|
+
const startup = {};
|
|
86
|
+
if (parsed.live !== undefined)
|
|
87
|
+
startup.live = parsed.live;
|
|
88
|
+
if (parsed.unknown)
|
|
89
|
+
warnings.push(`Unknown flag ${parsed.unknown} — ignored.`);
|
|
90
|
+
if (parsed.view) {
|
|
91
|
+
const view = normalizeShellView(parsed.view);
|
|
92
|
+
if (view)
|
|
93
|
+
startup.view = view;
|
|
94
|
+
else
|
|
95
|
+
warnings.push(`Unknown view "${parsed.view}" — opening on Projects.`);
|
|
96
|
+
}
|
|
97
|
+
if (parsed.project) {
|
|
98
|
+
startup.project = parsed.project;
|
|
99
|
+
}
|
|
100
|
+
else if (parsed.here) {
|
|
101
|
+
const detected = detectProject(opts.phrenPath, opts.cwd ?? process.cwd(), opts.profile);
|
|
102
|
+
if (detected)
|
|
103
|
+
startup.project = detected;
|
|
104
|
+
else
|
|
105
|
+
warnings.push("No phren project for this directory — opening without a project.");
|
|
106
|
+
}
|
|
107
|
+
// These views render an empty "no project selected" screen without a project,
|
|
108
|
+
// which is a worse landing spot than the project list the user came from.
|
|
109
|
+
if (!startup.project && startup.view && PROJECT_SCOPED_VIEWS.has(startup.view)) {
|
|
110
|
+
startup.view = undefined;
|
|
111
|
+
}
|
|
112
|
+
return { startup, warnings };
|
|
113
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type PhrenResult } from "../shared.js";
|
|
2
2
|
export interface ShellState {
|
|
3
3
|
version: number;
|
|
4
|
-
view: "Projects" | "Tasks" | "Findings" | "Review Queue" | "Skills" | "Hooks" | "Machines/Profiles" | "Health";
|
|
4
|
+
view: "Projects" | "Tasks" | "Findings" | "Review Queue" | "Skills" | "Hooks" | "Machines/Profiles" | "Health" | "Graph";
|
|
5
5
|
project?: string;
|
|
6
6
|
filter?: string;
|
|
7
7
|
page?: number;
|
|
@@ -5,7 +5,7 @@ import { withSafeLock } from "../shared/data-utils.js";
|
|
|
5
5
|
import { errorMessage } from "../utils.js";
|
|
6
6
|
import { logger } from "../logger.js";
|
|
7
7
|
const SHELL_STATE_VERSION = 3;
|
|
8
|
-
const VALID_VIEWS = new Set(["Projects", "Tasks", "Findings", "Review Queue", "Skills", "Hooks", "Machines/Profiles", "Health"]);
|
|
8
|
+
const VALID_VIEWS = new Set(["Projects", "Tasks", "Findings", "Review Queue", "Skills", "Hooks", "Machines/Profiles", "Health", "Graph"]);
|
|
9
9
|
export function loadShellState(phrenPath) {
|
|
10
10
|
const file = shellStateFile(phrenPath);
|
|
11
11
|
const fallback = {
|
package/dist/shell/types.js
CHANGED
package/dist/shell/view.d.ts
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import { ShellState } from "../data/access.js";
|
|
6
6
|
import { type DoctorResultLike } from "./types.js";
|
|
7
|
+
import type { GraphController } from "./graph/controller.js";
|
|
7
8
|
/** Shared rendering state passed from the orchestrator */
|
|
8
9
|
export interface ViewContext {
|
|
9
10
|
phrenPath: string;
|
|
@@ -12,6 +13,8 @@ export interface ViewContext {
|
|
|
12
13
|
currentCursor: () => number;
|
|
13
14
|
currentScroll: () => number;
|
|
14
15
|
setScroll: (n: number) => void;
|
|
16
|
+
/** The knowledge-graph view's controller (created on first use). Absent in hosts that only render menus. */
|
|
17
|
+
graph?: () => GraphController;
|
|
15
18
|
}
|
|
16
19
|
export interface SubsectionsCache {
|
|
17
20
|
project: string;
|
package/dist/shell/view.js
CHANGED
|
@@ -6,7 +6,7 @@ import * as fs from "fs";
|
|
|
6
6
|
import * as path from "path";
|
|
7
7
|
import { canonicalTaskFilePath, listProjectCards, readTasks, readFindings, readReviewQueue, readRuntimeHealth, resolveTaskFilePath, } from "../data/access.js";
|
|
8
8
|
import { getNonPrimaryStores } from "../store-registry.js";
|
|
9
|
-
import { style, badge, separator, stripAnsi, truncateLine, renderWidth, wrapSegments, lineViewport, shellHelpText, gradient, } from "./render.js";
|
|
9
|
+
import { style, badge, separator, stripAnsi, truncateLine, displayWidth, renderWidth, wrapSegments, lineViewport, shellHelpText, gradient, } from "./render.js";
|
|
10
10
|
import { formatSelectableLine, viewportWithStatus, } from "./view-list.js";
|
|
11
11
|
import { SUB_VIEWS, TAB_ICONS, } from "./types.js";
|
|
12
12
|
import { tasksByFilter, queueByFilter, } from "./palette.js";
|
|
@@ -16,6 +16,7 @@ import { isProjectHookEnabled, readProjectConfig } from "../project-config.js";
|
|
|
16
16
|
import { getScopedSkills } from "../skill/registry.js";
|
|
17
17
|
import { errorMessage } from "../utils.js";
|
|
18
18
|
import { logger } from "../logger.js";
|
|
19
|
+
import { renderGraphView, graphSummary } from "./graph/graph-view.js";
|
|
19
20
|
/** Resolve which store (primary or team) contains a project */
|
|
20
21
|
function resolveProjectStorePath(phrenPath, project) {
|
|
21
22
|
if (fs.existsSync(path.join(phrenPath, project)))
|
|
@@ -30,34 +31,35 @@ function resolveProjectStorePath(phrenPath, project) {
|
|
|
30
31
|
return phrenPath;
|
|
31
32
|
}
|
|
32
33
|
// ── Tab bar ────────────────────────────────────────────────────────────────
|
|
33
|
-
|
|
34
|
+
/**
|
|
35
|
+
* The whole top of the frame in as few rows as possible: brand, current view,
|
|
36
|
+
* project and filter on one line, then a rule. On a 24-row terminal the old
|
|
37
|
+
* three-row header cost more than a tenth of the screen.
|
|
38
|
+
*/
|
|
39
|
+
function renderTopBar(state, summary = "") {
|
|
34
40
|
const cols = renderWidth();
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
const
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
const
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
const tabLine = wrapSegments(
|
|
56
|
-
|
|
57
|
-
maxLines: 2,
|
|
58
|
-
separator: style.dim("│"),
|
|
59
|
-
});
|
|
60
|
-
return `${tabLine}\n${separator(cols)}`;
|
|
41
|
+
const brand = gradient("◆ phren");
|
|
42
|
+
const dot = style.dim("·");
|
|
43
|
+
const project = state.project ? `${dot} ${style.cyan(state.project)}` : "";
|
|
44
|
+
const filter = state.filter ? `${dot} ${style.yellow("/" + state.filter)}` : "";
|
|
45
|
+
const isSub = SUB_VIEWS.includes(state.view);
|
|
46
|
+
if (!isSub) {
|
|
47
|
+
const label = style.boldMagenta(`${TAB_ICONS[state.view] ?? "◆"} ${state.view}`);
|
|
48
|
+
const line = [" " + brand, label, project, filter, summary ? `${dot} ${summary}` : ""].filter(Boolean).join(" ");
|
|
49
|
+
return `${truncateLine(line, cols)}\n${separator(cols)}`;
|
|
50
|
+
}
|
|
51
|
+
// Sub-views carry a tab strip. Try full labels, then icons for the inactive
|
|
52
|
+
// tabs, before giving up and taking a second row.
|
|
53
|
+
const head = ` ${brand}${project ? ` ${project}` : ""}${filter ? ` ${filter}` : ""}`;
|
|
54
|
+
const full = SUB_VIEWS.map((v) => (v === state.view ? style.boldMagenta(`${TAB_ICONS[v]} ${v}`) : style.dim(`${TAB_ICONS[v]} ${v}`)));
|
|
55
|
+
const terse = SUB_VIEWS.map((v) => (v === state.view ? style.boldMagenta(`${TAB_ICONS[v]} ${v}`) : style.dim(TAB_ICONS[v] ?? "")));
|
|
56
|
+
for (const tabs of [full, terse]) {
|
|
57
|
+
const merged = `${head} ${style.dim("│")} ${tabs.join(style.dim(" │ "))}`;
|
|
58
|
+
if (displayWidth(merged) <= cols)
|
|
59
|
+
return `${merged}\n${separator(cols)}`;
|
|
60
|
+
}
|
|
61
|
+
const tabLine = wrapSegments(full, cols, { indent: " ", maxLines: 2, separator: style.dim("│") });
|
|
62
|
+
return `${head}\n${tabLine}\n${separator(cols)}`;
|
|
61
63
|
}
|
|
62
64
|
// ── Bottom bar ─────────────────────────────────────────────────────────────
|
|
63
65
|
function renderBottomBar(state, navMode, inputCtx, inputBuf) {
|
|
@@ -73,41 +75,43 @@ function renderBottomBar(state, navMode, inputCtx, inputBuf) {
|
|
|
73
75
|
add: "add task",
|
|
74
76
|
"learn-add": "add finding",
|
|
75
77
|
"skill-add": "new skill name",
|
|
78
|
+
"graph-search": "search graph",
|
|
76
79
|
};
|
|
77
80
|
const label = labels[inputCtx] || inputCtx;
|
|
78
81
|
return `${sep}\n ${style.boldCyan(label + " ›")} ${inputBuf}${style.cyan("█")}`;
|
|
79
82
|
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
"
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
83
|
+
// Only what you reach for constantly. Everything else is one `?` away, so
|
|
84
|
+
// the bar never costs more than a single row.
|
|
85
|
+
const essentials = {
|
|
86
|
+
Projects: [`${k("↑↓")} ${d("move")}`, `${k("↵")} ${d("open")}`],
|
|
87
|
+
Tasks: [`${k("↑↓")} ${d("move")}`, `${k("a")} ${d("add")}`, `${k("↵")} ${d("done")}`],
|
|
88
|
+
Findings: [`${k("↑↓")} ${d("move")}`, `${k("a")} ${d("add")}`],
|
|
89
|
+
"Review Queue": [`${k("↑↓")} ${d("move")}`, `${k("↵")} ${d("inspect")}`],
|
|
90
|
+
Skills: [`${k("↑↓")} ${d("move")}`, `${k("t")} ${d("toggle")}`],
|
|
91
|
+
Hooks: [`${k("↑↓")} ${d("move")}`, `${k("a")} ${d("enable")}`],
|
|
92
|
+
Health: [`${k("↑↓")} ${d("scroll")}`],
|
|
93
|
+
Graph: [`${k("↑↓←→")} ${d("walk")}`, `${k("↵")} ${d("select")}`, `${k("w")} ${d("watch")}`, `${k("a")} ${d("agents")}`],
|
|
88
94
|
};
|
|
89
|
-
const
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
separator: dot,
|
|
102
|
-
})}`;
|
|
95
|
+
const search = state.view === "Graph" ? `${k("/")} ${d("search")}` : `${k("/")} ${d("filter")}`;
|
|
96
|
+
// `? keys` and `q quit` are the two you cannot afford to lose, so a narrow
|
|
97
|
+
// terminal drops view hints off the end instead of truncating those away.
|
|
98
|
+
const always = [`${k("?")} ${d("keys")}`, `${k("q")} ${d("quit")}`];
|
|
99
|
+
const optional = [...(essentials[state.view] ?? []), search];
|
|
100
|
+
let line = "";
|
|
101
|
+
for (let take = optional.length; take >= 0; take--) {
|
|
102
|
+
line = wrapSegments([...optional.slice(0, take), ...always], cols, { indent: " ", maxLines: 1, separator: dot });
|
|
103
|
+
if (!stripAnsi(line).trimEnd().endsWith("…"))
|
|
104
|
+
break;
|
|
105
|
+
}
|
|
106
|
+
return `${sep}\n${line}`;
|
|
103
107
|
}
|
|
104
108
|
// ── Content height ─────────────────────────────────────────────────────────
|
|
105
109
|
function countRenderedLines(block) {
|
|
106
110
|
return block.split("\n").length;
|
|
107
111
|
}
|
|
108
|
-
function contentHeight(
|
|
112
|
+
function contentHeight(topBar, bottomBar, hasMessage) {
|
|
109
113
|
const rows = process.stdout.rows || 24;
|
|
110
|
-
const reserved =
|
|
114
|
+
const reserved = countRenderedLines(topBar) + countRenderedLines(bottomBar) + (hasMessage ? 1 : 0);
|
|
111
115
|
return Math.max(4, rows - reserved);
|
|
112
116
|
}
|
|
113
117
|
function collectProjectDashboardEntries(ctx) {
|
|
@@ -661,17 +665,13 @@ function renderHealthView(phrenPath, doctor, cursor, height, currentScroll, setS
|
|
|
661
665
|
}
|
|
662
666
|
// ── Main render ────────────────────────────────────────────────────────────
|
|
663
667
|
export async function renderShell(ctx, navMode, inputCtx, inputBuf, showHelp, message, doctorSnapshot, subsectionsCache, setHealthLineCount, setSubsectionsCache) {
|
|
664
|
-
const
|
|
665
|
-
|
|
666
|
-
: "";
|
|
667
|
-
const filterLabel = ctx.state.filter
|
|
668
|
-
? ` ${style.dim("·")} ${style.yellow("/" + ctx.state.filter)}`
|
|
669
|
-
: "";
|
|
670
|
-
const header = ` ${gradient("◆ phren")}${projectLabel}${filterLabel}`;
|
|
671
|
-
const tabBar = renderTabBar(ctx.state);
|
|
668
|
+
const graphSummaryLine = ctx.state.view === "Graph" && ctx.graph ? graphSummary(ctx.graph()) : "";
|
|
669
|
+
const topBar = renderTopBar(ctx.state, graphSummaryLine);
|
|
672
670
|
const bottomBar = renderBottomBar(ctx.state, navMode, inputCtx, inputBuf);
|
|
673
671
|
const cursor = ctx.currentCursor();
|
|
674
|
-
|
|
672
|
+
// An empty message line used to hold a row open on every frame.
|
|
673
|
+
const hasMessage = Boolean(stripAnsi(message).trim());
|
|
674
|
+
const height = contentHeight(topBar, bottomBar, hasMessage);
|
|
675
675
|
let contentLines;
|
|
676
676
|
if (showHelp) {
|
|
677
677
|
contentLines = shellHelpText().split("\n");
|
|
@@ -709,6 +709,16 @@ export async function renderShell(ctx, navMode, inputCtx, inputBuf, showHelp, me
|
|
|
709
709
|
setHealthLineCount(result.lineCount);
|
|
710
710
|
break;
|
|
711
711
|
}
|
|
712
|
+
case "Graph": {
|
|
713
|
+
if (!ctx.graph) {
|
|
714
|
+
contentLines = [" The graph view needs the interactive shell — run `phren shell`."];
|
|
715
|
+
break;
|
|
716
|
+
}
|
|
717
|
+
const controller = ctx.graph();
|
|
718
|
+
await controller.ensureData();
|
|
719
|
+
contentLines = renderGraphView(controller, renderWidth(), height);
|
|
720
|
+
break;
|
|
721
|
+
}
|
|
712
722
|
default:
|
|
713
723
|
contentLines = [" Unknown view."];
|
|
714
724
|
}
|
|
@@ -716,9 +726,8 @@ export async function renderShell(ctx, navMode, inputCtx, inputBuf, showHelp, me
|
|
|
716
726
|
const displayed = contentLines.slice(0, height);
|
|
717
727
|
while (displayed.length < height)
|
|
718
728
|
displayed.push("");
|
|
719
|
-
const msgLine = ` ${style.dimItalic(stripAnsi(message).trimStart() ? message : "")}`;
|
|
720
729
|
const cols = renderWidth();
|
|
721
|
-
const parts = [
|
|
730
|
+
const parts = [topBar, ...displayed, ...(hasMessage ? [` ${style.dimItalic(message.trimStart())}`] : []), bottomBar];
|
|
722
731
|
return parts.map(line => {
|
|
723
732
|
if (line.includes("\n")) {
|
|
724
733
|
return line.split("\n").map(sub => truncateLine(sub, cols) + "\x1b[K").join("\n");
|
package/dist/store-registry.js
CHANGED
|
@@ -4,7 +4,7 @@ import * as path from "path";
|
|
|
4
4
|
import * as yaml from "js-yaml";
|
|
5
5
|
import { expandHomePath, atomicWriteText } from "./phren-paths.js";
|
|
6
6
|
import { withFileLock } from "./governance/locks.js";
|
|
7
|
-
import { isRecord, PhrenError } from "./phren-core.js";
|
|
7
|
+
import { isRecord, loadYamlDocument, PhrenError } from "./phren-core.js";
|
|
8
8
|
import { getProjectDirs } from "./shared.js";
|
|
9
9
|
// ── Constants ────────────────────────────────────────────────────────────────
|
|
10
10
|
export const STORES_FILENAME = "stores.yaml";
|
|
@@ -39,7 +39,7 @@ export function readStoreRegistryDetailed(phrenPath) {
|
|
|
39
39
|
}
|
|
40
40
|
let parsed;
|
|
41
41
|
try {
|
|
42
|
-
parsed = yaml.load(
|
|
42
|
+
parsed = loadYamlDocument(raw, (text) => yaml.load(text, { schema: yaml.CORE_SCHEMA }));
|
|
43
43
|
}
|
|
44
44
|
catch (err) {
|
|
45
45
|
return { registry: null, problems: [`${STORES_FILENAME} is not valid YAML: ${String(err)}`], lossy: true };
|
|
@@ -183,7 +183,7 @@ export function readTeamBootstrap(storePath) {
|
|
|
183
183
|
return null;
|
|
184
184
|
try {
|
|
185
185
|
const raw = fs.readFileSync(filePath, "utf8");
|
|
186
|
-
const parsed = yaml.load(
|
|
186
|
+
const parsed = loadYamlDocument(raw, (text) => yaml.load(text, { schema: yaml.CORE_SCHEMA }));
|
|
187
187
|
if (!isRecord(parsed) || typeof parsed.name !== "string")
|
|
188
188
|
return null;
|
|
189
189
|
return {
|
|
@@ -13,13 +13,35 @@
|
|
|
13
13
|
*/
|
|
14
14
|
import { execFileSync } from "child_process";
|
|
15
15
|
import * as fs from "fs";
|
|
16
|
+
import * as os from "os";
|
|
16
17
|
import * as path from "path";
|
|
17
18
|
import { fileURLToPath } from "url";
|
|
18
19
|
const __filename = fileURLToPath(import.meta.url);
|
|
19
20
|
const __dirname = path.dirname(__filename);
|
|
20
21
|
const REPO_ROOT = path.resolve(__dirname, "../../..");
|
|
21
22
|
const CLI_PATH = path.join(REPO_ROOT, "packages", "cli", "dist", "index.js");
|
|
23
|
+
let sandboxHome = null;
|
|
24
|
+
/**
|
|
25
|
+
* Point HOME (and USERPROFILE) at a throwaway directory for the whole run.
|
|
26
|
+
*
|
|
27
|
+
* `pool: "forks"` workers inherit this process's env, and on Linux/macOS
|
|
28
|
+
* `os.homedir()` reads $HOME too, so this covers every route the CLI uses to
|
|
29
|
+
* find the user's home. Without it, isolation depends on each test
|
|
30
|
+
* remembering to override HOME — and the ones that forgot (e.g. the web-ui
|
|
31
|
+
* readiness test) re-pointed the developer's real ~/.claude/CLAUDE.md and
|
|
32
|
+
* ~/.claude/skills/phren-* at temp dirs that were deleted seconds later.
|
|
33
|
+
*/
|
|
34
|
+
function sandboxHomeDir() {
|
|
35
|
+
sandboxHome = fs.mkdtempSync(path.join(os.tmpdir(), "phren-test-home-"));
|
|
36
|
+
process.env.HOME = sandboxHome;
|
|
37
|
+
process.env.USERPROFILE = sandboxHome;
|
|
38
|
+
}
|
|
39
|
+
export async function teardown() {
|
|
40
|
+
if (sandboxHome)
|
|
41
|
+
fs.rmSync(sandboxHome, { recursive: true, force: true });
|
|
42
|
+
}
|
|
22
43
|
export async function setup() {
|
|
44
|
+
sandboxHomeDir();
|
|
23
45
|
if (fs.existsSync(CLI_PATH)) {
|
|
24
46
|
// Dist already present — skip build. This is the common path when
|
|
25
47
|
// `npm test` is used (pretest already built it) or during watch mode
|
package/dist/tool-registry.js
CHANGED
package/dist/ui/data.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import type { SqlJsDatabase } from "../shared/index.js";
|
|
2
2
|
import { type LookupEvent } from "../governance/activity.js";
|
|
3
|
-
interface EntryScore {
|
|
3
|
+
export interface EntryScore {
|
|
4
4
|
impressions: number;
|
|
5
5
|
helpful: number;
|
|
6
6
|
repromptPenalty: number;
|
|
7
7
|
regressionPenalty: number;
|
|
8
8
|
lastUsedAt: string;
|
|
9
9
|
}
|
|
10
|
-
interface GraphNode {
|
|
10
|
+
export interface GraphNode {
|
|
11
11
|
id: string;
|
|
12
12
|
label: string;
|
|
13
13
|
fullLabel: string;
|
|
@@ -30,18 +30,26 @@ interface GraphNode {
|
|
|
30
30
|
findingCount?: number;
|
|
31
31
|
taskCount?: number;
|
|
32
32
|
}
|
|
33
|
-
interface GraphDocRef {
|
|
33
|
+
export interface GraphDocRef {
|
|
34
34
|
doc: string;
|
|
35
35
|
project: string;
|
|
36
36
|
scoreKey?: string;
|
|
37
37
|
}
|
|
38
|
-
interface GraphTopicMeta {
|
|
38
|
+
export interface GraphTopicMeta {
|
|
39
39
|
slug: string;
|
|
40
40
|
label: string;
|
|
41
41
|
}
|
|
42
|
-
interface GraphLink {
|
|
42
|
+
export interface GraphLink {
|
|
43
43
|
source: string;
|
|
44
44
|
target: string;
|
|
45
|
+
/** Absent for the default project→leaf spoke; set for the opt-in enrichment edges. */
|
|
46
|
+
kind?: "fragment" | "supersedes" | "contradicts";
|
|
47
|
+
}
|
|
48
|
+
export interface BuildGraphOptions {
|
|
49
|
+
/** Fragment↔fragment edges for fragments co-mentioned in the same documents. */
|
|
50
|
+
includeFragmentEdges?: boolean;
|
|
51
|
+
/** Finding→finding edges from `supersedes` / `contradicts` lifecycle annotations. */
|
|
52
|
+
includeLifecycleEdges?: boolean;
|
|
45
53
|
}
|
|
46
54
|
interface ProjectInfo {
|
|
47
55
|
name: string;
|
|
@@ -92,7 +100,7 @@ export declare function collectSkillsForUI(phrenPath: string, profile?: string):
|
|
|
92
100
|
export declare function getHooksData(phrenPath: string, profile?: string): {
|
|
93
101
|
globalEnabled: boolean;
|
|
94
102
|
tools: {
|
|
95
|
-
tool: "claude" | "
|
|
103
|
+
tool: "claude" | "codex" | "copilot" | "cursor";
|
|
96
104
|
enabled: boolean;
|
|
97
105
|
configPath: string;
|
|
98
106
|
exists: boolean;
|
|
@@ -108,7 +116,7 @@ export declare function getHooksData(phrenPath: string, profile?: string): {
|
|
|
108
116
|
}>;
|
|
109
117
|
}[];
|
|
110
118
|
};
|
|
111
|
-
export declare function buildGraph(phrenPath: string, profile?: string, focusProject?: string, existingDb?: SqlJsDatabase | null): Promise<{
|
|
119
|
+
export declare function buildGraph(phrenPath: string, profile?: string, focusProject?: string, existingDb?: SqlJsDatabase | null, opts?: BuildGraphOptions): Promise<{
|
|
112
120
|
nodes: GraphNode[];
|
|
113
121
|
links: GraphLink[];
|
|
114
122
|
total: number;
|