agent-ide 0.7.5 → 0.8.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.
Files changed (137) hide show
  1. package/dist/core/deadcode/dead-code-remover.d.ts +27 -9
  2. package/dist/core/deadcode/dead-code-remover.d.ts.map +1 -1
  3. package/dist/core/deadcode/dead-code-remover.js +100 -26
  4. package/dist/core/deadcode/dead-code-remover.js.map +1 -1
  5. package/dist/core/move/import-resolver.d.ts +0 -3
  6. package/dist/core/move/import-resolver.d.ts.map +1 -1
  7. package/dist/core/move/import-resolver.js +0 -10
  8. package/dist/core/move/import-resolver.js.map +1 -1
  9. package/dist/core/move-member/index.d.ts +1 -1
  10. package/dist/core/move-member/index.d.ts.map +1 -1
  11. package/dist/core/move-member/index.js.map +1 -1
  12. package/dist/core/move-member/move-member-service.d.ts +2 -0
  13. package/dist/core/move-member/move-member-service.d.ts.map +1 -1
  14. package/dist/core/move-member/move-member-service.js +24 -31
  15. package/dist/core/move-member/move-member-service.js.map +1 -1
  16. package/dist/core/move-member/types.d.ts +48 -23
  17. package/dist/core/move-member/types.d.ts.map +1 -1
  18. package/dist/core/move-member/types.js.map +1 -1
  19. package/dist/core/rename/reference-updater.d.ts.map +1 -1
  20. package/dist/core/rename/reference-updater.js +3 -1
  21. package/dist/core/rename/reference-updater.js.map +1 -1
  22. package/dist/core/shared/symbol-finder.d.ts +39 -11
  23. package/dist/core/shared/symbol-finder.d.ts.map +1 -1
  24. package/dist/core/shared/symbol-finder.js +109 -75
  25. package/dist/core/shared/symbol-finder.js.map +1 -1
  26. package/dist/core/snapshot/snapshot-generator.d.ts +11 -0
  27. package/dist/core/snapshot/snapshot-generator.d.ts.map +1 -1
  28. package/dist/core/snapshot/snapshot-generator.js +117 -5
  29. package/dist/core/snapshot/snapshot-generator.js.map +1 -1
  30. package/dist/infrastructure/formatters/diff-generator.js +93 -26
  31. package/dist/infrastructure/formatters/diff-generator.js.map +1 -1
  32. package/dist/infrastructure/formatters/diff-utils.d.ts +24 -0
  33. package/dist/infrastructure/formatters/diff-utils.d.ts.map +1 -0
  34. package/dist/infrastructure/formatters/diff-utils.js +104 -0
  35. package/dist/infrastructure/formatters/diff-utils.js.map +1 -0
  36. package/dist/infrastructure/formatters/preview-converter.d.ts +2 -0
  37. package/dist/infrastructure/formatters/preview-converter.d.ts.map +1 -1
  38. package/dist/infrastructure/formatters/preview-converter.js +43 -5
  39. package/dist/infrastructure/formatters/preview-converter.js.map +1 -1
  40. package/dist/infrastructure/parser/base.d.ts +2 -6
  41. package/dist/infrastructure/parser/base.d.ts.map +1 -1
  42. package/dist/infrastructure/parser/base.js +1 -16
  43. package/dist/infrastructure/parser/base.js.map +1 -1
  44. package/dist/infrastructure/parser/index.d.ts +2 -0
  45. package/dist/infrastructure/parser/index.d.ts.map +1 -1
  46. package/dist/infrastructure/parser/index.js +1 -0
  47. package/dist/infrastructure/parser/index.js.map +1 -1
  48. package/dist/infrastructure/parser/interface.d.ts +197 -0
  49. package/dist/infrastructure/parser/interface.d.ts.map +1 -1
  50. package/dist/infrastructure/parser/interface.js +13 -0
  51. package/dist/infrastructure/parser/interface.js.map +1 -1
  52. package/dist/interfaces/cli/commands/cycles.command.js +8 -1
  53. package/dist/interfaces/cli/commands/cycles.command.js.map +1 -1
  54. package/dist/interfaces/cli/commands/deadcode.command.js +7 -1
  55. package/dist/interfaces/cli/commands/deadcode.command.js.map +1 -1
  56. package/dist/interfaces/cli/commands/impact.command.js +19 -5
  57. package/dist/interfaces/cli/commands/impact.command.js.map +1 -1
  58. package/dist/interfaces/cli/commands/move-member.command.d.ts.map +1 -1
  59. package/dist/interfaces/cli/commands/move-member.command.js +55 -29
  60. package/dist/interfaces/cli/commands/move-member.command.js.map +1 -1
  61. package/dist/plugins/javascript/code-analyzer.d.ts +68 -0
  62. package/dist/plugins/javascript/code-analyzer.d.ts.map +1 -0
  63. package/dist/plugins/javascript/code-analyzer.js +302 -0
  64. package/dist/plugins/javascript/code-analyzer.js.map +1 -0
  65. package/dist/plugins/javascript/declaration-analyzer.d.ts +58 -0
  66. package/dist/plugins/javascript/declaration-analyzer.d.ts.map +1 -0
  67. package/dist/plugins/javascript/declaration-analyzer.js +367 -0
  68. package/dist/plugins/javascript/declaration-analyzer.js.map +1 -0
  69. package/dist/plugins/javascript/parser.d.ts +21 -36
  70. package/dist/plugins/javascript/parser.d.ts.map +1 -1
  71. package/dist/plugins/javascript/parser.js +55 -321
  72. package/dist/plugins/javascript/parser.js.map +1 -1
  73. package/dist/plugins/javascript/pattern-analyzer.d.ts +33 -0
  74. package/dist/plugins/javascript/pattern-analyzer.d.ts.map +1 -0
  75. package/dist/plugins/javascript/pattern-analyzer.js +142 -0
  76. package/dist/plugins/javascript/pattern-analyzer.js.map +1 -0
  77. package/dist/plugins/javascript/reference-finder.d.ts +38 -0
  78. package/dist/plugins/javascript/reference-finder.d.ts.map +1 -0
  79. package/dist/plugins/javascript/reference-finder.js +210 -0
  80. package/dist/plugins/javascript/reference-finder.js.map +1 -0
  81. package/dist/plugins/javascript/types.d.ts +2 -4
  82. package/dist/plugins/javascript/types.d.ts.map +1 -1
  83. package/dist/plugins/javascript/types.js +4 -12
  84. package/dist/plugins/javascript/types.js.map +1 -1
  85. package/dist/plugins/shared/constants.d.ts +32 -0
  86. package/dist/plugins/shared/constants.d.ts.map +1 -0
  87. package/dist/plugins/shared/constants.js +78 -0
  88. package/dist/plugins/shared/constants.js.map +1 -0
  89. package/dist/plugins/shared/index.d.ts +7 -0
  90. package/dist/plugins/shared/index.d.ts.map +1 -0
  91. package/dist/plugins/shared/index.js +9 -0
  92. package/dist/plugins/shared/index.js.map +1 -0
  93. package/dist/plugins/shared/parser-helpers.d.ts +109 -0
  94. package/dist/plugins/shared/parser-helpers.d.ts.map +1 -0
  95. package/dist/plugins/shared/parser-helpers.js +223 -0
  96. package/dist/plugins/shared/parser-helpers.js.map +1 -0
  97. package/dist/plugins/typescript/declaration-analyzer.d.ts +123 -0
  98. package/dist/plugins/typescript/declaration-analyzer.d.ts.map +1 -0
  99. package/dist/plugins/typescript/declaration-analyzer.js +474 -0
  100. package/dist/plugins/typescript/declaration-analyzer.js.map +1 -0
  101. package/dist/plugins/typescript/dependency-analyzer.d.ts +0 -6
  102. package/dist/plugins/typescript/dependency-analyzer.d.ts.map +1 -1
  103. package/dist/plugins/typescript/dependency-analyzer.js +0 -34
  104. package/dist/plugins/typescript/dependency-analyzer.js.map +1 -1
  105. package/dist/plugins/typescript/index.d.ts +5 -0
  106. package/dist/plugins/typescript/index.d.ts.map +1 -1
  107. package/dist/plugins/typescript/index.js +5 -0
  108. package/dist/plugins/typescript/index.js.map +1 -1
  109. package/dist/plugins/typescript/language-service.d.ts +93 -0
  110. package/dist/plugins/typescript/language-service.d.ts.map +1 -0
  111. package/dist/plugins/typescript/language-service.js +159 -0
  112. package/dist/plugins/typescript/language-service.js.map +1 -0
  113. package/dist/plugins/typescript/parser.d.ts +27 -34
  114. package/dist/plugins/typescript/parser.d.ts.map +1 -1
  115. package/dist/plugins/typescript/parser.js +74 -429
  116. package/dist/plugins/typescript/parser.js.map +1 -1
  117. package/dist/plugins/typescript/pattern-analyzer.d.ts +59 -0
  118. package/dist/plugins/typescript/pattern-analyzer.d.ts.map +1 -0
  119. package/dist/plugins/typescript/pattern-analyzer.js +179 -0
  120. package/dist/plugins/typescript/pattern-analyzer.js.map +1 -0
  121. package/dist/plugins/typescript/reference-finder.d.ts +51 -0
  122. package/dist/plugins/typescript/reference-finder.d.ts.map +1 -0
  123. package/dist/plugins/typescript/reference-finder.js +214 -0
  124. package/dist/plugins/typescript/reference-finder.js.map +1 -0
  125. package/dist/plugins/typescript/scope-analyzer.d.ts +61 -0
  126. package/dist/plugins/typescript/scope-analyzer.d.ts.map +1 -0
  127. package/dist/plugins/typescript/scope-analyzer.js +300 -0
  128. package/dist/plugins/typescript/scope-analyzer.js.map +1 -0
  129. package/dist/plugins/typescript/symbol-extractor.d.ts +5 -0
  130. package/dist/plugins/typescript/symbol-extractor.d.ts.map +1 -1
  131. package/dist/plugins/typescript/symbol-extractor.js +25 -0
  132. package/dist/plugins/typescript/symbol-extractor.js.map +1 -1
  133. package/dist/plugins/typescript/types.d.ts +2 -4
  134. package/dist/plugins/typescript/types.d.ts.map +1 -1
  135. package/dist/plugins/typescript/types.js +4 -12
  136. package/dist/plugins/typescript/types.js.map +1 -1
  137. package/package.json +1 -1
