anywhere-ai 0.0.4 → 0.0.6

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.
Files changed (2) hide show
  1. package/dist/cli.js +20 -11
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -50,29 +50,38 @@ function isClaudeAuthed() {
50
50
  return false;
51
51
  }
52
52
  }
53
- function ensureClaudeAuth() {
53
+ async function ensureClaudeAuth() {
54
54
  if (!isClaudeInstalled()) {
55
55
  console.error("Claude Code CLI not found.");
56
56
  console.error("Install it: npm install -g @anthropic-ai/claude-code");
57
57
  console.error("Then run: claude auth login");
58
58
  process.exit(1);
59
59
  }
60
+ const config2 = JSON.parse(readFileSync(CONFIG_PATH, "utf-8"));
61
+ if (config2.claudeOAuthToken && !process.env.CLAUDE_CODE_OAUTH_TOKEN) {
62
+ process.env.CLAUDE_CODE_OAUTH_TOKEN = config2.claudeOAuthToken;
63
+ }
60
64
  if (isClaudeAuthed()) {
61
65
  console.log("Claude Code authenticated");
62
66
  return;
63
67
  }
64
- console.log("Claude Code not authenticated. Launching claude auth login...");
65
- const result = spawnSync("claude", ["auth", "login"], {
66
- stdio: "inherit"
68
+ console.log("\nClaude Code not authenticated. Running setup-token...\n");
69
+ const result = spawnSync("claude", ["setup-token"], {
70
+ stdio: ["inherit", "pipe", "inherit"],
71
+ encoding: "utf-8"
67
72
  });
68
- if (result.status !== 0) {
69
- console.error("Claude auth login failed");
70
- process.exit(1);
71
- }
72
- if (!isClaudeAuthed()) {
73
- console.error("Claude Code still not authenticated after login.");
73
+ const output = result.stdout || "";
74
+ const match = output.match(/(sk-ant-\S+)/);
75
+ if (!match) {
76
+ console.error("Could not extract token from setup-token output.");
77
+ console.error("Run `claude setup-token` manually and set CLAUDE_CODE_OAUTH_TOKEN.");
74
78
  process.exit(1);
75
79
  }
80
+ const token = match[1];
81
+ config2.claudeOAuthToken = token;
82
+ await fs.writeFile(CONFIG_PATH, JSON.stringify(config2, null, 2));
83
+ process.env.CLAUDE_CODE_OAUTH_TOKEN = token;
84
+ console.log("Claude Code authenticated (token saved)");
76
85
  }
77
86
  function isGhInstalled() {
78
87
  try {
@@ -146,7 +155,7 @@ async function ensureGhAuth() {
146
155
  }
147
156
  await fs.mkdir(ANYWHERE_DIR, { recursive: true });
148
157
  await createConfigFile();
149
- ensureClaudeAuth();
158
+ await ensureClaudeAuth();
150
159
  ensureGhInstalled();
151
160
  await ensureGhAuth();
152
161
  var config = JSON.parse(readFileSync(CONFIG_PATH, "utf-8"));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "anywhere-ai",
3
- "version": "0.0.4",
3
+ "version": "0.0.6",
4
4
  "type": "module",
5
5
  "description": "Code on any repo from your phone",
6
6
  "bin": {