@boyingliu01/xp-gate 0.21.0 → 0.22.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/adapters/gate-9.sh +142 -60
- package/bin/xp-gate.js +2 -2
- package/gate-9.sh +142 -59
- package/hooks/gate-9.sh +142 -59
- package/hooks/lib/coverage-total.sh +72 -0
- package/hooks/pre-commit +88 -27
- package/hooks/pre-push +32 -0
- package/lib/__tests__/arch.test.js +403 -0
- package/lib/__tests__/doctor-469-hook-env.test.js +200 -0
- package/lib/arch.js +336 -49
- package/lib/doctor.js +319 -13
- package/lib/mattpocock-license-verdict.json +1 -1
- package/package.json +1 -1
- package/plugins/dsh/src/command.test.ts +14 -2
- package/plugins/dsh/src/command.ts +8 -1
- package/plugins/dsh/src/index.test.ts +43 -26
- package/plugins/dsh/src/index.ts +164 -138
- package/plugins/opencode/README.md +5 -2
- package/plugins/opencode/index.ts +215 -164
package/plugins/dsh/src/index.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { defineTool } from "@deepseek-ai/dsh-tools"
|
|
2
2
|
import type { Context } from "@deepseek-ai/cordis"
|
|
3
|
+
import type { ShellDialect } from "./command.js"
|
|
3
4
|
import { GATE_WHITELIST, buildCommand, detectDialect, resolveTarget } from "./command.js"
|
|
4
5
|
import { runXpGate } from "./gate-runner.js"
|
|
5
6
|
import { DelphiSetupError, loadDelphiConfig, toDelphiOptions } from "./delphi-config.js"
|
|
@@ -9,152 +10,177 @@ export const name = "tool-xp-gate"
|
|
|
9
10
|
export const inject = ["tools", "shell"]
|
|
10
11
|
|
|
11
12
|
const DEFAULT_TIMEOUT_MS = 120_000
|
|
13
|
+
// Multi-round reviews over large inputs are slow; the transport applies its
|
|
14
|
+
// own per-request timeout on top of this ceiling.
|
|
15
|
+
const DELPHI_TIMEOUT_MS = 900_000
|
|
12
16
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
17
|
+
// Boy Scout (#447): gate-check's `gates` parameter nests one level too deep
|
|
18
|
+
// inline (parameters → gates → items), so the schema lives at module scope.
|
|
19
|
+
const GATES_PARAMETER = {
|
|
20
|
+
type: "array",
|
|
21
|
+
items: { type: "string", enum: GATE_WHITELIST },
|
|
22
|
+
description: "Optional gate subset to run (e.g. ['principles', 'arch']).",
|
|
23
|
+
} as const
|
|
18
24
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
items: { type: "string", enum: GATE_WHITELIST },
|
|
33
|
-
description: "Optional gate subset to run (e.g. ['principles', 'arch']).",
|
|
34
|
-
},
|
|
25
|
+
// Boy Scout (#447): apply() used to inline four register(defineTool({...}))
|
|
26
|
+
// blocks (149 lines, 5 brace levels). Each tool now lives in its own factory;
|
|
27
|
+
// apply() is pure wiring.
|
|
28
|
+
function gateCheckTool(shell: Context["shell"], dialect: ShellDialect) {
|
|
29
|
+
return defineTool({
|
|
30
|
+
name: "gate-check",
|
|
31
|
+
description:
|
|
32
|
+
"Run XP-Gate quality gates (xp-gate check) on a file or directory and return the gate report. Prefers the global xp-gate CLI and degrades to an actionable install hint when it is absent.",
|
|
33
|
+
parameters: {
|
|
34
|
+
path: {
|
|
35
|
+
type: "string",
|
|
36
|
+
required: true,
|
|
37
|
+
description: "File or directory path to check (absolute or relative to the workspace).",
|
|
35
38
|
},
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
},
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
|
|
39
|
+
gates: GATES_PARAMETER,
|
|
40
|
+
},
|
|
41
|
+
output: {
|
|
42
|
+
schema: { type: "string" },
|
|
43
|
+
render: (_args, value) => [{ type: "text", text: value }],
|
|
44
|
+
},
|
|
45
|
+
timeoutMs: DEFAULT_TIMEOUT_MS,
|
|
46
|
+
async execute(args, exec) {
|
|
47
|
+
const cwd = exec.agent?.session?.header?.cwd ?? process.cwd()
|
|
48
|
+
const target = resolveTarget(args.path, cwd)
|
|
49
|
+
const command = buildCommand({ subcommand: "check", target, gates: args.gates, dialect })
|
|
50
|
+
return runXpGate(shell, exec.signal, command, cwd, DEFAULT_TIMEOUT_MS)
|
|
51
|
+
},
|
|
52
|
+
})
|
|
53
|
+
}
|
|
49
54
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
},
|
|
61
|
-
},
|
|
62
|
-
output: {
|
|
63
|
-
schema: { type: "string" },
|
|
64
|
-
render: (_args, value) => [{ type: "text", text: value }],
|
|
55
|
+
function gatePrinciplesTool(shell: Context["shell"], dialect: ShellDialect) {
|
|
56
|
+
return defineTool({
|
|
57
|
+
name: "gate-principles",
|
|
58
|
+
description:
|
|
59
|
+
"Run the 14 Clean Code / SOLID rules (xp-gate principles, Gate 4) on a file or directory and return the principles report.",
|
|
60
|
+
parameters: {
|
|
61
|
+
path: {
|
|
62
|
+
type: "string",
|
|
63
|
+
required: true,
|
|
64
|
+
description: "File or directory path to check (absolute or relative to the workspace).",
|
|
65
65
|
},
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
66
|
+
},
|
|
67
|
+
output: {
|
|
68
|
+
schema: { type: "string" },
|
|
69
|
+
render: (_args, value) => [{ type: "text", text: value }],
|
|
70
|
+
},
|
|
71
|
+
timeoutMs: DEFAULT_TIMEOUT_MS,
|
|
72
|
+
async execute(args, exec) {
|
|
73
|
+
const cwd = exec.agent?.session?.header?.cwd ?? process.cwd()
|
|
74
|
+
const target = resolveTarget(args.path, cwd)
|
|
75
|
+
const command = buildCommand({ subcommand: "principles", target, dialect })
|
|
76
|
+
return runXpGate(shell, exec.signal, command, cwd, DEFAULT_TIMEOUT_MS)
|
|
77
|
+
},
|
|
78
|
+
})
|
|
79
|
+
}
|
|
75
80
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
},
|
|
87
|
-
output: {
|
|
88
|
-
schema: { type: "string" },
|
|
89
|
-
render: (_args, value) => [{ type: "text", text: value }],
|
|
81
|
+
function gateArchTool(shell: Context["shell"], dialect: ShellDialect) {
|
|
82
|
+
return defineTool({
|
|
83
|
+
name: "gate-arch",
|
|
84
|
+
description:
|
|
85
|
+
"Run architecture validation (xp-gate arch, Gate 6) with the pinned local @archlinter/cli built-in rules and baseline ratchet, and return the architecture report. Pass a config file only to opt into archlint's own --config path (pre-0.16 schemas are rejected by archlint itself).",
|
|
86
|
+
parameters: {
|
|
87
|
+
config: {
|
|
88
|
+
type: "string",
|
|
89
|
+
description:
|
|
90
|
+
"Optional architecture config file (opts into archlint --config; the default built-in-rules path needs none).",
|
|
90
91
|
},
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
92
|
+
},
|
|
93
|
+
output: {
|
|
94
|
+
schema: { type: "string" },
|
|
95
|
+
render: (_args, value) => [{ type: "text", text: value }],
|
|
96
|
+
},
|
|
97
|
+
timeoutMs: DEFAULT_TIMEOUT_MS,
|
|
98
|
+
async execute(args, exec) {
|
|
99
|
+
const cwd = exec.agent?.session?.header?.cwd ?? process.cwd()
|
|
100
|
+
const command = buildCommand({ subcommand: "arch", config: args.config, dialect })
|
|
101
|
+
return runXpGate(shell, exec.signal, command, cwd, DEFAULT_TIMEOUT_MS)
|
|
102
|
+
},
|
|
103
|
+
})
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
// Delphi multi-model cross-review.
|
|
107
|
+
//
|
|
108
|
+
// DSH's own subagents cannot do this: they inherit one host-configured model,
|
|
109
|
+
// so three "experts" would be three instances of the same model, and Delphi's
|
|
110
|
+
// value rests entirely on the reviewers being DIFFERENT models. This tool
|
|
111
|
+
// therefore calls an external OpenAI-compatible provider directly, with one
|
|
112
|
+
// distinct model per seat.
|
|
113
|
+
// Boy Scout (#447): the review body used to sit inline in execute() at 5 brace
|
|
114
|
+
// levels (defineTool → execute → try → runReview options). Module scope keeps
|
|
115
|
+
// the try/catch semantics identical while dropping two levels.
|
|
116
|
+
async function runDelphiReview(
|
|
117
|
+
subject: string,
|
|
118
|
+
addressed: string,
|
|
119
|
+
maxRounds: number | undefined,
|
|
120
|
+
cwd: string,
|
|
121
|
+
): Promise<string> {
|
|
122
|
+
try {
|
|
123
|
+
const cfg = loadDelphiConfig(cwd)
|
|
124
|
+
const outcome = await runReview(
|
|
125
|
+
{ ...toDelphiOptions(cfg), maxRounds: maxRounds ?? cfg.maxRounds },
|
|
126
|
+
subject,
|
|
127
|
+
addressed,
|
|
128
|
+
)
|
|
129
|
+
const seats = cfg.seats.map((s) => s.model).join(", ")
|
|
130
|
+
return `${formatOutcome(outcome)}\n\nProvider: ${cfg.provider}\nSeats: ${seats}`
|
|
131
|
+
} catch (e) {
|
|
132
|
+
// Config problems are the common failure; report them as guidance
|
|
133
|
+
// rather than a stack trace.
|
|
134
|
+
if (e instanceof DelphiSetupError) return `Delphi review not started: ${e.message}`
|
|
135
|
+
throw e
|
|
136
|
+
}
|
|
137
|
+
}
|
|
99
138
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
description:
|
|
117
|
-
"The material to review, inline. For a diff, pass the diff text (or a summarized form if very large).",
|
|
118
|
-
},
|
|
119
|
-
addressed: {
|
|
120
|
-
type: "string",
|
|
121
|
-
description:
|
|
122
|
-
"Optional description of what changed since a previous round, fed back to later rounds so reviewers can revise their position.",
|
|
123
|
-
},
|
|
124
|
-
maxRounds: {
|
|
125
|
-
type: "number",
|
|
126
|
-
description: "Override the configured round cap (Delphi default is 5).",
|
|
127
|
-
},
|
|
128
|
-
cwd: {
|
|
129
|
-
type: "string",
|
|
130
|
-
description: "Project root containing .delphi-config.json (defaults to the session cwd).",
|
|
131
|
-
},
|
|
139
|
+
function delphiReviewTool() {
|
|
140
|
+
return defineTool({
|
|
141
|
+
name: "delphi-review",
|
|
142
|
+
description:
|
|
143
|
+
"Run a Delphi cross-review of a subject (a diff, a design, a spec) using three DISTINCT models from an external OpenAI-compatible provider configured in .delphi-config.json. Round 1 is anonymous and concurrent; later rounds feed back the aggregate until the approval ratio reaches the configured threshold (default 90%) or the round cap (default 5). Use this whenever a change needs independent multi-model review rather than a single model's opinion.",
|
|
144
|
+
parameters: {
|
|
145
|
+
subject: {
|
|
146
|
+
type: "string",
|
|
147
|
+
required: true,
|
|
148
|
+
description:
|
|
149
|
+
"The material to review, inline. For a diff, pass the diff text (or a summarized form if very large).",
|
|
150
|
+
},
|
|
151
|
+
addressed: {
|
|
152
|
+
type: "string",
|
|
153
|
+
description:
|
|
154
|
+
"Optional description of what changed since a previous round, fed back to later rounds so reviewers can revise their position.",
|
|
132
155
|
},
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
156
|
+
maxRounds: {
|
|
157
|
+
type: "number",
|
|
158
|
+
description: "Override the configured round cap (Delphi default is 5).",
|
|
136
159
|
},
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
async execute(args, exec) {
|
|
141
|
-
const cwd = args.cwd ?? exec.agent?.session?.header?.cwd ?? process.cwd()
|
|
142
|
-
try {
|
|
143
|
-
const cfg = loadDelphiConfig(cwd)
|
|
144
|
-
const outcome = await runReview(
|
|
145
|
-
{ ...toDelphiOptions(cfg), maxRounds: args.maxRounds ?? cfg.maxRounds },
|
|
146
|
-
args.subject,
|
|
147
|
-
args.addressed ?? "",
|
|
148
|
-
)
|
|
149
|
-
const seats = cfg.seats.map((s) => s.model).join(", ")
|
|
150
|
-
return `${formatOutcome(outcome)}\n\nProvider: ${cfg.provider}\nSeats: ${seats}`
|
|
151
|
-
} catch (e) {
|
|
152
|
-
// Config problems are the common failure; report them as guidance
|
|
153
|
-
// rather than a stack trace.
|
|
154
|
-
if (e instanceof DelphiSetupError) return `Delphi review not started: ${e.message}`
|
|
155
|
-
throw e
|
|
156
|
-
}
|
|
160
|
+
cwd: {
|
|
161
|
+
type: "string",
|
|
162
|
+
description: "Project root containing .delphi-config.json (defaults to the session cwd).",
|
|
157
163
|
},
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
}
|
|
164
|
+
},
|
|
165
|
+
output: {
|
|
166
|
+
schema: { type: "string" },
|
|
167
|
+
render: (_args, value) => [{ type: "text", text: value }],
|
|
168
|
+
},
|
|
169
|
+
timeoutMs: DELPHI_TIMEOUT_MS,
|
|
170
|
+
async execute(args, exec) {
|
|
171
|
+
const cwd = args.cwd ?? exec.agent?.session?.header?.cwd ?? process.cwd()
|
|
172
|
+
return runDelphiReview(args.subject, args.addressed ?? "", args.maxRounds, cwd)
|
|
173
|
+
},
|
|
174
|
+
})
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
export function apply(ctx: Context, _config: unknown = {}): void {
|
|
178
|
+
// DSH runs a POSIX shell off-Windows and PowerShell on Windows; generating the
|
|
179
|
+
// wrong dialect makes every tool fail to parse rather than degrade gracefully.
|
|
180
|
+
const dialect = detectDialect()
|
|
181
|
+
const shell = ctx.shell
|
|
182
|
+
ctx.tools.register(gateCheckTool(shell, dialect))
|
|
183
|
+
ctx.tools.register(gatePrinciplesTool(shell, dialect))
|
|
184
|
+
ctx.tools.register(gateArchTool(shell, dialect))
|
|
185
|
+
ctx.tools.register(delphiReviewTool())
|
|
186
|
+
}
|
|
@@ -9,7 +9,8 @@ OpenCode plugin exposing xp-gate quality gates and AI workflow skills.
|
|
|
9
9
|
- **gate-principles** ⇄ `xp-gate principles <path>`: Run Clean Code + SOLID
|
|
10
10
|
principles checker (Gate 4 standalone).
|
|
11
11
|
- **gate-arch** ⇄ `xp-gate arch`: Run architecture validation (Gate 6
|
|
12
|
-
standalone
|
|
12
|
+
standalone) with the pinned local @archlinter/cli built-in rules and baseline
|
|
13
|
+
ratchet; an optional config file opts into archlint's own `--config` path.
|
|
13
14
|
- **session-reload-model**: Reload session model from config. After switching
|
|
14
15
|
provider configs (opencode.json + oh-my-openagent.json via switch-coding-plan.sh),
|
|
15
16
|
updates the session model in OpenCode DB to match the new config, so restarted
|
|
@@ -67,7 +68,9 @@ Or via local path (development):
|
|
|
67
68
|
- One of:
|
|
68
69
|
- `xp-gate` CLI installed globally (`npm install -g @boyingliu01/xp-gate`) — **preferred**, or
|
|
69
70
|
- the xp-gate repo checked out locally with `src/principles/index.ts` reachable — **fallback** (the tool will shell out via `npx -y tsx`)
|
|
70
|
-
- `
|
|
71
|
+
- `@archlinter/cli` installed locally or on PATH (for `gate-arch` only; the
|
|
72
|
+
default built-in-rules path needs no `architecture.yaml` — passing one opts
|
|
73
|
+
into archlint's own `--config` schema validation, which rejects pre-0.16 files)
|
|
71
74
|
|
|
72
75
|
## Graceful Degradation
|
|
73
76
|
|