@reverse-craft/smart-fs 1.0.7 → 2.0.1

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.
Files changed (41) hide show
  1. package/README.md +114 -100
  2. package/README.zh-CN.md +181 -0
  3. package/dist/analyzer.d.ts +91 -0
  4. package/dist/analyzer.d.ts.map +1 -0
  5. package/dist/beautifier.d.ts +120 -0
  6. package/dist/beautifier.d.ts.map +1 -0
  7. package/dist/index.d.ts +102 -0
  8. package/dist/index.d.ts.map +1 -0
  9. package/dist/index.js +1270 -0
  10. package/dist/index.js.map +7 -0
  11. package/dist/languageDetector.d.ts +74 -0
  12. package/dist/languageDetector.d.ts.map +1 -0
  13. package/dist/llmConfig.d.ts +34 -0
  14. package/dist/llmConfig.d.ts.map +1 -0
  15. package/dist/searcher.d.ts +113 -0
  16. package/dist/searcher.d.ts.map +1 -0
  17. package/dist/server.d.ts +2 -0
  18. package/dist/server.d.ts.map +1 -0
  19. package/dist/server.js +537 -41
  20. package/dist/server.js.map +4 -4
  21. package/dist/tools/ToolDefinition.d.ts +24 -0
  22. package/dist/tools/ToolDefinition.d.ts.map +1 -0
  23. package/dist/tools/aiFindJsvmpDispatcher.d.ts +79 -0
  24. package/dist/tools/aiFindJsvmpDispatcher.d.ts.map +1 -0
  25. package/dist/tools/applyCustomTransform.d.ts +14 -0
  26. package/dist/tools/applyCustomTransform.d.ts.map +1 -0
  27. package/dist/tools/findUsageSmart.d.ts +16 -0
  28. package/dist/tools/findUsageSmart.d.ts.map +1 -0
  29. package/dist/tools/index.d.ts +43 -0
  30. package/dist/tools/index.d.ts.map +1 -0
  31. package/dist/tools/readCodeSmart.d.ts +13 -0
  32. package/dist/tools/readCodeSmart.d.ts.map +1 -0
  33. package/dist/tools/searchCodeSmart.d.ts +18 -0
  34. package/dist/tools/searchCodeSmart.d.ts.map +1 -0
  35. package/dist/transformer.d.ts +119 -0
  36. package/dist/transformer.d.ts.map +1 -0
  37. package/dist/truncator.d.ts +69 -0
  38. package/dist/truncator.d.ts.map +1 -0
  39. package/dist/types.d.ts +61 -0
  40. package/dist/types.d.ts.map +1 -0
  41. package/package.json +16 -16
