Skip to content

Commit 46c19ac

Browse files
committed
Refactor: Add maintenance report and implementation plan (journal updated).
1 parent 3a72268 commit 46c19ac

7 files changed

Lines changed: 204 additions & 13 deletions

File tree

.gemini/agents/planner.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,14 @@ max_turns: 15
1313
You are an expert software architect and strategic planner. Your sole mission is to analyze the codebase and produce a comprehensive execution plan for a specific objective.
1414

1515
**Mandates:**
16-
1. **Read-Only Mode:** You MUST NOT modify, create, or delete any files in the repository. Use your search and read tools strictly for investigation.
17-
2. **Deep Context:** Investigate the existing architecture, file structure, and relevant dependencies before proposing any changes.
18-
3. **Actionable Output:** Your final output must be a highly detailed, step-by-step Markdown plan. It should include:
16+
1. **Strictly Read-Only:** You MUST NOT modify, create, or delete any files in the repository. You do not have access to write tools. Use your search and read tools strictly for investigation.
17+
2. **Analysis-to-Return Workflow:** Your role is to generate the plan and return it as your final response. You DO NOT save the plan to a file; the orchestrating command will handle persistence.
18+
3. **Deep Context:** Investigate the existing architecture, file structure, and relevant dependencies before proposing any changes.
19+
4. **Actionable Output:** Your final output must be a highly detailed, step-by-step Markdown plan. It should include:
1920
- **Objective:** A clear summary of the goal.
2021
- **Architectural Impact:** High-level overview of how the change fits into the existing system.
2122
- **File Operations:** Explicitly list which files need to be modified, created, or deleted.
2223
- **Step-by-Step Execution:** A logical sequence of tasks (e.g., Step 1: Update API, Step 2: Implement UI, Step 3: Add Tests).
2324
- **Testing Strategy:** How to validate the changes.
2425

25-
When given an objective, thoroughly investigate the codebase and return the final Markdown plan.
26+
When given an objective, thoroughly investigate the codebase and return the final Markdown plan content.

.gemini/commands/plan.toml

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,18 @@ Follow these phases strictly:
1111
1. Do not start planning immediately. Analyze the user's initial request.
1212
2. If the request is vague or lacks specific technical details, use `ask_user` to ask 1-3 targeted, follow-up questions to gather necessary context. (e.g., "Are we targeting a specific UI component?", "Should this include database migrations?").
1313
14-
### Phase 2: Agentic Analysis
14+
### Phase 2: Agentic Analysis (Planner)
1515
1. Once you have a clear understanding of the objective, invoke the `planner` subagent.
16-
2. Pass the fully clarified objective to the `planner`. The `planner` will scan the repository and return a detailed Markdown plan.
17-
3. Review the plan with the user, and apply necessary corrections or adjustments based on their feedback. Use `ask_user` to confirm any changes.
18-
4. Ensure the final plan is comprehensive, actionable, and aligned with the user's goals before proceeding to the next phase.
19-
20-
### Phase 3: Saving the Plan
21-
1. Ensure the `plans/` directory exists.
22-
2. Take the Markdown plan generated by the `planner` agent and save it to a new file in the `plans/` directory. Use a descriptive, kebab-case filename (e.g., `plans/implement-auth.md`).
23-
3. Notify the user that the plan has been saved.
16+
2. **Analysis-to-Content Workflow:** Instruct the `planner` to scan the repository and return a detailed Markdown plan.
17+
3. **Wait for Content:** Ensure the `planner` returns the full Markdown content of the plan.
18+
4. Review the plan with the user, and apply necessary corrections or adjustments based on their feedback. Use `ask_user` to confirm any changes.
19+
20+
### Phase 3: Persistence (Saving the Plan)
21+
1. **Command Responsibility:** As the orchestrating command, YOU are responsible for saving the plan. The `planner` agent is read-only.
22+
2. Ensure the `plans/` directory exists.
23+
3. Take the Markdown plan generated by the `planner` agent and save it to a new file in the `plans/` directory using `write_file`.
24+
4. Use a descriptive, kebab-case filename (e.g., `plans/implement-auth.md`).
25+
5. Notify the user that the plan has been saved.
2426
2527
### Phase 4: Task Synchronization (TASKS.md)
2628
1. Read the current `TASKS.md` file to understand the project roadmap.

