This file guides agentic coding agents working in this repository.
bun run test # Run all tests with Jest
bun run test:cov # Run with coverage report
bun run test:watch # Watch mode for TDD
npx jest tests/agent.test.ts --runInBand # Run single test file
npx jest agent --runInBand # Run tests matching patternbun run lint # ESLint check
bun run lint:fix # Auto-fix linting issues
bun run lint:check # Lint with zero warnings tolerance
npx tsc --noEmit # Type check without emitting files
npx tsc -p tsconfig.json # Generate type declarations to dist/bun run agent:integration # Run browser automation agent
bun run agent:mcp # Run MCP-enabled agent
bun run server:basic # Run basic server example- Use type-only imports for type annotations only:
import type { AgentForceAgent } from "../../agent"; import type { ModelConfig } from "../../types";
- Use regular imports when using code at runtime:
import { SomeClass } from "../../some-module";
- Double quotes for all imports and string literals
- Semicolons required
- Trailing commas in multiline arrays/objects
- 4 spaces for indentation
- No underscore prefix on private members - use
privatekeyword - Use
typefor type unions/aliases,interfacefor object shapes - Strict mode enabled in tsconfig.json
- Prefer explicit return types for exported functions
- camelCase for variables, functions, methods
- PascalCase for classes, interfaces, types
- UPPER_SNAKE_CASE for constants
- Descriptive names - avoid abbreviations
- CRITICAL: Prefer
logger.error()overthrowfor runtime errors - Use
throwonly for input validation (programming errors) - NEVER use
console.*methods - always use logger instance - Example:
// Runtime error - use logger try { await readFile(path); } catch (error) { logger.error({ path, error }, "Failed to read file"); return; } // Input validation - throw if (!path || path.trim() === "") { throw new Error("Path cannot be empty"); }
- Chainable methods return
thisand use.bind(this)pattern - Create method in
lib/agent/methods/orlib/server/routes/ - Export from
lib/agent/mod.tsorlib/server/mod.ts - Bind in main class:
methodName: () => AgentForceAgent = methodName.bind(this) - Include JSDoc with @memberof and @example
- JSDoc comments for all public APIs with
@exampleblocks - Document parameters with
@param {Type} name description - Document return values with
@returns {Type} description
- No transpilation - ship TypeScript source files directly
- ESM only - all modules use
"type": "module" - Method chaining - fluent interface pattern for agents
- Protected accessors - use bracket notation for external class access:
const name = agent["getName"]();
- Test files mirror lib structure in
tests/ - Use Jest with
ts-jestESM preset - Mock external dependencies (Puppeteer, etc.)
- Minimum 90% line coverage target
lib/mod.ts- Main entry point, exports all public APIslib/agent.ts- Core AgentForceAgent classlib/types.ts- All type definitionslib/tools/- Modular tool registrytests/- Jest test files (mirror lib structure)