SLOPSHOPPER

cc-sticky-probe

M0 probe for cc-sticky-notes: logs what the Mods API really does

bandrowstoastpromptmodelnetwork
★ 1v0.0.1no licenseupdated 2026-10-07k7term1a/cc-sticky-notes/probes/m0
A shopper browsing a rack in a slop shop
Preview · a replayed session in a sandbox
claude · ~/work/app · cc-sticky-probe
› fix the failing auth test and add an audit log call ● cc-sticky-probe: PROBE session.start e={"cwd":"/work/app","surface":"terminal","isInteractive":true} ● cc-sticky-probe: PROBE version={"version":"2.1.289","base":"2.1.289","builtAt":"2026-10-03T00:00:00Z"} ⏺ Read(src/auth.ts) ⎿ Read 6 lines ⏺ Update(src/auth.ts) ⎿ Added 2 lines, removed 1 line ⏺ Bash(bun test) ⎿ 3 pass, 1 fail ● Done. refresh now rejects expired claims and logs an audit event. ✻ Worked for 42s · done 4:20 PM ● cc-sticky-probe: PROBE id=preview-session root=/work/app cwd=/work/app ● cc-sticky-probe: PROBE surfaces=["terminal"] plugin.root=/plugins/cc-sticky-probe [ open ] ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── › ? for shortcuts

Draws

Band
[ open ]
README

cc-sticky-notes

一個 Claude Code mod:在專案 session 裡隨口問的「為什麼 / 這是什麼」不會進主線對話,而是變成「便利貼」,在背景回答、顯示在右側 pane,並存成一棵同專案所有 session 共用的樹。主線的 context 保持乾淨,追問也能一路掛在同一條旁支下。

版本 0.0.4,給朋友試用中。設計與決策:PLAN.md;Mods API 實測紀錄:PROBE.md;之後可能做的需求:REQUESTS.md。

0.0.4 新的地方

  • 多台電腦同步(選用):便利貼透過你自己的 Notion 資料庫在電腦之間同步,見下方「在多台電腦之間同步」。
  • 卡片時間前面有底色的類別標籤:Jev 對這個主題的判斷(知識旁問、專案疑問、主線任務)。
  • 刪除便利貼:問題旁的 ✕ 或 /sn rm,只刪這台電腦的。
  • Jev 的對話框 30 秒沒回應就自動送進主線(/sn timeout <秒> 調整,0 一直等)。對話框本身會留在畫面上,關掉就好。
  • 拿掉「結束追問」按鈕(改用 /sn back);舊的「這題在主線回答」便利貼會在開 session 時自動清掉。
  • /sn provider、/sn every、/sn notion 的設定改存在每台電腦自己的資料裡(之前在 Desktop 會設定失敗)。

0.0.3 新的地方

  • pane 改成卡片:一個主題一張卡,點開是一段對話(問題像 prompt 泡泡、答案在下面),多個追問用按鈕切換,卡片最下面直接回覆;滑鼠移到問題旁的 ✎ 可以換個問法再問一次。正在追問的那張是綠框。
  • 主線摘要與專案脈絡:每 3 個主線回合在背景統整一次(第一次讀整個 session),Jev 判斷時會參考;pane 最下面的「專案脈絡」卡片可以看、刪、加,或按「立即統整」。
  • 新指令:/sn provider claude|openai 切換統整層、/sn every <n> 調整統整頻率(0 關閉)、/sn ctx 看與編輯專案脈絡。
  • OpenAI 的 redacted 模式現在真的會先剝掉程式碼、路徑、金鑰再送出(之前沒有)。

0.0.2 新的地方

  • 對話框的〔接在「…」下〕改成 Jev 判斷最相關的那張便利貼(從最近 8 張裡挑),不再只能接目前追問的那張;多一個〔接在其他便利貼下…〕可以自己挑;在「其他」打標題的關鍵字也能找到便利貼。
  • 從另一台電腦或手機(Remote Control)打字不會跳便利貼的對話框,一律進主線。
  • Jev 判成「專案問題」的句子只進主線,不再在 pane 留下「在主線回答」的便利貼。
  • pane 的追問框送出後會清空。
  • 輸入框下方的狀態列改成顯示這個 mod 今天用掉的額度(Jev 次數、Claude / OpenAI token)。

