@h-rig/standard-plugin 0.0.6-alpha.142 → 0.0.6-alpha.143
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/dist/src/bundle.d.ts +6 -5
- package/dist/src/bundle.js +1693 -1300
- package/dist/src/cli-surface.d.ts +4 -0
- package/dist/src/cli-surface.js +21 -0
- package/dist/src/drift/metadata.d.ts +13 -0
- package/dist/src/drift/metadata.js +33 -0
- package/dist/src/drift/plugin.d.ts +4 -14
- package/dist/src/drift/plugin.js +4 -5
- package/dist/src/github-issues-source.js +52 -20
- package/dist/src/index.d.ts +0 -2
- package/dist/src/index.js +1657 -1414
- package/dist/src/lifecycle-closeout.d.ts +2 -0
- package/dist/src/lifecycle-closeout.js +6 -0
- package/dist/src/plugin.d.ts +8 -11
- package/dist/src/plugin.js +1657 -1397
- package/dist/src/product-entrypoint.d.ts +11 -0
- package/dist/src/product-entrypoint.js +101 -0
- package/dist/src/run-worker-panels.d.ts +15 -0
- package/dist/src/run-worker-panels.js +53 -0
- package/package.json +24 -8
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { RigPluginWithRuntime } from "@rig/core/config";
|
|
2
|
+
export declare const STANDARD_CLI_SURFACE_PLUGIN_NAME = "@rig/standard-plugin:cli-surface";
|
|
3
|
+
export declare const standardCliSurfacePlugin: RigPluginWithRuntime;
|
|
4
|
+
export declare function standardCliSurfaceRuntime(plugin: RigPluginWithRuntime): RigPluginWithRuntime;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
// packages/standard-plugin/src/cli-surface.ts
|
|
3
|
+
var STANDARD_CLI_SURFACE_PLUGIN_NAME = "@rig/standard-plugin:cli-surface";
|
|
4
|
+
var standardCliSurfacePlugin = {
|
|
5
|
+
name: STANDARD_CLI_SURFACE_PLUGIN_NAME,
|
|
6
|
+
version: "0.0.0-alpha.1",
|
|
7
|
+
contributes: {
|
|
8
|
+
capabilities: [{ id: "surface.cli", title: "Rig CLI surface", description: "Registry-dispatched command-line surface." }]
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
function standardCliSurfaceRuntime(plugin) {
|
|
12
|
+
if (plugin.name !== STANDARD_CLI_SURFACE_PLUGIN_NAME) {
|
|
13
|
+
throw new Error(`standard CLI surface runtime must use plugin name ${STANDARD_CLI_SURFACE_PLUGIN_NAME}, got ${plugin.name}`);
|
|
14
|
+
}
|
|
15
|
+
return plugin;
|
|
16
|
+
}
|
|
17
|
+
export {
|
|
18
|
+
standardCliSurfaceRuntime,
|
|
19
|
+
standardCliSurfacePlugin,
|
|
20
|
+
STANDARD_CLI_SURFACE_PLUGIN_NAME
|
|
21
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type StageMutation, type ValidatorRegistration } from "@rig/contracts";
|
|
2
|
+
export interface DocsDriftPluginOptions {
|
|
3
|
+
readonly docsGlobs?: readonly string[];
|
|
4
|
+
readonly ignoreGlobs?: readonly string[];
|
|
5
|
+
readonly failOnDrift?: boolean;
|
|
6
|
+
}
|
|
7
|
+
export declare const DOCS_DRIFT_VALIDATOR_ID = "std:docs-drift";
|
|
8
|
+
export declare const DOCS_DRIFT_CLI_ID = "std:drift";
|
|
9
|
+
export declare const DOCS_DRIFT_STAGE_ID = "docs-drift";
|
|
10
|
+
export declare const DOCS_DRIFT_CAPABILITY_ID = "std:docs-drift-capability";
|
|
11
|
+
export declare const DOCS_DRIFT_VALIDATOR: ValidatorRegistration;
|
|
12
|
+
export declare const DOCS_DRIFT_STAGE_MUTATION: StageMutation;
|
|
13
|
+
export declare const DOCS_DRIFT_CLI_COMMAND = "rig drift [--docs <csv>] [--ignore <csv>] [--fail-on-drift] [--json]";
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
// packages/standard-plugin/src/drift/metadata.ts
|
|
3
|
+
import { Schema } from "effect";
|
|
4
|
+
import { StageMutation as StageMutationSchema } from "@rig/contracts";
|
|
5
|
+
var DOCS_DRIFT_VALIDATOR_ID = "std:docs-drift";
|
|
6
|
+
var DOCS_DRIFT_CLI_ID = "std:drift";
|
|
7
|
+
var DOCS_DRIFT_STAGE_ID = "docs-drift";
|
|
8
|
+
var DOCS_DRIFT_CAPABILITY_ID = "std:docs-drift-capability";
|
|
9
|
+
var DOCS_DRIFT_VALIDATOR = {
|
|
10
|
+
id: DOCS_DRIFT_VALIDATOR_ID,
|
|
11
|
+
category: "regression",
|
|
12
|
+
description: "Detect documentation references that drifted from the source tree."
|
|
13
|
+
};
|
|
14
|
+
var DOCS_DRIFT_STAGE_MUTATION = Schema.decodeUnknownSync(StageMutationSchema)({
|
|
15
|
+
op: "insert",
|
|
16
|
+
stage: {
|
|
17
|
+
id: DOCS_DRIFT_STAGE_ID,
|
|
18
|
+
kind: "gate",
|
|
19
|
+
before: ["merge-gate"],
|
|
20
|
+
after: ["open-pr"]
|
|
21
|
+
},
|
|
22
|
+
contributedBy: DOCS_DRIFT_STAGE_ID
|
|
23
|
+
});
|
|
24
|
+
var DOCS_DRIFT_CLI_COMMAND = "rig drift [--docs <csv>] [--ignore <csv>] [--fail-on-drift] [--json]";
|
|
25
|
+
export {
|
|
26
|
+
DOCS_DRIFT_VALIDATOR_ID,
|
|
27
|
+
DOCS_DRIFT_VALIDATOR,
|
|
28
|
+
DOCS_DRIFT_STAGE_MUTATION,
|
|
29
|
+
DOCS_DRIFT_STAGE_ID,
|
|
30
|
+
DOCS_DRIFT_CLI_ID,
|
|
31
|
+
DOCS_DRIFT_CLI_COMMAND,
|
|
32
|
+
DOCS_DRIFT_CAPABILITY_ID
|
|
33
|
+
};
|
|
@@ -1,18 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import type { RegisteredValidator, RuntimeCliCommand, RuntimeCliContext, ValidatorResult } from "@rig/core";
|
|
1
|
+
import type { DriftFinding, DriftReport, StageResult, StageRun } from "@rig/contracts";
|
|
2
|
+
import type { RegisteredValidator, RuntimeCliCommand, RuntimeCliContext, ValidatorResult } from "@rig/core/config";
|
|
3
3
|
import { type DriftDetectOptions } from "./detect";
|
|
4
|
-
export
|
|
5
|
-
|
|
6
|
-
readonly ignoreGlobs?: readonly string[];
|
|
7
|
-
readonly failOnDrift?: boolean;
|
|
8
|
-
}
|
|
9
|
-
export declare const DOCS_DRIFT_VALIDATOR_ID = "std:docs-drift";
|
|
10
|
-
export declare const DOCS_DRIFT_CLI_ID = "std:drift";
|
|
11
|
-
export declare const DOCS_DRIFT_STAGE_ID = "docs-drift";
|
|
12
|
-
export declare const DOCS_DRIFT_CAPABILITY_ID = "std:docs-drift-capability";
|
|
13
|
-
export declare const DOCS_DRIFT_VALIDATOR: ValidatorRegistration;
|
|
14
|
-
export declare const DOCS_DRIFT_STAGE_MUTATION: StageMutation;
|
|
15
|
-
export declare const DOCS_DRIFT_CLI_COMMAND = "rig drift [--docs <csv>] [--ignore <csv>] [--fail-on-drift] [--json]";
|
|
4
|
+
export { DOCS_DRIFT_CAPABILITY_ID, DOCS_DRIFT_CLI_COMMAND, DOCS_DRIFT_CLI_ID, DOCS_DRIFT_STAGE_ID, DOCS_DRIFT_STAGE_MUTATION, DOCS_DRIFT_VALIDATOR, DOCS_DRIFT_VALIDATOR_ID, type DocsDriftPluginOptions, } from "./metadata";
|
|
5
|
+
import { type DocsDriftPluginOptions } from "./metadata";
|
|
16
6
|
export declare function highConfidenceDriftFindings(report: DriftReport): readonly DriftFinding[];
|
|
17
7
|
export declare function driftGateResult(report: DriftReport, mode?: "observe" | "enforce"): StageResult;
|
|
18
8
|
/**
|
package/dist/src/drift/plugin.js
CHANGED
|
@@ -1,8 +1,4 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
// packages/standard-plugin/src/drift/plugin.ts
|
|
3
|
-
import { Schema } from "effect";
|
|
4
|
-
import { StageMutation as StageMutationSchema } from "@rig/contracts";
|
|
5
|
-
|
|
6
2
|
// packages/standard-plugin/src/drift/detect.ts
|
|
7
3
|
import { existsSync } from "fs";
|
|
8
4
|
import { readdir, readFile, stat } from "fs/promises";
|
|
@@ -297,7 +293,9 @@ async function detectDrift(options) {
|
|
|
297
293
|
};
|
|
298
294
|
}
|
|
299
295
|
|
|
300
|
-
// packages/standard-plugin/src/drift/
|
|
296
|
+
// packages/standard-plugin/src/drift/metadata.ts
|
|
297
|
+
import { Schema } from "effect";
|
|
298
|
+
import { StageMutation as StageMutationSchema } from "@rig/contracts";
|
|
301
299
|
var DOCS_DRIFT_VALIDATOR_ID = "std:docs-drift";
|
|
302
300
|
var DOCS_DRIFT_CLI_ID = "std:drift";
|
|
303
301
|
var DOCS_DRIFT_STAGE_ID = "docs-drift";
|
|
@@ -318,6 +316,7 @@ var DOCS_DRIFT_STAGE_MUTATION = Schema.decodeUnknownSync(StageMutationSchema)({
|
|
|
318
316
|
contributedBy: DOCS_DRIFT_STAGE_ID
|
|
319
317
|
});
|
|
320
318
|
var DOCS_DRIFT_CLI_COMMAND = "rig drift [--docs <csv>] [--ignore <csv>] [--fail-on-drift] [--json]";
|
|
319
|
+
// packages/standard-plugin/src/drift/plugin.ts
|
|
321
320
|
function highConfidenceDriftFindings(report) {
|
|
322
321
|
return report.findings.filter((finding) => finding.confidence === "high");
|
|
323
322
|
}
|
|
@@ -22,15 +22,35 @@ function createEnvGitHubCredentialProvider() {
|
|
|
22
22
|
};
|
|
23
23
|
}
|
|
24
24
|
function createStateGitHubCredentialProvider(options = {}) {
|
|
25
|
+
const addCandidate = (candidates, path) => {
|
|
26
|
+
const trimmed = path?.trim();
|
|
27
|
+
if (!trimmed)
|
|
28
|
+
return;
|
|
29
|
+
const resolved = resolve(trimmed);
|
|
30
|
+
if (!candidates.includes(resolved))
|
|
31
|
+
candidates.push(resolved);
|
|
32
|
+
};
|
|
33
|
+
const addStateDir = (candidates, dir) => {
|
|
34
|
+
const trimmed = dir?.trim();
|
|
35
|
+
if (!trimmed)
|
|
36
|
+
return;
|
|
37
|
+
addCandidate(candidates, resolve(trimmed, "github-auth.json"));
|
|
38
|
+
};
|
|
39
|
+
const addProjectStateDir = (candidates, root) => {
|
|
40
|
+
const trimmed = root?.trim();
|
|
41
|
+
if (!trimmed)
|
|
42
|
+
return;
|
|
43
|
+
addStateDir(candidates, resolve(trimmed, ".rig", "state"));
|
|
44
|
+
};
|
|
25
45
|
const stateFileCandidates = () => {
|
|
26
46
|
const candidates = [];
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
47
|
+
addCandidate(candidates, options.stateFile ?? process.env.RIG_GITHUB_AUTH_STATE_FILE);
|
|
48
|
+
addStateDir(candidates, options.stateDir);
|
|
49
|
+
addProjectStateDir(candidates, process.env.PROJECT_RIG_ROOT);
|
|
50
|
+
addProjectStateDir(candidates, process.env.RIG_PROJECT_ROOT);
|
|
51
|
+
addProjectStateDir(candidates, process.env.RIG_HOST_PROJECT_ROOT);
|
|
52
|
+
addProjectStateDir(candidates, process.cwd());
|
|
53
|
+
addStateDir(candidates, process.env.RIG_STATE_DIR);
|
|
34
54
|
return candidates;
|
|
35
55
|
};
|
|
36
56
|
const readToken = () => {
|
|
@@ -90,23 +110,29 @@ function statusFor(issue) {
|
|
|
90
110
|
return "open";
|
|
91
111
|
}
|
|
92
112
|
function parseIssueRefs(raw) {
|
|
93
|
-
|
|
113
|
+
const refs = [...raw.matchAll(/(?:^|[^\w/.-])(?:[\w.-]+\/[\w.-]+#|#)?(\d+)\b/g)].map((match) => match[1]).filter((value) => Boolean(value));
|
|
114
|
+
return [...new Set(refs)];
|
|
115
|
+
}
|
|
116
|
+
function metadataKeyPattern(keys) {
|
|
117
|
+
return new RegExp(`^(?:${keys.map((key) => key.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("|")}):\\s*(.*)$`, "i");
|
|
94
118
|
}
|
|
95
|
-
function parseMetadataList(body,
|
|
119
|
+
function parseMetadataList(body, keys) {
|
|
96
120
|
const block = body.match(/<!-- rig:metadata:start -->\s*([\s\S]*?)\s*<!-- rig:metadata:end -->/);
|
|
97
121
|
if (!block)
|
|
98
122
|
return [];
|
|
99
123
|
const lines = block[1].split(/\r?\n/);
|
|
100
124
|
const values = [];
|
|
125
|
+
const keyPattern = metadataKeyPattern(keys);
|
|
101
126
|
for (let index = 0;index < lines.length; index += 1) {
|
|
102
127
|
const line = lines[index];
|
|
103
|
-
const sameLine = line.match(
|
|
104
|
-
if (sameLine)
|
|
105
|
-
values.push(...parseIssueRefs(sameLine[1]));
|
|
128
|
+
const sameLine = line.match(keyPattern);
|
|
129
|
+
if (!sameLine)
|
|
106
130
|
continue;
|
|
107
|
-
|
|
108
|
-
if (
|
|
131
|
+
const inlineValue = sameLine[1]?.trim() ?? "";
|
|
132
|
+
if (inlineValue) {
|
|
133
|
+
values.push(...parseIssueRefs(inlineValue));
|
|
109
134
|
continue;
|
|
135
|
+
}
|
|
110
136
|
for (let cursor = index + 1;cursor < lines.length; cursor += 1) {
|
|
111
137
|
const item = lines[cursor].match(/^\s*-\s*(.+)$/);
|
|
112
138
|
if (!item)
|
|
@@ -116,15 +142,21 @@ function parseMetadataList(body, key) {
|
|
|
116
142
|
}
|
|
117
143
|
return [...new Set(values)];
|
|
118
144
|
}
|
|
145
|
+
function parseBodyKeyRefs(body, keys) {
|
|
146
|
+
const keyPattern = metadataKeyPattern(keys);
|
|
147
|
+
const values = body.split(/\r?\n/).flatMap((line) => {
|
|
148
|
+
const match = line.match(keyPattern);
|
|
149
|
+
return match?.[1] ? parseIssueRefs(match[1]) : [];
|
|
150
|
+
});
|
|
151
|
+
return [...new Set(values)];
|
|
152
|
+
}
|
|
119
153
|
function parseDeps(body) {
|
|
120
|
-
const
|
|
121
|
-
|
|
122
|
-
return [...new Set([...bodyRefs, ...parseMetadataList(body, "depends-on")])];
|
|
154
|
+
const keys = ["depends-on", "deps", "blocked-by", "blocked_by"];
|
|
155
|
+
return [...new Set([...parseBodyKeyRefs(body, keys), ...parseMetadataList(body, keys)])];
|
|
123
156
|
}
|
|
124
157
|
function parseParents(body) {
|
|
125
|
-
const
|
|
126
|
-
|
|
127
|
-
return [...new Set([...bodyRefs, ...parseMetadataList(body, "parents")])];
|
|
158
|
+
const keys = ["parents", "parent"];
|
|
159
|
+
return [...new Set([...parseBodyKeyRefs(body, keys), ...parseMetadataList(body, keys)])];
|
|
128
160
|
}
|
|
129
161
|
function issueTypeFor(issue) {
|
|
130
162
|
const labels = labelNamesFor(issue);
|
package/dist/src/index.d.ts
CHANGED