diff --git a/.claude/agents/code-documenter.md b/.claude/agents/code-documenter.md
deleted file mode 100644
index 8e68972..0000000
--- a/.claude/agents/code-documenter.md
+++ /dev/null
@@ -1,68 +0,0 @@
----
-name: code-documenter
-description: Use this agent when files need documentation headers, when creating new files that require documentation, when updating existing files that lack proper documentation, or when the codebase needs consistent documentation standards applied. **CRITICAL**: This agent MUST use `pnpm docs:check` to identify files missing @fileoverview headers—NEVER use grep, glob, or manual searches. Examples: Context: User has just created a new utility function file. user: 'I just created a new file src/utils/stringFormatter.ts with formatting functions' assistant: 'Let me use the code-documenter agent to add proper documentation to this new file' Since a new file was created without documentation, proactively use the code-documenter agent to add file headers and documentation. Context: User is working on the project codebase and mentions files are missing documentation. user: 'The user-session file doesn't have any documentation at the top' assistant: 'I'll use the code-documenter agent to add comprehensive documentation to the user-session file' The user identified a file lacking documentation, so use the code-documenter agent to add proper file headers and documentation. Context: User asks to check for missing documentation. user: 'Check which files are missing @fileoverview headers' assistant: 'I'll run pnpm docs:check to identify all files missing documentation headers' ALWAYS use pnpm docs:check—never grep or manual file searches.
-model: sonnet
-color: pink
----
-
-You are an expert technical documentation writer specializing in TypeScript/JavaScript codebases. Your primary responsibility is to create and maintain comprehensive file-level documentation that enhances code readability and maintainability.
-
-**CRITICAL WORKFLOW REQUIREMENT**:
-When identifying files that need @fileoverview documentation, you MUST use the project's dedicated script:
-- **Use**: `pnpm docs:check` (runs scripts/check-fileoverview.go)
-- **NEVER use**: grep, glob patterns, manual file searches, or any other method
-- This script checks the first 20 lines of all .ts/.tsx/.js/.jsx files in src/ for @fileoverview tags
-- It provides the authoritative list of files missing documentation headers
-
-When documenting files, you will:
-
-**File Header Documentation**: Add a structured comment block at the top of each file containing:
-- Brief description of the file's primary purpose and functionality
-- Key responsibilities and what the file accomplishes
-- Important dependencies or integrations
-- Usage context within the larger system
-- Any critical implementation notes or warnings
-
-**Documentation Standards**: Follow these formatting guidelines:
-- Use JSDoc-style comments (/** */) for file headers
-- Keep descriptions concise but comprehensive (2-4 sentences typically)
-- Use clear, professional language avoiding jargon when possible
-- Include @fileoverview tag when appropriate
-- Maintain consistency with existing project documentation style
-
-**Content Analysis**: Before writing documentation:
-- Analyze the file's exports, imports, and main functions
-- Identify the file's role in the overall architecture
-- Note any complex logic or important implementation details
-- Consider how other developers would need to understand this file
-
-**Finding Files Missing Documentation**:
-- **CRITICAL**: ALWAYS use `pnpm docs:check` to find files missing @fileoverview headers
-- NEVER use grep, glob, manual file searches, or any other method to identify missing documentation
-- The `pnpm docs:check` script (scripts/check-fileoverview.go) scans the first 20 lines of all .ts/.tsx/.js/.jsx files in src/ for @fileoverview tags
-- This is the authoritative source for which files need documentation
-- Example: When asked "check what files are missing docs", run: `pnpm docs:check`
-
-**Quality Assurance**: Ensure documentation:
-- Accurately reflects the current code functionality
-- Provides value to developers reading the code
-- Follows the project's established patterns and terminology
-- Is neither too verbose nor too brief
-- After adding documentation, verify it was properly added by running `pnpm docs:check` again
-
-**Documentation Testing Limitations**:
-Your documentation work is limited to code analysis and cannot include:
-- Running the application to understand runtime behavior
-- Testing how components actually function or interact visually
-- Verifying that documentation matches real application behavior
-- Testing user workflows or interface interactions
-- Observing actual printer connectivity or hardware behavior
-
-Focus on code-level documentation quality:
-- Static code analysis to understand component purpose and functionality
-- Import/export analysis to document dependencies and relationships
-- Type definition analysis for accurate parameter and return documentation
-- Code pattern analysis to document architectural decisions
-- Configuration and setup documentation based on code structure
-
-You will proactively identify files lacking proper documentation and suggest improvements. When updating documentation, preserve any existing valuable comments while enhancing clarity and completeness. Your goal is to make the codebase self-documenting and accessible to both current and future developers.
\ No newline at end of file
diff --git a/.claude/agents/fileoverview-docs-writer.md b/.claude/agents/fileoverview-docs-writer.md
new file mode 100644
index 0000000..363e075
--- /dev/null
+++ b/.claude/agents/fileoverview-docs-writer.md
@@ -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\\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\\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\\n\\n\\n\\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\\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\\n\\n\\n\\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\\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\\n\\n\\n\\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\\nThis is a documentation compliance task. The fileoverview-docs-writer agent will systematically check and add documentation using the project's dedicated script.\\n\\n"
+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.
diff --git a/.claude/settings.local.json b/.claude/settings.local.json
index 4d537a2..cadc094 100644
--- a/.claude/settings.local.json
+++ b/.claude/settings.local.json
@@ -5,7 +5,8 @@
"Bash(pnpm import:*)",
"Bash(pnpm install)",
"Bash(pnpm build:*)",
- "Bash(pnpm test:coverage:*)"
+ "Bash(pnpm test:coverage:*)",
+ "Bash(go run:*)"
]
}
}
diff --git a/package.json b/package.json
index 29386a0..c638439 100644
--- a/package.json
+++ b/package.json
@@ -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",
diff --git a/src/FiveMClient.ts b/src/FiveMClient.ts
index b01f7e2..e58c009 100644
--- a/src/FiveMClient.ts
+++ b/src/FiveMClient.ts
@@ -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';
diff --git a/src/api/PrinterDiscovery.ts b/src/api/PrinterDiscovery.ts
index 5f51803..44acf6d 100644
--- a/src/api/PrinterDiscovery.ts
+++ b/src/api/PrinterDiscovery.ts
@@ -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';
diff --git a/src/api/controls/Control.test.ts b/src/api/controls/Control.test.ts
index 023dc2c..cd6aea7 100644
--- a/src/api/controls/Control.test.ts
+++ b/src/api/controls/Control.test.ts
@@ -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';
diff --git a/src/api/controls/Control.ts b/src/api/controls/Control.ts
index e9f597e..962c38c 100644
--- a/src/api/controls/Control.ts
+++ b/src/api/controls/Control.ts
@@ -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';
diff --git a/src/api/controls/Files.test.ts b/src/api/controls/Files.test.ts
index 5ac6dcf..5c30414 100644
--- a/src/api/controls/Files.test.ts
+++ b/src/api/controls/Files.test.ts
@@ -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';
diff --git a/src/api/controls/Files.ts b/src/api/controls/Files.ts
index ce351ea..7c60166 100644
--- a/src/api/controls/Files.ts
+++ b/src/api/controls/Files.ts
@@ -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
diff --git a/src/api/controls/Info.test.ts b/src/api/controls/Info.test.ts
index 0560bad..7ee3e1a 100644
--- a/src/api/controls/Info.test.ts
+++ b/src/api/controls/Info.test.ts
@@ -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';
diff --git a/src/api/controls/Info.ts b/src/api/controls/Info.ts
index a9a7c8f..50aaeb6 100644
--- a/src/api/controls/Info.ts
+++ b/src/api/controls/Info.ts
@@ -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';
diff --git a/src/api/controls/JobControl.test.ts b/src/api/controls/JobControl.test.ts
index f15844f..f578f81 100644
--- a/src/api/controls/JobControl.test.ts
+++ b/src/api/controls/JobControl.test.ts
@@ -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';
diff --git a/src/api/controls/JobControl.ts b/src/api/controls/JobControl.ts
index c2aa86d..9a32731 100644
--- a/src/api/controls/JobControl.ts
+++ b/src/api/controls/JobControl.ts
@@ -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';
diff --git a/src/api/controls/TempControl.test.ts b/src/api/controls/TempControl.test.ts
index 6923b98..096bdde 100644
--- a/src/api/controls/TempControl.test.ts
+++ b/src/api/controls/TempControl.test.ts
@@ -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';
diff --git a/src/api/controls/TempControl.ts b/src/api/controls/TempControl.ts
index 069a525..1d94d4e 100644
--- a/src/api/controls/TempControl.ts
+++ b/src/api/controls/TempControl.ts
@@ -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';
diff --git a/src/api/filament/Filament.test.ts b/src/api/filament/Filament.test.ts
index cbe85e0..4e1069c 100644
--- a/src/api/filament/Filament.test.ts
+++ b/src/api/filament/Filament.test.ts
@@ -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', () => {
diff --git a/src/api/filament/Filament.ts b/src/api/filament/Filament.ts
index f37ff19..6ebc14e 100644
--- a/src/api/filament/Filament.ts
+++ b/src/api/filament/Filament.ts
@@ -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.
diff --git a/src/api/misc/ScientificNotationFloatConverter.test.ts b/src/api/misc/ScientificNotationFloatConverter.test.ts
index 84459a9..4fc7e72 100644
--- a/src/api/misc/ScientificNotationFloatConverter.test.ts
+++ b/src/api/misc/ScientificNotationFloatConverter.test.ts
@@ -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', () => {
diff --git a/src/api/misc/ScientificNotationFloatConverter.ts b/src/api/misc/ScientificNotationFloatConverter.ts
index f840498..4af946f 100644
--- a/src/api/misc/ScientificNotationFloatConverter.ts
+++ b/src/api/misc/ScientificNotationFloatConverter.ts
@@ -1,3 +1,10 @@
+/**
+ * @fileoverview Number formatting utility for scientific notation
+ *
+ * Formats numbers using scientific notation when values are very small (< 0.001)
+ * or very large (>= 10000), otherwise returns standard decimal representation.
+ */
+
/**
* Formats a number into a string, using scientific notation if the number is
* very small (absolute value < 0.001) or very large (absolute value >= 10000).
diff --git a/src/api/misc/Temperature.test.ts b/src/api/misc/Temperature.test.ts
index d40ec42..4a66720 100644
--- a/src/api/misc/Temperature.test.ts
+++ b/src/api/misc/Temperature.test.ts
@@ -1,3 +1,9 @@
+/**
+ * @fileoverview Tests for Temperature class
+ *
+ * Verifies temperature value storage, retrieval, and string conversion
+ * for positive, negative, zero, and decimal values.
+ */
import { Temperature } from './Temperature';
describe('Temperature', () => {
diff --git a/src/api/misc/Temperature.ts b/src/api/misc/Temperature.ts
index 142971c..e487ebf 100644
--- a/src/api/misc/Temperature.ts
+++ b/src/api/misc/Temperature.ts
@@ -1,3 +1,9 @@
+/**
+ * @fileoverview Temperature value wrapper class
+ *
+ * Simple immutable container for numeric temperature values (typically Celsius)
+ * with getValue() and toString() accessors.
+ */
// src/api/misc/Temperature.ts
/**
* Represents a temperature value.
diff --git a/src/api/network/FNetCode.ts b/src/api/network/FNetCode.ts
index 0f87f49..e3a083d 100644
--- a/src/api/network/FNetCode.ts
+++ b/src/api/network/FNetCode.ts
@@ -1,3 +1,8 @@
+/**
+ * @fileoverview Network response code enumeration
+ *
+ * Defines success/error codes for API responses: 0 (Ok) and 1 (Error).
+ */
// src/api/network/FNetCode.ts
/**
* Represents network operation codes, typically used in API responses
diff --git a/src/api/network/NetworkUtils.test.ts b/src/api/network/NetworkUtils.test.ts
index 055a82a..0d4f44a 100644
--- a/src/api/network/NetworkUtils.test.ts
+++ b/src/api/network/NetworkUtils.test.ts
@@ -1,3 +1,8 @@
+/**
+ * @fileoverview Tests for NetworkUtils class
+ *
+ * Verifies response validation logic for successful and failed API responses.
+ */
import { NetworkUtils } from './NetworkUtils';
import { FNetCode } from './FNetCode';
import { GenericResponse } from '../controls/Control';
diff --git a/src/api/network/NetworkUtils.ts b/src/api/network/NetworkUtils.ts
index a0f6cae..27e5d62 100644
--- a/src/api/network/NetworkUtils.ts
+++ b/src/api/network/NetworkUtils.ts
@@ -1,3 +1,9 @@
+/**
+ * @fileoverview Network response validation utilities
+ *
+ * Provides helper functions for validating API responses, checking if
+ * GenericResponse objects indicate successful operations.
+ */
// src/api/network/NetworkUtils.ts
import { GenericResponse } from '../controls/Control';
import { FNetCode } from './FNetCode';
diff --git a/src/api/server/Commands.ts b/src/api/server/Commands.ts
index df75cde..79b77a8 100644
--- a/src/api/server/Commands.ts
+++ b/src/api/server/Commands.ts
@@ -1,3 +1,9 @@
+/**
+ * @fileoverview Command string constants for printer API requests
+ *
+ * Defines command type identifiers sent in API payloads to control printer
+ * functions like lighting, print jobs, temperature, and camera.
+ */
// src/api/server/Commands.ts
/**
* Defines a collection of command strings used for interacting with the printer's API.
diff --git a/src/api/server/Endpoints.ts b/src/api/server/Endpoints.ts
index 3e6f2cf..ed5a84a 100644
--- a/src/api/server/Endpoints.ts
+++ b/src/api/server/Endpoints.ts
@@ -1,3 +1,9 @@
+/**
+ * @fileoverview HTTP API endpoint paths for FlashForge 5M printers
+ *
+ * Defines URL paths for printer control operations including status queries,
+ * file management, print job control, and authentication.
+ */
// src/api/server/Endpoints.ts
/**
* Defines a collection of API endpoint paths for interacting with the FlashForge 3D printer.
diff --git a/src/firmware-test.ts b/src/firmware-test.ts
index abfe7b7..5b87758 100644
--- a/src/firmware-test.ts
+++ b/src/firmware-test.ts
@@ -1,3 +1,6 @@
+/**
+ * @fileoverview Standalone test script for verifying printer firmware version via HTTP and TCP APIs.
+ */
// src/firmware-test.ts
import { FiveMClient } from './index';
diff --git a/src/index.ts b/src/index.ts
index ee51f7e..0e8f912 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -1,3 +1,6 @@
+/**
+ * @fileoverview Public API entry point exporting all library modules for FlashForge printer control.
+ */
// src/index.ts
// Main client
export { FiveMClient, Product } from './FiveMClient';
diff --git a/src/models/MachineInfo.test.ts b/src/models/MachineInfo.test.ts
index 73824c8..3ac899b 100644
--- a/src/models/MachineInfo.test.ts
+++ b/src/models/MachineInfo.test.ts
@@ -1,3 +1,6 @@
+/**
+ * @fileoverview Unit tests for MachineInfo transformation logic.
+ */
import { MachineInfo } from './MachineInfo';
import { FFPrinterDetail, MachineState, SlotInfo, MatlStationInfo, IndepMatlInfo } from './ff-models';
diff --git a/src/models/MachineInfo.ts b/src/models/MachineInfo.ts
index 004cd17..49e200c 100644
--- a/src/models/MachineInfo.ts
+++ b/src/models/MachineInfo.ts
@@ -1,4 +1,6 @@
-// src/api/models/MachineInfo.ts
+/**
+ * @fileoverview Transforms raw printer detail data from the API into structured machine info.
+ */
import {FFMachineInfo, FFPrinterDetail, MachineState, MatlStationInfo, IndepMatlInfo} from './ff-models';
/**
diff --git a/src/models/ff-models.ts b/src/models/ff-models.ts
index 1628d3a..a1ba268 100644
--- a/src/models/ff-models.ts
+++ b/src/models/ff-models.ts
@@ -1,4 +1,6 @@
-// src/models/ff-models.ts
+/**
+ * @fileoverview TypeScript interfaces and enums for FlashForge printer data models and API responses.
+ */
/**
* Represents the raw detailed information about a FlashForge 3D printer as obtained from its API.
* Properties are often in the printer's native naming format (e.g., camelCase or with underscores)
diff --git a/src/tcpapi/FlashForgeClient.ts b/src/tcpapi/FlashForgeClient.ts
index b789688..d6bb36b 100644
--- a/src/tcpapi/FlashForgeClient.ts
+++ b/src/tcpapi/FlashForgeClient.ts
@@ -1,3 +1,7 @@
+/**
+ * @fileoverview High-level TCP client for FlashForge 3D printers, providing printer control
+ * workflows (LED, job management, homing, temperature, filament) via G-code commands.
+ */
// src/tcpapi/FlashForgeClient.ts
import { FlashForgeTcpClient } from './FlashForgeTcpClient';
import { GCodes } from './client/GCodes';
@@ -10,17 +14,6 @@ import { LocationInfo } from './replays/LocationInfo';
import { ThumbnailInfo } from './replays/ThumbnailInfo';
import { Filament } from '../api/filament/Filament';
import path from "node:path";
-
-/**
- * Provides a high-level client for interacting with FlashForge 3D printers via TCP/IP,
- * building upon the basic TCP communication provided by `FlashForgeTcpClient`.
- * This class implements specific G-code commands and workflows for printer control,
- * such as initialization, LED control, job management, homing, temperature settings,
- * filament operations, and retrieving various printer statuses.
- *
- * It uses a "legacy" API approach primarily based on sending G-code/M-code commands
- * and parsing text-based responses.
- */
export class FlashForgeClient extends FlashForgeTcpClient {
/** Controller for sending specific G-code commands. */
private control: GCodeController;
diff --git a/src/tcpapi/FlashForgeTcpClient.test.ts b/src/tcpapi/FlashForgeTcpClient.test.ts
index c8fc899..6f5ed15 100644
--- a/src/tcpapi/FlashForgeTcpClient.test.ts
+++ b/src/tcpapi/FlashForgeTcpClient.test.ts
@@ -1,3 +1,7 @@
+/**
+ * @fileoverview Tests for FlashForgeTcpClient file list parsing logic, validating extraction
+ * of filenames from M661 command responses across different printer models.
+ */
import { FlashForgeTcpClient } from './FlashForgeTcpClient';
// Suppress logs (from API files) during tests
diff --git a/src/tcpapi/FlashForgeTcpClient.ts b/src/tcpapi/FlashForgeTcpClient.ts
index e8d0c94..0146807 100644
--- a/src/tcpapi/FlashForgeTcpClient.ts
+++ b/src/tcpapi/FlashForgeTcpClient.ts
@@ -1,17 +1,10 @@
+/**
+ * @fileoverview Low-level TCP socket client for FlashForge printers, managing connections,
+ * command serialization, multi-line response parsing, and keep-alive mechanisms.
+ */
import * as net from 'net';
import {setTimeout as sleep} from 'timers/promises';
import {GCodes} from "./client/GCodes";
-
-/**
- * Provides the foundational TCP client for communicating with FlashForge 3D printers.
- * This class manages the socket connection, sending raw commands, handling responses,
- * and maintaining a keep-alive connection. It serves as the base class for
- * `FlashForgeClient`, which implements more specific G-code command logic.
- *
- * The communication protocol typically involves sending ASCII G-code/M-code commands
- * terminated by a newline character ('\n') and receiving text-based responses,
- * often ending with "ok" to indicate success.
- */
export class FlashForgeTcpClient {
/** The underlying network socket for TCP communication. Null if not connected. */
protected socket: net.Socket | null = null;
diff --git a/src/tcpapi/client/GCodeController.ts b/src/tcpapi/client/GCodeController.ts
index a73171b..b5d24a2 100644
--- a/src/tcpapi/client/GCodeController.ts
+++ b/src/tcpapi/client/GCodeController.ts
@@ -1,13 +1,10 @@
+/**
+ * @fileoverview Abstraction layer for sending specific G-code commands to FlashForge printers,
+ * wrapping operations like LED control, job management, homing, and temperature control.
+ */
// src/tcpapi/client/GCodeController.ts
import { FlashForgeClient } from '../FlashForgeClient';
import { GCodes } from './GCodes';
-
-/**
- * Provides a higher-level abstraction for sending specific G-code commands
- * to a FlashForge printer via an established `FlashForgeClient` (TCP client).
- * This class simplifies common printer operations by encapsulating the
- * corresponding G-code commands.
- */
export class GCodeController {
private tcpClient: FlashForgeClient;
diff --git a/src/tcpapi/client/GCodes.ts b/src/tcpapi/client/GCodes.ts
index 7810554..0c9d553 100644
--- a/src/tcpapi/client/GCodes.ts
+++ b/src/tcpapi/client/GCodes.ts
@@ -1,11 +1,8 @@
-// src/tcpapi/client/GCodes.ts
/**
- * Defines a collection of common G-code and M-code command strings used for
- * communicating with FlashForge 3D printers via TCP.
- * The `~` prefix is often used by FlashForge for commands sent over TCP.
- * Placeholders like `%%filename%%` are intended to be replaced with actual values
- * before sending the command.
+ * @fileoverview G-code and M-code command constants for FlashForge TCP communication,
+ * providing prefixed command strings for printer operations.
*/
+// src/tcpapi/client/GCodes.ts
export class GCodes {
/** Command to initiate a control session with the printer (login). */
public static readonly CmdLogin = "~M601 S1";
diff --git a/src/tcpapi/replays/EndstopStatus.test.ts b/src/tcpapi/replays/EndstopStatus.test.ts
index 19d03fe..51aaa15 100644
--- a/src/tcpapi/replays/EndstopStatus.test.ts
+++ b/src/tcpapi/replays/EndstopStatus.test.ts
@@ -1,3 +1,6 @@
+/**
+ * @fileoverview Tests for EndstopStatus parser including M119 response parsing and status checking methods.
+ */
import { EndstopStatus, Endstop, Status, MachineStatus, MoveMode } from './EndstopStatus';
describe('Endstop', () => {
diff --git a/src/tcpapi/replays/EndstopStatus.ts b/src/tcpapi/replays/EndstopStatus.ts
index e9adefd..55306b3 100644
--- a/src/tcpapi/replays/EndstopStatus.ts
+++ b/src/tcpapi/replays/EndstopStatus.ts
@@ -1,3 +1,6 @@
+/**
+ * @fileoverview Parses M119 command responses to extract endstop states, machine status, movement mode, and LED state.
+ */
// src/tcpapi/replays/EndstopStatus.ts
/**
* Represents the status of the printer's endstops and various other machine states.
diff --git a/src/tcpapi/replays/LocationInfo.test.ts b/src/tcpapi/replays/LocationInfo.test.ts
index d327e76..009a902 100644
--- a/src/tcpapi/replays/LocationInfo.test.ts
+++ b/src/tcpapi/replays/LocationInfo.test.ts
@@ -1,3 +1,6 @@
+/**
+ * @fileoverview Tests for LocationInfo parser including M114 response parsing and coordinate extraction.
+ */
import { LocationInfo } from './LocationInfo';
describe('LocationInfo', () => {
diff --git a/src/tcpapi/replays/LocationInfo.ts b/src/tcpapi/replays/LocationInfo.ts
index 872d318..0e5a062 100644
--- a/src/tcpapi/replays/LocationInfo.ts
+++ b/src/tcpapi/replays/LocationInfo.ts
@@ -1,3 +1,6 @@
+/**
+ * @fileoverview Parses M114 command responses to extract current print head X, Y, Z coordinates.
+ */
// src/tcpapi/replays/LocationInfo.ts
/**
* Represents the current X, Y, and Z coordinates of the printer's print head.
diff --git a/src/tcpapi/replays/PrintStatus.test.ts b/src/tcpapi/replays/PrintStatus.test.ts
index 4a4ec6e..540582e 100644
--- a/src/tcpapi/replays/PrintStatus.test.ts
+++ b/src/tcpapi/replays/PrintStatus.test.ts
@@ -1,3 +1,6 @@
+/**
+ * @fileoverview Tests for PrintStatus parser including M27 response parsing and progress calculation.
+ */
import { PrintStatus } from './PrintStatus';
describe('PrintStatus', () => {
diff --git a/src/tcpapi/replays/PrintStatus.ts b/src/tcpapi/replays/PrintStatus.ts
index 25e8bdf..068ea20 100644
--- a/src/tcpapi/replays/PrintStatus.ts
+++ b/src/tcpapi/replays/PrintStatus.ts
@@ -1,3 +1,6 @@
+/**
+ * @fileoverview Parses M27 command responses to extract print job progress including SD card bytes and layer counts.
+ */
// src/tcpapi/replays/PrintStatus.ts
/**
* Represents the status of an ongoing print job, including SD card byte progress and layer progress.
diff --git a/src/tcpapi/replays/PrinterInfo.test.ts b/src/tcpapi/replays/PrinterInfo.test.ts
index 9a26ec3..fb64e4f 100644
--- a/src/tcpapi/replays/PrinterInfo.test.ts
+++ b/src/tcpapi/replays/PrinterInfo.test.ts
@@ -1,3 +1,6 @@
+/**
+ * @fileoverview Tests for PrinterInfo parser including M115 response parsing and printer metadata extraction.
+ */
import { PrinterInfo } from './PrinterInfo';
describe('PrinterInfo', () => {
diff --git a/src/tcpapi/replays/PrinterInfo.ts b/src/tcpapi/replays/PrinterInfo.ts
index 9904eeb..525de17 100644
--- a/src/tcpapi/replays/PrinterInfo.ts
+++ b/src/tcpapi/replays/PrinterInfo.ts
@@ -1,3 +1,6 @@
+/**
+ * @fileoverview Parses M115 command responses to extract printer information including model, firmware, serial number, and dimensions.
+ */
// src/tcpapi/replays/PrinterInfo.ts
/**
* Represents general information about the FlashForge 3D printer,
diff --git a/src/tcpapi/replays/TempInfo.test.ts b/src/tcpapi/replays/TempInfo.test.ts
index ee4237f..ef435e5 100644
--- a/src/tcpapi/replays/TempInfo.test.ts
+++ b/src/tcpapi/replays/TempInfo.test.ts
@@ -1,3 +1,6 @@
+/**
+ * @fileoverview Tests for TempInfo parser including M105 response parsing and temperature data extraction.
+ */
import { TempInfo, TempData } from './TempInfo';
describe('TempData', () => {
diff --git a/src/tcpapi/replays/TempInfo.ts b/src/tcpapi/replays/TempInfo.ts
index 47fbe22..2143d1c 100644
--- a/src/tcpapi/replays/TempInfo.ts
+++ b/src/tcpapi/replays/TempInfo.ts
@@ -1,3 +1,6 @@
+/**
+ * @fileoverview Parses M105 command responses to extract extruder and bed temperatures with current and target values.
+ */
// src/tcpapi/replays/TempInfo.ts
/**
* Represents the temperature information for the printer's extruder and bed.
diff --git a/src/tcpapi/replays/ThumbnailInfo.test.ts b/src/tcpapi/replays/ThumbnailInfo.test.ts
index 742382e..890a492 100644
--- a/src/tcpapi/replays/ThumbnailInfo.test.ts
+++ b/src/tcpapi/replays/ThumbnailInfo.test.ts
@@ -1,3 +1,6 @@
+/**
+ * @fileoverview Tests for ThumbnailInfo parser including M662 response parsing and PNG image extraction.
+ */
import { ThumbnailInfo } from './ThumbnailInfo';
import * as fs from 'fs';
diff --git a/src/tcpapi/replays/ThumbnailInfo.ts b/src/tcpapi/replays/ThumbnailInfo.ts
index c3905c5..4582a89 100644
--- a/src/tcpapi/replays/ThumbnailInfo.ts
+++ b/src/tcpapi/replays/ThumbnailInfo.ts
@@ -1,3 +1,6 @@
+/**
+ * @fileoverview Parses M662 command responses to extract PNG thumbnail images from printer files.
+ */
// src/tcpapi/replays/ThumbnailInfo.ts
import * as fs from 'fs';
import * as path from 'path';