Skip to content

Latest commit

 

History

History
158 lines (120 loc) · 6.55 KB

AGENTS.md

File metadata and controls

158 lines (120 loc) · 6.55 KB

Agents

This repository uses AI agents to assist with development tasks. This file provides entry points for agent discovery.

Project Overview

effectionx is a TypeScript monorepo containing community packages built on Effection structured concurrency library. Packages are published to NPM under the @effectionx scope.

Effection

This repository builds on Effection, a structured concurrency library. Before working with code here, read the Effection AGENTS.md for essential concepts:

  • Operations vs Promises (lazy vs eager execution)
  • Scope ownership and structured concurrency
  • Entry points (main(), run(), createScope())
  • Streams, channels, and the each() pattern

Available Agents

Agent Purpose Location
Policy Officer Enforces code and documentation policies .agents/policy-officer.md

Policies

Static analysis policies are documented in .policies/index.md. The Policy Officer agent uses these to verify compliance.

For AI Agents

When working in this repository:

  1. Read this file first to understand available agents and policies
  2. Check applicable policies before making changes (see .policies/index.md)
  3. Follow progressive disclosure - start with index files, then drill into specifics as needed

Tech Stack

  • Runtime: Node.js 22.12.0 (via Volta)
  • Package Manager: pnpm 9.15.9
  • Build: TypeScript 5+, Turbo
  • Linting/Formatting: Biome
  • Testing: Vitest, via the @effectionx/vitest adapter

Code Review Policies

IMPORTANT: All code reviews must follow the policies in .policies/index.md. Read .agents/policy-officer.md for the expected review format and process.

When reviewing PRs:

  1. Read .policies/index.md to get the list of active policies
  2. Read each linked policy document
  3. Apply policy checks to changed files
  4. Use the output format from .agents/policy-officer.md

Coding Standards

TypeScript

  • Strict mode enabled
  • Use NodeNext module resolution
  • Target ES2022
  • Prefer type imports for type-only imports
  • Use explicit return types on public functions
  • Comments must say what the code cannot. Do not narrate the next line, and do not restate a rule that already lives in .policies/. Before keeping a comment, ask why it is needed at all (see the Code Comments policy)

Effection Patterns

  • Use structured concurrency (spawn, scope)
  • Resources must clean up properly on scope exit
  • Teardown that needs yield* must go in ensure(), never in a finally block. When a task is halted Effection unwinds it with iterator.return(); if a finally yields, the resume comes back as iterator.next(), which takes the frame out of return-mode and the halt is lost. Synchronous cleanup in finally is fine. See the Async Teardown policy
  • Never register event listeners with emitter.once(); listener lifetime must depend on a scope, not on the event firing. Register named handlers with .on() and remove them with .off() in the scope's own teardown — after any teardown wait that needs the listener still attached. See the Scope-Bound Event Registration policy
  • Prefer Operation<T> for async operations
  • Use *[Symbol.iterator] pattern for reusable stream operations (see Stateless Streams policy)
  • Avoid sleep() for test synchronization (see No-Sleep Test Sync policy)

Commit and PR conventions

Use gitmoji for commit and pull request subjects. For changes to files that direct the behavior of AI such as AGENTS.md or llms.txt use a robot emoji instead of the standard gitmoji for documentation

Do not include any agent marketing material (e.g. "Generated with...", "Co-Authored-By: <agent>") in commits, pull requests, issues, or comments.

Package Structure

Each package requires:

<package>/
├── mod.ts            # Main entry point (exports public API)
├── package.json      # Package manifest with peerDependencies
├── tsconfig.json     # Extends root tsconfig
├── *.test.ts         # Tests using @effectionx/vitest
└── README.md         # Documentation (text before --- used as description)

package.json Requirements

  • name: @effectionx/<package-name>
  • description: Required — single sentence, under 120 chars, no Markdown, no trailing period (see Package.json Metadata policy)
  • type: "module"
  • exports: Must include types, development, import, and default conditions
  • peerDependencies: Usually effection: "^3 || ^4"
  • files: Include only published artifacts (dist). Exceptions: bdd also ships mod.deno.ts (the ./deno subpath serves source directly); inline also ships swc/target/wasm32-wasip1/release/swc_plugin_inline.wasm. Workspace dev resolves source via the development export condition — source .ts files do not need to be in files

Test Files

  • Import describe/it from @effectionx/vitest, which runs Effection operations as tests. This is what new packages should use
  • bdd and inline are the two exceptions. Both are excluded from Vitest in vitest.config.ts, import @effectionx/bdd, and run under node --test via pnpm test:node
  • Tests run with --env-file=../.env
  • Do not use sleep() to wait for a result — see the No-Sleep Test Synchronization policy

Commands

pnpm build          # Build all packages (TypeScript + bundling)
pnpm build:tsc      # Build TypeScript only
pnpm test           # Run all tests (vitest)
pnpm test:node      # Run the bdd and inline suites under node --test
pnpm test:matrix    # Test against peer dependency versions
pnpm check          # Type-check all packages
pnpm lint           # Lint all packages
pnpm fmt            # Format all files
pnpm fmt:check      # Check formatting
pnpm sync           # Check tsconfig references
pnpm sync:fix       # Fix tsconfig references and dependencies

Repository Structure

effectionx/
├── .github/workflows/  # CI/CD workflows
├── .internal/          # Internal tooling (not published)
├── .policies/          # Code review policies
├── .agents/            # Agent instructions
├── <package>/          # Individual packages
└── package.json        # Root workspace config