Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
14 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,48 @@ jobs:
target/${{ matrix.target }}/release/cyber-sandbox-exec${{ matrix.exe }}
if-no-files-found: error

# `code-intelligence` → Repository map symbol extraction: the bundled grammars may not
# grow the stripped release binary by more than 12 MiB over the base branch.
binary-size:
name: Binary size
needs: changes
if: github.event_name == 'pull_request' && needs.changes.outputs.code == 'true'
runs-on: ubuntu-latest
steps:
- name: Free disk space
run: sudo rm -rf /usr/share/dotnet /usr/local/lib/android /opt/ghc /opt/hostedtoolcache/CodeQL
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: dtolnay/rust-toolchain@b725eda525362e7cf34af9a7243cac1e3f01a7ec # pinned commit
with:
toolchain: 1.99.1
- uses: Swatinem/rust-cache@v2
with:
key: binary-size
- name: Compare the stripped release binary with the base branch
env:
BASE: ${{ github.event.pull_request.base.sha }}
LIMIT_MIB: '12'
run: |
set -euo pipefail
git worktree add ../base "$BASE"
export CARGO_TARGET_DIR="$PWD/target"
(cd ../base && cargo build --locked --release -p cyber-cli --bin cyber)
strip -o base-cyber target/release/cyber
# Workspace crates are fingerprinted by mtime, not path: make the head's newer.
find crates -type f -exec touch {} +
cargo build --locked --release -p cyber-cli --bin cyber
strip -o head-cyber target/release/cyber
base=$(stat -c %s base-cyber)
head=$(stat -c %s head-cyber)
growth=$((head - base))
echo "base ${base} bytes, head ${head} bytes, growth ${growth} bytes"
if [ "$growth" -gt $((LIMIT_MIB * 1024 * 1024)) ]; then
echo "::error::the stripped release binary grew by more than ${LIMIT_MIB} MiB"
exit 1
fi

dashboard:
name: Web dashboard
needs: changes
Expand Down
77 changes: 77 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions NOTICE
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,17 @@ Copyright 2026 The Cyber Code Authors
This product is licensed under the Apache License, Version 2.0 (see LICENSE).
Third-party dependencies keep their own licenses; see each crate's and npm
package's license metadata.

The repository map's tag queries (crates/cyber-tools/src/repo_map/queries/*.scm)
are adapted from the tags.scm queries of these tree-sitter grammars, all under
the MIT License; the grammars themselves are linked as crates:
tree-sitter-rust Copyright (c) 2017 Maxim Sokolov
tree-sitter-python Copyright (c) 2016 Max Brunsfeld
tree-sitter-javascript Copyright (c) 2014 Max Brunsfeld
tree-sitter-typescript Copyright (c) Max Brunsfeld and the tree-sitter authors
tree-sitter-go Copyright (c) 2014 Max Brunsfeld
tree-sitter-c Copyright (c) 2014 Max Brunsfeld
tree-sitter-cpp Copyright (c) Max Brunsfeld and the tree-sitter authors
tree-sitter-java Copyright (c) Ayman Nadeem and the tree-sitter authors
The Bash and Solidity queries are written for Cyber Code. tree-sitter-solidity
is Copyright (c) 2020 Joran Honig (MIT).
2 changes: 1 addition & 1 deletion ROADMAP.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ The [current inventory](docs/implementation/spec-doc-reconciliation.md) contains

