codebase-snapshot 0.12.14 → 0.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +950 -3
- package/README.md +15 -3
- package/SECURITY.md +2 -2
- package/dist/bin.js +9848 -5460
- package/dist/{chunk-UQHIG2KN.js → chunk-BOJYZQFB.js} +7651 -747
- package/dist/chunk-NESEHOPU.js +266 -0
- package/dist/cli.cjs +9954 -5619
- package/dist/cli.d.cts +120 -2
- package/dist/cli.d.ts +120 -2
- package/dist/cli.js +422 -8
- package/dist/{generate-worker-BK4uJx7Z.d.cts → generate-worker-B79yGkQO.d.cts} +16 -0
- package/dist/{generate-worker-BK4uJx7Z.d.ts → generate-worker-B79yGkQO.d.ts} +16 -0
- package/dist/index.cjs +7389 -680
- package/dist/index.d.cts +145 -6
- package/dist/index.d.ts +145 -6
- package/dist/index.js +1 -1
- package/dist/mcp.cjs +3830 -1057
- package/dist/mcp.d.cts +86 -4
- package/dist/mcp.d.ts +86 -4
- package/dist/mcp.js +2 -2
- package/dist/{types-c0tLF2WC.d.cts → types-CbD8yQRZ.d.cts} +145 -1
- package/dist/{types-c0tLF2WC.d.ts → types-CbD8yQRZ.d.ts} +145 -1
- package/docs/agent.md +1 -1
- package/docs/benchmarks.md +80 -0
- package/docs/budget.md +59 -0
- package/docs/cli.md +56 -4
- package/docs/configuration.md +27 -0
- package/docs/delta.md +50 -0
- package/docs/deploy.md +75 -0
- package/docs/health.md +75 -0
- package/docs/mcp.md +112 -10
- package/docs/migration.md +68 -0
- package/docs/output.md +9 -3
- package/docs/remote.md +60 -0
- package/docs/security-review.md +117 -0
- package/docs/serve.md +66 -0
- package/docs/signing.md +61 -0
- package/docs/slice.md +57 -0
- package/docs/tools.md +161 -0
- package/docs/troubleshooting.md +63 -0
- package/docs/vs-repomix.md +1 -1
- package/docs/workspace.md +93 -0
- package/package.json +1 -1
- package/dist/chunk-6EGIFYWK.js +0 -3248
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { S as SecretRule, D as DiscoveryMode, a as SkipRecord, J as JsonSummary, M as MarkdownSummary, b as SourceSummary, K as KindRule, L as LayerRule, R as ResolvedSnapshotConfig, c as SnapshotConfig, B as ByteSize, C as CliOptions, d as PartMetadata, F as FileEntry, T as TextEncoding, e as SecretFinding, V as ValidationResult, f as Manifest, A as ArtifactSelection } from './types-
|
|
2
|
-
export { g as BudgetConfig, H as HooksConfig, I as InclusionMode, h as IncompleteFile, i as ManifestArtifact, j as ManifestConfigSnapshot, k as ManifestIndexes, l as ManifestTotals, m as Mode, O as OutputFormat, n as OwnerBrief, o as PartFileEntry, P as PromptTask, p as ResolvedArtifacts, q as ResolvedBudgets, r as SecretRuleInput, s as SkipReason, t as SummaryQuality, u as TruncationReason, v as ValidationDrift } from './types-
|
|
3
|
-
export { w as workerEntry } from './generate-worker-
|
|
1
|
+
import { S as SecretRule, D as DiscoveryMode, a as SkipRecord, J as JsonSummary, M as MarkdownSummary, b as SourceSummary, K as KindRule, L as LayerRule, R as ResolvedSnapshotConfig, c as SnapshotConfig, B as ByteSize, C as CliOptions, d as PartMetadata, F as FileEntry, T as TextEncoding, e as SecretFinding, V as ValidationResult, f as Manifest, A as ArtifactSelection } from './types-CbD8yQRZ.cjs';
|
|
2
|
+
export { g as BudgetConfig, H as HooksConfig, I as InclusionMode, h as IncompleteFile, i as ManifestArtifact, j as ManifestConfigSnapshot, k as ManifestIndexes, l as ManifestTotals, m as Mode, O as OutputFormat, n as OwnerBrief, o as PartFileEntry, P as PromptTask, p as ResolvedArtifacts, q as ResolvedBudgets, r as SecretRuleInput, s as SkipReason, t as SummaryQuality, u as TruncationReason, v as ValidationDrift } from './types-CbD8yQRZ.cjs';
|
|
3
|
+
export { w as workerEntry } from './generate-worker-B79yGkQO.cjs';
|
|
4
4
|
|
|
5
5
|
interface GitInfo {
|
|
6
6
|
branch: string;
|
|
@@ -210,7 +210,7 @@ declare const MIN_MAX_PART_BYTES = 4096;
|
|
|
210
210
|
*/
|
|
211
211
|
declare const MIN_MAX_PART_TOKENS: number;
|
|
212
212
|
/** Every artifact this package can write, in the order it is written. */
|
|
213
|
-
declare const ARTIFACT_NAMES: readonly ["readme", "prompt", "manifest", "parts", "navigation", "projectTree", "audit", "monolith"];
|
|
213
|
+
declare const ARTIFACT_NAMES: readonly ["readme", "prompt", "manifest", "parts", "navigation", "projectTree", "audit", "diff", "log", "tokenTree", "monolith"];
|
|
214
214
|
/**
|
|
215
215
|
* Parses a byte budget.
|
|
216
216
|
*
|
|
@@ -548,7 +548,7 @@ declare function validateSnapshot(configInput: ResolvedSnapshotConfig | Snapshot
|
|
|
548
548
|
* `package.json` carries the same version; `npm run verify` compares the two.
|
|
549
549
|
*/
|
|
550
550
|
declare const GENERATOR_NAME = "codebase-snapshot";
|
|
551
|
-
declare const GENERATOR_VERSION = "0.
|
|
551
|
+
declare const GENERATOR_VERSION = "0.13.0";
|
|
552
552
|
/**
|
|
553
553
|
* The manifest and ownership-marker schema this build writes and understands.
|
|
554
554
|
*
|
|
@@ -558,6 +558,131 @@ declare const GENERATOR_VERSION = "0.12.14";
|
|
|
558
558
|
*/
|
|
559
559
|
declare const SCHEMA_VERSION = "3.0.0";
|
|
560
560
|
|
|
561
|
+
/**
|
|
562
|
+
* Remote ingestion.
|
|
563
|
+
*
|
|
564
|
+
* A snapshot is only as trustworthy as the thing it describes. Fetching a repository from a URL is
|
|
565
|
+
* therefore a security boundary, not a convenience: the URL decides which machine this process
|
|
566
|
+
* talks to. The rules here are the ones that keep a "paste a repo URL" box from becoming a way to
|
|
567
|
+
* read a cloud metadata endpoint or a service on the local network.
|
|
568
|
+
*
|
|
569
|
+
* - https only, and only for hosts that resolve to public addresses. Loopback, RFC1918,
|
|
570
|
+
* link-local (including 169.254.169.254), CGNAT, multicast and their v6 equivalents are
|
|
571
|
+
* refused unless --allow-private is given explicitly.
|
|
572
|
+
* - No userinfo in the URL. Credentials belong in GITHUB_TOKEN, which is passed to git through
|
|
573
|
+
* the environment, never through argv or a provenance record.
|
|
574
|
+
* - A shallow clone: depth 1, one branch, no tags, no submodules, no LFS. A snapshot needs the
|
|
575
|
+
* tree a reader would see, not the history.
|
|
576
|
+
* - The provenance records where it came from and which commit was fetched, so a snapshot can
|
|
577
|
+
* always be traced back.
|
|
578
|
+
*/
|
|
579
|
+
interface RemoteSource {
|
|
580
|
+
kind: "https" | "file";
|
|
581
|
+
/** The URL as given, with any credentials removed (there are none by policy). */
|
|
582
|
+
url: string;
|
|
583
|
+
host: string;
|
|
584
|
+
owner: string;
|
|
585
|
+
repo: string;
|
|
586
|
+
/** The ref in the URL, when it names one (#branch), else null. */
|
|
587
|
+
ref: string | null;
|
|
588
|
+
}
|
|
589
|
+
type ParsedSource = {
|
|
590
|
+
ok: true;
|
|
591
|
+
source: RemoteSource;
|
|
592
|
+
} | {
|
|
593
|
+
ok: false;
|
|
594
|
+
message: string;
|
|
595
|
+
};
|
|
596
|
+
/** Hosts that are never a public repository, by literal form. DNS is checked separately. */
|
|
597
|
+
declare function isPrivateHost(host: string): boolean;
|
|
598
|
+
declare function parseRemoteSource(input: string, options?: {
|
|
599
|
+
allowPrivate?: boolean;
|
|
600
|
+
}): ParsedSource;
|
|
601
|
+
/** Every address a public host resolves to; refused when any is private. */
|
|
602
|
+
declare function assertPublicHost(host: string, allowPrivate: boolean): Promise<void>;
|
|
603
|
+
interface CloneOptions {
|
|
604
|
+
dest: string;
|
|
605
|
+
token?: string | null;
|
|
606
|
+
ref?: string | null;
|
|
607
|
+
allowPrivate?: boolean;
|
|
608
|
+
timeoutMs?: number;
|
|
609
|
+
log?: (line: string) => void;
|
|
610
|
+
}
|
|
611
|
+
interface CloneResult {
|
|
612
|
+
directory: string;
|
|
613
|
+
commit: string;
|
|
614
|
+
provenance: {
|
|
615
|
+
url: string;
|
|
616
|
+
host: string;
|
|
617
|
+
owner: string;
|
|
618
|
+
repo: string;
|
|
619
|
+
ref: string | null;
|
|
620
|
+
commit: string;
|
|
621
|
+
fetchedAt: string;
|
|
622
|
+
};
|
|
623
|
+
}
|
|
624
|
+
/**
|
|
625
|
+
* Shallow-clones a repository into `dest`.
|
|
626
|
+
*
|
|
627
|
+
* `git` is the only tool this product invokes, and it is invoked as an argument array with no
|
|
628
|
+
* shell. A clone that fails says which command failed and why; it never leaves a half directory
|
|
629
|
+
* that a later run might mistake for a snapshot.
|
|
630
|
+
*/
|
|
631
|
+
declare function cloneRepository(source: RemoteSource, options: CloneOptions): Promise<CloneResult>;
|
|
632
|
+
/** A temp directory for one clone, removed by the caller. */
|
|
633
|
+
declare function makeCloneDirectory(): string;
|
|
634
|
+
|
|
635
|
+
/**
|
|
636
|
+
* `snapshot serve`: the browser face of the tool.
|
|
637
|
+
*
|
|
638
|
+
* One process serves the page, the API it calls, and the MCP endpoint, so a browser client and an
|
|
639
|
+
* agent talk to the same snapshot. Three rules shape it:
|
|
640
|
+
*
|
|
641
|
+
* - Loopback by default, a bearer token always (generated on first run, printed once). The page
|
|
642
|
+
* asks for the token and keeps it in localStorage, so serving / can never leak the credential.
|
|
643
|
+
* - The API only ever writes where a person pointed it: a local path that exists, with the
|
|
644
|
+
* default settings. A remote URL is refused with a message that says what is missing, rather
|
|
645
|
+
* than pretending to fetch.
|
|
646
|
+
* - Every response is bounded. The preview is the first 64 KiB of PROMPT.md, the file list is
|
|
647
|
+
* capped, the zip is built in memory and streamed once.
|
|
648
|
+
*/
|
|
649
|
+
interface ServeOptions {
|
|
650
|
+
cwd: string;
|
|
651
|
+
host?: string;
|
|
652
|
+
port?: number;
|
|
653
|
+
token?: string | null;
|
|
654
|
+
/** Allow private addresses and file: URLs for remote sources (tests and air-gapped mirrors). */
|
|
655
|
+
allowPrivate?: boolean;
|
|
656
|
+
log?: (line: string) => void;
|
|
657
|
+
}
|
|
658
|
+
interface ServeHandle {
|
|
659
|
+
url: string;
|
|
660
|
+
port: number;
|
|
661
|
+
host: string;
|
|
662
|
+
token: string | null;
|
|
663
|
+
close(): Promise<void>;
|
|
664
|
+
}
|
|
665
|
+
declare function startWebServer(options: ServeOptions): Promise<ServeHandle>;
|
|
666
|
+
|
|
667
|
+
declare function crc32(data: Buffer): number;
|
|
668
|
+
interface ZipEntry {
|
|
669
|
+
/** Path inside the archive, forward slashes. */
|
|
670
|
+
name: string;
|
|
671
|
+
content: Buffer;
|
|
672
|
+
/** Modification time; defaults to now. */
|
|
673
|
+
mtime?: Date;
|
|
674
|
+
}
|
|
675
|
+
interface ZipOptions {
|
|
676
|
+
/** Root directory whose files become the entries; overrides `entries`. */
|
|
677
|
+
directory?: string;
|
|
678
|
+
entries?: readonly ZipEntry[];
|
|
679
|
+
/** Skip these names, relative to the directory. */
|
|
680
|
+
skip?: (relative: string) => boolean;
|
|
681
|
+
}
|
|
682
|
+
/** Every regular file under `root`, relative and forward-slashed. */
|
|
683
|
+
declare function walkFiles(root: string, prefix?: string): string[];
|
|
684
|
+
declare function writeZip(options: ZipOptions): Buffer;
|
|
685
|
+
|
|
561
686
|
/** The one endpoint this package will ever request. */
|
|
562
687
|
declare const PACKAGE_LATEST_URL = "https://registry.npmjs.org/codebase-snapshot/latest";
|
|
563
688
|
/** A result naming a newer release is trusted for a day: the upgrade command cannot change. */
|
|
@@ -1318,6 +1443,20 @@ declare function generateSarifReport(manifest: Manifest, findings: readonly Secr
|
|
|
1318
1443
|
interface GenerateOptions {
|
|
1319
1444
|
/** Compute the full manifest but write nothing to disk. */
|
|
1320
1445
|
dryRun?: boolean;
|
|
1446
|
+
/** Provenance for a tree fetched from a remote, recorded in the manifest and the brief. */
|
|
1447
|
+
source?: Manifest["source"];
|
|
1448
|
+
/** Base snapshot for `--delta`: only what changed since it is written, with its dependents. */
|
|
1449
|
+
deltaBase?: {
|
|
1450
|
+
manifest: Manifest;
|
|
1451
|
+
path: string;
|
|
1452
|
+
};
|
|
1453
|
+
/** `--slice`: narrow the snapshot to what the planner would pick for this question. */
|
|
1454
|
+
slice?: {
|
|
1455
|
+
question: string;
|
|
1456
|
+
maxTokens?: number;
|
|
1457
|
+
};
|
|
1458
|
+
/** `--budget-tokens`: fit the snapshot into this token budget, highest value first. */
|
|
1459
|
+
budgetTokens?: number;
|
|
1321
1460
|
}
|
|
1322
1461
|
/**
|
|
1323
1462
|
* Resolves and validates the output directories.
|
|
@@ -1363,4 +1502,4 @@ declare function generateSnapshot(configInput?: SnapshotConfig | ResolvedSnapsho
|
|
|
1363
1502
|
/** Promise-returning wrapper for consumers that prefer an async call site. */
|
|
1364
1503
|
declare function generateSnapshotAsync(configInput?: SnapshotConfig | ResolvedSnapshotConfig | null, options?: GenerateOptions): Promise<Manifest>;
|
|
1365
1504
|
|
|
1366
|
-
export { ARTIFACT_NAMES, ArtifactSelection, ByteSize, CHECK_INTERVAL_MS, CONFIG_KEYS, type ChangedScope, type ChangedScopeRequest, CliOptions, DEFAULT_ANSWERS, DEFAULT_SECRET_PATTERNS, DiscoveryMode, type ExplainResult, FAILURE_INTERVAL_MS, FileEntry, type FirstRunFacts, type FirstRunPlan, type FirstRunRefusal, GENERATOR_NAME, GENERATOR_VERSION, type GenerateOptions, HOOK_MARKER, type HeuristicResult, type HookInstallResult, type ImportCandidate, type ImportResolver, type InitDependency, type InitOptions, type InitResult, type InstallKind, JsonSummary, KindRule, LANGUAGE_PROFILES, type LanguageProfile, LayerRule, MIN_MAX_PART_BYTES, MIN_MAX_PART_TOKENS, Manifest, type ManifestDiff, MarkdownSummary, PACKAGE_LATEST_URL, PRESETS, PartMetadata, PromptBack, PromptCancelled, REQUEST_TIMEOUT_MS, ResolvedSnapshotConfig, SCHEMA_VERSION, SecretFinding, SecretRule, SkipRecord, SnapshotConfig, SourceSummary, TextEncoding, UP_TO_DATE_INTERVAL_MS, type UpdateCheckOptions, type UpdateNotice, ValidationResult, type WizardAnswers, anchorForPath, appendGitignoreEntries, assertReplaceable, assertUsableConfigInput, buildImportResolver, bytesForTokens, cacheDirectory, cacheFilePath, checkForUpdate, classifyKind, classifyLayer, collectFiles, compareManifests, configDigest, countInvalidUtf8Bytes, countLines, decodeText, defineConfig, detectLanguage, detectPreset, displayPath, displayWidth, enforceBudget, estimateTokens, explainPath, fenceForContent, fenceForText, fetchLatestVersion, findSecretInPath, firstRunMessage, formatTokens, formatUpdateNotice, generateProjectTree, generateSarifReport, generateSnapshot, generateSnapshotAsync, getGitInfo, getPreset, gitignorePath, globToRegExp, hasPriorSnapshot, importsChangedFile, importsOfFile, importsOfText, installKind, installPreCommitHook, isBinaryBuffer, isBinaryExtension, isBinaryFile, isEffectivelyEmpty, isInteractive, isNewer, isResolvedConfig, isSensitivePath, isSkeletonizable, isTsxFileName, listPresetNames, loadConfigFile, loadConfigFileDetailed, loadManifest, lockPathFor, markResolvedConfig, matchRule, matchesExclude, normalizeResolvedConfig, parseByteSize, partitionFiles, planFirstRun, profileForPath, renderConfig, renderDiffText, renderExplainText, renumberParts, resolveChangedScope, resolveConfig, resolveSafeOutputDirs, resolveSpecifier, runInit, scanAndRedactSecrets, shouldCheck, skeletonizeTypeScript, stripJsonComments, summarizeJson, summarizeMarkdown, summarizeTypeScriptSource, summarizeWithProfile, supportsTypeScriptImports, treeTruncationWarnings, truncatePreview, truncateToBytes, tsconfigPathsFor, updateCommand, validateSnapshot, wrapLines };
|
|
1505
|
+
export { ARTIFACT_NAMES, ArtifactSelection, ByteSize, CHECK_INTERVAL_MS, CONFIG_KEYS, type ChangedScope, type ChangedScopeRequest, CliOptions, type CloneOptions, type CloneResult, DEFAULT_ANSWERS, DEFAULT_SECRET_PATTERNS, DiscoveryMode, type ExplainResult, FAILURE_INTERVAL_MS, FileEntry, type FirstRunFacts, type FirstRunPlan, type FirstRunRefusal, GENERATOR_NAME, GENERATOR_VERSION, type GenerateOptions, HOOK_MARKER, type HeuristicResult, type HookInstallResult, type ImportCandidate, type ImportResolver, type InitDependency, type InitOptions, type InitResult, type InstallKind, JsonSummary, KindRule, LANGUAGE_PROFILES, type LanguageProfile, LayerRule, MIN_MAX_PART_BYTES, MIN_MAX_PART_TOKENS, Manifest, type ManifestDiff, MarkdownSummary, PACKAGE_LATEST_URL, PRESETS, type ParsedSource, PartMetadata, PromptBack, PromptCancelled, REQUEST_TIMEOUT_MS, type RemoteSource, ResolvedSnapshotConfig, SCHEMA_VERSION, SecretFinding, SecretRule, type ServeHandle, type ServeOptions, SkipRecord, SnapshotConfig, SourceSummary, TextEncoding, UP_TO_DATE_INTERVAL_MS, type UpdateCheckOptions, type UpdateNotice, ValidationResult, type WizardAnswers, type ZipEntry, type ZipOptions, anchorForPath, appendGitignoreEntries, assertPublicHost, assertReplaceable, assertUsableConfigInput, buildImportResolver, bytesForTokens, cacheDirectory, cacheFilePath, checkForUpdate, classifyKind, classifyLayer, cloneRepository, collectFiles, compareManifests, configDigest, countInvalidUtf8Bytes, countLines, crc32, decodeText, defineConfig, detectLanguage, detectPreset, displayPath, displayWidth, enforceBudget, estimateTokens, explainPath, fenceForContent, fenceForText, fetchLatestVersion, findSecretInPath, firstRunMessage, formatTokens, formatUpdateNotice, generateProjectTree, generateSarifReport, generateSnapshot, generateSnapshotAsync, getGitInfo, getPreset, gitignorePath, globToRegExp, hasPriorSnapshot, importsChangedFile, importsOfFile, importsOfText, installKind, installPreCommitHook, isBinaryBuffer, isBinaryExtension, isBinaryFile, isEffectivelyEmpty, isInteractive, isNewer, isPrivateHost, isResolvedConfig, isSensitivePath, isSkeletonizable, isTsxFileName, listPresetNames, loadConfigFile, loadConfigFileDetailed, loadManifest, lockPathFor, makeCloneDirectory, markResolvedConfig, matchRule, matchesExclude, normalizeResolvedConfig, parseByteSize, parseRemoteSource, partitionFiles, planFirstRun, profileForPath, renderConfig, renderDiffText, renderExplainText, renumberParts, resolveChangedScope, resolveConfig, resolveSafeOutputDirs, resolveSpecifier, runInit, scanAndRedactSecrets, shouldCheck, skeletonizeTypeScript, startWebServer, stripJsonComments, summarizeJson, summarizeMarkdown, summarizeTypeScriptSource, summarizeWithProfile, supportsTypeScriptImports, treeTruncationWarnings, truncatePreview, truncateToBytes, tsconfigPathsFor, updateCommand, validateSnapshot, walkFiles, wrapLines, writeZip };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { S as SecretRule, D as DiscoveryMode, a as SkipRecord, J as JsonSummary, M as MarkdownSummary, b as SourceSummary, K as KindRule, L as LayerRule, R as ResolvedSnapshotConfig, c as SnapshotConfig, B as ByteSize, C as CliOptions, d as PartMetadata, F as FileEntry, T as TextEncoding, e as SecretFinding, V as ValidationResult, f as Manifest, A as ArtifactSelection } from './types-
|
|
2
|
-
export { g as BudgetConfig, H as HooksConfig, I as InclusionMode, h as IncompleteFile, i as ManifestArtifact, j as ManifestConfigSnapshot, k as ManifestIndexes, l as ManifestTotals, m as Mode, O as OutputFormat, n as OwnerBrief, o as PartFileEntry, P as PromptTask, p as ResolvedArtifacts, q as ResolvedBudgets, r as SecretRuleInput, s as SkipReason, t as SummaryQuality, u as TruncationReason, v as ValidationDrift } from './types-
|
|
3
|
-
export { w as workerEntry } from './generate-worker-
|
|
1
|
+
import { S as SecretRule, D as DiscoveryMode, a as SkipRecord, J as JsonSummary, M as MarkdownSummary, b as SourceSummary, K as KindRule, L as LayerRule, R as ResolvedSnapshotConfig, c as SnapshotConfig, B as ByteSize, C as CliOptions, d as PartMetadata, F as FileEntry, T as TextEncoding, e as SecretFinding, V as ValidationResult, f as Manifest, A as ArtifactSelection } from './types-CbD8yQRZ.js';
|
|
2
|
+
export { g as BudgetConfig, H as HooksConfig, I as InclusionMode, h as IncompleteFile, i as ManifestArtifact, j as ManifestConfigSnapshot, k as ManifestIndexes, l as ManifestTotals, m as Mode, O as OutputFormat, n as OwnerBrief, o as PartFileEntry, P as PromptTask, p as ResolvedArtifacts, q as ResolvedBudgets, r as SecretRuleInput, s as SkipReason, t as SummaryQuality, u as TruncationReason, v as ValidationDrift } from './types-CbD8yQRZ.js';
|
|
3
|
+
export { w as workerEntry } from './generate-worker-B79yGkQO.js';
|
|
4
4
|
|
|
5
5
|
interface GitInfo {
|
|
6
6
|
branch: string;
|
|
@@ -210,7 +210,7 @@ declare const MIN_MAX_PART_BYTES = 4096;
|
|
|
210
210
|
*/
|
|
211
211
|
declare const MIN_MAX_PART_TOKENS: number;
|
|
212
212
|
/** Every artifact this package can write, in the order it is written. */
|
|
213
|
-
declare const ARTIFACT_NAMES: readonly ["readme", "prompt", "manifest", "parts", "navigation", "projectTree", "audit", "monolith"];
|
|
213
|
+
declare const ARTIFACT_NAMES: readonly ["readme", "prompt", "manifest", "parts", "navigation", "projectTree", "audit", "diff", "log", "tokenTree", "monolith"];
|
|
214
214
|
/**
|
|
215
215
|
* Parses a byte budget.
|
|
216
216
|
*
|
|
@@ -548,7 +548,7 @@ declare function validateSnapshot(configInput: ResolvedSnapshotConfig | Snapshot
|
|
|
548
548
|
* `package.json` carries the same version; `npm run verify` compares the two.
|
|
549
549
|
*/
|
|
550
550
|
declare const GENERATOR_NAME = "codebase-snapshot";
|
|
551
|
-
declare const GENERATOR_VERSION = "0.
|
|
551
|
+
declare const GENERATOR_VERSION = "0.13.0";
|
|
552
552
|
/**
|
|
553
553
|
* The manifest and ownership-marker schema this build writes and understands.
|
|
554
554
|
*
|
|
@@ -558,6 +558,131 @@ declare const GENERATOR_VERSION = "0.12.14";
|
|
|
558
558
|
*/
|
|
559
559
|
declare const SCHEMA_VERSION = "3.0.0";
|
|
560
560
|
|
|
561
|
+
/**
|
|
562
|
+
* Remote ingestion.
|
|
563
|
+
*
|
|
564
|
+
* A snapshot is only as trustworthy as the thing it describes. Fetching a repository from a URL is
|
|
565
|
+
* therefore a security boundary, not a convenience: the URL decides which machine this process
|
|
566
|
+
* talks to. The rules here are the ones that keep a "paste a repo URL" box from becoming a way to
|
|
567
|
+
* read a cloud metadata endpoint or a service on the local network.
|
|
568
|
+
*
|
|
569
|
+
* - https only, and only for hosts that resolve to public addresses. Loopback, RFC1918,
|
|
570
|
+
* link-local (including 169.254.169.254), CGNAT, multicast and their v6 equivalents are
|
|
571
|
+
* refused unless --allow-private is given explicitly.
|
|
572
|
+
* - No userinfo in the URL. Credentials belong in GITHUB_TOKEN, which is passed to git through
|
|
573
|
+
* the environment, never through argv or a provenance record.
|
|
574
|
+
* - A shallow clone: depth 1, one branch, no tags, no submodules, no LFS. A snapshot needs the
|
|
575
|
+
* tree a reader would see, not the history.
|
|
576
|
+
* - The provenance records where it came from and which commit was fetched, so a snapshot can
|
|
577
|
+
* always be traced back.
|
|
578
|
+
*/
|
|
579
|
+
interface RemoteSource {
|
|
580
|
+
kind: "https" | "file";
|
|
581
|
+
/** The URL as given, with any credentials removed (there are none by policy). */
|
|
582
|
+
url: string;
|
|
583
|
+
host: string;
|
|
584
|
+
owner: string;
|
|
585
|
+
repo: string;
|
|
586
|
+
/** The ref in the URL, when it names one (#branch), else null. */
|
|
587
|
+
ref: string | null;
|
|
588
|
+
}
|
|
589
|
+
type ParsedSource = {
|
|
590
|
+
ok: true;
|
|
591
|
+
source: RemoteSource;
|
|
592
|
+
} | {
|
|
593
|
+
ok: false;
|
|
594
|
+
message: string;
|
|
595
|
+
};
|
|
596
|
+
/** Hosts that are never a public repository, by literal form. DNS is checked separately. */
|
|
597
|
+
declare function isPrivateHost(host: string): boolean;
|
|
598
|
+
declare function parseRemoteSource(input: string, options?: {
|
|
599
|
+
allowPrivate?: boolean;
|
|
600
|
+
}): ParsedSource;
|
|
601
|
+
/** Every address a public host resolves to; refused when any is private. */
|
|
602
|
+
declare function assertPublicHost(host: string, allowPrivate: boolean): Promise<void>;
|
|
603
|
+
interface CloneOptions {
|
|
604
|
+
dest: string;
|
|
605
|
+
token?: string | null;
|
|
606
|
+
ref?: string | null;
|
|
607
|
+
allowPrivate?: boolean;
|
|
608
|
+
timeoutMs?: number;
|
|
609
|
+
log?: (line: string) => void;
|
|
610
|
+
}
|
|
611
|
+
interface CloneResult {
|
|
612
|
+
directory: string;
|
|
613
|
+
commit: string;
|
|
614
|
+
provenance: {
|
|
615
|
+
url: string;
|
|
616
|
+
host: string;
|
|
617
|
+
owner: string;
|
|
618
|
+
repo: string;
|
|
619
|
+
ref: string | null;
|
|
620
|
+
commit: string;
|
|
621
|
+
fetchedAt: string;
|
|
622
|
+
};
|
|
623
|
+
}
|
|
624
|
+
/**
|
|
625
|
+
* Shallow-clones a repository into `dest`.
|
|
626
|
+
*
|
|
627
|
+
* `git` is the only tool this product invokes, and it is invoked as an argument array with no
|
|
628
|
+
* shell. A clone that fails says which command failed and why; it never leaves a half directory
|
|
629
|
+
* that a later run might mistake for a snapshot.
|
|
630
|
+
*/
|
|
631
|
+
declare function cloneRepository(source: RemoteSource, options: CloneOptions): Promise<CloneResult>;
|
|
632
|
+
/** A temp directory for one clone, removed by the caller. */
|
|
633
|
+
declare function makeCloneDirectory(): string;
|
|
634
|
+
|
|
635
|
+
/**
|
|
636
|
+
* `snapshot serve`: the browser face of the tool.
|
|
637
|
+
*
|
|
638
|
+
* One process serves the page, the API it calls, and the MCP endpoint, so a browser client and an
|
|
639
|
+
* agent talk to the same snapshot. Three rules shape it:
|
|
640
|
+
*
|
|
641
|
+
* - Loopback by default, a bearer token always (generated on first run, printed once). The page
|
|
642
|
+
* asks for the token and keeps it in localStorage, so serving / can never leak the credential.
|
|
643
|
+
* - The API only ever writes where a person pointed it: a local path that exists, with the
|
|
644
|
+
* default settings. A remote URL is refused with a message that says what is missing, rather
|
|
645
|
+
* than pretending to fetch.
|
|
646
|
+
* - Every response is bounded. The preview is the first 64 KiB of PROMPT.md, the file list is
|
|
647
|
+
* capped, the zip is built in memory and streamed once.
|
|
648
|
+
*/
|
|
649
|
+
interface ServeOptions {
|
|
650
|
+
cwd: string;
|
|
651
|
+
host?: string;
|
|
652
|
+
port?: number;
|
|
653
|
+
token?: string | null;
|
|
654
|
+
/** Allow private addresses and file: URLs for remote sources (tests and air-gapped mirrors). */
|
|
655
|
+
allowPrivate?: boolean;
|
|
656
|
+
log?: (line: string) => void;
|
|
657
|
+
}
|
|
658
|
+
interface ServeHandle {
|
|
659
|
+
url: string;
|
|
660
|
+
port: number;
|
|
661
|
+
host: string;
|
|
662
|
+
token: string | null;
|
|
663
|
+
close(): Promise<void>;
|
|
664
|
+
}
|
|
665
|
+
declare function startWebServer(options: ServeOptions): Promise<ServeHandle>;
|
|
666
|
+
|
|
667
|
+
declare function crc32(data: Buffer): number;
|
|
668
|
+
interface ZipEntry {
|
|
669
|
+
/** Path inside the archive, forward slashes. */
|
|
670
|
+
name: string;
|
|
671
|
+
content: Buffer;
|
|
672
|
+
/** Modification time; defaults to now. */
|
|
673
|
+
mtime?: Date;
|
|
674
|
+
}
|
|
675
|
+
interface ZipOptions {
|
|
676
|
+
/** Root directory whose files become the entries; overrides `entries`. */
|
|
677
|
+
directory?: string;
|
|
678
|
+
entries?: readonly ZipEntry[];
|
|
679
|
+
/** Skip these names, relative to the directory. */
|
|
680
|
+
skip?: (relative: string) => boolean;
|
|
681
|
+
}
|
|
682
|
+
/** Every regular file under `root`, relative and forward-slashed. */
|
|
683
|
+
declare function walkFiles(root: string, prefix?: string): string[];
|
|
684
|
+
declare function writeZip(options: ZipOptions): Buffer;
|
|
685
|
+
|
|
561
686
|
/** The one endpoint this package will ever request. */
|
|
562
687
|
declare const PACKAGE_LATEST_URL = "https://registry.npmjs.org/codebase-snapshot/latest";
|
|
563
688
|
/** A result naming a newer release is trusted for a day: the upgrade command cannot change. */
|
|
@@ -1318,6 +1443,20 @@ declare function generateSarifReport(manifest: Manifest, findings: readonly Secr
|
|
|
1318
1443
|
interface GenerateOptions {
|
|
1319
1444
|
/** Compute the full manifest but write nothing to disk. */
|
|
1320
1445
|
dryRun?: boolean;
|
|
1446
|
+
/** Provenance for a tree fetched from a remote, recorded in the manifest and the brief. */
|
|
1447
|
+
source?: Manifest["source"];
|
|
1448
|
+
/** Base snapshot for `--delta`: only what changed since it is written, with its dependents. */
|
|
1449
|
+
deltaBase?: {
|
|
1450
|
+
manifest: Manifest;
|
|
1451
|
+
path: string;
|
|
1452
|
+
};
|
|
1453
|
+
/** `--slice`: narrow the snapshot to what the planner would pick for this question. */
|
|
1454
|
+
slice?: {
|
|
1455
|
+
question: string;
|
|
1456
|
+
maxTokens?: number;
|
|
1457
|
+
};
|
|
1458
|
+
/** `--budget-tokens`: fit the snapshot into this token budget, highest value first. */
|
|
1459
|
+
budgetTokens?: number;
|
|
1321
1460
|
}
|
|
1322
1461
|
/**
|
|
1323
1462
|
* Resolves and validates the output directories.
|
|
@@ -1363,4 +1502,4 @@ declare function generateSnapshot(configInput?: SnapshotConfig | ResolvedSnapsho
|
|
|
1363
1502
|
/** Promise-returning wrapper for consumers that prefer an async call site. */
|
|
1364
1503
|
declare function generateSnapshotAsync(configInput?: SnapshotConfig | ResolvedSnapshotConfig | null, options?: GenerateOptions): Promise<Manifest>;
|
|
1365
1504
|
|
|
1366
|
-
export { ARTIFACT_NAMES, ArtifactSelection, ByteSize, CHECK_INTERVAL_MS, CONFIG_KEYS, type ChangedScope, type ChangedScopeRequest, CliOptions, DEFAULT_ANSWERS, DEFAULT_SECRET_PATTERNS, DiscoveryMode, type ExplainResult, FAILURE_INTERVAL_MS, FileEntry, type FirstRunFacts, type FirstRunPlan, type FirstRunRefusal, GENERATOR_NAME, GENERATOR_VERSION, type GenerateOptions, HOOK_MARKER, type HeuristicResult, type HookInstallResult, type ImportCandidate, type ImportResolver, type InitDependency, type InitOptions, type InitResult, type InstallKind, JsonSummary, KindRule, LANGUAGE_PROFILES, type LanguageProfile, LayerRule, MIN_MAX_PART_BYTES, MIN_MAX_PART_TOKENS, Manifest, type ManifestDiff, MarkdownSummary, PACKAGE_LATEST_URL, PRESETS, PartMetadata, PromptBack, PromptCancelled, REQUEST_TIMEOUT_MS, ResolvedSnapshotConfig, SCHEMA_VERSION, SecretFinding, SecretRule, SkipRecord, SnapshotConfig, SourceSummary, TextEncoding, UP_TO_DATE_INTERVAL_MS, type UpdateCheckOptions, type UpdateNotice, ValidationResult, type WizardAnswers, anchorForPath, appendGitignoreEntries, assertReplaceable, assertUsableConfigInput, buildImportResolver, bytesForTokens, cacheDirectory, cacheFilePath, checkForUpdate, classifyKind, classifyLayer, collectFiles, compareManifests, configDigest, countInvalidUtf8Bytes, countLines, decodeText, defineConfig, detectLanguage, detectPreset, displayPath, displayWidth, enforceBudget, estimateTokens, explainPath, fenceForContent, fenceForText, fetchLatestVersion, findSecretInPath, firstRunMessage, formatTokens, formatUpdateNotice, generateProjectTree, generateSarifReport, generateSnapshot, generateSnapshotAsync, getGitInfo, getPreset, gitignorePath, globToRegExp, hasPriorSnapshot, importsChangedFile, importsOfFile, importsOfText, installKind, installPreCommitHook, isBinaryBuffer, isBinaryExtension, isBinaryFile, isEffectivelyEmpty, isInteractive, isNewer, isResolvedConfig, isSensitivePath, isSkeletonizable, isTsxFileName, listPresetNames, loadConfigFile, loadConfigFileDetailed, loadManifest, lockPathFor, markResolvedConfig, matchRule, matchesExclude, normalizeResolvedConfig, parseByteSize, partitionFiles, planFirstRun, profileForPath, renderConfig, renderDiffText, renderExplainText, renumberParts, resolveChangedScope, resolveConfig, resolveSafeOutputDirs, resolveSpecifier, runInit, scanAndRedactSecrets, shouldCheck, skeletonizeTypeScript, stripJsonComments, summarizeJson, summarizeMarkdown, summarizeTypeScriptSource, summarizeWithProfile, supportsTypeScriptImports, treeTruncationWarnings, truncatePreview, truncateToBytes, tsconfigPathsFor, updateCommand, validateSnapshot, wrapLines };
|
|
1505
|
+
export { ARTIFACT_NAMES, ArtifactSelection, ByteSize, CHECK_INTERVAL_MS, CONFIG_KEYS, type ChangedScope, type ChangedScopeRequest, CliOptions, type CloneOptions, type CloneResult, DEFAULT_ANSWERS, DEFAULT_SECRET_PATTERNS, DiscoveryMode, type ExplainResult, FAILURE_INTERVAL_MS, FileEntry, type FirstRunFacts, type FirstRunPlan, type FirstRunRefusal, GENERATOR_NAME, GENERATOR_VERSION, type GenerateOptions, HOOK_MARKER, type HeuristicResult, type HookInstallResult, type ImportCandidate, type ImportResolver, type InitDependency, type InitOptions, type InitResult, type InstallKind, JsonSummary, KindRule, LANGUAGE_PROFILES, type LanguageProfile, LayerRule, MIN_MAX_PART_BYTES, MIN_MAX_PART_TOKENS, Manifest, type ManifestDiff, MarkdownSummary, PACKAGE_LATEST_URL, PRESETS, type ParsedSource, PartMetadata, PromptBack, PromptCancelled, REQUEST_TIMEOUT_MS, type RemoteSource, ResolvedSnapshotConfig, SCHEMA_VERSION, SecretFinding, SecretRule, type ServeHandle, type ServeOptions, SkipRecord, SnapshotConfig, SourceSummary, TextEncoding, UP_TO_DATE_INTERVAL_MS, type UpdateCheckOptions, type UpdateNotice, ValidationResult, type WizardAnswers, type ZipEntry, type ZipOptions, anchorForPath, appendGitignoreEntries, assertPublicHost, assertReplaceable, assertUsableConfigInput, buildImportResolver, bytesForTokens, cacheDirectory, cacheFilePath, checkForUpdate, classifyKind, classifyLayer, cloneRepository, collectFiles, compareManifests, configDigest, countInvalidUtf8Bytes, countLines, crc32, decodeText, defineConfig, detectLanguage, detectPreset, displayPath, displayWidth, enforceBudget, estimateTokens, explainPath, fenceForContent, fenceForText, fetchLatestVersion, findSecretInPath, firstRunMessage, formatTokens, formatUpdateNotice, generateProjectTree, generateSarifReport, generateSnapshot, generateSnapshotAsync, getGitInfo, getPreset, gitignorePath, globToRegExp, hasPriorSnapshot, importsChangedFile, importsOfFile, importsOfText, installKind, installPreCommitHook, isBinaryBuffer, isBinaryExtension, isBinaryFile, isEffectivelyEmpty, isInteractive, isNewer, isPrivateHost, isResolvedConfig, isSensitivePath, isSkeletonizable, isTsxFileName, listPresetNames, loadConfigFile, loadConfigFileDetailed, loadManifest, lockPathFor, makeCloneDirectory, markResolvedConfig, matchRule, matchesExclude, normalizeResolvedConfig, parseByteSize, parseRemoteSource, partitionFiles, planFirstRun, profileForPath, renderConfig, renderDiffText, renderExplainText, renumberParts, resolveChangedScope, resolveConfig, resolveSafeOutputDirs, resolveSpecifier, runInit, scanAndRedactSecrets, shouldCheck, skeletonizeTypeScript, startWebServer, stripJsonComments, summarizeJson, summarizeMarkdown, summarizeTypeScriptSource, summarizeWithProfile, supportsTypeScriptImports, treeTruncationWarnings, truncatePreview, truncateToBytes, tsconfigPathsFor, updateCommand, validateSnapshot, walkFiles, wrapLines, writeZip };
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { ARTIFACT_NAMES, CHECK_INTERVAL_MS, CONFIG_KEYS, DEFAULT_ANSWERS, DEFAULT_SECRET_PATTERNS, FAILURE_INTERVAL_MS, GENERATOR_NAME, GENERATOR_VERSION, HOOK_MARKER, LANGUAGE_PROFILES, MIN_MAX_PART_BYTES, MIN_MAX_PART_TOKENS, PACKAGE_LATEST_URL, PRESETS, PromptBack, PromptCancelled, REQUEST_TIMEOUT_MS, SCHEMA_VERSION, UP_TO_DATE_INTERVAL_MS, anchorForPath, appendGitignoreEntries, assertReplaceable, assertUsableConfigInput, buildImportResolver, bytesForTokens, cacheDirectory, cacheFilePath, checkForUpdate, classifyKind, classifyLayer, collectFiles, compareManifests, configDigest, countInvalidUtf8Bytes, countLines, decodeText, defineConfig, detectLanguage, detectPreset, displayPath, displayWidth, enforceBudget, estimateTokens, explainPath, fenceForContent, fenceForText, fetchLatestVersion, findSecretInPath, firstRunMessage, formatTokens, formatUpdateNotice, generateProjectTree, generateSarifReport, generateSnapshot, generateSnapshotAsync, getGitInfo, getPreset, gitignorePath, globToRegExp, hasPriorSnapshot, importsChangedFile, importsOfFile, importsOfText, installKind, installPreCommitHook, isBinaryBuffer, isBinaryExtension, isBinaryFile, isEffectivelyEmpty, isInteractive, isNewer, isResolvedConfig, isSensitivePath, isSkeletonizable, isTsxFileName, listPresetNames, loadConfigFile, loadConfigFileDetailed, loadManifest, lockPathFor, markResolvedConfig, matchRule, matchesExclude, normalizeResolvedConfig, parseByteSize, partitionFiles, planFirstRun, profileForPath, renderConfig, renderDiffText, renderExplainText, renumberParts, resolveChangedScope, resolveConfig, resolveSafeOutputDirs, resolveSpecifier, runInit, scanAndRedactSecrets, shouldCheck, skeletonizeTypeScript, stripJsonComments, summarizeJson, summarizeMarkdown, summarizeTypeScriptSource, summarizeWithProfile, supportsTypeScriptImports, treeTruncationWarnings, truncatePreview, truncateToBytes, tsconfigPathsFor, updateCommand, validateSnapshot, workerEntry, wrapLines } from './chunk-
|
|
1
|
+
export { ARTIFACT_NAMES, CHECK_INTERVAL_MS, CONFIG_KEYS, DEFAULT_ANSWERS, DEFAULT_SECRET_PATTERNS, FAILURE_INTERVAL_MS, GENERATOR_NAME, GENERATOR_VERSION, HOOK_MARKER, LANGUAGE_PROFILES, MIN_MAX_PART_BYTES, MIN_MAX_PART_TOKENS, PACKAGE_LATEST_URL, PRESETS, PromptBack, PromptCancelled, REQUEST_TIMEOUT_MS, SCHEMA_VERSION, UP_TO_DATE_INTERVAL_MS, anchorForPath, appendGitignoreEntries, assertPublicHost, assertReplaceable, assertUsableConfigInput, buildImportResolver, bytesForTokens, cacheDirectory, cacheFilePath, checkForUpdate, classifyKind, classifyLayer, cloneRepository, collectFiles, compareManifests, configDigest, countInvalidUtf8Bytes, countLines, crc32, decodeText, defineConfig, detectLanguage, detectPreset, displayPath, displayWidth, enforceBudget, estimateTokens, explainPath, fenceForContent, fenceForText, fetchLatestVersion, findSecretInPath, firstRunMessage, formatTokens, formatUpdateNotice, generateProjectTree, generateSarifReport, generateSnapshot, generateSnapshotAsync, getGitInfo, getPreset, gitignorePath, globToRegExp, hasPriorSnapshot, importsChangedFile, importsOfFile, importsOfText, installKind, installPreCommitHook, isBinaryBuffer, isBinaryExtension, isBinaryFile, isEffectivelyEmpty, isInteractive, isNewer, isPrivateHost, isResolvedConfig, isSensitivePath, isSkeletonizable, isTsxFileName, listPresetNames, loadConfigFile, loadConfigFileDetailed, loadManifest, lockPathFor, makeCloneDirectory, markResolvedConfig, matchRule, matchesExclude, normalizeResolvedConfig, parseByteSize, parseRemoteSource, partitionFiles, planFirstRun, profileForPath, renderConfig, renderDiffText, renderExplainText, renumberParts, resolveChangedScope, resolveConfig, resolveSafeOutputDirs, resolveSpecifier, runInit, scanAndRedactSecrets, shouldCheck, skeletonizeTypeScript, startWebServer, stripJsonComments, summarizeJson, summarizeMarkdown, summarizeTypeScriptSource, summarizeWithProfile, supportsTypeScriptImports, treeTruncationWarnings, truncatePreview, truncateToBytes, tsconfigPathsFor, updateCommand, validateSnapshot, walkFiles, workerEntry, wrapLines, writeZip } from './chunk-BOJYZQFB.js';
|