Skip to content

Commit 3983178

Browse files
committed
Refine AGENTS.md for Enhanced Agent Workflow #7230
1 parent f483d5e commit 3983178

1 file changed

Lines changed: 56 additions & 13 deletions

File tree

AGENTS.md

Lines changed: 56 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -81,17 +81,48 @@ Use the `--type` (`-t`) flag to focus your search on specific types of content.
8181
- **To dive deep into implementation details:**
8282
- `npm run ai:query -- -q "afterSet hook" -t src`
8383

84-
**Strategy:** If a broad query returns too many source files and not enough conceptual documents, re-run the query with `-t guide`. Conversely, if you have read the guides but need to see the actual implementation, re-run with `-t src`.
85-
86-
#### 3. Implementation Pattern (Query Before Coding)
87-
Before writing or modifying any code, **always** query the knowledge base first to:
88-
- Look for existing similar implementations (try `-t src` or `-t example`).
89-
- Understand framework conventions for the task you are performing (try `-t guide`).
90-
- Identify common patterns used in the relevant area of the codebase.
84+
**Strategy:** If a broad query returns too many source files and not enough conceptual documents, re-run the query with `-t guide`. Conversely, if you have read the guides but need to see the actual implementation, re-run with `-t src` or `-t example`.
85+
86+
#### 3. Knowledge Base Enhancement Strategy: Contributing Intent-Driven Comments
87+
When analyzing source files (e.g., during step 2 of the Development Workflow), if you encounter code that lacks sufficient intent-driven comments or clear documentation, immediately enhance it with meaningful documentation before proceeding with your implementation.
88+
89+
1. **Analyze the Implementation**: Study the source code carefully to understand:
90+
- What the code does (mechanics)
91+
- Why it does it (intent)
92+
- How it fits into the broader architecture
93+
- What patterns it follows
94+
95+
2. **Generate Intent-Driven Comments**: Add meaningful comments that explain:
96+
- The purpose of complex methods
97+
- The reasoning behind architectural decisions
98+
- How the class fits into the framework ecosystem
99+
- Usage patterns and common scenarios
100+
101+
3. **Enhance for Future Sessions**: Your comments become part of the knowledge base, helping future AI sessions understand the code more effectively.
102+
103+
**Example of Good Intent-Driven Comments:**
104+
```javascript
105+
/**
106+
* Handles the complex lifecycle of tab activation in Neo.mjs containers.
107+
* This method coordinates between the visual tab switching UI and the
108+
* underlying card layout system, ensuring that component lifecycle
109+
* methods are properly called and that the framework's reactivity
110+
* system stays in sync.
111+
*
112+
* Key responsibilities:
113+
* - Deactivate the previous tab's associated card
114+
* - Trigger beforeTabChange and afterTabChange events
115+
* - Update the container's activeIndex config (triggers reactivity)
116+
* - Ensure proper DOM cleanup and creation
117+
*/
118+
activateTab(index, silentChange = false) {
119+
// Implementation details...
120+
}
121+
```
91122

92-
### When Queries Fail to Find Information
123+
#### 4. When Queries Fail to Find Information
93124

94-
If you cannot find relevant information after systematic querying:
125+
If you cannot find relevant information after systematic querying (including using the Knowledge Base Enhancement Strategy):
95126

96127
1. **Try alternative query terms**: Use synonyms, broader concepts, or different technical terminology
97128
2. **Query for related concepts**: Look for similar patterns or analogous implementations
@@ -111,10 +142,10 @@ Unable to find information about: "implementing custom layout managers in Neo.mj
111142
112143
Queries attempted:
113144
- "custom layout manager"
114-
- "layout implementation patterns"
145+
- "layout implementation patterns"
115146
- "extending layout base class"
116147
117-
Gap identified: Need learning guide covering layout manager development patterns,
148+
Gap identified: Need learning guide covering layout manager development patterns,
118149
lifecycle methods, and integration with container components.
119150
```
120151

@@ -132,13 +163,25 @@ If the `npm run ai:query` command itself fails or throws an error, consult the s
132163
Integrate the query tool into your development process.
133164

134165
1. **Understand the Task & Query:** For any new task (e.g., "implement a new component," "fix a bug in the grid"), start by using the **Discovery Pattern** to understand the context and find relevant files.
135-
2. **Analyze Existing Code:** Read the top 1-3 files returned by your queries. When reading, focus on understanding the existing class structure, method signatures, configuration patterns, and overall architecture. Your goal is to make your changes fit in seamlessly.
166+
2. **Analyze Existing Code & Enhance Documentation:** Read the top 1-3 files returned by your queries. When reading, focus on understanding the existing class structure, method signatures, configuration patterns, and overall architecture. **If you encounter source code lacking intent-driven comments, apply the "Knowledge Base Enhancement Strategy" to add meaningful documentation before proceeding.** Your goal is to make your changes fit in seamlessly.
136167
3. **Implement Changes:** Write or modify the code, strictly adhering to the conventions you observed.
137168
4. **Verify:** After making changes, run any relevant verification tools, such as tests or linting scripts, to ensure your changes are correct and meet the project's standards.
138169

139170
5. **Use `text` over `html` in VDOM:** When creating VDOM nodes, always prefer using the `text` property over the `html` property. `text` is mapped to the `textContent` DOM attribute, which is inherently secure against XSS attacks. `html` is mapped to `innerHTML` and should be avoided unless you are intentionally rendering trusted HTML content. This is especially important as the framework defaults to a `domApiRenderer` where `textContent` is also more performant.
140171

172+
## This Changes the Workflow
173+
174+
The enhanced workflow becomes:
175+
176+
1. **Query for understanding** (as before)
177+
2. **Read available documentation**
178+
3. **If source lacks context**: Analyze the code and **add meaningful comments**
179+
4. **Implement your changes** with the new understanding
180+
5. **The knowledge base gets richer** for the next session
181+
182+
This approach transforms the AI agent from just a consumer of documentation to a **contributor** to the project's long-term maintainability.
183+
141184
## 5. Session Maintenance
142185
Your initialization is a snapshot in time. The codebase can change. If you pull new changes from the repository, you should consider re-running your initialization steps (reading `structure.json`, `Neo.mjs`, and `core/Base.mjs`) to ensure your understanding is up-to-date.
143186

144-
Furthermore, after pulling changes, the local knowledge base may be out of sync. You should run `npm run ai:build-kb` to re-embed the latest changes into the database.
187+
Furthermore, after pulling changes, the local knowledge base may be out of sync. You should run `npm run ai:build-kb` to re-embed the latest changes into the database.

0 commit comments

Comments
 (0)