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
package/src/base/stop.ts
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
// 停止门:agent 要结束这一轮时,这个会话起的整组还在跑、或跑完还没看结果,就拦一次。
|
|
2
|
+
// 各模块在这个会话里还没处理完的事(module.ts 的 unfinished,比如改了代码还没有 modwall check 的通过记录),每件也拦一次;
|
|
3
|
+
// 只问会话干活的工作区(所在目录的、用改文件的工具改过的),只在命令里 cd 进去看过的别人的工作区不问。
|
|
4
|
+
// 每次整组只拦一次(还在跑时一次、跑完没看结果时一次),拦过的记在会话状态里,不靠 agent 给的 stop_hook_active:
|
|
5
|
+
// 有的 agent 不给或总是 false,靠它会反复拦。
|
|
6
|
+
// 谁起的整组看记录里的会话号(testpace full 从命令环境里 agent 的会话号记下,见 agent.ts);
|
|
7
|
+
// 想跑整组时发现同一个工作区已经在跑、等着用它结果的会话也算。别的会话或用户在终端里起的不管。
|
|
8
|
+
// 顺带检查本地和远程(origin)默认分支在这个会话里有没有落了没测过的代码,有就提示用户:
|
|
9
|
+
// 合并门只在 agent 移动本地默认分支时把关,推送别的分支到默认分支、在 GitHub 上合并 PR 不经过它。
|
|
10
|
+
// 这一项和合并门一样看提交里的 testpace.json:管不管、按哪些 ignore 判断,都不看工作区里的文件。
|
|
11
|
+
|
|
12
|
+
import { contractAt, CONTRACT_FILE, effectiveIgnore, joined } from './contract.ts'
|
|
13
|
+
import { duration, short, when } from './format.ts'
|
|
14
|
+
import { hasFile, refTip } from './git.ts'
|
|
15
|
+
import { modules } from './module.ts'
|
|
16
|
+
import { coverageOf, defaultTips, openRepo } from './repo.ts'
|
|
17
|
+
|
|
18
|
+
export interface StopInput {
|
|
19
|
+
sessionId: string
|
|
20
|
+
cwd: string
|
|
21
|
+
/** 仓库不是会话所在目录的(会话从仓库外开始),话里写上是哪个仓库。 */
|
|
22
|
+
named?: boolean
|
|
23
|
+
now: number
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export interface StopResult {
|
|
27
|
+
/** 拦下来时给 agent 的话。 */
|
|
28
|
+
block?: string
|
|
29
|
+
/** 给用户看的提示。 */
|
|
30
|
+
warn?: string
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export function stopCheck(input: StopInput): StopResult {
|
|
34
|
+
const repo = openRepo(input.cwd)
|
|
35
|
+
if (!repo || !joined(repo.root)) return {}
|
|
36
|
+
const session = repo.store.session(input.sessionId, input.now, () => defaultTips(repo))
|
|
37
|
+
const result: StopResult = {}
|
|
38
|
+
const place = input.named ? `${repo.root} 这个工作区` : '这个工作区'
|
|
39
|
+
|
|
40
|
+
const blocked = [...(session.blocked ?? [])]
|
|
41
|
+
const ours = (record: { kind: string; worktree: string; session?: string; waiting?: string[] }): boolean =>
|
|
42
|
+
record.kind === 'full' &&
|
|
43
|
+
record.worktree === repo.root &&
|
|
44
|
+
(record.session === input.sessionId || record.waiting?.includes(input.sessionId) === true)
|
|
45
|
+
const running = repo.store.running().find(marker => ours({ ...marker, waiting: repo.store.waiting(marker) }))
|
|
46
|
+
const last = repo.store
|
|
47
|
+
.readRuns()
|
|
48
|
+
.filter(ours)
|
|
49
|
+
.sort((a, b) => b.startedAt - a.startedAt)[0]
|
|
50
|
+
if (running && !blocked.includes(`running:${running.id}`)) {
|
|
51
|
+
blocked.push(`running:${running.id}`)
|
|
52
|
+
result.block = `${place}的整组还在跑(开始于 ${when(running.startedAt)},已 ${duration(input.now - running.startedAt)})。结论要等整组结果:等它结束后跑 testpace status 看结果,再收尾。`
|
|
53
|
+
} else if (!running && last && last.startedAt + last.durationMs > (session.read?.[repo.root] ?? 0) && !blocked.includes(`unread:${last.id}`)) {
|
|
54
|
+
blocked.push(`unread:${last.id}`)
|
|
55
|
+
const outcome = last.result === 'pass' ? '通过' : '失败'
|
|
56
|
+
const verb = last.session === input.sessionId ? '跑' : '等'
|
|
57
|
+
result.block = `这个会话${input.named ? `在 ${repo.root} ` : ''}${verb}的整组已经结束(${outcome}),还没看结果。先跑 testpace status 看结果,再收尾。`
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// 各模块在这个会话里还没处理完的事(比如改了代码还没有 modwall check 的通过记录):每件拦一次,免得一句带过。
|
|
61
|
+
// 只问这个会话干活的工作区(会话所在目录的、用改文件的工具改过的,见 SessionState.worked):只 cd 进去看过的,那里后来的改动是别的会话的
|
|
62
|
+
const works = input.named !== true || session.worked?.includes(repo.root) === true
|
|
63
|
+
const moduleProblems: string[] = []
|
|
64
|
+
for (const module of works ? modules() : []) {
|
|
65
|
+
if (result.block) break
|
|
66
|
+
let left: ReturnType<NonNullable<typeof module.unfinished>>
|
|
67
|
+
try {
|
|
68
|
+
left = module.unfinished?.(repo, input.sessionId, blocked, input.named === true)
|
|
69
|
+
} catch (error) {
|
|
70
|
+
// 一个模块出错不挡别的检查,但要让人看得到
|
|
71
|
+
moduleProblems.push(`testpace:停止门里"${module.name}"这一项检查出错,这次没查它(${(error as Error).message.split('\n')[0]})。`)
|
|
72
|
+
continue
|
|
73
|
+
}
|
|
74
|
+
if (!left) continue
|
|
75
|
+
blocked.push(...left.keys)
|
|
76
|
+
result.block = left.text
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// 没经过合并门的落地:默认分支在这个会话里有了新提交,却没有整组通过记录
|
|
80
|
+
const warned = [...session.warned]
|
|
81
|
+
const warns: string[] = [...moduleProblems]
|
|
82
|
+
for (const [ref, commit] of Object.entries(defaultTips(repo))) {
|
|
83
|
+
if (commit === session.tipsAtStart[ref] || warned.includes(commit)) continue
|
|
84
|
+
const tip = refTip(repo.root, ref)
|
|
85
|
+
if (!tip) continue
|
|
86
|
+
// 和合并门一样:会话开始时它指向的代码或现在的代码里有 testpace.json 才管
|
|
87
|
+
const contract = contractAt(repo.root, tip.commit)
|
|
88
|
+
const start = session.tipsAtStart[ref]
|
|
89
|
+
if (!contract && !(start && hasFile(repo.root, start, CONTRACT_FILE))) continue
|
|
90
|
+
// ignore 按会话开始时默认分支上那份认(和合并门一样:新加的规则落地以后才生效)
|
|
91
|
+
if (coverageOf(repo, effectiveIgnore(contract, start ? contractAt(repo.root, start) : undefined), tip.tree).kind !== 'none') continue
|
|
92
|
+
warned.push(commit)
|
|
93
|
+
const name = ref.replace(/^refs\/(heads|remotes)\//, '')
|
|
94
|
+
const how = ref.startsWith('refs/heads/') ? '可能不是 agent 提交的(合并门只管 agent 的命令),或者合并门没装上' : '可能是推送了别的分支到默认分支,或者在 GitHub 上合并了 PR'
|
|
95
|
+
warns.push(`testpace:${input.named ? `${repo.root} 的 ` : ''}${name} 的最新提交 ${short(commit)} 没有整组通过记录(${how})。`)
|
|
96
|
+
}
|
|
97
|
+
if (warns.length > 0) result.warn = warns.join('\n')
|
|
98
|
+
if (warns.length > 0 || result.block) repo.store.saveSession(input.sessionId, { ...session, warned, blocked })
|
|
99
|
+
return result
|
|
100
|
+
}
|
|
@@ -0,0 +1,348 @@
|
|
|
1
|
+
// 结果记录:放在仓库共用的 .git/testpace/ 下,不进版本库,也不影响工作区内容哈希。
|
|
2
|
+
// runs.jsonl 每次运行一行,只追加
|
|
3
|
+
// running/ 每个工作区正在跑的命令(或借用工作区的工具,见 testpace hold)一份,结束时删掉;等着用整组结果的会话另记一份
|
|
4
|
+
// logs/ 每次运行的完整输出
|
|
5
|
+
// flaky/ 时好时坏的测试的名单,一个测试一份(所有工作区共用)
|
|
6
|
+
// rounds/ 每个工作区里各测试连着几轮没过
|
|
7
|
+
|
|
8
|
+
import { createHash } from 'node:crypto'
|
|
9
|
+
import { appendFileSync, existsSync, linkSync, mkdirSync, readdirSync, readFileSync, renameSync, rmSync, writeFileSync } from 'node:fs'
|
|
10
|
+
import { join } from 'node:path'
|
|
11
|
+
import type { AgentKind } from './agent.ts'
|
|
12
|
+
|
|
13
|
+
export type RunResult = 'pass' | 'fail'
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* 一次运行的记录。这里是底座认的字段;模块跑的命令可以带自己的字段(见各模块自己的记录类型),底座原样存取。
|
|
17
|
+
* kind 是跑的什么:整组是 full,别的由模块定。
|
|
18
|
+
*/
|
|
19
|
+
export interface RunRecord {
|
|
20
|
+
id: string
|
|
21
|
+
kind: string
|
|
22
|
+
worktree: string
|
|
23
|
+
branch?: string
|
|
24
|
+
head?: string
|
|
25
|
+
/** 开始跑时工作区完整内容的哈希(git 树 id)。 */
|
|
26
|
+
tree: string
|
|
27
|
+
/** 跑完时的哈希;和 tree 不同说明跑的过程中代码改过,这次结果不能当通过记录。 */
|
|
28
|
+
treeAtEnd: string
|
|
29
|
+
startedAt: number
|
|
30
|
+
durationMs: number
|
|
31
|
+
exitCode: number | null
|
|
32
|
+
result: RunResult
|
|
33
|
+
/** 起这次整组的 agent 会话;用户在终端里起的、或 agent 没给会话号的没有。 */
|
|
34
|
+
session?: string
|
|
35
|
+
/** 跑这次的 agent;用户在终端里跑的没有。旧版本写的记录也没有。 */
|
|
36
|
+
agent?: AgentKind
|
|
37
|
+
/** 跑这次的 testpace 版本。旧版本写的记录没有。 */
|
|
38
|
+
version?: string
|
|
39
|
+
/** 想跑整组时发现它已经在跑、等着用它结果的其他会话。 */
|
|
40
|
+
waiting?: string[]
|
|
41
|
+
/** 整组各段的耗时,按跑的顺序;一段没过,后面的没有跑,就没有。旧版本写的记录没有。 */
|
|
42
|
+
steps?: RunStep[]
|
|
43
|
+
log: string
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** 整组的一段:模块交的(kind、name 由模块定,见 module.ts 的 FullStep)。name 是耗时报告里的名字,旧版本写的记录没有。 */
|
|
47
|
+
export interface RunStep {
|
|
48
|
+
kind: string
|
|
49
|
+
name?: string
|
|
50
|
+
durationMs: number
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/** testpace 跑项目命令时占着工作区的登记。 */
|
|
54
|
+
export interface RunMarker {
|
|
55
|
+
id: string
|
|
56
|
+
/** 跑的什么:整组是 full,别的由模块定。不会是 hold。 */
|
|
57
|
+
kind: string
|
|
58
|
+
/** testpace 进程。 */
|
|
59
|
+
pid: number
|
|
60
|
+
/** 测试命令的进程组:testpace 被强杀后测试可能还在跑,看它才知道这个工作区是不是真的空出来了。 */
|
|
61
|
+
group?: number
|
|
62
|
+
worktree: string
|
|
63
|
+
tree: string
|
|
64
|
+
startedAt: number
|
|
65
|
+
/** 同 RunRecord.session。 */
|
|
66
|
+
session?: string
|
|
67
|
+
log: string
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/** 别的工具借用工作区时的登记(testpace hold),比如 testcraft 建副本:占着时不跑测试。 */
|
|
71
|
+
export interface HoldMarker {
|
|
72
|
+
id: string
|
|
73
|
+
kind: 'hold'
|
|
74
|
+
/** 谁、为什么占着,比如"testcraft 建副本"。 */
|
|
75
|
+
by: string
|
|
76
|
+
/** 借用工作区的那个进程:它不在了,占用就作废。 */
|
|
77
|
+
pid: number
|
|
78
|
+
worktree: string
|
|
79
|
+
startedAt: number
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export type RunningMarker = RunMarker | HoldMarker
|
|
83
|
+
|
|
84
|
+
/** 这份登记是借用工作区的(testpace hold),不是在跑命令。 */
|
|
85
|
+
export function isHold(marker: RunningMarker): marker is HoldMarker {
|
|
86
|
+
return marker.kind === 'hold'
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export interface SessionState {
|
|
90
|
+
startedAt: number
|
|
91
|
+
/** 会话开始时本地和远程默认分支(引用 → 提交):之后变了才检查落地的代码有没有整组通过记录。 */
|
|
92
|
+
tipsAtStart: Record<string, string>
|
|
93
|
+
/** 已经提示过的、没有整组通过记录的默认分支提交。 */
|
|
94
|
+
warned: string[]
|
|
95
|
+
/** 已经给这个会话说过这个仓库的测试节奏。 */
|
|
96
|
+
rhythm?: boolean
|
|
97
|
+
/** 这个会话在各工作区最近一次看到整组结果的时间(跑了 testpace status,或在前台等到了 testpace full)。 */
|
|
98
|
+
read?: Record<string, number>
|
|
99
|
+
/**
|
|
100
|
+
* 这个会话在哪些工作区干活:会话所在目录的工作区,和用改文件的工具(Claude Code 的 Edit、Write、MultiEdit,Codex 的 apply_patch)改过文件的工作区。停止门只为这些工作区问各模块还有什么没处理完(stop.ts);
|
|
101
|
+
* 只在命令里 cd 进去看过的工作区不算,那里后来的改动是别的会话的。
|
|
102
|
+
*/
|
|
103
|
+
worked?: string[]
|
|
104
|
+
/** 停止门拦过的:running:<运行 id>(还在跑时拦过)、unread:<运行 id>(跑完没看结果时拦过)、flaky:<testKey>(认出的时好时坏测试)。每种只拦一次。 */
|
|
105
|
+
blocked?: string[]
|
|
106
|
+
/** 执行命令之前只能拒绝、不能只加一句话的 agent(Antigravity):为了说这几段提示已经拦过一次命令,同样的不再拦(hook.ts)。 */
|
|
107
|
+
refused?: string[]
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/** 会话记录留多久。 */
|
|
111
|
+
export const SESSION_KEEP_MS = 7 * 24 * 3600 * 1000
|
|
112
|
+
|
|
113
|
+
/** 按工作区存的文件用它当文件名。 */
|
|
114
|
+
export function worktreeKey(worktree: string): string {
|
|
115
|
+
return createHash('sha1').update(worktree).digest('hex').slice(0, 16)
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/** 日志文件名以开始时间开头,按名字排序就是按时间排序。 */
|
|
119
|
+
export const KEEP_LOGS = 200
|
|
120
|
+
|
|
121
|
+
export class Store {
|
|
122
|
+
readonly dir: string
|
|
123
|
+
|
|
124
|
+
constructor(gitCommonDir: string) {
|
|
125
|
+
this.dir = join(gitCommonDir, 'testpace')
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
private get runsFile(): string {
|
|
129
|
+
return join(this.dir, 'runs.jsonl')
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
private get runningDir(): string {
|
|
133
|
+
return join(this.dir, 'running')
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/** 新一次运行的日志路径。只留最近 KEEP_LOGS 份,更早的删掉;runs.jsonl 里的记录不删。 */
|
|
137
|
+
logPath(id: string): string {
|
|
138
|
+
const dir = join(this.dir, 'logs')
|
|
139
|
+
mkdirSync(dir, { recursive: true })
|
|
140
|
+
const logs = readdirSync(dir).filter(name => name.endsWith('.log')).sort()
|
|
141
|
+
for (const name of logs.slice(0, Math.max(0, logs.length - (KEEP_LOGS - 1)))) rmSync(join(dir, name), { force: true })
|
|
142
|
+
return join(dir, `${id}.log`)
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
appendRun(record: RunRecord): void {
|
|
146
|
+
mkdirSync(this.dir, { recursive: true })
|
|
147
|
+
appendFileSync(this.runsFile, `${JSON.stringify(record)}\n`)
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
readRuns(): RunRecord[] {
|
|
151
|
+
if (!existsSync(this.runsFile)) return []
|
|
152
|
+
const runs: RunRecord[] = []
|
|
153
|
+
for (const line of readFileSync(this.runsFile, 'utf8').split('\n')) {
|
|
154
|
+
if (!line.trim()) continue
|
|
155
|
+
try {
|
|
156
|
+
runs.push(JSON.parse(line) as RunRecord)
|
|
157
|
+
} catch {
|
|
158
|
+
// 写到一半的行(进程被杀)跳过
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
return runs
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
private markerPath(worktree: string): string {
|
|
165
|
+
return join(this.runningDir, `${worktreeKey(worktree)}.json`)
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* 占住这个工作区来跑 marker 这次命令:原子地创建这个工作区唯一的一份登记。
|
|
170
|
+
* 已经有在跑的,返回它,不占;登记的进程都不在了的(被强杀、机器重启)清掉再占。
|
|
171
|
+
*/
|
|
172
|
+
claim(marker: RunningMarker): RunningMarker | undefined {
|
|
173
|
+
mkdirSync(this.runningDir, { recursive: true })
|
|
174
|
+
const path = this.markerPath(marker.worktree)
|
|
175
|
+
// 先写好一份完整的,再用 link 原子地放到位:别人看到的登记总是完整的,不会把写了一半的当成坏了清掉
|
|
176
|
+
const ready = tempPath(path)
|
|
177
|
+
writeFileSync(ready, JSON.stringify(marker))
|
|
178
|
+
try {
|
|
179
|
+
for (;;) {
|
|
180
|
+
try {
|
|
181
|
+
linkSync(ready, path)
|
|
182
|
+
return undefined
|
|
183
|
+
} catch (error) {
|
|
184
|
+
if ((error as NodeJS.ErrnoException).code !== 'EEXIST') throw error
|
|
185
|
+
}
|
|
186
|
+
const existing = readMarker(path)
|
|
187
|
+
if (existing && markerAlive(existing)) return existing
|
|
188
|
+
// 清掉过期的登记:先改名挪开再核对,挪走的要是别人刚占上的,放回去
|
|
189
|
+
const moved = tempPath(path)
|
|
190
|
+
try {
|
|
191
|
+
renameSync(path, moved)
|
|
192
|
+
} catch {
|
|
193
|
+
continue
|
|
194
|
+
}
|
|
195
|
+
const taken = readMarker(moved)
|
|
196
|
+
if (taken && markerAlive(taken)) {
|
|
197
|
+
try {
|
|
198
|
+
linkSync(moved, path)
|
|
199
|
+
} catch {
|
|
200
|
+
// 又有别人占上了,下一轮看它
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
rmSync(moved, { force: true })
|
|
204
|
+
}
|
|
205
|
+
} finally {
|
|
206
|
+
rmSync(ready, { force: true })
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
/** 更新自己占着的登记(比如记下测试的进程组)。整份换掉,别人读不到写了一半的。 */
|
|
211
|
+
update(worktree: string, id: string, change: Partial<RunMarker>): void {
|
|
212
|
+
const path = this.markerPath(worktree)
|
|
213
|
+
const marker = readMarker(path)
|
|
214
|
+
if (marker?.id !== id) return
|
|
215
|
+
writeWhole(path, JSON.stringify({ ...marker, ...change }))
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
/** 放开这个工作区,返回等着用这次结果的会话。 */
|
|
219
|
+
release(worktree: string, id: string): string[] {
|
|
220
|
+
const path = this.markerPath(worktree)
|
|
221
|
+
// 先把等待名单整个挪走再放开工作区:放开之后下一次运行的等待记录写进新的名单,不会被这里删掉
|
|
222
|
+
const waitingPath = this.waitingPath(worktree)
|
|
223
|
+
const taken = tempPath(waitingPath)
|
|
224
|
+
let lines: string[] = []
|
|
225
|
+
try {
|
|
226
|
+
renameSync(waitingPath, taken)
|
|
227
|
+
lines = readFileSync(taken, 'utf8').split('\n')
|
|
228
|
+
rmSync(taken, { force: true })
|
|
229
|
+
} catch {
|
|
230
|
+
// 没有人等
|
|
231
|
+
}
|
|
232
|
+
if (readMarker(path)?.id === id) rmSync(path, { force: true })
|
|
233
|
+
const sessions = lines.filter(line => line.startsWith(`${id} `)).map(line => line.slice(id.length + 1))
|
|
234
|
+
return [...new Set(sessions)]
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
/** 记下这个会话在等这个工作区正在跑的那次结果(只追加一行,不改登记)。 */
|
|
238
|
+
waitOn(marker: RunMarker, session: string): void {
|
|
239
|
+
if (marker.session === session) return
|
|
240
|
+
appendFileSync(this.waitingPath(marker.worktree), `${marker.id} ${session}\n`)
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
private waitingPath(worktree: string): string {
|
|
244
|
+
return join(this.runningDir, `${worktreeKey(worktree)}.waiting`)
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
/** 正在等这次运行结果的会话。 */
|
|
248
|
+
waiting(marker: RunningMarker): string[] {
|
|
249
|
+
const path = this.waitingPath(marker.worktree)
|
|
250
|
+
if (!existsSync(path)) return []
|
|
251
|
+
return readFileSync(path, 'utf8')
|
|
252
|
+
.split('\n')
|
|
253
|
+
.filter(line => line.startsWith(`${marker.id} `))
|
|
254
|
+
.map(line => line.slice(marker.id.length + 1))
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
/** 这个会话看到了这个工作区的整组结果。 */
|
|
258
|
+
markRead(id: string, worktree: string, at: number, tips: () => Record<string, string>): void {
|
|
259
|
+
const state = this.session(id, at, tips)
|
|
260
|
+
this.saveSession(id, { ...state, read: { ...state.read, [worktree]: at } })
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
/** 会话第一次被 testpace 看到时的状态。第一次读时记下现在和 tips() 给的默认分支最新提交。 */
|
|
264
|
+
session(id: string, now: number, tips: () => Record<string, string> = () => ({})): SessionState {
|
|
265
|
+
const dir = join(this.dir, 'sessions')
|
|
266
|
+
const path = join(dir, `${id.replace(/[^\w.-]/g, '_')}.json`)
|
|
267
|
+
if (existsSync(path)) {
|
|
268
|
+
try {
|
|
269
|
+
const state = JSON.parse(readFileSync(path, 'utf8')) as SessionState
|
|
270
|
+
// 写坏了、或是旧版本的格式,就重新开始
|
|
271
|
+
if (typeof state.tipsAtStart === 'object' && state.tipsAtStart !== null && Array.isArray(state.warned)) return state
|
|
272
|
+
} catch {
|
|
273
|
+
// 同上
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
mkdirSync(dir, { recursive: true })
|
|
277
|
+
// 只看 .json:别的进程正在写的临时文件不碰
|
|
278
|
+
for (const name of readdirSync(dir).filter(name => name.endsWith('.json'))) {
|
|
279
|
+
const file = join(dir, name)
|
|
280
|
+
try {
|
|
281
|
+
if (now - (JSON.parse(readFileSync(file, 'utf8')) as SessionState).startedAt > SESSION_KEEP_MS) rmSync(file, { force: true })
|
|
282
|
+
} catch {
|
|
283
|
+
rmSync(file, { force: true })
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
const state: SessionState = { startedAt: now, tipsAtStart: tips(), warned: [] }
|
|
287
|
+
writeWhole(path, JSON.stringify(state))
|
|
288
|
+
return state
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
saveSession(id: string, state: SessionState): void {
|
|
292
|
+
const dir = join(this.dir, 'sessions')
|
|
293
|
+
mkdirSync(dir, { recursive: true })
|
|
294
|
+
writeWhole(join(dir, `${id.replace(/[^\w.-]/g, '_')}.json`), JSON.stringify(state))
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
/** 各工作区正在跑的命令。进程都不在了的登记不算,留给下一次 claim 清掉。 */
|
|
298
|
+
running(): RunningMarker[] {
|
|
299
|
+
if (!existsSync(this.runningDir)) return []
|
|
300
|
+
return readdirSync(this.runningDir)
|
|
301
|
+
.filter(name => name.endsWith('.json'))
|
|
302
|
+
.map(name => readMarker(join(this.runningDir, name)))
|
|
303
|
+
.filter((marker): marker is RunningMarker => marker !== undefined && markerAlive(marker))
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
/** 和 path 同目录、不会撞名的临时文件名(同目录才能原子地 rename、link)。 */
|
|
308
|
+
function tempPath(path: string): string {
|
|
309
|
+
return `${path}.${process.pid}.${Math.random().toString(36).slice(2)}.tmp`
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
/**
|
|
313
|
+
* 整份换掉一个文件:先写到同目录的临时文件再改名。同一会话的几个 hook 会同时读写这些状态文件,
|
|
314
|
+
* 直接覆盖写时别人可能读到写了一半的,当成坏了重新开始。
|
|
315
|
+
*/
|
|
316
|
+
export function writeWhole(path: string, text: string): void {
|
|
317
|
+
const next = tempPath(path)
|
|
318
|
+
writeFileSync(next, text)
|
|
319
|
+
renameSync(next, path)
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
function readMarker(path: string): RunningMarker | undefined {
|
|
323
|
+
try {
|
|
324
|
+
return JSON.parse(readFileSync(path, 'utf8')) as RunningMarker
|
|
325
|
+
} catch {
|
|
326
|
+
return undefined
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
/** 登记的进程(testpace、借用工作区的进程)或测试的进程组还有一个在。 */
|
|
331
|
+
function markerAlive(marker: RunningMarker): boolean {
|
|
332
|
+
return processAlive(marker.pid) || (!isHold(marker) && marker.group !== undefined && processAlive(-marker.group))
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
/** 进程(pid 为负时是进程组)还在。 */
|
|
336
|
+
export function processAlive(pid: number): boolean {
|
|
337
|
+
try {
|
|
338
|
+
process.kill(pid, 0)
|
|
339
|
+
return true
|
|
340
|
+
} catch (error) {
|
|
341
|
+
return (error as NodeJS.ErrnoException).code === 'EPERM'
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
export function newRunId(now: number): string {
|
|
346
|
+
const stamp = new Date(now).toISOString().replace(/[-:]/g, '').replace(/\.\d+Z$/, 'Z')
|
|
347
|
+
return `${stamp}-${process.pid}-${Math.random().toString(36).slice(2, 6)}`
|
|
348
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// 插件自己的名字和版本:取 Claude Code 的插件清单(Codex、Antigravity 的清单和它一起改,测试核对几份一致)。
|
|
2
|
+
|
|
3
|
+
import { readFileSync } from 'node:fs'
|
|
4
|
+
|
|
5
|
+
const manifest = JSON.parse(readFileSync(new URL('../../.claude-plugin/plugin.json', import.meta.url), 'utf8')) as { name: string; version: string }
|
|
6
|
+
|
|
7
|
+
export const VERSION: string = manifest.version
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* 插件的名字。说给 agent 的话里提到插件时用它;确认工具的全名里也有它(.mcp.json 里服务的名字,测试核对和它一样)。
|
|
11
|
+
* 三条命令(testpace、testcraft、modwall)不跟它走。
|
|
12
|
+
*/
|
|
13
|
+
export const PLUGIN_NAME: string = manifest.name
|
|
14
|
+
|
|
15
|
+
/** 比较两个 x.y.z 版本号:a 新返回正数,旧返回负数,一样返回 0。 */
|
|
16
|
+
export function compareVersions(a: string, b: string): number {
|
|
17
|
+
const pa = a.split('.').map(Number)
|
|
18
|
+
const pb = b.split('.').map(Number)
|
|
19
|
+
for (let i = 0; i < Math.max(pa.length, pb.length); i++) {
|
|
20
|
+
const diff = (pa[i] ?? 0) - (pb[i] ?? 0)
|
|
21
|
+
if (diff !== 0) return diff
|
|
22
|
+
}
|
|
23
|
+
return 0
|
|
24
|
+
}
|
package/src/cli.ts
ADDED
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
// testpace 命令行入口:focused、files、full、status、hold、release、report、verify、install、run,以及 git 钩子调用的 gate。
|
|
2
|
+
// 这里只做装配和分发:底座的命令在 base/commands.ts、base/full.ts,"跑测试"的命令在 pace/commands.ts;
|
|
3
|
+
// status 把底座和各模块的情况合在一起说,也放在这里。这个文件的路径不能变:bin/testpace 和固定入口都按它找。
|
|
4
|
+
|
|
5
|
+
import './modules.ts'
|
|
6
|
+
import { AGENT, runCommandLine } from './base/commandline.ts'
|
|
7
|
+
import { context, gate, hold, install, release } from './base/commands.ts'
|
|
8
|
+
import { CONTRACT_FILE, joined } from './base/contract.ts'
|
|
9
|
+
import { ENTRY_COMMANDS, type EntryState, entryDir, entryState } from './base/entry.ts'
|
|
10
|
+
import { EXIT } from './base/exit.ts'
|
|
11
|
+
import { duration, short, when } from './base/format.ts'
|
|
12
|
+
import { full } from './base/full.ts'
|
|
13
|
+
import { danglingNote, gateProblem } from './base/gate.ts'
|
|
14
|
+
import { workTreeId } from './base/git.ts'
|
|
15
|
+
import { coverageOf, defaultTips, describeCoverage, runningText, started } from './base/repo.ts'
|
|
16
|
+
import { isHold } from './base/store.ts'
|
|
17
|
+
import { files, focused, report, run, verify } from './pace/commands.ts'
|
|
18
|
+
import { commandExists, COMMAND_KEYS, loadConfig } from './pace/config.ts'
|
|
19
|
+
import { LAYERMAP_HINT } from './pace/focused.ts'
|
|
20
|
+
import { flakyStatus } from './pace/results.ts'
|
|
21
|
+
import { nodeTest } from './pace/run/node-test.ts'
|
|
22
|
+
import { playwright } from './pace/run/playwright.ts'
|
|
23
|
+
import { vitest } from './pace/run/vitest.ts'
|
|
24
|
+
import { flakyTests } from './pace/testlist.ts'
|
|
25
|
+
import { findTests } from './pace/tests.ts'
|
|
26
|
+
|
|
27
|
+
const USAGE = `用法:
|
|
28
|
+
testpace focused [--base REF] 改完先跑:fast,再跑 layermap 选出的相关测试。默认对比和默认分支的分叉点;在默认分支上选测靠不住时建议跑整组
|
|
29
|
+
testpace files [--repeat N] PATH[:行号]...
|
|
30
|
+
只跑给定的测试文件(testpace.json 的 files);文件:行号 只跑那一行的测试,比如重跑失败的测试。
|
|
31
|
+
--repeat N 连跑 N 次、没过就停:造出时好时坏的测试的失败,或修好后连跑 3 次证明
|
|
32
|
+
testpace full 跑整组:接入了的检查(modwall check、testcraft checklist)、full(测试以外的检查),再把 tests 规则找到的全部测试交给 files,
|
|
33
|
+
一段没过就停,按当前工作区完整内容记录结果。要跑几分钟,能放到后台的就放后台
|
|
34
|
+
testpace status 当前代码有没有整组通过记录、有没有正在跑的整组、最近一次结果、配置检查
|
|
35
|
+
testpace hold PID 说明 借用这个工作区(比如要复制一份工作区的工具):占着时别的 testpace 命令不跑,说明是谁占着。
|
|
36
|
+
PID 是借用的那个进程,它不在了占用就作废。占上时输出这次的 id,退出码 0;有在跑的、占着的,说明是谁,退出码 3。
|
|
37
|
+
整组里要建副本的检查带着这一轮的 TESTPACE_RUN,工作区已经是这一轮的,不另占、什么也不输出,退出码 0
|
|
38
|
+
testpace release ID 放开 hold 占的工作区
|
|
39
|
+
testpace report [--days N] 计时诊断,默认最近 28 天
|
|
40
|
+
testpace verify [测试文件...] 核对接入守不守约定:三条命令找得到、合并门在把关、files 对不存在的文件报失败、认 文件:行号;每种测试各给一个文件
|
|
41
|
+
testpace install 这台机器配一次:在全局 git 配置里配上合并门(agent 移动默认分支时,要求落地的代码有整组通过记录),
|
|
42
|
+
并在 ~/.local/bin 放上 testpace、modwall、testcraft 的固定命令入口(Codex 的命令和合并门的钩子靠它们找到这几条命令)
|
|
43
|
+
${nodeTest.usage}
|
|
44
|
+
${vitest.usage}
|
|
45
|
+
${playwright.usage}
|
|
46
|
+
写在 testpace.json 的 files 里(或项目的 files 脚本里):用项目的测试框架跑测试文件,守 files 的约定:
|
|
47
|
+
文件不存在、给的文件或行上一个测试都没跑到时失败,选中的测试全被跳过时说一句。
|
|
48
|
+
node:test 不能按行跑,按行给的整个文件跑,跑完照样核对那一行`
|
|
49
|
+
|
|
50
|
+
function status(): number {
|
|
51
|
+
const ctx = context()
|
|
52
|
+
if (!ctx) return EXIT.usage
|
|
53
|
+
const lines: string[] = []
|
|
54
|
+
const { config, problems } = loadConfig(ctx.root)
|
|
55
|
+
|
|
56
|
+
if (config) {
|
|
57
|
+
const tree = workTreeId(ctx.root)
|
|
58
|
+
const runs = ctx.store.readRuns()
|
|
59
|
+
lines.push(`当前代码(${short(tree)}):${describeCoverage(coverageOf(ctx, config.ignore, tree, runs))}`)
|
|
60
|
+
|
|
61
|
+
for (const marker of ctx.store.running().filter(m => m.worktree === ctx.root)) {
|
|
62
|
+
if (isHold(marker)) {
|
|
63
|
+
lines.push(`${runningText(marker)},已 ${duration(Date.now() - marker.startedAt)}`)
|
|
64
|
+
continue
|
|
65
|
+
}
|
|
66
|
+
const changed = marker.tree === tree ? '开始后代码没改过' : '开始后代码改过,跑完的结果不算当前代码的记录'
|
|
67
|
+
lines.push(`正在跑:${marker.kind},${started(marker)}(已 ${duration(Date.now() - marker.startedAt)}),${changed}`)
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const last = runs.filter(run => run.kind === 'full' && run.worktree === ctx.root).sort((a, b) => b.startedAt - a.startedAt)[0]
|
|
71
|
+
if (last) {
|
|
72
|
+
const outcome = last.result === 'pass' ? '通过' : '失败'
|
|
73
|
+
const changed = last.result === 'pass' && last.tree !== last.treeAtEnd ? ',但跑的过程中代码改过' : ''
|
|
74
|
+
const current = last.tree === tree ? '是当前代码' : '不是当前代码'
|
|
75
|
+
lines.push(`最近一次整组:${outcome}${changed}(${when(last.startedAt)},用时 ${duration(last.durationMs)},${current})`)
|
|
76
|
+
if (last.result === 'fail') lines.push(` 日志:${last.log}`)
|
|
77
|
+
} else {
|
|
78
|
+
lines.push('最近一次整组:这个工作区还没用 testpace 跑过')
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
lines.push(...flakyStatus(flakyTests(ctx.store)))
|
|
83
|
+
lines.push(`配置(${CONTRACT_FILE}):${problems.length ? problems.join(';') : '正常'}`)
|
|
84
|
+
if (config) {
|
|
85
|
+
for (const key of COMMAND_KEYS) {
|
|
86
|
+
const command = config[key]
|
|
87
|
+
if (!command) continue
|
|
88
|
+
lines.push(` ${key}: ${command}${commandExists(ctx.root, command) ? '' : ' ← 找不到这个命令'}`)
|
|
89
|
+
}
|
|
90
|
+
if (config.tests.length) {
|
|
91
|
+
const found = findTests(ctx.root, config.tests).length
|
|
92
|
+
lines.push(` tests: ${config.tests.join(', ')} → 找到 ${found} 个测试文件,整组时全部交给 files${found ? '' : ' ← 一个都没找到'}`)
|
|
93
|
+
}
|
|
94
|
+
if (config.ignore.length) lines.push(` ignore: ${config.ignore.join(', ')}`)
|
|
95
|
+
if (config.deferredIgnore?.length) lines.push(` ignore 里新加的 ${config.deferredIgnore.join(', ')} 合并后才生效,这次改动仍按没有它判`)
|
|
96
|
+
}
|
|
97
|
+
// 合并门看提交里的 testpace.json,工作区里这份写坏了它也照常把关
|
|
98
|
+
if (joined(ctx.root)) lines.push(`合并门:${gateProblem(ctx.root) ?? '已装上,agent 移动默认分支时检查'}`)
|
|
99
|
+
const dangling = joined(ctx.root) ? danglingNote(ctx.root) : undefined
|
|
100
|
+
if (dangling) lines.push(` ${dangling}`)
|
|
101
|
+
lines.push(`固定命令入口(${entryDir()}):${entryLine()}`)
|
|
102
|
+
// 版本太旧不在这里查:focused 读输出时会说
|
|
103
|
+
lines.push(`layermap:${commandExists(ctx.root, 'layermap') ? '找到' : `找不到,focused 没法按改动选测试,每次都会建议跑整组。${LAYERMAP_HINT}`}`)
|
|
104
|
+
|
|
105
|
+
console.log(lines.join('\n'))
|
|
106
|
+
// 停止门据此判断这个会话有没有看过整组的结果;不在 agent 里(没有会话号)不记
|
|
107
|
+
const sessionId = AGENT?.session
|
|
108
|
+
if (sessionId) ctx.store.markRead(sessionId, ctx.root, Date.now(), () => defaultTips(ctx))
|
|
109
|
+
return config ? EXIT.ok : EXIT.usage
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
const ENTRY_STATES = {
|
|
113
|
+
installed: '已放好',
|
|
114
|
+
newer: '是更新的版本放的(别的 agent 里装的插件更新),照常用',
|
|
115
|
+
outdated: '是旧版本放的,跑 testpace install 更新',
|
|
116
|
+
missing: '没放:插件的 bin 目录不在 PATH 上的地方(Codex 的命令、合并门的钩子)找不到。用户同意后跑 testpace install 放上',
|
|
117
|
+
foreign: '那里是别的文件,没有放',
|
|
118
|
+
} as const
|
|
119
|
+
|
|
120
|
+
/** 各条命令的固定入口放得怎样,状态一样的并在一起说:testpace 已放好;modwall、testcraft 没放:…… */
|
|
121
|
+
function entryLine(): string {
|
|
122
|
+
const states = Object.keys(ENTRY_STATES) as EntryState[]
|
|
123
|
+
return states
|
|
124
|
+
.map(state => ({ state, commands: ENTRY_COMMANDS.filter(command => entryState(command) === state) }))
|
|
125
|
+
.filter(({ commands }) => commands.length > 0)
|
|
126
|
+
.map(({ state, commands }) => `${commands.join('、')} ${ENTRY_STATES[state]}`)
|
|
127
|
+
.join(';')
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* 在 agent 的沙箱里不跑的子命令:跑项目命令的,和记下会话看过结果的 status(写不进 .git 时停止门还会再拦)。
|
|
132
|
+
* 测试在沙箱里会因为端口、网络被拒跑出假失败,记进去后 report 会当成测试不稳定。
|
|
133
|
+
* gate 不在里面:它由 git 钩子调用,在这里拒绝不是检查结论,钩子会当成没检查而放行。
|
|
134
|
+
*/
|
|
135
|
+
const OUTSIDE_SANDBOX = new Set(['focused', 'files', 'full', 'verify', 'status'])
|
|
136
|
+
|
|
137
|
+
/** 整组:底座编排,起它的 agent 会话记进记录(停止门只拦起它的会话和等着用它结果的会话)。 */
|
|
138
|
+
async function runFull(): Promise<number> {
|
|
139
|
+
const ctx = context()
|
|
140
|
+
return ctx ? full(ctx, AGENT?.session) : EXIT.usage
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
async function dispatch([command, ...rest]: string[]): Promise<number> {
|
|
144
|
+
switch (command) {
|
|
145
|
+
case 'focused':
|
|
146
|
+
return focused(rest, USAGE)
|
|
147
|
+
case 'files':
|
|
148
|
+
return files(rest, USAGE)
|
|
149
|
+
case 'full':
|
|
150
|
+
return runFull()
|
|
151
|
+
case 'status':
|
|
152
|
+
return status()
|
|
153
|
+
case 'hold':
|
|
154
|
+
return hold(rest, USAGE)
|
|
155
|
+
case 'release':
|
|
156
|
+
return release(rest, USAGE)
|
|
157
|
+
case 'report':
|
|
158
|
+
return report(rest)
|
|
159
|
+
case 'verify':
|
|
160
|
+
return verify(rest)
|
|
161
|
+
case 'install':
|
|
162
|
+
return install()
|
|
163
|
+
case 'gate':
|
|
164
|
+
return gate()
|
|
165
|
+
case 'run':
|
|
166
|
+
return run(rest)
|
|
167
|
+
case undefined:
|
|
168
|
+
case '-h':
|
|
169
|
+
case '--help':
|
|
170
|
+
case 'help':
|
|
171
|
+
console.log(USAGE)
|
|
172
|
+
return command === undefined ? EXIT.usage : EXIT.ok
|
|
173
|
+
default:
|
|
174
|
+
console.error(`不认识的命令 "${command}"\n${USAGE}`)
|
|
175
|
+
return EXIT.usage
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
process.exitCode = await runCommandLine(
|
|
180
|
+
{
|
|
181
|
+
name: 'testpace',
|
|
182
|
+
outside: ([command]) => (command && OUTSIDE_SANDBOX.has(command) ? '写 .git/testpace/ 的记录,测试还常要开端口和网络' : undefined),
|
|
183
|
+
run: dispatch,
|
|
184
|
+
},
|
|
185
|
+
process.argv.slice(2),
|
|
186
|
+
)
|