chiasmus: Instructions file for Codex

AGENTS.md

chiasmus AGENTS.md is an instructions file for Codex, OpenCode from yogthos/chiasmus. It costs 11,235 tokens per session, scanned A, original, Apache-2.0.

Repository instructions for Chiasmus, a TypeScript server that lets language models use formal logic tools and analyse which functions call one another. They describe the project, commands, tests, and continuous-integration checks.

In plain words
What is it for?
Use them when building, type-checking, testing, running, or modifying the Chiasmus project.
Why use it?
They tell a coding agent how this specific project is organised and how changes are checked. Formal verification means expressing a claim as logic and checking it with a solver.

Instructions file for CodexOpenCode

Written for Codex and OpenCode: the file is AGENTS.md. Also seen: mentions AGENTS.md.

This is yogthos/chiasmus's own configuration. It tells Codex and OpenCode how to work on chiasmus itself, so it is not a mod to install elsewhere. Copy it as a starting point and replace the rules that are about this project. Everything chiasmus configures →

Reuse

Borrowing it

Nothing to install: this file belongs to yogthos/chiasmus. Take a copy, put it at the same path in your own repository, and replace the rules that are about this project with yours.

Copy the file
curl -O https://raw.githubusercontent.com/yogthos/chiasmus/main/AGENTS.md
Clone the repo
git clone --depth 1 https://github.com/yogthos/chiasmus

Made for: Codex, OpenCode.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for chiasmus AGENTS.md

