gatelight 0.0.0-stage → 0.18.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/.antigravity-plugin/plugin.json +9 -0
- package/.claude-plugin/plugin.json +11 -0
- package/.codex-plugin/plugin.json +18 -0
- package/.mcp.json +8 -0
- package/LICENSE +21 -0
- package/README.md +29 -2
- package/bin/modwall +8 -0
- package/bin/node.sh +14 -0
- package/bin/testcraft +8 -0
- package/bin/testpace +8 -0
- package/entry/command +44 -0
- package/hooks/antigravity.sh +24 -0
- package/hooks/codex.json +50 -0
- package/hooks/codex.sh +7 -0
- package/hooks/hooks.json +43 -0
- package/hooks/testpace.ts +25 -0
- package/hooks.json +16 -0
- package/mcp_config.json +8 -0
- package/package.json +23 -4
- package/setup.mjs +99 -0
- package/skills/merge/SKILL.md +42 -0
- package/skills/modular/SKILL.md +75 -0
- package/skills/setup/SKILL.md +101 -0
- package/skills/setup-modwall/SKILL.md +112 -0
- package/skills/setup-testcraft/SKILL.md +23 -0
- package/skills/setup-testcraft/checklist/dev-login.md +20 -0
- package/skills/write-tests/SKILL.md +153 -0
- package/src/base/agent.ts +100 -0
- package/src/base/baseline.ts +54 -0
- package/src/base/commandline.ts +40 -0
- package/src/base/commands.ts +94 -0
- package/src/base/confirm.ts +161 -0
- package/src/base/contract.ts +94 -0
- package/src/base/coverage.ts +46 -0
- package/src/base/entry.ts +90 -0
- package/src/base/excerpt.ts +46 -0
- package/src/base/execute.ts +70 -0
- package/src/base/exit.ts +6 -0
- package/src/base/format.ts +27 -0
- package/src/base/full.ts +160 -0
- package/src/base/gate.ts +251 -0
- package/src/base/git.ts +361 -0
- package/src/base/glob.ts +38 -0
- package/src/base/hook.ts +297 -0
- package/src/base/hookformat.ts +257 -0
- package/src/base/judging.ts +27 -0
- package/src/base/layermap.ts +69 -0
- package/src/base/module.ts +88 -0
- package/src/base/process-group.ts +101 -0
- package/src/base/records.ts +66 -0
- package/src/base/repo.ts +155 -0
- package/src/base/sessions.ts +55 -0
- package/src/base/shell.ts +176 -0
- package/src/base/stop.ts +100 -0
- package/src/base/store.ts +348 -0
- package/src/base/version.ts +24 -0
- package/src/cli.ts +186 -0
- package/src/craft/change.ts +24 -0
- package/src/craft/checklist.ts +157 -0
- package/src/craft/commands.ts +111 -0
- package/src/craft/config.ts +15 -0
- package/src/craft/full.ts +30 -0
- package/src/craft/index.ts +12 -0
- package/src/craft/session.ts +21 -0
- package/src/mcp.ts +79 -0
- package/src/modules.ts +10 -0
- package/src/modwall.ts +8 -0
- package/src/pace/commands.ts +281 -0
- package/src/pace/config.ts +103 -0
- package/src/pace/consent.ts +81 -0
- package/src/pace/focused.ts +208 -0
- package/src/pace/full.ts +38 -0
- package/src/pace/index.ts +16 -0
- package/src/pace/record.ts +84 -0
- package/src/pace/report.ts +335 -0
- package/src/pace/results.ts +243 -0
- package/src/pace/run/node-test-reporter.mjs +34 -0
- package/src/pace/run/node-test.ts +26 -0
- package/src/pace/run/playwright-reporter.mjs +48 -0
- package/src/pace/run/playwright.ts +34 -0
- package/src/pace/run/runner.ts +157 -0
- package/src/pace/run/targets.ts +130 -0
- package/src/pace/run/vitest-launcher.mjs +101 -0
- package/src/pace/run/vitest.ts +22 -0
- package/src/pace/session.ts +35 -0
- package/src/pace/testlist.ts +91 -0
- package/src/pace/tests.ts +22 -0
- package/src/pace/verify.ts +95 -0
- package/src/testcraft.ts +9 -0
- package/src/wall/check.ts +258 -0
- package/src/wall/commands.ts +279 -0
- package/src/wall/config.ts +394 -0
- package/src/wall/database.ts +136 -0
- package/src/wall/dbcheck.ts +389 -0
- package/src/wall/dbrules.ts +213 -0
- package/src/wall/edit.ts +64 -0
- package/src/wall/files.ts +35 -0
- package/src/wall/full.ts +30 -0
- package/src/wall/index.ts +15 -0
- package/src/wall/init.ts +149 -0
- package/src/wall/layermap.ts +124 -0
- package/src/wall/layout.ts +231 -0
- package/src/wall/loosen.ts +157 -0
- package/src/wall/miniprogram.ts +80 -0
- package/src/wall/project.ts +88 -0
- package/src/wall/rules.ts +400 -0
- package/src/wall/session.ts +198 -0
- package/src/wall/sql.ts +510 -0
- package/src/wall/store.ts +39 -0
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "gatelight",
|
|
3
|
+
"displayName": "gatelight",
|
|
4
|
+
"version": "0.18.0",
|
|
5
|
+
"description": "Gates for coding agents: tests actually ran before code lands, code stays inside its module boundaries, plus test-writing conventions and a change-triggered checklist",
|
|
6
|
+
"author": {
|
|
7
|
+
"name": "coffeecoproject"
|
|
8
|
+
}
|
|
9
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "gatelight",
|
|
3
|
+
"displayName": "gatelight",
|
|
4
|
+
"version": "0.18.0",
|
|
5
|
+
"description": "Gates for coding agents: tests actually ran before code lands, code stays inside its module boundaries, plus test-writing conventions and a change-triggered checklist",
|
|
6
|
+
"author": {
|
|
7
|
+
"name": "coffeecoproject"
|
|
8
|
+
},
|
|
9
|
+
"license": "MIT",
|
|
10
|
+
"keywords": ["testing", "test selection", "merge gate", "test quality", "module boundaries", "coding agent"]
|
|
11
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "gatelight",
|
|
3
|
+
"version": "0.18.0",
|
|
4
|
+
"description": "Gates for coding agents: tests actually ran before code lands, code stays inside its module boundaries, plus test-writing conventions and a change-triggered checklist",
|
|
5
|
+
"author": {
|
|
6
|
+
"name": "coffeecoproject"
|
|
7
|
+
},
|
|
8
|
+
"license": "MIT",
|
|
9
|
+
"keywords": ["testing", "test selection", "merge gate", "test quality", "module boundaries", "coding agent"],
|
|
10
|
+
"hooks": "./hooks/codex.json",
|
|
11
|
+
"skills": "./skills/",
|
|
12
|
+
"interface": {
|
|
13
|
+
"displayName": "gatelight",
|
|
14
|
+
"shortDescription": "Gates for coding agents: tests ran, code stays in bounds, test-writing conventions",
|
|
15
|
+
"developerName": "coffeecoproject",
|
|
16
|
+
"category": "Developer Tools"
|
|
17
|
+
}
|
|
18
|
+
}
|
package/.mcp.json
ADDED
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 coffeecoproject
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,30 @@
|
|
|
1
|
-
#
|
|
1
|
+
# gatelight
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
给 agent 写代码把关的插件(Claude Code、Codex、Antigravity):测试跑了没有、测试怎么写、代码有没有越界。
|
|
4
|
+
|
|
5
|
+
这个 npm 包就是插件本身。说明、规则和开发都在 [gatelight 仓库](https://github.com/coffeecoproject/gatelight)。
|
|
6
|
+
|
|
7
|
+
## 安装
|
|
8
|
+
|
|
9
|
+
Claude Code:
|
|
10
|
+
|
|
11
|
+
```sh
|
|
12
|
+
claude plugin marketplace add coffeecoproject/gatelight-marketplace
|
|
13
|
+
claude plugin install gatelight@gatelight
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
Codex(要本机装着 `npm`):
|
|
17
|
+
|
|
18
|
+
```sh
|
|
19
|
+
codex plugin marketplace add coffeecoproject/gatelight-marketplace
|
|
20
|
+
codex plugin add gatelight@gatelight
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
Antigravity(桌面 App):
|
|
24
|
+
|
|
25
|
+
```sh
|
|
26
|
+
npx gatelight setup antigravity # 装上,或换成这一版
|
|
27
|
+
npx gatelight remove antigravity # 卸掉
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
需要 Node 22.18 以上,合并门要 git 2.54 以上。装好后开新会话,前提和用法见仓库的 README。
|
package/bin/modwall
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
# modwall 命令入口("模块边界"模块的命令)。Claude Code 插件启用时这个目录在 Bash 工具的 PATH 里;
|
|
3
|
+
# 别处(Codex 的命令)由固定入口 ~/.local/bin/modwall(entry/command)转过来。
|
|
4
|
+
dir=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
|
|
5
|
+
. "$dir/node.sh"
|
|
6
|
+
# 找不到 node 时退出码 2(配置问题)
|
|
7
|
+
node=$(testpace_node) || { echo 'modwall:找不到 22.18 以上的 node(要能直接运行 TypeScript)。装一个,或用 TESTPACE_NODE 指给它。' >&2; exit 2; }
|
|
8
|
+
exec "$node" --disable-warning=ExperimentalWarning "$dir/../src/modwall.ts" "$@"
|
package/bin/node.sh
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# 找一个能直接运行 TypeScript 的 node(22.18 及以上),打印它的路径;找不到返回 1。
|
|
2
|
+
# bin/testpace 和 Codex 的 hook 入口共用(. 进来再调 testpace_node)。git 钩子、Codex 的命令和 hook 的环境里,
|
|
3
|
+
# PATH 上的 node 不一定够新,依次试 TESTPACE_NODE、PATH 里的 node、nvm 装的各个版本(从新到旧)、Homebrew。
|
|
4
|
+
testpace_node() {
|
|
5
|
+
testpace_ok='const [a, b] = process.versions.node.split(".").map(Number); process.exit(a > 22 || (a === 22 && b >= 18) ? 0 : 1)'
|
|
6
|
+
for testpace_try in "$TESTPACE_NODE" "$(command -v node 2>/dev/null)" $(ls -d "$HOME"/.nvm/versions/node/v*/bin/node 2>/dev/null | sort -rV) /opt/homebrew/bin/node /usr/local/bin/node; do
|
|
7
|
+
[ -n "$testpace_try" ] && [ -x "$testpace_try" ] || continue
|
|
8
|
+
if "$testpace_try" -e "$testpace_ok" 2>/dev/null; then
|
|
9
|
+
printf '%s\n' "$testpace_try"
|
|
10
|
+
return 0
|
|
11
|
+
fi
|
|
12
|
+
done
|
|
13
|
+
return 1
|
|
14
|
+
}
|
package/bin/testcraft
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
# testcraft 命令入口("测试写法"模块的命令)。Claude Code 插件启用时这个目录在 Bash 工具的 PATH 里;
|
|
3
|
+
# 别处(Codex 的命令)由固定入口 ~/.local/bin/testcraft(entry/command)转过来。
|
|
4
|
+
dir=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
|
|
5
|
+
. "$dir/node.sh"
|
|
6
|
+
# 找不到 node 时退出码 2(配置问题)
|
|
7
|
+
node=$(testpace_node) || { echo 'testcraft:找不到 22.18 以上的 node(要能直接运行 TypeScript)。装一个,或用 TESTPACE_NODE 指给它。' >&2; exit 2; }
|
|
8
|
+
exec "$node" --disable-warning=ExperimentalWarning "$dir/../src/testcraft.ts" "$@"
|
package/bin/testpace
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
# testpace 命令入口。Claude Code 插件启用时这个目录在 Bash 工具的 PATH 里;
|
|
3
|
+
# 别处(Codex 的命令、合并门的钩子)由固定入口 ~/.local/bin/testpace(entry/command)转过来。
|
|
4
|
+
dir=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
|
|
5
|
+
. "$dir/node.sh"
|
|
6
|
+
# 找不到 node 时退出码 2(配置问题)
|
|
7
|
+
node=$(testpace_node) || { echo 'testpace:找不到 22.18 以上的 node(要能直接运行 TypeScript)。装一个,或用 TESTPACE_NODE 指给它。' >&2; exit 2; }
|
|
8
|
+
exec "$node" --disable-warning=ExperimentalWarning "$dir/../src/cli.ts" "$@"
|
package/entry/command
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
# testpace 固定入口:testpace install 把这个文件放到 ~/.local/bin 下,gatelight 的每条命令放一份(testpace、modwall、testcraft),内容一样,
|
|
3
|
+
# 运行时按被叫的名字转给插件里同名的命令(Codex 的命令和终端的 PATH 里都有这个目录)。放哪几条由 src/base/entry.ts 定,这里不列。
|
|
4
|
+
# 放上去时第一行后面插一行记着是哪一版放的(entry.ts),会话开始的自动更新只升不降。
|
|
5
|
+
# 插件(gatelight)的安装目录随版本变,不能写死,这里每次运行时找这台机器上装着的最高版本,Claude Code、Codex、Antigravity 装的都算,不分先后。
|
|
6
|
+
# 只认装着的:Claude Code 看它的安装记录(卸载、降级后缓存里留下的旧目录不算;没有记录就是没装);
|
|
7
|
+
# Codex 卸载插件时会删掉缓存,缓存里有的就是装着的;
|
|
8
|
+
# Antigravity 装在 ~/.gemini/config/plugins/<目录名>/(可以是指向别处的链接),目录名是它的安装标识,不带版本,版本看那里的 .antigravity-plugin/plugin.json。
|
|
9
|
+
# 只认装全的:插件目录里要有 src/cli.ts(缓存可能只复制了一部分),残缺的那份不参与挑版本。
|
|
10
|
+
# 找不到时退出码 2(配置问题),分两种说:这几个 agent 的配置目录有在的、却一个都读不了,多半是在 agent 的沙箱里
|
|
11
|
+
# (Antigravity 的沙箱里实测 ~/.claude、~/.codex、~/.gemini/config 都在、都读不了),让它申请到沙箱外;其余的才是没装。
|
|
12
|
+
# 话里的变量都写成 ${名字}:紧跟着的中文标点在 UTF-8 语言环境里会被 sh(macOS 上是 bash)把头一个字节当成变量名的一部分,吞掉字节。
|
|
13
|
+
name=$(basename -- "$0")
|
|
14
|
+
claude="$HOME/.claude"
|
|
15
|
+
codex="${CODEX_HOME:-$HOME/.codex}"
|
|
16
|
+
antigravity="$HOME/.gemini/config"
|
|
17
|
+
installed="$claude/plugins/installed_plugins.json"
|
|
18
|
+
tab=$(printf '\t')
|
|
19
|
+
# 每行一个装着的插件:版本、目录。Claude Code、Codex 的目录名就是版本
|
|
20
|
+
candidates() {
|
|
21
|
+
{
|
|
22
|
+
[ ! -f "$installed" ] || grep -o '"installPath": *"[^"]*/gatelight/[^"]*"' "$installed" | sed 's/.*"\([^"]*\)"$/\1/'
|
|
23
|
+
ls -d "$codex"/plugins/cache/*/gatelight/* 2>/dev/null
|
|
24
|
+
} | while IFS= read -r plugin; do printf '%s\t%s\n' "$(basename "$plugin")" "$plugin"; done
|
|
25
|
+
for plugin in "$antigravity"/plugins/*/; do
|
|
26
|
+
manifest="$plugin.antigravity-plugin/plugin.json"
|
|
27
|
+
[ -f "$manifest" ] && grep -q '"name": *"gatelight"' "$manifest" || continue
|
|
28
|
+
printf '%s\t%s\n' "$(sed -n 's/.*"version": *"\([^"]*\)".*/\1/p' "$manifest" | head -n 1)" "${plugin%/}"
|
|
29
|
+
done
|
|
30
|
+
}
|
|
31
|
+
best=$(
|
|
32
|
+
candidates | while IFS="$tab" read -r version plugin; do
|
|
33
|
+
[ -x "$plugin/bin/$name" ] && [ -f "$plugin/src/cli.ts" ] && printf '%s\t%s\n' "$version" "$plugin/bin/$name"
|
|
34
|
+
done | sort -t "$tab" -k1,1V | tail -n 1 | cut -f 2
|
|
35
|
+
)
|
|
36
|
+
if [ -z "$best" ]; then
|
|
37
|
+
if { [ -e "$claude" ] || [ -e "$codex" ] || [ -e "$antigravity" ]; } && [ ! -r "$claude" ] && [ ! -r "$codex" ] && [ ! -r "$antigravity" ]; then
|
|
38
|
+
echo "${name}:读不了插件的安装目录(${claude}、${codex}、${antigravity} 都读不了),多半是在 agent 的沙箱里。申请在沙箱外重新运行这条命令。" >&2
|
|
39
|
+
else
|
|
40
|
+
echo "${name}:这台机器上没找到装着的、完整的 gatelight 插件(Claude Code、Codex、Antigravity 里都没有)。" >&2
|
|
41
|
+
fi
|
|
42
|
+
exit 2
|
|
43
|
+
fi
|
|
44
|
+
exec "$best" "$@"
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
# Antigravity 的 hook 入口(插件根上的 hooks.json 用它;hook 的工作目录是 hooks.json 所在的插件目录):
|
|
3
|
+
# 先找一个能运行 TypeScript 的 node,再交给 testpace.ts(说明是 Antigravity)。
|
|
4
|
+
# Antigravity 下 hook 不干预时必须什么都不输出、退出码 0:PreToolUse 输出 {}、空的 decision、退出码非 0 都会把这次工具调用拦掉(实测)。
|
|
5
|
+
# 所以这里无论出了什么事(找不到 node、脚本抛错、node 自己退出码非 0)都只往标准错误说,退出码一律 0;不用 exec,好在 node 之后补上退出码。
|
|
6
|
+
# 唯一反过来的是调确认工具(gatelight 自己的 MCP 服务,ServerName 是 gatelight_gatelight,见 hookformat.ts):
|
|
7
|
+
# 那次调用要靠这里输出 force_ask 才会弹窗问用户,出错了不输出就成了不问就执行,所以出错一律拒绝。
|
|
8
|
+
# 认它只看输入里的 "ServerName":"gatelight_gatelight":别处(比如用户的话)出现这几个字时引号是转义过的,对不上。
|
|
9
|
+
dir=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
|
|
10
|
+
input=$(cat)
|
|
11
|
+
confirm=
|
|
12
|
+
printf '%s' "$input" | grep -Eq '"ServerName"[[:space:]]*:[[:space:]]*"gatelight_gatelight"' && confirm=1
|
|
13
|
+
refuse() {
|
|
14
|
+
echo "$1" >&2
|
|
15
|
+
[ -z "$confirm" ] || printf '%s\n' '{"decision":"deny","reason":"gatelight 的 hook 出错了,这次确认没能弹窗给用户看,所以没有执行。告诉用户 hook 出错了,不要换别的办法记下同意。"}'
|
|
16
|
+
exit 0
|
|
17
|
+
}
|
|
18
|
+
. "$dir/../bin/node.sh"
|
|
19
|
+
node=$(testpace_node) || refuse 'testpace hook 没有运行:找不到 22.18 以上的 node(要能直接运行 TypeScript)。装一个,或用 TESTPACE_NODE 指给它。'
|
|
20
|
+
output=$(printf '%s' "$input" | "$node" --disable-warning=ExperimentalWarning "$dir/testpace.ts" antigravity) || refuse "testpace hook 异常退出($?),这次没有检查。"
|
|
21
|
+
# 确认工具的调用一定有输出(弹窗或拒绝);没有就是哪里出错了
|
|
22
|
+
[ -n "$output" ] || [ -z "$confirm" ] || refuse 'testpace hook 对确认工具的调用没有给出结论。'
|
|
23
|
+
[ -z "$output" ] || printf '%s\n' "$output"
|
|
24
|
+
exit 0
|
package/hooks/codex.json
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
{
|
|
2
|
+
"hooks": {
|
|
3
|
+
"SessionStart": [
|
|
4
|
+
{
|
|
5
|
+
"hooks": [
|
|
6
|
+
{
|
|
7
|
+
"type": "command",
|
|
8
|
+
"command": "sh \"${PLUGIN_ROOT}/hooks/codex.sh\"",
|
|
9
|
+
"timeout": 30
|
|
10
|
+
}
|
|
11
|
+
]
|
|
12
|
+
}
|
|
13
|
+
],
|
|
14
|
+
"PreToolUse": [
|
|
15
|
+
{
|
|
16
|
+
"matcher": "^(Bash|apply_patch)$",
|
|
17
|
+
"hooks": [
|
|
18
|
+
{
|
|
19
|
+
"type": "command",
|
|
20
|
+
"command": "sh \"${PLUGIN_ROOT}/hooks/codex.sh\"",
|
|
21
|
+
"timeout": 30
|
|
22
|
+
}
|
|
23
|
+
]
|
|
24
|
+
}
|
|
25
|
+
],
|
|
26
|
+
"PostToolUse": [
|
|
27
|
+
{
|
|
28
|
+
"matcher": "^Bash$",
|
|
29
|
+
"hooks": [
|
|
30
|
+
{
|
|
31
|
+
"type": "command",
|
|
32
|
+
"command": "sh \"${PLUGIN_ROOT}/hooks/codex.sh\"",
|
|
33
|
+
"timeout": 30
|
|
34
|
+
}
|
|
35
|
+
]
|
|
36
|
+
}
|
|
37
|
+
],
|
|
38
|
+
"Stop": [
|
|
39
|
+
{
|
|
40
|
+
"hooks": [
|
|
41
|
+
{
|
|
42
|
+
"type": "command",
|
|
43
|
+
"command": "sh \"${PLUGIN_ROOT}/hooks/codex.sh\"",
|
|
44
|
+
"timeout": 60
|
|
45
|
+
}
|
|
46
|
+
]
|
|
47
|
+
}
|
|
48
|
+
]
|
|
49
|
+
}
|
|
50
|
+
}
|
package/hooks/codex.sh
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
# Codex 的 hook 入口:Codex 的 hook 环境里不一定有能运行 TypeScript 的 node,先找一个,再交给 testpace.ts(说明是 Codex)。
|
|
3
|
+
# 找不到 node 时不挡 Codex,但说一声。
|
|
4
|
+
dir=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
|
|
5
|
+
. "$dir/../bin/node.sh"
|
|
6
|
+
node=$(testpace_node) || { printf '%s\n' '{"systemMessage":"testpace hook 没有运行:找不到 22.18 以上的 node(要能直接运行 TypeScript)。装一个,或用 TESTPACE_NODE 指给它。"}'; exit 0; }
|
|
7
|
+
exec "$node" --disable-warning=ExperimentalWarning "$dir/testpace.ts" codex
|
package/hooks/hooks.json
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
{
|
|
2
|
+
"description": "gatelight:会话开始时说明测试节奏和写测试的约定(接入了 testcraft 的仓库),直接跑 full 的命令时提醒改用 testpace full;接入了 modwall 的仓库再说明模块列表和写法约定,改文件之前拦下没有归属的代码文件,和新文字里绕过入口引用别的模块内部文件的写法(只看路径和要写的文字);整组没跑完或结果没看、改了代码却没有 modwall check 的通过记录,拦一次结束。合并门是 git 钩子(testpace install)。",
|
|
3
|
+
"hooks": {
|
|
4
|
+
"SessionStart": [
|
|
5
|
+
{
|
|
6
|
+
"hooks": [
|
|
7
|
+
{ "type": "command", "command": "node --disable-warning=ExperimentalWarning \"${CLAUDE_PLUGIN_ROOT}/hooks/testpace.ts\" claude", "timeout": 30 }
|
|
8
|
+
]
|
|
9
|
+
}
|
|
10
|
+
],
|
|
11
|
+
"PreToolUse": [
|
|
12
|
+
{
|
|
13
|
+
"matcher": "Bash|Edit|Write|MultiEdit",
|
|
14
|
+
"hooks": [
|
|
15
|
+
{ "type": "command", "command": "node --disable-warning=ExperimentalWarning \"${CLAUDE_PLUGIN_ROOT}/hooks/testpace.ts\" claude", "timeout": 30 }
|
|
16
|
+
]
|
|
17
|
+
}
|
|
18
|
+
],
|
|
19
|
+
"PostToolUse": [
|
|
20
|
+
{
|
|
21
|
+
"matcher": "Bash",
|
|
22
|
+
"hooks": [
|
|
23
|
+
{ "type": "command", "command": "node --disable-warning=ExperimentalWarning \"${CLAUDE_PLUGIN_ROOT}/hooks/testpace.ts\" claude", "timeout": 30 }
|
|
24
|
+
]
|
|
25
|
+
}
|
|
26
|
+
],
|
|
27
|
+
"PostToolUseFailure": [
|
|
28
|
+
{
|
|
29
|
+
"matcher": "Bash",
|
|
30
|
+
"hooks": [
|
|
31
|
+
{ "type": "command", "command": "node --disable-warning=ExperimentalWarning \"${CLAUDE_PLUGIN_ROOT}/hooks/testpace.ts\" claude", "timeout": 30 }
|
|
32
|
+
]
|
|
33
|
+
}
|
|
34
|
+
],
|
|
35
|
+
"Stop": [
|
|
36
|
+
{
|
|
37
|
+
"hooks": [
|
|
38
|
+
{ "type": "command", "command": "node --disable-warning=ExperimentalWarning \"${CLAUDE_PLUGIN_ROOT}/hooks/testpace.ts\" claude", "timeout": 60 }
|
|
39
|
+
]
|
|
40
|
+
}
|
|
41
|
+
]
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// agent hook 入口:node testpace.ts <agent>,agent 是 claude、codex、antigravity 或 dsh,说明 hook 来自哪个 agent(各 agent 的 hook 配置里写明)。
|
|
2
|
+
// 从标准输入读事件,交给 src/base/hook.ts 判断,把结果写到标准输出。
|
|
3
|
+
// 出错时退出码 0、不挡 agent,但要让人看得到:按这个 agent 的格式输出一句(hookformat.ts 的 failure)。合并门自己把判断出错当作不放行。
|
|
4
|
+
|
|
5
|
+
import '../src/modules.ts'
|
|
6
|
+
import { AGENTS, isAgentKind } from '../src/base/agent.ts'
|
|
7
|
+
import { handle } from '../src/base/hook.ts'
|
|
8
|
+
import { CLAUDE_HOOKS } from '../src/base/hookformat.ts'
|
|
9
|
+
|
|
10
|
+
const agent = process.argv[2]
|
|
11
|
+
try {
|
|
12
|
+
if (!isAgentKind(agent)) throw new Error(`不认识的 agent "${agent}"`)
|
|
13
|
+
let text = ''
|
|
14
|
+
for await (const chunk of process.stdin) text += chunk
|
|
15
|
+
const output = handle(JSON.parse(text), Date.now(), agent)
|
|
16
|
+
if (output !== undefined) process.stdout.write(`${JSON.stringify(output)}\n`)
|
|
17
|
+
} catch (error) {
|
|
18
|
+
const message = `testpace hook 出错,这次没有检查:${(error as Error).message.split('\n')[0]}`
|
|
19
|
+
process.stderr.write(`${message}\n`)
|
|
20
|
+
// 没说是哪个 agent(hook 配置写错了)时不知道它的格式,按 Claude Code 的说
|
|
21
|
+
const format = isAgentKind(agent) ? AGENTS[agent].hooks : CLAUDE_HOOKS
|
|
22
|
+
// 什么都不能输出的 agent(Antigravity:输出什么都会把工具调用拦掉)只说在标准错误里
|
|
23
|
+
const output = format.failure(message)
|
|
24
|
+
if (output !== undefined) process.stdout.write(`${JSON.stringify(output)}\n`)
|
|
25
|
+
}
|
package/hooks.json
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"gatelight": {
|
|
3
|
+
"SessionStart": [
|
|
4
|
+
{ "type": "command", "command": "sh ./hooks/antigravity.sh", "timeout": 30 }
|
|
5
|
+
],
|
|
6
|
+
"PreToolUse": [
|
|
7
|
+
{ "matcher": "run_command", "hooks": [{ "type": "command", "command": "sh ./hooks/antigravity.sh", "timeout": 30 }] },
|
|
8
|
+
{ "matcher": "write_file", "hooks": [{ "type": "command", "command": "sh ./hooks/antigravity.sh", "timeout": 30 }] },
|
|
9
|
+
{ "matcher": "edit_file", "hooks": [{ "type": "command", "command": "sh ./hooks/antigravity.sh", "timeout": 30 }] },
|
|
10
|
+
{ "matcher": "call_mcp_tool", "hooks": [{ "type": "command", "command": "sh ./hooks/antigravity.sh", "timeout": 30 }] }
|
|
11
|
+
],
|
|
12
|
+
"Stop": [
|
|
13
|
+
{ "type": "command", "command": "sh ./hooks/antigravity.sh", "timeout": 60 }
|
|
14
|
+
]
|
|
15
|
+
}
|
|
16
|
+
}
|
package/mcp_config.json
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
{
|
|
2
|
+
"mcpServers": {
|
|
3
|
+
"gatelight": {
|
|
4
|
+
"command": "sh",
|
|
5
|
+
"args": ["-c", ". ./bin/node.sh && node=$(testpace_node) || { echo 'gatelight 的确认工具没有启动:找不到 22.18 以上的 node(要能直接运行 TypeScript)。' >&2; exit 1; }; exec \"$node\" --disable-warning=ExperimentalWarning ./src/mcp.ts"]
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,25 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gatelight",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.18.0",
|
|
4
|
+
"description": "Gates for coding agents: tests actually ran before code lands, code stays inside its module boundaries, plus test-writing conventions and a change-triggered checklist",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"homepage": "https://github.com/coffeecoproject/gatelight#readme",
|
|
7
|
+
"repository": { "type": "git", "url": "git+https://github.com/coffeecoproject/gatelight.git", "directory": "plugin" },
|
|
8
|
+
"type": "module",
|
|
9
|
+
"engines": { "node": ">=22.18" },
|
|
10
|
+
"bin": { "gatelight": "setup.mjs" },
|
|
11
|
+
"files": [
|
|
12
|
+
".claude-plugin",
|
|
13
|
+
".codex-plugin",
|
|
14
|
+
".antigravity-plugin",
|
|
15
|
+
".mcp.json",
|
|
16
|
+
"mcp_config.json",
|
|
17
|
+
"hooks.json",
|
|
18
|
+
"hooks",
|
|
19
|
+
"bin",
|
|
20
|
+
"entry",
|
|
21
|
+
"skills",
|
|
22
|
+
"src",
|
|
23
|
+
"setup.mjs"
|
|
24
|
+
]
|
|
25
|
+
}
|
package/setup.mjs
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// npm 包的命令:npx gatelight setup antigravity / npx gatelight remove antigravity。
|
|
3
|
+
// Antigravity 的插件市场只收官方和合作方的,装法是把插件目录放进 ~/.gemini/config/plugins/<名字>/:这里把这个包复制过去。
|
|
4
|
+
// Claude Code、Codex 从各自的插件市场装(市场目录里写的是 npm 来源),不走这里。
|
|
5
|
+
// 写成纯 JS:包在 node_modules 下面时 node 不肯直接跑 TypeScript(ERR_UNSUPPORTED_NODE_MODULES_TYPE_STRIPPING)。
|
|
6
|
+
// 复制到 Antigravity 的目录以后,插件里的 TypeScript 在那里跑,不受影响。
|
|
7
|
+
|
|
8
|
+
import { cpSync, existsSync, lstatSync, readFileSync, readlinkSync, renameSync, rmSync } from 'node:fs'
|
|
9
|
+
import { homedir } from 'node:os'
|
|
10
|
+
import { dirname, join } from 'node:path'
|
|
11
|
+
import { fileURLToPath } from 'node:url'
|
|
12
|
+
|
|
13
|
+
const pkg = dirname(fileURLToPath(import.meta.url))
|
|
14
|
+
const { name, version, files } = JSON.parse(readFileSync(join(pkg, 'package.json'), 'utf8'))
|
|
15
|
+
const target = join(process.env.HOME || homedir(), '.gemini', 'config', 'plugins', name)
|
|
16
|
+
const USAGE = `用法:
|
|
17
|
+
npx ${name} setup antigravity 把 ${name} 装进 Antigravity(${target}),已装的换成这一版
|
|
18
|
+
npx ${name} remove antigravity 从 Antigravity 卸掉
|
|
19
|
+
|
|
20
|
+
Claude Code、Codex 从各自的插件市场装,见 README。`
|
|
21
|
+
|
|
22
|
+
/** target 现在是什么:没有、开发用的链接、装着的 gatelight、别的东西。 */
|
|
23
|
+
function current() {
|
|
24
|
+
let stat
|
|
25
|
+
try {
|
|
26
|
+
stat = lstatSync(target)
|
|
27
|
+
} catch {
|
|
28
|
+
return { kind: 'none' }
|
|
29
|
+
}
|
|
30
|
+
if (stat.isSymbolicLink()) return { kind: 'link', to: readlinkSync(target) }
|
|
31
|
+
try {
|
|
32
|
+
const manifest = JSON.parse(readFileSync(join(target, '.antigravity-plugin', 'plugin.json'), 'utf8'))
|
|
33
|
+
if (manifest.name === name) return { kind: 'ours', version: manifest.version }
|
|
34
|
+
} catch {
|
|
35
|
+
// 读不出清单的按别的东西算
|
|
36
|
+
}
|
|
37
|
+
return { kind: 'other' }
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function refuseLink(to) {
|
|
41
|
+
console.error(`${target} 是指向 ${to} 的链接(开发用的),不动它。要换成 npm 上的版本,先删掉这个链接再运行。`)
|
|
42
|
+
return 1
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function setup() {
|
|
46
|
+
const now = current()
|
|
47
|
+
if (now.kind === 'link') return refuseLink(now.to)
|
|
48
|
+
if (now.kind === 'other') {
|
|
49
|
+
console.error(`${target} 已经有别的东西(不是 ${name} 的插件),没有覆盖。确认不要它后删掉,再运行。`)
|
|
50
|
+
return 1
|
|
51
|
+
}
|
|
52
|
+
// 先复制到旁边,整份到位后再换上去:中途出错不会留下半份插件
|
|
53
|
+
const staging = `${target}.new-${process.pid}`
|
|
54
|
+
const old = `${target}.old-${process.pid}`
|
|
55
|
+
try {
|
|
56
|
+
for (const entry of ['package.json', ...files]) {
|
|
57
|
+
cpSync(join(pkg, entry), join(staging, entry), { recursive: true })
|
|
58
|
+
}
|
|
59
|
+
} catch (error) {
|
|
60
|
+
rmSync(staging, { recursive: true, force: true })
|
|
61
|
+
throw error
|
|
62
|
+
}
|
|
63
|
+
if (now.kind === 'ours') renameSync(target, old)
|
|
64
|
+
renameSync(staging, target)
|
|
65
|
+
rmSync(old, { recursive: true, force: true })
|
|
66
|
+
console.log(now.kind !== 'ours'
|
|
67
|
+
? `已把 ${name} ${version} 装进 Antigravity:${target}`
|
|
68
|
+
: now.version === version
|
|
69
|
+
? `已把 Antigravity 里的 ${name} ${version} 重新装了一遍:${target}`
|
|
70
|
+
: `已把 Antigravity 里的 ${name} 从 ${now.version} 换成 ${version}:${target}`)
|
|
71
|
+
console.log('新开一个 Antigravity 对话生效。')
|
|
72
|
+
return 0
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function remove() {
|
|
76
|
+
const now = current()
|
|
77
|
+
if (now.kind === 'link') return refuseLink(now.to)
|
|
78
|
+
if (now.kind === 'none') {
|
|
79
|
+
console.log(`Antigravity 里没有装 ${name}(${target} 不存在)。`)
|
|
80
|
+
return 0
|
|
81
|
+
}
|
|
82
|
+
if (now.kind === 'other') {
|
|
83
|
+
console.error(`${target} 不是 ${name} 的插件,没有删。`)
|
|
84
|
+
return 1
|
|
85
|
+
}
|
|
86
|
+
rmSync(target, { recursive: true, force: true })
|
|
87
|
+
console.log(`已从 Antigravity 卸掉 ${name} ${now.version}(删了 ${target})。新开的对话里就没有了。`)
|
|
88
|
+
if (existsSync(join(process.env.HOME || homedir(), '.local', 'bin', 'testpace'))) {
|
|
89
|
+
console.log('~/.local/bin 下的 testpace、modwall、testcraft 入口留着:别的 agent 装着的 gatelight 还用它们,一个都没装时它们会说没装。')
|
|
90
|
+
}
|
|
91
|
+
return 0
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
const [command, agent] = process.argv.slice(2)
|
|
95
|
+
if (agent !== 'antigravity' || (command !== 'setup' && command !== 'remove')) {
|
|
96
|
+
console.error(USAGE)
|
|
97
|
+
process.exit(2)
|
|
98
|
+
}
|
|
99
|
+
process.exit(command === 'setup' ? setup() : remove())
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: merge
|
|
3
|
+
description: 把做完的分支合回默认分支:先把测试写上(接入了 testcraft 的),合到一个临时的合并分支上,跑一次 testpace full,通过了再落地。用户说"合""可以合了""提 PR""合并到 main",或接入了 testpace 的仓库要把分支落到默认分支时使用。
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# 合并分支
|
|
7
|
+
|
|
8
|
+
接入了 testpace 的仓库,开发在各自的分支上做:每轮跑一次相关的已有测试、只看不追,不写新测试。把关集中在合回默认分支这一步:用户说合,才把这次的测试写上,再在合并后的代码上跑整组。这一步是兜底的,照下面的步骤严格做,不省。
|
|
9
|
+
|
|
10
|
+
一个分支合一次,不攒:需求定了就写测试、合进去。测试要趁做这个分支的会话还在、还知道这次定了哪些规则的时候写。
|
|
11
|
+
|
|
12
|
+
做完一个任务不要自己合:告诉用户做完了,等用户说合。
|
|
13
|
+
|
|
14
|
+
合并门照常把关:落到默认分支的那份代码必须有 `testpace full` 的通过记录。记录按代码内容算,所有 worktree 共用,所以在合并分支上测过、默认分支快进过去的,不用重跑。
|
|
15
|
+
|
|
16
|
+
下面的 `main` 指仓库的默认分支,以 `testpace status` 和 git 里实际的为准。
|
|
17
|
+
|
|
18
|
+
## 步骤
|
|
19
|
+
|
|
20
|
+
1. **定要合哪些分支**。默认是这个会话自己做的那个分支。
|
|
21
|
+
- 用户点了别的分支的名的,一起合。别的分支的测试该由做它的会话写:你没看过那边的对话,不替它写。它改了业务代码却一个测试文件都没动的,落地后告诉用户一句是哪个分支。它所在的 worktree 有未提交改动的,是还在做的:不合,告诉用户,不替它提交。
|
|
22
|
+
- 这个会话没有自己的分支(比如在主目录里被叫来合),用户又没点名:列出还没合进去的分支(`git branch --no-merged main`)给用户挑。
|
|
23
|
+
2. **把测试补齐**,然后 `testpace focused` 通过,把这个分支提交干净。
|
|
24
|
+
- 开发中留着没过的旧测试(因为用户这次改了需求才不过的):照定下来的规则改掉。
|
|
25
|
+
- 仓库接入了 testcraft(有 `.testcraft/` 目录)的:照 gatelight:write-tests 技能"什么时候写"一节,把这次定下来的规则列出来,交给一个子代理写新测试,旧测试也交给它一起改。这次没改到规则的不用写。
|
|
26
|
+
3. **找一个干净的地方合**。主目录在 `main` 上而且没有未提交改动,就在主目录里做;否则开一个新 worktree,按项目说明准备好环境(依赖、`.env`、服务)。不要在别的会话正在用的目录里做。
|
|
27
|
+
4. **建合并分支并合进来**:从最新的 `main` 建 `merge/<日期时间>`,把要合的分支合进去(`git merge --no-ff --no-edit <分支>`;有几个就一个个合)。
|
|
28
|
+
- 有冲突时,机械性的(比如两边各加了一段、只是位置挨着)可以解决;涉及逻辑取舍的,停下来告诉用户是哪些文件、和 `main` 上的哪次改动冲突,问怎么办。不要用 `-X ours`、`-X theirs` 这类办法一刀切。
|
|
29
|
+
5. **跑整组**:在合并分支上跑 `testpace full`。它依次跑几段,一段没过就停:先是这个仓库接入了的检查(比如模块边界、清单),再是项目的 `full`,最后是全部测试。要跑几分钟:能把命令放到后台的就放后台,不要干等;结束后用 `testpace status` 看结果。
|
|
30
|
+
6. **通过了**:落地是在 `main` 所在的目录里 `git merge --ff-only merge/<...>`。
|
|
31
|
+
- 用户这次说了要合回 `main` 的:直接落地,不再问一次。落地后把合了哪些分支、整组用时、解过哪些冲突告诉用户。
|
|
32
|
+
- 是你自己提出要合的,或者要落地的和用户说的不一样了(拿出过分支):先把这些告诉用户,**用户确认后**再落地。
|
|
33
|
+
- 要推送的,推送先问。
|
|
34
|
+
- 快进不了,说明这期间 `main` 又有了新提交:把最新的 `main` 合进合并分支,再跑一次整组。
|
|
35
|
+
7. **失败了**:先看是哪一段没过,输出的第一行写着("整组失败:某一段没通过")。
|
|
36
|
+
- **测试之前的检查没过**(不是测试失败):那一段自己的输出说了哪里不对、怎么改,照它做。
|
|
37
|
+
- 输出里让你调用 `confirm_with_user` 的:是要用户同意的改动。分支上用户同意过的那几项不会再问,列出来的是还没同意的。照输出先用白话告诉用户每一项,再弹窗;用户同意后重跑整组,不同意的回到分支上改掉。
|
|
38
|
+
- 要改代码、改配置的:回到分支上改,再合一次。
|
|
39
|
+
- **测试失败**:回到这个分支自己的 worktree 里,用 `testpace files <文件:行号>` 跑失败的测试,找到原因修好,提交后重新建合并分支再合。不要在合并分支上直接改代码修测试。
|
|
40
|
+
- **一次合了几个分支的**:从失败的测试找是哪个分支引起的:看失败的测试测的是哪块代码,对照各分支改了哪些文件(`git diff --stat main...<分支>`)。把引起失败的分支拿出来:合并分支回到 `main`(`git reset --hard main`,只对这个临时分支做),重新合其余的分支,再跑一次整组;告诉用户拿出了哪个分支、为什么。单独都通过、合在一起才失败的,是分支之间互相影响,告诉用户是哪两个分支。
|
|
41
|
+
- 重跑没过的测试时它过了,testpace 会点名它时好时坏、记进名单。它不是这次要合的分支引起的(分支没碰它测的代码)时:告诉用户是哪个测试、两次的日志在哪,用户同意后再跑一次整组落地,它留在名单上另外修。不要不说就重跑整组过关。
|
|
42
|
+
8. **收尾**:列出已经合进去的分支和它们的 worktree,问用户要不要删。合并分支落地后可以删掉。
|