@stellar_ai/mcp_fossil_scm 0.2.1 → 0.2.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.
- package/README.md +32 -30
- package/dist/capabilities.js +30 -22
- package/dist/cli.js +11 -11
- package/dist/config.js +1 -1
- package/dist/core/gitignore.js +7 -4
- package/dist/index.js +1 -1
- package/dist/prompts.js +28 -30
- package/dist/tools/admin.js +54 -54
- package/dist/tools/utils.js +237 -0
- package/dist/tools/version-control.js +1 -231
- package/docs/README.md +6 -5
- package/docs/admin.md +45 -43
- package/docs/chat.md +1 -1
- package/docs/forum.md +1 -1
- package/docs/prompts.md +4 -4
- package/docs/tickets.md +1 -1
- package/docs/utils.md +262 -0
- package/docs/vcs.md +28 -235
- package/docs/wiki.md +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -2,19 +2,20 @@
|
|
|
2
2
|
|
|
3
3
|
[Fossil SCM](https://fossil-scm.org/) 的 MCP(Model Context Protocol)伺服器。
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
七種能力(Admin、Utils、VCS、Tickets、Chat、Forum、Wiki)、一個執行檔、一組字母:`--capability` 決定這個行程
|
|
6
6
|
要暴露哪些工具組,客戶端只載入需要的部分。每個字母是其能力名稱的**首字母**。
|
|
7
7
|
|
|
8
8
|
| 字母 | 能力 | 工具 | 暴露的內容 |
|
|
9
9
|
| --- | --- | --- | --- |
|
|
10
|
-
| `a` | **A**dmin | 11 | 倉庫生命週期:`init`、`open`、`close`、`clone`、`settings`、`remote`、`push`、`pull`、`sync`、`rebuild
|
|
11
|
-
| `
|
|
12
|
-
| `
|
|
10
|
+
| `a` | **A**dmin | 11 | 倉庫生命週期:`init`、`open`、`close`、`clone`、`settings`、`remote`、`push`、`pull`、`sync`、`config`、`rebuild` |
|
|
11
|
+
| `u` | **U**tils | 7 | 通用工具:檔案/工件讀取、SQL 查詢、歷史 grep/search、`.gitignore` 轉換 |
|
|
12
|
+
| `v` | **V**CS | 33 | 版本控制:status、diff、歷史、add/commit、branch、merge、update、undo、blame … |
|
|
13
13
|
| `t` | **T**ickets | 4 | 工單報表、建立、欄位更新 |
|
|
14
|
-
| `w` | **W**iki | 3 | 列表、匯出與建立/覆寫 wiki 頁面 |
|
|
15
14
|
| `c` | **C**hat | 4 | 聊天室 URL、傳送、拉取歷史、讀取本地訊息 |
|
|
15
|
+
| `f` | **F**orum | 3 | 論壇主題列表、讀取與文字搜尋(只讀) |
|
|
16
|
+
| `w` | **W**iki | 3 | 列表、匯出與建立/覆寫 wiki 頁面 |
|
|
16
17
|
|
|
17
|
-
字母**寫在單一值裡**:`-c v`(
|
|
18
|
+
字母**寫在單一值裡**:`-c v`(33 個工具)、`-c auv`(51)、`-c tcfw`(14),`-c All` 為全部
|
|
18
19
|
(65,也是預設)。
|
|
19
20
|
|
|
20
21
|
## 需求
|
|
@@ -26,7 +27,7 @@
|
|
|
26
27
|
|
|
27
28
|
```bash
|
|
28
29
|
pnpm add @stellar_ai/mcp_fossil_scm # or: npm i -g @stellar_ai/mcp_fossil_scm
|
|
29
|
-
npx -y @stellar_ai/mcp_fossil_scm -c
|
|
30
|
+
npx -y @stellar_ai/mcp_fossil_scm -c auv --workspace /path/to/workspace
|
|
30
31
|
```
|
|
31
32
|
|
|
32
33
|
## 從原始碼建置與執行
|
|
@@ -36,15 +37,15 @@ pnpm install
|
|
|
36
37
|
pnpm build
|
|
37
38
|
|
|
38
39
|
node dist/index.js -c v --workspace /path/to/workspace # 只啟用版本控制
|
|
39
|
-
node dist/index.js -c
|
|
40
|
-
node dist/index.js -c
|
|
40
|
+
node dist/index.js -c auv --workspace /path/to/workspace # admin + utils + VCS
|
|
41
|
+
node dist/index.js -c tcfw --workspace /path/to/workspace # tickets + chat + forum + wiki
|
|
41
42
|
node dist/index.js -c All --workspace /path/to/workspace # 全部
|
|
42
43
|
```
|
|
43
44
|
|
|
44
45
|
`npm link` 或全域安裝後,同一個執行檔以 `fossil-scm` 出現在 `PATH` 上:
|
|
45
46
|
|
|
46
47
|
```bash
|
|
47
|
-
fossil-scm -c
|
|
48
|
+
fossil-scm -c auv --workspace /path/to/workspace
|
|
48
49
|
```
|
|
49
50
|
|
|
50
51
|
### 從 MCP 客戶端選擇性啟用
|
|
@@ -89,14 +90,14 @@ fossil-scm -c avf --workspace /path/to/workspace
|
|
|
89
90
|
|
|
90
91
|
| 命令列旗標 | 意義 |
|
|
91
92
|
| --- | --- |
|
|
92
|
-
| `-c, --capability LIST` | 能力寫在同一個值裡:`a` `
|
|
93
|
+
| `-c, --capability LIST` | 能力寫在同一個值裡:`a` `u` `v` `t` `c` `f` `w` → `-c auv`;`-c All` 為全部。預設取 `FOSSIL_CAPABILITIES`,再無則 `All` |
|
|
93
94
|
| `--workspace DIR` | 工具呼叫省略 `workspace` 時的預設工作區;未給時用行程工作目錄 |
|
|
94
95
|
| `--verbose`, `-v` | 在 stderr 輸出診斷訊息(stdout 保留給協定) |
|
|
95
96
|
| `--help`, `-h` | 用法、能力表與範例 |
|
|
96
97
|
|
|
97
98
|
| 環境變數 | 預設 | 意義 |
|
|
98
99
|
| --- | --- | --- |
|
|
99
|
-
| `FOSSIL_CAPABILITIES` | `All` | 預設能力(語法同 `--capability`,例如 `
|
|
100
|
+
| `FOSSIL_CAPABILITIES` | `All` | 預設能力(語法同 `--capability`,例如 `auv` 或 `All`) |
|
|
100
101
|
| `FOSSIL_WORKSPACE` | 行程 cwd | 預設工作區 |
|
|
101
102
|
| `FOSSIL_BIN` | `fossil` | Fossil 執行檔(也可給完整路徑) |
|
|
102
103
|
| `FOSSIL_TIMEOUT_MS` | `30000` | 一般命令的逾時 |
|
|
@@ -109,29 +110,30 @@ fossil-scm -c avf --workspace /path/to/workspace
|
|
|
109
110
|
## 工具
|
|
110
111
|
|
|
111
112
|
**`a` Admin(11)** — `fossil_init`、`fossil_open`、`fossil_close`、`fossil_clone`、`fossil_settings`、
|
|
112
|
-
`fossil_remote`、`fossil_push`、`fossil_pull`、`fossil_sync`、`fossil_rebuild
|
|
113
|
+
`fossil_remote`、`fossil_push`、`fossil_pull`、`fossil_sync`、`fossil_config`、`fossil_rebuild`
|
|
113
114
|
|
|
114
|
-
**`
|
|
115
|
+
**`u` Utils(7)** — `fossil_cat`、`fossil_grep`、`fossil_whatis`、`fossil_ignore_from_gitignore`、
|
|
116
|
+
`fossil_search`、`fossil_artifact`、`fossil_sql`
|
|
117
|
+
|
|
118
|
+
**`v` VCS(33)** — `fossil_status`、`fossil_diff`、`fossil_finfo`、`fossil_revert`、
|
|
115
119
|
`fossil_stash`、`fossil_tag`、`fossil_addremove`、`fossil_commit`、`fossil_add`、`fossil_rm`、`fossil_mv`、
|
|
116
120
|
`fossil_extras`、`fossil_clean`、`fossil_timeline`、`fossil_info`、`fossil_branch`、`fossil_merge`、
|
|
117
|
-
`fossil_update`、`fossil_undo`、`fossil_changes`、`fossil_annotate`、`
|
|
118
|
-
`
|
|
119
|
-
`
|
|
120
|
-
`fossil_touch`、`fossil_amend`、`fossil_patch`、`fossil_bisect`、`fossil_sql`、
|
|
121
|
-
`fossil_ignore_from_gitignore`
|
|
122
|
-
|
|
123
|
-
**`f` Forum(3)** — `fossil_forum_list`、`fossil_forum_read`、`fossil_forum_search`
|
|
121
|
+
`fossil_update`、`fossil_undo`、`fossil_changes`、`fossil_annotate`、`fossil_merge_base`、`fossil_leaves`、
|
|
122
|
+
`fossil_descendants`、`fossil_unpublished`、`fossil_ls`、`fossil_describe`、`fossil_archive`、
|
|
123
|
+
`fossil_unversioned`、`fossil_touch`、`fossil_amend`、`fossil_patch`、`fossil_bisect`
|
|
124
124
|
|
|
125
125
|
**`t` Tickets(4)** — `fossil_ticket_list`、`fossil_ticket_show`、`fossil_ticket_create`、
|
|
126
126
|
`fossil_ticket_update`
|
|
127
127
|
|
|
128
|
-
**`w` Wiki(3)** — `fossil_wiki_ls`、`fossil_wiki_read`、`fossil_wiki_write`
|
|
129
|
-
|
|
130
128
|
**`c` Chat(4)** — `fossil_chat_url`、`fossil_chat_send`、`fossil_chat_pull`、`fossil_chat_read`
|
|
131
129
|
|
|
130
|
+
**`f` Forum(3)** — `fossil_forum_list`、`fossil_forum_read`、`fossil_forum_search`
|
|
131
|
+
|
|
132
|
+
**`w` Wiki(3)** — `fossil_wiki_ls`、`fossil_wiki_read`、`fossil_wiki_write`
|
|
133
|
+
|
|
132
134
|
`fossil_init`(能力 `a`)只建倉庫資料庫,`fossil_open` 只建 check-out。組態歸專案所有
|
|
133
|
-
(`.fossil-settings/`、`.editorconfig` …)。VCS 與內容類能力(`v`、`f`、`
|
|
134
|
-
裡已有開啟的 check-out
|
|
135
|
+
(`.fossil-settings/`、`.editorconfig` …)。VCS 與內容類能力(`v`、`t`、`c`、`f`、`w`)要求 `workspace`
|
|
136
|
+
裡已有開啟的 check-out;Utils 的 `fossil_cat`、`fossil_artifact`、`fossil_sql` 可以直接讀倉庫檔。
|
|
135
137
|
|
|
136
138
|
### 能力說明
|
|
137
139
|
|
|
@@ -149,19 +151,19 @@ fossil-scm -c avf --workspace /path/to/workspace
|
|
|
149
151
|
把常用的多步流程寫成一段指示交給模型。
|
|
150
152
|
|
|
151
153
|
逐工具說明(參數、真實 argv、真實輸出、邊界情況)在 [`docs/`](./docs/README.md):
|
|
152
|
-
[admin](./docs/admin.md)、[
|
|
153
|
-
[
|
|
154
|
+
[admin](./docs/admin.md)、[utils](./docs/utils.md)、[VCS](./docs/vcs.md)、[tickets](./docs/tickets.md)、
|
|
155
|
+
[chat](./docs/chat.md)、[forum](./docs/forum.md)、[wiki](./docs/wiki.md)、[prompts](./docs/prompts.md)。
|
|
154
156
|
|
|
155
157
|
## 設計重點
|
|
156
158
|
|
|
157
|
-
- **可選能力、單一執行檔。** 工具按能力組註冊(`src/capabilities.ts`:Admin、VCS、
|
|
158
|
-
|
|
159
|
+
- **可選能力、單一執行檔。** 工具按能力組註冊(`src/capabilities.ts`:Admin、Utils、VCS、Tickets、Chat、
|
|
160
|
+
Forum、Wiki),`--capability` 取寫在同一值裡的首字母(`auv`、`tcfw`、`All` 為全部)或 `FOSSIL_CAPABILITIES`,
|
|
159
161
|
客戶端只啟用需要的部分。
|
|
160
162
|
- **不會互動卡住。** 不經 shell 的 `spawn`、stdin 一律關閉、`SIGTERM`→`SIGKILL` 升級、逐命令逾時。
|
|
161
163
|
提交流程仍以 `a` 回答 "commit anyhow" 提示。
|
|
162
164
|
- **組態歸專案所有。** `fossil_init` 建資料庫、`fossil_open` 建 check-out;設定存在倉庫自己的
|
|
163
165
|
`.fossil-settings/*`,同一個倉庫在每個客戶端行為一致。
|
|
164
|
-
- **更少的行程。** `
|
|
166
|
+
- **更少的行程。** `fossil_wiki_write` 用一次頁面列表決定
|
|
165
167
|
`create` 還是 `commit`,不用先失敗一次 `commit`。
|
|
166
168
|
- **真實的錯誤語義。** 失敗回傳 `isError: true`,附退出碼、stdout/stderr 與實際執行的命令,呼叫方不必從
|
|
167
169
|
字串裡嗅 `"ERROR:"`。Admin 另外補上提示:`fossil_init` 建父目錄、`fossil_settings` 可讀寫清除並限定範圍
|
package/dist/capabilities.js
CHANGED
|
@@ -2,44 +2,45 @@ import { registerAdminTools } from './tools/admin.js';
|
|
|
2
2
|
import { registerChatTools } from './tools/chat.js';
|
|
3
3
|
import { registerForumTools } from './tools/forum.js';
|
|
4
4
|
import { registerTicketTools } from './tools/tickets.js';
|
|
5
|
+
import { registerUtilsTools } from './tools/utils.js';
|
|
5
6
|
import { registerVersionControlTools } from './tools/version-control.js';
|
|
6
7
|
import { registerWikiTools } from './tools/wiki.js';
|
|
7
8
|
/**
|
|
8
9
|
* Every capability the package can expose, in display order.
|
|
9
|
-
* Each id is the initial of its capability: a=Admin,
|
|
10
|
-
* t=Tickets,
|
|
10
|
+
* Each id is the initial of its capability: a=Admin, u=Utils, v=VCS,
|
|
11
|
+
* t=Tickets, c=Chat, f=Forum, w=Wiki.
|
|
11
12
|
*/
|
|
12
|
-
export const CAPABILITY_IDS = ['a', '
|
|
13
|
+
export const CAPABILITY_IDS = ['a', 'u', 'v', 't', 'c', 'f', 'w'];
|
|
13
14
|
/**
|
|
14
15
|
* The capability groups, keyed by the initial of the capability name:
|
|
15
16
|
*
|
|
16
|
-
* a = Admin
|
|
17
|
+
* a = Admin u = Utils v = VCS t = Tickets c = Chat f = Forum w = Wiki
|
|
17
18
|
*
|
|
18
|
-
* `--capability v` exposes only the version-control tools, `--capability
|
|
19
|
+
* `--capability v` exposes only the version-control tools, `--capability auv`
|
|
19
20
|
* is a three-group server, and so on.
|
|
20
21
|
*/
|
|
21
22
|
export const CAPABILITIES = {
|
|
22
23
|
a: {
|
|
23
24
|
id: 'a',
|
|
24
25
|
title: 'Admin',
|
|
25
|
-
description: 'Repository lifecycle (init/open/close/clone/
|
|
26
|
+
description: 'Repository lifecycle (init/open/close/clone/rebuild), settings, remote URLs and sync',
|
|
26
27
|
toolCount: 11,
|
|
27
28
|
register: registerAdminTools,
|
|
28
29
|
},
|
|
30
|
+
u: {
|
|
31
|
+
id: 'u',
|
|
32
|
+
title: 'Utils',
|
|
33
|
+
description: 'File and artifact reads, SQL queries, history grep/search and .gitignore conversion',
|
|
34
|
+
toolCount: 7,
|
|
35
|
+
register: registerUtilsTools,
|
|
36
|
+
},
|
|
29
37
|
v: {
|
|
30
38
|
id: 'v',
|
|
31
39
|
title: 'VCS',
|
|
32
|
-
description: 'Version control: working tree, history, commits, branches
|
|
33
|
-
toolCount:
|
|
40
|
+
description: 'Version control: working tree, history, commits, branches and ignore rules',
|
|
41
|
+
toolCount: 33,
|
|
34
42
|
register: registerVersionControlTools,
|
|
35
43
|
},
|
|
36
|
-
f: {
|
|
37
|
-
id: 'f',
|
|
38
|
-
title: 'Forum',
|
|
39
|
-
description: 'Read-only forum threads, posts and full-text search',
|
|
40
|
-
toolCount: 3,
|
|
41
|
-
register: registerForumTools,
|
|
42
|
-
},
|
|
43
44
|
t: {
|
|
44
45
|
id: 't',
|
|
45
46
|
title: 'Tickets',
|
|
@@ -47,13 +48,6 @@ export const CAPABILITIES = {
|
|
|
47
48
|
toolCount: 4,
|
|
48
49
|
register: registerTicketTools,
|
|
49
50
|
},
|
|
50
|
-
w: {
|
|
51
|
-
id: 'w',
|
|
52
|
-
title: 'Wiki',
|
|
53
|
-
description: 'List, export and create/replace wiki pages',
|
|
54
|
-
toolCount: 3,
|
|
55
|
-
register: registerWikiTools,
|
|
56
|
-
},
|
|
57
51
|
c: {
|
|
58
52
|
id: 'c',
|
|
59
53
|
title: 'Chat',
|
|
@@ -61,6 +55,20 @@ export const CAPABILITIES = {
|
|
|
61
55
|
toolCount: 4,
|
|
62
56
|
register: registerChatTools,
|
|
63
57
|
},
|
|
58
|
+
f: {
|
|
59
|
+
id: 'f',
|
|
60
|
+
title: 'Forum',
|
|
61
|
+
description: 'Read-only forum threads, posts and full-text search',
|
|
62
|
+
toolCount: 3,
|
|
63
|
+
register: registerForumTools,
|
|
64
|
+
},
|
|
65
|
+
w: {
|
|
66
|
+
id: 'w',
|
|
67
|
+
title: 'Wiki',
|
|
68
|
+
description: 'List, export and create/replace wiki pages',
|
|
69
|
+
toolCount: 3,
|
|
70
|
+
register: registerWikiTools,
|
|
71
|
+
},
|
|
64
72
|
};
|
|
65
73
|
export function isCapabilityId(value) {
|
|
66
74
|
return CAPABILITY_IDS.includes(value);
|
package/dist/cli.js
CHANGED
|
@@ -11,7 +11,7 @@ export class UsageError extends Error {
|
|
|
11
11
|
* Adds one `--capability` value.
|
|
12
12
|
*
|
|
13
13
|
* `All` selects every capability. Otherwise the value is a run of lowercase
|
|
14
|
-
* initials written together (`
|
|
14
|
+
* initials written together (`auv`, `tcfw`); separators are rejected.
|
|
15
15
|
*/
|
|
16
16
|
function addCapabilities(spec, selected) {
|
|
17
17
|
const value = spec.trim();
|
|
@@ -26,7 +26,7 @@ function addCapabilities(spec, selected) {
|
|
|
26
26
|
if (unknown.length > 0) {
|
|
27
27
|
const hint = value.toLowerCase() === 'all'
|
|
28
28
|
? "Use 'All' for every capability."
|
|
29
|
-
: "Use the letters together, e.g. '
|
|
29
|
+
: "Use the letters together, e.g. 'auv'.";
|
|
30
30
|
throw new UsageError(`unknown capability '${unknown[0]}'${value.length > 1 ? ` in '${value}'` : ''}. ${hint} ` +
|
|
31
31
|
`Valid letters: ${CAPABILITY_IDS.map((id) => `${id}=${CAPABILITIES[id].title}`).join(', ')}, or All for everything.`);
|
|
32
32
|
}
|
|
@@ -38,7 +38,7 @@ function addCapabilities(spec, selected) {
|
|
|
38
38
|
/**
|
|
39
39
|
* Parses the command line.
|
|
40
40
|
*
|
|
41
|
-
* `--capability` takes capability initials written together (`
|
|
41
|
+
* `--capability` takes capability initials written together (`auv`, `tcfw`) or
|
|
42
42
|
* the word `All` for everything; when it is absent the list comes from
|
|
43
43
|
* `FOSSIL_CAPABILITIES` (or every capability). `--workspace DIR` (or
|
|
44
44
|
* `FOSSIL_WORKSPACE`) sets the default workspace; otherwise tool calls fall
|
|
@@ -78,9 +78,9 @@ export function parseArgs(argv, env = process.env) {
|
|
|
78
78
|
workspace = value;
|
|
79
79
|
}
|
|
80
80
|
else {
|
|
81
|
-
// Exactly one value: all letters belong together, e.g. -c
|
|
81
|
+
// Exactly one value: all letters belong together, e.g. -c auv.
|
|
82
82
|
if (explicitCapabilities) {
|
|
83
|
-
throw new UsageError('give all capability letters in a single value, e.g. -c
|
|
83
|
+
throw new UsageError('give all capability letters in a single value, e.g. -c auv.');
|
|
84
84
|
}
|
|
85
85
|
explicitCapabilities = true;
|
|
86
86
|
addCapabilities(value, selected);
|
|
@@ -91,7 +91,7 @@ export function parseArgs(argv, env = process.env) {
|
|
|
91
91
|
}
|
|
92
92
|
const capabilities = [...selected];
|
|
93
93
|
if (capabilities.length === 0) {
|
|
94
|
-
throw new UsageError("no capability selected; use --capability (e.g. '
|
|
94
|
+
throw new UsageError("no capability selected; use --capability (e.g. 'auv') or FOSSIL_CAPABILITIES, or 'All'.");
|
|
95
95
|
}
|
|
96
96
|
return { workspace, capabilities, verbose, help };
|
|
97
97
|
}
|
|
@@ -107,8 +107,8 @@ export function helpText() {
|
|
|
107
107
|
'',
|
|
108
108
|
'Options:',
|
|
109
109
|
' -c, --capability LIST Capability initials written together in one value:',
|
|
110
|
-
' a(Admin)
|
|
111
|
-
' e.g. "-c
|
|
110
|
+
' a(Admin) u(Utils) v(VCS) t(Tickets) c(Chat) f(Forum) w(Wiki),',
|
|
111
|
+
' e.g. "-c auv". "-c All" selects everything.',
|
|
112
112
|
' Default: FOSSIL_CAPABILITIES, else every capability.',
|
|
113
113
|
' Each selected group contributes its tools to this one server.',
|
|
114
114
|
' --workspace DIR Default workspace for every tool call.',
|
|
@@ -120,9 +120,9 @@ export function helpText() {
|
|
|
120
120
|
...rows,
|
|
121
121
|
'',
|
|
122
122
|
'Examples:',
|
|
123
|
-
` ${SERVER_NAME} -c v # version control only (
|
|
124
|
-
` ${SERVER_NAME} -c
|
|
125
|
-
` ${SERVER_NAME} -c
|
|
123
|
+
` ${SERVER_NAME} -c v # version control only (33 tools)`,
|
|
124
|
+
` ${SERVER_NAME} -c auv # admin + utils + VCS (51 tools)`,
|
|
125
|
+
` ${SERVER_NAME} -c tcfw # tickets + chat + forum + wiki (14 tools)`,
|
|
126
126
|
` ${SERVER_NAME} -c All # everything (65 tools)`,
|
|
127
127
|
'',
|
|
128
128
|
'Prompts: fossil-review-changes, fossil-commit-workflow, fossil-ignore-conversion,',
|
package/dist/config.js
CHANGED
|
@@ -9,7 +9,7 @@ function readPositiveInt(name, fallback) {
|
|
|
9
9
|
}
|
|
10
10
|
/** Server/product name. The fossil *binary* stays `fossil` (see FOSSIL_BIN). */
|
|
11
11
|
export const SERVER_NAME = 'fossil-scm';
|
|
12
|
-
export const SERVER_VERSION = '0.2.
|
|
12
|
+
export const SERVER_VERSION = '0.2.2';
|
|
13
13
|
/**
|
|
14
14
|
* The Fossil executable. The command is named `fossil`; only the server/product
|
|
15
15
|
* name is written `fossil-scm`. Override with FOSSIL_BIN (e.g. a full path on Windows).
|
package/dist/core/gitignore.js
CHANGED
|
@@ -70,17 +70,20 @@ export function convertGitignore(text, options = {}) {
|
|
|
70
70
|
continue;
|
|
71
71
|
}
|
|
72
72
|
let pattern = unescapeGit(line);
|
|
73
|
-
const
|
|
74
|
-
if (
|
|
73
|
+
const leadingSlash = pattern.startsWith('/');
|
|
74
|
+
if (leadingSlash)
|
|
75
75
|
pattern = pattern.slice(1);
|
|
76
76
|
if (pattern.endsWith('/'))
|
|
77
77
|
pattern = pattern.slice(0, -1);
|
|
78
78
|
if (pattern === '' || pattern === '.')
|
|
79
79
|
continue;
|
|
80
|
+
// A rule that starts with `/` or holds a slash is relative to the directory
|
|
81
|
+
// of the .gitignore file; every other rule matches at any depth.
|
|
82
|
+
const anchoredRule = leadingSlash || pattern.includes('/');
|
|
80
83
|
if (pattern.includes('**')) {
|
|
81
84
|
const variants = expandDoubleStar(pattern);
|
|
82
85
|
for (const variant of variants) {
|
|
83
|
-
for (const expanded of expandRule(variant, prefix,
|
|
86
|
+
for (const expanded of expandRule(variant, prefix, anchoredRule))
|
|
84
87
|
push(expanded);
|
|
85
88
|
}
|
|
86
89
|
warnings.push(variants.length > 1
|
|
@@ -88,7 +91,7 @@ export function convertGitignore(text, options = {}) {
|
|
|
88
91
|
: `\`**\` in ${line} treated as \`*\``);
|
|
89
92
|
continue;
|
|
90
93
|
}
|
|
91
|
-
for (const expanded of expandRule(pattern, prefix,
|
|
94
|
+
for (const expanded of expandRule(pattern, prefix, anchoredRule))
|
|
92
95
|
push(expanded);
|
|
93
96
|
}
|
|
94
97
|
return { patterns, warnings, lineCount };
|
package/dist/index.js
CHANGED
package/dist/prompts.js
CHANGED
|
@@ -53,39 +53,21 @@ export function registerPrompts(server, ids) {
|
|
|
53
53
|
: '4. Write a one-line message in the style of the recent history, then commit with `fossil_commit`.',
|
|
54
54
|
'5. Confirm the result with `fossil_timeline { limit: 1 }`.',
|
|
55
55
|
].join('\n')));
|
|
56
|
-
server.registerPrompt('fossil-ignore-conversion', {
|
|
57
|
-
title: 'Convert .gitignore to ignore-glob',
|
|
58
|
-
description: 'Turn an existing .gitignore into .fossil-settings/ignore-glob and verify what Fossil now hides.',
|
|
59
|
-
argsSchema: z.object({
|
|
60
|
-
source: z.string().min(1).optional().describe('Path of the .gitignore file, relative to the workspace.'),
|
|
61
|
-
workspace: workspaceArg,
|
|
62
|
-
}),
|
|
63
|
-
}, ({ source, workspace }) => userMessage([
|
|
64
|
-
'Give this check-out the same ignore rules it had under Git.',
|
|
65
|
-
workspaceLine(workspace),
|
|
66
|
-
'',
|
|
67
|
-
'1. Call `fossil_extras` to see which untracked files currently show up.',
|
|
68
|
-
`2. Call \`fossil_ignore_from_gitignore\` with \`write: false\`${source ? ` and \`source: "${source}"\`` : ''} to preview the patterns.`,
|
|
69
|
-
'3. Read every `NOTE:` line: negated rules cannot be expressed, and `**` rules are expanded.',
|
|
70
|
-
'4. Write the file with `write: true`, adding `overwrite: true` when the tool reports an existing ignore-glob.',
|
|
71
|
-
'5. Call `fossil_extras` again and report which paths are now ignored.',
|
|
72
|
-
].join('\n')));
|
|
73
56
|
server.registerPrompt('fossil-trace-change', {
|
|
74
57
|
title: 'Trace a change',
|
|
75
|
-
description: 'Find out when, why and by whom a file
|
|
58
|
+
description: 'Find out when, why and by whom a file changed, using the history tools.',
|
|
76
59
|
argsSchema: z.object({
|
|
77
|
-
target: z.string().min(1).describe('File path
|
|
60
|
+
target: z.string().min(1).describe('File path to trace.'),
|
|
78
61
|
workspace: workspaceArg,
|
|
79
62
|
}),
|
|
80
63
|
}, ({ target, workspace }) => userMessage([
|
|
81
64
|
`Trace the history of \`${target}\`.`,
|
|
82
65
|
workspaceLine(workspace),
|
|
83
66
|
'',
|
|
84
|
-
'1. Use `
|
|
85
|
-
'2. Use `fossil_finfo` in `log` mode to list the changes of the file, and `fossil_annotate` to see which',
|
|
67
|
+
'1. Use `fossil_finfo` in `log` mode to list the changes of the file, and `fossil_annotate` to see which',
|
|
86
68
|
' check-in last touched each line.',
|
|
87
|
-
'
|
|
88
|
-
'
|
|
69
|
+
'2. Use `fossil_timeline` around the interesting timestamps to read the surrounding check-ins.',
|
|
70
|
+
'3. Use `fossil_diff` between two versions to see exactly what changed.',
|
|
89
71
|
'4. Use `fossil_describe` to name the versions you quote.',
|
|
90
72
|
'',
|
|
91
73
|
'Summarise the sequence of changes with check-in hashes, dates and comments.',
|
|
@@ -106,10 +88,28 @@ export function registerPrompts(server, ids) {
|
|
|
106
88
|
' known-bad one with `fossil_bisect { action: "bad", version: "tip" }`.',
|
|
107
89
|
'3. Repeat: `fossil_bisect { action: "next" }` updates the check-out, test the symptom, then mark',
|
|
108
90
|
' good or bad. Use `fossil_bisect { action: "log" }` to review the decisions.',
|
|
109
|
-
'4. Read the offending check-in with `
|
|
91
|
+
'4. Read the offending check-in with `fossil_diff` and quote it with `fossil_describe`.',
|
|
110
92
|
'5. Finish with `fossil_bisect { action: "reset" }` and restore the check-out with `fossil_update`.',
|
|
111
93
|
].join('\n')));
|
|
112
94
|
}
|
|
95
|
+
if (has('u')) {
|
|
96
|
+
server.registerPrompt('fossil-ignore-conversion', {
|
|
97
|
+
title: 'Convert .gitignore to ignore-glob',
|
|
98
|
+
description: 'Turn an existing .gitignore into .fossil-settings/ignore-glob.',
|
|
99
|
+
argsSchema: z.object({
|
|
100
|
+
source: z.string().min(1).optional().describe('Path of the .gitignore file, relative to the workspace.'),
|
|
101
|
+
workspace: workspaceArg,
|
|
102
|
+
}),
|
|
103
|
+
}, ({ source, workspace }) => userMessage([
|
|
104
|
+
'Give this check-out the same ignore rules it had under Git.',
|
|
105
|
+
workspaceLine(workspace),
|
|
106
|
+
'',
|
|
107
|
+
`1. Call \`fossil_ignore_from_gitignore\` with \`write: false\`${source ? ` and \`source: "${source}"\`` : ''} to preview the patterns.`,
|
|
108
|
+
'2. Read every `NOTE:` line: negated rules cannot be expressed, and `**` rules are expanded.',
|
|
109
|
+
'3. Write the file with `write: true`, adding `overwrite: true` when the tool reports an existing ignore-glob.',
|
|
110
|
+
'4. Report the number of rules written and every `NOTE:` the conversion produced.',
|
|
111
|
+
].join('\n')));
|
|
112
|
+
}
|
|
113
113
|
if (has('a')) {
|
|
114
114
|
server.registerPrompt('fossil-sync-remote', {
|
|
115
115
|
title: 'Sync with a remote',
|
|
@@ -140,12 +140,10 @@ export function registerPrompts(server, ids) {
|
|
|
140
140
|
workspaceLine(workspace),
|
|
141
141
|
repository ? `Target repository: \`${repository}\`.` : 'Use the repository of the current check-out.',
|
|
142
142
|
'',
|
|
143
|
-
'1. Call `
|
|
144
|
-
'2.
|
|
145
|
-
'
|
|
146
|
-
'
|
|
147
|
-
'4. Otherwise run `fossil_rebuild` with `stats: true` and, when the repository looks bloated, `compress: true`.',
|
|
148
|
-
'5. Repeat step 2 and compare the numbers, then report what changed.',
|
|
143
|
+
'1. Call `fossil_rebuild` with `ifneeded: true`; when the schema is current, report that and stop.',
|
|
144
|
+
'2. Otherwise run `fossil_rebuild` with `stats: true` to see what a rebuild would change.',
|
|
145
|
+
'3. When the repository looks bloated, run `fossil_rebuild` with `compress: true`.',
|
|
146
|
+
'4. Report the rebuild summary and the resulting schema version.',
|
|
149
147
|
].join('\n')));
|
|
150
148
|
}
|
|
151
149
|
if (has('t')) {
|
package/dist/tools/admin.js
CHANGED
|
@@ -495,6 +495,60 @@ export function registerAdminTools(server) {
|
|
|
495
495
|
const rendered = renderOutcome(outcome);
|
|
496
496
|
return input.reveal_secrets ? rendered : withoutSecrets(rendered);
|
|
497
497
|
});
|
|
498
|
+
server.registerTool('fossil_config', {
|
|
499
|
+
title: 'Project configuration',
|
|
500
|
+
description: 'Export, import, merge, pull, push or reset the configuration areas (ticket, user, skin, …) that live in the repository database.',
|
|
501
|
+
inputSchema: z.object({
|
|
502
|
+
action: z.enum(['export', 'import', 'merge', 'pull', 'push', 'reset']).describe('Configuration method.'),
|
|
503
|
+
area: z
|
|
504
|
+
.enum(['all', 'email', 'interwiki', 'project', 'shun', 'skin', 'ticket', 'user', 'alias', 'subscriber'])
|
|
505
|
+
.optional()
|
|
506
|
+
.describe('Configuration area; required by export, pull, push and reset.'),
|
|
507
|
+
file: z.string().min(1).optional().describe('File to read or write; required by export, import and merge.'),
|
|
508
|
+
url: z.string().min(1).optional().describe('Remote repository for pull/push; the default remote when omitted.'),
|
|
509
|
+
repository: repoPathParam
|
|
510
|
+
.optional()
|
|
511
|
+
.describe('Repository database file to configure (-R), e.g. `repos/app.fossil`; omit to use the repository of the check-out.'),
|
|
512
|
+
overwrite: flag('Replace local settings with the ones received from the remote (--overwrite).'),
|
|
513
|
+
workspace: workspaceParam,
|
|
514
|
+
}),
|
|
515
|
+
annotations: { openWorldHint: true },
|
|
516
|
+
}, async (input) => {
|
|
517
|
+
const needsArea = ['export', 'pull', 'push', 'reset'].includes(input.action);
|
|
518
|
+
const needsFile = ['export', 'import', 'merge'].includes(input.action);
|
|
519
|
+
if (needsArea && !input.area) {
|
|
520
|
+
return {
|
|
521
|
+
isError: true,
|
|
522
|
+
content: [{ type: 'text', text: `ERROR: \`${input.action}\` requires \`area\`.` }],
|
|
523
|
+
};
|
|
524
|
+
}
|
|
525
|
+
if (needsFile && !input.file) {
|
|
526
|
+
return {
|
|
527
|
+
isError: true,
|
|
528
|
+
content: [{ type: 'text', text: `ERROR: \`${input.action}\` requires \`file\`.` }],
|
|
529
|
+
};
|
|
530
|
+
}
|
|
531
|
+
const args = ['config', input.action];
|
|
532
|
+
if (input.action === 'export') {
|
|
533
|
+
args.push(input.area, input.file);
|
|
534
|
+
}
|
|
535
|
+
else if (input.action === 'import' || input.action === 'merge') {
|
|
536
|
+
args.push(input.file);
|
|
537
|
+
}
|
|
538
|
+
else if (input.action === 'reset') {
|
|
539
|
+
args.push(input.area);
|
|
540
|
+
}
|
|
541
|
+
else {
|
|
542
|
+
args.push(input.area);
|
|
543
|
+
if (input.url)
|
|
544
|
+
args.push(input.url);
|
|
545
|
+
if (input.overwrite)
|
|
546
|
+
args.push('--overwrite');
|
|
547
|
+
}
|
|
548
|
+
pushOption(args, '-R', input.repository);
|
|
549
|
+
const timeoutMs = input.action === 'pull' || input.action === 'push' ? NETWORK_TIMEOUT_MS : undefined;
|
|
550
|
+
return renderOutcome(await runFossil(args, { workspace: input.workspace, timeoutMs }));
|
|
551
|
+
});
|
|
498
552
|
server.registerTool('fossil_rebuild', {
|
|
499
553
|
title: 'Rebuild repository',
|
|
500
554
|
description: 'Reconstruct the repository database from its core records, e.g. after changing the fossil schema. WARNING: destructive. It rewrites the repository database; obtain user confirmation first.',
|
|
@@ -556,58 +610,4 @@ export function registerAdminTools(server) {
|
|
|
556
610
|
args.push(input.repository);
|
|
557
611
|
return renderOutcome(await runFossil(args, { workspace: input.workspace }));
|
|
558
612
|
});
|
|
559
|
-
server.registerTool('fossil_config', {
|
|
560
|
-
title: 'Project configuration',
|
|
561
|
-
description: 'Export, import, merge, pull, push or reset the configuration areas (ticket, user, skin, …) that live in the repository database.',
|
|
562
|
-
inputSchema: z.object({
|
|
563
|
-
action: z.enum(['export', 'import', 'merge', 'pull', 'push', 'reset']).describe('Configuration method.'),
|
|
564
|
-
area: z
|
|
565
|
-
.enum(['all', 'email', 'interwiki', 'project', 'shun', 'skin', 'ticket', 'user', 'alias', 'subscriber'])
|
|
566
|
-
.optional()
|
|
567
|
-
.describe('Configuration area; required by export, pull, push and reset.'),
|
|
568
|
-
file: z.string().min(1).optional().describe('File to read or write; required by export, import and merge.'),
|
|
569
|
-
url: z.string().min(1).optional().describe('Remote repository for pull/push; the default remote when omitted.'),
|
|
570
|
-
repository: repoPathParam
|
|
571
|
-
.optional()
|
|
572
|
-
.describe('Repository database file to configure (-R), e.g. `repos/app.fossil`; omit to use the repository of the check-out.'),
|
|
573
|
-
overwrite: flag('Replace local settings with the ones received from the remote (--overwrite).'),
|
|
574
|
-
workspace: workspaceParam,
|
|
575
|
-
}),
|
|
576
|
-
annotations: { openWorldHint: true },
|
|
577
|
-
}, async (input) => {
|
|
578
|
-
const needsArea = ['export', 'pull', 'push', 'reset'].includes(input.action);
|
|
579
|
-
const needsFile = ['export', 'import', 'merge'].includes(input.action);
|
|
580
|
-
if (needsArea && !input.area) {
|
|
581
|
-
return {
|
|
582
|
-
isError: true,
|
|
583
|
-
content: [{ type: 'text', text: `ERROR: \`${input.action}\` requires \`area\`.` }],
|
|
584
|
-
};
|
|
585
|
-
}
|
|
586
|
-
if (needsFile && !input.file) {
|
|
587
|
-
return {
|
|
588
|
-
isError: true,
|
|
589
|
-
content: [{ type: 'text', text: `ERROR: \`${input.action}\` requires \`file\`.` }],
|
|
590
|
-
};
|
|
591
|
-
}
|
|
592
|
-
const args = ['config', input.action];
|
|
593
|
-
if (input.action === 'export') {
|
|
594
|
-
args.push(input.area, input.file);
|
|
595
|
-
}
|
|
596
|
-
else if (input.action === 'import' || input.action === 'merge') {
|
|
597
|
-
args.push(input.file);
|
|
598
|
-
}
|
|
599
|
-
else if (input.action === 'reset') {
|
|
600
|
-
args.push(input.area);
|
|
601
|
-
}
|
|
602
|
-
else {
|
|
603
|
-
args.push(input.area);
|
|
604
|
-
if (input.url)
|
|
605
|
-
args.push(input.url);
|
|
606
|
-
if (input.overwrite)
|
|
607
|
-
args.push('--overwrite');
|
|
608
|
-
}
|
|
609
|
-
pushOption(args, '-R', input.repository);
|
|
610
|
-
const timeoutMs = input.action === 'pull' || input.action === 'push' ? NETWORK_TIMEOUT_MS : undefined;
|
|
611
|
-
return renderOutcome(await runFossil(args, { workspace: input.workspace, timeoutMs }));
|
|
612
|
-
});
|
|
613
613
|
}
|