pacework 1.4.2 → 1.5.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.
@@ -274,11 +274,12 @@ ${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
275
  ${row("pacework doctor", "Check this machine's setup")}
276
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")}
277
+ ${row("pacework up --token CODE", "One-step setup from the command in pacework's Runners page; asks for the runner's name and model")}
278
278
  ${row("pacework down", "Remove the background service")}
279
279
 
280
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
281
+ --repo-root PATH --executor TOOL --name NAME --model ID --max-parallel-runs N --sandbox --no-triage
282
+ ${d("--model: empty for the tool's latest default; Claude Code also takes opus, sonnet or haiku for the newest of each")}
282
283
  `)
283
284
  process.exit(0)
284
285
  }
@@ -489,6 +490,7 @@ if (command === "config") {
489
490
  const KEY_ALIASES = {
490
491
  "executor": "executor",
491
492
  "name": "runnerName",
493
+ "model": "model",
492
494
  "runner-name": "runnerName",
493
495
  "repo-root": "repoRoot",
494
496
  "app-url": "appUrl",
@@ -713,6 +715,9 @@ function buildRunnerArgs(extraArgs) {
713
715
  "--executor", executor,
714
716
  ]
715
717
  if (runnerName) base.push("--name", runnerName)
718
+ // The model chosen at `pacework up`; empty means the tool's own current default.
719
+ const model = parsedArgs["model"] !== undefined && parsedArgs["model"] !== "true" ? String(parsedArgs["model"]) : config.model
720
+ if (model) base.push("--model-preferences", model)
716
721
  const maxParallelRuns = parsedArgs["max-parallel-runs"] || config.maxParallelRuns
717
722
  if (maxParallelRuns) base.push("--max-parallel-runs", String(maxParallelRuns))
718
723
  const sandbox = parsedArgs.sandbox !== undefined
@@ -720,7 +725,7 @@ function buildRunnerArgs(extraArgs) {
720
725
  : config.sandbox === true
721
726
  if (sandbox) base.push("--sandbox", "true")
722
727
 
723
- const consumed = new Set(["app-url", "workspace-id", "workspace-api-key", "repo-root", "executor", "name", "max-parallel-runs", "token", "sandbox"])
728
+ const consumed = new Set(["app-url", "workspace-id", "workspace-api-key", "repo-root", "executor", "name", "model", "yes", "max-parallel-runs", "token", "sandbox"])
724
729
  for (let i = 0; i < extraArgs.length; i++) {
725
730
  const arg = extraArgs[i]
726
731
  if (arg.startsWith("--")) {
@@ -3058,13 +3063,43 @@ else if (command === "up") {
3058
3063
 
3059
3064
  config.executor = executor
3060
3065
  config.repoRoot = repoRoot
3061
- config.runnerName = (parsedArgs.name && parsedArgs.name !== "true") ? parsedArgs.name : (config.runnerName || `${os.hostname().replace(/\.local$/, "")} · ${executorLabel(executor)}`)
3066
+ const defaultName = config.runnerName || `${os.hostname().replace(/\.local$/, "")} · ${executorLabel(executor)}`
3067
+ const namedByFlag = parsedArgs.name && parsedArgs.name !== "true"
3068
+ const modelByFlag = parsedArgs.model !== undefined && parsedArgs.model !== "true"
3069
+ // In a terminal, ask for the name and the model; flags and pipes keep the defaults.
3070
+ if (process.stdin.isTTY && !parsedArgs.yes && (!namedByFlag || !modelByFlag)) {
3071
+ const prompt = await import("@clack/prompts")
3072
+ const { CUSTOM_MODEL, modelChoices } = await import("../lib/models.mjs")
3073
+ const answered = (value) => {
3074
+ if (prompt.isCancel(value)) { prompt.cancel("Nothing changed."); process.exit(0) }
3075
+ return value
3076
+ }
3077
+ if (!namedByFlag) {
3078
+ const typed = answered(await prompt.text({ message: "Name this runner", initialValue: defaultName, placeholder: defaultName }))
3079
+ config.runnerName = String(typed || "").trim() || defaultName
3080
+ }
3081
+ if (!modelByFlag) {
3082
+ const picked = answered(await prompt.select({
3083
+ message: `Which model should ${executorLabel(executor)} use?`,
3084
+ options: modelChoices(executor, config.model).map(({ value, label, hint }) => ({ value, label, hint })),
3085
+ initialValue: config.model ?? "",
3086
+ }))
3087
+ config.model = picked === CUSTOM_MODEL
3088
+ ? String(answered(await prompt.text({ message: "Model id", placeholder: executor === "codex" ? "gpt-5.4" : "a model id the tool accepts" })) || "").trim()
3089
+ : picked
3090
+ }
3091
+ }
3092
+ if (namedByFlag) config.runnerName = parsedArgs.name
3093
+ else if (!config.runnerName) config.runnerName = defaultName
3094
+ if (modelByFlag) config.model = String(parsedArgs.model).trim()
3062
3095
  // Gemini and Cursor share one config file per machine, so one run at a time.
3063
3096
  const singleRun = executor === "gemini" || executor === "cursor_agent"
3064
3097
  config.maxParallelRuns = singleRun ? 1 : Number(parsedArgs["max-parallel-runs"]) || config.maxParallelRuns || 2
3065
3098
  if (parsedArgs.sandbox !== undefined) config.sandbox = !["false", "0", "no"].includes(String(parsedArgs.sandbox))
3066
3099
  writeConfig(config)
3067
3100
  console.log(` runner \x1b[1m${config.runnerName}\x1b[0m (${config.maxParallelRuns} at a time${config.sandbox ? ", sandboxed" : ""})`)
3101
+ const { modelLabel } = await import("../lib/models.mjs")
3102
+ console.log(` model ${modelLabel(executor, config.model)}`)
3068
3103
 
3069
3104
  // 4. Replace any runner already going on this machine.
3070
3105
  if (isServiceInstalled()) stopService()
@@ -48,9 +48,42 @@ export const SERVICES = {
48
48
  },
49
49
  }
50
50
 
51
- /** The install command a repository's lockfile implies, or null when there is none to run. */
51
+ const JS_INSTALL = {
52
+ pnpm: "pnpm install --frozen-lockfile",
53
+ yarn: "yarn install --frozen-lockfile",
54
+ }
55
+
56
+ /** The package manager package.json declares ("pnpm@11.14.0+sha…" → "pnpm"), or null. */
57
+ function declaredPackageManager(dir) {
58
+ try {
59
+ const pkg = JSON.parse(fs.readFileSync(path.join(dir, "package.json"), "utf8"))
60
+ const name = String(pkg.packageManager ?? "").split("@")[0]
61
+ return JS_INSTALL[name] ? name : null
62
+ } catch {
63
+ return null
64
+ }
65
+ }
66
+
67
+ /**
68
+ * The install command a repository's lockfile implies, or null when there is none to run.
69
+ *
70
+ * The package manager package.json declares wins over a stray lockfile of another
71
+ * one. A repository that keeps its lockfiles one level down (frontend/, backend/)
72
+ * installs in each of those folders.
73
+ */
52
74
  export function detectSetupCommand(dir) {
53
75
  const has = (file) => fs.existsSync(path.join(dir, file))
76
+ const declared = declaredPackageManager(dir)
77
+ if (declared) {
78
+ const lockfile = declared === "pnpm" ? "pnpm-lock.yaml" : "yarn.lock"
79
+ if (has(lockfile)) return `corepack enable && ${JS_INSTALL[declared]}`
80
+ const folders = fs.readdirSync(dir, { withFileTypes: true })
81
+ .filter((entry) => entry.isDirectory() && !entry.name.startsWith(".") && entry.name !== "node_modules")
82
+ .map((entry) => entry.name)
83
+ .filter((name) => fs.existsSync(path.join(dir, name, lockfile)))
84
+ .sort()
85
+ if (folders.length) return `corepack enable && ${folders.map((name) => `(cd ${name} && ${JS_INSTALL[declared]})`).join(" && ")}`
86
+ }
54
87
  if (has("pnpm-lock.yaml")) return "corepack enable && pnpm install --frozen-lockfile"
55
88
  if (has("yarn.lock")) return "corepack enable && yarn install --frozen-lockfile"
56
89
  if (has("bun.lockb") || has("bun.lock")) return "npx -y bun install --frozen-lockfile"
package/lib/models.mjs ADDED
@@ -0,0 +1,36 @@
1
+ import { executorLabel } from "./executors.mjs"
2
+
3
+ /** The answer meaning "type another model id". */
4
+ export const CUSTOM_MODEL = "__custom__"
5
+
6
+ /**
7
+ * Model choices offered when a runner starts. "" means the tool's own current
8
+ * default, which moves forward whenever the tool updates. Claude Code's family
9
+ * aliases always resolve to the newest model in that family, so they never go
10
+ * stale the way a pinned id does.
11
+ */
12
+ export function modelChoices(executor, savedModel = "") {
13
+ const tool = executorLabel(executor)
14
+ const choices = [{ value: "", label: "Latest", hint: `whatever ${tool} uses by default; updates with ${tool}` }]
15
+ if (executor === "claude_code") {
16
+ choices.push(
17
+ { value: "opus", label: "Opus", hint: "always the newest Opus" },
18
+ { value: "sonnet", label: "Sonnet", hint: "always the newest Sonnet" },
19
+ { value: "haiku", label: "Haiku", hint: "always the newest Haiku" },
20
+ )
21
+ }
22
+ const saved = String(savedModel || "").trim()
23
+ if (saved && !choices.some((choice) => choice.value === saved)) {
24
+ choices.push({ value: saved, label: saved, hint: "used before" })
25
+ }
26
+ choices.push({ value: CUSTOM_MODEL, label: "Another model…", hint: "type its id" })
27
+ return choices
28
+ }
29
+
30
+ /** How a saved model reads in the summary. */
31
+ export function modelLabel(executor, model) {
32
+ const value = String(model || "").trim()
33
+ if (!value) return `latest (${executorLabel(executor)} default)`
34
+ if (executor === "claude_code" && ["opus", "sonnet", "haiku"].includes(value)) return `newest ${value[0].toUpperCase()}${value.slice(1)}`
35
+ return value
36
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pacework",
3
- "version": "1.4.2",
3
+ "version": "1.5.0",
4
4
  "description": "pacework CLI: connect this machine as a runner for pacework AI agents",
5
5
  "type": "module",
6
6
  "bin": {