Refactoring code
This commit is contained in:
40
lua/codetyper/params/agent/confidence.lua
Normal file
40
lua/codetyper/params/agent/confidence.lua
Normal file
@@ -0,0 +1,40 @@
|
||||
---@mod codetyper.params.agent.confidence Parameters for confidence scoring
|
||||
local M = {}
|
||||
|
||||
--- Heuristic weights (must sum to 1.0)
|
||||
M.weights = {
|
||||
length = 0.15, -- Response length relative to prompt
|
||||
uncertainty = 0.30, -- Uncertainty phrases
|
||||
syntax = 0.25, -- Syntax completeness
|
||||
repetition = 0.15, -- Duplicate lines
|
||||
truncation = 0.15, -- Incomplete ending
|
||||
}
|
||||
|
||||
--- Uncertainty phrases that indicate low confidence
|
||||
M.uncertainty_phrases = {
|
||||
-- English
|
||||
"i'm not sure",
|
||||
"i am not sure",
|
||||
"maybe",
|
||||
"perhaps",
|
||||
"might work",
|
||||
"could work",
|
||||
"not certain",
|
||||
"uncertain",
|
||||
"i think",
|
||||
"possibly",
|
||||
"TODO",
|
||||
"FIXME",
|
||||
"XXX",
|
||||
"placeholder",
|
||||
"implement this",
|
||||
"fill in",
|
||||
"your code here",
|
||||
"...", -- Ellipsis as placeholder
|
||||
"# TODO",
|
||||
"// TODO",
|
||||
"-- TODO",
|
||||
"/* TODO",
|
||||
}
|
||||
|
||||
return M
|
||||
33
lua/codetyper/params/agent/conflict.lua
Normal file
33
lua/codetyper/params/agent/conflict.lua
Normal file
@@ -0,0 +1,33 @@
|
||||
---@mod codetyper.params.agent.conflict Parameters for conflict resolution
|
||||
local M = {}
|
||||
|
||||
--- Configuration defaults
|
||||
M.config = {
|
||||
-- Run linter check after accepting AI suggestions
|
||||
lint_after_accept = true,
|
||||
-- Auto-fix lint errors without prompting
|
||||
auto_fix_lint_errors = true,
|
||||
-- Auto-show menu after injecting conflict
|
||||
auto_show_menu = true,
|
||||
-- Auto-show menu for next conflict after resolving one
|
||||
auto_show_next_menu = true,
|
||||
}
|
||||
|
||||
--- Highlight groups
|
||||
M.hl_groups = {
|
||||
current = "CoderConflictCurrent",
|
||||
current_label = "CoderConflictCurrentLabel",
|
||||
incoming = "CoderConflictIncoming",
|
||||
incoming_label = "CoderConflictIncomingLabel",
|
||||
separator = "CoderConflictSeparator",
|
||||
hint = "CoderConflictHint",
|
||||
}
|
||||
|
||||
--- Conflict markers
|
||||
M.markers = {
|
||||
current_start = "<<<<<<< CURRENT",
|
||||
separator = "=======",
|
||||
incoming_end = ">>>>>>> INCOMING",
|
||||
}
|
||||
|
||||
return M
|
||||
48
lua/codetyper/params/agent/context.lua
Normal file
48
lua/codetyper/params/agent/context.lua
Normal file
@@ -0,0 +1,48 @@
|
||||
---@mod codetyper.params.agent.context Parameters for context building
|
||||
local M = {}
|
||||
|
||||
--- Common ignore patterns
|
||||
M.ignore_patterns = {
|
||||
"^%.", -- Hidden files/dirs
|
||||
"node_modules",
|
||||
"%.git$",
|
||||
"__pycache__",
|
||||
"%.pyc$",
|
||||
"target", -- Rust
|
||||
"build",
|
||||
"dist",
|
||||
"%.o$",
|
||||
"%.a$",
|
||||
"%.so$",
|
||||
"%.min%.",
|
||||
"%.map$",
|
||||
}
|
||||
|
||||
--- Key files that are important for understanding the project
|
||||
M.important_files = {
|
||||
["package.json"] = "Node.js project config",
|
||||
["Cargo.toml"] = "Rust project config",
|
||||
["go.mod"] = "Go module config",
|
||||
["pyproject.toml"] = "Python project config",
|
||||
["setup.py"] = "Python setup config",
|
||||
["Makefile"] = "Build configuration",
|
||||
["CMakeLists.txt"] = "CMake config",
|
||||
[".gitignore"] = "Git ignore patterns",
|
||||
["README.md"] = "Project documentation",
|
||||
["init.lua"] = "Neovim plugin entry",
|
||||
["plugin.lua"] = "Neovim plugin config",
|
||||
}
|
||||
|
||||
--- Project type detection indicators
|
||||
M.indicators = {
|
||||
["package.json"] = { type = "node", language = "javascript/typescript" },
|
||||
["Cargo.toml"] = { type = "rust", language = "rust" },
|
||||
["go.mod"] = { type = "go", language = "go" },
|
||||
["pyproject.toml"] = { type = "python", language = "python" },
|
||||
["setup.py"] = { type = "python", language = "python" },
|
||||
["Gemfile"] = { type = "ruby", language = "ruby" },
|
||||
["pom.xml"] = { type = "maven", language = "java" },
|
||||
["build.gradle"] = { type = "gradle", language = "java/kotlin" },
|
||||
}
|
||||
|
||||
return M
|
||||
161
lua/codetyper/params/agent/intent.lua
Normal file
161
lua/codetyper/params/agent/intent.lua
Normal file
@@ -0,0 +1,161 @@
|
||||
---@mod codetyper.params.agent.intent Intent patterns and scope configuration
|
||||
local M = {}
|
||||
|
||||
--- Intent patterns with associated metadata
|
||||
M.intent_patterns = {
|
||||
-- Complete: fill in missing implementation
|
||||
complete = {
|
||||
patterns = {
|
||||
"complete",
|
||||
"finish",
|
||||
"implement",
|
||||
"fill in",
|
||||
"fill out",
|
||||
"stub",
|
||||
"todo",
|
||||
"fixme",
|
||||
},
|
||||
scope_hint = "function",
|
||||
action = "replace",
|
||||
priority = 1,
|
||||
},
|
||||
|
||||
-- Refactor: rewrite existing code
|
||||
refactor = {
|
||||
patterns = {
|
||||
"refactor",
|
||||
"rewrite",
|
||||
"restructure",
|
||||
"reorganize",
|
||||
"clean up",
|
||||
"cleanup",
|
||||
"simplify",
|
||||
"improve",
|
||||
},
|
||||
scope_hint = "function",
|
||||
action = "replace",
|
||||
priority = 2,
|
||||
},
|
||||
|
||||
-- Fix: repair bugs or issues
|
||||
fix = {
|
||||
patterns = {
|
||||
"fix",
|
||||
"repair",
|
||||
"correct",
|
||||
"debug",
|
||||
"solve",
|
||||
"resolve",
|
||||
"patch",
|
||||
"bug",
|
||||
"error",
|
||||
"issue",
|
||||
"update",
|
||||
"modify",
|
||||
"change",
|
||||
"adjust",
|
||||
"tweak",
|
||||
},
|
||||
scope_hint = "function",
|
||||
action = "replace",
|
||||
priority = 1,
|
||||
},
|
||||
|
||||
-- Add: insert new code
|
||||
add = {
|
||||
patterns = {
|
||||
"add",
|
||||
"create",
|
||||
"insert",
|
||||
"include",
|
||||
"append",
|
||||
"new",
|
||||
"generate",
|
||||
"write",
|
||||
},
|
||||
scope_hint = nil, -- Could be anywhere
|
||||
action = "insert",
|
||||
priority = 3,
|
||||
},
|
||||
|
||||
-- Document: add documentation
|
||||
document = {
|
||||
patterns = {
|
||||
"document",
|
||||
"comment",
|
||||
"jsdoc",
|
||||
"docstring",
|
||||
"describe",
|
||||
"annotate",
|
||||
"type hint",
|
||||
"typehint",
|
||||
},
|
||||
scope_hint = "function",
|
||||
action = "replace", -- Replace with documented version
|
||||
priority = 2,
|
||||
},
|
||||
|
||||
-- Test: generate tests
|
||||
test = {
|
||||
patterns = {
|
||||
"test",
|
||||
"spec",
|
||||
"unit test",
|
||||
"integration test",
|
||||
"coverage",
|
||||
},
|
||||
scope_hint = "file",
|
||||
action = "append",
|
||||
priority = 3,
|
||||
},
|
||||
|
||||
-- Optimize: improve performance
|
||||
optimize = {
|
||||
patterns = {
|
||||
"optimize",
|
||||
"performance",
|
||||
"faster",
|
||||
"efficient",
|
||||
"speed up",
|
||||
"reduce",
|
||||
"minimize",
|
||||
},
|
||||
scope_hint = "function",
|
||||
action = "replace",
|
||||
priority = 2,
|
||||
},
|
||||
|
||||
-- Explain: provide explanation (no code change)
|
||||
explain = {
|
||||
patterns = {
|
||||
"explain",
|
||||
"what does",
|
||||
"how does",
|
||||
"why",
|
||||
"describe",
|
||||
"walk through",
|
||||
"understand",
|
||||
},
|
||||
scope_hint = "function",
|
||||
action = "none",
|
||||
priority = 4,
|
||||
},
|
||||
}
|
||||
|
||||
--- Scope hint patterns
|
||||
M.scope_patterns = {
|
||||
["this function"] = "function",
|
||||
["this method"] = "function",
|
||||
["the function"] = "function",
|
||||
["the method"] = "function",
|
||||
["this class"] = "class",
|
||||
["the class"] = "class",
|
||||
["this file"] = "file",
|
||||
["the file"] = "file",
|
||||
["this block"] = "block",
|
||||
["the block"] = "block",
|
||||
["this"] = nil, -- Use Tree-sitter to determine
|
||||
["here"] = nil,
|
||||
}
|
||||
|
||||
return M
|
||||
87
lua/codetyper/params/agent/languages.lua
Normal file
87
lua/codetyper/params/agent/languages.lua
Normal file
@@ -0,0 +1,87 @@
|
||||
---@mod codetyper.params.agent.languages Language-specific patterns and configurations
|
||||
local M = {}
|
||||
|
||||
--- Language-specific import patterns
|
||||
M.import_patterns = {
|
||||
-- JavaScript/TypeScript
|
||||
javascript = {
|
||||
{ pattern = "^%s*import%s+.+%s+from%s+['\"]", multi_line = true },
|
||||
{ pattern = "^%s*import%s+['\"]", multi_line = false },
|
||||
{ pattern = "^%s*import%s*{", multi_line = true },
|
||||
{ pattern = "^%s*import%s*%*", multi_line = true },
|
||||
{ pattern = "^%s*export%s+{.+}%s+from%s+['\"]", multi_line = true },
|
||||
{ pattern = "^%s*const%s+%w+%s*=%s*require%(['\"]", multi_line = false },
|
||||
{ pattern = "^%s*let%s+%w+%s*=%s*require%(['\"]", multi_line = false },
|
||||
{ pattern = "^%s*var%s+%w+%s*=%s*require%(['\"]", multi_line = false },
|
||||
},
|
||||
-- Python
|
||||
python = {
|
||||
{ pattern = "^%s*import%s+%w", multi_line = false },
|
||||
{ pattern = "^%s*from%s+[%w%.]+%s+import%s+", multi_line = true },
|
||||
},
|
||||
-- Lua
|
||||
lua = {
|
||||
{ pattern = "^%s*local%s+%w+%s*=%s*require%s*%(?['\"]", multi_line = false },
|
||||
{ pattern = "^%s*require%s*%(?['\"]", multi_line = false },
|
||||
},
|
||||
-- Go
|
||||
go = {
|
||||
{ pattern = "^%s*import%s+%(?", multi_line = true },
|
||||
},
|
||||
-- Rust
|
||||
rust = {
|
||||
{ pattern = "^%s*use%s+", multi_line = true },
|
||||
{ pattern = "^%s*extern%s+crate%s+", multi_line = false },
|
||||
},
|
||||
-- C/C++
|
||||
c = {
|
||||
{ pattern = "^%s*#include%s*[<\"]", multi_line = false },
|
||||
},
|
||||
-- Java/Kotlin
|
||||
java = {
|
||||
{ pattern = "^%s*import%s+", multi_line = false },
|
||||
},
|
||||
-- Ruby
|
||||
ruby = {
|
||||
{ pattern = "^%s*require%s+['\"]", multi_line = false },
|
||||
{ pattern = "^%s*require_relative%s+['\"]", multi_line = false },
|
||||
},
|
||||
-- PHP
|
||||
php = {
|
||||
{ pattern = "^%s*use%s+", multi_line = false },
|
||||
{ pattern = "^%s*require%s+['\"]", multi_line = false },
|
||||
{ pattern = "^%s*require_once%s+['\"]", multi_line = false },
|
||||
{ pattern = "^%s*include%s+['\"]", multi_line = false },
|
||||
{ pattern = "^%s*include_once%s+['\"]", multi_line = false },
|
||||
},
|
||||
}
|
||||
|
||||
-- Alias common extensions to language configs
|
||||
M.import_patterns.ts = M.import_patterns.javascript
|
||||
M.import_patterns.tsx = M.import_patterns.javascript
|
||||
M.import_patterns.jsx = M.import_patterns.javascript
|
||||
M.import_patterns.mjs = M.import_patterns.javascript
|
||||
M.import_patterns.cjs = M.import_patterns.javascript
|
||||
M.import_patterns.py = M.import_patterns.python
|
||||
M.import_patterns.cpp = M.import_patterns.c
|
||||
M.import_patterns.hpp = M.import_patterns.c
|
||||
M.import_patterns.h = M.import_patterns.c
|
||||
M.import_patterns.kt = M.import_patterns.java
|
||||
M.import_patterns.rs = M.import_patterns.rust
|
||||
M.import_patterns.rb = M.import_patterns.ruby
|
||||
|
||||
--- Language-specific comment patterns
|
||||
M.comment_patterns = {
|
||||
lua = { "^%-%-" },
|
||||
python = { "^#" },
|
||||
javascript = { "^//", "^/%*", "^%*" },
|
||||
typescript = { "^//", "^/%*", "^%*" },
|
||||
go = { "^//", "^/%*", "^%*" },
|
||||
rust = { "^//", "^/%*", "^%*" },
|
||||
c = { "^//", "^/%*", "^%*", "^#" },
|
||||
java = { "^//", "^/%*", "^%*" },
|
||||
ruby = { "^#" },
|
||||
php = { "^//", "^/%*", "^%*", "^#" },
|
||||
}
|
||||
|
||||
return M
|
||||
15
lua/codetyper/params/agent/linter.lua
Normal file
15
lua/codetyper/params/agent/linter.lua
Normal file
@@ -0,0 +1,15 @@
|
||||
---@mod codetyper.params.agent.linter Linter configuration
|
||||
local M = {}
|
||||
|
||||
M.config = {
|
||||
-- Auto-save file after code injection
|
||||
auto_save = true,
|
||||
-- Delay in ms to wait for LSP diagnostics to update
|
||||
diagnostic_delay_ms = 500,
|
||||
-- Severity levels to check (1=Error, 2=Warning, 3=Info, 4=Hint)
|
||||
min_severity = vim.diagnostic.severity.WARN,
|
||||
-- Auto-offer to fix lint errors
|
||||
auto_offer_fix = true,
|
||||
}
|
||||
|
||||
return M
|
||||
36
lua/codetyper/params/agent/logs.lua
Normal file
36
lua/codetyper/params/agent/logs.lua
Normal file
@@ -0,0 +1,36 @@
|
||||
---@mod codetyper.params.agent.logs Log parameters
|
||||
local M = {}
|
||||
|
||||
M.icons = {
|
||||
start = "->",
|
||||
success = "OK",
|
||||
error = "ERR",
|
||||
approval = "??",
|
||||
approved = "YES",
|
||||
rejected = "NO",
|
||||
}
|
||||
|
||||
M.level_icons = {
|
||||
info = "i",
|
||||
debug = ".",
|
||||
request = ">",
|
||||
response = "<",
|
||||
tool = "T",
|
||||
error = "!",
|
||||
warning = "?",
|
||||
success = "i",
|
||||
queue = "Q",
|
||||
patch = "P",
|
||||
}
|
||||
|
||||
M.thinking_types = { "thinking", "reason", "action", "task", "result" }
|
||||
|
||||
M.thinking_prefixes = {
|
||||
thinking = "⏺",
|
||||
reason = "⏺",
|
||||
action = "⏺",
|
||||
task = "✶",
|
||||
result = "",
|
||||
}
|
||||
|
||||
return M
|
||||
15
lua/codetyper/params/agent/parser.lua
Normal file
15
lua/codetyper/params/agent/parser.lua
Normal file
@@ -0,0 +1,15 @@
|
||||
---@mod codetyper.params.agent.parser Parser regex patterns
|
||||
local M = {}
|
||||
|
||||
M.patterns = {
|
||||
fenced_json = "```json%s*(%b{})%s*```",
|
||||
inline_json = '(%{"tool"%s*:%s*"[^"]+"%s*,%s*"parameters"%s*:%s*%b{}%})',
|
||||
}
|
||||
|
||||
M.defaults = {
|
||||
stop_reason = "end_turn",
|
||||
tool_stop_reason = "tool_use",
|
||||
replacement_text = "[Tool call]",
|
||||
}
|
||||
|
||||
return M
|
||||
12
lua/codetyper/params/agent/patch.lua
Normal file
12
lua/codetyper/params/agent/patch.lua
Normal file
@@ -0,0 +1,12 @@
|
||||
---@mod codetyper.params.agent.patch Patch configuration
|
||||
local M = {}
|
||||
|
||||
M.config = {
|
||||
snapshot_range = 5, -- Lines above/below prompt to snapshot
|
||||
clean_interval_ms = 60000, -- Check for stale patches every minute
|
||||
max_age_ms = 3600000, -- 1 hour TTL
|
||||
staleness_check = true,
|
||||
use_search_replace_parser = true, -- Enable new parsing logic
|
||||
}
|
||||
|
||||
return M
|
||||
47
lua/codetyper/params/agent/permissions.lua
Normal file
47
lua/codetyper/params/agent/permissions.lua
Normal file
@@ -0,0 +1,47 @@
|
||||
---@mod codetyper.params.agent.permissions Dangerous and safe command patterns
|
||||
local M = {}
|
||||
|
||||
--- Dangerous command patterns that should never be auto-allowed
|
||||
M.dangerous_patterns = {
|
||||
"^rm%s+%-rf",
|
||||
"^rm%s+%-r%s+/",
|
||||
"^rm%s+/",
|
||||
"^sudo%s+rm",
|
||||
"^chmod%s+777",
|
||||
"^chmod%s+%-R",
|
||||
"^chown%s+%-R",
|
||||
"^dd%s+",
|
||||
"^mkfs",
|
||||
"^fdisk",
|
||||
"^format",
|
||||
":.*>%s*/dev/",
|
||||
"^curl.*|.*sh",
|
||||
"^wget.*|.*sh",
|
||||
"^eval%s+",
|
||||
"`;.*`",
|
||||
"%$%(.*%)",
|
||||
"fork%s*bomb",
|
||||
}
|
||||
|
||||
--- Safe command patterns that can be auto-allowed
|
||||
M.safe_patterns = {
|
||||
"^ls%s",
|
||||
"^ls$",
|
||||
"^cat%s",
|
||||
"^head%s",
|
||||
"^tail%s",
|
||||
"^grep%s",
|
||||
"^find%s",
|
||||
"^pwd$",
|
||||
"^echo%s",
|
||||
"^wc%s",
|
||||
"^git%s+status",
|
||||
"^git%s+diff",
|
||||
"^git%s+log",
|
||||
"^git%s+show",
|
||||
"^git%s+branch",
|
||||
"^git%s+checkout",
|
||||
"^git%s+add", -- Generally safe if reviewing changes
|
||||
}
|
||||
|
||||
return M
|
||||
14
lua/codetyper/params/agent/scheduler.lua
Normal file
14
lua/codetyper/params/agent/scheduler.lua
Normal file
@@ -0,0 +1,14 @@
|
||||
---@mod codetyper.params.agent.scheduler Scheduler configuration
|
||||
local M = {}
|
||||
|
||||
M.config = {
|
||||
enabled = true,
|
||||
ollama_scout = true,
|
||||
escalation_threshold = 0.7,
|
||||
max_concurrent = 2,
|
||||
completion_delay_ms = 100,
|
||||
apply_delay_ms = 5000, -- Wait before applying code
|
||||
remote_provider = "copilot", -- Default fallback provider
|
||||
}
|
||||
|
||||
return M
|
||||
72
lua/codetyper/params/agent/scope.lua
Normal file
72
lua/codetyper/params/agent/scope.lua
Normal file
@@ -0,0 +1,72 @@
|
||||
---@mod codetyper.params.agent.scope Tree-sitter scope mappings
|
||||
local M = {}
|
||||
|
||||
--- Node types that represent function-like scopes per language
|
||||
M.function_nodes = {
|
||||
-- Lua
|
||||
["function_declaration"] = "function",
|
||||
["function_definition"] = "function",
|
||||
["local_function"] = "function",
|
||||
["function"] = "function",
|
||||
|
||||
-- JavaScript/TypeScript
|
||||
["function_declaration"] = "function",
|
||||
["function_expression"] = "function",
|
||||
["arrow_function"] = "function",
|
||||
["method_definition"] = "method",
|
||||
["function"] = "function",
|
||||
|
||||
-- Python
|
||||
["function_definition"] = "function",
|
||||
["lambda"] = "function",
|
||||
|
||||
-- Go
|
||||
["function_declaration"] = "function",
|
||||
["method_declaration"] = "method",
|
||||
["func_literal"] = "function",
|
||||
|
||||
-- Rust
|
||||
["function_item"] = "function",
|
||||
["closure_expression"] = "function",
|
||||
|
||||
-- C/C++
|
||||
["function_definition"] = "function",
|
||||
["lambda_expression"] = "function",
|
||||
|
||||
-- Java
|
||||
["method_declaration"] = "method",
|
||||
["constructor_declaration"] = "method",
|
||||
["lambda_expression"] = "function",
|
||||
|
||||
-- Ruby
|
||||
["method"] = "method",
|
||||
["singleton_method"] = "method",
|
||||
["lambda"] = "function",
|
||||
["block"] = "function",
|
||||
|
||||
-- PHP
|
||||
["function_definition"] = "function",
|
||||
["method_declaration"] = "method",
|
||||
["arrow_function"] = "function",
|
||||
}
|
||||
|
||||
--- Node types that represent class-like scopes
|
||||
M.class_nodes = {
|
||||
["class_declaration"] = "class",
|
||||
["class_definition"] = "class",
|
||||
["struct_declaration"] = "class",
|
||||
["impl_item"] = "class", -- Rust config
|
||||
["interface_declaration"] = "class",
|
||||
["trait_item"] = "class",
|
||||
}
|
||||
|
||||
--- Node types that represent block scopes
|
||||
M.block_nodes = {
|
||||
["block"] = "block",
|
||||
["do_statement"] = "block", -- Lua
|
||||
["if_statement"] = "block",
|
||||
["for_statement"] = "block",
|
||||
["while_statement"] = "block",
|
||||
}
|
||||
|
||||
return M
|
||||
11
lua/codetyper/params/agent/search_replace.lua
Normal file
11
lua/codetyper/params/agent/search_replace.lua
Normal file
@@ -0,0 +1,11 @@
|
||||
---@mod codetyper.params.agent.search_replace Search/Replace patterns
|
||||
local M = {}
|
||||
|
||||
M.patterns = {
|
||||
dash_style = "%-%-%-%-%-%-%-?%s*SEARCH%s*\n(.-)\n=======%s*\n(.-)\n%+%+%+%+%+%+%+?%s*REPLACE",
|
||||
claude_style = "<<<<<<<[%s]*SEARCH%s*\n(.-)\n=======%s*\n(.-)\n>>>>>>>[%s]*REPLACE",
|
||||
simple_style = "%[SEARCH%]%s*\n(.-)\n%[REPLACE%]%s*\n(.-)\n%[END%]",
|
||||
diff_block = "```diff\n(.-)\n```",
|
||||
}
|
||||
|
||||
return M
|
||||
147
lua/codetyper/params/agent/tools.lua
Normal file
147
lua/codetyper/params/agent/tools.lua
Normal file
@@ -0,0 +1,147 @@
|
||||
---@mod codetyper.params.agent.tools Tool definitions
|
||||
local M = {}
|
||||
|
||||
--- Tool definitions in a provider-agnostic format
|
||||
M.definitions = {
|
||||
read_file = {
|
||||
name = "read_file",
|
||||
description = "Read the contents of a file at the specified path",
|
||||
parameters = {
|
||||
type = "object",
|
||||
properties = {
|
||||
path = {
|
||||
type = "string",
|
||||
description = "The path to the file to read",
|
||||
},
|
||||
start_line = {
|
||||
type = "number",
|
||||
description = "Optional start line number (1-indexed)",
|
||||
},
|
||||
end_line = {
|
||||
type = "number",
|
||||
description = "Optional end line number (1-indexed)",
|
||||
},
|
||||
},
|
||||
required = { "path" },
|
||||
},
|
||||
},
|
||||
|
||||
edit_file = {
|
||||
name = "edit_file",
|
||||
description = "Edit a file by replacing specific content. Provide the exact content to find and the replacement.",
|
||||
parameters = {
|
||||
type = "object",
|
||||
properties = {
|
||||
path = {
|
||||
type = "string",
|
||||
description = "The path to the file to edit",
|
||||
},
|
||||
find = {
|
||||
type = "string",
|
||||
description = "The exact content to replace",
|
||||
},
|
||||
replace = {
|
||||
type = "string",
|
||||
description = "The new content",
|
||||
},
|
||||
},
|
||||
required = { "path", "find", "replace" },
|
||||
},
|
||||
},
|
||||
|
||||
write_file = {
|
||||
name = "write_file",
|
||||
description = "Write content to a file, creating it if it doesn't exist or overwriting if it does",
|
||||
parameters = {
|
||||
type = "object",
|
||||
properties = {
|
||||
path = {
|
||||
type = "string",
|
||||
description = "The path to the file to write",
|
||||
},
|
||||
content = {
|
||||
type = "string",
|
||||
description = "The content to write",
|
||||
},
|
||||
},
|
||||
required = { "path", "content" },
|
||||
},
|
||||
},
|
||||
|
||||
bash = {
|
||||
name = "bash",
|
||||
description = "Execute a bash command and return the output. Use for git, npm, build tools, etc.",
|
||||
parameters = {
|
||||
type = "object",
|
||||
properties = {
|
||||
command = {
|
||||
type = "string",
|
||||
description = "The bash command to execute",
|
||||
},
|
||||
},
|
||||
required = { "command" },
|
||||
},
|
||||
},
|
||||
|
||||
delete_file = {
|
||||
name = "delete_file",
|
||||
description = "Delete a file",
|
||||
parameters = {
|
||||
type = "object",
|
||||
properties = {
|
||||
path = {
|
||||
type = "string",
|
||||
description = "The path to the file to delete",
|
||||
},
|
||||
reason = {
|
||||
type = "string",
|
||||
description = "Reason for deletion",
|
||||
},
|
||||
},
|
||||
required = { "path", "reason" },
|
||||
},
|
||||
},
|
||||
|
||||
list_directory = {
|
||||
name = "list_directory",
|
||||
description = "List files and directories in a path",
|
||||
parameters = {
|
||||
type = "object",
|
||||
properties = {
|
||||
path = {
|
||||
type = "string",
|
||||
description = "The path to list",
|
||||
},
|
||||
recursive = {
|
||||
type = "boolean",
|
||||
description = "Whether to list recursively",
|
||||
},
|
||||
},
|
||||
required = { "path" },
|
||||
},
|
||||
},
|
||||
|
||||
search_files = {
|
||||
name = "search_files",
|
||||
description = "Search for files by name/glob pattern or content",
|
||||
parameters = {
|
||||
type = "object",
|
||||
properties = {
|
||||
pattern = {
|
||||
type = "string",
|
||||
description = "Glob pattern to search for filenames",
|
||||
},
|
||||
content = {
|
||||
type = "string",
|
||||
description = "Content string to search for within files",
|
||||
},
|
||||
path = {
|
||||
type = "string",
|
||||
description = "The root path to start search",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
return M
|
||||
30
lua/codetyper/params/agent/worker.lua
Normal file
30
lua/codetyper/params/agent/worker.lua
Normal file
@@ -0,0 +1,30 @@
|
||||
---@mod codetyper.params.agent.worker Worker configuration and patterns
|
||||
local M = {}
|
||||
|
||||
--- Patterns that indicate LLM needs more context (must be near start of response)
|
||||
M.context_needed_patterns = {
|
||||
"I need to see",
|
||||
"Could you provide",
|
||||
"Please provide",
|
||||
"Can you show",
|
||||
"don't have enough context",
|
||||
"need more information",
|
||||
"cannot see the definition",
|
||||
"missing the implementation",
|
||||
"I would need to check",
|
||||
"please share",
|
||||
"Please upload",
|
||||
"could not find",
|
||||
}
|
||||
|
||||
--- Default timeouts by provider type
|
||||
M.default_timeouts = {
|
||||
openai = 60000, -- 60s
|
||||
anthropic = 90000, -- 90s
|
||||
google = 60000, -- 60s
|
||||
ollama = 120000, -- 120s (local models can be slower)
|
||||
copilot = 60000, -- 60s
|
||||
default = 60000,
|
||||
}
|
||||
|
||||
return M
|
||||
Reference in New Issue
Block a user