Skip to content

Commit 758b9ba

Browse files
authored
Merge pull request chaitin#183 from Haydenkkk/feat/context-enhance
Feat/context enhance 支持了 CodeSnippet 的检索功能 & 添加了CLI脚本文件
2 parents a8f6b63 + 5ad50a9 commit 758b9ba

51 files changed

Lines changed: 18768 additions & 154 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

backend/cmd/server/wire.go

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import (
1414
"github.com/chaitin/MonkeyCode/backend/db"
1515
"github.com/chaitin/MonkeyCode/backend/domain"
1616
billingv1 "github.com/chaitin/MonkeyCode/backend/internal/billing/handler/http/v1"
17+
codesnippetv1 "github.com/chaitin/MonkeyCode/backend/internal/codesnippet/handler/http/v1"
1718
dashv1 "github.com/chaitin/MonkeyCode/backend/internal/dashboard/handler/v1"
1819
v1 "github.com/chaitin/MonkeyCode/backend/internal/model/handler/http/v1"
1920
openaiV1 "github.com/chaitin/MonkeyCode/backend/internal/openai/handler/v1"
@@ -24,20 +25,21 @@ import (
2425
)
2526

2627
type Server struct {
27-
config *config.Config
28-
web *web.Web
29-
ent *db.Client
30-
logger *slog.Logger
31-
openaiV1 *openaiV1.V1Handler
32-
modelV1 *v1.ModelHandler
33-
userV1 *userV1.UserHandler
34-
dashboardV1 *dashv1.DashboardHandler
35-
billingV1 *billingv1.BillingHandler
36-
socketH *sockethandler.SocketHandler
37-
version *version.VersionInfo
38-
report *report.Reporter
39-
reportuse domain.ReportUsecase
40-
euse domain.ExtensionUsecase
28+
config *config.Config
29+
web *web.Web
30+
ent *db.Client
31+
logger *slog.Logger
32+
openaiV1 *openaiV1.V1Handler
33+
modelV1 *v1.ModelHandler
34+
userV1 *userV1.UserHandler
35+
dashboardV1 *dashv1.DashboardHandler
36+
billingV1 *billingv1.BillingHandler
37+
socketH *sockethandler.SocketHandler
38+
version *version.VersionInfo
39+
report *report.Reporter
40+
reportuse domain.ReportUsecase
41+
euse domain.ExtensionUsecase
42+
codeSnippetV1 *codesnippetv1.CodeSnippetHandler
4143
}
4244

4345
func newServer() (*Server, error) {

backend/cmd/server/wire_gen.go

Lines changed: 32 additions & 28 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

backend/docs/swagger.json

Lines changed: 197 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1173,6 +1173,61 @@
11731173
}
11741174
}
11751175
},
1176+
"/api/v1/ide/codesnippet/context": {
1177+
"post": {
1178+
"security": [
1179+
{
1180+
"ApiKeyAuth": []
1181+
}
1182+
],
1183+
"description": "为IDE端提供代码片段上下文检索功能,使用API Key认证。支持单个查询和批量查询。",
1184+
"consumes": [
1185+
"application/json"
1186+
],
1187+
"produces": [
1188+
"application/json"
1189+
],
1190+
"tags": [
1191+
"CodeSnippet"
1192+
],
1193+
"summary": "IDE端上下文检索",
1194+
"operationId": "get-context",
1195+
"parameters": [
1196+
{
1197+
"description": "检索请求参数",
1198+
"name": "request",
1199+
"in": "body",
1200+
"required": true,
1201+
"schema": {
1202+
"$ref": "#/definitions/internal_codesnippet_handler_http_v1.GetContextReq"
1203+
}
1204+
}
1205+
],
1206+
"responses": {
1207+
"200": {
1208+
"description": "OK",
1209+
"schema": {
1210+
"allOf": [
1211+
{
1212+
"$ref": "#/definitions/web.Resp"
1213+
},
1214+
{
1215+
"type": "object",
1216+
"properties": {
1217+
"data": {
1218+
"type": "array",
1219+
"items": {
1220+
"$ref": "#/definitions/domain.CodeSnippet"
1221+
}
1222+
}
1223+
}
1224+
}
1225+
]
1226+
}
1227+
}
1228+
}
1229+
}
1230+
},
11761231
"/api/v1/model": {
11771232
"get": {
11781233
"description": "获取模型列表",
@@ -3833,6 +3888,102 @@
38333888
"CodeLanguageTypeCpp"
38343889
]
38353890
},
3891+
"domain.CodeSnippet": {
3892+
"type": "object",
3893+
"properties": {
3894+
"definition": {
3895+
"description": "结构化信息",
3896+
"type": "object",
3897+
"additionalProperties": {}
3898+
},
3899+
"definitionText": {
3900+
"description": "定义文本",
3901+
"type": "string"
3902+
},
3903+
"dependencies": {
3904+
"description": "依赖项",
3905+
"type": "array",
3906+
"items": {
3907+
"type": "string"
3908+
}
3909+
},
3910+
"endColumn": {
3911+
"description": "结束列号",
3912+
"type": "integer"
3913+
},
3914+
"endLine": {
3915+
"description": "结束行号",
3916+
"type": "integer"
3917+
},
3918+
"field": {
3919+
"description": "容器名称",
3920+
"type": "string"
3921+
},
3922+
"fileHash": {
3923+
"description": "内容哈希",
3924+
"type": "string"
3925+
},
3926+
"filePath": {
3927+
"description": "文件路径",
3928+
"type": "string"
3929+
},
3930+
"id": {
3931+
"description": "代码片段ID",
3932+
"type": "string"
3933+
},
3934+
"language": {
3935+
"description": "编程语言",
3936+
"type": "string"
3937+
},
3938+
"name": {
3939+
"description": "代码片段名称",
3940+
"type": "string"
3941+
},
3942+
"namespace": {
3943+
"description": "命名空间",
3944+
"type": "string"
3945+
},
3946+
"parameters": {
3947+
"description": "参数列表",
3948+
"type": "array",
3949+
"items": {
3950+
"type": "object",
3951+
"additionalProperties": {}
3952+
}
3953+
},
3954+
"rangeText": {
3955+
"description": "代码片段内容",
3956+
"type": "string"
3957+
},
3958+
"scope": {
3959+
"description": "作用域信息",
3960+
"type": "array",
3961+
"items": {
3962+
"type": "string"
3963+
}
3964+
},
3965+
"signature": {
3966+
"description": "函数签名",
3967+
"type": "string"
3968+
},
3969+
"startColumn": {
3970+
"description": "起始列号",
3971+
"type": "integer"
3972+
},
3973+
"startLine": {
3974+
"description": "起始行号",
3975+
"type": "integer"
3976+
},
3977+
"type": {
3978+
"description": "代码片段类型",
3979+
"type": "string"
3980+
},
3981+
"workspace_file_id": {
3982+
"description": "关联的workspace file ID",
3983+
"type": "string"
3984+
}
3985+
}
3986+
},
38363987
"domain.CompletionData": {
38373988
"type": "object",
38383989
"properties": {
@@ -4381,12 +4532,7 @@
43814532
"rangeText": {
43824533
"type": "string"
43834534
},
4384-
"scope": {
4385-
"type": "array",
4386-
"items": {
4387-
"type": "object"
4388-
}
4389-
},
4535+
"scope": {},
43904536
"signature": {
43914537
"type": "string"
43924538
},
@@ -5638,6 +5784,51 @@
56385784
}
56395785
}
56405786
},
5787+
"internal_codesnippet_handler_http_v1.GetContextReq": {
5788+
"type": "object",
5789+
"properties": {
5790+
"limit": {
5791+
"description": "返回结果数量限制,默认10",
5792+
"type": "integer"
5793+
},
5794+
"queries": {
5795+
"description": "批量查询参数",
5796+
"type": "array",
5797+
"items": {
5798+
"$ref": "#/definitions/internal_codesnippet_handler_http_v1.Query"
5799+
}
5800+
},
5801+
"query": {
5802+
"description": "单个查询参数",
5803+
"allOf": [
5804+
{
5805+
"$ref": "#/definitions/internal_codesnippet_handler_http_v1.Query"
5806+
}
5807+
]
5808+
},
5809+
"workspacePath": {
5810+
"description": "工作区路径(必填)",
5811+
"type": "string"
5812+
}
5813+
}
5814+
},
5815+
"internal_codesnippet_handler_http_v1.Query": {
5816+
"type": "object",
5817+
"properties": {
5818+
"language": {
5819+
"description": "编程语言(可选)",
5820+
"type": "string"
5821+
},
5822+
"name": {
5823+
"description": "代码片段名称(可选)",
5824+
"type": "string"
5825+
},
5826+
"snippetType": {
5827+
"description": "代码片段类型(可选)",
5828+
"type": "string"
5829+
}
5830+
}
5831+
},
56415832
"web.Resp": {
56425833
"type": "object",
56435834
"properties": {

0 commit comments

Comments
 (0)