@tryarcanist/cli 0.1.343 → 0.1.344

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.
package/README.md CHANGED
@@ -128,7 +128,7 @@ arcanist environments prepare --wait --json
128
128
  arcanist environments prepare owner/repo --wait --poll-interval 5000 --json
129
129
  ```
130
130
 
131
- Agents should follow `repository.nextAction` and request a Zeus review only when it is `review`. `--wait` waits through internal handoffs until setup is ready or there is a real action for the user or Arcanist.
131
+ Agents should follow `repository.nextAction` and `repository.command`. Request a Zeus review only when `nextAction` is `review`. When `command` is `null`, do not invent an API call; surface `question` / `secretRequest` to a human. `--wait` waits through internal handoffs until setup is ready or there is a real action for the user or Arcanist.
132
132
 
133
133
  ### `arcanist environments status`
134
134
 
@@ -139,7 +139,7 @@ arcanist environments status owner/repo --json
139
139
  arcanist environments status owner/repo --wait --poll-interval 5000 --json
140
140
  ```
141
141
 
142
- Agents should follow `repository.nextAction` and request a Zeus review only when it is `review`. `--wait` waits through internal handoffs until setup is ready or there is a real action for the user or Arcanist.
142
+ Agents should follow `repository.nextAction` and `repository.command`. Request a Zeus review only when `nextAction` is `review`. When `command` is `null`, do not invent an API call; surface `question` / `secretRequest` to a human. `--wait` waits through internal handoffs until setup is ready or there is a real action for the user or Arcanist.
143
143
 
144
144
  ### `arcanist environments retry`
145
145
 
@@ -171,7 +171,7 @@ printf "arc_..." | arcanist auth login --token-stdin
171
171
  arcanist auth login --api-url https://api.tryarcanist.com
