@dxos/deus 0.0.0-stage → 0.0.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 +105 -0
- package/README.md +24 -2
- package/bin/deus.ts +42 -0
- package/dist/lib/chunk-blocks.mjs +151 -0
- package/dist/lib/chunk-blocks.mjs.map +1 -0
- package/dist/lib/chunk-check.mjs +452 -0
- package/dist/lib/chunk-check.mjs.map +1 -0
- package/dist/lib/chunk-completion.mjs +112 -0
- package/dist/lib/chunk-completion.mjs.map +1 -0
- package/dist/lib/chunk-extension.mjs +396 -0
- package/dist/lib/chunk-extension.mjs.map +1 -0
- package/dist/lib/chunk-parse.mjs +21 -0
- package/dist/lib/chunk-parse.mjs.map +1 -0
- package/dist/lib/cli.mjs +946 -0
- package/dist/lib/cli.mjs.map +1 -0
- package/dist/lib/extension.mjs +4 -0
- package/dist/lib/index.mjs +6 -0
- package/dist/lib/parse.mjs +4 -0
- package/dist/lib/review.mjs +260 -0
- package/dist/lib/review.mjs.map +1 -0
- package/dist/lib/spec-index.mjs +28 -0
- package/dist/lib/spec-index.mjs.map +1 -0
- package/dist/types/bin/deus.d.ts +3 -0
- package/dist/types/bin/deus.d.ts.map +1 -0
- package/dist/types/src/cli/__fixtures__/review/plugin-deps/dx.config.d.ts +8 -0
- package/dist/types/src/cli/__fixtures__/review/plugin-deps/dx.config.d.ts.map +1 -0
- package/dist/types/src/cli/__fixtures__/review/plugin-deps-diverged/dx.config.d.ts +8 -0
- package/dist/types/src/cli/__fixtures__/review/plugin-deps-diverged/dx.config.d.ts.map +1 -0
- package/dist/types/src/cli/__fixtures__/review/plugin-deps-empty/dx.config.d.ts +7 -0
- package/dist/types/src/cli/__fixtures__/review/plugin-deps-empty/dx.config.d.ts.map +1 -0
- package/dist/types/src/cli/__fixtures__/review/plugin-deps-mismatch/dx.config.d.ts +8 -0
- package/dist/types/src/cli/__fixtures__/review/plugin-deps-mismatch/dx.config.d.ts.map +1 -0
- package/dist/types/src/cli/__fixtures__/review/plugin-deps-noplugin/dx.config.d.ts +5 -0
- package/dist/types/src/cli/__fixtures__/review/plugin-deps-noplugin/dx.config.d.ts.map +1 -0
- package/dist/types/src/cli/changelog.d.ts +25 -0
- package/dist/types/src/cli/changelog.d.ts.map +1 -0
- package/dist/types/src/cli/cli.test.d.ts +2 -0
- package/dist/types/src/cli/cli.test.d.ts.map +1 -0
- package/dist/types/src/cli/errors.d.ts +183 -0
- package/dist/types/src/cli/errors.d.ts.map +1 -0
- package/dist/types/src/cli/features.d.ts +58 -0
- package/dist/types/src/cli/features.d.ts.map +1 -0
- package/dist/types/src/cli/git.d.ts +8 -0
- package/dist/types/src/cli/git.d.ts.map +1 -0
- package/dist/types/src/cli/index.d.ts +12 -0
- package/dist/types/src/cli/index.d.ts.map +1 -0
- package/dist/types/src/cli/lint.d.ts +17 -0
- package/dist/types/src/cli/lint.d.ts.map +1 -0
- package/dist/types/src/cli/qa-lint.d.ts +40 -0
- package/dist/types/src/cli/qa-lint.d.ts.map +1 -0
- package/dist/types/src/cli/qa.d.ts +86 -0
- package/dist/types/src/cli/qa.d.ts.map +1 -0
- package/dist/types/src/cli/review.d.ts +38 -0
- package/dist/types/src/cli/review.d.ts.map +1 -0
- package/dist/types/src/cli/spec-index.d.ts +17 -0
- package/dist/types/src/cli/spec-index.d.ts.map +1 -0
- package/dist/types/src/extension/blocks.d.ts +65 -0
- package/dist/types/src/extension/blocks.d.ts.map +1 -0
- package/dist/types/src/extension/check.d.ts +99 -0
- package/dist/types/src/extension/check.d.ts.map +1 -0
- package/dist/types/src/extension/check.test.d.ts +2 -0
- package/dist/types/src/extension/check.test.d.ts.map +1 -0
- package/dist/types/src/extension/code.d.ts +7 -0
- package/dist/types/src/extension/code.d.ts.map +1 -0
- package/dist/types/src/extension/complete.d.ts +6 -0
- package/dist/types/src/extension/complete.d.ts.map +1 -0
- package/dist/types/src/extension/completion.d.ts +10 -0
- package/dist/types/src/extension/completion.d.ts.map +1 -0
- package/dist/types/src/extension/constants.d.ts +6 -0
- package/dist/types/src/extension/constants.d.ts.map +1 -0
- package/dist/types/src/extension/fences.d.ts +10 -0
- package/dist/types/src/extension/fences.d.ts.map +1 -0
- package/dist/types/src/extension/gen/mdl.d.ts +3 -0
- package/dist/types/src/extension/gen/mdl.d.ts.map +1 -0
- package/dist/types/src/extension/gen/mdl.terms.d.ts +2 -0
- package/dist/types/src/extension/gen/mdl.terms.d.ts.map +1 -0
- package/dist/types/src/extension/index.d.ts +8 -0
- package/dist/types/src/extension/index.d.ts.map +1 -0
- package/dist/types/src/extension/language.d.ts +20 -0
- package/dist/types/src/extension/language.d.ts.map +1 -0
- package/dist/types/src/extension/lint.d.ts +8 -0
- package/dist/types/src/extension/lint.d.ts.map +1 -0
- package/dist/types/src/extension/parse.d.ts +6 -0
- package/dist/types/src/extension/parse.d.ts.map +1 -0
- package/dist/types/src/extension/parser.test.d.ts +2 -0
- package/dist/types/src/extension/parser.test.d.ts.map +1 -0
- package/dist/types/src/extension/refs.d.ts +32 -0
- package/dist/types/src/extension/refs.d.ts.map +1 -0
- package/dist/types/src/extension/refs.test.d.ts +2 -0
- package/dist/types/src/extension/refs.test.d.ts.map +1 -0
- package/dist/types/src/extension/syntax.d.ts +12 -0
- package/dist/types/src/extension/syntax.d.ts.map +1 -0
- package/dist/types/src/index.d.ts +3 -0
- package/dist/types/src/index.d.ts.map +1 -0
- package/dist/types/src/review/fields.d.ts +9 -0
- package/dist/types/src/review/fields.d.ts.map +1 -0
- package/dist/types/src/review/index.d.ts +5 -0
- package/dist/types/src/review/index.d.ts.map +1 -0
- package/dist/types/src/review/review.d.ts +70 -0
- package/dist/types/src/review/review.d.ts.map +1 -0
- package/dist/types/src/review/review.test.d.ts +2 -0
- package/dist/types/src/review/review.test.d.ts.map +1 -0
- package/dist/types/src/review/source-key.d.ts +35 -0
- package/dist/types/src/review/source-key.d.ts.map +1 -0
- package/dist/types/src/review/symbol.d.ts +17 -0
- package/dist/types/src/review/symbol.d.ts.map +1 -0
- package/dist/types/src/review/symbol.test.d.ts +2 -0
- package/dist/types/src/review/symbol.test.d.ts.map +1 -0
- package/dist/types/src/spec-index/index.d.ts +3 -0
- package/dist/types/src/spec-index/index.d.ts.map +1 -0
- package/dist/types/src/spec-index/parse.d.ts +11 -0
- package/dist/types/src/spec-index/parse.d.ts.map +1 -0
- package/dist/types/src/spec-index/spec-index.d.ts +21 -0
- package/dist/types/src/spec-index/spec-index.d.ts.map +1 -0
- package/dist/types/src/spec-index/spec-index.test.d.ts +2 -0
- package/dist/types/src/spec-index/spec-index.test.d.ts.map +1 -0
- package/dist/types/tsconfig.tsbuildinfo +1 -0
- package/docs/DESIGN.md +561 -0
- package/docs/IDIOMS.md +265 -0
- package/lang/PLUGIN-.template.mdl +115 -0
- package/lang/app.mdl +200 -0
- package/lang/changelog.mdl +184 -0
- package/lang/core.mdl +203 -0
- package/lang/examples/chess-1.mdl +149 -0
- package/lang/examples/chess-2.mdl +203 -0
- package/lang/examples/chess-3.mdl +231 -0
- package/lang/features.mdl +92 -0
- package/lang/plugin.mdl +59 -0
- package/lang/qa.mdl +383 -0
- package/lang/review.mdl +103 -0
- package/lang/sql.mdl +72 -0
- package/package.json +74 -3
- package/src/cli/__fixtures__/bad-decision.mdl +13 -0
- package/src/cli/__fixtures__/features/CYCLE.mdl +25 -0
- package/src/cli/__fixtures__/features/FEATURES.mdl +47 -0
- package/src/cli/__fixtures__/features/SPEC.mdl +22 -0
- package/src/cli/__fixtures__/features/SPEC.review.mdl +32 -0
- package/src/cli/__fixtures__/features/TASKS.md +5 -0
- package/src/cli/__fixtures__/lint-refs/SPEC.mdl +7 -0
- package/src/cli/__fixtures__/lint-refs/SPEC.review.mdl +7 -0
- package/src/cli/__fixtures__/qa-lint/packages/plugins/plugin-risky/PLUGIN.mdl +29 -0
- package/src/cli/__fixtures__/qa-list/plugin-sample/spec/PLUGIN.mdl +51 -0
- package/src/cli/__fixtures__/review/SPEC.mdl +23 -0
- package/src/cli/__fixtures__/review/SPEC.review.mdl +26 -0
- package/src/cli/__fixtures__/review/plugin-deps/PLUGIN.mdl +9 -0
- package/src/cli/__fixtures__/review/plugin-deps/PLUGIN.review.mdl +13 -0
- package/src/cli/__fixtures__/review/plugin-deps/dx.config.ts +10 -0
- package/src/cli/__fixtures__/review/plugin-deps-diverged/PLUGIN.mdl +9 -0
- package/src/cli/__fixtures__/review/plugin-deps-diverged/PLUGIN.review.mdl +14 -0
- package/src/cli/__fixtures__/review/plugin-deps-diverged/dx.config.ts +10 -0
- package/src/cli/__fixtures__/review/plugin-deps-empty/PLUGIN.mdl +9 -0
- package/src/cli/__fixtures__/review/plugin-deps-empty/PLUGIN.review.mdl +13 -0
- package/src/cli/__fixtures__/review/plugin-deps-empty/dx.config.ts +9 -0
- package/src/cli/__fixtures__/review/plugin-deps-mismatch/PLUGIN.mdl +9 -0
- package/src/cli/__fixtures__/review/plugin-deps-mismatch/PLUGIN.review.mdl +13 -0
- package/src/cli/__fixtures__/review/plugin-deps-mismatch/dx.config.ts +10 -0
- package/src/cli/__fixtures__/review/plugin-deps-noplugin/PLUGIN.mdl +9 -0
- package/src/cli/__fixtures__/review/plugin-deps-noplugin/PLUGIN.review.mdl +13 -0
- package/src/cli/__fixtures__/review/plugin-deps-noplugin/dx.config.ts +7 -0
- package/src/cli/changelog.ts +122 -0
- package/src/cli/cli.test.ts +359 -0
- package/src/cli/errors.ts +23 -0
- package/src/cli/features.ts +320 -0
- package/src/cli/git.ts +35 -0
- package/src/cli/index.ts +27 -0
- package/src/cli/lint.ts +75 -0
- package/src/cli/qa-lint.ts +206 -0
- package/src/cli/qa.ts +300 -0
- package/src/cli/review.ts +359 -0
- package/src/cli/spec-index.ts +54 -0
- package/src/extension/blocks.ts +169 -0
- package/src/extension/check.test.ts +629 -0
- package/src/extension/check.ts +552 -0
- package/src/extension/code.ts +99 -0
- package/src/extension/complete.ts +34 -0
- package/src/extension/completion.ts +64 -0
- package/src/extension/constants.ts +28 -0
- package/src/extension/fences.ts +270 -0
- package/src/extension/gen/mdl.terms.ts +16 -0
- package/src/extension/gen/mdl.ts +16 -0
- package/src/extension/index.ts +25 -0
- package/src/extension/language.ts +33 -0
- package/src/extension/lint.ts +19 -0
- package/src/extension/mdl.grammar +60 -0
- package/src/extension/parse.ts +31 -0
- package/src/extension/parser.test.ts +248 -0
- package/src/extension/refs.test.ts +95 -0
- package/src/extension/refs.ts +94 -0
- package/src/extension/syntax.ts +25 -0
- package/src/index.ts +6 -0
- package/src/review/fields.ts +31 -0
- package/src/review/index.ts +8 -0
- package/src/review/review.test.ts +111 -0
- package/src/review/review.ts +184 -0
- package/src/review/source-key.ts +63 -0
- package/src/review/symbol.test.ts +47 -0
- package/src/review/symbol.ts +96 -0
- package/src/spec-index/index.ts +6 -0
- package/src/spec-index/parse.ts +22 -0
- package/src/spec-index/spec-index.test.ts +56 -0
- package/src/spec-index/spec-index.ts +49 -0
|
@@ -0,0 +1,629 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2026 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { describe, test } from 'vitest';
|
|
6
|
+
|
|
7
|
+
import { indexSpecs } from '../spec-index/index.ts';
|
|
8
|
+
import { parseMdlBlocks } from './blocks.ts';
|
|
9
|
+
import { MISSING_DECISION, checkChangelogChange, isTrivialEdit, lintMdl, parseChangelog } from './check.ts';
|
|
10
|
+
|
|
11
|
+
const block = (body: string) => ['```mdl', body, '```', ''].join('\n');
|
|
12
|
+
|
|
13
|
+
const messages = (text: string) => lintMdl(text).map(({ message }) => message);
|
|
14
|
+
|
|
15
|
+
describe('mdl lint', () => {
|
|
16
|
+
test('unknown block type', ({ expect }) => {
|
|
17
|
+
expect(messages(block('widget W-1'))).toEqual([
|
|
18
|
+
'Unknown block type "widget". Declare it in the Extensions table or define it with an `ext` block.',
|
|
19
|
+
]);
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
describe('one block per fence', () => {
|
|
23
|
+
const lint = (text: string) =>
|
|
24
|
+
lintMdl(text)
|
|
25
|
+
.filter(({ source }) => source === 'mdl/block')
|
|
26
|
+
.map(({ from, message }) => ({ line: text.slice(0, from).split('\n').length, message }));
|
|
27
|
+
|
|
28
|
+
test('a second block header inside one fence', ({ expect }) => {
|
|
29
|
+
expect(lint(block('op create: Create.\n input: A\n\nop convert: Convert.\n input: B'))).toEqual([
|
|
30
|
+
{
|
|
31
|
+
line: 5,
|
|
32
|
+
message: 'A second block header (`op convert`) inside one fence; give each block its own ```mdl fence.',
|
|
33
|
+
},
|
|
34
|
+
]);
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
test('a body line at column 0 that is not a block type', ({ expect }) => {
|
|
38
|
+
expect(lint(block('type T\n desc: |\n text\nsurface prompt -> RoutineArticle'))).toEqual([]);
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
test('a block type inside an indented body', ({ expect }) => {
|
|
42
|
+
expect(lint(block('feat F-1: Feature.\n req:\n test the thing works\n type T'))).toEqual([]);
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
test('a term declared in the Extensions table', ({ expect }) => {
|
|
46
|
+
const extensions =
|
|
47
|
+
'## Extensions\n\n| Term | URI |\n|---|---|\n| `capability` | `org.dxos.mdl.capability@1.0` |\n\n';
|
|
48
|
+
expect(lint(extensions + block('capability A\n desc: x\n\ncapability B\n desc: y'))).toEqual([
|
|
49
|
+
{
|
|
50
|
+
line: 11,
|
|
51
|
+
message: 'A second block header (`capability B`) inside one fence; give each block its own ```mdl fence.',
|
|
52
|
+
},
|
|
53
|
+
]);
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
describe('decision', () => {
|
|
58
|
+
test('user decision', ({ expect }) => {
|
|
59
|
+
expect(messages(block('decision D-1: Use X.\n date: 2026-10-20\n by: user:a@b.org'))).toEqual([]);
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
test('agent decision with principal', ({ expect }) => {
|
|
63
|
+
expect(
|
|
64
|
+
messages(block('decision D-2: Use Y.\n by: agent:claude-code # ran the migration\n for: user:bob')),
|
|
65
|
+
).toEqual([]);
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
test('missing decider', ({ expect }) => {
|
|
69
|
+
expect(messages(block('decision D-1: Use X.\n date: 2026-10-20'))).toEqual([
|
|
70
|
+
'Decision is missing `by:` — name the user: or agent: that made it.',
|
|
71
|
+
]);
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
test('untyped decider', ({ expect }) => {
|
|
75
|
+
expect(messages(block('decision D-1: Use X.\n by: bob'))).toEqual([
|
|
76
|
+
'Decision `by: bob` must be `user:<handle>` or `agent:<name>`.',
|
|
77
|
+
]);
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
test('agent decision without principal', ({ expect }) => {
|
|
81
|
+
expect(messages(block('decision D-1: Use X.\n by: agent:claude-code'))).toEqual([
|
|
82
|
+
'Agent decision is missing `for:` — name the user: the agent acted for.',
|
|
83
|
+
]);
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
test('principal on a user decision', ({ expect }) => {
|
|
87
|
+
expect(messages(block('decision D-1: Use X.\n by: user:bob\n for: user:alice'))).toEqual([
|
|
88
|
+
'`for:` applies only to agent decisions.',
|
|
89
|
+
]);
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
test('principal must be a user', ({ expect }) => {
|
|
93
|
+
expect(messages(block('decision D-1: Use X.\n by: agent:a\n for: agent:b'))).toEqual([
|
|
94
|
+
'`for: agent:b` must be `user:<handle>`.',
|
|
95
|
+
]);
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
test('unclosed block at the end of the text', ({ expect }) => {
|
|
99
|
+
expect(messages('```mdl\ndecision D-1: Use X.\n by: user:bob\n')).toEqual([]);
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
test('unclosed block does not read the next block', ({ expect }) => {
|
|
103
|
+
expect(messages('```mdl\ndecision D-1: Use X.\n by: user:bob\n' + block('type T\n for: x'))).toEqual([]);
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
test('fields of a later block are not read', ({ expect }) => {
|
|
107
|
+
expect(messages(block('decision D-1: Use X.\n by: user:bob') + block('type T\n for: x'))).toEqual([]);
|
|
108
|
+
});
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
describe('question', () => {
|
|
112
|
+
test('agent question with principal', ({ expect }) => {
|
|
113
|
+
expect(messages(block('question Q-1: X or Y?\n by: agent:claude-code\n for: user:bob'))).toEqual([]);
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
test('agent question without principal', ({ expect }) => {
|
|
117
|
+
expect(messages(block('question Q-1: X or Y?\n by: agent:claude-code'))).toEqual([
|
|
118
|
+
'Agent question is missing `for:` — name the user: the agent acted for.',
|
|
119
|
+
]);
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
test('missing asker', ({ expect }) => {
|
|
123
|
+
expect(messages(block('question Q-1: X or Y?'))).toEqual([
|
|
124
|
+
'Question is missing `by:` — name the user: or agent: that made it.',
|
|
125
|
+
]);
|
|
126
|
+
});
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
describe('changelog change', () => {
|
|
130
|
+
const decision = (id: string, prose: string, extra = '') =>
|
|
131
|
+
block(`decision ${id}: ${prose}\n date: 2026-10-20\n by: user:bob${extra}`);
|
|
132
|
+
const spec = (body: string, ...entries: string[]) => `# Spec\n\n${body}\n\n## Changelog\n\n${entries.join('\n')}`;
|
|
133
|
+
const d1 = decision('D-1', 'Use X.');
|
|
134
|
+
const d2 = decision('D-2', 'Use Y.');
|
|
135
|
+
|
|
136
|
+
test('body change with a new decision', ({ expect }) => {
|
|
137
|
+
expect(checkChangelogChange(spec('X', d1), spec('X and Y', d1, d2))).toEqual([]);
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
test('body change without a decision', ({ expect }) => {
|
|
141
|
+
expect(checkChangelogChange(spec('X', d1), spec('X and Y', d1))).toEqual([MISSING_DECISION]);
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
test('typo fix without a decision', ({ expect }) => {
|
|
145
|
+
expect(checkChangelogChange(spec('The bord is drawn.', d1), spec('The board is drawn.\n', d1))).toEqual([]);
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
test('spec without a changelog section', ({ expect }) => {
|
|
149
|
+
expect(checkChangelogChange('# Spec\n\nX\n', '# Spec\n\nY\n')).toEqual([MISSING_DECISION]);
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
test('adding a changelog to an existing spec', ({ expect }) => {
|
|
153
|
+
expect(checkChangelogChange('# Spec\n\nX\n', spec('Y', d1))).toEqual([]);
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
test('decision only, such as an approval', ({ expect }) => {
|
|
157
|
+
expect(checkChangelogChange(spec('X', d1), spec('X', d1, decision('D-2', 'Approve [D-1].')))).toEqual([]);
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
test('new spec', ({ expect }) => {
|
|
161
|
+
expect(checkChangelogChange(undefined, spec('X', d1))).toEqual([]);
|
|
162
|
+
expect(checkChangelogChange(undefined, '# Spec\n')).toEqual([
|
|
163
|
+
'A new spec needs a `## Changelog` with at least one decision.',
|
|
164
|
+
]);
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
test('edited decision', ({ expect }) => {
|
|
168
|
+
expect(checkChangelogChange(spec('X', d1), spec('X', decision('D-1', 'Use Z.'), d2))).toEqual([
|
|
169
|
+
'Decision D-1 was edited — the changelog is append-only; supersede it instead.',
|
|
170
|
+
]);
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
test('removed decision', ({ expect }) => {
|
|
174
|
+
expect(checkChangelogChange(spec('X', d1, d2), spec('Y', d2, decision('D-3', 'Use Z.')))).toEqual([
|
|
175
|
+
'Decision D-1 was removed — the changelog is append-only; supersede it instead.',
|
|
176
|
+
]);
|
|
177
|
+
});
|
|
178
|
+
|
|
179
|
+
test('decision inserted before an existing one', ({ expect }) => {
|
|
180
|
+
expect(checkChangelogChange(spec('X', d1), spec('Y', d2, d1))).toEqual([
|
|
181
|
+
'Decisions must stay in order, with new ones appended last.',
|
|
182
|
+
]);
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
test('out of sequence id', ({ expect }) => {
|
|
186
|
+
expect(checkChangelogChange(spec('X', d1), spec('Y', d1, decision('D-3', 'Use Z.')))).toEqual([
|
|
187
|
+
'Decision D-3 is out of sequence — the next id is D-2.',
|
|
188
|
+
]);
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
test('supersedes an unknown decision', ({ expect }) => {
|
|
192
|
+
expect(
|
|
193
|
+
checkChangelogChange(spec('X', d1), spec('Y', d1, decision('D-2', 'Use Z.', '\n supersedes: D-9'))),
|
|
194
|
+
).toEqual(['Decision D-2 supersedes D-9, which is not in the changelog.']);
|
|
195
|
+
});
|
|
196
|
+
|
|
197
|
+
describe('questions', () => {
|
|
198
|
+
const question = (id: string, prose: string) =>
|
|
199
|
+
block(`question ${id}: ${prose}\n date: 2026-10-20\n by: agent:claude-code\n for: user:bob`);
|
|
200
|
+
const q1 = question('Q-1', 'X or Y?');
|
|
201
|
+
|
|
202
|
+
test('asking a question needs no decision', ({ expect }) => {
|
|
203
|
+
expect(checkChangelogChange(spec('X', d1), spec('X', d1, q1))).toEqual([]);
|
|
204
|
+
});
|
|
205
|
+
|
|
206
|
+
test('answering a question', ({ expect }) => {
|
|
207
|
+
expect(
|
|
208
|
+
checkChangelogChange(spec('X', d1, q1), spec('X', d1, q1, decision('D-2', 'Y.', '\n answers: Q-1'))),
|
|
209
|
+
).toEqual([]);
|
|
210
|
+
});
|
|
211
|
+
|
|
212
|
+
test('edited question', ({ expect }) => {
|
|
213
|
+
expect(checkChangelogChange(spec('X', d1, q1), spec('X', d1, question('Q-1', 'X or Z?')))).toEqual([
|
|
214
|
+
'Question Q-1 was edited — the changelog is append-only; ask a new question instead.',
|
|
215
|
+
]);
|
|
216
|
+
});
|
|
217
|
+
|
|
218
|
+
test('removed question', ({ expect }) => {
|
|
219
|
+
expect(checkChangelogChange(spec('X', d1, q1), spec('X', d1, d2))).toEqual([
|
|
220
|
+
'Question Q-1 was removed — the changelog is append-only; answer it with a decision instead.',
|
|
221
|
+
]);
|
|
222
|
+
});
|
|
223
|
+
|
|
224
|
+
test('out of sequence id', ({ expect }) => {
|
|
225
|
+
expect(checkChangelogChange(spec('X', d1, q1), spec('X', d1, q1, question('Q-3', 'Z?')))).toEqual([
|
|
226
|
+
'Question Q-3 is out of sequence — the next id is Q-2.',
|
|
227
|
+
]);
|
|
228
|
+
});
|
|
229
|
+
|
|
230
|
+
test('answers an unknown question', ({ expect }) => {
|
|
231
|
+
expect(checkChangelogChange(spec('X', d1), spec('X', d1, decision('D-2', 'Y.', '\n answers: Q-9')))).toEqual([
|
|
232
|
+
'Decision D-2 answers Q-9, which is not in the changelog.',
|
|
233
|
+
]);
|
|
234
|
+
});
|
|
235
|
+
|
|
236
|
+
test('a second answer must supersede the first', ({ expect }) => {
|
|
237
|
+
const a1 = decision('D-2', 'Y.', '\n answers: Q-1');
|
|
238
|
+
expect(
|
|
239
|
+
checkChangelogChange(spec('X', d1, q1, a1), spec('X', d1, q1, a1, decision('D-3', 'Z.', '\n answers: Q-1'))),
|
|
240
|
+
).toEqual(['Decision D-3 answers Q-1, which D-2 already answered — supersede D-2 instead.']);
|
|
241
|
+
expect(
|
|
242
|
+
checkChangelogChange(
|
|
243
|
+
spec('X', d1, q1, a1),
|
|
244
|
+
spec('X', d1, q1, a1, decision('D-3', 'Z.', '\n answers: Q-1\n supersedes: D-2')),
|
|
245
|
+
),
|
|
246
|
+
).toEqual([]);
|
|
247
|
+
});
|
|
248
|
+
});
|
|
249
|
+
|
|
250
|
+
test('decisions outside the changelog are examples', ({ expect }) => {
|
|
251
|
+
expect(
|
|
252
|
+
checkChangelogChange(spec(decision('D-7', 'Example.'), d1), spec(decision('D-7', 'Example.'), d1, d2)),
|
|
253
|
+
).toEqual([]);
|
|
254
|
+
});
|
|
255
|
+
});
|
|
256
|
+
|
|
257
|
+
describe('trivial edit', () => {
|
|
258
|
+
test('whitespace only', ({ expect }) => {
|
|
259
|
+
expect(isTrivialEdit('a b\nc', 'a b c\n')).toBe(true);
|
|
260
|
+
});
|
|
261
|
+
|
|
262
|
+
test('up to three small typo fixes', ({ expect }) => {
|
|
263
|
+
expect(isTrivialEdit('teh bord is recieved', 'the board is received')).toBe(true);
|
|
264
|
+
});
|
|
265
|
+
|
|
266
|
+
test('too many fixes', ({ expect }) => {
|
|
267
|
+
expect(isTrivialEdit('aa bb cc dd', 'ab bc cd de')).toBe(false);
|
|
268
|
+
});
|
|
269
|
+
|
|
270
|
+
test('a word added or removed', ({ expect }) => {
|
|
271
|
+
expect(isTrivialEdit('must move', 'must not move')).toBe(false);
|
|
272
|
+
});
|
|
273
|
+
|
|
274
|
+
test('a different word', ({ expect }) => {
|
|
275
|
+
expect(isTrivialEdit('white moves first', 'black moves first')).toBe(false);
|
|
276
|
+
});
|
|
277
|
+
|
|
278
|
+
test('normative words', ({ expect }) => {
|
|
279
|
+
expect(isTrivialEdit('you must move', 'you most move')).toBe(false);
|
|
280
|
+
expect(isTrivialEdit('it can move', "it can't move")).toBe(false);
|
|
281
|
+
});
|
|
282
|
+
|
|
283
|
+
test('short words', ({ expect }) => {
|
|
284
|
+
expect(isTrivialEdit('is on', 'in no')).toBe(false);
|
|
285
|
+
});
|
|
286
|
+
|
|
287
|
+
test('ids and numbers', ({ expect }) => {
|
|
288
|
+
expect(isTrivialEdit('see F-1.2', 'see F-1.3')).toBe(false);
|
|
289
|
+
expect(isTrivialEdit('max 8', 'max 9')).toBe(false);
|
|
290
|
+
});
|
|
291
|
+
});
|
|
292
|
+
|
|
293
|
+
describe('parse changelog', () => {
|
|
294
|
+
test('reads the fields of each decision', ({ expect }) => {
|
|
295
|
+
const text = [
|
|
296
|
+
'# Spec',
|
|
297
|
+
'',
|
|
298
|
+
'## Changelog',
|
|
299
|
+
'',
|
|
300
|
+
block(
|
|
301
|
+
[
|
|
302
|
+
'decision D-1: The canvas grows.',
|
|
303
|
+
' date: 2026-10-02',
|
|
304
|
+
' by: user:alice',
|
|
305
|
+
' quote: |',
|
|
306
|
+
' canvas should grow',
|
|
307
|
+
'',
|
|
308
|
+
' past the edge',
|
|
309
|
+
' affects: [Scene, F-2.1]',
|
|
310
|
+
].join('\n'),
|
|
311
|
+
),
|
|
312
|
+
block(
|
|
313
|
+
[
|
|
314
|
+
'decision D-2: Bounds grow to the major grid. Fills in [D-1].',
|
|
315
|
+
' date: 2026-10-02',
|
|
316
|
+
' by: agent:claude-code',
|
|
317
|
+
' for: user:alice',
|
|
318
|
+
' why: Keeps [D-1] cheap; see [D-1] and [D-2].',
|
|
319
|
+
' supersedes: D-1',
|
|
320
|
+
' rejected:',
|
|
321
|
+
' - Fixed padding: clips large nodes.',
|
|
322
|
+
' - Minor grid: re-lays on every drag.',
|
|
323
|
+
].join('\n'),
|
|
324
|
+
),
|
|
325
|
+
'## Appendix',
|
|
326
|
+
].join('\n');
|
|
327
|
+
|
|
328
|
+
const { entries } = parseChangelog(text);
|
|
329
|
+
expect(entries).toHaveLength(2);
|
|
330
|
+
expect(entries[0]).toMatchObject({
|
|
331
|
+
id: 'D-1',
|
|
332
|
+
title: 'The canvas grows.',
|
|
333
|
+
date: '2026-10-02',
|
|
334
|
+
by: 'user:alice',
|
|
335
|
+
quote: 'canvas should grow\n\npast the edge',
|
|
336
|
+
affects: ['Scene', 'F-2.1'],
|
|
337
|
+
refs: [],
|
|
338
|
+
rejected: [],
|
|
339
|
+
});
|
|
340
|
+
expect(entries[0].for).toBeUndefined();
|
|
341
|
+
expect(entries[1]).toMatchObject({
|
|
342
|
+
id: 'D-2',
|
|
343
|
+
by: 'agent:claude-code',
|
|
344
|
+
for: 'user:alice',
|
|
345
|
+
supersedes: 'D-1',
|
|
346
|
+
refs: ['D-1'],
|
|
347
|
+
rejected: ['Fixed padding: clips large nodes.', 'Minor grid: re-lays on every drag.'],
|
|
348
|
+
});
|
|
349
|
+
});
|
|
350
|
+
});
|
|
351
|
+
});
|
|
352
|
+
|
|
353
|
+
describe('parse changelog questions', () => {
|
|
354
|
+
test('reads the fields of each question and the answer of a decision', ({ expect }) => {
|
|
355
|
+
const text = [
|
|
356
|
+
'## Changelog',
|
|
357
|
+
'',
|
|
358
|
+
block(
|
|
359
|
+
[
|
|
360
|
+
'question Q-1: Does the canvas shrink?',
|
|
361
|
+
' date: 2026-10-06',
|
|
362
|
+
' by: agent:claude-code',
|
|
363
|
+
' for: user:alice',
|
|
364
|
+
' affects: [Scene]',
|
|
365
|
+
' context: Nothing says whether bounds shrink.',
|
|
366
|
+
' options:',
|
|
367
|
+
' - Never: the view never jumps.',
|
|
368
|
+
' - On drop',
|
|
369
|
+
].join('\n'),
|
|
370
|
+
),
|
|
371
|
+
block('decision D-1: Never.\n date: 2026-10-07\n by: user:alice\n answers: Q-1'),
|
|
372
|
+
].join('\n');
|
|
373
|
+
const { entries, questions } = parseChangelog(text);
|
|
374
|
+
expect(questions).toEqual([
|
|
375
|
+
expect.objectContaining({
|
|
376
|
+
id: 'Q-1',
|
|
377
|
+
title: 'Does the canvas shrink?',
|
|
378
|
+
by: 'agent:claude-code',
|
|
379
|
+
for: 'user:alice',
|
|
380
|
+
affects: ['Scene'],
|
|
381
|
+
context: 'Nothing says whether bounds shrink.',
|
|
382
|
+
options: [{ title: 'Never', description: 'the view never jumps.' }, { title: 'On drop' }],
|
|
383
|
+
}),
|
|
384
|
+
]);
|
|
385
|
+
expect(entries[0]).toMatchObject({ id: 'D-1', answers: 'Q-1' });
|
|
386
|
+
});
|
|
387
|
+
});
|
|
388
|
+
|
|
389
|
+
describe('parseMdlBlocks', () => {
|
|
390
|
+
test('reads type, id, title and body of every block', ({ expect }) => {
|
|
391
|
+
const text = [
|
|
392
|
+
'# Spec',
|
|
393
|
+
'',
|
|
394
|
+
'```mdl',
|
|
395
|
+
'type Call',
|
|
396
|
+
' fields:',
|
|
397
|
+
' name?: string',
|
|
398
|
+
'```',
|
|
399
|
+
'',
|
|
400
|
+
'```mdl',
|
|
401
|
+
'feat F-1: Start a call',
|
|
402
|
+
' req F-1.1: A Channel shows a call action.',
|
|
403
|
+
'```',
|
|
404
|
+
].join('\n');
|
|
405
|
+
const blocks = parseMdlBlocks(text);
|
|
406
|
+
expect(blocks.map(({ type, id, title }) => ({ type, id, title }))).toEqual([
|
|
407
|
+
{ type: 'type', id: 'Call', title: undefined },
|
|
408
|
+
{ type: 'feat', id: 'F-1', title: 'Start a call' },
|
|
409
|
+
]);
|
|
410
|
+
expect(blocks[0].body).toBe(' fields:\n name?: string\n');
|
|
411
|
+
});
|
|
412
|
+
|
|
413
|
+
test('ignores mdl fences inside an enclosing four-backtick or tilde fence', ({ expect }) => {
|
|
414
|
+
const text = [
|
|
415
|
+
'````md',
|
|
416
|
+
'```mdl',
|
|
417
|
+
'feat F-1: Example',
|
|
418
|
+
'```',
|
|
419
|
+
'````',
|
|
420
|
+
'',
|
|
421
|
+
'~~~md',
|
|
422
|
+
'```mdl',
|
|
423
|
+
'feat F-2: Example',
|
|
424
|
+
'```',
|
|
425
|
+
'~~~',
|
|
426
|
+
'',
|
|
427
|
+
'```mdl',
|
|
428
|
+
'feat F-3: Real',
|
|
429
|
+
' req F-3.1: A requirement.',
|
|
430
|
+
'```',
|
|
431
|
+
].join('\n');
|
|
432
|
+
const blocks = parseMdlBlocks(text);
|
|
433
|
+
expect(blocks.map(({ type, id }) => ({ type, id }))).toEqual([{ type: 'feat', id: 'F-3' }]);
|
|
434
|
+
expect(blocks[0].body).toBe(' req F-3.1: A requirement.\n');
|
|
435
|
+
});
|
|
436
|
+
|
|
437
|
+
test('a fence line with an info string does not end a block', ({ expect }) => {
|
|
438
|
+
const text = ['```mdl', 'feat F-1: Start', '```ts', 'code', '```'].join('\n');
|
|
439
|
+
const blocks = parseMdlBlocks(text);
|
|
440
|
+
expect(blocks).toHaveLength(1);
|
|
441
|
+
expect(blocks[0].body).toBe('```ts\ncode\n');
|
|
442
|
+
});
|
|
443
|
+
|
|
444
|
+
test('an unclosed block runs to the end of the text', ({ expect }) => {
|
|
445
|
+
const blocks = parseMdlBlocks(['```mdl', 'feat F-1: Start', ' req F-1.1: Open.'].join('\n'));
|
|
446
|
+
expect(blocks).toHaveLength(1);
|
|
447
|
+
expect(blocks[0].body).toBe(' req F-1.1: Open.');
|
|
448
|
+
});
|
|
449
|
+
});
|
|
450
|
+
|
|
451
|
+
describe('mdl references and dependencies', () => {
|
|
452
|
+
const other = (id: string, items: string) => ['---', `id: ${id}`, '---', '', block(items), ''].join('\n');
|
|
453
|
+
const index = indexSpecs([
|
|
454
|
+
{ path: 'a/SPEC.mdl', text: other('org.test.alpha', 'feat F-1: One\n req F-1.1: Do it') },
|
|
455
|
+
{ path: 'b/SPEC.mdl', text: other('org.test.beta', 'feat G-1: Other') },
|
|
456
|
+
{ path: 'c/SPEC.mdl', text: other('org.test.twice', 'feat T-1: Same') },
|
|
457
|
+
{ path: 'd/SPEC.mdl', text: other('org.test.twice', 'feat T-1: Same') },
|
|
458
|
+
]);
|
|
459
|
+
const spec = (body: string, frontmatter = 'id: org.test.self') => `---\n${frontmatter}\n---\n\n${body}\n`;
|
|
460
|
+
const uses = (id: string) => block(`uses ${id}: Why.`);
|
|
461
|
+
const lint = (text: string) => lintMdl(text, { index }).map(({ source, message }) => ({ source, message }));
|
|
462
|
+
|
|
463
|
+
test('unknown spec in a reference', ({ expect }) => {
|
|
464
|
+
expect(lint(spec('See org.test.nope#F-1.'))).toEqual([
|
|
465
|
+
{ source: 'mdl/ref', message: 'Unknown spec `org.test.nope`.' },
|
|
466
|
+
]);
|
|
467
|
+
});
|
|
468
|
+
|
|
469
|
+
test('missing item', ({ expect }) => {
|
|
470
|
+
expect(lint(spec(`${uses('org.test.alpha')}\nSee org.test.alpha#F-9.`))).toEqual([
|
|
471
|
+
{ source: 'mdl/ref', message: '`org.test.alpha` has no item `F-9`.' },
|
|
472
|
+
]);
|
|
473
|
+
});
|
|
474
|
+
|
|
475
|
+
test('item that exists', ({ expect }) => {
|
|
476
|
+
expect(lint(spec(`${uses('org.test.alpha')}\nSee org.test.alpha#F-1.1 and org.test.alpha#F-1.`))).toEqual([]);
|
|
477
|
+
});
|
|
478
|
+
|
|
479
|
+
test('reference to a spec that is not a dependency', ({ expect }) => {
|
|
480
|
+
expect(lint(spec('See org.test.alpha#F-1.'))).toEqual([
|
|
481
|
+
{
|
|
482
|
+
source: 'mdl/ref',
|
|
483
|
+
message: '`org.test.alpha` is not a dependency; add `uses org.test.alpha: …` under ## Dependencies.',
|
|
484
|
+
},
|
|
485
|
+
]);
|
|
486
|
+
});
|
|
487
|
+
|
|
488
|
+
test('github key to a spec', ({ expect }) => {
|
|
489
|
+
const message = 'Refer to a spec by id (`<id>#<item>`), not by a github: key.';
|
|
490
|
+
expect(lint(spec('See github:dxos/dxos/a/SPEC.mdl#F-1 and github:dxos/dxos/a/SPEC.mdl.'))).toEqual([
|
|
491
|
+
{ source: 'mdl/ref', message },
|
|
492
|
+
{ source: 'mdl/ref', message },
|
|
493
|
+
]);
|
|
494
|
+
});
|
|
495
|
+
|
|
496
|
+
test('github key to a spec in the changelog is kept', ({ expect }) => {
|
|
497
|
+
const message = 'Refer to a spec by id (`<id>#<item>`), not by a github: key.';
|
|
498
|
+
const text = spec(
|
|
499
|
+
[
|
|
500
|
+
'See github:dxos/dxos/a/SPEC.mdl#F-1.',
|
|
501
|
+
'',
|
|
502
|
+
'## Changelog',
|
|
503
|
+
'',
|
|
504
|
+
block('decision D-1: Uses github:dxos/dxos/a/SPEC.mdl#F-1.\n date: 2026-10-27\n by: user:alice'),
|
|
505
|
+
'',
|
|
506
|
+
'## Appendix',
|
|
507
|
+
'',
|
|
508
|
+
'See github:dxos/dxos/a/SPEC.mdl#F-1.',
|
|
509
|
+
].join('\n'),
|
|
510
|
+
);
|
|
511
|
+
expect(lint(text)).toEqual([
|
|
512
|
+
{ source: 'mdl/ref', message },
|
|
513
|
+
{ source: 'mdl/ref', message },
|
|
514
|
+
]);
|
|
515
|
+
});
|
|
516
|
+
|
|
517
|
+
test('github key to code is allowed', ({ expect }) => {
|
|
518
|
+
expect(lint(spec('See github:dxos/dxos/a/file.ts#Foo.'))).toEqual([]);
|
|
519
|
+
});
|
|
520
|
+
|
|
521
|
+
test('spec id declared by more than one file', ({ expect }) => {
|
|
522
|
+
const message = 'Spec id `org.test.twice` is declared by more than one file.';
|
|
523
|
+
expect(lint(spec(`${uses('org.test.twice')}\nSee org.test.twice#T-1.`))).toEqual([
|
|
524
|
+
{ source: 'mdl/uses', message },
|
|
525
|
+
{ source: 'mdl/ref', message },
|
|
526
|
+
]);
|
|
527
|
+
});
|
|
528
|
+
|
|
529
|
+
test('uses of an unknown spec', ({ expect }) => {
|
|
530
|
+
expect(lint(spec(uses('org.test.nope')))).toEqual([
|
|
531
|
+
{ source: 'mdl/uses', message: 'Unknown spec `org.test.nope`.' },
|
|
532
|
+
]);
|
|
533
|
+
});
|
|
534
|
+
|
|
535
|
+
test('uses declared twice', ({ expect }) => {
|
|
536
|
+
expect(lint(spec(`${uses('org.test.alpha')}\n${uses('org.test.alpha')}`))).toEqual([
|
|
537
|
+
{ source: 'mdl/uses', message: '`org.test.alpha` is declared twice.' },
|
|
538
|
+
]);
|
|
539
|
+
});
|
|
540
|
+
|
|
541
|
+
test('uses of itself', ({ expect }) => {
|
|
542
|
+
expect(lint(spec(uses('org.test.self')))).toEqual([{ source: 'mdl/uses', message: 'A spec cannot use itself.' }]);
|
|
543
|
+
});
|
|
544
|
+
|
|
545
|
+
test('uses an id already in dependsOn', ({ expect }) => {
|
|
546
|
+
const text = spec(`${block('plugin P: x\n dependsOn: [org.test.alpha]')}\n${uses('org.test.alpha')}`);
|
|
547
|
+
expect(lint(text)).toEqual([
|
|
548
|
+
{ source: 'mdl/uses', message: '`org.test.alpha` is in dependsOn; do not repeat it under uses.' },
|
|
549
|
+
]);
|
|
550
|
+
});
|
|
551
|
+
|
|
552
|
+
test('an id in dependsOn admits references to it', ({ expect }) => {
|
|
553
|
+
const text = spec(`${block('plugin P: x\n dependsOn: [org.test.alpha]')}\nSee org.test.alpha#F-1.`);
|
|
554
|
+
expect(lint(text)).toEqual([]);
|
|
555
|
+
});
|
|
556
|
+
|
|
557
|
+
test('a reference to an item of the spec itself is allowed', ({ expect }) => {
|
|
558
|
+
expect(lint(spec(`${block('feat X: One\n req X.1: Do it')}\nSee org.test.self#X and org.test.self#X.1.`))).toEqual(
|
|
559
|
+
[],
|
|
560
|
+
);
|
|
561
|
+
});
|
|
562
|
+
|
|
563
|
+
test('a reference to a missing item of the spec itself', ({ expect }) => {
|
|
564
|
+
expect(lint(spec('See org.test.self#X.'))).toEqual([
|
|
565
|
+
{ source: 'mdl/ref', message: '`org.test.self` has no item `X`.' },
|
|
566
|
+
]);
|
|
567
|
+
});
|
|
568
|
+
|
|
569
|
+
test('a cycle is allowed', ({ expect }) => {
|
|
570
|
+
const first = spec(`${uses('org.test.beta')}\nSee org.test.beta#G-1.`, 'id: org.test.alpha');
|
|
571
|
+
const second = spec(`${uses('org.test.alpha')}\nSee org.test.alpha#F-1.`, 'id: org.test.beta');
|
|
572
|
+
expect(lint(first)).toEqual([]);
|
|
573
|
+
expect(lint(second)).toEqual([]);
|
|
574
|
+
});
|
|
575
|
+
|
|
576
|
+
const dependsOn = (id: string) => block(`plugin P: x\n dependsOn: [${id}]`);
|
|
577
|
+
|
|
578
|
+
test('dependsOn of an unknown spec', ({ expect }) => {
|
|
579
|
+
expect(lint(spec(dependsOn('org.test.nope')))).toEqual([
|
|
580
|
+
{ source: 'mdl/uses', message: 'Unknown spec `org.test.nope`.' },
|
|
581
|
+
]);
|
|
582
|
+
});
|
|
583
|
+
|
|
584
|
+
test('dependsOn of itself', ({ expect }) => {
|
|
585
|
+
expect(lint(spec(dependsOn('org.test.self')))).toEqual([
|
|
586
|
+
{ source: 'mdl/uses', message: 'A spec cannot use itself.' },
|
|
587
|
+
]);
|
|
588
|
+
});
|
|
589
|
+
|
|
590
|
+
test('dependsOn declared twice', ({ expect }) => {
|
|
591
|
+
expect(lint(spec(dependsOn('org.test.alpha, org.test.alpha')))).toEqual([
|
|
592
|
+
{ source: 'mdl/uses', message: '`org.test.alpha` is declared twice.' },
|
|
593
|
+
]);
|
|
594
|
+
});
|
|
595
|
+
|
|
596
|
+
test('dependsOn of an ambiguous spec', ({ expect }) => {
|
|
597
|
+
expect(lint(spec(dependsOn('org.test.twice')))).toEqual([
|
|
598
|
+
{ source: 'mdl/uses', message: 'Spec id `org.test.twice` is declared by more than one file.' },
|
|
599
|
+
]);
|
|
600
|
+
});
|
|
601
|
+
|
|
602
|
+
test('github key boundary', ({ expect }) => {
|
|
603
|
+
expect(lint(spec('See github:o/r/a/file.mdl.ts#X and github:o/r/a/file.mdlx.'))).toEqual([]);
|
|
604
|
+
});
|
|
605
|
+
|
|
606
|
+
test('a candidate outside the indexed namespaces is prose', ({ expect }) => {
|
|
607
|
+
expect(lint(spec('See gmail-sync.test.ts#Foo and app.bsky.feed.defs#post.'))).toEqual([]);
|
|
608
|
+
});
|
|
609
|
+
|
|
610
|
+
test('a typo in an indexed namespace is an unknown spec', ({ expect }) => {
|
|
611
|
+
expect(lint(spec('See org.test.typo#X.'))).toEqual([
|
|
612
|
+
{ source: 'mdl/ref', message: 'Unknown spec `org.test.typo`.' },
|
|
613
|
+
]);
|
|
614
|
+
});
|
|
615
|
+
|
|
616
|
+
test('a spec whose own id is declared by more than one file', ({ expect }) => {
|
|
617
|
+
const text = spec('Body.', 'id: org.test.twice');
|
|
618
|
+
const [diagnostic] = lintMdl(text, { index });
|
|
619
|
+
expect(diagnostic).toMatchObject({
|
|
620
|
+
source: 'mdl/uses',
|
|
621
|
+
message: 'Spec id `org.test.twice` is declared by more than one file.',
|
|
622
|
+
});
|
|
623
|
+
expect(text.slice(diagnostic.from, diagnostic.to)).toBe('id: org.test.twice');
|
|
624
|
+
});
|
|
625
|
+
|
|
626
|
+
test('emits no ref or uses diagnostics without an index', ({ expect }) => {
|
|
627
|
+
expect(lintMdl(spec(`${uses('org.test.nope')}\nSee org.test.nope#F-1 and github:a/b.mdl.`))).toEqual([]);
|
|
628
|
+
});
|
|
629
|
+
});
|