@didnhdj/fnmap 0.2.1 → 0.4.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/README.md CHANGED
@@ -142,7 +142,8 @@ The `.fnmap` file contains structured information about your code:
142
142
  - `ClassName:SuperClass startLine-endLine` - Class information
143
143
  - ` .methodName(params) line description →calls` - Instance method
144
144
  - ` +methodName(params) line description →calls` - Static method
145
- - `CONSTANT_NAME line description` - Constant definition
145
+ - `$constName line description` - Constant definition (`$` prefix)
146
+ - `>export1,export2,default` - Exports (`>` prefix, supports `default`, `type:Name`)
146
147
 
147
148
  ## CLI Options
148
149
 
package/README_CN.md CHANGED
@@ -142,7 +142,8 @@ fnmap 支持多种配置方式(按优先级排序):
142
142
  - `ClassName:SuperClass startLine-endLine` - 类信息
143
143
  - ` .methodName(params) line description →calls` - 实例方法
144
144
  - ` +methodName(params) line description →calls` - 静态方法
145
- - `CONSTANT_NAME line description` - 常量定义
145
+ - `$constName line description` - 常量定义(`$` 前缀)
146
+ - `>export1,export2,default` - 导出(`>` 前缀,支持 `default`、`type:Name`)
146
147
 
147
148
  ## CLI 选项
148
149
 
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/analyzer/index.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAEV,aAAa,EAMd,MAAM,UAAU,CAAC;AAGlB,OAAO,EAAE,uBAAuB,EAAqB,MAAM,SAAS,CAAC;AAKrE;;GAEG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,GAAG,aAAa,CA40BjF;AAoFD,OAAO,EAAE,uBAAuB,EAAE,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/analyzer/index.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAEV,aAAa,EAOd,MAAM,UAAU,CAAC;AAGlB,OAAO,EAAE,uBAAuB,EAAqB,MAAM,SAAS,CAAC;AAyCrE;;GAEG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,GAAG,aAAa,CAq8BjF;AAoFD,OAAO,EAAE,uBAAuB,EAAE,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAUpC,eAAO,MAAM,MAAM;iBACJ,MAAM,KAAG,IAAI;mBAGX,MAAM,KAAG,IAAI;gBAGhB,MAAM,KAAG,IAAI;gBAGb,MAAM,KAAG,IAAI;iBAGZ,MAAM,KAAG,IAAI;iBAIb,MAAM,KAAG,IAAI;CAG3B,CAAC;AAEF,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI,CAEjD;AAED,wBAAgB,WAAW,IAAI,OAAO,CAErC;AAED;;GAEG;AACH,wBAAgB,UAAU,IAAI,MAAM,CAenC;AAED;;GAEG;AACH,wBAAgB,QAAQ,IAAI,OAAO,CAqDlC;AAGD,wBAAgB,UAAU,IAAI,OAAO,CAKpC;AAGD,eAAO,MAAM,OAAO;;;;CAUnB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAUpC,eAAO,MAAM,MAAM;iBACJ,MAAM,KAAG,IAAI;mBAGX,MAAM,KAAG,IAAI;gBAGhB,MAAM,KAAG,IAAI;gBAGb,MAAM,KAAG,IAAI;iBAGZ,MAAM,KAAG,IAAI;iBAIb,MAAM,KAAG,IAAI;CAG3B,CAAC;AAEF,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI,CAEjD;AAED,wBAAgB,WAAW,IAAI,OAAO,CAErC;AAED;;GAEG;AACH,wBAAgB,UAAU,IAAI,MAAM,CAenC;AAED;;GAEG;AACH,wBAAgB,QAAQ,IAAI,OAAO,CAyDlC;AAGD,wBAAgB,UAAU,IAAI,OAAO,CAKpC;AAGD,eAAO,MAAM,OAAO;;;;CAUnB,CAAC"}
@@ -10,7 +10,7 @@ export declare const COLORS: {
10
10
  };
11
11
  export declare const MAX_FILE_SIZE: number;
12
12
  export declare const MAX_DIR_DEPTH = 50;
13
- export declare const SUPPORTED_EXTENSIONS: readonly [".js", ".ts", ".jsx", ".tsx", ".mjs"];
13
+ export declare const SUPPORTED_EXTENSIONS: readonly [".js", ".ts", ".jsx", ".tsx", ".mjs", ".vue", ".svelte"];
14
14
  export type SupportedExtension = (typeof SUPPORTED_EXTENSIONS)[number];
15
15
  export declare const DEFAULT_EXCLUDES: readonly ["node_modules", ".git", "dist", "build", ".next", "coverage", "__pycache__", ".cache"];
16
16
  export declare const DEFAULT_CONFIG: Required<FnmapConfig>;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/constants/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAG5C,eAAO,MAAM,MAAM;;;;;;;;CAQT,CAAC;AAGX,eAAO,MAAM,aAAa,QAAmB,CAAC;AAG9C,eAAO,MAAM,aAAa,KAAK,CAAC;AAGhC,eAAO,MAAM,oBAAoB,iDAAkD,CAAC;AACpF,MAAM,MAAM,kBAAkB,GAAG,CAAC,OAAO,oBAAoB,CAAC,CAAC,MAAM,CAAC,CAAC;AAGvE,eAAO,MAAM,gBAAgB,kGASnB,CAAC;AAGX,eAAO,MAAM,cAAc,EAAE,QAAQ,CAAC,WAAW,CAIhD,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/constants/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAG5C,eAAO,MAAM,MAAM;;;;;;;;CAQT,CAAC;AAGX,eAAO,MAAM,aAAa,QAAmB,CAAC;AAG9C,eAAO,MAAM,aAAa,KAAK,CAAC;AAGhC,eAAO,MAAM,oBAAoB,oEAAqE,CAAC;AACvG,MAAM,MAAM,kBAAkB,GAAG,CAAC,OAAO,oBAAoB,CAAC,CAAC,MAAM,CAAC,CAAC;AAGvE,eAAO,MAAM,gBAAgB,kGASnB,CAAC;AAGX,eAAO,MAAM,cAAc,EAAE,QAAQ,CAAC,WAAW,CAIhD,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"fnmap.d.ts","sourceRoot":"","sources":["../../src/generator/fnmap.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAE9C;;GAEG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,aAAa,EAAE,GAAG,MAAM,CA2DjF"}
