summaryrefslogtreecommitdiff
path: root/makima/src
diff options
context:
space:
mode:
Diffstat (limited to 'makima/src')
-rw-r--r--makima/src/bin/makima.rs4
-rw-r--r--makima/src/daemon/api/supervisor.rs9
-rw-r--r--makima/src/daemon/cli/supervisor.rs8
-rw-r--r--makima/src/daemon/task/manager.rs40
-rw-r--r--makima/src/daemon/ws/protocol.rs4
-rw-r--r--makima/src/server/handlers/mesh_supervisor.rs41
-rw-r--r--makima/src/server/state.rs4
7 files changed, 49 insertions, 61 deletions
diff --git a/makima/src/bin/makima.rs b/makima/src/bin/makima.rs
index 44fa590..8e83565 100644
--- a/makima/src/bin/makima.rs
+++ b/makima/src/bin/makima.rs
@@ -439,10 +439,10 @@ async fn run_supervisor(
}
SupervisorCommand::Pr(args) => {
let client = ApiClient::new(args.common.api_url, args.common.api_key)?;
- eprintln!("Creating PR for task {}...", args.task_id);
+ eprintln!("Creating PR for branch {}...", args.branch);
let body = args.body.as_deref().unwrap_or("");
let result = client
- .supervisor_pr(args.task_id, &args.title, body, &args.base)
+ .supervisor_pr(&args.branch, &args.title, body)
.await?;
println!("{}", serde_json::to_string(&result.0)?);
}
diff --git a/makima/src/daemon/api/supervisor.rs b/makima/src/daemon/api/supervisor.rs
index 6b99de0..c841b21 100644
--- a/makima/src/daemon/api/supervisor.rs
+++ b/makima/src/daemon/api/supervisor.rs
@@ -54,10 +54,9 @@ pub struct MergeRequest {
#[derive(Serialize)]
#[serde(rename_all = "camelCase")]
pub struct CreatePrRequest {
- pub task_id: Uuid,
+ pub branch: String,
pub title: String,
pub body: String,
- pub base_branch: String,
}
#[derive(Serialize)]
@@ -165,16 +164,14 @@ impl ApiClient {
/// Create a pull request.
pub async fn supervisor_pr(
&self,
- task_id: Uuid,
+ branch: &str,
title: &str,
body: &str,
- base_branch: &str,
) -> Result<JsonValue, ApiError> {
let req = CreatePrRequest {
- task_id,
+ branch: branch.to_string(),
title: title.to_string(),
body: body.to_string(),
- base_branch: base_branch.to_string(),
};
self.post("/api/v1/mesh/supervisor/pr", &req).await
}
diff --git a/makima/src/daemon/cli/supervisor.rs b/makima/src/daemon/cli/supervisor.rs
index 09f61db..9ad7aef 100644
--- a/makima/src/daemon/cli/supervisor.rs
+++ b/makima/src/daemon/cli/supervisor.rs
@@ -128,9 +128,9 @@ pub struct PrArgs {
#[command(flatten)]
pub common: SupervisorArgs,
- /// Task ID to create PR for
+ /// Branch name to create PR from (e.g., "makima/feature-name")
#[arg(index = 1)]
- pub task_id: Uuid,
+ pub branch: String,
/// PR title
#[arg(long)]
@@ -139,10 +139,6 @@ pub struct PrArgs {
/// PR body/description
#[arg(long)]
pub body: Option<String>,
-
- /// Base branch (default: main)
- #[arg(long, default_value = "main")]
- pub base: String,
}
/// Arguments for diff command.
diff --git a/makima/src/daemon/task/manager.rs b/makima/src/daemon/task/manager.rs
index f0da860..8c5f8d7 100644
--- a/makima/src/daemon/task/manager.rs
+++ b/makima/src/daemon/task/manager.rs
@@ -669,7 +669,7 @@ makima supervisor wait "$TASK_ID"
makima supervisor merge "$TASK_ID" --to "makima/user-authentication"
# Step 3: All tasks complete - create PR from makima branch
-makima supervisor pr "makima/user-authentication" --title "Add user authentication" --base main
+makima supervisor pr "makima/user-authentication" --title "Add user authentication"
```
## Available Tools (via makima supervisor)
@@ -701,7 +701,7 @@ makima supervisor branch <branch_name> [--from <task_id|sha>]
makima supervisor merge <task_id> [--to <branch>] [--squash]
# Create a pull request
-makima supervisor pr <task_id> --title "Title" [--body "Body"] [--base main]
+makima supervisor pr <branch> --title "Title" [--body "Body"]
# View a task's diff
makima supervisor diff <task_id>
@@ -838,7 +838,7 @@ Common deliverable IDs by phase:
3. **wait blocks until complete** - you MUST call this to know when a task finishes
4. **Never fire-and-forget** - always wait for each task before moving on
5. **Merge to your makima branch** - use `merge <task_id> --to "makima/{name}"` to collect completed work
-6. **Create PR when done** - use `pr "makima/{name}" --title "..." --base main`
+6. **Create PR when done** - use `pr "makima/{name}" --title "..."`
7. **Ask when unsure** - use `ask` to get user feedback on decisions
## Standard Workflow
@@ -849,7 +849,7 @@ Common deliverable IDs by phase:
- `wait` - Block until complete
- `merge --to "makima/{name}"` - Merge to branch
3. `ask "Ready to create PR?"` - Get user approval
-4. `pr "makima/{name}" --title "..." --base main` - Create PR
+4. `pr "makima/{name}" --title "..."` - Create PR
## Important Reminders
@@ -875,7 +875,7 @@ When you receive an `[ACTION REQUIRED]` message from the system:
After all tasks are "done" and merged, you MUST take the following actions:
**If in execute phase:**
-1. Create PR immediately: `makima supervisor pr "makima/{name}" --title "..." --base main`
+1. Create PR immediately: `makima supervisor pr "makima/{name}" --title "..."`
2. After PR created:
- Simple contract: Mark complete with `makima supervisor complete`
- Specification contract: Advance to review with `makima supervisor advance-phase review`
@@ -2016,14 +2016,16 @@ impl TaskManager {
title,
body,
base_branch,
+ branch,
} => {
tracing::info!(
task_id = %task_id,
title = %title,
base_branch = %base_branch,
+ branch = %branch,
"Creating pull request"
);
- self.handle_create_pr(task_id, title, body, base_branch).await?;
+ self.handle_create_pr(task_id, title, body, base_branch, branch).await?;
}
DaemonCommand::GetTaskDiff {
task_id,
@@ -3135,6 +3137,7 @@ impl TaskManager {
title: String,
body: Option<String>,
base_branch: String,
+ branch: String,
) -> Result<(), DaemonError> {
// Get worktree path - this works even for completed tasks by scanning worktrees directory
let worktree_path = match self.get_task_worktree_path(task_id).await {
@@ -3153,30 +3156,19 @@ impl TaskManager {
}
};
- // Get base_branch from in-memory tasks if available (for fallback)
- let task_base_branch = {
- let tasks = self.tasks.read().await;
- tasks.get(&task_id).and_then(|t| t.base_branch.clone())
- };
-
- // Use task's base_branch if the provided one is the default "main" and task has a detected one
- let effective_base_branch = if base_branch == "main" {
- task_base_branch.unwrap_or(base_branch)
- } else {
- base_branch
- };
-
tracing::info!(
task_id = %task_id,
- effective_base_branch = %effective_base_branch,
+ base_branch = %base_branch,
+ branch = %branch,
worktree_path = %worktree_path.display(),
- "Creating PR with effective base branch"
+ "Creating PR"
);
- // Push the current branch first
+ // Push the branch to origin
+ let push_refspec = format!("HEAD:refs/heads/{}", branch);
let push_result = tokio::process::Command::new("git")
.current_dir(&worktree_path)
- .args(["push", "-u", "origin", "HEAD"])
+ .args(["push", "-u", "origin", &push_refspec])
.output()
.await;
@@ -3195,7 +3187,7 @@ impl TaskManager {
// Create PR using gh CLI
let mut pr_cmd = tokio::process::Command::new("gh");
pr_cmd.current_dir(&worktree_path);
- pr_cmd.args(["pr", "create", "--title", &title, "--base", &effective_base_branch]);
+ pr_cmd.args(["pr", "create", "--title", &title, "--base", &base_branch, "--head", &branch]);
if let Some(ref body_text) = body {
pr_cmd.args(["--body", body_text]);
diff --git a/makima/src/daemon/ws/protocol.rs b/makima/src/daemon/ws/protocol.rs
index bd13975..e971798 100644
--- a/makima/src/daemon/ws/protocol.rs
+++ b/makima/src/daemon/ws/protocol.rs
@@ -693,9 +693,11 @@ pub enum DaemonCommand {
task_id: Uuid,
title: String,
body: Option<String>,
- /// Base branch for the PR (default: main).
+ /// Base branch for the PR.
#[serde(rename = "baseBranch")]
base_branch: String,
+ /// Source branch name to push and create PR from.
+ branch: String,
},
/// Get the diff for a task's changes.
diff --git a/makima/src/server/handlers/mesh_supervisor.rs b/makima/src/server/handlers/mesh_supervisor.rs
index 016367f..a0a3a96 100644
--- a/makima/src/server/handlers/mesh_supervisor.rs
+++ b/makima/src/server/handlers/mesh_supervisor.rs
@@ -1267,15 +1267,9 @@ pub struct MergeTaskResponse {
#[derive(Debug, Deserialize, ToSchema)]
#[serde(rename_all = "camelCase")]
pub struct CreatePRRequest {
- pub task_id: Uuid,
+ pub branch: String,
pub title: String,
pub body: Option<String>,
- #[serde(default = "default_base_branch")]
- pub base_branch: String,
-}
-
-fn default_base_branch() -> String {
- "main".to_string()
}
/// Response for PR creation.
@@ -1513,48 +1507,53 @@ pub async fn create_pr(
headers: HeaderMap,
Json(request): Json<CreatePRRequest>,
) -> impl IntoResponse {
- let (_supervisor_id, owner_id) = match verify_supervisor_auth(&state, &headers, None).await {
+ let (supervisor_id, _owner_id) = match verify_supervisor_auth(&state, &headers, None).await {
Ok(ids) => ids,
Err(e) => return e.into_response(),
};
let pool = state.db_pool.as_ref().unwrap();
- // Get the target task
- let task = match repository::get_task_for_owner(pool, request.task_id, owner_id).await {
+ // Get the supervisor's own task to find daemon and base_branch
+ let task = match repository::get_task(pool, supervisor_id).await {
Ok(Some(t)) => t,
Ok(None) => {
return (
StatusCode::NOT_FOUND,
- Json(ApiError::new("NOT_FOUND", "Task not found")),
+ Json(ApiError::new("NOT_FOUND", "Supervisor task not found")),
).into_response();
}
Err(e) => {
- tracing::error!(error = %e, "Failed to get task");
+ tracing::error!(error = %e, "Failed to get supervisor task");
return (
StatusCode::INTERNAL_SERVER_ERROR,
- Json(ApiError::new("DB_ERROR", "Failed to get task")),
+ Json(ApiError::new("DB_ERROR", "Failed to get supervisor task")),
).into_response();
}
};
- // Get daemon running the task
+ // Get daemon running the supervisor
let Some(daemon_id) = task.daemon_id else {
return (
StatusCode::SERVICE_UNAVAILABLE,
- Json(ApiError::new("NO_DAEMON", "Task has no assigned daemon")),
+ Json(ApiError::new("NO_DAEMON", "Supervisor has no assigned daemon")),
).into_response();
};
+ // Use base_branch from the task's repository config, falling back to "main"
+ let base_branch = task.base_branch.unwrap_or_else(|| "main".to_string());
+
// Subscribe to PR results BEFORE sending the command
let mut rx = state.pr_results.subscribe();
- // Send CreatePR command to daemon
+ // Send CreatePR command to daemon using the supervisor's task ID
+ // (the branch is in the supervisor's worktree)
let cmd = DaemonCommand::CreatePR {
- task_id: request.task_id,
+ task_id: supervisor_id,
title: request.title.clone(),
body: request.body.clone(),
- base_branch: request.base_branch.clone(),
+ base_branch,
+ branch: request.branch.clone(),
};
if let Err(e) = state.send_daemon_command(daemon_id, cmd).await {
@@ -1571,7 +1570,7 @@ pub async fn create_pr(
loop {
match rx.recv().await {
Ok(notification) => {
- if notification.task_id == request.task_id {
+ if notification.task_id == supervisor_id {
return Some(notification);
}
// Not our task, keep waiting
@@ -1594,7 +1593,7 @@ pub async fn create_pr(
(
status,
Json(CreatePRResponse {
- task_id: request.task_id,
+ task_id: supervisor_id,
success: notification.success,
message: notification.message,
pr_url: notification.pr_url,
@@ -1607,7 +1606,7 @@ pub async fn create_pr(
(
StatusCode::GATEWAY_TIMEOUT,
Json(CreatePRResponse {
- task_id: request.task_id,
+ task_id: supervisor_id,
success: false,
message: "PR creation timed out waiting for daemon response".to_string(),
pr_url: None,
diff --git a/makima/src/server/state.rs b/makima/src/server/state.rs
index bf8f6f2..041b101 100644
--- a/makima/src/server/state.rs
+++ b/makima/src/server/state.rs
@@ -461,9 +461,11 @@ pub enum DaemonCommand {
task_id: Uuid,
title: String,
body: Option<String>,
- /// Base branch for the PR (default: main)
+ /// Base branch for the PR
#[serde(rename = "baseBranch")]
base_branch: String,
+ /// Source branch name to push and create PR from
+ branch: String,
},
/// Get the diff for a task's changes