code-survey 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/LICENSE +21 -0
- package/README.md +191 -0
- package/dist/bin/code-survey.js +1620 -0
- package/dist/cache/cache.d.ts +9 -0
- package/dist/cli/cli-parser.d.ts +24 -0
- package/dist/cli/token-estimator.d.ts +4 -0
- package/dist/cli/watcher.d.ts +2 -0
- package/dist/config/config.d.ts +2 -0
- package/dist/git/git.d.ts +1 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.js +941 -0
- package/dist/mcp-server.d.ts +1 -0
- package/dist/package-parser.d.ts +2 -0
- package/dist/parser.d.ts +7 -0
- package/dist/parsers/base.d.ts +9 -0
- package/dist/parsers/csharp.d.ts +5 -0
- package/dist/parsers/go.d.ts +5 -0
- package/dist/parsers/java.d.ts +5 -0
- package/dist/parsers/javascript.d.ts +5 -0
- package/dist/parsers/python.d.ts +5 -0
- package/dist/parsers/rust.d.ts +5 -0
- package/dist/parsers/typescript.d.ts +5 -0
- package/dist/resolver.d.ts +5 -0
- package/dist/scanner.d.ts +7 -0
- package/dist/types.d.ts +74 -0
- package/dist/wasm/wasm-loader.d.ts +1 -0
- package/dist/writer.d.ts +21 -0
- package/package.json +39 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function runMcpServer(): void;
|
package/dist/parser.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { LanguageParser, ParseResult, ParseOptions } from './types.ts';
|
|
2
|
+
export declare class CodebaseParser {
|
|
3
|
+
private parsers;
|
|
4
|
+
initialize(fileExtensions?: Set<string> | string[]): Promise<void>;
|
|
5
|
+
getParserForFile(filePath: string): LanguageParser | null;
|
|
6
|
+
parseFile(filePath: string, code: string, options?: ParseOptions): ParseResult;
|
|
7
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import Parser from 'web-tree-sitter';
|
|
2
|
+
import type { LanguageParser, ParseResult, ParseOptions } from '../types.ts';
|
|
3
|
+
export declare function ensureParserInit(): Promise<void>;
|
|
4
|
+
export declare abstract class BaseTreeSitterParser implements LanguageParser {
|
|
5
|
+
protected parser: Parser;
|
|
6
|
+
protected lang: Parser.Language;
|
|
7
|
+
initialize(wasmPath: string): Promise<void>;
|
|
8
|
+
abstract parse(code: string, options?: ParseOptions): ParseResult;
|
|
9
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { FileEntry, NamespaceEntry, PackageDependencies } from './types.ts';
|
|
2
|
+
export declare function resolveImports(files: Record<string, FileEntry>, namespaces: Record<string, NamespaceEntry>, packageDeps: PackageDependencies): {
|
|
3
|
+
externalImports: Record<string, string[]>;
|
|
4
|
+
internalLinks: Record<string, string[]>;
|
|
5
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export interface ScannedFile {
|
|
2
|
+
relativePath: string;
|
|
3
|
+
absolutePath: string;
|
|
4
|
+
hash: string;
|
|
5
|
+
}
|
|
6
|
+
export declare function calculateHash(filePath: string): string;
|
|
7
|
+
export declare function scanDirectory(rootDir: string, customExcludes?: string[], maxDepth?: number): ScannedFile[];
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
export interface ProjectMetadata {
|
|
2
|
+
name: string;
|
|
3
|
+
languages: string[];
|
|
4
|
+
root: string;
|
|
5
|
+
}
|
|
6
|
+
export interface PackageDependencies {
|
|
7
|
+
npm?: Record<string, string>;
|
|
8
|
+
nuget?: Record<string, string>;
|
|
9
|
+
go?: Record<string, string>;
|
|
10
|
+
maven?: Record<string, string>;
|
|
11
|
+
pip?: Record<string, string>;
|
|
12
|
+
}
|
|
13
|
+
export interface ImportEntry {
|
|
14
|
+
source: string;
|
|
15
|
+
symbols: string[];
|
|
16
|
+
}
|
|
17
|
+
export interface SymbolEntry {
|
|
18
|
+
name: string;
|
|
19
|
+
type: 'class' | 'interface' | 'struct' | 'method' | 'function' | 'variable' | 'type';
|
|
20
|
+
location: string;
|
|
21
|
+
doc?: string;
|
|
22
|
+
signature?: string;
|
|
23
|
+
}
|
|
24
|
+
export declare function formatLocation(start: number, end: number): string;
|
|
25
|
+
export declare function formatDocstring(text: string): string;
|
|
26
|
+
export interface FileEntry {
|
|
27
|
+
hash: string;
|
|
28
|
+
imports: ImportEntry[];
|
|
29
|
+
exports: SymbolEntry[];
|
|
30
|
+
symbols: SymbolEntry[];
|
|
31
|
+
}
|
|
32
|
+
export interface NamespaceEntry {
|
|
33
|
+
files: string[];
|
|
34
|
+
exports: string[];
|
|
35
|
+
}
|
|
36
|
+
export interface CodeSurveySchema {
|
|
37
|
+
version: string;
|
|
38
|
+
$schema?: string;
|
|
39
|
+
project: ProjectMetadata;
|
|
40
|
+
packageDependencies: PackageDependencies;
|
|
41
|
+
files: Record<string, FileEntry>;
|
|
42
|
+
namespaces: Record<string, NamespaceEntry>;
|
|
43
|
+
externalImports: Record<string, string[]>;
|
|
44
|
+
internalLinks: Record<string, string[]>;
|
|
45
|
+
}
|
|
46
|
+
export interface ParseOptions {
|
|
47
|
+
includeInternalVars?: boolean;
|
|
48
|
+
includeDocs?: boolean;
|
|
49
|
+
symbolsFilter?: string[];
|
|
50
|
+
includeSignatures?: boolean;
|
|
51
|
+
}
|
|
52
|
+
export interface ParseResult {
|
|
53
|
+
imports: ImportEntry[];
|
|
54
|
+
exports: SymbolEntry[];
|
|
55
|
+
symbols: SymbolEntry[];
|
|
56
|
+
namespace?: string;
|
|
57
|
+
}
|
|
58
|
+
export interface LanguageParser {
|
|
59
|
+
initialize(wasmPath: string): Promise<void>;
|
|
60
|
+
parse(code: string, options?: ParseOptions): ParseResult;
|
|
61
|
+
}
|
|
62
|
+
export interface CodeSurveyResult {
|
|
63
|
+
filesCount: number;
|
|
64
|
+
symbolsCount: {
|
|
65
|
+
class: number;
|
|
66
|
+
interface: number;
|
|
67
|
+
struct: number;
|
|
68
|
+
method: number;
|
|
69
|
+
function: number;
|
|
70
|
+
variable: number;
|
|
71
|
+
type: number;
|
|
72
|
+
};
|
|
73
|
+
data: CodeSurveySchema;
|
|
74
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getWasmPath(language: string): Promise<string>;
|
package/dist/writer.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { CodeSurveySchema } from './types.ts';
|
|
2
|
+
export declare function sortCodeSurveyData(data: CodeSurveySchema): CodeSurveySchema;
|
|
3
|
+
export declare function generateDeterministicJson(data: CodeSurveySchema): string;
|
|
4
|
+
export declare function generateDeterministicYaml(data: CodeSurveySchema): string;
|
|
5
|
+
export declare function generateDeterministicMermaid(data: CodeSurveySchema): string;
|
|
6
|
+
export declare function generateProjectMarkdown(data: CodeSurveySchema): string;
|
|
7
|
+
export declare function generateDependenciesMarkdown(data: CodeSurveySchema): string;
|
|
8
|
+
export declare function generateFilesMarkdown(data: CodeSurveySchema, options?: {
|
|
9
|
+
includeToc?: boolean;
|
|
10
|
+
}): string;
|
|
11
|
+
export declare function generateNamespacesMarkdown(data: CodeSurveySchema): string;
|
|
12
|
+
export declare function generateLinksMarkdown(data: CodeSurveySchema): string;
|
|
13
|
+
export declare function generateDeterministicMarkdown(data: CodeSurveySchema, options?: {
|
|
14
|
+
includeToc?: boolean;
|
|
15
|
+
}): string;
|
|
16
|
+
export declare function writeSurveyOutput(schemaObj: CodeSurveySchema, options: {
|
|
17
|
+
output?: string;
|
|
18
|
+
format?: 'json' | 'yaml' | 'markdown' | 'mermaid';
|
|
19
|
+
split?: boolean;
|
|
20
|
+
includeToc?: boolean;
|
|
21
|
+
}): void;
|
package/package.json
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "code-survey",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Deterministic codebase surveying tool for coding agents",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"bin": {
|
|
8
|
+
"code-survey": "./dist/bin/code-survey.js"
|
|
9
|
+
},
|
|
10
|
+
"files": [
|
|
11
|
+
"dist",
|
|
12
|
+
"README.md",
|
|
13
|
+
"LICENSE"
|
|
14
|
+
],
|
|
15
|
+
"scripts": {
|
|
16
|
+
"test": "deno test --allow-read --allow-write --allow-sys --allow-env --allow-run --allow-net tests/",
|
|
17
|
+
"test:node": "node --experimental-strip-types --test tests/**/*.test.ts",
|
|
18
|
+
"build": "rm -rf dist && npx tsc --declaration --emitDeclarationOnly --outDir dist --noEmit false && mv dist/src/* dist/ && rm -rf dist/src dist/bin && bun build src/index.ts --outfile dist/index.js --target node --external web-tree-sitter --external tree-sitter-wasms --external yaml && bun build bin/code-survey.ts --outfile dist/bin/code-survey.js --target node --external web-tree-sitter --external tree-sitter-wasms --external yaml",
|
|
19
|
+
"prepublishOnly": "npm run build"
|
|
20
|
+
},
|
|
21
|
+
"keywords": [
|
|
22
|
+
"code-survey",
|
|
23
|
+
"codemap",
|
|
24
|
+
"ast",
|
|
25
|
+
"parser",
|
|
26
|
+
"dependency-graph"
|
|
27
|
+
],
|
|
28
|
+
"author": "",
|
|
29
|
+
"license": "MIT",
|
|
30
|
+
"dependencies": {
|
|
31
|
+
"tree-sitter-wasms": "^0.1.11",
|
|
32
|
+
"web-tree-sitter": "^0.22.4",
|
|
33
|
+
"yaml": "^2.4.5"
|
|
34
|
+
},
|
|
35
|
+
"devDependencies": {
|
|
36
|
+
"@types/node": "^20.11.0",
|
|
37
|
+
"typescript": "^5.3.3"
|
|
38
|
+
}
|
|
39
|
+
}
|