Dev Log: Secretary agent, WeChat addon, session log, recipe skills, Zhipu provider

devlogdaily

This entry covers two days of work (Apr 10–11). 111 commits across two repos, +18,585 / -1,780 lines.

Secretary Agent

A new background agent that runs on a self-clocking hourly schedule, scanning session history and maintaining three files:

Two-phase architecture:

  1. Observation — each cycle reads ONE hourly history file, distills it into a condensed draft (~200–500 words), submits to library. Library entries survive molts. One file per cycle, round-robin across projects if multiple have backlogs.
  2. Consolidation — when all pending files are processed, loads all drafts for a project, does a complete rewrite of journal, optionally updates profile, constructs brief, verifies token counts, git-commits everything, deletes consumed drafts. Then waits for next hourly cycle.

Self-clocking: uses email(schedule) to send itself a “briefing cycle” email every hour. Backlog processing uses 5-minute follow-ups. No human intervention needed.

TUI integration:

The briefing skill went through multiple iterations to reach the final two-phase design with molt safety (drafts in library), token verification after every write, git version control in ~/.lingtai-tui/brief/, and memory-append workbench (pin profile + journal as read-only reference during consolidation).

Session Log System

New SessionCache replaces the old verbose.go, making session.jsonl the single source of truth for the TUI chat view.

Architecture: append-only write from three sources (mail, events.jsonl, soul_inquiry.jsonl), deduplicated by (from, ts) key, sorted chronologically. Detects hour boundaries on append — completed hours are automatically dumped as Markdown files for the secretary to read.

Key functions: NewSessionCache(), RebuildFromSources(), IngestMail/Events/Inquiries(), ProjectHash(), BriefFilePath(), dumpCompletedHour(), DumpAllHours().

Migrations:

Deleted verbose.go (-192 lines) — fully replaced.

Recipe System Upgrades

Recipe-Shipped Skills

Recipes can now include skill directories. On startup, the TUI auto-links them into .skills/ via symlinks. Uninstalling a recipe cleans up stale symlinks.

Language fallback chain: wen → zh → en → root. LinkRecipeSkills() handles bundled recipes first, then custom, then agora imports. PruneStaleSkillSymlinks() removes dead links.

recipe.json Manifest

Each recipe now carries a recipe.json metadata file with name and description, used for picker display. New RecipeInfo struct + LoadRecipeInfo() function. Supports imported recipe detection.

Covenant & Procedures Override

Recipes can override covenant.md and procedures.md per language. Resolved via ResolveCovenantPath() / ResolveProceduresPath() with language fallback.

lingtai-recipe Skill

Self-documenting skill in English and Chinese — agents can query the recipe system’s complete documentation via skills().

Default Recipe

Changed from adaptive to greeter.

Markdown Viewer

Reusable two-panel Bubble Tea component (MarkdownViewerModel) — left entry list + right rendered viewport with keyboard/mouse navigation.

Replaced the skills view and recipe preview implementations. skills.go went from ~284 lines to ~50. Recipe preview in firstrun.go from ~226 lines to ~115.

WeChat Addon

Full implementation of Tencent’s iLink Bot protocol from scratch, spanning both repos.

Kernel (Python — 6 modules)

ModuleWhat it does
types.pyProtocol dataclasses — MessageItemType (TEXT/IMAGE/VOICE/FILE/VIDEO), WeixinMessage, serialization functions
api.py5 async HTTP endpoint wrappers — get_qrcode(), poll_qr_status(), get_updates(), send_message(), get_upload_url(), get_config()
login.pycli_login() — displays QR in terminal, polls for scan confirmation, saves credentials.json (mode 0600)
media.pydownload_media(), decode_voice() (SILK→WAV via pilk), upload_media(), make_media_item()
manager.pyWechatManager — daemon thread poll loop, 8 action handlers (send/check/read/reply/search/contacts/add_contact/remove_contact), atomic file writes, thread-safe shared state
__init__.pysetup() entry point — loads config + credentials, creates manager, registers wechat tool

21 test functions across 3 test files. Post-audit fixes: async/sync boundary (run_coroutine_threadsafe), stop() deadlock removal, data race protection via threading.Lock, self-echo filtering, text chunking at 4000 chars.

TUI (Go)

Zhipu Provider

Full-stack integration of Zhipu GLM-5.1 as an LLM provider.

TUI: registered as preset with OpenAI-compatible API, env var ZHIPU_API_KEY, added to /setup flow and /doctor diagnostics.

Kernel — new services:

MCP infrastructure: new HTTPMCPClient class (+182 lines in services/mcp.py) for remote HTTP MCP servers. servers.json now supports "type": "http" alongside stdio.

Kernel Capability Enhancements

Psyche — Memory Append

New memory append action: pin files as read-only references that are re-read on every memory load, survive molts without being baked into memory.md. Primary use: secretary pins profile + journal during consolidation. Token guard at 100k, binary file detection, persisted to system/memory_append.json.

Also fixed schema enum: "character""lingtai" to match dispatch table.

Email — Filter Sub-Object

email(check) gains a filter parameter: sort, from, subject, contains (substring), after/before (ISO 8601), unread_only, has_attachments, truncate (preview char limit). Response capped at 10k tokens.

Procedures System Prompt

New first-class procedures section (peer of principle, covenant). Centralizes molt procedure, reduces duplication in tool descriptions.

Refresh Lock Polling

Fixed race condition: /refresh now polls for .agent.lock release (up to 60s) instead of fixed 3s sleep.

System Procedures

Trilingual operational procedures (procedures/en/, zh/, wen/) seeded to all agents via migration m009. Recipes can override per language.

Other

Migrations

VersionNameDescription
m009proceduresSeed trilingual procedures.md to all agents
m010legacy_addons_warnDetect old addon path, print warning
m011session_backfillRebuild session.jsonl, backfill history to brief dir
m012session_resortRebuild session.jsonl from sources on every startup

Current version: 12