witan-code 0.30.0__tar.gz → 0.31.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {witan_code-0.30.0 → witan_code-0.31.0}/CHANGELOG.md +57 -0
- {witan_code-0.30.0 → witan_code-0.31.0}/PKG-INFO +7 -6
- {witan_code-0.30.0 → witan_code-0.31.0}/README.md +5 -4
- {witan_code-0.30.0 → witan_code-0.31.0}/docs/USER_GUIDE.md +5 -3
- {witan_code-0.30.0 → witan_code-0.31.0}/pyproject.toml +7 -3
- {witan_code-0.30.0 → witan_code-0.31.0}/tests/test_branches.py +132 -0
- {witan_code-0.30.0 → witan_code-0.31.0}/tests/test_context.py +32 -0
- witan_code-0.31.0/tests/test_diff_impact.py +589 -0
- {witan_code-0.30.0 → witan_code-0.31.0}/tests/test_edges.py +9 -2
- {witan_code-0.30.0 → witan_code-0.31.0}/tests/test_maintenance.py +33 -7
- witan_code-0.31.0/tests/test_search_docstrings.py +231 -0
- {witan_code-0.30.0 → witan_code-0.31.0}/tests/test_server.py +43 -0
- {witan_code-0.30.0 → witan_code-0.31.0}/tests/test_setup.py +9 -0
- {witan_code-0.30.0 → witan_code-0.31.0}/tests/test_visualize.py +69 -3
- witan_code-0.31.0/tests/test_why.py +381 -0
- {witan_code-0.30.0 → witan_code-0.31.0}/witan_code/cli.py +364 -18
- {witan_code-0.30.0 → witan_code-0.31.0}/witan_code/config.py +2 -2
- {witan_code-0.30.0 → witan_code-0.31.0}/witan_code/context.py +12 -4
- witan_code-0.31.0/witan_code/diff_impact.py +679 -0
- {witan_code-0.30.0 → witan_code-0.31.0}/witan_code/graph.py +4 -0
- {witan_code-0.30.0 → witan_code-0.31.0}/witan_code/indexer.py +79 -20
- {witan_code-0.30.0 → witan_code-0.31.0}/witan_code/maintenance.py +11 -5
- {witan_code-0.30.0 → witan_code-0.31.0}/witan_code/output.py +9 -1
- {witan_code-0.30.0 → witan_code-0.31.0}/witan_code/queries/bridge.gq +1 -1
- {witan_code-0.30.0 → witan_code-0.31.0}/witan_code/queries/code_read.gq +48 -0
- {witan_code-0.30.0 → witan_code-0.31.0}/witan_code/schema/code-schema.pg +4 -1
- {witan_code-0.30.0 → witan_code-0.31.0}/witan_code/server.py +243 -47
- {witan_code-0.30.0 → witan_code-0.31.0}/witan_code/setup.py +15 -6
- {witan_code-0.30.0 → witan_code-0.31.0}/witan_code/skills/witan-code/SKILL.md +5 -4
- {witan_code-0.30.0 → witan_code-0.31.0}/witan_code/visualize.py +16 -8
- {witan_code-0.30.0 → witan_code-0.31.0}/.gitignore +0 -0
- {witan_code-0.30.0 → witan_code-0.31.0}/changelog.d/README.md +0 -0
- {witan_code-0.30.0 → witan_code-0.31.0}/config/claude.json +0 -0
- {witan_code-0.30.0 → witan_code-0.31.0}/config/copilot.json +0 -0
- {witan_code-0.30.0 → witan_code-0.31.0}/config/pi.json +0 -0
- {witan_code-0.30.0 → witan_code-0.31.0}/conftest.py +0 -0
- {witan_code-0.30.0 → witan_code-0.31.0}/docs/BRANCH_INDEXING.md +0 -0
- {witan_code-0.30.0 → witan_code-0.31.0}/docs/CLI_REFERENCE.md +0 -0
- {witan_code-0.30.0 → witan_code-0.31.0}/docs/EDGE_PRECISION_TIERS.md +0 -0
- {witan_code-0.30.0 → witan_code-0.31.0}/docs/PACKAGE_MAP.md +0 -0
- {witan_code-0.30.0 → witan_code-0.31.0}/docs/STAGE2_STITCHING.md +0 -0
- {witan_code-0.30.0 → witan_code-0.31.0}/docs/SYMBOL_FORMAT.md +0 -0
- {witan_code-0.30.0 → witan_code-0.31.0}/docs/SYMBOL_TABLE.md +0 -0
- {witan_code-0.30.0 → witan_code-0.31.0}/install.sh +0 -0
- {witan_code-0.30.0 → witan_code-0.31.0}/tests/__init__.py +0 -0
- {witan_code-0.30.0 → witan_code-0.31.0}/tests/conftest.py +0 -0
- {witan_code-0.30.0 → witan_code-0.31.0}/tests/test_batched_deletes.py +0 -0
- {witan_code-0.30.0 → witan_code-0.31.0}/tests/test_branches_served.py +0 -0
- {witan_code-0.30.0 → witan_code-0.31.0}/tests/test_bridge.py +0 -0
- {witan_code-0.30.0 → witan_code-0.31.0}/tests/test_chunked_load.py +0 -0
- {witan_code-0.30.0 → witan_code-0.31.0}/tests/test_cli_dispatch.py +0 -0
- {witan_code-0.30.0 → witan_code-0.31.0}/tests/test_cli_help_docstrings.py +0 -0
- {witan_code-0.30.0 → witan_code-0.31.0}/tests/test_cli_hooks.py +0 -0
- {witan_code-0.30.0 → witan_code-0.31.0}/tests/test_cli_output_format.py +0 -0
- {witan_code-0.30.0 → witan_code-0.31.0}/tests/test_cli_selected_target.py +0 -0
- {witan_code-0.30.0 → witan_code-0.31.0}/tests/test_config.py +0 -0
- {witan_code-0.30.0 → witan_code-0.31.0}/tests/test_config_targets.py +0 -0
- {witan_code-0.30.0 → witan_code-0.31.0}/tests/test_crossrepo.py +0 -0
- {witan_code-0.30.0 → witan_code-0.31.0}/tests/test_elicit.py +0 -0
- {witan_code-0.30.0 → witan_code-0.31.0}/tests/test_enrichment.py +0 -0
- {witan_code-0.30.0 → witan_code-0.31.0}/tests/test_github_app.py +0 -0
- {witan_code-0.30.0 → witan_code-0.31.0}/tests/test_graph.py +0 -0
- {witan_code-0.30.0 → witan_code-0.31.0}/tests/test_hooks.py +0 -0
- {witan_code-0.30.0 → witan_code-0.31.0}/tests/test_identity.py +0 -0
- {witan_code-0.30.0 → witan_code-0.31.0}/tests/test_index_failure_diagnostics.py +0 -0
- {witan_code-0.30.0 → witan_code-0.31.0}/tests/test_index_reports_its_store.py +0 -0
- {witan_code-0.30.0 → witan_code-0.31.0}/tests/test_index_requires_a_repo_key.py +0 -0
- {witan_code-0.30.0 → witan_code-0.31.0}/tests/test_indexer.py +0 -0
- {witan_code-0.30.0 → witan_code-0.31.0}/tests/test_indexer_scope.py +0 -0
- {witan_code-0.30.0 → witan_code-0.31.0}/tests/test_ingest.py +0 -0
- {witan_code-0.30.0 → witan_code-0.31.0}/tests/test_languages.py +0 -0
- {witan_code-0.30.0 → witan_code-0.31.0}/tests/test_package_map.py +0 -0
- {witan_code-0.30.0 → witan_code-0.31.0}/tests/test_reaper.py +0 -0
- {witan_code-0.30.0 → witan_code-0.31.0}/tests/test_rebuild_honours_the_repo_key.py +0 -0
- {witan_code-0.30.0 → witan_code-0.31.0}/tests/test_refusal_audit.py +0 -0
- {witan_code-0.30.0 → witan_code-0.31.0}/tests/test_remote_proxy.py +0 -0
- {witan_code-0.30.0 → witan_code-0.31.0}/tests/test_remote_store.py +0 -0
- {witan_code-0.30.0 → witan_code-0.31.0}/tests/test_repo.py +0 -0
- {witan_code-0.30.0 → witan_code-0.31.0}/tests/test_stitch.py +0 -0
- {witan_code-0.30.0 → witan_code-0.31.0}/tests/test_store.py +0 -0
- {witan_code-0.30.0 → witan_code-0.31.0}/tests/test_symbol_table.py +0 -0
- {witan_code-0.30.0 → witan_code-0.31.0}/tests/test_tasks.py +0 -0
- {witan_code-0.30.0 → witan_code-0.31.0}/tests/test_tool_schema.py +0 -0
- {witan_code-0.30.0 → witan_code-0.31.0}/tests/test_views.py +0 -0
- {witan_code-0.30.0 → witan_code-0.31.0}/witan_code/__init__.py +0 -0
- {witan_code-0.30.0 → witan_code-0.31.0}/witan_code/__main__.py +0 -0
- {witan_code-0.30.0 → witan_code-0.31.0}/witan_code/bridge.py +0 -0
- {witan_code-0.30.0 → witan_code-0.31.0}/witan_code/bridge_extractors.py +0 -0
- {witan_code-0.30.0 → witan_code-0.31.0}/witan_code/edges.py +0 -0
- {witan_code-0.30.0 → witan_code-0.31.0}/witan_code/elicit.py +0 -0
- {witan_code-0.30.0 → witan_code-0.31.0}/witan_code/extensions/pi/codegraph.ts +0 -0
- {witan_code-0.30.0 → witan_code-0.31.0}/witan_code/github_app.py +0 -0
- {witan_code-0.30.0 → witan_code-0.31.0}/witan_code/hooks.py +0 -0
- {witan_code-0.30.0 → witan_code-0.31.0}/witan_code/identity.py +0 -0
- {witan_code-0.30.0 → witan_code-0.31.0}/witan_code/ingest.py +0 -0
- {witan_code-0.30.0 → witan_code-0.31.0}/witan_code/package_map.py +0 -0
- {witan_code-0.30.0 → witan_code-0.31.0}/witan_code/queries/code_mutations.gq +0 -0
- {witan_code-0.30.0 → witan_code-0.31.0}/witan_code/queries/delete.gq +0 -0
- {witan_code-0.30.0 → witan_code-0.31.0}/witan_code/queries_ts/bash.scm +0 -0
- {witan_code-0.30.0 → witan_code-0.31.0}/witan_code/queries_ts/hcl.scm +0 -0
- {witan_code-0.30.0 → witan_code-0.31.0}/witan_code/queries_ts/python.scm +0 -0
- {witan_code-0.30.0 → witan_code-0.31.0}/witan_code/queries_ts/sql.scm +0 -0
- {witan_code-0.30.0 → witan_code-0.31.0}/witan_code/queries_ts/typescript.scm +0 -0
- {witan_code-0.30.0 → witan_code-0.31.0}/witan_code/queries_ts/yaml.scm +0 -0
- {witan_code-0.30.0 → witan_code-0.31.0}/witan_code/reaper.py +0 -0
- {witan_code-0.30.0 → witan_code-0.31.0}/witan_code/remote/__init__.py +0 -0
- {witan_code-0.30.0 → witan_code-0.31.0}/witan_code/remote/oidc.py +0 -0
- {witan_code-0.30.0 → witan_code-0.31.0}/witan_code/remote/proxy.py +0 -0
- {witan_code-0.30.0 → witan_code-0.31.0}/witan_code/remote/store.py +0 -0
- {witan_code-0.30.0 → witan_code-0.31.0}/witan_code/repo.py +0 -0
- {witan_code-0.30.0 → witan_code-0.31.0}/witan_code/schema/bridge-schema.pg +0 -0
- {witan_code-0.30.0 → witan_code-0.31.0}/witan_code/selected_target.py +0 -0
- {witan_code-0.30.0 → witan_code-0.31.0}/witan_code/stitch.py +0 -0
- {witan_code-0.30.0 → witan_code-0.31.0}/witan_code/store.py +0 -0
- {witan_code-0.30.0 → witan_code-0.31.0}/witan_code/views.py +0 -0
|
@@ -8,6 +8,63 @@ a MINOR bump may include breaking changes).
|
|
|
8
8
|
|
|
9
9
|
<!-- scriv-insert-here -->
|
|
10
10
|
|
|
11
|
+
## [0.31.0] - 2026-11-13
|
|
12
|
+
|
|
13
|
+
### Added
|
|
14
|
+
|
|
15
|
+
- `witan code why <path>` says whether a file is in the code graph, in the view the `code_*` tools read from its checkout, and if not, which indexer rule left it out (unsupported language, skipped directory, nested checkout, symlinked directory, gitignored) with the fix. An empty `code_*` result reads the same for an unused symbol and for a file the indexer never wrote; this tells the two apart. The rules are the indexer's own filter, now one function both the git-listing and disk-walk paths call, so the explanation cannot drift from what gets indexed. It reads the `--target`'s stores, and refuses (naming `code_transport`) when a remote URL sends the `code_*` reads to a deployment while the code-graph stores are local, since its answer would describe a graph those reads never use.
|
|
16
|
+
|
|
17
|
+
- `code_search_symbol` matches symbol docstrings as well as qualified names, so a query like "rate limiting" finds a symbol whose docstring describes it even when its name does not. A second BM25 run over `Symbol.docstring` is appended after the name run, keeping only the symbols the name run did not return, so a docstring-only match never outranks a name match, across a cross-repo fan-out too. Each run returns up to 50 symbols per store.
|
|
18
|
+
|
|
19
|
+
- `code_callers` takes `direction="callees"` to list the symbols a function calls, following the same `Calls` edges outward. The default, `direction="callers"`, is unchanged. Like the callers query it reads the checkout's branch view for the current repo.
|
|
20
|
+
|
|
21
|
+
- `witan code diff-impact --base origin/main` maps a branch's diff to the symbols it changes, by parsing both sides of each changed file with the indexer's parser (a decorator-only edit maps to the decorated symbol), then lists each symbol's callers, the bindings in other repos that share its env vars, endpoints and packages, the test files that name it (a stand-in for "tests to run", since the graph has no test-to-code edges), and the witan tasks and memories that cite it, plus the tasks claimed on the head branch. Every list carries its total next to what is shown (`--limit`, `--max-items`), changed test files are listed by file rather than looked up, renamed files are listed with a note that every symbol id in them moved, and the notes say what the answer cannot see: an unindexed repo, symbols missing from the index, callers in other files, and callers only this branch adds. Tasks and memories are skipped, with a note, when witan (council) is not installed. Honors `--output-format`. Its in-process lookups are pinned to the base branch's view, so a symbol the branch removed resolves against main even after the branch is indexed.
|
|
22
|
+
- `code_impact`, `code_cross_repo_impact` and `code_symbols_in_file` accept an optional `branch`, with the semantics `code_find_definition` already has: omitted, they follow the checkout's branch view for the current repo as before; `branch="main"` reads the default view from a checkout whose own branch is indexed. On `code_impact` it applies to the root symbol's repo, and on `code_cross_repo_impact` it selects that repo's bridge overlay. The server instructions now say which id-routed tools take `branch`.
|
|
23
|
+
|
|
24
|
+
### Changed
|
|
25
|
+
|
|
26
|
+
- `code_find_definition` and `code_search_symbol` docs no longer contrast their `repo=""` with the witan memory/task tools, which now refuse an empty `repo` and take `all_repos=True` instead. Behaviour is unchanged.
|
|
27
|
+
|
|
28
|
+
- The `witan-code` skill points at `recall(symbol_id=…)` for the memories and
|
|
29
|
+
tasks attached to a symbol, since witan folded `symbol_context` into
|
|
30
|
+
`recall`.
|
|
31
|
+
- `witan code diff-impact` reads each changed symbol's tasks and memories
|
|
32
|
+
through `recall(symbol_id=…, hops=0, include_superseded=True)`. It still
|
|
33
|
+
called the removed `symbol_context`, so it failed on every changed non-test
|
|
34
|
+
symbol when witan was installed.
|
|
35
|
+
|
|
36
|
+
### Fixed
|
|
37
|
+
|
|
38
|
+
- The optimize and cleanup throttle stamps
|
|
39
|
+
(`witan-code-{optimize,cleanup}-<digest>.json`) and the context hook's
|
|
40
|
+
cached bridge verdict (`codegraph-bridge-<digest>.probe`) moved from the bare
|
|
41
|
+
temp dir into witan-code's private per-user state dir, where the reindex
|
|
42
|
+
queue already lives (0700 under `$TMPDIR` on POSIX,
|
|
43
|
+
`%LOCALAPPDATA%\witan-code\state` on Windows). Another user could create a
|
|
44
|
+
predictable name in a shared `TMPDIR` first, as a file pinning a wrong
|
|
45
|
+
bridge verdict or as a symlink the write would follow. If the state dir is
|
|
46
|
+
refused, the hook probes the bridge uncached instead of dropping its block.
|
|
47
|
+
The first Stop hook after upgrading finds neither stamp, so it runs one
|
|
48
|
+
optimize and one `--cleanup-older-than 2d` cleanup that the old stamps might
|
|
49
|
+
have deferred (the cleanup by up to its 7-day window).
|
|
50
|
+
|
|
51
|
+
- `witan --target <name> code doctor` reads that target's code graphs. `doctor` used the config loaded when the server module was imported, which never sees a forwarded `--target`.
|
|
52
|
+
|
|
53
|
+
- `witan-code setup --agent codex` writes Codex's `witan-code` MCP entry as the installed `witan-code serve`, the same CLI its hooks call, instead of a `uvx --from git+…` entry. Which platforms get the CLI entry now follows agent-config-kit's registry: every platform it writes hooks for. Requires agent-config-kit 0.13, the first release with Codex hooks.
|
|
54
|
+
- `witan-code setup` warns when `witan-code` is not on PATH, since the hooks and the `witan-code serve` MCP entry it registers both need it.
|
|
55
|
+
|
|
56
|
+
- `code_repo_dependencies` and the bridge explorer draw the "ol-infrastructure
|
|
57
|
+
deploys repo X" edge again. The extractor has written a repo service anchor
|
|
58
|
+
as the bare repo URI with `sub_kind="repo"` since #7, but the graph builder
|
|
59
|
+
still looked for a `repo:` key prefix and the `all_bindings` read did not
|
|
60
|
+
return `sub_kind`, so no deployed graph ever had a service edge. Image and
|
|
61
|
+
app-name anchors still draw no edge: nothing in the indexed repos yet says
|
|
62
|
+
which repo builds an image.
|
|
63
|
+
|
|
64
|
+
### Notes
|
|
65
|
+
|
|
66
|
+
- `Symbol.docstring` gains `@index` in `code-schema.pg`. On omnigraph 0.15 both `schema plan` (a local store) and `cluster plan` (a cluster) report it as one supported `add_constraint` step, and the apply indexes the docstrings already stored, so no code graph needs a rebuild. A local store gains the index on its next index, through the schema apply that already runs when the schema file changes. A cluster's `code-<repo>` graphs gain it when an omnigraph-server image built with this schema boots and runs `cluster apply`. Until a store has the index, omnigraph 0.15 refuses the docstring run (`T27`). A client reading through a deployed MCP tier (`code_transport = "mcp"`) older than this release is refused too, because the tier looks the query up in its own bundled `code_read.gq`. In both cases `code_search_symbol` returns name matches only and logs `witan.code.search.docstring_search_unavailable`.
|
|
67
|
+
|
|
11
68
|
## [0.30.0] - 2026-11-12
|
|
12
69
|
|
|
13
70
|
### Added
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: witan-code
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.31.0
|
|
4
4
|
Summary: witan-code — tree-sitter code graph + cross-repo bridge (mounts under `witan code`)
|
|
5
5
|
Project-URL: Homepage, https://github.com/mitodl/agent-kit/tree/main/mcp/servers/witan-code
|
|
6
6
|
Project-URL: Repository, https://github.com/mitodl/agent-kit
|
|
@@ -10,7 +10,7 @@ License-Expression: BSD-3-Clause
|
|
|
10
10
|
Keywords: agent,code-graph,coding-agent,mcp,static-analysis,tree-sitter
|
|
11
11
|
Classifier: Programming Language :: Python :: 3
|
|
12
12
|
Requires-Python: >=3.11
|
|
13
|
-
Requires-Dist: agent-config-kit<1,>=0.
|
|
13
|
+
Requires-Dist: agent-config-kit<1,>=0.13
|
|
14
14
|
Requires-Dist: cyclopts<6,>=4
|
|
15
15
|
Requires-Dist: fastmcp<5,>=4
|
|
16
16
|
Requires-Dist: joserfc<2,>=1.0
|
|
@@ -246,8 +246,9 @@ file + a capture→kind map), and any new node types to `_DEF_NODE_TYPES`.
|
|
|
246
246
|
|
|
247
247
|
## Install
|
|
248
248
|
|
|
249
|
-
witan-code is usually installed as part of the `witan` umbrella
|
|
250
|
-
|
|
249
|
+
witan-code is usually installed as part of the `witan` umbrella: one `witan
|
|
250
|
+
serve` mounts witan-code's `code_*` tools whenever witan-code is installed
|
|
251
|
+
alongside it, and `witan setup` registers that one server. See the
|
|
251
252
|
[witan README](../witan/README.md) for the one-step setup.
|
|
252
253
|
|
|
253
254
|
To use witan-code **standalone** (code graph only, no memory/task tools):
|
|
@@ -506,10 +507,10 @@ indexer first).
|
|
|
506
507
|
|------|---------|
|
|
507
508
|
| `code_find_definition(name)` | symbols whose name / qualified name matches |
|
|
508
509
|
| `code_find_references(symbol_id)` | incoming `References` + `Calls` |
|
|
509
|
-
| `code_callers(symbol_id)` | incoming `Calls` |
|
|
510
|
+
| `code_callers(symbol_id, direction="callers")` | incoming `Calls`; `direction="callees"` for outgoing |
|
|
510
511
|
| `code_impact(symbol_id, max_depth=5, max_nodes=200)` | transitive callers via BFS |
|
|
511
512
|
| `code_symbols_in_file(path)` | symbols defined in a file |
|
|
512
|
-
| `code_search_symbol(query)` | BM25 search over symbol qualified names |
|
|
513
|
+
| `code_search_symbol(query)` | BM25 search over symbol qualified names, then docstrings (name matches first) |
|
|
513
514
|
| `code_reindex(path=None)` | index/re-index the repo or a subpath |
|
|
514
515
|
|
|
515
516
|
Cross-repo bridge tools (resolve the shared `_bridge.omni` store; return `[]` /
|
|
@@ -213,8 +213,9 @@ file + a capture→kind map), and any new node types to `_DEF_NODE_TYPES`.
|
|
|
213
213
|
|
|
214
214
|
## Install
|
|
215
215
|
|
|
216
|
-
witan-code is usually installed as part of the `witan` umbrella
|
|
217
|
-
|
|
216
|
+
witan-code is usually installed as part of the `witan` umbrella: one `witan
|
|
217
|
+
serve` mounts witan-code's `code_*` tools whenever witan-code is installed
|
|
218
|
+
alongside it, and `witan setup` registers that one server. See the
|
|
218
219
|
[witan README](../witan/README.md) for the one-step setup.
|
|
219
220
|
|
|
220
221
|
To use witan-code **standalone** (code graph only, no memory/task tools):
|
|
@@ -473,10 +474,10 @@ indexer first).
|
|
|
473
474
|
|------|---------|
|
|
474
475
|
| `code_find_definition(name)` | symbols whose name / qualified name matches |
|
|
475
476
|
| `code_find_references(symbol_id)` | incoming `References` + `Calls` |
|
|
476
|
-
| `code_callers(symbol_id)` | incoming `Calls` |
|
|
477
|
+
| `code_callers(symbol_id, direction="callers")` | incoming `Calls`; `direction="callees"` for outgoing |
|
|
477
478
|
| `code_impact(symbol_id, max_depth=5, max_nodes=200)` | transitive callers via BFS |
|
|
478
479
|
| `code_symbols_in_file(path)` | symbols defined in a file |
|
|
479
|
-
| `code_search_symbol(query)` | BM25 search over symbol qualified names |
|
|
480
|
+
| `code_search_symbol(query)` | BM25 search over symbol qualified names, then docstrings (name matches first) |
|
|
480
481
|
| `code_reindex(path=None)` | index/re-index the repo or a subpath |
|
|
481
482
|
|
|
482
483
|
Cross-repo bridge tools (resolve the shared `_bridge.omni` store; return `[]` /
|
|
@@ -55,9 +55,10 @@ index. See the main [README](../README.md) for the full two-layer table.
|
|
|
55
55
|
|
|
56
56
|
## Installation
|
|
57
57
|
|
|
58
|
-
witan-code is usually installed as part of the `witan` umbrella package
|
|
59
|
-
`witan
|
|
60
|
-
`
|
|
58
|
+
witan-code is usually installed as part of the `witan` umbrella package: one
|
|
59
|
+
`witan serve` mounts witan-code's `code_*` tools whenever witan-code is
|
|
60
|
+
installed alongside it, and `witan setup` registers that one server and
|
|
61
|
+
installs the shared `omnigraph` binary in one step. See the [witan README](../../witan/README.md)
|
|
61
62
|
for that one-step setup.
|
|
62
63
|
|
|
63
64
|
To use witan-code **standalone** (code graph only, no memory/task tools):
|
|
@@ -131,6 +132,7 @@ copy the matching snippet from `config/` into your agent's config — see
|
|
|
131
132
|
|
|
132
133
|
```bash
|
|
133
134
|
code_callers(symbol_id="https://github.com/org/repo#app/client.py::ServiceClient.run")
|
|
135
|
+
code_callers(symbol_id="...", direction="callees") # what it calls
|
|
134
136
|
code_impact(symbol_id="...", max_depth=5, max_nodes=200) # transitive callers
|
|
135
137
|
```
|
|
136
138
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "witan-code"
|
|
3
|
-
version = "0.
|
|
3
|
+
version = "0.31.0"
|
|
4
4
|
description = "witan-code — tree-sitter code graph + cross-repo bridge (mounts under `witan code`)"
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
license = "BSD-3-Clause"
|
|
@@ -30,7 +30,11 @@ dependencies = [
|
|
|
30
30
|
# pi-mcp-adapter is missing when Pi's built-in MCP will load the entry
|
|
31
31
|
# from 0.12.0. Older resolutions import and run, and print the false
|
|
32
32
|
# warning.
|
|
33
|
-
|
|
33
|
+
# >=0.13: Codex hooks (and the codex platform itself) arrive in 0.13.0.
|
|
34
|
+
# `cli_hook_platforms()` reads them from the registry, so an older
|
|
35
|
+
# resolution writes Codex a uvx MCP entry, and `--agent codex` raises
|
|
36
|
+
# KeyError on the missing platform.
|
|
37
|
+
"agent-config-kit>=0.13,<1",
|
|
34
38
|
# `remote`: the ADR-0005 client stack (OIDC device grant + MCP-client
|
|
35
39
|
# proxy) behind `witan-code login` and the read commands' remote mode.
|
|
36
40
|
# Costs nothing extra in practice — fastmcp is already required here and
|
|
@@ -305,7 +309,7 @@ testpaths = ["tests"]
|
|
|
305
309
|
packages = ["witan_code"]
|
|
306
310
|
|
|
307
311
|
[tool.bumpversion]
|
|
308
|
-
current_version = "0.
|
|
312
|
+
current_version = "0.31.0"
|
|
309
313
|
allow_dirty = true
|
|
310
314
|
|
|
311
315
|
[[tool.bumpversion.files]]
|
|
@@ -597,6 +597,48 @@ def test_two_writers_on_one_branch_do_not_overwrite_each_other(tmp_path, monkeyp
|
|
|
597
597
|
assert not _has("act-bob/feature_shared", "alice_only_symbol")
|
|
598
598
|
|
|
599
599
|
|
|
600
|
+
@requires_stack
|
|
601
|
+
def test_callees_follow_the_checkouts_branch_view(tmp_path, monkeypatch):
|
|
602
|
+
"""`code_callers(direction="callees")` routes by symbol id like the callers
|
|
603
|
+
query does, so on a feature branch it reads that branch's view: a call the
|
|
604
|
+
branch added shows up there and nowhere on main."""
|
|
605
|
+
from witan_code import config as cfg_mod
|
|
606
|
+
from witan_code import indexer
|
|
607
|
+
from witan_code import server as srv
|
|
608
|
+
|
|
609
|
+
monkeypatch.setenv("WITAN_REPO", REPO)
|
|
610
|
+
monkeypatch.setenv("WITAN_CODE_DIR", str(tmp_path / "code"))
|
|
611
|
+
monkeypatch.setattr(srv, "cfg", cfg_mod.load())
|
|
612
|
+
|
|
613
|
+
def reset():
|
|
614
|
+
srv._clients.clear()
|
|
615
|
+
srv._store_branches.clear()
|
|
616
|
+
srv._git_context.clear()
|
|
617
|
+
|
|
618
|
+
reset()
|
|
619
|
+
base = _git_repo(tmp_path / "r")
|
|
620
|
+
(base / "svc.py").write_text(SAMPLE)
|
|
621
|
+
indexer.index_path(base, config=srv.cfg)
|
|
622
|
+
|
|
623
|
+
_git(base, "checkout", "-q", "-b", "feature/x")
|
|
624
|
+
(base / "svc.py").write_text(
|
|
625
|
+
SAMPLE.replace("return helper()", "audit()\n return helper()")
|
|
626
|
+
+ "\n\ndef audit():\n return 0\n"
|
|
627
|
+
)
|
|
628
|
+
indexer.index_path(base, config=srv.cfg)
|
|
629
|
+
|
|
630
|
+
run_id = f"{REPO}#svc.py::Service.run"
|
|
631
|
+
monkeypatch.chdir(base)
|
|
632
|
+
reset()
|
|
633
|
+
on_branch = _fn(srv.code_callers)(run_id, direction="callees")
|
|
634
|
+
assert {c["qualified_name"] for c in on_branch} == {"audit", "helper"}
|
|
635
|
+
|
|
636
|
+
_git(base, "checkout", "-q", "main")
|
|
637
|
+
reset()
|
|
638
|
+
on_main = _fn(srv.code_callers)(run_id, direction="callees")
|
|
639
|
+
assert {c["qualified_name"] for c in on_main} == {"helper"}
|
|
640
|
+
|
|
641
|
+
|
|
600
642
|
@requires_stack
|
|
601
643
|
def test_a_reader_can_enumerate_every_writers_view_of_a_branch(tmp_path, monkeypatch):
|
|
602
644
|
"""Isolation and visibility are not in tension: the views are separated by
|
|
@@ -781,3 +823,93 @@ def test_a_branch_name_with_a_slash_is_not_read_as_a_view_name(tmp_path, monkeyp
|
|
|
781
823
|
"slashed_branch_symbol", repo=REPO, branch="feature/new-api"
|
|
782
824
|
)
|
|
783
825
|
assert found, "a raw git branch with a slash must map through sanitization"
|
|
826
|
+
|
|
827
|
+
|
|
828
|
+
# ── `branch` on the id- and file-routed tools ─────────────────────
|
|
829
|
+
#
|
|
830
|
+
# Locally, these tools follow the checkout's branch view once it is indexed.
|
|
831
|
+
# A symbol that branch removed is gone from that view, so a caller asking
|
|
832
|
+
# "what did this removal break" needs to read main: `branch="main"`.
|
|
833
|
+
|
|
834
|
+
MAIN_SVC = SAMPLE + (
|
|
835
|
+
'\n\ndef retired():\n return os.environ["SHARED_URL"] or helper()\n'
|
|
836
|
+
)
|
|
837
|
+
BRANCH_SVC = SAMPLE + "\n\ndef fresh():\n return helper()\n"
|
|
838
|
+
PROVIDER = "https://github.com/test/infra"
|
|
839
|
+
|
|
840
|
+
|
|
841
|
+
@pytest.fixture
|
|
842
|
+
def removal_on_an_indexed_branch(tmp_path, monkeypatch):
|
|
843
|
+
"""`retired` on main, gone on `feature/x` (indexed), `fresh` added there.
|
|
844
|
+
|
|
845
|
+
`retired` reads SHARED_URL, which a second repo provides, so it has a
|
|
846
|
+
cross-repo surface on main and none in the branch's overlay.
|
|
847
|
+
"""
|
|
848
|
+
from witan_code import config as cfg_mod
|
|
849
|
+
from witan_code import indexer
|
|
850
|
+
from witan_code import server as srv
|
|
851
|
+
|
|
852
|
+
monkeypatch.setenv("WITAN_CODE_DIR", str(tmp_path / "code"))
|
|
853
|
+
monkeypatch.setattr(srv, "cfg", cfg_mod.load())
|
|
854
|
+
|
|
855
|
+
infra = tmp_path / "infra"
|
|
856
|
+
infra.mkdir()
|
|
857
|
+
(infra / "Pulumi.QA.yaml").write_text(
|
|
858
|
+
'config:\n app:env_vars:\n SHARED_URL: "https://x.example.com"\n'
|
|
859
|
+
)
|
|
860
|
+
indexer.index_path(infra, repo_override=PROVIDER, config=srv.cfg)
|
|
861
|
+
|
|
862
|
+
monkeypatch.setenv("WITAN_REPO", REPO)
|
|
863
|
+
base = _git_repo(tmp_path / "r")
|
|
864
|
+
(base / "svc.py").write_text("import os\n" + MAIN_SVC)
|
|
865
|
+
indexer.index_path(base, config=srv.cfg)
|
|
866
|
+
_git(base, "checkout", "-q", "-b", "feature/x")
|
|
867
|
+
(base / "svc.py").write_text("import os\n" + BRANCH_SVC)
|
|
868
|
+
indexer.index_path(base, config=srv.cfg)
|
|
869
|
+
|
|
870
|
+
monkeypatch.chdir(base)
|
|
871
|
+
srv._clients.clear()
|
|
872
|
+
srv._store_branches.clear()
|
|
873
|
+
srv._git_context.clear()
|
|
874
|
+
return srv
|
|
875
|
+
|
|
876
|
+
|
|
877
|
+
@requires_stack
|
|
878
|
+
def test_symbols_in_file_reads_the_named_branchs_view(removal_on_an_indexed_branch):
|
|
879
|
+
srv = removal_on_an_indexed_branch
|
|
880
|
+
|
|
881
|
+
def names(**kwargs):
|
|
882
|
+
rows = _fn(srv.code_symbols_in_file)("svc.py", repo=REPO, **kwargs)
|
|
883
|
+
return {r["qualified_name"] for r in rows}
|
|
884
|
+
|
|
885
|
+
on_branch, on_main = names(), names(branch="main")
|
|
886
|
+
assert "fresh" in on_branch and "retired" not in on_branch
|
|
887
|
+
assert "retired" in on_main and "fresh" not in on_main
|
|
888
|
+
|
|
889
|
+
|
|
890
|
+
@requires_stack
|
|
891
|
+
def test_impact_walks_the_named_branchs_view(removal_on_an_indexed_branch):
|
|
892
|
+
srv = removal_on_an_indexed_branch
|
|
893
|
+
helper = f"{REPO}#svc.py::helper"
|
|
894
|
+
|
|
895
|
+
def callers(**kwargs):
|
|
896
|
+
impact = _fn(srv.code_impact)(helper, max_depth=1, **kwargs)
|
|
897
|
+
return {c["qualified_name"] for c in impact["impacted"]}
|
|
898
|
+
|
|
899
|
+
on_branch, on_main = callers(), callers(branch="main")
|
|
900
|
+
assert "fresh" in on_branch and "retired" not in on_branch
|
|
901
|
+
assert "retired" in on_main and "fresh" not in on_main
|
|
902
|
+
|
|
903
|
+
|
|
904
|
+
@requires_stack
|
|
905
|
+
def test_cross_repo_impact_reads_the_named_branchs_overlay(
|
|
906
|
+
removal_on_an_indexed_branch,
|
|
907
|
+
):
|
|
908
|
+
srv = removal_on_an_indexed_branch
|
|
909
|
+
retired = f"{REPO}#svc.py::retired"
|
|
910
|
+
|
|
911
|
+
on_branch = _fn(srv.code_cross_repo_impact)(retired)
|
|
912
|
+
assert on_branch["cross_repo"] == [], "the branch's overlay no longer has it"
|
|
913
|
+
|
|
914
|
+
on_main = _fn(srv.code_cross_repo_impact)(retired, branch="main")
|
|
915
|
+
assert {b["repo"] for b in on_main["cross_repo"]} == {PROVIDER}
|
|
@@ -293,8 +293,13 @@ def test_the_bridge_verdict_is_cached_across_processes(tmp_path, monkeypatch):
|
|
|
293
293
|
(code_dir / "_bridge.omni").mkdir(parents=True)
|
|
294
294
|
monkeypatch.setenv("WITAN_CODE_DIR", str(code_dir))
|
|
295
295
|
monkeypatch.setenv("TMPDIR", str(tmp_path))
|
|
296
|
+
monkeypatch.setattr(tempfile, "tempdir", str(tmp_path))
|
|
297
|
+
monkeypatch.setenv("LOCALAPPDATA", str(tmp_path))
|
|
296
298
|
cfg = cfg_mod.load()
|
|
297
299
|
|
|
300
|
+
# In the private state dir, not the bare temp dir another user can write.
|
|
301
|
+
assert context._bridge_probe_path(cfg).parent == context.state_dir()
|
|
302
|
+
|
|
298
303
|
probes = []
|
|
299
304
|
|
|
300
305
|
def _probe(ref, config=None, *, bridge=False):
|
|
@@ -318,6 +323,33 @@ def test_the_bridge_verdict_is_cached_across_processes(tmp_path, monkeypatch):
|
|
|
318
323
|
assert len(probes) == 2
|
|
319
324
|
|
|
320
325
|
|
|
326
|
+
def test_a_refused_state_dir_probes_uncached(tmp_path, monkeypatch):
|
|
327
|
+
"""state_dir() raises when its directory is not ours. The verdict must
|
|
328
|
+
still come back, uncached, rather than the raise blanking the block."""
|
|
329
|
+
from witan_code import config as cfg_mod
|
|
330
|
+
|
|
331
|
+
code_dir = tmp_path / "code"
|
|
332
|
+
(code_dir / "_bridge.omni").mkdir(parents=True)
|
|
333
|
+
monkeypatch.setenv("WITAN_CODE_DIR", str(code_dir))
|
|
334
|
+
cfg = cfg_mod.load()
|
|
335
|
+
|
|
336
|
+
def _refused():
|
|
337
|
+
raise PermissionError("not a directory owned by this user")
|
|
338
|
+
|
|
339
|
+
monkeypatch.setattr(context, "state_dir", _refused)
|
|
340
|
+
probes = []
|
|
341
|
+
|
|
342
|
+
def _probe(ref, config=None, *, bridge=False):
|
|
343
|
+
probes.append(ref)
|
|
344
|
+
return context.store_module.StoreHealth(ref, None, error="stale")
|
|
345
|
+
|
|
346
|
+
monkeypatch.setattr(context.store_module, "store_health", _probe)
|
|
347
|
+
|
|
348
|
+
assert context._bridge_ok(cfg) is False
|
|
349
|
+
assert context._bridge_ok(cfg) is False
|
|
350
|
+
assert len(probes) == 2
|
|
351
|
+
|
|
352
|
+
|
|
321
353
|
def test_lock_path_does_not_collide_on_sanitization(tmp_path, monkeypatch):
|
|
322
354
|
monkeypatch.setattr(tempfile, "tempdir", str(tmp_path))
|
|
323
355
|
|