Skip to content

Releases

CodeWise 3.0 — Import, streaming and code relationships

Choose a tag to compare

@shekharsanskar9 shekharsanskar9 released this 27 Sep 15:15

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.py are 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.
  • .gitignore support. .gitignore files in an uploaded folder or zip are applied to the other files, including nested ones.
  • Zip archives. A .zip upload 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. Set CODEWISE_GITHUB_TOKEN for 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 on store.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.py asks 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.jsonl records real questions and answers, off by default. Answers cut short with Stop are marked "complete": false. python eval/draft_from_log.py turns the log into a draft test set for review.

API changes

  • New: POST /api/projects/<id>/import/github with 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>/upload accepts .zip files and relative paths. The response adds summary: {indexed, skipped, failed}, and each result says whether the file was skipped.
  • /ask responses, and the sources event of /ask/stream, include relations: the symbols and files the relationships section covered.

Upgrading from 2.0

  1. pip install -r requirements.txt, which adds pathspec for .gitignore matching.
  2. 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.
  3. Re-upload existing projects to get relationship answers. Projects indexed with 2.0 still work for normal questions but have no code graph.
  4. 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 save in 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.json were 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) and codewise/relations.py (question → relationships → prompt and retrieval).
  • Frontend helpers: frontend/src/lib/uploads.js (folder traversal, filtering, batching) and frontend/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_modules and venv, 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 calls replace_file?" found the real caller.

Full diff: v2.0...v3.0

CodeWise 2.0 — RAG pipeline rework

Choose a tag to compare

@shekharsanskar9 shekharsanskar9 released this 27 Sep 15:15

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-text via Ollama, and embeds each chunk together with a File / Symbol / Lines header. 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_case and camelCase are 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/ and venv/ 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.py and tests/utils.py stay distinct.

Prompting

  • num_ctx is 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 system messages 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.
  • /analyze now 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>/upload returns 200 when all files were indexed, 207 for partial success and 400 when none were. Unknown project IDs return 404.
  • POST /api/projects/<id>/ask sources now include symbol, score, similarity and matched_by, and the response includes search_query and context_found.
  • New: POST /api/projects/<id>/ask/stream streams the answer as Server-Sent Events (sources, token, done).
  • GET /api/projects/<id>/analyze also returns files_analyzed and mode (full or map_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

  1. pip install -r requirements.txt
  2. ollama pull nomic-embed-text
  3. 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.
  4. Settings are now environment variables (see the README), for example CODEWISE_CHAT_MODEL, CODEWISE_NUM_CTX and CODEWISE_TOP_K.
  5. Flask debug mode is off by default (CODEWISE_DEBUG=1 turns it on), and CORS only allows http://localhost:5173. Set CODEWISE_CORS_ORIGINS if your frontend runs elsewhere.

Under the hood

  • backend.py is now a thin entry point. The logic lives in the codewise/ 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