|
1 | 1 | # CodeCompass Context Improvement TODO List |
2 | 2 |
|
3 | 3 | This document outlines the tasks required to enhance CodeCompass's ability to provide comprehensive context to its AI agent, especially when dealing with large and complex git repositories. |
| 4 | + |
| 5 | +## Task: Update Documentation & Create Unit Tests for Recent Enhancements (Agent Orchestration, Background Indexing, Git Hooks) |
| 6 | + |
| 7 | +The following tasks are aimed at ensuring comprehensive documentation and robust testing for the recent major features: `agent_query` orchestration, background repository indexing with status reporting, and Git hook integration. |
| 8 | + |
| 9 | +**Prioritization Key:** |
| 10 | +* **[P0]**: Highest priority - Critical for feature stability and understanding. |
| 11 | +* **[P1]**: Medium priority - Important for comprehensive coverage and usability. |
| 12 | +* **[P2]**: Lower priority - Refinements, edge cases, and less critical components. |
| 13 | + |
| 14 | +--- |
| 15 | + |
| 16 | +### I. Documentation Updates |
| 17 | + |
| 18 | +**A. Agent Orchestration (`agent_query`)** |
| 19 | + |
| 20 | +* **[P0] `src/lib/agent.ts`**: |
| 21 | + * [ ] Update documentation to thoroughly describe its role as the primary orchestrator for the `agent_query` tool. |
| 22 | + * [ ] Detail the logic of `runAgentQueryOrchestrator`, including: |
| 23 | + * LLM-based planning and multi-step execution. |
| 24 | + * Internal capability selection and invocation. |
| 25 | + * Management and evolution of `AgentState` throughout the orchestration. |
| 26 | + * How `agent_query` replaces the previous granular agent tools. |
| 27 | + * [ ] Explain error handling mechanisms within the orchestration loop. |
| 28 | +* **[P0] `src/lib/agent_capabilities.ts`**: |
| 29 | + * [ ] Ensure all internal capabilities (e.g., `capability_searchCodeSnippets`, `capability_getRepositoryOverview`, `capability_getChangelog`, `capability_fetchMoreSearchResults`, `capability_getFullFileContent`, `capability_listDirectory`, `capability_getAdjacentFileChunks`, `capability_generateSuggestionWithContext`, `capability_analyzeCodeProblemWithContext`) are accurately documented. |
| 30 | + * [ ] For each capability, verify descriptions of its purpose, parameters (linking to or embedding Zod schema definitions from `src/lib/agent.ts` if helpful, as noted in `RETROSPECTION.md`), and return types. |
| 31 | + * [ ] Clarify the structure and usage of the shared `CapabilityContext`. |
| 32 | +* **[P1] `src/lib/server.ts` (Agent Aspects)**: |
| 33 | + * [ ] Document the registration of the single `agent_query` tool. |
| 34 | + * [ ] Clearly state the removal/deprecation of granular tool registrations previously exposed to the LLM. |
| 35 | +* **[P1] `src/lib/types.ts` (Agent Aspects)**: |
| 36 | + * [ ] Review and update documentation for `AgentState`, `AgentStep`, `ParsedToolCall`, and any related types to ensure they accurately reflect the current agent orchestration model and state management. |
| 37 | +* **[P2] `src/lib/agent-service.ts`**: |
| 38 | + * [ ] Update documentation to reflect its current, possibly simplified, role in the agent architecture. Explicitly state that complex orchestration logic now resides in `src/lib/agent.ts`. |
| 39 | + |
| 40 | +**B. Background Indexing & Status Reporting** |
| 41 | + |
| 42 | +* **[P0] `src/lib/repository.ts`**: |
| 43 | + * [ ] Provide a comprehensive overview of the background repository indexing process flow (file listing, content indexing, commit indexing, stale entry cleaning). |
| 44 | + * [ ] Document the `IndexingStatusReport` interface in detail, explaining each field (status, message, progress metrics like `totalFilesToIndex`, `filesIndexed`, `overallProgress`, etc.). |
| 45 | + * [ ] Explain the functionality and usage of `getGlobalIndexingStatus()`. |
| 46 | + * [ ] Describe how errors during indexing are handled and reflected in the status report. |
| 47 | + * [ ] Document how the system prevents concurrent indexing runs. |
| 48 | +* **[P1] `src/lib/server.ts` (Indexing Aspects)**: |
| 49 | + * [ ] Document the `/api/indexing-status` HTTP endpoint: its purpose, request/response format, and how it uses `getGlobalIndexingStatus()`. |
| 50 | + * [ ] Document the `get_indexing_status` MCP tool: its purpose, parameters (if any), and response format. |
| 51 | + * [ ] Explain that `indexRepository` is initiated asynchronously upon server startup. |
| 52 | + * [ ] Document the `/api/repository/notify-update` endpoint: its role in triggering re-indexing (e.g., via Git hooks) and its interaction with the global indexing status to prevent concurrent runs. |
| 53 | + |
| 54 | +**C. Git Hooks & .gitignore Management** |
| 55 | + |
| 56 | +* **[P1] `src/scripts/install-git-hooks.ts`**: |
| 57 | + * [ ] Document the script's purpose: to install client-side Git hooks, specifically the `post-commit` hook. |
| 58 | + * [ ] Explain its usage (e.g., `npm run setup:hooks`). |
| 59 | + * [ ] Detail what the script does (e.g., creates `.git/hooks`, copies template, sets permissions). |
| 60 | +* **[P1] `src/templates/hooks/post-commit` (or general Git Hook documentation)**: |
| 61 | + * [ ] Explain the `post-commit` hook's functionality: automatically notifying the CodeCompass server to re-index the repository after a commit. |
| 62 | + * [ ] Provide clear instructions for users on how to customize the `SERVER_URL` within their local `post-commit` hook file if their server runs on a non-default host/port (addressing point from `RETROSPECTION.md`). |
| 63 | +* **[P2] `src/scripts/update-gitignore.ts`**: |
| 64 | + * [ ] Briefly document its purpose and usage (e.g., `npm run setup:gitignore`), especially if it's part of the recommended developer setup for managing project-specific ignores. |
| 65 | +* **[P1] Project Setup Documentation (e.g., README.md)**: |
| 66 | + * [ ] Add a dedicated section explaining how to set up and use the Git hooks for automatic repository synchronization. |
| 67 | + * [ ] Mention the `npm run setup:hooks` command. |
| 68 | + |
| 69 | +**D. General Documentation Review & Maintenance** |
| 70 | + |
| 71 | +* **[P1] Comprehensive Review**: |
| 72 | + * [ ] Review all existing documentation files (especially those in `docs/source-files/` and any markdown files in the `src` tree) for consistency with the new agent orchestration, background indexing, and Git hook features. |
| 73 | + * [ ] Pay special attention to `docs/source-files/src_lib_types.md`, `docs/source-files/src_lib_query-refinement.md`, and others mentioned in `RETROSPECTION.md` to ensure they align with current data structures and functionalities. |
| 74 | +* **[P1] Update Placeholders**: |
| 75 | + * [ ] Systematically review `CHANGELOG.md` and `RETROSPECTION.md` to replace all `[GIT_COMMIT_ID_PLACEHOLDER]` or similar placeholders with actual Git commit IDs for the relevant changes. |
| 76 | + |
| 77 | +--- |
| 78 | + |
| 79 | +### II. Unit Test Creation |
| 80 | + |
| 81 | +**A. Agent Orchestration (`agent_query`)** |
| 82 | + |
| 83 | +* **[P0] `src/lib/agent.ts` (`agent_query` orchestrator - `runAgentQueryOrchestrator`)**: |
| 84 | + * [ ] Test successful execution of a multi-step plan involving several capability calls. |
| 85 | + * [ ] Test correct selection and invocation of internal capabilities (using mocks for actual capability logic). |
| 86 | + * [ ] Verify accurate parameter construction and passing to mocked capabilities. |
| 87 | + * [ ] Test proper accumulation and updating of context within `AgentState` across multiple steps. |
| 88 | + * [ ] Test handling of various LLM responses (e.g., valid plan, request for capability call, final answer). |
| 89 | + * [ ] Test error handling scenarios: |
| 90 | + * An internal capability throws an error. |
| 91 | + * The LLM returns an error or malformed response. |
| 92 | + * [ ] Test enforcement of maximum agent loop steps (`AGENT_DEFAULT_MAX_STEPS`, `AGENT_ABSOLUTE_MAX_STEPS`). |
| 93 | +* **[P0] `src/lib/agent_capabilities.ts` (Individual Capabilities)**: |
| 94 | + * [ ] For each internal capability (e.g., `capability_searchCodeSnippets`, `capability_getRepositoryOverview`, etc.): |
| 95 | + * Create dedicated unit tests. |
| 96 | + * Mock all external dependencies (LLM calls, Qdrant client, file system operations). |
| 97 | + * Test with valid input parameters, verifying correct output/return values. |
| 98 | + * Test with invalid or edge-case input parameters. |
| 99 | + * Test internal error handling and reporting. |
| 100 | +* **[P1] `src/lib/server.ts` (Agent Tool Registration)**: |
| 101 | + * [ ] Write a test to ensure the `agent_query` tool is correctly registered with the MCP server, including its schema and handler. |
| 102 | + |
| 103 | +**B. Background Indexing & Status Reporting** |
| 104 | + |
| 105 | +* **[P0] `src/lib/repository.ts` (`indexRepository` and status management)**: |
| 106 | + * [ ] Test that `indexRepository` correctly updates `currentIndexingStatus` through all its stages (mocking `git`, `qdrantClient`, `llmProvider`, and file system operations): |
| 107 | + * `initializing`, `validating_repo`, `listing_files`, `cleaning_stale_entries`, `indexing_file_content`, `indexing_commits`, `completed`. |
| 108 | + * [ ] Verify accurate calculation and reporting of progress metrics (`filesIndexed`, `totalFilesToIndex`, `commitsIndexed`, `totalCommitsToIndex`, `overallProgress`). |
| 109 | + * [ ] Test behavior with an empty repository or a repository with no new changes to index. |
| 110 | + * [ ] Test that errors encountered during any stage correctly set the status to `error` and populate `errorDetails`. |
| 111 | + * [ ] Test `getGlobalIndexingStatus()` to ensure it returns an accurate copy of the current indexing status. |
| 112 | + * [ ] Test the logic that prevents concurrent calls to `indexRepository` if it's managed within this module (e.g., by checking status before starting). |
| 113 | +* **[P1] `src/lib/server.ts` (Indexing API & Tool)**: |
| 114 | + * [ ] Write integration tests for the `/api/indexing-status` HTTP endpoint (mocking `repository.getGlobalIndexingStatus`). |
| 115 | + * [ ] Write integration tests for the `get_indexing_status` MCP tool (mocking `repository.getGlobalIndexingStatus`). |
| 116 | + * [ ] Test the `/api/repository/notify-update` endpoint: |
| 117 | + * Verify it successfully triggers `indexRepository` (mocked) when the system is idle. |
| 118 | + * Verify it handles requests appropriately (e.g., logs a message, returns a specific status) when indexing is already in progress. |
| 119 | + |
| 120 | +**C. Git Hooks & .gitignore Management** |
| 121 | + |
| 122 | +* **[P1] `src/scripts/install-git-hooks.ts`**: |
| 123 | + * [ ] Test the script's core logic (mocking `fs-extra` and file system interactions): |
| 124 | + * Ensures `.git/hooks` directory is created if it doesn't exist. |
| 125 | + * Correctly copies hook template files to `.git/hooks`. |
| 126 | + * Sets executable permissions on the copied hook files. |
| 127 | + * Handles the scenario where the `.git` directory is not found gracefully. |
| 128 | +* **[P2] `post-commit` hook interaction (Conceptual/Partial Test)**: |
| 129 | + * [ ] If feasible, unit test any core logic extracted from the `post-commit` shell script (e.g., if it were a Node.js script, or if parts of its notification logic could be isolated and tested). |
| 130 | + * [ ] *Note: Full end-to-end testing of the shell-based `post-commit` hook is likely outside the scope of unit tests and may require manual or integration testing.* |
| 131 | + |
| 132 | +--- |
0 commit comments