pacework 1.5.0 → 1.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -16,7 +16,7 @@ import readline from "node:readline"
16
16
  import { spawn, execFileSync, execSync } from "node:child_process"
17
17
  import { fileURLToPath } from "node:url"
18
18
  import { agentSecretsFrom, detectSetupCommand } from "../lib/environment.mjs"
19
- import { runTriageLoop } from "../lib/triage-worker.mjs"
19
+ import { describeTriageJob, runTriageLoop } from "../lib/triage-worker.mjs"
20
20
  import { NPM_PACKAGE, isNewerVersion, latestPublishedVersion } from "../lib/version.mjs"
21
21
  import { EXECUTORS, EXECUTOR_DEFAULT_NAMES, checkBinaryExists, executorLabel } from "../lib/executors.mjs"
22
22
  import { BANNER_LINES } from "../lib/ui.mjs"
@@ -272,6 +272,8 @@ ${row("pacework status [--json]", "Is it running, and what is it doing")}
272
272
  ${row("pacework logs [--lines N]", "Follow its log")}
273
273
  ${row("pacework connect", "Run it in this terminal instead")}
274
274
  ${row("pacework use <tool>", `Switch AI tool: ${d("claude_code, codex, gemini, cursor_agent, github_copilot")}`)}
275
+ ${row("pacework settings", "Change the AI tool, model, folder, parallel jobs, triage, sandbox or name")}
276
+ ${row("pacework config [key] [value]", `The same from scripts: ${d("max-parallel-runs, triage, sandbox, model, …")}`)}
275
277
  ${row("pacework doctor", "Check this machine's setup")}
276
278
  ${row("pacework triage [--once]", "Only triage, in the foreground")}
277
279
  ${row("pacework up --token CODE", "One-step setup from the command in pacework's Runners page; asks for the runner's name and model")}
@@ -495,6 +497,15 @@ if (command === "config") {
495
497
  "repo-root": "repoRoot",
496
498
  "app-url": "appUrl",
497
499
  "workspace-id": "workspaceId",
500
+ "max-parallel-runs": "maxParallelRuns",
501
+ "triage": "triage",
502
+ "sandbox": "sandbox",
503
+ }
504
+ // Settings that are not plain text: how to read the typed value, or why it is wrong.
505
+ const PARSERS = {
506
+ maxParallelRuns: (raw) => (/^\d+$/.test(raw) && Number(raw) >= 1 && Number(raw) <= 20 ? Number(raw) : new Error("max-parallel-runs is a whole number from 1 to 20")),
507
+ triage: (raw) => (["on", "true", "yes", "1"].includes(raw) ? true : ["off", "false", "no", "0"].includes(raw) ? false : new Error("triage is on or off")),
508
+ sandbox: (raw) => (["on", "true", "yes", "1"].includes(raw) ? true : ["off", "false", "no", "0"].includes(raw) ? false : new Error("sandbox is on or off")),
498
509
  }
499
510
 
500
511
  const config = readConfig()
@@ -508,11 +519,15 @@ if (command === "config") {
508
519
  ["executor", config.executor ? `\x1b[1m${executorLabel(config.executor)}\x1b[0m (${config.executor})` : "\x1b[2mnot set\x1b[0m"],
509
520
  ["name", config.runnerName ?? "\x1b[2mnot set\x1b[0m"],
510
521
  ["repo-root", config.repoRoot ?? "\x1b[2mnot set\x1b[0m"],
522
+ ["model", config.model || "\x1b[2mlatest\x1b[0m"],
523
+ ["max-parallel-runs", String(config.maxParallelRuns ?? 1)],
524
+ ["triage", config.triage === false ? "off" : "on"],
525
+ ["sandbox", config.sandbox === true ? "on" : "off"],
511
526
  ["app-url", config.appUrl ?? "https://pacework.io"],
512
527
  ["api-key", config.apiKey ? `\x1b[2m${config.apiKey.slice(0, 12)}…\x1b[0m` : "\x1b[2mnot set\x1b[0m"],
513
528
  ]
514
- rows.forEach(([k, v]) => console.log(` ${k.padEnd(12)} ${v}`))
515
- console.log(`\nTo set: \x1b[36mpacework-runner config <key> <value>\x1b[0m`)
529
+ rows.forEach(([k, v]) => console.log(` ${k.padEnd(17)} ${v}`))
530
+ console.log(`\nTo set: \x1b[36mpacework config <key> <value>\x1b[0m`)
516
531
  console.log(`Keys: ${Object.keys(KEY_ALIASES).join(", ")}`)
