opencode-completion-gate 1.1.0 → 1.2.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/CHANGELOG.md +14 -0
- package/dist/ado-pr.d.ts +34 -0
- package/dist/config.d.ts +35 -0
- package/dist/core.d.ts +12 -243
- package/dist/gate.d.ts +6 -0
- package/dist/index.js +178 -194
- package/dist/plugin.js +357 -359
- package/dist/process.d.ts +11 -0
- package/dist/review.d.ts +3 -0
- package/dist/types.d.ts +100 -0
- package/package.json +2 -2
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { SpawnOptions } from 'child_process';
|
|
2
|
+
import type { ProcessOutcome, ShellFn, ShellInvocation } from './types.js';
|
|
3
|
+
export declare function logDiag(msg: string): void;
|
|
4
|
+
export declare function brief(s: string): string;
|
|
5
|
+
export declare function truncateTail(text: string, maxLines?: number): string;
|
|
6
|
+
export declare function runCommand(cmd: string, cwd: string, timeoutMs: number): Promise<ProcessOutcome>;
|
|
7
|
+
export declare function execFileOut(file: string, args: string[], cwd: string, timeoutMs: number, spawnOpts?: SpawnOptions): Promise<ProcessOutcome>;
|
|
8
|
+
export declare function quoteWin(s: string): string;
|
|
9
|
+
export declare function buildShellInvocation(args: string[]): ShellInvocation;
|
|
10
|
+
export declare const execShell: ShellFn;
|
|
11
|
+
export declare function describeSdkError(err: unknown): string;
|
package/dist/review.d.ts
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { AssertionOutcome, ReviewAssertion, ReviewSessionClient } from './types.js';
|
|
2
|
+
export declare function parseVerdict(output: string): 'PASS' | 'FAIL' | null;
|
|
3
|
+
export declare function runReviewAssertion(a: ReviewAssertion, cwd: string, client?: ReviewSessionClient, isAborted?: () => boolean): Promise<AssertionOutcome>;
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
export interface CommandAssertion {
|
|
2
|
+
type: 'command';
|
|
3
|
+
name: string;
|
|
4
|
+
run: string;
|
|
5
|
+
timeoutSeconds: number;
|
|
6
|
+
}
|
|
7
|
+
export interface AdoPrAssertion {
|
|
8
|
+
type: 'ado-pr';
|
|
9
|
+
name: string;
|
|
10
|
+
pollTimeoutMinutes: number;
|
|
11
|
+
pollIntervalSeconds: number;
|
|
12
|
+
skipIfNoPr: boolean;
|
|
13
|
+
ignoreHumanPolicies?: boolean;
|
|
14
|
+
}
|
|
15
|
+
export interface ReviewAssertion {
|
|
16
|
+
type: 'opencode-review';
|
|
17
|
+
name: string;
|
|
18
|
+
agent: string;
|
|
19
|
+
prompt?: string;
|
|
20
|
+
timeoutSeconds: number;
|
|
21
|
+
}
|
|
22
|
+
export type GateAssertion = CommandAssertion | AdoPrAssertion | ReviewAssertion;
|
|
23
|
+
export interface GateConfig {
|
|
24
|
+
enabled: boolean;
|
|
25
|
+
maxRetries: number;
|
|
26
|
+
assertions: GateAssertion[];
|
|
27
|
+
}
|
|
28
|
+
export interface ProcessOutcome {
|
|
29
|
+
code: number | null;
|
|
30
|
+
timedOut: boolean;
|
|
31
|
+
stdout: string;
|
|
32
|
+
stderr: string;
|
|
33
|
+
}
|
|
34
|
+
export interface AssertionOutcome {
|
|
35
|
+
name: string;
|
|
36
|
+
passed: boolean;
|
|
37
|
+
evidence: string;
|
|
38
|
+
}
|
|
39
|
+
export type ShellFn = (args: string[], cwd: string, timeoutMs: number) => Promise<string>;
|
|
40
|
+
export interface ShellInvocation {
|
|
41
|
+
file: string;
|
|
42
|
+
args: string[];
|
|
43
|
+
}
|
|
44
|
+
export interface BuildLogArtifact {
|
|
45
|
+
buildId: number;
|
|
46
|
+
archivePath?: string;
|
|
47
|
+
extractedPath?: string;
|
|
48
|
+
error?: string;
|
|
49
|
+
}
|
|
50
|
+
export type BuildLogExtractor = (archivePath: string, destination: string, cwd: string, timeoutMs: number) => Promise<void>;
|
|
51
|
+
export interface BuildLogDownloadOptions {
|
|
52
|
+
tempRoot?: string;
|
|
53
|
+
timeoutMs?: number;
|
|
54
|
+
shell?: ShellFn;
|
|
55
|
+
extract?: BuildLogExtractor;
|
|
56
|
+
isAborted?: () => boolean;
|
|
57
|
+
}
|
|
58
|
+
export type BuildLogArtifactRunner = (projectName: string, buildId: number, cwd: string, isAborted?: () => boolean) => Promise<BuildLogArtifact>;
|
|
59
|
+
export interface AdoPrPollOptions {
|
|
60
|
+
sleep?: (ms: number) => Promise<void>;
|
|
61
|
+
now?: () => number;
|
|
62
|
+
isAborted?: () => boolean;
|
|
63
|
+
buildLogArtifact?: BuildLogArtifactRunner;
|
|
64
|
+
}
|
|
65
|
+
export interface PolicyEvaluationMinimal {
|
|
66
|
+
configuration?: {
|
|
67
|
+
isBlocking?: boolean;
|
|
68
|
+
isRequired?: boolean;
|
|
69
|
+
type?: {
|
|
70
|
+
displayName?: string;
|
|
71
|
+
};
|
|
72
|
+
};
|
|
73
|
+
status?: string;
|
|
74
|
+
context?: {
|
|
75
|
+
buildId?: number | string | null;
|
|
76
|
+
buildDefinitionName?: string;
|
|
77
|
+
buildOutputPreview?: {
|
|
78
|
+
jobName?: string;
|
|
79
|
+
taskName?: string;
|
|
80
|
+
errors?: Array<{
|
|
81
|
+
message?: string | null;
|
|
82
|
+
}>;
|
|
83
|
+
} | null;
|
|
84
|
+
} | null;
|
|
85
|
+
}
|
|
86
|
+
export interface TerminalBuildFailure {
|
|
87
|
+
buildId: number | null;
|
|
88
|
+
status: string;
|
|
89
|
+
definitionName?: string;
|
|
90
|
+
jobName?: string;
|
|
91
|
+
taskName?: string;
|
|
92
|
+
previewErrors: string[];
|
|
93
|
+
}
|
|
94
|
+
export interface ReviewSessionClient {
|
|
95
|
+
session: {
|
|
96
|
+
create(options?: unknown): Promise<unknown>;
|
|
97
|
+
prompt(options: unknown): Promise<unknown>;
|
|
98
|
+
abort?(options: unknown): Promise<unknown>;
|
|
99
|
+
};
|
|
100
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "opencode-completion-gate",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "OpenCode plugin: per-session quality gate that blocks declaring done until configured assertions pass",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/plugin.js",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"test": "vitest run",
|
|
23
23
|
"test:watch": "vitest",
|
|
24
24
|
"test:coverage": "vitest run --coverage",
|
|
25
|
-
"lint": "eslint src tests",
|
|
25
|
+
"lint": "eslint src tests --max-warnings=0",
|
|
26
26
|
"lint:fix": "eslint src tests --fix",
|
|
27
27
|
"format": "prettier --write \"src/**/*.ts\" \"tests/**/*.ts\"",
|
|
28
28
|
"format:check": "prettier --check \"src/**/*.ts\" \"tests/**/*.ts\"",
|