refactor: unify declare block scanning between CLI and client

Introduce `scanDeclareBlocks` in `declare-parser.ts` to provide a
single source of truth for parsing `role=declare` blocks. This
replaces redundant scanning logic in both the CLI and the journal
completions.

Also remove unused `dice.ts` and `spark-scanner.ts` files.
This commit is contained in:
2026-07-13 10:43:44 +08:00
parent 3137970b97
commit f172da378a
5 changed files with 73 additions and 220 deletions
+4 -8
View File
@@ -7,7 +7,7 @@
import { posix } from "path";
import { createHash } from "crypto";
import { parseDeclareCsv, type VarDeclaration, type TagModifier } from "./declare-parser.js";
import { scanDeclareBlocks, type VarDeclaration, type TagModifier } from "./declare-parser.js";
import {
FENCED_BLOCK_RE,
parseBlockAttrs,
@@ -86,13 +86,9 @@ export function processBlocks(
// ---- Dispatch by role ----
if (attrs.role === "declare") {
try {
const result = parseDeclareCsv(body, fileRelativePath);
blocks.declarations.push(...result.variables);
blocks.tagModifiers.push(...result.tagModifiers);
} catch (e) {
console.warn(`[block-processor] ${fileRelativePath}: ${e}`);
}
const result = scanDeclareBlocks(_match, fileRelativePath);
blocks.declarations.push(...result.variables);
blocks.tagModifiers.push(...result.tagModifiers);
}
if (attrs.role === "file") {