From 20ffd9d64745cbf94013144b91df7a0ffe6f4161 Mon Sep 17 00:00:00 2001 From: Sidharth Menon Date: Thu, 1 Oct 2026 12:00:47 -0700 Subject: [PATCH] improvement: pseudocode summarization improvements Agent-Session: beda0994-f79e-4d8c-86d2-1e91557d62cc --- plugins/summarize/plugin.toml | 44 +++++++++++++++++++++++++++++------ src/plugin/config.rs | 8 +++---- src/plugin/tests/summarize.rs | 4 ---- 3 files changed, 41 insertions(+), 15 deletions(-) diff --git a/plugins/summarize/plugin.toml b/plugins/summarize/plugin.toml index 7f633cd92..9f303e859 100644 --- a/plugins/summarize/plugin.toml +++ b/plugins/summarize/plugin.toml @@ -68,14 +68,44 @@ default = 3 [options.system_prompt] type = "string" title = "System prompt" -description = "The system instruction sent with every request; diffr builds each request's message from the file's numbered lines and the folds to summarize. Unset uses the default: https://github.com/devdotfast/diffr/blob/main/plugins/summarize/plugin.toml#L72-L78" +description = "The system instruction sent with every request; diffr builds each request's message from the file's numbered lines and the folds to summarize. Unset uses the default: https://github.com/devdotfast/diffr/blob/main/plugins/summarize/plugin.toml#L72-L108" default = """\ -For each listed fold, rewrite that function body as short \ -pseudocode. Keep the names. No prose, no comments, no code fences. Use as few lines as \ -possible: about one pseudocode line per five source lines, and never more than a third \ -of the body's lines. When a fold lists a doc, also set "summary" to one sentence copied \ -verbatim from that doc; otherwise leave it empty. Answer with a JSON object whose \ -"summaries" array holds one {"id", "summary", "pseudocode"} object per fold.""" +For each listed fold, rewrite that function or test body as pseudocode a reviewer can \ +read instead of the code. First decide what the body mostly does, then use its shape. + +Logic or an algorithm (branches, loops, computation): plain-word steps, nested two \ +spaces per level: + if content is unchanged + return cached result + write new content + return fresh result + +Control flow (mostly calls to other functions, in order): a call tree of the callees, \ +each call's own calls indented under it: + createSession + persistPrompt + launchAgent + navigateToSession + +UI (renders components or markup): a component tree, with the hooks and state that \ +matter under their component, and a component's module in parentheses when it comes \ +from elsewhere: + + useSessionEvents() + (packages/ui) + +A test: the setup, the action under test, then what it asserts. + +If uncertain, pick the option with the shortest output / explanation. You do not need to be 1:1 \ +with the underlying code in any of this pseudocode. You can use notional function names, etc. \ +as long as it helps the reader get a quick understanding of what the underlying code is doing. + +Pseudocode is best read when it's short and sweet - you are not trying to write an algorithms textbook, \ +just a quick summary that the user can expand to the underlying code. Strive to compress the code. + +When a fold lists a doc, also set "summary" to one sentence copied verbatim from that \ +doc; otherwise leave it empty. Answer with a JSON object whose "summaries" array holds \ +one {"id", "summary", "pseudocode"} object per fold.""" [options.tests] type = "boolean" diff --git a/src/plugin/config.rs b/src/plugin/config.rs index c184a55c6..9640befdf 100644 --- a/src/plugin/config.rs +++ b/src/plugin/config.rs @@ -849,10 +849,10 @@ mod tests { let summarize = &plugins["bundled"]["properties"]["summarize"]["properties"]; // A text setting, so settings screens let users edit the prompt. assert!(summarize["system_prompt"].get("x-settings").is_none()); - assert!(summarize["system_prompt"]["default"] - .as_str() - .unwrap() - .starts_with("For each listed fold, rewrite that function body")); + assert_eq!( + summarize["system_prompt"]["default"], + super::builtin::manifest("summarize").unwrap().options["system_prompt"]["default"] + ); let keys: Vec<&String> = plugins.as_object().unwrap().keys().collect(); assert_eq!(keys, ["order", "bundled", "external"]); } diff --git a/src/plugin/tests/summarize.rs b/src/plugin/tests/summarize.rs index c2f632e40..ac740e806 100644 --- a/src/plugin/tests/summarize.rs +++ b/src/plugin/tests/summarize.rs @@ -378,10 +378,6 @@ fn the_system_prompt_is_the_configured_one() { .fill_defaults(&mut defaults); let default: Options = serde_json::from_value(serde_json::Value::Object(defaults)).unwrap(); assert_eq!(system, default.system_prompt.as_str()); - assert!(default.system_prompt.starts_with( - "For each listed fold, rewrite that function body as short pseudocode. Keep the names." - )); - assert!(!default.system_prompt.contains('\n')); } #[test]