coding-friend-cli 1.1.1 → 1.2.1

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.
Files changed (56) hide show
  1. package/README.md +44 -6
  2. package/dist/{chunk-AQXTNLQD.js → chunk-6OI37OZX.js} +9 -1
  3. package/dist/chunk-CSF4FAHL.js +129 -0
  4. package/dist/{chunk-KZT4AFDW.js → chunk-Q4DKU5IG.js} +4 -6
  5. package/dist/dev-MAAWPWML.js +290 -0
  6. package/dist/{host-JBTJCWM2.js → host-2WINWEW7.js} +2 -2
  7. package/dist/index.js +44 -6
  8. package/dist/{init-E6CL3UZQ.js → init-CTCDQKIQ.js} +24 -13
  9. package/dist/{mcp-MWESK6UX.js → mcp-43HCE2KD.js} +2 -2
  10. package/dist/postinstall.js +1 -1
  11. package/dist/{statusline-7D6YU5YM.js → statusline-ARI7I5YM.js} +1 -1
  12. package/dist/{update-IH3G4SN5.js → update-GGCBM7U4.js} +91 -40
  13. package/lib/learn-host/.prettierignore +4 -0
  14. package/lib/learn-host/.prettierrc +8 -0
  15. package/lib/learn-host/CHANGELOG.md +14 -0
  16. package/lib/learn-host/README.md +114 -0
  17. package/lib/learn-host/eslint.config.mjs +6 -0
  18. package/lib/learn-host/next-env.d.ts +1 -1
  19. package/lib/learn-host/next.config.ts +4 -0
  20. package/lib/learn-host/package-lock.json +6039 -391
  21. package/lib/learn-host/package.json +30 -15
  22. package/lib/learn-host/public/logo.svg +1 -0
  23. package/lib/learn-host/src/app/[category]/[slug]/page.tsx +36 -32
  24. package/lib/learn-host/src/app/[category]/page.tsx +2 -3
  25. package/lib/learn-host/src/app/apple-icon.svg +1 -0
  26. package/lib/learn-host/src/app/globals.css +74 -14
  27. package/lib/learn-host/src/app/icon.svg +1 -0
  28. package/lib/learn-host/src/app/layout.tsx +29 -9
  29. package/lib/learn-host/src/app/page.tsx +9 -11
  30. package/lib/learn-host/src/components/Breadcrumbs.tsx +12 -4
  31. package/lib/learn-host/src/components/DocCard.tsx +28 -10
  32. package/lib/learn-host/src/components/MarkdownRenderer.tsx +6 -2
  33. package/lib/learn-host/src/components/MobileNav.tsx +43 -35
  34. package/lib/learn-host/src/components/PagefindSearch.tsx +177 -54
  35. package/lib/learn-host/src/components/Sidebar.tsx +27 -29
  36. package/lib/learn-host/src/components/TableOfContents.tsx +62 -0
  37. package/lib/learn-host/src/components/TagBadge.tsx +1 -1
  38. package/lib/learn-host/src/components/ThemeToggle.tsx +36 -9
  39. package/lib/learn-host/src/components/layout/Footer.tsx +41 -0
  40. package/lib/learn-host/src/components/layout/Header.tsx +117 -0
  41. package/lib/learn-host/src/lib/docs.ts +98 -8
  42. package/lib/learn-host/src/lib/types.ts +7 -1
  43. package/lib/learn-host/tsconfig.json +8 -2
  44. package/lib/learn-host/tsconfig.tsbuildinfo +1 -0
  45. package/lib/learn-mcp/CHANGELOG.md +12 -0
  46. package/lib/learn-mcp/README.md +169 -0
  47. package/lib/learn-mcp/package.json +2 -1
  48. package/lib/learn-mcp/src/index.ts +1 -1
  49. package/lib/learn-mcp/src/lib/docs.ts +1 -3
  50. package/lib/learn-mcp/src/lib/knowledge.ts +2 -1
  51. package/lib/learn-mcp/src/tools/get-review-list.ts +1 -4
  52. package/lib/learn-mcp/src/tools/search-docs.ts +1 -4
  53. package/package.json +14 -6
  54. package/dist/chunk-VHZQ6KEU.js +0 -73
  55. package/lib/learn-host/src/app/search/page.tsx +0 -19
  56. package/lib/learn-host/src/components/SearchBar.tsx +0 -36
