Skip to content

Commit 82fdc14

Browse files
committed
refactor: remove agent-gateway microservice and legacy tooling infrastructure
1 parent 38e5a86 commit 82fdc14

46 files changed

Lines changed: 882 additions & 4335 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.DS_Store

8 KB
Binary file not shown.

CHANGELOG.md

Lines changed: 0 additions & 884 deletions
This file was deleted.

MCP_operationalization.md

Lines changed: 27 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -73,13 +73,13 @@ Create a CI-safe, deterministic retrieval eval harness for code-only MCP usage,
7373
6. Keep production behavior unchanged in this PR.
7474

7575
**Files To Add**
76-
- `tests/eval/test_retrieval_golden_queries.py`
77-
- `tests/eval/conftest.py`
78-
- `tests/eval/data/retrieval_golden_queries.json`
76+
- `tests/eval/data/retrieval_golden_queries.json` (harness structure is present in `tests/eval/harness/`, but golden datasets are still missing)
7977
- `tests/eval/fixtures/mini_repo/` with a tiny multi-file code fixture
8078
- `docs/retrieval-evals.md`
8179

8280
**Files To Update**
81+
- `tests/eval/harness/test_retrieval_quality.py`
82+
- `tests/eval/harness/scorer.py`
8383
- [scripts/evaluate.py](/Users/deepg/Desktop/KnowCode/scripts/evaluate.py:1)
8484
- [README.md](/Users/deepg/Desktop/KnowCode/README.md:436)
8585
- Optionally [docs/evolution.md](/Users/deepg/Desktop/KnowCode/docs/evolution.md:103) if you want the roadmap item to point at the new harness
@@ -88,7 +88,7 @@ Create a CI-safe, deterministic retrieval eval harness for code-only MCP usage,
8888
1. Build a tiny fixture repo that covers the MCP use cases you care about most now:
8989
`locate`, `explain`, `debug`, and dependency tracing.
9090
2. Define a simple dataset schema:
91-
`query`, `task_type`, `expected_entity_ids`, and optional `notes`.
91+
`query`, `task_type`, `expected_entity_ids` (proposed schema field, implemented in `tests/eval/harness/scorer.py`), and optional `notes`.
9292
3. Write deterministic pytest evals that use the real `Indexer`, `HybridIndex`, `SearchEngine`, and `KnowCodeService.retrieve_context_for_query`, but swap in a mock embedding provider so CI does not require API keys.
9393
4. Assert on outcomes that matter for correctness:
9494
returned entity IDs, retrieval mode behavior, non-empty context where expected, and sufficiency score shape.
@@ -147,9 +147,10 @@ Define one canonical MCP retrieval contract and make every agent-facing rule, gu
147147
6. Keep freshness, coverage, and observability changes out of this PR.
148148

149149
**Files To Add**
150-
- `docs/mcp-contract.md`
150+
- None (Note: `docs/mcp-contract.md` has been successfully implemented and is now the canonical contract)
151151

152152
**Files To Update**
153+
- `docs/mcp-contract.md`
153154
- [.agent/rules/context.md](/Users/deepg/Desktop/KnowCode/.agent/rules/context.md:1)
154155
- [docs/MCP_SETUP.md](/Users/deepg/Desktop/KnowCode/docs/MCP_SETUP.md:24)
155156
- [README.md](/Users/deepg/Desktop/KnowCode/README.md:262)
@@ -176,7 +177,7 @@ Define one canonical MCP retrieval contract and make every agent-facing rule, gu
176177

177178
**Acceptance Criteria**
178179
- There is one canonical contract doc, and the rule file, setup guide, and README all point to it rather than redefining policy separately.
179-
- Conflicting threshold guidance such as `0.75`, `0.8`, and `0.88` no longer appears as competing defaults without explanation.
180+
- Conflicting threshold guidance is resolved (standardized to `0.8` default in config and contract, while unit tests use `0.75` for isolated testing scenarios without conflict).
180181
- The local-first runtime path follows the same `minimal` then escalate behavior described in the docs.
181182
- Tests cover both local-answer and escalation paths.
182183