需求

  • Claude Code 2.1.288 以上(Mods 是 early access,在 2.1.288 / 2.1.289、Windows 的 Claude Desktop Code 分頁與終端機測過)。
  • 選用:TypeSafe 的 Jev API key(自動分類用)、OpenAI API key(統整層可改用 OpenAI)。沒有也能用,見下方「金鑰」。

安裝

git clone https://github.com/k7term1a/cc-sticky-notes.git

終端機:每次啟動時帶上資料夾路徑。

claude --plugin-dir /path/to/cc-sticky-notes

Claude Desktop(Code 分頁):在 ~/.claude/settings.json 的 env 加上這個資料夾,之後開的 session 都會載入。

{
  "env": {
    "CLAUDE_CODE_PLUGIN_DIRS": "C:\\Users\\you\\cc-sticky-notes",
    "CLAUDE_CODE_PLUGIN_DIR_WATCH": "1"
  }
}
  • 改完要開新的 session(已經開著的 session 不會重新讀設定)。
  • CLAUDE_CODE_PLUGIN_DIR_WATCH 是選用的:設了之後,mod 的檔案一更新(例如 git pull),開著的 session 就會自動重載。
  • 裝好後在輸入框下方右側會看到 cc-sticky-note。打 /sn doctor 可以檢查金鑰有沒有讀到。

金鑰(選用)

建一個 ~/.claude/sticky-notes/.env(Windows 是 C:\Users\<你>\.claude\sticky-notes\.env):

TYPESAFE_API_KEY=apikey_...
OPENAI_API_KEY=sk-...
  • 依序找:環境變數 → ~/.claude/sticky-notes/.env → mod 資料夾裡的 .env。不會讀你專案自己的 .env(那裡常有那個專案自己的 OpenAI key)。
  • 金鑰值不會被印出、記錄或存進 store;/sn doctor 只告訴你找到沒有、從哪裡找到。
  • 沒有 Jev key:不做自動分類,所有輸入照常進主線,不會跳任何對話框。便利貼只能用 /sn new <問題> 或 pane 的追問框建立。
  • 沒有 OpenAI key:完全不影響,預設本來就用 Claude(你登入的訂閱)寫標題和摘要。

怎麼用

直接在輸入框問

像平常一樣打字。Jev 只決定「要不要問你」,不會自己把你的話收成便利貼:

  • 有把握的專案任務:照常送給 Claude,什麼都不會跳出來。
  • 知識旁問(例如「CRDT 是什麼?」),或 Jev 沒把握的句子(信心低於 60%):跳出一個對話框,問題會帶 Jev 的判斷與信心,例如「這句要怎麼處理?(Jev:知識旁問 96%)」:
  • 〔開新的便利貼〕:這句不會進主線,畫面上出現一張卡片:
    A hook blocked your prompt
    Prompt dropped by a hook: cc-sticky-note:新的便利貼「CRDT 是什麼?」

幾秒後答案出現在右側 pane(會自動打開),對話裡留一行灰字預覽。灰字和卡片 Claude 都讀不到。

  • 〔接在「<正在追問的題目>」下〕:只有在你正在追問某一則時才會出現,Jev 覺得是同一個話題時會排在第一個。
  • 〔送進主線〕:照常送給 Claude。關掉對話框也一樣送進主線,不會吞掉你的話。
  • 專案相關的疑問(「為什麼我們這裡用 X?」):照常問 Claude,不會建便利貼。

從另一台電腦用 Remote Control 打字不會跳便利貼的對話框,本來會問的句子一律進主線;便利貼、狀態列和 pane 只在跑 session 的那台電腦上用。

追問

輸入框下方右側的狀態列顯示這個 mod 今天用掉的額度,例如 cc-sticky-notes 今日 Jev 12 次 · Claude 35k(用過 OpenAI 才會出現 OpenAI;Claude 的數字不含讀 cache 的部分;所有專案、所有 session 合計,每天歸零)。接著再問相關的問題,對話框會把 Jev 判斷最相關的那張便利貼放在〔接在「…」下〕,選它就掛在那張下面;不是那張的話選〔接在其他便利貼下…〕,或在「其他」打標題的關鍵字。想結束追問,打 /sn back。

也可以直接用 pane 卡片最下面的回覆框(不經 Jev,直接接在卡片目前讀到的最後一則下面)。

右側 pane