@@ -0,0 +1,169 @@
1
+ # coding-friend-learn-mcp
2
+
3
+ MCP (Model Context Protocol) server that exposes your `/cf-learn` docs as tools for Claude — letting Claude read, search, write, and improve your learning notes directly.
4
+
5
+ ## Usage (via CLI)
6
+
7
+ ```bash
8
+ cf mcp # setup MCP for docs/learn/
9
+ cf mcp ./my-docs # setup MCP for a custom directory
10
+ ```
11
+
12
+ The CLI builds the server and prints the config to add to Claude Desktop / Claude Code.
13
+
14
+ ## Local Development
15
+
16
+ Run the server directly without the CLI — useful when working on tools or docs logic.
17
+
18
+ ### 1. Install dependencies
19
+
20
+ ```bash
21
+ cd cli/lib/learn-mcp
22
+ npm install
23
+ ```
24
+
25
+ ### 2. Run with tsx (no build needed)
26
+
27
+ The server accepts the docs directory as the first CLI argument, or via `LEARN_DOCS_DIR` env var.
28
+
29
+ ```bash
30
+ # Using argument
31
+ npx tsx src/index.ts /path/to/your/docs/learn
32
+
33
+ # Using env var
34
+ LEARN_DOCS_DIR=/path/to/your/docs/learn npx tsx src/index.ts
35
+
36
+ # Point to this repo's own learn docs
37
+ npx tsx src/index.ts ../../../docs/learn
38
+ ```
39
+
40
+ The server communicates over stdio (MCP protocol), so you won't see output when running manually — it's meant to be connected to Claude.
41
+
42
+ ### 3. Connect to Claude Code (dev mode)
43
+
44
+ Add to your project's `.mcp.json`:
45
+
46
+ ```json
47
+ {
48
+ "mcpServers": {
49
+ "coding-friend-learn": {
50
+ "type": "stdio",
51
+ "command": "npx",
52
+ "args": [
53
+ "tsx",
54
+ "/path/to/coding-friend/cli/lib/learn-mcp/src/index.ts",
55
+ "/path/to/your/docs/learn"
56
+ ]
57
+ }
58
+ }
59
+ }
60
+ ```
61
+
62
+ Or for Claude Desktop, add to `~/Library/Application Support/Claude/claude_desktop_config.json`:
63
+
64
+ ```json
65
+ {
66
+ "mcpServers": {
67
+ "coding-friend-learn": {
68
+ "command": "npx",
69
+ "args": [
70
+ "tsx",
71
+ "/path/to/coding-friend/cli/lib/learn-mcp/src/index.ts",
72
+ "/path/to/your/docs/learn"
73
+ ]
74
+ }
75
+ }
76
+ }
77
+ ```
78
+
79
+ ### 4. Watch mode (auto-rebuild)
80
+
81
+ Keep a terminal running to auto-rebuild on every file change:
82
+
83
+ ```bash
84
+ npm run dev:watch
85
+ ```
86
+
87
+ Then restart the MCP server in Claude Code (`/mcp` → restart) to pick up the latest changes.
88
+
89
+ ### 5. Build and run compiled
90
+
91
+ ```bash
92
+ npm run build
93
+ node dist/index.js /path/to/docs/learn
94
+ ```
95
+
96
+ ## Docs Directory Structure
97
+
98
+ ```
99
+ docs/
100
+ └── learn/
101
+ ├── category-one/
102
+ │ ├── my-doc.md
103
+ │ └── another-doc.md
104
+ └── category-two/
105
+ └── some-doc.md
106
+ ```
107
+
108
+ Each `.md` file needs frontmatter:
109
+
110
+ ```md
111
+ ---
112
+ title: My Doc Title
113
+ category: category-one
114
+ tags: [typescript, patterns]
115
+ created: 2025-01-01
116
+ updated: 2025-01-15
117
+ ---
118
+
119
+ Content here...
120
+ ```
121
+
122
+ ## Available Tools
123
+
124
+ | Tool | Type | Description |
125
+ | ----------------- | ----- | ------------------------------------------------ |
126
+ | `list-categories` | Read | List all doc categories |
127
+ | `list-docs` | Read | List docs (optionally filter by category or tag) |
128
+ | `read-doc` | Read | Read a specific doc by category + slug |
129
+ | `search-docs` | Read | Full-text search across all docs |
130
+ | `get-review-list` | Read | Get docs needing review |
131
+ | `create-doc` | Write | Create a new doc with frontmatter |
132
+ | `update-doc` | Write | Append content or update tags on an existing doc |
133
+ | `improve-doc` | Write | Replace doc content while preserving frontmatter |
134
+ | `track-knowledge` | Write | Mark a doc as remembered / needs-review / new |
135
+
136
+ ## Structure
137
+
138
+ ```
139
+ src/
140
+ ├── index.ts # Entry: parses docs dir, starts MCP server
141
+ ├── server.ts # Registers all tools
142
+ ├── bin/
143
+ │ └── learn-mcp.ts # CLI binary entry
144
+ ├── tools/ # One file per MCP tool
145
+ │ ├── list-categories.ts
146
+ │ ├── list-docs.ts
147
+ │ ├── read-doc.ts
148
+ │ ├── search-docs.ts
149
+ │ ├── create-doc.ts
150
+ │ ├── update-doc.ts
151
+ │ ├── improve-doc.ts
152
+ │ ├── track-knowledge.ts
153
+ │ └── get-review-list.ts
154
+ └── lib/
155
+ ├── docs.ts # Shared doc utilities (read, write, search)
156
+ ├── types.ts # TypeScript interfaces
157
+ └── knowledge.ts # Knowledge tracking state
158
+ ```
159
+
160
+ ## How It Fits Together
161
+
162
+ ```
163
+ cf mcp [path]
164
+ └─ resolves docs dir
165
+ └─ npm install + build (one-time)
166
+ └─ prints MCP config to add to Claude
167
+ ```
168
+
169
+ Once configured, Claude can call these tools directly to read and write your learning notes without leaving the conversation.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "coding-friend-learn-mcp",
3
- "version": "1.0.0",
3
+ "version": "0.0.2",
4
4
  "private": true,
