@descent-vtt/spec-harness 0.6.0 → 0.8.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.
Files changed (87) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/.claude-plugin/plugin.json +1 -1
  3. package/CHANGELOG.md +118 -0
  4. package/README.md +275 -24
  5. package/dist/audit.d.ts +71 -1
  6. package/dist/audit.js +140 -17
  7. package/dist/audit.js.map +1 -1
  8. package/dist/branch.d.ts +13 -0
  9. package/dist/branch.js +19 -0
  10. package/dist/branch.js.map +1 -1
  11. package/dist/cli.d.ts +1 -1
  12. package/dist/cli.js +53 -13
  13. package/dist/cli.js.map +1 -1
  14. package/dist/commands.js +12 -4
  15. package/dist/commands.js.map +1 -1
  16. package/dist/config.js +3 -1
  17. package/dist/config.js.map +1 -1
  18. package/dist/configure.d.ts +62 -3
  19. package/dist/configure.js +121 -5
  20. package/dist/configure.js.map +1 -1
  21. package/dist/context.d.ts +23 -7
  22. package/dist/context.js +69 -21
  23. package/dist/context.js.map +1 -1
  24. package/dist/document.d.ts +15 -2
  25. package/dist/document.js.map +1 -1
  26. package/dist/formats.d.ts +31 -0
  27. package/dist/formats.js +127 -0
  28. package/dist/formats.js.map +1 -0
  29. package/dist/git.d.ts +6 -0
  30. package/dist/git.js +8 -0
  31. package/dist/git.js.map +1 -1
  32. package/dist/guard.d.ts +8 -0
  33. package/dist/guard.js +19 -1
  34. package/dist/guard.js.map +1 -1
  35. package/dist/host.d.ts +15 -0
  36. package/dist/host.js +111 -0
  37. package/dist/host.js.map +1 -0
  38. package/dist/index.d.ts +4 -2
  39. package/dist/index.js +2 -1
  40. package/dist/index.js.map +1 -1
  41. package/dist/manifests.d.ts +8 -1
  42. package/dist/manifests.js +16 -6
  43. package/dist/manifests.js.map +1 -1
  44. package/dist/premises.d.ts +3 -0
  45. package/dist/premises.js +52 -14
  46. package/dist/premises.js.map +1 -1
  47. package/dist/reader.js +28 -3
  48. package/dist/reader.js.map +1 -1
  49. package/dist/round.d.ts +8 -0
  50. package/dist/round.js +70 -23
  51. package/dist/round.js.map +1 -1
  52. package/dist/server.js +10 -3
  53. package/dist/server.js.map +1 -1
  54. package/dist/setup.d.ts +10 -0
  55. package/dist/setup.js +73 -32
  56. package/dist/setup.js.map +1 -1
  57. package/dist/siblings.d.ts +2 -0
  58. package/dist/siblings.js +1 -1
  59. package/dist/siblings.js.map +1 -1
  60. package/dist/signers.d.ts +46 -0
  61. package/dist/signers.js +180 -0
  62. package/dist/signers.js.map +1 -0
  63. package/dist/types.d.ts +7 -0
  64. package/dist/types.js.map +1 -1
  65. package/dist/vendor/spec-core/markdown/frontmatter.d.ts +11 -1
  66. package/dist/vendor/spec-core/markdown/frontmatter.js +20 -3
  67. package/dist/vendor/spec-core/markdown/frontmatter.js.map +1 -1
  68. package/dist/vendor/spec-core/pattern/glob.d.ts +85 -0
  69. package/dist/vendor/spec-core/pattern/glob.js +207 -17
  70. package/dist/vendor/spec-core/pattern/glob.js.map +1 -1
  71. package/dist/vendor/spec-core/pattern/index.d.ts +2 -2
  72. package/dist/vendor/spec-core/pattern/index.js +1 -1
  73. package/dist/vendor/spec-core/pattern/index.js.map +1 -1
  74. package/dist/vendor/spec-core/text/index.d.ts +1 -0
  75. package/dist/vendor/spec-core/text/index.js +1 -0
  76. package/dist/vendor/spec-core/text/index.js.map +1 -1
  77. package/dist/vendor/spec-core/text/width.d.ts +30 -0
  78. package/dist/vendor/spec-core/text/width.js +113 -0
  79. package/dist/vendor/spec-core/text/width.js.map +1 -0
  80. package/dist/versions.d.ts +40 -1
  81. package/dist/versions.js +33 -1
  82. package/dist/versions.js.map +1 -1
  83. package/dist/workspace.d.ts +6 -1
  84. package/dist/workspace.js +17 -6
  85. package/dist/workspace.js.map +1 -1
  86. package/package.json +1 -1
  87. package/skills/close-round/SKILL.md +4 -1
