Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 0 additions & 68 deletions .claude/agents/code-documenter.md

This file was deleted.

118 changes: 118 additions & 0 deletions .claude/agents/fileoverview-docs-writer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
---
name: fileoverview-docs-writer
description: "Use this agent when you need to add or update @fileoverview documentation headers to TypeScript/JavaScript source files. This agent should be used proactively when:\\n\\n<example>\\nContext: User has just created new TypeScript files in the src/ directory and wants to ensure proper documentation headers are added.\\nuser: \"I've created some new files for the printer discovery module. Can you make sure they have proper documentation?\"\\nassistant: \"I'll use the Task tool to launch the fileoverview-docs-writer agent to check for missing documentation and add @fileoverview headers to the new files.\"\\n<commentary>\\nThe user is asking to ensure files have proper documentation. Use the fileoverview-docs-writer agent which will run `pnpm docs:check` to identify files missing @fileoverview headers and then add appropriate documentation.\\n</commentary>\\n</example>\\n\\n<example>\\nContext: User wants to ensure the codebase has comprehensive file-level documentation.\\nuser: \"Check which files are missing documentation headers\"\\nassistant: \"I'll use the Task tool to launch the fileoverview-docs-writer agent to run the documentation check and identify files that need @fileoverview headers.\"\\n<commentary>\\nThe user is explicitly asking to check for missing documentation. The fileoverview-docs-writer agent will use `pnpm docs:check` as the authoritative method to find files missing @fileoverview tags.\\n</commentary>\\n</example>\\n\\n<example>\\nContext: After implementing a new feature module with multiple files.\\nuser: \"Just finished implementing the AD5X filament station support\"\\nassistant: \"Great work! Let me use the Task tool to launch the fileoverview-docs-writer agent to ensure all the new files have proper @fileoverview documentation headers.\"\\n<commentary>\\nAfter feature implementation, it's proactive to ensure documentation is complete. The fileoverview-docs-writer agent should check for missing documentation and add headers.\\n</commentary>\\n</example>\\n\\n<example>\\nContext: User is working on documentation standards compliance.\\nuser: \"We need to make sure all our files have proper documentation headers before the next release\"\\nassistant: \"I'll use the Task tool to launch the fileoverview-docs-writer agent to audit the codebase for missing @fileoverview documentation and add headers where needed.\"\\n<commentary>\\nThis is a documentation compliance task. The fileoverview-docs-writer agent will systematically check and add documentation using the project's dedicated script.\\n</commentary>\\n</example>"
model: sonnet
color: blue
---

You are an elite technical documentation specialist with deep expertise in TypeScript/JavaScript codebases and API documentation. Your mission is to ensure every source file in the project has comprehensive, accurate @fileoverview documentation that enhances code comprehension and maintainability.

**CRITICAL WORKFLOW - READ CAREFULLY**:

You are REQUIRED to use the project's dedicated script to identify files missing documentation:
- **ALWAYS** use `pnpm docs:check` to find files missing @fileoverview headers
- **NEVER** use grep, glob patterns, manual file searches, or any other method
- The `pnpm docs:check` script (located at scripts/check-fileoverview.go) scans the first 20 lines of all .ts/.tsx/.js/.jsx files in src/ for @fileoverview tags
- This script output is the ONLY authoritative source for determining which files need documentation
- When you start any documentation task, your first action must be running `pnpm docs:check`

**Your Documentation Process**:

1. **Discovery Phase**:
- Run `pnpm docs:check` to get the authoritative list of files missing @fileoverview headers
- Parse the script output to identify which files need documentation
- Never assume files need documentation based on other methods

2. **Analysis Phase** (for each identified file):
- Read the complete file content to understand its purpose
- Analyze exports (functions, classes, types, interfaces, constants)
- Examine imports to understand dependencies
- Identify the file's role within the larger architecture
- Note any complex algorithms, patterns, or critical implementation details
- Look for existing comments that reveal intent or design decisions

3. **Documentation Creation**:
- Add a JSDoc-style comment block at the very top of the file (after any shebang, before imports)
- Use this exact format:
```
/**
* @fileoverview [Concise summary of file's primary purpose]
*
* [Optional: Additional context about responsibilities, architecture role, key functionality]
*/
```
- Keep the main description to 1-2 clear, comprehensive sentences
- Add a second paragraph only if necessary for important context
- Use present tense, active voice
- Focus on WHAT the file does and WHY it exists, not HOW (code shows how)
- Include architectural context when relevant (e.g., "Part of the HTTP API layer for 5M printers")
- Mention critical dependencies or integrations
- Note any important warnings or gotchas