1
+ {"version":3,"file":"fnmap.d.ts","sourceRoot":"","sources":["../../src/generator/fnmap.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAE9C;;GAEG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,aAAa,EAAE,GAAG,MAAM,CA0EjF"}
@@ -0,0 +1,11 @@
1
+ import * as readline from 'node:readline';
2
+ import type { DetectedTool } from '../types';
3
+ /** 根据检测到的工具生成质量检查脚本 */
4
+ export declare function generateQualityScript(detectedTools: DetectedTool[]): string;
5
+ /** 将 fnmap hooks 安装到项目的 .claude 目录 */
6
+ export declare function installHooks(projectDir: string, detectedTools: DetectedTool[]): void;
7
+ /** 交互式 hooks 安装流程 */
8
+ export declare function executeHooksSetup(projectDir: string, rl?: readline.Interface): Promise<void>;
9
+ /** 检测项目中安装的工具 */
10
+ export declare function detectTools(projectDir: string): DetectedTool[];
11
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAC;AAC1C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAgH7C,uBAAuB;AACvB,wBAAgB,qBAAqB,CAAC,aAAa,EAAE,YAAY,EAAE,GAAG,MAAM,CA0C3E;AASD,sCAAsC;AACtC,wBAAgB,YAAY,CAAC,UAAU,EAAE,MAAM,EAAE,aAAa,EAAE,YAAY,EAAE,GAAG,IAAI,CA0DpF;AAWD,qBAAqB;AACrB,wBAAsB,iBAAiB,CAAC,UAAU,EAAE,MAAM,EAAE,EAAE,CAAC,EAAE,QAAQ,CAAC,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC,CAgDlG;AAED,iBAAiB;AACjB,wBAAgB,WAAW,CAAC,UAAU,EAAE,MAAM,GAAG,YAAY,EAAE,CAgB9D"}
package/dist/index.d.ts CHANGED
@@ -3,7 +3,7 @@
3
3
  * fnmap - AI Code Indexing Tool
4
4
  * Analyzes JS/TS code structure and generates structured code maps to help AI understand code quickly
5
5
  */
6
- export type { ErrorType, ValidationResult, ValidationSuccess, ValidationFailure, FnmapConfig, LoadedConfig, ImportInfo, FunctionInfo, MethodInfo, ClassInfo, ConstantInfo, CallGraph, FileInfo, ParseErrorResult, AnalyzeResult, ProcessResult, ProcessSuccess, ProcessFailure, CLIOptions, InitOptions, ErrorContext, FileInfoEntry } from './types';
6
+ export type { ErrorType, ValidationResult, ValidationSuccess, ValidationFailure, FnmapConfig, LoadedConfig, ImportInfo, FunctionInfo, MethodInfo, ClassInfo, ConstantInfo, CallGraph, FileInfo, ParseErrorResult, AnalyzeResult, ProcessResult, ProcessSuccess, ProcessFailure, CLIOptions, InitOptions, ErrorContext, FileInfoEntry, DetectedTool } from './types';
7
7
  export { ErrorTypes, isParseError, isProcessSuccess, isProcessFailure, isValidationSuccess, isValidationFailure } from './types';
8
8
  export { COLORS, SUPPORTED_EXTENSIONS, DEFAULT_EXCLUDES, DEFAULT_CONFIG, MAX_FILE_SIZE, MAX_DIR_DEPTH } from './constants';
9
9
  export { validateFilePath, validateConfig, formatError, normalizePath, normalizePaths } from './validation';
@@ -14,6 +14,7 @@ export { analyzeFile, extractJSDocDescription } from './analyzer';
14
14
  export { generateHeader, removeExistingHeaders, generateAiMap, generateFileMermaid, generateProjectMermaid } from './generator';
15
15
  export { processFile, processCode } from './processor';
16
16
  export type { ProcessCodeOptions } from './processor';
17
+ export { detectTools, generateQualityScript, installHooks, executeHooksSetup } from './hooks';
17
18
  import { main } from './main';
18
19
  export { main };
19
20
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA;;;GAGG;AAGH,YAAY,EACV,SAAS,EACT,gBAAgB,EAChB,iBAAiB,EACjB,iBAAiB,EACjB,WAAW,EACX,YAAY,EACZ,UAAU,EACV,YAAY,EACZ,UAAU,EACV,SAAS,EACT,YAAY,EACZ,SAAS,EACT,QAAQ,EACR,gBAAgB,EAChB,aAAa,EACb,aAAa,EACb,cAAc,EACd,cAAc,EACd,UAAU,EACV,WAAW,EACX,YAAY,EACZ,aAAa,EACd,MAAM,SAAS,CAAC;AAGjB,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAGjI,OAAO,EAAE,MAAM,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,cAAc,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAG3H,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,WAAW,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAG5G,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAGnD,OAAO,EAAE,QAAQ,EAAE,UA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,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAGnD,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,EAAE,YAAY,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAGzF,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAG9D,OAAO,EAAE,WAAW,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC;AAGlE,OAAO,EAAE,cAAc,EAAE,qBAAqB,EAAE,aAAa,EAAE,mBAAmB,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAGhI,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AACvD,YAAY,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAGtD,OAAO,EAAE,WAAW,EAAE,qBAAqB,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAG9F,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO,EAAE,IAAI,EAAE,CAAC"}
package/dist/index.js CHANGED
@@ -1,14 +1,14 @@
1
1
  #!/usr/bin/env node
2
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const F=require("fs"),g=require("path"),en=require("commander"),Ie=require("child_process"),nn=require("@babel/parser"),Re=require("@babel/traverse"),tn=require("os"),rn=require("node:readline");function sn(e){const r=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const s=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(r,n,s.get?s:{enumerable:!0,get:()=>e[n]})}}return r.default=e,Object.freeze(r)}const on=sn(rn),z={FILE_NOT_FOUND:"FILE_NOT_FOUND",FILE_READ_ERROR:"FILE_READ_ERROR",PARSE_ERROR:"PARSE_ERROR",CONFIG_ERROR:"CONFIG_ERROR",VALIDATION_ERROR:"VALIDATION_ERROR",PERMISSION_ERROR:"PERMISSION_ERROR",FILE_TOO_LARGE:"FILE_TOO_LARGE"};function ke(e){return"parseError"in e}function an(e){return e.success===!0}function cn(e){return e.success===!1}function ln(e){return e.valid===!0}function fn(e){return e.valid===!1}const S={reset:"\x1B[0m",red:"\x1B[31m",green:"\x1B[32m",yellow:"\x1B[33m",blue:"\x1B[34m",gray:"\x1B[90m",bold:"\x1B[1m"},Le=10*1024*1024,je=50,Fe=[".js",".ts",".jsx",".tsx",".mjs"],Te=["node_modules",".git","dist","build",".next","coverage","__pycache__",".cache"],Ne={enable:!0,include:["**/*.js","**/*.ts","**/*.jsx","**/*.tsx","**/*.mjs"],exclude:[]};function $e(e){if(!e)return e;const r=e.replace(/\\/g,"/");return g.normalize(r)}function dn(e){return e.map($e)}function ze(e){if(!e||typeof e!="string")return{valid:!1,error:"File path is required and must be a string / 文件路径必须是字符串",errorType:z.VALIDATION_ERROR};if(!F.existsSync(e))return{valid:!1,error:`File not found: ${e} / 文件不存在: ${e}`,errorType:z.FILE_NOT_FOUND};try{const r=F.statSync(e);if(!r.isFile())return{valid:!1,error:`Path is not a file: ${e} / 路径不是文件: ${e}`,errorType:z.VALIDATION_ERROR};if(r.size>Le)return{valid:!1,error:`File too large (${(r.size/1024/1024).toFixed(2)}MB > ${Le/1024/1024}MB): ${e} / 文件过大`,errorType:z.FILE_TOO_LARGE}}catch(r){return{valid:!1,error:`Cannot access file: ${e}. Reason: ${r.message} / 无法访问文件`,errorType:z.PERMISSION_ERROR}}return{valid:!0}}function De(e){if(!e||typeof e!="object")return{valid:!1,error:"Config must be an object / 配置必须是对象"};const r=e;return r.enable!==void 0&&typeof r.enable!="boolean"?{valid:!1,error:"Config.enable must be a boolean / enable 字段必须是布尔值"}:r.include!==void 0&&!Array.isArray(r.include)?{valid:!1,error:"Config.include must be an array / include 字段必须是数组"}:r.exclude!==void 0&&!Array.isArray(r.exclude)?{valid:!1,error:"Config.exclude must be an array / exclude 字段必须是数组"}:{valid:!0}}function Se(e,r,n={}){const s=[r];return n.file&&s.push(`File: ${n.file}`),n.line!==void 0&&n.column!==void 0&&s.push(`Location: Line ${n.line}, Column ${n.column}`),n.suggestion&&s.push(`Suggestion: ${n.suggestion}`),s.join(`
3
- `)}let ye=!0,be=null;const E={error:e=>{ye||console.error(`${S.red}✗${S.reset} ${e}`)},success:e=>{ye||console.log(`${S.green}✓${S.reset} ${e}`)},info:e=>{ye||console.log(e)},warn:e=>{ye||console.warn(`${S.yellow}!${S.reset} ${e}`)},title:e=>{ye||console.log(`${S.bold}${e}${S.reset}`)},stats:e=>{console.log(e)}};function he(e){ye=e}function _e(){return ye}function We(){try{let e;try{e=require("../../package.json")}catch{e=require("../package.json")}return e.version}catch{return"0.1.0"}}function Me(){return be=new en.Command,be.name("fnmap").description("AI code indexing tool - Analyzes JS/TS code structure and generates structured code maps").version(We(),"-v, --version","Show version number").option("-f, --files <files>","Process specified files (comma-separated)",e=>e.split(",").map(r=>$e(r.trim())).filter(Boolean)).option("-d, --dir <dir>","Process all code files in directory",e=>$e(e)).option("-p, --project <dir>","Specify project root directory (default: current directory)",e=>$e(e),process.env.CLAUDE_PROJECT_DIR??process.cwd()).option("-c, --changed","Process only git changed files (staged + modified + untracked)").option("-s, --staged","Process only git staged files (for pre-commit hook)").option("-m, --mermaid [mode]","Generate Mermaid call graph (file=file-level, project=project-level)").option("-l, --log","Show detailed processing logs").option("--init","Create default config file and setup project (interactive)").option("--clear","Clear generated files (.fnmap, *.fnmap, *.mermaid)").argument("[files...]","Directly specify file paths").allowUnknownOption(!1).addHelpText("after",`
2
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const A=require("fs"),$=require("path"),pt=require("commander"),_e=require("child_process"),mt=require("@babel/parser"),je=require("@babel/traverse"),ut=require("node:readline"),gt=require("os");function yt(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const s=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,s.get?s:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const Ye=yt(ut),U={FILE_NOT_FOUND:"FILE_NOT_FOUND",FILE_READ_ERROR:"FILE_READ_ERROR",PARSE_ERROR:"PARSE_ERROR",CONFIG_ERROR:"CONFIG_ERROR",VALIDATION_ERROR:"VALIDATION_ERROR",PERMISSION_ERROR:"PERMISSION_ERROR",FILE_TOO_LARGE:"FILE_TOO_LARGE"};function We(e){return"parseError"in e}function ht(e){return e.success===!0}function $t(e){return e.success===!1}function Et(e){return e.valid===!0}function St(e){return e.valid===!1}const y={reset:"\x1B[0m",red:"\x1B[31m",green:"\x1B[32m",yellow:"\x1B[33m",blue:"\x1B[34m",gray:"\x1B[90m",bold:"\x1B[1m"},Pe=10*1024*1024,Me=50,Le=[".js",".ts",".jsx",".tsx",".mjs",".vue",".svelte"],Be=["node_modules",".git","dist","build",".next","coverage","__pycache__",".cache"],Ue={enable:!0,include:["**/*.js","**/*.ts","**/*.jsx","**/*.tsx","**/*.mjs","**/*.vue","**/*.svelte"],exclude:[]};function be(e){if(!e)return e;const t=e.replace(/\\/g,"/");return $.normalize(t)}function Rt(e){return e.map(be)}function Ze(e){if(!e||typeof e!="string")return{valid:!1,error:"File path is required and must be a string / 文件路径必须是字符串",errorType:U.VALIDATION_ERROR};if(!A.existsSync(e))return{valid:!1,error:`File not found: ${e} / 文件不存在: ${e}`,errorType:U.FILE_NOT_FOUND};try{const t=A.statSync(e);if(!t.isFile())return{valid:!1,error:`Path is not a file: ${e} / 路径不是文件: ${e}`,errorType:U.VALIDATION_ERROR};if(t.size>Pe)return{valid:!1,error:`File too large (${(t.size/1024/1024).toFixed(2)}MB > ${Pe/1024/1024}MB): ${e} / 文件过大`,errorType:U.FILE_TOO_LARGE}}catch(t){return{valid:!1,error:`Cannot access file: ${e}. Reason: ${t.message} / 无法访问文件`,errorType:U.PERMISSION_ERROR}}return{valid:!0}}function Ge(e){if(!e||typeof e!="object")return{valid:!1,error:"Config must be an object / 配置必须是对象"};const t=e;return t.enable!==void 0&&typeof t.enable!="boolean"?{valid:!1,error:"Config.enable must be a boolean / enable 字段必须是布尔值"}:t.include!==void 0&&!Array.isArray(t.include)?{valid:!1,error:"Config.include must be an array / include 字段必须是数组"}:t.exclude!==void 0&&!Array.isArray(t.exclude)?{valid:!1,error:"Config.exclude must be an array / exclude 字段必须是数组"}:{valid:!0}}function Ae(e,t,n={}){const s=[t];return n.file&&s.push(`File: ${n.file}`),n.line!==void 0&&n.column!==void 0&&s.push(`Location: Line ${n.line}, Column ${n.column}`),n.suggestion&&s.push(`Suggestion: ${n.suggestion}`),s.join(`
3
+ `)}let xe=!0,ve=null;const x={error:e=>{xe||console.error(`${y.red}✗${y.reset} ${e}`)},success:e=>{xe||console.log(`${y.green}✓${y.reset} ${e}`)},info:e=>{xe||console.log(e)},warn:e=>{xe||console.warn(`${y.yellow}!${y.reset} ${e}`)},title:e=>{xe||console.log(`${y.bold}${e}${y.reset}`)},stats:e=>{console.log(e)}};function Se(e){xe=e}function Fe(){return xe}function et(){try{let e;try{e=require("../../package.json")}catch{e=require("../package.json")}return e.version}catch{return"0.1.0"}}function Ve(){return ve=new pt.Command,ve.name("fnmap").description("AI code indexing tool - Analyzes JS/TS code structure and generates structured code maps").version(et(),"-v, --version","Show version number").option("-f, --files <files>","Process specified files (comma-separated)",e=>e.split(",").map(t=>be(t.trim())).filter(Boolean)).option("-d, --dir <dir>","Process all code files in directory",e=>be(e)).option("-p, --project <dir>","Specify project root directory (default: current directory)",e=>be(e),process.env.CLAUDE_PROJECT_DIR??process.cwd()).option("-c, --changed","Process only git changed files (staged + modified + untracked)").option("-s, --staged","Process only git staged files (for pre-commit hook)").option("--merge","Merge all files in same directory into one .fnmap (default: per-file)").option("-m, --mermaid [mode]","Generate Mermaid call graph (file=file-level, project=project-level)").option("-l, --log","Show detailed processing logs").option("--init","Create default config file and setup project (interactive)").option("--clear","Clear generated files (.fnmap, *.fnmap, *.mermaid)").option("--hooks","Setup Claude Code hooks for auto quality checks").argument("[files...]","Directly specify file paths").allowUnknownOption(!1).addHelpText("after",`
4
4
  Configuration files (by priority):
5
5
  .fnmaprc JSON config file
6
6
  .fnmaprc.json JSON config file
7
7
  package.json#fnmap fnmap field in package.json
8
8
 
9
9
  Output:
10
- .fnmap Code index file in directory mode (imports, functions, classes, constants, call graph)
11
- *.fnmap Individual file index when using --files (e.g., module.fnmap)
10
+ *.fnmap Per-file code index (default, e.g., module.fnmap)
11
+ .fnmap Merged directory index (when using --merge)
12
12
  *.mermaid Mermaid call graph (when using --mermaid file)
13
13
  .fnmap.mermaid Project-level Mermaid call graph (when using --mermaid project)
14
14
 
@@ -22,59 +22,112 @@ Examples:
22
22
  $ fnmap --mermaid project Generate project-level call graph
23
23
  $ fnmap --init Interactive project setup
24
24
  $ fnmap --clear Clear all generated files
25
+ $ fnmap --merge --dir src Merge into one .fnmap per directory
25
26
  $ fnmap --clear --dir src Clear generated files in src directory
26
- `),be}function xe(){return be||Me()}const mn={get opts(){return xe().opts.bind(xe())},get args(){return xe().args},get parse(){return xe().parse.bind(xe())}};function Be(e){const r=[".fnmaprc",".fnmaprc.json"];for(const s of r){const c=g.join(e,s);if(F.existsSync(c))try{const f=F.readFileSync(c,"utf-8");if(!f.trim()){E.warn(`Config file is empty: ${s}. Using default config / 配置文件为空,使用默认配置`);continue}let $;try{$=JSON.parse(f)}catch(p){const h=p,o=Se(z.CONFIG_ERROR,`Failed to parse config file: ${s} / 配置文件解析失败`,{file:c,line:h.lineNumber,column:h.columnNumber,suggestion:"Check JSON syntax, ensure proper quotes and commas / 检查 JSON 语法,确保引号和逗号正确"});E.warn(o);continue}const u=De($);if(!u.valid){E.warn(`Invalid config in ${s}: ${u.error}`);continue}return{config:$,source:s}}catch(f){const $=f,u=Se(z.FILE_READ_ERROR,`Failed to read config file: ${s} / 配置文件读取失败`,{file:c,suggestion:$.message});E.warn(u)}}const n=g.join(e,"package.json");if(F.existsSync(n))try{const s=JSON.parse(F.readFileSync(n,"utf-8"));if(s.fnmap){const c=De(s.fnmap);if(!c.valid)E.warn(`Invalid fnmap config in package.json: ${c.error}`);else return{config:s.fnmap,source:"package.json#fnmap"}}}catch{}return{config:null,source:null}}function Je(e){return e?{...Ne,...e,exclude:[...e.exclude??[]]}:Ne}function Pe(e){return e.endsWith(".d.ts")||e.endsWith(".d.tsx")||e.endsWith(".d.mts")}function pn(e){try{return Ie.execSync("git rev-parse --show-toplevel",{cwd:e,encoding:"utf-8"}).trim()}catch{return null}}function Ke(e,r=!1){const n=[];try{const s=pn(e);if(!s)return[];let c;if(r)c=Ie.execSync("git diff --cached --name-only --diff-filter=ACMR",{cwd:e,encoding:"utf-8"});else{const u=Ie.execSync("git diff --cached --name-only --diff-filter=ACMR",{cwd:e,encoding:"utf-8"}),p=Ie.execSync("git diff --name-only --diff-filter=ACMR",{cwd:e,encoding:"utf-8"}),h=Ie.execSync("git ls-files --others --exclude-standard",{cwd:e,encoding:"utf-8"});c=`${u}
27
- ${p}
28
- ${h}`}const f=c.split(`
29
- `).map(u=>u.trim()).filter(Boolean).filter(u=>{const p=g.extname(u);return Fe.includes(p)&&!Pe(u)}),$=[...new Set(f)];for(const u of $){const p=g.resolve(s,u);F.existsSync(p)&&p.startsWith(g.resolve(e))&&n.push(p)}}catch{return[]}return n}function un(e){const r=[];if(!F.existsSync(e))return r;try{const n=F.readdirSync(e,{withFileTypes:!0});for(const s of n)if(s.isFile()){const c=g.extname(s.name);Fe.includes(c)&&!Pe(s.name)&&r.push(g.join(e,s.name))}}catch{return r}return r}function Ae(e,r=e,n=Te,s=0,c=new Set){const f=[];if(!F.existsSync(e))return E.warn(`Directory does not exist: ${e} / 目录不存在`),f;if(s>je)return E.warn(`Max directory depth (${je}) exceeded: ${e} / 超过最大目录深度`),f;let $;try{$=F.realpathSync(e)}catch(p){const h=p;return E.warn(`Cannot resolve real path: ${e}. Reason: ${h.message} / 无法解析真实路径`),f}if(c.has($))return E.warn(`Circular reference detected, skipping: ${e} / 检测到循环引用`),f;c.add($);let u;try{u=F.readdirSync(e,{withFileTypes:!0})}catch(p){const h=p;return h.code==="EACCES"||h.code==="EPERM"?E.warn(`Permission denied: ${e} / 权限不足`):E.warn(`Failed to read directory: ${e}. Reason: ${h.message} / 读取目录失败`),f}for(const p of u)try{const h=g.join(e,p.name);if(p.isDirectory())n.includes(p.name)||f.push(...Ae(h,r,n,s+1,c));else if(p.isFile()){const o=g.extname(p.name);Fe.includes(o)&&!Pe(p.name)&&f.push(g.relative(r,h))}}catch(h){const o=h;E.warn(`Error processing entry: ${p.name}. Reason: ${o.message} / 处理条目出错`)}return f}function Y(e){if(!e)return"";const n=e.value.split(`
30
- `).map(s=>s.replace(/^\s*\*\s?/,"").trim());for(const s of n)if(s.startsWith("@description "))return s.slice(13).trim().slice(0,60);for(const s of n)if(s&&!s.startsWith("@")&&!s.startsWith("/"))return s.slice(0,60);return""}function ge(e,r){if(e.leadingComments&&e.leadingComments.length>0)return e.leadingComments[e.leadingComments.length-1]??null;if(r&&(r.type==="ExportNamedDeclaration"||r.type==="ExportDefaultDeclaration")){const n=r;if(n.leadingComments&&n.leadingComments.length>0)return n.leadingComments[n.leadingComments.length-1]??null}return null}const ve=typeof Re=="function"?Re:Re.default;function Ge(e,r){var I,v;if(e==null)return{parseError:"Code content is null or undefined / 代码内容为空",errorType:z.VALIDATION_ERROR};if(typeof e!="string")return{parseError:"Code must be a string / 代码必须是字符串类型",errorType:z.VALIDATION_ERROR};if(!e.trim())return{description:"",imports:[],functions:[],classes:[],constants:[],callGraph:{}};const n={description:"",imports:[],functions:[],classes:[],constants:[],callGraph:{}},s=e.match(/^\/\*\*[\s\S]*?\*\//);if(s){const t=s[0].split(`
31
- `).map(i=>i.replace(/^\s*\*\s?/,"").trim()).filter(i=>i&&!i.startsWith("/")&&!i.startsWith("@ai"));for(const i of t)if(i.startsWith("@description ")){n.description=i.slice(13).trim();break}if(!n.description&&t.length>0){const i=t.find(m=>!m.startsWith("@"));i&&(n.description=i)}}let c;try{const a=r&&(r.endsWith(".ts")||r.endsWith(".tsx"));c=nn.parse(e,{sourceType:"unambiguous",plugins:["jsx","classPrivateProperties","classPrivateMethods",...a?["typescript"]:[]]})}catch(a){const t=a;return{parseError:Se(z.PARSE_ERROR,`Syntax error: ${t.message} / 语法错误`,{file:r??void 0,line:(I=t.loc)==null?void 0:I.line,column:(v=t.loc)==null?void 0:v.column,suggestion:"Check syntax errors in the file / 检查文件中的语法错误"}),loc:t.loc,errorType:z.PARSE_ERROR}}const f=new Map,$=new Map,u=new Map;function p(a){if(!a)return null;if(a.type==="Identifier")return a.name;if(a.type==="MemberExpression"){const t=a.object,i=a.property;if(t.type==="Identifier"&&i.type==="Identifier")return t.name}return null}function h(a){var i,m,b;let t=a;for(;t;){if(t.node.type==="FunctionDeclaration"){const x=t.node;if(x.id)return x.id.name}if(t.node.type==="ClassMethod"){const x=t.node,R=(i=t.parentPath)==null?void 0:i.parentPath,C=R==null?void 0:R.node,j=((m=C==null?void 0:C.id)==null?void 0:m.name)??"",T=((b=x.key)==null?void 0:b.name)??"";return j?`${j}.${T}`:T}if(t.node.type==="ArrowFunctionExpression"||t.node.type==="FunctionExpression"){const x=t.parent;if((x==null?void 0:x.type)==="VariableDeclarator"){const C=x.id;if(C!=null&&C.name)return C.name}}t=t.parentPath}return null}ve(c,{VariableDeclarator(a){var i,m,b,x;const t=a.node;if(((i=t.init)==null?void 0:i.type)==="CallExpression"&&((m=t.init.callee)==null?void 0:m.type)==="Identifier"&&t.init.callee.name==="require"&&((x=(b=t.init.arguments)==null?void 0:b[0])==null?void 0:x.type)==="StringLiteral"){const R=t.init.arguments[0].value;if(f.has(R)||f.set(R,new Set),t.id.type==="Identifier"){const C=t.id.name;f.get(R).add(C),$.set(C,R),u.set(C,new Set)}else if(t.id.type==="ObjectPattern"){for(const C of t.id.properties)if(C.type==="ObjectProperty"&&C.key.type==="Identifier"){const j=C.value.type==="Identifier"?C.value.name:C.key.name;f.get(R).add(C.key.name),$.set(j,R),u.set(j,new Set)}}}},CallExpression(a){var i,m,b,x,R,C;const t=a.node;if(((i=t.callee)==null?void 0:i.type)==="Identifier"&&t.callee.name==="require"&&((b=(m=t.arguments)==null?void 0:m[0])==null?void 0:b.type)==="StringLiteral"){const j=a.parent;if((j==null?void 0:j.type)==="MemberExpression"&&((x=j.property)==null?void 0:x.type)==="Identifier"){const T=t.arguments[0].value;f.has(T)||f.set(T,new Set),f.get(T).add(j.property.name);const U=(R=a.parentPath)==null?void 0:R.parent;if((U==null?void 0:U.type)==="VariableDeclarator"){const q=U;((C=q.id)==null?void 0:C.type)==="Identifier"&&($.set(q.id.name,T),u.set(q.id.name,new Set))}}}},ImportDeclaration(a){const t=a.node,i=t.source.value;f.has(i)||f.set(i,new Set);for(const m of t.specifiers){let b,x;if(m.type==="ImportDefaultSpecifier")b="default",x=m.local.name;else if(m.type==="ImportNamespaceSpecifier")b="*",x=m.local.name;else if(m.type==="ImportSpecifier"){const R=m.imported;b=R.type==="Identifier"?R.name:R.value,x=m.local.name}b&&x&&(f.get(i).add(b),$.set(x,i),u.set(x,new Set))}}}),ve(c,{Identifier(a){const t=a.node.name;if(u.has(t)){const i=a.parent;if((i==null?void 0:i.type)==="VariableDeclarator"&&i.id===a.node||(i==null?void 0:i.type)==="ImportSpecifier"||(i==null?void 0:i.type)==="ImportDefaultSpecifier")return;const m=h(a);m&&u.get(t).add(m)}},FunctionDeclaration(a){var C,j,T,U,q;if(a.parent.type==="ExportDefaultDeclaration")return;const t=a.node,i=((C=t.id)==null?void 0:C.name)??"[anonymous]",m=t.params.map(G=>{var K,X;return G.type==="Identifier"?G.name:G.type==="AssignmentPattern"&&((K=G.left)==null?void 0:K.type)==="Identifier"?G.left.name+"?":G.type==="RestElement"&&((X=G.argument)==null?void 0:X.type)==="Identifier"?"..."+G.argument.name:"?"}),b=((T=(j=t.loc)==null?void 0:j.start)==null?void 0:T.line)??0,x=((q=(U=t.loc)==null?void 0:U.end)==null?void 0:q.line)??0,R=Y(ge(t,a.parent));n.functions.push({name:i,params:m.join(","),startLine:b,endLine:x,description:R})},ClassDeclaration(a){var j,T,U,q,G,K,X,ee,ne;if(a.parent.type==="ExportDefaultDeclaration")return;const t=a.node,i=((j=t.id)==null?void 0:j.name)??"[anonymous]",m=((U=(T=t.loc)==null?void 0:T.start)==null?void 0:U.line)??0,b=((G=(q=t.loc)==null?void 0:q.end)==null?void 0:G.line)??0,x=p(t.superClass),R=Y(ge(t,a.parent)),C=[];if((K=t.body)!=null&&K.body){for(const W of t.body.body)if(W.type==="ClassMethod"){const se=((X=W.key)==null?void 0:X.type)==="Identifier"?W.key.name:"[computed]",ie=W.params.map(H=>{var re;return H.type==="Identifier"?H.name:H.type==="AssignmentPattern"&&((re=H.left)==null?void 0:re.type)==="Identifier"?H.left.name+"?":"?"}),oe=((ne=(ee=W.loc)==null?void 0:ee.start)==null?void 0:ne.line)??0;let te="";const Z=W.leadingComments;Z&&Z.length>0&&(te=Y(Z[Z.length-1])),C.push({name:se,params:ie.join(","),line:oe,static:W.static,kind:W.kind,description:te})}}n.classes.push({name:i,superClass:x,startLine:m,endLine:b,methods:C,description:R})},VariableDeclaration(a){var b,x,R,C,j,T,U,q,G,K,X,ee,ne,W,se,ie,oe,te,Z,H,re,ce,le,fe,de,me,pe,ae,B,L,J;const t=a.parent.type;if(t!=="Program"&&t!=="ExportNamedDeclaration")return;const i=a.node,m=Y(ge(i,a.parent));for(const O of i.declarations){const _=((b=O.id)==null?void 0:b.type)==="Identifier"?O.id.name:void 0;if(_){if(((x=O.init)==null?void 0:x.type)==="ArrowFunctionExpression"||((R=O.init)==null?void 0:R.type)==="FunctionExpression"){const d=O.init.params.map(P=>{var N,V;return P.type==="Identifier"?P.name:P.type==="AssignmentPattern"&&((N=P.left)==null?void 0:N.type)==="Identifier"?P.left.name+"?":P.type==="RestElement"&&((V=P.argument)==null?void 0:V.type)==="Identifier"?"..."+P.argument.name:"?"}),A=((j=(C=i.loc)==null?void 0:C.start)==null?void 0:j.line)??0,M=((U=(T=i.loc)==null?void 0:T.end)==null?void 0:U.line)??0;n.functions.push({name:_,params:d.join(","),startLine:A,endLine:M,description:m});continue}if(((q=O.init)==null?void 0:q.type)==="ClassExpression"){const w=O.init,d=((K=(G=i.loc)==null?void 0:G.start)==null?void 0:K.line)??0,A=((ee=(X=i.loc)==null?void 0:X.end)==null?void 0:ee.line)??0,M=p(w.superClass),P=[];if((ne=w.body)!=null&&ne.body){for(const N of w.body.body)if(N.type==="ClassMethod"){const V=((W=N.key)==null?void 0:W.type)==="Identifier"?N.key.name:"[computed]",k=N.params.map(Ee=>{var Ue;return Ee.type==="Identifier"?Ee.name:Ee.type==="AssignmentPattern"&&((Ue=Ee.left)==null?void 0:Ue.type)==="Identifier"?Ee.left.name+"?":"?"}),D=((ie=(se=N.loc)==null?void 0:se.start)==null?void 0:ie.line)??0;let Q="";const ue=N.leadingComments;ue&&ue.length>0&&(Q=Y(ue[ue.length-1])),P.push({name:V,params:k.join(","),line:D,static:N.static,kind:N.kind,description:Q})}}n.classes.push({name:_,superClass:M,startLine:d,endLine:A,methods:P,description:m});continue}if(((oe=O.init)==null?void 0:oe.type)==="ObjectExpression"){const w=O.init;for(const d of w.properties)if(d.type==="ObjectMethod"){const A=((te=d.key)==null?void 0:te.type)==="Identifier"?`${_}.${d.key.name}`:`${_}.[computed]`,M=d.params.map(k=>{var D,Q;return k.type==="Identifier"?k.name:k.type==="AssignmentPattern"&&((D=k.left)==null?void 0:D.type)==="Identifier"?k.left.name+"?":k.type==="RestElement"&&((Q=k.argument)==null?void 0:Q.type)==="Identifier"?"..."+k.argument.name:"?"}),P=((H=(Z=d.loc)==null?void 0:Z.start)==null?void 0:H.line)??0,N=((ce=(re=d.loc)==null?void 0:re.end)==null?void 0:ce.line)??0;let V="";d.leadingComments&&d.leadingComments.length>0&&(V=Y(d.leadingComments[d.leadingComments.length-1])),n.functions.push({name:A,params:M.join(","),startLine:P,endLine:N,description:V})}else if(d.type==="ObjectProperty"&&((le=d.key)==null?void 0:le.type)==="Identifier"&&(((fe=d.value)==null?void 0:fe.type)==="ArrowFunctionExpression"||((de=d.value)==null?void 0:de.type)==="FunctionExpression")){const A=d.value,M=`${_}.${d.key.name}`,P=A.params.map(D=>{var Q,ue;return D.type==="Identifier"?D.name:D.type==="AssignmentPattern"&&((Q=D.left)==null?void 0:Q.type)==="Identifier"?D.left.name+"?":D.type==="RestElement"&&((ue=D.argument)==null?void 0:ue.type)==="Identifier"?"..."+D.argument.name:"?"}),N=((pe=(me=d.loc)==null?void 0:me.start)==null?void 0:pe.line)??0,V=((B=(ae=d.loc)==null?void 0:ae.end)==null?void 0:B.line)??0;let k="";d.leadingComments&&d.leadingComments.length>0&&(k=Y(d.leadingComments[d.leadingComments.length-1])),n.functions.push({name:M,params:P.join(","),startLine:N,endLine:V,description:k})}}if(i.kind==="const"&&_===_.toUpperCase()&&_.length>2){const w=((J=(L=i.loc)==null?void 0:L.start)==null?void 0:J.line)??0;n.constants.push({name:_,line:w,description:m})}}}},ExportDefaultDeclaration(a){var b,x,R,C,j,T,U,q,G,K,X,ee,ne,W,se,ie,oe,te,Z,H,re,ce,le,fe,de,me,pe,ae,B;const t=a.node,i=t.declaration,m=Y(ge(t,a.parent));if(i.type==="FunctionDeclaration"){const L=i,J=((b=L.id)==null?void 0:b.name)??"[default]",O=L.params.map(d=>{var A,M;return d.type==="Identifier"?d.name:d.type==="AssignmentPattern"&&((A=d.left)==null?void 0:A.type)==="Identifier"?d.left.name+"?":d.type==="RestElement"&&((M=d.argument)==null?void 0:M.type)==="Identifier"?"..."+d.argument.name:"?"}),_=((R=(x=t.loc)==null?void 0:x.start)==null?void 0:R.line)??0,w=((j=(C=t.loc)==null?void 0:C.end)==null?void 0:j.line)??0;n.functions.push({name:J,params:O.join(","),startLine:_,endLine:w,description:m});return}if(i.type==="ClassDeclaration"){const L=i,J=((T=L.id)==null?void 0:T.name)??"[default]",O=((q=(U=t.loc)==null?void 0:U.start)==null?void 0:q.line)??0,_=((K=(G=t.loc)==null?void 0:G.end)==null?void 0:K.line)??0,w=p(L.superClass),d=[];if((X=L.body)!=null&&X.body){for(const A of L.body.body)if(A.type==="ClassMethod"){const M=((ee=A.key)==null?void 0:ee.type)==="Identifier"?A.key.name:"[computed]",P=A.params.map(D=>{var Q;return D.type==="Identifier"?D.name:D.type==="AssignmentPattern"&&((Q=D.left)==null?void 0:Q.type)==="Identifier"?D.left.name+"?":"?"}),N=((W=(ne=A.loc)==null?void 0:ne.start)==null?void 0:W.line)??0;let V="";const k=A.leadingComments;k&&k.length>0&&(V=Y(k[k.length-1])),d.push({name:M,params:P.join(","),line:N,static:A.static,kind:A.kind,description:V})}}n.classes.push({name:J,superClass:w,startLine:O,endLine:_,methods:d,description:m});return}if(i.type==="ArrowFunctionExpression"||i.type==="FunctionExpression"){const L=i,J=L.type==="FunctionExpression"&&((se=L.id)!=null&&se.name)?L.id.name:"[default]",O=L.params.map(d=>{var A,M;return d.type==="Identifier"?d.name:d.type==="AssignmentPattern"&&((A=d.left)==null?void 0:A.type)==="Identifier"?d.left.name+"?":d.type==="RestElement"&&((M=d.argument)==null?void 0:M.type)==="Identifier"?"..."+d.argument.name:"?"}),_=((oe=(ie=t.loc)==null?void 0:ie.start)==null?void 0:oe.line)??0,w=((Z=(te=t.loc)==null?void 0:te.end)==null?void 0:Z.line)??0;n.functions.push({name:J,params:O.join(","),startLine:_,endLine:w,description:m});return}if(i.type==="ClassExpression"){const L=i,J=((H=L.id)==null?void 0:H.name)??"[default]",O=((ce=(re=t.loc)==null?void 0:re.start)==null?void 0:ce.line)??0,_=((fe=(le=t.loc)==null?void 0:le.end)==null?void 0:fe.line)??0,w=((de=L.superClass)==null?void 0:de.type)==="Identifier"?L.superClass.name:null,d=[];if((me=L.body)!=null&&me.body){for(const A of L.body.body)if(A.type==="ClassMethod"){const M=((pe=A.key)==null?void 0:pe.type)==="Identifier"?A.key.name:"[computed]",P=A.params.map(D=>{var Q;return D.type==="Identifier"?D.name:D.type==="AssignmentPattern"&&((Q=D.left)==null?void 0:Q.type)==="Identifier"?D.left.name+"?":"?"}),N=((B=(ae=A.loc)==null?void 0:ae.start)==null?void 0:B.line)??0;let V="";const k=A.leadingComments;k&&k.length>0&&(V=Y(k[k.length-1])),d.push({name:M,params:P.join(","),line:N,static:A.static,kind:A.kind,description:V})}}n.classes.push({name:J,superClass:w,startLine:O,endLine:_,methods:d,description:m})}},AssignmentExpression(a){var x,R,C,j,T,U,q,G,K,X,ee,ne,W,se,ie,oe,te,Z,H,re,ce,le,fe,de,me,pe;const t=a.node;if(a.parent.type!=="ExpressionStatement")return;const i=(x=a.parentPath)==null?void 0:x.parent;if((i==null?void 0:i.type)!=="Program")return;const m=t.left,b=t.right;if(m.type==="MemberExpression"&&((R=m.object)==null?void 0:R.type)==="Identifier"&&m.object.name==="module"&&((C=m.property)==null?void 0:C.type)==="Identifier"&&m.property.name==="exports"){const ae=Y(ge(a.parent,i));if(b.type==="FunctionExpression"||b.type==="ArrowFunctionExpression"){const B=b,L=b.type==="FunctionExpression"&&((j=b.id)!=null&&j.name)?b.id.name:"[exports]",J=B.params.map(w=>{var d,A;return w.type==="Identifier"?w.name:w.type==="AssignmentPattern"&&((d=w.left)==null?void 0:d.type)==="Identifier"?w.left.name+"?":w.type==="RestElement"&&((A=w.argument)==null?void 0:A.type)==="Identifier"?"..."+w.argument.name:"?"}),O=((U=(T=t.loc)==null?void 0:T.start)==null?void 0:U.line)??0,_=((G=(q=t.loc)==null?void 0:q.end)==null?void 0:G.line)??0;n.functions.push({name:L,params:J.join(","),startLine:O,endLine:_,description:ae});return}if(b.type==="ClassExpression"){const B=b,L=((K=B.id)==null?void 0:K.name)??"[exports]",J=((ee=(X=t.loc)==null?void 0:X.start)==null?void 0:ee.line)??0,O=((W=(ne=t.loc)==null?void 0:ne.end)==null?void 0:W.line)??0,_=p(B.superClass),w=[];if((se=B.body)!=null&&se.body){for(const d of B.body.body)if(d.type==="ClassMethod"){const A=((ie=d.key)==null?void 0:ie.type)==="Identifier"?d.key.name:"[computed]",M=d.params.map(N=>{var V;return N.type==="Identifier"?N.name:N.type==="AssignmentPattern"&&((V=N.left)==null?void 0:V.type)==="Identifier"?N.left.name+"?":"?"}),P=((te=(oe=d.loc)==null?void 0:oe.start)==null?void 0:te.line)??0;w.push({name:A,params:M.join(","),line:P,static:d.static,kind:d.kind,description:""})}}n.classes.push({name:L,superClass:_,startLine:J,endLine:O,methods:w,description:ae});return}}if(m.type==="MemberExpression"&&((Z=m.property)==null?void 0:Z.type)==="Identifier"){const ae=m.property.name;let B=!1;if(((H=m.object)==null?void 0:H.type)==="Identifier"&&m.object.name==="exports"&&(B=!0),((re=m.object)==null?void 0:re.type)==="MemberExpression"&&((ce=m.object.object)==null?void 0:ce.type)==="Identifier"&&m.object.object.name==="module"&&((le=m.object.property)==null?void 0:le.type)==="Identifier"&&m.object.property.name==="exports"&&(B=!0),B){const L=Y(ge(a.parent,i));if(b.type==="FunctionExpression"||b.type==="ArrowFunctionExpression"){const O=b.params.map(d=>{var A,M;return d.type==="Identifier"?d.name:d.type==="AssignmentPattern"&&((A=d.left)==null?void 0:A.type)==="Identifier"?d.left.name+"?":d.type==="RestElement"&&((M=d.argument)==null?void 0:M.type)==="Identifier"?"..."+d.argument.name:"?"}),_=((de=(fe=t.loc)==null?void 0:fe.start)==null?void 0:de.line)??0,w=((pe=(me=t.loc)==null?void 0:me.end)==null?void 0:pe.line)??0;n.functions.push({name:ae,params:O.join(","),startLine:_,endLine:w,description:L})}}}}});for(const[a,t]of f){const i=new Set;for(const m of $.keys())if($.get(m)===a&&u.has(m))for(const b of u.get(m))i.add(b);n.imports.push({module:a,members:Array.from(t),usedIn:Array.from(i)})}const o=new Set;for(const a of n.functions)o.add(a.name);for(const a of n.classes)for(const t of a.methods)o.add(t.name),o.add(`${a.name}.${t.name}`);const y=new Set($.keys()),l=new Map;ve(c,{CallExpression(a){var m,b;const t=a.node;let i=null;if(t.callee.type==="Identifier")i=t.callee.name;else if(t.callee.type==="MemberExpression"&&((m=t.callee.property)==null?void 0:m.type)==="Identifier"){const x=((b=t.callee.object)==null?void 0:b.type)==="Identifier"?t.callee.object.name:void 0,R=t.callee.property.name;x&&y.has(x)?i=`${x}.${R}`:i=R}if(i){const x=h(a);if(x&&x!==i){const R=o.has(i),C=y.has(i)||i.includes(".")&&y.has(i.split(".")[0]);(R||C)&&(l.has(x)||l.set(x,new Set),l.get(x).add(i))}}}}),n.callGraph={};for(const[a,t]of l)n.callGraph[a]=Array.from(t);return n.isPureType=yn(c),n}function yn(e){let r=!1;for(const n of e.program.body){switch(n.type){case"TSTypeAliasDeclaration":case"TSInterfaceDeclaration":case"TSEnumDeclaration":break;case"ImportDeclaration":n.importKind!=="type"&&n.specifiers.some(c=>c.type==="ImportSpecifier"?c.importKind!=="type":!0)&&n.specifiers.length>0&&(r=!0);break;case"ExportNamedDeclaration":if(n.exportKind==="type")break;if(n.declaration){const s=n.declaration.type;s!=="TSTypeAliasDeclaration"&&s!=="TSInterfaceDeclaration"&&(r=!0)}else n.specifiers&&n.specifiers.length>0&&n.specifiers.some(c=>c.type==="ExportSpecifier"?c.exportKind!=="type":!0)&&(r=!0);break;case"ExportDefaultDeclaration":r=!0;break;case"ExportAllDeclaration":n.exportKind!=="type"&&(r=!0);break;default:r=!0;break}if(r)break}return!r}function gn(e,r){const n=[];let s=`/*@AI ${r}`;e.description&&(s+=` - ${e.description.slice(0,50)}`),n.push(s);for(const c of e.imports){const f=Array.isArray(c.members)?c.members.join(","):"";let $=`<${c.module}:${f}`;Array.isArray(c.usedIn)&&c.usedIn.length>0&&($+=` ->${c.usedIn.join(",")}`),n.push($)}for(const c of e.classes){let f=c.name;c.superClass&&(f+=`:${c.superClass}`),f+=` ${c.startLine}-${c.endLine}`,c.description&&(f+=` ${c.description}`),n.push(f);for(const $ of c.methods){const u=$.static?" +":" .",p=$.kind==="get"?"get:":$.kind==="set"?"set:":"";let h=`${u}${p}${$.name}(${$.params}) ${$.line}`;$.description&&(h+=` ${$.description}`),n.push(h)}}for(const c of e.functions){let f=`${c.name}(${c.params}) ${c.startLine}-${c.endLine}`;c.description&&(f+=` ${c.description}`),n.push(f)}for(const c of e.constants){let f=`${c.name} ${c.line}`;c.description&&(f+=` ${c.description}`),n.push(f)}return n.push("@AI*/"),n.join(`
32
- `)}function hn(e){let r=e;return r=r.replace(/\/\*@AI[\s\S]*?@AI\*\/\s*/g,""),r=r.replace(/\/\*\*[\s\S]*?@ai-context-end[\s\S]*?\*\/\s*/g,""),r=r.replace(/^\/\*\*[\s\S]*?\*\/\s*\n?/,""),r}function Oe(e,r){var s,c,f;const n=[`@FNMAP ${g.basename(e)}/`];for(const{relativePath:$,info:u}of r){let h=`#${g.basename($)}`;u.description&&(h+=` ${u.description.slice(0,50)}`),n.push(h);for(const o of u.imports){const y=Array.isArray(o.members)?o.members.join(","):"";n.push(` <${o.module}:${y}`)}for(const o of u.classes){let y=` ${o.name}`;o.superClass&&(y+=`:${o.superClass}`),y+=` ${o.startLine}-${o.endLine}`,o.description&&(y+=` ${o.description}`),n.push(y);for(const l of o.methods){const I=l.static?" +":" .",v=l.kind==="get"?"get:":l.kind==="set"?"set:":"";let a=`${I}${v}${l.name}(${l.params}) ${l.line}`;l.description&&(a+=` ${l.description}`);const t=`${o.name}.${l.name}`,i=((s=u.callGraph)==null?void 0:s[t])??((c=u.callGraph)==null?void 0:c[l.name]);Array.isArray(i)&&i.length>0&&(a+=` →${i.join(",")}`),n.push(a)}}for(const o of u.functions){let y=` ${o.name}(${o.params}) ${o.startLine}-${o.endLine}`;o.description&&(y+=` ${o.description}`);const l=(f=u.callGraph)==null?void 0:f[o.name];Array.isArray(l)&&l.length>0&&(y+=` →${l.join(",")}`),n.push(y)}for(const o of u.constants){let y=` ${o.name} ${o.line}`;o.description&&(y+=` ${o.description}`),n.push(y)}}return n.push("@FNMAP"),n.join(`
33
- `)}function Xe(e,r){const n=["flowchart TD"],s=o=>"id_"+o.replace(/[^a-zA-Z0-9]/g,y=>`_${y.charCodeAt(0)}_`),c=o=>o.replace(/"/g,"#quot;"),f=r.functions.map(o=>o.name),$=[];for(const o of r.classes)for(const y of o.methods)$.push(`${o.name}.${y.name}`);const u=[...f,...$];if(u.length===0)return null;const p=g.basename(e,g.extname(e));n.push(` subgraph ${s(p)}["${p}"]`);for(const o of u)n.push(` ${s(o)}["${c(o)}"]`);n.push(" end");const h=r.callGraph??{};for(const[o,y]of Object.entries(h))if(Array.isArray(y)){for(const l of y)if(u.includes(l)||l.includes(".")){const I=u.includes(l)?l:l.split(".").pop();(u.includes(l)||u.some(v=>v.endsWith(I)))&&n.push(` ${s(o)} --> ${s(l)}`)}}return n.join(`
34
- `)}function He(e,r){const n=["flowchart TD"],s=p=>"id_"+p.replace(/[^a-zA-Z0-9]/g,h=>`_${h.charCodeAt(0)}_`),c=p=>p.replace(/"/g,"#quot;"),f=new Map,$=[];for(const{relativePath:p,info:h}of r){const o=g.basename(p,g.extname(p)),y=h.functions.map(a=>a.name),l=[];for(const a of h.classes)for(const t of a.methods)l.push(`${a.name}.${t.name}`);const I=[...y,...l];f.set(p,{fileName:o,functions:I});const v=h.callGraph??{};for(const[a,t]of Object.entries(v))if(Array.isArray(t))for(const i of t)$.push({file:p,fileName:o,caller:a,callee:i})}for(const[,{fileName:p,functions:h}]of f)if(h.length!==0){n.push(` subgraph ${s(p)}["${c(p)}"]`);for(const o of h)n.push(` ${s(p)}_${s(o)}["${c(o)}"]`);n.push(" end")}const u=new Set;for(const{fileName:p,caller:h,callee:o}of $){const y=`${s(p)}_${s(h)}`;let l=null;for(const[,{fileName:I,functions:v}]of f)if(v.includes(o)){l=`${s(I)}_${s(o)}`;break}if(!l){const I=[...f.keys()].find(v=>{var a;return((a=f.get(v))==null?void 0:a.fileName)===p});if(I){const v=f.get(I);v!=null&&v.functions.includes(o)&&(l=`${s(p)}_${s(o)}`)}}if(l){const I=`${y}-->${l}`;u.has(I)||(n.push(` ${y} --> ${l}`),u.add(I))}}return n.join(`
35
- `)}function $n(e,r){const n=(r==null?void 0:r.filePath)??null;try{const s=Ge(e,n);return s?ke(s)?{success:!1,error:s.parseError,errorType:s.errorType,loc:s.loc}:{success:!0,info:s}:{success:!1,error:"Analysis returned null / 分析返回空值",errorType:z.PARSE_ERROR}}catch(s){return{success:!1,error:`Failed to process code / 处理代码失败: ${s.message}`,errorType:z.PARSE_ERROR}}}function Qe(e){const r=ze(e);if(!r.valid)return{success:!1,error:r.error,errorType:r.errorType??z.VALIDATION_ERROR};try{const n=F.readFileSync(e,"utf-8"),s=Ge(n,e);return s?ke(s)?{success:!1,error:s.parseError,errorType:s.errorType,loc:s.loc}:{success:!0,info:s}:{success:!1,error:"Analysis returned null / 分析返回空值",errorType:z.PARSE_ERROR}}catch(n){const s=n;return{success:!1,error:Se(z.FILE_READ_ERROR,"Failed to read or process file / 读取或处理文件失败",{file:e,suggestion:s.message}),errorType:z.FILE_READ_ERROR}}}const qe=`
27
+ $ fnmap --hooks Setup Claude Code hooks
28
+ `),ve}function Te(){return ve||Ve()}const xt={get opts(){return Te().opts.bind(Te())},get args(){return Te().args},get parse(){return Te().parse.bind(Te())}};function tt(e){const t=[".fnmaprc",".fnmaprc.json"];for(const s of t){const i=$.join(e,s);if(A.existsSync(i))try{const f=A.readFileSync(i,"utf-8");if(!f.trim()){x.warn(`Config file is empty: ${s}. Using default config / 配置文件为空,使用默认配置`);continue}let E;try{E=JSON.parse(f)}catch(m){const g=m,o=Ae(U.CONFIG_ERROR,`Failed to parse config file: ${s} / 配置文件解析失败`,{file:i,line:g.lineNumber,column:g.columnNumber,suggestion:"Check JSON syntax, ensure proper quotes and commas / 检查 JSON 语法,确保引号和逗号正确"});x.warn(o);continue}const c=Ge(E);if(!c.valid){x.warn(`Invalid config in ${s}: ${c.error}`);continue}return{config:E,source:s}}catch(f){const E=f,c=Ae(U.FILE_READ_ERROR,`Failed to read config file: ${s} / 配置文件读取失败`,{file:i,suggestion:E.message});x.warn(c)}}const n=$.join(e,"package.json");if(A.existsSync(n))try{const s=JSON.parse(A.readFileSync(n,"utf-8"));if(s.fnmap){const i=Ge(s.fnmap);if(!i.valid)x.warn(`Invalid fnmap config in package.json: ${i.error}`);else return{config:s.fnmap,source:"package.json#fnmap"}}}catch{}return{config:null,source:null}}function nt(e){return e?{...Ue,...e,exclude:[...e.exclude??[]]}:Ue}function Ke(e){return e.endsWith(".d.ts")||e.endsWith(".d.tsx")||e.endsWith(".d.mts")}function Ct(e){try{return _e.execSync("git rev-parse --show-toplevel",{cwd:e,encoding:"utf-8"}).trim()}catch{return null}}function st(e,t=!1){const n=[];try{const s=Ct(e);if(!s)return[];let i;if(t)i=_e.execSync("git diff --cached --name-only --diff-filter=ACMR",{cwd:e,encoding:"utf-8"});else{const c=_e.execSync("git diff --cached --name-only --diff-filter=ACMR",{cwd:e,encoding:"utf-8"}),m=_e.execSync("git diff --name-only --diff-filter=ACMR",{cwd:e,encoding:"utf-8"}),g=_e.execSync("git ls-files --others --exclude-standard",{cwd:e,encoding:"utf-8"});i=`${c}
29
+ ${m}
30
+ ${g}`}const f=i.split(`
31
+ `).map(c=>c.trim()).filter(Boolean).filter(c=>{const m=$.extname(c);return Le.includes(m)&&!Ke(c)}),E=[...new Set(f)];for(const c of E){const m=$.resolve(s,c);A.existsSync(m)&&m.startsWith($.resolve(e))&&n.push(m)}}catch{return[]}return n}function bt(e){const t=[];if(!A.existsSync(e))return t;try{const n=A.readdirSync(e,{withFileTypes:!0});for(const s of n)if(s.isFile()){const i=$.extname(s.name);Le.includes(i)&&!Ke(s.name)&&t.push($.join(e,s.name))}}catch{return t}return t}function Ne(e,t=e,n=Be,s=0,i=new Set){const f=[];if(!A.existsSync(e))return x.warn(`Directory does not exist: ${e} / 目录不存在`),f;if(s>Me)return x.warn(`Max directory depth (${Me}) exceeded: ${e} / 超过最大目录深度`),f;let E;try{E=A.realpathSync(e)}catch(m){const g=m;return x.warn(`Cannot resolve real path: ${e}. Reason: ${g.message} / 无法解析真实路径`),f}if(i.has(E))return x.warn(`Circular reference detected, skipping: ${e} / 检测到循环引用`),f;i.add(E);let c;try{c=A.readdirSync(e,{withFileTypes:!0})}catch(m){const g=m;return g.code==="EACCES"||g.code==="EPERM"?x.warn(`Permission denied: ${e} / 权限不足`):x.warn(`Failed to read directory: ${e}. Reason: ${g.message} / 读取目录失败`),f}for(const m of c)try{const g=$.join(e,m.name);if(m.isDirectory())n.includes(m.name)||f.push(...Ne(g,t,n,s+1,i));else if(m.isFile()){const o=$.extname(m.name);Le.includes(o)&&!Ke(m.name)&&f.push($.relative(t,g))}}catch(g){const o=g;x.warn(`Error processing entry: ${m.name}. Reason: ${o.message} / 处理条目出错`)}return f}function oe(e){if(!e)return"";const n=e.value.split(`
32
+ `).map(s=>s.replace(/^\s*\*\s?/,"").trim());for(const s of n)if(s.startsWith("@description "))return s.slice(13).trim().slice(0,60);for(const s of n)if(s&&!s.startsWith("@")&&!s.startsWith("/"))return s.slice(0,60);return""}function Ce(e,t){if(e.leadingComments&&e.leadingComments.length>0)return e.leadingComments[e.leadingComments.length-1]??null;if(t&&(t.type==="ExportNamedDeclaration"||t.type==="ExportDefaultDeclaration")){const n=t;if(n.leadingComments&&n.leadingComments.length>0)return n.leadingComments[n.leadingComments.length-1]??null}return null}let we=null;function At(){return we||(we=require("@vue/compiler-sfc")),we}const ke=typeof je=="function"?je:je.default;function It(e){const{descriptor:t,errors:n}=At().parse(e,{pad:"line"});if(n.length>0)return null;const s=t.scriptSetup??t.script;return s?{code:s.content,lang:s.lang??"js"}:null}function Tt(e){const t=/<script(?:\s+[^>]*)?>(\s*[\s\S]*?)<\/script>/gi;let n=null,s;for(;(s=t.exec(e))!==null;){const i=s[0],f=s[1]??"",E=/context\s*=\s*["']module["']/.test(i)||/\bmodule\b/.test(i),m=i.match(/lang\s*=\s*["'](ts|typescript)["']/i)?"ts":"js";if(!E)return{code:f,lang:m};n||(n={code:f,lang:m})}return n}function He(e,t){var G,H;if(e==null)return{parseError:"Code content is null or undefined / 代码内容为空",errorType:U.VALIDATION_ERROR};if(typeof e!="string")return{parseError:"Code must be a string / 代码必须是字符串类型",errorType:U.VALIDATION_ERROR};if(!e.trim())return{description:"",imports:[],functions:[],classes:[],constants:[],exports:[],callGraph:{}};const n={description:"",imports:[],functions:[],classes:[],constants:[],exports:[],callGraph:{}},s=e.match(/^\/\*\*[\s\S]*?\*\//);if(s){const r=s[0].split(`
33
+ `).map(a=>a.replace(/^\s*\*\s?/,"").trim()).filter(a=>a&&!a.startsWith("/")&&!a.startsWith("@ai"));for(const a of r)if(a.startsWith("@description ")){n.description=a.slice(13).trim();break}if(!n.description&&r.length>0){const a=r.find(u=>!u.startsWith("@"));a&&(n.description=a)}}const i=t==null?void 0:t.endsWith(".vue"),f=t==null?void 0:t.endsWith(".svelte");let E=e,c="";if(i||f){const d=i?It(E):Tt(E);if(!d)return{parseError:Ae(U.PARSE_ERROR,`Failed to extract script from ${i?"Vue":"Svelte"} SFC / 无法从 SFC 提取 script`,{file:t??void 0}),errorType:U.PARSE_ERROR};E=d.code,c=d.lang}let m;try{const d=t&&(t.endsWith(".ts")||t.endsWith(".tsx")||c==="ts");m=mt.parse(E,{sourceType:"unambiguous",plugins:["jsx","classPrivateProperties","classPrivateMethods",...d?["typescript"]:[]]})}catch(d){const r=d;return{parseError:Ae(U.PARSE_ERROR,`Syntax error: ${r.message} / 语法错误`,{file:t??void 0,line:(G=r.loc)==null?void 0:G.line,column:(H=r.loc)==null?void 0:H.column,suggestion:"Check syntax errors in the file / 检查文件中的语法错误"}),loc:r.loc,errorType:U.PARSE_ERROR}}const g=new Map,o=new Map,p=new Map;function l(d){if(!d)return null;if(d.type==="Identifier")return d.name;if(d.type==="MemberExpression"){const r=d.object,a=d.property;if(r.type==="Identifier"&&a.type==="Identifier")return r.name}return null}function b(d){var a,u,C;let r=d;for(;r;){if(r.node.type==="FunctionDeclaration"){const S=r.node;if(S.id)return S.id.name}if(r.node.type==="ClassMethod"){const S=r.node,h=(a=r.parentPath)==null?void 0:a.parentPath,I=h==null?void 0:h.node,F=((u=I==null?void 0:I.id)==null?void 0:u.name)??"",w=((C=S.key)==null?void 0:C.name)??"";return F?`${F}.${w}`:w}if(r.node.type==="ArrowFunctionExpression"||r.node.type==="FunctionExpression"){const S=r.parent;if((S==null?void 0:S.type)==="VariableDeclarator"){const I=S.id;if(I!=null&&I.name)return I.name}}r=r.parentPath}return null}ke(m,{VariableDeclarator(d){var a,u,C,S;const r=d.node;if(((a=r.init)==null?void 0:a.type)==="CallExpression"&&((u=r.init.callee)==null?void 0:u.type)==="Identifier"&&r.init.callee.name==="require"&&((S=(C=r.init.arguments)==null?void 0:C[0])==null?void 0:S.type)==="StringLiteral"){const h=r.init.arguments[0].value;if(g.has(h)||g.set(h,new Set),r.id.type==="Identifier"){const I=r.id.name;g.get(h).add(I),o.set(I,h),p.set(I,new Set)}else if(r.id.type==="ObjectPattern"){for(const I of r.id.properties)if(I.type==="ObjectProperty"&&I.key.type==="Identifier"){const F=I.value.type==="Identifier"?I.value.name:I.key.name;g.get(h).add(I.key.name),o.set(F,h),p.set(F,new Set)}}}},CallExpression(d){var a,u,C,S,h,I;const r=d.node;if(((a=r.callee)==null?void 0:a.type)==="Identifier"&&r.callee.name==="require"&&((C=(u=r.arguments)==null?void 0:u[0])==null?void 0:C.type)==="StringLiteral"){const F=d.parent;if((F==null?void 0:F.type)==="MemberExpression"&&((S=F.property)==null?void 0:S.type)==="Identifier"){const w=r.arguments[0].value;g.has(w)||g.set(w,new Set),g.get(w).add(F.property.name);const q=(h=d.parentPath)==null?void 0:h.parent;if((q==null?void 0:q.type)==="VariableDeclarator"){const B=q;((I=B.id)==null?void 0:I.type)==="Identifier"&&(o.set(B.id.name,w),p.set(B.id.name,new Set))}}}},ImportDeclaration(d){const r=d.node,a=r.source.value;g.has(a)||g.set(a,new Set);for(const u of r.specifiers){let C,S;if(u.type==="ImportDefaultSpecifier")C="default",S=u.local.name;else if(u.type==="ImportNamespaceSpecifier")C="*",S=u.local.name;else if(u.type==="ImportSpecifier"){const h=u.imported;C=h.type==="Identifier"?h.name:h.value,S=u.local.name}C&&S&&(g.get(a).add(C),o.set(S,a),p.set(S,new Set))}}}),ke(m,{Identifier(d){const r=d.node.name;if(p.has(r)){const a=d.parent;if((a==null?void 0:a.type)==="VariableDeclarator"&&a.id===d.node||(a==null?void 0:a.type)==="ImportSpecifier"||(a==null?void 0:a.type)==="ImportDefaultSpecifier")return;const u=b(d);u&&p.get(r).add(u)}},FunctionDeclaration(d){var I,F,w,q,B;if(d.parent.type==="ExportDefaultDeclaration")return;const r=d.node,a=((I=r.id)==null?void 0:I.name)??"[anonymous]",u=r.params.map(M=>{var Y,Z;return M.type==="Identifier"?M.name:M.type==="AssignmentPattern"&&((Y=M.left)==null?void 0:Y.type)==="Identifier"?M.left.name+"?":M.type==="RestElement"&&((Z=M.argument)==null?void 0:Z.type)==="Identifier"?"..."+M.argument.name:"?"}),C=((w=(F=r.loc)==null?void 0:F.start)==null?void 0:w.line)??0,S=((B=(q=r.loc)==null?void 0:q.end)==null?void 0:B.line)??0,h=oe(Ce(r,d.parent));n.functions.push({name:a,params:u.join(","),startLine:C,endLine:S,description:h})},ClassDeclaration(d){var F,w,q,B,M,Y,Z,re,ie;if(d.parent.type==="ExportDefaultDeclaration")return;const r=d.node,a=((F=r.id)==null?void 0:F.name)??"[anonymous]",u=((q=(w=r.loc)==null?void 0:w.start)==null?void 0:q.line)??0,C=((M=(B=r.loc)==null?void 0:B.end)==null?void 0:M.line)??0,S=l(r.superClass),h=oe(Ce(r,d.parent)),I=[];if((Y=r.body)!=null&&Y.body){for(const V of r.body.body)if(V.type==="ClassMethod"){const le=((Z=V.key)==null?void 0:Z.type)==="Identifier"?V.key.name:"[computed]",fe=V.params.map(ee=>{var ce;return ee.type==="Identifier"?ee.name:ee.type==="AssignmentPattern"&&((ce=ee.left)==null?void 0:ce.type)==="Identifier"?ee.left.name+"?":"?"}),de=((ie=(re=V.loc)==null?void 0:re.start)==null?void 0:ie.line)??0;let ae="";const te=V.leadingComments;te&&te.length>0&&(ae=oe(te[te.length-1])),I.push({name:le,params:fe.join(","),line:de,static:V.static,kind:V.kind,description:ae})}}n.classes.push({name:a,superClass:S,startLine:u,endLine:C,methods:I,description:h})},VariableDeclaration(d){var C,S,h,I,F,w,q,B,M,Y,Z,re,ie,V,le,fe,de,ae,te,ee,ce,me,ue,ge,ye,he,$e,pe,J,L,X,z,Q;const r=d.parent.type;if(r!=="Program"&&r!=="ExportNamedDeclaration")return;const a=d.node,u=oe(Ce(a,d.parent));for(const k of a.declarations){const R=((C=k.id)==null?void 0:C.type)==="Identifier"?k.id.name:void 0;if(R){if(((S=k.init)==null?void 0:S.type)==="ArrowFunctionExpression"||((h=k.init)==null?void 0:h.type)==="FunctionExpression"){const T=k.init.params.map(D=>{var j,P;return D.type==="Identifier"?D.name:D.type==="AssignmentPattern"&&((j=D.left)==null?void 0:j.type)==="Identifier"?D.left.name+"?":D.type==="RestElement"&&((P=D.argument)==null?void 0:P.type)==="Identifier"?"..."+D.argument.name:"?"}),ne=((F=(I=a.loc)==null?void 0:I.start)==null?void 0:F.line)??0,K=((q=(w=a.loc)==null?void 0:w.end)==null?void 0:q.line)??0;n.functions.push({name:R,params:T.join(","),startLine:ne,endLine:K,description:u});continue}if(((B=k.init)==null?void 0:B.type)==="ClassExpression"){const O=k.init,T=((Y=(M=a.loc)==null?void 0:M.start)==null?void 0:Y.line)??0,ne=((re=(Z=a.loc)==null?void 0:Z.end)==null?void 0:re.line)??0,K=l(O.superClass),D=[];if((ie=O.body)!=null&&ie.body){for(const j of O.body.body)if(j.type==="ClassMethod"){const P=((V=j.key)==null?void 0:V.type)==="Identifier"?j.key.name:"[computed]",W=j.params.map(Ie=>{var ze;return Ie.type==="Identifier"?Ie.name:Ie.type==="AssignmentPattern"&&((ze=Ie.left)==null?void 0:ze.type)==="Identifier"?Ie.left.name+"?":"?"}),se=((fe=(le=j.loc)==null?void 0:le.start)==null?void 0:fe.line)??0;let Ee="";const Re=j.leadingComments;Re&&Re.length>0&&(Ee=oe(Re[Re.length-1])),D.push({name:P,params:W.join(","),line:se,static:j.static,kind:j.kind,description:Ee})}}n.classes.push({name:R,superClass:K,startLine:T,endLine:ne,methods:D,description:u});continue}if(((de=k.init)==null?void 0:de.type)==="ObjectExpression"){const O=k.init;for(const T of O.properties)if(T.type==="ObjectMethod"){const ne=((ae=T.key)==null?void 0:ae.type)==="Identifier"?`${R}.${T.key.name}`:`${R}.[computed]`,K=T.params.map(W=>{var se,Ee;return W.type==="Identifier"?W.name:W.type==="AssignmentPattern"&&((se=W.left)==null?void 0:se.type)==="Identifier"?W.left.name+"?":W.type==="RestElement"&&((Ee=W.argument)==null?void 0:Ee.type)==="Identifier"?"..."+W.argument.name:"?"}),D=((ee=(te=T.loc)==null?void 0:te.start)==null?void 0:ee.line)??0,j=((me=(ce=T.loc)==null?void 0:ce.end)==null?void 0:me.line)??0;let P="";T.leadingComments&&T.leadingComments.length>0&&(P=oe(T.leadingComments[T.leadingComments.length-1])),n.functions.push({name:ne,params:K.join(","),startLine:D,endLine:j,description:P})}else if(T.type==="ObjectProperty"&&((ue=T.key)==null?void 0:ue.type)==="Identifier"&&(((ge=T.value)==null?void 0:ge.type)==="ArrowFunctionExpression"||((ye=T.value)==null?void 0:ye.type)==="FunctionExpression")){const ne=T.value,K=`${R}.${T.key.name}`,D=ne.params.map(se=>{var Ee,Re;return se.type==="Identifier"?se.name:se.type==="AssignmentPattern"&&((Ee=se.left)==null?void 0:Ee.type)==="Identifier"?se.left.name+"?":se.type==="RestElement"&&((Re=se.argument)==null?void 0:Re.type)==="Identifier"?"..."+se.argument.name:"?"}),j=(($e=(he=T.loc)==null?void 0:he.start)==null?void 0:$e.line)??0,P=((J=(pe=T.loc)==null?void 0:pe.end)==null?void 0:J.line)??0;let W="";T.leadingComments&&T.leadingComments.length>0&&(W=oe(T.leadingComments[T.leadingComments.length-1])),n.functions.push({name:K,params:D.join(","),startLine:j,endLine:P,description:W})}}if(a.kind==="const"&&!(((L=k.init)==null?void 0:L.type)==="CallExpression"&&((X=k.init.callee)==null?void 0:X.type)==="Identifier"&&k.init.callee.name==="require")){const T=((Q=(z=a.loc)==null?void 0:z.start)==null?void 0:Q.line)??0;n.constants.push({name:R,line:T,description:u})}}}},ExportDefaultDeclaration(d){var C,S,h,I,F,w,q,B,M,Y,Z,re,ie,V,le,fe,de,ae,te,ee,ce,me,ue,ge,ye,he,$e,pe,J;const r=d.node,a=r.declaration,u=oe(Ce(r,d.parent));if(a.type==="FunctionDeclaration"){const L=a,X=((C=L.id)==null?void 0:C.name)??"[default]",z=L.params.map(R=>{var O,T;return R.type==="Identifier"?R.name:R.type==="AssignmentPattern"&&((O=R.left)==null?void 0:O.type)==="Identifier"?R.left.name+"?":R.type==="RestElement"&&((T=R.argument)==null?void 0:T.type)==="Identifier"?"..."+R.argument.name:"?"}),Q=((h=(S=r.loc)==null?void 0:S.start)==null?void 0:h.line)??0,k=((F=(I=r.loc)==null?void 0:I.end)==null?void 0:F.line)??0;n.functions.push({name:X,params:z.join(","),startLine:Q,endLine:k,description:u});return}if(a.type==="ClassDeclaration"){const L=a,X=((w=L.id)==null?void 0:w.name)??"[default]",z=((B=(q=r.loc)==null?void 0:q.start)==null?void 0:B.line)??0,Q=((Y=(M=r.loc)==null?void 0:M.end)==null?void 0:Y.line)??0,k=l(L.superClass),R=[];if((Z=L.body)!=null&&Z.body){for(const O of L.body.body)if(O.type==="ClassMethod"){const T=((re=O.key)==null?void 0:re.type)==="Identifier"?O.key.name:"[computed]",ne=O.params.map(P=>{var W;return P.type==="Identifier"?P.name:P.type==="AssignmentPattern"&&((W=P.left)==null?void 0:W.type)==="Identifier"?P.left.name+"?":"?"}),K=((V=(ie=O.loc)==null?void 0:ie.start)==null?void 0:V.line)??0;let D="";const j=O.leadingComments;j&&j.length>0&&(D=oe(j[j.length-1])),R.push({name:T,params:ne.join(","),line:K,static:O.static,kind:O.kind,description:D})}}n.classes.push({name:X,superClass:k,startLine:z,endLine:Q,methods:R,description:u});return}if(a.type==="ArrowFunctionExpression"||a.type==="FunctionExpression"){const L=a,X=L.type==="FunctionExpression"&&((le=L.id)!=null&&le.name)?L.id.name:"[default]",z=L.params.map(R=>{var O,T;return R.type==="Identifier"?R.name:R.type==="AssignmentPattern"&&((O=R.left)==null?void 0:O.type)==="Identifier"?R.left.name+"?":R.type==="RestElement"&&((T=R.argument)==null?void 0:T.type)==="Identifier"?"..."+R.argument.name:"?"}),Q=((de=(fe=r.loc)==null?void 0:fe.start)==null?void 0:de.line)??0,k=((te=(ae=r.loc)==null?void 0:ae.end)==null?void 0:te.line)??0;n.functions.push({name:X,params:z.join(","),startLine:Q,endLine:k,description:u});return}if(a.type==="ClassExpression"){const L=a,X=((ee=L.id)==null?void 0:ee.name)??"[default]",z=((me=(ce=r.loc)==null?void 0:ce.start)==null?void 0:me.line)??0,Q=((ge=(ue=r.loc)==null?void 0:ue.end)==null?void 0:ge.line)??0,k=((ye=L.superClass)==null?void 0:ye.type)==="Identifier"?L.superClass.name:null,R=[];if((he=L.body)!=null&&he.body){for(const O of L.body.body)if(O.type==="ClassMethod"){const T=(($e=O.key)==null?void 0:$e.type)==="Identifier"?O.key.name:"[computed]",ne=O.params.map(P=>{var W;return P.type==="Identifier"?P.name:P.type==="AssignmentPattern"&&((W=P.left)==null?void 0:W.type)==="Identifier"?P.left.name+"?":"?"}),K=((J=(pe=O.loc)==null?void 0:pe.start)==null?void 0:J.line)??0;let D="";const j=O.leadingComments;j&&j.length>0&&(D=oe(j[j.length-1])),R.push({name:T,params:ne.join(","),line:K,static:O.static,kind:O.kind,description:D})}}n.classes.push({name:X,superClass:k,startLine:z,endLine:Q,methods:R,description:u})}},AssignmentExpression(d){var S,h,I,F,w,q,B,M,Y,Z,re,ie,V,le,fe,de,ae,te,ee,ce,me,ue,ge,ye,he,$e;const r=d.node;if(d.parent.type!=="ExpressionStatement")return;const a=(S=d.parentPath)==null?void 0:S.parent;if((a==null?void 0:a.type)!=="Program")return;const u=r.left,C=r.right;if(u.type==="MemberExpression"&&((h=u.object)==null?void 0:h.type)==="Identifier"&&u.object.name==="module"&&((I=u.property)==null?void 0:I.type)==="Identifier"&&u.property.name==="exports"){const pe=oe(Ce(d.parent,a));if(C.type==="FunctionExpression"||C.type==="ArrowFunctionExpression"){const J=C,L=C.type==="FunctionExpression"&&((F=C.id)!=null&&F.name)?C.id.name:"[exports]",X=J.params.map(k=>{var R,O;return k.type==="Identifier"?k.name:k.type==="AssignmentPattern"&&((R=k.left)==null?void 0:R.type)==="Identifier"?k.left.name+"?":k.type==="RestElement"&&((O=k.argument)==null?void 0:O.type)==="Identifier"?"..."+k.argument.name:"?"}),z=((q=(w=r.loc)==null?void 0:w.start)==null?void 0:q.line)??0,Q=((M=(B=r.loc)==null?void 0:B.end)==null?void 0:M.line)??0;n.functions.push({name:L,params:X.join(","),startLine:z,endLine:Q,description:pe});return}if(C.type==="ClassExpression"){const J=C,L=((Y=J.id)==null?void 0:Y.name)??"[exports]",X=((re=(Z=r.loc)==null?void 0:Z.start)==null?void 0:re.line)??0,z=((V=(ie=r.loc)==null?void 0:ie.end)==null?void 0:V.line)??0,Q=l(J.superClass),k=[];if((le=J.body)!=null&&le.body){for(const R of J.body.body)if(R.type==="ClassMethod"){const O=((fe=R.key)==null?void 0:fe.type)==="Identifier"?R.key.name:"[computed]",T=R.params.map(K=>{var D;return K.type==="Identifier"?K.name:K.type==="AssignmentPattern"&&((D=K.left)==null?void 0:D.type)==="Identifier"?K.left.name+"?":"?"}),ne=((ae=(de=R.loc)==null?void 0:de.start)==null?void 0:ae.line)??0;k.push({name:O,params:T.join(","),line:ne,static:R.static,kind:R.kind,description:""})}}n.classes.push({name:L,superClass:Q,startLine:X,endLine:z,methods:k,description:pe});return}}if(u.type==="MemberExpression"&&((te=u.property)==null?void 0:te.type)==="Identifier"){const pe=u.property.name;let J=!1;if(((ee=u.object)==null?void 0:ee.type)==="Identifier"&&u.object.name==="exports"&&(J=!0),((ce=u.object)==null?void 0:ce.type)==="MemberExpression"&&((me=u.object.object)==null?void 0:me.type)==="Identifier"&&u.object.object.name==="module"&&((ue=u.object.property)==null?void 0:ue.type)==="Identifier"&&u.object.property.name==="exports"&&(J=!0),J){const L=oe(Ce(d.parent,a));if(C.type==="FunctionExpression"||C.type==="ArrowFunctionExpression"){const z=C.params.map(R=>{var O,T;return R.type==="Identifier"?R.name:R.type==="AssignmentPattern"&&((O=R.left)==null?void 0:O.type)==="Identifier"?R.left.name+"?":R.type==="RestElement"&&((T=R.argument)==null?void 0:T.type)==="Identifier"?"..."+R.argument.name:"?"}),Q=((ye=(ge=r.loc)==null?void 0:ge.start)==null?void 0:ye.line)??0,k=(($e=(he=r.loc)==null?void 0:he.end)==null?void 0:$e.line)??0;n.functions.push({name:pe,params:z.join(","),startLine:Q,endLine:k,description:L})}}}}});for(const[d,r]of g){const a=new Set;for(const u of o.keys())if(o.get(u)===d&&p.has(u))for(const C of p.get(u))a.add(C);n.imports.push({module:d,members:Array.from(r),usedIn:Array.from(a)})}const _=new Set;for(const d of n.functions)_.add(d.name);for(const d of n.classes)for(const r of d.methods)_.add(r.name),_.add(`${d.name}.${r.name}`);const v=new Set(o.keys()),N=new Map;ke(m,{CallExpression(d){var u,C;const r=d.node;let a=null;if(r.callee.type==="Identifier")a=r.callee.name;else if(r.callee.type==="MemberExpression"&&((u=r.callee.property)==null?void 0:u.type)==="Identifier"){const S=((C=r.callee.object)==null?void 0:C.type)==="Identifier"?r.callee.object.name:void 0,h=r.callee.property.name;S&&v.has(S)?a=`${S}.${h}`:a=h}if(a){const S=b(d);if(S&&S!==a){const h=_.has(a),I=v.has(a)||a.includes(".")&&v.has(a.split(".")[0]);(h||I)&&(N.has(S)||N.set(S,new Set),N.get(S).add(a))}}}}),n.callGraph={};for(const[d,r]of N)n.callGraph[d]=Array.from(r);return ke(m,{ExportNamedDeclaration(d){var C,S;const r=d.node,a=((S=(C=r.loc)==null?void 0:C.start)==null?void 0:S.line)??0,u=r.exportKind==="type";if(r.specifiers&&r.specifiers.length>0){for(const h of r.specifiers)if(h.type==="ExportSpecifier"){const I=h.exported.type==="Identifier"?h.exported.name:h.exported.value,F=h.local.name,w=u||h.exportKind==="type";n.exports.push({name:I,localName:F!==I?F:void 0,line:a,kind:w?"type":"value"})}return}if(r.declaration){const h=r.declaration;if(h.type==="FunctionDeclaration"&&h.id)n.exports.push({name:h.id.name,line:a,kind:"value"});else if(h.type==="ClassDeclaration"&&h.id)n.exports.push({name:h.id.name,line:a,kind:"value"});else if(h.type==="VariableDeclaration")for(const I of h.declarations)I.id.type==="Identifier"&&n.exports.push({name:I.id.name,line:a,kind:"value"});else(h.type==="TSTypeAliasDeclaration"||h.type==="TSInterfaceDeclaration")&&h.id&&n.exports.push({name:h.id.name,line:a,kind:"type"})}},ExportDefaultDeclaration(d){var S,h;const r=d.node,a=((h=(S=r.loc)==null?void 0:S.start)==null?void 0:h.line)??0,u=r.declaration;let C;u.type==="FunctionDeclaration"&&u.id||u.type==="ClassDeclaration"&&u.id?C=u.id.name:u.type==="Identifier"&&(C=u.name),n.exports.push({name:"default",localName:C,line:a,kind:"default"})}}),n.isPureType=Ot(m),n}function Ot(e){let t=!1;for(const n of e.program.body){switch(n.type){case"TSTypeAliasDeclaration":case"TSInterfaceDeclaration":case"TSEnumDeclaration":break;case"ImportDeclaration":n.importKind!=="type"&&n.specifiers.some(i=>i.type==="ImportSpecifier"?i.importKind!=="type":!0)&&n.specifiers.length>0&&(t=!0);break;case"ExportNamedDeclaration":if(n.exportKind==="type")break;if(n.declaration){const s=n.declaration.type;s!=="TSTypeAliasDeclaration"&&s!=="TSInterfaceDeclaration"&&(t=!0)}else n.specifiers&&n.specifiers.length>0&&n.specifiers.some(i=>i.type==="ExportSpecifier"?i.exportKind!=="type":!0)&&(t=!0);break;case"ExportDefaultDeclaration":t=!0;break;case"ExportAllDeclaration":n.exportKind!=="type"&&(t=!0);break;default:t=!0;break}if(t)break}return!t}function _t(e,t){const n=[];let s=`/*@AI ${t}`;e.description&&(s+=` - ${e.description.slice(0,50)}`),n.push(s);for(const i of e.imports){const f=Array.isArray(i.members)?i.members.join(","):"";let E=`<${i.module}:${f}`;Array.isArray(i.usedIn)&&i.usedIn.length>0&&(E+=` ->${i.usedIn.join(",")}`),n.push(E)}for(const i of e.classes){let f=i.name;i.superClass&&(f+=`:${i.superClass}`),f+=` ${i.startLine}-${i.endLine}`,i.description&&(f+=` ${i.description}`),n.push(f);for(const E of i.methods){const c=E.static?" +":" .",m=E.kind==="get"?"get:":E.kind==="set"?"set:":"";let g=`${c}${m}${E.name}(${E.params}) ${E.line}`;E.description&&(g+=` ${E.description}`),n.push(g)}}for(const i of e.functions){let f=`${i.name}(${i.params}) ${i.startLine}-${i.endLine}`;i.description&&(f+=` ${i.description}`),n.push(f)}for(const i of e.constants){let f=`${i.name} ${i.line}`;i.description&&(f+=` ${i.description}`),n.push(f)}return n.push("@AI*/"),n.join(`
34
+ `)}function vt(e){let t=e;return t=t.replace(/\/\*@AI[\s\S]*?@AI\*\/\s*/g,""),t=t.replace(/\/\*\*[\s\S]*?@ai-context-end[\s\S]*?\*\/\s*/g,""),t=t.replace(/^\/\*\*[\s\S]*?\*\/\s*\n?/,""),t}function qe(e,t){var s,i,f;const n=[`@FNMAP ${$.basename(e)}/`];for(const{relativePath:E,info:c}of t){let g=`#${$.basename(E)}`;c.description&&(g+=` ${c.description.slice(0,50)}`),n.push(g);for(const o of c.imports){const p=Array.isArray(o.members)?o.members.join(","):"";n.push(` <${o.module}:${p}`)}for(const o of c.classes){let p=` ${o.name}`;o.superClass&&(p+=`:${o.superClass}`),p+=` ${o.startLine}-${o.endLine}`,o.description&&(p+=` ${o.description}`),n.push(p);for(const l of o.methods){const b=l.static?" +":" .",_=l.kind==="get"?"get:":l.kind==="set"?"set:":"";let v=`${b}${_}${l.name}(${l.params}) ${l.line}`;l.description&&(v+=` ${l.description}`);const N=`${o.name}.${l.name}`,G=((s=c.callGraph)==null?void 0:s[N])??((i=c.callGraph)==null?void 0:i[l.name]);Array.isArray(G)&&G.length>0&&(v+=` →${G.join(",")}`),n.push(v)}}for(const o of c.functions){let p=` ${o.name}(${o.params}) ${o.startLine}-${o.endLine}`;o.description&&(p+=` ${o.description}`);const l=(f=c.callGraph)==null?void 0:f[o.name];Array.isArray(l)&&l.length>0&&(p+=` →${l.join(",")}`),n.push(p)}for(const o of c.constants){let p=` $${o.name} ${o.line}`;o.description&&(p+=` ${o.description}`),n.push(p)}if(c.exports&&c.exports.length>0){const o=[];for(const p of c.exports)p.kind==="default"?o.push(p.localName?`default:${p.localName}`:"default"):p.kind==="type"?o.push(`type:${p.name}`):o.push(p.name);n.push(` >${o.join(",")}`)}}return n.push("@FNMAP"),n.join(`
35
+ `)}function ot(e,t){const n=["flowchart TD"],s=o=>"id_"+o.replace(/[^a-zA-Z0-9]/g,p=>`_${p.charCodeAt(0)}_`),i=o=>o.replace(/"/g,"#quot;"),f=t.functions.map(o=>o.name),E=[];for(const o of t.classes)for(const p of o.methods)E.push(`${o.name}.${p.name}`);const c=[...f,...E];if(c.length===0)return null;const m=$.basename(e,$.extname(e));n.push(` subgraph ${s(m)}["${m}"]`);for(const o of c)n.push(` ${s(o)}["${i(o)}"]`);n.push(" end");const g=t.callGraph??{};for(const[o,p]of Object.entries(g))if(Array.isArray(p)){for(const l of p)if(c.includes(l)||l.includes(".")){const b=c.includes(l)?l:l.split(".").pop();(c.includes(l)||c.some(_=>_.endsWith(b)))&&n.push(` ${s(o)} --> ${s(l)}`)}}return n.join(`
36
+ `)}function rt(e,t){const n=["flowchart TD"],s=m=>"id_"+m.replace(/[^a-zA-Z0-9]/g,g=>`_${g.charCodeAt(0)}_`),i=m=>m.replace(/"/g,"#quot;"),f=new Map,E=[];for(const{relativePath:m,info:g}of t){const o=$.basename(m,$.extname(m)),p=g.functions.map(v=>v.name),l=[];for(const v of g.classes)for(const N of v.methods)l.push(`${v.name}.${N.name}`);const b=[...p,...l];f.set(m,{fileName:o,functions:b});const _=g.callGraph??{};for(const[v,N]of Object.entries(_))if(Array.isArray(N))for(const G of N)E.push({file:m,fileName:o,caller:v,callee:G})}for(const[,{fileName:m,functions:g}]of f)if(g.length!==0){n.push(` subgraph ${s(m)}["${i(m)}"]`);for(const o of g)n.push(` ${s(m)}_${s(o)}["${i(o)}"]`);n.push(" end")}const c=new Set;for(const{fileName:m,caller:g,callee:o}of E){const p=`${s(m)}_${s(g)}`;let l=null;for(const[,{fileName:b,functions:_}]of f)if(_.includes(o)){l=`${s(b)}_${s(o)}`;break}if(!l){const b=[...f.keys()].find(_=>{var v;return((v=f.get(_))==null?void 0:v.fileName)===m});if(b){const _=f.get(b);_!=null&&_.functions.includes(o)&&(l=`${s(m)}_${s(o)}`)}}if(l){const b=`${p}-->${l}`;c.has(b)||(n.push(` ${p} --> ${l}`),c.add(b))}}return n.join(`
37
+ `)}function kt(e,t){const n=(t==null?void 0:t.filePath)??null;try{const s=He(e,n);return s?We(s)?{success:!1,error:s.parseError,errorType:s.errorType,loc:s.loc}:{success:!0,info:s}:{success:!1,error:"Analysis returned null / 分析返回空值",errorType:U.PARSE_ERROR}}catch(s){return{success:!1,error:`Failed to process code / 处理代码失败: ${s.message}`,errorType:U.PARSE_ERROR}}}function it(e){const t=Ze(e);if(!t.valid)return{success:!1,error:t.error,errorType:t.errorType??U.VALIDATION_ERROR};try{const n=A.readFileSync(e,"utf-8"),s=He(n,e);return s?We(s)?{success:!1,error:s.parseError,errorType:s.errorType,loc:s.loc}:{success:!0,info:s}:{success:!1,error:"Analysis returned null / 分析返回空值",errorType:U.PARSE_ERROR}}catch(n){const s=n;return{success:!1,error:Ae(U.FILE_READ_ERROR,"Failed to read or process file / 读取或处理文件失败",{file:e,suggestion:s.message}),errorType:U.FILE_READ_ERROR}}}function Ft(e){const t=$.join(e,"package.json");if(!A.existsSync(t))return null;try{return JSON.parse(A.readFileSync(t,"utf-8"))}catch{return null}}function Nt(e){return e?new Set([...Object.keys(e.dependencies||{}),...Object.keys(e.devDependencies||{})]):new Set}function Lt(e,t){for(const n of t)if(n.endsWith("*")){const s=n.slice(0,-1);try{const i=A.readdirSync(e).filter(f=>f.startsWith(s));if(i.length>0)return i[0]??null}catch{}}else if(A.existsSync($.join(e,n)))return n;return null}function jt(e,t){var n,s;return e?(n=e.devDependencies)!=null&&n[t]?"devDependencies":(s=e.dependencies)!=null&&s[t]?"dependencies":"":""}const wt=[{name:"typescript",depNames:["typescript"],configPatterns:["tsconfig.json"],level:"block"},{name:"eslint",depNames:["eslint"],configPatterns:[".eslintrc*","eslint.config.*"],level:"warn"},{name:"biome",depNames:["@biomejs/biome"],configPatterns:["biome.json","biome.jsonc"],level:"warn"},{name:"prettier",depNames:["prettier"],configPatterns:[".prettierrc*","prettier.config.*"],level:"warn"},{name:"vitest",depNames:["vitest"],configPatterns:[],level:"block"},{name:"jest",depNames:["jest"],configPatterns:["jest.config.*"],level:"block"},{name:"mocha",depNames:["mocha"],configPatterns:[".mocharc*"],level:"block"}],Dt={typescript:`# TypeScript 类型检查
38
+ TS_OUTPUT=$(npx tsc --noEmit 2>&1)
39
+ if [ $? -ne 0 ]; then
40
+ TS_ERRORS=$(echo "$TS_OUTPUT" | head -30)
41
+ BLOCK_ERRORS="$BLOCK_ERRORS\\n[TypeScript 类型错误]\\n$TS_ERRORS"
42
+ fi`,eslint:`# ESLint 检查(仅变更文件)
43
+ LINT_OUTPUT=$(echo "$ALL_CHANGED" | xargs -d '\\n' npx eslint --no-warn 2>&1)
44
+ if [ $? -ne 0 ]; then
45
+ LINT_ERRORS=$(echo "$LINT_OUTPUT" | head -30)
46
+ WARN_MESSAGES="$WARN_MESSAGES\\n[ESLint 问题]\\n$LINT_ERRORS"
47
+ fi`,biome:`# Biome 检查(仅变更文件)
48
+ BIOME_OUTPUT=$(echo "$ALL_CHANGED" | xargs -d '\\n' npx biome check 2>&1)
49
+ if [ $? -ne 0 ]; then
50
+ BIOME_ERRORS=$(echo "$BIOME_OUTPUT" | head -30)
51
+ WARN_MESSAGES="$WARN_MESSAGES\\n[Biome 问题]\\n$BIOME_ERRORS"
52
+ fi`,prettier:`# Prettier 格式检查(仅变更文件)
53
+ PRETTIER_OUTPUT=$(echo "$ALL_CHANGED" | xargs -d '\\n' npx prettier --check 2>&1)
54
+ if [ $? -ne 0 ]; then
55
+ PRETTIER_ERRORS=$(echo "$PRETTIER_OUTPUT" | grep -v '^\\[warn\\]' | head -20)
56
+ WARN_MESSAGES="$WARN_MESSAGES\\n[Prettier 格式问题]\\n$PRETTIER_ERRORS"
57
+ fi`,vitest:`# Vitest 测试
58
+ TEST_OUTPUT=$(npx vitest run 2>&1)
59
+ if [ $? -ne 0 ]; then
60
+ TEST_ERRORS=$(echo "$TEST_OUTPUT" | tail -30)
61
+ BLOCK_ERRORS="$BLOCK_ERRORS\\n[测试失败]\\n$TEST_ERRORS"
62
+ fi`,jest:`# Jest 测试
63
+ TEST_OUTPUT=$(npx jest 2>&1)
64
+ if [ $? -ne 0 ]; then
65
+ TEST_ERRORS=$(echo "$TEST_OUTPUT" | tail -30)
66
+ BLOCK_ERRORS="$BLOCK_ERRORS\\n[测试失败]\\n$TEST_ERRORS"
67
+ fi`,mocha:`# Mocha 测试
68
+ TEST_OUTPUT=$(npx mocha 2>&1)
69
+ if [ $? -ne 0 ]; then
70
+ TEST_ERRORS=$(echo "$TEST_OUTPUT" | tail -30)
71
+ BLOCK_ERRORS="$BLOCK_ERRORS\\n[测试失败]\\n$TEST_ERRORS"
72
+ fi`};function at(e){return`#!/bin/bash
73
+ # Auto-generated by fnmap --hooks
74
+ # 自动代码质量检查脚本 - 由 fnmap 生成,勿手动编辑
36
75
 
37
- ## .fnmap Code Index Format
76
+ cd "\${CLAUDE_PROJECT_DIR:-.}" || exit 0
38
77
 
39
- The \`.fnmap\` file provides a structured code index for quick navigation. Read it before exploring code to locate target files and function line numbers.
78
+ # 检测变更的 JS/TS/Vue 文件
79
+ CHANGED=$(git diff --name-only --diff-filter=ACMR HEAD 2>/dev/null | grep -E '\\.(js|ts|jsx|tsx|vue)$')
80
+ UNTRACKED=$(git ls-files --others --exclude-standard 2>/dev/null | grep -E '\\.(js|ts|jsx|tsx|vue)$')
81
+ ALL_CHANGED=$(printf '%s\\n%s' "$CHANGED" "$UNTRACKED" | sort -u | grep -v '^$')
40
82
 
41
- **Format Reference:**
83
+ [ -z "$ALL_CHANGED" ] && exit 0
42
84
 
43
- - \`#filename.js\` - Filename followed by file description
44
- - \`<module:members\` - Imported module and its members
45
- - \`funcName(params) 10-20 description →callee1,callee2\` - Function signature, line range, description, call graph
46
- - \`ClassName:SuperClass 30-100\` - Class definition with inheritance
47
- - \` .method(params) 35 →callee\` - Instance method (\`.\` prefix)
48
- - \` +staticMethod(params) 40\` - Static method (\`+\` prefix)
49
- - \`CONST_NAME 5\` - Constant definition with line number
85
+ BLOCK_ERRORS=""
86
+ WARN_MESSAGES=""
50
87
 
51
- **Call Graph:** The \`→\` at the end of function/method lines indicates which functions are called (both local and imported), helping you understand code execution flow.
88
+ # fnmap 索引更新
89
+ fnmap --changed 2>/dev/null || true
52
90
 
53
- **Note:** \`.fnmap\` files are auto-maintained by scripts and should not be manually updated.
91
+ ${e.filter(s=>s.detected).map(s=>Dt[s.name]).filter(Boolean).join(`
54
92
 
55
- ## Code Comment Guidelines
93
+ `)}
56
94
 
57
- 1. Every global variable, function, class, and file module must have a **concise comment describing its purpose or functionality** - avoid describing anything else
58
- 2. When updating code, always update related comments to reflect the changes
59
- 3. Prefer encapsulating logic in functions rather than writing flat, sequential code
60
- `,Ve=`
95
+ # 转义 JSON 并输出结果
96
+ escape_json() {
97
+ node -e "let d='';process.stdin.on('data',c=>d+=c);process.stdin.on('end',()=>console.log(JSON.stringify(d)));"
98
+ }
99
+
100
+ if [ -n "$BLOCK_ERRORS" ]; then
101
+ ESCAPED=$(echo -e "$BLOCK_ERRORS" | escape_json)
102
+ echo "{\\"decision\\":\\"block\\",\\"reason\\":$ESCAPED}"
103
+ elif [ -n "$WARN_MESSAGES" ]; then
104
+ ESCAPED=$(echo -e "$WARN_MESSAGES" | escape_json)
105
+ echo "{\\"systemMessage\\":$ESCAPED}"
106
+ fi
107
+ `}const Pt="检查 .fnmap 文件保护...",Mt="quality-check.sh",Ut=`node -e "const j=JSON.parse(require('fs').readFileSync(0,'utf8'));const f=j.tool_input?.file_path||'';if(f.endsWith('.fnmap')){console.log(JSON.stringify({hookSpecificOutput:{hookEventName:'PreToolUse',permissionDecision:'deny',permissionDecisionReason:'.fnmap 文件由脚本自动维护,禁止手动修改。请使用 fnmap --changed 命令更新。'}}));}"`;function ct(e,t){const n=$.join(e,".claude"),s=$.join(n,"hooks"),i=$.join(n,"settings.json"),f=$.join(s,"quality-check.sh");A.mkdirSync(s,{recursive:!0});const E=at(t);A.writeFileSync(f,E);let c={};if(A.existsSync(i))try{c=JSON.parse(A.readFileSync(i,"utf-8"))}catch{c={}}c.hooks||(c.hooks={}),c.hooks.PreToolUse||(c.hooks.PreToolUse=[]),c.hooks.PreToolUse=c.hooks.PreToolUse.filter(m=>{var g;return!((g=m.hooks)!=null&&g.some(o=>{var p;return(p=o.statusMessage)==null?void 0:p.includes("fnmap")}))}),c.hooks.PreToolUse.push({matcher:"Edit|Write",hooks:[{type:"command",command:Ut,statusMessage:Pt}]}),c.hooks.Stop||(c.hooks.Stop=[]),c.hooks.Stop=c.hooks.Stop.filter(m=>{var g;return!((g=m.hooks)!=null&&g.some(o=>{var p;return(p=o.command)==null?void 0:p.includes(Mt)}))}),c.hooks.Stop.push({matcher:"",hooks:[{type:"command",command:"bash .claude/hooks/quality-check.sh",timeout:120,statusMessage:"代码质量检查中..."}]}),A.writeFileSync(i,JSON.stringify(c,null,2))}function Gt(e,t){return new Promise(n=>{e.question(t,s=>{n(s.trim())})})}async function Je(e,t){const n=!t;t||(t=Ye.createInterface({input:process.stdin,output:process.stdout}));try{console.log(`
108
+ ${y.bold}fnmap - Claude Code Hooks Setup${y.reset}`),console.log("=".repeat(50)),console.log(`Detecting project tools...
109
+ `);const s=lt(e);for(const c of s)c.detected?console.log(` ${y.green}✓${y.reset} ${c.name} (${c.source})`):console.log(` ${y.gray}✗ ${c.name} (not found)${y.reset}`);const i=s.filter(c=>c.detected);console.log(`
110
+ Hooks to install:`),console.log(` 1. ${y.bold}[protect]${y.reset} Block AI from editing .fnmap files (PreToolUse)`),console.log(` 2. ${y.bold}[fnmap]${y.reset} Auto-update fnmap index on stop (Stop)`);let f=3;for(const c of i){const m=c.level==="block"?"block on errors":"warn on issues";console.log(` ${f}. ${y.bold}[${c.name}]${y.reset}${" ".repeat(Math.max(1,10-c.name.length))}${c.name} check - ${m} (Stop)`),f++}if((await Gt(t,`
111
+ Install these hooks to .claude/settings.json? (Y/n): `)).toLowerCase()==="n"){console.log("Skipped hooks installation.");return}ct(e,i),console.log(`
112
+ ${y.green}✓${y.reset} Created .claude/hooks/quality-check.sh`),console.log(`${y.green}✓${y.reset} Updated .claude/settings.json`),console.log(`${y.green}✓${y.reset} Hooks installed! Restart Claude Code session to activate.`)}finally{n&&t&&t.close()}}function lt(e){const t=Ft(e),n=Nt(t);return wt.map(s=>{const i=s.depNames.find(E=>n.has(E));if(i){const E=jt(t,i);return{name:s.name,detected:!0,source:E||"dependencies",level:s.level}}const f=Lt(e,s.configPatterns);return f?{name:s.name,detected:!0,source:f,level:s.level}:{name:s.name,detected:!1,source:"",level:s.level}})}const Qe="\n\n## .fnmap Code Index Format\n\nThe `.fnmap` file provides a structured code index for quick navigation. Read it before exploring code to locate target files and function line numbers.\n\n**Format Reference:**\n\n- `#filename.js` - Filename followed by file description\n- `<module:members` - Imported module and its members\n- `funcName(params) 10-20 description →callee1,callee2` - Function signature, line range, description, call graph\n- `ClassName:SuperClass 30-100` - Class definition with inheritance\n- ` .method(params) 35 →callee` - Instance method (`.` prefix)\n- ` +staticMethod(params) 40` - Static method (`+` prefix)\n- `$constName 5` - Constant definition (`$` prefix)\n- `>export1,export2,default` - Exports (`>` prefix, supports `default`, `type:Name`)\n\n**Call Graph:** The `→` at the end of function/method lines indicates which functions are called (both local and imported), helping you understand code execution flow.\n\n**Note:** `.fnmap` files are auto-maintained by scripts and should not be manually updated.\n\n## Code Comment Guidelines\n\n1. Every global variable, function, class, and file module must have a **concise comment describing its purpose or functionality** - avoid describing anything else\n2. When updating code, always update related comments to reflect the changes\n3. Prefer encapsulating logic in functions rather than writing flat, sequential code\n",Xe=`
61
113
  # fnmap generated files
62
114
  .fnmap
63
115
  *.fnmap
64
116
  *.mermaid
65
117
  .fnmap.mermaid
66
- `;function Ce(e,r){return new Promise(n=>{e.question(r,s=>{n(s.trim())})})}function Ze(e,r){let n=0;const s=["node_modules",".git","dist","build",".next","coverage"];if(!F.existsSync(e))return E.warn(`Directory does not exist: ${e}`),0;const c=F.readdirSync(e,{withFileTypes:!0});for(const f of c){const $=g.join(e,f.name);if(f.isDirectory()){if(s.includes(f.name))continue;n+=Ze($,r)}else if(f.isFile()){const u=f.name;if(u===".fnmap"||u.endsWith(".fnmap")||u.endsWith(".mermaid"))try{F.unlinkSync($),E.success(`Deleted: ${g.relative(r,$)}`),n++}catch(p){const h=p;E.error(`Failed to delete ${g.relative(r,$)}: ${h.message}`)}}}return n}function En(e,r){E.title("fnmap - Clear Generated Files"),E.info("=".repeat(50));const n=r?g.resolve(e,r):e,s=Ze(n,e);E.info("=".repeat(50)),s>0?E.success(`Cleared ${s} generated file(s)`):E.info("No generated files found")}function xn(e){const r=g.join(e,".gitignore");if(F.existsSync(r)){const n=F.readFileSync(r,"utf-8");if(n.includes("fnmap generated files")||n.includes("*.fnmap")){console.log(`${S.yellow}!${S.reset} .gitignore already contains fnmap rules`);return}F.appendFileSync(r,Ve)}else F.writeFileSync(r,Ve.trim()+`
67
- `);console.log(`${S.green}✓${S.reset} Added fnmap rules to .gitignore`)}function we(e,r){const n=g.dirname(e);if(F.existsSync(n)||F.mkdirSync(n,{recursive:!0}),F.existsSync(e)){if(F.readFileSync(e,"utf-8").includes(".fnmap Code Index Format")){console.log(`${S.yellow}!${S.reset} ${r} already contains fnmap documentation`);return}F.appendFileSync(e,qe)}else F.writeFileSync(e,qe.trim()+`
68
- `);console.log(`${S.green}✓${S.reset} Added fnmap documentation to ${r}`)}async function In(e){const r=on.createInterface({input:process.stdin,output:process.stdout});console.log(`
69
- ${S.bold}fnmap - Interactive Setup${S.reset}`),console.log("=".repeat(50));try{const n=g.join(e,".fnmaprc");if(F.existsSync(n))console.log(`${S.yellow}!${S.reset} Config file already exists: .fnmaprc`);else{const y={enable:!0,include:["src/**/*.js","src/**/*.ts","src/**/*.jsx","src/**/*.tsx"],exclude:["node_modules","dist","build",".next","coverage","__pycache__",".cache"]};F.writeFileSync(n,JSON.stringify(y,null,2)),console.log(`${S.green}✓${S.reset} Created config file: .fnmaprc`)}(await Ce(r,`
70
- Add fnmap rules to .gitignore? (Y/n): `)).toLowerCase()!=="n"&&xn(e);const c=g.join(e,"CLAUDE.md"),f=g.join(e,"AGENTS.md"),$=g.join(tn.homedir(),".claude","CLAUDE.md"),u=F.existsSync(c),p=F.existsSync(f),h=F.existsSync($);if(!(u||p))console.log(`
71
- ${S.yellow}!${S.reset} No CLAUDE.md or AGENTS.md found in project.`),(await Ce(r,"Create CLAUDE.md with fnmap documentation? (Y/n): ")).toLowerCase()!=="n"&&we(c,"CLAUDE.md");else{console.log(`
72
- ${S.bold}Select files to add fnmap documentation:${S.reset}`),console.log(`(Enter numbers separated by comma, e.g., 1,2)
73
- `);const y=[];let l=1;u&&y.push({key:String(l++),label:"Project CLAUDE.md",path:c,exists:!0}),y.push({key:String(l++),label:"User CLAUDE.md (~/.claude/CLAUDE.md)",path:$,exists:h}),p&&y.push({key:String(l++),label:"AGENTS.md",path:f,exists:!0});const I=String(l);for(const t of y){const i=t.exists?`${S.green}[exists]${S.reset}`:`${S.gray}[new]${S.reset}`;console.log(` ${t.key}. ${t.label} ${i}`)}console.log(` ${I}. Custom file path`),console.log(` 0. Skip
74
- `);const a=(await Ce(r,"Your choice: ")).split(",").map(t=>t.trim()).filter(Boolean);if(a.includes("0")||a.length===0)console.log("Skipped adding documentation to files.");else for(const t of a)if(t===I){const i=await Ce(r,"Enter custom file path: ");if(i){const m=g.isAbsolute(i)?i:g.resolve(e,i);we(m,i)}}else{const i=y.find(m=>m.key===t);i&&we(i.path,i.label)}}console.log(`
75
- `+"=".repeat(50)),console.log(`${S.green}✓${S.reset} Setup complete!`),console.log(`
76
- Run ${S.bold}fnmap${S.reset} or ${S.bold}fnmap --dir src${S.reset} to generate code index.`)}finally{r.close()}}async function Ye(){const e=Me();e.parse(process.argv);const r=e.opts(),n=e.args;r.log&&he(!1);const s=g.resolve(r.project);if(r.clear){const o=_e();he(!1),En(s,r.dir),he(o);return}if(r.init){const o=_e();he(!1),await In(s),he(o);return}const c=[...r.files??[],...n.map($e)].filter(o=>F.existsSync(o));let f=[],$=!1;if(r.changed||r.staged){const o=Ke(s,r.staged);if(o.length===0){E.info("No git changed code files detected");return}const y=new Set;for(const l of o)y.add(g.dirname(l));for(const l of y){const I=un(l);f.push(...I)}}else if(c.length>0)$=!0,f=c.map(o=>g.isAbsolute(o)?o:g.resolve(s,o));else if(r.dir){const o=g.resolve(s,r.dir);f=Ae(o,s).map(l=>g.join(s,l))}else{const{config:o,source:y}=Be(s);if(o){if(E.info(`Using config: ${y}`),o.enable===!1){E.info("Config file has enable set to false, skipping processing");return}const l=Je(o),I=[...Te,...l.exclude];if(l.include&&l.include.length>0){const v=new Set;for(const a of l.include){const t=a.replace(/\/\*\*\/.*$/,"").replace(/\*\*\/.*$/,"").replace(/\/\*\..*$/,"").replace(/\*\..*$/,"");t&&v.add(t)}for(const a of v){const t=g.resolve(s,a);if(F.existsSync(t)){const i=Ae(t,s,I);f.push(...i.map(m=>g.join(s,m)))}}}}else{E.warn("No config file found. Use fnmap init to create config, or use --dir/--files to specify scope"),E.info(""),E.info("Supported config files: .fnmaprc, .fnmaprc.json, package.json#fnmap");return}}if(f.length===0){E.info("No files found to process");return}f=[...new Set(f)],E.info("=".repeat(50)),E.title("fnmap - AI Code Indexing Tool"),E.info("=".repeat(50));let u=0,p=0;const h=new Map;for(const o of f){const y=g.relative(s,o);E.info(`
77
- Analyzing: ${y}`);const l=Qe(o);if(l.success){u++;const I=l.info;if(I.isPureType){E.info("Skipped (pure type file) / 跳过纯类型文件");continue}E.success(`Imports: ${I.imports.length}, Functions: ${I.functions.length}, Classes: ${I.classes.length}, Constants: ${I.constants.length}`);const v=g.dirname(o);h.has(v)||h.set(v,[]),h.get(v).push({relativePath:y,info:I})}else p++,E.error(l.error)}if(h.size>0)if(E.info(`
78
- Generating .fnmap index...`),$)for(const[o,y]of h)for(const{relativePath:l,info:I}of y)try{const v=Oe(o,[{relativePath:l,info:I}]),a=g.basename(l,g.extname(l)),t=g.join(o,`${a}.fnmap`);F.writeFileSync(t,v),E.success(g.relative(s,t))}catch(v){const a=v;E.error(`Failed to generate .fnmap for ${l}: ${a.message}`)}else for(const[o,y]of h)try{const l=Oe(o,y),I=g.join(o,".fnmap");F.writeFileSync(I,l),E.success(g.relative(s,I))}catch(l){const I=l;E.error(`Failed to generate .fnmap for ${g.relative(s,o)}: ${I.message}`)}if(r.mermaid&&h.size>0){if(E.info(`
79
- Generating Mermaid call graphs...`),r.mermaid==="file"||r.mermaid===!0)for(const[o,y]of h)for(const{relativePath:l,info:I}of y)try{const v=Xe(l,I);if(v){const a=g.basename(l,g.extname(l)),t=g.join(o,`${a}.mermaid`);F.writeFileSync(t,v),E.success(g.relative(s,t))}}catch(v){const a=v;E.error(`Failed to generate mermaid for ${l}: ${a.message}`)}else if(r.mermaid==="project")try{const o=[];for(const[,I]of h)o.push(...I);const y=He(s,o),l=g.join(s,".fnmap.mermaid");F.writeFileSync(l,y),E.success(g.relative(s,l))}catch(o){const y=o;E.error(`Failed to generate project mermaid: ${y.message}`)}}E.info(`
80
- `+"=".repeat(50)),E.stats(`Complete! Analyzed: ${S.green}${u}${S.reset}, Failed: ${p>0?S.red:""}${p}${S.reset}`),E.info("=".repeat(50))}require.main===module&&Ye().catch(e=>{console.error(e),process.exit(1)});exports.COLORS=S;exports.DEFAULT_CONFIG=Ne;exports.DEFAULT_EXCLUDES=Te;exports.ErrorTypes=z;exports.MAX_DIR_DEPTH=je;exports.MAX_FILE_SIZE=Le;exports.SUPPORTED_EXTENSIONS=Fe;exports.analyzeFile=Ge;exports.extractJSDocDescription=Y;exports.formatError=Se;exports.generateAiMap=Oe;exports.generateFileMermaid=Xe;exports.generateHeader=gn;exports.generateProjectMermaid=He;exports.getGitChangedFiles=Ke;exports.getVersion=We;exports.isParseError=ke;exports.isProcessFailure=cn;exports.isProcessSuccess=an;exports.isQuietMode=_e;exports.isValidationFailure=fn;exports.isValidationSuccess=ln;exports.loadConfig=Be;exports.logger=E;exports.main=Ye;exports.mergeConfig=Je;exports.normalizePath=$e;exports.normalizePaths=dn;exports.processCode=$n;exports.processFile=Qe;exports.program=mn;exports.removeExistingHeaders=hn;exports.scanDirectory=Ae;exports.setQuietMode=he;exports.setupCLI=Me;exports.validateConfig=De;exports.validateFilePath=ze;
118
+ `;function Oe(e,t){return new Promise(n=>{e.question(t,s=>{n(s.trim())})})}function ft(e,t){let n=0;const s=["node_modules",".git","dist","build",".next","coverage"];if(!A.existsSync(e))return x.warn(`Directory does not exist: ${e}`),0;const i=A.readdirSync(e,{withFileTypes:!0});for(const f of i){const E=$.join(e,f.name);if(f.isDirectory()){if(s.includes(f.name))continue;n+=ft(E,t)}else if(f.isFile()){const c=f.name;if(c===".fnmap"||c.endsWith(".fnmap")||c.endsWith(".mermaid"))try{A.unlinkSync(E),x.success(`Deleted: ${$.relative(t,E)}`),n++}catch(m){const g=m;x.error(`Failed to delete ${$.relative(t,E)}: ${g.message}`)}}}return n}function qt(e,t){x.title("fnmap - Clear Generated Files"),x.info("=".repeat(50));const n=t?$.resolve(e,t):e,s=ft(n,e);x.info("=".repeat(50)),s>0?x.success(`Cleared ${s} generated file(s)`):x.info("No generated files found")}function Wt(e){const t=$.join(e,".gitignore");if(A.existsSync(t)){const n=A.readFileSync(t,"utf-8");if(n.includes("fnmap generated files")||n.includes("*.fnmap")){console.log(`${y.yellow}!${y.reset} .gitignore already contains fnmap rules`);return}A.appendFileSync(t,Xe)}else A.writeFileSync(t,Xe.trim()+`
119
+ `);console.log(`${y.green}✓${y.reset} Added fnmap rules to .gitignore`)}function De(e,t){const n=$.dirname(e);if(A.existsSync(n)||A.mkdirSync(n,{recursive:!0}),A.existsSync(e)){if(A.readFileSync(e,"utf-8").includes(".fnmap Code Index Format")){console.log(`${y.yellow}!${y.reset} ${t} already contains fnmap documentation`);return}A.appendFileSync(e,Qe)}else A.writeFileSync(e,Qe.trim()+`
120
+ `);console.log(`${y.green}✓${y.reset} Added fnmap documentation to ${t}`)}async function Bt(e){const t=Ye.createInterface({input:process.stdin,output:process.stdout});console.log(`
121
+ ${y.bold}fnmap - Interactive Setup${y.reset}`),console.log("=".repeat(50));try{const n=$.join(e,".fnmaprc");if(A.existsSync(n))console.log(`${y.yellow}!${y.reset} Config file already exists: .fnmaprc`);else{const l={enable:!0,include:["src/**/*.js","src/**/*.ts","src/**/*.jsx","src/**/*.tsx"],exclude:["node_modules","dist","build",".next","coverage","__pycache__",".cache"]};A.writeFileSync(n,JSON.stringify(l,null,2)),console.log(`${y.green}✓${y.reset} Created config file: .fnmaprc`)}(await Oe(t,`
122
+ Add fnmap rules to .gitignore? (Y/n): `)).toLowerCase()!=="n"&&Wt(e);const i=$.join(e,"CLAUDE.md"),f=$.join(e,"AGENTS.md"),E=$.join(gt.homedir(),".claude","CLAUDE.md"),c=A.existsSync(i),m=A.existsSync(f),g=A.existsSync(E);if(!(c||m))console.log(`
123
+ ${y.yellow}!${y.reset} No CLAUDE.md or AGENTS.md found in project.`),(await Oe(t,"Create CLAUDE.md with fnmap documentation? (Y/n): ")).toLowerCase()!=="n"&&De(i,"CLAUDE.md");else{console.log(`
124
+ ${y.bold}Select files to add fnmap documentation:${y.reset}`),console.log(`(Enter numbers separated by comma, e.g., 1,2)
125
+ `);const l=[];let b=1;c&&l.push({key:String(b++),label:"Project CLAUDE.md",path:i,exists:!0}),l.push({key:String(b++),label:"User CLAUDE.md (~/.claude/CLAUDE.md)",path:E,exists:g}),m&&l.push({key:String(b++),label:"AGENTS.md",path:f,exists:!0});const _=String(b);for(const G of l){const H=G.exists?`${y.green}[exists]${y.reset}`:`${y.gray}[new]${y.reset}`;console.log(` ${G.key}. ${G.label} ${H}`)}console.log(` ${_}. Custom file path`),console.log(` 0. Skip
126
+ `);const N=(await Oe(t,"Your choice: ")).split(",").map(G=>G.trim()).filter(Boolean);if(N.includes("0")||N.length===0)console.log("Skipped adding documentation to files.");else for(const G of N)if(G===_){const H=await Oe(t,"Enter custom file path: ");if(H){const d=$.isAbsolute(H)?H:$.resolve(e,H);De(d,H)}}else{const H=l.find(d=>d.key===G);H&&De(H.path,H.label)}}(await Oe(t,`
127
+ Setup Claude Code hooks for auto quality checks? (Y/n): `)).toLowerCase()!=="n"&&await Je(e,t),console.log(`
128
+ `+"=".repeat(50)),console.log(`${y.green}✓${y.reset} Setup complete!`),console.log(`
129
+ Run ${y.bold}fnmap${y.reset} or ${y.bold}fnmap --dir src${y.reset} to generate code index.`)}finally{t.close()}}async function dt(){const e=Ve();e.parse(process.argv);const t=e.opts(),n=e.args;t.log&&Se(!1);const s=$.resolve(t.project);if(t.clear){const o=Fe();Se(!1),qt(s,t.dir),Se(o);return}if(t.hooks){const o=Fe();Se(!1),await Je(s),Se(o);return}if(t.init){const o=Fe();Se(!1),await Bt(s),Se(o);return}const i=[...t.files??[],...n.map(be)].filter(o=>A.existsSync(o));let f=[];if(t.changed||t.staged){const o=st(s,t.staged);if(o.length===0){x.info("No git changed code files detected");return}const p=new Set;for(const l of o)p.add($.dirname(l));for(const l of p){const b=bt(l);f.push(...b)}}else if(i.length>0)f=i.map(o=>$.isAbsolute(o)?o:$.resolve(s,o));else if(t.dir){const o=$.resolve(s,t.dir);f=Ne(o,s).map(l=>$.join(s,l))}else{const{config:o,source:p}=tt(s);if(o){if(x.info(`Using config: ${p}`),o.enable===!1){x.info("Config file has enable set to false, skipping processing");return}const l=nt(o),b=[...Be,...l.exclude];if(l.include&&l.include.length>0){const _=new Set;for(const v of l.include){const N=v.replace(/\/\*\*\/.*$/,"").replace(/\*\*\/.*$/,"").replace(/\/\*\..*$/,"").replace(/\*\..*$/,"");N&&_.add(N)}for(const v of _){const N=$.resolve(s,v);if(A.existsSync(N)){const G=Ne(N,s,b);f.push(...G.map(H=>$.join(s,H)))}}}}else{x.warn("No config file found. Use fnmap init to create config, or use --dir/--files to specify scope"),x.info(""),x.info("Supported config files: .fnmaprc, .fnmaprc.json, package.json#fnmap");return}}if(f.length===0){x.info("No files found to process");return}f=[...new Set(f)],x.info("=".repeat(50)),x.title("fnmap - AI Code Indexing Tool"),x.info("=".repeat(50));let E=0,c=0;const m=[],g=new Map;for(const o of f){const p=$.relative(s,o);x.info(`
130
+ Analyzing: ${p}`);const l=it(o);if(l.success){E++;const b=l.info;if(b.isPureType){x.info("Skipped (pure type file) / 跳过纯类型文件");continue}if(!(b.functions.length>0||b.classes.length>0||b.constants.length>0||b.exports&&b.exports.length>0)){x.info("Skipped (empty file) / 跳过空文件");continue}x.success(`Imports: ${b.imports.length}, Functions: ${b.functions.length}, Classes: ${b.classes.length}, Constants: ${b.constants.length}`);const v=$.dirname(o);g.has(v)||g.set(v,[]),g.get(v).push({relativePath:p,info:b})}else c++,m.push({file:p,reason:l.error}),x.error(l.error)}if(g.size>0)if(x.info(`
131
+ Generating .fnmap index...`),t.merge)for(const[o,p]of g)try{const l=qe(o,p),b=$.join(o,".fnmap");A.writeFileSync(b,l),x.success($.relative(s,b))}catch(l){const b=l;x.error(`Failed to generate .fnmap for ${$.relative(s,o)}: ${b.message}`)}else for(const[o,p]of g)for(const{relativePath:l,info:b}of p)try{const _=qe(o,[{relativePath:l,info:b}]),v=$.basename(l,$.extname(l)),N=$.join(o,`${v}.fnmap`);A.writeFileSync(N,_),x.success($.relative(s,N))}catch(_){const v=_;x.error(`Failed to generate .fnmap for ${l}: ${v.message}`)}if(t.mermaid&&g.size>0){if(x.info(`
132
+ Generating Mermaid call graphs...`),t.mermaid==="file"||t.mermaid===!0)for(const[o,p]of g)for(const{relativePath:l,info:b}of p)try{const _=ot(l,b);if(_){const v=$.basename(l,$.extname(l)),N=$.join(o,`${v}.mermaid`);A.writeFileSync(N,_),x.success($.relative(s,N))}}catch(_){const v=_;x.error(`Failed to generate mermaid for ${l}: ${v.message}`)}else if(t.mermaid==="project")try{const o=[];for(const[,b]of g)o.push(...b);const p=rt(s,o),l=$.join(s,".fnmap.mermaid");A.writeFileSync(l,p),x.success($.relative(s,l))}catch(o){const p=o;x.error(`Failed to generate project mermaid: ${p.message}`)}}if(x.info(`
133
+ `+"=".repeat(50)),x.stats(`Complete! Analyzed: ${y.green}${E}${y.reset}, Failed: ${c>0?y.red:""}${c}${y.reset}`),m.length>0)for(const{file:o,reason:p}of m)x.stats(` ${y.red}✗${y.reset} ${o}: ${p}`);x.info("=".repeat(50))}require.main===module&&dt().catch(e=>{console.error(e),process.exit(1)});exports.COLORS=y;exports.DEFAULT_CONFIG=Ue;exports.DEFAULT_EXCLUDES=Be;exports.ErrorTypes=U;exports.MAX_DIR_DEPTH=Me;exports.MAX_FILE_SIZE=Pe;exports.SUPPORTED_EXTENSIONS=Le;exports.analyzeFile=He;exports.detectTools=lt;exports.executeHooksSetup=Je;exports.extractJSDocDescription=oe;exports.formatError=Ae;exports.generateAiMap=qe;exports.generateFileMermaid=ot;exports.generateHeader=_t;exports.generateProjectMermaid=rt;exports.generateQualityScript=at;exports.getGitChangedFiles=st;exports.getVersion=et;exports.installHooks=ct;exports.isParseError=We;exports.isProcessFailure=$t;exports.isProcessSuccess=ht;exports.isQuietMode=Fe;exports.isValidationFailure=St;exports.isValidationSuccess=Et;exports.loadConfig=tt;exports.logger=x;exports.main=dt;exports.mergeConfig=nt;exports.normalizePath=be;exports.normalizePaths=Rt;exports.processCode=kt;exports.processFile=it;exports.program=xt;exports.removeExistingHeaders=vt;exports.scanDirectory=Ne;exports.setQuietMode=Se;exports.setupCLI=Ve;exports.validateConfig=Ge;exports.validateFilePath=Ze;
@@ -1 +1 @@
1
- {"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":"AAmRA;;GAEG;AACH,wBAAsB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAmP1C"}
1
+ {"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":"AA2RA;;GAEG;AACH,wBAAsB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CA2Q1C"}
@@ -59,6 +59,12 @@ export interface ConstantInfo {
59
59
  line: number;
60
60
  description: string;
61
61
  }
62
+ export interface ExportInfo {
63
+ name: string;
64
+ localName?: string;
65
+ line: number;
66
+ kind: 'value' | 'type' | 'default';
67
+ }
62
68
  export type CallGraph = Record<string, string[]>;
63
69
  export interface FileInfo {
64
70
  description: string;
@@ -66,6 +72,7 @@ export interface FileInfo {
66
72
  functions: FunctionInfo[];
67
73
  classes: ClassInfo[];
68
74
  constants: ConstantInfo[];
75
+ exports: ExportInfo[];
69
76
  callGraph: CallGraph;
70
77
  isPureType?: boolean;
71
78
  }
@@ -98,16 +105,24 @@ export interface CLIOptions {
98
105
  project: string;
99
106
  changed?: boolean;
100
107
  staged?: boolean;
108
+ merge?: boolean;
101
109
  mermaid?: boolean | 'file' | 'project';
102
110
  log?: boolean;
103
111
  init?: boolean;
104
112
  clear?: boolean;
113
+ hooks?: boolean;
105
114
  }
106
115
  export interface InitOptions {
107
116
  gitignore: boolean;
108
117
  claudeMd: 'project' | 'user' | 'none';
109
118
  cursorRules: boolean;
110
119
  }
120
+ export interface DetectedTool {
121
+ name: string;
122
+ detected: boolean;
123
+ source: string;
124
+ level: 'block' | 'warn';
125
+ }
111
126
  export interface ErrorContext {
112
127
  file?: string;
113
128
  line?: number;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,UAAU;;;;;;;;CAQb,CAAC;AAEX,MAAM,MAAM,SAAS,GAAG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B,IAAI,EAAE,QAAQ,CAAC;CAChB;AAID,wBAAgB,YAAY,CAAC,MAAM,EAAE,aAAa,GAAG,MAAM,IAAI,gBAAgB,CAE9E;AAED,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,aAAa,GAAG,MAAM,IAAI,cAAc,CAEhF;AAED,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,aAAa,GAAG,MAAM,IAAI,cAAc,CAEhF;AAED,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,gBAAgB,GAAG,MAAM,IAAI,iBAAiB,CAEzF;AAED,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,gBAAgB,GAAG,MAAM,IAAI,iBAAiB,CAEzF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@didnhdj/fnmap",
3
- "version": "0.2.1",
3
+ "version": "0.4.0",
4
4
  "description": "AI code indexing tool for analyzing JS/TS code structure and generating structured code maps to help AI understand code quickly",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -53,6 +53,7 @@
53
53
  "@babel/parser": "^7.28.5",
54
54
  "@babel/traverse": "^7.28.5",
55
55
  "@babel/types": "^7.28.5",
56
+ "@vue/compiler-sfc": "^3.5.31",
56
57
  "commander": "^14.0.2",
57
58
  "prettier": "^3.7.4"
58
59
  },