coding-friend-cli 1.27.0 → 1.27.2

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.
@@ -224,7 +224,7 @@ async function memoryStatusCommand() {
224
224
  );
225
225
  } else {
226
226
  log.info(
227
- `MCP: ${chalk.dim("not configured")} ${chalk.dim('(run "cf memory init" or add manually via "cf memory mcp")')}`
227
+ `MCP: ${chalk.dim("not configured in this project")} ${chalk.dim('(run "cf memory init" or add manually via "cf memory mcp")')}`
228
228
  );
229
229
  }
230
230
  const autoCapture = config.memory?.autoCapture ?? false;
package/dist/index.js CHANGED
@@ -30,7 +30,7 @@ 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-QP57Q2C6.js");
33
+ const { initCommand } = await import("./init-FM5D5CD2.js");
34
34
  await initCommand();
35
35
  });
36
36
  program.command("config").description("Manage Coding Friend configuration").action(async () => {
@@ -42,7 +42,7 @@ program.command("host").description("Build and serve learning docs as a static w
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-24NCFFAF.js");
45
+ const { mcpCommand } = await import("./mcp-DABSO5PE.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(
@@ -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-DMQZXZ7F.js");
79
+ const { sessionSaveCommand } = await import("./session-VXYTI2C6.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-DMQZXZ7F.js");
83
+ const { sessionLoadCommand } = await import("./session-VXYTI2C6.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-HLMKDGWY.js");
103
+ const { memoryStatusCommand } = await import("./memory-7Q5P7LIU.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-HLMKDGWY.js");
107
+ const { memorySearchCommand } = await import("./memory-7Q5P7LIU.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-HLMKDGWY.js");
113
+ const { memoryListCommand } = await import("./memory-7Q5P7LIU.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-HLMKDGWY.js");
119
+ const { memoryInitCommand } = await import("./memory-7Q5P7LIU.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-HLMKDGWY.js");
123
+ const { memoryConfigCommand } = await import("./memory-7Q5P7LIU.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-HLMKDGWY.js");
127
+ const { memoryStartDaemonCommand } = await import("./memory-7Q5P7LIU.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-HLMKDGWY.js");
131
+ const { memoryStopDaemonCommand } = await import("./memory-7Q5P7LIU.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-HLMKDGWY.js");
135
+ const { memoryRebuildCommand } = await import("./memory-7Q5P7LIU.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-HLMKDGWY.js");
139
+ const { memoryMcpCommand } = await import("./memory-7Q5P7LIU.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,7 +144,7 @@ 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-HLMKDGWY.js");
147
+ const { memoryRmCommand } = await import("./memory-7Q5P7LIU.js");
148
148
  await memoryRmCommand(opts);
149
149
  }
150
150
  );
@@ -2,7 +2,7 @@ import {
2
2
  ensureMemoryBuilt,
3
3
  isMemoryInitialized,
4
4
  memoryInitWizard
5
- } from "./chunk-TOM2FI3W.js";
5
+ } from "./chunk-75IEE2OE.js";
6
6
  import {
7
7
  memoryConfigMenu
8
8
  } from "./chunk-BX3DRKTU.js";
@@ -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,7 +1,7 @@
1
1
  import {
2
2
  ensureMemoryBuilt,
3
3
  printMemoryMcpConfig
4
- } from "./chunk-TOM2FI3W.js";
4
+ } from "./chunk-75IEE2OE.js";
5
5
  import "./chunk-BX3DRKTU.js";
6
6
  import {
7
7
  getLibPath
@@ -13,7 +13,7 @@ import {
13
13
  memoryStatusCommand,
14
14
  memoryStopDaemonCommand,
15
15
  printMemoryMcpConfig
16
- } from "./chunk-TOM2FI3W.js";
16
+ } from "./chunk-75IEE2OE.js";
17
17
  import "./chunk-BX3DRKTU.js";
18
18
  import "./chunk-RZRT7NGT.js";
19
19
  import "./chunk-2HQVNQB7.js";
@@ -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) metas.push(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 destDir = join(syncDir, "sessions", sessionId);
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 srcPath = join(syncDir, "sessions", meta.sessionId, "session.jsonl");
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", sessionId)}`);
215
+ log.dim(` \u2192 ${join2(docsDir, "sessions", folderName)}`);
197
216
  }
198
217
  async function sessionLoadCommand() {
199
218
  const docsDir = resolveDocsDir();
@@ -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 also synced to the project's `CLAUDE.md` under a `## CF Memory: Conventions` section. Entries are tracked via HTML comments (`<!-- cf:<id> -->`) and are automatically added, updated, or removed when the corresponding memory is stored, updated, or deleted.
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
 
@@ -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
+ });
@@ -14,7 +14,10 @@
14
14
  import fs from "node:fs";
15
15
  import path from "node:path";
16
16
 
17
- export const SECTION_HEADER = "## CF Memory: Conventions";
17
+ export const SECTION_HEADER = "## CF Memory: Project Rules";
18
+
19
+ /** @deprecated Old header — kept for migration. Removed after reading. */
20
+ const LEGACY_HEADER = "## CF Memory: Conventions";
18
21
 
19
22
  // Tested per-line via .split("\n"), not against the full document,
