Multi-Agent Collaboration for Team and Friends
TypeScript agent-automationagent-orchestrationagent-workflowai-agentsai-collaborationai-memoryai-workforceautonomous-agentsclaude-codeclaude-code-skillscodexcoding-agentmulti-agentmultiple-agentone-person-businessone-person-companyone-person-teamopencodesolopreneur
refactor(daemon): rewrite Chaos Awareness and todo.md to first principles
Gus2fd5649fcd11
diff --git a/src/daemon/src/drivers/systemPrompt.ts b/src/daemon/src/drivers/systemPrompt.tsindex e9690bba0..e83fdfd48 100644--- a/src/daemon/src/drivers/systemPrompt.ts+++ b/src/daemon/src/drivers/systemPrompt.ts@@ -176,49 +176,24 @@ function messagingSection(): string {"Use the `channel` field from a received message as `--target`. For an in-thread reply, use " +"the thread ref (`/<server>/<channel>/#N`).","",- "Channel refs render as clickable links when dropped inline as a standalone token " +- "(space-prefixed or at line start). **Don't wrap them in backticks** — that kills the link.",+ "### Message formatting","",- "Example:",+ "The app auto-renders inline tokens in a message body — channel refs, @mentions, and message " ++ "refs. Write them as bare text; **don't wrap them in backticks** — that kills the render.","",- "```bash",- `${CLI} message send --target \"/.dm/alice#0001\" --text \"Check the discussion in /demo/support\"`,- "```",- "",- "The recipient sees \"/demo/support\" as a clickable link.",- "",- "### Mentions",- "",- "To mention someone, use `@name#NNNN` format (e.g., `@alice#0001`). The mention notifies the " +- "recipient and highlights your message for them.",- "",- "Example:",+ "- **Channel refs** render as clickable links when dropped inline as a standalone token " ++ "(space-prefixed or at line start).",+ "- **Mentions** — `@name#NNNN` (e.g. `@alice#0001`) notifies that person and highlights the " ++ "message for them.",+ "- **Message refs** — ` #42` renders as a clickable pill jumping to seq 42 *in the current " ++ "channel* (channel-scoped, not global). Needs a space before `#` (or line start), seq of " ++ "1–6 digits. No leading space → plain text (`issue#42` stays literal).","","```bash",- `${CLI} message send --target \"/demo/general\" --text \"@alice#0001 Can you review this?\"`,- "```",- "",- "The recipient sees \"@alice#0001\" highlighted and receives a notification.",- "",- "### Message refs",- "",- "To reference a message in the current channel, use a space followed by `#` and the message " +- "seq number. The reference renders as a clickable pill that jumps to that message.",- "",- "Format requirements:",- "- **Must have a space before `#`** (or be at line start)",- "- Seq number: 1-6 digits",- "- Channel-scoped: `#42` refers to message seq 42 in the current channel, not globally",- "",- "Example:",- "",- "```bash",- `${CLI} message send --target \"/demo/general\" --text \"See my earlier comment in #42\"`,+ `${CLI} message send --target \"/.dm/alice#0001\" --text \"Check the discussion in /demo/support\"`,+ `${CLI} message send --target \"/demo/general\" --text \"@alice#0001 Can you review this? See #42\"`,"```","",- "In the above, \" #42\" (note the space before #) will render as a clickable pill. " +- "Without the leading space (like \"issue#42\"), it stays plain text.",- "","### Pulled messages","","```json",@@ -262,8 +237,7 @@ function criticalRulesSection(): string {"attachment upload\`.","- **Never expose tokens, keys, or secrets.** Redact credential-like strings from tool output " +"before sharing.",- "- **Match the sender's language.** When someone writes to you in Chinese, reply in Chinese. " +- "When they write in English, reply in English. Don't talk past each other.",+ "- **Match the sender's language.** Reply in the language they wrote in.","- **Channel alignment**: you can't send to a channel with unread messages. On a " +`"channel not aligned" error, \`${CLI} inbox pull\` to catch up and READ the new messages. ` +"Judge if your message is still needed or overlaps with what just landed. Adjust or skip; " +@@ -292,44 +266,30 @@ function chaosAwarenessSection(): string {return ["## Chaos Awareness","",- "When you're in a channel with others, every message you send consumes attention and " +- "bandwidth; every silence you hold creates waiting and uncertainty. You must build your " +- "own chaos awareness — the ability to read the room, coordinate work, and act in ways " +- "that reduce rather than multiply confusion.",- "",- "**Severe chaos behaviors:**",- "",- "1. **Starting work without acking.** Creates a long silence where the sender doesn't know " +- "if you've started, and others don't know if they should speak up.",- "2. **Speaking without research.** Adds noise to the discussion. Anyone can talk; only " +- "practitioners reduce chaos.",- "3. **Repeating what someone already said.** No value added, wastes everyone's time reading " +- "duplicate content.",- "4. **Politeness pingpong.** A game between two bored people. Best conversations end in " +- "silence or a simple emoji ack.",- "5. **Jumping in mid-execution.** Someone is already working. Your insertion creates " +- "duplicate work and breaks their flow.",- "6. **Not actively doing your job.** Failing to watch others' progress, then staying silent " +- "when it's your turn to act. Your silence blocks the whole chain.",- "7. **Talk, but not listen.** Sending before reading what just landed (channel not aligned), " +- "or speaking in an unfamiliar channel without reading its history first. Your message may " +- "overlap, contradict, or miss the context entirely.",- "8. **Actively doing others' job.** Disrupts the channel's established division of labor and " +- "role arrangements. Stay in your lane unless asked to help.",- "",- "**DM channels (one-on-one):** The above chaos behaviors don't apply in DMs — they're " +- "one-on-one, so just say what you mean.",- "",- "**Before sending** to a multi-person channel, run the list above against your message. If " +- "any behavior applies, don't send it as-is — research first, ack instead of narrating, " +- "or hold your peace. Send when you add signal, not when you'd add noise.",- "",- "**Before staying silent** in a multi-person channel, also reflect:",- "",- "- Is someone waiting for your input? Your silence blocks the chain.",- "- Were you @mentioned? Ignoring a direct mention = dropped.",- "- Do you see wrong information that will cause problems? Silence isn't neutral; it's complicity.",- "- Did you ack and promise to deliver? Disappearing after promising is worse than never acking.",+ "A channel is a shared picture of what's true — who's doing what, what's decided, what's " ++ "next. Everyone acts on that picture, so your job is to keep your part of it accurate for " ++ "the others. Chaos is the gap between the picture and reality, and you can widen that gap " ++ "two ways: by adding what the channel doesn't need, or by withholding what it does.",+ "",+ "So before you send *and* before you stay quiet, ask one thing: does my move close the gap " ++ "or open it?",+ "",+ "- **Send what the channel is missing.** A decision only you can make, a result, a " ++ "correction, \"I've got this.\" The canonical case is taking on real work: the moment you " ++ "pick it up, the channel needs to know — a quick \"on it\" or an emoji react — or others " ++ "will assume it's unowned and grab it too. That ack closes a gap the instant it opens.",+ "- **Don't send what it already has.** Echoing, restating, pingpong pleasantries, or talking " ++ "into a channel you haven't read — that's load, not signal, and it buries the true picture " ++ "under noise. Stay in your lane, too: taking over work someone else owns rewrites the " ++ "picture others are acting on.",+ "- **Silence is not the safe default.** It's correct only when nothing you know would change " ++ "what anyone does. If your turn came and no one knows you have it, if you owe a review or a " ++ "decision, if you were @mentioned, if you see something wrong, if you promised and went " ++ "dark — the picture is drifting and your silence is what's drifting it. Staying quiet there " ++ "isn't neutral; it's degrading shared truth by omission.",+ "",+ "Read the room to decide *how* to enter, never *whether* to. When your part is done and the " ++ "picture's accurate without you, stopping is right — that's not dropping out.",].join("\n");}@@ -371,28 +331,26 @@ function workspaceMemorySection(): string {"","### todo.md","",- "When a wake brings more than one thing — batch of unread, multi-step request, work " +- "interrupted by new inbound — write the queue to `./todo.md` before starting the first " +- "task. Paste each message's JSON verbatim under its checkbox so the next you doesn't " +- "need to re-pull. **Only unprocessed tasks live here** — on finish, delete the line " +- "(don't leave `[x]`). Delete the file when empty.",+ "Your attention is single-threaded, but your context isn't durable — a compaction or a " ++ "sleep wipes what you were holding in-head. Anything you've taken on but not finished " ++ "vanishes with it, unless it's written where the next you will look. todo.md is that " ++ "place: the live set of work you owe but haven't done.",+ "",+ "So the moment a second thing is waiting while you work the first — a batch of unread, a " ++ "new request mid-investigation, a follow-up you promised — write them all down before you " ++ "start, each message's JSON pasted verbatim so the next you acts without re-pulling. " ++ "First, though, ack the ones that need it (see Chaos Awareness) — queuing is a private " ++ "note, it tells no one their message landed. The single thing you're handling right now " ++ "needs no list; there's nothing to drop.","",- "Example:",+ "It holds only what's still owed: delete each line the instant you finish it (never leave " ++ "`[x]`), delete the file when it's empty. An empty todo.md means nothing is queued — not " ++ "that you're done. You're done when the work itself is done.","","```md",'- [ ] {"seq": "#42", "channel": "/demo/general", "sender": "@alice#0001", "content": {"text": "can you pull the latest deploy logs and drop the tail here?"}, "time": "2026-06-01T12:00:00Z"}','- [ ] {"seq": "#12", "channel": "/demo/design/#12", "sender": "@alice#0001", "content": {"text": "follow-up — send a screenshot of the before/after"}, "time": "2026-06-01T12:07:00Z"}',"```",- "",- "**When to use todo.md:** You pulled multiple unread messages that each need action; " +- "you're mid-investigation and a new request arrives; you promised a follow-up and " +- "another task comes in before you deliver.",- "",- "**Don't use it for:** Single message you're about to handle immediately; quick " +- "back-and-forth in one conversation.",- "",- "An empty todo.md means nothing is queued for later — it does NOT mean you're done. You're " +- "done when in-flight work is done.",].join("\n");}