Refactor: Restructure project into core, features, adapters, and config modules

This commit is contained in:
2026-01-16 11:52:46 -05:00
parent 4fb52596e3
commit 10c1de8843
83 changed files with 337 additions and 337 deletions

View File

@@ -2,7 +2,7 @@
local M = {}
local utils = require("codetyper.utils")
local utils = require("codetyper.support.utils")
--- Autocommand group name
local AUGROUP = "Codetyper"
@@ -43,7 +43,7 @@ local function schedule_tree_update()
end
tree_update_timer = vim.defer_fn(function()
local tree = require("codetyper.tree")
local tree = require("codetyper.support.tree")
tree.update_tree_log()
tree_update_timer = nil
end, TREE_UPDATE_DEBOUNCE_MS)
@@ -179,7 +179,7 @@ function M.setup()
group = group,
pattern = "*.coder.*",
callback = function(ev)
local window = require("codetyper.window")
local window = require("codetyper.adapters.nvim.windows")
if window.is_open() then
window.close_split()
end
@@ -397,11 +397,11 @@ function M.check_for_closed_prompt()
if scheduler_enabled then
-- Event-driven: emit to queue
vim.schedule(function()
local queue = require("codetyper.agent.queue")
local patch_mod = require("codetyper.agent.patch")
local intent_mod = require("codetyper.agent.intent")
local scope_mod = require("codetyper.agent.scope")
local logs_panel = require("codetyper.logs_panel")
local queue = require("codetyper.core.events.queue")
local patch_mod = require("codetyper.core.diff.patch")
local intent_mod = require("codetyper.core.intent")
local scope_mod = require("codetyper.core.scope")
local logs_panel = require("codetyper.adapters.nvim.ui.logs_panel")
-- Open logs panel to show progress
logs_panel.ensure_open()
@@ -543,7 +543,7 @@ end
---@param skip_processed_check? boolean Skip the processed check (for manual mode)
function M.process_single_prompt(bufnr, prompt, current_file, skip_processed_check)
local parser = require("codetyper.parser")
local scheduler = require("codetyper.agent.scheduler")
local scheduler = require("codetyper.core.scheduler.scheduler")
if not prompt.content or prompt.content == "" then
return
@@ -567,11 +567,11 @@ function M.process_single_prompt(bufnr, prompt, current_file, skip_processed_che
-- Process this prompt
vim.schedule(function()
local queue = require("codetyper.agent.queue")
local patch_mod = require("codetyper.agent.patch")
local intent_mod = require("codetyper.agent.intent")
local scope_mod = require("codetyper.agent.scope")
local logs_panel = require("codetyper.logs_panel")
local queue = require("codetyper.core.events.queue")
local patch_mod = require("codetyper.core.diff.patch")
local intent_mod = require("codetyper.core.intent")
local scope_mod = require("codetyper.core.scope")
local logs_panel = require("codetyper.adapters.nvim.ui.logs_panel")
-- Open logs panel to show progress
logs_panel.ensure_open()
@@ -840,7 +840,7 @@ local auto_opened_buffers = {}
--- Auto-open target file when a coder file is opened directly
function M.auto_open_target_file()
local window = require("codetyper.window")
local window = require("codetyper.adapters.nvim.windows")
-- Skip if split is already open
if window.is_open() then
@@ -1508,7 +1508,7 @@ function M.open_coder_companion(open_split)
if open_split then
-- Use the window module to open split view
local window = require("codetyper.window")
local window = require("codetyper.adapters.nvim.windows")
window.open_split(coder_path, filepath)
else
-- Just open the coder file

View File

@@ -2,8 +2,8 @@
local M = {}
local utils = require("codetyper.utils")
local window = require("codetyper.window")
local utils = require("codetyper.support.utils")
local window = require("codetyper.adapters.nvim.windows")
--- Open coder view for current file or select one
---@param opts? table Command options
@@ -108,7 +108,7 @@ end
--- Process prompt at cursor and generate code
local function cmd_process()
local parser = require("codetyper.parser")
local llm = require("codetyper.llm")
local llm = require("codetyper.core.llm")
local bufnr = vim.api.nvim_get_current_buf()
local current_file = vim.fn.expand("%:p")
@@ -153,7 +153,7 @@ end
local function cmd_status()
local codetyper = require("codetyper")
local config = codetyper.get_config()
local tree = require("codetyper.tree")
local tree = require("codetyper.support.tree")
local stats = tree.get_stats()
@@ -195,7 +195,7 @@ end
--- Refresh tree.log manually
local function cmd_tree()
local tree = require("codetyper.tree")
local tree = require("codetyper.support.tree")
if tree.update_tree_log() then
utils.notify("Tree log updated: " .. tree.get_tree_log_path())
else
@@ -205,7 +205,7 @@ end
--- Open tree.log file
local function cmd_tree_view()
local tree = require("codetyper.tree")
local tree = require("codetyper.support.tree")
local tree_log_path = tree.get_tree_log_path()
if not tree_log_path then
@@ -224,63 +224,63 @@ end
--- Reset processed prompts to allow re-processing
local function cmd_reset()
local autocmds = require("codetyper.autocmds")
local autocmds = require("codetyper.adapters.nvim.autocmds")
autocmds.reset_processed()
end
--- Force update gitignore
local function cmd_gitignore()
local gitignore = require("codetyper.gitignore")
local gitignore = require("codetyper.support.gitignore")
gitignore.force_update()
end
--- Open ask panel (with optional visual selection)
---@param selection table|nil Visual selection info
local function cmd_ask(selection)
local ask = require("codetyper.ask")
local ask = require("codetyper.features.ask.engine")
ask.open(selection)
end
--- Close ask panel
local function cmd_ask_close()
local ask = require("codetyper.ask")
local ask = require("codetyper.features.ask.engine")
ask.close()
end
--- Toggle ask panel
local function cmd_ask_toggle()
local ask = require("codetyper.ask")
local ask = require("codetyper.features.ask.engine")
ask.toggle()
end
--- Clear ask history
local function cmd_ask_clear()
local ask = require("codetyper.ask")
local ask = require("codetyper.features.ask.engine")
ask.clear_history()
end
--- Open agent panel (with optional visual selection)
---@param selection table|nil Visual selection info
local function cmd_agent(selection)
local agent_ui = require("codetyper.agent.ui")
local agent_ui = require("codetyper.adapters.nvim.ui.chat")
agent_ui.open(selection)
end
--- Close agent panel
local function cmd_agent_close()
local agent_ui = require("codetyper.agent.ui")
local agent_ui = require("codetyper.adapters.nvim.ui.chat")
agent_ui.close()
end
--- Toggle agent panel
local function cmd_agent_toggle()
local agent_ui = require("codetyper.agent.ui")
local agent_ui = require("codetyper.adapters.nvim.ui.chat")
agent_ui.toggle()
end
--- Stop running agent
local function cmd_agent_stop()
local agent = require("codetyper.agent")
local agent = require("codetyper.features.agents")
if agent.is_running() then
agent.stop()
utils.notify("Agent stopped")
@@ -293,9 +293,9 @@ end
---@param task string The task to accomplish
---@param agent_name? string Optional agent name
local function cmd_agentic_run(task, agent_name)
local agentic = require("codetyper.agent.agentic")
local logs_panel = require("codetyper.logs_panel")
local logs = require("codetyper.agent.logs")
local agentic = require("codetyper.features.agents.engine")
local logs_panel = require("codetyper.adapters.nvim.ui.logs_panel")
local logs = require("codetyper.adapters.nvim.ui.logs")
-- Open logs panel
logs_panel.open()
@@ -355,7 +355,7 @@ end
--- List available agents
local function cmd_agentic_list()
local agentic = require("codetyper.agent.agentic")
local agentic = require("codetyper.features.agents.engine")
local agents = agentic.list_agents()
local lines = {
@@ -379,7 +379,7 @@ end
--- Initialize .coder/agents/ and .coder/rules/ directories
local function cmd_agentic_init()
local agentic = require("codetyper.agent.agentic")
local agentic = require("codetyper.features.agents.engine")
agentic.init()
local agents_dir = vim.fn.getcwd() .. "/.coder/agents"
@@ -409,14 +409,14 @@ end
--- Toggle logs panel
local function cmd_logs_toggle()
local logs_panel = require("codetyper.logs_panel")
local logs_panel = require("codetyper.adapters.nvim.ui.logs_panel")
logs_panel.toggle()
end
--- Show scheduler status and queue info
local function cmd_queue_status()
local scheduler = require("codetyper.agent.scheduler")
local queue = require("codetyper.agent.queue")
local scheduler = require("codetyper.core.scheduler.scheduler")
local queue = require("codetyper.core.events.queue")
local parser = require("codetyper.parser")
local status = scheduler.status()
@@ -455,8 +455,8 @@ end
--- Manually trigger queue processing for current buffer
local function cmd_queue_process()
local autocmds = require("codetyper.autocmds")
local logs_panel = require("codetyper.logs_panel")
local autocmds = require("codetyper.adapters.nvim.autocmds")
local logs_panel = require("codetyper.adapters.nvim.ui.logs_panel")
-- Open logs panel to show progress
logs_panel.open()
@@ -487,9 +487,9 @@ end
--- Uses the same processing logic as automatic mode for consistent results
local function cmd_transform()
local parser = require("codetyper.parser")
local autocmds = require("codetyper.autocmds")
local logs_panel = require("codetyper.logs_panel")
local logs = require("codetyper.agent.logs")
local autocmds = require("codetyper.adapters.nvim.autocmds")
local logs_panel = require("codetyper.adapters.nvim.ui.logs_panel")
local logs = require("codetyper.adapters.nvim.ui.logs")
local bufnr = vim.api.nvim_get_current_buf()
local filepath = vim.fn.expand("%:p")
@@ -527,9 +527,9 @@ end
---@param end_line number End line (1-indexed)
local function cmd_transform_range(start_line, end_line)
local parser = require("codetyper.parser")
local autocmds = require("codetyper.autocmds")
local logs_panel = require("codetyper.logs_panel")
local logs = require("codetyper.agent.logs")
local autocmds = require("codetyper.adapters.nvim.autocmds")
local logs_panel = require("codetyper.adapters.nvim.ui.logs_panel")
local logs = require("codetyper.adapters.nvim.ui.logs")
local bufnr = vim.api.nvim_get_current_buf()
local filepath = vim.fn.expand("%:p")
@@ -579,7 +579,7 @@ end
--- Index the entire project
local function cmd_index_project()
local indexer = require("codetyper.indexer")
local indexer = require("codetyper.features.indexer")
utils.notify("Indexing project...", vim.log.levels.INFO)
@@ -601,8 +601,8 @@ end
--- Show index status
local function cmd_index_status()
local indexer = require("codetyper.indexer")
local memory = require("codetyper.indexer.memory")
local indexer = require("codetyper.features.indexer")
local memory = require("codetyper.features.indexer.memory")
local status = indexer.get_status()
local mem_stats = memory.get_stats()
@@ -639,7 +639,7 @@ end
--- Show learned memories
local function cmd_memories()
local memory = require("codetyper.indexer.memory")
local memory = require("codetyper.features.indexer.memory")
local all = memory.get_all()
local lines = {
@@ -684,7 +684,7 @@ end
--- Clear memories
---@param pattern string|nil Optional pattern to match
local function cmd_forget(pattern)
local memory = require("codetyper.indexer.memory")
local memory = require("codetyper.features.indexer.memory")
if not pattern or pattern == "" then
-- Confirm before clearing all
@@ -706,9 +706,9 @@ end
--- Uses the same processing logic as automatic mode for consistent results
local function cmd_transform_at_cursor()
local parser = require("codetyper.parser")
local autocmds = require("codetyper.autocmds")
local logs_panel = require("codetyper.logs_panel")
local logs = require("codetyper.agent.logs")
local autocmds = require("codetyper.adapters.nvim.autocmds")
local logs_panel = require("codetyper.adapters.nvim.ui.logs_panel")
local logs = require("codetyper.adapters.nvim.ui.logs")
local bufnr = vim.api.nvim_get_current_buf()
local filepath = vim.fn.expand("%:p")
@@ -741,7 +741,7 @@ end
---@param args table Command arguments
--- Show LLM accuracy statistics
local function cmd_llm_stats()
local llm = require("codetyper.llm")
local llm = require("codetyper.core.llm")
local stats = llm.get_accuracy_stats()
local lines = {
@@ -769,13 +769,13 @@ end
--- Report feedback on last LLM response
---@param was_good boolean Whether the response was good
local function cmd_llm_feedback(was_good)
local llm = require("codetyper.llm")
local llm = require("codetyper.core.llm")
-- Get the last used provider from logs or default
local provider = "ollama" -- Default assumption
-- Try to get actual last provider from logs
pcall(function()
local logs = require("codetyper.agent.logs")
local logs = require("codetyper.adapters.nvim.ui.logs")
local entries = logs.get(10)
for i = #entries, 1, -1 do
local entry = entries[i]
@@ -793,7 +793,7 @@ end
--- Reset LLM accuracy statistics
local function cmd_llm_reset_stats()
local selector = require("codetyper.llm.selector")
local selector = require("codetyper.core.llm.selector")
selector.reset_accuracy_stats()
utils.notify("LLM accuracy statistics reset", vim.log.levels.INFO)
end
@@ -877,11 +877,11 @@ local function coder_cmd(args)
["llm-reset-stats"] = cmd_llm_reset_stats,
-- Cost tracking commands
["cost"] = function()
local cost = require("codetyper.cost")
local cost = require("codetyper.core.cost")
cost.toggle()
end,
["cost-clear"] = function()
local cost = require("codetyper.cost")
local cost = require("codetyper.core.cost")
cost.clear()
end,
-- Credentials management commands
@@ -1069,7 +1069,7 @@ function M.setup()
-- Index command - open coder companion for current file
vim.api.nvim_create_user_command("CoderIndex", function()
local autocmds = require("codetyper.autocmds")
local autocmds = require("codetyper.adapters.nvim.autocmds")
autocmds.open_coder_companion()
end, { desc = "Open coder companion for current file" })
@@ -1137,7 +1137,7 @@ function M.setup()
-- Brain feedback command - teach the brain from your experience
vim.api.nvim_create_user_command("CoderFeedback", function(opts)
local brain = require("codetyper.brain")
local brain = require("codetyper.core.memory")
if not brain.is_initialized() then
vim.notify("Brain not initialized", vim.log.levels.WARN)
return
@@ -1197,7 +1197,7 @@ function M.setup()
-- Brain stats command
vim.api.nvim_create_user_command("CoderBrain", function(opts)
local brain = require("codetyper.brain")
local brain = require("codetyper.core.memory")
if not brain.is_initialized() then
vim.notify("Brain not initialized", vim.log.levels.WARN)
return
@@ -1251,7 +1251,7 @@ function M.setup()
-- Cost estimation command
vim.api.nvim_create_user_command("CoderCost", function()
local cost = require("codetyper.cost")
local cost = require("codetyper.core.cost")
cost.toggle()
end, { desc = "Show LLM cost estimation window" })
@@ -1315,14 +1315,14 @@ function M.setup()
-- Conflict mode commands
vim.api.nvim_create_user_command("CoderConflictToggle", function()
local patch = require("codetyper.agent.patch")
local patch = require("codetyper.core.diff.patch")
local current = patch.is_conflict_mode()
patch.configure({ use_conflict_mode = not current })
utils.notify("Conflict mode " .. (not current and "enabled" or "disabled"), vim.log.levels.INFO)
end, { desc = "Toggle conflict mode for code changes" })
vim.api.nvim_create_user_command("CoderConflictResolveAll", function(opts)
local conflict = require("codetyper.agent.conflict")
local conflict = require("codetyper.core.diff.conflict")
local bufnr = vim.api.nvim_get_current_buf()
local keep = opts.args ~= "" and opts.args or "theirs"
if not vim.tbl_contains({ "ours", "theirs", "both", "none" }, keep) then
@@ -1338,18 +1338,18 @@ function M.setup()
})
vim.api.nvim_create_user_command("CoderConflictNext", function()
local conflict = require("codetyper.agent.conflict")
local conflict = require("codetyper.core.diff.conflict")
conflict.goto_next(vim.api.nvim_get_current_buf())
end, { desc = "Go to next conflict" })
vim.api.nvim_create_user_command("CoderConflictPrev", function()
local conflict = require("codetyper.agent.conflict")
local conflict = require("codetyper.core.diff.conflict")
conflict.goto_prev(vim.api.nvim_get_current_buf())
end, { desc = "Go to previous conflict" })
vim.api.nvim_create_user_command("CoderConflictStatus", function()
local conflict = require("codetyper.agent.conflict")
local patch = require("codetyper.agent.patch")
local conflict = require("codetyper.core.diff.conflict")
local patch = require("codetyper.core.diff.patch")
local bufnr = vim.api.nvim_get_current_buf()
local count = conflict.count_conflicts(bufnr)
local mode = patch.is_conflict_mode() and "enabled" or "disabled"
@@ -1357,7 +1357,7 @@ function M.setup()
end, { desc = "Show conflict status" })
vim.api.nvim_create_user_command("CoderConflictMenu", function()
local conflict = require("codetyper.agent.conflict")
local conflict = require("codetyper.core.diff.conflict")
local bufnr = vim.api.nvim_get_current_buf()
-- Ensure conflicts are processed first (sets up highlights and keymaps)
conflict.process(bufnr)
@@ -1366,35 +1366,35 @@ function M.setup()
-- Manual commands to accept conflicts
vim.api.nvim_create_user_command("CoderConflictAcceptCurrent", function()
local conflict = require("codetyper.agent.conflict")
local conflict = require("codetyper.core.diff.conflict")
local bufnr = vim.api.nvim_get_current_buf()
conflict.process(bufnr) -- Ensure keymaps are set up
conflict.accept_ours(bufnr)
end, { desc = "Accept current (original) code" })
vim.api.nvim_create_user_command("CoderConflictAcceptIncoming", function()
local conflict = require("codetyper.agent.conflict")
local conflict = require("codetyper.core.diff.conflict")
local bufnr = vim.api.nvim_get_current_buf()
conflict.process(bufnr) -- Ensure keymaps are set up
conflict.accept_theirs(bufnr)
end, { desc = "Accept incoming (AI) code" })
vim.api.nvim_create_user_command("CoderConflictAcceptBoth", function()
local conflict = require("codetyper.agent.conflict")
local conflict = require("codetyper.core.diff.conflict")
local bufnr = vim.api.nvim_get_current_buf()
conflict.process(bufnr)
conflict.accept_both(bufnr)
end, { desc = "Accept both versions" })
vim.api.nvim_create_user_command("CoderConflictAcceptNone", function()
local conflict = require("codetyper.agent.conflict")
local conflict = require("codetyper.core.diff.conflict")
local bufnr = vim.api.nvim_get_current_buf()
conflict.process(bufnr)
conflict.accept_none(bufnr)
end, { desc = "Delete conflict (accept none)" })
vim.api.nvim_create_user_command("CoderConflictAutoMenu", function()
local conflict = require("codetyper.agent.conflict")
local conflict = require("codetyper.core.diff.conflict")
local conf = conflict.get_config()
local new_state = not conf.auto_show_menu
conflict.configure({ auto_show_menu = new_state, auto_show_next_menu = new_state })
@@ -1402,12 +1402,12 @@ function M.setup()
end, { desc = "Toggle auto-show conflict menu after code injection" })
-- Initialize conflict module
local conflict = require("codetyper.agent.conflict")
local conflict = require("codetyper.core.diff.conflict")
conflict.setup()
-- Linter validation commands
vim.api.nvim_create_user_command("CoderLintCheck", function()
local linter = require("codetyper.agent.linter")
local linter = require("codetyper.features.agents.linter")
local bufnr = vim.api.nvim_get_current_buf()
linter.validate_after_injection(bufnr, nil, nil, function(result)
if result then
@@ -1419,7 +1419,7 @@ function M.setup()
end, { desc = "Check current buffer for lint errors" })
vim.api.nvim_create_user_command("CoderLintFix", function()
local linter = require("codetyper.agent.linter")
local linter = require("codetyper.features.agents.linter")
local bufnr = vim.api.nvim_get_current_buf()
local line_count = vim.api.nvim_buf_line_count(bufnr)
local result = linter.check_region(bufnr, 1, line_count)
@@ -1431,7 +1431,7 @@ function M.setup()
end, { desc = "Request AI to fix lint errors in current buffer" })
vim.api.nvim_create_user_command("CoderLintQuickfix", function()
local linter = require("codetyper.agent.linter")
local linter = require("codetyper.features.agents.linter")
local bufnr = vim.api.nvim_get_current_buf()
local line_count = vim.api.nvim_buf_line_count(bufnr)
local result = linter.check_region(bufnr, 1, line_count)
@@ -1443,8 +1443,8 @@ function M.setup()
end, { desc = "Show lint errors in quickfix list" })
vim.api.nvim_create_user_command("CoderLintToggleAuto", function()
local conflict = require("codetyper.agent.conflict")
local linter = require("codetyper.agent.linter")
local conflict = require("codetyper.core.diff.conflict")
local linter = require("codetyper.features.agents.linter")
local linter_config = linter.get_config()
local new_state = not linter_config.auto_save
linter.configure({ auto_save = new_state })

View File

@@ -4,9 +4,9 @@
local M = {}
local agent = require("codetyper.agent")
local logs = require("codetyper.agent.logs")
local utils = require("codetyper.utils")
local agent = require("codetyper.features.agents")
local logs = require("codetyper.adapters.nvim.ui.logs")
local utils = require("codetyper.support.utils")
---@class AgentUIState
---@field chat_buf number|nil Chat buffer
@@ -321,7 +321,7 @@ local function submit_input()
vim.bo[state.chat_buf].modifiable = false
end
-- Also clear collected diffs
local diff_review = require("codetyper.agent.diff_review")
local diff_review = require("codetyper.adapters.nvim.ui.diff_review")
diff_review.clear()
return
end
@@ -387,7 +387,7 @@ local function submit_input()
current_file = vim.fn.expand("%:p")
end
local llm = require("codetyper.llm")
local llm = require("codetyper.core.llm")
local context = {}
if current_file ~= "" and vim.fn.filereadable(current_file) == 1 then

View File

@@ -304,7 +304,7 @@ function M.open(original_event, llm_response, callback, suggested_commands)
-- Log
pcall(function()
local logs = require("codetyper.agent.logs")
local logs = require("codetyper.adapters.nvim.ui.logs")
logs.add({
type = "info",
message = "Context modal opened - waiting for user input",

View File

@@ -5,7 +5,7 @@
local M = {}
local utils = require("codetyper.utils")
local utils = require("codetyper.support.utils")
local prompts = require("codetyper.prompts.agent.diff")

View File

@@ -4,8 +4,8 @@
local M = {}
local logs = require("codetyper.agent.logs")
local queue = require("codetyper.agent.queue")
local logs = require("codetyper.adapters.nvim.ui.logs")
local queue = require("codetyper.core.events.queue")
---@class LogsPanelState
---@field buf number|nil Logs buffer

View File

@@ -20,8 +20,8 @@ function M.show()
end
-- Close current panel first
local ask = require("codetyper.ask")
local agent_ui = require("codetyper.agent.ui")
local ask = require("codetyper.features.ask.engine")
local agent_ui = require("codetyper.adapters.nvim.ui.chat")
if ask.is_open() then
ask.close()

View File

@@ -2,7 +2,7 @@
local M = {}
local utils = require("codetyper.utils")
local utils = require("codetyper.support.utils")
---@type number|nil Current coder window ID
M._coder_win = nil
@@ -43,7 +43,7 @@ function M.open_split(target_path, coder_path)
utils.write_file(coder_path, "")
-- Ensure gitignore is updated when creating a new coder file
local gitignore = require("codetyper.gitignore")
local gitignore = require("codetyper.support.gitignore")
gitignore.ensure_ignored()
end

View File

@@ -6,7 +6,7 @@
local M = {}
local utils = require("codetyper.utils")
local utils = require("codetyper.support.utils")
--- Get the credentials file path
---@return string Path to credentials file

View File

@@ -6,7 +6,7 @@
local M = {}
local utils = require("codetyper.utils")
local utils = require("codetyper.support.utils")
---@class CoderPreferences
---@field auto_process boolean Whether to auto-process /@ @/ tags (default: nil = ask)

View File

@@ -6,7 +6,7 @@
local M = {}
local utils = require("codetyper.utils")
local utils = require("codetyper.support.utils")
--- Cost history file name
local COST_HISTORY_FILE = "cost_history.json"

View File

@@ -19,7 +19,7 @@ local params = require("codetyper.params.agent.conflict")
--- Lazy load linter module
local function get_linter()
return require("codetyper.agent.linter")
return require("codetyper.features.agents.linter")
end
--- Configuration
@@ -66,7 +66,7 @@ local function validate_after_accept(bufnr, start_line, end_line, accepted_type)
-- If errors found and auto-fix is enabled, queue fix automatically
if result.has_errors and config.auto_fix_lint_errors then
pcall(function()
local logs = require("codetyper.agent.logs")
local logs = require("codetyper.adapters.nvim.ui.logs")
logs.add({
type = "info",
message = "Auto-queuing fix for lint errors...",
@@ -954,7 +954,7 @@ function M.process(bufnr)
-- Log
pcall(function()
local logs = require("codetyper.agent.logs")
local logs = require("codetyper.adapters.nvim.ui.logs")
logs.info(string.format("Found %d conflict(s) - use co/ct/cb/cn to resolve, [x/]x to navigate", #conflicts))
end)
else

View File

@@ -178,7 +178,7 @@ end
---@param command string The bash command to approve
---@param callback fun(result: BashApprovalResult) Called with user decision
function M.show_bash_approval(command, callback)
local permissions = require("codetyper.agent.permissions")
local permissions = require("codetyper.features.agents.permissions")
-- Check if command is auto-approved
local perm_result = permissions.check_bash_permission(command)

View File

@@ -12,17 +12,17 @@ local params = require("codetyper.params.agent.patch")
--- Lazy load inject module to avoid circular requires
local function get_inject_module()
return require("codetyper.agent.inject")
return require("codetyper.inject")
end
--- Lazy load search_replace module
local function get_search_replace_module()
return require("codetyper.agent.search_replace")
return require("codetyper.core.diff.search_replace")
end
--- Lazy load conflict module
local function get_conflict_module()
return require("codetyper.agent.conflict")
return require("codetyper.core.diff.conflict")
end
--- Configuration for patch behavior
@@ -170,7 +170,7 @@ function M.queue_patch(patch)
-- Log patch creation
pcall(function()
local logs = require("codetyper.agent.logs")
local logs = require("codetyper.adapters.nvim.ui.logs")
logs.add({
type = "patch",
message = string.format(
@@ -236,14 +236,14 @@ function M.create_from_event(event, generated_code, confidence, strategy)
if use_search_replace then
injection_strategy = "search_replace"
pcall(function()
local logs = require("codetyper.agent.logs")
local logs = require("codetyper.adapters.nvim.ui.logs")
logs.add({
type = "info",
message = string.format("Using SEARCH/REPLACE mode with %d block(s)", #sr_blocks),
})
end)
elseif not injection_strategy and event.intent then
local intent_mod = require("codetyper.agent.intent")
local intent_mod = require("codetyper.core.intent")
if intent_mod.is_replacement(event.intent) then
injection_strategy = "replace"
@@ -255,7 +255,7 @@ function M.create_from_event(event, generated_code, confidence, strategy)
end_line = event.range.end_line,
}
pcall(function()
local logs = require("codetyper.agent.logs")
local logs = require("codetyper.adapters.nvim.ui.logs")
logs.add({
type = "info",
message = string.format("Inline prompt: will replace tag region (lines %d-%d)",
@@ -273,7 +273,7 @@ function M.create_from_event(event, generated_code, confidence, strategy)
end_line = event.range.end_line,
}
pcall(function()
local logs = require("codetyper.agent.logs")
local logs = require("codetyper.adapters.nvim.ui.logs")
logs.add({
type = "warning",
message = "No scope found, using tag range as fallback",
@@ -510,7 +510,7 @@ function M.apply(patch)
M.mark_stale(patch.id, stale_reason)
pcall(function()
local logs = require("codetyper.agent.logs")
local logs = require("codetyper.adapters.nvim.ui.logs")
logs.add({
type = "warning",
message = string.format("Patch %s is stale: %s", patch.id, stale_reason or "unknown"),
@@ -549,7 +549,7 @@ function M.apply(patch)
pcall(function()
if tags_removed > 0 then
local logs = require("codetyper.agent.logs")
local logs = require("codetyper.adapters.nvim.ui.logs")
local source_name = vim.api.nvim_buf_get_name(source_bufnr)
logs.add({
type = "info",
@@ -573,7 +573,7 @@ function M.apply(patch)
tags_removed = remove_prompt_tags(source_bufnr)
if tags_removed > 0 then
pcall(function()
local logs = require("codetyper.agent.logs")
local logs = require("codetyper.adapters.nvim.ui.logs")
logs.add({
type = "info",
message = string.format("Removed %d prompt tag(s)", tags_removed),
@@ -589,7 +589,7 @@ function M.apply(patch)
M.mark_applied(patch.id)
pcall(function()
local logs = require("codetyper.agent.logs")
local logs = require("codetyper.adapters.nvim.ui.logs")
logs.add({
type = "success",
message = string.format("Patch %s applied via SEARCH/REPLACE (%d block(s))",
@@ -603,7 +603,7 @@ function M.apply(patch)
-- Learn from successful code generation
pcall(function()
local brain = require("codetyper.brain")
local brain = require("codetyper.core.memory")
if brain.is_initialized() then
local intent_type = patch.intent and patch.intent.type or "unknown"
brain.learn({
@@ -624,7 +624,7 @@ function M.apply(patch)
else
-- SEARCH/REPLACE failed, log the error
pcall(function()
local logs = require("codetyper.agent.logs")
local logs = require("codetyper.adapters.nvim.ui.logs")
logs.add({
type = "warning",
message = string.format("SEARCH/REPLACE failed: %s. Falling back to line-based injection.", err or "unknown"),
@@ -723,7 +723,7 @@ function M.apply(patch)
-- Log inline prompt handling
if is_inline_prompt then
pcall(function()
local logs = require("codetyper.agent.logs")
local logs = require("codetyper.adapters.nvim.ui.logs")
logs.add({
type = "info",
message = string.format("Inline prompt: replacing lines %d-%d",
@@ -738,7 +738,7 @@ function M.apply(patch)
-- Log injection details
pcall(function()
local logs = require("codetyper.agent.logs")
local logs = require("codetyper.adapters.nvim.ui.logs")
if inject_result.imports_added > 0 then
logs.add({
type = "info",
@@ -766,7 +766,7 @@ function M.apply(patch)
M.mark_applied(patch.id)
pcall(function()
local logs = require("codetyper.agent.logs")
local logs = require("codetyper.adapters.nvim.ui.logs")
logs.add({
type = "success",
message = string.format("Patch %s applied successfully", patch.id),
@@ -780,7 +780,7 @@ function M.apply(patch)
-- Learn from successful code generation - this builds neural pathways
-- The more code is successfully applied, the better the brain becomes
pcall(function()
local brain = require("codetyper.brain")
local brain = require("codetyper.core.memory")
if brain.is_initialized() then
-- Learn the successful pattern
local intent_type = patch.intent and patch.intent.type or "unknown"
@@ -1010,7 +1010,7 @@ function M.apply_with_conflict(patch)
M.mark_applied(patch.id)
pcall(function()
local logs = require("codetyper.agent.logs")
local logs = require("codetyper.adapters.nvim.ui.logs")
logs.add({
type = "success",
message = string.format(
@@ -1044,7 +1044,7 @@ function M.apply_with_conflict(patch)
M.mark_applied(patch.id)
pcall(function()
local logs = require("codetyper.agent.logs")
local logs = require("codetyper.adapters.nvim.ui.logs")
logs.add({
type = "success",
message = "Created conflict for review - use co/ct/cb/cn to resolve",

View File

@@ -194,7 +194,7 @@ function M.enqueue(event)
-- Log to agent logs if available
pcall(function()
local logs = require("codetyper.agent.logs")
local logs = require("codetyper.adapters.nvim.ui.logs")
logs.add({
type = "queue",
message = string.format("Event queued: %s (priority: %d)", event.id, event.priority),

View File

@@ -74,7 +74,7 @@ local function score_syntax(response)
local score = 1.0
-- Check bracket balance
if not require("codetyper.utils").check_brackets(response) then
if not require("codetyper.support.utils").check_brackets(response) then
score = score - 0.4
end

View File

@@ -2,8 +2,8 @@
local M = {}
local utils = require("codetyper.utils")
local llm = require("codetyper.llm")
local utils = require("codetyper.support.utils")
local llm = require("codetyper.core.llm")
--- Copilot API endpoints
local AUTH_URL = "https://api.github.com/copilot_internal/v2/token"
@@ -296,7 +296,7 @@ local function make_request(token, body, callback)
-- Record usage for cost tracking
if usage.prompt_tokens or usage.completion_tokens then
local cost = require("codetyper.cost")
local cost = require("codetyper.core.cost")
cost.record_usage(
get_model(),
usage.prompt_tokens or 0,
@@ -348,7 +348,7 @@ end
---@param context table Context information
---@param callback fun(response: string|nil, error: string|nil)
function M.generate(prompt, context, callback)
local logs = require("codetyper.agent.logs")
local logs = require("codetyper.adapters.nvim.ui.logs")
ensure_initialized()
@@ -414,7 +414,7 @@ end
---@param tool_definitions table Tool definitions
---@param callback fun(response: table|nil, error: string|nil)
function M.generate_with_tools(messages, context, tool_definitions, callback)
local logs = require("codetyper.agent.logs")
local logs = require("codetyper.adapters.nvim.ui.logs")
ensure_initialized()
@@ -436,7 +436,7 @@ function M.generate_with_tools(messages, context, tool_definitions, callback)
return
end
local tools_module = require("codetyper.agent.tools")
local tools_module = require("codetyper.core.tools")
local agent_prompts = require("codetyper.prompts.agent")
-- Build system prompt with agent instructions and project context
@@ -634,7 +634,7 @@ function M.generate_with_tools(messages, context, tool_definitions, callback)
logs.response(response.usage.prompt_tokens or 0, response.usage.completion_tokens or 0, "stop")
-- Record usage for cost tracking
local cost_tracker = require("codetyper.cost")
local cost_tracker = require("codetyper.core.cost")
cost_tracker.record_usage(
get_model(),
response.usage.prompt_tokens or 0,

View File

@@ -2,8 +2,8 @@
local M = {}
local utils = require("codetyper.utils")
local llm = require("codetyper.llm")
local utils = require("codetyper.support.utils")
local llm = require("codetyper.core.llm")
--- Gemini API endpoint
local API_URL = "https://generativelanguage.googleapis.com/v1beta/models"
@@ -167,7 +167,7 @@ end
---@param context table Context information
---@param callback fun(response: string|nil, error: string|nil) Callback function
function M.generate(prompt, context, callback)
local logs = require("codetyper.agent.logs")
local logs = require("codetyper.adapters.nvim.ui.logs")
local model = get_model()
-- Log the request
@@ -217,7 +217,7 @@ end
---@param tool_definitions table Tool definitions
---@param callback fun(response: table|nil, error: string|nil) Callback with raw response
function M.generate_with_tools(messages, context, tool_definitions, callback)
local logs = require("codetyper.agent.logs")
local logs = require("codetyper.adapters.nvim.ui.logs")
local model = get_model()
logs.request("gemini", model)
@@ -230,7 +230,7 @@ function M.generate_with_tools(messages, context, tool_definitions, callback)
return
end
local tools_module = require("codetyper.agent.tools")
local tools_module = require("codetyper.core.tools")
local agent_prompts = require("codetyper.prompts.agent")
-- Build system prompt with agent instructions

View File

@@ -1,8 +1,8 @@
---@mod codetyper.llm LLM interface for Codetyper.nvim
local M = {}
local lang_map = require("codetyper.utils.langmap")
local utils = require("codetyper.utils")
local lang_map = require("codetyper.support.langmap")
local utils = require("codetyper.support.utils")
--- Get the appropriate LLM client based on configuration
---@return table LLM client module
@@ -11,13 +11,13 @@ function M.get_client()
local config = codetyper.get_config()
if config.llm.provider == "ollama" then
return require("codetyper.llm.ollama")
return require("codetyper.core.llm.ollama")
elseif config.llm.provider == "openai" then
return require("codetyper.llm.openai")
return require("codetyper.core.llm.openai")
elseif config.llm.provider == "gemini" then
return require("codetyper.llm.gemini")
return require("codetyper.core.llm.gemini")
elseif config.llm.provider == "copilot" then
return require("codetyper.llm.copilot")
return require("codetyper.core.llm.copilot")
else
error("Unknown LLM provider: " .. config.llm.provider)
end
@@ -39,14 +39,14 @@ end
---@param context table Context information
---@param callback fun(response: string|nil, error: string|nil, metadata: table|nil) Callback
function M.smart_generate(prompt, context, callback)
local selector = require("codetyper.llm.selector")
local selector = require("codetyper.core.llm.selector")
selector.smart_generate(prompt, context, callback)
end
--- Get accuracy statistics for providers
---@return table Statistics for each provider
function M.get_accuracy_stats()
local selector = require("codetyper.llm.selector")
local selector = require("codetyper.core.llm.selector")
return selector.get_accuracy_stats()
end
@@ -54,7 +54,7 @@ end
---@param provider string Which provider generated the response
---@param was_correct boolean Whether the response was good
function M.report_feedback(provider, was_correct)
local selector = require("codetyper.llm.selector")
local selector = require("codetyper.core.llm.selector")
selector.report_feedback(provider, was_correct)
end

View File

@@ -2,8 +2,8 @@
local M = {}
local utils = require("codetyper.utils")
local llm = require("codetyper.llm")
local utils = require("codetyper.support.utils")
local llm = require("codetyper.core.llm")
--- Get Ollama host from stored credentials or config
---@return string Host URL
@@ -137,7 +137,7 @@ end
---@param context table Context information
---@param callback fun(response: string|nil, error: string|nil) Callback function
function M.generate(prompt, context, callback)
local logs = require("codetyper.agent.logs")
local logs = require("codetyper.adapters.nvim.ui.logs")
local model = get_model()
-- Log the request
@@ -217,9 +217,9 @@ end
---@param tool_definitions table Tool definitions
---@param callback fun(response: table|nil, error: string|nil) Callback with Claude-like response format
function M.generate_with_tools(messages, context, tool_definitions, callback)
local logs = require("codetyper.agent.logs")
local logs = require("codetyper.adapters.nvim.ui.logs")
local agent_prompts = require("codetyper.prompts.agent")
local tools_module = require("codetyper.agent.tools")
local tools_module = require("codetyper.core.tools")
logs.request("ollama", get_model())
logs.thinking("Preparing agent request...")
@@ -322,7 +322,7 @@ function M.generate_with_tools(messages, context, tool_definitions, callback)
logs.response(response.prompt_eval_count or 0, response.eval_count or 0, "stop")
-- Record usage for cost tracking (free for local models)
local cost = require("codetyper.cost")
local cost = require("codetyper.core.cost")
cost.record_usage(
get_model(),
response.prompt_eval_count or 0,

View File

@@ -2,8 +2,8 @@
local M = {}
local utils = require("codetyper.utils")
local llm = require("codetyper.llm")
local utils = require("codetyper.support.utils")
local llm = require("codetyper.core.llm")
--- OpenAI API endpoint
local API_URL = "https://api.openai.com/v1/chat/completions"
@@ -158,7 +158,7 @@ end
---@param context table Context information
---@param callback fun(response: string|nil, error: string|nil) Callback function
function M.generate(prompt, context, callback)
local logs = require("codetyper.agent.logs")
local logs = require("codetyper.adapters.nvim.ui.logs")
local model = get_model()
-- Log the request
@@ -208,7 +208,7 @@ end
---@param tool_definitions table Tool definitions
---@param callback fun(response: table|nil, error: string|nil) Callback with raw response
function M.generate_with_tools(messages, context, tool_definitions, callback)
local logs = require("codetyper.agent.logs")
local logs = require("codetyper.adapters.nvim.ui.logs")
local model = get_model()
logs.request("openai", model)
@@ -221,7 +221,7 @@ function M.generate_with_tools(messages, context, tool_definitions, callback)
return
end
local tools_module = require("codetyper.agent.tools")
local tools_module = require("codetyper.core.tools")
local agent_prompts = require("codetyper.prompts.agent")
-- Build system prompt with agent instructions
@@ -310,7 +310,7 @@ function M.generate_with_tools(messages, context, tool_definitions, callback)
logs.response(response.usage.prompt_tokens or 0, response.usage.completion_tokens or 0, "stop")
-- Record usage for cost tracking
local cost = require("codetyper.cost")
local cost = require("codetyper.core.cost")
cost.record_usage(
model,
response.usage.prompt_tokens or 0,

View File

@@ -296,7 +296,7 @@ end
---@param callback fun(result: PonderResult) Callback with pondering result
function M.ponder(prompt, context, ollama_response, callback)
-- Use Copilot as verifier
local copilot = require("codetyper.llm.copilot")
local copilot = require("codetyper.core.llm.copilot")
-- Build verification prompt
local verify_prompt = prompt
@@ -393,7 +393,7 @@ function M.smart_generate(prompt, context, callback)
-- Log selection
pcall(function()
local logs = require("codetyper.agent.logs")
local logs = require("codetyper.adapters.nvim.ui.logs")
logs.add({
type = "info",
message = string.format(
@@ -408,9 +408,9 @@ function M.smart_generate(prompt, context, callback)
-- Get the selected client
local client
if selection.provider == "ollama" then
client = require("codetyper.llm.ollama")
client = require("codetyper.core.llm.ollama")
else
client = require("codetyper.llm.copilot")
client = require("codetyper.core.llm.copilot")
end
-- Generate response
@@ -419,7 +419,7 @@ function M.smart_generate(prompt, context, callback)
-- Fallback on error
if selection.provider == "ollama" then
-- Try Copilot as fallback
local copilot = require("codetyper.llm.copilot")
local copilot = require("codetyper.core.llm.copilot")
copilot.generate(prompt, context, function(fallback_response, fallback_error)
callback(fallback_response, fallback_error, {
provider = "copilot",

View File

@@ -1,10 +1,10 @@
--- Brain Delta Commit Operations
--- Git-like commit creation and management
local storage = require("codetyper.brain.storage")
local hash_mod = require("codetyper.brain.hash")
local diff_mod = require("codetyper.brain.delta.diff")
local types = require("codetyper.brain.types")
local storage = require("codetyper.core.memory.storage")
local hash_mod = require("codetyper.core.memory.hash")
local diff_mod = require("codetyper.core.memory.delta.diff")
local types = require("codetyper.core.memory.types")
local M = {}

View File

@@ -1,7 +1,7 @@
--- Brain Delta Diff Computation
--- Field-level diff algorithms for delta versioning
local hash = require("codetyper.brain.hash")
local hash = require("codetyper.core.memory.hash")
local M = {}

View File

@@ -1,10 +1,10 @@
--- Brain Delta Coordinator
--- Git-like versioning system for brain state
local storage = require("codetyper.brain.storage")
local commit_mod = require("codetyper.brain.delta.commit")
local diff_mod = require("codetyper.brain.delta.diff")
local types = require("codetyper.brain.types")
local storage = require("codetyper.core.memory.storage")
local commit_mod = require("codetyper.core.memory.delta.commit")
local diff_mod = require("codetyper.core.memory.delta.diff")
local types = require("codetyper.core.memory.types")
local M = {}
@@ -17,7 +17,7 @@ M.diff = diff_mod
---@param trigger? string Trigger source
---@return string|nil Delta hash
function M.commit(message, trigger)
local graph = require("codetyper.brain.graph")
local graph = require("codetyper.core.memory.graph")
local changes = graph.get_pending_changes()
if #changes == 0 then
@@ -87,7 +87,7 @@ end
--- Apply changes to current state
---@param changes table[] Changes to apply
function M.apply_changes(changes)
local node_mod = require("codetyper.brain.graph.node")
local node_mod = require("codetyper.core.memory.graph.node")
for _, change in ipairs(changes) do
local parts = vim.split(change.path, ".", { plain = true })
@@ -117,7 +117,7 @@ function M.apply_changes(changes)
end
elseif parts[1] == "graph" then
-- Handle graph/edge changes
local edge_mod = require("codetyper.brain.graph.edge")
local edge_mod = require("codetyper.core.memory.graph.edge")
if parts[2] == "edges" and #parts >= 3 then
local edge_id = parts[3]
if change.op == types.DELTA_OPS.ADD then
@@ -168,17 +168,17 @@ end
--- Check if there are uncommitted changes
---@return boolean
function M.has_pending()
local graph = require("codetyper.brain.graph")
local node_pending = require("codetyper.brain.graph.node").pending
local edge_pending = require("codetyper.brain.graph.edge").pending
local graph = require("codetyper.core.memory.graph")
local node_pending = require("codetyper.core.memory.graph.node").pending
local edge_pending = require("codetyper.core.memory.graph.edge").pending
return #node_pending > 0 or #edge_pending > 0
end
--- Get status (like git status)
---@return table Status info
function M.status()
local node_pending = require("codetyper.brain.graph.node").pending
local edge_pending = require("codetyper.brain.graph.edge").pending
local node_pending = require("codetyper.core.memory.graph.node").pending
local edge_pending = require("codetyper.core.memory.graph.edge").pending
local adds = 0
local mods = 0
@@ -268,8 +268,8 @@ function M.reset()
})
-- Clear pending
require("codetyper.brain.graph.node").pending = {}
require("codetyper.brain.graph.edge").pending = {}
require("codetyper.core.memory.graph.node").pending = {}
require("codetyper.core.memory.graph.edge").pending = {}
storage.flush_all()
return true

View File

@@ -1,9 +1,9 @@
--- Brain Graph Edge Operations
--- CRUD operations for node connections
local storage = require("codetyper.brain.storage")
local hash = require("codetyper.brain.hash")
local types = require("codetyper.brain.types")
local storage = require("codetyper.core.memory.storage")
local hash = require("codetyper.core.memory.hash")
local types = require("codetyper.core.memory.types")
local M = {}

View File

@@ -1,11 +1,11 @@
--- Brain Graph Coordinator
--- High-level graph operations
local node = require("codetyper.brain.graph.node")
local edge = require("codetyper.brain.graph.edge")
local query = require("codetyper.brain.graph.query")
local storage = require("codetyper.brain.storage")
local types = require("codetyper.brain.types")
local node = require("codetyper.core.memory.graph.node")
local edge = require("codetyper.core.memory.graph.edge")
local query = require("codetyper.core.memory.graph.query")
local storage = require("codetyper.core.memory.storage")
local types = require("codetyper.core.memory.types")
local M = {}

View File

@@ -1,9 +1,9 @@
--- Brain Graph Node Operations
--- CRUD operations for learning nodes
local storage = require("codetyper.brain.storage")
local hash = require("codetyper.brain.hash")
local types = require("codetyper.brain.types")
local storage = require("codetyper.core.memory.storage")
local hash = require("codetyper.core.memory.hash")
local types = require("codetyper.core.memory.types")
local M = {}

View File

@@ -1,18 +1,18 @@
--- Brain Graph Query Engine
--- Multi-dimensional traversal and relevance scoring
local storage = require("codetyper.brain.storage")
local types = require("codetyper.brain.types")
local storage = require("codetyper.core.memory.storage")
local types = require("codetyper.core.memory.types")
local M = {}
--- Lazy load dependencies to avoid circular requires
local function get_node_module()
return require("codetyper.brain.graph.node")
return require("codetyper.core.memory.graph.node")
end
local function get_edge_module()
return require("codetyper.brain.graph.edge")
return require("codetyper.core.memory.graph.edge")
end
--- Compute text similarity (simple keyword matching)

View File

@@ -1,8 +1,8 @@
--- Brain Learning System
--- Graph-based knowledge storage with delta versioning
local storage = require("codetyper.brain.storage")
local types = require("codetyper.brain.types")
local storage = require("codetyper.core.memory.storage")
local types = require("codetyper.core.memory.types")
local M = {}
@@ -72,7 +72,7 @@ function M.learn(event)
return nil
end
local learners = require("codetyper.brain.learners")
local learners = require("codetyper.core.memory.learners")
local node_id = learners.process(event)
if node_id then
@@ -96,7 +96,7 @@ function M.query(opts)
return { nodes = {}, edges = {}, stats = {}, truncated = false }
end
local query_engine = require("codetyper.brain.graph.query")
local query_engine = require("codetyper.core.memory.graph.query")
return query_engine.execute(opts)
end
@@ -112,7 +112,7 @@ function M.get_context_for_llm(opts)
opts.max_tokens = opts.max_tokens or config.output.max_tokens
local result = M.query(opts)
local formatter = require("codetyper.brain.output.formatter")
local formatter = require("codetyper.core.memory.output.formatter")
if config.output.format == "json" then
return formatter.to_json(result, opts)
@@ -129,7 +129,7 @@ function M.commit(message)
return nil
end
local delta_mgr = require("codetyper.brain.delta")
local delta_mgr = require("codetyper.core.memory.delta")
return delta_mgr.commit(message)
end
@@ -141,7 +141,7 @@ function M.rollback(delta_hash)
return false
end
local delta_mgr = require("codetyper.brain.delta")
local delta_mgr = require("codetyper.core.memory.delta")
return delta_mgr.rollback(delta_hash)
end
@@ -153,7 +153,7 @@ function M.get_history(limit)
return {}
end
local delta_mgr = require("codetyper.brain.delta")
local delta_mgr = require("codetyper.core.memory.delta")
return delta_mgr.get_history(limit or 50)
end
@@ -170,7 +170,7 @@ function M.prune(opts)
unused_days = config.prune.unused_days,
}, opts or {})
local graph = require("codetyper.brain.graph")
local graph = require("codetyper.core.memory.graph")
return graph.prune(opts)
end

View File

@@ -1,7 +1,7 @@
--- Brain Convention Learner
--- Learns project conventions and coding standards
local types = require("codetyper.brain.types")
local types = require("codetyper.core.memory.types")
local M = {}

View File

@@ -1,7 +1,7 @@
--- Brain Correction Learner
--- Learns from user corrections and edits
local types = require("codetyper.brain.types")
local types = require("codetyper.core.memory.types")
local M = {}

View File

@@ -1,21 +1,21 @@
--- Brain Learners Coordinator
--- Routes learning events to appropriate learners
local types = require("codetyper.brain.types")
local types = require("codetyper.core.memory.types")
local M = {}
-- Lazy load learners
local function get_pattern_learner()
return require("codetyper.brain.learners.pattern")
return require("codetyper.core.memory.learners.pattern")
end
local function get_correction_learner()
return require("codetyper.brain.learners.correction")
return require("codetyper.core.memory.learners.correction")
end
local function get_convention_learner()
return require("codetyper.brain.learners.convention")
return require("codetyper.core.memory.learners.convention")
end
--- All available learners
@@ -99,7 +99,7 @@ function M.create_learning(learner, data, event)
local params = learner.create_node_params(data)
-- Get graph module
local graph = require("codetyper.brain.graph")
local graph = require("codetyper.core.memory.graph")
-- Find related nodes
local related_ids = {}
@@ -125,7 +125,7 @@ end
---@return string|nil Created node ID
function M.process_feedback(event)
local data = event.data or {}
local graph = require("codetyper.brain.graph")
local graph = require("codetyper.core.memory.graph")
local content = {
s = "Feedback: " .. (data.feedback or "unknown"),
@@ -167,7 +167,7 @@ end
---@return string|nil Created node ID
function M.process_session(event)
local data = event.data or {}
local graph = require("codetyper.brain.graph")
local graph = require("codetyper.core.memory.graph")
local content = {
s = event.type == "session_start" and "Session started" or "Session ended",

View File

@@ -1,7 +1,7 @@
--- Brain Pattern Learner
--- Detects and learns code patterns
local types = require("codetyper.brain.types")
local types = require("codetyper.core.memory.types")
local M = {}

View File

@@ -1,7 +1,7 @@
--- Brain Output Formatter
--- LLM-optimized output formatting
local types = require("codetyper.brain.types")
local types = require("codetyper.core.memory.types")
local M = {}

View File

@@ -1,7 +1,7 @@
--- Brain Output Coordinator
--- Manages LLM context generation
local formatter = require("codetyper.brain.output.formatter")
local formatter = require("codetyper.core.memory.output.formatter")
local M = {}
@@ -17,7 +17,7 @@ local DEFAULT_MAX_TOKENS = 4000
function M.generate(opts)
opts = opts or {}
local brain = require("codetyper.brain")
local brain = require("codetyper.core.memory")
if not brain.is_initialized() then
return ""
end
@@ -138,7 +138,7 @@ end
--- Check if context is available
---@return boolean
function M.has_context()
local brain = require("codetyper.brain")
local brain = require("codetyper.core.memory")
if not brain.is_initialized() then
return false
end
@@ -150,7 +150,7 @@ end
--- Get context stats
---@return table Stats
function M.stats()
local brain = require("codetyper.brain")
local brain = require("codetyper.core.memory")
if not brain.is_initialized() then
return { available = false }
end

View File

@@ -1,8 +1,8 @@
--- Brain Storage Layer
--- Cache + disk persistence with lazy loading
local utils = require("codetyper.utils")
local types = require("codetyper.brain.types")
local utils = require("codetyper.support.utils")
local types = require("codetyper.core.memory.types")
local M = {}

View File

@@ -3,8 +3,8 @@
--- Executes tools requested by the LLM and returns results.
local M = {}
local utils = require("codetyper.utils")
local logs = require("codetyper.agent.logs")
local utils = require("codetyper.support.utils")
local logs = require("codetyper.adapters.nvim.ui.logs")
---@class ExecutionResult
---@field success boolean Whether the execution succeeded

View File

@@ -144,8 +144,8 @@ end
--- Execute the agent loop
---@param opts AgentLoopOpts
function M.run(opts)
local tools_mod = require("codetyper.agent.tools")
local llm = require("codetyper.llm")
local tools_mod = require("codetyper.core.tools")
local llm = require("codetyper.core.llm")
-- Get tools
local tools = opts.tools or tools_mod.list()
@@ -280,7 +280,7 @@ function M.run(opts)
local tool_opts = {
on_log = function(msg)
pcall(function()
local logs = require("codetyper.agent.logs")
local logs = require("codetyper.adapters.nvim.ui.logs")
logs.add({ type = "tool", message = msg })
end)
end,
@@ -363,7 +363,7 @@ function M.dispatch(prompt, on_complete, opts)
opts = opts or {}
-- Sub-agents get limited tools by default
local tools_mod = require("codetyper.agent.tools")
local tools_mod = require("codetyper.core.tools")
local safe_tools = tools_mod.list(function(tool)
return tool.name == "view" or tool.name == "grep" or tool.name == "glob"
end)

View File

@@ -4,7 +4,7 @@
local M = {}
local utils = require("codetyper.utils")
local utils = require("codetyper.support.utils")
--- Get the resume context directory
---@return string|nil

View File

@@ -6,11 +6,11 @@
local M = {}
local queue = require("codetyper.agent.queue")
local patch = require("codetyper.agent.patch")
local worker = require("codetyper.agent.worker")
local confidence_mod = require("codetyper.agent.confidence")
local context_modal = require("codetyper.agent.context_modal")
local queue = require("codetyper.core.events.queue")
local patch = require("codetyper.core.diff.patch")
local worker = require("codetyper.core.scheduler.worker")
local confidence_mod = require("codetyper.core.llm.confidence")
local context_modal = require("codetyper.adapters.nvim.ui.context_modal")
local params = require("codetyper.params.agent.scheduler")
-- Setup context modal cleanup on exit
@@ -138,7 +138,7 @@ local function retry_with_context(original_event, additional_context, attached_f
-- Log the retry
pcall(function()
local logs = require("codetyper.agent.logs")
local logs = require("codetyper.adapters.nvim.ui.logs")
logs.add({
type = "info",
message = string.format("Retrying with additional context (original: %s)", original_event.id),
@@ -229,7 +229,7 @@ local function handle_worker_result(event, result)
-- Check if LLM needs more context
if result.needs_context then
pcall(function()
local logs = require("codetyper.agent.logs")
local logs = require("codetyper.adapters.nvim.ui.logs")
logs.add({
type = "info",
message = string.format("Event %s: LLM needs more context, opening modal", event.id),
@@ -285,7 +285,7 @@ local function handle_worker_result(event, result)
end
if requested and #requested > 0 then
pcall(function()
local logs = require("codetyper.agent.logs")
local logs = require("codetyper.adapters.nvim.ui.logs")
logs.add({ type = "info", message = string.format("Auto-attaching %d requested file(s)", #requested) })
end)
@@ -328,7 +328,7 @@ local function handle_worker_result(event, result)
-- Failed - try escalation if this was ollama
if result.worker_type == "ollama" and event.attempt_count < 2 then
pcall(function()
local logs = require("codetyper.agent.logs")
local logs = require("codetyper.adapters.nvim.ui.logs")
logs.add({
type = "info",
message = string.format(
@@ -358,7 +358,7 @@ local function handle_worker_result(event, result)
if needs_escalation and result.worker_type == "ollama" and event.attempt_count < 2 then
-- Low confidence from ollama - escalate to remote
pcall(function()
local logs = require("codetyper.agent.logs")
local logs = require("codetyper.adapters.nvim.ui.logs")
logs.add({
type = "info",
message = string.format(
@@ -383,7 +383,7 @@ local function handle_worker_result(event, result)
-- Schedule patch application after delay (gives user time to review/cancel)
local delay = state.config.apply_delay_ms or 5000
pcall(function()
local logs = require("codetyper.agent.logs")
local logs = require("codetyper.adapters.nvim.ui.logs")
logs.add({
type = "info",
message = string.format("Code ready. Applying in %.1f seconds...", delay / 1000),
@@ -416,7 +416,7 @@ local function dispatch_next()
local should_skip, skip_reason = queue.check_precedence(event)
if should_skip then
pcall(function()
local logs = require("codetyper.agent.logs")
local logs = require("codetyper.adapters.nvim.ui.logs")
logs.add({
type = "warning",
message = string.format("Event %s skipped: %s", event.id, skip_reason or "conflict"),
@@ -432,7 +432,7 @@ local function dispatch_next()
-- Log dispatch with intent/scope info
pcall(function()
local logs = require("codetyper.agent.logs")
local logs = require("codetyper.adapters.nvim.ui.logs")
local intent_info = event.intent and event.intent.type or "unknown"
local scope_info = event.scope and event.scope.type ~= "file"
and string.format("%s:%s", event.scope.type, event.scope.name or "anon")
@@ -474,7 +474,7 @@ function M.schedule_patch_flush()
local applied, stale = patch.flush_pending_smart()
if applied > 0 or stale > 0 then
pcall(function()
local logs = require("codetyper.agent.logs")
local logs = require("codetyper.adapters.nvim.ui.logs")
logs.add({
type = "info",
message = string.format("Patches flushed: %d applied, %d stale", applied, stale),
@@ -487,7 +487,7 @@ function M.schedule_patch_flush()
if not waiting_to_flush then
waiting_to_flush = true
pcall(function()
local logs = require("codetyper.agent.logs")
local logs = require("codetyper.adapters.nvim.ui.logs")
logs.add({
type = "info",
message = "Waiting for user to finish typing before applying code...",
@@ -628,7 +628,7 @@ function M.start(config)
scheduler_loop()
pcall(function()
local logs = require("codetyper.agent.logs")
local logs = require("codetyper.adapters.nvim.ui.logs")
logs.add({
type = "info",
message = "Scheduler started",
@@ -660,7 +660,7 @@ function M.stop()
end
pcall(function()
local logs = require("codetyper.agent.logs")
local logs = require("codetyper.adapters.nvim.ui.logs")
logs.add({
type = "info",
message = "Scheduler stopped",

View File

@@ -7,7 +7,7 @@
local M = {}
local params = require("codetyper.params.agent.worker")
local confidence = require("codetyper.agent.confidence")
local confidence = require("codetyper.core.llm.confidence")
---@class WorkerResult
---@field success boolean Whether the request succeeded
@@ -399,7 +399,7 @@ end
---@return string prompt
---@return table context
local function build_prompt(event)
local intent_mod = require("codetyper.agent.intent")
local intent_mod = require("codetyper.core.intent")
-- Get target file content for context
local target_content = ""
@@ -420,7 +420,7 @@ local function build_prompt(event)
local indexed_context = nil
local indexed_content = ""
pcall(function()
local indexer = require("codetyper.indexer")
local indexer = require("codetyper.features.indexer")
indexed_context = indexer.get_context_for({
file = event.target_path,
intent = event.intent,
@@ -439,7 +439,7 @@ local function build_prompt(event)
-- Get brain memories - contextual recall based on current task
local brain_context = ""
pcall(function()
local brain = require("codetyper.brain")
local brain = require("codetyper.core.memory")
if brain.is_initialized() then
-- Query brain for relevant memories based on:
-- 1. Current file (file-specific patterns)
@@ -726,7 +726,7 @@ function M.create(event, worker_type, callback)
-- Log worker creation
pcall(function()
local logs = require("codetyper.agent.logs")
local logs = require("codetyper.adapters.nvim.ui.logs")
logs.add({
type = "worker",
message = string.format("Worker %s started (%s)", worker.id, worker_type),
@@ -756,7 +756,7 @@ function M.start(worker)
active_workers[worker.id] = nil
pcall(function()
local logs = require("codetyper.agent.logs")
local logs = require("codetyper.adapters.nvim.ui.logs")
logs.add({
type = "warning",
message = string.format("Worker %s timed out after %dms", worker.id, worker.timeout_ms),
@@ -810,7 +810,7 @@ function M.start(worker)
-- Log if pondering occurred
if usage_or_metadata.pondered then
pcall(function()
local logs = require("codetyper.agent.logs")
local logs = require("codetyper.adapters.nvim.ui.logs")
logs.add({
type = "info",
message = string.format(
@@ -828,7 +828,7 @@ function M.start(worker)
-- Use smart selection or direct client
if use_smart_selection then
local llm = require("codetyper.llm")
local llm = require("codetyper.core.llm")
llm.smart_generate(prompt, context, handle_response)
else
-- Get client and execute directly
@@ -854,7 +854,7 @@ function M.complete(worker, response, error, usage)
active_workers[worker.id] = nil
pcall(function()
local logs = require("codetyper.agent.logs")
local logs = require("codetyper.adapters.nvim.ui.logs")
logs.add({
type = "error",
message = string.format("Worker %s failed: %s", worker.id, error),
@@ -880,7 +880,7 @@ function M.complete(worker, response, error, usage)
active_workers[worker.id] = nil
pcall(function()
local logs = require("codetyper.agent.logs")
local logs = require("codetyper.adapters.nvim.ui.logs")
logs.add({
type = "info",
message = string.format("Worker %s: LLM needs more context", worker.id),
@@ -904,7 +904,7 @@ function M.complete(worker, response, error, usage)
-- Log the full raw LLM response (for debugging)
pcall(function()
local logs = require("codetyper.agent.logs")
local logs = require("codetyper.adapters.nvim.ui.logs")
logs.add({
type = "response",
message = "--- LLM Response ---",
@@ -925,7 +925,7 @@ function M.complete(worker, response, error, usage)
active_workers[worker.id] = nil
pcall(function()
local logs = require("codetyper.agent.logs")
local logs = require("codetyper.adapters.nvim.ui.logs")
logs.add({
type = "success",
message = string.format(
@@ -972,7 +972,7 @@ function M.cancel(worker_id)
active_workers[worker_id] = nil
pcall(function()
local logs = require("codetyper.agent.logs")
local logs = require("codetyper.adapters.nvim.ui.logs")
logs.add({
type = "info",
message = string.format("Worker %s cancelled", worker_id),

View File

@@ -3,7 +3,7 @@
--- Tool for executing shell commands with safety checks.
---@brief ]]
local Base = require("codetyper.agent.tools.base")
local Base = require("codetyper.core.tools.base")
local description = require("codetyper.prompts.agent.bash").description
local params = require("codetyper.params.agent.bash").params
local returns = require("codetyper.params.agent.bash").returns

View File

@@ -5,7 +5,7 @@
--- Multi-strategy approach for reliable editing.
---@brief ]]
local Base = require("codetyper.agent.tools.base")
local Base = require("codetyper.core.tools.base")
local description = require("codetyper.prompts.agent.edit").description
local params = require("codetyper.params.agent.edit").params
local returns = require("codetyper.params.agent.edit").returns

View File

@@ -3,7 +3,7 @@
--- Tool for finding files by glob pattern.
---@brief ]]
local Base = require("codetyper.agent.tools.base")
local Base = require("codetyper.core.tools.base")
---@class CoderTool
local M = setmetatable({}, Base)

View File

@@ -3,7 +3,7 @@
--- Tool for searching file contents using ripgrep.
---@brief ]]
local Base = require("codetyper.agent.tools.base")
local Base = require("codetyper.core.tools.base")
local description = require("codetyper.params.agent.grep").description
local params = require("codetyper.prompts.agents.grep").params
local returns = require("codetyper.prompts.agents.grep").returns

View File

@@ -162,27 +162,27 @@ end
--- Load built-in tools
function M.load_builtins()
-- View file tool
local view = require("codetyper.agent.tools.view")
local view = require("codetyper.core.tools.view")
M.register(view)
-- Bash tool
local bash = require("codetyper.agent.tools.bash")
local bash = require("codetyper.core.tools.bash")
M.register(bash)
-- Grep tool
local grep = require("codetyper.agent.tools.grep")
local grep = require("codetyper.core.tools.grep")
M.register(grep)
-- Glob tool
local glob = require("codetyper.agent.tools.glob")
local glob = require("codetyper.core.tools.glob")
M.register(glob)
-- Write file tool
local write = require("codetyper.agent.tools.write")
local write = require("codetyper.core.tools.write")
M.register(write)
-- Edit tool
local edit = require("codetyper.agent.tools.edit")
local edit = require("codetyper.core.tools.edit")
M.register(edit)
end

View File

@@ -3,7 +3,7 @@
--- Tool for reading file contents with line range support.
---@brief ]]
local Base = require("codetyper.agent.tools.base")
local Base = require("codetyper.core.tools.base")
---@class CoderTool
local M = setmetatable({}, Base)

View File

@@ -3,7 +3,7 @@
--- Tool for creating or overwriting files.
---@brief ]]
local Base = require("codetyper.agent.tools.base")
local Base = require("codetyper.core.tools.base")
local description = require("codetyper.prompts.agents.write").description
local params = require("codetyper.params.agents.write")

View File

@@ -5,7 +5,7 @@
local M = {}
local utils = require("codetyper.utils")
local utils = require("codetyper.support.utils")
local params = require("codetyper.params.agent.context")
--- Get project structure as a tree string

View File

@@ -31,7 +31,7 @@ local M = {}
---@field on_complete? fun(result: string|nil, error: string|nil) Called when done
---@field on_status? fun(status: string) Status updates
local utils = require("codetyper.utils")
local utils = require("codetyper.support.utils")
--- Load agent definition
---@param name string Agent name
@@ -177,7 +177,7 @@ end
---@param provider string "openai"|"claude"
---@return table[] Formatted tools
local function build_tools(tool_names, provider)
local tools_mod = require("codetyper.agent.tools")
local tools_mod = require("codetyper.core.tools")
local tools = {}
for _, name in ipairs(tool_names) do
@@ -234,7 +234,7 @@ end
---@return string result
---@return string|nil error
local function execute_tool(tool_call, opts)
local tools_mod = require("codetyper.agent.tools")
local tools_mod = require("codetyper.core.tools")
local name = tool_call["function"].name
local args = tool_call["function"].arguments
@@ -363,7 +363,7 @@ local function call_llm(messages, tools, system_prompt, provider, model, callbac
-- Use native tool calling APIs
if provider == "copilot" then
local client = require("codetyper.llm.copilot")
local client = require("codetyper.core.llm.copilot")
-- Copilot's generate_with_tools expects messages in a specific format
-- Convert to the format it expects
@@ -406,7 +406,7 @@ local function call_llm(messages, tools, system_prompt, provider, model, callbac
callback(result, nil)
end)
elseif provider == "openai" then
local client = require("codetyper.llm.openai")
local client = require("codetyper.core.llm.openai")
-- OpenAI's generate_with_tools
local converted_messages = {}
@@ -447,7 +447,7 @@ local function call_llm(messages, tools, system_prompt, provider, model, callbac
callback(result, nil)
end)
elseif provider == "ollama" then
local client = require("codetyper.llm.ollama")
local client = require("codetyper.core.llm.ollama")
-- Ollama's generate_with_tools (text-based tool calling)
local converted_messages = {}
@@ -468,7 +468,7 @@ local function call_llm(messages, tools, system_prompt, provider, model, callbac
end)
else
-- Fallback for other providers (ollama, etc.) - use text-based parsing
local client = require("codetyper.llm." .. provider)
local client = require("codetyper.core.llm." .. provider)
-- Build prompt from messages
local prompts = require("codetyper.prompts.agent")
@@ -578,7 +578,7 @@ function M.run(opts)
local tool_names = agent.tools or { "view", "edit", "write", "grep", "glob", "bash" }
-- Ensure tools are loaded
local tools_mod = require("codetyper.agent.tools")
local tools_mod = require("codetyper.core.tools")
tools_mod.setup()
-- Build tools for API

View File

@@ -4,14 +4,14 @@
local M = {}
local tools = require("codetyper.agent.tools")
local executor = require("codetyper.agent.executor")
local parser = require("codetyper.agent.parser")
local diff = require("codetyper.agent.diff")
local diff_review = require("codetyper.agent.diff_review")
local resume = require("codetyper.agent.resume")
local utils = require("codetyper.utils")
local logs = require("codetyper.agent.logs")
local tools = require("codetyper.core.tools")
local executor = require("codetyper.core.scheduler.executor")
local parser = require("codetyper.core.llm.parser")
local diff = require("codetyper.core.diff.diff")
local diff_review = require("codetyper.adapters.nvim.ui.diff_review")
local resume = require("codetyper.core.scheduler.resume")
local utils = require("codetyper.support.utils")
local logs = require("codetyper.adapters.nvim.ui.logs")
---@class AgentState
---@field conversation table[] Message history for multi-turn
@@ -107,7 +107,7 @@ function M.agent_loop(context, callbacks)
return
end
local llm = require("codetyper.llm")
local llm = require("codetyper.core.llm")
local client = llm.get_client()
-- Check if client supports tools
@@ -416,7 +416,7 @@ function M.continue_session(callbacks)
state.current_callbacks = callbacks
-- Build context from current state
local llm = require("codetyper.llm")
local llm = require("codetyper.core.llm")
local context = {}
local current_file = vim.fn.expand("%:p")
if current_file ~= "" and vim.fn.filereadable(current_file) == 1 then

View File

@@ -60,7 +60,7 @@ local function save_buffer(bufnr)
if not ok then
pcall(function()
local logs = require("codetyper.agent.logs")
local logs = require("codetyper.adapters.nvim.ui.logs")
logs.add({
type = "warning",
message = "Failed to save buffer: " .. tostring(err),
@@ -185,7 +185,7 @@ function M.validate_after_injection(bufnr, start_line, end_line, callback)
-- Log results
pcall(function()
local logs = require("codetyper.agent.logs")
local logs = require("codetyper.adapters.nvim.ui.logs")
if result.has_errors then
logs.add({
type = "error",
@@ -332,9 +332,9 @@ function M.request_ai_fix(bufnr, result)
)
-- Queue the fix through the scheduler
local scheduler = require("codetyper.agent.scheduler")
local queue = require("codetyper.agent.queue")
local patch_mod = require("codetyper.agent.patch")
local scheduler = require("codetyper.core.scheduler.scheduler")
local queue = require("codetyper.core.events.queue")
local patch_mod = require("codetyper.core.diff.patch")
-- Ensure scheduler is running
if not scheduler.status().running then
@@ -370,7 +370,7 @@ function M.request_ai_fix(bufnr, result)
})
pcall(function()
local logs = require("codetyper.agent.logs")
local logs = require("codetyper.adapters.nvim.ui.logs")
logs.add({
type = "info",
message = "Queued AI fix request for lint errors",

View File

@@ -2,7 +2,7 @@
local M = {}
local utils = require("codetyper.utils")
local utils = require("codetyper.support.utils")
---@class AskState
---@field input_buf number|nil Input buffer
@@ -345,7 +345,7 @@ local function setup_log_listener()
-- Remove existing listener if any
if state.log_listener_id then
pcall(function()
local logs = require("codetyper.agent.logs")
local logs = require("codetyper.adapters.nvim.ui.logs")
logs.remove_listener(state.log_listener_id)
end)
state.log_listener_id = nil
@@ -362,7 +362,7 @@ end
local function remove_log_listener()
if state.log_listener_id then
pcall(function()
local logs = require("codetyper.agent.logs")
local logs = require("codetyper.adapters.nvim.ui.logs")
logs.remove_listener(state.log_listener_id)
end)
state.log_listener_id = nil

View File

@@ -6,7 +6,7 @@
local M = {}
local utils = require("codetyper.utils")
local utils = require("codetyper.support.utils")
---@class ExplorationState
---@field is_exploring boolean

View File

@@ -17,7 +17,7 @@ local M = {}
---@field body string[] Non-import code lines
---@field import_lines table<number, boolean> Map of line numbers that are imports
local utils = require("codetyper.utils")
local utils = require("codetyper.support.utils")
local languages = require("codetyper.params.agent.languages")
local import_patterns = languages.import_patterns

View File

@@ -5,7 +5,7 @@
local M = {}
local parser = require("codetyper.parser")
local utils = require("codetyper.utils")
local utils = require("codetyper.support.utils")
--- Get list of files for completion
---@param prefix string Prefix to filter files

View File

@@ -6,8 +6,8 @@
local M = {}
local utils = require("codetyper.utils")
local scanner = require("codetyper.indexer.scanner")
local utils = require("codetyper.support.utils")
local scanner = require("codetyper.features.indexer.scanner")
--- Language-specific query patterns for Tree-sitter
local TS_QUERIES = {

View File

@@ -6,7 +6,7 @@
local M = {}
local utils = require("codetyper.utils")
local utils = require("codetyper.support.utils")
--- Index schema version for migrations
local INDEX_VERSION = 1
@@ -194,8 +194,8 @@ end
---@param callback? fun(index: ProjectIndex)
---@return ProjectIndex|nil
function M.index_project(callback)
local scanner = require("codetyper.indexer.scanner")
local analyzer = require("codetyper.indexer.analyzer")
local scanner = require("codetyper.features.indexer.scanner")
local analyzer = require("codetyper.features.indexer.analyzer")
local index = create_empty_index()
local root = utils.get_project_root()
@@ -256,7 +256,7 @@ function M.index_project(callback)
M.save_index(index)
-- Store memories
local memory = require("codetyper.indexer.memory")
local memory = require("codetyper.features.indexer.memory")
memory.store_index_summary(index)
-- Sync project summary to brain
@@ -331,8 +331,8 @@ end
---@param filepath string
---@return FileIndex|nil
function M.index_file(filepath)
local analyzer = require("codetyper.indexer.analyzer")
local memory = require("codetyper.indexer.memory")
local analyzer = require("codetyper.features.indexer.analyzer")
local memory = require("codetyper.features.indexer.memory")
local root = utils.get_project_root()
if not root then
@@ -475,7 +475,7 @@ function M.schedule_index_file(filepath)
end
-- Check if file should be indexed
local scanner = require("codetyper.indexer.scanner")
local scanner = require("codetyper.features.indexer.scanner")
if not scanner.should_index(filepath, config) then
return
end
@@ -496,7 +496,7 @@ end
---@param opts {file: string, intent: table|nil, prompt: string, scope: string|nil}
---@return table Context information
function M.get_context_for(opts)
local memory = require("codetyper.indexer.memory")
local memory = require("codetyper.features.indexer.memory")
local index = M.load_index()
local context = {

View File

@@ -6,7 +6,7 @@
local M = {}
local utils = require("codetyper.utils")
local utils = require("codetyper.support.utils")
--- Memory directories
local MEMORIES_DIR = "memories"

View File

@@ -5,7 +5,7 @@
local M = {}
local utils = require("codetyper.utils")
local utils = require("codetyper.support.utils")
--- Project type markers
local PROJECT_MARKERS = {

View File

@@ -22,16 +22,16 @@ function M.setup(opts)
return
end
local config = require("codetyper.config")
local config = require("codetyper.config.defaults")
M.config = config.setup(opts)
-- Initialize modules
local commands = require("codetyper.commands")
local gitignore = require("codetyper.gitignore")
local autocmds = require("codetyper.autocmds")
local tree = require("codetyper.tree")
local completion = require("codetyper.completion")
local logs_panel = require("codetyper.logs_panel")
local commands = require("codetyper.adapters.nvim.commands")
local gitignore = require("codetyper.support.gitignore")
local autocmds = require("codetyper.adapters.nvim.autocmds")
local tree = require("codetyper.support.tree")
local completion = require("codetyper.features.completion.inline")
local logs_panel = require("codetyper.adapters.nvim.ui.logs_panel")
-- Register commands
commands.setup()
@@ -53,25 +53,25 @@ function M.setup(opts)
-- Initialize project indexer if enabled
if M.config.indexer and M.config.indexer.enabled then
local indexer = require("codetyper.indexer")
local indexer = require("codetyper.features.indexer")
indexer.setup(M.config.indexer)
end
-- Initialize brain learning system if enabled
if M.config.brain and M.config.brain.enabled then
local brain = require("codetyper.brain")
local brain = require("codetyper.core.memory")
brain.setup(M.config.brain)
end
-- Setup inline ghost text suggestions (Copilot-style)
if M.config.suggestion and M.config.suggestion.enabled then
local suggestion = require("codetyper.suggestion")
local suggestion = require("codetyper.features.completion.suggestion")
suggestion.setup(M.config.suggestion)
end
-- Start the event-driven scheduler if enabled
if M.config.scheduler and M.config.scheduler.enabled then
local scheduler = require("codetyper.agent.scheduler")
local scheduler = require("codetyper.core.scheduler.scheduler")
scheduler.start(M.config.scheduler)
end
@@ -80,7 +80,7 @@ function M.setup(opts)
-- Auto-open Ask panel after a short delay (to let UI settle)
if M.config.auto_open_ask then
vim.defer_fn(function()
local ask = require("codetyper.ask")
local ask = require("codetyper.features.ask.engine")
if not ask.is_open() then
ask.open()
end

View File

@@ -2,14 +2,14 @@
local M = {}
local utils = require("codetyper.utils")
local utils = require("codetyper.support.utils")
--- Inject generated code into target file
---@param target_path string Path to target file
---@param code string Generated code
---@param prompt_type string Type of prompt (refactor, add, document, etc.)
function M.inject_code(target_path, code, prompt_type)
local window = require("codetyper.window")
local window = require("codetyper.adapters.nvim.windows")
-- Normalize the target path
target_path = vim.fn.fnamemodify(target_path, ":p")
@@ -109,7 +109,7 @@ function M.inject_add(bufnr, code)
local lines = vim.split(code, "\n", { plain = true })
-- Get cursor position in target window
local window = require("codetyper.window")
local window = require("codetyper.adapters.nvim.windows")
local target_win = window.get_target_win()
local insert_line

View File

@@ -2,7 +2,7 @@
local M = {}
local utils = require("codetyper.utils")
local utils = require("codetyper.support.utils")
--- Get config with safe fallback
---@return table config

View File

@@ -2,7 +2,7 @@
local M = {}
local utils = require("codetyper.utils")
local utils = require("codetyper.support.utils")
--- Patterns to add to .gitignore
local IGNORE_PATTERNS = {

View File

@@ -41,7 +41,7 @@ function M.check()
health.info("Ollama model: " .. config.llm.ollama.model)
-- Try to check Ollama connectivity
local ollama = require("codetyper.llm.ollama")
local ollama = require("codetyper.core.llm.ollama")
ollama.health_check(function(is_ok, err)
if is_ok then
vim.schedule(function()
@@ -64,8 +64,8 @@ function M.check()
end
-- Check .gitignore configuration
local utils = require("codetyper.utils")
local gitignore = require("codetyper.gitignore")
local utils = require("codetyper.support.utils")
local gitignore = require("codetyper.support.gitignore")
local root = utils.get_project_root()
if root then

View File

@@ -2,7 +2,7 @@
local M = {}
local utils = require("codetyper.utils")
local utils = require("codetyper.support.utils")
--- Name of the coder folder
local CODER_FOLDER = ".coder"