@kentwynn/kgraph 0.1.26 → 0.1.27
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 +3 -18
- package/dist/cli/commands/init.js +2 -25
- package/dist/cli/help.js +0 -5
- package/dist/cli/index.js +0 -2
- package/dist/cli/init-prompt.d.ts +2 -7
- package/dist/cli/init-prompt.js +0 -63
- package/dist/cli/init-recommendations.d.ts +1 -12
- package/dist/cli/init-recommendations.js +0 -23
- package/dist/cli/init-summary.d.ts +2 -4
- package/dist/cli/init-summary.js +10 -35
- package/dist/config/config.js +0 -33
- package/dist/scanner/c-symbol-extractor.d.ts +1 -1
- package/dist/scanner/c-symbol-extractor.js +108 -65
- package/dist/scanner/csharp-symbol-extractor.d.ts +1 -1
- package/dist/scanner/csharp-symbol-extractor.js +93 -67
- package/dist/scanner/go-symbol-extractor.d.ts +1 -1
- package/dist/scanner/go-symbol-extractor.js +75 -60
- package/dist/scanner/jvm-symbol-extractor.d.ts +1 -1
- package/dist/scanner/jvm-symbol-extractor.js +139 -71
- package/dist/scanner/python-symbol-extractor.d.ts +1 -1
- package/dist/scanner/python-symbol-extractor.js +92 -71
- package/dist/scanner/repo-scanner.js +3 -3
- package/dist/scanner/rust-symbol-extractor.d.ts +1 -1
- package/dist/scanner/rust-symbol-extractor.js +94 -89
- package/dist/scanner/tree-sitter-parser.d.ts +5 -0
- package/dist/scanner/tree-sitter-parser.js +55 -0
- package/dist/types/config.d.ts +0 -7
- package/package.json +10 -1
- package/dist/cli/commands/extractor.d.ts +0 -2
- package/dist/cli/commands/extractor.js +0 -50
- package/dist/extractors/extractor-registry.d.ts +0 -11
- package/dist/extractors/extractor-registry.js +0 -70
- package/dist/extractors/extractor-store.d.ts +0 -10
- package/dist/extractors/extractor-store.js +0 -58
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
const ADAPTERS = [
|
|
2
|
-
{
|
|
3
|
-
name: 'python',
|
|
4
|
-
label: 'Python deep extractor',
|
|
5
|
-
packageName: '@kentwynn/kgraph-extractor-python',
|
|
6
|
-
languages: ['python'],
|
|
7
|
-
},
|
|
8
|
-
{
|
|
9
|
-
name: 'jvm',
|
|
10
|
-
label: 'JVM deep extractor',
|
|
11
|
-
packageName: '@kentwynn/kgraph-extractor-jvm',
|
|
12
|
-
languages: ['java', 'kotlin'],
|
|
13
|
-
},
|
|
14
|
-
{
|
|
15
|
-
name: 'go',
|
|
16
|
-
label: 'Go deep extractor',
|
|
17
|
-
packageName: '@kentwynn/kgraph-extractor-go',
|
|
18
|
-
languages: ['go'],
|
|
19
|
-
},
|
|
20
|
-
{
|
|
21
|
-
name: 'rust',
|
|
22
|
-
label: 'Rust deep extractor',
|
|
23
|
-
packageName: '@kentwynn/kgraph-extractor-rust',
|
|
24
|
-
languages: ['rust'],
|
|
25
|
-
},
|
|
26
|
-
{
|
|
27
|
-
name: 'c-family',
|
|
28
|
-
label: 'C/C++ deep extractor',
|
|
29
|
-
packageName: '@kentwynn/kgraph-extractor-c-family',
|
|
30
|
-
languages: ['c', 'cpp'],
|
|
31
|
-
},
|
|
32
|
-
{
|
|
33
|
-
name: 'csharp',
|
|
34
|
-
label: 'C# deep extractor',
|
|
35
|
-
packageName: '@kentwynn/kgraph-extractor-csharp',
|
|
36
|
-
languages: ['csharp'],
|
|
37
|
-
},
|
|
38
|
-
].sort((left, right) => left.name.localeCompare(right.name));
|
|
39
|
-
export function listExtractorAdapters() {
|
|
40
|
-
return ADAPTERS;
|
|
41
|
-
}
|
|
42
|
-
export function getExtractorAdapter(name) {
|
|
43
|
-
const adapter = ADAPTERS.find((item) => item.name === name);
|
|
44
|
-
if (!adapter) {
|
|
45
|
-
throw new Error(`Unsupported extractor "${name}". Supported extractors: ${ADAPTERS.map((item) => item.name).join(', ')}`);
|
|
46
|
-
}
|
|
47
|
-
return adapter;
|
|
48
|
-
}
|
|
49
|
-
export function normalizeExtractorNames(values) {
|
|
50
|
-
if (!values || values.length === 0) {
|
|
51
|
-
return [];
|
|
52
|
-
}
|
|
53
|
-
const names = [];
|
|
54
|
-
const seen = new Set();
|
|
55
|
-
for (const value of values) {
|
|
56
|
-
for (const raw of value.split(/[\s,]+/)) {
|
|
57
|
-
const name = raw.trim();
|
|
58
|
-
if (!name || seen.has(name)) {
|
|
59
|
-
continue;
|
|
60
|
-
}
|
|
61
|
-
const adapter = getExtractorAdapter(name);
|
|
62
|
-
seen.add(adapter.name);
|
|
63
|
-
names.push(adapter.name);
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
return names;
|
|
67
|
-
}
|
|
68
|
-
export function installCommandForExtractors(packageNames) {
|
|
69
|
-
return `npm install -D ${packageNames.join(' ')}`;
|
|
70
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { ExtractorConfig, ExtractorName, KGraphWorkspace } from '../types/config.js';
|
|
2
|
-
export interface ExtractorStatus {
|
|
3
|
-
name: ExtractorName;
|
|
4
|
-
enabled: boolean;
|
|
5
|
-
packageName: string;
|
|
6
|
-
packageInstalled: boolean;
|
|
7
|
-
}
|
|
8
|
-
export declare function listExtractors(workspace: KGraphWorkspace): Promise<ExtractorStatus[]>;
|
|
9
|
-
export declare function addExtractors(workspace: KGraphWorkspace, names: ExtractorName[]): Promise<ExtractorConfig[]>;
|
|
10
|
-
export declare function removeExtractors(workspace: KGraphWorkspace, names: ExtractorName[]): Promise<ExtractorName[]>;
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import { readFile } from 'node:fs/promises';
|
|
2
|
-
import path from 'node:path';
|
|
3
|
-
import { loadConfig, saveConfig } from '../config/config.js';
|
|
4
|
-
import { pathExists } from '../storage/kgraph-paths.js';
|
|
5
|
-
import { getExtractorAdapter } from './extractor-registry.js';
|
|
6
|
-
export async function listExtractors(workspace) {
|
|
7
|
-
const config = await loadConfig(workspace);
|
|
8
|
-
const statuses = await Promise.all(config.extractors.map(async (extractor) => ({
|
|
9
|
-
name: extractor.name,
|
|
10
|
-
enabled: extractor.enabled,
|
|
11
|
-
packageName: extractor.packageName,
|
|
12
|
-
packageInstalled: await isExtractorInstalled(workspace.rootPath, extractor.packageName),
|
|
13
|
-
})));
|
|
14
|
-
return statuses.sort((left, right) => left.name.localeCompare(right.name));
|
|
15
|
-
}
|
|
16
|
-
export async function addExtractors(workspace, names) {
|
|
17
|
-
const config = await loadConfig(workspace);
|
|
18
|
-
const byName = new Map(config.extractors.map((extractor) => [extractor.name, extractor]));
|
|
19
|
-
const changed = [];
|
|
20
|
-
for (const name of names) {
|
|
21
|
-
const adapter = getExtractorAdapter(name);
|
|
22
|
-
const next = {
|
|
23
|
-
name: adapter.name,
|
|
24
|
-
enabled: true,
|
|
25
|
-
packageName: adapter.packageName,
|
|
26
|
-
};
|
|
27
|
-
byName.set(adapter.name, next);
|
|
28
|
-
changed.push(next);
|
|
29
|
-
}
|
|
30
|
-
config.extractors = [...byName.values()].sort((left, right) => left.name.localeCompare(right.name));
|
|
31
|
-
await saveConfig(workspace, config);
|
|
32
|
-
return changed;
|
|
33
|
-
}
|
|
34
|
-
export async function removeExtractors(workspace, names) {
|
|
35
|
-
const config = await loadConfig(workspace);
|
|
36
|
-
const removeNames = new Set(names);
|
|
37
|
-
config.extractors = config.extractors.filter((extractor) => !removeNames.has(extractor.name));
|
|
38
|
-
await saveConfig(workspace, config);
|
|
39
|
-
return [...removeNames].sort((left, right) => left.localeCompare(right));
|
|
40
|
-
}
|
|
41
|
-
async function isExtractorInstalled(rootPath, packageName) {
|
|
42
|
-
const packageJsonPath = path.join(rootPath, 'package.json');
|
|
43
|
-
if (await pathExists(packageJsonPath)) {
|
|
44
|
-
try {
|
|
45
|
-
const raw = await readFile(packageJsonPath, 'utf8');
|
|
46
|
-
const pkg = JSON.parse(raw);
|
|
47
|
-
if (pkg.dependencies?.[packageName] ||
|
|
48
|
-
pkg.devDependencies?.[packageName] ||
|
|
49
|
-
pkg.optionalDependencies?.[packageName]) {
|
|
50
|
-
return true;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
catch {
|
|
54
|
-
return false;
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
return pathExists(path.join(rootPath, 'node_modules', ...packageName.split('/'), 'package.json'));
|
|
58
|
-
}
|