Skip to content

Commit f32d2f4

Browse files
fix: resolve all CI failures — lint, co-changes test, integration db … (#22)
* fix: resolve all CI failures — lint, co-changes test, integration db path - Fix unsorted import blocks across init_cmd.py and all server routers (ruff I001) - Fix test_get_co_changes using wrong key "count" instead of canonical "co_change_count" - Fix integration tests asserting wiki.db at repo-local path while code writes to ~/.repowise/wiki.db by default; set REPOWISE_DB_URL in work_repo fixture to isolate each test * revert: restore server import order (ruff --fix on Windows produced wrong ordering for Linux CI) * fix: apply ruff format to 7 files failing format check on CI
1 parent 4308893 commit f32d2f4

9 files changed

Lines changed: 43 additions & 22 deletions

File tree

packages/cli/src/repowise/cli/commands/init_cmd.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030

3131
def _register_mcp_with_claude(console_obj: Any, repo_path: Path) -> None:
3232
"""Register the repowise MCP server with Claude Desktop and Claude Code."""
33-
from repowise.cli.mcp_config import register_with_claude_desktop, register_with_claude_code
33+
from repowise.cli.mcp_config import register_with_claude_code, register_with_claude_desktop
3434

3535
desktop = register_with_claude_desktop(repo_path)
3636
if desktop:
@@ -733,8 +733,6 @@ def on_commit_done() -> None:
733733
from repowise.cli.mcp_config import (
734734
save_mcp_config,
735735
save_root_mcp_config,
736-
register_with_claude_desktop,
737-
register_with_claude_code,
738736
)
739737

740738
save_mcp_config(repo_path)

packages/cli/src/repowise/cli/commands/serve_cmd.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,7 @@ def _setup_embedder() -> None:
3939
return
4040

4141
# Detect which providers already have keys in the environment.
42-
has_gemini = bool(
43-
os.environ.get("GEMINI_API_KEY") or os.environ.get("GOOGLE_API_KEY")
44-
)
42+
has_gemini = bool(os.environ.get("GEMINI_API_KEY") or os.environ.get("GOOGLE_API_KEY"))
4543
has_openai = bool(os.environ.get("OPENAI_API_KEY"))
4644

4745
console.print(
@@ -74,7 +72,11 @@ def _setup_embedder() -> None:
7472
raw = click.prompt(" Select", default=default).strip()
7573

7674
# Map number or name to option.
77-
choice = raw if raw in options else (options[int(raw) - 1] if raw.isdigit() and 1 <= int(raw) <= len(options) else "skip")
75+
choice = (
76+
raw
77+
if raw in options
78+
else (options[int(raw) - 1] if raw.isdigit() and 1 <= int(raw) <= len(options) else "skip")
79+
)
7880

7981
if choice == "skip":
8082
console.print("[dim]Skipping embedder — chat and search will be unavailable.[/dim]\n")
@@ -124,18 +126,21 @@ def _save_global_embedder(embedder: str, api_key: str) -> None:
124126
existing: dict = {}
125127
if config_path.exists():
126128
import yaml # type: ignore[import-untyped]
129+
127130
existing = yaml.safe_load(config_path.read_text(encoding="utf-8")) or {}
128131
existing["embedder"] = embedder
129132
if api_key:
130133
existing["embedder_api_key"] = api_key
131134
import yaml # type: ignore[import-untyped]
135+
132136
config_path.write_text(
133137
yaml.dump(existing, default_flow_style=False, sort_keys=False),
134138
encoding="utf-8",
135139
)
136140
except Exception:
137141
pass # Non-fatal — user just gets prompted again next time.
138142

143+
139144
_GITHUB_REPO = "RaghavChamadiya/repowise"
140145
_WEB_CACHE_DIR = Path.home() / ".repowise" / "web"
141146
_MARKER_FILE = _WEB_CACHE_DIR / ".version"
@@ -345,7 +350,9 @@ def serve_command(port: int, host: str, workers: int, ui_port: int, no_ui: bool)
345350
if not ready:
346351
local_web = _find_local_web()
347352
if local_web:
348-
standalone = local_web / ".next" / "standalone" / "packages" / "web" / "server.js"
353+
standalone = (
354+
local_web / ".next" / "standalone" / "packages" / "web" / "server.js"
355+
)
349356
if standalone.exists():
350357
ready = True
351358
elif npm:

packages/cli/src/repowise/cli/mcp_config.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,13 @@
1010
def _claude_desktop_config_path() -> Path | None:
1111
"""Return the Claude Desktop config path for this OS, or None if unsupported."""
1212
if sys.platform == "darwin":
13-
return Path.home() / "Library" / "Application Support" / "Claude" / "claude_desktop_config.json"
13+
return (
14+
Path.home()
15+
/ "Library"
16+
/ "Application Support"
17+
/ "Claude"
18+
/ "claude_desktop_config.json"
19+
)
1420
if sys.platform == "win32":
1521
appdata = Path.home() / "AppData" / "Roaming"
1622
return appdata / "Claude" / "claude_desktop_config.json"

packages/core/src/repowise/core/persistence/database.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,11 @@
3636
"init_db",
3737
]
3838

39+
3940
def _default_db_url() -> str:
4041
"""Global SQLite DB at ~/.repowise/wiki.db — shared across all repos."""
4142
from pathlib import Path
43+
4244
db_path = Path.home() / ".repowise" / "wiki.db"
4345
db_path.parent.mkdir(parents=True, exist_ok=True)
4446
return f"sqlite+aiosqlite:///{db_path}"

packages/server/src/repowise/server/routers/git.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,9 @@ async def get_hotspots(
6969
lines_added_90d=r.lines_added_90d or 0,
7070
lines_deleted_90d=r.lines_deleted_90d or 0,
7171
avg_commit_size=r.avg_commit_size or 0.0,
72-
commit_categories=json.loads(r.commit_categories_json) if r.commit_categories_json else {},
72+
commit_categories=json.loads(r.commit_categories_json)
73+
if r.commit_categories_json
74+
else {},
7375
)
7476
for r in rows
7577
]
@@ -171,10 +173,7 @@ async def get_git_summary(
171173
owners[m.primary_owner_name] = owners.get(m.primary_owner_name, 0) + 1
172174
total = len(all_meta) or 1
173175
top_owners = sorted(
174-
[
175-
{"name": k, "file_count": v, "pct": v / total}
176-
for k, v in owners.items()
177-
],
176+
[{"name": k, "file_count": v, "pct": v / total} for k, v in owners.items()],
178177
key=lambda x: x["file_count"],
179178
reverse=True,
180179
)[:10]

packages/server/src/repowise/server/routers/graph.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -366,14 +366,15 @@ async def dead_code_graph(
366366
"__init__.py",
367367
"conftest.py",
368368
"fixtures/",
369-
"/app/", # Next.js app router pages
370-
"/pages/", # Next.js pages router
371-
"/routers/", # FastAPI routers
372-
"/commands/", # CLI commands
369+
"/app/", # Next.js app router pages
370+
"/pages/", # Next.js pages router
371+
"/routers/", # FastAPI routers
372+
"/commands/", # CLI commands
373373
"/components/ui/", # UI component library
374374
)
375375
dead_nodes = [
376-
n for n in all_candidates
376+
n
377+
for n in all_candidates
377378
if not n.is_entry_point
378379
and not n.is_test
379380
and not any(pat in n.node_id for pat in _framework_patterns)

packages/server/src/repowise/server/schemas.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,9 @@ def from_orm(cls, obj: object) -> GitMetadataResponse:
344344
lines_added_90d=obj.lines_added_90d or 0, # type: ignore[attr-defined]
345345
lines_deleted_90d=obj.lines_deleted_90d or 0, # type: ignore[attr-defined]
346346
avg_commit_size=obj.avg_commit_size or 0.0, # type: ignore[attr-defined]
347-
commit_categories=json.loads(obj.commit_categories_json) if obj.commit_categories_json else {}, # type: ignore[attr-defined]
347+
commit_categories=json.loads(obj.commit_categories_json)
348+
if obj.commit_categories_json
349+
else {}, # type: ignore[attr-defined]
348350
merge_commit_count_90d=obj.merge_commit_count_90d or 0, # type: ignore[attr-defined]
349351
)
350352

tests/integration/test_cli.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,14 @@ def runner():
1616

1717

1818
@pytest.fixture
19-
def work_repo(tmp_path, sample_repo_path):
19+
def work_repo(tmp_path, sample_repo_path, monkeypatch):
2020
"""Copy sample_repo into a temporary directory for isolation."""
2121
dest = tmp_path / "repo"
2222
shutil.copytree(sample_repo_path, dest)
23+
# Point the DB at the repo-local path so tests can assert on its existence
24+
db_path = dest / ".repowise" / "wiki.db"
25+
db_path.parent.mkdir(parents=True, exist_ok=True)
26+
monkeypatch.setenv("REPOWISE_DB_URL", f"sqlite+aiosqlite:///{db_path}")
2327
return dest
2428

2529

tests/unit/server/test_git.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@ async def _insert_git_metadata(session_factory, repo_id: str) -> None:
2727
primary_owner_commit_pct=0.6,
2828
top_authors_json=json.dumps([{"name": "Alice", "commits": 30}]),
2929
significant_commits_json=json.dumps([{"sha": "abc", "message": "init"}]),
30-
co_change_partners_json=json.dumps([{"file_path": "src/utils.py", "count": 5}]),
30+
co_change_partners_json=json.dumps(
31+
[{"file_path": "src/utils.py", "co_change_count": 5}]
32+
),
3133
is_hotspot=True,
3234
is_stable=False,
3335
churn_percentile=0.85,

0 commit comments

Comments
 (0)