Skip to content

CodeWise 3.0 — Import, streaming and code relationships

Latest

Choose a tag to compare

@shekharsanskar9 shekharsanskar9 released this 27 Sep 15:15
· 4 commits to main since this release

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