@@ -0,0 +1,78 @@
1
+ /**
2
+ * Parser 共用常數
3
+ * TypeScript 和 JavaScript Parser 共享的設定值
4
+ */
5
+ /**
6
+ * 行號匹配的容差值(允許 JSDoc 造成的偏移)
7
+ * JSDoc 可能跨越多行,因此需要容差來正確匹配目標宣告
8
+ */
9
+ export const LINE_TOLERANCE = 10;
10
+ /**
11
+ * 通用排除模式(適用於所有語言)
12
+ */
13
+ export const COMMON_EXCLUDE_PATTERNS = [
14
+ 'node_modules/**',
15
+ '.git/**',
16
+ 'dist/**',
17
+ 'build/**',
18
+ 'coverage/**',
19
+ '.next/**',
20
+ '.nuxt/**',
21
+ 'out/**',
22
+ '.cache/**',
23
+ '.turbo/**'
24
+ ];
25
+ /**
26
+ * TypeScript 特定排除模式
27
+ */
28
+ export const TYPESCRIPT_EXCLUDE_PATTERNS = [
29
+ ...COMMON_EXCLUDE_PATTERNS,
30
+ '**/*.test.ts',
31
+ '**/*.spec.ts',
32
+ '**/*.test.tsx',
33
+ '**/*.spec.tsx',
34
+ '**/__tests__/**',
35
+ '**/__mocks__/**',
36
+ '**/*.d.ts'
37
+ ];
38
+ /**
39
+ * JavaScript 特定排除模式
40
+ */
41
+ export const JAVASCRIPT_EXCLUDE_PATTERNS = [
42
+ ...COMMON_EXCLUDE_PATTERNS,
43
+ '**/*.test.js',
44
+ '**/*.spec.js',
45
+ '**/*.test.jsx',
46
+ '**/*.spec.jsx',
47
+ '**/*.test.mjs',
48
+ '**/*.spec.mjs',
49
+ '**/*.test.cjs',
50
+ '**/*.spec.cjs',
51
+ '**/__tests__/**',
52
+ '**/__mocks__/**'
53
+ ];
54
+ /**
55
+ * Factory 模式識別的回傳型別排除清單
56
+ * 這些型別不視為 factory 模式的產物
57
+ */
58
+ export const NON_FACTORY_RETURN_TYPES = [
59
+ 'void',
60
+ 'never',
61
+ 'string',
62
+ 'number',
63
+ 'boolean',
64
+ 'null',
65
+ 'undefined',
66
+ 'symbol',
67
+ 'bigint'
68
+ ];
69
+ /**
70
+ * Factory 模式函數名稱前綴
71
+ * 符合這些前綴的函數更可能是 factory
72
+ */
73
+ export const FACTORY_NAME_PREFIXES = [
74
+ 'create',
75
+ 'make',
76
+ 'build'
77
+ ];
78
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/plugins/shared/constants.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;GAGG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,EAAE,CAAC;AAEjC;;GAEG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG;IACrC,iBAAiB;IACjB,SAAS;IACT,SAAS;IACT,UAAU;IACV,aAAa;IACb,UAAU;IACV,UAAU;IACV,QAAQ;IACR,WAAW;IACX,WAAW;CACH,CAAC;AAEX;;GAEG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAG;IACzC,GAAG,uBAAuB;IAC1B,cAAc;IACd,cAAc;IACd,eAAe;IACf,eAAe;IACf,iBAAiB;IACjB,iBAAiB;IACjB,WAAW;CACH,CAAC;AAEX;;GAEG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAG;IACzC,GAAG,uBAAuB;IAC1B,cAAc;IACd,cAAc;IACd,eAAe;IACf,eAAe;IACf,eAAe;IACf,eAAe;IACf,eAAe;IACf,eAAe;IACf,iBAAiB;IACjB,iBAAiB;CACT,CAAC;AAEX;;;GAGG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG;IACtC,MAAM;IACN,OAAO;IACP,QAAQ;IACR,QAAQ;IACR,SAAS;IACT,MAAM;IACN,WAAW;IACX,QAAQ;IACR,QAAQ;CACA,CAAC;AAEX;;;GAGG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC,QAAQ;IACR,MAAM;IACN,OAAO;CACC,CAAC"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Parser 共用模組
3
+ * 提供 TypeScript 和 JavaScript Parser 共享的常數和輔助函數
4
+ */
5
+ export { LINE_TOLERANCE, COMMON_EXCLUDE_PATTERNS, TYPESCRIPT_EXCLUDE_PATTERNS, JAVASCRIPT_EXCLUDE_PATTERNS, NON_FACTORY_RETURN_TYPES, FACTORY_NAME_PREFIXES } from './constants.js';
6
+ export { isLineMatch, isFactoryReturnType, calculateFactoryConfidence, createFactoryPatternInfo, parseJSDocContent, createDocumentation, createFormattedParameter, createEmptyRange, isRelativePath, UNICODE_IDENTIFIER_PATTERN, isValidUnicodeIdentifier, matchesAnyPattern } from './parser-helpers.js';
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/shared/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EACL,cAAc,EACd,uBAAuB,EACvB,2BAA2B,EAC3B,2BAA2B,EAC3B,wBAAwB,EACxB,qBAAqB,EACtB,MAAM,gBAAgB,CAAC;AAGxB,OAAO,EACL,WAAW,EACX,mBAAmB,EACnB,0BAA0B,EAC1B,wBAAwB,EACxB,iBAAiB,EACjB,mBAAmB,EACnB,wBAAwB,EACxB,gBAAgB,EAChB,cAAc,EACd,0BAA0B,EAC1B,wBAAwB,EACxB,iBAAiB,EAClB,MAAM,qBAAqB,CAAC"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Parser 共用模組
3
+ * 提供 TypeScript 和 JavaScript Parser 共享的常數和輔助函數
4
+ */
5
+ // 常數
6
+ export { LINE_TOLERANCE, COMMON_EXCLUDE_PATTERNS, TYPESCRIPT_EXCLUDE_PATTERNS, JAVASCRIPT_EXCLUDE_PATTERNS, NON_FACTORY_RETURN_TYPES, FACTORY_NAME_PREFIXES } from './constants.js';
7
+ // 輔助函數
8
+ export { isLineMatch, isFactoryReturnType, calculateFactoryConfidence, createFactoryPatternInfo, parseJSDocContent, createDocumentation, createFormattedParameter, createEmptyRange, isRelativePath, UNICODE_IDENTIFIER_PATTERN, isValidUnicodeIdentifier, matchesAnyPattern } from './parser-helpers.js';
9
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/plugins/shared/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,KAAK;AACL,OAAO,EACL,cAAc,EACd,uBAAuB,EACvB,2BAA2B,EAC3B,2BAA2B,EAC3B,wBAAwB,EACxB,qBAAqB,EACtB,MAAM,gBAAgB,CAAC;AAExB,OAAO;AACP,OAAO,EACL,WAAW,EACX,mBAAmB,EACnB,0BAA0B,EAC1B,wBAAwB,EACxB,iBAAiB,EACjB,mBAAmB,EACnB,wBAAwB,EACxB,gBAAgB,EAChB,cAAc,EACd,0BAA0B,EAC1B,wBAAwB,EACxB,iBAAiB,EAClB,MAAM,qBAAqB,CAAC"}
@@ -0,0 +1,109 @@
1
+ /**
2
+ * Parser 共用輔助函數
3
+ * TypeScript 和 JavaScript Parser 共享的邏輯
4
+ */
5
+ import type { Range } from '../../shared/types/core.js';
6
+ import type { Documentation, DocumentationTag, PatternInfo, FormattedParameter } from '../../infrastructure/parser/index.js';
7
+ /**
8
+ * 檢查節點行號是否匹配目標行號
9
+ * 允許 JSDoc 造成的偏移
10
+ *
11
+ * @param nodeStartLine 節點起始行(1-based)
12
+ * @param targetLine 目標行(1-based)
13
+ * @returns 是否匹配
14
+ */
15
+ export declare function isLineMatch(nodeStartLine: number, targetLine: number): boolean;
16
+ /**
17
+ * 判斷回傳型別是否符合 factory 模式
18
+ * 排除 void、never、基本型別、Promise<void> 等
19
+ *
20
+ * @param typeName 型別名稱
21
+ * @returns 是否可能是 factory 回傳型別
22
+ */
23
+ export declare function isFactoryReturnType(typeName: string): boolean;
24
+ /**
25
+ * 計算 factory 模式的信心度
26
+ *
27
+ * @param functionName 函數名稱
28
+ * @param returnType 回傳型別(可選,JavaScript 沒有型別)
29
+ * @param hasNewExpression 是否有 new 表達式
30
+ * @param hasObjectReturn 是否回傳物件字面量
31
+ * @returns 信心度 (0-1)
32
+ */
33
+ export declare function calculateFactoryConfidence(functionName: string, returnType: string | undefined, hasNewExpression: boolean, hasObjectReturn: boolean): number;
34
+ /**
35
+ * 建立 PatternInfo 物件
36
+ *
37
+ * @param symbolName 符號名稱
38
+ * @param confidence 信心度
39
+ * @param producedType 產生的型別(可選)
40
+ * @returns PatternInfo 物件
41
+ */
42
+ export declare function createFactoryPatternInfo(symbolName: string, confidence: number, producedType?: string): PatternInfo;
43
+ /**
44
+ * 解析 JSDoc 內容
45
+ * 從原始 JSDoc 文字中提取描述和標籤
46
+ *
47
+ * @param content JSDoc 內容(不含 /** 和 * /)
48
+ * @returns 解析後的描述和標籤
49
+ */
50
+ export declare function parseJSDocContent(content: string): {
51
+ description?: string;
52
+ tags: DocumentationTag[];
53
+ };
54
+ /**
55
+ * 建立 Documentation 物件
56
+ *
57
+ * @param rawText 原始 JSDoc 文字
58
+ * @param description 描述
59
+ * @param tags 標籤列表
60
+ * @returns Documentation 物件,如果無內容則返回 null
61
+ */
62
+ export declare function createDocumentation(rawText: string, description?: string, tags?: DocumentationTag[]): Documentation | null;
63
+ /**
64
+ * 建立 FormattedParameter 物件
65
+ *
66
+ * @param name 參數名稱
67
+ * @param type 參數型別(JavaScript 預設為 'any')
68
+ * @param optional 是否可選
69
+ * @param defaultValue 預設值
70
+ * @returns FormattedParameter 物件
71
+ */
72
+ export declare function createFormattedParameter(name: string, type?: string, optional?: boolean, defaultValue?: string): FormattedParameter;
73
+ /**
74
+ * 建立空 Range(用於錯誤情況)
75
+ */
76
+ export declare function createEmptyRange(): Range;
77
+ /**
78
+ * 檢查路徑是否為相對路徑
79
+ * 相對路徑以 ./ 或 ../ 開頭
80
+ *
81
+ * @param path 路徑字串
82
+ * @returns 是否為相對路徑
83
+ */
84
+ export declare function isRelativePath(path: string): boolean;
85
+ /**
86
+ * 預編譯的 Unicode 識別符正則表達式
87
+ * 符合 UAX #31 標準:
88
+ * - 第一個字元:Unicode 類別 ID_Start、底線、或 $
89
+ * - 後續字元:Unicode 類別 ID_Continue 或 $
90
+ */
91
+ export declare const UNICODE_IDENTIFIER_PATTERN: RegExp;
92
+ /**
93
+ * 檢查名稱是否符合 Unicode 識別符格式
94
+ * 不包含保留字檢查,僅驗證格式
95
+ *
96
+ * @param name 識別符名稱
97
+ * @returns 是否符合格式
98
+ */
99
+ export declare function isValidUnicodeIdentifier(name: string): boolean;
100
+ /**
101
+ * 檢查檔案路徑是否匹配任一模式
102
+ * 使用簡單的字串匹配,不依賴外部 glob 套件
103
+ *
104
+ * @param filePath 檔案路徑
105
+ * @param patterns 模式列表
106
+ * @returns 是否匹配
107
+ */
108
+ export declare function matchesAnyPattern(filePath: string, patterns: readonly string[]): boolean;
109
+ //# sourceMappingURL=parser-helpers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parser-helpers.d.ts","sourceRoot":"","sources":["../../../src/plugins/shared/parser-helpers.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAY,MAAM,uBAAuB,CAAC;AAC7D,OAAO,KAAK,EACV,aAAa,EACb,gBAAgB,EAChB,WAAW,EACX,kBAAkB,EACnB,MAAM,iCAAiC,CAAC;AAOzC;;;;;;;GAOG;AACH,wBAAgB,WAAW,CAAC,aAAa,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAE9E;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAmB7D;AAED;;;;;;;;GAQG;AACH,wBAAgB,0BAA0B,CACxC,YAAY,E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import { LINE_TOLERANCE, NON_FACTORY_RETURN_TYPES, FACTORY_NAME_PREFIXES } from './constants.js';
6
+ /**
7
+ * 檢查節點行號是否匹配目標行號
8
+ * 允許 JSDoc 造成的偏移
9
+ *
10
+ * @param nodeStartLine 節點起始行(1-based)
11
+ * @param targetLine 目標行(1-based)
12
+ * @returns 是否匹配
13
+ */
14
+ export function isLineMatch(nodeStartLine, targetLine) {
15
+ return Math.abs(nodeStartLine - targetLine) <= LINE_TOLERANCE;
16
+ }
17
+ /**
18
+ * 判斷回傳型別是否符合 factory 模式
19
+ * 排除 void、never、基本型別、Promise<void> 等
20
+ *
21
+ * @param typeName 型別名稱
22
+ * @returns 是否可能是 factory 回傳型別
23
+ */
24
+ export function isFactoryReturnType(typeName) {
25
+ const normalizedType = typeName.trim().toLowerCase();
26
+ // 排除基本排除型別
27
+ if (NON_FACTORY_RETURN_TYPES.includes(normalizedType)) {
28
+ return false;
29
+ }
30
+ // 排除 Promise<void>
31
+ if (/^promise\s*<\s*void\s*>$/i.test(typeName)) {
32
+ return false;
33
+ }
34
+ // 排除純陣列基本型別
35
+ if (/^(string|number|boolean)\[\]$/.test(normalizedType)) {
36
+ return false;
37
+ }
38
+ return true;
39
+ }
40
+ /**
41
+ * 計算 factory 模式的信心度
42
+ *
43
+ * @param functionName 函數名稱
44
+ * @param returnType 回傳型別(可選,JavaScript 沒有型別)
45
+ * @param hasNewExpression 是否有 new 表達式
46
+ * @param hasObjectReturn 是否回傳物件字面量
47
+ * @returns 信心度 (0-1)
48
+ */
49
+ export function calculateFactoryConfidence(functionName, returnType, hasNewExpression, hasObjectReturn) {
50
+ let confidence = 0;
51
+ // 名稱前綴權重
52
+ const nameWeight = returnType ? 0.3 : 0.4; // JavaScript 沒有型別,名稱權重較高
53
+ if (FACTORY_NAME_PREFIXES.some(prefix => functionName.toLowerCase().startsWith(prefix))) {
54
+ confidence += nameWeight;
55
+ }
56
+ // 回傳型別權重(僅 TypeScript)
57
+ if (returnType && returnType !== 'any') {
58
+ confidence += 0.3;
59
+ }
60
+ // Factory 行為權重
61
+ if (hasNewExpression) {
62
+ confidence += 0.4;
63
+ }
64
+ if (hasObjectReturn) {
65
+ confidence += 0.3;
66
+ }
67
+ return Math.min(confidence, 1);
68
+ }
69
+ /**
70
+ * 建立 PatternInfo 物件
71
+ *
72
+ * @param symbolName 符號名稱
73
+ * @param confidence 信心度
74
+ * @param producedType 產生的型別(可選)
75
+ * @returns PatternInfo 物件
76
+ */
77
+ export function createFactoryPatternInfo(symbolName, confidence, producedType) {
78
+ return {
79
+ type: 'factory',
80
+ symbolName,
81
+ confidence,
82
+ metadata: producedType ? { producedType } : undefined
83
+ };
84
+ }
85
+ /**
86
+ * 解析 JSDoc 內容
87
+ * 從原始 JSDoc 文字中提取描述和標籤
88
+ *
89
+ * @param content JSDoc 內容(不含 /** 和 * /)
90
+ * @returns 解析後的描述和標籤
91
+ */
92
+ export function parseJSDocContent(content) {
93
+ const lines = content.split('\n');
94
+ const tags = [];
95
+ const descriptionLines = [];
96
+ let inDescription = true;
97
+ for (const line of lines) {
98
+ // 移除行首的 * 和空白
99
+ const trimmedLine = line.replace(/^\s*\*\s?/, '').trim();
100
+ // 檢查是否為標籤行
101
+ const tagMatch = trimmedLine.match(/^@(\w+)\s*(.*)?$/);
102
+ if (tagMatch) {
103
+ inDescription = false;
104
+ const tagName = tagMatch[1];
105
+ const tagText = tagMatch[2]?.trim() ?? '';
106
+ tags.push({ name: tagName, text: tagText });
107
+ }
108
+ else if (inDescription && trimmedLine) {
109
+ descriptionLines.push(trimmedLine);
110
+ }
111
+ }
112
+ const description = descriptionLines.length > 0
113
+ ? descriptionLines.join(' ').trim()
114
+ : undefined;
115
+ return { description, tags };
116
+ }
117
+ /**
118
+ * 建立 Documentation 物件
119
+ *
120
+ * @param rawText 原始 JSDoc 文字
121
+ * @param description 描述
122
+ * @param tags 標籤列表
123
+ * @returns Documentation 物件,如果無內容則返回 null
124
+ */
125
+ export function createDocumentation(rawText, description, tags) {
126
+ if (!rawText.trim()) {
127
+ return null;
128
+ }
129
+ return {
130
+ rawText,
131
+ description,
132
+ tags: tags ?? []
133
+ };
134
+ }
135
+ /**
136
+ * 建立 FormattedParameter 物件
137
+ *
138
+ * @param name 參數名稱
139
+ * @param type 參數型別(JavaScript 預設為 'any')
140
+ * @param optional 是否可選
141
+ * @param defaultValue 預設值
142
+ * @returns FormattedParameter 物件
143
+ */
144
+ export function createFormattedParameter(name, type = 'any', optional = false, defaultValue) {
145
+ return {
146
+ name,
147
+ type,
148
+ optional,
149
+ defaultValue
150
+ };
151
+ }
152
+ /**
153
+ * 建立空 Range(用於錯誤情況)
154
+ */
155
+ export function createEmptyRange() {
156
+ const emptyPosition = { line: 0, column: 0, offset: 0 };
157
+ return { start: emptyPosition, end: emptyPosition };
158
+ }
159
+ /**
160
+ * 檢查路徑是否為相對路徑
161
+ * 相對路徑以 ./ 或 ../ 開頭
162
+ *
163
+ * @param path 路徑字串
164
+ * @returns 是否為相對路徑
165
+ */
166
+ export function isRelativePath(path) {
167
+ return path.startsWith('./') || path.startsWith('../');
168
+ }
169
+ /**
170
+ * 預編譯的 Unicode 識別符正則表達式
171
+ * 符合 UAX #31 標準:
172
+ * - 第一個字元:Unicode 類別 ID_Start、底線、或 $
173
+ * - 後續字元:Unicode 類別 ID_Continue 或 $
174
+ */
175
+ export const UNICODE_IDENTIFIER_PATTERN = /^[\p{ID_Start}_$][\p{ID_Continue}$]*$/u;
176
+ /**
177
+ * 檢查名稱是否符合 Unicode 識別符格式
178
+ * 不包含保留字檢查,僅驗證格式
179
+ *
180
+ * @param name 識別符名稱
181
+ * @returns 是否符合格式
182
+ */
183
+ export function isValidUnicodeIdentifier(name) {
184
+ if (!name || name.length === 0) {
185
+ return false;
186
+ }
187
+ return UNICODE_IDENTIFIER_PATTERN.test(name);
188
+ }
189
+ /**
190
+ * 檢查檔案路徑是否匹配任一模式
191
+ * 使用簡單的字串匹配,不依賴外部 glob 套件
192
+ *
193
+ * @param filePath 檔案路徑
194
+ * @param patterns 模式列表
195
+ * @returns 是否匹配
196
+ */
197
+ export function matchesAnyPattern(filePath, patterns) {
198
+ const normalizedPath = filePath.replace(/^\.?\//, '');
199
+ return patterns.some(pattern => {
200
+ try {
201
+ // 直接使用字串包含檢查來提高效能
202
+ if (pattern.includes('**')) {
203
+ // 對於包含 ** 的模式,進行簡單的子字串匹配
204
+ const simplePattern = pattern.replace(/\*\*/g, '').replace(/\//g, '');
205
+ if (normalizedPath.includes(simplePattern)) {
206
+ return true;
207
+ }
208
+ }
209
+ // 檢查檔案路徑是否匹配模式
210
+ if (pattern.startsWith('**/')) {
211
+ const suffix = pattern.substring(3);
212
+ if (normalizedPath.endsWith(suffix) || normalizedPath.includes('/' + suffix)) {
213
+ return true;
214
+ }
215
+ }
216
+ return false;
217
+ }
218
+ catch {
219
+ return false;
220
+ }
221
+ });
222
+ }
223
+ //# sourceMappingURL=parser-helpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parser-helpers.js","sourceRoot":"","sources":["../../../src/plugins/shared/parser-helpers.ts"],"names":[],"mappings":"AAAA;;;GAGG;AASH,OAAO,EACL,cAAc,EACd,wBAAwB,EACxB,qBAAqB,EACtB,MAAM,gBAAgB,CAAC;AAExB;;;;;;;GAOG;AACH,MAAM,UAAU,WAAW,CAAC,aAAqB,EAAE,UAAkB;IACnE,OAAO,IAAI,CAAC,GAAG,CAAC,aAAa,GAAG,UAAU,CAAC,IAAI,cAAc,CAAC;AAChE,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,mBAAmB,CAAC,QAAgB;IAClD,MAAM,cAAc,GAAG,QAAQ,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IAErD,WAAW;IACX,IAAI,wBAAwB,CAAC,QAAQ,CAAC,cAAqB,CAAC,EAAE,CAAC;QAC7D,OAAO,KAAK,CAAC;IACf,CAAC;IAED,mBAAmB;IACnB,IAAI,2BAA2B,CAAC,IAAI,CAAC,QAAQ,CAAC,EAA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ACH,kBAAkB;YAClB,IAAI,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;gBAC3B,yBAAyB;gBACzB,MAAM,aAAa,GAAG,OAAO,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;gBACtE,IAAI,cAAc,CAAC,QAAQ,CAAC,aAAa,CAAC,EAAE,CAAC;oBAC3C,OAAO,IAAI,CAAC;gBACd,CAAC;YACH,CAAC;YAED,eAAe;YACf,IAAI,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC;gBAC9B,MAAM,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;gBACpC,IAAI,cAAc,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,cAAc,CAAC,QAAQ,CAAC,GAAG,GAAG,MAAM,CAAC,EAAE,CAAC;oBAC7E,OAAO,IAAI,CAAC;gBACd,CAAC;YACH,CAAC;YAED,OAAO,KAAK,CAAC;QACf,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,KAAK,CAAC;QACf,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,123 @@
1
+ /**
2
+ * TypeScript 宣告分析器
3
+ * 負責解析宣告範圍、import 宣告、函數簽章和 JSDoc 文件
4
+ */
5
+ import * as ts from 'typescript';
6
+ import type { ImportDeclaration, FormattedSignature, FormattedParameter, Documentation } from '../../infrastructure/parser/index.js';
7
+ import type { Range } from '../../shared/types/index.js';
8
+ /**
9
+ * 宣告分析器類別
10
+ * 提供 TypeScript 程式碼的宣告解析功能
11
+ */
12
+ export declare class DeclarationAnalyzer {
13
+ private readonly compilerOptions?;
14
+ /**
15
+ * 建立宣告分析器實例
16
+ * @param compilerOptions TypeScript 編譯器選項
17
+ */
18
+ constructor(compilerOptions?: ts.CompilerOptions | undefined);
19
+ /**
20
+ * 取得完整宣告範圍(包含前導註解)
21
+ * @param code 原始程式碼
22
+ * @param symbolName 符號名稱
23
+ * @param symbolType 符號類型
24
+ * @param startLine 起始行號(1-based)
25
+ * @returns 完整範圍或 null
26
+ */
27
+ getFullDeclarationRange(code: string, symbolName: string, symbolType: string, startLine: number): Range | null;
28
+ /**
29
+ * 在 AST 中尋找符合條件的宣告節點
30
+ * @param sourceFile TypeScript SourceFile
31
+ * @param symbolName 符號名稱
32
+ * @param symbolType 符號類型
33
+ * @param startLine 起始行號(1-based)
34
+ * @returns 符合條件的節點或 null
35
+ */
36
+ findDeclarationNode(sourceFile: ts.SourceFile, symbolName: string, symbolType: string, startLine: number): ts.Node | null;
37
+ /**
38
+ * 檢查節點是否符合目標宣告
39
+ * @param node AST 節點
40
+ * @param symbolName 符號名稱
41
+ * @param symbolType 符號類型
42
+ * @param nodeStartLine 節點起始行號
43
+ * @param targetStartLine 目標起始行號
44
+ * @returns 是否符合
45
+ */
46
+ isMatchingDeclaration(node: ts.Node, symbolName: string, symbolType: string, nodeStartLine: number, targetStartLine: number): boolean;
47
+ /**
48
+ * 解析程式碼中的所有 import 宣告
49
+ * 使用 TypeScript Compiler API 精確解析
50
+ * @param code 原始程式碼
51
+ * @returns import 宣告陣列或 null
52
+ */
53
+ getImportDeclarations(code: string): ImportDeclaration[] | null;
54
+ /**
55
+ * 解析單個 import 宣告節點
56
+ * @param node import 宣告節點
57
+ * @param sourceFile TypeScript SourceFile
58
+ * @param code 原始程式碼
59
+ * @returns ImportDeclaration 或 null
60
+ */
61
+ parseImportDeclaration(node: ts.ImportDeclaration, sourceFile: ts.SourceFile, code: string): ImportDeclaration | null;
62
+ /**
63
+ * 格式化函數簽章
64
+ * 使用 TypeScript Compiler API 精確解析,正確處理複雜泛型巢狀
65
+ * @param code 原始程式碼
66
+ * @param functionName 函數名稱
67
+ * @param line 行號(1-based)
68
+ * @returns 格式化簽章或 null
69
+ */
70
+ formatSignature(code: string, functionName: string, line: number): FormattedSignature | null;
71
+ /**
72
+ * 尋找符合條件的函數節點
73
+ * @param sourceFile TypeScript SourceFile
74
+ * @param functionName 函數名稱
75
+ * @param targetLine 目標行號(1-based)
76
+ * @returns 函數節點或 null
77
+ */
78
+ findFunctionNode(sourceFile: ts.SourceFile, functionName: string, targetLine: number): ts.FunctionDeclaration | ts.MethodDeclaration | ts.ArrowFunction | null;
79
+ /**
80
+ * 提取函數參數
81
+ * @param node 函數節點
82
+ * @param sourceFile TypeScript SourceFile
83
+ * @returns 格式化參數陣列
84
+ */
85
+ extractParameters(node: ts.FunctionDeclaration | ts.MethodDeclaration | ts.ArrowFunction, sourceFile: ts.SourceFile): FormattedParameter[];
86
+ /**
87
+ * 提取函數回傳型別
88
+ * @param node 函數節點
89
+ * @param sourceFile TypeScript SourceFile
90
+ * @returns 回傳型別字串
91
+ */
92
+ extractReturnType(node: ts.FunctionDeclaration | ts.MethodDeclaration | ts.ArrowFunction, sourceFile: ts.SourceFile): string;
93
+ /**
94
+ * 提取泛型參數
95
+ * @param node 函數節點
96
+ * @returns 泛型參數名稱陣列
97
+ */
98
+ extractTypeParameters(node: ts.FunctionDeclaration | ts.MethodDeclaration | ts.ArrowFunction): string[];
99
+ /**
100
+ * 提取符號的 JSDoc 文件註解
101
+ * 使用 TypeScript Compiler API 精確識別屬於該節點的 JSDoc
102
+ * @param code 原始程式碼
103
+ * @param symbolName 符號名稱
104
+ * @param symbolType 符號類型
105
+ * @param line 行號(1-based)
106
+ * @returns Documentation 或 null
107
+ */
108
+ getDocumentation(code: string, symbolName: string, symbolType: string, line: number): Documentation | null;
109
+ /**
110
+ * 提取 JSDoc 標籤的文字內容
111
+ * @param tag JSDoc 標籤節點
112
+ * @param sourceFile TypeScript SourceFile
113
+ * @returns 標籤文字
114
+ */
115
+ extractJSDocTagText(tag: ts.JSDocTag, sourceFile: ts.SourceFile): string;
116
+ }
117
+ /**
118
+ * 建立宣告分析器實例
119
+ * @param compilerOptions TypeScript 編譯器選項
120
+ * @returns DeclarationAnalyzer 實例
121
+ */
122
+ export declare function createDeclarationAnalyzer(compilerOptions?: ts.CompilerOptions): DeclarationAnalyzer;
123
+ //# sourceMappingURL=declaration-analyzer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"declaration-analyzer.d.ts","sourceRoot":"","sources":["../../../src/plugins/typescript/declaration-analyzer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;AACjC,OAAO,KAAK,EACV,iBAAiB,EAEjB,kBAAkB,EAClB,kBAAkB,EAClB,aAAa,EAEd,MAAM,iCAAiC,CAAC;AACzC,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAC;AAGpD;;;GAGG;AACH,qBAAa,mBAAmB;IAKlB,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAC;IAJ7C;;;OAGG;gBAC0B,eAAe,CAAC,EAAE,EAAE,CAAC,eAAe,YAAA;IAEjE;;;;;;;OAOG;IACH,uBAAuB,CACrB,IAAI,EAAE,MAAM,EACZ,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,MAAM,EAClB,SAAS,EAAE,MAAM,GAChB,KAAK,GAAG,IAAI;IA0Cf;;;;;;;OAOG;IACH,mBAAmB,CACjB,UAAU,EAAE,EAAE,CAAC,UAAU,EACzB,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,MAAM,EAClB,SAAS,EAAE,MAAM,GAChB,EAAE,CAAC,IAAI,GAAG,IAAI;IAoBjB;;;;;;;;OAQG;IACH,qBAAqB,CACnB,IAAI,EAAE,EAAE,CAAC,IAAI,EACb,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,MAAM,EAClB,aAAa,EAAE,MAAM,EACrB,eAAe,EAAE,MAAM,GACtB,OAAO;IAuEV;;;;;OAKG;IACH,qBAAqB,CAAC,IAAI,EAAE,MAAM,GAAG,iBAAiB,EAAE,GAAG,IAAI;IA2B/D;;;;;;OAMG;IACH,sBAAsB,CACpB,IAAI,EAAE,EAAE,CAAC,iBAAiB,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