20
23
  // so the $ anchor correctly matches end-of-line without the `m` flag.
@@ -52,13 +55,19 @@ function parseClaudeMd(content: string): {
52
55
  after: string;
53
56
  untrackedLines: string[];
54
57
  } {
55
- const headerIdx = content.indexOf(SECTION_HEADER);
58
+ // Try current header first, then legacy header for migration
59
+ let headerIdx = content.indexOf(SECTION_HEADER);
60
+ let headerLen = SECTION_HEADER.length;
61
+ if (headerIdx === -1) {
62
+ headerIdx = content.indexOf(LEGACY_HEADER);
63
+ headerLen = LEGACY_HEADER.length;
64
+ }
56
65
  if (headerIdx === -1) {
57
66
  return { before: content, entries: [], after: "", untrackedLines: [] };
58
67
  }
59
68
 
60
69
  const before = content.slice(0, headerIdx);
61
- const rest = content.slice(headerIdx + SECTION_HEADER.length);
70
+ const rest = content.slice(headerIdx + headerLen);
62
71
 
63
72
  // Find the next section header (## ) to determine where our section ends
64
73
  const nextSectionMatch = rest.match(/\n(## )/);
@@ -28,12 +28,12 @@ export function registerDelete(
28
28
  isError: true,
29
29
  };
30
30
  }
31
- // Remove from CLAUDE.md if it was a conventions entry
32
- if (id.startsWith("conventions/") && ctx?.docsDir) {
31
+ // Remove from CLAUDE.md (any category may have been synced via sync_to_claude_md)
32
+ if (ctx?.docsDir) {
33
33
  try {
34
34
  removeFromClaudeMd(ctx.docsDir, id);
35
35
  } catch {
36
- // Best-effort
36
+ // Best-effort — removeFromClaudeMd is idempotent
37
37
  }
38
38
  }
39
39
 
@@ -40,6 +40,14 @@ export function registerStore(
40
40
  .describe(
41
41
  "When true, skip file creation and return a Memory object for indexing. File must already exist on disk.",
42
42
  ),
43
+ sync_to_claude_md: z
44
+ .boolean()
45
+ .optional()
46
+ .describe(
47
+ "When true, sync this memory to the project's CLAUDE.md regardless of category. " +
48
+ "Use for memories containing project-wide rules, conventions, or decisions that should be visible in CLAUDE.md. " +
49
+ "Convention memories (type: preference) are always synced automatically.",
50
+ ),
43
51
  },
44
52
  async ({
45
53
  title,
@@ -50,6 +58,7 @@ export function registerStore(
50
58
  importance,
51
59
  source,
52
60
  index_only,
61
+ sync_to_claude_md,
53
62
  }) => {
54
63
  const input = {
55
64
  title,
@@ -73,9 +82,12 @@ export function registerStore(
73
82
 
74
83
  const memory = await backend.store(input);
75
84
 
76
- // Sync convention memories to CLAUDE.md
85
+ // Sync to CLAUDE.md: auto for conventions, opt-in for other categories
77
86
  let claudeMdUpdated = false;
78
- if (memory.category === "conventions" && ctx?.docsDir && !index_only) {
87
+ const shouldSync =
88
+ (memory.category === "conventions" || sync_to_claude_md) &&
89
+ ctx?.docsDir;
90
+ if (shouldSync) {
79
91
  try {
80
92
  syncToClaudeMd(ctx.docsDir, memory.id, description);
81
93
  claudeMdUpdated = true;
@@ -29,8 +29,23 @@ export function registerUpdate(
29
29
  .max(5)
30
30
  .optional()
31
31
  .describe("New importance"),
32
+ sync_to_claude_md: z
33
+ .boolean()
34
+ .optional()
35
+ .describe(
36
+ "When true, sync this memory to the project's CLAUDE.md regardless of category. " +
37
+ "Convention memories (type: preference) are always synced automatically.",
38
+ ),
32
39
  },
33
- async ({ id, title, description, tags, content, importance }) => {
40
+ async ({
41
+ id,
42
+ title,
43
+ description,
44
+ tags,
45
+ content,
46
+ importance,
47
+ sync_to_claude_md,
48
+ }) => {
34
49
  const memory = await backend.update({
35
50
  id,
36
51
  title,
@@ -51,9 +66,12 @@ export function registerUpdate(
51
66
  };
52
67
  }
53
68
 
54
- // Sync convention memories to CLAUDE.md
69
+ // Sync to CLAUDE.md: auto for conventions, opt-in for other categories
55
70
  let claudeMdUpdated = false;
56
- if (memory.category === "conventions" && ctx?.docsDir) {
71
+ const shouldSync =
72
+ (memory.category === "conventions" || sync_to_claude_md) &&
73
+ ctx?.docsDir;
74
+ if (shouldSync) {
57
75
  try {
58
76
  if (description) {
59
77
  // Description changed — update the CLAUDE.md entry
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "coding-friend-cli",
3
- "version": "1.27.0",
3
+ "version": "1.27.2",
4
4
  "description": "CLI for coding-friend — host learning docs, setup MCP server, initialize projects",
5
5
  "type": "module",
6
6
  "bin": {