Skip to content

Commit ba57242

Browse files
committed
chore: update .gitignore and enhance project instruction handling in conversation preparation
- Added '.claude' to .gitignore to exclude specific files from version control. - Refactored conversation preparation logic in both V1 and V2 to use a local variable for project instructions, improving code clarity. - Updated toolkit client to register file and LaTeX tools with project service injection, enhancing functionality. - Modified error messages in file and folder tools to indicate unimplemented features.
1 parent 48bdda6 commit ba57242

12 files changed

Lines changed: 45 additions & 53 deletions

File tree

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
.claude
2+
13
# docker image build
24
.dockerignore
35
node_modules

internal/api/chat/create_conversation_message_stream.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,9 +207,13 @@ func (s *ChatServerV1) prepare(ctx context.Context, projectId string, conversati
207207
}
208208

209209
var latexFullSource string
210+
var projectInstructions string
210211
switch conversationType {
211212
case chatv1.ConversationType_CONVERSATION_TYPE_DEBUG:
212213
latexFullSource = "latex_full_source is not available in debug mode"
214+
if project != nil {
215+
projectInstructions = project.Instructions
216+
}
213217
default:
214218
if project == nil || project.IsOutOfDate() {
215219
return ctx, nil, nil, shared.ErrProjectOutOfDate("project is out of date")
@@ -219,6 +223,7 @@ func (s *ChatServerV1) prepare(ctx context.Context, projectId string, conversati
219223
if err != nil {
220224
return ctx, nil, nil, err
221225
}
226+
projectInstructions = project.Instructions
222227
}
223228

224229
var conversation *models.Conversation
@@ -229,7 +234,7 @@ func (s *ChatServerV1) prepare(ctx context.Context, projectId string, conversati
229234
actor.ID,
230235
projectId,
231236
latexFullSource,
232-
project.Instructions,
237+
projectInstructions,
233238
userInstructions,
234239
userMessage,
235240
userSelectedText,

internal/api/chat/create_conversation_message_stream_v2.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,9 +225,13 @@ func (s *ChatServerV2) prepare(ctx context.Context, projectId string, conversati
225225
}
226226

227227
var latexFullSource string
228+
var projectInstructions string
228229
switch conversationType {
229230
case chatv2.ConversationType_CONVERSATION_TYPE_DEBUG:
230231
latexFullSource = "latex_full_source is not available in debug mode"
232+
if project != nil {
233+
projectInstructions = project.Instructions
234+
}
231235
default:
232236
if project == nil || project.IsOutOfDate() {
233237
return ctx, nil, nil, nil, shared.ErrProjectOutOfDate("project is out of date")
@@ -237,6 +241,7 @@ func (s *ChatServerV2) prepare(ctx context.Context, projectId string, conversati
237241
if err != nil {
238242
return ctx, nil, nil, nil, err
239243
}
244+
projectInstructions = project.Instructions
240245
}
241246

242247
var conversation *models.Conversation
@@ -249,7 +254,7 @@ func (s *ChatServerV2) prepare(ctx context.Context, projectId string, conversati
249254
actor.ID,
250255
projectId,
251256
latexFullSource,
252-
project.Instructions,
257+
projectInstructions,
253258
userInstructions,
254259
userMessage,
255260
userSelectedText,

internal/services/toolkit/client/utils_v2.go

Lines changed: 22 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ import (
1212
"paperdebugger/internal/libs/logger"
1313
"paperdebugger/internal/services"
1414
"paperdebugger/internal/services/toolkit/registry"
15+
filetools "paperdebugger/internal/services/toolkit/tools/files"
16+
latextools "paperdebugger/internal/services/toolkit/tools/latex"
1517
"paperdebugger/internal/services/toolkit/tools/xtramcp"
1618
chatv2 "paperdebugger/pkg/gen/api/chat/v2"
1719
"strings"
@@ -109,40 +111,26 @@ func initializeToolkitV2(
109111
) *registry.ToolRegistryV2 {
110112
toolRegistry := registry.NewToolRegistryV2()
111113

112-
// Register static file tools (create/delete don't need ProjectService - they're placeholder only)
113-
// toolRegistry.Register("create_file", filetools.CreateFileToolDescriptionV2, filetools.CreateFileTool)
114-
// toolRegistry.Register("delete_file", filetools.DeleteFileToolDescriptionV2, filetools.DeleteFileTool)
115-
// toolRegistry.Register("create_folder", filetools.CreateFolderToolDescriptionV2, filetools.CreateFolderTool)
116-
// toolRegistry.Register("delete_folder", filetools.DeleteFolderToolDescriptionV2, filetools.DeleteFolderTool)
117-
118-
// Register file tools with ProjectService injection
119-
// readFileTool := filetools.NewReadFileTool(projectService)
120-
// toolRegistry.Register("read_file", filetools.ReadFileToolDescriptionV2, readFileTool.Call)
121-
122-
// listFolderTool := filetools.NewListFolderTool(projectService)
123-
// toolRegistry.Register("list_folder", filetools.ListFolderToolDescriptionV2, listFolderTool.Call)
124-
125-
// searchStringTool := filetools.NewSearchStringTool(projectService)
126-
// toolRegistry.Register("search_string", filetools.SearchStringToolDescriptionV2, searchStringTool.Call)
127-
128-
// searchFileTool := filetools.NewSearchFileTool(projectService)
129-
// toolRegistry.Register("search_file", filetools.SearchFileToolDescriptionV2, searchFileTool.Call)
130-
131-
logger.Info("[AI Client V2] Registered static file tools", "count", 0)
132-
133-
// Register LaTeX tools with ProjectService injection
134-
// documentStructureTool := latextools.NewDocumentStructureTool(projectService)
135-
// toolRegistry.Register("get_document_structure", latextools.GetDocumentStructureToolDescriptionV2, documentStructureTool.Call)
136-
137-
// toolRegistry.Register("locate_section", latextools.LocateSectionToolDescriptionV2, latextools.LocateSectionTool)
138-
139-
// readSectionSourceTool := latextools.NewReadSectionSourceTool(projectService)
140-
// toolRegistry.Register("read_section_source", latextools.ReadSectionSourceToolDescriptionV2, readSectionSourceTool.Call)
141-
142-
// readSourceLineRangeTool := latextools.NewReadSourceLineRangeTool(projectService)
143-
// toolRegistry.Register("read_source_line_range", latextools.ReadSourceLineRangeToolDescriptionV2, readSourceLineRangeTool.Call)
144-
145-
logger.Info("[AI Client V2] Registered static LaTeX tools", "count", 0)
114+
readFileTool := filetools.NewReadFileTool(projectService)
115+
listFolderTool := filetools.NewListFolderTool(projectService)
116+
searchStringTool := filetools.NewSearchStringTool(projectService)
117+
searchFileTool := filetools.NewSearchFileTool(projectService)
118+
documentStructureTool := latextools.NewDocumentStructureTool(projectService)
119+
readSectionSourceTool := latextools.NewReadSectionSourceTool(projectService)
120+
readSourceLineRangeTool := latextools.NewReadSourceLineRangeTool(projectService)
121+
122+
toolRegistry.Register("create_file", filetools.CreateFileToolDescriptionV2, filetools.CreateFileTool)
123+
toolRegistry.Register("delete_file", filetools.DeleteFileToolDescriptionV2, filetools.DeleteFileTool)
124+
toolRegistry.Register("create_folder", filetools.CreateFolderToolDescriptionV2, filetools.CreateFolderTool)
125+
toolRegistry.Register("delete_folder", filetools.DeleteFolderToolDescriptionV2, filetools.DeleteFolderTool)
126+
toolRegistry.Register("read_file", filetools.ReadFileToolDescriptionV2, readFileTool.Call)
127+
toolRegistry.Register("list_folder", filetools.ListFolderToolDescriptionV2, listFolderTool.Call)
128+
toolRegistry.Register("search_string", filetools.SearchStringToolDescriptionV2, searchStringTool.Call)
129+
toolRegistry.Register("search_file", filetools.SearchFileToolDescriptionV2, searchFileTool.Call)
130+
toolRegistry.Register("get_document_structure", latextools.GetDocumentStructureToolDescriptionV2, documentStructureTool.Call)
131+
toolRegistry.Register("locate_section", latextools.LocateSectionToolDescriptionV2, latextools.LocateSectionTool)
132+
toolRegistry.Register("read_section_source", latextools.ReadSectionSourceToolDescriptionV2, readSectionSourceTool.Call)
133+
toolRegistry.Register("read_source_line_range", latextools.ReadSourceLineRangeToolDescriptionV2, readSourceLineRangeTool.Call)
146134

147135
// Load tools dynamically from backend
148136
xtraMCPLoader := xtramcp.NewXtraMCPLoaderV2(db, projectService, cfg.XtraMCPURI)

internal/services/toolkit/tools/files/file_create.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,5 +45,5 @@ func CreateFileTool(ctx context.Context, toolCallId string, args json.RawMessage
4545
}
4646

4747
// TODO: Implement actual file creation logic
48-
return fmt.Sprintf("[DUMMY] File created at: %s (content length: %d bytes)", getArgs.Path, len(getArgs.Content)), "", nil
48+
return "", "", fmt.Errorf("create_file tool is not yet implemented: cannot create file at %s", getArgs.Path)
4949
}

internal/services/toolkit/tools/files/file_delete.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,5 +40,5 @@ func DeleteFileTool(ctx context.Context, toolCallId string, args json.RawMessage
4040
}
4141

4242
// TODO: Implement actual file deletion logic
43-
return fmt.Sprintf("[DUMMY] File deleted: %s", getArgs.Path), "", nil
43+
return "", "", fmt.Errorf("delete_file tool is not yet implemented: cannot delete file at %s", getArgs.Path)
4444
}

internal/services/toolkit/tools/files/file_search.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ func (t *SearchFileTool) Call(ctx context.Context, toolCallId string, args json.
104104
if !recursive && dir != searchPath {
105105
continue
106106
}
107-
if recursive && !strings.HasPrefix(docPath, searchPath) {
107+
if recursive && !strings.HasPrefix(docPath, searchPath+"/") {
108108
continue
109109
}
110110
}

internal/services/toolkit/tools/files/folder_create.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,5 +40,5 @@ func CreateFolderTool(ctx context.Context, toolCallId string, args json.RawMessa
4040
}
4141

4242
// TODO: Implement actual folder creation logic
43-
return fmt.Sprintf("[DUMMY] Folder created at: %s", getArgs.Path), "", nil
43+
return "", "", fmt.Errorf("create_folder tool is not yet implemented: cannot create folder at %s", getArgs.Path)
4444
}

internal/services/toolkit/tools/files/folder_delete.go

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,6 @@ func DeleteFolderTool(ctx context.Context, toolCallId string, args json.RawMessa
4444
return "", "", err
4545
}
4646

47-
recursive := false
48-
if getArgs.Recursive != nil {
49-
recursive = *getArgs.Recursive
50-
}
51-
5247
// TODO: Implement actual folder deletion logic
53-
return fmt.Sprintf("[DUMMY] Folder deleted: %s (recursive: %v)", getArgs.Path, recursive), "", nil
48+
return "", "", fmt.Errorf("delete_folder tool is not yet implemented: cannot delete folder at %s", getArgs.Path)
5449
}

internal/services/toolkit/tools/latex/locate_section.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,5 @@ func LocateSectionTool(ctx context.Context, toolCallId string, args json.RawMess
4040
}
4141

4242
// TODO: Implement actual section location logic
43-
return fmt.Sprintf(`[DUMMY] Located section '%s':
44-
File: main.tex
45-
Start Line: 42
46-
End Line: 87`, getArgs.Title), "", nil
43+
return "", "", fmt.Errorf("locate_section tool is not yet implemented: cannot locate section '%s'", getArgs.Title)
4744
}

0 commit comments

Comments
 (0)