Repository navigation
Releases
CodeWise 3.0 — Import, streaming and code relationships
CodeWise 3.0 makes it practical to load a whole codebase and ask real questions about it. You can import a folder, a zip or a GitHub repository in one step. Answers stream in as they're generated. And questions like "who calls X?" are answered from the code's actual call and import relationships, not just text similarity.
Highlights
Import a whole project
- Folders. Pick a folder, or drag one onto the upload area. Paths like
src/utils.pyare kept. The frontend skips unsupported and ignored files (node_modules,.git,venv, lockfiles and so on) before uploading, and sends the rest in batches under the request size limit. .gitignoresupport..gitignorefiles in an uploaded folder or zip are applied to the other files, including nested ones.- Zip archives. A
.zipupload is expanded on the server. The top-level folder is stripped, and entry-count and size limits protect against zip bombs. Path traversal and symlinks are blocked. - GitHub repositories. Paste
github.com/owner/repo(optionally with/tree/<branch>) and click Import. Only github.com URLs are accepted. SetCODEWISE_GITHUB_TOKENfor private repositories or higher rate limits.
Streaming answers
- Answers appear word by word instead of after a long spinner. Sources show up as soon as retrieval finishes.
- A Stop button ends generation early.
- Source chips show the function or class each chunk belongs to. A branch icon marks chunks found through code relationships.
Code relationships
- On upload, CodeWise extracts definitions, calls and imports from each file:
- Python: parsed with its syntax tree, so scopes and calls are exact.
- JavaScript/TypeScript: pattern-based, including multi-line imports, class methods and JSX components.
- Java/Kotlin, C/C++, Go, Rust and C#: imports are detected.
- When a question names a function or file ("Who calls
process_pdf_pipeline?", "What depends onstore.py?"):- The prompt gets a Code relationships section listing definitions, call sites (file, line and calling function), importers and callees.
- Those call sites are also added to retrieval as a third ranking signal, alongside vector and keyword search.
- New endpoint:
GET /api/projects/<id>/graph?symbol=<name>or?file=<path>returns these relationships as JSON.
Measuring answer quality
-
python eval/answer_eval.pyasks each question in a labelled set through the real pipeline and scores:- whether the expected files were retrieved;
- whether required terms and forbidden phrases appear;
- whether cited file paths exist;
- whether it admits when the code doesn't contain the answer;
- optionally, an LLM judge grade against a reference answer.
Results are saved to
eval/results/, so you can compare runs. -
CODEWISE_QUESTION_LOG=logs/questions.jsonlrecords real questions and answers, off by default. Answers cut short with Stop are marked"complete": false.python eval/draft_from_log.pyturns the log into a draft test set for review.
API changes
- New:
POST /api/projects/<id>/import/githubwith body{"url": "...", "ref": "optional"}. - New:
GET /api/projects/<id>/graph. - New:
GET /api/upload-rules, which returns the extensions, ignored folders and size limits so clients can filter before uploading. POST /api/projects/<id>/uploadaccepts.zipfiles and relative paths. The response addssummary: {indexed, skipped, failed}, and each result says whether the file wasskipped./askresponses, and thesourcesevent of/ask/stream, includerelations: the symbols and files the relationships section covered.
Upgrading from 2.0
pip install -r requirements.txt, which addspathspecfor.gitignorematching.- The backend now runs on port 8000 by default, because port 5000 is taken by macOS AirPlay Receiver. The bundled frontend already points at 8000. Update any scripts or custom clients, or run with
CODEWISE_PORT=5000. - Re-upload existing projects to get relationship answers. Projects indexed with 2.0 still work for normal questions but have no code graph.
- Hard-refresh the frontend (Cmd+Shift+R) so it loads the new upload panel and streaming.
Known limitations
- Calls are matched by name. Two functions called
savein different classes are treated as the same, and dynamic calls (callbacks,getattr, reflection) aren't detected. The prompt tells the model this. - JavaScript/TypeScript analysis uses patterns rather than a full parser, so unusual syntax can be missed.
- Large imports are processed within a single request. Very large repositories can take a while and have no progress indicator beyond per-batch updates.
- The 12 seed questions in
eval/answer_questions.jsonwere written by the developer, so they're biased toward what's known to work. Grow the set from logged real questions.
Under the hood
- New modules:
codewise/sources.py(folders, zip, GitHub,.gitignore),codewise/graph.py(extraction and import resolution) andcodewise/relations.py(question → relationships → prompt and retrieval). - Frontend helpers:
frontend/src/lib/uploads.js(folder traversal, filtering, batching) andfrontend/src/lib/stream.js(Server-Sent Events over POST). - 89 tests (up from 45), covering zip safety, GitHub URL validation, the graph for Python, JS and other languages, relationship prompts, import endpoints and question logging.
- Checked end to end against a running backend. A 55,000-file folder, including
node_modulesandvenv, was filtered down to 43 source files in under a second. A GitHub import (pallets/itsdangerous) indexed 28 files in about 4 seconds. Streaming and Stop worked. "Who callsreplace_file?" found the real caller.
Full diff: v2.0...v3.0
CodeWise 2.0 — RAG pipeline rework
CodeWise 2.0 rebuilds the backend's retrieval pipeline so answers are grounded in the right code, cite real line numbers, and stay inside the model's context window. The API is unchanged apart from the additions listed below, so the existing React frontend works without modification.
Highlights
Better retrieval
- Structure-aware chunking. Python is split by AST (functions, classes, and methods of large classes, with decorators and comments attached). JavaScript, TypeScript, Java, Go, Rust, C and C++ are split by top-level brace blocks, and Markdown by headings. The old fixed-size windows cut functions in half.
- Code-aware embeddings. Uses
nomic-embed-textvia Ollama, and embeds each chunk together with aFile / Symbol / Linesheader. If the model isn't installed, it falls back to MiniLM with a warning. - Hybrid search. Vector search plus BM25 keyword search that understands identifiers (
snake_caseandcamelCaseare split), fused with Reciprocal Rank Fusion. Files named in the question are boosted, and weak matches are dropped. - Follow-up questions. "How does it handle errors?" is rewritten into a standalone search query using the chat history.
- Less noise. Lockfiles, minified bundles, binaries, and folders such as
node_modules/,dist/andvenv/are rejected at upload.
Correctness fixes
- Identical content in two files (licence headers, empty
__init__.py) no longer collides onto one chunk ID. - Re-uploading a file replaces its old chunks instead of mixing old and new code.
- Line numbers start at 1, and every line in the prompt is numbered, so citations point at real lines.
- Project metadata is stored in SQLite (
codewise.db) and survives restarts. Existing Chroma collections are adopted automatically. - Relative paths are kept, so
src/utils.pyandtests/utils.pystay distinct.
Prompting
num_ctxis set explicitly (default 8192), and retrieved code and history are fitted to a token budget. Ollama's small default window used to cut the start of the prompt without warning.- Clients can no longer inject
systemmessages through the chat history. - When no relevant code is found, the model is told so, and it answers "not in the code" instead of guessing.
/analyzenow uses the file tree, README, dependency manifests and entry points. For large projects it summarises files first and then combines the summaries (map-reduce).
API changes
POST /api/projects/<id>/uploadreturns 200 when all files were indexed, 207 for partial success and 400 when none were. Unknown project IDs return 404.POST /api/projects/<id>/asksources now includesymbol,score,similarityandmatched_by, and the response includessearch_queryandcontext_found.- New:
POST /api/projects/<id>/ask/streamstreams the answer as Server-Sent Events (sources,token,done). GET /api/projects/<id>/analyzealso returnsfiles_analyzedandmode(fullormap_reduce).- Errors come back as JSON with sensible status codes: 400, 404, 409 (embedding model mismatch), 413 and 502 (model unavailable).
Upgrading from 1.0
pip install -r requirements.txtollama pull nomic-embed-text- Create a new project and upload your code again. Projects indexed with 1.0's embedding model return 409 when you ask questions, because vectors from different models can't be mixed.
- Settings are now environment variables (see the README), for example
CODEWISE_CHAT_MODEL,CODEWISE_NUM_CTXandCODEWISE_TOP_K. - Flask debug mode is off by default (
CODEWISE_DEBUG=1turns it on), and CORS only allowshttp://localhost:5173. SetCODEWISE_CORS_ORIGINSif your frontend runs elsewhere.
Under the hood
backend.pyis now a thin entry point. The logic lives in thecodewise/package (config, files, chunking, embeddings, index, retrieval, llm, store, service, app), so each part can be tested and swapped on its own.- 45 tests (
pytest) cover chunking, file filtering, BM25, prompt building and the API. They use fake models, so Ollama isn't needed. - Retrieval evaluation (
python eval/retrieval_eval.py) reports hit@k and MRR for vector, keyword and hybrid search. On CodeWise's own backend (21 questions, MiniLM fallback embeddings), hybrid search reached 100% hit@5 with an MRR of 0.806, against 0.756 for vector-only and 0.754 for keyword-only. The question set is small and was written by the developer, so treat these numbers as a regression check, not a benchmark. - Generated files (
chroma_data/,node_modules/, local databases, caches) are no longer tracked.
Full diff: e3f6d2b...v2.0