TASKS.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ Put done tasks into the Archive.
1818

1919
## Active Tasks
2020

21+
- [ ] Implement documentation harmonization and refactor tests for dynamic synchronization. (See plan: plans/maintenance-improvements.md)
22+
2123
---
2224

2325
## Archive

journal/2026-03-23.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@
1111
[2026-03-23T06:07:18] - Align README, Style Guide, Docs, and historical entries with writer/reviewer naming.
1212
[2026-03-23T06:08:20] - Archive completed /draft command and writer agent improvement task.
1313
[2026-03-23T06:50:29] - Refactor /maintenance command into a read-only audit workflow using codebase_investigator.
14+
[2026-03-23T07:10:07] - Perform maintenance audit and generate implementation plan for documentation harmonization.

plans/maintenance-improvements.md

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
# Execution Plan: Documentation and Test Synchronization
2+
3+
## Objective
4+
Harmonize the project's documentation with its implementation by standardizing command names, filling documentation gaps, and replacing brittle tests with a dynamic synchronization verification suite.
5+
6+
## Architectural Impact
7+
- **Consistency:** Ensures that users and AI agents have a single, accurate source of truth for command names and capabilities.
8+
- **Maintainability:** Reduces test suite fragility by moving from hard-coded string matching to dynamic discovery.
9+
- **Safety:** Strengthens the link between implementation (TOML/Markdown) and documentation (README/User Guide) through automated CI checks.
10+
11+
## File Operations
12+
13+
### Files to Modify:
14+
- `README.md`: Update `/learn` description; ensure `/document` is correctly referenced.
15+
- `docs/index.md`: Rename `/docs` references to `/document`.
16+
- `docs/user-guide.md`:
17+
- Rename `/docs` to `/document`.
18+
- Add missing `/scaffold` and `/onboard` sections.
19+
- Remove redundant `/learn` section.
20+
- Explicitly identify `learner` and `debugger` as subagents.
21+
- `tests/test_review_command.py`: Refactor to remove brittle string assertions.
22+
23+
### Files to Create:
24+
- `tests/test_sync.py`: New dynamic test suite for implementation-documentation synchronization.
25+
26+
---
27+
28+
## Step-by-Step Execution
29+
30+
### Phase 1: Documentation Harmonization
31+
32+
#### Step 1.1: Update `docs/index.md`
33+
- Replace the legacy `/docs` command reference with `/document` in the "Key Capabilities" section.
34+
35+
#### Step 1.2: Update `docs/user-guide.md`
36+
- **Search & Replace:** Globally replace `/docs` with `/document`.
37+
- **Deduplication:** Remove the second, redundant occurrence of the `### /learn` section.
38+
- **Explicit Agent Identification:**
39+
- Update the `/learn` section to explicitly mention the `learner` subagent.
40+
- Update the `/debug` section to explicitly mention the `debugger` subagent.
41+
- **Add Missing Commands:**
42+
- Add a `### /onboard` section under "The Discovery & Strategy Workflow".
43+
- Add a `### /scaffold` section under "The Software Development Workflow".
44+
45+
#### Step 1.3: Update `README.md`
46+
- Update the `/learn` section under "Phase 1: Planning & Discovery" to explicitly mention the `learner` subagent (consistent with how `/debug` and `/plan` are described).
47+
48+
---
49+
50+
### Phase 2: Test Suite Refactoring
51+
52+
#### Step 2.1: Refactor `tests/test_review_command.py`
53+
- Modify `test_reviewer_agent_has_grep_search` to verify file existence and basic Markdown structure (e.g., presence of a title) instead of specific tool names like `grep_search`.
54+
- Modify `test_review_command_is_multiphase` to verify the TOML file contains `description` and `prompt` keys, rather than searching for specific "Phase X" strings.
55+
- Simplify `test_maintenance_command_is_audit` and `test_planner_agent_read_only` to focus on existence and high-level role rather than internal implementation details.
56+
- Retain "gone" file checks (e.g., `test_editor_agent_gone`) as they validate successful migrations.
57+
58+
---
59+
60+
### Phase 3: Dynamic Synchronization Implementation
61+
62+
#### Step 3.1: Create `tests/test_sync.py`
63+
Implement a pytest-compatible script that performs the following:
64+
1. **Command Discovery:** Programmatically list all `.toml` files in `.gemini/commands/`.
65+
2. **Agent Discovery:** Programmatically list all `.md` files in `.gemini/agents/`.
66+
3. **Forward Sync Check:**
67+
- Verify every discovered command is mentioned as `/{command}` in both `README.md` and `docs/user-guide.md`.
68+
- Verify every discovered agent is mentioned in `docs/design.md` and `docs/user-guide.md`.
69+
4. **Reverse Sync Check:**
70+
- Parse `README.md` and `docs/user-guide.md` for any strings matching the `/{command}` pattern.
71+
- Assert that each found pattern (excluding known exceptions like `/docs`) has a corresponding `.toml` file in `.gemini/commands/`.
72+
5. **Agent Role Verification:**
73+
- Ensure `README.md` and `docs/user-guide.md` use the terms "agent" or "subagent" when describing the specialized roles (e.g., `planner`, `researcher`, `learner`).
74+
75+
---
76+
77+
## Testing Strategy
78+
79+
### 1. Manual Validation
80+
- Inspect the modified `docs/user-guide.md` and `README.md` to ensure formatting is correct and descriptions are accurate.
81+
- Verify that the `/document` command is used consistently across all files.
82+
83+
### 2. Automated Validation
84+
- **Run the refactored suite:** Execute `pytest tests/test_review_command.py` to ensure the new, leaner assertions pass.
85+
- **Run the synchronization suite:** Execute `pytest tests/test_sync.py`. This test is expected to fail initially if any commands were missed during the manual update phase, providing an automated "punch list" for completion.
86+
87+
### 3. CI/CD Integration
88+
- Ensure these new tests are picked up by the `make test` target, which is triggered by the `pre-commit.py` hook and GitHub Actions.
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# Maintenance Report Card - 2026-03-23
2+
3+
## Executive Summary
4+
This audit focused on the synchronization between implementation (commands and agents) and documentation (README and user guides), as well as the robustness of the test suite. While the core functionality is well-documented, there are notable inconsistencies in command naming and coverage across different documentation files. Additionally, the current test suite is overly brittle due to specific content matching.
5+
6+
---
7+
8+
## 🛠️ Command & Agent Inventory
9+
10+
### Commands (.gemini/commands/) - 15 Total
11+
- `commit`, `cron`, `debug`, `document`, `draft`, `issues`, `learn`, `maintenance`, `onboard`, `plan`, `release`, `research`, `review`, `scaffold`, `task`.
12+
13+
### Agents (.gemini/agents/) - 6 Total
14+
- `debugger`, `learner`, `planner`, `researcher`, `reviewer`, `writer`.
15+
16+
---
17+
18+
## 🔍 Synchronization Audit
19+
20+
### 1. Naming Inconsistencies
21+
- **Critical Issue:** The command defined in `.gemini/commands/document.toml` is correctly referred to as `/document` in `README.md`, but incorrectly as `/docs` in `docs/index.md` and `docs/user-guide.md`.
22+
- **Impact:** Users following the documentation will encounter errors if they attempt to run `/docs`.
23+
24+
### 2. Documentation Coverage Gaps
25+
- **README.md:** Comprehensive. Mentions all 15 commands.
26+
- **docs/user-guide.md:**
27+
- **Missing Commands:** `/scaffold`, `/onboard`.
28+
- **Naming Error:** Uses `/docs` instead of `/document`.
29+
- **docs/index.md:**
30+
- **Naming Error:** Uses `/docs` instead of `/document`.
31+
32+
### 3. Agent Mentions
33+
- Agents are generally well-represented, but `learner` and `debugger` are sometimes mentioned only through their respective commands (`/learn`, `/debug`) rather than being explicitly identified as subagents in all documentation sections.
34+
35+
---
36+
37+
## 🧪 Test Suite Analysis
38+
39+
### Observations on `tests/test_review_command.py`
40+
The current tests are **overly strict** and prone to failure when the implementation details change. Specifically:
41+
- `test_reviewer_agent_has_grep_search`: Asserts exact string `"grep_search"` in `reviewer.md`.
42+
- `test_review_command_is_multiphase`: Asserts exact strings `"Phase 1"`, `"Phase 2"`, etc.
43+
- `test_maintenance_command_is_audit`: Asserts exact output strings and internal agent names.
44+
- `test_planner_agent_read_only`: Asserts lack of `"write_file"` and `"replace"` strings.
45+
46+
### Actionable Suggestion for Tests
47+
Refactor the tests to be **dynamic and behavior-oriented**:
48+
1. **Dynamic Discovery:** Iterate through `.gemini/commands/*.toml` and `.gemini/agents/*.md`.
49+
2. **Sync Verification:** Ensure every command file found has a corresponding entry in `README.md` and `docs/user-guide.md`.
50+
3. **Reverse Sync:** Ensure every command mentioned in `docs/*.md` exists in `.gemini/commands/`.
51+
4. **Generic Validation:** Check for TOML validity and basic structure rather than specific wording.
52+
53+
---
54+
55+
## 📝 Actionable Recommendations
56+
57+
1. **Standardize Command Names:** Rename `document.toml` to `docs.toml` OR update all documentation to use `/document`. (Recommendation: Rename to `docs.toml` for brevity and alignment with user expectations).
58+
2. **Harmonize Documentation:** Update `docs/user-guide.md` to include missing commands (`/scaffold`, `/onboard`) and fix the `/docs` vs `/document` discrepancy.
59+
3. **Refactor Tests:** Implement a new test file (e.g., `tests/test_sync.py`) that programmatically verifies the 1:1 mapping between implementation and documentation.
60+
4. **Leaner Assertions:** Remove specific content assertions from `tests/test_review_command.py` to prevent unnecessary maintenance overhead.
61+
62+
---
63+
64+
## 💡 Orchestration Tip
65+
Use the `/plan` command, pointing to this report, to formulate a safe strategy for standardizing command names and refactoring the test suite to ensure long-term maintainability.

