semantic-atlas 0.3.0 → 1.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 +131 -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 +134 -239
- 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 -35
- 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 +649 -0
- package/dist/contracts/observation.d.ts.map +1 -0
- package/dist/contracts/observation.js +140 -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 +13 -0
- package/dist/observations/observation-claim-manager.d.ts.map +1 -0
- package/dist/observations/observation-claim-manager.js +247 -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 +208 -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 +116 -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 +307 -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 +428 -0
- package/docs/evaluation.md +220 -174
- package/docs/index.md +27 -40
- package/docs/map-format.md +224 -0
- package/docs/observations.md +175 -0
- package/docs/product-contract.md +295 -137
- package/examples/commerce.yaml +204 -0
- package/package.json +31 -30
- 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 -273
- 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 -96
- 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/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 -7
- package/dist/repository/repository-inspector.d.ts.map +0 -1
- package/dist/repository/repository-inspector.js +0 -84
- 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 -19
- package/dist/storage/atlas-database.d.ts.map +0 -1
- package/dist/storage/atlas-database.js +0 -433
- 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/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 -26
- package/dist/world/world-graph-query.d.ts.map +0 -1
- package/dist/world/world-graph-query.js +0 -250
- 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 -40
- 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/contracts/cli-v1.md +0 -164
- package/docs/contracts/graph-model.md +0 -106
- package/docs/contracts/graph-patch-v1.md +0 -105
- package/docs/contracts/insights-v1.md +0 -84
- package/docs/log.md +0 -80
- 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,571 +0,0 @@
|
|
|
1
|
-
var __addDisposableResource = (this && this.__addDisposableResource) || function (env, value, async) {
|
|
2
|
-
if (value !== null && value !== void 0) {
|
|
3
|
-
if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
|
|
4
|
-
var dispose, inner;
|
|
5
|
-
if (async) {
|
|
6
|
-
if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined.");
|
|
7
|
-
dispose = value[Symbol.asyncDispose];
|
|
8
|
-
}
|
|
9
|
-
if (dispose === void 0) {
|
|
10
|
-
if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined.");
|
|
11
|
-
dispose = value[Symbol.dispose];
|
|
12
|
-
if (async) inner = dispose;
|
|
13
|
-
}
|
|
14
|
-
if (typeof dispose !== "function") throw new TypeError("Object not disposable.");
|
|
15
|
-
if (inner) dispose = function() { try { inner.call(this); } catch (e) { return Promise.reject(e); } };
|
|
16
|
-
env.stack.push({ value: value, dispose: dispose, async: async });
|
|
17
|
-
}
|
|
18
|
-
else if (async) {
|
|
19
|
-
env.stack.push({ async: true });
|
|
20
|
-
}
|
|
21
|
-
return value;
|
|
22
|
-
};
|
|
23
|
-
var __disposeResources = (this && this.__disposeResources) || (function (SuppressedError) {
|
|
24
|
-
return function (env) {
|
|
25
|
-
function fail(e) {
|
|
26
|
-
env.error = env.hasError ? new SuppressedError(e, env.error, "An error was suppressed during disposal.") : e;
|
|
27
|
-
env.hasError = true;
|
|
28
|
-
}
|
|
29
|
-
var r, s = 0;
|
|
30
|
-
function next() {
|
|
31
|
-
while (r = env.stack.pop()) {
|
|
32
|
-
try {
|
|
33
|
-
if (!r.async && s === 1) return s = 0, env.stack.push(r), Promise.resolve().then(next);
|
|
34
|
-
if (r.dispose) {
|
|
35
|
-
var result = r.dispose.call(r.value);
|
|
36
|
-
if (r.async) return s |= 2, Promise.resolve(result).then(next, function(e) { fail(e); return next(); });
|
|
37
|
-
}
|
|
38
|
-
else s |= 1;
|
|
39
|
-
}
|
|
40
|
-
catch (e) {
|
|
41
|
-
fail(e);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
if (s === 1) return env.hasError ? Promise.reject(env.error) : Promise.resolve();
|
|
45
|
-
if (env.hasError) throw env.error;
|
|
46
|
-
}
|
|
47
|
-
return next();
|
|
48
|
-
};
|
|
49
|
-
})(typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
50
|
-
var e = new Error(message);
|
|
51
|
-
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
52
|
-
});
|
|
53
|
-
import { cliEnvelopeSchema } from "../contracts/cli.js";
|
|
54
|
-
import { graphPatchV1Schema } from "../contracts/graph.js";
|
|
55
|
-
import { feedbackReportInputSchema } from "../contracts/insights.js";
|
|
56
|
-
import { GraphStore } from "../graph/graph-store.js";
|
|
57
|
-
import { BusinessKnowledgeService } from "../knowledge/business-knowledge-service.js";
|
|
58
|
-
import { hasSupportedRepositoryLanguage, inspectRepositoryLanguages, } from "../repository/repository-language-support.js";
|
|
59
|
-
import { inspectGitRepository, } from "../repository/repository-inspector.js";
|
|
60
|
-
import { createRepositorySnapshot } from "../snapshots/repository-snapshot.js";
|
|
61
|
-
import { SnapshotStore, } from "../storage/snapshot-store.js";
|
|
62
|
-
import { resolveAtlasDatabasePath } from "../storage/atlas-database.js";
|
|
63
|
-
import { InsightsStore } from "../insights/insights-store.js";
|
|
64
|
-
import { CodeGraphStructuralBackend } from "../structural-backend/codegraph-backend.js";
|
|
65
|
-
import { WorldGraphQuery } from "../world/world-graph-query.js";
|
|
66
|
-
import { WorldModelService } from "../world/world-model-service.js";
|
|
67
|
-
import { WorldSnapshotStore } from "../world/world-snapshot-store.js";
|
|
68
|
-
import { CliError, invalidInput } from "./cli-error.js";
|
|
69
|
-
export class CliApplication {
|
|
70
|
-
io;
|
|
71
|
-
constructor(io) {
|
|
72
|
-
this.io = io;
|
|
73
|
-
}
|
|
74
|
-
async openRepository(path, command) {
|
|
75
|
-
let repository;
|
|
76
|
-
try {
|
|
77
|
-
repository = await inspectGitRepository(path);
|
|
78
|
-
}
|
|
79
|
-
catch {
|
|
80
|
-
throw new CliError(3, "REPOSITORY_NOT_FOUND", "The selected path is not inside a supported Git worktree.", command);
|
|
81
|
-
}
|
|
82
|
-
const [currentSnapshot, structural, languages] = await Promise.all([
|
|
83
|
-
createRepositorySnapshot(repository),
|
|
84
|
-
new CodeGraphStructuralBackend(repository).inspect(),
|
|
85
|
-
inspectRepositoryLanguages(repository),
|
|
86
|
-
]);
|
|
87
|
-
try {
|
|
88
|
-
const env_1 = { stack: [], error: void 0, hasError: false };
|
|
89
|
-
try {
|
|
90
|
-
const world = __addDisposableResource(env_1, new WorldSnapshotStore(repository), false);
|
|
91
|
-
const state = world.readState();
|
|
92
|
-
const publishedSnapshot = state.currentSnapshotId === null
|
|
93
|
-
? null
|
|
94
|
-
: findPublishedSnapshot(repository, state.currentSnapshotId);
|
|
95
|
-
return { repository, currentSnapshot, structural, languages, state, publishedSnapshot };
|
|
96
|
-
}
|
|
97
|
-
catch (e_1) {
|
|
98
|
-
env_1.error = e_1;
|
|
99
|
-
env_1.hasError = true;
|
|
100
|
-
}
|
|
101
|
-
finally {
|
|
102
|
-
__disposeResources(env_1);
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
catch {
|
|
106
|
-
return {
|
|
107
|
-
repository,
|
|
108
|
-
currentSnapshot,
|
|
109
|
-
structural,
|
|
110
|
-
languages,
|
|
111
|
-
state: null,
|
|
112
|
-
publishedSnapshot: null,
|
|
113
|
-
};
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
async execute(command, context) {
|
|
117
|
-
switch (command.name) {
|
|
118
|
-
case "status":
|
|
119
|
-
return this.status(context);
|
|
120
|
-
case "index":
|
|
121
|
-
return this.index(context);
|
|
122
|
-
case "map.view":
|
|
123
|
-
return this.mapView(command.focusKey, context);
|
|
124
|
-
case "map.search":
|
|
125
|
-
return this.mapSearch(command.query, command.limit, context);
|
|
126
|
-
case "map.show":
|
|
127
|
-
return this.mapShow(command.businessKey, context);
|
|
128
|
-
case "code.search":
|
|
129
|
-
return this.codeSearch(command.query, command.limit, context);
|
|
130
|
-
case "learn":
|
|
131
|
-
return this.learn(context);
|
|
132
|
-
case "feedback.report":
|
|
133
|
-
return this.feedbackReport(context);
|
|
134
|
-
case "changes":
|
|
135
|
-
return this.changes(command, context);
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
envelope(result, context) {
|
|
139
|
-
const partial = hasPartialResult(result.data, result.warnings);
|
|
140
|
-
return cliEnvelopeSchema.parse({
|
|
141
|
-
schemaVersion: 1,
|
|
142
|
-
repository: repositoryDescriptor(context),
|
|
143
|
-
snapshot: snapshotDescriptor(context),
|
|
144
|
-
status: partial ? "partial" : "ok",
|
|
145
|
-
data: result.data,
|
|
146
|
-
warnings: [...result.warnings],
|
|
147
|
-
});
|
|
148
|
-
}
|
|
149
|
-
responseContext(context) {
|
|
150
|
-
return {
|
|
151
|
-
repository: repositoryDescriptor(context),
|
|
152
|
-
snapshot: snapshotDescriptor(context),
|
|
153
|
-
};
|
|
154
|
-
}
|
|
155
|
-
status(context) {
|
|
156
|
-
const freshness = worldFreshness(context);
|
|
157
|
-
const warnings = statusWarnings(context, freshness);
|
|
158
|
-
return {
|
|
159
|
-
data: {
|
|
160
|
-
command: "status",
|
|
161
|
-
currentRevision: {
|
|
162
|
-
headCommit: context.currentSnapshot.headCommit,
|
|
163
|
-
changes: changeCounts(context.currentSnapshot),
|
|
164
|
-
},
|
|
165
|
-
freshness,
|
|
166
|
-
storeLocation: resolveAtlasDatabasePath(context.repository),
|
|
167
|
-
languages: [...context.languages],
|
|
168
|
-
backend: {
|
|
169
|
-
version: context.structural.backendVersion,
|
|
170
|
-
completeness: context.structural.completeness,
|
|
171
|
-
extractionVersion: context.structural.extractionVersion,
|
|
172
|
-
indexedAt: context.structural.indexedAt,
|
|
173
|
-
},
|
|
174
|
-
},
|
|
175
|
-
warnings,
|
|
176
|
-
};
|
|
177
|
-
}
|
|
178
|
-
async index(context) {
|
|
179
|
-
if (!hasSupportedRepositoryLanguage(context.languages)) {
|
|
180
|
-
throw new CliError(3, "UNSUPPORTED_REPOSITORY", "The repository has no TypeScript or JavaScript source files to index.", "index");
|
|
181
|
-
}
|
|
182
|
-
const previousUnknowns = context.structural.completeness === "complete"
|
|
183
|
-
? await new CodeGraphStructuralBackend(context.repository).listUnknownBoundaries()
|
|
184
|
-
: [];
|
|
185
|
-
const world = new WorldModelService(context.repository);
|
|
186
|
-
const publication = context.structural.completeness === "incomplete"
|
|
187
|
-
? await world.build()
|
|
188
|
-
: await world.sync();
|
|
189
|
-
const unknownChanges = compareUnknownBoundaries(previousUnknowns, publication.structural.boundaries);
|
|
190
|
-
const warnings = [
|
|
191
|
-
...unsupportedLanguageWarnings(context.languages),
|
|
192
|
-
...publication.staleAssertions.length === 0 ? [] : [{
|
|
193
|
-
code: "STALE_ASSERTION",
|
|
194
|
-
message: `${publication.staleAssertions.length} learned assertions have stale evidence.`,
|
|
195
|
-
details: { assertions: publication.staleAssertions },
|
|
196
|
-
}],
|
|
197
|
-
...publication.structural.boundaries.length === 0 ? [] : [{
|
|
198
|
-
code: "UNKNOWN_BOUNDARY",
|
|
199
|
-
message: `${publication.structural.boundaries.length} structural operations remain unresolved.`,
|
|
200
|
-
}],
|
|
201
|
-
];
|
|
202
|
-
return {
|
|
203
|
-
data: {
|
|
204
|
-
command: "index",
|
|
205
|
-
snapshotId: publication.snapshotId,
|
|
206
|
-
facts: publication.structural.factChanges,
|
|
207
|
-
unknowns: {
|
|
208
|
-
added: unknownChanges.added,
|
|
209
|
-
resolved: unknownChanges.resolved,
|
|
210
|
-
total: publication.structural.boundaries.length,
|
|
211
|
-
},
|
|
212
|
-
backendVersion: publication.structural.backendVersion,
|
|
213
|
-
extractionVersion: publication.structural.extractionVersion,
|
|
214
|
-
structuralTotals: {
|
|
215
|
-
nodes: publication.structural.counts.nodes,
|
|
216
|
-
relations: publication.structural.counts.relations,
|
|
217
|
-
},
|
|
218
|
-
staleAssertions: publication.staleAssertions,
|
|
219
|
-
},
|
|
220
|
-
warnings,
|
|
221
|
-
};
|
|
222
|
-
}
|
|
223
|
-
async mapView(focusKey, context) {
|
|
224
|
-
const env_2 = { stack: [], error: void 0, hasError: false };
|
|
225
|
-
try {
|
|
226
|
-
this.requireCurrentWorld(context, "map.view");
|
|
227
|
-
const query = __addDisposableResource(env_2, new WorldGraphQuery(context.repository), false);
|
|
228
|
-
const view = await query.view(focusKey);
|
|
229
|
-
if (view === undefined) {
|
|
230
|
-
throw invalidInput(`Business node ${focusKey} was not found.`, "map.view");
|
|
231
|
-
}
|
|
232
|
-
const warnings = view.focus === null && view.regions.length === 0
|
|
233
|
-
? [{
|
|
234
|
-
code: "BUSINESS_KNOWLEDGE_EMPTY",
|
|
235
|
-
message: "No business knowledge has been learned from engineering work yet.",
|
|
236
|
-
}]
|
|
237
|
-
: [];
|
|
238
|
-
return mapResult({ command: "map.view", ...view }, context.languages, warnings);
|
|
239
|
-
}
|
|
240
|
-
catch (e_2) {
|
|
241
|
-
env_2.error = e_2;
|
|
242
|
-
env_2.hasError = true;
|
|
243
|
-
}
|
|
244
|
-
finally {
|
|
245
|
-
__disposeResources(env_2);
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
async mapSearch(lexicalQuery, limit, context) {
|
|
249
|
-
const env_3 = { stack: [], error: void 0, hasError: false };
|
|
250
|
-
try {
|
|
251
|
-
this.requireCurrentWorld(context, "map.search");
|
|
252
|
-
const query = __addDisposableResource(env_3, new WorldGraphQuery(context.repository), false);
|
|
253
|
-
const results = await query.searchBusiness(lexicalQuery, { limit });
|
|
254
|
-
return mapResult({ command: "map.search", query: lexicalQuery, limit, results }, context.languages);
|
|
255
|
-
}
|
|
256
|
-
catch (e_3) {
|
|
257
|
-
env_3.error = e_3;
|
|
258
|
-
env_3.hasError = true;
|
|
259
|
-
}
|
|
260
|
-
finally {
|
|
261
|
-
__disposeResources(env_3);
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
async codeSearch(structuralQuery, limit, context) {
|
|
265
|
-
const env_4 = { stack: [], error: void 0, hasError: false };
|
|
266
|
-
try {
|
|
267
|
-
this.requireCurrentWorld(context, "code.search");
|
|
268
|
-
const query = __addDisposableResource(env_4, new WorldGraphQuery(context.repository), false);
|
|
269
|
-
const results = await query.searchCode(structuralQuery, { limit });
|
|
270
|
-
return mapResult({
|
|
271
|
-
command: "code.search",
|
|
272
|
-
query: structuralQuery,
|
|
273
|
-
limit,
|
|
274
|
-
results,
|
|
275
|
-
}, context.languages);
|
|
276
|
-
}
|
|
277
|
-
catch (e_4) {
|
|
278
|
-
env_4.error = e_4;
|
|
279
|
-
env_4.hasError = true;
|
|
280
|
-
}
|
|
281
|
-
finally {
|
|
282
|
-
__disposeResources(env_4);
|
|
283
|
-
}
|
|
284
|
-
}
|
|
285
|
-
async mapShow(businessKey, context) {
|
|
286
|
-
const env_5 = { stack: [], error: void 0, hasError: false };
|
|
287
|
-
try {
|
|
288
|
-
this.requireCurrentWorld(context, "map.show");
|
|
289
|
-
const query = __addDisposableResource(env_5, new WorldGraphQuery(context.repository), false);
|
|
290
|
-
const view = await query.showBusiness(businessKey);
|
|
291
|
-
if (view === undefined) {
|
|
292
|
-
throw invalidInput(`Business node ${businessKey} was not found.`, "map.show");
|
|
293
|
-
}
|
|
294
|
-
return mapResult({
|
|
295
|
-
command: "map.show",
|
|
296
|
-
node: view.node,
|
|
297
|
-
relations: view.relations.map(presentNeighbor),
|
|
298
|
-
}, context.languages);
|
|
299
|
-
}
|
|
300
|
-
catch (e_5) {
|
|
301
|
-
env_5.error = e_5;
|
|
302
|
-
env_5.hasError = true;
|
|
303
|
-
}
|
|
304
|
-
finally {
|
|
305
|
-
__disposeResources(env_5);
|
|
306
|
-
}
|
|
307
|
-
}
|
|
308
|
-
async learn(context) {
|
|
309
|
-
const env_6 = { stack: [], error: void 0, hasError: false };
|
|
310
|
-
try {
|
|
311
|
-
this.requireAvailableWorld(context, "learn");
|
|
312
|
-
const input = await readStandardInput(this.io.stdin);
|
|
313
|
-
let inputValue;
|
|
314
|
-
try {
|
|
315
|
-
inputValue = JSON.parse(input);
|
|
316
|
-
}
|
|
317
|
-
catch {
|
|
318
|
-
throw invalidInput("Standard input must contain one complete JSON value.", "learn");
|
|
319
|
-
}
|
|
320
|
-
const parsedPatch = graphPatchV1Schema.safeParse(inputValue);
|
|
321
|
-
if (!parsedPatch.success) {
|
|
322
|
-
throw invalidInput("The GraphPatch input is invalid.", "learn", {
|
|
323
|
-
issues: parsedPatch.error.issues.map(({ code, message, path }) => ({ code, message, path })),
|
|
324
|
-
});
|
|
325
|
-
}
|
|
326
|
-
const patch = parsedPatch.data;
|
|
327
|
-
const graph = __addDisposableResource(env_6, new GraphStore(context.repository), false);
|
|
328
|
-
const applied = await new BusinessKnowledgeService(context.repository, graph).learn(patch);
|
|
329
|
-
return {
|
|
330
|
-
data: { command: "learn", ...applied },
|
|
331
|
-
warnings: unsupportedLanguageWarnings(context.languages),
|
|
332
|
-
};
|
|
333
|
-
}
|
|
334
|
-
catch (e_6) {
|
|
335
|
-
env_6.error = e_6;
|
|
336
|
-
env_6.hasError = true;
|
|
337
|
-
}
|
|
338
|
-
finally {
|
|
339
|
-
__disposeResources(env_6);
|
|
340
|
-
}
|
|
341
|
-
}
|
|
342
|
-
async feedbackReport(context) {
|
|
343
|
-
const env_7 = { stack: [], error: void 0, hasError: false };
|
|
344
|
-
try {
|
|
345
|
-
const input = await readStandardInput(this.io.stdin);
|
|
346
|
-
let inputValue;
|
|
347
|
-
try {
|
|
348
|
-
inputValue = JSON.parse(input);
|
|
349
|
-
}
|
|
350
|
-
catch {
|
|
351
|
-
throw invalidInput("Standard input must contain one complete JSON value.", "feedback.report");
|
|
352
|
-
}
|
|
353
|
-
const parsed = feedbackReportInputSchema.safeParse(inputValue);
|
|
354
|
-
if (!parsed.success) {
|
|
355
|
-
throw invalidInput("The feedback report input is invalid.", "feedback.report", {
|
|
356
|
-
issues: parsed.error.issues.map(({ code, message, path }) => ({ code, message, path })),
|
|
357
|
-
});
|
|
358
|
-
}
|
|
359
|
-
const insights = __addDisposableResource(env_7, new InsightsStore(), false);
|
|
360
|
-
const report = insights.recordFeedback({
|
|
361
|
-
...parsed.data,
|
|
362
|
-
repositoryId: context.repository.repositoryId,
|
|
363
|
-
snapshotId: snapshotDescriptor(context)?.id ?? null,
|
|
364
|
-
});
|
|
365
|
-
return {
|
|
366
|
-
data: {
|
|
367
|
-
command: "feedback.report",
|
|
368
|
-
report: {
|
|
369
|
-
id: report.id,
|
|
370
|
-
kind: report.kind,
|
|
371
|
-
category: report.category,
|
|
372
|
-
impact: report.impact,
|
|
373
|
-
sourceConfirmed: report.sourceConfirmed,
|
|
374
|
-
status: report.status,
|
|
375
|
-
contextEventCount: report.contextEventIds.length,
|
|
376
|
-
createdAt: report.createdAt,
|
|
377
|
-
},
|
|
378
|
-
},
|
|
379
|
-
warnings: [],
|
|
380
|
-
};
|
|
381
|
-
}
|
|
382
|
-
catch (e_7) {
|
|
383
|
-
env_7.error = e_7;
|
|
384
|
-
env_7.hasError = true;
|
|
385
|
-
}
|
|
386
|
-
finally {
|
|
387
|
-
__disposeResources(env_7);
|
|
388
|
-
}
|
|
389
|
-
}
|
|
390
|
-
changes(command, context) {
|
|
391
|
-
const env_8 = { stack: [], error: void 0, hasError: false };
|
|
392
|
-
try {
|
|
393
|
-
this.requireCurrentWorld(context, "changes");
|
|
394
|
-
const query = __addDisposableResource(env_8, new WorldGraphQuery(context.repository), false);
|
|
395
|
-
let changes;
|
|
396
|
-
try {
|
|
397
|
-
changes = query.changes({
|
|
398
|
-
...(command.fromSnapshotId === undefined ? {} : { fromSnapshotId: command.fromSnapshotId }),
|
|
399
|
-
...(command.toSnapshotId === undefined ? {} : { toSnapshotId: command.toSnapshotId }),
|
|
400
|
-
});
|
|
401
|
-
}
|
|
402
|
-
catch (error) {
|
|
403
|
-
throw new CliError(4, "CHANGE_RANGE_NOT_FOUND", error instanceof Error ? error.message : "The requested semantic change range is unavailable.", "changes");
|
|
404
|
-
}
|
|
405
|
-
if (changes === undefined) {
|
|
406
|
-
throw new CliError(4, "CHANGE_RANGE_NOT_FOUND", "The requested semantic change range is not available.", "changes");
|
|
407
|
-
}
|
|
408
|
-
const warnings = [
|
|
409
|
-
...unsupportedLanguageWarnings(context.languages),
|
|
410
|
-
...changes.staleAssertions.length === 0 ? [] : [{
|
|
411
|
-
code: "STALE_ASSERTION",
|
|
412
|
-
message: `${changes.staleAssertions.length} assertions are stale at the target snapshot.`,
|
|
413
|
-
details: { assertions: changes.staleAssertions },
|
|
414
|
-
}],
|
|
415
|
-
];
|
|
416
|
-
return { data: { command: "changes", ...changes }, warnings };
|
|
417
|
-
}
|
|
418
|
-
catch (e_8) {
|
|
419
|
-
env_8.error = e_8;
|
|
420
|
-
env_8.hasError = true;
|
|
421
|
-
}
|
|
422
|
-
finally {
|
|
423
|
-
__disposeResources(env_8);
|
|
424
|
-
}
|
|
425
|
-
}
|
|
426
|
-
requireAvailableWorld(context, command) {
|
|
427
|
-
if (context.structural.completeness === "missing" || context.publishedSnapshot === null) {
|
|
428
|
-
throw new CliError(4, "ATLAS_STATE_MISSING", "The repository has no published Atlas index.", command);
|
|
429
|
-
}
|
|
430
|
-
if (context.structural.completeness !== "complete" || context.state?.status !== "current") {
|
|
431
|
-
throw new CliError(4, "ATLAS_STATE_STALE", "The published Atlas index is unavailable.", command);
|
|
432
|
-
}
|
|
433
|
-
}
|
|
434
|
-
requireCurrentWorld(context, command) {
|
|
435
|
-
this.requireAvailableWorld(context, command);
|
|
436
|
-
if (worldFreshness(context) !== "current") {
|
|
437
|
-
throw new CliError(4, "ATLAS_STATE_STALE", "The repository differs from the published Atlas snapshot; run index first.", command);
|
|
438
|
-
}
|
|
439
|
-
}
|
|
440
|
-
}
|
|
441
|
-
function compareUnknownBoundaries(previous, current) {
|
|
442
|
-
const previousIds = new Set(previous.map(({ reference }) => reference.id));
|
|
443
|
-
const currentIds = new Set(current.map(({ reference }) => reference.id));
|
|
444
|
-
return {
|
|
445
|
-
added: [...currentIds].filter((id) => !previousIds.has(id)).length,
|
|
446
|
-
resolved: [...previousIds].filter((id) => !currentIds.has(id)).length,
|
|
447
|
-
};
|
|
448
|
-
}
|
|
449
|
-
function repositoryDescriptor(context) {
|
|
450
|
-
return {
|
|
451
|
-
id: context.repository.repositoryId,
|
|
452
|
-
root: context.repository.worktreeRoot,
|
|
453
|
-
headCommit: context.currentSnapshot.headCommit,
|
|
454
|
-
};
|
|
455
|
-
}
|
|
456
|
-
function snapshotDescriptor(context) {
|
|
457
|
-
if (context.publishedSnapshot === null) {
|
|
458
|
-
return null;
|
|
459
|
-
}
|
|
460
|
-
return {
|
|
461
|
-
id: context.publishedSnapshot.snapshot.snapshotId,
|
|
462
|
-
gitHead: context.publishedSnapshot.snapshot.headCommit,
|
|
463
|
-
createdAt: context.publishedSnapshot.createdAt,
|
|
464
|
-
freshness: worldFreshness(context) === "current"
|
|
465
|
-
? "current"
|
|
466
|
-
: "stale",
|
|
467
|
-
};
|
|
468
|
-
}
|
|
469
|
-
function worldFreshness(context) {
|
|
470
|
-
if (context.publishedSnapshot === null)
|
|
471
|
-
return "missing";
|
|
472
|
-
if (context.state?.status !== "current")
|
|
473
|
-
return "stale";
|
|
474
|
-
return context.publishedSnapshot.snapshot.snapshotId === context.currentSnapshot.snapshotId
|
|
475
|
-
? "current"
|
|
476
|
-
: "stale";
|
|
477
|
-
}
|
|
478
|
-
function findPublishedSnapshot(repository, snapshotId) {
|
|
479
|
-
const env_9 = { stack: [], error: void 0, hasError: false };
|
|
480
|
-
try {
|
|
481
|
-
const snapshots = __addDisposableResource(env_9, new SnapshotStore(repository), false);
|
|
482
|
-
return snapshots.findStored(snapshotId) ?? null;
|
|
483
|
-
}
|
|
484
|
-
catch (e_9) {
|
|
485
|
-
env_9.error = e_9;
|
|
486
|
-
env_9.hasError = true;
|
|
487
|
-
}
|
|
488
|
-
finally {
|
|
489
|
-
__disposeResources(env_9);
|
|
490
|
-
}
|
|
491
|
-
}
|
|
492
|
-
function changeCounts(snapshot) {
|
|
493
|
-
return {
|
|
494
|
-
staged: snapshot.changes.staged.length,
|
|
495
|
-
unstaged: snapshot.changes.unstaged.length,
|
|
496
|
-
untracked: snapshot.changes.untracked.length,
|
|
497
|
-
};
|
|
498
|
-
}
|
|
499
|
-
function statusWarnings(context, freshness) {
|
|
500
|
-
const warnings = unsupportedLanguageWarnings(context.languages);
|
|
501
|
-
if (freshness === "stale") {
|
|
502
|
-
warnings.push({ code: "STALE_INDEX", message: "The repository differs from the published Atlas snapshot." });
|
|
503
|
-
}
|
|
504
|
-
if (context.structural.completeness === "incomplete") {
|
|
505
|
-
warnings.push({
|
|
506
|
-
code: "INCOMPLETE_INDEX",
|
|
507
|
-
message: "The structural index is incomplete.",
|
|
508
|
-
details: { diagnostics: context.structural.diagnostics },
|
|
509
|
-
});
|
|
510
|
-
}
|
|
511
|
-
return warnings;
|
|
512
|
-
}
|
|
513
|
-
function unsupportedLanguageWarnings(languages) {
|
|
514
|
-
return languages.flatMap((language) => (language.support === "unsupported"
|
|
515
|
-
? [{ code: "UNSUPPORTED_LANGUAGE", message: language.reason, details: { language: language.language } }]
|
|
516
|
-
: []));
|
|
517
|
-
}
|
|
518
|
-
function mapResult(data, languages, additionalWarnings = []) {
|
|
519
|
-
const warnings = [
|
|
520
|
-
...unsupportedLanguageWarnings(languages),
|
|
521
|
-
...additionalWarnings,
|
|
522
|
-
];
|
|
523
|
-
if (containsUnknown(data)) {
|
|
524
|
-
warnings.push({ code: "UNKNOWN_BOUNDARY", message: "The result contains unresolved structural behavior." });
|
|
525
|
-
}
|
|
526
|
-
if (containsStale(data)) {
|
|
527
|
-
warnings.push({ code: "STALE_ASSERTION", message: "The result contains stale learned assertions." });
|
|
528
|
-
}
|
|
529
|
-
return { data, warnings };
|
|
530
|
-
}
|
|
531
|
-
function presentNeighbor(neighbor) {
|
|
532
|
-
return {
|
|
533
|
-
type: neighbor.relation.type,
|
|
534
|
-
direction: neighbor.direction,
|
|
535
|
-
node: neighbor.node,
|
|
536
|
-
certainty: neighbor.relation.certainty,
|
|
537
|
-
validity: neighbor.relation.validity,
|
|
538
|
-
evidence: neighbor.relation.evidence,
|
|
539
|
-
...(neighbor.relation.domain === "structural" ? { support: neighbor.relation.support } : {}),
|
|
540
|
-
depth: neighbor.depth,
|
|
541
|
-
};
|
|
542
|
-
}
|
|
543
|
-
function containsUnknown(data) {
|
|
544
|
-
return JSON.stringify(data).includes('"validity":"unknown"');
|
|
545
|
-
}
|
|
546
|
-
function containsStale(data) {
|
|
547
|
-
return JSON.stringify(data).includes('"validity":"stale"')
|
|
548
|
-
|| isChangesWithStaleAssertions(data);
|
|
549
|
-
}
|
|
550
|
-
function hasPartialResult(data, warnings) {
|
|
551
|
-
return warnings.length > 0 || containsUnknown(data) || containsStale(data);
|
|
552
|
-
}
|
|
553
|
-
function isChangesWithStaleAssertions(data) {
|
|
554
|
-
return typeof data === "object"
|
|
555
|
-
&& data !== null
|
|
556
|
-
&& "command" in data
|
|
557
|
-
&& data.command === "changes"
|
|
558
|
-
&& "staleAssertions" in data
|
|
559
|
-
&& Array.isArray(data.staleAssertions)
|
|
560
|
-
&& data.staleAssertions.length > 0;
|
|
561
|
-
}
|
|
562
|
-
async function readStandardInput(input) {
|
|
563
|
-
let contents = "";
|
|
564
|
-
for await (const chunk of input) {
|
|
565
|
-
contents += Buffer.isBuffer(chunk) ? chunk.toString("utf8") : String(chunk);
|
|
566
|
-
}
|
|
567
|
-
if (contents.trim().length === 0) {
|
|
568
|
-
throw invalidInput("Standard input must contain one complete JSON value.", "learn");
|
|
569
|
-
}
|
|
570
|
-
return contents;
|
|
571
|
-
}
|
package/dist/cli/cli-error.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { CliCommandName } from "./types.js";
|
|
2
|
-
export declare class CliError extends Error {
|
|
3
|
-
readonly exitCode: number;
|
|
4
|
-
readonly code: string;
|
|
5
|
-
readonly command: CliCommandName | null;
|
|
6
|
-
readonly details?: unknown | undefined;
|
|
7
|
-
constructor(exitCode: number, code: string, message: string, command: CliCommandName | null, details?: unknown | undefined);
|
|
8
|
-
}
|
|
9
|
-
export declare function invalidInput(message: string, command: CliCommandName | null, details?: unknown): CliError;
|
|
10
|
-
export declare function classifyCliError(error: unknown, command: CliCommandName | null): CliError;
|
|
11
|
-
export declare function errorMessage(error: unknown): string;
|
|
12
|
-
//# sourceMappingURL=cli-error.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cli-error.d.ts","sourceRoot":"","sources":["../../src/cli/cli-error.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEjD,qBAAa,QAAS,SAAQ,KAAK;IAE/B,QAAQ,CAAC,QAAQ,EAAE,MAAM;IACzB,QAAQ,CAAC,IAAI,EAAE,MAAM;IAErB,QAAQ,CAAC,OAAO,EAAE,cAAc,GAAG,IAAI;IACvC,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO;gBAJjB,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,MAAM,EACrB,OAAO,EAAE,MAAM,EACN,OAAO,EAAE,cAAc,GAAG,IAAI,EAC9B,OAAO,CAAC,EAAE,OAAO,YAAA;CAK7B;AAED,wBAAgB,YAAY,CAC1B,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,cAAc,GAAG,IAAI,EAC9B,OAAO,CAAC,EAAE,OAAO,GAChB,QAAQ,CAEV;AAED,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,OAAO,EACd,OAAO,EAAE,cAAc,GAAG,IAAI,GAC7B,QAAQ,CA+BV;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAEnD"}
|
package/dist/cli/cli-error.js
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { GraphPatchConflictError } from "../knowledge/graph-patch-conflict-error.js";
|
|
2
|
-
import { StructuralBackendError } from "../structural-backend/types.js";
|
|
3
|
-
export class CliError extends Error {
|
|
4
|
-
exitCode;
|
|
5
|
-
code;
|
|
6
|
-
command;
|
|
7
|
-
details;
|
|
8
|
-
constructor(exitCode, code, message, command, details) {
|
|
9
|
-
super(message);
|
|
10
|
-
this.exitCode = exitCode;
|
|
11
|
-
this.code = code;
|
|
12
|
-
this.command = command;
|
|
13
|
-
this.details = details;
|
|
14
|
-
this.name = "CliError";
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
export function invalidInput(message, command, details) {
|
|
18
|
-
return new CliError(2, "INVALID_INPUT", message, command, details);
|
|
19
|
-
}
|
|
20
|
-
export function classifyCliError(error, command) {
|
|
21
|
-
if (error instanceof CliError) {
|
|
22
|
-
return error;
|
|
23
|
-
}
|
|
24
|
-
if (error instanceof GraphPatchConflictError) {
|
|
25
|
-
return new CliError(5, error.code, error.message, command, {
|
|
26
|
-
baseSnapshotId: error.baseSnapshotId,
|
|
27
|
-
currentSnapshotId: error.currentSnapshotId,
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
if (error instanceof StructuralBackendError) {
|
|
31
|
-
if (command === "learn" && error.code === "STRUCTURAL_QUERY_FAILED") {
|
|
32
|
-
return new CliError(5, "GRAPH_PATCH_REJECTED", error.message, command);
|
|
33
|
-
}
|
|
34
|
-
const missing = error.code === "STRUCTURAL_INDEX_MISSING";
|
|
35
|
-
return new CliError(4, missing ? "ATLAS_STATE_MISSING" : "ATLAS_STATE_STALE", error.message, command);
|
|
36
|
-
}
|
|
37
|
-
if (command === "learn") {
|
|
38
|
-
return new CliError(5, "GRAPH_PATCH_REJECTED", errorMessage(error), command);
|
|
39
|
-
}
|
|
40
|
-
return new CliError(1, "INTERNAL_ERROR", "Semantic Atlas failed unexpectedly.", command);
|
|
41
|
-
}
|
|
42
|
-
export function errorMessage(error) {
|
|
43
|
-
return error instanceof Error ? error.message : String(error);
|
|
44
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { type CliEnvelope } from "../contracts/cli.js";
|
|
2
|
-
import { type CliError } from "./cli-error.js";
|
|
3
|
-
import type { CliIo } from "./types.js";
|
|
4
|
-
export declare class CliPresenter {
|
|
5
|
-
private readonly io;
|
|
6
|
-
constructor(io: CliIo);
|
|
7
|
-
write(envelope: CliEnvelope, pretty: boolean): void;
|
|
8
|
-
writeError(error: CliError, context: {
|
|
9
|
-
readonly repository: CliEnvelope["repository"];
|
|
10
|
-
readonly snapshot: CliEnvelope["snapshot"];
|
|
11
|
-
}, pretty: boolean): void;
|
|
12
|
-
writeUnexpectedDiagnostic(error: unknown): void;
|
|
13
|
-
}
|
|
14
|
-
//# sourceMappingURL=cli-presenter.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cli-presenter.d.ts","sourceRoot":"","sources":["../../src/cli/cli-presenter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,KAAK,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAC1E,OAAO,EAAgB,KAAK,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC7D,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAExC,qBAAa,YAAY;IACX,OAAO,CAAC,QAAQ,CAAC,EAAE;gBAAF,EAAE,EAAE,KAAK;IAEtC,KAAK,CAAC,QAAQ,EAAE,WAAW,EAAE,MAAM,EAAE,OAAO,GAAG,IAAI;IAKnD,UAAU,CACR,KAAK,EAAE,QAAQ,EACf,OAAO,EAAE;QACP,QAAQ,CAAC,UAAU,EAAE,WAAW,CAAC,YAAY,CAAC,CAAC;QAC/C,QAAQ,CAAC,QAAQ,EAAE,WAAW,CAAC,UAAU,CAAC,CAAC;KAC5C,EACD,MAAM,EAAE,OAAO,GACd,IAAI;IAmBP,yBAAyB,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI;CAMhD"}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { cliEnvelopeSchema } from "../contracts/cli.js";
|
|
2
|
-
import { errorMessage } from "./cli-error.js";
|
|
3
|
-
export class CliPresenter {
|
|
4
|
-
io;
|
|
5
|
-
constructor(io) {
|
|
6
|
-
this.io = io;
|
|
7
|
-
}
|
|
8
|
-
write(envelope, pretty) {
|
|
9
|
-
const validated = cliEnvelopeSchema.parse(envelope);
|
|
10
|
-
this.io.stdout.write(`${JSON.stringify(validated, null, pretty ? 2 : undefined)}\n`);
|
|
11
|
-
}
|
|
12
|
-
writeError(error, context, pretty) {
|
|
13
|
-
const envelope = cliEnvelopeSchema.parse({
|
|
14
|
-
schemaVersion: 1,
|
|
15
|
-
repository: context.repository,
|
|
16
|
-
snapshot: context.snapshot,
|
|
17
|
-
status: "error",
|
|
18
|
-
data: {
|
|
19
|
-
command: error.command,
|
|
20
|
-
error: {
|
|
21
|
-
code: error.code,
|
|
22
|
-
message: error.message,
|
|
23
|
-
...(error.details === undefined ? {} : { details: error.details }),
|
|
24
|
-
},
|
|
25
|
-
},
|
|
26
|
-
warnings: [],
|
|
27
|
-
});
|
|
28
|
-
this.write(envelope, pretty);
|
|
29
|
-
}
|
|
30
|
-
writeUnexpectedDiagnostic(error) {
|
|
31
|
-
const diagnostic = error instanceof Error && error.stack !== undefined
|
|
32
|
-
? error.stack
|
|
33
|
-
: errorMessage(error);
|
|
34
|
-
this.io.stderr.write(`${diagnostic}\n`);
|
|
35
|
-
}
|
|
36
|
-
}
|