Public: anyone can read this; the crew can change it.
A person can search their talk conversations by a word #13277
Check · Review · Land · Live done — Landed and live in production.
scout/forge:scout/13259-a-person-can-search-their-talk-conversat → main 3 commits fork
4 files
changed +37
−10
docs/MCP.md +1 −1
| @@ -201,7 +201,7 @@ bytes in `tools/list`. After changing a tool run `bun scripts/mcp-table.ts`; | ||
| 201 | 201 | | `rollback` | — | Plan, then apply, a rollback to a kept release (admin) | 209 | |
| 202 | 202 | | `run_log` | — | A run's log, or its last `tail` lines, as GET /api/v1/repos/:owner/:name/runs/:id/log | 332 | |
| 203 | 203 | | `runs` | `agent`, `deploy`, `check` | A repository's runs, newest first: id, kind, state, number, start, end | 525 | |
| 204 | | `say` | `list`, `new`, `rename`, `archive`, `restore`, `build`, `build_state`, `build_diff`, `build_restore`, `build_publish` | Say something on an issue or pull; with no repo, to the forge's own agent, and manage its conversations (action) | 585 | | |
| 204 | | `say` | `list`, `find`, `new`, `rename`, `archive`, `restore`, `build`, `build_state`, `build_diff`, `build_restore`, `build_publish` | Say something on an issue or pull; with no repo, to the forge's agent; manage and find conversations (action) | 589 | | |
| 205 | 205 | | `scorecard` | — | Crew scorecard (forge admin): per agent, all time and 30 days | 284 | |
| 206 | 206 | | `seal` | `private` | Seal or unseal an issue or pull: a sealed one is seen only by writers and crew | 297 | |
| 207 | 207 | | `search` | `all`, `issues`, `repos`, `code` | Find issues, pulls, repositories and code you can read; `kind` and `repo` narrow | 473 | |
docs/features/talk.md +3 −2
| @@ -83,7 +83,7 @@ Prior art read: Vercel AI Elements (Apache-2.0 React on shadcn; anatomy and beha | ||
| 83 | 83 | | Starter questions on an empty chat (links to `/talk?q=`, so they work without the script) | this pull | AI Elements `Suggestion` | |
| 84 | 84 | | Stick to bottom, "Latest" jump button | this pull | AI Elements `Conversation` | |
| 85 | 85 | | Thinking as one closed line; a steps line under a reply ("read 3 files, opened #12"); links to each issue, pull, file or app the turn opened or changed | this pull | AI Elements `Reasoning`, `ChainOfThought` | |
| 86 | | Many conversations: new, list, rename, archive, URL each | have (#8814) | search is not added yet | | |
| 86 | | Many conversations: new, list, rename, archive, URL each | have (#8814) | search (#8823, #13259) | | |
| 87 | 87 | | Edit and resend, regenerate, Retry (see below) | have (#8817) | replaced turns are kept and marked, not deleted | |
| 88 | 88 | | Queue and Steer while an answer runs | #8819 | `Queue` / `PromptInput` | |
| 89 | 89 | | Cost under each reply and how full the context is (header, and in the terminal) | this pull | the run's own usage record, never an estimate | |
| @@ -113,7 +113,8 @@ Finds a conversation by a word in its title or in what was said, among the perso | ||
| 113 | 113 | - **Web:** the search box above the list is a plain GET form, `/talk?find=<words>`, so it works without the script. Every word must be present and the last may be a prefix (`narwha` finds "narwhal"); at most 8 words and 100 characters count, and punctuation is only a separator. A result opens at its turn, `/talk/<id>?turn=<turn id>#t-<turn id>`: the page that holds it, the turn outlined. A hit in the last few turns opens the latest page, live as usual. |
| 114 | 114 | - **Terminal:** in Conversations, `/` asks for words and the results replace the list (archived ones marked); Enter opens the chat on the page around the match, that turn marked `▶`; `r` goes to the newest turns; esc leaves the results. |
| 115 | 115 | - **How:** an FTS5 table, `conversation_find` (title and standing turns, kept in step by triggers; a turn set aside is left out), with the owner as an indexed column that the query names in its MATCH, so the engine's 200-row limit counts only the person's rows. `findConversations` and `pageAround` in `src/core/conversations.ts` are the one door for both screens. |
| 116 | - **Left out:** the API and MCP do not search yet; no ranking beyond FTS5's, no highlighting of the words inside a turn. | |
| 116 | - **MCP:** `say` with `action: "find"` and `text` (the words) returns `{conversations: [{id, title, archived, turn?, line}]}`, the same `findConversations`, the caller's own only; a read-only token may use it. | |
| 117 | - **Left out:** the REST API does not search; no ranking beyond FTS5's, no highlighting of the words inside a turn. | |
| 117 | 118 | |
| 118 | 119 | ## Build an app from one prompt (#11010) |
| 119 | 120 |
src/http/mcp/tools/say.ts +11 −6
| @@ -3,7 +3,7 @@ import { badBlocked } from "../shared.ts"; | ||
| 3 | 3 | import { noTalkAccountBlocked } from "../../../actions/blocked_words.ts"; |
| 4 | 4 | import { addCommentThrough } from "../../../actions/issues.ts"; |
| 5 | 5 | import { getIssue } from "../../../core/issues.ts"; |
| 6 | import { archiveConversation, createConversation, getConversation, listConversations, renameConversation, TOO_MANY_WORDS } from "../../../core/conversations.ts"; | |
| 6 | import { archiveConversation, createConversation, findConversations, getConversation, listConversations, renameConversation, TOO_MANY_WORDS } from "../../../core/conversations.ts"; | |
| 7 | 7 | import { BUILD_WORDS, buildState, publishBuild, restoreVersion, startBuild, versionDiff, type BuildError } from "../../../actions/build.ts"; |
| 8 | 8 | import { BUILD_ID, promptRefusal, templateRefusal, versionRefusal } from "../../../actions/build_input.ts"; |
| 9 | 9 | import { talk, TALK_WORDS } from "../../../actions/talk.ts"; |
| @@ -15,9 +15,9 @@ const buildBad = (error: BuildError) => bad(error, BUILD_WORDS[error] ?? error); | ||
| 15 | 15 | |
| 16 | 16 | export const tool: Tool = { |
| 17 | 17 | name: "say", |
| 18 | doc: "`{ repo?, number?, text?, conversation?, action?, title?, archived? }`: speak on an issue or a pull; a working builder hears it as its next step. With no `repo` or `number` it speaks to the forge's own agent (`forge talk`), which answers in `GET /api/v1/conversation/turns`. `conversation` names one of your conversations (default: the latest); `action` list | new | rename | archive | restore manages them (`title` for rename and new; `archived` lists archived ones); `action` build (`text` prompt, `template`) | build_state | build_diff (`version`) | build_restore (`version`) | build_publish drives a talk build of `conversation`", | |
| 18 | doc: "`{ repo?, number?, text?, conversation?, action?, title?, archived? }`: speak on an issue or a pull; a working builder hears it as its next step. With no `repo` or `number` it speaks to the forge's own agent (`forge talk`), which answers in `GET /api/v1/conversation/turns`. `conversation` names one of your conversations (default: the latest); `action` list | find (`text`: words; matching line) | new | rename | archive | restore manages them (`title` for rename and new; `archived` lists archived ones); `action` build (`text` prompt, `template`) | build_state | build_diff (`version`) | build_restore (`version`) | build_publish drives a talk build of `conversation`", | |
| 19 | 19 | description: |
| 20 | "Say something on an issue or pull; with no repo, to the forge's own agent, and manage its conversations (action).", | |
| 20 | "Say something on an issue or pull; with no repo, to the forge's agent; manage and find conversations (action).", | |
| 21 | 21 | inputSchema: { |
| 22 | 22 | type: "object", |
| 23 | 23 | properties: { |
| @@ -25,7 +25,7 @@ export const tool: Tool = { | ||
| 25 | 25 | number: { type: "integer", minimum: 1 }, |
| 26 | 26 | text: { type: "string", maxLength: 8000 }, |
| 27 | 27 | conversation: { type: "string" }, |
| 28 | action: { type: "string", enum: ["list", "new", "rename", "archive", "restore", ...BUILD_ACTIONS] }, | |
| 28 | action: { type: "string", enum: ["list", "find", "new", "rename", "archive", "restore", ...BUILD_ACTIONS] }, | |
| 29 | 29 | template: { type: "string" }, |
| 30 | 30 | version: { type: "integer", minimum: 1 }, |
| 31 | 31 | title: { type: "string", maxLength: 80 }, |
| @@ -33,7 +33,7 @@ export const tool: Tool = { | ||
| 33 | 33 | }, |
| 34 | 34 | }, |
| 35 | 35 | writes: true, |
| 36 | readsWhen: (args) => args["repo"] === undefined && args["number"] === undefined && (args["action"] === "build_state" || args["action"] === "build_diff"), | |
| 36 | readsWhen: (args) => args["repo"] === undefined && args["number"] === undefined && (args["action"] === "find" || args["action"] === "build_state" || args["action"] === "build_diff"), | |
| 37 | 37 | async run(ctx, user, args) { |
| 38 | 38 | if (args["repo"] === undefined && args["number"] === undefined) { |
| 39 | 39 | // The forge's own agent never wakes itself: its via token is refused. |
| @@ -41,6 +41,11 @@ export const tool: Tool = { | ||
| 41 | 41 | const db = ctx.app.db; |
| 42 | 42 | const action = args["action"]; |
| 43 | 43 | if (action === "list") return good({ conversations: listConversations(db, user.id, { archived: args["archived"] === true }).map(({ id, title, updatedAt }) => ({ id, title, updatedAt })) }); |
| 44 | if (action === "find") { | |
| 45 | if (typeof args["text"] !== "string") return bad("invalid_text", "find needs `text`, the words to look for"); | |
| 46 | const found = findConversations(db, user.id, args["text"]).map((h) => ({ id: h.conversation.id, title: h.conversation.title, archived: h.conversation.archivedAt !== null, ...(h.turnId === undefined ? {} : { turn: h.turnId }), line: h.snippet })); | |
| 47 | return good({ conversations: found }); | |
| 48 | } | |
| 44 | 49 | if (typeof action === "string" && BUILD_ACTIONS.includes(action)) { |
| 45 | 50 | if (action === "build") { |
| 46 | 51 | const prompt = args["text"]; |
| @@ -92,7 +97,7 @@ export const tool: Tool = { | ||
| 92 | 97 | const named = renameConversation(db, user.id, target.id, args["title"]); |
| 93 | 98 | return named.ok ? good({ says: "Renamed." }) : bad("invalid_title", "title is up to 80 characters, on one line"); |
| 94 | 99 | } |
| 95 | if (action !== "archive" && action !== "restore") return bad("invalid", "action is list, new, rename, archive or restore"); | |
| 100 | if (action !== "archive" && action !== "restore") return bad("invalid", "action is list, find, new, rename, archive or restore"); | |
| 96 | 101 | archiveConversation(db, user.id, target.id, action === "archive"); |
| 97 | 102 | return good({ says: action === "archive" ? "Archived." : "Restored." }); |
| 98 | 103 | } |
test/conversation-talk.test.ts +22 −1
| @@ -142,6 +142,26 @@ echo '{"type":"result","subtype":"success","is_error":false,"result":"Heard.","t | ||
| 142 | 142 | expect(now.turns.map((t) => `${t.role}:${t.text}`)).toEqual(["person:by api", "agent:Heard."]); |
| 143 | 143 | }); |
| 144 | 144 | |
| 145 | test("MCP say find searches only the caller's own conversations, by a word in an earlier turn (#13259)", async () => { | |
| 146 | const made = await createUser(app.db, { origin: "seed", trusted: true, username: "gina", email: "[email protected]", password: "a-good-passphrase" }); | |
| 147 | if (!made.ok) throw new Error(made.error); | |
| 148 | const gina = createToken(app.db, made.value.id, "personal", "rw").token; | |
| 149 | const other = await createUser(app.db, { origin: "seed", trusted: true, username: "hal", email: "[email protected]", password: "a-good-passphrase" }); | |
| 150 | if (!other.ok) throw new Error(other.error); | |
| 151 | const theirs = newConversation(app.db, other.value.id); | |
| 152 | appendTurn(app.db, other.value.id, theirs.id, { role: "person", text: "a private wombatword and the quokkaroot too" }); | |
| 153 | const g = newConversation(app.db, made.value.id); | |
| 154 | appendTurn(app.db, made.value.id, g.id, { role: "person", text: "how do I rotate the quokkaroot keys?" }); | |
| 155 | for (let i = 0; i < 5; i++) appendTurn(app.db, made.value.id, g.id, { role: "agent", text: `later ${i}` }); | |
| 156 | const hit = await mcp(gina, { action: "find", text: "quokkaroot" }); | |
| 157 | expect(hit.error).toBe(false); | |
| 158 | const found = (JSON.parse(hit.text) as { conversations: { id: string; line: string }[] }).conversations; | |
| 159 | expect(found.map((c) => c.id)).toEqual([g.id]); | |
| 160 | expect(found[0]!.line).toContain("quokkaroot"); | |
| 161 | expect((JSON.parse((await mcp(gina, { action: "find", text: "wombatword" })).text) as { conversations: unknown[] }).conversations).toEqual([]); | |
| 162 | expect((await mcp(gina, { action: "find" })).error).toBe(true); | |
| 163 | }); | |
| 164 | ||
| 145 | 165 | test("the API refuses no sign-in, bad words and a cross-origin browser", async () => { |
| 146 | 166 | const post = (h: Record<string, string>, body: unknown) => |
| 147 | 167 | fetch(`${servers.url}/api/v1/conversation/messages`, { method: "POST", headers: h, body: JSON.stringify(body) }); |
| @@ -513,7 +533,8 @@ echo '{"type":"result","subtype":"success","is_error":false,"result":"Heard.","t | ||
| 513 | 533 | // Bob's own turn (alice's minute of messages is spent by the tests above). |
| 514 | 534 | let seen = ""; |
| 515 | 535 | beforeAll(() => { |
| 516 | // Earlier tests swap in their own stand-ins; this one records the first message it is started with. | |
| 536 | // Earlier tests swap in their own stand-ins; this one records the first message it is started | |
| 537 | // with. | |
| 517 | 538 | const mine = join(dir, "claude-records"); |
| 518 | 539 | writeFileSync(mine, readFileSync(join(dir, "claude"), "utf8")); |
| 519 | 540 | chmodSync(mine, 0o755); |
new above
offline