Skip to content

Commit 5361733

Browse files
0.2.2 polish: privacy gate, plugin dispatch fixes, image-preview removal (#239)
* plugins: once-only "N updated" notice; PATH probe accepts unprefixed binaries stats_line showed "{u} updated" on every launch for 24h after an update pass. Stamp the shown `at` into ~/.gray/auto-update-notified so each update result displays on exactly one launch; the next pass writes a newer `at` and notifies once again. The install PATH probe only looked for gray-<spec>; a plugin binary named <spec> (no gray- prefix, decoupled from any repo-name convention) was unreachable — try gray-<spec> first, then <spec>. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com> * plugins: index-driven command hints, multi-spec install, offline-aware lookups - index Entry gains `commands`; forward() resolves "which plugin owns this verb" from the served index instead of the hardcoded removed_builtin table alone (table remains as fallback for entries the index can't express) - index hint lookups are 24h-cached, 5s-timeout, and short-circuit under GRAY_OFFLINE - `gray plugin install` accepts multiple specs in one invocation - forward() is async; call sites updated Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com> * composer: drop inline image previews Kitty/half-block preview rows reserved giant blank regions in the transcript. Removes the preview path entirely: kitty module, preview line builders, transcript/tool-result splice sites, and the attached param on format_user_prompt_lines. Attachment markers in the prompt text are unchanged. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com> * privacy: GRAY_OFFLINE master switch + scope session header to zen Audit after anomalyco/opencode#10416 (silent prompt egress to a hosted provider for title generation; background models.dev connections). - GRAY_OFFLINE=1 suppresses every unsolicited outbound request: startup catalog fetches (models.dev, recommended.json, litellm, openrouter rates), the update check, and index hint lookups. Provider calls and explicit commands are unaffected. - Startup fetches now also respect --bare (they were unconditional). - x-opencode-session header is sent only to opencode.ai/zen endpoints; previously gray's session id went to every OpenAI-compatible provider. Title generation already uses the user's own configured provider — the opencode failure mode was not present. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com> * docs(changelog): 0.2.2 — privacy gate, plugin extraction, preview removal Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com> * fix(clippy): useless format! in PATH probe Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com> * test(provider): assert session header stays off non-zen endpoints The old test encoded the leak — header expected on every request. Now asserts the privacy property: no x-opencode-session on generic OpenAI-compatible endpoints. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com> --------- Co-authored-by: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
1 parent a4ebde7 commit 5361733

20 files changed

Lines changed: 150 additions & 768 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,6 @@
2525
of the box.
2626
- **`gray cloud` — your hosted Gray machine.** Provision it, check it,
2727
and chat with a Grayling seat from the CLI.
28-
- **Inline image previews in the transcript.** `cat`-ed image paths
29-
render inline (kitty graphics), the grounded band repaints rows it
30-
vacated, and prompt cards keep their painted margins.
3128
- **Prompt-cache + overflow machinery, ported from pi.** Provider
3229
`prompt_cache_key` support, compaction quarantine, cache-miss
3330
metering, a recoverable length-stop retry, and child/tool output that
@@ -36,8 +33,24 @@
3633
curated plugin set — account, memory, search, questions, subagents,
3734
mcp — on unix, WSL and the Windows path.
3835
- **`/skills` menu: Enter invokes the highlighted skill.**
36+
- **`GRAY_OFFLINE=1` — a master switch for unsolicited outbound
37+
requests.** Startup catalog fetches (models.dev, recommended model
38+
lists, litellm context windows, OpenRouter rates), the update check,
39+
and index hint lookups all stand down. Provider calls and explicit
40+
commands are unaffected. The startup fetches now also respect
41+
`--bare`, and `x-opencode-session` is sent only to opencode.ai/zen
42+
endpoints rather than every OpenAI-compatible provider.
43+
- **`gray plugin install` accepts multiple specs** in one invocation,
44+
resolves command-owner hints from the served plugin index, and the
45+
PATH probe accepts unprefixed binaries (`questions`, not only
46+
`gray-questions`).
3947

4048
### Fixed
49+
- **`login`/`whoami`/`logout`/`cloud`/`cron` live in their plugins now**
50+
(`account`, `gateway`) instead of gray core; both `gray x` and REPL
51+
`/x` dispatch through the manifest's claimed commands, including when
52+
the sidecar isn't running. The "N updated" launch notice now appears
53+
once per update instead of on every launch for 24h.
4154
- **`gray update` no longer reinstalls when already current.** It
4255
checks the latest version first and reports `gray X is current`
4356
instead of re-downloading; and a debug build refuses to self-update,

‎README.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ Gray runs the model's shell commands with **your privileges, no approval prompt,
136136
| `GRAY_EXEC_PREFIX` | run shell commands through this program |
137137
| `GRAY_NO_MEMORY=1` | disable memory |
138138
| `GRAY_NO_UPDATE_CHECK=1` · `GRAY_AUTO_UPDATE=1` | update check off, or background self-update |
139+
| `GRAY_OFFLINE=1` | no unsolicited outbound requests — update checks, model catalogs, index hints. Provider calls and explicit commands still work |
139140
| `GRAY_LOG` | `error`…`trace` → `~/.gray/logs/gray.log` |
140141

141142
### Platform support

‎crates/gray-pkg/src/index.rs‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,9 @@ pub struct Entry {
7070

7171
#[serde(default)]
7272
pub conflicts: Vec<String>,
73+
74+
#[serde(default)]
75+
pub commands: Vec<String>,
7376
}
7477

7578
impl Entry {

‎crates/gray-provider/src/openai.rs‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1784,9 +1784,13 @@ async fn send_json_once(
17841784
.post(url.clone())
17851785
.header("Authorization", format!("Bearer {api_key}"))
17861786
};
1787-
let base = session_affinity_headers(session_id)
1788-
.into_iter()
1789-
.fold(base, |b, (name, value)| b.header(name, value));
1787+
let base = session_affinity_headers(if url.as_str().contains("opencode.ai/zen") {
1788+
session_id
1789+
} else {
1790+
None
1791+
})
1792+
.into_iter()
1793+
.fold(base, |b, (name, value)| b.header(name, value));
17901794
let req = base.header("Content-Type", "application/json").json(body);
17911795
let res_result = req.send().await;
17921796
log::debug!(target: "gray_provider", "request sent to {url} (attempt {attempt})");

‎crates/gray-provider/src/openai_tests.rs‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -191,11 +191,10 @@ async fn session_header_sent_on_chat_post() {
191191
"default retry burst POSTs once per attempt"
192192
);
193193
for r in &received {
194-
let got = r
195-
.headers
196-
.get("x-opencode-session")
197-
.expect("session header sent");
198-
assert_eq!(got.to_str().expect("header ascii"), "sess-123");
194+
assert!(
195+
r.headers.get("x-opencode-session").is_none(),
196+
"session header must not leak to non-zen endpoints"
197+
);
199198
}
200199
}
201200

‎crates/gray/src/composer/mod.rs‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1069,9 +1069,8 @@ impl Tui {
10691069
self.record_rows(lines.clone());
10701070
self.insert_paragraph(&lines, Some(crate::theme::theme().window_bg));
10711071
}
1072-
TranscriptEntry::UserPrompt(text, attached) => {
1073-
let lines =
1074-
crate::composer::transcript::format_user_prompt_lines(text, attached, w);
1072+
TranscriptEntry::UserPrompt(text, _) => {
1073+
let lines = crate::composer::transcript::format_user_prompt_lines(text, w);
10751074
self.emit_rows(lines, Some(crate::theme::theme().surface_bg));
10761075
}
10771076
TranscriptEntry::ToolBox { header, body } => {

‎crates/gray/src/composer/transcript/boxes.rs‎

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -510,23 +510,13 @@ fn replay_tool_result(
510510
display.preview(&name),
511511
),
512512
};
513-
let mut lines = crate::tool_fmt::format_tool_result_lines_with_context(
513+
let lines = crate::tool_fmt::format_tool_result_lines_with_context(
514514
&name,
515515
args.as_ref(),
516516
content,
517517
is_error,
518518
Some(cwd),
519519
);
520-
if !is_error
521-
&& let Some(rows) = crate::composer::transcript::rows::viewed_image_lines(
522-
&name,
523-
args.as_ref(),
524-
cwd,
525-
tui.width(),
526-
)
527-
{
528-
lines.extend(rows);
529-
}
530520
tui.push_tool_box_lines(header, lines);
531521
}
532522

‎crates/gray/src/composer/transcript/mod.rs‎

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -103,12 +103,8 @@ pub(crate) fn layout_history(
103103
for entry in entries {
104104
match entry {
105105
TranscriptEntry::Welcome => out.extend(super::build_welcome_lines(w)),
106-
TranscriptEntry::UserPrompt(text, attached) => {
107-
place(
108-
&mut out,
109-
&mut owed,
110-
format_user_prompt_lines(text, attached, w),
111-
);
106+
TranscriptEntry::UserPrompt(text, _) => {
107+
place(&mut out, &mut owed, format_user_prompt_lines(text, w));
112108
}
113109
TranscriptEntry::ToolBox { header, body } => {
114110
place(
@@ -524,7 +520,7 @@ impl Tui {
524520
) {
525521
self.atomic(|t| {
526522
t.ensure_gap();
527-
let lines = format_user_prompt_lines(text, attached, t.width().max(10));
523+
let lines = format_user_prompt_lines(text, t.width().max(10));
528524
t.history_entries.push(super::TranscriptEntry::UserPrompt(
529525
text.to_string(),
530526
attached.to_vec(),

‎crates/gray/src/composer/transcript/mod_tests.rs‎

Lines changed: 5 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ fn unboundaryed_punctuation_only_chunks_are_held_not_rendered() {
184184
#[test]
185185
fn user_prompt_wraps_at_word_boundaries() {
186186
let text = "write a very long poem about the restless sea";
187-
let lines = format_user_prompt_lines(text, &[], 24);
187+
let lines = format_user_prompt_lines(text, 24);
188188

189189
let bodies: Vec<String> = lines
190190
.iter()
@@ -206,7 +206,7 @@ fn user_prompt_wraps_at_word_boundaries() {
206206
#[test]
207207
fn user_prompt_wraps_wide_chars_by_cells() {
208208
let text = "界界界界界";
209-
let lines = format_user_prompt_lines(text, &[], 6);
209+
let lines = format_user_prompt_lines(text, 6);
210210
let bodies: Vec<Span<'static>> = lines
211211
.iter()
212212
.filter_map(|l| l.spans.get(1).cloned())
@@ -493,10 +493,10 @@ fn prose_and_card_glyphs_share_the_gutter_column() {
493493
assert_eq!(first_glyph(&prose[0]), GUTTER);
494494
let card = format_tool_box_lines(Line::from("● Ran cargo fmt"), &[], 80);
495495
assert_eq!(first_glyph(&card[1]), GUTTER);
496-
let prompt = format_user_prompt_lines("rebuilt?", &[], 80);
496+
let prompt = format_user_prompt_lines("rebuilt?", 80);
497497
assert_eq!(first_glyph(&prompt[1]), GUTTER);
498498

499-
let long = format_user_prompt_lines(&"word ".repeat(40), &[], 40);
499+
let long = format_user_prompt_lines(&"word ".repeat(40), 40);
500500
assert_eq!(first_glyph(&long[2]), GUTTER + 2);
501501
for row in &long {
502502
let w: usize = row.spans.iter().map(|s| s.width()).sum();
@@ -547,7 +547,7 @@ fn the_backdrop_keeps_the_live_margins() {
547547

548548
#[test]
549549
fn user_prompt_renders_attachment_markers_as_chips() {
550-
let lines = format_user_prompt_lines("look [image: shot.png] here", &[], 60);
550+
let lines = format_user_prompt_lines("look [image: shot.png] here", 60);
551551
let text: String = lines
552552
.iter()
553553
.flat_map(|l| l.spans.iter().map(|s| s.content.to_string()))
@@ -556,37 +556,3 @@ fn user_prompt_renders_attachment_markers_as_chips() {
556556
assert!(text.contains(" IMAGE "), "{text}");
557557
assert!(text.contains("shot.png"), "{text}");
558558
}
559-
560-
#[test]
561-
fn viewed_image_lines_preview_read_path() {
562-
let dir = tempfile::tempdir().expect("tempdir");
563-
let img = dir.path().join("slide.png");
564-
::image::RgbaImage::from_pixel(8, 8, ::image::Rgba([255, 0, 0, 255]))
565-
.save(&img)
566-
.expect("write png");
567-
let args = serde_json::json!({"path": "slide.png"});
568-
let rows = super::rows::viewed_image_lines("read", Some(&args), dir.path(), 40);
569-
assert!(rows.is_some(), "read on an image should preview");
570-
}
571-
572-
#[test]
573-
fn viewed_image_lines_preview_bash_cat() {
574-
let dir = tempfile::tempdir().expect("tempdir");
575-
let img = dir.path().join("slide.png");
576-
::image::RgbaImage::from_pixel(8, 8, ::image::Rgba([0, 255, 0, 255]))
577-
.save(&img)
578-
.expect("write png");
579-
let cmd = format!("cat '{}'", img.display());
580-
let args = serde_json::json!({"command": cmd});
581-
let rows = super::rows::viewed_image_lines("bash", Some(&args), dir.path(), 40);
582-
assert!(rows.is_some(), "cat image.png should preview");
583-
}
584-
585-
#[test]
586-
fn viewed_image_lines_skip_non_image_bash() {
587-
let dir = tempfile::tempdir().expect("tempdir");
588-
let args = serde_json::json!({"command": "cat notes.txt"});
589-
assert!(super::rows::viewed_image_lines("bash", Some(&args), dir.path(), 40).is_none());
590-
let args = serde_json::json!({"command": "cat x.png | head"});
591-
assert!(super::rows::viewed_image_lines("bash", Some(&args), dir.path(), 40).is_none());
592-
}

‎crates/gray/src/composer/transcript/rows.rs‎

Lines changed: 1 addition & 107 deletions
Original file line numberDiff line numberDiff line change
@@ -362,11 +362,7 @@ pub(crate) fn thinking_replay_lines(text: &str) -> Vec<Line<'static>> {
362362
.collect()
363363
}
364364

365-
pub(crate) fn format_user_prompt_lines(
366-
text: &str,
367-
attached: &[std::path::PathBuf],
368-
width: usize,
369-
) -> Vec<Line<'static>> {
365+
pub(crate) fn format_user_prompt_lines(text: &str, width: usize) -> Vec<Line<'static>> {
370366
let sanitized = crate::tui::sanitize_user_text(text);
371367
let prompt_color = crate::theme::theme().text_soft;
372368
let text_primary = crate::theme::theme().text_body;
@@ -420,109 +416,7 @@ pub(crate) fn format_user_prompt_lines(
420416
}
421417
}
422418
}
423-
let mut previews = false;
424-
for path in attached {
425-
if let Some(rows) = image_preview_lines(path, max_w) {
426-
if !previews && !lines.is_empty() {
427-
lines.push(margin_row());
428-
}
429-
previews = true;
430-
lines.extend(rows);
431-
}
432-
}
433419
lines.insert(0, margin_row());
434420
lines.push(margin_row());
435421
lines
436422
}
437-
438-
pub(crate) fn viewed_image_lines(
439-
name: &str,
440-
args: Option<&serde_json::Value>,
441-
cwd: &std::path::Path,
442-
max_w: usize,
443-
) -> Option<Vec<Line<'static>>> {
444-
let args = args?;
445-
const MAX_PREVIEWS: usize = 4;
446-
let collected: Vec<String> = if matches!(name, "view" | "read") {
447-
args.get("path")
448-
.and_then(|v| v.as_str())
449-
.into_iter()
450-
.chain(
451-
args.get("paths")
452-
.and_then(|v| v.as_array())
453-
.into_iter()
454-
.flatten()
455-
.filter_map(|v| v.as_str()),
456-
)
457-
.map(String::from)
458-
.collect()
459-
} else if matches!(name, "bash" | "shell") {
460-
args.get("command")
461-
.and_then(|v| v.as_str())
462-
.and_then(gray_tools::shell::label::read_only)
463-
.filter(|r| r.look == gray_tools::shell::label::Look::Viewed)
464-
.map(|r| r.targets)
465-
.unwrap_or_default()
466-
} else {
467-
return None;
468-
};
469-
let raw_paths = collected.into_iter().take(MAX_PREVIEWS);
470-
let mut lines = Vec::new();
471-
for raw in raw_paths {
472-
let path = std::path::Path::new(&raw);
473-
let path = if path.is_absolute() {
474-
path.to_path_buf()
475-
} else {
476-
cwd.join(path)
477-
};
478-
let is_image = gray_tools::images::is_image_extension(&path);
479-
if !is_image {
480-
continue;
481-
}
482-
if let Some(rows) = image_preview_lines(&path, max_w) {
483-
if !lines.is_empty() {
484-
lines.push(Line::default());
485-
}
486-
lines.extend(rows);
487-
}
488-
}
489-
(!lines.is_empty()).then_some(lines)
490-
}
491-
492-
fn image_preview_lines(path: &std::path::Path, max_w: usize) -> Option<Vec<Line<'static>>> {
493-
if let Some(rows) = crate::qol::kitty::preview_lines(path, max_w, GUTTER + 2) {
494-
return Some(rows);
495-
}
496-
let img = image::open(path).ok()?;
497-
let cols = max_w.clamp(8, 48) as u32;
498-
let thumb = img.thumbnail(cols, 48).to_rgba8();
499-
let (tw, th) = thumb.dimensions();
500-
if tw == 0 || th == 0 {
501-
return None;
502-
}
503-
let surface = crate::theme::theme().surface_bg;
504-
let to_color = |px: &image::Rgba<u8>| -> ratatui::style::Color {
505-
if px[3] < 128 {
506-
surface
507-
} else {
508-
ratatui::style::Color::Rgb(px[0], px[1], px[2])
509-
}
510-
};
511-
let hang = " ".repeat(GUTTER + 2);
512-
let mut lines = Vec::new();
513-
let mut y = 0u32;
514-
while y < th {
515-
let mut spans = vec![Span::styled(hang.clone(), Style::default().bg(surface))];
516-
for x in 0..tw {
517-
let top = thumb.get_pixel(x, y);
518-
let bottom = thumb.get_pixel(x, (y + 1).min(th - 1));
519-
spans.push(Span::styled(
520-
"\u{2580}",
521-
Style::default().fg(to_color(top)).bg(to_color(bottom)),
522-
));
523-
}
524-
lines.push(Line::from(spans));
525-
y += 2;
526-
}
527-
Some(lines)
528-
}

0 commit comments

Comments
 (0)