docs: add architecture awareness system — CLAUDE.md §13/§14 + ARCHITECTURE_BRIEF
Some checks failed
CI / Lint & TypeCheck (push) Has been cancelled
CI / Unit Tests (push) Has been cancelled
CI / Build Frontend (push) Has been cancelled
CI / Rust Check (push) Has been cancelled
CI / Security Scan (push) Has been cancelled
CI / E2E Tests (push) Has been cancelled

- Activate CLAUDE.md with §13 architecture snapshot (auto-sync markers)
  and §14 anti-pattern warnings + scenario instructions
- Fix dead link to non-existent STABILIZATION_DIRECTIVE.md
- Update stale numbers (93→130 SaaS APIs, 171→182 Tauri commands, 13→15 admin pages)
- Create docs/ARCHITECTURE_BRIEF.md as permanent architecture reference
  covering 10 subsystems (butler, chatstream, LLM drivers, client routing,
  SaaS auth, memory pipeline, Pipeline DSL, Hands, middleware, key paths)
- Add /sync-arch skill for manual or workflow-triggered architecture sync
- Add PostToolUse hook to remind doc sync after git commit/push
- Update §8.3 completion flow to include architecture snapshot updates
- Mark memory files (system_architecture, butler_mode) as migrated to BRIEF
- Add ARCHITECTURE_BRIEF.md as top entry in MEMORY.md index
This commit is contained in:
iven
2026-04-09 14:09:26 +08:00
parent 26f50cd746
commit f2d6a3b6b7
5 changed files with 467 additions and 11 deletions

View File

@@ -0,0 +1,28 @@
// arch-sync-check.js
// PostToolUse hook: detects git commit/push and reminds to sync architecture docs
// Reads tool input from stdin, outputs reminder if git operation detected
const CHUNKS = [];
process.stdin.on('data', (c) => CHUNKS.push(c));
process.stdin.on('end', () => {
try {
const input = JSON.parse(Buffer.concat(CHUNKS).toString());
const toolName = input.tool_name || '';
const toolInput = input.tool_input || {};
// Only check Bash tool calls
if (toolName !== 'Bash') return;
const cmd = (toolInput.command || '').trim();
// Detect git commit or git push
const isGitCommit = cmd.startsWith('git commit') || cmd.includes('&& git commit');
const isGitPush = cmd.startsWith('git push') || cmd.includes('&& git push');
if (isGitCommit || isGitPush) {
console.log('[arch-sync] Architecture docs may need updating. Run /sync-arch or update CLAUDE.md §13 + ARCHITECTURE_BRIEF.md as part of §8.3 completion flow.');
}
} catch {
// Silently ignore parse errors
}
});

15
.claude/settings.json Normal file
View File

@@ -0,0 +1,15 @@
{
"hooks": {
"PostToolUse": [
{
"matcher": "Bash",
"hooks": [
{
"type": "command",
"command": "node .claude/hooks/arch-sync-check.js"
}
]
}
]
}
}

52
.claude/skills/sync-arch Normal file
View File

@@ -0,0 +1,52 @@
# Architecture Sync Skill
Analyze recent git changes and update the architecture documentation to keep it current.
## When to use
- After completing a significant feature or bugfix
- As part of the §8.3 completion flow
- When you notice the architecture snapshot is stale
- User runs `/sync-arch`
## Steps
1. **Gather context**: Run `git log --oneline -10` and identify commits since the last ARCH-SNAPSHOT update date (check the comment in CLAUDE.md `<!-- ARCH-SNAPSHOT-START -->` section).
2. **Analyze changes**: For each relevant commit, determine which subsystems were affected:
- Butler/管家模式 (butler_router, pain_storage, cold_start, ui_mode)
- ChatStream/聊天流 (kernel-chat, gateway-client, saas-relay, streamStore)
- LLM Drivers/驱动 (driver/*, config.rs)
- Client Routing/客户端路由 (connectionStore)
- SaaS Auth/认证 (saas-session, auth handlers, token pool)
- Memory Pipeline/记忆管道 (growth, extraction, FTS5)
- Pipeline DSL (pipeline/*, executor)
- Hands (hands/*, handStore)
- Middleware (middleware/*)
- Skills (skills/*, skillStore)
3. **Update CLAUDE.md §13** (between `<!-- ARCH-SNAPSHOT-START -->` and `<!-- ARCH-SNAPSHOT-END -->`):
- Update the "活跃子系统" table: change status and latest change for affected subsystems
- Update "关键架构模式": modify descriptions if architecture changed
- Update "最近变更": add new entries, keep only the most recent 4-5
- Update the date in the comment `<!-- 此区域由 auto-sync 自动更新,更新时间: YYYY-MM-DD -->`
4. **Update CLAUDE.md §14** (between `<!-- ANTI-PATTERN-START -->` and `<!-- ANTI-PATTERN-END -->`):
- Add new anti-patterns if new pitfalls were discovered
- Add new scenario instructions if new common patterns emerged
- Remove items that are no longer relevant
5. **Update docs/ARCHITECTURE_BRIEF.md**:
- Update the affected subsystem sections with new details
- Add new components, files, or data flows that were introduced
- Update the "最后更新" date at the top
6. **Commit**: Create a commit with message `docs(sync-arch): update architecture snapshot for <date>`
## Rules
- Only update content BETWEEN the HTML comment markers — never touch other parts of CLAUDE.md
- Keep the snapshot concise — the §13 section should be under 50 lines
- Use accurate dates from git log, not approximations
- If no significant changes since last update, do nothing (don't create empty commits)
- Architecture decisions > code details — focus on WHAT and WHY, not line numbers