5
5
  "type": "module",
6
6
  "bin": {
@@ -9,6 +9,7 @@
9
9
  "scripts": {
10
10
  "build": "tsc",
11
11
  "dev": "tsx src/index.ts",
12
+ "dev:watch": "tsc --watch --preserveWatchOutput",
12
13
  "start": "node dist/index.js"
13
14
  },
14
15
  "dependencies": {
@@ -8,7 +8,7 @@ const docsDir = path.resolve(rawDir);
8
8
 
9
9
  const server = new McpServer({
10
10
  name: "coding-friend-learn",
11
- version: "1.0.0",
11
+ version: "0.0.1",
12
12
  });
13
13
 
14
14
  registerAllTools(server, docsDir);
@@ -181,9 +181,7 @@ export function updateDoc(
181
181
  const today = new Date().toISOString().split("T")[0];
182
182
 
183
183
  if (updates.tags) {
184
- raw.data.tags = [
185
- ...new Set([...(raw.data.tags || []), ...updates.tags]),
186
- ];
184
+ raw.data.tags = [...new Set([...(raw.data.tags || []), ...updates.tags])];
187
185
  }
188
186
  if (updates.title) {
189
187
  raw.data.title = updates.title;
@@ -71,7 +71,8 @@ export function getReviewList(
71
71
  lastReviewed: null,
72
72
  reviewCount: 0,
73
73
  notes: "",
74
- firstSeen: doc.frontmatter.created || new Date().toISOString().split("T")[0]!,
74
+ firstSeen:
75
+ doc.frontmatter.created || new Date().toISOString().split("T")[0]!,
75
76
  };
76
77
 
77
78
  if (statusFilter && entry.status !== statusFilter) continue;
@@ -14,10 +14,7 @@ export function registerGetReviewList(
14
14
  .enum(["needs-review", "new"])
15
15
  .optional()
16
16
  .describe("Filter by specific status"),
17
- limit: z
18
- .number()
19
- .optional()
20
- .describe("Max number of results to return"),
17
+ limit: z.number().optional().describe("Max number of results to return"),
21
18
  },
22
19
  async ({ status, limit }) => {
23
20
  const results = getReviewList(docsDir, status, limit);
@@ -8,10 +8,7 @@ export function registerSearchDocs(server: McpServer, docsDir: string): void {
8
8
  "Full-text search across all learning docs. Searches titles, tags, and content. Optionally filter by category.",
9
9
  {
10
10
  query: z.string().describe("Search query text"),
11
- category: z
12
- .string()
13
- .optional()
14
- .describe("Limit search to this category"),
11
+ category: z.string().optional().describe("Limit search to this category"),
15
12
  },
16
13
  async ({ query, category }) => {
17
14
  const results = searchDocs(docsDir, query, category);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "coding-friend-cli",
3
- "version": "1.1.1",
3
+ "version": "1.2.1",
4
4
  "description": "CLI for coding-friend — host learning docs, setup MCP server, initialize projects",
5
5
  "type": "module",
6
6
  "bin": {
@@ -8,9 +8,12 @@
8
8
  },
9
9
  "scripts": {
10
10
  "build": "tsup src/index.ts src/postinstall.ts --format esm --dts --clean",
11
- "postinstall": "node dist/postinstall.js || true",
12
- "prepublishOnly": "npm run build && node scripts/bundle-libs.js",
13
- "dev": "tsx src/index.ts"
11
+ "postinstall": "test -f dist/postinstall.js && node dist/postinstall.js || true",
12
+ "prepublishOnly": "npm run build",
13
+ "dev": "tsx src/index.ts",
14
+ "watch": "tsup src/index.ts src/postinstall.ts --format esm --dts --watch",
15
+ "test": "vitest run",
16
+ "test:watch": "vitest"
14
17
  },
15
18
  "files": [
16
19
  "dist",
@@ -23,7 +26,11 @@
23
26
  "mcp",
24
27
  "claude"
25
28
  ],
26
- "author": "Anh-Thi Dinh",
29
+ "author": {
30
+ "name": "Anh-Thi Dinh",
31
+ "email": "me@dinhanhthi.com",
32
+ "url": "https://dinhanhthi.com"
33
+ },
27
34
  "license": "MIT",
28
35
  "repository": {
29
36
  "type": "git",
@@ -42,6 +49,7 @@
42
49
  "@types/node": "^22.0.0",
43
50
  "tsup": "^8.0.0",
44
51
  "tsx": "^4.0.0",
45
- "typescript": "^5.7.0"
52
+ "typescript": "^5.7.0",
53
+ "vitest": "^4.0.18"
46
54
  }
47
55
  }
@@ -1,73 +0,0 @@
1
- import {
2
- log
3
- } from "./chunk-6DUFTBTO.js";
4
-
5
- // src/lib/shell-completion.ts
6
- import { appendFileSync, existsSync, readFileSync } from "fs";
7
- import { homedir } from "os";
8
- var MARKER_START = "# >>> coding-friend CLI completion >>>";
9
- var MARKER_END = "# <<< coding-friend CLI completion <<<";
10
- var BASH_BLOCK = `
11
-
12
- ${MARKER_START}
13
- _cf_completions() {
14
- local cur="\${COMP_WORDS[COMP_CWORD]}"
15
- local commands="init host mcp statusline update"
16
- COMPREPLY=($(compgen -W "$commands" -- "$cur"))
17
- }
18
- complete -o default -F _cf_completions cf
19
- ${MARKER_END}
20
- `;
21
- var ZSH_BLOCK = `
22
-
23
- ${MARKER_START}
24
- _cf() {
25
- local -a commands
26
- commands=(
27
- 'init:Initialize coding-friend in current project'
28
- 'host:Build and serve learning docs as a static website'
29
- 'mcp:Setup MCP server for learning docs'
30
- 'statusline:Setup coding-friend statusline in Claude Code'
31
- 'update:Update coding-friend plugin and refresh statusline'
32
- )
33
- _describe 'command' commands
34
- }
35
- compdef _cf cf
36
- ${MARKER_END}
37
- `;
38
- function getShellRcPath() {
39
- const shell = process.env.SHELL ?? "";
40
- if (shell.includes("zsh")) return `${homedir()}/.zshrc`;
41
- return `${homedir()}/.bashrc`;
42
- }
43
- function getRcName(rcPath) {
44
- return rcPath.endsWith(".zshrc") ? ".zshrc" : ".bashrc";
45
- }
46
- function isZsh(rcPath) {
47
- return rcPath.endsWith(".zshrc");
48
- }
49
- function hasShellCompletion() {
50
- const rcPath = getShellRcPath();
51
- if (!existsSync(rcPath)) return false;
52
- return readFileSync(rcPath, "utf-8").includes(MARKER_START);
53
- }
54
- function ensureShellCompletion(opts) {
55
- const rcPath = getShellRcPath();
56
- const rcName = getRcName(rcPath);
57
- if (hasShellCompletion()) {
58
- if (!opts?.silent) log.dim(`Tab completion already in ~/${rcName}`);
59
- return false;
60
- }
61
- const block = isZsh(rcPath) ? ZSH_BLOCK : BASH_BLOCK;
62
- appendFileSync(rcPath, block);
63
- if (!opts?.silent) {
64
- log.success(`Tab completion added to ~/${rcName}`);
65
- log.dim(`Run \`source ~/${rcName}\` or open a new terminal to activate.`);
66
- }
67
- return true;
68
- }
69
-
70
- export {
71
- hasShellCompletion,
72
- ensureShellCompletion
73
- };
@@ -1,19 +0,0 @@
1
- "use client";
2
-
3
- import { Suspense } from "react";
4
- import { useSearchParams } from "next/navigation";
5
- import PagefindSearch from "@/components/PagefindSearch";
6
-
7
- function SearchWithParams() {
8
- const searchParams = useSearchParams();
9
- const query = searchParams.get("q") ?? "";
10
- return <PagefindSearch initialQuery={query} />;
11
- }
12
-
13
- export default function SearchPage() {
14
- return (
15
- <Suspense fallback={<div>Loading...</div>}>
16
- <SearchWithParams />
17
- </Suspense>
18
- );
19
- }
@@ -1,36 +0,0 @@
1
- "use client";
2
-
3
- import { useRouter } from "next/navigation";
4
- import { useState } from "react";
5
-
6
- export default function SearchBar() {
7
- const [query, setQuery] = useState("");
8
- const router = useRouter();
9
-
10
- function handleSubmit(e: React.FormEvent) {
11
- e.preventDefault();
12
- if (query.trim()) {
13
- router.push(`/search/?q=${encodeURIComponent(query.trim())}`);
14
- }
15
- }
16
-
17
- return (
18
- <form onSubmit={handleSubmit} className="relative">
19
- <svg
20
- className="absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-400"
21
- fill="none"
22
- viewBox="0 0 24 24"
23
- stroke="currentColor"
24
- >
25
- <path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z" />
26
- </svg>
27
- <input
28
- type="text"
29
- value={query}
30
- onChange={(e) => setQuery(e.target.value)}
31
- placeholder="Search docs..."
32
- className="w-full pl-10 pr-4 py-2 text-sm rounded-lg border border-gray-200 dark:border-gray-700 bg-white dark:bg-gray-800 focus:outline-none focus:ring-2 focus:ring-blue-500 dark:focus:ring-blue-400"
33
- />
34
- </form>
35
- );
36
- }