package/dist/git.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"git.js","sourceRoot":"","sources":["../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,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC;AAC7G,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,IAAY,EAAE,GAAW,EAAE,GAAW;IACtE,MAAM,GAAG,GAAG,MAAM,GAAG,CAAC,CAAC,UAAU,EAAE,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,IAAI,EAAE,GAAG,CAAC,EAAE,GAAG,CAAC,CAAC;IAClF,IAAI,GAAG,CAAC,IAAI,KAAK,CAAC;QAAE,MAAM,IAAI,QAAQ,CAAC,4BAA4B,GAAG,CAAC,MAAM,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;AAC1F,CAAC;AAED;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,IAAY,EAAE,GAAW;IAC5D,MAAM,GAAG,CAAC,CAAC,UAAU,EAAE,QAAQ,EAAE,SAAS,EAAE,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC;AAC1D,CAAC","sourcesContent":["/**\n * The edge where the harness meets git.\n *\n * Reads, except for two things ADR-0003 allows and bounds: a temporary\n * worktree, added and always removed by the sandbox, and nothing else. Every\n * call is an argument vector, never a shell string, so a path or a ref cannot\n * become a command.\n */\n\nimport { execFile } from 'node:child_process';\n\nimport type { FileChange } from './types.js';\n\nexport interface Run {\n readonly code: number;\n readonly stdout: string;\n readonly stderr: string;\n}\n\n/** Runs git and answers whatever it answered; a missing git is a code of -1. */\nexport function git(args: readonly string[], cwd: string, input?: string): Promise<Run> {\n return new Promise((resolve) => {\n const child = execFile(\n 'git',\n [...args],\n { cwd, maxBuffer: 256 * 1024 * 1024, encoding: 'utf8', windowsHide: true },\n (error, stdout, stderr) => {\n const code = error === null ? 0 : typeof (error as { code?: unknown }).code === 'number' ? ((error as { code: number }).code) : -1;\n resolve({ code, stdout, stderr });\n },\n );\n if (input !== undefined) child.stdin?.end(input);\n });\n}\n\nasync function value(args: readonly string[], cwd: string): Promise<string | null> {\n const run = await git(args, cwd);\n return run.code === 0 ? run.stdout.trim() : null;\n}\n\nexport class GitError extends Error {\n constructor(message: string) {\n super(message);\n this.name = 'GitError';\n }\n}\n\n/** The top of the work tree holding `cwd`, POSIX-separated, or `null` outside one. */\nexport async function workTreeRoot(cwd: string): Promise<string | null> {\n return value(['rev-parse', '--show-toplevel'], cwd);\n}\n\n/** The git directory every worktree of this repository shares. */\nexport async function commonDirectory(cwd: string): Promise<string | null> {\n return value(['rev-parse', '--path-format=absolute', '--git-common-dir'], cwd);\n}\n\n/** The checked-out branch's short name, or `null` on a detached head. */\nexport async function currentBranch(cwd: string): Promise<string | null> {\n return value(['symbolic-ref', '--quiet', '--short', 'HEAD'], cwd);\n}\n\n/** The remote's default branch as a local ref, such as `origin/main`, or `null`. */\nexport async function remoteDefault(cwd: string): Promise<string | null> {\n return value(['symbolic-ref', '--quiet', '--short', 'refs/remotes/origin/HEAD'], cwd);\n}\n\n/** Every local branch, by its short name. */\nexport async function localBranches(cwd: string): Promise<string[]> {\n const listed = await value(['for-each-ref', '--format=%(refname:short)', 'refs/heads/'], cwd);\n return listed === null || listed === '' ? [] : listed.split('\\n').map((name) => name.trim());\n}\n\nexport async function revision(ref: string, cwd: string): Promise<string | null> {\n return value(['rev-parse', '--verify', '--quiet', `${ref}^{commit}`], cwd);\n}\n\nexport async function mergeBase(a: string, b: string, cwd: string): Promise<string | null> {\n return value(['merge-base', a, b], cwd);\n}\n\n/** Parses `git diff --name-status -z` output. */\nexport function parseNameStatus(output: string): FileChange[] {\n const fields = output.split('\\0');\n const out: FileChange[] = [];\n for (let i = 0; i < fields.length; ) {\n const code = fields[i] ?? '';\n if (code === '') {\n i += 1;\n continue;\n }\n const status = code.charAt(0) as FileChange['status'];\n if (status === 'R' || status === 'C') {\n out.push({ status, from: fields[i + 1] ?? '', path: fields[i + 2] ?? '' });\n i += 3;\n } else {\n out.push({ status, path: fields[i + 1] ?? '' });\n i += 2;\n }\n }\n return out;\n}\n\n/** The files changed from one revision to another, renames found. */\nexport async function changes(from: string, to: string, cwd: string): Promise<FileChange[]> {\n const run = await git(['diff', '--name-status', '-z', '--find-renames', '--no-color', from, to, '--'], cwd);\n if (run.code !== 0) throw new GitError(`git diff ${from} ${to} failed: ${run.stderr.trim()}`);\n return parseNameStatus(run.stdout);\n}\n\n/** The files a commit would change: what is staged. */\nexport async function stagedChanges(cwd: string): Promise<FileChange[]> {\n const run = await git(['diff', '--cached', '--name-status', '-z', '--find-renames', '--no-color', '--'], cwd);\n if (run.code !== 0) throw new GitError(`git diff --cached failed: ${run.stderr.trim()}`);\n return parseNameStatus(run.stdout);\n}\n\n/** A file's content at a revision, or `null` when it does not exist there. */\nexport async function show(ref: string, path: string, cwd: string): Promise<string | null> {\n const run = await git(['show', `${ref}:${path}`], cwd);\n return run.code === 0 ? run.stdout : null;\n}\n\n/**\n * The commit that last changed one line of a file, as of a revision, or of\n * the working tree when `ref` is `null` - where a line nobody committed yet\n * belongs to the all-zero commit.\n */\nexport async function blameLine(ref: string | null, path: string, line: number, cwd: string): Promise<string | null> {\n const run = await git(['blame', '--porcelain', '-L', `${line},${line}`, ...(ref === null ? [] : [ref]), '--', path], cwd);\n if (run.code !== 0) return null;\n const sha = /^([0-9a-f]{40,64}) /.exec(run.stdout)?.[1];\n return sha ?? null;\n}\n\nexport interface Signature {\n readonly good: boolean;\n /** The allowed signer's principal, for a good signature. */\n readonly principal: string | null;\n readonly detail: string;\n}\n\n/**\n * Whether a commit carries a good SSH signature by a principal in the given\n * allowed-signers file. The file is passed in, never read from the commit's\n * own tree: a round cannot vouch for itself (ADR-0006).\n */\nexport async function verifyCommit(sha: string, allowedSignersFile: string, cwd: string): Promise<Signature> {\n const run = await git(\n ['-c', `gpg.ssh.allowedSignersFile=${allowedSignersFile}`, '-c', 'gpg.format=ssh', 'verify-commit', '--raw', sha],\n cwd,\n );\n const text = `${run.stderr}\\n${run.stdout}`;\n const principal = /Good \"git\" signature for (\\S+)/.exec(text)?.[1] ?? null;\n return { good: run.code === 0 && principal !== null, principal, detail: text.trim().split('\\n')[0] ?? '' };\n}\n\nexport async function addWorktree(path: string, rev: string, cwd: string): Promise<void> {\n const run = await git(['worktree', 'add', '--detach', '--force', path, rev], cwd);\n if (run.code !== 0) throw new GitError(`git worktree add failed: ${run.stderr.trim()}`);\n}\n\n/**\n * Forgets the worktree at `path`, and no other, once its directory is\n * deleted. Git refuses to remove a worktree whose directory has lost its\n * `.git` file, and removes its record of one whose directory is gone, found by\n * the path it was added at: `git worktree prune` would also forget every other\n * worktree git has lost track of, the person's among them.\n */\nexport async function removeWorktree(path: string, cwd: string): Promise<void> {\n await git(['worktree', 'remove', '--force', path], cwd);\n}\n"]}
1
+ {"version":3,"file":"git.js","sourceRoot":"","sources":["../src/git.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAU9C,gFAAgF;AAChF,MAAM,UAAU,GAAG,CAAC,IAAuB,EAAE,GAAW,EAAE,KAAc;IACtE,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;QAC7B,MAAM,KAAK,GAAG,QAAQ,CACpB,KAAK,EACL,CAAC,GAAG,IAAI,CAAC,EACT,EAAE,GAAG,EAAE,SAAS,EAAE,GAAG,GAAG,IAAI,GAAG,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,WAAW,EAAE,IAAI,EAAE,EAC1E,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE;YACxB,MAAM,IAAI,GAAG,KAAK,KAAK,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAQ,KAA4B,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAE,KAA0B,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YACnI,OAAO,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,C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MAAM,GAAG,CAAC,CAAC,UAAU,EAAE,QAAQ,EAAE,SAAS,EAAE,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC;AAC1D,CAAC","sourcesContent":["/**\n * The edge where the harness meets git.\n *\n * Reads, except for two things ADR-0003 allows and bounds: a temporary\n * worktree, added and always removed by the sandbox, and nothing else. Every\n * call is an argument vector, never a shell string, so a path or a ref cannot\n * become a command.\n */\n\nimport { execFile } from 'node:child_process';\n\nimport type { FileChange } from './types.js';\n\nexport interface Run {\n readonly code: number;\n readonly stdout: string;\n readonly stderr: string;\n}\n\n/** Runs git and answers whatever it answered; a missing git is a code of -1. */\nexport function git(args: readonly string[], cwd: string, input?: string): Promise<Run> {\n return new Promise((resolve) => {\n const child = execFile(\n 'git',\n [...args],\n { cwd, maxBuffer: 256 * 1024 * 1024, encoding: 'utf8', windowsHide: true },\n (error, stdout, stderr) => {\n const code = error === null ? 0 : typeof (error as { code?: unknown }).code === 'number' ? ((error as { code: number }).code) : -1;\n resolve({ code, stdout, stderr });\n },\n );\n if (input !== undefined) child.stdin?.end(input);\n });\n}\n\nasync function value(args: readonly string[], cwd: string): Promise<string | null> {\n const run = await git(args, cwd);\n return run.code === 0 ? run.stdout.trim() : null;\n}\n\nexport class GitError extends Error {\n constructor(message: string) {\n super(message);\n this.name = 'GitError';\n }\n}\n\n/** The top of the work tree holding `cwd`, POSIX-separated, or `null` outside one. */\nexport async function workTreeRoot(cwd: string): Promise<string | null> {\n return value(['rev-parse', '--show-toplevel'], cwd);\n}\n\n/** The git directory every worktree of this repository shares. */\nexport async function commonDirectory(cwd: string): Promise<string | null> {\n return value(['rev-parse', '--path-format=absolute', '--git-common-dir'], cwd);\n}\n\n/**\n * Where git runs the hook `name` from, absolute: `core.hooksPath` read as git\n * reads it - relative to the work tree, absolute, or under `~` - and a linked\n * worktree's shared hooks. `null` when git cannot say, before 2.31.\n */\nexport async function hookPath(name: string, cwd: string): Promise<string | null> {\n return value(['rev-parse', '--path-format=absolute', '--git-path', `hooks/${name}`], cwd);\n}\n\n/** The checked-out branch's short name, or `null` on a detached head. */\nexport async function currentBranch(cwd: string): Promise<string | null> {\n return value(['symbolic-ref', '--quiet', '--short', 'HEAD'], cwd);\n}\n\n/** The remote's default branch as a local ref, such as `origin/main`, or `null`. */\nexport async function remoteDefault(cwd: string): Promise<string | null> {\n return value(['symbolic-ref', '--quiet', '--short', 'refs/remotes/origin/HEAD'], cwd);\n}\n\n/** Every local branch, by its short name. */\nexport async function localBranches(cwd: string): Promise<string[]> {\n const listed = await value(['for-each-ref', '--format=%(refname:short)', 'refs/heads/'], cwd);\n return listed === null || listed === '' ? [] : listed.split('\\n').map((name) => name.trim());\n}\n\nexport async function revision(ref: string, cwd: string): Promise<string | null> {\n return value(['rev-parse', '--verify', '--quiet', `${ref}^{commit}`], cwd);\n}\n\nexport async function mergeBase(a: string, b: string, cwd: string): Promise<string | null> {\n return value(['merge-base', a, b], cwd);\n}\n\n/** Parses `git diff --name-status -z` output. */\nexport function parseNameStatus(output: string): FileChange[] {\n const fields = output.split('\\0');\n const out: FileChange[] = [];\n for (let i = 0; i < fields.length; ) {\n const code = fields[i] ?? '';\n if (code === '') {\n i += 1;\n continue;\n }\n const status = code.charAt(0) as FileChange['status'];\n if (status === 'R' || status === 'C') {\n out.push({ status, from: fields[i + 1] ?? '', path: fields[i + 2] ?? '' });\n i += 3;\n } else {\n out.push({ status, path: fields[i + 1] ?? '' });\n i += 2;\n }\n }\n return out;\n}\n\n/** The files changed from one revision to another, renames found. */\nexport async function changes(from: string, to: string, cwd: string): Promise<FileChange[]> {\n const run = await git(['diff', '--name-status', '-z', '--find-renames', '--no-color', from, to, '--'], cwd);\n if (run.code !== 0) throw new GitError(`git diff ${from} ${to} failed: ${run.stderr.trim()}`);\n return parseNameStatus(run.stdout);\n}\n\n/** The files a commit would change: what is staged. */\nexport async function stagedChanges(cwd: string): Promise<FileChange[]> {\n const run = await git(['diff', '--cached', '--name-status', '-z', '--find-renames', '--no-color', '--'], cwd);\n if (run.code !== 0) throw new GitError(`git diff --cached failed: ${run.stderr.trim()}`);\n return parseNameStatus(run.stdout);\n}\n\n/** A file's content at a revision, or `null` when it does not exist there. */\nexport async function show(ref: string, path: string, cwd: string): Promise<string | null> {\n const run = await git(['show', `${ref}:${path}`], cwd);\n return run.code === 0 ? run.stdout : null;\n}\n\n/**\n * The commit that last changed one line of a file, as of a revision, or of\n * the working tree when `ref` is `null` - where a line nobody committed yet\n * belongs to the all-zero commit.\n */\nexport async function blameLine(ref: string | null, path: string, line: number, cwd: string): Promise<string | null> {\n const run = await git(['blame', '--porcelain', '-L', `${line},${line}`, ...(ref === null ? [] : [ref]), '--', path], cwd);\n if (run.code !== 0) return null;\n const sha = /^([0-9a-f]{40,64}) /.exec(run.stdout)?.[1];\n return sha ?? null;\n}\n\nexport interface Signature {\n readonly good: boolean;\n /** The allowed signer's principal, for a good signature. */\n readonly principal: string | null;\n readonly detail: string;\n}\n\n/**\n * Whether a commit carries a good SSH signature by a principal in the given\n * allowed-signers file. The file is passed in, never read from the commit's\n * own tree: a round cannot vouch for itself (ADR-0006).\n */\nexport async function verifyCommit(sha: string, allowedSignersFile: string, cwd: string): Promise<Signature> {\n const run = await git(\n ['-c', `gpg.ssh.allowedSignersFile=${allowedSignersFile}`, '-c', 'gpg.format=ssh', 'verify-commit', '--raw', sha],\n cwd,\n );\n const text = `${run.stderr}\\n${run.stdout}`;\n const principal = /Good \"git\" signature for (\\S+)/.exec(text)?.[1] ?? null;\n return { good: run.code === 0 && principal !== null, principal, detail: text.trim().split('\\n')[0] ?? '' };\n}\n\nexport async function addWorktree(path: string, rev: string, cwd: string): Promise<void> {\n const run = await git(['worktree', 'add', '--detach', '--force', path, rev], cwd);\n if (run.code !== 0) throw new GitError(`git worktree add failed: ${run.stderr.trim()}`);\n}\n\n/**\n * Forgets the worktree at `path`, and no other, once its directory is\n * deleted. Git refuses to remove a worktree whose directory has lost its\n * `.git` file, and removes its record of one whose directory is gone, found by\n * the path it was added at: `git worktree prune` would also forget every other\n * worktree git has lost track of, the person's among them.\n */\nexport async function removeWorktree(path: string, cwd: string): Promise<void> {\n await git(['worktree', 'remove', '--force', path], cwd);\n}\n"]}
package/dist/guard.d.ts CHANGED
@@ -44,6 +44,14 @@ export interface GuardInput {
44
44
  * can. The guard matches no path by a pattern it cannot read.
45
45
  */
46
46
  export declare function whyUnreadable(pattern: string): string | null;
47
+ /**
48
+ * Whether a leading `/` roots a pattern the guard can read at the
49
+ * filesystem's root: `whole` when every alternative is rooted, `part` when
50
+ * some brace alternative is, `null` when none is or the pattern cannot be
51
+ * read. The guard decides repository-relative paths, so a rooted
52
+ * alternative matches none of them.
53
+ */
54
+ export declare function rooted(pattern: string): 'whole' | 'part' | null;
47
55
  /** The first verified ruling whose paths cover `path`, read as the guard reads a scope. */
48
56
  export declare function rulingFor(rulings: readonly VerifiedRuling[], path: string): VerifiedRuling | undefined;
49
57
  /** Decides one path. Pure: the caller resolved the path, the brief and the rulings. */
package/dist/guard.js CHANGED
@@ -8,7 +8,7 @@
8
8
  * through a shell passes it - so the audit and spec-brief's archive are the
9
9
  * gates, and this is what keeps an honest agent from needing them (ADR-0005).
10
10
  */
11
- import { parseGlob } from './vendor/spec-core/pattern/index.js';
11
+ import { globAlternatives, parseGlob } from './vendor/spec-core/pattern/index.js';
12
12
  function compile(pattern) {
13
13
  const parsed = parseGlob(pattern, { dialect: 'path', caseSensitive: true, literal: 'either' });
14
14
  return parsed.ok ? parsed.glob : parsed.error;
@@ -21,6 +21,24 @@ export function whyUnreadable(pattern) {
21
21
  const glob = compile(pattern);
22
22
  return typeof glob === 'string' ? glob : null;
23
23
  }
24
+ /**
25
+ * Whether a leading `/` roots a pattern the guard can read at the
26
+ * filesystem's root: `whole` when every alternative is rooted, `part` when
27
+ * some brace alternative is, `null` when none is or the pattern cannot be
28
+ * read. The guard decides repository-relative paths, so a rooted
29
+ * alternative matches none of them.
30
+ */
31
+ export function rooted(pattern) {
32
+ if (typeof compile(pattern) === 'string')
33
+ return null;
34
+ // spec-core refuses here only what its compile refuses, so a pattern the
35
+ // guard reads always has its alternatives read.
36
+ const { alternatives } = globAlternatives(pattern);
37
+ const roots = alternatives.filter((alternative) => alternative.rooted).length;
38
+ if (roots === 0)
39
+ return null;
40
+ return roots === alternatives.length ? 'whole' : 'part';
41
+ }
24
42
  function matching(patterns, path) {
25
43
  const matched = [];
26
44
  const unreadable = [];
package/dist/guard.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"guard.js","sourceRoot":"","sources":["../src/guard.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,SAAS,EAAa,MAAM,qCAAqC,CAAC;AA8C3E,SAAS,OAAO,CAAC,OAAe;IAC9B,MAAM,MAAM,GAAG,SAAS,CAAC,OAAO,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC,CAAC;IAC/F,OAAO,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;AAChD,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,aAAa,CAAC,OAAe;IAC3C,MAAM,IAAI,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAC9B,OAAO,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC;AAChD,CAAC;AAED,SAAS,QAAQ,CAAC,QAA2B,EAAE,IAAY;IACzD,MAAM,OAAO,GAAa,EAAE,CAAC;IAC7B,MAAM,UAAU,GAAa,EAAE,CAAC;IAChC,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;QAC/B,MAAM,IAAI,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;QAC9B,IAAI,OAAO,IAAI,KAAK,QAAQ;YAAE,UAAU,CAAC,IAAI,CAAC,GAAG,OAAO,KAAK,I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,aAAa,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG;YAChI,IAAI,EAAE,QAAQ;SACf,CAAC;IACJ,CAAC;IAED,MAAM,YAAY,GAAG,QAAQ,CAAC,KAAK,CAAC,aAAa,EAAE,IAAI,CAAC,CAAC;IACzD,IAAI,YAAY,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACpC,OAAO;YACL,IAAI;YACJ,OAAO,EAAE,OAAO;YAChB,MAAM,EAAE,UAAU;YAClB,OAAO,EAAE,YAAY,CAAC,OAAO;YAC7B,OAAO,EAAE,GAAG,IAAI,gBAAgB,KAAK,CAAC,EAAE,aAAa,YAAY,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG;YACvF,IAAI,EAAE,eAAe;SACtB,CAAC;IACJ,CAAC;IAED,MAAM,OAAO,GAAY,KAAK,CAAC,UAAU,CAAC;IAC1C,MAAM,KAAK,GAAG,KAAK,CAAC,aAAa,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,2BAA2B,CAAC,CAAC,CAAC,UAAU,KAAK,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;IAC1H,OAAO;QACL,IAAI;QACJ,OAAO;QACP,MAAM,EAAE,cAAc;QACtB,OAAO,EAAE,YAAY,CAAC,UAAU;QAChC,OAAO,EAAE,GAAG,IAAI,qBAAqB,KAAK,CAAC,EAAE,mBAAmB,KAAK,EAAE;QACvE,IAAI,EACF,OAAO,KAAK,MAAM;YAChB,CAAC,CAAC,8BAA8B,KAAK,CAAC,IAAI,4FAA4F,QAAQ,EAAE;YAChJ,CAAC,CAAC,oCAAoC,KAAK,CAAC,IAAI,gFAAgF;KACrI,CAAC;AACJ,CAAC","sourcesContent":["/**\n * May this round write this file?\n *\n * The answer is read from the brief the round runs under: `protectedFiles`\n * are refused unless a person has ruled otherwise, `affectedFiles` are the\n * round's to write, and anything else is outside the scope the person\n * approved. A guard is a guardrail, not a boundary - an agent that writes\n * through a shell passes it - so the audit and spec-brief's archive are the\n * gates, and this is what keeps an honest agent from needing them (ADR-0005).\n */\n\nimport { parseGlob, type Glob } from './vendor/spec-core/pattern/index.js';\nimport type { OutOfScope } from './config.js';\nimport type { BriefRow } from './types.js';\n\nexport type Verdict = 'allow' | 'warn' | 'ask' | 'deny';\n\nexport type Reason =\n | 'outside-repository'\n | 'no-brief'\n | 'brief-file'\n | 'protected'\n | 'ruled'\n | 'unreadable-protection'\n | 'in-scope'\n | 'out-of-scope';\n\nexport interface Decision {\n /** Repository-relative, or the path as given when it lies outside. */\n readonly path: string;\n readonly verdict: Verdict;\n readonly reason: Reason;\n /** The patterns or ruling that decided it. */\n readonly because: readonly string[];\n readonly message: string;\n readonly hint: string;\n}\n\n/** A ruling whose signature has been verified: a person allowed these paths. */\nexport interface VerifiedRuling {\n readonly id: string;\n readonly paths: readonly string[];\n readonly signer: string;\n}\n\nexport interface GuardInput {\n /** Repository-relative POSIX path, or `null` for a path outside the repository. */\n readonly path: string | null;\n /** The path as the caller gave it, for messages. */\n readonly given: string;\n readonly brief: BriefRow | null;\n /** Why there is no brief, when there is none. */\n readonly noBrief?: string | undefined;\n readonly rulings: readonly VerifiedRuling[];\n readonly outOfScope: OutOfScope;\n}\n\nfunction compile(pattern: string): Glob | string {\n const parsed = parseGlob(pattern, { dialect: 'path', caseSensitive: true, literal: 'either' });\n return parsed.ok ? parsed.glob : parsed.error;\n}\n\n/**\n * Why the guard cannot read a pattern, in spec-core's words; `null` when it\n * can. The guard matches no path by a pattern it cannot read.\n */\nexport function whyUnreadable(pattern: string): string | null {\n const glob = compile(pattern);\n return typeof glob === 'string' ? glob : null;\n}\n\nfunction matching(patterns: readonly string[], path: string): { matched: string[]; unreadable: string[] } {\n const matched: string[] = [];\n const unreadable: string[] = [];\n for (const pattern of patterns) {\n const glob = compile(pattern);\n if (typeof glob === 'string') unreadable.push(`${pattern} (${glob})`);\n else if (glob.match(path)) matched.push(pattern);\n }\n return { matched, unreadable };\n}\n\n/** The first verified ruling whose paths cover `path`, read as the guard reads a scope. */\nexport function rulingFor(rulings: readonly VerifiedRuling[], path: string): VerifiedRuling | undefined {\n return rulings.find((candidate) => matching(candidate.paths, path).matched.length > 0);\n}\n\nconst ESCALATE =\n 'if the round cannot be done without it, stop and ask for a ruling: spec-harness escalate --path <file> --reason <why>, or the request_escalation tool';\n\n/** Decides one path. Pure: the caller resolved the path, the brief and the rulings. */\nexport function decide(input: GuardInput): Decision {\n const { path, given, brief } = input;\n if (path === null) {\n return {\n path: given,\n verdict: 'allow',\n reason: 'outside-repository',\n because: [],\n message: `${given} is outside the repository; no brief governs it`,\n hint: 'nothing to do',\n };\n }\n if (brief === null) {\n return {\n path,\n verdict: 'allow',\n reason: 'no-brief',\n because: [],\n message: `no brief governs ${path}: ${input.noBrief ?? 'no active brief'}`,\n hint: 'name the brief this work belongs to, so its scope can be checked',\n };\n }\n if (path === brief.file) {\n return {\n path,\n verdict: 'allow',\n reason: 'brief-file',\n because: [],\n message: `${path} is brief ${brief.id} itself`,\n hint: 'tick or disposition its boxes as the work lands',\n };\n }\n\n const protectedHits = matching(brief.protectedFiles, path);\n if (protectedHits.unreadable.length > 0) {\n // A protection that cannot be read cannot be honoured, and cannot be\n // assumed not to apply: refuse until the brief is fixed.\n return {\n path,\n verdict: 'deny',\n reason: 'unreadable-protection',\n because: protectedHits.unreadable,\n message: `brief ${brief.id} protects files with a pattern that cannot be read: ${protectedHits.unreadable.join('; ')}`,\n hint: `fix protectedFiles in ${brief.file} (spec-brief lint names the problem)`,\n };\n }\n if (protectedHits.matched.length > 0) {\n const ruling = rulingFor(input.rulings, path);\n if (ruling !== undefined) {\n return {\n path,\n verdict: 'allow',\n reason: 'ruled',\n because: [ruling.id],\n message: `${path} is protected by brief ${brief.id}, and ruling ${ruling.id}, signed by ${ruling.signer}, allows it`,\n hint: 'keep the change to what the ruling allows',\n };\n }\n return {\n path,\n verdict: 'deny',\n reason: 'protected',\n because: protectedHits.matched,\n message: `brief ${brief.id} does not empower this round to change ${path} (protectedFiles: ${protectedHits.matched.join(', ')})`,\n hint: ESCALATE,\n };\n }\n\n const affectedHits = matching(brief.affectedFiles, path);\n if (affectedHits.matched.length > 0) {\n return {\n path,\n verdict: 'allow',\n reason: 'in-scope',\n because: affectedHits.matched,\n message: `${path} is in brief ${brief.id}'s scope (${affectedHits.matched.join(', ')})`,\n hint: 'nothing to do',\n };\n }\n\n const verdict: Verdict = input.outOfScope;\n const scope = brief.affectedFiles.length === 0 ? 'declares no affectedFiles' : `covers ${brief.affectedFiles.join(', ')}`;\n return {\n path,\n verdict,\n reason: 'out-of-scope',\n because: affectedHits.unreadable,\n message: `${path} is outside brief ${brief.id}'s scope, which ${scope}`,\n hint:\n verdict === 'deny'\n ? `add it to affectedFiles in ${brief.file} if the round needs it, which is a change the person who approved the brief must see; or ${ESCALATE}`\n : `if the round needs it, say so in ${brief.file} and add it to affectedFiles; the archive reports every file outside the scope`,\n };\n}\n"]}
1
+ {"version":3,"file":"guard.js","sourceRoot":"","sources":["../src/guard.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAmC,MAAM,qCAAqC,CAAC;AA8CnH,SAAS,OAAO,CAAC,OAAe;IAC9B,MAAM,MAAM,GAAG,SAAS,CAAC,OAAO,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC,CAAC;IAC/F,OAAO,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;AAChD,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,aAAa,CAAC,OAAe;IAC3C,MAAM,IAAI,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAC9B,OAAO,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAA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,EAAE,GAAG,IAAI,gBAAgB,KAAK,CAAC,EAAE,aAAa,YAAY,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG;YACvF,IAAI,EAAE,eAAe;SACtB,CAAC;IACJ,CAAC;IAED,MAAM,OAAO,GAAY,KAAK,CAAC,UAAU,CAAC;IAC1C,MAAM,KAAK,GAAG,KAAK,CAAC,aAAa,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,2BAA2B,CAAC,CAAC,CAAC,UAAU,KAAK,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;IAC1H,OAAO;QACL,IAAI;QACJ,OAAO;QACP,MAAM,EAAE,cAAc;QACtB,OAAO,EAAE,YAAY,CAAC,UAAU;QAChC,OAAO,EAAE,GAAG,IAAI,qBAAqB,KAAK,CAAC,EAAE,mBAAmB,KAAK,EAAE;QACvE,IAAI,EACF,OAAO,KAAK,MAAM;YAChB,CAAC,CAAC,8BAA8B,KAAK,CAAC,IAAI,4FAA4F,QAAQ,EAAE;YAChJ,CAAC,CAAC,oCAAoC,KAAK,CAAC,IAAI,gFAAgF;KACrI,CAAC;AACJ,CAAC","sourcesContent":["/**\n * May this round write this file?\n *\n * The answer is read from the brief the round runs under: `protectedFiles`\n * are refused unless a person has ruled otherwise, `affectedFiles` are the\n * round's to write, and anything else is outside the scope the person\n * approved. A guard is a guardrail, not a boundary - an agent that writes\n * through a shell passes it - so the audit and spec-brief's archive are the\n * gates, and this is what keeps an honest agent from needing them (ADR-0005).\n */\n\nimport { globAlternatives, parseGlob, type Glob, type GlobAlternative } from './vendor/spec-core/pattern/index.js';\nimport type { OutOfScope } from './config.js';\nimport type { BriefRow } from './types.js';\n\nexport type Verdict = 'allow' | 'warn' | 'ask' | 'deny';\n\nexport type Reason =\n | 'outside-repository'\n | 'no-brief'\n | 'brief-file'\n | 'protected'\n | 'ruled'\n | 'unreadable-protection'\n | 'in-scope'\n | 'out-of-scope';\n\nexport interface Decision {\n /** Repository-relative, or the path as given when it lies outside. */\n readonly path: string;\n readonly verdict: Verdict;\n readonly reason: Reason;\n /** The patterns or ruling that decided it. */\n readonly because: readonly string[];\n readonly message: string;\n readonly hint: string;\n}\n\n/** A ruling whose signature has been verified: a person allowed these paths. */\nexport interface VerifiedRuling {\n readonly id: string;\n readonly paths: readonly string[];\n readonly signer: string;\n}\n\nexport interface GuardInput {\n /** Repository-relative POSIX path, or `null` for a path outside the repository. */\n readonly path: string | null;\n /** The path as the caller gave it, for messages. */\n readonly given: string;\n readonly brief: BriefRow | null;\n /** Why there is no brief, when there is none. */\n readonly noBrief?: string | undefined;\n readonly rulings: readonly VerifiedRuling[];\n readonly outOfScope: OutOfScope;\n}\n\nfunction compile(pattern: string): Glob | string {\n const parsed = parseGlob(pattern, { dialect: 'path', caseSensitive: true, literal: 'either' });\n return parsed.ok ? parsed.glob : parsed.error;\n}\n\n/**\n * Why the guard cannot read a pattern, in spec-core's words; `null` when it\n * can. The guard matches no path by a pattern it cannot read.\n */\nexport function whyUnreadable(pattern: string): string | null {\n const glob = compile(pattern);\n return typeof glob === 'string' ? glob : null;\n}\n\n/**\n * Whether a leading `/` roots a pattern the guard can read at the\n * filesystem's root: `whole` when every alternative is rooted, `part` when\n * some brace alternative is, `null` when none is or the pattern cannot be\n * read. The guard decides repository-relative paths, so a rooted\n * alternative matches none of them.\n */\nexport function rooted(pattern: string): 'whole' | 'part' | null {\n if (typeof compile(pattern) === 'string') return null;\n // spec-core refuses here only what its compile refuses, so a pattern the\n // guard reads always has its alternatives read.\n const { alternatives } = globAlternatives(pattern) as { readonly alternatives: readonly GlobAlternative[] };\n const roots = alternatives.filter((alternative) => alternative.rooted).length;\n if (roots === 0) return null;\n return roots === alternatives.length ? 'whole' : 'part';\n}\n\nfunction matching(patterns: readonly string[], path: string): { matched: string[]; unreadable: string[] } {\n const matched: string[] = [];\n const unreadable: string[] = [];\n for (const pattern of patterns) {\n const glob = compile(pattern);\n if (typeof glob === 'string') unreadable.push(`${pattern} (${glob})`);\n else if (glob.match(path)) matched.push(pattern);\n }\n return { matched, unreadable };\n}\n\n/** The first verified ruling whose paths cover `path`, read as the guard reads a scope. */\nexport function rulingFor(rulings: readonly VerifiedRuling[], path: string): VerifiedRuling | undefined {\n return rulings.find((candidate) => matching(candidate.paths, path).matched.length > 0);\n}\n\nconst ESCALATE =\n 'if the round cannot be done without it, stop and ask for a ruling: spec-harness escalate --path <file> --reason <why>, or the request_escalation tool';\n\n/** Decides one path. Pure: the caller resolved the path, the brief and the rulings. */\nexport function decide(input: GuardInput): Decision {\n const { path, given, brief } = input;\n if (path === null) {\n return {\n path: given,\n verdict: 'allow',\n reason: 'outside-repository',\n because: [],\n message: `${given} is outside the repository; no brief governs it`,\n hint: 'nothing to do',\n };\n }\n if (brief === null) {\n return {\n path,\n verdict: 'allow',\n reason: 'no-brief',\n because: [],\n message: `no brief governs ${path}: ${input.noBrief ?? 'no active brief'}`,\n hint: 'name the brief this work belongs to, so its scope can be checked',\n };\n }\n if (path === brief.file) {\n return {\n path,\n verdict: 'allow',\n reason: 'brief-file',\n because: [],\n message: `${path} is brief ${brief.id} itself`,\n hint: 'tick or disposition its boxes as the work lands',\n };\n }\n\n const protectedHits = matching(brief.protectedFiles, path);\n if (protectedHits.unreadable.length > 0) {\n // A protection that cannot be read cannot be honoured, and cannot be\n // assumed not to apply: refuse until the brief is fixed.\n return {\n path,\n verdict: 'deny',\n reason: 'unreadable-protection',\n because: protectedHits.unreadable,\n message: `brief ${brief.id} protects files with a pattern that cannot be read: ${protectedHits.unreadable.join('; ')}`,\n hint: `fix protectedFiles in ${brief.file} (spec-brief lint names the problem)`,\n };\n }\n if (protectedHits.matched.length > 0) {\n const ruling = rulingFor(input.rulings, path);\n if (ruling !== undefined) {\n return {\n path,\n verdict: 'allow',\n reason: 'ruled',\n because: [ruling.id],\n message: `${path} is protected by brief ${brief.id}, and ruling ${ruling.id}, signed by ${ruling.signer}, allows it`,\n hint: 'keep the change to what the ruling allows',\n };\n }\n return {\n path,\n verdict: 'deny',\n reason: 'protected',\n because: protectedHits.matched,\n message: `brief ${brief.id} does not empower this round to change ${path} (protectedFiles: ${protectedHits.matched.join(', ')})`,\n hint: ESCALATE,\n };\n }\n\n const affectedHits = matching(brief.affectedFiles, path);\n if (affectedHits.matched.length > 0) {\n return {\n path,\n verdict: 'allow',\n reason: 'in-scope',\n because: affectedHits.matched,\n message: `${path} is in brief ${brief.id}'s scope (${affectedHits.matched.join(', ')})`,\n hint: 'nothing to do',\n };\n }\n\n const verdict: Verdict = input.outOfScope;\n const scope = brief.affectedFiles.length === 0 ? 'declares no affectedFiles' : `covers ${brief.affectedFiles.join(', ')}`;\n return {\n path,\n verdict,\n reason: 'out-of-scope',\n because: affectedHits.unreadable,\n message: `${path} is outside brief ${brief.id}'s scope, which ${scope}`,\n hint:\n verdict === 'deny'\n ? `add it to affectedFiles in ${brief.file} if the round needs it, which is a change the person who approved the brief must see; or ${ESCALATE}`\n : `if the round needs it, say so in ${brief.file} and add it to affectedFiles; the archive reports every file outside the scope`,\n };\n}\n"]}
package/dist/host.d.ts ADDED
@@ -0,0 +1,15 @@
1
+ /**
2
+ * The edge where the harness meets a program that is neither git nor a
3
+ * sibling: Claude Code, asked which release it is.
4
+ *
5
+ * Found on `PATH` and started without a shell, as every program the harness
6
+ * runs is (ADR-0002). On Windows a program is an `.exe` or a `.com`. A
7
+ * `claude.cmd` shim, as npm installs Claude Code, can be started only by a
8
+ * shell - Node refuses a `.cmd` without one since the fix for CVE-2024-27980 -
9
+ * so it is read rather than run: the package it runs declares the release.
10
+ */
11
+ import type { ClaudeCodeAnswer } from './versions.js';
12
+ /** The file `name` names on `PATH` as the environment gives it, or `null`. */
13
+ export declare function onPath(name: string, env: Readonly<Record<string, string | undefined>>, platform?: NodeJS.Platform): string | null;
14
+ /** `claude --version`, as the Claude Code on `PATH` answers it, or why it cannot. */
15
+ export declare function claudeVersion(env: Readonly<Record<string, string | undefined>>, platform?: NodeJS.Platform): Promise<ClaudeCodeAnswer>;
package/dist/host.js ADDED
@@ -0,0 +1,111 @@
1
+ /**
2
+ * The edge where the harness meets a program that is neither git nor a
3
+ * sibling: Claude Code, asked which release it is.
4
+ *
5
+ * Found on `PATH` and started without a shell, as every program the harness
6
+ * runs is (ADR-0002). On Windows a program is an `.exe` or a `.com`. A
7
+ * `claude.cmd` shim, as npm installs Claude Code, can be started only by a
8
+ * shell - Node refuses a `.cmd` without one since the fix for CVE-2024-27980 -
9
+ * so it is read rather than run: the package it runs declares the release.
10
+ */
11
+ import { execFile } from 'node:child_process';
12
+ import { existsSync, statSync } from 'node:fs';
13
+ import { delimiter, dirname, join } from 'node:path';
14
+ import { readText } from './fs.js';
15
+ import { declaredVersion } from './siblings.js';
16
+ /** What Windows runs for a name with no extension, in order; the first two alone without a shell. */
17
+ const WINDOWS_EXTENSIONS = ['.COM', '.EXE', '.BAT', '.CMD'];
18
+ /**
19
+ * A path a shim runs, from the shim's own directory. npm's cmd-shim writes
20
+ * `"%dp0%\node_modules\@anthropic-ai\claude-code\bin\claude.exe"`, after
21
+ * `SET dp0=%~dp0`; pnpm's writes `"%~dp0\..."`.
22
+ */
23
+ const SHIM_TARGET = /"(?:%~dp0|%dp0%)\\([^"\r\n]*)"/g;
24
+ /**
25
+ * Where npm and pnpm install Claude Code, as the segments of a path: only its
26
+ * own package declares its release, where a package that wraps it declares
27
+ * the wrapper's.
28
+ */
29
+ const CLAUDE_CODE_PACKAGE = ['node_modules', '@anthropic-ai', 'claude-code'];
30
+ /** The file `name` names on `PATH` as the environment gives it, or `null`. */
31
+ export function onPath(name, env, platform = process.platform) {
32
+ // With neither, any text names directories no test can have made; and an
33
+ // empty entry is passed over rather than read as the working directory,
34
+ // which a test cannot fill: both mutants are equivalent in the suite.
35
+ const path = env['PATH'] ?? env['Path'] ?? '';
36
+ const windows = platform === 'win32';
37
+ const extensions = windows
38
+ ? (env['PATHEXT'] ?? WINDOWS_EXTENSIONS.join(';')).split(';').filter((extension) => extension !== '')
39
+ : [''];
40
+ for (const directory of path.split(windows ? ';' : delimiter)) {
41
+ if (directory === '')
42
+ continue;
43
+ for (const extension of extensions) {
44
+ const file = join(directory, `${name}${extension.toLowerCase()}`);
45
+ if (existsSync(file) && statSync(file).isFile())
46
+ return file;
47
+ }
48
+ }
49
+ return null;
50
+ }
51
+ /** The directory of Claude Code's package that a shim runs, or `null` when it runs none. */
52
+ function shimPackage(file, text) {
53
+ for (const match of text.matchAll(SHIM_TARGET)) {
54
+ const parts = match[1].split('\\');
55
+ const at = parts.findIndex((_, start) => CLAUDE_CODE_PACKAGE.every((part, offset) => parts[start + offset] === part));
56
+ if (at >= 0)
57
+ return join(dirname(file), ...parts.slice(0, at + CLAUDE_CODE_PACKAGE.length));
58
+ }
59
+ return null;
60
+ }
61
+ /**
62
+ * The release a Windows script on `PATH` runs, as the package.json of the
63
+ * Claude Code package it names declares it; nothing is run. A script that
64
+ * names no such package, or one whose package.json gives no version, cannot
65
+ * tell.
66
+ */
67
+ async function shimVersion(file) {
68
+ // A shim that cannot be read names no package, as an empty one does, so
69
+ // what stands in for its text is equivalent whatever it is.
70
+ const directory = shimPackage(file, (await readText(file)) ?? '');
71
+ if (directory !== null) {
72
+ const manifest = join(directory, 'package.json');
73
+ const version = declaredVersion(manifest);
74
+ if (typeof version === 'string')
75
+ return { declared: version, file: manifest };
76
+ }
77
+ return {
78
+ missing: `claude on PATH is ${file}, a script that cannot be started without a shell, which spec-harness does not use, and it names no @anthropic-ai/claude-code package whose package.json gives a version`,
79
+ };
80
+ }
81
+ /** `claude --version`, as the Claude Code on `PATH` answers it, or why it cannot. */
82
+ export async function claudeVersion(env, platform = process.platform) {
83
+ const file = onPath('claude', env, platform);
84
+ if (file === null)
85
+ return { missing: 'no claude is on PATH' };
86
+ if (platform === 'win32' && !/\.(?:exe|com)$/i.test(file))
87
+ return shimVersion(file);
88
+ // Of the options, only `shell: false` and the encoding change an answer a
89
+ // test can see: `windowsHide` hides a console window, and the timeout
90
+ // stops a claude that never answers, which a test would wait on for its
91
+ // length, so their mutants are equivalent in the suite.
92
+ return new Promise((resolve) => {
93
+ const failed = (error) => resolve({ missing: `${file} --version failed: ${error.message.split('\n')[0]}` });
94
+ try {
95
+ execFile(file, ['--version'], { encoding: 'utf8', windowsHide: true, timeout: 15_000, shell: false }, (error, stdout) => {
96
+ if (error !== null)
97
+ failed(error);
98
+ else
99
+ resolve({ output: stdout });
100
+ });
101
+ }
102
+ catch (error) {
103
+ // Windows refuses a file that is no program before any callback, as
104
+ // spawn UNKNOWN, where Linux reports it to the callback: doctor says
105
+ // so rather than stop. The sweep runs on Linux, so this line is the
106
+ // Windows job's to hold.
107
+ failed(error);
108
+ }
109
+ });
110
+ }
111
+ //# sourceMappingURL=host.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"host.js","sourceRoot":"","sources":["../src/host.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAErD,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACnC,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAGhD,qGAAqG;AACrG,MAAM,kBAAkB,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;AAE5D;;;;GAIG;AACH,MAAM,WAAW,GAAG,iCAAiC,CAAC;AAEtD;;;;GAIG;AACH,MAAM,mBAAmB,GAAG,CAAC,cAAc,EAAE,eAAe,EAAE,aAAa,CAAC,CAAC;AAE7E,8EAA8E;AAC9E,MAAM,UAAU,MAAM,CAAC,IAAY,EAAE,GAAiD,EAAE,QAAQ,GAAoB,OAAO,CAAC,QAAQ;IAClI,yEAAyE;IACzE,wEAAwE;IACxE,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C,iBAAiB,CAAC,IAAI,CAAC,IAAI,CAAC;QAAE,OAAO,WAAW,CAAC,IAAI,CAAC,CAAC;IACpF,0EAA0E;IAC1E,sEAAsE;IACtE,wEAAwE;IACxE,wDAAwD;IACxD,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;QAC7B,MAAM,MAAM,GAAG,CAAC,KAAY,EAAQ,EAAE,CAAC,OAAO,CAAC,EAAE,OAAO,EAAE,GAAG,IAAI,sBAAsB,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAW,EAAE,EAAE,CAAC,CAAC;QACnI,IAAI,CAAC;YACH,QAAQ,CAAC,IAAI,EAAE,CAAC,WAAW,CAAC,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,WAAW,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE;gBACtH,IAAI,KAAK,KAAK,IAAI;oBAAE,MAAM,CAAC,KAAK,CAAC,CAAC;;oBAC7B,OAAO,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;YACnC,CAAC,CAAC,CAAC;QACL,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,oEAAoE;YACpE,qEAAqE;YACrE,oEAAoE;YACpE,yBAAyB;YACzB,MAAM,CAAC,KAAc,CAAC,CAAC;QACzB,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["/**\n * The edge where the harness meets a program that is neither git nor a\n * sibling: Claude Code, asked which release it is.\n *\n * Found on `PATH` and started without a shell, as every program the harness\n * runs is (ADR-0002). On Windows a program is an `.exe` or a `.com`. A\n * `claude.cmd` shim, as npm installs Claude Code, can be started only by a\n * shell - Node refuses a `.cmd` without one since the fix for CVE-2024-27980 -\n * so it is read rather than run: the package it runs declares the release.\n */\n\nimport { execFile } from 'node:child_process';\nimport { existsSync, statSync } from 'node:fs';\nimport { delimiter, dirname, join } from 'node:path';\n\nimport { readText } from './fs.js';\nimport { declaredVersion } from './siblings.js';\nimport type { ClaudeCodeAnswer } from './versions.js';\n\n/** What Windows runs for a name with no extension, in order; the first two alone without a shell. */\nconst WINDOWS_EXTENSIONS = ['.COM', '.EXE', '.BAT', '.CMD'];\n\n/**\n * A path a shim runs, from the shim's own directory. npm's cmd-shim writes\n * `\"%dp0%\\node_modules\\@anthropic-ai\\claude-code\\bin\\claude.exe\"`, after\n * `SET dp0=%~dp0`; pnpm's writes `\"%~dp0\\...\"`.\n */\nconst SHIM_TARGET = /\"(?:%~dp0|%dp0%)\\\\([^\"\\r\\n]*)\"/g;\n\n/**\n * Where npm and pnpm install Claude Code, as the segments of a path: only its\n * own package declares its release, where a package that wraps it declares\n * the wrapper's.\n */\nconst CLAUDE_CODE_PACKAGE = ['node_modules', '@anthropic-ai', 'claude-code'];\n\n/** The file `name` names on `PATH` as the environment gives it, or `null`. */\nexport function onPath(name: string, env: Readonly<Record<string, string | undefined>>, platform: NodeJS.Platform = process.platform): string | null {\n // With neither, any text names directories no test can have made; and an\n // empty entry is passed over rather than read as the working directory,\n // which a test cannot fill: both mutants are equivalent in the suite.\n const path = env['PATH'] ?? env['Path'] ?? '';\n const windows = platform === 'win32';\n const extensions = windows\n ? (env['PATHEXT'] ?? WINDOWS_EXTENSIONS.join(';')).split(';').filter((extension) => extension !== '')\n : [''];\n for (const directory of path.split(windows ? ';' : delimiter)) {\n if (directory === '') continue;\n for (const extension of extensions) {\n const file = join(directory, `${name}${extension.toLowerCase()}`);\n if (existsSync(file) && statSync(file).isFile()) return file;\n }\n }\n return null;\n}\n\n/** The directory of Claude Code's package that a shim runs, or `null` when it runs none. */\nfunction shimPackage(file: string, text: string): string | null {\n for (const match of text.matchAll(SHIM_TARGET)) {\n const parts = (match[1] as string).split('\\\\');\n const at = parts.findIndex((_, start) => CLAUDE_CODE_PACKAGE.every((part, offset) => parts[start + offset] === part));\n if (at >= 0) return join(dirname(file), ...parts.slice(0, at + CLAUDE_CODE_PACKAGE.length));\n }\n return null;\n}\n\n/**\n * The release a Windows script on `PATH` runs, as the package.json of the\n * Claude Code package it names declares it; nothing is run. A script that\n * names no such package, or one whose package.json gives no version, cannot\n * tell.\n */\nasync function shimVersion(file: string): Promise<ClaudeCodeAnswer> {\n // A shim that cannot be read names no package, as an empty one does, so\n // what stands in for its text is equivalent whatever it is.\n const directory = shimPackage(file, (await readText(file)) ?? '');\n if (directory !== null) {\n const manifest = join(directory, 'package.json');\n const version = declaredVersion(manifest);\n if (typeof version === 'string') return { declared: version, file: manifest };\n }\n return {\n missing: `claude on PATH is ${file}, a script that cannot be started without a shell, which spec-harness does not use, and it names no @anthropic-ai/claude-code package whose package.json gives a version`,\n };\n}\n\n/** `claude --version`, as the Claude Code on `PATH` answers it, or why it cannot. */\nexport async function claudeVersion(env: Readonly<Record<string, string | undefined>>, platform: NodeJS.Platform = process.platform): Promise<ClaudeCodeAnswer> {\n const file = onPath('claude', env, platform);\n if (file === null) return { missing: 'no claude is on PATH' };\n if (platform === 'win32' && !/\\.(?:exe|com)$/i.test(file)) return shimVersion(file);\n // Of the options, only `shell: false` and the encoding change an answer a\n // test can see: `windowsHide` hides a console window, and the timeout\n // stops a claude that never answers, which a test would wait on for its\n // length, so their mutants are equivalent in the suite.\n return new Promise((resolve) => {\n const failed = (error: Error): void => resolve({ missing: `${file} --version failed: ${error.message.split('\\n')[0] as string}` });\n try {\n execFile(file, ['--version'], { encoding: 'utf8', windowsHide: true, timeout: 15_000, shell: false }, (error, stdout) => {\n if (error !== null) failed(error);\n else resolve({ output: stdout });\n });\n } catch (error) {\n // Windows refuses a file that is no program before any callback, as\n // spawn UNKNOWN, where Linux reports it to the callback: doctor says\n // so rather than stop. The sweep runs on Linux, so this line is the\n // Windows job's to hold.\n failed(error as Error);\n }\n });\n}\n"]}
package/dist/index.d.ts CHANGED
@@ -4,8 +4,8 @@
4
4
  */
5
5
  export { main, run, EXIT_ERROR, EXIT_FAILED, EXIT_OK, UsageError, version } from './cli.js';
6
6
  export type { CliIO } from './cli.js';
7
- export { audit } from './audit.js';
8
- export type { AssertionOutcome, AuditInput, AuditReport } from './audit.js';
7
+ export { audit, describeMeasured } from './audit.js';
8
+ export type { AssertionOutcome, AuditInput, AuditReport, Measured, UnreadableAssertion } from './audit.js';
9
9
  export { briefIdFromBranch, idFromBranch, sameId, templateError } from './branch.js';
10
10
  export { findActive, parseBriefList, SiblingOutputError, SUPPORTED_SCHEMA_VERSIONS } from './briefs.js';
11
11
  export type { ActiveBrief, ActiveSource } from './briefs.js';
@@ -13,6 +13,8 @@ export { ConfigError, CONFIG_FILE, DEFAULT_CONFIG, parseConfig, SIBLINGS } from
13
13
  export type { HarnessConfig, OutOfScope, SiblingName } from './config.js';
14
14
  export { renderContext } from './context.js';
15
15
  export type { CitedDocument, ContextInput, ContextPacket, RuleInForce, RulingInForce, UnreadablePattern, UnreadableRulingPath } from './context.js';
16
+ export { formatFindings, formatGithub, formatGitlab, formatSarif } from './formats.js';
17
+ export type { FindingFormat, FormatOptions } from './formats.js';
16
18
  export { decide } from './guard.js';
17
19
  export type { Decision, GuardInput, Reason, Verdict, VerifiedRuling } from './guard.js';
18
20
  export { claudeResponse, gitResponse, parseClaudeHook, WRITING_TOOLS } from './hooks.js';
package/dist/index.js CHANGED
@@ -3,11 +3,12 @@
3
3
  * another kind - a CI job, an orchestrator - can ask the same questions.
4
4
  */
5
5
  export { main, run, EXIT_ERROR, EXIT_FAILED, EXIT_OK, UsageError, version } from './cli.js';
6
- export { audit } from './audit.js';
6
+ export { audit, describeMeasured } from './audit.js';
7
7
  export { briefIdFromBranch, idFromBranch, sameId, templateError } from './branch.js';
8
8
  export { findActive, parseBriefList, SiblingOutputError, SUPPORTED_SCHEMA_VERSIONS } from './briefs.js';
9
9
  export { ConfigError, CONFIG_FILE, DEFAULT_CONFIG, parseConfig, SIBLINGS } from './config.js';
10
10
  export { renderContext } from './context.js';
11
+ export { formatFindings, formatGithub, formatGitlab, formatSarif } from './formats.js';
11
12
  export { decide } from './guard.js';
12
13
  export { claudeResponse, gitResponse, parseClaudeHook, WRITING_TOOLS } from './hooks.js';
13
14
  export { readJUnit } from './junit.js';
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,UAAU,EAAE,WAAW,EAAE,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAG5F,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAEnC,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACrF,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,kBAAkB,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAC;AAExG,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,cAAc,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE9F,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAE7C,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAEpC,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEzF,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEvC,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,eAAe,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAE7G,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAE7E,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEjG,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,YAAY,EAAE,eAAe,EAAE,YAAY,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC1H,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,mBAAmB,EAAE,QAAQ,EAAE,cAAc,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC","sourcesContent":["/**\n * Programmatic API. The command line is a thin shell over these; a harness of\n * another kind - a CI job, an orchestrator - can ask the same questions.\n */\n\nexport { main, run, EXIT_ERROR, EXIT_FAILED, EXIT_OK, UsageError, version } from './cli.js';\nexport type { CliIO } from './cli.js';\n\nexport { audit } from './audit.js';\nexport type { AssertionOutcome, AuditInput, AuditReport } from './audit.js';\nexport { briefIdFromBranch, idFromBranch, sameId, templateError } from './branch.js';\nexport { findActive, parseBriefList, SiblingOutputError, SUPPORTED_SCHEMA_VERSIONS } from './briefs.js';\nexport type { ActiveBrief, ActiveSource } from './briefs.js';\nexport { ConfigError, CONFIG_FILE, DEFAULT_CONFIG, parseConfig, SIBLINGS } from './config.js';\nexport type { HarnessConfig, OutOfScope, SiblingName } from './config.js';\nexport { renderContext } from './context.js';\nexport type { CitedDocument, ContextInput, ContextPacket, RuleInForce, RulingInForce, UnreadablePattern, UnreadableRulingPath } from './context.js';\nexport { decide } from './guard.js';\nexport type { Decision, GuardInput, Reason, Verdict, VerifiedRuling } from './guard.js';\nexport { claudeResponse, gitResponse, parseClaudeHook, WRITING_TOOLS } from './hooks.js';\nexport type { HookRequest, HookResponse } from './hooks.js';\nexport { readJUnit } from './junit.js';\nexport type { JUnitCase, JUnitRead } from './junit.js';\nexport { diffManifest, ecosystemOf, manifestMatcher, readManifest, readManifestNames } from './manifests.js';\nexport type { Dependency, DependencyChange, Ecosystem, ManifestNames } from './manifests.js';\nexport { classify, readProbes, renderEvidence, verdictOf } from './probe.js';\nexport type { Classified, CodeBlock, ProbeFile, ProbeResult, ProbeRun, ProbeSet, ProbeSpec } from './probe.js';\nexport { createReader } from './reader.js';\nexport { addRulingRow, nextId, pathsOf, readRulings, renderMemo, renderRow } from './rulings.js';\nexport type { EscalationOption, EscalationRequest, RulingRow, TableView } from './rulings.js';\nexport { buildContext, checkPaths, checkRulings, raiseEscalation, recordRuling, resolveBase, runAudit } from './round.js';\nexport { GUARD_HOOK, mcpServer, mergeClaudeSettings, mergeMcp, mergeSpecGraph, PROJECT_DIR, PROJECT_DIR_OR_HERE } from './configure.js';\nexport type { BriefRow, FileChange, Finding, Severity } from './types.js';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,UAAU,EAAE,WAAW,EAAE,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAG5F,OAAO,EAAE,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAErD,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACrF,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,kBAAkB,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAC;AAExG,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,cAAc,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE9F,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAE7C,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAEvF,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAEpC,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEzF,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEvC,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,eAAe,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAE7G,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAE7E,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEjG,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,YAAY,EAAE,eAAe,EAAE,YAAY,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC1H,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,mBAAmB,EAAE,QAAQ,EAAE,cAAc,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC","sourcesContent":["/**\n * Programmatic API. The command line is a thin shell over these; a harness of\n * another kind - a CI job, an orchestrator - can ask the same questions.\n */\n\nexport { main, run, EXIT_ERROR, EXIT_FAILED, EXIT_OK, UsageError, version } from './cli.js';\nexport type { CliIO } from './cli.js';\n\nexport { audit, describeMeasured } from './audit.js';\nexport type { AssertionOutcome, AuditInput, AuditReport, Measured, UnreadableAssertion } from './audit.js';\nexport { briefIdFromBranch, idFromBranch, sameId, templateError } from './branch.js';\nexport { findActive, parseBriefList, SiblingOutputError, SUPPORTED_SCHEMA_VERSIONS } from './briefs.js';\nexport type { ActiveBrief, ActiveSource } from './briefs.js';\nexport { ConfigError, CONFIG_FILE, DEFAULT_CONFIG, parseConfig, SIBLINGS } from './config.js';\nexport type { HarnessConfig, OutOfScope, SiblingName } from './config.js';\nexport { renderContext } from './context.js';\nexport type { CitedDocument, ContextInput, ContextPacket, RuleInForce, RulingInForce, UnreadablePattern, UnreadableRulingPath } from './context.js';\nexport { formatFindings, formatGithub, formatGitlab, formatSarif } from './formats.js';\nexport type { FindingFormat, FormatOptions } from './formats.js';\nexport { decide } from './guard.js';\nexport type { Decision, GuardInput, Reason, Verdict, VerifiedRuling } from './guard.js';\nexport { claudeResponse, gitResponse, parseClaudeHook, WRITING_TOOLS } from './hooks.js';\nexport type { HookRequest, HookResponse } from './hooks.js';\nexport { readJUnit } from './junit.js';\nexport type { JUnitCase, JUnitRead } from './junit.js';\nexport { diffManifest, ecosystemOf, manifestMatcher, readManifest, readManifestNames } from './manifests.js';\nexport type { Dependency, DependencyChange, Ecosystem, ManifestNames } from './manifests.js';\nexport { classify, readProbes, renderEvidence, verdictOf } from './probe.js';\nexport type { Classified, CodeBlock, ProbeFile, ProbeResult, ProbeRun, ProbeSet, ProbeSpec } from './probe.js';\nexport { createReader } from './reader.js';\nexport { addRulingRow, nextId, pathsOf, readRulings, renderMemo, renderRow } from './rulings.js';\nexport type { EscalationOption, EscalationRequest, RulingRow, TableView } from './rulings.js';\nexport { buildContext, checkPaths, checkRulings, raiseEscalation, recordRuling, resolveBase, runAudit } from './round.js';\nexport { GUARD_HOOK, mcpServer, mergeClaudeSettings, mergeMcp, mergeSpecGraph, PROJECT_DIR, PROJECT_DIR_OR_HERE } from './configure.js';\nexport type { BriefRow, FileChange, Finding, Severity } from './types.js';\n"]}
@@ -43,11 +43,18 @@ export interface ManifestNames {
43
43
  readonly name: string;
44
44
  readonly reason: string;
45
45
  }[];
46
+ /** The names a leading `/` roots, alone or on a brace alternative, and whether every alternative is. */
47
+ readonly rooted: readonly {
48
+ readonly name: string;
49
+ readonly whole: boolean;
50
+ }[];
46
51
  }
47
52
  /**
48
53
  * The configured manifest names, read. A name that cannot be read names no
49
54
  * manifest, and is returned so the audit can say so: every file it was
50
- * meant to name would otherwise go unmeasured in silence.
55
+ * meant to name would otherwise go unmeasured in silence. So is a name a
56
+ * leading `/` roots at the filesystem's root: it can be read, and names no
57
+ * path the audit is given, all of which are repository-relative.
51
58
  */
52
59
  export declare function readManifestNames(patterns: readonly string[]): ManifestNames;
53
60
  /** A predicate over paths for the configured manifest names, matched at any depth. */
package/dist/manifests.js CHANGED
@@ -9,7 +9,7 @@
9
9
  * network. A manifest it cannot read is reported as unread, never as clean,
10
10
  * and so is a configured name it cannot read.
11
11
  */
12
- import { parseGlob } from './vendor/spec-core/pattern/index.js';
12
+ import { globAlternatives, parseGlob } from './vendor/spec-core/pattern/index.js';
13
13
  /** The ecosystem a manifest file name belongs to, or `null`. */
14
14
  export function ecosystemOf(path) {
15
15
  const name = path.slice(path.lastIndexOf('/') + 1);
@@ -32,19 +32,29 @@ export function ecosystemOf(path) {
32
32
  /**
33
33
  * The configured manifest names, read. A name that cannot be read names no
34
34
  * manifest, and is returned so the audit can say so: every file it was
35
- * meant to name would otherwise go unmeasured in silence.
35
+ * meant to name would otherwise go unmeasured in silence. So is a name a
36
+ * leading `/` roots at the filesystem's root: it can be read, and names no
37
+ * path the audit is given, all of which are repository-relative.
36
38
  */
37
39
  export function readManifestNames(patterns) {
38
40
  const globs = [];
39
41
  const unread = [];
42
+ const rooted = [];
40
43
  for (const pattern of patterns) {
41
44
  const parsed = parseGlob(pattern, { dialect: 'ripgrep', caseSensitive: true });
42
- if (parsed.ok)
43
- globs.push(parsed.glob);
44
- else
45
+ if (!parsed.ok) {
45
46
  unread.push({ name: pattern, reason: parsed.error });
47
+ continue;
48
+ }
49
+ globs.push(parsed.glob);
50
+ // spec-core refuses here only what parseGlob refuses, so a name read
51
+ // above always has its alternatives read.
52
+ const { alternatives } = globAlternatives(pattern);
53
+ const roots = alternatives.filter((alternative) => alternative.rooted).length;
54
+ if (roots > 0)
55
+ rooted.push({ name: pattern, whole: roots === alternatives.length });
46
56
  }
47
- return { match: (path) => globs.some((glob) => glob.match(path)), unread };
57
+ return { match: (path) => globs.some((glob) => glob.match(path)), unread, rooted };
48
58
  }
49
59
  /** A predicate over paths for the configured manifest names, matched at any depth. */
50
60
  export function manifestMatcher(patterns) {
@@ -1 +1 @@
1
- {"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,EAAE,OAAO,EAAE,UAAU,CAAC,OAAO,EAAE,IAAI,EAAE,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,IAAI,IAAI,EAAE,KAAK,EAAE,UAAU,CAAC,OAAO,EAAE,CAAC,CAAC;QACtJ,CAAC;IACH,CAAC;IACD,KAAK,MAAM,CAAC,EAAE,EAAE,UAAU,CAAC,IAAI,GAAG,EAAE,CAAC;QACnC,IAAI,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC;YAAE,OAAO,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,UAAU,CAAC,OAAO,EAAE,IAAI,EAAE,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,CAAC,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;IAClJ,CAAC;IACD,OAAO,EAAE,OAAO,EAAE,CAAC;AACrB,CAAC","sourcesContent":["/**\n * Which dependencies a round added, removed or moved, read from the manifests\n * it changed.\n *\n * \"No new dependency without saying so\" is one of the few audit questions\n * that can be answered exactly, and it matters: a dependency is code nobody in\n * the review read. Each reader here understands the part of its format that\n * declares dependencies and nothing more - no resolver, no lockfile, no\n * network. A manifest it cannot read is reported as unread, never as clean,\n * and so is a configured name it cannot read.\n */\n\nimport { parseGlob, type Glob } from './vendor/spec-core/pattern/index.js';\n\nexport type Ecosystem = 'npm' | 'cargo' | 'go' | 'pip' | 'python' | 'nuget' | 'bundler';\n\nexport interface Dependency {\n readonly section: string;\n readonly name: string;\n /** The version or requirement as written; `''` when none is. */\n readonly version: string;\n}\n\nexport interface DependencyChange {\n readonly file: string;\n readonly ecosystem: Ecosystem;\n readonly section: string;\n readonly name: string;\n /** `null` when the dependency is new. */\n readonly before: string | null;\n /** `null` when the dependency was removed. */\n readonly after: string | null;\n}\n\nexport type ManifestRead = { readonly ok: true; readonly dependencies: readonly Dependency[] } | { readonly ok: false; readonly error: string };\n\n/** The ecosystem a manifest file name belongs to, or `null`. */\nexport function ecosystemOf(path: string): Ecosystem | null {\n const name = path.slice(path.lastIndexOf('/') + 1);\n if (name === 'package.json') return 'npm';\n if (name === 'Cargo.toml') return 'cargo';\n if (name === 'go.mod') return 'go';\n if (name === 'pyproject.toml') return 'python';\n if (/^requirements.*\\.txt$/.test(name)) return 'pip';\n if (name === 'Directory.Packages.props' || /\\.(?:cs|fs|vb)proj$/.test(name)) return 'nuget';\n if (name === 'Gemfile') return 'bundler';\n return null;\n}\n\nexport interface ManifestNames {\n /** Whether a path is a manifest by one of the names that could be read, matched at any depth. */\n readonly match: (path: string) => boolean;\n /** The names spec-core's glob refused, malformed or too large to compile, each with its reason. */\n readonly unread: readonly { readonly name: string; readonly reason: string }[];\n}\n\n/**\n * The configured manifest names, read. A name that cannot be read names no\n * manifest, and is returned so the audit can say so: every file it was\n * meant to name would otherwise go unmeasured in silence.\n */\nexport function readManifestNames(patterns: readonly string[]): ManifestNames {\n const globs: Glob[] = [];\n const unread: { name: string; reason: string }[] = [];\n for (const pattern of patterns) {\n const parsed = parseGlob(pattern, { dialect: 'ripgrep', caseSensitive: true });\n if (parsed.ok) globs.push(parsed.glob);\n else unread.push({ name: pattern, reason: parsed.error });\n }\n return { match: (path) => globs.some((glob) => glob.match(path)), unread };\n}\n\n/** A predicate over paths for the configured manifest names, matched at any depth. */\nexport function manifestMatcher(patterns: readonly string[]): (path: string) => boolean {\n return readManifestNames(patterns).match;\n}\n\n/* --------------------------------------------------------------------- npm */\n\nconst NPM_SECTIONS = ['dependencies', 'devDependencies', 'optionalDependencies', 'peerDependencies'];\n\nfunction readNpm(text: string): ManifestRead {\n let value: unknown;\n try {\n value = JSON.parse(text);\n } catch {\n return { ok: false, error: 'not valid JSON' };\n }\n if (typeof value !== 'object' || value === null || Array.isArray(value)) return { ok: false, error: 'not a JSON object' };\n const out: Dependency[] = [];\n for (const section of NPM_SECTIONS) {\n const table = (value as Record<string, unknown>)[section];\n if (table === undefined) continue;\n if (typeof table !== 'object' || table === null || Array.isArray(table)) return { ok: false, error: `\"${section}\" is not an object` };\n for (const [name, version] of Object.entries(table)) out.push({ section, name, version: String(version) });\n }\n return { ok: true, dependencies: out };\n}\n\n/* -------------------------------------------------------------------- TOML */\n\n/** A TOML value on one line, or the start of a multi-line array. Comments and quotes read the way TOML reads them. */\nfunction stripTomlComment(line: string): string {\n let quote: string | null = null;\n for (let i = 0; i < line.length; i += 1) {\n const ch = line.charAt(i);\n if (quote !== null) {\n if (ch === '\\\\' && quote === '\"') i += 1;\n else if (ch === quote) quote = null;\n } else if (ch === '\"' || ch === \"'\") {\n quote = ch;\n } else if (ch === '#') {\n return line.slice(0, i);\n }\n }\n return line;\n}\n\nfunction unquote(value: string): string {\n const trimmed = value.trim();\n if (trimmed.length >= 2 && (trimmed.startsWith('\"') || trimmed.startsWith(\"'\")) && trimmed.endsWith(trimmed.charAt(0))) {\n return trimmed.slice(1, -1);\n }\n return trimmed;\n}\n\n/**\n * The strings of a TOML array, `[\"a>=1\", 'b']`, possibly spread over lines.\n * A string inside an inline table is a value of that table, not an element:\n * `{include-group = \"test\"}` in a dependency group names a group, not a package.\n */\nfunction tomlStrings(text: string): string[] {\n const out: string[] = [];\n let depth = 0;\n let i = 0;\n while (i < text.length) {\n const ch = text.charAt(i);\n if (ch === '{') depth += 1;\n else if (ch === '}') depth -= 1;\n if (ch === '\"' || ch === \"'\") {\n let j = i + 1;\n let value = '';\n while (j < text.length && text.charAt(j) !== ch) {\n if (text.charAt(j) === '\\\\' && ch === '\"') {\n value += text.charAt(j + 1);\n j += 2;\n continue;\n }\n value += text.charAt(j);\n j += 1;\n }\n if (depth === 0) out.push(value);\n i = j + 1;\n continue;\n }\n i += 1;\n }\n return out;\n}\n\n/** The name a PEP 508 requirement names, normalised as PEP 503 says. */\nexport function pythonName(requirement: string): string {\n const match = /^\\s*([A-Za-z0-9][A-Za-z0-9._-]*)/.exec(requirement);\n return (match?.[1] ?? requirement.trim()).toLowerCase().replace(/[-_.]+/g, '-');\n}\n\ninterface TomlLine {\n readonly table: string;\n readonly key: string;\n readonly value: string;\n}\n\n/** Top-level `key = value` lines per table header, arrays gathered across lines. Enough for dependency tables. */\nfunction tomlEntries(text: string): TomlLine[] | string {\n const out: TomlLine[] = [];\n let table = '';\n const lines = text.split(/\\r?\\n/);\n for (let i = 0; i < lines.length; i += 1) {\n const line = stripTomlComment(lines[i] as string).trim();\n if (line === '') continue;\n const header = /^\\[\\[?\\s*([^\\]]+?)\\s*\\]\\]?$/.exec(line);\n if (header !== null) {\n table = (header[1] as string).replace(/\\s*\\.\\s*/g, '.');\n continue;\n }\n const eq = line.indexOf('=');\n if (eq <= 0) continue;\n const key = unquote(line.slice(0, eq));\n let value = line.slice(eq + 1).trim();\n if (value.startsWith('[') && !balanced(value)) {\n while (i + 1 < lines.length && !balanced(value)) {\n i += 1;\n value += ` ${stripTomlComment(lines[i] as string).trim()}`;\n }\n if (!balanced(value)) return `the array for \"${key}\" is never closed`;\n }\n out.push({ table, key, value });\n }\n return out;\n}\n\nfunction balanced(value: string): boolean {\n let depth = 0;\n let quote: string | null = null;\n for (let i = 0; i < value.length; i += 1) {\n const ch = value.charAt(i);\n if (quote !== null) {\n if (ch === '\\\\' && quote === '\"') i += 1;\n else if (ch === quote) quote = null;\n } else if (ch === '\"' || ch === \"'\") quote = ch;\n else if (ch === '[') depth += 1;\n else if (ch === ']') depth -= 1;\n }\n return depth <= 0 && quote === null;\n}\n\nconst CARGO_TABLE = /^(?:target\\..+\\.)?((?:workspace\\.)?(?:dev-|build-)?dependencies)(?:\\.(.+))?$/;\n\nfunction readCargo(text: string): ManifestRead {\n const entries = tomlEntries(text);\n if (typeof entries === 'string') return { ok: false, error: entries };\n const out = new Map<string, Dependency>();\n for (const { table, key, value } of entries) {\n const match = CARGO_TABLE.exec(table);\n if (match === null) continue;\n const section = match[1] as string;\n const inline = match[2];\n if (inline !== undefined) {\n // [dependencies.serde] then `version = \"1\"`: the table names the crate.\n const name = unquote(inline);\n const id = `${section}\\u0000${name}`;\n const current = out.get(id) ?? { section, name, version: '' };\n out.set(id, key === 'version' ? { ...current, version: unquote(value) } : current);\n continue;\n }\n const version = value.startsWith('{') ? (/version\\s*=\\s*(\"[^\"]*\"|'[^']*')/.exec(value)?.[1] ?? '') : value;\n out.set(`${section}\\u0000${key}`, { section, name: key, version: unquote(version) });\n }\n return { ok: true, dependencies: [...out.values()] };\n}\n\nfunction readPyproject(text: string): ManifestRead {\n const entries = tomlEntries(text);\n if (typeof entries === 'string') return { ok: false, error: entries };\n const out: Dependency[] = [];\n for (const { table, key, value } of entries) {\n if (table === 'project' && key === 'dependencies') {\n for (const requirement of tomlStrings(value)) out.push({ section: 'project', name: pythonName(requirement), version: requirement });\n } else if (table === 'project.optional-dependencies' || table === 'dependency-groups') {\n for (const requirement of tomlStrings(value)) out.push({ section: `${table}.${key}`, name: pythonName(requirement), version: requirement });\n } else if (/^tool\\.poetry\\.(?:group\\.[^.]+\\.)?(?:dev-)?dependencies$/.test(table) && key.toLowerCase() !== 'python') {\n out.push({ section: table, name: pythonName(key), version: unquote(value) });\n }\n }\n return { ok: true, dependencies: out };\n}\n\n/* ------------------------------------------------------------ line formats */\n\nfunction readGoMod(text: string): ManifestRead {\n const out: Dependency[] = [];\n let block = false;\n for (const raw of text.split(/\\r?\\n/)) {\n const indirect = /\\/\\/\\s*indirect\\b/.test(raw);\n const line = raw.replace(/\\/\\/.*$/, '').trim();\n if (line === '') continue;\n if (block) {\n if (line === ')') {\n block = false;\n continue;\n }\n const [name, version] = line.split(/\\s+/);\n if (name !== undefined) out.push({ section: indirect ? 'require (indirect)' : 'require', name, version: version ?? '' });\n continue;\n }\n if (/^require\\s*\\($/.test(line)) {\n block = true;\n continue;\n }\n const single = /^require\\s+(\\S+)\\s+(\\S+)/.exec(line);\n if (single !== null) out.push({ section: indirect ? 'require (indirect)' : 'require', name: single[1] as string, version: single[2] as string });\n }\n if (block) return { ok: false, error: 'a require block is never closed' };\n return { ok: true, dependencies: out };\n}\n\nfunction readRequirements(text: string): ManifestRead {\n const out: Dependency[] = [];\n for (const raw of text.split(/\\r?\\n/)) {\n const line = raw.replace(/(^|\\s)#.*$/, '').trim();\n if (line === '' || line.startsWith('-')) continue;\n out.push({ section: 'requirements', name: pythonName(line), version: line });\n }\n return { ok: true, dependencies: out };\n}\n\nfunction readNuget(text: string): ManifestRead {\n const out: Dependency[] = [];\n const element = /<(PackageReference|PackageVersion)\\b([^>]*?)\\/?>/g;\n for (let match = element.exec(text); match !== null; match = element.exec(text)) {\n const attributes = match[2] as string;\n const name = /\\bInclude\\s*=\\s*\"([^\"]*)\"/.exec(attributes)?.[1] ?? /\\bUpdate\\s*=\\s*\"([^\"]*)\"/.exec(attributes)?.[1];\n if (name === undefined) continue;\n const version = /\\bVersion\\s*=\\s*\"([^\"]*)\"/.exec(attributes)?.[1] ?? '';\n out.push({ section: match[1] as string, name, version });\n }\n return { ok: true, dependencies: out };\n}\n\nfunction readGemfile(text: string): ManifestRead {\n const out: Dependency[] = [];\n for (const raw of text.split(/\\r?\\n/)) {\n const match = /^\\s*gem\\s+([\"'])([^\"']+)\\1\\s*(?:,\\s*([\"'])([^\"']*)\\3)?/.exec(raw);\n if (match !== null) out.push({ section: 'gem', name: match[2] as string, version: match[4] ?? '' });\n }\n return { ok: true, dependencies: out };\n}\n\n/** Reads the dependencies a manifest declares. */\nexport function readManifest(ecosystem: Ecosystem, text: string): ManifestRead {\n switch (ecosystem) {\n case 'npm':\n return readNpm(text);\n case 'cargo':\n return readCargo(text);\n case 'go':\n return readGoMod(text);\n case 'python':\n return readPyproject(text);\n case 'pip':\n return readRequirements(text);\n case 'nuget':\n return readNuget(text);\n case 'bundler':\n return readGemfile(text);\n }\n}\n\n/**\n * What changed between two versions of one manifest. `null` text is a file\n * that does not exist on that side. Returns the error instead when either\n * side cannot be read.\n */\nexport function diffManifest(\n file: string,\n ecosystem: Ecosystem,\n before: string | null,\n after: string | null,\n): { readonly changes: readonly DependencyChange[] } | { readonly error: string } {\n const read = (text: string | null, side: string): readonly Dependency[] | string => {\n if (text === null) return [];\n const result = readManifest(ecosystem, text);\n return result.ok ? result.dependencies : `${file} (${side}): ${result.error}`;\n };\n const old = read(before, 'before');\n if (typeof old === 'string') return { error: old };\n const now = read(after, 'after');\n if (typeof now === 'string') return { error: now };\n const key = (d: Dependency): string => `${d.section}\\u0000${d.name}`;\n const was = new Map(old.map((d) => [key(d), d]));\n const is = new Map(now.map((d) => [key(d), d]));\n const changes: DependencyChange[] = [];\n for (const [id, dependency] of is) {\n const previous = was.get(id);\n if (previous === undefined || previous.version !== dependency.version) {\n changes.push({ file, ecosystem, section: dependency.section, name: dependency.name, before: previous?.version ?? null, after: dependency.version });\n }\n }\n for (const [id, dependency] of was) {\n if (!is.has(id)) changes.push({ file, ecosystem, section: dependency.section, name: dependency.name, before: dependency.version, after: null });\n }\n return { changes };\n}\n"]}
1
+ {"version":3,"file":"manifests.js","sourceRoot":"","sources":["../src/manifests.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAmC,MAAM,qCAAqC,CAAC;AAwBnH,gEAAgE;AAChE,MAAM,UAAU,WAAW,CAAC,IAAY;IACtC,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;IACnD,IAAI,IAAI,KAAK,cAAc;QAAE,OAAO,KAAK,CAAC;IAC1C,IAAI,IAAI,KAAK,YAAY;QAAE,OAAO,OAAO,CAAC;IAC1C,IAAI,IAAI,KAAK,QAAQ;QAAE,OAAO,IAAI,CAAC;IACnC,IAAI,IAAI,KAAK,gBAAgB;QAAE,OAAO,QAAQ,CAAC;IAC/C,IAAI,uBAAuB,CAAC,IAAI,CAAC,IAAI,CAAC;QAAE,OAAO,KAAK,CAAC;IACrD,IAAI,IAAI,KAAK,0BAA0B,IAAI,qBAAqB,CAAC,IAAI,CAAC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AAC;IACD,KAAK,MAAM,CAAC,EAAE,EAAE,UAAU,CAAC,IAAI,GAAG,EAAE,CAAC;QACnC,IAAI,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC;YAAE,OAAO,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,UAAU,CAAC,OAAO,EAAE,IAAI,EAAE,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,CAAC,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;IAClJ,CAAC;IACD,OAAO,EAAE,OAAO,EAAE,CAAC;AACrB,CAAC","sourcesContent":["/**\n * Which dependencies a round added, removed or moved, read from the manifests\n * it changed.\n *\n * \"No new dependency without saying so\" is one of the few audit questions\n * that can be answered exactly, and it matters: a dependency is code nobody in\n * the review read. Each reader here understands the part of its format that\n * declares dependencies and nothing more - no resolver, no lockfile, no\n * network. A manifest it cannot read is reported as unread, never as clean,\n * and so is a configured name it cannot read.\n */\n\nimport { globAlternatives, parseGlob, type Glob, type GlobAlternative } from './vendor/spec-core/pattern/index.js';\n\nexport type Ecosystem = 'npm' | 'cargo' | 'go' | 'pip' | 'python' | 'nuget' | 'bundler';\n\nexport interface Dependency {\n readonly section: string;\n readonly name: string;\n /** The version or requirement as written; `''` when none is. */\n readonly version: string;\n}\n\nexport interface DependencyChange {\n readonly file: string;\n readonly ecosystem: Ecosystem;\n readonly section: string;\n readonly name: string;\n /** `null` when the dependency is new. */\n readonly before: string | null;\n /** `null` when the dependency was removed. */\n readonly after: string | null;\n}\n\nexport type ManifestRead = { readonly ok: true; readonly dependencies: readonly Dependency[] } | { readonly ok: false; readonly error: string };\n\n/** The ecosystem a manifest file name belongs to, or `null`. */\nexport function ecosystemOf(path: string): Ecosystem | null {\n const name = path.slice(path.lastIndexOf('/') + 1);\n if (name === 'package.json') return 'npm';\n if (name === 'Cargo.toml') return 'cargo';\n if (name === 'go.mod') return 'go';\n if (name === 'pyproject.toml') return 'python';\n if (/^requirements.*\\.txt$/.test(name)) return 'pip';\n if (name === 'Directory.Packages.props' || /\\.(?:cs|fs|vb)proj$/.test(name)) return 'nuget';\n if (name === 'Gemfile') return 'bundler';\n return null;\n}\n\nexport interface ManifestNames {\n /** Whether a path is a manifest by one of the names that could be read, matched at any depth. */\n readonly match: (path: string) => boolean;\n /** The names spec-core's glob refused, malformed or too large to compile, each with its reason. */\n readonly unread: readonly { readonly name: string; readonly reason: string }[];\n /** The names a leading `/` roots, alone or on a brace alternative, and whether every alternative is. */\n readonly rooted: readonly { readonly name: string; readonly whole: boolean }[];\n}\n\n/**\n * The configured manifest names, read. A name that cannot be read names no\n * manifest, and is returned so the audit can say so: every file it was\n * meant to name would otherwise go unmeasured in silence. So is a name a\n * leading `/` roots at the filesystem's root: it can be read, and names no\n * path the audit is given, all of which are repository-relative.\n */\nexport function readManifestNames(patterns: readonly string[]): ManifestNames {\n const globs: Glob[] = [];\n const unread: { name: string; reason: string }[] = [];\n const rooted: { name: string; whole: boolean }[] = [];\n for (const pattern of patterns) {\n const parsed = parseGlob(pattern, { dialect: 'ripgrep', caseSensitive: true });\n if (!parsed.ok) {\n unread.push({ name: pattern, reason: parsed.error });\n continue;\n }\n globs.push(parsed.glob);\n // spec-core refuses here only what parseGlob refuses, so a name read\n // above always has its alternatives read.\n const { alternatives } = globAlternatives(pattern) as { readonly alternatives: readonly GlobAlternative[] };\n const roots = alternatives.filter((alternative) => alternative.rooted).length;\n if (roots > 0) rooted.push({ name: pattern, whole: roots === alternatives.length });\n }\n return { match: (path) => globs.some((glob) => glob.match(path)), unread, rooted };\n}\n\n/** A predicate over paths for the configured manifest names, matched at any depth. */\nexport function manifestMatcher(patterns: readonly string[]): (path: string) => boolean {\n return readManifestNames(patterns).match;\n}\n\n/* --------------------------------------------------------------------- npm */\n\nconst NPM_SECTIONS = ['dependencies', 'devDependencies', 'optionalDependencies', 'peerDependencies'];\n\nfunction readNpm(text: string): ManifestRead {\n let value: unknown;\n try {\n value = JSON.parse(text);\n } catch {\n return { ok: false, error: 'not valid JSON' };\n }\n if (typeof value !== 'object' || value === null || Array.isArray(value)) return { ok: false, error: 'not a JSON object' };\n const out: Dependency[] = [];\n for (const section of NPM_SECTIONS) {\n const table = (value as Record<string, unknown>)[section];\n if (table === undefined) continue;\n if (typeof table !== 'object' || table === null || Array.isArray(table)) return { ok: false, error: `\"${section}\" is not an object` };\n for (const [name, version] of Object.entries(table)) out.push({ section, name, version: String(version) });\n }\n return { ok: true, dependencies: out };\n}\n\n/* -------------------------------------------------------------------- TOML */\n\n/** A TOML value on one line, or the start of a multi-line array. Comments and quotes read the way TOML reads them. */\nfunction stripTomlComment(line: string): string {\n let quote: string | null = null;\n for (let i = 0; i < line.length; i += 1) {\n const ch = line.charAt(i);\n if (quote !== null) {\n if (ch === '\\\\' && quote === '\"') i += 1;\n else if (ch === quote) quote = null;\n } else if (ch === '\"' || ch === \"'\") {\n quote = ch;\n } else if (ch === '#') {\n return line.slice(0, i);\n }\n }\n return line;\n}\n\nfunction unquote(value: string): string {\n const trimmed = value.trim();\n if (trimmed.length >= 2 && (trimmed.startsWith('\"') || trimmed.startsWith(\"'\")) && trimmed.endsWith(trimmed.charAt(0))) {\n return trimmed.slice(1, -1);\n }\n return trimmed;\n}\n\n/**\n * The strings of a TOML array, `[\"a>=1\", 'b']`, possibly spread over lines.\n * A string inside an inline table is a value of that table, not an element:\n * `{include-group = \"test\"}` in a dependency group names a group, not a package.\n */\nfunction tomlStrings(text: string): string[] {\n const out: string[] = [];\n let depth = 0;\n let i = 0;\n while (i < text.length) {\n const ch = text.charAt(i);\n if (ch === '{') depth += 1;\n else if (ch === '}') depth -= 1;\n if (ch === '\"' || ch === \"'\") {\n let j = i + 1;\n let value = '';\n while (j < text.length && text.charAt(j) !== ch) {\n if (text.charAt(j) === '\\\\' && ch === '\"') {\n value += text.charAt(j + 1);\n j += 2;\n continue;\n }\n value += text.charAt(j);\n j += 1;\n }\n if (depth === 0) out.push(value);\n i = j + 1;\n continue;\n }\n i += 1;\n }\n return out;\n}\n\n/** The name a PEP 508 requirement names, normalised as PEP 503 says. */\nexport function pythonName(requirement: string): string {\n const match = /^\\s*([A-Za-z0-9][A-Za-z0-9._-]*)/.exec(requirement);\n return (match?.[1] ?? requirement.trim()).toLowerCase().replace(/[-_.]+/g, '-');\n}\n\ninterface TomlLine {\n readonly table: string;\n readonly key: string;\n readonly value: string;\n}\n\n/** Top-level `key = value` lines per table header, arrays gathered across lines. Enough for dependency tables. */\nfunction tomlEntries(text: string): TomlLine[] | string {\n const out: TomlLine[] = [];\n let table = '';\n const lines = text.split(/\\r?\\n/);\n for (let i = 0; i < lines.length; i += 1) {\n const line = stripTomlComment(lines[i] as string).trim();\n if (line === '') continue;\n const header = /^\\[\\[?\\s*([^\\]]+?)\\s*\\]\\]?$/.exec(line);\n if (header !== null) {\n table = (header[1] as string).replace(/\\s*\\.\\s*/g, '.');\n continue;\n }\n const eq = line.indexOf('=');\n if (eq <= 0) continue;\n const key = unquote(line.slice(0, eq));\n let value = line.slice(eq + 1).trim();\n if (value.startsWith('[') && !balanced(value)) {\n while (i + 1 < lines.length && !balanced(value)) {\n i += 1;\n value += ` ${stripTomlComment(lines[i] as string).trim()}`;\n }\n if (!balanced(value)) return `the array for \"${key}\" is never closed`;\n }\n out.push({ table, key, value });\n }\n return out;\n}\n\nfunction balanced(value: string): boolean {\n let depth = 0;\n let quote: string | null = null;\n for (let i = 0; i < value.length; i += 1) {\n const ch = value.charAt(i);\n if (quote !== null) {\n if (ch === '\\\\' && quote === '\"') i += 1;\n else if (ch === quote) quote = null;\n } else if (ch === '\"' || ch === \"'\") quote = ch;\n else if (ch === '[') depth += 1;\n else if (ch === ']') depth -= 1;\n }\n return depth <= 0 && quote === null;\n}\n\nconst CARGO_TABLE = /^(?:target\\..+\\.)?((?:workspace\\.)?(?:dev-|build-)?dependencies)(?:\\.(.+))?$/;\n\nfunction readCargo(text: string): ManifestRead {\n const entries = tomlEntries(text);\n if (typeof entries === 'string') return { ok: false, error: entries };\n const out = new Map<string, Dependency>();\n for (const { table, key, value } of entries) {\n const match = CARGO_TABLE.exec(table);\n if (match === null) continue;\n const section = match[1] as string;\n const inline = match[2];\n if (inline !== undefined) {\n // [dependencies.serde] then `version = \"1\"`: the table names the crate.\n const name = unquote(inline);\n const id = `${section}\\u0000${name}`;\n const current = out.get(id) ?? { section, name, version: '' };\n out.set(id, key === 'version' ? { ...current, version: unquote(value) } : current);\n continue;\n }\n const version = value.startsWith('{') ? (/version\\s*=\\s*(\"[^\"]*\"|'[^']*')/.exec(value)?.[1] ?? '') : value;\n out.set(`${section}\\u0000${key}`, { section, name: key, version: unquote(version) });\n }\n return { ok: true, dependencies: [...out.values()] };\n}\n\nfunction readPyproject(text: string): ManifestRead {\n const entries = tomlEntries(text);\n if (typeof entries === 'string') return { ok: false, error: entries };\n const out: Dependency[] = [];\n for (const { table, key, value } of entries) {\n if (table === 'project' && key === 'dependencies') {\n for (const requirement of tomlStrings(value)) out.push({ section: 'project', name: pythonName(requirement), version: requirement });\n } else if (table === 'project.optional-dependencies' || table === 'dependency-groups') {\n for (const requirement of tomlStrings(value)) out.push({ section: `${table}.${key}`, name: pythonName(requirement), version: requirement });\n } else if (/^tool\\.poetry\\.(?:group\\.[^.]+\\.)?(?:dev-)?dependencies$/.test(table) && key.toLowerCase() !== 'python') {\n out.push({ section: table, name: pythonName(key), version: unquote(value) });\n }\n }\n return { ok: true, dependencies: out };\n}\n\n/* ------------------------------------------------------------ line formats */\n\nfunction readGoMod(text: string): ManifestRead {\n const out: Dependency[] = [];\n let block = false;\n for (const raw of text.split(/\\r?\\n/)) {\n const indirect = /\\/\\/\\s*indirect\\b/.test(raw);\n const line = raw.replace(/\\/\\/.*$/, '').trim();\n if (line === '') continue;\n if (block) {\n if (line === ')') {\n block = false;\n continue;\n }\n const [name, version] = line.split(/\\s+/);\n if (name !== undefined) out.push({ section: indirect ? 'require (indirect)' : 'require', name, version: version ?? '' });\n continue;\n }\n if (/^require\\s*\\($/.test(line)) {\n block = true;\n continue;\n }\n const single = /^require\\s+(\\S+)\\s+(\\S+)/.exec(line);\n if (single !== null) out.push({ section: indirect ? 'require (indirect)' : 'require', name: single[1] as string, version: single[2] as string });\n }\n if (block) return { ok: false, error: 'a require block is never closed' };\n return { ok: true, dependencies: out };\n}\n\nfunction readRequirements(text: string): ManifestRead {\n const out: Dependency[] = [];\n for (const raw of text.split(/\\r?\\n/)) {\n const line = raw.replace(/(^|\\s)#.*$/, '').trim();\n if (line === '' || line.startsWith('-')) continue;\n out.push({ section: 'requirements', name: pythonName(line), version: line });\n }\n return { ok: true, dependencies: out };\n}\n\nfunction readNuget(text: string): ManifestRead {\n const out: Dependency[] = [];\n const element = /<(PackageReference|PackageVersion)\\b([^>]*?)\\/?>/g;\n for (let match = element.exec(text); match !== null; match = element.exec(text)) {\n const attributes = match[2] as string;\n const name = /\\bInclude\\s*=\\s*\"([^\"]*)\"/.exec(attributes)?.[1] ?? /\\bUpdate\\s*=\\s*\"([^\"]*)\"/.exec(attributes)?.[1];\n if (name === undefined) continue;\n const version = /\\bVersion\\s*=\\s*\"([^\"]*)\"/.exec(attributes)?.[1] ?? '';\n out.push({ section: match[1] as string, name, version });\n }\n return { ok: true, dependencies: out };\n}\n\nfunction readGemfile(text: string): ManifestRead {\n const out: Dependency[] = [];\n for (const raw of text.split(/\\r?\\n/)) {\n const match = /^\\s*gem\\s+([\"'])([^\"']+)\\1\\s*(?:,\\s*([\"'])([^\"']*)\\3)?/.exec(raw);\n if (match !== null) out.push({ section: 'gem', name: match[2] as string, version: match[4] ?? '' });\n }\n return { ok: true, dependencies: out };\n}\n\n/** Reads the dependencies a manifest declares. */\nexport function readManifest(ecosystem: Ecosystem, text: string): ManifestRead {\n switch (ecosystem) {\n case 'npm':\n return readNpm(text);\n case 'cargo':\n return readCargo(text);\n case 'go':\n return readGoMod(text);\n case 'python':\n return readPyproject(text);\n case 'pip':\n return readRequirements(text);\n case 'nuget':\n return readNuget(text);\n case 'bundler':\n return readGemfile(text);\n }\n}\n\n/**\n * What changed between two versions of one manifest. `null` text is a file\n * that does not exist on that side. Returns the error instead when either\n * side cannot be read.\n */\nexport function diffManifest(\n file: string,\n ecosystem: Ecosystem,\n before: string | null,\n after: string | null,\n): { readonly changes: readonly DependencyChange[] } | { readonly error: string } {\n const read = (text: string | null, side: string): readonly Dependency[] | string => {\n if (text === null) return [];\n const result = readManifest(ecosystem, text);\n return result.ok ? result.dependencies : `${file} (${side}): ${result.error}`;\n };\n const old = read(before, 'before');\n if (typeof old === 'string') return { error: old };\n const now = read(after, 'after');\n if (typeof now === 'string') return { error: now };\n const key = (d: Dependency): string => `${d.section}\\u0000${d.name}`;\n const was = new Map(old.map((d) => [key(d), d]));\n const is = new Map(now.map((d) => [key(d), d]));\n const changes: DependencyChange[] = [];\n for (const [id, dependency] of is) {\n const previous = was.get(id);\n if (previous === undefined || previous.version !== dependency.version) {\n changes.push({ file, ecosystem, section: dependency.section, name: dependency.name, before: previous?.version ?? null, after: dependency.version });\n }\n }\n for (const [id, dependency] of was) {\n if (!is.has(id)) changes.push({ file, ecosystem, section: dependency.section, name: dependency.name, before: dependency.version, after: null });\n }\n return { changes };\n}\n"]}
@@ -15,6 +15,9 @@
15
15
  * one the flag, SPEC_BRIEF or the branch names - is reported as the audit
16
16
  * reports it, retired as the round intends, and fails nothing: on the round's
17
17
  * branch, a premise that no longer holds is the work being done.
18
+ *
19
+ * A premise spec-guard cannot read is checked by nothing, and is a warning,
20
+ * as it is in the audit: `--strict` fails the run on it.
18
21
  */
19
22
  import { type CliIO, type Options } from './workspace.js';
20
23
  export declare function premisesCommand(options: Options, io: CliIO): Promise<number>;