**Untrusted-content defense (`untrusted-content`, `permissions-modes`, `system-context`, P1): Status: implemented** (change [`add-untrusted-content-defense`](openspec/changes/archive/2026-11-08-add-untrusted-content-defense/proposal.md)). It carries the `workspace-trust` provenance rule through every tool that returns third-party content. `webfetch`, `websearch`, MCP tool results, browser pages and MCP resources are returned in one escape-safe `<untrusted_content>` frame that replaces the MCP-resource frame. Hidden characters become visible markers, and a deterministic detector flags instruction-like text with a notice in the TUI, `exec` and the dashboard, without dropping content. After a flagged result, risky actions (network egress, writes outside the Location, classifier-allowed commands, secret reads) ask until the next user prompt, or are denied with no user attached; `bypass` shows the notice or refuses when configured. The base prompts cover the frame (version 3), and a labeled fixture set gates recall and false positives, with scripted end-to-end scenarios for secret reads, permission widening and provider redirection. The TUI and dashboard state each notice's consequence from the Location's effective `taint`/`bypass` settings (task 5.3). What remains: acceptance by hand on the real binary.

**Proposed repository map (`code-intelligence`, `system-context`, `provider-catalog`, P1):** [`add-repository-map`](openspec/changes/add-repository-map/proposal.md) adds a ranked overview of the repository's files and symbols. Symbols come from tree-sitter tag queries, ranked by PageRank over references and personalised by the Session's recent files. The map is fitted to a token budget set by the model profile, offered as a read-only `repo_map` tool, and optionally included as an Epoch-pinned `core/repo-map` Context Source in trusted checkouts. Pinning means it never breaks the cached prompt prefix. The index is a local cache shared across worktrees; inspection is through `cyber lsp map` and `/map`. Semantic code search is deferred. Specification only; the budget field depends on archiving `improve-model-protocol-fidelity`.
**Repository map (`code-intelligence`, `system-context`, `provider-catalog`, P1): Status: implemented locally** (change [`add-repository-map`](openspec/changes/add-repository-map/proposal.md)). A ranked overview of the repository's files and symbols: tree-sitter tag queries for eleven bundled languages, personalized PageRank over references (focus paths and symbols, the Session's recent files), rendered to a token budget from the model profile. It is offered as the read-only `repo_map` tool and, in trusted checkouts, as the Epoch-pinned `core/repo-map` Context Source, which never breaks the cached prompt prefix. The index is a local SQLite cache shared across worktrees; inspection is through `cyber lsp map`, `GET /api/v1/lsp/map` and `/map`. Remaining: the with/without-map eval on a hosted and a local model (which decides the `repo_map.context` default), the 50 000-file benchmark record, and archiving after `improve-model-protocol-fidelity`. Semantic code search is deferred.

**Native Gemini adapter (`provider-catalog`, `provider-credentials`, P1): Status: in progress, experimental.** [`add-gemini-adapter`](openspec/changes/add-gemini-adapter/proposal.md) is the Gemini part of Additional native provider adapters. A `gemini` protocol, experimental (`features.gemini`) until its live coding baseline is published, streams `streamGenerateContent` with an AI Studio key (`GEMINI_API_KEY`, `GOOGLE_GENERATIVE_AI_API_KEY`, `GOOGLE_API_KEY`; pinned endpoint), so models.dev's `google` provider becomes available, with the newest Gemini Pro-tier model as the default when only a Google key is set. Thought signatures are returned exactly where they arrived, including the first of parallel calls and an empty final part, and foreign calls in the current turn are sent as text. Per-minute 429s wait the server's `RetryInfo` delay (cap 240 s; longer delays fail at once interactively and are waited in full by unattended runs); daily quotas, spend caps and 402 prepaid balance stop at once. It also covers `thinkingLevel`/`thinkingBudget`, safety and finish reasons, cache-read and thinking usage, and a 600 s idle window. Vertex AI, explicit caching, the Interactions API and Google subscription login stay out of scope; subscription login remains refused. Implemented and tested against hand-written protocol fixtures ([guide](docs/local-core-guide.md#gemini-api)); remaining: `cyber providers login google` with a stored key (waits for stored API-key connections), the live checks with a key, and the live coding baseline that moves `gemini` to stable.

Expand Down
8 changes: 8 additions & 0 deletions crates/cyber-app/src/host.rs
Original file line number Diff line number Diff line change
Expand Up @@ -657,6 +657,14 @@ impl ToolHost for AppHost {
})
}

