You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: prepare v1.5.0 trust and indexing foundation (#21)
* feat: prepare v1.5.0 reliability test build
Add evidence-locked preflight, memory confidence/failure signals, git-derived memories, and manifest-based incremental indexing with coverage tests so branch testing can validate trust claims before release.
* chore: keep internal-docs submodule pointer on master baseline
* fix: mark invalid memory dates as stale evidence
* chore: format indexer and manifest for CI checks
Copy file name to clipboardExpand all lines: AGENTS.md
+12-3Lines changed: 12 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,15 @@
1
1
# Agent Instructions
2
2
3
-
## Internal Documentation
3
+
## Codebase Context
4
+
5
+
**At start of each task:** Call `get_memory` to load team conventions.
6
+
7
+
**CRITICAL:** When user says "remember this" or "record this":
8
+
- STOP immediately and call `remember` tool FIRST
9
+
- DO NOT proceed with other actions until memory is recorded
10
+
- This is a blocking requirement, not optional
11
+
12
+
## Internal Documentation (Submodule)
4
13
5
14
This repository uses a private git submodule for internal notes.
6
15
@@ -20,6 +29,6 @@ git pull --recurse-submodules
20
29
git submodule update --remote --merge
21
30
```
22
31
23
-
### Privacy & Security
32
+
### Privacy
24
33
25
-
The `internal-docs` repository is **Private**. It returns a 404 to unauthenticated users/APIs. Access requires a GitHub PAT or SSH keys with repository permissions.
34
+
The `internal-docs` repository is private. It returns a 404 to unauthenticated users. Access requires a GitHub PAT or SSH keys with repository permissions.
Copy file name to clipboardExpand all lines: MOTIVATION.md
+7-12Lines changed: 7 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
# Motivation: Why This Exists
2
2
3
-
> **TL;DR**: AI coding assistants are smart but dangerous. Without guidance, they "vibe code" their way into technical debt. This MCP gives them **Context** (to know your patterns) and **Wisdom** (to keep your codebase healthy).
3
+
> **TL;DR**: AI coding assistants increase throughput but often degrade stability. Without codebase context, they generate code that works but violates team conventions and architectural rules. This MCP provides structured pattern data and recorded rationale so agents produce code that fits.
4
4
5
5
---
6
6
@@ -28,7 +28,7 @@ AI drastically increases **Throughput** (more code/hour) but often kills **Stabi
28
28
29
29
## What This Does
30
30
31
-
We provide **Active Context**—not just raw data, but the *judgment* of a Senior Engineer.
31
+
This MCP provides **active context** - not raw data, but structured intelligence derived from actual codebase state.
32
32
33
33
### 1. Pattern Discovery (The "Map")
34
34
-**Frequency Detection**: "97% use `inject()`, 3% use `constructor`." (Consensus)
@@ -40,19 +40,18 @@ We provide **Active Context**—not just raw data, but the *judgment* of a Senio
40
40
-**Health Context**: "⚠️ Careful, `UserService.ts` is a high-churn hotspot with circular dependencies. Add tests."
|**File-level trend detection**| Trend is based on file modification date, not line-by-line content. A recently modified file may still contain legacy patterns on specific lines. Future: AST-based line-level detection. |
57
56
58
57
---
@@ -61,7 +60,7 @@ We provide **Active Context**—not just raw data, but the *judgment* of a Senio
61
60
62
61
1.**Context alone is dangerous**: Giving AI "all the context" just confuses it or teaches it bad habits (Search Contamination).
63
62
2.**Decisions > Data**: AI needs *guidance* ("Use X"), not just *options* ("Here is X and Y").
64
-
3.**Governance through Discovery**: We don't need to block PRs to be useful. If we show the AI that a pattern is "Declining" and "Dangerous," it self-corrects.
63
+
3.**Governance through Discovery**: Blocking PRs is not required. If the AI sees that a pattern is "Declining" and "Dangerous," it self-corrects.
65
64
66
65
---
67
66
@@ -76,7 +75,3 @@ We provide **Active Context**—not just raw data, but the *judgment* of a Senio
76
75
-**Search Contamination**: Without MCP, models copied legacy patterns 40% of the time.
77
76
-**Momentum Success**: With "Trending" signals, models adopted modern patterns even when they were the minority (3%).
Your team has internal libraries, naming conventions, and patterns that external AI models have never seen. This MCP server gives AI assistants real-time visibility into your codebase: which libraries your team actually uses, how often, and where to find canonical examples.
5
+
A second brain for AI coding agents. MCP server that remembers team decisions, tracks pattern evolution, and guides every edit with evidence.
6
6
7
7
## Quick Start
8
8
9
-
Add this to your MCP client config (Claude Desktop, VS Code, Cursor, etc.).
No config file needed. Add to `.claude/settings.json` or run:
72
+
73
+
```bash
74
+
claude mcp add codebase-context -- npx -y codebase-context /path/to/your/project
75
+
```
76
+
77
+
## What Makes It a Second Brain
78
+
79
+
Other tools help AI find code. This one helps AI make the right decisions — by remembering what your team does, tracking how patterns evolve, and warning before mistakes repeat.
| Internal library detection | 336 uses of `@company/ui-toolkit` vs 3 direct PrimeNG |
124
+
| DI pattern consensus | 98% `inject()` adoption detected, constructor DI flagged |
125
+
| Test framework detection | 74% Jest, 26% Jasmine/Karma, per-module awareness |
126
+
| Wrapper discovery |`ToastEventService`, `DialogComponent` surfaced over raw |
127
+
| Golden file identification | Top 5 files scoring 4-6 modern patterns each |
128
+
129
+
Without this context, AI agents default to generic patterns: raw PrimeNG imports, constructor injection, Jasmine syntax. With the second brain active, generated code matches the existing codebase on first attempt.
32
130
33
131
## How It Works
34
132
35
-
When generating code, the agent checks your patterns first:
|`get_indexing_status`| Indexing progress + last stats |
207
+
|`get_style_guide`| Query style guide rules |
208
+
|`detect_circular_dependencies`| Find import cycles between files |
209
+
|`remember`| Record memory (conventions/decisions/gotchas/failures) |
210
+
|`get_memory`| Query memory with confidence decay scoring |
211
+
|`refresh_index`| Re-index the codebase + extract git memories |
212
+
213
+
## Language Support
214
+
215
+
The Angular analyzer provides deep framework-specific analysis (signals, standalone components, control flow syntax, lifecycle hooks, DI patterns). A generic analyzer covers 30+ languages and file types as a fallback: JavaScript, TypeScript, Python, Java, Kotlin, C/C++, C#, Go, Rust, PHP, Ruby, Swift, Scala, Shell, and common config/markup formats.
74
216
75
217
## File Structure
76
218
@@ -97,22 +239,27 @@ The MCP creates the following structure in your project:
97
239
Patterns tell you _what_ the team does ("97% use inject"), but not _why_ ("standalone compatibility"). Use `remember` to capture rationale that prevents repeated mistakes:
98
240
99
241
```typescript
100
-
// AI won't change this again after recording the decision
Memories surface automatically in `search_codebase` results and `get_team_patterns` responses.
250
+
**Memory types:**`convention` (style rules), `decision` (architecture choices), `gotcha` (things that break), `failure` (tried X, failed because Y).
251
+
252
+
**Confidence decay:** Memories age. Conventions never decay. Decisions have a 180-day half-life. Gotchas and failures have a 90-day half-life. Memories below 30% confidence are flagged as stale in `get_memory` responses.
253
+
254
+
**Git auto-extraction:** During indexing, conventional commits (`refactor:`, `migrate:`, `fix:`, `revert:`) from the last 90 days are auto-recorded as memories. Zero manual effort.
255
+
256
+
**Pattern conflicts:**`get_team_patterns` detects when two patterns in the same category are both above 20% adoption with different trends, and surfaces them as conflicts with both sides.
257
+
258
+
Memories surface automatically in `search_codebase` results, `get_team_patterns` responses, and preflight cards.
111
259
112
-
**Early baseline — known quirks:**
260
+
**Known quirks:**
113
261
114
262
- Agents may bundle multiple things into one entry
115
-
- Duplicates can happen if you record the same thing twice
116
263
- Edit `.codebase-context/memory.json` directly to clean up
117
264
- Be explicit: "Remember this: use X not Y"
118
265
@@ -125,19 +272,19 @@ Memories surface automatically in `search_codebase` results and `get_team_patter
125
272
|`CODEBASE_ROOT`| - | Project root to index (CLI arg takes precedence) |
126
273
|`CODEBASE_CONTEXT_DEBUG`| - | Set to `1` to enable verbose logging (startup messages, analyzer registration) |
127
274
128
-
## Performance Note
275
+
## Performance
129
276
130
-
This tool runs **locally** on your machine using your hardware.
277
+
This tool runs locally on your machine.
131
278
132
-
-**Initial Indexing**: The first run works hard. It may take several minutes (e.g., ~2-5 mins for 30k files) to compute embeddings for your entire codebase.
133
-
-**Caching**: Subsequent queries are instant (milliseconds).
134
-
-**Updates**: Currently, `refresh_index` re-scans the codebase. True incremental indexing (processing only changed files) is on the roadmap.
279
+
-**Initial indexing**: First run may take several minutes (e.g., 2-5 min for 30k files) to compute embeddings.
280
+
-**Subsequent queries**: Instant (milliseconds) from cache.
281
+
-**Updates**: `refresh_index` re-scans the codebase. True incremental indexing (processing only changed files) is on the roadmap.
135
282
136
283
## Links
137
284
138
-
-📄 [Motivation](./MOTIVATION.md) — Why this exists, research, learnings
139
-
-📋 [Changelog](./CHANGELOG.md) — Version history
140
-
-🤝 [Contributing](./CONTRIBUTING.md) — How to add analyzers
285
+
-[Motivation](./MOTIVATION.md) — Research and design rationale
286
+
-[Changelog](./CHANGELOG.md) — Version history
287
+
-[Contributing](./CONTRIBUTING.md) — How to add analyzers
0 commit comments