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), progressive L1 discovery, and 5 opt-in workflow skills for the full R&D lifecycle.

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.

Optional Workflow Skills (Progressive L2/L3)

The package ships 5 opt-in workflow skills covering the end-to-end R&D lifecycle without bloating AGENTS.md or imposing mandatory gates:

Skill Role in lifecycle On-demand L3 references
solution-research First-principles problem framing, 3 distinct options, counter-evidence, and full lifecycle cost full-cost-framework.md
design-resource UI/UX reasoning, repo-native interactive prototypes (with annotation overlay), delta revisions, scoped adoption, optional Stitch design-reasoning.md, design-method.md, visual-language.md, patterns.md, motion.md, adoption.md, stitch.md
durable-goal Upfront task index, full requirements, unique actionable plan, strict plan-change authorization, hard stop before execution technical-implementation.md
handoff Post-research/design plan settlement, mid-dev session handoff, bounded cleanup, copy-ready continuation prompt host-modes.md
development-execution Proactive 3-stage verify-and-fix loop, symptom-driven diagnostics, module/batch discipline, engineering & runtime boundaries engineering-boundaries.md, runtime-verification.md

Install only the skills your project wants (defaults to <harness-root>/skills, refuses to overwrite existing project skills without --overwrite), and put project-specific paths, tools, or rules inside <skill>/local/ (e.g., local/adapter.md) so future upstream refreshes never clobber local customizations:

npx --no-install ty-context skill list [--target .agents/skills] [--json]
npx --no-install ty-context skill install solution-research durable-goal handoff [--target .agents/skills]
npx --no-install ty-context skill install --all [--target .agents/skills] [--dry-run]
npx --no-install ty-context skill update [--target .agents/skills] [--dry-run]

Installed skills remain project-owned: init, sync, and upgrade never auto-install or overwrite them. Both skill update (which refreshes only already-installed packaged skills) and skill install --overwrite strictly preserve <skill>/local/** untouched while updating upstream files. See docs/design-resources.md for repo-native design resource adoption and Skill composition details.

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.