@ivannikov-pro/ai-context-surgeon 1.0.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.
Files changed (87) hide show
  1. package/LICENSE +22 -0
  2. package/README.md +372 -0
  3. package/bin/catalog.js +153 -0
  4. package/bin/cli.js +380 -0
  5. package/bin/installer.js +135 -0
  6. package/bin/prompts.js +371 -0
  7. package/checklists/phase-1-analysis.md +58 -0
  8. package/checklists/phase-2-planning.md +67 -0
  9. package/checklists/phase-3-restructuring.md +77 -0
  10. package/checklists/phase-4-documentation.md +111 -0
  11. package/checklists/phase-5-validation.md +91 -0
  12. package/examples/before-after/README.md +139 -0
  13. package/examples/ideal-monorepo/README.md +127 -0
  14. package/knowledge/agent-context-system/artifacts/guide.md +183 -0
  15. package/knowledge/agent-context-system/artifacts/knowledge.md +177 -0
  16. package/knowledge/agent-context-system/artifacts/skills.md +101 -0
  17. package/knowledge/agent-context-system/artifacts/workflows.md +143 -0
  18. package/knowledge/agent-context-system/metadata.json +26 -0
  19. package/knowledge/agent-context-system/timestamps.json +5 -0
  20. package/knowledge/agent-vulnerabilities/LICENSE +21 -0
  21. package/knowledge/agent-vulnerabilities/artifacts/stealth_injection.md +110 -0
  22. package/knowledge/agent-vulnerabilities/artifacts/vulnerabilities.md +232 -0
  23. package/knowledge/agent-vulnerabilities/metadata.json +14 -0
  24. package/knowledge/agent-vulnerabilities/timestamps.json +5 -0
  25. package/knowledge/power-words-dictionary/LICENSE +21 -0
  26. package/knowledge/power-words-dictionary/artifacts/dictionary.md +231 -0
  27. package/knowledge/power-words-dictionary/artifacts/prompt_amplifier.py +381 -0
  28. package/knowledge/power-words-dictionary/metadata.json +14 -0
  29. package/knowledge/power-words-dictionary/timestamps.json +5 -0
  30. package/package.json +77 -0
  31. package/roles/README.md +81 -0
  32. package/roles/architect.md +203 -0
  33. package/roles/inspector.md +232 -0
  34. package/roles/librarian.md +176 -0
  35. package/roles/scout.md +169 -0
  36. package/roles/surgeon.md +172 -0
  37. package/roles/tuner.md +204 -0
  38. package/skills/annotate-jsdoc/SKILL.md +262 -0
  39. package/skills/prompt-engineering/LICENSE +21 -0
  40. package/skills/prompt-engineering/SKILL.md +235 -0
  41. package/skills/prompt-engineering/scripts/extract_instructions.py +416 -0
  42. package/skills/prompt-engineering/scripts/prompt_amplifier.py +381 -0
  43. package/skills/prompt-engineering/scripts/prompt_diff_tracker.py +281 -0
  44. package/skills/prompt-engineering/scripts/prompt_dna_analyzer.py +692 -0
  45. package/skills/prompt-engineering/scripts/templates/code_review.md +47 -0
  46. package/skills/prompt-engineering/scripts/templates/dump_extraction.md +59 -0
  47. package/skills/prompt-engineering/scripts/templates/multi_agent_orchestration.md +100 -0
  48. package/skills/prompt-engineering/scripts/templates/prompt_audit.md +106 -0
  49. package/skills/prompt-engineering/scripts/templates/stealth_injection.md +110 -0
  50. package/skills/prompt-engineering/scripts/templates/task_automation.md +87 -0
  51. package/skills/prompt-engineering/workflows/amplify.md +36 -0
  52. package/skills/prompt-engineering/workflows/audit.md +55 -0
  53. package/skills/prompt-engineering/workflows/context-dump.md +90 -0
  54. package/skills/prompt-engineering/workflows/diff.md +44 -0
  55. package/strategy/bash-guide.md +134 -0
  56. package/strategy/context-exclusion.md +220 -0
  57. package/strategy/context-weight-theory.md +49 -0
  58. package/strategy/file-navigation-header.md +562 -0
  59. package/strategy/jsdoc-guide.md +596 -0
  60. package/strategy/monorepo_strategy.md +726 -0
  61. package/strategy/package-json-guide.md +541 -0
  62. package/templates/AGENTS.md.template +148 -0
  63. package/templates/antigravityignore.template +64 -0
  64. package/templates/cursorrules.template +7 -0
  65. package/templates/knowledge-item.template +44 -0
  66. package/templates/package-json-ideal.template +26 -0
  67. package/templates/package-readme.template +45 -0
  68. package/templates/publish-meta.template +34 -0
  69. package/templates/skill.template +50 -0
  70. package/templates/workflow.template +33 -0
  71. package/tools/analyze-package-json.sh +213 -0
  72. package/tools/analyze-structure.sh +101 -0
  73. package/tools/audit-jsdoc.sh +176 -0
  74. package/tools/check-fnh-freshness.sh +74 -0
  75. package/tools/detect-circular-deps.sh +147 -0
  76. package/tools/detect-god-files.sh +71 -0
  77. package/tools/enforce-god-files.sh +112 -0
  78. package/tools/enrich-package-json.js +311 -0
  79. package/tools/generate-jsdoc-headers.sh +109 -0
  80. package/tools/generate-source-map.sh +71 -0
  81. package/tools/lint-imports.sh +123 -0
  82. package/tools/measure-context-cost.sh +206 -0
  83. package/tools/scan-fnh.sh +174 -0
  84. package/tools/shared/config.sh +53 -0
  85. package/tools/validate-context-hygiene.sh +52 -0
  86. package/tools/validate-context-weight.sh +100 -0
  87. package/tools/validate-naming.sh +98 -0
