agy-context-saver 0.0.0-stage → 1.2.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 +60 -0
- package/LICENSE +21 -0
- package/README.md +172 -2
- package/hooks.json +16 -0
- package/install.ps1 +42 -0
- package/install.sh +6 -0
- package/mcp/index.js +1085 -0
- package/mcp/instructions.md +30 -0
- package/mcp_config.json +8 -0
- package/package.json +42 -6
- package/plugin.json +5 -0
- package/rules/AGENTS.md +78 -0
- package/scripts/execution-guard-hook.mjs +575 -0
- package/scripts/install-register.mjs +620 -0
- package/scripts/provision-rtk.mjs +120 -0
- package/skills/context-governance/SKILL.md +130 -0
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# Agy-Context-Saver MCP Server Instructions
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
Agy-Context-Saver is the universal Model Context Protocol server and lifecycle governor for Google Antigravity, paired with RTK (Rust Token Killer) for transparent CLI output reduction.
|
|
5
|
+
|
|
6
|
+
## Core Rules for Antigravity Agents
|
|
7
|
+
1. **Reactive Wakeup (Zero Task Polling)**:
|
|
8
|
+
- When background tasks run, DO NOT call `manage_task(Action='status')` or `schedule` polling timers.
|
|
9
|
+
- Stop calling tools and yield the turn. The system notifies you automatically via `<SYSTEM_MESSAGE>`.
|
|
10
|
+
- Repeated polling triggers an escalating circuit breaker (frozen at 5 denials).
|
|
11
|
+
2. **Never Read Internal State Directly**:
|
|
12
|
+
- Access to `.system_generated/` via `view_file` is strictly denied to prevent transcript explosion.
|
|
13
|
+
- Use `read_transcript` or `query_transcript` to inspect conversation history cleanly.
|
|
14
|
+
3. **Platform-Aware Codebase Inspection**:
|
|
15
|
+
- **Windows**: Use `rtk read <file>`, `rtk find <path>`, and `rtk rg "<pattern>" .` (the trailing `.` is required to avoid stdin stalls).
|
|
16
|
+
- **POSIX**: Use `rtk read <file>`, `rtk ls <path>`, and `rtk grep "<pattern>"` or `rtk rg "<pattern>"`.
|
|
17
|
+
|
|
18
|
+
## Available MCP Tools
|
|
19
|
+
- `check_context_health`: Diagnoses transcript turn counts, byte payload, and polling loops. Accepts `transcriptPath` or `conversationId`.
|
|
20
|
+
- `subagent_brief`: Generates scope-isolated instructions for delegated subagents to prevent parent context bloat.
|
|
21
|
+
- `read_transcript`: Streams recent turns from `transcript.jsonl` or `transcript_full.jsonl` formatted as clean Markdown.
|
|
22
|
+
- `query_transcript`: Forensic regex search and filtering engine across transcript steps with optional `summaryOnly: true`.
|
|
23
|
+
- `get_installation_status`: Audits live health of the plugin link, hook, MCP server, tool schemas, and RTK.
|
|
24
|
+
- `sync_installation`: Synchronizes and repairs all 4 integration layers in ~25ms.
|
|
25
|
+
|
|
26
|
+
## Diagnostic & CLI Playbook
|
|
27
|
+
- Audit Status: `npm run status` or `node mcp/index.js status`
|
|
28
|
+
- Run Test Suite: `npm test`
|
|
29
|
+
- CLI Help: `node mcp/index.js --help`
|
|
30
|
+
- ⚠️ Warning: Do not run `npm start` or `node mcp/index.js` without subcommands interactively (it is a stdio JSON-RPC server).
|
package/mcp_config.json
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,42 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "agy-context-saver",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "agy-context-saver",
|
|
3
|
+
"version": "1.2.1",
|
|
4
|
+
"description": "Universal Model Context Protocol (MCP) server & lifecycle governor purpose-built for Google Antigravity",
|
|
5
|
+
"main": "mcp/index.js",
|
|
6
|
+
"bin": {
|
|
7
|
+
"agy-context-saver": "mcp/index.js"
|
|
8
|
+
},
|
|
9
|
+
"type": "module",
|
|
10
|
+
"scripts": {
|
|
11
|
+
"start": "node mcp/index.js",
|
|
12
|
+
"setup": "node scripts/install-register.mjs",
|
|
13
|
+
"uninstall": "node scripts/install-register.mjs --uninstall",
|
|
14
|
+
"status": "node scripts/install-register.mjs --status",
|
|
15
|
+
"test": "node tests/test-hook.mjs && node tests/test-mcp.mjs && node tests/test-e2e-probes.mjs && node tests/test-performance-probes.mjs && node tests/test-installed-verification.mjs && node tests/test-lifecycle-rollback.mjs"
|
|
16
|
+
},
|
|
17
|
+
"keywords": [
|
|
18
|
+
"antigravity",
|
|
19
|
+
"mcp",
|
|
20
|
+
"model-context-protocol",
|
|
21
|
+
"gemini",
|
|
22
|
+
"context-window",
|
|
23
|
+
"lifecycle-hooks",
|
|
24
|
+
"agentic-coding"
|
|
25
|
+
],
|
|
26
|
+
"files": [
|
|
27
|
+
"mcp",
|
|
28
|
+
"scripts",
|
|
29
|
+
"rules",
|
|
30
|
+
"skills",
|
|
31
|
+
"hooks.json",
|
|
32
|
+
"plugin.json",
|
|
33
|
+
"mcp_config.json",
|
|
34
|
+
"install.ps1",
|
|
35
|
+
"install.sh",
|
|
36
|
+
"README.md",
|
|
37
|
+
"CHANGELOG.md",
|
|
38
|
+
"LICENSE"
|
|
39
|
+
],
|
|
40
|
+
"author": "paragon-ux",
|
|
41
|
+
"license": "MIT"
|
|
42
|
+
}
|
package/plugin.json
ADDED
package/rules/AGENTS.md
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
# Antigravity Execution & Context Governance (Agy-Context-Saver + RTK)
|
|
2
|
+
|
|
3
|
+
## Core Architectural Boundary
|
|
4
|
+
- **RTK (Rust Token Killer)**: Owns shell command transparent rewriting, output reduction, and compact codebase inspection (`rtk read`, `rtk grep`, `rtk find`, `rtk ls`, `rtk err`, `rtk summary`).
|
|
5
|
+
- **Agy-Context-Saver**: Owns Antigravity lifecycle governance, Reactive Wakeup enforcement, transcript forensics, and session integrity.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Layer 1: Background Tasks & Polling Ban (Reactive Wakeup SSOT)
|
|
10
|
+
- **Zero-Tolerance on Task Polling**: Do NOT call `manage_task(Action='status')` or `schedule` timers in a loop to wait for running background tasks. Background tasks execute asynchronously and automatically resume the agent via **Reactive Wakeup** (`<SYSTEM_MESSAGE>`).
|
|
11
|
+
- **Yield Turn Immediately**: When a process moves to the background, stop calling tools, output a concise status message, and yield the turn.
|
|
12
|
+
- **No Keyword or Timer Exemptions**: Words like "debug", "timeout", "diagnose", or "stuck" do NOT exempt an agent from lifecycle governance. Timers with `duration >= 120` are NOT exempt.
|
|
13
|
+
- **Circuit Breaker**: Repeated polling calls across any tasks in a session trigger an escalating circuit breaker. At 5 cumulative denials, autonomous execution is frozen via `force_ask`.
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## Layer 2: Transparent Shell Execution & Codebase Inspection via RTK
|
|
18
|
+
- **Native Shell Commands**: Run shell commands normally using `run_command`. The PreToolUse hook transparently rewrites supported commands via RTK (`git`, `pytest`, `cargo`, `npm`, etc.) to produce ultra-compact outputs.
|
|
19
|
+
- **Canonical Codebase Inspection**: Native file and search inspection tools (`view_file`, `grep_search`, `find_by_name`, `list_dir`) that bypass RTK are blocked for workspace files. Use RTK's canonical CLI interfaces via `run_command`:
|
|
20
|
+
- `rtk read <file>`: Read file with intelligent token filtering and line ranges.
|
|
21
|
+
- `rtk find <path>`: Compact file search tree and directory listings (cross-platform, works on Windows & POSIX).
|
|
22
|
+
- Search commands by platform:
|
|
23
|
+
- **Windows**: Use `rtk rg "<pattern>" .` (explicit target `.` is required to prevent stdin pipe hanging) or `rg "<pattern>" .`.
|
|
24
|
+
- **POSIX / Linux / macOS**: Use `rtk grep "<pattern>"` or `rtk rg "<pattern>"`.
|
|
25
|
+
- Directory listing by platform:
|
|
26
|
+
- **Windows**: Use `rtk find <path>` or PowerShell `dir` / `Get-ChildItem`. (Avoid `rtk ls` or `rtk tree` on Windows as they rely on POSIX binaries/flags).
|
|
27
|
+
- **POSIX / Linux / macOS**: Use `rtk ls <path>` or `rtk tree`.
|
|
28
|
+
- `rtk err <cmd>`: Run command and show only errors/warnings.
|
|
29
|
+
- `rtk summary <cmd>`: Run command and produce a 2-line heuristic summary.
|
|
30
|
+
- **Antigravity Special Files Safe Harbor**: Documented Antigravity special files (`SKILL.md`, brain artifacts, `.gemini/config/` configs) are permitted via `view_file`.
|
|
31
|
+
- **Protected Internal State**: Direct native inspection of `.system_generated/` (transcripts, task logs, progress files) is strictly forbidden. Use Agy MCP tools `read_transcript` and `query_transcript`.
|
|
32
|
+
|
|
33
|
+
---
|
|
34
|
+
|
|
35
|
+
## Layer 3: Synchronous Execution & Subagent Delegation
|
|
36
|
+
- **Maximum Synchronous Window**: Non-daemon `run_command` calls are automatically set to `WaitMsBeforeAsync: 10000` to complete synchronously and prevent unnecessary background detachment.
|
|
37
|
+
- **Targeted Test Execution**: Avoid massive multi-minute test sweeps in interactive turns. Run targeted, quiet, fail-fast commands (e.g. `pytest tests/test_core.py -q -x`).
|
|
38
|
+
- **Subagent Delegation**: Delegate heavy multi-file exploration and exploratory research to subagents (`invoke_subagent`). Subagents absorb intermediate steps and return high-signal summaries.
|
|
39
|
+
- **Benchmark / Evaluator Integrity**: Never mutate benchmark definitions, prompt templates, or scoring artifacts during an active evaluation without explicit user confirmation.
|
|
40
|
+
|
|
41
|
+
---
|
|
42
|
+
|
|
43
|
+
## Layer 4: Zero-Guesswork Testing & Verification Playbook
|
|
44
|
+
When an agent or developer tests this framework, follow this exact sequence without guessing:
|
|
45
|
+
|
|
46
|
+
1. **Verify Live Registration & Health (Fast, non-blocking)**:
|
|
47
|
+
```bash
|
|
48
|
+
npm run status
|
|
49
|
+
# or
|
|
50
|
+
node mcp/index.js status
|
|
51
|
+
```
|
|
52
|
+
*Expected*: Reports `HEALTHY & ACTIVE 🛡️` across plugin link, hook, MCP config, schemas, and RTK.
|
|
53
|
+
|
|
54
|
+
2. **Execute Full Automated Test Suite**:
|
|
55
|
+
```bash
|
|
56
|
+
npm test
|
|
57
|
+
```
|
|
58
|
+
*Expected*: All 5 test suites pass (Hook unit tests, MCP protocol tests, E2E probes, live system validation, lifecycle rollback).
|
|
59
|
+
|
|
60
|
+
3. **Verify Individual Layers On-Demand**:
|
|
61
|
+
- Governance Hook: `node tests/test-hook.mjs`
|
|
62
|
+
- MCP Protocol & JSON-RPC: `node tests/test-mcp.mjs`
|
|
63
|
+
- E2E Probes: `node tests/test-e2e-probes.mjs`
|
|
64
|
+
- Live System Checks: `node tests/test-installed-verification.mjs`
|
|
65
|
+
- Lifecycle & Rollback: `node tests/test-lifecycle-rollback.mjs`
|
|
66
|
+
|
|
67
|
+
4. **Verify MCP Tools in Antigravity**:
|
|
68
|
+
- `get_installation_status`: Inspect live integration layers.
|
|
69
|
+
- `check_context_health`: Pass `{ "transcriptPath": "<path-to-transcript.jsonl>" }`.
|
|
70
|
+
- `read_transcript`: Pass `{ "conversationId": "<uuid>", "lastTurns": 3, "mode": "compact" }`.
|
|
71
|
+
- `query_transcript`: Pass `{ "conversationId": "<uuid>", "query": "<pattern>", "summaryOnly": true }`.
|
|
72
|
+
- `subagent_brief`: Pass `{ "objective": "<goal>", "scopeFiles": ["..."] }`.
|
|
73
|
+
|
|
74
|
+
5. **Operational Anti-Patterns (What NOT to do)**:
|
|
75
|
+
- ❌ **Do NOT run `npm start` or `node mcp/index.js` interactively**: It starts the stdio JSON-RPC daemon and waits indefinitely on stdin.
|
|
76
|
+
- ❌ **Do NOT run `manage_task(Action='status')` loops**: Status polling is governed; 5 polls trigger the `force_ask` circuit breaker.
|
|
77
|
+
- ❌ **Do NOT run `npm run uninstall` as an isolated test**: It strips the live hook from `~/.gemini/config/`. If run, immediately re-run `npm run setup`.
|
|
78
|
+
- ❌ **Do NOT omit explicit target paths with `rtk rg`**: Always provide a path (e.g. `rtk rg "pattern" .`) to prevent stdin blocking.
|