@phren/cli 0.1.42 → 0.1.45
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/capabilities/cli.js +1 -1
- package/dist/capabilities/mcp.js +1 -1
- package/dist/capabilities/vscode.js +3 -3
- package/dist/capabilities/web-ui.js +29 -29
- 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-output.js +15 -6
- package/dist/cli/hooks.d.ts +1 -1
- package/dist/cli/hooks.js +16 -5
- package/dist/cli/session-stop.d.ts +1 -1
- package/dist/cli/session-tool-hook.d.ts +1 -1
- package/dist/cli-registry.js +1 -1
- package/dist/data/access.js +2 -1
- package/dist/generated/memory-ui-graph.browser.js +481 -318
- package/dist/governance/locks.js +6 -0
- package/dist/governance/scores.d.ts +9 -1
- package/dist/governance/scores.js +12 -1
- 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 +355 -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 +13 -3
- 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 +481 -318
- 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.d.ts +2 -0
- package/dist/profile-store.js +16 -19
- package/dist/project-config.js +2 -1
- package/dist/shared/fragment-graph.js +7 -2
- package/dist/shared/index.js +1 -1
- package/dist/shared/retrieval.d.ts +38 -0
- package/dist/shared/retrieval.js +62 -4
- package/dist/shell/entry.d.ts +10 -2
- package/dist/shell/entry.js +128 -97
- package/dist/shell/graph/canvas.d.ts +64 -0
- package/dist/shell/graph/canvas.js +256 -0
- package/dist/shell/graph/controller.d.ts +164 -0
- package/dist/shell/graph/controller.js +645 -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 +12 -0
- package/dist/shell/graph/graph-view.js +408 -0
- package/dist/shell/graph/layout.d.ts +68 -0
- package/dist/shell/graph/layout.js +267 -0
- package/dist/shell/input.d.ts +4 -1
- package/dist/shell/input.js +28 -5
- package/dist/shell/intro.d.ts +37 -0
- package/dist/shell/intro.js +82 -0
- package/dist/shell/keys.d.ts +36 -0
- package/dist/shell/keys.js +107 -0
- package/dist/shell/logo-fx.d.ts +35 -0
- package/dist/shell/logo-fx.js +128 -0
- package/dist/shell/render.d.ts +34 -1
- package/dist/shell/render.js +220 -66
- package/dist/shell/shell.d.ts +13 -1
- package/dist/shell/shell.js +61 -10
- package/dist/shell/startup.d.ts +37 -0
- package/dist/shell/startup.js +105 -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 +26 -4
- package/dist/store-registry.d.ts +13 -0
- package/dist/store-registry.js +109 -37
- 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/tools/memory.js +12 -5
- package/dist/tools/ops.js +1 -1
- package/dist/ui/data.d.ts +15 -7
- package/dist/ui/data.js +102 -3
- 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 +38 -7
- package/starter/global/skills/phren-consolidate/SKILL.md +152 -0
- package/starter/global/skills/phren-discover/SKILL.md +175 -0
- package/starter/global/skills/phren-init/SKILL.md +216 -0
- package/starter/global/skills/phren-profiles/SKILL.md +121 -0
- package/starter/global/skills/phren-sync/SKILL.md +261 -0
- package/dist/init-uninstall.d.ts +0 -3
- package/dist/init-uninstall.js +0 -514
- package/dist/init-walkthrough.d.ts +0 -55
- package/dist/init-walkthrough.js +0 -524
package/dist/shell/shell.js
CHANGED
|
@@ -9,6 +9,17 @@ 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";
|
|
13
|
+
/** Remove the final character, keeping surrogate pairs and combining marks intact. */
|
|
14
|
+
function dropLastCharacter(s) {
|
|
15
|
+
if (!s)
|
|
16
|
+
return s;
|
|
17
|
+
const chars = [...s];
|
|
18
|
+
chars.pop();
|
|
19
|
+
while (chars.length && /\p{M}/u.test(chars[chars.length - 1]))
|
|
20
|
+
chars.pop();
|
|
21
|
+
return chars.join("");
|
|
22
|
+
}
|
|
12
23
|
// ── Shell class ──────────────────────────────────────────────────────────────
|
|
13
24
|
export class PhrenShell {
|
|
14
25
|
phrenPath;
|
|
@@ -29,6 +40,8 @@ export class PhrenShell {
|
|
|
29
40
|
viewScrollMap = {};
|
|
30
41
|
healthLineCount = 0;
|
|
31
42
|
_subsectionsCache = null;
|
|
43
|
+
_graph;
|
|
44
|
+
repaintHandler = null;
|
|
32
45
|
get mode() { return this.navMode; }
|
|
33
46
|
get inputBuffer() { return this.inputBuf; }
|
|
34
47
|
get filter() { return this.state.filter; }
|
|
@@ -37,23 +50,47 @@ export class PhrenShell {
|
|
|
37
50
|
runRelink: defaultRunRelink,
|
|
38
51
|
runHooks: defaultRunHooks,
|
|
39
52
|
runUpdate: defaultRunUpdate,
|
|
40
|
-
}) {
|
|
53
|
+
}, startup = {}) {
|
|
41
54
|
this.phrenPath = phrenPath;
|
|
42
55
|
this.profile = profile;
|
|
43
56
|
this.deps = deps;
|
|
44
57
|
this.state = loadShellState(phrenPath);
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
58
|
+
// A deep link (`phren shell --view tasks --here`) wins over the view the
|
|
59
|
+
// last session happened to leave behind; without one we always land home.
|
|
60
|
+
if (startup.project)
|
|
61
|
+
this.state.project = startup.project;
|
|
62
|
+
this.state.view = startup.view ?? "Projects";
|
|
63
|
+
this.message = startup.notice
|
|
64
|
+
? ` ${style.yellow("⚠")} ${startup.notice}`
|
|
65
|
+
: this.state.project
|
|
66
|
+
? ` Dashboard ready — active context ${style.boldCyan(this.state.project)}`
|
|
67
|
+
: ` Dashboard ready — choose a project with ${style.boldCyan("↵")} or stay global`;
|
|
49
68
|
}
|
|
50
|
-
close() { saveShellState(this.phrenPath, this.state); }
|
|
69
|
+
close() { this._graph?.dispose(); saveShellState(this.phrenPath, this.state); }
|
|
51
70
|
setMessage(msg) { this.message = msg; }
|
|
71
|
+
/**
|
|
72
|
+
* Let the host (entry.ts) hand over a way to repaint on the shell's own
|
|
73
|
+
* initiative — the graph view uses it to animate its layout settling and
|
|
74
|
+
* to show a build that finished while nothing was typed.
|
|
75
|
+
*/
|
|
76
|
+
setRepaintHandler(handler) {
|
|
77
|
+
this.repaintHandler = handler;
|
|
78
|
+
this._graph?.setRepaintHook(handler);
|
|
79
|
+
}
|
|
80
|
+
graph() {
|
|
81
|
+
if (!this._graph) {
|
|
82
|
+
this._graph = new GraphController(this.phrenPath, this.profile);
|
|
83
|
+
this._graph.setRepaintHook(this.repaintHandler);
|
|
84
|
+
}
|
|
85
|
+
return this._graph;
|
|
86
|
+
}
|
|
52
87
|
confirmThen(label, action) {
|
|
53
88
|
this.pendingConfirm = { label, action };
|
|
54
89
|
this.setMessage(`${label} ${style.boldCyan("y")} ${style.dim("confirm")} ${style.boldCyan("n")} ${style.dim("cancel")}`);
|
|
55
90
|
}
|
|
56
91
|
setView(view) {
|
|
92
|
+
if (this.state.view === "Graph" && view !== "Graph")
|
|
93
|
+
this._graph?.stopAnimation();
|
|
57
94
|
this.state.view = view;
|
|
58
95
|
this.viewScrollMap[view] = 0;
|
|
59
96
|
saveShellState(this.phrenPath, this.state);
|
|
@@ -116,7 +153,7 @@ export class PhrenShell {
|
|
|
116
153
|
this.navMode = "navigate";
|
|
117
154
|
this.inputBuf = "";
|
|
118
155
|
this.inputCtx = "";
|
|
119
|
-
if (!buf.trim() && ctx !== "command") {
|
|
156
|
+
if (!buf.trim() && ctx !== "command" && ctx !== "graph-search") {
|
|
120
157
|
this.setMessage(" Nothing entered.");
|
|
121
158
|
return;
|
|
122
159
|
}
|
|
@@ -124,6 +161,15 @@ export class PhrenShell {
|
|
|
124
161
|
case "filter":
|
|
125
162
|
this.setFilter(buf);
|
|
126
163
|
break;
|
|
164
|
+
case "graph-search": {
|
|
165
|
+
const graph = this.graph();
|
|
166
|
+
const best = graph.applySearch(buf);
|
|
167
|
+
if (best)
|
|
168
|
+
this.setMessage(` ${style.yellow(`1/${graph.search.results.length}`)} ${graph.describe(best).trimStart()}`);
|
|
169
|
+
else
|
|
170
|
+
this.setMessage(buf.trim() ? ` ${style.dim("no matches for")} ${style.yellow(buf.trim())}` : ` ${style.dim("search cleared")}`);
|
|
171
|
+
break;
|
|
172
|
+
}
|
|
127
173
|
case "command":
|
|
128
174
|
await this.runPalette(buf.startsWith(":") ? buf.slice(1) : buf);
|
|
129
175
|
break;
|
|
@@ -198,12 +244,15 @@ export class PhrenShell {
|
|
|
198
244
|
return true;
|
|
199
245
|
}
|
|
200
246
|
if (key === "\x7f" || key === "\x08") {
|
|
201
|
-
this.inputBuf = this.inputBuf
|
|
247
|
+
this.inputBuf = dropLastCharacter(this.inputBuf);
|
|
202
248
|
return true;
|
|
203
249
|
}
|
|
204
|
-
if (key.startsWith("\x1b
|
|
250
|
+
if (key.startsWith("\x1b"))
|
|
205
251
|
return true;
|
|
206
|
-
|
|
252
|
+
// Accept any printable key. Astral characters (emoji, and anything else the
|
|
253
|
+
// user pastes) span two UTF-16 units, so this cannot test key.length === 1.
|
|
254
|
+
const cp = key.codePointAt(0);
|
|
255
|
+
if (cp !== undefined && cp >= 32 && cp !== 0x7f) {
|
|
207
256
|
this.inputBuf += key;
|
|
208
257
|
return true;
|
|
209
258
|
}
|
|
@@ -223,6 +272,7 @@ export class PhrenShell {
|
|
|
223
272
|
phrenPath: this.phrenPath, profile: this.profile, state: this.state,
|
|
224
273
|
currentCursor: () => this.currentCursor(), currentScroll: () => this.currentScroll(),
|
|
225
274
|
setScroll: (n) => this.setScroll(n),
|
|
275
|
+
graph: () => this.graph(),
|
|
226
276
|
};
|
|
227
277
|
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; });
|
|
228
278
|
}
|
|
@@ -248,6 +298,7 @@ export class PhrenShell {
|
|
|
248
298
|
moveCursor: (delta) => this.moveCursor(delta),
|
|
249
299
|
getListItems: () => this.getListItems(),
|
|
250
300
|
startInput: (ctx, initial) => this.startInput(ctx, initial),
|
|
301
|
+
graph: () => this.graph(),
|
|
251
302
|
};
|
|
252
303
|
}
|
|
253
304
|
// ── Palette (delegates to shell-input.ts) ──────────────────────────────
|
|
@@ -0,0 +1,37 @@
|
|
|
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
|
+
/** Shown on the shell's message line — fullscreen mode eats anything printed before launch. */
|
|
13
|
+
notice?: string;
|
|
14
|
+
}
|
|
15
|
+
export interface ShellStartupArgs {
|
|
16
|
+
view?: string;
|
|
17
|
+
project?: string;
|
|
18
|
+
here?: boolean;
|
|
19
|
+
unknown?: string;
|
|
20
|
+
}
|
|
21
|
+
export declare function normalizeShellView(raw: string | undefined): ShellView | undefined;
|
|
22
|
+
export declare const SHELL_VIEW_ALIASES: string[];
|
|
23
|
+
/** Parse `--view`/`--project`/`--here`, in both `--flag value` and `--flag=value` form. */
|
|
24
|
+
export declare function parseShellArgs(args: string[]): ShellStartupArgs;
|
|
25
|
+
/**
|
|
26
|
+
* Turn parsed flags into the state the shell should open in. An unresolvable
|
|
27
|
+
* view or project is dropped rather than fatal — a deep link that misses should
|
|
28
|
+
* still land you in the shell, on the home screen, with everything else intact.
|
|
29
|
+
*/
|
|
30
|
+
export declare function resolveShellStartup(parsed: ShellStartupArgs, opts: {
|
|
31
|
+
phrenPath: string;
|
|
32
|
+
profile?: string;
|
|
33
|
+
cwd?: string;
|
|
34
|
+
}): {
|
|
35
|
+
startup: ShellStartup;
|
|
36
|
+
warnings: string[];
|
|
37
|
+
};
|
|
@@ -0,0 +1,105 @@
|
|
|
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
|
+
default:
|
|
66
|
+
if (flag.startsWith("-") && parsed.unknown === undefined)
|
|
67
|
+
parsed.unknown = flag;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return parsed;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Turn parsed flags into the state the shell should open in. An unresolvable
|
|
74
|
+
* view or project is dropped rather than fatal — a deep link that misses should
|
|
75
|
+
* still land you in the shell, on the home screen, with everything else intact.
|
|
76
|
+
*/
|
|
77
|
+
export function resolveShellStartup(parsed, opts) {
|
|
78
|
+
const warnings = [];
|
|
79
|
+
const startup = {};
|
|
80
|
+
if (parsed.unknown)
|
|
81
|
+
warnings.push(`Unknown flag ${parsed.unknown} — ignored.`);
|
|
82
|
+
if (parsed.view) {
|
|
83
|
+
const view = normalizeShellView(parsed.view);
|
|
84
|
+
if (view)
|
|
85
|
+
startup.view = view;
|
|
86
|
+
else
|
|
87
|
+
warnings.push(`Unknown view "${parsed.view}" — opening on Projects.`);
|
|
88
|
+
}
|
|
89
|
+
if (parsed.project) {
|
|
90
|
+
startup.project = parsed.project;
|
|
91
|
+
}
|
|
92
|
+
else if (parsed.here) {
|
|
93
|
+
const detected = detectProject(opts.phrenPath, opts.cwd ?? process.cwd(), opts.profile);
|
|
94
|
+
if (detected)
|
|
95
|
+
startup.project = detected;
|
|
96
|
+
else
|
|
97
|
+
warnings.push("No phren project for this directory — opening without a project.");
|
|
98
|
+
}
|
|
99
|
+
// These views render an empty "no project selected" screen without a project,
|
|
100
|
+
// which is a worse landing spot than the project list the user came from.
|
|
101
|
+
if (!startup.project && startup.view && PROJECT_SCOPED_VIEWS.has(startup.view)) {
|
|
102
|
+
startup.view = undefined;
|
|
103
|
+
}
|
|
104
|
+
return { startup, warnings };
|
|
105
|
+
}
|
|
@@ -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
|
@@ -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 } 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)))
|
|
@@ -36,6 +37,10 @@ function renderTabBar(state) {
|
|
|
36
37
|
const label = `${TAB_ICONS.Health} Health`;
|
|
37
38
|
return ` ${style.boldMagenta(label)}\n${separator(cols)}`;
|
|
38
39
|
}
|
|
40
|
+
if (state.view === "Graph") {
|
|
41
|
+
const label = `${TAB_ICONS.Graph} Graph`;
|
|
42
|
+
return ` ${style.boldMagenta(label)}\n${separator(cols)}`;
|
|
43
|
+
}
|
|
39
44
|
if (state.view === "Projects") {
|
|
40
45
|
const label = `${TAB_ICONS.Projects} Projects`;
|
|
41
46
|
const tabLine = ` ${style.boldMagenta(label)} `;
|
|
@@ -73,6 +78,7 @@ function renderBottomBar(state, navMode, inputCtx, inputBuf) {
|
|
|
73
78
|
add: "add task",
|
|
74
79
|
"learn-add": "add finding",
|
|
75
80
|
"skill-add": "new skill name",
|
|
81
|
+
"graph-search": "search graph",
|
|
76
82
|
};
|
|
77
83
|
const label = labels[inputCtx] || inputCtx;
|
|
78
84
|
return `${sep}\n ${style.boldCyan(label + " ›")} ${inputBuf}${style.cyan("█")}`;
|
|
@@ -85,15 +91,20 @@ function renderBottomBar(state, navMode, inputCtx, inputBuf) {
|
|
|
85
91
|
Skills: [`${k("a")} ${d("add")}`, `${k("t")} ${d("toggle")}`, `${k("d")} ${d("remove")}`],
|
|
86
92
|
Hooks: [`${k("a")} ${d("enable")}`, `${k("d")} ${d("disable")}`],
|
|
87
93
|
Health: [`${k("↑↓")} ${d("scroll")}`, `${k("esc")} ${d("back")}`],
|
|
94
|
+
Graph: [`${k("↑↓←→")} ${d("walk")}`, `${k("↵")} ${d("select")}`, `${k("f")} ${d("filter")}`, `${k("[ ]")} ${d("project")}`, `${k("esc")} ${d("back")}`],
|
|
88
95
|
};
|
|
89
96
|
const extra = viewHints[state.view] ?? [];
|
|
90
|
-
const isSubView = state.view !== "Projects" && state.view !== "Health";
|
|
97
|
+
const isSubView = state.view !== "Projects" && state.view !== "Health" && state.view !== "Graph";
|
|
91
98
|
const nav = isSubView
|
|
92
99
|
? [`${k("←→")} ${d("tabs")}`, `${k("↑↓")} ${d("move")}`, `${k("esc")} ${d("back")}`]
|
|
93
|
-
: state.view === "Health"
|
|
100
|
+
: state.view === "Health" || state.view === "Graph"
|
|
94
101
|
? []
|
|
95
102
|
: [`${k("↑↓")} ${d("move")}`];
|
|
96
|
-
const tail = [
|
|
103
|
+
const tail = [
|
|
104
|
+
state.view === "Graph" ? `${k("h")} ${d("health")}` : `${k("g")} ${d("graph")}`,
|
|
105
|
+
`${k("/")} ${d(state.view === "Graph" ? "search" : "filter")}`,
|
|
106
|
+
`${k(":")} ${d("cmd")}`, `${k("?")} ${d("help")}`, `${k("q")} ${d("quit")}`,
|
|
107
|
+
];
|
|
97
108
|
const hints = [...nav, ...extra, ...tail];
|
|
98
109
|
return `${sep}\n${wrapSegments(hints, cols, {
|
|
99
110
|
indent: " ",
|
|
@@ -193,7 +204,8 @@ function renderProjectsView(ctx, cursor, height) {
|
|
|
193
204
|
const bullet = isActive ? style.green("●") : style.dim("○");
|
|
194
205
|
const nameStr = isActive ? style.boldGreen(card.name) : style.bold(card.name);
|
|
195
206
|
const docsStr = style.dim(`[A${card.activeCount} · Q${card.queueCount} · F${card.findingCount} · R${card.reviewCount}]`);
|
|
196
|
-
|
|
207
|
+
const storeStr = card.store ? ` ${style.dim("·")} ${style.cyan(card.store)}` : "";
|
|
208
|
+
let nameRow = ` ${cursorChar} ${bullet} ${nameStr} ${docsStr}${storeStr}`;
|
|
197
209
|
let summaryRow = ` ${style.dim(card.summary || "No summary yet.")}`;
|
|
198
210
|
if (isSelected) {
|
|
199
211
|
nameRow = formatSelectableLine(nameRow, cols, true);
|
|
@@ -708,6 +720,16 @@ export async function renderShell(ctx, navMode, inputCtx, inputBuf, showHelp, me
|
|
|
708
720
|
setHealthLineCount(result.lineCount);
|
|
709
721
|
break;
|
|
710
722
|
}
|
|
723
|
+
case "Graph": {
|
|
724
|
+
if (!ctx.graph) {
|
|
725
|
+
contentLines = [" The graph view needs the interactive shell — run `phren shell`."];
|
|
726
|
+
break;
|
|
727
|
+
}
|
|
728
|
+
const controller = ctx.graph();
|
|
729
|
+
await controller.ensureData();
|
|
730
|
+
contentLines = renderGraphView(controller, renderWidth(), height);
|
|
731
|
+
break;
|
|
732
|
+
}
|
|
711
733
|
default:
|
|
712
734
|
contentLines = [" Unknown view."];
|
|
713
735
|
}
|
package/dist/store-registry.d.ts
CHANGED
|
@@ -35,6 +35,19 @@ export interface TeamBootstrap {
|
|
|
35
35
|
export declare const STORES_FILENAME = "stores.yaml";
|
|
36
36
|
export declare function storesFilePath(phrenPath: string): string;
|
|
37
37
|
export declare function generateStoreId(): string;
|
|
38
|
+
/**
|
|
39
|
+
* What a registry read actually found. `registry` is what could be honored;
|
|
40
|
+
* `problems` says what couldn't; `lossy` means stores.yaml EXISTS but the
|
|
41
|
+
* result does not fully represent it (unreadable, unparsable, entries
|
|
42
|
+
* skipped, or validation failed). Mutators must refuse to write while a read
|
|
43
|
+
* is lossy — writing back would silently destroy the entries we skipped.
|
|
44
|
+
*/
|
|
45
|
+
export interface RegistryReadResult {
|
|
46
|
+
registry: StoreRegistry | null;
|
|
47
|
+
problems: string[];
|
|
48
|
+
lossy: boolean;
|
|
49
|
+
}
|
|
50
|
+
export declare function readStoreRegistryDetailed(phrenPath: string): RegistryReadResult;
|
|
38
51
|
export declare function readStoreRegistry(phrenPath: string): StoreRegistry | null;
|
|
39
52
|
export declare function writeStoreRegistry(phrenPath: string, registry: StoreRegistry): void;
|
|
40
53
|
/** True when a store's directory exists on this machine. */
|