Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
38 changes: 24 additions & 14 deletions pk-cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -299,17 +299,16 @@ async fn main() -> Result<()> {
tags,
} = &cli.command
{
return run_context(
let request = ContextRequest {
query,
scopes,
*limit,
*max_candidates,
*max_bytes,
*format,
limit: *limit,
max_candidates: *max_candidates,
max_bytes: *max_bytes,
format: *format,
tags,
cli.kb_dir.as_deref(),
)
.await;
};
return run_context(request, cli.kb_dir.as_deref()).await;
}
if let Cmd::Snapshot { scopes } = &cli.command {
return run_snapshot(scopes, cli.kb_dir.as_deref()).await;
Expand Down Expand Up @@ -699,16 +698,27 @@ struct ContextItem {
score: f32,
}

async fn run_context(
query: &str,
requested_scopes: &[ContextScope],
/// Options for a single `pk context` invocation, borrowed from the parsed CLI.
struct ContextRequest<'a> {
query: &'a str,
scopes: &'a [ContextScope],
limit: usize,
max_candidates: usize,
max_bytes: usize,
format: ContextFormat,
required_tags: &[String],
explicit_project_kb: Option<&str>,
) -> Result<()> {
tags: &'a [String],
}

async fn run_context(request: ContextRequest<'_>, explicit_project_kb: Option<&str>) -> Result<()> {
let ContextRequest {
query,
scopes: requested_scopes,
limit,
max_candidates,
max_bytes,
format,
tags: required_tags,
} = request;
let scopes = if requested_scopes.is_empty() {
vec![
ContextScope::Project,
Expand Down
3 changes: 3 additions & 0 deletions pk-learning-worker/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1675,6 +1675,9 @@ mod tests {
captured_at: "2026-08-03T00:00:00Z".to_owned(),
payload_digest: "fixture".to_owned(),
scope: LearningScope::Project,
project_id: None,
team_id: None,
role_id: None,
attempt: 0,
}
}
Expand Down
Loading