codebase-snapshot 0.20.8 → 0.20.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { O as OutputFormat, P as PromptTask, D as DiscoveryMode, C as CliOptions, R as ResolvedSnapshotConfig } from './types-CykWdR6V.cjs';
1
+ import { O as OutputFormat, P as PromptTask, D as DiscoveryMode, C as CliOptions, R as ResolvedSnapshotConfig } from './types-C5ytHMYz.cjs';
2
2
 
3
3
  /**
4
4
  * The machine-readable description of this tool.
@@ -53,7 +53,7 @@ interface AgentContract {
53
53
  * magnitude.
54
54
  */
55
55
  type: "string" | "boolean" | "number";
56
- default?: string | number | boolean;
56
+ default?: string | number | boolean | null;
57
57
  appliesTo: string;
58
58
  summary: string;
59
59
  }>;
package/dist/cli.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { O as OutputFormat, P as PromptTask, D as DiscoveryMode, C as CliOptions, R as ResolvedSnapshotConfig } from './types-CykWdR6V.js';
1
+ import { O as OutputFormat, P as PromptTask, D as DiscoveryMode, C as CliOptions, R as ResolvedSnapshotConfig } from './types-C5ytHMYz.js';
2
2
 
3
3
  /**
4
4
  * The machine-readable description of this tool.
@@ -53,7 +53,7 @@ interface AgentContract {
53
53
  * magnitude.
54
54
  */
55
55
  type: "string" | "boolean" | "number";
56
- default?: string | number | boolean;
56
+ default?: string | number | boolean | null;
57
57
  appliesTo: string;
58
58
  summary: string;
59
59
  }>;
package/dist/cli.js CHANGED
@@ -1,6 +1,6 @@
1
- import { startHttpTransport } from './chunk-STWEFBES.js';
2
- import { shouldCheck, checkForUpdate, GENERATOR_VERSION, cacheFilePath, formatUpdateNotice, installKind, buildAgentContract, startWebServer, buildTools, runStdioServer, parseRemoteSource, assertPublicHost, cloneRepository, makeCloneDirectory, loadConfigFileDetailed, resolveConfig, validateSnapshot, auditSnapshot, describeManifestShapeProblem, explainPath, compareManifests, loadManifest, renderDiffText, generateSnapshot, getGitInfo, loadSigningKey, SIGNATURE_FILE, formatNumber, isDiscoveryMode, ARTIFACT_NAMES, COMMAND_OPTION_SCOPE, commandsForOption, getPreset, unknownPresetMessage, GENERATOR_NAME, runInit, installPreCommitHook, PromptCancelled, SKILL_NAME, renderSkill, resolveLatest, isNewer, updateCommand, findConfigFile, planFirstRun, isEffectivelyEmpty, isInteractive, defaultIO, hasPriorSnapshot, DEFAULT_ANSWERS, firstRunMessage, stripJsonComments, parseByteSize, gitignorePath, appendGitignoreEntries, escapeControls, runWithStdoutCapture, MIN_MAX_PART_TOKENS, MIN_MAX_PART_BYTES, renderContractText, renderExplainText } from './chunk-RVWDPCJ6.js';
3
- export { buildAgentContract } from './chunk-RVWDPCJ6.js';
1
+ import './chunk-WMEZFLUT.js';
2
+ import { shouldCheck, checkForUpdate, GENERATOR_VERSION, cacheFilePath, formatUpdateNotice, installKind, buildAgentContract, startWebServer, startHttpTransport, buildTools, runStdioServer, parseRemoteSource, assertPublicHost, cloneRepository, makeCloneDirectory, loadConfigFileDetailed, resolveConfig, validateSnapshot, readConfinedText, auditSnapshot, describeManifestShapeProblem, explainPath, compareManifests, loadManifest, renderDiffText, generateSnapshot, getGitInfo, loadSigningKey, SIGNATURE_FILE, formatNumber, isDiscoveryMode, ARTIFACT_NAMES, COMMAND_OPTION_SCOPE, commandsForOption, getPreset, unknownPresetMessage, GENERATOR_NAME, runInit, installPreCommitHook, PromptCancelled, SKILL_NAME, renderSkill, resolveLatest, isNewer, updateCommand, findConfigFile, planFirstRun, isEffectivelyEmpty, isInteractive, defaultIO, hasPriorSnapshot, DEFAULT_ANSWERS, firstRunMessage, stripJsonComments, parseByteSize, gitignorePath, appendGitignoreEntries, escapeControls, runWithStdoutCapture, MIN_MAX_PART_TOKENS, MIN_MAX_PART_BYTES, renderContractText, renderExplainText } from './chunk-TUKY6KLH.js';
3
+ export { buildAgentContract } from './chunk-TUKY6KLH.js';
4
4
  import { spawnSync } from 'child_process';
