feat: remove active knowledge support

This commit is contained in:
2026-07-16 07:30:00 +09:00
parent f2106407be
commit f786e01997
54 changed files with 197 additions and 1591 deletions
+2 -2
View File
@@ -6,7 +6,7 @@ export type AlertLevel = "warn" | "error";
export type AlertSource = "worker" | "engine" | "compactor" | "agents_md";
export type CompletionKind = "file" | "knowledge";
export type CompletionKind = "file";
export type WorkerStatus = "idle" | "running" | "paused";
@@ -79,7 +79,7 @@ message: string,
*/
timestamp_ms: number, };
export type Segment = { "kind": "text", content: string, } | { "kind": "paste", id: number, chars: number, lines: number, content: string, } | { "kind": "file_ref", path: string, } | { "kind": "knowledge_ref", slug: string, } | { "kind": "unknown" };
export type Segment = { "kind": "text", content: string, } | { "kind": "paste", id: number, chars: number, lines: number, content: string, } | { "kind": "file_ref", path: string, } | { "kind": "unknown" };
export type WorkerEvent = { "kind": "turn_ended", worker_name: string, } | { "kind": "errored", worker_name: string, message: string, } | { "kind": "shut_down", worker_name: string, } | { "kind": "scope_sub_delegated",
/**
@@ -1,72 +1,20 @@
import {
buildComposerRequest,
parseSigilSegments,
} from "./composer-command.ts";
import { parseSigilSegments } from "./composer-command.ts";
declare const Deno: {
test(name: string, fn: () => void): void;
};
function assert(condition: unknown, message: string): asserts condition {
if (!condition) {
throw new Error(message);
}
}
declare const Deno: { test(name: string, fn: () => void): void };
function assertEquals<T>(actual: T, expected: T): void {
const actualJson = JSON.stringify(actual);
const expectedJson = JSON.stringify(expected);
if (actualJson !== expectedJson) {
throw new Error(`Expected ${expectedJson}, got ${actualJson}`);
}
const a = JSON.stringify(actual);
const e = JSON.stringify(expected);
if (a !== e) throw new Error(`Expected ${e}, got ${a}`);
}
Deno.test("parseSigilSegments converts TUI-style references", () => {
assertEquals(
parseSigilSegments("read @src/main.rs then #memory and /literal"),
[
{ kind: "text", content: "read " },
{ kind: "file_ref", path: "src/main.rs" },
{ kind: "text", content: " then " },
{ kind: "knowledge_ref", slug: "memory" },
{ kind: "text", content: " and /literal" },
],
);
});
Deno.test("buildComposerRequest sends user segments when sigils are present", () => {
const result = buildComposerRequest("inspect @README.md");
assert(result.ok, "request should be accepted");
assertEquals(result.request?.kind, "user");
assertEquals(result.request?.content, "inspect @README.md");
assertEquals(result.request?.segments, [
{ kind: "text", content: "inspect " },
{ kind: "file_ref", path: "README.md" },
Deno.test("parseSigilSegments turns file sigils into file refs", () => {
assertEquals(parseSigilSegments("read @src/main.rs"), [
{ kind: "text", content: "read " },
{ kind: "file_ref", path: "src/main.rs" },
]);
});
Deno.test("buildComposerRequest parses colon commands", () => {
const compact = buildComposerRequest(":compact");
assert(compact.ok, "compact should be accepted");
assertEquals(compact.request, { kind: "compact", content: "" });
const peer = buildComposerRequest(":peer companion");
assert(peer.ok, "peer should be accepted");
assertEquals(peer.request, { kind: "register_peer", content: "companion" });
const help = buildComposerRequest(":help compact");
assert(help.ok, "help should be accepted");
assertEquals(help.request, undefined);
assert(
help.notice?.includes(":compact"),
"help should return a local notice",
);
});
Deno.test("buildComposerRequest rejects invalid colon commands", () => {
const unknown = buildComposerRequest(":does-not-exist");
assert(!unknown.ok, "unknown command should be rejected");
const invalidPeer = buildComposerRequest(":peer");
assert(!invalidPeer.ok, "invalid peer command should be rejected");
Deno.test("parseSigilSegments leaves hash sigils as plain text", () => {
assertEquals(parseSigilSegments("ask #memory"), [{ kind: "text", content: "ask #memory" }]);
});
@@ -161,7 +161,7 @@ function invalidUsage(name: string): ComposerCommandResult {
export function parseSigilSegments(input: string): Segment[] {
const segments: Segment[] = [];
const pattern = /(^|\s)([@#])([^\s]+)/g;
const pattern = /(^|\s)([@])([^\s]+)/g;
let cursor = 0;
let match: RegExpExecArray | null;
while ((match = pattern.exec(input)) !== null) {
@@ -185,8 +185,6 @@ function sigilSegment(sigil: string, value: string): Segment {
switch (sigil) {
case "@":
return { kind: "file_ref", path: value };
case "#":
return { kind: "knowledge_ref", slug: value };
default:
return { kind: "text", content: `${sigil}${value}` };
}
@@ -31,7 +31,6 @@ Deno.test("completionTokenAt detects TUI-style sigils before the cursor", () =>
prefix: "src/ma",
});
assertEquals(completionTokenAt(":comp", 5)?.kind, "command");
assertEquals(completionTokenAt("ask #mem", 8)?.kind, "knowledge");
assertEquals(completionTokenAt("run /work", 9), null);
});
@@ -1,4 +1,4 @@
export type ComposerCompletionKind = "command" | "file" | "knowledge";
export type ComposerCompletionKind = "command" | "file";
export type ComposerCompletionToken = {
sigil: ":" | "@" | "#";
@@ -83,9 +83,9 @@ function completionKindForSigil(
switch (sigil) {
case ":":
return "command";
default:
return "file";
case "@":
return "file";
case "#":
return "knowledge";
}
}
@@ -35,23 +35,7 @@ Deno.test("workerConsoleHref encodes runtime and worker target authority", () =>
);
});
Deno.test("segmentsToText preserves protocol segment semantics", () => {
const text = segmentsToText([
{ kind: "text", content: "hello" },
{ kind: "file_ref", path: "/tmp/example.md" },
{ kind: "knowledge_ref", slug: "design-note" },
]);
assert(text.includes("hello"), "text segment should render content");
assert(
text.includes("@file /tmp/example.md"),
"file ref should render as a file reference",
);
assert(
text.includes("@knowledge design-note"),
"knowledge ref should render as a knowledge reference",
);
});
Deno.test("projectConsole projects visible protocol rows", () => {
const projection = projectConsole([
@@ -317,8 +317,6 @@ export function segmentsToText(segments: Segment[]): string {
`[paste ${segment.id}: ${segment.chars} chars / ${segment.lines} lines]`;
case "file_ref":
return `@file ${segment.path}`;
case "knowledge_ref":
return `@knowledge ${segment.slug}`;
case "unknown":
return "[unknown segment]";
}
@@ -46,7 +46,7 @@
}
type WorkerCompletionsResult = {
kind: "file" | "knowledge";
kind: "file";
prefix: string;
entries: ComposerCompletionEntry[];
diagnostics: Diagnostic[];