Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ java-codebase-rag install
java-codebase-rag install --non-interactive --agent claude-code
```

After `pip install --upgrade java-codebase-rag`, run `java-codebase-rag update` to refresh shipped artifacts.
After `pip install --upgrade java-codebase-rag`, run `java-codebase-rag update` to refresh shipped artifacts and catch up the index (Lance + graph).

### Manual registration

Expand Down Expand Up @@ -195,7 +195,7 @@ Run `java-codebase-rag --help` to list grouped subcommands. Operator playbook wi
| Group | Subcommand | What it does |
|---|---|---|
| Setup | `install` | Interactive setup wizard: config, MCP registration, skill/agent deployment, indexing. |
| Setup | `update` | Refresh shipped artifacts (skill, agent, MCP entry) after pip upgrade. |
| Setup | `update` | Refresh shipped artifacts (skill, agent, MCP entry) + incremental Lance/graph catch-up after pip upgrade. |
| Lifecycle | `init` | First-time index. Refuses if artifacts already exist. |
| Lifecycle | `increment` | CocoIndex catch-up + incremental Kuzu update. `--vectors-only` for Lance only. |
| Lifecycle | `reprocess` | Full Lance + Kuzu rebuild. `--vectors-only` / `--graph-only` for a single phase. |
Expand Down
4 changes: 2 additions & 2 deletions docs/JAVA-CODEBASE-RAG-CLI.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ java-codebase-rag install --scope user

### `update`

Post-upgrade refresh: overwrites skill and agent files with the latest shipped versions and updates the MCP command path. Requires a prior `install` run.
Post-upgrade refresh: overwrites skill and agent files with the latest shipped versions and updates the MCP command path. If an index exists, also runs an incremental Lance + graph catch-up (same as `increment`). Requires a prior `install` run.

```bash
# Refresh after pip upgrade
Expand All @@ -83,7 +83,7 @@ java-codebase-rag update --force
- Detects previously configured agent hosts (scans both project-level and user-level config files).
- Refreshes skill and agent files (versioned assets from the package).
- Updates MCP entrypoint path if `java-codebase-rag-mcp` has moved.
- Runs `increment` on the index if it exists (LanceDB catch-up). Prints graph staleness warning.
- Runs an incremental index update (Lance + graph) if an index exists — same as `java-codebase-rag increment`.
- Skips MCP config if the entry already exists and is correct.

**Exit codes:**
Expand Down
5 changes: 3 additions & 2 deletions java_codebase_rag/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -775,8 +775,9 @@ def build_parser() -> argparse.ArgumentParser:
help="Refresh shipped artifacts (skill, agent, MCP entry) after pip upgrade.",
description=(
"Post-upgrade refresh: overwrites skill and agent files with the latest "
"shipped versions and updates the MCP command path. Use --dry-run to "
"preview changes without writing. Requires a prior `install` run."
"shipped versions and updates the MCP command path. If an index exists, "
"also runs an incremental Lance + graph catch-up (same as `increment`). "
"Use --dry-run to preview changes without writing. Requires a prior `install` run."
),
)
update.add_argument(
Expand Down
31 changes: 23 additions & 8 deletions java_codebase_rag/installer.py
Original file line number Diff line number Diff line change
Expand Up @@ -1182,7 +1182,7 @@ def run_update(
index_dir_has_existing_artifacts,
resolve_operator_config,
)
from java_codebase_rag.pipeline import run_cocoindex_update
from java_codebase_rag.pipeline import run_cocoindex_update, run_incremental_graph

project_root = discover_project_root(cwd)
if project_root is None:
Expand All @@ -1207,22 +1207,37 @@ def run_update(
print("Run `java-codebase-rag install` to create one.")
return EXIT_PARTIAL if has_artifact_failures else EXIT_SUCCESS

# Run increment (LanceDB catch-up)
# Run increment: LanceDB catch-up + incremental graph rebuild.
# Mirrors `java-codebase-rag increment` so both index layers stay current.
# The "graph not implemented" warning belongs only on the vectors-only path
# (increment --vectors-only), where the graph step is deliberately skipped.
if not dry_run:
print("\nUpdating index (incremental LanceDB update)...")
print("\nUpdating index (Lance + graph)...")
cfg.apply_to_os_environ()
env = cfg.subprocess_env()

coco = run_cocoindex_update(env, full_reprocess=False, quiet=True)
if coco.returncode != 0:
print(f"Error: Index update failed with code {coco.returncode}")
print(f"Error: Lance index update failed with code {coco.returncode}")
return 1

# Print graph staleness warning
from java_codebase_rag.cli import _INCREMENT_WARNING_LINES
print("\n" + "\n".join(_INCREMENT_WARNING_LINES))
g = run_incremental_graph(
source_root=cfg.source_root,
ladybug_path=cfg.ladybug_path,
verbose=False,
quiet=True,
env=env,
)
if g.returncode != 0:
# Artifacts above already refreshed; the graph catch-up is best-effort
# here. Surface a truthful, actionable message instead of leaving the
# graph silently stale or claiming the feature is unimplemented.
print(
f"\nWarning: incremental graph update failed (exit {g.returncode}). "
"Run `java-codebase-rag reprocess` for a full rebuild."
)
else:
print("\nWould run incremental index update.")
print("\nWould run incremental index update (Lance + graph).")

# Print summary
print("\nUpdate complete.")
Expand Down
8 changes: 8 additions & 0 deletions tests/test_installer.py
Original file line number Diff line number Diff line change
Expand Up @@ -1106,6 +1106,10 @@ def mock_run_build_ast_graph(*args, **kwargs):
from subprocess import CompletedProcess
return CompletedProcess(["build_ast_graph"], 0)

def mock_run_incremental_graph(*args, **kwargs):
from subprocess import CompletedProcess
return CompletedProcess(["build_ast_graph", "--incremental"], 0)

monkeypatch.setattr(
"java_codebase_rag.pipeline.run_cocoindex_update",
mock_run_cocoindex_update,
Expand All @@ -1114,6 +1118,10 @@ def mock_run_build_ast_graph(*args, **kwargs):
"java_codebase_rag.pipeline.run_build_ast_graph",
mock_run_build_ast_graph,
)
monkeypatch.setattr(
"java_codebase_rag.pipeline.run_incremental_graph",
mock_run_incremental_graph,
)

# Change to fixture directory
monkeypatch.setattr(Path, "cwd", lambda: cwd)
Expand Down
Loading