agentleFS
PAIR-codePAIR-code/deliberate-lab/utils/AGENTS.md

deliberate-lab / utils

AGENTS.md97 starsChanged 57 days agoApache-2.0View on GitHub

Shared TypeScript types, validation functions, and utilities consumed by both frontend and functions. Changes here can cause cascading breakage — always rebuild and run tests before committing. See also: root AGENTS.md for monorepo-wide conventions. From the repository root: utils must be rebuilt before frontend or functions pick up changes. During local dev, run_locally.sh starts a watcher automatically. [!TIP] If you change any exported type in utils, you must also run npm run update-schemas from the repo root to regenerate docs/assets/api/schemas.json…

  • Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about code style.

    Of the AGENTS.md files we read, the 31,774 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.

  • In this repository10 other files it gives its agents.

The file

We split this AGENTS.md into the rules it gives an agent

2 rules. About 0 are common, 1 is distinctive, and 1 is very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈1

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Not every stage type has all of these files — only the ones it needs.

    line 51
  2. Very specific:

    After any type change in utils, remember to:

    line 94

≈ “Common” is an estimate: at least 1 in 5 of the 40,246 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
AGENTS.md

AGENTS.md — @deliberation-lab/utils

Shared TypeScript types, validation functions, and utilities consumed by both frontend and functions. Changes here can cause cascading breakage — always rebuild and run tests before committing.

See also: root AGENTS.md for monorepo-wide conventions.

Build & test

From the repository root:

npm run build -w utils    # Build with tsup (outputs to dist/)
npm test -w utils         # Run Jest tests (colocated with source)
npm run typecheck -w utils

utils must be rebuilt before frontend or functions pick up changes. During local dev, run_locally.sh starts a watcher automatically.

[!TIP] If you change any exported type in utils, you must also run npm run update-schemas from the repo root to regenerate docs/assets/api/schemas.json and scripts/deliberate_lab/types.py. CI will fail the schema sync check if these are out of date.

File naming conventions

General entities

PatternPurpose
<entity>.tsType definitions and interfaces
<entity>.validation.tsRuntime validation functions
<entity>.test.tsTests (colocated with source)

Stage files (src/stages/)

Each stage type follows a consistent naming pattern:

PatternPurpose
<stage_type>_stage.tsStage config types, participant answer types, public data types
<stage_type>_stage.validation.tsValidation for stage configs and answers
<stage_type>_stage.manager.tsBaseStageHandler subclass for agent actions and prompt display
<stage_type>_stage.prompts.tsPrompt construction helpers for LLM agents
<stage_type>_stage.utils.tsStage-specific utility functions
<stage_type>_stage.test.tsTests

Not every stage type has all of these files — only the ones it needs. For example:

  • Minimal (tos_stage): .ts, .validation.ts, .manager.ts, .prompts.ts — just the basics
  • Full (survey_stage): .ts, .validation.ts, .manager.ts, .prompts.ts, .prompts.test.ts — includes prompt tests

How to add a new stage type

  1. Define the StageKind — add an entry to the StageKind enum in src/stages/stage.ts
  2. Create stage files — add files in src/stages/ following the naming pattern above (at minimum <stage_type>_stage.ts and <stage_type>_stage.validation.ts)
  3. Add types to the unions — update the StageConfig, StageParticipantAnswer, and StagePublicData union types in src/stages/stage.ts
  4. Add transfer migration entry — update STAGE_KIND_REQUIRES_TRANSFER_MIGRATION in src/stages/stage.ts
  5. Register the handler — add a handler instance in src/stages/stage.handler.ts (or import the default BaseStageHandler)
  6. Export JSON schema — register the new types in src/export-schemas.ts so consumers can validate JSON payloads
  7. Update sibling workspaces — implement backend logic in functions/src/stages/ and UI components in frontend/src/components/stages/; register any new endpoints in functions/src/index.ts

How to modify an existing stage

Modifying an existing stage is the most common type of change. The files you need to touch depend on what you're changing:

What you're changingFiles to update
Stage config optionsutils/src/stages/<stage>_stage.ts (types), <stage>_stage.validation.ts (defaults), and the frontend config editor in frontend/src/components/stages/<stage>_config.ts
Participant answer shapeutils/src/stages/<stage>_stage.ts (answer type + union in stage.ts), <stage>_stage.validation.ts, and the frontend answer component
Public stage dataSame as above, plus any trigger or backend logic in functions/src/stages/ that reads/writes public data
LLM agent behaviorutils/src/stages/<stage>_stage.manager.ts and/or <stage>_stage.prompts.ts
Backend logic onlyfunctions/src/stages/<stage>.utils.ts and/or <stage>.endpoints.ts
UI onlyfrontend/src/components/stages/<stage>_*.ts and SCSS files

After any type change in utils, remember to:

  1. Rebuild: npm run build -w utils
  2. Regenerate schemas: npm run update-schemas
  3. Run tests: npm test -w utils

Variables system

variables.ts, variables.utils.ts, and variables.template.ts implement a template variable system used in prompts and stage descriptions. variables.schema.utils.ts handles schema-level variable processing.

Variables are defined as VariableDefinition objects (name, description, default value) and referenced in text using double-brace syntax (e.g., {{variable_name}}). At runtime, resolveTemplateVariables replaces placeholders with their resolved values.

Key files

FileRole
src/index.tsPublic API barrel file — all exports
src/stages/stage.tsStageKind enum, base types, union types
src/stages/stage.handler.tsBaseStageHandler class for stage actions
src/export-schemas.tsJSON schema generation for the docs site
src/structured_prompt.tsStructured prompt types (mediator + participant)
src/structured_output.tsStructured output parsing

Common pitfalls

  1. Forgetting to update union types — when adding a new stage, you must add it to the StageConfig, StageParticipantAnswer, and StagePublicData unions in src/stages/stage.ts.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.