agy-context-saver 1.7.0 → 1.8.1

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.
package/CHANGELOG.md CHANGED
@@ -5,6 +5,39 @@ All notable changes to `Agy-Context-Saver` will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [1.8.1] - 2026-10-16
9
+
10
+ ### Added
11
+ - **Hybrid `view_file` Slice Governance (`scripts/execution-guard-hook.mjs`)**: Retains the 150-line default slice ceiling (`1–150` lines allowed; partial slices of `151–800` lines denied) while adding a guarded full-file audit exception: explicit `StartLine: 1, EndLine: <TotalFileLines>` reads are permitted when the file on disk is $\le 800$ lines and $\le 45\text{ KiB}$ (`46,080` bytes). `.system_generated/` protections continue to take unconditional precedence.
12
+ - **Waymark-First Denial Routing**: When `waymark-engine` is installed, `view_file` hook denials now recommend `waymark_ask(..., plain: true)` across all 23 supported formats followed by a bounded `view_file(StartLine, EndLine)` slice, falling back to `rtk read` when Waymark is unavailable.
13
+
14
+ ### Changed
15
+ - **Single-Source-of-Truth MCP Instructions (`scripts/install-register.mjs`)**: Replaced the hardcoded pre-v1.7 `instructions.md` template in `install-register.mjs` with a direct read of `mcp/instructions.md`, eliminating the split-brain discrepancy between repository docs and `~/.gemini/antigravity/mcp/agy-context-saver/instructions.md`.
16
+ - **Unified 3-Tier Inspection Documentation**: Reconciled `README.md`, `mcp/instructions.md`, `rules/AGENTS.md`, `skills/context-governance/SKILL.md`, `mcp/index.js`, and `docs/*.md` around the 3-tier hierarchy (`waymark_ask(..., plain: true)` $\to$ hybrid `view_file` $\to$ `rtk` for spillovers, task logs, and directory/prose search) and standardized references to all 10 automated test files.
17
+
18
+ ### Fixed
19
+ - **Inline `read_transcript` Payload Cap (`mcp/index.js`)**: Bounded `compact` mode transcript output to `3,800` characters (`< 4 KB`) and clamped intermediate non-dialogue step bodies so `read_transcript(mode: "compact")` never triggers an Antigravity host spillover file.
20
+ - **Complete `query_transcript` Role Schema**: Documented `'subagent'` in the `roles` filter description across `mcp/index.js`, `scripts/install-register.mjs`, `skills/context-governance/SKILL.md`, and `docs/tools.md`.
21
+
22
+ ---
23
+
24
+ ## [1.8.0] - 2026-10-15
25
+
26
+ ### Removed
27
+ - **`subagent_brief` moved to the separate [Agy-Squad](https://github.com/paragon-ux/agy-squad) package.** Agy-Context-Saver now exposes 5 MCP tools. Agy-Squad is under construction, and the two will install side by side. Removed with it: the tool schema, `tests/test-subagent-trials.mjs`, and the subagent delegation and Pointer-Over-Wire guidance in `rules/AGENTS.md`, `skills/context-governance/SKILL.md`, `mcp/instructions.md` and the docs.
28
+
29
+ ### Changed
30
+ - **Hook state moved out of the shared temp folder.** The polling ledger and RTK rewrite cache now live in a per-user folder: `%LOCALAPPDATA%\agy-context-saver` on Windows, `$XDG_STATE_HOME/agy-context-saver` (default `~/.local/state/agy-context-saver`) elsewhere. Other users and processes on the machine can no longer read or tamper with them.
31
+ - **Uninstall removes all hook state.** It deletes the state folder and any files older versions left in the temp folder (`agy-session-*.json`, `agy-rtk-rewrite-cache.json` and their temp files). Install removes those legacy temp files too. `test-lifecycle-rollback` seeds all of them and checks that they're removed, and that unrelated temp files are left alone.
32
+ - **The installer retires stale subagent schemas.** Re-installing removes `subagent_brief.json` and `dispatch_squad.json` from `~/.gemini/antigravity/mcp/agy-context-saver/`. `test-lifecycle-rollback` seeds both and checks that they're removed.
33
+ - **The `check_context_health` turn-budget warning** now recommends summarizing and continuing in a fresh conversation instead of delegating to subagents.
34
+
35
+ ### Fixed
36
+ - **The MCP server exits when its parent goes away.** It exits on stdin end/close, on stdout `EPIPE`, and when its parent process is gone (15 s watchdog), so no orphaned server processes are left behind.
37
+ - **`mcp/index.js` can be imported without side effects.** The CLI and the stdio loop run only when it's the entry point, and it exports `handleRequest`.
38
+
39
+ ---
40
+
8
41
  ## [1.7.0] - 2026-10-13
9
42
 
10
43
  ### Added
package/README.md CHANGED
@@ -18,10 +18,9 @@ It permanently eliminates session degradation, memory bloat, and context window
18
18
  | Metric / Capability | Without Governor | With Agy-Context-Saver + RTK |
19
19
  | :--- | :--- | :--- |
20
20
  | **Command Output Bloat** | Unlimited raw test dots, ANSI dumps | RTK transparent reduction (60–90% token savings) |
21
- | **Workspace File Inspection** | Massive uncompressed view_file dumps | Compact `rtk read`, `rtk grep`, `rtk find` |
21
+ | **Workspace File Inspection** | Massive uncompressed `view_file` dumps | `waymark_ask(..., plain: true)` $\to$ bounded `view_file` slices ($\le 150$ lines) + `rtk find` / `rtk rg` |
22
22
  | **Long Command Execution** | Detached after 5s $\to$ busy-wait loop | Synchronous window expanded to 10s $\to$ finishes in-turn |
23
23
  | **Background Task Monitoring** | Repetitive busy-polling loops | Enforced Reactive Wakeup with 5-strike circuit breaker |
24
- | **Subagent Delegation** | In-band truncated >16KB JSON dumps | Pointer-Over-Wire (POW) protocols via `subagent_brief` |
25
24
  | **Configuration Safety** | Risk of third-party config clobber | Non-destructive preservation of foreign hooks/MCP with `.bak` backups |
26
25
  | **Transcript Review** | Raw JSONL dumped into context | Clean human-readable Markdown via `read_transcript` |
27
26
  | **Runtime Dependencies** | N/A | **Zero** external npm dependencies (100% Node.js stdlib) + native RTK binary |
@@ -31,8 +30,10 @@ It permanently eliminates session degradation, memory bloat, and context window
31
30
  ## Canonical 3-Layer Governance Architecture
32
31
 
33
32
  1. **Layer 1: Reactive Lifecycle & Polling Immunity**: Replaces destructive busy-polling loops with native Antigravity **Reactive Wakeup**, governed by an exponential Proportional Backoff curve and a 5-strike circuit breaker.
34
- 2. **Layer 2: Transparent CLI & Codebase Streamlining**: Intercepts shell execution via PreToolUse hooks, transparently rewriting commands to RTK (`rtk git`, `rtk pytest`), hard-routing workspace searches to `rtk read`/`find`/`rg`, and shielding internal `.system_generated` state.
35
- 3. **Layer 3: Orchestration, Delegation & Pointer-Over-Wire (POW)**: Expands synchronous execution windows to 10s and enforces Pointer-Over-Wire contracts across subagent teams (`subagent_brief`).
33
+ 2. **Layer 2: Transparent CLI & Codebase Streamlining**: Intercepts shell execution via PreToolUse hooks, transparently rewriting commands to RTK (`rtk git`, `rtk pytest`), enforcing bounded `view_file` slices paired with `waymark_ask(..., plain: true)`, routing spillovers/task logs to `rtk read` and directory/prose searches to `rtk find`/`rg`, and shielding internal `.system_generated` state.
34
+ 3. **Layer 3: Synchronous Execution**: Expands synchronous execution windows to 10s so routine commands finish in-turn instead of detaching.
35
+
36
+ > **Subagent tools moved.** `subagent_brief` and squad dispatch now live in the separate [Agy-Squad](https://github.com/paragon-ux/agy-squad) package (under construction). Agy-Context-Saver is complete without them, and the two will install side by side.
36
37
 
37
38
  ---
38
39
 
@@ -54,6 +55,9 @@ npm run status
54
55
  > [!TIP]
55
56
  > **Enterprise Non-Destructive Guarantee**: Agy-Context-Saver requires **zero external npm dependencies** (100% native Node.js standard library), strictly preserves existing foreign hooks (e.g. `waymark-continuity`) and foreign MCP servers, automatically writes atomic `.bak` configuration backups, and supports clean 1-step rollback.
56
57
 
58
+ > [!NOTE]
59
+ > **RTK Default Configuration Notice**: To protect agent context and command execution from unprompted marketing banners (`[rtk] /!\ No hook installed...`), `Agy-Context-Saver` standardizes `suppress_hook_warning = true` in RTK's user configuration (`%APPDATA%\rtk\config.toml` on Windows / `~/.config/rtk/config.toml` on POSIX) during installation. Existing user configurations are safely preserved. See [RTK Support Matrix](docs/RTK-SUPPORT-MATRIX.md#rtk-configuration-standardization--default-modifications).
60
+
57
61
  ---
58
62
 
59
63
  ## Architectural Division of Responsibilities
@@ -94,7 +98,6 @@ npm run status
94
98
  - Background task polling governance & 5-strike circuit breaker
95
99
  - Antigravity internal state protection (`.system_generated/`)
96
100
  - Zero-JSON Markdown transcript extraction (`read_transcript`, `query_transcript`)
97
- - Subagent delegation formulation (`subagent_brief`)
98
101
  - Benchmark and evaluation artifact mutation protection
99
102
 
100
103
  ---
@@ -104,26 +107,27 @@ npm run status
104
107
  1. **The Polling Trap**: When shell tasks detach to background jobs (`task-XYZ`), agents waste tokens repeatedly polling `manage_task(Action='status')` or scheduling artificial timers. Agy enforces native **Reactive Wakeup** (`<SYSTEM_MESSAGE>`).
105
108
  2. **The Terminal Bloat Trap**: Routine test runs and git operations dump hundreds of lines of noise into context. RTK compresses these outputs natively before they enter model context.
106
109
  3. **The Raw Transcript Trap**: Reading `transcript.jsonl` dumps megabytes of raw JSON into context. Agy blocks direct reads of `.system_generated` and provides high-density Markdown streaming tools.
107
- 4. **Native Inspection Bypass**: Native inspection tools (`view_file`, `grep_search`, `find_by_name`, `list_dir`) bypass token reduction. Agy hard-routes workspace inspection to RTK's canonical CLI (`rtk read`, `rtk grep`, `rtk find`, `rtk ls`).
108
- 5. **The Subagent Truncation Trap**: When subagents return massive audits or code in-band over `send_message`, payloads exceed transport limits (~16 KB) and pollute parent context. Agy enforces **Pointer-Over-Wire (POW)**: subagents dump detailed reports to disk and transmit only high-signal summaries and clickable links.
110
+ 4. **Native Inspection Bypass**: Unbounded native inspection tools (`view_file` without slices, `grep_search`, `find_by_name`, `list_dir`) bypass token reduction. Agy enforces bounded `view_file` slices (`StartLine` / `EndLine <= 150`, paired with `waymark_ask(..., plain: true)`) and routes directory/prose search and spillover reads to RTK's canonical CLI (`rtk find`, `rtk rg`, `rtk grep`, `rtk read`).
109
111
 
110
112
  ---
111
113
 
112
114
  ## Key Capabilities
113
115
 
114
116
  - **Transparent RTK Rewriting**: Native `run_command` calls are automatically rewritten (e.g. `pytest` $\to$ `rtk pytest`) via Antigravity PreToolUse hooks.
115
- - **Pointer-Over-Wire (POW) Subagent Architecture**: Equips `subagent_brief` payloads with isolated workspaces and file-pointer reporting, eliminating context pollution and message truncation during multi-agent workflows.
116
- - **Canonical Codebase Inspection**:
117
- - `rtk read <file>`: Read file with intelligent token filtering and line ranges.
118
- - `rtk find <path>`: Compact file search tree and directory listing (cross-platform, works on Windows & POSIX).
119
- - Search by platform:
120
- - **Windows**: `rtk rg "<pattern>" .` (explicit target `.` prevents child process stdin stalls) or `rg "<pattern>" .`.
121
- - **POSIX / Linux / macOS**: `rtk grep "<pattern>"` or `rtk rg "<pattern>"`.
122
- - Directory listing by platform:
123
- - **Windows**: `rtk find <path>` or PowerShell `dir` / `Get-ChildItem`. (Avoid `rtk ls` / `rtk tree` on Windows as they rely on POSIX binaries/flags).
124
- - **POSIX / Linux / macOS**: `rtk ls <path>` or `rtk tree`.
125
- - `rtk err <cmd>`: Run command and show only errors/warnings.
126
- - `rtk summary <cmd>`: Run command and produce a 2-line heuristic summary.
117
+ - **Unified 3-Tier Codebase & File Inspection**:
118
+ 1. **Tier 1 — Structural Discovery (`waymark_ask(..., plain: true)`)**: Locate exact `[StartLine, EndLine]` coordinates across all 23 supported formats (code ASTs + `markdown`, `yaml`, `json`, `toml`, `bash`) in ~19–466 tokens.
119
+ 2. **Tier 2 — Precision Workspace Reading (`view_file` Hybrid Slice Policy)**: Pass `StartLine` and `EndLine` (`1–150` lines default; or explicit `StartLine: 1, EndLine: <TotalLines>` full-file audit when $\le 800$ lines and $\le 45\text{ KiB}$) into `view_file` to preserve 1-indexed line numbers for `replace_file_content` without terminal stdout truncation.
120
+ 3. **Tier 3 — RTK CLI Boundaries**:
121
+ - `rtk read <path>`: Inspect runtime step spillovers (`.system_generated/steps/<step>/output.txt`) and completed background task logs (`tasks/<taskId>.log`) with `--head-lines` / `--tail-lines`.
122
+ - `rtk find <path>`: Compact file search tree and directory listing (cross-platform, works on Windows & POSIX).
123
+ - Prose / Regex Search (when symbol, heading, or config key is unknown):
124
+ - **Windows**: `rtk rg "<pattern>" .` (explicit target `.` prevents child process stdin stalls) or `rg "<pattern>" .`.
125
+ - **POSIX / Linux / macOS**: `rtk grep "<pattern>"` or `rtk rg "<pattern>"`.
126
+ - Directory listing by platform:
127
+ - **Windows**: `rtk find <path>` or PowerShell `dir` / `Get-ChildItem`. (Avoid `rtk ls` / `rtk tree` on Windows as they rely on POSIX binaries/flags).
128
+ - **POSIX / Linux / macOS**: `rtk ls <path>` or `rtk tree`.
129
+ - `rtk err <cmd>`: Run command and show only errors/warnings.
130
+ - `rtk summary <cmd>`: Run command and produce a 2-line heuristic summary.
127
131
  - **Antigravity Special Files Safe Harbor**: Direct `view_file` access to `SKILL.md`, brain artifacts, and config files is preserved.
128
132
  - **Protected Internal State**: Root-based guard prevents reading `.system_generated/` (transcripts, task logs, progress).
129
133
  - **Session-Wide Lifecycle Ledger**: Polling checks are tracked globally per session; changing task IDs or waiting does not reset governance.
@@ -138,8 +142,8 @@ For complete technical references, architectural specifications, and governance
138
142
  - 📖 **[Getting Started & Installation](docs/installation.md)**: Zero-delay setup, native plugin linking, hooks registration, and verification matrix.
139
143
  - 🏗️ **[Architecture & Internals](docs/architecture.md)**: Closed Execution Topology, RTK separation of concerns, and the Four Non-Fragile Architectural Pillars.
140
144
  - 🛡️ **[Lifecycle Governance & Hooks](docs/governance.md)**: Proportional Backoff curve, Reactive Wakeup invariants, and the 5-strike circuit breaker.
141
- - 🧰 **[MCP Tools & CLI Reference](docs/tools.md)**: Complete specifications for all 6 canonical autonomous MCP tools, slash commands, and diagnostic utilities.
142
- - 🔬 **[Forensic & Output Inspection](docs/architecture.md#6-output-governance-spillover-safe-harbor-0-new-tools)**: Ephemeral tool spillover resolution, post-mortem task retrieval, and Pointer-Over-Wire (POW) contracts.
145
+ - 🧰 **[MCP Tools & CLI Reference](docs/tools.md)**: Complete specifications for all 5 canonical autonomous MCP tools, slash commands, and diagnostic utilities.
146
+ - 🔬 **[Forensic & Output Inspection](docs/architecture.md#6-output-governance-spillover-safe-harbor-0-new-tools)**: Ephemeral tool spillover resolution, and post-mortem task retrieval.
143
147
  - 🚀 **[Publishing & Verification Playbook](docs/publishing.md)**: Clean-room test runs, release procedures, and multi-suite verification matrix.
144
148
  - 🗺️ **[Product Roadmap](docs/roadmap.md)**: Phased strategic roadmap focusing on affordable and reliable multi-agent workflows across general tasks.
145
149
 
@@ -175,11 +179,11 @@ node mcp/index.js status
175
179
  ```bash
176
180
  npm test
177
181
  ```
178
- *Runs all 11 test suites (hook governance, MCP protocol, output inspection governance, E2E probes, performance probes, installed verification, lifecycle rollback, subagent delegation trials, check-only read-only safety, malformed configuration preservation, and Waymark dual-MCP synergy).*
182
+ *Runs all 10 test suites (hook governance, MCP protocol, output inspection governance, E2E probes, performance probes, installed verification, lifecycle rollback, check-only read-only safety, malformed configuration preservation, and RTK ledger fresh install verification).*
179
183
 
180
184
  ### 3. Run Targeted Tests Individually
181
185
  ```bash
182
- # Governance hook unit tests (28 closed-topology tests)
186
+ # Governance hook unit tests (27 closed-topology tests)
183
187
  node tests/test-hook.mjs
184
188
 
185
189
  # MCP server protocol & method tests
@@ -200,17 +204,14 @@ node tests/test-installed-verification.mjs
200
204
  # Clean install/uninstall/restore lifecycle test
201
205
  node tests/test-lifecycle-rollback.mjs
202
206
 
203
- # Subagent delegation trials & batching
204
- node tests/test-subagent-trials.mjs
205
-
206
207
  # Check-only read-only isolation regression test
207
208
  node tests/test-check-only-readonly.mjs
208
209
 
209
210
  # Malformed config preservation fail-closed regression test
210
211
  node tests/test-malformed-config-preservation.mjs
211
212
 
212
- # Dual-MCP Waymark code intelligence + subagent synergy suite
213
- node tests/test-waymark-synergy.mjs
213
+ # RTK ledger & fresh install verification test
214
+ node tests/test-rtk-ledger-fresh-install.mjs
214
215
  ```
215
216
 
216
217
  ### 4. Test MCP Tools from Antigravity Agent
@@ -218,7 +219,6 @@ node tests/test-waymark-synergy.mjs
218
219
  - `check_context_health`: Call with `{ "transcriptPath": "<path-to-transcript.jsonl>" }`.
219
220
  - `read_transcript`: Call with `{ "conversationId": "<uuid>", "lastTurns": 3, "mode": "compact" }`.
220
221
  - `query_transcript`: Call with `{ "conversationId": "<uuid>", "query": "<term>", "summaryOnly": true }`.
221
- - `subagent_brief`: Call with `{ "objective": "<goal>", "scopeFiles": ["..."] }`.
222
222
 
223
223
  ### 5. Testing Pitfalls & Anti-Patterns to Avoid
224
224
  - ❌ **Do NOT run `npm start` or `node mcp/index.js` interactively**: It starts the stdio JSON-RPC daemon and waits indefinitely on `stdin`.
@@ -234,11 +234,10 @@ node tests/test-waymark-synergy.mjs
234
234
  - `/mcp:agy-context-saver:context_shield`: Injects 3-layer governance rules and RTK standards into any session with one click. *(MCP Prompts appear in your chat autocomplete menu; MCP Tools are called autonomously by the agent).*
235
235
  * **Agent MCP Tools**:
236
236
  1. `check_context_health`: Diagnoses conversation transcript turn budgets, payload size, RTK status, and polling loops.
237
- 2. `subagent_brief`: Formulates scope-isolated prompts for delegated subagents with Pointer-Over-Wire (POW) delivery contract.
238
- 3. `read_transcript`: Reads recent conversation history in clean Markdown format (compact/full).
239
- 4. `query_transcript`: Forensic filtering, regex search engine, and surgical single-step dereferencing (`stepIndex`, `field`) from full transcripts.
240
- 5. `get_installation_status`: Inspects live Antigravity plugin link, hook, MCP server, tool schemas, and RTK binary.
241
- 6. `sync_installation`: Re-verifies and repairs all integration layers in ~25ms.
237
+ 2. `read_transcript`: Reads recent conversation history in clean Markdown format (compact/full).
238
+ 3. `query_transcript`: Forensic filtering, regex search engine, and surgical single-step dereferencing (`stepIndex`, `field`) from full transcripts.
239
+ 4. `get_installation_status`: Inspects live Antigravity plugin link, hook, MCP server, tool schemas, and RTK binary.
240
+ 5. `sync_installation`: Re-verifies and repairs all integration layers in ~25ms.
242
241
 
243
242
  * **Streamlined Output Inspection (0 New Tools)**:
244
243
  - **Runtime Step Spillovers** (`.system_generated/steps/<step>/output.txt`): Inspected via canonical `rtk read <path>` (safe-harbored in the PreToolUse hook; native `view_file` calls automatically route to `rtk read`).