@milkenjoyer/toolchain 0.0.0-stage → 0.6.5

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.
@@ -0,0 +1 @@
1
+ export { t as default } from "./effect-plugin-DARbVmA3.mjs";
@@ -0,0 +1,10 @@
1
+ export declare const patchCommand = "effect-tsgo patch --oxlint";
2
+ export declare const effectTsgoPlugin = "effecttsgo";
3
+ export type HeldRules = {
4
+ readonly issue: string;
5
+ readonly rules: ReadonlyArray<string>;
6
+ };
7
+ export declare const held: HeldRules;
8
+ export declare const effectTsgoCatalog: ReadonlyArray<string>;
9
+ export declare const enforcedTsgoRules: ReadonlyArray<string>;
10
+ export declare const effectTsgoRules: Readonly<Record<string, "error" | "off">>;
@@ -0,0 +1,16 @@
1
+ import * as Arr from "effect/Array";
2
+ import * as R from "effect/Record";
3
+ import { presets } from "@effect/tsgo/oxlint-presets";
4
+ import * as Order from "effect/Order";
5
+ import * as Struct from "effect/Struct";
6
+ // src/effect-tsgo.ts
7
+ const patchCommand = "effect-tsgo patch --oxlint";
8
+ const effectTsgoPlugin = "effecttsgo";
9
+ const held = {
10
+ issue: "https://github.com/birbprophet/agent-kit/issues/122",
11
+ rules: ["effecttsgo/api-stability-leak"]
12
+ };
13
+ const effectTsgoCatalog = Arr.sort(Arr.dedupe(Arr.flatMap(R.values(presets), ({ rules = {} }) => Struct.keys(rules))), Order.String);
14
+ const enforcedTsgoRules = Arr.filter(effectTsgoCatalog, (rule) => !held.rules.includes(rule));
15
+ const effectTsgoRules = R.fromEntries([...Arr.map(held.rules, (rule) => [rule, "off"]), ...Arr.map(enforcedTsgoRules, (rule) => [rule, "error"])]);
16
+ export { effectTsgoCatalog, effectTsgoPlugin, effectTsgoRules, enforcedTsgoRules, held, patchCommand };
@@ -0,0 +1,6 @@
1
+ export type Exception = {
2
+ readonly files: ReadonlyArray<string>;
3
+ readonly rules: ReadonlyArray<string>;
4
+ readonly issue: string;
5
+ };
6
+ export declare const exceptions: ReadonlyArray<Exception>;
@@ -0,0 +1,16 @@
1
+ // src/exceptions.ts
2
+ const exceptions = [{
3
+ files: [
4
+ "packages/repo-lint/src/rules/import-allowlist.ts",
5
+ "packages/repo-lint/src/rules/no-test-clock-real-io.ts",
6
+ "packages/repo-lint/src/workspace-guard.config.ts",
7
+ "packages/repo-lint/tests/design-system.test.ts"
8
+ ],
9
+ rules: ["effecttsgo/node-builtin-import"],
10
+ issue: "https://github.com/birbprophet/agent-kit/issues/171"
11
+ }, {
12
+ files: ["vite.config.ts"],
13
+ rules: ["effecttsgo/process-env"],
14
+ issue: "https://github.com/birbprophet/agent-kit/issues/171"
15
+ }];
16
+ export { exceptions };
package/dist/fmt.d.mts ADDED
@@ -0,0 +1,5 @@
1
+ import { OxfmtConfig } from "vite-plus/fmt";
2
+ export type FmtOptions = {
3
+ readonly ignores?: ReadonlyArray<string>;
4
+ };
5
+ export declare const fmt: ({ ignores }?: FmtOptions) => OxfmtConfig;
package/dist/fmt.mjs ADDED
@@ -0,0 +1,8 @@
1
+ import ultraciteFmt from "ultracite/oxfmt";
2
+ // src/fmt.ts
3
+ const { ignorePatterns: coreIgnores = [] } = ultraciteFmt;
4
+ const fmt = ({ ignores = [] } = {}) => ({
5
+ ...ultraciteFmt,
6
+ ignorePatterns: [...coreIgnores, ...ignores]
7
+ });
8
+ export { fmt };
@@ -0,0 +1,3 @@
1
+ import upstream from "@foldkit/oxlint-plugin";
2
+ declare const plugin: typeof upstream;
3
+ export { plugin as default };
@@ -0,0 +1,17 @@
1
+ import * as Arr from "effect/Array";
2
+ import upstream from "@foldkit/oxlint-plugin";
3
+ // src/foldkit.ts
4
+ const serverGlobals = upstream.rules["no-nonportable-server-globals"];
5
+ const plugin = {
6
+ ...upstream,
7
+ rules: {
8
+ ...upstream.rules,
9
+ "no-nonportable-server-globals": {
10
+ ...serverGlobals,
11
+ create(context) {
12
+ return Arr.some(context.sourceCode.ast.body, (node) => node.type === "ImportDeclaration" && node.importKind !== "type" && (node.source.value === "vite-plus/test/browser" || node.source.value === "vitest/browser") && (Arr.isReadonlyArrayEmpty(node.specifiers) || Arr.some(node.specifiers, (specifier) => specifier.type !== "ImportSpecifier" || specifier.importKind !== "type"))) ? {} : serverGlobals.create(context);
13
+ }
14
+ }
15
+ }
16
+ };
17
+ export { plugin as default };
@@ -0,0 +1,32 @@
1
+ import { Packuments } from "./compatible.mjs";
2
+ import { HeldRules } from "./effect-tsgo.mjs";
3
+ import { Exception } from "./exceptions.mjs";
4
+ import { Catalog } from "./versions.mjs";
5
+ import { OxlintConfig } from "vite-plus/lint";
6
+ type Ranges = Readonly<Record<string, string>>;
7
+ export declare const manifestRanges: (text: string) => ReadonlyArray<readonly [string, Ranges]>;
8
+ export declare const isFoldkitViteInput: (file: string) => boolean;
9
+ export declare const foldkitViteFindings: (files: ReadonlyArray<readonly [string, string]>) => ReadonlyArray<string>;
10
+ export declare const exactFindings: {
11
+ (text: string): (file: string) => ReadonlyArray<string>;
12
+ (file: string, text: string): ReadonlyArray<string>;
13
+ };
14
+ export declare const pinFindings: {
15
+ (text: string, rootCatalog?: Ranges): (file: string) => ReadonlyArray<string>;
16
+ (file: string, text: string, rootCatalog?: Ranges): ReadonlyArray<string>;
17
+ };
18
+ export declare const ruleFindings: {
19
+ (list?: ReadonlyArray<Exception>): (config: OxlintConfig) => ReadonlyArray<string>;
20
+ (config: OxlintConfig, list?: ReadonlyArray<Exception>): ReadonlyArray<string>;
21
+ };
22
+ export declare const exceptionFindings: (list?: ReadonlyArray<Exception>) => ReadonlyArray<string>;
23
+ export declare const heldFindings: {
24
+ (list?: undefined): ReadonlyArray<string>;
25
+ (catalog?: ReadonlyArray<string>): (list?: HeldRules) => ReadonlyArray<string>;
26
+ (list?: HeldRules, catalog?: ReadonlyArray<string>): ReadonlyArray<string>;
27
+ };
28
+ export declare const tagFindings: {
29
+ (registry: Packuments): (current: Catalog) => ReadonlyArray<string>;
30
+ (current: Catalog, registry: Packuments): ReadonlyArray<string>;
31
+ };
32
+ export {};
package/dist/guard.mjs ADDED
@@ -0,0 +1,131 @@
1
+ import { latestOf, onLatestLine, otherTags } from "./compatible.mjs";
2
+ import { effectTsgoCatalog, enforcedTsgoRules, held } from "./effect-tsgo.mjs";
3
+ import { exceptions } from "./exceptions.mjs";
4
+ import { birbprophetRules, effectRules, foldkitRules } from "./lint.mjs";
5
+ import { n as rikalabsRules } from "./rikalabs-hPKWFZ1P.mjs";
6
+ import { lead, versionOf } from "./versions.mjs";
7
+ import * as Arr from "effect/Array";
8
+ import { dual } from "effect/Function";
9
+ import * as HashSet from "effect/HashSet";
10
+ import * as Option from "effect/Option";
11
+ import * as R from "effect/Record";
12
+ import * as Schema from "effect/Schema";
13
+ import * as Str from "effect/String";
14
+ import * as Effect from "effect/Effect";
15
+ import * as Result from "effect/Result";
16
+ // src/guard.ts
17
+ const Versions = Schema.Record(Schema.String, Schema.String).pipe(Schema.withDecodingDefaultKey(Effect.succeed({})));
18
+ const Catalogs = Schema.Record(Schema.String, Schema.Record(Schema.String, Schema.String)).pipe(Schema.withDecodingDefaultKey(Effect.succeed({})));
19
+ const WorkspaceList = Schema.Array(Schema.String);
20
+ const WorkspaceCatalogs = Schema.Struct({
21
+ catalog: Versions,
22
+ catalogs: Catalogs
23
+ });
24
+ const Manifest = Schema.fromJsonString(Schema.Struct({
25
+ dependencies: Versions,
26
+ devDependencies: Versions,
27
+ peerDependencies: Versions,
28
+ optionalDependencies: Versions,
29
+ overrides: Versions,
30
+ resolutions: Versions,
31
+ catalog: Versions,
32
+ catalogs: Catalogs,
33
+ workspaces: Schema.optionalKey(Schema.Union([WorkspaceList, WorkspaceCatalogs]))
34
+ }));
35
+ const named = (prefix, catalogs) => Arr.map(R.toEntries(catalogs), ([name, ranges]) => [`${prefix}.${name}`, ranges]);
36
+ const manifestRanges = (text) => {
37
+ const decoded = Schema.decodeResult(Manifest)(text);
38
+ if (Result.isFailure(decoded)) throw decoded.failure;
39
+ const manifest = decoded.success;
40
+ const workspaces = Schema.is(WorkspaceCatalogs)(manifest.workspaces) ? manifest.workspaces : {
41
+ catalog: {},
42
+ catalogs: {}
43
+ };
44
+ return [
45
+ ["dependencies", manifest.dependencies],
46
+ ["devDependencies", manifest.devDependencies],
47
+ ["peerDependencies", manifest.peerDependencies],
48
+ ["optionalDependencies", manifest.optionalDependencies],
49
+ ["overrides", manifest.overrides],
50
+ ["resolutions", manifest.resolutions],
51
+ ["catalog", manifest.catalog],
52
+ ["workspaces.catalog", workspaces.catalog],
53
+ ...named("catalogs", manifest.catalogs),
54
+ ...named("workspaces.catalogs", workspaces.catalogs)
55
+ ];
56
+ };
57
+ const SEMVER = String.raw`\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?`;
58
+ const EXACT = new RegExp(String.raw`^(?:npm:(?:@[\w.-]+\/)?[\w.-]+@)?${SEMVER}$`, "u");
59
+ const REFERENCE = /^(?:catalog:[\w.-]*|workspace:\*)$/u;
60
+ const DEPENDENCY_FIELDS = HashSet.fromIterable([
61
+ "dependencies",
62
+ "devDependencies",
63
+ "peerDependencies",
64
+ "optionalDependencies"
65
+ ]);
66
+ const VITE_CONFIG = /(?:^|\/)vite\.config\.[cm]?[jt]s$/u;
67
+ const MANIFEST = /(?:^|\/)package\.json$/u;
68
+ const VITE_PLUGIN = /["'`]@foldkit\/vite-plugin["'`]/u;
69
+ const folderOf = (file) => Str.slice(0, Str.lastIndexOf("/")(file).pipe(Option.getOrElse(() => -1)) + 1)(file);
70
+ const isFoldkitViteInput = (file) => MANIFEST.test(file) || VITE_CONFIG.test(file);
71
+ const foldkitViteFindings = (files) => {
72
+ 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)] : []));
73
+ 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`] : []);
74
+ };
75
+ 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`])));
76
+ 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), {
77
+ onNone: () => [],
78
+ onSome: (pinnedVersion) => {
79
+ const actual = written === "catalog:" ? Option.getOrElse(R.get(rootCatalog, name), () => written) : written;
80
+ return actual === pinnedVersion || Str.startsWith("workspace:")(written) ? [] : [`${file} ${field} ${name}: ${actual} is not the toolchain catalog's ${pinnedVersion}`];
81
+ }
82
+ }))));
83
+ const severityOf = (setting) => String(Schema.is(Schema.Array(Schema.Unknown))(setting) ? setting[0] : setting);
84
+ const atError = (setting) => [
85
+ "error",
86
+ "deny",
87
+ "2"
88
+ ].includes(severityOf(setting));
89
+ const settingOf = (rules, rule) => Option.fromNullishOr(rules?.[rule]);
90
+ const guarded = [
91
+ ...R.keys(foldkitRules),
92
+ ...R.keys(effectRules),
93
+ ...R.keys(birbprophetRules),
94
+ ...R.keys(rikalabsRules),
95
+ ...enforcedTsgoRules
96
+ ];
97
+ const excepted = (override, rule, list) => Arr.some(list, (exception) => exception.rules.includes(rule) && override.files.length === exception.files.length && Arr.every(override.files, (file) => exception.files.includes(file)));
98
+ const overrideFindings = (where, overrides, list) => Arr.flatMap(overrides, (override) => Arr.flatMap(guarded, (rule) => Option.match(settingOf(override.rules, rule), {
99
+ onNone: () => [],
100
+ onSome: (setting) => atError(setting) || excepted(override, rule, list) ? [] : [`${where} override for ${Arr.join(override.files, ", ")} sets ${rule} to ${severityOf(setting)} outside a named-file exception`]
101
+ })));
102
+ const inheritedFindings = (where, { extends: extendedConfigs = [] }) => Arr.flatMap(extendedConfigs, ({ overrides = [], ...extended }, index) => {
103
+ const path = `${where}extends[${index}]`;
104
+ return [...overrideFindings(path, overrides, []), ...inheritedFindings(`${path}.`, extended)];
105
+ });
106
+ const ruleFindings = dual((args) => args[0] !== void 0 && !Schema.is(Schema.Array(Schema.Unknown))(args[0]), ({ overrides = [], ...config }, list = exceptions) => [
107
+ ...Arr.flatMap(guarded, (rule) => Option.match(settingOf(config.rules, rule), {
108
+ onNone: () => [`${rule} is not set`],
109
+ onSome: (setting) => atError(setting) ? [] : [`${rule} is ${severityOf(setting)}`]
110
+ })),
111
+ ...overrideFindings("the config's", overrides, list),
112
+ ...inheritedFindings("", config)
113
+ ]);
114
+ const GLOB = /[*?[\]{}!]/u;
115
+ const ISSUE = /^https:\/\/github\.com\/[\w.-]+\/[\w.-]+\/issues\/\d+$/u;
116
+ const exceptionFindings = (list = exceptions) => Arr.flatMap(list, (exception, index) => [
117
+ ...Arr.isReadonlyArrayEmpty(exception.files) ? [`exception ${index} names no file`] : [],
118
+ ...Arr.flatMap(exception.files, (file) => GLOB.test(file) ? [`exception ${index} names ${file}, a pattern rather than a file`] : []),
119
+ ...Arr.isReadonlyArrayEmpty(exception.rules) ? [`exception ${index} names no rule`] : [],
120
+ ...ISSUE.test(exception.issue) ? [] : [`exception ${index} has no issue link: ${exception.issue}`]
121
+ ]);
122
+ const heldFindings = dual((args) => !Schema.is(Schema.Array(Schema.Unknown))(args[0]), (list = held, catalog = effectTsgoCatalog) => [...ISSUE.test(list.issue) ? [] : [`the held @effect/tsgo rules have no issue link: ${list.issue}`], ...Arr.flatMap(list.rules, (rule) => catalog.includes(rule) ? [] : [`${rule} is held but is not in the @effect/tsgo catalog`])]);
123
+ const familyTagFindings = (registry, family) => Option.match(latestOf(registry, family), {
124
+ onNone: () => [`${lead(family)} has no latest tag in the registry record`],
125
+ onSome: (latest) => family.version === latest ? [] : Option.match(Arr.findFirst(otherTags(registry, family), ([, version]) => version === family.version), {
126
+ onSome: ([tag]) => [`${family.name} ${family.version} comes from the ${tag} tag`],
127
+ onNone: () => onLatestLine(family.version, latest) ? [] : [`${family.name} ${family.version} is not on npm's latest line (${latest})`]
128
+ })
129
+ });
130
+ const tagFindings = dual(2, (current, registry) => Arr.flatMap(current.families, (family) => familyTagFindings(registry, family)));
131
+ export { exactFindings, exceptionFindings, foldkitViteFindings, heldFindings, isFoldkitViteInput, manifestRanges, pinFindings, ruleFindings, tagFindings };
@@ -0,0 +1,16 @@
1
+ import * as Schema from "effect/Schema";
2
+ import * as Effect from "effect/Effect";
3
+ import { FileSystem } from "effect/FileSystem";
4
+ import { Path } from "effect/Path";
5
+ export declare const worktreePrePush = "#!/bin/sh\nif ! root=$(git rev-parse --show-toplevel); then\n printf '%s\\n' 'pre-push: could not determine the invoking worktree root' >&2\n exit 1\nfi\nif [ ! -f \"$root/node_modules/.bin/vp\" ] || [ ! -x \"$root/node_modules/.bin/vp\" ]; then\n printf '%s\\n' \"pre-push: missing or nonexecutable $root/node_modules/.bin/vp\" >&2\n exit 1\nfi\nif [ ! -f \"$root/.vite-hooks/pre-push\" ]; then\n printf '%s\\n' \"pre-push: missing $root/.vite-hooks/pre-push\" >&2\n exit 1\nfi\nif ! git -C \"$root\" ls-files --error-unmatch .vite-hooks/pre-push >/dev/null 2>&1; then\n printf '%s\\n' \"pre-push: untracked $root/.vite-hooks/pre-push\" >&2\n exit 1\nfi\nexport PATH=\"$root/node_modules/.bin:$PATH\"\nexec /bin/sh -e \"$root/.vite-hooks/pre-push\" \"$@\"\n";
6
+ declare const Setup_base: Schema.Class<Setup, Schema.TaggedStruct<"Setup", {
7
+ readonly message: Schema.String;
8
+ }>, import("effect/Cause").YieldableError & {
9
+ readonly brand: unique symbol;
10
+ }>;
11
+ declare class Setup extends Setup_base {}
12
+ export declare const configurePrePush: (args_0: {
13
+ readonly cwd: string;
14
+ readonly agent: boolean;
15
+ }) => Effect.Effect<void, import("effect/PlatformError").PlatformError | Setup, import("effect/process/ChildProcessSpawner").ChildProcessSpawner | FileSystem | Path>;
16
+ export {};
package/dist/hooks.mjs ADDED
@@ -0,0 +1,137 @@
1
+ import * as Arr from "effect/Array";
2
+ import * as Schema from "effect/Schema";
3
+ import * as Str from "effect/String";
4
+ import * as Effect from "effect/Effect";
5
+ import { FileSystem } from "effect/FileSystem";
6
+ import { Path } from "effect/Path";
7
+ import { ChildProcess } from "effect/process";
8
+ import * as Stream from "effect/Stream";
9
+ // src/hooks.ts
10
+ const worktreePrePush = `#!/bin/sh
11
+ if ! root=$(git rev-parse --show-toplevel); then
12
+ printf '%s\\n' 'pre-push: could not determine the invoking worktree root' >&2
13
+ exit 1
14
+ fi
15
+ if [ ! -f "$root/node_modules/.bin/vp" ] || [ ! -x "$root/node_modules/.bin/vp" ]; then
16
+ printf '%s\\n' "pre-push: missing or nonexecutable $root/node_modules/.bin/vp" >&2
17
+ exit 1
18
+ fi
19
+ if [ ! -f "$root/.vite-hooks/pre-push" ]; then
20
+ printf '%s\\n' "pre-push: missing $root/.vite-hooks/pre-push" >&2
21
+ exit 1
22
+ fi
23
+ if ! git -C "$root" ls-files --error-unmatch .vite-hooks/pre-push >/dev/null 2>&1; then
24
+ printf '%s\\n' "pre-push: untracked $root/.vite-hooks/pre-push" >&2
25
+ exit 1
26
+ fi
27
+ export PATH="$root/node_modules/.bin:$PATH"
28
+ exec /bin/sh -e "$root/.vite-hooks/pre-push" "$@"
29
+ `;
30
+ var Setup = class extends Schema.TaggedError()("Setup", { message: Schema.String }) {};
31
+ const execute = Effect.fn("Hooks.execute")(function* (command) {
32
+ const child = yield* command;
33
+ const [code, stdout, stderr] = yield* Effect.all([
34
+ child.exitCode,
35
+ child.stdout.pipe(Stream.decodeText, Stream.mkString),
36
+ child.stderr.pipe(Stream.decodeText, Stream.mkString)
37
+ ], { concurrency: "unbounded" });
38
+ if (Number(code) !== 0) return yield* Setup.make({ message: `${command.command} ${Arr.join(Arr.map(command.args, String), " ")} exited ${code}: ${stdout}${stderr}` });
39
+ return {
40
+ stdout,
41
+ stderr
42
+ };
43
+ });
44
+ const git = Effect.fn("Hooks.git")(function* (cwd, args) {
45
+ return yield* execute(ChildProcess.make("git", args, {
46
+ cwd,
47
+ stdin: "ignore"
48
+ }));
49
+ });
50
+ const localVp = Effect.fn("Hooks.localVp")(function* (root, args) {
51
+ return yield* execute(ChildProcess.make(`${root}/node_modules/.bin/vp`, args, {
52
+ cwd: root,
53
+ stdin: "ignore"
54
+ }));
55
+ });
56
+ const requireFile = Effect.fn("Hooks.requireFile")(function* (file) {
57
+ const stat = yield* (yield* FileSystem).stat(file);
58
+ if (stat.type !== "File") return yield* Setup.make({ message: `Required pre-push setup file is not a file: ${file}` });
59
+ return stat;
60
+ });
61
+ const requireExecutable = Effect.fn("Hooks.requireExecutable")(function* (file) {
62
+ const stat = yield* requireFile(file);
63
+ if (!Arr.some([
64
+ 64,
65
+ 8,
66
+ 1
67
+ ], (permission) => Math.floor(stat.mode / permission) % 2 === 1)) return yield* Setup.make({ message: `Required pre-push setup file is not executable: ${file}` });
68
+ return stat;
69
+ });
70
+ const installPrePush = Effect.fn("Hooks.installPrePush")(function* (root) {
71
+ const fs = yield* FileSystem;
72
+ const path = yield* Path;
73
+ const generated = path.join(root, ".vite-hooks", "_");
74
+ yield* requireFile(path.join(generated, "h"));
75
+ const dispatcher = path.join(generated, "pre-push");
76
+ yield* requireFile(dispatcher);
77
+ yield* git(root, [
78
+ "config",
79
+ "--local",
80
+ "core.hooksPath",
81
+ generated
82
+ ]);
83
+ yield* fs.writeFileString(dispatcher, worktreePrePush);
84
+ yield* fs.chmod(dispatcher, 493);
85
+ });
86
+ const verifyActivePrePush = Effect.fn("Hooks.verifyActivePrePush")(function* (root) {
87
+ const fs = yield* FileSystem;
88
+ const path = yield* Path;
89
+ const active = yield* git(root, [
90
+ "rev-parse",
91
+ "--path-format=absolute",
92
+ "--git-path",
93
+ "hooks"
94
+ ]);
95
+ const activeHook = path.join(Str.trim(active.stdout), "pre-push");
96
+ const bytes = yield* fs.readFile(activeHook);
97
+ const expected = new TextEncoder().encode(worktreePrePush);
98
+ if (bytes.length !== expected.length || bytes.some((byte, index) => byte !== expected[index])) return yield* Setup.make({ message: `Active pre-push has wrong bytes: ${activeHook}` });
99
+ return yield* requireExecutable(activeHook).pipe(Effect.asVoid);
100
+ });
101
+ const configurePrePush = Effect.fn("Hooks.configurePrePush")(function* ({ cwd, agent }) {
102
+ const path = yield* Path;
103
+ const rootResult = yield* git(cwd, ["rev-parse", "--show-toplevel"]);
104
+ const root = Str.trim(rootResult.stdout);
105
+ const vp = path.join(root, "node_modules", ".bin", "vp");
106
+ yield* requireExecutable(vp);
107
+ const tracked = path.join(root, ".vite-hooks", "pre-push");
108
+ yield* requireFile(tracked);
109
+ yield* git(root, [
110
+ "ls-files",
111
+ "--error-unmatch",
112
+ ".vite-hooks/pre-push"
113
+ ]);
114
+ yield* localVp(root, [
115
+ "config",
116
+ "--hooks",
117
+ agent ? "--agent" : "--no-agent"
118
+ ]);
119
+ const active = yield* git(root, [
120
+ "rev-parse",
121
+ "--path-format=absolute",
122
+ "--git-path",
123
+ "hooks"
124
+ ]);
125
+ const generated = path.join(root, ".vite-hooks", "_");
126
+ const disabled = yield* git(root, [
127
+ "config",
128
+ "--type=bool",
129
+ "--default=false",
130
+ "--get",
131
+ "vp.hooks.disabled"
132
+ ]);
133
+ if (Str.trim(disabled.stdout) === "true") return yield* Setup.make({ message: "Native pre-push setup has hooks disabled" });
134
+ if (Str.trim(active.stdout) === generated) yield* installPrePush(root);
135
+ return yield* verifyActivePrePush(root);
136
+ }, Effect.scoped);
137
+ export { configurePrePush, worktreePrePush };
@@ -0,0 +1 @@
1
+ export declare const packageName = "@milkenjoyer/toolchain";
package/dist/index.mjs ADDED
@@ -0,0 +1,3 @@
1
+ // src/index.ts
2
+ const packageName = "@milkenjoyer/toolchain";
3
+ export { packageName };
@@ -0,0 +1,7 @@
1
+ import { KnipConfiguration } from "knip";
2
+ export type KnipOptions = {
3
+ readonly entry?: ReadonlyArray<string>;
4
+ readonly ignoreDependencies?: ReadonlyArray<string>;
5
+ readonly workspaces?: KnipConfiguration["workspaces"];
6
+ };
7
+ export declare const knip: ({ entry, ignoreDependencies, workspaces }?: KnipOptions) => KnipConfiguration;
package/dist/knip.mjs ADDED
@@ -0,0 +1,15 @@
1
+ // src/knip.ts
2
+ const baseEntry = [
3
+ "*.run.ts",
4
+ "scripts/*.ts",
5
+ "tests/fixtures/**/*.ts"
6
+ ];
7
+ const toolchainPlugins = ["@effect/language-service", "@foldkit/oxlint-plugin"];
8
+ const knip = ({ entry = [], ignoreDependencies = [], workspaces = {} } = {}) => ({
9
+ ignoreDependencies: [...toolchainPlugins, ...ignoreDependencies],
10
+ workspaces: {
11
+ ".": { entry: [...baseEntry, ...entry] },
12
+ ...workspaces
13
+ }
14
+ });
15
+ export { knip };
@@ -0,0 +1,9 @@
1
+ import { OxlintConfig } from "vite-plus/lint";
2
+ export type LintOptions = {
3
+ readonly ignores?: ReadonlyArray<string>;
4
+ readonly domainPackages?: ReadonlyArray<string>;
5
+ };
6
+ export declare const foldkitRules: Record<string, "error">;
7
+ export declare const effectRules: Record<string, "error">;
8
+ export declare const birbprophetRules: Record<string, "error">;
9
+ export declare const lint: ({ ignores, domainPackages }?: LintOptions) => OxlintConfig;
package/dist/lint.mjs ADDED
@@ -0,0 +1,113 @@
1
+ import { t as plugin } from "./effect-plugin-DARbVmA3.mjs";
2
+ import { effectTsgoPlugin, effectTsgoRules } from "./effect-tsgo.mjs";
3
+ import { exceptions } from "./exceptions.mjs";
4
+ import plugin$1 from "./foldkit.mjs";
5
+ import { t as plugin$2 } from "./plugin-CBUJ7Tgd.mjs";
6
+ import { n as rikalabsRules, t as plugin$3 } from "./rikalabs-hPKWFZ1P.mjs";
7
+ import { staticRules } from "./rules.mjs";
8
+ import * as Arr from "effect/Array";
9
+ import * as HashSet from "effect/HashSet";
10
+ import * as Option from "effect/Option";
11
+ import * as R from "effect/Record";
12
+ import * as Str from "effect/String";
13
+ import ultraciteCore from "ultracite/oxlint/core";
14
+ import ultraciteVitest from "ultracite/oxlint/vitest";
15
+ // src/lint.ts
16
+ const plugins = [
17
+ "typescript",
18
+ "import",
19
+ "promise",
20
+ "unicorn",
21
+ "oxc",
22
+ "eslint",
23
+ "node",
24
+ "vitest",
25
+ "jsdoc",
26
+ effectTsgoPlugin
27
+ ];
28
+ const categories = {
29
+ correctness: "error",
30
+ suspicious: "error",
31
+ pedantic: "error",
32
+ perf: "error",
33
+ style: "error",
34
+ restriction: "off",
35
+ nursery: "off"
36
+ };
37
+ const atError = (prefix, rules) => R.fromEntries(Arr.map(rules, (rule) => [`${prefix}/${rule}`, "error"]));
38
+ const foldkitRules = atError(plugin$1.meta.name, R.keys(plugin$1.rules));
39
+ const effectRules = atError(plugin.meta.name, R.keys(plugin.rules));
40
+ const birbprophetRules = atError(plugin$2.meta.name, R.keys(plugin$2.rules));
41
+ const offEverywhere = HashSet.fromIterable(Arr.flatMap(R.toEntries(staticRules), ([rule, setting]) => setting === "off" ? [rule] : []));
42
+ const { overrides: vitestOverrides = [] } = ultraciteVitest;
43
+ const { ignorePatterns: coreIgnores = [] } = ultraciteCore;
44
+ const vitestPreset = {
45
+ ...ultraciteVitest,
46
+ overrides: Arr.map(vitestOverrides, ({ rules = {}, ...override }) => ({
47
+ ...override,
48
+ rules: R.filter(rules, (_setting, rule) => !HashSet.has(offEverywhere, rule))
49
+ }))
50
+ };
51
+ const resolved = (specifier) => decodeURIComponent(new URL(import.meta.resolve(specifier)).pathname);
52
+ const ownExtension = Str.slice(Str.lastIndexOf(".")(import.meta.filename).pipe(Option.getOrElse(() => -1)))(import.meta.filename);
53
+ const sibling = (module) => resolved(`./${module}${ownExtension}`);
54
+ const domainTiers = (roots) => Arr.match(roots, {
55
+ onEmpty: () => [],
56
+ onNonEmpty: () => [{
57
+ files: Arr.map(roots, (root) => `${root}/src/**`),
58
+ rules: { "unicorn/filename-case": ["error", {
59
+ case: "pascalCase",
60
+ multipleFileExtensions: true
61
+ }] }
62
+ }, {
63
+ files: Arr.map(roots, (root) => `${root}/src/**/*.command.ts`),
64
+ rules: { "eslint/max-classes-per-file": "off" }
65
+ }]
66
+ });
67
+ const exceptionTier = (exception) => ({
68
+ files: [...exception.files],
69
+ rules: R.fromEntries(Arr.map(exception.rules, (rule) => [rule, "off"]))
70
+ });
71
+ const lint = ({ ignores = [], domainPackages = [] } = {}) => ({
72
+ plugins,
73
+ categories,
74
+ extends: [ultraciteCore, vitestPreset],
75
+ jsPlugins: [
76
+ {
77
+ name: "vite-plus",
78
+ specifier: resolved("vite-plus/oxlint-plugin")
79
+ },
80
+ {
81
+ name: plugin$1.meta.name,
82
+ specifier: sibling("foldkit")
83
+ },
84
+ {
85
+ name: plugin.meta.name,
86
+ specifier: sibling("effect-plugin")
87
+ },
88
+ {
89
+ name: plugin$2.meta.name,
90
+ specifier: sibling("plugin")
91
+ },
92
+ {
93
+ name: plugin$3.meta.name,
94
+ specifier: sibling("rikalabs")
95
+ }
96
+ ],
97
+ options: {
98
+ typeAware: true,
99
+ typeCheck: true
100
+ },
101
+ rules: {
102
+ ...staticRules,
103
+ "vite-plus/prefer-vite-plus-imports": "error",
104
+ ...foldkitRules,
105
+ ...effectRules,
106
+ ...birbprophetRules,
107
+ ...rikalabsRules,
108
+ ...effectTsgoRules
109
+ },
110
+ overrides: [...domainTiers(domainPackages), ...Arr.map(exceptions, exceptionTier)],
111
+ ignorePatterns: [...coreIgnores, ...ignores]
112
+ });
113
+ export { birbprophetRules, effectRules, foldkitRules, lint };