pacework 1.1.0 → 1.4.1

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.
@@ -17,7 +17,9 @@ 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
19
  import { runTriageLoop } from "../lib/triage-worker.mjs"
20
+ import { NPM_PACKAGE, isNewerVersion, latestPublishedVersion } from "../lib/version.mjs"
20
21
  import { EXECUTORS, EXECUTOR_DEFAULT_NAMES, checkBinaryExists, executorLabel } from "../lib/executors.mjs"
22
+ import { BANNER_LINES } from "../lib/ui.mjs"
21
23
  import {
22
24
  PACEWORK_DIR,
23
25
  STATE_DIR,
@@ -61,24 +63,17 @@ const LOCAL_VERSION = (() => {
61
63
  async function checkForUpdate() {
62
64
  if (!LOCAL_VERSION) return
63
65
  try {
64
- const res = await fetch("https://registry.npmjs.org/pacework-runner/latest", { signal: AbortSignal.timeout(4000) })
65
- if (!res.ok) return
66
- const { version: latest } = await res.json()
67
- if (latest && latest !== LOCAL_VERSION) {
68
- console.log(`\n⚠ Update available: pacework-runner ${LOCAL_VERSION} → ${latest}`)
69
- console.log(` Run: npm install -g pacework\n`)
66
+ const latest = await latestPublishedVersion()
67
+ if (latest && isNewerVersion(latest, LOCAL_VERSION)) {
68
+ console.log(`\n⚠ Update available: ${NPM_PACKAGE} ${LOCAL_VERSION} → ${latest}`)
69
+ console.log(` Run: pacework update\n`)
70
70
  }
71
71
  } catch {}
72
72
  }
73
73
 
74
74
  // ── ascii banner ──────────────────────────────────────────────────────────────
75
75
 
76
- const BANNER = `\x1b[38;5;39m ██████╗ █████╗ ██████╗███████╗██╗ ██╗ ██████╗ ██████╗ ██╗ ██╗
77
- ██╔══██╗██╔══██╗██╔════╝██╔════╝██║ ██║██╔═══██╗██╔══██╗██║ ██╔╝
78
- ██████╔╝███████║██║ █████╗ ██║ █╗ ██║██║ ██║██████╔╝█████╔╝
79
- ██╔═══╝ ██╔══██║██║ ██╔══╝ ██║███╗██║██║ ██║██╔══██╗██╔═██╗
80
- ██║ ██║ ██║╚██████╗███████╗╚███╔███╔╝╚██████╔╝██║ ██║██║ ██╗
81
- ╚═╝ ╚═╝ ╚═╝ ╚═════╝╚══════╝ ╚══╝╚══╝ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝\x1b[0m`
76
+ const BANNER = `\x1b[38;5;39m${BANNER_LINES.map((line) => ` ${line}`).join("\n")}\x1b[0m`
82
77
 
83
78
  function printBanner(config) {
84
79
  const cols = process.stdout.columns || 80
@@ -244,51 +239,87 @@ const parsedArgs = parseCliArgs(restArgs)
244
239
 
245
240
  // ── help ──────────────────────────────────────────────────────────────────────
246
241
 
247
- if (!command || command === "--help" || command === "-h") {
248
- printBanner()
249
- console.log(`\x1b[1mCommands:\x1b[0m
250
- \x1b[36mup\x1b[0m --token CODE One-command setup: sign in, detect your coding tool, install as a service
251
- \x1b[36mdown\x1b[0m Remove the runner service from this machine
252
- \x1b[36mlogin\x1b[0m [--app-url URL] Authenticate via browser and save credentials
253
- \x1b[36mlogout\x1b[0m Revoke saved API key and clear credentials
254
- \x1b[36mconnect\x1b[0m [flags] Run the runner in the foreground (interactive)
255
- \x1b[36mstart\x1b[0m [flags] Start the runner as a background daemon
256
- \x1b[36mstop\x1b[0m Stop the background runner
257
- \x1b[36mstatus\x1b[0m Show runner and config status
258
- \x1b[36mlogs\x1b[0m [--lines N] [--raw] Tail the runner log (default: 50 lines)
259
- \x1b[36muse\x1b[0m <executor> Switch executor without re-logging in
260
- \x1b[36mconfig\x1b[0m [key] [value] View or set config values
261
- \x1b[36mdoctor\x1b[0m Check that everything is set up correctly
262
- \x1b[36mjobs\x1b[0m [--lines N] Show recent job history
263
- \x1b[36mmenu\x1b[0m Guided interactive mode — pick actions from questions (default for bare \x1b[36mpacework\x1b[0m)
264
- \x1b[36mtriage\x1b[0m [--once] [--model M] Run pacework Intelligence triage jobs locally via your executor CLI
265
- \x1b[36mshell\x1b[0m Interactive REPL with tab completion
266
-
267
- \x1b[1mExecutors:\x1b[0m claude_code · codex · gemini · cursor_agent · github_copilot
268
-
269
- \x1b[1mFlags:\x1b[0m
270
- --app-url pacework app URL (default: https://pacework.io)
271
- --workspace-id Workspace UUID (saved after login)
272
- --workspace-api-key API key (saved after login)
273
- --repo-root Absolute path to your git repo (default: cwd)
274
- --executor AI executor (default: codex)
275
- --name Runner display name
276
- --max-parallel-runs Max concurrent jobs (default: 1)
277
- --sandbox Confine agents to their checkout; network only to package registries and GitHub
278
-
279
- \x1b[1mQuick start:\x1b[0m
280
- Copy the command from pacework → Agents → Connect a runner, then run it inside your repo:
281
- npx pacework@latest up --app-url https://pacework.io --token <code>
282
-
283
- \x1b[1mManual setup:\x1b[0m
284
- npm install -g pacework
285
- pacework login \x1b[2m# opens browser, picks executor, saves config\x1b[0m
286
- pacework connect \x1b[2m# run interactively\x1b[0m
287
- pacework start \x1b[2m# run as background daemon\x1b[0m
242
+ if (!command || command === "--help" || command === "-h" || command === "help") {
243
+ const c = (text) => `\x1b[36m${text}\x1b[0m`
244
+ const d = (text) => `\x1b[2m${text}\x1b[0m`
245
+ const row = (command, description) => ` ${c(command.padEnd(30))} ${description}`
246
+ console.log(`\n${BANNER}\n`)
247
+ console.log(` Connect this machine to pacework: agents work on your issues here, and
248
+ your AI tools can read and update pacework.
249
+
250
+ \x1b[1mStart here\x1b[0m
251
+ ${row("pacework", "Guided setup the first time, then the live home screen")}
252
+
253
+ \x1b[1mAccount\x1b[0m
254
+ ${row("pacework login", "Sign in to a pacework (asks which one)")}
255
+ ${row("pacework logout", "Sign out and revoke this machine's key")}
256
+ ${row("pacework whoami", "Who and where you are signed in")}
257
+
258
+ \x1b[1mConnect your AI tools\x1b[0m ${d("Claude Code, Codex, Gemini CLI, Cursor, VS Code")}
259
+ ${row("pacework mcp add [tool…|--all]", "Give them pacework's tools; they sign in on first use")}
260
+ ${row("pacework mcp status", "Which tools are connected")}
261
+ ${row("pacework mcp remove [tool…]", "Disconnect tools")}
262
+
263
+ \x1b[1mIssues\x1b[0m
264
+ ${row("pacework issues [--mine]", "List open issues, or the ones assigned to you")}
265
+ ${row("pacework issues --status S", `Filter: ${d("open, todo, in_progress, in_review, done, …")}`)}
266
+ ${row("pacework issue ENG-42", "Show one issue with its latest comments")}
267
+ ${row("pacework open [ENG-42]", "Open the workspace or an issue in the browser")}
268
+
269
+ \x1b[1mRunner\x1b[0m ${d("takes development and triage jobs")}
270
+ ${row("pacework start | stop", "Start or stop it in the background")}
271
+ ${row("pacework status [--json]", "Is it running, and what is it doing")}
272
+ ${row("pacework logs [--lines N]", "Follow its log")}
273
+ ${row("pacework connect", "Run it in this terminal instead")}
274
+ ${row("pacework use <tool>", `Switch AI tool: ${d("claude_code, codex, gemini, cursor_agent, github_copilot")}`)}
275
+ ${row("pacework doctor", "Check this machine's setup")}
276
+ ${row("pacework triage [--once]", "Only triage, in the foreground")}
277
+ ${row("pacework up --token CODE", "One-step setup from the command in pacework's Runners page")}
278
+ ${row("pacework down", "Remove the background service")}
279
+
280
+ \x1b[1mRunner flags\x1b[0m ${d("for start, connect and up")}
281
+ --repo-root PATH --executor TOOL --name NAME --max-parallel-runs N --sandbox --no-triage
288
282
  `)
289
283
  process.exit(0)
290
284
  }
291
285
 
286
+ // ── account, AI tools, issues ─────────────────────────────────────────────────
287
+
288
+ if (["whoami", "issues", "issue", "open", "mcp"].includes(command)) {
289
+ try {
290
+ const api = await import("../lib/workspace-api.mjs")
291
+ if (command === "whoami") {
292
+ const session = api.currentSession()
293
+ await api.workspaceGet("/cli/issues?limit=1")
294
+ console.log(`\n ${session.userName ?? session.userEmail ?? "Signed in"}${session.userName && session.userEmail ? ` \x1b[2m${session.userEmail}\x1b[0m` : ""}`)
295
+ console.log(` workspace \x1b[1m${session.workspaceSlug ?? session.workspaceId}\x1b[0m`)
296
+ console.log(` server ${session.appUrl}`)
297
+ console.log(` key \x1b[2m${session.apiKey.slice(0, 12)}…\x1b[0m \x1b[32mvalid\x1b[0m\n`)
298
+ } else if (command === "issues") {
299
+ const { printIssues } = await import("../lib/issues-cli.mjs")
300
+ const status = parsedArgs.status && parsedArgs.status !== "true" ? parsedArgs.status : (restArgs.find((arg) => !arg.startsWith("--")) ?? "open")
301
+ await printIssues({ mine: Boolean(parsedArgs.mine), status, limit: Number(parsedArgs.limit) || 30 })
302
+ } else if (command === "issue") {
303
+ const identifier = restArgs.find((arg) => !arg.startsWith("--"))
304
+ if (!identifier) throw new Error("Which issue? For example: pacework issue ENG-42")
305
+ const { printIssue } = await import("../lib/issues-cli.mjs")
306
+ await printIssue(identifier)
307
+ } else if (command === "open") {
308
+ const { openInBrowser } = await import("../lib/login.mjs")
309
+ const url = api.workspaceUrl(restArgs.find((arg) => !arg.startsWith("--")))
310
+ console.log(openInBrowser(url) ? `Opened ${url}` : `Open ${url}`)
311
+ } else if (command === "mcp") {
312
+ const { runMcpCommand } = await import("../lib/mcp-cli.mjs")
313
+ const sub = restArgs[0] && !restArgs[0].startsWith("--") ? restArgs[0] : (process.stdin.isTTY ? "add" : "status")
314
+ process.exit(await runMcpCommand(sub, restArgs.slice(1).filter((arg) => !arg.startsWith("--")), parsedArgs))
315
+ }
316
+ process.exit(0)
317
+ } catch (error) {
318
+ console.error(`\x1b[31m${error instanceof Error ? error.message : error}\x1b[0m`)
319
+ process.exit(1)
320
+ }
321
+ }
322
+
292
323
  // ── login ─────────────────────────────────────────────────────────────────────
293
324
 
294
325
  if (command === "login" && process.stdin.isTTY && !parsedArgs["app-url"] && !parsedArgs["workspace-id"]) {
@@ -1403,7 +1434,7 @@ else if (command === "shell" || command === "sh") {
1403
1434
  console.log(cmd("use <executor>", "Switch executor"))
1404
1435
  console.log(cmd("rename <name>", "Set runner display name"))
1405
1436
  console.log(cmd("doctor", "Check all dependencies"))
1406
- console.log(cmd("update", "Upgrade pacework-runner"))
1437
+ console.log(cmd("update", "Upgrade pacework to the latest version"))
1407
1438
  console.log(cmd("login", "Authenticate via browser"))
1408
1439
  console.log(cmd("logout", "Revoke API key and clear credentials"))
1409
1440
  console.log(sec("SHELL"))
@@ -2452,7 +2483,7 @@ else if (command === "shell" || command === "sh") {
2452
2483
  const slug = config.workspaceSlug ?? config.workspaceId ?? ""
2453
2484
  const issueId = args[0]
2454
2485
  const url = issueId
2455
- ? (slug ? `${base}/${slug}/issues/${issueId.toUpperCase()}` : base)
2486
+ ? (slug ? `${base}/${slug}/issue/${issueId.toUpperCase()}` : base)
2456
2487
  : (slug ? `${base}/${slug}` : base)
2457
2488
  console.log(`Opening \x1b[36m${url}\x1b[0m`)
2458
2489
  const opener = process.platform === "darwin" ? "open" : process.platform === "win32" ? "start" : "xdg-open"
@@ -2463,13 +2494,13 @@ else if (command === "shell" || command === "sh") {
2463
2494
  case "update": {
2464
2495
  console.log("Checking for updates…")
2465
2496
  try {
2466
- const res = await fetch("https://registry.npmjs.org/pacework-runner/latest", { signal: AbortSignal.timeout(4000) })
2467
- const { version: latest } = await res.json()
2468
- if (latest === LOCAL_VERSION) {
2497
+ const latest = await latestPublishedVersion()
2498
+ if (!latest) throw new Error("no version")
2499
+ if (!isNewerVersion(latest, LOCAL_VERSION)) {
2469
2500
  console.log(`\x1b[32m✓\x1b[0m Already on latest (\x1b[1m${LOCAL_VERSION}\x1b[0m)`)
2470
2501
  } else {
2471
2502
  console.log(`Updating ${LOCAL_VERSION} → \x1b[1m${latest}\x1b[0m…`)
2472
- const child = spawn("npm", ["install", "-g", "pacework-runner"], { stdio: "inherit" })
2503
+ const child = spawn("npm", ["install", "-g", `${NPM_PACKAGE}@${latest}`], { stdio: "inherit" })
2473
2504
  await new Promise(r => child.on("exit", r))
2474
2505
  }
2475
2506
  } catch { console.log("\x1b[31mCould not reach npm registry.\x1b[0m") }
@@ -2636,7 +2667,7 @@ else if (command === "shell" || command === "sh") {
2636
2667
  { name: "open", desc: "Open workspace in browser" },
2637
2668
  { name: "config", desc: "View or set config values" },
2638
2669
  { name: "doctor", desc: "Check dependencies" },
2639
- { name: "update", desc: "Upgrade pacework-runner" },
2670
+ { name: "update", desc: "Upgrade pacework to the latest version" },
2640
2671
  { name: "login", desc: "Authenticate via browser" },
2641
2672
  { name: "logout", desc: "Revoke API key and clear credentials" },
2642
2673
  { name: "help", desc: "Show this help screen" },