打 /sn 開關。內容:

  • 一個主題一張卡片,最新的在最上面。收合時只有一行:標題、時間、這個主題共幾則(標題後的 … 表示還在回答)。點那一行就展開,點展開後的標題就收合。
  • 展開後是一段對話:你的問題畫成像 Desktop prompt 的泡泡(靠右),答案接在下面,不分層級。某則有多個追問時,答案下面列出各追問的標題(● 是目前讀的這條、○ 是其他),點了就換成那條往下讀。答案不是看得到專案的 Claude 回答時,下面會標「無專案脈絡」。
  • 刪除:滑鼠移到問題那一列,左邊的 ✕ 會先問一次,再刪掉那則和它底下的追問。只刪這台電腦的;有同步到 Notion 的會在 Notion 勾上「不同步」,其他電腦之後就不會再下載它(已經下載過的不會被刪)。也可以先點開那則,再打 /sn rm。
  • 改寫問題:滑鼠移到問題那一列,左邊會出現 ✎;改完按 ↵ 會在同一層多一個追問(改的是第一個問題就開一張新卡片),舊的留著,可以用上面的 ● / ○ 切換。
  • 回覆框:卡片最下面,接在目前讀到的最後一則下面。Desktop 的輸入框寬度固定,mod 改不了。
  • 類別:時間前面有底色的小標籤,是 Jev 對這個主題第一句的判斷(知識旁問、專案疑問、主線任務),和對話框裡顯示的一樣。用 /sn new 或回覆框建的、Jev 沒看過的便利貼沒有類別。
  • 綠色邊框:這個 session 正在追問的那張;其他卡片都是灰框。只是點開來看不會變成追問中。想結束追問打 /sn back。

主線摘要與專案脈絡

每 3 個主線回合(/sn every 可調),mod 會在背景請統整層(Claude haiku 或 OpenAI)讀最近幾輪對話,寫兩樣東西:

  • 主線摘要:這個 session 現在在做什麼、剛決定什麼、還卡在哪,200 字內。Jev 判斷新的一句要不要跳對話框、接在哪張時會讀它,比原本只看幾句原文準。
  • 專案脈絡:值得長期記住的事(決定、慣例、限制、踩過的坑),每次 0–3 條,所有 session 共用,只會自動增加。

兩者都在 pane 最下面的「專案脈絡」卡片:可以看、用 ✕ 刪、自己加一條,或按「立即統整」。用 OpenAI 時,送出去的對話會先依 openaiContextMode 剝掉程式碼、路徑等內容。每次統整大約 2–4k token,會算進狀態列的今日用量。

在多台電腦之間同步(Notion,選用)

每台電腦的便利貼可以同步到你自己 Notion 裡的一個資料庫:答好的便利貼自動上傳一列;session 開始時把其他電腦在同一個專案做的便利貼拉下來(專案用 git remote 對應,路徑不同也沒關係)。走的是你在 claude.ai 連好的 Notion connector,mod 不存任何 token。

  1. 在 Notion 建一個資料庫,欄位:標題(title)、問題、摘要、Note ID、上一層(文字)、專案、電腦、回答者(select)、建立時間(date)。
  2. 在 ~/.claude/settings.json 的 permissions.allow 加上 Notion connector 的四個工具:notion-fetch、notion-query-data-sources、notion-create-pages、notion-update-page(完整名稱是 mcp__<connector id>__notion-fetch 這種形式,/sn notion test 會印出 connector id)。沒加的話,auto 權限模式會擋下 mod 的呼叫。
  3. 每台電腦各打一次 /sn notion <collection://…>,再打 /sn notion test 確認四步都 ✓。
指令作用
/sn notion看同步到哪、上次同步的結果
/sn notion pull現在就下載其他電腦的便利貼
/sn notion push把這個專案還沒上傳的便利貼全部上傳(第一次設定時用)

只會新增,不會合併同一張便利貼的修改。

指令

/sn 和 /sticky-note 完全一樣,/sn 比較好打。

