@milkenjoyer/toolchain 0.18.0 → 0.20.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/starts.mjs CHANGED
@@ -1,310 +1,5 @@
1
1
  import * as Schema from "effect/Schema";
2
- import * as Effect from "effect/Effect";
3
- import * as Layer from "effect/Layer";
4
- import * as Clock from "effect/Clock";
5
- import * as Context from "effect/Context";
6
- import { Octokit } from "@octokit/rest";
7
- import * as Redacted from "effect/Redacted";
8
- import { BoatApi, CiJobState, Configuration } from "@boatdev/sdk";
9
2
  import { parse } from "yaml";
10
- // src/starts/budget.ts
11
- const Repo = Schema.String.check(Schema.isPattern(/^[\w.-]+\/[\w.-]+$/u)).pipe(Schema.brand("Repo"));
12
- const Window = Schema.Literals([
13
- "minute",
14
- "hour",
15
- "day"
16
- ]);
17
- const Line = Schema.Union([
18
- Schema.TaggedStruct("Unread", { reason: Schema.String }),
19
- Schema.TaggedStruct("Paid", { nextStartDollars: Schema.UndefinedOr(Schema.Number) }),
20
- Schema.TaggedStruct("Account", {
21
- window: Window,
22
- used: Schema.Number,
23
- line: Schema.Number
24
- }),
25
- Schema.TaggedStruct("Budget", {
26
- repo: Repo,
27
- window: Window,
28
- used: Schema.Number,
29
- budget: Schema.Number
30
- })
31
- ]);
32
- const windows$1 = [
33
- "minute",
34
- "hour",
35
- "day"
36
- ];
37
- const windowMillis = {
38
- minute: 6e4,
39
- hour: 36e5,
40
- day: 864e5
41
- };
42
- const pollMillis = {
43
- minute: 15e3,
44
- hour: 6e4,
45
- day: 3e5
46
- };
47
- const startRepos = [
48
- Repo.make("birbprophet/agent-kit"),
49
- Repo.make("siglata/siglata"),
50
- Repo.make("optionhouse-xyz/optionhouse"),
51
- Repo.make("birbprophet/vibebattler")
52
- ];
53
- const count = (value) => Number.isSafeInteger(value) && value >= 0;
54
- const ceiling = (request, plan, window) => Number(BigInt(plan.limits[window]) * (request.priority === "p0" ? 95n : 80n) / 100n);
55
- const sharedWindows = (request, plan) => request.priority === "p0" || plan.nextStartDollars !== 0 || !windows$1.every((window) => count(plan.limits[window]) && count(plan.used[window])) || windows$1.some((window) => plan.used[window] + request.jobs > ceiling(request, plan, window)) ? [] : windows$1.filter((window) => 2 * plan.used[window] >= plan.limits[window]);
56
- const liveShare = (repo, merges) => {
57
- if (merges === void 0 || merges.length !== startRepos.length || !startRepos.every((repo) => merges.filter((row) => row.repo === repo).length === 1) || !merges.every((row) => [
58
- row.h6,
59
- row.h24,
60
- row.d7
61
- ].every(count))) return void 0;
62
- const weights = merges.map((row) => ({
63
- repo: row.repo,
64
- weight: [
65
- 7n * BigInt(row.h24),
66
- 28n * BigInt(row.h6),
67
- BigInt(row.d7)
68
- ].reduce((largest, value) => value > largest ? value : largest, 0n)
69
- }));
70
- const total = weights.reduce((sum, row) => sum + row.weight, 0n);
71
- const weight = weights.find((row) => row.repo === repo)?.weight;
72
- return weight === void 0 ? void 0 : total === 0n ? {
73
- numerator: 1n,
74
- denominator: 4n
75
- } : {
76
- numerator: total + 6n * weight,
77
- denominator: 10n * total
78
- };
79
- };
80
- const unread = (reason) => ({
81
- _tag: "Hold",
82
- line: {
83
- _tag: "Unread",
84
- reason
85
- }
86
- });
87
- const decide = (request, counts, now) => {
88
- if (!startRepos.includes(request.repo)) return unread("repo has no start budget");
89
- if (!count(request.jobs) || request.jobs === 0) return unread("jobs must be a positive safe integer");
90
- if (!Number.isFinite(now)) return unread("start time unread");
91
- if (counts === void 0) return {
92
- _tag: "Wait",
93
- until: now + pollMillis.minute,
94
- line: {
95
- _tag: "Unread",
96
- reason: "start plan unread"
97
- }
98
- };
99
- if (!Number.isFinite(counts.now) || counts.now > now || !windows$1.every((window) => count(counts.plan.limits[window]) && count(counts.plan.used[window]))) return unread("start plan unread");
100
- const { plan } = counts;
101
- if (plan.nextStartDollars !== 0) return {
102
- _tag: "Wait",
103
- until: now + pollMillis.minute,
104
- line: {
105
- _tag: "Paid",
106
- nextStartDollars: plan.nextStartDollars
107
- }
108
- };
109
- for (const window of windows$1) {
110
- const used = plan.used[window];
111
- const line = ceiling(request, plan, window);
112
- if (used + request.jobs > line) return window === "day" ? {
113
- _tag: "Hold",
114
- line: {
115
- _tag: "Account",
116
- window,
117
- used,
118
- line
119
- }
120
- } : {
121
- _tag: "Wait",
122
- until: now + pollMillis[window],
123
- line: {
124
- _tag: "Account",
125
- window,
126
- used,
127
- line
128
- }
129
- };
130
- }
131
- const shared = sharedWindows(request, plan);
132
- if (shared.length === 0) return { _tag: "Admit" };
133
- if (counts.repo === void 0 || !counts.repo.complete) return {
134
- _tag: "Wait",
135
- until: now + pollMillis.minute,
136
- line: {
137
- _tag: "Unread",
138
- reason: "repo start history incomplete"
139
- }
140
- };
141
- if (counts.repo.repo !== request.repo || !counts.repo.starts.every((at) => Number.isFinite(at) && at <= counts.now)) return unread("repo start history incomplete");
142
- const share = liveShare(request.repo, counts.merges);
143
- if (share === void 0) return {
144
- _tag: "Wait",
145
- until: now + pollMillis.minute,
146
- line: {
147
- _tag: "Unread",
148
- reason: "merge history incomplete"
149
- }
150
- };
151
- for (const window of shared) {
152
- const starts = counts.repo.starts.filter((at) => at > now - windowMillis[window]).toSorted((left, right) => left - right);
153
- const used = starts.length;
154
- const budget = Number(share.numerator * 4n * BigInt(plan.limits[window]) / (share.denominator * 5n));
155
- if (used + request.jobs <= budget) continue;
156
- const line = {
157
- _tag: "Budget",
158
- repo: request.repo,
159
- window,
160
- used,
161
- budget
162
- };
163
- const expires = starts[used + request.jobs - budget - 1];
164
- return request.jobs > budget || expires === void 0 ? {
165
- _tag: "Hold",
166
- line
167
- } : {
168
- _tag: "Wait",
169
- until: expires + windowMillis[window],
170
- line
171
- };
172
- }
173
- return { _tag: "Admit" };
174
- };
175
- // src/starts/boat.ts
176
- var StartReadError = class extends Schema.TaggedError()("StartReadError", { reason: Schema.String }) {};
177
- const Count$1 = Schema.Number.check(Schema.makeFilter((value) => Number.isSafeInteger(value) && value >= 0));
178
- const Usage = Schema.Struct({
179
- limit: Count$1,
180
- used: Count$1
181
- });
182
- const Limits = Schema.Struct({
183
- ok: Schema.Literal(true),
184
- starts: Schema.Struct({
185
- minute: Usage,
186
- hour: Usage,
187
- day: Usage
188
- }),
189
- nextStartDollars: Schema.optional(Schema.NullOr(Schema.Finite))
190
- });
191
- const Ci = Schema.Struct({
192
- ok: Schema.Literal(true),
193
- jobs: Schema.Array(Schema.Struct({
194
- repo: Schema.String,
195
- label: Schema.String,
196
- state: Schema.String.check(Schema.isMinLength(1)),
197
- queuedAt: Schema.Date,
198
- runStartedAt: Schema.optional(Schema.NullOr(Schema.Date)),
199
- finishedAt: Schema.optional(Schema.NullOr(Schema.Date))
200
- }))
201
- });
202
- const settled = /* @__PURE__ */ new Set([
203
- CiJobState.Success,
204
- CiJobState.Failure,
205
- CiJobState.Cancelled,
206
- CiJobState.Skipped,
207
- CiJobState.Failed,
208
- CiJobState.Refused
209
- ]);
210
- var BoatStarts = class BoatStarts extends Context.Service()("toolchain/BoatStarts") {
211
- static layer = (key, options = {}) => Layer.sync(BoatStarts, () => {
212
- const api = new BoatApi(new Configuration({
213
- accessToken: Redacted.value(key),
214
- ...options.fetch === void 0 ? {} : { fetchApi: options.fetch }
215
- }));
216
- const plan = Effect.gen(function* () {
217
- const response = yield* Effect.tryPromise({
218
- try: () => api.limits(),
219
- catch: () => new StartReadError({ reason: "Boat limits request failed" })
220
- });
221
- const limits = yield* Schema.decodeUnknownEffect(Limits)(response).pipe(Effect.mapError(() => new StartReadError({ reason: "Boat limits unread" })));
222
- return {
223
- limits: {
224
- minute: limits.starts.minute.limit,
225
- hour: limits.starts.hour.limit,
226
- day: limits.starts.day.limit
227
- },
228
- used: {
229
- minute: limits.starts.minute.used,
230
- hour: limits.starts.hour.used,
231
- day: limits.starts.day.used
232
- },
233
- nextStartDollars: limits.nextStartDollars ?? void 0
234
- };
235
- });
236
- const repoStarts = Effect.fn("BoatStarts.repoStarts")(function* (repo) {
237
- const response = yield* Effect.tryPromise({
238
- try: () => api.getCiOverview({
239
- repo,
240
- limit: 500
241
- }),
242
- catch: () => new StartReadError({ reason: "Boat CI request failed" })
243
- });
244
- const now = yield* Clock.currentTimeMillis;
245
- const { jobs } = yield* Schema.decodeUnknownEffect(Ci)(response).pipe(Effect.mapError(() => new StartReadError({ reason: "Boat CI history unread" })));
246
- if (jobs.some((job) => job.repo !== repo)) return yield* new StartReadError({ reason: "Boat CI history differs from request" });
247
- const oldest = Math.min(...jobs.map((job) => Math.max(job.queuedAt.getTime(), job.runStartedAt?.getTime() ?? 0)));
248
- return {
249
- repo,
250
- starts: jobs.flatMap((job) => {
251
- const at = job.runStartedAt?.getTime() ?? (settled.has(job.state) || job.finishedAt !== void 0 && job.finishedAt !== null ? void 0 : now);
252
- return job.label.split("/")[0]?.startsWith("boat") === true && at !== void 0 && at > now - windowMillis.day ? [Math.min(at, now)] : [];
253
- }),
254
- complete: jobs.length < 500 || oldest <= now - windowMillis.day
255
- };
256
- });
257
- return BoatStarts.of({
258
- plan,
259
- repoStarts
260
- });
261
- });
262
- };
263
- // src/starts/merges.ts
264
- const Count = Schema.Struct({ issueCount: Schema.Number.check(Schema.makeFilter((value) => Number.isSafeInteger(value) && value >= 0)) });
265
- const windows = {
266
- h6: 216e5,
267
- h24: 864e5,
268
- d7: 6048e5
269
- };
270
- var Merges = class Merges extends Context.Service()("toolchain/Merges") {
271
- static layer = (token, options = {}) => Layer.sync(Merges, () => {
272
- const api = new Octokit({
273
- auth: Redacted.value(token),
274
- ...options.fetch === void 0 ? {} : { request: { fetch: options.fetch } }
275
- });
276
- const counts = Effect.gen(function* () {
277
- const now = yield* Clock.currentTimeMillis;
278
- const query = `query { ${startRepos.flatMap((repo, index) => {
279
- const [owner, name] = repo.split("/");
280
- return [`repo${index}: repository(owner: "${owner}", name: "${name}") { nameWithOwner }`, ...Object.entries(windows).map(([window, millis]) => {
281
- return `${window}_${index}: search(type: ISSUE, first: 0, query: "repo:${repo} is:pr is:merged base:main merged:>=${new Date(now - millis).toISOString().replace(/\.\d{3}Z$/u, "Z")}") { issueCount }`;
282
- })];
283
- }).join(" ")} }`;
284
- const response = yield* Effect.tryPromise({
285
- try: () => api.graphql(query),
286
- catch: () => new StartReadError({ reason: "GitHub merges request failed" })
287
- });
288
- return yield* Schema.decodeUnknownEffect(Schema.Record(Schema.String, Schema.Unknown))(response).pipe(Effect.flatMap((data) => Effect.forEach(startRepos, (repo, index) => Schema.decodeUnknownEffect(Schema.Struct({
289
- repository: Schema.Struct({ nameWithOwner: Schema.Literal(repo) }),
290
- h6: Count,
291
- h24: Count,
292
- d7: Count
293
- }))({
294
- repository: data[`repo${index}`],
295
- h6: data[`h6_${index}`],
296
- h24: data[`h24_${index}`],
297
- d7: data[`d7_${index}`]
298
- }).pipe(Effect.map((row) => ({
299
- repo,
300
- h6: row.h6.issueCount,
301
- h24: row.h24.issueCount,
302
- d7: row.d7.issueCount
303
- }))), { concurrency: 1 })), Effect.mapError(() => new StartReadError({ reason: "GitHub merges unread" })));
304
- });
305
- return Merges.of({ counts });
306
- });
307
- };
308
3
  // src/starts/policy.ts
