Skip to content

abso-core

Public

abso is version control for agents: the client, the engine and a server you can run on your own Cloudflare account.

Check passed
MCP
show on this site's /mcp
CLI
abso show 20 --json
JSON
/christopher/abso-core/versions/20?format=json

Add abso search: find a project's issues by words or meaning

of shared·devops··Not checked

abso search "<words>" [--limit <N>] lists the project's issues that match, best first, and is served as an MCP tool as well.

  • Each hit shows the issue, then where it matched: the title, the description, a comment, or "by meaning".
  • "#N" or "N" puts issue N first.
  • Where the server also searches by meaning, an issue worded unlike the search still turns up; the hit says so.

Version 19 · Files at version 20

6 files, 93 lines added, 5 removed.

--- a/client/src/api.ts
+++ b/client/src/api.ts
@@ -50,7 +50,16 @@
5050 WhereAnswer,
5151 WhyAnswer,
5252} from "./history-answers.ts";
53−import type { Ask, Attachment, Draft, DraftBody, News as IssueNews, IssuePage, IssueRow } from "./issues-wire.ts";
53+import type {
54+ Ask,
55+ Attachment,
56+ Draft,
57+ DraftBody,
58+ News as IssueNews,
59+ IssuePage,
60+ IssueRow,
61+ IssueSearchHit,
62+} from "./issues-wire.ts";
5463import type { Modes } from "./modes.ts";
5564
5665export * from "./api-answers.ts";
@@ -65,7 +74,7 @@
6574} from "./box-run.ts";
6675export * from "./ci-answers.ts";
6776export * from "./history-answers.ts";
68−export type { Ask, Attachment, Draft, DraftBody, IssueNews, IssuePage, IssueRow };
77+export type { Ask, Attachment, Draft, DraftBody, IssueNews, IssuePage, IssueRow, IssueSearchHit };
6978
7079/**
7180 * How long a call may take: the base, plus 1 s for each 100 KB it sends
@@ -375,6 +384,14 @@
375384 );
376385 }
377386
387+ /**
388+ * The project's issues matching q, best first: by its words and, where
389+ * the server has it on, by what it means.
390+ */
391+ issueSearch(q: string, limit?: number): Promise<{ hits: readonly IssueSearchHit[] }> {
392+ return this.#issues("GET", `/search?${query({ q, limit })}`);
393+ }
378395 /** Every label in use, with how many issues have it and how many of those are open. */
379396 issueLabels(): Promise<{ labels: readonly { label: string; open: number; total: number }[] }> {
380397 return this.#issues("GET", "/labels");
--- a/client/src/issues-wire.ts
+++ b/client/src/issues-wire.ts
@@ -134,3 +134,14 @@
134134 body: DraftBody;
135135 saved: number;
136136}
138+/** One issue search hit: the issue, where it matched, a few words around it. */
139+export interface IssueSearchHit {
140+ issue: { id: number; title: string; status: Status; updated: number; labels: string[] };
141+ where: "title" | "description" | "comment";
142+ comment?: number;
143+ /** The words around the match; char(1) and char(2) bracket each matched span. */
144+ snippet: string;
145+ /** Only meaning search found it: the words differ, the meaning matches. */
146+ meaning?: true;
147+}
--- a/client/src/issues.ts
+++ b/client/src/issues.ts
@@ -7,7 +7,7 @@
77
88import { readFileSync, statSync } from "node:fs";
99import { basename, resolve } from "node:path";
10−import type { Api, Ask, Attachment, Draft, DraftBody, IssuePage, IssueRow } from "./api.ts";
10+import type { Api, Ask, Attachment, Draft, DraftBody, IssuePage, IssueRow, IssueSearchHit } from "./api.ts";
1111import { bool, type Parsed, str, UsageError } from "./args.ts";
1212import { type Env, type Output, open, plural } from "./commands.ts";
1313import { type Config, readMachineServers, trustedServers } from "./config.ts";
@@ -479,6 +479,41 @@
479479 return { text: `Withdrew ask ${id}. ${r.ask.of} hears it, and it no longer waits on them.`, json: { ask: r.ask } };
480480}
481481
482+/** One search hit as two lines: the issue, then where it matched and the words around it. */
483+export function searchLines(h: IssueSearchHit): string[] {
484+ const where = h.meaning ? "by meaning" : h.where === "comment" ? `in comment ${h.comment}` : `in the ${h.where}`;
485+ const words = h.snippet
486+ .replace(/[\u0001\u0002]/g, "")
487+ .replace(/\s+/g, " ")
488+ .trim();
489+ return [
490+ ` ${String(h.issue.id).padStart(3)} ${h.issue.status.padEnd(11)} ${q(h.issue.title)}`,
491+ ` ${where}${words && words !== h.issue.title ? `: ${q(words)}` : ""}`,
492+ ];
493+}
495+export async function runSearch(args: Parsed, env: Env): Promise<Output> {
496+ const words = args.positionals.join(" ").trim();
497+ if (words === "") throw new UsageError('search needs words: abso search "<words>" [--limit <N>]');
498+ const limitWord = str(args, "limit");
499+ const limit = limitWord === undefined ? undefined : Number(limitWord);
500+ if (limit !== undefined && !(Number.isInteger(limit) && limit >= 1 && limit <= 50))
501+ throw new UsageError("--limit is a number from 1 to 50");
502+ const { api } = openIssues(env);
503+ const { hits } = await api.issueSearch(words, limit);
504+ return {
505+ text:
506+ hits.length === 0
507+ ? `Nothing matches ${q(words)}.`
508+ : [
509+ `${plural(hits.length, "issue")} for ${q(words)}, best first:`,
510+ ...hits.flatMap(searchLines),
511+ "abso issue <N> shows one.",
512+ ].join("\n"),
513+ json: { hits },
514+ };
515+}
482517export async function runWaiting(args: Parsed, env: Env): Promise<Output> {
483518 if (args.positionals.length > 0)
484519 throw new UsageError("waiting takes no words: abso waiting [--of <agent or person:id>] [--mine]");
--- a/client/src/main.ts
+++ b/client/src/main.ts
@@ -40,7 +40,7 @@
4040import { runDraftSync, runLand, runSwitch } from "./drafts.ts";
4141import { runExport } from "./export.ts";
4242import { runBlame, runWhere, runWho, runWhy } from "./history.ts";
43−import { runAnswer, runAsk, runIssue, runIssues, runWaiting } from "./issues.ts";
43+import { runAnswer, runAsk, runIssue, runIssues, runSearch, runWaiting } from "./issues.ts";
4444import { adminToken, issuedPublic, keyList, keyListText, keyNew, keyRevoke } from "./key-admin.ts";
4545import { runUnqueue } from "./queue.ts";
4646import { runNote, runNotes, runReview } from "./review.ts";
@@ -390,6 +390,13 @@
390390 "Ask an agent, or a person (person:<id>), something; they hear it. On an issue, it holds the issue at Blocked (In review for --review) until answered. --task asks for something done instead of an answer; --options gives the choices; --blocks names the issues waiting on it. --withdraw takes back an ask you made that no longer needs an answer: it leaves their waiting list, stops holding the issue, keeps your --note as why, and they hear it.",
391391 run: runAsk,
392392 },
393+ search: {
394+ flags: { limit: "string" },
395+ usage: 'abso search "<words>" [--limit <N>]',
396+ about:
397+ "The project's issues that match, best first: by their words, and by what they mean where the server has meaning search on, so an issue worded differently from your search still turns up. #N or N puts issue N first. Each hit says where it matched; one only meaning search found says by meaning.",
398+ run: runSearch,
399+ },
393400 waiting: {
394401 flags: { of: "string", mine: "boolean" },
395402 usage: "abso waiting [--of <agent or person:id>] [--mine]",
--- a/client/src/mcp.ts
+++ b/client/src/mcp.ts
@@ -47,6 +47,7 @@
4747 "notes",
4848 "issues",
4949 "issue",
50+ "search",
5051 "ask",
5152 "waiting",
5253 "answer",
--- a/client/test/issues.test.ts
+++ b/client/test/issues.test.ts
@@ -14,6 +14,7 @@
1414import { after, before, describe, it } from "node:test";
1515import { readMachineServers } from "../src/config.ts";
1616import { issuesServerFor, tokenGoesTo } from "../src/core.ts";
17+import { searchLines } from "../src/issues.ts";
1718import { main } from "../src/main.ts";
1819import { argvFor, mcpTools } from "../src/mcp.ts";
1920import { type Fake, startFake } from "./fake-server.ts";
@@ -106,7 +107,7 @@
106107
107108 it("are MCP tools", () => {
108109 const names = mcpTools().map((t) => t.name);
109− for (const n of ["issues", "issue", "ask", "waiting", "answer"]) assert.ok(names.includes(n), n);
110+ for (const n of ["issues", "issue", "search", "ask", "waiting", "answer"]) assert.ok(names.includes(n), n);
110111 assert.deepEqual(argvFor("ask", { args: ["alice", "Which login?"], issue: "3", review: true }), [
111112 "ask",
112113 "--issue=3",
@@ -133,6 +134,9 @@
133134 ["ask", "--withdraw", "3", "--issue", "2"],
134135 ["ask", "--withdraw", "3", "--task"],
135136 ["ask", "alice", "q", "--note", "a note without --withdraw"],
137+ ["search"],
138+ ["search", "words", "--limit", "0"],
139+ ["search", "words", "--limit", "51"],
136140 ]) {
137141 const r = await avcs(erin, argv);
138142 assert.equal(r.exit, 1, `${argv.join(" ")}: ${r.out}`);
@@ -140,6 +144,19 @@
140144 assert.equal(seen.length, before);
141145 });
142146
147+ it("shows a search hit as the issue, then where it matched, without the match markers", () => {
148+ const issue = { id: 12, title: "Sync is slow", status: "open" as const, updated: 0, labels: [] };
149+ assert.deepEqual(
150+ searchLines({ issue, where: "comment", comment: 40, snippet: "the \u0001network\u0002 drops mid-sync" }),
151+ [' 12 open "Sync is slow"', ' in comment 40: "the network drops mid-sync"'],
152+ );
153+ assert.deepEqual(searchLines({ issue, where: "description", snippet: "Pages load late.", meaning: true }), [
154+ ' 12 open "Sync is slow"',
155+ ' by meaning: "Pages load late."',
156+ ]);
157+ assert.deepEqual(searchLines({ issue, where: "title", snippet: "Sync is slow" })[1], " in the title");
158+ });
143160 it("withdraw is one POST to the asker's own withdraw/<ask> route", async () => {
144161 const erin = await folder("erin");
145162 const before = seen.length;