@milkenjoyer/toolchain 0.13.0 → 0.14.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 +20 -0
- package/dist/formal.mjs +7 -120
- package/dist/guard.d.mts +2 -2
- package/dist/guard.mjs +1 -46
- package/dist/manifest-xQwgnYI1.mjs +53 -0
- package/dist/specs-file-NsQF4V7X.mjs +135 -0
- package/dist/standard.d.mts +2 -0
- package/dist/standard.mjs +398 -0
- package/package.json +4 -1
- package/src/formal/critical.ts +48 -0
- package/src/formal/proofs.ts +2 -45
- package/src/formal/specs-file.ts +119 -0
- package/src/formal/specs.ts +2 -112
- package/src/standard/agents.ts +44 -0
- package/src/standard/checks.ts +19 -0
- package/src/standard/config.ts +110 -0
- package/src/standard/formal.ts +93 -0
- package/src/standard/manifest.ts +102 -0
- package/src/standard/plugin-skills.ts +88 -0
- package/src/standard/repo.ts +69 -0
- package/src/standard/toolchain.ts +90 -0
- package/src/standard.ts +71 -0
package/src/formal/specs.ts
CHANGED
|
@@ -2,112 +2,14 @@ import * as Effect from "effect/Effect";
|
|
|
2
2
|
import { FileSystem } from "effect/FileSystem";
|
|
3
3
|
import { Path } from "effect/Path";
|
|
4
4
|
import { ChildProcess } from "effect/process";
|
|
5
|
-
import * as Result from "effect/Result";
|
|
6
|
-
import * as Schema from "effect/Schema";
|
|
7
|
-
import * as SchemaIssue from "effect/SchemaIssue";
|
|
8
5
|
import * as Stream from "effect/Stream";
|
|
9
6
|
|
|
10
7
|
import { parseCfg } from "./cfg.ts";
|
|
11
8
|
import type { Cfg, CfgError } from "./cfg.ts";
|
|
12
9
|
import type { Semantics } from "./semantics.ts";
|
|
10
|
+
import { decode, type SpecsFile, type Entry } from "./specs-file.ts";
|
|
13
11
|
import { FormalError, Tla } from "./tla.ts";
|
|
14
12
|
|
|
15
|
-
const RepoPath = Schema.String.check(
|
|
16
|
-
Schema.isPattern(/^(?!\/)(?!(?:.*\/)?\.\.(?:\/|$))[^\0\\]+$/u)
|
|
17
|
-
);
|
|
18
|
-
const OperatorName = Schema.String.check(
|
|
19
|
-
Schema.isPattern(/^[A-Za-z_][A-Za-z0-9_]*$/u)
|
|
20
|
-
);
|
|
21
|
-
const Common = {
|
|
22
|
-
synced: Schema.String.check(Schema.isPattern(/^[0-9a-f]{40}$/u)),
|
|
23
|
-
covers: Schema.NonEmptyArray(Schema.NonEmptyString),
|
|
24
|
-
};
|
|
25
|
-
const Runtime = {
|
|
26
|
-
...Common,
|
|
27
|
-
timeoutSeconds: Schema.Int.check(
|
|
28
|
-
Schema.isBetween({ minimum: 1, maximum: 1800 })
|
|
29
|
-
).pipe(Schema.withDecodingDefaultKey(Effect.succeed(60))),
|
|
30
|
-
};
|
|
31
|
-
const Proof = {
|
|
32
|
-
...Runtime,
|
|
33
|
-
witnesses: Schema.NonEmptyArray(OperatorName).check(
|
|
34
|
-
Schema.makeFilter(
|
|
35
|
-
(names) =>
|
|
36
|
-
new Set(names).size === names.length || "witnesses must be unique"
|
|
37
|
-
)
|
|
38
|
-
),
|
|
39
|
-
breaks: Schema.Array(
|
|
40
|
-
Schema.Struct({
|
|
41
|
-
violates: OperatorName,
|
|
42
|
-
find: Schema.NonEmptyString,
|
|
43
|
-
replace: Schema.String,
|
|
44
|
-
file: Schema.optionalKey(RepoPath),
|
|
45
|
-
})
|
|
46
|
-
).pipe(Schema.withDecodingDefaultKey(Effect.succeed([]))),
|
|
47
|
-
};
|
|
48
|
-
const Entry = Schema.Union([
|
|
49
|
-
Schema.Struct({
|
|
50
|
-
...Proof,
|
|
51
|
-
mode: Schema.Literal("gate"),
|
|
52
|
-
traces: Schema.optionalKey(
|
|
53
|
-
Schema.Struct({
|
|
54
|
-
seed: Schema.Int.check(Schema.isGreaterThanOrEqualTo(0)),
|
|
55
|
-
depth: Schema.Int.check(
|
|
56
|
-
Schema.isBetween({ minimum: 1, maximum: 10000 })
|
|
57
|
-
),
|
|
58
|
-
count: Schema.Int.check(
|
|
59
|
-
Schema.isBetween({ minimum: 1, maximum: 100000 })
|
|
60
|
-
),
|
|
61
|
-
steer: Schema.optionalKey(
|
|
62
|
-
Schema.Record(
|
|
63
|
-
OperatorName,
|
|
64
|
-
Schema.Int.check(Schema.isBetween({ minimum: 2, maximum: 1000 }))
|
|
65
|
-
)
|
|
66
|
-
),
|
|
67
|
-
conformance: RepoPath,
|
|
68
|
-
})
|
|
69
|
-
),
|
|
70
|
-
}),
|
|
71
|
-
Schema.Struct({ ...Proof, mode: Schema.Literal("manual") }),
|
|
72
|
-
Schema.Struct({ ...Common, mode: Schema.Literal("library") }),
|
|
73
|
-
]);
|
|
74
|
-
const ArithmeticCommon = {
|
|
75
|
-
covers: Common.covers,
|
|
76
|
-
timeoutSeconds: Runtime.timeoutSeconds,
|
|
77
|
-
breaks: Schema.NonEmptyArray(
|
|
78
|
-
Schema.Struct({
|
|
79
|
-
file: RepoPath,
|
|
80
|
-
find: Schema.NonEmptyString,
|
|
81
|
-
replace: Schema.String,
|
|
82
|
-
})
|
|
83
|
-
),
|
|
84
|
-
};
|
|
85
|
-
const ArithmeticProof = Schema.Union([
|
|
86
|
-
Schema.Struct({ ...ArithmeticCommon, kind: Schema.Literal("every") }),
|
|
87
|
-
Schema.Struct({
|
|
88
|
-
...ArithmeticCommon,
|
|
89
|
-
kind: Schema.Literal("z3"),
|
|
90
|
-
samples: Schema.Int.check(
|
|
91
|
-
Schema.isBetween({ minimum: 10000, maximum: 1000000 })
|
|
92
|
-
).pipe(Schema.withDecodingDefaultKey(Effect.succeed(10000))),
|
|
93
|
-
}),
|
|
94
|
-
]);
|
|
95
|
-
const SpecsFile = Schema.Struct({
|
|
96
|
-
critical: Schema.NonEmptyArray(Schema.NonEmptyString),
|
|
97
|
-
arithmetic: Schema.optionalKey(Schema.Array(Schema.NonEmptyString)),
|
|
98
|
-
proofs: Schema.Record(
|
|
99
|
-
RepoPath.check(Schema.isPattern(/\.proof\.ts$/u)),
|
|
100
|
-
ArithmeticProof
|
|
101
|
-
).pipe(Schema.withDecodingDefaultKey(Effect.succeed({}))),
|
|
102
|
-
specs: Schema.Record(RepoPath.check(Schema.isPattern(/\.tla$/u)), Entry),
|
|
103
|
-
kani: Schema.Record(
|
|
104
|
-
RepoPath.check(Schema.isPattern(/\.rs$/u)),
|
|
105
|
-
Schema.Struct({ ...Runtime, mode: Schema.Literals(["gate", "manual"]) })
|
|
106
|
-
).pipe(Schema.withDecodingDefaultKey(Effect.succeed({}))),
|
|
107
|
-
});
|
|
108
|
-
type SpecsFile = Omit<typeof SpecsFile.Type, "critical"> & {
|
|
109
|
-
readonly critical: ReadonlyArray<string>;
|
|
110
|
-
};
|
|
111
13
|
export type Analysis =
|
|
112
14
|
| { readonly _tag: "Parsed"; readonly semantics: Semantics }
|
|
113
15
|
| { readonly _tag: "Unparsed"; readonly output: string };
|
|
@@ -153,19 +55,7 @@ export const load = Effect.fn("formal.load")(function* (root: string) {
|
|
|
153
55
|
let decodeErrors: ReadonlyArray<string> = [];
|
|
154
56
|
if (yield* fs.exists(path.join(root, "specs.json"))) {
|
|
155
57
|
const raw = yield* fs.readFileString(path.join(root, "specs.json"));
|
|
156
|
-
|
|
157
|
-
errors: "all",
|
|
158
|
-
onExcessProperty: "error",
|
|
159
|
-
});
|
|
160
|
-
if (Result.isSuccess(decoded)) file = decoded.success;
|
|
161
|
-
else
|
|
162
|
-
decodeErrors = SchemaIssue.makeFormatterStandardSchemaV1()(
|
|
163
|
-
decoded.failure.issue
|
|
164
|
-
).issues.map(({ message, path: at = [] }) =>
|
|
165
|
-
at.length === 0
|
|
166
|
-
? message
|
|
167
|
-
: `${at.map((key) => `[${JSON.stringify(typeof key === "object" ? key.key : key)}]`).join("")}: ${message}`
|
|
168
|
-
);
|
|
58
|
+
({ file, decodeErrors } = decode(raw));
|
|
169
59
|
}
|
|
170
60
|
const modules = tracked.filter((f) => f.endsWith(".tla"));
|
|
171
61
|
const configs = tracked.filter(
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import * as Effect from "effect/Effect";
|
|
2
|
+
|
|
3
|
+
import { pluginSkills } from "./plugin-skills.ts";
|
|
4
|
+
import { read, type Rule } from "./repo.ts";
|
|
5
|
+
|
|
6
|
+
export const taskAgents: Rule = (repo) =>
|
|
7
|
+
Effect.gen(function* () {
|
|
8
|
+
const input = yield* read(repo, "AGENTS.md", (text) => text);
|
|
9
|
+
if (!input.ok) return input.findings;
|
|
10
|
+
const lines = input.value.split("\n");
|
|
11
|
+
const start = lines.findIndex((line) => /^## Task agents\s*$/u.test(line));
|
|
12
|
+
const section: string[] = [];
|
|
13
|
+
if (start !== -1)
|
|
14
|
+
for (const line of lines.slice(start + 1)) {
|
|
15
|
+
if (/^#{1,6}\s/u.test(line)) break;
|
|
16
|
+
if (line.trim()) section.push(line.trim());
|
|
17
|
+
}
|
|
18
|
+
return section.length === 1 &&
|
|
19
|
+
section[0]?.includes("`agent-kit:task-agents`") === true
|
|
20
|
+
? []
|
|
21
|
+
: [
|
|
22
|
+
{
|
|
23
|
+
file: "AGENTS.md",
|
|
24
|
+
message:
|
|
25
|
+
"add a ## Task agents section containing only one line pointing to `agent-kit:task-agents`",
|
|
26
|
+
},
|
|
27
|
+
];
|
|
28
|
+
});
|
|
29
|
+
export const skillNames: Rule = (repo) =>
|
|
30
|
+
Effect.succeed(
|
|
31
|
+
repo.tracked.flatMap((file) => {
|
|
32
|
+
const name =
|
|
33
|
+
/^(?:\.agents|\.claude|\.codex)\/skills\/([^/]+)\/SKILL\.md$/u.exec(
|
|
34
|
+
file
|
|
35
|
+
)?.[1];
|
|
36
|
+
return name === undefined
|
|
37
|
+
? []
|
|
38
|
+
: Object.entries(pluginSkills).flatMap(([plugin, names]) =>
|
|
39
|
+
names.includes(name)
|
|
40
|
+
? [{ file, message: `shares its name with ${plugin}:${name}` }]
|
|
41
|
+
: []
|
|
42
|
+
);
|
|
43
|
+
})
|
|
44
|
+
);
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { skillNames, taskAgents } from "./agents.ts";
|
|
2
|
+
import { lintFmt, tsconfig } from "./config.ts";
|
|
3
|
+
import { readyFormal, specs } from "./formal.ts";
|
|
4
|
+
import type { Rule } from "./repo.ts";
|
|
5
|
+
import { exact, lintPackage, nodeVersion, pin, renovate } from "./toolchain.ts";
|
|
6
|
+
|
|
7
|
+
export const rules = {
|
|
8
|
+
"toolchain-pin": pin,
|
|
9
|
+
"lint-package": lintPackage,
|
|
10
|
+
"lint-fmt": lintFmt,
|
|
11
|
+
"tsconfig-base": tsconfig,
|
|
12
|
+
"node-version": nodeVersion,
|
|
13
|
+
"renovate-preset": renovate,
|
|
14
|
+
"exact-versions": exact,
|
|
15
|
+
specs,
|
|
16
|
+
"ready-formal": readyFormal,
|
|
17
|
+
"task-agents": taskAgents,
|
|
18
|
+
"skill-names": skillNames,
|
|
19
|
+
} satisfies Record<string, Rule>;
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import * as Effect from "effect/Effect";
|
|
2
|
+
import { Path } from "effect/Path";
|
|
3
|
+
import * as Schema from "effect/Schema";
|
|
4
|
+
|
|
5
|
+
import { read, type Finding, type Rule } from "./repo.ts";
|
|
6
|
+
|
|
7
|
+
export const lintFmt: Rule = (repo) =>
|
|
8
|
+
Effect.gen(function* () {
|
|
9
|
+
const path = yield* Path;
|
|
10
|
+
const roots = repo.tracked.filter((file) =>
|
|
11
|
+
/^vite\.config\.(?:ts|mts|js|mjs)$/u.test(file)
|
|
12
|
+
);
|
|
13
|
+
if (!roots.length)
|
|
14
|
+
return [
|
|
15
|
+
{
|
|
16
|
+
file: "vite.config.ts",
|
|
17
|
+
message: "track a root vite.config.ts, .mts, .js or .mjs",
|
|
18
|
+
},
|
|
19
|
+
];
|
|
20
|
+
const pending = [...roots];
|
|
21
|
+
const visited = new Set<string>();
|
|
22
|
+
const imports = new Set<string>();
|
|
23
|
+
const findings: Finding[] = [];
|
|
24
|
+
const transpiler = new Bun.Transpiler({ loader: "ts" });
|
|
25
|
+
for (const file of pending) {
|
|
26
|
+
if (visited.has(file)) continue;
|
|
27
|
+
visited.add(file);
|
|
28
|
+
const input = yield* read(repo, file, (text) =>
|
|
29
|
+
transpiler.scanImports(text)
|
|
30
|
+
);
|
|
31
|
+
if (!input.ok) {
|
|
32
|
+
findings.push(...input.findings);
|
|
33
|
+
continue;
|
|
34
|
+
}
|
|
35
|
+
for (const item of input.value) {
|
|
36
|
+
imports.add(item.path);
|
|
37
|
+
if (!item.path.startsWith(".")) continue;
|
|
38
|
+
const stem = path.normalize(path.join(path.dirname(file), item.path));
|
|
39
|
+
const candidates = [
|
|
40
|
+
stem,
|
|
41
|
+
stem.replace(/\.(m?)js$/u, ".$1ts"),
|
|
42
|
+
...[".ts", ".mts", ".js", ".mjs"].map((ext) => stem + ext),
|
|
43
|
+
...["ts", "mts", "js", "mjs"].map((ext) => `${stem}/index.${ext}`),
|
|
44
|
+
];
|
|
45
|
+
const target = candidates.find((candidate) =>
|
|
46
|
+
repo.tracked.includes(candidate)
|
|
47
|
+
);
|
|
48
|
+
if (target !== undefined) pending.push(target);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
for (const area of ["lint", "fmt"]) {
|
|
52
|
+
const name = `@milkenjoyer/toolchain/${area}`;
|
|
53
|
+
if (!imports.has(name))
|
|
54
|
+
findings.push({
|
|
55
|
+
file: roots[0] ?? "vite.config.ts",
|
|
56
|
+
message: `import ${name} from the root Vite config or its relative imports`,
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
return findings;
|
|
60
|
+
});
|
|
61
|
+
const Config = Schema.Struct({
|
|
62
|
+
extends: Schema.optionalKey(
|
|
63
|
+
Schema.Union([Schema.String, Schema.Array(Schema.String)])
|
|
64
|
+
),
|
|
65
|
+
});
|
|
66
|
+
export const tsconfig: Rule = (repo) =>
|
|
67
|
+
Effect.gen(function* () {
|
|
68
|
+
const path = yield* Path;
|
|
69
|
+
const pending = ["tsconfig.json"];
|
|
70
|
+
const visited = new Set<string>();
|
|
71
|
+
const findings: Finding[] = [];
|
|
72
|
+
let reached = false;
|
|
73
|
+
for (const file of pending) {
|
|
74
|
+
if (visited.has(file)) continue;
|
|
75
|
+
visited.add(file);
|
|
76
|
+
const input = yield* read(repo, file, (text) =>
|
|
77
|
+
Schema.decodeUnknownSync(Config)(Bun.JSONC.parse(text))
|
|
78
|
+
);
|
|
79
|
+
if (!input.ok) {
|
|
80
|
+
findings.push(...input.findings);
|
|
81
|
+
continue;
|
|
82
|
+
}
|
|
83
|
+
const parents =
|
|
84
|
+
typeof input.value.extends === "string"
|
|
85
|
+
? [input.value.extends]
|
|
86
|
+
: (input.value.extends ?? []);
|
|
87
|
+
for (const parent of parents) {
|
|
88
|
+
if (parent === "@milkenjoyer/toolchain/tsconfig.base.json")
|
|
89
|
+
reached = true;
|
|
90
|
+
if (!parent.startsWith(".")) continue;
|
|
91
|
+
const stem = path.normalize(path.join(path.dirname(file), parent));
|
|
92
|
+
const target = [stem, `${stem}.json`].find((candidate) =>
|
|
93
|
+
repo.tracked.includes(candidate)
|
|
94
|
+
);
|
|
95
|
+
if (target !== undefined) pending.push(target);
|
|
96
|
+
else
|
|
97
|
+
findings.push({
|
|
98
|
+
file: stem,
|
|
99
|
+
message: "track the relative tsconfig extends file",
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
if (!reached && !findings.length)
|
|
104
|
+
findings.push({
|
|
105
|
+
file: "tsconfig.json",
|
|
106
|
+
message:
|
|
107
|
+
"extend @milkenjoyer/toolchain/tsconfig.base.json through the extends chain",
|
|
108
|
+
});
|
|
109
|
+
return findings;
|
|
110
|
+
});
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import * as Effect from "effect/Effect";
|
|
2
|
+
import * as Schema from "effect/Schema";
|
|
3
|
+
|
|
4
|
+
import { criticalFindings } from "../formal/critical.ts";
|
|
5
|
+
import { decode } from "../formal/specs-file.ts";
|
|
6
|
+
import { read, type Rule } from "./repo.ts";
|
|
7
|
+
|
|
8
|
+
export const specs: Rule = (repo) =>
|
|
9
|
+
Effect.gen(function* () {
|
|
10
|
+
if (!repo.tracked.includes("specs.json"))
|
|
11
|
+
return [
|
|
12
|
+
{
|
|
13
|
+
file: "specs.json",
|
|
14
|
+
message: "track specs.json with at least one spec entry",
|
|
15
|
+
},
|
|
16
|
+
];
|
|
17
|
+
const input = yield* read(repo, "specs.json", decode);
|
|
18
|
+
if (!input.ok) return input.findings;
|
|
19
|
+
const { file, decodeErrors } = input.value;
|
|
20
|
+
if (decodeErrors.length)
|
|
21
|
+
return decodeErrors.map((message) => ({ file: "specs.json", message }));
|
|
22
|
+
return [
|
|
23
|
+
...(Object.keys(file.specs).length
|
|
24
|
+
? []
|
|
25
|
+
: [{ file: "specs.json", message: "add at least one spec entry" }]),
|
|
26
|
+
...criticalFindings({ tracked: repo.tracked, file }),
|
|
27
|
+
];
|
|
28
|
+
});
|
|
29
|
+
const Gates = {
|
|
30
|
+
if: Schema.optionalKey(Schema.Unknown),
|
|
31
|
+
"continue-on-error": Schema.optionalKey(Schema.Unknown),
|
|
32
|
+
};
|
|
33
|
+
const Workflow = Schema.Struct({
|
|
34
|
+
jobs: Schema.Record(
|
|
35
|
+
Schema.String,
|
|
36
|
+
Schema.Struct({
|
|
37
|
+
...Gates,
|
|
38
|
+
steps: Schema.optionalKey(
|
|
39
|
+
Schema.Array(
|
|
40
|
+
Schema.Struct({ ...Gates, run: Schema.optionalKey(Schema.String) })
|
|
41
|
+
)
|
|
42
|
+
),
|
|
43
|
+
})
|
|
44
|
+
),
|
|
45
|
+
});
|
|
46
|
+
const FALSE = /^\s*(?:\$\{\{\s*false\s*\}\}|false)\s*$/u;
|
|
47
|
+
const enforced = (gates: {
|
|
48
|
+
readonly if?: unknown;
|
|
49
|
+
readonly "continue-on-error"?: unknown;
|
|
50
|
+
}) =>
|
|
51
|
+
gates.if !== false &&
|
|
52
|
+
!(typeof gates.if === "string" && FALSE.test(gates.if)) &&
|
|
53
|
+
(gates["continue-on-error"] === undefined ||
|
|
54
|
+
gates["continue-on-error"] === false ||
|
|
55
|
+
(typeof gates["continue-on-error"] === "string" &&
|
|
56
|
+
FALSE.test(gates["continue-on-error"])));
|
|
57
|
+
export const readyFormal: Rule = (repo) =>
|
|
58
|
+
Effect.gen(function* () {
|
|
59
|
+
const file = [
|
|
60
|
+
".github/workflows/ready.yml",
|
|
61
|
+
".github/workflows/ready.yaml",
|
|
62
|
+
].find((name) => repo.tracked.includes(name));
|
|
63
|
+
if (file === undefined)
|
|
64
|
+
return [
|
|
65
|
+
{
|
|
66
|
+
file: ".github/workflows/ready.yml",
|
|
67
|
+
message: "track a ready workflow running vp exec formal",
|
|
68
|
+
},
|
|
69
|
+
];
|
|
70
|
+
const input = yield* read(repo, file, (text) =>
|
|
71
|
+
Schema.decodeUnknownSync(Workflow)(Bun.YAML.parse(text))
|
|
72
|
+
);
|
|
73
|
+
if (!input.ok) return input.findings;
|
|
74
|
+
return Object.values(input.value.jobs).some(
|
|
75
|
+
(job) =>
|
|
76
|
+
enforced(job) &&
|
|
77
|
+
(job.steps ?? []).some(
|
|
78
|
+
(step) =>
|
|
79
|
+
enforced(step) &&
|
|
80
|
+
(step.run ?? "")
|
|
81
|
+
.split("\n")
|
|
82
|
+
.some((line) => line.trim() === "vp exec formal")
|
|
83
|
+
)
|
|
84
|
+
)
|
|
85
|
+
? []
|
|
86
|
+
: [
|
|
87
|
+
{
|
|
88
|
+
file,
|
|
89
|
+
message:
|
|
90
|
+
"add a step with a vp exec formal line that no if: false or continue-on-error skips or ignores",
|
|
91
|
+
},
|
|
92
|
+
];
|
|
93
|
+
});
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import * as Arr from "effect/Array";
|
|
2
|
+
import * as Effect from "effect/Effect";
|
|
3
|
+
import { dual } from "effect/Function";
|
|
4
|
+
import * as R from "effect/Record";
|
|
5
|
+
import * as Result from "effect/Result";
|
|
6
|
+
import * as Schema from "effect/Schema";
|
|
7
|
+
|
|
8
|
+
const Versions = Schema.Record(Schema.String, Schema.String).pipe(
|
|
9
|
+
Schema.withDecodingDefaultKey(Effect.succeed({}))
|
|
10
|
+
);
|
|
11
|
+
|
|
12
|
+
const Catalogs = Schema.Record(
|
|
13
|
+
Schema.String,
|
|
14
|
+
Schema.Record(Schema.String, Schema.String)
|
|
15
|
+
).pipe(Schema.withDecodingDefaultKey(Effect.succeed({})));
|
|
16
|
+
|
|
17
|
+
const WorkspaceList = Schema.Array(Schema.String);
|
|
18
|
+
|
|
19
|
+
const WorkspaceCatalogs = Schema.Struct({
|
|
20
|
+
catalog: Versions,
|
|
21
|
+
catalogs: Catalogs,
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
const Manifest = Schema.fromJsonString(
|
|
25
|
+
Schema.Struct({
|
|
26
|
+
dependencies: Versions,
|
|
27
|
+
devDependencies: Versions,
|
|
28
|
+
peerDependencies: Versions,
|
|
29
|
+
optionalDependencies: Versions,
|
|
30
|
+
overrides: Versions,
|
|
31
|
+
resolutions: Versions,
|
|
32
|
+
catalog: Versions,
|
|
33
|
+
catalogs: Catalogs,
|
|
34
|
+
workspaces: Schema.optionalKey(
|
|
35
|
+
Schema.Union([WorkspaceList, WorkspaceCatalogs])
|
|
36
|
+
),
|
|
37
|
+
})
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
export type Ranges = Readonly<Record<string, string>>;
|
|
41
|
+
|
|
42
|
+
const named = (
|
|
43
|
+
prefix: string,
|
|
44
|
+
catalogs: Readonly<Record<string, Ranges>>
|
|
45
|
+
): ReadonlyArray<readonly [string, Ranges]> =>
|
|
46
|
+
Arr.map(R.toEntries(catalogs), ([name, ranges]) => [
|
|
47
|
+
`${prefix}.${name}`,
|
|
48
|
+
ranges,
|
|
49
|
+
]);
|
|
50
|
+
|
|
51
|
+
export const manifestRanges = (
|
|
52
|
+
text: string
|
|
53
|
+
): ReadonlyArray<readonly [string, Ranges]> => {
|
|
54
|
+
const decoded = Schema.decodeResult(Manifest)(text);
|
|
55
|
+
|
|
56
|
+
if (Result.isFailure(decoded)) {
|
|
57
|
+
throw decoded.failure;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const manifest = decoded.success;
|
|
61
|
+
|
|
62
|
+
const workspaces = Schema.is(WorkspaceCatalogs)(manifest.workspaces)
|
|
63
|
+
? manifest.workspaces
|
|
64
|
+
: { catalog: {}, catalogs: {} };
|
|
65
|
+
|
|
66
|
+
return [
|
|
67
|
+
["dependencies", manifest.dependencies],
|
|
68
|
+
["devDependencies", manifest.devDependencies],
|
|
69
|
+
["peerDependencies", manifest.peerDependencies],
|
|
70
|
+
["optionalDependencies", manifest.optionalDependencies],
|
|
71
|
+
["overrides", manifest.overrides],
|
|
72
|
+
["resolutions", manifest.resolutions],
|
|
73
|
+
["catalog", manifest.catalog],
|
|
74
|
+
["workspaces.catalog", workspaces.catalog],
|
|
75
|
+
...named("catalogs", manifest.catalogs),
|
|
76
|
+
...named("workspaces.catalogs", workspaces.catalogs),
|
|
77
|
+
];
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
const SEMVER = String.raw`\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?`;
|
|
81
|
+
|
|
82
|
+
export const PLAIN = new RegExp(`^${SEMVER}$`, "u");
|
|
83
|
+
|
|
84
|
+
const EXACT = new RegExp(
|
|
85
|
+
String.raw`^(?:npm:(?:@[\w.-]+\/)?[\w.-]+@)?${SEMVER}$`,
|
|
86
|
+
"u"
|
|
87
|
+
);
|
|
88
|
+
|
|
89
|
+
const REFERENCE = /^(?:catalog:[\w.-]*|workspace:\*)$/u;
|
|
90
|
+
|
|
91
|
+
export const exactFindings: {
|
|
92
|
+
(text: string): (file: string) => ReadonlyArray<string>;
|
|
93
|
+
(file: string, text: string): ReadonlyArray<string>;
|
|
94
|
+
} = dual(2, (file: string, text: string): ReadonlyArray<string> =>
|
|
95
|
+
Arr.flatMap(manifestRanges(text), ([field, ranges]) =>
|
|
96
|
+
Arr.flatMap(R.toEntries(ranges), ([name, version]) =>
|
|
97
|
+
EXACT.test(version) || REFERENCE.test(version)
|
|
98
|
+
? []
|
|
99
|
+
: [`${file} ${field} ${name}: ${version} is not an exact version`]
|
|
100
|
+
)
|
|
101
|
+
)
|
|
102
|
+
);
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
export const pluginSkills = {
|
|
2
|
+
"agent-kit": [
|
|
3
|
+
"alchemy-domain",
|
|
4
|
+
"animation-performance",
|
|
5
|
+
"better-accessibility",
|
|
6
|
+
"break-ui",
|
|
7
|
+
"coordinate",
|
|
8
|
+
"diagnosing-bugs",
|
|
9
|
+
"formal-bug-hunt",
|
|
10
|
+
"interface-review",
|
|
11
|
+
"report-loop",
|
|
12
|
+
"task-agents",
|
|
13
|
+
"testing",
|
|
14
|
+
"writing-for-agents",
|
|
15
|
+
],
|
|
16
|
+
pstack: [
|
|
17
|
+
"architect",
|
|
18
|
+
"arena",
|
|
19
|
+
"automate-me",
|
|
20
|
+
"benchmark-checklist",
|
|
21
|
+
"blast-radius",
|
|
22
|
+
"bro",
|
|
23
|
+
"correct",
|
|
24
|
+
"create-formal-verification-skill",
|
|
25
|
+
"create-verification-skill",
|
|
26
|
+
"figure-it-out",
|
|
27
|
+
"how",
|
|
28
|
+
"in-your-own-words",
|
|
29
|
+
"interrogate",
|
|
30
|
+
"ketchup",
|
|
31
|
+
"ketchup-video",
|
|
32
|
+
"maintain-formal-verification-skill",
|
|
33
|
+
"maintain-verification-skill",
|
|
34
|
+
"make-bot-ui",
|
|
35
|
+
"no-comments",
|
|
36
|
+
"poteto-help",
|
|
37
|
+
"poteto-mode",
|
|
38
|
+
"principle-attack-the-premise",
|
|
39
|
+
"principle-boundary-discipline",
|
|
40
|
+
"principle-build-the-lever",
|
|
41
|
+
"principle-encode-lessons-in-structure",
|
|
42
|
+
"principle-exhaust-the-design-space",
|
|
43
|
+
"principle-experience-first",
|
|
44
|
+
"principle-explain-the-number",
|
|
45
|
+
"principle-fix-root-causes",
|
|
46
|
+
"principle-foundational-thinking",
|
|
47
|
+
"principle-guard-the-context-window",
|
|
48
|
+
"principle-laziness-protocol",
|
|
49
|
+
"principle-make-operations-idempotent",
|
|
50
|
+
"principle-migrate-callers-then-delete-legacy-apis",
|
|
51
|
+
"principle-minimize-reader-load",
|
|
52
|
+
"principle-model-the-domain",
|
|
53
|
+
"principle-never-block-on-the-human",
|
|
54
|
+
"principle-outcome-oriented-execution",
|
|
55
|
+
"principle-prove-it-works",
|
|
56
|
+
"principle-redesign-from-first-principles",
|
|
57
|
+
"principle-separate-before-serializing-shared-state",
|
|
58
|
+
"principle-sequence-verifiable-units",
|
|
59
|
+
"principle-subtract-before-you-add",
|
|
60
|
+
"principle-test-behavior-not-implementation",
|
|
61
|
+
"principle-type-system-discipline",
|
|
62
|
+
"recall",
|
|
63
|
+
"reflect",
|
|
64
|
+
"setup-pstack",
|
|
65
|
+
"sharpen",
|
|
66
|
+
"show-me-your-work",
|
|
67
|
+
"statechart",
|
|
68
|
+
"swarm",
|
|
69
|
+
"tdd",
|
|
70
|
+
"teach",
|
|
71
|
+
"technical-writing",
|
|
72
|
+
"typescript-best-practices",
|
|
73
|
+
"unslop",
|
|
74
|
+
"why",
|
|
75
|
+
],
|
|
76
|
+
tstack: [
|
|
77
|
+
"babysit-pr",
|
|
78
|
+
"council",
|
|
79
|
+
"file-pr",
|
|
80
|
+
"full-send",
|
|
81
|
+
"full-stop",
|
|
82
|
+
"leaving-pr-comments",
|
|
83
|
+
"modernize",
|
|
84
|
+
"sol-loop",
|
|
85
|
+
"takeover",
|
|
86
|
+
],
|
|
87
|
+
effect: ["effect"],
|
|
88
|
+
};
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import * as Effect from "effect/Effect";
|
|
2
|
+
import { FileSystem } from "effect/FileSystem";
|
|
3
|
+
import { Path } from "effect/Path";
|
|
4
|
+
import { ChildProcess } from "effect/process";
|
|
5
|
+
import * as Schema from "effect/Schema";
|
|
6
|
+
import * as Stream from "effect/Stream";
|
|
7
|
+
|
|
8
|
+
export class StandardError extends Schema.TaggedError<
|
|
9
|
+
StandardError,
|
|
10
|
+
{ readonly brand: unique symbol }
|
|
11
|
+
>()("StandardError", { message: Schema.String }) {}
|
|
12
|
+
|
|
13
|
+
export type Repo = { root: string; tracked: ReadonlyArray<string> };
|
|
14
|
+
export type Finding = { file: string; message: string };
|
|
15
|
+
export type Rule<E = unknown> = (
|
|
16
|
+
repo: Repo
|
|
17
|
+
) => Effect.Effect<ReadonlyArray<Finding>, E, FileSystem | Path>;
|
|
18
|
+
|
|
19
|
+
export const load = Effect.fn("standard.load")(function* (root: string) {
|
|
20
|
+
const fs = yield* FileSystem;
|
|
21
|
+
const path = yield* Path;
|
|
22
|
+
const git = yield* ChildProcess.make("git", ["ls-files", "-z"], {
|
|
23
|
+
cwd: root,
|
|
24
|
+
stdin: "ignore",
|
|
25
|
+
});
|
|
26
|
+
const [files, code] = yield* Effect.all(
|
|
27
|
+
[git.stdout.pipe(Stream.decodeText, Stream.mkString), git.exitCode],
|
|
28
|
+
{ concurrency: "unbounded" }
|
|
29
|
+
);
|
|
30
|
+
if (Number(code) !== 0)
|
|
31
|
+
return yield* new StandardError({ message: "git ls-files failed" });
|
|
32
|
+
const tracked = yield* Effect.filter(
|
|
33
|
+
files.split("\0").filter(Boolean),
|
|
34
|
+
(file) => fs.exists(path.join(root, file))
|
|
35
|
+
);
|
|
36
|
+
return { root, tracked } satisfies Repo;
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
export const read = Effect.fn("standard.read")(function* <A>(
|
|
40
|
+
repo: Repo,
|
|
41
|
+
file: string,
|
|
42
|
+
parse: (text: string) => A
|
|
43
|
+
) {
|
|
44
|
+
const fs = yield* FileSystem;
|
|
45
|
+
const path = yield* Path;
|
|
46
|
+
const failed = (message: string) => ({
|
|
47
|
+
ok: false as const,
|
|
48
|
+
findings: [{ file, message }],
|
|
49
|
+
});
|
|
50
|
+
if (!repo.tracked.includes(file)) return failed("track this file");
|
|
51
|
+
return yield* fs.readFileString(path.join(repo.root, file)).pipe(
|
|
52
|
+
Effect.mapError(
|
|
53
|
+
() => new StandardError({ message: "this file cannot be read" })
|
|
54
|
+
),
|
|
55
|
+
Effect.flatMap((text) =>
|
|
56
|
+
Effect.try({
|
|
57
|
+
try: () => parse(text),
|
|
58
|
+
catch: (error) =>
|
|
59
|
+
new StandardError({
|
|
60
|
+
message: `this file does not parse: ${String(error instanceof Error ? error.message : error).split("\n")[0]}`,
|
|
61
|
+
}),
|
|
62
|
+
})
|
|
63
|
+
),
|
|
64
|
+
Effect.map((value) => ({ ok: true as const, value })),
|
|
65
|
+
Effect.catchTag("StandardError", (error) =>
|
|
66
|
+
Effect.succeed(failed(error.message))
|
|
67
|
+
)
|
|
68
|
+
);
|
|
69
|
+
});
|