Skip to content

Commit 07d2ce6

Browse files
thomaspblockWrench
authored andcommitted
feat(projects): unify navigation and reviewed channel requests
Open project homes consistently from channel and project routes, preserve file/work-item deep links, and let agents request owner-reviewed project channels. Signed-off-by: Thomas Petersen <[email protected]> Co-authored-by: Thomas Petersen <[email protected]>
1 parent 7d6c4ab commit 07d2ce6

42 files changed

Lines changed: 1550 additions & 243 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎crates/buzz-acp/src/base_prompt.md‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ The `buzz` CLI is your primary interface. Auth env vars: `BUZZ_RELAY_URL`, `BUZZ
2323
| `buzz feed` | `get` |
2424
| `buzz social` | `publish`, `notes` |
2525
| `buzz repos` | `create`, `get`, `list` |
26-
| `buzz projects` | `create`, `get`, `list`, `add-repo` |
26+
| `buzz projects` | `create`, `get`, `list`, `add-repo`, `add-channel` |
2727
| `buzz issues` | `create`, `get`, `list`, `status`, `assign` |
2828
| `buzz pr` | `open`, `update`, `get`, `list`, `status` |
2929
| `buzz upload` | `file` |
@@ -39,6 +39,7 @@ A project is a named grouping (`kind:30621`) with a home channel. Creating a sec
3939
- If you are in a project's home channel, or a project with that name/slug already exists, do **not** run `buzz projects create`. `[Context]` includes a Project block when this channel is a project home — tasks, repositories, and files you create belong to that project.
4040
- To add a codebase: `buzz repos create --id <id> --name "…" --channel <current-channel-uuid>`. `mkdir` in `REPOS/` is not a Buzz repository.
4141
- To add tasks: `buzz issues create --channel <current-channel-uuid> --subject "…" --content "…"`. That uses this project's repository and creates one bound to the channel if none exists. `--repo-owner` / `--repo-id` remain valid once a repository exists. Session todos and markdown plans do not appear on the project.
42+
- To add another channel to this project: `buzz projects add-channel --home-channel <current-channel-uuid> --name "…" [--template "…"]`. This opens an owner-reviewed request in Buzz Desktop and uses the project-aware channel primitive after approval. Do **not** use `buzz channels create` for a channel that should belong to the current project, and do not claim the channel exists until the owner approves it.
4243

4344
`buzz pr open`, `buzz issues create`, `buzz repos create`, and `buzz projects create` return a `link` field (a `buzz://` deep link). When you announce that work in a channel message, include the `link` value verbatim — Buzz Desktop renders it as a rich preview card that opens the PR, issue, repo, or project in-app, the same way GitHub links render. Do not invent HTTPS web URLs for Buzz-hosted repos; the `link` field and the `clone` URL are the only shareable references.
4445

‎crates/buzz-cli/src/agent_management.rs‎

Lines changed: 103 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ use serde::Serialize;
66

77
use crate::error::CliError;
88

9-
const REQUEST_KIND: &str = "agent_management_request";
9+
const AGENT_REQUEST_KIND: &str = "agent_management_request";
10+
const PROJECT_CHANNEL_REQUEST_KIND: &str = "project_channel_request";
1011
const MAX_NAME_CHARS: usize = 120;
1112
const MAX_PROMPT_CHARS: usize = 20_000;
1213

@@ -37,6 +38,20 @@ pub struct UpdateAgentDraft {
3738
pub respond_to: Option<String>,
3839
}
3940

