@codex-ultra/cxu 0.1.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.
@@ -0,0 +1,129 @@
1
+ import { type Node } from "web-tree-sitter";
2
+ export type OutlineSymbolKind = "function" | "method" | "class" | "struct" | "interface" | "enum" | "variant" | "trait" | "impl" | "type" | "module" | "constant" | "variable";
3
+ export type OutlineSymbol = {
4
+ name: string;
5
+ kind: OutlineSymbolKind;
6
+ startLine: number;
7
+ endLine: number;
8
+ signature?: string;
9
+ children?: OutlineSymbol[];
10
+ };
11
+ export type FileOutlineResult = {
12
+ filePath: string;
13
+ language: string | null;
14
+ totalLines: number;
15
+ symbols: OutlineSymbol[];
16
+ formatted: string;
17
+ };
18
+ export type SymbolEdit = {
19
+ start: number;
20
+ end: number;
21
+ line: number;
22
+ column: number;
23
+ oldText: string;
24
+ newText: string;
25
+ preview: string;
26
+ };
27
+ export type FileRenameResult = {
28
+ filePath: string;
29
+ editsCount: number;
30
+ edits: SymbolEdit[];
31
+ newContent: string;
32
+ applied: boolean;
33
+ };
34
+ export declare function getTreeSitterWasmPath(): string | null;
35
+ export declare function getLanguageWasmPath(langName: string): string | null;
36
+ export declare function initTreeSitter(): Promise<boolean>;
37
+ export declare function getLanguageNameForFile(filePath: string): string | null;
38
+ /** Check if an AST node is located inside comments or string literals. */
39
+ export declare function isInsideCommentOrString(node: Node | null): boolean;
40
+ /** Format symbol outline as a compact tree text for LLM. */
41
+ export declare function formatOutlineAsTree(filePath: string, totalLines: number, symbols: OutlineSymbol[]): string;
42
+ /** Extract structural outline of any supported source file. */
43
+ export declare function extractFileOutline(filePath: string, content: string, options?: {
44
+ detail?: boolean;
45
+ }): Promise<FileOutlineResult>;
46
+ /**
47
+ * Safely rename a symbol within a file using Tree-sitter AST.
48
+ * Skips comments, string literals, and identifiers that don't match the exact symbol boundary.
49
+ */
50
+ export declare function renameSymbolInContent(filePath: string, content: string, oldName: string, newName: string): Promise<{
51
+ newContent: string;
52
+ edits: SymbolEdit[];
53
+ }>;
54
+ export type DefinitionMatch = {
55
+ filePath: string;
56
+ symbol: string;
57
+ kind: OutlineSymbolKind;
58
+ startLine: number;
59
+ endLine: number;
60
+ signature: string;
61
+ bodySnippet: string;
62
+ };
63
+ export declare function findDefinitionInContent(filePath: string, content: string, targetSymbol: string, options?: {
64
+ includeBody?: boolean;
65
+ maxBodyLines?: number;
66
+ }): Promise<DefinitionMatch | null>;
67
+ export type SyntaxDiagnostic = {
68
+ line: number;
69
+ column: number;
70
+ message: string;
71
+ preview: string;
72
+ code?: string | number;
73
+ };
74
+ export type SyntaxDiagnosticsResult = {
75
+ filePath: string;
76
+ clean: boolean;
77
+ errorsCount: number;
78
+ errors: SyntaxDiagnostic[];
79
+ formatted: string;
80
+ };
81
+ export declare function getSyntaxDiagnostics(filePath: string, content: string): Promise<SyntaxDiagnosticsResult>;
82
+ export declare function addImportToContent(_filePath: string, content: string, options: {
83
+ statement?: string;
84
+ symbol?: string;
85
+ module?: string;
86
+ isType?: boolean;
87
+ }): {
88
+ newContent: string;
89
+ applied: boolean;
90
+ message: string;
91
+ };
92
+ export interface OrganizeImportsResult {
93
+ filePath: string;
94
+ applied: boolean;
95
+ changed: boolean;
96
+ newContent: string;
97
+ removedImportsCount: number;
98
+ removedUnusedCount: number;
99
+ mergedImportsCount: number;
100
+ mergedCount: number;
101
+ formatted: string;
102
+ summary: string;
103
+ }
104
+ export declare function organizeImportsInContent(filePath: string, content: string, options?: {
105
+ removeUnused?: boolean;
106
+ sort?: boolean;
107
+ mergeDuplicates?: boolean;
108
+ }): OrganizeImportsResult;
109
+ export interface ScopeAnalysisResult {
110
+ filePath: string;
111
+ startLine: number;
112
+ endLine: number;
113
+ componentName: string;
114
+ capturedVariables: Array<{
115
+ name: string;
116
+ type: string;
117
+ isFunction: boolean;
118
+ isStateSetter: boolean;
119
+ }>;
120
+ declaredSymbols: string[];
121
+ importedDependencies: string[];
122
+ suggestedPropsInterface: string;
123
+ suggestedCallSnippet: string;
124
+ summary: string;
125
+ }
126
+ export declare function analyzeBlockScope(filePath: string, content: string, startLine: number, endLine: number, optionsOrComponentName?: {
127
+ componentName?: string;
128
+ } | string): ScopeAnalysisResult;
129
+ export declare function generateTargetImportsForBlock(sourcePath: string, targetPath: string, sourceContent: string, startLine: number, endLine: number): string;
package/package.json ADDED
@@ -0,0 +1,65 @@
1
+ {
2
+ "name": "@codex-ultra/cxu",
3
+ "version": "0.1.0",
4
+ "description": "Pure-TypeScript cross-platform file and AST toolkit (zero embedded binaries). Bring your own Bun only for run_bun / complex TS tracks.",
5
+ "type": "module",
6
+ "main": "dist/index.js",
7
+ "types": "dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.js"
12
+ }
13
+ },
14
+ "bin": {
15
+ "cxu": "dist/cli.js"
16
+ },
17
+ "files": [
18
+ "dist",
19
+ "wasm",
20
+ "README.md",
21
+ "LICENSE"
22
+ ],
23
+ "scripts": {
24
+ "vendor": "node scripts/vendor-sa-vm.mjs",
25
+ "build": "node scripts/build.mjs",
26
+ "build:bun": "bun scripts/build.mjs",
27
+ "obfuscate": "node scripts/obfuscate.mjs",
28
+ "typecheck": "tsc -p tsconfig.json --noEmit",
29
+ "prepack": "npm run build && npm run obfuscate",
30
+ "test": "bun test test/ 2>/dev/null || node --test test/*.test.mjs"
31
+ },
32
+ "publishConfig": {
33
+ "access": "public"
34
+ },
35
+ "dependencies": {
36
+ "tree-sitter-wasms": "^0.1.13",
37
+ "web-tree-sitter": "0.25.10"
38
+ },
39
+ "devDependencies": {
40
+ "esbuild": "^0.25.12",
41
+ "javascript-obfuscator": "^5.5.0",
42
+ "typescript": "^5.9.3"
43
+ },
44
+ "engines": {
45
+ "node": ">=18"
46
+ },
47
+ "license": "MIT",
48
+ "homepage": "https://github.com/layola13/codex-ultra#readme",
49
+ "bugs": {
50
+ "url": "https://github.com/layola13/codex-ultra/issues"
51
+ },
52
+ "repository": {
53
+ "type": "git",
54
+ "url": "git+https://github.com/layola13/codex-ultra.git",
55
+ "directory": "packages/cxu"
56
+ },
57
+ "keywords": [
58
+ "codex",
59
+ "vm-tools",
60
+ "ast",
61
+ "tree-sitter",
62
+ "typescript",
63
+ "cross-platform"
64
+ ]
65
+ }
Binary file