tests/test_review_command.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,24 +70,56 @@ def test_maintenance_command_is_audit():
7070
# Ensure it doesn't mention Step-by-Step Implementation or modification
7171
assert "Step-by-Step Implementation" not in content
7272

73+
def test_planner_agent_read_only():
74+
with open(".gemini/agents/planner.md", "r") as f:
75+
content = f.read()
76+
assert "planner" in content.lower()
77+
assert "read-only" in content.lower()
78+
79+
def test_plan_command_persistence_responsibility():
80+
with open(".gemini/commands/plan.toml", "r") as f:
81+
content = f.read()
82+
assert "Command Responsibility" in content
83+
assert "responsible for saving the plan" in content.lower()
84+
assert "planner" in content.lower()
85+
assert "agent" in content.lower()
86+
assert "read-only" in content.lower()
87+
7388
if __name__ == "__main__":
7489
# Simple manual runner for now
7590
try:
91+
print("Checking reviewer agent exists...")
7692
test_reviewer_agent_exists()
93+
print("Checking editor agent gone...")
7794
test_editor_agent_gone()
95+
print("Checking review command exists...")
7896
test_review_command_exists()
97+
print("Checking revise command gone...")
7998
test_revise_command_gone()
99+
print("Checking reviewer agent has grep_search...")
80100
test_reviewer_agent_has_grep_search()
101+
print("Checking review command is multi-phase...")
81102
test_review_command_is_multiphase()
103+
print("Checking draft command suggests review...")
82104
test_draft_command_suggests_review()
105+
print("Checking docs updated...")
83106
test_docs_updated()
84107

108+
print("Checking writer agent exists...")
85109
test_writer_agent_exists()
110+
print("Checking reporter agent gone...")
86111
test_reporter_agent_gone()
112+
print("Checking writer agent has replace...")
87113
test_writer_agent_has_replace()
114+
print("Checking draft command is multi-mode...")
88115
test_draft_command_is_multimode()
89116

117+
print("Checking maintenance command is audit...")
90118
test_maintenance_command_is_audit()
119+
print("Checking planner agent is read-only...")
120+
test_planner_agent_read_only()
121+
print("Checking plan command persistence responsibility...")
122+
test_plan_command_persistence_responsibility()
91123

92124
print("Tests Passed")
93125
except AssertionError as e:

0 commit comments

Comments
 (0)