メインコンテンツまでスキップ

分析 API

コード分析と AI によるインサイトのためのエンドポイント。

セマンティック検索

自然言語でコードを検索します。

POST /v1/projects/:id/search

リクエストボディ:

{
"query": "ユーザー認証フロー",
"limit": 10
}

レスポンス:

{
"success": true,
"results": [
{
"filePath": "src/auth/login.ts",
"lineStart": 45,
"lineEnd": 78,
"content": "async function authenticate(email, password) {...}",
"score": 0.92,
"context": "LoginService - ユーザー認証を処理"
}
]
}

AI アシスタントに質問

コードベースについて質問します。

POST /v1/projects/:id/ask

リクエストボディ:

{
"question": "認証システムはどのように機能しますか?",
"language": "ja"
}

レスポンス:

{
"success": true,
"answer": "認証システムは JWT トークンを使用しています...",
"references": [
{
"filePath": "src/auth/login.ts",
"description": "メインの認証ロジック"
}
]
}

影響分析

ファイルへの変更の影響を分析します。

POST /v1/projects/:id/analyze

リクエストボディ:

{
"path": "src/services/user.ts"
}

レスポンス:

{
"success": true,
"impact": {
"directDependencies": [
"src/utils/crypto.ts",
"src/db/models/user.ts"
],
"dependents": [
"src/controllers/auth.ts",
"src/controllers/profile.ts"
],
"affectedTests": [
"tests/user.test.ts"
],
"riskLevel": "medium",
"recommendation": "変更には認証とプロファイルフローのテストが必要です"
}
}

コードメトリクス

コード品質メトリクスを取得します。

GET /v1/projects/:id/metrics

クエリパラメータ:

パラメータ説明
pathstringパスでフィルタリング(オプション)

レスポンス:

{
"success": true,
"metrics": {
"summary": {
"totalFiles": 234,
"totalLines": 15420,
"avgComplexity": 4.2,
"maxComplexity": 18,
"duplicatePercentage": 3.1
},
"byFile": [
{
"path": "src/services/complex.ts",
"lines": 450,
"complexity": 18,
"maintainability": 62
}
]
}
}

セキュリティスキャン

セキュリティ脆弱性スキャン結果を取得します。

GET /v1/projects/:id/security

レスポンス:

{
"success": true,
"scan": {
"status": "completed",
"scannedAt": "2024-01-15T10:30:00Z",
"summary": {
"high": 2,
"medium": 5,
"low": 8
},
"issues": [
{
"severity": "high",
"type": "sql-injection",
"file": "src/db/query.ts",
"line": 34,
"description": "潜在的な SQL インジェクション脆弱性",
"recommendation": "パラメータ化クエリを使用してください"
}
]
}
}

デッドコード検出

使用されていないコードを見つけます。

GET /v1/projects/:id/dead-code

レスポンス:

{
"success": true,
"deadCode": {
"unusedExports": [
{
"file": "src/utils/helpers.ts",
"name": "formatDate",
"line": 45,
"type": "function"
}
],
"unusedFiles": [
"src/legacy/old-service.ts"
],
"estimatedLines": 234
}
}

コード重複

重複したコードブロックを見つけます。

GET /v1/projects/:id/duplication

レスポンス:

{
"success": true,
"duplication": {
"percentage": 3.1,
"duplicates": [
{
"lines": 15,
"occurrences": [
{ "file": "src/api/users.ts", "start": 45, "end": 60 },
{ "file": "src/api/products.ts", "start": 32, "end": 47 }
]
}
]
}
}