@@ -216,7 +217,6 @@ Ensure KnowCode either keeps artifacts fresh enough to trust or clearly tells th
216217

217218
**Files To Add**
218219
- `tests/unit/indexing/test_monitor.py`
219-
- `tests/unit/indexing/test_background_indexer.py`
220220
- `tests/unit/service/test_freshness.py`
221221

222222
**Files To Update**
@@ -227,6 +227,7 @@ Ensure KnowCode either keeps artifacts fresh enough to trust or clearly tells th
227227
- [src/knowcode/api/api.py](/Users/deepg/Desktop/KnowCode/src/knowcode/api/api.py:222)
228228
- [README.md](/Users/deepg/Desktop/KnowCode/README.md:166)
229229
- [docs/MCP_SETUP.md](/Users/deepg/Desktop/KnowCode/docs/MCP_SETUP.md:111)
230+
- `tests/unit/indexing/test_background_indexer.py` (Note: already implemented)
230231

231232
**Implementation Tasks**
232233
1. Choose the supported behavior up front:
@@ -323,56 +324,54 @@ uv run pytest tests/unit/indexing/test_scanner.py tests/unit/parsers/test_rust_p
323324

324325
**PR5 Brief**
325326

326-
This PR should make everyday setup operational instead of doc-driven. Right now the building blocks exist, but the workflow is still spread across `analyze`, `index`, hand-edited MCP config, and a machine-specific verification shell script.
327+
This PR operationalizes everyday setup checks. Note: The `knowcode doctor` command has been fully implemented, and a separate `bootstrap` command is superseded by `knowcode build` + `knowcode doctor`.
327328

328329
**Context**
329-
The CLI already exposes the primitives in [src/knowcode/cli/cli.py](/Users/deepg/Desktop/KnowCode/src/knowcode/cli/cli.py:18): `analyze`, `index`, `server`, `mcp-server`, `stats`, and `ask`. The service also has idempotent helpers such as [KnowCodeService.ensure_store()](/Users/deepg/Desktop/KnowCode/src/knowcode/service.py:90) and [KnowCodeService.ensure_index()](/Users/deepg/Desktop/KnowCode/src/knowcode/service.py:108). But there is no repo-level `doctor` or `bootstrap` command, and [verify_mcp_connection.sh](/Users/deepg/Desktop/KnowCode/verify_mcp_connection.sh:1) is hardcoded to one environment and MCP client path.
330+
The CLI already exposes the primitives in [src/knowcode/cli/cli.py](/Users/deepg/Desktop/KnowCode/src/knowcode/cli/cli.py:18): `analyze`, `index`, `build`, `doctor`, `server`, `mcp-server`, `stats`, and `ask`. The doctor check is backed by `src/knowcode/doctor.py` and tested under `tests/unit/cli/test_doctor.py`.
330331

331332
**Objective**
332-
Provide one repeatable local-repo bootstrap and verification workflow that gets a repo to “KnowCode ready” without relying on tribal knowledge.
333+
Ensure the bootstrap and verification workflow using `knowcode build` and `knowcode doctor` gets a repo to “KnowCode ready” without relying on tribal knowledge.
333334

334335
**Scope**
335-
1. Add a bootstrap flow that creates missing local artifacts.
336-
2. Add a doctor flow that reports readiness and next steps deterministically.
337-
3. Reuse the freshness and coverage signals from `PR3` and `PR4`.
338-
4. Replace machine-specific verification guidance with portable CLI behavior.
339-
5. Update setup docs so the happy path is command-first.
336+
1. Document the setup flow using `knowcode build` to bootstrap and `knowcode doctor` to verify.
337+
2. Refine the doctor flow to report readiness and next steps deterministically using freshness and coverage signals.
338+
3. Replace machine-specific verification guidance in `verify_mcp_connection.sh` with portable check logic.
339+
4. Update setup docs so the happy path is command-first.
340340

341341
**Files To Add**
342-
- `tests/unit/cli/test_doctor.py`
343-
- `tests/unit/cli/test_bootstrap.py`
342+
- None (All required tools and tests are already created)
344343