README.md
[![agentmods](https://agentmods.dev/badge/instructions/yogthos/chiasmus/agents-md/github.svg)](https://agentmods.dev/instructions/yogthos/chiasmus/agents-md)
Your own site
<a href="https://agentmods.dev/instructions/yogthos/chiasmus/agents-md"><img src="https://agentmods.dev/badge/instructions/yogthos/chiasmus/agents-md/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for chiasmus AGENTS.md

Your own site · 80×15
<a href="https://agentmods.dev/instructions/yogthos/chiasmus/agents-md"><img src="https://agentmods.dev/badge/instructions/yogthos/chiasmus/agents-md.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 11,235 This file is loaded in full into every session.
When invoked 11,235 The same file — it is already loaded in full.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.11235 $0.11235
Opus 5.5 $0.04494 $0.04494
Sonnet 5.5 $0.02247 $0.02247
Haiku 4.5 $0.01124 $0.01124

Measured 25d ago against content hash 020758438afe, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

chiasmus AGENTS.md scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 25d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

AGENTS.md · 408 lines

How it starts

The opening of the file, as written. The whole thing — 408 lines — stays where its author put it; the contents beside it link to each section on GitHub.

AGENTS.md — Chiasmus

Project Overview

Chiasmus is an MCP (Model Context Protocol) server that gives LLMs access to formal verification via Z3 (SMT solver) and SWI-Prolog (via prolog-wasm-full, including library(clpfd)). It also provides tree-sitter-based source code call graph analysis. The server translates natural language problems into formal logic using a template-based pipeline, verifies results with mathematical certainty, and analyzes call graphs for reachability, dead code, and impact analysis.

  • Language: TypeScript (strict mode, ESM)
  • Runtime: Node.js ≥20
  • License: Apache-2.0
  • Package: npm package chiasmus, exposes a CLI binary

Commands

pnpm build          # Compile TypeScript (tsc) → dist/
pnpm typecheck      # Type-check only (tsc --noEmit)
pnpm test           # Run tests in watch mode (vitest)
pnpm test:run       # Run tests once (vitest run)
pnpm test:coverage  # Run tests with V8 coverage report
pnpm mcp            # Run MCP server locally via tsx
pnpm mcp:http       # Run the Streamable HTTP daemon (chiasmus-http) locally via tsx

CI Pipeline

CI runs on push/PR to main (.github/workflows/test.yml):

  1. pnpm install --frozen-lockfile
  2. pnpm typecheck
  3. pnpm test:run

Tested on Node 22 and 24. Minimum is Node 22 (better-sqlite3 13 requires it; Node 20 went EOL 2026-04-30).

Code Organization

src/
├── mcp-server.ts          # Entry point — MCP server, tool handlers (graph ones in graph/tool-handlers.ts), CLI bootstrap
├── mcp-http-server.ts     # Streamable HTTP daemon entry (chiasmus-http): one MCP server per session, one shared SkillLibrary, Host/Origin check
├── config.ts              # Loads ~/.chiasmus/config.json
├── child/
│   ├── pool.ts            # ChildPool — persistent child process, bounded queue, recycling, SIGKILL stops (graph + solver pools)
│   └── serve.ts           # serveJobs — child side: job loop, result + fatal flag + RSS, parent watchdog
├── solvers/
│   ├── types.ts           # SolverType, SolverResult (discriminated union), Solver, SolverInput, SolveOptions
│   ├── session.ts         # SolverSession — Z3/Prolog solver for the tools; solves run in a solver child unless CHIASMUS_SOLVER_WORKER=off
│   ├── child-pool.ts      # SolverChildPool — one child per solver; createChildSolver, shutdownSolverChildren
│   ├── solver-child.ts    # Child-process entry: runs one solve at a time, reports a fatal WASM error with its result
│   ├── z3-solver.ts       # Z3 WASM wrapper (z3-solver npm), auto-strips check-sat/get-model
│   ├── prolog-solver.ts   # SWI-Prolog (prolog-wasm-full) wrapper, derivation tracing via assertz
│   ├── fatal.ts           # Fatal WASM error (abort/trap/exit) classification + entry-point exit handler
│   └── correction-loop.ts # Bounded repair loop (delegates to repl-sandbox)
├── formalize/
│   ├── engine.ts          # FormalizationEngine — template selection, LLM slot-filling, solve pipeline
│   ├── validate.ts        # lintSpec — structural validation, auto-fixes for SMT-LIB/Prolog
│   └── feedback.ts        # classifyFeedback — converts SolverResult to human-readable feedback
├── skills/
│   ├── types.ts           # SkillTemplate, SlotDef, Normalization, SkillMetadata
│   ├── library.ts         # SkillLibrary — SQLite-backed template storage, BM25 search
│   ├── starters.ts        # 8 built-in starter templates (5 Z3, 3 Prolog)
│   ├── bm25.ts            # BM25 keyword search for template retrieval
│   ├── craft.ts           # craftTemplate — user-created template validation + storage
│   └── relationships.ts   # Template relationship/suggestion graph
├── graph/
│   ├── types.ts           # CodeGraph, LanguageAdapter, FileNode, Hyperedge, DefinesFact, CallsFact.calleeQN, ImportsFact.resolved, FileTypeInfo
│   ├── parser.ts          # tree-sitter lang registry + sync/async parse for TS/JS/Py/Go/Rust/Clojure/Scheme/Racket/CL
│   ├── extractor.ts       # AST walking + per-language call graph extraction + TS/JS collectTypeInfo
│   ├── extract-sexp.ts    # Scheme/Racket + Common Lisp extraction (scope-aware s-expression walkers)
│   ├── facts.ts           # graphToProlog — CodeGraph → Prolog facts (incl. calls_qn/3, imports_resolved/3)
│   ├── analyses.ts        # runAnalysis — dispatches all graph analyses
│   ├── native-analyses.ts # O(V+E) cycles/reachability/impact/dead-code/callers/callees
│   ├── graph-util.ts      # Shared helpers: buildUndirectedGraph (+ entriesByName), forEachUndirectedEdge, undirectedDegree
│   ├── community.ts       # Louvain community detection + cohesion score
│   ├── insights.ts        # detectHubs, detectBridges/analyzeBridges (sampled above 2k nodes), detectSurprisingConnections
│   ├── diff.ts            # graphDiff — set diff on nodes + (src,tgt) edge keys
│   ├── entry-points.ts    # Heuristic entry-point detection (zero-in-degree exports)
│   ├── cache.ts           # SHA256 per-file cache + LRU eviction + named snapshots (proper-lockfile)
│   ├── tool-handlers.ts   # chiasmus_graph / chiasmus_map handlers (run in the graph child process)
│   ├── child-pool.ts      # GraphChildPool — ChildPool for chiasmus_graph/chiasmus_map; runGraphTool, shutdownGraphChild
│   ├── graph-child.ts     # Child-process entry: adopts the parent's cwd/env, runs one job, reports fatal web-tree-sitter state
│   ├── mermaid.ts         # parseMermaid — Mermaid flowcharts/state diagrams → Prolog facts
│   ├── type-env.ts        # TS/JS three-tier type inference + class field/method extraction
│   ├── resolve-calls.ts   # Project-wide QN resolution: inheritance-aware field/method registry
│   ├── tsconfig-aliases.ts # Parses tsconfig.json paths/baseUrl with JSONC + extends chain
│   ├── suffix-index.ts    # Suffix index over batch files for relative import resolution
│   └── adapter-registry.ts # Auto-discovery of chiasmus-adapter-* npm packages
├── search/
│   ├── engine.ts          # buildSearchCorpus + runSearch — cosine-sim code search
│   ├── vector-store.ts    # In-process linear-scan store; serializable
│   ├── embedding-cache.ts # SHA-256-keyed persistent cache, atomic writes
│   └── index.ts           # Module exports
├── llm/
│   ├── types.ts           # LLMAdapter + EmbeddingAdapter interfaces, LLMMessage
│   ├── anthropic.ts       # Anthropic/DeepSeek/OpenAI provider factories (createLLMFromEnv, createEmbeddingFromEnv)
│   ├── openai-compatible.ts # OpenAI-compatible chat + embedding adapters
│   └── mock.ts            # Mock LLM + MockEmbeddingAdapter for testing
tests/                      # Unit tests (mirrors src/ structure)
benchmark/                  # Benchmark problems (5 problems × traditional + chiasmus implementations)

Read the full file on GitHub · 408 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 25d ago Changed · -2 lines · -39 tokens per session 020758438afe
  2. 28d ago Changed · +17 lines · +1,522 tokens per session 1bdb97046148
  3. 29d ago Changed · +38 lines · +3,620 tokens per session 37c7df0df1f3
  4. 2mo ago Changed · +15 lines · +569 tokens per session 90a933cf906c
  5. 2mo ago First seen · 340 lines · 5,563 tokens per session scan A 3774afc2cffa

Subscribe to this mod's changes

chiasmus AGENTS.md is an instructions file published in the GitHub repository yogthos/chiasmus (218 stars, last pushed 19d ago), licensed Apache-2.0. It adds 11,235 tokens to every session, about $0.0449 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

chiasmus AGENTS.md compared with instructions from other repositories

chiasmus AGENTS.md next to 6 instructions from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
chiasmus AGENTS.mdyogthos/chiasmusInstructions file21819d agoApache-2.0A11,235Codex, OpenCode
vscode buildNext.instructions.mdmicrosoft/vscodeInstructions file195kyesterdayMITA9,719GitHub Copilot
next.js AGENTS.mdvercel/next.jsInstructions file143ktodayMITA7,461Codex, OpenCode
langchain AGENTS.mdlangchain-ai/langchainInstructions file149kyesterdayMITA4,680Codex, OpenCode
vscode oss-third-party-notices.instructions.mdmicrosoft/vscodeInstructions file195kyesterdayMITA5,516GitHub Copilot
vscode copilot-instructions.mdmicrosoft/vscodeInstructions file195kyesterdayMITA3,093GitHub Copilot
deepseek-harness AGENTS.mddeepseek-ai/deepseek-harnessInstructions file274k2d agoMITA4,313Codex, OpenCode