@r_masseater/i68 0.2.2 → 0.2.4
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/{app-CS-xLSmb.mjs → app-Dvnt_9zv.mjs} +1 -2
- package/dist/{app-CS-xLSmb.mjs.map → app-Dvnt_9zv.mjs.map} +1 -1
- package/dist/cli-cJLiG0az.mjs +111 -0
- package/dist/cli-cJLiG0az.mjs.map +1 -0
- package/dist/cli.mjs +1 -1
- package/dist/index.mjs +2 -2
- package/dist/presets.mjs +13 -7
- package/dist/presets.mjs.map +1 -1
- package/dist/{section-nUBg-T7E.mjs → section-KjxJ8PF-.mjs} +3 -131
- package/dist/section-KjxJ8PF-.mjs.map +1 -0
- package/package.json +5 -5
- package/dist/cli-BsA_dteW.mjs +0 -20
- package/dist/cli-BsA_dteW.mjs.map +0 -1
- package/dist/section-nUBg-T7E.mjs.map +0 -1
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import "./section-nUBg-T7E.mjs";
|
|
2
1
|
// src/entities/rule/model/define.ts
|
|
3
2
|
const defineRule = (rule) => rule;
|
|
4
3
|
const definePlugin = (plugin) => plugin;
|
|
5
4
|
export { defineRule as n, definePlugin as t };
|
|
6
5
|
|
|
7
|
-
//# sourceMappingURL=app-
|
|
6
|
+
//# sourceMappingURL=app-Dvnt_9zv.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app-
|
|
1
|
+
{"version":3,"file":"app-Dvnt_9zv.mjs","names":[],"sources":["../src/entities/rule/model/define.ts"],"sourcesContent":["import type { Plugin, Rule } from \"#/shared/config/index.ts\";\n\nexport const defineRule = (rule: Rule): Rule => rule;\n\nexport const definePlugin = (plugin: Plugin): Plugin => plugin;\n"],"mappings":";AAEA,MAAa,cAAc,SAAqB;AAEhD,MAAa,gBAAgB,WAA2B"}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { c as NotUtf8Error, n as songPathspecs, o as failedWith, r as lint, s as formatDiagnostic, t as i68Section } from "./section-KjxJ8PF-.mjs";
|
|
2
|
+
import { Array, Console, Effect, FileSystem, Function, Option, Path, String, pipe } from "effect";
|
|
3
|
+
import { runMain } from "@r_masseater/node-main";
|
|
4
|
+
import { ChildProcess, ChildProcessSpawner } from "effect/process";
|
|
5
|
+
import { Argument, Command } from "effect/cli";
|
|
6
|
+
import { resolveConfigFromFile } from "vite-plus";
|
|
7
|
+
// ../lint-host/src/features/run-cli/model/cli.ts
|
|
8
|
+
const CONFIG_FILES = [
|
|
9
|
+
"vite.config.ts",
|
|
10
|
+
"vite.config.mts",
|
|
11
|
+
"vite.config.js",
|
|
12
|
+
"vite.config.mjs"
|
|
13
|
+
];
|
|
14
|
+
const FAILED = 1;
|
|
15
|
+
const DATA_FIRST_ARITY = 2;
|
|
16
|
+
const STRICT_UTF8 = new TextDecoder("utf-8", { fatal: true });
|
|
17
|
+
const readSectionIn = (source, root) => Effect.gen(function* readConfig() {
|
|
18
|
+
const fileSystem = yield* FileSystem.FileSystem;
|
|
19
|
+
const path = yield* Path.Path;
|
|
20
|
+
const found = yield* pipe(CONFIG_FILES, Array.map((name) => path.join(root, name)), Effect.filter((file) => fileSystem.exists(file).pipe(Effect.orElseSucceed(() => false))));
|
|
21
|
+
const loaded = yield* Option.match(Array.head(found), {
|
|
22
|
+
onNone: () => Effect.succeed({}),
|
|
23
|
+
onSome: (file) => Effect.tryPromise({
|
|
24
|
+
try: () => resolveConfigFromFile(file),
|
|
25
|
+
catch: source.failWith(`could not load ${file}`)
|
|
26
|
+
})
|
|
27
|
+
});
|
|
28
|
+
return source.section(loaded);
|
|
29
|
+
}).pipe(Effect.withSpan(`${source.name}.config`));
|
|
30
|
+
Function.dual(DATA_FIRST_ARITY, readSectionIn);
|
|
31
|
+
const trackedFiles = (root, pathspecs) => Effect.gen(function* listFiles() {
|
|
32
|
+
const output = yield* (yield* ChildProcessSpawner.ChildProcessSpawner).string(ChildProcess.make("git", [
|
|
33
|
+
"ls-files",
|
|
34
|
+
"-co",
|
|
35
|
+
"--exclude-standard",
|
|
36
|
+
"-z",
|
|
37
|
+
"--",
|
|
38
|
+
...pathspecs
|
|
39
|
+
], { cwd: root }));
|
|
40
|
+
return pipe(String.split(output, "\0"), Array.filter(String.isNonEmpty));
|
|
41
|
+
});
|
|
42
|
+
const requestOf = (config, patterns) => Array.match(patterns, {
|
|
43
|
+
onEmpty: () => ({ config }),
|
|
44
|
+
onNonEmpty: (given) => ({
|
|
45
|
+
config,
|
|
46
|
+
patterns: given
|
|
47
|
+
})
|
|
48
|
+
});
|
|
49
|
+
const hasError = (found) => pipe(found, Array.some(({ severity }) => severity === "error"));
|
|
50
|
+
const failWhen = (failed) => Effect.when(Effect.sync(() => {
|
|
51
|
+
process.exitCode = FAILED;
|
|
52
|
+
}), Effect.succeed(failed)).pipe(Effect.asVoid);
|
|
53
|
+
const printAll = (found, format) => Array.match(found, {
|
|
54
|
+
onEmpty: () => Effect.void,
|
|
55
|
+
onNonEmpty: (all) => Console.log(pipe(all, Array.map(format), Array.join("\n")))
|
|
56
|
+
});
|
|
57
|
+
const readerIn = (root, failWith) => Effect.gen(function* reader() {
|
|
58
|
+
const fileSystem = yield* FileSystem.FileSystem;
|
|
59
|
+
const path = yield* Path.Path;
|
|
60
|
+
return (file) => fileSystem.readFile(path.resolve(root, file)).pipe(Effect.mapError(failWith(`could not read ${file}`)), Effect.flatMap((bytes) => Effect.try({
|
|
61
|
+
try: () => STRICT_UTF8.decode(bytes),
|
|
62
|
+
catch: () => NotUtf8Error.make({ path: file })
|
|
63
|
+
})));
|
|
64
|
+
});
|
|
65
|
+
const mainOf = (cli, patterns) => Effect.gen(function* main() {
|
|
66
|
+
const root = process.cwd();
|
|
67
|
+
const config = yield* readSectionIn(cli, root);
|
|
68
|
+
const pathspecs = cli.pathspecs(requestOf(config, patterns));
|
|
69
|
+
const { files, projectFiles } = yield* Effect.all({
|
|
70
|
+
files: trackedFiles(root, pathspecs).pipe(Effect.withSpan(`${cli.name}.files`)),
|
|
71
|
+
projectFiles: trackedFiles(root, []).pipe(Effect.withSpan(`${cli.name}.project`))
|
|
72
|
+
}, { concurrency: "unbounded" });
|
|
73
|
+
const read = yield* readerIn(root, cli.failWith);
|
|
74
|
+
const found = yield* cli.lint({
|
|
75
|
+
root,
|
|
76
|
+
files,
|
|
77
|
+
projectFiles,
|
|
78
|
+
config,
|
|
79
|
+
read
|
|
80
|
+
});
|
|
81
|
+
yield* printAll(found, cli.format);
|
|
82
|
+
yield* failWhen(hasError(found));
|
|
83
|
+
});
|
|
84
|
+
const variadicOf = ({ name, description }) => Argument.String(name).pipe(Argument.withDescription(description), Argument.variadic());
|
|
85
|
+
const pathspecArgument = () => variadicOf({
|
|
86
|
+
name: "pathspec",
|
|
87
|
+
description: "Git pathspecs of the files to lint, in place of the configured ones"
|
|
88
|
+
});
|
|
89
|
+
const runCli$1 = (cli) => {
|
|
90
|
+
const command = Command.make(cli.name, { pathspecs: pathspecArgument() }, ({ pathspecs }) => mainOf(cli, pathspecs)).pipe(Command.withDescription(cli.description));
|
|
91
|
+
runMain(cli.name)(Command.run(command, { version: cli.version }));
|
|
92
|
+
};
|
|
93
|
+
// package.json
|
|
94
|
+
var version = "0.2.4";
|
|
95
|
+
var description = "A linter for .fumx songs that checks musical rules such as notes outside the key, part ranges, voicing clashes and parallel fifths, configured from vite.config.ts with rules written in TypeScript.";
|
|
96
|
+
// src/app/cli.ts
|
|
97
|
+
const runCli = () => {
|
|
98
|
+
runCli$1({
|
|
99
|
+
name: "i68",
|
|
100
|
+
version,
|
|
101
|
+
description,
|
|
102
|
+
section: i68Section,
|
|
103
|
+
pathspecs: songPathspecs,
|
|
104
|
+
lint,
|
|
105
|
+
format: formatDiagnostic,
|
|
106
|
+
failWith: failedWith
|
|
107
|
+
});
|
|
108
|
+
};
|
|
109
|
+
export { runCli };
|
|
110
|
+
|
|
111
|
+
//# sourceMappingURL=cli-cJLiG0az.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli-cJLiG0az.mjs","names":["Arr","Fn","Str","runCli","manifest.version","manifest.description"],"sources":["../../lint-host/src/features/run-cli/model/cli.ts","../package.json","../src/app/cli.ts"],"sourcesContent":["import { runMain } from \"@r_masseater/node-main\";\nimport {\n Array as Arr,\n Console,\n Effect,\n FileSystem,\n Function as Fn,\n Option,\n Path,\n Record as Rec,\n String as Str,\n pipe,\n} from \"effect\";\nimport { Argument, Command, Flag } from \"effect/cli\";\nimport type { PlatformError } from \"effect/PlatformError\";\nimport { ChildProcess, ChildProcessSpawner } from \"effect/process\";\nimport { resolveConfigFromFile } from \"vite-plus\";\n\nimport { NotUtf8Error } from \"#/shared/lib/fail.ts\";\nimport type { FailWith } from \"#/shared/lib/fail.ts\";\n\nconst CONFIG_FILES = [\"vite.config.ts\", \"vite.config.mts\", \"vite.config.js\", \"vite.config.mjs\"];\nconst FAILED = 1;\nconst DATA_FIRST_ARITY = 2;\nconst STRICT_UTF8 = new TextDecoder(\"utf-8\", { fatal: true });\n\nexport interface Reported {\n readonly severity: string;\n}\n\nexport interface LintCall<Config, Failure> {\n readonly root: string;\n readonly files: readonly string[];\n readonly projectFiles: readonly string[];\n readonly config: Config;\n readonly read: (file: string) => Effect.Effect<string, Failure | NotUtf8Error>;\n}\n\nexport interface PathspecRequest<Config> {\n readonly config: Config;\n readonly patterns?: readonly string[];\n}\n\nexport interface SectionSource<Config, Failure> {\n readonly name: string;\n readonly version: string;\n readonly description: string;\n readonly section: (config: unknown) => Config;\n readonly failWith: FailWith<Failure>;\n}\n\nexport interface Cli<Config, Found extends Reported, Failure> extends SectionSource<\n Config,\n Failure\n> {\n readonly pathspecs: (request: PathspecRequest<Config>) => readonly string[];\n readonly lint: (call: LintCall<Config, Failure>) => Effect.Effect<readonly Found[], Failure>;\n readonly format: (found: Found) => string;\n}\n\nexport interface ToolParameter {\n readonly name: string;\n readonly description: string;\n}\n\nexport interface ToolInput {\n readonly flags: ReadonlySet<string>;\n readonly args: readonly string[];\n}\n\nexport interface ToolCall<Config> {\n readonly root: string;\n readonly config: Config;\n readonly input: ToolInput;\n}\n\nexport interface Tool<Config, Found, Failure> extends SectionSource<Config, Failure> {\n readonly flags: readonly ToolParameter[];\n readonly argument: ToolParameter;\n readonly scan: (call: ToolCall<Config>) => Effect.Effect<readonly Found[], Failure>;\n readonly format: (found: Found) => string;\n}\n\ntype CliServices = FileSystem.FileSystem | Path.Path | ChildProcessSpawner.ChildProcessSpawner;\n\nconst readSectionIn = <Config, Failure>(\n source: SectionSource<Config, Failure>,\n root: string,\n): Effect.Effect<Config, Failure, FileSystem.FileSystem | Path.Path> =>\n Effect.gen(function* readConfig() {\n const fileSystem = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const found = yield* pipe(\n CONFIG_FILES,\n Arr.map((name) => path.join(root, name)),\n Effect.filter((file) => fileSystem.exists(file).pipe(Effect.orElseSucceed(() => false))),\n );\n const loaded = yield* Option.match(Arr.head(found), {\n onNone: () => Effect.succeed<unknown>({}),\n onSome: (file) =>\n Effect.tryPromise({\n try: () => resolveConfigFromFile(file),\n catch: source.failWith(`could not load ${file}`),\n }),\n });\n return source.section(loaded);\n }).pipe(Effect.withSpan(`${source.name}.config`));\n\n/** @internal */\nexport const readSection: {\n (\n root: string,\n ): <Config, Failure>(\n source: SectionSource<Config, Failure>,\n ) => Effect.Effect<Config, Failure, FileSystem.FileSystem | Path.Path>;\n <Config, Failure>(\n source: SectionSource<Config, Failure>,\n root: string,\n ): Effect.Effect<Config, Failure, FileSystem.FileSystem | Path.Path>;\n} = Fn.dual(DATA_FIRST_ARITY, readSectionIn);\n\nconst trackedFiles = (\n root: string,\n pathspecs: readonly string[],\n): Effect.Effect<readonly string[], PlatformError, ChildProcessSpawner.ChildProcessSpawner> =>\n Effect.gen(function* listFiles() {\n const spawner = yield* ChildProcessSpawner.ChildProcessSpawner;\n const output = yield* spawner.string(\n ChildProcess.make(\n \"git\",\n [\"ls-files\", \"-co\", \"--exclude-standard\", \"-z\", \"--\", ...pathspecs],\n { cwd: root },\n ),\n );\n return pipe(Str.split(output, \"\\0\"), Arr.filter(Str.isNonEmpty));\n });\n\nconst requestOf = <Config>(config: Config, patterns: readonly string[]): PathspecRequest<Config> =>\n Arr.match(patterns, {\n onEmpty: () => ({ config }),\n onNonEmpty: (given) => ({ config, patterns: given }),\n });\n\nconst hasError = (found: readonly Reported[]): boolean =>\n pipe(\n found,\n Arr.some(({ severity }) => severity === \"error\"),\n );\n\nconst failWhen = (failed: boolean): Effect.Effect<void> =>\n Effect.when(\n Effect.sync(() => {\n process.exitCode = FAILED;\n }),\n Effect.succeed(failed),\n ).pipe(Effect.asVoid);\n\nconst printAll = <Found>(\n found: readonly Found[],\n format: (found: Found) => string,\n): Effect.Effect<void> =>\n Arr.match(found, {\n onEmpty: () => Effect.void,\n onNonEmpty: (all) => Console.log(pipe(all, Arr.map(format), Arr.join(\"\\n\"))),\n });\n\nconst readerIn = <Failure>(\n root: string,\n failWith: FailWith<Failure>,\n): Effect.Effect<\n (file: string) => Effect.Effect<string, Failure | NotUtf8Error>,\n never,\n FileSystem.FileSystem | Path.Path\n> =>\n Effect.gen(function* reader() {\n const fileSystem = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n return (file: string): Effect.Effect<string, Failure | NotUtf8Error> =>\n fileSystem.readFile(path.resolve(root, file)).pipe(\n Effect.mapError(failWith(`could not read ${file}`)),\n Effect.flatMap((bytes) =>\n Effect.try({\n try: () => STRICT_UTF8.decode(bytes),\n catch: () => NotUtf8Error.make({ path: file }),\n }),\n ),\n );\n });\n\nconst mainOf = <Config, Found extends Reported, Failure>(\n cli: Cli<Config, Found, Failure>,\n patterns: readonly string[],\n): Effect.Effect<void, Failure | PlatformError, CliServices> =>\n Effect.gen(function* main() {\n const root = process.cwd();\n const config = yield* readSectionIn(cli, root);\n const pathspecs = cli.pathspecs(requestOf(config, patterns));\n const { files, projectFiles } = yield* Effect.all(\n {\n files: trackedFiles(root, pathspecs).pipe(Effect.withSpan(`${cli.name}.files`)),\n projectFiles: trackedFiles(root, []).pipe(Effect.withSpan(`${cli.name}.project`)),\n },\n { concurrency: \"unbounded\" },\n );\n const read = yield* readerIn(root, cli.failWith);\n const found = yield* cli.lint({ root, files, projectFiles, config, read });\n yield* printAll(found, cli.format);\n yield* failWhen(hasError(found));\n });\n\nconst toolMainOf =\n <Config, Found, Failure>(tool: Tool<Config, Found, Failure>) =>\n (input: ToolInput): Effect.Effect<void, Failure | PlatformError, CliServices> =>\n Effect.gen(function* main() {\n const root = process.cwd();\n const config = yield* readSectionIn(tool, root);\n const found = yield* tool.scan({ root, config, input });\n yield* printAll(found, tool.format);\n yield* failWhen(Arr.isReadonlyArrayNonEmpty(found));\n });\n\nconst variadicOf = ({ name, description }: ToolParameter): Argument.Argument<readonly string[]> =>\n Argument.String(name).pipe(Argument.withDescription(description), Argument.variadic());\n\nconst flagsOf = (flags: readonly ToolParameter[]): Readonly<Record<string, Flag.Flag<boolean>>> =>\n Rec.fromEntries(\n pipe(\n flags,\n Arr.map(({ name, description }) => [\n name,\n Flag.Boolean(name).pipe(Flag.withDescription(description), Flag.withDefault(false)),\n ]),\n ),\n );\n\nconst setFlags = (values: Readonly<Record<string, boolean>>): ReadonlySet<string> =>\n new Set(pipe(values, Rec.filter(Fn.identity), Rec.keys));\n\nexport const runTool = <Config, Found, Failure>(tool: Tool<Config, Found, Failure>): void => {\n const command = Command.make(\n tool.name,\n { args: variadicOf(tool.argument), flags: flagsOf(tool.flags) },\n ({ args, flags }) => toolMainOf(tool)({ args, flags: setFlags(flags) }),\n ).pipe(Command.withDescription(tool.description));\n runMain(tool.name)(Command.run(command, { version: tool.version }));\n};\n\nconst pathspecArgument = (): Argument.Argument<readonly string[]> =>\n variadicOf({\n name: \"pathspec\",\n description: \"Git pathspecs of the files to lint, in place of the configured ones\",\n });\n\nexport const runCli = <Config, Found extends Reported, Failure>(\n cli: Cli<Config, Found, Failure>,\n): void => {\n const command = Command.make(cli.name, { pathspecs: pathspecArgument() }, ({ pathspecs }) =>\n mainOf(cli, pathspecs),\n ).pipe(Command.withDescription(cli.description));\n runMain(cli.name)(Command.run(command, { version: cli.version }));\n};\n","","import { formatDiagnostic, runCli as runLinter } from \"@masseater.dev/lint-host\";\nimport manifest from \"@r_masseater/i68/package.json\" with { type: \"json\" };\n\nimport { failedWith } from \"#/shared/lib/errors.ts\";\n\nimport { lint } from \"./lint.ts\";\nimport { i68Section, songPathspecs } from \"./section.ts\";\n\nexport const runCli = (): void => {\n runLinter({\n name: \"i68\",\n version: manifest.version,\n description: manifest.description,\n section: i68Section,\n pathspecs: songPathspecs,\n lint,\n format: formatDiagnostic,\n failWith: failedWith,\n });\n};\n"],"mappings":";;;;;;;AAqBA,MAAM,eAAe;CAAC;CAAkB;CAAmB;CAAkB;AAAiB;AAC9F,MAAM,SAAS;AACf,MAAM,mBAAmB;AACzB,MAAM,cAAc,IAAI,YAAY,SAAS,EAAE,OAAO,KAAK,CAAC;AA6D5D,MAAM,iBACJ,QACA,SAEA,OAAO,IAAI,UAAU,aAAa;CAChC,MAAM,aAAa,OAAO,WAAW;CACrC,MAAM,OAAO,OAAO,KAAK;CACzB,MAAM,QAAQ,OAAO,KACnB,cACAA,MAAI,KAAK,SAAS,KAAK,KAAK,MAAM,IAAI,CAAC,GACvC,OAAO,QAAQ,SAAS,WAAW,OAAO,IAAI,CAAC,CAAC,KAAK,OAAO,oBAAoB,KAAK,CAAC,CAAC,CACzF;CACA,MAAM,SAAS,OAAO,OAAO,MAAMA,MAAI,KAAK,KAAK,GAAG;EAClD,cAAc,OAAO,QAAiB,CAAC,CAAC;EACxC,SAAS,SACP,OAAO,WAAW;GAChB,WAAW,sBAAsB,IAAI;GACrC,OAAO,OAAO,SAAS,kBAAkB,MAAM;EACjD,CAAC;CACL,CAAC;CACD,OAAO,OAAO,QAAQ,MAAM;AAC9B,CAAC,CAAC,CAAC,KAAK,OAAO,SAAS,GAAG,OAAO,KAAK,QAAQ,CAAC;AAa9CC,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W;EACX;EACA,QAAQ;EACR,UAAU;CACZ,CAAC;AACH"}
|
package/dist/cli.mjs
CHANGED
package/dist/index.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { n as defineRule, t as definePlugin } from "./app-
|
|
2
|
-
import { a as I68Error, i as lintText, n as songPathspecs, r as lint, s as formatDiagnostic, t as i68Section } from "./section-
|
|
1
|
+
import { n as defineRule, t as definePlugin } from "./app-Dvnt_9zv.mjs";
|
|
2
|
+
import { a as I68Error, i as lintText, n as songPathspecs, r as lint, s as formatDiagnostic, t as i68Section } from "./section-KjxJ8PF-.mjs";
|
|
3
3
|
export { I68Error, definePlugin, defineRule, formatDiagnostic as format, i68Section, lint, lintText, songPathspecs };
|
package/dist/presets.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { n as defineRule, t as definePlugin } from "./app-
|
|
2
|
-
import { A as tracksOf, C as neighborsOf, D as sortByPitch, E as reporterOf, O as soundingAt, S as lowest, T as overlappingPairs, _ as pitchClassOf, a as StyleRulesSchema, b as highest, c as mixKeyOf, d as bach_chorales_default, f as progressionOf, g as nameOf, h as midiOf, i as HABIT_KINDS, k as topLineOf, m as keysOf, n as placeIn, p as keyAt, r as trackKeyOf, s as subjectKeyOf, t as mixFactsOf, u as longestContext, v as MELODIC, w as onsetsOf, x as isPitched, y as hasRole } from "./mix-facts-fJHVIUfj.mjs";
|
|
1
|
+
import { n as defineRule, t as definePlugin } from "./app-Dvnt_9zv.mjs";
|
|
2
|
+
import { A as tracksOf, C as neighborsOf, D as sortByPitch, E as reporterOf, O as soundingAt, S as lowest, T as overlappingPairs, _ as pitchClassOf, a as StyleRulesSchema, b as highest, c as mixKeyOf, d as bach_chorales_default, f as progressionOf, g as nameOf, h as midiOf$1, i as HABIT_KINDS, k as topLineOf, m as keysOf, n as placeIn, p as keyAt, r as trackKeyOf, s as subjectKeyOf, t as mixFactsOf, u as longestContext, v as MELODIC, w as onsetsOf, x as isPitched, y as hasRole } from "./mix-facts-fJHVIUfj.mjs";
|
|
3
3
|
import { Array, Match, Number, Option, Order, Predicate, Record, String as String$1, pipe } from "effect";
|
|
4
4
|
import { TICKS_PER_WHOLE } from "@r_masseater/song-format";
|
|
5
|
-
import { Chord } from "tonal";
|
|
5
|
+
import { Chord, Note, VoiceLeading } from "tonal";
|
|
6
6
|
// src/app/presets/shared/lib/options.ts
|
|
7
7
|
const numberOption = ({ key, fallback }) => (options) => pipe(Option.fromNullishOr(options[key]), Option.filter(Predicate.isNumber), Option.getOrElse(() => fallback));
|
|
8
8
|
// src/app/presets/features/check-harmony/model/chord-above-melody.ts
|
|
@@ -152,9 +152,15 @@ const chordOf = (onset) => ({
|
|
|
152
152
|
first: Array.headNonEmpty(onset),
|
|
153
153
|
pitches: pipe(onset, Array.map((sounding) => sounding.midi), Array.dedupe)
|
|
154
154
|
});
|
|
155
|
-
const
|
|
155
|
+
const midiOf = (note) => Option.fromNullishOr(Note.midi(note));
|
|
156
|
+
const sizeOf = ([from, to]) => Option.map(Option.all([midiOf(from), midiOf(to)]), ([start, end]) => Math.abs(end - start));
|
|
157
|
+
const namesOf = (chord) => pipe(chord.pitches, Array.map((midi) => Note.fromMidi(midi)));
|
|
158
|
+
const movesOf = (previous, next) => {
|
|
159
|
+
const { moves } = VoiceLeading.get(namesOf(previous), namesOf(next));
|
|
160
|
+
return pipe(moves, Array.map(sizeOf), Array.getSomes);
|
|
161
|
+
};
|
|
156
162
|
const checkChange = (report, max) => ([previous, next]) => {
|
|
157
|
-
const leaps = pipe(
|
|
163
|
+
const leaps = pipe(movesOf(previous, next), Array.filter((move) => move > max));
|
|
158
164
|
if (next.first.start - previous.first.start <= NEARBY && Array.isReadonlyArrayNonEmpty(leaps)) report(`${String(next.first.line)}:${String(next.first.start)}`, {
|
|
159
165
|
line: next.first.line,
|
|
160
166
|
column: next.first.column,
|
|
@@ -393,8 +399,8 @@ const DEFAULT_RANGES = {
|
|
|
393
399
|
const RANGE_LENGTH = 2;
|
|
394
400
|
const isRange = (value) => Array.isArray(value) && value.length === RANGE_LENGTH && pipe(value, Array.every(Predicate.isString));
|
|
395
401
|
const boundsOf = ([low, high]) => Option.all({
|
|
396
|
-
low: midiOf(low),
|
|
397
|
-
high: midiOf(high),
|
|
402
|
+
low: midiOf$1(low),
|
|
403
|
+
high: midiOf$1(high),
|
|
398
404
|
name: Option.some(`${low}-${high}`)
|
|
399
405
|
});
|
|
400
406
|
const configured = (options) => pipe(Option.fromNullishOr(options["ranges"]), Option.filter(Predicate.isObject), Option.map((value) => ({
|
package/dist/presets.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"presets.mjs","names":["UNISON","checkPair","Arr","stepsOf","Arr","checkPair","Rec","Arr","MAJOR_THIRD","Arr","Arr","Arr","Arr","checkStep","Arr","Arr","Rec","Arr","checkNote","Arr","Rec","checkNote","Arr","Rec","Arr","Arr","Str","FIRST","Rec","Arr","Num","BACH_CHORALES","Str","Arr","Arr"],"sources":["../src/app/presets/shared/lib/options.ts","../src/app/presets/features/check-harmony/model/chord-above-melody.ts","../src/app/presets/features/check-harmony/model/crowded-low-mids.ts","../src/app/presets/features/check-harmony/model/low-interval-limit.ts","../src/app/presets/features/check-harmony/model/semitone-clash.ts","../src/app/presets/features/check-harmony/model/voice-jump.ts","../src/app/presets/features/check-harmony/model/preset.ts","../src/app/presets/shared/lib/time.ts","../src/app/presets/features/check-pop/model/breath.ts","../src/app/presets/features/check-pop/model/melody-leap.ts","../src/app/presets/shared/lib/chords.ts","../src/app/presets/features/check-pop/model/out-of-key.ts","../src/app/presets/features/check-pop/model/part-range.ts","../src/app/presets/features/check-pop/model/preset.ts","../src/app/presets/features/check-classical/model/outer-voices.ts","../src/app/presets/features/check-classical/model/parallel-perfects.ts","../src/app/presets/features/check-classical/model/unresolved-dissonance.ts","../src/app/presets/features/check-classical/model/preset.ts","../src/app/presets/features/check-progressions/model/named.ts","../src/app/presets/features/check-progressions/model/preset.ts","../src/app/presets/features/check-style/model/rare-transition.ts","../src/app/presets/features/check-style/model/preset.ts","../src/app/presets/features/check-habits/model/occasions.ts","../src/app/presets/features/check-habits/model/habit-rule.ts","../src/app/presets/features/check-habits/model/preset.ts","../src/app/presets.ts"],"sourcesContent":["import { Option, Predicate, pipe } from \"effect\";\n\nimport type { RuleOptions } from \"#/shared/config/index.ts\";\n\nexport interface NumberOption {\n readonly key: string;\n readonly fallback: number;\n}\n\nexport const numberOption =\n ({ key, fallback }: NumberOption) =>\n (options: RuleOptions): number =>\n pipe(\n Option.fromNullishOr(options[key]),\n Option.filter(Predicate.isNumber),\n Option.getOrElse(() => fallback),\n );\n","import type { Sounding } from \"@r_masseater/song-format/analysis\";\nimport { Array as Arr, Option, pipe } from \"effect\";\n\nimport { numberOption } from \"#/app/presets/shared/lib/options.ts\";\nimport { hasRole, overlappingPairs, reporterOf } from \"#/app/presets/shared/lib/voices.ts\";\nimport type { Pair, Reporter } from \"#/app/presets/shared/lib/voices.ts\";\nimport { defineRule } from \"#/entities/rule/index.ts\";\nimport type { Rule } from \"#/shared/config/index.ts\";\n\nconst UNISON = 0;\nconst within = numberOption({ key: \"within\", fallback: UNISON });\nconst isMelody = hasRole([\"melody\"]);\nconst isHarmony = hasRole([\"harmony\"]);\n\nconst placementOf = (distance: number, room: number): Option.Option<string> => {\n if (distance < UNISON) {\n return Option.some(\"above\");\n }\n if (distance > UNISON && distance <= room) {\n return Option.some(\"just below\");\n }\n return Option.none();\n};\n\nconst checkPair =\n (report: Reporter, room: number) =>\n (pair: Pair): void => {\n const parts = Option.all({\n melody: pipe(pair, Arr.findFirst(isMelody)),\n chord: pipe(pair, Arr.findFirst(isHarmony)),\n });\n for (const { melody, chord } of Option.toArray(parts)) {\n for (const where of Option.toArray(placementOf(melody.midi - chord.midi, room))) {\n report(`${String(chord.line)}:${String(chord.column)}:${String(chord.bar)}`, {\n line: chord.line,\n column: chord.column,\n message: `${chord.spelling} in ${chord.track} sits ${where} the melody note ${melody.spelling}`,\n detail: \"Keep the chord below the melody with some room between them\",\n });\n }\n }\n };\n\nconst isPart = (sounding: Sounding): boolean => isMelody(sounding) || isHarmony(sounding);\n\nexport const chordAboveMelody: Rule = defineRule({\n meta: { description: \"Chord parts stay below the lead melody\" },\n check: (context) => {\n const check = checkPair(reporterOf(context), within(context.options));\n for (const pair of overlappingPairs(pipe(context.soundings, Arr.filter(isPart)))) {\n check(pair);\n }\n },\n});\n","import type { Bar } from \"@r_masseater/song-format\";\nimport { TICKS_PER_WHOLE } from \"@r_masseater/song-format\";\nimport type { Sounding } from \"@r_masseater/song-format/analysis\";\nimport { Array as Arr, Option, pipe } from \"effect\";\n\nimport { numberOption } from \"#/app/presets/shared/lib/options.ts\";\nimport { hasRole, isPitched, reporterOf, soundingAt } from \"#/app/presets/shared/lib/voices.ts\";\nimport type { Reporter } from \"#/app/presets/shared/lib/voices.ts\";\nimport { defineRule } from \"#/entities/rule/index.ts\";\nimport type { Rule } from \"#/shared/config/index.ts\";\n\nconst SIXTEENTHS_PER_WHOLE = 16;\nconst SIXTEENTH = TICKS_PER_WHOLE / SIXTEENTHS_PER_WHOLE;\nconst LOW_MID_FLOOR = 45;\nconst BASS_FLOOR = 40;\nconst LOW_MID_CEILING = 59;\nconst DEFAULT_MAX = 3;\nconst maxNotes = numberOption({ key: \"max\", fallback: DEFAULT_MAX });\n\nconst floorOf = (sounding: Sounding): number => {\n if (hasRole([\"bass\"])(sounding)) {\n return BASS_FLOOR;\n }\n return LOW_MID_FLOOR;\n};\n\nconst inLowMids = (sounding: Sounding): boolean =>\n isPitched(sounding) && sounding.midi <= LOW_MID_CEILING && sounding.midi >= floorOf(sounding);\n\nconst stepsOf = (bar: Bar): readonly number[] =>\n Arr.makeBy(Math.ceil(bar.length / SIXTEENTH), (index) => bar.start + index * SIXTEENTH);\n\nconst crowdAt =\n (low: readonly Sounding[]) =>\n (tick: number): readonly Sounding[] =>\n pipe(\n soundingAt(low)(tick),\n Arr.dedupeWith((left, right) => left.track === right.track && left.midi === right.midi),\n );\n\nconst spellingsOf = (notes: readonly Sounding[]): string =>\n pipe(\n notes,\n Arr.map((note) => note.spelling),\n Arr.join(\", \"),\n );\n\nconst checkBar =\n (report: Reporter, low: readonly Sounding[], max: number) =>\n (bar: Bar): void => {\n const crowded = pipe(\n stepsOf(bar),\n Arr.map(crowdAt(low)),\n Arr.findFirst((notes) => notes.length > max),\n );\n for (const notes of Option.toArray(crowded)) {\n for (const first of Option.toArray(Arr.head(notes))) {\n report(String(bar.index), {\n line: first.line,\n column: first.column,\n message: `${String(notes.length)} notes crowd the low mids in bar ${String(bar.index)}: ${spellingsOf(notes)}`,\n detail: \"Thin the chord or move notes out of A2-B3\",\n });\n }\n }\n };\n\nexport const crowdedLowMids: Rule = defineRule({\n meta: { description: \"Few notes pile up between A2 and B3 at once\" },\n check: (context) => {\n const low = pipe(context.soundings, Arr.filter(inLowMids));\n const check = checkBar(reporterOf(context), low, maxNotes(context.options));\n for (const bar of context.song.bars) {\n check(bar);\n }\n },\n});\n","import { Array as Arr, Option, Record as Rec, pipe } from \"effect\";\n\nimport { nameOf } from \"#/app/presets/shared/lib/pitch.ts\";\nimport { isPitched, overlappingPairs, reporterOf } from \"#/app/presets/shared/lib/voices.ts\";\nimport type { Pair, Reporter } from \"#/app/presets/shared/lib/voices.ts\";\nimport { defineRule } from \"#/entities/rule/index.ts\";\nimport type { Rule } from \"#/shared/config/index.ts\";\n\nconst LIMITS: Readonly<Record<string, number>> = {\n \"1\": 52,\n \"2\": 51,\n \"3\": 48,\n \"4\": 46,\n \"5\": 46,\n \"6\": 46,\n \"7\": 34,\n \"8\": 43,\n \"9\": 41,\n \"10\": 41,\n \"11\": 41,\n \"13\": 40,\n \"14\": 39,\n};\n\nconst checkPair =\n (report: Reporter) =>\n (pair: Pair): void => {\n const [first, second] = pair;\n const low = Math.min(first.midi, second.midi);\n const gap = Math.abs(first.midi - second.midi);\n const limits = pipe(LIMITS, Rec.get(String(gap)), Option.toArray);\n for (const limit of limits) {\n if (low < limit) {\n report(`${String(second.line)}:${String(low)}:${String(gap)}`, {\n line: second.line,\n column: second.column,\n message: `${String(gap)} semitones between ${first.spelling} (${first.track}) and ${second.spelling} (${second.track}) is below its limit ${nameOf(limit)}`,\n detail: \"Widen the interval or move the upper note up an octave\",\n });\n }\n }\n };\n\nexport const lowIntervalLimit: Rule = defineRule({\n meta: { description: \"Close intervals stay above the pitch where they turn muddy\" },\n check: (context) => {\n const check = checkPair(reporterOf(context));\n for (const pair of overlappingPairs(pipe(context.soundings, Arr.filter(isPitched)))) {\n check(pair);\n }\n },\n});\n","import type { Sounding } from \"@r_masseater/song-format/analysis\";\nimport { Array as Arr, Match, Option, pipe } from \"effect\";\n\nimport { pitchClassOf } from \"#/app/presets/shared/lib/pitch.ts\";\nimport {\n hasRole,\n isPitched,\n overlappingPairs,\n reporterOf,\n soundingAt,\n sortByPitch,\n} from \"#/app/presets/shared/lib/voices.ts\";\nimport type { Pair, Reporter } from \"#/app/presets/shared/lib/voices.ts\";\nimport { defineRule } from \"#/entities/rule/index.ts\";\nimport type { Rule } from \"#/shared/config/index.ts\";\n\nconst MINOR_SECOND = 1;\nconst MINOR_NINTH = 13;\nconst CLUSTER_FLOOR = 59;\n\nconst MAJOR_THIRD = 4;\nconst MINOR_SEVENTH = 10;\nconst isBass = hasRole([\"bass\"]);\n\ntype Excused = (bottom: Sounding, top: Sounding) => boolean;\n\nconst dominantOver =\n (soundings: readonly Sounding[]): Excused =>\n (bottom, top) => {\n if (!isBass(bottom) && !isBass(top)) {\n return false;\n }\n if (!isBass(bottom) || top.midi - bottom.midi !== MINOR_NINTH) {\n return true;\n }\n const classes = pipe(\n soundingAt(soundings)(top.start),\n Arr.map((other) => pitchClassOf(other.midi - bottom.midi)),\n );\n return Arr.contains(classes, MAJOR_THIRD) && Arr.contains(classes, MINOR_SEVENTH);\n };\n\nconst nameOfGap = (gap: number): Option.Option<string> =>\n Match.value(gap).pipe(\n Match.when(MINOR_SECOND, () => Option.some(\"minor 2nd\")),\n Match.when(MINOR_NINTH, () => Option.some(\"minor 9th\")),\n Match.orElse(() => Option.none()),\n );\n\nconst isCluster = (low: Sounding, high: Sounding): boolean =>\n low.track === high.track && high.midi - low.midi === MINOR_SECOND && low.midi >= CLUSTER_FLOOR;\n\nconst checkPair =\n (report: Reporter, excused: Excused) =>\n (pair: Pair): void => {\n const [low, high] = sortByPitch(pair);\n const [, later] = pair;\n for (const [bottom, top] of Option.toArray(\n Option.all([Option.fromNullishOr(low), Option.fromNullishOr(high)]),\n )) {\n for (const name of Option.toArray(nameOfGap(top.midi - bottom.midi))) {\n if (!isCluster(bottom, top) && !excused(bottom, top)) {\n report(`${String(later.line)}:${String(bottom.midi)}:${String(top.midi)}`, {\n line: later.line,\n column: later.column,\n message: `${top.spelling} (${top.track}) and ${bottom.spelling} (${bottom.track}) clash a ${name} apart`,\n detail: \"Move one of the two notes to a chord note\",\n });\n }\n }\n }\n };\n\nexport const semitoneClash: Rule = defineRule({\n meta: {\n description:\n \"Parts do not sound a minor 2nd or minor 9th apart, except the flat 9th of a dominant over its bass\",\n },\n check: (context) => {\n const pitched = pipe(context.soundings, Arr.filter(isPitched));\n const check = checkPair(reporterOf(context), dominantOver(pitched));\n for (const pair of overlappingPairs(pitched)) {\n check(pair);\n }\n },\n});\n","import { TICKS_PER_WHOLE } from \"@r_masseater/song-format\";\nimport type { Sounding } from \"@r_masseater/song-format/analysis\";\nimport { Array as Arr, pipe } from \"effect\";\n\nimport { numberOption } from \"#/app/presets/shared/lib/options.ts\";\nimport {\n hasRole,\n neighborsOf,\n onsetsOf,\n reporterOf,\n tracksOf,\n} from \"#/app/presets/shared/lib/voices.ts\";\nimport type { Onset, Reporter } from \"#/app/presets/shared/lib/voices.ts\";\nimport { defineRule } from \"#/entities/rule/index.ts\";\nimport type { Rule } from \"#/shared/config/index.ts\";\n\nconst MAJOR_THIRD = 4;\nconst MIN_VOICES = 3;\nconst NEARBY_WHOLES = 1.5;\nconst NEARBY = NEARBY_WHOLES * TICKS_PER_WHOLE;\nconst maxMove = numberOption({ key: \"max\", fallback: MAJOR_THIRD });\n\ninterface Chord {\n readonly first: Sounding;\n readonly pitches: readonly number[];\n}\n\nconst chordOf = (onset: Onset): Chord => ({\n first: Arr.headNonEmpty(onset),\n pitches: pipe(\n onset,\n Arr.map((sounding) => sounding.midi),\n Arr.dedupe,\n ),\n});\n\nconst nearestMove =\n (from: readonly number[]) =>\n (pitch: number): number =>\n Math.min(\n ...pipe(\n from,\n Arr.map((other) => Math.abs(pitch - other)),\n ),\n );\n\nconst checkChange =\n (report: Reporter, max: number) =>\n ([previous, next]: readonly [Chord, Chord]): void => {\n const leaps = pipe(\n next.pitches,\n Arr.map(nearestMove(previous.pitches)),\n Arr.filter((move) => move > max),\n );\n if (next.first.start - previous.first.start <= NEARBY && Arr.isReadonlyArrayNonEmpty(leaps)) {\n report(`${String(next.first.line)}:${String(next.first.start)}`, {\n line: next.first.line,\n column: next.first.column,\n message: `${String(leaps.length)} voices of ${next.first.track} leap more than ${String(max)} semitones into the next chord`,\n detail: \"Keep shared notes and move each voice to the closest note\",\n });\n }\n };\n\nconst chordsOf = (track: readonly Sounding[]): readonly Chord[] =>\n pipe(\n onsetsOf(track),\n Arr.map(chordOf),\n Arr.filter((chord) => chord.pitches.length >= MIN_VOICES),\n );\n\nexport const voiceJump: Rule = defineRule({\n meta: { description: \"Chord voices move to the nearest note of the next chord\" },\n check: (context) => {\n const check = checkChange(reporterOf(context), maxMove(context.options));\n const harmony = pipe(context.soundings, Arr.filter(hasRole([\"harmony\"])));\n for (const track of tracksOf(harmony)) {\n for (const change of neighborsOf(chordsOf(track))) {\n check(change);\n }\n }\n },\n});\n","import { definePlugin } from \"#/entities/rule/index.ts\";\nimport type { I68Config, Plugin } from \"#/shared/config/index.ts\";\n\nimport { chordAboveMelody } from \"./chord-above-melody.ts\";\nimport { crowdedLowMids } from \"./crowded-low-mids.ts\";\nimport { lowIntervalLimit } from \"./low-interval-limit.ts\";\nimport { semitoneClash } from \"./semitone-clash.ts\";\nimport { voiceJump } from \"./voice-jump.ts\";\n\nexport const harmonyPlugin: Plugin = definePlugin({\n rules: {\n \"semitone-clash\": semitoneClash,\n \"low-interval-limit\": lowIntervalLimit,\n \"crowded-low-mids\": crowdedLowMids,\n \"chord-above-melody\": chordAboveMelody,\n \"voice-jump\": voiceJump,\n },\n});\n\nexport const harmony = (): I68Config => ({\n plugins: { harmony: harmonyPlugin },\n rules: {\n \"harmony/semitone-clash\": \"warn\",\n \"harmony/low-interval-limit\": \"warn\",\n \"harmony/crowded-low-mids\": \"warn\",\n \"harmony/chord-above-melody\": \"warn\",\n \"harmony/voice-jump\": \"warn\",\n },\n});\n","import type { Bar, Song } from \"@r_masseater/song-format\";\nimport { TICKS_PER_WHOLE } from \"@r_masseater/song-format\";\nimport { Array as Arr, pipe } from \"effect\";\n\nconst SECONDS_PER_MINUTE = 60;\nconst QUARTERS_PER_WHOLE = 4;\nconst NONE = 0;\n\ninterface Segment {\n readonly start: number;\n readonly end: number;\n readonly bpm: number;\n}\n\nconst segmentsIn = (bar: Bar): readonly Segment[] =>\n Arr.match(bar.tempoSteps, {\n onEmpty: () => [{ start: bar.start, end: bar.start + bar.length, bpm: bar.tempo.bpm }],\n onNonEmpty: (steps) =>\n pipe(\n steps,\n Arr.map((step) => ({\n start: bar.start + step.offset,\n end: bar.start + step.offset + step.length,\n bpm: step.bpm,\n })),\n ),\n });\n\nconst secondsPerTick = (bpm: number): number =>\n (SECONDS_PER_MINUTE * QUARTERS_PER_WHOLE) / (bpm * TICKS_PER_WHOLE);\n\nexport const clockOf = (song: Song): ((tick: number) => number) => {\n const segments = pipe(song.bars, Arr.flatMap(segmentsIn));\n return (tick) => {\n let seconds = NONE;\n for (const segment of segments) {\n if (segment.start < tick) {\n seconds += (Math.min(tick, segment.end) - segment.start) * secondsPerTick(segment.bpm);\n }\n }\n return seconds;\n };\n};\n","import type { Sounding } from \"@r_masseater/song-format/analysis\";\nimport { Array as Arr, Option, pipe } from \"effect\";\n\nimport { numberOption } from \"#/app/presets/shared/lib/options.ts\";\nimport { clockOf } from \"#/app/presets/shared/lib/time.ts\";\nimport {\n MELODIC,\n hasRole,\n reporterOf,\n topLineOf,\n tracksOf,\n} from \"#/app/presets/shared/lib/voices.ts\";\nimport type { Reporter } from \"#/app/presets/shared/lib/voices.ts\";\nimport { defineRule } from \"#/entities/rule/index.ts\";\nimport type { Rule } from \"#/shared/config/index.ts\";\n\nconst DEFAULT_SECONDS = 8;\nconst DEFAULT_REST = 0.15;\nconst DIGITS = 1;\nconst LAST = 1;\nconst maxSeconds = numberOption({ key: \"seconds\", fallback: DEFAULT_SECONDS });\nconst minRest = numberOption({ key: \"rest\", fallback: DEFAULT_REST });\n\ntype Clock = (tick: number) => number;\n\ntype Phrase = Arr.NonEmptyReadonlyArray<Sounding>;\n\nconst phrasesOf =\n (clock: Clock, rest: number) =>\n (line: readonly Sounding[]): readonly Phrase[] =>\n Arr.reduce(line, Arr.empty<Phrase>(), (phrases, note): readonly Phrase[] =>\n pipe(\n Arr.last(phrases),\n Option.filter((phrase) => clock(note.start) - clock(Arr.lastNonEmpty(phrase).end) < rest),\n Option.match({\n onNone: () => Arr.append(phrases, Arr.of(note)),\n onSome: (phrase) => Arr.append(Arr.dropRight(phrases, LAST), Arr.append(phrase, note)),\n }),\n ),\n );\n\nconst endOf = (phrase: Phrase): number =>\n pipe(\n phrase,\n Arr.map((sounding) => sounding.end),\n (ends) => Math.max(...ends),\n );\n\nconst checkPhrase =\n (report: Reporter, clock: Clock, max: number) =>\n (phrase: Phrase): void => {\n const first = Arr.headNonEmpty(phrase);\n const seconds = clock(endOf(phrase)) - clock(first.start);\n if (seconds > max) {\n report(`${String(first.line)}:${String(first.start)}`, {\n line: first.line,\n column: first.column,\n message: `${first.track} sings for ${seconds.toFixed(DIGITS)} seconds without a rest`,\n detail: \"Put a short rest in the phrase\",\n });\n }\n };\n\nexport const breath: Rule = defineRule({\n meta: { description: \"A sung line leaves room to breathe\" },\n check: (context) => {\n const clock = clockOf(context.song);\n const check = checkPhrase(reporterOf(context), clock, maxSeconds(context.options));\n const split = phrasesOf(clock, minRest(context.options));\n const melodic = pipe(context.soundings, Arr.filter(hasRole(MELODIC)));\n for (const track of tracksOf(melodic)) {\n for (const phrase of split(topLineOf(track))) {\n check(phrase);\n }\n }\n },\n});\n","import { TICKS_PER_WHOLE } from \"@r_masseater/song-format\";\nimport type { Sounding } from \"@r_masseater/song-format/analysis\";\nimport { Array as Arr, pipe } from \"effect\";\n\nimport { numberOption } from \"#/app/presets/shared/lib/options.ts\";\nimport {\n MELODIC,\n hasRole,\n neighborsOf,\n reporterOf,\n topLineOf,\n tracksOf,\n} from \"#/app/presets/shared/lib/voices.ts\";\nimport type { Reporter } from \"#/app/presets/shared/lib/voices.ts\";\nimport { defineRule } from \"#/entities/rule/index.ts\";\nimport type { Rule } from \"#/shared/config/index.ts\";\n\nconst OCTAVE = 12;\nconst maxLeap = numberOption({ key: \"max\", fallback: OCTAVE });\n\nconst checkStep =\n (report: Reporter, max: number) =>\n ([previous, next]: readonly [Sounding, Sounding]): void => {\n const leap = Math.abs(next.midi - previous.midi);\n if (leap > max && next.start - previous.end < TICKS_PER_WHOLE) {\n report(`${String(next.line)}:${String(next.start)}`, {\n line: next.line,\n column: next.column,\n message: `${next.track} leaps ${String(leap)} semitones from ${previous.spelling} to ${next.spelling}`,\n detail: \"Make the jump smaller, or step back the other way right after it\",\n });\n }\n };\n\nexport const melodyLeap: Rule = defineRule({\n meta: { description: \"A melody does not jump further than an octave from one note to the next\" },\n check: (context) => {\n const check = checkStep(reporterOf(context), maxLeap(context.options));\n const melodic = pipe(context.soundings, Arr.filter(hasRole(MELODIC)));\n for (const track of tracksOf(melodic)) {\n for (const step of neighborsOf(topLineOf(track))) {\n check(step);\n }\n }\n },\n});\n","import { Array as Arr, Option, pipe } from \"effect\";\nimport { Chord } from \"tonal\";\n\nconst COMMON = [\n \"M\",\n \"m\",\n \"dim\",\n \"aug\",\n \"7\",\n \"maj7\",\n \"m7\",\n \"m7b5\",\n \"dim7\",\n \"sus4\",\n \"sus2\",\n \"6\",\n \"m6\",\n \"Madd9\",\n \"madd9\",\n \"9\",\n \"maj9\",\n \"m9\",\n \"7sus4\",\n \"m/ma7\",\n \"6add9\",\n \"m69\",\n \"5\",\n];\nconst DYAD = 2;\n\nconst isCommonName = (name: string): boolean =>\n pipe(\n Arr.head(Chord.get(name).aliases),\n Option.exists((alias) => Arr.contains(COMMON, alias)),\n );\n\nexport const isCommonChord = (pitchClasses: readonly string[]): boolean => {\n const names = Arr.dedupe(pitchClasses);\n if (names.length < DYAD) {\n return true;\n }\n return pipe(Chord.detect(names), Arr.some(isCommonName));\n};\n","import { TICKS_PER_WHOLE } from \"@r_masseater/song-format\";\nimport type { KeySpan, Sounding } from \"@r_masseater/song-format/analysis\";\nimport { Array as Arr, Option, Record as Rec, pipe } from \"effect\";\n\nimport { isCommonChord } from \"#/app/presets/shared/lib/chords.ts\";\nimport { keyAt, keysOf } from \"#/app/presets/shared/lib/keys.ts\";\nimport { pitchClassOf } from \"#/app/presets/shared/lib/pitch.ts\";\nimport {\n hasRole,\n isPitched,\n reporterOf,\n soundingAt,\n tracksOf,\n} from \"#/app/presets/shared/lib/voices.ts\";\nimport type { Reporter } from \"#/app/presets/shared/lib/voices.ts\";\nimport { defineRule } from \"#/entities/rule/index.ts\";\nimport type { Rule } from \"#/shared/config/index.ts\";\n\nconst EIGHTHS_PER_WHOLE = 8;\nconst ORNAMENT = TICKS_PER_WHOLE / EIGHTHS_PER_WHOLE;\nconst HALF_STEP = 1;\nconst WHOLE_STEP = 2;\nconst MAJOR_STEPS = { tonic: 0, second: 2, third: 4, fourth: 5, fifth: 7, sixth: 9, seventh: 11 };\nconst MINOR_STEPS = {\n tonic: 0,\n second: 2,\n flatThird: 3,\n fourth: 5,\n fifth: 7,\n flatSixth: 8,\n raisedSixth: 9,\n flatSeventh: 10,\n leadingTone: 11,\n};\nconst MAJOR = Rec.values(MAJOR_STEPS);\nconst MINOR = Rec.values(MINOR_STEPS);\nconst stepsOf = (key: KeySpan): readonly number[] => {\n if (key.mode === \"major\") {\n return MAJOR;\n }\n return MINOR;\n};\n\nconst inScale =\n (key: KeySpan) =>\n (midi: number): boolean =>\n Arr.contains(stepsOf(key), pitchClassOf(midi - key.pitchClass));\n\ntype Fits = (sounding: Sounding) => boolean;\n\nconst inChordOf = (soundings: readonly Sounding[]): Fits => {\n const harmony = pipe(soundings, Arr.filter(hasRole([\"bass\", \"harmony\"])));\n return (sounding) => {\n const under = soundingAt(harmony)(sounding.start);\n const shared = pipe(\n under,\n Arr.some(\n (other) =>\n other.track !== sounding.track &&\n pitchClassOf(other.midi) === pitchClassOf(sounding.midi),\n ),\n );\n const voicesChord =\n hasRole([\"bass\", \"harmony\"])(sounding) &&\n isCommonChord(\n pipe(\n under,\n Arr.map((other) => other.pitchClass),\n ),\n );\n return shared || voicesChord;\n };\n};\n\nconst isStep = (from: Sounding, to: Sounding): boolean => {\n const distance = Math.abs(to.midi - from.midi);\n return distance >= HALF_STEP && distance <= WHOLE_STEP;\n};\n\nconst neighboursOf =\n (track: readonly Sounding[]) =>\n (sounding: Sounding): Option.Option<readonly [Sounding, Sounding]> => {\n const before = pipe(\n track,\n Arr.findLast((other) => other.end === sounding.start),\n );\n const after = pipe(\n track,\n Arr.findFirst((other) => other.start === sounding.end),\n );\n return Option.all([before, after]);\n };\n\nconst isOrnament =\n (fits: Fits, track: readonly Sounding[]) =>\n (sounding: Sounding): boolean =>\n sounding.end - sounding.start <= ORNAMENT &&\n pipe(\n neighboursOf(track)(sounding),\n Option.exists(\n ([before, after]) =>\n isStep(before, sounding) && isStep(sounding, after) && fits(before) && fits(after),\n ),\n );\n\nconst fitsOf =\n (keys: readonly KeySpan[], inChord: Fits): Fits =>\n (sounding) =>\n inChord(sounding) ||\n pipe(\n keyAt(keys)(sounding.bar),\n Option.match({ onNone: () => true, onSome: (key) => inScale(key)(sounding.midi) }),\n );\n\ninterface NoteCheck {\n readonly report: Reporter;\n readonly keys: readonly KeySpan[];\n readonly fits: Fits;\n readonly tracks: readonly (readonly Sounding[])[];\n}\n\nconst trackOf =\n (tracks: readonly (readonly Sounding[])[]) =>\n (sounding: Sounding): readonly Sounding[] =>\n pipe(\n tracks,\n Arr.findFirst((candidate) =>\n pipe(\n candidate,\n Arr.some((other) => other.track === sounding.track),\n ),\n ),\n Option.getOrElse((): readonly Sounding[] => []),\n );\n\nconst checkNote =\n ({ report, keys, fits, tracks }: NoteCheck) =>\n (sounding: Sounding): void => {\n const track = trackOf(tracks)(sounding);\n for (const key of Option.toArray(keyAt(keys)(sounding.bar))) {\n if (!fits(sounding) && !isOrnament(fits, track)(sounding)) {\n report(`${String(sounding.line)}:${String(sounding.column)}`, {\n line: sounding.line,\n column: sounding.column,\n message: `${sounding.spelling} in ${sounding.track} is outside ${key.tonic} ${key.mode} and the chord under it`,\n detail: \"Move it a semitone, or ignore the line if the borrowed note is intended\",\n });\n }\n }\n };\n\nexport const outOfKey: Rule = defineRule({\n meta: { description: \"Notes stay in the key the notes around them imply\" },\n check: (context) => {\n const keys = keysOf(context.song);\n const pitched = pipe(context.soundings, Arr.filter(isPitched));\n const fits = fitsOf(keys, inChordOf(context.soundings));\n const check = checkNote({ report: reporterOf(context), keys, fits, tracks: tracksOf(pitched) });\n for (const sounding of pitched) {\n check(sounding);\n }\n },\n});\n","import type { Sounding } from \"@r_masseater/song-format/analysis\";\nimport { Array as Arr, Option, Predicate, Record as Rec, pipe } from \"effect\";\n\nimport { midiOf } from \"#/app/presets/shared/lib/pitch.ts\";\nimport { reporterOf } from \"#/app/presets/shared/lib/voices.ts\";\nimport type { Reporter } from \"#/app/presets/shared/lib/voices.ts\";\nimport { defineRule } from \"#/entities/rule/index.ts\";\nimport type { Rule, RuleOptions } from \"#/shared/config/index.ts\";\n\nexport type Range = readonly [string, string];\n\nexport type Ranges = Readonly<Record<string, Range>>;\n\nexport const DEFAULT_RANGES: Ranges = {\n melody: [\"C3\", \"C6\"],\n countermelody: [\"C3\", \"C6\"],\n bass: [\"E1\", \"C4\"],\n};\n\ninterface Bounds {\n readonly low: number;\n readonly high: number;\n readonly name: string;\n}\n\nconst RANGE_LENGTH = 2;\n\nconst isRange = (value: unknown): value is Range =>\n Arr.isArray(value) && value.length === RANGE_LENGTH && pipe(value, Arr.every(Predicate.isString));\n\nconst boundsOf = ([low, high]: Range): Option.Option<Bounds> =>\n Option.all({ low: midiOf(low), high: midiOf(high), name: Option.some(`${low}-${high}`) });\n\nconst configured = (options: RuleOptions): Readonly<Record<string, unknown>> =>\n pipe(\n Option.fromNullishOr(options[\"ranges\"]),\n Option.filter(Predicate.isObject),\n Option.map((value): Readonly<Record<string, unknown>> => ({ ...DEFAULT_RANGES, ...value })),\n Option.getOrElse((): Readonly<Record<string, unknown>> => DEFAULT_RANGES),\n );\n\nconst rangesOf = (options: RuleOptions): Readonly<Record<string, Bounds>> =>\n pipe(\n configured(options),\n Rec.toEntries,\n Arr.flatMap(([name, value]) =>\n pipe(\n Option.liftPredicate(value, isRange),\n Option.flatMap(boundsOf),\n Option.map((bounds): readonly [string, Bounds] => [name, bounds]),\n Option.toArray,\n ),\n ),\n Rec.fromEntries,\n );\n\nconst boundsFor =\n (ranges: Readonly<Record<string, Bounds>>) =>\n (sounding: Sounding): Option.Option<Bounds> =>\n pipe(\n ranges,\n Rec.get(sounding.track),\n Option.orElse(() =>\n pipe(\n sounding.role,\n Option.flatMap((role) => pipe(ranges, Rec.get(role))),\n ),\n ),\n );\n\nconst checkNote =\n (report: Reporter) =>\n (sounding: Sounding, bounds: Bounds): void => {\n if (sounding.midi < bounds.low || sounding.midi > bounds.high) {\n report(`${String(sounding.line)}:${String(sounding.column)}`, {\n line: sounding.line,\n column: sounding.column,\n message: `${sounding.spelling} in ${sounding.track} is outside ${bounds.name}`,\n detail: \"Move the phrase an octave, or set the range of this track\",\n });\n }\n };\n\nexport const partRange: Rule = defineRule({\n meta: { description: \"Each part stays inside the range its singer or instrument can play\" },\n check: (context) => {\n const check = checkNote(reporterOf(context));\n const lookup = boundsFor(rangesOf(context.options));\n for (const sounding of context.soundings) {\n for (const bounds of Option.toArray(lookup(sounding))) {\n check(sounding, bounds);\n }\n }\n },\n});\n","import { Option, pipe } from \"effect\";\n\nimport { definePlugin } from \"#/entities/rule/index.ts\";\nimport type { I68Config, Plugin, RuleEntry } from \"#/shared/config/index.ts\";\n\nimport { breath } from \"./breath.ts\";\nimport { melodyLeap } from \"./melody-leap.ts\";\nimport { outOfKey } from \"./out-of-key.ts\";\nimport { partRange } from \"./part-range.ts\";\nimport type { Ranges } from \"./part-range.ts\";\n\nexport interface PopOptions {\n readonly ranges?: Ranges;\n readonly maxLeap?: number;\n readonly breathSeconds?: number;\n}\n\nexport const popPlugin: Plugin = definePlugin({\n rules: {\n \"out-of-key\": outOfKey,\n \"part-range\": partRange,\n \"melody-leap\": melodyLeap,\n breath,\n },\n});\n\nconst warnWith =\n (key: string) =>\n (value: unknown): RuleEntry =>\n pipe(\n Option.fromNullishOr(value),\n Option.match({\n onNone: (): RuleEntry => \"warn\",\n onSome: (given): RuleEntry => [\"warn\", { [key]: given }],\n }),\n );\n\nexport const pop = (options: PopOptions = {}): I68Config => ({\n plugins: { pop: popPlugin },\n rules: {\n \"pop/out-of-key\": \"warn\",\n \"pop/part-range\": warnWith(\"ranges\")(options.ranges),\n \"pop/melody-leap\": warnWith(\"max\")(options.maxLeap),\n \"pop/breath\": warnWith(\"seconds\")(options.breathSeconds),\n },\n});\n","import type { Sounding } from \"@r_masseater/song-format/analysis\";\nimport { Array as Arr, Option, Order, pipe } from \"effect\";\n\nimport { MELODIC, hasRole, highest, lowest, soundingAt } from \"#/app/presets/shared/lib/voices.ts\";\n\nexport interface OuterPair {\n readonly tick: number;\n readonly melody: Sounding;\n readonly bass: Sounding;\n}\n\nconst pickAt =\n (\n soundings: readonly Sounding[],\n pick: (found: Arr.NonEmptyReadonlyArray<Sounding>) => Sounding,\n ) =>\n (tick: number): Option.Option<Sounding> =>\n pipe(\n soundingAt(soundings)(tick),\n Arr.match({ onEmpty: () => Option.none(), onNonEmpty: (found) => Option.some(pick(found)) }),\n );\n\nexport const outerVoicesOf = (soundings: readonly Sounding[]): readonly OuterPair[] => {\n const melodic = pipe(soundings, Arr.filter(hasRole(MELODIC)));\n const low = pipe(soundings, Arr.filter(hasRole([\"bass\"])));\n const topAt = pickAt(melodic, highest);\n const bottomAt = pickAt(low, lowest);\n const ticks = pipe(\n [...melodic, ...low],\n Arr.map((sounding) => sounding.start),\n Arr.dedupe,\n (all) => Arr.sort(all, Order.Number),\n );\n const pairAt = (tick: number): Option.Option<OuterPair> =>\n pipe(\n Option.all({ melody: topAt(tick), bass: bottomAt(tick) }),\n Option.map(({ melody, bass }) => ({ tick, melody, bass })),\n );\n return pipe(ticks, Arr.map(pairAt), Arr.getSomes);\n};\n","import { Match, Option } from \"effect\";\n\nimport { pitchClassOf } from \"#/app/presets/shared/lib/pitch.ts\";\nimport { neighborsOf, reporterOf } from \"#/app/presets/shared/lib/voices.ts\";\nimport type { Reporter } from \"#/app/presets/shared/lib/voices.ts\";\nimport { defineRule } from \"#/entities/rule/index.ts\";\nimport type { Rule } from \"#/shared/config/index.ts\";\n\nimport { outerVoicesOf } from \"./outer-voices.ts\";\nimport type { OuterPair } from \"./outer-voices.ts\";\n\nconst UNISON = 0;\nconst FIFTH = 7;\nconst STILL = 0;\n\nconst perfectName = (interval: number): Option.Option<string> =>\n Match.value(interval).pipe(\n Match.when(UNISON, () => Option.some(\"octaves\")),\n Match.when(FIFTH, () => Option.some(\"fifths\")),\n Match.orElse(() => Option.none()),\n );\n\nconst intervalOf = (pair: OuterPair): number => pitchClassOf(pair.melody.midi - pair.bass.midi);\n\nconst movesTogether = (previous: OuterPair, next: OuterPair): boolean => {\n const melody = Math.sign(next.melody.midi - previous.melody.midi);\n return melody !== STILL && melody === Math.sign(next.bass.midi - previous.bass.midi);\n};\n\nconst checkMove =\n (report: Reporter) =>\n ([previous, next]: readonly [OuterPair, OuterPair]): void => {\n const name = perfectName(intervalOf(next));\n if (\n Option.isSome(name) &&\n intervalOf(previous) === intervalOf(next) &&\n movesTogether(previous, next)\n ) {\n report(`${String(next.melody.line)}:${String(next.tick)}`, {\n line: next.melody.line,\n column: next.melody.column,\n message: `Parallel ${name.value}: ${previous.melody.spelling}/${previous.bass.spelling} to ${next.melody.spelling}/${next.bass.spelling} between ${next.melody.track} and ${next.bass.track}`,\n detail: \"Move the melody or the bass the other way\",\n });\n }\n };\n\nexport const parallelPerfects: Rule = defineRule({\n meta: { description: \"Melody and bass do not move in parallel fifths or octaves\" },\n check: (context) => {\n const check = checkMove(reporterOf(context));\n for (const move of neighborsOf(outerVoicesOf(context.soundings))) {\n check(move);\n }\n },\n});\n","import type { Song } from \"@r_masseater/song-format\";\nimport type { Sounding } from \"@r_masseater/song-format/analysis\";\nimport { Array as Arr, Option, Record as Rec, pipe } from \"effect\";\n\nimport { pitchClassOf } from \"#/app/presets/shared/lib/pitch.ts\";\nimport {\n MELODIC,\n hasRole,\n neighborsOf,\n reporterOf,\n topLineOf,\n tracksOf,\n} from \"#/app/presets/shared/lib/voices.ts\";\nimport type { Reporter } from \"#/app/presets/shared/lib/voices.ts\";\nimport { defineRule } from \"#/entities/rule/index.ts\";\nimport type { Rule } from \"#/shared/config/index.ts\";\n\nimport { outerVoicesOf } from \"./outer-voices.ts\";\n\nconst DISSONANT_STEPS = {\n minorSecond: 1,\n majorSecond: 2,\n fourth: 5,\n tritone: 6,\n minorSeventh: 10,\n majorSeventh: 11,\n};\nconst DISSONANT = Rec.values(DISSONANT_STEPS);\nconst STEP_DOWN = Rec.values({ halfStep: -1, wholeStep: -2 });\nconst HALVES = 2;\nconst ON_BEAT = 0;\n\nconst strongLength = (length: number, numerator: number): number => {\n if (numerator % HALVES === ON_BEAT) {\n return length / HALVES;\n }\n return length;\n};\n\nconst isStrongBeat =\n (song: Song) =>\n (sounding: Sounding): boolean =>\n pipe(\n song.bars,\n Arr.findFirst((bar) => bar.index === sounding.bar),\n Option.exists(\n (bar) =>\n (sounding.start - bar.start) % strongLength(bar.length, bar.meter.numerator) === ON_BEAT,\n ),\n );\n\ntype BassAt = (tick: number) => Option.Option<Sounding>;\n\nconst bassOf = (soundings: readonly Sounding[]): BassAt => {\n const pairs = outerVoicesOf(soundings);\n return (tick) =>\n pipe(\n pairs,\n Arr.findFirst((pair) => pair.tick === tick),\n Option.map((pair) => pair.bass),\n );\n};\n\nconst checkNote =\n (report: Reporter, strong: (sounding: Sounding) => boolean, bassAt: BassAt) =>\n ([note, next]: readonly [Sounding, Option.Option<Sounding>]): void => {\n const dissonant = Option.exists(bassAt(note.start), (bass) =>\n Arr.contains(DISSONANT, pitchClassOf(note.midi - bass.midi)),\n );\n const resolved = Option.exists(next, (found) =>\n Arr.contains(STEP_DOWN, found.midi - note.midi),\n );\n if (strong(note) && dissonant && !resolved) {\n report(`${String(note.line)}:${String(note.start)}`, {\n line: note.line,\n column: note.column,\n message: `${note.spelling} in ${note.track} is dissonant against the bass and does not step down`,\n detail: \"Move the next note down a step\",\n });\n }\n };\n\nconst withNext = (\n line: readonly Sounding[],\n): readonly (readonly [Sounding, Option.Option<Sounding>])[] => [\n ...pipe(\n neighborsOf(line),\n Arr.map(([note, next]): readonly [Sounding, Option.Option<Sounding>] => [\n note,\n Option.some(next),\n ]),\n ),\n ...pipe(\n Arr.last(line),\n Option.map((note): readonly [Sounding, Option.Option<Sounding>] => [note, Option.none()]),\n Option.toArray,\n ),\n];\n\nexport const unresolvedDissonance: Rule = defineRule({\n meta: { description: \"A dissonant melody note on a strong beat steps down to resolve\" },\n check: (context) => {\n const check = checkNote(\n reporterOf(context),\n isStrongBeat(context.song),\n bassOf(context.soundings),\n );\n const melodic = pipe(context.soundings, Arr.filter(hasRole(MELODIC)));\n for (const track of tracksOf(melodic)) {\n for (const entry of withNext(topLineOf(track))) {\n check(entry);\n }\n }\n },\n});\n","import { definePlugin } from \"#/entities/rule/index.ts\";\nimport type { I68Config, Plugin } from \"#/shared/config/index.ts\";\n\nimport { parallelPerfects } from \"./parallel-perfects.ts\";\nimport { unresolvedDissonance } from \"./unresolved-dissonance.ts\";\n\nexport const classicalPlugin: Plugin = definePlugin({\n rules: {\n \"parallel-perfects\": parallelPerfects,\n \"unresolved-dissonance\": unresolvedDissonance,\n },\n});\n\nexport const classical = (): I68Config => ({\n plugins: { classical: classicalPlugin },\n rules: {\n \"classical/parallel-perfects\": \"warn\",\n \"classical/unresolved-dissonance\": \"warn\",\n },\n});\n","import { Array as Arr, Option, String as Str, pipe } from \"effect\";\n\nimport { progressionOf } from \"#/app/presets/shared/lib/degrees.ts\";\nimport type { Step } from \"#/app/presets/shared/lib/degrees.ts\";\nimport { reporterOf } from \"#/app/presets/shared/lib/voices.ts\";\nimport { defineRule } from \"#/entities/rule/index.ts\";\nimport type { Rule } from \"#/shared/config/index.ts\";\n\nexport interface Progression {\n readonly name: string;\n readonly degrees: readonly string[];\n}\n\nexport const PROGRESSIONS: readonly Progression[] = [\n { name: \"丸サ進行 (Just the Two of Us)\", degrees: [\"IVM7\", \"III7\", \"VIm7\"] },\n { name: \"王道進行\", degrees: [\"IV\", \"V\", \"IIIm\", \"VIm\"] },\n { name: \"小室進行\", degrees: [\"VIm\", \"IV\", \"V\", \"I\"] },\n { name: \"カノン進行\", degrees: [\"I\", \"V\", \"VIm\", \"IIIm\", \"IV\", \"I\", \"IV\", \"V\"] },\n { name: \"ii–V–I\", degrees: [\"IIm\", \"V\", \"I\"] },\n { name: \"Andalusian cadence\", degrees: [\"VIm\", \"V\", \"IV\", \"III\"] },\n];\n\nconst START = 0;\n\nconst FAMILIES = [\n [\"M7\", \"\"],\n [\"m7b5\", \"dim\"],\n [\"m7\", \"m\"],\n [\"dim7\", \"dim\"],\n [\"7\", \"\"],\n] as const;\n\nconst familyOf = (token: string): string =>\n pipe(\n FAMILIES,\n Arr.findFirst(([suffix]) => Str.endsWith(suffix)(token)),\n Option.match({\n onNone: () => token,\n onSome: ([suffix, triad]) =>\n `${Str.slice(START, token.length - suffix.length)(token)}${triad}`,\n }),\n );\n\nconst matches =\n (steps: readonly Step[], degrees: readonly string[]) =>\n (start: number): boolean =>\n pipe(\n degrees,\n Arr.every((degree, offset) =>\n pipe(\n Arr.get(steps, start + offset),\n Option.exists((step) => familyOf(step.token) === familyOf(degree)),\n ),\n ),\n );\n\nexport const namedProgression: Rule = defineRule({\n meta: { description: \"Names the well-known chord progressions a song uses\" },\n check: (context) => {\n const steps = progressionOf(context.soundings)(context.song);\n const report = reporterOf(context);\n for (const progression of PROGRESSIONS) {\n const starts = pipe(\n Arr.makeBy(steps.length, (index) => index),\n Arr.filter(matches(steps, progression.degrees)),\n );\n for (const step of pipe(\n starts,\n Arr.flatMap((start) => Option.toArray(Arr.get(steps, start))),\n )) {\n report(`${progression.name}:${String(step.line)}:${String(step.bar)}`, {\n line: step.line,\n column: step.column,\n message: `${progression.name} (${Arr.join(progression.degrees, \"–\")}) starts in bar ${String(step.bar)}`,\n });\n }\n }\n },\n});\n","import { definePlugin } from \"#/entities/rule/index.ts\";\nimport type { I68Config, Plugin } from \"#/shared/config/index.ts\";\n\nimport { namedProgression } from \"./named.ts\";\n\nexport const progressionsPlugin: Plugin = definePlugin({\n rules: { named: namedProgression },\n});\n\nexport const progressions = (): I68Config => ({\n plugins: { progressions: progressionsPlugin },\n rules: { \"progressions/named\": \"warn\" },\n});\n","import { Array as Arr, Number as Num, Option, Record as Rec, pipe } from \"effect\";\n\nimport { progressionOf } from \"#/app/presets/shared/lib/degrees.ts\";\nimport type { Step } from \"#/app/presets/shared/lib/degrees.ts\";\nimport { numberOption } from \"#/app/presets/shared/lib/options.ts\";\nimport { longestContext } from \"#/app/presets/shared/lib/style-table.ts\";\nimport type { Context, StyleTable } from \"#/app/presets/shared/lib/style-table.ts\";\nimport { reporterOf } from \"#/app/presets/shared/lib/voices.ts\";\nimport type { Reporter } from \"#/app/presets/shared/lib/voices.ts\";\nimport { defineRule } from \"#/entities/rule/index.ts\";\nimport type { Rule } from \"#/shared/config/index.ts\";\n\nconst DEFAULT_SHARE = 0.03;\nconst DEFAULT_SEEN = 8;\nconst PERCENT = 100;\nconst SUGGESTIONS = 3;\nconst FIRST = 1;\nconst NEVER = 0;\nconst minShare = numberOption({ key: \"share\", fallback: DEFAULT_SHARE });\nconst minSeen = numberOption({ key: \"seen\", fallback: DEFAULT_SEEN });\n\nconst percentOf = (count: number, total: number): string =>\n `${String(Math.round((count / total) * PERCENT))}%`;\n\nconst suggestionsOf = (context: Context): string =>\n pipe(\n Rec.toEntries(context.next),\n Arr.sortWith(([, count]) => -count, Num.Order),\n Arr.take(SUGGESTIONS),\n Arr.map(([token, count]) => `${token} (${percentOf(count, context.total)})`),\n Arr.join(\", \"),\n );\n\ninterface Limits {\n readonly share: number;\n readonly seen: number;\n}\n\nconst checkStep =\n (report: Reporter, table: StyleTable, { share, seen }: Limits) =>\n (steps: readonly Step[], index: number): void => {\n const before = Arr.take(steps, index);\n for (const step of Option.toArray(Arr.get(steps, index))) {\n for (const context of Option.toArray(longestContext({ table, seen })(before))) {\n const count = Option.getOrElse(Rec.get(context.next, step.token), () => NEVER);\n if (count / context.total < share) {\n report(`${String(step.line)}:${step.token}:${String(index)}`, {\n line: step.line,\n column: step.column,\n message: `${context.words} → ${step.token} is rare in ${table.name} (${percentOf(count, context.total)})`,\n detail: `${table.name} usually goes to ${suggestionsOf(context)}`,\n });\n }\n }\n }\n };\n\nexport const rareTransitionOf = (table: StyleTable): Rule =>\n defineRule({\n meta: { description: `Chord changes follow what ${table.name} usually does next` },\n check: (context) => {\n const steps = progressionOf(context.soundings)(context.song);\n const check = checkStep(reporterOf(context), table, {\n share: minShare(context.options),\n seen: minSeen(context.options),\n });\n const indices = Arr.makeBy(steps.length, (at) => at);\n for (const index of Arr.drop(indices, FIRST)) {\n check(steps, index);\n }\n },\n });\n","import BACH_CHORALES from \"#/app/presets/features/check-style/data/bach-chorales.json\" with { type: \"json\" };\nimport type { StyleTable } from \"#/app/presets/shared/lib/style-table.ts\";\nimport { definePlugin } from \"#/entities/rule/index.ts\";\nimport type { I68Config, Plugin } from \"#/shared/config/index.ts\";\n\nimport { rareTransitionOf } from \"./rare-transition.ts\";\n\nexport const bachPlugin: Plugin = definePlugin({\n rules: { \"rare-transition\": rareTransitionOf(BACH_CHORALES) },\n});\n\nexport const bach = (): I68Config => ({\n plugins: { bach: bachPlugin },\n rules: { \"bach/rare-transition\": \"warn\" },\n});\n\nexport const stylePluginOf = (table: StyleTable): Plugin =>\n definePlugin({ rules: { \"rare-transition\": rareTransitionOf(table) } });\n","import type { RuleContext } from \"@r_masseater/i68\";\nimport { Array as Arr, Option, String as Str, pipe } from \"effect\";\n\nimport { progressionOf } from \"#/app/presets/shared/lib/degrees.ts\";\nimport type { Step } from \"#/app/presets/shared/lib/degrees.ts\";\nimport { mixFactsOf, placeIn, trackKeyOf } from \"#/app/presets/shared/lib/mix-facts.ts\";\nimport type { MixFact, MixPlace } from \"#/app/presets/shared/lib/mix-facts.ts\";\nimport { mixKeyOf } from \"#/app/presets/shared/lib/mix-habit.ts\";\nimport type { MixHabit } from \"#/app/presets/shared/lib/mix-habit.ts\";\nimport type { Subject } from \"#/app/presets/shared/lib/style-rules.ts\";\n\nconst FIRST = 1;\n\nexport interface Occasion {\n readonly id: string;\n readonly line: number;\n readonly column: number;\n readonly holds: boolean;\n}\n\ntype Chord = Extract<Subject, { readonly type: \"chord\" }>;\n\nconst follows = (before: readonly Step[], context: string): boolean => {\n const words = Str.split(\" \")(context);\n return (\n before.length >= words.length &&\n pipe(\n Arr.takeRight(before, words.length),\n Arr.map((step) => step.token),\n Arr.join(\" \"),\n ) === context\n );\n};\n\nconst chordOccasions =\n (context: RuleContext) =>\n (chord: Chord): readonly Occasion[] => {\n const steps = progressionOf(context.soundings)(context.song);\n return pipe(\n Arr.makeBy(steps.length, (index) => index),\n Arr.drop(FIRST),\n Arr.filter((index) => follows(Arr.take(steps, index), chord.context)),\n Arr.map((index) => {\n const step = Arr.getUnsafe(steps, index);\n return {\n id: String(index),\n line: step.line,\n column: step.column,\n holds: step.token === chord.next,\n };\n }),\n );\n };\n\nconst sectionStartsOf = (context: RuleContext): readonly number[] =>\n pipe(\n context.song.bars,\n Arr.drop(FIRST),\n Arr.filter((bar) => Option.isSome(bar.section) || Option.isSome(bar.mark)),\n Arr.map((bar) => bar.index),\n );\n\nconst occasionAt = (place: MixPlace, holds: boolean): Occasion => ({\n id: String(place.bar),\n line: place.line,\n column: place.column,\n holds,\n});\n\nconst has =\n (facts: readonly MixFact[], habit: MixHabit) =>\n (bar: Option.Option<number>): boolean =>\n pipe(\n facts,\n Arr.some(\n (fact) =>\n mixKeyOf(fact.habit) === mixKeyOf(habit) &&\n Option.match(bar, { onNone: () => true, onSome: (at) => fact.place.bar === at }),\n ),\n );\n\nconst mixOccasions =\n (context: RuleContext) =>\n (habit: MixHabit): readonly Occasion[] => {\n const facts = mixFactsOf(context.soundings)(context.song);\n const place = placeIn(context.soundings);\n const tracks = pipe(\n context.song.tracks,\n Arr.filter((track) => trackKeyOf(track.name) === habit.track),\n );\n if (habit.type !== \"move\") {\n return pipe(\n tracks,\n Arr.map((track) =>\n occasionAt(place({ track: track.name, bar: FIRST }), has(facts, habit)(Option.none())),\n ),\n );\n }\n return pipe(\n tracks,\n Arr.flatMap((track) =>\n pipe(\n sectionStartsOf(context),\n Arr.map((bar) =>\n occasionAt(place({ track: track.name, bar }), has(facts, habit)(Option.some(bar))),\n ),\n ),\n ),\n );\n };\n\nexport const occasionsOf =\n (context: RuleContext) =>\n (subject: Subject): readonly Occasion[] => {\n if (subject.type === \"chord\") {\n return chordOccasions(context)(subject);\n }\n return mixOccasions(context)(subject);\n };\n","import { defineRule } from \"@r_masseater/i68\";\nimport type { Rule } from \"@r_masseater/i68\";\nimport { Array as Arr, Option, pipe } from \"effect\";\n\nimport { subjectKeyOf } from \"#/app/presets/shared/lib/style-rules.ts\";\nimport type { HabitKind, HabitRule, StyleRules } from \"#/app/presets/shared/lib/style-rules.ts\";\nimport { reporterOf } from \"#/app/presets/shared/lib/voices.ts\";\n\nimport { occasionsOf } from \"./occasions.ts\";\n\ntype Wording = Readonly<{\n description: (name: string) => string;\n reportsWhen: boolean;\n message: (name: string, key: string) => string;\n}>;\n\nconst WORDINGS: Readonly<Record<HabitKind, Wording>> = {\n keep: {\n description: (name) => `Songs keep the habits of ${name}`,\n reportsWhen: false,\n message: (name, key) => `${name} keeps ${key} here`,\n },\n fix: {\n description: (name) => `Songs avoid the habits ${name} is fixing`,\n reportsWhen: true,\n message: (name, key) => `${key} is a habit ${name} is fixing`,\n },\n suggest: {\n description: (name) => `Habits that would fit ${name}`,\n reportsWhen: false,\n message: (name, key) => `${key} would fit ${name} here`,\n },\n};\n\nconst detailOf = (habit: HabitRule): string =>\n pipe(\n Option.fromNullishOr(habit.reason),\n Option.match({\n onNone: () => habit.aim,\n onSome: (reason) => `${habit.aim}: ${reason}`,\n }),\n );\n\nexport type HabitRuleInput = Readonly<{ rules: StyleRules; kind: HabitKind }>;\n\nexport const habitRuleOf = ({ rules, kind }: HabitRuleInput): Rule => {\n const wording = WORDINGS[kind];\n const habits = pipe(\n rules.habits,\n Arr.filter((habit) => habit.kind === kind),\n );\n return defineRule({\n meta: { description: wording.description(rules.name) },\n check: (context) => {\n const report = reporterOf(context);\n for (const habit of habits) {\n const key = subjectKeyOf(habit.habit);\n for (const occasion of occasionsOf(context)(habit.habit)) {\n if (occasion.holds === wording.reportsWhen) {\n report(`${key}:${occasion.id}`, {\n line: occasion.line,\n column: occasion.column,\n message: wording.message(rules.name, key),\n detail: detailOf(habit),\n });\n }\n }\n }\n },\n });\n};\n","import { definePlugin } from \"@r_masseater/i68\";\nimport type { I68Config, Plugin } from \"@r_masseater/i68\";\n\nimport type { StyleRules } from \"#/app/presets/shared/lib/style-rules.ts\";\n\nimport { habitRuleOf } from \"./habit-rule.ts\";\n\nexport const styleRulesPluginOf = (rules: StyleRules): Plugin =>\n definePlugin({\n rules: {\n keep: habitRuleOf({ rules, kind: \"keep\" }),\n fix: habitRuleOf({ rules, kind: \"fix\" }),\n suggest: habitRuleOf({ rules, kind: \"suggest\" }),\n },\n });\n\nexport type StyleRulesPreset = Readonly<{ plugin: string; rules: StyleRules }>;\n\nexport const styleRules = ({ plugin, rules }: StyleRulesPreset): I68Config => ({\n plugins: { [plugin]: styleRulesPluginOf(rules) },\n rules: {\n [`${plugin}/keep`]: \"warn\",\n [`${plugin}/fix`]: \"error\",\n [`${plugin}/suggest`]: \"warn\",\n },\n});\n","import { harmony } from \"#/app/presets/features/check-harmony/index.ts\";\nimport { pop } from \"#/app/presets/features/check-pop/index.ts\";\nimport type { PopOptions } from \"#/app/presets/features/check-pop/index.ts\";\nimport type { I68Config } from \"#/shared/config/index.ts\";\n\nexport { classical, classicalPlugin } from \"#/app/presets/features/check-classical/index.ts\";\nexport { DEFAULT_RANGES, pop, popPlugin } from \"#/app/presets/features/check-pop/index.ts\";\nexport type { PopOptions, Range, Ranges } from \"#/app/presets/features/check-pop/index.ts\";\nexport {\n PROGRESSIONS,\n progressions,\n progressionsPlugin,\n} from \"#/app/presets/features/check-progressions/index.ts\";\nexport type { Progression } from \"#/app/presets/features/check-progressions/index.ts\";\nexport { bach, bachPlugin, stylePluginOf } from \"#/app/presets/features/check-style/index.ts\";\nexport { styleRules, styleRulesPluginOf } from \"#/app/presets/features/check-habits/index.ts\";\nexport type { StyleRulesPreset } from \"#/app/presets/features/check-habits/index.ts\";\nexport {\n HABIT_KINDS,\n StyleRulesSchema,\n subjectKeyOf,\n} from \"#/app/presets/shared/lib/style-rules.ts\";\nexport type {\n HabitKind,\n HabitRule,\n StyleRules,\n Subject,\n} from \"#/app/presets/shared/lib/style-rules.ts\";\nexport { mixKeyOf } from \"#/app/presets/shared/lib/mix-habit.ts\";\nexport type { MixHabit } from \"#/app/presets/shared/lib/mix-habit.ts\";\nexport type { StyleTable, Transitions } from \"#/app/presets/shared/lib/style-table.ts\";\nexport { harmony, harmonyPlugin } from \"#/app/presets/features/check-harmony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AAQ;GAClB,GAAG,OAAO,YAAY;CACzB;AACF;;ACQA,MAAa,eAAe,UAAsB,CAAC,OAAkB,EACnE,SAAS,CAAC,IAAI,OAAO,GAAG,QAAQ,CAAC,EACnC"}
|
|
1
|
+
{"version":3,"file":"presets.mjs","names":["UNISON","checkPair","Arr","stepsOf","Arr","checkPair","Rec","Arr","MAJOR_THIRD","Arr","Arr","Arr","Arr","checkStep","Arr","Arr","Rec","Arr","checkNote","Arr","midiOf","Rec","checkNote","Arr","Rec","Arr","Arr","Str","FIRST","Rec","Arr","Num","BACH_CHORALES","Str","Arr","Arr"],"sources":["../src/app/presets/shared/lib/options.ts","../src/app/presets/features/check-harmony/model/chord-above-melody.ts","../src/app/presets/features/check-harmony/model/crowded-low-mids.ts","../src/app/presets/features/check-harmony/model/low-interval-limit.ts","../src/app/presets/features/check-harmony/model/semitone-clash.ts","../src/app/presets/features/check-harmony/model/voice-jump.ts","../src/app/presets/features/check-harmony/model/preset.ts","../src/app/presets/shared/lib/time.ts","../src/app/presets/features/check-pop/model/breath.ts","../src/app/presets/features/check-pop/model/melody-leap.ts","../src/app/presets/shared/lib/chords.ts","../src/app/presets/features/check-pop/model/out-of-key.ts","../src/app/presets/features/check-pop/model/part-range.ts","../src/app/presets/features/check-pop/model/preset.ts","../src/app/presets/features/check-classical/model/outer-voices.ts","../src/app/presets/features/check-classical/model/parallel-perfects.ts","../src/app/presets/features/check-classical/model/unresolved-dissonance.ts","../src/app/presets/features/check-classical/model/preset.ts","../src/app/presets/features/check-progressions/model/named.ts","../src/app/presets/features/check-progressions/model/preset.ts","../src/app/presets/features/check-style/model/rare-transition.ts","../src/app/presets/features/check-style/model/preset.ts","../src/app/presets/features/check-habits/model/occasions.ts","../src/app/presets/features/check-habits/model/habit-rule.ts","../src/app/presets/features/check-habits/model/preset.ts","../src/app/presets.ts"],"sourcesContent":["import { Option, Predicate, pipe } from \"effect\";\n\nimport type { RuleOptions } from \"#/shared/config/index.ts\";\n\nexport interface NumberOption {\n readonly key: string;\n readonly fallback: number;\n}\n\nexport const numberOption =\n ({ key, fallback }: NumberOption) =>\n (options: RuleOptions): number =>\n pipe(\n Option.fromNullishOr(options[key]),\n Option.filter(Predicate.isNumber),\n Option.getOrElse(() => fallback),\n );\n","import type { Sounding } from \"@r_masseater/song-format/analysis\";\nimport { Array as Arr, Option, pipe } from \"effect\";\n\nimport { numberOption } from \"#/app/presets/shared/lib/options.ts\";\nimport { hasRole, overlappingPairs, reporterOf } from \"#/app/presets/shared/lib/voices.ts\";\nimport type { Pair, Reporter } from \"#/app/presets/shared/lib/voices.ts\";\nimport { defineRule } from \"#/entities/rule/index.ts\";\nimport type { Rule } from \"#/shared/config/index.ts\";\n\nconst UNISON = 0;\nconst within = numberOption({ key: \"within\", fallback: UNISON });\nconst isMelody = hasRole([\"melody\"]);\nconst isHarmony = hasRole([\"harmony\"]);\n\nconst placementOf = (distance: number, room: number): Option.Option<string> => {\n if (distance < UNISON) {\n return Option.some(\"above\");\n }\n if (distance > UNISON && distance <= room) {\n return Option.some(\"just below\");\n }\n return Option.none();\n};\n\nconst checkPair =\n (report: Reporter, room: number) =>\n (pair: Pair): void => {\n const parts = Option.all({\n melody: pipe(pair, Arr.findFirst(isMelody)),\n chord: pipe(pair, Arr.findFirst(isHarmony)),\n });\n for (const { melody, chord } of Option.toArray(parts)) {\n for (const where of Option.toArray(placementOf(melody.midi - chord.midi, room))) {\n report(`${String(chord.line)}:${String(chord.column)}:${String(chord.bar)}`, {\n line: chord.line,\n column: chord.column,\n message: `${chord.spelling} in ${chord.track} sits ${where} the melody note ${melody.spelling}`,\n detail: \"Keep the chord below the melody with some room between them\",\n });\n }\n }\n };\n\nconst isPart = (sounding: Sounding): boolean => isMelody(sounding) || isHarmony(sounding);\n\nexport const chordAboveMelody: Rule = defineRule({\n meta: { description: \"Chord parts stay below the lead melody\" },\n check: (context) => {\n const check = checkPair(reporterOf(context), within(context.options));\n for (const pair of overlappingPairs(pipe(context.soundings, Arr.filter(isPart)))) {\n check(pair);\n }\n },\n});\n","import type { Bar } from \"@r_masseater/song-format\";\nimport { TICKS_PER_WHOLE } from \"@r_masseater/song-format\";\nimport type { Sounding } from \"@r_masseater/song-format/analysis\";\nimport { Array as Arr, Option, pipe } from \"effect\";\n\nimport { numberOption } from \"#/app/presets/shared/lib/options.ts\";\nimport { hasRole, isPitched, reporterOf, soundingAt } from \"#/app/presets/shared/lib/voices.ts\";\nimport type { Reporter } from \"#/app/presets/shared/lib/voices.ts\";\nimport { defineRule } from \"#/entities/rule/index.ts\";\nimport type { Rule } from \"#/shared/config/index.ts\";\n\nconst SIXTEENTHS_PER_WHOLE = 16;\nconst SIXTEENTH = TICKS_PER_WHOLE / SIXTEENTHS_PER_WHOLE;\nconst LOW_MID_FLOOR = 45;\nconst BASS_FLOOR = 40;\nconst LOW_MID_CEILING = 59;\nconst DEFAULT_MAX = 3;\nconst maxNotes = numberOption({ key: \"max\", fallback: DEFAULT_MAX });\n\nconst floorOf = (sounding: Sounding): number => {\n if (hasRole([\"bass\"])(sounding)) {\n return BASS_FLOOR;\n }\n return LOW_MID_FLOOR;\n};\n\nconst inLowMids = (sounding: Sounding): boolean =>\n isPitched(sounding) && sounding.midi <= LOW_MID_CEILING && sounding.midi >= floorOf(sounding);\n\nconst stepsOf = (bar: Bar): readonly number[] =>\n Arr.makeBy(Math.ceil(bar.length / SIXTEENTH), (index) => bar.start + index * SIXTEENTH);\n\nconst crowdAt =\n (low: readonly Sounding[]) =>\n (tick: number): readonly Sounding[] =>\n pipe(\n soundingAt(low)(tick),\n Arr.dedupeWith((left, right) => left.track === right.track && left.midi === right.midi),\n );\n\nconst spellingsOf = (notes: readonly Sounding[]): string =>\n pipe(\n notes,\n Arr.map((note) => note.spelling),\n Arr.join(\", \"),\n );\n\nconst checkBar =\n (report: Reporter, low: readonly Sounding[], max: number) =>\n (bar: Bar): void => {\n const crowded = pipe(\n stepsOf(bar),\n Arr.map(crowdAt(low)),\n Arr.findFirst((notes) => notes.length > max),\n );\n for (const notes of Option.toArray(crowded)) {\n for (const first of Option.toArray(Arr.head(notes))) {\n report(String(bar.index), {\n line: first.line,\n column: first.column,\n message: `${String(notes.length)} notes crowd the low mids in bar ${String(bar.index)}: ${spellingsOf(notes)}`,\n detail: \"Thin the chord or move notes out of A2-B3\",\n });\n }\n }\n };\n\nexport const crowdedLowMids: Rule = defineRule({\n meta: { description: \"Few notes pile up between A2 and B3 at once\" },\n check: (context) => {\n const low = pipe(context.soundings, Arr.filter(inLowMids));\n const check = checkBar(reporterOf(context), low, maxNotes(context.options));\n for (const bar of context.song.bars) {\n check(bar);\n }\n },\n});\n","import { Array as Arr, Option, Record as Rec, pipe } from \"effect\";\n\nimport { nameOf } from \"#/app/presets/shared/lib/pitch.ts\";\nimport { isPitched, overlappingPairs, reporterOf } from \"#/app/presets/shared/lib/voices.ts\";\nimport type { Pair, Reporter } from \"#/app/presets/shared/lib/voices.ts\";\nimport { defineRule } from \"#/entities/rule/index.ts\";\nimport type { Rule } from \"#/shared/config/index.ts\";\n\nconst LIMITS: Readonly<Record<string, number>> = {\n \"1\": 52,\n \"2\": 51,\n \"3\": 48,\n \"4\": 46,\n \"5\": 46,\n \"6\": 46,\n \"7\": 34,\n \"8\": 43,\n \"9\": 41,\n \"10\": 41,\n \"11\": 41,\n \"13\": 40,\n \"14\": 39,\n};\n\nconst checkPair =\n (report: Reporter) =>\n (pair: Pair): void => {\n const [first, second] = pair;\n const low = Math.min(first.midi, second.midi);\n const gap = Math.abs(first.midi - second.midi);\n const limits = pipe(LIMITS, Rec.get(String(gap)), Option.toArray);\n for (const limit of limits) {\n if (low < limit) {\n report(`${String(second.line)}:${String(low)}:${String(gap)}`, {\n line: second.line,\n column: second.column,\n message: `${String(gap)} semitones between ${first.spelling} (${first.track}) and ${second.spelling} (${second.track}) is below its limit ${nameOf(limit)}`,\n detail: \"Widen the interval or move the upper note up an octave\",\n });\n }\n }\n };\n\nexport const lowIntervalLimit: Rule = defineRule({\n meta: { description: \"Close intervals stay above the pitch where they turn muddy\" },\n check: (context) => {\n const check = checkPair(reporterOf(context));\n for (const pair of overlappingPairs(pipe(context.soundings, Arr.filter(isPitched)))) {\n check(pair);\n }\n },\n});\n","import type { Sounding } from \"@r_masseater/song-format/analysis\";\nimport { Array as Arr, Match, Option, pipe } from \"effect\";\n\nimport { pitchClassOf } from \"#/app/presets/shared/lib/pitch.ts\";\nimport {\n hasRole,\n isPitched,\n overlappingPairs,\n reporterOf,\n soundingAt,\n sortByPitch,\n} from \"#/app/presets/shared/lib/voices.ts\";\nimport type { Pair, Reporter } from \"#/app/presets/shared/lib/voices.ts\";\nimport { defineRule } from \"#/entities/rule/index.ts\";\nimport type { Rule } from \"#/shared/config/index.ts\";\n\nconst MINOR_SECOND = 1;\nconst MINOR_NINTH = 13;\nconst CLUSTER_FLOOR = 59;\n\nconst MAJOR_THIRD = 4;\nconst MINOR_SEVENTH = 10;\nconst isBass = hasRole([\"bass\"]);\n\ntype Excused = (bottom: Sounding, top: Sounding) => boolean;\n\nconst dominantOver =\n (soundings: readonly Sounding[]): Excused =>\n (bottom, top) => {\n if (!isBass(bottom) && !isBass(top)) {\n return false;\n }\n if (!isBass(bottom) || top.midi - bottom.midi !== MINOR_NINTH) {\n return true;\n }\n const classes = pipe(\n soundingAt(soundings)(top.start),\n Arr.map((other) => pitchClassOf(other.midi - bottom.midi)),\n );\n return Arr.contains(classes, MAJOR_THIRD) && Arr.contains(classes, MINOR_SEVENTH);\n };\n\nconst nameOfGap = (gap: number): Option.Option<string> =>\n Match.value(gap).pipe(\n Match.when(MINOR_SECOND, () => Option.some(\"minor 2nd\")),\n Match.when(MINOR_NINTH, () => Option.some(\"minor 9th\")),\n Match.orElse(() => Option.none()),\n );\n\nconst isCluster = (low: Sounding, high: Sounding): boolean =>\n low.track === high.track && high.midi - low.midi === MINOR_SECOND && low.midi >= CLUSTER_FLOOR;\n\nconst checkPair =\n (report: Reporter, excused: Excused) =>\n (pair: Pair): void => {\n const [low, high] = sortByPitch(pair);\n const [, later] = pair;\n for (const [bottom, top] of Option.toArray(\n Option.all([Option.fromNullishOr(low), Option.fromNullishOr(high)]),\n )) {\n for (const name of Option.toArray(nameOfGap(top.midi - bottom.midi))) {\n if (!isCluster(bottom, top) && !excused(bottom, top)) {\n report(`${String(later.line)}:${String(bottom.midi)}:${String(top.midi)}`, {\n line: later.line,\n column: later.column,\n message: `${top.spelling} (${top.track}) and ${bottom.spelling} (${bottom.track}) clash a ${name} apart`,\n detail: \"Move one of the two notes to a chord note\",\n });\n }\n }\n }\n };\n\nexport const semitoneClash: Rule = defineRule({\n meta: {\n description:\n \"Parts do not sound a minor 2nd or minor 9th apart, except the flat 9th of a dominant over its bass\",\n },\n check: (context) => {\n const pitched = pipe(context.soundings, Arr.filter(isPitched));\n const check = checkPair(reporterOf(context), dominantOver(pitched));\n for (const pair of overlappingPairs(pitched)) {\n check(pair);\n }\n },\n});\n","import { TICKS_PER_WHOLE } from \"@r_masseater/song-format\";\nimport type { Sounding } from \"@r_masseater/song-format/analysis\";\nimport { Array as Arr, Option, pipe } from \"effect\";\nimport { Note, VoiceLeading } from \"tonal\";\n\nimport { numberOption } from \"#/app/presets/shared/lib/options.ts\";\nimport {\n hasRole,\n neighborsOf,\n onsetsOf,\n reporterOf,\n tracksOf,\n} from \"#/app/presets/shared/lib/voices.ts\";\nimport type { Onset, Reporter } from \"#/app/presets/shared/lib/voices.ts\";\nimport { defineRule } from \"#/entities/rule/index.ts\";\nimport type { Rule } from \"#/shared/config/index.ts\";\n\nconst MAJOR_THIRD = 4;\nconst MIN_VOICES = 3;\nconst NEARBY_WHOLES = 1.5;\nconst NEARBY = NEARBY_WHOLES * TICKS_PER_WHOLE;\nconst maxMove = numberOption({ key: \"max\", fallback: MAJOR_THIRD });\n\ninterface Chord {\n readonly first: Sounding;\n readonly pitches: readonly number[];\n}\n\nconst chordOf = (onset: Onset): Chord => ({\n first: Arr.headNonEmpty(onset),\n pitches: pipe(\n onset,\n Arr.map((sounding) => sounding.midi),\n Arr.dedupe,\n ),\n});\n\nconst midiOf = (note: string): Option.Option<number> => Option.fromNullishOr(Note.midi(note));\n\nconst sizeOf = ([from, to]: readonly [string, string]): Option.Option<number> =>\n Option.map(Option.all([midiOf(from), midiOf(to)]), ([start, end]) => Math.abs(end - start));\n\nconst namesOf = (chord: Chord): string[] =>\n pipe(\n chord.pitches,\n Arr.map((midi) => Note.fromMidi(midi)),\n );\n\nconst movesOf = (previous: Chord, next: Chord): readonly number[] => {\n const { moves } = VoiceLeading.get(namesOf(previous), namesOf(next));\n return pipe(moves, Arr.map(sizeOf), Arr.getSomes);\n};\n\nconst checkChange =\n (report: Reporter, max: number) =>\n ([previous, next]: readonly [Chord, Chord]): void => {\n const leaps = pipe(\n movesOf(previous, next),\n Arr.filter((move) => move > max),\n );\n if (next.first.start - previous.first.start <= NEARBY && Arr.isReadonlyArrayNonEmpty(leaps)) {\n report(`${String(next.first.line)}:${String(next.first.start)}`, {\n line: next.first.line,\n column: next.first.column,\n message: `${String(leaps.length)} voices of ${next.first.track} leap more than ${String(max)} semitones into the next chord`,\n detail: \"Keep shared notes and move each voice to the closest note\",\n });\n }\n };\n\nconst chordsOf = (track: readonly Sounding[]): readonly Chord[] =>\n pipe(\n onsetsOf(track),\n Arr.map(chordOf),\n Arr.filter((chord) => chord.pitches.length >= MIN_VOICES),\n );\n\nexport const voiceJump: Rule = defineRule({\n meta: { description: \"Chord voices move to the nearest note of the next chord\" },\n check: (context) => {\n const check = checkChange(reporterOf(context), maxMove(context.options));\n const harmony = pipe(context.soundings, Arr.filter(hasRole([\"harmony\"])));\n for (const track of tracksOf(harmony)) {\n for (const change of neighborsOf(chordsOf(track))) {\n check(change);\n }\n }\n },\n});\n","import { definePlugin } from \"#/entities/rule/index.ts\";\nimport type { I68Config, Plugin } from \"#/shared/config/index.ts\";\n\nimport { chordAboveMelody } from \"./chord-above-melody.ts\";\nimport { crowdedLowMids } from \"./crowded-low-mids.ts\";\nimport { lowIntervalLimit } from \"./low-interval-limit.ts\";\nimport { semitoneClash } from \"./semitone-clash.ts\";\nimport { voiceJump } from \"./voice-jump.ts\";\n\nexport const harmonyPlugin: Plugin = definePlugin({\n rules: {\n \"semitone-clash\": semitoneClash,\n \"low-interval-limit\": lowIntervalLimit,\n \"crowded-low-mids\": crowdedLowMids,\n \"chord-above-melody\": chordAboveMelody,\n \"voice-jump\": voiceJump,\n },\n});\n\nexport const harmony = (): I68Config => ({\n plugins: { harmony: harmonyPlugin },\n rules: {\n \"harmony/semitone-clash\": \"warn\",\n \"harmony/low-interval-limit\": \"warn\",\n \"harmony/crowded-low-mids\": \"warn\",\n \"harmony/chord-above-melody\": \"warn\",\n \"harmony/voice-jump\": \"warn\",\n },\n});\n","import type { Bar, Song } from \"@r_masseater/song-format\";\nimport { TICKS_PER_WHOLE } from \"@r_masseater/song-format\";\nimport { Array as Arr, pipe } from \"effect\";\n\nconst SECONDS_PER_MINUTE = 60;\nconst QUARTERS_PER_WHOLE = 4;\nconst NONE = 0;\n\ninterface Segment {\n readonly start: number;\n readonly end: number;\n readonly bpm: number;\n}\n\nconst segmentsIn = (bar: Bar): readonly Segment[] =>\n Arr.match(bar.tempoSteps, {\n onEmpty: () => [{ start: bar.start, end: bar.start + bar.length, bpm: bar.tempo.bpm }],\n onNonEmpty: (steps) =>\n pipe(\n steps,\n Arr.map((step) => ({\n start: bar.start + step.offset,\n end: bar.start + step.offset + step.length,\n bpm: step.bpm,\n })),\n ),\n });\n\nconst secondsPerTick = (bpm: number): number =>\n (SECONDS_PER_MINUTE * QUARTERS_PER_WHOLE) / (bpm * TICKS_PER_WHOLE);\n\nexport const clockOf = (song: Song): ((tick: number) => number) => {\n const segments = pipe(song.bars, Arr.flatMap(segmentsIn));\n return (tick) => {\n let seconds = NONE;\n for (const segment of segments) {\n if (segment.start < tick) {\n seconds += (Math.min(tick, segment.end) - segment.start) * secondsPerTick(segment.bpm);\n }\n }\n return seconds;\n };\n};\n","import type { Sounding } from \"@r_masseater/song-format/analysis\";\nimport { Array as Arr, Option, pipe } from \"effect\";\n\nimport { numberOption } from \"#/app/presets/shared/lib/options.ts\";\nimport { clockOf } from \"#/app/presets/shared/lib/time.ts\";\nimport {\n MELODIC,\n hasRole,\n reporterOf,\n topLineOf,\n tracksOf,\n} from \"#/app/presets/shared/lib/voices.ts\";\nimport type { Reporter } from \"#/app/presets/shared/lib/voices.ts\";\nimport { defineRule } from \"#/entities/rule/index.ts\";\nimport type { Rule } from \"#/shared/config/index.ts\";\n\nconst DEFAULT_SECONDS = 8;\nconst DEFAULT_REST = 0.15;\nconst DIGITS = 1;\nconst LAST = 1;\nconst maxSeconds = numberOption({ key: \"seconds\", fallback: DEFAULT_SECONDS });\nconst minRest = numberOption({ key: \"rest\", fallback: DEFAULT_REST });\n\ntype Clock = (tick: number) => number;\n\ntype Phrase = Arr.NonEmptyReadonlyArray<Sounding>;\n\nconst phrasesOf =\n (clock: Clock, rest: number) =>\n (line: readonly Sounding[]): readonly Phrase[] =>\n Arr.reduce(line, Arr.empty<Phrase>(), (phrases, note): readonly Phrase[] =>\n pipe(\n Arr.last(phrases),\n Option.filter((phrase) => clock(note.start) - clock(Arr.lastNonEmpty(phrase).end) < rest),\n Option.match({\n onNone: () => Arr.append(phrases, Arr.of(note)),\n onSome: (phrase) => Arr.append(Arr.dropRight(phrases, LAST), Arr.append(phrase, note)),\n }),\n ),\n );\n\nconst endOf = (phrase: Phrase): number =>\n pipe(\n phrase,\n Arr.map((sounding) => sounding.end),\n (ends) => Math.max(...ends),\n );\n\nconst checkPhrase =\n (report: Reporter, clock: Clock, max: number) =>\n (phrase: Phrase): void => {\n const first = Arr.headNonEmpty(phrase);\n const seconds = clock(endOf(phrase)) - clock(first.start);\n if (seconds > max) {\n report(`${String(first.line)}:${String(first.start)}`, {\n line: first.line,\n column: first.column,\n message: `${first.track} sings for ${seconds.toFixed(DIGITS)} seconds without a rest`,\n detail: \"Put a short rest in the phrase\",\n });\n }\n };\n\nexport const breath: Rule = defineRule({\n meta: { description: \"A sung line leaves room to breathe\" },\n check: (context) => {\n const clock = clockOf(context.song);\n const check = checkPhrase(reporterOf(context), clock, maxSeconds(context.options));\n const split = phrasesOf(clock, minRest(context.options));\n const melodic = pipe(context.soundings, Arr.filter(hasRole(MELODIC)));\n for (const track of tracksOf(melodic)) {\n for (const phrase of split(topLineOf(track))) {\n check(phrase);\n }\n }\n },\n});\n","import { TICKS_PER_WHOLE } from \"@r_masseater/song-format\";\nimport type { Sounding } from \"@r_masseater/song-format/analysis\";\nimport { Array as Arr, pipe } from \"effect\";\n\nimport { numberOption } from \"#/app/presets/shared/lib/options.ts\";\nimport {\n MELODIC,\n hasRole,\n neighborsOf,\n reporterOf,\n topLineOf,\n tracksOf,\n} from \"#/app/presets/shared/lib/voices.ts\";\nimport type { Reporter } from \"#/app/presets/shared/lib/voices.ts\";\nimport { defineRule } from \"#/entities/rule/index.ts\";\nimport type { Rule } from \"#/shared/config/index.ts\";\n\nconst OCTAVE = 12;\nconst maxLeap = numberOption({ key: \"max\", fallback: OCTAVE });\n\nconst checkStep =\n (report: Reporter, max: number) =>\n ([previous, next]: readonly [Sounding, Sounding]): void => {\n const leap = Math.abs(next.midi - previous.midi);\n if (leap > max && next.start - previous.end < TICKS_PER_WHOLE) {\n report(`${String(next.line)}:${String(next.start)}`, {\n line: next.line,\n column: next.column,\n message: `${next.track} leaps ${String(leap)} semitones from ${previous.spelling} to ${next.spelling}`,\n detail: \"Make the jump smaller, or step back the other way right after it\",\n });\n }\n };\n\nexport const melodyLeap: Rule = defineRule({\n meta: { description: \"A melody does not jump further than an octave from one note to the next\" },\n check: (context) => {\n const check = checkStep(reporterOf(context), maxLeap(context.options));\n const melodic = pipe(context.soundings, Arr.filter(hasRole(MELODIC)));\n for (const track of tracksOf(melodic)) {\n for (const step of neighborsOf(topLineOf(track))) {\n check(step);\n }\n }\n },\n});\n","import { Array as Arr, Option, pipe } from \"effect\";\nimport { Chord } from \"tonal\";\n\nconst COMMON = [\n \"M\",\n \"m\",\n \"dim\",\n \"aug\",\n \"7\",\n \"maj7\",\n \"m7\",\n \"m7b5\",\n \"dim7\",\n \"sus4\",\n \"sus2\",\n \"6\",\n \"m6\",\n \"Madd9\",\n \"madd9\",\n \"9\",\n \"maj9\",\n \"m9\",\n \"7sus4\",\n \"m/ma7\",\n \"6add9\",\n \"m69\",\n \"5\",\n];\nconst DYAD = 2;\n\nconst isCommonName = (name: string): boolean =>\n pipe(\n Arr.head(Chord.get(name).aliases),\n Option.exists((alias) => Arr.contains(COMMON, alias)),\n );\n\nexport const isCommonChord = (pitchClasses: readonly string[]): boolean => {\n const names = Arr.dedupe(pitchClasses);\n if (names.length < DYAD) {\n return true;\n }\n return pipe(Chord.detect(names), Arr.some(isCommonName));\n};\n","import { TICKS_PER_WHOLE } from \"@r_masseater/song-format\";\nimport type { KeySpan, Sounding } from \"@r_masseater/song-format/analysis\";\nimport { Array as Arr, Option, Record as Rec, pipe } from \"effect\";\n\nimport { isCommonChord } from \"#/app/presets/shared/lib/chords.ts\";\nimport { keyAt, keysOf } from \"#/app/presets/shared/lib/keys.ts\";\nimport { pitchClassOf } from \"#/app/presets/shared/lib/pitch.ts\";\nimport {\n hasRole,\n isPitched,\n reporterOf,\n soundingAt,\n tracksOf,\n} from \"#/app/presets/shared/lib/voices.ts\";\nimport type { Reporter } from \"#/app/presets/shared/lib/voices.ts\";\nimport { defineRule } from \"#/entities/rule/index.ts\";\nimport type { Rule } from \"#/shared/config/index.ts\";\n\nconst EIGHTHS_PER_WHOLE = 8;\nconst ORNAMENT = TICKS_PER_WHOLE / EIGHTHS_PER_WHOLE;\nconst HALF_STEP = 1;\nconst WHOLE_STEP = 2;\nconst MAJOR_STEPS = { tonic: 0, second: 2, third: 4, fourth: 5, fifth: 7, sixth: 9, seventh: 11 };\nconst MINOR_STEPS = {\n tonic: 0,\n second: 2,\n flatThird: 3,\n fourth: 5,\n fifth: 7,\n flatSixth: 8,\n raisedSixth: 9,\n flatSeventh: 10,\n leadingTone: 11,\n};\nconst MAJOR = Rec.values(MAJOR_STEPS);\nconst MINOR = Rec.values(MINOR_STEPS);\nconst stepsOf = (key: KeySpan): readonly number[] => {\n if (key.mode === \"major\") {\n return MAJOR;\n }\n return MINOR;\n};\n\nconst inScale =\n (key: KeySpan) =>\n (midi: number): boolean =>\n Arr.contains(stepsOf(key), pitchClassOf(midi - key.pitchClass));\n\ntype Fits = (sounding: Sounding) => boolean;\n\nconst inChordOf = (soundings: readonly Sounding[]): Fits => {\n const harmony = pipe(soundings, Arr.filter(hasRole([\"bass\", \"harmony\"])));\n return (sounding) => {\n const under = soundingAt(harmony)(sounding.start);\n const shared = pipe(\n under,\n Arr.some(\n (other) =>\n other.track !== sounding.track &&\n pitchClassOf(other.midi) === pitchClassOf(sounding.midi),\n ),\n );\n const voicesChord =\n hasRole([\"bass\", \"harmony\"])(sounding) &&\n isCommonChord(\n pipe(\n under,\n Arr.map((other) => other.pitchClass),\n ),\n );\n return shared || voicesChord;\n };\n};\n\nconst isStep = (from: Sounding, to: Sounding): boolean => {\n const distance = Math.abs(to.midi - from.midi);\n return distance >= HALF_STEP && distance <= WHOLE_STEP;\n};\n\nconst neighboursOf =\n (track: readonly Sounding[]) =>\n (sounding: Sounding): Option.Option<readonly [Sounding, Sounding]> => {\n const before = pipe(\n track,\n Arr.findLast((other) => other.end === sounding.start),\n );\n const after = pipe(\n track,\n Arr.findFirst((other) => other.start === sounding.end),\n );\n return Option.all([before, after]);\n };\n\nconst isOrnament =\n (fits: Fits, track: readonly Sounding[]) =>\n (sounding: Sounding): boolean =>\n sounding.end - sounding.start <= ORNAMENT &&\n pipe(\n neighboursOf(track)(sounding),\n Option.exists(\n ([before, after]) =>\n isStep(before, sounding) && isStep(sounding, after) && fits(before) && fits(after),\n ),\n );\n\nconst fitsOf =\n (keys: readonly KeySpan[], inChord: Fits): Fits =>\n (sounding) =>\n inChord(sounding) ||\n pipe(\n keyAt(keys)(sounding.bar),\n Option.match({ onNone: () => true, onSome: (key) => inScale(key)(sounding.midi) }),\n );\n\ninterface NoteCheck {\n readonly report: Reporter;\n readonly keys: readonly KeySpan[];\n readonly fits: Fits;\n readonly tracks: readonly (readonly Sounding[])[];\n}\n\nconst trackOf =\n (tracks: readonly (readonly Sounding[])[]) =>\n (sounding: Sounding): readonly Sounding[] =>\n pipe(\n tracks,\n Arr.findFirst((candidate) =>\n pipe(\n candidate,\n Arr.some((other) => other.track === sounding.track),\n ),\n ),\n Option.getOrElse((): readonly Sounding[] => []),\n );\n\nconst checkNote =\n ({ report, keys, fits, tracks }: NoteCheck) =>\n (sounding: Sounding): void => {\n const track = trackOf(tracks)(sounding);\n for (const key of Option.toArray(keyAt(keys)(sounding.bar))) {\n if (!fits(sounding) && !isOrnament(fits, track)(sounding)) {\n report(`${String(sounding.line)}:${String(sounding.column)}`, {\n line: sounding.line,\n column: sounding.column,\n message: `${sounding.spelling} in ${sounding.track} is outside ${key.tonic} ${key.mode} and the chord under it`,\n detail: \"Move it a semitone, or ignore the line if the borrowed note is intended\",\n });\n }\n }\n };\n\nexport const outOfKey: Rule = defineRule({\n meta: { description: \"Notes stay in the key the notes around them imply\" },\n check: (context) => {\n const keys = keysOf(context.song);\n const pitched = pipe(context.soundings, Arr.filter(isPitched));\n const fits = fitsOf(keys, inChordOf(context.soundings));\n const check = checkNote({ report: reporterOf(context), keys, fits, tracks: tracksOf(pitched) });\n for (const sounding of pitched) {\n check(sounding);\n }\n },\n});\n","import type { Sounding } from \"@r_masseater/song-format/analysis\";\nimport { Array as Arr, Option, Predicate, Record as Rec, pipe } from \"effect\";\n\nimport { midiOf } from \"#/app/presets/shared/lib/pitch.ts\";\nimport { reporterOf } from \"#/app/presets/shared/lib/voices.ts\";\nimport type { Reporter } from \"#/app/presets/shared/lib/voices.ts\";\nimport { defineRule } from \"#/entities/rule/index.ts\";\nimport type { Rule, RuleOptions } from \"#/shared/config/index.ts\";\n\nexport type Range = readonly [string, string];\n\nexport type Ranges = Readonly<Record<string, Range>>;\n\nexport const DEFAULT_RANGES: Ranges = {\n melody: [\"C3\", \"C6\"],\n countermelody: [\"C3\", \"C6\"],\n bass: [\"E1\", \"C4\"],\n};\n\ninterface Bounds {\n readonly low: number;\n readonly high: number;\n readonly name: string;\n}\n\nconst RANGE_LENGTH = 2;\n\nconst isRange = (value: unknown): value is Range =>\n Arr.isArray(value) && value.length === RANGE_LENGTH && pipe(value, Arr.every(Predicate.isString));\n\nconst boundsOf = ([low, high]: Range): Option.Option<Bounds> =>\n Option.all({ low: midiOf(low), high: midiOf(high), name: Option.some(`${low}-${high}`) });\n\nconst configured = (options: RuleOptions): Readonly<Record<string, unknown>> =>\n pipe(\n Option.fromNullishOr(options[\"ranges\"]),\n Option.filter(Predicate.isObject),\n Option.map((value): Readonly<Record<string, unknown>> => ({ ...DEFAULT_RANGES, ...value })),\n Option.getOrElse((): Readonly<Record<string, unknown>> => DEFAULT_RANGES),\n );\n\nconst rangesOf = (options: RuleOptions): Readonly<Record<string, Bounds>> =>\n pipe(\n configured(options),\n Rec.toEntries,\n Arr.flatMap(([name, value]) =>\n pipe(\n Option.liftPredicate(value, isRange),\n Option.flatMap(boundsOf),\n Option.map((bounds): readonly [string, Bounds] => [name, bounds]),\n Option.toArray,\n ),\n ),\n Rec.fromEntries,\n );\n\nconst boundsFor =\n (ranges: Readonly<Record<string, Bounds>>) =>\n (sounding: Sounding): Option.Option<Bounds> =>\n pipe(\n ranges,\n Rec.get(sounding.track),\n Option.orElse(() =>\n pipe(\n sounding.role,\n Option.flatMap((role) => pipe(ranges, Rec.get(role))),\n ),\n ),\n );\n\nconst checkNote =\n (report: Reporter) =>\n (sounding: Sounding, bounds: Bounds): void => {\n if (sounding.midi < bounds.low || sounding.midi > bounds.high) {\n report(`${String(sounding.line)}:${String(sounding.column)}`, {\n line: sounding.line,\n column: sounding.column,\n message: `${sounding.spelling} in ${sounding.track} is outside ${bounds.name}`,\n detail: \"Move the phrase an octave, or set the range of this track\",\n });\n }\n };\n\nexport const partRange: Rule = defineRule({\n meta: { description: \"Each part stays inside the range its singer or instrument can play\" },\n check: (context) => {\n const check = checkNote(reporterOf(context));\n const lookup = boundsFor(rangesOf(context.options));\n for (const sounding of context.soundings) {\n for (const bounds of Option.toArray(lookup(sounding))) {\n check(sounding, bounds);\n }\n }\n },\n});\n","import { Option, pipe } from \"effect\";\n\nimport { definePlugin } from \"#/entities/rule/index.ts\";\nimport type { I68Config, Plugin, RuleEntry } from \"#/shared/config/index.ts\";\n\nimport { breath } from \"./breath.ts\";\nimport { melodyLeap } from \"./melody-leap.ts\";\nimport { outOfKey } from \"./out-of-key.ts\";\nimport { partRange } from \"./part-range.ts\";\nimport type { Ranges } from \"./part-range.ts\";\n\nexport interface PopOptions {\n readonly ranges?: Ranges;\n readonly maxLeap?: number;\n readonly breathSeconds?: number;\n}\n\nexport const popPlugin: Plugin = definePlugin({\n rules: {\n \"out-of-key\": outOfKey,\n \"part-range\": partRange,\n \"melody-leap\": melodyLeap,\n breath,\n },\n});\n\nconst warnWith =\n (key: string) =>\n (value: unknown): RuleEntry =>\n pipe(\n Option.fromNullishOr(value),\n Option.match({\n onNone: (): RuleEntry => \"warn\",\n onSome: (given): RuleEntry => [\"warn\", { [key]: given }],\n }),\n );\n\nexport const pop = (options: PopOptions = {}): I68Config => ({\n plugins: { pop: popPlugin },\n rules: {\n \"pop/out-of-key\": \"warn\",\n \"pop/part-range\": warnWith(\"ranges\")(options.ranges),\n \"pop/melody-leap\": warnWith(\"max\")(options.maxLeap),\n \"pop/breath\": warnWith(\"seconds\")(options.breathSeconds),\n },\n});\n","import type { Sounding } from \"@r_masseater/song-format/analysis\";\nimport { Array as Arr, Option, Order, pipe } from \"effect\";\n\nimport { MELODIC, hasRole, highest, lowest, soundingAt } from \"#/app/presets/shared/lib/voices.ts\";\n\nexport interface OuterPair {\n readonly tick: number;\n readonly melody: Sounding;\n readonly bass: Sounding;\n}\n\nconst pickAt =\n (\n soundings: readonly Sounding[],\n pick: (found: Arr.NonEmptyReadonlyArray<Sounding>) => Sounding,\n ) =>\n (tick: number): Option.Option<Sounding> =>\n pipe(\n soundingAt(soundings)(tick),\n Arr.match({ onEmpty: () => Option.none(), onNonEmpty: (found) => Option.some(pick(found)) }),\n );\n\nexport const outerVoicesOf = (soundings: readonly Sounding[]): readonly OuterPair[] => {\n const melodic = pipe(soundings, Arr.filter(hasRole(MELODIC)));\n const low = pipe(soundings, Arr.filter(hasRole([\"bass\"])));\n const topAt = pickAt(melodic, highest);\n const bottomAt = pickAt(low, lowest);\n const ticks = pipe(\n [...melodic, ...low],\n Arr.map((sounding) => sounding.start),\n Arr.dedupe,\n (all) => Arr.sort(all, Order.Number),\n );\n const pairAt = (tick: number): Option.Option<OuterPair> =>\n pipe(\n Option.all({ melody: topAt(tick), bass: bottomAt(tick) }),\n Option.map(({ melody, bass }) => ({ tick, melody, bass })),\n );\n return pipe(ticks, Arr.map(pairAt), Arr.getSomes);\n};\n","import { Match, Option } from \"effect\";\n\nimport { pitchClassOf } from \"#/app/presets/shared/lib/pitch.ts\";\nimport { neighborsOf, reporterOf } from \"#/app/presets/shared/lib/voices.ts\";\nimport type { Reporter } from \"#/app/presets/shared/lib/voices.ts\";\nimport { defineRule } from \"#/entities/rule/index.ts\";\nimport type { Rule } from \"#/shared/config/index.ts\";\n\nimport { outerVoicesOf } from \"./outer-voices.ts\";\nimport type { OuterPair } from \"./outer-voices.ts\";\n\nconst UNISON = 0;\nconst FIFTH = 7;\nconst STILL = 0;\n\nconst perfectName = (interval: number): Option.Option<string> =>\n Match.value(interval).pipe(\n Match.when(UNISON, () => Option.some(\"octaves\")),\n Match.when(FIFTH, () => Option.some(\"fifths\")),\n Match.orElse(() => Option.none()),\n );\n\nconst intervalOf = (pair: OuterPair): number => pitchClassOf(pair.melody.midi - pair.bass.midi);\n\nconst movesTogether = (previous: OuterPair, next: OuterPair): boolean => {\n const melody = Math.sign(next.melody.midi - previous.melody.midi);\n return melody !== STILL && melody === Math.sign(next.bass.midi - previous.bass.midi);\n};\n\nconst checkMove =\n (report: Reporter) =>\n ([previous, next]: readonly [OuterPair, OuterPair]): void => {\n const name = perfectName(intervalOf(next));\n if (\n Option.isSome(name) &&\n intervalOf(previous) === intervalOf(next) &&\n movesTogether(previous, next)\n ) {\n report(`${String(next.melody.line)}:${String(next.tick)}`, {\n line: next.melody.line,\n column: next.melody.column,\n message: `Parallel ${name.value}: ${previous.melody.spelling}/${previous.bass.spelling} to ${next.melody.spelling}/${next.bass.spelling} between ${next.melody.track} and ${next.bass.track}`,\n detail: \"Move the melody or the bass the other way\",\n });\n }\n };\n\nexport const parallelPerfects: Rule = defineRule({\n meta: { description: \"Melody and bass do not move in parallel fifths or octaves\" },\n check: (context) => {\n const check = checkMove(reporterOf(context));\n for (const move of neighborsOf(outerVoicesOf(context.soundings))) {\n check(move);\n }\n },\n});\n","import type { Song } from \"@r_masseater/song-format\";\nimport type { Sounding } from \"@r_masseater/song-format/analysis\";\nimport { Array as Arr, Option, Record as Rec, pipe } from \"effect\";\n\nimport { pitchClassOf } from \"#/app/presets/shared/lib/pitch.ts\";\nimport {\n MELODIC,\n hasRole,\n neighborsOf,\n reporterOf,\n topLineOf,\n tracksOf,\n} from \"#/app/presets/shared/lib/voices.ts\";\nimport type { Reporter } from \"#/app/presets/shared/lib/voices.ts\";\nimport { defineRule } from \"#/entities/rule/index.ts\";\nimport type { Rule } from \"#/shared/config/index.ts\";\n\nimport { outerVoicesOf } from \"./outer-voices.ts\";\n\nconst DISSONANT_STEPS = {\n minorSecond: 1,\n majorSecond: 2,\n fourth: 5,\n tritone: 6,\n minorSeventh: 10,\n majorSeventh: 11,\n};\nconst DISSONANT = Rec.values(DISSONANT_STEPS);\nconst STEP_DOWN = Rec.values({ halfStep: -1, wholeStep: -2 });\nconst HALVES = 2;\nconst ON_BEAT = 0;\n\nconst strongLength = (length: number, numerator: number): number => {\n if (numerator % HALVES === ON_BEAT) {\n return length / HALVES;\n }\n return length;\n};\n\nconst isStrongBeat =\n (song: Song) =>\n (sounding: Sounding): boolean =>\n pipe(\n song.bars,\n Arr.findFirst((bar) => bar.index === sounding.bar),\n Option.exists(\n (bar) =>\n (sounding.start - bar.start) % strongLength(bar.length, bar.meter.numerator) === ON_BEAT,\n ),\n );\n\ntype BassAt = (tick: number) => Option.Option<Sounding>;\n\nconst bassOf = (soundings: readonly Sounding[]): BassAt => {\n const pairs = outerVoicesOf(soundings);\n return (tick) =>\n pipe(\n pairs,\n Arr.findFirst((pair) => pair.tick === tick),\n Option.map((pair) => pair.bass),\n );\n};\n\nconst checkNote =\n (report: Reporter, strong: (sounding: Sounding) => boolean, bassAt: BassAt) =>\n ([note, next]: readonly [Sounding, Option.Option<Sounding>]): void => {\n const dissonant = Option.exists(bassAt(note.start), (bass) =>\n Arr.contains(DISSONANT, pitchClassOf(note.midi - bass.midi)),\n );\n const resolved = Option.exists(next, (found) =>\n Arr.contains(STEP_DOWN, found.midi - note.midi),\n );\n if (strong(note) && dissonant && !resolved) {\n report(`${String(note.line)}:${String(note.start)}`, {\n line: note.line,\n column: note.column,\n message: `${note.spelling} in ${note.track} is dissonant against the bass and does not step down`,\n detail: \"Move the next note down a step\",\n });\n }\n };\n\nconst withNext = (\n line: readonly Sounding[],\n): readonly (readonly [Sounding, Option.Option<Sounding>])[] => [\n ...pipe(\n neighborsOf(line),\n Arr.map(([note, next]): readonly [Sounding, Option.Option<Sounding>] => [\n note,\n Option.some(next),\n ]),\n ),\n ...pipe(\n Arr.last(line),\n Option.map((note): readonly [Sounding, Option.Option<Sounding>] => [note, Option.none()]),\n Option.toArray,\n ),\n];\n\nexport const unresolvedDissonance: Rule = defineRule({\n meta: { description: \"A dissonant melody note on a strong beat steps down to resolve\" },\n check: (context) => {\n const check = checkNote(\n reporterOf(context),\n isStrongBeat(context.song),\n bassOf(context.soundings),\n );\n const melodic = pipe(context.soundings, Arr.filter(hasRole(MELODIC)));\n for (const track of tracksOf(melodic)) {\n for (const entry of withNext(topLineOf(track))) {\n check(entry);\n }\n }\n },\n});\n","import { definePlugin } from \"#/entities/rule/index.ts\";\nimport type { I68Config, Plugin } from \"#/shared/config/index.ts\";\n\nimport { parallelPerfects } from \"./parallel-perfects.ts\";\nimport { unresolvedDissonance } from \"./unresolved-dissonance.ts\";\n\nexport const classicalPlugin: Plugin = definePlugin({\n rules: {\n \"parallel-perfects\": parallelPerfects,\n \"unresolved-dissonance\": unresolvedDissonance,\n },\n});\n\nexport const classical = (): I68Config => ({\n plugins: { classical: classicalPlugin },\n rules: {\n \"classical/parallel-perfects\": \"warn\",\n \"classical/unresolved-dissonance\": \"warn\",\n },\n});\n","import { Array as Arr, Option, String as Str, pipe } from \"effect\";\n\nimport { progressionOf } from \"#/app/presets/shared/lib/degrees.ts\";\nimport type { Step } from \"#/app/presets/shared/lib/degrees.ts\";\nimport { reporterOf } from \"#/app/presets/shared/lib/voices.ts\";\nimport { defineRule } from \"#/entities/rule/index.ts\";\nimport type { Rule } from \"#/shared/config/index.ts\";\n\nexport interface Progression {\n readonly name: string;\n readonly degrees: readonly string[];\n}\n\nexport const PROGRESSIONS: readonly Progression[] = [\n { name: \"丸サ進行 (Just the Two of Us)\", degrees: [\"IVM7\", \"III7\", \"VIm7\"] },\n { name: \"王道進行\", degrees: [\"IV\", \"V\", \"IIIm\", \"VIm\"] },\n { name: \"小室進行\", degrees: [\"VIm\", \"IV\", \"V\", \"I\"] },\n { name: \"カノン進行\", degrees: [\"I\", \"V\", \"VIm\", \"IIIm\", \"IV\", \"I\", \"IV\", \"V\"] },\n { name: \"ii–V–I\", degrees: [\"IIm\", \"V\", \"I\"] },\n { name: \"Andalusian cadence\", degrees: [\"VIm\", \"V\", \"IV\", \"III\"] },\n];\n\nconst START = 0;\n\nconst FAMILIES = [\n [\"M7\", \"\"],\n [\"m7b5\", \"dim\"],\n [\"m7\", \"m\"],\n [\"dim7\", \"dim\"],\n [\"7\", \"\"],\n] as const;\n\nconst familyOf = (token: string): string =>\n pipe(\n FAMILIES,\n Arr.findFirst(([suffix]) => Str.endsWith(suffix)(token)),\n Option.match({\n onNone: () => token,\n onSome: ([suffix, triad]) =>\n `${Str.slice(START, token.length - suffix.length)(token)}${triad}`,\n }),\n );\n\nconst matches =\n (steps: readonly Step[], degrees: readonly string[]) =>\n (start: number): boolean =>\n pipe(\n degrees,\n Arr.every((degree, offset) =>\n pipe(\n Arr.get(steps, start + offset),\n Option.exists((step) => familyOf(step.token) === familyOf(degree)),\n ),\n ),\n );\n\nexport const namedProgression: Rule = defineRule({\n meta: { description: \"Names the well-known chord progressions a song uses\" },\n check: (context) => {\n const steps = progressionOf(context.soundings)(context.song);\n const report = reporterOf(context);\n for (const progression of PROGRESSIONS) {\n const starts = pipe(\n Arr.makeBy(steps.length, (index) => index),\n Arr.filter(matches(steps, progression.degrees)),\n );\n for (const step of pipe(\n starts,\n Arr.flatMap((start) => Option.toArray(Arr.get(steps, start))),\n )) {\n report(`${progression.name}:${String(step.line)}:${String(step.bar)}`, {\n line: step.line,\n column: step.column,\n message: `${progression.name} (${Arr.join(progression.degrees, \"–\")}) starts in bar ${String(step.bar)}`,\n });\n }\n }\n },\n});\n","import { definePlugin } from \"#/entities/rule/index.ts\";\nimport type { I68Config, Plugin } from \"#/shared/config/index.ts\";\n\nimport { namedProgression } from \"./named.ts\";\n\nexport const progressionsPlugin: Plugin = definePlugin({\n rules: { named: namedProgression },\n});\n\nexport const progressions = (): I68Config => ({\n plugins: { progressions: progressionsPlugin },\n rules: { \"progressions/named\": \"warn\" },\n});\n","import { Array as Arr, Number as Num, Option, Record as Rec, pipe } from \"effect\";\n\nimport { progressionOf } from \"#/app/presets/shared/lib/degrees.ts\";\nimport type { Step } from \"#/app/presets/shared/lib/degrees.ts\";\nimport { numberOption } from \"#/app/presets/shared/lib/options.ts\";\nimport { longestContext } from \"#/app/presets/shared/lib/style-table.ts\";\nimport type { Context, StyleTable } from \"#/app/presets/shared/lib/style-table.ts\";\nimport { reporterOf } from \"#/app/presets/shared/lib/voices.ts\";\nimport type { Reporter } from \"#/app/presets/shared/lib/voices.ts\";\nimport { defineRule } from \"#/entities/rule/index.ts\";\nimport type { Rule } from \"#/shared/config/index.ts\";\n\nconst DEFAULT_SHARE = 0.03;\nconst DEFAULT_SEEN = 8;\nconst PERCENT = 100;\nconst SUGGESTIONS = 3;\nconst FIRST = 1;\nconst NEVER = 0;\nconst minShare = numberOption({ key: \"share\", fallback: DEFAULT_SHARE });\nconst minSeen = numberOption({ key: \"seen\", fallback: DEFAULT_SEEN });\n\nconst percentOf = (count: number, total: number): string =>\n `${String(Math.round((count / total) * PERCENT))}%`;\n\nconst suggestionsOf = (context: Context): string =>\n pipe(\n Rec.toEntries(context.next),\n Arr.sortWith(([, count]) => -count, Num.Order),\n Arr.take(SUGGESTIONS),\n Arr.map(([token, count]) => `${token} (${percentOf(count, context.total)})`),\n Arr.join(\", \"),\n );\n\ninterface Limits {\n readonly share: number;\n readonly seen: number;\n}\n\nconst checkStep =\n (report: Reporter, table: StyleTable, { share, seen }: Limits) =>\n (steps: readonly Step[], index: number): void => {\n const before = Arr.take(steps, index);\n for (const step of Option.toArray(Arr.get(steps, index))) {\n for (const context of Option.toArray(longestContext({ table, seen })(before))) {\n const count = Option.getOrElse(Rec.get(context.next, step.token), () => NEVER);\n if (count / context.total < share) {\n report(`${String(step.line)}:${step.token}:${String(index)}`, {\n line: step.line,\n column: step.column,\n message: `${context.words} → ${step.token} is rare in ${table.name} (${percentOf(count, context.total)})`,\n detail: `${table.name} usually goes to ${suggestionsOf(context)}`,\n });\n }\n }\n }\n };\n\nexport const rareTransitionOf = (table: StyleTable): Rule =>\n defineRule({\n meta: { description: `Chord changes follow what ${table.name} usually does next` },\n check: (context) => {\n const steps = progressionOf(context.soundings)(context.song);\n const check = checkStep(reporterOf(context), table, {\n share: minShare(context.options),\n seen: minSeen(context.options),\n });\n const indices = Arr.makeBy(steps.length, (at) => at);\n for (const index of Arr.drop(indices, FIRST)) {\n check(steps, index);\n }\n },\n });\n","import BACH_CHORALES from \"#/app/presets/features/check-style/data/bach-chorales.json\" with { type: \"json\" };\nimport type { StyleTable } from \"#/app/presets/shared/lib/style-table.ts\";\nimport { definePlugin } from \"#/entities/rule/index.ts\";\nimport type { I68Config, Plugin } from \"#/shared/config/index.ts\";\n\nimport { rareTransitionOf } from \"./rare-transition.ts\";\n\nexport const bachPlugin: Plugin = definePlugin({\n rules: { \"rare-transition\": rareTransitionOf(BACH_CHORALES) },\n});\n\nexport const bach = (): I68Config => ({\n plugins: { bach: bachPlugin },\n rules: { \"bach/rare-transition\": \"warn\" },\n});\n\nexport const stylePluginOf = (table: StyleTable): Plugin =>\n definePlugin({ rules: { \"rare-transition\": rareTransitionOf(table) } });\n","import type { RuleContext } from \"@r_masseater/i68\";\nimport { Array as Arr, Option, String as Str, pipe } from \"effect\";\n\nimport { progressionOf } from \"#/app/presets/shared/lib/degrees.ts\";\nimport type { Step } from \"#/app/presets/shared/lib/degrees.ts\";\nimport { mixFactsOf, placeIn, trackKeyOf } from \"#/app/presets/shared/lib/mix-facts.ts\";\nimport type { MixFact, MixPlace } from \"#/app/presets/shared/lib/mix-facts.ts\";\nimport { mixKeyOf } from \"#/app/presets/shared/lib/mix-habit.ts\";\nimport type { MixHabit } from \"#/app/presets/shared/lib/mix-habit.ts\";\nimport type { Subject } from \"#/app/presets/shared/lib/style-rules.ts\";\n\nconst FIRST = 1;\n\nexport interface Occasion {\n readonly id: string;\n readonly line: number;\n readonly column: number;\n readonly holds: boolean;\n}\n\ntype Chord = Extract<Subject, { readonly type: \"chord\" }>;\n\nconst follows = (before: readonly Step[], context: string): boolean => {\n const words = Str.split(\" \")(context);\n return (\n before.length >= words.length &&\n pipe(\n Arr.takeRight(before, words.length),\n Arr.map((step) => step.token),\n Arr.join(\" \"),\n ) === context\n );\n};\n\nconst chordOccasions =\n (context: RuleContext) =>\n (chord: Chord): readonly Occasion[] => {\n const steps = progressionOf(context.soundings)(context.song);\n return pipe(\n Arr.makeBy(steps.length, (index) => index),\n Arr.drop(FIRST),\n Arr.filter((index) => follows(Arr.take(steps, index), chord.context)),\n Arr.map((index) => {\n const step = Arr.getUnsafe(steps, index);\n return {\n id: String(index),\n line: step.line,\n column: step.column,\n holds: step.token === chord.next,\n };\n }),\n );\n };\n\nconst sectionStartsOf = (context: RuleContext): readonly number[] =>\n pipe(\n context.song.bars,\n Arr.drop(FIRST),\n Arr.filter((bar) => Option.isSome(bar.section) || Option.isSome(bar.mark)),\n Arr.map((bar) => bar.index),\n );\n\nconst occasionAt = (place: MixPlace, holds: boolean): Occasion => ({\n id: String(place.bar),\n line: place.line,\n column: place.column,\n holds,\n});\n\nconst has =\n (facts: readonly MixFact[], habit: MixHabit) =>\n (bar: Option.Option<number>): boolean =>\n pipe(\n facts,\n Arr.some(\n (fact) =>\n mixKeyOf(fact.habit) === mixKeyOf(habit) &&\n Option.match(bar, { onNone: () => true, onSome: (at) => fact.place.bar === at }),\n ),\n );\n\nconst mixOccasions =\n (context: RuleContext) =>\n (habit: MixHabit): readonly Occasion[] => {\n const facts = mixFactsOf(context.soundings)(context.song);\n const place = placeIn(context.soundings);\n const tracks = pipe(\n context.song.tracks,\n Arr.filter((track) => trackKeyOf(track.name) === habit.track),\n );\n if (habit.type !== \"move\") {\n return pipe(\n tracks,\n Arr.map((track) =>\n occasionAt(place({ track: track.name, bar: FIRST }), has(facts, habit)(Option.none())),\n ),\n );\n }\n return pipe(\n tracks,\n Arr.flatMap((track) =>\n pipe(\n sectionStartsOf(context),\n Arr.map((bar) =>\n occasionAt(place({ track: track.name, bar }), has(facts, habit)(Option.some(bar))),\n ),\n ),\n ),\n );\n };\n\nexport const occasionsOf =\n (context: RuleContext) =>\n (subject: Subject): readonly Occasion[] => {\n if (subject.type === \"chord\") {\n return chordOccasions(context)(subject);\n }\n return mixOccasions(context)(subject);\n };\n","import { defineRule } from \"@r_masseater/i68\";\nimport type { Rule } from \"@r_masseater/i68\";\nimport { Array as Arr, Option, pipe } from \"effect\";\n\nimport { subjectKeyOf } from \"#/app/presets/shared/lib/style-rules.ts\";\nimport type { HabitKind, HabitRule, StyleRules } from \"#/app/presets/shared/lib/style-rules.ts\";\nimport { reporterOf } from \"#/app/presets/shared/lib/voices.ts\";\n\nimport { occasionsOf } from \"./occasions.ts\";\n\ntype Wording = Readonly<{\n description: (name: string) => string;\n reportsWhen: boolean;\n message: (name: string, key: string) => string;\n}>;\n\nconst WORDINGS: Readonly<Record<HabitKind, Wording>> = {\n keep: {\n description: (name) => `Songs keep the habits of ${name}`,\n reportsWhen: false,\n message: (name, key) => `${name} keeps ${key} here`,\n },\n fix: {\n description: (name) => `Songs avoid the habits ${name} is fixing`,\n reportsWhen: true,\n message: (name, key) => `${key} is a habit ${name} is fixing`,\n },\n suggest: {\n description: (name) => `Habits that would fit ${name}`,\n reportsWhen: false,\n message: (name, key) => `${key} would fit ${name} here`,\n },\n};\n\nconst detailOf = (habit: HabitRule): string =>\n pipe(\n Option.fromNullishOr(habit.reason),\n Option.match({\n onNone: () => habit.aim,\n onSome: (reason) => `${habit.aim}: ${reason}`,\n }),\n );\n\nexport type HabitRuleInput = Readonly<{ rules: StyleRules; kind: HabitKind }>;\n\nexport const habitRuleOf = ({ rules, kind }: HabitRuleInput): Rule => {\n const wording = WORDINGS[kind];\n const habits = pipe(\n rules.habits,\n Arr.filter((habit) => habit.kind === kind),\n );\n return defineRule({\n meta: { description: wording.description(rules.name) },\n check: (context) => {\n const report = reporterOf(context);\n for (const habit of habits) {\n const key = subjectKeyOf(habit.habit);\n for (const occasion of occasionsOf(context)(habit.habit)) {\n if (occasion.holds === wording.reportsWhen) {\n report(`${key}:${occasion.id}`, {\n line: occasion.line,\n column: occasion.column,\n message: wording.message(rules.name, key),\n detail: detailOf(habit),\n });\n }\n }\n }\n },\n });\n};\n","import { definePlugin } from \"@r_masseater/i68\";\nimport type { I68Config, Plugin } from \"@r_masseater/i68\";\n\nimport type { StyleRules } from \"#/app/presets/shared/lib/style-rules.ts\";\n\nimport { habitRuleOf } from \"./habit-rule.ts\";\n\nexport const styleRulesPluginOf = (rules: StyleRules): Plugin =>\n definePlugin({\n rules: {\n keep: habitRuleOf({ rules, kind: \"keep\" }),\n fix: habitRuleOf({ rules, kind: \"fix\" }),\n suggest: habitRuleOf({ rules, kind: \"suggest\" }),\n },\n });\n\nexport type StyleRulesPreset = Readonly<{ plugin: string; rules: StyleRules }>;\n\nexport const styleRules = ({ plugin, rules }: StyleRulesPreset): I68Config => ({\n plugins: { [plugin]: styleRulesPluginOf(rules) },\n rules: {\n [`${plugin}/keep`]: \"warn\",\n [`${plugin}/fix`]: \"error\",\n [`${plugin}/suggest`]: \"warn\",\n },\n});\n","import { harmony } from \"#/app/presets/features/check-harmony/index.ts\";\nimport { pop } from \"#/app/presets/features/check-pop/index.ts\";\nimport type { PopOptions } from \"#/app/presets/features/check-pop/index.ts\";\nimport type { I68Config } from \"#/shared/config/index.ts\";\n\nexport { classical, classicalPlugin } from \"#/app/presets/features/check-classical/index.ts\";\nexport { DEFAULT_RANGES, pop, popPlugin } from \"#/app/presets/features/check-pop/index.ts\";\nexport type { PopOptions, Range, Ranges } from \"#/app/presets/features/check-pop/index.ts\";\nexport {\n PROGRESSIONS,\n progressions,\n progressionsPlugin,\n} from \"#/app/presets/features/check-progressions/index.ts\";\nexport type { Progression } from \"#/app/presets/features/check-progressions/index.ts\";\nexport { bach, bachPlugin, stylePluginOf } from \"#/app/presets/features/check-style/index.ts\";\nexport { styleRules, styleRulesPluginOf } from \"#/app/presets/features/check-habits/index.ts\";\nexport type { StyleRulesPreset } from \"#/app/presets/features/check-habits/index.ts\";\nexport {\n HABIT_KINDS,\n StyleRulesSchema,\n subjectKeyOf,\n} from \"#/app/presets/shared/lib/style-rules.ts\";\nexport type {\n HabitKind,\n HabitRule,\n StyleRules,\n Subject,\n} from \"#/app/presets/shared/lib/style-rules.ts\";\nexport { mixKeyOf } from \"#/app/presets/shared/lib/mix-habit.ts\";\nexport type { MixHabit } from \"#/app/presets/shared/lib/mix-habit.ts\";\nexport type { StyleTable, Transitions } from \"#/app/presets/shared/lib/style-table.ts\";\nexport { harmony, harmonyPlugin } from \"#/app/presets/features/check-harmony/index.ts\";\n\nexport const recommended = (options: PopOptions = {}): I68Config => ({\n extends: [pop(options), harmony()],\n});\n"],"mappings":";;;;;;AASA,MAAa,gBACV,EAAE,KAAK,gBACP,YACC,KACE,OAAO,cAAc,QAAQ,IAAI,GACjC,OAAO,OAAO,UAAU,QAAQ,GAChC,OAAO,gBAAgB,QAAQ,CACjC;;ACPJ,MAAMA,WAAS;AACf,MAAM,SAAS,aAAa;CAAE,KAAK;CAAU,UAAUA;AAAO,CAAC;AAC/D,MAAM,WAAW,QAAQ,CAAC,QAAQ,CAAC;AACnC,MAAM,YAAY,QAAQ,CAAC,SAAS,CAAC;AAErC,MAAM,eAAe,UAAkB,SAAwC;CAC7E,IAAI,WAAWA,UACb,OAAO,OAAO,KAAK,OAAO;CAE5B,IAAI,WAAWA,YAAU,YAAY,MACnC,OAAO,OAAO,KAAK,YAAY;CAEjC,OAAO,OAAO,KAAK;AACrB;AAEA,MAAMC,eACH,QAAkB,UAClB,SAAqB;CACpB,MAAM,QAAQ,OAAO,IAAI;EACvB,QAAQ,KAAK,MAAMC,MAAI,UAAU,QAAQ,CAAC;EAC1C,OAAO,KAAK,MAAMA,MAAI,UAAU,SAAS,CAAC;CAC5C,CAAC;CACD,KAAK,MAAM,EAAE,QAAQ,WAAW,OAAO,QAAQ,KAAK,GAClD,KAAK,MAAM,SAAS,OAAO,QAAQ,YAAY,OAAO,OAAO,MAAM,MAAM,IAAI,CAAC,GAC5E,OAAO,GAAG,OAAO,MAAM,IAAI,EAAE,GAAG,OAAO,MAAM,MAAM,EAAE,GAAG,OAAO,MAAM,GAAG,KAAK;EAC3E,MAAM,MAAM;EACZ,QAAQ,MAAM;EACd,SAAS,GAAG,MAAM,SAAS,MAAM,MAAM,MAAM,QAAQ,MAAM,mBAAmB,OAAO;EACrF,QAAQ;CACV,CAAC;AAGP;AAEF,MAAM,UAAU,aAAgC,SAAS,QAAQ,KAAK,UAAU,QAAQ;AAExF,MAAa,mBAAyB,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GP;EACF;CACF,CAAC;AACH;;AC/DA,MAAa,sBAAsB,UACjC,aAAa,EACX,OAAO;CACL,MAAM,YAAY;EAAE;EAAO,MAAM;CAAO,CAAC;CACzC,KAAK,YAAY;EAAE;EAAO,MAAM;CAAM,CAAC;CACvC,SAAS,YAAY;EAAE;EAAO,MAAM;CAAU,CAAC;AACjD,EACF,CAAC;AAIH,MAAa,cAAc,EAAE,QAAQ,aAA0C;CAC7E,SAAS,GAAG,SAAS,mBAAmB,KAAK,EAAE;CAC/C,OAAO;GACJ,GAAG,OAAO,SAAS;GACnB,GAAG,OAAO,QAAQ;GAClB,GAAG,OAAO,YAAY;CACzB;AACF;;ACQA,MAAa,eAAe,UAAsB,CAAC,OAAkB,EACnE,SAAS,CAAC,IAAI,OAAO,GAAG,QAAQ,CAAC,EACnC"}
|
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
import { Array, Boolean,
|
|
2
|
-
import { runMain } from "@r_masseater/node-main";
|
|
3
|
-
import { ChildProcess, ChildProcessSpawner } from "effect/process";
|
|
4
|
-
import { Argument, Command } from "effect/cli";
|
|
5
|
-
import { resolveConfigFromFile } from "vite-plus";
|
|
1
|
+
import { Array, Boolean, Effect, Function, Match, Option, Order, Predicate, Record, Result, Schema, String as String$1, pipe } from "effect";
|
|
6
2
|
import { readSong } from "@r_masseater/song-format";
|
|
7
3
|
import { soundingsOf } from "@r_masseater/song-format/analysis";
|
|
8
4
|
// ../lint-host/src/entities/rule/model/setting.ts
|
|
@@ -29,133 +25,9 @@ const mergedRules = (layers) => {
|
|
|
29
25
|
};
|
|
30
26
|
// ../lint-host/src/entities/rule/model/severity.ts
|
|
31
27
|
const reportedSeverity = (setting) => Match.value(setting.severity).pipe(Match.when("warn", () => "warn"), Match.orElse(() => "error"));
|
|
32
|
-
// ../lint-host/src/shared/lib/target.ts
|
|
33
|
-
const abiOf = (platform) => Match.value(platform).pipe(Match.when("linux", () => "-gnu"), Match.when("win32", () => "-msvc"), Match.orElse(() => ""));
|
|
34
|
-
const platformTarget = `${process.platform}-${process.arch}${abiOf(process.platform)}`;
|
|
35
|
-
const addonFileOf = (binary) => `${binary}.${platformTarget}.node`;
|
|
36
|
-
// ../lint-host/src/features/build-addon/model/build.ts
|
|
37
|
-
const taggedError$2 = Schema.TaggedError;
|
|
38
|
-
var AddonBuildFailed = class extends taggedError$2()("AddonBuildFailed", { message: Schema.String }) {};
|
|
39
|
-
const LIBRARY = {
|
|
40
|
-
linux: (name) => `lib${name}.so`,
|
|
41
|
-
darwin: (name) => `lib${name}.dylib`,
|
|
42
|
-
win32: (name) => `${name}.dll`
|
|
43
|
-
};
|
|
44
|
-
const SUCCESS = 0;
|
|
45
|
-
const cargo = Effect.fn("cargo")(function* cargo(crate, workspace) {
|
|
46
|
-
const exitCode = yield* (yield* ChildProcessSpawner.ChildProcessSpawner).exitCode(ChildProcess.make("cargo", [
|
|
47
|
-
"build",
|
|
48
|
-
"--release",
|
|
49
|
-
"--locked",
|
|
50
|
-
"-p",
|
|
51
|
-
crate
|
|
52
|
-
], {
|
|
53
|
-
cwd: workspace,
|
|
54
|
-
stdout: "inherit",
|
|
55
|
-
stderr: "inherit"
|
|
56
|
-
}));
|
|
57
|
-
const failure = AddonBuildFailed.make({ message: `cargo exited with ${String(exitCode)}` });
|
|
58
|
-
yield* Effect.when(Effect.fail(failure), Effect.sync(() => Number(exitCode) !== SUCCESS));
|
|
59
|
-
});
|
|
60
|
-
Effect.fn("buildAddon")(function* build(options) {
|
|
61
|
-
const fileSystem = yield* FileSystem.FileSystem;
|
|
62
|
-
const path = yield* Path.Path;
|
|
63
|
-
const library = yield* Effect.fromOption(Record.get(LIBRARY, process.platform)).pipe(Effect.mapError(() => AddonBuildFailed.make({ message: `no native build for ${process.platform}` })));
|
|
64
|
-
yield* cargo(options.crate, options.workspaceDir);
|
|
65
|
-
const output = path.join(options.packageDir, "native");
|
|
66
|
-
yield* fileSystem.makeDirectory(output, { recursive: true });
|
|
67
|
-
const built = library(String$1.replaceAll("-", "_")(options.crate));
|
|
68
|
-
yield* fileSystem.copyFile(path.join(options.workspaceDir, "target", "release", built), path.join(output, addonFileOf(options.binary)));
|
|
69
|
-
});
|
|
70
28
|
// ../lint-host/src/shared/lib/fail.ts
|
|
71
29
|
const taggedError$1 = Schema.TaggedError;
|
|
72
30
|
var NotUtf8Error = class extends taggedError$1()("NotUtf8Error", { path: Schema.String }) {};
|
|
73
|
-
// ../lint-host/src/features/run-cli/model/cli.ts
|
|
74
|
-
const CONFIG_FILES = [
|
|
75
|
-
"vite.config.ts",
|
|
76
|
-
"vite.config.mts",
|
|
77
|
-
"vite.config.js",
|
|
78
|
-
"vite.config.mjs"
|
|
79
|
-
];
|
|
80
|
-
const FAILED = 1;
|
|
81
|
-
const DATA_FIRST_ARITY$1 = 2;
|
|
82
|
-
const STRICT_UTF8 = new TextDecoder("utf-8", { fatal: true });
|
|
83
|
-
const readSectionIn = (source, root) => Effect.gen(function* readConfig() {
|
|
84
|
-
const fileSystem = yield* FileSystem.FileSystem;
|
|
85
|
-
const path = yield* Path.Path;
|
|
86
|
-
const found = yield* pipe(CONFIG_FILES, Array.map((name) => path.join(root, name)), Effect.filter((file) => fileSystem.exists(file).pipe(Effect.orElseSucceed(() => false))));
|
|
87
|
-
const loaded = yield* Option.match(Array.head(found), {
|
|
88
|
-
onNone: () => Effect.succeed({}),
|
|
89
|
-
onSome: (file) => Effect.tryPromise({
|
|
90
|
-
try: () => resolveConfigFromFile(file),
|
|
91
|
-
catch: source.failWith(`could not load ${file}`)
|
|
92
|
-
})
|
|
93
|
-
});
|
|
94
|
-
return source.section(loaded);
|
|
95
|
-
}).pipe(Effect.withSpan(`${source.name}.config`));
|
|
96
|
-
Function.dual(DATA_FIRST_ARITY$1, readSectionIn);
|
|
97
|
-
const trackedFiles = (root, pathspecs) => Effect.gen(function* listFiles() {
|
|
98
|
-
const output = yield* (yield* ChildProcessSpawner.ChildProcessSpawner).string(ChildProcess.make("git", [
|
|
99
|
-
"ls-files",
|
|
100
|
-
"-co",
|
|
101
|
-
"--exclude-standard",
|
|
102
|
-
"-z",
|
|
103
|
-
"--",
|
|
104
|
-
...pathspecs
|
|
105
|
-
], { cwd: root }));
|
|
106
|
-
return pipe(String$1.split(output, "\0"), Array.filter(String$1.isNonEmpty));
|
|
107
|
-
});
|
|
108
|
-
const requestOf = (config, patterns) => Array.match(patterns, {
|
|
109
|
-
onEmpty: () => ({ config }),
|
|
110
|
-
onNonEmpty: (given) => ({
|
|
111
|
-
config,
|
|
112
|
-
patterns: given
|
|
113
|
-
})
|
|
114
|
-
});
|
|
115
|
-
const hasError = (found) => pipe(found, Array.some(({ severity }) => severity === "error"));
|
|
116
|
-
const failWhen = (failed) => Effect.when(Effect.sync(() => {
|
|
117
|
-
process.exitCode = FAILED;
|
|
118
|
-
}), Effect.succeed(failed)).pipe(Effect.asVoid);
|
|
119
|
-
const printAll = (found, format) => Array.match(found, {
|
|
120
|
-
onEmpty: () => Effect.void,
|
|
121
|
-
onNonEmpty: (all) => Console.log(pipe(all, Array.map(format), Array.join("\n")))
|
|
122
|
-
});
|
|
123
|
-
const readerIn = (root, failWith) => Effect.gen(function* reader() {
|
|
124
|
-
const fileSystem = yield* FileSystem.FileSystem;
|
|
125
|
-
const path = yield* Path.Path;
|
|
126
|
-
return (file) => fileSystem.readFile(path.resolve(root, file)).pipe(Effect.mapError(failWith(`could not read ${file}`)), Effect.flatMap((bytes) => Effect.try({
|
|
127
|
-
try: () => STRICT_UTF8.decode(bytes),
|
|
128
|
-
catch: () => NotUtf8Error.make({ path: file })
|
|
129
|
-
})));
|
|
130
|
-
});
|
|
131
|
-
const mainOf = (cli, patterns) => Effect.gen(function* main() {
|
|
132
|
-
const root = process.cwd();
|
|
133
|
-
const config = yield* readSectionIn(cli, root);
|
|
134
|
-
const pathspecs = cli.pathspecs(requestOf(config, patterns));
|
|
135
|
-
const { files, projectFiles } = yield* Effect.all({
|
|
136
|
-
files: trackedFiles(root, pathspecs).pipe(Effect.withSpan(`${cli.name}.files`)),
|
|
137
|
-
projectFiles: trackedFiles(root, []).pipe(Effect.withSpan(`${cli.name}.project`))
|
|
138
|
-
}, { concurrency: "unbounded" });
|
|
139
|
-
const read = yield* readerIn(root, cli.failWith);
|
|
140
|
-
const found = yield* cli.lint({
|
|
141
|
-
root,
|
|
142
|
-
files,
|
|
143
|
-
projectFiles,
|
|
144
|
-
config,
|
|
145
|
-
read
|
|
146
|
-
});
|
|
147
|
-
yield* printAll(found, cli.format);
|
|
148
|
-
yield* failWhen(hasError(found));
|
|
149
|
-
});
|
|
150
|
-
const variadicOf = ({ name, description }) => Argument.String(name).pipe(Argument.withDescription(description), Argument.variadic());
|
|
151
|
-
const pathspecArgument = () => variadicOf({
|
|
152
|
-
name: "pathspec",
|
|
153
|
-
description: "Git pathspecs of the files to lint, in place of the configured ones"
|
|
154
|
-
});
|
|
155
|
-
const runCli = (cli) => {
|
|
156
|
-
const command = Command.make(cli.name, { pathspecs: pathspecArgument() }, ({ pathspecs }) => mainOf(cli, pathspecs)).pipe(Command.withDescription(cli.description));
|
|
157
|
-
runMain(cli.name)(Command.run(command, { version: cli.version }));
|
|
158
|
-
};
|
|
159
31
|
const present = Function.dual(2, (value, build) => Option.match(value, {
|
|
160
32
|
onNone: () => ({}),
|
|
161
33
|
onSome: build
|
|
@@ -414,6 +286,6 @@ const i68Section = sectionOf({
|
|
|
414
286
|
fallback: {}
|
|
415
287
|
});
|
|
416
288
|
const songPathspecs = pathspecsOf({ defaults: ["*.fumx"] });
|
|
417
|
-
export { I68Error as a,
|
|
289
|
+
export { I68Error as a, NotUtf8Error as c, lintText as i, songPathspecs as n, failedWith as o, lint as r, formatDiagnostic as s, i68Section as t };
|
|
418
290
|
|
|
419
|
-
//# sourceMappingURL=section-
|
|
291
|
+
//# sourceMappingURL=section-KjxJ8PF-.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"section-KjxJ8PF-.mjs","names":["Arr","Rec","taggedError","Fn","LINE_START","Bool","Arr","Arr","Rec","Arr","Fn","Arr","Arr","SEPARATOR","Str","rulesOf","Rec","Arr","Str","rulesOf","Arr","Arr","Arr"],"sources":["../../lint-host/src/entities/rule/model/setting.ts","../../lint-host/src/entities/rule/model/severity.ts","../../lint-host/src/shared/lib/fail.ts","../../lint-host/src/shared/lib/present.ts","../../lint-host/src/shared/lib/trace.ts","../../lint-host/src/shared/lib/layers.ts","../../lint-host/src/shared/lib/diagnostic.ts","../../lint-host/src/shared/lib/section.ts","../src/entities/rule/model/extend.ts","../src/entities/rule/model/resolve.ts","../src/features/read-songs/model/read.ts","../src/shared/lib/errors.ts","../src/features/run-rules/model/suppressions.ts","../src/features/run-rules/model/run.ts","../src/app/lint.ts","../src/app/section.ts"],"sourcesContent":["import { Array as Arr, Match, Option, Record as Rec, pipe } from \"effect\";\n\nexport type Severity = \"off\" | \"warn\" | \"error\";\n\nexport type RuleOptions = Readonly<Record<string, unknown>>;\n\nexport type RuleEntry = Severity | readonly [Severity] | readonly [Severity, RuleOptions];\n\nexport interface Setting {\n readonly severity: Severity;\n readonly options: RuleOptions;\n}\n\nconst NO_OPTIONS: RuleOptions = {};\n\nexport const settingOf = (entry: RuleEntry): Setting =>\n Match.value(entry).pipe(\n Match.when(Match.string, (severity): Setting => ({ severity, options: NO_OPTIONS })),\n Match.orElse(([severity, options]): Setting => ({\n severity,\n options: options ?? NO_OPTIONS,\n })),\n );\n\nconst optionsOf = (entry: RuleEntry): Option.Option<RuleOptions> =>\n Match.value(entry).pipe(\n Match.when(Match.string, () => Option.none()),\n Match.orElse(([, options]) => Option.fromUndefinedOr(options)),\n );\n\nconst overridden = (earlier: RuleEntry, later: RuleEntry): RuleEntry =>\n pipe(\n optionsOf(later),\n Option.orElse(() => optionsOf(earlier)),\n Option.match({\n onNone: () => later,\n onSome: (options): RuleEntry => [settingOf(later).severity, options],\n }),\n );\n\nexport const mergedRules = (\n layers: readonly (Readonly<Record<string, RuleEntry>> | undefined)[],\n): Readonly<Record<string, RuleEntry>> => {\n const merged: Record<string, RuleEntry> = {};\n for (const [name, later] of pipe(\n layers,\n Arr.flatMap((layer) => Rec.toEntries(layer ?? {})),\n )) {\n merged[name] = pipe(\n Rec.get(merged, name),\n Option.match({\n onNone: () => later,\n onSome: (earlier) => overridden(earlier, later),\n }),\n );\n }\n return merged;\n};\n","import { Match } from \"effect\";\n\nimport type { Setting, Severity } from \"./setting.ts\";\n\nexport const reportedSeverity = (setting: Setting): Exclude<Severity, \"off\"> =>\n Match.value(setting.severity).pipe(\n Match.when(\"warn\", (): Exclude<Severity, \"off\"> => \"warn\"),\n Match.orElse((): Exclude<Severity, \"off\"> => \"error\"),\n );\n","import { Schema } from \"effect\";\n\nconst taggedError = Schema.TaggedError;\n\nexport class NotUtf8Error extends taggedError<NotUtf8Error, { readonly brand: unique symbol }>()(\n \"NotUtf8Error\",\n { path: Schema.String },\n) {}\n\nexport type FailWith<Failure> = (message: string) => (cause: unknown) => Failure;\n","import { Function as Fn, Option } from \"effect\";\n\nconst DATA_FIRST_ARITY = 2;\n\nexport const present: {\n <Value, Fields extends object>(\n build: (value: Value) => Fields,\n ): (value: Option.Option<Value>) => Partial<Fields>;\n <Value, Fields extends object>(\n value: Option.Option<Value>,\n build: (value: Value) => Fields,\n ): Partial<Fields>;\n} = Fn.dual(\n DATA_FIRST_ARITY,\n <Value, Fields extends object>(\n value: Option.Option<Value>,\n build: (value: Value) => Fields,\n ): Partial<Fields> => Option.match(value, { onNone: (): Partial<Fields> => ({}), onSome: build }),\n);\n","import { Array as Arr, Boolean as Bool, Effect, Order } from \"effect\";\nimport type { Option } from \"effect\";\n\nconst SAMPLED = \"01\";\nconst NOT_SAMPLED = \"00\";\n\nexport interface Positioned {\n readonly path: string;\n readonly line: number;\n readonly column?: number;\n}\n\nconst LINE_START = 0;\n\nconst flagsOf = (sampled: boolean): string =>\n Bool.match(sampled, { onFalse: () => NOT_SAMPLED, onTrue: () => SAMPLED });\n\nexport const traceparent: Effect.Effect<Option.Option<string>> = Effect.currentSpan.pipe(\n Effect.map((span) => `00-${span.traceId}-${span.spanId}-${flagsOf(span.sampled)}`),\n Effect.option,\n);\n\nconst byPosition: Order.Order<Positioned> = Order.combine(\n Order.mapInput(Order.String, (found: Positioned) => found.path),\n Order.combine(\n Order.mapInput(Order.Number, (found: Positioned) => found.line),\n Order.mapInput(Order.Number, (found: Positioned) => found.column ?? LINE_START),\n ),\n);\n\nexport const sortByPosition = <Found extends Positioned>(found: readonly Found[]): Found[] =>\n Arr.sort(found, byPosition);\n","import { Array as Arr, Record as Rec, pipe } from \"effect\";\n\nexport interface Layer<Plugin, Entry, Override> {\n readonly plugins?: Readonly<Record<string, Plugin>>;\n readonly rules?: Readonly<Record<string, Entry>>;\n readonly ignores?: readonly string[];\n readonly overrides?: readonly Override[];\n}\n\nexport interface Merged<Plugin, Entry, Override> {\n readonly plugins: Readonly<Record<string, Plugin>>;\n readonly rules: Readonly<Record<string, Entry>>;\n readonly ignores: readonly string[];\n readonly overrides: readonly Override[];\n}\n\nexport const mergedRecords = <Value>(\n records: readonly (Readonly<Record<string, Value>> | undefined)[],\n): Readonly<Record<string, Value>> =>\n pipe(\n records,\n Arr.flatMap((record) => Rec.toEntries(record ?? {})),\n Rec.fromEntries,\n );\n\nexport const layersOf = <Config extends { readonly extends?: readonly Config[] }>(\n config: Config,\n): readonly Omit<Config, \"extends\">[] => {\n const { extends: bases = [], ...own } = config;\n return [...pipe(bases, Arr.flatMap(layersOf)), own];\n};\n\nexport const mergedLayers = <Plugin, Entry, Override>(\n layers: readonly Layer<Plugin, Entry, Override>[],\n): Merged<Plugin, Entry, Override> => ({\n plugins: mergedRecords(\n pipe(\n layers,\n Arr.map((layer) => layer.plugins),\n ),\n ),\n rules: mergedRecords(\n pipe(\n layers,\n Arr.map((layer) => layer.rules),\n ),\n ),\n ignores: pipe(\n layers,\n Arr.flatMap((layer) => layer.ignores ?? []),\n ),\n overrides: pipe(\n layers,\n Arr.flatMap((layer) => layer.overrides ?? []),\n ),\n});\n","import { Array as Arr, Option, pipe } from \"effect\";\n\nexport interface Reportable {\n readonly path: string;\n readonly line: number;\n readonly column?: number | undefined;\n readonly rule: string;\n readonly message: string;\n readonly detail?: string | undefined;\n readonly context?: string | undefined;\n readonly severity: string;\n}\n\nexport const diagnosticDetail = (diagnostic: Reportable): string =>\n pipe(\n [diagnostic.detail, diagnostic.context],\n Arr.flatMap((part) => Option.toArray(Option.fromNullishOr(part))),\n Arr.filter((part) => part !== \"\"),\n Arr.map((part) => ` [${part}]`),\n Arr.join(\"\"),\n );\n\nexport const formatDiagnostic = (diagnostic: Reportable): string => {\n const column = pipe(\n Option.fromNullishOr(diagnostic.column),\n Option.map((value) => `:${String(value)}`),\n Option.getOrElse(() => \"\"),\n );\n return `${diagnostic.path}:${String(diagnostic.line)}${column} ${diagnostic.severity} ${diagnostic.rule} ${diagnostic.message}${diagnosticDetail(diagnostic)}`;\n};\n\nexport interface NotUtf8 {\n readonly path: string;\n readonly line: number;\n readonly column: number;\n readonly rule: string;\n readonly message: string;\n readonly severity: \"error\";\n}\n\nexport const notUtf8 =\n (tool: string) =>\n (path: string): NotUtf8 => ({\n path,\n line: 1,\n column: 1,\n rule: \"utf8\",\n message: `The file is not valid UTF-8, so ${tool} cannot read it`,\n severity: \"error\",\n });\n","import { Array as Arr, Function as Fn, Option, Predicate, pipe } from \"effect\";\n\nexport interface SectionRequest<Config extends object> {\n readonly name: string;\n readonly fallback: Config;\n readonly prepare?: (section: Config) => Config;\n}\n\nexport const sectionOf = <Config extends object>({\n name,\n fallback,\n prepare = Fn.identity,\n}: SectionRequest<Config>): ((config: unknown) => Config) => {\n const hasSection = (value: unknown): value is Readonly<Record<string, Config>> =>\n Predicate.hasProperty(value, name) && Predicate.isObject(value[name]);\n return (config) =>\n pipe(\n Option.liftPredicate(config, hasSection),\n Option.flatMapNullishOr((value) => value[name]),\n Option.map(prepare),\n Option.getOrElse(() => fallback),\n );\n};\n\nexport interface Ignoring {\n readonly ignores?: readonly string[] | undefined;\n}\n\nexport interface Pathspecs {\n readonly defaults: readonly string[];\n readonly unowned?: readonly string[];\n}\n\nexport const pathspecsOf =\n ({ defaults, unowned = [] }: Pathspecs) =>\n ({\n config,\n patterns = [],\n }: {\n readonly config: Ignoring;\n readonly patterns?: readonly string[];\n }): readonly string[] => [\n ...Arr.match(patterns, { onEmpty: () => defaults, onNonEmpty: Fn.identity }),\n ...unowned,\n ...pipe(\n config.ignores ?? [],\n Arr.map((glob) => `:(glob,exclude)${glob}`),\n ),\n ];\n","import { layersOf, mergedLayers, mergedRules } from \"@masseater.dev/lint-host\";\nimport { Array as Arr, pipe } from \"effect\";\n\nimport type { I68Config } from \"#/shared/config/index.ts\";\n\nexport const flattenConfig = (config: I68Config): I68Config => {\n const layers = layersOf(config);\n const { plugins, ignores } = mergedLayers(layers);\n const rules = mergedRules(\n pipe(\n layers,\n Arr.map((layer) => layer.rules),\n ),\n );\n return { plugins, rules, ignores };\n};\n","import { settingOf } from \"@masseater.dev/lint-host\";\nimport type { Setting } from \"@masseater.dev/lint-host\";\nimport { Array as Arr, Option, Record as Rec, String as Str, pipe } from \"effect\";\n\nimport type { I68Config, Plugin, Rule } from \"#/shared/config/index.ts\";\n\nconst SEPARATOR = \"/\";\nconst START = 0;\nconst ENABLED: Setting = settingOf(\"error\");\n\nexport interface ResolvedRule {\n readonly id: string;\n readonly rule: Rule;\n readonly setting: Setting;\n}\n\ntype PluginEntry = readonly [string, Plugin];\n\nconst idOf = (plugin: string, name: string): string => `${plugin}${SEPARATOR}${name}`;\n\nconst pluginOf = (id: string): string =>\n pipe(\n Str.indexOf(SEPARATOR)(id),\n Option.match({\n onNone: () => id,\n onSome: (slash) => Str.slice(START, slash)(id),\n }),\n );\n\nconst rulesOf =\n (config: I68Config) =>\n ([plugin, value]: PluginEntry): readonly ResolvedRule[] =>\n pipe(\n Rec.toEntries(value.rules),\n Arr.map(([name, rule]): ResolvedRule => {\n const id = idOf(plugin, name);\n return {\n id,\n rule,\n setting: pipe(\n config.rules ?? {},\n Rec.get(id),\n Option.map(settingOf),\n Option.getOrElse(() => ENABLED),\n ),\n };\n }),\n Arr.filter(({ setting }) => setting.severity !== \"off\"),\n );\n\nexport const resolve = (config: I68Config): readonly ResolvedRule[] =>\n pipe(Rec.toEntries(config.plugins ?? {}), Arr.flatMap(rulesOf(config)));\n\nexport const unknownPlugins = (config: I68Config): readonly string[] =>\n pipe(\n Rec.keys(config.rules ?? {}),\n Arr.map(pluginOf),\n Arr.filter((plugin) => !Rec.has(config.plugins ?? {}, plugin)),\n Arr.dedupe,\n );\n\nconst ruleNameOf = (id: string): string =>\n pipe(\n Str.indexOf(SEPARATOR)(id),\n Option.match({\n onNone: () => \"\",\n onSome: (slash) => Str.slice(slash + SEPARATOR.length)(id),\n }),\n );\n\nconst isKnownRule =\n (config: I68Config) =>\n (id: string): boolean =>\n pipe(\n Rec.get(config.plugins ?? {}, pluginOf(id)),\n Option.match({\n onNone: () => true,\n onSome: (plugin) => Rec.has(plugin.rules, ruleNameOf(id)),\n }),\n );\n\nexport const unknownRules = (config: I68Config): readonly string[] =>\n pipe(\n Rec.keys(config.rules ?? {}),\n Arr.filter((id) => !isKnownRule(config)(id)),\n );\n","import type { NotUtf8Error } from \"@masseater.dev/lint-host\";\nimport { readSong } from \"@r_masseater/song-format\";\nimport type { SongSource } from \"@r_masseater/song-format\";\nimport { Effect } from \"effect\";\n\nimport type { I68Error } from \"#/shared/lib/errors.ts\";\n\nconst SEPARATOR = \"/\";\n\nexport interface SongFile {\n readonly file: string;\n readonly source: SongSource;\n}\n\nexport type Read = (path: string) => Effect.Effect<string, I68Error | NotUtf8Error>;\n\nexport interface ReadInput {\n readonly root: string;\n readonly file: string;\n readonly read: Read;\n}\n\nexport const pathOf = (input: Omit<ReadInput, \"read\">): string =>\n `${input.root}${SEPARATOR}${input.file}`;\n\nexport const readSongFile = Effect.fn(\"i68.read\")(function* readSongFile(input: ReadInput) {\n const source = yield* readSong({ path: pathOf(input), read: input.read });\n return { file: input.file, source } satisfies SongFile;\n});\n","import { Schema } from \"effect\";\n\nconst taggedError = Schema.TaggedError;\n\nexport class I68Error extends taggedError<I68Error, { readonly brand: unique symbol }>()(\n \"I68Error\",\n { message: Schema.String },\n) {}\n\nexport const failedWith =\n (message: string) =>\n (cause: unknown): I68Error =>\n I68Error.make({ message: `${message}: ${String(cause)}` });\n","import type { SourceComment } from \"@r_masseater/song-format\";\nimport { Array as Arr, Match, Option, String as Str, pipe } from \"effect\";\n\nconst DIRECTIVE =\n /^i68-(?<kind>ignore-next-line|ignore-file|ignore|disable|enable)(?:\\s(?<rest>[\\s\\S]*))?$/u;\nconst REASON = /\\s-{2,}(?:\\s|$)/u;\nconst LINE_MARK = \"//\";\nconst BLOCK_START = \"/*\";\nconst BLOCK_END = \"*/\";\nconst LIST = \",\";\nconst NEXT = 1;\nconst LINE_START = 0;\n\ntype Kind = \"ignore\" | \"ignore-next-line\" | \"ignore-file\" | \"disable\" | \"enable\";\n\ninterface Directive {\n readonly line: number;\n readonly column: number;\n readonly kind: Kind;\n readonly rules: readonly string[];\n}\n\nexport interface Suppressed {\n readonly line: number;\n readonly column?: number;\n readonly rule: string;\n}\n\nconst kindOf = (text: string): Kind =>\n Match.value(text).pipe(\n Match.when(\"ignore-file\", (): Kind => \"ignore-file\"),\n Match.when(\"ignore-next-line\", (): Kind => \"ignore-next-line\"),\n Match.when(\"disable\", (): Kind => \"disable\"),\n Match.when(\"enable\", (): Kind => \"enable\"),\n Match.orElse((): Kind => \"ignore\"),\n );\n\nconst bodyOf = (text: string): string => {\n if (Str.startsWith(BLOCK_START)(text)) {\n return pipe(text, Str.slice(BLOCK_START.length), Str.replace(BLOCK_END, \"\"), Str.trim);\n }\n return pipe(text, Str.slice(LINE_MARK.length), Str.trim);\n};\n\nconst rulesOf = (rest: string): readonly string[] =>\n pipe(\n Str.split(` ${rest}`, REASON),\n Arr.head,\n Option.getOrElse(() => \"\"),\n Str.split(LIST),\n Arr.map(Str.trim),\n Arr.filter(Str.isNonEmpty),\n );\n\nconst groupsOf = (text: string): Option.Option<Partial<Record<string, string>>> =>\n pipe(\n Option.fromNullishOr(DIRECTIVE.exec(text)),\n Option.flatMap((found) => Option.fromNullishOr(found.groups)),\n );\n\nconst directiveOf = (comment: SourceComment): Option.Option<Directive> =>\n pipe(\n groupsOf(bodyOf(comment.text)),\n Option.map((groups) => ({\n line: comment.line,\n column: comment.column,\n kind: kindOf(groups[\"kind\"] ?? \"\"),\n rules: rulesOf(groups[\"rest\"] ?? \"\"),\n })),\n );\n\nconst names =\n (rule: string) =>\n (directive: Directive): boolean =>\n !Arr.isReadonlyArrayNonEmpty(directive.rules) || Arr.contains(directive.rules, rule);\n\nconst isRange = (directive: Directive): boolean =>\n directive.kind === \"disable\" || directive.kind === \"enable\";\n\nconst coversLine =\n (found: Suppressed) =>\n (directive: Directive): boolean =>\n names(found.rule)(directive) &&\n Match.value(directive.kind).pipe(\n Match.when(\"ignore-file\", () => true),\n Match.when(\"ignore-next-line\", () => directive.line + NEXT === found.line),\n Match.when(\"ignore\", () => directive.line === found.line),\n Match.orElse(() => false),\n );\n\nconst isAfter =\n (found: Suppressed) =>\n (directive: Directive): boolean =>\n directive.line < found.line ||\n (directive.line === found.line && directive.column <= (found.column ?? LINE_START));\n\nconst insideRange =\n (directives: readonly Directive[]) =>\n (found: Suppressed): boolean =>\n pipe(\n directives,\n Arr.filter(\n (directive) =>\n isRange(directive) && isAfter(found)(directive) && names(found.rule)(directive),\n ),\n Arr.last,\n Option.exists((directive) => directive.kind === \"disable\"),\n );\n\nexport const suppressionsOf = (\n comments: readonly SourceComment[],\n): ((found: Suppressed) => boolean) => {\n const directives = pipe(comments, Arr.map(directiveOf), Arr.getSomes);\n return (found) => pipe(directives, Arr.some(coversLine(found))) || insideRange(directives)(found);\n};\n","import { present, reportedSeverity } from \"@masseater.dev/lint-host\";\nimport type { Song, SourceComment } from \"@r_masseater/song-format\";\nimport { soundingsOf } from \"@r_masseater/song-format/analysis\";\nimport type { Sounding } from \"@r_masseater/song-format/analysis\";\nimport { Array as Arr, Effect, Option, pipe } from \"effect\";\n\nimport type { ResolvedRule } from \"#/entities/rule/index.ts\";\nimport type { Diagnostic, Report } from \"#/shared/config/index.ts\";\nimport { failedWith } from \"#/shared/lib/errors.ts\";\nimport type { I68Error } from \"#/shared/lib/errors.ts\";\n\nimport { suppressionsOf } from \"./suppressions.ts\";\n\nexport interface RunInput {\n readonly path: string;\n readonly comments: readonly SourceComment[];\n readonly song: Song;\n readonly rules: readonly ResolvedRule[];\n}\n\nconst diagnosticOf =\n (path: string, rule: ResolvedRule) =>\n (report: Report): Diagnostic => ({\n path,\n line: report.line,\n rule: rule.id,\n message: report.message,\n severity: reportedSeverity(rule.setting),\n ...present(Option.fromNullishOr(report.column), (column) => ({ column })),\n ...present(Option.fromNullishOr(report.detail), (detail) => ({ detail })),\n });\n\nconst runOne = (\n input: RunInput,\n soundings: readonly Sounding[],\n): ((rule: ResolvedRule) => Effect.Effect<readonly Diagnostic[], I68Error>) =>\n Effect.fn(\"i68.rule\")(function* run(rule: ResolvedRule) {\n yield* Effect.annotateCurrentSpan({ \"i68.rule\": rule.id });\n const reports: Report[] = [];\n yield* Effect.try({\n try: () => {\n rule.rule.check({\n filename: input.path,\n song: input.song,\n soundings,\n options: rule.setting.options,\n report: (report) => {\n reports.push(report);\n },\n });\n },\n catch: failedWith(`${rule.id} failed`),\n });\n return pipe(reports, Arr.map(diagnosticOf(input.path, rule)));\n });\n\nexport const runRules = Effect.fn(\"i68.rules\")(function* runRules(input: RunInput) {\n const soundings = soundingsOf(input.song);\n const suppressed = suppressionsOf(input.comments);\n const found = yield* pipe(\n input.rules,\n Effect.forEach(runOne(input, soundings), { concurrency: 1 }),\n );\n return pipe(\n Arr.flatten(found),\n Arr.filter((diagnostic) => !suppressed(diagnostic)),\n );\n});\n","import { NotUtf8Error, notUtf8, sortByPosition } from \"@masseater.dev/lint-host\";\nimport { readSong } from \"@r_masseater/song-format\";\nimport type { SourceIssue } from \"@r_masseater/song-format\";\nimport { Array as Arr, Effect, Result, Schema, pipe } from \"effect\";\n\nimport { flattenConfig, resolve, unknownPlugins, unknownRules } from \"#/entities/rule/index.ts\";\nimport type { ResolvedRule } from \"#/entities/rule/index.ts\";\nimport { pathOf, readSongFile } from \"#/features/read-songs/index.ts\";\nimport type { Read, SongFile } from \"#/features/read-songs/index.ts\";\nimport { runRules } from \"#/features/run-rules/index.ts\";\nimport type { Diagnostic, I68Config } from \"#/shared/config/index.ts\";\nimport { I68Error } from \"#/shared/lib/errors.ts\";\n\nconst PARSE_RULE = \"i68/parse\";\n\nexport interface LintInput {\n readonly root: string;\n readonly files: readonly string[];\n readonly read: Read;\n readonly config?: I68Config;\n}\n\nexport interface TextInput {\n readonly path: string;\n readonly text: string;\n readonly read?: Read;\n readonly config?: I68Config;\n}\n\nconst failIfAny =\n (problem: string) =>\n (names: readonly string[]): Effect.Effect<void, I68Error> =>\n Arr.match(names, {\n onEmpty: () => Effect.void,\n onNonEmpty: (found) =>\n Effect.fail(I68Error.make({ message: `${problem}: ${Arr.join(found, \", \")}` })),\n });\n\nconst UNKNOWN_PLUGINS = failIfAny(\"rules name plugins that are not configured\");\nconst UNKNOWN_RULES = failIfAny(\"rules name rules that their plugins do not have\");\n\nconst checkPlugins = (config: I68Config): Effect.Effect<void, I68Error> => {\n const rules = UNKNOWN_RULES(unknownRules(config));\n return UNKNOWN_PLUGINS(unknownPlugins(config)).pipe(Effect.andThen(rules));\n};\n\nconst rulesOf = (\n config: I68Config | undefined,\n): Effect.Effect<readonly ResolvedRule[], I68Error> => {\n const flat = flattenConfig(config ?? {});\n return checkPlugins(flat).pipe(Effect.as(resolve(flat)));\n};\n\nconst parseDiagnosticsOf =\n (file: string) =>\n (issues: readonly SourceIssue[]): readonly Diagnostic[] =>\n pipe(\n issues,\n Arr.map((issue): Diagnostic => ({\n path: file,\n line: issue.line,\n column: issue.column,\n rule: PARSE_RULE,\n message: issue.message,\n severity: \"error\",\n })),\n );\n\nconst lintFile =\n (rules: readonly ResolvedRule[]) =>\n (song: SongFile): Effect.Effect<readonly Diagnostic[], I68Error> => {\n if (song.source.status === \"invalid\") {\n return Effect.succeed(parseDiagnosticsOf(song.file)(song.source.issues));\n }\n return runRules({\n path: song.file,\n comments: song.source.outline.comments,\n song: song.source.song,\n rules,\n });\n };\n\nconst notFound = (path: string): Effect.Effect<string, I68Error> =>\n Effect.fail(I68Error.make({ message: `could not read ${path}` }));\n\nconst readerOf =\n (input: TextInput): Read =>\n (path) => {\n if (path === input.path) {\n return Effect.succeed(input.text);\n }\n return (input.read ?? notFound)(path);\n };\n\nconst lintTracked = (\n rules: readonly ResolvedRule[],\n input: LintInput,\n): ((file: string) => Effect.Effect<readonly Diagnostic[], I68Error>) =>\n Effect.fnUntraced(function* lintOne(\n file: string,\n ): Effect.fn.Return<readonly Diagnostic[], I68Error> {\n const path = pathOf({ root: input.root, file });\n const read = yield* Effect.result(input.read(path));\n if (Result.isFailure(read) && Schema.is(NotUtf8Error)(read.failure)) {\n return [notUtf8(\"i68\")(file)];\n }\n const reader = Result.match(read, {\n onFailure: () => input.read,\n onSuccess: (text): Read => readerOf({ path, text, read: input.read }),\n });\n const source = yield* readSongFile({ root: input.root, file, read: reader });\n return yield* lintFile(rules)(source);\n });\n\nexport const lint = Effect.fn(\"i68.lint\")(function* lint(input: LintInput) {\n const rules = yield* rulesOf(input.config);\n const found = yield* Effect.forEach(input.files, lintTracked(rules, input), {\n concurrency: \"unbounded\",\n });\n return sortByPosition<Diagnostic>(Arr.flatten(found));\n});\n\nexport const lintText = Effect.fn(\"i68.lintText\")(function* lintText(input: TextInput) {\n const rules = yield* rulesOf(input.config);\n const source = yield* readSong({ path: input.path, read: readerOf(input) });\n const found = yield* lintFile(rules)({ file: input.path, source });\n return sortByPosition<Diagnostic>(found);\n});\n","import { pathspecsOf, sectionOf } from \"@masseater.dev/lint-host\";\nimport type { PathspecRequest } from \"@masseater.dev/lint-host\";\n\nimport { flattenConfig } from \"#/entities/rule/index.ts\";\nimport type { I68Config } from \"#/shared/config/index.ts\";\n\nexport type PathspecInput = PathspecRequest<I68Config>;\n\nexport const i68Section = sectionOf<I68Config>({\n name: \"i68\",\n prepare: flattenConfig,\n fallback: {},\n});\n\nexport const songPathspecs = pathspecsOf({ defaults: [\"*.fumx\"] });\n"],"mappings":";;;;AAaA,MAAM,aAA0B,CAAC;AAEjC,MAAa,aAAa,UACxB,MAAM,MAAM,KAAK,CAAC,CAAC,KACjB,MAAM,KAAK,MAAM,SAAS,cAAuB;CAAE;CAAU,SAAS;AAAW,EAAE,GACnF,MAAM,QAAQ,CAAC,UAAU,cAAuB;CAC9C;CACA,SAAS,WAAW;AACtB,EAAE,CACJ;AAEF,MAAM,aAAa,UACjB,MAAM,MAAM,KAAK,CAAC,CAAC,KACjB,MAAM,KAAK,MAAM,cAAc,OAAO,KAAK,CAAC,GAC5C,MAAM,QAAQ,GAAG,aAAa,OAAO,gBAAgB,OAAO,CAAC,CAC/D;AAEF,MAAM,cAAc,SAAoB,UACtC,KACE,UAAU,KAAK,GACf,OAAO,aAAa,UAAU,OAAO,CAAC,GACtC,OAAO,MAAM;CACX,cAAc;CACd,SAAS,YAAuB,CAAC,UAAU,KAAK,CAAC,CAAC,UAAU,OAAO;AACrE,CAAC,CACH;AAEF,MAAa,eACX,WACwC;CACxC,MAAM,SAAoC,CAAC;CAC3C,KAAK,MAAM,CAAC,MAAM,UAAU,KAC1B,QACAA,MAAI,SAAS,UAAUC,OAAI,UAAU,SAAS,CAAC,CAAC,CAAC,CACnD,GACE,OAAO,QAAQ,KACbA,OAAI,IAAI,QAAQ,IAAI,GACpB,OAAO,MAAM;EACX,cAAc;EACd,SAAS,YAAY,WAAW,SAAS,KAAK;CAChD,CAAC,CACH;CAEF,OAAO;AACT;;ACrDA,MAAa,oBAAoB,YAC/B,MAAM,MAAM,QAAQ,QAAQ,CAAC,CAAC,KAC5B,MAAM,KAAK,cAAwC,MAAM,GACzD,MAAM,aAAuC,OAAO,CACtD;;ACNF,M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QAAQ,OAAO,QAAQ,MAAM,MAAM;CACzC,MAAM,QAAQ,OAAO,OAAO,QAAQ,MAAM,OAAO,YAAY,OAAO,KAAK,GAAG,EAC1E,aAAa,YACf,CAAC;CACD,OAAO,eAA2BA,MAAI,QAAQ,KAAK,CAAC;AACtD,CAAC;AAED,MAAa,WAAW,OAAO,GAAG,cAAc,CAAC,CAAC,UAAU,SAAS,OAAkB;CACrF,MAAM,QAAQ,OAAO,QAAQ,MAAM,MAAM;CACzC,MAAM,SAAS,OAAO,SAAS;EAAE,MAAM,MAAM;EAAM,MAAM,SAAS,KAAK;CAAE,CAAC;CAC1E,MAAM,QAAQ,OAAO,SAAS,KAAK,CAAC,CAAC;EAAE,MAAM,MAAM;EAAM;CAAO,CAAC;CACjE,OAAO,eAA2B,KAAK;AACzC,CAAC;;ACvHD,MAAa,aAAa,UAAqB;CAC7C,MAAM;CACN,SAAS;CACT,UAAU,CAAC;AACb,CAAC;AAED,MAAa,gBAAgB,YAAY,EAAE,UAAU,CAAC,QAAQ,EAAE,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@r_masseater/i68",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.4",
|
|
4
4
|
"description": "A linter for .fumx songs that checks musical rules such as notes outside the key, part ranges, voicing clashes and parallel fifths, configured from vite.config.ts with rules written in TypeScript.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"fumx",
|
|
@@ -61,8 +61,8 @@
|
|
|
61
61
|
},
|
|
62
62
|
"dependencies": {
|
|
63
63
|
"@effect/platform-node": "^4.1.5",
|
|
64
|
-
"@r_masseater/node-main": "^0.2.
|
|
65
|
-
"@r_masseater/song-format": "^0.2.
|
|
64
|
+
"@r_masseater/node-main": "^0.2.1",
|
|
65
|
+
"@r_masseater/song-format": "^0.2.4"
|
|
66
66
|
},
|
|
67
67
|
"devDependencies": {
|
|
68
68
|
"@effect/vitest": "4.1.5",
|
|
@@ -70,14 +70,14 @@
|
|
|
70
70
|
"@r_masseater/vitest-otlp": "0.2.2",
|
|
71
71
|
"@types/node": "26.6.10",
|
|
72
72
|
"effect": "4.1.5",
|
|
73
|
-
"tonal": "6.
|
|
73
|
+
"tonal": "6.11.0",
|
|
74
74
|
"verovio": "6.4.1",
|
|
75
75
|
"vite": "npm:@voidzero-dev/vite-plus-core@8.3.8001",
|
|
76
76
|
"vite-plus": "1.8.0"
|
|
77
77
|
},
|
|
78
78
|
"peerDependencies": {
|
|
79
79
|
"effect": "^4.1.0",
|
|
80
|
-
"tonal": ">=6.
|
|
80
|
+
"tonal": ">=6.10.0",
|
|
81
81
|
"vite": "*",
|
|
82
82
|
"vite-plus": ">=1.8.0"
|
|
83
83
|
},
|
package/dist/cli-BsA_dteW.mjs
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { c as runCli$1, n as songPathspecs, o as failedWith, r as lint, s as formatDiagnostic, t as i68Section } from "./section-nUBg-T7E.mjs";
|
|
2
|
-
// package.json
|
|
3
|
-
var version = "0.2.2";
|
|
4
|
-
var description = "A linter for .fumx songs that checks musical rules such as notes outside the key, part ranges, voicing clashes and parallel fifths, configured from vite.config.ts with rules written in TypeScript.";
|
|
5
|
-
// src/app/cli.ts
|
|
6
|
-
const runCli = () => {
|
|
7
|
-
runCli$1({
|
|
8
|
-
name: "i68",
|
|
9
|
-
version,
|
|
10
|
-
description,
|
|
11
|
-
section: i68Section,
|
|
12
|
-
pathspecs: songPathspecs,
|
|
13
|
-
lint,
|
|
14
|
-
format: formatDiagnostic,
|
|
15
|
-
failWith: failedWith
|
|
16
|
-
});
|
|
17
|
-
};
|
|
18
|
-
export { runCli };
|
|
19
|
-
|
|
20
|
-
//# sourceMappingURL=cli-BsA_dteW.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cli-BsA_dteW.mjs","names":["manifest.version","manifest.description"],"sources":["../package.json","../src/app/cli.ts"],"sourcesContent":["","import { formatDiagnostic, runCli as runLinter } from \"@masseater.dev/lint-host\";\nimport manifest from \"@r_masseater/i68/package.json\" with { type: \"json\" };\n\nimport { failedWith } from \"#/shared/lib/errors.ts\";\n\nimport { lint } from \"./lint.ts\";\nimport { i68Section, songPathspecs } from \"./section.ts\";\n\nexport const runCli = (): void => {\n runLinter({\n name: \"i68\",\n version: manifest.version,\n description: manifest.description,\n section: i68Section,\n pathspecs: songPathspecs,\n lint,\n format: formatDiagnostic,\n failWith: failedWith,\n });\n};\n"],"mappings":";;;;;ACQA,MAAa,eAAqB;CAChC,SAAU;EACR,MAAM;EACGA;EACIC;EACb,SAAS;EACT,WAAW;EACX;EACA,QAAQ;EACR,UAAU;CACZ,CAAC;AACH"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"section-nUBg-T7E.mjs","names":["Arr","Rec","taggedError","Rec","Str","taggedError","DATA_FIRST_ARITY","Arr","Fn","Str","Fn","LINE_START","Bool","Arr","Arr","Rec","Arr","Fn","Arr","Arr","SEPARATOR","Str","rulesOf","Rec","Arr","Str","rulesOf","Arr","Arr","Arr"],"sources":["../../lint-host/src/entities/rule/model/setting.ts","../../lint-host/src/entities/rule/model/severity.ts","../../lint-host/src/shared/lib/target.ts","../../lint-host/src/features/build-addon/model/build.ts","../../lint-host/src/shared/lib/fail.ts","../../lint-host/src/features/run-cli/model/cli.ts","../../lint-host/src/shared/lib/present.ts","../../lint-host/src/shared/lib/trace.ts","../../lint-host/src/shared/lib/layers.ts","../../lint-host/src/shared/lib/diagnostic.ts","../../lint-host/src/shared/lib/section.ts","../src/entities/rule/model/extend.ts","../src/entities/rule/model/resolve.ts","../src/features/read-songs/model/read.ts","../src/shared/lib/errors.ts","../src/features/run-rules/model/suppressions.ts","../src/features/run-rules/model/run.ts","../src/app/lint.ts","../src/app/section.ts"],"sourcesContent":["import { Array as Arr, Match, Option, Record as Rec, pipe } from \"effect\";\n\nexport type Severity = \"off\" | \"warn\" | \"error\";\n\nexport type RuleOptions = Readonly<Record<string, unknown>>;\n\nexport type RuleEntry = Severity | readonly [Severity] | readonly [Severity, RuleOptions];\n\nexport interface Setting {\n readonly severity: Severity;\n readonly options: RuleOptions;\n}\n\nconst NO_OPTIONS: RuleOptions = {};\n\nexport const settingOf = (entry: RuleEntry): Setting =>\n Match.value(entry).pipe(\n Match.when(Match.string, (severity): Setting => ({ severity, options: NO_OPTIONS })),\n Match.orElse(([severity, options]): Setting => ({\n severity,\n options: options ?? NO_OPTIONS,\n })),\n );\n\nconst optionsOf = (entry: RuleEntry): Option.Option<RuleOptions> =>\n Match.value(entry).pipe(\n Match.when(Match.string, () => Option.none()),\n Match.orElse(([, options]) => Option.fromUndefinedOr(options)),\n );\n\nconst overridden = (earlier: RuleEntry, later: RuleEntry): RuleEntry =>\n pipe(\n optionsOf(later),\n Option.orElse(() => optionsOf(earlier)),\n Option.match({\n onNone: () => later,\n onSome: (options): RuleEntry => [settingOf(later).severity, options],\n }),\n );\n\nexport const mergedRules = (\n layers: readonly (Readonly<Record<string, RuleEntry>> | undefined)[],\n): Readonly<Record<string, RuleEntry>> => {\n const merged: Record<string, RuleEntry> = {};\n for (const [name, later] of pipe(\n layers,\n Arr.flatMap((layer) => Rec.toEntries(layer ?? {})),\n )) {\n merged[name] = pipe(\n Rec.get(merged, name),\n Option.match({\n onNone: () => later,\n onSome: (earlier) => overridden(earlier, later),\n }),\n );\n }\n return merged;\n};\n","import { Match } from \"effect\";\n\nimport type { Setting, Severity } from \"./setting.ts\";\n\nexport const reportedSeverity = (setting: Setting): Exclude<Severity, \"off\"> =>\n Match.value(setting.severity).pipe(\n Match.when(\"warn\", (): Exclude<Severity, \"off\"> => \"warn\"),\n Match.orElse((): Exclude<Severity, \"off\"> => \"error\"),\n );\n","import { Match } from \"effect\";\n\nconst abiOf = (platform: string): string =>\n Match.value(platform).pipe(\n Match.when(\"linux\", () => \"-gnu\"),\n Match.when(\"win32\", () => \"-msvc\"),\n Match.orElse(() => \"\"),\n );\n\nexport const platformTarget = `${process.platform}-${process.arch}${abiOf(process.platform)}`;\n\nexport const addonFileOf = (binary: string): string => `${binary}.${platformTarget}.node`;\n","import { runMain } from \"@r_masseater/node-main\";\nimport { Effect, FileSystem, Path, Record as Rec, Schema, String as Str } from \"effect\";\nimport { ChildProcess, ChildProcessSpawner } from \"effect/process\";\n\nimport { addonFileOf } from \"#/shared/lib/target.ts\";\n\nconst taggedError = Schema.TaggedError;\n\nclass AddonBuildFailed extends taggedError<AddonBuildFailed, { readonly brand: unique symbol }>()(\n \"AddonBuildFailed\",\n { message: Schema.String },\n) {}\n\nconst LIBRARY: Readonly<Record<string, (name: string) => string>> = {\n linux: (name) => `lib${name}.so`,\n darwin: (name) => `lib${name}.dylib`,\n win32: (name) => `${name}.dll`,\n};\n\nconst SUCCESS = 0;\n\nexport interface AddonBuild {\n readonly crate: string;\n readonly binary: string;\n readonly packageDir: string;\n readonly workspaceDir: string;\n}\n\nconst cargo = Effect.fn(\"cargo\")(function* cargo(crate: string, workspace: string) {\n const spawner = yield* ChildProcessSpawner.ChildProcessSpawner;\n const exitCode = yield* spawner.exitCode(\n ChildProcess.make(\"cargo\", [\"build\", \"--release\", \"--locked\", \"-p\", crate], {\n cwd: workspace,\n stdout: \"inherit\",\n stderr: \"inherit\",\n }),\n );\n const failure = AddonBuildFailed.make({ message: `cargo exited with ${String(exitCode)}` });\n yield* Effect.when(\n Effect.fail(failure),\n Effect.sync(() => Number(exitCode) !== SUCCESS),\n );\n});\n\nconst build = Effect.fn(\"buildAddon\")(function* build(options: AddonBuild) {\n const fileSystem = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const library = yield* Effect.fromOption(Rec.get(LIBRARY, process.platform)).pipe(\n Effect.mapError(() =>\n AddonBuildFailed.make({ message: `no native build for ${process.platform}` }),\n ),\n );\n yield* cargo(options.crate, options.workspaceDir);\n const output = path.join(options.packageDir, \"native\");\n yield* fileSystem.makeDirectory(output, { recursive: true });\n const built = library(Str.replaceAll(\"-\", \"_\")(options.crate));\n yield* fileSystem.copyFile(\n path.join(options.workspaceDir, \"target\", \"release\", built),\n path.join(output, addonFileOf(options.binary)),\n );\n});\n\nexport const buildAddon = (options: AddonBuild): void => {\n runMain(`${options.binary}-build`)(build(options));\n};\n","import { Schema } from \"effect\";\n\nconst taggedError = Schema.TaggedError;\n\nexport class NotUtf8Error extends taggedError<NotUtf8Error, { readonly brand: unique symbol }>()(\n \"NotUtf8Error\",\n { path: Schema.String },\n) {}\n\nexport type FailWith<Failure> = (message: string) => (cause: unknown) => Failure;\n","import { runMain } from \"@r_masseater/node-main\";\nimport {\n Array as Arr,\n Console,\n Effect,\n FileSystem,\n Function as Fn,\n Option,\n Path,\n Record as Rec,\n String as Str,\n pipe,\n} from \"effect\";\nimport { Argument, Command, Flag } from \"effect/cli\";\nimport type { PlatformError } from \"effect/PlatformError\";\nimport { ChildProcess, ChildProcessSpawner } from \"effect/process\";\nimport { resolveConfigFromFile } from \"vite-plus\";\n\nimport { NotUtf8Error } from \"#/shared/lib/fail.ts\";\nimport type { FailWith } from \"#/shared/lib/fail.ts\";\n\nconst CONFIG_FILES = [\"vite.config.ts\", \"vite.config.mts\", \"vite.config.js\", \"vite.config.mjs\"];\nconst FAILED = 1;\nconst DATA_FIRST_ARITY = 2;\nconst STRICT_UTF8 = new TextDecoder(\"utf-8\", { fatal: true });\n\nexport interface Reported {\n readonly severity: string;\n}\n\nexport interface LintCall<Config, Failure> {\n readonly root: string;\n readonly files: readonly string[];\n readonly projectFiles: readonly string[];\n readonly config: Config;\n readonly read: (file: string) => Effect.Effect<string, Failure | NotUtf8Error>;\n}\n\nexport interface PathspecRequest<Config> {\n readonly config: Config;\n readonly patterns?: readonly string[];\n}\n\nexport interface SectionSource<Config, Failure> {\n readonly name: string;\n readonly version: string;\n readonly description: string;\n readonly section: (config: unknown) => Config;\n readonly failWith: FailWith<Failure>;\n}\n\nexport interface Cli<Config, Found extends Reported, Failure> extends SectionSource<\n Config,\n Failure\n> {\n readonly pathspecs: (request: PathspecRequest<Config>) => readonly string[];\n readonly lint: (call: LintCall<Config, Failure>) => Effect.Effect<readonly Found[], Failure>;\n readonly format: (found: Found) => string;\n}\n\nexport interface ToolParameter {\n readonly name: string;\n readonly description: string;\n}\n\nexport interface ToolInput {\n readonly flags: ReadonlySet<string>;\n readonly args: readonly string[];\n}\n\nexport interface ToolCall<Config> {\n readonly root: string;\n readonly config: Config;\n readonly input: ToolInput;\n}\n\nexport interface Tool<Config, Found, Failure> extends SectionSource<Config, Failure> {\n readonly flags: readonly ToolParameter[];\n readonly argument: ToolParameter;\n readonly scan: (call: ToolCall<Config>) => Effect.Effect<readonly Found[], Failure>;\n readonly format: (found: Found) => string;\n}\n\ntype CliServices = FileSystem.FileSystem | Path.Path | ChildProcessSpawner.ChildProcessSpawner;\n\nconst readSectionIn = <Config, Failure>(\n source: SectionSource<Config, Failure>,\n root: string,\n): Effect.Effect<Config, Failure, FileSystem.FileSystem | Path.Path> =>\n Effect.gen(function* readConfig() {\n const fileSystem = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const found = yield* pipe(\n CONFIG_FILES,\n Arr.map((name) => path.join(root, name)),\n Effect.filter((file) => fileSystem.exists(file).pipe(Effect.orElseSucceed(() => false))),\n );\n const loaded = yield* Option.match(Arr.head(found), {\n onNone: () => Effect.succeed<unknown>({}),\n onSome: (file) =>\n Effect.tryPromise({\n try: () => resolveConfigFromFile(file),\n catch: source.failWith(`could not load ${file}`),\n }),\n });\n return source.section(loaded);\n }).pipe(Effect.withSpan(`${source.name}.config`));\n\n/** @internal */\nexport const readSection: {\n (\n root: string,\n ): <Config, Failure>(\n source: SectionSource<Config, Failure>,\n ) => Effect.Effect<Config, Failure, FileSystem.FileSystem | Path.Path>;\n <Config, Failure>(\n source: SectionSource<Config, Failure>,\n root: string,\n ): Effect.Effect<Config, Failure, FileSystem.FileSystem | Path.Path>;\n} = Fn.dual(DATA_FIRST_ARITY, readSectionIn);\n\nconst trackedFiles = (\n root: string,\n pathspecs: readonly string[],\n): Effect.Effect<readonly string[], PlatformError, ChildProcessSpawner.ChildProcessSpawner> =>\n Effect.gen(function* listFiles() {\n const spawner = yield* ChildProcessSpawner.ChildProcessSpawner;\n const output = yield* spawner.string(\n ChildProcess.make(\n \"git\",\n [\"ls-files\", \"-co\", \"--exclude-standard\", \"-z\", \"--\", ...pathspecs],\n { cwd: root },\n ),\n );\n return pipe(Str.split(output, \"\\0\"), Arr.filter(Str.isNonEmpty));\n });\n\nconst requestOf = <Config>(config: Config, patterns: readonly string[]): PathspecRequest<Config> =>\n Arr.match(patterns, {\n onEmpty: () => ({ config }),\n onNonEmpty: (given) => ({ config, patterns: given }),\n });\n\nconst hasError = (found: readonly Reported[]): boolean =>\n pipe(\n found,\n Arr.some(({ severity }) => severity === \"error\"),\n );\n\nconst failWhen = (failed: boolean): Effect.Effect<void> =>\n Effect.when(\n Effect.sync(() => {\n process.exitCode = FAILED;\n }),\n Effect.succeed(failed),\n ).pipe(Effect.asVoid);\n\nconst printAll = <Found>(\n found: readonly Found[],\n format: (found: Found) => string,\n): Effect.Effect<void> =>\n Arr.match(found, {\n onEmpty: () => Effect.void,\n onNonEmpty: (all) => Console.log(pipe(all, Arr.map(format), Arr.join(\"\\n\"))),\n });\n\nconst readerIn = <Failure>(\n root: string,\n failWith: FailWith<Failure>,\n): Effect.Effect<\n (file: string) => Effect.Effect<string, Failure | NotUtf8Error>,\n never,\n FileSystem.FileSystem | Path.Path\n> =>\n Effect.gen(function* reader() {\n const fileSystem = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n return (file: string): Effect.Effect<string, Failure | NotUtf8Error> =>\n fileSystem.readFile(path.resolve(root, file)).pipe(\n Effect.mapError(failWith(`could not read ${file}`)),\n Effect.flatMap((bytes) =>\n Effect.try({\n try: () => STRICT_UTF8.decode(bytes),\n catch: () => NotUtf8Error.make({ path: file }),\n }),\n ),\n );\n });\n\nconst mainOf = <Config, Found extends Reported, Failure>(\n cli: Cli<Config, Found, Failure>,\n patterns: readonly string[],\n): Effect.Effect<void, Failure | PlatformError, CliServices> =>\n Effect.gen(function* main() {\n const root = process.cwd();\n const config = yield* readSectionIn(cli, root);\n const pathspecs = cli.pathspecs(requestOf(config, patterns));\n const { files, projectFiles } = yield* Effect.all(\n {\n files: trackedFiles(root, pathspecs).pipe(Effect.withSpan(`${cli.name}.files`)),\n projectFiles: trackedFiles(root, []).pipe(Effect.withSpan(`${cli.name}.project`)),\n },\n { concurrency: \"unbounded\" },\n );\n const read = yield* readerIn(root, cli.failWith);\n const found = yield* cli.lint({ root, files, projectFiles, config, read });\n yield* printAll(found, cli.format);\n yield* failWhen(hasError(found));\n });\n\nconst toolMainOf =\n <Config, Found, Failure>(tool: Tool<Config, Found, Failure>) =>\n (input: ToolInput): Effect.Effect<void, Failure | PlatformError, CliServices> =>\n Effect.gen(function* main() {\n const root = process.cwd();\n const config = yield* readSectionIn(tool, root);\n const found = yield* tool.scan({ root, config, input });\n yield* printAll(found, tool.format);\n yield* failWhen(Arr.isReadonlyArrayNonEmpty(found));\n });\n\nconst variadicOf = ({ name, description }: ToolParameter): Argument.Argument<readonly string[]> =>\n Argument.String(name).pipe(Argument.withDescription(description), Argument.variadic());\n\nconst flagsOf = (flags: readonly ToolParameter[]): Readonly<Record<string, Flag.Flag<boolean>>> =>\n Rec.fromEntries(\n pipe(\n flags,\n Arr.map(({ name, description }) => [\n name,\n Flag.Boolean(name).pipe(Flag.withDescription(description), Flag.withDefault(false)),\n ]),\n ),\n );\n\nconst setFlags = (values: Readonly<Record<string, boolean>>): ReadonlySet<string> =>\n new Set(pipe(values, Rec.filter(Fn.identity), Rec.keys));\n\nexport const runTool = <Config, Found, Failure>(tool: Tool<Config, Found, Failure>): void => {\n const command = Command.make(\n tool.name,\n { args: variadicOf(tool.argument), flags: flagsOf(tool.flags) },\n ({ args, flags }) => toolMainOf(tool)({ args, flags: setFlags(flags) }),\n ).pipe(Command.withDescription(tool.description));\n runMain(tool.name)(Command.run(command, { version: tool.version }));\n};\n\nconst pathspecArgument = (): Argument.Argument<readonly string[]> =>\n variadicOf({\n name: \"pathspec\",\n description: \"Git pathspecs of the files to lint, in place of the configured ones\",\n });\n\nexport const runCli = <Config, Found extends Reported, Failure>(\n cli: Cli<Config, Found, Failure>,\n): void => {\n const command = Command.make(cli.name, { pathspecs: pathspecArgument() }, ({ pathspecs }) =>\n mainOf(cli, pathspecs),\n ).pipe(Command.withDescription(cli.description));\n runMain(cli.name)(Command.run(command, { version: cli.version }));\n};\n","import { Function as Fn, Option } from \"effect\";\n\nconst DATA_FIRST_ARITY = 2;\n\nexport const present: {\n <Value, Fields extends object>(\n build: (value: Value) => Fields,\n ): (value: Option.Option<Value>) => Partial<Fields>;\n <Value, Fields extends object>(\n value: Option.Option<Value>,\n build: (value: Value) => Fields,\n ): Partial<Fields>;\n} = Fn.dual(\n DATA_FIRST_ARITY,\n <Value, Fields extends object>(\n value: Option.Option<Value>,\n build: (value: Value) => Fields,\n ): Partial<Fields> => Option.match(value, { onNone: (): Partial<Fields> => ({}), onSome: build }),\n);\n","import { Array as Arr, Boolean as Bool, Effect, Order } from \"effect\";\nimport type { Option } from \"effect\";\n\nconst SAMPLED = \"01\";\nconst NOT_SAMPLED = \"00\";\n\nexport interface Positioned {\n readonly path: string;\n readonly line: number;\n readonly column?: number;\n}\n\nconst LINE_START = 0;\n\nconst flagsOf = (sampled: boolean): string =>\n Bool.match(sampled, { onFalse: () => NOT_SAMPLED, onTrue: () => SAMPLED });\n\nexport const traceparent: Effect.Effect<Option.Option<string>> = Effect.currentSpan.pipe(\n Effect.map((span) => `00-${span.traceId}-${span.spanId}-${flagsOf(span.sampled)}`),\n Effect.option,\n);\n\nconst byPosition: Order.Order<Positioned> = Order.combine(\n Order.mapInput(Order.String, (found: Positioned) => found.path),\n Order.combine(\n Order.mapInput(Order.Number, (found: Positioned) => found.line),\n Order.mapInput(Order.Number, (found: Positioned) => found.column ?? LINE_START),\n ),\n);\n\nexport const sortByPosition = <Found extends Positioned>(found: readonly Found[]): Found[] =>\n Arr.sort(found, byPosition);\n","import { Array as Arr, Record as Rec, pipe } from \"effect\";\n\nexport interface Layer<Plugin, Entry, Override> {\n readonly plugins?: Readonly<Record<string, Plugin>>;\n readonly rules?: Readonly<Record<string, Entry>>;\n readonly ignores?: readonly string[];\n readonly overrides?: readonly Override[];\n}\n\nexport interface Merged<Plugin, Entry, Override> {\n readonly plugins: Readonly<Record<string, Plugin>>;\n readonly rules: Readonly<Record<string, Entry>>;\n readonly ignores: readonly string[];\n readonly overrides: readonly Override[];\n}\n\nexport const mergedRecords = <Value>(\n records: readonly (Readonly<Record<string, Value>> | undefined)[],\n): Readonly<Record<string, Value>> =>\n pipe(\n records,\n Arr.flatMap((record) => Rec.toEntries(record ?? {})),\n Rec.fromEntries,\n );\n\nexport const layersOf = <Config extends { readonly extends?: readonly Config[] }>(\n config: Config,\n): readonly Omit<Config, \"extends\">[] => {\n const { extends: bases = [], ...own } = config;\n return [...pipe(bases, Arr.flatMap(layersOf)), own];\n};\n\nexport const mergedLayers = <Plugin, Entry, Override>(\n layers: readonly Layer<Plugin, Entry, Override>[],\n): Merged<Plugin, Entry, Override> => ({\n plugins: mergedRecords(\n pipe(\n layers,\n Arr.map((layer) => layer.plugins),\n ),\n ),\n rules: mergedRecords(\n pipe(\n layers,\n Arr.map((layer) => layer.rules),\n ),\n ),\n ignores: pipe(\n layers,\n Arr.flatMap((layer) => layer.ignores ?? []),\n ),\n overrides: pipe(\n layers,\n Arr.flatMap((layer) => layer.overrides ?? []),\n ),\n});\n","import { Array as Arr, Option, pipe } from \"effect\";\n\nexport interface Reportable {\n readonly path: string;\n readonly line: number;\n readonly column?: number | undefined;\n readonly rule: string;\n readonly message: string;\n readonly detail?: string | undefined;\n readonly context?: string | undefined;\n readonly severity: string;\n}\n\nexport const diagnosticDetail = (diagnostic: Reportable): string =>\n pipe(\n [diagnostic.detail, diagnostic.context],\n Arr.flatMap((part) => Option.toArray(Option.fromNullishOr(part))),\n Arr.filter((part) => part !== \"\"),\n Arr.map((part) => ` [${part}]`),\n Arr.join(\"\"),\n );\n\nexport const formatDiagnostic = (diagnostic: Reportable): string => {\n const column = pipe(\n Option.fromNullishOr(diagnostic.column),\n Option.map((value) => `:${String(value)}`),\n Option.getOrElse(() => \"\"),\n );\n return `${diagnostic.path}:${String(diagnostic.line)}${column} ${diagnostic.severity} ${diagnostic.rule} ${diagnostic.message}${diagnosticDetail(diagnostic)}`;\n};\n\nexport interface NotUtf8 {\n readonly path: string;\n readonly line: number;\n readonly column: number;\n readonly rule: string;\n readonly message: string;\n readonly severity: \"error\";\n}\n\nexport const notUtf8 =\n (tool: string) =>\n (path: string): NotUtf8 => ({\n path,\n line: 1,\n column: 1,\n rule: \"utf8\",\n message: `The file is not valid UTF-8, so ${tool} cannot read it`,\n severity: \"error\",\n });\n","import { Array as Arr, Function as Fn, Option, Predicate, pipe } from \"effect\";\n\nexport interface SectionRequest<Config extends object> {\n readonly name: string;\n readonly fallback: Config;\n readonly prepare?: (section: Config) => Config;\n}\n\nexport const sectionOf = <Config extends object>({\n name,\n fallback,\n prepare = Fn.identity,\n}: SectionRequest<Config>): ((config: unknown) => Config) => {\n const hasSection = (value: unknown): value is Readonly<Record<string, Config>> =>\n Predicate.hasProperty(value, name) && Predicate.isObject(value[name]);\n return (config) =>\n pipe(\n Option.liftPredicate(config, hasSection),\n Option.flatMapNullishOr((value) => value[name]),\n Option.map(prepare),\n Option.getOrElse(() => fallback),\n );\n};\n\nexport interface Ignoring {\n readonly ignores?: readonly string[] | undefined;\n}\n\nexport interface Pathspecs {\n readonly defaults: readonly string[];\n readonly unowned?: readonly string[];\n}\n\nexport const pathspecsOf =\n ({ defaults, unowned = [] }: Pathspecs) =>\n ({\n config,\n patterns = [],\n }: {\n readonly config: Ignoring;\n readonly patterns?: readonly string[];\n }): readonly string[] => [\n ...Arr.match(patterns, { onEmpty: () => defaults, onNonEmpty: Fn.identity }),\n ...unowned,\n ...pipe(\n config.ignores ?? [],\n Arr.map((glob) => `:(glob,exclude)${glob}`),\n ),\n ];\n","import { layersOf, mergedLayers, mergedRules } from \"@masseater.dev/lint-host\";\nimport { Array as Arr, pipe } from \"effect\";\n\nimport type { I68Config } from \"#/shared/config/index.ts\";\n\nexport const flattenConfig = (config: I68Config): I68Config => {\n const layers = layersOf(config);\n const { plugins, ignores } = mergedLayers(layers);\n const rules = mergedRules(\n pipe(\n layers,\n Arr.map((layer) => layer.rules),\n ),\n );\n return { plugins, rules, ignores };\n};\n","import { settingOf } from \"@masseater.dev/lint-host\";\nimport type { Setting } from \"@masseater.dev/lint-host\";\nimport { Array as Arr, Option, Record as Rec, String as Str, pipe } from \"effect\";\n\nimport type { I68Config, Plugin, Rule } from \"#/shared/config/index.ts\";\n\nconst SEPARATOR = \"/\";\nconst START = 0;\nconst ENABLED: Setting = settingOf(\"error\");\n\nexport interface ResolvedRule {\n readonly id: string;\n readonly rule: Rule;\n readonly setting: Setting;\n}\n\ntype PluginEntry = readonly [string, Plugin];\n\nconst idOf = (plugin: string, name: string): string => `${plugin}${SEPARATOR}${name}`;\n\nconst pluginOf = (id: string): string =>\n pipe(\n Str.indexOf(SEPARATOR)(id),\n Option.match({\n onNone: () => id,\n onSome: (slash) => Str.slice(START, slash)(id),\n }),\n );\n\nconst rulesOf =\n (config: I68Config) =>\n ([plugin, value]: PluginEntry): readonly ResolvedRule[] =>\n pipe(\n Rec.toEntries(value.rules),\n Arr.map(([name, rule]): ResolvedRule => {\n const id = idOf(plugin, name);\n return {\n id,\n rule,\n setting: pipe(\n config.rules ?? {},\n Rec.get(id),\n Option.map(settingOf),\n Option.getOrElse(() => ENABLED),\n ),\n };\n }),\n Arr.filter(({ setting }) => setting.severity !== \"off\"),\n );\n\nexport const resolve = (config: I68Config): readonly ResolvedRule[] =>\n pipe(Rec.toEntries(config.plugins ?? {}), Arr.flatMap(rulesOf(config)));\n\nexport const unknownPlugins = (config: I68Config): readonly string[] =>\n pipe(\n Rec.keys(config.rules ?? {}),\n Arr.map(pluginOf),\n Arr.filter((plugin) => !Rec.has(config.plugins ?? {}, plugin)),\n Arr.dedupe,\n );\n\nconst ruleNameOf = (id: string): string =>\n pipe(\n Str.indexOf(SEPARATOR)(id),\n Option.match({\n onNone: () => \"\",\n onSome: (slash) => Str.slice(slash + SEPARATOR.length)(id),\n }),\n );\n\nconst isKnownRule =\n (config: I68Config) =>\n (id: string): boolean =>\n pipe(\n Rec.get(config.plugins ?? {}, pluginOf(id)),\n Option.match({\n onNone: () => true,\n onSome: (plugin) => Rec.has(plugin.rules, ruleNameOf(id)),\n }),\n );\n\nexport const unknownRules = (config: I68Config): readonly string[] =>\n pipe(\n Rec.keys(config.rules ?? {}),\n Arr.filter((id) => !isKnownRule(config)(id)),\n );\n","import type { NotUtf8Error } from \"@masseater.dev/lint-host\";\nimport { readSong } from \"@r_masseater/song-format\";\nimport type { SongSource } from \"@r_masseater/song-format\";\nimport { Effect } from \"effect\";\n\nimport type { I68Error } from \"#/shared/lib/errors.ts\";\n\nconst SEPARATOR = \"/\";\n\nexport interface SongFile {\n readonly file: string;\n readonly source: SongSource;\n}\n\nexport type Read = (path: string) => Effect.Effect<string, I68Error | NotUtf8Error>;\n\nexport interface ReadInput {\n readonly root: string;\n readonly file: string;\n readonly read: Read;\n}\n\nexport const pathOf = (input: Omit<ReadInput, \"read\">): string =>\n `${input.root}${SEPARATOR}${input.file}`;\n\nexport const readSongFile = Effect.fn(\"i68.read\")(function* readSongFile(input: ReadInput) {\n const source = yield* readSong({ path: pathOf(input), read: input.read });\n return { file: input.file, source } satisfies SongFile;\n});\n","import { Schema } from \"effect\";\n\nconst taggedError = Schema.TaggedError;\n\nexport class I68Error extends taggedError<I68Error, { readonly brand: unique symbol }>()(\n \"I68Error\",\n { message: Schema.String },\n) {}\n\nexport const failedWith =\n (message: string) =>\n (cause: unknown): I68Error =>\n I68Error.make({ message: `${message}: ${String(cause)}` });\n","import type { SourceComment } from \"@r_masseater/song-format\";\nimport { Array as Arr, Match, Option, String as Str, pipe } from \"effect\";\n\nconst DIRECTIVE =\n /^i68-(?<kind>ignore-next-line|ignore-file|ignore|disable|enable)(?:\\s(?<rest>[\\s\\S]*))?$/u;\nconst REASON = /\\s-{2,}(?:\\s|$)/u;\nconst LINE_MARK = \"//\";\nconst BLOCK_START = \"/*\";\nconst BLOCK_END = \"*/\";\nconst LIST = \",\";\nconst NEXT = 1;\nconst LINE_START = 0;\n\ntype Kind = \"ignore\" | \"ignore-next-line\" | \"ignore-file\" | \"disable\" | \"enable\";\n\ninterface Directive {\n readonly line: number;\n readonly column: number;\n readonly kind: Kind;\n readonly rules: readonly string[];\n}\n\nexport interface Suppressed {\n readonly line: number;\n readonly column?: number;\n readonly rule: string;\n}\n\nconst kindOf = (text: string): Kind =>\n Match.value(text).pipe(\n Match.when(\"ignore-file\", (): Kind => \"ignore-file\"),\n Match.when(\"ignore-next-line\", (): Kind => \"ignore-next-line\"),\n Match.when(\"disable\", (): Kind => \"disable\"),\n Match.when(\"enable\", (): Kind => \"enable\"),\n Match.orElse((): Kind => \"ignore\"),\n );\n\nconst bodyOf = (text: string): string => {\n if (Str.startsWith(BLOCK_START)(text)) {\n return pipe(text, Str.slice(BLOCK_START.length), Str.replace(BLOCK_END, \"\"), Str.trim);\n }\n return pipe(text, Str.slice(LINE_MARK.length), Str.trim);\n};\n\nconst rulesOf = (rest: string): readonly string[] =>\n pipe(\n Str.split(` ${rest}`, REASON),\n Arr.head,\n Option.getOrElse(() => \"\"),\n Str.split(LIST),\n Arr.map(Str.trim),\n Arr.filter(Str.isNonEmpty),\n );\n\nconst groupsOf = (text: string): Option.Option<Partial<Record<string, string>>> =>\n pipe(\n Option.fromNullishOr(DIRECTIVE.exec(text)),\n Option.flatMap((found) => Option.fromNullishOr(found.groups)),\n );\n\nconst directiveOf = (comment: SourceComment): Option.Option<Directive> =>\n pipe(\n groupsOf(bodyOf(comment.text)),\n Option.map((groups) => ({\n line: comment.line,\n column: comment.column,\n kind: kindOf(groups[\"kind\"] ?? \"\"),\n rules: rulesOf(groups[\"rest\"] ?? \"\"),\n })),\n );\n\nconst names =\n (rule: string) =>\n (directive: Directive): boolean =>\n !Arr.isReadonlyArrayNonEmpty(directive.rules) || Arr.contains(directive.rules, rule);\n\nconst isRange = (directive: Directive): boolean =>\n directive.kind === \"disable\" || directive.kind === \"enable\";\n\nconst coversLine =\n (found: Suppressed) =>\n (directive: Directive): boolean =>\n names(found.rule)(directive) &&\n Match.value(directive.kind).pipe(\n Match.when(\"ignore-file\", () => true),\n Match.when(\"ignore-next-line\", () => directive.line + NEXT === found.line),\n Match.when(\"ignore\", () => directive.line === found.line),\n Match.orElse(() => false),\n );\n\nconst isAfter =\n (found: Suppressed) =>\n (directive: Directive): boolean =>\n directive.line < found.line ||\n (directive.line === found.line && directive.column <= (found.column ?? LINE_START));\n\nconst insideRange =\n (directives: readonly Directive[]) =>\n (found: Suppressed): boolean =>\n pipe(\n directives,\n Arr.filter(\n (directive) =>\n isRange(directive) && isAfter(found)(directive) && names(found.rule)(directive),\n ),\n Arr.last,\n Option.exists((directive) => directive.kind === \"disable\"),\n );\n\nexport const suppressionsOf = (\n comments: readonly SourceComment[],\n): ((found: Suppressed) => boolean) => {\n const directives = pipe(comments, Arr.map(directiveOf), Arr.getSomes);\n return (found) => pipe(directives, Arr.some(coversLine(found))) || insideRange(directives)(found);\n};\n","import { present, reportedSeverity } from \"@masseater.dev/lint-host\";\nimport type { Song, SourceComment } from \"@r_masseater/song-format\";\nimport { soundingsOf } from \"@r_masseater/song-format/analysis\";\nimport type { Sounding } from \"@r_masseater/song-format/analysis\";\nimport { Array as Arr, Effect, Option, pipe } from \"effect\";\n\nimport type { ResolvedRule } from \"#/entities/rule/index.ts\";\nimport type { Diagnostic, Report } from \"#/shared/config/index.ts\";\nimport { failedWith } from \"#/shared/lib/errors.ts\";\nimport type { I68Error } from \"#/shared/lib/errors.ts\";\n\nimport { suppressionsOf } from \"./suppressions.ts\";\n\nexport interface RunInput {\n readonly path: string;\n readonly comments: readonly SourceComment[];\n readonly song: Song;\n readonly rules: readonly ResolvedRule[];\n}\n\nconst diagnosticOf =\n (path: string, rule: ResolvedRule) =>\n (report: Report): Diagnostic => ({\n path,\n line: report.line,\n rule: rule.id,\n message: report.message,\n severity: reportedSeverity(rule.setting),\n ...present(Option.fromNullishOr(report.column), (column) => ({ column })),\n ...present(Option.fromNullishOr(report.detail), (detail) => ({ detail })),\n });\n\nconst runOne = (\n input: RunInput,\n soundings: readonly Sounding[],\n): ((rule: ResolvedRule) => Effect.Effect<readonly Diagnostic[], I68Error>) =>\n Effect.fn(\"i68.rule\")(function* run(rule: ResolvedRule) {\n yield* Effect.annotateCurrentSpan({ \"i68.rule\": rule.id });\n const reports: Report[] = [];\n yield* Effect.try({\n try: () => {\n rule.rule.check({\n filename: input.path,\n song: input.song,\n soundings,\n options: rule.setting.options,\n report: (report) => {\n reports.push(report);\n },\n });\n },\n catch: failedWith(`${rule.id} failed`),\n });\n return pipe(reports, Arr.map(diagnosticOf(input.path, rule)));\n });\n\nexport const runRules = Effect.fn(\"i68.rules\")(function* runRules(input: RunInput) {\n const soundings = soundingsOf(input.song);\n const suppressed = suppressionsOf(input.comments);\n const found = yield* pipe(\n input.rules,\n Effect.forEach(runOne(input, soundings), { concurrency: 1 }),\n );\n return pipe(\n Arr.flatten(found),\n Arr.filter((diagnostic) => !suppressed(diagnostic)),\n );\n});\n","import { NotUtf8Error, notUtf8, sortByPosition } from \"@masseater.dev/lint-host\";\nimport { readSong } from \"@r_masseater/song-format\";\nimport type { SourceIssue } from \"@r_masseater/song-format\";\nimport { Array as Arr, Effect, Result, Schema, pipe } from \"effect\";\n\nimport { flattenConfig, resolve, unknownPlugins, unknownRules } from \"#/entities/rule/index.ts\";\nimport type { ResolvedRule } from \"#/entities/rule/index.ts\";\nimport { pathOf, readSongFile } from \"#/features/read-songs/index.ts\";\nimport type { Read, SongFile } from \"#/features/read-songs/index.ts\";\nimport { runRules } from \"#/features/run-rules/index.ts\";\nimport type { Diagnostic, I68Config } from \"#/shared/config/index.ts\";\nimport { I68Error } from \"#/shared/lib/errors.ts\";\n\nconst PARSE_RULE = \"i68/parse\";\n\nexport interface LintInput {\n readonly root: string;\n readonly files: readonly string[];\n readonly read: Read;\n readonly config?: I68Config;\n}\n\nexport interface TextInput {\n readonly path: string;\n readonly text: string;\n readonly read?: Read;\n readonly config?: I68Config;\n}\n\nconst failIfAny =\n (problem: string) =>\n (names: readonly string[]): Effect.Effect<void, I68Error> =>\n Arr.match(names, {\n onEmpty: () => Effect.void,\n onNonEmpty: (found) =>\n Effect.fail(I68Error.make({ message: `${problem}: ${Arr.join(found, \", \")}` })),\n });\n\nconst UNKNOWN_PLUGINS = failIfAny(\"rules name plugins that are not configured\");\nconst UNKNOWN_RULES = failIfAny(\"rules name rules that their plugins do not have\");\n\nconst checkPlugins = (config: I68Config): Effect.Effect<void, I68Error> => {\n const rules = UNKNOWN_RULES(unknownRules(config));\n return UNKNOWN_PLUGINS(unknownPlugins(config)).pipe(Effect.andThen(rules));\n};\n\nconst rulesOf = (\n config: I68Config | undefined,\n): Effect.Effect<readonly ResolvedRule[], I68Error> => {\n const flat = flattenConfig(config ?? {});\n return checkPlugins(flat).pipe(Effect.as(resolve(flat)));\n};\n\nconst parseDiagnosticsOf =\n (file: string) =>\n (issues: readonly SourceIssue[]): readonly Diagnostic[] =>\n pipe(\n issues,\n Arr.map((issue): Diagnostic => ({\n path: file,\n line: issue.line,\n column: issue.column,\n rule: PARSE_RULE,\n message: issue.message,\n severity: \"error\",\n })),\n );\n\nconst lintFile =\n (rules: readonly ResolvedRule[]) =>\n (song: SongFile): Effect.Effect<readonly Diagnostic[], I68Error> => {\n if (song.source.status === \"invalid\") {\n return Effect.succeed(parseDiagnosticsOf(song.file)(song.source.issues));\n }\n return runRules({\n path: song.file,\n comments: song.source.outline.comments,\n song: song.source.song,\n rules,\n });\n };\n\nconst notFound = (path: string): Effect.Effect<string, I68Error> =>\n Effect.fail(I68Error.make({ message: `could not read ${path}` }));\n\nconst readerOf =\n (input: TextInput): Read =>\n (path) => {\n if (path === input.path) {\n return Effect.succeed(input.text);\n }\n return (input.read ?? notFound)(path);\n };\n\nconst lintTracked = (\n rules: readonly ResolvedRule[],\n input: LintInput,\n): ((file: string) => Effect.Effect<readonly Diagnostic[], I68Error>) =>\n Effect.fnUntraced(function* lintOne(\n file: string,\n ): Effect.fn.Return<readonly Diagnostic[], I68Error> {\n const path = pathOf({ root: input.root, file });\n const read = yield* Effect.result(input.read(path));\n if (Result.isFailure(read) && Schema.is(NotUtf8Error)(read.failure)) {\n return [notUtf8(\"i68\")(file)];\n }\n const reader = Result.match(read, {\n onFailure: () => input.read,\n onSuccess: (text): Read => readerOf({ path, text, read: input.read }),\n });\n const source = yield* readSongFile({ root: input.root, file, read: reader });\n return yield* lintFile(rules)(source);\n });\n\nexport const lint = Effect.fn(\"i68.lint\")(function* lint(input: LintInput) {\n const rules = yield* rulesOf(input.config);\n const found = yield* Effect.forEach(input.files, lintTracked(rules, input), {\n concurrency: \"unbounded\",\n });\n return sortByPosition<Diagnostic>(Arr.flatten(found));\n});\n\nexport const lintText = Effect.fn(\"i68.lintText\")(function* lintText(input: TextInput) {\n const rules = yield* rulesOf(input.config);\n const source = yield* readSong({ path: input.path, read: readerOf(input) });\n const found = yield* lintFile(rules)({ file: input.path, source });\n return sortByPosition<Diagnostic>(found);\n});\n","import { pathspecsOf, sectionOf } from \"@masseater.dev/lint-host\";\nimport type { PathspecRequest } from \"@masseater.dev/lint-host\";\n\nimport { flattenConfig } from \"#/entities/rule/index.ts\";\nimport type { I68Config } from \"#/shared/config/index.ts\";\n\nexport type PathspecInput = PathspecRequest<I68Config>;\n\nexport const i68Section = sectionOf<I68Config>({\n name: \"i68\",\n prepare: flattenConfig,\n fallback: {},\n});\n\nexport const songPathspecs = pathspecsOf({ defaults: [\"*.fumx\"] });\n"],"mappings":";;;;;;;;AAaA,MAAM,aAA0B,CAAC;AAEjC,MAAa,aAAa,UACxB,MAAM,MAAM,KAAK,C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