@r_masseater/i68 0.0.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +87 -0
- package/README.md +134 -1
- package/dist/app-J9_4mtbE.mjs +7 -0
- package/dist/app-J9_4mtbE.mjs.map +1 -0
- package/dist/cli-CzV_7HHU.mjs +15 -0
- package/dist/cli-CzV_7HHU.mjs.map +1 -0
- package/dist/cli.d.mts +1 -0
- package/dist/cli.mjs +9 -0
- package/dist/cli.mjs.map +1 -0
- package/dist/habits.d.mts +72 -0
- package/dist/habits.mjs +98 -0
- package/dist/habits.mjs.map +1 -0
- package/dist/index-5D8Rm7JG.d.mts +48 -0
- package/dist/index-DB7buWb9.d.mts +49 -0
- package/dist/index.d.mts +3 -0
- package/dist/index.mjs +3 -0
- package/dist/mix-facts-CvX18d2q.mjs +6997 -0
- package/dist/mix-facts-CvX18d2q.mjs.map +1 -0
- package/dist/presets.d.mts +36 -0
- package/dist/presets.mjs +802 -0
- package/dist/presets.mjs.map +1 -0
- package/dist/section-C9JQ1-aJ.mjs +388 -0
- package/dist/section-C9JQ1-aJ.mjs.map +1 -0
- package/dist/style-rules-gR1Cixel.d.mts +132 -0
- package/dist/vite.d.mts +7 -0
- package/dist/vite.mjs +1 -0
- package/package.json +87 -7
- package/skills/lint-songs/SKILL.md +51 -0
- package/skills/use-i68-presets/SKILL.md +57 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 masseater
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
@tanstack/eslint-plugin-start
|
|
26
|
+
|
|
27
|
+
MIT License
|
|
28
|
+
|
|
29
|
+
Copyright (c) 2021-present Tanner Linsley
|
|
30
|
+
|
|
31
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
32
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
33
|
+
in the Software without restriction, including without limitation the rights
|
|
34
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
35
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
36
|
+
furnished to do so, subject to the following conditions:
|
|
37
|
+
|
|
38
|
+
The above copyright notice and this permission notice shall be included in all
|
|
39
|
+
copies or substantial portions of the Software.
|
|
40
|
+
|
|
41
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
42
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
43
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
44
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
45
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
46
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
47
|
+
SOFTWARE.
|
|
48
|
+
|
|
49
|
+
---
|
|
50
|
+
|
|
51
|
+
@typescript-eslint/utils
|
|
52
|
+
|
|
53
|
+
MIT License
|
|
54
|
+
|
|
55
|
+
Copyright (c) 2019 typescript-eslint and other contributors
|
|
56
|
+
|
|
57
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
58
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
59
|
+
in the Software without restriction, including without limitation the rights
|
|
60
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
61
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
62
|
+
furnished to do so, subject to the following conditions:
|
|
63
|
+
|
|
64
|
+
The above copyright notice and this permission notice shall be included in all
|
|
65
|
+
copies or substantial portions of the Software.
|
|
66
|
+
|
|
67
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
68
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
69
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
70
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
71
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
72
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
73
|
+
SOFTWARE.
|
|
74
|
+
|
|
75
|
+
---
|
|
76
|
+
|
|
77
|
+
globals
|
|
78
|
+
|
|
79
|
+
MIT License
|
|
80
|
+
|
|
81
|
+
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
|
|
82
|
+
|
|
83
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
84
|
+
|
|
85
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
86
|
+
|
|
87
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,136 @@
|
|
|
1
1
|
# @r_masseater/i68
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A linter for `.fumx` songs, configured from `vite.config.ts`.
|
|
4
|
+
|
|
5
|
+
`.fumx` writes music as text, so the habits a composer keeps can be checked like code: notes outside the key, a part above what its singer can reach, two parts clashing a semitone apart. i68 reads each song with [`@r_masseater/song-format`](https://www.npmjs.com/package/@r_masseater/song-format), runs rules written in TypeScript over its notes, and prints each finding with its file, line and column.
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
vp add -D @r_masseater/i68 effect
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
```ts
|
|
12
|
+
import "@r_masseater/i68/vite";
|
|
13
|
+
import { recommended } from "@r_masseater/i68/presets";
|
|
14
|
+
import { defineConfig } from "vite-plus";
|
|
15
|
+
|
|
16
|
+
export default defineConfig({
|
|
17
|
+
i68: {
|
|
18
|
+
extends: [recommended({ ranges: { lead: ["A3", "E5"] } })],
|
|
19
|
+
rules: { "harmony/chord-above-melody": "off" },
|
|
20
|
+
},
|
|
21
|
+
});
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
```sh
|
|
25
|
+
vp exec i68 # every .fumx file git tracks
|
|
26
|
+
vp exec i68 songs/ # only these paths
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
The official rules live in the `@r_masseater/i68/presets` subpath, one preset per concern.
|
|
30
|
+
|
|
31
|
+
## Rules
|
|
32
|
+
|
|
33
|
+
A rule gets the song, the notes that sound (with their track role, source line and column) and its options, and reports what it finds.
|
|
34
|
+
|
|
35
|
+
```ts
|
|
36
|
+
import { definePlugin, defineRule } from "@r_masseater/i68";
|
|
37
|
+
|
|
38
|
+
const noHighBass = defineRule({
|
|
39
|
+
meta: { description: "The bass stays at or below C3" },
|
|
40
|
+
check: (context) => {
|
|
41
|
+
for (const note of context.soundings) {
|
|
42
|
+
if (note.track === "bass" && note.midi > 48) {
|
|
43
|
+
context.report({ line: note.line, column: note.column, message: "The bass is too high" });
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
export const local = definePlugin({ rules: { "no-high-bass": noHighBass } });
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Register a plugin under a name in `plugins` and its rules become `<name>/<rule>`. A rule is on as an error unless `rules` sets it to `"warn"`, `"off"` or `["warn", { ...options }]`. A later config that sets only the severity keeps the options an earlier one gave, as in ESLint. Naming a plugin or a rule that is not registered, or a rule that throws, stops the run with an error.
|
|
53
|
+
|
|
54
|
+
## Ignoring a finding
|
|
55
|
+
|
|
56
|
+
When a passage breaks a rule on purpose, say so in the file, and write why after `--`:
|
|
57
|
+
|
|
58
|
+
```fumx
|
|
59
|
+
lead: C5 1/2, F#5 1/2 // i68-ignore pop/out-of-key -- borrowed from the parallel minor
|
|
60
|
+
// i68-ignore-next-line harmony/semitone-clash
|
|
61
|
+
pad: [B4 C5] 1/1
|
|
62
|
+
// i68-disable pop/melody-leap -- the chorus jumps on purpose
|
|
63
|
+
...
|
|
64
|
+
// i68-enable pop/melody-leap
|
|
65
|
+
// i68-ignore-file classical/parallel-perfects
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
Directives follow ESLint's: they start the comment, `//` or `/* */`, and separate rule names with commas. `i68-ignore` covers its own line, `i68-ignore-next-line` the line after it, and `i68-ignore-file` the whole file. `i68-disable` covers everything after it until the matching `i68-enable`, or to the end of the file. A comment without rule names covers every rule.
|
|
69
|
+
|
|
70
|
+
## Programmatic use
|
|
71
|
+
|
|
72
|
+
`lint({ root, files, read, config })` lints files through your own `read`. `lintText({ path, text, config })` lints one song held in memory, for editors and tests. Both return diagnostics with `path`, `line`, `column`, `rule`, `severity`, `message` and `detail`.
|
|
73
|
+
|
|
74
|
+
## Presets
|
|
75
|
+
|
|
76
|
+
Pick the presets that match how you write, or take `pop` and `harmony` together with `recommended()`. Every rule warns rather than fails.
|
|
77
|
+
|
|
78
|
+
## pop
|
|
79
|
+
|
|
80
|
+
For songs with a lead vocal. `pop({ ranges, maxLeap, breathSeconds })`.
|
|
81
|
+
|
|
82
|
+
| Rule | What it catches | How to fix it |
|
|
83
|
+
| ----------------- | -------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------- |
|
|
84
|
+
| `pop/out-of-key` | A note outside both the key the section implies and the chord under it, except a short chromatic passing or neighbour note | Move it a semitone, or ignore the line if the borrowed note is intended |
|
|
85
|
+
| `pop/part-range` | A note outside its part's range (melody C3-C6, bass E1-C4 unless set per track) | Move the phrase an octave, or set `ranges` |
|
|
86
|
+
| `pop/melody-leap` | A melody jump over an octave | Make it smaller, or step back the other way right after it |
|
|
87
|
+
| `pop/breath` | A sung line longer than 8 seconds without a rest | Put a short rest in the phrase |
|
|
88
|
+
|
|
89
|
+
## harmony
|
|
90
|
+
|
|
91
|
+
How chords and parts sound together: voicing, spacing and clashes. `harmony()`.
|
|
92
|
+
|
|
93
|
+
| Rule | What it catches | How to fix it |
|
|
94
|
+
| ---------------------------- | ------------------------------------------------------------------------------------ | --------------------------------------------------------- |
|
|
95
|
+
| `harmony/semitone-clash` | Two parts a minor 2nd or minor 9th apart, except a dominant's flat 9th over its bass | Move one of them to a chord note |
|
|
96
|
+
| `harmony/low-interval-limit` | A close interval below the pitch where it turns muddy (a 3rd below C3) | Widen it or move the upper note up an octave |
|
|
97
|
+
| `harmony/crowded-low-mids` | More than 3 notes at once between A2 and B3 | Thin the chord or move notes out of that range |
|
|
98
|
+
| `harmony/chord-above-melody` | A harmony part above the lead melody | Keep the chord below the melody |
|
|
99
|
+
| `harmony/voice-jump` | A chord voice that leaps more than a major 3rd into the next chord | Keep shared notes and move each voice to the nearest note |
|
|
100
|
+
|
|
101
|
+
## classical
|
|
102
|
+
|
|
103
|
+
Common-practice part writing, off unless you add it. `classical()`.
|
|
104
|
+
|
|
105
|
+
| Rule | What it catches | How to fix it |
|
|
106
|
+
| --------------------------------- | ---------------------------------------------------------------- | ------------------------------ |
|
|
107
|
+
| `classical/parallel-perfects` | Melody and bass moving in parallel fifths or octaves | Move one of them the other way |
|
|
108
|
+
| `classical/unresolved-dissonance` | A dissonant melody note on a strong beat that does not step down | Move the next note down a step |
|
|
109
|
+
|
|
110
|
+
## progressions
|
|
111
|
+
|
|
112
|
+
Points out well-known chord progressions so you can see where a song leans on one. `progressions()`.
|
|
113
|
+
|
|
114
|
+
| Rule | What it catches | How to fix it |
|
|
115
|
+
| -------------------- | ------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------ |
|
|
116
|
+
| `progressions/named` | Marusa (IVM7 III7 VIm7), Oudou (IV V IIIm VIm), Komuro (VIm IV V I), Canon, ii–V–I and Andalusian | Nothing to fix; change a chord if you do not want that progression |
|
|
117
|
+
|
|
118
|
+
Matching ignores sevenths, so IV V IIIm VIm and IVM7 V7 IIIm7 VIm7 are both Oudou. `PROGRESSIONS` lists them.
|
|
119
|
+
|
|
120
|
+
## bach
|
|
121
|
+
|
|
122
|
+
Compares each chord change with what Bach did in his 370 four-part chorales. `bach()`.
|
|
123
|
+
|
|
124
|
+
| Rule | What it catches | How to fix it |
|
|
125
|
+
| ---------------------- | --------------------------------------------------------------------------------- | -------------------------------------------------------- |
|
|
126
|
+
| `bach/rare-transition` | A chord change that Bach makes less than 3% of the time after the same 1-3 chords | Use one of the chords the detail says Bach usually picks |
|
|
127
|
+
|
|
128
|
+
Chords are read as degrees of the key each section implies, so the table works in any key. Minor keys are read as their relative major. The rule looks at the last 1-3 chords and uses the longest of them that the table has seen at least 8 times. Set `["warn", { share, seen }]` to change both numbers.
|
|
129
|
+
|
|
130
|
+
The table in `src/app/presets/features/check-style/data/bach-chorales.json` holds only counts of chord transitions. `vp run build-style-tables` builds it from the Humdrum kern files of [craigsapp/bach-370-chorales](https://github.com/craigsapp/bach-370-chorales). The scores themselves are not in this package. For another composer, build a `StyleTable` the same way and pass it to `stylePluginOf(table)`.
|
|
131
|
+
|
|
132
|
+
Rules find parts by the `role` of their track (`melody`, `countermelody`, `harmony`, `bass`, `drums`), so give each track a role.
|
|
133
|
+
|
|
134
|
+
## Agent skills
|
|
135
|
+
|
|
136
|
+
The package ships agent skills in `skills/`. Add `permissions: { "@r_masseater/i68": { skills: true } }` to `pnpm-workspace.yaml` and `vp install` links them into the skill directories of your agents.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"app-J9_4mtbE.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,15 @@
|
|
|
1
|
+
import { c as runCli$1, n as songPathspecs, o as failedWith, r as lint, s as formatDiagnostic, t as i68Section } from "./section-C9JQ1-aJ.mjs";
|
|
2
|
+
// src/app/cli.ts
|
|
3
|
+
const runCli = () => {
|
|
4
|
+
runCli$1({
|
|
5
|
+
name: "i68",
|
|
6
|
+
section: i68Section,
|
|
7
|
+
pathspecs: songPathspecs,
|
|
8
|
+
lint,
|
|
9
|
+
format: formatDiagnostic,
|
|
10
|
+
failWith: failedWith
|
|
11
|
+
});
|
|
12
|
+
};
|
|
13
|
+
export { runCli };
|
|
14
|
+
|
|
15
|
+
//# sourceMappingURL=cli-CzV_7HHU.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli-CzV_7HHU.mjs","names":[],"sources":["../src/app/cli.ts"],"sourcesContent":["import { formatDiagnostic, runCli as runLinter } from \"@masseater.dev/lint-host\";\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 section: i68Section,\n pathspecs: songPathspecs,\n lint,\n format: formatDiagnostic,\n failWith: failedWith,\n });\n};\n"],"mappings":";;AAOA,MAAa,eAAqB;CAChC,SAAU;EACR,MAAM;EACN,SAAS;EACT,WAAW;EACX;EACA,QAAQ;EACR,UAAU;CACZ,CAAC;AACH"}
|
package/dist/cli.d.mts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {}
|
package/dist/cli.mjs
ADDED
package/dist/cli.mjs.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.mjs","names":[],"sources":["../bin/i68.ts"],"sourcesContent":["#!/usr/bin/env node\nimport { enableCompileCache } from \"node:module\";\n\nenableCompileCache();\n\nconst { runCli } = await import(\"#/app/cli.ts\");\n\nrunCli();\n"],"mappings":";;;AAGA,mBAAmB;AAEnB,MAAM,EAAE,WAAW,MAAM,OAAO;AAEhC,OAAO"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { a as StyleRulesSchema, c as subjectKeyOf, d as StyleTable, f as StyleTableSchema, i as StyleRules, l as MixHabit, m as Step, n as HabitKind, o as Subject, r as HabitRule, s as SubjectSchema, t as HABIT_KINDS, u as mixKeyOf } from "./style-rules-gR1Cixel.mjs";
|
|
2
|
+
import { Effect, Schema } from "effect";
|
|
3
|
+
import { Song } from "@r_masseater/song-format";
|
|
4
|
+
import { Sounding } from "@r_masseater/song-format/analysis";
|
|
5
|
+
interface MixPlace {
|
|
6
|
+
readonly bar: number;
|
|
7
|
+
readonly line: number;
|
|
8
|
+
readonly column: number;
|
|
9
|
+
}
|
|
10
|
+
interface MixFact {
|
|
11
|
+
readonly habit: MixHabit;
|
|
12
|
+
readonly place: MixPlace;
|
|
13
|
+
}
|
|
14
|
+
interface StyleSong {
|
|
15
|
+
readonly name: string;
|
|
16
|
+
readonly steps: readonly Step[];
|
|
17
|
+
readonly mix: readonly MixFact[];
|
|
18
|
+
}
|
|
19
|
+
interface HabitLimits {
|
|
20
|
+
readonly songs: number;
|
|
21
|
+
readonly share: number;
|
|
22
|
+
readonly baseline: number;
|
|
23
|
+
readonly seen: number;
|
|
24
|
+
}
|
|
25
|
+
export declare const DEFAULT_LIMITS: HabitLimits;
|
|
26
|
+
interface Place {
|
|
27
|
+
readonly song: string;
|
|
28
|
+
readonly bar: number;
|
|
29
|
+
readonly line: number;
|
|
30
|
+
readonly column: number;
|
|
31
|
+
}
|
|
32
|
+
interface Habit {
|
|
33
|
+
readonly context: string;
|
|
34
|
+
readonly next: string;
|
|
35
|
+
readonly songs: number;
|
|
36
|
+
readonly count: number;
|
|
37
|
+
readonly share: number;
|
|
38
|
+
readonly baselineShare: number;
|
|
39
|
+
readonly evidence: readonly Place[];
|
|
40
|
+
}
|
|
41
|
+
interface HabitInput {
|
|
42
|
+
readonly songs: readonly StyleSong[];
|
|
43
|
+
readonly baseline: StyleTable;
|
|
44
|
+
readonly limits: HabitLimits;
|
|
45
|
+
}
|
|
46
|
+
export declare const habitsOf: ({ songs, baseline, limits }: HabitInput) => readonly Habit[];
|
|
47
|
+
declare const UnreadableSong_base: Schema.Class<UnreadableSong, Schema.TaggedStruct<"UnreadableSong", {
|
|
48
|
+
readonly message: Schema.String;
|
|
49
|
+
}>, import("effect/Cause").YieldableError & {
|
|
50
|
+
readonly brand: unique symbol;
|
|
51
|
+
}>;
|
|
52
|
+
export declare class UnreadableSong extends UnreadableSong_base {}
|
|
53
|
+
interface SongText {
|
|
54
|
+
readonly name: string;
|
|
55
|
+
readonly text: string;
|
|
56
|
+
}
|
|
57
|
+
export declare const styleSongFromText: (args_0: SongText) => Effect.Effect<StyleSong, UnreadableSong, never>;
|
|
58
|
+
interface MixHabitFound {
|
|
59
|
+
readonly habit: MixHabit;
|
|
60
|
+
readonly key: string;
|
|
61
|
+
readonly songs: number;
|
|
62
|
+
readonly count: number;
|
|
63
|
+
readonly evidence: readonly Place[];
|
|
64
|
+
}
|
|
65
|
+
interface MixHabitInput {
|
|
66
|
+
readonly songs: readonly StyleSong[];
|
|
67
|
+
readonly minSongs: number;
|
|
68
|
+
}
|
|
69
|
+
export declare const mixHabitsOf: ({ songs, minSongs }: MixHabitInput) => readonly MixHabitFound[];
|
|
70
|
+
export declare const BACH_TABLE: StyleTable;
|
|
71
|
+
export { HABIT_KINDS, type Habit, type HabitInput, type HabitKind, type HabitLimits, type HabitRule, type MixHabit, type MixHabitFound, type Place, type SongText, type StyleRules, StyleRulesSchema, type StyleSong, type StyleTable, StyleTableSchema, type Subject, SubjectSchema, mixKeyOf, subjectKeyOf };
|
|
72
|
+
//# sourceMappingURL=habits.d.mts.map
|
package/dist/habits.mjs
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { a as StyleRulesSchema, c as mixKeyOf, d as bach_chorales_default, f as progressionOf, i as HABIT_KINDS, l as StyleTableSchema, o as SubjectSchema, s as subjectKeyOf, t as mixFactsOf, u as longestContext } from "./mix-facts-CvX18d2q.mjs";
|
|
2
|
+
import { Array, Effect, Number, Option, Order, Record, Schema, String, pipe } from "effect";
|
|
3
|
+
import { readSong } from "@r_masseater/song-format";
|
|
4
|
+
import { soundingsOf } from "@r_masseater/song-format/analysis";
|
|
5
|
+
// src/app/presets/features/find-habits/model/habits.ts
|
|
6
|
+
const FIRST = 1;
|
|
7
|
+
const NEVER = 0;
|
|
8
|
+
const DEFAULT_LIMITS = {
|
|
9
|
+
songs: 2,
|
|
10
|
+
share: .3,
|
|
11
|
+
baseline: .03,
|
|
12
|
+
seen: 8
|
|
13
|
+
};
|
|
14
|
+
const occurrencesIn = (baseline, limits) => (song) => pipe(Array.drop(Array.makeBy(song.steps.length, (index) => index), FIRST), Array.flatMap((index) => {
|
|
15
|
+
const step = Array.getUnsafe(song.steps, index);
|
|
16
|
+
return pipe(longestContext({
|
|
17
|
+
table: baseline,
|
|
18
|
+
seen: limits.seen
|
|
19
|
+
})(Array.take(song.steps, index)), Option.map((context) => ({
|
|
20
|
+
context: context.words,
|
|
21
|
+
next: step.token,
|
|
22
|
+
baselineShare: Option.getOrElse(Record.get(context.next, step.token), () => NEVER) / context.total,
|
|
23
|
+
place: {
|
|
24
|
+
song: song.name,
|
|
25
|
+
bar: step.bar,
|
|
26
|
+
line: step.line,
|
|
27
|
+
column: step.column
|
|
28
|
+
}
|
|
29
|
+
})), Option.filter((occurrence) => occurrence.baselineShare < limits.baseline), Option.toArray);
|
|
30
|
+
}));
|
|
31
|
+
const matches = (tokens, words) => Array.join(tokens, " ") === words;
|
|
32
|
+
const styleShareOf = (songs) => (context, next) => {
|
|
33
|
+
const { length } = String.split(" ")(context);
|
|
34
|
+
const following = pipe(songs, Array.flatMap((song) => {
|
|
35
|
+
const tokens = pipe(song.steps, Array.map((step) => step.token));
|
|
36
|
+
return pipe(Array.makeBy(tokens.length, (index) => index), Array.filter((index) => index >= length && matches(tokens.slice(index - length, index), context)), Array.map((index) => Array.getUnsafe(tokens, index)));
|
|
37
|
+
}));
|
|
38
|
+
return Array.countBy(following, (token) => token === next) / following.length;
|
|
39
|
+
};
|
|
40
|
+
const habitOf = (share) => (same) => {
|
|
41
|
+
const first = Array.headNonEmpty(same);
|
|
42
|
+
return {
|
|
43
|
+
context: first.context,
|
|
44
|
+
next: first.next,
|
|
45
|
+
songs: pipe(same, Array.map((occurrence) => occurrence.place.song), Array.dedupe, Array.length),
|
|
46
|
+
count: same.length,
|
|
47
|
+
share: share(first.context, first.next),
|
|
48
|
+
baselineShare: first.baselineShare,
|
|
49
|
+
evidence: pipe(same, Array.map((occurrence) => occurrence.place))
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
const byReach$1 = Order.combine(Order.mapInput(Number.Order, (habit) => -habit.songs), Order.mapInput(Number.Order, (habit) => -habit.count));
|
|
53
|
+
const habitsOf = ({ songs, baseline, limits }) => {
|
|
54
|
+
const toHabit = habitOf(styleShareOf(songs));
|
|
55
|
+
return pipe(songs, Array.flatMap(occurrencesIn(baseline, limits)), Array.groupBy((occurrence) => `${occurrence.context}\u0000${occurrence.next}`), Record.values, Array.map(toHabit), Array.filter((habit) => habit.songs >= limits.songs && habit.share >= limits.share), Array.sortBy(byReach$1));
|
|
56
|
+
};
|
|
57
|
+
// src/app/presets/features/find-habits/model/read.ts
|
|
58
|
+
const taggedError = Schema.TaggedError;
|
|
59
|
+
var UnreadableSong = class extends taggedError()("UnreadableSong", { message: Schema.String }, { identifier: "UnreadableSong" }) {};
|
|
60
|
+
const styleSongFromText = Effect.fn("styleSongFromText")(function* styleSongFromText({ name, text }) {
|
|
61
|
+
const source = yield* readSong({
|
|
62
|
+
path: `/${name}.fumx`,
|
|
63
|
+
read: () => Effect.succeed(text)
|
|
64
|
+
});
|
|
65
|
+
if (source.status === "invalid") return yield* UnreadableSong.make({ message: `${name} is not a song i68 can read` });
|
|
66
|
+
const soundings = soundingsOf(source.song);
|
|
67
|
+
return {
|
|
68
|
+
name,
|
|
69
|
+
steps: progressionOf(soundings)(source.song),
|
|
70
|
+
mix: mixFactsOf(soundings)(source.song)
|
|
71
|
+
};
|
|
72
|
+
});
|
|
73
|
+
// src/app/presets/features/find-habits/model/mix-habits.ts
|
|
74
|
+
const seenIn = (song) => pipe(song.mix, Array.map((fact) => ({
|
|
75
|
+
habit: fact.habit,
|
|
76
|
+
key: mixKeyOf(fact.habit),
|
|
77
|
+
place: {
|
|
78
|
+
song: song.name,
|
|
79
|
+
...fact.place
|
|
80
|
+
}
|
|
81
|
+
})));
|
|
82
|
+
const foundOf = (same) => {
|
|
83
|
+
const first = Array.headNonEmpty(same);
|
|
84
|
+
return {
|
|
85
|
+
habit: first.habit,
|
|
86
|
+
key: first.key,
|
|
87
|
+
songs: pipe(same, Array.map((seen) => seen.place.song), Array.dedupe, Array.length),
|
|
88
|
+
count: same.length,
|
|
89
|
+
evidence: pipe(same, Array.map((seen) => seen.place))
|
|
90
|
+
};
|
|
91
|
+
};
|
|
92
|
+
const byReach = Order.combine(Order.mapInput(Order.Number, (found) => -found.songs), Order.mapInput(Order.Number, (found) => -found.count));
|
|
93
|
+
const mixHabitsOf = ({ songs, minSongs }) => pipe(songs, Array.flatMap(seenIn), Array.groupBy((seen) => seen.key), Record.values, Array.map(foundOf), Array.filter((found) => found.songs >= minSongs), Array.sortBy(byReach));
|
|
94
|
+
// src/app/habits.ts
|
|
95
|
+
const BACH_TABLE = bach_chorales_default;
|
|
96
|
+
export { BACH_TABLE, DEFAULT_LIMITS, HABIT_KINDS, StyleRulesSchema, StyleTableSchema, SubjectSchema, UnreadableSong, habitsOf, mixHabitsOf, mixKeyOf, styleSongFromText, subjectKeyOf };
|
|
97
|
+
|
|
98
|
+
//# sourceMappingURL=habits.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"habits.mjs","names":["Arr","Rec","Str","byReach","Num","Arr","Rec","BACH_CHORALES"],"sources":["../src/app/presets/features/find-habits/model/habits.ts","../src/app/presets/features/find-habits/model/read.ts","../src/app/presets/features/find-habits/model/mix-habits.ts","../src/app/habits.ts"],"sourcesContent":["import {\n Array as Arr,\n Number as Num,\n Option,\n Order,\n Record as Rec,\n String as Str,\n pipe,\n} from \"effect\";\n\nimport type { Step } from \"#/app/presets/shared/lib/degrees.ts\";\nimport type { MixFact } from \"#/app/presets/shared/lib/mix-facts.ts\";\nimport { longestContext } from \"#/app/presets/shared/lib/style-table.ts\";\nimport type { StyleTable } from \"#/app/presets/shared/lib/style-table.ts\";\n\nconst FIRST = 1;\nconst NEVER = 0;\n\nexport interface StyleSong {\n readonly name: string;\n readonly steps: readonly Step[];\n readonly mix: readonly MixFact[];\n}\n\nexport interface HabitLimits {\n readonly songs: number;\n readonly share: number;\n readonly baseline: number;\n readonly seen: number;\n}\n\nexport const DEFAULT_LIMITS: HabitLimits = { songs: 2, share: 0.3, baseline: 0.03, seen: 8 };\n\nexport interface Place {\n readonly song: string;\n readonly bar: number;\n readonly line: number;\n readonly column: number;\n}\n\nexport interface Habit {\n readonly context: string;\n readonly next: string;\n readonly songs: number;\n readonly count: number;\n readonly share: number;\n readonly baselineShare: number;\n readonly evidence: readonly Place[];\n}\n\nexport interface HabitInput {\n readonly songs: readonly StyleSong[];\n readonly baseline: StyleTable;\n readonly limits: HabitLimits;\n}\n\ninterface Occurrence {\n readonly context: string;\n readonly next: string;\n readonly baselineShare: number;\n readonly place: Place;\n}\n\nconst occurrencesIn =\n (baseline: StyleTable, limits: HabitLimits) =>\n (song: StyleSong): readonly Occurrence[] =>\n pipe(\n Arr.drop(\n Arr.makeBy(song.steps.length, (index) => index),\n FIRST,\n ),\n Arr.flatMap((index) => {\n const step = Arr.getUnsafe(song.steps, index);\n return pipe(\n longestContext({ table: baseline, seen: limits.seen })(Arr.take(song.steps, index)),\n Option.map((context) => ({\n context: context.words,\n next: step.token,\n baselineShare:\n Option.getOrElse(Rec.get(context.next, step.token), () => NEVER) / context.total,\n place: { song: song.name, bar: step.bar, line: step.line, column: step.column },\n })),\n Option.filter((occurrence) => occurrence.baselineShare < limits.baseline),\n Option.toArray,\n );\n }),\n );\n\nconst matches = (tokens: readonly string[], words: string): boolean =>\n Arr.join(tokens, \" \") === words;\n\nconst styleShareOf =\n (songs: readonly StyleSong[]) =>\n (context: string, next: string): number => {\n const { length } = Str.split(\" \")(context);\n const following = pipe(\n songs,\n Arr.flatMap((song) => {\n const tokens = pipe(\n song.steps,\n Arr.map((step) => step.token),\n );\n return pipe(\n Arr.makeBy(tokens.length, (index) => index),\n Arr.filter(\n (index) => index >= length && matches(tokens.slice(index - length, index), context),\n ),\n Arr.map((index) => Arr.getUnsafe(tokens, index)),\n );\n }),\n );\n return Arr.countBy(following, (token) => token === next) / following.length;\n };\n\nconst habitOf =\n (share: (context: string, next: string) => number) =>\n (same: Arr.NonEmptyReadonlyArray<Occurrence>): Habit => {\n const first = Arr.headNonEmpty(same);\n return {\n context: first.context,\n next: first.next,\n songs: pipe(\n same,\n Arr.map((occurrence) => occurrence.place.song),\n Arr.dedupe,\n Arr.length,\n ),\n count: same.length,\n share: share(first.context, first.next),\n baselineShare: first.baselineShare,\n evidence: pipe(\n same,\n Arr.map((occurrence) => occurrence.place),\n ),\n };\n };\n\nconst byReach = Order.combine(\n Order.mapInput(Num.Order, (habit: Habit) => -habit.songs),\n Order.mapInput(Num.Order, (habit: Habit) => -habit.count),\n);\n\nexport const habitsOf = ({ songs, baseline, limits }: HabitInput): readonly Habit[] => {\n const toHabit = habitOf(styleShareOf(songs));\n return pipe(\n songs,\n Arr.flatMap(occurrencesIn(baseline, limits)),\n Arr.groupBy((occurrence) => `${occurrence.context}\\u0000${occurrence.next}`),\n Rec.values,\n Arr.map(toHabit),\n Arr.filter((habit) => habit.songs >= limits.songs && habit.share >= limits.share),\n Arr.sortBy(byReach),\n );\n};\n","import { readSong } from \"@r_masseater/song-format\";\nimport { soundingsOf } from \"@r_masseater/song-format/analysis\";\nimport { Effect, Schema } from \"effect\";\n\nimport { progressionOf } from \"#/app/presets/shared/lib/degrees.ts\";\nimport { mixFactsOf } from \"#/app/presets/shared/lib/mix-facts.ts\";\n\nimport type { StyleSong } from \"./habits.ts\";\n\nconst taggedError = Schema.TaggedError;\n\nexport class UnreadableSong extends taggedError<\n UnreadableSong,\n { readonly brand: unique symbol }\n>()(\"UnreadableSong\", { message: Schema.String }, { identifier: \"UnreadableSong\" }) {}\n\nexport interface SongText {\n readonly name: string;\n readonly text: string;\n}\n\nexport const styleSongFromText = Effect.fn(\"styleSongFromText\")(function* styleSongFromText({\n name,\n text,\n}: SongText) {\n const source = yield* readSong({ path: `/${name}.fumx`, read: () => Effect.succeed(text) });\n if (source.status === \"invalid\") {\n return yield* UnreadableSong.make({ message: `${name} is not a song i68 can read` });\n }\n const soundings = soundingsOf(source.song);\n const song: StyleSong = {\n name,\n steps: progressionOf(soundings)(source.song),\n mix: mixFactsOf(soundings)(source.song),\n };\n return song;\n});\n","import { Array as Arr, Order, Record as Rec, pipe } from \"effect\";\n\nimport { mixKeyOf } from \"#/app/presets/shared/lib/mix-habit.ts\";\nimport type { MixHabit } from \"#/app/presets/shared/lib/mix-habit.ts\";\n\nimport type { Place, StyleSong } from \"./habits.ts\";\n\nexport interface MixHabitFound {\n readonly habit: MixHabit;\n readonly key: string;\n readonly songs: number;\n readonly count: number;\n readonly evidence: readonly Place[];\n}\n\nexport interface MixHabitInput {\n readonly songs: readonly StyleSong[];\n readonly minSongs: number;\n}\n\ninterface Seen {\n readonly habit: MixHabit;\n readonly key: string;\n readonly place: Place;\n}\n\nconst seenIn = (song: StyleSong): readonly Seen[] =>\n pipe(\n song.mix,\n Arr.map((fact) => ({\n habit: fact.habit,\n key: mixKeyOf(fact.habit),\n place: { song: song.name, ...fact.place },\n })),\n );\n\nconst foundOf = (same: Arr.NonEmptyReadonlyArray<Seen>): MixHabitFound => {\n const first = Arr.headNonEmpty(same);\n return {\n habit: first.habit,\n key: first.key,\n songs: pipe(\n same,\n Arr.map((seen) => seen.place.song),\n Arr.dedupe,\n Arr.length,\n ),\n count: same.length,\n evidence: pipe(\n same,\n Arr.map((seen) => seen.place),\n ),\n };\n};\n\nconst byReach = Order.combine(\n Order.mapInput(Order.Number, (found: MixHabitFound) => -found.songs),\n Order.mapInput(Order.Number, (found: MixHabitFound) => -found.count),\n);\n\nexport const mixHabitsOf = ({ songs, minSongs }: MixHabitInput): readonly MixHabitFound[] =>\n pipe(\n songs,\n Arr.flatMap(seenIn),\n Arr.groupBy((seen) => seen.key),\n Rec.values,\n Arr.map(foundOf),\n Arr.filter((found) => found.songs >= minSongs),\n Arr.sortBy(byReach),\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\";\n\nexport {\n DEFAULT_LIMITS,\n UnreadableSong,\n habitsOf,\n mixHabitsOf,\n styleSongFromText,\n} from \"#/app/presets/features/find-habits/index.ts\";\nexport type {\n Habit,\n HabitInput,\n HabitLimits,\n MixHabitFound,\n Place,\n SongText,\n StyleSong,\n} from \"#/app/presets/features/find-habits/index.ts\";\nexport {\n HABIT_KINDS,\n StyleRulesSchema,\n SubjectSchema,\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 { StyleTableSchema } from \"#/app/presets/shared/lib/style-table.ts\";\nexport type { StyleTable } from \"#/app/presets/shared/lib/style-table.ts\";\n\nexport const BACH_TABLE: StyleTable = BACH_CHORALES;\n"],"mappings":"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"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { a as Rule, n as I68Config, r as Plugin, s as PathspecRequest, t as Diagnostic } from "./index-DB7buWb9.mjs";
|
|
2
|
+
import { Effect, Schema } from "effect";
|
|
3
|
+
import "@r_masseater/song-format";
|
|
4
|
+
interface Reportable {
|
|
5
|
+
readonly path: string;
|
|
6
|
+
readonly line: number;
|
|
7
|
+
readonly column?: number | undefined;
|
|
8
|
+
readonly rule: string;
|
|
9
|
+
readonly message: string;
|
|
10
|
+
readonly detail?: string | undefined;
|
|
11
|
+
readonly context?: string | undefined;
|
|
12
|
+
readonly severity: string;
|
|
13
|
+
}
|
|
14
|
+
declare const formatDiagnostic: (diagnostic: Reportable) => string;
|
|
15
|
+
interface Ignoring {
|
|
16
|
+
readonly ignores?: readonly string[] | undefined;
|
|
17
|
+
}
|
|
18
|
+
declare const defineRule: (rule: Rule) => Rule;
|
|
19
|
+
declare const definePlugin: (plugin: Plugin) => Plugin;
|
|
20
|
+
declare const I68Error_base: Schema.Class<I68Error, Schema.TaggedStruct<"I68Error", {
|
|
21
|
+
readonly message: Schema.String;
|
|
22
|
+
}>, import("effect/Cause").YieldableError & {
|
|
23
|
+
readonly brand: unique symbol;
|
|
24
|
+
}>;
|
|
25
|
+
declare class I68Error extends I68Error_base {}
|
|
26
|
+
type Read = (path: string) => Effect.Effect<string, I68Error>;
|
|
27
|
+
interface LintInput {
|
|
28
|
+
readonly root: string;
|
|
29
|
+
readonly files: readonly string[];
|
|
30
|
+
readonly read: Read;
|
|
31
|
+
readonly config?: I68Config;
|
|
32
|
+
}
|
|
33
|
+
interface TextInput {
|
|
34
|
+
readonly path: string;
|
|
35
|
+
readonly text: string;
|
|
36
|
+
readonly read?: Read;
|
|
37
|
+
readonly config?: I68Config;
|
|
38
|
+
}
|
|
39
|
+
declare const lint: (input: LintInput) => Effect.Effect<Diagnostic[], I68Error, never>;
|
|
40
|
+
declare const lintText: (input: TextInput) => Effect.Effect<Diagnostic[], I68Error, never>;
|
|
41
|
+
type PathspecInput = PathspecRequest<I68Config>;
|
|
42
|
+
declare const i68Section: (config: unknown) => I68Config;
|
|
43
|
+
declare const songPathspecs: ({ config, patterns }: {
|
|
44
|
+
readonly config: Ignoring;
|
|
45
|
+
readonly patterns?: readonly string[];
|
|
46
|
+
}) => readonly string[];
|
|
47
|
+
export { TextInput as a, Read as c, defineRule as d, formatDiagnostic as f, LintInput as i, I68Error as l, i68Section as n, lint as o, songPathspecs as r, lintText as s, PathspecInput as t, definePlugin as u };
|
|
48
|
+
//# sourceMappingURL=index-5D8Rm7JG.d.mts.map
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { Effect, FileSystem, Option, Path } from "effect";
|
|
2
|
+
import { Song } from "@r_masseater/song-format";
|
|
3
|
+
import { Sounding } from "@r_masseater/song-format/analysis";
|
|
4
|
+
type Severity = "off" | "warn" | "error";
|
|
5
|
+
type RuleOptions = Readonly<Record<string, unknown>>;
|
|
6
|
+
type RuleEntry = Severity | readonly [Severity] | readonly [Severity, RuleOptions];
|
|
7
|
+
interface PathspecRequest<Config> {
|
|
8
|
+
readonly config: Config;
|
|
9
|
+
readonly patterns?: readonly string[];
|
|
10
|
+
}
|
|
11
|
+
interface Report {
|
|
12
|
+
readonly message: string;
|
|
13
|
+
readonly line: number;
|
|
14
|
+
readonly column?: number;
|
|
15
|
+
readonly detail?: string;
|
|
16
|
+
}
|
|
17
|
+
interface RuleContext {
|
|
18
|
+
readonly filename: string;
|
|
19
|
+
readonly song: Song;
|
|
20
|
+
readonly soundings: readonly Sounding[];
|
|
21
|
+
readonly options: RuleOptions;
|
|
22
|
+
readonly report: (report: Report) => void;
|
|
23
|
+
}
|
|
24
|
+
interface Rule {
|
|
25
|
+
readonly meta: {
|
|
26
|
+
readonly description: string;
|
|
27
|
+
};
|
|
28
|
+
readonly check: (context: RuleContext) => void;
|
|
29
|
+
}
|
|
30
|
+
interface Plugin {
|
|
31
|
+
readonly rules: Readonly<Record<string, Rule>>;
|
|
32
|
+
}
|
|
33
|
+
interface I68Config {
|
|
34
|
+
readonly extends?: readonly I68Config[];
|
|
35
|
+
readonly plugins?: Readonly<Record<string, Plugin>>;
|
|
36
|
+
readonly rules?: Readonly<Record<string, RuleEntry>>;
|
|
37
|
+
readonly ignores?: readonly string[];
|
|
38
|
+
}
|
|
39
|
+
interface Diagnostic {
|
|
40
|
+
readonly path: string;
|
|
41
|
+
readonly line: number;
|
|
42
|
+
readonly column?: number;
|
|
43
|
+
readonly rule: string;
|
|
44
|
+
readonly message: string;
|
|
45
|
+
readonly detail?: string;
|
|
46
|
+
readonly severity: Exclude<Severity, "off">;
|
|
47
|
+
}
|
|
48
|
+
export { Rule as a, RuleEntry as c, Report as i, RuleOptions as l, I68Config as n, RuleContext as o, Plugin as r, PathspecRequest as s, Diagnostic as t, Severity as u };
|
|
49
|
+
//# sourceMappingURL=index-DB7buWb9.d.mts.map
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { a as Rule, c as RuleEntry, i as Report, l as RuleOptions, n as I68Config, o as RuleContext, r as Plugin, t as Diagnostic, u as Severity } from "./index-DB7buWb9.mjs";
|
|
2
|
+
import { a as TextInput, c as Read, d as defineRule, f as formatDiagnostic, i as LintInput, l as I68Error, n as i68Section, o as lint, r as songPathspecs, s as lintText, t as PathspecInput, u as definePlugin } from "./index-5D8Rm7JG.mjs";
|
|
3
|
+
export { type Diagnostic, type I68Config, I68Error, type LintInput, type PathspecInput, type Plugin, type Read, type Report, type Rule, type RuleContext, type RuleEntry, type RuleOptions, type Severity, type TextInput, definePlugin, defineRule, formatDiagnostic as format, i68Section, lint, lintText, songPathspecs };
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { n as defineRule, t as definePlugin } from "./app-J9_4mtbE.mjs";
|
|
2
|
+
import { a as I68Error, i as lintText, n as songPathspecs, r as lint, s as formatDiagnostic, t as i68Section } from "./section-C9JQ1-aJ.mjs";
|
|
3
|
+
export { I68Error, definePlugin, defineRule, formatDiagnostic as format, i68Section, lint, lintText, songPathspecs };
|