wikifier 4.5.1__tar.gz → 4.5.3__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.
Files changed (49) hide show
  1. wikifier-4.5.3/PKG-INFO +157 -0
  2. wikifier-4.5.3/README.md +125 -0
  3. {wikifier-4.5.1 → wikifier-4.5.3}/skills/run.md +50 -20
  4. wikifier-4.5.3/tests/test_gap_closure.py +128 -0
  5. wikifier-4.5.3/tests/test_selftest_wrappers.py +39 -0
  6. {wikifier-4.5.1 → wikifier-4.5.3}/wikifier/__init__.py +15 -5
  7. {wikifier-4.5.1 → wikifier-4.5.3}/wikifier/cli.py +180 -21
  8. {wikifier-4.5.1 → wikifier-4.5.3}/wikifier/contracts.py +0 -227
  9. {wikifier-4.5.1 → wikifier-4.5.3}/wikifier/daemon.py +37 -9
  10. {wikifier-4.5.1 → wikifier-4.5.3}/wikifier/health.py +48 -15
  11. {wikifier-4.5.1 → wikifier-4.5.3}/wikifier/import_cache.py +87 -54
  12. {wikifier-4.5.1 → wikifier-4.5.3}/wikifier/mcp/server.py +79 -115
  13. {wikifier-4.5.1 → wikifier-4.5.3}/wikifier/parsers/bree.py +9 -29
  14. {wikifier-4.5.1 → wikifier-4.5.3}/wikifier/parsers/cdia.py +0 -112
  15. {wikifier-4.5.1 → wikifier-4.5.3}/wikifier/parsers/javascript.py +23 -331
  16. {wikifier-4.5.1 → wikifier-4.5.3}/wikifier/parsers/python.py +0 -44
  17. {wikifier-4.5.1 → wikifier-4.5.3}/wikifier/resolution.py +0 -142
  18. {wikifier-4.5.1 → wikifier-4.5.3}/wikifier/scripts/wikifier.sh +50 -11
  19. wikifier-4.5.3/wikifier.egg-info/PKG-INFO +157 -0
  20. {wikifier-4.5.1 → wikifier-4.5.3}/wikifier.egg-info/SOURCES.txt +2 -0
  21. wikifier-4.5.1/PKG-INFO +0 -169
  22. wikifier-4.5.1/README.md +0 -137
  23. wikifier-4.5.1/wikifier.egg-info/PKG-INFO +0 -169
  24. {wikifier-4.5.1 → wikifier-4.5.3}/CONTRIBUTING.md +0 -0
  25. {wikifier-4.5.1 → wikifier-4.5.3}/LICENSE +0 -0
  26. {wikifier-4.5.1 → wikifier-4.5.3}/MANIFEST.in +0 -0
  27. {wikifier-4.5.1 → wikifier-4.5.3}/diagnostics.html +0 -0
  28. {wikifier-4.5.1 → wikifier-4.5.3}/docs/spec.md +0 -0
  29. {wikifier-4.5.1 → wikifier-4.5.3}/index.html +0 -0
  30. {wikifier-4.5.1 → wikifier-4.5.3}/pyproject.toml +0 -0
  31. {wikifier-4.5.1 → wikifier-4.5.3}/setup.cfg +0 -0
  32. {wikifier-4.5.1 → wikifier-4.5.3}/tests/test_barrel_invalidation.py +0 -0
  33. {wikifier-4.5.1 → wikifier-4.5.3}/tests/test_health.py +0 -0
  34. {wikifier-4.5.1 → wikifier-4.5.3}/tests/test_import_cache.py +0 -0
  35. {wikifier-4.5.1 → wikifier-4.5.3}/tests/test_parsers.py +0 -0
  36. {wikifier-4.5.1 → wikifier-4.5.3}/wikifier/__main__.py +0 -0
  37. {wikifier-4.5.1 → wikifier-4.5.3}/wikifier/diagnostics.py +0 -0
  38. {wikifier-4.5.1 → wikifier-4.5.3}/wikifier/index.html +0 -0
  39. {wikifier-4.5.1 → wikifier-4.5.3}/wikifier/library.py +0 -0
  40. {wikifier-4.5.1 → wikifier-4.5.3}/wikifier/locking.py +0 -0
  41. {wikifier-4.5.1 → wikifier-4.5.3}/wikifier/mcp/__init__.py +0 -0
  42. {wikifier-4.5.1 → wikifier-4.5.3}/wikifier/parsers/__init__.py +0 -0
  43. {wikifier-4.5.1 → wikifier-4.5.3}/wikifier/scripts/wikifier.bat +0 -0
  44. {wikifier-4.5.1 → wikifier-4.5.3}/wikifier/scripts/wikifier.ps1 +0 -0
  45. {wikifier-4.5.1 → wikifier-4.5.3}/wikifier/serve.py +0 -0
  46. {wikifier-4.5.1 → wikifier-4.5.3}/wikifier.egg-info/dependency_links.txt +0 -0
  47. {wikifier-4.5.1 → wikifier-4.5.3}/wikifier.egg-info/entry_points.txt +0 -0
  48. {wikifier-4.5.1 → wikifier-4.5.3}/wikifier.egg-info/requires.txt +0 -0
  49. {wikifier-4.5.1 → wikifier-4.5.3}/wikifier.egg-info/top_level.txt +0 -0
