worktree-bay 3.0.0 → 4.0.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.
- package/README.md +1 -1
- package/dist/cli.js +2 -9
- package/dist/commands/add.js +2 -0
- package/dist/commands/completion.js +3 -3
- package/dist/mcp.js +1 -1
- package/package.json +1 -1
- package/skill.md +4 -5
package/README.md
CHANGED
|
@@ -47,7 +47,7 @@ worktree-bay gc
|
|
|
47
47
|
|
|
48
48
|
> 运行体随起随停(不动 worktree/代码):`worktree-bay stop drill-fix` 停掉(docker 容器 + dev server 一起)、`start` 起回来、`restart` 重启。
|
|
49
49
|
>
|
|
50
|
-
> 更细的控制:`claim <feature>` 单独占槽、`add <feature> <service> [branch]` 单加一个服务(branch 可自定义,省略则用功能名)、`
|
|
50
|
+
> 更细的控制:`claim <feature>` 单独占槽、`add <feature> <service> [branch]` 单加一个服务(branch 可自定义,省略则用功能名)、`down <feature> <service>` 只拆某个服务(省略服务则拆整功能)。
|
|
51
51
|
|
|
52
52
|
## 配置
|
|
53
53
|
|
package/dist/cli.js
CHANGED
|
@@ -106,16 +106,9 @@ program.command('restart <feature> [services...]').description(t('重启功能
|
|
|
106
106
|
catch (e) {
|
|
107
107
|
die(e.message);
|
|
108
108
|
} });
|
|
109
|
-
program.command('down <feature>').description(t('
|
|
110
|
-
.action(async (f, o) => { try {
|
|
111
|
-
await rmCommand(loadConfig(process.cwd()), f, [], !!o.force);
|
|
112
|
-
}
|
|
113
|
-
catch (e) {
|
|
114
|
-
die(e.message);
|
|
115
|
-
} });
|
|
116
|
-
program.command('rm <feature> <services...>').description(t('拆除功能下指定的一个或多个服务的 worktree(拆整功能用 down)。默认查脏/未推保护', 'remove the worktree(s) of the given service(s) of a feature (use down for the whole feature). Dirty/unpushed protected by default')).option('-f, --force', t('跳过脏/未推检查强制删除', 'skip dirty/unpushed checks and force-remove'))
|
|
109
|
+
program.command('down <feature> [services...]').description(t('拆除功能的 worktree(停运行体 + teardown + 删 worktree);省略 services = 整功能,可列多个只拆这些。默认查脏/未推保护', 'tear down a feature\'s worktree(s) (stop runtime + teardown + remove worktree); omit services = whole feature, or list several. Dirty/unpushed protected by default')).option('-f, --force', t('跳过脏/未推检查强制删除', 'skip dirty/unpushed checks and force-remove'))
|
|
117
110
|
.action(async (f, s, o) => { try {
|
|
118
|
-
await rmCommand(loadConfig(process.cwd()), f, s, !!o.force);
|
|
111
|
+
await rmCommand(loadConfig(process.cwd()), f, s ?? [], !!o.force);
|
|
119
112
|
}
|
|
120
113
|
catch (e) {
|
|
121
114
|
die(e.message);
|
package/dist/commands/add.js
CHANGED
|
@@ -35,6 +35,8 @@ export async function addCommand(cfg, feature, service, branch, base) {
|
|
|
35
35
|
}
|
|
36
36
|
catch (e) {
|
|
37
37
|
const m = String(e.message);
|
|
38
|
+
if (/not a valid branch name|cannot be used as a branch name/i.test(m)) // 分支名不合法(先于 base 判,二者都含 "not a valid")
|
|
39
|
+
throw new Error(t(`分支名「${br}」不合法:git 分支名不能以 / 开头或结尾、不能含 // 或 ..。换一个,如 fix/log(去掉前导斜杠)。`, `invalid branch name "${br}": git branch names can't start/end with "/" or contain "//" or "..". Use e.g. fix/log (no leading slash).`));
|
|
38
40
|
if (/invalid reference|unknown revision|ambiguous argument|not a valid|Not a valid object name/i.test(m))
|
|
39
41
|
throw new Error(t(`基分支「${resolvedBase}」无效(该仓可能没有 origin 或对应主分支)。给 add 显式传 base,例如:worktree-bay add ${feature} ${service} ${br} HEAD`, `invalid base ref "${resolvedBase}" (this repo may have no origin or main branch). Pass an explicit base to add, e.g.: worktree-bay add ${feature} ${service} ${br} HEAD`));
|
|
40
42
|
throw e;
|
|
@@ -4,7 +4,7 @@ import path from 'node:path';
|
|
|
4
4
|
import { readLabels } from '../slots.js';
|
|
5
5
|
import { log } from '../util/log.js';
|
|
6
6
|
import { t } from '../i18n.js';
|
|
7
|
-
const SUBCMDS = ['init', 'doctor', 'claim', 'up', 'add', 'ls', 'path', 'gc', 'down', '
|
|
7
|
+
const SUBCMDS = ['init', 'doctor', 'claim', 'up', 'add', 'ls', 'path', 'gc', 'down', 'run', 'sh', 'start', 'stop', 'restart', 'completion', 'mcp', 'skill', 'version', 'help'];
|
|
8
8
|
// words = 命令名 + 光标前已输入完的词(不含当前正在补的词)
|
|
9
9
|
export function complete(cfg, words) {
|
|
10
10
|
const prev = words.slice(1);
|
|
@@ -14,14 +14,14 @@ export function complete(cfg, words) {
|
|
|
14
14
|
return []; // 无配置(不在工作区内):子命令已补全,feature/service 无从读取
|
|
15
15
|
const sub = prev[0];
|
|
16
16
|
const pos = prev.length;
|
|
17
|
-
const featureSubs = ['up', 'add', '
|
|
17
|
+
const featureSubs = ['up', 'add', 'down', 'run', 'sh', 'path', 'start', 'stop', 'restart'];
|
|
18
18
|
if (featureSubs.includes(sub) && pos === 1)
|
|
19
19
|
return Object.values(readLabels(cfg));
|
|
20
20
|
if (['add', 'run', 'sh', 'path'].includes(sub) && pos === 2)
|
|
21
21
|
return Object.keys(cfg.services); // 单服务
|
|
22
22
|
if (sub === 'run' && pos === 3)
|
|
23
23
|
return Object.keys(cfg.services[prev[2]]?.run ?? {}); // run <feature> <service> <name>:补该服务的 run 命令名
|
|
24
|
-
if (['up', 'start', 'stop', 'restart', '
|
|
24
|
+
if (['up', 'start', 'stop', 'restart', 'down'].includes(sub) && pos >= 2)
|
|
25
25
|
return Object.keys(cfg.services); // 变长服务列表
|
|
26
26
|
return [];
|
|
27
27
|
}
|
package/dist/mcp.js
CHANGED
|
@@ -63,7 +63,7 @@ export const TOOLS = [
|
|
|
63
63
|
toArgs: (a) => ['restart', String(a.feature), ...(a.services ?? [])] },
|
|
64
64
|
{ name: 'worktree_bay_down', description: '拆除 worktree:省略 services 拆整个功能(所有服务),给 services 只拆这些服务(默认查脏/未推保护,force=true 强删)',
|
|
65
65
|
inputSchema: { type: 'object', properties: { feature: str, services: { type: 'array', items: str }, force: { type: 'boolean' } }, required: ['feature'] },
|
|
66
|
-
toArgs: (a) =>
|
|
66
|
+
toArgs: (a) => ['down', String(a.feature), ...(a.services ?? []), ...(a.force ? ['-f'] : [])] },
|
|
67
67
|
{ name: 'worktree_bay_gc', description: '合并感知回收:默认 dry-run 只列建议,apply=true 才实际删除「已合并且干净」的功能',
|
|
68
68
|
inputSchema: { type: 'object', properties: { apply: { type: 'boolean' } } },
|
|
69
69
|
toArgs: (a) => ['gc', ...(a.apply ? ['--apply'] : [])] },
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "worktree-bay",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.1",
|
|
4
4
|
"description": "Per-feature git worktree + port slots for parallel multi-service development: auto deps, env wiring, frontend-to-backend, merge-aware reclaim, plus an MCP server for AI agents.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"git",
|
package/skill.md
CHANGED
|
@@ -38,8 +38,7 @@ worktree-bay completion install # 一键装 shell 补全(可选)
|
|
|
38
38
|
| `worktree-bay start <feature> [services...]` | 启动功能的运行体(docker 容器 + node dev server 一起);**省略 = 全部**,也可列多个。不动 worktree |
|
|
39
39
|
| `worktree-bay stop <feature> [services...]` | 停止功能的运行体(停 docker + 杀 node dev server);省略 = 全部,可列多个。保留 worktree |
|
|
40
40
|
| `worktree-bay restart <feature> [services...]` | 重启运行体(停掉再起);省略 = 全部,可列多个 |
|
|
41
|
-
| `worktree-bay down <feature> [
|
|
42
|
-
| `worktree-bay rm <feature> <services...> [-f]` | 拆除指定的**一个或多个服务**(拆整功能用 `down`)。`add` 的反操作。默认查脏/未推保护,`-f` 强删 |
|
|
41
|
+
| `worktree-bay down <feature> [services...]` | 拆除 worktree(停运行体 + teardown + 删 worktree);**省略 services = 整功能**,也可列多个只拆这些。默认查脏/未推保护,`-f` 强删 |
|
|
43
42
|
| `worktree-bay gc [--apply]` | 合并感知回收:默认 dry-run 只列建议,`--apply` 才删「已合并且干净」的 |
|
|
44
43
|
| `worktree-bay completion <install\|bash\|zsh\|fish>` | `install` 一键装进 shell;或打印补全脚本 |
|
|
45
44
|
| `worktree-bay mcp` | 启动 MCP 服务(stdio,轻量脚本,客户端按需 spawn),供 AI 调用 |
|
|
@@ -157,8 +156,8 @@ worktree-bay gc # 回收已合并的
|
|
|
157
156
|
| ③ 在运行体里执行 | 跑命令 / 开 shell | — | `run` / `sh` | — |
|
|
158
157
|
|
|
159
158
|
- `up`:建 worktree+infra(首次)并起运行体;**重入 = 恢复运行体**(docker 挂了重跑 `up` 能拉回来,等价 `start`)。
|
|
160
|
-
- `start
|
|
161
|
-
- `down`
|
|
159
|
+
- 整套 runtime/teardown 命令统一为「一个动词 + `[services...]`(省略=全部)」:`start` / `stop` / `restart` / `down`。
|
|
160
|
+
- `up`(创建,服务必填)↔ `down`(拆除,服务可省=整功能)。`add` 是「单服务 + 自定义分支/基点」的精细创建,其反操作 = `down <feature> <service>`。
|
|
162
161
|
|
|
163
162
|
## 工作原理要点
|
|
164
163
|
|
|
@@ -172,7 +171,7 @@ worktree-bay gc # 回收已合并的
|
|
|
172
171
|
|
|
173
172
|
## 给 AI(MCP)
|
|
174
173
|
|
|
175
|
-
`worktree-bay mcp` 暴露工具:`worktree_bay_doctor / ls / up / claim / add / path / run / start / stop / restart / down / gc / init / skill`。`doctor` 列出全部服务(AI 借此得知服务名);`ls` 以 JSON 返回(含各 worktree 绝对路径、`▸run`);`path` 给某功能某服务的 worktree 目录;`start/stop/restart` 控制运行体(docker+node);`down` 省略
|
|
174
|
+
`worktree-bay mcp` 暴露工具:`worktree_bay_doctor / ls / up / claim / add / path / run / start / stop / restart / down / gc / init / skill`。`doctor` 列出全部服务(AI 借此得知服务名);`ls` 以 JSON 返回(含各 worktree 绝对路径、`▸run`);`path` 给某功能某服务的 worktree 目录;`start/stop/restart` 控制运行体(docker+node);`down` 省略 services 拆整功能、给 services 只拆这些。要写或修改 `worktree-bay.config.json`、或拿不准命令/配置细节时,调用 `worktree_bay_skill` 取本指南全文。
|
|
176
175
|
|
|
177
176
|
## 常见坑
|
|
178
177
|
|