@@ -0,0 +1,91 @@
1
+ <!-- FNH: Checklist — Phase 5 Validation | ROLE: Inspector | MODEL: Gemini 3.1 Pro -->
2
+
3
+ # Phase 5: Validation — Checklist
4
+
5
+ > **Role:** Inspector | **Model:** Gemini 3.1 Pro (High) | **Mode:** Planning | **Goal:** Verify everything works and measure improvement | **SECTIONS:** Linting, Freshness, Context Cost, Self-Check | **DEPS:** Phase 4
6
+
7
+ ## Pre-flight
8
+
9
+ - [ ] Read `roles/inspector.md` for full instructions
10
+ - [ ] Ensure ALL previous phases completed
11
+ - [ ] This phase is read-only + run commands
12
+
13
+ ## Build & Tests
14
+
15
+ - [ ] Full build: `{{BUILD_COMMAND}}` → must pass
16
+ - [ ] Full tests: `{{TEST_COMMAND}}` → must pass (≥80%)
17
+ - [ ] Type check: `tsc --noEmit` → no errors
18
+ - [ ] Lint: `{{LINT_COMMAND}}` → no errors (warnings OK)
19
+
20
+ ## Structure Validation
21
+
22
+ - [ ] Run `tools/analyze-structure.sh {{TARGET_REPO_PATH}}`
23
+ - [ ] Every package has `README.md`
24
+ - [ ] Every package has `src/index.ts`
25
+ - [ ] Every package has `src/types.ts` or `src/types/`
26
+ - [ ] No god-files remain: `tools/detect-god-files.sh {{TARGET_REPO_PATH}}`
27
+ - [ ] No circular dependencies: `tools/detect-circular-deps.sh {{TARGET_REPO_PATH}}`
28
+ - [ ] No direct internal imports (cross-package)
29
+ - [ ] All `.antigravityignore` configurations are correct
30
+
31
+ ## Documentation Validation
32
+
33
+ - [ ] `.agents/AGENTS.md` exists and has key rules
34
+ - [ ] AGENTS.md has "Read README first" rule
35
+ - [ ] AGENTS.md has "Stay within package" rule
36
+ - [ ] AGENTS.md has English-only rule
37
+ - [ ] AGENTS.md has build/test commands
38
+ - [ ] Knowledge Items exist (≥1)
39
+ - [ ] Knowledge Items have `metadata.json`
40
+ - [ ] Skills exist (≥1) with `SKILL.md`
41
+ - [ ] Workflows exist (≥1)
42
+ - [ ] READMEs have Source Structure sections
43
+
44
+ ## FNH / JSDoc Validation
45
+
46
+ - [ ] ALL source files have FNH headers
47
+ - [ ] FNH headers have real descriptions (not TODO)
48
+ - [ ] ALL FNH headers are in English
49
+ - [ ] No verbose tags (no @author, @version)
50
+
51
+ ## Context Cost Measurement
52
+
53
+ - [ ] Run `tools/measure-context-cost.sh` for each major package
54
+ - [ ] Record "Before" metrics (from scout-report.md)
55
+ - [ ] Record "After" metrics
56
+ - [ ] Calculate reduction percentage
57
+ - [ ] Target: ≥70% reduction
58
+
59
+ ## Agent Smoke Test
60
+
61
+ In a **new conversation** (fresh context), ask the agent:
62
+
63
+ - [ ] "Add a new field `phone` to the User entity"
64
+ - Did agent read README first?
65
+ - How many files did agent read?
66
+ - Did agent follow AGENTS.md rules?
67
+ - Quality of result?
68
+
69
+ ## Scoring
70
+
71
+ | Category | Score (0-10) | Notes |
72
+ | --- | --- | --- |
73
+ | Structure | | |
74
+ | Documentation | | |
75
+ | Context Optimization | | |
76
+ | **Total** | **/30** | |
77
+
78
+ ### Scoring Guide
79
+
80
+ - **0-10:** 🔴 Needs re-work — go back to Architect
81
+ - **11-20:** 🟡 Acceptable but gaps — targeted fixes needed
82
+ - **21-27:** 🟢 Good — minor improvements possible
83
+ - **28-30:** ⭐ Excellent — production-ready
84
+
85
+ ## Deliverable
86
+
87
+ - [ ] `{{TARGET_REPO_PATH}}/validation-report.md` created
88
+ - [ ] All sections filled with measurements
89
+ - [ ] Context cost Before/After table
90
+ - [ ] Final score assigned
91
+ - [ ] Remaining issues listed (if any)
@@ -0,0 +1,139 @@
1
+ <!-- FNH: Examples — Before and after comparison of monorepo restructuring | SECTIONS: Case Study A, Findings | DEPS: none -->
2
+
3
+ # Before & After — ai-context-surgeon examples
4
+
5
+ > Examples of monorepo restructuring results | SECTIONS: Example 1, Example 2 | DEPS: none
6
+
7
+ ### ❌ BEFORE
8
+
9
+ ```
10
+ packages/api/src/
11
+ app.ts (150 lines)
12
+ routes.ts (1200 lines — GOD FILE)
13
+ middleware.ts (400 lines)
14
+ utils.ts (800 lines — GOD FILE)
15
+ types.ts (50 lines)
16
+ db.ts (100 lines)
17
+ auth.ts (200 lines)
18
+ validation.ts (300 lines)
19
+ logger.ts (50 lines)
20
+ errors.ts (80 lines)
21
+ ```
22
+
23
+ **Context cost:** Agent reads 10 files (~3,300 lines) = ~8K tokens just to understand the package.
24
+
25
+ **Problems:**
26
+
27
+ - `routes.ts` — 1200 lines with ALL routes for ALL domains
28
+ - `utils.ts` — 800 lines of mixed utilities
29
+ - No README, no Source Structure
30
+ - No clear domain boundaries
31
+
32
+ ### ✅ AFTER
33
+
34
+ ```
35
+ packages/api/
36
+ README.md ← Source Structure map
37
+ src/
38
+ index.ts ← App setup, exports
39
+ types.ts ← API-specific types
40
+ routes/
41
+ v1/
42
+ index.ts ← Route registration
43
+ users.ts ← /api/v1/users (120 lines)
44
+ orders.ts ← /api/v1/orders (150 lines)
45
+ products.ts ← /api/v1/products (100 lines)
46
+ auth.ts ← /api/v1/auth (80 lines)
47
+ middleware/
48
+ auth.ts ← JWT verification (60 lines)
49
+ validation.ts ← Zod middleware (40 lines)
50
+ error-handler.ts ← Error handler (50 lines)
51
+ logger.ts ← Request logging (30 lines)
52
+ validation/
53
+ user.schema.ts ← User validation (40 lines)
54
+ order.schema.ts ← Order validation (45 lines)
55
+ utils/
56
+ response.ts ← Response formatting (30 lines)
57
+ pagination.ts ← Pagination helpers (25 lines)
58
+ ```
59
+
60
+ **Context cost:** Agent reads README (~300 tokens) + 1 target file (~200 tokens) = ~500 tokens.
61
+
62
+ **Improvement:** 8K → 500 tokens = **94% reduction**
63
+
64
+ ---
65
+
66
+ ## Example 2: Mixed Monorepo Root
67
+
68
+ ### ❌ BEFORE
69
+
70
+ ```
71
+ project/
72
+ src/
73
+ (87 files all in one directory)
74
+ UserController.ts
75
+ UserService.ts
76
+ UserRepository.ts
77
+ OrderController.ts
78
+ OrderService.ts
79
+ ... (82 more files)
80
+ package.json
81
+ tsconfig.json
82
+ (no README, no AGENTS.md, no docs)
83
+ ```
84
+
85
+ **Problems:**
86
+
87
+ - 87 files in one flat directory — impossible to navigate
88
+ - No packages — everything coupled
89
+ - No README — agent has no map
90
+ - No AGENTS.md — no rules
91
+ - No Knowledge Items — agent has no memory
92
+
93
+ ### ✅ AFTER
94
+
95
+ ```
96
+ project/
97
+ .agents/
98
+ AGENTS.md ← Navigation rules
99
+ knowledge/
100
+ database-schema/ ← DB knowledge
101
+ api-conventions/ ← API patterns
102
+ skills/
103
+ create-endpoint/ ← How to add endpoints
104
+ workflows/
105
+ test.md ← /test workflow
106
+ packages/
107
+ core/
108
+ README.md ← Source Structure
109
+ src/
110
+ index.ts
111
+ types.ts
112
+ entities/ (5 files)
113
+ services/ (5 files)
114
+ repositories/ (5 files)
115
+ api/
116
+ README.md
117
+ src/
118
+ index.ts
119
+ types.ts
120
+ routes/ (8 files)
121
+ middleware/ (4 files)
122
+ validation/ (5 files)
123
+ shared/
124
+ README.md
125
+ src/
126
+ index.ts
127
+ types.ts
128
+ utils/ (6 files)
129
+ README.md ← Architecture map
130
+ package.json
131
+ turbo.json
132
+ ```
133
+
134
+ **Improvement:**
135
+
136
+ - 87 files in one dir → 3 packages, max 15 files each
137
+ - No docs → README + AGENTS.md + KI + Skills + Workflows
138
+ - Context cost: from ~25K tokens down to ~1.5K tokens per task
139
+ - **94% reduction**
@@ -0,0 +1,127 @@
1
+ <!-- FNH: Examples — Ideal monorepo structure reference | SECTIONS: Directory Map, Core Standards | DEPS: none -->
2
+
3
+ # Ideal Monorepo Structure — Reference
4
+
5
+ > Guide: Perfectly optimized monorepo structure after ai-context-surgeon treatment | SECTIONS: Root Structure, Package Structure, Metadata | DEPS: none
6
+
7
+ ```
8
+ project-root/
9
+
10
+ ├── .agents/ ← 🧠 AI Agent Configuration
11
+ │ ├── AGENTS.md ← Rules (HIGHEST PRIORITY)
12
+ │ ├── knowledge/ ← Persistent memory
13
+ │ │ ├── database-schema/
14
+ │ │ │ ├── metadata.json ← title, summary
15
+ │ │ │ └── artifacts/
16
+ │ │ │ └── schema.md ← Tables, relations, indexes
17
+ │ │ ├── api-conventions/
18
+ │ │ │ ├── metadata.json
19
+ │ │ │ └── artifacts/
20
+ │ │ │ └── conventions.md ← Response format, error codes
21
+ │ │ └── auth-flow/
22
+ │ │ ├── metadata.json
23
+ │ │ └── artifacts/
24
+ │ │ └── flow.md ← JWT lifecycle, roles
25
+ │ ├── skills/
26
+ │ │ ├── create-endpoint/
27
+ │ │ │ └── SKILL.md ← How to add a new API endpoint
28
+ │ │ └── create-package/
29
+ │ │ └── SKILL.md ← How to add a new package
30
+ │ └── workflows/
31
+ │ ├── test.md ← /test — run package tests
32
+ │ ├── build.md ← /build — build verification
33
+ │ └── deploy.md ← /deploy — deploy procedure
34
+
35
+ ├── packages/ ← 📦 Isolated Packages
36
+ │ ├── shared/ ← Shared types & utilities
37
+ │ │ ├── README.md ← Source Structure + API
38
+ │ │ ├── package.json ← @project/shared
39
+ │ │ ├── tsconfig.json ← Standalone config
40
+ │ │ └── src/
41
+ │ │ ├── index.ts ← Public API (re-exports)
42
+ │ │ ├── types.ts ← All shared type contracts
43
+ │ │ ├── constants.ts ← Shared constants
44
+ │ │ └── utils/
45
+ │ │ ├── string.ts ← String utilities
46
+ │ │ └── date.ts ← Date utilities
47
+ │ │
48
+ │ ├── core/ ← Domain logic
49
+ │ │ ├── README.md ← Source Structure + API
50
+ │ │ ├── package.json ← @project/core
51
+ │ │ ├── tsconfig.json
52
+ │ │ └── src/
53
+ │ │ ├── index.ts ← Public API
54
+ │ │ ├── types.ts ← Core type contracts
55
+ │ │ ├── entities/
56
+ │ │ │ ├── user.ts ← User entity
57
+ │ │ │ └── order.ts ← Order entity
58
+ │ │ ├── services/
59
+ │ │ │ ├── user.service.ts ← User business logic
60
+ │ │ │ └── order.service.ts ← Order business logic
61
+ │ │ └── repositories/
62
+ │ │ ├── user.repository.ts ← User data access
63
+ │ │ └── order.repository.ts ← Order data access
64
+ │ │
65
+ │ └── api/ ← REST API
66
+ │ ├── README.md ← Source Structure + API
67
+ │ ├── package.json ← @project/api
68
+ │ ├── tsconfig.json
69
+ │ └── src/
70
+ │ ├── index.ts ← App setup, server start
71
+ │ ├── types.ts ← API-specific types
72
+ │ ├── routes/
73
+ │ │ └── v1/
74
+ │ │ ├── index.ts ← Route registration
75
+ │ │ ├── users.ts ← /api/v1/users
76
+ │ │ └── orders.ts ← /api/v1/orders
77
+ │ ├── middleware/
78
+ │ │ ├── auth.ts ← JWT verification
79
+ │ │ ├── validation.ts ← Zod schema middleware
80
+ │ │ └── error-handler.ts ← Global error handler
81
+ │ └── validation/
82
+ │ ├── user.schema.ts ← User input schemas
83
+ │ └── order.schema.ts ← Order input schemas
84
+
85
+ ├── apps/ ← 🚀 Deployable Applications
86
+ │ └── dashboard/
87
+ │ ├── README.md
88
+ │ ├── package.json
89
+ │ └── src/
90
+
91
+ ├── README.md ← 📋 Project overview + architecture map
92
+ ├── package.json ← Root manifest
93
+ ├── turbo.json ← Build pipeline
94
+ ├── tsconfig.json ← Root TypeScript config
95
+ └── .gitignore
96
+ ```
97
+
98
+ ## Key Properties
99
+
100
+ | Property | Value |
101
+ | --- | --- |
102
+ | Every package has `README.md` | ✅ |
103
+ | Every package has `src/index.ts` | ✅ |
104
+ | Every package has `src/types.ts` | ✅ |
105
+ | No god-files (>500 lines) | ✅ |
106
+ | No circular dependencies | ✅ |
107
+ | AGENTS.md with navigation rules | ✅ |
108
+ | Knowledge Items for stable knowledge | ✅ |
109
+ | Skills for recurring tasks | ✅ |
110
+ | Workflows for routine procedures | ✅ |
111
+ | Consistent naming (kebab-case files) | ✅ |
112
+ | Dependency direction enforced | ✅ |
113
+
114
+ ## Context Cost Estimate
115
+
116
+ ```
117
+ Agent needs to add a new /api/v1/products endpoint:
118
+
119
+ 1. Read packages/api/README.md → ~300 tokens (knows structure)
120
+ 2. Read packages/api/src/routes/v1/users.ts → ~200 tokens (pattern reference)
121
+ 3. Read packages/core/src/types.ts → ~150 tokens (type contracts)
122
+ ─────────────────────────────────────────
123
+ Total: ~650 tokens to understand everything needed
124
+
125
+ Without this structure: ~6,000+ tokens of blind scanning
126
+ Savings: 89%
127
+ ```
@@ -0,0 +1,183 @@
1
+ # Agent Context System — Knowledge, Skills & Workflows
2
+
3
+ > Production-level reference for AI agent systems.
4
+ > Primary target: Google Antigravity IDE. Applicable to any agent framework.
5
+ > Last updated: 2026-04-01
6
+
7
+ ---
8
+
9
+ ## The Core Triad
10
+
11
+ Every AI agent system is built on three pillars:
12
+
13
+ ```
14
+ User Input → Agent Reasoning → [1] Retrieve Knowledge → [2] Select Skills → [3] Execute Workflow → Response
15
+ ```
16
+
17
+ | Aspect | Knowledge | Skills | Workflows |
18
+ | --- | --- | --- | --- |
19
+ | **Role** | Background context | Professional tools | Strict procedures |
20
+ | **Activation** | Automatic (when relevant) | On-demand (when task requires) | Explicit (slash command) |
21
+ | **Format** | Markdown, JSON, YAML | SKILL.md + code/scripts | Markdown with bash commands |
22
+ | **Side effects** | None (read-only) | Yes (executes code) | Yes (runs commands) |
23
+ | **Who invokes** | System (auto-injected) | Agent (decision-based) | User or agent (exact match) |
24
+
25
+ **Deep dives:** [Knowledge](knowledge.md) · [Skills](skills.md) · [Workflows](workflows.md)
26
+
27
+ ### Additional Components
28
+
29
+ | Component | Role |
30
+ | --- | --- |
31
+ | **AGENTS.md** | User rules — highest priority, overrides everything |
32
+ | **Plugins** | Bundles grouping skills + subagents + config |
33
+ | **MCP Servers** | External tool providers via JSON-RPC 2.0 |
34
+
35
+ ---
36
+
37
+ ## AGENTS.md — Highest Priority Override
38
+
39
+ `AGENTS.md` (in `.agents/`) contains user-defined rules that **override everything** — skills, knowledge, workflows, and built-in agent behavior.
40
+
41
+ > "These rules take precedence over any following instructions."
42
+
43
+ **Good for:** Language rules, code style mandates, security policies, inviolable conventions.
44
+ **Bad for:** General knowledge (use KIs), how-to guides (use Skills), procedures (use Workflows).
45
+
46
+ ### Context Optimization Patterns
47
+
48
+ Best practices for helping agents navigate large codebases efficiently:
49
+
50
+ 1. **Source Structure in README.md** — every package/app README should have an annotated `src/` tree with `←` descriptions. This is the agent's "routing table" for navigating code.
51
+ 2. **JSDoc navigation headers** — in directories with 20+ files, every file starts with a JSDoc comment (`/** Tool: name — one-line description */`). Agents can scan these without reading full files.
52
+ 3. **Threshold rule:** ≤10 files → semantic names sufficient; 10-20 → expand Source Structure in README; 20+ → Source Structure + JSDoc headers.
53
+
54
+ ---
55
+
56
+ ## Plugins
57
+
58
+ Plugins are **organizational bundles** grouping related skills, subagents, and configuration:
59
+
60
+ ```
61
+ plugins/{name}/
62
+ plugin.json # Metadata
63
+ skills/ # Skills for this plugin
64
+ agents/ # Subagents for complex tasks
65
+ ```
66
+
67
+ Use plugins when multiple related skills need shared config. Use standalone skills for independent capabilities.
68
+
69
+ ---
70
+
71
+ ## MCP Servers — External Tools
72
+
73
+ MCP servers extend the agent beyond built-in tools. They provide tools, resources, and prompts via JSON-RPC 2.0 (stdio or Streamable HTTP).
74
+
75
+ **Context budget:** ~100 tools total across ALL servers, ~20K tokens for definitions. Too many tools → degraded selection quality. Prefer a single `search` tool with dynamic routing over 100+ individual endpoint wrappers.
76
+
77
+ ---
78
+
79
+ ## Conversation Logs — Raw Memory
80
+
81
+ Beyond KIs, the agent can access raw logs from past conversations:
82
+
83
+ ```
84
+ ~/.gemini/antigravity/brain/{conversation-id}/.system_generated/logs/overview.txt
85
+ ```
86
+
87
+ **Priority:** KIs first → Conversation Logs → Fresh research.
88
+
89
+ Use logs only when: user references a past conversation, a KI is insufficient, or you have a specific Conversation ID.
90
+
91
+ ---
92
+
93
+ ## Planning Mode
94
+
95
+ The agent's decision-making framework that determines whether to plan before acting:
96
+
97
+ ```
98
+ Phase 1: Research → Read knowledge, explore codebase (NO code changes)
99
+ Phase 2: Plan → Create implementation_plan.md
100
+ Phase 3: Approve → User reviews and approves
101
+ Phase 4: Execute → Follow plan, track in task.md
102
+ Phase 5: Verify → Run tests, create walkthrough.md
103
+ ```
104
+
105
+ **Plan required for:** Major architecture changes, extensive research, significant ambiguity.
106
+ **No plan for:** Simple questions, trivial fixes, minor follow-ups.
107
+
108
+ Artifacts live in: `~/.gemini/antigravity/brain/{conversation-id}/`
109
+
110
+ ---
111
+
112
+ ## How Components Interact
113
+
114
+ ### Example 1: "Create a new MCP server"
115
+
116
+ 1. **Knowledge** → checks KIs for tool limits, conventions
117
+ 2. **Skill** → loads `mcp-server-creation` SKILL.md
118
+ 3. **Workflow** → follows `mcp-dev.md` for IDE restart cycle
119
+
120
+ ### Example 2: User runs `/deploy`
121
+
122
+ 1. **Workflow** → activates immediately, follows steps
123
+ 2. **Knowledge** → checks KI for deployment conventions
124
+ 3. **Skills** → references Docker skill if needed
125
+
126
+ ### Example 3: "Fix the login bug"
127
+
128
+ 1. **Knowledge** → checks KIs for known bugs, auth patterns
129
+ 2. No specific skill or workflow needed — ad-hoc debugging
130
+
131
+ ---
132
+
133
+ ## Antigravity System Prompt Integration
134
+
135
+ | Section | Provides |
136
+ | --- | --- |
137
+ | `<skills>` | Available skills list (name + description + path) |
138
+ | `<persistent_context>` | KI system rules + KI summaries |
139
+ | `<workflows>` | Workflow discovery + slash command mapping |
140
+ | `<user_rules>` | AGENTS.md content (highest priority) |
141
+ | `<mcp_servers>` | MCP server definitions |
142
+
143
+ ---
144
+
145
+ ## File Structure Reference
146
+
147
+ ```
148
+ project-root/
149
+ .agents/
150
+ AGENTS.md # User rules (HIGHEST PRIORITY)
151
+ knowledge/ # Per-project KIs
152
+ {ki-name}/
153
+ metadata.json
154
+ artifacts/{content}.md
155
+ skills/ # Per-project skills
156
+ {skill-name}/
157
+ SKILL.md
158
+ assets/
159
+ workflows/
160
+ workflows/ # Slash commands
161
+ {workflow-name}.md
162
+
163
+ ~/.gemini/antigravity/
164
+ knowledge/ # Global KIs
165
+ skills/ # Global skills
166
+ settings.json # MCP server configs
167
+ brain/{conversation-id}/ # Logs & artifacts
168
+ .system_generated/logs/overview.txt
169
+ implementation_plan.md
170
+ task.md
171
+ walkthrough.md
172
+ ```
173
+
174
+ ---
175
+
176
+ ## Key Insight
177
+
178
+ > **AGENTS.md** sets the law — inviolable rules.
179
+ > **Knowledge** makes an agent _useful_ — it understands the domain.
180
+ > **Skills** make it _competent_ — it knows the right tools.
181
+ > **Workflows** make it _reliable_ — consistent execution.
182
+ > **MCP Servers** make it _extensible_ — connected to the world.
183
+ > **Planning Mode** makes it _disciplined_ — thinks before acting.