Skip to content

Commit d6f145e

Browse files
committed
Add AGENTS.md
1 parent 22b1906 commit d6f145e

File tree

1 file changed

+360
-0
lines changed

1 file changed

+360
-0
lines changed

AGENTS.md

Lines changed: 360 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,360 @@
1+
# Doc Detective Documentation - AI Coding Agent Instructions
2+
3+
This document provides guidance for AI coding agents working on the Doc Detective documentation website.
4+
5+
## Architecture and Core Concepts
6+
7+
This is a [Docusaurus](https://docusaurus.io/) v3 website. The primary purpose is to provide documentation for the `doc-detective` tool.
8+
9+
- **Configuration**: The main configuration file is `docusaurus.config.ts`. It controls navigation, plugins, sidebars, and integrations.
10+
- **Content**: Documentation is written in Markdown and located in the `docs/` directory. The sidebar structure is defined in `sidebars.ts`.
11+
- **Components**: Custom React components are in `src/components/`. These are used to enhance the documentation pages. The site uses TypeScript and React.
12+
- **Styling**: Custom CSS is located in `src/css/custom.css`.
13+
- **JSON Schemas**: The project uses `docusaurus-json-schema-plugin` to render JSON schema documentation. A custom script (`.scripts/buildSchemaReferencesV4.js`) runs before builds (`npm run build-schemas`) to process these schemas. This is a key part of documenting the configuration for Doc Detective.
14+
15+
## Development Workflow
16+
17+
1. **Setup**:
18+
- To install dependencies, run `npm install`.
19+
- To start the local development server, run `npm run start`. The site will be available at `http://localhost:3000`.
20+
21+
2. **Common Tasks**:
22+
- **Build**: To create a production build, run `npm run build`.
23+
- **Component Development**: [Storybook](https://storybook.js.org/) is used for UI component development. Run `npm run storybook` to start the Storybook server. Component stories are in `src/stories/`.
24+
25+
## Testing
26+
27+
A unique aspect of this project is that it uses **Doc Detective to test its own documentation**.
28+
29+
- **Test Execution**: To run the tests, use the command: `npm run doc-detective`.
30+
- **Test Files**: The tests are defined in `.spec.json` files. These files contain a series of steps that Doc Detective executes against the live documentation site to ensure it's accurate. An example can be found at `docs/sampletest.spec.json`.
31+
- **Workflow**: This "dogfooding" approach is a critical workflow. When you change documentation related to a feature, you should review the corresponding `.spec.json` file to see if the test needs to be updated.
32+
33+
## Key Conventions
34+
35+
- **Adding Docs**: To add a new documentation page, create a new `.mdx` file in the appropriate subdirectory within `docs/` and add it to `sidebars.ts`.
36+
- **Custom Components**: You can create custom React components in `src/components/` and use them within your `.mdx` files or as custom pages in `src/pages/`.
37+
- **Deployment**: The site is automatically deployed via GitHub Pages when changes are merged into the `main` branch. The deployment process uses the `gh-pages` branch.
38+
39+
## Docusaurus Implementation Guide
40+
41+
This site uses Docusaurus v3 with MDX support. Here are the key features and how to use them:
42+
43+
### Admonitions (Callout Boxes)
44+
45+
Use admonitions to highlight important information. Available types: `note`, `tip`, `info`, `warning`, `danger`.
46+
47+
```markdown
48+
:::info
49+
Drag-and-drop has many different implementations, and Doc Detective wants to support them all.
50+
:::
51+
52+
:::warning
53+
Make sure to set the port number to `8080` in your VSCode settings.
54+
:::
55+
```
56+
57+
**With custom titles:**
58+
```markdown
59+
:::tip[Pro tip]
60+
Use plugins to introduce shorter syntax for commonly used JSX elements.
61+
:::
62+
```
63+
64+
### Tabs for Multi-Option Content
65+
66+
Use tabs to present multiple alternatives (like different programming languages or platforms):
67+
68+
```mdx
69+
import Tabs from "@theme/Tabs";
70+
import TabItem from "@theme/TabItem";
71+
72+
<Tabs>
73+
<TabItem value='python' label='Python'>
74+
```bash
75+
python -m http.server 8080
76+
```
77+
</TabItem>
78+
<TabItem value='node' label='Node.js'>
79+
```bash
80+
npx http-server
81+
```
82+
</TabItem>
83+
</Tabs>
84+
```
85+
86+
### Code Blocks with Features
87+
88+
Code blocks support syntax highlighting, titles, and line numbers:
89+
90+
```markdown
91+
```json title="homepage-check.spec.json"
92+
{
93+
"tests": [
94+
{
95+
"steps": []
96+
}
97+
]
98+
}
99+
\```
100+
```
101+
102+
### Mermaid Diagrams
103+
104+
The site has `@docusaurus/theme-mermaid` enabled. Create diagrams with:
105+
106+
```markdown
107+
```mermaid
108+
graph TD;
109+
A[Start Test] --> B[Navigate to URL];
110+
B --> C[Find Element];
111+
C --> D[Take Screenshot];
112+
\```
113+
```
114+
115+
### Custom React Components in MDX
116+
117+
Import and use React components directly in `.mdx` files:
118+
119+
```mdx
120+
import JSONSchemaViewer from "@theme/JSONSchemaViewer";
121+
import { schemas } from "doc-detective-common";
122+
123+
<JSONSchemaViewer schema={ schemas.dragAndDrop_v3 } />
124+
```
125+
126+
**Available custom components:**
127+
- `JSONSchemaViewer`: Renders JSON schema documentation (from `docusaurus-json-schema-plugin`)
128+
- `CodeBlock`: Enhanced code blocks from `@theme/CodeBlock`
129+
- Custom components in `src/components/`: `JSONBlock`, `SchemaForms`, etc.
130+
131+
### Front Matter
132+
133+
Always include front matter for docs:
134+
135+
```markdown
136+
---
137+
title: dragAndDrop
138+
description: Drag an element to a target location.
139+
sidebar_label: Drag and Drop
140+
---
141+
```
142+
143+
### File Extensions
144+
145+
- **Always use `.mdx`** for documentation files (even if you're not currently using React components or JSX)
146+
- This provides flexibility to add React components later without renaming files
147+
- Docusaurus handles both Markdown and MDX syntax in `.mdx` files
148+
149+
## Content and Style Guide
150+
151+
### Google Developer Style Guide
152+
153+
All documentation must follow the [Google Developer Style Guide](https://developers.google.com/style). Key principles:
154+
155+
**Voice and Tone:**
156+
- Write conversationally and friendly, like a knowledgeable friend, without being frivolous or overly colloquial
157+
- Avoid buzzwords, jargon, exclamation marks (except rare exciting moments), and phrases like "simply" or "it's easy"
158+
- Don't use "please" in instructions: ✅ "Click **View**" not ❌ "Please click **View**"
159+
160+
**Language and Grammar:**
161+
- Use second person ("you") rather than first person ("we")
162+
- Use active voice: ✅ "Click the button" not ❌ "The button can be clicked"
163+
- Use present tense: ✅ "The API returns data" not ❌ "The API will return data"
164+
- Put conditions before instructions: ✅ "If you want to save, click **Save**" not ❌ "Click **Save** if you want to save"
165+
166+
**Formatting:**
167+
- Use sentence case for headings (not Title Case)
168+
- Use numbered lists for sequential steps
169+
- Use bulleted lists for non-sequential items
170+
- Use serial commas (Oxford commas)
171+
- Put code-related text in `code font`
172+
- Put UI elements in **bold**
173+
174+
**Examples of Tone:**
175+
- ✅ Good: "To get the user's phone number, call `user.phoneNumber.get`."
176+
- ❌ Too casual: "Dude! This API is totally awesome!"
177+
- ❌ Too formal: "The telephone number can be retrieved by the developer via the simple expedient of using the get method."
178+
179+
### The Good Docs Project Templates
180+
181+
When creating new documentation, use templates from [The Good Docs Project](https://gitlab.com/tgdp/templates/-/releases) as a starting point to ensure consistent, user-friendly structure:
182+
183+
**Concept** - Explains what something is and why it matters (background knowledge)
184+
```markdown
185+
# Test contexts
186+
187+
A test context is a logical grouping of test specifications that share
188+
common configuration settings.
189+
190+
## What is a test context?
191+
192+
A test context defines the environment and settings for running tests,
193+
including the browser type, viewport size, and application URL.
194+
195+
## Why use test contexts?
196+
197+
Test contexts let you:
198+
- Run the same tests across different environments
199+
- Share configuration across multiple test files
200+
- Organize tests by application area or user role
201+
202+
## When to use test contexts
203+
204+
Use test contexts when you need to test the same functionality across
205+
multiple browsers or configurations.
206+
```
207+
208+
**How-To** - Task-oriented guides for accomplishing specific goals
209+
```markdown
210+
# How to validate form inputs
211+
212+
This guide shows you how to test form validation in your documentation.
213+
214+
## Before you begin
215+
216+
- Install Doc Detective
217+
- Have a test specification file ready
218+
219+
## Validate required fields
220+
221+
1. Navigate to the form page:
222+
```json
223+
{"action": "goTo", "url": "https://example.com/form"}
224+
```
225+
226+
2. Submit the form without filling required fields:
227+
```json
228+
{"action": "click", "selector": "#submit-button"}
229+
```
230+
231+
3. Verify the error message appears:
232+
```json
233+
{"action": "find", "selector": ".error-message",
234+
"matchText": "This field is required"}
235+
```
236+
237+
## What's next
238+
239+
- Learn about [testing user workflows](link)
240+
- Explore [advanced validation patterns](link)
241+
```
242+
243+
**Tutorial** - Learning-oriented lessons that guide users through a complete workflow
244+
```markdown
245+
# Create your first test
246+
247+
In this tutorial, you create a simple test that validates a documentation
248+
page loads correctly and contains the expected content.
249+
250+
## What you'll learn
251+
252+
- How to structure a test specification
253+
- How to navigate to a page
254+
- How to verify page content
255+
256+
## What you'll need
257+
258+
- Node.js 18 or later
259+
- 15 minutes
260+
261+
## Step 1: Create a test specification file
262+
263+
Create a file named `first-test.spec.json`:
264+
265+
```json
266+
{
267+
"tests": [
268+
{
269+
"id": "my-first-test",
270+
"description": "Verify homepage loads"
271+
}
272+
]
273+
}
274+
```
275+
276+
## Step 2: Add navigation
277+
278+
Add a `goTo` action to navigate to your documentation:
279+
280+
```json
281+
{
282+
"tests": [
283+
{
284+
"id": "my-first-test",
285+
"description": "Verify homepage loads",
286+
"steps": [
287+
{"action": "goTo", "url": "https://doc-detective.com"}
288+
]
289+
}
290+
]
291+
}
292+
```
293+
294+
## Step 3: Run your test
295+
296+
Run the test with the Doc Detective CLI:
297+
298+
```bash
299+
npx doc-detective runTests --input first-test.spec.json
300+
```
301+
302+
You should see output indicating the test passed.
303+
304+
## What you learned
305+
306+
You created a basic test specification and ran it successfully.
307+
308+
## Next steps
309+
310+
- Add content validation with the `find` action
311+
- Learn about [test contexts](link)
312+
```
313+
314+
**Reference** - Information-oriented technical descriptions (API docs, configuration options)
315+
```markdown
316+
# goTo action
317+
318+
Navigates the browser to a specified URL.
319+
320+
## Syntax
321+
322+
```json
323+
{
324+
"action": "goTo",
325+
"url": "string"
326+
}
327+
```
328+
329+
## Parameters
330+
331+
| Parameter | Type | Required | Description |
332+
|-----------|--------|----------|-------------|
333+
| action | string | Yes | Must be "goTo" |
334+
| url | string | Yes | The URL to navigate to. Must include protocol (http:// or https://) |
335+
336+
## Examples
337+
338+
### Navigate to a documentation page
339+
340+
```json
341+
{
342+
"action": "goTo",
343+
"url": "https://doc-detective.com/docs/get-started"
344+
}
345+
```
346+
347+
### Navigate to localhost
348+
349+
```json
350+
{
351+
"action": "goTo",
352+
"url": "http://localhost:3000"
353+
}
354+
```
355+
356+
## Related actions
357+
358+
- `find` - Verify elements exist on the page
359+
- `click` - Interact with page elements
360+
```

0 commit comments

Comments
 (0)