Gathering detailed insights and metrics for codn_ts
Gathering detailed insights and metrics for codn_ts
Gathering detailed insights and metrics for codn_ts
Gathering detailed insights and metrics for codn_ts
npm install codn_ts
Typescript
Module System
Min. Node Version
Node Version
NPM Version
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
codn_ts 是一个基于 TypeScript 的智能代码分析工具,支持作为库和 CLI 工具使用,对大模型/AI agent 友好。
cod ref
支持精准分析任意符号的调用方/被调方cod check
基于 LSP 输出语法/类型错误和警告1# 全局安装 2npm install -g codn_ts 3 4# 或本地安装 5npm install codn_ts
1# 语义搜索 2cod search "authentication" --semantic --json 3 4# 分析引用关系 5cod analyze --json 6 7# 符号引用分析 8cod ref -s "main" --json 9 10# 诊断检查 11cod check 12cod check --file src/index.ts --json 13 14# 调用链可视化 15cod analyze --call-chain --from "main" --format mermaid --output callchain.md 16 17# 列出目录 18cod ls --long --json 19 20# 查看文件 21cod cat src/semantic_search.ts --json
cod search
- 智能搜索1cod search "functionName" 2cod search "authentication" --semantic 3cod search "api" --type file,symbol,content 4cod search "database" --semantic --json
cod analyze
- 代码分析1cod analyze 2cod analyze --call-chain --from "main" 3cod analyze --call-chain --format mermaid --output diagram.md 4cod analyze --json
cod ref
- 符号引用分析1# 分析函数/类/变量引用关系 2cod ref -s "authenticateUser" 3cod ref -s "UserService" --json 4cod ref -s "main" --format mermaid --output ref.md
cod check
- 诊断检查(LSP)1# 全项目诊断 2cod check 3# 单文件诊断 4cod check --file src/index.ts 5# JSON 输出 6cod check --json
cod ls
- 目录列表1cod ls 2cod ls --long 3cod ls --recursive 4cod ls --json
cod cat
- 文件查看1cod cat src/index.ts 2cod cat src/index.ts --line-numbers 3cod cat src/index.ts --json
1import { 2 searchProject, 3 analyzeProjectReferences, 4 listDirectory, 5 readFile, 6 semanticSearch 7} from 'codn_ts'; 8 9// 语义搜索 10const results = await semanticSearch(projectPath, "authentication", { 11 semantic: true, 12 json: true 13}); 14 15// 分析引用关系 16const references = await analyzeProjectReferences(projectPath); 17 18// 搜索项目 19const searchResults = await searchProject(projectPath, "api", { 20 types: ['file', 'symbol', 'content'] 21}); 22 23// 列出目录 24const files = await listDirectory(projectPath, { 25 long: true, 26 recursive: true 27}); 28 29// 读取文件 30const content = await readFile(filePath, { 31 lineNumbers: true 32});
src/
├── index.ts # 统一导出接口
├── cli.ts # CLI 入口
├── search.ts # 搜索功能
├── semantic_search.ts # 语义搜索(5维度评分)
├── callChain.ts # 调用链分析
├── ls.ts # 目录列表
├── cat.ts # 文件读取
└── utils/
├── lsp_core.ts # LSP 客户端
├── os_utils.ts # 系统工具
├── reference_analyzer.ts # 引用分析
└── symbol_utils.ts # 符号工具
1# 运行测试 2npm test 3 4# 运行测试覆盖率 5npm run test:coverage
当前测试状态:
1git clone https://github.com/dweb-lab/codn_ts.git 2cd codn_ts 3npm install 4npm run build
1# 开发模式运行 2npm run dev 3 4# 格式化代码 5npm run format 6 7# 代码检查 8npm run lint
1// 为 AI 提供代码上下文 2const context = await semanticSearch(projectPath, userQuery, { 3 semantic: true, 4 json: true, 5 limit: 10 6});
1# 分析函数调用关系 2cod analyze --call-chain --from "processPayment" --format mermaid
1# 查找所有使用特定 API 的地方 2cod search "deprecatedAPI" --semantic --type symbol,content
1# 生成项目结构图 2cod analyze --call-chain --format mermaid --output docs/architecture.md
--semantic
: 启用语义搜索--type
: 指定搜索类型 (file|symbol|content)--limit
: 限制结果数量--json
: JSON 格式输出--call-chain
: 生成调用链--from
: 指定起始函数--format
: 输出格式 (json|mermaid|text)--output
: 输出文件路径我们欢迎贡献!请查看我们的 贡献指南。
MIT © askender
codn_ref
(符号引用分析)、codn_check
(诊断检查)等能力No vulnerabilities found.
No security vulnerabilities found.