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
+11 -25
View File
@@ -171,7 +171,7 @@ impl WorkerEvent {
/// `Method::Run` and `Event::UserMessage` carry `Vec<Segment>`. Dumb
/// clients (CLI piping, scripts) only need to produce a single
/// `Segment::Text`; richer clients (TUI / GUI) construct typed atoms
/// (paste chips, file refs, knowledge refs, knowledge refs) and
/// (paste chips, file refs) and
/// send them through directly so the Worker side never has to re-parse a
/// flattened string.
///
@@ -201,8 +201,6 @@ pub enum Segment {
/// `[Dir: <path>]` listings; the flattened user text keeps the literal
/// `@<path>` placeholder either way.
FileRef { path: String },
/// `#<slug>` Knowledge reference (see `docs/plan/memory.md`).
KnowledgeRef { slug: String },
/// Unknown variant from a newer client. Worker treats this as an
/// unresolved input — surfaces an alert and inserts a placeholder.
/// Round-trip is lossy: re-serializing yields `{"kind":"unknown"}`.
@@ -221,9 +219,8 @@ impl Segment {
/// to surface user-visible alerts for unresolved refs should do so
/// alongside this call (Worker does so at submit time).
///
/// Sigil-prefixed variants (`FileRef` / `KnowledgeRef`)
/// flatten back to their literal sigil form (`@<path>`, `#<slug>`,
/// ) — matching what the user originally typed. Resolved
/// Sigil-prefixed variants (`FileRef`) flatten back to their literal
/// sigil form (`@<path>`) when converted to text.
/// content (e.g. file body or shallow directory listing for `FileRef`) is
/// delivered as separate `Item::system_message`s adjacent to the user
/// message; the resolution itself is the caller's job. `Unknown` falls back to
@@ -238,13 +235,7 @@ impl Segment {
out.push('@');
out.push_str(path);
}
Segment::KnowledgeRef { slug } => {
out.push('#');
out.push_str(slug);
}
Segment::Unknown => {
out.push_str("[unknown input segment]");
}
Segment::Unknown => {}
}
}
out
@@ -287,8 +278,7 @@ pub enum Event {
///
/// Carries the JSON form of `session_store::SystemItem`. Covers
/// `Method::Notify` echoes, child-Worker lifecycle events from
/// `Method::WorkerEvent`, `@<path>` / `#<slug>` /
/// resolution payloads, and any future agent-side injection kind.
/// `Method::WorkerEvent`, `@<path>` resolution payloads, and any future
/// Clients dispatch on the `kind` tag for typed rendering instead
/// of parsing free-text prefixes like `[Notification] …` or
/// `[File: …]`.
@@ -599,21 +589,17 @@ pub enum AlertSource {
/// Kind of completion requested by `Method::ListCompletions`.
///
/// Mirrors the completion prefix sigils: `@` → `File`, `#` → `Knowledge`.
/// Mirrors the completion prefix sigil: `@` → `File`.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
#[cfg_attr(feature = "typescript", derive(ts_rs::TS))]
#[serde(rename_all = "snake_case")]
pub enum CompletionKind {
File,
Knowledge,
}
/// One candidate returned in `Event::Completions::entries`.
/// One completion candidate for a prefix query.
///
/// `value` is a path (file kind) or a Knowledge slug.
/// `is_dir` is meaningful only for the file kind — it lets the TUI
/// keep a trailing `/` after a directory selection so the user can
/// drill in without re-typing the prefix.
/// `value` is a path (file kind).
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[cfg_attr(feature = "typescript", derive(ts_rs::TS))]
pub struct CompletionEntry {
@@ -1177,16 +1163,16 @@ mod tests {
#[test]
fn event_completions_format_and_default_is_dir() {
let event = Event::Completions {
kind: CompletionKind::Knowledge,
kind: CompletionKind::File,
entries: vec![CompletionEntry {
value: "clear".into(),
value: "src/main.rs".into(),
is_dir: false,
}],
};
let json = serde_json::to_string(&event).unwrap();
let parsed: serde_json::Value = serde_json::from_str(&json).unwrap();
assert_eq!(parsed["event"], "completions");
assert_eq!(parsed["data"]["kind"], "knowledge");
assert_eq!(parsed["data"]["kind"], "file");
assert_eq!(parsed["data"]["entries"][0]["value"], "clear");
// is_dir defaults to false on inbound payloads that omit it.