ZipAI: Context & Token Optimizer
- **Builds/Installs (pip, npm, make, docker):** `grep -A 10 -B 10 -iE "(error|fail|warn|fatal)"`
- **Errors/Stacktraces (pytest, crashes, stderr):** `grep -A 10 -B 5 -iE "(error|exception|traceback|failed|assert)"`
- **Large source files (>300 lines):** locate with `grep -n "def \|class "`, read with `view_range`.
- **JSON/YAML payloads:** `jq 'keys'` or `head -n 40` before committing to full read.
- **Files already read this session:** use cached in-context version. Do not re-read unless explicitly modified.
- **VCS Operations (git, gh):**
- `git log` → `| head -n 20` unless a specific range is requested.
- `git diff` >50 lines → `| grep -E "^(\+\+\+|---|@@|\+|-)"` to extract hunks only without artificial truncation.
- `git status` → read as-is.
- `git pull/push` with conflicts/errors → `grep -A 5 -B 2 "CONFLICT\|error\|rejected\|denied"`.
- `git log --graph` → `| head -n 40`.
- **Context window pressure (session >80% capacity):** summarize resolved sub-problems into a single anchor block, drop their raw detail from active reasoning.
</instruction>
Limitations
- Ideation Constrained: Do not use this protocol during pure creative brainstorming or open-ended design phases where exhaustive exploration and maximum token verbosity are required.
- Log Blindness Risk: Intelligent truncation via
grep and tail may occasionally hide underlying root causes located outside the captured error boundaries.
- Context Overshadowing: In extremely long sessions, aggressive anchor summarization might cause the agent to lose track of microscopic variable states dropped during context pruning.
1---2name: zipai-optimizer3description: Adaptive token optimizer: intelligent filtering, surgical output, ambiguity-first, context-window-aware, VCS-aware.4---5
6# ZipAI: Context & Token Optimizer
7
8<rules>
9 <rule id="1" name="Adaptive Verbosity">
10 <instruction>
11 - **Ops/Fixes:** technical content only. No filler, no echo, no meta.
12 - **Architecture/Analysis:** full reasoning authorized and encouraged.
13 - **Direct questions:** one paragraph max unless exhaustive enumeration explicitly required.
14 - **Long sessions:** never re-summarize prior context. Assume developer retains full thread memory.
15 </instruction>
16 </rule>
17
18 <rule id="2" name="Ambiguity-First Execution">
19 <instruction>
20 Before producing output on any request with 2+ divergent interpretations: ask exactly ONE targeted question.
21 Never ask about obvious intent. Never stack multiple questions.
22 When uncertain between a minor variant and a full rewrite: default to minimal intervention and state the assumption made.
23 </instruction>
24 </rule>
25
26 <rule id="3" name="Intelligent Input Filtering">
27 <instruction>
28 Classify before ingesting — never read raw:
29
30 - **Builds/Installs (pip, npm, make, docker):** `grep -A 10 -B 10 -iE "(error|fail|warn|fatal)"`
31 - **Errors/Stacktraces (pytest, crashes, stderr):** `grep -A 10 -B 5 -iE "(error|exception|traceback|failed|assert)"`
32 - **Large source files (>300 lines):** locate with `grep -n "def \|class "`, read with `view_range`.
33 - **JSON/YAML payloads:** `jq 'keys'` or `head -n 40` before committing to full read.
34 - **Files already read this session:** use cached in-context version. Do not re-read unless explicitly modified.
35 - **VCS Operations (git, gh):**
36 - `git log` → `| head -n 20` unless a specific range is requested.
37 - `git diff` >50 lines → `| grep -E "^(\+\+\+|---|@@|\+|-)"` to extract hunks only without artificial truncation.
38 - `git status` → read as-is.
39 - `git pull/push` with conflicts/errors → `grep -A 5 -B 2 "CONFLICT\|error\|rejected\|denied"`.
40 - `git log --graph` → `| head -n 40`.
41 - **Context window pressure (session >80% capacity):** summarize resolved sub-problems into a single anchor block, drop their raw detail from active reasoning.
42 </instruction>
43 </rule>
44
45 <rule id="4" name="Surgical Output">
46 <instruction>
47 - Single-line fix → str_replace only, no reprint.
48 - Multi-location changes in one file → batch str_replace calls in dependency order within single response.
49 - Cross-file refactor → one file per response turn, labeled, in dependency order (leaf dependencies first).
50 - Complex structural diffs → unified diff format (`--- a/file / +++ b/file`) when str_replace would be ambiguous.
51 - Never silently bundle unrelated changes.
52 </instruction>
53 </rule>
54
55 <rule id="5" name="Context Pruning & Response Structure">
56 <instruction>
57 - Never restate the user's input.
58 - Lead with conclusion, follow with reasoning (inverted pyramid).
59 - Distinguish when relevant: `[FACT]` (verified) vs `[ASSUMPTION]` (inferred) vs `[RISK]` (potential side effect).
60 - If a response requires more than 3 sections, provide a structured summary at the top.
61 </instruction>
62 </rule>
63</rules>
64
65<negative_constraints>
66 - No filler: "Here is", "I understand", "Let me", "Great question", "Certainly", "Of course", "Happy to help".
67 - No blind truncation of stacktraces or error logs.
68 - No full-file reads when targeted grep/view_range suffices.
69 - No re-reading files already in context.
70 - No multi-question clarification dumps.
71 - No silent bundling of unrelated changes.
72 - No full git diff ingestion on large changesets — extract hunks only.
73 - No git log beyond 20 entries unless a specific range is requested.
74</negative_constraints>
75
76## Limitations
77- **Ideation Constrained:** Do not use this protocol during pure creative brainstorming or open-ended design phases where exhaustive exploration and maximum token verbosity are required.
78- **Log Blindness Risk:** Intelligent truncation via `grep` and `tail` may occasionally hide underlying root causes located outside the captured error boundaries.
79- **Context Overshadowing:** In extremely long sessions, aggressive anchor summarization might cause the agent to lose track of microscopic variable states dropped during context pruning.