feat: Mode B codebase ingestion, drift lint, and commit-triggered sync#81
Open
RasenGUY wants to merge 1 commit into
Open
feat: Mode B codebase ingestion, drift lint, and commit-triggered sync#81RasenGUY wants to merge 1 commit into
RasenGUY wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Makes Mode B (GitHub / Repository) a real, end-to-end feature instead of a folder template. A codebase can now be ingested into the wiki as
modules/flows/dependencies/decisionspages from deterministic signals (gitignore-aware repo walk, parsed dependency manifests, git anchors, regex import edges);wiki-lintcan detect drift when a page's source changes via git content-hash anchors; and a watched repo can be kept in sync on every commit (enqueue-only git hook → in-session drain by default, opt-in autonomous headless drain). Language-agnostic by construction (git content-addressing + extension maps), additive, and backward-compatible — no change to prose ingestion. Until now Mode B was a folder convention filled in by hand (skills/wiki/references/modes.md§Mode B); this wires it into the router, the schema, the lint, and the hooks.Type
fix:)feat:)docs:)refactor:)test:)chore:)Related issue
None yet. The work arrived complete, so it skipped the issue-first flow in CONTRIBUTING §1 — happy to open a feature-request issue retroactively if you'd prefer it tracked there.
Changes
Code ingestion (new)
skills/wiki-code-ingest/SKILL.md,agents/wiki-code-ingest.md,commands/wiki-code-ingest.md— guided ingest skill (mirrorswiki-ingeststructure) + one-page-per-module parallel sub-agent + slash command. Whole-repo bootstrap, single-path ingest, and--syncmodes.scripts/code-scan.py— tree / language / LOC snapshot. Gitignore guarantee: enumerates viagit ls-files --cached --others --exclude-standard; ignored/vendored/build-output files are never indexed.scripts/code-manifests.py— detect + parse npm/pypi/go/cargo/rubygems/composer manifests (stdlib only; drawn from the gitignore-aware set, so no vendored manifests).scripts/code-signals.py— git anchors (blob/tree SHA per path vials-tree), churn, best-effort regex import edges. Degrades cleanly on non-git dirs.Router + schema + drift lint
scripts/wiki-mode.py—module|component|dependency|flow|decisionadded toVALID_TYPES, the genericDEFAULT_CONFIGfolders, and the generic + PARA routing maps (LYT/Zettelkasten route them automatically). Mirrored inskills/wiki-mode/SKILL.md.skills/wiki/references/frontmatter.md+references/modes.md— code-page schema:source_type: code,source_paths,code_anchors(flat"path@sha"strings — honors the no-nested-YAML rule Automatize the learning? #1),ingest_commit,ingested_at.scripts/code-anchor-check.py+skills/wiki-lint/SKILL.md(check setup-vault.sh doesn't move commands/, skills/, hooks/ to .claude/ directory #11) +agents/wiki-lint.md(check Remove development leftovers and reset seed vault #9) — read-only git drift lint. Flags DRIFTED / MOVED / UNTRACKED pages; exits10/11to skip cleanly when git/repo absent (drift itself is a finding at exit0, mirroring tiling).Commit-triggered auto-sync
bin/setup-code-watch.sh— installs enqueue-onlypost-commit/post-merge/post-rewritehooks into a watched repo (chains existing hooks; refuses the vault's own repo to prevent a commit→sync→commit loop).scripts/code-sync-check.py— queue/state manager +SessionStartsurfacer. Untrusted git strings sanitized viasafe_display()before reaching session context.bin/code-sync-launch.sh— opt-in debounced, single-flighted, detached headlessclaude -pdrain. RequiresANTHROPIC_API_KEY; degrades to enqueue-only without it.hooks/hooks.json+hooks/README.md+skills/wiki/SKILL.md— newSessionStarthook (no-op unless a sync queue exists) + routing + docs.Tests / build
Makefiletargets;.gitignorerules for the new runtime artifacts.Six-cut self-review
--unwatch; loop guard;ANTHROPIC_API_KEY/claude/non-git degradation)Testing
15 hermetic suites (9 pre-existing + 6 new:
test-code-scan,-manifests,-signals,-code-drift,-code-sync,-code-watch). All hermetic — temp git repos, no network/ollama/Anthropic API. The auto-sync test drives a realgit commit→ queue enqueue end-to-end and asserts existing-hook chaining, the loop guard, and--unwatchcleanup. Each new signal/drift behavior (incl. the gitignore-exclusion guarantee) has a dedicated assertion.Verifier
Dispatched
agents/verifier.mdon the staged diff (two passes)..vault-meta/code-sync-queue.jsonl,code-sync-state.json,.code-sync*.lock,.raw/code/) weren't gitignored, so the existingPostToolUsevault auto-commit (git add -- .vault-meta/ .raw/) would have committed them every interaction. Fixed: added a.gitignoreblock (verified each path withgit check-ignore).finallyvariable use inaction_unregister; trust note on$REPO/$HEADinterpolation incode-sync-launch.sh). Fixed.safe_display()control-char stripping + untrusted-data framing in the headless prompt + a documented trust boundary incommands/wiki-code-watch.md) and CLEARED by the verifier. The unwatch/action_unregisterflow was also traced and CLEARED.CHANGELOG
## [Unreleased]inCHANGELOG.mdplugin.json/marketplace.jsonare intentionally left at1.9.2and the changelog under## [Unreleased]per CONTRIBUTING §8 — version assignment is yours at release time.Screenshots / output
Real-repo smoke test (run against this plugin repo itself):
Notes for reviewer
> [!gap]callouts rather than faked precision.ANTHROPIC_API_KEY; the default is in-session with a human in the loop (SessionStart surfaces drift and offers/wiki-code-ingest --sync).hooks/README.md): declarative Claude plugin hooks ship with the plugin; the commit-detecting git hooks are installed per-repo by/wiki-code-watchbecause plugins can't run install-time scripts and don't know which repo you'll map.v1.10in the project's version-tagged-comment style; rename if you'd assign a different version.