automata-cli 0.1.0-feature-030-do-work.216 → 0.1.0-feature-030-do-work.218

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.
@@ -147,6 +147,9 @@ function ConfigWizard() {
147
147
  );
148
148
  const initialExecutorIndex = EXECUTOR_OPTIONS.findIndex((o) => o.value === existing.doWork?.executor);
149
149
  const [doWorkExecutorIndex, setDoWorkExecutorIndex] = useState(Math.max(initialExecutorIndex, 0));
150
+ const [doWorkProtectedBranches, setDoWorkProtectedBranches] = useState(
151
+ (existing.doWork?.protectedBranches ?? DEFAULT_DO_WORK.protectedBranches).join(", ")
152
+ );
150
153
  const [doWorkClaudeModel, setDoWorkClaudeModel] = useState(existing.doWork?.models?.claude ?? "");
151
154
  const [doWorkCodexModel, setDoWorkCodexModel] = useState(existing.doWork?.models?.codex ?? "");
152
155
  const [doWorkLockStale, setDoWorkLockStale] = useState(
@@ -246,9 +249,24 @@ function ConfigWizard() {
246
249
  },
247
250
  "do-work-base-branch": {
248
251
  setValue: setDoWorkBaseBranch,
249
- onSubmit: () => setScreen("do-work-executor"),
252
+ onSubmit: () => setScreen("do-work-protected-branches"),
250
253
  onBack: () => setScreen("main")
251
254
  },
255
+ "do-work-protected-branches": {
256
+ setValue: (update) => {
257
+ setValidationError("");
258
+ setDoWorkProtectedBranches(update);
259
+ },
260
+ onSubmit: () => {
261
+ if (parseAllowedUsers(doWorkProtectedBranches).length === 0) {
262
+ setValidationError("Enter at least one branch name.");
263
+ return;
264
+ }
265
+ setValidationError("");
266
+ setScreen("do-work-executor");
267
+ },
268
+ onBack: () => setScreen("do-work-base-branch")
269
+ },
252
270
  "do-work-claude-model": {
253
271
  setValue: setDoWorkClaudeModel,
254
272
  onSubmit: () => setScreen("do-work-codex-model"),
@@ -293,6 +311,7 @@ function ConfigWizard() {
293
311
  doWork: {
294
312
  ...current.doWork,
295
313
  baseBranch: doWorkBaseBranch.trim() || void 0,
314
+ protectedBranches: parseAllowedUsers(doWorkProtectedBranches),
296
315
  executor: EXECUTOR_OPTIONS[doWorkExecutorIndex].value,
297
316
  models: {
298
317
  claude: doWorkClaudeModel.trim() || void 0,
@@ -375,7 +394,7 @@ function ConfigWizard() {
375
394
  length: EXECUTOR_OPTIONS.length,
376
395
  setIndex: setDoWorkExecutorIndex,
377
396
  onSelect: () => setScreen("do-work-claude-model"),
378
- onBack: () => setScreen("do-work-base-branch")
397
+ onBack: () => setScreen("do-work-protected-branches")
379
398
  }
380
399
  };
381
400
  useInput((input, key) => {
@@ -439,6 +458,12 @@ function ConfigWizard() {
439
458
  value: doWorkBaseBranch,
440
459
  hint: `Type branch \xB7 Enter to continue \xB7 ${BACK}`
441
460
  },
461
+ "do-work-protected-branches": {
462
+ title: "Do Work \u2014 Protected Branches",
463
+ label: "Branches a build turn must never push to (comma separated):",
464
+ value: doWorkProtectedBranches,
465
+ hint: `Type branches \xB7 Enter to continue \xB7 ${BACK}`
466
+ },
442
467
  "do-work-claude-model": {
443
468
  title: "Do Work \u2014 Claude Model",
444
469
  label: "Default model when the executor is Claude (blank = the executor's own default):",
package/dist/index.js CHANGED
@@ -109,6 +109,16 @@ var configSetDoWorkBaseBranch = new Command("do-work-base-branch").description("
109
109
  process.stdout.write(`do-work base branch set to: ${branch}
110
110
  `);
111
111
  });
112
+ var configSetDoWorkProtectedBranches = new Command("do-work-protected-branches").description("Set the branches a `do-work` build turn must never check out and push to").argument("<value>", `Comma-separated branch names (default: ${DEFAULT_DO_WORK.protectedBranches.join(",")})`).action((value) => {
113
+ const branches = value.split(",").map((branch) => branch.trim()).filter((branch) => branch.length > 0);
114
+ if (branches.length === 0) {
115
+ process.stderr.write("Error: do-work-protected-branches requires at least one branch name.\n");
116
+ process.exit(1);
117
+ }
118
+ writeDoWork({ protectedBranches: branches });
119
+ process.stdout.write(`do-work protected branches set to: ${branches.join(", ")}
120
+ `);
121
+ });
112
122
  var configSetDoWorkExecutor = new Command("do-work-executor").description("Set the default executor `do-work` invokes").argument("<value>", `Executor: ${VALID_EXECUTORS.join(", ")}`).action((value) => {
113
123
  if (!VALID_EXECUTORS.includes(value)) {
114
124
  process.stderr.write(`Error: invalid executor "${value}". Must be one of: ${VALID_EXECUTORS.join(", ")}
@@ -179,12 +189,12 @@ var configSetDoWorkPrompt = new Command("do-work-prompt").description("Set the t
179
189
  process.stdout.write(`do-work ${turnKind} prompt set.
180
190
  `);
181
191
  });
182
- var configSet = new Command("set").description("Set a configuration value").addCommand(configSetType).addCommand(configSetIssueDiscoveryTechnique).addCommand(configSetIssueDiscoveryValue).addCommand(configSetClaudeSystemPrompt).addCommand(configSetAllowedUsers).addCommand(configSetAgentUser).addCommand(configSetDoWorkBaseBranch).addCommand(configSetDoWorkExecutor).addCommand(configSetDoWorkModel).addCommand(configSetDoWorkMaxRuns).addCommand(configSetDoWorkLockStaleMinutes).addCommand(configSetDoWorkPrompt);
192
+ var configSet = new Command("set").description("Set a configuration value").addCommand(configSetType).addCommand(configSetIssueDiscoveryTechnique).addCommand(configSetIssueDiscoveryValue).addCommand(configSetClaudeSystemPrompt).addCommand(configSetAllowedUsers).addCommand(configSetAgentUser).addCommand(configSetDoWorkBaseBranch).addCommand(configSetDoWorkProtectedBranches).addCommand(configSetDoWorkExecutor).addCommand(configSetDoWorkModel).addCommand(configSetDoWorkMaxRuns).addCommand(configSetDoWorkLockStaleMinutes).addCommand(configSetDoWorkPrompt);
183
193
  var configCommand = new Command("config").description("Configure automata settings").addCommand(configSet).action(async () => {
184
194
  const [{ render }, React, { ConfigWizard }] = await Promise.all([
185
195
  import("ink"),
186
196
  import("react"),
187
- import("./ConfigWizard-O25ZZT5R.js")
197
+ import("./ConfigWizard-5B5AOGUU.js")
188
198
  ]);
189
199
  const { waitUntilExit } = render(React.createElement(ConfigWizard));
190
200
  await waitUntilExit();
@@ -3024,7 +3034,7 @@ function makeHandle(path, token) {
3024
3034
  }
3025
3035
  };
3026
3036
  }
3027
- function write(path, command, token, flag = "wx") {
3037
+ function publishLock(path, command, token) {
3028
3038
  const owner = {
3029
3039
  pid: process.pid,
3030
3040
  startedAt: (/* @__PURE__ */ new Date()).toISOString(),
@@ -3033,17 +3043,31 @@ function write(path, command, token, flag = "wx") {
3033
3043
  token,
3034
3044
  pidStartedAt: processStartedAt(process.pid) ?? void 0
3035
3045
  };
3036
- writeFileSync(path, JSON.stringify(owner, null, 2) + "\n", { encoding: "utf8", flag });
3046
+ const staging = `${path}.staging.${token}`;
3047
+ try {
3048
+ writeFileSync(staging, JSON.stringify(owner, null, 2) + "\n", { encoding: "utf8", flag: "wx" });
3049
+ } catch {
3050
+ return false;
3051
+ }
3052
+ try {
3053
+ linkSync(staging, path);
3054
+ return true;
3055
+ } catch (err) {
3056
+ if (err.code !== "EEXIST") throw err;
3057
+ return false;
3058
+ } finally {
3059
+ try {
3060
+ unlinkSync(staging);
3061
+ } catch {
3062
+ }
3063
+ }
3037
3064
  }
3038
3065
  function acquireRunLock(command, staleMinutes) {
3039
3066
  const path = lockPath();
3040
3067
  const token = randomUUID();
3041
3068
  mkdirSync(join2(process.cwd(), LOCK_DIR), { recursive: true });
3042
- try {
3043
- write(path, command, token);
3069
+ if (publishLock(path, command, token)) {
3044
3070
  return { ok: true, handle: makeHandle(path, token) };
3045
- } catch (err) {
3046
- if (err.code !== "EEXIST") throw err;
3047
3071
  }
3048
3072
  const owner = readOwner(path);
3049
3073
  if (!isStale(owner, staleMinutes)) {
@@ -3145,10 +3169,9 @@ function reclaim(path, command, token, expected) {
3145
3169
  }
3146
3170
  const claimed = `${path}.stale.${token}`;
3147
3171
  try {
3148
- write(path, command, token, "wx");
3149
- return { ok: true, handle: makeHandle(path, token) };
3150
- } catch (err) {
3151
- if (err.code !== "EEXIST") throw err;
3172
+ if (publishLock(path, command, token)) {
3173
+ return { ok: true, handle: makeHandle(path, token) };
3174
+ }
3152
3175
  return { ok: false, heldBy: readOwner(path) ?? UNKNOWN_OWNER, suspect: false };
3153
3176
  } finally {
3154
3177
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "automata-cli",
3
- "version": "0.1.0-feature-030-do-work.216",
3
+ "version": "0.1.0-feature-030-do-work.218",
4
4
  "description": "Automata CLI tool",
5
5
  "type": "module",
6
6
  "bin": {