@@ -0,0 +1,102 @@
1
+ /**
2
+ * smart-fs - Smart file processing library
3
+ *
4
+ * Provides code beautification, truncation, search, analysis, and transformation
5
+ * with multi-language support and source map generation.
6
+ *
7
+ * @module smart-fs
8
+ */
9
+ export * from './types.js';
10
+ export { type SupportedLanguage, type LanguageInfo, detectLanguage, getLanguageInfo, isFullySupportedLanguage, getSupportedExtensions, isExtensionSupported, } from './languageDetector.js';
11
+ export { type SourceMap, type BeautifyOptions, type BeautifyResult, type LocalPaths, type LocalCacheCheck, ensureBeautified, beautifyCode, beautifyJson, beautifyHtml, beautifyCss, getLocalPaths, isLocalCacheValid, } from './beautifier.js';
12
+ export { type TruncateOptions, type TruncateResult, truncateCode, truncateCodeFromFile, truncateFallback, truncateLongLines, truncateCodeHighPerf, } from './truncator.js';
13
+ export { type OriginalPosition as SearchOriginalPosition, type ContextLine, type SearchMatch, type SearchOptions, type SearchResult, searchInCode, formatSearchResult, formatSourcePosition as formatSearchSourcePosition, createRegex, escapeRegex, unescapeBackslashes, } from './searcher.js';
14
+ export { type OriginalPosition as AnalyzeOriginalPosition, type LocationInfo, type BindingInfo, type AnalysisResult, type AnalyzeOptions, analyzeBindings, formatAnalysisResult, formatSourcePosition as formatAnalyzeSourcePosition, parseCode, } from './analyzer.js';
15
+ export { type TransformOptions, type TransformResult, type OutputPaths, type BabelPluginFunction, applyCustomTransform, loadBabelPlugin, runBabelTransform, getOutputPaths, cleanBasename, } from './transformer.js';
16
+ import type { SmartReadOptions, ProcessingResult } from './types.js';
17
+ import type { SearchOptions, SearchResult } from './searcher.js';
18
+ import type { AnalyzeOptions, AnalysisResult } from './analyzer.js';
19
+ /**
20
+ * Smart read file with beautification and truncation
21
+ *
22
+ * This is a convenience function that combines beautification and truncation
23
+ * into a single operation. It handles:
24
+ * - Language detection (or uses specified language)
25
+ * - Code beautification (for supported languages)
26
+ * - String/line truncation
27
+ * - Optional line range extraction
28
+ *
29
+ * @param filePath - Path to the file to read
30
+ * @param options - Processing options
31
+ * @returns ProcessingResult with processed code and metadata
32
+ *
33
+ * @example
34
+ * ```typescript
35
+ * // Read and process entire file
36
+ * const result = await smartRead('./src/app.js');
37
+ *
38
+ * // Read specific lines with custom options
39
+ * const result = await smartRead('./src/app.js', {
40
+ * startLine: 10,
41
+ * endLine: 50,
42
+ * charLimit: 200,
43
+ * maxLineChars: 400
44
+ * });
45
+ * ```
46
+ */
47
+ export declare function smartRead(filePath: string, options?: SmartReadOptions): Promise<ProcessingResult>;
48
+ /**
49
+ * Smart search in file with beautification and source map support
50
+ *
51
+ * This function beautifies the file first, then searches in the beautified code.
52
+ * Results include original file positions via source map for setting breakpoints.
53
+ *
54
+ * @param filePath - Path to the file to search
55
+ * @param query - Search query (text or regex pattern)
56
+ * @param options - Search options
57
+ * @returns SearchResult with matches and original positions
58
+ *
59
+ * @example
60
+ * ```typescript
61
+ * // Simple text search
62
+ * const result = await smartSearch('./src/app.js', 'function');
63
+ *
64
+ * // Regex search with options
65
+ * const result = await smartSearch('./src/app.js', 'function\\s+\\w+', {
66
+ * isRegex: true,
67
+ * caseSensitive: true,
68
+ * contextLines: 3
69
+ * });
70
+ * ```
71
+ */
72
+ export declare function smartSearch(filePath: string, query: string, options?: SearchOptions): Promise<SearchResult & {
73
+ formatted: string;
74
+ error?: string;
75
+ }>;
76
+ /**
77
+ * Find variable/function usage in file
78
+ *
79
+ * This function analyzes the code to find all bindings (definitions and references)
80
+ * for a specific identifier. Results include original file positions via source map.
81
+ *
82
+ * @param filePath - Path to the file to analyze
83
+ * @param identifier - Variable or function name to find
84
+ * @param options - Analysis options
85
+ * @returns AnalysisResult with bindings and original positions
86
+ *
87
+ * @example
88
+ * ```typescript
89
+ * // Find all usages of 'myFunction'
90
+ * const result = await findUsage('./src/app.js', 'myFunction');
91
+ *
92
+ * // Find usage at specific line
93
+ * const result = await findUsage('./src/app.js', 'data', {
94
+ * targetLine: 42
95
+ * });
96
+ * ```
97
+ */
98
+ export declare function findUsage(filePath: string, identifier: string, options?: AnalyzeOptions): Promise<AnalysisResult & {
99
+ formatted: string;
100
+ error?: string;
101
+ }>;
102
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAMH,cAAc,YAAY,CAAC;AAG3B,OAAO,EACL,KAAK,iBAAiB,EACtB,KAAK,YAAY,EACjB,cAAc,EACd,eAAe,EACf,wBAAwB,EACxB,sBAAsB,EACtB,oBAAoB,GACrB,MAAM,uBAAuB,CAAC;AAG/B,OAAO,EACL,KAAK,SAAS,EACd,KAAK,eAAe,EACpB,KAAK,cAAc,EACnB,KAAK,UAAU,EACf,KAAK,eAAe,EACpB,gBAAgB,EAChB,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,WAAW,EACX,aAAa,EACb,iBAAiB,GAClB,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EACL,KAAK,eAAe,EACpB,KAAK,cAAc,EACnB,YAAY,EACZ,oBAAoB,EACpB,gBAAgB,EAChB,iBAAiB,EACjB,oBAAoB,GACrB,MAAM,gBAAgB,CAAC;AAGxB,OAAO,EACL,KAAK,gBAAgB,IAAI,sBAAsB,EAC/C,KAAK,WAAW,EAChB,KAAK,WAAW,EAChB,KAAK,aAAa,EAClB,KAAK,YAAY,EACjB,YAAY,EACZ,kBAAkB,EAClB,oBAAoB,IAAI,0BAA0B,EAClD,WAAW,EACX,WAAW,EACX,mBAAmB,GACpB,MAAM,eAAe,CAAC;AAGvB,OAAO,EACL,KAAK,gBAAgB,IAAI,uBAAuB,EAChD,KAAK,YAAY,EACjB,KAAK,WAAW,EAChB,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,eAAe,EACf,oBAAoB,EACpB,oBAAoB,IAAI,2BAA2B,EAC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