gatelight 0.18.0 → 0.19.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/.antigravity-plugin/plugin.json +2 -2
- package/.claude-plugin/plugin.json +2 -2
- package/.codex-plugin/mcp.json +10 -0
- package/.codex-plugin/mcp.sh +7 -0
- package/.codex-plugin/plugin.json +4 -3
- package/README.md +1 -1
- package/bin/codekeep +8 -0
- package/entry/command +1 -1
- package/hooks/hooks.json +1 -1
- package/package.json +2 -2
- package/setup.mjs +1 -1
- package/skills/setup-codekeep/SKILL.md +80 -0
- package/src/base/commandline.ts +2 -2
- package/src/base/confirm.ts +26 -10
- package/src/base/entry.ts +2 -2
- package/src/base/version.ts +1 -1
- package/src/cli.ts +3 -3
- package/src/codekeep.ts +8 -0
- package/src/keep/check.ts +296 -0
- package/src/keep/commands.ts +48 -0
- package/src/keep/config.ts +139 -0
- package/src/keep/eslint.ts +233 -0
- package/src/keep/forktree.ts +86 -0
- package/src/keep/full.ts +29 -0
- package/src/keep/index.ts +13 -0
- package/src/keep/loosen.ts +163 -0
- package/src/keep/prettier.ts +58 -0
- package/src/keep/secrets.ts +63 -0
- package/src/keep/session.ts +22 -0
- package/src/keep/tsconfig.ts +115 -0
- package/src/mcp.ts +89 -30
- package/src/modules.ts +3 -2
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gatelight",
|
|
3
3
|
"displayName": "gatelight",
|
|
4
|
-
"version": "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",
|
|
4
|
+
"version": "0.19.1",
|
|
5
|
+
"description": "Gates for coding agents: tests actually ran before code lands, code stays inside its module boundaries, standards (types, lint, format, secrets) are not quietly loosened, plus test-writing conventions and a change-triggered checklist",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "coffeecoproject"
|
|
8
8
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gatelight",
|
|
3
3
|
"displayName": "gatelight",
|
|
4
|
-
"version": "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",
|
|
4
|
+
"version": "0.19.1",
|
|
5
|
+
"description": "Gates for coding agents: tests actually ran before code lands, code stays inside its module boundaries, standards (types, lint, format, secrets) are not quietly loosened, plus test-writing conventions and a change-triggered checklist",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "coffeecoproject"
|
|
8
8
|
},
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
# Codex 起确认工具服务的入口(.codex-plugin/mcp.json):Codex 起服务的环境里不一定有能运行 TypeScript 的 node,先找一个,
|
|
3
|
+
# 再起 src/mcp.ts(参数 codex:服务自己向 Codex 发表单问用户)。找不到 node 时说一声、退出,Codex 里就没有这个工具。
|
|
4
|
+
dir=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd)
|
|
5
|
+
. "$dir/bin/node.sh"
|
|
6
|
+
node=$(testpace_node) || { echo "gatelight 的确认工具没有启动:找不到 22.18 以上的 node(要能直接运行 TypeScript)。装一个,或用 TESTPACE_NODE 指给它。" >&2; exit 1; }
|
|
7
|
+
exec "$node" --disable-warning=ExperimentalWarning "$dir/src/mcp.ts" codex
|
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gatelight",
|
|
3
|
-
"version": "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",
|
|
3
|
+
"version": "0.19.1",
|
|
4
|
+
"description": "Gates for coding agents: tests actually ran before code lands, code stays inside its module boundaries, standards (types, lint, format, secrets) are not quietly loosened, plus test-writing conventions and a change-triggered checklist",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "coffeecoproject"
|
|
7
7
|
},
|
|
8
8
|
"license": "MIT",
|
|
9
9
|
"keywords": ["testing", "test selection", "merge gate", "test quality", "module boundaries", "coding agent"],
|
|
10
10
|
"hooks": "./hooks/codex.json",
|
|
11
|
+
"mcpServers": "./.codex-plugin/mcp.json",
|
|
11
12
|
"skills": "./skills/",
|
|
12
13
|
"interface": {
|
|
13
14
|
"displayName": "gatelight",
|
|
14
|
-
"shortDescription": "Gates for coding agents: tests ran, code stays in bounds, test-writing conventions",
|
|
15
|
+
"shortDescription": "Gates for coding agents: tests ran, code stays in bounds, standards hold, test-writing conventions",
|
|
15
16
|
"developerName": "coffeecoproject",
|
|
16
17
|
"category": "Developer Tools"
|
|
17
18
|
}
|
package/README.md
CHANGED
package/bin/codekeep
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
# codekeep 命令入口("代码规范"模块的命令)。Claude Code 插件启用时这个目录在 Bash 工具的 PATH 里;
|
|
3
|
+
# 别处(Codex 的命令)由固定入口 ~/.local/bin/codekeep(entry/command)转过来。
|
|
4
|
+
dir=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
|
|
5
|
+
. "$dir/node.sh"
|
|
6
|
+
# 找不到 node 时退出码 2(配置问题)
|
|
7
|
+
node=$(testpace_node) || { echo 'codekeep:找不到 22.18 以上的 node(要能直接运行 TypeScript)。装一个,或用 TESTPACE_NODE 指给它。' >&2; exit 2; }
|
|
8
|
+
exec "$node" --disable-warning=ExperimentalWarning "$dir/../src/codekeep.ts" "$@"
|
package/entry/command
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/bin/sh
|
|
2
|
-
# testpace 固定入口:testpace install 把这个文件放到 ~/.local/bin 下,gatelight 的每条命令放一份(testpace、modwall、testcraft),内容一样,
|
|
2
|
+
# testpace 固定入口:testpace install 把这个文件放到 ~/.local/bin 下,gatelight 的每条命令放一份(testpace、modwall、testcraft、codekeep),内容一样,
|
|
3
3
|
# 运行时按被叫的名字转给插件里同名的命令(Codex 的命令和终端的 PATH 里都有这个目录)。放哪几条由 src/base/entry.ts 定,这里不列。
|
|
4
4
|
# 放上去时第一行后面插一行记着是哪一版放的(entry.ts),会话开始的自动更新只升不降。
|
|
5
5
|
# 插件(gatelight)的安装目录随版本变,不能写死,这里每次运行时找这台机器上装着的最高版本,Claude Code、Codex、Antigravity 装的都算,不分先后。
|
package/hooks/hooks.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"description": "gatelight:会话开始时说明测试节奏和写测试的约定(接入了 testcraft 的仓库),直接跑 full 的命令时提醒改用 testpace full;接入了 modwall 的仓库再说明模块列表和写法约定,改文件之前拦下没有归属的代码文件,和新文字里绕过入口引用别的模块内部文件的写法(只看路径和要写的文字);整组没跑完或结果没看、改了代码却没有 modwall check 的通过记录,拦一次结束。合并门是 git 钩子(testpace install)。",
|
|
2
|
+
"description": "gatelight:会话开始时说明测试节奏和写测试的约定(接入了 testcraft 的仓库)、代码规范的约定(接入了 codekeep 的仓库),直接跑 full 的命令时提醒改用 testpace full;接入了 modwall 的仓库再说明模块列表和写法约定,改文件之前拦下没有归属的代码文件,和新文字里绕过入口引用别的模块内部文件的写法(只看路径和要写的文字);整组没跑完或结果没看、改了代码却没有 modwall check 的通过记录,拦一次结束。合并门是 git 钩子(testpace install)。",
|
|
3
3
|
"hooks": {
|
|
4
4
|
"SessionStart": [
|
|
5
5
|
{
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gatelight",
|
|
3
|
-
"version": "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",
|
|
3
|
+
"version": "0.19.1",
|
|
4
|
+
"description": "Gates for coding agents: tests actually ran before code lands, code stays inside its module boundaries, standards (types, lint, format, secrets) are not quietly loosened, plus test-writing conventions and a change-triggered checklist",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://github.com/coffeecoproject/gatelight#readme",
|
|
7
7
|
"repository": { "type": "git", "url": "git+https://github.com/coffeecoproject/gatelight.git", "directory": "plugin" },
|
package/setup.mjs
CHANGED
|
@@ -86,7 +86,7 @@ function remove() {
|
|
|
86
86
|
rmSync(target, { recursive: true, force: true })
|
|
87
87
|
console.log(`已从 Antigravity 卸掉 ${name} ${now.version}(删了 ${target})。新开的对话里就没有了。`)
|
|
88
88
|
if (existsSync(join(process.env.HOME || homedir(), '.local', 'bin', 'testpace'))) {
|
|
89
|
-
console.log('~/.local/bin 下的 testpace、modwall、testcraft 入口留着:别的 agent 装着的 gatelight 还用它们,一个都没装时它们会说没装。')
|
|
89
|
+
console.log('~/.local/bin 下的 testpace、modwall、testcraft、codekeep 入口留着:别的 agent 装着的 gatelight 还用它们,一个都没装时它们会说没装。')
|
|
90
90
|
}
|
|
91
91
|
return 0
|
|
92
92
|
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: setup-codekeep
|
|
3
|
+
description: 给项目接入 codekeep:确认已接入 testpace、testpace 的 ignore 没盖住规范配置;按项目现有的工具配好严格类型、lint(长度和复杂度上限、"这里不查"的注释要写理由)、格式检查,旧代码超标的记进 eslint 的批量豁免文件;写 .codekeep/config.json,把规范检查从 full 挪过来;没装 gitleaks 的问用户要不要装;跑一次 codekeep check 和整组。用户要给项目接入 codekeep 时使用。
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# 接入 codekeep
|
|
7
|
+
|
|
8
|
+
codekeep 管代码本身的规范:类型查得严不严、lint 和格式检查有没有、规范有没有被悄悄改松、提交里有没有密钥。它不让 AI 判断代码写得好不好,只做程序判断得了的事。它和 testpace 在同一个插件里:仓库里有 `.codekeep/` 目录,`testpace full` 就会在测试之前跑一次 `codekeep check`,不用另外登记。
|
|
9
|
+
|
|
10
|
+
`codekeep check` 依次做:
|
|
11
|
+
|
|
12
|
+
1. 配置写得对不对(`.codekeep/config.json`)。
|
|
13
|
+
2. 和分叉点比,规范改松了哪些:关规则、error 降成 warn、调高上限、文件不再被 lint、关严格类型选项、开 `skipLibCheck`、`include` 少了或 `exclude` 多了、批量豁免变多、`.gitleaksignore` 多了条目、改了 gitleaks 或 biome 的配置、改了或删了检查命令。改松的要用户在弹窗里同意;分叉点上还没有 `.codekeep/`(首次接入)的不问。
|
|
14
|
+
3. 依次跑 `checks` 里的命令,一条没过就停。
|
|
15
|
+
4. `secrets` 开着时用 gitleaks 扫分叉点之后的提交和没提交的改动。
|
|
16
|
+
|
|
17
|
+
第一期只做 TypeScript、JavaScript,lint 只比 eslint。
|
|
18
|
+
|
|
19
|
+
## 先确认
|
|
20
|
+
|
|
21
|
+
1. **接入了 testpace**:仓库根目录有 `testpace.json`,`testpace verify` 能过。没有就先用 `gatelight:setup` 接入:会话说明、整组、合并前的把关都只管接入了 testpace 的仓库。
|
|
22
|
+
2. **`testpace.json` 的 `ignore` 没盖住规范配置**:`.codekeep/`、eslint 的配置文件、`tsconfig*.json`、`eslint-suppressions.json`、`.prettierignore`、`.gitleaksignore`、`.gitleaks.toml` 都不能在 `ignore` 里(比如 `.*/**`、`*.json`)。盖住的话,改这些不会重跑整组,改松规范就绕过了合并门:从 `ignore` 里去掉它们。
|
|
23
|
+
|
|
24
|
+
## 步骤(在接入分支上做)
|
|
25
|
+
|
|
26
|
+
1. **看项目现有的工具**:类型检查(TypeScript)、lint(eslint 还是 biome)、格式(prettier 还是 biome)各有没有,各子包用的是不是同一套。缺的要新装依赖,**先问用户**,说清装什么、为什么。
|
|
27
|
+
- 用 biome 的项目:eslint 那一项先不写(codekeep 不比 biome 生效的规则),biome 的配置(仓库根目录的 `biome.json`、`biome.jsonc`)改了,整组按"程序看不出改松还是改紧"问用户。
|
|
28
|
+
2. **配严格类型**:每个 tsconfig 开 `strict`。开了以后旧代码报错的,少的直接改;多的、或者要动业务逻辑才改得掉的,停下来问用户。
|
|
29
|
+
3. **配 lint**(eslint 的 flat config;批量豁免用 eslint 自带的,实测 eslint 10 有):
|
|
30
|
+
- 用工具的推荐集:`@eslint/js` 的 `recommended`,TypeScript 项目加 `typescript-eslint` 的 `recommended`(里面有不许 `any`、不许没用的变量和导入),React 项目加 `eslint-plugin-react-hooks` 的推荐集(代码里已经有 `react-hooks/...` 的注释的,不加它 lint 会报找不到规则)。
|
|
31
|
+
- 长度和复杂度上限:`max-lines` 500(`{ max: 500, skipBlankLines: true, skipComments: true }`)、`max-lines-per-function` 80(同样不算空行和注释)、`complexity` 20、`max-depth` 5,都是 `error`。先放宽一点,试接后再调。
|
|
32
|
+
- 只查 git 收的文件:eslint 不读 `.git/info/exclude` 和全局的排除规则,本机工具放在仓库里的目录(napbox 的 `.napbox/`、agent 开在仓库里的 `.claude/worktrees/`)只写在那里,在主目录跑会查到它们(嵌着的工作区还会按它自己的配置查、对不上主目录的批量豁免)。配置文件开头用 git 列出它不收的,放进 `ignores`:
|
|
33
|
+
|
|
34
|
+
```js
|
|
35
|
+
import { execFileSync } from 'node:child_process'
|
|
36
|
+
const gitIgnored = execFileSync('git', ['ls-files', '-z', '--others', '--ignored', '--exclude-standard', '--directory'], { cwd: import.meta.dirname, encoding: 'utf8' })
|
|
37
|
+
.split('\0')
|
|
38
|
+
.filter(Boolean)
|
|
39
|
+
.map(path => path.replace(/[*?[\]{}()!\\]/g, '\\$&'))
|
|
40
|
+
// export default [{ ignores: gitIgnored }, ...]
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
- "这里不查"的注释要写理由、没用了的要删:`linterOptions: { reportUnusedDisableDirectives: 'error' }`;`@eslint-community/eslint-plugin-eslint-comments` 的 `require-description`(`eslint-disable` 一类的注释要带 `-- 理由`);TypeScript 项目用 `@typescript-eslint/ban-ts-comment` 的默认设置(`@ts-ignore`、`@ts-nocheck` 不许用,`@ts-expect-error` 要写理由)。没装这几个插件的,装之前先问用户。
|
|
44
|
+
4. **格式检查**:项目有 prettier 的用它;没有的问用户要不要加。检查命令把 git 收的文件交给 prettier(`git ls-files -z --cached --others --exclude-standard | xargs -0 pnpm -s exec prettier --check --ignore-unknown --no-error-on-unmatched-pattern`),不用 `prettier --check .`:prettier 只读仓库根目录的 `.gitignore` 和 `.prettierignore`,会查到上面说的本机工具目录。新加的照项目现有的写法配(分号、引号、行宽),让改动尽量小,再 `prettier --write .` 把全部代码排一遍(改动大,先和用户说清;有别的分支正在做的,排完它们合进来会冲突,先问)。`.prettierignore` 里写上 `eslint-suppressions.json`(eslint 生成、改写它,不按 prettier 排)和锁文件。
|
|
45
|
+
5. **旧代码超标的记进批量豁免**:`eslint --suppress-all`,生成仓库根目录的 `eslint-suppressions.json`,提交进仓库。以后豁免只许变少:代码改好了用 `eslint --prune-suppressions` 清掉用不上的;豁免变多算改松,要用户同意。lint 不在仓库根目录跑的,用 `--suppressions-location` 指到同一个文件,并在配置里写上 `eslint.suppressions`。
|
|
46
|
+
6. **写 `.codekeep/config.json`**:
|
|
47
|
+
|
|
48
|
+
```json
|
|
49
|
+
{
|
|
50
|
+
"checks": [
|
|
51
|
+
{ "name": "类型检查", "command": "pnpm -s exec tsc -p apps/server --noEmit" },
|
|
52
|
+
{ "name": "lint", "command": "pnpm -s exec eslint ." },
|
|
53
|
+
{ "name": "格式", "command": "git ls-files -z --cached --others --exclude-standard | xargs -0 pnpm -s exec prettier --check --ignore-unknown --no-error-on-unmatched-pattern" }
|
|
54
|
+
],
|
|
55
|
+
"eslint": { "config": "eslint.config.mjs" },
|
|
56
|
+
"tsconfig": ["apps/server/tsconfig.json", "apps/web/tsconfig.app.json"],
|
|
57
|
+
"prettier": true,
|
|
58
|
+
"secrets": true
|
|
59
|
+
}
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
- `checks`:规范检查直接写工具命令,从仓库根目录用 sh 跑,不经过项目的脚本(脚本里删掉一行,codekeep 看不到)。每个要类型检查的 tsconfig 各写一条。
|
|
63
|
+
- `eslint.config`:eslint 的配置文件,codekeep 按它对每个代码文件算"生效的规则"来比;`eslint.suppressions`:批量豁免文件,不在仓库根目录的 `eslint-suppressions.json` 时才写。不用 eslint 的项目不写 `eslint`。
|
|
64
|
+
- `prettier`:用 prettier 做格式检查的写 `true`,codekeep 比每个文件查不查(往 `.prettierignore` 里加路径算改松)。
|
|
65
|
+
- `tsconfig`:`checks` 里类型检查用到的 tsconfig,codekeep 比它们的严格选项。只写引用别的 tsconfig 的(`tsc -b` 用的那种总的)不用写它,写它引用的那几份。
|
|
66
|
+
- `secrets`:开着时扫密钥(下一步)。
|
|
67
|
+
- 路径都从仓库根目录写起。
|
|
68
|
+
- 把这几条检查从项目的 `full`(`testpace.json` 的 `full`,或它调用的脚本)里挪出来,不要两边都跑。先用白话告诉用户挪了什么:`full` 直接写在 `testpace.json` 里的,改了整组会照 testpace 原有的流程弹窗;`full` 调的是脚本的,testpace 看不到脚本里删了哪行,不会弹窗,只靠这一句告诉用户。`fast` 里的 lint 和类型检查照旧留着;`fast` 没有 lint 的加上(整个仓库 lint 一遍一般几秒)。
|
|
69
|
+
- 接入了 modwall 的仓库:新加的 `eslint.config.mjs` 这类配置文件没有归属,`modwall check` 会报,把它加进 `.modwall/config.json` 的 `outside`(放宽规则,整组会弹窗要用户同意一次)。
|
|
70
|
+
7. **密钥扫描**:`gitleaks version` 看装没装。没装的问用户要不要装(`brew install gitleaks`,别的系统见 https://github.com/gitleaks/gitleaks#installing),这是装在这台机器上的工具,用户同意了再装;用户不要的,`secrets` 写 `false`。gitleaks 用仓库根目录的 `.gitleaks.toml`、`.gitleaksignore`(有的话),旧提交里的不管,只扫这次改动。代码里的 `gitleaks:allow` 注释不认:确实不是密钥的,把那一条的 Fingerprint 加进 `.gitleaksignore`(算放松,要用户同意)。
|
|
71
|
+
8. **跑一次**:`codekeep check` 通过(首次接入不问用户),再跑 `testpace full`。
|
|
72
|
+
9. 提交前先问用户;合回默认分支照 testpace 的节奏(`gatelight:merge`)。
|
|
73
|
+
|
|
74
|
+
## 完成时用白话告诉用户
|
|
75
|
+
|
|
76
|
+
比如:
|
|
77
|
+
|
|
78
|
+
> 项目的类型检查开了严格模式,lint 加上了文件和函数长度、复杂度的上限,旧代码里超标的先记下来、以后只许减少。从现在起,谁把这些规范改松(关规则、调高上限、加豁免),合并前都会弹窗问你;提交里带了密钥也会被拦下。
|
|
79
|
+
|
|
80
|
+
有没接上的(没装 gitleaks、项目用 biome 所以 lint 规则没在比),也在这里说清楚。
|
package/src/base/commandline.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
//
|
|
2
|
-
// 各命令只说哪些子命令在沙箱里跑不了、要做什么(outside
|
|
1
|
+
// 几条命令(testpace、modwall、testcraft、codekeep)的入口共用的一层:在 agent 的沙箱里跑不了的子命令事先拒绝,写入被拒时说清楚。
|
|
2
|
+
// 各命令只说哪些子命令在沙箱里跑不了、要做什么(outside);怎么认沙箱、怎么说、退出码是什么都在这里,各个入口都经过它。
|
|
3
3
|
|
|
4
4
|
import { AGENTS, currentAgent } from './agent.ts'
|
|
5
5
|
import { EXIT } from './exit.ts'
|
package/src/base/confirm.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
// 用户确认:检查里有要用户同意的改动(放松了测试、放宽了规则)时,模块把条目交到这里,不自己弹窗、不自己存同意记录。
|
|
2
2
|
// 同意只能来自确认工具(src/mcp.ts 的 confirm_with_user):每次调用都要用户在弹窗里同意(Claude Code 靠工具上的标记,
|
|
3
|
-
// Antigravity 靠 hook 的 force_ask
|
|
3
|
+
// Antigravity 靠 hook 的 force_ask,Codex 靠服务自己向客户端发的表单),agent 自己说"用户同意了"不算。
|
|
4
4
|
//
|
|
5
5
|
// 同意按项记:一项是"哪个模块的、改之前是什么、改成什么、用户当时看到的文字",四样都一样才是同一项。
|
|
6
6
|
// 几个分支合到一起,没再动过的那一项不用重新确认;文字相同但改之前的内容不同,是另一项,要重新确认。
|
|
7
7
|
//
|
|
8
8
|
// 两步:检查(askUser)把还没同意的条目按编号存好,输出编号和弹窗文字让 agent 去调工具;
|
|
9
|
-
// 工具(
|
|
9
|
+
// 工具(check、record)只按编号取存下的内容,核对传来的文字一字不差,用户同意了再记下。工具进程跟着会话开着、插件更新后还是旧代码,
|
|
10
10
|
// 所以它不打开改动、不做任何判断。
|
|
11
11
|
//
|
|
12
12
|
// 记录在 .git/testpace/confirm/ 下(所有 worktree 共用):pending.json 等用户过目的,confirmed.json 用户同意过的。
|
|
@@ -135,11 +135,21 @@ export interface Confirmed {
|
|
|
135
135
|
/** 编号是 32 位十六进制。 */
|
|
136
136
|
const ID = /^[0-9a-f]{32}$/
|
|
137
137
|
|
|
138
|
-
/**
|
|
139
|
-
export
|
|
138
|
+
/** 核对通过、还没记下的一次确认:popup 是检查给这个编号存下的弹窗文字,用户同意了再调 record。 */
|
|
139
|
+
export interface Checked {
|
|
140
|
+
ok: true
|
|
141
|
+
popup: string
|
|
142
|
+
record: () => Confirmed
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* 只核对、不记:编号和文字对得上时返回存下的弹窗文字和记下同意的办法。
|
|
147
|
+
* 工具自己问用户的 agent(Codex:服务向客户端发表单)先核对再问,用户同意了才 record;对不上的不问用户。
|
|
148
|
+
*/
|
|
149
|
+
export function check(repoPath: string, id: string, text: string): Checked | { ok: false; text: string } {
|
|
140
150
|
const root = existsSync(repoPath) ? repoRoot(repoPath) : undefined
|
|
141
|
-
if (!root) return { ok: false, text: `${repoPath} 不在 git 仓库里` }
|
|
142
|
-
const missing = { ok: false, text: '没有这个编号要确认的内容:重跑要求确认的那条检查,照它输出的编号和文字填。' }
|
|
151
|
+
if (!root) return { ok: false as const, text: `${repoPath} 不在 git 仓库里` }
|
|
152
|
+
const missing = { ok: false as const, text: '没有这个编号要确认的内容:重跑要求确认的那条检查,照它输出的编号和文字填。' }
|
|
143
153
|
if (!ID.test(id)) return missing
|
|
144
154
|
const store = new Store(commonDir(root))
|
|
145
155
|
// 编号是外面传来的:模块记录只取文件里这个键自己的
|
|
@@ -154,8 +164,14 @@ export function confirm(repoPath: string, id: string, text: string): Confirmed {
|
|
|
154
164
|
if (plain(text) !== plain(pending.text)) {
|
|
155
165
|
return { ok: false, text: '传来的文字和检查给这个编号的不一致:照它输出的原样填,不要改写、增删。' }
|
|
156
166
|
}
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
167
|
+
return {
|
|
168
|
+
ok: true,
|
|
169
|
+
popup: pending.text,
|
|
170
|
+
record: () => {
|
|
171
|
+
const records = confirmedOf(store)
|
|
172
|
+
const at = Date.now()
|
|
173
|
+
for (const item of pending.items) records.put(item.key, { module: pending.module, text: item.text, at })
|
|
174
|
+
return { ok: true, text: `已记下:用户确认并同意了这 ${pending.items.length} 项。再跑一次要求确认的那条检查。` }
|
|
175
|
+
},
|
|
176
|
+
}
|
|
161
177
|
}
|
package/src/base/entry.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// 固定命令入口:~/.local/bin 下的 testpace、modwall、testcraft。Codex 不把插件的 bin/ 放进命令的 PATH,合并门的 git 钩子也靠 PATH 找 testpace。
|
|
1
|
+
// 固定命令入口:~/.local/bin 下的 testpace、modwall、testcraft、codekeep。Codex 不把插件的 bin/ 放进命令的 PATH,合并门的 git 钩子也靠 PATH 找 testpace。
|
|
2
2
|
// 入口文件只有一份(entry/command),每条命令放一份一样的;它不带版本,运行时按被叫的名字找这台机器上装着的最高版本的插件里同名的命令,插件升级不用重放。
|
|
3
3
|
// 这是全局安装:只在 testpace install 时放,不在会话开始时自动放(放过别的命令的机器上,新加的命令也一样)。
|
|
4
4
|
// 放过的入口是旧版本放的(入口文件本身变了,比如插件改了名、旧入口按旧名字找不到装着的那份):会话开始时换成这一版的。
|
|
@@ -11,7 +11,7 @@ import { join } from 'node:path'
|
|
|
11
11
|
import { compareVersions, VERSION } from './version.ts'
|
|
12
12
|
|
|
13
13
|
/** 放固定入口的命令:插件 bin/ 里给 agent 直接叫的那几条。加命令只改这里。 */
|
|
14
|
-
export const ENTRY_COMMANDS = ['testpace', 'modwall', 'testcraft'] as const
|
|
14
|
+
export const ENTRY_COMMANDS = ['testpace', 'modwall', 'testcraft', 'codekeep'] as const
|
|
15
15
|
export type EntryCommand = (typeof ENTRY_COMMANDS)[number]
|
|
16
16
|
|
|
17
17
|
const SOURCE = new URL('../../entry/command', import.meta.url)
|
package/src/base/version.ts
CHANGED
|
@@ -8,7 +8,7 @@ export const VERSION: string = manifest.version
|
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* 插件的名字。说给 agent 的话里提到插件时用它;确认工具的全名里也有它(.mcp.json 里服务的名字,测试核对和它一样)。
|
|
11
|
-
*
|
|
11
|
+
* 几条命令(testpace、testcraft、modwall、codekeep)不跟它走。
|
|
12
12
|
*/
|
|
13
13
|
export const PLUGIN_NAME: string = manifest.name
|
|
14
14
|
|
package/src/cli.ts
CHANGED
|
@@ -29,7 +29,7 @@ const USAGE = `用法:
|
|
|
29
29
|
testpace files [--repeat N] PATH[:行号]...
|
|
30
30
|
只跑给定的测试文件(testpace.json 的 files);文件:行号 只跑那一行的测试,比如重跑失败的测试。
|
|
31
31
|
--repeat N 连跑 N 次、没过就停:造出时好时坏的测试的失败,或修好后连跑 3 次证明
|
|
32
|
-
testpace full 跑整组:接入了的检查(modwall check、testcraft checklist)、full(测试以外的检查),再把 tests 规则找到的全部测试交给 files,
|
|
32
|
+
testpace full 跑整组:接入了的检查(modwall check、testcraft checklist、codekeep check)、full(测试以外的检查),再把 tests 规则找到的全部测试交给 files,
|
|
33
33
|
一段没过就停,按当前工作区完整内容记录结果。要跑几分钟,能放到后台的就放后台
|
|
34
34
|
testpace status 当前代码有没有整组通过记录、有没有正在跑的整组、最近一次结果、配置检查
|
|
35
35
|
testpace hold PID 说明 借用这个工作区(比如要复制一份工作区的工具):占着时别的 testpace 命令不跑,说明是谁占着。
|
|
@@ -39,7 +39,7 @@ const USAGE = `用法:
|
|
|
39
39
|
testpace report [--days N] 计时诊断,默认最近 28 天
|
|
40
40
|
testpace verify [测试文件...] 核对接入守不守约定:三条命令找得到、合并门在把关、files 对不存在的文件报失败、认 文件:行号;每种测试各给一个文件
|
|
41
41
|
testpace install 这台机器配一次:在全局 git 配置里配上合并门(agent 移动默认分支时,要求落地的代码有整组通过记录),
|
|
42
|
-
并在 ~/.local/bin 放上 testpace、modwall、testcraft 的固定命令入口(Codex 的命令和合并门的钩子靠它们找到这几条命令)
|
|
42
|
+
并在 ~/.local/bin 放上 testpace、modwall、testcraft、codekeep 的固定命令入口(Codex 的命令和合并门的钩子靠它们找到这几条命令)
|
|
43
43
|
${nodeTest.usage}
|
|
44
44
|
${vitest.usage}
|
|
45
45
|
${playwright.usage}
|
|
@@ -117,7 +117,7 @@ const ENTRY_STATES = {
|
|
|
117
117
|
foreign: '那里是别的文件,没有放',
|
|
118
118
|
} as const
|
|
119
119
|
|
|
120
|
-
/** 各条命令的固定入口放得怎样,状态一样的并在一起说:testpace 已放好;modwall、testcraft 没放:…… */
|
|
120
|
+
/** 各条命令的固定入口放得怎样,状态一样的并在一起说:testpace 已放好;modwall、testcraft、codekeep 没放:…… */
|
|
121
121
|
function entryLine(): string {
|
|
122
122
|
const states = Object.keys(ENTRY_STATES) as EntryState[]
|
|
123
123
|
return states
|
package/src/codekeep.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// codekeep 命令行入口:check(实现在 keep/commands.ts)。
|
|
2
|
+
// 这个文件的路径不能变:bin/codekeep 和整组里"代码规范"的那一段按它找。
|
|
3
|
+
|
|
4
|
+
import './modules.ts'
|
|
5
|
+
import { runCommandLine } from './base/commandline.ts'
|
|
6
|
+
import { main, outside } from './keep/commands.ts'
|
|
7
|
+
|
|
8
|
+
process.exitCode = await runCommandLine({ name: 'codekeep', outside, run: main }, process.argv.slice(2))
|