Public: anyone can read this; the crew can change it.

A person can search their talk conversations by a word #13277

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

scout/forge:scout/13259-a-person-can-search-their-talk-conversat → main 3 commits fork

  • Merged. scout/13259-a-person-can-search-their-talk-conversat was merged into main as bdc4c7e.

Review

Sign in to review this change.
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`;
201201 | `rollback` | — | Plan, then apply, a rollback to a kept release (admin) | 209 |
202202 | `run_log` | — | A run's log, or its last `tail` lines, as GET /api/v1/repos/:owner/:name/runs/:id/log | 332 |
203203 | `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 |
205205 | `scorecard` | — | Crew scorecard (forge admin): per agent, all time and 30 days | 284 |
206206 | `seal` | `private` | Seal or unseal an issue or pull: a sealed one is seen only by writers and crew | 297 |
207207 | `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
8383 | Starter questions on an empty chat (links to `/talk?q=`, so they work without the script) | this pull | AI Elements `Suggestion` |
8484 | Stick to bottom, "Latest" jump button | this pull | AI Elements `Conversation` |
8585 | 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) |
8787 | Edit and resend, regenerate, Retry (see below) | have (#8817) | replaced turns are kept and marked, not deleted |
8888 | Queue and Steer while an answer runs | #8819 | `Queue` / `PromptInput` |
8989 | 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
113113 - **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.
114114 - **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.
115115 - **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.
117118
118119 ## Build an app from one prompt (#11010)
119120
src/http/mcp/tools/say.ts +11 −6
@@ -3,7 +3,7 @@ import { badBlocked } from "../shared.ts";
33 import { noTalkAccountBlocked } from "../../../actions/blocked_words.ts";
44 import { addCommentThrough } from "../../../actions/issues.ts";
55 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";
77 import { BUILD_WORDS, buildState, publishBuild, restoreVersion, startBuild, versionDiff, type BuildError } from "../../../actions/build.ts";
88 import { BUILD_ID, promptRefusal, templateRefusal, versionRefusal } from "../../../actions/build_input.ts";
99 import { talk, TALK_WORDS } from "../../../actions/talk.ts";
@@ -15,9 +15,9 @@ const buildBad = (error: BuildError) => bad(error, BUILD_WORDS[error] ?? error);
1515
1616 export const tool: Tool = {
1717 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`",
1919 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).",
2121 inputSchema: {
2222 type: "object",
2323 properties: {
@@ -25,7 +25,7 @@ export const tool: Tool = {
2525 number: { type: "integer", minimum: 1 },
2626 text: { type: "string", maxLength: 8000 },
2727 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] },
2929 template: { type: "string" },
3030 version: { type: "integer", minimum: 1 },
3131 title: { type: "string", maxLength: 80 },
@@ -33,7 +33,7 @@ export const tool: Tool = {
3333 },
3434 },
3535 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"),
3737 async run(ctx, user, args) {
3838 if (args["repo"] === undefined && args["number"] === undefined) {
3939 // The forge's own agent never wakes itself: its via token is refused.
@@ -41,6 +41,11 @@ export const tool: Tool = {
4141 const db = ctx.app.db;
4242 const action = args["action"];
4343 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 }
4449 if (typeof action === "string" && BUILD_ACTIONS.includes(action)) {
4550 if (action === "build") {
4651 const prompt = args["text"];
@@ -92,7 +97,7 @@ export const tool: Tool = {
9297 const named = renameConversation(db, user.id, target.id, args["title"]);
9398 return named.ok ? good({ says: "Renamed." }) : bad("invalid_title", "title is up to 80 characters, on one line");
9499 }
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");
96101 archiveConversation(db, user.id, target.id, action === "archive");
97102 return good({ says: action === "archive" ? "Archived." : "Restored." });
98103 }
test/conversation-talk.test.ts +22 −1
@@ -142,6 +142,26 @@ echo '{"type":"result","subtype":"success","is_error":false,"result":"Heard.","t
142142 expect(now.turns.map((t) => `${t.role}:${t.text}`)).toEqual(["person:by api", "agent:Heard."]);
143143 });
144144
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
145165 test("the API refuses no sign-in, bad words and a cross-origin browser", async () => {
146166 const post = (h: Record<string, string>, body: unknown) =>
147167 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
513533 // Bob's own turn (alice's minute of messages is spent by the tests above).
514534 let seen = "";
515535 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.
517538 const mine = join(dir, "claude-records");
518539 writeFileSync(mine, readFileSync(join(dir, "claude"), "utf8"));
519540 chmodSync(mine, 0o755);

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs