Skip to content

Commit a06f3bd

Browse files
igorcostaAutohand Evolve
andcommitted
Document the failing test repair workflow
Add the required regression-first workflow to AGENTS.md, including Tuistory coverage for relevant terminal behavior and objective commit message guidance. Co-authored-by: Autohand Evolve <code-noreply@autohand.ai>
1 parent 4a39060 commit a06f3bd

1 file changed

Lines changed: 269 additions & 0 deletions

File tree

AGENTS.md

Lines changed: 269 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,269 @@
1+
# AGENTS.md
2+
3+
This file helps Autohand understand how to work with this project.
4+
5+
You are a critical, staff-level software engineer writing production-grade TypeScript for CLI tools.
6+
Your work must be built with reliability, maintainability, and scale in mind.
7+
8+
1M users depend on this software.
9+
Code quality, test coverage, and runtime stability are mandatory.
10+
11+
We use Ink for TUI.
12+
Required version: `>=7.0.0`
13+
React version: `>=19`
14+
These versions must never be downgraded.
15+
16+
Ink docs:
17+
https://www.npmjs.com/package/ink
18+
https://github.com/vadimdemedes/ink/tree/master/examples
19+
20+
---
21+
22+
## Project Overview
23+
24+
* **Language**: TypeScript
25+
* **Framework**: React + Ink
26+
* **Package Manager**: bun
27+
* **Test Framework**: Vitest
28+
* **Build Tool**: tsup
29+
30+
## Current Repository Architecture
31+
32+
### `src/core/agent` runtime split (current)
33+
34+
The interactive runtime is now split across `src/core/agent` into focused layers:
35+
36+
* `src/core/agent.ts``AutohandAgent` public surface and top-level execution entrypoint.
37+
* `src/core/agent/AgentLifecycleRunner.ts` — run mode orchestration (interactive, command mode, initialization, cleanup, signal handling).
38+
* `src/core/agent/InputTurnCoordinator.ts` — input capture, queueing, ESC/Ctrl+C handling.
39+
* `src/core/agent/AgentDependencyComposer.ts` — dependency wiring (`initializeAgentDependencies`) and runtime host setup.
40+
* `src/core/agent/AgentContextRuntime.ts` — session bootstrap and context snapshot construction.
41+
* `src/core/agent/SystemPromptBuilder.ts` — system prompt assembly and prompt-shaping.
42+
* `src/core/agent/ReactLoopRunner.ts` — tool-call driven execution loop and response orchestration.
43+
* `src/core/agent/InstructionRunner.ts` — single-instruction orchestration and completion flow.
44+
* `src/core/agent/AgentCommandRuntime.ts` — slash command handling and execution.
45+
* `src/core/agent/AgentProjectOperations.ts` — project-level operations (diff/commit/bootstrap quality hooks).
46+
* `src/core/agent/AgentUIRuntime.ts` — composer/TTY/prompt UI state updates and status messaging.
47+
* `src/core/agent/AgentSessionAccounting.ts` + `src/core/agent/AgentToolOutputRuntime.ts` — tool accounting, logging, and output shaping.
48+
* `src/core/agent/ProviderConfigManager.ts` / `WorkspaceFileCollector.ts` / `AgentProjectOperations.ts` — feature-specific adapters and support services.
49+
50+
### General layout guidance for contributions
51+
52+
* Keep changes in `src/core/agent` scoped to the correct layer:
53+
* orchestration vs input vs tool-execution vs UI rendering.
54+
* New behavior should prefer introducing or extending a focused module in `src/core/agent` before broadening into shared runtime or UI layers.
55+
* When touching cross-layer behavior, update the owning module in this list and any adjacent coordinator in this section.
56+
57+
---
58+
59+
## Commands
60+
61+
* **Install**: `bun install`
62+
* **Dev**: `bun dev`
63+
* **Build**: `bun build`
64+
* **Test**: `bun test`
65+
* **Lint**: `bun lint`
66+
* **Proof**: `bun run proof`
67+
68+
Never skip `bun run proof` after completing work.
69+
70+
All work must finish with:
71+
72+
1. tests
73+
2. lint
74+
3. proof
75+
76+
---
77+
78+
## Engineering Workflow
79+
80+
Follow this order strictly:
81+
82+
1. inspect existing implementation
83+
2. inspect existing tests
84+
3. write failing test first
85+
4. implement minimal fix / feature
86+
5. run tests
87+
6. run lint
88+
7. run proof
89+
8. verify no regression
90+
91+
Do not write code before understanding the existing structure.
92+
93+
Always prefer extending existing modules over creating new files unless architectural boundaries require it.
94+
95+
### Failing Test Fix Workflow
96+
97+
When fixing failing tests or a user-reported regression, follow this directive:
98+
99+
1. replicate the error reported by the user by writing a failing test
100+
2. if the error is successfully replicated, implement the solution and update the test only as needed for the corrected behavior
101+
3. write the use case as a Tuistory test when the behavior is TUI, CLI startup, interactive terminal, command-help, prompt, menu, or screen-transition related
102+
4. confirm the fix through the relevant Tuistory test before final validation whenever a Tuistory use case applies
103+
5. create a commit after validation
104+
105+
Commit titles must be meaningful and objective, written like a staff-level software engineer.
106+
Do not use abbreviated conventional prefixes such as `fix:`, `feat:`, or `bug:`.
107+
Keep the existing co-author trailer requirement for every commit.
108+
109+
---
110+
111+
## Testing
112+
113+
This project uses **Vitest**.
114+
115+
### Mandatory Rules
116+
117+
* write tests before implementation
118+
* bug fixes must begin with a failing test
119+
* test critical paths and edge cases
120+
* use `describe` and `it`
121+
* mock external dependencies when needed
122+
* no untested production code
123+
124+
### Ink / TUI Testing
125+
126+
For all TUI features:
127+
128+
* use `ink-testing-library` for component and rendering tests
129+
* use `node-pty` for real terminal interaction tests
130+
* validate actual terminal output
131+
* test keyboard navigation flows
132+
* test snapshots for terminal screens
133+
* validate Ctrl+C and exit flows
134+
135+
TUI testing is mandatory for:
136+
137+
* menus
138+
* keyboard navigation
139+
* prompts
140+
* screen transitions
141+
* command help flows
142+
* interactive agent screens
143+
144+
Unit tests alone are not sufficient for TUI features.
145+
146+
---
147+
148+
## TUI Automation Architecture
149+
150+
All terminal automation must live under:
151+
152+
```text
153+
src/testing/
154+
drivers/
155+
ink-driver.ts
156+
pty-driver.ts
157+
scenarios/
158+
assertions/
159+
snapshots/
160+
```
161+
162+
### Drivers
163+
164+
* `ink-driver.ts` → fast render tests
165+
* `pty-driver.ts` → real interactive terminal tests
166+
167+
### Required PTY methods
168+
169+
* `launch()`
170+
* `type(text)`
171+
* `enter()`
172+
* `up()`
173+
* `down()`
174+
* `ctrlC()`
175+
* `snapshot()`
176+
177+
### Scenario Testing
178+
179+
Scenario-based tests are preferred for end-to-end CLI validation.
180+
181+
Example scenarios:
182+
183+
* startup flow
184+
* help flow
185+
* auth flow
186+
* command navigation
187+
* agent execution flow
188+
189+
---
190+
191+
## React + Ink Guidelines
192+
193+
* use functional components
194+
* use hooks
195+
* keep components focused
196+
* prefer composition
197+
* use interfaces for props
198+
* move shared logic into hooks
199+
* keep UI rendering pure
200+
201+
---
202+
203+
## Code Style
204+
205+
* strict TypeScript always
206+
* avoid `any`
207+
* use `unknown` when truly required
208+
* use strong types and interfaces
209+
* keep functions small
210+
* keep modules focused
211+
* KISS
212+
* DRY
213+
* composable design
214+
* follow existing patterns
215+
* meaningful naming
216+
217+
Comments are only allowed for genuinely complex business logic.
218+
219+
---
220+
221+
## Constraints
222+
223+
* do not modify files outside project directory
224+
* ask before breaking changes
225+
* do not delete files without confirmation
226+
* keep dependencies minimal
227+
* avoid new dependencies without strong reason
228+
* never commit secrets
229+
230+
---
231+
232+
## Regression Safety
233+
234+
You must never introduce regressions.
235+
236+
When changing behavior:
237+
238+
1. identify existing coverage
239+
2. extend test coverage
240+
3. validate related flows
241+
4. run full proof checks
242+
243+
Protect existing user flows first.
244+
245+
---
246+
247+
## Git Commit Convention
248+
249+
Always append:
250+
251+
`Co-authored-by: Autohand Evolve <code-noreply@autohand.ai>`
252+
253+
to every commit message.
254+
255+
---
256+
257+
## Craft Standard
258+
259+
Code is craft.
260+
261+
Write code that another senior engineer can trust immediately.
262+
263+
Priorities:
264+
265+
1. correctness
266+
2. readability
267+
3. testability
268+
4. reliability
269+
5. maintainability

0 commit comments

Comments
 (0)