@@ -0,0 +1,157 @@
1
+ Metadata-Version: 2.4
2
+ Name: wikifier
3
+ Version: 4.5.3
4
+ Summary: Zero-dependency agent-to-agent codebase wiki for LLMs and AI agents. Autonomously maintained via record-change and mark-green for token-efficient lookup of files, dependencies, health, and summaries — across tiny scripts to 50k+ monorepos. Optional MCP server with rich tools for agents.
5
+ Author-email: Aron Amos <aron@example.com>
6
+ Maintainer: Aron Amos
7
+ License: MIT
8
+ Project-URL: Homepage, https://github.com/IronAdamant/wikifier
9
+ Project-URL: Repository, https://github.com/IronAdamant/wikifier
10
+ Project-URL: Documentation, https://github.com/IronAdamant/wikifier#readme
11
+ Project-URL: Bug Tracker, https://github.com/IronAdamant/wikifier/issues
12
+ Keywords: wiki,documentation,llm,agent,mcp,codebase,health-matrix,zero-dependency,shell,token-efficient,autonomous,record-change,mark-green,agent-wiki,llm-tools,dependency-graph,monorepo
13
+ Classifier: Development Status :: 4 - Beta
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: License :: OSI Approved :: MIT License
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3.8
18
+ Classifier: Programming Language :: Python :: 3.9
19
+ Classifier: Programming Language :: Python :: 3.10
20
+ Classifier: Programming Language :: Python :: 3.11
21
+ Classifier: Programming Language :: Python :: 3.12
22
+ Classifier: Operating System :: OS Independent
23
+ Classifier: Topic :: Software Development :: Documentation
24
+ Classifier: Topic :: Software Development :: Version Control
25
+ Classifier: Topic :: Text Processing :: Markup :: Markdown
26
+ Requires-Python: >=3.8
27
+ Description-Content-Type: text/markdown
28
+ License-File: LICENSE
29
+ Provides-Extra: mcp
30
+ Requires-Dist: mcp>=1.0.0; extra == "mcp"
31
+ Dynamic: license-file
32
+
33
+ # Wikifier
34
+
35
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
36
+ [![PyPI version](https://img.shields.io/pypi/v/wikifier.svg)](https://pypi.org/project/wikifier/)
37
+ [![GitHub Stars](https://img.shields.io/github/stars/IronAdamant/wikifier?style=social)](https://github.com/IronAdamant/wikifier/stargazers)
38
+
39
+ **A zero-dependency codebase wiki for AI agents** — token-efficient maps so LLMs look things up instead of re-reading full sources.
40
+
41
+ Wikifier is an **agent-to-agent** tool: it builds a living map of a project (health matrix, dependency graph, short file summaries) and agents keep that map current as they work. Humans can peek via a small dashboard; the product is the agent loop, not a general docs site or IDE.
42
+
43
+ Works from small scripts to large monorepos. **Deep import maps** cover **Python + JavaScript/TypeScript** (barrels, cycles, incremental updates). Other languages can still use health/journal/watch; they won’t get full import graphs until a parser exists.
44
+
45
+ ## Why
46
+
47
+ Context windows are finite. Re-reading a large file to answer “what is this and who depends on it?” wastes tokens.
48
+
49
+ | Artifact | Role |
50
+ |----------|------|
51
+ | `file_health.md` | 🟢 / 🟡 / 🔴 matrix — what to trust, what to fix first |
52
+ | `library.md` | File tree, Mermaid dependency map, import tables, cycles + confidence |
53
+ | `*.wiki.md` | Short per-file “what this is for” notes (**agent-maintained** prose) |
54
+ | `journal/` + `pending_updates.md` | Semantic *why* trail + work queue (audit, **not** a full issue tracker) |
55
+
56
+ **Map first, wiki depth second:** `update-maps` builds the structural map automatically. Rich per-file wiki text is filled by agents as they work — not a free full-repo “understand everything” pass on init.
57
+
58
+ ## First run (bootstrap the map)
59
+
60
+ ```bash
61
+ pip install wikifier # pure Python stdlib core — no runtime deps
62
+ pip install wikifier[mcp] # optional Model Context Protocol (MCP) server
63
+
64
+ cd /path/to/your/project
65
+ wikifier init # seeds + human index.html
66
+ wikifier update-maps # full structural map → library.md + import cache
67
+ wikifier health --summary # matrix counts
68
+ wikifier suggest-next # or MCP suggest_next_actions — 🔴/🟡 only
69
+ ```
70
+
71
+ Always set an explicit root for external trees: `WIKIFIER_PROJECT_ROOT=/abs/path wikifier …`
72
+
73
+ ## Steady state (only touch what needs it)
74
+
75
+ Full protocol: [`skills/run.md`](skills/run.md).
76
+
77
+ ```bash
78
+ wikifier check-changes # yellow dirty files; red ghosts (missing paths)
79
+ # prioritize 🔴 then 🟡 — do NOT re-wiki 🟢 Green files
80
+ # ... edit only those sources ...
81
+ wikifier record-change "path/file.py" "why this changed" # required
82
+ # ... refresh that file’s wiki summary only ...
83
+ wikifier mark-green "path/file.py"
84
+ wikifier update-maps # only if imports/structure changed
85
+ # removals:
86
+ wikifier record-deletion "path/gone.py" "why removed"
87
+ ```
88
+
89
+ MCP **Core 6** (start every session): `get_project_status`, `check_changes`, `get_files_needing_attention`, `get_file_wiki`, `suggest_next_actions`, `record_change` / `mark_green`. Intel as needed: `get_dependencies`, `get_dependents`, `get_cycles`. Always pass `project_root=` for external trees.
90
+
91
+ ## What you get
92
+
93
+ - **Import analysis** — Python + JS/TS (ESM, CommonJS, dynamic imports, path aliases, package exports); per-edge confidence; name-routed barrel expansion (precise leaves, not edge explosion)
94
+ - **Incremental pipeline** — pure-Python `update-maps`: dirty parse → import cache → reverse deps → cycles → `library.md`
95
+ - **Selective agent work** — health + suggest bias to 🔴/🟡 only; ACS *actionable* low-conf excludes stdlib/external noise
96
+ - **Scale** — reverse index + barrel invalidation so one edit doesn’t re-scan the monorepo
97
+ - **MCP tools** — optional server for Claude, Cursor, Cline, and other MCP clients
98
+ - **Zero core dependencies** — stdlib only; forks can add their own stack on top
99
+ - **Agent navigability** — short **AGENT MAP** docstrings on core modules; self-tests under `tests/` (not buried in parsers)
100
+
101
+ ## Performance (measured)
102
+
103
+ | Project | Scale | Full `update-maps` |
104
+ |---------|-------|--------------------|
105
+ | llama_index | ~3.8k Python files | ~8.5s |
106
+ | Babylon.js | ~3.9k TS files, barrel-heavy | ~4.5 min (scoped re-runs ~80s) |
107
+ | Large trees (e.g. LLVM-scale) | tens of thousands of files | candidate scan in seconds |
108
+
109
+ Tests: `python -m unittest discover tests` (stdlib only).
110
+
111
+ ## Commands
112
+
113
+ | Command | Purpose |
114
+ |---------|---------|
115
+ | `wikifier init [--target DIR]` | Bootstrap project + human `index.html` |
116
+ | `wikifier check-changes` | Incremental scan → health / pending |
117
+ | `wikifier record-change <file> "reason"` | Log *why* (required after edits) |
118
+ | `wikifier mark-green <file>` | Mark wiki current |
119
+ | `wikifier record-deletion <file> "reason"` | Mark removed paths 🔴 + prune barrel refs |
120
+ | `wikifier suggest-next` | Next actions (🔴/🟡 only) |
121
+ | `wikifier update-maps [--directory=src/] [--max-files=N]` | Rebuild graph + `library.md` |
122
+ | `wikifier health [--summary\|--json]` | Health matrix (machine-friendly flags) |
123
+ | `wikifier validate` | Missing wiki rows + ghost paths |
124
+ | `wikifier cycles` | Circular deps + break hints |
125
+ | `wikifier monitor` / `daemon` | Background maintenance (`WIKIFIER_DAEMON_MAPS=0` for check-only) |
126
+ | `wikifier serve` | Localhost dashboard with Run/Stop |
127
+
128
+ Library: `from wikifier import check_changes, record_change, mark_green, suggest_next_actions, update_maps, health`.
129
+
130
+ ## MCP
131
+
132
+ ```bash
133
+ WIKIFIER_PROJECT_ROOT=/abs/path/to/project wikifier-mcp
134
+ # or: python3 -m wikifier.mcp.server
135
+ ```
136
+
137
+ Setup and tool list: [`wikifier/mcp/README.md`](wikifier/mcp/README.md).
138
+
139
+ ## Human dashboard (secondary)
140
+
141
+ ![Wikifier dashboard — file tree, health pills, local Run/Stop](https://raw.githubusercontent.com/IronAdamant/wikifier/main/screenshot/front_page_review.png)
142
+
143
+ `wikifier init` drops a single `index.html`. Prefer **`wikifier serve`** (e.g. http://localhost:8787/index.html) — `file://` can’t load project files. The markdown artifacts and CLI/MCP tools stay the source of truth; the UI is a read-only window.
144
+
145
+ ## Scope
146
+
147
+ **In:** agent-maintained codebase wiki, dependency intelligence, token-saving lookup for LLMs and coding agents.
148
+ **Out:** general human documentation systems, IDE plugins, “docs for everyone” product growth.
149
+
150
+ **Agent navigability:** Prefer protocol ([`skills/run.md`](skills/run.md)) + MCP Core 6 over reading 20k LOC of parsers/cache. Production modules carry a short **AGENT MAP** docstring; self-tests live under `tests/` and `tests/selftest/`, not inline at the bottom of parsers.
151
+
152
+ ## Links
153
+
154
+ - [PyPI](https://pypi.org/project/wikifier/) · [GitHub](https://github.com/IronAdamant/wikifier)
155
+ - Agent protocol: [`skills/run.md`](skills/run.md)
156
+ - Changelog: [`CHANGELOG.md`](CHANGELOG.md)
157
+ - Dogfood notes: `Findings/`
@@ -0,0 +1,125 @@
1
+ # Wikifier
2
+
3
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
4
+ [![PyPI version](https://img.shields.io/pypi/v/wikifier.svg)](https://pypi.org/project/wikifier/)
5
+ [![GitHub Stars](https://img.shields.io/github/stars/IronAdamant/wikifier?style=social)](https://github.com/IronAdamant/wikifier/stargazers)
6
+
7
+ **A zero-dependency codebase wiki for AI agents** — token-efficient maps so LLMs look things up instead of re-reading full sources.
8
+
9
+ Wikifier is an **agent-to-agent** tool: it builds a living map of a project (health matrix, dependency graph, short file summaries) and agents keep that map current as they work. Humans can peek via a small dashboard; the product is the agent loop, not a general docs site or IDE.
10
+
11
+ Works from small scripts to large monorepos. **Deep import maps** cover **Python + JavaScript/TypeScript** (barrels, cycles, incremental updates). Other languages can still use health/journal/watch; they won’t get full import graphs until a parser exists.
12
+
13
+ ## Why
14
+
15
+ Context windows are finite. Re-reading a large file to answer “what is this and who depends on it?” wastes tokens.
16
+
17
+ | Artifact | Role |
18
+ |----------|------|
19
+ | `file_health.md` | 🟢 / 🟡 / 🔴 matrix — what to trust, what to fix first |
20
+ | `library.md` | File tree, Mermaid dependency map, import tables, cycles + confidence |
21
+ | `*.wiki.md` | Short per-file “what this is for” notes (**agent-maintained** prose) |
22
+ | `journal/` + `pending_updates.md` | Semantic *why* trail + work queue (audit, **not** a full issue tracker) |
23
+
24
+ **Map first, wiki depth second:** `update-maps` builds the structural map automatically. Rich per-file wiki text is filled by agents as they work — not a free full-repo “understand everything” pass on init.
25
+
26
+ ## First run (bootstrap the map)
27
+
28
+ ```bash
29
+ pip install wikifier # pure Python stdlib core — no runtime deps
30
+ pip install wikifier[mcp] # optional Model Context Protocol (MCP) server
31
+
32
+ cd /path/to/your/project
33
+ wikifier init # seeds + human index.html
34
+ wikifier update-maps # full structural map → library.md + import cache
35
+ wikifier health --summary # matrix counts
36
+ wikifier suggest-next # or MCP suggest_next_actions — 🔴/🟡 only
37
+ ```
38
+
39
+ Always set an explicit root for external trees: `WIKIFIER_PROJECT_ROOT=/abs/path wikifier …`
40
+
41
+ ## Steady state (only touch what needs it)
42
+
43
+ Full protocol: [`skills/run.md`](skills/run.md).
44
+
45
+ ```bash
46
+ wikifier check-changes # yellow dirty files; red ghosts (missing paths)
47
+ # prioritize 🔴 then 🟡 — do NOT re-wiki 🟢 Green files
48
+ # ... edit only those sources ...
49
+ wikifier record-change "path/file.py" "why this changed" # required
50
+ # ... refresh that file’s wiki summary only ...
51
+ wikifier mark-green "path/file.py"
52
+ wikifier update-maps # only if imports/structure changed
53
+ # removals:
54
+ wikifier record-deletion "path/gone.py" "why removed"
55
+ ```
56
+
57
+ MCP **Core 6** (start every session): `get_project_status`, `check_changes`, `get_files_needing_attention`, `get_file_wiki`, `suggest_next_actions`, `record_change` / `mark_green`. Intel as needed: `get_dependencies`, `get_dependents`, `get_cycles`. Always pass `project_root=` for external trees.
58
+
59
+ ## What you get
60
+
61
+ - **Import analysis** — Python + JS/TS (ESM, CommonJS, dynamic imports, path aliases, package exports); per-edge confidence; name-routed barrel expansion (precise leaves, not edge explosion)
62
+ - **Incremental pipeline** — pure-Python `update-maps`: dirty parse → import cache → reverse deps → cycles → `library.md`
63
+ - **Selective agent work** — health + suggest bias to 🔴/🟡 only; ACS *actionable* low-conf excludes stdlib/external noise
64
+ - **Scale** — reverse index + barrel invalidation so one edit doesn’t re-scan the monorepo
65
+ - **MCP tools** — optional server for Claude, Cursor, Cline, and other MCP clients
66
+ - **Zero core dependencies** — stdlib only; forks can add their own stack on top
67
+ - **Agent navigability** — short **AGENT MAP** docstrings on core modules; self-tests under `tests/` (not buried in parsers)
68
+
69
+ ## Performance (measured)
70
+
71
+ | Project | Scale | Full `update-maps` |
72
+ |---------|-------|--------------------|
73
+ | llama_index | ~3.8k Python files | ~8.5s |
74
+ | Babylon.js | ~3.9k TS files, barrel-heavy | ~4.5 min (scoped re-runs ~80s) |
75
+ | Large trees (e.g. LLVM-scale) | tens of thousands of files | candidate scan in seconds |
76
+
77
+ Tests: `python -m unittest discover tests` (stdlib only).
78
+
79
+ ## Commands
80
+
81
+ | Command | Purpose |
82
+ |---------|---------|
83
+ | `wikifier init [--target DIR]` | Bootstrap project + human `index.html` |
84
+ | `wikifier check-changes` | Incremental scan → health / pending |
85
+ | `wikifier record-change <file> "reason"` | Log *why* (required after edits) |
86
+ | `wikifier mark-green <file>` | Mark wiki current |
87
+ | `wikifier record-deletion <file> "reason"` | Mark removed paths 🔴 + prune barrel refs |
88
+ | `wikifier suggest-next` | Next actions (🔴/🟡 only) |
89
+ | `wikifier update-maps [--directory=src/] [--max-files=N]` | Rebuild graph + `library.md` |
90
+ | `wikifier health [--summary\|--json]` | Health matrix (machine-friendly flags) |
91
+ | `wikifier validate` | Missing wiki rows + ghost paths |
92
+ | `wikifier cycles` | Circular deps + break hints |
93
+ | `wikifier monitor` / `daemon` | Background maintenance (`WIKIFIER_DAEMON_MAPS=0` for check-only) |
94
+ | `wikifier serve` | Localhost dashboard with Run/Stop |
95
+
96
+ Library: `from wikifier import check_changes, record_change, mark_green, suggest_next_actions, update_maps, health`.
97
+
98
+ ## MCP
99
+
100
+ ```bash
101
+ WIKIFIER_PROJECT_ROOT=/abs/path/to/project wikifier-mcp
102
+ # or: python3 -m wikifier.mcp.server
103
+ ```
104
+
105
+ Setup and tool list: [`wikifier/mcp/README.md`](wikifier/mcp/README.md).
106
+
107
+ ## Human dashboard (secondary)
108
+
109
+ ![Wikifier dashboard — file tree, health pills, local Run/Stop](https://raw.githubusercontent.com/IronAdamant/wikifier/main/screenshot/front_page_review.png)
110
+
111
+ `wikifier init` drops a single `index.html`. Prefer **`wikifier serve`** (e.g. http://localhost:8787/index.html) — `file://` can’t load project files. The markdown artifacts and CLI/MCP tools stay the source of truth; the UI is a read-only window.
112
+
113
+ ## Scope
114
+
115
+ **In:** agent-maintained codebase wiki, dependency intelligence, token-saving lookup for LLMs and coding agents.
116
+ **Out:** general human documentation systems, IDE plugins, “docs for everyone” product growth.
117
+
118
+ **Agent navigability:** Prefer protocol ([`skills/run.md`](skills/run.md)) + MCP Core 6 over reading 20k LOC of parsers/cache. Production modules carry a short **AGENT MAP** docstring; self-tests live under `tests/` and `tests/selftest/`, not inline at the bottom of parsers.
119
+
120
+ ## Links
121
+
122
+ - [PyPI](https://pypi.org/project/wikifier/) · [GitHub](https://github.com/IronAdamant/wikifier)
123
+ - Agent protocol: [`skills/run.md`](skills/run.md)
124
+ - Changelog: [`CHANGELOG.md`](CHANGELOG.md)
125
+ - Dogfood notes: `Findings/`
@@ -2,10 +2,19 @@
2
2
 
3
3
  **Formerly "Wikifier Skills & Commands". This is the authoritative, versioned specification for agent behavior when using Wikifier.**
4
4
 
5
- **Version**: v0.6 (v4.2.0 real-pipeline + reliability update)
6
- **Date**: 2026-06-10
5
+ **Version**: v0.6 (v4.2.0 real-pipeline + reliability update; package current **4.5.x**)
6
+ **Date**: 2026-06-10 (package notes refreshed 2026-07-09; gap-closure contract 2026-07-09)
7
7
  **Status**: Active. Supersedes v0.5.
8
- **See also**: `README.md` (Intended Use section: strictly agent-to-agent wiki for token saving), M5-Dogfood-Assessment-Report.md, Findings/2026-06-10-Dogfood-Refactor-Validation.md, and the library in wikifier/.
8
+ **See also**: `README.md`, `Findings/gap-closure-report.md`, and the library in wikifier/.
9
+
10
+ **Package 4.5.x + gap-closure notes (additive; protocol still v0.6):**
11
+ - File Tree + `wikifier serve`; MCP status/attention use library + emoji (not `[GREEN]` tags).
12
+ - **First-run:** `init` → `update-maps` → `health --summary` → `suggest_next_actions`. Map is automatic; wiki *prose* is agent-filled over time.
13
+ - **Steady-state selective work:** only 🔴/🟡 (never re-wiki 🟢 unless required). ACS suggestions use `actionable_low_conf_edges` (stdlib/external bare demoted).
14
+ - **Deletions:** `record-deletion` + check-changes ghost detection (missing paths → Red DELETED).
15
+ - **Languages:** deep import maps = Python + JS/TS. journal/pending = audit queue, not Jira.
16
+ - **Monitor:** optional background `monitor`/`daemon` for mtime heartbeat; agents still own wiki/mark-green.
17
+ - Health module: use `importlib.import_module("wikifier.health")` or `wikifier.health_module` — `from wikifier import health` is the *function*.
9
18
 
10
19
  **v0.6 migration notes (packages v4.2.0–v4.3.0)** — changes are additive or strictly-better defaults; v0.5 agent behavior keeps working:
11
20
  - `update-maps` (CLI) now runs the **pure-Python full pipeline**: every dirty file is parsed in-process, the canonical per-file cache is persisted, reverse deps + cycles + ACS are computed, and `library.md` is regenerated atomically. `--python-primary` is accepted but redundant; the in-shell first-pass was retired entirely (wikifier.sh's update-maps delegates to this pipeline; `--sh`/`--legacy-sh` are deprecated no-ops). Scoping is explicit via `--directory=`/`--max-files=` and reported in the result (`files_skipped`) — there are no silent caps.
@@ -22,33 +31,54 @@ This protocol + the Python package + MCP server form the bridge for consistent,
22
31
 
23
32
  **This file is the primary contract for any LLM or agent operating Wikifier.**
24
33
 
34
+ ## Agent architecture (navigability — G12)
35
+
36
+ Do **not** open megamodules (`javascript.py`, `import_cache.py`, `bree.py`) to decide workflow. Use this map:
37
+
38
+ | Need | Use |
39
+ |------|-----|
40
+ | First-run map | `init` → `update-maps` → `health --summary` → `suggest-next` |
41
+ | Steady-state | `check-changes` → edit 🔴/🟡 only → `record-change` → wiki → `mark-green` |
42
+ | Lookup | MCP Core 6: status, check_changes, needing_attention, get_file_wiki, suggest, record/mark |
43
+ | Deps / cycles | `get_dependencies`, `get_dependents`, `get_cycles` (json) |
44
+ | Deletion | `record-deletion` |
45
+ | Code entry | `wikifier/cli.py` (dispatch) + `wikifier/health.py` + parsers — self-tests live in `tests/` + `tests/selftest/` |
46
+
47
+ **CLI pure-Python vs shell:** mutators and maps prefer `python -m wikifier …`. Shell still owns `init`, `monitor`, `daemon`, `serve`, `journal`.
48
+ **Scope:** `monitored_paths` = change detection; `exclude_patterns` + optional `--directory` = map walk.
49
+ **Human HTML** is secondary observation only.
50
+
25
51
  ## Mandatory New-Session Rule
26
52
 
27
53
  **Copy this exact block into the system prompt or the very first instruction of every new LLM session that uses Wikifier:**
28
54
 
29
55
  ```
30
- You are now operating inside a Wikifier-managed codebase (Agent Protocol v0.6 — v4.2.0).
56
+ You are now operating inside a Wikifier-managed codebase (Agent Protocol v0.6 — package 4.5.x).
57
+
58
+ This is strictly an agent-to-agent wiki for token saving: map lookup (health + file wikis + deps) instead of full sources; selective wiki updates; not a human docs product or Jira.
31
59
 
32
- This is strictly an agent-to-agent wiki for token saving: quick file lookup (health matrix + file wikis + BRC + stele instead of full sources), autonomous wiki summary updates, and creation of new wiki entries as you work. It should not be used for anything more.
60
+ SELECTIVE WORK (mandatory): Only update/remove/re-wiki 🔴 Red and 🟡 Yellow files. Do not re-summarize 🟢 Green files or the whole tree. First-run builds the structural map; wiki depth is filled as you touch files.
33
61
 
34
- FIRST ACTIONS (mandatory, post-M5 hardened):
35
- 1. If the Wikifier MCP server is connected, prefer its tools (get_project_status, get_file_wiki, check_changes, get_barrel_reports, suggest_next_actions, etc.). Always pass project_root= for external/user projects (e.g. RecipeLab_alt, ConsistencyHub, llvm subs).
36
- 2. If MCP times out or is unavailable (rare since v4.2.0 fixed the workflow-call deadlock and batched barrel persistence; historically seen on BRC-heavy or 50k+ scale targets), fall back immediately to reliable CLI/library:
62
+ FIRST ACTIONS:
63
+ 1. Prefer MCP tools when connected (get_project_status, get_file_wiki, check_changes, suggest_next_actions, get_dependencies, ). Always pass project_root= for external projects.
64
+ 2. CLI/library fallback:
37
65
  WIKIFIER_PROJECT_ROOT=/path/to/target python -m wikifier check-changes
38
- python -m wikifier health --summary # or format=json/summary for machine use (token-efficient lookup)
39
- ... perform edit on source ...
40
- python -m wikifier record-change "path/to/file" "concise semantic reason (why, not what). Include subid if agent work."
41
- ... write/update the wiki summary for the file ...
42
- python -m wikifier mark-green "path/to/file" "Reason for Green (e.g. after autonomous agent update)."
43
- if imports changed: python -m wikifier update-maps [--directory=src/] # pure-Python full pipeline by default (v4.2.0)
44
66
  python -m wikifier health --summary
45
- 3. For sustained agent work: launch `python -m wikifier monitor` (or wikifier.sh monitor) in bg / daemon for 30s "Pruned 0 / No new" heartbeat + auto BRC healing. Use .last_check + health for observability.
46
- 4. Immediately consult the small health matrix (file_health.md or health --summary) + pending_updates.md. Prioritise 🔴 then 🟡. Use this for quick reference instead of full file reads to save tokens.
47
- 5. For edits to agent-maintained docs (e.g. this protocol, README, Findings/M5-*.md): precede with FRESH 3 hygiene (grep for 0 def matches on the target .md), use record-change + mark-green.
48
- 6. Always pass explicit project_root / WIKIFIER_PROJECT_ROOT for any external or multi-project work (M5 lesson: absolute monitored_paths.txt, no pollution).
49
- 7. Re-validate with health + suggest_next_actions (or equivalent) at end of turn/session. Use monitor for long-running.
67
+ python -m wikifier suggest-next # or suggest_next_actions(format="json")
68
+ ... edit only red/yellow sources ...
69
+ python -m wikifier record-change "path/to/file" "why (semantic). Include subid if agent work."
70
+ ... update that file's wiki only ...
71
+ python -m wikifier mark-green "path/to/file" "reason"
72
+ if imports changed: python -m wikifier update-maps [--directory=src/]
73
+ if file removed: python -m wikifier record-deletion "path" "why"
74
+ python -m wikifier health --summary
75
+ 3. Optional background: `python -m wikifier monitor` or daemon for mtime heartbeat — you still own wiki + mark-green.
76
+ 4. Prioritize 🔴 then 🟡 from health/pending. Lookup greens via get_file_wiki; do not rewrite them.
77
+ 5. Agent docs edits: record-change + mark-green.
78
+ 6. Always explicit project_root / WIKIFIER_PROJECT_ROOT for external/multi-project work.
79
+ 7. End turn: health + suggest_next_actions.
50
80
 
51
- Never skip record-change — it is the semantic audit trail (journal + health + pending + BRC).
81
+ Never skip record-change — semantic audit trail (journal + health + pending).
52
82
 
53
83
  **M5+ notes (2026-06)**:
54
84
  - External projects: always explicit root. CLI is battle-tested fallback (M5.1 MCP reliability: 60s timeout + better errors; M5 dogfood on alt BRC exact named services, 79k llvm, etc.).
@@ -0,0 +1,128 @@
1
+ """Gap-closure regressions (G4 ACS actionable, G5 health module, G7 ghosts/deletion)."""
2
+
3
+ import importlib
4
+ import unittest
5
+
6
+ from tests._base import TempProjectTestCase
7
+
8
+ from wikifier import import_cache as ic
9
+ from wikifier import cli
10
+
11
+
12
+ class TestHealthModuleImportG5(unittest.TestCase):
13
+ def test_importlib_health_is_module_with_get_summary(self):
14
+ mod = importlib.import_module("wikifier.health")
15
+ self.assertTrue(hasattr(mod, "get_summary"))
16
+ self.assertTrue(hasattr(mod, "find_ghost_entries"))
17
+ self.assertTrue(callable(mod.get_summary))
18
+
19
+ def test_health_module_alias_on_package(self):
20
+ import wikifier
21
+ self.assertTrue(hasattr(wikifier, "health_module"))
22
+ self.assertTrue(hasattr(wikifier.health_module, "get_summary"))
23
+ # Convenience function still exported as wikifier.health
24
+ self.assertTrue(callable(wikifier.health))
25
+
26
+
27
+ class TestAcsActionableG4(TempProjectTestCase):
28
+ def test_external_noise_excluded_from_actionable_low_conf(self):
29
+ cache = {}
30
+ # Project-internal low-conf edge
31
+ ic.update_file_data(
32
+ cache,
33
+ "app.py",
34
+ mtime=1,
35
+ imports=["./util"],
36
+ resolved_pairs=[{
37
+ "raw": "./util",
38
+ "resolved": "util.py",
39
+ "resolved_path": "util.py",
40
+ "confidence_score": 0.4,
41
+ "confidence_reasons": ["base:low", "via_barrel"],
42
+ "confidence_explanation": "Base low. Recommendation: Review project edge.",
43
+ "diagnostic": {"category": "project"},
44
+ "resolution_metadata": {"strategy": "relative-fs"},
45
+ }],
46
+ )
47
+ # External/stdlib-style edge (noise)
48
+ ic.update_file_data(
49
+ cache,
50
+ "app.py",
51
+ mtime=1,
52
+ imports=["json", "./util"],
53
+ resolved_pairs=[
54
+ {
55
+ "raw": "./util",
56
+ "resolved": "util.py",
57
+ "resolved_path": "util.py",
58
+ "confidence_score": 0.4,
59
+ "confidence_reasons": ["base:low"],
60
+ "confidence_explanation": "Project low. Recommendation: Review.",
61
+ "resolution_metadata": {"strategy": "relative-fs"},
62
+ },
63
+ {
64
+ "raw": "json",
65
+ "resolved": "json",
66
+ "resolved_path": "",
67
+ "confidence_score": 0.48,
68
+ "confidence_reasons": ["base:medium", "no_resolved_path"],
69
+ "confidence_explanation": "stdlib. Recommendation: harden import.",
70
+ "diagnostic": {"category": "external_or_bare"},
71
+ "resolution_metadata": {"strategy": "python-bare-or-external"},
72
+ },
73
+ ],
74
+ )
75
+ # Note: update_file_data may replace pairs — set explicitly
76
+ cache["app.py"]["resolved_pairs"] = [
77
+ {
78
+ "raw": "./util",
79
+ "resolved": "util.py",
80
+ "resolved_path": "util.py",
81
+ "confidence_score": 0.4,
82
+ "confidence_reasons": ["base:low"],
83
+ "confidence_explanation": "Project low. Recommendation: Review.",
84
+ "resolution_metadata": {"strategy": "relative-fs"},
85
+ },
86
+ {
87
+ "raw": "json",
88
+ "resolved": "json",
89
+ "confidence_score": 0.48,
90
+ "confidence_reasons": ["base:medium"],
91
+ "confidence_explanation": "stdlib noise. Recommendation: ignore.",
92
+ "diagnostic": {"category": "external_or_bare"},
93
+ "resolution_metadata": {"strategy": "python-bare-or-external"},
94
+ },
95
+ ]
96
+ summary = ic.compute_acs_summary(cache)
97
+ self.assertGreaterEqual(summary["low_conf_edges"], 1)
98
+ self.assertEqual(summary["actionable_low_conf_edges"], 1)
99
+ self.assertGreaterEqual(summary["external_noise_edges"], 1)
100
+ action = ic.get_low_confidence_edges(cache, actionable_only=True)
101
+ self.assertTrue(all(
102
+ (p.get("diagnostic") or {}).get("category") != "external_or_bare"
103
+ for p in action
104
+ ))
105
+
106
+
107
+ class TestGhostAndDeletionG7(TempProjectTestCase):
108
+ def test_find_ghost_and_record_deletion(self):
109
+ health_mod = importlib.import_module("wikifier.health")
110
+ self.write("keep.py", "x=1\n")
111
+ self.write("gone.py", "y=1\n")
112
+ health_mod.upsert_entry(self.root, "keep.py", "🟢 Green", "ok")
113
+ health_mod.upsert_entry(self.root, "gone.py", "🟢 Green", "ok")
114
+ (self.root / "gone.py").unlink()
115
+
116
+ ghosts = health_mod.find_ghost_entries(self.root)
117
+ self.assertIn("gone.py", ghosts)
118
+ self.assertNotIn("keep.py", ghosts)
119
+
120
+ res = cli.record_deletion("gone.py", "removed in cleanup", project_root=self.root)
121
+ self.assertTrue(res.get("success"))
122
+ entries = health_mod.load_health(self.root)["entries"]
123
+ self.assertIn("🔴", entries["gone.py"]["status"])
124
+ self.assertIn("DELETED", entries["gone.py"]["reason"])
125
+
126
+
127
+ if __name__ == "__main__":
128
+ unittest.main()
@@ -0,0 +1,39 @@
1
+ """G12: run extracted selftest harnesses via unittest (no harness in prod modules)."""
2
+
3
+ import runpy
4
+ import unittest
5
+ from pathlib import Path
6
+
7
+ SELFTEST = Path(__file__).resolve().parent / "selftest"
8
+
9
+
10
+ class TestExtractedSelftests(unittest.TestCase):
11
+ def _run(self, name: str):
12
+ path = SELFTEST / name
13
+ self.assertTrue(path.is_file(), f"missing {path}")
14
+ # Execute as __main__ so assert-based scripts raise on failure
15
+ try:
16
+ runpy.run_path(str(path), run_name="__main__")
17
+ except SystemExit as e:
18
+ if e.code not in (0, None):
19
+ self.fail(f"{name} exited with {e.code}")
20
+
21
+ def test_contracts_selftest(self):
22
+ self._run("run_contracts_selftest.py")
23
+
24
+ def test_python_parser_selftest(self):
25
+ self._run("run_python_parser_selftest.py")
26
+
27
+ def test_cdia_selftest(self):
28
+ self._run("run_cdia_selftest.py")
29
+
30
+ def test_resolution_selftest(self):
31
+ self._run("run_resolution_selftest.py")
32
+
33
+ def test_javascript_selftest(self):
34
+ # Heavier; still must pass for agent-navigable JS parser
35
+ self._run("run_javascript_selftest.py")
36
+
37
+
38
+ if __name__ == "__main__":
39
+ unittest.main()
@@ -13,14 +13,18 @@ Zero-dependency, agent-to-agent codebase wiki. Provides:
13
13
 
14
14
  The flat library API below (check_changes, record_change, mark_green,
15
15
  health, update_maps, ...) is the preferred surface for agents calling
16
- Wikifier directly from Python. Note: `from wikifier import health` binds the
17
- convenience function; the module is still reachable via
18
- `from wikifier.health import upsert_entry, ...`.
16
+ Wikifier directly from Python.
17
+
18
+ **Health import hygiene (G5):** `from wikifier import health` is the *convenience
19
+ function* (cli). The real module is always `importlib.import_module("wikifier.health")`
20
+ or `from wikifier.health import upsert_entry, get_summary, ...`. Prefer
21
+ `wikifier.health_module` (alias below) over `import wikifier.health as …`, which
22
+ binds the function under CPython because the package attribute is shadowed.
19
23
  """
20
24
 
21
25
  from . import parsers
22
26
  from . import mcp # exposes wikifier.mcp.mcp (None when the optional extra is absent)
23
- from . import health
27
+ from . import health as health_module # submodule — keep this name for agents/tools
24
28
  from . import locking
25
29
  from . import import_cache
26
30
  from . import resolution
@@ -40,6 +44,12 @@ from .cli import (
40
44
  health, # flat convenience func (delegates to the health module + adds scoping)
41
45
  )
42
46
 
47
+ # Re-export module under a non-shadowed name (G5). sys.modules['wikifier.health']
48
+ # remains the real module; package attribute `health` is intentionally the function.
49
+ import sys as _sys
50
+ if "wikifier.health" not in _sys.modules:
51
+ _sys.modules["wikifier.health"] = health_module
52
+
43
53
  # Shared frozen data contracts (single source of truth for shapes used by
44
54
  # parsers, cache, MCP, and diagnostics).
45
55
  from . import contracts
@@ -61,4 +71,4 @@ from .contracts import (
61
71
  compute_acs_confidence,
62
72
  )
63
73
 
64
- __version__ = "4.5.1"
74
+ __version__ = "4.5.3"