Compare commits

...

3 Commits

Author SHA1 Message Date
PP-bot
f287ba99db sync(memory): backup auto-memory snapshot iter9 close
Mirror of ~/.claude/projects/-Users-pp-bot/memory/ as of 2026-04-27.

Files:
- MEMORY.md (index)
- dasheng-codebase.md (Gitea + IM family + 取经团 worker layout)
- feedback_bot_node_field.md (bots.json node field is informational)

Per-user Claude memory is Mac-local. This repo is the canonical backup
so a fresh machine / EC2 / colleague workstation can prime new Claude
Code windows with the same project knowledge.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-27 14:38:36 +09:00
lobster-wenshu-bot
a11440dc1a docs(agent-hook): install dev role hooks (CLAUDE.md, AGENTS.md) — 文殊 batch 2026-04-27 2026-04-27 13:42:14 +09:00
lobster-wenshu-bot
e1c671a10f docs(claude-hook): install dev role hook (CLAUDE.md) — 文殊 batch 2026-04-27 2026-04-27 13:42:14 +09:00
5 changed files with 277 additions and 0 deletions

67
AGENTS.md Normal file
View File

@@ -0,0 +1,67 @@
<!-- agents-md-role: dev -->
# AGENTS.md — dev role
> Open-standard agent contract per [agents.md](https://agents.md).
> Companion to `CLAUDE.md` (Claude-specific) — this file works for any
> AI coding agent (Cursor, Aider, Codex, OpenHands, etc.).
## Dev environment tips
- Default branch convention: `main` = prod, `dev` = rolling integration,
`release/*` = release candidates, `feat/*` = ephemeral feature branches.
If this repo currently uses something else (`im-dev`, `bundle`,
`4411-1`, `release`, `20260203`), see
`dasheng-repos/.omc/notes/packing-machine-arch-2026-04-27.md` for the
migration plan.
- For Vue 3 + Vite repos: `npm run build-only` (not `npm run build`)
to bypass legacy `tsc` errors that block clean builds.
- For Flutter repos: `flutter pub get && flutter test` before any change.
- For Swift repos: `xcodebuild -workspace ... -scheme ... test` from the
workspace root.
## Testing instructions
- TDD-first. Diff that changes behavior MUST add or update a test that
fails on the parent commit and passes on this branch.
- Find existing tests by language:
- `tests/`, `core/tests/`, `__tests__/` (Python / JS)
- `test/`, `integration_test/` (Flutter / Dart)
- `*Tests/` (Swift)
- Run with the lightest scope that proves the change:
`pytest core/tests/test_<module>.py` / `vitest run <pattern>` /
`flutter test test/<file>` / `xcodebuild test -only-testing:<TestClass>`.
- Pre-existing failures unrelated to your change are NOT in scope to fix
unless explicitly requested. Note them in your PR body.
## PR instructions
- Title: `<type>(<scope>): <subject>` lowercase, no trailing period.
- Body: `Why:` + `How:` + `Refs:` + `Co-Authored-By:` trailer.
- Default branch is read at runtime — never hardcode `"main"` in
PR-create / merge calls. See `wen_shu_hub.auto_pr_botdev` for the
canonical pattern.
- Idempotency: any artifact (issue, PR, comment) the agent creates MUST
carry an idempotency key in body so re-runs dedupe. Pattern:
`<!-- idem:<sha16> -->`.
## Hard rules (production-incident-driven)
1. **Fail-closed defaults** when uncertain about routing / permissions /
platforms. Default to the safer outcome (no fan-out, no auto-promote,
no auto-merge). See `_MODULE_PLATFORMS` in
`claude-worker-universe/core/wen_shu_hub.py` for the canonical pattern.
2. **Portable links only.** Never write `/Users/...` in commits, issues,
comments, or test artifacts. Use Gitea web URL with per-segment UTF-8
percent-encoding. Helper: `_qa_spec_gitea_url`.
3. **No inline PAT in remote URL.** If you see
`https://oauth2:<token>@host/...` in a remote, that's an existing
smell — don't propagate.
## References
- Master design: `claude-worker-universe/.omc/notes/master-design.md`
- Build machine review: `dasheng-repos/.omc/notes/packing-machine-arch-2026-04-27.md`
- Big-co patterns reused: Stripe Idempotency, Linear AI agents,
GitHub Copilot for Issues, Datadog rolling-3-window WARN, AWS IAM
fail-closed.

95
CLAUDE.md Normal file
View File

@@ -0,0 +1,95 @@
<!-- claude-md-role: dev -->
# CLAUDE.md — dev repo hook (autoinstalled by lobster-wenshu-bot)
> This file is the project's CLAUDE.md hook for the **dev** role.
> When Claude Code opens this repo, this is the first context it reads.
> Author: 文殊菩萨 / `lobster-wenshu-bot`. Last updated: 2026-04-27.
## Identity
This repo is a **product / dev** repo. Code that ships to users.
Bot owners: `lobster-worker-bot*` (iOS), `xurishu_bot` / `kevins-studio-bot` /
`jarvis_theone_bot` / `andyjanebot` (H5). PR review: 八戒 (`lobster-qa-bot`)
or human gate. Deploy: `mini-build-all` orchestrator (see also
`packing-machine-arch-2026-04-27.md` in claude-worker-universe `.omc/notes/`).
## Top rules
1. **TDD-first.** Before changing behavior, the diff must include a new or
updated test that *fails* on `main` and passes on this branch. No
exceptions for "trivial" fixes — historically the trivial ones are the
ones that come back as P0 production bugs (idem-label collapse, label
string→int64 422, bold-colon regex, fail-closed iOS routing — all
shipped without enough tests).
2. **Fail-closed defaults.** When a routing / permission / platform table
is unsure, default to the *safer* answer (no fan-out, no auto-promote,
no auto-merge). See `_MODULE_PLATFORMS` and `_PLATFORM_OWNER_BOTS` in
`claude-worker-universe/core/wen_shu_hub.py` for the canonical pattern.
3. **Idempotency markers in the body.** Any artifact this repo creates
(issues, PRs, comments, files) should carry an idempotency key in its
body (e.g. `<!-- idem:<sha16> -->`) so re-runs / retries de-dupe. The
*labels* field on Gitea issues is **not** authoritative — it requires
the bot account to be a repo collaborator (most aren't). Cross-ref
commit `3a1013b` in claude-worker-universe.
4. **Portable links only.** Never write a per-machine path
(`/Users/pp-bot/...`) into a commit, issue, or comment. Use the Gitea
web URL (`<host>/<org>/<repo>/src/branch/<branch>/<path>`) with
per-segment UTF-8 percent-encoding. See `_qa_spec_gitea_url` for the
canonical helper.
5. **Branch convention** (target end state): `main` is prod, `dev` is
rolling integration, `release/*` is tagged. If this repo currently
uses something else (`im-dev`, `bundle`, `4411-1`, `release`, `20260203`),
read the latest `packing-machine-arch-2026-04-27.md` for the migration
plan and **don't unilaterally rename**.
6. **Default branch is read at runtime** — never hardcode `"main"` in
PR-create / merge calls. `auto_pr_botdev` got bitten by this; the fix
reads `RepoState.default_branch` dynamically.
## Big-co patterns reused in this codebase
- **Stripe Idempotency-Key** → `_idempotency_key()` (sha16 hash; body
marker is the source of truth, not the label).
- **Linear AI agents / GitHub Copilot for Issues** → @-mention
`_PLATFORM_OWNER_BOTS` in body; assignees are best-effort with 422
fallback because most bots aren't repo collaborators.
- **Datadog rolling-window WARN** → `distribute.summary` JSON +
`distribute.idem_storm` after 3 consecutive ticks at idem_rate > 0.9.
- **AWS IAM fail-closed default-deny** → `_MODULE_PLATFORMS` opt-in for
iOS routing; default H5-only.
- **GitHub Actions/Vercel preview-smoke contract** → `headless-smoke`
CLI command (Playwright + Chromium against built dist/, emits PASS/FAIL
+ screenshot + exit code).
## Agent tier guidance for this repo
- Trivial lookups → Haiku
- Standard implementation → Sonnet
- Architecture, race conditions, security review → Opus
For multi-step work in this repo, route via the wenshu CLI:
`python3 .../core/wen_shu_hub.py <subcommand>``gen` / `distribute` /
`poll` / `auto-pr` / `state` / `daemon` / `headless-smoke` /
`align-bot-dev` / `figma`.
## Run commands
If `package.json` exists: `npm install && npm run build-only` (skip
type-check until repo's TS errors are clean — see lessons_learned).
If `pyproject.toml` exists: `python3 -m pytest core/tests/`.
If `pubspec.yaml` exists: this is a Flutter repo — see
`packing-machine-arch-2026-04-27.md` for build hooks (worker-knowledge,
bajie merge).
## Commit style
`<type>(<scope>): <subject in lowercase, no trailing period>`
Body: `Why:` + `How:` + `Refs:`. End every commit with the `Co-Authored-By`
trailer for the bot that authored it.
## What this hook deliberately does NOT do
- It does NOT pin a Python / Node / Flutter version (varies per repo).
- It does NOT enforce a license / formatter — repos diverge.
- It does NOT bypass review — `bot-dev → main` PRs still need human or
八戒 sign-off (master-design D2 / §6.2).

2
memory/MEMORY.md Normal file
View File

@@ -0,0 +1,2 @@
- [Dasheng (大盛) codebase map](dasheng-codebase.md) — Gitea instance at dasheng.io, IM product family + 悟空分身/取经团 worker system; refactor focus on `claude-worker-universe` + `jx-im/worker-client/thin_worker.py` (corrected from mini_tonky_bot/...)
- [bots.json node field is informational](feedback_bot_node_field.md) — don't block planning on unknown node values; sub-bots run on colleague machines

View File

@@ -0,0 +1,98 @@
---
name: Dasheng (大盛) Gitea codebase map
description: Top-level orientation for the dasheng.io Gitea organization — the IM product family + 悟空分身/取经团 distributed Claude worker system. Cite when work touches any of the cloned repos under ~/dasheng-repos.
type: project
originSessionId: c2c569ed-e20b-4000-a286-8d48afea8d86
---
# Dasheng codebase — orientation
## Account and access
- Gitea instance: `https://dasheng.io/gitea` (Gitea 1.25.4)
- Active account: `leipayne18` (admin)
- Credentials: NEVER commit. Held only in session-scoped env vars (`GITEA_TOKEN`). Rotated after each task.
## Workspace
- Local clone root: `/Users/pp-bot/dasheng-repos/`
- Master index of all 124 repos: `/Users/pp-bot/dasheng-repos/INDEX.md`
- Per-org subdirs: `~/dasheng-repos/<org>/<repo>/`
- Manifest: `.omc/repos.json` (with full_name, clone_url, default_branch, empty, size_kb)
- 108 cloned, 16 truly empty (verified via git ls-remote, kept as placeholders only)
## Org map (14 orgs)
| Org | Apparent role |
|---|---|
| `jx-im` | Core: IM client (Dart/Swift), worker system (universe, worker-client, worker-knowledge) |
| `Matrix-Ant-AI` | Mini-app ecosystem + Flutter packages (44 repos, the largest org) |
| `CUS-IM` / `CUS-IM-Plugin` | Customer-facing IM client + parallel plugin set (mirrors jx-im-plugin) |
| `jx-im-plugin` | Flutter plugin set: kiwi_module, photo_view, pin_code_fields, agora, camerawesome, etc. |
| `jx-im-advance-plugin` | Dev-branch versions of plugins (im_message_plugins-im-dev, jxim_chat_room_nav-im-dev, etc.) |
| `mini_tonky_bot` | Single repo: `worker-client` (thin worker — see below) |
| `leipayne18` | Personal: clawd, clawdbot-memory, customer-im-client-dev |
| `lewis`, `thomas`, `harry`, `josh`, `durant`, `victor`, `jiaswee`, `PM`, `ui` | Individual contributor sandboxes |
## Refactor targets (active focus)
### Universe
- Repo: `jx-im/claude-worker-universe` (44.7M Python)
- Local path: `~/dasheng-repos/jx-im/claude-worker-universe/`
- Role: Central hub / orchestrator of the 取经团 (Pilgrim Team) distributed Claude worker system
- Architecture uses Journey-to-the-West character names: 唐僧 (tang_seng_*), 八戒 (ba_jie_*), 沙僧 (wu_jing_*, sha), 悟空 (wu_kong_*)
- Deep-dive notes: `~/dasheng-repos/.omc/notes/universe.md`
- Headline pain points: `core/run_loop.py` 9238 LOC, `tools/thin_worker.py` 5271 LOC, `core/wu_jing_daemon.py` 4808 LOC, `services/bot_dashboard.py` 4266 LOC, ~zero tests
### Tinworker (= thin_worker)
- "tinworker" is phonetic for `thin_worker` — refers to the file `thin_worker.py`
- Primary repo: `mini_tonky_bot/worker-client` (1.7M Python)
- Local path: `~/dasheng-repos/mini_tonky_bot/worker-client/`
- Role: Single-file deployable Claude dev worker, distributed to volunteer contributors ("大仙")
- Deep-dive notes: `~/dasheng-repos/.omc/notes/tinworker.md`
- Confirmation status: hypothesis (strong evidence: file `thin_worker.py` matches user's "tinworker" pronunciation; module docstring "悟空分身 · Thin Worker"). User can override in `.omc/state.json`.
- Alternative candidates noted: `jx-im/worker-client` (older "Kevin" variant), `jx-im/worker-knowledge` (knowledge base, not runtime)
### CRITICAL FINDING — dual thin_worker.py
There are TWO `thin_worker.py` files with significant divergence:
- `jx-im/claude-worker-universe/tools/thin_worker.py` — 5271 LOC
- `mini_tonky_bot/worker-client/thin_worker.py` — 2233 LOC
Refactoring must decide which is canonical, identify drift, and consolidate. This is documented in both deep-dive notes and is the central refactor question.
## Multi-version IM client landscape
The IM client exists in at least 4 flavors — clarify with user which is the active production codebase before refactoring touches it:
- `jx-im/im-client` (Dart/Flutter, 2.3 GiB, latest)
- `jx-im/im-client-im-dev` (Dart, 1.1 GiB, dev branch carved out)
- `jx-im/im-client-ios-swift` / `-swift-demo` (native iOS)
- `Matrix-Ant-AI/im-client` (parallel?)
- `CUS-IM/customer-im-client` (customer-facing fork)
## Plugin set duplication
`jx-im-plugin` and `CUS-IM-Plugin` carry parallel forks of the same plugin set (kiwi_module, photo_view, pin_code_fields, pull_to_refresh, agora, camerawesome, im_camera, ZLImageEditor, etc.). When asked to fix a plugin, confirm which fork the user means.
## Where to look for what
- Onboarding flow / volunteer registration: `jx-im/worker-client/README.md` describes the "大仙接入" flow via http://www.dasheng.io
- Knowledge base / lessons learned / role docs: `jx-im/worker-knowledge/`
- Bot configs in production: `jx-im/claude-worker-universe/config/bots.json` (21 bots; ⚠ 19 plaintext tg_bot_tokens leaked in git — pending cleanup)
- Tinworker correction: canonical = `jx-im/worker-client` (verified 2026-04-25 by user; mini_tonky_bot/worker-client is a stale Phase-2 fork)
- 文殊菩萨 design (iter2 of /ralph): `~/dasheng-repos/.omc/notes/master-design.md` — full architecture; `~/dasheng-repos/.omc/prd-iter3.json` for execution stories
## Infrastructure access
- **EC2 server (also hosts Gitea)**: `dasheng.io`, user `ec2-user`, SSH key `/Users/pp-bot/Downloads/cc.pem` (chmod 400)
- AWS region: ap-southeast-2 (Sydney). Hostname: `ip-172-31-19-46.ap-southeast-2.compute.internal`. OS: Amazon Linux 2023.
- EC2-resident bots: `lobster-qa-bot` (八戒), `nezhasantaizi_bot` (哪吒三太子), `thin-nezha`. Run from `~/.claude/` on the EC2 box.
- env-var convention in `run_loop.py:6481`: `EC2_USER=ec2-user`, `EC2_HOST=dasheng.io`, `BAJIE_HOST=office-studio-cc` (SSH alias).
- Test command: `ssh -i /Users/pp-bot/Downloads/cc.pem ec2-user@dasheng.io 'whoami'`
## H5 vs iOS bot taxonomy (after 2026-04-25 user clarification)
4 H5 bots out of 21:
- jarvis_theone_bot (大仙·清源妙道真君, role=PM)
- kevins-studio-bot (奔波儿灞·Kevin, role=QA, qa_priority=true)
- andyjanebot (鬼金羊, role=QA, qa_priority=true)
- 虚日鼠 (planned: login=xurishu_bot, role=QA, qa_priority=true, tg_name=@newim2026wbot)
QA-priority H5 bot rule: verify open issues first, only switch to dev when no verification work pending.
## 文殊菩萨 (Manjushri) — planned new top-level role
- Inherits BOTH 八戒 (QA Automation) AND 唐僧 (PM Patrol) via composition (not subclass).
- Adds: PM-spec → test-case generation, hourly QA/test-task polling, cross-platform issue distribution, auto-PR (bot-dev → main), CLI surface, current-state-aware issue creation.
- node=MacBook (same as 唐僧). TG token reuse from 唐僧 (`tg_bot_token_inherits: lobster-pm-bot`); messages prefixed `[文殊菩萨]`.
- Module: `core/wen_shu_hub.py` (planned). Schedule: launchd plist (planned).
- Pre-req refactors before introduction: extract `sync_main_into_bot_dev` from `ba_jie_rev.merge_to_main:451-487`; extract `_fetch_open_issues_paginated` from 唐僧; add `RepoState` snapshot facade.

View File

@@ -0,0 +1,15 @@
---
name: bots.json node field is informational, not routing
description: When working with the dasheng claude-worker-universe bot registry, do not block planning or PRDs on resolving the node field for sub-bots; many run on colleague machines that the user does not own.
type: feedback
originSessionId: c2c569ed-e20b-4000-a286-8d48afea8d86
---
In `jx-im/claude-worker-universe/config/bots.json`, the `node` field on each bot entry is **informational, not behavioral**. Many sub-bots run on colleague machines outside the user's control. Do not treat unknown / unverified `node` values as blockers.
**Why:** User feedback 2026-04-25 iter2 of /ralph: "子机器人很多都是同事的机器 所以不要纠结在哪里" — many sub-bots are colleague-owned. The dispatch system uses Gitea labels + dashboard KV for routing, not the `node` field; bots self-register at startup.
**How to apply:**
- When designing or PRD-ing changes that touch bots.json, do NOT add acceptance criteria like "every bot has a verified node value" — accept `node="unknown"` or stale values.
- When asking the user about a new bot, DO NOT make the node a blocker question; default to `MacBook` (this user's primary machine) and let the colleague update it later if they own the bot.
- For 文殊菩萨 specifically: it runs on the same node as 唐僧 (MacBook) per separate instruction; that's fixed.
- Routing decisions (H5 vs iOS, qa_priority verify-first) come from `platforms` + `qa_priority` + `role_type` fields — never from `node`.