@optave/codegraph 3.1.4 → 3.1.5
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 +26 -70
- package/package.json +10 -8
- package/src/ast-analysis/engine.js +32 -12
- package/src/ast-analysis/shared.js +2 -2
- package/src/cli/commands/ast.js +2 -6
- package/src/cli/commands/audit.js +9 -10
- package/src/cli/commands/batch.js +4 -4
- package/src/cli/commands/branch-compare.js +1 -1
- package/src/cli/commands/build.js +1 -1
- package/src/cli/commands/cfg.js +3 -7
- package/src/cli/commands/check.js +12 -17
- package/src/cli/commands/children.js +3 -6
- package/src/cli/commands/co-change.js +5 -3
- package/src/cli/commands/communities.js +2 -6
- package/src/cli/commands/complexity.js +3 -2
- package/src/cli/commands/context.js +3 -7
- package/src/cli/commands/cycles.js +12 -8
- package/src/cli/commands/dataflow.js +3 -7
- package/src/cli/commands/deps.js +2 -6
- package/src/cli/commands/diff-impact.js +2 -6
- package/src/cli/commands/embed.js +1 -1
- package/src/cli/commands/export.js +34 -31
- package/src/cli/commands/exports.js +2 -6
- package/src/cli/commands/flow.js +3 -7
- package/src/cli/commands/fn-impact.js +3 -7
- package/src/cli/commands/impact.js +2 -6
- package/src/cli/commands/info.js +2 -2
- package/src/cli/commands/map.js +1 -1
- package/src/cli/commands/mcp.js +1 -1
- package/src/cli/commands/models.js +1 -1
- package/src/cli/commands/owners.js +1 -1
- package/src/cli/commands/path.js +2 -2
- package/src/cli/commands/plot.js +40 -31
- package/src/cli/commands/query.js +3 -7
- package/src/cli/commands/registry.js +2 -2
- package/src/cli/commands/roles.js +3 -7
- package/src/cli/commands/search.js +1 -1
- package/src/cli/commands/sequence.js +3 -7
- package/src/cli/commands/snapshot.js +6 -1
- package/src/cli/commands/stats.js +1 -1
- package/src/cli/commands/structure.js +5 -4
- package/src/cli/commands/triage.js +4 -4
- package/src/cli/commands/watch.js +1 -1
- package/src/cli/commands/where.js +2 -6
- package/src/cli/index.js +11 -5
- package/src/cli/shared/open-graph.js +13 -0
- package/src/cli/shared/options.js +22 -2
- package/src/cli.js +1 -1
- package/src/db/connection.js +127 -4
- package/src/{db.js → db/index.js} +12 -5
- package/src/db/migrations.js +1 -1
- package/src/db/query-builder.js +15 -8
- package/src/db/repository/base.js +1 -1
- package/src/db/repository/graph-read.js +3 -3
- package/src/db/repository/in-memory-repository.js +4 -13
- package/src/db/repository/nodes.js +3 -8
- package/src/{analysis → domain/analysis}/context.js +6 -6
- package/src/{analysis → domain/analysis}/dependencies.js +5 -5
- package/src/{analysis → domain/analysis}/exports.js +8 -4
- package/src/{analysis → domain/analysis}/impact.js +61 -58
- package/src/{analysis → domain/analysis}/module-map.js +3 -3
- package/src/{analysis → domain/analysis}/roles.js +4 -4
- package/src/{analysis → domain/analysis}/symbol-lookup.js +13 -7
- package/src/{builder → domain/graph/builder}/helpers.js +3 -3
- package/src/{builder → domain/graph/builder}/incremental.js +3 -3
- package/src/{builder → domain/graph/builder}/pipeline.js +4 -4
- package/src/{builder → domain/graph/builder}/stages/build-edges.js +2 -2
- package/src/{builder → domain/graph/builder}/stages/build-structure.js +4 -4
- package/src/{builder → domain/graph/builder}/stages/collect-files.js +2 -2
- package/src/{builder → domain/graph/builder}/stages/detect-changes.js +6 -6
- package/src/{builder → domain/graph/builder}/stages/finalize.js +4 -4
- package/src/{builder → domain/graph/builder}/stages/insert-nodes.js +1 -1
- package/src/{builder → domain/graph/builder}/stages/parse-files.js +2 -2
- package/src/{builder → domain/graph/builder}/stages/resolve-imports.js +1 -1
- package/src/{builder → domain/graph/builder}/stages/run-analyses.js +2 -2
- package/src/{change-journal.js → domain/graph/change-journal.js} +1 -1
- package/src/{cycles.js → domain/graph/cycles.js} +4 -4
- package/src/{journal.js → domain/graph/journal.js} +1 -1
- package/src/{resolve.js → domain/graph/resolve.js} +2 -2
- package/src/{watcher.js → domain/graph/watcher.js} +5 -5
- package/src/{parser.js → domain/parser.js} +5 -5
- package/src/{queries.js → domain/queries.js} +16 -16
- package/src/{embeddings → domain/search}/generator.js +3 -3
- package/src/{embeddings → domain/search}/models.js +2 -2
- package/src/{embeddings → domain/search}/search/cli-formatter.js +1 -1
- package/src/{embeddings → domain/search}/search/hybrid.js +1 -1
- package/src/{embeddings → domain/search}/search/keyword.js +1 -1
- package/src/{embeddings → domain/search}/search/prepare.js +2 -2
- package/src/{embeddings → domain/search}/search/semantic.js +1 -1
- package/src/{embeddings → domain/search}/strategies/structured.js +1 -1
- package/src/extractors/javascript.js +1 -1
- package/src/{ast.js → features/ast.js} +8 -8
- package/src/{audit.js → features/audit.js} +16 -44
- package/src/{batch.js → features/batch.js} +5 -5
- package/src/{boundaries.js → features/boundaries.js} +2 -2
- package/src/{branch-compare.js → features/branch-compare.js} +3 -3
- package/src/{cfg.js → features/cfg.js} +10 -10
- package/src/{check.js → features/check.js} +13 -30
- package/src/{cochange.js → features/cochange.js} +5 -5
- package/src/{communities.js → features/communities.js} +7 -7
- package/src/{complexity.js → features/complexity.js} +13 -13
- package/src/{dataflow.js → features/dataflow.js} +11 -11
- package/src/{export.js → features/export.js} +3 -3
- package/src/{flow.js → features/flow.js} +4 -4
- package/src/{viewer.js → features/graph-enrichment.js} +6 -6
- package/src/{manifesto.js → features/manifesto.js} +6 -6
- package/src/{owners.js → features/owners.js} +2 -2
- package/src/{sequence.js → features/sequence.js} +15 -15
- package/src/{snapshot.js → features/snapshot.js} +3 -3
- package/src/{structure.js → features/structure.js} +7 -7
- package/src/{triage.js → features/triage.js} +8 -8
- package/src/graph/builders/dependency.js +33 -14
- package/src/index.cjs +16 -0
- package/src/index.js +39 -39
- package/src/{native.js → infrastructure/native.js} +1 -1
- package/src/mcp/middleware.js +1 -1
- package/src/mcp/server.js +5 -5
- package/src/mcp/tool-registry.js +2 -2
- package/src/mcp/tools/ast-query.js +1 -1
- package/src/mcp/tools/audit.js +1 -1
- package/src/mcp/tools/batch-query.js +1 -1
- package/src/mcp/tools/branch-compare.js +3 -1
- package/src/mcp/tools/cfg.js +1 -1
- package/src/mcp/tools/check.js +3 -3
- package/src/mcp/tools/co-changes.js +1 -1
- package/src/mcp/tools/code-owners.js +1 -1
- package/src/mcp/tools/communities.js +1 -1
- package/src/mcp/tools/complexity.js +1 -1
- package/src/mcp/tools/dataflow.js +2 -2
- package/src/mcp/tools/execution-flow.js +2 -2
- package/src/mcp/tools/export-graph.js +2 -2
- package/src/mcp/tools/find-cycles.js +2 -2
- package/src/mcp/tools/list-repos.js +1 -1
- package/src/mcp/tools/sequence.js +1 -1
- package/src/mcp/tools/structure.js +1 -1
- package/src/mcp/tools/triage.js +2 -2
- package/src/{commands → presentation}/audit.js +2 -2
- package/src/{commands → presentation}/batch.js +1 -1
- package/src/{commands → presentation}/branch-compare.js +2 -2
- package/src/{commands → presentation}/cfg.js +1 -1
- package/src/{commands → presentation}/check.js +2 -2
- package/src/{commands → presentation}/communities.js +1 -1
- package/src/{commands → presentation}/complexity.js +1 -1
- package/src/{commands → presentation}/dataflow.js +1 -1
- package/src/{commands → presentation}/flow.js +2 -2
- package/src/{commands → presentation}/manifesto.js +1 -1
- package/src/{commands → presentation}/owners.js +1 -1
- package/src/presentation/queries-cli/exports.js +46 -0
- package/src/presentation/queries-cli/impact.js +198 -0
- package/src/presentation/queries-cli/index.js +5 -0
- package/src/presentation/queries-cli/inspect.js +334 -0
- package/src/presentation/queries-cli/overview.js +197 -0
- package/src/presentation/queries-cli/path.js +58 -0
- package/src/presentation/queries-cli.js +27 -0
- package/src/{commands → presentation}/query.js +1 -1
- package/src/presentation/result-formatter.js +126 -3
- package/src/{commands → presentation}/sequence.js +2 -2
- package/src/{commands → presentation}/structure.js +1 -1
- package/src/{commands → presentation}/triage.js +1 -1
- package/src/{constants.js → shared/constants.js} +1 -1
- package/src/shared/file-utils.js +2 -2
- package/src/shared/generators.js +2 -2
- package/src/shared/hierarchy.js +1 -1
- package/src/mcp.js +0 -2
- package/src/queries-cli.js +0 -866
- /package/src/{builder → domain/graph/builder}/context.js +0 -0
- /package/src/{builder.js → domain/graph/builder.js} +0 -0
- /package/src/{embeddings → domain/search}/index.js +0 -0
- /package/src/{embeddings → domain/search}/search/filters.js +0 -0
- /package/src/{embeddings → domain/search}/stores/fts5.js +0 -0
- /package/src/{embeddings → domain/search}/stores/sqlite-blob.js +0 -0
- /package/src/{embeddings → domain/search}/strategies/source.js +0 -0
- /package/src/{embeddings → domain/search}/strategies/text-utils.js +0 -0
- /package/src/{config.js → infrastructure/config.js} +0 -0
- /package/src/{logger.js → infrastructure/logger.js} +0 -0
- /package/src/{registry.js → infrastructure/registry.js} +0 -0
- /package/src/{update-check.js → infrastructure/update-check.js} +0 -0
- /package/src/{commands → presentation}/cochange.js +0 -0
- /package/src/{errors.js → shared/errors.js} +0 -0
- /package/src/{kinds.js → shared/kinds.js} +0 -0
- /package/src/{paginate.js → shared/paginate.js} +0 -0
package/src/index.cjs
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CJS compatibility wrapper — delegates to ESM via dynamic import().
|
|
3
|
+
*
|
|
4
|
+
* This wrapper always returns a Promise on every Node version, because
|
|
5
|
+
* import() is unconditionally async. You must always await the result:
|
|
6
|
+
*
|
|
7
|
+
* const codegraph = await require('@optave/codegraph');
|
|
8
|
+
*
|
|
9
|
+
* // Named destructuring at require-time does NOT work — always await the full result first.
|
|
10
|
+
* // BAD: const { buildGraph } = require('@optave/codegraph'); // buildGraph is undefined
|
|
11
|
+
* // GOOD: const { buildGraph } = await require('@optave/codegraph');
|
|
12
|
+
*/
|
|
13
|
+
// Note: if import() rejects (e.g. missing dependency), the rejected Promise is cached
|
|
14
|
+
// by the CJS module system and every subsequent require() call will re-surface the same
|
|
15
|
+
// rejection without re-attempting the load.
|
|
16
|
+
module.exports = import('./index.js');
|
package/src/index.js
CHANGED
|
@@ -9,41 +9,8 @@
|
|
|
9
9
|
* import { buildGraph, queryNameData, findCycles, exportDOT } from '@optave/codegraph';
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
-
export {
|
|
13
|
-
export {
|
|
14
|
-
export { batchData } from './batch.js';
|
|
15
|
-
export { branchCompareData } from './branch-compare.js';
|
|
16
|
-
export { buildGraph } from './builder.js';
|
|
17
|
-
export { cfgData } from './cfg.js';
|
|
18
|
-
export { checkData } from './check.js';
|
|
19
|
-
export { coChangeData } from './cochange.js';
|
|
20
|
-
export { communitiesData } from './communities.js';
|
|
21
|
-
export { complexityData } from './complexity.js';
|
|
22
|
-
export { loadConfig } from './config.js';
|
|
23
|
-
export { EXTENSIONS, IGNORE_DIRS } from './constants.js';
|
|
24
|
-
export { findCycles } from './cycles.js';
|
|
25
|
-
export { dataflowData } from './dataflow.js';
|
|
26
|
-
export {
|
|
27
|
-
buildEmbeddings,
|
|
28
|
-
hybridSearchData,
|
|
29
|
-
multiSearchData,
|
|
30
|
-
searchData,
|
|
31
|
-
} from './embeddings/index.js';
|
|
32
|
-
export {
|
|
33
|
-
AnalysisError,
|
|
34
|
-
BoundaryError,
|
|
35
|
-
CodegraphError,
|
|
36
|
-
ConfigError,
|
|
37
|
-
DbError,
|
|
38
|
-
EngineError,
|
|
39
|
-
ParseError,
|
|
40
|
-
ResolutionError,
|
|
41
|
-
} from './errors.js';
|
|
42
|
-
export { exportDOT, exportJSON, exportMermaid } from './export.js';
|
|
43
|
-
export { flowData, listEntryPointsData } from './flow.js';
|
|
44
|
-
export { EVERY_EDGE_KIND, EVERY_SYMBOL_KIND } from './kinds.js';
|
|
45
|
-
export { manifestoData } from './manifesto.js';
|
|
46
|
-
export { ownersData } from './owners.js';
|
|
12
|
+
export { buildGraph } from './domain/graph/builder.js';
|
|
13
|
+
export { findCycles } from './domain/graph/cycles.js';
|
|
47
14
|
export {
|
|
48
15
|
childrenData,
|
|
49
16
|
contextData,
|
|
@@ -60,7 +27,40 @@ export {
|
|
|
60
27
|
rolesData,
|
|
61
28
|
statsData,
|
|
62
29
|
whereData,
|
|
63
|
-
} from './queries.js';
|
|
64
|
-
export {
|
|
65
|
-
|
|
66
|
-
|
|
30
|
+
} from './domain/queries.js';
|
|
31
|
+
export {
|
|
32
|
+
buildEmbeddings,
|
|
33
|
+
hybridSearchData,
|
|
34
|
+
multiSearchData,
|
|
35
|
+
searchData,
|
|
36
|
+
} from './domain/search/index.js';
|
|
37
|
+
export { astQueryData } from './features/ast.js';
|
|
38
|
+
export { auditData } from './features/audit.js';
|
|
39
|
+
export { batchData } from './features/batch.js';
|
|
40
|
+
export { branchCompareData } from './features/branch-compare.js';
|
|
41
|
+
export { cfgData } from './features/cfg.js';
|
|
42
|
+
export { checkData } from './features/check.js';
|
|
43
|
+
export { coChangeData } from './features/cochange.js';
|
|
44
|
+
export { communitiesData } from './features/communities.js';
|
|
45
|
+
export { complexityData } from './features/complexity.js';
|
|
46
|
+
export { dataflowData } from './features/dataflow.js';
|
|
47
|
+
export { exportDOT, exportJSON, exportMermaid } from './features/export.js';
|
|
48
|
+
export { flowData, listEntryPointsData } from './features/flow.js';
|
|
49
|
+
export { manifestoData } from './features/manifesto.js';
|
|
50
|
+
export { ownersData } from './features/owners.js';
|
|
51
|
+
export { sequenceData } from './features/sequence.js';
|
|
52
|
+
export { hotspotsData, moduleBoundariesData, structureData } from './features/structure.js';
|
|
53
|
+
export { triageData } from './features/triage.js';
|
|
54
|
+
export { loadConfig } from './infrastructure/config.js';
|
|
55
|
+
export { EXTENSIONS, IGNORE_DIRS } from './shared/constants.js';
|
|
56
|
+
export {
|
|
57
|
+
AnalysisError,
|
|
58
|
+
BoundaryError,
|
|
59
|
+
CodegraphError,
|
|
60
|
+
ConfigError,
|
|
61
|
+
DbError,
|
|
62
|
+
EngineError,
|
|
63
|
+
ParseError,
|
|
64
|
+
ResolutionError,
|
|
65
|
+
} from './shared/errors.js';
|
|
66
|
+
export { EVERY_EDGE_KIND, EVERY_SYMBOL_KIND } from './shared/kinds.js';
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
import { createRequire } from 'node:module';
|
|
10
10
|
import os from 'node:os';
|
|
11
|
-
import { EngineError } from '
|
|
11
|
+
import { EngineError } from '../shared/errors.js';
|
|
12
12
|
|
|
13
13
|
let _cached; // undefined = not yet tried, null = failed, object = module
|
|
14
14
|
let _loadError = null;
|
package/src/mcp/middleware.js
CHANGED
package/src/mcp/server.js
CHANGED
|
@@ -6,9 +6,9 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import { createRequire } from 'node:module';
|
|
9
|
-
import { findDbPath } from '../db.js';
|
|
10
|
-
import { CodegraphError, ConfigError } from '../errors.js';
|
|
11
|
-
import { MCP_MAX_LIMIT } from '../paginate.js';
|
|
9
|
+
import { findDbPath } from '../db/index.js';
|
|
10
|
+
import { CodegraphError, ConfigError } from '../shared/errors.js';
|
|
11
|
+
import { MCP_MAX_LIMIT } from '../shared/paginate.js';
|
|
12
12
|
import { buildToolList } from './tool-registry.js';
|
|
13
13
|
import { TOOL_HANDLERS } from './tools/index.js';
|
|
14
14
|
|
|
@@ -48,7 +48,7 @@ export async function startMCPServer(customDbPath, options = {}) {
|
|
|
48
48
|
|
|
49
49
|
async function getQueries() {
|
|
50
50
|
if (!_queries) {
|
|
51
|
-
_queries = await import('../queries.js');
|
|
51
|
+
_queries = await import('../domain/queries.js');
|
|
52
52
|
}
|
|
53
53
|
return _queries;
|
|
54
54
|
}
|
|
@@ -89,7 +89,7 @@ export async function startMCPServer(customDbPath, options = {}) {
|
|
|
89
89
|
if (allowedRepos && !allowedRepos.includes(args.repo)) {
|
|
90
90
|
throw new ConfigError(`Repository "${args.repo}" is not in the allowed repos list.`);
|
|
91
91
|
}
|
|
92
|
-
const { resolveRepoDbPath } = await import('../registry.js');
|
|
92
|
+
const { resolveRepoDbPath } = await import('../infrastructure/registry.js');
|
|
93
93
|
const resolved = resolveRepoDbPath(args.repo);
|
|
94
94
|
if (!resolved)
|
|
95
95
|
throw new ConfigError(
|
package/src/mcp/tool-registry.js
CHANGED
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
* Owns BASE_TOOLS, LIST_REPOS_TOOL, buildToolList(), and the backward-compatible TOOLS export.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
7
|
+
import { EVERY_EDGE_KIND, EVERY_SYMBOL_KIND, VALID_ROLES } from '../domain/queries.js';
|
|
8
|
+
import { AST_NODE_KINDS } from '../features/ast.js';
|
|
9
9
|
|
|
10
10
|
const REPO_PROP = {
|
|
11
11
|
repo: {
|
|
@@ -3,7 +3,7 @@ import { effectiveLimit, effectiveOffset } from '../middleware.js';
|
|
|
3
3
|
export const name = 'ast_query';
|
|
4
4
|
|
|
5
5
|
export async function handler(args, ctx) {
|
|
6
|
-
const { astQueryData } = await import('../../ast.js');
|
|
6
|
+
const { astQueryData } = await import('../../features/ast.js');
|
|
7
7
|
return astQueryData(args.pattern, ctx.dbPath, {
|
|
8
8
|
kind: args.kind,
|
|
9
9
|
file: args.file,
|
package/src/mcp/tools/audit.js
CHANGED
|
@@ -11,7 +11,7 @@ export async function handler(args, ctx) {
|
|
|
11
11
|
offset: effectiveOffset(args),
|
|
12
12
|
});
|
|
13
13
|
}
|
|
14
|
-
const { auditData } = await import('../../audit.js');
|
|
14
|
+
const { auditData } = await import('../../features/audit.js');
|
|
15
15
|
return auditData(args.target, ctx.dbPath, {
|
|
16
16
|
depth: args.depth,
|
|
17
17
|
file: args.file,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export const name = 'batch_query';
|
|
2
2
|
|
|
3
3
|
export async function handler(args, ctx) {
|
|
4
|
-
const { batchData } = await import('../../batch.js');
|
|
4
|
+
const { batchData } = await import('../../features/batch.js');
|
|
5
5
|
return batchData(args.command, args.targets, ctx.dbPath, {
|
|
6
6
|
depth: args.depth,
|
|
7
7
|
file: args.file,
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
export const name = 'branch_compare';
|
|
2
2
|
|
|
3
3
|
export async function handler(args, _ctx) {
|
|
4
|
-
const { branchCompareData, branchCompareMermaid } = await import(
|
|
4
|
+
const { branchCompareData, branchCompareMermaid } = await import(
|
|
5
|
+
'../../features/branch-compare.js'
|
|
6
|
+
);
|
|
5
7
|
const bcData = await branchCompareData(args.base, args.target, {
|
|
6
8
|
depth: args.depth,
|
|
7
9
|
noTests: args.no_tests,
|
package/src/mcp/tools/cfg.js
CHANGED
|
@@ -3,7 +3,7 @@ import { effectiveOffset, MCP_DEFAULTS } from '../middleware.js';
|
|
|
3
3
|
export const name = 'cfg';
|
|
4
4
|
|
|
5
5
|
export async function handler(args, ctx) {
|
|
6
|
-
const { cfgData, cfgToDOT, cfgToMermaid } = await import('../../cfg.js');
|
|
6
|
+
const { cfgData, cfgToDOT, cfgToMermaid } = await import('../../features/cfg.js');
|
|
7
7
|
const cfgResult = cfgData(args.name, ctx.dbPath, {
|
|
8
8
|
file: args.file,
|
|
9
9
|
kind: args.kind,
|
package/src/mcp/tools/check.js
CHANGED
|
@@ -6,7 +6,7 @@ export async function handler(args, ctx) {
|
|
|
6
6
|
const isDiffMode = args.ref || args.staged;
|
|
7
7
|
|
|
8
8
|
if (!isDiffMode && !args.rules) {
|
|
9
|
-
const { manifestoData } = await import('../../manifesto.js');
|
|
9
|
+
const { manifestoData } = await import('../../features/manifesto.js');
|
|
10
10
|
return manifestoData(ctx.dbPath, {
|
|
11
11
|
file: args.file,
|
|
12
12
|
noTests: args.no_tests,
|
|
@@ -16,7 +16,7 @@ export async function handler(args, ctx) {
|
|
|
16
16
|
});
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
const { checkData } = await import('../../check.js');
|
|
19
|
+
const { checkData } = await import('../../features/check.js');
|
|
20
20
|
const checkResult = checkData(ctx.dbPath, {
|
|
21
21
|
ref: args.ref,
|
|
22
22
|
staged: args.staged,
|
|
@@ -29,7 +29,7 @@ export async function handler(args, ctx) {
|
|
|
29
29
|
});
|
|
30
30
|
|
|
31
31
|
if (args.rules) {
|
|
32
|
-
const { manifestoData } = await import('../../manifesto.js');
|
|
32
|
+
const { manifestoData } = await import('../../features/manifesto.js');
|
|
33
33
|
const manifestoResult = manifestoData(ctx.dbPath, {
|
|
34
34
|
file: args.file,
|
|
35
35
|
noTests: args.no_tests,
|
|
@@ -3,7 +3,7 @@ import { effectiveLimit, effectiveOffset } from '../middleware.js';
|
|
|
3
3
|
export const name = 'co_changes';
|
|
4
4
|
|
|
5
5
|
export async function handler(args, ctx) {
|
|
6
|
-
const { coChangeData, coChangeTopData } = await import('../../cochange.js');
|
|
6
|
+
const { coChangeData, coChangeTopData } = await import('../../features/cochange.js');
|
|
7
7
|
return args.file
|
|
8
8
|
? coChangeData(args.file, ctx.dbPath, {
|
|
9
9
|
limit: effectiveLimit(args, name),
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export const name = 'code_owners';
|
|
2
2
|
|
|
3
3
|
export async function handler(args, ctx) {
|
|
4
|
-
const { ownersData } = await import('../../owners.js');
|
|
4
|
+
const { ownersData } = await import('../../features/owners.js');
|
|
5
5
|
return ownersData(ctx.dbPath, {
|
|
6
6
|
file: args.file,
|
|
7
7
|
owner: args.owner,
|
|
@@ -3,7 +3,7 @@ import { effectiveLimit, effectiveOffset } from '../middleware.js';
|
|
|
3
3
|
export const name = 'communities';
|
|
4
4
|
|
|
5
5
|
export async function handler(args, ctx) {
|
|
6
|
-
const { communitiesData } = await import('../../communities.js');
|
|
6
|
+
const { communitiesData } = await import('../../features/communities.js');
|
|
7
7
|
return communitiesData(ctx.dbPath, {
|
|
8
8
|
functions: args.functions,
|
|
9
9
|
resolution: args.resolution,
|
|
@@ -3,7 +3,7 @@ import { effectiveLimit, effectiveOffset } from '../middleware.js';
|
|
|
3
3
|
export const name = 'complexity';
|
|
4
4
|
|
|
5
5
|
export async function handler(args, ctx) {
|
|
6
|
-
const { complexityData } = await import('../../complexity.js');
|
|
6
|
+
const { complexityData } = await import('../../features/complexity.js');
|
|
7
7
|
return complexityData(ctx.dbPath, {
|
|
8
8
|
target: args.name,
|
|
9
9
|
file: args.file,
|
|
@@ -5,7 +5,7 @@ export const name = 'dataflow';
|
|
|
5
5
|
export async function handler(args, ctx) {
|
|
6
6
|
const dfMode = args.mode || 'edges';
|
|
7
7
|
if (dfMode === 'impact') {
|
|
8
|
-
const { dataflowImpactData } = await import('../../dataflow.js');
|
|
8
|
+
const { dataflowImpactData } = await import('../../features/dataflow.js');
|
|
9
9
|
return dataflowImpactData(args.name, ctx.dbPath, {
|
|
10
10
|
depth: args.depth,
|
|
11
11
|
file: args.file,
|
|
@@ -15,7 +15,7 @@ export async function handler(args, ctx) {
|
|
|
15
15
|
offset: effectiveOffset(args),
|
|
16
16
|
});
|
|
17
17
|
}
|
|
18
|
-
const { dataflowData } = await import('../../dataflow.js');
|
|
18
|
+
const { dataflowData } = await import('../../features/dataflow.js');
|
|
19
19
|
return dataflowData(args.name, ctx.dbPath, {
|
|
20
20
|
file: args.file,
|
|
21
21
|
kind: args.kind,
|
|
@@ -4,7 +4,7 @@ export const name = 'execution_flow';
|
|
|
4
4
|
|
|
5
5
|
export async function handler(args, ctx) {
|
|
6
6
|
if (args.list) {
|
|
7
|
-
const { listEntryPointsData } = await import('../../flow.js');
|
|
7
|
+
const { listEntryPointsData } = await import('../../features/flow.js');
|
|
8
8
|
return listEntryPointsData(ctx.dbPath, {
|
|
9
9
|
noTests: args.no_tests,
|
|
10
10
|
limit: effectiveLimit(args, name),
|
|
@@ -14,7 +14,7 @@ export async function handler(args, ctx) {
|
|
|
14
14
|
if (!args.name) {
|
|
15
15
|
return { error: 'Provide a name or set list=true' };
|
|
16
16
|
}
|
|
17
|
-
const { flowData } = await import('../../flow.js');
|
|
17
|
+
const { flowData } = await import('../../features/flow.js');
|
|
18
18
|
return flowData(args.name, ctx.dbPath, {
|
|
19
19
|
depth: args.depth,
|
|
20
20
|
file: args.file,
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { findDbPath } from '../../db.js';
|
|
1
|
+
import { findDbPath } from '../../db/index.js';
|
|
2
2
|
import { effectiveOffset, MCP_DEFAULTS, MCP_MAX_LIMIT } from '../middleware.js';
|
|
3
3
|
|
|
4
4
|
export const name = 'export_graph';
|
|
5
5
|
|
|
6
6
|
export async function handler(args, ctx) {
|
|
7
7
|
const { exportDOT, exportGraphML, exportGraphSON, exportJSON, exportMermaid, exportNeo4jCSV } =
|
|
8
|
-
await import('../../export.js');
|
|
8
|
+
await import('../../features/export.js');
|
|
9
9
|
const Database = ctx.getDatabase();
|
|
10
10
|
const db = new Database(findDbPath(ctx.dbPath), { readonly: true });
|
|
11
11
|
const fileLevel = args.file_level !== false;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export const name = 'list_repos';
|
|
2
2
|
|
|
3
3
|
export async function handler(_args, ctx) {
|
|
4
|
-
const { listRepos, pruneRegistry } = await import('../../registry.js');
|
|
4
|
+
const { listRepos, pruneRegistry } = await import('../../infrastructure/registry.js');
|
|
5
5
|
pruneRegistry();
|
|
6
6
|
let repos = listRepos();
|
|
7
7
|
if (ctx.allowedRepos) {
|
|
@@ -3,7 +3,7 @@ import { effectiveOffset, MCP_DEFAULTS } from '../middleware.js';
|
|
|
3
3
|
export const name = 'sequence';
|
|
4
4
|
|
|
5
5
|
export async function handler(args, ctx) {
|
|
6
|
-
const { sequenceData, sequenceToMermaid } = await import('../../sequence.js');
|
|
6
|
+
const { sequenceData, sequenceToMermaid } = await import('../../features/sequence.js');
|
|
7
7
|
const seqResult = sequenceData(args.name, ctx.dbPath, {
|
|
8
8
|
depth: args.depth,
|
|
9
9
|
file: args.file,
|
|
@@ -3,7 +3,7 @@ import { effectiveLimit, effectiveOffset } from '../middleware.js';
|
|
|
3
3
|
export const name = 'structure';
|
|
4
4
|
|
|
5
5
|
export async function handler(args, ctx) {
|
|
6
|
-
const { structureData } = await import('../../structure.js');
|
|
6
|
+
const { structureData } = await import('../../features/structure.js');
|
|
7
7
|
return structureData(ctx.dbPath, {
|
|
8
8
|
directory: args.directory,
|
|
9
9
|
depth: args.depth,
|
package/src/mcp/tools/triage.js
CHANGED
|
@@ -4,7 +4,7 @@ export const name = 'triage';
|
|
|
4
4
|
|
|
5
5
|
export async function handler(args, ctx) {
|
|
6
6
|
if (args.level === 'file' || args.level === 'directory') {
|
|
7
|
-
const { hotspotsData } = await import('../../structure.js');
|
|
7
|
+
const { hotspotsData } = await import('../../features/structure.js');
|
|
8
8
|
const TRIAGE_TO_HOTSPOT = {
|
|
9
9
|
risk: 'fan-in',
|
|
10
10
|
complexity: 'density',
|
|
@@ -20,7 +20,7 @@ export async function handler(args, ctx) {
|
|
|
20
20
|
noTests: args.no_tests,
|
|
21
21
|
});
|
|
22
22
|
}
|
|
23
|
-
const { triageData } = await import('../../triage.js');
|
|
23
|
+
const { triageData } = await import('../../features/triage.js');
|
|
24
24
|
return triageData(ctx.dbPath, {
|
|
25
25
|
sort: args.sort,
|
|
26
26
|
minScore: args.min_score,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { kindIcon } from '../domain/queries.js';
|
|
2
|
+
import { auditData } from '../features/audit.js';
|
|
2
3
|
import { outputResult } from '../infrastructure/result-formatter.js';
|
|
3
|
-
import { kindIcon } from '../queries.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* CLI formatter for the audit command.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { kindIcon } from '../domain/queries.js';
|
|
2
|
+
import { branchCompareData, branchCompareMermaid } from '../features/branch-compare.js';
|
|
2
3
|
import { outputResult } from '../infrastructure/result-formatter.js';
|
|
3
|
-
import { kindIcon } from '../queries.js';
|
|
4
4
|
|
|
5
5
|
// ─── Text Formatting ────────────────────────────────────────────────────
|
|
6
6
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { checkData } from '../check.js';
|
|
2
|
-
import { AnalysisError } from '../errors.js';
|
|
1
|
+
import { checkData } from '../features/check.js';
|
|
3
2
|
import { outputResult } from '../infrastructure/result-formatter.js';
|
|
3
|
+
import { AnalysisError } from '../shared/errors.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* CLI formatter — prints check results and sets exitCode 1 on failure.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { kindIcon } from '../domain/queries.js';
|
|
2
|
+
import { flowData, listEntryPointsData } from '../features/flow.js';
|
|
2
3
|
import { outputResult } from '../infrastructure/result-formatter.js';
|
|
3
|
-
import { kindIcon } from '../queries.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* CLI formatter — text or JSON output.
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { exportsData, kindIcon } from '../../domain/queries.js';
|
|
2
|
+
import { outputResult } from '../../infrastructure/result-formatter.js';
|
|
3
|
+
|
|
4
|
+
export function fileExports(file, customDbPath, opts = {}) {
|
|
5
|
+
const data = exportsData(file, customDbPath, opts);
|
|
6
|
+
if (outputResult(data, 'results', opts)) return;
|
|
7
|
+
|
|
8
|
+
if (data.results.length === 0) {
|
|
9
|
+
if (opts.unused) {
|
|
10
|
+
console.log(`No unused exports found for "${file}".`);
|
|
11
|
+
} else {
|
|
12
|
+
console.log(`No exported symbols found for "${file}". Run "codegraph build" first.`);
|
|
13
|
+
}
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
if (opts.unused) {
|
|
18
|
+
console.log(
|
|
19
|
+
`\n# ${data.file} — ${data.totalUnused} unused export${data.totalUnused !== 1 ? 's' : ''} (of ${data.totalExported} exported)\n`,
|
|
20
|
+
);
|
|
21
|
+
} else {
|
|
22
|
+
const unusedNote = data.totalUnused > 0 ? ` (${data.totalUnused} unused)` : '';
|
|
23
|
+
console.log(
|
|
24
|
+
`\n# ${data.file} — ${data.totalExported} exported${unusedNote}, ${data.totalInternal} internal\n`,
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
for (const sym of data.results) {
|
|
29
|
+
const icon = kindIcon(sym.kind);
|
|
30
|
+
const sig = sym.signature?.params ? `(${sym.signature.params})` : '';
|
|
31
|
+
const role = sym.role ? ` [${sym.role}]` : '';
|
|
32
|
+
console.log(` ${icon} ${sym.name}${sig}${role} :${sym.line}`);
|
|
33
|
+
if (sym.consumers.length === 0) {
|
|
34
|
+
console.log(' (no consumers)');
|
|
35
|
+
} else {
|
|
36
|
+
for (const c of sym.consumers) {
|
|
37
|
+
console.log(` <- ${c.name} (${c.file}:${c.line})`);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if (data.reexports.length > 0) {
|
|
43
|
+
console.log(`\n Re-exports: ${data.reexports.map((r) => r.file).join(', ')}`);
|
|
44
|
+
}
|
|
45
|
+
console.log();
|
|
46
|
+
}
|