@descent-vtt/spec-harness 0.20.0 → 0.21.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/.claude-plugin/marketplace.json +1 -1
- package/.claude-plugin/plugin.json +1 -1
- package/CHANGELOG.md +113 -0
- package/README.md +13 -7
- package/dist/cli.d.ts +1 -1
- package/dist/cli.js +119 -30
- package/dist/cli.js.map +1 -1
- package/dist/configure.d.ts +40 -3
- package/dist/configure.js +75 -9
- package/dist/configure.js.map +1 -1
- package/dist/fs.d.ts +30 -4
- package/dist/fs.js +104 -11
- package/dist/fs.js.map +1 -1
- package/dist/git.d.ts +38 -0
- package/dist/git.js +59 -2
- package/dist/git.js.map +1 -1
- package/dist/guard.d.ts +20 -1
- package/dist/guard.js +31 -0
- package/dist/guard.js.map +1 -1
- package/dist/hooks.d.ts +14 -0
- package/dist/hooks.js +14 -0
- package/dist/hooks.js.map +1 -1
- package/dist/round.d.ts +19 -1
- package/dist/round.js +59 -16
- package/dist/round.js.map +1 -1
- package/dist/server.js +42 -7
- package/dist/server.js.map +1 -1
- package/dist/siblings.d.ts +5 -3
- package/dist/siblings.js +52 -31
- package/dist/siblings.js.map +1 -1
- package/dist/workspace.js +23 -13
- package/dist/workspace.js.map +1 -1
- package/package.json +3 -3
package/dist/round.js
CHANGED
|
@@ -17,11 +17,11 @@ import { fileURLToPath } from 'node:url';
|
|
|
17
17
|
import { readArchivePlan, readGuardRun } from './answers.js';
|
|
18
18
|
import { SiblingOutputError } from './briefs.js';
|
|
19
19
|
import { sameId } from './branch.js';
|
|
20
|
-
import { arrayMatcher, enabledPlugin, exportedFile, handedLines, hooksDisabled, HOSTED_REGISTRY, isStarted, loadsPlugin, MARKETPLACE_REGISTRY, matchingUnder, patternReader, pluginMarketplace, pluginPresence, PROJECT_SETTINGS, readsOnFailure, registersServer, reportHooks, SPEC_BRIEF_CONFIGS, startsSessions, wiringState, } from './configure.js';
|
|
20
|
+
import { arrayMatcher, enabledPlugin, exportedFile, handedLines, hooksDisabled, HOSTED_REGISTRY, isStarted, loadsPlugin, MARKETPLACE_REGISTRY, matchingUnder, patternReader, pluginMarketplace, pluginPresence, PROJECT_SETTINGS, readsOnFailure, registersServer, reportHooks, reportsTurns, SPEC_BRIEF_CONFIGS, startsSessions, wiringState, } from './configure.js';
|
|
21
21
|
import { readRules, renderContext } from './context.js';
|
|
22
|
-
import { isDirectory, isFile, readJsonObject, readText, repositoryPath, stateDirectory, writeAtomic } from './fs.js';
|
|
22
|
+
import { isDirectory, isFile, reachedBy, readJsonObject, readText, repositoryPath, stateDirectory, writeAtomic } from './fs.js';
|
|
23
23
|
import { blameLine, changes, commonDirectory, isUncommitted, mergeBase, remoteDefault, revision, show, verifyCommit, workTreeRoot } from './git.js';
|
|
24
|
-
import { decide } from './guard.js';
|
|
24
|
+
import { decide, decideWritten } from './guard.js';
|
|
25
25
|
import { diffManifest, ecosystemOf, readManifestNames } from './manifests.js';
|
|
26
26
|
import { addRulingRow, nextId, readRulings, renderMemo, renderRow, } from './rulings.js';
|
|
27
27
|
import { compileGlob } from './vendor/spec-core/pattern/index.js';
|
|
@@ -119,8 +119,14 @@ export async function briefText(workspace, brief) {
|
|
|
119
119
|
* decides every write need not load a scanner for those that read none.
|
|
120
120
|
*/
|
|
121
121
|
export async function checkPaths(workspace, brief, noBrief, given, cwd, reader, baseFlag) {
|
|
122
|
-
|
|
123
|
-
|
|
122
|
+
// Each path as it reads and as the system writes it, which a link can make
|
|
123
|
+
// two files: the last a path reaches is the one it is written to, or the
|
|
124
|
+
// one it reads as where that is all it reaches (ADR-0005).
|
|
125
|
+
const resolved = given.map((path) => ({ given: path, path: repositoryPath(path, workspace.root, cwd), written: repositoryPath(reachedBy(path, cwd).at(-1), workspace.root, cwd) }));
|
|
126
|
+
const decideAll = (rulings) => resolved.map(({ path, given: g, written }) => {
|
|
127
|
+
const input = { path, given: g, brief, noBrief, rulings, outOfScope: workspace.config.outOfScope };
|
|
128
|
+
return decideWritten(decide(input), { ...input, path: written });
|
|
129
|
+
});
|
|
124
130
|
const first = decideAll([]);
|
|
125
131
|
// Rulings cost the reader of a brief, and a blame and a signature check
|
|
126
132
|
// each, so they are read only when a write reaches a protected file. Read
|
|
@@ -433,8 +439,14 @@ export async function claudeSettings(root, env) {
|
|
|
433
439
|
* the release, so it says that it does not report it, and it is asked only
|
|
434
440
|
* where a line turns on it: where what is read of the lines differs between
|
|
435
441
|
* a release that cannot be told and the newest.
|
|
442
|
+
*
|
|
443
|
+
* `doctor` also looks for the script each line runs in `places`, each
|
|
444
|
+
* directory `${CLAUDE_PROJECT_DIR}` can name as a session starts, and says
|
|
445
|
+
* a line whose script is in none as a guard that is off (reportHooks).
|
|
446
|
+
* `init` gives none: it writes the line that names the project's install,
|
|
447
|
+
* which may come after it.
|
|
436
448
|
*/
|
|
437
|
-
export async function claudeCodeWiring(root, io, pattern = patternReader(), reported = true) {
|
|
449
|
+
export async function claudeCodeWiring(root, io, pattern = patternReader(), reported = true, places = null) {
|
|
438
450
|
const sources = await claudeSettings(root, io.env);
|
|
439
451
|
// Each line is read once, before any is reported: what the brief on one
|
|
440
452
|
// names is spec-brief's to say, and the report itself asks nothing.
|
|
@@ -456,15 +468,16 @@ export async function claudeCodeWiring(root, io, pattern = patternReader(), repo
|
|
|
456
468
|
// equivalent.
|
|
457
469
|
const isHook = (words) => claudeHookLine(words, parseOptions, root, (path) => isDirectory(resolve(root, path))) !== null;
|
|
458
470
|
const sessionStart = sources.some(({ settings }) => startsSessions(settings, isHook));
|
|
471
|
+
const turnEnd = sources.some(({ settings }) => reportsTurns(settings, isHook));
|
|
459
472
|
// init writes its hooks into the project's file alone, and none where an array unloads it.
|
|
460
473
|
const unloaded = arrayMatcher(sources.find(({ file }) => file === PROJECT_SETTINGS).settings);
|
|
461
474
|
const under = (release) => {
|
|
462
|
-
const lines = reportHooks(sources, root, (words) => read.get(JSON.stringify(words)), pattern, matchingUnder(release), readsOnFailure(release));
|
|
475
|
+
const lines = reportHooks(sources, root, (words) => read.get(JSON.stringify(words)), pattern, matchingUnder(release), readsOnFailure(release), places === null ? null : { projects: places, isFile });
|
|
463
476
|
// A line Claude Code starts for no write, before one or after, is in no
|
|
464
477
|
// one's way: it is said, and the file is not counted for it.
|
|
465
478
|
const hooks = sources.map(({ file }) => file).filter((file) => lines.some((line) => line.file === file && (isStarted(line.before) || isStarted(line.after))));
|
|
466
479
|
// In the order a document has them, which a script may compare by the byte.
|
|
467
|
-
return { plugin, presence, hooksOff: hooksDisabled(sources), hooks, lines, server, sessionStart, release, unloaded };
|
|
480
|
+
return { plugin, presence, hooksOff: hooksDisabled(sources), hooks, lines, server, sessionStart, turnEnd, release, unloaded };
|
|
468
481
|
};
|
|
469
482
|
const untold = under(null);
|
|
470
483
|
const asked = reported ? wiringState(untold) !== 'none' : JSON.stringify(untold.lines) !== JSON.stringify(reportHooks(sources, root, (words) => read.get(JSON.stringify(words)), pattern));
|
|
@@ -519,8 +532,14 @@ async function hookLineHere(words, root, io) {
|
|
|
519
532
|
if (line.brief === undefined)
|
|
520
533
|
return told;
|
|
521
534
|
const workspace = await openWorkspace({ root: line.root === undefined ? root : resolve(root, line.root) }, io);
|
|
522
|
-
const { problem } = await diagnoseBrief(workspace, { brief: line.brief }, io.env);
|
|
523
|
-
|
|
535
|
+
const { id, problem } = await diagnoseBrief(workspace, { brief: line.brief }, io.env);
|
|
536
|
+
if (problem !== null)
|
|
537
|
+
return heldHookLine(problem);
|
|
538
|
+
// A spec-brief that cannot be run is no problem of a name given as a
|
|
539
|
+
// flag, and the hook holds every write all the same: it asks spec-brief
|
|
540
|
+
// about the brief its line names before each one.
|
|
541
|
+
const sibling = workspace.siblings.locate('spec-brief');
|
|
542
|
+
return sibling.kind === 'found' ? told : heldHookLine(couldNotSay(id, sibling.reason));
|
|
524
543
|
}
|
|
525
544
|
/**
|
|
526
545
|
* The brief a round works on, as doctor reports it: its id, and what is
|
|
@@ -534,29 +553,53 @@ async function hookLineHere(words, root, io) {
|
|
|
534
553
|
* setup that holds every write, as a hook's line naming such a brief is
|
|
535
554
|
* (ADR-0004). A name the flag gives is the question doctor was asked, and
|
|
536
555
|
* holds no write of anyone's.
|
|
556
|
+
*
|
|
557
|
+
* `holds` is whether the branch names a brief and spec-brief cannot answer
|
|
558
|
+
* for it: not installed, too old, or failing as it is asked. The hook asks
|
|
559
|
+
* spec-brief before every write under the name, and holds each write it
|
|
560
|
+
* cannot ask about, so that too is a setup that holds every write.
|
|
561
|
+
*
|
|
562
|
+
* `archived` is the brief the branch names where spec-brief has archived
|
|
563
|
+
* it, which doctor reads further in git: the branch that archived it waits
|
|
564
|
+
* to merge, and fails nothing (ADR-0004). It reads nothing else, and the
|
|
565
|
+
* problem is the one every write is held with, as before.
|
|
537
566
|
*/
|
|
538
567
|
export async function diagnoseBrief(workspace, options, env) {
|
|
539
568
|
if (options.brief !== undefined && isBlank(options.brief))
|
|
540
|
-
return { id: null, problem: emptyValue('--brief', 'brief', options.brief), branch: false };
|
|
569
|
+
return { id: null, problem: emptyValue('--brief', 'brief', options.brief), branch: false, holds: false, archived: null };
|
|
541
570
|
const id = namedId(workspace, options, env);
|
|
542
|
-
//
|
|
543
|
-
|
|
544
|
-
|
|
571
|
+
// Neither the flag nor SPEC_BRIEF names it, so the name is the branch's,
|
|
572
|
+
// where something names one. A flag given only blanks was answered above.
|
|
573
|
+
const byBranch = id !== null && options.brief === undefined && isBlank(env['SPEC_BRIEF'] ?? '');
|
|
574
|
+
const sibling = workspace.siblings.locate('spec-brief');
|
|
575
|
+
if (sibling.kind !== 'found') {
|
|
576
|
+
// Under the flag or SPEC_BRIEF, a spec-brief that cannot be run is a row
|
|
577
|
+
// of the report, with the reason. Under the branch it is the reason
|
|
578
|
+
// the hook holds every write, and said as one it could not ask. There
|
|
579
|
+
// `holds` fails doctor whatever `branch` says, and nothing else reads
|
|
580
|
+
// `branch`, so its `false` is equivalent to its mutant.
|
|
581
|
+
return byBranch ? { id, problem: couldNotSay(id, sibling.reason), branch: false, holds: true, archived: null } : { id, problem: null, branch: false, holds: false, archived: null };
|
|
582
|
+
}
|
|
545
583
|
try {
|
|
546
584
|
// Where nothing names a brief, spec-brief is not asked (ADR-0004), and
|
|
547
585
|
// there is no problem to state.
|
|
548
586
|
const active = await activeBrief(workspace, options, env);
|
|
549
587
|
const branch = (active.kind === 'unknown' || active.kind === 'archived') && active.source === 'branch';
|
|
550
|
-
|
|
588
|
+
const archived = active.kind === 'archived' && active.source === 'branch' ? active.brief : null;
|
|
589
|
+
return { id, problem: describeActive(active).problem, branch, holds: false, archived };
|
|
551
590
|
}
|
|
552
591
|
catch (error) {
|
|
553
592
|
// Asking spec-brief throws nothing but this, so the check is equivalent
|
|
554
593
|
// to its mutant; it keeps any other error the stack it needs.
|
|
555
594
|
if (!(error instanceof SiblingError))
|
|
556
595
|
throw error;
|
|
557
|
-
return { id, problem:
|
|
596
|
+
return { id, problem: couldNotSay(id, error.message), branch: false, holds: byBranch, archived: null };
|
|
558
597
|
}
|
|
559
598
|
}
|
|
599
|
+
/** What is said of a brief spec-brief could not be asked about, and why. */
|
|
600
|
+
function couldNotSay(id, why) {
|
|
601
|
+
return `spec-brief could not say whether it knows brief ${id}: ${why}`;
|
|
602
|
+
}
|
|
560
603
|
async function archiveReasons(workspace, brief, base) {
|
|
561
604
|
const args = ['archive', brief.id, '--dry-run', '--format', 'json', '--no-color'];
|
|
562
605
|
if (base.kind === 'resolved')
|
package/dist/round.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"round.js","sourceRoot":"","sources":["../src/round.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACjE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC1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,EAAE,GAAG,MAAM,CAAC,GAAG,EAAE,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;IAC7C,MAAM,GAAG,GAAG,SAAS,CAAC,EAAE,EAAE,OAAO,CAAC,KAAK,EAAE,QAAQ,EAAE,IAAI,CAAC,CAAC;IACzD,MAAM,WAAW,CAAC,IAAI,EAAE,YAAY,CAAC,IAAI,EAAE,SAAS,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC,CAAC;IAC1F,oEAAoE;IACpE,uEAAuE;IACvE,MAAM,EAAE,CAAC,IAAI,CAAC,MAAM,mBAAmB,CAAC,SAAS,CAAC,EAAE,GAAG,OAAO,CAAC,EAAE,OAAO,CAAC,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;IAC5F,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,OAAO,CAAC,SAAS,EAAE,GAAG,EAAE,CAAC;AAC9C,CAAC","sourcesContent":["/**\n * A round, measured: the operations the command line and the MCP server\n * share. Each gathers what a pure module needs - from git, the disk and the\n * siblings - and hands it over; the decisions are made in `context.ts`,\n * `audit.ts`, `guard.ts` and `rulings.ts`.\n *\n * The hook loads this module before every write it decides, so what only\n * an audit, a verified ruling or `doctor` runs is imported where it runs:\n * the audit's judgement, which brings the Markdown scanner with it, the\n * hash a copy of the signers is named by, and what asks Claude Code its\n * release.\n */\n\nimport { existsSync, readFileSync, realpathSync } from 'node:fs';\nimport { readdir, readFile, rm } from 'node:fs/promises';\nimport { join, resolve } from 'node:path';\nimport { fileURLToPath } from 'node:url';\n\nimport { readArchivePlan, readGuardRun } from './answers.js';\nimport type { ArchiveReason, AssertionOutcome, AuditInput, AuditReport, UnreadableAssertion } from './audit.js';\nimport { SiblingOutputError } from './briefs.js';\nimport { sameId } from './branch.js';\nimport {\n arrayMatcher,\n enabledPlugin,\n exportedFile,\n handedLines,\n hooksDisabled,\n HOSTED_REGISTRY,\n isStarted,\n loadsPlugin,\n MARKETPLACE_REGISTRY,\n matchingUnder,\n patternReader,\n pluginMarketplace,\n pluginPresence,\n PROJECT_SETTINGS,\n readsOnFailure,\n registersServer,\n reportHooks,\n SPEC_BRIEF_CONFIGS,\n startsSessions,\n wiringState,\n type BaseSource,\n type ClaudeCodeWiring,\n type ClaudeSettings,\n type PatternReader,\n type PluginsRoot,\n type PluginState,\n} from './configure.js';\nimport { readRules, renderContext, type CitedDocument, type ContextPacket, type Rules } from './context.js';\nimport type { DocumentReader } from './document.js';\nimport { isDirectory, isFile, readJsonObject, readText, repositoryPath, stateDirectory, writeAtomic } from './fs.js';\nimport { blameLine, changes, commonDirectory, isUncommitted, mergeBase, remoteDefault, revision, show, verifyCommit, workTreeRoot } from './git.js';\nimport { decide, type Decision, type VerifiedRuling } from './guard.js';\nimport { diffManifest, ecosystemOf, readManifestNames, type DependencyChange, type InstallScriptChange } from './manifests.js';\nimport {\n addRulingRow,\n nextId,\n readRulings,\n renderMemo,\n renderRow,\n type EscalationOption,\n type EscalationRequest,\n type RulingRow,\n} from './rulings.js';\nimport type { BriefRow, Finding } from './types.js';\nimport { compileGlob, type LiteralReading } from './vendor/spec-core/pattern/index.js';\nimport { dirname, isRelativeReference, resolveInside, splitReference } from './vendor/spec-core/path/index.js';\nimport { SiblingError } from './siblings.js';\nimport { claudeHookLine, elsewhereHookLine, emptyValue, heldHookLine, holderHookLine, isBlank, outsideHookLine, type HookLine } from './usage.js';\nimport { checkClaudeCode, type ClaudeCodeCheck } from './versions.js';\nimport { activeBrief, describeActive, namedId, openWorkspace, parseOptions, UsageError, type CliIO, type Options, type Workspace } from './workspace.js';\n\n/* -------------------------------------------------------------------- base */\n\nexport type Base =\n | { readonly kind: 'resolved'; readonly ref: string; readonly source: BaseSource; readonly sha: string; readonly mergeBase: string; readonly head: string }\n | { readonly kind: 'unresolved'; readonly reason: string };\n\n/** What the round is measured from: the flag, the configuration, then the remote's default branch. */\nexport async function resolveBase(workspace: Workspace, flag: string | undefined): Promise<Base> {\n const source: BaseSource = flag !== undefined ? 'flag' : workspace.config.base !== null ? 'config' : 'remote';\n const ref = flag ?? workspace.config.base ?? (await remoteDefault(workspace.root));\n if (ref === null) {\n return { kind: 'unresolved', reason: 'no base is named and the remote has no default branch; pass --base <ref> or set \"base\"' };\n }\n // Neither commit waits on the other, so git is asked for both at once, and\n // they are read in the order they were asked in before: a base that names\n // no commit is said before a HEAD that names none.\n const [sha, head] = await Promise.all([revision(ref, workspace.root), revision('HEAD', workspace.root)]);\n if (sha === null) return { kind: 'unresolved', reason: `\"${ref}\" names no commit` };\n if (head === null) return { kind: 'unresolved', reason: 'HEAD names no commit: nothing is committed on this branch yet' };\n const common = await mergeBase(sha, head, workspace.root);\n if (common === null) return { kind: 'unresolved', reason: `\"${ref}\" and HEAD share no history` };\n return { kind: 'resolved', ref, source, sha, mergeBase: common, head };\n}\n\n/* ----------------------------------------------------------------- rulings */\n\nexport interface RulingCheck {\n readonly rows: readonly RulingRow[];\n readonly verified: readonly VerifiedRuling[];\n readonly unverified: readonly { readonly id: string; readonly reason: string }[];\n readonly problems: readonly Finding[];\n}\n\n/**\n * The brief's rulings, each checked against its signature: the commit that\n * last changed its row must be signed by a principal the base branch's\n * allowed-signers file lists (ADR-0006).\n */\nexport async function checkRulings(workspace: Workspace, brief: Pick<BriefRow, 'file'>, text: string, reader: DocumentReader, base: Base): Promise<RulingCheck> {\n const { rulings: rows, problems } = readRulings(reader.sectionTables(text, workspace.config.rulings.section).tables);\n const findings: Finding[] = problems.map((problem) => ({\n rule: 'ruling-unreadable',\n severity: 'warning',\n message: problem.message,\n hint: 'a ruling row is | id | `paths` | allow or deny | note |',\n file: brief.file,\n line: problem.line,\n }));\n const allows = rows.filter((row) => row.decision === 'allow');\n // Nothing below verifies a row that allows nothing, so this saves a git\n // show and is equivalent to its mutants.\n if (allows.length === 0) return { rows, verified: [], unverified: [], problems: findings };\n if (base.kind === 'unresolved') {\n return { rows, verified: [], unverified: allows.map((row) => ({ id: row.id, reason: `no base to read the allowed signers from: ${base.reason}` })), problems: findings };\n }\n const signers = await show(base.sha, workspace.config.rulings.allowedSigners, workspace.root);\n if (signers === null) {\n const reason = `${base.ref} has no ${workspace.config.rulings.allowedSigners}, so no signature can count`;\n return { rows, verified: [], unverified: allows.map((row) => ({ id: row.id, reason })), problems: findings };\n }\n // Only verify-commit below reads this copy, so where it is kept, and under\n // what name, is equivalent to its mutants. The one that reads the digest\n // with no encoding names the file by its bytes, which a path refuses when\n // one of them is NUL: a sweep counts that mutant killed now and then.\n const directory = await stateDirectory(workspace.commonDir, 'signers');\n const { createHash } = await import('node:crypto');\n const file = join(directory, `${createHash('sha256').update(signers).digest('hex').slice(0, 16)}`);\n await writeAtomic(file, signers);\n const verified: VerifiedRuling[] = [];\n const unverified: { id: string; reason: string }[] = [];\n for (const row of allows) {\n // The row's line is a line of the text on disk, so it is blamed there: at\n // HEAD the same number can be another line, one a signed commit wrote,\n // and an uncommitted row would borrow that commit's signature.\n const commit = await blameLine(null, brief.file, row.line, workspace.root);\n if (commit === null || isUncommitted(commit)) {\n unverified.push({ id: row.id, reason: 'its row is not committed' });\n continue;\n }\n const signature = await verifyCommit(commit, file, workspace.root);\n if (signature.good) verified.push({ id: row.id, paths: row.paths, signer: signature.principal });\n else unverified.push({ id: row.id, reason: `commit ${commit.slice(0, 12)} last changed its row, and ${signature.detail || 'it is not signed'}` });\n }\n return { rows, verified, unverified, problems: findings };\n}\n\n/* ------------------------------------------------------------------- guard */\n\nexport async function briefText(workspace: Workspace, brief: BriefRow): Promise<string> {\n const text = await readText(join(workspace.root, brief.file));\n if (text === null) throw new UsageError(`${brief.file} cannot be read`);\n return text;\n}\n\n/**\n * Decides paths against the brief, with the rulings verified against the\n * base `baseFlag` names, or the configured one. The reader may be given as\n * what makes one: it is asked for where a ruling is read, and a caller that\n * decides every write need not load a scanner for those that read none.\n */\nexport async function checkPaths(\n workspace: Workspace,\n brief: BriefRow | null,\n noBrief: string | undefined,\n given: readonly string[],\n cwd: string,\n reader: DocumentReader | (() => Promise<DocumentReader>),\n baseFlag: string | undefined,\n): Promise<Decision[]> {\n const resolved = given.map((path) => ({ given: path, path: repositoryPath(path, workspace.root, cwd) }));\n const decideAll = (rulings: readonly VerifiedRuling[]): Decision[] =>\n resolved.map(({ path, given: g }) => decide({ path, given: g, brief, noBrief, rulings, outOfScope: workspace.config.outOfScope }));\n const first = decideAll([]);\n // Rulings cost the reader of a brief, and a blame and a signature check\n // each, so they are read only when a write reaches a protected file. Read\n // anyway, they decide the same, since a ruling allows only a protected\n // path: what a mutant that always reads them changes is what is loaded\n // for a write no brief protects (loads.test.ts). With no brief nothing is\n // protected, so the null check is there for the type.\n if (brief === null || !first.some((decision) => decision.reason === 'protected')) return first;\n const text = await briefText(workspace, brief);\n const documents = typeof reader === 'function' ? await reader() : reader;\n // The base is where the allowed signers are read, and only a row that\n // allows something is checked against them: where none does, git is asked\n // nothing of the base, three processes of a refusal, and what was decided\n // without a ruling stands.\n const { rulings } = readRulings(documents.sectionTables(text, workspace.config.rulings.section).tables);\n if (!rulings.some((row) => row.decision === 'allow')) return first;\n const base = await resolveBase(workspace, baseFlag);\n return decideAll((await checkRulings(workspace, brief, text, documents, base)).verified);\n}\n\n/* ----------------------------------------------------------------- context */\n\n/**\n * The paths spec-guard is asked about for a scope: where its patterns can\n * match. A name with no glob syntax that exists is asked about as itself,\n * since spec-guard reads from the disk whether a path is a file or a\n * directory. One the round has yet to create may become either, and\n * spec-guard would read it as a file, leaving out the rules over a\n * directory of that name; it is asked about through the directory that will\n * hold it, the root for a name at the top, which covers both.\n */\nfunction scopeBases(root: string, patterns: readonly string[]): string[] {\n // Read as a directory, a name's base is the name itself; read any other\n // way, it is the directory holding it, so which other reading a missing\n // name gets changes nothing. The glob is compiled for its bases and never\n // matched: a file read as a directory narrows the question and nothing\n // else.\n const literal = (path: string): LiteralReading => (existsSync(join(root, path)) ? 'directory' : 'either');\n const bases = new Set<string>();\n for (const pattern of patterns) {\n try {\n // Case is read only in matching, which this compile never does: its\n // bases are the same either way, so `caseSensitive: false` is equivalent.\n for (const base of compileGlob(pattern, { dialect: 'path', caseSensitive: true, literal }).bases) {\n // A rooted alternative's base, `/docs` or `/`, is outside the\n // repository: it puts no path in the scope, and spec-guard refuses\n // the whole question for it, with the rules for every other base.\n // The packet names the pattern.\n if (base.startsWith('/')) continue;\n bases.add(base === '' ? '.' : base);\n }\n } catch {\n // The packet names a pattern the guard cannot read, with spec-core's\n // reason, and says so when it is every pattern; the rules for the rest\n // still count.\n }\n }\n return [...bases].sort();\n}\n\nasync function rulesFor(workspace: Workspace, brief: BriefRow): Promise<Rules> {\n const paths = scopeBases(workspace.root, brief.affectedFiles);\n if (paths.length === 0) return [];\n try {\n const answer = await workspace.siblings.json('spec-guard', ['query', ...paths, '--json']);\n return 'absent' in answer ? { unavailable: answer.absent } : readRules(answer);\n } catch (error) {\n // spec-guard printed no JSON, or a document of another shape: what it\n // said instead, or what was wrong, is the reason, and the rest of the\n // packet stands without the rules.\n if (error instanceof SiblingError || error instanceof SiblingOutputError) return { unavailable: error.message };\n throw error;\n }\n}\n\nasync function citedDocuments(workspace: Workspace, brief: BriefRow, text: string, reader: DocumentReader): Promise<CitedDocument[]> {\n const seen = new Set<string>();\n const out: CitedDocument[] = [];\n for (const citation of reader.citations(text)) {\n if (!isRelativeReference(citation.target)) continue;\n let target = splitReference(citation.target).path;\n try {\n target = decodeURIComponent(target);\n } catch {\n // A destination that is not valid percent-encoding is read as written.\n }\n const path = resolveInside(dirname(brief.file), target);\n if (path === null || path === brief.file || seen.has(path)) continue;\n seen.add(path);\n const document = /\\.(?:md|markdown|mdx|txt)$/i.test(path);\n // A link to code or a directory that exists is not a document to include,\n // and must not be reported as a link that resolves to nothing.\n if (!document && existsSync(join(workspace.root, path))) continue;\n const content = document ? await readText(join(workspace.root, path)) : null;\n // A document that cannot be read is listed by its path alone, so its\n // title and status are never read, and an empty object is equivalent.\n const meta = content === null ? { title: null, status: null } : reader.titleAndStatus(content);\n out.push({ path, ...meta, text: content });\n }\n return out;\n}\n\nexport async function buildContext(\n workspace: Workspace,\n brief: BriefRow,\n briefs: readonly BriefRow[],\n reader: DocumentReader,\n baseFlag: string | undefined,\n): Promise<ContextPacket> {\n const text = await briefText(workspace, brief);\n const base = await resolveBase(workspace, baseFlag);\n const [rules, cited, rulings] = await Promise.all([\n rulesFor(workspace, brief),\n citedDocuments(workspace, brief, text, reader),\n checkRulings(workspace, brief, text, reader, base),\n ]);\n return renderContext({\n brief,\n briefText: text,\n dependencies: brief.dependsOn.map(\n (id) =>\n // spec-brief reports a dependency as its front matter spells it, `7` for brief 007.\n // The context reads a dependency's id, title, status and phase, and\n // the brief copied here is live.\n briefs.find((candidate) => sameId(candidate.id, id)) ?? { ...brief, id, title: '(no such brief)', status: 'unknown' },\n ),\n cited,\n rules,\n rulings: rulings.verified,\n branch: workspace.branch,\n base: base.kind === 'resolved' ? base.ref : null,\n budget: workspace.config.context.budget,\n });\n}\n\n/* ------------------------------------------------------------------- audit */\n\nasync function dependencyChanges(workspace: Workspace, base: Base): Promise<AuditInput['dependencies'] & { readonly installScripts: readonly InstallScriptChange[] }> {\n // A name that cannot be read is reported with or without a base: it would\n // leave its manifests out of every audit measured from one.\n const names = readManifestNames(workspace.config.dependencies.manifests);\n if (base.kind === 'unresolved') return { changes: [], installScripts: [], unread: [], unreadNames: names.unread, rootedNames: names.rooted };\n const isManifest = names.match;\n const out: DependencyChange[] = [];\n const installScripts: InstallScriptChange[] = [];\n const unread: string[] = [];\n for (const change of await changes(base.mergeBase, base.head, workspace.root)) {\n if (!isManifest(change.path) && !(change.from !== undefined && isManifest(change.from))) continue;\n const ecosystem = ecosystemOf(change.path);\n if (ecosystem === null) {\n unread.push(change.path);\n continue;\n }\n // git shows nothing where a file is not: an added manifest has no before,\n // and a deleted one no after.\n const before = await show(base.mergeBase, change.from ?? change.path, workspace.root);\n const after = await show(base.head, change.path, workspace.root);\n const diff = diffManifest(change.path, ecosystem, before, after);\n if ('error' in diff) {\n unread.push(change.path);\n continue;\n }\n out.push(...diff.changes);\n installScripts.push(...diff.installScripts);\n }\n return { changes: out, installScripts, unread, unreadNames: names.unread, rootedNames: names.rooted };\n}\n\n/** A file's real path, links and the filesystem's case resolved, or `null` when there is no such file. */\nfunction realFile(path: string): string | null {\n try {\n return realpathSync.native(path);\n } catch {\n return null;\n }\n}\n\n/**\n * Whether a path spec-brief's `plugins` names, read from the root, is this\n * package's plugin: the file its `./spec-brief-plugin` export names, as the\n * project installed the package, or as this copy of it ships. spec-brief\n * loads a plugin by a path as well as by its name, and a path to the plugin\n * read as another plugin would say the archive cannot accept a ruling it can.\n */\nexport function pluginFile(root: string): (path: string) => boolean {\n const installed = join(root, 'node_modules', '@descent-vtt', 'spec-harness');\n const candidates: string[] = [fileURLToPath(new URL('../dist/plugin.js', import.meta.url))];\n try {\n // A manifest with no exports, or none for the plugin, throws in `join`\n // or on the missing key inside this block, which the catch reads as no\n // installed copy: `exports?.` and `target !== null` are equivalent to\n // their mutants here. So is the encoding: a Buffer parses as its text.\n // Only a file is read: what stands there and is none is no installed\n // copy, as a manifest with no exports is (ADR-0002).\n const file = join(installed, 'package.json');\n const manifest: { exports?: Record<string, unknown> } = isFile(file) ? JSON.parse(readFileSync(file, 'utf8')) : {};\n const target = exportedFile(manifest.exports?.['./spec-brief-plugin']);\n if (target !== null) candidates.push(join(installed, target));\n } catch {\n // Not installed at the root, or its manifest cannot be read: this copy's file is the one to compare.\n }\n // A candidate that names no file is `null` here, and so is a path that\n // names none, which is never the plugin.\n const files = new Set(candidates.map(realFile));\n return (path) => {\n const file = realFile(resolve(root, path));\n return file !== null && files.has(file);\n };\n}\n\n/** Whether spec-brief loads this package's plugin, as its configuration at the root says. */\nexport async function specBriefPlugin(root: string): Promise<PluginState> {\n const file = SPEC_BRIEF_CONFIGS.find((name) => existsSync(join(root, name)));\n if (file === undefined) return { kind: 'unconfigured' };\n const config = await readJsonObject(join(root, file));\n // The file was found a moment ago, so null is one removed in between, and\n // reads as the unreadable one it has become.\n if (config === null || config === 'unreadable') return { kind: 'unreadable', file };\n return { kind: loadsPlugin(config, pluginFile(root)) ? 'loaded' : 'not-loaded', file };\n}\n\n/** Claude Code's configuration directory, where it is known: `CLAUDE_CONFIG_DIR`, otherwise `.claude` under the home directory it uses. */\nfunction claudeConfigDirectory(env: CliIO['env'], platform: NodeJS.Platform): string | undefined {\n const home = (platform === 'win32' ? env['USERPROFILE'] : env['HOME']) || undefined;\n return env['CLAUDE_CONFIG_DIR'] || (home === undefined ? undefined : join(home, '.claude'));\n}\n\n/**\n * The directories Claude Code keeps plugins in, by its documentation\n * (https://code.claude.com/docs/en/env-vars, read 2026-10-12): the plugins\n * root, which is `CLAUDE_CODE_PLUGIN_CACHE_DIR` when that is set and\n * `plugins` in the configuration directory otherwise, and after it each\n * seed directory `CLAUDE_CODE_PLUGIN_SEED_DIR` names, separated by `;` on\n * Windows and `:` elsewhere. A seed has the layout of the root, by its page\n * on plugins for an organization\n * (https://code.claude.com/docs/en/plugins/org, Seed containers and CI,\n * read the same day). Read from the environment this runs in, as the\n * settings files are.\n */\nexport function pluginDirectories(env: CliIO['env'], platform: NodeJS.Platform = process.platform): string[] {\n const configDir = claudeConfigDirectory(env, platform);\n const plugins = env['CLAUDE_CODE_PLUGIN_CACHE_DIR'] || (configDir === undefined ? undefined : join(configDir, 'plugins'));\n const seeds = (env['CLAUDE_CODE_PLUGIN_SEED_DIR'] ?? '').split(platform === 'win32' ? ';' : ':').filter((seed) => seed !== '');\n return [...(plugins === undefined ? [] : [plugins]), ...seeds];\n}\n\n/**\n * What one of those directories holds of this package's plugin as\n * `marketplace` lists it: whether its cache has a version of it, one\n * directory each under the marketplace's and the plugin's names, that no\n * `.orphaned_at` marks as left behind by an update or an uninstall; the\n * record of marketplaces fetched; and whether a record of marketplaces\n * hosted on claude.ai stands beside it (the plugin loading reference, Find\n * plugins on disk, ADR-0012). Nothing else there is read.\n */\nasync function pluginsRoot(directory: string, marketplace: string): Promise<PluginsRoot> {\n const versions = join(directory, 'cache', marketplace, 'spec-harness');\n let cached = false;\n try {\n const entries = await readdir(versions, { withFileTypes: true });\n cached = entries.some((entry) => entry.isDirectory() && !existsSync(join(versions, entry.name, '.orphaned_at')));\n } catch {\n // No directory for the plugin in this cache: it holds no version of it.\n }\n return { directory, cached, registry: await readJsonObject(join(directory, MARKETPLACE_REGISTRY)), hosted: existsSync(join(directory, HOSTED_REGISTRY)) };\n}\n\n/**\n * Claude Code's settings files that can turn a plugin on or hold a hook,\n * lowest precedence first: the user's, the project's, and the person's own\n * for the project. The user's is in `CLAUDE_CONFIG_DIR` when that is set,\n * otherwise in `.claude` under the home directory Claude Code uses,\n * `USERPROFILE` on Windows and `HOME` elsewhere; with neither it is not read.\n * Managed settings and `--settings` are not files a project can see.\n */\nexport function claudeSettingsFiles(root: string, env: CliIO['env'], platform: NodeJS.Platform = process.platform): { file: string; path: string }[] {\n const configDir = claudeConfigDirectory(env, platform);\n const user = configDir === undefined ? null : join(configDir, 'settings.json');\n return [\n ...(user === null ? [] : [{ file: user, path: user }]),\n { file: PROJECT_SETTINGS, path: join(root, '.claude', 'settings.json') },\n { file: '.claude/settings.local.json', path: join(root, '.claude', 'settings.local.json') },\n ];\n}\n\n/** The settings files Claude Code reads here, as read; one that is missing or cannot be read as JSON holds nothing. */\nexport async function claudeSettings(root: string, env: CliIO['env']): Promise<ClaudeSettings[]> {\n return Promise.all(claudeSettingsFiles(root, env).map(async ({ file, path }) => ({ file, settings: await readJsonObject(path) })));\n}\n\n/**\n * Whether the plugin, init's entries, both or neither wire Claude Code to the\n * harness here, and what the hook does with each line the settings hold for\n * it.\n *\n * A line is the hook's by the hook's own reading of it, whatever else stands\n * on it, and read as a session started at `root` hands it over: the project\n * is `root`, an empty `--root` is the directory the hook is started in, and\n * a relative one is read from there. A brief on it is asked of spec-brief, as\n * the hook asks. The plugin's own hooks are not read: they are files of a\n * release, in a directory Claude Code keeps, and every release wrote the\n * hook alone on their line, under the matcher init writes (ADR-0012). What\n * is read of that directory is whether the plugin is in it at all.\n *\n * `init` reads the wiring through this too, so that it and `doctor` say\n * the same of every tree, and hands it the reader it reads the matchers of\n * the same files with, so that the two read each pattern once between them.\n *\n * A matcher that lists names with a comma is read as the Claude Code on\n * `PATH` reads it, which turns on its release (configure.ts). `doctor`\n * reports the release, and asks it wherever something wires the guard,\n * since one too old for the hooks lets every write through: the lines are\n * first read as a release that cannot be told reads them, under which a\n * line that may be started counts as wiring. `init` has no other use for\n * the release, so it says that it does not report it, and it is asked only\n * where a line turns on it: where what is read of the lines differs between\n * a release that cannot be told and the newest.\n */\nexport async function claudeCodeWiring(root: string, io: CliIO, pattern: PatternReader = patternReader(), reported = true): Promise<ClaudeCodeWiring> {\n const sources = await claudeSettings(root, io.env);\n // Each line is read once, before any is reported: what the brief on one\n // names is spec-brief's to say, and the report itself asks nothing.\n const read = new Map<string, HookLine | null>();\n for (const words of handedLines(sources, root)) read.set(JSON.stringify(words), await hookLineHere(words, root, io));\n const plugin = enabledPlugin(sources);\n // An id that names no marketplace has no directory to look in, and is said\n // as one that cannot be told whatever is on disk: pluginPresence answers\n // for it before it reads a directory, so what stands here for none is\n // equivalent to its mutant.\n const marketplace = plugin === null ? null : pluginMarketplace(plugin.id);\n const roots = marketplace === null ? [] : await Promise.all(pluginDirectories(io.env).map((directory) => pluginsRoot(directory, marketplace)));\n const presence = plugin === null ? null : pluginPresence(plugin, sources, roots);\n const server = registersServer(await readJsonObject(join(root, '.mcp.json')));\n // A line under SessionStart is the hook's by the hook's own reading of it, as any line is.\n // A root on it that is no directory is a line of the hook that is off, and\n // one all the same, so the mutant of the test for a directory is\n // equivalent.\n const isHook = (words: readonly string[]): boolean => claudeHookLine(words, parseOptions, root, (path) => isDirectory(resolve(root, path))) !== null;\n const sessionStart = sources.some(({ settings }) => startsSessions(settings, isHook));\n // init writes its hooks into the project's file alone, and none where an array unloads it.\n const unloaded = arrayMatcher(sources.find(({ file }) => file === PROJECT_SETTINGS)!.settings);\n const under = (release: ClaudeCodeCheck | null): ClaudeCodeWiring => {\n const lines = reportHooks(sources, root, (words) => read.get(JSON.stringify(words))!, pattern, matchingUnder(release), readsOnFailure(release));\n // A line Claude Code starts for no write, before one or after, is in no\n // one's way: it is said, and the file is not counted for it.\n const hooks = sources.map(({ file }) => file).filter((file) => lines.some((line) => line.file === file && (isStarted(line.before) || isStarted(line.after))));\n // In the order a document has them, which a script may compare by the byte.\n return { plugin, presence, hooksOff: hooksDisabled(sources), hooks, lines, server, sessionStart, release, unloaded };\n };\n const untold = under(null);\n const asked = reported ? wiringState(untold) !== 'none' : JSON.stringify(untold.lines) !== JSON.stringify(reportHooks(sources, root, (words) => read.get(JSON.stringify(words))!, pattern));\n // Read again under the release, where it was asked: what is read without\n // one is what is read under one that cannot be told. What asks it is\n // loaded here, where it is asked: the hook loads these operations for\n // every write, and asks no release.\n return under(asked ? checkClaudeCode(await (await import('./host.js')).claudeVersion(io.env)) : null);\n}\n\n/**\n * What the hook does with the words a session started at `root` hands it:\n * its own reading of the line (usage.ts), and what follows from where its\n * root is, where the line guards. The hook opens the work tree its root is\n * in. Where the root is a directory in none, it reads a session outside a\n * work tree, checks no write and says nothing (ADR-0005): git is asked here\n * as the hook asks it, and the line is one under which the guard is off.\n * Where the root is in another work tree than the project's, the hook\n * decides by that work tree's briefs, and a file outside it is none of its\n * repository's: so a work tree that does not hold the project leaves every\n * write to a file of the project unchecked, and one that holds it checks\n * them, by its own briefs. Where the line names a brief, the hook asks\n * spec-brief in the work tree it opened which brief the name is, and holds\n * every write under a name that is none (ADR-0004). So this asks the same,\n * of the same work tree, and a line that holds every write is said as that\n * wherever its root is.\n */\nasync function hookLineHere(words: readonly string[], root: string, io: CliIO): Promise<HookLine | null> {\n const line = claudeHookLine(words, parseOptions, root, (path) => isDirectory(resolve(root, path)));\n // Only a line that guards gives a root to open or names a brief, so the\n // check of its state is the compiler's, and its mutant is equivalent.\n if (line === null || line.state !== 'guards') return line;\n let told: HookLine = line;\n // With no root on its line the hook opens the project, which is the work\n // tree this runs in: git is asked only about a root the line gives.\n if (line.root !== undefined) {\n const top = await workTreeRoot(resolve(root, line.root));\n if (top === null) return outsideHookLine(line.root);\n // The project's top as the root's work tree names it: nothing where the\n // two are one work tree, which is every root in the project, and\n // `null` where the project is not in it.\n const path = repositoryPath(root, top, root);\n if (path !== '') {\n // One repository's work trees share a git directory, and no two\n // repositories do.\n const [theirs, ours] = await Promise.all([commonDirectory(top), commonDirectory(root)]);\n const tree = { top, ours: theirs === ours };\n told = path === null ? elsewhereHookLine(line.root, tree) : holderHookLine(line, tree, path);\n }\n }\n if (line.brief === undefined) return told;\n const workspace = await openWorkspace({ root: line.root === undefined ? root : resolve(root, line.root) }, io);\n const { problem } = await diagnoseBrief(workspace, { brief: line.brief }, io.env);\n return problem === null ? told : heldHookLine(problem);\n}\n\n/**\n * The brief a round works on, as doctor reports it: its id, and what is\n * wrong with the name when no round can work under it. Every other command\n * stops there. A diagnosis says it, being what a person runs when the guard\n * holds a write they expected it to pass.\n *\n * `branch` is whether the name no round can work under is the branch's: a\n * brief it names that spec-brief does not know, or has archived. The hook\n * reads the same branch and holds every write under such a name, which is a\n * setup that holds every write, as a hook's line naming such a brief is\n * (ADR-0004). A name the flag gives is the question doctor was asked, and\n * holds no write of anyone's.\n */\nexport async function diagnoseBrief(\n workspace: Workspace,\n options: Pick<Options, 'brief'>,\n env: CliIO['env'],\n): Promise<{ readonly id: string | null; readonly problem: string | null; readonly branch: boolean }> {\n if (options.brief !== undefined && isBlank(options.brief)) return { id: null, problem: emptyValue('--brief', 'brief', options.brief), branch: false };\n const id = namedId(workspace, options, env);\n // A spec-brief that cannot be run is a row of the report, with the reason.\n if (workspace.siblings.locate('spec-brief').kind !== 'found') return { id, problem: null, branch: false };\n try {\n // Where nothing names a brief, spec-brief is not asked (ADR-0004), and\n // there is no problem to state.\n const active = await activeBrief(workspace, options, env);\n const branch = (active.kind === 'unknown' || active.kind === 'archived') && active.source === 'branch';\n return { id, problem: describeActive(active).problem, branch };\n } catch (error) {\n // Asking spec-brief throws nothing but this, so the check is equivalent\n // to its mutant; it keeps any other error the stack it needs.\n if (!(error instanceof SiblingError)) throw error;\n return { id, problem: `spec-brief could not say whether it knows brief ${id}: ${error.message}`, branch: false };\n }\n}\n\nasync function archiveReasons(workspace: Workspace, brief: BriefRow, base: Base): Promise<{ blocking: ArchiveReason[]; warnings: ArchiveReason[] } | { unavailable: string }> {\n const args = ['archive', brief.id, '--dry-run', '--format', 'json', '--no-color'];\n if (base.kind === 'resolved') args.push('--base', base.ref);\n const answer = await workspace.siblings.json('spec-brief', args);\n // The audit listed the briefs through spec-brief before it asks this, so\n // an absent one stopped it there; the check is for the type.\n if ('absent' in answer) return { unavailable: answer.absent };\n if (answer.code === 2) return { unavailable: 'spec-brief could not plan the archive' };\n return readArchivePlan(answer.document);\n}\n\n/** The brief's assertions as spec-guard ran them, and those it could not read, which it lists apart as `errors`. */\nasync function briefAssertions(\n workspace: Workspace,\n brief: BriefRow,\n text: string,\n reader: DocumentReader,\n): Promise<{ outcomes: AssertionOutcome[]; unreadable: UnreadableAssertion[] } | { unavailable: string }> {\n const answer = await workspace.siblings.json('spec-guard', [brief.file, '--ignore-status', '--json']);\n if ('absent' in answer) return { unavailable: answer.absent };\n if (answer.code === 2) return { unavailable: 'spec-guard could not run the brief\\'s assertions' };\n const report = readGuardRun(answer.document);\n const own = (spec: { readonly file: string } | undefined): boolean => spec === undefined || spec.file.replace(/\\\\/g, '/') === brief.file;\n const outcomes = report.results\n .filter((result) => own(result.spec))\n .map((result) => {\n const line = result.spec?.line ?? 0;\n return { ok: result.ok, description: result.description, message: result.message, line, section: reader.sectionAt(text, line), enclosing: reader.sectionsAt(text, line) };\n });\n const unreadable = report.errors.filter((error) => own(error.spec)).map((error) => ({ message: error.message, line: error.spec?.line ?? 0, raw: error.raw }));\n return { outcomes, unreadable };\n}\n\nexport interface AuditResult {\n readonly brief: BriefRow;\n readonly base: Base;\n readonly report: AuditReport;\n readonly dependencies: readonly DependencyChange[];\n /** The entries of an install-script policy the round added, removed or turned. */\n readonly installScripts: readonly InstallScriptChange[];\n}\n\nexport async function runAudit(workspace: Workspace, brief: BriefRow, reader: DocumentReader, baseFlag: string | undefined): Promise<AuditResult> {\n const { audit, tally } = await import('./audit.js');\n const base = await resolveBase(workspace, baseFlag);\n const text = await briefText(workspace, brief);\n const [dependencies, archive, assertions, rulings, plugin] = await Promise.all([\n dependencyChanges(workspace, base),\n archiveReasons(workspace, brief, base),\n briefAssertions(workspace, brief, text, reader),\n checkRulings(workspace, brief, text, reader, base),\n specBriefPlugin(workspace.root),\n ]);\n const unmeasured =\n base.kind === 'unresolved' ? base.reason : base.mergeBase === base.head ? `${base.ref} and HEAD are the same commit: there is nothing to measure` : null;\n const report = audit({\n brief,\n unmeasured,\n dependencies,\n archive,\n assertions: 'unavailable' in assertions ? assertions : assertions.outcomes,\n // The audit reads no list as an empty one, and a run spec-guard could not\n // make has none, so a mutant of this test reads the same.\n unreadableAssertions: 'unavailable' in assertions ? [] : assertions.unreadable,\n premiseSections: workspace.config.assertions.premises,\n unverifiedRulings: rulings.unverified,\n verifiedRulings: rulings.verified,\n pluginLoaded: plugin.kind === 'loaded',\n });\n const findings = [...rulings.problems, ...report.findings];\n return {\n brief,\n base,\n dependencies: dependencies.changes,\n installScripts: dependencies.installScripts,\n report: { findings, counts: tally(findings), measured: report.measured },\n };\n}\n\n/* -------------------------------------------------------------- escalation */\n\nasync function escalationDirectory(workspace: Workspace): Promise<string> {\n return stateDirectory(workspace.commonDir, 'escalations');\n}\n\nexport async function listEscalations(workspace: Workspace): Promise<EscalationRequest[]> {\n const directory = await escalationDirectory(workspace);\n const out: EscalationRequest[] = [];\n for (const name of (await readdir(directory)).filter((n) => n.endsWith('.json')).sort()) {\n // What is no file is no request, and is passed over as one that cannot be read is.\n if (!isFile(join(directory, name))) continue;\n try {\n // A Buffer parses as its text, so the encoding is equivalent to its mutant.\n const request: EscalationRequest = JSON.parse(await readFile(join(directory, name), 'utf8'));\n out.push(request);\n } catch {\n // A request that cannot be read is skipped; listing it would list nothing true.\n }\n }\n return out;\n}\n\nexport async function raiseEscalation(\n workspace: Workspace,\n brief: BriefRow,\n request: { paths: readonly string[]; reason: string; options: readonly EscalationOption[]; recommendation: string | null },\n): Promise<{ request: EscalationRequest; memo: string }> {\n const existing = await listEscalations(workspace);\n const id = nextId('E', brief.id, existing.map((e) => e.id));\n const full: EscalationRequest = {\n id,\n brief: brief.id,\n briefFile: brief.file,\n paths: request.paths,\n reason: request.reason,\n options: request.options,\n recommendation: request.recommendation,\n created: new Date().toISOString(),\n branch: workspace.branch,\n head: await revision('HEAD', workspace.root),\n };\n await writeAtomic(join(await escalationDirectory(workspace), `${id}.json`), `${JSON.stringify(full, null, 2)}\\n`);\n return { request: full, memo: renderMemo(full) };\n}\n\n/** Writes a person's ruling into the brief and retires the request. Never commits: the signature is the person's. */\nexport async function recordRuling(\n workspace: Workspace,\n escalationId: string,\n decision: 'allow' | 'deny',\n note: string,\n reader: DocumentReader,\n): Promise<{ id: string; file: string; row: string }> {\n const request = (await listEscalations(workspace)).find((candidate) => candidate.id === escalationId.toUpperCase() || candidate.id === escalationId);\n if (request === undefined) throw new UsageError(`no escalation \"${escalationId}\" is waiting; spec-harness escalate --list shows those that are`);\n const path = join(workspace.root, request.briefFile);\n const text = await readText(path);\n if (text === null) throw new UsageError(`${request.briefFile} cannot be read`);\n const where = reader.sectionTables(text, workspace.config.rulings.section);\n const taken = readRulings(where.tables).rulings.map((row) => row.id);\n const id = nextId('R', request.brief, taken);\n const row = renderRow(id, request.paths, decision, note);\n await writeAtomic(path, addRulingRow(text, workspace.config.rulings.section, row, where));\n // Listed a moment ago; forced, a request another process retired in\n // between is not an error, so the option is equivalent to its mutants.\n await rm(join(await escalationDirectory(workspace), `${request.id}.json`), { force: true });\n return { id, file: request.briefFile, row };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"round.js","sourceRoot":"","sources":["../src/round.ts"],"names":[],"m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CAAC;IAC1F,oEAAoE;IACpE,uEAAuE;IACvE,MAAM,EAAE,CAAC,IAAI,CAAC,MAAM,mBAAmB,CAAC,SAAS,CAAC,EAAE,GAAG,OAAO,CAAC,EAAE,OAAO,CAAC,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;IAC5F,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,OAAO,CAAC,SAAS,EAAE,GAAG,EAAE,CAAC;AAC9C,CAAC","sourcesContent":["/**\n * A round, measured: the operations the command line and the MCP server\n * share. Each gathers what a pure module needs - from git, the disk and the\n * siblings - and hands it over; the decisions are made in `context.ts`,\n * `audit.ts`, `guard.ts` and `rulings.ts`.\n *\n * The hook loads this module before every write it decides, so what only\n * an audit, a verified ruling or `doctor` runs is imported where it runs:\n * the audit's judgement, which brings the Markdown scanner with it, the\n * hash a copy of the signers is named by, and what asks Claude Code its\n * release.\n */\n\nimport { existsSync, readFileSync, realpathSync } from 'node:fs';\nimport { readdir, readFile, rm } from 'node:fs/promises';\nimport { join, resolve } from 'node:path';\nimport { fileURLToPath } from 'node:url';\n\nimport { readArchivePlan, readGuardRun } from './answers.js';\nimport type { ArchiveReason, AssertionOutcome, AuditInput, AuditReport, UnreadableAssertion } from './audit.js';\nimport { SiblingOutputError } from './briefs.js';\nimport { sameId } from './branch.js';\nimport {\n arrayMatcher,\n enabledPlugin,\n exportedFile,\n handedLines,\n hooksDisabled,\n HOSTED_REGISTRY,\n isStarted,\n loadsPlugin,\n MARKETPLACE_REGISTRY,\n matchingUnder,\n patternReader,\n pluginMarketplace,\n pluginPresence,\n PROJECT_SETTINGS,\n readsOnFailure,\n registersServer,\n reportHooks,\n reportsTurns,\n SPEC_BRIEF_CONFIGS,\n startsSessions,\n wiringState,\n type BaseSource,\n type ClaudeCodeWiring,\n type ClaudeSettings,\n type PatternReader,\n type PluginsRoot,\n type PluginState,\n} from './configure.js';\nimport { readRules, renderContext, type CitedDocument, type ContextPacket, type Rules } from './context.js';\nimport type { DocumentReader } from './document.js';\nimport { isDirectory, isFile, reachedBy, readJsonObject, readText, repositoryPath, stateDirectory, writeAtomic } from './fs.js';\nimport { blameLine, changes, commonDirectory, isUncommitted, mergeBase, remoteDefault, revision, show, verifyCommit, workTreeRoot } from './git.js';\nimport { decide, decideWritten, type Decision, type VerifiedRuling } from './guard.js';\nimport { diffManifest, ecosystemOf, readManifestNames, type DependencyChange, type InstallScriptChange } from './manifests.js';\nimport {\n addRulingRow,\n nextId,\n readRulings,\n renderMemo,\n renderRow,\n type EscalationOption,\n type EscalationRequest,\n type RulingRow,\n} from './rulings.js';\nimport type { BriefRow, Finding } from './types.js';\nimport { compileGlob, type LiteralReading } from './vendor/spec-core/pattern/index.js';\nimport { dirname, isRelativeReference, resolveInside, splitReference } from './vendor/spec-core/path/index.js';\nimport { SiblingError } from './siblings.js';\nimport { claudeHookLine, elsewhereHookLine, emptyValue, heldHookLine, holderHookLine, isBlank, outsideHookLine, type HookLine } from './usage.js';\nimport { checkClaudeCode, type ClaudeCodeCheck } from './versions.js';\nimport { activeBrief, describeActive, namedId, openWorkspace, parseOptions, UsageError, type CliIO, type Options, type Workspace } from './workspace.js';\n\n/* -------------------------------------------------------------------- base */\n\nexport type Base =\n | { readonly kind: 'resolved'; readonly ref: string; readonly source: BaseSource; readonly sha: string; readonly mergeBase: string; readonly head: string }\n | { readonly kind: 'unresolved'; readonly reason: string };\n\n/** What the round is measured from: the flag, the configuration, then the remote's default branch. */\nexport async function resolveBase(workspace: Workspace, flag: string | undefined): Promise<Base> {\n const source: BaseSource = flag !== undefined ? 'flag' : workspace.config.base !== null ? 'config' : 'remote';\n const ref = flag ?? workspace.config.base ?? (await remoteDefault(workspace.root));\n if (ref === null) {\n return { kind: 'unresolved', reason: 'no base is named and the remote has no default branch; pass --base <ref> or set \"base\"' };\n }\n // Neither commit waits on the other, so git is asked for both at once, and\n // they are read in the order they were asked in before: a base that names\n // no commit is said before a HEAD that names none.\n const [sha, head] = await Promise.all([revision(ref, workspace.root), revision('HEAD', workspace.root)]);\n if (sha === null) return { kind: 'unresolved', reason: `\"${ref}\" names no commit` };\n if (head === null) return { kind: 'unresolved', reason: 'HEAD names no commit: nothing is committed on this branch yet' };\n const common = await mergeBase(sha, head, workspace.root);\n if (common === null) return { kind: 'unresolved', reason: `\"${ref}\" and HEAD share no history` };\n return { kind: 'resolved', ref, source, sha, mergeBase: common, head };\n}\n\n/* ----------------------------------------------------------------- rulings */\n\nexport interface RulingCheck {\n readonly rows: readonly RulingRow[];\n readonly verified: readonly VerifiedRuling[];\n readonly unverified: readonly { readonly id: string; readonly reason: string }[];\n readonly problems: readonly Finding[];\n}\n\n/**\n * The brief's rulings, each checked against its signature: the commit that\n * last changed its row must be signed by a principal the base branch's\n * allowed-signers file lists (ADR-0006).\n */\nexport async function checkRulings(workspace: Workspace, brief: Pick<BriefRow, 'file'>, text: string, reader: DocumentReader, base: Base): Promise<RulingCheck> {\n const { rulings: rows, problems } = readRulings(reader.sectionTables(text, workspace.config.rulings.section).tables);\n const findings: Finding[] = problems.map((problem) => ({\n rule: 'ruling-unreadable',\n severity: 'warning',\n message: problem.message,\n hint: 'a ruling row is | id | `paths` | allow or deny | note |',\n file: brief.file,\n line: problem.line,\n }));\n const allows = rows.filter((row) => row.decision === 'allow');\n // Nothing below verifies a row that allows nothing, so this saves a git\n // show and is equivalent to its mutants.\n if (allows.length === 0) return { rows, verified: [], unverified: [], problems: findings };\n if (base.kind === 'unresolved') {\n return { rows, verified: [], unverified: allows.map((row) => ({ id: row.id, reason: `no base to read the allowed signers from: ${base.reason}` })), problems: findings };\n }\n const signers = await show(base.sha, workspace.config.rulings.allowedSigners, workspace.root);\n if (signers === null) {\n const reason = `${base.ref} has no ${workspace.config.rulings.allowedSigners}, so no signature can count`;\n return { rows, verified: [], unverified: allows.map((row) => ({ id: row.id, reason })), problems: findings };\n }\n // Only verify-commit below reads this copy, so where it is kept, and under\n // what name, is equivalent to its mutants. The one that reads the digest\n // with no encoding names the file by its bytes, which a path refuses when\n // one of them is NUL: a sweep counts that mutant killed now and then.\n const directory = await stateDirectory(workspace.commonDir, 'signers');\n const { createHash } = await import('node:crypto');\n const file = join(directory, `${createHash('sha256').update(signers).digest('hex').slice(0, 16)}`);\n await writeAtomic(file, signers);\n const verified: VerifiedRuling[] = [];\n const unverified: { id: string; reason: string }[] = [];\n for (const row of allows) {\n // The row's line is a line of the text on disk, so it is blamed there: at\n // HEAD the same number can be another line, one a signed commit wrote,\n // and an uncommitted row would borrow that commit's signature.\n const commit = await blameLine(null, brief.file, row.line, workspace.root);\n if (commit === null || isUncommitted(commit)) {\n unverified.push({ id: row.id, reason: 'its row is not committed' });\n continue;\n }\n const signature = await verifyCommit(commit, file, workspace.root);\n if (signature.good) verified.push({ id: row.id, paths: row.paths, signer: signature.principal });\n else unverified.push({ id: row.id, reason: `commit ${commit.slice(0, 12)} last changed its row, and ${signature.detail || 'it is not signed'}` });\n }\n return { rows, verified, unverified, problems: findings };\n}\n\n/* ------------------------------------------------------------------- guard */\n\nexport async function briefText(workspace: Workspace, brief: BriefRow): Promise<string> {\n const text = await readText(join(workspace.root, brief.file));\n if (text === null) throw new UsageError(`${brief.file} cannot be read`);\n return text;\n}\n\n/**\n * Decides paths against the brief, with the rulings verified against the\n * base `baseFlag` names, or the configured one. The reader may be given as\n * what makes one: it is asked for where a ruling is read, and a caller that\n * decides every write need not load a scanner for those that read none.\n */\nexport async function checkPaths(\n workspace: Workspace,\n brief: BriefRow | null,\n noBrief: string | undefined,\n given: readonly string[],\n cwd: string,\n reader: DocumentReader | (() => Promise<DocumentReader>),\n baseFlag: string | undefined,\n): Promise<Decision[]> {\n // Each path as it reads and as the system writes it, which a link can make\n // two files: the last a path reaches is the one it is written to, or the\n // one it reads as where that is all it reaches (ADR-0005).\n const resolved = given.map((path) => ({ given: path, path: repositoryPath(path, workspace.root, cwd), written: repositoryPath(reachedBy(path, cwd).at(-1)!, workspace.root, cwd) }));\n const decideAll = (rulings: readonly VerifiedRuling[]): Decision[] =>\n resolved.map(({ path, given: g, written }) => {\n const input = { path, given: g, brief, noBrief, rulings, outOfScope: workspace.config.outOfScope };\n return decideWritten(decide(input), { ...input, path: written });\n });\n const first = decideAll([]);\n // Rulings cost the reader of a brief, and a blame and a signature check\n // each, so they are read only when a write reaches a protected file. Read\n // anyway, they decide the same, since a ruling allows only a protected\n // path: what a mutant that always reads them changes is what is loaded\n // for a write no brief protects (loads.test.ts). With no brief nothing is\n // protected, so the null check is there for the type.\n if (brief === null || !first.some((decision) => decision.reason === 'protected')) return first;\n const text = await briefText(workspace, brief);\n const documents = typeof reader === 'function' ? await reader() : reader;\n // The base is where the allowed signers are read, and only a row that\n // allows something is checked against them: where none does, git is asked\n // nothing of the base, three processes of a refusal, and what was decided\n // without a ruling stands.\n const { rulings } = readRulings(documents.sectionTables(text, workspace.config.rulings.section).tables);\n if (!rulings.some((row) => row.decision === 'allow')) return first;\n const base = await resolveBase(workspace, baseFlag);\n return decideAll((await checkRulings(workspace, brief, text, documents, base)).verified);\n}\n\n/* ----------------------------------------------------------------- context */\n\n/**\n * The paths spec-guard is asked about for a scope: where its patterns can\n * match. A name with no glob syntax that exists is asked about as itself,\n * since spec-guard reads from the disk whether a path is a file or a\n * directory. One the round has yet to create may become either, and\n * spec-guard would read it as a file, leaving out the rules over a\n * directory of that name; it is asked about through the directory that will\n * hold it, the root for a name at the top, which covers both.\n */\nfunction scopeBases(root: string, patterns: readonly string[]): string[] {\n // Read as a directory, a name's base is the name itself; read any other\n // way, it is the directory holding it, so which other reading a missing\n // name gets changes nothing. The glob is compiled for its bases and never\n // matched: a file read as a directory narrows the question and nothing\n // else.\n const literal = (path: string): LiteralReading => (existsSync(join(root, path)) ? 'directory' : 'either');\n const bases = new Set<string>();\n for (const pattern of patterns) {\n try {\n // Case is read only in matching, which this compile never does: its\n // bases are the same either way, so `caseSensitive: false` is equivalent.\n for (const base of compileGlob(pattern, { dialect: 'path', caseSensitive: true, literal }).bases) {\n // A rooted alternative's base, `/docs` or `/`, is outside the\n // repository: it puts no path in the scope, and spec-guard refuses\n // the whole question for it, with the rules for every other base.\n // The packet names the pattern.\n if (base.startsWith('/')) continue;\n bases.add(base === '' ? '.' : base);\n }\n } catch {\n // The packet names a pattern the guard cannot read, with spec-core's\n // reason, and says so when it is every pattern; the rules for the rest\n // still count.\n }\n }\n return [...bases].sort();\n}\n\nasync function rulesFor(workspace: Workspace, brief: BriefRow): Promise<Rules> {\n const paths = scopeBases(workspace.root, brief.affectedFiles);\n if (paths.length === 0) return [];\n try {\n const answer = await workspace.siblings.json('spec-guard', ['query', ...paths, '--json']);\n return 'absent' in answer ? { unavailable: answer.absent } : readRules(answer);\n } catch (error) {\n // spec-guard printed no JSON, or a document of another shape: what it\n // said instead, or what was wrong, is the reason, and the rest of the\n // packet stands without the rules.\n if (error instanceof SiblingError || error instanceof SiblingOutputError) return { unavailable: error.message };\n throw error;\n }\n}\n\nasync function citedDocuments(workspace: Workspace, brief: BriefRow, text: string, reader: DocumentReader): Promise<CitedDocument[]> {\n const seen = new Set<string>();\n const out: CitedDocument[] = [];\n for (const citation of reader.citations(text)) {\n if (!isRelativeReference(citation.target)) continue;\n let target = splitReference(citation.target).path;\n try {\n target = decodeURIComponent(target);\n } catch {\n // A destination that is not valid percent-encoding is read as written.\n }\n const path = resolveInside(dirname(brief.file), target);\n if (path === null || path === brief.file || seen.has(path)) continue;\n seen.add(path);\n const document = /\\.(?:md|markdown|mdx|txt)$/i.test(path);\n // A link to code or a directory that exists is not a document to include,\n // and must not be reported as a link that resolves to nothing.\n if (!document && existsSync(join(workspace.root, path))) continue;\n const content = document ? await readText(join(workspace.root, path)) : null;\n // A document that cannot be read is listed by its path alone, so its\n // title and status are never read, and an empty object is equivalent.\n const meta = content === null ? { title: null, status: null } : reader.titleAndStatus(content);\n out.push({ path, ...meta, text: content });\n }\n return out;\n}\n\nexport async function buildContext(\n workspace: Workspace,\n brief: BriefRow,\n briefs: readonly BriefRow[],\n reader: DocumentReader,\n baseFlag: string | undefined,\n): Promise<ContextPacket> {\n const text = await briefText(workspace, brief);\n const base = await resolveBase(workspace, baseFlag);\n const [rules, cited, rulings] = await Promise.all([\n rulesFor(workspace, brief),\n citedDocuments(workspace, brief, text, reader),\n checkRulings(workspace, brief, text, reader, base),\n ]);\n return renderContext({\n brief,\n briefText: text,\n dependencies: brief.dependsOn.map(\n (id) =>\n // spec-brief reports a dependency as its front matter spells it, `7` for brief 007.\n // The context reads a dependency's id, title, status and phase, and\n // the brief copied here is live.\n briefs.find((candidate) => sameId(candidate.id, id)) ?? { ...brief, id, title: '(no such brief)', status: 'unknown' },\n ),\n cited,\n rules,\n rulings: rulings.verified,\n branch: workspace.branch,\n base: base.kind === 'resolved' ? base.ref : null,\n budget: workspace.config.context.budget,\n });\n}\n\n/* ------------------------------------------------------------------- audit */\n\nasync function dependencyChanges(workspace: Workspace, base: Base): Promise<AuditInput['dependencies'] & { readonly installScripts: readonly InstallScriptChange[] }> {\n // A name that cannot be read is reported with or without a base: it would\n // leave its manifests out of every audit measured from one.\n const names = readManifestNames(workspace.config.dependencies.manifests);\n if (base.kind === 'unresolved') return { changes: [], installScripts: [], unread: [], unreadNames: names.unread, rootedNames: names.rooted };\n const isManifest = names.match;\n const out: DependencyChange[] = [];\n const installScripts: InstallScriptChange[] = [];\n const unread: string[] = [];\n for (const change of await changes(base.mergeBase, base.head, workspace.root)) {\n if (!isManifest(change.path) && !(change.from !== undefined && isManifest(change.from))) continue;\n const ecosystem = ecosystemOf(change.path);\n if (ecosystem === null) {\n unread.push(change.path);\n continue;\n }\n // git shows nothing where a file is not: an added manifest has no before,\n // and a deleted one no after.\n const before = await show(base.mergeBase, change.from ?? change.path, workspace.root);\n const after = await show(base.head, change.path, workspace.root);\n const diff = diffManifest(change.path, ecosystem, before, after);\n if ('error' in diff) {\n unread.push(change.path);\n continue;\n }\n out.push(...diff.changes);\n installScripts.push(...diff.installScripts);\n }\n return { changes: out, installScripts, unread, unreadNames: names.unread, rootedNames: names.rooted };\n}\n\n/** A file's real path, links and the filesystem's case resolved, or `null` when there is no such file. */\nfunction realFile(path: string): string | null {\n try {\n return realpathSync.native(path);\n } catch {\n return null;\n }\n}\n\n/**\n * Whether a path spec-brief's `plugins` names, read from the root, is this\n * package's plugin: the file its `./spec-brief-plugin` export names, as the\n * project installed the package, or as this copy of it ships. spec-brief\n * loads a plugin by a path as well as by its name, and a path to the plugin\n * read as another plugin would say the archive cannot accept a ruling it can.\n */\nexport function pluginFile(root: string): (path: string) => boolean {\n const installed = join(root, 'node_modules', '@descent-vtt', 'spec-harness');\n const candidates: string[] = [fileURLToPath(new URL('../dist/plugin.js', import.meta.url))];\n try {\n // A manifest with no exports, or none for the plugin, throws in `join`\n // or on the missing key inside this block, which the catch reads as no\n // installed copy: `exports?.` and `target !== null` are equivalent to\n // their mutants here. So is the encoding: a Buffer parses as its text.\n // Only a file is read: what stands there and is none is no installed\n // copy, as a manifest with no exports is (ADR-0002).\n const file = join(installed, 'package.json');\n const manifest: { exports?: Record<string, unknown> } = isFile(file) ? JSON.parse(readFileSync(file, 'utf8')) : {};\n const target = exportedFile(manifest.exports?.['./spec-brief-plugin']);\n if (target !== null) candidates.push(join(installed, target));\n } catch {\n // Not installed at the root, or its manifest cannot be read: this copy's file is the one to compare.\n }\n // A candidate that names no file is `null` here, and so is a path that\n // names none, which is never the plugin.\n const files = new Set(candidates.map(realFile));\n return (path) => {\n const file = realFile(resolve(root, path));\n return file !== null && files.has(file);\n };\n}\n\n/** Whether spec-brief loads this package's plugin, as its configuration at the root says. */\nexport async function specBriefPlugin(root: string): Promise<PluginState> {\n const file = SPEC_BRIEF_CONFIGS.find((name) => existsSync(join(root, name)));\n if (file === undefined) return { kind: 'unconfigured' };\n const config = await readJsonObject(join(root, file));\n // The file was found a moment ago, so null is one removed in between, and\n // reads as the unreadable one it has become.\n if (config === null || config === 'unreadable') return { kind: 'unreadable', file };\n return { kind: loadsPlugin(config, pluginFile(root)) ? 'loaded' : 'not-loaded', file };\n}\n\n/** Claude Code's configuration directory, where it is known: `CLAUDE_CONFIG_DIR`, otherwise `.claude` under the home directory it uses. */\nfunction claudeConfigDirectory(env: CliIO['env'], platform: NodeJS.Platform): string | undefined {\n const home = (platform === 'win32' ? env['USERPROFILE'] : env['HOME']) || undefined;\n return env['CLAUDE_CONFIG_DIR'] || (home === undefined ? undefined : join(home, '.claude'));\n}\n\n/**\n * The directories Claude Code keeps plugins in, by its documentation\n * (https://code.claude.com/docs/en/env-vars, read 2026-10-12): the plugins\n * root, which is `CLAUDE_CODE_PLUGIN_CACHE_DIR` when that is set and\n * `plugins` in the configuration directory otherwise, and after it each\n * seed directory `CLAUDE_CODE_PLUGIN_SEED_DIR` names, separated by `;` on\n * Windows and `:` elsewhere. A seed has the layout of the root, by its page\n * on plugins for an organization\n * (https://code.claude.com/docs/en/plugins/org, Seed containers and CI,\n * read the same day). Read from the environment this runs in, as the\n * settings files are.\n */\nexport function pluginDirectories(env: CliIO['env'], platform: NodeJS.Platform = process.platform): string[] {\n const configDir = claudeConfigDirectory(env, platform);\n const plugins = env['CLAUDE_CODE_PLUGIN_CACHE_DIR'] || (configDir === undefined ? undefined : join(configDir, 'plugins'));\n const seeds = (env['CLAUDE_CODE_PLUGIN_SEED_DIR'] ?? '').split(platform === 'win32' ? ';' : ':').filter((seed) => seed !== '');\n return [...(plugins === undefined ? [] : [plugins]), ...seeds];\n}\n\n/**\n * What one of those directories holds of this package's plugin as\n * `marketplace` lists it: whether its cache has a version of it, one\n * directory each under the marketplace's and the plugin's names, that no\n * `.orphaned_at` marks as left behind by an update or an uninstall; the\n * record of marketplaces fetched; and whether a record of marketplaces\n * hosted on claude.ai stands beside it (the plugin loading reference, Find\n * plugins on disk, ADR-0012). Nothing else there is read.\n */\nasync function pluginsRoot(directory: string, marketplace: string): Promise<PluginsRoot> {\n const versions = join(directory, 'cache', marketplace, 'spec-harness');\n let cached = false;\n try {\n const entries = await readdir(versions, { withFileTypes: true });\n cached = entries.some((entry) => entry.isDirectory() && !existsSync(join(versions, entry.name, '.orphaned_at')));\n } catch {\n // No directory for the plugin in this cache: it holds no version of it.\n }\n return { directory, cached, registry: await readJsonObject(join(directory, MARKETPLACE_REGISTRY)), hosted: existsSync(join(directory, HOSTED_REGISTRY)) };\n}\n\n/**\n * Claude Code's settings files that can turn a plugin on or hold a hook,\n * lowest precedence first: the user's, the project's, and the person's own\n * for the project. The user's is in `CLAUDE_CONFIG_DIR` when that is set,\n * otherwise in `.claude` under the home directory Claude Code uses,\n * `USERPROFILE` on Windows and `HOME` elsewhere; with neither it is not read.\n * Managed settings and `--settings` are not files a project can see.\n */\nexport function claudeSettingsFiles(root: string, env: CliIO['env'], platform: NodeJS.Platform = process.platform): { file: string; path: string }[] {\n const configDir = claudeConfigDirectory(env, platform);\n const user = configDir === undefined ? null : join(configDir, 'settings.json');\n return [\n ...(user === null ? [] : [{ file: user, path: user }]),\n { file: PROJECT_SETTINGS, path: join(root, '.claude', 'settings.json') },\n { file: '.claude/settings.local.json', path: join(root, '.claude', 'settings.local.json') },\n ];\n}\n\n/** The settings files Claude Code reads here, as read; one that is missing or cannot be read as JSON holds nothing. */\nexport async function claudeSettings(root: string, env: CliIO['env']): Promise<ClaudeSettings[]> {\n return Promise.all(claudeSettingsFiles(root, env).map(async ({ file, path }) => ({ file, settings: await readJsonObject(path) })));\n}\n\n/**\n * Whether the plugin, init's entries, both or neither wire Claude Code to the\n * harness here, and what the hook does with each line the settings hold for\n * it.\n *\n * A line is the hook's by the hook's own reading of it, whatever else stands\n * on it, and read as a session started at `root` hands it over: the project\n * is `root`, an empty `--root` is the directory the hook is started in, and\n * a relative one is read from there. A brief on it is asked of spec-brief, as\n * the hook asks. The plugin's own hooks are not read: they are files of a\n * release, in a directory Claude Code keeps, and every release wrote the\n * hook alone on their line, under the matcher init writes (ADR-0012). What\n * is read of that directory is whether the plugin is in it at all.\n *\n * `init` reads the wiring through this too, so that it and `doctor` say\n * the same of every tree, and hands it the reader it reads the matchers of\n * the same files with, so that the two read each pattern once between them.\n *\n * A matcher that lists names with a comma is read as the Claude Code on\n * `PATH` reads it, which turns on its release (configure.ts). `doctor`\n * reports the release, and asks it wherever something wires the guard,\n * since one too old for the hooks lets every write through: the lines are\n * first read as a release that cannot be told reads them, under which a\n * line that may be started counts as wiring. `init` has no other use for\n * the release, so it says that it does not report it, and it is asked only\n * where a line turns on it: where what is read of the lines differs between\n * a release that cannot be told and the newest.\n *\n * `doctor` also looks for the script each line runs in `places`, each\n * directory `${CLAUDE_PROJECT_DIR}` can name as a session starts, and says\n * a line whose script is in none as a guard that is off (reportHooks).\n * `init` gives none: it writes the line that names the project's install,\n * which may come after it.\n */\nexport async function claudeCodeWiring(root: string, io: CliIO, pattern: PatternReader = patternReader(), reported = true, places: readonly string[] | null = null): Promise<ClaudeCodeWiring> {\n const sources = await claudeSettings(root, io.env);\n // Each line is read once, before any is reported: what the brief on one\n // names is spec-brief's to say, and the report itself asks nothing.\n const read = new Map<string, HookLine | null>();\n for (const words of handedLines(sources, root)) read.set(JSON.stringify(words), await hookLineHere(words, root, io));\n const plugin = enabledPlugin(sources);\n // An id that names no marketplace has no directory to look in, and is said\n // as one that cannot be told whatever is on disk: pluginPresence answers\n // for it before it reads a directory, so what stands here for none is\n // equivalent to its mutant.\n const marketplace = plugin === null ? null : pluginMarketplace(plugin.id);\n const roots = marketplace === null ? [] : await Promise.all(pluginDirectories(io.env).map((directory) => pluginsRoot(directory, marketplace)));\n const presence = plugin === null ? null : pluginPresence(plugin, sources, roots);\n const server = registersServer(await readJsonObject(join(root, '.mcp.json')));\n // A line under SessionStart is the hook's by the hook's own reading of it, as any line is.\n // A root on it that is no directory is a line of the hook that is off, and\n // one all the same, so the mutant of the test for a directory is\n // equivalent.\n const isHook = (words: readonly string[]): boolean => claudeHookLine(words, parseOptions, root, (path) => isDirectory(resolve(root, path))) !== null;\n const sessionStart = sources.some(({ settings }) => startsSessions(settings, isHook));\n const turnEnd = sources.some(({ settings }) => reportsTurns(settings, isHook));\n // init writes its hooks into the project's file alone, and none where an array unloads it.\n const unloaded = arrayMatcher(sources.find(({ file }) => file === PROJECT_SETTINGS)!.settings);\n const under = (release: ClaudeCodeCheck | null): ClaudeCodeWiring => {\n const lines = reportHooks(sources, root, (words) => read.get(JSON.stringify(words))!, pattern, matchingUnder(release), readsOnFailure(release), places === null ? null : { projects: places, isFile });\n // A line Claude Code starts for no write, before one or after, is in no\n // one's way: it is said, and the file is not counted for it.\n const hooks = sources.map(({ file }) => file).filter((file) => lines.some((line) => line.file === file && (isStarted(line.before) || isStarted(line.after))));\n // In the order a document has them, which a script may compare by the byte.\n return { plugin, presence, hooksOff: hooksDisabled(sources), hooks, lines, server, sessionStart, turnEnd, release, unloaded };\n };\n const untold = under(null);\n const asked = reported ? wiringState(untold) !== 'none' : JSON.stringify(untold.lines) !== JSON.stringify(reportHooks(sources, root, (words) => read.get(JSON.stringify(words))!, pattern));\n // Read again under the release, where it was asked: what is read without\n // one is what is read under one that cannot be told. What asks it is\n // loaded here, where it is asked: the hook loads these operations for\n // every write, and asks no release.\n return under(asked ? checkClaudeCode(await (await import('./host.js')).claudeVersion(io.env)) : null);\n}\n\n/**\n * What the hook does with the words a session started at `root` hands it:\n * its own reading of the line (usage.ts), and what follows from where its\n * root is, where the line guards. The hook opens the work tree its root is\n * in. Where the root is a directory in none, it reads a session outside a\n * work tree, checks no write and says nothing (ADR-0005): git is asked here\n * as the hook asks it, and the line is one under which the guard is off.\n * Where the root is in another work tree than the project's, the hook\n * decides by that work tree's briefs, and a file outside it is none of its\n * repository's: so a work tree that does not hold the project leaves every\n * write to a file of the project unchecked, and one that holds it checks\n * them, by its own briefs. Where the line names a brief, the hook asks\n * spec-brief in the work tree it opened which brief the name is, and holds\n * every write under a name that is none (ADR-0004). So this asks the same,\n * of the same work tree, and a line that holds every write is said as that\n * wherever its root is.\n */\nasync function hookLineHere(words: readonly string[], root: string, io: CliIO): Promise<HookLine | null> {\n const line = claudeHookLine(words, parseOptions, root, (path) => isDirectory(resolve(root, path)));\n // Only a line that guards gives a root to open or names a brief, so the\n // check of its state is the compiler's, and its mutant is equivalent.\n if (line === null || line.state !== 'guards') return line;\n let told: HookLine = line;\n // With no root on its line the hook opens the project, which is the work\n // tree this runs in: git is asked only about a root the line gives.\n if (line.root !== undefined) {\n const top = await workTreeRoot(resolve(root, line.root));\n if (top === null) return outsideHookLine(line.root);\n // The project's top as the root's work tree names it: nothing where the\n // two are one work tree, which is every root in the project, and\n // `null` where the project is not in it.\n const path = repositoryPath(root, top, root);\n if (path !== '') {\n // One repository's work trees share a git directory, and no two\n // repositories do.\n const [theirs, ours] = await Promise.all([commonDirectory(top), commonDirectory(root)]);\n const tree = { top, ours: theirs === ours };\n told = path === null ? elsewhereHookLine(line.root, tree) : holderHookLine(line, tree, path);\n }\n }\n if (line.brief === undefined) return told;\n const workspace = await openWorkspace({ root: line.root === undefined ? root : resolve(root, line.root) }, io);\n const { id, problem } = await diagnoseBrief(workspace, { brief: line.brief }, io.env);\n if (problem !== null) return heldHookLine(problem);\n // A spec-brief that cannot be run is no problem of a name given as a\n // flag, and the hook holds every write all the same: it asks spec-brief\n // about the brief its line names before each one.\n const sibling = workspace.siblings.locate('spec-brief');\n return sibling.kind === 'found' ? told : heldHookLine(couldNotSay(id, sibling.reason));\n}\n\n/**\n * The brief a round works on, as doctor reports it: its id, and what is\n * wrong with the name when no round can work under it. Every other command\n * stops there. A diagnosis says it, being what a person runs when the guard\n * holds a write they expected it to pass.\n *\n * `branch` is whether the name no round can work under is the branch's: a\n * brief it names that spec-brief does not know, or has archived. The hook\n * reads the same branch and holds every write under such a name, which is a\n * setup that holds every write, as a hook's line naming such a brief is\n * (ADR-0004). A name the flag gives is the question doctor was asked, and\n * holds no write of anyone's.\n *\n * `holds` is whether the branch names a brief and spec-brief cannot answer\n * for it: not installed, too old, or failing as it is asked. The hook asks\n * spec-brief before every write under the name, and holds each write it\n * cannot ask about, so that too is a setup that holds every write.\n *\n * `archived` is the brief the branch names where spec-brief has archived\n * it, which doctor reads further in git: the branch that archived it waits\n * to merge, and fails nothing (ADR-0004). It reads nothing else, and the\n * problem is the one every write is held with, as before.\n */\nexport async function diagnoseBrief(\n workspace: Workspace,\n options: Pick<Options, 'brief'>,\n env: CliIO['env'],\n): Promise<{ readonly id: string | null; readonly problem: string | null; readonly branch: boolean; readonly holds: boolean; readonly archived: BriefRow | null }> {\n if (options.brief !== undefined && isBlank(options.brief)) return { id: null, problem: emptyValue('--brief', 'brief', options.brief), branch: false, holds: false, archived: null };\n const id = namedId(workspace, options, env);\n // Neither the flag nor SPEC_BRIEF names it, so the name is the branch's,\n // where something names one. A flag given only blanks was answered above.\n const byBranch = id !== null && options.brief === undefined && isBlank(env['SPEC_BRIEF'] ?? '');\n const sibling = workspace.siblings.locate('spec-brief');\n if (sibling.kind !== 'found') {\n // Under the flag or SPEC_BRIEF, a spec-brief that cannot be run is a row\n // of the report, with the reason. Under the branch it is the reason\n // the hook holds every write, and said as one it could not ask. There\n // `holds` fails doctor whatever `branch` says, and nothing else reads\n // `branch`, so its `false` is equivalent to its mutant.\n return byBranch ? { id, problem: couldNotSay(id, sibling.reason), branch: false, holds: true, archived: null } : { id, problem: null, branch: false, holds: false, archived: null };\n }\n try {\n // Where nothing names a brief, spec-brief is not asked (ADR-0004), and\n // there is no problem to state.\n const active = await activeBrief(workspace, options, env);\n const branch = (active.kind === 'unknown' || active.kind === 'archived') && active.source === 'branch';\n const archived = active.kind === 'archived' && active.source === 'branch' ? active.brief : null;\n return { id, problem: describeActive(active).problem, branch, holds: false, archived };\n } catch (error) {\n // Asking spec-brief throws nothing but this, so the check is equivalent\n // to its mutant; it keeps any other error the stack it needs.\n if (!(error instanceof SiblingError)) throw error;\n return { id, problem: couldNotSay(id, error.message), branch: false, holds: byBranch, archived: null };\n }\n}\n\n/** What is said of a brief spec-brief could not be asked about, and why. */\nfunction couldNotSay(id: string | null, why: string): string {\n return `spec-brief could not say whether it knows brief ${id}: ${why}`;\n}\n\nasync function archiveReasons(workspace: Workspace, brief: BriefRow, base: Base): Promise<{ blocking: ArchiveReason[]; warnings: ArchiveReason[] } | { unavailable: string }> {\n const args = ['archive', brief.id, '--dry-run', '--format', 'json', '--no-color'];\n if (base.kind === 'resolved') args.push('--base', base.ref);\n const answer = await workspace.siblings.json('spec-brief', args);\n // The audit listed the briefs through spec-brief before it asks this, so\n // an absent one stopped it there; the check is for the type.\n if ('absent' in answer) return { unavailable: answer.absent };\n if (answer.code === 2) return { unavailable: 'spec-brief could not plan the archive' };\n return readArchivePlan(answer.document);\n}\n\n/** The brief's assertions as spec-guard ran them, and those it could not read, which it lists apart as `errors`. */\nasync function briefAssertions(\n workspace: Workspace,\n brief: BriefRow,\n text: string,\n reader: DocumentReader,\n): Promise<{ outcomes: AssertionOutcome[]; unreadable: UnreadableAssertion[] } | { unavailable: string }> {\n const answer = await workspace.siblings.json('spec-guard', [brief.file, '--ignore-status', '--json']);\n if ('absent' in answer) return { unavailable: answer.absent };\n if (answer.code === 2) return { unavailable: 'spec-guard could not run the brief\\'s assertions' };\n const report = readGuardRun(answer.document);\n const own = (spec: { readonly file: string } | undefined): boolean => spec === undefined || spec.file.replace(/\\\\/g, '/') === brief.file;\n const outcomes = report.results\n .filter((result) => own(result.spec))\n .map((result) => {\n const line = result.spec?.line ?? 0;\n return { ok: result.ok, description: result.description, message: result.message, line, section: reader.sectionAt(text, line), enclosing: reader.sectionsAt(text, line) };\n });\n const unreadable = report.errors.filter((error) => own(error.spec)).map((error) => ({ message: error.message, line: error.spec?.line ?? 0, raw: error.raw }));\n return { outcomes, unreadable };\n}\n\nexport interface AuditResult {\n readonly brief: BriefRow;\n readonly base: Base;\n readonly report: AuditReport;\n readonly dependencies: readonly DependencyChange[];\n /** The entries of an install-script policy the round added, removed or turned. */\n readonly installScripts: readonly InstallScriptChange[];\n}\n\nexport async function runAudit(workspace: Workspace, brief: BriefRow, reader: DocumentReader, baseFlag: string | undefined): Promise<AuditResult> {\n const { audit, tally } = await import('./audit.js');\n const base = await resolveBase(workspace, baseFlag);\n const text = await briefText(workspace, brief);\n const [dependencies, archive, assertions, rulings, plugin] = await Promise.all([\n dependencyChanges(workspace, base),\n archiveReasons(workspace, brief, base),\n briefAssertions(workspace, brief, text, reader),\n checkRulings(workspace, brief, text, reader, base),\n specBriefPlugin(workspace.root),\n ]);\n const unmeasured =\n base.kind === 'unresolved' ? base.reason : base.mergeBase === base.head ? `${base.ref} and HEAD are the same commit: there is nothing to measure` : null;\n const report = audit({\n brief,\n unmeasured,\n dependencies,\n archive,\n assertions: 'unavailable' in assertions ? assertions : assertions.outcomes,\n // The audit reads no list as an empty one, and a run spec-guard could not\n // make has none, so a mutant of this test reads the same.\n unreadableAssertions: 'unavailable' in assertions ? [] : assertions.unreadable,\n premiseSections: workspace.config.assertions.premises,\n unverifiedRulings: rulings.unverified,\n verifiedRulings: rulings.verified,\n pluginLoaded: plugin.kind === 'loaded',\n });\n const findings = [...rulings.problems, ...report.findings];\n return {\n brief,\n base,\n dependencies: dependencies.changes,\n installScripts: dependencies.installScripts,\n report: { findings, counts: tally(findings), measured: report.measured },\n };\n}\n\n/* -------------------------------------------------------------- escalation */\n\nasync function escalationDirectory(workspace: Workspace): Promise<string> {\n return stateDirectory(workspace.commonDir, 'escalations');\n}\n\nexport async function listEscalations(workspace: Workspace): Promise<EscalationRequest[]> {\n const directory = await escalationDirectory(workspace);\n const out: EscalationRequest[] = [];\n for (const name of (await readdir(directory)).filter((n) => n.endsWith('.json')).sort()) {\n // What is no file is no request, and is passed over as one that cannot be read is.\n if (!isFile(join(directory, name))) continue;\n try {\n // A Buffer parses as its text, so the encoding is equivalent to its mutant.\n const request: EscalationRequest = JSON.parse(await readFile(join(directory, name), 'utf8'));\n out.push(request);\n } catch {\n // A request that cannot be read is skipped; listing it would list nothing true.\n }\n }\n return out;\n}\n\nexport async function raiseEscalation(\n workspace: Workspace,\n brief: BriefRow,\n request: { paths: readonly string[]; reason: string; options: readonly EscalationOption[]; recommendation: string | null },\n): Promise<{ request: EscalationRequest; memo: string }> {\n const existing = await listEscalations(workspace);\n const id = nextId('E', brief.id, existing.map((e) => e.id));\n const full: EscalationRequest = {\n id,\n brief: brief.id,\n briefFile: brief.file,\n paths: request.paths,\n reason: request.reason,\n options: request.options,\n recommendation: request.recommendation,\n created: new Date().toISOString(),\n branch: workspace.branch,\n head: await revision('HEAD', workspace.root),\n };\n await writeAtomic(join(await escalationDirectory(workspace), `${id}.json`), `${JSON.stringify(full, null, 2)}\\n`);\n return { request: full, memo: renderMemo(full) };\n}\n\n/** Writes a person's ruling into the brief and retires the request. Never commits: the signature is the person's. */\nexport async function recordRuling(\n workspace: Workspace,\n escalationId: string,\n decision: 'allow' | 'deny',\n note: string,\n reader: DocumentReader,\n): Promise<{ id: string; file: string; row: string }> {\n const request = (await listEscalations(workspace)).find((candidate) => candidate.id === escalationId.toUpperCase() || candidate.id === escalationId);\n if (request === undefined) throw new UsageError(`no escalation \"${escalationId}\" is waiting; spec-harness escalate --list shows those that are`);\n const path = join(workspace.root, request.briefFile);\n const text = await readText(path);\n if (text === null) throw new UsageError(`${request.briefFile} cannot be read`);\n const where = reader.sectionTables(text, workspace.config.rulings.section);\n const taken = readRulings(where.tables).rulings.map((row) => row.id);\n const id = nextId('R', request.brief, taken);\n const row = renderRow(id, request.paths, decision, note);\n await writeAtomic(path, addRulingRow(text, workspace.config.rulings.section, row, where));\n // Listed a moment ago; forced, a request another process retired in\n // between is not an error, so the option is equivalent to its mutants.\n await rm(join(await escalationDirectory(workspace), `${request.id}.json`), { force: true });\n return { id, file: request.briefFile, row };\n}\n"]}
|
package/dist/server.js
CHANGED
|
@@ -14,11 +14,12 @@ import { findActive } from './briefs.js';
|
|
|
14
14
|
import { briefIdFromBranch } from './branch.js';
|
|
15
15
|
import { titleOf } from './context.js';
|
|
16
16
|
import { createReader } from './reader.js';
|
|
17
|
-
import { realSpelling } from './fs.js';
|
|
17
|
+
import { outsideEvery, realSpelling } from './fs.js';
|
|
18
|
+
import { heldBy } from './guard.js';
|
|
18
19
|
import { buildContext, checkPaths, raiseEscalation, runAudit } from './round.js';
|
|
19
20
|
import { emptyValue, isBlank } from './usage.js';
|
|
20
21
|
import { CLIENT_CAPABILITIES_KEY, createMcpServer, isObject, serveLines, toolError, unknownArguments, } from './vendor/spec-core/jsonrpc/index.js';
|
|
21
|
-
import { describeActive, findTree, foundCommonDir, mayBeElsewhere, openFound, openWorkspace, version, writesBy } from './workspace.js';
|
|
22
|
+
import { describeActive, findTree, foundCommonDir, mayBeElsewhere, namedId, openFound, openWorkspace, version, writesBy } from './workspace.js';
|
|
22
23
|
const reader = createReader();
|
|
23
24
|
export const INSTRUCTIONS = 'spec-harness keeps a round of work inside the brief a person approved. ' +
|
|
24
25
|
'Call start_round before working: it returns the brief, the scope you may write, what you must not touch, the rules in force and the documents the brief cites. ' +
|
|
@@ -230,6 +231,38 @@ async function round(workspace, env, id) {
|
|
|
230
231
|
return toolError(note);
|
|
231
232
|
return { brief, briefs };
|
|
232
233
|
}
|
|
234
|
+
/**
|
|
235
|
+
* The brief the argument, `SPEC_BRIEF` or the branch names, as the hook
|
|
236
|
+
* finds it: where nothing names one, spec-brief is not asked, and the answer
|
|
237
|
+
* is no brief whatever spec-brief would say (ADR-0004), so the empty list is
|
|
238
|
+
* equivalent to its mutant.
|
|
239
|
+
*/
|
|
240
|
+
async function namedBrief(workspace, env, id) {
|
|
241
|
+
if (namedId(workspace, { brief: id }, env) === null)
|
|
242
|
+
return findActive([], {});
|
|
243
|
+
const briefs = await workspace.siblings.briefs();
|
|
244
|
+
return findActive(briefs, { argument: id, environment: env['SPEC_BRIEF'], branch: briefIdFromBranch(workspace.config.branches, workspace.branch) });
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* Each path as the hook decides a write of it alone (ADR-0005, ADR-0008): one
|
|
248
|
+
* outside every work tree of the repository as a file outside it, with no
|
|
249
|
+
* brief asked about, whatever names one; the rest by the brief named, with
|
|
250
|
+
* no brief where nothing names one, and held, in the hook's words, where
|
|
251
|
+
* what names it names none a round can work under. spec-brief is asked only
|
|
252
|
+
* where a path is inside, as the hook asks it.
|
|
253
|
+
*/
|
|
254
|
+
async function asTheHook(workspace, env, id, paths, cwd, base) {
|
|
255
|
+
const outside = paths.map((path) => outsideEvery([path], workspace.root, workspace.commonDir, cwd));
|
|
256
|
+
// Paths all outside ask about no brief, and are answered as with none
|
|
257
|
+
// named: the empty list is equivalent to its mutant, as in namedBrief.
|
|
258
|
+
const { brief, note, problem } = describeActive(outside.every((each) => each) ? findActive([], {}) : await namedBrief(workspace, env, id), '"brief"');
|
|
259
|
+
if (problem === null)
|
|
260
|
+
return checkPaths(workspace, brief, note, paths, cwd, reader, base);
|
|
261
|
+
// Decided by no brief, a path outside is decided as outside the
|
|
262
|
+
// repository, and one inside is held, named as the repository names it.
|
|
263
|
+
const decided = await checkPaths(workspace, null, undefined, paths, cwd, reader, base);
|
|
264
|
+
return decided.map((decision, at) => (outside[at] ? decision : heldBy(decision.path, problem)));
|
|
265
|
+
}
|
|
233
266
|
export function tools(workspace, env, roots = NO_ROOTS) {
|
|
234
267
|
const readOnly = { readOnlyHint: true, idempotentHint: true, openWorldHint: false };
|
|
235
268
|
// A tool writes nothing to the server's streams, so these are never
|
|
@@ -283,7 +316,7 @@ export function tools(workspace, env, roots = NO_ROOTS) {
|
|
|
283
316
|
descriptor: {
|
|
284
317
|
name: 'check_path',
|
|
285
318
|
title: 'May the round write these files',
|
|
286
|
-
description: 'For each path: allowed (in scope,
|
|
319
|
+
description: 'For each path, as the guard hook decides a write of it: allowed (in scope, covered by a signed ruling, outside every work tree of the repository, or with no brief named), outside the scope, or refused (protected by the brief, or held where what names the brief names none a round can work under). Works for files that do not exist yet.',
|
|
287
320
|
inputSchema: {
|
|
288
321
|
type: 'object',
|
|
289
322
|
properties: {
|
|
@@ -314,14 +347,16 @@ export function tools(workspace, env, roots = NO_ROOTS) {
|
|
|
314
347
|
const where = await chosen(workspace, io, roots, args['directory']);
|
|
315
348
|
if ('text' in where)
|
|
316
349
|
return where;
|
|
350
|
+
const id = args['brief'];
|
|
351
|
+
if (id !== undefined && typeof id !== 'string')
|
|
352
|
+
return toolError('"brief" must be a string.');
|
|
353
|
+
if (id !== undefined && isBlank(id))
|
|
354
|
+
return namesNothing('brief', 'brief', id);
|
|
317
355
|
// Each path by the work tree of this repository that holds it, as the
|
|
318
356
|
// hook decides a write: the one read, another, or the server's own.
|
|
319
357
|
const decisions = [];
|
|
320
358
|
for (const part of await writesBy(workspace, where.workspace.root, given.paths, io)) {
|
|
321
|
-
|
|
322
|
-
if ('text' in found)
|
|
323
|
-
return found;
|
|
324
|
-
decisions.push(...(await checkPaths(part.workspace, found.brief, undefined, part.paths, where.workspace.root, reader, base.base)));
|
|
359
|
+
decisions.push(...(await asTheHook(part.workspace, env, id, part.paths, where.workspace.root, base.base)));
|
|
325
360
|
}
|
|
326
361
|
const text = decisions.map((d) => `${d.verdict}: ${d.message}${d.verdict === 'allow' ? '' : `. Next: ${d.hint}`}`).join('\n');
|
|
327
362
|
const { said, workTree } = readIn(where);
|