@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 @@
|
|
|
1
|
+
{"version":3,"file":"cli.mjs","names":["check","check"],"sources":["../../src/cli/errors.ts","../../src/cli/git.ts","../../src/cli/changelog.ts","../../src/cli/review.ts","../../src/cli/features.ts","../../src/cli/spec-index.ts","../../src/cli/lint.ts","../../src/cli/qa-lint.ts","../../src/cli/qa.ts","../../src/cli/index.ts"],"sourcesContent":["//\n// Copyright 2026 DXOS.org\n//\n\nimport { BaseError } from '@dxos/errors';\n\n/** A git command failed or exited non-zero. */\nexport class GitError extends BaseError.extend('DeusGitError', 'A git command failed.') {}\n\n/** One or more changed specs break the changelog rules. */\nexport class ChangelogCheckError extends BaseError.extend('DeusChangelogCheckError', 'Spec changelog check failed.') {}\n\n/** A QA lint reported findings in the plugin specs. */\nexport class QaLintError extends BaseError.extend('DeusQaLintError', 'The QA lints reported findings.') {}\n\n/** A spec review breaks the review rules. */\nexport class ReviewCheckError extends BaseError.extend('DeusReviewCheckError', 'The spec review has errors.') {}\n\n/** One or more `.mdl` files have lint errors. */\nexport class LintError extends BaseError.extend('DeusLintError', 'The .mdl files have lint errors.') {}\n\n/** The feature map has errors: a bad status, a spec reference that resolves to nothing, or a dependency cycle. */\nexport class FeatureCheckError extends BaseError.extend('DeusFeatureCheckError', 'The feature map has errors.') {}\n","//\n// Copyright 2026 DXOS.org\n//\n\nimport * as Effect from 'effect/Effect';\nimport * as ChildProcess from 'effect/process/ChildProcess';\nimport * as ChildProcessSpawner from 'effect/process/ChildProcessSpawner';\nimport * as Stream from 'effect/Stream';\n\nimport { GitError } from './errors.ts';\n\n/** Runs `git <args>` in `cwd` and returns trimmed stdout; a non-zero exit fails with {@link GitError}. */\nexport const git = Effect.fnUntraced(function* (cwd: string, ...args: string[]) {\n const spawner = yield* ChildProcessSpawner.ChildProcessSpawner;\n return yield* Effect.scoped(\n Effect.gen(function* () {\n const handle = yield* spawner.spawn(ChildProcess.make('git', args, { cwd }));\n const [stdout, stderr, exitCode] = yield* Effect.all(\n [\n Stream.mkString(Stream.decodeText(handle.stdout)),\n Stream.mkString(Stream.decodeText(handle.stderr)),\n handle.exitCode,\n ],\n { concurrency: 'unbounded' },\n );\n if (exitCode !== 0) {\n return yield* Effect.fail(new GitError({ context: { args, exitCode, stderr: stderr.trim() } }));\n }\n return stdout.trim();\n }),\n ).pipe(Effect.catchTag('PlatformError', (error) => Effect.fail(new GitError({ cause: error, context: { args } }))));\n});\n\n/** Splits command output into its non-empty lines. */\nexport const lines = (text: string): string[] => text.split('\\n').filter(Boolean);\n","//\n// Copyright 2026 DXOS.org\n//\n\nimport * as Command from 'effect/cli/Command';\nimport * as Flag from 'effect/cli/Flag';\nimport * as Config from 'effect/Config';\nimport * as Console from 'effect/Console';\nimport * as Effect from 'effect/Effect';\nimport * as FileSystem from 'effect/FileSystem';\nimport * as Path from 'effect/Path';\n\nimport { MISSING_DECISION, checkChangelogChange, lintMdl } from '../extension/check.ts';\nimport { ChangelogCheckError } from './errors.ts';\nimport { git, lines } from './git.ts';\n\n/** A commit trailer that waives the missing-decision rule for a bulk mechanical edit; append-only rules still apply. */\nexport const WAIVER = 'Spec-Changelog-Skip';\n\n/** Language definitions, review rules, spec reviews and test fixtures are .mdl files but not specs. */\nconst EXEMPT = [/^packages\\/reflect\\/deus\\/lang\\//, /\\/__fixtures__\\//, /(^|\\/)rules\\//, /\\.review\\.mdl$/];\n\nexport const DEFAULT_BASE_REF = 'origin/main';\n\nexport type ChangelogCheckOptions = {\n /** Ref whose merge base with HEAD the working tree is compared against. */\n base: string;\n /** Repository directory; any path inside the work tree. */\n cwd: string;\n /** `GITHUB_EVENT_NAME`; the check runs only for pull requests or outside CI. */\n event: string;\n};\n\n/**\n * Fails when a changed .mdl spec has no new `## Changelog` decision, or edits the log in place (lang/changelog.mdl).\n * Whitespace and small typo fixes need no decision; a `Spec-Changelog-Skip: <reason>` commit trailer waives the rule.\n * Compares the working tree with the merge base of `base`, so a local run also covers uncommitted edits.\n */\nexport const checkChangelog = Effect.fnUntraced(function* ({ base: baseRef, cwd, event }: ChangelogCheckOptions) {\n // The rule is diff-based: on `main` every spec's history is already merged, so only a branch run means anything.\n if (event && event !== 'pull_request') {\n yield* Console.log(`Skipping on \\`${event}\\` — the changelog check is diff-based.`);\n return;\n }\n\n const fs = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const root = yield* git(cwd, 'rev-parse', '--show-toplevel');\n const base = yield* git(root, 'merge-base', baseRef, 'HEAD').pipe(Effect.orElseSucceed(() => baseRef));\n\n const waivers = lines(yield* git(root, 'log', `${base}..HEAD`, `--format=%(trailers:key=${WAIVER},valueonly)`));\n if (waivers.length > 0) {\n yield* Console.log(`Missing-decision rule waived by ${WAIVER}: ${waivers.join('; ')}`);\n }\n\n // Path in the working tree → path at the base (undefined for a new file).\n const changed = new Map<string, string | undefined>();\n // Unquoted paths, so a non-ASCII file name reads back as the file it names.\n const quotePath = ['-c', 'core.quotePath=false'];\n for (const line of lines(\n yield* git(root, ...quotePath, 'diff', '--name-status', '-M', '--diff-filter=AMR', base, '--', '*.mdl'),\n )) {\n const [status, ...paths] = line.split('\\t');\n changed.set(paths[paths.length - 1], status === 'A' ? undefined : paths[0]);\n }\n for (const file of lines(\n yield* git(root, ...quotePath, 'ls-files', '--others', '--exclude-standard', '--', '*.mdl'),\n )) {\n changed.set(file, undefined);\n }\n\n let failures = 0;\n for (const [file, basePath] of [...changed].sort(([a], [b]) => a.localeCompare(b))) {\n if (EXEMPT.some((pattern) => pattern.test(file))) {\n continue;\n }\n const after = yield* fs.readFileString(path.join(root, file));\n const before = basePath === undefined ? undefined : yield* git(root, 'show', `${base}:${basePath}`);\n const errors = [\n ...checkChangelogChange(before, after).filter((error) => waivers.length === 0 || error !== MISSING_DECISION),\n ...lintMdl(after)\n .filter(({ source }) => source === 'mdl/decision')\n .map(({ message }) => message),\n ];\n for (const error of errors) {\n yield* Console.log(`${file}: ${error}`);\n }\n failures += errors.length;\n }\n\n if (failures > 0) {\n yield* Console.log(\n `\\n${failures} changelog error(s). Every spec change adds a decision — see .agents/skills/mdl/SKILL.md.`,\n );\n return yield* Effect.fail(new ChangelogCheckError({ context: { failures } }));\n }\n yield* Console.log(`OK: ${changed.size} changed .mdl file(s) checked against ${baseRef}.`);\n});\n\nconst check = Command.make(\n 'check',\n {\n base: Flag.String('base').pipe(\n Flag.withDescription('Ref to diff against, via its merge base with HEAD (env MDL_BASE_REF).'),\n Flag.withFallbackConfig(Config.String('MDL_BASE_REF')),\n Flag.withDefault(DEFAULT_BASE_REF),\n ),\n },\n Effect.fnUntraced(function* ({ base }) {\n const event = yield* Config.String('GITHUB_EVENT_NAME').pipe(Config.withDefault(''));\n yield* checkChangelog({ base, cwd: process.cwd(), event });\n }),\n).pipe(\n Command.withDescription(\n 'Fail when a changed .mdl spec adds no `## Changelog` decision or edits an existing one (waive with a `Spec-Changelog-Skip:` trailer).',\n ),\n);\n\nexport const changelog = Command.make('changelog').pipe(\n Command.withDescription('Spec changelog tools.'),\n Command.withSubcommands([check]),\n);\n","//\n// Copyright 2026 DXOS.org\n//\n\nimport * as Argument from 'effect/cli/Argument';\nimport * as Command from 'effect/cli/Command';\nimport * as Console from 'effect/Console';\nimport * as Effect from 'effect/Effect';\nimport * as FileSystem from 'effect/FileSystem';\nimport * as Option from 'effect/Option';\nimport * as Path from 'effect/Path';\n\nimport { parseMdlBlocks } from '../extension/blocks.ts';\nimport { specDependencies } from '../extension/refs.ts';\nimport { frontmatter, reqs } from '../spec-index/parse.ts';\nimport { ReviewCheckError } from './errors.ts';\nimport { git } from './git.ts';\n\nconst STATUSES = new Set(['done', 'untested', 'partial', 'diverged', 'missing']);\n\n/** Kinds a review judges. Acceptance blocks (scenarios, QA tests) are run, not reviewed; history is not code. */\nconst REVIEWED_KINDS = new Set([\n 'plugin',\n 'feat',\n 'req',\n 'type',\n 'op',\n 'component',\n 'service',\n 'capability',\n 'module',\n 'db',\n 'scenario',\n 'test',\n]);\n\n/** A walkthrough says where things are; more steps than this retells the code. */\nconst MAX_WALKTHROUGH = 5;\n\n/** Kinds judged on whether automation exercises them rather than on whether code implements them. */\nconst EXERCISE_KINDS = new Set(['scenario', 'test']);\n\n/** A key list written inline (`[a, b]`), wrapped over lines, or as `- a` items, as `parseReview` reads it. */\nexport const keyList = (value: string | undefined): string[] =>\n (value ?? '')\n .split(/[,\\n]/)\n .map((item) => item.replace(/^[\\s[-]+|[\\s\\]]+$/g, ''))\n .filter(Boolean);\n\nexport type ReviewItem = { id: string; kind: string; line: number; title: string };\n\nconst blocks = (text: string): { body: string; line: number }[] =>\n [...text.matchAll(/^```mdl\\s*\\n([\\s\\S]*?)^```/gm)].map((match) => ({\n body: match[1],\n line: text.slice(0, match.index).split('\\n').length + 1,\n }));\n\n/** Top-level blocks, plus `req` items nested in a `feat`; a feat with reqs is judged through them. */\nexport const reviewItems = (text: string): ReviewItem[] =>\n blocks(text).flatMap(({ body, line }) => {\n const lines = body.split('\\n');\n const header = lines[0].match(/^(\\w+)\\s+([A-Za-z][\\w.-]*)\\s*(?::\\s*(.*))?$/);\n if (!header || !REVIEWED_KINDS.has(header[1])) {\n return [];\n }\n const nested = reqs(body).map(({ id, title, offset }) => ({ id, kind: 'req', line: line + offset, title }));\n return nested.length > 0 ? nested : [{ id: header[2], kind: header[1], line, title: header[3] ?? '' }];\n });\n\n/** A block field at two spaces of indent; a `|` value continues on lines indented four or more. */\nexport const blockField = (body: string, name: string): string | undefined => {\n const match = body.match(new RegExp(`^ ${name}:[ \\\\t]*(.*)$((?:\\\\n {4,}.*)*)`, 'm'));\n return match ? `${match[1]} ${match[2]}`.replace(/^\\|/, '').trim() : undefined;\n};\n\n/**\n * The items a reference to `id` covers: a block's reqs (or the block itself when it has none), or one nested req.\n */\nexport const itemsUnder = (text: string, id: string): ReviewItem[] => {\n const block = blocks(text).find(({ body }) => body.split('\\n')[0].match(/^\\w+\\s+([A-Za-z][\\w.-]*)/)?.[1] === id);\n if (block) {\n const end = block.line + block.body.split('\\n').length;\n return reviewItems(text).filter(({ line }) => line >= block.line && line < end);\n }\n return reviewItems(text).filter((item) => item.id === id);\n};\n\n/** Each verdict's status and note, by item id. */\nexport const reviewVerdicts = (text: string): Map<string, { status?: string; note?: string }> =>\n new Map(\n blocks(text).flatMap(({ body }) => {\n const id = body.split('\\n')[0].match(/^verdict\\s+([A-Za-z][\\w.-]*)/)?.[1];\n return id ? [[id, { status: blockField(body, 'status'), note: blockField(body, 'note') }] as const] : [];\n }),\n );\n\n/**\n * The `dependsOn` array of the `plugin` object in a `dx.config.ts`, empty when the object has none; undefined when\n * there is no `plugin` object or `dependsOn` is not a literal array of strings. Comments are stripped first so a commented-out entry does not count.\n */\nexport const configDependsOn = (configText: string): string[] | undefined => {\n const code = configText.replace(/(['\"`])(?:\\\\.|(?!\\1)[^\\\\])*\\1|\\/\\/.*|\\/\\*[\\s\\S]*?\\*\\//g, (match) =>\n match.startsWith('/') ? ' ' : match,\n );\n const start = /\\bplugin\\s*:\\s*\\{/.exec(code);\n if (start?.index === undefined) {\n return undefined;\n }\n let depth = 0;\n let end = code.length;\n for (let index = start.index + start[0].length - 1; index < code.length; index++) {\n depth += code[index] === '{' ? 1 : code[index] === '}' ? -1 : 0;\n if (depth === 0) {\n end = index;\n break;\n }\n }\n const plugin = code.slice(start.index, end);\n if (!/\\bdependsOn\\s*:/.test(plugin)) {\n return [];\n }\n const literal = plugin.match(/\\bdependsOn\\s*:\\s*\\[([^\\]]*)\\]/)?.[1];\n if (literal === undefined) {\n return undefined;\n }\n const items = literal\n .split(',')\n .map((item) => item.trim())\n .filter((item) => item !== '');\n const strings = items.map((item) => item.match(/^(['\"`])([^'\"`$\\\\]*)\\1$/)?.[2]);\n return strings.every((value) => value !== undefined) ? strings.filter((value) => value !== undefined) : undefined;\n};\n\n/** Whether the source declares the name: a top-level declaration, a member, or an export list entry. */\nconst declares = (source: string, name: string): boolean => {\n const id = name.replace(/[$]/g, '\\\\$');\n return [\n new RegExp(`(?:class|interface|type|enum|function\\\\*?|const|let|var|namespace)\\\\s+${id}\\\\b`),\n new RegExp(\n `^\\\\s*(?:(?:public|private|protected|static|readonly|override|async|get|set|#)\\\\s*)*${id}\\\\s*\\\\??[:(<=]`,\n 'm',\n ),\n new RegExp(`export\\\\s*\\\\{[^}]*\\\\b${id}\\\\b`),\n ].some((pattern) => pattern.test(source));\n};\n\ntype ResolvedKey = { file?: string; symbol?: string; error?: string };\n\n/**\n * Validates a `.review.mdl` against its spec and the checkout: frontmatter, statuses, notes, coverage of every item,\n * and that each evidence key names an existing file and symbol.\n */\nexport const checkReview = Effect.fnUntraced(function* (reviewPath: string) {\n const fs = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const errors: string[] = [];\n const warnings: string[] = [];\n const text = yield* fs.readFileString(reviewPath);\n const meta = frontmatter(text);\n for (const key of ['spec', 'commit', 'date', 'by']) {\n if (!meta[key]) {\n errors.push(`frontmatter: missing \\`${key}\\``);\n }\n }\n if (meta.date && !/^\\d{4}-\\d{2}-\\d{2}$/.test(meta.date)) {\n errors.push('frontmatter: `date` must be YYYY-MM-DD');\n }\n if (meta.by && !/^(user|agent):\\S+$/.test(meta.by)) {\n errors.push('frontmatter: `by` must be `user:<handle>` or `agent:<name>`');\n }\n\n const root = yield* git(path.dirname(path.resolve(reviewPath)), 'rev-parse', '--show-toplevel');\n const realRoot = yield* fs.realPath(root);\n const repo = Option.getOrUndefined(\n yield* git(root, 'remote', 'get-url', 'origin').pipe(\n Effect.option,\n Effect.map(Option.flatMapNullishOr((url) => url.match(/github\\.com[:/]([\\w.-]+\\/[\\w.-]+?)(?:\\.git)?\\/?$/)?.[1])),\n ),\n );\n if (meta.commit && Option.isNone(yield* git(root, 'cat-file', '-e', `${meta.commit}^{commit}`).pipe(Effect.option))) {\n warnings.push(`frontmatter: commit ${meta.commit} is not in this clone (shallow, or not fetched)`);\n }\n\n const exists = (file: string) => fs.exists(file).pipe(Effect.orElseSucceed(() => false));\n const resolveKey = Effect.fnUntraced(function* (key: string) {\n const match = key.match(/^github:([\\w.-]+\\/[\\w.-]+)\\/([^#\\s]+)(?:#([\\w$.-]+))?$/);\n if (!match) {\n return { error: `not a github: key: ${key}` } satisfies ResolvedKey;\n }\n if (repo && match[1].toLowerCase() !== repo.toLowerCase()) {\n return {} satisfies ResolvedKey;\n }\n const file = path.resolve(root, match[2]);\n // A key names a file inside the checkout; neither `..` nor a symlink may reach outside it.\n const real = (yield* exists(file)) ? yield* fs.realPath(file) : file;\n if (match[2].split('/').includes('..') || !real.startsWith(`${realRoot}${path.sep}`)) {\n return { error: `key leaves the checkout: ${key}` } satisfies ResolvedKey;\n }\n return { file, symbol: match[3] } satisfies ResolvedKey;\n });\n\n const specFile = meta.spec ? (yield* resolveKey(meta.spec)).file : undefined;\n const specText = specFile && (yield* exists(specFile)) ? yield* fs.readFileString(specFile) : undefined;\n if (meta.spec && !specText) {\n errors.push(`frontmatter: spec not found in this checkout: ${meta.spec}`);\n }\n const items = specText ? reviewItems(specText) : [];\n const itemIds = new Set(items.map(({ id }) => id));\n const kindOf = new Map(items.map(({ id, kind }) => [id, kind]));\n\n const verdicts = blocks(text).flatMap(({ body, line }) => {\n const header = body.split('\\n')[0].match(/^verdict\\s+([A-Za-z][\\w.-]*)\\s*(?::\\s*(.*))?$/);\n return header ? [{ id: header[1], line, body }] : [];\n });\n const seen = new Set<string>();\n for (const { id, line, body } of verdicts) {\n const at = `${reviewPath}:${line}`;\n if (seen.has(id)) {\n errors.push(`${at}: second verdict for ${id}`);\n }\n seen.add(id);\n if (specText && !itemIds.has(id)) {\n errors.push(`${at}: ${id} is not a reviewable item of the spec (run \\`items\\` for the list)`);\n }\n const status = blockField(body, 'status');\n if (!status || !STATUSES.has(status)) {\n errors.push(`${at}: ${id} has status \\`${status ?? ''}\\`; use one of ${[...STATUSES].join(', ')}`);\n }\n if (status && status !== 'done' && !blockField(body, 'note')) {\n errors.push(`${at}: ${id} is ${status} but has no note saying what is missing or different`);\n }\n const exercise = EXERCISE_KINDS.has(kindOf.get(id) ?? '');\n const evidence = keyList(blockField(body, 'evidence'));\n if (!exercise && (status === 'done' || status === 'untested' || status === 'partial') && evidence.length === 0) {\n warnings.push(`${at}: ${id} is ${status} with no evidence`);\n }\n for (const key of evidence) {\n const { file, symbol, error } = yield* resolveKey(key);\n if (error) {\n errors.push(`${at}: ${error}`);\n } else if (file && !(yield* exists(file))) {\n errors.push(`${at}: evidence file not found: ${key}`);\n } else if (file && symbol) {\n if (!declares(yield* fs.readFileString(file), symbol.split('.').pop() ?? symbol)) {\n errors.push(`${at}: no declaration of ${symbol} in ${key.split('#')[0]} (a mention is not evidence)`);\n }\n }\n }\n const tests = keyList(blockField(body, 'tests'));\n if (exercise && status === 'untested') {\n errors.push(`${at}: ${id} is a ${kindOf.get(id)}; use done, partial, diverged or missing (see lang/review.mdl)`);\n }\n if (exercise && status !== 'missing' && tests.length === 0) {\n errors.push(`${at}: ${id} is a ${kindOf.get(id)} judged ${status} but cites no tests`);\n }\n if (status === 'untested' && tests.length > 0) {\n errors.push(`${at}: ${id} is untested but cites tests; make it done or drop the tests`);\n }\n if (!exercise && status === 'done' && tests.length === 0) {\n warnings.push(`${at}: ${id} is done with no tests; cite them or make it untested`);\n }\n for (const key of tests) {\n const { file, symbol, error } = yield* resolveKey(key);\n if (error) {\n errors.push(`${at}: ${error}`);\n } else if (symbol) {\n errors.push(`${at}: a test key names the test file only, without #: ${key}`);\n } else if (file && !(yield* exists(file))) {\n errors.push(`${at}: test file not found: ${key}`);\n }\n }\n // Each step is `- <sentence>. github:<key>`; the joined field holds them as `- ` separated items.\n const steps = (blockField(body, 'walkthrough') ?? '')\n .split(/(?:^|\\s)-\\s+/)\n .map((step) => step.trim())\n .filter(Boolean);\n if (steps.length > MAX_WALKTHROUGH) {\n errors.push(`${at}: ${id} has ${steps.length} walkthrough steps; keep it to ${MAX_WALKTHROUGH}`);\n }\n if (steps.length > 0 && evidence.length < 2) {\n warnings.push(`${at}: ${id} has one implementation; its code chip already shows it, so drop the walkthrough`);\n }\n for (const step of steps) {\n const key = step.match(/(github:\\S+)\\s*$/)?.[1];\n if (!key) {\n errors.push(`${at}: walkthrough step does not end with a github: key: ${step}`);\n continue;\n }\n const { file, symbol, error } = yield* resolveKey(key);\n if (error) {\n errors.push(`${at}: ${error}`);\n } else if (file && !(yield* exists(file))) {\n errors.push(`${at}: walkthrough file not found: ${key}`);\n } else if (file && symbol) {\n if (!declares(yield* fs.readFileString(file), symbol.split('.').pop() ?? symbol)) {\n errors.push(`${at}: no declaration of ${symbol} in ${key.split('#')[0]} (walkthrough)`);\n }\n }\n }\n }\n // dx.config.ts is what the app loads, so a spec that lists other dependencies has diverged from the code.\n const pluginBlock = specText ? parseMdlBlocks(specText).find(({ type }) => type === 'plugin') : undefined;\n const configFile = specFile ? path.join(path.dirname(specFile), 'dx.config.ts') : undefined;\n if (specText && pluginBlock && configFile && (yield* exists(configFile))) {\n const config = configDependsOn(yield* fs.readFileString(configFile));\n const declared = specDependencies(specText)\n .filter(({ via }) => via === 'dependsOn')\n .map(({ id }) => id);\n const verdict = verdicts.find(({ id }) => id === pluginBlock.id);\n if (config && verdict && blockField(verdict.body, 'status') !== 'diverged') {\n const same = new Set(declared).size === new Set(config).size && declared.every((id) => config.includes(id));\n if (!same) {\n errors.push(\n `${reviewPath}:${verdict.line}: ${pluginBlock.id} dependsOn [${declared.join(', ')}] differs from dx.config.ts [${config.join(', ')}]; judge it diverged`,\n );\n }\n }\n }\n for (const { id, line } of items) {\n if (!seen.has(id)) {\n errors.push(`${specFile}:${line}: ${id} has no verdict`);\n }\n }\n\n for (const warning of warnings) {\n yield* Console.log(`warning: ${warning}`);\n }\n for (const error of errors) {\n yield* Console.log(`error: ${error}`);\n }\n yield* Console.log(\n `${verdicts.length} verdicts for ${items.length} items; ${errors.length} errors, ${warnings.length} warnings.`,\n );\n if (errors.length > 0) {\n return yield* Effect.fail(new ReviewCheckError({ context: { errors: errors.length } }));\n }\n});\n\nconst items = Command.make(\n 'items',\n { spec: Argument.String('spec').pipe(Argument.withDescription('The spec (.mdl) to list.')) },\n Effect.fnUntraced(function* ({ spec }) {\n const fs = yield* FileSystem.FileSystem;\n for (const { id, kind, line, title } of reviewItems(yield* fs.readFileString(spec))) {\n yield* Console.log(`${id}\\t${kind}\\t${line}\\t${title}`);\n }\n }),\n).pipe(Command.withDescription('List every item a spec review must judge: `<id>\\\\t<kind>\\\\t<line>\\\\t<title>`.'));\n\nconst check = Command.make(\n 'check',\n { review: Argument.String('review').pipe(Argument.withDescription('The review (.review.mdl) to validate.')) },\n ({ review }) => checkReview(review),\n).pipe(Command.withDescription('Validate a spec review against its spec and the checkout.'));\n\nexport const review = Command.make('review').pipe(\n Command.withDescription('Spec review tools.'),\n Command.withSubcommands([items, check]),\n);\n","//\n// Copyright 2026 DXOS.org\n//\n\nimport * as Argument from 'effect/cli/Argument';\nimport * as Command from 'effect/cli/Command';\nimport * as Flag from 'effect/cli/Flag';\nimport * as Console from 'effect/Console';\nimport * as Effect from 'effect/Effect';\nimport * as FileSystem from 'effect/FileSystem';\nimport * as Option from 'effect/Option';\nimport * as Path from 'effect/Path';\n\nimport { parseMdlBlocks } from '../extension/blocks.ts';\nimport { frontmatter } from '../spec-index/parse.ts';\nimport { FeatureCheckError } from './errors.ts';\nimport { git } from './git.ts';\nimport { type ReviewItem, blockField, itemsUnder, keyList, reviewItems, reviewVerdicts } from './review.ts';\n\n/** The authored statuses of `lang/features.mdl`, in the order a feature normally moves through them. */\nexport const FEATURE_STATUSES = ['planned', 'in-progress', 'prototype', 'operational', 'failing'] as const;\n\nexport type FeatureStatus = (typeof FEATURE_STATUSES)[number];\n\n/** What the reviews of a feature's spec items say, or `unreviewed` when an item has no verdict. */\nexport type DerivedStatus = Exclude<FeatureStatus, 'failing'> | 'unreviewed';\n\nexport type Feature = {\n id: string;\n title: string;\n line: number;\n status?: string;\n /** Repo-relative spec paths, each optionally `#<item id>`. */\n specs: string[];\n depends: string[];\n};\n\n/** Every `feature` block of a feature map. */\nexport const parseFeatureMap = (text: string): Feature[] =>\n parseMdlBlocks(text)\n .filter(({ type }) => type === 'feature')\n .map(({ id, title, body, from }) => ({\n id: id ?? '',\n title: title ?? '',\n line: text.slice(0, from).split('\\n').length,\n status: blockField(body, 'status'),\n specs: keyList(blockField(body, 'specs')),\n depends: keyList(blockField(body, 'depends')),\n }));\n\n/**\n * The status the reviews support: every item done is operational, done or untested is a prototype, every item\n * missing is planned, and anything between is in progress.\n */\nexport const deriveStatus = (statuses: ReadonlyArray<string | undefined>): DerivedStatus => {\n if (statuses.length === 0 || statuses.some((status) => status === undefined)) {\n return 'unreviewed';\n }\n if (statuses.every((status) => status === 'done')) {\n return 'operational';\n }\n if (statuses.every((status) => status === 'done' || status === 'untested')) {\n return 'prototype';\n }\n if (statuses.every((status) => status === 'missing')) {\n return 'planned';\n }\n return 'in-progress';\n};\n\n/** One spec item a feature cites, with the verdict its review gives it. */\nexport type FeatureItem = ReviewItem & { spec: string; status?: string; note?: string };\n\nexport type FeatureReport = {\n feature: Feature;\n derived: DerivedStatus;\n items: FeatureItem[];\n};\n\nexport type FeatureMapReport = {\n reports: FeatureReport[];\n errors: string[];\n warnings: string[];\n};\n\nconst REVIEW_SUFFIX = '.review.mdl';\n\n/** Finds the first dependency cycle as the ids along it, closing on the id it started from. */\nconst findCycle = (features: ReadonlyArray<Feature>): string[] | undefined => {\n const depends = new Map(features.map(({ id, depends }) => [id, depends]));\n const done = new Set<string>();\n const visit = (id: string, trail: string[]): string[] | undefined => {\n if (trail.includes(id)) {\n return [...trail.slice(trail.indexOf(id)), id];\n }\n if (done.has(id)) {\n return undefined;\n }\n for (const next of depends.get(id) ?? []) {\n const cycle = visit(next, [...trail, id]);\n if (cycle) {\n return cycle;\n }\n }\n done.add(id);\n return undefined;\n };\n for (const { id } of features) {\n const cycle = visit(id, []);\n if (cycle) {\n return cycle;\n }\n }\n return undefined;\n};\n\n/**\n * Resolves every spec reference of a feature map against the checkout and its reviews, derives each feature's status,\n * and collects what is wrong (errors) or out of step (warnings).\n */\nexport const analyzeFeatureMap = Effect.fnUntraced(function* (mapPath: string) {\n const fs = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const root = yield* git(path.dirname(path.resolve(mapPath)), 'rev-parse', '--show-toplevel');\n const features = parseFeatureMap(yield* fs.readFileString(mapPath));\n const errors: string[] = [];\n const warnings: string[] = [];\n const exists = (file: string) => fs.exists(file).pipe(Effect.orElseSucceed(() => false));\n const readIfExists = Effect.fnUntraced(function* (file: string) {\n return (yield* exists(file)) ? yield* fs.readFileString(file) : undefined;\n });\n\n const byId = new Map<string, Feature>();\n for (const feature of features) {\n const at = `${mapPath}:${feature.line}: ${feature.id}`;\n if (byId.has(feature.id)) {\n errors.push(`${at}: second feature with this id`);\n }\n byId.set(feature.id, feature);\n if (!feature.status || !(FEATURE_STATUSES as readonly string[]).includes(feature.status)) {\n errors.push(`${at}: status \\`${feature.status ?? ''}\\`; use one of ${FEATURE_STATUSES.join(', ')}`);\n }\n if (feature.specs.length === 0) {\n errors.push(`${at}: cites no spec; a feature names the spec items that state it`);\n }\n }\n for (const feature of features) {\n for (const dependency of feature.depends) {\n if (!byId.has(dependency)) {\n errors.push(`${mapPath}:${feature.line}: ${feature.id}: depends on unknown feature ${dependency}`);\n }\n }\n }\n const cycle = findCycle(features);\n if (cycle) {\n errors.push(`${mapPath}: dependency cycle: ${cycle.join(' -> ')}`);\n }\n\n // A spec is read, and its review's staleness checked, once however many features cite it.\n const specs = new Map<string, { text?: string; verdicts: Map<string, { status?: string; note?: string }> }>();\n const loadSpec = Effect.fnUntraced(function* (spec: string, at: string) {\n const cached = specs.get(spec);\n if (cached) {\n return cached;\n }\n const file = path.resolve(root, spec);\n const text = yield* readIfExists(file);\n const reviewFile = file.replace(/\\.mdl$/, REVIEW_SUFFIX);\n const review = text ? yield* readIfExists(reviewFile) : undefined;\n if (!text) {\n errors.push(`${at}: spec not found: ${spec}`);\n } else if (!review) {\n warnings.push(`${at}: ${spec} has no review; run the spec-review skill`);\n } else {\n const commit = frontmatter(review).commit;\n const changed = commit\n ? yield* git(root, 'rev-list', `${commit}..HEAD`, '--', spec).pipe(Effect.option)\n : Option.none<string>();\n const dirty = yield* git(root, 'status', '--porcelain', '--', spec).pipe(Effect.orElseSucceed(() => ''));\n if (Option.isNone(changed)) {\n warnings.push(`${at}: the review of ${spec} names a commit not in this clone`);\n } else if (changed.value !== '' || dirty !== '') {\n warnings.push(`${at}: ${spec} changed after its review (${commit?.slice(0, 8)}); re-review it`);\n }\n }\n const entry = { text, verdicts: review ? reviewVerdicts(review) : new Map() };\n specs.set(spec, entry);\n return entry;\n });\n\n const reports: FeatureReport[] = [];\n for (const feature of features) {\n const at = `${mapPath}:${feature.line}: ${feature.id}`;\n const items: FeatureItem[] = [];\n for (const ref of feature.specs) {\n const [spec, id] = ref.split('#');\n const { text, verdicts } = yield* loadSpec(spec, at);\n if (!text) {\n continue;\n }\n const cited = id ? itemsUnder(text, id) : reviewItems(text);\n if (cited.length === 0) {\n errors.push(`${at}: ${ref} names no reviewable item of the spec`);\n }\n items.push(...cited.map((item) => ({ ...item, spec, ...verdicts.get(item.id) })));\n }\n const derived = deriveStatus(items.map(({ status }) => status));\n const unjudged = items.filter(({ status }) => status === undefined).map(({ id }) => id);\n if (unjudged.length > 0 && unjudged.length < items.length) {\n warnings.push(`${at}: no verdict yet for ${unjudged.join(', ')}`);\n }\n if (feature.status && feature.status !== 'failing' && derived !== 'unreviewed' && feature.status !== derived) {\n warnings.push(`${at}: marked ${feature.status} but its reviews say ${derived}`);\n }\n for (const dependency of feature.depends) {\n const status = byId.get(dependency)?.status;\n if (feature.status !== 'planned' && (status === 'planned' || status === 'failing')) {\n warnings.push(`${at}: blocked: depends on ${dependency}, which is ${status}`);\n } else if (feature.status === 'operational' && status !== 'operational') {\n warnings.push(`${at}: operational ahead of its dependency ${dependency} (${status})`);\n }\n }\n if (feature.status === 'in-progress') {\n const dirs = new Set(\n items.flatMap(({ spec }) => {\n const dir = path.dirname(path.resolve(root, spec));\n return ['spec', 'docs'].includes(path.basename(dir)) ? [dir, path.dirname(dir)] : [dir];\n }),\n );\n let planned = false;\n for (const dir of dirs) {\n const tasks = yield* readIfExists(path.join(dir, 'TASKS.md'));\n planned ||=\n tasks !== undefined && new RegExp(`^#{2,3} .*\\\\b${feature.id.replace(/\\./g, '\\\\.')}\\\\b`, 'm').test(tasks);\n }\n if (!planned) {\n warnings.push(\n `${at}: partly built with no work planned: no TASKS.md beside its spec has a \\`## ${feature.id}\\` section`,\n );\n }\n }\n reports.push({ feature, derived, items });\n }\n\n return { reports, errors, warnings } satisfies FeatureMapReport;\n});\n\nconst DEFAULT_MAP = 'FEATURES.mdl';\n\nconst resolveMap = Effect.fnUntraced(function* (map: Option.Option<string>) {\n if (Option.isSome(map)) {\n return map.value;\n }\n const path = yield* Path.Path;\n return path.join(yield* git(process.cwd(), 'rev-parse', '--show-toplevel'), DEFAULT_MAP);\n});\n\nconst mapFlag = Flag.String('map').pipe(\n Flag.withDescription(`The feature map; defaults to ${DEFAULT_MAP} at the repository root.`),\n Flag.optional,\n);\n\n/** Prints one row per feature, then every warning and error; fails when there is an error. */\nexport const checkFeatures = Effect.fnUntraced(function* (mapPath: string) {\n const { reports, errors, warnings } = yield* analyzeFeatureMap(mapPath);\n for (const { feature, derived, items } of reports) {\n const done = items.filter(({ status }) => status === 'done').length;\n yield* Console.log(`${feature.id}\\t${feature.status ?? ''}\\t${derived}\\t${done}/${items.length} done`);\n }\n for (const warning of warnings) {\n yield* Console.log(`warning: ${warning}`);\n }\n for (const error of errors) {\n yield* Console.log(`error: ${error}`);\n }\n yield* Console.log(`${reports.length} features; ${errors.length} errors, ${warnings.length} warnings.`);\n if (errors.length > 0) {\n return yield* Effect.fail(new FeatureCheckError({ context: { errors: errors.length } }));\n }\n});\n\n/** The first sentence of a verdict note, so a task line stays one line. */\nconst firstSentence = (note: string | undefined): string =>\n (note ?? '').replace(/\\s+/g, ' ').match(/^.*?[.!?](?=\\s|$)/)?.[0] ?? (note ?? '').trim();\n\n/** Prints the open work of one feature as a TASKS.md section: one task per spec item not yet done. */\nexport const featureTasks = Effect.fnUntraced(function* (mapPath: string, id: string) {\n const { reports } = yield* analyzeFeatureMap(mapPath);\n const report = reports.find(({ feature }) => feature.id === id);\n if (!report) {\n return yield* Effect.fail(new FeatureCheckError({ context: { feature: id, reason: 'not on the map' } }));\n }\n yield* Console.log(`## ${report.feature.id}: ${report.feature.title}\\n`);\n let spec: string | undefined;\n for (const item of report.items.filter(({ status }) => status !== 'done')) {\n if (item.spec !== spec) {\n spec = item.spec;\n yield* Console.log(`Spec: \\`${spec}\\`\\n`);\n }\n const why = item.status ? `${item.status}${item.note ? `: ${firstSentence(item.note)}` : ''}` : 'unreviewed';\n yield* Console.log(`- [ ] ${item.id}: ${item.title} (${why})`);\n }\n});\n\nconst check = Command.make('check', { map: mapFlag }, ({ map }) => Effect.flatMap(resolveMap(map), checkFeatures)).pipe(\n Command.withDescription(\n 'Check the feature map against the specs and their reviews: `<id>\\\\t<status>\\\\t<derived>\\\\t<done>/<items> done`.',\n ),\n);\n\nconst tasks = Command.make(\n 'tasks',\n { map: mapFlag, feature: Argument.String('feature').pipe(Argument.withDescription('The feature id.')) },\n ({ map, feature }) => Effect.flatMap(resolveMap(map), (mapPath) => featureTasks(mapPath, feature)),\n).pipe(Command.withDescription('Print the open spec items of one feature as a TASKS.md section.'));\n\nexport const features = Command.make('features').pipe(\n Command.withDescription('Feature map tools: the top of feature map > specs > tasks > code > result.'),\n Command.withSubcommands([check, tasks]),\n);\n","//\n// Copyright 2026 DXOS.org\n//\n\nimport * as Command from 'effect/cli/Command';\nimport * as Flag from 'effect/cli/Flag';\nimport * as Console from 'effect/Console';\nimport * as Effect from 'effect/Effect';\nimport * as FileSystem from 'effect/FileSystem';\nimport * as Option from 'effect/Option';\nimport * as Path from 'effect/Path';\n\nimport { indexSpecs, isIndexedSpec } from '../spec-index/index.ts';\nimport { git, lines } from './git.ts';\n\n/** Indexes every tracked `.mdl` spec under `root`, leaving out what {@link isIndexedSpec} excludes. */\nexport const buildSpecIndex = Effect.fnUntraced(function* (root: string) {\n const fs = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const tracked = lines(yield* git(root, '-c', 'core.quotePath=false', 'ls-files', '--', '*.mdl')).filter(\n isIndexedSpec,\n );\n const files = yield* Effect.forEach(tracked, (file) =>\n fs.readFileString(path.join(root, file)).pipe(\n Effect.map((text) => ({ path: file, text })),\n // A tracked file deleted in the working tree is no longer a spec.\n Effect.option,\n ),\n );\n return indexSpecs(files.flatMap((file) => (file._tag === 'Some' ? [file.value] : [])));\n});\n\nexport type IndexOptions = {\n /** File to write instead of printing. */\n out: Option.Option<string>;\n};\n\n/** Indexes every spec of the checkout by id and prints the JSON, or writes it to `out`. */\nexport const printIndex = Effect.fnUntraced(function* ({ out }: IndexOptions) {\n const fs = yield* FileSystem.FileSystem;\n const root = yield* git(process.cwd(), 'rev-parse', '--show-toplevel');\n const json = JSON.stringify(yield* buildSpecIndex(root), null, 2);\n if (Option.isSome(out)) {\n yield* fs.writeFileString(out.value, `${json}\\n`);\n } else {\n yield* Console.log(json);\n }\n});\n\nexport const index = Command.make(\n 'index',\n { out: Flag.String('out').pipe(Flag.withDescription('Write the index to this file.'), Flag.optional) },\n printIndex,\n).pipe(Command.withDescription('Index every .mdl spec of the checkout by its frontmatter id.'));\n","//\n// Copyright 2026 DXOS.org\n//\n\nimport * as Argument from 'effect/cli/Argument';\nimport * as Command from 'effect/cli/Command';\nimport * as Flag from 'effect/cli/Flag';\nimport * as Console from 'effect/Console';\nimport * as Effect from 'effect/Effect';\nimport * as FileSystem from 'effect/FileSystem';\nimport * as Option from 'effect/Option';\n\nimport { lintMdl } from '../extension/check.ts';\nimport { LintError } from './errors.ts';\nimport { git } from './git.ts';\nimport { buildSpecIndex } from './spec-index.ts';\n\nconst INDEXED_CHECKS = ['mdl/ref', 'mdl/uses'];\n\nexport type LintOptions = {\n files: readonly string[];\n /** Keep one check, e.g. `mdl/decision`; the block-type check still knows only the built-in types. */\n only: Option.Option<string>;\n};\n\n/** Lints .mdl files with the checks the editor runs; fails when any diagnostic is an error. */\nexport const lintFiles = Effect.fnUntraced(function* ({ files, only }: LintOptions) {\n const fs = yield* FileSystem.FileSystem;\n const needsIndex = Option.isNone(only) || INDEXED_CHECKS.includes(only.value);\n const root = needsIndex\n ? yield* git(process.cwd(), 'rev-parse', '--show-toplevel').pipe(\n // Outside a checkout there is nothing to resolve references against; any other git failure must fail the run.\n Effect.catch((error) =>\n String(error.context?.stderr).includes('not a git repository')\n ? Effect.succeed(undefined)\n : Effect.fail(error),\n ),\n )\n : undefined;\n if (needsIndex && root === undefined) {\n yield* Console.log('warning: not inside a git checkout; the mdl/ref and mdl/uses checks were skipped.');\n }\n const index = root === undefined ? undefined : yield* buildSpecIndex(root);\n let errors = 0;\n for (const file of files) {\n const text = yield* fs.readFileString(file);\n for (const { from, severity, source, message } of lintMdl(text, {\n index: file.endsWith('.review.mdl') ? undefined : index,\n })) {\n if (Option.isSome(only) && source !== only.value) {\n continue;\n }\n const line = text.slice(0, from).split('\\n').length;\n yield* Console.log(`${file}:${line}: ${severity} [${source}]: ${message}`);\n if (severity === 'error') {\n errors++;\n }\n }\n }\n if (errors > 0) {\n return yield* Effect.fail(new LintError({ context: { errors } }));\n }\n});\n\nexport const lint = Command.make(\n 'lint',\n {\n only: Flag.String('only').pipe(Flag.withDescription('Report one check only, e.g. `mdl/decision`.'), Flag.optional),\n files: Argument.String('files').pipe(\n Argument.withDescription('The .mdl files to lint.'),\n Argument.variadic({ min: 1 }),\n ),\n },\n lintFiles,\n).pipe(Command.withDescription('Lint .mdl files with the checks the editor runs.'));\n","//\n// Copyright 2026 DXOS.org\n//\n\nimport * as Command from 'effect/cli/Command';\nimport * as Flag from 'effect/cli/Flag';\nimport * as Console from 'effect/Console';\nimport * as Effect from 'effect/Effect';\nimport * as FileSystem from 'effect/FileSystem';\nimport * as Option from 'effect/Option';\nimport * as Path from 'effect/Path';\n\nimport { QaLintError } from './errors.ts';\n\n/** Names the runner binds itself (qa.mdl Field rule 5 and Input literals), so no test declares them. */\nconst RUNNER_BOUND = new Set(['given', 'result', 'error', 'spaceId', 'snapshot', 'stepErrors', 'runId']);\n\nexport type UnboundReport = { file: string; test: string; unbound: [name: string, line: number][] };\n\n/** `test QA-n` blocks whose steps reference a `$given.x` or `$x` the test never binds. */\nexport const findUnboundReferences = (file: string, text: string): UnboundReport[] => {\n const lines = text.split('\\n');\n // Slice each `test QA-n:` block: starts at the header, ends at the closing fence.\n const tests: { name: string; body: { line: number; text: string }[] }[] = [];\n let current: (typeof tests)[number] | undefined;\n lines.forEach((line, index) => {\n const header = line.match(/^test (QA-\\d+):/);\n if (header) {\n current = { name: header[1], body: [] };\n tests.push(current);\n } else if (current && line.startsWith('```')) {\n current = undefined;\n } else if (current) {\n current.body.push({ line: index + 1, text: line });\n }\n });\n\n return tests.flatMap((test) => {\n const text = test.body.map(({ text }) => text).join('\\n');\n // Bound names: `given:` entries written `- name: prose`, and every `capture:`.\n const givens = new Set<string>();\n let inGiven = false;\n for (const { text: line } of test.body) {\n if (/^\\s{2}given:/.test(line)) {\n inGiven = true;\n continue;\n }\n if (/^\\s{2}\\w+[?]?:/.test(line)) {\n inGiven = false;\n }\n const entry = inGiven ? line.match(/^\\s*-\\s+([A-Za-z_][A-Za-z0-9_]*):\\s/) : null;\n if (entry) {\n givens.add(entry[1]);\n }\n }\n const captures = new Set([...text.matchAll(/^\\s*capture:\\s*([A-Za-z_][A-Za-z0-9_]*)/gm)].map((match) => match[1]));\n\n const unbound = new Map<string, number>();\n for (const { line, text: content } of test.body) {\n for (const match of content.matchAll(/\\$given\\.([A-Za-z_][A-Za-z0-9_]*)/g)) {\n if (!givens.has(match[1])) {\n unbound.set(`$given.${match[1]}`, line);\n }\n }\n for (const match of content.matchAll(/\\$([A-Za-z_][A-Za-z0-9_]*)/g)) {\n if (!RUNNER_BOUND.has(match[1]) && !captures.has(match[1])) {\n unbound.set(`$${match[1]}`, line);\n }\n }\n }\n return unbound.size > 0 ? [{ file, test: test.name, unbound: [...unbound.entries()] }] : [];\n });\n};\n\nexport type TeardownReport = { file: string; test: string; line: number; reason: string };\n\n/**\n * `after:` steps that could remove an object the run did not create.\n *\n * A teardown is safe when it removes something the test bound itself (a `capture:` or a named `given:`), or resolves\n * by a name the test's `given` guarantees is absent — constrained to the subject's own type, and throwing when nothing\n * matches. Resolving by type-and-index deletes whatever the space happens to hold first; resolving by name across\n * `Filter.everything()` deletes any object carrying that name, which the `given` precondition does not exclude.\n */\nexport const findUnsafeTeardowns = (file: string, text: string): TeardownReport[] => {\n const lines = text.split('\\n');\n const reports: TeardownReport[] = [];\n let inAfter = false;\n let test = '';\n lines.forEach((line, index) => {\n const header = line.match(/^test (QA-\\d+):/);\n if (header) {\n test = header[1];\n inAfter = false;\n }\n if (/^ {2}after:/.test(line)) {\n inAfter = true;\n return;\n }\n if (/^ {2}(steps|before|given):/.test(line) || line.startsWith('```')) {\n inAfter = false;\n }\n if (!inAfter || !/removeObjects/.test(line)) {\n return;\n }\n // Only the invoke's own continuation lines — an `assert:` verifying removal legitimately queries the database and\n // must not be mistaken for victim selection.\n const step: string[] = [];\n for (let next = index; next < lines.length; next++) {\n if (next > index && /^\\s+(assert|expect|note|do|name|capture):/.test(lines[next])) {\n break;\n }\n step.push(lines[next]);\n }\n const body = step.join('\\n');\n if (!/db\\.query/.test(body)) {\n return; // Removes a bound value.\n }\n const byIndex = /\\.objects\\[\\d+\\]/.test(body);\n const guarded = /throw new Error/.test(body);\n // A name match over every object in the space is not narrowed by a `given` that only promises no *typed* subject\n // carries the name.\n const untyped = /Filter\\.everything\\(\\)/.test(body) && /\\.name ===/.test(body);\n // Selecting on an id the test itself produced discriminates even on a dirty fixture, so it needs no name guard\n // (Execution Rule 5).\n const byIdentity = /\\.id ===/.test(body);\n if (byIndex || untyped || (!guarded && !byIdentity)) {\n const reason = byIndex ? 'resolves by index' : untyped ? 'name match across every type' : 'unguarded query';\n reports.push({ file, test, line: index + 1, reason });\n }\n });\n return reports;\n};\n\n/** The plugin specs the QA lints cover: `packages/plugins/<plugin>/PLUGIN.mdl`, sorted, relative to `root`. */\nconst pluginSpecs = Effect.fnUntraced(function* (root: string) {\n const fs = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const plugins = (yield* fs.readDirectory(path.join(root, 'packages/plugins'))).sort();\n const specs: { file: string; text: string }[] = [];\n for (const plugin of plugins) {\n const file = `packages/plugins/${plugin}/PLUGIN.mdl`;\n const text = yield* fs.readFileString(path.join(root, file)).pipe(Effect.option);\n if (Option.isSome(text)) {\n specs.push({ file, text: text.value });\n }\n }\n return specs;\n});\n\nexport type QaCheck = 'unbound' | 'teardown';\n\nexport const QA_CHECKS: readonly QaCheck[] = ['unbound', 'teardown'];\n\n/** Runs the QA lints over every plugin spec under `root`; fails when any reports a finding. */\nexport const lintQa = Effect.fnUntraced(function* ({ root, checks }: { root: string; checks: readonly QaCheck[] }) {\n const specs = yield* pluginSpecs(root);\n let findings = 0;\n\n if (checks.includes('unbound')) {\n const reports = specs.flatMap(({ file, text }) => findUnboundReferences(file, text));\n let total = 0;\n for (const report of reports) {\n yield* Console.log(`${report.file} ${report.test}`);\n for (const [name, line] of report.unbound) {\n yield* Console.log(` L${line} ${name}`);\n total++;\n }\n }\n yield* Console.log(`\\n${reports.length} tests with unbound references; ${total} references total`);\n findings += total;\n }\n\n if (checks.includes('teardown')) {\n const reports = specs.flatMap(({ file, text }) => findUnsafeTeardowns(file, text));\n for (const { file, test, line, reason } of reports) {\n yield* Console.log(`${file} ${test} L${line} ${reason}`);\n }\n yield* Console.log(`\\n${reports.length} teardown step(s) that could remove an object the run did not create`);\n findings += reports.length;\n }\n\n if (findings > 0) {\n return yield* Effect.fail(new QaLintError({ context: { findings } }));\n }\n});\n\nexport const qaLint = Command.make(\n 'lint',\n {\n check: Flag.Literals('check', QA_CHECKS).pipe(\n Flag.withDescription(\n 'Run one check: `unbound` ($references a test never binds) or `teardown` (unsafe `after:` removals).',\n ),\n Flag.optional,\n ),\n root: Flag.String('root').pipe(\n Flag.withDescription('Repository root holding `packages/plugins` (default the working directory).'),\n Flag.withDefault(process.cwd()),\n ),\n },\n ({ check, root }) =>\n lintQa({ root, checks: Option.match(check, { onNone: () => QA_CHECKS, onSome: (one) => [one] }) }),\n).pipe(\n Command.withDescription('Lint the `test` blocks of every plugin spec for unbound references and unsafe teardowns.'),\n);\n","//\n// Copyright 2026 DXOS.org\n//\n\nimport * as Argument from 'effect/cli/Argument';\nimport * as Command from 'effect/cli/Command';\nimport * as Flag from 'effect/cli/Flag';\nimport * as Config from 'effect/Config';\nimport * as Console from 'effect/Console';\nimport * as Context from 'effect/Context';\nimport * as Effect from 'effect/Effect';\nimport * as FileSystem from 'effect/FileSystem';\nimport * as Option from 'effect/Option';\nimport * as Path from 'effect/Path';\n\nimport { qaLint } from './qa-lint.ts';\n\n/**\n * Whether a host CLI asked for JSON output. `dx` declares `--json` as a shared root flag, which consumes it before\n * `dx deus qa list` sees its own, so `dx` provides this instead.\n */\nexport const JsonOutput: Context.Reference<boolean> = Context.Reference<boolean>('@dxos/deus/JsonOutput', {\n defaultValue: () => false,\n});\n\n// Enumerates the executable `test QA-n` blocks and the `suite` blocks that group them across the repo's `.mdl` specs\n// (the Deus.QA dialect, `lang/qa.mdl`). Deliberately regex-based rather than a real parser: the block grammar is still\n// settling, and a listing that breaks on an unparsed field is worse than one that reports what it found.\n\n/** Directories never searched; `__fixtures__` hold test inputs, not runnable plans. */\nconst SKIP = new Set(['node_modules', 'dist', '.git', '.moon', 'out', 'temp', '.cache', '__fixtures__']);\n\nconst STAGES = ['before', 'steps', 'after'] as const;\n\ntype Stage = (typeof STAGES)[number];\n\nexport type StageCounts = Record<Stage, number>;\n\nexport type QaTest = {\n file: string;\n plugin: string;\n id: string;\n title: string;\n status: string;\n actors: string;\n /** Per stage, so a partial run's size is visible; `steps` is the test, the other two are fixture. */\n stages: StageCounts;\n covers: string;\n tags: string[];\n};\n\nexport type TestRef = { plugin: string; id: string };\n\nexport type QaSuite = {\n file: string;\n plugin: string;\n id: string;\n title: string;\n tags: string[];\n tests: TestRef[];\n};\n\nexport type QaDocument = { file: string; text: string };\n\ntype Block = { file: string; plugin: string; id: string; title: string; body: string };\n\n/** Steps per stage. A stage header sits at two spaces; its steps are `- name:`/`- do:` at four. */\nconst countStages = (body: string): StageCounts => {\n const counts: StageCounts = { before: 0, steps: 0, after: 0 };\n let stage: Stage | undefined;\n for (const line of body.split('\\n')) {\n const header = line.match(/^ {2}(\\w+):\\s*$/);\n if (header) {\n stage = STAGES.find((candidate) => candidate === header[1]);\n continue;\n }\n if (stage && /^ {4}- +(?:name|do):/.test(line)) {\n counts[stage]++;\n }\n }\n return counts;\n};\n\n/** The short name a test or suite is addressed by: `markdown` for plugin-markdown, `app` for APP.mdl. */\nexport const shortName = (file: string): string =>\n file.match(/plugin-([\\w-]+)\\//)?.[1] ?? (file.endsWith('APP.mdl') ? 'app' : file.replace(/\\.mdl$/, ''));\n\nconst parseList = (value: string | undefined): string[] =>\n (value ?? '')\n .split(',')\n .map((item) => item.trim())\n .filter(Boolean);\n\n/** Blocks of one kind in a document. Several blocks may share one fence, so headers are matched per line. */\nconst parseBlocks = (text: string, file: string, kind: string): Block[] =>\n [...text.matchAll(/```mdl\\n([\\s\\S]*?)```/g)].flatMap(([, fence]) => {\n const headers = [...fence.matchAll(new RegExp(`^${kind}\\\\s+([\\\\w.-]+)\\\\s*(?::\\\\s*(.*))?$`, 'gm'))];\n return headers.map((header, index) => ({\n file,\n plugin: shortName(file),\n id: header[1],\n title: (header[2] ?? '').trim(),\n body: fence.slice(header.index, headers[index + 1]?.index ?? fence.length),\n }));\n });\n\nexport const parseTests = (text: string, file: string): QaTest[] =>\n parseBlocks(text, file, 'test').map(({ body, ...block }) => ({\n ...block,\n status: body.match(/^\\s*status:\\s*(\\w+)/m)?.[1] ?? 'unverified',\n actors: body.match(/^\\s*actors:\\s*([\\w|\\s]+?)\\s*$/m)?.[1]?.trim() ?? 'both',\n stages: countStages(body),\n covers: body.match(/^\\s*covers:\\s*\\[(.*?)\\]/m)?.[1] ?? '',\n tags: parseList(body.match(/^\\s*tags:\\s*\\[(.*?)\\]/m)?.[1]),\n }));\n\nexport const parseSuites = (text: string, file: string): QaSuite[] =>\n parseBlocks(text, file, 'suite').map(({ body, ...block }) => ({\n ...block,\n tags: parseList(body.match(/^\\s*tags:\\s*\\[(.*?)\\]/m)?.[1]),\n // A bare `QA-1` is this document's test; `markdown:QA-1` names another plugin's.\n tests: parseList(body.match(/^\\s*tests:\\s*\\[(.*?)\\]/m)?.[1]).map((ref) => {\n const [plugin, id] = ref.includes(':') ? ref.split(':') : [block.plugin, ref];\n return { plugin, id };\n }),\n }));\n\n/**\n * A dialect definition (`org.dxos.spec.*`) carries example tests to document its own syntax; those are illustrations,\n * not plans, and listing them as runnable is a trap.\n */\nexport const isDialect = (text: string): boolean => /^id:\\s*org\\.dxos\\.spec\\./m.test(text.split('---')[1] ?? '');\n\nexport type QaQuery = {\n /** `[<plugin> <testId>]` resolves exactly; a single value is a substring filter over path, id and title. */\n query: readonly string[];\n tag: Option.Option<string>;\n suite: Option.Option<string>;\n suites: boolean;\n};\n\nexport type QaSelection = { kind: 'tests'; rows: QaTest[] } | { kind: 'suites'; rows: QaSuite[] };\n\n/** The tests a suite names, in its order; a ref that resolves to nothing is reported as `missing`, not dropped. */\nconst resolveSuite = (tests: QaTest[], suite: QaSuite): QaTest[] =>\n suite.tests.map(\n (ref) =>\n tests.find((candidate) => candidate.plugin === ref.plugin && candidate.id === ref.id) ?? {\n file: suite.file,\n plugin: ref.plugin,\n id: ref.id,\n title: '(unresolved)',\n status: 'missing',\n actors: 'both',\n stages: { before: 0, steps: 0, after: 0 },\n covers: '',\n tags: [],\n },\n );\n\n/** Selects the tests (or suites) a query names from the parsed documents. */\nexport const selectQa = (documents: readonly QaDocument[], { query, tag, suite, suites: listSuites }: QaQuery) => {\n const specs = documents.filter(({ text }) => !isDialect(text));\n const tests = specs.flatMap(({ file, text }) => parseTests(text, file));\n const suites = specs.flatMap(({ file, text }) => parseSuites(text, file));\n\n // Two positionals resolve exactly — `<plugin> <testId>`. One is the loose substring filter, and a test id alone is\n // genuinely ambiguous: QA-1 exists in more than one plugin.\n const [plugin, testId] = query.length >= 2 ? query : [undefined, undefined];\n const filter = query.length >= 2 ? undefined : query[0];\n const matchesPlugin = (item: { plugin: string }) => !plugin || item.plugin === plugin.replace(/^plugin-/, '');\n const matchesFilter = (item: { file: string; id: string; title: string }) =>\n !filter || `${item.file} ${item.id} ${item.title}`.toLowerCase().includes(filter.toLowerCase());\n\n let selectedSuites = suites.filter(matchesPlugin).filter(matchesFilter);\n if (Option.isSome(tag)) {\n selectedSuites = suites.filter((candidate) => candidate.tags.includes(tag.value));\n }\n if (Option.isSome(suite)) {\n selectedSuites = suites.filter((candidate) => candidate.id === suite.value);\n }\n\n const description = plugin\n ? `${plugin} ${testId}`\n : (filter ?? Option.getOrUndefined(tag) ?? Option.getOrUndefined(suite));\n if (listSuites) {\n return { selection: { kind: 'suites', rows: selectedSuites } satisfies QaSelection, description };\n }\n if (Option.isSome(tag) || Option.isSome(suite)) {\n // Suites are order-independent by construction (each test owns its fixture), so a tag's union is simply every\n // member test, de-duplicated, in suite order.\n const seen = new Set<string>();\n const rows = selectedSuites\n .flatMap((candidate) => resolveSuite(tests, candidate))\n .filter((test) => {\n const key = `${test.plugin}:${test.id}`;\n return seen.has(key) ? false : (seen.add(key), true);\n });\n return { selection: { kind: 'tests', rows } satisfies QaSelection, description };\n }\n const rows = tests\n .filter(matchesPlugin)\n .filter(matchesFilter)\n .filter((test) => !testId || test.id.toLowerCase() === testId.toLowerCase());\n return { selection: { kind: 'tests', rows } satisfies QaSelection, description };\n};\n\n/** The numbered table `/dxos:qa` renders; row numbers are the addressing scheme. */\nexport const formatSelection = (selection: QaSelection, description: string | undefined): string[] => {\n const noun = selection.kind;\n if (selection.rows.length === 0) {\n return [description ? `No ${noun} matching \"${description}\".` : `No ${noun} found.`];\n }\n if (selection.kind === 'suites') {\n const width = Math.max(...selection.rows.map((suite) => suite.id.length));\n return selection.rows.flatMap((suite, index) => [\n `${String(index + 1).padStart(2)}. ${suite.id.padEnd(width)} ${String(suite.tests.length).padStart(2)} tests ${suite.title}`,\n ` ${suite.file}${suite.tags.length ? ` tags: ${suite.tags.join(', ')}` : ''}`,\n ]);\n }\n const idWidth = Math.max(...selection.rows.map((test) => test.id.length));\n const statusWidth = Math.max(...selection.rows.map((test) => test.status.length));\n return selection.rows.flatMap((test, index) => {\n const { before, steps, after } = test.stages;\n return [\n `${String(index + 1).padStart(2)}. ${test.plugin}:${test.id.padEnd(idWidth)} ${test.status.padEnd(statusWidth)} ` +\n `${String(steps).padStart(2)} steps (${before} before, ${after} after) ${test.title}`,\n ` ${test.file}${test.covers ? ` covers: ${test.covers}` : ''}`,\n ];\n });\n};\n\n/** Every `.mdl` file under `root`, sorted, with paths relative to it; broken symlinks are skipped. */\nexport const readDocuments = Effect.fnUntraced(function* (root: string) {\n const fs = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const walk = (dir: string): Effect.Effect<string[]> =>\n Effect.gen(function* () {\n // Sorted: the row numbers are the addressing scheme, and readdir order is filesystem-defined.\n const entries = (yield* fs.readDirectory(dir).pipe(Effect.orElseSucceed((): string[] => []))).sort();\n const files: string[] = [];\n for (const entry of entries) {\n if (SKIP.has(entry)) {\n continue;\n }\n const full = path.join(dir, entry);\n const info = yield* fs.stat(full).pipe(Effect.option);\n if (Option.isNone(info)) {\n continue;\n }\n if (info.value.type === 'Directory') {\n files.push(...(yield* walk(full)));\n } else if (entry.endsWith('.mdl')) {\n files.push(full);\n }\n }\n return files;\n });\n\n const files = yield* walk(root);\n return yield* Effect.forEach(files, (file) =>\n fs.readFileString(file).pipe(Effect.map((text): QaDocument => ({ file: path.relative(root, file), text }))),\n );\n});\n\nconst list = Command.make(\n 'list',\n {\n query: Argument.String('query').pipe(\n Argument.withDescription(\n '`<plugin> <testId>` for exactly one test (`markdown QA-1`, `app QA-1`), or a substring filter.',\n ),\n Argument.variadic({ max: 2 }),\n ),\n tag: Flag.String('tag').pipe(Flag.withDescription('The tests of every suite carrying this tag.'), Flag.optional),\n suite: Flag.String('suite').pipe(Flag.withDescription('The tests of one suite, in its order.'), Flag.optional),\n suites: Flag.Boolean('suites').pipe(Flag.withDescription('List suites instead of tests.'), Flag.withDefault(false)),\n json: Flag.Boolean('json').pipe(Flag.withDescription('Print the rows as JSON.'), Flag.withDefault(false)),\n root: Flag.String('root').pipe(\n Flag.withDescription('Directory to search (env DX_REPO_ROOT; default the working directory).'),\n Flag.withFallbackConfig(Config.String('DX_REPO_ROOT')),\n Flag.withDefault(process.cwd()),\n ),\n },\n Effect.fnUntraced(function* ({ json, root, ...query }) {\n const { selection, description } = selectQa(yield* readDocuments(root), query);\n if (json || (yield* JsonOutput)) {\n yield* Console.log(JSON.stringify(selection.rows, null, 2));\n return;\n }\n for (const line of formatSelection(selection, description)) {\n yield* Console.log(line);\n }\n }),\n).pipe(Command.withDescription('List the executable `test` and `suite` blocks across the .mdl specs, numbered.'));\n\nexport const qa = Command.make('qa').pipe(\n Command.withDescription('Deus.QA tools.'),\n Command.withSubcommands([list, qaLint]),\n);\n","//\n// Copyright 2026 DXOS.org\n//\n\nimport * as Command from 'effect/cli/Command';\n\nimport { changelog } from './changelog.ts';\nimport { features } from './features.ts';\nimport { lint } from './lint.ts';\nimport { qa } from './qa.ts';\nimport { review } from './review.ts';\nimport { index } from './spec-index.ts';\n\nexport * from './changelog.ts';\nexport * from './errors.ts';\nexport * from './features.ts';\nexport * from './lint.ts';\nexport * from './qa.ts';\nexport * from './qa-lint.ts';\nexport * from './review.ts';\nexport * from './spec-index.ts';\n\n/** The `deus` command tree: run standalone by `bin/deus.ts` and mounted by the `dx` CLI as `dx deus`. */\nexport const deus = Command.make('deus').pipe(\n Command.withDescription('Tools for Deus `.mdl` specs.'),\n Command.withSubcommands([changelog, features, index, lint, qa, review]),\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAOA,IAAa,WAAb,cAA8B,UAAU,OAAO,gBAAgB,uBAAuB,CAAC,CAAC,CAAC;;AAGzF,IAAa,sBAAb,cAAyC,UAAU,OAAO,2BAA2B,8BAA8B,CAAC,CAAC,CAAC;;AAGtH,IAAa,cAAb,cAAiC,UAAU,OAAO,mBAAmB,iCAAiC,CAAC,CAAC,CAAC;;AAGzG,IAAa,mBAAb,cAAsC,UAAU,OAAO,wBAAwB,6BAA6B,CAAC,CAAC,CAAC;;AAG/G,IAAa,YAAb,cAA+B,UAAU,OAAO,iBAAiB,kCAAkC,CAAC,CAAC,CAAC;;AAGtG,IAAa,oBAAb,cAAuC,UAAU,OAAO,yBAAyB,6BAA6B,CAAC,CAAC,CAAC;;;;ACVjH,IAAa,MAAM,OAAO,WAAW,WAAW,KAAa,GAAG,MAAgB;CAC9E,MAAM,UAAU,OAAO,oBAAoB;CAC3C,OAAO,OAAO,OAAO,OACnB,OAAO,IAAI,aAAa;EACtB,MAAM,SAAS,OAAO,QAAQ,MAAM,aAAa,KAAK,OAAO,MA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AA+B,GAAG,KAAK,YAAY,KAAK,CAAC;CAClH,MAAM,KAAK,QAAQ,MAAM,CAAC,CAAC,KAAK,KAAK,gBAAgB,yBAAyB,GAAG,KAAK,YAAY,KAAK,CAAC;CACxG,MAAM,KAAK,OAAO,MAAM,CAAC,CAAC,KACxB,KAAK,gBAAgB,wEAAwE,GAC7F,KAAK,mBAAmB,OAAO,OAAO,cAAc,CAAC,GACrD,KAAK,YAAY,QAAQ,IAAI,CAAC,CAChC;AACF,GACA,OAAO,WAAW,WAAW,EAAE,MAAM,MAAM,GAAG,SAAS;CACrD,MAAM,EAAE,WAAW,gBAAgB,SAAS,OAAO,cAAc,IAAI,GAAG,KAAK;CAC7E,IAAI,SAAS,OAAO,aAAa;EAC/B,OAAO,QAAQ,IAAI,KAAK,UAAU,UAAU,MAAM,MAAM,CAAC,CAAC;EAC1D;CACF;CACA,KAAK,MAAM,QAAQ,gBAAgB,WAAW,WAAW,GACvD,OAAO,QAAQ,IAAI,IAAI;AAE3B,CAAC,CACH,CAAC,CAAC,KAAK,QAAQ,gBAAgB,gFAAgF,CAAC;AAEhH,IAAa,KAAK,QAAQ,KAAK,IAAI,CAAC,CAAC,KACnC,QAAQ,gBAAgB,gBAAgB,GACxC,QAAQ,gBAAgB,CAAC,MAAM,MAAM,CAAC,CACxC;;;;ACpRA,IAAa,OAAO,QAAQ,KAAK,MAAM,CAAC,CAAC,KACvC,QAAQ,gBAAgB,8BAA8B,GACtD,QAAQ,gBAAgB;CAAC;CAAW;CAAU;CAAO;CAAM;CAAI;AAAM,CAAC,CACxE"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { a as mdlLint, i as mdlTerms, n as mdl, r as mdlBlockDescription, t as mdlComplete } from "./chunk-extension.mjs";
|
|
2
|
+
import { o as parseMdlBlocks } from "./chunk-blocks.mjs";
|
|
3
|
+
import { a as lintMdl, c as specReferenceFilter, d as findSpecRefs, i as isTrivialEdit, l as unknownSpecMessage, n as checkChangelogChange, o as missingItemMessage, p as specDependencies, r as duplicateSpecMessage, s as parseChangelog, t as MISSING_DECISION } from "./chunk-check.mjs";
|
|
4
|
+
export { MISSING_DECISION, checkChangelogChange, duplicateSpecMessage, findSpecRefs, isTrivialEdit, lintMdl, mdl, mdlBlockDescription, mdlComplete, mdlLint, mdlTerms, missingItemMessage, parseChangelog, parseMdlBlocks, specDependencies, specReferenceFilter, unknownSpecMessage };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { a as mdlLint, i as mdlTerms, n as mdl, r as mdlBlockDescription, t as mdlComplete } from "./chunk-extension.mjs";
|
|
2
|
+
import { n as reqIds, r as reqs, t as frontmatter } from "./chunk-parse.mjs";
|
|
3
|
+
import { o as parseMdlBlocks } from "./chunk-blocks.mjs";
|
|
4
|
+
import { a as lintMdl, c as specReferenceFilter, d as findSpecRefs, i as isTrivialEdit, l as unknownSpecMessage, n as checkChangelogChange, o as missingItemMessage, p as specDependencies, r as duplicateSpecMessage, s as parseChangelog, t as MISSING_DECISION } from "./chunk-check.mjs";
|
|
5
|
+
import { indexSpecs, isIndexedSpec } from "./spec-index.mjs";
|
|
6
|
+
export { MISSING_DECISION, checkChangelogChange, duplicateSpecMessage, findSpecRefs, frontmatter, indexSpecs, isIndexedSpec, isTrivialEdit, lintMdl, mdl, mdlBlockDescription, mdlComplete, mdlLint, mdlTerms, missingItemMessage, parseChangelog, parseMdlBlocks, reqIds, reqs, specDependencies, specReferenceFilter, unknownSpecMessage };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { a as parseBlockHeaders, o as parseMdlBlocks, r as extensionTerms, s as scanFenceLines, t as BLOCK_HEADER_LINE } from "./chunk-blocks.mjs";
|
|
2
|
+
import { a as lintMdl, c as specReferenceFilter, d as findSpecRefs, f as scanSpecLines, i as isTrivialEdit, l as unknownSpecMessage, m as BLOCK_TYPES, n as checkChangelogChange, o as missingItemMessage, p as specDependencies, r as duplicateSpecMessage, s as parseChangelog, t as MISSING_DECISION, u as findSpecKeys } from "./chunk-check.mjs";
|
|
3
|
+
import { n as fieldCompletionContext, t as BLOCK_FIELDS } from "./chunk-completion.mjs";
|
|
4
|
+
export { BLOCK_FIELDS, BLOCK_HEADER_LINE, BLOCK_TYPES, MISSING_DECISION, checkChangelogChange, duplicateSpecMessage, extensionTerms, fieldCompletionContext, findSpecKeys, findSpecRefs, isTrivialEdit, lintMdl, missingItemMessage, parseBlockHeaders, parseChangelog, parseMdlBlocks, scanFenceLines, scanSpecLines, specDependencies, specReferenceFilter, unknownSpecMessage };
|
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
import { o as parseMdlBlocks } from "./chunk-blocks.mjs";
|
|
2
|
+
//#region src/review/fields.ts
|
|
3
|
+
var indentOf = (line) => line.length - line.trimStart().length;
|
|
4
|
+
/**
|
|
5
|
+
* The top-level fields of a block body: a field's inline value, or for a `|` block or nested map, its
|
|
6
|
+
* indented lines with the common indent removed.
|
|
7
|
+
*/
|
|
8
|
+
var parseFields = (body) => {
|
|
9
|
+
const lines = body.split("\n");
|
|
10
|
+
const contentIndents = lines.filter((line) => line.trim() !== "").map(indentOf);
|
|
11
|
+
const base = contentIndents.length > 0 ? Math.min(...contentIndents) : 0;
|
|
12
|
+
const fields = /* @__PURE__ */ new Map();
|
|
13
|
+
let current;
|
|
14
|
+
for (const line of lines) {
|
|
15
|
+
if (line.trim() === "") continue;
|
|
16
|
+
const match = indentOf(line) === base && line.trim().match(/^([\w-]+)(\??):(?:\s+(.*))?$/);
|
|
17
|
+
if (match) {
|
|
18
|
+
const inline = match[3]?.trim();
|
|
19
|
+
current = {
|
|
20
|
+
inline: inline && inline !== "|" && inline !== ">" ? inline : void 0,
|
|
21
|
+
lines: []
|
|
22
|
+
};
|
|
23
|
+
fields.set(match[1], current);
|
|
24
|
+
} else if (current && indentOf(line) > base) current.lines.push(line.trim());
|
|
25
|
+
}
|
|
26
|
+
return fields;
|
|
27
|
+
};
|
|
28
|
+
//#endregion
|
|
29
|
+
//#region src/review/source-key.ts
|
|
30
|
+
/** The prefix of a key written in text: `github:owner/repo/path`. */
|
|
31
|
+
var GITHUB_SOURCE = "github";
|
|
32
|
+
/** Matches a key in running text; a trailing `.` is sentence punctuation and is trimmed by {@link findSourceKeys}. */
|
|
33
|
+
var SOURCE_KEY_PATTERN = /github:[\w.-]+\/[\w.-]+\/[\w./@+-]+(?:#[\w$.-]+)?/g;
|
|
34
|
+
/** Parses `github:owner/repo/path[#fragment]`; undefined when the text is not a key. */
|
|
35
|
+
var parseSourceKey = (text) => {
|
|
36
|
+
const match = text.trim().match(/^github:([\w.-]+)\/([\w.-]+)\/([^#\s]+)(?:#([\w$.-]+))?$/);
|
|
37
|
+
if (!match) return;
|
|
38
|
+
const [, owner, repo, path, fragment] = match;
|
|
39
|
+
return {
|
|
40
|
+
owner,
|
|
41
|
+
repo,
|
|
42
|
+
path,
|
|
43
|
+
...fragment && { fragment }
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
/** Formats a key; the fragment is included only when asked for. */
|
|
47
|
+
var formatSourceKey = ({ owner, repo, path, fragment }, withFragment = true) => `${GITHUB_SOURCE}:${owner}/${repo}/${path}${withFragment && fragment ? `#${fragment}` : ""}`;
|
|
48
|
+
/** `owner/repo`, the identity a local checkout is matched by. */
|
|
49
|
+
var repoId = ({ owner, repo }) => `${owner}/${repo}`;
|
|
50
|
+
/** `owner/repo` from a GitHub remote URL (`git@github.com:o/r.git`, `https://github.com/o/r`). */
|
|
51
|
+
var parseGitHubRemote = (url) => url.match(/github\.com[:/]([\w.-]+)\/([\w.-]+?)(?:\.git)?\/?$/)?.slice(1, 3).join("/");
|
|
52
|
+
/** Whether the key points at a spec document rather than at code. */
|
|
53
|
+
var isSpecKey = (key) => key.path.endsWith(".mdl");
|
|
54
|
+
/** The review written beside a spec: `SPEC.mdl` → `SPEC.review.mdl`. */
|
|
55
|
+
var reviewKeyOf = (key) => ({
|
|
56
|
+
owner: key.owner,
|
|
57
|
+
repo: key.repo,
|
|
58
|
+
path: key.path.replace(/\.mdl$/, ".review.mdl")
|
|
59
|
+
});
|
|
60
|
+
/** Every key mentioned in a text, with its offsets. */
|
|
61
|
+
var findSourceKeys = (text) => [...text.matchAll(SOURCE_KEY_PATTERN)].flatMap((match) => {
|
|
62
|
+
const raw = match[0].replace(/\.+$/, "");
|
|
63
|
+
const key = parseSourceKey(raw);
|
|
64
|
+
return key ? [{
|
|
65
|
+
from: match.index,
|
|
66
|
+
to: match.index + raw.length,
|
|
67
|
+
key,
|
|
68
|
+
raw
|
|
69
|
+
}] : [];
|
|
70
|
+
});
|
|
71
|
+
//#endregion
|
|
72
|
+
//#region src/review/review.ts
|
|
73
|
+
/**
|
|
74
|
+
* How far the code meets one spec item, least severe first: `done` as specified, `untested` present but with no test
|
|
75
|
+
* that covers it, `partial` in part, `diverged` implemented differently from what the spec says, `missing` not at all.
|
|
76
|
+
*/
|
|
77
|
+
var VERDICT_STATUSES = [
|
|
78
|
+
"done",
|
|
79
|
+
"untested",
|
|
80
|
+
"partial",
|
|
81
|
+
"diverged",
|
|
82
|
+
"missing"
|
|
83
|
+
];
|
|
84
|
+
/** At most this many segments: a walkthrough says where things are, it does not retell the code. */
|
|
85
|
+
var MAX_WALKTHROUGH = 5;
|
|
86
|
+
/** `- a` items, a line without the dash continuing the item above it. */
|
|
87
|
+
var listItems = (lines) => lines.reduce((items, line) => line.startsWith("-") ? [...items, line.replace(/^-\s*/, "")] : items.length > 0 ? [...items.slice(0, -1), `${items[items.length - 1]} ${line}`] : items, []);
|
|
88
|
+
/** `- <sentence>. github:<key>`, the key last; a step with no key is dropped. */
|
|
89
|
+
var parseStep = (item) => {
|
|
90
|
+
const match = item.match(/^(.*?)\s*(github:\S+)\s*$/);
|
|
91
|
+
return match ? [{
|
|
92
|
+
text: match[1].replace(/[\s.:—-]+$/, "").trim(),
|
|
93
|
+
key: match[2]
|
|
94
|
+
}] : [];
|
|
95
|
+
};
|
|
96
|
+
/**
|
|
97
|
+
* The walkthrough shown for a verdict: the reviewer's, or one segment per evidence key when the item is implemented
|
|
98
|
+
* in more than one place. Undefined for a single implementation, whose code chip already shows its declaration.
|
|
99
|
+
*/
|
|
100
|
+
var walkthroughOf = (verdict) => {
|
|
101
|
+
if (verdict.walkthrough.length > 0) return verdict.walkthrough.slice(0, 5);
|
|
102
|
+
return verdict.evidence.length > 1 ? verdict.evidence.slice(0, 5).map((key) => ({
|
|
103
|
+
text: "",
|
|
104
|
+
key
|
|
105
|
+
})) : void 0;
|
|
106
|
+
};
|
|
107
|
+
var severity = (status) => VERDICT_STATUSES.indexOf(status);
|
|
108
|
+
var isStatus = (value) => value !== void 0 && VERDICT_STATUSES.includes(value);
|
|
109
|
+
var parseFrontmatter = (text) => {
|
|
110
|
+
const body = text.match(/^---\n([\s\S]*?)\n---/)?.[1] ?? "";
|
|
111
|
+
return Object.fromEntries(body.split("\n").flatMap((line) => {
|
|
112
|
+
const match = line.match(/^([\w-]+):\s*(.*?)\s*$/);
|
|
113
|
+
return match ? [[match[1], match[2]]] : [];
|
|
114
|
+
}));
|
|
115
|
+
};
|
|
116
|
+
/** The `verdict` blocks of a review document; a verdict with no known status is dropped. */
|
|
117
|
+
var parseReview = (text) => {
|
|
118
|
+
const { spec, commit, date, by } = parseFrontmatter(text);
|
|
119
|
+
return {
|
|
120
|
+
spec,
|
|
121
|
+
commit,
|
|
122
|
+
date,
|
|
123
|
+
by,
|
|
124
|
+
verdicts: parseMdlBlocks(text).filter(({ type, id }) => type === "verdict" && id).flatMap(({ id, title, body }) => {
|
|
125
|
+
const fields = parseFields(body);
|
|
126
|
+
const status = fields.get("status")?.inline;
|
|
127
|
+
if (!isStatus(status)) return [];
|
|
128
|
+
const list = (name) => [fields.get(name)?.inline, ...fields.get(name)?.lines ?? []].join(",").split(",").map((value) => value.replace(/^[\s[-]+|[\s\]]+$/g, "")).filter(Boolean);
|
|
129
|
+
const note = [fields.get("note")?.inline, ...fields.get("note")?.lines ?? []].filter(Boolean).join(" ");
|
|
130
|
+
return [{
|
|
131
|
+
id,
|
|
132
|
+
status,
|
|
133
|
+
...title && { summary: title },
|
|
134
|
+
evidence: list("evidence"),
|
|
135
|
+
tests: list("tests"),
|
|
136
|
+
walkthrough: listItems(fields.get("walkthrough")?.lines ?? []).flatMap(parseStep),
|
|
137
|
+
...note && { note }
|
|
138
|
+
}];
|
|
139
|
+
})
|
|
140
|
+
};
|
|
141
|
+
};
|
|
142
|
+
/**
|
|
143
|
+
* The status shown for a spec item: its own verdict, else the worst verdict of the items nested under it
|
|
144
|
+
* (`F-1` from `F-1.1`, `F-1.2`), so a feature reads as missing when any of its requirements is.
|
|
145
|
+
*/
|
|
146
|
+
var statusOf = (review, id) => {
|
|
147
|
+
if (!review) return;
|
|
148
|
+
const own = review.verdicts.find((verdict) => verdict.id === id);
|
|
149
|
+
if (own) return own.status;
|
|
150
|
+
const nested = review.verdicts.filter((verdict) => verdict.id.startsWith(`${id}.`));
|
|
151
|
+
return nested.length > 0 ? nested.reduce((worst, { status }) => severity(status) > severity(worst) ? status : worst, nested[0].status) : void 0;
|
|
152
|
+
};
|
|
153
|
+
/** Verdict counts per status, in display order. */
|
|
154
|
+
var summarizeReview = (review) => VERDICT_STATUSES.map((status) => ({
|
|
155
|
+
status,
|
|
156
|
+
count: review.verdicts.filter((verdict) => verdict.status === status).length
|
|
157
|
+
})).filter(({ count }) => count > 0);
|
|
158
|
+
/** The files a review cites (evidence, tests and walkthrough steps), without fragments and in a stable order. */
|
|
159
|
+
var citedFiles = (review) => [...new Set(review.verdicts.flatMap(({ evidence, tests, walkthrough }) => [
|
|
160
|
+
...evidence,
|
|
161
|
+
...tests,
|
|
162
|
+
...walkthrough.map(({ key }) => key)
|
|
163
|
+
]).map(parseSourceKey).filter((key) => key !== void 0).map((key) => formatSourceKey(key, false)))].sort();
|
|
164
|
+
/**
|
|
165
|
+
* A review's verdicts as annotations: the code that implements each item and the tests that exercise it. `done` means
|
|
166
|
+
* tested by definition (see `VERDICT_STATUSES`); nothing is said about testing code that does not exist.
|
|
167
|
+
*/
|
|
168
|
+
var reviewAnnotations = (review) => (review?.verdicts ?? []).map(({ id, status, evidence, tests }) => {
|
|
169
|
+
const keys = evidence.map(parseSourceKey).filter((key) => key !== void 0);
|
|
170
|
+
const testKeys = tests.map(parseSourceKey).filter((key) => key !== void 0);
|
|
171
|
+
const testing = testKeys.length > 0 || status === "done" ? "tested" : status === "missing" ? void 0 : "untested";
|
|
172
|
+
return {
|
|
173
|
+
id,
|
|
174
|
+
keys,
|
|
175
|
+
...testing && { testing },
|
|
176
|
+
...testKeys.length > 0 && { tests: testKeys }
|
|
177
|
+
};
|
|
178
|
+
});
|
|
179
|
+
//#endregion
|
|
180
|
+
//#region src/review/symbol.ts
|
|
181
|
+
var escape = (text) => text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
182
|
+
/** Declarations, most specific first: a top-level declaration beats a member, which beats a bare mention. */
|
|
183
|
+
var declarationPatterns = (name) => {
|
|
184
|
+
const id = escape(name);
|
|
185
|
+
return [
|
|
186
|
+
new RegExp(`^\\s*(?:export\\s+)?(?:default\\s+)?(?:declare\\s+)?(?:abstract\\s+)?(?:async\\s+)?(?:class|interface|type|enum|function\\*?|const|let|var|namespace)\\s+${id}\\b`),
|
|
187
|
+
new RegExp(`^\\s*(?:(?:public|private|protected|static|readonly|override|async|get|set|#)\\s*)*${id}\\s*(?:\\??[:(<=])`),
|
|
188
|
+
new RegExp(`\\b${id}\\b`)
|
|
189
|
+
];
|
|
190
|
+
};
|
|
191
|
+
/**
|
|
192
|
+
* The 1-based line that declares a symbol in a source file, or undefined when it is not there. A dotted name
|
|
193
|
+
* (`Spec.make`, `Class.method`) finds the outer declaration first and then the member after it.
|
|
194
|
+
*/
|
|
195
|
+
var findSymbolLine = (content, symbol) => {
|
|
196
|
+
const lines = content.split("\n");
|
|
197
|
+
let start = 0;
|
|
198
|
+
let found;
|
|
199
|
+
for (const [index, part] of symbol.split(".").entries()) {
|
|
200
|
+
found = void 0;
|
|
201
|
+
const [declaration, member, mention] = declarationPatterns(part);
|
|
202
|
+
for (const pattern of index === 0 ? [
|
|
203
|
+
declaration,
|
|
204
|
+
member,
|
|
205
|
+
mention
|
|
206
|
+
] : [
|
|
207
|
+
member,
|
|
208
|
+
declaration,
|
|
209
|
+
mention
|
|
210
|
+
]) {
|
|
211
|
+
const index = lines.findIndex((line, number) => number >= start && pattern.test(line));
|
|
212
|
+
if (index >= 0) {
|
|
213
|
+
found = index;
|
|
214
|
+
break;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
if (found === void 0) return;
|
|
218
|
+
start = found + 1;
|
|
219
|
+
}
|
|
220
|
+
return found === void 0 ? void 0 : found + 1;
|
|
221
|
+
};
|
|
222
|
+
/** The longest declaration a snippet shows; a longer one ends with an ellipsis line. */
|
|
223
|
+
var MAX_SNIPPET_LINES = 16;
|
|
224
|
+
var depthChange = (line) => {
|
|
225
|
+
const code = line.replace(/(["'`])(?:\\.|(?!\1).)*\1/g, "").replace(/\/\/.*$/, "");
|
|
226
|
+
return (code.match(/[{([]/g)?.length ?? 0) - (code.match(/[})\]]/g)?.length ?? 0);
|
|
227
|
+
};
|
|
228
|
+
/**
|
|
229
|
+
* The declaration a key names, as shown on hover: from the declaring line to where its brackets close, or the
|
|
230
|
+
* file's opening lines (after the copyright header) when there is no symbol. Undefined when the symbol is not there.
|
|
231
|
+
*/
|
|
232
|
+
var declarationSnippet = (content, symbol) => {
|
|
233
|
+
const lines = content.split("\n");
|
|
234
|
+
let start;
|
|
235
|
+
if (symbol) {
|
|
236
|
+
const found = findSymbolLine(content, symbol);
|
|
237
|
+
if (found === void 0) return;
|
|
238
|
+
start = found - 1;
|
|
239
|
+
} else {
|
|
240
|
+
start = 0;
|
|
241
|
+
while (start < lines.length && (lines[start].startsWith("//") || lines[start].trim() === "")) start++;
|
|
242
|
+
}
|
|
243
|
+
let end = start;
|
|
244
|
+
let depth = depthChange(lines[start] ?? "");
|
|
245
|
+
while (symbol && depth > 0 && end + 1 < lines.length) {
|
|
246
|
+
end++;
|
|
247
|
+
depth += depthChange(lines[end]);
|
|
248
|
+
}
|
|
249
|
+
if (!symbol) end = Math.min(lines.length - 1, start + MAX_SNIPPET_LINES - 1);
|
|
250
|
+
const truncated = end - start + 1 > MAX_SNIPPET_LINES;
|
|
251
|
+
return {
|
|
252
|
+
line: start + 1,
|
|
253
|
+
lines: lines.slice(start, truncated ? start + MAX_SNIPPET_LINES : end + 1),
|
|
254
|
+
truncated: truncated || !symbol && end < lines.length - 1
|
|
255
|
+
};
|
|
256
|
+
};
|
|
257
|
+
//#endregion
|
|
258
|
+
export { GITHUB_SOURCE, MAX_WALKTHROUGH, SOURCE_KEY_PATTERN, VERDICT_STATUSES, citedFiles, declarationSnippet, findSourceKeys, findSymbolLine, formatSourceKey, isSpecKey, parseFields, parseGitHubRemote, parseReview, parseSourceKey, repoId, reviewAnnotations, reviewKeyOf, statusOf, summarizeReview, walkthroughOf };
|
|
259
|
+
|
|
260
|
+
//# sourceMappingURL=review.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"review.mjs","names":[],"sources":["../../src/review/fields.ts","../../src/review/source-key.ts","../../src/review/review.ts","../../src/review/symbol.ts"],"sourcesContent":["//\n// Copyright 2026 DXOS.org\n//\n\nconst indentOf = (line: string): number => line.length - line.trimStart().length;\n\n/**\n * The top-level fields of a block body: a field's inline value, or for a `|` block or nested map, its\n * indented lines with the common indent removed.\n */\nexport const parseFields = (body: string): Map<string, { inline?: string; lines: string[] }> => {\n const lines = body.split('\\n');\n const contentIndents = lines.filter((line) => line.trim() !== '').map(indentOf);\n const base = contentIndents.length > 0 ? Math.min(...contentIndents) : 0;\n const fields = new Map<string, { inline?: string; lines: string[] }>();\n let current: { inline?: string; lines: string[] } | undefined;\n for (const line of lines) {\n if (line.trim() === '') {\n continue;\n }\n const match = indentOf(line) === base && line.trim().match(/^([\\w-]+)(\\??):(?:\\s+(.*))?$/);\n if (match) {\n const inline = match[3]?.trim();\n current = { inline: inline && inline !== '|' && inline !== '>' ? inline : undefined, lines: [] };\n fields.set(match[1], current);\n } else if (current && indentOf(line) > base) {\n current.lines.push(line.trim());\n }\n }\n return fields;\n};\n","//\n// Copyright 2026 DXOS.org\n//\n\n/** The prefix of a key written in text: `github:owner/repo/path`. */\nexport const GITHUB_SOURCE = 'github';\n\n/**\n * A location in a GitHub repository: `github:owner/repo/path/to/file[#fragment]`.\n * The fragment names a spec block (`#F-1`, `#Scene`) or a code symbol (`#MyClass`).\n */\nexport type SourceKey = {\n owner: string;\n repo: string;\n /** POSIX path relative to the repository root. */\n path: string;\n fragment?: string;\n};\n\n/** Matches a key in running text; a trailing `.` is sentence punctuation and is trimmed by {@link findSourceKeys}. */\nexport const SOURCE_KEY_PATTERN = /github:[\\w.-]+\\/[\\w.-]+\\/[\\w./@+-]+(?:#[\\w$.-]+)?/g;\n\n/** Parses `github:owner/repo/path[#fragment]`; undefined when the text is not a key. */\nexport const parseSourceKey = (text: string): SourceKey | undefined => {\n const match = text.trim().match(/^github:([\\w.-]+)\\/([\\w.-]+)\\/([^#\\s]+)(?:#([\\w$.-]+))?$/);\n if (!match) {\n return undefined;\n }\n const [, owner, repo, path, fragment] = match;\n return { owner, repo, path, ...(fragment && { fragment }) };\n};\n\n/** Formats a key; the fragment is included only when asked for. */\nexport const formatSourceKey = ({ owner, repo, path, fragment }: SourceKey, withFragment = true): string =>\n `${GITHUB_SOURCE}:${owner}/${repo}/${path}${withFragment && fragment ? `#${fragment}` : ''}`;\n\n/** `owner/repo`, the identity a local checkout is matched by. */\nexport const repoId = ({ owner, repo }: Pick<SourceKey, 'owner' | 'repo'>): string => `${owner}/${repo}`;\n\n/** `owner/repo` from a GitHub remote URL (`git@github.com:o/r.git`, `https://github.com/o/r`). */\nexport const parseGitHubRemote = (url: string): string | undefined =>\n url\n .match(/github\\.com[:/]([\\w.-]+)\\/([\\w.-]+?)(?:\\.git)?\\/?$/)\n ?.slice(1, 3)\n .join('/');\n\n/** Whether the key points at a spec document rather than at code. */\nexport const isSpecKey = (key: SourceKey): boolean => key.path.endsWith('.mdl');\n\n/** The review written beside a spec: `SPEC.mdl` → `SPEC.review.mdl`. */\nexport const reviewKeyOf = (key: SourceKey): SourceKey => ({\n owner: key.owner,\n repo: key.repo,\n path: key.path.replace(/\\.mdl$/, '.review.mdl'),\n});\n\n/** Every key mentioned in a text, with its offsets. */\nexport const findSourceKeys = (text: string): { from: number; to: number; key: SourceKey; raw: string }[] =>\n [...text.matchAll(SOURCE_KEY_PATTERN)].flatMap((match) => {\n const raw = match[0].replace(/\\.+$/, '');\n const key = parseSourceKey(raw);\n return key ? [{ from: match.index, to: match.index + raw.length, key, raw }] : [];\n });\n","//\n// Copyright 2026 DXOS.org\n//\n\nimport { parseMdlBlocks } from '../extension/blocks.ts';\nimport { parseFields } from './fields.ts';\nimport { type SourceKey, formatSourceKey, parseSourceKey } from './source-key.ts';\n\n/**\n * How far the code meets one spec item, least severe first: `done` as specified, `untested` present but with no test\n * that covers it, `partial` in part, `diverged` implemented differently from what the spec says, `missing` not at all.\n */\nexport const VERDICT_STATUSES = ['done', 'untested', 'partial', 'diverged', 'missing'] as const;\n\nexport type VerdictStatus = (typeof VERDICT_STATUSES)[number];\n\nexport type Verdict = {\n /** The spec item judged: a block id (`Scene`, `F-1`) or a nested requirement (`F-1.2`). */\n id: string;\n status: VerdictStatus;\n summary?: string;\n /** `github:` keys of the code that supports the verdict. */\n evidence: string[];\n /** `github:` keys of the tests that exercise the item; empty when the review names none. */\n tests: string[];\n /** Where each part of the item is implemented, in reading order; empty when the review gives none. */\n walkthrough: WalkthroughStep[];\n note?: string;\n};\n\n/** One segment of a walkthrough: a sentence and the `github:` key of the code it describes. */\nexport type WalkthroughStep = { text: string; key: string };\n\n/** At most this many segments: a walkthrough says where things are, it does not retell the code. */\nexport const MAX_WALKTHROUGH = 5;\n\n/** `- a` items, a line without the dash continuing the item above it. */\nconst listItems = (lines: readonly string[]): string[] =>\n lines.reduce<string[]>(\n (items, line) =>\n line.startsWith('-')\n ? [...items, line.replace(/^-\\s*/, '')]\n : items.length > 0\n ? [...items.slice(0, -1), `${items[items.length - 1]} ${line}`]\n : items,\n [],\n );\n\n/** `- <sentence>. github:<key>`, the key last; a step with no key is dropped. */\nconst parseStep = (item: string): WalkthroughStep[] => {\n const match = item.match(/^(.*?)\\s*(github:\\S+)\\s*$/);\n return match ? [{ text: match[1].replace(/[\\s.:—-]+$/, '').trim(), key: match[2] }] : [];\n};\n\n/**\n * The walkthrough shown for a verdict: the reviewer's, or one segment per evidence key when the item is implemented\n * in more than one place. Undefined for a single implementation, whose code chip already shows its declaration.\n */\nexport const walkthroughOf = (verdict: Verdict): WalkthroughStep[] | undefined => {\n if (verdict.walkthrough.length > 0) {\n return verdict.walkthrough.slice(0, MAX_WALKTHROUGH);\n }\n return verdict.evidence.length > 1\n ? verdict.evidence.slice(0, MAX_WALKTHROUGH).map((key) => ({ text: '', key }))\n : undefined;\n};\n\nexport type ReviewModel = {\n /** Frontmatter: the reviewed spec's key, the commit the code was read at, when, and by whom. */\n spec?: string;\n commit?: string;\n date?: string;\n by?: string;\n verdicts: Verdict[];\n};\n\nconst severity = (status: VerdictStatus): number => VERDICT_STATUSES.indexOf(status);\n\nconst isStatus = (value?: string): value is VerdictStatus =>\n value !== undefined && (VERDICT_STATUSES as readonly string[]).includes(value);\n\nconst parseFrontmatter = (text: string): Record<string, string> => {\n const body = text.match(/^---\\n([\\s\\S]*?)\\n---/)?.[1] ?? '';\n return Object.fromEntries(\n body.split('\\n').flatMap((line) => {\n const match = line.match(/^([\\w-]+):\\s*(.*?)\\s*$/);\n return match ? [[match[1], match[2]]] : [];\n }),\n );\n};\n\n/** The `verdict` blocks of a review document; a verdict with no known status is dropped. */\nexport const parseReview = (text: string): ReviewModel => {\n const { spec, commit, date, by } = parseFrontmatter(text);\n const verdicts = parseMdlBlocks(text)\n .filter(({ type, id }) => type === 'verdict' && id)\n .flatMap(({ id, title, body }): Verdict[] => {\n const fields = parseFields(body);\n const status = fields.get('status')?.inline;\n if (!isStatus(status)) {\n return [];\n }\n // A list may be inline (`[a, b]`), wrapped over several lines, or written as `- a` items.\n const list = (name: string) =>\n [fields.get(name)?.inline, ...(fields.get(name)?.lines ?? [])]\n .join(',')\n .split(',')\n .map((value) => value.replace(/^[\\s[-]+|[\\s\\]]+$/g, ''))\n .filter(Boolean);\n const note = [fields.get('note')?.inline, ...(fields.get('note')?.lines ?? [])].filter(Boolean).join(' ');\n return [\n {\n id,\n status,\n ...(title && { summary: title }),\n evidence: list('evidence'),\n tests: list('tests'),\n walkthrough: listItems(fields.get('walkthrough')?.lines ?? []).flatMap(parseStep),\n ...(note && { note }),\n },\n ];\n });\n return { spec, commit, date, by, verdicts };\n};\n\n/**\n * The status shown for a spec item: its own verdict, else the worst verdict of the items nested under it\n * (`F-1` from `F-1.1`, `F-1.2`), so a feature reads as missing when any of its requirements is.\n */\nexport const statusOf = (review: ReviewModel | undefined, id: string): VerdictStatus | undefined => {\n if (!review) {\n return undefined;\n }\n const own = review.verdicts.find((verdict) => verdict.id === id);\n if (own) {\n return own.status;\n }\n const nested = review.verdicts.filter((verdict) => verdict.id.startsWith(`${id}.`));\n return nested.length > 0\n ? nested.reduce((worst, { status }) => (severity(status) > severity(worst) ? status : worst), nested[0].status)\n : undefined;\n};\n\n/** Verdict counts per status, in display order. */\nexport const summarizeReview = (review: ReviewModel): { status: VerdictStatus; count: number }[] =>\n VERDICT_STATUSES.map((status) => ({\n status,\n count: review.verdicts.filter((verdict) => verdict.status === status).length,\n })).filter(({ count }) => count > 0);\n\n/** The files a review cites (evidence, tests and walkthrough steps), without fragments and in a stable order. */\nexport const citedFiles = (review: ReviewModel): string[] =>\n [\n ...new Set(\n review.verdicts\n .flatMap(({ evidence, tests, walkthrough }) => [...evidence, ...tests, ...walkthrough.map(({ key }) => key)])\n .map(parseSourceKey)\n .filter((key) => key !== undefined)\n .map((key) => formatSourceKey(key, false)),\n ),\n ].sort();\n\n/** Keys attached to a spec item from outside its text, e.g. a review's evidence; `id` may name a nested req (`F-1.2`). */\nexport type Annotation = {\n id: string;\n /** The code that implements the item. */\n keys: readonly SourceKey[];\n /** Whether a review found tests for the item; absent when it does not say. */\n testing?: 'tested' | 'untested';\n /** The tests that exercise the item. */\n tests?: readonly SourceKey[];\n};\n\n/**\n * A review's verdicts as annotations: the code that implements each item and the tests that exercise it. `done` means\n * tested by definition (see `VERDICT_STATUSES`); nothing is said about testing code that does not exist.\n */\nexport const reviewAnnotations = (review: ReviewModel | undefined): Annotation[] =>\n (review?.verdicts ?? []).map(({ id, status, evidence, tests }): Annotation => {\n const keys = evidence.map(parseSourceKey).filter((key) => key !== undefined);\n const testKeys = tests.map(parseSourceKey).filter((key) => key !== undefined);\n const testing = testKeys.length > 0 || status === 'done' ? 'tested' : status === 'missing' ? undefined : 'untested';\n return { id, keys, ...(testing && { testing }), ...(testKeys.length > 0 && { tests: testKeys }) };\n });\n","//\n// Copyright 2026 DXOS.org\n//\n\nconst escape = (text: string): string => text.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\n\n/** Declarations, most specific first: a top-level declaration beats a member, which beats a bare mention. */\nconst declarationPatterns = (name: string): RegExp[] => {\n const id = escape(name);\n return [\n new RegExp(\n `^\\\\s*(?:export\\\\s+)?(?:default\\\\s+)?(?:declare\\\\s+)?(?:abstract\\\\s+)?(?:async\\\\s+)?(?:class|interface|type|enum|function\\\\*?|const|let|var|namespace)\\\\s+${id}\\\\b`,\n ),\n new RegExp(\n `^\\\\s*(?:(?:public|private|protected|static|readonly|override|async|get|set|#)\\\\s*)*${id}\\\\s*(?:\\\\??[:(<=])`,\n ),\n new RegExp(`\\\\b${id}\\\\b`),\n ];\n};\n\n/**\n * The 1-based line that declares a symbol in a source file, or undefined when it is not there. A dotted name\n * (`Spec.make`, `Class.method`) finds the outer declaration first and then the member after it.\n */\nexport const findSymbolLine = (content: string, symbol: string): number | undefined => {\n const lines = content.split('\\n');\n let start = 0;\n let found: number | undefined;\n for (const [index, part] of symbol.split('.').entries()) {\n found = undefined;\n const [declaration, member, mention] = declarationPatterns(part);\n // After the owner, a member is what the dotted name means; a later top-level namesake is not.\n for (const pattern of index === 0 ? [declaration, member, mention] : [member, declaration, mention]) {\n const index = lines.findIndex((line, number) => number >= start && pattern.test(line));\n if (index >= 0) {\n found = index;\n break;\n }\n }\n if (found === undefined) {\n return undefined;\n }\n start = found + 1;\n }\n return found === undefined ? undefined : found + 1;\n};\n\n/** The longest declaration a snippet shows; a longer one ends with an ellipsis line. */\nconst MAX_SNIPPET_LINES = 16;\n\n/** A short excerpt of a source file: its first line number (1-based) and its lines. */\nexport type Snippet = { line: number; lines: string[]; truncated: boolean };\n\nconst depthChange = (line: string): number => {\n // Quoted text and line comments do not open or close a block.\n const code = line.replace(/([\"'`])(?:\\\\.|(?!\\1).)*\\1/g, '').replace(/\\/\\/.*$/, '');\n return (code.match(/[{([]/g)?.length ?? 0) - (code.match(/[})\\]]/g)?.length ?? 0);\n};\n\n/**\n * The declaration a key names, as shown on hover: from the declaring line to where its brackets close, or the\n * file's opening lines (after the copyright header) when there is no symbol. Undefined when the symbol is not there.\n */\nexport const declarationSnippet = (content: string, symbol?: string): Snippet | undefined => {\n const lines = content.split('\\n');\n let start: number;\n if (symbol) {\n const found = findSymbolLine(content, symbol);\n if (found === undefined) {\n return undefined;\n }\n start = found - 1;\n } else {\n start = 0;\n while (start < lines.length && (lines[start].startsWith('//') || lines[start].trim() === '')) {\n start++;\n }\n }\n\n let end = start;\n let depth = depthChange(lines[start] ?? '');\n // A declaration continues while a bracket it opened is still open.\n while (symbol && depth > 0 && end + 1 < lines.length) {\n end++;\n depth += depthChange(lines[end]);\n }\n if (!symbol) {\n end = Math.min(lines.length - 1, start + MAX_SNIPPET_LINES - 1);\n }\n const truncated = end - start + 1 > MAX_SNIPPET_LINES;\n return {\n line: start + 1,\n lines: lines.slice(start, truncated ? start + MAX_SNIPPET_LINES : end + 1),\n truncated: truncated || (!symbol && end < lines.length - 1),\n };\n};\n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{ o as parseMdlBlocks } from "./chunk-blocks.mjs";
|
|
3
|
+
//#region src/spec-index/spec-index.ts
|
|
4
|
+
/** Whether the index holds a tracked `.mdl` path; `lang/examples/` is excluded because its files share one id. */
|
|
5
|
+
var isIndexedSpec = (path) => !path.endsWith(".review.mdl") && !path.includes("__fixtures__") && !path.includes("/deus/lang/examples/");
|
|
6
|
+
var specItems = (text) => [...new Set(parseMdlBlocks(text).flatMap(({ id, body }) => [...id ? [id] : [], ...reqIds(body)]))];
|
|
7
|
+
/** Indexes spec texts by frontmatter id; a file with no id is skipped. */
|
|
8
|
+
var indexSpecs = (files) => {
|
|
9
|
+
const claims = /* @__PURE__ */ new Map();
|
|
10
|
+
for (const { path, text } of files) {
|
|
11
|
+
const id = frontmatter(text).id;
|
|
12
|
+
if (id) claims.set(id, [...claims.get(id) ?? [], {
|
|
13
|
+
path,
|
|
14
|
+
items: specItems(text)
|
|
15
|
+
}]);
|
|
16
|
+
}
|
|
17
|
+
const index = {
|
|
18
|
+
specs: {},
|
|
19
|
+
duplicates: {}
|
|
20
|
+
};
|
|
21
|
+
for (const [id, entries] of claims) if (entries.length === 1) index.specs[id] = entries[0];
|
|
22
|
+
else index.duplicates[id] = entries.map((entry) => entry.path);
|
|
23
|
+
return index;
|
|
24
|
+
};
|
|
25
|
+
//#endregion
|
|
26
|
+
export { frontmatter, indexSpecs, isIndexedSpec, reqIds, reqs };
|
|
27
|
+
|
|
28
|
+
//# sourceMappingURL=spec-index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spec-index.mjs","names":[],"sources":["../../src/spec-index/spec-index.ts"],"sourcesContent":["//\n// Copyright 2026 DXOS.org\n//\n\nimport { parseMdlBlocks } from '../extension/blocks.ts';\nimport { frontmatter, reqIds } from './parse.ts';\n\n/** One spec in the index: where it lives and every id a reference into it can name. */\nexport type SpecEntry = {\n /** POSIX, repo-relative. */\n path: string;\n /** Every block id and `req` id of the spec. */\n items: string[];\n};\n\nexport type SpecIndex = {\n /** Specs by frontmatter id; a duplicated id is absent. */\n specs: Record<string, SpecEntry>;\n /** Each duplicated id with every path that claims it. */\n duplicates: Record<string, string[]>;\n};\n\n/** Whether the index holds a tracked `.mdl` path; `lang/examples/` is excluded because its files share one id. */\nexport const isIndexedSpec = (path: string): boolean =>\n !path.endsWith('.review.mdl') && !path.includes('__fixtures__') && !path.includes('/deus/lang/examples/');\n\nconst specItems = (text: string): string[] => [\n ...new Set(parseMdlBlocks(text).flatMap(({ id, body }) => [...(id ? [id] : []), ...reqIds(body)])),\n];\n\n/** Indexes spec texts by frontmatter id; a file with no id is skipped. */\nexport const indexSpecs = (files: { path: string; text: string }[]): SpecIndex => {\n const claims = new Map<string, { path: string; items: string[] }[]>();\n for (const { path, text } of files) {\n const id = frontmatter(text).id;\n if (id) {\n claims.set(id, [...(claims.get(id) ?? []), { path, items: specItems(text) }]);\n }\n }\n const index: SpecIndex = { specs: {}, duplicates: {} };\n for (const [id, entries] of claims) {\n if (entries.length === 1) {\n index.specs[id] = entries[0];\n } else {\n index.duplicates[id] = entries.map((entry) => entry.path);\n }\n }\n return index;\n};\n"],"mappings":";;;;AAuBA,IAAa,iBAAiB,SAC5B,CAAC,KAAK,SAAS,aAAa,KAAK,CAAC,KAAK,SAAS,cAAc,KAAK,CAAC,KAAK,SAAS,sBAAsB;AAE1G,IAAM,aAAa,SAA2B,CAC5C,GAAG,IAAI,IAAI,eAAe,IAAI,CAAC,CAAC,SAAS,EAAE,IAAI,WAAW,CAAC,GAAI,KAAK,CAAC,EAAE,IAAI,CAAC,GAAI,GAAG,OAAO,IAAI,CAAC,CAAC,CAAC,CACnG;;AAGA,IAAa,cAAc,UAAuD;CAChF,MAAM,yBAAS,IAAI,IAAiD;CACpE,KAAK,MAAM,EAAE,MAAM,UAAU,OAAO;EAClC,MAAM,KAAK,YAAY,IAAI,CAAC,CAAC;EAC7B,IAAI,IACF,OAAO,IAAI,IAAI,CAAC,GAAI,OAAO,IAAI,EAAE,KAAK,CAAC,GAAI;GAAE;GAAM,OAAO,UAAU,IAAI;EAAE,CAAC,CAAC;CAEhF;CACA,MAAM,QAAmB;EAAE,OAAO,CAAC;EAAG,YAAY,CAAC;CAAE;CACrD,KAAK,MAAM,CAAC,IAAI,YAAY,QAC1B,IAAI,QAAQ,WAAW,GACrB,MAAM,MAAM,MAAM,QAAQ;MAE1B,MAAM,WAAW,MAAM,QAAQ,KAAK,UAAU,MAAM,IAAI;CAG5D,OAAO;AACT"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deus.d.ts","sourceRoot":"","sources":["../../../bin/deus.ts"],"names":[],"mappings":""}
|