diff --git a/conductor/tracks.md b/conductor/tracks.md index 7b22d81..952f284 100644 --- a/conductor/tracks.md +++ b/conductor/tracks.md @@ -63,7 +63,7 @@ This file tracks all major tracks for the project. Each track has its own detail --- -### C/C++ Language Support +### Additional Language Support 1. [ ] **Track: Tree-Sitter C/C++ MCP Tools** *Link: [./tracks/ts_cpp_tree_sitter_20260308/](./tracks/ts_cpp_tree_sitter_20260308/)* @@ -73,6 +73,10 @@ This file tracks all major tracks for the project. Each track has its own detail *Link: [./tracks/gencpp_python_bindings_20260308/](./tracks/gencpp_python_bindings_20260308/)* *Goal: Bootstrap standalone Python project with CFFI bindings for gencpp C library. Provides foundation for richer C++ AST parsing in future (beyond tree-sitter syntax).* +3. [ ] **Track: Tree-Sitter Lua MCP Tools** + *Link: [./tracks/tree_sitter_lua_mcp_tools_20260310/](./tracks/tree_sitter_lua_mcp_tools_20260310/)* + *Goal: Add Tree-Sitter Lua MCP tools for structural parsing, documentation extraction, and surgical editing.* + --- ### Path Configuration diff --git a/conductor/tracks/tree_sitter_lua_mcp_tools_20260310/index.md b/conductor/tracks/tree_sitter_lua_mcp_tools_20260310/index.md new file mode 100644 index 0000000..16264df --- /dev/null +++ b/conductor/tracks/tree_sitter_lua_mcp_tools_20260310/index.md @@ -0,0 +1,5 @@ +# Track tree_sitter_lua_mcp_tools_20260310 Context + +- [Specification](./spec.md) +- [Implementation Plan](./plan.md) +- [Metadata](./metadata.json) diff --git a/conductor/tracks/tree_sitter_lua_mcp_tools_20260310/metadata.json b/conductor/tracks/tree_sitter_lua_mcp_tools_20260310/metadata.json new file mode 100644 index 0000000..1ab755b --- /dev/null +++ b/conductor/tracks/tree_sitter_lua_mcp_tools_20260310/metadata.json @@ -0,0 +1,8 @@ +{ + "track_id": "tree_sitter_lua_mcp_tools_20260310", + "type": "feature", + "status": "new", + "created_at": "2026-03-10T00:45:00Z", + "updated_at": "2026-03-10T00:45:00Z", + "description": "Add Tree-Sitter Lua MCP tools for structural parsing, documentation extraction, and surgical editing." +} diff --git a/conductor/tracks/tree_sitter_lua_mcp_tools_20260310/plan.md b/conductor/tracks/tree_sitter_lua_mcp_tools_20260310/plan.md new file mode 100644 index 0000000..1da365e --- /dev/null +++ b/conductor/tracks/tree_sitter_lua_mcp_tools_20260310/plan.md @@ -0,0 +1,25 @@ +# Implementation Plan: Tree-Sitter Lua MCP Tools + +## Phase 1: Grammar Integration & Base Parser +- [ ] Task: Update project dependencies (e.g., `requirements.txt` or `pyproject.toml`) to include `tree-sitter-lua` or equivalent. +- [ ] Task: Write Tests: Verify the tree-sitter parser can successfully initialize the Lua language and parse a simple `local function test() end` string. +- [ ] Task: Implement: Create `src/lua_parser.py` (or extend existing AST parsers) to handle the base Lua tree-sitter initialization and generic node walking. +- [ ] Task: Conductor - User Manual Verification 'Phase 1: Grammar Integration & Base Parser' (Protocol in workflow.md) + +## Phase 2: Structural & Context Tools +- [ ] Task: Write Tests: Verify `lua_get_skeleton` and `lua_get_code_outline` against a complex Lua file containing nested functions, tables, and block comments. +- [ ] Task: Implement: Add `lua_get_skeleton` logic to extract signatures, table assignments (e.g., `Module.func = function()`), and replace bodies with `...`. +- [ ] Task: Implement: Add `lua_get_code_outline` and `lua_get_docstring` logic to traverse the AST and map line numbers and comments. +- [ ] Task: Conductor - User Manual Verification 'Phase 2: Structural & Context Tools' (Protocol in workflow.md) + +## Phase 3: Surgical Editing Tools +- [ ] Task: Write Tests: Verify `lua_get_definition` returns the exact source text of a targeted function, and `lua_update_definition` replaces it accurately within a larger file. +- [ ] Task: Implement: Add `lua_get_definition` logic using AST line/byte ranges. +- [ ] Task: Implement: Add `lua_update_definition` and `lua_set_signature` logic to perform string replacement based on strict AST node boundaries. +- [ ] Task: Conductor - User Manual Verification 'Phase 3: Surgical Editing Tools' (Protocol in workflow.md) + +## Phase 4: MCP Client Integration & Polish +- [ ] Task: Write Tests: Verify the new tools are successfully registered and invokable via the `mcp_client.py` unified interface. +- [ ] Task: Implement: Register the new `lua_*` functions as official tools in `src/mcp_client.py`. +- [ ] Task: Implement: Ensure the caching layer (mtime invalidation) is correctly applied to the new Lua parsing operations. +- [ ] Task: Conductor - User Manual Verification 'Phase 4: MCP Client Integration & Polish' (Protocol in workflow.md) diff --git a/conductor/tracks/tree_sitter_lua_mcp_tools_20260310/spec.md b/conductor/tracks/tree_sitter_lua_mcp_tools_20260310/spec.md new file mode 100644 index 0000000..17a8c84 --- /dev/null +++ b/conductor/tracks/tree_sitter_lua_mcp_tools_20260310/spec.md @@ -0,0 +1,32 @@ +# Specification: Tree-Sitter Lua MCP Tools + +## Overview +Expand the Conductor's AI context-gathering and surgical editing capabilities by introducing full Tree-Sitter parsing support for the Lua programming language. This will bring Lua to feature-parity with the existing Python MCP tools, enabling deep AST-driven structural mapping, documentation extraction, and precise code modification. + +## Functional Requirements +- **Grammar Integration:** + - Introduce `tree-sitter-lua` (or a suitable native equivalent) to the project's parsing environment to generate deterministic Abstract Syntax Trees for Lua files. +- **Structural Parsing Tools:** + - **`lua_get_skeleton`:** Extract a high-level view of a Lua file, containing all table/module declarations and function signatures with their associated comments, replacing function bodies with `...`. + - **`lua_get_code_outline`:** Generate a hierarchical text outline showing line ranges for major structural elements (functions, loops, distinct blocks). +- **Documentation & Context Tools:** + - **`lua_get_docstring` (or comment block):** Extract the block comment immediately preceding a function or module definition. + - **`lua_find_usages`:** Locate usages of specific Lua symbols/functions across a file or directory using AST or strict regex boundaries. +- **Surgical Editing Tools:** + - **`lua_get_definition`:** Extract the full source code of a specific Lua function or table definition. + - **`lua_update_definition`:** Surgically replace the implementation of a specific Lua function without relying on generic search-and-replace strings. + - **`lua_set_signature`:** Update only the signature (parameters) of a Lua function. + +## Non-Functional Requirements +- **Performance:** Parsing and skeleton generation should be heavily cached (using `mtime` invalidation) to ensure near-instantaneous responses, matching the current Python tool performance. +- **Robustness:** The parser must gracefully handle malformed Lua code, returning as much structural information as possible rather than failing entirely. + +## Acceptance Criteria +- [ ] A new suite of Lua-specific tools (`lua_get_skeleton`, `lua_get_code_outline`, `lua_get_definition`, `lua_update_definition`) is available via the MCP Client. +- [ ] Automated tests verify that `lua_get_skeleton` correctly identifies local functions, global functions, and table-assigned methods. +- [ ] `lua_update_definition` can successfully replace a multi-line function body while maintaining the surrounding file structure and indentation. +- [ ] The `tree-sitter-lua` grammar is successfully integrated into the build/setup pipeline. + +## Out of Scope +- Full language server protocol (LSP) features like deep type inference or cross-file variable renaming. +- Automated code formatting or linting for Lua (formatting relies on external ecosystem tools if needed).