Skip to content
Open
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
8 changes: 4 additions & 4 deletions acceptance/task_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ func TestTaskRunHappyPath(t *testing.T) {
params := body["parameters"].(map[string]interface{})
assert.Equal(t, params["custom-prompt"], "Fix the flaky test")
assert.Equal(t, params["run-pipeline-as-a-tool"], true)
assert.Equal(t, params["create-new-branch"], false)
assert.Equal(t, params["create-new-branch"], true)

// Verify auth header
assert.Assert(t, runReqs[0].Header.Get("Circle-Token") != "",
Expand Down Expand Up @@ -138,7 +138,7 @@ func TestTaskRunBranchOverride(t *testing.T) {
assert.Equal(t, body["checkout_branch"], "feature/my-branch")
}

func TestTaskRunNewBranch(t *testing.T) {
func TestTaskRunNewBranchFalse(t *testing.T) {
cci := fakes.NewFakeCircleCI()
srv := httptest.NewServer(cci)
defer srv.Close()
Expand All @@ -153,7 +153,7 @@ func TestTaskRunNewBranch(t *testing.T) {
"task", "run",
"--definition", "dev",
"--prompt", "Add types",
"--new-branch",
"--new-branch=false",
}, env, workDir)

assert.Equal(t, result.ExitCode, 0, "stderr: %s", result.Stderr)
Expand All @@ -167,7 +167,7 @@ func TestTaskRunNewBranch(t *testing.T) {
assert.NilError(t, err)

params := body["parameters"].(map[string]interface{})
assert.Equal(t, params["create-new-branch"], true)
assert.Equal(t, params["create-new-branch"], false)
}

func TestTaskRunPipelineAsToolDefault(t *testing.T) {
Expand Down
4 changes: 3 additions & 1 deletion docs/CLI.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ chunk
│ │ --definition <name|uuid> # Definition name or UUID (required)
│ │ --prompt <text> # Prompt text (required)
│ │ --branch <branch> # Branch override
│ │ --new-branch # Create a new branch
│ │ --new-branch # Create a new branch (default: true; pass =false to commit on checkout branch)
│ │ --no-pipeline-as-tool # Disable pipeline-as-tool mode
│ │ --json # Output as JSON
│ └── config # Set up .chunk/run.json for this repository
Expand Down Expand Up @@ -146,6 +146,8 @@ chunk
- `build-prompt` does not write intermediate files by default. Pass `--debug` to write the raw details JSON, analysis markdown, and PR rankings CSV alongside the prompt — useful when diagnosing unexpected prompt output.
- `task run` defaults to pipeline-as-tool mode; use `--no-pipeline-as-tool`
to disable.
- `task run` creates a new branch by default (`create-new-branch: true`);
pass `--new-branch=false` to commit on the checkout branch instead.
- `config set` user keys: `model`. Project keys (`.chunk/config.json`): `orgID`,
`validation.sidecarImage`. Credentials use `chunk auth set`, not `config set`.
- **Org ID resolution** for `sidecar create`, `sidecar list`, and other sidecar
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ func newTaskRunCmd() *cobra.Command {
cmd.Flags().StringVar(&definition, "definition", "", "Definition name or UUID")
cmd.Flags().StringVar(&prompt, "prompt", "", "Prompt text")
cmd.Flags().StringVar(&branch, "branch", "", "Checkout branch override")
cmd.Flags().BoolVar(&newBranch, "new-branch", false, "Create a new branch")
cmd.Flags().BoolVar(&newBranch, "new-branch", true, "Create a new branch (default true; pass =false to commit on the checkout branch)")
cmd.Flags().BoolVar(&noPipelineAsTool, "no-pipeline-as-tool", false, "Disable running pipeline as a tool")
cmd.Flags().BoolVar(&jsonOut, "json", false, "Output as JSON")

Expand Down
34 changes: 32 additions & 2 deletions internal/task/task_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@ func TestTriggerRunHappyPath(t *testing.T) {
Definition: "dev",
Prompt: "Fix tests",
PipelineAsTool: true,
NewBranch: true,
})
if err != nil {
t.Fatalf("unexpected error: %v", err)
Expand Down Expand Up @@ -324,11 +325,40 @@ func TestTriggerRunHappyPath(t *testing.T) {
if params["run-pipeline-as-a-tool"] != true {
t.Fatalf("run-pipeline-as-a-tool = %v, want true", params["run-pipeline-as-a-tool"])
}
if params["create-new-branch"] != false {
t.Fatalf("create-new-branch = %v, want false", params["create-new-branch"])
if params["create-new-branch"] != true {
t.Fatalf("create-new-branch = %v, want true", params["create-new-branch"])
}
}

func TestTriggerRunNoNewBranch(t *testing.T) {
cci, client := newFakeAndClient(t)
cfg := testCfg()

_, err := TriggerRun(context.Background(), client, cfg, RunParams{
Definition: "dev",
Prompt: "Add feature",
NewBranch: false,
})
if err != nil {
t.Fatalf("unexpected error: %v", err)
}

for _, r := range cci.Recorder.AllRequests() {
if r.URL.Path == "/api/v2/agents/org/org-111/project/proj-222/runs" {
var body map[string]interface{}
if err := json.Unmarshal(r.Body, &body); err != nil {
t.Fatalf("unmarshal: %v", err)
}
params := body["parameters"].(map[string]interface{})
if params["create-new-branch"] != false {
t.Fatalf("create-new-branch = %v, want false", params["create-new-branch"])
}
return
}
}
t.Fatal("no request to trigger run endpoint")
}

func TestTriggerRunBranchOverride(t *testing.T) {
cci, client := newFakeAndClient(t)
cfg := testCfg()
Expand Down