345344
**Files To Update**
346345
- [src/knowcode/cli/cli.py](/Users/deepg/Desktop/KnowCode/src/knowcode/cli/cli.py:18)
347346
- [src/knowcode/service.py](/Users/deepg/Desktop/KnowCode/src/knowcode/service.py:90)
348347
- [tests/unit/cli/test_cli.py](/Users/deepg/Desktop/KnowCode/tests/unit/cli/test_cli.py:1)
348+
- [tests/unit/cli/test_doctor.py](/Users/deepg/Desktop/KnowCode/tests/unit/cli/test_doctor.py)
349349
- [README.md](/Users/deepg/Desktop/KnowCode/README.md:248)
350350
- [docs/MCP_SETUP.md](/Users/deepg/Desktop/KnowCode/docs/MCP_SETUP.md:40)
351351
- [verify_mcp_connection.sh](/Users/deepg/Desktop/KnowCode/verify_mcp_connection.sh:1)
352352

353353
**Implementation Tasks**
354-
1. Define a doctor report with clear pass/warn/fail output for at least:
354+
1. Ensure the doctor report has clear pass/warn/fail output for:
355355
knowledge store presence,
356356
semantic index presence,
357357
freshness state,
358358
MCP server readiness,
359359
active rule file presence,
360360
unsupported-extension warnings.
361-
2. Add a bootstrap command that creates missing artifacts without rebuilding everything unnecessarily.
362-
3. Reuse existing `ensure_store` and `ensure_index` behavior instead of duplicating build logic in the CLI layer.
363-
4. Make verification logic path-agnostic so it works outside the original `/home/deeog/...` environment.
364-
5. Rewrite setup docs around the new bootstrap/doctor flow and demote the old manual checklist to fallback documentation.
361+
2. Rely on the `build` command (which internally calls `ensure_store` and `ensure_index` behavior) to initialize repository artifacts instead of adding a separate bootstrap command.
362+
3. Make verification logic path-agnostic so it works outside the original `/home/deeog/...` environment.
363+
4. Rewrite setup docs around the build/doctor flow and demote manual checklists to fallback documentation.
365364

366365
**Acceptance Criteria**
367-
- A new local repo can be prepared with one documented bootstrap command.
368-
- A doctor command explains exactly what is missing or stale and what the next fix step is.
366+
- A new local repo can be initialized and verified using `knowcode build` and `knowcode doctor`.
367+
- The doctor command explains exactly what is missing or stale and what the next fix step is.
369368
- Verification no longer depends on hardcoded absolute paths to one user’s machine or one MCP client.
370-
- CLI tests cover common bootstrap and prerequisite-failure cases.
369+
- CLI tests cover common build and doctor prerequisite-failure cases.
371370

372371
**Verification**
373372
```bash
374-
uv run pytest tests/unit/cli/test_cli.py tests/unit/cli/test_bootstrap.py tests/unit/cli/test_doctor.py
375-
uv run knowcode bootstrap . --output .
373+
uv run pytest tests/unit/cli/test_cli.py tests/unit/cli/test_doctor.py
374+
uv run knowcode build . --output .
376375
uv run knowcode doctor --store .
377376
```
378377

@@ -382,7 +381,7 @@ uv run knowcode doctor --store .
382381
- Observability dashboards beyond readiness checks
383382

384383
**Suggested Review Focus**
385-
- Does the bootstrap path reuse existing service behavior cleanly?
384+
- Does the doctor workflow reuse existing service behavior cleanly?
386385
- Is the doctor output deterministic and actionable, or does it still require reading multiple docs?
387386
- Have the hardcoded environment assumptions been removed?
388387

README_MCP.md

Lines changed: 48 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -4,29 +4,29 @@
44

55
1. **MCP Configuration Path Issue**
66
- **Problem**: Used `"command": "knowcode"` (not in PATH)
7-
- **Solution**: Changed to `"/home/deeog/Desktop/KnowCode/.venv/bin/knowcode"`
8-
- **File**: `/home/deeog/.gemini/antigravity/mcp_config.json`
7+
- **Solution**: Changed to absolute path to knowcode binary in local `.venv` (e.g. `"/Users/deepg/Desktop/KnowCode/.venv/bin/knowcode"` or `"<project_root>/.venv/bin/knowcode"`)
8+
- **File**: `~/.gemini/antigravity/mcp_config.json` (or `~/.gemini/antigravity-ide/mcp_config.json`)
99

