feat: auto-detect and persist project conventions to wiki#1010
feat: auto-detect and persist project conventions to wiki#1010kevincodex1 wants to merge 1 commit intoGitlawb:mainfrom
Conversation
Adds a convention scanner that reads project config files (package.json, tsconfig.json, eslint, prettier, Dockerfile, CI workflows, lockfiles) on startup and saves extracted conventions to .openclaude/wiki/pages/conventions.md. Includes a fingerprint cache to avoid redundant writes and a /wiki scan command for manual re-scans. New modules: - src/services/wiki/conventions.ts — scanner + cache + save - src/services/wiki/identity.ts — project identity (name, languages, monorepo) - src/services/wiki/conventions.test.ts — 7 tests Modified: - paths/types/init/status — extended wiki infrastructure for conventions - wiki.tsx/index — added /wiki scan command - main.tsx — fires scan via startDeferredPrefetches - init.test.ts/status.test.ts — updated for new conventions page/fields Co-Authored-By: OpenClaude <openclaude@gitlawb.com>
|
please have an independent review too @techbrewboss |
|
I found 3 issues in the wiki-conventions changes: 1. Startup scan bypasses the trust gate
The new startup convention scan calls Git before trust is established by running Suggested fix: only run the scan after trust is established, or avoid Git-dependent identity detection during startup. 2. Cache key can leave
|
Vasanthdev2004
left a comment
There was a problem hiding this comment.
Thanks for the PR. The direction is useful, and CI is green, but I found one blocker on the current head.
Review scope: Targeted review of the new wiki convention scanner command/startup path, cache behavior, and focused tests.
Verdict: Needs changes
Blocking issue:
/wiki scanfails when the wiki has not been initialized yet.forceScanConventions()catches the missingpages/conventions.mdwrite, but then still callswriteCache(), which tries to write.openclaude/.conventions-cache.jsoneven when.openclaudedoes not exist. I reproduced this locally with a temp project that only hadpackage.json;forceScanConventions(cwd)throwsENOENT: no such file or directory, open '<tmp>\.openclaude\.conventions-cache.json'.
Why this matters: /wiki scan is now a user-facing command, so the uninitialized path should either return a clear ?run /wiki init first? message or avoid writing the cache when the wiki root is missing. Right now it can crash instead of producing a clean command result.
What I checked:
- Current head:
51d6caf bun test src/services/wiki/passesbun run buildpasses- Manual repro for uninitialized
forceScanConventions(cwd)fails with the cache write ENOENT above
Happy to re-review once that uninitialized scan path is handled and covered by a small regression test.
techbrewboss
left a comment
There was a problem hiding this comment.
Thanks for the PR. I did an independent pass over the convention scanner startup path, cache behavior, and the wiki command flow. I agree with the existing uninitialized /wiki scan blocker, and I found two additional issues that should be addressed before merge.
-
Startup scan still runs Git before workspace trust is established.
startDeferredPrefetches()now callsscanAndSaveConventions(getCwd())unconditionally, and that reachesgetProjectIdentity()->detectMainBranch()->execFileSync('git', ['symbolic-ref', ...]). This bypasses the explicitprefetchSystemContextIfSafe()trust gate immediately above it, which exists because Git can execute repo-controlled hooks/config. Please either gate this startup scan behind the same trust/non-interactive check, or make the startup path avoid Git-dependent identity detection until after trust. -
The cache fingerprint can leave
conventions.mdstale.computeFingerprint()only hashes the detected convention sections, but the rendered markdown also includes identity-derived data: project name, language counts, monorepo status, and default branch. If any of those identity fields changes while the scanned config sections do not,scanAndSaveConventions()returnsnulland skips rewriting the page. Please include the identity inputs in the cache key, or compute the cache key from the final markdown after normalizing/removing the scan timestamp.
I also confirmed bun test src/services/wiki/conventions.test.ts passes on this head, but the current tests do not cover the trust-gated startup path, identity-only cache invalidation, or the uninitialized /wiki scan cache write failure.
gnanam1990
left a comment
There was a problem hiding this comment.
Re-reviewed at current head — the three blockers raised by Vasanthdev2004 and techbrewboss are still present:
forceScanConventions(cwd)(src/services/wiki/conventions.ts) catches the page write failure but unconditionally callswriteCache(cwd, scan.fingerprint)immediately after, which writes.openclaude/.conventions-cache.json. If.openclaudedoesn't exist, this still throws ENOENT —/wiki scancrashes for users who haven't run/wiki init.startDeferredPrefetches()insrc/main.tsx(line ~422) callsscanAndSaveConventions(getCwd())outside the existingprefetchSystemContextIfSafe()trust gate. That path reachesgetProjectIdentity()→detectMainBranch()→execFileSync('git', …)insrc/services/wiki/identity.ts:798, which can run repo-controlled git hooks/config on untrusted workspaces. Must be gated identically to the system-context prefetch above it.computeFingerprint()only hashes the scanned config sections — but the rendered markdown also embeds identity-derived data (project name, language counts, monorepo flag, default branch). Identity-only changes won't invalidate the cache, soconventions.mdstays stale. Either include identity inputs in the cache key or hash the final rendered markdown (with timestamp normalized).
No red-flag rule hits otherwise. Verified locally: traced forceScanConventions and startDeferredPrefetches call paths in the diff at HEAD.
Summary
Adds a convention scanner that reads project config files (package.json, tsconfig.json, eslint, prettier, Dockerfile, CI workflows, lockfiles) on startup and saves extracted conventions to .openclaude/wiki/pages/conventions.md. Includes a fingerprint cache to avoid redundant writes and a /wiki scan command for manual re-scans.
New modules:
Modified:
Impact
setup — no need to tell it every session. A new /wiki scan command lets users force a re-scan at any time. The /wiki status output now shows convention page status.
Fingerprint-based caching prevents redundant writes on subsequent sessions.
Testing
Notes