41+
#[derive(Debug, Clone, Serialize)]
42+
#[serde(rename_all = "camelCase")]
43+
pub struct CreateProjectChannelDraft {
44+
pub home_channel_id: String,
45+
pub name: String,
46+
#[serde(skip_serializing_if = "Option::is_none")]
47+
pub description: Option<String>,
48+
pub visibility: String,
49+
#[serde(skip_serializing_if = "Option::is_none")]
50+
pub ttl_seconds: Option<u64>,
51+
#[serde(skip_serializing_if = "Option::is_none")]
52+
pub template_name: Option<String>,
53+
}
54+
4055
#[derive(Debug, Serialize)]
4156
#[serde(rename_all = "camelCase")]
4257
struct ManagementRequest<T> {
@@ -88,20 +103,21 @@ fn build<T: Serialize>(
88103
keys: &Keys,
89104
owner: &PublicKey,
90105
channel_id: String,
106+
request_kind: &'static str,
91107
action: &'static str,
92108
request: T,
93109
) -> Result<BuiltDraftRequest, CliError> {
94110
let request_id = uuid::Uuid::new_v4().to_string();
95111
let payload = ObserverEvent {
96112
seq: 0,
97113
timestamp: chrono::Utc::now().to_rfc3339(),
98-
kind: REQUEST_KIND,
114+
kind: request_kind,
99115
agent_index: None,
100116
channel_id: Some(channel_id),
101117
session_id: None,
102118
turn_id: None,
103119
payload: ManagementRequest {
104-
request_type: REQUEST_KIND,
120+
request_type: request_kind,
105121
action,
106122
request_id: request_id.clone(),
107123
request,
@@ -138,7 +154,14 @@ pub fn build_create(
138154
display_name: required(draft.display_name, "display name", MAX_NAME_CHARS)?,
139155
system_prompt: required(draft.system_prompt, "system prompt", MAX_PROMPT_CHARS)?,
140156
};
141-
build(keys, owner, channel_id, "create", request)
157+
build(
158+
keys,
159+
owner,
160+
channel_id,
161+
AGENT_REQUEST_KIND,
162+
"create",
163+
request,
164+
)
142165
}
143166

144167
pub fn build_update(
@@ -182,7 +205,50 @@ pub fn build_update(
182205
"include at least one field to update".into(),
183206
));
184207
}
185-
build(keys, owner, channel_id, "update", request)
208+
build(
209+
keys,
210+
owner,
211+
channel_id,
212+
AGENT_REQUEST_KIND,
213+
"update",
214+
request,
215+
)
216+
}
217+
218+
pub fn build_project_channel(
219+
keys: &Keys,
220+
owner: &PublicKey,
221+
draft: CreateProjectChannelDraft,
222+
) -> Result<BuiltDraftRequest, CliError> {
223+
let home_channel_id = required(draft.home_channel_id, "home channel", 128)?;
224+
uuid::Uuid::parse_str(&home_channel_id)
225+
.map_err(|_| CliError::Usage(format!("invalid channel UUID: {home_channel_id}")))?;
226+
let visibility = required(draft.visibility, "visibility", 16)?;
227+
if visibility != "open" && visibility != "private" {
228+
return Err(CliError::Usage("visibility must be open or private".into()));
229+
}
230+
if draft.ttl_seconds == Some(0) {
231+
return Err(CliError::Usage("ttl must be greater than zero".into()));
232+
}
233+
let request = CreateProjectChannelDraft {
234+
home_channel_id: home_channel_id.clone(),
235+
name: required(draft.name, "name", MAX_NAME_CHARS)?,
236+
description: draft
237+
.description
238+
.map(|value| required(value, "description", 2_048))
239+
.transpose()?,
240+
visibility,
241+
ttl_seconds: draft.ttl_seconds,
242+
template_name: optional(draft.template_name, "template")?,
243+
};
244+
build(
245+
keys,
246+
owner,
247+
home_channel_id,
248+
PROJECT_CHANNEL_REQUEST_KIND,
249+
"create",
250+
request,
251+
)
186252
}
187253

188254
#[cfg(test)]
@@ -228,9 +294,9 @@ mod tests {
228294
.any(|tag| tag.first().map(String::as_str) == Some("h")));
229295

230296
let payload: serde_json::Value = decrypt_observer_payload(&owner, &built.event).unwrap();
231-
assert_eq!(payload["kind"], REQUEST_KIND);
297+
assert_eq!(payload["kind"], AGENT_REQUEST_KIND);
232298
assert_eq!(payload["channelId"], CHANNEL);
233-
assert_eq!(payload["payload"]["type"], REQUEST_KIND);
299+
assert_eq!(payload["payload"]["type"], AGENT_REQUEST_KIND);
234300
assert_eq!(payload["payload"]["action"], "create");
235301
assert_eq!(
236302
payload["payload"]["request"]["displayName"],
@@ -274,4 +340,34 @@ mod tests {
274340
.unwrap_err();
275341
assert!(error.to_string().contains("invalid channel UUID"));
276342
}
343+
344+
#[test]
345+
fn project_channel_request_is_owner_encrypted() {
346+
let agent = Keys::generate();
347+
let owner = Keys::generate();
348+
let built = build_project_channel(
349+
&agent,
350+
&owner.public_key(),
351+
CreateProjectChannelDraft {
352+
home_channel_id: CHANNEL.into(),
353+
name: "release-planning".into(),
354+
description: Some("Coordinate the next release.".into()),
355+
visibility: "open".into(),
356+
ttl_seconds: None,
357+
template_name: Some("Release team".into()),
358+
},
359+
)
360+
.unwrap();
361+
362+
let payload: serde_json::Value = decrypt_observer_payload(&owner, &built.event).unwrap();
363+
assert_eq!(payload["kind"], PROJECT_CHANNEL_REQUEST_KIND);
364+
assert_eq!(payload["channelId"], CHANNEL);
365+
assert_eq!(payload["payload"]["type"], PROJECT_CHANNEL_REQUEST_KIND);
366+
assert_eq!(payload["payload"]["action"], "create");
367+
assert_eq!(payload["payload"]["request"]["homeChannelId"], CHANNEL);
368+
assert_eq!(
369+
payload["payload"]["request"]["templateName"],
370+
"Release team"
371+
);
372+
}
277373
}

‎crates/buzz-cli/src/commands/projects.rs‎

Lines changed: 64 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,58 @@ use buzz_sdk::{
2121
build_delete_addressable, build_project, build_project_with_tags, ProjectMemberCoord,
2222
PROJECT_D_MAX_LEN,
2323
};
24-
use nostr::{Event, EventBuilder, Tag, Timestamp};
24+
use nostr::{Event, EventBuilder, PublicKey, Tag, Timestamp};
2525

26+
use crate::agent_management::{build_project_channel, CreateProjectChannelDraft};
2627
use crate::client::BuzzClient;
2728
use crate::commands::parse_write_response;
2829
use crate::commands::project_channel::repo_id_from_project_slug;
2930
use crate::commands::repos::{build_create_announcement, fetch_own_repo_announcement};
3031
use crate::error::CliError;
3132

33+
async fn cmd_add_channel_draft(
34+
client: &BuzzClient,
35+
home_channel: String,
36+
name: String,
37+
description: Option<String>,
38+
visibility: String,
39+
ttl_seconds: Option<u64>,
40+
template_name: Option<String>,
41+
) -> Result<(), CliError> {
42+
let owner_hex = client
43+
.auth_tag_owner_hex()
44+
.ok_or_else(|| CliError::Auth("project channel requests require BUZZ_AUTH_TAG".into()))?;
45+
let owner = PublicKey::parse(&owner_hex)
46+
.map_err(|error| CliError::Auth(format!("invalid owner attestation: {error}")))?;
47+
let built = build_project_channel(
48+
client.keys(),
49+
&owner,
50+
CreateProjectChannelDraft {
51+
home_channel_id: home_channel,
52+
name,
53+
description,
54+
visibility,
55+
ttl_seconds,
56+
template_name,
57+
},
58+
)?;
59+
let response = client.publish_ephemeral_event(built.event).await?;
60+
let mut output: serde_json::Value = serde_json::from_str(&response)
61+
.map_err(|error| CliError::Other(format!("invalid relay response: {error}")))?;
62+
if let Some(object) = output.as_object_mut() {
63+
object.insert("request_id".into(), built.request_id.into());
64+
object.insert("action".into(), "add-channel".into());
65+
object.insert("saved".into(), false.into());
66+
object.insert(
67+
"message".into(),
68+
"Project channel draft sent to Buzz Desktop for owner review. The channel is not created until the owner approves it."
69+
.into(),
70+
);
71+
}
72+
println!("{output}");
73+
Ok(())
74+
}
75+
3276
// ── Buzz repo-ID grammar (bare --repo shorthand) ─────────────────────────────
3377

3478
/// Pattern for a Buzz-hosted repo identifier (bare `--repo` shorthand).
@@ -739,6 +783,25 @@ pub async fn dispatch(cmd: crate::ProjectsCmd, client: &BuzzClient) -> Result<()
739783
ProjectsCmd::Get { slug, owner } => cmd_get(client, &slug, owner.as_deref()).await,
740784
ProjectsCmd::List { owner, limit } => cmd_list(client, owner.as_deref(), limit).await,
741785
ProjectsCmd::AddRepo { slug, repo } => cmd_add_repo(client, &slug, &repo).await,
786+
ProjectsCmd::AddChannel {
787+
home_channel,
788+
name,
789+
description,
790+
visibility,
791+
ttl,
792+
template,
793+
} => {
794+
cmd_add_channel_draft(
795+
client,
796+
home_channel,
797+
name,
798+
description,
799+
visibility.to_string(),
800+
ttl,
801+
template,
802+
)
803+
.await
804+
}
742805
ProjectsCmd::RemoveRepo { slug, repo } => cmd_remove_repo(client, &slug, &repo).await,
743806
ProjectsCmd::Update {
744807
slug,

‎crates/buzz-cli/src/lib.rs‎

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1334,6 +1334,28 @@ pub enum ProjectsCmd {
13341334
#[arg(long = "repo", required = true)]
13351335
repo: Vec<String>,
13361336
},
1337+
/// Draft a project-linked channel for owner review in Buzz Desktop
1338+
#[command(name = "add-channel")]
1339+
AddChannel {
1340+
/// Project home channel UUID from the current ACP [Context]
1341+
#[arg(long)]
1342+
home_channel: String,
1343+
/// New channel name
1344+
#[arg(long)]
1345+
name: String,
1346+
/// Optional channel description
1347+
#[arg(long)]
1348+
description: Option<String>,
1349+
/// Channel visibility
1350+
#[arg(long, value_enum, default_value = "open")]
1351+
visibility: ChannelVisibility,
1352+
/// Optional temporary-channel lifetime in seconds
1353+
#[arg(long)]
1354+
ttl: Option<u64>,
1355+
/// Optional Desktop channel-template name
1356+
#[arg(long)]
1357+
template: Option<String>,
1358+
},
13371359
/// Remove one or more member repositories from a project
13381360
#[command(name = "remove-repo")]
13391361
RemoveRepo {
@@ -2375,6 +2397,7 @@ mod tests {
23752397
assert_eq!(
23762398
names(&cmd, "projects"),
23772399
vec![
2400+
"add-channel",
23782401
"add-repo",
23792402
"create",
23802403
"delete",
@@ -2421,7 +2444,7 @@ mod tests {
24212444
("pack", 2),
24222445
("patches", 4),
24232446
("pr", 5),
2424-
("projects", 7),
2447+
("projects", 8),
24252448
("reactions", 3),
24262449
("repos", 5),
24272450
("social", 7),
@@ -2492,6 +2515,25 @@ mod tests {
24922515

24932516
// ── projects update mutation group ────────────────────────────────────────
24942517

2518+
/// Project-channel requests accept the owner-review metadata.
2519+
#[test]
2520+
fn projects_add_channel_accepts_owner_review_fields() {
2521+
assert!(Cli::try_parse_from([
2522+
"buzz",
2523+
"projects",
2524+
"add-channel",
2525+
"--home-channel",
2526+
"11111111-1111-4111-8111-111111111111",
2527+
"--name",
2528+
"release-planning",
2529+
"--visibility",
2530+
"private",
2531+
"--template",
2532+
"Release team",
2533+
])
2534+
.is_ok());
2535+
}
2536+
24952537
/// Multiple independent fields must be accepted in the same invocation.
24962538
#[test]
24972539
fn projects_update_multi_field_is_accepted() {

‎desktop/src/app/navigation/useAppNavigation.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ export function useAppNavigation() {
108108
projectId: string,
109109
behavior?: NavigationBehavior & {
110110
commitHash?: string;
111+
filePath?: string;
111112
pullRequestId?: string;
112113
issueId?: string;
113114
repositoryId?: string;
@@ -128,6 +129,7 @@ export function useAppNavigation() {
128129
...(behavior?.commitHash
129130
? { commitHash: behavior.commitHash }
130131
: {}),
132+
...(behavior?.filePath ? { filePath: behavior.filePath } : {}),
131133
...(behavior?.pullRequestId
132134
? { pullRequestId: behavior.pullRequestId }
133135
: {}),

0 commit comments

Comments
 (0)