coding-friend-cli 1.27.1 → 1.28.0
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/README.md +9 -3
- package/dist/{chunk-PRIH34UB.js → chunk-DHH6SRXV.js} +5 -1
- package/dist/{chunk-75IEE2OE.js → chunk-E7OY4UWW.js} +2 -2
- package/dist/chunk-J4N2ODQ5.js +191 -0
- package/dist/{chunk-YCWRBOB3.js → chunk-RGQGKOBH.js} +1 -1
- package/dist/{chunk-GDZTU2Z4.js → chunk-XQ5KAXKL.js} +1 -1
- package/dist/{chunk-BX3DRKTU.js → chunk-XROT7L2F.js} +6 -5
- package/dist/{config-N55LTJ76.js → config-U2WEZXF6.js} +4 -4
- package/dist/{dev-BSXR55PZ.js → dev-4OAJCQRQ.js} +29 -5
- package/dist/guide-F2FLCDYO.js +113 -0
- package/dist/{host-JVLWYY5A.js → host-2KBOPER6.js} +2 -2
- package/dist/index.js +35 -26
- package/dist/{init-KX6Y3ELD.js → init-R5L2GAFV.js} +6 -6
- package/dist/{install-G4XYNVL3.js → install-XZC6UO54.js} +3 -3
- package/dist/{mcp-DABSO5PE.js → mcp-CNZLJ57B.js} +4 -4
- package/dist/{memory-7Q5P7LIU.js → memory-KU2MOCPQ.js} +4 -4
- package/dist/{session-DMQZXZ7F.js → session-ZGNQKV4M.js} +26 -7
- package/dist/{status-K7TBUAXT.js → status-JXUXVHRH.js} +4 -4
- package/dist/{statusline-CDGADB3C.js → statusline-RMTO4MQA.js} +2 -2
- package/dist/{update-6M3YFHS6.js → update-HS6A2C5V.js} +3 -3
- package/lib/cf-memory/README.md +4 -4
- package/lib/cf-memory/src/__tests__/claude-md.test.ts +105 -0
- package/lib/cf-memory/src/__tests__/tier.test.ts +59 -0
- package/lib/cf-memory/src/daemon/process.ts +1 -1
- package/lib/cf-memory/src/lib/claude-md.ts +12 -3
- package/lib/cf-memory/src/lib/tier.ts +19 -7
- package/lib/cf-memory/src/tools/delete.ts +3 -3
- package/lib/cf-memory/src/tools/store.ts +14 -2
- package/lib/cf-memory/src/tools/update.ts +21 -3
- package/package.json +7 -4
- package/dist/chunk-2HQVNQB7.js +0 -71
package/dist/index.js
CHANGED
|
@@ -14,7 +14,7 @@ program.name("cf").description(
|
|
|
14
14
|
"coding-friend CLI \u2014 host learning docs, setup MCP, init projects"
|
|
15
15
|
).version(pkg.version, "-v, --version");
|
|
16
16
|
program.command("install").description("Install the Coding Friend plugin into Claude Code").option("--user", "Install at user scope (all projects)").option("--global", "Install at user scope (all projects)").option("--project", "Install at project scope (shared via git)").option("--local", "Install at local scope (this machine only)").action(async (opts) => {
|
|
17
|
-
const { installCommand } = await import("./install-
|
|
17
|
+
const { installCommand } = await import("./install-XZC6UO54.js");
|
|
18
18
|
await installCommand(opts);
|
|
19
19
|
});
|
|
20
20
|
program.command("uninstall").description("Uninstall the Coding Friend plugin from Claude Code").option("--user", "Uninstall from user scope (all projects)").option("--global", "Uninstall from user scope (all projects)").option("--project", "Uninstall from project scope").option("--local", "Uninstall from local scope").action(async (opts) => {
|
|
@@ -30,19 +30,19 @@ program.command("enable").description("Re-enable the Coding Friend plugin").opti
|
|
|
30
30
|
await enableCommand(opts);
|
|
31
31
|
});
|
|
32
32
|
program.command("init").description("Initialize coding-friend in current project").action(async () => {
|
|
33
|
-
const { initCommand } = await import("./init-
|
|
33
|
+
const { initCommand } = await import("./init-R5L2GAFV.js");
|
|
34
34
|
await initCommand();
|
|
35
35
|
});
|
|
36
36
|
program.command("config").description("Manage Coding Friend configuration").action(async () => {
|
|
37
|
-
const { configCommand } = await import("./config-
|
|
37
|
+
const { configCommand } = await import("./config-U2WEZXF6.js");
|
|
38
38
|
await configCommand();
|
|
39
39
|
});
|
|
40
40
|
program.command("host").description("Build and serve learning docs as a static website").argument("[path]", "path to docs folder").option("-p, --port <port>", "port number", "3333").action(async (path, opts) => {
|
|
41
|
-
const { hostCommand } = await import("./host-
|
|
41
|
+
const { hostCommand } = await import("./host-2KBOPER6.js");
|
|
42
42
|
await hostCommand(path, opts);
|
|
43
43
|
});
|
|
44
44
|
program.command("mcp").description("Setup MCP server for learning docs").argument("[path]", "path to docs folder").action(async (path) => {
|
|
45
|
-
const { mcpCommand } = await import("./mcp-
|
|
45
|
+
const { mcpCommand } = await import("./mcp-CNZLJ57B.js");
|
|
46
46
|
await mcpCommand(path);
|
|
47
47
|
});
|
|
48
48
|
program.command("permission").description("Manage Claude Code permission rules for Coding Friend").option("--all", "Apply all recommended permissions without prompts").option("--user", "Save to user-level settings (~/.claude/settings.json)").option(
|
|
@@ -53,15 +53,15 @@ program.command("permission").description("Manage Claude Code permission rules f
|
|
|
53
53
|
await permissionCommand(opts);
|
|
54
54
|
});
|
|
55
55
|
program.command("statusline").description("Setup coding-friend statusline in Claude Code").action(async () => {
|
|
56
|
-
const { statuslineCommand } = await import("./statusline-
|
|
56
|
+
const { statuslineCommand } = await import("./statusline-RMTO4MQA.js");
|
|
57
57
|
await statuslineCommand();
|
|
58
58
|
});
|
|
59
59
|
program.command("update").description("Update coding-friend plugin, CLI, and statusline").option("--cli", "Update only the CLI (npm package)").option("--plugin", "Update only the Claude Code plugin").option("--statusline", "Update only the statusline").option("--user", "Update plugin at user scope (all projects)").option("--global", "Update plugin at user scope (all projects)").option("--project", "Update plugin at project scope").option("--local", "Update plugin at local scope").action(async (opts) => {
|
|
60
|
-
const { updateCommand } = await import("./update-
|
|
60
|
+
const { updateCommand } = await import("./update-HS6A2C5V.js");
|
|
61
61
|
await updateCommand(opts);
|
|
62
62
|
});
|
|
63
63
|
program.command("status").description("Show comprehensive Coding Friend status").action(async () => {
|
|
64
|
-
const { statusCommand } = await import("./status-
|
|
64
|
+
const { statusCommand } = await import("./status-JXUXVHRH.js");
|
|
65
65
|
await statusCommand();
|
|
66
66
|
});
|
|
67
67
|
var session = program.command("session").description("Save and load Claude Code sessions across machines");
|
|
@@ -76,11 +76,11 @@ session.command("save").description("Save current Claude Code session to sync fo
|
|
|
76
76
|
"-s, --session-id <id>",
|
|
77
77
|
"session UUID to save (default: auto-detect newest)"
|
|
78
78
|
).option("-l, --label <label>", "label for this session").action(async (opts) => {
|
|
79
|
-
const { sessionSaveCommand } = await import("./session-
|
|
79
|
+
const { sessionSaveCommand } = await import("./session-ZGNQKV4M.js");
|
|
80
80
|
await sessionSaveCommand(opts);
|
|
81
81
|
});
|
|
82
82
|
session.command("load").description("Load a saved session from sync folder").action(async () => {
|
|
83
|
-
const { sessionLoadCommand } = await import("./session-
|
|
83
|
+
const { sessionLoadCommand } = await import("./session-ZGNQKV4M.js");
|
|
84
84
|
await sessionLoadCommand();
|
|
85
85
|
});
|
|
86
86
|
var memory = program.command("memory").description("AI memory system \u2014 store and search project knowledge");
|
|
@@ -100,43 +100,43 @@ Memory subcommands:
|
|
|
100
100
|
memory mcp Show MCP server setup instructions`
|
|
101
101
|
);
|
|
102
102
|
memory.command("status").description("Show memory system status").action(async () => {
|
|
103
|
-
const { memoryStatusCommand } = await import("./memory-
|
|
103
|
+
const { memoryStatusCommand } = await import("./memory-KU2MOCPQ.js");
|
|
104
104
|
await memoryStatusCommand();
|
|
105
105
|
});
|
|
106
106
|
memory.command("search").description("Search memories by query").argument("<query>", "search query").action(async (query) => {
|
|
107
|
-
const { memorySearchCommand } = await import("./memory-
|
|
107
|
+
const { memorySearchCommand } = await import("./memory-KU2MOCPQ.js");
|
|
108
108
|
await memorySearchCommand(query);
|
|
109
109
|
});
|
|
110
110
|
memory.command("list").description(
|
|
111
111
|
"List memories in current project, or all projects with --projects"
|
|
112
112
|
).option("--projects", "List all project databases with size and metadata").action(async (opts) => {
|
|
113
|
-
const { memoryListCommand } = await import("./memory-
|
|
113
|
+
const { memoryListCommand } = await import("./memory-KU2MOCPQ.js");
|
|
114
114
|
await memoryListCommand(opts);
|
|
115
115
|
});
|
|
116
116
|
memory.command("init").description(
|
|
117
117
|
"Initialize memory system \u2014 interactive wizard (first time) or config menu"
|
|
118
118
|
).action(async () => {
|
|
119
|
-
const { memoryInitCommand } = await import("./memory-
|
|
119
|
+
const { memoryInitCommand } = await import("./memory-KU2MOCPQ.js");
|
|
120
120
|
await memoryInitCommand();
|
|
121
121
|
});
|
|
122
122
|
memory.command("config").description("Configure memory system settings").action(async () => {
|
|
123
|
-
const { memoryConfigCommand } = await import("./memory-
|
|
123
|
+
const { memoryConfigCommand } = await import("./memory-KU2MOCPQ.js");
|
|
124
124
|
await memoryConfigCommand();
|
|
125
125
|
});
|
|
126
126
|
memory.command("start-daemon").description("Start the memory daemon (Tier 2 \u2014 MiniSearch)").action(async () => {
|
|
127
|
-
const { memoryStartDaemonCommand } = await import("./memory-
|
|
127
|
+
const { memoryStartDaemonCommand } = await import("./memory-KU2MOCPQ.js");
|
|
128
128
|
await memoryStartDaemonCommand();
|
|
129
129
|
});
|
|
130
130
|
memory.command("stop-daemon").description("Stop the memory daemon").action(async () => {
|
|
131
|
-
const { memoryStopDaemonCommand } = await import("./memory-
|
|
131
|
+
const { memoryStopDaemonCommand } = await import("./memory-KU2MOCPQ.js");
|
|
132
132
|
await memoryStopDaemonCommand();
|
|
133
133
|
});
|
|
134
134
|
memory.command("rebuild").description("Rebuild the daemon search index").action(async () => {
|
|
135
|
-
const { memoryRebuildCommand } = await import("./memory-
|
|
135
|
+
const { memoryRebuildCommand } = await import("./memory-KU2MOCPQ.js");
|
|
136
136
|
await memoryRebuildCommand();
|
|
137
137
|
});
|
|
138
138
|
memory.command("mcp").description("Show MCP server setup instructions").action(async () => {
|
|
139
|
-
const { memoryMcpCommand } = await import("./memory-
|
|
139
|
+
const { memoryMcpCommand } = await import("./memory-KU2MOCPQ.js");
|
|
140
140
|
await memoryMcpCommand();
|
|
141
141
|
});
|
|
142
142
|
memory.command("rm").description("Remove a project database").option("--project-id <id>", "Project ID to remove").option("--all", "Remove all project databases").option(
|
|
@@ -144,10 +144,19 @@ memory.command("rm").description("Remove a project database").option("--project-
|
|
|
144
144
|
"Remove orphaned projects (source dir missing or 0 memories)"
|
|
145
145
|
).action(
|
|
146
146
|
async (opts) => {
|
|
147
|
-
const { memoryRmCommand } = await import("./memory-
|
|
147
|
+
const { memoryRmCommand } = await import("./memory-KU2MOCPQ.js");
|
|
148
148
|
await memoryRmCommand(opts);
|
|
149
149
|
}
|
|
150
150
|
);
|
|
151
|
+
var guide = program.command("guide").description("Manage custom skill guides");
|
|
152
|
+
guide.command("create").description("Create a custom guide for a skill").argument("<skill-name>", "skill to create guide for (e.g. cf-commit)").action(async (skillName) => {
|
|
153
|
+
const { guideCreateCommand } = await import("./guide-F2FLCDYO.js");
|
|
154
|
+
guideCreateCommand(skillName);
|
|
155
|
+
});
|
|
156
|
+
guide.command("list").description("List existing custom guides").action(async () => {
|
|
157
|
+
const { guideListCommand } = await import("./guide-F2FLCDYO.js");
|
|
158
|
+
guideListCommand();
|
|
159
|
+
});
|
|
151
160
|
var dev = program.command("dev").description("Development mode commands");
|
|
152
161
|
program.addHelpText(
|
|
153
162
|
"after",
|
|
@@ -161,35 +170,35 @@ Dev subcommands:
|
|
|
161
170
|
dev update [path] Update local dev plugin to latest version`
|
|
162
171
|
);
|
|
163
172
|
dev.command("on").description("Switch to local plugin source").argument("[path]", "path to local coding-friend repo (default: cwd)").action(async (path) => {
|
|
164
|
-
const { devOnCommand } = await import("./dev-
|
|
173
|
+
const { devOnCommand } = await import("./dev-4OAJCQRQ.js");
|
|
165
174
|
await devOnCommand(path);
|
|
166
175
|
});
|
|
167
176
|
dev.command("off").description("Switch back to remote marketplace").action(async () => {
|
|
168
|
-
const { devOffCommand } = await import("./dev-
|
|
177
|
+
const { devOffCommand } = await import("./dev-4OAJCQRQ.js");
|
|
169
178
|
await devOffCommand();
|
|
170
179
|
});
|
|
171
180
|
dev.command("status").description("Show current dev mode").action(async () => {
|
|
172
|
-
const { devStatusCommand } = await import("./dev-
|
|
181
|
+
const { devStatusCommand } = await import("./dev-4OAJCQRQ.js");
|
|
173
182
|
await devStatusCommand();
|
|
174
183
|
});
|
|
175
184
|
dev.command("sync").description(
|
|
176
185
|
"Copy local source files to plugin cache (no version bump needed)"
|
|
177
186
|
).action(async () => {
|
|
178
|
-
const { devSyncCommand } = await import("./dev-
|
|
187
|
+
const { devSyncCommand } = await import("./dev-4OAJCQRQ.js");
|
|
179
188
|
await devSyncCommand();
|
|
180
189
|
});
|
|
181
190
|
dev.command("restart").description("Reinstall local dev plugin (off + on)").argument(
|
|
182
191
|
"[path]",
|
|
183
192
|
"path to local coding-friend repo (default: saved path or cwd)"
|
|
184
193
|
).action(async (path) => {
|
|
185
|
-
const { devRestartCommand } = await import("./dev-
|
|
194
|
+
const { devRestartCommand } = await import("./dev-4OAJCQRQ.js");
|
|
186
195
|
await devRestartCommand(path);
|
|
187
196
|
});
|
|
188
197
|
dev.command("update").description("Update local dev plugin to latest version (off + on)").argument(
|
|
189
198
|
"[path]",
|
|
190
199
|
"path to local coding-friend repo (default: saved path or cwd)"
|
|
191
200
|
).action(async (path) => {
|
|
192
|
-
const { devUpdateCommand } = await import("./dev-
|
|
201
|
+
const { devUpdateCommand } = await import("./dev-4OAJCQRQ.js");
|
|
193
202
|
await devUpdateCommand(path);
|
|
194
203
|
});
|
|
195
204
|
program.hook("postAction", async () => {
|
|
@@ -2,24 +2,24 @@ import {
|
|
|
2
2
|
ensureMemoryBuilt,
|
|
3
3
|
isMemoryInitialized,
|
|
4
4
|
memoryInitWizard
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-E7OY4UWW.js";
|
|
6
6
|
import {
|
|
7
7
|
memoryConfigMenu
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-XROT7L2F.js";
|
|
9
9
|
import {
|
|
10
10
|
getLibPath
|
|
11
11
|
} from "./chunk-RZRT7NGT.js";
|
|
12
|
-
import "./chunk-
|
|
12
|
+
import "./chunk-J4N2ODQ5.js";
|
|
13
13
|
import {
|
|
14
14
|
findStatuslineHookPath,
|
|
15
15
|
isStatuslineConfigured,
|
|
16
16
|
saveStatuslineConfig,
|
|
17
17
|
selectStatuslineComponents,
|
|
18
18
|
writeStatuslineSettings
|
|
19
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-XQ5KAXKL.js";
|
|
20
20
|
import {
|
|
21
21
|
DEFAULT_CONFIG
|
|
22
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-DHH6SRXV.js";
|
|
23
23
|
import {
|
|
24
24
|
ensureShellCompletion,
|
|
25
25
|
hasShellCompletion
|
|
@@ -980,7 +980,7 @@ async function initCommand() {
|
|
|
980
980
|
console.log();
|
|
981
981
|
log.congrats("Setup complete!");
|
|
982
982
|
log.dim(
|
|
983
|
-
"Available commands: /cf-ask, /cf-plan, /cf-fix, /cf-commit, /cf-review, /cf-review-out, /cf-review-in, /cf-ship, /cf-optimize, /cf-scan, /cf-remember, /cf-learn, /cf-research, /cf-session, /cf-help"
|
|
983
|
+
"Available commands: /cf-ask, /cf-plan, /cf-fix, /cf-commit, /cf-review, /cf-review-out, /cf-review-in, /cf-ship, /cf-optimize, /cf-scan, /cf-remember, /cf-learn, /cf-teach, /cf-research, /cf-session, /cf-warm, /cf-help"
|
|
984
984
|
);
|
|
985
985
|
}
|
|
986
986
|
export {
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getLatestVersion,
|
|
3
3
|
semverCompare
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-RGQGKOBH.js";
|
|
5
5
|
import {
|
|
6
6
|
getInstalledVersion
|
|
7
|
-
} from "./chunk-
|
|
8
|
-
import "./chunk-
|
|
7
|
+
} from "./chunk-XQ5KAXKL.js";
|
|
8
|
+
import "./chunk-DHH6SRXV.js";
|
|
9
9
|
import {
|
|
10
10
|
ensureShellCompletion
|
|
11
11
|
} from "./chunk-DMJCO6LJ.js";
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ensureMemoryBuilt,
|
|
3
3
|
printMemoryMcpConfig
|
|
4
|
-
} from "./chunk-
|
|
5
|
-
import "./chunk-
|
|
4
|
+
} from "./chunk-E7OY4UWW.js";
|
|
5
|
+
import "./chunk-XROT7L2F.js";
|
|
6
6
|
import {
|
|
7
7
|
getLibPath
|
|
8
8
|
} from "./chunk-RZRT7NGT.js";
|
|
9
9
|
import {
|
|
10
10
|
resolveDocsDir,
|
|
11
11
|
resolveMemoryDir
|
|
12
|
-
} from "./chunk-
|
|
13
|
-
import "./chunk-
|
|
12
|
+
} from "./chunk-J4N2ODQ5.js";
|
|
13
|
+
import "./chunk-DHH6SRXV.js";
|
|
14
14
|
import "./chunk-HPNRQYLM.js";
|
|
15
15
|
import {
|
|
16
16
|
run
|
|
@@ -13,11 +13,11 @@ import {
|
|
|
13
13
|
memoryStatusCommand,
|
|
14
14
|
memoryStopDaemonCommand,
|
|
15
15
|
printMemoryMcpConfig
|
|
16
|
-
} from "./chunk-
|
|
17
|
-
import "./chunk-
|
|
16
|
+
} from "./chunk-E7OY4UWW.js";
|
|
17
|
+
import "./chunk-XROT7L2F.js";
|
|
18
18
|
import "./chunk-RZRT7NGT.js";
|
|
19
|
-
import "./chunk-
|
|
20
|
-
import "./chunk-
|
|
19
|
+
import "./chunk-J4N2ODQ5.js";
|
|
20
|
+
import "./chunk-DHH6SRXV.js";
|
|
21
21
|
import "./chunk-HPNRQYLM.js";
|
|
22
22
|
import "./chunk-EVGXUDX4.js";
|
|
23
23
|
import "./chunk-TWKNGPBO.js";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
loadConfig
|
|
3
|
-
} from "./chunk-
|
|
4
|
-
import "./chunk-
|
|
3
|
+
} from "./chunk-J4N2ODQ5.js";
|
|
4
|
+
import "./chunk-DHH6SRXV.js";
|
|
5
5
|
import {
|
|
6
6
|
claudeSessionDir,
|
|
7
7
|
encodeProjectPath,
|
|
@@ -32,6 +32,10 @@ import {
|
|
|
32
32
|
} from "fs";
|
|
33
33
|
import { join } from "path";
|
|
34
34
|
import { hostname as osHostname } from "os";
|
|
35
|
+
function slugifyLabel(label, maxLen = 100) {
|
|
36
|
+
const slug = label.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, maxLen).replace(/-+$/, "");
|
|
37
|
+
return slug || "session";
|
|
38
|
+
}
|
|
35
39
|
function buildPreviewText(jsonlPath, maxChars = 200) {
|
|
36
40
|
try {
|
|
37
41
|
const content = readFileSync(jsonlPath, "utf-8");
|
|
@@ -65,7 +69,10 @@ function listSyncedSessions(syncDir) {
|
|
|
65
69
|
for (const entry of entries) {
|
|
66
70
|
const metaPath = join(sessionsDir, entry, "meta.json");
|
|
67
71
|
const meta = readJson(metaPath);
|
|
68
|
-
if (meta)
|
|
72
|
+
if (meta) {
|
|
73
|
+
if (!meta.folderName) meta.folderName = entry;
|
|
74
|
+
metas.push(meta);
|
|
75
|
+
}
|
|
69
76
|
}
|
|
70
77
|
return metas.sort(
|
|
71
78
|
(a, b) => new Date(b.savedAt).getTime() - new Date(a.savedAt).getTime()
|
|
@@ -92,13 +99,17 @@ function remapProjectPath(originalPath, currentHome) {
|
|
|
92
99
|
}
|
|
93
100
|
function saveSession(opts) {
|
|
94
101
|
const { jsonlPath, sessionId, label, projectPath, syncDir, previewText } = opts;
|
|
95
|
-
const
|
|
102
|
+
const sessionsDir = join(syncDir, "sessions");
|
|
103
|
+
const baseSlug = slugifyLabel(label);
|
|
104
|
+
const folderName = uniqueFolderName(sessionsDir, baseSlug);
|
|
105
|
+
const destDir = join(sessionsDir, folderName);
|
|
96
106
|
const destJsonl = join(destDir, "session.jsonl");
|
|
97
107
|
const destMeta = join(destDir, "meta.json");
|
|
98
108
|
mkdirSync(destDir, { recursive: true });
|
|
99
109
|
copyFileSync(jsonlPath, destJsonl);
|
|
100
110
|
const meta = {
|
|
101
111
|
sessionId,
|
|
112
|
+
folderName,
|
|
102
113
|
label,
|
|
103
114
|
projectPath,
|
|
104
115
|
savedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -106,12 +117,20 @@ function saveSession(opts) {
|
|
|
106
117
|
previewText
|
|
107
118
|
};
|
|
108
119
|
writeJson(destMeta, meta);
|
|
120
|
+
return folderName;
|
|
121
|
+
}
|
|
122
|
+
function uniqueFolderName(sessionsDir, base) {
|
|
123
|
+
if (!existsSync(join(sessionsDir, base))) return base;
|
|
124
|
+
let i = 2;
|
|
125
|
+
while (existsSync(join(sessionsDir, `${base}-${i}`))) i++;
|
|
126
|
+
return `${base}-${i}`;
|
|
109
127
|
}
|
|
110
128
|
function loadSession(meta, localProjectPath, syncDir) {
|
|
111
129
|
const encodedPath = encodeProjectPath(localProjectPath);
|
|
112
130
|
const destDir = claudeSessionDir(encodedPath);
|
|
113
131
|
const destPath = join(destDir, `${meta.sessionId}.jsonl`);
|
|
114
|
-
const
|
|
132
|
+
const folder = meta.folderName ?? meta.sessionId;
|
|
133
|
+
const srcPath = join(syncDir, "sessions", folder, "session.jsonl");
|
|
115
134
|
mkdirSync(destDir, { recursive: true });
|
|
116
135
|
copyFileSync(srcPath, destPath);
|
|
117
136
|
}
|
|
@@ -184,7 +203,7 @@ async function sessionSaveCommand(opts = {}) {
|
|
|
184
203
|
default: `session-${(/* @__PURE__ */ new Date()).toISOString().slice(0, 10)}`
|
|
185
204
|
});
|
|
186
205
|
const previewText = buildPreviewText(jsonlPath);
|
|
187
|
-
saveSession({
|
|
206
|
+
const folderName = saveSession({
|
|
188
207
|
jsonlPath,
|
|
189
208
|
sessionId,
|
|
190
209
|
label,
|
|
@@ -193,7 +212,7 @@ async function sessionSaveCommand(opts = {}) {
|
|
|
193
212
|
previewText
|
|
194
213
|
});
|
|
195
214
|
log.success(`Session saved: "${label}"`);
|
|
196
|
-
log.dim(` \u2192 ${join2(docsDir, "sessions",
|
|
215
|
+
log.dim(` \u2192 ${join2(docsDir, "sessions", folderName)}`);
|
|
197
216
|
}
|
|
198
217
|
async function sessionLoadCommand() {
|
|
199
218
|
const docsDir = resolveDocsDir();
|
|
@@ -3,17 +3,17 @@ import {
|
|
|
3
3
|
} from "./chunk-RZRT7NGT.js";
|
|
4
4
|
import {
|
|
5
5
|
resolveMemoryDir
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-J4N2ODQ5.js";
|
|
7
7
|
import {
|
|
8
8
|
getCliVersion,
|
|
9
9
|
getLatestCliVersion,
|
|
10
10
|
getLatestVersion,
|
|
11
11
|
semverCompare
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-RGQGKOBH.js";
|
|
13
13
|
import {
|
|
14
14
|
getInstalledVersion
|
|
15
|
-
} from "./chunk-
|
|
16
|
-
import "./chunk-
|
|
15
|
+
} from "./chunk-XQ5KAXKL.js";
|
|
16
|
+
import "./chunk-DHH6SRXV.js";
|
|
17
17
|
import "./chunk-DMJCO6LJ.js";
|
|
18
18
|
import {
|
|
19
19
|
detectPluginScope,
|
|
@@ -4,10 +4,10 @@ import {
|
|
|
4
4
|
saveStatuslineConfig,
|
|
5
5
|
selectStatuslineComponents,
|
|
6
6
|
writeStatuslineSettings
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-XQ5KAXKL.js";
|
|
8
8
|
import {
|
|
9
9
|
ALL_COMPONENT_IDS
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-DHH6SRXV.js";
|
|
11
11
|
import {
|
|
12
12
|
commandExists
|
|
13
13
|
} from "./chunk-EVGXUDX4.js";
|
|
@@ -4,9 +4,9 @@ import {
|
|
|
4
4
|
getLatestVersion,
|
|
5
5
|
semverCompare,
|
|
6
6
|
updateCommand
|
|
7
|
-
} from "./chunk-
|
|
8
|
-
import "./chunk-
|
|
9
|
-
import "./chunk-
|
|
7
|
+
} from "./chunk-RGQGKOBH.js";
|
|
8
|
+
import "./chunk-XQ5KAXKL.js";
|
|
9
|
+
import "./chunk-DHH6SRXV.js";
|
|
10
10
|
import "./chunk-DMJCO6LJ.js";
|
|
11
11
|
import "./chunk-HPNRQYLM.js";
|
|
12
12
|
import "./chunk-EVGXUDX4.js";
|
package/lib/cf-memory/README.md
CHANGED
|
@@ -48,7 +48,7 @@ Detection: Tier 1 → Tier 2 → Tier 3 (first available wins).
|
|
|
48
48
|
|
|
49
49
|
Memories are stored as Markdown files with YAML frontmatter in `docs/memory/<category>/`.
|
|
50
50
|
|
|
51
|
-
Convention memories (`preference` type → `conventions/` folder) are
|
|
51
|
+
Convention memories (`preference` type → `conventions/` folder) are automatically synced to the project's `CLAUDE.md` under a `## CF Memory: Project Rules` section. Other memory types can opt-in to CLAUDE.md sync by setting `sync_to_claude_md: true` when storing or updating — useful for decisions, infrastructure rules, or any project-wide rules that future sessions must follow. Entries are tracked via HTML comments (`<!-- cf:<id> -->`) and are automatically added, updated, or removed when the corresponding memory is stored, updated, or deleted.
|
|
52
52
|
|
|
53
53
|
## Embedding Models
|
|
54
54
|
|
|
@@ -226,12 +226,12 @@ npm run test:watch # Watch mode
|
|
|
226
226
|
node dist/daemon/entry.js ./docs/memory
|
|
227
227
|
|
|
228
228
|
# With idle timeout (ms) and tier
|
|
229
|
-
node dist/daemon/entry.js ./docs/memory
|
|
229
|
+
node dist/daemon/entry.js ./docs/memory 0 --tier=lite
|
|
230
230
|
```
|
|
231
231
|
|
|
232
232
|
The daemon runs a Hono HTTP server on a Unix Domain Socket at `~/.coding-friend/memory/daemon.sock`, with PID tracking at `~/.coding-friend/memory/daemon.pid`.
|
|
233
233
|
|
|
234
|
-
**Auto-reconnect:** If the daemon dies (e.g.,
|
|
234
|
+
**Auto-reconnect with retry:** If the daemon dies (e.g., crash or explicit stop), the `DaemonClient` automatically respawns it on the next request with up to 3 retry attempts (1-second delay between retries). If all retries fail, it falls back to Tier 3 (markdown grep). This means mid-session daemon restarts are transparent — no manual intervention needed.
|
|
235
235
|
|
|
236
236
|
### Lazy dependencies (Tier 1)
|
|
237
237
|
|
|
@@ -306,7 +306,7 @@ If these are missing, `cf memory init` will fail at the "Installing SQLite depen
|
|
|
306
306
|
| ----------------------------- | ------------------------ | ------------------------------------------------- |
|
|
307
307
|
| `MEMORY_DOCS_DIR` | `./docs/memory` | Path to memory storage directory |
|
|
308
308
|
| `MEMORY_TIER` | `auto` | Force a tier: `auto`, `full`, `lite`, `markdown` |
|
|
309
|
-
| `MEMORY_DAEMON_IDLE_TIMEOUT` | `
|
|
309
|
+
| `MEMORY_DAEMON_IDLE_TIMEOUT` | `0` (no timeout) | Daemon idle timeout in ms (`0` = never auto-stop) |
|
|
310
310
|
| `MEMORY_EMBEDDING_PROVIDER` | `transformers` | Embedding provider: `transformers` or `ollama` |
|
|
311
311
|
| `MEMORY_EMBEDDING_MODEL` | (provider default) | Embedding model name (e.g., `nomic-embed-text`) |
|
|
312
312
|
| `MEMORY_EMBEDDING_OLLAMA_URL` | `http://localhost:11434` | Ollama server URL |
|
|
@@ -236,3 +236,108 @@ describe("syncToClaudeMd with realistic docsDir", () => {
|
|
|
236
236
|
expect(content).toContain(SECTION_HEADER);
|
|
237
237
|
});
|
|
238
238
|
});
|
|
239
|
+
|
|
240
|
+
describe("migration from old header", () => {
|
|
241
|
+
const OLD_HEADER = "## CF Memory: Conventions";
|
|
242
|
+
|
|
243
|
+
it("reads entries from old header and rewrites with new header on sync", () => {
|
|
244
|
+
writeFileSync(
|
|
245
|
+
claudeMdFile,
|
|
246
|
+
`# My Project\n\n${OLD_HEADER}\n\n- Old rule <!-- cf:conventions/old-rule -->\n`,
|
|
247
|
+
);
|
|
248
|
+
|
|
249
|
+
syncToClaudeMd(testDir, "conventions/new-rule", "New rule");
|
|
250
|
+
|
|
251
|
+
const content = readFileSync(claudeMdFile, "utf-8");
|
|
252
|
+
// Should have new header
|
|
253
|
+
expect(content).toContain(SECTION_HEADER);
|
|
254
|
+
// Should NOT have old header (unless they're the same)
|
|
255
|
+
if (SECTION_HEADER !== OLD_HEADER) {
|
|
256
|
+
expect(content).not.toContain(OLD_HEADER);
|
|
257
|
+
}
|
|
258
|
+
// Both entries should be preserved
|
|
259
|
+
expect(content).toContain("Old rule");
|
|
260
|
+
expect(content).toContain("New rule");
|
|
261
|
+
});
|
|
262
|
+
|
|
263
|
+
it("removes entries from old header format", () => {
|
|
264
|
+
writeFileSync(
|
|
265
|
+
claudeMdFile,
|
|
266
|
+
`# My Project\n\n${OLD_HEADER}\n\n- Old rule <!-- cf:conventions/old-rule -->\n- Keep this <!-- cf:conventions/keep -->\n`,
|
|
267
|
+
);
|
|
268
|
+
|
|
269
|
+
removeFromClaudeMd(testDir, "conventions/old-rule");
|
|
270
|
+
|
|
271
|
+
const content = readFileSync(claudeMdFile, "utf-8");
|
|
272
|
+
expect(content).not.toContain("Old rule");
|
|
273
|
+
expect(content).toContain("Keep this");
|
|
274
|
+
});
|
|
275
|
+
});
|
|
276
|
+
|
|
277
|
+
describe("syncToClaudeMd with non-convention categories", () => {
|
|
278
|
+
it("syncs decisions entries to CLAUDE.md", () => {
|
|
279
|
+
syncToClaudeMd(
|
|
280
|
+
testDir,
|
|
281
|
+
"decisions/api-versioning",
|
|
282
|
+
"Always use URL-based API versioning (v1, v2)",
|
|
283
|
+
);
|
|
284
|
+
|
|
285
|
+
const content = readFileSync(claudeMdFile, "utf-8");
|
|
286
|
+
expect(content).toContain(SECTION_HEADER);
|
|
287
|
+
expect(content).toContain("Always use URL-based API versioning");
|
|
288
|
+
expect(content).toContain("<!-- cf:decisions/api-versioning -->");
|
|
289
|
+
});
|
|
290
|
+
|
|
291
|
+
it("syncs infrastructure entries to CLAUDE.md", () => {
|
|
292
|
+
syncToClaudeMd(
|
|
293
|
+
testDir,
|
|
294
|
+
"infrastructure/deploy-checklist",
|
|
295
|
+
"Always run migrations before deploying",
|
|
296
|
+
);
|
|
297
|
+
|
|
298
|
+
const content = readFileSync(claudeMdFile, "utf-8");
|
|
299
|
+
expect(content).toContain("Always run migrations before deploying");
|
|
300
|
+
expect(content).toContain("<!-- cf:infrastructure/deploy-checklist -->");
|
|
301
|
+
});
|
|
302
|
+
|
|
303
|
+
it("mixes convention and non-convention entries in same section", () => {
|
|
304
|
+
syncToClaudeMd(testDir, "conventions/naming", "Use camelCase");
|
|
305
|
+
syncToClaudeMd(
|
|
306
|
+
testDir,
|
|
307
|
+
"decisions/db-choice",
|
|
308
|
+
"Use PostgreSQL for all new services",
|
|
309
|
+
);
|
|
310
|
+
|
|
311
|
+
const content = readFileSync(claudeMdFile, "utf-8");
|
|
312
|
+
expect(content).toContain("Use camelCase");
|
|
313
|
+
expect(content).toContain("Use PostgreSQL for all new services");
|
|
314
|
+
// Only one section header
|
|
315
|
+
const headerCount = content.split(SECTION_HEADER).length - 1;
|
|
316
|
+
expect(headerCount).toBe(1);
|
|
317
|
+
});
|
|
318
|
+
|
|
319
|
+
it("removes non-convention entries by ID", () => {
|
|
320
|
+
syncToClaudeMd(testDir, "decisions/api-versioning", "URL-based versioning");
|
|
321
|
+
syncToClaudeMd(testDir, "conventions/naming", "Use camelCase");
|
|
322
|
+
|
|
323
|
+
removeFromClaudeMd(testDir, "decisions/api-versioning");
|
|
324
|
+
|
|
325
|
+
const content = readFileSync(claudeMdFile, "utf-8");
|
|
326
|
+
expect(content).not.toContain("URL-based versioning");
|
|
327
|
+
expect(content).toContain("Use camelCase");
|
|
328
|
+
});
|
|
329
|
+
|
|
330
|
+
it("updates non-convention entries", () => {
|
|
331
|
+
syncToClaudeMd(testDir, "infrastructure/ci-rule", "Run lint before tests");
|
|
332
|
+
|
|
333
|
+
updateInClaudeMd(
|
|
334
|
+
testDir,
|
|
335
|
+
"infrastructure/ci-rule",
|
|
336
|
+
"Run lint and type-check before tests",
|
|
337
|
+
);
|
|
338
|
+
|
|
339
|
+
const content = readFileSync(claudeMdFile, "utf-8");
|
|
340
|
+
expect(content).toContain("Run lint and type-check before tests");
|
|
341
|
+
expect(content).not.toContain("Run lint before tests\n");
|
|
342
|
+
});
|
|
343
|
+
});
|
|
@@ -289,6 +289,65 @@ describe("createBackendForTier() with embeddingConfig", () => {
|
|
|
289
289
|
});
|
|
290
290
|
});
|
|
291
291
|
|
|
292
|
+
describe("makeRespawn retry logic", () => {
|
|
293
|
+
it("retries up to 3 times before giving up", async () => {
|
|
294
|
+
const daemonProcess = await import("../daemon/process.js");
|
|
295
|
+
|
|
296
|
+
let attempts = 0;
|
|
297
|
+
const spawnSpy = vi
|
|
298
|
+
.spyOn(daemonProcess, "spawnDaemon")
|
|
299
|
+
.mockImplementation(async () => {
|
|
300
|
+
attempts++;
|
|
301
|
+
return null; // always fail
|
|
302
|
+
});
|
|
303
|
+
// Isolate from real daemon state on the host machine
|
|
304
|
+
const runningSpy = vi
|
|
305
|
+
.spyOn(daemonProcess, "isDaemonRunning")
|
|
306
|
+
.mockResolvedValue(false);
|
|
307
|
+
|
|
308
|
+
// Use createBackendForTier with "lite" to trigger respawn path
|
|
309
|
+
// The respawn callback wraps makeRespawn which calls spawnDaemon
|
|
310
|
+
// We need to get the respawn function indirectly
|
|
311
|
+
// Instead, test via the exported createRespawnWithRetry
|
|
312
|
+
const { createRespawnWithRetry } = await import("../lib/tier.js");
|
|
313
|
+
const respawn = createRespawnWithRetry(".", undefined, undefined);
|
|
314
|
+
const result = await respawn();
|
|
315
|
+
|
|
316
|
+
expect(result).toBe(false);
|
|
317
|
+
expect(attempts).toBe(3);
|
|
318
|
+
|
|
319
|
+
spawnSpy.mockRestore();
|
|
320
|
+
runningSpy.mockRestore();
|
|
321
|
+
});
|
|
322
|
+
|
|
323
|
+
it("succeeds on second attempt", async () => {
|
|
324
|
+
const daemonProcess = await import("../daemon/process.js");
|
|
325
|
+
|
|
326
|
+
let attempts = 0;
|
|
327
|
+
const spawnSpy = vi
|
|
328
|
+
.spyOn(daemonProcess, "spawnDaemon")
|
|
329
|
+
.mockImplementation(async () => {
|
|
330
|
+
attempts++;
|
|
331
|
+
if (attempts === 2) return { pid: 1234 };
|
|
332
|
+
return null;
|
|
333
|
+
});
|
|
334
|
+
// Isolate from real daemon state on the host machine
|
|
335
|
+
const runningSpy = vi
|
|
336
|
+
.spyOn(daemonProcess, "isDaemonRunning")
|
|
337
|
+
.mockResolvedValue(false);
|
|
338
|
+
|
|
339
|
+
const { createRespawnWithRetry } = await import("../lib/tier.js");
|
|
340
|
+
const respawn = createRespawnWithRetry(".", undefined, undefined);
|
|
341
|
+
const result = await respawn();
|
|
342
|
+
|
|
343
|
+
expect(result).toBe(true);
|
|
344
|
+
expect(attempts).toBe(2);
|
|
345
|
+
|
|
346
|
+
spawnSpy.mockRestore();
|
|
347
|
+
runningSpy.mockRestore();
|
|
348
|
+
});
|
|
349
|
+
});
|
|
350
|
+
|
|
292
351
|
describe("TIERS constant", () => {
|
|
293
352
|
it("has all 3 tier definitions", () => {
|
|
294
353
|
expect(Object.keys(TIERS)).toHaveLength(3);
|
|
@@ -6,7 +6,7 @@ import { getRequestListener } from "@hono/node-server";
|
|
|
6
6
|
import { createDaemonApp } from "./server.js";
|
|
7
7
|
import type { MemoryBackend } from "../lib/backend.js";
|
|
8
8
|
|
|
9
|
-
const DEFAULT_IDLE_TIMEOUT_MS =
|
|
9
|
+
const DEFAULT_IDLE_TIMEOUT_MS = 0; // 0 = no timeout, run until explicitly stopped
|
|
10
10
|
|
|
11
11
|
export interface DaemonPaths {
|
|
12
12
|
socketPath: string;
|