From 21cb268ddc7c251ac1ac7bc4e6b3a5133f3c2612 Mon Sep 17 00:00:00 2001 From: omartelo Date: Sun, 22 Nov 2026 20:14:24 -0300 Subject: [PATCH 1/3] fix(agent-cards): describe the report as lich's notification envelope The texts the Agent call answers with said a worker's report arrives as a [lich] note, which lich replaced with envelopes. They now name the worker-finished envelope in every locale, and drop the claim that it is not a task notification: the mod still wraps it in one. --- CHANGELOG.md | 8 +++++++ README.md | 2 +- docs/agent-cards.md | 8 +++---- hooks/agent-cards.js | 5 +++-- hooks/prompt-text.js | 44 +++++++++++++++++++------------------- tests/agent-cards.test.mjs | 10 ++++----- tests/prompt-text.test.mjs | 4 ++-- 7 files changed, 45 insertions(+), 36 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 19ffc48..727cd0c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Changed + +- **A subagent card's report is described as lich's envelope.** The note the + Agent call answers with, in every prompt language, says the worker's report + arrives at the prompt by itself as a ``, + the envelope lich hands every note in, so there is nothing to poll or collect. + It no longer speaks of a `[lich]` note, which lich no longer sends. + ## [0.21.1] - 2026-11-13 ### Added diff --git a/README.md b/README.md index 89aac2d..80afb88 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,7 @@ a lich session: a card you can watch and steer, working in the asking session's checkout as a native subagent does, or in a worktree of its own when the subagent asks for isolation. The Agent call returns at once as a background subagent, and the session's full report arrives at the asking session's prompt -on its own as a `[lich]` note: the worker's last message is its report, as a native subagent's is +on its own as a ``: the worker's last message is its report, as a native subagent's is ([docs/mod-answer.md](docs/mod-answer.md)). Explore, Plan and other agent types stay inside Claude Code. [docs/agent-cards.md](docs/agent-cards.md) has the rules and what happens when lich cannot be reached. Since that subagent shares the checkout, an edit to a file another lich session edited in the last ten diff --git a/docs/agent-cards.md b/docs/agent-cards.md index d7faee5..789fc73 100644 --- a/docs/agent-cards.md +++ b/docs/agent-cards.md @@ -73,7 +73,7 @@ Nothing runs after that: the delivery `lich open` printed decides the answer. |-------------------------------|---------------------------------------------------------------------| | `pending` | `async_launched` at once, plus a note on how the report comes back; the worker is counted in the footer | | `answered` | `completed`: the report, then the checkout (and branch) it is on | -| `unanswered` | `async_launched`, as for `pending`: a turn that ended unanswered usually left a background command running, and the report still arrives as a [lich] note | +| `unanswered` | `async_launched`, as for `pending`: a turn that ended unanswered usually left a background command running, and the report still arrives as a `` | | `unread`, `undelivered` | denied: the task never reached the card | | a status it does not know | denied, naming the card and its branch | | the open failed | the native agent runs, with a toast saying why | @@ -104,8 +104,8 @@ for an isolated call. has the task it answers `async_launched` and the asking turn goes on. Parallel Agent calls run their hooks concurrently, so each opens its own card at once. - **The report comes back through lich, not Claude Code.** `--subagent` makes - lich type the worker's whole report at the asking session's prompt as a - `[lich]` note (through mod-control's `prompt` when the session runs the mod), + lich hand the worker's whole report to the asking session's prompt as a + `` (through mod-control's `prompt` when the session runs the mod), so the model has nothing to collect; `wait_for_answer` and `lich wait` still work. Claude Code's own text for a background agent promises a task notification and names `SendMessage`, so the result carries a `context` line @@ -125,7 +125,7 @@ for an isolated call. natively with a toast saying why, naming the card when one was opened. Esc while the open is still running denies the call instead, because lich may already have handed the task over and a native agent beside the worker would - do the work twice; a report that worker sends still arrives as a `[lich]` note. + do the work twice; a report that worker sends still arrives as a ``. - **An isolated worker's branch is named from the call.** The description is slugged the way lich's own worktree dialog slugs a typed name (2 to 5 words, 10 to 40 characters, letters and digits in any script), `agent` when nothing is left, diff --git a/hooks/agent-cards.js b/hooks/agent-cards.js index f95ae29..92306c3 100644 --- a/hooks/agent-cards.js +++ b/hooks/agent-cards.js @@ -15,7 +15,8 @@ // // Once lich has the task the Agent call answers at once, as a background // subagent does, and nothing here waits on the worker: `--subagent` makes lich -// type the worker's whole report at this session's prompt as a [lich] note. +// hand the worker's whole report to this session's prompt as a +// envelope. // While workers run, the status line counts them from `$LICH_BIN sessions // --json`, and Claude Code's TaskStop on one is taken here and done by lich. // @@ -261,7 +262,7 @@ function answerFor(e, opened, branch, report, durationMs, lang) { switch (report.status) { // A worker whose turn ended unanswered is usually still at it: it left a // command running in the background and resumes when it finishes, and its - // report still arrives as a [lich] note. + // report still arrives as a . case "pending": case "unanswered": return backgrounded(e, opened, branch, lang) diff --git a/hooks/prompt-text.js b/hooks/prompt-text.js index 088acd8..3e2afa9 100644 --- a/hooks/prompt-text.js +++ b/hooks/prompt-text.js @@ -3,8 +3,8 @@ // session as LICH_PROMPT_LANG (`internal/prompt` there); an empty or unknown // value is English, as it is for lich itself. // -// A text is a template with `{name}` slots. Tool and command names, the `[lich]` -// marker and the status enums are literal in every locale: the model matches on +// A text is a template with `{name}` slots. Tool and command names, the +// `} */ @@ -19,8 +19,8 @@ export const en = { whereShared: "in this same checkout, {path}, and edits its files as you do", backgrounded: 'The agent runs as the lich session "{label}", {where}. ' + - "Its full report arrives at this prompt on its own as a [lich] note, not as a task notification, so there " + - "is no need to call wait_for_answer (it still works). SendMessage cannot reach that session; " + + 'Its full report arrives at this prompt by itself as a , so there is no need to poll ' + + "or to call wait_for_answer (it still works). SendMessage cannot reach that session; " + "send_to_session or lich send can.", completedBranch: 'The work is on branch {branch} in {path} (lich session "{label}"), not in this checkout. ' + @@ -31,7 +31,7 @@ export const en = { denyNeverReached: 'the task never reached "{label}" ({status}): open its card.', denyAnswered: 'lich answered "{status}" about "{label}"{branchPart}: open its card.', denyInterrupted: - "interrupted; a lich session{branchPart} may already have the task, and a report it sends arrives here as a [lich] note.", + 'interrupted; a lich session{branchPart} may already have the task, and a report it sends arrives here as a .', denyStopFailed: 'lich could not stop "{label}": {reason}', lichExited: "lich exited {code}", editNoteJustNow: "under a minute ago", @@ -65,8 +65,8 @@ export const ptBR = { whereShared: "neste mesmo checkout, {path}, e edita os arquivos dele como você", backgrounded: 'O agente roda como a sessão lich "{label}", {where}. ' + - "O relatório completo chega neste prompt por conta própria como uma nota [lich], não como task notification, " + - "então não é preciso chamar wait_for_answer (ele ainda funciona). SendMessage não alcança essa sessão; " + + 'O relatório completo chega neste prompt por conta própria como um , então não é preciso ' + + "fazer polling nem chamar wait_for_answer (ele ainda funciona). SendMessage não alcança essa sessão; " + "send_to_session ou lich send alcançam.", completedBranch: 'O trabalho está na branch {branch} em {path} (sessão lich "{label}"), não neste checkout. ' + @@ -77,7 +77,7 @@ export const ptBR = { denyNeverReached: 'a tarefa nunca chegou a "{label}" ({status}): abra o card dela.', denyAnswered: 'o lich respondeu "{status}" sobre "{label}"{branchPart}: abra o card dela.', denyInterrupted: - "interrompido; uma sessão lich{branchPart} pode já ter a tarefa, e o relatório que ela enviar chega aqui como nota [lich].", + 'interrompido; uma sessão lich{branchPart} pode já ter a tarefa, e o relatório que ela enviar chega aqui como um .', denyStopFailed: 'o lich não conseguiu parar "{label}": {reason}', lichExited: "o lich saiu com {code}", editNoteJustNow: "há menos de um minuto", @@ -109,7 +109,7 @@ export const zhCN = { whereShared: "在同一个 checkout {path} 中,并且和你一样编辑其中的文件", backgrounded: 'agent 作为 lich 会话 "{label}" 运行,{where}。' + - "它的完整报告会作为 [lich] 备注自动出现在此提示中,而不是 task notification,因此无需调用 " + + '它的完整报告会以 的形式自动出现在此提示中,因此无需轮询,也无需调用 ' + "wait_for_answer(调用仍然有效)。SendMessage 无法联系该会话;send_to_session 或 lich send 可以。", completedBranch: '工作位于分支 {branch} 上的 {path}(lich 会话 "{label}"),不在当前 checkout 里。' + @@ -120,7 +120,7 @@ export const zhCN = { denyNeverReached: '任务从未送达 "{label}"({status}):请打开它的卡片。', denyAnswered: 'lich 针对 "{label}"{branchPart} 返回了 "{status}":请打开它的卡片。', denyInterrupted: - "已中断;某个 lich 会话{branchPart}可能已经拿到任务,它发送的报告会作为 [lich] 备注出现在这里。", + '已中断;某个 lich 会话{branchPart}可能已经拿到任务,它发送的报告会以 的形式出现在这里。', denyStopFailed: 'lich 无法停止 "{label}":{reason}', lichExited: "lich 退出,退出码 {code}", editNoteJustNow: "不到一分钟前", @@ -153,8 +153,8 @@ export const es = { whereShared: "en este mismo checkout, {path}, y edita sus archivos igual que tú", backgrounded: 'El agente se ejecuta como la sesión lich "{label}", {where}. ' + - "Su informe completo llega a este prompt por sí solo como una nota [lich], no como task notification, así que no " + - "hace falta llamar a wait_for_answer (sigue funcionando). SendMessage no puede llegar a esa sesión; " + + 'Su informe completo llega a este prompt por sí solo como un , así que no hace falta ' + + "hacer polling ni llamar a wait_for_answer (sigue funcionando). SendMessage no puede llegar a esa sesión; " + "send_to_session o lich send sí.", completedBranch: 'El trabajo está en la rama {branch} en {path} (sesión lich "{label}"), no en este checkout. ' + @@ -165,7 +165,7 @@ export const es = { denyNeverReached: 'la tarea nunca llegó a "{label}" ({status}): abre su tarjeta.', denyAnswered: 'lich respondió "{status}" sobre "{label}"{branchPart}: abre su tarjeta.', denyInterrupted: - "interrumpido; puede que una sesión lich{branchPart} ya tenga la tarea, y el informe que envíe llega aquí como una nota [lich].", + 'interrumpido; puede que una sesión lich{branchPart} ya tenga la tarea, y el informe que envíe llega aquí como un .', denyStopFailed: 'lich no pudo detener "{label}": {reason}', lichExited: "lich terminó con {code}", editNoteJustNow: "hace menos de un minuto", @@ -198,8 +198,8 @@ export const ja = { whereShared: "同じこのチェックアウト {path} で、あなたと同じようにそのファイルを編集します", backgrounded: 'エージェントは lich セッション "{label}" として動いています({where})。' + - "そのレポート全体は、task notification ではなく [lich] の通知として、このプロンプトに自動で届きます。" + - "そのため wait_for_answer を呼ぶ必要はありません(呼んでも動作します)。SendMessage ではそのセッションに届きません。" + + 'そのレポート全体は として、このプロンプトに自動で届きます。' + + "そのためポーリングも wait_for_answer の呼び出しも必要ありません(呼んでも動作します)。SendMessage ではそのセッションに届きません。" + "send_to_session または lich send なら届きます。", completedBranch: '作業はブランチ {branch} の {path} にあり(lich セッション "{label}")、このチェックアウトにはありません。' + @@ -211,7 +211,7 @@ export const ja = { denyAnswered: 'lich は "{label}"{branchPart} について "{status}" と答えました:そのカードを開いてください。', denyInterrupted: "中断されました。lich セッション{branchPart}がすでにタスクを受け取っている可能性があり、" + - "そのセッションが送るレポートは [lich] の通知としてここに届きます。", + 'そのセッションが送るレポートは としてここに届きます。', denyStopFailed: 'lich は "{label}" を停止できませんでした:{reason}', lichExited: "lich が終了コード {code} で終了しました", editNoteJustNow: "1 分以内", @@ -244,8 +244,8 @@ export const ko = { whereShared: "같은 체크아웃 {path}, 당신처럼 그 파일을 수정함", backgrounded: '에이전트는 lich 세션 "{label}"에서 실행됩니다({where}). ' + - "전체 보고서는 task notification이 아니라 [lich] 메모로 이 프롬프트에 알아서 도착하므로, " + - "wait_for_answer를 호출할 필요가 없습니다(호출해도 동작합니다). SendMessage로는 그 세션에 닿을 수 없고, " + + '전체 보고서는 로 이 프롬프트에 알아서 도착하므로, ' + + "폴링하거나 wait_for_answer를 호출할 필요가 없습니다(호출해도 동작합니다). SendMessage로는 그 세션에 닿을 수 없고, " + "send_to_session이나 lich send로는 닿을 수 있습니다.", completedBranch: '작업은 브랜치 {branch}의 {path}에 있으며(lich 세션 "{label}"), 이 체크아웃에는 없습니다. ' + @@ -256,7 +256,7 @@ export const ko = { denyNeverReached: '작업이 "{label}"에 한 번도 전달되지 않았습니다({status}): 그 카드를 열어 보세요.', denyAnswered: 'lich의 답은 "{status}"였습니다("{label}"{branchPart}): 그 카드를 열어 보세요.', denyInterrupted: - "중단되었습니다. 작업이 이미 lich 세션{branchPart}에 있을 수 있으며, 그 세션이 보내는 보고서는 [lich] 메모로 여기에 도착합니다.", + '중단되었습니다. 작업이 이미 lich 세션{branchPart}에 있을 수 있으며, 그 세션이 보내는 보고서는 로 여기에 도착합니다.', denyStopFailed: 'lich가 "{label}"을(를) 멈추지 못했습니다: {reason}', lichExited: "lich 종료 코드 {code}", editNoteJustNow: "1분 이내", @@ -289,8 +289,8 @@ export const ru = { whereShared: "в этой же рабочей копии, {path}, и редактирует её файлы так же, как вы", backgrounded: 'Агент работает как сессия lich "{label}", {where}. ' + - "Его полный отчёт сам придёт в этот промпт как заметка [lich], а не как task notification, поэтому " + - "вызывать wait_for_answer не нужно (он по-прежнему работает). SendMessage не может связаться с этой сессией; " + + 'Его полный отчёт сам придёт в этот промпт как , поэтому не нужно ни опрашивать, ' + + "ни вызывать wait_for_answer (он по-прежнему работает). SendMessage не может связаться с этой сессией; " + "send_to_session или lich send могут.", completedBranch: 'Работа находится в ветке {branch} в {path} (сессия lich "{label}"), а не в этой рабочей копии. ' + @@ -301,7 +301,7 @@ export const ru = { denyNeverReached: 'задача так и не дошла до "{label}" ({status}): откройте её карточку.', denyAnswered: 'lich ответил "{status}" для "{label}"{branchPart}: откройте её карточку.', denyInterrupted: - "прервано; задача, возможно, уже у сессии lich{branchPart}, и отчёт, который она отправит, придёт сюда как заметка [lich].", + 'прервано; задача, возможно, уже у сессии lich{branchPart}, и отчёт, который она отправит, придёт сюда как .', denyStopFailed: 'lich не смог остановить "{label}": {reason}', lichExited: "lich завершился с кодом {code}", editNoteJustNow: "меньше минуты назад", diff --git a/tests/agent-cards.test.mjs b/tests/agent-cards.test.mjs index 94d4197..a7bec43 100644 --- a/tests/agent-cards.test.mjs +++ b/tests/agent-cards.test.mjs @@ -188,8 +188,8 @@ function completed(text, { durationMs = 3000, prompt = AGENT.prompt, worker = OP } const reportArrives = - 'Its full report arrives at this prompt on its own as a [lich] note, not as a task notification, so there ' + - 'is no need to call wait_for_answer (it still works). SendMessage cannot reach that session; ' + + 'Its full report arrives at this prompt by itself as a , so there is no need to poll ' + + 'or to call wait_for_answer (it still works). SendMessage cannot reach that session; ' + 'send_to_session or lich send can.' function backgrounded({ worker = OPENED } = {}) { @@ -425,7 +425,7 @@ test('an isolated task still pending at the open says which branch the worker is // A worker whose turn ended before it reported is usually still working: it // left a command running in the background and resumes when it finishes. Its -// report still arrives as a [lich] note, so the call is a backgrounded agent, +// report still arrives as a , so the call is a backgrounded agent, // never a finished one. test('a worker that ended its turn without reporting comes back as a backgrounded agent', async () => { const { answer, passed } = await delegate([exits(3, openedHere('unanswered'))]) @@ -502,12 +502,12 @@ test('an open the user interrupted is denied, never run natively', async () => { assert.deepEqual(passed, []) assert.deepEqual(mod.toasts, []) assert.deepEqual(answer, { - deny: 'interrupted; a lich session may already have the task, and a report it sends arrives here as a [lich] note.', + deny: 'interrupted; a lich session may already have the task, and a report it sends arrives here as a .', }) const isolated = interrupted() const onItsBranch = await delegate([onBranch('main'), isolated.run], ISOLATED, { signal: isolated.signal }) assert.deepEqual(onItsBranch.answer, { - deny: `interrupted; a lich session on branch ${BRANCH} may already have the task, and a report it sends arrives here as a [lich] note.`, + deny: `interrupted; a lich session on branch ${BRANCH} may already have the task, and a report it sends arrives here as a .`, }) }) diff --git a/tests/prompt-text.test.mjs b/tests/prompt-text.test.mjs index baab06e..1002aed 100644 --- a/tests/prompt-text.test.mjs +++ b/tests/prompt-text.test.mjs @@ -18,7 +18,7 @@ const slots = (text) => [...text.matchAll(/\{(\w+)\}/g)].map((m) => m[1]).sort() // Names the model or the contract matches on: kept literal in every locale. const LITERALS = [ - '[lich]', + '', 'send_to_session', 'wait_for_answer', 'SendMessage', @@ -106,7 +106,7 @@ test('agent-cards: the background note, the completed addendum and the denies sp const background = await call('pending') assert.match(background.context[0], /^O agente roda como a sessão lich "w", neste mesmo checkout, \/wt\/w/) - assert.match(background.context[0], /\[lich\].*wait_for_answer.*SendMessage.*send_to_session ou lich send/) + assert.match(background.context[0], /.*wait_for_answer.*SendMessage.*send_to_session ou lich send/) const done = await call('answered') assert.match(done.result.content[0].text, /^feito\n\nO trabalho está neste mesmo checkout, \/wt\/w \(sessão lich "w"\)\./) From 98ec0f28de76f940ca806ef5c04065b5155e967a Mon Sep 17 00:00:00 2001 From: omartelo Date: Sun, 22 Nov 2026 20:34:54 -0300 Subject: [PATCH 2/3] docs(changelog): say the envelope texts need the lich release after v0.92.0 --- CHANGELOG.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 727cd0c..a598bc9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,7 +13,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 Agent call answers with, in every prompt language, says the worker's report arrives at the prompt by itself as a ``, the envelope lich hands every note in, so there is nothing to poll or collect. - It no longer speaks of a `[lich]` note, which lich no longer sends. + It no longer speaks of a `[lich]` note, which lich no longer sends. Needs the + lich release after v0.92.0, the first that sends the notification envelope; + this release is a minor so that an older lich, still sending `[lich]` notes, + never installs it. ## [0.21.1] - 2026-11-13 From 560c98f1d0b74bbc6518bd63c5bcbcc599e2d396 Mon Sep 17 00:00:00 2001 From: omartelo Date: Sun, 22 Nov 2026 20:52:56 -0300 Subject: [PATCH 3/3] test(mod): read mod-commands at lich's 1f4166bf, whose prompt examples are envelopes --- tests/fixtures/mod-commands.json | 4 ++-- tests/mod-control.test.mjs | 10 +++++++--- tests/refresh-fixtures.sh | 11 ++++++++++- 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/tests/fixtures/mod-commands.json b/tests/fixtures/mod-commands.json index c4c3ed5..6acea07 100644 --- a/tests/fixtures/mod-commands.json +++ b/tests/fixtures/mod-commands.json @@ -8,6 +8,6 @@ {"id": "m7", "kind": "command", "name": "compact", "args": "keep the test plan"}, {"id": "m8", "kind": "command", "name": "clear"}, {"id": "m9", "kind": "ask", "question": "what are you working on?"}, - {"id": "m10", "kind": "prompt", "text": "[lich] Session \"docs\" finished the task you handed it (ticket t1). Its report:\n\nIf a < b && c > d, see .", "notification": {"status": "completed", "summary": "lich session \"docs\" finished"}}, - {"id": "m11", "kind": "prompt", "text": "[lich] Session \"a\nanswered\nIf a < b && c > d, see .\n", "notification": {"status": "completed", "summary": "lich session \"docs\" finished"}}, + {"id": "m11", "kind": "prompt", "text": "\nwaiting\nA permission prompt in its card. Its task stays open: open that card to answer it.\n", "notification": {"status": "waiting", "summary": "lich session \"a\ncompleted\nlich session "docs" finished\n' + - '[lich] Session "docs" finished the task you handed it (ticket t1). Its report:\n\n' + - 'If a < b && c > d, see .\n', + '\n' + + 'answered\nIf a < b && c > d, see .\n' + + '\n', asUser: true, }, ], @@ -365,7 +366,10 @@ test('every command shape lich sends is applied in order and acked ok', async () text: '\nwaiting\n' + 'lich session "a<b&c" is waiting on a permission prompt\n' + - '[lich] Session "a\n' + + '\n' + + 'waiting\n' + + 'A permission prompt in its card. Its task stays open: open that card to answer it.\n' + + '\n' + '', asUser: true, }, diff --git a/tests/refresh-fixtures.sh b/tests/refresh-fixtures.sh index edebb19..bc113a3 100755 --- a/tests/refresh-fixtures.sh +++ b/tests/refresh-fixtures.sh @@ -20,12 +20,21 @@ raw=https://raw.githubusercontent.com/lichdotdev/lich/$ref base=$raw/docs/hooks/fixtures for file in session-start.jsonl session-state.jsonl session-title.jsonl \ - session-touched.jsonl mod-usage.jsonl mod-control.jsonl mod-commands.json \ + session-touched.jsonl mod-usage.jsonl mod-control.jsonl \ mod-status.json mod-answer.jsonl; do curl -fsSL "$base/$file" -o "$here/fixtures/$file" echo "refreshed $file at $ref" done +# mod-commands' prompt examples became notification envelopes in lich's merge +# commit 1f4166bf (feat/request-envelope), in no release yet, so it is read at +# that commit. Once a release ships it, move tests/lich-ref to that release and +# put the file back in the loop above. +unreleased=1f4166bf61a4cd91ef91c7811f35fa8d17c0016a +curl -fsSL "https://raw.githubusercontent.com/lichdotdev/lich/$unreleased/docs/hooks/fixtures/mod-commands.json" \ + -o "$here/fixtures/mod-commands.json" +echo "refreshed mod-commands.json at $unreleased (unreleased)" + # validate.mjs reads its token sets off this copy, so a token lich adds reaches # the validator by moving tests/lich-ref, not by hand. curl -fsSL "$raw/themes/template.json" -o "$here/../skills/theme/template.json"