1010
## 📋 Current Status
1111

12+
Verify the setup status dynamically using the `knowcode doctor` command:
13+
```bash
14+
uv run knowcode doctor --store .
15+
```
16+
1217
### ✅ Ready
1318

1419
- [x] MCP configuration file updated with absolute path
15-
- [x] Knowledge store exists (1.1M, 1 day old)
16-
- [x] KnowCode CLI working (v0.2.1)
20+
- [x] Knowledge store exists
21+
- [x] KnowCode CLI working
1722
- [x] Virtual environment configured
18-
- [x] Agent rules defined in `.agent/context.md`
19-
20-
### ⚠️ Needs Attention
21-
22-
- [ ] **Semantic index missing** - Will use lexical search only
23-
- [ ] **Knowledge store is 1 day old** - Consider re-analyzing
23+
- [x] Agent rules defined in [.agent/rules/context.md](file:///.agent/rules/context.md)
2424

2525
### 🔄 Next Actions Required
2626

2727
1. **Stop the manual MCP server** (Ctrl+C in terminal)
2828
2. **Restart Antigravity IDE**
29-
3. **Test the workflow** (see test_mcp_workflow.md)
29+
3. **Test the workflow** (see [tests/test_mcp_workflow.md](file:///Users/deepg/Desktop/KnowCode/tests/test_mcp_workflow.md))
3030

3131
## 🎯 Expected Workflow After Restart
3232

@@ -36,9 +36,9 @@ User asks: "How does search work in KnowCode?"
3636
Agent calls: retrieve_context_for_query(
3737
query="How does search work in KnowCode?",
3838
task_type="auto",
39-
max_tokens=3000,
40-
limit_entities=3,
41-
expand_deps=true
39+
max_tokens=1500,
40+
limit_entities=1,
41+
expand_deps=false
4242
)
4343
4444
KnowCode MCP Server returns:
@@ -49,18 +49,19 @@ KnowCode MCP Server returns:
4949
...
5050
}
5151
52-
Agent checks: sufficiency_score >= 0.8?
52+
Agent checks: sufficiency_score >= sufficiency_threshold (0.8 per aimodels.yaml)?
5353
54-
YES → Answer from context_text only (no external LLM)
55-
NO → Use external LLM (Claude Sonnet 4.5)
54+
YES → Answer directly from local context_text
55+
NO → Escalate local context (raise max_tokens/limit_entities, or verbosity to standard/verbose)
56+
If local context still insufficient → Fallback to external LLM (as defined in docs/mcp-contract.md)
5657
```
5758

5859
## 📁 Files Created
5960

60-
1. **`verify_mcp_connection.sh`** - Check MCP setup status
61-
2. **`test_mcp_workflow.md`** - Test questions after restart
62-
3. **`docs/MCP_SETUP.md`** - Complete setup documentation
63-
4. **`README_MCP.md`** - This quick reference (you are here)
61+
1. **[verify_mcp_connection.sh](file:///Users/deepg/Desktop/KnowCode/verify_mcp_connection.sh)** - Check MCP setup status
62+
2. **[tests/test_mcp_workflow.md](file:///Users/deepg/Desktop/KnowCode/tests/test_mcp_workflow.md)** - Test questions after restart
63+
3. **[docs/MCP_SETUP.md](file:///Users/deepg/Desktop/KnowCode/docs/MCP_SETUP.md)** - Complete setup documentation
64+
4. **[README_MCP.md](file:///Users/deepg/Desktop/KnowCode/README_MCP.md)** - This quick reference (you are here)
6465

6566
## 🚀 Quick Commands
6667

@@ -93,40 +94,43 @@ knowcode analyze . -o .
9394

9495
## 🐛 Troubleshooting
9596

96-
### MCP Tool Not Available After Restart?
97+
### Check Setup with Doctor Command
98+
The absolute best way to check the status of your KnowCode configuration, knowledge store, and semantic index is using `knowcode doctor`:
99+
```bash
100+
uv run knowcode doctor --store . --mcp
101+
```
102+
This command checks configuration files, verifies the presence of required index files (`index_manifest.json`, `chunks.json`, `vectors.index`), and tests the local MCP server handshake.
97103

98-
1. Check server is running:
104+
### MCP Tool Not Available After Restart?
99105

106+
1. Check if the server process is running:
100107
```bash
101108
ps aux | grep "knowcode mcp-server"
102109
```
103110

104-
2. Check configuration:
105-
111+
2. Check configuration file paths:
106112
```bash
107113
cat ~/.gemini/antigravity/mcp_config.json
108114
```
109115

110-
3. Restart IDE again
116+
3. Restart the IDE/client to reload the configuration.
111117

112118
### Low Sufficiency Scores?
113119

114-
1. Verify index exists (should be created by analyze):
115-
120+
1. Verify the semantic index directory contains the three required files:
121+
- `index_manifest.json`
122+
- `chunks.json`
123+
- `vectors.index`
116124
```bash
117125
ls -la knowcode_index/
118126
```
119127

120-
2. If missing, run a dedicated index build:
121-
128+
2. If any files are missing, rebuild the index:
122129
```bash
123-
knowcode index . --output knowcode_index
130+
uv run knowcode index . --output knowcode_index
124131
```
125132

126-
3. Increase token budget in `.agent/context.md`:
127-
```markdown
128-
Use max_tokens=6000, limit_entities=5
129-
```
133+
3. Adjust token budget parameters in [.agent/rules/context.md](file:///.agent/rules/context.md) following the verbosity ladder in [docs/mcp-contract.md](file:///Users/deepg/Desktop/KnowCode/docs/mcp-contract.md).
130134

131135
## 📊 Success Metrics
132136

@@ -139,19 +143,18 @@ After setup, you should see:
139143

140144
## 📚 Documentation
141145

142-
- **Full Setup Guide**: `docs/MCP_SETUP.md`
143-
- **Test Plan**: `test_mcp_workflow.md`
144-
- **KnowCode Docs**: `README.md`
146+
- **Full Setup Guide**: [docs/MCP_SETUP.md](file:///Users/deepg/Desktop/KnowCode/docs/MCP_SETUP.md)
147+
- **Test Plan**: [tests/test_mcp_workflow.md](file:///Users/deepg/Desktop/KnowCode/tests/test_mcp_workflow.md)
148+
- **KnowCode Docs**: [README.md](file:///Users/deepg/Desktop/KnowCode/README.md)
149+
- **MCP Contract**: [docs/mcp-contract.md](file:///Users/deepg/Desktop/KnowCode/docs/mcp-contract.md)
145150

146151
## 🎓 Key Concepts
147152

148153
**Sufficiency Score**: Confidence that retrieved context is enough to answer the query
149-
150-
- `>= 0.8` → Answer locally
151-
- `< 0.8` → Use external LLM
154+
- `>= sufficiency_threshold` (default 0.8) → Answer locally
155+
- `< sufficiency_threshold` → Escalate or use external LLM
152156

153157
**Retrieval Modes**:
154-
155158
- **Semantic**: Uses embeddings + vector search (better)
156159
- **Lexical**: Uses keyword matching (fallback)
157160

@@ -161,8 +164,8 @@ After setup, you should see:
161164

162165
1. **Build semantic index** - Much better than lexical
163166
2. **Keep knowledge store updated** - Re-analyze after major changes
164-
3. **Tune parameters** - Adjust max_tokens and limit_entities
165-
4. **Monitor scores** - Track sufficiency_score distribution
167+
3. **Tune parameters** - Adjust `max_tokens` and `limit_entities` following the verbosity ladder
168+
4. **Monitor scores** - Track `sufficiency_score` distribution
166169

167170
## 🔒 Security Notes
168171

@@ -183,4 +186,4 @@ Good luck! 🚀
183186

184187
---
185188

186-
_Last updated: 2026-01-13_
189+
_Last updated: 2026-06-06_

0 commit comments

Comments
 (0)