@milkenjoyer/toolchain 0.12.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 +115 -6
- package/dist/arithmetic.d.mts +45 -0
- package/dist/arithmetic.mjs +25 -0
- package/dist/formal.mjs +369 -273
- package/dist/guard.d.mts +2 -2
- package/dist/guard.mjs +1 -46
- package/dist/knip.mjs +2 -1
- 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 +10 -2
- package/src/formal/arithmetic.ts +190 -0
- package/src/formal/checks.ts +19 -1
- package/src/formal/critical.ts +48 -0
- package/src/formal/proof-run.ts +77 -0
- package/src/formal/proofs.ts +2 -36
- package/src/formal/prover.ts +291 -0
- package/src/formal/specs-file.ts +119 -0
- package/src/formal/specs.ts +3 -87
- package/src/formal/tla.ts +36 -17
- package/src/formal/z3.ts +321 -0
- package/src/formal.ts +1 -1
- 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
|
@@ -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
|
+
});
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { fileURLToPath } from "node:url";
|
|
2
|
+
|
|
3
|
+
import * as Effect from "effect/Effect";
|
|
4
|
+
import { FileSystem } from "effect/FileSystem";
|
|
5
|
+
import * as Schema from "effect/Schema";
|
|
6
|
+
|
|
7
|
+
import { exactFindings, manifestRanges, PLAIN } from "./manifest.ts";
|
|
8
|
+
import { read, type Finding, type Rule } from "./repo.ts";
|
|
9
|
+
|
|
10
|
+
const packageName = "@milkenjoyer/toolchain";
|
|
11
|
+
export const pin: Rule = (repo) =>
|
|
12
|
+
Effect.gen(function* () {
|
|
13
|
+
const input = yield* read(repo, "package.json", manifestRanges);
|
|
14
|
+
if (!input.ok) return input.findings;
|
|
15
|
+
const groups = new Map(input.value);
|
|
16
|
+
const version =
|
|
17
|
+
groups.get("dependencies")?.[packageName] ??
|
|
18
|
+
groups.get("devDependencies")?.[packageName];
|
|
19
|
+
const name =
|
|
20
|
+
version?.startsWith("catalog:") === true ? version.slice(8) : undefined;
|
|
21
|
+
const resolved =
|
|
22
|
+
name === undefined
|
|
23
|
+
? version
|
|
24
|
+
: name === ""
|
|
25
|
+
? (groups.get("workspaces.catalog")?.[packageName] ??
|
|
26
|
+
groups.get("catalog")?.[packageName])
|
|
27
|
+
: (groups.get(`workspaces.catalogs.${name}`)?.[packageName] ??
|
|
28
|
+
groups.get(`catalogs.${name}`)?.[packageName]);
|
|
29
|
+
return resolved !== undefined && PLAIN.test(resolved)
|
|
30
|
+
? []
|
|
31
|
+
: [
|
|
32
|
+
{
|
|
33
|
+
file: "package.json",
|
|
34
|
+
message:
|
|
35
|
+
"pin @milkenjoyer/toolchain to an exact version or an exact catalog entry",
|
|
36
|
+
},
|
|
37
|
+
];
|
|
38
|
+
});
|
|
39
|
+
export const lintPackage: Rule = (repo) =>
|
|
40
|
+
Effect.succeed(
|
|
41
|
+
["packages/lint", "packages/oxlint-standards"]
|
|
42
|
+
.filter((dir) => repo.tracked.some((file) => file.startsWith(`${dir}/`)))
|
|
43
|
+
.map((file) => ({ file, message: "remove this repo-owned lint package" }))
|
|
44
|
+
);
|
|
45
|
+
export const nodeVersion: Rule = (repo) =>
|
|
46
|
+
Effect.gen(function* () {
|
|
47
|
+
const actual = yield* read(repo, ".node-version", (text) => text.trim());
|
|
48
|
+
if (!actual.ok) return actual.findings;
|
|
49
|
+
const fs = yield* FileSystem;
|
|
50
|
+
const expected = yield* fs.readFileString(
|
|
51
|
+
fileURLToPath(new URL("../../node-version", import.meta.url))
|
|
52
|
+
);
|
|
53
|
+
return actual.value === expected.trim()
|
|
54
|
+
? []
|
|
55
|
+
: [
|
|
56
|
+
{
|
|
57
|
+
file: ".node-version",
|
|
58
|
+
message: `set Node version to ${expected.trim()}`,
|
|
59
|
+
},
|
|
60
|
+
];
|
|
61
|
+
});
|
|
62
|
+
const Renovate = Schema.Struct({ extends: Schema.Array(Schema.String) });
|
|
63
|
+
const parseRenovate = Schema.decodeUnknownSync(Schema.fromJsonString(Renovate));
|
|
64
|
+
export const renovate: Rule = (repo) =>
|
|
65
|
+
Effect.gen(function* () {
|
|
66
|
+
const input = yield* read(repo, "renovate.json", parseRenovate);
|
|
67
|
+
if (!input.ok) return input.findings;
|
|
68
|
+
const preset =
|
|
69
|
+
"https://cdn.jsdelivr.net/npm/@milkenjoyer/toolchain/renovate.json";
|
|
70
|
+
return input.value.extends.includes(preset)
|
|
71
|
+
? []
|
|
72
|
+
: [{ file: "renovate.json", message: `extend ${preset}` }];
|
|
73
|
+
});
|
|
74
|
+
export const exact: Rule = (repo) =>
|
|
75
|
+
Effect.gen(function* () {
|
|
76
|
+
const findings: Finding[] = [];
|
|
77
|
+
for (const file of repo.tracked.filter((f) =>
|
|
78
|
+
/(?:^|\/)package\.json$/u.test(f)
|
|
79
|
+
)) {
|
|
80
|
+
const input = yield* read(repo, file, (text) =>
|
|
81
|
+
exactFindings(file, text)
|
|
82
|
+
);
|
|
83
|
+
findings.push(
|
|
84
|
+
...(input.ok
|
|
85
|
+
? input.value.map((message) => ({ file, message }))
|
|
86
|
+
: input.findings)
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
return findings;
|
|
90
|
+
});
|
package/src/standard.ts
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
#!/usr/bin/env bun
|
|
2
|
+
import { NodeServices } from "@effect/platform-node";
|
|
3
|
+
import * as Cause from "effect/Cause";
|
|
4
|
+
import * as Console from "effect/Console";
|
|
5
|
+
import * as Effect from "effect/Effect";
|
|
6
|
+
import * as Exit from "effect/Exit";
|
|
7
|
+
import { ChildProcess } from "effect/process";
|
|
8
|
+
import * as Stream from "effect/Stream";
|
|
9
|
+
|
|
10
|
+
import { rules } from "./standard/checks.ts";
|
|
11
|
+
import { load, StandardError, type Finding } from "./standard/repo.ts";
|
|
12
|
+
|
|
13
|
+
const singleLine = (message: string) => message.replaceAll(/\s+/gu, " ").trim();
|
|
14
|
+
export const standard = Effect.fn("standard")(function* (root: string) {
|
|
15
|
+
const repo = yield* load(root);
|
|
16
|
+
const findings: (Finding & { rule: string; order: number })[] = [];
|
|
17
|
+
for (const [order, [name, rule]] of Object.entries(rules).entries()) {
|
|
18
|
+
const problems = yield* rule(repo);
|
|
19
|
+
findings.push(
|
|
20
|
+
...problems.map((problem) => ({ ...problem, rule: name, order }))
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
findings.sort((a, b) => a.file.localeCompare(b.file) || a.order - b.order);
|
|
24
|
+
if (findings.length) {
|
|
25
|
+
for (const f of findings)
|
|
26
|
+
yield* Console.error(`${f.file}: ${f.rule}: ${singleLine(f.message)}`);
|
|
27
|
+
yield* Console.error(
|
|
28
|
+
`standard: ${findings.length} ${findings.length === 1 ? "finding" : "findings"}`
|
|
29
|
+
);
|
|
30
|
+
} else
|
|
31
|
+
yield* Console.log(
|
|
32
|
+
`standard: ${Object.keys(rules).length} rules, no findings`
|
|
33
|
+
);
|
|
34
|
+
return findings.length ? 1 : 0;
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
if (import.meta.main) {
|
|
38
|
+
if (process.argv.length > 2) {
|
|
39
|
+
process.stderr.write("usage: standard\n");
|
|
40
|
+
process.exitCode = 2;
|
|
41
|
+
} else {
|
|
42
|
+
const exit = await Effect.runPromiseExit(
|
|
43
|
+
Effect.scoped(
|
|
44
|
+
Effect.gen(function* () {
|
|
45
|
+
const git = yield* ChildProcess.make(
|
|
46
|
+
"git",
|
|
47
|
+
["rev-parse", "--show-toplevel"],
|
|
48
|
+
{ stdin: "ignore" }
|
|
49
|
+
);
|
|
50
|
+
const [root, code] = yield* Effect.all(
|
|
51
|
+
[git.stdout.pipe(Stream.decodeText, Stream.mkString), git.exitCode],
|
|
52
|
+
{ concurrency: "unbounded" }
|
|
53
|
+
);
|
|
54
|
+
if (Number(code) !== 0)
|
|
55
|
+
return yield* new StandardError({
|
|
56
|
+
message: "run standard inside a git repository",
|
|
57
|
+
});
|
|
58
|
+
return yield* standard(root.trim());
|
|
59
|
+
})
|
|
60
|
+
).pipe(Effect.provide(NodeServices.layer))
|
|
61
|
+
);
|
|
62
|
+
if (Exit.isSuccess(exit)) process.exitCode = exit.value;
|
|
63
|
+
else {
|
|
64
|
+
const error = Cause.squash(exit.cause);
|
|
65
|
+
process.stderr.write(
|
|
66
|
+
`standard: ${singleLine(error instanceof Error ? error.message : String(error))}\n`
|
|
67
|
+
);
|
|
68
|
+
process.exitCode = 1;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|