@phren/cli 0.3.11 → 0.3.12
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/agent-hook-stores.d.ts +3 -0
- package/dist/bridge/agent-hook-stores.js +5 -0
- package/dist/bridge/agent-hooks.d.ts +159 -5
- package/dist/bridge/agent-hooks.js +663 -49
- package/dist/bridge/approval-summary.d.ts +16 -0
- package/dist/bridge/approval-summary.js +133 -0
- package/dist/bridge/authority-command.d.ts +20 -0
- package/dist/bridge/authority-command.js +120 -0
- package/dist/bridge/authority.d.ts +223 -0
- package/dist/bridge/authority.js +231 -0
- package/dist/bridge/claude-account-setup.d.ts +14 -0
- package/dist/bridge/claude-account-setup.js +69 -0
- package/dist/bridge/claude-accounts.d.ts +49 -0
- package/dist/bridge/claude-accounts.js +195 -0
- package/dist/bridge/code-routes.js +2 -2
- package/dist/bridge/codex-app-server.d.ts +144 -0
- package/dist/bridge/codex-app-server.js +319 -0
- package/dist/bridge/codex-auth-refresh.d.ts +33 -0
- package/dist/bridge/codex-auth-refresh.js +71 -0
- package/dist/bridge/codex-question-reply.d.ts +16 -0
- package/dist/bridge/codex-question-reply.js +57 -0
- package/dist/bridge/codex-review-mode.d.ts +10 -0
- package/dist/bridge/codex-review-mode.js +74 -0
- package/dist/bridge/codex-servers.d.ts +217 -0
- package/dist/bridge/codex-servers.js +636 -0
- package/dist/bridge/command.js +94 -4
- package/dist/bridge/computer-identity.d.ts +75 -0
- package/dist/bridge/computer-identity.js +166 -0
- package/dist/bridge/conductor-group.d.ts +91 -8
- package/dist/bridge/conductor-group.js +105 -9
- package/dist/bridge/conductor-role.d.ts +94 -0
- package/dist/bridge/conductor-role.js +176 -0
- package/dist/bridge/conductor-sets.d.ts +20 -0
- package/dist/bridge/conductor-sets.js +59 -0
- package/dist/bridge/dispatch-command.d.ts +3 -0
- package/dist/bridge/dispatch-command.js +75 -11
- package/dist/bridge/dispatch-returns.d.ts +123 -19
- package/dist/bridge/dispatch-returns.js +357 -50
- package/dist/bridge/dispatch.d.ts +103 -2
- package/dist/bridge/dispatch.js +272 -40
- package/dist/bridge/fanouts.d.ts +7 -1
- package/dist/bridge/fanouts.js +39 -4
- package/dist/bridge/folder-trust.d.ts +56 -0
- package/dist/bridge/folder-trust.js +195 -0
- package/dist/bridge/grants.d.ts +22 -1
- package/dist/bridge/grants.js +57 -9
- package/dist/bridge/hand-off.d.ts +21 -9
- package/dist/bridge/hand-off.js +58 -45
- package/dist/bridge/harness-status.d.ts +11 -0
- package/dist/bridge/harness-status.js +32 -0
- package/dist/bridge/harnesses.d.ts +39 -0
- package/dist/bridge/harnesses.js +65 -0
- package/dist/bridge/health.d.ts +2 -0
- package/dist/bridge/health.js +1 -1
- package/dist/bridge/herdr.d.ts +11 -2
- package/dist/bridge/herdr.js +98 -23
- package/dist/bridge/hook-fast.d.ts +4 -0
- package/dist/bridge/hook-fast.js +68 -0
- package/dist/bridge/install.d.ts +16 -1
- package/dist/bridge/install.js +88 -21
- package/dist/bridge/launch-brief.d.ts +96 -0
- package/dist/bridge/launch-brief.js +164 -0
- package/dist/bridge/model-switch.d.ts +3 -0
- package/dist/bridge/model-switch.js +17 -1
- package/dist/bridge/models.d.ts +8 -4
- package/dist/bridge/models.js +24 -8
- package/dist/bridge/mux-wire.d.ts +9 -0
- package/dist/bridge/mux-wire.js +19 -0
- package/dist/bridge/opencode-pane-server.d.ts +113 -0
- package/dist/bridge/opencode-pane-server.js +332 -0
- package/dist/bridge/opencode-panes.d.ts +111 -0
- package/dist/bridge/opencode-panes.js +295 -0
- package/dist/bridge/pane-accounts.d.ts +8 -0
- package/dist/bridge/pane-accounts.js +46 -0
- package/dist/bridge/prompt-startup.d.ts +5 -0
- package/dist/bridge/prompt-startup.js +24 -0
- package/dist/bridge/protocol.d.ts +5 -0
- package/dist/bridge/protocol.js +4 -0
- package/dist/bridge/push.d.ts +5 -4
- package/dist/bridge/push.js +6 -4
- package/dist/bridge/questions.d.ts +37 -2
- package/dist/bridge/questions.js +158 -15
- package/dist/bridge/resources.d.ts +9 -3
- package/dist/bridge/resources.js +24 -8
- package/dist/bridge/schedule-format.d.ts +2 -0
- package/dist/bridge/schedule-format.js +3 -0
- package/dist/bridge/schedule-launch.d.ts +2 -1
- package/dist/bridge/schedule-launch.js +23 -53
- package/dist/bridge/schedule-watch.d.ts +10 -1
- package/dist/bridge/schedule-watch.js +54 -2
- package/dist/bridge/server-launch.d.ts +22 -5
- package/dist/bridge/server-launch.js +225 -29
- package/dist/bridge/server-overview.d.ts +3 -3
- package/dist/bridge/server-overview.js +22 -14
- package/dist/bridge/server-pane-routes.d.ts +2 -0
- package/dist/bridge/server-pane-routes.js +145 -15
- package/dist/bridge/server-routes.d.ts +7 -0
- package/dist/bridge/server-routes.js +163 -35
- package/dist/bridge/server-stream.d.ts +2 -0
- package/dist/bridge/server-stream.js +22 -8
- package/dist/bridge/server.d.ts +6 -1
- package/dist/bridge/server.js +44 -12
- package/dist/bridge/session-activity.d.ts +81 -0
- package/dist/bridge/session-activity.js +117 -0
- package/dist/bridge/session-rename.d.ts +48 -0
- package/dist/bridge/session-rename.js +190 -0
- package/dist/bridge/session-servers.js +2 -2
- package/dist/bridge/settings-switch.d.ts +60 -0
- package/dist/bridge/settings-switch.js +287 -0
- package/dist/bridge/speech-voice.d.ts +55 -0
- package/dist/bridge/speech-voice.js +132 -0
- package/dist/bridge/speech.d.ts +70 -11
- package/dist/bridge/speech.js +169 -41
- package/dist/bridge/terminal-herdr.js +9 -3
- package/dist/bridge/terminal-tmux.d.ts +3 -3
- package/dist/bridge/terminal-tmux.js +24 -9
- package/dist/bridge/terminal.d.ts +27 -4
- package/dist/bridge/terminal.js +8 -1
- package/dist/bridge/transcript-claude.js +57 -12
- package/dist/bridge/transcript-codex.d.ts +0 -2
- package/dist/bridge/transcript-codex.js +29 -4
- package/dist/bridge/transcript-preview.d.ts +1 -0
- package/dist/bridge/transcript-preview.js +24 -4
- package/dist/bridge/transcripts.d.ts +15 -2
- package/dist/bridge/transcripts.js +47 -16
- package/dist/bridge/turn-records.d.ts +85 -0
- package/dist/bridge/turn-records.js +143 -0
- package/dist/bridge/uploads.d.ts +3 -0
- package/dist/bridge/uploads.js +14 -0
- package/dist/bridge/usage.d.ts +39 -10
- package/dist/bridge/usage.js +155 -44
- package/dist/bridge-hook.mjs +19169 -13176
- package/dist/cli/claude-unmanaged.d.ts +12 -0
- package/dist/cli/claude-unmanaged.js +105 -0
- package/dist/cli/schedules.js +2 -1
- package/dist/cli/session-start.js +10 -1
- package/dist/cli/session-stop.js +9 -1
- package/dist/cli-registry.js +24 -5
- package/dist/data/task-receipts.d.ts +19 -0
- package/dist/data/task-receipts.js +68 -0
- package/dist/data/tasks.js +4 -1
- package/dist/generated/memory-ui-graph.browser.js +63 -63
- package/dist/graph-core/model.js +24 -3
- package/dist/graph-core/types.d.ts +4 -1
- package/dist/graph-core/types.js +1 -0
- package/dist/init/init-preset.js +7 -3
- package/dist/init/init-uninstall.js +2 -11
- package/dist/init/teardown.d.ts +3 -0
- package/dist/init/teardown.js +47 -0
- package/dist/link/context.js +21 -9
- package/dist/mcp/plugin-mode.js +1 -1
- package/dist/memory-ui-graph.runtime.js +63 -63
- package/dist/modules/code-package.d.ts +1 -0
- package/dist/modules/code-package.js +36 -7
- package/dist/modules/registry.js +14 -13
- package/dist/profile-store.d.ts +6 -0
- package/dist/profile-store.js +25 -1
- package/dist/shell/graph/glyphs.js +4 -0
- package/dist/shell/graph/graph-view.js +2 -0
- package/dist/status.js +7 -1
- package/dist/sync/task-claim.js +3 -2
- package/dist/task/lifecycle.js +25 -4
- package/dist/test-global-setup.js +5 -0
- package/dist/tools/dispatch.js +35 -2
- package/dist/tools/tasks.js +10 -1
- package/package.json +1 -1
- package/plugins/opencode/phren-transcript.js +87 -4
- package/starter/global/skills/conductor/SKILL.md +17 -2
package/dist/graph-core/model.js
CHANGED
|
@@ -35,6 +35,10 @@ export function deriveKind(node) {
|
|
|
35
35
|
return "entity";
|
|
36
36
|
if (node.group === "reference")
|
|
37
37
|
return "reference";
|
|
38
|
+
if (node.group === "topic")
|
|
39
|
+
return "topic";
|
|
40
|
+
if (node.group === "note")
|
|
41
|
+
return "note";
|
|
38
42
|
if (node.group.startsWith("task-"))
|
|
39
43
|
return "task";
|
|
40
44
|
if (node.group.startsWith("topic:"))
|
|
@@ -102,6 +106,10 @@ export function baseColorForNode(node, storeColor) {
|
|
|
102
106
|
return KIND_COLORS.entity;
|
|
103
107
|
if (kind === "reference")
|
|
104
108
|
return KIND_COLORS.reference;
|
|
109
|
+
if (kind === "topic")
|
|
110
|
+
return topicColor(node.topicSlug);
|
|
111
|
+
if (kind === "note")
|
|
112
|
+
return KIND_COLORS.note;
|
|
105
113
|
return KIND_COLORS.other;
|
|
106
114
|
}
|
|
107
115
|
export function sizeForNode(node, scores) {
|
|
@@ -119,6 +127,10 @@ export function sizeForNode(node, scores) {
|
|
|
119
127
|
return clamp(8 + (node.section === "Active" ? 2 : 0) + (node.priority === "high" ? 1 : 0), 8, 15);
|
|
120
128
|
if (kind === "reference")
|
|
121
129
|
return clamp(7 + Math.sqrt(refCount + 1) * 1.2, 7, 12);
|
|
130
|
+
if (kind === "topic")
|
|
131
|
+
return clamp(10 + Math.sqrt(refCount + 1) * 2.2, 11, 24);
|
|
132
|
+
if (kind === "note")
|
|
133
|
+
return 9;
|
|
122
134
|
return 9;
|
|
123
135
|
}
|
|
124
136
|
export function nodeRadius(node) {
|
|
@@ -148,7 +160,7 @@ export function normalizeNode(node, scores, storeColor) {
|
|
|
148
160
|
health: inferHealth(score),
|
|
149
161
|
baseColor: baseColorForNode(node, storeColor),
|
|
150
162
|
size: sizeForNode(node, scores),
|
|
151
|
-
forceLabel: kind === "project" || (kind === "entity" && (node.refCount || 0) >= 12),
|
|
163
|
+
forceLabel: kind === "project" || (kind === "entity" && (node.refCount || 0) >= 12) || (kind === "topic" && (node.refCount || 0) >= 8),
|
|
152
164
|
};
|
|
153
165
|
}
|
|
154
166
|
/** Undirected adjacency over every node/link, ignoring links to unknown ids. */
|
|
@@ -165,7 +177,7 @@ export function buildFullAdjacency(nodes, links) {
|
|
|
165
177
|
return adjacency;
|
|
166
178
|
}
|
|
167
179
|
export function connectionCounts(model, nodeId) {
|
|
168
|
-
const counts = { total: 0, projects: 0, findings: 0, tasks: 0, entities: 0, references: 0 };
|
|
180
|
+
const counts = { total: 0, projects: 0, findings: 0, tasks: 0, entities: 0, references: 0, topics: 0, notes: 0 };
|
|
169
181
|
const adjacency = model.fullAdjacency.get(nodeId);
|
|
170
182
|
if (!adjacency)
|
|
171
183
|
return counts;
|
|
@@ -184,6 +196,10 @@ export function connectionCounts(model, nodeId) {
|
|
|
184
196
|
counts.entities++;
|
|
185
197
|
else if (neighbor.kind === "reference")
|
|
186
198
|
counts.references++;
|
|
199
|
+
else if (neighbor.kind === "topic")
|
|
200
|
+
counts.topics++;
|
|
201
|
+
else if (neighbor.kind === "note")
|
|
202
|
+
counts.notes++;
|
|
187
203
|
});
|
|
188
204
|
return counts;
|
|
189
205
|
}
|
|
@@ -272,6 +288,10 @@ export function nodeRank(node, filters, scores) {
|
|
|
272
288
|
rank += node.section === "Active" ? 540 : 470;
|
|
273
289
|
if (node.kind === "reference")
|
|
274
290
|
rank += 180 + (node.refCount || 0) * 3;
|
|
291
|
+
if (node.kind === "topic")
|
|
292
|
+
rank += 700 + (node.refCount || 0) * 4;
|
|
293
|
+
if (node.kind === "note")
|
|
294
|
+
rank += 440;
|
|
275
295
|
if (node.priority === "high")
|
|
276
296
|
rank += 60;
|
|
277
297
|
if (node.health === "healthy")
|
|
@@ -459,7 +479,8 @@ export function rankedProjectIds(nodes, project) {
|
|
|
459
479
|
return left > right ? -1 : 1;
|
|
460
480
|
});
|
|
461
481
|
const tasks = nodes.filter((node) => node.project === project && deriveKind(node) === "task");
|
|
462
|
-
|
|
482
|
+
const notes = nodes.filter((node) => node.project === project && deriveKind(node) === "note");
|
|
483
|
+
return [...findings, ...tasks, ...notes].map((node) => node.id);
|
|
463
484
|
}
|
|
464
485
|
/**
|
|
465
486
|
* Previous/next id in a ranked list, wrapping at both ends. The list is the
|
|
@@ -62,7 +62,7 @@ export type GraphPayload = {
|
|
|
62
62
|
scores?: Record<string, ScoreEntry>;
|
|
63
63
|
topics?: RawTopic[];
|
|
64
64
|
};
|
|
65
|
-
export type NodeKind = "project" | "finding" | "task" | "entity" | "reference" | "other";
|
|
65
|
+
export type NodeKind = "project" | "finding" | "task" | "entity" | "reference" | "topic" | "note" | "other";
|
|
66
66
|
export type NodeHealth = "healthy" | "decaying" | "stale";
|
|
67
67
|
export type RuntimeNode = RawNode & {
|
|
68
68
|
kind: NodeKind;
|
|
@@ -86,6 +86,8 @@ export type NodeDetail = RuntimeNode & {
|
|
|
86
86
|
tasks: number;
|
|
87
87
|
entities: number;
|
|
88
88
|
references: number;
|
|
89
|
+
topics: number;
|
|
90
|
+
notes: number;
|
|
89
91
|
};
|
|
90
92
|
score?: ScoreEntry;
|
|
91
93
|
/** Values supplied by the project pane's inline editor on save. */
|
|
@@ -104,6 +106,7 @@ export declare const KIND_COLORS: {
|
|
|
104
106
|
project: string;
|
|
105
107
|
entity: string;
|
|
106
108
|
reference: string;
|
|
109
|
+
note: string;
|
|
107
110
|
"task-active": string;
|
|
108
111
|
"task-queue": string;
|
|
109
112
|
"task-done": string;
|
package/dist/graph-core/types.js
CHANGED
package/dist/init/init-preset.js
CHANGED
|
@@ -12,7 +12,7 @@ import { configureMcpTargets, configureHooksIfEnabled } from "./init-configure.j
|
|
|
12
12
|
import { repairPreexistingInstall } from "./setup.js";
|
|
13
13
|
import { getMcpEnabledPreference, getHooksEnabledPreference, setHooksEnabledPreference, setManagementPresetPreference, } from "./preferences.js";
|
|
14
14
|
import { MANAGEMENT_PRESETS, getManagementPreset, parseManagementPreset, presetSummaryLines, resolveManagementCapabilities, } from "./management-preset.js";
|
|
15
|
-
import { removePhrenHomeSymlinks, removePhrenWrappers, sweepAgentSkillSymlinks, sweepProjectMirrors } from "./teardown.js";
|
|
15
|
+
import { removeGeneratedHomeFiles, removePhrenHomeSymlinks, removePhrenWrappers, sweepAgentSkillSymlinks, sweepProjectMirrors } from "./teardown.js";
|
|
16
16
|
import { printSelfWiringSnippet } from "./self-wiring.js";
|
|
17
17
|
import { DEFAULT_PHREN_PATH, log, confirmPrompt } from "./shared.js";
|
|
18
18
|
function printCapabilityTable(caps) {
|
|
@@ -57,7 +57,8 @@ export async function runPreset(arg, opts = {}) {
|
|
|
57
57
|
const teardownNeeded = (prevCaps.linkGlobalClaudeMd && !caps.linkGlobalClaudeMd) ||
|
|
58
58
|
(prevCaps.installSkillLinks && !caps.installSkillLinks) ||
|
|
59
59
|
(prevCaps.installWrappers && !caps.installWrappers) ||
|
|
60
|
-
(prevCaps.repoMirroring && !caps.repoMirroring)
|
|
60
|
+
(prevCaps.repoMirroring && !caps.repoMirroring) ||
|
|
61
|
+
(prevCaps.selfHeal && !caps.selfHeal);
|
|
61
62
|
if (teardownNeeded && !opts.yes) {
|
|
62
63
|
const ok = await confirmPrompt(`Switching ${previous} → ${preset} will remove phren-owned symlinks/wrappers from your machine and repos. Continue?`);
|
|
63
64
|
if (!ok) {
|
|
@@ -94,10 +95,13 @@ export async function runPreset(arg, opts = {}) {
|
|
|
94
95
|
removePhrenWrappers();
|
|
95
96
|
if (prevCaps.repoMirroring && !caps.repoMirroring)
|
|
96
97
|
sweepProjectMirrors(phrenPath);
|
|
98
|
+
if (prevCaps.selfHeal && !caps.selfHeal)
|
|
99
|
+
removeGeneratedHomeFiles();
|
|
97
100
|
// Setup of artifacts the new preset adds but the previous one lacked.
|
|
98
101
|
const setupNeeded = (!prevCaps.linkGlobalClaudeMd && caps.linkGlobalClaudeMd) ||
|
|
99
102
|
(!prevCaps.installSkillLinks && caps.installSkillLinks) ||
|
|
100
|
-
(!prevCaps.repoMirroring && caps.repoMirroring)
|
|
103
|
+
(!prevCaps.repoMirroring && caps.repoMirroring) ||
|
|
104
|
+
(!prevCaps.selfHeal && caps.selfHeal);
|
|
101
105
|
if (setupNeeded) {
|
|
102
106
|
try {
|
|
103
107
|
repairPreexistingInstall(phrenPath, { caps, preset });
|
|
@@ -10,7 +10,7 @@ import { FINDINGS_FILENAME } from "../data/access.js";
|
|
|
10
10
|
import { codexJsonCandidates, copilotMcpCandidates, cursorMcpCandidates, vscodeMcpCandidates, } from "../provider-adapters.js";
|
|
11
11
|
import { removeMcpServerAtPath, removeTomlMcpServer, isPhrenCommand, patchJsonFile, } from "./config.js";
|
|
12
12
|
import { DEFAULT_PHREN_PATH, log } from "./shared.js";
|
|
13
|
-
import { sweepProjectMirrors } from "./teardown.js";
|
|
13
|
+
import { removeGeneratedHomeFiles, sweepProjectMirrors } from "./teardown.js";
|
|
14
14
|
const PHREN_NPM_PACKAGE_NAME = "@phren/cli";
|
|
15
15
|
function getNpmCommand() {
|
|
16
16
|
return process.platform === "win32" ? "npm.cmd" : "npm";
|
|
@@ -429,16 +429,7 @@ export async function runUninstall(opts = {}) {
|
|
|
429
429
|
catch (err) {
|
|
430
430
|
debugLog(`uninstall: cleanup failed for ${machineFile}: ${errorMessage(err)}`);
|
|
431
431
|
}
|
|
432
|
-
|
|
433
|
-
try {
|
|
434
|
-
if (fs.existsSync(contextFile)) {
|
|
435
|
-
fs.unlinkSync(contextFile);
|
|
436
|
-
log(` Removed machine context file (${contextFile})`);
|
|
437
|
-
}
|
|
438
|
-
}
|
|
439
|
-
catch (err) {
|
|
440
|
-
debugLog(`uninstall: cleanup failed for ${contextFile}: ${errorMessage(err)}`);
|
|
441
|
-
}
|
|
432
|
+
removeGeneratedHomeFiles();
|
|
442
433
|
// Remove global AGENTS.md symlink (created by linkGlobal -> ~/.claude/CLAUDE.md)
|
|
443
434
|
const globalClaudeLink = homePath(".claude", "CLAUDE.md");
|
|
444
435
|
try {
|
package/dist/init/teardown.d.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
export declare function generatedRootMemoryPath(): string;
|
|
2
|
+
/** Remove only complete managed blocks; surrounding notes and unmarked files survive. */
|
|
3
|
+
export declare function removeGeneratedHomeFiles(): string[];
|
|
1
4
|
/** Remove the phren-owned ~/.claude/CLAUDE.md and copilot-instructions.md symlinks. */
|
|
2
5
|
export declare function removePhrenHomeSymlinks(): string[];
|
|
3
6
|
/** Remove ~/.local/bin/{copilot,cursor,codex,phren} wrappers that carry the phren marker. */
|
package/dist/init/teardown.js
CHANGED
|
@@ -24,6 +24,53 @@ function agentSkillDirs() {
|
|
|
24
24
|
path.join(home, ".codex", "skills"),
|
|
25
25
|
];
|
|
26
26
|
}
|
|
27
|
+
export function generatedRootMemoryPath() {
|
|
28
|
+
const home = homeDir();
|
|
29
|
+
const key = home.replace(/[/\\:]/g, "-").replace(/^-/, "");
|
|
30
|
+
return path.join(home, ".claude", "projects", key, "memory", "MEMORY.md");
|
|
31
|
+
}
|
|
32
|
+
/** Remove only complete managed blocks; surrounding notes and unmarked files survive. */
|
|
33
|
+
export function removeGeneratedHomeFiles() {
|
|
34
|
+
const changed = [];
|
|
35
|
+
const targets = [
|
|
36
|
+
{ file: homePath(".phren-context.md"), start: "<!-- phren-managed -->", end: "<!-- phren-managed -->" },
|
|
37
|
+
{ file: generatedRootMemoryPath(), start: "<!-- phren:projects:start -->", end: "<!-- phren:projects:end -->" },
|
|
38
|
+
];
|
|
39
|
+
for (const { file, start, end } of targets) {
|
|
40
|
+
try {
|
|
41
|
+
// A symlink may point at a user's unrelated file, even if it has a marker.
|
|
42
|
+
if (!fs.existsSync(file) || !fs.lstatSync(file).isFile())
|
|
43
|
+
continue;
|
|
44
|
+
const content = fs.readFileSync(file, "utf8");
|
|
45
|
+
const first = content.indexOf(start);
|
|
46
|
+
const last = content.indexOf(end, first + start.length);
|
|
47
|
+
if (first < 0 || last < 0)
|
|
48
|
+
continue;
|
|
49
|
+
let remaining = content.slice(0, first) + content.slice(last + end.length);
|
|
50
|
+
// This exact introduction is generated alongside the root projects block.
|
|
51
|
+
// Custom introductions and any notes following the block remain intact.
|
|
52
|
+
const generatedIntros = [
|
|
53
|
+
"# Root Memory\n\n## Machine Context\nRead `~/.phren-context.md` for profile, active projects, and sync metadata.\n\n",
|
|
54
|
+
"# Root Memory\n\n## Machine Context\nRead `~/.phren-context.md` for profile, active projects, last sync date.\n\n## Cross-Project Notes\n- Read a project's AGENTS.md before making changes.\n- Per-project memory files (MEMORY-{name}.md) have commands, versions, findings.\n\n",
|
|
55
|
+
];
|
|
56
|
+
if (file === generatedRootMemoryPath()) {
|
|
57
|
+
const introduction = generatedIntros.find((intro) => remaining.startsWith(intro));
|
|
58
|
+
if (introduction)
|
|
59
|
+
remaining = remaining.slice(introduction.length);
|
|
60
|
+
}
|
|
61
|
+
if (remaining.trim())
|
|
62
|
+
fs.writeFileSync(file, remaining);
|
|
63
|
+
else
|
|
64
|
+
fs.unlinkSync(file);
|
|
65
|
+
changed.push(file);
|
|
66
|
+
log(` Removed phren-managed content: ${file}`);
|
|
67
|
+
}
|
|
68
|
+
catch (err) {
|
|
69
|
+
debugLog(`removeGeneratedHomeFiles: cleanup failed for ${file}: ${errorMessage(err)}`);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return changed;
|
|
73
|
+
}
|
|
27
74
|
/** Remove the phren-owned ~/.claude/CLAUDE.md and copilot-instructions.md symlinks. */
|
|
28
75
|
export function removePhrenHomeSymlinks() {
|
|
29
76
|
const removed = [];
|
package/dist/link/context.js
CHANGED
|
@@ -192,13 +192,9 @@ export function rebuildMemory(phrenPath, projects) {
|
|
|
192
192
|
if (!hasSummaries)
|
|
193
193
|
return;
|
|
194
194
|
fs.mkdirSync(memoryDir, { recursive: true });
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
const idx = existing.indexOf("<!-- phren:projects:start -->");
|
|
199
|
-
if (idx !== -1)
|
|
200
|
-
header = existing.slice(0, idx);
|
|
201
|
-
}
|
|
195
|
+
const existing = fs.existsSync(memoryFile) ? fs.readFileSync(memoryFile, "utf8") : "";
|
|
196
|
+
const projectsStart = "<!-- phren:projects:start -->";
|
|
197
|
+
const projectsEnd = "<!-- phren:projects:end -->";
|
|
202
198
|
let managed = "<!-- phren:projects:start -->\n<!-- Auto-generated by phren link. Do not edit below this line. -->\n\n## Active Projects\n\n| Project | What | Memory |\n|---------|------|--------|\n";
|
|
203
199
|
for (const project of projects) {
|
|
204
200
|
if (project === "global")
|
|
@@ -213,8 +209,24 @@ export function rebuildMemory(phrenPath, projects) {
|
|
|
213
209
|
}
|
|
214
210
|
managed += "\n<!-- phren:projects:end -->";
|
|
215
211
|
const freshHeader = "# Root Memory\n\n## Machine Context\nRead `~/.phren-context.md` for profile, active projects, last sync date.\n\n## Cross-Project Notes\n- Read a project's AGENTS.md before making changes.\n- Per-project memory files (MEMORY-{name}.md) have commands, versions, findings.\n\n";
|
|
216
|
-
|
|
217
|
-
|
|
212
|
+
const start = existing.indexOf(projectsStart);
|
|
213
|
+
const end = existing.indexOf(projectsEnd);
|
|
214
|
+
let updated = existing;
|
|
215
|
+
if (start === -1 && end === -1) {
|
|
216
|
+
// A preset downgrade removes our block but leaves the owner's notes.
|
|
217
|
+
// An unmarked file is user content, not an empty generated header.
|
|
218
|
+
const header = existing || freshHeader;
|
|
219
|
+
const separator = header.endsWith("\n\n") ? "" : header.endsWith("\n") ? "\n" : "\n\n";
|
|
220
|
+
updated = header + separator + managed + "\n";
|
|
221
|
+
}
|
|
222
|
+
else if (start !== -1 && end > start) {
|
|
223
|
+
updated = existing.slice(0, start) + managed + existing.slice(end + projectsEnd.length);
|
|
224
|
+
}
|
|
225
|
+
// Incomplete or reversed markers cannot establish ownership: leave them alone.
|
|
226
|
+
if (updated !== existing) {
|
|
227
|
+
fs.writeFileSync(memoryFile, updated);
|
|
228
|
+
log(` rebuilt ${memoryFile} (pointer format)`);
|
|
229
|
+
}
|
|
218
230
|
const SUMMARY_START = "<!-- phren:summary:start -->";
|
|
219
231
|
const SUMMARY_END = "<!-- phren:summary:end -->";
|
|
220
232
|
for (const project of projects) {
|
package/dist/mcp/plugin-mode.js
CHANGED
|
@@ -49,7 +49,7 @@ export function setupMessage() {
|
|
|
49
49
|
"",
|
|
50
50
|
"Setup runs `phren init --yes`, which:",
|
|
51
51
|
"- creates the store at ~/.phren (a local git repo; nothing leaves the machine unless you add a remote)",
|
|
52
|
-
"-
|
|
52
|
+
"- wires Claude Code's memory hooks and MCP server (the plugin yields wherever init's wiring loads)",
|
|
53
53
|
"- wires any other agents it detects (Codex, Copilot CLI, Cursor, VS Code)",
|
|
54
54
|
"",
|
|
55
55
|
"Ask the user before running it. Afterwards, Claude Code needs a restart to load the memory tools.",
|