@boyingliu01/xp-gate 0.27.6 → 0.28.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.
Files changed (104) hide show
  1. package/adapter-common.sh +0 -0
  2. package/adapters/cpp.sh +0 -0
  3. package/adapters/dart.sh +0 -0
  4. package/adapters/flutter.sh +0 -0
  5. package/adapters/gate-9.sh +13 -2
  6. package/adapters/go.sh +0 -0
  7. package/adapters/iac.sh +0 -0
  8. package/adapters/java.sh +0 -0
  9. package/adapters/kotlin.sh +0 -0
  10. package/adapters/objectivec.sh +0 -0
  11. package/adapters/plugins/book299-20132-python/scripts/install-gradle.sh +0 -0
  12. package/adapters/plugins/book299-20132-python/scripts/install-maven.sh +0 -0
  13. package/adapters/plugins/book299-4081-c/scripts/install-gradle.sh +0 -0
  14. package/adapters/plugins/book299-4081-c/scripts/install-maven.sh +0 -0
  15. package/adapters/plugins/book299-4083-javascriptes5/scripts/install-gradle.sh +0 -0
  16. package/adapters/plugins/book299-4083-javascriptes5/scripts/install-maven.sh +0 -0
  17. package/adapters/powershell.sh +0 -0
  18. package/adapters/python.sh +0 -0
  19. package/adapters/shell.sh +0 -0
  20. package/adapters/swift.sh +0 -0
  21. package/adapters/typescript.sh +0 -0
  22. package/bin/xp-gate.js +0 -0
  23. package/build-integrity/gate-10.ts +290 -263
  24. package/gate-10.sh +25 -6
  25. package/gate-12-file-hygiene.sh +35 -1
  26. package/gate-3.sh +78 -2
  27. package/gate-4.sh +0 -0
  28. package/gate-7.sh +0 -0
  29. package/gate-8.sh +0 -0
  30. package/gate-9.sh +13 -2
  31. package/hooks/adapter-common.sh +0 -0
  32. package/hooks/gate-10.sh +25 -6
  33. package/hooks/gate-12-file-hygiene.sh +35 -1
  34. package/hooks/gate-3.sh +78 -2
  35. package/hooks/gate-4.sh +0 -0
  36. package/hooks/gate-7.sh +0 -0
  37. package/hooks/gate-8.sh +0 -0
  38. package/hooks/gate-9.sh +13 -2
  39. package/hooks/lib/audit-sanitize.sh +51 -0
  40. package/hooks/lib/ccn-ratchet.sh +183 -0
  41. package/hooks/lib/docs-only.sh +49 -0
  42. package/hooks/post-merge +0 -0
  43. package/hooks/pre-commit +74 -15
  44. package/hooks/pre-push +19 -4
  45. package/hooks/sprint-gate.sh +0 -0
  46. package/lib/__tests__/sprint-audit.test.js +207 -207
  47. package/lib/gate-audit.ts +9 -4
  48. package/lib/mattpocock-license-verdict.json +1 -1
  49. package/lib/retro.js +27 -6
  50. package/lib/sprint-audit.js +235 -235
  51. package/mock-policy/AGENTS.md +3 -3
  52. package/mutation/AGENTS.md +3 -3
  53. package/package.json +1 -1
  54. package/plugins/claude-code/.claude-plugin/plugin.json +1 -1
  55. package/plugins/claude-code/bin/delphi-review-guard.sh +0 -0
  56. package/plugins/claude-code/bin/xp-gate-check +0 -0
  57. package/plugins/claude-code/skills/delphi-review/AGENTS.md +3 -3
  58. package/plugins/claude-code/skills/sprint-flow/AGENTS.md +3 -3
  59. package/plugins/claude-code/skills/test-specification-alignment/AGENTS.md +3 -3
  60. package/plugins/dsh/package.json +1 -1
  61. package/plugins/dsh/skills/delphi-review/AGENTS.md +3 -3
  62. package/plugins/dsh/skills/sprint-flow/AGENTS.md +3 -3
  63. package/plugins/dsh/skills/test-specification-alignment/AGENTS.md +3 -3
  64. package/plugins/opencode/package.json +1 -1
  65. package/plugins/opencode/skills/delphi-review/AGENTS.md +3 -3
  66. package/plugins/opencode/skills/sprint-flow/AGENTS.md +3 -3
  67. package/plugins/opencode/skills/test-specification-alignment/AGENTS.md +3 -3
  68. package/plugins/qoder/bin/sprint-flow-guard.sh +0 -0
  69. package/plugins/qoder/bin/xp-gate-check +0 -0
  70. package/plugins/qoder/plugin.json +1 -1
  71. package/plugins/qoder/skills/delphi-review/AGENTS.md +3 -3
  72. package/plugins/qoder/skills/sprint-flow/AGENTS.md +3 -3
  73. package/plugins/qoder/skills/test-specification-alignment/AGENTS.md +3 -3
  74. package/principles/AGENTS.md +3 -3
  75. package/principles/__tests__/many-exports-reexport.test.ts +40 -0
  76. package/principles/adapters/typescript.ts +61 -30
  77. package/principles/boy-scout.ts +22 -17
  78. package/scripts/delphi-external-review.cjs +195 -132
  79. package/skills/delphi-review/AGENTS.md +3 -3
  80. package/skills/sprint-flow/AGENTS.md +3 -3
  81. package/skills/test-specification-alignment/AGENTS.md +3 -3
  82. package/sprint-gate.sh +0 -0
  83. package/plugins/dsh/lib/command.d.ts +0 -32
  84. package/plugins/dsh/lib/command.d.ts.map +0 -1
  85. package/plugins/dsh/lib/command.js +0 -81
  86. package/plugins/dsh/lib/delphi-config.d.ts +0 -75
  87. package/plugins/dsh/lib/delphi-config.d.ts.map +0 -1
  88. package/plugins/dsh/lib/delphi-config.js +0 -183
  89. package/plugins/dsh/lib/delphi-run.d.ts +0 -24
  90. package/plugins/dsh/lib/delphi-run.d.ts.map +0 -1
  91. package/plugins/dsh/lib/delphi-run.js +0 -92
  92. package/plugins/dsh/lib/delphi.d.ts +0 -88
  93. package/plugins/dsh/lib/delphi.d.ts.map +0 -1
  94. package/plugins/dsh/lib/delphi.js +0 -161
  95. package/plugins/dsh/lib/dialect.d.ts +0 -24
  96. package/plugins/dsh/lib/dialect.d.ts.map +0 -1
  97. package/plugins/dsh/lib/dialect.js +0 -36
  98. package/plugins/dsh/lib/gate-runner.d.ts +0 -18
  99. package/plugins/dsh/lib/gate-runner.d.ts.map +0 -1
  100. package/plugins/dsh/lib/gate-runner.js +0 -46
  101. package/plugins/dsh/lib/index.d.ts +0 -5
  102. package/plugins/dsh/lib/index.d.ts.map +0 -1
  103. package/plugins/dsh/lib/index.js +0 -162
  104. package/plugins/dsh/node_modules/.vite/vitest/results.json +0 -1
