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
Walk-up config discovery, configurable source root, and microservice auto-scope (#277)
* Update propose skill with brainstorming-inspired discovery process
- Add Hard Gate: prevent writing proposals without discovery
- Add systematic 8-step process with task tracking
- Agent determines clarifying questions (not scripted)
- Present 2-3 solution approaches with trade-offs
- Draft sections incrementally with approval
- Self-review after writing
- User review gate before completion
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* Add walk-up config discovery and microservice auto-scope design
This commit adds the complete design specification for two related
features that address workspace flexibility and codebase boundary
awareness:
Walk-up config discovery:
- Tool finds .java-codebase-rag.yml by walking up from cwd (like git)
- YAML gains optional source_root field for config/code separation
- Index dir auto-derives from resolved source root
- Precedence: CLI > env > YAML > walk-up > cwd
Microservice auto-scope:
- Automatically detects microservice from current working directory
- Applies microservice filter to queries when inside a microservice
- Prevents agents from seeing code outside their context
- Explicit filters always override auto-detected scope
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* Fix code review issues in walk-up and microservice auto-scope design
This commit addresses all issues found in code review:
Critical Issues Fixed:
1. Directory traversal logic - Added detailed algorithm specification with error
handling for permissions, inaccessible home, and boundary conditions
2. Microservice detection at source_root - Clarified that cwd=source_root returns
None with semantic rationale different from indexing behavior
3. ScopeManager lifecycle - Specified that scope is cached at startup and
requires restart for directory changes
Important Issues Fixed:
4. Permissions error handling - Added comprehensive error handling table
5. Path resolution documentation - Clarified how precedence interacts with
different resolution bases
6. Multiple config files - Specified .yml takes precedence over .yaml
7. _resolve_lancedb_uri integration - Specified behavior when
JAVA_CODEBASE_RAG_INDEX_DIR is set but JAVA_CODEBASE_RAG_SOURCE_ROOT is not
Minor Issues Fixed:
8. Documentation update timing - Added timing specification to plan
9. Advisory message phrasing - Defined exact log and advisory message text
10. Test file organization - Added justification for separate test files
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* Add walk-up config discovery, configurable source root, and microservice auto-scope
Implement walk-up config discovery, configurable source root via YAML,
and microservice auto-scope for MCP queries.
Changes:
- Add discover_project_root() to walk up directory tree finding config
- Add source_root YAML field for config-source separation
- Implement precedence chain: CLI > env > YAML > discovery > cwd
- Update _project_root() in server.py to use walk-up discovery
- Add detect_microservice_from_path() for microservice detection
- Add ScopeManager class for automatic microservice scoping
- Wire ScopeManager into all MCP tool wrappers
- Add init command warning when parent config detected
- Update documentation for walk-up, source_root, and auto-scope
- Add mcp.json.example with zero-env-var configuration
Tests: 21 new tests covering config discovery, precedence, and microservice scope.
All tests pass, ruff check clean.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* Fix config tests to clean environment variables
Add monkeypatch.delenv() calls to tests that need clean environment.
The conftest.py mcp_env fixture sets JAVA_CODEBASE_RAG_INDEX_DIR and
JAVA_CODEBASE_RAG_SOURCE_ROOT at session level, which was causing
test failures when resolve_operator_config(source_root=None)
picked up these env vars instead of using walk-up discovery.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* Address review comments from PR #277
Fixes:
1. Remove duplicate "Key Principles" section in SKILL.md
2. Rename apply_auto_scope parameter from 'filter' to 'node_filter' to avoid shadowing built-in
3. Add test_detect_scope_integration to exercise real detection flow
4. Fix detect_microservice_from_path to check cwd against YAML overrides
5. Add test_detect_scope_with_yaml_overrides to verify override behavior
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: README.md
+3-1Lines changed: 3 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -92,7 +92,9 @@ With the package installed, the console script `java-codebase-rag-mcp` is on you
92
92
claude mcp add --transport stdio java-codebase-rag -- java-codebase-rag-mcp
93
93
```
94
94
95
-
Then set env vars (`JAVA_CODEBASE_RAG_INDEX_DIR`, `JAVA_CODEBASE_RAG_SOURCE_ROOT`, `SBERT_MODEL`, …) in `.mcp.json` or your shell profile. For a project-scoped `.mcp.json` template, see [`mcp.json.example`](./mcp.json.example). Official docs: [Claude Code settings](https://docs.anthropic.com/en/docs/claude-code/settings).
95
+
**Zero-env-var configuration:** The tool automatically walks up the directory tree to find `.java-codebase-rag.yml`, so you don't need to set `JAVA_CODEBASE_RAG_SOURCE_ROOT` when working from within a project. Just place the config file at your project root and the tool will find it. See [`mcp.json.example`](./mcp.json.example) for the minimal configuration.
96
+
97
+
If you need to override defaults, you can set env vars (`JAVA_CODEBASE_RAG_INDEX_DIR`, `JAVA_CODEBASE_RAG_SOURCE_ROOT`, `SBERT_MODEL`, …) in `.mcp.json` or your shell profile. For a full configuration template, see [`mcp.json.example`](./mcp.json.example). Official docs: [Claude Code settings](https://docs.anthropic.com/en/docs/claude-code/settings).
Copy file name to clipboardExpand all lines: docs/CONFIGURATION.md
+46Lines changed: 46 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -22,6 +22,25 @@ For the architecture rationale (the GPS metaphor, three-layer design, future wor
22
22
23
23
The operator-facing surface is **six** variables (plus MCP-only `JAVA_CODEBASE_RAG_SOURCE_ROOT` below). Precedence for knobs that also exist as CLI flags or YAML entries is **CLI flag > env var > YAML > built-in default** (see [`JAVA-CODEBASE-RAG-CLI.md`](./JAVA-CODEBASE-RAG-CLI.md)).
24
24
25
+
### Config file discovery (walk-up)
26
+
27
+
The tool automatically walks up the directory tree from the current working directory to find `.java-codebase-rag.yml` (or `.yaml`), similar to how Git finds `.git`. This means you can run CLI commands and MCP queries from any subdirectory within your project — the tool will locate the config file automatically.
28
+
29
+
**Walk-up behavior:**
30
+
- Starts from the current working directory and walks up the directory tree
31
+
- Stops at `$HOME` (inclusive — checks `$HOME` itself but doesn't walk past it)
32
+
- First match wins (closest config to cwd, not "most specific" or "deepest")
33
+
- If no config is found, falls back to using the current directory
3. YAML field `source_root` (resolved relative to config directory)
39
+
4. Walk-up discovery result (config directory itself)
40
+
5. Current working directory (fallback)
41
+
42
+
This walk-up behavior means you no longer need to set environment variables or pass flags when working from within a project — the tool finds the config automatically.
43
+
25
44
| Variable | Purpose |
26
45
|---|---|
27
46
|`JAVA_CODEBASE_RAG_INDEX_DIR`| Local filesystem **directory** for Lance tables, the Kuzu file `code_graph.kuzu`, and cocoindex state (`cocoindex.db`). Not a `lancedb://` or cloud URI — use a path. Default: `./.java-codebase-rag/` under the resolved Java tree root. |
@@ -58,6 +77,14 @@ A single file at the project root (the directory you pass as `--source-root`, or
0 commit comments