309
4
  const BOAT_JOBS_PER_RUN = 2;
310
5
  const Matrix = Schema.Record(Schema.String, Schema.Array(Schema.Unknown));
@@ -432,47 +127,4 @@ const boatJobFindings = (files) => {
432
127
  }
433
128
  return [...new Set(findings)];
434
129
  };
435
- // src/starts.ts
436
- var StartHeld = class extends Schema.TaggedError()("StartHeld", { line: Line }) {};
437
- const admitStart = Effect.fn("Starts.admitStart")(function* (request, start, { deadline }) {
438
- const boat = yield* BoatStarts;
439
- const merges = yield* Merges;
440
- let last = {
441
- _tag: "Unread",
442
- reason: "start deadline reached"
443
- };
444
- for (;;) {
445
- const remaining = deadline - (yield* Clock.currentTimeMillis);
446
- if (!Number.isFinite(remaining) || remaining <= 0) return yield* new StartHeld({ line: last });
447
- const counts = yield* Effect.gen(function* () {
448
- const plan = yield* boat.plan;
449
- if (sharedWindows(request, plan).length === 0) return {
450
- now: yield* Clock.currentTimeMillis,
451
- plan
452
- };
453
- const repo = yield* boat.repoStarts(request.repo).pipe(Effect.catchTag("StartReadError", () => Effect.undefined));
454
- const history = yield* merges.counts.pipe(Effect.catchTag("StartReadError", () => Effect.undefined));
455
- return {
456
- now: yield* Clock.currentTimeMillis,
457
- plan,
458
- repo,
459
- merges: history
460
- };
461
- }).pipe(Effect.catchTag("StartReadError", () => Effect.undefined), Effect.timeoutOrElse({
462
- duration: remaining,
463
- orElse: () => Effect.fail(new StartHeld({ line: last }))
464
- }));
465
- const now = yield* Clock.currentTimeMillis;
466
- const decision = decide(request, counts, now);
467
- if (decision._tag === "Hold") return yield* new StartHeld({ line: decision.line });
468
- if (!Number.isFinite(deadline) || now >= deadline) return yield* new StartHeld({ line: decision._tag === "Wait" ? decision.line : {
469
- _tag: "Unread",
470
- reason: "start deadline reached"
471
- } });
472
- if (decision._tag === "Admit") return yield* start;
473
- last = decision.line;
474
- const window = decision.line._tag === "Account" || decision.line._tag === "Budget" ? decision.line.window : "minute";
475
- yield* Effect.sleep(Math.max(0, Math.min(decision.until, now + pollMillis[window], deadline) - now));
476
- }
477
- });
478
- export { BOAT_JOBS_PER_RUN, BoatStarts, Merges, Repo, StartHeld, StartReadError, admitStart, boatJobFindings, decide, startRepos };
130
+ export { BOAT_JOBS_PER_RUN, boatJobFindings };
@@ -5,17 +5,17 @@ import * as R from "effect/Record";
5
5
  import * as Schema from "effect/Schema";