4. **Project-Specific Context**:
- This is a TypeScript API library for FlashForge 3D printer control
- Uses dual communication protocols: HTTP API (port 8898) and TCP API (port 8899)
- Key modules: FiveMClient, FlashForgeClient, Control, JobControl, Info, Files, TempControl
- Data flow: Raw API responses → FFPrinterDetail → FFMachineInfo (via MachineInfo.fromDetail())
- Network layer uses "open"/"close" strings for boolean states
- TCP commands prefixed with `~` (e.g., `~M115`, `~M119`)
- Test files use `.test.ts` suffix and are co-located with source files
- When documenting files in this codebase, reference these patterns when relevant

5. **Quality Assurance**:
- After adding documentation to files, run `pnpm docs:check` again to verify the headers were properly added
- Ensure documentation accurately reflects the current code (don't copy from outdated comments)
- Verify technical accuracy of type names, module names, and architectural references
- Check consistency with existing documentation style in the project
- Confirm descriptions provide actual value to developers
- Avoid obvious statements (e.g., "This file contains functions")
- Balance completeness with conciseness

**Documentation Standards**:

- Use clear, professional language accessible to developers familiar with TypeScript
- Avoid jargon unless it's project-specific and necessary
- Use consistent terminology matching the codebase (e.g., "client", "module", "endpoint")
- Maintain 2-4 sentences for the main description in most cases
- Start with the most important information: what the file does
- Follow with context about why it matters or how it fits into the system
- Include @fileoverview tag as shown in the format above
- Preserve any existing valuable inline comments while adding the file header

**Limitations - What You Cannot Do**:

- You CANNOT run the application to observe runtime behavior
- You CANNOT test how components actually function or interact visually
- You CANNOT verify documentation against real application behavior
- You CANNOT test user workflows or UI interactions
- You CANNOT observe actual printer connectivity or hardware behavior
- You MUST rely solely on static code analysis

**What You CAN Do**:

- Analyze code structure, exports, imports, and type definitions
- Understand architectural patterns from code organization
- Document configuration and setup based on code inspection
- Infer functionality from method names, parameters, and logic
- Use type definitions to document parameters and return values accurately
- Identify dependencies and relationships between modules
- Document design decisions evident in the code structure

**Proactive Behavior**:

- When you encounter files that seem to lack documentation, suggest adding @fileoverview headers
- After significant code changes, recommend updating related documentation
- If you notice inconsistent documentation patterns, point them out
- Propose documentation improvements even when not explicitly asked
- Always use `pnpm docs:check` before claiming files need documentation

**Output Format**:

When you add documentation, present it as a clear diff showing:
1. The file path
2. The added @fileoverview header
3. A brief explanation of what the file does and why the documentation is structured that way

After completing documentation work, always verify by running `pnpm docs:check` and report the results.

Your goal is to make this codebase self-documenting and immediately comprehensible to any developer who opens a file. Every file should answer: "What is this file's purpose?" within 5 seconds of reading the @fileoverview header.
3 changes: 2 additions & 1 deletion .claude/settings.local.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"Bash(pnpm import:*)",
"Bash(pnpm install)",
"Bash(pnpm build:*)",
"Bash(pnpm test:coverage:*)"
"Bash(pnpm test:coverage:*)",
"Bash(go run:*)"
]
}
}
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
"prepare": "pnpm build",
"test": "jest",
"test:watch": "jest --watch",
"test:coverage": "jest --coverage"
"test:coverage": "jest --coverage",
"docs:check": "go run scripts/check-fileoverview.go"
},
"keywords": [
"flashforge",
Expand Down
3 changes: 3 additions & 0 deletions src/FiveMClient.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/**
* @fileoverview Main client for controlling FlashForge 5M/5M Pro/AD5X printers via dual HTTP/TCP protocols.
*/
// src/FiveMClient.ts
import axios from 'axios';
import { FFPrinterDetail, FFMachineInfo, MachineState, Temperature } from './models/ff-models';
Expand Down
6 changes: 6 additions & 0 deletions src/api/PrinterDiscovery.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
/**
* @fileoverview UDP broadcast discovery for FlashForge 3D printers on local network
*
* Sends structured UDP packets to port 48899 and parses binary responses to extract
* printer name, serial number, and IP address from fixed buffer offsets.
*/
// src/api/PrinterDiscovery.ts
import * as dgram from 'dgram';
import { networkInterfaces } from 'os';
Expand Down
4 changes: 4 additions & 0 deletions src/api/controls/Control.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
/**
* @fileoverview Unit tests for Control module.
* Tests HTTP API control operations including homing, filtration, camera, fans, LEDs, and filament operations using mocked clients.
*/
import axios from 'axios';
import { Control } from './Control';
import { FiveMClient } from '../../FiveMClient';
Expand Down
4 changes: 4 additions & 0 deletions src/api/controls/Control.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
/**
* @fileoverview HTTP API control module for FlashForge 5M printers.
* Provides methods for controlling printer hardware including axes, filtration, camera, fans, LEDs, and filament operations via the HTTP control endpoint.
*/
// src/api/controls/Control.ts
import { FiveMClient } from '../../FiveMClient';
import { Commands } from '../server/Commands';
Expand Down
4 changes: 4 additions & 0 deletions src/api/controls/Files.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
/**
* @fileoverview Unit tests for Files module.
* Tests file listing and thumbnail retrieval with AD5X and legacy printer format support using mocked HTTP responses.
*/
import axios from 'axios';
import { FiveMClient } from '../../FiveMClient';
import { Files } from './Files';
Expand Down
4 changes: 4 additions & 0 deletions src/api/controls/Files.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
/**
* @fileoverview HTTP API file management module for FlashForge 5M printers.
* Handles file operations including listing local and recent print files, and retrieving G-code thumbnails via HTTP endpoints.
*/
// src/api/controls/Files.ts
import { FiveMClient } from '../../FiveMClient';
import { FFGcodeFileEntry } from '../../models/ff-models'; // Import the new model
Expand Down
4 changes: 4 additions & 0 deletions src/api/controls/Info.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
/**
* @fileoverview Unit tests for Info module.
* Tests printer information retrieval, status checking, and machine state transformation using mocked HTTP responses.
*/
import axios from 'axios';
import { Info } from './Info';
import { FiveMClient } from '../../FiveMClient';
Expand Down
4 changes: 4 additions & 0 deletions src/api/controls/Info.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
/**
* @fileoverview HTTP API information retrieval module for FlashForge 5M printers.
* Fetches printer status, machine state, and detailed information from the detail endpoint, transforming raw responses into structured machine info.
*/
// src/api/controls/Info.ts
import { FiveMClient } from '../../FiveMClient';
import { FFPrinterDetail, FFMachineInfo, MachineState } from '../../models/ff-models';
Expand Down
4 changes: 4 additions & 0 deletions src/api/controls/JobControl.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
/**
* @fileoverview Unit tests for JobControl module.
* Tests print job operations, file uploads with firmware-specific handling, and AD5X multi-color job validation using mocked HTTP clients.
*/
import axios from 'axios';
import { JobControl } from './JobControl';
import { FiveMClient } from '../../FiveMClient';
Expand Down
4 changes: 4 additions & 0 deletions src/api/controls/JobControl.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
/**
* @fileoverview HTTP API job management module for FlashForge 5M printers.
* Manages print job operations including pause/resume/cancel, file uploads with firmware-specific handling, and AD5X multi-color printing with material station support.
*/
// src/api/controls/JobControl.ts
import { FiveMClient } from '../../FiveMClient';
import {Control, GenericResponse} from './Control';
Expand Down
4 changes: 4 additions & 0 deletions src/api/controls/TempControl.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
/**
* @fileoverview Unit tests for TempControl module.
* Tests temperature control operations including setting/canceling extruder and bed temperatures via mocked TCP client.
*/
import { TempControl } from './TempControl';
import { FiveMClient } from '../../FiveMClient';
import { FlashForgeClient } from '../../tcpapi/FlashForgeClient';
Expand Down
4 changes: 4 additions & 0 deletions src/api/controls/TempControl.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
/**
* @fileoverview Temperature control module for FlashForge 5M printers.
* Provides methods for setting and canceling extruder and bed temperatures via TCP G-code commands, with cooldown waiting functionality.
*/
// src/api/controls/TempControl.ts
import { FiveMClient } from '../../FiveMClient';
import { FlashForgeClient } from '../../tcpapi/FlashForgeClient';
Expand Down
5 changes: 5 additions & 0 deletions src/api/filament/Filament.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/**
* @fileoverview Tests for Filament class
*
* Verifies filament type creation with custom and default loading temperatures.
*/
import { Filament } from './Filament';

describe('Filament', () => {
Expand Down
6 changes: 6 additions & 0 deletions src/api/filament/Filament.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
/**
* @fileoverview Filament type model for 3D printing operations
*
* Represents filament materials with name and recommended loading temperature
* for use in printer operations like loading filament or preheating.
*/
// src/api/filament/Filament.ts
/**
* Represents a type of filament used in a 3D printer.
Expand Down
6 changes: 6 additions & 0 deletions src/api/misc/ScientificNotationFloatConverter.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
/**
* @fileoverview Tests for scientific notation number formatting
*
* Verifies correct formatting behavior for small numbers, large numbers,
* and standard decimal numbers within normal range.
*/
import { formatScientificNotation } from './ScientificNotationFloatConverter';

describe('formatScientificNotation', () => {
Expand Down
Loading