glosslint 0.0.0 → 0.1.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 ADDED
@@ -0,0 +1,120 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 onmax
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
+ tinyaml/js-yaml, tinyaml/js-yaml-v5, tinyaml/yaml, tinyaml/yamljs and tinyaml/std
26
+ reproduce the behaviour, messages and parts of the code of the libraries they
27
+ replace. Their licenses and copyright notices follow.
28
+
29
+ ---
30
+
31
+ js-yaml (versions 4 and 5)
32
+
33
+ (The MIT License)
34
+
35
+ Copyright (C) 2011-2015 by Vitaly Puzrin
36
+
37
+ Permission is hereby granted, free of charge, to any person obtaining a copy
38
+ of this software and associated documentation files (the "Software"), to deal
39
+ in the Software without restriction, including without limitation the rights
40
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
41
+ copies of the Software, and to permit persons to whom the Software is
42
+ furnished to do so, subject to the following conditions:
43
+
44
+ The above copyright notice and this permission notice shall be included in
45
+ all copies or substantial portions of the Software.
46
+
47
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
48
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
49
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
50
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
51
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
52
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
53
+ THE SOFTWARE.
54
+
55
+ ---
56
+
57
+ yaml
58
+
59
+ Copyright Eemeli Aro <eemeli@gmail.com>
60
+
61
+ Permission to use, copy, modify, and/or distribute this software for any purpose
62
+ with or without fee is hereby granted, provided that the above copyright notice
63
+ and this permission notice appear in all copies.
64
+
65
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
66
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
67
+ FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
68
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
69
+ OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
70
+ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
71
+ THIS SOFTWARE.
72
+
73
+ ---
74
+
75
+ yamljs
76
+
77
+ Copyright (c) 2010 Jeremy Faivre
78
+
79
+ Permission is hereby granted, free of charge, to any person obtaining a copy
80
+ of this software and associated documentation files (the "Software"), to deal
81
+ in the Software without restriction, including without limitation the rights
82
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
83
+ copies of the Software, and to permit persons to whom the Software is furnished
84
+ to do so, subject to the following conditions:
85
+
86
+ The above copyright notice and this permission notice shall be included in all
87
+ copies or substantial portions of the Software.
88
+
89
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
90
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
91
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
92
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
93
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
94
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
95
+ THE SOFTWARE.
96
+ ---
97
+
98
+ @std/yaml
99
+
100
+ MIT License
101
+
102
+ Copyright 2018-2022 the Deno authors.
103
+
104
+ Permission is hereby granted, free of charge, to any person obtaining a copy
105
+ of this software and associated documentation files (the "Software"), to deal
106
+ in the Software without restriction, including without limitation the rights
107
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
108
+ copies of the Software, and to permit persons to whom the Software is
109
+ furnished to do so, subject to the following conditions:
110
+
111
+ The above copyright notice and this permission notice shall be included in all
112
+ copies or substantial portions of the Software.
113
+
114
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
115
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
116
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
117
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
118
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
119
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
120
+ SOFTWARE.
package/NOTICE ADDED
@@ -0,0 +1,31 @@
1
+ glosslint
2
+ Copyright (c) 2026 onmax
3
+
4
+ This package includes third-party data. Its notices follow.
5
+
6
+ ---
7
+
8
+ src/presets/tech-data.ts is generated from the dictionaries of case-police
9
+ (https://github.com/antfu/case-police), version 2.2.1, under the MIT License:
10
+
11
+ MIT License
12
+
13
+ Copyright (c) 2021 Anthony Fu <https://github.com/antfu>
14
+
15
+ Permission is hereby granted, free of charge, to any person obtaining a copy
16
+ of this software and associated documentation files (the "Software"), to deal
17
+ in the Software without restriction, including without limitation the rights
18
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
19
+ copies of the Software, and to permit persons to whom the Software is
20
+ furnished to do so, subject to the following conditions:
21
+
22
+ The above copyright notice and this permission notice shall be included in all
23
+ copies or substantial portions of the Software.
24
+
25
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
26
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
27
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
28
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
29
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
30
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
31
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,99 @@
1
- # glosslint
1
+ <h1><img src="./.github/assets/banner.svg" alt="glosslint" width="100%"></h1>
2
2
 
3
- Placeholder. The first release comes from https://github.com/onmax/glosslint.
3
+ <!-- automd:comark-badges packages=glosslint -->
4
+
5
+ [![npm version](https://comark-ui.onmax.me/badge.svg?source=npm-version&package=glosslint&label=glosslint&icon=npm)](https://www.npmjs.com/package/glosslint)
6
+ [![npm downloads](https://comark-ui.onmax.me/badge.svg?source=npm-downloads&package=glosslint&period=month&icon=npm)](https://www.npmjs.com/package/glosslint)
7
+ [![CI](https://comark-ui.onmax.me/badge.svg?source=github-actions&repository=onmax%2Fglosslint&workflow=pkg-pr-new.yml&icon=github)](https://github.com/onmax/glosslint/actions/workflows/pkg-pr-new.yml)
8
+ [![license: MIT](https://comark-ui.onmax.me/badge.svg?label=license&value=MIT)](./LICENSE)
9
+
10
+ <!-- /automd -->
11
+
12
+ [![docs](https://comark-ui.onmax.me/badge.svg?label=docs&value=glosslint.onmax.me)](https://glosslint.onmax.me)
13
+
14
+ glosslint checks your product's vocabulary against one Markdown file, `.agents/glossary.md`. People and coding agents read that file directly, while ESLint, Oxlint, x18n and the CLI enforce it on code, translations and docs. Every finding carries the reason and meaning alongside the fix.
15
+
16
+ [Docs](https://glosslint.onmax.me) · [Installation](https://glosslint.onmax.me/guide/installation) · [The glossary file](https://glosslint.onmax.me/guide/glossary) · [ESLint](https://glosslint.onmax.me/integrations/eslint) · [Oxlint](https://glosslint.onmax.me/integrations/oxlint) · [x18n](https://glosslint.onmax.me/integrations/x18n) · [CLI](https://glosslint.onmax.me/integrations/cli) · [For agents](https://glosslint.onmax.me/guide/agents)
17
+
18
+ ## The glossary
19
+
20
+ Write your product's terms in `.agents/glossary.md`. This excerpt comes from the bike-share app in [`examples/basic/.agents/glossary.md`](https://github.com/onmax/glosslint/blob/main/examples/basic/.agents/glossary.md):
21
+
22
+ <!-- prettier-ignore -->
23
+ ```md
24
+ # Glossary
25
+
26
+ The words the rider app and the help center use.
27
+
28
+ Extends: tech, inclusive
29
+ Allow: check out our, roof rack
30
+
31
+ ## Dock
32
+ What: A powered stand where one bike is locked.
33
+ How: A station is a group of docks.
34
+ Avoid:
35
+ - rack: Racks are unpowered.
36
+ - bay
37
+ Good:
38
+ - Return the bike to any dock
39
+ Bad:
40
+ - Return the bike to any rack
41
+ Links:
42
+ - [Docks](https://example.com/docs/docks)
43
+
44
+ ## eBike
45
+
46
+ ## Day Pass (DP)
47
+ Case: context
48
+ ```
49
+
50
+ `eBike` gets `Case: exact` automatically because of its inner capital. `Day Pass (DP)` sets the abbreviation `DP` and enforces Title Case in labels and lowercase in sentences. Every runner reads `.agents/glossary.md` by default; `defineCorpus` in `glosslint.config.ts` is available when you need fields such as `skip`, `forms` or `translations`.
51
+
52
+ ## Install
53
+
54
+ ```sh
55
+ pnpm add -D glosslint
56
+ ```
57
+
58
+ glosslint requires Node 22.18 or later. ESLint (`>=9.15.0`), Oxlint (`>=1.94.0`) and `@x18n/core` (`>=0.1.14`) are optional peer dependencies. Install only the ones you use.
59
+
60
+ ## One finding
61
+
62
+ Run the CLI on Markdown docs:
63
+
64
+ ```sh
65
+ npx glosslint check docs/guide
66
+ ```
67
+
68
+ Here is one finding from `examples/basic`:
69
+
70
+ ```txt
71
+ [GLOSSLINT_AVOID] "rack" in docs/guide/riding.md:3:56
72
+ ├▶ why: Racks are unpowered.
73
+ ├▶ fix: Use "dock": "Unlock a bike at any station, then return it to a free dock when you finish."
74
+ ├▶ term: Dock, a powered stand where one bike is locked.
75
+ ╰▶ see: https://example.com/docs/docks
76
+ ```
77
+
78
+ ## Where it checks
79
+
80
+ - [ESLint](https://glosslint.onmax.me/integrations/eslint): `glosslint()` reads `.agents/glossary.md` with no options and checks strings, comments and identifiers in JavaScript, TypeScript and Vue templates, plus YAML locale values.
81
+ - [Oxlint](https://glosslint.onmax.me/integrations/oxlint): add `"glosslint/oxlint"` to `jsPlugins` in `.oxlintrc.json` to run the four rules on JavaScript, TypeScript and Vue `<script>` blocks (Oxlint JS plugins are alpha).
82
+ - [x18n](https://glosslint.onmax.me/integrations/x18n): check source-locale messages and hard-coded strings, and pass the corpus to `toX18nGlossary` for x18n's glossary.
83
+ - [CLI](https://glosslint.onmax.me/integrations/cli): checks Markdown, MDX and text files, tests term examples, prints corpora and explains words from the terminal.
84
+
85
+ ## Doctor
86
+
87
+ `glosslint doctor` checks `.agents/glossary.md` for format mistakes, bad values, duplicate terms and failing `Good`/`Bad` examples. Pass `--fix` to rewrite fixable layout, heading and field-name issues into canonical form without dropping text:
88
+
89
+ ```sh
90
+ npx glosslint doctor --fix
91
+ ```
92
+
93
+ ## For agents
94
+
95
+ Coding agents read `.agents/glossary.md` directly, so link it from `AGENTS.md`. When an agent is unsure which word to use, `glosslint explain "<word>"` prints the term, its meaning, its usage notes and the words to avoid. [For agents](https://glosslint.onmax.me/guide/agents) covers the editing loop by `fix.kind`.
96
+
97
+ ## License
98
+
99
+ MIT. The tech preset includes data from case-police, also MIT. See [NOTICE](./NOTICE).
package/dist/cli.d.mts ADDED
@@ -0,0 +1,111 @@
1
+ import { t as GlossaryProblem } from "./glossary-DmTK_e1d.mjs";
2
+ import { c as Corpus, o as CliFinding, v as Matcher } from "./types-Bbp_cYfZ.mjs";
3
+ /** Where a command reads and writes, so tests can run commands without a process. */
4
+ export interface CliIo {
5
+ /** The folder paths and the config are resolved from. */
6
+ cwd: string;
7
+ stdout: (text: string) => void;
8
+ stderr: (text: string) => void;
9
+ /** Whether stdout is a terminal that takes colors, used when `--color` is not given. */
10
+ color?: boolean;
11
+ }
12
+ /** Options every command takes. */
13
+ export interface CommandOptions {
14
+ /** The config file. Default: `glosslint.config.{ts,mts,js,mjs}` in `cwd`. */
15
+ config?: string;
16
+ /** The glossary file, read when there is no `config`. Default: `.agents/glossary.md` in `cwd`. */
17
+ glossary?: string;
18
+ /** Color the output. Default: `io.color`. */
19
+ color?: boolean;
20
+ }
21
+ /** Options of `glosslint check`. */
22
+ export interface CheckOptions extends CommandOptions {
23
+ /** `text` (default) or `json`. */
24
+ format?: string;
25
+ /** File extensions read in folders, comma-separated. Default: `md,mdx,txt`. */
26
+ ext?: string;
27
+ }
28
+ /** Options of `glosslint print`. */
29
+ export interface PrintOptions extends CommandOptions {
30
+ /** `md` (default) or `json`. */
31
+ format?: string;
32
+ }
33
+ /** Options of `glosslint doctor`. */
34
+ export interface DoctorOptions {
35
+ /** The glossary file. Default: `.agents/glossary.md` in `cwd`. */
36
+ glossary?: string;
37
+ /** Rewrite the file in canonical form when that drops no text. */
38
+ fix?: boolean;
39
+ /** `text` (default) or `json`. */
40
+ format?: string;
41
+ /** Color the output. Default: `io.color`. */
42
+ color?: boolean;
43
+ }
44
+ /** One problem of the glossary, as `glosslint doctor --format json` prints it. */
45
+ export interface DoctorProblem extends GlossaryProblem {
46
+ /** The glossary, relative to `cwd`. */
47
+ file: string;
48
+ }
49
+ /** The JSON `glosslint doctor` prints: the problems left, and how many `--fix` fixed. */
50
+ export interface DoctorReport {
51
+ problems: DoctorProblem[];
52
+ summary: {
53
+ file: string;
54
+ problems: number;
55
+ fixable: number;
56
+ fixed: number;
57
+ };
58
+ }
59
+ /** Codes of the errors the CLI prints itself, next to the corpus's `GLOSSLINT_C00x`. */
60
+ export declare const CLI_ERRORS: {
61
+ readonly noConfig: "GLOSSLINT_C009";
62
+ readonly loadConfig: "GLOSSLINT_C010";
63
+ readonly notCorpus: "GLOSSLINT_C008";
64
+ readonly usage: "GLOSSLINT_USAGE";
65
+ readonly failed: "GLOSSLINT_ERROR";
66
+ };
67
+ /** What `loadCorpus` read: a config, or a glossary file it then never checks. */
68
+ export interface LoadedCorpus {
69
+ corpus: Corpus;
70
+ /** The absolute path of the file read. */
71
+ file: string;
72
+ from: "config" | "glossary";
73
+ }
74
+ /**
75
+ * Finds the corpus: `config`, else `glossary`, else `glosslint.config.{ts,mts,js,mjs}` in `cwd`, else
76
+ * `.agents/glossary.md` in `cwd`.
77
+ */
78
+ export declare function loadCorpus(cwd: string, options?: {
79
+ config?: string;
80
+ glossary?: string;
81
+ }): Promise<LoadedCorpus>;
82
+ /**
83
+ * Blanks what is not prose in Markdown, keeping every offset: frontmatter, fenced code, HTML
84
+ * comments and tags, inline code, link targets and references, and the markers of headings, lists
85
+ * and quotes. In MDX, `import` and `export` lines too.
86
+ */
87
+ export declare function maskMarkdown(text: string, options?: {
88
+ mdx?: boolean;
89
+ }): string;
90
+ /** Checks one file's text. Markdown is masked first, so code and link targets are never reported. */
91
+ export declare function checkFileText(matcher: Matcher, text: string, file: string, options?: {
92
+ markdown?: boolean;
93
+ mdx?: boolean;
94
+ }): CliFinding[];
95
+ /** The files `check` reads: named files as they are, folders by extension, and glob patterns. */
96
+ export declare function collectFiles(paths: readonly string[], cwd: string, extensions?: readonly string[]): Promise<string[]>;
97
+ /** `glosslint check`: reports every finding in the files, as text or JSON. Exits 1 on findings. */
98
+ export declare function runCheck(paths: readonly string[], options: CheckOptions, io: CliIo): Promise<number>;
99
+ /** `glosslint test`: checks every term's good and bad examples. Exits 1 when one fails. */
100
+ export declare function runTest(options: CommandOptions, io: CliIo): Promise<number>;
101
+ /** `glosslint print`: writes the corpus as a Markdown glossary or as JSON. */
102
+ export declare function runPrint(options: PrintOptions, io: CliIo): Promise<number>;
103
+ /** `glosslint explain`: what the corpus says about a word or phrase. Exits 1 when no term matches. */
104
+ export declare function runExplain(query: string, options: CommandOptions, io: CliIo): Promise<number>;
105
+ /**
106
+ * `glosslint doctor`: reports the problems of the glossary file, and with `fix` rewrites it in canonical
107
+ * form when no problem would drop text. Exits 0 with no problems left, 1 with problems, 2 with no file.
108
+ */
109
+ export declare function runDoctor(options: DoctorOptions, io: CliIo): Promise<number>;
110
+ /** Runs the CLI on `argv` (the arguments after the program name) and resolves to the exit code. */
111
+ export declare function main(argv: readonly string[], io?: CliIo): Promise<number>;