semantic-atlas 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/.agents/skills/semantic-atlas/SKILL.md +172 -0
- package/.agents/skills/semantic-atlas/references/graph-patch.md +109 -0
- package/.agents/skills/semantic-atlas/references/result-routing.md +91 -0
- package/LICENSE +21 -0
- package/README.md +118 -0
- package/dist/business-flow/business-flow-derivation-service.d.ts +11 -0
- package/dist/business-flow/business-flow-derivation-service.d.ts.map +1 -0
- package/dist/business-flow/business-flow-derivation-service.js +151 -0
- package/dist/business-flow/business-flow-draft.d.ts +16 -0
- package/dist/business-flow/business-flow-draft.d.ts.map +1 -0
- package/dist/business-flow/business-flow-draft.js +150 -0
- package/dist/business-flow/framework-business-strategy.d.ts +7 -0
- package/dist/business-flow/framework-business-strategy.d.ts.map +1 -0
- package/dist/business-flow/framework-business-strategy.js +1 -0
- package/dist/business-flow/strategies/bullmq-business-strategy.d.ts +10 -0
- package/dist/business-flow/strategies/bullmq-business-strategy.d.ts.map +1 -0
- package/dist/business-flow/strategies/bullmq-business-strategy.js +79 -0
- package/dist/business-flow/strategies/called-operation-derivation.d.ts +13 -0
- package/dist/business-flow/strategies/called-operation-derivation.d.ts.map +1 -0
- package/dist/business-flow/strategies/called-operation-derivation.js +32 -0
- package/dist/business-flow/strategies/graphql-business-strategy.d.ts +8 -0
- package/dist/business-flow/strategies/graphql-business-strategy.d.ts.map +1 -0
- package/dist/business-flow/strategies/graphql-business-strategy.js +65 -0
- package/dist/business-flow/strategies/nestjs-business-strategy.d.ts +8 -0
- package/dist/business-flow/strategies/nestjs-business-strategy.d.ts.map +1 -0
- package/dist/business-flow/strategies/nestjs-business-strategy.js +72 -0
- package/dist/business-flow/strategies/strategy-helpers.d.ts +32 -0
- package/dist/business-flow/strategies/strategy-helpers.d.ts.map +1 -0
- package/dist/business-flow/strategies/strategy-helpers.js +49 -0
- package/dist/business-flow/strategies/typeorm-business-strategy.d.ts +10 -0
- package/dist/business-flow/strategies/typeorm-business-strategy.d.ts.map +1 -0
- package/dist/business-flow/strategies/typeorm-business-strategy.js +136 -0
- package/dist/business-flow/strategies/verified-invariant-strategy.d.ts +5 -0
- package/dist/business-flow/strategies/verified-invariant-strategy.d.ts.map +1 -0
- package/dist/business-flow/strategies/verified-invariant-strategy.js +38 -0
- package/dist/business-flow/strategies/verified-test-strategy.d.ts +5 -0
- package/dist/business-flow/strategies/verified-test-strategy.d.ts.map +1 -0
- package/dist/business-flow/strategies/verified-test-strategy.js +26 -0
- package/dist/business-flow/structural-flow-catalog.d.ts +21 -0
- package/dist/business-flow/structural-flow-catalog.d.ts.map +1 -0
- package/dist/business-flow/structural-flow-catalog.js +125 -0
- package/dist/business-flow/types.d.ts +51 -0
- package/dist/business-flow/types.d.ts.map +1 -0
- package/dist/business-flow/types.js +1 -0
- package/dist/cli/argument-parser.d.ts +3 -0
- package/dist/cli/argument-parser.d.ts.map +1 -0
- package/dist/cli/argument-parser.js +174 -0
- package/dist/cli/bin.d.ts +3 -0
- package/dist/cli/bin.d.ts.map +1 -0
- package/dist/cli/bin.js +23 -0
- package/dist/cli/cli-application.d.ts +38 -0
- package/dist/cli/cli-application.d.ts.map +1 -0
- package/dist/cli/cli-application.js +515 -0
- package/dist/cli/cli-error.d.ts +12 -0
- package/dist/cli/cli-error.d.ts.map +1 -0
- package/dist/cli/cli-error.js +44 -0
- package/dist/cli/cli-presenter.d.ts +14 -0
- package/dist/cli/cli-presenter.d.ts.map +1 -0
- package/dist/cli/cli-presenter.js +36 -0
- package/dist/cli/main.d.ts +3 -0
- package/dist/cli/main.d.ts.map +1 -0
- package/dist/cli/main.js +45 -0
- package/dist/cli/types.d.ts +46 -0
- package/dist/cli/types.d.ts.map +1 -0
- package/dist/cli/types.js +1 -0
- package/dist/contracts/cli.d.ts +2139 -0
- package/dist/contracts/cli.d.ts.map +1 -0
- package/dist/contracts/cli.js +232 -0
- package/dist/contracts/graph.d.ts +262 -0
- package/dist/contracts/graph.d.ts.map +1 -0
- package/dist/contracts/graph.js +182 -0
- package/dist/contracts/identifiers.d.ts +4 -0
- package/dist/contracts/identifiers.d.ts.map +1 -0
- package/dist/contracts/identifiers.js +7 -0
- package/dist/contracts/public-contracts.d.ts +4 -0
- package/dist/contracts/public-contracts.d.ts.map +1 -0
- package/dist/contracts/public-contracts.js +3 -0
- package/dist/evaluation/comparison.d.ts +30 -0
- package/dist/evaluation/comparison.d.ts.map +1 -0
- package/dist/evaluation/comparison.js +108 -0
- package/dist/evaluation/contracts.d.ts +204 -0
- package/dist/evaluation/contracts.d.ts.map +1 -0
- package/dist/evaluation/contracts.js +269 -0
- package/dist/graph/graph-store.d.ts +47 -0
- package/dist/graph/graph-store.d.ts.map +1 -0
- package/dist/graph/graph-store.js +719 -0
- package/dist/graph/types.d.ts +168 -0
- package/dist/graph/types.d.ts.map +1 -0
- package/dist/graph/types.js +1 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +9 -0
- package/dist/knowledge/business-knowledge-service.d.ts +24 -0
- package/dist/knowledge/business-knowledge-service.d.ts.map +1 -0
- package/dist/knowledge/business-knowledge-service.js +200 -0
- package/dist/knowledge/graph-patch-conflict-error.d.ts +8 -0
- package/dist/knowledge/graph-patch-conflict-error.d.ts.map +1 -0
- package/dist/knowledge/graph-patch-conflict-error.js +12 -0
- package/dist/knowledge/structural-target-binding.d.ts +14 -0
- package/dist/knowledge/structural-target-binding.d.ts.map +1 -0
- package/dist/knowledge/structural-target-binding.js +11 -0
- package/dist/repository/git-command.d.ts +3 -0
- package/dist/repository/git-command.d.ts.map +1 -0
- package/dist/repository/git-command.js +25 -0
- package/dist/repository/repository-inspector.d.ts +7 -0
- package/dist/repository/repository-inspector.d.ts.map +1 -0
- package/dist/repository/repository-inspector.js +84 -0
- package/dist/repository/repository-language-support.d.ts +14 -0
- package/dist/repository/repository-language-support.d.ts.map +1 -0
- package/dist/repository/repository-language-support.js +64 -0
- package/dist/repository/types.d.ts +9 -0
- package/dist/repository/types.d.ts.map +1 -0
- package/dist/repository/types.js +1 -0
- package/dist/snapshots/repository-snapshot.d.ts +4 -0
- package/dist/snapshots/repository-snapshot.d.ts.map +1 -0
- package/dist/snapshots/repository-snapshot.js +119 -0
- package/dist/snapshots/types.d.ts +30 -0
- package/dist/snapshots/types.d.ts.map +1 -0
- package/dist/snapshots/types.js +1 -0
- package/dist/storage/atlas-database.d.ts +14 -0
- package/dist/storage/atlas-database.d.ts.map +1 -0
- package/dist/storage/atlas-database.js +552 -0
- package/dist/storage/snapshot-store.d.ts +19 -0
- package/dist/storage/snapshot-store.d.ts.map +1 -0
- package/dist/storage/snapshot-store.js +77 -0
- package/dist/structural-backend/codegraph-backend.d.ts +54 -0
- package/dist/structural-backend/codegraph-backend.d.ts.map +1 -0
- package/dist/structural-backend/codegraph-backend.js +1224 -0
- package/dist/structural-backend/codegraph-worker-client.d.ts +5 -0
- package/dist/structural-backend/codegraph-worker-client.d.ts.map +1 -0
- package/dist/structural-backend/codegraph-worker-client.js +118 -0
- package/dist/structural-backend/codegraph-worker-protocol.d.ts +35 -0
- package/dist/structural-backend/codegraph-worker-protocol.d.ts.map +1 -0
- package/dist/structural-backend/codegraph-worker-protocol.js +1 -0
- package/dist/structural-backend/codegraph-worker.d.ts +2 -0
- package/dist/structural-backend/codegraph-worker.d.ts.map +1 -0
- package/dist/structural-backend/codegraph-worker.js +131 -0
- package/dist/structural-backend/process-instance.d.ts +18 -0
- package/dist/structural-backend/process-instance.d.ts.map +1 -0
- package/dist/structural-backend/process-instance.js +207 -0
- package/dist/structural-backend/structural-fact-changes.d.ts +7 -0
- package/dist/structural-backend/structural-fact-changes.d.ts.map +1 -0
- package/dist/structural-backend/structural-fact-changes.js +78 -0
- package/dist/structural-backend/structural-publication.d.ts +12 -0
- package/dist/structural-backend/structural-publication.d.ts.map +1 -0
- package/dist/structural-backend/structural-publication.js +252 -0
- package/dist/structural-backend/structural-write-lock.d.ts +8 -0
- package/dist/structural-backend/structural-write-lock.d.ts.map +1 -0
- package/dist/structural-backend/structural-write-lock.js +415 -0
- package/dist/structural-backend/types.d.ts +144 -0
- package/dist/structural-backend/types.d.ts.map +1 -0
- package/dist/structural-backend/types.js +11 -0
- package/dist/world/types.d.ts +77 -0
- package/dist/world/types.d.ts.map +1 -0
- package/dist/world/types.js +1 -0
- package/dist/world/world-graph-query.d.ts +31 -0
- package/dist/world/world-graph-query.d.ts.map +1 -0
- package/dist/world/world-graph-query.js +453 -0
- package/dist/world/world-model-service.d.ts +21 -0
- package/dist/world/world-model-service.d.ts.map +1 -0
- package/dist/world/world-model-service.js +211 -0
- package/dist/world/world-snapshot-store.d.ts +40 -0
- package/dist/world/world-snapshot-store.d.ts.map +1 -0
- package/dist/world/world-snapshot-store.js +555 -0
- package/docs/architecture/codegraph-backend.md +193 -0
- package/docs/contracts/cli-v1.md +119 -0
- package/docs/contracts/graph-model.md +102 -0
- package/docs/contracts/graph-patch-v1.md +98 -0
- package/docs/evaluation.md +128 -0
- package/docs/product-contract.md +148 -0
- package/package.json +78 -0
- package/schemas/cli-envelope-v1.schema.json +1359 -0
- package/schemas/evaluation-plan-v1.schema.json +211 -0
- package/schemas/evaluation-run-v1.schema.json +365 -0
- package/schemas/graph-patch-v1.schema.json +392 -0
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { GitRepository } from "./types.js";
|
|
2
|
+
export interface SupportedRepositoryLanguage {
|
|
3
|
+
readonly language: string;
|
|
4
|
+
readonly support: "supported";
|
|
5
|
+
}
|
|
6
|
+
export interface UnsupportedRepositoryLanguage {
|
|
7
|
+
readonly language: string;
|
|
8
|
+
readonly support: "unsupported";
|
|
9
|
+
readonly reason: string;
|
|
10
|
+
}
|
|
11
|
+
export type RepositoryLanguageSupport = SupportedRepositoryLanguage | UnsupportedRepositoryLanguage;
|
|
12
|
+
export declare function inspectRepositoryLanguages(repository: GitRepository): Promise<readonly RepositoryLanguageSupport[]>;
|
|
13
|
+
export declare function hasSupportedRepositoryLanguage(languages: readonly RepositoryLanguageSupport[]): boolean;
|
|
14
|
+
//# sourceMappingURL=repository-language-support.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"repository-language-support.d.ts","sourceRoot":"","sources":["../../src/repository/repository-language-support.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEhD,MAAM,WAAW,2BAA2B;IAC1C,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAC;CAC/B;AAED,MAAM,WAAW,6BAA6B;IAC5C,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,OAAO,EAAE,aAAa,CAAC;IAChC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,MAAM,yBAAyB,GACjC,2BAA2B,GAC3B,6BAA6B,CAAC;AAgClC,wBAAsB,0BAA0B,CAC9C,UAAU,EAAE,aAAa,GACxB,OAAO,CAAC,SAAS,yBAAyB,EAAE,CAAC,CAiC/C;AAED,wBAAgB,8BAA8B,CAC5C,SAAS,EAAE,SAAS,yBAAyB,EAAE,GAC9C,OAAO,CAET"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { extname } from "node:path";
|
|
2
|
+
import { runGit } from "./git-command.js";
|
|
3
|
+
const languageByExtension = new Map([
|
|
4
|
+
[".c", "c"],
|
|
5
|
+
[".cc", "cpp"],
|
|
6
|
+
[".cpp", "cpp"],
|
|
7
|
+
[".cs", "csharp"],
|
|
8
|
+
[".cts", "typescript"],
|
|
9
|
+
[".cxx", "cpp"],
|
|
10
|
+
[".go", "go"],
|
|
11
|
+
[".h", "c"],
|
|
12
|
+
[".hpp", "cpp"],
|
|
13
|
+
[".java", "java"],
|
|
14
|
+
[".js", "javascript"],
|
|
15
|
+
[".jsx", "javascript"],
|
|
16
|
+
[".kt", "kotlin"],
|
|
17
|
+
[".kts", "kotlin"],
|
|
18
|
+
[".mjs", "javascript"],
|
|
19
|
+
[".mts", "typescript"],
|
|
20
|
+
[".php", "php"],
|
|
21
|
+
[".py", "python"],
|
|
22
|
+
[".rb", "ruby"],
|
|
23
|
+
[".rs", "rust"],
|
|
24
|
+
[".scala", "scala"],
|
|
25
|
+
[".swift", "swift"],
|
|
26
|
+
[".ts", "typescript"],
|
|
27
|
+
[".tsx", "typescript"],
|
|
28
|
+
[".vue", "vue"],
|
|
29
|
+
]);
|
|
30
|
+
const supportedLanguages = new Set(["javascript", "typescript"]);
|
|
31
|
+
export async function inspectRepositoryLanguages(repository) {
|
|
32
|
+
const output = await runGit(repository.worktreeRoot, [
|
|
33
|
+
"ls-files",
|
|
34
|
+
"--cached",
|
|
35
|
+
"--others",
|
|
36
|
+
"--exclude-standard",
|
|
37
|
+
"-z",
|
|
38
|
+
]);
|
|
39
|
+
const languages = new Set(output.toString("utf8")
|
|
40
|
+
.split("\0")
|
|
41
|
+
.flatMap((path) => {
|
|
42
|
+
const language = languageByExtension.get(extname(path).toLowerCase());
|
|
43
|
+
return language === undefined ? [] : [language];
|
|
44
|
+
}));
|
|
45
|
+
if (languages.size === 0) {
|
|
46
|
+
return [{
|
|
47
|
+
language: "unknown",
|
|
48
|
+
support: "unsupported",
|
|
49
|
+
reason: "No supported TypeScript or JavaScript source files were found.",
|
|
50
|
+
}];
|
|
51
|
+
}
|
|
52
|
+
return [...languages]
|
|
53
|
+
.sort((left, right) => left.localeCompare(right))
|
|
54
|
+
.map((language) => (supportedLanguages.has(language)
|
|
55
|
+
? { language, support: "supported" }
|
|
56
|
+
: {
|
|
57
|
+
language,
|
|
58
|
+
support: "unsupported",
|
|
59
|
+
reason: `Semantic Atlas v0.1 does not structurally index ${language} source files.`,
|
|
60
|
+
}));
|
|
61
|
+
}
|
|
62
|
+
export function hasSupportedRepositoryLanguage(languages) {
|
|
63
|
+
return languages.some(({ support }) => support === "supported");
|
|
64
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export interface GitRepository {
|
|
2
|
+
readonly repositoryId: string;
|
|
3
|
+
readonly worktreeRoot: string;
|
|
4
|
+
readonly gitDirectory: string;
|
|
5
|
+
readonly commonGitDirectory: string;
|
|
6
|
+
readonly worktreeRoots: readonly string[];
|
|
7
|
+
readonly indexPath: string;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/repository/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,kBAAkB,EAAE,MAAM,CAAC;IACpC,QAAQ,CAAC,aAAa,EAAE,SAAS,MAAM,EAAE,CAAC;IAC1C,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;CAC5B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { GitRepository } from "../repository/types.js";
|
|
2
|
+
import type { RepositorySnapshot } from "./types.js";
|
|
3
|
+
export declare function createRepositorySnapshot(repository: GitRepository): Promise<RepositorySnapshot>;
|
|
4
|
+
//# sourceMappingURL=repository-snapshot.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"repository-snapshot.d.ts","sourceRoot":"","sources":["../../src/snapshots/repository-snapshot.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,KAAK,EAGV,kBAAkB,EAGnB,MAAM,YAAY,CAAC;AAyGpB,wBAAsB,wBAAwB,CAC5C,UAAU,EAAE,aAAa,GACxB,OAAO,CAAC,kBAAkB,CAAC,CA0B7B"}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import { lstat, readFile, readlink } from "node:fs/promises";
|
|
3
|
+
import { join } from "node:path";
|
|
4
|
+
import { runGit } from "../repository/git-command.js";
|
|
5
|
+
import { discoverTargetSources, isTargetSource, readCurrentHead, } from "../repository/repository-inspector.js";
|
|
6
|
+
function parseIndexEntries(output) {
|
|
7
|
+
const entries = new Map();
|
|
8
|
+
for (const record of output.toString("utf8").split("\0")) {
|
|
9
|
+
if (record.length === 0) {
|
|
10
|
+
continue;
|
|
11
|
+
}
|
|
12
|
+
const separatorIndex = record.indexOf("\t");
|
|
13
|
+
const metadata = record.slice(0, separatorIndex).split(" ");
|
|
14
|
+
const path = record.slice(separatorIndex + 1);
|
|
15
|
+
const [mode, objectId, stageText] = metadata;
|
|
16
|
+
if (separatorIndex < 0 || mode === undefined || objectId === undefined || stageText === undefined) {
|
|
17
|
+
throw new Error(`Invalid Git index entry: ${record}`);
|
|
18
|
+
}
|
|
19
|
+
const pathEntries = entries.get(path) ?? [];
|
|
20
|
+
pathEntries.push({ mode, objectId, stage: Number.parseInt(stageText, 10) });
|
|
21
|
+
entries.set(path, pathEntries);
|
|
22
|
+
}
|
|
23
|
+
return entries;
|
|
24
|
+
}
|
|
25
|
+
async function readIndexVersion(indexPath) {
|
|
26
|
+
const header = (await readFile(indexPath)).subarray(0, 8);
|
|
27
|
+
if (header.length !== 8 || header.subarray(0, 4).toString("ascii") !== "DIRC") {
|
|
28
|
+
throw new Error(`Invalid Git index header at ${indexPath}`);
|
|
29
|
+
}
|
|
30
|
+
return header.readUInt32BE(4);
|
|
31
|
+
}
|
|
32
|
+
async function readWorktreeContent(absolutePath) {
|
|
33
|
+
try {
|
|
34
|
+
const fileStat = await lstat(absolutePath);
|
|
35
|
+
const symbolicLink = fileStat.isSymbolicLink();
|
|
36
|
+
const content = symbolicLink
|
|
37
|
+
? Buffer.from(await readlink(absolutePath), "utf8")
|
|
38
|
+
: await readFile(absolutePath);
|
|
39
|
+
return {
|
|
40
|
+
contentHash: createHash("sha256").update(content).digest("hex"),
|
|
41
|
+
executable: (fileStat.mode & 0o111) !== 0,
|
|
42
|
+
symbolicLink,
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
catch (error) {
|
|
46
|
+
if (error.code === "ENOENT") {
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
throw error;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
function parseChanges(output) {
|
|
53
|
+
const staged = new Set();
|
|
54
|
+
const unstaged = new Set();
|
|
55
|
+
const untracked = new Set();
|
|
56
|
+
const records = output.toString("utf8").split("\0");
|
|
57
|
+
for (let index = 0; index < records.length; index += 1) {
|
|
58
|
+
const record = records[index];
|
|
59
|
+
if (record === undefined || record.length < 4) {
|
|
60
|
+
continue;
|
|
61
|
+
}
|
|
62
|
+
const indexState = record[0];
|
|
63
|
+
const worktreeState = record[1];
|
|
64
|
+
const path = record.slice(3);
|
|
65
|
+
const isRenameOrCopy = (indexState === "R" ||
|
|
66
|
+
indexState === "C" ||
|
|
67
|
+
worktreeState === "R" ||
|
|
68
|
+
worktreeState === "C");
|
|
69
|
+
const originalPath = isRenameOrCopy ? records[index + 1] : undefined;
|
|
70
|
+
if (isRenameOrCopy) {
|
|
71
|
+
index += 1;
|
|
72
|
+
}
|
|
73
|
+
if (!isTargetSource(path) && (originalPath === undefined || !isTargetSource(originalPath))) {
|
|
74
|
+
continue;
|
|
75
|
+
}
|
|
76
|
+
if (indexState === "?" && worktreeState === "?") {
|
|
77
|
+
untracked.add(path);
|
|
78
|
+
continue;
|
|
79
|
+
}
|
|
80
|
+
if (indexState !== undefined && indexState !== " ") {
|
|
81
|
+
staged.add(path);
|
|
82
|
+
}
|
|
83
|
+
if (worktreeState !== undefined && worktreeState !== " ") {
|
|
84
|
+
unstaged.add(path);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
const sort = (paths) => [...paths].sort((left, right) => (left < right ? -1 : left > right ? 1 : 0));
|
|
88
|
+
return {
|
|
89
|
+
staged: sort(staged),
|
|
90
|
+
unstaged: sort(unstaged),
|
|
91
|
+
untracked: sort(untracked),
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
export async function createRepositorySnapshot(repository) {
|
|
95
|
+
const [headCommit, indexVersion, targetSources, rawIndexEntries, rawChanges] = await Promise.all([
|
|
96
|
+
readCurrentHead(repository),
|
|
97
|
+
readIndexVersion(repository.indexPath),
|
|
98
|
+
discoverTargetSources(repository),
|
|
99
|
+
runGit(repository.worktreeRoot, ["ls-files", "--stage", "-z"]),
|
|
100
|
+
runGit(repository.worktreeRoot, ["status", "--porcelain=v1", "-z", "--untracked-files=all"]),
|
|
101
|
+
]);
|
|
102
|
+
const indexEntries = parseIndexEntries(rawIndexEntries);
|
|
103
|
+
const files = await Promise.all(targetSources.map(async (path) => ({
|
|
104
|
+
path,
|
|
105
|
+
indexEntries: indexEntries.get(path) ?? [],
|
|
106
|
+
worktree: await readWorktreeContent(join(repository.worktreeRoot, path)),
|
|
107
|
+
})));
|
|
108
|
+
const changes = parseChanges(rawChanges);
|
|
109
|
+
const content = {
|
|
110
|
+
schemaVersion: 1,
|
|
111
|
+
repositoryId: repository.repositoryId,
|
|
112
|
+
headCommit,
|
|
113
|
+
indexVersion,
|
|
114
|
+
files,
|
|
115
|
+
changes,
|
|
116
|
+
};
|
|
117
|
+
const snapshotId = createHash("sha256").update(JSON.stringify(content)).digest("hex");
|
|
118
|
+
return { snapshotId, ...content };
|
|
119
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export interface IndexEntry {
|
|
2
|
+
readonly mode: string;
|
|
3
|
+
readonly objectId: string;
|
|
4
|
+
readonly stage: number;
|
|
5
|
+
}
|
|
6
|
+
export interface WorktreeContent {
|
|
7
|
+
readonly contentHash: string;
|
|
8
|
+
readonly executable: boolean;
|
|
9
|
+
readonly symbolicLink: boolean;
|
|
10
|
+
}
|
|
11
|
+
export interface SnapshotFile {
|
|
12
|
+
readonly path: string;
|
|
13
|
+
readonly indexEntries: readonly IndexEntry[];
|
|
14
|
+
readonly worktree: WorktreeContent | null;
|
|
15
|
+
}
|
|
16
|
+
export interface RepositoryChanges {
|
|
17
|
+
readonly staged: readonly string[];
|
|
18
|
+
readonly unstaged: readonly string[];
|
|
19
|
+
readonly untracked: readonly string[];
|
|
20
|
+
}
|
|
21
|
+
export interface RepositorySnapshot {
|
|
22
|
+
readonly schemaVersion: 1;
|
|
23
|
+
readonly snapshotId: string;
|
|
24
|
+
readonly repositoryId: string;
|
|
25
|
+
readonly headCommit: string;
|
|
26
|
+
readonly indexVersion: number;
|
|
27
|
+
readonly files: readonly SnapshotFile[];
|
|
28
|
+
readonly changes: RepositoryChanges;
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/snapshots/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC;IAC7B,QAAQ,CAAC,YAAY,EAAE,OAAO,CAAC;CAChC;AAED,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,YAAY,EAAE,SAAS,UAAU,EAAE,CAAC;IAC7C,QAAQ,CAAC,QAAQ,EAAE,eAAe,GAAG,IAAI,CAAC;CAC3C;AAED,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC;IACnC,QAAQ,CAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,CAAC;IACrC,QAAQ,CAAC,SAAS,EAAE,SAAS,MAAM,EAAE,CAAC;CACvC;AAED,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,aAAa,EAAE,CAAC,CAAC;IAC1B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,KAAK,EAAE,SAAS,YAAY,EAAE,CAAC;IACxC,QAAQ,CAAC,OAAO,EAAE,iBAAiB,CAAC;CACrC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { DatabaseSync as NodeDatabaseSync } from "node:sqlite";
|
|
2
|
+
import type { GitRepository } from "../repository/types.js";
|
|
3
|
+
export declare const CURRENT_ATLAS_SCHEMA_VERSION = 5;
|
|
4
|
+
export declare class AtlasDatabase implements Disposable {
|
|
5
|
+
#private;
|
|
6
|
+
readonly databasePath: string;
|
|
7
|
+
readonly connection: NodeDatabaseSync;
|
|
8
|
+
constructor(repository: GitRepository);
|
|
9
|
+
get schemaVersion(): number;
|
|
10
|
+
close(): void;
|
|
11
|
+
[Symbol.dispose](): void;
|
|
12
|
+
private applyMigrations;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=atlas-database.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"atlas-database.d.ts","sourceRoot":"","sources":["../../src/storage/atlas-database.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,IAAI,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAEpE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAE5D,eAAO,MAAM,4BAA4B,IAAI,CAAC;AAyc9C,qBAAa,aAAc,YAAW,UAAU;;IAC9C,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,UAAU,EAAE,gBAAgB,CAAC;gBAG1B,UAAU,EAAE,aAAa;IAuCrC,IAAI,aAAa,IAAI,MAAM,CAM1B;IAED,KAAK,IAAI,IAAI;IAQb,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,IAAI;IAIxB,OAAO,CAAC,eAAe;CAoCxB"}
|