agy-context-saver 1.6.1 → 1.7.0

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,18 @@ 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.7.0] - 2026-10-13
9
+
10
+ ### Added
11
+ - **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").
12
+ - **Pointer-Over-Wire (POW) File Delivery Clarification**: Codified explicit two-option guidance for subagent deliverables:
13
+ - *Option A (Workspace `scratch/` — Recommended)*: Write to `<workspace>/scratch/<task>_findings.md` and omit `ArtifactMetadata`.
14
+ - *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 }`.
15
+ - **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.
16
+ - **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.
17
+
18
+ ---
19
+
8
20
  ## [1.6.1] - 2026-10-12
9
21
 
10
22
  ### Added
@@ -162,6 +174,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
162
174
  - Antigravity Model Context Protocol (MCP) server.
163
175
  - Background task lifecycle governance and reactive wakeup enforcement.
164
176
 
177
+ [1.7.0]: https://github.com/paragon-ux/agy-context-saver/compare/v1.6.1...v1.7.0
165
178
  [1.6.1]: https://github.com/paragon-ux/agy-context-saver/compare/v1.6.0...v1.6.1
166
179
  [1.6.0]: https://github.com/paragon-ux/agy-context-saver/compare/v1.5.1...v1.6.0
167
180
  [1.5.1]: https://github.com/paragon-ux/agy-context-saver/compare/v1.5.0...v1.5.1
package/mcp/index.js CHANGED
@@ -72,7 +72,7 @@ if (checkFlag) {
72
72
 
73
73
  function printHelp() {
74
74
  console.log(`
75
- Agy-Context-Saver 🛡️ (v1.6.1)
75
+ Agy-Context-Saver 🛡️ (v1.7.0)
76
76
  Universal MCP Server & Lifecycle Governor for Google Antigravity (Powered by RTK)
77
77
 
78
78
  Usage:
@@ -119,7 +119,7 @@ const __dirname = path.dirname(fileURLToPath(import.meta.url));
119
119
  const rulesPath = path.resolve(__dirname, "../rules/AGENTS.md");
120
120
 
121
121
  const SERVER_NAME = "agy-context-saver";
122
- const SERVER_VERSION = "1.6.1";
122
+ const SERVER_VERSION = "1.7.0";
123
123
 
124
124
  // --- Tools Specification ---