指令作用
/sn開 / 關右側 pane
/sn new <問題>手動開一張便利貼(不經 Jev)
/sn back結束追問,回到主線
/sn rm刪除 pane 裡點開的那則便利貼和它底下的追問(會先問)
/sn timeout <秒>Jev 的對話框幾秒沒回應就自動送進主線(預設 30,0 一直等)
`/sn feedback main\new\followup`上一句其實應該是:主線 / 新的便利貼 / 追問(也可以打「主線」「便利貼」「追問」)
/sn feedback good上一句現在這樣就對
/sn calibrate用你的選擇與回饋,看各門檻下 Jev 的表現
`/sn provider claude\openai`切換標題、摘要、背景統整用誰寫(不帶參數就顯示目前用哪個)
/sn every <n>每 n 個主線回合在背景統整一次主線摘要與專案脈絡;0 關閉(預設 3)
/sn ctx在對話裡列出這個 session 的主線摘要和專案脈絡(只有你看得到,Claude 讀不到)
/sn ctx add <文字>、/sn ctx rm <n>自己加一條、刪第 n 條專案脈絡
/sn ctx refresh現在就統整一次
/sn doctor檢查兩把金鑰找到沒有、從哪裡找到

幫忙測試

你在對話框的每一次選擇都會自動記下來(Jev 的判斷、信心、你的選擇,只存在你的電腦)。最有用的額外回饋是 Jev 沒問、直接送進主線,但其實你想要便利貼 的時候:打 /sn feedback new,再截圖給我。

設定

下列欄位可以在 Claude Code 的設定選單(/config,終端機)調整:

欄位預設說明
autoOpenPanetrue答案回來時自動打開 pane 並選中
routeThreshold0.6Jev 判成專案任務、且信心至少這麼高時才不問你
followupThreshold0.6對話框裡〔接在…下〕排第一的門檻
summaryProviderclaude標題、摘要、背景統整用誰寫:claude 或 openai(也可以用 /sn provider)
digestEvery3每幾個主線回合在背景統整一次;0 關閉(也可以用 /sn every)
claudeModel / claudeEfforthaiku / low寫標題摘要的 Claude 模型與 effort(旁答本身一律用主線的模型)
openaiModel / openaiReasoningEffortgpt-5-mini / minimalsummaryProvider = openai 時用

已知限制

  • 被攔下的那句,Desktop 一定會顯示那張「A hook blocked your prompt」卡片,標題改不掉。Claude 讀不到這句,但它仍會留在本機的 session 紀錄檔裡。
  • 旁答用的是主線同一個模型(Claude Code 的限制),算在你的訂閱用量裡;有 prompt cache,通常 1–3 秒。
  • 剛重開或 resume 一個 session、主線還沒跑過任何回合之前,旁答拿不到專案脈絡,pane 會標「無專案脈絡」。
  • Jev 會收到你最近 3 句主線 prompt 與最後一則回覆(各取前 300 字)、正在追問的題目,以及新的這句(判斷用)。介意的話不要設 Jev key。
  • 便利貼存在本機:~/.claude/plugins/store/cc-sticky-notes_*.json。用 --plugin-dir 載入和正式安裝可能是不同的檔。
  • 側邊欄外觀還很陽春,下一版會改。

開發

claude plugin validate .
claude plugin test .
npx -p typescript@5.6 tsc -p .

tsconfig.json extends .claude-plugin/types/tsconfig.json,那是引擎載入 mod 時寫出來的型別(已 git-ignore),所以第一次 type-check 前要先載入一次 mod。

  • hooks/register.tsx:所有 hook,以及 portsOf($)。只有這個檔碰 $(PROBE.md P1)。
  • hooks/tree.ts、route.ts、jev.ts、redact.ts、digest.ts、answer.ts:邏輯模組,純函式或吃 Ports。
  • hooks/notes.ts:流程(路由 → 便利貼 → 背景回答 → 路由樣本)。
  • hooks/feedback.ts:路由回饋紀錄(feedback:<root>:<id>)、/sn feedback、calibrate。
  • hooks/secrets.ts:金鑰從哪裡來。
  • hooks/pane.tsx:右側 pane 與輸入框下方的狀態列。
  • probes/m0/:M0 探針 mod(cc-sticky-probe),獨立的 plugin。
