codewiki-mcp 1.0.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/.claude/skills/codewiki.md +186 -0
- package/.cursor/mcp.json +9 -0
- package/.dockerignore +10 -0
- package/.github/dependabot.yml +33 -0
- package/.github/workflows/ci.yml +42 -0
- package/.github/workflows/release.yml +36 -0
- package/.releaserc.json +16 -0
- package/CHANGELOG.md +6 -0
- package/Dockerfile +15 -0
- package/README.md +484 -0
- package/README.ru.md +484 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +59 -0
- package/dist/cli.js.map +1 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.js +13 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/batchexecute.d.ts +7 -0
- package/dist/lib/batchexecute.js +56 -0
- package/dist/lib/batchexecute.js.map +1 -0
- package/dist/lib/codewikiClient.d.ts +55 -0
- package/dist/lib/codewikiClient.js +207 -0
- package/dist/lib/codewikiClient.js.map +1 -0
- package/dist/lib/config.d.ts +8 -0
- package/dist/lib/config.js +22 -0
- package/dist/lib/config.js.map +1 -0
- package/dist/lib/errors.d.ts +26 -0
- package/dist/lib/errors.js +40 -0
- package/dist/lib/errors.js.map +1 -0
- package/dist/lib/extractKeyword.d.ts +1 -0
- package/dist/lib/extractKeyword.js +41 -0
- package/dist/lib/extractKeyword.js.map +1 -0
- package/dist/lib/repo.d.ts +9 -0
- package/dist/lib/repo.js +51 -0
- package/dist/lib/repo.js.map +1 -0
- package/dist/lib/resolveRepo.d.ts +2 -0
- package/dist/lib/resolveRepo.js +44 -0
- package/dist/lib/resolveRepo.js.map +1 -0
- package/dist/schemas.d.ts +50 -0
- package/dist/schemas.js +18 -0
- package/dist/schemas.js.map +1 -0
- package/dist/server.d.ts +10 -0
- package/dist/server.js +94 -0
- package/dist/server.js.map +1 -0
- package/dist/tools/askRepo.d.ts +4 -0
- package/dist/tools/askRepo.js +29 -0
- package/dist/tools/askRepo.js.map +1 -0
- package/dist/tools/fetchRepo.d.ts +4 -0
- package/dist/tools/fetchRepo.js +62 -0
- package/dist/tools/fetchRepo.js.map +1 -0
- package/dist/tools/searchRepos.d.ts +3 -0
- package/dist/tools/searchRepos.js +32 -0
- package/dist/tools/searchRepos.js.map +1 -0
- package/package.json +37 -0
- package/src/cli.ts +67 -0
- package/src/index.ts +32 -0
- package/src/lib/batchexecute.ts +72 -0
- package/src/lib/codewikiClient.ts +294 -0
- package/src/lib/config.ts +30 -0
- package/src/lib/errors.ts +57 -0
- package/src/lib/extractKeyword.ts +47 -0
- package/src/lib/repo.ts +70 -0
- package/src/lib/resolveRepo.ts +60 -0
- package/src/schemas.ts +22 -0
- package/src/server.ts +120 -0
- package/src/tools/askRepo.ts +38 -0
- package/src/tools/fetchRepo.ts +74 -0
- package/src/tools/searchRepos.ts +40 -0
- package/tests/batchexecute.test.ts +42 -0
- package/tests/client.test.ts +129 -0
- package/tests/errors.test.ts +122 -0
- package/tests/extractKeyword.test.ts +34 -0
- package/tests/resolveRepo.test.ts +79 -0
- package/tsconfig.json +18 -0
- package/vitest.config.ts +10 -0
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: codewiki
|
|
3
|
+
description: Research any open-source repository via codewiki.google — search, fetch wiki docs, ask questions
|
|
4
|
+
tools: ["codewiki_search_repos", "codewiki_fetch_repo", "codewiki_ask_repo"]
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# CodeWiki MCP — Skill Guide
|
|
8
|
+
|
|
9
|
+
## Available Tools
|
|
10
|
+
|
|
11
|
+
### codewiki_search_repos
|
|
12
|
+
Search repositories indexed by codewiki.google.
|
|
13
|
+
|
|
14
|
+
| Parameter | Type | Required | Description |
|
|
15
|
+
|-----------|------|----------|-------------|
|
|
16
|
+
| `query` | string | yes | Search query (library name, keyword, description) |
|
|
17
|
+
| `limit` | number | no | Max results (1-50, default 10) |
|
|
18
|
+
|
|
19
|
+
**Returns**: JSON with `query`, `count`, `items[]` (each with `fullName`, `url`, `description`, `avatarUrl`, `extraScore`), and `meta` (totalBytes, totalElapsedMs).
|
|
20
|
+
|
|
21
|
+
### codewiki_fetch_repo
|
|
22
|
+
Fetch generated wiki content for a repository.
|
|
23
|
+
|
|
24
|
+
| Parameter | Type | Required | Description |
|
|
25
|
+
|-----------|------|----------|-------------|
|
|
26
|
+
| `repo` | string | yes | Repository identifier: `owner/repo`, full GitHub URL, or natural-language query (NLP resolved) |
|
|
27
|
+
| `mode` | string | no | `"aggregate"` (default) — full markdown; `"pages"` — structured JSON per section |
|
|
28
|
+
|
|
29
|
+
**Returns**:
|
|
30
|
+
- **aggregate mode**: Markdown text with preface (repo, commit, canonical URL, response meta)
|
|
31
|
+
- **pages mode**: JSON with `repo`, `commit`, `canonicalUrl`, `pages[]` (title, level, anchor, markdown, diagramCount), and `meta`
|
|
32
|
+
|
|
33
|
+
### codewiki_ask_repo
|
|
34
|
+
Ask a natural-language question about a repository.
|
|
35
|
+
|
|
36
|
+
| Parameter | Type | Required | Description |
|
|
37
|
+
|-----------|------|----------|-------------|
|
|
38
|
+
| `repo` | string | yes | Repository identifier (same formats as fetch) |
|
|
39
|
+
| `question` | string | yes | Natural-language question about the repo |
|
|
40
|
+
| `history` | array | no | Conversation history: `[{role: "user"|"assistant", content: "..."}]` (max 20) |
|
|
41
|
+
|
|
42
|
+
**Returns**: JSON with `answer` (string) and `meta` (totalBytes, totalElapsedMs).
|
|
43
|
+
|
|
44
|
+
---
|
|
45
|
+
|
|
46
|
+
## Prompt Templates
|
|
47
|
+
|
|
48
|
+
### Study a project's architecture
|
|
49
|
+
```
|
|
50
|
+
1. codewiki_search_repos(query: "<project name>")
|
|
51
|
+
→ find the exact owner/repo
|
|
52
|
+
2. codewiki_fetch_repo(repo: "<owner/repo>", mode: "aggregate")
|
|
53
|
+
→ read the full wiki to understand architecture
|
|
54
|
+
3. codewiki_ask_repo(repo: "<owner/repo>", question: "What are the main architectural patterns and components?")
|
|
55
|
+
→ deep-dive into architecture
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### Find how a feature is implemented
|
|
59
|
+
```
|
|
60
|
+
codewiki_ask_repo(
|
|
61
|
+
repo: "<owner/repo>",
|
|
62
|
+
question: "How is <feature X> implemented? Show the key modules and data flow."
|
|
63
|
+
)
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### Compare approaches in two repos
|
|
67
|
+
```
|
|
68
|
+
1. codewiki_fetch_repo(repo: "<owner1/repo1>", mode: "pages")
|
|
69
|
+
2. codewiki_fetch_repo(repo: "<owner2/repo2>", mode: "pages")
|
|
70
|
+
3. Compare the architectural approaches, patterns, and trade-offs
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### Quick library overview
|
|
74
|
+
```
|
|
75
|
+
1. codewiki_search_repos(query: "<library>")
|
|
76
|
+
→ confirm the right repo
|
|
77
|
+
2. codewiki_fetch_repo(repo: "<owner/repo>", mode: "pages")
|
|
78
|
+
→ get structured sections
|
|
79
|
+
3. Summarize: purpose, key features, getting started, API surface
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### Explore a topic across repos
|
|
83
|
+
```
|
|
84
|
+
1. codewiki_search_repos(query: "<topic>", limit: 5)
|
|
85
|
+
→ find top repos for the topic
|
|
86
|
+
2. For each interesting repo:
|
|
87
|
+
codewiki_ask_repo(repo: "<repo>", question: "Summarize the approach to <topic>")
|
|
88
|
+
3. Synthesize findings across repos
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
---
|
|
92
|
+
|
|
93
|
+
## Workflow Chains
|
|
94
|
+
|
|
95
|
+
### Deep Research Chain
|
|
96
|
+
**Goal**: Thorough understanding of a project
|
|
97
|
+
|
|
98
|
+
1. **Search** → `codewiki_search_repos` to find the repo and confirm its full name
|
|
99
|
+
2. **Fetch overview** → `codewiki_fetch_repo(mode: "aggregate")` to read the full wiki
|
|
100
|
+
3. **Ask specific questions** → `codewiki_ask_repo` for deep-dives into specific areas
|
|
101
|
+
4. **Follow up** → Use `history` parameter to maintain context across questions
|
|
102
|
+
|
|
103
|
+
### Comparison Chain
|
|
104
|
+
**Goal**: Compare two or more implementations
|
|
105
|
+
|
|
106
|
+
1. **Fetch all** → `codewiki_fetch_repo(mode: "pages")` for each repo
|
|
107
|
+
2. **Identify patterns** → Extract architectural sections from each
|
|
108
|
+
3. **Ask targeted questions** → `codewiki_ask_repo` about specific differences
|
|
109
|
+
|
|
110
|
+
### Migration Research Chain
|
|
111
|
+
**Goal**: Understand a library for migration
|
|
112
|
+
|
|
113
|
+
1. **Search** → Find source and target libraries
|
|
114
|
+
2. **Fetch both** → Get wiki content for both
|
|
115
|
+
3. **Ask migration questions** → "What are the key API differences between X and Y?"
|
|
116
|
+
4. **Ask compatibility** → "What breaking changes should I watch for?"
|
|
117
|
+
|
|
118
|
+
---
|
|
119
|
+
|
|
120
|
+
## Error Handling
|
|
121
|
+
|
|
122
|
+
| Error Code | Meaning | Action |
|
|
123
|
+
|------------|---------|--------|
|
|
124
|
+
| `VALIDATION` | Invalid input parameters | Check parameter types and required fields |
|
|
125
|
+
| `RPC_FAIL` | CodeWiki API call failed | Retry with different query; check if repo exists on codewiki.google |
|
|
126
|
+
| `TIMEOUT` | Request timed out | Try again; for large repos, use `mode: "pages"` to get structured data |
|
|
127
|
+
| `NLP_RESOLVE_FAIL` | Could not resolve natural-language input to a repo | Use explicit `owner/repo` format instead |
|
|
128
|
+
|
|
129
|
+
When you receive an error:
|
|
130
|
+
1. Parse the error envelope: `{ error: { code, message, rpcId?, statusCode? } }`
|
|
131
|
+
2. If `RPC_FAIL` with `statusCode: 404` → repo not indexed, suggest searching first
|
|
132
|
+
3. If `TIMEOUT` → simplify query or try mode: "pages" for fetch
|
|
133
|
+
4. If `NLP_RESOLVE_FAIL` → ask user for the exact repo name
|
|
134
|
+
|
|
135
|
+
---
|
|
136
|
+
|
|
137
|
+
## Conversation History Tips
|
|
138
|
+
|
|
139
|
+
The `history` parameter in `codewiki_ask_repo` enables multi-turn conversations:
|
|
140
|
+
|
|
141
|
+
```json
|
|
142
|
+
{
|
|
143
|
+
"repo": "facebook/react",
|
|
144
|
+
"question": "How does the fiber reconciler differ?",
|
|
145
|
+
"history": [
|
|
146
|
+
{"role": "user", "content": "What is the rendering pipeline?"},
|
|
147
|
+
{"role": "assistant", "content": "React's rendering pipeline consists of..."}
|
|
148
|
+
]
|
|
149
|
+
}
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
**Best practices**:
|
|
153
|
+
- Keep history under 20 entries for optimal performance
|
|
154
|
+
- Include only relevant prior Q&A pairs
|
|
155
|
+
- Summarize long assistant responses in history to save tokens
|
|
156
|
+
- Start a new conversation (no history) when changing topics
|
|
157
|
+
|
|
158
|
+
---
|
|
159
|
+
|
|
160
|
+
## Examples
|
|
161
|
+
|
|
162
|
+
### Example 1: Quick repo lookup
|
|
163
|
+
**User**: "What does the fastify framework do?"
|
|
164
|
+
```
|
|
165
|
+
codewiki_search_repos(query: "fastify")
|
|
166
|
+
→ finds fastify/fastify
|
|
167
|
+
codewiki_ask_repo(repo: "fastify/fastify", question: "What is Fastify and what are its key features?")
|
|
168
|
+
→ comprehensive answer
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
### Example 2: Architecture deep-dive
|
|
172
|
+
**User**: "Explain how Next.js handles server-side rendering"
|
|
173
|
+
```
|
|
174
|
+
codewiki_fetch_repo(repo: "vercel/next.js", mode: "aggregate")
|
|
175
|
+
→ full wiki content
|
|
176
|
+
codewiki_ask_repo(repo: "vercel/next.js", question: "How does Next.js implement server-side rendering? Describe the request lifecycle.")
|
|
177
|
+
→ detailed SSR explanation
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
### Example 3: Library comparison
|
|
181
|
+
**User**: "Compare Express and Fastify"
|
|
182
|
+
```
|
|
183
|
+
codewiki_fetch_repo(repo: "expressjs/express", mode: "pages")
|
|
184
|
+
codewiki_fetch_repo(repo: "fastify/fastify", mode: "pages")
|
|
185
|
+
→ compare architectures, middleware patterns, performance approaches
|
|
186
|
+
```
|
package/.cursor/mcp.json
ADDED
package/.dockerignore
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
version: 2
|
|
2
|
+
|
|
3
|
+
updates:
|
|
4
|
+
- package-ecosystem: npm
|
|
5
|
+
directory: /
|
|
6
|
+
schedule:
|
|
7
|
+
interval: weekly
|
|
8
|
+
day: monday
|
|
9
|
+
open-pull-requests-limit: 10
|
|
10
|
+
labels:
|
|
11
|
+
- dependencies
|
|
12
|
+
commit-message:
|
|
13
|
+
prefix: "chore(deps):"
|
|
14
|
+
groups:
|
|
15
|
+
dev-dependencies:
|
|
16
|
+
dependency-type: development
|
|
17
|
+
update-types:
|
|
18
|
+
- minor
|
|
19
|
+
- patch
|
|
20
|
+
production-dependencies:
|
|
21
|
+
dependency-type: production
|
|
22
|
+
update-types:
|
|
23
|
+
- patch
|
|
24
|
+
|
|
25
|
+
- package-ecosystem: github-actions
|
|
26
|
+
directory: /
|
|
27
|
+
schedule:
|
|
28
|
+
interval: weekly
|
|
29
|
+
day: monday
|
|
30
|
+
labels:
|
|
31
|
+
- ci
|
|
32
|
+
commit-message:
|
|
33
|
+
prefix: "ci:"
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: [main]
|
|
8
|
+
|
|
9
|
+
permissions:
|
|
10
|
+
contents: read
|
|
11
|
+
|
|
12
|
+
jobs:
|
|
13
|
+
test:
|
|
14
|
+
runs-on: ubuntu-latest
|
|
15
|
+
strategy:
|
|
16
|
+
matrix:
|
|
17
|
+
node-version: [18, 20, 22]
|
|
18
|
+
steps:
|
|
19
|
+
- uses: actions/checkout@v4
|
|
20
|
+
|
|
21
|
+
- uses: actions/setup-node@v4
|
|
22
|
+
with:
|
|
23
|
+
node-version: ${{ matrix.node-version }}
|
|
24
|
+
cache: npm
|
|
25
|
+
|
|
26
|
+
- run: npm ci
|
|
27
|
+
- run: npm run typecheck
|
|
28
|
+
- run: npm run build
|
|
29
|
+
- run: npm run test
|
|
30
|
+
|
|
31
|
+
docker:
|
|
32
|
+
runs-on: ubuntu-latest
|
|
33
|
+
needs: test
|
|
34
|
+
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
|
|
35
|
+
steps:
|
|
36
|
+
- uses: actions/checkout@v4
|
|
37
|
+
|
|
38
|
+
- name: Build Docker image
|
|
39
|
+
run: docker build -t codewiki-mcp .
|
|
40
|
+
|
|
41
|
+
- name: Verify CLI starts
|
|
42
|
+
run: docker run --rm codewiki-mcp --help
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
name: Release
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
|
|
7
|
+
permissions:
|
|
8
|
+
contents: write
|
|
9
|
+
issues: write
|
|
10
|
+
pull-requests: write
|
|
11
|
+
id-token: write
|
|
12
|
+
|
|
13
|
+
jobs:
|
|
14
|
+
release:
|
|
15
|
+
runs-on: ubuntu-latest
|
|
16
|
+
steps:
|
|
17
|
+
- uses: actions/checkout@v4
|
|
18
|
+
with:
|
|
19
|
+
fetch-depth: 0
|
|
20
|
+
persist-credentials: false
|
|
21
|
+
|
|
22
|
+
- uses: actions/setup-node@v4
|
|
23
|
+
with:
|
|
24
|
+
node-version: 22
|
|
25
|
+
cache: npm
|
|
26
|
+
|
|
27
|
+
- run: npm ci
|
|
28
|
+
- run: npm run typecheck
|
|
29
|
+
- run: npm run build
|
|
30
|
+
- run: npm run test
|
|
31
|
+
|
|
32
|
+
- name: Semantic Release
|
|
33
|
+
env:
|
|
34
|
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
35
|
+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
36
|
+
run: npx semantic-release
|
package/.releaserc.json
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"branches": ["main"],
|
|
3
|
+
"plugins": [
|
|
4
|
+
"@semantic-release/commit-analyzer",
|
|
5
|
+
"@semantic-release/release-notes-generator",
|
|
6
|
+
"@semantic-release/changelog",
|
|
7
|
+
["@semantic-release/npm", {
|
|
8
|
+
"npmPublish": true
|
|
9
|
+
}],
|
|
10
|
+
["@semantic-release/git", {
|
|
11
|
+
"assets": ["CHANGELOG.md", "package.json", "package-lock.json"],
|
|
12
|
+
"message": "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
|
|
13
|
+
}],
|
|
14
|
+
"@semantic-release/github"
|
|
15
|
+
]
|
|
16
|
+
}
|
package/CHANGELOG.md
ADDED
package/Dockerfile
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
FROM node:22-alpine AS builder
|
|
2
|
+
WORKDIR /app
|
|
3
|
+
COPY package.json package-lock.json ./
|
|
4
|
+
RUN npm ci
|
|
5
|
+
COPY tsconfig.json ./
|
|
6
|
+
COPY src/ src/
|
|
7
|
+
RUN npm run build
|
|
8
|
+
|
|
9
|
+
FROM node:22-alpine
|
|
10
|
+
WORKDIR /app
|
|
11
|
+
COPY --from=builder /app/package.json /app/package-lock.json ./
|
|
12
|
+
RUN npm ci --omit=dev
|
|
13
|
+
COPY --from=builder /app/dist/ dist/
|
|
14
|
+
EXPOSE 3000
|
|
15
|
+
ENTRYPOINT ["node", "dist/cli.js"]
|