517
532
  process.exit(0)
518
533
  }
@@ -536,9 +551,16 @@ if (command === "config") {
536
551
  process.exit(1)
537
552
  }
538
553
 
539
- config[configKey] = value
554
+ const parsed = PARSERS[configKey] ? PARSERS[configKey](String(value).trim().toLowerCase()) : value
555
+ if (parsed instanceof Error) {
556
+ console.error(parsed.message)
557
+ process.exit(1)
558
+ }
559
+ config[configKey] = parsed
540
560
  writeConfig(config)
541
- console.log(`\x1b[32m✓\x1b[0m ${key} = \x1b[1m${value}\x1b[0m`)
561
+ const pidNow = readPid()
562
+ const restartHint = pidNow && isRunning(pidNow) ? ` \x1b[2mrestart the runner to use it: pacework stop && pacework start\x1b[0m` : ""
563
+ console.log(`\x1b[32m✓\x1b[0m ${key} = \x1b[1m${typeof parsed === "boolean" ? (parsed ? "on" : "off") : parsed}\x1b[0m${restartHint}`)
542
564
  process.exit(0)
543
565
  }
544
566
 
@@ -724,6 +746,8 @@ function buildRunnerArgs(extraArgs) {
724
746
  ? !["false", "0", "no"].includes(String(parsedArgs.sandbox))
725
747
  : config.sandbox === true
726
748
  if (sandbox) base.push("--sandbox", "true")
749
+ // Triage is on unless switched off here (pacework settings) or with --no-triage.
750
+ if (config.triage === false && parsedArgs["no-triage"] === undefined) base.push("--no-triage")
727
751
 
728
752
  const consumed = new Set(["app-url", "workspace-id", "workspace-api-key", "repo-root", "executor", "name", "model", "yes", "max-parallel-runs", "token", "sandbox"])
729
753
  for (let i = 0; i < extraArgs.length; i++) {
@@ -784,7 +808,7 @@ function formatLogLine(raw) {
784
808
 
785
809
  if (event === "runner.ready") return `${prefix} ${green}●${reset} Runner ready ${dim}${entry.meta?.local_executor ?? ""} ${entry.meta?.machine_name ?? ""}${reset}`
786
810
  if (event === "runner.job.start") return `${prefix} ${blue}▶${reset} ${bold}${entry.meta?.task_identifier ?? ""}${reset} ${entry.meta?.task_title ?? msg} ${dim}${entry.meta?.local_executor ?? ""}${reset}`
787
- if (event === "runner.job.complete") return `${prefix} ${green}✓${reset} ${bold}${entry.meta?.task_identifier ?? ""}${reset} completed ${dim}${fmtDuration(entry.meta?.duration_ms)}${reset}`
811
+ if (event === "runner.job.complete") return `${prefix} ${green}✓${reset} ${bold}${entry.meta?.task_identifier ?? ""}${reset} ${entry.meta?.task_title ?? ""} ${entry.meta?.outcome ?? "completed"} ${dim}${fmtDuration(entry.meta?.duration_ms)}${reset}`
788
812
  if (event === "runner.job.error") return `${prefix} ${red}✗${reset} ${bold}${entry.meta?.task_identifier ?? ""}${reset} ${red}${msg}${reset}`
789
813
  if (event === "runner.job.cancel") return `${prefix} ${dim}■ ${entry.meta?.task_identifier ?? ""} canceled${reset}`
790
814
  if (event === "runner.heartbeat") return null // skip noise
@@ -1170,8 +1194,8 @@ else if (command === "triage") {
1170
1194
  shouldStop: () => stopping,
1171
1195
  report: (event, details) => {
1172
1196
  if (event === "started") log(`Triage runner "${details.runnerName}" polling ${appUrl} every ${details.pollIntervalMs / 1000}s (executor: ${details.executor})`)
1173
- else if (event === "claimed") log(`Job ${details.job.id} claimed; running ${executor}...`)
1174
- else if (event === "completed") log(`\x1b[32mJob ${details.job.id} completed\x1b[0m (confidence: ${details.confidence ?? "n/a"})`)
1197
+ else if (event === "claimed") log(`\x1b[1m${describeTriageJob(details.job).identifier}\x1b[0m ${describeTriageJob(details.job).title} \x1b[2mrunning ${executor}…\x1b[0m`)
1198
+ else if (event === "completed") log(`\x1b[32m✓\x1b[0m ${describeTriageJob(details.job).title} ${details.outcome ?? `confidence ${details.confidence ?? "n/a"}`} \x1b[2m${Math.round(details.durationMs / 1000)}s\x1b[0m`)
1175
1199
  else if (event === "rejected") log(`\x1b[31mJob ${details.job.id}: server rejected completion (${details.status}): ${JSON.stringify(details.payload)}\x1b[0m`)
1176
1200
  else if (event === "failed") log(`\x1b[31mJob ${details.job.id} failed: ${details.message}\x1b[0m`)
1177
1201
  else if (event === "poll_error") log(`Poll error: ${details.message}`)
@@ -1190,6 +1214,20 @@ else if (command === "triage") {
1190
1214
  // Question-driven UX: numbered choices instead of remembering commands/flags.
1191
1215
  // Every action shells out to this same CLI, so menu and commands never drift.
1192
1216
 
1217
+ else if (command === "settings") {
1218
+ const { changeSettings } = await import("../lib/setup.mjs")
1219
+ const changed = await changeSettings()
1220
+ const pid = readPid()
1221
+ if (changed && pid && isRunning(pid)) {
1222
+ const ctlScript = fileURLToPath(import.meta.url)
1223
+ const run = (args) => new Promise((resolve) => spawn(process.execPath, [ctlScript, ...args], { stdio: "ignore" }).on("close", (code) => resolve(code === 0)))
1224
+ console.log("Restarting the runner with the new settings…")
1225
+ await run(["stop"])
1226
+ console.log(await run(["start"]) ? "\x1b[32m✓\x1b[0m Runner restarted." : "\x1b[31mThe runner did not start again; see pacework logs.\x1b[0m")
1227
+ }
1228
+ process.exit(0)
1229
+ }
1230
+
1193
1231
  else if (command === "menu") {
1194
1232
  // `pacework` in a terminal: guided setup the first time, then the live home
1195
1233
  // screen. Both load the prompt library lazily, so the background service,
@@ -29,8 +29,9 @@ import { prepareRunEnvironment } from "../lib/environment.mjs"
29
29
  import { installSkills, parseSkillsUsed, skillsPromptSection } from "../lib/skills.mjs"
30
30
  import { isGitLockError, repoLockKey, retryGitLock, withRepoLock } from "../lib/git-lock.mjs"
31
31
  import { describeRegistration, isRevokedError, registrationChanges, REVOKED_MESSAGE, runEndedOnServer } from "../lib/runner-control.mjs"
32
- import { runTriageLoop, TRIAGE_EXECUTORS } from "../lib/triage-worker.mjs"
32
+ import { describeTriageJob, runTriageLoop, TRIAGE_EXECUTORS } from "../lib/triage-worker.mjs"
33
33
  import { automationDenyRules, automationLimits } from "../lib/automation-limits.mjs"
34
+ import { truncateSummary } from "../lib/summary-text.mjs"
34
35
 
35
36
  function parseArgs(argv) {
36
37
  const args = {}
@@ -215,6 +216,11 @@ function getRunLogger(state, run) {
215
216
  run_id: run?.id || undefined,
216
217
  task_id: run?.task_id || undefined,
217
218
  agent_id: run?.agent_id || run?.agent?.id || undefined,
219
+ // Every line of a run names its issue, so `pacework` can say what is being worked on.
220
+ meta: {
221
+ task_identifier: run?.task?.identifier || undefined,
222
+ task_title: run?.task?.title ? String(run.task.title).replace(/\s+/g, " ").trim() : undefined,
223
+ },
218
224
  })
219
225
  }
220
226
 
@@ -648,7 +654,7 @@ function parseReviewerDecisionSummary(summary) {
648
654
 
649
655
  return {
650
656
  decision,
651
- summary: truncate(review || "Reviewer decision submitted.", 6000),
657
+ summary: truncateSummary(review || "Reviewer decision submitted.", 6000),
652
658
  }
653
659
  }
654
660
 
@@ -1443,7 +1449,7 @@ function buildPullRequestBody(run, details = {}) {
1443
1449
  const sections = [
1444
1450
  "## Summary",
1445
1451
  // An agent that ignored the headings still wrote a report; show it whole.
1446
- summary || truncate(report, 4000) || `Implements ${identifier}: ${run.task?.title || "see the linked issue"}.`,
1452
+ summary || truncateSummary(report, 4000) || `Implements ${identifier}: ${run.task?.title || "see the linked issue"}.`,
1447
1453
  "",
1448
1454
  "## Why",
1449
1455
  `pacework issue **${identifier}** — ${run.task?.title || "Untitled"}`,
@@ -3250,7 +3256,10 @@ async function runExecutor(run, state) {
3250
3256
  }, RUN_TIMEOUT_MS)
3251
3257
  })
3252
3258
 
3259
+ const jobStartedAt = Date.now()
3253
3260
  try {
3261
+ // The job events the CLI's home screen, `jobs` and `logs` read.
3262
+ runLogger.info("runner.job.start", `Working on ${run.task?.identifier || "an issue"}`)
3254
3263
  runLogger.info("runner.run.started", "Local runner execution started", {
3255
3264
  meta: {
3256
3265
  branch,
@@ -3770,7 +3779,7 @@ async function runExecutor(run, state) {
3770
3779
 
3771
3780
  await completeRun(state, run.id, {
3772
3781
  status: "completed",
3773
- result_summary: truncate(summary, 4000),
3782
+ result_summary: truncateSummary(summary, 4000),
3774
3783
  // Which of its skills the agent says it used, from its report's last line.
3775
3784
  skills_used: parseSkillsUsed(summary, skillInstall.installed),
3776
3785
  usage: runUsage,
@@ -3780,7 +3789,7 @@ async function runExecutor(run, state) {
3780
3789
  // This completion payload omitted the excerpt entirely, so the diff was
3781
3790
  // captured and then dropped on the way to the server.
3782
3791
  diff_excerpt: diffExcerpt,
3783
- verification_summary: truncate(verificationSummary, 4000),
3792
+ verification_summary: truncateSummary(verificationSummary, 4000),
3784
3793
  worktree_path: worktreePath,
3785
3794
  commit_sha: commitResult?.sha,
3786
3795
  commit_message: commitResult?.subject,
@@ -3823,6 +3832,14 @@ async function runExecutor(run, state) {
3823
3832
  },
3824
3833
  })
3825
3834
 
3835
+ runLogger.info("runner.job.complete", "Done", {
3836
+ meta: {
3837
+ duration_ms: Date.now() - jobStartedAt,
3838
+ outcome: pushResult?.pr_url
3839
+ ? `PR ${pushResult.pr_url.replace(/^.*\/pull\//, "#")} · ${changedFiles.length} file${changedFiles.length === 1 ? "" : "s"}`
3840
+ : changedFiles.length ? `${changedFiles.length} file${changedFiles.length === 1 ? "" : "s"} changed` : "no changes",
3841
+ },
3842
+ })
3826
3843
  return { summary, branch, worktreePath, artifactsFile, reportFile, verificationSummary, commitResult, pushResult }
3827
3844
  } catch (error) {
3828
3845
  await flushRunnerLog().catch(() => {})
@@ -3903,6 +3920,8 @@ async function runExecutor(run, state) {
3903
3920
  changed_files: stopped?.changedFiles ?? undefined,
3904
3921
  }).catch(() => {})
3905
3922
 
3923
+ if (cancelRequested) runLogger.info("runner.job.cancel", "Canceled", { meta: { duration_ms: Date.now() - jobStartedAt } })
3924
+ else runLogger.error("runner.job.error", String(message).split("\n")[0].slice(0, 200), { meta: { duration_ms: Date.now() - jobStartedAt } })
3906
3925
  runLogger.error("runner.run.failed", "Local runner execution failed", {
3907
3926
  meta: {
3908
3927
  branch,
@@ -4237,7 +4256,10 @@ async function main() {
4237
4256
  if (!cloudState && triageEnabled && workspaceApiKey) {
4238
4257
  const triageLogger = () => getRunnerLogger(state)
4239
4258
  if (TRIAGE_EXECUTORS.includes(defaultExecutor)) {
4240
- const jobMeta = (job, extra = {}) => ({ meta: { run_id: job.id, task_identifier: "Triage", task_title: "Triage a request", request_id: job.request_id, ...extra } })
4259
+ const jobMeta = (job, extra = {}) => {
4260
+ const { identifier, title } = describeTriageJob(job)
4261
+ return { meta: { run_id: job.id, task_identifier: identifier, task_title: title, request_id: job.request_id, ...extra } }
4262
+ }
4241
4263
  runTriageLoop({
4242
4264
  appUrl,
4243
4265
  apiKey: workspaceApiKey,
@@ -4246,8 +4268,8 @@ async function main() {
4246
4268
  shouldStop: () => shuttingDown,
4247
4269
  report: (event, details) => {
4248
4270
  if (event === "started") triageLogger().info("runner.triage.ready", "Taking triage jobs too")
4249
- else if (event === "claimed") triageLogger().info("runner.job.start", "Triage job started", jobMeta(details.job))
4250
- else if (event === "completed") triageLogger().info("runner.job.complete", "Triage job completed", jobMeta(details.job, { duration_ms: details.durationMs, confidence: details.confidence }))
4271
+ else if (event === "claimed") triageLogger().info("runner.job.start", `Triaging: ${describeTriageJob(details.job).title}`, jobMeta(details.job))
4272
+ else if (event === "completed") triageLogger().info("runner.job.complete", details.outcome ? `Triaged: ${details.outcome}` : "Triage job completed", jobMeta(details.job, { duration_ms: details.durationMs, confidence: details.confidence, outcome: details.outcome }))
4251
4273
  else if (event === "rejected") triageLogger().error("runner.job.error", `Triage result rejected (${details.status})`, jobMeta(details.job, { duration_ms: details.durationMs }))
4252
4274
  else if (event === "failed") triageLogger().error("runner.job.error", details.message, jobMeta(details.job, { duration_ms: details.durationMs }))
4253
4275
  else if (event === "auth_failed") triageLogger().error("runner.triage.auth_failed", `Triage is paused: the server rejected this runner's key (${details.status}). Retrying every ${Math.round(details.retryMs / 60000)} minutes; run \`npx pacework login\` if it keeps failing.`)
@@ -101,6 +101,7 @@ function parseLogLine(raw) {
101
101
  taskIdentifier: entry.meta?.task_identifier ?? null,
102
102
  taskTitle: entry.meta?.task_title ?? null,
103
103
  durationMs: entry.meta?.duration_ms ?? null,
104
+ outcome: entry.meta?.outcome ?? null,
104
105
  }
105
106
  } catch {
106
107
  return { ts: null, level: "info", event: null, message: raw }
@@ -120,6 +121,7 @@ function summarizeJobs(entries) {
120
121
  finishedAt: null,
121
122
  durationMs: null,
122
123
  message: null,
124
+ outcome: null,
123
125
  }
124
126
  if (entry.event === "runner.job.start") {
125
127
  existing.status = "running"
@@ -128,6 +130,7 @@ function summarizeJobs(entries) {
128
130
  existing.status = "completed"
129
131
  existing.finishedAt = entry.ts
130
132
  existing.durationMs = entry.durationMs
133
+ existing.outcome = entry.outcome
131
134
  } else if (entry.event === "runner.job.error") {
132
135
  existing.status = "error"
133
136
  existing.finishedAt = entry.ts
package/lib/home.mjs CHANGED
@@ -3,9 +3,10 @@ import { spawn } from "node:child_process"
3
3
  import { readConfig, readRunnerSnapshot } from "./control-state.mjs"
4
4
  import { executorLabel } from "./executors.mjs"
5
5
  import { openInBrowser } from "./login.mjs"
6
- import { changeExecutor, changeRepo, switchServer } from "./setup.mjs"
6
+ import { changeExecutor, changeRepo, changeSettings, switchServer } from "./setup.mjs"
7
+ import { runnerSettingRows } from "./runner-settings.mjs"
7
8
  import { TRIAGE_EXECUTORS } from "./triage-worker.mjs"
8
- import { BANNER_LINES, LOGO, formatDuration, hostOf, relativeTime, style, tildePath, truncate } from "./ui.mjs"
9
+ import { BANNER_LINES, LOGO, formatDuration, hostOf, relativeTime, style, tildePath, truncate, visibleLength } from "./ui.mjs"
9
10
  import { formatIssueRows, listIssues } from "./issues-cli.mjs"
10
11
  import { workspaceUrl } from "./workspace-api.mjs"
11
12
 
@@ -20,9 +21,8 @@ const KEYS = [
20
21
  ["i", "issues"],
21
22
  ["m", "MCP"],
22
23
  ["l", "logs"],
24
+ ["c", "settings"],
23
25
  ["w", "switch"],
24
- ["r", "repo"],
25
- ["e", "agent AI"],
26
26
  ["o", "open"],
27
27
  ["d", "doctor"],
28
28
  ["?", "help"],
@@ -35,8 +35,7 @@ const HELP = [
35
35
  ["m", "Connect your AI tools to pacework over MCP, so they can read and update issues"],
36
36
  ["l", "Show the live runner log"],
37
37
  ["w", "Switch to another pacework server or workspace (signs in again)"],
38
- ["r", "Change the folder agents work in"],
39
- ["e", "Change the AI tool agents run on (Claude Code, Codex, …)"],
38
+ ["c", "Runner settings: AI tool, model, folder, parallel jobs, triage, sandbox, name"],
40
39
  ["o", "Open this workspace in your browser"],
41
40
  ["d", "Run the health check"],
42
41
  ["q", "Quit this screen; the runner keeps working in the background"],
@@ -49,6 +48,7 @@ const PLAIN_COMMANDS = [
49
48
  ["pacework start | stop", "Start or stop the background runner"],
50
49
  ["pacework logs", "Follow the runner log"],
51
50
  ["pacework login | logout", "Sign in to a pacework, or sign out"],
51
+ ["pacework settings", "Change runner settings"],
52
52
  ["pacework doctor", "Check this machine's setup"],
53
53
  ["pacework triage", "Run only triage, in the foreground"],
54
54
  ]
@@ -84,11 +84,13 @@ function jobLine(job, width) {
84
84
  }
85
85
  const mark = job.status === "completed" ? style.green("✓") : job.status === "error" ? style.red("✗") : style.gray("–")
86
86
  const outcome = job.status === "completed"
87
- ? formatDuration(job.durationMs)
87
+ ? [job.outcome, formatDuration(job.durationMs)].filter(Boolean).join(" · ")
88
88
  : job.status === "error" ? `failed${job.message ? `: ${job.message}` : ""}` : job.status
89
89
  const when = relativeTime(job.finishedAt)
90
- const title = truncate(job.title ?? "", Math.max(10, width - 44))
91
- return ` ${mark} ${id} ${title} ${style.gray(truncate(`${outcome}${when ? ` · ${when}` : ""}`, 34))}`
90
+ // The result gets the room it needs (a triage verdict is longer than a duration); the title the rest.
91
+ const tail = truncate(`${outcome}${when ? ` · ${when}` : ""}`, Math.max(20, Math.floor(width * 0.45)))
92
+ const title = truncate(job.title ?? "", Math.max(10, width - 18 - visibleLength(tail)))
93
+ return ` ${mark} ${id} ${title} ${style.gray(tail)}`
92
94
  }
93
95
 
94
96
  export async function runHome({ ctlScript, version }) {
@@ -119,8 +121,11 @@ export async function runHome({ ctlScript, version }) {
119
121
  lines.push(` ${style.gray(`${hostOf(snapshot.appUrl)} · ${snapshot.workspace ?? "no workspace"}`)}`)
120
122
  const state = snapshot.running ? `${style.green("●")} running` : `${style.gray("○")} stopped`
121
123
  const tool = executorLabel(snapshot.executor)
122
- const work = TRIAGE_EXECUTORS.includes(snapshot.executor) ? "development + triage" : "development"
123
- lines.push(` ${state} ${tildePath(snapshot.repoRoot) || style.yellow("no folder set")} ${style.gray("·")} ${tool} ${style.gray("·")} ${style.gray(work)}`)
124
+ const triageOn = TRIAGE_EXECUTORS.includes(snapshot.executor) && config.triage !== false
125
+ lines.push(` ${state} ${tildePath(snapshot.repoRoot) || style.yellow("no folder set")} ${style.gray("·")} ${tool} ${style.gray("·")} ${style.gray(triageOn ? "development + triage" : "development")}`)
126
+ // The settings that change what it does, so nobody has to open the menu to check.
127
+ const setting = Object.fromEntries(runnerSettingRows(config).map((row) => [row.key, row.value]))
128
+ lines.push(` ${style.gray(`model ${setting.model} · ${setting.maxParallelRuns} at a time${config.sandbox ? " · sandboxed" : ""} · c to change`)}`)
124
129
  lines.push("")
125
130
 
126
131
  if (mode === "issues") {
@@ -307,7 +312,8 @@ export async function runHome({ ctlScript, version }) {
307
312
  })
308
313
  })
309
314
  }
310
- const settings = { w: switchServer, r: changeRepo, e: changeExecutor }
315
+ // r and e predate the settings menu (c) and still go straight to their setting.
316
+ const settings = { c: changeSettings, w: switchServer, r: changeRepo, e: changeExecutor }
311
317
  if (settings[name]) {
312
318
  const changed = await suspend(() => settings[name]())
313
319
  if (changed) {
@@ -0,0 +1,21 @@
1
+ import { executorLabel } from "./executors.mjs"
2
+ import { modelLabel } from "./models.mjs"
3
+ import { tildePath } from "./ui.mjs"
4
+
5
+ /** The runner settings `pacework settings` and the home screen show, read from the saved config. */
6
+ export const RUNNER_SETTING_DEFAULTS = { maxParallelRuns: 1, triage: true, sandbox: false }
7
+
8
+ export function runnerSettingRows(config) {
9
+ const executor = config.executor ?? "codex"
10
+ const on = (value) => (value ? "on" : "off")
11
+ return [
12
+ { key: "executor", label: "AI tool", value: executorLabel(executor) },
13
+ { key: "model", label: "Model", value: modelLabel(executor, config.model) },
14
+ { key: "repoRoot", label: "Folder", value: tildePath(config.repoRoot) || "not set" },
15
+ { key: "maxParallelRuns", label: "Parallel jobs", value: String(config.maxParallelRuns ?? RUNNER_SETTING_DEFAULTS.maxParallelRuns) },
16
+ { key: "triage", label: "Triage requests", value: on(config.triage ?? RUNNER_SETTING_DEFAULTS.triage) },
17
+ { key: "sandbox", label: "Sandbox", value: on(config.sandbox ?? RUNNER_SETTING_DEFAULTS.sandbox) },
18
+ { key: "runnerName", label: "Name", value: config.runnerName || "not set" },
19
+ ]
20
+ }
21
+
package/lib/setup.mjs CHANGED
@@ -6,6 +6,8 @@ import { readConfig, writeConfig } from "./control-state.mjs"
6
6
  import { EXECUTORS, EXECUTOR_DEFAULT_NAMES, checkBinaryExists, executorLabel } from "./executors.mjs"
7
7
  import { openInBrowser, startLogin, waitForApproval } from "./login.mjs"
8
8
  import { hostOf, normalizeAppUrl, style, tildePath } from "./ui.mjs"
9
+ import { CUSTOM_MODEL, modelChoices } from "./models.mjs"
10
+ import { RUNNER_SETTING_DEFAULTS, runnerSettingRows } from "./runner-settings.mjs"
9
11
 
10
12
  /**
11
13
  * Guided setup for the interactive CLI: which pacework, sign in, which folder,
@@ -220,3 +222,77 @@ export async function changeExecutor() {
220
222
  return true
221
223
  }) ?? false
222
224
  }
225
+
226
+ /**
227
+ * Every runner setting in one menu (home screen key c, `pacework settings`):
228
+ * pick one, change it, come back to the list; Done or Esc leaves. Returns
229
+ * whether anything changed, so the caller can restart a running runner.
230
+ */
231
+ const SETTING_HINTS = {
232
+ maxParallelRuns: "how many issues it works on at once",
233
+ triage: "also triage incoming requests with your AI tool",
234
+ sandbox: "run agents with restricted file and network access",
235
+ runnerName: "how this machine shows in pacework",
236
+ }
237
+
238
+ async function changeSetting(key) {
239
+ const config = readConfig()
240
+ if (key === "executor") {
241
+ const executor = await chooseExecutor(config.executor)
242
+ // A model id belongs to one tool; switching tools starts from its default.
243
+ updateConfig(executor === config.executor ? { executor } : { executor, model: "" })
244
+ } else if (key === "model") {
245
+ const executor = config.executor ?? "codex"
246
+ const picked = unlessCancelled(await prompt.select({
247
+ message: `Which model should ${executorLabel(executor)} use?`,
248
+ options: modelChoices(executor, config.model),
249
+ initialValue: config.model ?? "",
250
+ }))
251
+ const model = picked === CUSTOM_MODEL
252
+ ? String(unlessCancelled(await prompt.text({ message: "Model id", validate: (value) => (String(value ?? "").trim() ? undefined : "Enter a model id") }))).trim()
253
+ : picked
254
+ updateConfig({ model })
255
+ } else if (key === "repoRoot") {
256
+ updateConfig({ repoRoot: await chooseRepo(config.repoRoot) })
257
+ } else if (key === "maxParallelRuns") {
258
+ const current = config.maxParallelRuns ?? RUNNER_SETTING_DEFAULTS.maxParallelRuns
259
+ const value = unlessCancelled(await prompt.text({
260
+ message: "How many issues at once? (1-20)",
261
+ initialValue: String(current),
262
+ validate: (input) => (/^\d+$/.test(String(input ?? "").trim()) && Number(input) >= 1 && Number(input) <= 20 ? undefined : "A whole number from 1 to 20"),
263
+ }))
264
+ updateConfig({ maxParallelRuns: Number(value) })
265
+ } else if (key === "triage" || key === "sandbox") {
266
+ const current = config[key] ?? RUNNER_SETTING_DEFAULTS[key]
267
+ const value = unlessCancelled(await prompt.confirm({ message: `${key === "triage" ? "Triage requests on this machine" : "Run agents in a sandbox"}?`, initialValue: current }))
268
+ updateConfig({ [key]: value })
269
+ } else if (key === "runnerName") {
270
+ const value = unlessCancelled(await prompt.text({
271
+ message: "Runner name",
272
+ initialValue: config.runnerName ?? "",
273
+ validate: (input) => (String(input ?? "").trim() ? undefined : "Enter a name"),
274
+ }))
275
+ updateConfig({ runnerName: String(value).trim() })
276
+ }
277
+ }
278
+
279
+ export async function changeSettings() {
280
+ let changed = false
281
+ prompt.intro(`${style.inverse(" pacework ")} Runner settings`)
282
+ for (;;) {
283
+ const rows = runnerSettingRows(readConfig())
284
+ const width = Math.max(...rows.map((row) => row.label.length))
285
+ const choice = await prompt.select({
286
+ message: "Pick a setting to change",
287
+ options: [
288
+ ...rows.map((row) => ({ value: row.key, label: `${row.label.padEnd(width)} ${row.value}`, hint: SETTING_HINTS[row.key] })),
289
+ { value: "done", label: "Done" },
290
+ ],
291
+ })
292
+ if (prompt.isCancel(choice) || choice === "done") break
293
+ const saved = await step(async () => { await changeSetting(choice); return true })
294
+ if (saved) changed = true
295
+ }
296
+ prompt.outro(changed ? "Saved. A running runner restarts to use them." : "Nothing changed.")
297
+ return changed
298
+ }
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Shortens text a person will read (a run summary, a review, a PR body) by
3
+ * keeping its beginning. Cuts at the last line break before the limit so a
4
+ * code span or list item is not split, and says where the rest is.
5
+ * Logs keep their tail instead; see truncate() in bin/pacework-runner.mjs.
6
+ */
7
+ export function truncateSummary(value, max = 4000, note = "…(shortened; the full text is in the run report)") {
8
+ const text = String(value ?? "").trim()
9
+ if (text.length <= max) return text
10
+ const room = Math.max(0, max - note.length - 2)
11
+ const head = text.slice(0, room)
12
+ const lineBreak = head.lastIndexOf("\n")
13
+ const cut = lineBreak > room * 0.5 ? head.slice(0, lineBreak) : head.replace(/\s+\S*$/, "")
14
+ return `${cut.trimEnd()}\n\n${note}`
15
+ }
@@ -11,6 +11,17 @@ import { spawn } from "node:child_process"
11
11
  */
12
12
  export const TRIAGE_EXECUTORS = ["claude_code", "codex", "gemini"]
13
13
 
14
+ /**
15
+ * How a job reads in the terminal: a short tag and what it is about. Triage
16
+ * jobs carry their request's title (servers before that send none); the other
17
+ * kind answers an AI feature such as the Slack agent.
18
+ */
19
+ export function describeTriageJob(job) {
20
+ if (job?.kind === "completion") return { identifier: "AI reply", title: "Answering for the Slack agent" }
21
+ const title = typeof job?.title === "string" ? job.title.replace(/\s+/g, " ").trim() : ""
22
+ return { identifier: "Triage", title: title || "A request" }
23
+ }
24
+
14
25
  function buildExecSpec({ executor, model, binaries }, prompt) {
15
26
  if (executor === "codex") {
16
27
  const outputFile = path.join(os.tmpdir(), `pacework-triage-${Date.now()}-${Math.random().toString(36).slice(2)}.txt`)
@@ -129,7 +140,7 @@ export async function runTriageLoop({
129
140
  model: `${executor}${model ? `:${model}` : ""}`,
130
141
  })
131
142
  if (complete.status >= 400) report("rejected", { job, status: complete.status, payload: complete.payload, durationMs: Date.now() - startedAt })
132
- else report("completed", { job, confidence: complete.payload?.confidence ?? null, durationMs: Date.now() - startedAt })
143
+ else report("completed", { job, confidence: complete.payload?.confidence ?? null, outcome: complete.payload?.outcome ?? null, durationMs: Date.now() - startedAt })
133
144
  } catch (error) {
134
145
  const message = error instanceof Error ? error.message : String(error)
135
146
  report("failed", { job, message, durationMs: Date.now() - startedAt })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pacework",
3
- "version": "1.5.0",
3
+ "version": "1.6.0",
4
4
  "description": "pacework CLI: connect this machine as a runner for pacework AI agents",
5
5
  "type": "module",
6
6
  "bin": {