Source 1 files
hooks/register.tsx 268 lines
1// M0 probe. Every line it logs starts with "PROBE " so the stream-json output can be grepped.
2// Driven by the prompt prefix: "probe-<name> <rest>". Unknown prompts pass through.
3import type { Register } from 'claude-code'
4
5export const register: Register = on => {
6
7  on('session.start', async ($, e, next) => {
8    const out = (s: string) => $.ui.log(`PROBE ${s}`)
9    out(`session.start e=${JSON.stringify(e)}`)
10    out(`version=${JSON.stringify(await $.session.version())}`)
11    out(`id=${await $.session.id()} root=${await $.session.root()} cwd=${await $.session.cwd()}`)
12    out(`surfaces=${JSON.stringify(await $.session.surfaces())} plugin.root=${$.plugin.root}`)
13    out(`env TYPESAFE_API_KEY set=${(await $.env.get('TYPESAFE_API_KEY')) !== undefined}`)
14    out(`env OPENAI_API_KEY set=${(await $.env.get('OPENAI_API_KEY')) !== undefined}`)
15    // store: who was here before (cross-session persistence)
16    const id = await $.session.id()
17    const visits = ((await $.store.get('visits')) as string[] | undefined) ?? []
18    out(`store visits(before)=${JSON.stringify(visits)}`)
19    await $.store.set('visits', [...visits, id].slice(-10))
20    await $.store.set(`mark:${id}`, await $.clock.now())
21    out(`store keys=${JSON.stringify(await $.store.keys())}`)
22    return next(e)
23  })
24
25  on('turn.start', async ($, e, next) => {
26    $.ui.log(`PROBE turn.start turnId=${e.turnId} text=${JSON.stringify(e.text.slice(0, 60))}`)
27    return next(e)
28  })
29
30  on('turn.complete', async ($, e, next) => {
31    $.ui.log(`PROBE turn.complete keys=${Object.keys(e).join(',')}`)
32    // second look at the store: did a concurrent session write meanwhile?
33    $.ui.log(`PROBE store keys at turn.complete=${JSON.stringify(await $.store.keys())}`)
34    return next(e)
35  })
36
37  on('prompt.submit', async ($, e, next) => {
38    const out = (s: string) => $.ui.log(`PROBE ${s}`)
39    out(`prompt.submit keys=${Object.keys(e).join(',')} turnId=${e.turnId} wait=${e.wait} origin=${JSON.stringify(e.origin)}`)
40    const m = /^probe-([a-z-]+)\s*([\s\S]*)$/.exec(e.text)
41    if (!m) return next(e)
42    const [, name, rest] = m
43    const t0 = await $.clock.now()
44    const ms = async () => (await $.clock.now()) - t0
45
46    switch (name) {
47      case 'drop':
48        return { drop: 'cc-sticky-probe: dropped on purpose' }
49
50      case 'fork': {
51        const r = await $.model.fork({ prompt: rest || 'In one sentence: what is TCP backpressure?' })
52        out(`fork ms=${await ms()} result=${JSON.stringify(r).slice(0, 600)}`)
53        return { drop: 'cc-sticky-probe: fork answered off the transcript' }
54      }
55
56      case 'fork-history': {
57        // Can a fork carry side-thread history? Only via the prompt text (ModelForkRequest is { prompt }).
58        const history = 'Q1: What is TCP backpressure?\nA1: When a receiver is slower than a sender, buffers fill and the sender is told to slow down.\n'
59        const r = await $.model.fork({ prompt: `[side thread so far]\n${history}\n[follow-up]\n${rest || 'How does that relate to Node streams? One sentence.'}` })
60        out(`fork-history ms=${await ms()} result=${JSON.stringify(r).slice(0, 600)}`)
61        return { drop: 'cc-sticky-probe: fork-history done' }
62      }
63
64      case 'fork-bg': {
65        // Drop first, answer in the background.
66        $.clock.after(0, async () => {
67          const r = await $.model.fork({ prompt: rest || 'One sentence: what is a hash map?' })
68          $.ui.log(`PROBE fork-bg ms=${(await $.clock.now()) - t0} result=${JSON.stringify(r).slice(0, 400)}`)
69        })
70        return { drop: 'cc-sticky-probe: fork-bg scheduled' }
71      }
72
73      case 'complete': {
74        const r = await $.model.complete({
75          model: 'haiku',
76          effort: 'low',
77          system: 'Reply with a JSON object {"title": string (<=12 chars), "summary": string (3 sentences)}.',
78          prompt: rest || 'Q: What is TCP backpressure? A: Receiver slower than sender, sender slows down.',
79          maxTokens: 300,
80          timeoutMs: 20000,
81        })
82        out(`complete ms=${await ms()} result=${JSON.stringify(r).slice(0, 600)}`)
83        return { drop: 'cc-sticky-probe: complete done' }
84      }
85
86      case 'model': {
87        // Does $.model.complete honour an alias and a full id? (claudeModel userConfig)
88        for (const model of (rest || 'sonnet claude-haiku-4-5-20251001 opus').split(/\s+/)) {
89          try {
90            const r = await $.model.complete({ model, prompt: 'Reply with only the name of the model you are.', maxTokens: 40, effort: 'low', timeoutMs: 30000 })
91            out(`model ${model} ms=${await ms()} result=${JSON.stringify(r).slice(0, 300)}`)
92          } catch (err) {
93            out(`model ${model} threw ${String(err).slice(0, 200)}`)
94          }
95        }
96        return { drop: 'cc-sticky-probe: model done' }
97      }
98
99      case 'classify': {
100        try {
101          const label = await $.model.classify(rest || 'why does TCP need a three-way handshake?', [
102            'main_task', 'sidebar_knowledge', 'project_question',
103          ])
104          out(`classify ms=${await ms()} label=${JSON.stringify(label)}`)
105        } catch (err) {
106          out(`classify threw ${String(err)}`)
107        }
108        return { drop: 'cc-sticky-probe: classify done' }
109      }
110
111      case 'messages': {
112        const msgs = await $.session.messages()
113        if (Array.isArray(msgs)) {
114          out(`messages n=${msgs.length}`)
115          for (const one of msgs.slice(-4)) {
116            out(`  msg role=${one.role} keys=${Object.keys(one).join(',')} text=${JSON.stringify(one.text.slice(0, 80))} toolUses=${one.toolUses.length}`)
117          }
118        } else out(`messages deny=${JSON.stringify(msgs)}`)
119        out(`turns=${await $.session.turns()} usage=${JSON.stringify(await $.session.usage()).slice(0, 400)}`)
120        return { drop: 'cc-sticky-probe: messages done' }
121      }
122
123      case 'http': {
124        for (const url of ['https://api.openai.com/v1/models', 'https://api.typesafe.ai/v1/systemone']) {
125          try {
126            const r = await $.http.fetch(url, { method: url.includes('typesafe') ? 'POST' : 'GET', headers: { 'content-type': 'application/json' }, body: url.includes('typesafe') ? '{}' : undefined })
127            out(`http ${url} status=${r.status} ok=${r.ok} headerKeys=${Object.keys(r.headers).slice(0, 8).join(',')} text=${JSON.stringify(r.text.slice(0, 200))}`)
128          } catch (err) {
129            out(`http ${url} threw ${String(err)}`)
130          }
131        }
132        return { drop: 'cc-sticky-probe: http done' }
133      }
134
135      case 'jev': {
136        // Real Jev call with the four PLAN.md questions; logs the raw response.
137        const key = await $.env.get('TYPESAFE_API_KEY')
138        if (!key) {
139          out('jev: no TYPESAFE_API_KEY')
140          return { drop: 'cc-sticky-probe: jev skipped' }
141        }
142        const prompt = rest || 'TCP 的 backpressure 是什麼原理?'
143        const body = {
144          model: 'jev-latest',
145          state: `[recent main-line context]\nuser: 把 auth 改成 session cookie\nassistant: 已改好,剩 token 輪替。\n\n[sidebar state]\nactive_thread_title: none\nactive_thread_last_question: none\nmain_turns_since_last_sidebar: 2\n\n[new prompt]\n${prompt}`,
146          questions: {
147            route: {
148              type: 'choice',
149              instructions: 'Where should the new prompt go?',
150              criteria: {
151                main_task: 'Advances the project: an instruction, a code change, or a decision about what Claude just did',
152                sidebar_knowledge: 'Asks about a principle, concept or background knowledge; does not ask Claude to change anything',
153                project_question: 'A question about this project itself whose answer belongs in the main conversation',
154              },
155            },
156            is_followup: { type: 'noul', instructions: 'Does the new prompt continue the topic of active_thread?' },
157            needs_project_ctx: { type: 'noul', instructions: "Does answering the new prompt require seeing the project's code or conversation?" },
158            tag: { type: 'choice', instructions: 'Which topic tag fits the new prompt?', criteria: { network: 'About network', db: 'About db', __new__: 'None of the existing tags fits' } },
159          },
160        }
161        const r = await $.http.fetch('https://api.typesafe.ai/v1/systemone', {
162          method: 'POST',
163          headers: { 'content-type': 'application/json', authorization: `Bearer ${key}` },
164          body: JSON.stringify(body),
165        })
166        out(`jev ms=${await ms()} status=${r.status} text=${r.text.slice(0, 1500)}`)
167        return { drop: 'cc-sticky-probe: jev done' }
168      }
169
170      case 'openai': {
171        const key = await $.env.get('OPENAI_API_KEY')
172        if (!key) {
173          out('openai: no OPENAI_API_KEY')
174          return { drop: 'cc-sticky-probe: openai skipped' }
175        }
176        const r = await $.http.fetch('https://api.openai.com/v1/chat/completions', {
177          method: 'POST',
178          headers: { 'content-type': 'application/json', authorization: `Bearer ${key}` },
179          body: JSON.stringify({
180            model: rest || 'gpt-5-mini',
181            max_completion_tokens: 400,
182            reasoning_effort: 'minimal',
183            messages: [
184              { role: 'system', content: 'Reply with JSON only: {"title": "<=12 chars", "summary": "three sentences"}' },
185              { role: 'user', content: 'Q: What is TCP backpressure? A: When the receiver is slower, buffers fill and the sender slows down.' },
186            ],
187          }),
188        })
189        out(`openai ms=${await ms()} status=${r.status} text=${r.text.slice(0, 1500)}`)
190        return { drop: 'cc-sticky-probe: openai done' }
191      }
192
193      case 'agents': {
194        try {
195          const r = await $.tool.call({ tool: 'ListAgents' })
196          out(`ListAgents result=${JSON.stringify(r).slice(0, 800)}`)
197        } catch (err) {
198          out(`ListAgents threw ${String(err)}`)
199        }
200        return { drop: 'cc-sticky-probe: agents done' }
201      }
202
203      case 'suggest': {
204        const r = await $.prompt.suggest({ text: '正在追問:probe' })
205        out(`suggest result=${JSON.stringify(r)}`)
206        return { drop: 'cc-sticky-probe: suggest done' }
207      }
208
209      case 'store-race': {
210        // Two processes run this at once. Separate keys + one shared read-modify-write key.
211        const id = await $.session.id()
212        await $.store.set(`race:${id}`, t0)
213        const before = ((await $.store.get('race-list')) as string[] | undefined) ?? []
214        await $.clock.sleep(3000)
215        await $.store.set('race-list', [...before, id])
216        out(`store-race id=${id} keysAfter=${JSON.stringify((await $.store.keys()).filter(k => k.startsWith('race')))} list=${JSON.stringify(await $.store.get('race-list'))}`)
217        return { drop: 'cc-sticky-probe: store-race done' }
218      }
219
220      case 'store-read': {
221        out(`store-read keys=${JSON.stringify((await $.store.keys()).filter(k => k.startsWith('race')))} list=${JSON.stringify(await $.store.get('race-list'))}`)
222        return { drop: 'cc-sticky-probe: store-read done' }
223      }
224
225      case 'budget': {
226        // Does a long $ call count against the 10 s budget? $.clock.sleep does; http does not.
227        try {
228          await $.http.fetch('https://httpbin.org/delay/12')
229          out(`budget http 12s ok ms=${await ms()}`)
230        } catch (err) {
231          out(`budget http threw ${String(err)} ms=${await ms()}`)
232        }
233        return { drop: 'cc-sticky-probe: budget done' }
234      }
235
236      case 'context': {
237        // project_question path: pass through with extra context
238        return next({ ...e, text: rest ?? '', context: [...(e.context ?? []), '[sticky-notes] project question; answer briefly'] })
239      }
240
241      default:
242        return next(e)
243    }
244  })
245
246  // UI probe: a badge beside the original user row, and a hotkey the type says is refused.
247  on('ui.render', { component: 'UserMessage' }, async ($, e, next) => {
248    if (!e.props.text.includes('badge-me')) return next(e)
249    const { Box, Button } = $.ui.resolve(e)
250    const original = await next(e)
251    return (
252      <Box flexDirection="row">
253        {original}
254        <Button key="badge" plain label="📌 1" onPress={() => $.ui.toast('badge pressed')} />
255      </Box>
256    )
257  })
258
259  on('ui.render', { component: 'AbovePrompt' }, async ($, e, next) => {
260    const { Box, Button } = $.ui.resolve(e)
261    return (
262      <Box>
263        <Button key="alt" label="open" hotkey="⌥s" onPress={() => {}} />
264      </Box>
265    )
266  })
267}
268