@phren/cli 0.1.35 → 0.1.37
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/web-ui.js +1 -1
- package/dist/data/access.js +26 -1
- package/dist/generated/memory-ui-graph.browser.js +5958 -294
- package/dist/hooks.d.ts +9 -0
- package/dist/hooks.js +17 -1
- package/dist/init/init-configure.js +13 -0
- package/dist/link/doctor.js +14 -1
- package/dist/memory-ui-graph.runtime.js +5958 -294
- package/dist/ui/data.d.ts +5 -0
- package/dist/ui/data.js +46 -7
- package/dist/ui/graph-chrome.d.ts +1 -0
- package/dist/ui/graph-chrome.js +194 -0
- package/dist/ui/graph.js +1 -1
- package/dist/ui/page.js +3 -0
- package/dist/ui/scripts.js +313 -44
- package/dist/ui/server.js +34 -2
- package/package.json +3 -4
package/dist/hooks.d.ts
CHANGED
|
@@ -5,6 +5,15 @@ export interface HookError {
|
|
|
5
5
|
}
|
|
6
6
|
export declare function commandExists(cmd: string): boolean;
|
|
7
7
|
export declare function detectInstalledTools(): Set<string>;
|
|
8
|
+
/**
|
|
9
|
+
* True if a path lives inside an ephemeral npx download cache
|
|
10
|
+
* (`~/.npm/_npx/<hash>/…`). Baking such a path into a hook command that has no
|
|
11
|
+
* self-healing fallback is fragile: npx prunes that cache and the `<hash>`
|
|
12
|
+
* segment changes between versions, silently breaking every phren hook. Hook
|
|
13
|
+
* commands that resolve here must fall back to `npx -y <spec>` (which
|
|
14
|
+
* re-resolves on every run) or the ~/.local/bin/phren wrapper instead.
|
|
15
|
+
*/
|
|
16
|
+
export declare function isEphemeralNpxPath(p: string): boolean;
|
|
8
17
|
/** Shell-escape a value by wrapping in single quotes with proper escaping of embedded single quotes. */
|
|
9
18
|
export declare function shellEscape(s: string): string;
|
|
10
19
|
export interface LifecycleCommands {
|
package/dist/hooks.js
CHANGED
|
@@ -65,6 +65,17 @@ function resolveCliEntryScript() {
|
|
|
65
65
|
const local = path.join(path.dirname(fileURLToPath(import.meta.url)), "index.js");
|
|
66
66
|
return fs.existsSync(local) ? local : null;
|
|
67
67
|
}
|
|
68
|
+
/**
|
|
69
|
+
* True if a path lives inside an ephemeral npx download cache
|
|
70
|
+
* (`~/.npm/_npx/<hash>/…`). Baking such a path into a hook command that has no
|
|
71
|
+
* self-healing fallback is fragile: npx prunes that cache and the `<hash>`
|
|
72
|
+
* segment changes between versions, silently breaking every phren hook. Hook
|
|
73
|
+
* commands that resolve here must fall back to `npx -y <spec>` (which
|
|
74
|
+
* re-resolves on every run) or the ~/.local/bin/phren wrapper instead.
|
|
75
|
+
*/
|
|
76
|
+
export function isEphemeralNpxPath(p) {
|
|
77
|
+
return /(^|[/\\])_npx[/\\]/.test(p);
|
|
78
|
+
}
|
|
68
79
|
function phrenPackageSpec() {
|
|
69
80
|
return PACKAGE_SPEC;
|
|
70
81
|
}
|
|
@@ -82,7 +93,12 @@ function buildPackageLifecycleCommands() {
|
|
|
82
93
|
};
|
|
83
94
|
}
|
|
84
95
|
export function buildLifecycleCommands(phrenPath, options = {}) {
|
|
85
|
-
const
|
|
96
|
+
const rawEntry = resolveCliEntryScript();
|
|
97
|
+
// A bare `node <entry>` hook has no fallback if <entry> disappears. When the
|
|
98
|
+
// package is running from the npx cache, that entry path is ephemeral, so we
|
|
99
|
+
// drop it here and let resolution fall through to the ~/.local/bin/phren
|
|
100
|
+
// wrapper (preferred) or the self-healing `npx -y <spec>` last resort.
|
|
101
|
+
const entry = rawEntry && !isEphemeralNpxPath(rawEntry) ? rawEntry : null;
|
|
86
102
|
const nativeWindows = process.platform === "win32" && !options.forcePosix;
|
|
87
103
|
const escapedPhren = phrenPath.replace(/\\/g, "\\\\").replace(/"/g, '\\"');
|
|
88
104
|
const quotedPhren = shellEscape(phrenPath);
|
|
@@ -20,6 +20,19 @@ import { log } from "./shared.js";
|
|
|
20
20
|
* @param verb - label used in log messages, e.g. "Updated" or "Configured"
|
|
21
21
|
*/
|
|
22
22
|
export function configureMcpTargets(phrenPath, opts, verb = "Configured") {
|
|
23
|
+
// Install the stable ~/.local/bin/phren wrapper BEFORE writing any hook
|
|
24
|
+
// commands. buildLifecycleCommands prefers that wrapper (it carries an npx
|
|
25
|
+
// fallback, so it survives nvm switches and npx cache clears); if it doesn't
|
|
26
|
+
// yet exist, hook commands fall through to the ephemeral npx-cache entry path
|
|
27
|
+
// and break the next time npx prunes its cache. configureHooksIfEnabled runs
|
|
28
|
+
// later and re-installs the wrapper idempotently, emitting the user-facing
|
|
29
|
+
// "CLI wrapper" line — this early install is intentionally silent.
|
|
30
|
+
try {
|
|
31
|
+
installPhrenCliWrapper(phrenPath);
|
|
32
|
+
}
|
|
33
|
+
catch (err) {
|
|
34
|
+
debugLog(`configureMcpTargets: early wrapper install failed: ${errorMessage(err)}`);
|
|
35
|
+
}
|
|
23
36
|
let claudeStatus = "no_settings";
|
|
24
37
|
try {
|
|
25
38
|
const status = configureClaude(phrenPath, { mcpEnabled: opts.mcpEnabled, hooksEnabled: opts.hooksEnabled });
|
package/dist/link/doctor.js
CHANGED
|
@@ -8,7 +8,7 @@ import { validateGovernanceJson } from "../shared/governance.js";
|
|
|
8
8
|
import { errorMessage } from "../utils.js";
|
|
9
9
|
import { buildIndex, queryRows } from "../shared/index.js";
|
|
10
10
|
import { validateTaskFormat, validateFindingsFormat } from "../shared/content.js";
|
|
11
|
-
import { detectInstalledTools } from "../hooks.js";
|
|
11
|
+
import { detectInstalledTools, isEphemeralNpxPath } from "../hooks.js";
|
|
12
12
|
import { validateSkillFrontmatter, validateSkillsDir } from "./skills.js";
|
|
13
13
|
import { verifyFileChecksums, updateFileChecksums } from "./checksums.js";
|
|
14
14
|
import { buildSkillManifest } from "../skill/registry.js";
|
|
@@ -329,6 +329,7 @@ export async function runDoctor(phrenPath, fix = false, checkData = false) {
|
|
|
329
329
|
});
|
|
330
330
|
let hookOk = false;
|
|
331
331
|
let lifecycleOk = false;
|
|
332
|
+
let hooksEphemeral = false;
|
|
332
333
|
try {
|
|
333
334
|
const cfg = JSON.parse(fs.readFileSync(settingsPath, "utf8"));
|
|
334
335
|
const hooks = cfg?.hooks || {};
|
|
@@ -339,6 +340,11 @@ export async function runDoctor(phrenPath, fix = false, checkData = false) {
|
|
|
339
340
|
const stopHookOk = stopHooks.includes("hook-stop");
|
|
340
341
|
const startHookOk = startHooks.includes("hook-session-start");
|
|
341
342
|
lifecycleOk = stopHookOk && startHookOk;
|
|
343
|
+
// A hook command that points into the npx cache (~/.npm/_npx/<hash>/…)
|
|
344
|
+
// works until npx prunes that cache, then breaks silently. Flag it so a
|
|
345
|
+
// re-init (which now resolves to the stable ~/.local/bin/phren wrapper)
|
|
346
|
+
// can repair it before the user notices context has stopped flowing.
|
|
347
|
+
hooksEphemeral = [promptHooks, stopHooks, startHooks].some(isEphemeralNpxPath);
|
|
342
348
|
}
|
|
343
349
|
catch (err) {
|
|
344
350
|
debugLog(`doctor: failed to read Claude settings for hook check: ${errorMessage(err)}`);
|
|
@@ -357,6 +363,13 @@ export async function runDoctor(phrenPath, fix = false, checkData = false) {
|
|
|
357
363
|
? "session-start + stop lifecycle hooks configured"
|
|
358
364
|
: "missing lifecycle hooks (expected hook-session-start and hook-stop)",
|
|
359
365
|
});
|
|
366
|
+
checks.push({
|
|
367
|
+
name: "hook-path-stable",
|
|
368
|
+
ok: !hooksEphemeral,
|
|
369
|
+
detail: hooksEphemeral
|
|
370
|
+
? "hook commands point into the ephemeral npx cache (~/.npm/_npx/…); re-run `npx @phren/cli init` to repoint at the stable ~/.local/bin/phren wrapper"
|
|
371
|
+
: "hook commands use a stable entrypoint",
|
|
372
|
+
});
|
|
360
373
|
const runtimeHealthPath = runtimeHealthFile(phrenPath);
|
|
361
374
|
let runtime = null;
|
|
362
375
|
if (fs.existsSync(runtimeHealthPath)) {
|