contextplate 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- contextplate/__init__.py +7 -0
- contextplate/__main__.py +5 -0
- contextplate/adapters/__init__.py +50 -0
- contextplate/adapters/aider.py +28 -0
- contextplate/adapters/base.py +85 -0
- contextplate/adapters/claude.py +181 -0
- contextplate/adapters/codex.py +119 -0
- contextplate/adapters/copilot.py +57 -0
- contextplate/adapters/core.py +197 -0
- contextplate/adapters/cursor.py +55 -0
- contextplate/adapters/gemini.py +31 -0
- contextplate/adopt.py +596 -0
- contextplate/cli.py +308 -0
- contextplate/config.py +306 -0
- contextplate/doctor.py +147 -0
- contextplate/frontmatter.py +226 -0
- contextplate/globs.py +84 -0
- contextplate/model.py +185 -0
- contextplate/presets.py +165 -0
- contextplate/scaffold.py +162 -0
- contextplate/templates/check.sh +44 -0
- contextplate/templates/hooks/format.py +74 -0
- contextplate/templates/hooks/guard.py +121 -0
- contextplate/templates/hooks/session_context.py +79 -0
- contextplate/templates/scaffold/AGENTS.md +29 -0
- contextplate/templates/scaffold/agents/agents/researcher.md +16 -0
- contextplate/templates/scaffold/agents/agents/reviewer.md +20 -0
- contextplate/templates/scaffold/agents/agents/test-runner.md +17 -0
- contextplate/templates/scaffold/agents/rules/ai-assets.md +12 -0
- contextplate/templates/scaffold/agents/rules/docs.md +11 -0
- contextplate/templates/scaffold/agents/skills/adr/SKILL.md +12 -0
- contextplate/templates/scaffold/agents/skills/adr/template.md +21 -0
- contextplate/templates/scaffold/agents/skills/handoff/SKILL.md +17 -0
- contextplate/templates/scaffold/agents/skills/plan-task/SKILL.md +15 -0
- contextplate/templates/scaffold/agents/skills/plan-task/template.md +28 -0
- contextplate/templates/scaffold/ai_app/data/README.md +5 -0
- contextplate/templates/scaffold/ai_app/evals/README.md +7 -0
- contextplate/templates/scaffold/ai_app/prompts/README.md +17 -0
- contextplate/templates/scaffold/docs/agent-context.md +42 -0
- contextplate/templates/scaffold/docs/architecture.md +27 -0
- contextplate/templates/scaffold/docs/decisions/0001-record-architecture-decisions.md +22 -0
- contextplate/templates/scaffold/docs/glossary.md +7 -0
- contextplate/templates/scaffold/work/handoff.md +22 -0
- contextplate/writer.py +396 -0
- contextplate-0.1.0.dist-info/METADATA +201 -0
- contextplate-0.1.0.dist-info/RECORD +49 -0
- contextplate-0.1.0.dist-info/WHEEL +4 -0
- contextplate-0.1.0.dist-info/entry_points.txt +3 -0
- contextplate-0.1.0.dist-info/licenses/LICENSE +21 -0
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: researcher
|
|
3
|
+
description: Read-only exploration of the codebase, docs, or web. Use for "where is X", "how does Y work", or library research, so raw search output stays out of the main context.
|
|
4
|
+
tools: [read, search, web]
|
|
5
|
+
model: inherit
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
You are a research assistant. You never modify files.
|
|
9
|
+
|
|
10
|
+
Answer the question you were given, then stop. Return:
|
|
11
|
+
|
|
12
|
+
1. **Answer**: 1 to 3 sentences.
|
|
13
|
+
2. **Evidence**: up to 8 bullets, each with a `path:line` reference or URL.
|
|
14
|
+
3. **Unknowns**: anything you could not confirm.
|
|
15
|
+
|
|
16
|
+
Hard limit: 300 words. Do not paste file contents or long code blocks; point to locations instead.
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: reviewer
|
|
3
|
+
description: Reviews the current diff for bugs, security issues, missing tests, and convention drift. Use before reporting a task as done.
|
|
4
|
+
tools: [read, search, shell]
|
|
5
|
+
model: inherit
|
|
6
|
+
claude.memory: project
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
You are a senior reviewer seeing this change for the first time. You never edit files.
|
|
10
|
+
|
|
11
|
+
1. Inspect the change with `git diff` and `git diff --staged`. Read surrounding code only where needed.
|
|
12
|
+
2. Check: correctness and edge cases; security (secrets, injection, authorization); tests for new behavior; consistency with AGENTS.md and the rules in `.agents/rules/`.
|
|
13
|
+
3. If you keep notes between reviews, check them for recurring issues in this repo, and add any new recurring pattern (one line each).
|
|
14
|
+
|
|
15
|
+
Reply with findings ranked by severity:
|
|
16
|
+
|
|
17
|
+
- **Blocker** / **Should fix** / **Nit**, each with `path:line`, the problem, and a concrete fix.
|
|
18
|
+
- End with `Verdict: ship` or `Verdict: fix first`.
|
|
19
|
+
|
|
20
|
+
If nothing is worth flagging, say so in one line. Do not pad.
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: test-runner
|
|
3
|
+
description: Runs tests, linters, and the project check command, and reports only failures. Use whenever command output could be long.
|
|
4
|
+
tools: [shell, read, search]
|
|
5
|
+
model: fast
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
You run checks and summarize results. You never edit files.
|
|
9
|
+
|
|
10
|
+
1. Run the command you were given. Default: the "Check everything" command in AGENTS.md.
|
|
11
|
+
2. If everything passes, reply with one line: `PASS: <command>`, plus counts if shown.
|
|
12
|
+
3. If anything fails, reply with:
|
|
13
|
+
- `FAIL: <command>`
|
|
14
|
+
- For each failure: test or check name, `path:line`, and the key error line (not the full trace).
|
|
15
|
+
- Your best one-line guess at the cause of each, labeled as a guess.
|
|
16
|
+
|
|
17
|
+
Hard limit: 25 lines. Never paste full logs.
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Prompts, evals, and datasets for LLM features
|
|
3
|
+
paths: ["prompts/**", "evals/**", "data/**"]
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Prompt and eval rules
|
|
7
|
+
|
|
8
|
+
- One prompt per file, with frontmatter: `id`, `version`, `model`, `owner`.
|
|
9
|
+
- Changing a prompt's wording bumps `version`. Never edit a released version in place.
|
|
10
|
+
- Every prompt change needs an eval run compared against the last baseline.
|
|
11
|
+
- Eval datasets are append-only. Add cases; do not rewrite existing ones.
|
|
12
|
+
- Read eval summaries, not raw result dumps. Never read `data/raw/`; use a small sample file instead.
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Documentation and decision records
|
|
3
|
+
paths: ["docs/**", "README.md"]
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Documentation rules
|
|
7
|
+
|
|
8
|
+
- Write for a new teammate: plain language, short sections, examples over prose.
|
|
9
|
+
- Keep `docs/architecture.md` to one page. Link out for detail.
|
|
10
|
+
- Decision records are immutable once accepted. To change a decision, write a new one that supersedes it.
|
|
11
|
+
- Add new domain terms to `docs/glossary.md` in the same change that introduces them.
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: adr
|
|
3
|
+
description: Record an architecture decision in docs/decisions/. Use when a non-obvious technical choice is made, changed, or reversed.
|
|
4
|
+
metadata:
|
|
5
|
+
argument-hint: "<decision title>"
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Record a decision
|
|
9
|
+
|
|
10
|
+
1. List `docs/decisions/` and use the next 4-digit number: `docs/decisions/NNNN-kebab-title.md`.
|
|
11
|
+
2. Fill in [template.md](template.md). Keep it under 40 lines.
|
|
12
|
+
3. If it replaces an earlier decision, set that record's status to `Superseded by NNNN` and change nothing else in it.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# NNNN. <Decision title>
|
|
2
|
+
|
|
3
|
+
- Status: Proposed | Accepted | Superseded by NNNN
|
|
4
|
+
- Date: YYYY-MM-DD
|
|
5
|
+
|
|
6
|
+
## Context
|
|
7
|
+
|
|
8
|
+
<The forces at play. What problem forced a decision?>
|
|
9
|
+
|
|
10
|
+
## Decision
|
|
11
|
+
|
|
12
|
+
<What we chose, in one or two sentences.>
|
|
13
|
+
|
|
14
|
+
## Alternatives considered
|
|
15
|
+
|
|
16
|
+
- <Option>: <why not>
|
|
17
|
+
|
|
18
|
+
## Consequences
|
|
19
|
+
|
|
20
|
+
- <What gets easier>
|
|
21
|
+
- <What gets harder, or what we now must do>
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: handoff
|
|
3
|
+
description: Rewrite work/handoff.md so the next session can resume instantly. Use at the end of a session or before clearing context.
|
|
4
|
+
metadata:
|
|
5
|
+
invocation: manual
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Write the handoff note
|
|
9
|
+
|
|
10
|
+
1. Run `git status --short` and `git log --oneline -5` to see the current state.
|
|
11
|
+
2. Rewrite `work/handoff.md` from scratch (replace it, do not append). It is loaded at the start of every session, so keep it to 25 lines.
|
|
12
|
+
3. Use exactly these sections:
|
|
13
|
+
- **Goal**: what we are trying to achieve right now (1 line).
|
|
14
|
+
- **State**: what is done and in progress, with file paths (3 to 6 bullets).
|
|
15
|
+
- **Next**: the next 1 to 3 concrete actions, in order.
|
|
16
|
+
- **Watch out**: gotchas found this session that the code does not make obvious (0 to 3 bullets).
|
|
17
|
+
4. If a lesson is permanent (true for every future session), suggest adding it to AGENTS.md or a rule in `.agents/rules/` instead of keeping it here.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: plan-task
|
|
3
|
+
description: Write a step-by-step plan in work/plans/ before starting multi-step work. Use for any task likely to take more than about 30 minutes.
|
|
4
|
+
metadata:
|
|
5
|
+
invocation: manual
|
|
6
|
+
argument-hint: "<what to build or fix>"
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# Plan a task
|
|
10
|
+
|
|
11
|
+
1. Explore only what the plan needs. Delegate broad searches to the `researcher` role and keep only its summary.
|
|
12
|
+
2. Create `work/plans/<YYYY-MM-DD>-<kebab-slug>.md` from [template.md](template.md). Set `status: active`.
|
|
13
|
+
3. Keep it under 60 lines. Every step must be independently checkable.
|
|
14
|
+
4. Show the plan and stop. Do not implement until the user approves it.
|
|
15
|
+
5. When the work is finished, set `status: done` and fill in the Outcome section.
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
---
|
|
2
|
+
status: active
|
|
3
|
+
created: YYYY-MM-DD
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# <Task title>
|
|
7
|
+
|
|
8
|
+
## Goal
|
|
9
|
+
|
|
10
|
+
<One sentence. What is true when this is done?>
|
|
11
|
+
|
|
12
|
+
## Context
|
|
13
|
+
|
|
14
|
+
<Only what someone needs to start: relevant files, constraints, links.>
|
|
15
|
+
|
|
16
|
+
## Steps
|
|
17
|
+
|
|
18
|
+
- [ ] 1. <step> (check: <how to verify>)
|
|
19
|
+
- [ ] 2. <step> (check: <how to verify>)
|
|
20
|
+
- [ ] 3. Run the project check command
|
|
21
|
+
|
|
22
|
+
## Risks and open questions
|
|
23
|
+
|
|
24
|
+
- <unknowns, decisions needed from the user>
|
|
25
|
+
|
|
26
|
+
## Outcome
|
|
27
|
+
|
|
28
|
+
<Filled in when done: what shipped, what was deferred.>
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
# data/
|
|
2
|
+
|
|
3
|
+
- `raw/`: source data. Gitignored, read-only, and blocked from agent reads (large files flood context).
|
|
4
|
+
- `processed/`: derived data. Gitignored. Regenerate it with a script in `scripts/`.
|
|
5
|
+
- When an agent needs to see the shape of the data, give it a small sample (for example `data/sample.jsonl`, under 50 rows).
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
# evals/
|
|
2
|
+
|
|
3
|
+
How we know a prompt or model change made things better, not just different.
|
|
4
|
+
|
|
5
|
+
- `datasets/`: input cases (JSONL). Append-only.
|
|
6
|
+
- `graders/`: scoring code or rubric prompts.
|
|
7
|
+
- `results/`: run outputs (gitignored, unreadable by agents). Each run writes a short `summary.md`; commit only the baselines you want to keep.
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# prompts/
|
|
2
|
+
|
|
3
|
+
Versioned prompts for the LLM features this project ships.
|
|
4
|
+
|
|
5
|
+
- One prompt per file: `prompts/<feature>/<name>.md`
|
|
6
|
+
- Frontmatter on every file:
|
|
7
|
+
|
|
8
|
+
```yaml
|
|
9
|
+
---
|
|
10
|
+
id: summarize-ticket
|
|
11
|
+
version: 3
|
|
12
|
+
model: <model id>
|
|
13
|
+
owner: <name>
|
|
14
|
+
---
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
- A wording change means a version bump and an eval run (see `evals/`).
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# How agent context is organized
|
|
2
|
+
|
|
3
|
+
Rule of thumb: **every line that loads in every session must earn its place.** Everything else loads on demand.
|
|
4
|
+
|
|
5
|
+
## Four tiers
|
|
6
|
+
|
|
7
|
+
| Tier | What | Loads | Cost |
|
|
8
|
+
| ---------------- | ------------------------------------------------ | --------------------------------------------------------------------------- | ----------------------------- |
|
|
9
|
+
| 1. Always on | `AGENTS.md` (plus `CLAUDE.md`, which imports it) | Every session | Every token, every turn |
|
|
10
|
+
| 2. On demand | Scoped rules, skills, `docs/` | When a matching file is touched, a skill fits, or the agent decides to read | Only when relevant |
|
|
11
|
+
| 3. Session state | `work/handoff.md`, git snapshot, active plans | Start of session and after compaction (hook where supported) | About 40 lines |
|
|
12
|
+
| 4. Isolated | Roles in `.agents/agents/` run as subagents | Their own context; only a summary comes back | Near zero in the main session |
|
|
13
|
+
|
|
14
|
+
Enforcement is separate from context. Permissions and hooks block things; instructions only ask.
|
|
15
|
+
|
|
16
|
+
## Where does new information go?
|
|
17
|
+
|
|
18
|
+
| If it is... | Put it in |
|
|
19
|
+
| ---------------------------------------- | --------------------------------------------------------------- |
|
|
20
|
+
| True for every task in this repo | `AGENTS.md` (stay under the budget in `.agents/contextplate.toml`) |
|
|
21
|
+
| True only for some folders or file types | `.agents/rules/<topic>.md` with `paths:` |
|
|
22
|
+
| A repeatable multi-step procedure | `.agents/skills/<name>/SKILL.md` |
|
|
23
|
+
| A specialist with its own instructions | `.agents/agents/<name>.md` |
|
|
24
|
+
| Background someone reads occasionally | `docs/` |
|
|
25
|
+
| Why we chose X over Y | `docs/decisions/` |
|
|
26
|
+
| Where we are right now | `work/handoff.md` |
|
|
27
|
+
| A task's step-by-step plan | `work/plans/` |
|
|
28
|
+
| Something that must never happen | `[protect]` in `.agents/contextplate.toml` |
|
|
29
|
+
|
|
30
|
+
After editing anything in `.agents/`, run `ctxplate sync` to regenerate each tool's native files.
|
|
31
|
+
|
|
32
|
+
## Efficiency habits
|
|
33
|
+
|
|
34
|
+
- **Point, do not import.** Imports load every session. Prefer "read `docs/x.md` when doing Y".
|
|
35
|
+
- **Delegate noisy output.** Test runs, log reading, and broad searches go to roles with their own context.
|
|
36
|
+
- **Clear between unrelated tasks.** The handoff note and session snapshot restore what matters.
|
|
37
|
+
|
|
38
|
+
## Monthly maintenance (10 minutes)
|
|
39
|
+
|
|
40
|
+
1. Run `ctxplate doctor` to check the context budget, unfilled placeholders, and drift.
|
|
41
|
+
2. Prune AGENTS.md: delete anything agents already do without being told.
|
|
42
|
+
3. Promote corrections you keep repeating into AGENTS.md or a rule. Demote rarely used lines into `docs/`.
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# Architecture
|
|
2
|
+
|
|
3
|
+
<!-- One page max. Agents read this only when touching module boundaries, so make it a map, not a manual. -->
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
<2 to 3 sentences: what the system does and its main moving parts.>
|
|
8
|
+
|
|
9
|
+
## Components
|
|
10
|
+
|
|
11
|
+
| Component | Path | Responsibility |
|
|
12
|
+
| ---------- | --------------- | --------------------------------- |
|
|
13
|
+
| <API> | `src/api/` | <handles HTTP, validation> |
|
|
14
|
+
| <Core> | `src/core/` | <business logic, no I/O> |
|
|
15
|
+
| <Adapters> | `src/adapters/` | <database, queues, external APIs> |
|
|
16
|
+
|
|
17
|
+
## Data flow
|
|
18
|
+
|
|
19
|
+
<request -> api -> core -> adapters -> response. Add a Mermaid diagram if it helps.>
|
|
20
|
+
|
|
21
|
+
## Invariants
|
|
22
|
+
|
|
23
|
+
- <Rules that must never break, e.g. "core/ never imports adapters/".>
|
|
24
|
+
|
|
25
|
+
## External dependencies
|
|
26
|
+
|
|
27
|
+
- <Service>: <what for, where it is configured>
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# 0001. Record architecture decisions
|
|
2
|
+
|
|
3
|
+
- Status: Accepted
|
|
4
|
+
- Date: {{date}}
|
|
5
|
+
|
|
6
|
+
## Context
|
|
7
|
+
|
|
8
|
+
Agents and new teammates repeatedly ask why things are built a certain way, and re-open settled choices.
|
|
9
|
+
|
|
10
|
+
## Decision
|
|
11
|
+
|
|
12
|
+
Record each non-obvious technical decision as a short record in `docs/decisions/` (the `adr` skill does this).
|
|
13
|
+
|
|
14
|
+
## Alternatives considered
|
|
15
|
+
|
|
16
|
+
- Put decisions in AGENTS.md: rejected, it would bloat context that loads in every session.
|
|
17
|
+
- Rely on commit messages: rejected, hard to find and not curated.
|
|
18
|
+
|
|
19
|
+
## Consequences
|
|
20
|
+
|
|
21
|
+
- Agents look up the "why" on demand instead of carrying it in every session.
|
|
22
|
+
- Someone must write the record when a decision is made.
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
# Glossary
|
|
2
|
+
|
|
3
|
+
<!-- Domain terms an agent cannot infer from the code. The highest value per token of any doc. One line each. -->
|
|
4
|
+
|
|
5
|
+
| Term | Meaning in this project |
|
|
6
|
+
| ------ | ------------------------------------------------------------------------------ |
|
|
7
|
+
| <Term> | <Definition, plus the code name if different, e.g. "Account (code: `Tenant`)"> |
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
Loaded at the start of each session (and after compaction) where hooks are supported.
|
|
3
|
+
Rewrite it with the `handoff` skill at the end of a session. 25 lines max.
|
|
4
|
+
-->
|
|
5
|
+
|
|
6
|
+
## Goal
|
|
7
|
+
|
|
8
|
+
Set up the project.
|
|
9
|
+
|
|
10
|
+
## State
|
|
11
|
+
|
|
12
|
+
- Scaffolded with ContextPlate. Placeholders in AGENTS.md and docs/ are not filled in yet.
|
|
13
|
+
|
|
14
|
+
## Next
|
|
15
|
+
|
|
16
|
+
1. Fill in AGENTS.md (description, layout, conventions).
|
|
17
|
+
2. Fill in docs/architecture.md and docs/glossary.md.
|
|
18
|
+
3. Set real commands under [commands] in .agents/contextplate.toml, then run `ctxplate sync`.
|
|
19
|
+
|
|
20
|
+
## Watch out
|
|
21
|
+
|
|
22
|
+
- Nothing yet.
|