125
125
  const TOOLS = [
@@ -472,14 +472,20 @@ function formatSingleBrief({
472
472
  } = {}) {
473
473
  const scopeStr = scopeFiles && scopeFiles.length ? `\n\nTarget files:\n${scopeFiles.map(f => `- ${f}`).join("\n")}` : "";
474
474
  const instrStr = instructions && instructions.trim() ? `\n\nSPECIFIC INSTRUCTIONS:\n${instructions.trim()}` : "";
475
+ const hasBrainUuidPath = /[/\\]\.gemini[/\\]antigravity[/\\]brain[/\\][0-9a-f-]{36}/i.test(`${objective}\n${instructions}\n${expectedDeliverable}`);
476
+ const brainPathWarning = hasBrainUuidPath
477
+ ? `\n\n⚠️ ARTIFACT DIRECTORY WRITE GUARD: Any 'brain/<uuid>/' path referenced above belongs to another conversation. You may READ from it via 'view_file', but when calling 'write_to_file' or 'replace_file_content', you MUST either write to workspace '<workspace>/scratch/...' (OMIT ArtifactMetadata) or substitute YOUR OWN Artifact Directory Path from <user_information> (INCLUDE ArtifactMetadata).`
478
+ : "";
475
479
  return [
476
480
  `ROLE: ${role}`,
477
- `OBJECTIVE: ${objective}${scopeStr}${instrStr}`,
481
+ `OBJECTIVE: ${objective}${scopeStr}${instrStr}${brainPathWarning}`,
478
482
  ``,
479
483
  `CRITICAL CONTEXT GOVERNANCE INSTRUCTIONS (POINTER-OVER-WIRE):`,
480
- `1. Isolated Workspace: Do all necessary multi-file exploration, searches, and analysis in this subagent sandbox.`,
484
+ `1. Isolated Workspace & Bounded File Slices: Do all multi-file exploration in this subagent sandbox. Prefer 'view_file' with bounded slices (StartLine and EndLine, max 150 lines) over 'rtk read' so line numbers are preserved and terminal buffers never truncate file headers.`,
481
485
  `2. Pointer-Over-Wire (POW) Protocol: In-band messaging channels (send_message) have strict transport payload limits (~16-20 KB). If your findings or deliverable exceed 1 KB:`,
482
- ` a. Write the full comprehensive deliverable or raw output to a file in the workspace (e.g., 'scratch/<task>_findings.md' or an artifact).`,
486
+ ` a. Write the full comprehensive deliverable using 'write_to_file' following Antigravity's strict path rules:`,
487
+ ` - Option A (Workspace 'scratch/' — Recommended): Set TargetFile to '<workspace>/scratch/<task>_findings.md' and OMIT ArtifactMetadata completely (passing ArtifactMetadata on a workspace path throws "files must be written to the correct artifact directory").`,
488
+ ` - Option B (Your Own Brain 'scratch/'): Set TargetFile to '<your-Artifact-Directory-Path>/scratch/<task>_findings.md' using the exact Artifact Directory Path from YOUR <user_information> block (NEVER a parent's brain/<other-uuid>/ path) and INCLUDE ArtifactMetadata: { Summary: "...", UserFacing: false, RequestFeedback: false }.`,
483
489
  ` b. In 'send_message', transmit ONLY:`,
484
490
  ` - Executive Summary (3-5 high-signal sentences)`,
485
491
  ` - Verdict / Scoreboard Table`,
@@ -12,8 +12,9 @@ Agy-Context-Saver is the universal Model Context Protocol server and lifecycle g
12
12
  - Access to `.system_generated/` via `view_file` is strictly denied to prevent transcript explosion.
13
13
  - Use `read_transcript` or `query_transcript` to inspect conversation history cleanly.
14
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>"`.
15
+ - **File Reading**: Prefer `view_file` with bounded slices (`StartLine` and `EndLine`, max 150 lines) to preserve line numbers and avoid terminal truncation.
16
+ - **Windows Search/Listing**: Use `rtk find <path>` and `rtk rg "<pattern>" .` (the trailing `.` is required to avoid stdin stalls).
17
+ - **POSIX Search/Listing**: Use `rtk ls <path>` and `rtk grep "<pattern>"` or `rtk rg "<pattern>"`.
17
18
 
18
19
  ## Available MCP Tools
19
20
  - `check_context_health`: Diagnoses transcript turn counts, byte payload, and polling loops. Accepts `transcriptPath` or `conversationId`.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agy-context-saver",
3
- "version": "1.6.1",
3
+ "version": "1.7.0",
4
4
  "description": "Universal Model Context Protocol (MCP) server & lifecycle governor purpose-built for Google Antigravity",
5
5
  "main": "mcp/index.js",
6
6
  "bin": {
package/plugin.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "agy-context-saver",
3
3
  "displayName": "Antigravity Context Shield & Governor",
4
- "version": "1.6.1",
4
+ "version": "1.7.0",
5
5
  "description": "Deterministic background polling governor, RTK terminal optimizer, and subagent context preservation shield for Antigravity.",
6
6
  "logo": "assets/logo.svg",
7
7
  "suggestedPrompts": [
package/rules/AGENTS.md CHANGED
@@ -32,8 +32,8 @@
32
32
 
33
33
  ## Layer 2: Transparent Shell Execution & Codebase Inspection via RTK
34
34
  - **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.
35
- - **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`:
36
- - `rtk read <file>`: Read file with intelligent token filtering and line ranges.
35
+ - **Canonical Codebase Inspection**: Unbounded full-file reads and unoptimized search tools (`grep_search`, `find_by_name`, `list_dir`) are blocked for workspace files. Use bounded slices and RTK's canonical CLI interfaces:
36
+ - `view_file` with bounded slices (`StartLine` and `EndLine`, max 150 lines): **Preferred for reading files**—preserves 1-indexed line numbers and avoids terminal stdout truncation. Pair with `waymark_ask` to locate exact symbol line ranges first.
37
37
  - `rtk find <path>`: Compact file search tree and directory listings (cross-platform, works on Windows & POSIX).
38
38
  - Search commands by platform:
39
39
  - **Windows**: Use `rtk rg "<pattern>" .` (explicit target `.` is required to prevent stdin pipe hanging) or `rg "<pattern>" .`.
@@ -43,7 +43,7 @@
43
43
  - **POSIX / Linux / macOS**: Use `rtk ls <path>` or `rtk tree`.
44
44
  - `rtk err <cmd>`: Run command and show only errors/warnings.
45
45
  - `rtk summary <cmd>`: Run command and produce a 2-line heuristic summary.
46
- - **Antigravity Special Files Safe Harbor**: Documented Antigravity special files (`SKILL.md`, brain artifacts, `.gemini/config/` configs) are permitted via `view_file`.
46
+ - **Antigravity Special Files Safe Harbor**: Documented Antigravity special files (`SKILL.md`, brain artifacts, `.gemini/config/` configs) are permitted via `view_file` without slice bounds.
47
47
  - **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`.
48
48
 
49
49
  ---
@@ -57,7 +57,7 @@
57
57
  - **Subagent Delegation for Deep Audits**: When a comprehensive repository-wide test audit is required, delegate the sweep to a subagent (`invoke_subagent`) to keep the main thread responsive.
58
58
  - **Subagent Delegation & Pointer-Over-Wire (POW)**:
59
59
  - Delegate heavy multi-file exploration, deep research, and repo sweeps to subagents (`invoke_subagent`). Subagents absorb intermediate steps and return high-signal summaries.
60
- - **POW Protocol**: Payloads or deliverables exceeding 1 KB must be written to workspace scratch files (e.g. `scratch/<task>_findings.md` or artifacts). Transmit **ONLY** an Executive Summary (3–5 sentences), a Scoreboard / Verdict table, and a clickable file link (`file:///...`) in `send_message` to prevent transport truncation and parent context bloat.
60
+ - **POW Protocol & `write_to_file` Isolation**: Payloads or deliverables exceeding 1 KB must be written either to workspace scratch files (`<workspace>/scratch/<task>_findings.md` with `ArtifactMetadata` **omitted**) or to the **subagent's own** `<Artifact Directory Path>/scratch/<task>_findings.md` (with `ArtifactMetadata: { Summary, UserFacing: false, RequestFeedback: false }`). Never instruct a subagent to `write_to_file` into the parent conversation's `brain/<parent-uuid>/` directory, as Antigravity enforces per-conversation `brain/<uuid>` write isolation. Transmit **ONLY** an Executive Summary (3–5 sentences), a Scoreboard / Verdict table, and a clickable file link (`file:///...`) in `send_message` to prevent transport truncation and parent context bloat.
61
61
  - **Benchmark / Evaluator Integrity**: Never mutate benchmark definitions, prompt templates, or scoring artifacts during an active evaluation without explicit user confirmation.
62
62
 
63
63
  ---
@@ -18,9 +18,9 @@ Agy-Context-Saver and RTK protect session transcript health and LLM attention by
18
18
 
19
19
  ## Codebase Inspection via RTK
20
20
 
21
- Native Antigravity file and search tools (`view_file`, `grep_search`, `find_by_name`, `list_dir`) bypass token compression and are hard-routed to RTK shell commands:
21
+ Unbounded full-file `view_file` calls and unoptimized search tools (`grep_search`, `find_by_name`, `list_dir`) bypass token compression and are guarded:
22
22
 
23
- - `rtk read <file>`: Reads file with intelligent token filtering and line ranges.
23
+ - `view_file` with bounded slices (`StartLine` and `EndLine`, max 150 lines): **Preferred for reading files**—returns exact 1-indexed line numbers without terminal stdout truncation.
24
24
  - `rtk find <path>`: Compact file search tree and directory listings (cross-platform, works on Windows & POSIX).
25
25
  - Search commands by platform:
26
26
  - **Windows**: Use `rtk rg "<pattern>" .` (explicit target `.` is required to avoid child process stdin pipe stalls) or `rg "<pattern>" .`.
@@ -31,7 +31,7 @@ Native Antigravity file and search tools (`view_file`, `grep_search`, `find_by_n
31
31
  - `rtk err <cmd>`: Runs command and displays only errors/warnings.
32
32
  - `rtk summary <cmd>`: Runs command and produces a 2-line technical summary.
33
33
 
34
- *Safe Harbor*: Documented Antigravity special files (`SKILL.md`, brain artifacts, `.gemini/config/`) may be viewed directly via `view_file`.
34
+ *Safe Harbor*: Documented Antigravity special files (`SKILL.md`, brain artifacts, `.gemini/config/`) may be viewed directly via `view_file` without slice bounds.
35
35
 
36
36
  ---
37
37