@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/dist/guard.d.mts CHANGED
@@ -4,12 +4,12 @@ import { t as Catalog } from "./versions-D02TrtKw.mjs";
4
4
  import { OxlintConfig } from "vite-plus/lint";
5
5
  type Ranges = Readonly<Record<string, string>>;
6
6
  export declare const manifestRanges: (text: string) => ReadonlyArray<readonly [string, Ranges]>;
7
- export declare const isFoldkitViteInput: (file: string) => boolean;
8
- export declare const foldkitViteFindings: (files: ReadonlyArray<readonly [string, string]>) => ReadonlyArray<string>;
9
7
  export declare const exactFindings: {
10
8
  (text: string): (file: string) => ReadonlyArray<string>;
11
9
  (file: string, text: string): ReadonlyArray<string>;
12
10
  };
11
+ export declare const isFoldkitViteInput: (file: string) => boolean;
12
+ export declare const foldkitViteFindings: (files: ReadonlyArray<readonly [string, string]>) => ReadonlyArray<string>;
13
13
  export declare const pinFindings: {
14
14
  (text: string, rootCatalog?: Ranges): (file: string) => ReadonlyArray<string>;
15
15
  (file: string, text: string, rootCatalog?: Ranges): ReadonlyArray<string>;
package/dist/guard.mjs CHANGED
@@ -2,6 +2,7 @@ import { d as otherTags, l as latestOf, u as onLatestLine } from "./compatible-D
2
2
  import { i as enforcedTsgoRules } from "./effect-tsgo-D0QfeKGD.mjs";
3
3
  import { t as exceptions } from "./exceptions-Dybl9xpc.mjs";
4
4
  import { a as toolchainScopes, n as effectRules, r as foldkitPreset, t as birbprophetRules } from "./lint-IhmtnBbx.mjs";
5
+ import { n as exactFindings, r as manifestRanges } from "./manifest-xQwgnYI1.mjs";
5
6
  import { c as lead, f as versionOf } from "./versions-C7LKZGr3.mjs";
6
7
  import * as Arr from "effect/Array";
7
8
  import { dual } from "effect/Function";
@@ -10,52 +11,7 @@ import * as Option from "effect/Option";
10
11
  import * as R from "effect/Record";
11
12
  import * as Schema from "effect/Schema";
12
13
  import * as Str from "effect/String";
13
- import * as Effect from "effect/Effect";
14
- import * as Result from "effect/Result";
15
14
  // src/guard.ts
16
- const Versions = Schema.Record(Schema.String, Schema.String).pipe(Schema.withDecodingDefaultKey(Effect.succeed({})));
17
- const Catalogs = Schema.Record(Schema.String, Schema.Record(Schema.String, Schema.String)).pipe(Schema.withDecodingDefaultKey(Effect.succeed({})));
18
- const WorkspaceList = Schema.Array(Schema.String);
19
- const WorkspaceCatalogs = Schema.Struct({
20
- catalog: Versions,
21
- catalogs: Catalogs
22
- });
23
- const Manifest = Schema.fromJsonString(Schema.Struct({
24
- dependencies: Versions,
25
- devDependencies: Versions,
26
- peerDependencies: Versions,
27
- optionalDependencies: Versions,
28
- overrides: Versions,
29
- resolutions: Versions,
30
- catalog: Versions,
31
- catalogs: Catalogs,
32
- workspaces: Schema.optionalKey(Schema.Union([WorkspaceList, WorkspaceCatalogs]))
33
- }));
34
- const named = (prefix, catalogs) => Arr.map(R.toEntries(catalogs), ([name, ranges]) => [`${prefix}.${name}`, ranges]);
35
- const manifestRanges = (text) => {
36
- const decoded = Schema.decodeResult(Manifest)(text);
37
- if (Result.isFailure(decoded)) throw decoded.failure;
38
- const manifest = decoded.success;
39
- const workspaces = Schema.is(WorkspaceCatalogs)(manifest.workspaces) ? manifest.workspaces : {
40
- catalog: {},
41
- catalogs: {}
42
- };
43
- return [
44
- ["dependencies", manifest.dependencies],
45
- ["devDependencies", manifest.devDependencies],
46
- ["peerDependencies", manifest.peerDependencies],
47
- ["optionalDependencies", manifest.optionalDependencies],
48
- ["overrides", manifest.overrides],
49
- ["resolutions", manifest.resolutions],
50
- ["catalog", manifest.catalog],
51
- ["workspaces.catalog", workspaces.catalog],
52
- ...named("catalogs", manifest.catalogs),
53
- ...named("workspaces.catalogs", workspaces.catalogs)
54
- ];
55
- };
56
- const SEMVER = String.raw`\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?`;
57
- const EXACT = new RegExp(String.raw`^(?:npm:(?:@[\w.-]+\/)?[\w.-]+@)?${SEMVER}$`, "u");
58
- const REFERENCE = /^(?:catalog:[\w.-]*|workspace:\*)$/u;
59
15
  const DEPENDENCY_FIELDS = HashSet.fromIterable([
60
16
  "dependencies",
61
17
  "devDependencies",
@@ -71,7 +27,6 @@ const foldkitViteFindings = (files) => {
71
27
  const foldkitFolders = HashSet.fromIterable(Arr.flatMap(files, ([file, text]) => MANIFEST.test(file) && Arr.some(manifestRanges(text), ([field, ranges]) => HashSet.has(DEPENDENCY_FIELDS, field) && R.has(ranges, "foldkit")) ? [folderOf(file)] : []));
72
28
  return Arr.flatMap(files, ([config, source]) => VITE_CONFIG.test(config) && HashSet.has(foldkitFolders, folderOf(config)) && !VITE_PLUGIN.test(source) ? [`${config} builds a foldkit package without @foldkit/vite-plugin, so view identity isn't stamped and keyed patching breaks`] : []);
73
29
  };
74
- const exactFindings = dual(2, (file, text) => Arr.flatMap(manifestRanges(text), ([field, ranges]) => Arr.flatMap(R.toEntries(ranges), ([name, version]) => EXACT.test(version) || REFERENCE.test(version) ? [] : [`${file} ${field} ${name}: ${version} is not an exact version`])));
75
30
  const pinFindings = dual((args) => Schema.is(Schema.String)(args[1]), (file, text, rootCatalog = {}) => Arr.flatMap(manifestRanges(text), ([field, ranges]) => Arr.flatMap(R.toEntries(ranges), ([name, written]) => Option.match(versionOf(name), {
76
31
  onNone: () => [],
77
32
  onSome: (pinnedVersion) => {
package/dist/knip.mjs CHANGED
@@ -2,7 +2,8 @@
2
2
  const baseEntry = [
3
3
  "*.run.ts",
4
4
  "scripts/*.ts",
5
- "tests/fixtures/**/*.ts"
5
+ "tests/fixtures/**/*.ts",
6
+ "**/*.proof.ts"
6
7
  ];
7
8
  const toolchainPlugins = ["@effect/language-service", "@foldkit/oxlint-plugin"];
8
9
  const knip = ({ entry = [], ignoreDependencies = [], workspaces = {} } = {}) => ({
@@ -0,0 +1,53 @@
1
+ import * as Arr from "effect/Array";
2
+ import { dual } from "effect/Function";
3
+ import * as R from "effect/Record";
4
+ import * as Schema from "effect/Schema";
5
+ import * as Effect from "effect/Effect";
6
+ import * as Result from "effect/Result";
7
+ // src/standard/manifest.ts
8
+ const Versions = Schema.Record(Schema.String, Schema.String).pipe(Schema.withDecodingDefaultKey(Effect.succeed({})));
9
+ const Catalogs = Schema.Record(Schema.String, Schema.Record(Schema.String, Schema.String)).pipe(Schema.withDecodingDefaultKey(Effect.succeed({})));
10
+ const WorkspaceList = Schema.Array(Schema.String);
11
+ const WorkspaceCatalogs = Schema.Struct({
12
+ catalog: Versions,
13
+ catalogs: Catalogs
14
+ });
15
+ const Manifest = Schema.fromJsonString(Schema.Struct({
16
+ dependencies: Versions,
17
+ devDependencies: Versions,
18
+ peerDependencies: Versions,
19
+ optionalDependencies: Versions,
20
+ overrides: Versions,
21
+ resolutions: Versions,
22
+ catalog: Versions,
23
+ catalogs: Catalogs,
24
+ workspaces: Schema.optionalKey(Schema.Union([WorkspaceList, WorkspaceCatalogs]))
25
+ }));
26
+ const named = (prefix, catalogs) => Arr.map(R.toEntries(catalogs), ([name, ranges]) => [`${prefix}.${name}`, ranges]);
27
+ const manifestRanges = (text) => {
28
+ const decoded = Schema.decodeResult(Manifest)(text);
29
+ if (Result.isFailure(decoded)) throw decoded.failure;
30
+ const manifest = decoded.success;
31
+ const workspaces = Schema.is(WorkspaceCatalogs)(manifest.workspaces) ? manifest.workspaces : {
32
+ catalog: {},
33
+ catalogs: {}
34
+ };
35
+ return [
36
+ ["dependencies", manifest.dependencies],
37
+ ["devDependencies", manifest.devDependencies],
38
+ ["peerDependencies", manifest.peerDependencies],
39
+ ["optionalDependencies", manifest.optionalDependencies],
40
+ ["overrides", manifest.overrides],
41
+ ["resolutions", manifest.resolutions],
42
+ ["catalog", manifest.catalog],
43
+ ["workspaces.catalog", workspaces.catalog],
44
+ ...named("catalogs", manifest.catalogs),
45
+ ...named("workspaces.catalogs", workspaces.catalogs)
46
+ ];
47
+ };
48
+ const SEMVER = String.raw`\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?`;
49
+ const PLAIN = new RegExp(`^${SEMVER}$`, "u");
50
+ const EXACT = new RegExp(String.raw`^(?:npm:(?:@[\w.-]+\/)?[\w.-]+@)?${SEMVER}$`, "u");
51
+ const REFERENCE = /^(?:catalog:[\w.-]*|workspace:\*)$/u;
52
+ const exactFindings = dual(2, (file, text) => Arr.flatMap(manifestRanges(text), ([field, ranges]) => Arr.flatMap(R.toEntries(ranges), ([name, version]) => EXACT.test(version) || REFERENCE.test(version) ? [] : [`${file} ${field} ${name}: ${version} is not an exact version`])));
53
+ export { exactFindings as n, manifestRanges as r, PLAIN as t };
@@ -0,0 +1,135 @@
1
+ import * as Schema from "effect/Schema";
2
+ import * as Effect from "effect/Effect";
3
+ import * as Result from "effect/Result";
4
+ import * as SchemaIssue from "effect/SchemaIssue";
5
+ // src/formal/critical.ts
6
+ const matches = (glob, file) => new Bun.Glob(glob).match(file);
7
+ const criticalFindings = (repo) => [
8
+ ...repo.file.critical.flatMap((glob) => repo.tracked.some((f) => matches(glob, f)) ? [] : [{
9
+ file: "specs.json",
10
+ message: `critical glob ${glob} matches no tracked file`
11
+ }]),
12
+ ...Object.entries({
13
+ ...repo.file.specs,
14
+ ...repo.file.kani,
15
+ ...repo.file.proofs
16
+ }).flatMap(([file, e]) => e.covers.flatMap((glob) => repo.tracked.some((f) => matches(glob, f)) ? [] : [{
17
+ file,
18
+ message: `covers glob ${glob} matches no tracked file`
19
+ }])),
20
+ ...repo.tracked.flatMap((file) => {
21
+ const glob = repo.file.critical.find((g) => matches(g, file));
22
+ return glob !== void 0 && !Object.values({
23
+ ...repo.file.specs,
24
+ ...repo.file.kani,
25
+ ...repo.file.proofs
26
+ }).some((e) => (!("mode" in e) || e.mode !== "library") && e.covers.some((g) => matches(g, file))) ? [{
27
+ file,
28
+ message: `matches critical glob ${glob} but no spec covers it`
29
+ }] : [];
30
+ })
31
+ ];
32
+ // src/formal/specs-file.ts
33
+ const RepoPath = Schema.String.check(Schema.isPattern(/^(?!\/)(?!(?:.*\/)?\.\.(?:\/|$))[^\0\\]+$/u));
34
+ const OperatorName = Schema.String.check(Schema.isPattern(/^[A-Za-z_][A-Za-z0-9_]*$/u));
35
+ const Common = {
36
+ synced: Schema.String.check(Schema.isPattern(/^[0-9a-f]{40}$/u)),
37
+ covers: Schema.NonEmptyArray(Schema.NonEmptyString)
38
+ };
39
+ const Runtime = {
40
+ ...Common,
41
+ timeoutSeconds: Schema.Int.check(Schema.isBetween({
42
+ minimum: 1,
43
+ maximum: 1800
44
+ })).pipe(Schema.withDecodingDefaultKey(Effect.succeed(60)))
45
+ };
46
+ const Proof = {
47
+ ...Runtime,
48
+ witnesses: Schema.NonEmptyArray(OperatorName).check(Schema.makeFilter((names) => new Set(names).size === names.length || "witnesses must be unique")),
49
+ breaks: Schema.Array(Schema.Struct({
50
+ violates: OperatorName,
51
+ find: Schema.NonEmptyString,
52
+ replace: Schema.String,
53
+ file: Schema.optionalKey(RepoPath)
54
+ })).pipe(Schema.withDecodingDefaultKey(Effect.succeed([])))
55
+ };
56
+ const Entry = Schema.Union([
57
+ Schema.Struct({
58
+ ...Proof,
59
+ mode: Schema.Literal("gate"),
60
+ traces: Schema.optionalKey(Schema.Struct({
61
+ seed: Schema.Int.check(Schema.isGreaterThanOrEqualTo(0)),
62
+ depth: Schema.Int.check(Schema.isBetween({
63
+ minimum: 1,
64
+ maximum: 1e4
65
+ })),
66
+ count: Schema.Int.check(Schema.isBetween({
67
+ minimum: 1,
68
+ maximum: 1e5
69
+ })),
70
+ steer: Schema.optionalKey(Schema.Record(OperatorName, Schema.Int.check(Schema.isBetween({
71
+ minimum: 2,
72
+ maximum: 1e3
73
+ })))),
74
+ conformance: RepoPath
75
+ }))
76
+ }),
77
+ Schema.Struct({
78
+ ...Proof,
79
+ mode: Schema.Literal("manual")
80
+ }),
81
+ Schema.Struct({
82
+ ...Common,
83
+ mode: Schema.Literal("library")
84
+ })
85
+ ]);
86
+ const ArithmeticCommon = {
87
+ covers: Common.covers,
88
+ timeoutSeconds: Runtime.timeoutSeconds,
89
+ breaks: Schema.NonEmptyArray(Schema.Struct({
90
+ file: RepoPath,
91
+ find: Schema.NonEmptyString,
92
+ replace: Schema.String
93
+ }))
94
+ };
95
+ const ArithmeticProof = Schema.Union([Schema.Struct({
96
+ ...ArithmeticCommon,
97
+ kind: Schema.Literal("every")
98
+ }), Schema.Struct({
99
+ ...ArithmeticCommon,
100
+ kind: Schema.Literal("z3"),
101
+ samples: Schema.Int.check(Schema.isBetween({
102
+ minimum: 1e4,
103
+ maximum: 1e6
104
+ })).pipe(Schema.withDecodingDefaultKey(Effect.succeed(1e4)))
105
+ })]);
106
+ const SpecsFile = Schema.Struct({
107
+ critical: Schema.NonEmptyArray(Schema.NonEmptyString),
108
+ arithmetic: Schema.optionalKey(Schema.Array(Schema.NonEmptyString)),
109
+ proofs: Schema.Record(RepoPath.check(Schema.isPattern(/\.proof\.ts$/u)), ArithmeticProof).pipe(Schema.withDecodingDefaultKey(Effect.succeed({}))),
110
+ specs: Schema.Record(RepoPath.check(Schema.isPattern(/\.tla$/u)), Entry),
111
+ kani: Schema.Record(RepoPath.check(Schema.isPattern(/\.rs$/u)), Schema.Struct({
112
+ ...Runtime,
113
+ mode: Schema.Literals(["gate", "manual"])
114
+ })).pipe(Schema.withDecodingDefaultKey(Effect.succeed({})))
115
+ });
116
+ const decode = (raw) => {
117
+ let file = {
118
+ critical: [],
119
+ specs: {},
120
+ kani: {},
121
+ proofs: {}
122
+ };
123
+ let decodeErrors = [];
124
+ const decoded = Schema.decodeResult(Schema.fromJsonString(SpecsFile))(raw, {
125
+ errors: "all",
126
+ onExcessProperty: "error"
127
+ });
128
+ if (Result.isSuccess(decoded)) file = decoded.success;
129
+ else decodeErrors = SchemaIssue.makeFormatterStandardSchemaV1()(decoded.failure.issue).issues.map(({ message, path: at = [] }) => at.length === 0 ? message : `${at.map((key) => `[${JSON.stringify(typeof key === "object" ? key.key : key)}]`).join("")}: ${message}`);
130
+ return {
131
+ file,
132
+ decodeErrors
133
+ };
134
+ };
135
+ export { criticalFindings as n, decode as t };
@@ -0,0 +1,2 @@
1
+ import * as Effect from "effect/Effect";
2
+ export declare const standard: (root: string) => Effect.Effect<0 | 1, unknown, import("effect/process/ChildProcessSpawner").ChildProcessSpawner | import("effect/FileSystem").FileSystem | import("effect/Path").Path | import("effect/Scope").Scope>;
@@ -0,0 +1,398 @@
1
+ #!/usr/bin/env bun
2
+ import { n as criticalFindings, t as decode } from "./specs-file-NsQF4V7X.mjs";
3
+ import { n as exactFindings, r as manifestRanges, t as PLAIN } from "./manifest-xQwgnYI1.mjs";
4
+ import * as Schema from "effect/Schema";
5
+ import * as Effect from "effect/Effect";
6
+ import { NodeServices } from "@effect/platform-node";
7
+ import * as Cause from "effect/Cause";
8
+ import * as Console from "effect/Console";
9
+ import * as Exit from "effect/Exit";
10
+ import { ChildProcess } from "effect/process";
11
+ import * as Stream from "effect/Stream";
12
+ import { FileSystem } from "effect/FileSystem";
13
+ import { fileURLToPath } from "node:url";
14
+ import { Path } from "effect/Path";
15
+ // src/standard/plugin-skills.ts
16
+ const pluginSkills = {
17
+ "agent-kit": [
18
+ "alchemy-domain",
19
+ "animation-performance",
20
+ "better-accessibility",
21
+ "break-ui",
22
+ "coordinate",
23
+ "diagnosing-bugs",
24
+ "formal-bug-hunt",
25
+ "interface-review",
26
+ "report-loop",
27
+ "task-agents",
28
+ "testing",
29
+ "writing-for-agents"
30
+ ],
31
+ pstack: [
32
+ "architect",
33
+ "arena",
34
+ "automate-me",
35
+ "benchmark-checklist",
36
+ "blast-radius",
37
+ "bro",
38
+ "correct",
39
+ "create-formal-verification-skill",
40
+ "create-verification-skill",
41
+ "figure-it-out",
42
+ "how",
43
+ "in-your-own-words",
44
+ "interrogate",
45
+ "ketchup",
46
+ "ketchup-video",
47
+ "maintain-formal-verification-skill",
48
+ "maintain-verification-skill",
49
+ "make-bot-ui",
50
+ "no-comments",
51
+ "poteto-help",
52
+ "poteto-mode",
53
+ "principle-attack-the-premise",
54
+ "principle-boundary-discipline",
55
+ "principle-build-the-lever",
56
+ "principle-encode-lessons-in-structure",
57
+ "principle-exhaust-the-design-space",
58
+ "principle-experience-first",
59
+ "principle-explain-the-number",
60
+ "principle-fix-root-causes",
61
+ "principle-foundational-thinking",
62
+ "principle-guard-the-context-window",
63
+ "principle-laziness-protocol",
64
+ "principle-make-operations-idempotent",
65
+ "principle-migrate-callers-then-delete-legacy-apis",
66
+ "principle-minimize-reader-load",
67
+ "principle-model-the-domain",
68
+ "principle-never-block-on-the-human",
69
+ "principle-outcome-oriented-execution",
70
+ "principle-prove-it-works",
71
+ "principle-redesign-from-first-principles",
72
+ "principle-separate-before-serializing-shared-state",
73
+ "principle-sequence-verifiable-units",
74
+ "principle-subtract-before-you-add",
75
+ "principle-test-behavior-not-implementation",
76
+ "principle-type-system-discipline",
77
+ "recall",
78
+ "reflect",
79
+ "setup-pstack",
80
+ "sharpen",
81
+ "show-me-your-work",
82
+ "statechart",
83
+ "swarm",
84
+ "tdd",
85
+ "teach",
86
+ "technical-writing",
87
+ "typescript-best-practices",
88
+ "unslop",
89
+ "why"
90
+ ],
91
+ tstack: [
92
+ "babysit-pr",
93
+ "council",
94
+ "file-pr",
95
+ "full-send",
96
+ "full-stop",
97
+ "leaving-pr-comments",
98
+ "modernize",
99
+ "sol-loop",
100
+ "takeover"
101
+ ],
102
+ effect: ["effect"]
103
+ };
104
+ // src/standard/repo.ts
105
+ var StandardError = class extends Schema.TaggedError()("StandardError", { message: Schema.String }) {};
106
+ const load = Effect.fn("standard.load")(function* (root) {
107
+ const fs = yield* FileSystem;
108
+ const path = yield* Path;
109
+ const git = yield* ChildProcess.make("git", ["ls-files", "-z"], {
110
+ cwd: root,
111
+ stdin: "ignore"
112
+ });
113
+ const [files, code] = yield* Effect.all([git.stdout.pipe(Stream.decodeText, Stream.mkString), git.exitCode], { concurrency: "unbounded" });
114
+ if (Number(code) !== 0) return yield* new StandardError({ message: "git ls-files failed" });
115
+ return {
116
+ root,
117
+ tracked: yield* Effect.filter(files.split("\0").filter(Boolean), (file) => fs.exists(path.join(root, file)))
118
+ };
119
+ });
120
+ const read = Effect.fn("standard.read")(function* (repo, file, parse) {
121
+ const fs = yield* FileSystem;
122
+ const path = yield* Path;
123
+ const failed = (message) => ({
124
+ ok: false,
125
+ findings: [{
126
+ file,
127
+ message
128
+ }]
129
+ });
130
+ if (!repo.tracked.includes(file)) return failed("track this file");
131
+ return yield* fs.readFileString(path.join(repo.root, file)).pipe(Effect.mapError(() => new StandardError({ message: "this file cannot be read" })), Effect.flatMap((text) => Effect.try({
132
+ try: () => parse(text),
133
+ catch: (error) => new StandardError({ message: `this file does not parse: ${String(error instanceof Error ? error.message : error).split("\n")[0]}` })
134
+ })), Effect.map((value) => ({
135
+ ok: true,
136
+ value
137
+ })), Effect.catchTag("StandardError", (error) => Effect.succeed(failed(error.message))));
138
+ });
139
+ // src/standard/agents.ts
140
+ const taskAgents = (repo) => Effect.gen(function* () {
141
+ const input = yield* read(repo, "AGENTS.md", (text) => text);
142
+ if (!input.ok) return input.findings;
143
+ const lines = input.value.split("\n");
144
+ const start = lines.findIndex((line) => /^## Task agents\s*$/u.test(line));
145
+ const section = [];
146
+ if (start !== -1) for (const line of lines.slice(start + 1)) {
147
+ if (/^#{1,6}\s/u.test(line)) break;
148
+ if (line.trim()) section.push(line.trim());
149
+ }
150
+ return section.length === 1 && section[0]?.includes("`agent-kit:task-agents`") === true ? [] : [{
151
+ file: "AGENTS.md",
152
+ message: "add a ## Task agents section containing only one line pointing to `agent-kit:task-agents`"
153
+ }];
154
+ });
155
+ const skillNames = (repo) => Effect.succeed(repo.tracked.flatMap((file) => {
156
+ const name = /^(?:\.agents|\.claude|\.codex)\/skills\/([^/]+)\/SKILL\.md$/u.exec(file)?.[1];
157
+ return name === void 0 ? [] : Object.entries(pluginSkills).flatMap(([plugin, names]) => names.includes(name) ? [{
158
+ file,
159
+ message: `shares its name with ${plugin}:${name}`
160
+ }] : []);
161
+ }));
162
+ // src/standard/config.ts
163
+ const lintFmt = (repo) => Effect.gen(function* () {
164
+ const path = yield* Path;
165
+ const roots = repo.tracked.filter((file) => /^vite\.config\.(?:ts|mts|js|mjs)$/u.test(file));
166
+ if (!roots.length) return [{
167
+ file: "vite.config.ts",
168
+ message: "track a root vite.config.ts, .mts, .js or .mjs"
169
+ }];
170
+ const pending = [...roots];
171
+ const visited = /* @__PURE__ */ new Set();
172
+ const imports = /* @__PURE__ */ new Set();
173
+ const findings = [];
174
+ const transpiler = new Bun.Transpiler({ loader: "ts" });
175
+ for (const file of pending) {
176
+ if (visited.has(file)) continue;
177
+ visited.add(file);
178
+ const input = yield* read(repo, file, (text) => transpiler.scanImports(text));
179
+ if (!input.ok) {
180
+ findings.push(...input.findings);
181
+ continue;
182
+ }
183
+ for (const item of input.value) {
184
+ imports.add(item.path);
185
+ if (!item.path.startsWith(".")) continue;
186
+ const stem = path.normalize(path.join(path.dirname(file), item.path));
187
+ const target = [
188
+ stem,
189
+ stem.replace(/\.(m?)js$/u, ".$1ts"),
190
+ ...[
191
+ ".ts",
192
+ ".mts",
193
+ ".js",
194
+ ".mjs"
195
+ ].map((ext) => stem + ext),
196
+ ...[
197
+ "ts",
198
+ "mts",
199
+ "js",
200
+ "mjs"
201
+ ].map((ext) => `${stem}/index.${ext}`)
202
+ ].find((candidate) => repo.tracked.includes(candidate));
203
+ if (target !== void 0) pending.push(target);
204
+ }
205
+ }
206
+ for (const area of ["lint", "fmt"]) {
207
+ const name = `@milkenjoyer/toolchain/${area}`;
208
+ if (!imports.has(name)) findings.push({
209
+ file: roots[0] ?? "vite.config.ts",
210
+ message: `import ${name} from the root Vite config or its relative imports`
211
+ });
212
+ }
213
+ return findings;
214
+ });
215
+ const Config = Schema.Struct({ extends: Schema.optionalKey(Schema.Union([Schema.String, Schema.Array(Schema.String)])) });
216
+ const tsconfig = (repo) => Effect.gen(function* () {
217
+ const path = yield* Path;
218
+ const pending = ["tsconfig.json"];
219
+ const visited = /* @__PURE__ */ new Set();
220
+ const findings = [];
221
+ let reached = false;
222
+ for (const file of pending) {
223
+ if (visited.has(file)) continue;
224
+ visited.add(file);
225
+ const input = yield* read(repo, file, (text) => Schema.decodeUnknownSync(Config)(Bun.JSONC.parse(text)));
226
+ if (!input.ok) {
227
+ findings.push(...input.findings);
228
+ continue;
229
+ }
230
+ const parents = typeof input.value.extends === "string" ? [input.value.extends] : input.value.extends ?? [];
231
+ for (const parent of parents) {
232
+ if (parent === "@milkenjoyer/toolchain/tsconfig.base.json") reached = true;
233
+ if (!parent.startsWith(".")) continue;
234
+ const stem = path.normalize(path.join(path.dirname(file), parent));
235
+ const target = [stem, `${stem}.json`].find((candidate) => repo.tracked.includes(candidate));
236
+ if (target !== void 0) pending.push(target);
237
+ else findings.push({
238
+ file: stem,
239
+ message: "track the relative tsconfig extends file"
240
+ });
241
+ }
242
+ }
243
+ if (!reached && !findings.length) findings.push({
244
+ file: "tsconfig.json",
245
+ message: "extend @milkenjoyer/toolchain/tsconfig.base.json through the extends chain"
246
+ });
247
+ return findings;
248
+ });
249
+ // src/standard/formal.ts
250
+ const specs = (repo) => Effect.gen(function* () {
251
+ if (!repo.tracked.includes("specs.json")) return [{
252
+ file: "specs.json",
253
+ message: "track specs.json with at least one spec entry"
254
+ }];
255
+ const input = yield* read(repo, "specs.json", decode);
256
+ if (!input.ok) return input.findings;
257
+ const { file, decodeErrors } = input.value;
258
+ if (decodeErrors.length) return decodeErrors.map((message) => ({
259
+ file: "specs.json",
260
+ message
261
+ }));
262
+ return [...Object.keys(file.specs).length ? [] : [{
263
+ file: "specs.json",
264
+ message: "add at least one spec entry"
265
+ }], ...criticalFindings({
266
+ tracked: repo.tracked,
267
+ file
268
+ })];
269
+ });
270
+ const Gates = {
271
+ if: Schema.optionalKey(Schema.Unknown),
272
+ "continue-on-error": Schema.optionalKey(Schema.Unknown)
273
+ };
274
+ const Workflow = Schema.Struct({ jobs: Schema.Record(Schema.String, Schema.Struct({
275
+ ...Gates,
276
+ steps: Schema.optionalKey(Schema.Array(Schema.Struct({
277
+ ...Gates,
278
+ run: Schema.optionalKey(Schema.String)
279
+ })))
280
+ })) });
281
+ const FALSE = /^\s*(?:\$\{\{\s*false\s*\}\}|false)\s*$/u;
282
+ const enforced = (gates) => gates.if !== false && !(typeof gates.if === "string" && FALSE.test(gates.if)) && (gates["continue-on-error"] === void 0 || gates["continue-on-error"] === false || typeof gates["continue-on-error"] === "string" && FALSE.test(gates["continue-on-error"]));
283
+ const readyFormal = (repo) => Effect.gen(function* () {
284
+ const file = [".github/workflows/ready.yml", ".github/workflows/ready.yaml"].find((name) => repo.tracked.includes(name));
285
+ if (file === void 0) return [{
286
+ file: ".github/workflows/ready.yml",
287
+ message: "track a ready workflow running vp exec formal"
288
+ }];
289
+ const input = yield* read(repo, file, (text) => Schema.decodeUnknownSync(Workflow)(Bun.YAML.parse(text)));
290
+ if (!input.ok) return input.findings;
291
+ return Object.values(input.value.jobs).some((job) => enforced(job) && (job.steps ?? []).some((step) => enforced(step) && (step.run ?? "").split("\n").some((line) => line.trim() === "vp exec formal"))) ? [] : [{
292
+ file,
293
+ message: "add a step with a vp exec formal line that no if: false or continue-on-error skips or ignores"
294
+ }];
295
+ });
296
+ // src/standard/toolchain.ts
297
+ const packageName = "@milkenjoyer/toolchain";
298
+ const pin = (repo) => Effect.gen(function* () {
299
+ const input = yield* read(repo, "package.json", manifestRanges);
300
+ if (!input.ok) return input.findings;
301
+ const groups = new Map(input.value);
302
+ const version = groups.get("dependencies")?.[packageName] ?? groups.get("devDependencies")?.[packageName];
303
+ const name = version?.startsWith("catalog:") === true ? version.slice(8) : void 0;
304
+ const resolved = name === void 0 ? version : name === "" ? groups.get("workspaces.catalog")?.[packageName] ?? groups.get("catalog")?.[packageName] : groups.get(`workspaces.catalogs.${name}`)?.[packageName] ?? groups.get(`catalogs.${name}`)?.[packageName];
305
+ return resolved !== void 0 && PLAIN.test(resolved) ? [] : [{
306
+ file: "package.json",
307
+ message: "pin @milkenjoyer/toolchain to an exact version or an exact catalog entry"
308
+ }];
309
+ });
310
+ const lintPackage = (repo) => Effect.succeed(["packages/lint", "packages/oxlint-standards"].filter((dir) => repo.tracked.some((file) => file.startsWith(`${dir}/`))).map((file) => ({
311
+ file,
312
+ message: "remove this repo-owned lint package"
313
+ })));
314
+ const nodeVersion = (repo) => Effect.gen(function* () {
315
+ const actual = yield* read(repo, ".node-version", (text) => text.trim());
316
+ if (!actual.ok) return actual.findings;
317
+ const expected = yield* (yield* FileSystem).readFileString(fileURLToPath(new URL("../../node-version", import.meta.url)));
318
+ return actual.value === expected.trim() ? [] : [{
319
+ file: ".node-version",
320
+ message: `set Node version to ${expected.trim()}`
321
+ }];
322
+ });
323
+ const Renovate = Schema.Struct({ extends: Schema.Array(Schema.String) });
324
+ const parseRenovate = Schema.decodeUnknownSync(Schema.fromJsonString(Renovate));
325
+ const renovate = (repo) => Effect.gen(function* () {
326
+ const input = yield* read(repo, "renovate.json", parseRenovate);
327
+ if (!input.ok) return input.findings;
328
+ const preset = "https://cdn.jsdelivr.net/npm/@milkenjoyer/toolchain/renovate.json";
329
+ return input.value.extends.includes(preset) ? [] : [{
330
+ file: "renovate.json",
331
+ message: `extend ${preset}`
332
+ }];
333
+ });
334
+ const exact = (repo) => Effect.gen(function* () {
335
+ const findings = [];
336
+ for (const file of repo.tracked.filter((f) => /(?:^|\/)package\.json$/u.test(f))) {
337
+ const input = yield* read(repo, file, (text) => exactFindings(file, text));
338
+ findings.push(...input.ok ? input.value.map((message) => ({
339
+ file,
340
+ message
341
+ })) : input.findings);
342
+ }
343
+ return findings;
344
+ });
345
+ // src/standard/checks.ts
346
+ const rules = {
347
+ "toolchain-pin": pin,
348
+ "lint-package": lintPackage,
349
+ "lint-fmt": lintFmt,
350
+ "tsconfig-base": tsconfig,
351
+ "node-version": nodeVersion,
352
+ "renovate-preset": renovate,
353
+ "exact-versions": exact,
354
+ specs,
355
+ "ready-formal": readyFormal,
356
+ "task-agents": taskAgents,
357
+ "skill-names": skillNames
358
+ };
359
+ // src/standard.ts
360
+ const singleLine = (message) => message.replaceAll(/\s+/gu, " ").trim();
361
+ const standard = Effect.fn("standard")(function* (root) {
362
+ const repo = yield* load(root);
363
+ const findings = [];
364
+ for (const [order, [name, rule]] of Object.entries(rules).entries()) {
365
+ const problems = yield* rule(repo);
366
+ findings.push(...problems.map((problem) => ({
367
+ ...problem,
368
+ rule: name,
369
+ order
370
+ })));
371
+ }
372
+ findings.sort((a, b) => a.file.localeCompare(b.file) || a.order - b.order);
373
+ if (findings.length) {
374
+ for (const f of findings) yield* Console.error(`${f.file}: ${f.rule}: ${singleLine(f.message)}`);
375
+ yield* Console.error(`standard: ${findings.length} ${findings.length === 1 ? "finding" : "findings"}`);
376
+ } else yield* Console.log(`standard: ${Object.keys(rules).length} rules, no findings`);
377
+ return findings.length ? 1 : 0;
378
+ });
379
+ if (import.meta.main) {
380
+ if (process.argv.length > 2) {
381
+ process.stderr.write("usage: standard\n");
382
+ process.exitCode = 2;
383
+ } else {
384
+ const exit = await Effect.runPromiseExit(Effect.scoped(Effect.gen(function* () {
385
+ const git = yield* ChildProcess.make("git", ["rev-parse", "--show-toplevel"], { stdin: "ignore" });
386
+ const [root, code] = yield* Effect.all([git.stdout.pipe(Stream.decodeText, Stream.mkString), git.exitCode], { concurrency: "unbounded" });
387
+ if (Number(code) !== 0) return yield* new StandardError({ message: "run standard inside a git repository" });
388
+ return yield* standard(root.trim());
389
+ })).pipe(Effect.provide(NodeServices.layer)));
390
+ if (Exit.isSuccess(exit)) process.exitCode = exit.value;
391
+ else {
392
+ const error = Cause.squash(exit.cause);
393
+ process.stderr.write(`standard: ${singleLine(error instanceof Error ? error.message : String(error))}\n`);
394
+ process.exitCode = 1;
395
+ }
396
+ }
397
+ }
398
+ export { standard };