6
6
  import * as Str from "effect/String";
7
7
  // src/versions.ts
8
- const nodeVersion = "26.13.0";
8
+ const nodeVersion = "26.13.1";
9
9
  const families = [
10
10
  {
11
11
  name: "vite-plus",
12
- version: "1.5.0",
12
+ version: "1.6.0",
13
13
  packages: ["vite-plus"],
14
14
  scopes: []
15
15
  },
16
16
  {
17
17
  name: "alchemy",
18
- version: "2.0.0-beta.85",
18
+ version: "2.0.0-beta.87",
19
19
  packages: [
20
20
  "@alchemy.run/domain",
21
21
  "alchemy",
@@ -50,7 +50,7 @@ const families = [
50
50
  },
51
51
  {
52
52
  name: "effect",
53
- version: "4.1.2",
53
+ version: "4.1.4",
54
54
  packages: [
55
55
  "effect",
56
56
  "@effect/platform-browser",
@@ -63,13 +63,13 @@ const families = [
63
63
  },
64
64
  {
65
65
  name: "@effect/tsgo",
66
- version: "0.67.3",
66
+ version: "0.69.0",
67
67
  packages: ["@effect/tsgo"],
68
68
  scopes: []
69
69
  },
70
70
  {
71
71
  name: "ultracite",
72
- version: "8.1.1",
72
+ version: "8.2.1",
73
73
  packages: ["ultracite"],
74
74
  scopes: []
75
75
  },
@@ -81,7 +81,7 @@ const families = [
81
81
  },
82
82
  {
83
83
  name: "effect-oxlint",
84
- version: "0.4.0",
84
+ version: "0.5.1",
85
85
  packages: ["effect-oxlint"],
86
86
  scopes: []
87
87
  },
@@ -95,22 +95,22 @@ const families = [
95
95
  const fixed = [
96
96
  {
97
97
  name: "oxlint",
98
- version: "1.91.0",
98
+ version: "1.93.0",
99
99
  by: "vite-plus"
100
100
  },
101
101
  {
102
102
  name: "@oxlint/plugins",
103
- version: "1.91.0",
103
+ version: "1.93.0",
104
104
  by: "vite-plus"
105
105
  },
106
106
  {
107
107
  name: "oxlint-tsgolint",
108
- version: "7.0.2005",
108
+ version: "7.0.2006",
109
109
  by: "vite-plus"
110
110
  },
111
111
  {
112
112
  name: "oxfmt",
113
- version: "0.76.0",
113
+ version: "0.78.0",
114
114
  by: "vite-plus"
115
115
  },
116
116
  {
@@ -120,7 +120,7 @@ const fixed = [
120
120
  },
121
121
  {
122
122
  name: "vite",
123
- version: "npm:@voidzero-dev/vite-plus-core@1.5.0",
123
+ version: "npm:@voidzero-dev/vite-plus-core@1.6.0",
124
124
  by: "vite-plus"
125
125
  }
126
126
  ];
@@ -10,7 +10,7 @@ type Fixed = {
10
10
  readonly version: string;
11
11
  readonly by: string;
12
12
  };
13
- declare const nodeVersion = "26.13.0";
13
+ declare const nodeVersion = "26.13.1";
14
14
  declare const families: ReadonlyArray<Family>;
15
15
  declare const fixed: ReadonlyArray<Fixed>;
16
16
  type Catalog = {
@@ -1,2 +1,2 @@
1
- import { a as families, c as fixed, d as lead, f as nodeVersion, g as versions, h as versionOf, i as catalog, l as fixedBy, m as pinned, n as Family, o as familyNamed, p as ownerOf, r as Fixed, s as familyOf, t as Catalog, u as fixedOf } from "./versions-D02TrtKw.mjs";
1
+ import { a as families, c as fixed, d as lead, f as nodeVersion, g as versions, h as versionOf, i as catalog, l as fixedBy, m as pinned, n as Family, o as familyNamed, p as ownerOf, r as Fixed, s as familyOf, t as Catalog, u as fixedOf } from "./versions-DqZd0jF9.mjs";
2
2
  export { Catalog, Family, Fixed, catalog, families, familyNamed, familyOf, fixed, fixedBy, fixedOf, lead, nodeVersion, ownerOf, pinned, versionOf, versions };
package/dist/versions.mjs CHANGED
@@ -1 +1 @@
1
- export { t as catalog, n as families, r as familyNamed, i as familyOf, a as fixed, o as fixedBy, s as fixedOf, c as lead, l as nodeVersion, u as ownerOf, d as pinned, f as versionOf, p as versions } from "./versions-C7LKZGr3.mjs";
1
+ export { t as catalog, n as families, r as familyNamed, i as familyOf, a as fixed, o as fixedBy, s as fixedOf, c as lead, l as nodeVersion, u as ownerOf, d as pinned, f as versionOf, p as versions } from "./versions-DpRzgSR_.mjs";
package/node-version CHANGED
@@ -1 +1 @@
1
- 26.13.0
1
+ 26.13.1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@milkenjoyer/toolchain",
3
- "version": "0.18.0",
3
+ "version": "0.20.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/birbprophet/agent-kit.git",
@@ -108,31 +108,30 @@
108
108
  "prepack": "vp pack"
109
109
  },
110
110
  "dependencies": {
111
- "@boatdev/sdk": "1.13.0",
112
- "@effect/platform-node": "4.1.2",
113
- "@effect/tsgo": "0.67.3",
111
+ "@effect/platform-node": "4.1.4",
112
+ "@effect/tsgo": "0.69.0",
114
113
  "@foldkit/oxlint-plugin": "0.15.4",
115
114
  "@mpsuesser/oxlint-plugin-effect": "0.6.0",
116
115
  "@octokit/rest": "22.0.1",
117
- "effect": "4.1.2",
118
- "effect-oxlint": "0.4.0",
116
+ "effect": "4.1.4",
117
+ "effect-oxlint": "0.5.1",
119
118
  "oxc-parser": "0.157.0",
120
119
  "semver": "7.8.6",
121
- "ultracite": "8.1.1",
120
+ "ultracite": "8.2.1",
122
121
  "yaml": "2.9.1",
123
122
  "z3-solver": "5.3.3"
124
123
  },
125
124
  "devDependencies": {
126
125
  "@birbprophet/test-kit": "0.0.0",
127
- "@effect/vitest": "4.1.2",
126
+ "@effect/vitest": "4.1.4",
128
127
  "@types/semver": "7.8.0",
129
128
  "jsonata": "2.2.2",
130
129
  "knip": "6.44.1",
131
- "oxlint": "1.91.0",
132
- "vite-plus": "1.5.0"
130
+ "oxlint": "1.93.0",
131
+ "vite-plus": "1.6.0"
133
132
  },
134
133
  "peerDependencies": {
135
134
  "knip": "6.44.1",
136
- "vite-plus": "1.5.0"
135
+ "vite-plus": "1.6.0"
137
136
  }
138
137
  }
package/src/fmt.ts CHANGED
@@ -5,7 +5,7 @@ export type FmtOptions = {
5
5
  readonly ignores?: ReadonlyArray<string>;
6
6
  };
7
7
 
8
- const { ignorePatterns: coreIgnores = [] } = ultraciteFmt;
8
+ const { ignorePatterns: coreIgnores } = ultraciteFmt;
9
9
 
10
10
  export const fmt = ({ ignores = [] }: FmtOptions = {}): OxfmtConfig => ({
11
11
  ...ultraciteFmt,
package/src/formal/tla.ts CHANGED
@@ -165,11 +165,18 @@ const make = Effect.gen(function* () {
165
165
  ) {
166
166
  return yield* Effect.scoped(
167
167
  Effect.gen(function* () {
168
- const process = yield* ChildProcess.make("java", args, {
169
- cwd,
170
- stdin: "ignore",
171
- killSignal: "SIGKILL",
168
+ const temporary = yield* fs.makeTempDirectoryScoped({
169
+ prefix: "formal-java-",
172
170
  });
171
+ const process = yield* ChildProcess.make(
172
+ "java",
173
+ [`-Djava.io.tmpdir=${temporary}`, ...args],
174
+ {
175
+ cwd,
176
+ stdin: "ignore",
177
+ killSignal: "SIGKILL",
178
+ }
179
+ );
173
180
  return yield* Effect.all(
174
181
  [
175
182
  process.stdout.pipe(Stream.decodeText, Stream.mkString),
package/src/lint.ts CHANGED
@@ -124,7 +124,7 @@ export const birbprophetRules = atError(
124
124
  R.keys(birbprophetPlugin.rules)
125
125
  );
126
126
 
127
- const { ignorePatterns: coreIgnores = [] } = ultraciteCore;
127
+ const { ignorePatterns: coreIgnores } = ultraciteCore;
128
128
 
129
129
  const resolved = (specifier: string): string =>
130
130
  decodeURIComponent(new URL(import.meta.resolve(specifier)).pathname);
@@ -1,6 +1,8 @@
1
1
  import * as Effect from "effect/Effect";
2
+ import * as Option from "effect/Option";
2
3
 
3
- import { manifestRanges, PLAIN, type Ranges } from "./manifest.ts";
4
+ import { versionOf } from "../versions.ts";
5
+ import { manifestRanges, resolveCatalog } from "./manifest.ts";
4
6
  import { read, type Finding, type Rule } from "./repo.ts";
5
7
 
6
8
  interface AlchemyEntry {
@@ -9,21 +11,6 @@ interface AlchemyEntry {
9
11
  readonly name: string;
10
12
  readonly version: string;
11
13
  }
12
- const resolve = (
13
- name: string,
14
- written: string,
15
- groups: ReadonlyMap<string, Ranges>
16
- ): string => {
17
- if (!written.startsWith("catalog:")) return written;
18
- const catalog = written.slice(8);
19
- return (
20
- (catalog === ""
21
- ? (groups.get("workspaces.catalog")?.[name] ??
22
- groups.get("catalog")?.[name])
23
- : (groups.get(`workspaces.catalogs.${catalog}`)?.[name] ??
24
- groups.get(`catalogs.${catalog}`)?.[name])) ?? written
25
- );
26
- };
27
14
  export const alchemyPins: Rule = (repo) =>
28
15
  Effect.gen(function* () {
29
16
  const root = yield* read(repo, "package.json", manifestRanges);
@@ -46,25 +33,35 @@ export const alchemyPins: Rule = (repo) =>
46
33
  for (const [name, written] of Object.entries(ranges).toSorted(
47
34
  ([a], [b]) => a.localeCompare(b)
48
35
  )) {
49
- if (name === "alchemy" || name.startsWith("@alchemy.run/"))
36
+ if (
37
+ (name === "alchemy" || name.startsWith("@alchemy.run/")) &&
38
+ !written.startsWith("workspace:")
39
+ )
50
40
  entries.push({
51
41
  file,
52
42
  field,
53
43
  name,
54
- version: resolve(name, written, groups),
44
+ version: resolveCatalog(name, written, groups),
55
45
  });
56
46
  }
57
47
  }
58
48
  }
59
- const expected =
60
- entries.find((entry) => entry.name === "alchemy")?.version ??
61
- entries[0]?.version;
62
- for (const entry of entries) {
63
- if (!PLAIN.test(entry.version) || entry.version !== expected)
64
- findings.push({
65
- file: entry.file,
66
- message: `${entry.field} ${entry.name}: ${entry.version} must match the exact Alchemy version ${expected}`,
67
- });
68
- }
69
- return findings;
49
+ return Option.match(versionOf("alchemy"), {
50
+ onNone: () => [
51
+ ...findings,
52
+ {
53
+ file: "package.json",
54
+ message: "toolchain catalog has no Alchemy version",
55
+ },
56
+ ],
57
+ onSome: (expected) => [
58
+ ...findings,
59
+ ...entries
60
+ .filter((entry) => entry.version !== expected)
61
+ .map((entry) => ({
62
+ file: entry.file,
63
+ message: `${entry.field} ${entry.name}: ${entry.version} must match the exact Alchemy version ${expected}`,
64
+ })),
65
+ ],
66
+ });
70
67
  });
@@ -39,6 +39,22 @@ const Manifest = Schema.fromJsonString(
39
39
 
40
40
  export type Ranges = Readonly<Record<string, string>>;
41
41
 
42
+ export const resolveCatalog = (
43
+ name: string,
44
+ written: string,
45
+ groups: ReadonlyMap<string, Ranges>
46
+ ): string => {
47
+ if (!written.startsWith("catalog:")) return written;
48
+ const catalog = written.slice(8);
49
+ return (
50
+ (catalog === ""
51
+ ? (groups.get("workspaces.catalog")?.[name] ??
52
+ groups.get("catalog")?.[name])
53
+ : (groups.get(`workspaces.catalogs.${catalog}`)?.[name] ??
54
+ groups.get(`catalogs.${catalog}`)?.[name])) ?? written
55
+ );
56
+ };
57
+
42
58
  const named = (
43
59
  prefix: string,
44
60
  catalogs: Readonly<Record<string, Ranges>>