@milkenjoyer/toolchain 0.14.1 → 0.16.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 +17 -17
- package/STARTS.md +11 -0
- package/dist/effect-plugin-BsrW5_nI.mjs +79 -0
- package/dist/effect-plugin.d.mts +2 -3966
- package/dist/effect-plugin.mjs +1 -1
- package/dist/fmt-BaECz64m.mjs +8 -0
- package/dist/fmt.mjs +1 -8
- package/dist/formal.mjs +1 -1
- package/dist/guard-Doqk4Fju.mjs +143 -0
- package/dist/guard.mjs +1 -96
- package/dist/{lint-IhmtnBbx.mjs → lint-CfztB4u8.mjs} +1 -1
- package/dist/lint.mjs +1 -1
- package/dist/standard.mjs +557 -4
- package/dist/starts.d.mts +100 -0
- package/dist/starts.mjs +385 -0
- package/package.json +11 -9
- package/src/arithmetic.ts +60 -0
- package/src/compatible.ts +512 -0
- package/src/conformance.ts +56 -0
- package/src/effect-plugin.ts +24 -0
- package/src/effect-tsgo.ts +44 -0
- package/src/exceptions.ts +17 -0
- package/src/fmt.ts +13 -0
- package/src/foldkit-plugin.ts +51 -0
- package/src/guard.ts +307 -0
- package/src/hooks.ts +205 -0
- package/src/index.ts +1 -0
- package/src/knip.ts +25 -0
- package/src/lint.ts +170 -0
- package/src/plugin.ts +21 -0
- package/src/rules/no-comments.ts +36 -0
- package/src/rules/no-process-env.ts +68 -0
- package/src/rules/prefer-accessible-scene-locators.ts +227 -0
- package/src/rules/require-command-answer-names.ts +144 -0
- package/src/rules/require-past-tense-messages.ts +201 -0
- package/src/rules/use-temp-file-scoped.ts +132 -0
- package/src/rules.ts +121 -0
- package/src/shared/foldkit-api.ts +51 -0
- package/src/shared/member-path.ts +106 -0
- package/src/shared/syntax.ts +47 -0
- package/src/standard/alchemy.ts +70 -0
- package/src/standard/checks.ts +10 -1
- package/src/standard/config.ts +84 -0
- package/src/standard/domain-rules.ts +204 -0
- package/src/standard/domain.ts +296 -0
- package/src/standard/infra.ts +486 -0
- package/src/starts/boat.ts +140 -0
- package/src/starts/budget.ts +151 -0
- package/src/starts/policy.ts +171 -0
- package/src/starts.ts +84 -0
- package/src/versions.ts +221 -0
- package/dist/effect-plugin-BXUx9PPu.mjs +0 -3561
- package/dist/manifest-xQwgnYI1.mjs +0 -53
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import * as Schema from "effect/Schema";
|
|
2
|
+
|
|
3
|
+
export const Repo = Schema.String.check(
|
|
4
|
+
Schema.isPattern(/^[\w.-]+\/[\w.-]+$/u)
|
|
5
|
+
).pipe(Schema.brand("Repo"));
|
|
6
|
+
export type Repo = typeof Repo.Type;
|
|
7
|
+
export type Window = "minute" | "hour" | "day";
|
|
8
|
+
export type PerWindow<A> = { readonly [W in Window]: A };
|
|
9
|
+
export type Share = { readonly repo: Repo; readonly share: number };
|
|
10
|
+
export type Plan = {
|
|
11
|
+
readonly limits: PerWindow<number>;
|
|
12
|
+
readonly used: PerWindow<number>;
|
|
13
|
+
readonly nextStartDollars: number | undefined;
|
|
14
|
+
};
|
|
15
|
+
export type RepoStarts = {
|
|
16
|
+
readonly repo: Repo;
|
|
17
|
+
readonly starts: ReadonlyArray<number>;
|
|
18
|
+
readonly complete: boolean;
|
|
19
|
+
};
|
|
20
|
+
export type Counts = {
|
|
21
|
+
readonly now: number;
|
|
22
|
+
readonly plan: Plan;
|
|
23
|
+
readonly repo: RepoStarts;
|
|
24
|
+
};
|
|
25
|
+
export type StartRequest = { readonly repo: Repo; readonly jobs: number };
|
|
26
|
+
|
|
27
|
+
const Window = Schema.Literals(["minute", "hour", "day"]);
|
|
28
|
+
export const Line = Schema.Union([
|
|
29
|
+
Schema.TaggedStruct("Unread", { reason: Schema.String }),
|
|
30
|
+
Schema.TaggedStruct("Paid", {
|
|
31
|
+
nextStartDollars: Schema.UndefinedOr(Schema.Number),
|
|
32
|
+
}),
|
|
33
|
+
Schema.TaggedStruct("Account", {
|
|
34
|
+
window: Window,
|
|
35
|
+
used: Schema.Number,
|
|
36
|
+
line: Schema.Number,
|
|
37
|
+
}),
|
|
38
|
+
Schema.TaggedStruct("Budget", {
|
|
39
|
+
repo: Repo,
|
|
40
|
+
window: Window,
|
|
41
|
+
used: Schema.Number,
|
|
42
|
+
budget: Schema.Number,
|
|
43
|
+
}),
|
|
44
|
+
]);
|
|
45
|
+
export type Line = typeof Line.Type;
|
|
46
|
+
export type Admission =
|
|
47
|
+
| { readonly _tag: "Admit" }
|
|
48
|
+
| { readonly _tag: "Wait"; readonly until: number; readonly line: Line }
|
|
49
|
+
| { readonly _tag: "Hold"; readonly line: Line };
|
|
50
|
+
|
|
51
|
+
const windows: ReadonlyArray<Window> = ["minute", "hour", "day"];
|
|
52
|
+
export const windowMillis: PerWindow<number> = {
|
|
53
|
+
minute: 60_000,
|
|
54
|
+
hour: 3_600_000,
|
|
55
|
+
day: 86_400_000,
|
|
56
|
+
};
|
|
57
|
+
export const pollMillis: PerWindow<number> = {
|
|
58
|
+
minute: 15_000,
|
|
59
|
+
hour: 60_000,
|
|
60
|
+
day: 300_000,
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
export const startShares: ReadonlyArray<Share> = [
|
|
64
|
+
{ repo: Repo.make("birbprophet/agent-kit"), share: 0.1 },
|
|
65
|
+
{ repo: Repo.make("siglata/siglata"), share: 0.2 },
|
|
66
|
+
{ repo: Repo.make("optionhouse-xyz/optionhouse"), share: 0.25 },
|
|
67
|
+
{ repo: Repo.make("birbprophet/vibebattler"), share: 0.25 },
|
|
68
|
+
{ repo: Repo.make("birbprophet/secrets"), share: 0 },
|
|
69
|
+
];
|
|
70
|
+
|
|
71
|
+
const count = (value: number) => Number.isSafeInteger(value) && value >= 0;
|
|
72
|
+
const unread = (reason: string): Admission => ({
|
|
73
|
+
_tag: "Hold",
|
|
74
|
+
line: { _tag: "Unread", reason },
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
export const decide = (
|
|
78
|
+
request: StartRequest,
|
|
79
|
+
counts: Counts | undefined,
|
|
80
|
+
now: number
|
|
81
|
+
): Admission => {
|
|
82
|
+
const share = startShares.find(({ repo }) => repo === request.repo);
|
|
83
|
+
if (share === undefined) return unread("repo has no start budget");
|
|
84
|
+
if (!count(request.jobs) || request.jobs === 0)
|
|
85
|
+
return unread("jobs must be a positive safe integer");
|
|
86
|
+
if (!Number.isFinite(now)) return unread("start time unread");
|
|
87
|
+
if (counts === undefined)
|
|
88
|
+
return {
|
|
89
|
+
_tag: "Wait",
|
|
90
|
+
until: now + pollMillis.minute,
|
|
91
|
+
line: { _tag: "Unread", reason: "start plan unread" },
|
|
92
|
+
};
|
|
93
|
+
if (
|
|
94
|
+
!Number.isFinite(counts.now) ||
|
|
95
|
+
!windows.every(
|
|
96
|
+
(window) =>
|
|
97
|
+
count(counts.plan.limits[window]) && count(counts.plan.used[window])
|
|
98
|
+
)
|
|
99
|
+
)
|
|
100
|
+
return unread("start plan unread");
|
|
101
|
+
if (
|
|
102
|
+
counts.repo.repo !== request.repo ||
|
|
103
|
+
!counts.repo.starts.every((at) => Number.isFinite(at) && at <= counts.now)
|
|
104
|
+
)
|
|
105
|
+
return unread("repo start history incomplete");
|
|
106
|
+
if (!counts.repo.complete)
|
|
107
|
+
return {
|
|
108
|
+
_tag: "Wait",
|
|
109
|
+
until: now + pollMillis.minute,
|
|
110
|
+
line: { _tag: "Unread", reason: "repo start history incomplete" },
|
|
111
|
+
};
|
|
112
|
+
const { plan } = counts;
|
|
113
|
+
if (plan.nextStartDollars !== 0)
|
|
114
|
+
return {
|
|
115
|
+
_tag: "Wait",
|
|
116
|
+
until: now + pollMillis.minute,
|
|
117
|
+
line: { _tag: "Paid", nextStartDollars: plan.nextStartDollars },
|
|
118
|
+
};
|
|
119
|
+
for (const window of windows) {
|
|
120
|
+
const used = plan.used[window];
|
|
121
|
+
const line = plan.limits[window] - 20;
|
|
122
|
+
if (used + request.jobs > line)
|
|
123
|
+
return window === "day"
|
|
124
|
+
? { _tag: "Hold", line: { _tag: "Account", window, used, line } }
|
|
125
|
+
: {
|
|
126
|
+
_tag: "Wait",
|
|
127
|
+
until: now + pollMillis[window],
|
|
128
|
+
line: { _tag: "Account", window, used, line },
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
for (const window of windows) {
|
|
132
|
+
const starts = counts.repo.starts
|
|
133
|
+
.filter((at) => at > now - windowMillis[window])
|
|
134
|
+
.toSorted((left, right) => left - right);
|
|
135
|
+
const used = starts.length;
|
|
136
|
+
const budget = Math.floor(share.share * plan.limits[window]);
|
|
137
|
+
if (used + request.jobs <= budget) continue;
|
|
138
|
+
const line: Line = {
|
|
139
|
+
_tag: "Budget",
|
|
140
|
+
repo: request.repo,
|
|
141
|
+
window,
|
|
142
|
+
used,
|
|
143
|
+
budget,
|
|
144
|
+
};
|
|
145
|
+
const expires = starts[used + request.jobs - budget - 1];
|
|
146
|
+
return request.jobs > budget || expires === undefined
|
|
147
|
+
? { _tag: "Hold", line }
|
|
148
|
+
: { _tag: "Wait", until: expires + windowMillis[window], line };
|
|
149
|
+
}
|
|
150
|
+
return { _tag: "Admit" };
|
|
151
|
+
};
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import * as Schema from "effect/Schema";
|
|
2
|
+
import { parse } from "yaml";
|
|
3
|
+
|
|
4
|
+
export const BOAT_JOBS_PER_RUN = 2;
|
|
5
|
+
|
|
6
|
+
const Matrix = Schema.Record(Schema.String, Schema.Array(Schema.Unknown));
|
|
7
|
+
const Workflow = Schema.Struct({
|
|
8
|
+
name: Schema.optionalKey(Schema.String),
|
|
9
|
+
on: Schema.optionalKey(
|
|
10
|
+
Schema.Union([
|
|
11
|
+
Schema.String,
|
|
12
|
+
Schema.Array(Schema.String),
|
|
13
|
+
Schema.Record(Schema.String, Schema.Unknown),
|
|
14
|
+
])
|
|
15
|
+
),
|
|
16
|
+
jobs: Schema.Record(
|
|
17
|
+
Schema.String,
|
|
18
|
+
Schema.Struct({
|
|
19
|
+
"runs-on": Schema.optionalKey(
|
|
20
|
+
Schema.Union([Schema.String, Schema.Array(Schema.String)])
|
|
21
|
+
),
|
|
22
|
+
uses: Schema.optionalKey(Schema.String),
|
|
23
|
+
strategy: Schema.optionalKey(
|
|
24
|
+
Schema.Struct({
|
|
25
|
+
matrix: Schema.optionalKey(Schema.Union([Schema.String, Matrix])),
|
|
26
|
+
})
|
|
27
|
+
),
|
|
28
|
+
})
|
|
29
|
+
),
|
|
30
|
+
});
|
|
31
|
+
const Descendant = Schema.Struct({
|
|
32
|
+
workflow_run: Schema.Struct({
|
|
33
|
+
workflows: Schema.Union([Schema.String, Schema.Array(Schema.String)]),
|
|
34
|
+
types: Schema.optionalKey(
|
|
35
|
+
Schema.Union([Schema.String, Schema.Array(Schema.String)])
|
|
36
|
+
),
|
|
37
|
+
}),
|
|
38
|
+
});
|
|
39
|
+
type WorkflowFile = readonly [path: string, text: string];
|
|
40
|
+
type Parsed = {
|
|
41
|
+
readonly path: string;
|
|
42
|
+
readonly workflow: typeof Workflow.Type;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
const dynamic = (value: unknown): boolean => {
|
|
46
|
+
try {
|
|
47
|
+
return JSON.stringify(value).includes("${{");
|
|
48
|
+
} catch {
|
|
49
|
+
return true;
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
export const boatJobFindings = (
|
|
54
|
+
files: ReadonlyArray<WorkflowFile>
|
|
55
|
+
): ReadonlyArray<string> => {
|
|
56
|
+
const findings: string[] = [];
|
|
57
|
+
const workflows: Parsed[] = [];
|
|
58
|
+
for (const [path, text] of files) {
|
|
59
|
+
try {
|
|
60
|
+
workflows.push({
|
|
61
|
+
path,
|
|
62
|
+
workflow: Schema.decodeUnknownSync(Workflow)(parse(text)),
|
|
63
|
+
});
|
|
64
|
+
} catch {
|
|
65
|
+
findings.push(`${path}: workflow unread`);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
const after = (
|
|
69
|
+
entry: Parsed
|
|
70
|
+
): { readonly names: ReadonlyArray<string>; readonly copies: number } => {
|
|
71
|
+
const events = entry.workflow.on;
|
|
72
|
+
if (!Schema.is(Descendant)(events)) {
|
|
73
|
+
if (typeof events === "object" && "workflow_run" in events)
|
|
74
|
+
findings.push(`${entry.path}: workflow_run unread`);
|
|
75
|
+
return { names: [], copies: 0 };
|
|
76
|
+
}
|
|
77
|
+
const names = events.workflow_run.workflows;
|
|
78
|
+
const selectors = typeof names === "string" ? [names] : names;
|
|
79
|
+
if (selectors.some((name) => /[*!?[\]]/u.test(name)))
|
|
80
|
+
findings.push(`${entry.path}: workflow_run pattern unresolved`);
|
|
81
|
+
const types = events.workflow_run.types;
|
|
82
|
+
if (types !== undefined && dynamic(types))
|
|
83
|
+
findings.push(`${entry.path}: dynamic workflow_run types`);
|
|
84
|
+
return {
|
|
85
|
+
names: selectors,
|
|
86
|
+
copies:
|
|
87
|
+
types === undefined
|
|
88
|
+
? 3
|
|
89
|
+
: new Set(typeof types === "string" ? [types] : types).size,
|
|
90
|
+
};
|
|
91
|
+
};
|
|
92
|
+
const count = (
|
|
93
|
+
entry: Parsed,
|
|
94
|
+
parents: ReadonlyArray<string>,
|
|
95
|
+
descendants: boolean
|
|
96
|
+
): number => {
|
|
97
|
+
if (parents.includes(entry.path)) {
|
|
98
|
+
findings.push(`${entry.path}: workflow cycle`);
|
|
99
|
+
return 0;
|
|
100
|
+
}
|
|
101
|
+
const stack = [...parents, entry.path];
|
|
102
|
+
let total = 0;
|
|
103
|
+
for (const [name, job] of Object.entries(entry.workflow.jobs)) {
|
|
104
|
+
const label = `${entry.path} ${name}`;
|
|
105
|
+
const matrix = job.strategy?.matrix;
|
|
106
|
+
let copies = 1;
|
|
107
|
+
if (matrix !== undefined) {
|
|
108
|
+
if (typeof matrix === "string" || dynamic(matrix)) {
|
|
109
|
+
findings.push(`${label}: dynamic matrix`);
|
|
110
|
+
} else {
|
|
111
|
+
const axes = Object.entries(matrix).filter(
|
|
112
|
+
([axis]) => axis !== "include" && axis !== "exclude"
|
|
113
|
+
);
|
|
114
|
+
copies =
|
|
115
|
+
(axes.length === 0
|
|
116
|
+
? 0
|
|
117
|
+
: axes.reduce(
|
|
118
|
+
(product, [, values]) => product * values.length,
|
|
119
|
+
1
|
|
120
|
+
)) + (matrix.include?.length ?? 0);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
if (job.uses !== undefined) {
|
|
124
|
+
if (!/^\.\/\.github\/workflows\/[^/]+\.ya?ml$/u.test(job.uses)) {
|
|
125
|
+
findings.push(`${label}: remote or unresolved reusable workflow`);
|
|
126
|
+
continue;
|
|
127
|
+
}
|
|
128
|
+
const target = job.uses.slice(2);
|
|
129
|
+
const called = workflows.find(
|
|
130
|
+
({ path }) =>
|
|
131
|
+
path === target || `.github/workflows/${path}` === target
|
|
132
|
+
);
|
|
133
|
+
if (called === undefined)
|
|
134
|
+
findings.push(`${label}: reusable workflow ${target} unread`);
|
|
135
|
+
else total += copies * count(called, stack, false);
|
|
136
|
+
} else if (job["runs-on"] === undefined || dynamic(job["runs-on"])) {
|
|
137
|
+
findings.push(`${label}: dynamic or unread runs-on`);
|
|
138
|
+
} else {
|
|
139
|
+
const runners = job["runs-on"];
|
|
140
|
+
if (
|
|
141
|
+
(typeof runners === "string" ? [runners] : runners).some(
|
|
142
|
+
(runner) => runner.split("/")[0]?.startsWith("boat") === true
|
|
143
|
+
)
|
|
144
|
+
)
|
|
145
|
+
total += copies;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
if (descendants)
|
|
149
|
+
for (const child of workflows) {
|
|
150
|
+
const { names, copies } = after(child);
|
|
151
|
+
if (dynamic(names))
|
|
152
|
+
findings.push(`${child.path}: dynamic workflow_run`);
|
|
153
|
+
const file = entry.path.split("/").at(-1) ?? entry.path;
|
|
154
|
+
const rootNames =
|
|
155
|
+
entry.workflow.name === undefined
|
|
156
|
+
? [entry.path, file, `.github/workflows/${file}`]
|
|
157
|
+
: [entry.workflow.name];
|
|
158
|
+
if (rootNames.some((name) => names.includes(name)))
|
|
159
|
+
total += copies * count(child, stack, true);
|
|
160
|
+
}
|
|
161
|
+
return total;
|
|
162
|
+
};
|
|
163
|
+
for (const entry of workflows) {
|
|
164
|
+
const total = count(entry, [], true);
|
|
165
|
+
if (total > BOAT_JOBS_PER_RUN)
|
|
166
|
+
findings.push(
|
|
167
|
+
`${entry.path}: closure starts ${total} Boat jobs, limit ${BOAT_JOBS_PER_RUN}`
|
|
168
|
+
);
|
|
169
|
+
}
|
|
170
|
+
return [...new Set(findings)];
|
|
171
|
+
};
|
package/src/starts.ts
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import * as Clock from "effect/Clock";
|
|
2
|
+
import * as Effect from "effect/Effect";
|
|
3
|
+
import * as Schema from "effect/Schema";
|
|
4
|
+
|
|
5
|
+
import { BoatStarts } from "./starts/boat.ts";
|
|
6
|
+
import {
|
|
7
|
+
decide,
|
|
8
|
+
Line,
|
|
9
|
+
pollMillis,
|
|
10
|
+
type StartRequest,
|
|
11
|
+
} from "./starts/budget.ts";
|
|
12
|
+
|
|
13
|
+
export { BoatStarts, StartReadError } from "./starts/boat.ts";
|
|
14
|
+
export { decide, Repo, startShares } from "./starts/budget.ts";
|
|
15
|
+
export type {
|
|
16
|
+
Admission,
|
|
17
|
+
Counts,
|
|
18
|
+
PerWindow,
|
|
19
|
+
Plan,
|
|
20
|
+
RepoStarts,
|
|
21
|
+
Share,
|
|
22
|
+
StartRequest,
|
|
23
|
+
Window,
|
|
24
|
+
} from "./starts/budget.ts";
|
|
25
|
+
export { boatJobFindings, BOAT_JOBS_PER_RUN } from "./starts/policy.ts";
|
|
26
|
+
export type { Line } from "./starts/budget.ts";
|
|
27
|
+
|
|
28
|
+
export class StartHeld extends Schema.TaggedError<
|
|
29
|
+
StartHeld,
|
|
30
|
+
{ readonly brand: unique symbol }
|
|
31
|
+
>()("StartHeld", {
|
|
32
|
+
line: Line,
|
|
33
|
+
}) {}
|
|
34
|
+
|
|
35
|
+
export const admitStart = Effect.fn("Starts.admitStart")(function* <A, E, R>(
|
|
36
|
+
request: StartRequest,
|
|
37
|
+
start: Effect.Effect<A, E, R>,
|
|
38
|
+
{ deadline }: { readonly deadline: number }
|
|
39
|
+
) {
|
|
40
|
+
const boat = yield* BoatStarts;
|
|
41
|
+
let last: Line = {
|
|
42
|
+
_tag: "Unread",
|
|
43
|
+
reason: "start deadline reached",
|
|
44
|
+
};
|
|
45
|
+
for (;;) {
|
|
46
|
+
const remaining = deadline - (yield* Clock.currentTimeMillis);
|
|
47
|
+
if (!Number.isFinite(remaining) || remaining <= 0)
|
|
48
|
+
return yield* new StartHeld({ line: last });
|
|
49
|
+
const counts = yield* Effect.gen(function* () {
|
|
50
|
+
const plan = yield* boat.plan;
|
|
51
|
+
const repo = yield* boat.repoStarts(request.repo);
|
|
52
|
+
return { now: yield* Clock.currentTimeMillis, plan, repo };
|
|
53
|
+
}).pipe(
|
|
54
|
+
Effect.catchTag("StartReadError", () => Effect.undefined),
|
|
55
|
+
Effect.timeoutOrElse({
|
|
56
|
+
duration: remaining,
|
|
57
|
+
orElse: () => Effect.fail(new StartHeld({ line: last })),
|
|
58
|
+
})
|
|
59
|
+
);
|
|
60
|
+
const now = yield* Clock.currentTimeMillis;
|
|
61
|
+
const decision = decide(request, counts, now);
|
|
62
|
+
if (decision._tag === "Hold")
|
|
63
|
+
return yield* new StartHeld({ line: decision.line });
|
|
64
|
+
if (!Number.isFinite(deadline) || now >= deadline)
|
|
65
|
+
return yield* new StartHeld({
|
|
66
|
+
line:
|
|
67
|
+
decision._tag === "Wait"
|
|
68
|
+
? decision.line
|
|
69
|
+
: { _tag: "Unread", reason: "start deadline reached" },
|
|
70
|
+
});
|
|
71
|
+
if (decision._tag === "Admit") return yield* start;
|
|
72
|
+
last = decision.line;
|
|
73
|
+
const window =
|
|
74
|
+
decision.line._tag === "Account" || decision.line._tag === "Budget"
|
|
75
|
+
? decision.line.window
|
|
76
|
+
: "minute";
|
|
77
|
+
yield* Effect.sleep(
|
|
78
|
+
Math.max(
|
|
79
|
+
0,
|
|
80
|
+
Math.min(decision.until, now + pollMillis[window], deadline) - now
|
|
81
|
+
)
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
});
|
package/src/versions.ts
ADDED
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
import * as Arr from "effect/Array";
|
|
2
|
+
import { dual } from "effect/Function";
|
|
3
|
+
import * as Option from "effect/Option";
|
|
4
|
+
import * as R from "effect/Record";
|
|
5
|
+
import * as Schema from "effect/Schema";
|
|
6
|
+
import * as Str from "effect/String";
|
|
7
|
+
|
|
8
|
+
export type Family = {
|
|
9
|
+
readonly name: string;
|
|
10
|
+
readonly version: string;
|
|
11
|
+
readonly packages: ReadonlyArray<string>;
|
|
12
|
+
readonly scopes: ReadonlyArray<string>;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export type Fixed = {
|
|
16
|
+
readonly name: string;
|
|
17
|
+
readonly version: string;
|
|
18
|
+
readonly by: string;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export const nodeVersion = "26.13.0";
|
|
22
|
+
|
|
23
|
+
export const families: ReadonlyArray<Family> = [
|
|
24
|
+
{
|
|
25
|
+
name: "vite-plus",
|
|
26
|
+
version: "1.5.0",
|
|
27
|
+
packages: ["vite-plus"],
|
|
28
|
+
scopes: [],
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
name: "alchemy",
|
|
32
|
+
version: "2.0.0-beta.85",
|
|
33
|
+
packages: [
|
|
34
|
+
"@alchemy.run/domain",
|
|
35
|
+
"alchemy",
|
|
36
|
+
"@alchemy.run/github",
|
|
37
|
+
"@alchemy.run/test",
|
|
38
|
+
],
|
|
39
|
+
scopes: ["@alchemy.run/"],
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
name: "foldkit",
|
|
43
|
+
version: "0.170.0",
|
|
44
|
+
packages: ["foldkit", "@foldkit/ui"],
|
|
45
|
+
scopes: [],
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
name: "@foldkit/vite-plugin",
|
|
49
|
+
version: "0.29.0",
|
|
50
|
+
packages: ["@foldkit/vite-plugin"],
|
|
51
|
+
scopes: [],
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
name: "@foldkit/devtools-mcp",
|
|
55
|
+
version: "0.26.0",
|
|
56
|
+
packages: ["@foldkit/devtools-mcp"],
|
|
57
|
+
scopes: [],
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
name: "@foldkit/oxlint-plugin",
|
|
61
|
+
version: "0.15.4",
|
|
62
|
+
packages: ["@foldkit/oxlint-plugin"],
|
|
63
|
+
scopes: [],
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
name: "effect",
|
|
67
|
+
version: "4.1.2",
|
|
68
|
+
packages: [
|
|
69
|
+
"effect",
|
|
70
|
+
"@effect/platform-browser",
|
|
71
|
+
"@effect/platform-bun",
|
|
72
|
+
"@effect/platform-node",
|
|
73
|
+
"@effect/platform-node-shared",
|
|
74
|
+
"@effect/vitest",
|
|
75
|
+
],
|
|
76
|
+
scopes: ["@effect/"],
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
name: "@effect/tsgo",
|
|
80
|
+
version: "0.67.3",
|
|
81
|
+
packages: ["@effect/tsgo"],
|
|
82
|
+
scopes: [],
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
name: "ultracite",
|
|
86
|
+
version: "8.1.1",
|
|
87
|
+
packages: ["ultracite"],
|
|
88
|
+
scopes: [],
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
name: "@mpsuesser/oxlint-plugin-effect",
|
|
92
|
+
version: "0.6.0",
|
|
93
|
+
packages: ["@mpsuesser/oxlint-plugin-effect"],
|
|
94
|
+
scopes: [],
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
name: "effect-oxlint",
|
|
98
|
+
version: "0.4.0",
|
|
99
|
+
packages: ["effect-oxlint"],
|
|
100
|
+
scopes: [],
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
name: "typescript",
|
|
104
|
+
version: "7.0.2",
|
|
105
|
+
packages: ["typescript"],
|
|
106
|
+
scopes: [],
|
|
107
|
+
},
|
|
108
|
+
];
|
|
109
|
+
|
|
110
|
+
export const fixed: ReadonlyArray<Fixed> = [
|
|
111
|
+
{ name: "oxlint", version: "1.91.0", by: "vite-plus" },
|
|
112
|
+
{ name: "@oxlint/plugins", version: "1.91.0", by: "vite-plus" },
|
|
113
|
+
{ name: "oxlint-tsgolint", version: "7.0.2005", by: "vite-plus" },
|
|
114
|
+
{ name: "oxfmt", version: "0.76.0", by: "vite-plus" },
|
|
115
|
+
{ name: "vitest", version: "5.1.0", by: "vite-plus" },
|
|
116
|
+
{
|
|
117
|
+
name: "vite",
|
|
118
|
+
version: "npm:@voidzero-dev/vite-plus-core@1.5.0",
|
|
119
|
+
by: "vite-plus",
|
|
120
|
+
},
|
|
121
|
+
];
|
|
122
|
+
|
|
123
|
+
export type Catalog = {
|
|
124
|
+
readonly families: ReadonlyArray<Family>;
|
|
125
|
+
readonly fixed: ReadonlyArray<Fixed>;
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
export const catalog: Catalog = { families, fixed };
|
|
129
|
+
|
|
130
|
+
export const lead = (family: Family): string =>
|
|
131
|
+
family.packages[0] ?? family.name;
|
|
132
|
+
|
|
133
|
+
const inScope = (current: Catalog, family: Family, name: string): boolean =>
|
|
134
|
+
Arr.some(family.scopes, (scope) => Str.startsWith(scope)(name)) &&
|
|
135
|
+
Arr.every(
|
|
136
|
+
current.families,
|
|
137
|
+
(other) => other === family || !other.packages.includes(name)
|
|
138
|
+
);
|
|
139
|
+
|
|
140
|
+
export const familyOf: {
|
|
141
|
+
(current?: Catalog): (name: string) => Option.Option<Family>;
|
|
142
|
+
(name: string, current?: Catalog): Option.Option<Family>;
|
|
143
|
+
} = dual(
|
|
144
|
+
(args) => Schema.is(Schema.String)(args[0]),
|
|
145
|
+
(name: string, current: Catalog = catalog): Option.Option<Family> =>
|
|
146
|
+
Option.orElse(
|
|
147
|
+
Arr.findFirst(current.families, (family) =>
|
|
148
|
+
family.packages.includes(name)
|
|
149
|
+
),
|
|
150
|
+
() =>
|
|
151
|
+
Arr.findFirst(current.families, (family) =>
|
|
152
|
+
inScope(current, family, name)
|
|
153
|
+
)
|
|
154
|
+
)
|
|
155
|
+
);
|
|
156
|
+
|
|
157
|
+
type NamedLookup<A> = {
|
|
158
|
+
(current?: Catalog): (name: string) => Option.Option<A>;
|
|
159
|
+
(name: string, current?: Catalog): Option.Option<A>;
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
const lookupNamed = <A extends { readonly name: string }>(
|
|
163
|
+
entries: (current: Catalog) => ReadonlyArray<A>
|
|
164
|
+
): NamedLookup<A> =>
|
|
165
|
+
dual(
|
|
166
|
+
(args) => Schema.is(Schema.String)(args[0]),
|
|
167
|
+
(name: string, current: Catalog = catalog) =>
|
|
168
|
+
Arr.findFirst(entries(current), (entry) => entry.name === name)
|
|
169
|
+
);
|
|
170
|
+
|
|
171
|
+
export const fixedOf = lookupNamed(
|
|
172
|
+
(current): ReadonlyArray<Fixed> => current.fixed
|
|
173
|
+
);
|
|
174
|
+
|
|
175
|
+
export const familyNamed = lookupNamed(
|
|
176
|
+
(current): ReadonlyArray<Family> => current.families
|
|
177
|
+
);
|
|
178
|
+
|
|
179
|
+
export const fixedBy: {
|
|
180
|
+
(current?: Catalog): (family: string) => ReadonlyArray<Fixed>;
|
|
181
|
+
(family: string, current?: Catalog): ReadonlyArray<Fixed>;
|
|
182
|
+
} = dual(
|
|
183
|
+
(args) => Schema.is(Schema.String)(args[0]),
|
|
184
|
+
(family: string, current: Catalog = catalog): ReadonlyArray<Fixed> =>
|
|
185
|
+
Arr.filter(current.fixed, (entry) => entry.by === family)
|
|
186
|
+
);
|
|
187
|
+
|
|
188
|
+
export const ownerOf: {
|
|
189
|
+
(current?: Catalog): (name: string) => Option.Option<Family>;
|
|
190
|
+
(name: string, current?: Catalog): Option.Option<Family>;
|
|
191
|
+
} = dual(
|
|
192
|
+
(args) => Schema.is(Schema.String)(args[0]),
|
|
193
|
+
(name: string, current: Catalog = catalog): Option.Option<Family> =>
|
|
194
|
+
Option.orElse(familyOf(name, current), () =>
|
|
195
|
+
Option.flatMap(fixedOf(name, current), (entry) =>
|
|
196
|
+
familyNamed(entry.by, current)
|
|
197
|
+
)
|
|
198
|
+
)
|
|
199
|
+
);
|
|
200
|
+
|
|
201
|
+
export const versionOf: {
|
|
202
|
+
(current?: Catalog): (name: string) => Option.Option<string>;
|
|
203
|
+
(name: string, current?: Catalog): Option.Option<string>;
|
|
204
|
+
} = dual(
|
|
205
|
+
(args) => Schema.is(Schema.String)(args[0]),
|
|
206
|
+
(name: string, current: Catalog = catalog): Option.Option<string> =>
|
|
207
|
+
Option.orElse(
|
|
208
|
+
Option.map(familyOf(name, current), (family) => family.version),
|
|
209
|
+
() => Option.map(fixedOf(name, current), (entry) => entry.version)
|
|
210
|
+
)
|
|
211
|
+
);
|
|
212
|
+
|
|
213
|
+
export const pinned = (current: Catalog): Readonly<Record<string, string>> =>
|
|
214
|
+
R.fromEntries([
|
|
215
|
+
...Arr.flatMap(current.families, (family) =>
|
|
216
|
+
Arr.map(family.packages, (name) => [name, family.version] as const)
|
|
217
|
+
),
|
|
218
|
+
...Arr.map(current.fixed, (entry) => [entry.name, entry.version] as const),
|
|
219
|
+
]);
|
|
220
|
+
|
|
221
|
+
export const versions: Readonly<Record<string, string>> = pinned(catalog);
|