5
5
  import * as fs2 from 'fs';
6
6
  import * as path2 from 'path';
@@ -260,8 +260,8 @@ Options:
260
260
  bar, calibration); merged at fixed slots
261
261
  --prompt-task <task> audit | review | explain - which job the brief is for
262
262
  --skip-artifacts <names> Comma-separated artifacts to omit
263
- (readme, manifest, parts, navigation,
264
- projectTree, audit, monolith)
263
+ (readme, prompt, manifest, parts, navigation,
264
+ projectTree, audit, diff, log, tokenTree, monolith)
265
265
  --only-artifacts <names> Write *only* these artifacts
266
266
  --format <text|json> CLI output format (default: text)
267
267
  --dry-run Compute the snapshot without writing anything
@@ -701,7 +701,9 @@ function splitList(value) {
701
701
  function displayOutPath(cwd, outDir, ...segments) {
702
702
  const absolute = path2.resolve(cwd, outDir, ...segments);
703
703
  const relative3 = path2.relative(cwd, absolute);
704
- if (relative3 && !relative3.startsWith("..") && !path2.isAbsolute(relative3)) return relative3;
704
+ if (relative3 !== "" && relative3 !== ".." && !relative3.startsWith(`..${path2.sep}`) && !relative3.startsWith("../") && !path2.isAbsolute(relative3)) {
705
+ return relative3;
706
+ }
705
707
  return absolute;
706
708
  }
707
709
  function nextStepHint(cwd, scriptsAddedNow) {
@@ -1320,6 +1322,7 @@ ${USAGE}
1320
1322
  if (invocation.http === true) {
1321
1323
  const transport = await startHttpTransport({
1322
1324
  cwd: path2.resolve(invocation.cwd),
1325
+ noConfig: invocation.noConfig,
1323
1326
  ...invocation.host === void 0 ? {} : { host: invocation.host },
1324
1327
  ...invocation.port === void 0 ? {} : { port: invocation.port },
1325
1328
  ...tokenOption,
@@ -1343,7 +1346,10 @@ ${USAGE}
1343
1346
  });
1344
1347
  return 0;
1345
1348
  }
1346
- return await runStdioServer({ cwd: path2.resolve(invocation.cwd) });
1349
+ return await runStdioServer({
1350
+ cwd: path2.resolve(invocation.cwd),
1351
+ noConfig: invocation.noConfig
1352
+ });
1347
1353
  }
1348
1354
  if (invocation.command === "setup") {
1349
1355
  return runSetupCommand(invocation);
@@ -1429,21 +1435,25 @@ ${USAGE}
1429
1435
  }
1430
1436
  let index;
1431
1437
  try {
1432
- index = JSON.parse(fs2.readFileSync(indexPath, "utf8"));
1433
- } catch (error) {
1434
- return fail(invocation.format, `Could not read ${indexPath}: ${error.message}`);
1438
+ const indexRead = readConfinedText(outRoot, "WORKSPACE.json");
1439
+ if (!indexRead.ok) {
1440
+ return fail(invocation.format, "Could not read WORKSPACE.json: " + indexRead.message);
1441
+ }
1442
+ index = JSON.parse(indexRead.text);
1443
+ } catch {
1444
+ return fail(invocation.format, "WORKSPACE.json is not valid JSON.");
1435
1445
  }
1436
1446
  const rows = [];
1437
1447
  const insidePath = (parent, child) => {
1438
1448
  const relative3 = path2.relative(parent, child);
1439
- return relative3 === "" || !relative3.startsWith("..") && !path2.isAbsolute(relative3);
1449
+ return relative3 === "" || relative3 !== ".." && !relative3.startsWith(`..${path2.sep}`) && !relative3.startsWith("../") && !path2.isAbsolute(relative3);
1440
1450
  };
1441
1451
  for (const member of index.members ?? []) {
1442
1452
  const name = member.name ?? "?";
1443
1453
  const snapshotDir2 = path2.resolve(outRoot, name);
1444
1454
  const repoPath = member.path ?? name;
1445
1455
  const repoDir = path2.resolve(resolved.cwd, repoPath);
1446
- if (name.length === 0 || path2.isAbsolute(name) || name.split("/").includes("..") || !insidePath(outRoot, snapshotDir2) || path2.isAbsolute(repoPath) || repoPath.split(/[\\/]/).includes("..") || !insidePath(resolved.cwd, repoDir)) {
1456
+ if (name.length === 0 || path2.isAbsolute(name) || name.split(/[\\/]/).includes("..") || !insidePath(outRoot, snapshotDir2) || path2.isAbsolute(repoPath) || repoPath.split(/[\\/]/).includes("..") || !insidePath(resolved.cwd, repoDir)) {
1447
1457
  rows.push({
1448
1458
  name,
1449
1459
  score: 0,
@@ -1453,13 +1463,45 @@ ${USAGE}
1453
1463
  });
1454
1464
  continue;
1455
1465
  }
1466
+ let canonicalSnapshot = snapshotDir2;
1467
+ let canonicalRepo = repoDir;
1468
+ try {
1469
+ const outRootReal = fs2.realpathSync(outRoot);
1470
+ const cwdReal = fs2.realpathSync(resolved.cwd);
1471
+ canonicalSnapshot = fs2.realpathSync(snapshotDir2);
1472
+ canonicalRepo = fs2.existsSync(repoDir) ? fs2.realpathSync(repoDir) : repoDir;
1473
+ if (!insidePath(outRootReal, canonicalSnapshot) || !insidePath(cwdReal, canonicalRepo)) {
1474
+ rows.push({
1475
+ name,
1476
+ score: 0,
1477
+ counts: { pass: 0, warn: 0, fail: 1 },
1478
+ failed: [],
1479
+ error: "the workspace index names a path outside the workspace"
1480
+ });
1481
+ continue;
1482
+ }
1483
+ } catch {
1484
+ canonicalSnapshot = snapshotDir2;
1485
+ canonicalRepo = repoDir;
1486
+ }
1456
1487
  if (!fs2.existsSync(path2.join(snapshotDir2, "manifest.json"))) {
1457
1488
  rows.push({ name, score: 0, counts: { pass: 0, warn: 0, fail: 1 }, failed: [], error: "no snapshot at " + snapshotDir2 });
1458
1489
  continue;
1459
1490
  }
1491
+ let memberSecretRules = resolved.customSecretRules ?? [];
1492
+ try {
1493
+ const memberLoaded = await loadConfigFileDetailed(canonicalRepo, {
1494
+ allowExecutableConfig: false
1495
+ });
1496
+ if (memberLoaded.errors.length === 0) {
1497
+ memberSecretRules = resolveConfig(memberLoaded.config, void 0, repoDir).customSecretRules ?? [];
1498
+ }
1499
+ } catch {
1500
+ }
1460
1501
  const report2 = auditSnapshot({
1461
- snapshotDir: snapshotDir2,
1462
- repoDir,
1502
+ snapshotDir: canonicalSnapshot,
1503
+ repoDir: canonicalRepo,
1504
+ ...memberSecretRules.length === 0 ? {} : { secretRules: memberSecretRules },
1463
1505
  ...invocation.deep === true ? { deep: true } : {}
1464
1506
  });
1465
1507
  rows.push({
@@ -1493,6 +1535,7 @@ ${USAGE}
1493
1535
  const report = auditSnapshot({
1494
1536
  snapshotDir,
1495
1537
  repoDir: resolved.cwd,
1538
+ ...resolved.customSecretRules === void 0 || resolved.customSecretRules.length === 0 ? {} : { secretRules: resolved.customSecretRules },
1496
1539
  ...invocation.deep === true ? { deep: true } : {}
1497
1540
  });
1498
1541
  emit(invocation.format, report, () => renderHealthText(report));
@@ -1622,7 +1665,7 @@ ${USAGE}
1622
1665
  const outRoot = path2.resolve(invocation.cwd, invocation.outDir ?? "snapshot");
1623
1666
  const workspaceCwd = path2.resolve(invocation.cwd);
1624
1667
  const outRootRelative = path2.relative(outRoot, workspaceCwd);
1625
- if (outRootRelative === "" || !outRootRelative.startsWith("..") && !path2.isAbsolute(outRootRelative)) {
1668
+ if (outRootRelative === "" || outRootRelative !== ".." && !outRootRelative.startsWith(`..${path2.sep}`) && !outRootRelative.startsWith("../") && !path2.isAbsolute(outRootRelative)) {
1626
1669
  return fail(
1627
1670
  invocation.format,
1628
1671
  `--workspace refuses --out-dir ${outRoot}: it is the working directory or one of its ancestors.`
@@ -1660,10 +1703,16 @@ ${USAGE}
1660
1703
  continue;
1661
1704
  }
1662
1705
  try {
1663
- const manifest = generateSnapshot(
1664
- { cwd: directory, outDir: path2.join(outRoot, name) },
1665
- { dryRun: invocation.dryRun }
1706
+ const memberConfig = resolveConfig(
1707
+ null,
1708
+ {
1709
+ ...generateCliOptions(invocation),
1710
+ cwd: directory,
1711
+ outDir: path2.join(outRoot, name)
1712
+ },
1713
+ directory
1666
1714
  );
1715
+ const manifest = generateSnapshot(memberConfig, { dryRun: invocation.dryRun });
1667
1716
  records.push({
1668
1717
  name,
1669
1718
  path: directory,
@@ -1778,7 +1827,7 @@ ${USAGE}
1778
1827
  return fail(invocation.format, manifestPath + " is not a snapshot manifest: " + shape);
1779
1828
  }
1780
1829
  const relativeBase = path2.relative(invocation.cwd, manifestPath).split(path2.sep).join("/");
1781
- const recordedBase = relativeBase === "" || relativeBase.startsWith("..") || path2.isAbsolute(relativeBase) ? path2.basename(manifestPath) : relativeBase;
1830
+ const recordedBase = relativeBase === "" || relativeBase === ".." || relativeBase.startsWith(`..${path2.sep}`) || relativeBase.startsWith("../") || path2.isAbsolute(relativeBase) ? path2.basename(manifestPath) : relativeBase;
1782
1831
  deltaBase = { manifest: base, path: recordedBase };
1783
1832
  info(" Delta base: " + recordedBase + " (" + base.files.length + " files, fingerprint " + base.fingerprint.slice(0, 12) + ")");
1784
1833
  }
@@ -1,4 +1,4 @@
1
- import { c as SnapshotConfig, f as Manifest } from './types-CykWdR6V.js';
1
+ import { c as SnapshotConfig, f as Manifest } from './types-C5ytHMYz.js';
2
2
 
3
3
  /** The options `resolveConfig` was called with, as the CLI would have passed them. */
4
4
  interface WorkspaceCliOptions {
@@ -13,21 +13,23 @@ interface WorkspaceCliOptions {
13
13
  * override* that beats `skeleton: true` in the project's configuration — the same trap the CLI
14
14
  * documents. Absent means "whatever the configuration says".
15
15
  */
16
- skeleton?: true;
17
- sarif?: true;
18
- staged?: true;
19
- withDependents?: true;
16
+ skeleton?: boolean;
17
+ sarif?: boolean;
18
+ staged?: boolean;
19
+ withDependents?: boolean;
20
20
  changedSince?: string;
21
21
  /** Opt-in reports a client can ask for by name; absent means "whatever the configuration says". */
22
- includeDiffs?: true;
22
+ includeDiffs?: boolean;
23
23
  includeLogs?: number;
24
- tokenTree?: true;
25
- stripComments?: true;
26
- removeEmptyLines?: true;
24
+ tokenTree?: boolean;
25
+ stripComments?: boolean;
26
+ removeEmptyLines?: boolean;
27
27
  pack?: "single" | "xml" | "json";
28
28
  /** Per-run narrowing, as the CLI's `--only` and `--ignore`; the config's lists are the default. */
29
29
  only?: string[];
30
30
  ignore?: string[];
31
+ /** True when `mcp --no-config` asked to ignore every config file. */
32
+ noConfig?: true;
31
33
  }
32
34
 
33
35
  /** What the caller needs from a finished run; the whole manifest can be megabytes. */
@@ -56,6 +58,9 @@ interface GenerateSummary {
56
58
  count: number;
57
59
  }>;
58
60
  warnings: string[];
61
+ /** The in-memory integrity check recorded in `manifest.validation`. */
62
+ validationStatus: "passed" | "failed";
63
+ validationErrors: string[];
59
64
  }
60
65
  type WorkerResults = {
61
66
  ok: true;
@@ -102,8 +107,16 @@ declare function generateInWorker(cwd: string, cliOptions: WorkspaceCliOptions,
102
107
  runId?: string;
103
108
  /** Directories whose locks/staging this run may own; used only for abandoned-worker cleanup. */
104
109
  lockRoots?: readonly string[];
105
- /** A configuration already loaded on this thread; skips a second, possibly untrusted, load. */
106
- config?: SnapshotConfig;
110
+ /**
111
+ * A configuration already loaded on this thread; skips a second, possibly untrusted, load.
112
+ * `null` is meaningful when `configLoaded` is true: it says "there is no config file", not
113
+ * "load one".
114
+ */
115
+ config?: SnapshotConfig | null;
116
+ /** True when `config` is the complete answer, including the no-config case. */
117
+ configLoaded?: boolean;
118
+ /** True when `--no-config` asked to ignore every config file. */
119
+ noConfig?: boolean;
107
120
  /** Provenance for a clone this process made; it is a value, so it crosses the boundary. */
108
121
  source?: Manifest["source"];
109
122
  }): Promise<WorkerResults>;
@@ -1,4 +1,4 @@
1
- import { c as SnapshotConfig, f as Manifest } from './types-CykWdR6V.cjs';
1
+ import { c as SnapshotConfig, f as Manifest } from './types-C5ytHMYz.cjs';
2
2
 
3
3
  /** The options `resolveConfig` was called with, as the CLI would have passed them. */
4
4
  interface WorkspaceCliOptions {
@@ -13,21 +13,23 @@ interface WorkspaceCliOptions {
13
13
  * override* that beats `skeleton: true` in the project's configuration — the same trap the CLI
14
14
  * documents. Absent means "whatever the configuration says".
15
15
  */
16
- skeleton?: true;
17
- sarif?: true;
18
- staged?: true;
19
- withDependents?: true;
16
+ skeleton?: boolean;
17
+ sarif?: boolean;
18
+ staged?: boolean;
19
+ withDependents?: boolean;
20
20
  changedSince?: string;
21
21
  /** Opt-in reports a client can ask for by name; absent means "whatever the configuration says". */
22
- includeDiffs?: true;
22
+ includeDiffs?: boolean;
23
23
  includeLogs?: number;
24
- tokenTree?: true;
25
- stripComments?: true;
26
- removeEmptyLines?: true;
24
+ tokenTree?: boolean;
25
+ stripComments?: boolean;
26
+ removeEmptyLines?: boolean;
27
27
  pack?: "single" | "xml" | "json";
28
28
  /** Per-run narrowing, as the CLI's `--only` and `--ignore`; the config's lists are the default. */
29
29
  only?: string[];
30
30
  ignore?: string[];
31
+ /** True when `mcp --no-config` asked to ignore every config file. */
32
+ noConfig?: true;
31
33
  }
32
34
 
33
35
  /** What the caller needs from a finished run; the whole manifest can be megabytes. */
@@ -56,6 +58,9 @@ interface GenerateSummary {
56
58
  count: number;
57
59
  }>;
58
60
  warnings: string[];
61
+ /** The in-memory integrity check recorded in `manifest.validation`. */
62
+ validationStatus: "passed" | "failed";
63
+ validationErrors: string[];
59
64
  }
60
65
  type WorkerResults = {
61
66
  ok: true;
@@ -102,8 +107,16 @@ declare function generateInWorker(cwd: string, cliOptions: WorkspaceCliOptions,
102
107
  runId?: string;
103
108
  /** Directories whose locks/staging this run may own; used only for abandoned-worker cleanup. */
104
109
  lockRoots?: readonly string[];
105
- /** A configuration already loaded on this thread; skips a second, possibly untrusted, load. */
106
- config?: SnapshotConfig;
110
+ /**
111
+ * A configuration already loaded on this thread; skips a second, possibly untrusted, load.
112
+ * `null` is meaningful when `configLoaded` is true: it says "there is no config file", not
113
+ * "load one".
114
+ */
115
+ config?: SnapshotConfig | null;
116
+ /** True when `config` is the complete answer, including the no-config case. */
117
+ configLoaded?: boolean;
118
+ /** True when `--no-config` asked to ignore every config file. */
119
+ noConfig?: boolean;
107
120
  /** Provenance for a clone this process made; it is a value, so it crosses the boundary. */
108
121
  source?: Manifest["source"];
109
122
  }): Promise<WorkerResults>;