@ref0/workspace 0.10.0 → 0.12.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/README.md +171 -1
- package/dist/bin.mjs +19 -7
- package/dist/lint/generic/ast-fields.mjs +32 -0
- package/dist/lint/generic/build-cache-inputs.d.mts +9 -0
- package/dist/lint/generic/build-cache-inputs.mjs +147 -0
- package/dist/lint/generic/effect-gen-wrappers.d.mts +13 -0
- package/dist/lint/generic/effect-gen-wrappers.mjs +100 -0
- package/dist/lint/generic/folder-imports.mjs +84 -0
- package/dist/lint/generic/folder-layers.d.mts +40 -0
- package/dist/lint/generic/folder-layers.mjs +82 -0
- package/dist/lint/generic/imports.mjs +34 -0
- package/dist/lint/generic/package-graph.d.mts +36 -0
- package/dist/lint/generic/package-graph.mjs +111 -0
- package/dist/lint/generic/package-imports.mjs +85 -0
- package/dist/lint/generic/plugin.d.mts +7 -3
- package/dist/lint/generic/plugin.mjs +21 -3
- package/dist/lint/generic/public-docs.d.mts +12 -0
- package/dist/lint/generic/public-docs.mjs +345 -0
- package/dist/lint/generic/pure-effect-fn.mjs +107 -0
- package/dist/lint/generic/pure-top-level.d.mts +44 -0
- package/dist/lint/generic/pure-top-level.mjs +393 -0
- package/dist/lint/generic/rule-options.mjs +17 -0
- package/dist/lint/generic/workspace-packages.d.mts +58 -0
- package/dist/lint/generic/workspace-packages.mjs +119 -0
- package/dist/lint/graph.d.mts +8 -0
- package/dist/lint/graph.mjs +3 -0
- package/dist/review-record/command.mjs +107 -0
- package/dist/review-record/index.d.mts +3 -0
- package/dist/review-record/index.mjs +3 -0
- package/dist/review-record/review-record.d.mts +33 -0
- package/dist/review-record/review-record.mjs +1256 -0
- package/dist/review-record/settings.d.mts +40 -0
- package/dist/review-record/settings.mjs +103 -0
- package/dist/symbols/symbols.mjs +1 -1
- package/dist/task-sources.d.mts +16 -0
- package/dist/task-sources.mjs +121 -0
- package/package.json +13 -1
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/** The path of the settings, in the repo. */
|
|
2
|
+
export declare const settingsPath = ".agents/repo/review.json";
|
|
3
|
+
export interface Settings {
|
|
4
|
+
/**
|
|
5
|
+
* The review types the repo accepts: a session naming another fails, by that type's name. The
|
|
6
|
+
* shared review skill's `references/types.md` lists them.
|
|
7
|
+
*/
|
|
8
|
+
readonly reviewTypes: ReadonlyArray<string>;
|
|
9
|
+
/** The types every session names, as run or as not run with why, on a change a review covers. */
|
|
10
|
+
readonly consideredTypes: ReadonlyArray<string>;
|
|
11
|
+
/** Changed lines, additions plus deletions from the merge base, up to which a pull request may be low. */
|
|
12
|
+
readonly lowTierLines: number;
|
|
13
|
+
/** Changed lines up to which a pull request may be medium: past them its floor is high. */
|
|
14
|
+
readonly highTierLines: number;
|
|
15
|
+
/**
|
|
16
|
+
* Production source, as globs, whose net lines count toward a large change. The globs name what
|
|
17
|
+
* they leave out, test code among it, with `!` entries, so a repo may count a test script as
|
|
18
|
+
* production when its old gate did. Fixtures are left out whatever the globs name.
|
|
19
|
+
*/
|
|
20
|
+
readonly productionSource: ReadonlyArray<string>;
|
|
21
|
+
/**
|
|
22
|
+
* Test code, as globs: a pull request that changes it needs a tests reviewer, or at low or medium
|
|
23
|
+
* a recorded break.
|
|
24
|
+
*/
|
|
25
|
+
readonly testCode: ReadonlyArray<string>;
|
|
26
|
+
/**
|
|
27
|
+
* Shared test helpers, test code whether `testCode` names them or not: a change to one puts a
|
|
28
|
+
* pull request at medium or above.
|
|
29
|
+
*/
|
|
30
|
+
readonly testHelpers: ReadonlyArray<string>;
|
|
31
|
+
/**
|
|
32
|
+
* The list that ties source to the bench cases that time it, as `<case> <glob>` lines, or none in
|
|
33
|
+
* a repo with no bench.
|
|
34
|
+
*/
|
|
35
|
+
readonly benchedPaths: string | undefined;
|
|
36
|
+
/** Files under a `testing/` folder that a bench case runs all the same, so a change to one owes its readings. */
|
|
37
|
+
readonly benchRuns: ReadonlyArray<string>;
|
|
38
|
+
}
|
|
39
|
+
/** `settingsOf`'s settings, which throws on a problem, as the gate does on anything it can't read. */
|
|
40
|
+
export declare const settingsFrom: (text: string | undefined) => Settings;
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { Result, Schema } from "effect";
|
|
2
|
+
// src/review-record/settings.ts
|
|
3
|
+
/**
|
|
4
|
+
* What the review gate reads of each repo: `.agents/repo/review.json`, beside `review-paths.txt`, as
|
|
5
|
+
* the package's README says under "The review gate". Every key may be left out, for the value
|
|
6
|
+
* `defaults` gives it, so a repo names only where it differs. CI reads the base's copy, so a pull
|
|
7
|
+
* request can't loosen the settings that judge it.
|
|
8
|
+
*/
|
|
9
|
+
/** The path of the settings, in the repo. */
|
|
10
|
+
const settingsPath = ".agents/repo/review.json";
|
|
11
|
+
/** The path of the list of files a review covers, in the repo. */
|
|
12
|
+
const listPath = ".agents/repo/review-paths.txt";
|
|
13
|
+
/** Globs in `review-paths.txt`'s form, where `*` crosses folders and a `!` entry takes a path off. */
|
|
14
|
+
const Globs = Schema.Array(Schema.String);
|
|
15
|
+
/** A count of lines, a whole number above 0. */
|
|
16
|
+
const Lines = Schema.Int.check(Schema.isGreaterThan(0));
|
|
17
|
+
/** A review type, in lowercase, as the shared review skill's `references/types.md` names it. */
|
|
18
|
+
const ReviewType = Schema.String.check(Schema.isPattern(/^[a-z][a-z -]*[a-z]$/));
|
|
19
|
+
/** The settings file's keys, each optional, and no others, so a misspelt one is named. */
|
|
20
|
+
const File = Schema.Struct({
|
|
21
|
+
reviewTypes: Schema.optionalKey(Schema.Array(ReviewType)),
|
|
22
|
+
consideredTypes: Schema.optionalKey(Schema.Array(ReviewType)),
|
|
23
|
+
lowTierLines: Schema.optionalKey(Lines),
|
|
24
|
+
highTierLines: Schema.optionalKey(Lines),
|
|
25
|
+
productionSource: Schema.optionalKey(Globs),
|
|
26
|
+
testCode: Schema.optionalKey(Globs),
|
|
27
|
+
testHelpers: Schema.optionalKey(Globs),
|
|
28
|
+
benchedPaths: Schema.optionalKey(Schema.String),
|
|
29
|
+
benchRuns: Schema.optionalKey(Schema.Array(Schema.String))
|
|
30
|
+
});
|
|
31
|
+
/** Each setting's value when the file leaves it out: ref-0/git's, where the gate began. */
|
|
32
|
+
const defaults = {
|
|
33
|
+
reviewTypes: [
|
|
34
|
+
"stress test",
|
|
35
|
+
"red team",
|
|
36
|
+
"system design",
|
|
37
|
+
"formal verification",
|
|
38
|
+
"fuzzing",
|
|
39
|
+
"storage",
|
|
40
|
+
"program design",
|
|
41
|
+
"tests",
|
|
42
|
+
"code quality",
|
|
43
|
+
"agent reader",
|
|
44
|
+
"fidelity",
|
|
45
|
+
"experiment",
|
|
46
|
+
"skeptic",
|
|
47
|
+
"cold read"
|
|
48
|
+
],
|
|
49
|
+
consideredTypes: [
|
|
50
|
+
"stress test",
|
|
51
|
+
"system design",
|
|
52
|
+
"red team",
|
|
53
|
+
"storage",
|
|
54
|
+
"program design",
|
|
55
|
+
"formal verification",
|
|
56
|
+
"fuzzing",
|
|
57
|
+
"fidelity"
|
|
58
|
+
],
|
|
59
|
+
lowTierLines: 150,
|
|
60
|
+
highTierLines: 500,
|
|
61
|
+
productionSource: [
|
|
62
|
+
"packages/*/src/*.ts",
|
|
63
|
+
"packages/*/src/*.tsx",
|
|
64
|
+
"apps/*/src/*.ts",
|
|
65
|
+
"apps/*/src/*.tsx",
|
|
66
|
+
"!*.test.ts",
|
|
67
|
+
"!*.test-d.ts",
|
|
68
|
+
"!*/testing/*"
|
|
69
|
+
],
|
|
70
|
+
testCode: [
|
|
71
|
+
"*.test.ts",
|
|
72
|
+
"*.test-d.ts",
|
|
73
|
+
"*/testing/*"
|
|
74
|
+
],
|
|
75
|
+
testHelpers: ["*/testing/*"],
|
|
76
|
+
benchedPaths: void 0,
|
|
77
|
+
benchRuns: []
|
|
78
|
+
};
|
|
79
|
+
const decodeFile = Schema.decodeUnknownResult(Schema.fromJsonString(File), { onExcessProperty: "error" });
|
|
80
|
+
/**
|
|
81
|
+
* The settings a file's text gives, `defaults` for each key it leaves out and all of them when
|
|
82
|
+
* there's no file, or what's wrong with it.
|
|
83
|
+
*/
|
|
84
|
+
const settingsOf = (text) => {
|
|
85
|
+
if (text === void 0) return { settings: defaults };
|
|
86
|
+
const decoded = decodeFile(text);
|
|
87
|
+
if (Result.isFailure(decoded)) return { problem: `${settingsPath}: ${decoded.failure.message}` };
|
|
88
|
+
const settings = {
|
|
89
|
+
...defaults,
|
|
90
|
+
...decoded.success
|
|
91
|
+
};
|
|
92
|
+
const unknown = settings.consideredTypes.filter((type) => !settings.reviewTypes.includes(type));
|
|
93
|
+
if (unknown.length > 0) return { problem: `${settingsPath}: consideredTypes names ${unknown.join(", ")}, not in reviewTypes` };
|
|
94
|
+
if (settings.highTierLines < settings.lowTierLines) return { problem: `${settingsPath}: highTierLines, ${settings.highTierLines}, is below lowTierLines, ${settings.lowTierLines}` };
|
|
95
|
+
return { settings };
|
|
96
|
+
};
|
|
97
|
+
/** `settingsOf`'s settings, which throws on a problem, as the gate does on anything it can't read. */
|
|
98
|
+
const settingsFrom = (text) => {
|
|
99
|
+
const read = settingsOf(text);
|
|
100
|
+
if ("problem" in read) throw new Error(read.problem);
|
|
101
|
+
return read.settings;
|
|
102
|
+
};
|
|
103
|
+
export { defaults, listPath, settingsFrom, settingsOf, settingsPath };
|
package/dist/symbols/symbols.mjs
CHANGED
|
@@ -3,8 +3,8 @@ import { existsSync, mkdirSync, readFileSync, renameSync, writeFileSync } from "
|
|
|
3
3
|
import { pid } from "node:process";
|
|
4
4
|
import { dirname, join } from "node:path";
|
|
5
5
|
import { fileURLToPath } from "node:url";
|
|
6
|
-
import { parseAst } from "vite-plus";
|
|
7
6
|
import { createHash } from "node:crypto";
|
|
7
|
+
import { parseAst } from "vite-plus";
|
|
8
8
|
import { deserialize, serialize } from "node:v8";
|
|
9
9
|
// src/symbols/symbols.ts
|
|
10
10
|
/**
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Workspace } from "./lint/generic/workspace-packages.mjs";
|
|
2
|
+
declare global {
|
|
3
|
+
var ref0WorkspaceTaskSources: Map<string, ReadonlyMap<string, string> | null> | undefined;
|
|
4
|
+
}
|
|
5
|
+
/** A hash of the files under `folders`, from the root, `''` for all of them, but tests unless asked. */
|
|
6
|
+
export declare const sourcesHash: (ids: ReadonlyMap<string, string>, folders: ReadonlyArray<string>, tests: boolean) => string;
|
|
7
|
+
/**
|
|
8
|
+
* The task commands of a workspace: `builtFrom`, a package's build command, from its
|
|
9
|
+
* `vite.config.ts`'s `import.meta.url`, keyed by its folder and the workspace packages it depends
|
|
10
|
+
* on, but their tests; and `readsAll`, a command that reads the whole workspace, such as lint's,
|
|
11
|
+
* keyed by every file.
|
|
12
|
+
*/
|
|
13
|
+
export declare const taskSources: (workspace: Workspace) => {
|
|
14
|
+
builtFrom: (config: string, command: string) => string;
|
|
15
|
+
readsAll: (command: string) => string;
|
|
16
|
+
};
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { dependedOn, fromRoot, workspacePackages } from "./lint/generic/workspace-packages.mjs";
|
|
2
|
+
import { execFileSync } from "node:child_process";
|
|
3
|
+
import { existsSync } from "node:fs";
|
|
4
|
+
import { env } from "node:process";
|
|
5
|
+
import { dirname, join } from "node:path";
|
|
6
|
+
import { fileURLToPath } from "node:url";
|
|
7
|
+
import { createHash } from "node:crypto";
|
|
8
|
+
// src/task-sources.ts
|
|
9
|
+
/**
|
|
10
|
+
* A cached task's command with its sources' contents in it, so that Vite Task's key holds them.
|
|
11
|
+
*
|
|
12
|
+
* Vite Task keys a task by its command, arguments, folder and named variables, and keeps the
|
|
13
|
+
* files it read, with their hashes, in the result. The remote tier keeps one result a key, so two
|
|
14
|
+
* branches that build one package from different sources replace each other's result, and the
|
|
15
|
+
* next run on either misses: on 8 Nov a new worktree, at the commit another had just built and
|
|
16
|
+
* uploaded, replayed 3 of 12 builds and no lint, every miss naming a file only another branch had.
|
|
17
|
+
* With the sources' hash in the command, each set of contents has a key of its own, and any
|
|
18
|
+
* checkout at those contents, CI's too, finds it. The files read are still checked on a replay.
|
|
19
|
+
*
|
|
20
|
+
* The hash is of each file's Git object ID, as the checkout holds it: from Git's index, or, for a
|
|
21
|
+
* file changed or added and not ignored, hashed as Git would. Ignored files, such as the
|
|
22
|
+
* compiler's generated bundles, are left out, so two checkouts that differ only there share a key,
|
|
23
|
+
* and the files read still tell them apart. A build's sources are its package's folder and each
|
|
24
|
+
* workspace package it depends on, but their test files, with the lockfile, the workspace file and
|
|
25
|
+
* `tsconfig.base.json`. Lint's are every file.
|
|
26
|
+
*
|
|
27
|
+
* A command that `&&` joins from several takes the hash on each, as web's and overlord's staging
|
|
28
|
+
* builds do, a build and then Wrangler's dry run of its deploy. Vite Task may keep a result for
|
|
29
|
+
* each joined command, as it did for those two before they had the hash, or one for them all, as
|
|
30
|
+
* it does with it, on 9 Nov 2026: either way, every key holds the hash.
|
|
31
|
+
*
|
|
32
|
+
* Only the run that plans the tasks adds it: a task's own processes, which Vite Task marks with
|
|
33
|
+
* `VP_RUN`, load the same config, where the command is never read. Outside Git, the command is
|
|
34
|
+
* left as it is.
|
|
35
|
+
*/
|
|
36
|
+
const git = (root, args, input = "") => execFileSync("git", args, {
|
|
37
|
+
cwd: root,
|
|
38
|
+
encoding: "utf8",
|
|
39
|
+
input,
|
|
40
|
+
maxBuffer: 268435456,
|
|
41
|
+
stdio: [
|
|
42
|
+
"pipe",
|
|
43
|
+
"pipe",
|
|
44
|
+
"ignore"
|
|
45
|
+
]
|
|
46
|
+
});
|
|
47
|
+
/** Each file's Git object ID, from the root, as the checkout holds it, or none outside Git. */
|
|
48
|
+
const listObjects = (root) => {
|
|
49
|
+
try {
|
|
50
|
+
const ids = /* @__PURE__ */ new Map();
|
|
51
|
+
for (const entry of git(root, [
|
|
52
|
+
"ls-files",
|
|
53
|
+
"--stage",
|
|
54
|
+
"-z"
|
|
55
|
+
]).split("\0")) {
|
|
56
|
+
const tab = entry.indexOf(" ");
|
|
57
|
+
if (tab === -1) continue;
|
|
58
|
+
ids.set(entry.slice(tab + 1), entry.slice(0, tab).split(" ")[1] ?? "");
|
|
59
|
+
}
|
|
60
|
+
const changed = git(root, [
|
|
61
|
+
"ls-files",
|
|
62
|
+
"--modified",
|
|
63
|
+
"--others",
|
|
64
|
+
"--exclude-standard",
|
|
65
|
+
"-z"
|
|
66
|
+
]).split("\0").filter((path) => path !== "" && !path.includes("\n"));
|
|
67
|
+
const present = changed.filter((path) => existsSync(join(root, path)));
|
|
68
|
+
for (const path of changed) ids.delete(path);
|
|
69
|
+
const hashed = present.length === 0 ? [] : git(root, ["hash-object", "--stdin-paths"], present.join("\n")).split("\n");
|
|
70
|
+
for (const [index, path] of present.entries()) ids.set(path, hashed[index] ?? "");
|
|
71
|
+
return ids;
|
|
72
|
+
} catch {
|
|
73
|
+
return null;
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
const objects = (root) => {
|
|
77
|
+
globalThis.ref0WorkspaceTaskSources ??= /* @__PURE__ */ new Map();
|
|
78
|
+
const known = globalThis.ref0WorkspaceTaskSources.get(root);
|
|
79
|
+
if (known !== void 0) return known;
|
|
80
|
+
const listed = listObjects(root);
|
|
81
|
+
globalThis.ref0WorkspaceTaskSources.set(root, listed);
|
|
82
|
+
return listed;
|
|
83
|
+
};
|
|
84
|
+
/** Every build reads these, as its inputs name them. */
|
|
85
|
+
const shared = /* @__PURE__ */ new Set([
|
|
86
|
+
"pnpm-lock.yaml",
|
|
87
|
+
"pnpm-workspace.yaml",
|
|
88
|
+
"tsconfig.base.json"
|
|
89
|
+
]);
|
|
90
|
+
const testFile = /\.test\.[cm]?[jt]sx?$/u;
|
|
91
|
+
/** A hash of the files under `folders`, from the root, `''` for all of them, but tests unless asked. */
|
|
92
|
+
const sourcesHash = (ids, folders, tests) => {
|
|
93
|
+
const within = (path) => shared.has(path) || folders.some((folder) => folder === "" || path.startsWith(`${folder}/`));
|
|
94
|
+
const entries = [...ids].flatMap(([path, id]) => within(path) && (tests || !testFile.test(path)) ? [`${path}\0${id}`] : []);
|
|
95
|
+
entries.sort();
|
|
96
|
+
return createHash("sha256").update(entries.join("\n")).digest("hex").slice(0, 16);
|
|
97
|
+
};
|
|
98
|
+
const keyed = (root, command, folders, tests) => {
|
|
99
|
+
if (env["VP_RUN"] !== void 0) return command;
|
|
100
|
+
const ids = objects(root);
|
|
101
|
+
if (ids === null) return command;
|
|
102
|
+
const sources = `env REF0_SOURCES=${sourcesHash(ids, folders, tests)}`;
|
|
103
|
+
return command.split(" && ").map((part) => `${sources} ${part}`).join(" && ");
|
|
104
|
+
};
|
|
105
|
+
/**
|
|
106
|
+
* The task commands of a workspace: `builtFrom`, a package's build command, from its
|
|
107
|
+
* `vite.config.ts`'s `import.meta.url`, keyed by its folder and the workspace packages it depends
|
|
108
|
+
* on, but their tests; and `readsAll`, a command that reads the whole workspace, such as lint's,
|
|
109
|
+
* keyed by every file.
|
|
110
|
+
*/
|
|
111
|
+
const taskSources = (workspace) => ({
|
|
112
|
+
builtFrom: (config, command) => {
|
|
113
|
+
const directory = fromRoot(workspace.root, dirname(fileURLToPath(config)));
|
|
114
|
+
const packages = workspacePackages(workspace);
|
|
115
|
+
const own = [...packages.values()].find((found) => found.directory === directory);
|
|
116
|
+
const dependencies = own === void 0 ? [] : [...dependedOn(own.name, packages).values()];
|
|
117
|
+
return keyed(workspace.root, command, [directory, ...dependencies.map((dependency) => dependency.directory)], false);
|
|
118
|
+
},
|
|
119
|
+
readsAll: (command) => keyed(workspace.root, command, [""], true)
|
|
120
|
+
});
|
|
121
|
+
export { sourcesHash, taskSources };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ref0/workspace",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.12.0",
|
|
4
4
|
"description": "The lint and workspace checks every ref-0 repo shares",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -28,6 +28,18 @@
|
|
|
28
28
|
"./lint/plugins": {
|
|
29
29
|
"types": "./dist/lint/plugins.d.mts",
|
|
30
30
|
"import": "./dist/lint/plugins.mjs"
|
|
31
|
+
},
|
|
32
|
+
"./lint/graph": {
|
|
33
|
+
"types": "./dist/lint/graph.d.mts",
|
|
34
|
+
"import": "./dist/lint/graph.mjs"
|
|
35
|
+
},
|
|
36
|
+
"./task-sources": {
|
|
37
|
+
"types": "./dist/task-sources.d.mts",
|
|
38
|
+
"import": "./dist/task-sources.mjs"
|
|
39
|
+
},
|
|
40
|
+
"./review-record": {
|
|
41
|
+
"types": "./dist/review-record/index.d.mts",
|
|
42
|
+
"import": "./dist/review-record/index.mjs"
|
|
31
43
|
}
|
|
32
44
|
},
|
|
33
45
|
"publishConfig": {
|