seer-mcp 0.1.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/.vscode/settings.json +3 -0
- package/LICENSE +176 -0
- package/README.md +272 -0
- package/README_dev.md +199 -0
- package/dist/bundle/ci.d.ts +47 -0
- package/dist/bundle/ci.d.ts.map +1 -0
- package/dist/bundle/ci.js +113 -0
- package/dist/bundle/ci.js.map +1 -0
- package/dist/bundle/contract.d.ts +111 -0
- package/dist/bundle/contract.d.ts.map +1 -0
- package/dist/bundle/contract.js +352 -0
- package/dist/bundle/contract.js.map +1 -0
- package/dist/bundle/export.d.ts +36 -0
- package/dist/bundle/export.d.ts.map +1 -0
- package/dist/bundle/export.js +152 -0
- package/dist/bundle/export.js.map +1 -0
- package/dist/bundle/external.d.ts +66 -0
- package/dist/bundle/external.d.ts.map +1 -0
- package/dist/bundle/external.js +238 -0
- package/dist/bundle/external.js.map +1 -0
- package/dist/bundle/format.d.ts +94 -0
- package/dist/bundle/format.d.ts.map +1 -0
- package/dist/bundle/format.js +42 -0
- package/dist/bundle/format.js.map +1 -0
- package/dist/bundle/import.d.ts +49 -0
- package/dist/bundle/import.d.ts.map +1 -0
- package/dist/bundle/import.js +116 -0
- package/dist/bundle/import.js.map +1 -0
- package/dist/cli/index.d.ts +3 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +1402 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/init.d.ts +48 -0
- package/dist/cli/init.d.ts.map +1 -0
- package/dist/cli/init.js +284 -0
- package/dist/cli/init.js.map +1 -0
- package/dist/db/schema.d.ts +3 -0
- package/dist/db/schema.d.ts.map +1 -0
- package/dist/db/schema.js +616 -0
- package/dist/db/schema.js.map +1 -0
- package/dist/db/store.d.ts +1011 -0
- package/dist/db/store.d.ts.map +1 -0
- package/dist/db/store.js +3888 -0
- package/dist/db/store.js.map +1 -0
- package/dist/graph/pagerank.d.ts +9 -0
- package/dist/graph/pagerank.d.ts.map +1 -0
- package/dist/graph/pagerank.js +47 -0
- package/dist/graph/pagerank.js.map +1 -0
- package/dist/indexer/architecture.d.ts +72 -0
- package/dist/indexer/architecture.d.ts.map +1 -0
- package/dist/indexer/architecture.js +112 -0
- package/dist/indexer/architecture.js.map +1 -0
- package/dist/indexer/behavior.d.ts +75 -0
- package/dist/indexer/behavior.d.ts.map +1 -0
- package/dist/indexer/behavior.js +395 -0
- package/dist/indexer/behavior.js.map +1 -0
- package/dist/indexer/boundaries.d.ts +60 -0
- package/dist/indexer/boundaries.d.ts.map +1 -0
- package/dist/indexer/boundaries.js +366 -0
- package/dist/indexer/boundaries.js.map +1 -0
- package/dist/indexer/churn.d.ts +15 -0
- package/dist/indexer/churn.d.ts.map +1 -0
- package/dist/indexer/churn.js +49 -0
- package/dist/indexer/churn.js.map +1 -0
- package/dist/indexer/classify.d.ts +9 -0
- package/dist/indexer/classify.d.ts.map +1 -0
- package/dist/indexer/classify.js +90 -0
- package/dist/indexer/classify.js.map +1 -0
- package/dist/indexer/context.d.ts +176 -0
- package/dist/indexer/context.d.ts.map +1 -0
- package/dist/indexer/context.js +193 -0
- package/dist/indexer/context.js.map +1 -0
- package/dist/indexer/continuity.d.ts +67 -0
- package/dist/indexer/continuity.d.ts.map +1 -0
- package/dist/indexer/continuity.js +288 -0
- package/dist/indexer/continuity.js.map +1 -0
- package/dist/indexer/detectchanges.d.ts +32 -0
- package/dist/indexer/detectchanges.d.ts.map +1 -0
- package/dist/indexer/detectchanges.js +74 -0
- package/dist/indexer/detectchanges.js.map +1 -0
- package/dist/indexer/discovery.d.ts +37 -0
- package/dist/indexer/discovery.d.ts.map +1 -0
- package/dist/indexer/discovery.js +136 -0
- package/dist/indexer/discovery.js.map +1 -0
- package/dist/indexer/externaldeps.d.ts +18 -0
- package/dist/indexer/externaldeps.d.ts.map +1 -0
- package/dist/indexer/externaldeps.js +288 -0
- package/dist/indexer/externaldeps.js.map +1 -0
- package/dist/indexer/freshness.d.ts +48 -0
- package/dist/indexer/freshness.d.ts.map +1 -0
- package/dist/indexer/freshness.js +128 -0
- package/dist/indexer/freshness.js.map +1 -0
- package/dist/indexer/git.d.ts +144 -0
- package/dist/indexer/git.d.ts.map +1 -0
- package/dist/indexer/git.js +444 -0
- package/dist/indexer/git.js.map +1 -0
- package/dist/indexer/index.d.ts +145 -0
- package/dist/indexer/index.d.ts.map +1 -0
- package/dist/indexer/index.js +930 -0
- package/dist/indexer/index.js.map +1 -0
- package/dist/indexer/modules.d.ts +62 -0
- package/dist/indexer/modules.d.ts.map +1 -0
- package/dist/indexer/modules.js +293 -0
- package/dist/indexer/modules.js.map +1 -0
- package/dist/indexer/preflight.d.ts +154 -0
- package/dist/indexer/preflight.d.ts.map +1 -0
- package/dist/indexer/preflight.js +399 -0
- package/dist/indexer/preflight.js.map +1 -0
- package/dist/indexer/protoScanner.d.ts +34 -0
- package/dist/indexer/protoScanner.d.ts.map +1 -0
- package/dist/indexer/protoScanner.js +133 -0
- package/dist/indexer/protoScanner.js.map +1 -0
- package/dist/indexer/risk.d.ts +115 -0
- package/dist/indexer/risk.d.ts.map +1 -0
- package/dist/indexer/risk.js +194 -0
- package/dist/indexer/risk.js.map +1 -0
- package/dist/indexer/serviceHostScanner.d.ts +25 -0
- package/dist/indexer/serviceHostScanner.d.ts.map +1 -0
- package/dist/indexer/serviceHostScanner.js +95 -0
- package/dist/indexer/serviceHostScanner.js.map +1 -0
- package/dist/indexer/serviceLinks.d.ts +105 -0
- package/dist/indexer/serviceLinks.d.ts.map +1 -0
- package/dist/indexer/serviceLinks.js +509 -0
- package/dist/indexer/serviceLinks.js.map +1 -0
- package/dist/indexer/shapehash.d.ts +98 -0
- package/dist/indexer/shapehash.d.ts.map +1 -0
- package/dist/indexer/shapehash.js +354 -0
- package/dist/indexer/shapehash.js.map +1 -0
- package/dist/indexer/skeleton.d.ts +15 -0
- package/dist/indexer/skeleton.d.ts.map +1 -0
- package/dist/indexer/skeleton.js +136 -0
- package/dist/indexer/skeleton.js.map +1 -0
- package/dist/indexer/symbolhistory.d.ts +41 -0
- package/dist/indexer/symbolhistory.d.ts.map +1 -0
- package/dist/indexer/symbolhistory.js +124 -0
- package/dist/indexer/symbolhistory.js.map +1 -0
- package/dist/indexer/watcher.d.ts +68 -0
- package/dist/indexer/watcher.d.ts.map +1 -0
- package/dist/indexer/watcher.js +179 -0
- package/dist/indexer/watcher.js.map +1 -0
- package/dist/mcp/server.d.ts +80 -0
- package/dist/mcp/server.d.ts.map +1 -0
- package/dist/mcp/server.js +1610 -0
- package/dist/mcp/server.js.map +1 -0
- package/dist/parser/index.d.ts +8 -0
- package/dist/parser/index.d.ts.map +1 -0
- package/dist/parser/index.js +33 -0
- package/dist/parser/index.js.map +1 -0
- package/dist/parser/languages/cpp.d.ts +3 -0
- package/dist/parser/languages/cpp.d.ts.map +1 -0
- package/dist/parser/languages/cpp.js +350 -0
- package/dist/parser/languages/cpp.js.map +1 -0
- package/dist/parser/languages/csharp.d.ts +3 -0
- package/dist/parser/languages/csharp.d.ts.map +1 -0
- package/dist/parser/languages/csharp.js +239 -0
- package/dist/parser/languages/csharp.js.map +1 -0
- package/dist/parser/languages/go.d.ts +3 -0
- package/dist/parser/languages/go.d.ts.map +1 -0
- package/dist/parser/languages/go.js +259 -0
- package/dist/parser/languages/go.js.map +1 -0
- package/dist/parser/languages/java.d.ts +3 -0
- package/dist/parser/languages/java.d.ts.map +1 -0
- package/dist/parser/languages/java.js +391 -0
- package/dist/parser/languages/java.js.map +1 -0
- package/dist/parser/languages/python.d.ts +3 -0
- package/dist/parser/languages/python.d.ts.map +1 -0
- package/dist/parser/languages/python.js +396 -0
- package/dist/parser/languages/python.js.map +1 -0
- package/dist/parser/languages/rust.d.ts +3 -0
- package/dist/parser/languages/rust.d.ts.map +1 -0
- package/dist/parser/languages/rust.js +159 -0
- package/dist/parser/languages/rust.js.map +1 -0
- package/dist/parser/languages/typescript.d.ts +3 -0
- package/dist/parser/languages/typescript.d.ts.map +1 -0
- package/dist/parser/languages/typescript.js +1442 -0
- package/dist/parser/languages/typescript.js.map +1 -0
- package/dist/parser/parserContext.d.ts +77 -0
- package/dist/parser/parserContext.d.ts.map +1 -0
- package/dist/parser/parserContext.js +354 -0
- package/dist/parser/parserContext.js.map +1 -0
- package/dist/parser/walker.d.ts +81 -0
- package/dist/parser/walker.d.ts.map +1 -0
- package/dist/parser/walker.js +217 -0
- package/dist/parser/walker.js.map +1 -0
- package/dist/parser/worker.d.ts +66 -0
- package/dist/parser/worker.d.ts.map +1 -0
- package/dist/parser/worker.js +129 -0
- package/dist/parser/worker.js.map +1 -0
- package/dist/parser/workerpool.d.ts +107 -0
- package/dist/parser/workerpool.d.ts.map +1 -0
- package/dist/parser/workerpool.js +383 -0
- package/dist/parser/workerpool.js.map +1 -0
- package/dist/scip/format.d.ts +87 -0
- package/dist/scip/format.d.ts.map +1 -0
- package/dist/scip/format.js +31 -0
- package/dist/scip/format.js.map +1 -0
- package/dist/scip/import.d.ts +37 -0
- package/dist/scip/import.d.ts.map +1 -0
- package/dist/scip/import.js +180 -0
- package/dist/scip/import.js.map +1 -0
- package/dist/types.d.ts +392 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +4 -0
- package/dist/types.js.map +1 -0
- package/docs/architecture.md +105 -0
- package/docs/benchmarks/methodology.md +134 -0
- package/docs/benchmarks/raw-results.md +71 -0
- package/docs/benchmarks.md +74 -0
- package/docs/cli.md +148 -0
- package/docs/examples/behavior-tests.md +70 -0
- package/docs/examples/change-history.md +85 -0
- package/docs/examples/pre-edit-context.md +81 -0
- package/docs/examples/service-links.md +88 -0
- package/docs/examples.md +80 -0
- package/docs/faq.md +70 -0
- package/docs/internals.md +104 -0
- package/docs/languages.md +70 -0
- package/docs/limits.md +52 -0
- package/docs/mcp.md +199 -0
- package/docs/quickstart.md +119 -0
- package/docs/testing.md +123 -0
- package/docs/tools.md +115 -0
- package/package.json +52 -0
- package/research-codebase.md +578 -0
- package/seer-cli-docs.md +326 -0
- package/seer-master-guide.md +246 -0
- package/src/bundle/ci.ts +141 -0
- package/src/bundle/contract.ts +387 -0
- package/src/bundle/export.ts +175 -0
- package/src/bundle/external.ts +285 -0
- package/src/bundle/format.ts +92 -0
- package/src/bundle/import.ts +157 -0
- package/src/cli/index.ts +1249 -0
- package/src/cli/init.ts +389 -0
- package/src/db/schema.ts +614 -0
- package/src/db/store.ts +4306 -0
- package/src/graph/pagerank.ts +53 -0
- package/src/indexer/architecture.ts +148 -0
- package/src/indexer/behavior.ts +466 -0
- package/src/indexer/boundaries.ts +374 -0
- package/src/indexer/churn.ts +58 -0
- package/src/indexer/classify.ts +96 -0
- package/src/indexer/context.ts +340 -0
- package/src/indexer/continuity.ts +322 -0
- package/src/indexer/detectchanges.ts +94 -0
- package/src/indexer/discovery.ts +176 -0
- package/src/indexer/externaldeps.ts +243 -0
- package/src/indexer/freshness.ts +166 -0
- package/src/indexer/git.ts +453 -0
- package/src/indexer/index.ts +1092 -0
- package/src/indexer/modules.ts +358 -0
- package/src/indexer/preflight.ts +548 -0
- package/src/indexer/protoScanner.ts +147 -0
- package/src/indexer/risk.ts +304 -0
- package/src/indexer/serviceHostScanner.ts +92 -0
- package/src/indexer/serviceLinks.ts +543 -0
- package/src/indexer/shapehash.ts +370 -0
- package/src/indexer/skeleton.ts +169 -0
- package/src/indexer/symbolhistory.ts +172 -0
- package/src/indexer/watcher.ts +206 -0
- package/src/mcp/server.ts +1659 -0
- package/src/parser/index.ts +37 -0
- package/src/parser/languages/cpp.ts +361 -0
- package/src/parser/languages/csharp.ts +235 -0
- package/src/parser/languages/go.ts +259 -0
- package/src/parser/languages/java.ts +382 -0
- package/src/parser/languages/python.ts +370 -0
- package/src/parser/languages/rust.ts +164 -0
- package/src/parser/languages/typescript.ts +1435 -0
- package/src/parser/parserContext.ts +392 -0
- package/src/parser/walker.ts +306 -0
- package/src/parser/worker.ts +181 -0
- package/src/parser/workerpool.ts +448 -0
- package/src/scip/format.ts +83 -0
- package/src/scip/import.ts +216 -0
- package/src/types.ts +457 -0
- package/tests/benchmark-service-links.ts +244 -0
- package/tests/bug-regressions.ts +626 -0
- package/tests/filters.ts +264 -0
- package/tests/fixtures/Counter.tsx +38 -0
- package/tests/fixtures/caller.ts +7 -0
- package/tests/fixtures/collisions.ts +23 -0
- package/tests/fixtures/local_helper.ts +5 -0
- package/tests/fixtures/overloads.java +17 -0
- package/tests/fixtures/remote_helper.ts +4 -0
- package/tests/fixtures/sample.c +15 -0
- package/tests/fixtures/sample.cpp +47 -0
- package/tests/fixtures/sample.cs +62 -0
- package/tests/fixtures/sample.go +68 -0
- package/tests/fixtures/sample.h +30 -0
- package/tests/fixtures/sample.java +85 -0
- package/tests/fixtures/sample.py +46 -0
- package/tests/fixtures/sample.rs +78 -0
- package/tests/fixtures/sample.ts +76 -0
- package/tests/fixtures-service/HttpClients.cs +30 -0
- package/tests/fixtures-service/HttpClients.java +24 -0
- package/tests/fixtures-service/billing.ts +15 -0
- package/tests/fixtures-service/docker-compose.yml +15 -0
- package/tests/fixtures-service/gateway.ts +10 -0
- package/tests/fixtures-service/get_user.ts +11 -0
- package/tests/fixtures-service/graphql_client.ts +63 -0
- package/tests/fixtures-service/graphql_server.ts +30 -0
- package/tests/fixtures-service/grpc_client.go +30 -0
- package/tests/fixtures-service/http_clients.go +23 -0
- package/tests/fixtures-service/http_clients.py +38 -0
- package/tests/fixtures-service/http_clients.ts +49 -0
- package/tests/fixtures-service/k8s/payment-service.yaml +22 -0
- package/tests/fixtures-service/k8s_calls.ts +20 -0
- package/tests/fixtures-service/messaging.ts +87 -0
- package/tests/fixtures-service/trpc_client.ts +39 -0
- package/tests/fixtures-service/trpc_server.ts +39 -0
- package/tests/fixtures-service/user_service.proto +33 -0
- package/tests/fixtures-trackcd/Cargo.toml +11 -0
- package/tests/fixtures-trackcd/SpringController.java +36 -0
- package/tests/fixtures-trackcd/auth_service.ts +19 -0
- package/tests/fixtures-trackcd/complex_module.py +50 -0
- package/tests/fixtures-trackcd/express_app.js +30 -0
- package/tests/fixtures-trackcd/fastapi_app.py +49 -0
- package/tests/fixtures-trackcd/fastify_object_routes.js +32 -0
- package/tests/fixtures-trackcd/go.mod +8 -0
- package/tests/fixtures-trackcd/package.json +15 -0
- package/tests/fixtures-trackcd/requirements.txt +4 -0
- package/tests/fixtures-trackcd/tests/auth_service.test.ts +13 -0
- package/tests/fixtures-tracke/auth/AuthService.ts +23 -0
- package/tests/fixtures-tracke/auth/crypto.ts +7 -0
- package/tests/fixtures-tracke/billing/Billing.ts +20 -0
- package/tests/fixtures-tracke/billing/Invoice.ts +10 -0
- package/tests/fixtures-tracke/billing/server.ts +17 -0
- package/tests/fixtures-tracke/package.json +7 -0
- package/tests/fixtures-tracke/tests/auth.test.ts +23 -0
- package/tests/fixtures-tracke/tests/billing.test.ts +14 -0
- package/tests/fixtures-trackf/package.json +5 -0
- package/tests/fixtures-trackf/src/auth.ts +26 -0
- package/tests/fixtures-trackf/src/handlers.ts +35 -0
- package/tests/fixtures-tracki/billing/routes.ts +12 -0
- package/tests/fixtures-tracki/gateway/client.ts +13 -0
- package/tests/git-features.ts +267 -0
- package/tests/init.ts +141 -0
- package/tests/mcp-jit.ts +130 -0
- package/tests/mcp-smoke.ts +191 -0
- package/tests/mcp-trackcd.ts +169 -0
- package/tests/mcp-tracke.ts +229 -0
- package/tests/mcp-trackf.ts +330 -0
- package/tests/mcp-trackg.ts +219 -0
- package/tests/mcp-tracki.ts +174 -0
- package/tests/mcp-watcher.ts +126 -0
- package/tests/optspec.ts +194 -0
- package/tests/parallel-index.ts +333 -0
- package/tests/parallel-read.ts +125 -0
- package/tests/parallel-recovery.ts +241 -0
- package/tests/perf-callers.ts +145 -0
- package/tests/query-parity.ts +184 -0
- package/tests/query-perf.ts +55 -0
- package/tests/scale-parallel-parity.ts +225 -0
- package/tests/scale-test.ts +523 -0
- package/tests/smoke.ts +396 -0
- package/tests/trackcd.ts +325 -0
- package/tests/tracke-collisions.ts +255 -0
- package/tests/tracke.ts +314 -0
- package/tests/trackf-bugs.ts +406 -0
- package/tests/trackf.ts +390 -0
- package/tests/trackg.ts +1372 -0
- package/tests/tracki-boundaries.ts +202 -0
- package/tests/tracki-continuity.ts +253 -0
- package/tests/tracki-contract-diff.ts +249 -0
- package/tests/tracki-external-bundles.ts +341 -0
- package/tests/tracki-preflight.ts +251 -0
- package/tests/verify-roles.ts +51 -0
- package/tests/worker-parity.ts +286 -0
- package/tests/worker-pool.ts +262 -0
- package/tsconfig.json +20 -0
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { BundleManifest } from './format.js';
|
|
2
|
+
export interface ExportOptions {
|
|
3
|
+
/** Where to write the bundle. Defaults to `<repoRoot>/.seer/index.seerbundle`. */
|
|
4
|
+
out?: string;
|
|
5
|
+
/** Gzip level (0-9). Defaults to 6 (zlib's standard balance). */
|
|
6
|
+
compressionLevel?: number;
|
|
7
|
+
/** Logger; defaults to no-op. */
|
|
8
|
+
log?: (msg: string) => void;
|
|
9
|
+
/** Override the gitHead recorded in the manifest (CI sometimes wants this). */
|
|
10
|
+
gitHead?: string;
|
|
11
|
+
/** Override the gitBranch recorded in the manifest. */
|
|
12
|
+
gitBranch?: string;
|
|
13
|
+
/**
|
|
14
|
+
* Pin the manifest's `builtAt` (Unix-millis). Defaults to `Date.now()`,
|
|
15
|
+
* which makes successive exports of the same DB byte-different. Override
|
|
16
|
+
* to a stable value (e.g. the source repo's HEAD commit time) when you
|
|
17
|
+
* need reproducible bundle bytes for build-cache keys.
|
|
18
|
+
*/
|
|
19
|
+
builtAt?: number;
|
|
20
|
+
}
|
|
21
|
+
export interface ExportResult {
|
|
22
|
+
bundlePath: string;
|
|
23
|
+
bytes: number;
|
|
24
|
+
manifest: BundleManifest;
|
|
25
|
+
elapsedMs: number;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Bundle an existing `.seer/graph.db` into a portable single-file artifact.
|
|
29
|
+
*
|
|
30
|
+
* The DB is first VACUUM INTO'd to a temp file so we ship a tightly packed
|
|
31
|
+
* copy (no WAL, no free pages). The packed DB is hashed, then gzip-compressed
|
|
32
|
+
* and concatenated after the manifest header. The result is deterministic for
|
|
33
|
+
* a given DB content + manifest input.
|
|
34
|
+
*/
|
|
35
|
+
export declare function exportBundle(dbPath: string, repoRoot: string, options?: ExportOptions): Promise<ExportResult>;
|
|
36
|
+
//# sourceMappingURL=export.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"export.d.ts","sourceRoot":"","sources":["../../src/bundle/export.ts"],"names":[],"mappings":"AAOA,OAAO,EACgC,cAAc,EACpD,MAAM,aAAa,CAAC;AAErB,MAAM,WAAW,aAAa;IAC5B,kFAAkF;IAClF,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,iEAAiE;IACjE,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,iCAAiC;IACjC,GAAG,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;IAC5B,+EAA+E;IAC/E,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,uDAAuD;IACvD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;;;OAKG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,YAAY;IAC3B,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,cAAc,CAAC;IACzB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;;;;;;GAOG;AACH,wBAAsB,YAAY,CAChC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,GAAE,aAAkB,GAC5D,OAAO,CAAC,YAAY,CAAC,CA4GvB"}
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.exportBundle = exportBundle;
|
|
7
|
+
const fs_1 = __importDefault(require("fs"));
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
9
|
+
const os_1 = __importDefault(require("os"));
|
|
10
|
+
const crypto_1 = __importDefault(require("crypto"));
|
|
11
|
+
const zlib_1 = __importDefault(require("zlib"));
|
|
12
|
+
const child_process_1 = require("child_process");
|
|
13
|
+
const store_js_1 = require("../db/store.js");
|
|
14
|
+
const format_js_1 = require("./format.js");
|
|
15
|
+
/**
|
|
16
|
+
* Bundle an existing `.seer/graph.db` into a portable single-file artifact.
|
|
17
|
+
*
|
|
18
|
+
* The DB is first VACUUM INTO'd to a temp file so we ship a tightly packed
|
|
19
|
+
* copy (no WAL, no free pages). The packed DB is hashed, then gzip-compressed
|
|
20
|
+
* and concatenated after the manifest header. The result is deterministic for
|
|
21
|
+
* a given DB content + manifest input.
|
|
22
|
+
*/
|
|
23
|
+
async function exportBundle(dbPath, repoRoot, options = {}) {
|
|
24
|
+
const start = Date.now();
|
|
25
|
+
const log = options.log ?? (() => { });
|
|
26
|
+
if (!fs_1.default.existsSync(dbPath)) {
|
|
27
|
+
throw new Error(`No index at ${dbPath} — run \`seer index\` first.`);
|
|
28
|
+
}
|
|
29
|
+
// Open the source DB read-only and harvest the manifest data BEFORE we
|
|
30
|
+
// start the vacuum (vacuum closes implicit locks on its own connection but
|
|
31
|
+
// the source connection stays compatible since we re-open it here).
|
|
32
|
+
const srcStore = store_js_1.Store.openReadOnly(dbPath);
|
|
33
|
+
let manifest;
|
|
34
|
+
try {
|
|
35
|
+
const stats = srcStore.getStats();
|
|
36
|
+
const scipImports = srcStore.listScipImports();
|
|
37
|
+
const files = srcStore.listFiles();
|
|
38
|
+
const roster = files
|
|
39
|
+
.map(f => ({ relPath: f.relPath, hash: f.hash }))
|
|
40
|
+
.sort((a, b) => a.relPath < b.relPath ? -1 : a.relPath > b.relPath ? 1 : 0);
|
|
41
|
+
const rosterHash = crypto_1.default.createHash('sha256')
|
|
42
|
+
.update(roster.map(r => `${r.relPath}\t${r.hash}`).join('\n'))
|
|
43
|
+
.digest('hex');
|
|
44
|
+
const schemaVersion = srcStore.schemaInfo().dbVersion;
|
|
45
|
+
manifest = {
|
|
46
|
+
bundleFormatVersion: format_js_1.BUNDLE_FORMAT_VERSION,
|
|
47
|
+
schemaVersion,
|
|
48
|
+
builtAt: options.builtAt ?? Date.now(),
|
|
49
|
+
builtBy: `seer/${format_js_1.BUNDLE_FORMAT_VERSION}`,
|
|
50
|
+
source: {
|
|
51
|
+
repoRoot: path_1.default.resolve(repoRoot),
|
|
52
|
+
gitHead: options.gitHead ?? detectGitHead(repoRoot),
|
|
53
|
+
gitBranch: options.gitBranch ?? detectGitBranch(repoRoot),
|
|
54
|
+
rosterHash,
|
|
55
|
+
fileCount: files.length,
|
|
56
|
+
},
|
|
57
|
+
index: {
|
|
58
|
+
symbols: stats.symbols,
|
|
59
|
+
edges: stats.edges,
|
|
60
|
+
resolvedEdges: stats.resolvedEdges,
|
|
61
|
+
modules: stats.modules ?? 0,
|
|
62
|
+
routes: stats.routes ?? 0,
|
|
63
|
+
externalDependencies: stats.externalDependencies ?? 0,
|
|
64
|
+
configKeys: stats.configKeys ?? 0,
|
|
65
|
+
languages: stats.languages,
|
|
66
|
+
provenance: stats.provenance,
|
|
67
|
+
},
|
|
68
|
+
scipImports: scipImports.map(s => ({
|
|
69
|
+
path: s.path, sha256: s.sha256, tool: s.tool,
|
|
70
|
+
symbolCount: s.symbolCount, refCount: s.refCount,
|
|
71
|
+
})),
|
|
72
|
+
dbSha256: '', // filled in after we hash the packed DB
|
|
73
|
+
dbBytes: 0,
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
finally {
|
|
77
|
+
srcStore.close();
|
|
78
|
+
}
|
|
79
|
+
// VACUUM INTO produces a fresh, tightly packed DB — fast on small repos,
|
|
80
|
+
// O(rows) on huge ones. We write to a temp file so the source DB stays
|
|
81
|
+
// untouched and aborted exports leave nothing behind.
|
|
82
|
+
const tmpDir = fs_1.default.mkdtempSync(path_1.default.join(os_1.default.tmpdir(), 'seer-bundle-'));
|
|
83
|
+
const packedDb = path_1.default.join(tmpDir, 'graph.packed.db');
|
|
84
|
+
log(`Vacuuming index into ${packedDb}...`);
|
|
85
|
+
const packStore = new store_js_1.Store(dbPath);
|
|
86
|
+
try {
|
|
87
|
+
packStore.rawDb().exec(`VACUUM INTO '${packedDb.replace(/'/g, "''")}'`);
|
|
88
|
+
}
|
|
89
|
+
finally {
|
|
90
|
+
packStore.close();
|
|
91
|
+
}
|
|
92
|
+
const dbBuf = fs_1.default.readFileSync(packedDb);
|
|
93
|
+
const dbSha = crypto_1.default.createHash('sha256').update(dbBuf).digest('hex');
|
|
94
|
+
manifest.dbSha256 = dbSha;
|
|
95
|
+
manifest.dbBytes = dbBuf.length;
|
|
96
|
+
log(`Packed DB: ${dbBuf.length} bytes, sha256 ${dbSha.slice(0, 12)}...`);
|
|
97
|
+
const manifestJson = Buffer.from(JSON.stringify(manifest, null, 2), 'utf-8');
|
|
98
|
+
// Gzip the DB. Level 6 is the zlib default; bumpable for CI artifacts.
|
|
99
|
+
const compressed = zlib_1.default.gzipSync(dbBuf, {
|
|
100
|
+
level: options.compressionLevel ?? 6,
|
|
101
|
+
});
|
|
102
|
+
log(`Compressed DB: ${compressed.length} bytes (${(compressed.length / dbBuf.length * 100).toFixed(1)}% of raw)`);
|
|
103
|
+
const header = Buffer.alloc(4 + 4 + 4);
|
|
104
|
+
format_js_1.BUNDLE_MAGIC.copy(header, 0);
|
|
105
|
+
header.writeUInt32BE(format_js_1.BUNDLE_FORMAT_VERSION, 4);
|
|
106
|
+
header.writeUInt32BE(manifestJson.length, 8);
|
|
107
|
+
const outPath = options.out ?? path_1.default.join(repoRoot, '.seer', 'index.seerbundle');
|
|
108
|
+
fs_1.default.mkdirSync(path_1.default.dirname(outPath), { recursive: true });
|
|
109
|
+
const fd = fs_1.default.openSync(outPath, 'w');
|
|
110
|
+
try {
|
|
111
|
+
fs_1.default.writeSync(fd, header);
|
|
112
|
+
fs_1.default.writeSync(fd, manifestJson);
|
|
113
|
+
fs_1.default.writeSync(fd, compressed);
|
|
114
|
+
}
|
|
115
|
+
finally {
|
|
116
|
+
fs_1.default.closeSync(fd);
|
|
117
|
+
}
|
|
118
|
+
try {
|
|
119
|
+
fs_1.default.unlinkSync(packedDb);
|
|
120
|
+
fs_1.default.rmdirSync(tmpDir);
|
|
121
|
+
}
|
|
122
|
+
catch { /* */ }
|
|
123
|
+
return {
|
|
124
|
+
bundlePath: outPath,
|
|
125
|
+
bytes: header.length + manifestJson.length + compressed.length,
|
|
126
|
+
manifest,
|
|
127
|
+
elapsedMs: Date.now() - start,
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
function detectGitHead(repoRoot) {
|
|
131
|
+
try {
|
|
132
|
+
const sha = (0, child_process_1.execFileSync)('git', ['-C', repoRoot, 'rev-parse', 'HEAD'], {
|
|
133
|
+
encoding: 'utf-8', stdio: ['ignore', 'pipe', 'ignore'],
|
|
134
|
+
}).trim();
|
|
135
|
+
return sha.length > 0 ? sha : null;
|
|
136
|
+
}
|
|
137
|
+
catch {
|
|
138
|
+
return null;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
function detectGitBranch(repoRoot) {
|
|
142
|
+
try {
|
|
143
|
+
const branch = (0, child_process_1.execFileSync)('git', ['-C', repoRoot, 'rev-parse', '--abbrev-ref', 'HEAD'], {
|
|
144
|
+
encoding: 'utf-8', stdio: ['ignore', 'pipe', 'ignore'],
|
|
145
|
+
}).trim();
|
|
146
|
+
return branch.length > 0 && branch !== 'HEAD' ? branch : null;
|
|
147
|
+
}
|
|
148
|
+
catch {
|
|
149
|
+
return null;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
//# sourceMappingURL=export.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"export.js","sourceRoot":"","sources":["../../src/bundle/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EAAE,QAAQ,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,CAAC,EAAE;YACxF,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,CAAC;SACvD,CAAC,CAAC,IAAI,EAAE,CAAC;QACV,OAAO,MAAM,CAAC,MAAM,GAAG,CAAC,IAAI,MAAM,KAAK,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC;IAChE,CAAC;IAAC,MAAM,CAAC;QAAC,OAAO,IAAI,CAAC;IAAC,CAAC;AAC1B,CAAC"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* v10 External Bundle Layers — additive import of a peer repo's .seerbundle as
|
|
3
|
+
* read-only external evidence.
|
|
4
|
+
*
|
|
5
|
+
* The destructive bundle import (src/bundle/import.ts) replaces the local
|
|
6
|
+
* graph DB wholesale; this importer leaves local files/symbols untouched and
|
|
7
|
+
* only adds:
|
|
8
|
+
* - one row in external_bundles (source identity + manifest hash)
|
|
9
|
+
* - one phantom file per bundle (`__external_bundle__/<project>/<id>`)
|
|
10
|
+
* - rows in routes (and where present, service_endpoints) marked
|
|
11
|
+
* `external_bundle_id` so they participate in service-link resolution but
|
|
12
|
+
* can be wiped as a single layer on re-import.
|
|
13
|
+
*
|
|
14
|
+
* Design rules:
|
|
15
|
+
* - never touch local symbols / files / edges / pagerank
|
|
16
|
+
* - never write rows whose external_bundle_id is NULL
|
|
17
|
+
* - re-importing the same path with the same hash is a no-op
|
|
18
|
+
* - re-importing with a NEW hash replaces only that layer (FK cascade)
|
|
19
|
+
* - the bundle is read by spinning up a temp Store against the bundle's
|
|
20
|
+
* SQLite payload — same code path that bundle/info uses to enumerate the
|
|
21
|
+
* manifest, but with full row access scoped read-only
|
|
22
|
+
*/
|
|
23
|
+
import { Store } from '../db/store.js';
|
|
24
|
+
export interface ExternalImportOptions {
|
|
25
|
+
/** Optional alias for the bundle (defaults to the manifest's gitBranch or basename). */
|
|
26
|
+
alias?: string;
|
|
27
|
+
/** When true, force re-import even if the same hash is already present. */
|
|
28
|
+
force?: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Skip the dbSha256 / dbBytes integrity check. Off by default — the manifest
|
|
31
|
+
* integrity guarantee is what lets us trust a peer-repo bundle. Use only for
|
|
32
|
+
* forensic inspection of a corrupted bundle whose header still parses.
|
|
33
|
+
*/
|
|
34
|
+
skipIntegrityCheck?: boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Skip the schema-version compatibility check. Off by default — a bundle
|
|
37
|
+
* whose schemaVersion is newer than this build can't be safely read.
|
|
38
|
+
*/
|
|
39
|
+
skipSchemaCheck?: boolean;
|
|
40
|
+
/**
|
|
41
|
+
* Rebuild service_links after import so cross-repo links are visible to the
|
|
42
|
+
* next query without waiting for a re-index. Default true.
|
|
43
|
+
*/
|
|
44
|
+
rebuildServiceLinks?: boolean;
|
|
45
|
+
/** Logger; defaults to no-op. */
|
|
46
|
+
log?: (msg: string) => void;
|
|
47
|
+
}
|
|
48
|
+
export interface ExternalImportResult {
|
|
49
|
+
bundlePath: string;
|
|
50
|
+
bundleId: number;
|
|
51
|
+
externalProject: string | null;
|
|
52
|
+
externalHash: string;
|
|
53
|
+
schemaVersion: number;
|
|
54
|
+
/** True when the same bundle path + hash was already imported and we skipped. */
|
|
55
|
+
alreadyImported: boolean;
|
|
56
|
+
routesImported: number;
|
|
57
|
+
serviceEndpointsImported: number;
|
|
58
|
+
elapsedMs: number;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Import a .seerbundle as an additive external layer into the given local
|
|
62
|
+
* Store. The local DB is NOT touched outside of the external_bundles row,
|
|
63
|
+
* the phantom file row, and the new external-marked routes/service_calls.
|
|
64
|
+
*/
|
|
65
|
+
export declare function importExternalBundle(bundlePath: string, localStore: Store, options?: ExternalImportOptions): Promise<ExternalImportResult>;
|
|
66
|
+
//# sourceMappingURL=external.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"external.d.ts","sourceRoot":"","sources":["../../src/bundle/external.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AASH,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAGvC,MAAM,WAAW,qBAAqB;IACpC,wFAAwF;IACxF,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,2EAA2E;IAC3E,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB;;;;OAIG;IACH,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B;;;OAGG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B;;;OAGG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,iCAAiC;IACjC,GAAG,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;CAC7B;AAED,MAAM,WAAW,oBAAoB;IACnC,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,iFAAiF;IACjF,eAAe,EAAE,OAAO,CAAC;IACzB,cAAc,EAAE,MAAM,CAAC;IACvB,wBAAwB,EAAE,MAAM,CAAC;IACjC,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;;;GAIG;AACH,wBAAsB,oBAAoB,CACxC,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,KAAK,EACjB,OAAO,GAAE,qBAA0B,GAClC,OAAO,CAAC,oBAAoB,CAAC,CA4M/B"}
|
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* v10 External Bundle Layers — additive import of a peer repo's .seerbundle as
|
|
4
|
+
* read-only external evidence.
|
|
5
|
+
*
|
|
6
|
+
* The destructive bundle import (src/bundle/import.ts) replaces the local
|
|
7
|
+
* graph DB wholesale; this importer leaves local files/symbols untouched and
|
|
8
|
+
* only adds:
|
|
9
|
+
* - one row in external_bundles (source identity + manifest hash)
|
|
10
|
+
* - one phantom file per bundle (`__external_bundle__/<project>/<id>`)
|
|
11
|
+
* - rows in routes (and where present, service_endpoints) marked
|
|
12
|
+
* `external_bundle_id` so they participate in service-link resolution but
|
|
13
|
+
* can be wiped as a single layer on re-import.
|
|
14
|
+
*
|
|
15
|
+
* Design rules:
|
|
16
|
+
* - never touch local symbols / files / edges / pagerank
|
|
17
|
+
* - never write rows whose external_bundle_id is NULL
|
|
18
|
+
* - re-importing the same path with the same hash is a no-op
|
|
19
|
+
* - re-importing with a NEW hash replaces only that layer (FK cascade)
|
|
20
|
+
* - the bundle is read by spinning up a temp Store against the bundle's
|
|
21
|
+
* SQLite payload — same code path that bundle/info uses to enumerate the
|
|
22
|
+
* manifest, but with full row access scoped read-only
|
|
23
|
+
*/
|
|
24
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
25
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
26
|
+
};
|
|
27
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
28
|
+
exports.importExternalBundle = importExternalBundle;
|
|
29
|
+
const fs_1 = __importDefault(require("fs"));
|
|
30
|
+
const path_1 = __importDefault(require("path"));
|
|
31
|
+
const os_1 = __importDefault(require("os"));
|
|
32
|
+
const zlib_1 = __importDefault(require("zlib"));
|
|
33
|
+
const crypto_1 = __importDefault(require("crypto"));
|
|
34
|
+
const format_js_1 = require("./format.js");
|
|
35
|
+
const schema_js_1 = require("../db/schema.js");
|
|
36
|
+
const store_js_1 = require("../db/store.js");
|
|
37
|
+
const serviceLinks_js_1 = require("../indexer/serviceLinks.js");
|
|
38
|
+
/**
|
|
39
|
+
* Import a .seerbundle as an additive external layer into the given local
|
|
40
|
+
* Store. The local DB is NOT touched outside of the external_bundles row,
|
|
41
|
+
* the phantom file row, and the new external-marked routes/service_calls.
|
|
42
|
+
*/
|
|
43
|
+
async function importExternalBundle(bundlePath, localStore, options = {}) {
|
|
44
|
+
const start = Date.now();
|
|
45
|
+
const log = options.log ?? (() => { });
|
|
46
|
+
if (localStore.isReadOnly()) {
|
|
47
|
+
throw new Error('Cannot import external bundle into a read-only Store');
|
|
48
|
+
}
|
|
49
|
+
if (!localStore.hasV10()) {
|
|
50
|
+
throw new Error('Local DB does not have v10 external_bundles tables — upgrade first');
|
|
51
|
+
}
|
|
52
|
+
if (!fs_1.default.existsSync(bundlePath)) {
|
|
53
|
+
throw new Error(`No bundle at ${bundlePath}`);
|
|
54
|
+
}
|
|
55
|
+
// Parse the manifest + payload up front. We need both: the manifest gives us
|
|
56
|
+
// identity + schema_version, the payload gives us the read source.
|
|
57
|
+
const fileBuf = fs_1.default.readFileSync(bundlePath);
|
|
58
|
+
if (fileBuf.length < 12 || !fileBuf.subarray(0, 4).equals(format_js_1.BUNDLE_MAGIC)) {
|
|
59
|
+
throw new Error(`Not a Seer bundle: ${bundlePath} (bad magic)`);
|
|
60
|
+
}
|
|
61
|
+
const formatVersion = fileBuf.readUInt32BE(4);
|
|
62
|
+
if (formatVersion > format_js_1.BUNDLE_FORMAT_VERSION) {
|
|
63
|
+
throw new Error(`Bundle format v${formatVersion} is newer than this build (v${format_js_1.BUNDLE_FORMAT_VERSION}). Upgrade Seer.`);
|
|
64
|
+
}
|
|
65
|
+
const manifestLen = fileBuf.readUInt32BE(8);
|
|
66
|
+
const manifestEnd = 12 + manifestLen;
|
|
67
|
+
if (manifestLen <= 0 || manifestEnd > fileBuf.length) {
|
|
68
|
+
throw new Error(`Bundle truncated; manifest length ${manifestLen} exceeds file size`);
|
|
69
|
+
}
|
|
70
|
+
const manifest = JSON.parse(fileBuf.slice(12, manifestEnd).toString('utf-8'));
|
|
71
|
+
// Schema compatibility: a bundle built against a NEWER schema may carry
|
|
72
|
+
// tables/columns we don't understand. Reject up front rather than reading
|
|
73
|
+
// partial data. Older bundles are fine — listRoutes tolerates older shapes.
|
|
74
|
+
if (!options.skipSchemaCheck) {
|
|
75
|
+
if (typeof manifest.schemaVersion !== 'number' || manifest.schemaVersion <= 0) {
|
|
76
|
+
throw new Error(`Bundle has invalid schemaVersion=${manifest.schemaVersion}.`);
|
|
77
|
+
}
|
|
78
|
+
if (manifest.schemaVersion > schema_js_1.CURRENT_SCHEMA_VERSION) {
|
|
79
|
+
throw new Error(`Bundle schemaVersion=${manifest.schemaVersion} is newer than this build's ` +
|
|
80
|
+
`CURRENT_SCHEMA_VERSION=${schema_js_1.CURRENT_SCHEMA_VERSION}. Upgrade Seer or pass skipSchemaCheck=true.`);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
const externalHash = manifest.dbSha256;
|
|
84
|
+
const externalProject = options.alias
|
|
85
|
+
?? manifest.source.gitBranch
|
|
86
|
+
?? path_1.default.basename(bundlePath, path_1.default.extname(bundlePath));
|
|
87
|
+
const externalVersion = manifest.source.gitHead ?? null;
|
|
88
|
+
const absBundlePath = path_1.default.resolve(bundlePath);
|
|
89
|
+
// Idempotency check: same path + same hash → no-op.
|
|
90
|
+
const existing = localStore.findExternalBundleByPath(absBundlePath);
|
|
91
|
+
if (existing && existing.externalHash === externalHash && !options.force) {
|
|
92
|
+
log(`already imported with the same hash; skipping`);
|
|
93
|
+
return {
|
|
94
|
+
bundlePath: absBundlePath,
|
|
95
|
+
bundleId: existing.id,
|
|
96
|
+
externalProject: existing.externalProject,
|
|
97
|
+
externalHash,
|
|
98
|
+
schemaVersion: manifest.schemaVersion,
|
|
99
|
+
alreadyImported: true,
|
|
100
|
+
routesImported: 0,
|
|
101
|
+
serviceEndpointsImported: 0,
|
|
102
|
+
elapsedMs: Date.now() - start,
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
// Decompress the embedded DB so we can read its tables.
|
|
106
|
+
const compressed = fileBuf.slice(manifestEnd);
|
|
107
|
+
const dbBuf = zlib_1.default.gunzipSync(compressed);
|
|
108
|
+
// Integrity check: the decompressed payload must match the manifest's
|
|
109
|
+
// sha256 + byte length. A tampered or truncated bundle is rejected here.
|
|
110
|
+
if (!options.skipIntegrityCheck) {
|
|
111
|
+
const dbSha = crypto_1.default.createHash('sha256').update(dbBuf).digest('hex');
|
|
112
|
+
if (dbSha !== manifest.dbSha256) {
|
|
113
|
+
throw new Error(`Bundle integrity check FAILED. Expected ${manifest.dbSha256}, got ${dbSha}.`);
|
|
114
|
+
}
|
|
115
|
+
if (typeof manifest.dbBytes === 'number' && dbBuf.length !== manifest.dbBytes) {
|
|
116
|
+
throw new Error(`Bundle integrity check FAILED. Expected ${manifest.dbBytes} bytes, got ${dbBuf.length}.`);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
const tmpDir = fs_1.default.mkdtempSync(path_1.default.join(os_1.default.tmpdir(), 'seer-extbundle-'));
|
|
120
|
+
const externalDbPath = path_1.default.join(tmpDir, 'external.db');
|
|
121
|
+
fs_1.default.writeFileSync(externalDbPath, dbBuf);
|
|
122
|
+
let bundleId = 0;
|
|
123
|
+
let routesImported = 0;
|
|
124
|
+
let serviceEndpointsImported = 0;
|
|
125
|
+
try {
|
|
126
|
+
const externalStore = store_js_1.Store.openReadOnly(externalDbPath);
|
|
127
|
+
try {
|
|
128
|
+
// If we already had this path but with a different hash, wipe the
|
|
129
|
+
// previous layer first so the new import is a clean replace.
|
|
130
|
+
if (existing) {
|
|
131
|
+
const wiped = localStore.clearExternalBundle(existing.id);
|
|
132
|
+
log(`re-import: wiped previous layer (routes=${wiped.routes}, serviceCalls=${wiped.serviceCalls})`);
|
|
133
|
+
}
|
|
134
|
+
// Create the bundle row first so we have a stable id for the phantom
|
|
135
|
+
// file + the imported route rows.
|
|
136
|
+
bundleId = localStore.upsertExternalBundle({
|
|
137
|
+
bundlePath: absBundlePath,
|
|
138
|
+
externalProject,
|
|
139
|
+
externalVersion,
|
|
140
|
+
externalHash,
|
|
141
|
+
schemaVersion: manifest.schemaVersion,
|
|
142
|
+
routesImported: 0,
|
|
143
|
+
serviceCallsImported: 0,
|
|
144
|
+
serviceLinksImported: 0,
|
|
145
|
+
});
|
|
146
|
+
const externalFileId = localStore.ensureExternalFile(bundleId, externalProject);
|
|
147
|
+
// Import routes from the external bundle. We use the public listRoutes
|
|
148
|
+
// API which transparently handles pre-v9 column shapes (older bundles
|
|
149
|
+
// won't carry protocol/operation/etc.).
|
|
150
|
+
const localRoutes = externalStore.listRoutes({ limit: 1_000_000 });
|
|
151
|
+
// Filter: we never want external-bundle rows from a nested bundle. If
|
|
152
|
+
// the source bundle has external_bundle_id, skip those (they're
|
|
153
|
+
// someone else's external layer).
|
|
154
|
+
const importableRoutes = localRoutes.filter(r => {
|
|
155
|
+
// Cannot easily detect external_bundle_id via the public API; raw
|
|
156
|
+
// probe the column. listRoutes doesn't surface it today, so accept
|
|
157
|
+
// everything; the bundle generator should not have exported external
|
|
158
|
+
// rows itself (round-tripping external layers would be misleading).
|
|
159
|
+
return r.method && r.path;
|
|
160
|
+
});
|
|
161
|
+
log(`importing ${importableRoutes.length} routes from external bundle`);
|
|
162
|
+
localStore.begin();
|
|
163
|
+
try {
|
|
164
|
+
for (const r of importableRoutes) {
|
|
165
|
+
localStore.insertExternalRoute({
|
|
166
|
+
bundleId,
|
|
167
|
+
externalFileId,
|
|
168
|
+
method: r.method,
|
|
169
|
+
path: r.path,
|
|
170
|
+
framework: r.framework,
|
|
171
|
+
handlerName: r.handlerName,
|
|
172
|
+
line: r.line,
|
|
173
|
+
protocol: r.protocol ?? 'http',
|
|
174
|
+
operation: r.operation ?? null,
|
|
175
|
+
topic: r.topic ?? null,
|
|
176
|
+
queue: r.queue ?? null,
|
|
177
|
+
exchange: r.exchange ?? null,
|
|
178
|
+
service: r.service ?? null,
|
|
179
|
+
broker: r.broker ?? null,
|
|
180
|
+
metadataJson: r.metadataJson ?? null,
|
|
181
|
+
});
|
|
182
|
+
routesImported++;
|
|
183
|
+
}
|
|
184
|
+
localStore.commit();
|
|
185
|
+
}
|
|
186
|
+
catch (err) {
|
|
187
|
+
localStore.rollback();
|
|
188
|
+
throw err;
|
|
189
|
+
}
|
|
190
|
+
// Rebuild service links so the freshly-imported external routes are
|
|
191
|
+
// visible to the next query immediately, without waiting for a re-index.
|
|
192
|
+
let serviceLinksImported = 0;
|
|
193
|
+
if (options.rebuildServiceLinks !== false) {
|
|
194
|
+
try {
|
|
195
|
+
const sr = (0, serviceLinks_js_1.resolveServiceLinks)(localStore);
|
|
196
|
+
serviceLinksImported = sr.linksInserted ?? 0;
|
|
197
|
+
log(`rebuilt service links (linked=${serviceLinksImported})`);
|
|
198
|
+
}
|
|
199
|
+
catch (err) {
|
|
200
|
+
log(`service-link rebuild skipped: ${err.message}`);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
// Update final counts on the bundle row.
|
|
204
|
+
localStore.upsertExternalBundle({
|
|
205
|
+
bundlePath: absBundlePath,
|
|
206
|
+
externalProject,
|
|
207
|
+
externalVersion,
|
|
208
|
+
externalHash,
|
|
209
|
+
schemaVersion: manifest.schemaVersion,
|
|
210
|
+
routesImported,
|
|
211
|
+
serviceCallsImported: 0,
|
|
212
|
+
serviceLinksImported,
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
finally {
|
|
216
|
+
externalStore.close();
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
finally {
|
|
220
|
+
try {
|
|
221
|
+
fs_1.default.unlinkSync(externalDbPath);
|
|
222
|
+
fs_1.default.rmdirSync(tmpDir);
|
|
223
|
+
}
|
|
224
|
+
catch { /* */ }
|
|
225
|
+
}
|
|
226
|
+
return {
|
|
227
|
+
bundlePath: absBundlePath,
|
|
228
|
+
bundleId,
|
|
229
|
+
externalProject,
|
|
230
|
+
externalHash,
|
|
231
|
+
schemaVersion: manifest.schemaVersion,
|
|
232
|
+
alreadyImported: false,
|
|
233
|
+
routesImported,
|
|
234
|
+
serviceEndpointsImported,
|
|
235
|
+
elapsedMs: Date.now() - start,
|
|
236
|
+
};
|
|
237
|
+
}
|
|
238
|
+
//# sourceMappingURL=external.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"external.js","sourceRoot":"","sources":["../../src/bundle/external.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;;;;;AAuDH,oDAgNC;AArQD,4CAAoB;AACpB,gDAAwB;AACxB,4CAAoB;AACpB,gDAAwB;AACxB,oDAA4B;AAC5B,2CAAkF;AAClF,+CAAyD;AACzD,6CAAuC;AACvC,gEAAiE;AAwCjE;;;;GAIG;AACI,KAAK,UAAU,oBAAoB,CACxC,UAAkB,EAClB,UAAiB,EACjB,UAAiC,EAAE;IAEnC,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IACzB,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,IAAI,CAAC,GAAG,EAAE,GAAS,CAAC,CAAC,CAAC;IAE7C,IAAI,UAAU,CAAC,UAAU,EAAE,EAAE,CAAC;QAC5B,MAAM,IAAI,KAAK,CAAC,sDAAsD,CAAC,CAAC;IAC1E,CAAC;IACD,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE,EAAE,CAAC;QACzB,MAAM,IAAI,KAAK,CAAC,oEAAoE,CAAC,CAAC;IACxF,CAAC;IAED,IAAI,CAAC,YAAE,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;QAC/B,MAAM,IAAI,KAAK,CAAC,gBAAgB,UAAU,EAAE,CAAC,CAAC;IAChD,CAAC;IAED,6EAA6E;IAC7E,mEAAmE;IACnE,MAAM,OAAO,GAAG,YAAE,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC;IAC5C,IAAI,OAAO,CAAC,MAAM,GAAG,EAAE,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,wBAAY,CAAC,EAAE,CAAC;QACxE,MAAM,IAAI,KAAK,CAAC,sBAAsB,UAAU,cAAc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AC;QAAC,MAAM,CAAC,CAAC,KAAK,CAAC,CAAC;IAC9E,CAAC;IAED,OAAO;QACL,UAAU,EAAE,aAAa;QACzB,QAAQ;QACR,eAAe;QACf,YAAY;QACZ,aAAa,EAAE,QAAQ,CAAC,aAAa;QACrC,eAAe,EAAE,KAAK;QACtB,cAAc;QACd,wBAAwB;QACxB,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,KAAK;KAC9B,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Track-F portable .seer bundle format.
|
|
3
|
+
*
|
|
4
|
+
* A bundle is a single self-describing file that lets a team ship a fully
|
|
5
|
+
* built index without every developer having to re-run `seer index`. The
|
|
6
|
+
* format is deliberately tiny and dependency-free:
|
|
7
|
+
*
|
|
8
|
+
* [4 bytes: magic 'SEER']
|
|
9
|
+
* [4 bytes: bundle format version (uint32 BE)]
|
|
10
|
+
* [4 bytes: manifest length (uint32 BE)]
|
|
11
|
+
* [N bytes: manifest JSON (utf-8)]
|
|
12
|
+
* [M bytes: gzip-compressed SQLite DB]
|
|
13
|
+
*
|
|
14
|
+
* Why not tar/zip? Both add a dependency or a hand-rolled archive writer for
|
|
15
|
+
* a single payload file. Our payload IS the DB; everything else is a few
|
|
16
|
+
* structured fields. One header + one gzip stream gets us:
|
|
17
|
+
* - O(1) manifest read without decompressing the DB
|
|
18
|
+
* - cross-platform, no native deps
|
|
19
|
+
*
|
|
20
|
+
* On determinism: the gzip stream and the VACUUM INTO'd DB ARE deterministic
|
|
21
|
+
* for fixed input. The manifest, however, defaults `builtAt = Date.now()` so
|
|
22
|
+
* out-of-the-box exports of the same DB at different wall-clock times
|
|
23
|
+
* produce different bytes. If you need bit-identical bundles (build-cache
|
|
24
|
+
* keys, reproducible-builds CI), pass an explicit `builtAt` to `exportBundle`
|
|
25
|
+
* to pin it.
|
|
26
|
+
*
|
|
27
|
+
* The manifest is the source of truth for:
|
|
28
|
+
* - schema_version (so the consumer can refuse incompatible bundles)
|
|
29
|
+
* - source signature (repo root, git head, file count + hash) so the
|
|
30
|
+
* bundle's "shape" is auditable before the agent trusts it
|
|
31
|
+
* - tool versions, build time, SCIP layers contributing precision
|
|
32
|
+
*
|
|
33
|
+
* Bundles are produced by `seer bundle export` and consumed by
|
|
34
|
+
* `seer bundle import`. CI mode (`seer ci bundle`) is a thin wrapper that
|
|
35
|
+
* runs `index` then `bundle export` and surfaces the resulting path.
|
|
36
|
+
*/
|
|
37
|
+
export declare const BUNDLE_MAGIC: Buffer<ArrayBuffer>;
|
|
38
|
+
export declare const BUNDLE_FORMAT_VERSION = 1;
|
|
39
|
+
export interface BundleManifest {
|
|
40
|
+
/**
|
|
41
|
+
* Bundle format version — bumped when the on-disk layout changes
|
|
42
|
+
* incompatibly. Distinct from the DB schema version, which can bump
|
|
43
|
+
* independently when only the SQL evolves.
|
|
44
|
+
*/
|
|
45
|
+
bundleFormatVersion: number;
|
|
46
|
+
/** Schema version of the embedded DB. Consumers refuse on mismatch. */
|
|
47
|
+
schemaVersion: number;
|
|
48
|
+
/** Wall-clock millis the bundle was built. */
|
|
49
|
+
builtAt: number;
|
|
50
|
+
/** Tool that produced the bundle. */
|
|
51
|
+
builtBy: string;
|
|
52
|
+
/** Source identity. */
|
|
53
|
+
source: {
|
|
54
|
+
repoRoot: string;
|
|
55
|
+
gitHead: string | null;
|
|
56
|
+
gitBranch: string | null;
|
|
57
|
+
/** Stable hash over the source file roster — `(relPath, fileHash)` pairs. */
|
|
58
|
+
rosterHash: string;
|
|
59
|
+
/** Number of source files indexed. */
|
|
60
|
+
fileCount: number;
|
|
61
|
+
};
|
|
62
|
+
/** Index summary so a consumer can size-check without unpacking. */
|
|
63
|
+
index: {
|
|
64
|
+
symbols: number;
|
|
65
|
+
edges: number;
|
|
66
|
+
resolvedEdges: number;
|
|
67
|
+
modules: number;
|
|
68
|
+
routes: number;
|
|
69
|
+
externalDependencies: number;
|
|
70
|
+
configKeys: number;
|
|
71
|
+
languages: Record<string, number>;
|
|
72
|
+
/** v7: provenance counts. */
|
|
73
|
+
provenance?: {
|
|
74
|
+
symbols: Record<string, number>;
|
|
75
|
+
edges: Record<string, number>;
|
|
76
|
+
};
|
|
77
|
+
};
|
|
78
|
+
/** SCIP layers folded into the DB (if any). */
|
|
79
|
+
scipImports: Array<{
|
|
80
|
+
path: string;
|
|
81
|
+
sha256: string;
|
|
82
|
+
tool: string | null;
|
|
83
|
+
symbolCount: number;
|
|
84
|
+
refCount: number;
|
|
85
|
+
}>;
|
|
86
|
+
/**
|
|
87
|
+
* Sha-256 of the embedded DB (computed BEFORE compression). Lets the
|
|
88
|
+
* consumer verify a transferred bundle without trusting the gzip CRC alone.
|
|
89
|
+
*/
|
|
90
|
+
dbSha256: string;
|
|
91
|
+
/** Uncompressed DB size in bytes. */
|
|
92
|
+
dbBytes: number;
|
|
93
|
+
}
|
|
94
|
+
//# sourceMappingURL=format.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"format.d.ts","sourceRoot":"","sources":["../../src/bundle/format.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAEH,eAAO,MAAM,YAAY,qBAA+B,CAAC;AACzD,eAAO,MAAM,qBAAqB,IAAI,CAAC;AAEvC,MAAM,WAAW,cAAc;IAC7B;;;;OAIG;IACH,mBAAmB,EAAE,MAAM,CAAC;IAC5B,uEAAuE;IACvE,aAAa,EAAE,MAAM,CAAC;IACtB,8CAA8C;IAC9C,OAAO,EAAE,MAAM,CAAC;IAChB,qCAAqC;IACrC,OAAO,EAAE,MAAM,CAAC;IAChB,uBAAuB;IACvB,MAAM,EAAE;QACN,QAAQ,EAAE,MAAM,CAAC;QACjB,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;QACvB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;QACzB,6EAA6E;QAC7E,UAAU,EAAE,MAAM,CAAC;QACnB,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