agy-context-saver 1.8.1 → 2.0.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 +27 -1
- package/README.md +52 -220
- package/assets/architecture-overview.svg +39 -0
- package/bin/agy-context.mjs +616 -0
- package/hooks.json +3 -3
- package/install.ps1 +1 -1
- package/lib/transcript-core.mjs +2310 -0
- package/package.json +11 -10
- package/plugin.json +6 -6
- package/rules/AGENTS.md +47 -79
- package/scripts/execution-guard-hook.mjs +3239 -375
- package/scripts/install-register.mjs +465 -323
- package/scripts/provision-rtk.mjs +35 -26
- package/scripts/release-preflight.mjs +75 -11
- package/scripts/state-dir.mjs +1 -0
- package/skills/context-governance/SKILL.md +85 -79
- package/mcp/index.js +0 -1332
- package/mcp/instructions.md +0 -33
- package/mcp_config.json +0 -8
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,32 @@ 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
|
+
## [2.0.1] - 2026-11-15
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
- **Pinned `rtk v1.1.0` Release Checksums (`scripts/provision-rtk.mjs`, `tests/test-rtk-ledger-fresh-install.mjs`)**: Pinned verified SHA-256 digests from upstream `rtk v1.1.0` `checksums.txt` across all 5 supported platform archives (`win32-x64`, `darwin-arm64`, `darwin-x64`, `linux-x64`, `linux-arm64`) so clean installs without a pre-installed `rtk` binary can automatically download and verify `rtk v1.1.0` fail-closed.
|
|
12
|
+
|
|
13
|
+
### Security
|
|
14
|
+
- **Operation-Bound, Single-Invocation Capability Grants (`lib/transcript-core.mjs`, `bin/agy-context.mjs`, `scripts/execution-guard-hook.mjs`)**: Bound `verifyTranscriptCoreAccess()` to canonical subcommand (`read`, `query`, `step`, `health`, `list`) and recorded `targetConvId`, and cleared the in-memory `processVerifiedGrant` synchronously upon path resolution (before async stream I/O begins) and on any early error (`L39`) so grants cannot be reused within the same process, shared across concurrent `Promise.all` calls, or repurposed across mismatched subcommands or conversation targets.
|
|
15
|
+
- **Independent `--file` Brain-Directory Containment (`lib/transcript-core.mjs`, `scripts/execution-guard-hook.mjs`)**: Enforced independent `isContainedInDir()` checks on `--file` (`explicitFile`) inside `resolveTranscriptPath()` (`<brainDir>/<callerConvId>` in `self-only` mode and `<brainDir>` whenever any parent access policy or first-line launch restriction is active) and updated `extractConvId()` to resolve conversation folder IDs relative to `getBrainDir()` (`L38`).
|
|
16
|
+
|
|
17
|
+
### Changed
|
|
18
|
+
- **Documentation & Release Hygiene (`README.md`, `SECURITY.md`, `docs/installation.md`, `docs/governance.md`, `docs/architecture.md`, `docs/plans/LEDGER.md`, `scripts/release-preflight.mjs`)**: Added a `v1.x` to `v2.0` migration note and explicit `RTK >= 1.1.0` prerequisite details to `README.md` (`L37`), clarified application-layer `PreToolUse`/CLI defense-in-depth boundaries vs. OS-kernel sandboxing and `--id` vs. `--file` containment rules (`L40`), and enforced `plugin.json` / `package.json` / `CHANGELOG.md` version parity in `scripts/release-preflight.mjs`.
|
|
19
|
+
|
|
20
|
+
## [2.0.0] - 2026-11-14
|
|
21
|
+
|
|
22
|
+
### Added
|
|
23
|
+
- **CLI-First Transcript & Health Engine (`lib/transcript-core.mjs`, `bin/agy-context.mjs`)**: Extracted the streaming JSONL transcript engine into `lib/transcript-core.mjs` and exposed `agy-context` (`bin/agy-context.mjs`) with `transcript read|query|step|health|list|access` (plus intuitive aliases `outline`, `summary`, `grep`, `search`, `find`, `tools`, `stats`, `info`, `ls`, and `policy`) and `status|setup|uninstall|restore-backups` subcommands. Includes positional arguments (`read [<id>]`, `query <pattern> [<id>]`, `step <N|N,M|N-M|N..M> [<id>]`, `health [<id>]`), step head/tail slicing (`step --tail <N>`, `--head <N>`, `--full`), `read --outline`, `query --tools`, `query --full-args`, `--field <content|thinking|tool_calls|tool_args|tool_args:Key|all>`, $O(1)$ `CircularRingBuffer` bounded `lastTurns: 0` streaming, `mode: "auto"` full-log dereferencing for truncated search misses, structured `error` role telemetry, active swarm conversation disambiguation, and `fs.realpathSync` containment checks.
|
|
24
|
+
- **On-Demand Parent Transcript Access Governance (`lib/transcript-core.mjs`, `scripts/execution-guard-hook.mjs`, `bin/agy-context.mjs`)**: Added parent transcript access control via `agy-context transcript access --status | --off (--deny-children) | --on (--reset) | --self-only | --mode <open|allowlist|self-only|deny> | --allow <id,@roster*...> | --deny <id,@roster*...> | --ttl <sec> | --json` (with `policy` alias and positional shorthands `status`, `off`, `on`, `reset`, `self-only`), first-line launch directives (`[agy-transcript-access: deny|self-only|allow]`) on `define_subagent` `SystemPrompt`, `invoke_subagent` `Prompt`, and `/swarm` worker `brief` with prompt-echo immunity in prose and code blocks, 5-tier precedence (`1. Policy Owner` -> `2. Explicit CLI --deny` -> `3. Explicit CLI --allow` supporting `@roster*` prefix globs -> `4. First-Line Launch Directive` -> `5. Cohort Default Mode`), and stale-lock protection (parent-keyed `policies[ownerId]` with 1h TTL, Step 0 `USER_INPUT` top-level session bypass, Step 0/1 `sender=<parentConvId>` child binding, and `Transcript Access Policy` visibility in `agy-context status`).
|
|
25
|
+
- **Transcript Access & State Directory Security Hardening (`scripts/execution-guard-hook.mjs`, `lib/transcript-core.mjs`)**: Added single-use `PreToolUse` capability grants (`lastHookGrant` and `lastAccessMutationGrant`, 10s TTL) verified in `lib/transcript-core.mjs` to block direct `node bin/agy-context.mjs` or library-import bypasses, protected `getStateDir()` against file and shell reads/writes, added executable script and heredoc scanning (`node -e`, `python -c`, subshells), added context-aware `.system_generated` denials when transcript access is restricted, and wired blocked transcript probes into the 5-strike `force_ask` circuit breaker.
|
|
26
|
+
- **RTK `>= 1.1.0` Contract Tests & Transcript Test Suite**: Added `tests/test-transcript.mjs` and `tests/test-rtk-integration.mjs` (11 total automated suites in `npm test`).
|
|
27
|
+
|
|
28
|
+
### Changed
|
|
29
|
+
- **RTK `>= 1.1.0` Native Hook Delegation (`scripts/provision-rtk.mjs`, `scripts/execution-guard-hook.mjs`)**: Upgraded minimum RTK version to `1.1.0`, delegated shell command rewriting to `rtk hook antigravity`, guarded absent `rg` and lossy implicit `wc`/`ls`/`diff` rewrites, removed legacy bespoke rewrite caches and `bash -c` regex wrappers, and applied `WaitMsBeforeAsync: 10000` only when `!isDaemon && waitMs === undefined`.
|
|
30
|
+
- **Antigravity 2.0 Hook Policy & Shell Segment Isolation (`hooks.json`, `scripts/execution-guard-hook.mjs`)**: Standardized on single hook key `agy-context-saver` with relative CWD-safe `node ./scripts/execution-guard-hook.mjs`, added `edit_file` and `write_file` (`args.Path`) to `GOVERNED_TOOLS` and `LH-09` benchmark protection, applied `args.Path` Safe Harbor + Hybrid Slice symmetrically across `read_file` and `view_file`, enforced segment/quote/heredoc-aware parsing with strict unchained exemption for `rtk read <spillover>` and `agy-context transcript ...`, and injected canonical `--id <convId>` under `self-only` access policies.
|
|
31
|
+
- **Default MCP Retirement & `mcp/` Removal (`scripts/install-register.mjs`)**: Removed `mcp/index.js` and `mcp/instructions.md` in favor of `bin/agy-context.mjs`, `rules/AGENTS.md`, and `skills/context-governance/SKILL.md`, retired default `mcp_config.json` registration, swept legacy `agy-context-saver*` MCP entries and duplicate `~/.gemini/antigravity/mcp/agy-context-saver*` schema folders during `setup`/`uninstall`, pruned global `hooks.json` duplicates, and installed `~/.gemini/antigravity/bin/agy-context` shims.
|
|
32
|
+
- **Documentation & Governance Sync (`rules/AGENTS.md`, `skills/context-governance/SKILL.md`, `README.md`, `plugin.json`)**: Updated rules, skills, and README to Antigravity 2.0 `read_file` / `edit_file` / `write_file` tools and `agy-context` CLI commands, removing `waymark_ask` and `view_file` ghost instructions.
|
|
33
|
+
|
|
8
34
|
## [1.8.1] - 2026-10-16
|
|
9
35
|
|
|
10
36
|
### Added
|
|
@@ -43,7 +69,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
43
69
|
### Added
|
|
44
70
|
- **Subagent Artifact Directory Write Guard (`subagent_brief`)**: Added automated path analysis in `formatSingleBrief` that detects when an objective or instruction references a foreign `brain/<uuid>/` directory. Warns subagents proactively to prevent Antigravity's fatal `write_to_file` error ("files must reside within the designated artifact directory").
|
|
45
71
|
- **Pointer-Over-Wire (POW) File Delivery Clarification**: Codified explicit two-option guidance for subagent deliverables:
|
|
46
|
-
- *Option A (Workspace `scratch
|
|
72
|
+
- *Option A (Workspace `scratch/`, Recommended)*: Write to `<workspace>/scratch/<task>_findings.md` and omit `ArtifactMetadata`.
|
|
47
73
|
- *Option B (Own Brain `scratch/`)*: Write to `<your-Artifact-Directory-Path>/scratch/...` using the subagent's own `<user_information>` block and include `ArtifactMetadata: { Summary, UserFacing: false, RequestFeedback: false }`.
|
|
48
74
|
- **Bounded Slice Reading Safe Harbor (`view_file`)**: Prioritized `view_file` with bounded slices (`StartLine` and `EndLine`, max 150 lines) over `rtk read` across `rules/AGENTS.md`, `skills/context-governance/SKILL.md`, and `mcp/instructions.md` to preserve exact 1-indexed line numbers without stdout buffer truncation.
|
|
49
75
|
- **Subagent Delegation Trial 4 (`tests/test-subagent-trials.mjs`)**: Added automated trial verifying `subagent_brief` emits the artifact directory write guard, bounded slice guidance, and Option A/Option B file delivery rules.
|
package/README.md
CHANGED
|
@@ -1,249 +1,81 @@
|
|
|
1
|
-
# Agy-Context-Saver
|
|
2
|
-
|
|
3
|
-
**Model Context Protocol (MCP) Server & Lifecycle Governor for Google Antigravity (Powered by RTK)**
|
|
1
|
+
# Agy-Context-Saver
|
|
4
2
|
|
|
5
3
|
[](https://www.npmjs.com/package/agy-context-saver)
|
|
6
4
|
[](LICENSE)
|
|
7
5
|
[](https://paragon-ux.github.io/agy-context-saver/)
|
|
8
6
|
[](https://github.com/paragon-ux/agy-context-saver/actions)
|
|
9
7
|
|
|
10
|
-
`Agy-Context-Saver` is a
|
|
11
|
-
|
|
12
|
-
It permanently eliminates session degradation, memory bloat, and context window exhaustion caused by **background task busy-wait polling**, **uncompressed terminal outputs**, and **raw JSON transcript reading**.
|
|
8
|
+
`Agy-Context-Saver` is a `PreToolUse` execution hook and transcript CLI (`agy-context`) for **Google Antigravity** (`agy`) on Linux, macOS, and Windows (`Node.js >= 22`, zero external npm dependencies). It pairs with **RTK (`>= 1.1.0`)** to compress shell output, bound workspace file reads, stop background-task busy-polling, and govern transcript inspection across parent sessions, subagents, and `/swarm` workers.
|
|
13
9
|
|
|
14
|
-
|
|
10
|
+

|
|
15
11
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
| Metric / Capability | Without Governor | With Agy-Context-Saver + RTK |
|
|
19
|
-
| :--- | :--- | :--- |
|
|
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 | `waymark_ask(..., plain: true)` $\to$ bounded `view_file` slices ($\le 150$ lines) + `rtk find` / `rtk rg` |
|
|
22
|
-
| **Long Command Execution** | Detached after 5s $\to$ busy-wait loop | Synchronous window expanded to 10s $\to$ finishes in-turn |
|
|
23
|
-
| **Background Task Monitoring** | Repetitive busy-polling loops | Enforced Reactive Wakeup with 5-strike circuit breaker |
|
|
24
|
-
| **Configuration Safety** | Risk of third-party config clobber | Non-destructive preservation of foreign hooks/MCP with `.bak` backups |
|
|
25
|
-
| **Transcript Review** | Raw JSONL dumped into context | Clean human-readable Markdown via `read_transcript` |
|
|
26
|
-
| **Runtime Dependencies** | N/A | **Zero** external npm dependencies (100% Node.js stdlib) + native RTK binary |
|
|
12
|
+
The repository ships four components:
|
|
27
13
|
|
|
28
|
-
|
|
14
|
+
- **`PreToolUse` execution hook ([`hooks.json`](hooks.json), [`scripts/execution-guard-hook.mjs`](scripts/execution-guard-hook.mjs)):** Delegates `run_command` rewriting to `rtk hook antigravity`, requires bounded `read_file` line slices (`<= 150` lines, or explicit `1..TotalLines` reads on files `<= 800` lines and `<= 45 KiB`), upgrades unset `WaitMsBeforeAsync` to `10s`, enforces exponential backoff on `manage_task` and `schedule` with a 5-strike `force_ask` circuit breaker, and blocks direct file or shell access to `.system_generated/` and the state directory.
|
|
15
|
+
- **Transcript forensics CLI ([`bin/agy-context.mjs`](bin/agy-context.mjs), [`lib/transcript-core.mjs`](lib/transcript-core.mjs)):** Streams conversation turns in Markdown, searches compact and full logs by regex or role, extracts single steps or step ranges with `--head`/`--tail` slicing, and audits session turn budgets (`read`, `query`, `step`, `health`, `list`, `access`).
|
|
16
|
+
- **Parent transcript access control (`agy-context transcript access`):** Lets parent sessions restrict or scope child subagent and `/swarm` worker transcript access on demand (`open`, `allowlist`, `self-only`, `deny`) via CLI flags (`--off`, `--self-only`, `--allow @audit-squad*`) or first-line launch directives (`[agy-transcript-access: deny|self-only|allow]`), backed by 10-second single-use capability grants.
|
|
17
|
+
- **Agent rules and skill ([`rules/AGENTS.md`](rules/AGENTS.md), [`skills/context-governance/SKILL.md`](skills/context-governance/SKILL.md)):** Installed into `~/.gemini/config/plugins/agy-context-saver` so Antigravity sessions inherit the inspection and Reactive Wakeup rules automatically. Multi-agent cohort planning and SHA-256 evidence bundling live in the companion [Agy-Squad](https://github.com/paragon-ux/agy-squad) repository.
|
|
29
18
|
|
|
30
|
-
##
|
|
19
|
+
## Quickstart
|
|
31
20
|
|
|
32
|
-
|
|
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.
|
|
21
|
+
### Prerequisites
|
|
35
22
|
|
|
36
|
-
|
|
23
|
+
- **Node.js:** `>= 22.0.0`
|
|
24
|
+
- **Google Antigravity:** Antigravity 2.0+ (Desktop IDE or `agy` CLI)
|
|
25
|
+
- **RTK:** `>= 1.1.0` (`brew install rtk`, `cargo install --locked rtk`, or downloaded automatically into `bin/` during `agy-context setup` with pinned SHA-256 verification)
|
|
37
26
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
## Quickstart (Instant Install)
|
|
41
|
-
|
|
42
|
-
Install and synchronize the governor and RTK across your Antigravity environment:
|
|
27
|
+
### Install and verify
|
|
43
28
|
|
|
44
29
|
```bash
|
|
45
|
-
#
|
|
46
|
-
npx agy-context-saver
|
|
30
|
+
# Install via npx
|
|
31
|
+
npx --package=agy-context-saver agy-context setup
|
|
47
32
|
|
|
48
|
-
# Or
|
|
33
|
+
# Or from a local checkout
|
|
49
34
|
npm run setup
|
|
50
35
|
|
|
51
|
-
#
|
|
52
|
-
|
|
36
|
+
# Check installation and active policy status
|
|
37
|
+
agy-context status
|
|
53
38
|
```
|
|
54
39
|
|
|
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.
|
|
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
|
-
|
|
61
|
-
---
|
|
62
|
-
|
|
63
|
-
## Architectural Division of Responsibilities
|
|
64
|
-
|
|
65
|
-
```text
|
|
66
|
-
Antigravity Agent
|
|
67
|
-
|
|
|
68
|
-
+------------------+------------------+
|
|
69
|
-
| |
|
|
70
|
-
run_command native inspection /
|
|
71
|
-
| lifecycle tools
|
|
72
|
-
v |
|
|
73
|
-
RTK hook |
|
|
74
|
-
| +---------+----------+
|
|
75
|
-
v | |
|
|
76
|
-
RTK execution inspection tools lifecycle
|
|
77
|
-
| | |
|
|
78
|
-
v v v
|
|
79
|
-
compact command output Agy DENY + route Agy governance
|
|
80
|
-
| |
|
|
81
|
-
v v
|
|
82
|
-
RTK read/grep/find Agy MCP
|
|
83
|
-
| |
|
|
84
|
-
+---------+----------+
|
|
85
|
-
|
|
|
86
|
-
v
|
|
87
|
-
useful context
|
|
88
|
-
```
|
|
89
|
-
|
|
90
|
-
### RTK Owns:
|
|
91
|
-
- Transparent `run_command` rewriting (`rtk rewrite`)
|
|
92
|
-
- Shell command output reduction (`git`, `pytest`, `cargo`, `npm`, `docker`, etc.)
|
|
93
|
-
- Canonical codebase inspection CLI (`rtk read`, `rtk grep`, `rtk find`, `rtk ls`, `rtk tree`)
|
|
94
|
-
- Focused diagnostic utilities (`rtk err`, `rtk summary`)
|
|
95
|
-
|
|
96
|
-
### Agy Owns:
|
|
97
|
-
- Antigravity lifecycle management & Reactive Wakeup enforcement
|
|
98
|
-
- Background task polling governance & 5-strike circuit breaker
|
|
99
|
-
- Antigravity internal state protection (`.system_generated/`)
|
|
100
|
-
- Zero-JSON Markdown transcript extraction (`read_transcript`, `query_transcript`)
|
|
101
|
-
- Benchmark and evaluation artifact mutation protection
|
|
102
|
-
|
|
103
|
-
---
|
|
104
|
-
|
|
105
|
-
## The Core Problems Solved
|
|
106
|
-
|
|
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>`).
|
|
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.
|
|
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.
|
|
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`).
|
|
111
|
-
|
|
112
|
-
---
|
|
40
|
+
> **Upgrading from v1.x:** Running `agy-context setup` automatically removes legacy `mcp_config.json` entries, sweeps stale `~/.gemini/antigravity/mcp/agy-context-saver*` schema caches, and replaces the retired v1.x MCP server with the on-demand `agy-context` CLI and updated `PreToolUse` hook.
|
|
113
41
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
- **Transparent RTK Rewriting**: Native `run_command` calls are automatically rewritten (e.g. `pytest` $\to$ `rtk pytest`) via Antigravity PreToolUse hooks.
|
|
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.
|
|
131
|
-
- **Antigravity Special Files Safe Harbor**: Direct `view_file` access to `SKILL.md`, brain artifacts, and config files is preserved.
|
|
132
|
-
- **Protected Internal State**: Root-based guard prevents reading `.system_generated/` (transcripts, task logs, progress).
|
|
133
|
-
- **Session-Wide Lifecycle Ledger**: Polling checks are tracked globally per session; changing task IDs or waiting does not reset governance.
|
|
134
|
-
- **Zero-JSON Transcript Streaming**: Stream conversation turns without raw JSON syntax using `read_transcript` and `query_transcript`.
|
|
135
|
-
|
|
136
|
-
---
|
|
137
|
-
|
|
138
|
-
## Comprehensive Documentation
|
|
139
|
-
|
|
140
|
-
For complete technical references, architectural specifications, and governance rules, visit our **[Zensical Documentation Site](https://paragon-ux.github.io/agy-context-saver/)**:
|
|
141
|
-
|
|
142
|
-
- 📖 **[Getting Started & Installation](docs/installation.md)**: Zero-delay setup, native plugin linking, hooks registration, and verification matrix.
|
|
143
|
-
- 🏗️ **[Architecture & Internals](docs/architecture.md)**: Closed Execution Topology, RTK separation of concerns, and the Four Non-Fragile Architectural Pillars.
|
|
144
|
-
- 🛡️ **[Lifecycle Governance & Hooks](docs/governance.md)**: Proportional Backoff curve, Reactive Wakeup invariants, and the 5-strike circuit breaker.
|
|
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.
|
|
147
|
-
- 🚀 **[Publishing & Verification Playbook](docs/publishing.md)**: Clean-room test runs, release procedures, and multi-suite verification matrix.
|
|
148
|
-
- 🗺️ **[Product Roadmap](docs/roadmap.md)**: Phased strategic roadmap focusing on affordable and reliable multi-agent workflows across general tasks.
|
|
149
|
-
|
|
150
|
-
---
|
|
151
|
-
|
|
152
|
-
## Local Documentation Server
|
|
153
|
-
|
|
154
|
-
Build or serve the documentation locally using **Zensical**:
|
|
42
|
+
To remove the plugin link, hook entries, and CLI shims:
|
|
155
43
|
|
|
156
44
|
```bash
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
# Serve live preview server
|
|
161
|
-
zensical serve
|
|
45
|
+
agy-context uninstall
|
|
46
|
+
# Or restore pre-install .bak configuration files:
|
|
47
|
+
agy-context uninstall --restore-backups
|
|
162
48
|
```
|
|
163
49
|
|
|
164
|
-
|
|
50
|
+
## CLI and hook summary
|
|
165
51
|
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
node tests/test-output-governance.mjs
|
|
194
|
-
|
|
195
|
-
# End-to-end edge case & probe tests
|
|
196
|
-
node tests/test-e2e-probes.mjs
|
|
197
|
-
|
|
198
|
-
# Performance, streaming & memory probes
|
|
199
|
-
node tests/test-performance-probes.mjs
|
|
200
|
-
|
|
201
|
-
# Live installed environment verification
|
|
202
|
-
node tests/test-installed-verification.mjs
|
|
203
|
-
|
|
204
|
-
# Clean install/uninstall/restore lifecycle test
|
|
205
|
-
node tests/test-lifecycle-rollback.mjs
|
|
206
|
-
|
|
207
|
-
# Check-only read-only isolation regression test
|
|
208
|
-
node tests/test-check-only-readonly.mjs
|
|
209
|
-
|
|
210
|
-
# Malformed config preservation fail-closed regression test
|
|
211
|
-
node tests/test-malformed-config-preservation.mjs
|
|
212
|
-
|
|
213
|
-
# RTK ledger & fresh install verification test
|
|
214
|
-
node tests/test-rtk-ledger-fresh-install.mjs
|
|
215
|
-
```
|
|
216
|
-
|
|
217
|
-
### 4. Test MCP Tools from Antigravity Agent
|
|
218
|
-
- `get_installation_status`: Call with `{}` to audit all 4 layers + RTK.
|
|
219
|
-
- `check_context_health`: Call with `{ "transcriptPath": "<path-to-transcript.jsonl>" }`.
|
|
220
|
-
- `read_transcript`: Call with `{ "conversationId": "<uuid>", "lastTurns": 3, "mode": "compact" }`.
|
|
221
|
-
- `query_transcript`: Call with `{ "conversationId": "<uuid>", "query": "<term>", "summaryOnly": true }`.
|
|
222
|
-
|
|
223
|
-
### 5. Testing Pitfalls & Anti-Patterns to Avoid
|
|
224
|
-
- ❌ **Do NOT run `npm start` or `node mcp/index.js` interactively**: It starts the stdio JSON-RPC daemon and waits indefinitely on `stdin`.
|
|
225
|
-
- ❌ **Do NOT loop on `manage_task(Action='status')`**: Polling triggers the session ledger circuit breaker at 5 cumulative denials. Rely on native Reactive Wakeup (`<SYSTEM_MESSAGE>`).
|
|
226
|
-
- ❌ **Do NOT run `npm run uninstall` as a standalone check**: It unregisters the live hook. If run, immediately re-run `npm run setup`.
|
|
227
|
-
- ❌ **On Windows, do NOT omit the directory in `rtk rg`**: Always run `rtk rg "<pattern>" .` to avoid stdin pipe blocking.
|
|
228
|
-
|
|
229
|
-
---
|
|
230
|
-
|
|
231
|
-
## MCP Tools & Slash Commands
|
|
232
|
-
|
|
233
|
-
* **User Slash Command (`/mcp:...`)**:
|
|
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
|
-
* **Agent MCP Tools**:
|
|
236
|
-
1. `check_context_health`: Diagnoses conversation transcript turn budgets, payload size, RTK status, and polling loops.
|
|
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.
|
|
241
|
-
|
|
242
|
-
* **Streamlined Output Inspection (0 New Tools)**:
|
|
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`).
|
|
244
|
-
- **Completed Background Task Logs**: Inspected via `rtk read tasks/<taskId>.log` (lifecycle-gated in the PreToolUse hook; strictly blocked under Proportional Backoff while running, allowed once completed).
|
|
245
|
-
|
|
246
|
-
---
|
|
52
|
+
| Surface | Purpose | Common usage |
|
|
53
|
+
| :--- | :--- | :--- |
|
|
54
|
+
| `agy-context transcript health` (`stats`, `info`) | Check turn counts, transcript byte size, RTK status, and polling events | `agy-context transcript health [<id>] [--json]` |
|
|
55
|
+
| `agy-context transcript read` (`outline`, `summary`) | Read recent turns in Markdown or print a 1-line-per-step tool outline | `agy-context transcript read [<id>] --last-turns 3` / `agy-context transcript outline [<id>]` |
|
|
56
|
+
| `agy-context transcript query` (`grep`, `search`, `find`, `tools`) | Search compact and truncated full steps by regex, role, or tool call arguments | `agy-context transcript grep "<pattern>" [<id>] --summary` / `agy-context transcript tools [<id>]` |
|
|
57
|
+
| `agy-context transcript step` | Extract untruncated fields for a step, comma list, or range (`N..M`) | `agy-context transcript step 10..15 [<id>] --field content --tail 40` |
|
|
58
|
+
| `agy-context transcript list` (`ls`) | List recent conversation transcripts in the Antigravity brain directory | `agy-context transcript ls --limit 5` |
|
|
59
|
+
| `agy-context transcript access` (`policy`) | View or update child subagent and `/swarm` worker transcript access | `agy-context transcript access --status` / `--off` / `--self-only` / `--allow @audit-squad*` / `--on` |
|
|
60
|
+
| `agy-context status` / `setup` / `uninstall` | Audit, synchronize, or remove plugin link, hook, CLI shims, and RTK config | `agy-context status` / `agy-context setup --check` |
|
|
61
|
+
|
|
62
|
+
## Documentation
|
|
63
|
+
|
|
64
|
+
Full documentation is hosted at [paragon-ux.github.io/agy-context-saver](https://paragon-ux.github.io/agy-context-saver/) and in [`docs/`](docs/):
|
|
65
|
+
|
|
66
|
+
- [Overview](docs/index.md)
|
|
67
|
+
- [Installation and setup](docs/installation.md)
|
|
68
|
+
- [CLI and hook reference](docs/tools.md)
|
|
69
|
+
- [Lifecycle governance and transcript access control](docs/governance.md)
|
|
70
|
+
- [Architecture and internals](docs/architecture.md)
|
|
71
|
+
- [Installer hardening policy](docs/INSTALLER-HARDENING.md)
|
|
72
|
+
- [RTK support matrix](docs/RTK-SUPPORT-MATRIX.md)
|
|
73
|
+
- [Publishing and verification](docs/publishing.md)
|
|
74
|
+
- [Product roadmap](docs/roadmap.md)
|
|
75
|
+
|
|
76
|
+
## Development
|
|
77
|
+
|
|
78
|
+
Run `node scripts/release-preflight.mjs` and `npm test` with Node.js `>= 22`. Runs all 11 test suites (`tests/test-hook.mjs`, `tests/test-transcript.mjs`, `tests/test-rtk-integration.mjs`, `tests/test-output-governance.mjs`, `tests/test-e2e-probes.mjs`, `tests/test-performance-probes.mjs`, `tests/test-installed-verification.mjs`, `tests/test-lifecycle-rollback.mjs`, `tests/test-check-only-readonly.mjs`, `tests/test-malformed-config-preservation.mjs`, and `tests/test-rtk-ledger-fresh-install.mjs`) in isolated temporary profiles without mutating your live `~/.gemini` directory.
|
|
247
79
|
|
|
248
80
|
## License
|
|
249
81
|
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" class="pele pele-flowchart" viewBox="0 0 793 582" width="793" height="582" style="max-width:100%;height:auto;--_bg:var(--pele-bg,#fff);--_fg:var(--pele-fg,#1f1f1f);--_m:var(--pele-muted,#6e6e6e);--_l:var(--pele-line,#1f1f1f);--_s:var(--pele-surface,#f3f3f3);--_a:var(--pele-surface-alt,#e6e6e6);--_b:var(--pele-border,#8a8a8a);--_c:var(--pele-accent,#5b7bd5);color:var(--_fg);--_r:var(--pele-radius,4px);--_fm:var(--pele-font-mono,monospace);font:16px sans-serif;letter-spacing:normal;word-spacing:normal;text-transform:none;direction:ltr;font-family:var(--pele-font,sans-serif)" fill="var(--_fg)" role="graphics-document document" aria-roledescription="flowchart">
|
|
2
|
+
<style>
|
|
3
|
+
:root {
|
|
4
|
+
--pele-font: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif;
|
|
5
|
+
--pele-bg: #ffffff;
|
|
6
|
+
--pele-fg: #1f2328;
|
|
7
|
+
--pele-muted: #656d76;
|
|
8
|
+
--pele-line: #57606a;
|
|
9
|
+
--pele-surface: #f6f8fa;
|
|
10
|
+
--pele-surface-alt: #eaeef2;
|
|
11
|
+
--pele-border: #d0d7de;
|
|
12
|
+
--pele-accent: #0969da;
|
|
13
|
+
--pele-series-1: #0969da;
|
|
14
|
+
--pele-series-2: #1a7f37;
|
|
15
|
+
--pele-series-3: #9a6700;
|
|
16
|
+
--pele-series-4: #8250df;
|
|
17
|
+
--pele-series-5: #cf222e;
|
|
18
|
+
--pele-series-6: #bf3989;
|
|
19
|
+
}
|
|
20
|
+
@media (prefers-color-scheme: dark) {
|
|
21
|
+
:root {
|
|
22
|
+
--pele-bg: #0d1117;
|
|
23
|
+
--pele-fg: #e6edf3;
|
|
24
|
+
--pele-muted: #8b949e;
|
|
25
|
+
--pele-line: #8b949e;
|
|
26
|
+
--pele-surface: #161b22;
|
|
27
|
+
--pele-surface-alt: #21262d;
|
|
28
|
+
--pele-border: #30363d;
|
|
29
|
+
--pele-accent: #2f81f7;
|
|
30
|
+
--pele-series-1: #2f81f7;
|
|
31
|
+
--pele-series-2: #3fb950;
|
|
32
|
+
--pele-series-3: #d29922;
|
|
33
|
+
--pele-series-4: #a371f7;
|
|
34
|
+
--pele-series-5: #f85149;
|
|
35
|
+
--pele-series-6: #db61a2;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
</style>
|
|
39
|
+
<g class="pele-clusters"><g class="pele-cluster" data-id="L3"><rect x="8" y="427" width="776.45" height="147" fill="var(--_a)" fill-opacity="0.5" stroke="var(--_b)" style="rx:var(--_r)"/><text class="pele-cluster-label" fill="var(--_m)" x="193.18" y="452.6" text-anchor="middle">RTK (>= 1.1.0), agy-context CLI & Host Wakeup</text></g><g class="pele-cluster" data-id="L2"><rect x="59.9" y="228" width="672.64" height="126" fill="var(--_a)" fill-opacity="0.5" stroke="var(--_b)" style="rx:var(--_r)"/></g><g class="pele-cluster" data-id="L1"><rect x="25.72" y="8" width="741.01" height="147" fill="var(--_a)" fill-opacity="0.5" stroke="var(--_b)" style="rx:var(--_r)"/><text class="pele-cluster-label" fill="var(--_m)" x="109.07" y="33.6" text-anchor="middle">Antigravity Runtime</text></g></g><g class="pele-edges" fill="none" stroke="var(--_l)" stroke-linecap="round"><g class="pele-edge" data-id="L_L1_L2_0"><path d="M396.22,155L396.22,221"/><path class="pele-marker" d="M396.22,228L392.86,220L399.58,220Z" fill="var(--_l)" stroke="none"/></g><g class="pele-edge" data-id="L_L2_L3_0"><path d="M396.22,354L396.22,420"/><path class="pele-marker" d="M396.22,427L392.86,419L399.58,419Z" fill="var(--_l)" stroke="none"/></g></g><g class="pele-cluster-titles"><g class="pele-cluster-title" data-id="L2"><text fill="none" stroke="color-mix(in srgb,var(--_a) 50%,var(--_bg))" stroke-width="5" stroke-linejoin="round" x="254.85" y="253.6" text-anchor="middle">Agy-Context-Saver: PreToolUse Hook (hooks.json)</text><text class="pele-cluster-label" fill="var(--_m)" x="254.85" y="253.6" text-anchor="middle">Agy-Context-Saver: PreToolUse Hook (hooks.json)</text></g></g><g class="pele-edge-labels" font-size="14"><g class="pele-edge-label" data-id="L_L1_L2_0"><rect x="328.81" y="177.5" width="134.83" height="21" rx="3" fill="var(--_bg)"/><text x="396.22" y="192.9" text-anchor="middle">PreToolUse payload</text></g><g class="pele-edge-label" data-id="L_L2_L3_0"><rect x="312.09" y="376.5" width="168.27" height="21" rx="3" fill="var(--_bg)"/><text x="396.22" y="391.9" text-anchor="middle">rewrite, slice, or 10s grant</text></g></g><g class="pele-nodes"><g class="pele-node pele-shape-rect" data-id="A1" transform="translate(125.95,91.5)"><rect x="-80.23" y="-33" width="160.46" height="66" fill="var(--_s)" stroke="var(--_b)" style="rx:var(--_r)"/><text class="pele-label" text-anchor="middle" xml:space="preserve"><tspan x="0" y="-4.9">run_command</tspan><tspan x="0" y="16.1">(shell & CLI calls)</tspan></text></g><g class="pele-node pele-shape-rect" data-id="A2" transform="translate(358.87,91.5)"><rect x="-112.69" y="-43.5" width="225.38" height="87" fill="var(--_s)" stroke="var(--_b)" style="rx:var(--_r)"/><text class="pele-label" text-anchor="middle" xml:space="preserve"><tspan x="0" y="-15.4">read_file / edit_file /</tspan><tspan x="0" y="5.6">write_file</tspan><tspan x="0" y="26.6">(workspace & special files)</tspan></text></g><g class="pele-node pele-shape-rect" data-id="A3" transform="translate(629.14,91.5)"><rect x="-117.58" y="-33" width="235.17" height="66" fill="var(--_s)" stroke="var(--_b)" style="rx:var(--_r)"/><text class="pele-label" text-anchor="middle" xml:space="preserve"><tspan x="0" y="-4.9">manage_task / schedule</tspan><tspan x="0" y="16.1">(background tasks & timers)</tspan></text></g><g class="pele-node pele-shape-rect" data-id="B1" transform="translate(168.61,301)"><rect x="-88.7" y="-33" width="177.41" height="66" fill="var(--_s)" stroke="var(--_b)" style="rx:var(--_r)"/><text class="pele-label" text-anchor="middle" xml:space="preserve"><tspan x="0" y="-4.9">Shell & State Guard</tspan><tspan x="0" y="16.1">+ 10s Sync Window</tspan></text></g><g class="pele-node pele-shape-rect" data-id="B2" transform="translate(394.9,301)"><rect x="-97.58" y="-33" width="195.17" height="66" fill="var(--_s)" stroke="var(--_b)" style="rx:var(--_r)"/><text class="pele-label" text-anchor="middle" xml:space="preserve"><tspan x="0" y="-4.9">Hybrid Slice (<= 150L)</tspan><tspan x="0" y="16.1">& Safe Harbor</tspan></text></g><g class="pele-node pele-shape-rect" data-id="B3" transform="translate(622.51,301)"><rect x="-90.03" y="-33" width="180.06" height="66" fill="var(--_s)" stroke="var(--_b)" style="rx:var(--_r)"/><text class="pele-label" text-anchor="middle" xml:space="preserve"><tspan x="0" y="-4.9">Proportional Backoff</tspan><tspan x="0" y="16.1">& 5-Strike Breaker</tspan></text></g><g class="pele-node pele-shape-rect" data-id="C1" transform="translate(135.38,510.5)"><rect x="-107.38" y="-33" width="214.75" height="66" fill="var(--_s)" stroke="var(--_b)" style="rx:var(--_r)"/><text class="pele-label" text-anchor="middle" xml:space="preserve"><tspan x="0" y="-4.9">rtk hook antigravity</tspan><tspan x="0" y="16.1">& rtk grep / find / ls / read</tspan></text></g><g class="pele-node pele-shape-rect" data-id="C2" transform="translate(397.57,510.5)"><rect x="-114.82" y="-43.5" width="229.63" height="87" fill="var(--_s)" stroke="var(--_b)" style="rx:var(--_r)"/><text class="pele-label" text-anchor="middle" xml:space="preserve"><tspan x="0" y="-15.4">agy-context transcript</tspan><tspan x="0" y="5.6">read | query | step | health |</tspan><tspan x="0" y="26.6">list | access</tspan></text></g><g class="pele-node pele-shape-rect" data-id="C3" transform="translate(658.42,510.5)"><rect x="-106.03" y="-33" width="212.06" height="66" fill="var(--_s)" stroke="var(--_b)" style="rx:var(--_r)"/><text class="pele-label" text-anchor="middle" xml:space="preserve"><tspan x="0" y="-4.9">Reactive Wakeup</tspan><tspan x="0" y="16.1">& 10s Single-Use Grants</tspan></text></g></g></svg>
|