semantic-atlas 0.4.0 → 2.0.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 +134 -166
- package/.agents/skills/semantic-atlas/agents/openai.yaml +4 -0
- package/.agents/skills/semantic-atlas/references/observations.md +130 -0
- package/.agents/skills/semantic-atlas/scripts/query-context.mjs +110 -0
- package/.agents/skills/semantic-atlas-maintenance/SKILL.md +93 -0
- package/.agents/skills/semantic-atlas-maintenance/agents/openai.yaml +4 -0
- package/.agents/skills/semantic-atlas-maintenance/references/reconciliation.md +56 -0
- package/README.md +133 -265
- package/dist/application/map-application.d.ts +24 -0
- package/dist/application/map-application.d.ts.map +1 -0
- package/dist/application/map-application.js +134 -0
- package/dist/application/map-application.js.map +1 -0
- package/dist/cli/bin.js +6 -42
- package/dist/cli/bin.js.map +1 -0
- package/dist/cli/observation-commands.d.ts +16 -0
- package/dist/cli/observation-commands.d.ts.map +1 -0
- package/dist/cli/observation-commands.js +118 -0
- package/dist/cli/observation-commands.js.map +1 -0
- package/dist/cli/projection-writer.d.ts +2 -0
- package/dist/cli/projection-writer.d.ts.map +1 -0
- package/dist/cli/projection-writer.js +9 -0
- package/dist/cli/projection-writer.js.map +1 -0
- package/dist/cli/reconciliation-command.d.ts +7 -0
- package/dist/cli/reconciliation-command.d.ts.map +1 -0
- package/dist/cli/reconciliation-command.js +33 -0
- package/dist/cli/reconciliation-command.js.map +1 -0
- package/dist/cli/run-cli.d.ts +21 -0
- package/dist/cli/run-cli.d.ts.map +1 -0
- package/dist/cli/run-cli.js +299 -0
- package/dist/cli/run-cli.js.map +1 -0
- package/dist/contracts/cli.d.ts +166 -1211
- package/dist/contracts/cli.d.ts.map +1 -1
- package/dist/contracts/cli.js +2 -232
- package/dist/contracts/cli.js.map +1 -0
- package/dist/contracts/insights.d.ts +39 -1
- package/dist/contracts/insights.d.ts.map +1 -1
- package/dist/contracts/insights.js +2 -1
- package/dist/contracts/insights.js.map +1 -0
- package/dist/contracts/map.d.ts +154 -0
- package/dist/contracts/map.d.ts.map +1 -0
- package/dist/contracts/map.js +60 -0
- package/dist/contracts/map.js.map +1 -0
- package/dist/contracts/observation.d.ts +414 -0
- package/dist/contracts/observation.d.ts.map +1 -0
- package/dist/contracts/observation.js +125 -0
- package/dist/contracts/observation.js.map +1 -0
- package/dist/contracts/projection.d.ts +7 -0
- package/dist/contracts/projection.d.ts.map +1 -0
- package/dist/contracts/projection.js +2 -0
- package/dist/contracts/projection.js.map +1 -0
- package/dist/contracts/reconciliation.d.ts +40 -0
- package/dist/contracts/reconciliation.d.ts.map +1 -0
- package/dist/contracts/reconciliation.js +2 -0
- package/dist/contracts/reconciliation.js.map +1 -0
- package/dist/index.d.ts +7 -17
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -9
- package/dist/index.js.map +1 -0
- package/dist/insights/insight-service.d.ts +14 -0
- package/dist/insights/insight-service.d.ts.map +1 -0
- package/dist/insights/insight-service.js +129 -0
- package/dist/insights/insight-service.js.map +1 -0
- package/dist/map/business-graph.d.ts +32 -0
- package/dist/map/business-graph.d.ts.map +1 -0
- package/dist/map/business-graph.js +122 -0
- package/dist/map/business-graph.js.map +1 -0
- package/dist/map/map-document-loader.d.ts +13 -0
- package/dist/map/map-document-loader.d.ts.map +1 -0
- package/dist/map/map-document-loader.js +86 -0
- package/dist/map/map-document-loader.js.map +1 -0
- package/dist/map/map-validator.d.ts +12 -0
- package/dist/map/map-validator.d.ts.map +1 -0
- package/dist/map/map-validator.js +322 -0
- package/dist/map/map-validator.js.map +1 -0
- package/dist/observations/observation-application.d.ts +23 -0
- package/dist/observations/observation-application.d.ts.map +1 -0
- package/dist/observations/observation-application.js +62 -0
- package/dist/observations/observation-application.js.map +1 -0
- package/dist/observations/observation-claim-manager.d.ts +17 -0
- package/dist/observations/observation-claim-manager.d.ts.map +1 -0
- package/dist/observations/observation-claim-manager.js +198 -0
- package/dist/observations/observation-claim-manager.js.map +1 -0
- package/dist/observations/observation-store.d.ts +43 -0
- package/dist/observations/observation-store.d.ts.map +1 -0
- package/dist/observations/observation-store.js +213 -0
- package/dist/observations/observation-store.js.map +1 -0
- package/dist/observations/repository-identity.d.ts +12 -0
- package/dist/observations/repository-identity.d.ts.map +1 -0
- package/dist/observations/repository-identity.js +108 -0
- package/dist/observations/repository-identity.js.map +1 -0
- package/dist/query/context-query-service.d.ts +15 -0
- package/dist/query/context-query-service.d.ts.map +1 -0
- package/dist/query/context-query-service.js +36 -0
- package/dist/query/context-query-service.js.map +1 -0
- package/dist/reconciliation/reconciliation-service.d.ts +10 -0
- package/dist/reconciliation/reconciliation-service.d.ts.map +1 -0
- package/dist/reconciliation/reconciliation-service.js +114 -0
- package/dist/reconciliation/reconciliation-service.js.map +1 -0
- package/dist/rendering/map-projector.d.ts +8 -0
- package/dist/rendering/map-projector.d.ts.map +1 -0
- package/dist/rendering/map-projector.js +386 -0
- package/dist/rendering/map-projector.js.map +1 -0
- package/dist/setup/managed-skill-installer.d.ts +60 -0
- package/dist/setup/managed-skill-installer.d.ts.map +1 -0
- package/dist/setup/managed-skill-installer.js +293 -0
- package/dist/setup/managed-skill-installer.js.map +1 -0
- package/dist/setup/package-identity.d.ts +6 -0
- package/dist/setup/package-identity.d.ts.map +1 -0
- package/dist/setup/package-identity.js +16 -0
- package/dist/setup/package-identity.js.map +1 -0
- package/dist/setup/package-upgrader.d.ts +10 -22
- package/dist/setup/package-upgrader.d.ts.map +1 -1
- package/dist/setup/package-upgrader.js +60 -76
- package/dist/setup/package-upgrader.js.map +1 -0
- package/docs/architecture.md +426 -0
- package/docs/evaluation.md +220 -174
- package/docs/index.md +27 -45
- package/docs/map-format.md +225 -0
- package/docs/observations.md +167 -0
- package/docs/product-contract.md +282 -165
- package/examples/commerce.yaml +204 -0
- package/package.json +31 -32
- package/.agents/skills/semantic-atlas/references/graph-patch.md +0 -190
- package/.agents/skills/semantic-atlas/references/product-feedback.md +0 -34
- package/.agents/skills/semantic-atlas/references/result-routing.md +0 -104
- package/.agents/skills/semantic-atlas/references/snapshot-bootstrap.md +0 -42
- package/.agents/skills/semantic-atlas-insights/SKILL.md +0 -55
- package/README.zh-CN.md +0 -296
- package/dist/business-flow/business-flow-derivation-service.d.ts +0 -11
- package/dist/business-flow/business-flow-derivation-service.d.ts.map +0 -1
- package/dist/business-flow/business-flow-derivation-service.js +0 -151
- package/dist/business-flow/business-flow-draft.d.ts +0 -16
- package/dist/business-flow/business-flow-draft.d.ts.map +0 -1
- package/dist/business-flow/business-flow-draft.js +0 -150
- package/dist/business-flow/framework-business-strategy.d.ts +0 -7
- package/dist/business-flow/framework-business-strategy.d.ts.map +0 -1
- package/dist/business-flow/framework-business-strategy.js +0 -1
- package/dist/business-flow/strategies/bullmq-business-strategy.d.ts +0 -10
- package/dist/business-flow/strategies/bullmq-business-strategy.d.ts.map +0 -1
- package/dist/business-flow/strategies/bullmq-business-strategy.js +0 -79
- package/dist/business-flow/strategies/called-operation-derivation.d.ts +0 -13
- package/dist/business-flow/strategies/called-operation-derivation.d.ts.map +0 -1
- package/dist/business-flow/strategies/called-operation-derivation.js +0 -32
- package/dist/business-flow/strategies/graphql-business-strategy.d.ts +0 -8
- package/dist/business-flow/strategies/graphql-business-strategy.d.ts.map +0 -1
- package/dist/business-flow/strategies/graphql-business-strategy.js +0 -65
- package/dist/business-flow/strategies/nestjs-business-strategy.d.ts +0 -8
- package/dist/business-flow/strategies/nestjs-business-strategy.d.ts.map +0 -1
- package/dist/business-flow/strategies/nestjs-business-strategy.js +0 -72
- package/dist/business-flow/strategies/strategy-helpers.d.ts +0 -32
- package/dist/business-flow/strategies/strategy-helpers.d.ts.map +0 -1
- package/dist/business-flow/strategies/strategy-helpers.js +0 -49
- package/dist/business-flow/strategies/typeorm-business-strategy.d.ts +0 -10
- package/dist/business-flow/strategies/typeorm-business-strategy.d.ts.map +0 -1
- package/dist/business-flow/strategies/typeorm-business-strategy.js +0 -136
- package/dist/business-flow/strategies/verified-invariant-strategy.d.ts +0 -5
- package/dist/business-flow/strategies/verified-invariant-strategy.d.ts.map +0 -1
- package/dist/business-flow/strategies/verified-invariant-strategy.js +0 -38
- package/dist/business-flow/strategies/verified-test-strategy.d.ts +0 -5
- package/dist/business-flow/strategies/verified-test-strategy.d.ts.map +0 -1
- package/dist/business-flow/strategies/verified-test-strategy.js +0 -26
- package/dist/business-flow/structural-flow-catalog.d.ts +0 -21
- package/dist/business-flow/structural-flow-catalog.d.ts.map +0 -1
- package/dist/business-flow/structural-flow-catalog.js +0 -125
- package/dist/business-flow/types.d.ts +0 -51
- package/dist/business-flow/types.d.ts.map +0 -1
- package/dist/business-flow/types.js +0 -1
- package/dist/cli/argument-parser.d.ts +0 -3
- package/dist/cli/argument-parser.d.ts.map +0 -1
- package/dist/cli/argument-parser.js +0 -200
- package/dist/cli/cli-application.d.ts +0 -39
- package/dist/cli/cli-application.d.ts.map +0 -1
- package/dist/cli/cli-application.js +0 -571
- package/dist/cli/cli-error.d.ts +0 -12
- package/dist/cli/cli-error.d.ts.map +0 -1
- package/dist/cli/cli-error.js +0 -44
- package/dist/cli/cli-presenter.d.ts +0 -14
- package/dist/cli/cli-presenter.d.ts.map +0 -1
- package/dist/cli/cli-presenter.js +0 -36
- package/dist/cli/insights-cli.d.ts +0 -6
- package/dist/cli/insights-cli.d.ts.map +0 -1
- package/dist/cli/insights-cli.js +0 -236
- package/dist/cli/main.d.ts +0 -3
- package/dist/cli/main.d.ts.map +0 -1
- package/dist/cli/main.js +0 -137
- package/dist/cli/standalone-cli.d.ts +0 -3
- package/dist/cli/standalone-cli.d.ts.map +0 -1
- package/dist/cli/standalone-cli.js +0 -104
- package/dist/cli/types.d.ts +0 -49
- package/dist/cli/types.d.ts.map +0 -1
- package/dist/cli/types.js +0 -1
- package/dist/cli/web-cli.d.ts +0 -9
- package/dist/cli/web-cli.d.ts.map +0 -1
- package/dist/cli/web-cli.js +0 -134
- package/dist/contracts/graph.d.ts +0 -266
- package/dist/contracts/graph.d.ts.map +0 -1
- package/dist/contracts/graph.js +0 -182
- package/dist/contracts/identifiers.d.ts +0 -4
- package/dist/contracts/identifiers.d.ts.map +0 -1
- package/dist/contracts/identifiers.js +0 -7
- package/dist/contracts/public-contracts.d.ts +0 -5
- package/dist/contracts/public-contracts.d.ts.map +0 -1
- package/dist/contracts/public-contracts.js +0 -4
- package/dist/evaluation/comparison.d.ts +0 -30
- package/dist/evaluation/comparison.d.ts.map +0 -1
- package/dist/evaluation/comparison.js +0 -108
- package/dist/evaluation/contracts.d.ts +0 -301
- package/dist/evaluation/contracts.d.ts.map +0 -1
- package/dist/evaluation/contracts.js +0 -413
- package/dist/graph/graph-store.d.ts +0 -55
- package/dist/graph/graph-store.d.ts.map +0 -1
- package/dist/graph/graph-store.js +0 -912
- package/dist/graph/types.d.ts +0 -189
- package/dist/graph/types.d.ts.map +0 -1
- package/dist/graph/types.js +0 -1
- package/dist/insights/contracts.d.ts +0 -266
- package/dist/insights/contracts.d.ts.map +0 -1
- package/dist/insights/contracts.js +0 -124
- package/dist/insights/insights-store.d.ts +0 -73
- package/dist/insights/insights-store.d.ts.map +0 -1
- package/dist/insights/insights-store.js +0 -246
- package/dist/knowledge/business-knowledge-service.d.ts +0 -24
- package/dist/knowledge/business-knowledge-service.d.ts.map +0 -1
- package/dist/knowledge/business-knowledge-service.js +0 -200
- package/dist/knowledge/graph-patch-conflict-error.d.ts +0 -8
- package/dist/knowledge/graph-patch-conflict-error.d.ts.map +0 -1
- package/dist/knowledge/graph-patch-conflict-error.js +0 -12
- package/dist/knowledge/structural-target-binding.d.ts +0 -14
- package/dist/knowledge/structural-target-binding.d.ts.map +0 -1
- package/dist/knowledge/structural-target-binding.js +0 -11
- package/dist/package-metadata.d.ts +0 -2
- package/dist/package-metadata.d.ts.map +0 -1
- package/dist/package-metadata.js +0 -9
- package/dist/repository/git-command.d.ts +0 -3
- package/dist/repository/git-command.d.ts.map +0 -1
- package/dist/repository/git-command.js +0 -25
- package/dist/repository/repository-inspector.d.ts +0 -8
- package/dist/repository/repository-inspector.d.ts.map +0 -1
- package/dist/repository/repository-inspector.js +0 -97
- package/dist/repository/repository-language-support.d.ts +0 -14
- package/dist/repository/repository-language-support.d.ts.map +0 -1
- package/dist/repository/repository-language-support.js +0 -64
- package/dist/repository/types.d.ts +0 -9
- package/dist/repository/types.d.ts.map +0 -1
- package/dist/repository/types.js +0 -1
- package/dist/runtime/sqlite-compatibility-process.d.ts +0 -8
- package/dist/runtime/sqlite-compatibility-process.d.ts.map +0 -1
- package/dist/runtime/sqlite-compatibility-process.js +0 -20
- package/dist/setup/skill-installer.d.ts +0 -20
- package/dist/setup/skill-installer.d.ts.map +0 -1
- package/dist/setup/skill-installer.js +0 -187
- package/dist/snapshots/repository-snapshot.d.ts +0 -4
- package/dist/snapshots/repository-snapshot.d.ts.map +0 -1
- package/dist/snapshots/repository-snapshot.js +0 -119
- package/dist/snapshots/types.d.ts +0 -30
- package/dist/snapshots/types.d.ts.map +0 -1
- package/dist/snapshots/types.js +0 -1
- package/dist/storage/atlas-database.d.ts +0 -25
- package/dist/storage/atlas-database.d.ts.map +0 -1
- package/dist/storage/atlas-database.js +0 -483
- package/dist/storage/snapshot-store.d.ts +0 -19
- package/dist/storage/snapshot-store.d.ts.map +0 -1
- package/dist/storage/snapshot-store.js +0 -74
- package/dist/structural-backend/codegraph-backend.d.ts +0 -57
- package/dist/structural-backend/codegraph-backend.d.ts.map +0 -1
- package/dist/structural-backend/codegraph-backend.js +0 -1230
- package/dist/structural-backend/codegraph-worker-client.d.ts +0 -5
- package/dist/structural-backend/codegraph-worker-client.d.ts.map +0 -1
- package/dist/structural-backend/codegraph-worker-client.js +0 -118
- package/dist/structural-backend/codegraph-worker-protocol.d.ts +0 -35
- package/dist/structural-backend/codegraph-worker-protocol.d.ts.map +0 -1
- package/dist/structural-backend/codegraph-worker-protocol.js +0 -1
- package/dist/structural-backend/codegraph-worker.d.ts +0 -2
- package/dist/structural-backend/codegraph-worker.d.ts.map +0 -1
- package/dist/structural-backend/codegraph-worker.js +0 -131
- package/dist/structural-backend/process-instance.d.ts +0 -18
- package/dist/structural-backend/process-instance.d.ts.map +0 -1
- package/dist/structural-backend/process-instance.js +0 -207
- package/dist/structural-backend/structural-fact-changes.d.ts +0 -7
- package/dist/structural-backend/structural-fact-changes.d.ts.map +0 -1
- package/dist/structural-backend/structural-fact-changes.js +0 -78
- package/dist/structural-backend/structural-projection-bootstrapper.d.ts +0 -10
- package/dist/structural-backend/structural-projection-bootstrapper.d.ts.map +0 -1
- package/dist/structural-backend/structural-projection-bootstrapper.js +0 -295
- package/dist/structural-backend/structural-publication.d.ts +0 -13
- package/dist/structural-backend/structural-publication.d.ts.map +0 -1
- package/dist/structural-backend/structural-publication.js +0 -255
- package/dist/structural-backend/structural-write-lock.d.ts +0 -8
- package/dist/structural-backend/structural-write-lock.d.ts.map +0 -1
- package/dist/structural-backend/structural-write-lock.js +0 -415
- package/dist/structural-backend/types.d.ts +0 -144
- package/dist/structural-backend/types.d.ts.map +0 -1
- package/dist/structural-backend/types.js +0 -11
- package/dist/web/application/atlas-read-service.d.ts +0 -27
- package/dist/web/application/atlas-read-service.d.ts.map +0 -1
- package/dist/web/application/atlas-read-service.js +0 -216
- package/dist/web/application/primary-repository-catalog.d.ts +0 -15
- package/dist/web/application/primary-repository-catalog.d.ts.map +0 -1
- package/dist/web/application/primary-repository-catalog.js +0 -202
- package/dist/web/application/types.d.ts +0 -41
- package/dist/web/application/types.d.ts.map +0 -1
- package/dist/web/application/types.js +0 -1
- package/dist/web/server/api-router.d.ts +0 -4
- package/dist/web/server/api-router.d.ts.map +0 -1
- package/dist/web/server/api-router.js +0 -151
- package/dist/web/server/local-web-server.d.ts +0 -12
- package/dist/web/server/local-web-server.d.ts.map +0 -1
- package/dist/web/server/local-web-server.js +0 -100
- package/dist/web-client/assets/index-DneaErDj.css +0 -1
- package/dist/web-client/assets/index-cze_4vtt.js +0 -2
- package/dist/web-client/assets/index-cze_4vtt.js.map +0 -1
- package/dist/web-client/index.html +0 -61
- package/dist/world/business-map-projector.d.ts +0 -14
- package/dist/world/business-map-projector.d.ts.map +0 -1
- package/dist/world/business-map-projector.js +0 -178
- package/dist/world/types.d.ts +0 -77
- package/dist/world/types.d.ts.map +0 -1
- package/dist/world/types.js +0 -1
- package/dist/world/world-graph-query.d.ts +0 -30
- package/dist/world/world-graph-query.d.ts.map +0 -1
- package/dist/world/world-graph-query.js +0 -252
- package/dist/world/world-model-service.d.ts +0 -21
- package/dist/world/world-model-service.d.ts.map +0 -1
- package/dist/world/world-model-service.js +0 -219
- package/dist/world/world-snapshot-store.d.ts +0 -41
- package/dist/world/world-snapshot-store.d.ts.map +0 -1
- package/dist/world/world-snapshot-store.js +0 -581
- package/docs/README.md +0 -30
- package/docs/architecture/codegraph-backend.md +0 -190
- package/docs/architecture/continuous-business-learning.md +0 -240
- package/docs/architecture/web-viewer.md +0 -225
- package/docs/contracts/cli-v1.md +0 -179
- package/docs/contracts/graph-model.md +0 -106
- package/docs/contracts/graph-patch-v1.md +0 -105
- package/docs/contracts/http-api-v1.md +0 -155
- package/docs/contracts/insights-v1.md +0 -84
- package/docs/log.md +0 -159
- package/docs/mindmaps/semantic-atlas-overview.drawio +0 -255
- package/docs/mindmaps/semantic-atlas-overview.png +0 -0
- package/docs/mindmaps/semantic-atlas-overview.zh-CN.drawio +0 -255
- package/docs/mindmaps/semantic-atlas-overview.zh-CN.png +0 -0
- package/schemas/cli-envelope-v1.schema.json +0 -1244
- package/schemas/evaluation-plan-v1.schema.json +0 -211
- package/schemas/evaluation-run-v1.schema.json +0 -659
- package/schemas/graph-patch-v1.schema.json +0 -392
- package/schemas/insights-envelope-v1.schema.json +0 -428
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
import { createHash } from "node:crypto";
|
|
2
|
-
import { realpath } from "node:fs/promises";
|
|
3
|
-
import { basename, isAbsolute, resolve } from "node:path";
|
|
4
|
-
import { runGit, runGitText } from "./git-command.js";
|
|
5
|
-
const SUPPORTED_SOURCE_EXTENSIONS = new Set([
|
|
6
|
-
".cjs",
|
|
7
|
-
".cts",
|
|
8
|
-
".js",
|
|
9
|
-
".jsx",
|
|
10
|
-
".mjs",
|
|
11
|
-
".mts",
|
|
12
|
-
".ts",
|
|
13
|
-
".tsx",
|
|
14
|
-
]);
|
|
15
|
-
function resolveGitPath(workingDirectory, path) {
|
|
16
|
-
return isAbsolute(path) ? path : resolve(workingDirectory, path);
|
|
17
|
-
}
|
|
18
|
-
function normalizeIdentityPath(path) {
|
|
19
|
-
const normalized = path.replaceAll("\\", "/");
|
|
20
|
-
return process.platform === "win32" ? normalized.toLowerCase() : normalized;
|
|
21
|
-
}
|
|
22
|
-
function createRepositoryId(commonGitDirectory) {
|
|
23
|
-
return createHash("sha256")
|
|
24
|
-
.update("semantic-atlas:git-common-directory:v1\0")
|
|
25
|
-
.update(normalizeIdentityPath(commonGitDirectory))
|
|
26
|
-
.digest("hex");
|
|
27
|
-
}
|
|
28
|
-
function compareRepositoryPaths(left, right) {
|
|
29
|
-
return left < right ? -1 : left > right ? 1 : 0;
|
|
30
|
-
}
|
|
31
|
-
async function discoverWorktreeRoots(workingDirectory) {
|
|
32
|
-
const output = await runGit(workingDirectory, ["worktree", "list", "--porcelain", "-z"]);
|
|
33
|
-
const worktreePaths = output
|
|
34
|
-
.toString("utf8")
|
|
35
|
-
.split("\0")
|
|
36
|
-
.filter((field) => field.startsWith("worktree "))
|
|
37
|
-
.map((field) => resolveGitPath(workingDirectory, field.slice("worktree ".length)));
|
|
38
|
-
return [...new Set(worktreePaths)].sort(compareRepositoryPaths);
|
|
39
|
-
}
|
|
40
|
-
export function isSupportedSource(path) {
|
|
41
|
-
const extensionIndex = path.lastIndexOf(".");
|
|
42
|
-
if (extensionIndex < 0) {
|
|
43
|
-
return false;
|
|
44
|
-
}
|
|
45
|
-
return SUPPORTED_SOURCE_EXTENSIONS.has(path.slice(extensionIndex).toLowerCase());
|
|
46
|
-
}
|
|
47
|
-
export function isTargetSource(path) {
|
|
48
|
-
const fileName = basename(path);
|
|
49
|
-
return (isSupportedSource(path) ||
|
|
50
|
-
fileName === "package.json" ||
|
|
51
|
-
/^(?:ts|js)config(?:\.[^.]+)*\.json$/u.test(fileName));
|
|
52
|
-
}
|
|
53
|
-
export async function inspectGitRepository(startPath) {
|
|
54
|
-
const worktreeRoot = await realpath(await runGitText(startPath, ["rev-parse", "--show-toplevel"]));
|
|
55
|
-
const gitDirectory = await realpath(resolveGitPath(startPath, await runGitText(startPath, ["rev-parse", "--git-dir"])));
|
|
56
|
-
const commonGitDirectory = await realpath(resolveGitPath(startPath, await runGitText(startPath, ["rev-parse", "--git-common-dir"])));
|
|
57
|
-
const indexPath = resolveGitPath(startPath, await runGitText(startPath, ["rev-parse", "--git-path", "index"]));
|
|
58
|
-
const worktreeRoots = await discoverWorktreeRoots(worktreeRoot);
|
|
59
|
-
return {
|
|
60
|
-
repositoryId: createRepositoryId(commonGitDirectory),
|
|
61
|
-
worktreeRoot,
|
|
62
|
-
gitDirectory,
|
|
63
|
-
commonGitDirectory,
|
|
64
|
-
worktreeRoots,
|
|
65
|
-
indexPath,
|
|
66
|
-
};
|
|
67
|
-
}
|
|
68
|
-
export async function discoverTargetSources(repository) {
|
|
69
|
-
const output = await runGit(repository.worktreeRoot, [
|
|
70
|
-
"ls-files",
|
|
71
|
-
"--cached",
|
|
72
|
-
"--others",
|
|
73
|
-
"--exclude-standard",
|
|
74
|
-
"-z",
|
|
75
|
-
]);
|
|
76
|
-
return output
|
|
77
|
-
.toString("utf8")
|
|
78
|
-
.split("\0")
|
|
79
|
-
.filter((path) => path.length > 0 && isTargetSource(path))
|
|
80
|
-
.sort(compareRepositoryPaths);
|
|
81
|
-
}
|
|
82
|
-
export async function readCurrentHead(repository) {
|
|
83
|
-
return runGitText(repository.worktreeRoot, ["rev-parse", "--verify", "HEAD"]);
|
|
84
|
-
}
|
|
85
|
-
export async function readCurrentBranch(repository) {
|
|
86
|
-
try {
|
|
87
|
-
return await runGitText(repository.worktreeRoot, [
|
|
88
|
-
"symbolic-ref",
|
|
89
|
-
"--quiet",
|
|
90
|
-
"--short",
|
|
91
|
-
"HEAD",
|
|
92
|
-
]);
|
|
93
|
-
}
|
|
94
|
-
catch {
|
|
95
|
-
return null;
|
|
96
|
-
}
|
|
97
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1,64 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
package/dist/repository/types.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export interface SqliteRuntimeState {
|
|
2
|
-
readonly nodeVersion: string;
|
|
3
|
-
readonly execArguments: readonly string[];
|
|
4
|
-
readonly sqliteAvailable: boolean;
|
|
5
|
-
}
|
|
6
|
-
export declare function requiresSqliteCompatibilityProcess(runtime: SqliteRuntimeState): boolean;
|
|
7
|
-
export declare function createSqliteCompatibilityArguments(entryPoint: string, applicationArguments: readonly string[], inheritedExecArguments?: readonly string[]): readonly string[];
|
|
8
|
-
//# sourceMappingURL=sqlite-compatibility-process.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sqlite-compatibility-process.d.ts","sourceRoot":"","sources":["../../src/runtime/sqlite-compatibility-process.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,aAAa,EAAE,SAAS,MAAM,EAAE,CAAC;IAC1C,QAAQ,CAAC,eAAe,EAAE,OAAO,CAAC;CACnC;AAED,wBAAgB,kCAAkC,CAAC,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAWvF;AAED,wBAAgB,kCAAkC,CAChD,UAAU,EAAE,MAAM,EAClB,oBAAoB,EAAE,SAAS,MAAM,EAAE,EACvC,sBAAsB,GAAE,SAAS,MAAM,EAAO,GAC7C,SAAS,MAAM,EAAE,CAYnB"}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
export function requiresSqliteCompatibilityProcess(runtime) {
|
|
2
|
-
const nodeMajor = Number.parseInt(runtime.nodeVersion, 10);
|
|
3
|
-
const warningAlreadyDisabled = runtime.execArguments.some((argument) => (argument === "--no-warnings"
|
|
4
|
-
|| argument === "--disable-warning=ExperimentalWarning"));
|
|
5
|
-
if (nodeMajor < 24 && !warningAlreadyDisabled) {
|
|
6
|
-
return true;
|
|
7
|
-
}
|
|
8
|
-
return !runtime.sqliteAvailable;
|
|
9
|
-
}
|
|
10
|
-
export function createSqliteCompatibilityArguments(entryPoint, applicationArguments, inheritedExecArguments = []) {
|
|
11
|
-
const loaderArguments = inheritedExecArguments.filter((argument) => (argument !== "--experimental-sqlite"
|
|
12
|
-
&& argument !== "--no-experimental-sqlite"));
|
|
13
|
-
return [
|
|
14
|
-
"--experimental-sqlite",
|
|
15
|
-
"--disable-warning=ExperimentalWarning",
|
|
16
|
-
...loaderArguments,
|
|
17
|
-
entryPoint,
|
|
18
|
-
...applicationArguments,
|
|
19
|
-
];
|
|
20
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
export interface SkillInstallerOptions {
|
|
2
|
-
readonly sourceDirectory?: string;
|
|
3
|
-
readonly insightsSourceDirectory?: string;
|
|
4
|
-
readonly userHome?: string;
|
|
5
|
-
readonly version: string;
|
|
6
|
-
}
|
|
7
|
-
export interface SkillInstallationResult {
|
|
8
|
-
readonly outcome: "installed" | "updated" | "current";
|
|
9
|
-
readonly targetDirectory: string;
|
|
10
|
-
readonly insightsTargetDirectory: string;
|
|
11
|
-
readonly removedLegacyDirectories: readonly string[];
|
|
12
|
-
}
|
|
13
|
-
export declare class SkillInstaller {
|
|
14
|
-
#private;
|
|
15
|
-
constructor(options: SkillInstallerOptions);
|
|
16
|
-
install(): Promise<SkillInstallationResult>;
|
|
17
|
-
private existingLegacyDirectories;
|
|
18
|
-
}
|
|
19
|
-
export declare function resolveBundledSkillDirectory(name?: string): string;
|
|
20
|
-
//# sourceMappingURL=skill-installer.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"skill-installer.d.ts","sourceRoot":"","sources":["../../src/setup/skill-installer.ts"],"names":[],"mappings":"AAwBA,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,eAAe,CAAC,EAAE,MAAM,CAAC;IAClC,QAAQ,CAAC,uBAAuB,CAAC,EAAE,MAAM,CAAC;IAC1C,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,uBAAuB;IACtC,QAAQ,CAAC,OAAO,EAAE,WAAW,GAAG,SAAS,GAAG,SAAS,CAAC;IACtD,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;IACjC,QAAQ,CAAC,uBAAuB,EAAE,MAAM,CAAC;IACzC,QAAQ,CAAC,wBAAwB,EAAE,SAAS,MAAM,EAAE,CAAC;CACtD;AAED,qBAAa,cAAc;;gBAQb,OAAO,EAAE,qBAAqB;IAWpC,OAAO,IAAI,OAAO,CAAC,uBAAuB,CAAC;YAuDnC,yBAAyB;CAUxC;AAED,wBAAgB,4BAA4B,CAAC,IAAI,SAAY,GAAG,MAAM,CAGrE"}
|
|
@@ -1,187 +0,0 @@
|
|
|
1
|
-
import { createHash, randomUUID } from "node:crypto";
|
|
2
|
-
import { access, cp, mkdir, readFile, readdir, rename, rm, writeFile, } from "node:fs/promises";
|
|
3
|
-
import { homedir } from "node:os";
|
|
4
|
-
import { dirname, join, relative } from "node:path";
|
|
5
|
-
import { fileURLToPath } from "node:url";
|
|
6
|
-
const skillName = "semantic-atlas";
|
|
7
|
-
const insightsSkillName = "semantic-atlas-insights";
|
|
8
|
-
const installationMarkerName = ".semantic-atlas-managed.json";
|
|
9
|
-
export class SkillInstaller {
|
|
10
|
-
#sourceDirectory;
|
|
11
|
-
#targetDirectory;
|
|
12
|
-
#insightsSourceDirectory;
|
|
13
|
-
#insightsTargetDirectory;
|
|
14
|
-
#legacyDirectories;
|
|
15
|
-
#version;
|
|
16
|
-
constructor(options) {
|
|
17
|
-
const userHome = options.userHome ?? homedir();
|
|
18
|
-
this.#sourceDirectory = options.sourceDirectory ?? resolveBundledSkillDirectory();
|
|
19
|
-
this.#targetDirectory = join(userHome, ".agents", "skills", skillName);
|
|
20
|
-
this.#insightsSourceDirectory = options.insightsSourceDirectory
|
|
21
|
-
?? resolveBundledSkillDirectory(insightsSkillName);
|
|
22
|
-
this.#insightsTargetDirectory = join(userHome, ".agents", "skills", insightsSkillName);
|
|
23
|
-
this.#legacyDirectories = [join(userHome, ".codex", "skills", skillName)];
|
|
24
|
-
this.#version = options.version;
|
|
25
|
-
}
|
|
26
|
-
async install() {
|
|
27
|
-
await requireSemanticAtlasSkill(this.#sourceDirectory, "bundled Skill");
|
|
28
|
-
await requireManagedSkill(this.#insightsSourceDirectory, insightsSkillName, "bundled insights Skill");
|
|
29
|
-
const targetExists = await exists(this.#targetDirectory);
|
|
30
|
-
if (targetExists) {
|
|
31
|
-
await requireSemanticAtlasSkill(this.#targetDirectory, "existing shared Skill");
|
|
32
|
-
}
|
|
33
|
-
const insightsTargetExists = await exists(this.#insightsTargetDirectory);
|
|
34
|
-
if (insightsTargetExists) {
|
|
35
|
-
await requireManagedSkill(this.#insightsTargetDirectory, insightsSkillName, "existing shared insights Skill");
|
|
36
|
-
}
|
|
37
|
-
const existingLegacyDirectories = await this.existingLegacyDirectories();
|
|
38
|
-
for (const directory of existingLegacyDirectories) {
|
|
39
|
-
await requireSemanticAtlasSkill(directory, "legacy Codex Skill");
|
|
40
|
-
}
|
|
41
|
-
const sourceFingerprint = await fingerprintSkill(this.#sourceDirectory);
|
|
42
|
-
const targetCurrent = targetExists
|
|
43
|
-
&& await installedSkillIsCurrent(this.#targetDirectory, this.#version, sourceFingerprint);
|
|
44
|
-
if (!targetCurrent || existingLegacyDirectories.length > 0) {
|
|
45
|
-
await installSkillAtomically(this.#sourceDirectory, this.#targetDirectory, { version: this.#version, fingerprint: sourceFingerprint });
|
|
46
|
-
}
|
|
47
|
-
const insights = await installManagedSkill({
|
|
48
|
-
sourceDirectory: this.#insightsSourceDirectory,
|
|
49
|
-
targetDirectory: this.#insightsTargetDirectory,
|
|
50
|
-
version: this.#version,
|
|
51
|
-
});
|
|
52
|
-
for (const directory of existingLegacyDirectories) {
|
|
53
|
-
await rm(directory, { recursive: true, force: true });
|
|
54
|
-
}
|
|
55
|
-
return {
|
|
56
|
-
outcome: targetCurrent && insights === "current" && existingLegacyDirectories.length === 0
|
|
57
|
-
? "current"
|
|
58
|
-
: targetExists || insightsTargetExists
|
|
59
|
-
? "updated"
|
|
60
|
-
: "installed",
|
|
61
|
-
targetDirectory: this.#targetDirectory,
|
|
62
|
-
insightsTargetDirectory: this.#insightsTargetDirectory,
|
|
63
|
-
removedLegacyDirectories: existingLegacyDirectories,
|
|
64
|
-
};
|
|
65
|
-
}
|
|
66
|
-
async existingLegacyDirectories() {
|
|
67
|
-
const result = [];
|
|
68
|
-
for (const directory of this.#legacyDirectories) {
|
|
69
|
-
if (await exists(directory)) {
|
|
70
|
-
result.push(directory);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
return result;
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
export function resolveBundledSkillDirectory(name = skillName) {
|
|
77
|
-
const moduleDirectory = dirname(fileURLToPath(import.meta.url));
|
|
78
|
-
return join(moduleDirectory, "..", "..", ".agents", "skills", name);
|
|
79
|
-
}
|
|
80
|
-
async function installedSkillIsCurrent(directory, version, sourceFingerprint) {
|
|
81
|
-
const marker = await readInstallationMarker(join(directory, installationMarkerName));
|
|
82
|
-
if (marker?.version !== version || marker.fingerprint !== sourceFingerprint) {
|
|
83
|
-
return false;
|
|
84
|
-
}
|
|
85
|
-
return await fingerprintSkill(directory) === sourceFingerprint;
|
|
86
|
-
}
|
|
87
|
-
async function requireSemanticAtlasSkill(directory, description) {
|
|
88
|
-
return requireManagedSkill(directory, skillName, description);
|
|
89
|
-
}
|
|
90
|
-
async function requireManagedSkill(directory, name, description) {
|
|
91
|
-
let contents;
|
|
92
|
-
try {
|
|
93
|
-
contents = await readFile(join(directory, "SKILL.md"), "utf8");
|
|
94
|
-
}
|
|
95
|
-
catch {
|
|
96
|
-
throw new Error(`Refusing to replace ${description} at ${directory}: SKILL.md is missing`);
|
|
97
|
-
}
|
|
98
|
-
const escapedName = name.replace(/[.*+?^${}()|[\]\\]/gu, "\\$&");
|
|
99
|
-
const namePattern = new RegExp(`^---\\r?\\n[\\s\\S]*?^name:\\s*["']?${escapedName}["']?\\s*$[\\s\\S]*?^---\\s*$`, "mu");
|
|
100
|
-
if (!namePattern.test(contents)) {
|
|
101
|
-
throw new Error(`Refusing to replace unrelated Skill at ${directory}`);
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
async function installManagedSkill(options) {
|
|
105
|
-
const targetExists = await exists(options.targetDirectory);
|
|
106
|
-
const fingerprint = await fingerprintSkill(options.sourceDirectory);
|
|
107
|
-
const current = targetExists && await installedSkillIsCurrent(options.targetDirectory, options.version, fingerprint);
|
|
108
|
-
if (current)
|
|
109
|
-
return "current";
|
|
110
|
-
await installSkillAtomically(options.sourceDirectory, options.targetDirectory, {
|
|
111
|
-
version: options.version,
|
|
112
|
-
fingerprint,
|
|
113
|
-
});
|
|
114
|
-
return targetExists ? "updated" : "installed";
|
|
115
|
-
}
|
|
116
|
-
async function installSkillAtomically(sourceDirectory, targetDirectory, marker) {
|
|
117
|
-
const parent = dirname(targetDirectory);
|
|
118
|
-
const token = `${process.pid}-${randomUUID()}`;
|
|
119
|
-
const temporary = `${targetDirectory}.installing-${token}`;
|
|
120
|
-
const backup = `${targetDirectory}.backup-${token}`;
|
|
121
|
-
const targetExists = await exists(targetDirectory);
|
|
122
|
-
await mkdir(parent, { recursive: true });
|
|
123
|
-
await rm(temporary, { recursive: true, force: true });
|
|
124
|
-
await rm(backup, { recursive: true, force: true });
|
|
125
|
-
await cp(sourceDirectory, temporary, { recursive: true });
|
|
126
|
-
await writeFile(join(temporary, installationMarkerName), `${JSON.stringify(marker, null, 2)}\n`, "utf8");
|
|
127
|
-
if (targetExists)
|
|
128
|
-
await rename(targetDirectory, backup);
|
|
129
|
-
try {
|
|
130
|
-
await rename(temporary, targetDirectory);
|
|
131
|
-
}
|
|
132
|
-
catch (error) {
|
|
133
|
-
if (targetExists)
|
|
134
|
-
await rename(backup, targetDirectory);
|
|
135
|
-
throw error;
|
|
136
|
-
}
|
|
137
|
-
await rm(backup, { recursive: true, force: true });
|
|
138
|
-
}
|
|
139
|
-
async function readInstallationMarker(path) {
|
|
140
|
-
try {
|
|
141
|
-
const parsed = JSON.parse(await readFile(path, "utf8"));
|
|
142
|
-
return typeof parsed.version === "string" && /^[a-f0-9]{64}$/u.test(parsed.fingerprint ?? "")
|
|
143
|
-
? { version: parsed.version, fingerprint: parsed.fingerprint }
|
|
144
|
-
: undefined;
|
|
145
|
-
}
|
|
146
|
-
catch (error) {
|
|
147
|
-
if (error instanceof Error && "code" in error && error.code === "ENOENT") {
|
|
148
|
-
return undefined;
|
|
149
|
-
}
|
|
150
|
-
return undefined;
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
async function fingerprintSkill(directory) {
|
|
154
|
-
const hash = createHash("sha256");
|
|
155
|
-
for (const path of await listFiles(directory)) {
|
|
156
|
-
const relativePath = relative(directory, path);
|
|
157
|
-
hash.update(relativePath);
|
|
158
|
-
hash.update("\0");
|
|
159
|
-
hash.update(await readFile(path));
|
|
160
|
-
hash.update("\0");
|
|
161
|
-
}
|
|
162
|
-
return hash.digest("hex");
|
|
163
|
-
}
|
|
164
|
-
async function listFiles(directory) {
|
|
165
|
-
const result = [];
|
|
166
|
-
for (const entry of await readdir(directory, { withFileTypes: true })) {
|
|
167
|
-
if (entry.name === installationMarkerName) {
|
|
168
|
-
continue;
|
|
169
|
-
}
|
|
170
|
-
const path = join(directory, entry.name);
|
|
171
|
-
if (entry.isDirectory()) {
|
|
172
|
-
result.push(...await listFiles(path));
|
|
173
|
-
}
|
|
174
|
-
else {
|
|
175
|
-
result.push(path);
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
return result.sort();
|
|
179
|
-
}
|
|
180
|
-
async function exists(path) {
|
|
181
|
-
return access(path).then(() => true, (error) => {
|
|
182
|
-
if (error.code === "ENOENT") {
|
|
183
|
-
return false;
|
|
184
|
-
}
|
|
185
|
-
throw error;
|
|
186
|
-
});
|
|
187
|
-
}
|
|
@@ -1,4 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1,119 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
package/dist/snapshots/types.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,25 +0,0 @@
|
|
|
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 = 1;
|
|
4
|
-
export declare const SEMANTIC_ATLAS_HOME_ENVIRONMENT_VARIABLE = "SEMANTIC_ATLAS_HOME";
|
|
5
|
-
export type AtlasDatabaseAccess = "read-write" | "read-only";
|
|
6
|
-
export interface AtlasDatabaseOptions {
|
|
7
|
-
readonly access?: AtlasDatabaseAccess;
|
|
8
|
-
}
|
|
9
|
-
export declare class AtlasDatabase implements Disposable {
|
|
10
|
-
#private;
|
|
11
|
-
readonly databasePath: string;
|
|
12
|
-
readonly connection: NodeDatabaseSync;
|
|
13
|
-
constructor(repository: GitRepository, options?: AtlasDatabaseOptions);
|
|
14
|
-
get schemaVersion(): number;
|
|
15
|
-
close(): void;
|
|
16
|
-
[Symbol.dispose](): void;
|
|
17
|
-
private initializeSchema;
|
|
18
|
-
private requireCurrentSchema;
|
|
19
|
-
private registerRepository;
|
|
20
|
-
}
|
|
21
|
-
export declare function resolveAtlasHome(repository: GitRepository): string;
|
|
22
|
-
export declare function resolveExistingAtlasHome(): string | null;
|
|
23
|
-
export declare function resolveInsightsDatabasePath(): string;
|
|
24
|
-
export declare function resolveAtlasDatabasePath(repository: GitRepository): string;
|
|
25
|
-
//# sourceMappingURL=atlas-database.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"atlas-database.d.ts","sourceRoot":"","sources":["../../src/storage/atlas-database.ts"],"names":[],"mappings":"AAIA,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;AAC9C,eAAO,MAAM,wCAAwC,wBAAwB,CAAC;AAS9E,MAAM,MAAM,mBAAmB,GAAG,YAAY,GAAG,WAAW,CAAC;AAE7D,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,MAAM,CAAC,EAAE,mBAAmB,CAAC;CACvC;AAED,qBAAa,aAAc,YAAW,UAAU;;IAC9C,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,UAAU,EAAE,gBAAgB,CAAC;gBAG1B,UAAU,EAAE,aAAa,EAAE,OAAO,GAAE,oBAAyB;IAuBzE,IAAI,aAAa,IAAI,MAAM,CAO1B;IAED,KAAK,IAAI,IAAI;IAQb,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,IAAI;IAIxB,OAAO,CAAC,gBAAgB;IAuCxB,OAAO,CAAC,oBAAoB;IAW5B,OAAO,CAAC,kBAAkB;CAqC3B;AAED,wBAAgB,gBAAgB,CAAC,UAAU,EAAE,aAAa,GAAG,MAAM,CAIlE;AAED,wBAAgB,wBAAwB,IAAI,MAAM,GAAG,IAAI,CAWxD;AAcD,wBAAgB,2BAA2B,IAAI,MAAM,CAEpD;AAmBD,wBAAgB,wBAAwB,CAAC,UAAU,EAAE,aAAa,GAAG,MAAM,CAQ1E"}
|