@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,359 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2026 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import * as NodeServices from '@effect/platform-node/NodeServices';
|
|
6
|
+
import * as CliError from 'effect/cli/CliError';
|
|
7
|
+
import * as Command from 'effect/cli/Command';
|
|
8
|
+
import * as ConfigProvider from 'effect/ConfigProvider';
|
|
9
|
+
import * as Console from 'effect/Console';
|
|
10
|
+
import * as Effect from 'effect/Effect';
|
|
11
|
+
import * as Exit from 'effect/Exit';
|
|
12
|
+
import * as FileSystem from 'effect/FileSystem';
|
|
13
|
+
import * as Path from 'effect/Path';
|
|
14
|
+
import { describe, test } from 'vitest';
|
|
15
|
+
|
|
16
|
+
import { git } from './git.ts';
|
|
17
|
+
import {
|
|
18
|
+
ChangelogCheckError,
|
|
19
|
+
FeatureCheckError,
|
|
20
|
+
LintError,
|
|
21
|
+
QaLintError,
|
|
22
|
+
ReviewCheckError,
|
|
23
|
+
checkChangelog,
|
|
24
|
+
configDependsOn,
|
|
25
|
+
deriveStatus,
|
|
26
|
+
deus,
|
|
27
|
+
} from './index.ts';
|
|
28
|
+
|
|
29
|
+
const FIXTURES = new URL('./__fixtures__/', import.meta.url).pathname;
|
|
30
|
+
const QA_LIST = `${FIXTURES}qa-list`;
|
|
31
|
+
const SAMPLE_SPEC = `${QA_LIST}/plugin-sample/spec/PLUGIN.mdl`;
|
|
32
|
+
|
|
33
|
+
/** Runs `deus <args>` and returns its exit and everything it printed. */
|
|
34
|
+
const run = (args: string[], env: Record<string, string> = {}) => {
|
|
35
|
+
const output: string[] = [];
|
|
36
|
+
const capture = (...values: ReadonlyArray<unknown>) => void output.push(values.join(' '));
|
|
37
|
+
const console: Console.Console = { ...globalThis.console, log: capture, error: capture };
|
|
38
|
+
return Command.runWith(deus, { version: 'test', renderErrors: false })(args).pipe(
|
|
39
|
+
Effect.exit,
|
|
40
|
+
Effect.map((exit) => ({ exit, output })),
|
|
41
|
+
Effect.provideService(Console.Console, console),
|
|
42
|
+
Effect.provideService(ConfigProvider.ConfigProvider, ConfigProvider.fromEnv({ env })),
|
|
43
|
+
Effect.provide(NodeServices.layer),
|
|
44
|
+
Effect.runPromise,
|
|
45
|
+
);
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
const failure = (exit: Exit.Exit<unknown, unknown>): unknown =>
|
|
49
|
+
Exit.isFailure(exit) ? exit.cause.reasons.find((reason) => reason._tag === 'Fail')?.error : undefined;
|
|
50
|
+
|
|
51
|
+
describe('deus command parsing', () => {
|
|
52
|
+
test('lint requires at least one file', async ({ expect }) => {
|
|
53
|
+
const { exit } = await run(['lint']);
|
|
54
|
+
expect(CliError.isCliError(failure(exit))).toBe(true);
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
test('qa list takes at most two positionals', async ({ expect }) => {
|
|
58
|
+
const { exit } = await run(['qa', 'list', 'markdown', 'QA-1', 'extra']);
|
|
59
|
+
expect(CliError.isCliError(failure(exit))).toBe(true);
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
test('an unknown subcommand is a usage error', async ({ expect }) => {
|
|
63
|
+
const { exit } = await run(['nope']);
|
|
64
|
+
expect(CliError.isCliError(failure(exit))).toBe(true);
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
test('--help lists every subcommand', async ({ expect }) => {
|
|
68
|
+
const { exit, output } = await run(['--help']);
|
|
69
|
+
expect(Exit.isSuccess(exit)).toBe(true);
|
|
70
|
+
const help = output.join('\n');
|
|
71
|
+
for (const name of ['changelog', 'features', 'lint', 'qa', 'review']) {
|
|
72
|
+
expect(help).toContain(name);
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
describe('deus lint', () => {
|
|
78
|
+
test('a clean spec passes', async ({ expect }) => {
|
|
79
|
+
const { exit } = await run(['lint', SAMPLE_SPEC]);
|
|
80
|
+
expect(Exit.isSuccess(exit)).toBe(true);
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
test('--only keeps one check and an error fails the run', async ({ expect }) => {
|
|
84
|
+
const file = `${FIXTURES}bad-decision.mdl`;
|
|
85
|
+
const { exit, output } = await run(['lint', '--only', 'mdl/decision', file]);
|
|
86
|
+
expect(LintError.is(failure(exit))).toBe(true);
|
|
87
|
+
expect(output.length).toBeGreaterThan(0);
|
|
88
|
+
for (const line of output) {
|
|
89
|
+
expect(line).toMatch(new RegExp(`^${file}:\\d+: error \\[mdl/decision\\]: `));
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
describe('deus lint references', () => {
|
|
95
|
+
const dir = `${FIXTURES}lint-refs`;
|
|
96
|
+
|
|
97
|
+
test('lint reports mdl/ref in a spec', async ({ expect }) => {
|
|
98
|
+
const { exit, output } = await run(['lint', '--only', 'mdl/ref', `${dir}/SPEC.mdl`]);
|
|
99
|
+
expect(LintError.is(failure(exit))).toBe(true);
|
|
100
|
+
expect(output).toEqual([`${dir}/SPEC.mdl:7: error [mdl/ref]: Unknown spec \`org.dxos.fixture.nope\`.`]);
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
test('lint skips mdl/ref in review files', async ({ expect }) => {
|
|
104
|
+
const { exit, output } = await run(['lint', `${dir}/SPEC.review.mdl`]);
|
|
105
|
+
expect(Exit.isSuccess(exit)).toBe(true);
|
|
106
|
+
expect(output).toEqual([]);
|
|
107
|
+
});
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
describe('deus qa list', () => {
|
|
111
|
+
test('lists the tests with their stage counts', async ({ expect }) => {
|
|
112
|
+
const { exit, output } = await run(['qa', 'list', '--root', QA_LIST]);
|
|
113
|
+
expect(Exit.isSuccess(exit)).toBe(true);
|
|
114
|
+
expect(output).toEqual([
|
|
115
|
+
' 1. sample:QA-1 unverified 2 steps (1 before, 1 after) Shows the greeting',
|
|
116
|
+
' plugin-sample/spec/PLUGIN.mdl covers: F-1.1',
|
|
117
|
+
' 2. sample:QA-2 verified 1 steps (0 before, 0 after) Hides the greeting',
|
|
118
|
+
' plugin-sample/spec/PLUGIN.mdl',
|
|
119
|
+
]);
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
test('<plugin> <testId> selects exactly one test', async ({ expect }) => {
|
|
123
|
+
const { output } = await run(['qa', 'list', '--root', QA_LIST, '--json', 'plugin-sample', 'qa-2']);
|
|
124
|
+
expect(JSON.parse(output.join('\n')).map(({ id }: { id: string }) => id)).toEqual(['QA-2']);
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
test('--tag resolves suite members in order and reports unresolved refs', async ({ expect }) => {
|
|
128
|
+
const { output } = await run(['qa', 'list', '--root', QA_LIST, '--json', '--tag', 'nightly']);
|
|
129
|
+
const rows: { plugin: string; id: string; status: string }[] = JSON.parse(output.join('\n'));
|
|
130
|
+
expect(rows.map(({ plugin, id, status }) => `${plugin}:${id}:${status}`)).toEqual([
|
|
131
|
+
'sample:QA-1:unverified',
|
|
132
|
+
'sample:QA-2:verified',
|
|
133
|
+
'other:QA-9:missing',
|
|
134
|
+
]);
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
test('--suites lists suites', async ({ expect }) => {
|
|
138
|
+
const { output } = await run(['qa', 'list', '--root', QA_LIST, '--suites']);
|
|
139
|
+
expect(output).toEqual([' 1. smoke 3 tests Smoke tests', ' plugin-sample/spec/PLUGIN.mdl tags: nightly']);
|
|
140
|
+
});
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
describe('deus qa lint', () => {
|
|
144
|
+
const root = `${FIXTURES}qa-lint`;
|
|
145
|
+
|
|
146
|
+
test('reports unbound references and unsafe teardowns', async ({ expect }) => {
|
|
147
|
+
const { exit, output } = await run(['qa', 'lint', '--root', root]);
|
|
148
|
+
expect(QaLintError.is(failure(exit))).toBe(true);
|
|
149
|
+
expect(output).toEqual([
|
|
150
|
+
'packages/plugins/plugin-risky/PLUGIN.mdl QA-1',
|
|
151
|
+
' L17 $given.document',
|
|
152
|
+
' L19 $orphan',
|
|
153
|
+
'\n1 tests with unbound references; 2 references total',
|
|
154
|
+
'packages/plugins/plugin-risky/PLUGIN.mdl QA-2 L28 resolves by index',
|
|
155
|
+
'\n1 teardown step(s) that could remove an object the run did not create',
|
|
156
|
+
]);
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
test('--check runs one lint', async ({ expect }) => {
|
|
160
|
+
const { output } = await run(['qa', 'lint', '--root', root, '--check', 'teardown']);
|
|
161
|
+
expect(output.join('\n')).not.toContain('unbound');
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
test('--check rejects an unknown lint', async ({ expect }) => {
|
|
165
|
+
const { exit } = await run(['qa', 'lint', '--root', root, '--check', 'nope']);
|
|
166
|
+
expect(CliError.isCliError(failure(exit))).toBe(true);
|
|
167
|
+
});
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
describe('deus review', () => {
|
|
171
|
+
const dir = `${FIXTURES}review`;
|
|
172
|
+
|
|
173
|
+
test('items lists reqs in place of their feat, plus other reviewed blocks', async ({ expect }) => {
|
|
174
|
+
const { exit, output } = await run(['review', 'items', `${dir}/SPEC.mdl`]);
|
|
175
|
+
expect(Exit.isSuccess(exit)).toBe(true);
|
|
176
|
+
expect(output.map((line) => line.split('\t').slice(0, 2).join(' '))).toEqual([
|
|
177
|
+
'F-1.1 req',
|
|
178
|
+
'F-1.2 req',
|
|
179
|
+
'Greet op',
|
|
180
|
+
'QA-1 test',
|
|
181
|
+
]);
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
test('check reports every broken verdict and each item without one', async ({ expect }) => {
|
|
185
|
+
const { exit, output } = await run(['review', 'check', `${dir}/SPEC.review.mdl`]);
|
|
186
|
+
expect(ReviewCheckError.is(failure(exit))).toBe(true);
|
|
187
|
+
const errors = output.filter((line) => line.startsWith('error: '));
|
|
188
|
+
expect(errors.map((line) => line.replace(/^error: .*?:\d+: /, ''))).toEqual([
|
|
189
|
+
'F-1.2 is partial but has no note saying what is missing or different',
|
|
190
|
+
'no declaration of noSuchSymbol in github:dxos/dxos/packages/reflect/deus/src/cli/review.ts (a mention is not evidence)',
|
|
191
|
+
'Greet has status `shiny`; use one of done, untested, partial, diverged, missing',
|
|
192
|
+
'key leaves the checkout: github:dxos/dxos/../outside.ts',
|
|
193
|
+
'QA-1 has no verdict',
|
|
194
|
+
]);
|
|
195
|
+
expect(output.at(-1)).toBe('3 verdicts for 4 items; 5 errors, 1 warnings.');
|
|
196
|
+
});
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
describe('review dependsOn', () => {
|
|
200
|
+
const dir = `${FIXTURES}review`;
|
|
201
|
+
|
|
202
|
+
test('configDependsOn parses the array', ({ expect }) => {
|
|
203
|
+
expect(configDependsOn('plugin: {\n dependsOn: [\'a.b\', "c.d"],\n}')).toEqual(['a.b', 'c.d']);
|
|
204
|
+
expect(configDependsOn('plugin: { dependsOn: [] }')).toEqual([]);
|
|
205
|
+
expect(configDependsOn('plugin: {}')).toEqual([]);
|
|
206
|
+
expect(configDependsOn("plugin: { key: 'x' }")).toEqual([]);
|
|
207
|
+
expect(configDependsOn("export default { name: 'x' }")).toBeUndefined();
|
|
208
|
+
expect(configDependsOn('plugin: { dependsOn: DEPS }')).toBeUndefined();
|
|
209
|
+
expect(configDependsOn("plugin: { dependsOn: [...BASE, 'x'] }")).toBeUndefined();
|
|
210
|
+
expect(configDependsOn("plugin: { dependsOn: ['a', B] }")).toBeUndefined();
|
|
211
|
+
expect(
|
|
212
|
+
configDependsOn(
|
|
213
|
+
"plugin: {\n // dependsOn: ['old'],\n dependsOn: [\n 'a',\n // 'x',\n 'b', /* 'y' */\n ],\n}",
|
|
214
|
+
),
|
|
215
|
+
).toEqual(['a', 'b']);
|
|
216
|
+
});
|
|
217
|
+
|
|
218
|
+
test('review check fails on a dependsOn mismatch judged done', async ({ expect }) => {
|
|
219
|
+
const { exit, output } = await run(['review', 'check', `${dir}/plugin-deps-mismatch/PLUGIN.review.mdl`]);
|
|
220
|
+
expect(ReviewCheckError.is(failure(exit))).toBe(true);
|
|
221
|
+
expect(
|
|
222
|
+
output.filter((line) => line.startsWith('error: ')).map((line) => line.replace(/^error: .*?:\d+: /, '')),
|
|
223
|
+
).toEqual([
|
|
224
|
+
'SamplePlugin dependsOn [org.example.plugin.a] differs from dx.config.ts [org.example.plugin.a, org.example.plugin.b]; judge it diverged',
|
|
225
|
+
]);
|
|
226
|
+
});
|
|
227
|
+
|
|
228
|
+
test('review check treats a config plugin without dependsOn as empty', async ({ expect }) => {
|
|
229
|
+
const { exit, output } = await run(['review', 'check', `${dir}/plugin-deps-empty/PLUGIN.review.mdl`]);
|
|
230
|
+
expect(ReviewCheckError.is(failure(exit))).toBe(true);
|
|
231
|
+
expect(
|
|
232
|
+
output.filter((line) => line.startsWith('error: ')).map((line) => line.replace(/^error: .*?:\d+: /, '')),
|
|
233
|
+
).toEqual(['SamplePlugin dependsOn [org.example.plugin.a] differs from dx.config.ts []; judge it diverged']);
|
|
234
|
+
});
|
|
235
|
+
|
|
236
|
+
test('review check passes when the mismatch is judged diverged, or the sets match', async ({ expect }) => {
|
|
237
|
+
for (const name of ['plugin-deps-diverged', 'plugin-deps', 'plugin-deps-noplugin']) {
|
|
238
|
+
const { exit, output } = await run(['review', 'check', `${dir}/${name}/PLUGIN.review.mdl`]);
|
|
239
|
+
expect(Exit.isSuccess(exit)).toBe(true);
|
|
240
|
+
expect(output.at(-1)).toMatch(/^1 verdicts for 1 items; 0 errors, /);
|
|
241
|
+
}
|
|
242
|
+
});
|
|
243
|
+
});
|
|
244
|
+
|
|
245
|
+
describe('deus features', () => {
|
|
246
|
+
const dir = `${FIXTURES}features`;
|
|
247
|
+
const map = `${dir}/FEATURES.mdl`;
|
|
248
|
+
/** Drops the `<map>:<line>: ` prefix so assertions read as the message. */
|
|
249
|
+
const message = (line: string) => line.replace(/^(warning|error): .*?\.mdl(?::\d+)?: /, '$1: ');
|
|
250
|
+
|
|
251
|
+
test('status follows the verdicts of the cited items', ({ expect }) => {
|
|
252
|
+
expect(deriveStatus(['done', 'done'])).toBe('operational');
|
|
253
|
+
expect(deriveStatus(['done', 'untested'])).toBe('prototype');
|
|
254
|
+
expect(deriveStatus(['missing', 'missing'])).toBe('planned');
|
|
255
|
+
expect(deriveStatus(['done', 'missing'])).toBe('in-progress');
|
|
256
|
+
expect(deriveStatus(['diverged'])).toBe('in-progress');
|
|
257
|
+
expect(deriveStatus(['done', undefined])).toBe('unreviewed');
|
|
258
|
+
expect(deriveStatus([])).toBe('unreviewed');
|
|
259
|
+
});
|
|
260
|
+
|
|
261
|
+
test('check derives each status and reports what is wrong or out of step', async ({ expect }) => {
|
|
262
|
+
const { exit, output } = await run(['features', 'check', '--map', map]);
|
|
263
|
+
expect(FeatureCheckError.is(failure(exit))).toBe(true);
|
|
264
|
+
expect(output.filter((line) => !line.startsWith('warning') && !line.startsWith('error'))).toEqual([
|
|
265
|
+
'listing\toperational\toperational\t2/2 done',
|
|
266
|
+
'greeting\toperational\tprototype\t0/1 done',
|
|
267
|
+
'listing-next\tplanned\tplanned\t0/1 done',
|
|
268
|
+
'export\tin-progress\tplanned\t0/1 done',
|
|
269
|
+
'ghost\tshiny\tunreviewed\t0/0 done',
|
|
270
|
+
'5 features; 4 errors, 4 warnings.',
|
|
271
|
+
]);
|
|
272
|
+
expect(output.filter((line) => /^(warning|error)/.test(line)).map(message)).toEqual([
|
|
273
|
+
expect.stringMatching(/^warning: listing: the review of .*SPEC\.mdl names a commit not in this clone$/),
|
|
274
|
+
'warning: greeting: marked operational but its reviews say prototype',
|
|
275
|
+
'warning: export: marked in-progress but its reviews say planned',
|
|
276
|
+
'warning: export: partly built with no work planned: no TASKS.md beside its spec has a `## export` section',
|
|
277
|
+
'error: ghost: status `shiny`; use one of planned, in-progress, prototype, operational, failing',
|
|
278
|
+
'error: export: depends on unknown feature nobody',
|
|
279
|
+
expect.stringMatching(/^error: ghost: .*SPEC\.mdl#F-9 names no reviewable item of the spec$/),
|
|
280
|
+
expect.stringMatching(/^error: ghost: spec not found: .*NOPE\.mdl$/),
|
|
281
|
+
]);
|
|
282
|
+
});
|
|
283
|
+
|
|
284
|
+
test('check rejects a dependency cycle', async ({ expect }) => {
|
|
285
|
+
const { exit, output } = await run(['features', 'check', '--map', `${dir}/CYCLE.mdl`]);
|
|
286
|
+
expect(FeatureCheckError.is(failure(exit))).toBe(true);
|
|
287
|
+
expect(output.filter((line) => line.startsWith('error')).map(message)).toEqual([
|
|
288
|
+
'error: dependency cycle: first -> second -> first',
|
|
289
|
+
]);
|
|
290
|
+
});
|
|
291
|
+
|
|
292
|
+
test('tasks lists the open items of one feature with their verdicts', async ({ expect }) => {
|
|
293
|
+
const { exit, output } = await run(['features', 'tasks', '--map', map, 'export']);
|
|
294
|
+
expect(Exit.isSuccess(exit)).toBe(true);
|
|
295
|
+
expect(output.filter((line) => line.startsWith('- ['))).toEqual([
|
|
296
|
+
'- [ ] F-2.1: The CLI exports items as JSON. (missing: No exporter exists.)',
|
|
297
|
+
]);
|
|
298
|
+
});
|
|
299
|
+
|
|
300
|
+
test('tasks fails for a feature that is not on the map', async ({ expect }) => {
|
|
301
|
+
const { exit } = await run(['features', 'tasks', '--map', map, 'nope']);
|
|
302
|
+
expect(FeatureCheckError.is(failure(exit))).toBe(true);
|
|
303
|
+
});
|
|
304
|
+
});
|
|
305
|
+
|
|
306
|
+
describe('deus changelog check', () => {
|
|
307
|
+
const DECISION = [
|
|
308
|
+
'',
|
|
309
|
+
'```mdl',
|
|
310
|
+
'decision D-2: The greeting is optional.',
|
|
311
|
+
' date: 2026-10-23',
|
|
312
|
+
' by: user:dmaretskyi',
|
|
313
|
+
' affects: [F-1]',
|
|
314
|
+
'```',
|
|
315
|
+
'',
|
|
316
|
+
].join('\n');
|
|
317
|
+
|
|
318
|
+
/** A scratch repository whose `main` holds the fixture spec, with `spec.mdl` then edited by `edit`. */
|
|
319
|
+
const repo = Effect.fnUntraced(function* (edit: (text: string) => string) {
|
|
320
|
+
const fs = yield* FileSystem.FileSystem;
|
|
321
|
+
const path = yield* Path.Path;
|
|
322
|
+
const dir = yield* fs.makeTempDirectoryScoped();
|
|
323
|
+
const spec = path.join(dir, 'spec.mdl');
|
|
324
|
+
const original = yield* fs.readFileString(SAMPLE_SPEC);
|
|
325
|
+
yield* fs.writeFileString(spec, original);
|
|
326
|
+
yield* git(dir, 'init', '-q', '-b', 'main');
|
|
327
|
+
yield* git(dir, 'add', '.');
|
|
328
|
+
// Pinned so a global identity or `commit.gpgsign` cannot change or block the scratch commit.
|
|
329
|
+
const identity = ['-c', 'user.name=test', '-c', 'user.email=test@example.com', '-c', 'commit.gpgsign=false'];
|
|
330
|
+
yield* git(dir, ...identity, 'commit', '-q', '-m', 'init');
|
|
331
|
+
yield* fs.writeFileString(spec, edit(original));
|
|
332
|
+
return dir;
|
|
333
|
+
});
|
|
334
|
+
|
|
335
|
+
const check = (edit: (text: string) => string) =>
|
|
336
|
+
repo(edit).pipe(
|
|
337
|
+
Effect.flatMap((dir) => checkChangelog({ base: 'main', cwd: dir, event: '' })),
|
|
338
|
+
Effect.exit,
|
|
339
|
+
Effect.scoped,
|
|
340
|
+
Effect.provide(NodeServices.layer),
|
|
341
|
+
Effect.runPromise,
|
|
342
|
+
);
|
|
343
|
+
|
|
344
|
+
test('a spec change without a decision fails', async ({ expect }) => {
|
|
345
|
+
const exit = await check((text) => text.replace('shows a greeting.', 'shows a friendly greeting.'));
|
|
346
|
+
expect(ChangelogCheckError.is(failure(exit))).toBe(true);
|
|
347
|
+
});
|
|
348
|
+
|
|
349
|
+
test('a spec change with a new decision passes', async ({ expect }) => {
|
|
350
|
+
const exit = await check((text) => text.replace('shows a greeting.', 'shows a friendly greeting.') + DECISION);
|
|
351
|
+
expect(Exit.isSuccess(exit)).toBe(true);
|
|
352
|
+
});
|
|
353
|
+
|
|
354
|
+
test('a non-pull-request CI event skips the check', async ({ expect }) => {
|
|
355
|
+
const { exit, output } = await run(['changelog', 'check', '--base', 'no-such-ref'], { GITHUB_EVENT_NAME: 'push' });
|
|
356
|
+
expect(Exit.isSuccess(exit)).toBe(true);
|
|
357
|
+
expect(output).toEqual(['Skipping on `push` — the changelog check is diff-based.']);
|
|
358
|
+
});
|
|
359
|
+
});
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2026 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { BaseError } from '@dxos/errors';
|
|
6
|
+
|
|
7
|
+
/** A git command failed or exited non-zero. */
|
|
8
|
+
export class GitError extends BaseError.extend('DeusGitError', 'A git command failed.') {}
|
|
9
|
+
|
|
10
|
+
/** One or more changed specs break the changelog rules. */
|
|
11
|
+
export class ChangelogCheckError extends BaseError.extend('DeusChangelogCheckError', 'Spec changelog check failed.') {}
|
|
12
|
+
|
|
13
|
+
/** A QA lint reported findings in the plugin specs. */
|
|
14
|
+
export class QaLintError extends BaseError.extend('DeusQaLintError', 'The QA lints reported findings.') {}
|
|
15
|
+
|
|
16
|
+
/** A spec review breaks the review rules. */
|
|
17
|
+
export class ReviewCheckError extends BaseError.extend('DeusReviewCheckError', 'The spec review has errors.') {}
|
|
18
|
+
|
|
19
|
+
/** One or more `.mdl` files have lint errors. */
|
|
20
|
+
export class LintError extends BaseError.extend('DeusLintError', 'The .mdl files have lint errors.') {}
|
|
21
|
+
|
|
22
|
+
/** The feature map has errors: a bad status, a spec reference that resolves to nothing, or a dependency cycle. */
|
|
23
|
+
export class FeatureCheckError extends BaseError.extend('DeusFeatureCheckError', 'The feature map has errors.') {}
|