Principles and conventions only — what to obey and how to decide. History lives in docstrings, commits and records.
EMRG is a self-evolving AI agent architecture experiment: a micro-kernel — LLM-based task understanding and tool scheduling plus a thin file/exec shell — growing capabilities as runtime patches, in Python. README.md is canonical.
The server is the living core; a client is only the interface. Task understanding, tool scheduling, and self-evolution live there; one server serves many clients and outlives them.
emrg/— core:__main__.py(CLI),protocol.py,config.py,connect.py(WebSocket, token auth)emrg/server/— the daemon:daemon.py(messages, the evolution thread, the tool loop),llm.py,tool_types.py, task templatesemrg/tools/— bash, read, write, edit, glob, grep, base + registryemrg/skills/— skills from.emrg/skills/(progressive disclosure) + the installable-skill catalogemrg/client/— TUI:daemon_manager.py(daemon lifecycle + protocol client, shared with the GUI),app.pyemrg/gui/— Electron GUI (non-developer entry): the main process owns the connection, the renderer is sandboxedscripts/— the guards ·tests/— pytest suite ·packaging/— installers
- A change is not done until it is pushed and its guard runs in CI — local green is necessary, never sufficient
- Server logs are discarded (
stderr=DEVNULL); client logs go to./.emrg/emrg-client.log - A client auto-detects the server and starts it if absent
README.md/Agent.mdare English;README.cn.mdis Chinese- Commits:
emrg: <description>, English, one intent per commit - A derived number is never written where a guard can measure it; a mechanisable rule is mechanised
- Prefer inspectable state: everything the agent knows is a file
- Say the thing. Never narrate the conversation: who spoke first, which line was wrong, what class of problem this is.
- Every sentence has someone doing something. A clause crushed into a noun phrase (
名字撞上它赢) is not speech, nor is a clipped fragment. - Never say what the reader saw or thought.
- The test: a person in a novel could say it, and the reader learns one new thing.
- Be short. A long answer is not what a person says either. When length is truly needed: the point first, then its parts, each as long as it earns.
The execution model, in this repo's terms (emrg/server/daemon.py):
- Tool loop — everything one user message triggers: LLM requests and tool calls repeat until a round brings no new tool calls (
_run_tool_loop). - Round — one iteration inside a tool loop: one LLM request + zero or more tool calls + their execution (
round_num, bounded bymax_tool_rounds). - Evolution cycle — one full self-evolution run (Preparation → Look → Think → Act → Record). Never call it a "round".
What EMRG does today — capabilities, not a changelog.
- TUI client — markdown/diffs, slash commands, autocomplete, pickers, clipboard images (
visionper model), ESC interrupt, CJK input - Electron GUI — streaming chat, tool-status cards, sessions, models, settings, onboarding, reconnect, daemon respawn
- Scheduled tasks —
TaskHandlerper registered project: builtin and custom types, CRUD, hot reload,whenearly wake - Rant-driven evolution — host feedback through
/rantdrives the cycles - Memory — project and session memory (frontmatter + a Markdown index), compact/clear, capped prompt footprint
- Operational — config hot-reload, project tracking, headless GitHub auth
Foreground daemon: python -m emrg.
- Python:
uv run pytest tests/ -v— re-count withuv run --no-sync python3 scripts/check-doc-count.py --measure. Import check:uv run python -c "from emrg.client.app import run_client"GUI:cd emrg/gui && npm test(284: 107 daemon_client + 22 conn-manager + 7 integration + 7 nav-policy + 11 gui-state + 10 build-config + 10 config_fields + 16 boot-contract + 3 preload-api + 2 theme-guard + 2 image-hash + 8 switch-session + 19 atp_login + 4 gui-op-log + 9 theme-setting + 5 window-title + 4 frame-route + 12 browser-policy + 5 browser-wiring + 13 settings_store + 8 annotation-wiring) — syntax:node --check main.js preload.js daemon_client.jsRenderer:cd emrg/gui/renderer && npm run typecheck && npm test(1287: 5 snapshot-store + 13 utils + 3 ErrorBoundary + 2 App + 12 commands + 4 copywriting + 14 i18n + 33 markdown + 22 selection + 41 transcript + 11 conversationType + 4 MarkdownText + 65 TranscriptView + 22 history + 30 historyReplay + 8 userImages + 43 composer + 97 Composer + 14 sidebar + 32 workspaceView + 18 WorkspaceView + 10 dialog + 6 Dialog + 9 ConfirmDialog + 9 RenameDialog + 13 dialogLists + 3 HelpDialog + 9 MemoryDialog + 8 SkillsDialog + 8 openSession + 6 WelcomeDialog + 20 OpenSessionDialog + 14 NewSessionDialog + 7 rewind + 8 RewindDialog + 7 GithubDeviceDialog + 82 daemonBridge + 13 DaemonBridgeProvider + 69 Shell + 19 page + 51 EditorPanel + 25 DialogHost + 48 SettingsPanel + 18 TaskFormDialog + 5 RantDialog + 8 vendorMarkdown + 10 highlightTheme + 8 ApprovalDialog + 20 SandboxRootsDialog + 42 cockpit + 4 editorSelectionCascade + 9 fileTree + 24 FileTree + 5 contextMenu + 1 residue + 24 StatusBand + 24 UsageRanking + 9 usageRanking + 6 SearchOverlay + 5 ResizeHandle + 8 IconRail + 6 SessionColumn + 5 EmrgMark + 38 editorDoc + 27 CodeEditor + 30 annotation + 14 AnnotationMode) - CI: pytest on ubuntu and windows-2025, the GUI suites, and an actionlint gate over
.github/workflows/; re-trigger a dropped push withscripts/re-trigger-ci.sh <branch>, never an empty commit - Merge gates, run before merging —
uv run --no-sync python3 scripts/check-vote-count.py·scripts/check-pr-base.py·scripts/check-merge-freshness.py·scripts/check-merge-order.py·scripts/check-merge-landing-diff.py·scripts/check-merge-pairs.py/scripts/check-merge-sequence.py·scripts/check-merge-tree-health.py(the merged tree passes one guard) ·scripts/check-merge-plan-suite.py— all underuv run --no-sync python3 - Post-merge audit:
uv run --no-sync python3 scripts/check-merge-landed.py <N>(did it land the reviewed tree) - Other tools:
uv run --no-sync python3 scripts/check-node-test-count.py --write,scripts/check-memory-index.py,scripts/check-patch-files.py,scripts/check-staged-inverse.py,scripts/check-memory-rotation.py,scripts/cast-vote.py,scripts/feishu-gate.py,bump-version.py,classify-conflict.py,sync-master-from-api.py,push-branch-from-api.py
Every guard names the tree it reads; what it cannot answer is unmeasurable, never a pass.
- Bump —
python3 scripts/bump-version.py <x.y.z>rewrites every version declaration;tests/test_version_sync.pyproves they agree. PR it, take three approvals from different cycles, squash merge — never self-merge a release PR. - Tag —
git tag -a v<x.y.z> -m "emrg v<x.y.z>" && git push origin v<x.y.z>. The tag is the only trigger ofbuild-release.yml; Test never signs or notarizes. - Verify and confirm —
scripts/check-release-published.py v<x.y.z>: green across the platform matrix, published as Latest (not draft, not prerelease) with the full asset set.
bump-version.py --check and scripts/check-release-tag.py v<x.y.z> are the host-side counterparts: run both before pushing.
Only icon.svg is committed; generated icons are gitignored, built by CI (bash packaging/gen-assets.sh first; .icns needs macOS iconutil).
~/.emrg/config.toml — [llm] sets the default model; each [[llm.models]] entry adds a model for /model. A logged-in machine uses the configuration service; only the daemon reads or writes it. Template: DEVELOPMENT.md.