Skip to content

Repository files navigation

Tiny Context

Tiny Context is a lightweight, repo-native glue layer for coding agents. It provides durable project memory (project_context/**), an ultra-compact startup contract (AGENTS.md, ~500 tokens), and progressive L1 discovery—without bundling workflow opinions or role skills into your repository.

Quick Start

Requires Node.js 24+. Install the package version you intend to use, then initialize:

npm install --save-dev project-tiny-context-harness
npx --no-install ty-context init

Plain init creates only 4 files: AGENTS.md, .agent/config.yaml, project_context/global.md, and project_context/context.toml. No architecture doc, Area, design system, Skill, Hook, Makefile, or CI workflow is auto-installed.

  • Existing repository: add --adopt.
  • Custom harness config folder (e.g. Antigravity .agents, .codex, .claude, .cursor): pass --harness-folder <path> on initial setup.
  • For an unreleased checkout, build and install its local tarball rather than assuming the published package matches source.

Progressive Context Loading (L0 → L3)

Tiny Context layers memory by abstraction and change rate so fresh sessions recover accurately with minimal token cost:

Layer Surface Cost & Change Rate Purpose
L0 AGENTS.md managed block ~500 tokens · rarely changes Context contract, first-principles & evidence calibration, authorization boundaries
L1 project_context/context.toml (summary, owns, areas) Compact map · changes on module topology changes Deterministic discovery of default and on-demand owners
L2 project_context/**/*.md Loaded per hit · changes on settled decisions Goals, non-goals, boundaries, decisions with rationale, entrypoints
L3 Code, tests, and ty-context-controlling-source files Loaded on demand · changes every iteration Exact implementation values, API specs, adopted design prototypes

Discovery Commands (CLI Optional, Offline-First)

npx --no-install ty-context context list --default [--json]
npx --no-install ty-context context list --index [--json]
npx --no-install ty-context context for src/payments/refund.ts [--query "recovery"] [--with-defaults] [--json]
npx --no-install ty-context context inspect project_context/global.md
  • L1 index (context list --index): compact 1-line-per-file map of default, on-demand, and unregistered Context with estimated token counts.
  • Deterministic path routing (context for <path>): resolves owning Context files from affected code paths ([[context]].owns prefixes/globs and [[areas]].root) or literal --query terms without waiting for trigger keywords.
  • Offline reading without CLI: read project_context/global.md plus project_context/context.toml (default_files without child traversal, default Area, read_policy = "default" nodes and transitive default_children, plus owns/summary for on-demand routing). Invalid manifests exit non-zero; failed queries are incomplete, never an empty set.

Example optional project_context/context.toml:

default_files = ["project_context/architecture.md"]

[[areas]]
id = "payments"
root = "src/payments"
context = "project_context/areas/payments.md"
kind = "service"
summary = "Payment lifecycle, ledger boundaries, and provider constraints"

[[context]]
path = "project_context/areas/payments/recovery.md"
role = "domain"
read_policy = "on-demand"
summary = "Idempotency keys, webhook retry limits, and settlement recovery rules"
owns = ["src/payments/recovery/**", "src/payments/webhooks/**"]
triggers = ["payment recovery"]

Write summary as scope (what the doc owns), not volatile details, and bind owns to directory/module prefixes so routine edits never churn L1 metadata.

Companion Workflow Skills (Decoupled in 0.14.0)

Tiny Context intentionally stays focused on repo-bound project memory (AGENTS.md managed block + project_context/** + context.toml + validate-context/doctor). Cross-project R&D workflow skills (solution-research, design-resource, durable-goal, development-execution, handoff) were decoupled in 0.14.0 into the standalone global plugin project-workflow-skills so reusable methodology is installed once globally (read-only) rather than vendored into every consumer repo, while project-specific rules stay in thin repo-local .agents/workflow/<skill>.md adapters.

  • ty-context skill is retired in 0.14.0 and exits non-zero with migration guidance.
  • Upgrading from 0.13.x is sync-only: init, sync, and upgrade never delete any existing project skills directory.
  • See docs/design-resources.md for declaring repo-native design resources via ty-context-controlling-source.

Safe File Maintenance

npx --no-install ty-context context create --path project_context/payments.md --role domain
npx --no-install ty-context context register --path project_context/payments.md --role domain --summary "Payment boundaries" --owns "src/payments/**" [--apply]
npx --no-install ty-context context move --from project_context/payments.md --to project_context/billing.md [--apply]
npx --no-install ty-context context transaction status|complete|rollback
npx --no-install ty-context sync
  • create publishes an unregistered TODO scaffold without editing context.toml.
  • register and move dry-run by default; --apply uses path-safety checks, CAS byte comparisons, lossless manifest patching, and recoverable context-mutation-journal-v3 journals (recovery-compatible with context-mutation-journal-v2; unrecognized pre-v2 journals require manual recovery with a matching old version; no --force bypass). Multi-file replacements are recoverable, never claimed to be physically atomic.
  • sync refreshes only the AGENTS.md managed block, preserving surrounding user prose and refusing schema mismatches or unfinished transactions.

Structural Validation & Advisory Doctor

npx --no-install ty-context validate-context
npx --no-install ty-context doctor [--strict] [--context-file-soft-budget <bytes>] [--context-total-soft-budget <bytes>]
  • validate-context checks manifest syntax, registered/default paths, owns path safety, Unicode NFC and case-fold collisions, symlink boundaries, front-matter consistency, and explicit local dependencies (<!-- ty-context-controlling-source domain="product|technical|design|acceptance|external" path="docs/api.md" -->).
  • doctor reports advisory default-footprint budgets (6 KB per default file and 16 KB total default body, with estimated tokens) and observable startup risks (AGENTS.md > 24,000 bytes, AGENTS.override.md, coexisting GEMINI.md).
  • Neither command proves factual truth, model compliance, or product correctness—use project tests, runtime observation, and human review.

Explicit Schema-4 Upgrade & Source Development

npx --no-install ty-context upgrade --check
# Stop old host sessions before acknowledging this precondition:
npx --no-install ty-context upgrade --sessions-stopped

Automatic retirement supports the pinned schema-4 (0.11.0) baseline, preserves exact normalized default body paths, backs up planned edits under tmp/ty-context/upgrade-backups, and retires Long-Task, DSA/DRA, role workflows, and legacy gates. Settle pending schema-4 Context transactions with the compatible 0.11.0 CLI before upgrading, and start a fresh host session afterward. Details: migrations/README.md.

  • Temporary exports: ty-context export-context --help (writes under tmp/ty-context/context-exports/** with secret redaction).
  • Repository verification: npm ci, npm run build --workspace project-tiny-context-harness, npm test, node packages/ty-context/dist/cli.js package sync-source, node packages/ty-context/dist/cli.js package check-source.