toolnet-memory 0.2.1 → 0.2.3
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/README.md +55 -28
- package/bin/toolnet-memory +55 -55
- package/bundle/agy.js +88 -0
- package/bundle/codex.js +92 -0
- package/bundle/context-runtime.js +56 -0
- package/bundle/context.js +62 -0
- package/bundle/doctor.js +3 -0
- package/bundle/full-index.js +8 -0
- package/bundle/learner.js +8 -0
- package/bundle/mcp.js +7 -0
- package/bundle/opencode.js +314 -0
- package/bundle/project-manual.js +54 -0
- package/bundle/setup.js +31 -0
- package/bundle/snapshot.js +4 -0
- package/bundle/work-continuity.js +12 -0
- package/package.json +9 -6
- package/dist/packages/cli/commands.js +0 -1
- package/dist/packages/cli/index.js +0 -1
- package/dist/packages/sdk/client.js +0 -78
- package/dist/packages/sdk/index.js +0 -1
- package/dist/packages/sdk/types.js +0 -1
- package/dist/src/api/index.js +0 -1
- package/dist/src/api/routes/health.js +0 -1
- package/dist/src/api/routes/index.js +0 -1
- package/dist/src/api/routes/memory.js +0 -1
- package/dist/src/api/routes/projects.js +0 -1
- package/dist/src/api/routes/search.js +0 -1
- package/dist/src/api/server.js +0 -1
- package/dist/src/capture/activity-capture.js +0 -21
- package/dist/src/capture/command-capture.js +0 -12
- package/dist/src/capture/error-capture.js +0 -14
- package/dist/src/capture/event-deduplicator.js +0 -28
- package/dist/src/capture/event-queue.js +0 -20
- package/dist/src/capture/file-capture.js +0 -23
- package/dist/src/capture/index.js +0 -8
- package/dist/src/capture/session-capture.js +0 -18
- package/dist/src/capture/tool-capture.js +0 -13
- package/dist/src/code-intelligence/analysis/analysis-engine.js +0 -26
- package/dist/src/code-intelligence/analysis/dead-code-analyzer.js +0 -127
- package/dist/src/code-intelligence/analysis/dependency-analyzer.js +0 -66
- package/dist/src/code-intelligence/analysis/index.js +0 -4
- package/dist/src/code-intelligence/analysis/types.js +0 -1
- package/dist/src/code-intelligence/architecture/architecture-engine.js +0 -48
- package/dist/src/code-intelligence/architecture/clusters.js +0 -322
- package/dist/src/code-intelligence/architecture/entry-points.js +0 -150
- package/dist/src/code-intelligence/architecture/hotspots.js +0 -136
- package/dist/src/code-intelligence/architecture/index.js +0 -6
- package/dist/src/code-intelligence/architecture/layers.js +0 -197
- package/dist/src/code-intelligence/architecture/types.js +0 -1
- package/dist/src/code-intelligence/chunks/index.js +0 -2
- package/dist/src/code-intelligence/chunks/smart-chunker.js +0 -125
- package/dist/src/code-intelligence/chunks/types.js +0 -1
- package/dist/src/code-intelligence/git/git-diff.js +0 -109
- package/dist/src/code-intelligence/git/index.js +0 -1
- package/dist/src/code-intelligence/graph/architecture.js +0 -26
- package/dist/src/code-intelligence/graph/graph-builder.js +0 -213
- package/dist/src/code-intelligence/graph/graph-store.js +0 -57
- package/dist/src/code-intelligence/graph/index.js +0 -1
- package/dist/src/code-intelligence/graph/relationships.js +0 -1
- package/dist/src/code-intelligence/graph/trace.js +0 -65
- package/dist/src/code-intelligence/impact/blast-radius.js +0 -160
- package/dist/src/code-intelligence/impact/change-mapper.js +0 -69
- package/dist/src/code-intelligence/impact/edit-tool-detector.js +0 -92
- package/dist/src/code-intelligence/impact/impact-analyzer.js +0 -60
- package/dist/src/code-intelligence/impact/impact-guard.js +0 -33
- package/dist/src/code-intelligence/impact/index.js +0 -5
- package/dist/src/code-intelligence/incremental/file-hash.js +0 -8
- package/dist/src/code-intelligence/incremental/incremental-indexer.js +0 -106
- package/dist/src/code-intelligence/incremental/manifest-builder.js +0 -19
- package/dist/src/code-intelligence/incremental/manifest.js +0 -31
- package/dist/src/code-intelligence/index.js +0 -23
- package/dist/src/code-intelligence/indexer/file-watcher.js +0 -1
- package/dist/src/code-intelligence/indexer/incremental-indexer.js +0 -1
- package/dist/src/code-intelligence/indexer/index.js +0 -1
- package/dist/src/code-intelligence/indexer/repository-indexer.js +0 -31
- package/dist/src/code-intelligence/indexer/repository-scanner.js +0 -50
- package/dist/src/code-intelligence/parsers/index.js +0 -1
- package/dist/src/code-intelligence/parsers/tree-sitter/index.js +0 -1
- package/dist/src/code-intelligence/parsers/tree-sitter/languages.js +0 -1
- package/dist/src/code-intelligence/parsers/tree-sitter/parser.js +0 -1
- package/dist/src/code-intelligence/parsers/typescript-parser.js +0 -190
- package/dist/src/code-intelligence/query/graph-query-engine.js +0 -275
- package/dist/src/code-intelligence/query/index.js +0 -2
- package/dist/src/code-intelligence/query/types.js +0 -1
- package/dist/src/code-intelligence/resolution/index.js +0 -2
- package/dist/src/code-intelligence/resolution/types.js +0 -1
- package/dist/src/code-intelligence/resolution/typescript-resolver.js +0 -316
- package/dist/src/code-intelligence/rich/index.js +0 -1
- package/dist/src/code-intelligence/rich/rich-graph-enricher.js +0 -463
- package/dist/src/code-intelligence/semantic/index.js +0 -2
- package/dist/src/code-intelligence/semantic/semantic-code-engine.js +0 -213
- package/dist/src/code-intelligence/semantic/source-priority.js +0 -22
- package/dist/src/code-intelligence/symbols/index.js +0 -1
- package/dist/src/code-intelligence/symbols/reference-resolver.js +0 -21
- package/dist/src/code-intelligence/symbols/symbol-extractor.js +0 -1
- package/dist/src/code-intelligence/test-analysis.js +0 -72
- package/dist/src/code-intelligence/test-architecture.js +0 -67
- package/dist/src/code-intelligence/test-impact.js +0 -47
- package/dist/src/code-intelligence/test-incremental.js +0 -24
- package/dist/src/code-intelligence/test-index.js +0 -39
- package/dist/src/code-intelligence/test-resolution.js +0 -54
- package/dist/src/code-intelligence/test-rich-graph.js +0 -48
- package/dist/src/code-intelligence/test-semantic.js +0 -57
- package/dist/src/code-intelligence/test-visualization.js +0 -36
- package/dist/src/code-intelligence/types.js +0 -1
- package/dist/src/code-intelligence/visualization/index.js +0 -2
- package/dist/src/code-intelligence/visualization/types.js +0 -1
- package/dist/src/code-intelligence/visualization/visualization-builder.js +0 -104
- package/dist/src/core/config.js +0 -66
- package/dist/src/core/global-env.js +0 -70
- package/dist/src/core/importance.js +0 -30
- package/dist/src/core/index.js +0 -5
- package/dist/src/core/memory-engine.js +0 -183
- package/dist/src/core/project-manager.js +0 -243
- package/dist/src/core/types.js +0 -1
- package/dist/src/embeddings/batch-embedder.js +0 -1
- package/dist/src/embeddings/cache.js +0 -1
- package/dist/src/embeddings/embedder.js +0 -51
- package/dist/src/embeddings/index.js +0 -4
- package/dist/src/embeddings/local.js +0 -37
- package/dist/src/embeddings/provider.js +0 -1
- package/dist/src/embeddings/remote.js +0 -76
- package/dist/src/embeddings/test-connection.js +0 -16
- package/dist/src/hooks/after-edit.js +0 -3
- package/dist/src/hooks/after-tool.js +0 -3
- package/dist/src/hooks/auto-context.js +0 -68
- package/dist/src/hooks/auto-impact-guard.js +0 -94
- package/dist/src/hooks/auto-retrieval.js +0 -27
- package/dist/src/hooks/before-agent.js +0 -18
- package/dist/src/hooks/before-compact.js +0 -3
- package/dist/src/hooks/before-edit.js +0 -20
- package/dist/src/hooks/index.js +0 -11
- package/dist/src/hooks/runtime.js +0 -110
- package/dist/src/hooks/session-end.js +0 -3
- package/dist/src/hooks/session-start.js +0 -3
- package/dist/src/index.js +0 -22
- package/dist/src/mcp/bootstrap.js +0 -68
- package/dist/src/mcp/context.js +0 -1
- package/dist/src/mcp/index.js +0 -3
- package/dist/src/mcp/server.js +0 -45
- package/dist/src/mcp/tools/analyze-impact.js +0 -41
- package/dist/src/mcp/tools/dead-code.js +0 -55
- package/dist/src/mcp/tools/find-callers.js +0 -24
- package/dist/src/mcp/tools/find-dependencies.js +0 -57
- package/dist/src/mcp/tools/find-symbol.js +0 -7
- package/dist/src/mcp/tools/get-architecture.js +0 -11
- package/dist/src/mcp/tools/graph-dependents.js +0 -24
- package/dist/src/mcp/tools/graph-neighborhood.js +0 -58
- package/dist/src/mcp/tools/graph-path.js +0 -43
- package/dist/src/mcp/tools/graph-query-utils.js +0 -32
- package/dist/src/mcp/tools/impact-guard.js +0 -34
- package/dist/src/mcp/tools/index-repository.js +0 -1
- package/dist/src/mcp/tools/index.js +0 -20
- package/dist/src/mcp/tools/memory-decisions.js +0 -1
- package/dist/src/mcp/tools/memory-forget.js +0 -14
- package/dist/src/mcp/tools/memory-recent.js +0 -1
- package/dist/src/mcp/tools/memory-remember.js +0 -33
- package/dist/src/mcp/tools/memory-rules.js +0 -1
- package/dist/src/mcp/tools/memory-search.js +0 -18
- package/dist/src/mcp/tools/memory-todos.js +0 -1
- package/dist/src/mcp/tools/project-context.js +0 -25
- package/dist/src/mcp/tools/search-code.js +0 -21
- package/dist/src/mcp/tools/semantic-code-search.js +0 -33
- package/dist/src/mcp/tools/snapshot-create.js +0 -13
- package/dist/src/mcp/tools/snapshot-list.js +0 -7
- package/dist/src/mcp/tools/snapshot-restore.js +0 -13
- package/dist/src/mcp/tools/trace-calls.js +0 -37
- package/dist/src/memory/activity.js +0 -5
- package/dist/src/memory/conflict-detector.js +0 -105
- package/dist/src/memory/consolidator.js +0 -104
- package/dist/src/memory/decay.js +0 -59
- package/dist/src/memory/decisions.js +0 -3
- package/dist/src/memory/deduplicate.js +0 -25
- package/dist/src/memory/index.js +0 -11
- package/dist/src/memory/maintenance.js +0 -16
- package/dist/src/memory/remember.js +0 -3
- package/dist/src/memory/rules.js +0 -3
- package/dist/src/memory/search.js +0 -3
- package/dist/src/memory/summaries.js +0 -1
- package/dist/src/memory/todos.js +0 -3
- package/dist/src/processor/decision-extractor.js +0 -13
- package/dist/src/processor/importance-scorer.js +0 -22
- package/dist/src/processor/index.js +0 -7
- package/dist/src/processor/memory-extractor.js +0 -59
- package/dist/src/processor/memory-processor.js +0 -105
- package/dist/src/processor/rule-extractor.js +0 -13
- package/dist/src/processor/summarizer.js +0 -71
- package/dist/src/processor/todo-extractor.js +0 -12
- package/dist/src/production/config-check.js +0 -34
- package/dist/src/production/doctor.js +0 -58
- package/dist/src/production/full-index.js +0 -114
- package/dist/src/production/health.js +0 -58
- package/dist/src/production/index-pipeline.js +0 -151
- package/dist/src/production/index.js +0 -4
- package/dist/src/production/project-lock.js +0 -95
- package/dist/src/production/project-status.js +0 -16
- package/dist/src/production/recovery.js +0 -15
- package/dist/src/production/setup.js +0 -219
- package/dist/src/production/snapshot-cli.js +0 -58
- package/dist/src/project-manual/cli.js +0 -77
- package/dist/src/project-manual/index.js +0 -2
- package/dist/src/project-manual/manager.js +0 -147
- package/dist/src/project-manual/types.js +0 -1
- package/dist/src/retrieval/bm25/index.js +0 -1
- package/dist/src/retrieval/bm25/search.js +0 -1
- package/dist/src/retrieval/bm25.js +0 -30
- package/dist/src/retrieval/context-budget.js +0 -1
- package/dist/src/retrieval/context-builder.js +0 -22
- package/dist/src/retrieval/graph/index.js +0 -1
- package/dist/src/retrieval/graph/search.js +0 -1
- package/dist/src/retrieval/hybrid/hybrid-search.js +0 -1
- package/dist/src/retrieval/hybrid/index.js +0 -1
- package/dist/src/retrieval/hybrid-search.js +0 -68
- package/dist/src/retrieval/importance.js +0 -16
- package/dist/src/retrieval/index.js +0 -12
- package/dist/src/retrieval/query-analyzer.js +0 -32
- package/dist/src/retrieval/query-classifier.js +0 -1
- package/dist/src/retrieval/query-expansion.js +0 -1
- package/dist/src/retrieval/recency.js +0 -12
- package/dist/src/retrieval/reranker/index.js +0 -1
- package/dist/src/retrieval/reranker/reranker.js +0 -1
- package/dist/src/retrieval/retrieval-engine.js +0 -17
- package/dist/src/retrieval/tokenizer.js +0 -9
- package/dist/src/retrieval/type-priority.js +0 -10
- package/dist/src/retrieval/types.js +0 -1
- package/dist/src/retrieval/vector/index.js +0 -4
- package/dist/src/retrieval/vector/metadata-filter.js +0 -1
- package/dist/src/retrieval/vector/persistence.js +0 -67
- package/dist/src/retrieval/vector/search.js +0 -12
- package/dist/src/retrieval/vector/test-persistence.js +0 -36
- package/dist/src/retrieval/vector/upsert.js +0 -40
- package/dist/src/retrieval/vector/vector-store.js +0 -89
- package/dist/src/retrieval/vector-hybrid-engine.js +0 -91
- package/dist/src/runtime/bootstrap.js +0 -28
- package/dist/src/runtime/graceful.js +0 -17
- package/dist/src/runtime/index.js +0 -3
- package/dist/src/runtime/toolnet-memory-runtime.js +0 -156
- package/dist/src/security/encryption.js +0 -1
- package/dist/src/security/file-filter.js +0 -30
- package/dist/src/security/index.js +0 -3
- package/dist/src/security/sanitizer.js +0 -49
- package/dist/src/security/secret-scanner.js +0 -56
- package/dist/src/session/agy/adapter.js +0 -159
- package/dist/src/session/agy/cli.js +0 -87
- package/dist/src/session/agy/hook-installer.js +0 -62
- package/dist/src/session/agy/hook.js +0 -167
- package/dist/src/session/agy/index.js +0 -5
- package/dist/src/session/agy/project-resolver.js +0 -27
- package/dist/src/session/agy/recovery.js +0 -112
- package/dist/src/session/agy/transcript.js +0 -191
- package/dist/src/session/codex/adapter.js +0 -138
- package/dist/src/session/codex/cli.js +0 -236
- package/dist/src/session/codex/context-hook-installer.js +0 -70
- package/dist/src/session/codex/context-hook.js +0 -69
- package/dist/src/session/codex/discovery.js +0 -138
- package/dist/src/session/codex/index.js +0 -6
- package/dist/src/session/codex/notify-installer.js +0 -135
- package/dist/src/session/codex/project-resolver.js +0 -25
- package/dist/src/session/codex/recovery.js +0 -27
- package/dist/src/session/codex/rollout.js +0 -186
- package/dist/src/session/core.js +0 -239
- package/dist/src/session/identity.js +0 -57
- package/dist/src/session/index.js +0 -9
- package/dist/src/session/learner/cli.js +0 -62
- package/dist/src/session/learner/extractor.js +0 -461
- package/dist/src/session/learner/index.js +0 -4
- package/dist/src/session/learner/journal.js +0 -159
- package/dist/src/session/learner/learner.js +0 -124
- package/dist/src/session/learner/types.js +0 -1
- package/dist/src/session/opencode/adapter.js +0 -553
- package/dist/src/session/opencode/cli.js +0 -121
- package/dist/src/session/opencode/index.js +0 -2
- package/dist/src/session/opencode/plugin-installer.js +0 -230
- package/dist/src/session/store.js +0 -242
- package/dist/src/session/types.js +0 -1
- package/dist/src/session/utils.js +0 -47
- package/dist/src/session/wal.js +0 -303
- package/dist/src/snapshot/index.js +0 -2
- package/dist/src/snapshot/manager.js +0 -130
- package/dist/src/snapshot/test-snapshot.js +0 -28
- package/dist/src/snapshot/types.js +0 -1
- package/dist/src/storage/architecture-store.js +0 -37
- package/dist/src/storage/cleanup-health.js +0 -20
- package/dist/src/storage/code-analysis-store.js +0 -35
- package/dist/src/storage/code-chunk-store.js +0 -25
- package/dist/src/storage/code-graph-store.js +0 -24
- package/dist/src/storage/code-manifest-store.js +0 -24
- package/dist/src/storage/code-vector-store.js +0 -25
- package/dist/src/storage/github/client.js +0 -1
- package/dist/src/storage/github/index.js +0 -1
- package/dist/src/storage/google-drive/client.js +0 -1
- package/dist/src/storage/google-drive/index.js +0 -1
- package/dist/src/storage/huggingface/client.js +0 -116
- package/dist/src/storage/huggingface/index.js +0 -1
- package/dist/src/storage/index.js +0 -16
- package/dist/src/storage/list-bucket-raw.js +0 -14
- package/dist/src/storage/list-bucket-tree.js +0 -38
- package/dist/src/storage/local/client.js +0 -99
- package/dist/src/storage/local/index.js +0 -1
- package/dist/src/storage/memory-store.js +0 -30
- package/dist/src/storage/project/cleanup-layout-v1.js +0 -72
- package/dist/src/storage/project/folder.js +0 -15
- package/dist/src/storage/project/index.js +0 -3
- package/dist/src/storage/project/layout.js +0 -74
- package/dist/src/storage/project/migrate-layout-v2.js +0 -101
- package/dist/src/storage/project/migrate.js +0 -73
- package/dist/src/storage/project/scoped-provider.js +0 -165
- package/dist/src/storage/provider.js +0 -26
- package/dist/src/storage/retrying-provider.js +0 -23
- package/dist/src/storage/test-connection.js +0 -32
- package/dist/src/storage/type-resolution-store.js +0 -26
- package/dist/src/storage/types.js +0 -1
- package/dist/src/storage/vector-store.js +0 -30
- package/dist/src/storage/visualization-store.js +0 -25
- package/dist/src/sync/compressor.js +0 -1
- package/dist/src/sync/conflict-resolver.js +0 -1
- package/dist/src/sync/downloader.js +0 -1
- package/dist/src/sync/index.js +0 -1
- package/dist/src/sync/sync-engine.js +0 -1
- package/dist/src/sync/upload-queue.js +0 -1
- package/dist/src/utils/retry.js +0 -29
- package/dist/src/visualization/server.js +0 -270
- package/dist/src/work-continuity/brief-cache.js +0 -107
- package/dist/src/work-continuity/brief.js +0 -349
- package/dist/src/work-continuity/cli.js +0 -96
- package/dist/src/work-continuity/context-cli.js +0 -106
- package/dist/src/work-continuity/context-runtime-cli.js +0 -88
- package/dist/src/work-continuity/extractor.js +0 -339
- package/dist/src/work-continuity/handoff.js +0 -185
- package/dist/src/work-continuity/index.js +0 -14
- package/dist/src/work-continuity/injection.js +0 -84
- package/dist/src/work-continuity/journal.js +0 -49
- package/dist/src/work-continuity/learner.js +0 -127
- package/dist/src/work-continuity/reducer.js +0 -316
- package/dist/src/work-continuity/semantic-extractor.js +0 -360
- package/dist/src/work-continuity/semantic-journal.js +0 -55
- package/dist/src/work-continuity/semantic-learner.js +0 -125
- package/dist/src/work-continuity/semantic-reducer.js +0 -268
- package/dist/src/work-continuity/semantic-types.js +0 -1
- package/dist/src/work-continuity/types.js +0 -1
- package/dist/visualization/public/index.html +0 -2896
- package/dist/visualization/public/vendor/3d-force-graph.min.js +0 -5
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
export class ReferenceResolver {
|
|
2
|
-
graph;
|
|
3
|
-
constructor(graph) {
|
|
4
|
-
this.graph = graph;
|
|
5
|
-
}
|
|
6
|
-
findSymbol(projectId, name) {
|
|
7
|
-
return this.graph.findByName(projectId, name);
|
|
8
|
-
}
|
|
9
|
-
findCallers(projectId, symbolId) {
|
|
10
|
-
const callerIds = this.graph
|
|
11
|
-
.allEdges(projectId)
|
|
12
|
-
.filter((edge) => edge.type ===
|
|
13
|
-
"CALLS" &&
|
|
14
|
-
edge.to ===
|
|
15
|
-
symbolId)
|
|
16
|
-
.map((edge) => edge.from);
|
|
17
|
-
return callerIds
|
|
18
|
-
.map((id) => this.graph.getSymbol(id))
|
|
19
|
-
.filter((symbol) => Boolean(symbol));
|
|
20
|
-
}
|
|
21
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import "dotenv/config";
|
|
2
|
-
import { loadConfig, ProjectManager, } from "../core/index.js";
|
|
3
|
-
import { createStorageProvider, withStorageRetry, ProjectScopedStorageProvider, PersistentCodeAnalysisStore, PersistentCodeGraphStore, } from "../storage/index.js";
|
|
4
|
-
import { CodeAnalysisEngine, CodeGraphStore, GraphQueryEngine, } from "./index.js";
|
|
5
|
-
async function main() {
|
|
6
|
-
const config = loadConfig();
|
|
7
|
-
const project = new ProjectManager()
|
|
8
|
-
.detect();
|
|
9
|
-
const rawStorage = withStorageRetry(createStorageProvider({
|
|
10
|
-
provider: config.storage.provider,
|
|
11
|
-
huggingface: config.storage.huggingface,
|
|
12
|
-
localRoot: config.storage.localRoot,
|
|
13
|
-
}), {
|
|
14
|
-
attempts: 3,
|
|
15
|
-
});
|
|
16
|
-
const storage = new ProjectScopedStorageProvider(rawStorage, project.id, project.name, project.remote ?? project.name);
|
|
17
|
-
const graphSnapshot = await new PersistentCodeGraphStore(storage).load(project.id);
|
|
18
|
-
if (!graphSnapshot) {
|
|
19
|
-
throw new Error("Code graph missing");
|
|
20
|
-
}
|
|
21
|
-
const graph = new CodeGraphStore();
|
|
22
|
-
graph.import(graphSnapshot.symbols, graphSnapshot.edges);
|
|
23
|
-
const analysis = new CodeAnalysisEngine(graph).analyze(project.id);
|
|
24
|
-
await new PersistentCodeAnalysisStore(storage).save(analysis);
|
|
25
|
-
const query = new GraphQueryEngine(graph);
|
|
26
|
-
const memoryStore = query.findSymbols(project.id, "MemoryStore")[0];
|
|
27
|
-
console.log({
|
|
28
|
-
ok: true,
|
|
29
|
-
project: project.name,
|
|
30
|
-
summary: analysis.summary,
|
|
31
|
-
highConfidenceDeadCode: analysis.deadCode
|
|
32
|
-
.filter((item) => item.confidence ===
|
|
33
|
-
"high")
|
|
34
|
-
.slice(0, 20)
|
|
35
|
-
.map((item) => ({
|
|
36
|
-
symbol: item.qualifiedName ??
|
|
37
|
-
item.name,
|
|
38
|
-
type: item.type,
|
|
39
|
-
file: item.filePath,
|
|
40
|
-
line: item.startLine,
|
|
41
|
-
score: item.score,
|
|
42
|
-
})),
|
|
43
|
-
topDependencyHubs: analysis.dependencies
|
|
44
|
-
.slice()
|
|
45
|
-
.sort((a, b) => (b.incomingEdges +
|
|
46
|
-
b.outgoingEdges) -
|
|
47
|
-
(a.incomingEdges +
|
|
48
|
-
a.outgoingEdges))
|
|
49
|
-
.slice(0, 15)
|
|
50
|
-
.map((item) => ({
|
|
51
|
-
file: item.filePath,
|
|
52
|
-
dependencies: item.dependencies.length,
|
|
53
|
-
dependents: item.dependents.length,
|
|
54
|
-
incoming: item.incomingEdges,
|
|
55
|
-
outgoing: item.outgoingEdges,
|
|
56
|
-
})),
|
|
57
|
-
memoryStore: memoryStore
|
|
58
|
-
? {
|
|
59
|
-
symbol: memoryStore
|
|
60
|
-
.qualifiedName ??
|
|
61
|
-
memoryStore.name,
|
|
62
|
-
callers: query.callers(project.id, memoryStore.id).length,
|
|
63
|
-
dependents: query.dependents(project.id, memoryStore.id).length,
|
|
64
|
-
dependencies: query.dependencies(project.id, memoryStore.id).length,
|
|
65
|
-
}
|
|
66
|
-
: null,
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
main().catch((error) => {
|
|
70
|
-
console.error(error);
|
|
71
|
-
process.exit(1);
|
|
72
|
-
});
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import "dotenv/config";
|
|
2
|
-
import { loadConfig, ProjectManager, } from "../core/index.js";
|
|
3
|
-
import { createStorageProvider, withStorageRetry, ProjectScopedStorageProvider, PersistentArchitectureStore, PersistentCodeGraphStore, } from "../storage/index.js";
|
|
4
|
-
import { ArchitectureEngine, CodeGraphStore, } from "./index.js";
|
|
5
|
-
async function main() {
|
|
6
|
-
const config = loadConfig();
|
|
7
|
-
const project = new ProjectManager()
|
|
8
|
-
.detect();
|
|
9
|
-
const rawStorage = withStorageRetry(createStorageProvider({
|
|
10
|
-
provider: config.storage.provider,
|
|
11
|
-
huggingface: config.storage.huggingface,
|
|
12
|
-
localRoot: config.storage.localRoot,
|
|
13
|
-
}), {
|
|
14
|
-
attempts: 3,
|
|
15
|
-
});
|
|
16
|
-
const storage = new ProjectScopedStorageProvider(rawStorage, project.id, project.name, project.remote ?? project.name);
|
|
17
|
-
const graphSnapshot = await new PersistentCodeGraphStore(storage).load(project.id);
|
|
18
|
-
if (!graphSnapshot) {
|
|
19
|
-
throw new Error("Code graph missing");
|
|
20
|
-
}
|
|
21
|
-
const graph = new CodeGraphStore();
|
|
22
|
-
graph.import(graphSnapshot.symbols, graphSnapshot.edges);
|
|
23
|
-
const architecture = new ArchitectureEngine(graph).analyze(project.id);
|
|
24
|
-
await new PersistentArchitectureStore(storage).save(architecture);
|
|
25
|
-
const layerCounts = architecture.layers
|
|
26
|
-
.reduce((result, item) => {
|
|
27
|
-
result[item.layer] =
|
|
28
|
-
(result[item.layer] ?? 0) + 1;
|
|
29
|
-
return result;
|
|
30
|
-
}, {});
|
|
31
|
-
console.log({
|
|
32
|
-
ok: true,
|
|
33
|
-
project: project.name,
|
|
34
|
-
summary: architecture.summary,
|
|
35
|
-
layers: layerCounts,
|
|
36
|
-
topEntryPoints: architecture.entryPoints
|
|
37
|
-
.slice(0, 10)
|
|
38
|
-
.map((item) => ({
|
|
39
|
-
kind: item.kind,
|
|
40
|
-
file: item.filePath,
|
|
41
|
-
name: item.name,
|
|
42
|
-
score: item.score,
|
|
43
|
-
})),
|
|
44
|
-
topHotspots: architecture.hotspots
|
|
45
|
-
.slice(0, 10)
|
|
46
|
-
.map((item) => ({
|
|
47
|
-
file: item.filePath,
|
|
48
|
-
score: item.score,
|
|
49
|
-
incoming: item.incoming,
|
|
50
|
-
outgoing: item.outgoing,
|
|
51
|
-
})),
|
|
52
|
-
largestClusters: architecture.clusters
|
|
53
|
-
.slice(0, 10)
|
|
54
|
-
.map((item) => ({
|
|
55
|
-
id: item.id,
|
|
56
|
-
label: item.label,
|
|
57
|
-
subsystem: item.subsystem,
|
|
58
|
-
size: item.size,
|
|
59
|
-
cohesion: item.cohesion,
|
|
60
|
-
sample: item.files.slice(0, 5),
|
|
61
|
-
})),
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
main().catch((error) => {
|
|
65
|
-
console.error(error);
|
|
66
|
-
process.exit(1);
|
|
67
|
-
});
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import "dotenv/config";
|
|
2
|
-
import { loadConfig, ProjectManager, } from "../core/index.js";
|
|
3
|
-
import { createStorageProvider, withStorageRetry, ProjectScopedStorageProvider, PersistentCodeGraphStore, } from "../storage/index.js";
|
|
4
|
-
import { CodeGraphStore, ImpactGuard, } from "./index.js";
|
|
5
|
-
async function main() {
|
|
6
|
-
const config = loadConfig();
|
|
7
|
-
const project = new ProjectManager()
|
|
8
|
-
.detect();
|
|
9
|
-
const raw = withStorageRetry(createStorageProvider({
|
|
10
|
-
provider: config.storage.provider,
|
|
11
|
-
huggingface: config.storage.huggingface,
|
|
12
|
-
localRoot: config.storage.localRoot,
|
|
13
|
-
}), {
|
|
14
|
-
attempts: 3,
|
|
15
|
-
});
|
|
16
|
-
const storage = new ProjectScopedStorageProvider(raw, project.id, project.name, project.remote ?? project.name);
|
|
17
|
-
const snapshot = await new PersistentCodeGraphStore(storage).load(project.id);
|
|
18
|
-
if (!snapshot) {
|
|
19
|
-
throw new Error("Code graph missing");
|
|
20
|
-
}
|
|
21
|
-
const graph = new CodeGraphStore();
|
|
22
|
-
graph.import(snapshot.symbols, snapshot.edges);
|
|
23
|
-
const guard = new ImpactGuard(graph);
|
|
24
|
-
const filePath = process.argv[2];
|
|
25
|
-
const result = filePath
|
|
26
|
-
? guard.analyzeFile(project.id, filePath)
|
|
27
|
-
: await guard.analyzeGitDiff(project.id, project.rootPath);
|
|
28
|
-
console.log({
|
|
29
|
-
risk: result.risk,
|
|
30
|
-
riskScore: result.riskScore,
|
|
31
|
-
changedSymbols: result.changedSymbols.map((item) => ({
|
|
32
|
-
symbol: item.symbol
|
|
33
|
-
.qualifiedName,
|
|
34
|
-
file: item.symbol
|
|
35
|
-
.filePath,
|
|
36
|
-
type: item.symbol
|
|
37
|
-
.type,
|
|
38
|
-
})),
|
|
39
|
-
impactedFiles: result.impactedFiles,
|
|
40
|
-
suggestedTests: result.suggestedTests,
|
|
41
|
-
impactedCount: result.impacted.length,
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
main().catch((error) => {
|
|
45
|
-
console.error(error);
|
|
46
|
-
process.exit(1);
|
|
47
|
-
});
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import "dotenv/config";
|
|
2
|
-
import { loadConfig, ProjectManager, } from "../core/index.js";
|
|
3
|
-
import { createStorageProvider, ProjectScopedStorageProvider, } from "../storage/index.js";
|
|
4
|
-
import { IncrementalRepositoryIndexer, } from "./incremental/incremental-indexer.js";
|
|
5
|
-
async function main() {
|
|
6
|
-
const config = loadConfig();
|
|
7
|
-
const project = new ProjectManager().detect();
|
|
8
|
-
const rawStorage = createStorageProvider({
|
|
9
|
-
provider: config.storage.provider,
|
|
10
|
-
huggingface: config.storage.huggingface,
|
|
11
|
-
localRoot: config.storage.localRoot,
|
|
12
|
-
});
|
|
13
|
-
const storage = new ProjectScopedStorageProvider(rawStorage, project.id, project.name, project.remote ?? project.name);
|
|
14
|
-
const result = await new IncrementalRepositoryIndexer(storage).index(project.id, project.rootPath);
|
|
15
|
-
console.log({
|
|
16
|
-
ok: true,
|
|
17
|
-
storage: storage.name,
|
|
18
|
-
...result,
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
main().catch((error) => {
|
|
22
|
-
console.error(error);
|
|
23
|
-
process.exit(1);
|
|
24
|
-
});
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import "dotenv/config";
|
|
2
|
-
import { loadConfig, ProjectManager, } from "../core/index.js";
|
|
3
|
-
import { RepositoryIndexer, getArchitecture, } from "./index.js";
|
|
4
|
-
import { createStorageProvider, PersistentCodeGraphStore, ProjectScopedStorageProvider, } from "../storage/index.js";
|
|
5
|
-
async function main() {
|
|
6
|
-
const config = loadConfig();
|
|
7
|
-
const project = new ProjectManager()
|
|
8
|
-
.detect();
|
|
9
|
-
const rawStorage = createStorageProvider({
|
|
10
|
-
provider: config.storage.provider,
|
|
11
|
-
huggingface: config.storage.huggingface,
|
|
12
|
-
localRoot: config.storage.localRoot,
|
|
13
|
-
});
|
|
14
|
-
const storage = new ProjectScopedStorageProvider(rawStorage, project.id, project.name, project.remote ?? project.name);
|
|
15
|
-
const result = await new RepositoryIndexer()
|
|
16
|
-
.index(project.id, project.rootPath);
|
|
17
|
-
const architecture = getArchitecture(result.graph, project.id);
|
|
18
|
-
const persistent = new PersistentCodeGraphStore(storage);
|
|
19
|
-
await persistent.save({
|
|
20
|
-
version: 1,
|
|
21
|
-
projectId: project.id,
|
|
22
|
-
updatedAt: new Date()
|
|
23
|
-
.toISOString(),
|
|
24
|
-
files: result.files,
|
|
25
|
-
symbols: result.graph
|
|
26
|
-
.allSymbols(project.id),
|
|
27
|
-
edges: result.graph
|
|
28
|
-
.allEdges(project.id),
|
|
29
|
-
});
|
|
30
|
-
console.log({
|
|
31
|
-
ok: true,
|
|
32
|
-
storage: storage.name,
|
|
33
|
-
...architecture,
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
main().catch((error) => {
|
|
37
|
-
console.error(error);
|
|
38
|
-
process.exit(1);
|
|
39
|
-
});
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import "dotenv/config";
|
|
2
|
-
import { loadConfig, ProjectManager, } from "../core/index.js";
|
|
3
|
-
import { createStorageProvider, withStorageRetry, ProjectScopedStorageProvider, PersistentCodeGraphStore, PersistentTypeResolutionStore, } from "../storage/index.js";
|
|
4
|
-
import { CodeGraphStore, TypeScriptTypeResolver, } from "./index.js";
|
|
5
|
-
async function main() {
|
|
6
|
-
const config = loadConfig();
|
|
7
|
-
const project = new ProjectManager()
|
|
8
|
-
.detect();
|
|
9
|
-
const rawStorage = withStorageRetry(createStorageProvider({
|
|
10
|
-
provider: config.storage.provider,
|
|
11
|
-
huggingface: config.storage.huggingface,
|
|
12
|
-
localRoot: config.storage.localRoot,
|
|
13
|
-
}), {
|
|
14
|
-
attempts: 3,
|
|
15
|
-
});
|
|
16
|
-
const storage = new ProjectScopedStorageProvider(rawStorage, project.id, project.name, project.remote ?? project.name);
|
|
17
|
-
const graphSnapshot = await new PersistentCodeGraphStore(storage).load(project.id);
|
|
18
|
-
if (!graphSnapshot) {
|
|
19
|
-
throw new Error("Code graph missing. Run code:index:test first.");
|
|
20
|
-
}
|
|
21
|
-
const graph = new CodeGraphStore();
|
|
22
|
-
graph.import(graphSnapshot.symbols, graphSnapshot.edges);
|
|
23
|
-
const resolver = new TypeScriptTypeResolver(graph);
|
|
24
|
-
const resolution = await resolver.resolveProject(project.id, project.rootPath);
|
|
25
|
-
await new PersistentTypeResolutionStore(storage).save(resolution);
|
|
26
|
-
console.log({
|
|
27
|
-
ok: true,
|
|
28
|
-
project: project.name,
|
|
29
|
-
total: resolution.total,
|
|
30
|
-
exact: resolution.exact,
|
|
31
|
-
high: resolution.high,
|
|
32
|
-
fallback: resolution.fallback,
|
|
33
|
-
exactRate: resolution.total
|
|
34
|
-
? Number(((resolution.exact /
|
|
35
|
-
resolution.total) *
|
|
36
|
-
100).toFixed(2))
|
|
37
|
-
: 0,
|
|
38
|
-
samples: resolution.resolutions
|
|
39
|
-
.filter((item) => item.targetFile)
|
|
40
|
-
.slice(0, 10)
|
|
41
|
-
.map((item) => ({
|
|
42
|
-
expression: item.expression,
|
|
43
|
-
from: `${item.sourceFile}:${item.sourceLine}`,
|
|
44
|
-
to: `${item.targetFile}:${item.targetLine ?? "?"}`,
|
|
45
|
-
target: item.targetQualifiedName ??
|
|
46
|
-
item.targetName,
|
|
47
|
-
confidence: item.confidence,
|
|
48
|
-
})),
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
main().catch((error) => {
|
|
52
|
-
console.error(error);
|
|
53
|
-
process.exit(1);
|
|
54
|
-
});
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import "dotenv/config";
|
|
2
|
-
import { loadConfig, ProjectManager, } from "../core/index.js";
|
|
3
|
-
import { createStorageProvider, withStorageRetry, ProjectScopedStorageProvider, PersistentCodeGraphStore, PersistentTypeResolutionStore, } from "../storage/index.js";
|
|
4
|
-
import { CodeGraphStore, RichGraphEnricher, getArchitecture, } from "./index.js";
|
|
5
|
-
async function main() {
|
|
6
|
-
const config = loadConfig();
|
|
7
|
-
const project = new ProjectManager()
|
|
8
|
-
.detect();
|
|
9
|
-
const raw = withStorageRetry(createStorageProvider({
|
|
10
|
-
provider: config.storage.provider,
|
|
11
|
-
huggingface: config.storage.huggingface,
|
|
12
|
-
localRoot: config.storage.localRoot,
|
|
13
|
-
}), {
|
|
14
|
-
attempts: 3,
|
|
15
|
-
});
|
|
16
|
-
const storage = new ProjectScopedStorageProvider(raw, project.id, project.name, project.remote ?? project.name);
|
|
17
|
-
const store = new PersistentCodeGraphStore(storage);
|
|
18
|
-
const snapshot = await store.load(project.id);
|
|
19
|
-
if (!snapshot) {
|
|
20
|
-
throw new Error("Code graph missing");
|
|
21
|
-
}
|
|
22
|
-
const graph = new CodeGraphStore();
|
|
23
|
-
graph.import(snapshot.symbols, snapshot.edges);
|
|
24
|
-
const resolution = await new PersistentTypeResolutionStore(storage).load(project.id);
|
|
25
|
-
const stats = new RichGraphEnricher(graph).enrich(project.id, project.rootPath, resolution);
|
|
26
|
-
const symbols = graph.allSymbols(project.id);
|
|
27
|
-
const edges = graph.allEdges(project.id);
|
|
28
|
-
await store.save({
|
|
29
|
-
version: 1,
|
|
30
|
-
projectId: project.id,
|
|
31
|
-
updatedAt: new Date()
|
|
32
|
-
.toISOString(),
|
|
33
|
-
files: symbols.filter((item) => item.type ===
|
|
34
|
-
"file").length,
|
|
35
|
-
symbols,
|
|
36
|
-
edges,
|
|
37
|
-
});
|
|
38
|
-
console.log({
|
|
39
|
-
ok: true,
|
|
40
|
-
project: project.name,
|
|
41
|
-
added: stats,
|
|
42
|
-
architecture: getArchitecture(graph, project.id),
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
main().catch((error) => {
|
|
46
|
-
console.error(error);
|
|
47
|
-
process.exit(1);
|
|
48
|
-
});
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import "dotenv/config";
|
|
2
|
-
import { loadConfig, ProjectManager, } from "../core/index.js";
|
|
3
|
-
import { createStorageProvider, PersistentCodeGraphStore, ProjectScopedStorageProvider, } from "../storage/index.js";
|
|
4
|
-
import { CodeGraphStore, SemanticCodeEngine, } from "./index.js";
|
|
5
|
-
import { createEmbeddingProvider, } from "../embeddings/index.js";
|
|
6
|
-
async function main() {
|
|
7
|
-
const config = loadConfig();
|
|
8
|
-
const project = new ProjectManager()
|
|
9
|
-
.detect();
|
|
10
|
-
const rawStorage = createStorageProvider({
|
|
11
|
-
provider: config.storage.provider,
|
|
12
|
-
huggingface: config.storage.huggingface,
|
|
13
|
-
localRoot: config.storage.localRoot,
|
|
14
|
-
});
|
|
15
|
-
const storage = new ProjectScopedStorageProvider(rawStorage, project.id, project.name, project.remote ?? project.name);
|
|
16
|
-
const graph = new CodeGraphStore();
|
|
17
|
-
const snapshot = await new PersistentCodeGraphStore(storage).load(project.id);
|
|
18
|
-
if (!snapshot) {
|
|
19
|
-
throw new Error("Code graph missing. Run npm run code:index:test first.");
|
|
20
|
-
}
|
|
21
|
-
graph.import(snapshot.symbols, snapshot.edges);
|
|
22
|
-
const engine = new SemanticCodeEngine({
|
|
23
|
-
projectId: project.id,
|
|
24
|
-
rootPath: project.rootPath,
|
|
25
|
-
model: process.env
|
|
26
|
-
.HF_EMBEDDING_MODEL ??
|
|
27
|
-
"sentence-transformers/all-MiniLM-L6-v2",
|
|
28
|
-
storage,
|
|
29
|
-
embeddings: createEmbeddingProvider(),
|
|
30
|
-
graph,
|
|
31
|
-
});
|
|
32
|
-
const stats = await engine.initialize();
|
|
33
|
-
const query = process.argv
|
|
34
|
-
.slice(2)
|
|
35
|
-
.join(" ") ||
|
|
36
|
-
"memory storage hugging face";
|
|
37
|
-
const results = await engine.search(query, 5);
|
|
38
|
-
console.log({
|
|
39
|
-
ok: true,
|
|
40
|
-
query,
|
|
41
|
-
...stats,
|
|
42
|
-
results: results.map((item) => ({
|
|
43
|
-
score: Number(item.score
|
|
44
|
-
.toFixed(4)),
|
|
45
|
-
file: item.chunk.filePath,
|
|
46
|
-
symbol: item.chunk.symbolName,
|
|
47
|
-
lines: `${item.chunk.startLine}-${item.chunk.endLine}`,
|
|
48
|
-
preview: item.chunk.content
|
|
49
|
-
.replace(/\s+/g, " ")
|
|
50
|
-
.slice(0, 140),
|
|
51
|
-
})),
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
main().catch((error) => {
|
|
55
|
-
console.error(error);
|
|
56
|
-
process.exit(1);
|
|
57
|
-
});
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import "dotenv/config";
|
|
2
|
-
import { loadConfig, ProjectManager, } from "../core/index.js";
|
|
3
|
-
import { createStorageProvider, withStorageRetry, ProjectScopedStorageProvider, PersistentArchitectureStore, PersistentCodeAnalysisStore, PersistentCodeGraphStore, PersistentVisualizationStore, } from "../storage/index.js";
|
|
4
|
-
import { CodeGraphStore, VisualizationBuilder, } from "./index.js";
|
|
5
|
-
async function main() {
|
|
6
|
-
const config = loadConfig();
|
|
7
|
-
const project = new ProjectManager()
|
|
8
|
-
.detect();
|
|
9
|
-
const rawStorage = withStorageRetry(createStorageProvider({
|
|
10
|
-
provider: config.storage.provider,
|
|
11
|
-
huggingface: config.storage.huggingface,
|
|
12
|
-
localRoot: config.storage.localRoot,
|
|
13
|
-
}), {
|
|
14
|
-
attempts: 3,
|
|
15
|
-
});
|
|
16
|
-
const storage = new ProjectScopedStorageProvider(rawStorage, project.id, project.name, project.remote ?? project.name);
|
|
17
|
-
const graphSnapshot = await new PersistentCodeGraphStore(storage).load(project.id);
|
|
18
|
-
if (!graphSnapshot) {
|
|
19
|
-
throw new Error("Code graph missing");
|
|
20
|
-
}
|
|
21
|
-
const architecture = await new PersistentArchitectureStore(storage).load(project.id);
|
|
22
|
-
const analysis = await new PersistentCodeAnalysisStore(storage).load(project.id);
|
|
23
|
-
const graph = new CodeGraphStore();
|
|
24
|
-
graph.import(graphSnapshot.symbols, graphSnapshot.edges);
|
|
25
|
-
const visualization = new VisualizationBuilder(graph).build(project.id, architecture, analysis);
|
|
26
|
-
await new PersistentVisualizationStore(storage).save(visualization);
|
|
27
|
-
console.log({
|
|
28
|
-
ok: true,
|
|
29
|
-
project: project.name,
|
|
30
|
-
...visualization.summary,
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
main().catch((error) => {
|
|
34
|
-
console.error(error);
|
|
35
|
-
process.exit(1);
|
|
36
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
export class VisualizationBuilder {
|
|
2
|
-
graph;
|
|
3
|
-
constructor(graph) {
|
|
4
|
-
this.graph = graph;
|
|
5
|
-
}
|
|
6
|
-
build(projectId, architecture, analysis) {
|
|
7
|
-
const symbols = this.graph.allSymbols(projectId);
|
|
8
|
-
const edges = this.graph.allEdges(projectId);
|
|
9
|
-
const layers = new Map(architecture
|
|
10
|
-
?.layers
|
|
11
|
-
.map((item) => [
|
|
12
|
-
item.filePath,
|
|
13
|
-
item.layer,
|
|
14
|
-
]) ??
|
|
15
|
-
[]);
|
|
16
|
-
const clusterByFile = new Map();
|
|
17
|
-
for (const cluster of architecture?.clusters ??
|
|
18
|
-
[]) {
|
|
19
|
-
for (const file of cluster.files) {
|
|
20
|
-
clusterByFile.set(file, {
|
|
21
|
-
id: cluster.id,
|
|
22
|
-
label: cluster.label,
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
const hotspotByFile = new Map(architecture
|
|
27
|
-
?.hotspots
|
|
28
|
-
.map((item) => [
|
|
29
|
-
item.filePath,
|
|
30
|
-
item.score,
|
|
31
|
-
]) ??
|
|
32
|
-
[]);
|
|
33
|
-
const deadCodeBySymbol = new Map(analysis
|
|
34
|
-
?.deadCode
|
|
35
|
-
.map((item) => [
|
|
36
|
-
item.symbolId,
|
|
37
|
-
{
|
|
38
|
-
confidence: item.confidence,
|
|
39
|
-
score: item.score,
|
|
40
|
-
},
|
|
41
|
-
]) ??
|
|
42
|
-
[]);
|
|
43
|
-
const incoming = new Map();
|
|
44
|
-
const outgoing = new Map();
|
|
45
|
-
for (const edge of edges) {
|
|
46
|
-
outgoing.set(edge.from, (outgoing.get(edge.from) ?? 0) + 1);
|
|
47
|
-
incoming.set(edge.to, (incoming.get(edge.to) ?? 0) + 1);
|
|
48
|
-
}
|
|
49
|
-
const nodes = symbols.map((symbol) => {
|
|
50
|
-
const cluster = clusterByFile.get(symbol.filePath);
|
|
51
|
-
return {
|
|
52
|
-
id: symbol.id,
|
|
53
|
-
name: symbol.name,
|
|
54
|
-
qualifiedName: symbol.qualifiedName,
|
|
55
|
-
type: symbol.type,
|
|
56
|
-
filePath: symbol.filePath,
|
|
57
|
-
layer: layers.get(symbol.filePath),
|
|
58
|
-
cluster: cluster?.id,
|
|
59
|
-
clusterLabel: cluster?.label,
|
|
60
|
-
hotspotScore: hotspotByFile.get(symbol.filePath),
|
|
61
|
-
deadCode: deadCodeBySymbol.get(symbol.id),
|
|
62
|
-
incoming: incoming.get(symbol.id) ?? 0,
|
|
63
|
-
outgoing: outgoing.get(symbol.id) ?? 0,
|
|
64
|
-
};
|
|
65
|
-
});
|
|
66
|
-
const symbolIds = new Set(nodes.map((node) => node.id));
|
|
67
|
-
const links = edges
|
|
68
|
-
.filter((edge) => symbolIds.has(edge.from) &&
|
|
69
|
-
symbolIds.has(edge.to))
|
|
70
|
-
.map((edge) => ({
|
|
71
|
-
source: edge.from,
|
|
72
|
-
target: edge.to,
|
|
73
|
-
type: edge.type,
|
|
74
|
-
confidence: typeof edge.metadata
|
|
75
|
-
?.confidence ===
|
|
76
|
-
"string"
|
|
77
|
-
? edge.metadata
|
|
78
|
-
.confidence
|
|
79
|
-
: undefined,
|
|
80
|
-
resolver: typeof edge.metadata
|
|
81
|
-
?.resolver ===
|
|
82
|
-
"string"
|
|
83
|
-
? edge.metadata
|
|
84
|
-
.resolver
|
|
85
|
-
: undefined,
|
|
86
|
-
}));
|
|
87
|
-
return {
|
|
88
|
-
version: 1,
|
|
89
|
-
projectId,
|
|
90
|
-
generatedAt: new Date()
|
|
91
|
-
.toISOString(),
|
|
92
|
-
summary: {
|
|
93
|
-
nodes: nodes.length,
|
|
94
|
-
links: links.length,
|
|
95
|
-
files: new Set(nodes.map((node) => node.filePath)).size,
|
|
96
|
-
clusters: new Set(nodes
|
|
97
|
-
.map((node) => node.cluster)
|
|
98
|
-
.filter(Boolean)).size,
|
|
99
|
-
},
|
|
100
|
-
nodes,
|
|
101
|
-
links,
|
|
102
|
-
};
|
|
103
|
-
}
|
|
104
|
-
}
|
package/dist/src/core/config.js
DELETED
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import "./global-env.js";
|
|
2
|
-
function envBool(value, fallback) {
|
|
3
|
-
if (value === undefined) {
|
|
4
|
-
return fallback;
|
|
5
|
-
}
|
|
6
|
-
return [
|
|
7
|
-
"1",
|
|
8
|
-
"true",
|
|
9
|
-
"yes",
|
|
10
|
-
"on",
|
|
11
|
-
].includes(value.toLowerCase());
|
|
12
|
-
}
|
|
13
|
-
function envNumber(value, fallback) {
|
|
14
|
-
if (!value) {
|
|
15
|
-
return fallback;
|
|
16
|
-
}
|
|
17
|
-
const parsed = Number(value);
|
|
18
|
-
return Number.isFinite(parsed)
|
|
19
|
-
? parsed
|
|
20
|
-
: fallback;
|
|
21
|
-
}
|
|
22
|
-
export function loadConfig() {
|
|
23
|
-
return {
|
|
24
|
-
memory: {
|
|
25
|
-
autoCapture: envBool(process.env
|
|
26
|
-
.MEMORY_AUTO_CAPTURE, true),
|
|
27
|
-
autoRetrieve: envBool(process.env
|
|
28
|
-
.MEMORY_AUTO_RETRIEVE, true),
|
|
29
|
-
autoSummarize: envBool(process.env
|
|
30
|
-
.MEMORY_AUTO_SUMMARIZE, true),
|
|
31
|
-
autoSync: envBool(process.env
|
|
32
|
-
.MEMORY_AUTO_SYNC, true),
|
|
33
|
-
},
|
|
34
|
-
retrieval: {
|
|
35
|
-
maxCandidates: envNumber(process.env
|
|
36
|
-
.MEMORY_MAX_CANDIDATES, 50),
|
|
37
|
-
rerankTop: envNumber(process.env
|
|
38
|
-
.MEMORY_RERANK_TOP, 10),
|
|
39
|
-
finalContext: envNumber(process.env
|
|
40
|
-
.MEMORY_FINAL_CONTEXT, 5),
|
|
41
|
-
tokenBudget: envNumber(process.env
|
|
42
|
-
.MEMORY_TOKEN_BUDGET, 2000),
|
|
43
|
-
},
|
|
44
|
-
storage: {
|
|
45
|
-
provider: process.env
|
|
46
|
-
.MEMORY_STORAGE_PROVIDER ??
|
|
47
|
-
"huggingface",
|
|
48
|
-
huggingface: {
|
|
49
|
-
namespace: process.env
|
|
50
|
-
.HF_NAMESPACE,
|
|
51
|
-
bucket: process.env
|
|
52
|
-
.HF_BUCKET,
|
|
53
|
-
accessKeyId: process.env
|
|
54
|
-
.HF_S3_ACCESS_KEY_ID,
|
|
55
|
-
secretAccessKey: process.env
|
|
56
|
-
.HF_S3_SECRET_ACCESS_KEY,
|
|
57
|
-
},
|
|
58
|
-
localRoot: process.env
|
|
59
|
-
.MEMORY_LOCAL_STORAGE_PATH,
|
|
60
|
-
},
|
|
61
|
-
cache: {
|
|
62
|
-
maxMb: envNumber(process.env
|
|
63
|
-
.MEMORY_LOCAL_CACHE_MB, 200),
|
|
64
|
-
},
|
|
65
|
-
};
|
|
66
|
-
}
|