172
172
  ```
173
173
 
174
- The default flow prints a browser authorization URL and waits for human approval. `--json` writes the action immediately as JSONL on stderr and writes one final result to stdout. `ARCANIST_TOKEN` authenticates later commands through the same config loader as `~/.arcanist/config.json`. `arcanist auth login --token-stdin` or `--token` persists a token for later use.
174
+ The default flow prints a browser authorization URL and waits for human approval. `--json` writes the action immediately as JSONL on stderr and writes one final result to stdout. `ARCANIST_TOKEN` authenticates later commands through the same config loader as `~/.arcanist/config.json`. `arcanist auth login --token-stdin`, `--token`, or `ARCANIST_TOKEN` persists a token for later use.
175
175
 
176
176
  ### `arcanist auth whoami`
177
177
 
package/dist/index.js CHANGED
@@ -7409,7 +7409,7 @@ function isTerminalPhase(phase, _sessionKind) {
7409
7409
  // package.json
7410
7410
  var package_default = {
7411
7411
  name: "@tryarcanist/cli",
7412
- version: "0.1.343",
7412
+ version: "0.1.344",
7413
7413
  description: "Command-line interface for Arcanist: inspect sessions, prepare Zeus environments, and trigger reviews",
7414
7414
  type: "module",
7415
7415
  bin: {
@@ -23149,11 +23149,33 @@ async function fetchSetupState(config2, fullName) {
23149
23149
  status: "not_started",
23150
23150
  stage: null
23151
23151
  };
23152
- return { ...state, nextAction: nextAction(state) };
23152
+ const action = nextAction(state);
23153
+ return { ...state, nextAction: action, command: commandForNextAction(action, state.fullName) };
23153
23154
  }
23154
23155
  function isActive(state) {
23155
23156
  return state.nextAction === "wait";
23156
23157
  }
23158
+ function commandForNextAction(action, fullName) {
23159
+ switch (action) {
23160
+ case "prepare":
23161
+ return `arcanist environments prepare ${fullName}`;
23162
+ case "wait":
23163
+ return `arcanist environments status ${fullName} --wait`;
23164
+ case "retry":
23165
+ return `arcanist environments retry ${fullName}`;
23166
+ case "review":
23167
+ return null;
23168
+ case "add_credentials":
23169
+ case "answer_question":
23170
+ case "authorize_github":
23171
+ case "wait_for_arcanist":
23172
+ return null;
23173
+ default: {
23174
+ const _exhaustive = action;
23175
+ return _exhaustive;
23176
+ }
23177
+ }
23178
+ }
23157
23179
  function nextAction(state) {
23158
23180
  if (state.status === "not_started") return "prepare";
23159
23181
  if (state.status === "ready") return "review";
@@ -23219,11 +23241,13 @@ async function environmentPrepareCommand(repoArg, options = {}, command) {
23219
23241
  emit(command, options, { repository: state2 }, ({ repository }) => printState(repository));
23220
23242
  return;
23221
23243
  }
23244
+ const action = result.status === "already_ready" ? "review" : "wait";
23222
23245
  const state = {
23223
23246
  fullName: result.fullName,
23224
23247
  status: result.status === "already_ready" ? "ready" : "pending",
23225
23248
  stage: null,
23226
- nextAction: result.status === "already_ready" ? "review" : "wait"
23249
+ nextAction: action,
23250
+ command: commandForNextAction(action, result.fullName)
23227
23251
  };
23228
23252
  emit(command, options, { repository: state }, ({ repository }) => printState(repository));
23229
23253
  }
@@ -23259,11 +23283,12 @@ var DEVICE_AUTH_TOKEN_PATH = "/api/auth/cli/device/token";
23259
23283
  async function loginCommand(options, command) {
23260
23284
  const runtime = getRuntimeOptions(command, options);
23261
23285
  const apiUrl = resolveLoginApiUrl(runtime.apiUrl);
23286
+ const envOrFlag = resolveEnvOrFlagConfig(runtime, false);
23262
23287
  let token = null;
23263
23288
  if (options.tokenStdin) {
23264
23289
  token = await readStdinTrimmed();
23265
- } else if (runtime.token) {
23266
- token = runtime.token;
23290
+ } else if (envOrFlag?.token) {
23291
+ token = envOrFlag.token;
23267
23292
  } else {
23268
23293
  token = await loginWithDeviceAuthorization(apiUrl, runtime);
23269
23294
  }
@@ -27021,7 +27046,13 @@ async function setupCommand(repoArgs = [], options = {}, command) {
27021
27046
  }
27022
27047
  const runtime = getRuntimeOptions(command, options);
27023
27048
  let config2 = loadConfig(runtime);
27024
- if (!config2) config2 = await loginCommand({ ...runtime, emitResult: false }, command);
27049
+ if (!config2) {
27050
+ const envOrFlag = resolveEnvOrFlagConfig(runtime, false);
27051
+ if ((process.stdin.isTTY !== true || process.stdout.isTTY !== true) && !envOrFlag?.token) {
27052
+ throw new CliError("auth", "Not logged in.", { hint: "Run `arcanist auth login` or set `ARCANIST_TOKEN`." });
27053
+ }
27054
+ config2 = await loginCommand({ ...runtime, emitResult: false }, command);
27055
+ }
27025
27056
  const requested = repoArgs.map((value) => {
27026
27057
  const repo = parseRepoArg(value);
27027
27058
  return `${repo.owner}/${repo.repo}`;
@@ -27163,7 +27194,7 @@ function emitSetupAction(runtime, action) {
27163
27194
  `);
27164
27195
  }
27165
27196
  function trackingCommands(repositories) {
27166
- return repositories.map((repository) => `Track later: arcanist environments status ${repository} --wait`);
27197
+ return repositories.map((repository) => `Track later: ${commandForNextAction("wait", repository)}`);
27167
27198
  }
27168
27199
 
27169
27200
  // src/commands/stop.ts
@@ -27603,7 +27634,8 @@ environments.command("status").description("Show repository environment setup st
27603
27634
  "after",
27604
27635
  `
27605
27636
  JSON:
27606
- Returns {repository: {fullName, status, stage, nextAction, buildStatus?, failureReason?, secretRequest?, question?}}.
27637
+ Returns {repository: {fullName, status, stage, nextAction, command, buildStatus?, failureReason?, secretRequest?, question?}}.
27638
+ command is the CLI argv to run, or null when the next step is the web UI or Arcanist.
27607
27639
  The stable status values are not_started, pending, running, escalated, succeeded, failed, and ready.
27608
27640
  `
27609
27641
  ).action((repo, options, command) => environmentStatusCommand(repo, options, command));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tryarcanist/cli",
3
- "version": "0.1.343",
3
+ "version": "0.1.344",
4
4
  "description": "Command-line interface for Arcanist: inspect sessions, prepare Zeus environments, and trigger reviews",
5
5
  "type": "module",
6
6
  "bin": {