fn pinned_context_observations<'a>(
&'a self,
turn: &'a TurnContext,
profile: &'a cyber_llm::catalog::ModelProfile,
) -> BoxFuture<'a, BTreeMap<String, cyber_server::runtime::ContextObservation>> {
Box::pin(self.builtin.pinned_context_observations_for(turn, profile))
}

fn shell_owned(
&self,
directory: &str,
Expand Down
1 change: 1 addition & 0 deletions crates/cyber-app/src/host/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ async fn application(root: &std::path::Path) -> App {
fn invocation(turn: &TurnContext) -> Invocation {
Invocation {
tool_output: Default::default(),
repo_map: Default::default(),
registration: None,
session_id: turn.session_id.clone(),
directory: turn.directory.clone(),
Expand Down
19 changes: 18 additions & 1 deletion crates/cyber-app/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ use cyber_tools::{BuiltinHost, ConfigFn, HookConfigFn, HostOptions};
use serde_json::{Value, json};

pub use cyber_tools::IsolationOptions;
pub use registered_status::registered_lsp_status;
pub use registered_status::{
registered_lsp_status, registered_repo_map, registered_repo_map_rebuild,
};
pub use registration::{
ClientBuild, Probe, Registration, ServerClientInfo, ServiceNotice, health, probe,
probe_registration, read_registration, registered_health, registration_path, start_service,
Expand Down Expand Up @@ -303,6 +305,20 @@ impl App {
.clone()
.unwrap_or_else(|| Arc::new(cyber_tools::PolicyFetcher));
host.attach_remote_skills(opts.paths.cache.join("skills"), fetcher)?;
// `code-intelligence` → Repository map index storage: `<cache>/repo-map/index.db`.
// Builds report counts only, to the telemetry exporter, once the runtime exists.
let build_runtime: Arc<std::sync::OnceLock<cyber_server::runtime::WeakRuntime>> =
Arc::default();
let observed = Arc::clone(&build_runtime);
host.attach_repo_maps(Arc::new(
cyber_tools::repo_map::RepoMaps::new(opts.paths.cache.clone()).with_observer(Arc::new(
move |report| {
if let Some(runtime) = observed.get().and_then(|weak| weak.upgrade()) {
runtime.publish_repo_map_build(report.telemetry());
}
},
)),
))?;
let lsp_options = cyber_tools::lsp::LaunchOptions {
checkout_claim: Some(host.lsp_checkout_claim()),
paths: opts.paths.clone(),
Expand Down Expand Up @@ -379,6 +395,7 @@ impl App {
.map_err(|error| error.to_string())?;
}
host.attach(runtime.clone());
let _ = build_runtime.set(runtime.downgrade());
if opts.snapshots {
// Owner-confirmed construction discards whose unlink failed are retried forever.
cyber_server::runtime::construction_discard::spawn_retry(runtime.clone());
Expand Down
103 changes: 96 additions & 7 deletions crates/cyber-app/src/registered_status.rs
Original file line number Diff line number Diff line change
@@ -1,18 +1,26 @@
//! Read-only observation of an existing registered server, without startup or database access.
use cyber_core::paths::Paths;
use cyber_server::http::LspStatus;
use cyber_server::http::{LspStatus, RepoMapIndex, RepoMapRequest, RepoMapView};
use serde_json::Value;
use std::{
path::{Component, Path},
time::Duration,
};

const MAX_RESPONSE: usize = 1024 * 1024;
/// A map waits up to 10 s for a running build.
const MAP_TIMEOUT: Duration = Duration::from_secs(30);

pub async fn registered_lsp_status(
/// One authenticated call to the registered server's `path` for `location`: its
/// response body and the registration it was made against, or `None` without a server.
async fn registered_call(
paths: &Paths,
location: &Path,
) -> Result<Option<Vec<LspStatus>>, String> {
method: reqwest::Method,
path: &str,
query: &[(&str, String)],
timeout: Duration,
) -> Result<Option<(Value, crate::Registration)>, String> {
let Some(registration) = crate::read_registration(paths) else {
if crate::registration_path(paths).exists() {
return Err("Existing server registration is invalid".into());
Expand All @@ -28,7 +36,7 @@ pub async fn registered_lsp_status(
return Err("Existing server credentials are empty".into());
}
let builder = reqwest::Client::builder()
.timeout(Duration::from_secs(5))
.timeout(timeout)
.no_proxy()
.redirect(reqwest::redirect::Policy::none());
let (builder, url) = if registration.url.is_empty() {
Expand Down Expand Up @@ -59,13 +67,18 @@ pub async fn registered_lsp_status(
{
return Err("Existing server listener is invalid".into());
}
url.set_path("/api/v1/lsp");
url.set_path(path);
let mut pairs = vec![(
"location[directory]",
location.to_string_lossy().into_owned(),
)];
pairs.extend(query.iter().cloned());
let mut response = builder
.build()
.map_err(|_| "Cannot create status transport")?
.get(url)
.request(method, url)
.basic_auth("cyber", Some(password.trim()))
.query(&[("location[directory]", location.to_string_lossy().as_ref())])
.query(&pairs)
.send()
.await
.map_err(|_| "Existing server status is unavailable")?;
Expand All @@ -91,6 +104,28 @@ pub async fn registered_lsp_status(
if body["location"]["directory"].as_str() != location.to_str() {
return Err("Existing server status returned another Location".into());
}
Ok(Some((body, registration)))
}

pub async fn registered_lsp_status(
paths: &Paths,
location: &Path,
) -> Result<Option<Vec<LspStatus>>, String> {
let Some((body, registration)) = registered_call(
paths,
location,
reqwest::Method::GET,
"/api/v1/lsp",
&[],
Duration::from_secs(5),
)
.await?
else {
return Ok(None);
};
let location = location
.canonicalize()
.map_err(|_| "Status Location is unavailable")?;
let statuses: Vec<LspStatus> = serde_json::from_value(body["data"].clone())
.map_err(|_| "Existing server status entries are invalid")?;
if statuses.iter().any(|status| {
Expand All @@ -109,3 +144,57 @@ pub async fn registered_lsp_status(
}
Ok(Some(statuses))
}

/// `GET /api/v1/lsp/map` on the registered server, or `None` without one.
pub async fn registered_repo_map(
paths: &Paths,
location: &Path,
request: &RepoMapRequest,
) -> Result<Option<RepoMapView>, String> {
let mut query: Vec<(&str, String)> = Vec::new();
if let Some(path) = &request.path {
query.push(("path", path.clone()));
}
query.extend(request.focus.iter().map(|f| ("focus", f.clone())));
query.extend(request.symbol.iter().map(|s| ("symbol", s.clone())));
if let Some(tokens) = request.tokens {
query.push(("tokens", tokens.to_string()));
}
let Some((body, _)) = registered_call(
paths,
location,
reqwest::Method::GET,
"/api/v1/lsp/map",
&query,
MAP_TIMEOUT,
)
.await?
else {
return Ok(None);
};
serde_json::from_value(body["data"].clone())
.map(Some)
.map_err(|_| "Existing server map is malformed".into())
}

/// `POST /api/v1/lsp/map/rebuild` on the registered server, or `None` without one.
pub async fn registered_repo_map_rebuild(
paths: &Paths,
location: &Path,
) -> Result<Option<RepoMapIndex>, String> {
let Some((body, _)) = registered_call(
paths,
location,
reqwest::Method::POST,
"/api/v1/lsp/map/rebuild",
&[],
MAP_TIMEOUT,
)
.await?
else {
return Ok(None);
};
serde_json::from_value(body["data"].clone())
.map(Some)
.map_err(|_| "Existing server map status is malformed".into())
}
Loading
Loading