@stellar_ai/mcp_fossil_scm 0.1.2 → 0.2.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 +136 -123
- package/dist/capabilities.js +6 -6
- package/dist/cli.js +38 -33
- package/dist/config.js +7 -24
- package/dist/core/fossil.js +65 -77
- package/dist/core/gitignore.js +136 -0
- package/dist/core/sql.js +3 -1
- package/dist/index.js +6 -3
- package/dist/prompts.js +167 -0
- package/dist/server.js +5 -3
- package/dist/tools/admin.js +489 -82
- package/dist/tools/chat.js +16 -16
- package/dist/tools/common.js +4 -3
- package/dist/tools/forum.js +21 -18
- package/dist/tools/tickets.js +32 -10
- package/dist/tools/version-control.js +1261 -102
- package/dist/tools/wiki.js +17 -17
- package/docs/README.md +31 -0
- package/docs/admin.md +666 -0
- package/docs/chat.md +152 -0
- package/docs/forum.md +146 -0
- package/docs/prompts.md +39 -0
- package/docs/tickets.md +179 -0
- package/docs/vcs.md +1182 -0
- package/docs/wiki.md +140 -0
- package/package.json +9 -6
package/dist/tools/wiki.js
CHANGED
|
@@ -3,7 +3,7 @@ import { tmpdir } from 'node:os';
|
|
|
3
3
|
import path from 'node:path';
|
|
4
4
|
import { z } from 'zod';
|
|
5
5
|
import { renderOutcome, runFossil } from '../core/fossil.js';
|
|
6
|
-
import {
|
|
6
|
+
import { workspaceParam } from './common.js';
|
|
7
7
|
/** Matches the wording fossil uses when a wiki page does not exist yet. */
|
|
8
8
|
const MISSING_PAGE_PATTERN = /no such wiki page|not found|doesn'?t exist|does not exist/i;
|
|
9
9
|
function looksLikeMissingPage(outcome) {
|
|
@@ -13,8 +13,8 @@ function looksLikeMissingPage(outcome) {
|
|
|
13
13
|
* Lists existing page names (lower-cased) or `undefined` when the list cannot
|
|
14
14
|
* be read (e.g. the command is not run inside a check-out).
|
|
15
15
|
*/
|
|
16
|
-
async function listWikiPages(
|
|
17
|
-
const outcome = await runFossil(['wiki', 'ls'], {
|
|
16
|
+
async function listWikiPages(workspace) {
|
|
17
|
+
const outcome = await runFossil(['wiki', 'ls'], { workspace });
|
|
18
18
|
if (!outcome.ok)
|
|
19
19
|
return undefined;
|
|
20
20
|
const pages = new Set();
|
|
@@ -29,52 +29,52 @@ async function listWikiPages(cwd) {
|
|
|
29
29
|
* Writes the page with `create` or `commit`, choosing the right sub-command up
|
|
30
30
|
* front (one extra call) instead of always failing a `commit` first.
|
|
31
31
|
*/
|
|
32
|
-
async function writeWikiPage(pageName, file,
|
|
32
|
+
async function writeWikiPage(pageName, file, workspace) {
|
|
33
33
|
const key = pageName.trim().toLowerCase();
|
|
34
|
-
const pages = await listWikiPages(
|
|
34
|
+
const pages = await listWikiPages(workspace);
|
|
35
35
|
const pageExists = pages === undefined ? undefined : pages.has(key);
|
|
36
36
|
if (pageExists === false) {
|
|
37
|
-
const created = await runFossil(['wiki', 'create', pageName, file], {
|
|
37
|
+
const created = await runFossil(['wiki', 'create', pageName, file], { workspace });
|
|
38
38
|
// The page may have appeared between the listing and the create: retry as commit.
|
|
39
|
-
return created.ok ? created : runFossil(['wiki', 'commit', pageName, file], {
|
|
39
|
+
return created.ok ? created : runFossil(['wiki', 'commit', pageName, file], { workspace });
|
|
40
40
|
}
|
|
41
|
-
const committed = await runFossil(['wiki', 'commit', pageName, file], {
|
|
41
|
+
const committed = await runFossil(['wiki', 'commit', pageName, file], { workspace });
|
|
42
42
|
if (committed.ok || pageExists === true)
|
|
43
43
|
return committed;
|
|
44
44
|
// Page list unavailable: a "missing page" error means the page must be created.
|
|
45
|
-
return looksLikeMissingPage(committed) ? runFossil(['wiki', 'create', pageName, file], {
|
|
45
|
+
return looksLikeMissingPage(committed) ? runFossil(['wiki', 'create', pageName, file], { workspace }) : committed;
|
|
46
46
|
}
|
|
47
47
|
/** Wiki tools: list, read (raw export) and write pages. */
|
|
48
48
|
export function registerWikiTools(server) {
|
|
49
49
|
server.registerTool('fossil_wiki_ls', {
|
|
50
50
|
title: 'List wiki pages',
|
|
51
51
|
description: 'List every wiki page in the repository.',
|
|
52
|
-
inputSchema: z.object({
|
|
52
|
+
inputSchema: z.object({ workspace: workspaceParam }),
|
|
53
53
|
annotations: { readOnlyHint: true },
|
|
54
|
-
}, async ({
|
|
54
|
+
}, async ({ workspace }) => renderOutcome(await runFossil(['wiki', 'ls'], { workspace }), { emptyText: 'No wiki pages.' }));
|
|
55
55
|
server.registerTool('fossil_wiki_read', {
|
|
56
56
|
title: 'Read wiki page',
|
|
57
57
|
description: 'Export a wiki page as raw markdown/wiki text.',
|
|
58
58
|
inputSchema: z.object({
|
|
59
59
|
page_name: z.string().min(1).describe('Wiki page name.'),
|
|
60
|
-
|
|
60
|
+
workspace: workspaceParam,
|
|
61
61
|
}),
|
|
62
62
|
annotations: { readOnlyHint: true },
|
|
63
|
-
}, async ({ page_name,
|
|
63
|
+
}, async ({ page_name, workspace }) => renderOutcome(await runFossil(['wiki', 'export', page_name], { workspace })));
|
|
64
64
|
server.registerTool('fossil_wiki_write', {
|
|
65
65
|
title: 'Write wiki page',
|
|
66
|
-
description: 'Create or replace a wiki page.
|
|
66
|
+
description: 'Create or replace a wiki page.',
|
|
67
67
|
inputSchema: z.object({
|
|
68
68
|
page_name: z.string().min(1).describe('Wiki page name (created when missing).'),
|
|
69
69
|
content: z.string().describe('Full markdown/wiki content of the page.'),
|
|
70
|
-
|
|
70
|
+
workspace: workspaceParam,
|
|
71
71
|
}),
|
|
72
|
-
}, async ({ page_name, content,
|
|
72
|
+
}, async ({ page_name, content, workspace }) => {
|
|
73
73
|
const dir = await mkdtemp(path.join(tmpdir(), 'fossil-wiki-'));
|
|
74
74
|
const file = path.join(dir, 'page.md');
|
|
75
75
|
try {
|
|
76
76
|
await writeFile(file, content, 'utf8');
|
|
77
|
-
const outcome = await writeWikiPage(page_name, file,
|
|
77
|
+
const outcome = await writeWikiPage(page_name, file, workspace);
|
|
78
78
|
return renderOutcome(outcome, { note: `Wiki page '${page_name}' saved.` });
|
|
79
79
|
}
|
|
80
80
|
finally {
|
package/docs/README.md
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# 文件索引
|
|
2
|
+
|
|
3
|
+
按能力分冊,每冊包含:能力概覽表、通用約定、逐工具的參數表與真實 argv/輸出、典型流程、已知邊界、原始碼位置。
|
|
4
|
+
所有內容在 fossil 2.21 + `@stellar_ai/mcp_fossil_scm@0.2.0` 上實測。
|
|
5
|
+
|
|
6
|
+
| 文件 | 能力 | `-c` | 工具數 |
|
|
7
|
+
| --- | --- | --- | --- |
|
|
8
|
+
| [admin.md](./admin.md) | 倉庫管理 | `a` | 11 |
|
|
9
|
+
| [vcs.md](./vcs.md) | 版本控制:status / diff / commit / branch / blame / grep / … | `v` | 40 |
|
|
10
|
+
| [forum.md](./forum.md) | 論壇 | `f` | 3 |
|
|
11
|
+
| [tickets.md](./tickets.md) | 工單 | `t` | 4 |
|
|
12
|
+
| [wiki.md](./wiki.md) | Wiki 頁面 | `w` | 3 |
|
|
13
|
+
| [chat.md](./chat.md) | 聊天室 | `c` | 4 |
|
|
14
|
+
| [prompts.md](./prompts.md) | MCP 提示(`prompts/list` / `prompts/get`) | — | 8 |
|
|
15
|
+
|
|
16
|
+
合計 65 個工具;`-c All` 啟用全部。
|
|
17
|
+
|
|
18
|
+
## 閱讀順序
|
|
19
|
+
|
|
20
|
+
1. [admin.md](./admin.md) §2 —— `workspace` 與 `repository` 兩個概念,所有能力共用,先看這裡。
|
|
21
|
+
2. [prompts.md](./prompts.md) —— 內建的 MCP 提示,把常用的多步流程寫成一段指示。
|
|
22
|
+
3. 然後按需跳到具體能力分冊。VCS 與內容類能力(`v/f/t/w/c`)以 check-out 為前提;`fossil_sql` 可用 `repository` 直接查詢。
|
|
23
|
+
|
|
24
|
+
## 約定速查
|
|
25
|
+
|
|
26
|
+
- **命令**:可執行檔案叫 `fossil`(可用 `FOSSIL_BIN` 覆蓋),產品名/伺服器名是 `fossil-scm`。
|
|
27
|
+
- **目錄**:只有一個概念 `workspace`;工具參數 `workspace`、命令列 `--workspace DIR`、
|
|
28
|
+
環境變數 `FOSSIL_WORKSPACE`,最後兜底 `process.cwd()`。
|
|
29
|
+
- **倉庫**:沒有預設位置,必須由呼叫方給 `repository`;不自動補 `.fossil` 後綴。
|
|
30
|
+
- **失敗**:`isError: true` + `ERROR: Fossil command failed (exit code N).` + 原始輸出 + `COMMAND` / `WORKSPACE`。
|
|
31
|
+
- **超時**:普通命令 `FOSSIL_TIMEOUT_MS`(30s),網路命令 `FOSSIL_NETWORK_TIMEOUT_MS`(600s)。
|