@@ -1,46 +0,0 @@
1
- import { TOOL_ABORTED } from "@deepseek-ai/dsh-tools";
2
- import { HarnessError } from "@deepseek-ai/dsh-llm";
3
- /** Render a completed shell run as a single model-facing text block. */
4
- export function renderGateResult(result) {
5
- const lines = [];
6
- const stdout = result.stdout.text.trim();
7
- if (stdout.length > 0)
8
- lines.push(stdout);
9
- const stderr = result.stderr.text.trim();
10
- if (stderr.length > 0)
11
- lines.push(`[stderr] ${stderr}`);
12
- if (result.timedOut)
13
- lines.push(`[timed out after ${result.timeoutMs}ms]`);
14
- if (result.exitCode !== null && result.exitCode !== 0)
15
- lines.push(`[exit code: ${result.exitCode}]`);
16
- if (result.signal !== null)
17
- lines.push(`[signal: ${result.signal}]`);
18
- if (result.sandbox?.denied === true) {
19
- lines.push(`[sandbox: file access denied under ${result.sandbox.mode} mode]`);
20
- }
21
- if (result.stdout.truncated) {
22
- const spill = result.stdout.spillPath !== undefined ? `, full output: ${result.stdout.spillPath}` : "";
23
- lines.push(`[stdout truncated${spill}]`);
24
- }
25
- if (result.stderr.truncated) {
26
- const spill = result.stderr.spillPath !== undefined ? `, full output: ${result.stderr.spillPath}` : "";
27
- lines.push(`[stderr truncated${spill}]`);
28
- }
29
- return lines.length > 0 ? lines.join("\n") : "[XP-Gate] command completed (no output).";
30
- }
31
- /**
32
- * Run an xp-gate command through the harness shell seam. Nonzero exits, timeouts,
33
- * and sandbox denials resolve (and render) rather than reject; only cancellation
34
- * (the caller's AbortSignal fired first) throws an AbortError with code ABORTED.
35
- */
36
- export async function runXpGate(shell, signal, command, workdir, timeoutMs) {
37
- const spec = shell.resolve({ command, workdir, timeoutMs, signal });
38
- const result = await shell.run(spec);
39
- if (result.aborted) {
40
- const error = new HarnessError("tool call aborted", TOOL_ABORTED);
41
- error.name = "AbortError";
42
- throw error;
43
- }
44
- return renderGateResult(result);
45
- }
46
- //# sourceMappingURL=gate-runner.js.map
@@ -1,5 +0,0 @@
1
- import type { Context } from "@deepseek-ai/cordis";
2
- export declare const name = "tool-xp-gate";
3
- export declare const inject: string[];
4
- export declare function apply(ctx: Context, _config?: unknown): void;
5
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAOlD,eAAO,MAAM,IAAI,iBAAiB,CAAA;AAClC,eAAO,MAAM,MAAM,UAAqB,CAAA;AAuKxC,wBAAgB,KAAK,CAAC,GAAG,EAAE,OAAO,EAAE,OAAO,GAAE,OAAY,GAAG,IAAI,CAS/D"}
@@ -1,162 +0,0 @@
1
- import { defineTool } from "@deepseek-ai/dsh-tools";
2
- import { GATE_WHITELIST, buildCommand, detectDialect, resolveTarget } from "./command.js";
3
- import { runXpGate } from "./gate-runner.js";
4
- import { DelphiSetupError, loadDelphiConfig, toDelphiOptions } from "./delphi-config.js";
5
- import { formatOutcome, runReview } from "./delphi-run.js";
6
- export const name = "tool-xp-gate";
7
- export const inject = ["tools", "shell"];
8
- const DEFAULT_TIMEOUT_MS = 120_000;
9
- // Multi-round reviews over large inputs are slow; the transport applies its
10
- // own per-request timeout on top of this ceiling.
11
- const DELPHI_TIMEOUT_MS = 900_000;
12
- // Boy Scout (#447): gate-check's `gates` parameter nests one level too deep
13
- // inline (parameters → gates → items), so the schema lives at module scope.
14
- const GATES_PARAMETER = {
15
- type: "array",
16
- items: { type: "string", enum: GATE_WHITELIST },
17
- description: "Optional gate subset to run (e.g. ['principles', 'arch']).",
18
- };
19
- // Boy Scout (#447): apply() used to inline four register(defineTool({...}))
20
- // blocks (149 lines, 5 brace levels). Each tool now lives in its own factory;
21
- // apply() is pure wiring.
22
- function gateCheckTool(shell, dialect) {
23
- return defineTool({
24
- name: "gate-check",
25
- description: "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.",
26
- parameters: {
27
- path: {
28
- type: "string",
29
- required: true,
30
- description: "File or directory path to check (absolute or relative to the workspace).",
31
- },
32
- gates: GATES_PARAMETER,
33
- },
34
- output: {
35
- schema: { type: "string" },
36
- render: (_args, value) => [{ type: "text", text: value }],
37
- },
38
- timeoutMs: DEFAULT_TIMEOUT_MS,
39
- async execute(args, exec) {
40
- const cwd = exec.agent?.session?.header?.cwd ?? process.cwd();
41
- const target = resolveTarget(args.path, cwd);
42
- const command = buildCommand({ subcommand: "check", target, gates: args.gates, dialect });
43
- return runXpGate(shell, exec.signal, command, cwd, DEFAULT_TIMEOUT_MS);
44
- },
45
- });
46
- }
47
- function gatePrinciplesTool(shell, dialect) {
48
- return defineTool({
49
- name: "gate-principles",
50
- description: "Run the 14 Clean Code / SOLID rules (xp-gate principles, Gate 4) on a file or directory and return the principles report.",
51
- parameters: {
52
- path: {
53
- type: "string",
54
- required: true,
55
- description: "File or directory path to check (absolute or relative to the workspace).",
56
- },
57
- },
58
- output: {
59
- schema: { type: "string" },
60
- render: (_args, value) => [{ type: "text", text: value }],
61
- },
62
- timeoutMs: DEFAULT_TIMEOUT_MS,
63
- async execute(args, exec) {
64
- const cwd = exec.agent?.session?.header?.cwd ?? process.cwd();
65
- const target = resolveTarget(args.path, cwd);
66
- const command = buildCommand({ subcommand: "principles", target, dialect });
67
- return runXpGate(shell, exec.signal, command, cwd, DEFAULT_TIMEOUT_MS);
68
- },
69
- });
70
- }
71
- function gateArchTool(shell, dialect) {
72
- return defineTool({
73
- name: "gate-arch",
74
- description: "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).",
75
- parameters: {
76
- config: {
77
- type: "string",
78
- description: "Optional architecture config file (opts into archlint --config; the default built-in-rules path needs none).",
79
- },
80
- },
81
- output: {
82
- schema: { type: "string" },
83
- render: (_args, value) => [{ type: "text", text: value }],
84
- },
85
- timeoutMs: DEFAULT_TIMEOUT_MS,
86
- async execute(args, exec) {
87
- const cwd = exec.agent?.session?.header?.cwd ?? process.cwd();
88
- const command = buildCommand({ subcommand: "arch", config: args.config, dialect });
89
- return runXpGate(shell, exec.signal, command, cwd, DEFAULT_TIMEOUT_MS);
90
- },
91
- });
92
- }
93
- // Delphi multi-model cross-review.
94
- //
95
- // DSH's own subagents cannot do this: they inherit one host-configured model,
96
- // so three "experts" would be three instances of the same model, and Delphi's
97
- // value rests entirely on the reviewers being DIFFERENT models. This tool
98
- // therefore calls an external OpenAI-compatible provider directly, with one
99
- // distinct model per seat.
100
- // Boy Scout (#447): the review body used to sit inline in execute() at 5 brace
101
- // levels (defineTool → execute → try → runReview options). Module scope keeps
102
- // the try/catch semantics identical while dropping two levels.
103
- async function runDelphiReview(subject, addressed, maxRounds, cwd) {
104
- try {
105
- const cfg = loadDelphiConfig(cwd);
106
- const outcome = await runReview({ ...toDelphiOptions(cfg), maxRounds: maxRounds ?? cfg.maxRounds }, subject, addressed);
107
- const seats = cfg.seats.map((s) => s.model).join(", ");
108
- return `${formatOutcome(outcome)}\n\nProvider: ${cfg.provider}\nSeats: ${seats}`;
109
- }
110
- catch (e) {
111
- // Config problems are the common failure; report them as guidance
112
- // rather than a stack trace.
113
- if (e instanceof DelphiSetupError)
114
- return `Delphi review not started: ${e.message}`;
115
- throw e;
116
- }
117
- }
118
- function delphiReviewTool() {
119
- return defineTool({
120
- name: "delphi-review",
121
- description: "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.",
122
- parameters: {
123
- subject: {
124
- type: "string",
125
- required: true,
126
- description: "The material to review, inline. For a diff, pass the diff text (or a summarized form if very large).",
127
- },
128
- addressed: {
129
- type: "string",
130
- description: "Optional description of what changed since a previous round, fed back to later rounds so reviewers can revise their position.",
131
- },
132
- maxRounds: {
133
- type: "number",
134
- description: "Override the configured round cap (Delphi default is 5).",
135
- },
136
- cwd: {
137
- type: "string",
138
- description: "Project root containing .delphi-config.json (defaults to the session cwd).",
139
- },
140
- },
141
- output: {
142
- schema: { type: "string" },
143
- render: (_args, value) => [{ type: "text", text: value }],
144
- },
145
- timeoutMs: DELPHI_TIMEOUT_MS,
146
- async execute(args, exec) {
147
- const cwd = args.cwd ?? exec.agent?.session?.header?.cwd ?? process.cwd();
148
- return runDelphiReview(args.subject, args.addressed ?? "", args.maxRounds, cwd);
149
- },
150
- });
151
- }
152
- export function apply(ctx, _config = {}) {
153
- // DSH runs a POSIX shell off-Windows and PowerShell on Windows; generating the
154
- // wrong dialect makes every tool fail to parse rather than degrade gracefully.
155
- const dialect = detectDialect();
156
- const shell = ctx.shell;
157
- ctx.tools.register(gateCheckTool(shell, dialect));
158
- ctx.tools.register(gatePrinciplesTool(shell, dialect));
159
- ctx.tools.register(gateArchTool(shell, dialect));
160
- ctx.tools.register(delphiReviewTool());
161
- }
162
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":"1.6.1","results":[[":src/delphi-config-global-fallback.test.ts",{"duration":13,"failed":false}]]}