feat: added .set memory REPL commands to control memory injection and applied formatting
This commit is contained in:
+9
-12
@@ -253,8 +253,7 @@ fn workspace_label(w: &WorkspaceMemory) -> Value {
|
||||
|
||||
fn lint_memory(store: &MemoryStore) -> Result<Value> {
|
||||
let files = store.list_files()?;
|
||||
let names: HashSet<&str> =
|
||||
files.iter().map(|f| f.frontmatter.name.as_str()).collect();
|
||||
let names: HashSet<&str> = files.iter().map(|f| f.frontmatter.name.as_str()).collect();
|
||||
|
||||
let mut oversized = Vec::new();
|
||||
let mut broken_links = Vec::new();
|
||||
@@ -293,12 +292,13 @@ fn extract_wikilinks(body: &str) -> Vec<String> {
|
||||
let bytes = body.as_bytes();
|
||||
let mut i = 0;
|
||||
while i + 1 < bytes.len() {
|
||||
if bytes[i] == b'[' && bytes[i + 1] == b'[' {
|
||||
if let Some(end_rel) = body[i + 2..].find("]]") {
|
||||
out.push(body[i + 2..i + 2 + end_rel].to_string());
|
||||
i = i + 2 + end_rel + 2;
|
||||
continue;
|
||||
}
|
||||
if bytes[i] == b'['
|
||||
&& bytes[i + 1] == b'['
|
||||
&& let Some(end_rel) = body[i + 2..].find("]]")
|
||||
{
|
||||
out.push(body[i + 2..i + 2 + end_rel].to_string());
|
||||
i = i + 2 + end_rel + 2;
|
||||
continue;
|
||||
}
|
||||
i += 1;
|
||||
}
|
||||
@@ -466,10 +466,7 @@ mod tests {
|
||||
assert!(!orphan_names.contains(&"referenced"));
|
||||
|
||||
let broken = report["broken_wikilinks"].as_array().unwrap();
|
||||
let broken_targets: Vec<&str> = broken
|
||||
.iter()
|
||||
.filter_map(|v| v["to"].as_str())
|
||||
.collect();
|
||||
let broken_targets: Vec<&str> = broken.iter().filter_map(|v| v["to"].as_str()).collect();
|
||||
assert!(broken_targets.contains(&"missing"));
|
||||
assert!(broken_targets.contains(&"also_missing"));
|
||||
|
||||
|
||||
+6
-1
@@ -20,10 +20,10 @@ use crate::parsers::{bash, python, typescript};
|
||||
use anyhow::{Context, Result, anyhow, bail};
|
||||
use indexmap::IndexMap;
|
||||
use indoc::formatdoc;
|
||||
use memory::MEMORY_FUNCTION_PREFIX;
|
||||
use rust_embed::Embed;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde_json::{Value, json};
|
||||
use memory::MEMORY_FUNCTION_PREFIX;
|
||||
use skill::SKILL_FUNCTION_PREFIX;
|
||||
use std::collections::VecDeque;
|
||||
use std::ffi::OsStr;
|
||||
@@ -362,6 +362,11 @@ impl Functions {
|
||||
.extend(memory::memory_function_declarations());
|
||||
}
|
||||
|
||||
pub fn remove_memory_functions(&mut self) {
|
||||
self.declarations
|
||||
.retain(|f| !f.name.starts_with(MEMORY_FUNCTION_PREFIX));
|
||||
}
|
||||
|
||||
pub fn append_skill_functions(&mut self) {
|
||||
self.declarations
|
||||
.extend(skill::skill_function_declarations());
|
||||
|
||||
Reference in New Issue
Block a user