chore(core): checkpoint local changes

This commit is contained in:
James Peter
2025-12-03 19:12:11 +10:00
parent fe7de503d7
commit bab6373f68
4 changed files with 25 additions and 24 deletions
+2 -2
View File
@@ -22,10 +22,10 @@ Before linting a file for the first time on a file you MUST do a dry-run first.
Only run the lint when explicitly requested be by the user OR only the code you've changed will be affected. This helps keep changes surgical.
## Code Bridge (events from apps -> Code)
- Trace/debug running apps in realtime. Install in apps via npm: `@just-every/code-bridge`.
- Local Sentry-style telemetry plus two-way control: error/console streaming, pageviews/screenshots, and control commands. Install in apps via npm: `@just-every/code-bridge`.
- Host writes `.code/code-bridge.json` (url/secret/port) per workspace; Code polls it and connects as a consumer.
- Bridge clients send console/errors/screenshot/pageview/control events.
- Adjust subscriptions with the internal tool `code_bridge_subscription` (actions: show|set|clear; params: levels[], capabilities[], llm_filter; `persist=true|false`).
- Adjust subscriptions with the internal tool `code_bridge` (actions: show|set|clear; params: levels[], capabilities[], llm_filter; `persist=true|false`). Examples: `{"action":"show"}`, `{"action":"set","levels":["trace"],"capabilities":["screenshot","pageview"],"llm_filter":"minimal"}`, `{"action":"clear","persist":true}`.
- Session override: defaults to session-only (doesn’t affect other Code sessions).
- Workspace default: set `persist=true` to write `.code/code-bridge.subscription.json` so other sessions inherit it.
- Defaults: errors-only; use levels `trace` + capabilities `screenshot,pageview` to capture more.
+4 -4
View File
@@ -728,13 +728,13 @@ async fn connect_and_listen(meta: BridgeMeta, session: Arc<Session>, cwd: &Path)
session.record_bridge_event(announce).await;
if !BRIDGE_HINT_EMITTED.swap(true, Ordering::SeqCst) && workspace_has_code_bridge(cwd) {
session
.record_bridge_event(
"Tip: adjust Code Bridge subscription with the internal tool `code_bridge_subscription` (show|set|clear; session-only by default; use persist=true to update .code/code-bridge.subscription.json for workspace defaults)."
session
.record_bridge_event(
"Code Bridge is a local, real-time debug stream (errors/console like Sentry, plus pageviews/screenshots and a control channel). Use the `code_bridge` tool to show|set|clear your subscription; examples: {\"action\":\"show\"}, {\"action\":\"set\",\"levels\":[\"trace\"],\"capabilities\":[\"screenshot\",\"pageview\"]}, {\"action\":\"clear\",\"persist\":true}. Set persist=true to write .code/code-bridge.subscription.json for workspace defaults."
.to_string(),
)
.await;
}
}
let (batch_tx, mut batch_rx) = tokio::sync::mpsc::unbounded_channel::<BridgeBatchEvent>();
let session_for_batch = Arc::clone(&session);
+5 -5
View File
@@ -6673,7 +6673,7 @@ async fn handle_function_call(
"web_fetch" => handle_web_fetch(sess, &ctx, arguments).await,
"wait" => handle_wait(sess, &ctx, arguments).await,
"kill" => handle_kill(sess, &ctx, arguments).await,
"code_bridge_subscription" => handle_bridge_subscription(sess, &ctx, arguments).await,
"code_bridge" | "code_bridge_subscription" => handle_code_bridge(sess, &ctx, arguments).await,
_ => {
match sess.mcp_connection_manager.parse_tool_name(&name) {
Some((server, tool_name)) => {
@@ -6751,15 +6751,15 @@ fn norm_vec(vals: &Option<Vec<String>>) -> Option<Vec<String>> {
})
}
async fn handle_bridge_subscription(
async fn handle_code_bridge(
sess: &Session,
ctx: &ToolCallCtx,
arguments: String,
) -> ResponseInputItem {
handle_bridge_subscription_with_cwd(sess.get_cwd(), ctx, arguments).await
handle_code_bridge_with_cwd(sess.get_cwd(), ctx, arguments).await
}
async fn handle_bridge_subscription_with_cwd(
async fn handle_code_bridge_with_cwd(
cwd: &Path,
ctx: &ToolCallCtx,
arguments: String,
@@ -6877,7 +6877,7 @@ mod bridge_tool_tests {
let ctx = ToolCallCtx::new("sub".into(), "call".into(), None, None);
tokio::runtime::Runtime::new()
.unwrap()
.block_on(async { handle_bridge_subscription_with_cwd(cwd, &ctx, args.to_string()).await })
.block_on(async { handle_code_bridge_with_cwd(cwd, &ctx, args.to_string()).await })
}
#[test]
+14 -13
View File
@@ -709,7 +709,7 @@ pub fn get_openai_tools(
// Add general wait tool for background completions
tools.push(create_wait_tool());
tools.push(create_kill_tool());
tools.push(create_bridge_subscription_tool());
tools.push(create_bridge_tool());
if config.web_search_request {
let tool = match &config.web_search_allowed_domains {
@@ -799,7 +799,7 @@ pub fn create_kill_tool() -> OpenAiTool {
})
}
pub fn create_bridge_subscription_tool() -> OpenAiTool {
pub fn create_bridge_tool() -> OpenAiTool {
let mut properties = BTreeMap::new();
properties.insert(
@@ -852,8 +852,9 @@ pub fn create_bridge_subscription_tool() -> OpenAiTool {
);
OpenAiTool::Function(ResponsesApiTool {
name: "code_bridge_subscription".to_string(),
description: "Show/set/clear this session's Code Bridge subscription; optional persist to workspace file.".to_string(),
name: "code_bridge".to_string(),
description:
"Code Bridge = local Sentry-style event stream plus two-way control (errors/console/pageviews/screenshots/control). Manage the subscription (show|set|clear). Examples: {\"action\":\"show\"}, {\"action\":\"set\",\"levels\":[\"trace\"],\"capabilities\":[\"screenshot\",\"pageview\"]}, {\"action\":\"clear\",\"persist\":true}.".to_string(),
strict: false,
parameters: JsonSchema::Object {
properties,
@@ -935,7 +936,7 @@ mod tests {
"agent",
"wait",
"kill",
"code_bridge_subscription",
"code_bridge",
"web_search",
],
);
@@ -967,7 +968,7 @@ mod tests {
"agent",
"wait",
"kill",
"code_bridge_subscription",
"code_bridge",
"web_search",
],
);
@@ -998,7 +999,7 @@ mod tests {
"agent",
"wait",
"kill",
"code_bridge_subscription",
"code_bridge",
"web_search",
],
);
@@ -1066,7 +1067,7 @@ mod tests {
"agent",
"wait",
"kill",
"code_bridge_subscription",
"code_bridge",
"web_search",
"test_server/do_something_cool",
],
@@ -1187,7 +1188,7 @@ mod tests {
"agent",
"wait",
"kill",
"code_bridge_subscription",
"code_bridge",
"web_search",
"test_server/do_something_cool",
],
@@ -1310,7 +1311,7 @@ mod tests {
"agent",
"wait",
"kill",
"code_bridge_subscription",
"code_bridge",
"web_search",
"dash/search",
],
@@ -1383,7 +1384,7 @@ mod tests {
"agent",
"wait",
"kill",
"code_bridge_subscription",
"code_bridge",
"web_search",
"dash/paginate",
],
@@ -1457,7 +1458,7 @@ mod tests {
"agent",
"wait",
"kill",
"code_bridge_subscription",
"code_bridge",
"web_search",
"dash/tags",
],
@@ -1529,7 +1530,7 @@ mod tests {
"agent",
"wait",
"kill",
"code_bridge_subscription",
"code_bridge",
"web_search",
"dash/value",
],