@phren/cli 0.3.5 → 0.3.7
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/bridge/terminal-choice.js +9 -2
- package/dist/bridge/transcript-copilot.d.ts +3 -2
- package/dist/bridge/transcript-copilot.js +26 -7
- package/dist/bridge-hook.mjs +21 -6
- package/dist/entrypoint.d.ts +2 -0
- package/dist/entrypoint.js +3 -0
- package/dist/index.js +8 -2
- package/dist/mcp/plugin-mode.d.ts +16 -0
- package/dist/mcp/plugin-mode.js +106 -0
- package/package.json +1 -1
- package/starter/global/skills/phren-consolidate/SKILL.md +1 -1
- package/starter/global/skills/phren-discover/SKILL.md +1 -1
- package/starter/global/skills/phren-init/SKILL.md +6 -8
- package/starter/global/skills/phren-profiles/SKILL.md +1 -1
- package/starter/global/skills/phren-summarize/SKILL.md +1 -1
- package/starter/global/skills/phren-sync/SKILL.md +1 -1
|
@@ -173,7 +173,14 @@ export function opencodePermissionDialog(ansi) {
|
|
|
173
173
|
// Lines pushed far right are OpenCode's status column, not the question.
|
|
174
174
|
const body = plain.slice(header + 1, row).map(content)
|
|
175
175
|
.filter(line => line.trim() && !/^\s{24,}/.test(line)).map(line => line.trim());
|
|
176
|
-
|
|
176
|
+
// "← Access external directory ~/apps" is what it asks; a "Patterns" list
|
|
177
|
+
// under it is what it applies to, one "- " line each.
|
|
178
|
+
const [asks, ...rest] = body;
|
|
179
|
+
const title = (asks?.replace(/^[←→]\s*/, "") || "Permission required").slice(0, 4_000);
|
|
180
|
+
const patterns = rest.indexOf("Patterns");
|
|
181
|
+
const details = patterns < 0 ? rest
|
|
182
|
+
: [...rest.slice(0, patterns), ...rest.slice(patterns + 1).map(line => line.replace(/^-\s+/, ""))];
|
|
183
|
+
const detail = details.join("\n").slice(0, 4_000);
|
|
177
184
|
const backgrounds = OPENCODE_OPTIONS.map(label => {
|
|
178
185
|
const at = raw[row].indexOf(label);
|
|
179
186
|
if (at < 0)
|
|
@@ -183,7 +190,7 @@ export function opencodePermissionDialog(ansi) {
|
|
|
183
190
|
});
|
|
184
191
|
const unique = backgrounds.flatMap((background, index) => background !== undefined && backgrounds.filter(other => other === background).length === 1 ? [index] : []);
|
|
185
192
|
const selected = unique.length === 1 && backgrounds.every(background => background !== undefined) ? unique[0] : undefined;
|
|
186
|
-
return { choice: { title, options: [{ label: "Allow once", key: "1", hasKey: false }, { label: "Reject", key: "Escape", hasKey: true }],
|
|
193
|
+
return { choice: { title, ...(detail ? { body: detail } : {}), options: [{ label: "Allow once", key: "1", hasKey: false }, { label: "Reject", key: "Escape", hasKey: true }],
|
|
187
194
|
...(selected === 0 ? { highlightedIndex: 0 } : {}) }, ...(selected !== undefined ? { selected } : {}) };
|
|
188
195
|
}
|
|
189
196
|
/** The pane's last non-empty line is a password read: sudo's "[sudo] password
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type Json } from "./protocol.js";
|
|
2
|
-
/** Copilot's transcript reader: public message, tool and usage events,
|
|
3
|
-
*
|
|
2
|
+
/** Copilot's transcript reader: public message, tool and usage events, and
|
|
3
|
+
* the reasoning summary Copilot itself prints under "Thought for Ns". Its
|
|
4
|
+
* encrypted and opaque reasoning stays out. */
|
|
4
5
|
export declare function visibleCopilotEvent(raw: Json): Json | undefined;
|
|
@@ -1,14 +1,33 @@
|
|
|
1
1
|
import { object } from "./protocol.js";
|
|
2
|
-
/** Copilot's transcript reader: public message, tool and usage events,
|
|
3
|
-
*
|
|
2
|
+
/** Copilot's transcript reader: public message, tool and usage events, and
|
|
3
|
+
* the reasoning summary Copilot itself prints under "Thought for Ns". Its
|
|
4
|
+
* encrypted and opaque reasoning stays out. */
|
|
4
5
|
export function visibleCopilotEvent(raw) {
|
|
5
|
-
if (raw.agentId || raw.ephemeral
|
|
6
|
+
if (raw.agentId || raw.ephemeral)
|
|
7
|
+
return undefined;
|
|
8
|
+
// What a skill loaded: Copilot answers the `skill` call with only "Skill
|
|
9
|
+
// loaded", then writes the SKILL.md it put in context as `skill.invoked`.
|
|
10
|
+
if (raw.type === "skill.invoked") {
|
|
11
|
+
const data = object(raw.data);
|
|
12
|
+
if (typeof data.name !== "string" || typeof data.content !== "string")
|
|
13
|
+
return undefined;
|
|
14
|
+
return { type: raw.type, timestamp: raw.timestamp, data: { name: data.name.slice(0, 200), content: data.content.slice(0, 65_536),
|
|
15
|
+
...(typeof data.description === "string" ? { description: data.description.slice(0, 1_000) } : {}) } };
|
|
16
|
+
}
|
|
17
|
+
if (!["user.message", "assistant.message", "assistant.message_delta", "tool.execution_start", "tool.execution_complete", "assistant.turn_start", "assistant.turn_end", "session.idle", "abort", "session.error", "session.usage_info", "assistant.usage"].includes(String(raw.type)))
|
|
6
18
|
return undefined;
|
|
7
19
|
const data = object(raw.data);
|
|
8
|
-
// Copilot
|
|
9
|
-
//
|
|
20
|
+
// Copilot writes its reasoning beside the message three ways: the summary
|
|
21
|
+
// its terminal shows (`reasoningText`), and encrypted/opaque copies for the
|
|
22
|
+
// model (`encryptedContent`, `reasoningOpaque`, `reasoningBlocks`). Only the
|
|
23
|
+
// summary the person already sees in the terminal is exported.
|
|
10
24
|
// `phase` marks Copilot 1.0.87's final answer (it writes no session.idle);
|
|
11
25
|
// `success` is false on a failed tool run.
|
|
12
|
-
const allowed = ["content", "source", "messageId", "deltaContent", "toolName", "toolCallId", "arguments", "result", "error", "success", "phase", "aborted", "inputTokens", "outputTokens", "cacheReadTokens"];
|
|
13
|
-
return { type: raw.type, timestamp: raw.timestamp, data: Object.fromEntries(Object.entries(data)
|
|
26
|
+
const allowed = ["content", "source", "messageId", "deltaContent", "toolName", "toolCallId", "arguments", "result", "error", "success", "phase", "aborted", "reasoningText", "mcpServerName", "mcpToolName", "inputTokens", "outputTokens", "cacheReadTokens"];
|
|
27
|
+
return { type: raw.type, timestamp: raw.timestamp, data: Object.fromEntries(Object.entries(data)
|
|
28
|
+
// The MCP server and tool a call went to (`phren` + `get_tasks` for the
|
|
29
|
+
// `phren-get_tasks` tool), so the phone draws the server's own card.
|
|
30
|
+
.filter(([key, value]) => allowed.includes(key) && (key !== "reasoningText" || (raw.type === "assistant.message" && typeof value === "string"))
|
|
31
|
+
&& (!["mcpServerName", "mcpToolName"].includes(key) || (typeof value === "string" && value.length <= 200)))
|
|
32
|
+
.map(([key, value]) => [key, key === "reasoningText" ? String(value).slice(0, 8_000) : value])) };
|
|
14
33
|
}
|
package/dist/bridge-hook.mjs
CHANGED
|
@@ -22258,10 +22258,20 @@ var init_transcript_codex = __esm({
|
|
|
22258
22258
|
|
|
22259
22259
|
// src/bridge/transcript-copilot.ts
|
|
22260
22260
|
function visibleCopilotEvent(raw) {
|
|
22261
|
-
if (raw.agentId || raw.ephemeral
|
|
22261
|
+
if (raw.agentId || raw.ephemeral) return void 0;
|
|
22262
|
+
if (raw.type === "skill.invoked") {
|
|
22263
|
+
const data2 = object2(raw.data);
|
|
22264
|
+
if (typeof data2.name !== "string" || typeof data2.content !== "string") return void 0;
|
|
22265
|
+
return { type: raw.type, timestamp: raw.timestamp, data: {
|
|
22266
|
+
name: data2.name.slice(0, 200),
|
|
22267
|
+
content: data2.content.slice(0, 65536),
|
|
22268
|
+
...typeof data2.description === "string" ? { description: data2.description.slice(0, 1e3) } : {}
|
|
22269
|
+
} };
|
|
22270
|
+
}
|
|
22271
|
+
if (!["user.message", "assistant.message", "assistant.message_delta", "tool.execution_start", "tool.execution_complete", "assistant.turn_start", "assistant.turn_end", "session.idle", "abort", "session.error", "session.usage_info", "assistant.usage"].includes(String(raw.type))) return void 0;
|
|
22262
22272
|
const data = object2(raw.data);
|
|
22263
|
-
const allowed = ["content", "source", "messageId", "deltaContent", "toolName", "toolCallId", "arguments", "result", "error", "success", "phase", "aborted", "inputTokens", "outputTokens", "cacheReadTokens"];
|
|
22264
|
-
return { type: raw.type, timestamp: raw.timestamp, data: Object.fromEntries(Object.entries(data).filter(([key2]) => allowed.includes(key2))) };
|
|
22273
|
+
const allowed = ["content", "source", "messageId", "deltaContent", "toolName", "toolCallId", "arguments", "result", "error", "success", "phase", "aborted", "reasoningText", "mcpServerName", "mcpToolName", "inputTokens", "outputTokens", "cacheReadTokens"];
|
|
22274
|
+
return { type: raw.type, timestamp: raw.timestamp, data: Object.fromEntries(Object.entries(data).filter(([key2, value2]) => allowed.includes(key2) && (key2 !== "reasoningText" || raw.type === "assistant.message" && typeof value2 === "string") && (!["mcpServerName", "mcpToolName"].includes(key2) || typeof value2 === "string" && value2.length <= 200)).map(([key2, value2]) => [key2, key2 === "reasoningText" ? String(value2).slice(0, 8e3) : value2])) };
|
|
22265
22275
|
}
|
|
22266
22276
|
var init_transcript_copilot = __esm({
|
|
22267
22277
|
"src/bridge/transcript-copilot.ts"() {
|
|
@@ -28307,7 +28317,7 @@ var init_package_metadata = __esm({
|
|
|
28307
28317
|
__dirname = path24.dirname(fileURLToPath2(import.meta.url));
|
|
28308
28318
|
ROOT = path24.join(__dirname, "..");
|
|
28309
28319
|
PACKAGE_JSON_PATH = path24.join(ROOT, "package.json");
|
|
28310
|
-
BUNDLED_VERSION = true ? "0.3.
|
|
28320
|
+
BUNDLED_VERSION = true ? "0.3.7" : "0.0.0";
|
|
28311
28321
|
PACKAGE_JSON = readPackageJson();
|
|
28312
28322
|
PACKAGE_NAME = PACKAGE_JSON.name || "phren";
|
|
28313
28323
|
VERSION = PACKAGE_JSON.version || BUNDLED_VERSION;
|
|
@@ -32641,7 +32651,11 @@ function opencodePermissionDialog(ansi) {
|
|
|
32641
32651
|
const row = plain2.findIndex((line, index2) => index2 > header2 && OPENCODE_OPTIONS.every((label2) => line.includes(label2)));
|
|
32642
32652
|
if (row < 0 || row - header2 > 24) return void 0;
|
|
32643
32653
|
const body2 = plain2.slice(header2 + 1, row).map(content).filter((line) => line.trim() && !/^\s{24,}/.test(line)).map((line) => line.trim());
|
|
32644
|
-
const
|
|
32654
|
+
const [asks, ...rest] = body2;
|
|
32655
|
+
const title = (asks?.replace(/^[←→]\s*/, "") || "Permission required").slice(0, 4e3);
|
|
32656
|
+
const patterns = rest.indexOf("Patterns");
|
|
32657
|
+
const details = patterns < 0 ? rest : [...rest.slice(0, patterns), ...rest.slice(patterns + 1).map((line) => line.replace(/^-\s+/, ""))];
|
|
32658
|
+
const detail = details.join("\n").slice(0, 4e3);
|
|
32645
32659
|
const backgrounds = OPENCODE_OPTIONS.map((label2) => {
|
|
32646
32660
|
const at = raw[row].indexOf(label2);
|
|
32647
32661
|
if (at < 0) return void 0;
|
|
@@ -32652,6 +32666,7 @@ function opencodePermissionDialog(ansi) {
|
|
|
32652
32666
|
const selected = unique.length === 1 && backgrounds.every((background) => background !== void 0) ? unique[0] : void 0;
|
|
32653
32667
|
return { choice: {
|
|
32654
32668
|
title,
|
|
32669
|
+
...detail ? { body: detail } : {},
|
|
32655
32670
|
options: [{ label: "Allow once", key: "1", hasKey: false }, { label: "Reject", key: "Escape", hasKey: true }],
|
|
32656
32671
|
...selected === 0 ? { highlightedIndex: 0 } : {}
|
|
32657
32672
|
}, ...selected !== void 0 ? { selected } : {} };
|
|
@@ -50515,7 +50530,7 @@ async function readSecret(prompt) {
|
|
|
50515
50530
|
// src/bridge/hook-main.ts
|
|
50516
50531
|
init_utils_helpers();
|
|
50517
50532
|
Object.assign(process.env, nonInteractiveGitEnv());
|
|
50518
|
-
runBridge(process.argv.slice(2), "0.3.
|
|
50533
|
+
runBridge(process.argv.slice(2), "0.3.7").then((code) => {
|
|
50519
50534
|
process.exitCode = code;
|
|
50520
50535
|
}).catch((error62) => {
|
|
50521
50536
|
console.error(error62 instanceof Error ? error62.message : "Phren Hook failed.");
|
package/dist/entrypoint.d.ts
CHANGED
package/dist/entrypoint.js
CHANGED
|
@@ -30,6 +30,9 @@ export function resolveTopLevelInvocation(argv) {
|
|
|
30
30
|
if (looksLikePhrenRootArg(positional)) {
|
|
31
31
|
return { kind: "mcp", phrenArg: positional };
|
|
32
32
|
}
|
|
33
|
+
if (argvCommand === "mcp" && argv.length === 1) {
|
|
34
|
+
return { kind: "mcp-serve" };
|
|
35
|
+
}
|
|
33
36
|
if (argvCommand === "--help" || argvCommand === "-h") {
|
|
34
37
|
// `phren --help all` reads like `phren help all`, so it does the same.
|
|
35
38
|
return argv.length > 1 ? { kind: "manage", argv } : { kind: "help" };
|
package/dist/index.js
CHANGED
|
@@ -6,6 +6,7 @@ import { log as structuredLog, logger } from "./logger.js";
|
|
|
6
6
|
import { errorMessage } from "./utils.js";
|
|
7
7
|
import { nonInteractiveGitEnv } from "./utils-helpers.js";
|
|
8
8
|
import { printIntegratedHelp, printIntegratedVersion, resolveTopLevelInvocation, runTopLevelCommand, } from "./entrypoint.js";
|
|
9
|
+
import { pluginSetupReason, runPluginSetupServer } from "./mcp/plugin-mode.js";
|
|
9
10
|
// NOTE: the MCP-server-only module graph (MCP SDK, FTS indexer, tool registries,
|
|
10
11
|
// startup-embedding, custom-hook engine) is intentionally NOT imported here. It is
|
|
11
12
|
// dynamically imported inside main() so that top-level commands — hook-prompt,
|
|
@@ -30,7 +31,12 @@ if (invocation.kind === "manage") {
|
|
|
30
31
|
}
|
|
31
32
|
process.exit(process.exitCode ?? 0);
|
|
32
33
|
}
|
|
33
|
-
|
|
34
|
+
// `phren mcp` (the Claude Code plugin) with no store yet, or with `phren init`'s
|
|
35
|
+
// own server already registered, serves a small setup / empty server instead.
|
|
36
|
+
const pluginSetup = invocation.kind === "mcp-serve" ? pluginSetupReason() : null;
|
|
37
|
+
const phrenPath = pluginSetup
|
|
38
|
+
? ""
|
|
39
|
+
: findPhrenPathWithArg(invocation.kind === "mcp" ? invocation.phrenArg : undefined);
|
|
34
40
|
const STALE_LOCK_MS = 120_000; // 2 min — slightly above EXEC_TIMEOUT_MS (30s) to avoid blocking healthy writers
|
|
35
41
|
function cleanStaleLocks(phrenPath) {
|
|
36
42
|
const dir = runtimeDir(phrenPath);
|
|
@@ -342,7 +348,7 @@ async function main() {
|
|
|
342
348
|
process.on("SIGTERM", () => void shutdown("SIGTERM"));
|
|
343
349
|
process.on("SIGINT", () => void shutdown("SIGINT"));
|
|
344
350
|
}
|
|
345
|
-
main().catch((err) => {
|
|
351
|
+
(pluginSetup ? runPluginSetupServer(pluginSetup) : main()).catch((err) => {
|
|
346
352
|
console.error("Failed to start phren-mcp:", err);
|
|
347
353
|
process.exit(1);
|
|
348
354
|
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export type PluginSetupReason = "no-store" | "stand-down";
|
|
2
|
+
/**
|
|
3
|
+
* True when Claude Code will also load a user-level `phren` server that
|
|
4
|
+
* `phren init` registered. Claude Code reads user MCP servers from
|
|
5
|
+
* `.claude.json` (inside CLAUDE_CONFIG_DIR when set), not from settings.json,
|
|
6
|
+
* so an entry only in settings.json does not count.
|
|
7
|
+
*/
|
|
8
|
+
export declare function userLevelPhrenMcpConfigured(env?: NodeJS.ProcessEnv): boolean;
|
|
9
|
+
/** Why `phren mcp` should not start the full server, or null when it should. */
|
|
10
|
+
export declare function pluginSetupReason(env?: NodeJS.ProcessEnv): PluginSetupReason | null;
|
|
11
|
+
export declare function setupMessage(): string;
|
|
12
|
+
export declare function runInitForPlugin(): {
|
|
13
|
+
ok: boolean;
|
|
14
|
+
output: string;
|
|
15
|
+
};
|
|
16
|
+
export declare function runPluginSetupServer(reason: PluginSetupReason): Promise<void>;
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `phren mcp`: the MCP server as the Claude Code plugin starts it.
|
|
3
|
+
*
|
|
4
|
+
* The plugin cannot pass a store path (it does not know one), so `phren mcp`
|
|
5
|
+
* finds the store itself. Two cases then need something other than the full
|
|
6
|
+
* server:
|
|
7
|
+
*
|
|
8
|
+
* - no store yet (a plugin-only user on first run): a small server whose one
|
|
9
|
+
* tool explains setup and, once the user agrees, runs `phren init --yes`;
|
|
10
|
+
* - `phren init` already registered its own `phren` server for Claude Code and
|
|
11
|
+
* the plugin launched this one (PHREN_MCP_OWNER=plugin): an empty server, so
|
|
12
|
+
* the user does not see every phren tool twice.
|
|
13
|
+
*/
|
|
14
|
+
import * as fs from "fs";
|
|
15
|
+
import * as path from "path";
|
|
16
|
+
import { spawnSync } from "child_process";
|
|
17
|
+
import { findPhrenPath, homePath } from "../phren-paths.js";
|
|
18
|
+
function hasPhrenServer(filePath) {
|
|
19
|
+
try {
|
|
20
|
+
const data = JSON.parse(fs.readFileSync(filePath, "utf8"));
|
|
21
|
+
return Boolean(data?.mcpServers && typeof data.mcpServers === "object" && data.mcpServers.phren);
|
|
22
|
+
}
|
|
23
|
+
catch {
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* True when Claude Code will also load a user-level `phren` server that
|
|
29
|
+
* `phren init` registered. Claude Code reads user MCP servers from
|
|
30
|
+
* `.claude.json` (inside CLAUDE_CONFIG_DIR when set), not from settings.json,
|
|
31
|
+
* so an entry only in settings.json does not count.
|
|
32
|
+
*/
|
|
33
|
+
export function userLevelPhrenMcpConfigured(env = process.env) {
|
|
34
|
+
const configDir = env.CLAUDE_CONFIG_DIR?.trim();
|
|
35
|
+
return hasPhrenServer(configDir ? path.join(configDir, ".claude.json") : homePath(".claude.json"));
|
|
36
|
+
}
|
|
37
|
+
/** Why `phren mcp` should not start the full server, or null when it should. */
|
|
38
|
+
export function pluginSetupReason(env = process.env) {
|
|
39
|
+
if (env.PHREN_MCP_OWNER === "plugin" && userLevelPhrenMcpConfigured(env))
|
|
40
|
+
return "stand-down";
|
|
41
|
+
return findPhrenPath() ? null : "no-store";
|
|
42
|
+
}
|
|
43
|
+
const NO_STORE_INSTRUCTIONS = "phren gives this agent memory across sessions (findings, tasks, project context), but it has no store on this machine yet. " +
|
|
44
|
+
"When the user asks about phren or memory, call phren_setup to explain setup, and only call it with confirm=true after they agree.";
|
|
45
|
+
const STAND_DOWN_INSTRUCTIONS = "phren is already registered as its own MCP server by `phren init`; use that server's tools. This plugin copy stays empty so nothing appears twice.";
|
|
46
|
+
export function setupMessage() {
|
|
47
|
+
return [
|
|
48
|
+
"phren has no memory store on this machine yet.",
|
|
49
|
+
"",
|
|
50
|
+
"Setup runs `phren init --yes`, which:",
|
|
51
|
+
"- creates the store at ~/.phren (a local git repo; nothing leaves the machine unless you add a remote)",
|
|
52
|
+
"- registers phren's MCP server and memory hooks in ~/.claude/settings.json (the plugin's own copies then stand down)",
|
|
53
|
+
"- wires any other agents it detects (Codex, Copilot CLI, Cursor, VS Code)",
|
|
54
|
+
"",
|
|
55
|
+
"Ask the user before running it. Afterwards, Claude Code needs a restart to load the memory tools.",
|
|
56
|
+
].join("\n");
|
|
57
|
+
}
|
|
58
|
+
export function runInitForPlugin() {
|
|
59
|
+
const entry = process.argv[1];
|
|
60
|
+
const result = spawnSync(process.execPath, [entry, "init", "--yes"], {
|
|
61
|
+
encoding: "utf8",
|
|
62
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
63
|
+
timeout: 180_000,
|
|
64
|
+
env: { ...process.env, PHREN_MCP_OWNER: "" },
|
|
65
|
+
});
|
|
66
|
+
const output = `${result.stdout ?? ""}${result.stderr ?? ""}`.trim();
|
|
67
|
+
const tail = output.split("\n").slice(-25).join("\n");
|
|
68
|
+
return { ok: result.status === 0, output: tail || (result.error ? String(result.error) : "") };
|
|
69
|
+
}
|
|
70
|
+
export async function runPluginSetupServer(reason) {
|
|
71
|
+
const [{ McpServer }, { StdioServerTransport }, { z }, { VERSION }] = await Promise.all([
|
|
72
|
+
import("@modelcontextprotocol/sdk/server/mcp.js"),
|
|
73
|
+
import("@modelcontextprotocol/sdk/server/stdio.js"),
|
|
74
|
+
import("zod"),
|
|
75
|
+
import("../package-metadata.js"),
|
|
76
|
+
]);
|
|
77
|
+
const server = new McpServer({ name: "phren-mcp", version: VERSION }, { instructions: reason === "no-store" ? NO_STORE_INSTRUCTIONS : STAND_DOWN_INSTRUCTIONS });
|
|
78
|
+
if (reason === "no-store") {
|
|
79
|
+
server.registerTool("phren_setup", {
|
|
80
|
+
title: "◆ phren · set up memory",
|
|
81
|
+
description: "phren has no memory store on this machine yet. Call without arguments to get what setup does; " +
|
|
82
|
+
"call with confirm=true, only after the user agrees, to run `phren init --yes` (creates ~/.phren and wires Claude Code). Restart Claude Code afterwards.",
|
|
83
|
+
inputSchema: z.object({
|
|
84
|
+
confirm: z.boolean().optional().describe("true runs setup now. Only after the user agreed."),
|
|
85
|
+
}),
|
|
86
|
+
}, async ({ confirm }) => {
|
|
87
|
+
if (!confirm)
|
|
88
|
+
return { content: [{ type: "text", text: setupMessage() }] };
|
|
89
|
+
const result = runInitForPlugin();
|
|
90
|
+
const next = result.ok
|
|
91
|
+
? "\n\nphren is set up. Restart Claude Code so its memory tools and hooks load."
|
|
92
|
+
: "\n\nSetup failed. The user can run `npx -y @phren/cli init` in a terminal instead.";
|
|
93
|
+
return { content: [{ type: "text", text: `${result.output}${next}` }], isError: !result.ok };
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
else {
|
|
97
|
+
// An empty but well-formed tool list, so clients that list tools
|
|
98
|
+
// regardless of capabilities get [] rather than "method not found".
|
|
99
|
+
const { ListToolsRequestSchema } = await import("@modelcontextprotocol/sdk/types.js");
|
|
100
|
+
server.server.registerCapabilities({ tools: {} });
|
|
101
|
+
server.server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: [] }));
|
|
102
|
+
}
|
|
103
|
+
const transport = new StdioServerTransport();
|
|
104
|
+
await server.connect(transport);
|
|
105
|
+
console.error(`phren-mcp running in plugin ${reason} mode`);
|
|
106
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: phren-consolidate
|
|
3
|
-
description: Find patterns across
|
|
3
|
+
description: Find patterns that repeat across several projects' phren findings and promote the ones that apply everywhere into shared global memory.
|
|
4
4
|
dependencies:
|
|
5
5
|
- git
|
|
6
6
|
---
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: phren-discover
|
|
3
|
-
description: Audit
|
|
3
|
+
description: Audit the phren memory store and report what needs attention, such as stale content, projects missing a summary, skill gaps and unhealthy task queues, with the top three things to fix.
|
|
4
4
|
dependencies:
|
|
5
5
|
- git
|
|
6
6
|
- gh
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: phren-init
|
|
3
|
-
description: Set up
|
|
3
|
+
description: Set up phren memory. Creates the store with `phren init` on first use, or adds the current project to an existing store with its summary, AGENTS.md and task list. Use when phren reports no store or the user wants a project remembered.
|
|
4
4
|
dependencies:
|
|
5
5
|
- git
|
|
6
6
|
---
|
|
@@ -24,17 +24,15 @@ PHREN_DIR="${PHREN_DIR:-$HOME/.phren}"
|
|
|
24
24
|
ls "$PHREN_DIR" 2>/dev/null
|
|
25
25
|
```
|
|
26
26
|
|
|
27
|
-
If the phren directory doesn't exist,
|
|
28
|
-
> "
|
|
27
|
+
If the phren directory doesn't exist, this is a first run. Offer to set phren up:
|
|
28
|
+
> "phren has no memory store on this machine yet. Want me to run `phren init`? It creates a local git-backed store at ~/.phren and registers phren's memory hooks and MCP server with Claude Code (and any other agents it finds). Nothing leaves this machine unless you add a git remote."
|
|
29
29
|
|
|
30
|
-
If the user says yes,
|
|
30
|
+
If the user says yes, let the CLI build the store; never create it by hand:
|
|
31
31
|
```bash
|
|
32
|
-
|
|
33
|
-
# Create a starter machines.yaml
|
|
34
|
-
# Create a starter profile
|
|
32
|
+
if command -v phren >/dev/null 2>&1; then phren init --yes; else npx -y @phren/cli init --yes; fi
|
|
35
33
|
```
|
|
36
34
|
|
|
37
|
-
|
|
35
|
+
If phren's MCP server is running in setup mode it offers the same thing as the `phren_setup` tool (`confirm: true` runs it). Either way, tell the user to restart Claude Code afterwards so the memory tools and hooks load, then continue with the project scaffolding below if they named a project.
|
|
38
36
|
|
|
39
37
|
## With a project name
|
|
40
38
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: phren-profiles
|
|
3
|
-
description:
|
|
3
|
+
description: Inspect or change which projects each machine loads from the phren store (machine-to-profile and profile-to-project mappings). Only for users who sync phren across several machines.
|
|
4
4
|
dependencies:
|
|
5
5
|
- git
|
|
6
6
|
---
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: phren-summarize
|
|
3
|
-
description: Write the "what we know" paragraph for each topic archive
|
|
3
|
+
description: Write the grounded "what we know" paragraph for each phren topic archive from the bullets phren provides, using the model already running. No API key or local model needed.
|
|
4
4
|
---
|
|
5
5
|
# /phren-summarize
|
|
6
6
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: phren-sync
|
|
3
|
-
description: Pull
|
|
3
|
+
description: Pull the phren memory store onto this machine (and wire it with `phren init`) or push local memory changes to its git remote. Use on a new machine or when memory on another machine should catch up.
|
|
4
4
|
dependencies:
|
|
5
5
|
- git
|
|
6
6
|
---
|