{"draft":null,"from":19,"to":20,"files":[{"path":"client/src/issues.ts","added":36,"removed":1,"diff":"--- a/client/src/issues.ts\n+++ b/client/src/issues.ts\n@@ -7,7 +7,7 @@\n \n import { readFileSync, statSync } from \"node:fs\";\n import { basename, resolve } from \"node:path\";\n-import type { Api, Ask, Attachment, Draft, DraftBody, IssuePage, IssueRow } from \"./api.ts\";\n+import type { Api, Ask, Attachment, Draft, DraftBody, IssuePage, IssueRow, IssueSearchHit } from \"./api.ts\";\n import { bool, type Parsed, str, UsageError } from \"./args.ts\";\n import { type Env, type Output, open, plural } from \"./commands.ts\";\n import { type Config, readMachineServers, trustedServers } from \"./config.ts\";\n@@ -479,6 +479,41 @@\n \treturn { text: `Withdrew ask ${id}. ${r.ask.of} hears it, and it no longer waits on them.`, json: { ask: r.ask } };\n }\n \n+/** One search hit as two lines: the issue, then where it matched and the words around it. */\n+export function searchLines(h: IssueSearchHit): string[] {\n+\tconst where = h.meaning ? \"by meaning\" : h.where === \"comment\" ? `in comment ${h.comment}` : `in the ${h.where}`;\n+\tconst words = h.snippet\n+\t\t.replace(/[\\u0001\\u0002]/g, \"\")\n+\t\t.replace(/\\s+/g, \" \")\n+\t\t.trim();\n+\treturn [\n+\t\t`  ${String(h.issue.id).padStart(3)}  ${h.issue.status.padEnd(11)}  ${q(h.issue.title)}`,\n+\t\t`       ${where}${words && words !== h.issue.title ? `: ${q(words)}` : \"\"}`,\n+\t];\n+}\n+\n+export async function runSearch(args: Parsed, env: Env): Promise<Output> {\n+\tconst words = args.positionals.join(\" \").trim();\n+\tif (words === \"\") throw new UsageError('search needs words: abso search \"<words>\" [--limit <N>]');\n+\tconst limitWord = str(args, \"limit\");\n+\tconst limit = limitWord === undefined ? undefined : Number(limitWord);\n+\tif (limit !== undefined && !(Number.isInteger(limit) && limit >= 1 && limit <= 50))\n+\t\tthrow new UsageError(\"--limit is a number from 1 to 50\");\n+\tconst { api } = openIssues(env);\n+\tconst { hits } = await api.issueSearch(words, limit);\n+\treturn {\n+\t\ttext:\n+\t\t\thits.length === 0\n+\t\t\t\t? `Nothing matches ${q(words)}.`\n+\t\t\t\t: [\n+\t\t\t\t\t\t`${plural(hits.length, \"issue\")} for ${q(words)}, best first:`,\n+\t\t\t\t\t\t...hits.flatMap(searchLines),\n+\t\t\t\t\t\t\"abso issue <N> shows one.\",\n+\t\t\t\t\t].join(\"\\n\"),\n+\t\tjson: { hits },\n+\t};\n+}\n+\n export async function runWaiting(args: Parsed, env: Env): Promise<Output> {\n \tif (args.positionals.length > 0)\n \t\tthrow new UsageError(\"waiting takes no words: abso waiting [--of <agent or person:id>] [--mine]\");"}],"unmatched":[]}