astracode-agent 0.5.0 → 0.5.2

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
@@ -15,6 +15,18 @@ It works on macOS and Linux, on arm64 and x64. It checks the download's
15
15
  checksum, and on a Mac also checks that AstraCode signed it. To update, run
16
16
  `astracode-agent update`, which runs the same installer for the latest version.
17
17
 
18
+ On Windows, x64 or arm64, in PowerShell:
19
+
20
+ ```powershell
21
+ irm https://astracode.io/install.ps1 | iex
22
+ ```
23
+
24
+ That puts `astracode-agent.exe` in `%USERPROFILE%\.local\bin`, checks the
25
+ download's checksum, and adds the folder to your user PATH, with no
26
+ administrator rights. `$env:ASTRACODE_VERSION` pins a version and
27
+ `$env:ASTRACODE_BIN_DIR` picks another folder, as they do for `install.sh`.
28
+ `astracode-agent update` runs this installer on Windows.
29
+
18
30
  With Homebrew, on macOS or Linux:
19
31
 
20
32
  ```bash
@@ -55,7 +55,7 @@ var init_define_ASTRACODE_BUNDLED_SKILLS = __esm({
55
55
  var require_shim_vscode = __commonJS({
56
56
  "../packaging/bench/shim-vscode.js"(exports2, module2) {
57
57
  init_define_ASTRACODE_BUNDLED_SKILLS();
58
- var fs54 = require("node:fs");
58
+ var fs55 = require("node:fs");
59
59
  var path63 = require("node:path");
60
60
  function root2() {
61
61
  const r = process.env.ASTRACODE_BENCH_ROOT;
@@ -72,7 +72,7 @@ var require_shim_vscode = __commonJS({
72
72
  if (!dir) return false;
73
73
  let base = path63.resolve(dir);
74
74
  try {
75
- base = fs54.realpathSync(base);
75
+ base = fs55.realpathSync(base);
76
76
  } catch {
77
77
  }
78
78
  return full.startsWith(base + path63.sep);
@@ -114,7 +114,7 @@ var require_shim_vscode = __commonJS({
114
114
  return new RegExp(`^${re}$`);
115
115
  }
116
116
  function walk5(dir, out2 = []) {
117
- for (const e of fs54.readdirSync(dir, { withFileTypes: true })) {
117
+ for (const e of fs55.readdirSync(dir, { withFileTypes: true })) {
118
118
  if (e.name === "node_modules" || e.name === ".git" || e.name === "dist") continue;
119
119
  const full = path63.join(dir, e.name);
120
120
  if (e.isDirectory()) walk5(full, out2);
@@ -238,7 +238,7 @@ var require_shim_vscode = __commonJS({
238
238
  return out2;
239
239
  },
240
240
  openTextDocument: async (u) => {
241
- const text2 = fs54.existsSync(u.fsPath) ? fs54.readFileSync(u.fsPath, "utf8") : "";
241
+ const text2 = fs55.existsSync(u.fsPath) ? fs55.readFileSync(u.fsPath, "utf8") : "";
242
242
  const lines2 = text2.split("\n");
243
243
  return {
244
244
  uri: u,
@@ -259,10 +259,10 @@ var require_shim_vscode = __commonJS({
259
259
  },
260
260
  applyEdit: async (edit) => {
261
261
  for (const op of edit.ops) {
262
- if (op.kind === "delete") fs54.rmSync(op.path, { force: true });
262
+ if (op.kind === "delete") fs55.rmSync(op.path, { force: true });
263
263
  else {
264
- fs54.mkdirSync(path63.dirname(op.path), { recursive: true });
265
- fs54.writeFileSync(op.path, op.text, "utf8");
264
+ fs55.mkdirSync(path63.dirname(op.path), { recursive: true });
265
+ fs55.writeFileSync(op.path, op.text, "utf8");
266
266
  UNSAVED.add(op.path);
267
267
  }
268
268
  }
@@ -289,7 +289,7 @@ var require_shim_vscode = __commonJS({
289
289
  */
290
290
  readFile: async (u) => {
291
291
  try {
292
- return fs54.readFileSync(u.fsPath);
292
+ return fs55.readFileSync(u.fsPath);
293
293
  } catch (err2) {
294
294
  if (err2 && err2.code === "ENOENT") {
295
295
  const e = new Error(`file not found: ${u.fsPath}`);
@@ -313,20 +313,20 @@ var require_shim_vscode = __commonJS({
313
313
  * would break the caller that relies on exactly that.
314
314
  */
315
315
  createDirectory: async (u) => {
316
- fs54.mkdirSync(u.fsPath, { recursive: true });
316
+ fs55.mkdirSync(u.fsPath, { recursive: true });
317
317
  },
318
318
  writeFile: async (u, data) => {
319
319
  if (inTranscripts(u.fsPath)) throw new Error(`refusing to write ${u.fsPath}: transcripts are read-only`);
320
- fs54.mkdirSync(path63.dirname(u.fsPath), { recursive: true });
321
- fs54.writeFileSync(u.fsPath, Buffer.from(data));
320
+ fs55.mkdirSync(path63.dirname(u.fsPath), { recursive: true });
321
+ fs55.writeFileSync(u.fsPath, Buffer.from(data));
322
322
  },
323
323
  stat: async (u) => {
324
- const st = fs54.statSync(u.fsPath);
324
+ const st = fs55.statSync(u.fsPath);
325
325
  return { type: st.isDirectory() ? 2 : 1, size: st.size };
326
326
  },
327
327
  delete: async (u) => {
328
328
  if (inTranscripts(u.fsPath)) throw new Error(`refusing to delete ${u.fsPath}: transcripts are read-only`);
329
- fs54.rmSync(u.fsPath, { force: true, recursive: true });
329
+ fs55.rmSync(u.fsPath, { force: true, recursive: true });
330
330
  }
331
331
  },
332
332
  onDidChangeVisibleTextEditors: () => ({ dispose() {
@@ -1425,12 +1425,12 @@ function redactSensitive(body2) {
1425
1425
  async function checkCredentialsFileSafety(path63, onWarn = (m) => console.warn(`anthropic-sdk: ${m}`)) {
1426
1426
  if (typeof process === "undefined" || process.platform === "win32")
1427
1427
  return;
1428
- const fs54 = await import("node:fs");
1428
+ const fs55 = await import("node:fs");
1429
1429
  let resolved = path63;
1430
1430
  let st;
1431
1431
  try {
1432
- resolved = await fs54.promises.realpath(path63);
1433
- st = await fs54.promises.stat(resolved);
1432
+ resolved = await fs55.promises.realpath(path63);
1433
+ st = await fs55.promises.stat(resolved);
1434
1434
  } catch {
1435
1435
  return;
1436
1436
  }
@@ -1446,27 +1446,27 @@ async function checkCredentialsFileSafety(path63, onWarn = (m) => console.warn(`
1446
1446
  }
1447
1447
  }
1448
1448
  async function writeCredentialsFileAtomic(targetPath, data) {
1449
- const fs54 = await import("node:fs");
1449
+ const fs55 = await import("node:fs");
1450
1450
  const path63 = await import("node:path");
1451
1451
  const dir = path63.dirname(targetPath);
1452
- await fs54.promises.mkdir(dir, { recursive: true, mode: 448 });
1452
+ await fs55.promises.mkdir(dir, { recursive: true, mode: 448 });
1453
1453
  const tmpPath = `${targetPath}.${process.pid}.${Math.random().toString(36).slice(2)}.tmp`;
1454
1454
  try {
1455
- const fh = await fs54.promises.open(tmpPath, "w", 384);
1455
+ const fh = await fs55.promises.open(tmpPath, "w", 384);
1456
1456
  try {
1457
1457
  await fh.writeFile(JSON.stringify(data, null, 2));
1458
1458
  await fh.sync();
1459
1459
  } finally {
1460
1460
  await fh.close();
1461
1461
  }
1462
- await fs54.promises.rename(tmpPath, targetPath);
1462
+ await fs55.promises.rename(tmpPath, targetPath);
1463
1463
  } catch (err2) {
1464
- await fs54.promises.unlink(tmpPath).catch(() => {
1464
+ await fs55.promises.unlink(tmpPath).catch(() => {
1465
1465
  });
1466
1466
  throw err2;
1467
1467
  }
1468
1468
  try {
1469
- const dirFh = await fs54.promises.open(dir, "r");
1469
+ const dirFh = await fs55.promises.open(dir, "r");
1470
1470
  try {
1471
1471
  await dirFh.sync();
1472
1472
  } finally {
@@ -1855,12 +1855,12 @@ var init_credentials = __esm({
1855
1855
  return null;
1856
1856
  }
1857
1857
  validateProfileName(profileName);
1858
- const fs54 = await import("node:fs");
1858
+ const fs55 = await import("node:fs");
1859
1859
  const path63 = await import("node:path");
1860
1860
  const configPath = path63.join(rootConfigPath, "configs", `${profileName}.json`);
1861
1861
  let configRaw;
1862
1862
  try {
1863
- configRaw = await fs54.promises.readFile(configPath, "utf-8");
1863
+ configRaw = await fs55.promises.readFile(configPath, "utf-8");
1864
1864
  } catch (err2) {
1865
1865
  if (err2?.code !== "ENOENT") {
1866
1866
  throw new Error(`failed to read config file ${configPath}: ${err2}`);
@@ -1953,8 +1953,8 @@ var init_credentials = __esm({
1953
1953
  if (configDir2) {
1954
1954
  return configDir2;
1955
1955
  }
1956
- const os20 = getPlatformHeaders()["X-Stainless-OS"];
1957
- if (os20 === "Windows") {
1956
+ const os21 = getPlatformHeaders()["X-Stainless-OS"];
1957
+ if (os21 === "Windows") {
1958
1958
  const appData = readEnv("APPDATA");
1959
1959
  if (appData) {
1960
1960
  return path63.join(appData, "Anthropic");
@@ -1988,11 +1988,11 @@ var init_credentials = __esm({
1988
1988
  if (profileName) {
1989
1989
  return profileName;
1990
1990
  }
1991
- const fs54 = await import("node:fs");
1991
+ const fs55 = await import("node:fs");
1992
1992
  const path63 = await import("node:path");
1993
1993
  const filePath = path63.join(rootConfigPath, "active_config");
1994
1994
  try {
1995
- return (await fs54.promises.readFile(filePath, "utf-8")).trim() || "default";
1995
+ return (await fs55.promises.readFile(filePath, "utf-8")).trim() || "default";
1996
1996
  } catch (err2) {
1997
1997
  if (err2?.code !== "ENOENT") {
1998
1998
  throw new Error(`failed to read ${filePath}: ${err2}`);
@@ -2009,10 +2009,10 @@ function identityTokenFromFile(path63) {
2009
2009
  throw new AnthropicError("Identity token file path is empty");
2010
2010
  }
2011
2011
  return async () => {
2012
- const fs54 = await import("node:fs");
2012
+ const fs55 = await import("node:fs");
2013
2013
  let content;
2014
2014
  try {
2015
- content = await fs54.promises.readFile(path63, "utf-8");
2015
+ content = await fs55.promises.readFile(path63, "utf-8");
2016
2016
  } catch (err2) {
2017
2017
  throw new AnthropicError(`Failed to read identity token file at ${path63}: ${err2}`);
2018
2018
  }
@@ -2105,11 +2105,11 @@ var init_oidc_federation = __esm({
2105
2105
  // ../editor/node_modules/@anthropic-ai/sdk/lib/credentials/user-oauth.mjs
2106
2106
  function userOAuthProvider(config3) {
2107
2107
  return async (opts) => {
2108
- const fs54 = await import("node:fs");
2108
+ const fs55 = await import("node:fs");
2109
2109
  await checkCredentialsFileSafety(config3.credentialsPath, config3.onSafetyWarning);
2110
2110
  let raw;
2111
2111
  try {
2112
- raw = await fs54.promises.readFile(config3.credentialsPath, "utf-8");
2112
+ raw = await fs55.promises.readFile(config3.credentialsPath, "utf-8");
2113
2113
  } catch (err2) {
2114
2114
  throw new WorkloadIdentityError(`Credentials file not found at ${config3.credentialsPath}: ${err2}`);
2115
2115
  }
@@ -2282,11 +2282,11 @@ function resolveIdentityTokenProvider(auth) {
2282
2282
  }
2283
2283
  function cachedExchangeProvider(exchange2, credentialsPath, onCacheWriteError, onSafetyWarning) {
2284
2284
  return async (opts) => {
2285
- const fs54 = await import("node:fs");
2285
+ const fs55 = await import("node:fs");
2286
2286
  await checkCredentialsFileSafety(credentialsPath, onSafetyWarning);
2287
2287
  let existing;
2288
2288
  try {
2289
- const raw = await fs54.promises.readFile(credentialsPath, "utf-8");
2289
+ const raw = await fs55.promises.readFile(credentialsPath, "utf-8");
2290
2290
  existing = JSON.parse(raw);
2291
2291
  const token = existing?.["access_token"];
2292
2292
  if (token && !opts?.forceRefresh) {
@@ -18983,7 +18983,8 @@ function asClaudePayload(payload) {
18983
18983
  const i2 = input;
18984
18984
  if (typeof i2.path === "string" && i2.file_path === void 0) {
18985
18985
  const root2 = typeof payload.cwd === "string" && payload.cwd ? payload.cwd : "";
18986
- const abs = /^([\\/]|[A-Za-z]:)/.test(i2.path) || !root2 ? i2.path : `${root2.replace(/[\\/]+$/, "")}/${i2.path}`;
18986
+ const win = /^[A-Za-z]:\\|^\\\\/.test(root2);
18987
+ const abs = /^([\\/]|[A-Za-z]:)/.test(i2.path) || !root2 ? i2.path : `${root2.replace(/[\\/]+$/, "")}${win ? "\\" : "/"}${win ? i2.path.replace(/\//g, "\\") : i2.path}`;
18987
18988
  out2.tool_input = { ...i2, file_path: abs };
18988
18989
  }
18989
18990
  }
@@ -28678,6 +28679,16 @@ function scopeNamed(challenge) {
28678
28679
  const scope = /(?:^|[\s,])scope="([^"]+)"/i.exec(challenge ?? "")?.[1];
28679
28680
  return scope ? ` (${scope})` : "";
28680
28681
  }
28682
+ function insufficientScope(res) {
28683
+ return res.status === 403 && /error="?insufficient_scope"?/i.test(res.headers.get("www-authenticate") ?? "");
28684
+ }
28685
+ function refusal(res, said, steppedUp) {
28686
+ if (res.status !== 403) return `the server answered ${res.status}${said ? `: ${said}` : ""}`;
28687
+ if (insufficientScope(res)) {
28688
+ return `the server needs permission AstraCode does not have${scopeNamed(res.headers.get("www-authenticate"))}` + (steppedUp ? ", and signing in again did not grant it" : "");
28689
+ }
28690
+ return `the server refused this request (403 Forbidden)${said ? `: ${said}` : ""}. The account or token AstraCode used is not allowed to do this; check its access on the server's side`;
28691
+ }
28681
28692
  var McpHttpClient = class {
28682
28693
  constructor(spec, log2, auth) {
28683
28694
  this.spec = spec;
@@ -28819,6 +28830,38 @@ var McpHttpClient = class {
28819
28830
  throw err2;
28820
28831
  }
28821
28832
  }
28833
+ /*
28834
+ A REFUSAL A SIGN-IN CAN ANSWER, ON EITHER TRANSPORT.
28835
+
28836
+ 401: at most two rounds of authorization (see send for why two), handing
28837
+ over the token just refused so it is not handed straight back.
28838
+
28839
+ 403 insufficient_scope: STEP-UP. 2026-10-09. A server that grants a
28840
+ narrow scope first and more on demand answers a call needing more with 403
28841
+ and `error="insufficient_scope", scope="..."`. That was "the server
28842
+ answered 403", for good. The person is now asked, once per request, to
28843
+ grant the scope the challenge names (with what was granted before), and
28844
+ the request is sent again. 2026-10-22: the HTTP+SSE transport's message
28845
+ endpoint got only the 401 half, so a step-up there was a 403 for good.
28846
+
28847
+ Returns the options to send the request again with, or null when this is
28848
+ not such a refusal (or it has been answered already) and is the caller's
28849
+ to report. `before` runs once it is decided, ahead of the sign-in, so the
28850
+ caller can let go of the request's deadline first.
28851
+ */
28852
+ async answerChallenge(res, opts, before = () => {
28853
+ }) {
28854
+ if (!this.auth || this.spec.bearer) return null;
28855
+ const challenge = res.headers.get("www-authenticate");
28856
+ const signIns = opts.signIns ?? 0;
28857
+ const signIn = res.status === 401 && signIns < 2;
28858
+ const stepUp = !signIn && insufficientScope(res) && !opts.steppedUp;
28859
+ if (!signIn && !stepUp) return null;
28860
+ before();
28861
+ void res.body?.cancel().catch(() => void 0);
28862
+ this.token = (await this.signIn(challenge, { rejected: this.token || void 0, ...stepUp ? { stepUp: true } : {} }, opts.signal)).accessToken;
28863
+ return stepUp ? { ...opts, steppedUp: true } : { ...opts, signIns: signIns + 1 };
28864
+ }
28822
28865
  /** The OAuth token this client obtained, or the keychain one a catalogue entry gave it. */
28823
28866
  bearer() {
28824
28867
  return this.token || this.spec.bearer?.token || "";
@@ -28885,23 +28928,12 @@ var McpHttpClient = class {
28885
28928
  this.lastError = token ? `the server refused the ${variable} stored in your keychain (401); it may have expired or been revoked. Use Set token on "${this.spec.id}" (Customize > MCP servers) to paste a new one` : `no ${variable} is stored for "${this.spec.id}". Use Set token on it (Customize > MCP servers, or the composer's Connectors menu) to paste one`;
28886
28929
  throw new McpError(this.lastError);
28887
28930
  }
28888
- if (res.status === 401 && signIns < 2) {
28889
- settle3();
28890
- if (!this.auth) throw new McpError("server requires authorization");
28891
- this.token = (await this.signIn(res.headers.get("www-authenticate"), {
28892
- // The token it just refused, so it is not handed straight back.
28893
- rejected: this.token || void 0
28894
- }, signal)).accessToken;
28895
- return this.send(body2, timeout, { ...opts, signIns: signIns + 1 });
28896
- }
28897
- const challenge = res.headers.get("www-authenticate");
28898
- const insufficient = res.status === 403 && /error="?insufficient_scope"?/i.test(challenge ?? "");
28899
- if (insufficient && this.auth && !this.spec.bearer && !opts.steppedUp) {
28931
+ if (res.status === 401 && signIns < 2 && !this.auth) {
28900
28932
  settle3();
28901
- void res.body?.cancel().catch(() => void 0);
28902
- this.token = (await this.signIn(challenge, { rejected: this.token || void 0, stepUp: true }, signal)).accessToken;
28903
- return this.send(body2, timeout, { ...opts, steppedUp: true });
28933
+ throw new McpError("server requires authorization");
28904
28934
  }
28935
+ const again = await this.answerChallenge(res, opts, settle3);
28936
+ if (again) return this.send(body2, timeout, again);
28905
28937
  if (res.status === 404 && this.sessionId && retry) {
28906
28938
  settle3();
28907
28939
  this.log(`mcp: session for "${this.spec.id}" expired, starting a new one`);
@@ -28924,7 +28956,7 @@ var McpHttpClient = class {
28924
28956
  if (e && typeof e === "object" && typeof e.code === "number") rpcError = { code: e.code, data: e.data };
28925
28957
  } catch {
28926
28958
  }
28927
- this.lastError = res.status === 403 ? insufficient ? `the server needs permission AstraCode does not have${scopeNamed(challenge)}${opts.steppedUp ? ", and signing in again did not grant it" : ""}` : `the server refused this request (403 Forbidden)${said ? `: ${said}` : ""}. The account or token AstraCode used is not allowed to do this; check its access on the server's side` : `the server answered ${res.status}${said ? `: ${said}` : ""}`;
28959
+ this.lastError = refusal(res, said, opts.steppedUp);
28928
28960
  throw new McpError(this.lastError, { status: res.status, ...rpcError });
28929
28961
  }
28930
28962
  const session3 = res.headers.get("mcp-session-id");
@@ -29111,7 +29143,7 @@ var McpHttpClient = class {
29111
29143
  */
29112
29144
  legacy = null;
29113
29145
  /** Open an HTTP+SSE server's stream and wait for its endpoint. False when it is not one. */
29114
- async openLegacy(signIns = 0) {
29146
+ async openLegacy(opts = {}) {
29115
29147
  const controller = new AbortController();
29116
29148
  const timer = setTimeout(() => controller.abort(), HANDSHAKE_TIMEOUT_MS);
29117
29149
  let res;
@@ -29121,17 +29153,8 @@ var McpHttpClient = class {
29121
29153
  clearTimeout(timer);
29122
29154
  return false;
29123
29155
  }
29124
- if (res.status === 401 && this.auth && !this.spec.bearer && signIns < 2) {
29125
- clearTimeout(timer);
29126
- void res.body?.cancel().catch(() => void 0);
29127
- this.token = (await authorize(
29128
- this.spec.url,
29129
- res.headers.get("www-authenticate"),
29130
- this.auth,
29131
- { rejected: this.token || void 0 }
29132
- )).accessToken;
29133
- return this.openLegacy(signIns + 1);
29134
- }
29156
+ const again = await this.answerChallenge(res, opts, () => clearTimeout(timer));
29157
+ if (again) return this.openLegacy(again);
29135
29158
  if (res.status !== 200 || !(res.headers.get("content-type") ?? "").includes("text/event-stream")) {
29136
29159
  clearTimeout(timer);
29137
29160
  void res.body?.cancel().catch(() => void 0);
@@ -29193,7 +29216,7 @@ var McpHttpClient = class {
29193
29216
  }
29194
29217
  /** POST one message to an HTTP+SSE server, and wait for its reply on the stream. */
29195
29218
  async sendLegacy(state, body2, timeout, opts) {
29196
- const { signIns = 0, signal, progressToken } = opts;
29219
+ const { signal, progressToken } = opts;
29197
29220
  if (signal?.aborted) throw new McpError("the run was stopped");
29198
29221
  const id = idOf(body2);
29199
29222
  const seconds = Math.round(timeout / 1e3);
@@ -29244,14 +29267,11 @@ var McpHttpClient = class {
29244
29267
  throw new McpError(this.lastError);
29245
29268
  }
29246
29269
  void res.body?.cancel().catch(() => void 0);
29247
- if (res.status === 401 && this.auth && !this.spec.bearer && signIns < 2) {
29248
- forget2();
29249
- this.token = (await this.signIn(res.headers.get("www-authenticate"), { rejected: this.token || void 0 }, signal)).accessToken;
29250
- return this.sendLegacy(state, body2, timeout, { ...opts, signIns: signIns + 1 });
29251
- }
29270
+ const again = await this.answerChallenge(res, opts, forget2);
29271
+ if (again) return this.sendLegacy(state, body2, timeout, again);
29252
29272
  if (!res.ok) {
29253
29273
  forget2();
29254
- this.lastError = `the server answered ${res.status}`;
29274
+ this.lastError = refusal(res, void 0, opts.steppedUp);
29255
29275
  throw new McpError(this.lastError, { status: res.status });
29256
29276
  }
29257
29277
  return reply ? reply : null;
@@ -29317,7 +29337,7 @@ var McpHttpClient = class {
29317
29337
  this.modern = MODERN_PROTOCOL_VERSION;
29318
29338
  let era;
29319
29339
  let discovered;
29320
- let refusal = null;
29340
+ let refusal2 = null;
29321
29341
  this.probing = true;
29322
29342
  try {
29323
29343
  discovered = await this.send(this.request(this.nextId++, "server/discover"), HANDSHAKE_TIMEOUT_MS);
@@ -29327,12 +29347,12 @@ var McpHttpClient = class {
29327
29347
  this.modern = null;
29328
29348
  throw err2;
29329
29349
  }
29330
- refusal = err2;
29350
+ refusal2 = err2;
29331
29351
  } finally {
29332
29352
  this.probing = false;
29333
29353
  }
29334
29354
  try {
29335
- era = refusal ? eraFromDiscover({ error: refusal }) : eraFromDiscover({ result: discovered });
29355
+ era = refusal2 ? eraFromDiscover({ error: refusal2 }) : eraFromDiscover({ result: discovered });
29336
29356
  } catch (err2) {
29337
29357
  this.modern = null;
29338
29358
  this.lastError = err2 instanceof Error ? err2.message : String(err2);
@@ -29348,7 +29368,7 @@ var McpHttpClient = class {
29348
29368
  this.modern = null;
29349
29369
  this.sessionId = "";
29350
29370
  this.lastError = "";
29351
- if (refusal) this.log(`mcp: "${this.spec.id}" speaks an earlier MCP (${refusal.message}); initializing it`);
29371
+ if (refusal2) this.log(`mcp: "${this.spec.id}" speaks an earlier MCP (${refusal2.message}); initializing it`);
29352
29372
  const initialize = rpc(this.nextId++, "initialize", {
29353
29373
  protocolVersion: PROTOCOL_VERSION,
29354
29374
  capabilities: {},
@@ -30257,8 +30277,8 @@ var os9 = __toESM(require("os"));
30257
30277
  var path17 = __toESM(require("path"));
30258
30278
  var PROJECT_FILES = [
30259
30279
  { rel: ".mcp.json", key: "mcpServers" },
30260
- { rel: path17.join(".cursor", "mcp.json"), key: "mcpServers" },
30261
- { rel: path17.join(".vscode", "mcp.json"), key: "servers" }
30280
+ { rel: ".cursor/mcp.json", key: "mcpServers" },
30281
+ { rel: ".vscode/mcp.json", key: "servers" }
30262
30282
  ];
30263
30283
  function parseJsonc(text2) {
30264
30284
  let out2 = "";
@@ -34813,8 +34833,8 @@ function slugFromPath(path63) {
34813
34833
  return m ? m[1] : void 0;
34814
34834
  }
34815
34835
  var PlanStore = class {
34816
- constructor(fs54, newId) {
34817
- this.fs = fs54;
34836
+ constructor(fs55, newId) {
34837
+ this.fs = fs55;
34818
34838
  this.newId = newId;
34819
34839
  }
34820
34840
  fs;
@@ -63011,20 +63031,23 @@ function runGit(args2, opts = {}) {
63011
63031
  function isSha(value) {
63012
63032
  return !!value && /^[0-9a-f]{40}$/i.test(value);
63013
63033
  }
63034
+ function isLocalPath(u) {
63035
+ return u.startsWith("/") || /^[A-Za-z]:[\\/]/.test(u) || u.startsWith("\\\\");
63036
+ }
63014
63037
  function gitUrlProblem(url2, allowLocal) {
63015
63038
  const u = url2.trim();
63016
63039
  if (!u) return "the url is empty";
63017
63040
  if (u.startsWith("-")) return `"${u}" starts with "-", which git would read as an option`;
63018
63041
  if (/^[A-Za-z][A-Za-z0-9+.-]*::/.test(u))
63019
63042
  return `"${u}" names a git remote helper, which runs a program; refused`;
63020
- if (u.startsWith("/"))
63043
+ if (isLocalPath(u))
63021
63044
  return allowLocal ? void 0 : `"${u}" is a path on this machine; only a marketplace you add yourself may be local`;
63022
63045
  if (/\s/.test(u)) return `"${u}" contains whitespace`;
63023
63046
  if (/^https:\/\//i.test(u)) return void 0;
63024
63047
  if (/^ssh:\/\//i.test(u)) return void 0;
63025
63048
  if (/^[A-Za-z0-9._-]+@[A-Za-z0-9.-]+:[^/\\]/.test(u)) return void 0;
63026
63049
  if (/^http:\/\/(localhost|127\.0\.0\.1|\[::1\])(:\d+)?\//i.test(u)) return void 0;
63027
- if (/^file:\/\//i.test(u) || u.startsWith("/"))
63050
+ if (/^file:\/\//i.test(u))
63028
63051
  return allowLocal ? void 0 : `"${u}" is a path on this machine; only a marketplace you add yourself may be local`;
63029
63052
  return `"${u}" is not an https, ssh or git@ url`;
63030
63053
  }
@@ -68080,8 +68103,11 @@ ${lines2.join("\n\n")}
68080
68103
  // ../editor/src/cli/update.ts
68081
68104
  init_define_ASTRACODE_BUNDLED_SKILLS();
68082
68105
  var import_node_child_process20 = require("node:child_process");
68106
+ var fs53 = __toESM(require("node:fs"));
68107
+ var os20 = __toESM(require("node:os"));
68083
68108
  var path60 = __toESM(require("node:path"));
68084
68109
  var DEFAULT_INSTALLER = "https://astracode.io/install";
68110
+ var DEFAULT_WINDOWS_INSTALLER = "https://astracode.io/install.ps1";
68085
68111
  function cliReason(err2) {
68086
68112
  const status3 = err2.status;
68087
68113
  if (status3 === 407) return "a proxy needs you to sign in to it (HTTP 407)";
@@ -68125,7 +68151,8 @@ async function update2(current4) {
68125
68151
  return 0;
68126
68152
  }
68127
68153
  let script;
68128
- const installer = process.env.ASTRACODE_INSTALL_URL || DEFAULT_INSTALLER;
68154
+ const windows = process.platform === "win32";
68155
+ const installer = process.env.ASTRACODE_INSTALL_URL || (windows ? DEFAULT_WINDOWS_INSTALLER : DEFAULT_INSTALLER);
68129
68156
  try {
68130
68157
  script = await text(installer);
68131
68158
  } catch (err2) {
@@ -68136,6 +68163,7 @@ async function update2(current4) {
68136
68163
  process.stderr.write(`Updating astracode-agent ${current4} -> ${latest}
68137
68164
  `);
68138
68165
  const env5 = { ...process.env, ASTRACODE_VERSION: latest };
68166
+ if (windows) return runWindowsInstaller(script, env5);
68139
68167
  const versionDir = path60.dirname(process.execPath);
68140
68168
  if (VERSION_RE.test(path60.basename(versionDir)) && !process.env.ASTRACODE_DATA_DIR) {
68141
68169
  env5.ASTRACODE_DATA_DIR = path60.dirname(versionDir);
@@ -68151,10 +68179,37 @@ async function update2(current4) {
68151
68179
  child.stdin.end(script);
68152
68180
  });
68153
68181
  }
68182
+ function windowsPowerShellEnv(env5) {
68183
+ const out2 = { ...env5 };
68184
+ for (const key of Object.keys(out2)) if (key.toLowerCase() === "psmodulepath") delete out2[key];
68185
+ return out2;
68186
+ }
68187
+ function runWindowsInstaller(script, base) {
68188
+ const env5 = windowsPowerShellEnv(base);
68189
+ if (!env5.ASTRACODE_BIN_DIR) env5.ASTRACODE_BIN_DIR = path60.dirname(process.execPath);
68190
+ const dir = fs53.mkdtempSync(path60.join(os20.tmpdir(), "astracode-agent-update-"));
68191
+ const file2 = path60.join(dir, "install.ps1");
68192
+ fs53.writeFileSync(file2, script);
68193
+ env5.ASTRACODE_INSTALLER_FILE = file2;
68194
+ const command2 = "& ([scriptblock]::Create([IO.File]::ReadAllText($env:ASTRACODE_INSTALLER_FILE)))";
68195
+ return new Promise((resolve22) => {
68196
+ const done2 = (code) => {
68197
+ fs53.rmSync(dir, { recursive: true, force: true });
68198
+ resolve22(code);
68199
+ };
68200
+ const child = (0, import_node_child_process20.spawn)("powershell.exe", ["-NoProfile", "-NonInteractive", "-Command", command2], { env: env5, stdio: "inherit" });
68201
+ child.on("error", (err2) => {
68202
+ process.stderr.write(`astracode-agent: could not run the installer (${err2.message})
68203
+ `);
68204
+ done2(1);
68205
+ });
68206
+ child.on("close", (code) => done2(code ?? 1));
68207
+ });
68208
+ }
68154
68209
 
68155
68210
  // ../editor/src/cli/update-check.ts
68156
68211
  init_define_ASTRACODE_BUNDLED_SKILLS();
68157
- var fs53 = __toESM(require("node:fs"));
68212
+ var fs54 = __toESM(require("node:fs"));
68158
68213
  var path61 = __toESM(require("node:path"));
68159
68214
  var DAY_MS = 24 * 60 * 60 * 1e3;
68160
68215
  var FETCH_TIMEOUT_MS = 3e3;
@@ -68185,7 +68240,7 @@ function startUpdateCheck(current4, kind) {
68185
68240
  const file2 = path61.join(configDir(), "update-check.json");
68186
68241
  let cached4;
68187
68242
  try {
68188
- cached4 = JSON.parse(fs53.readFileSync(file2, "utf8"));
68243
+ cached4 = JSON.parse(fs54.readFileSync(file2, "utf8"));
68189
68244
  } catch {
68190
68245
  }
68191
68246
  const fresh = cached4 && cached4.kind === kind && Date.now() - cached4.checkedAt < DAY_MS && VERSION_RE.test(cached4.latest);
@@ -68193,8 +68248,8 @@ function startUpdateCheck(current4, kind) {
68193
68248
  (latest) => {
68194
68249
  if (latest) {
68195
68250
  try {
68196
- fs53.mkdirSync(path61.dirname(file2), { recursive: true, mode: 448 });
68197
- fs53.writeFileSync(file2, JSON.stringify({ checkedAt: Date.now(), latest, kind }));
68251
+ fs54.mkdirSync(path61.dirname(file2), { recursive: true, mode: 448 });
68252
+ fs54.writeFileSync(file2, JSON.stringify({ checkedAt: Date.now(), latest, kind }));
68198
68253
  } catch {
68199
68254
  }
68200
68255
  }
@@ -68331,7 +68386,7 @@ var RunReporter = class {
68331
68386
 
68332
68387
  // ../editor/src/cli/main.ts
68333
68388
  var readline5 = __toESM(require("node:readline"));
68334
- var VERSION2 = true ? "0.5.0" : "dev";
68389
+ var VERSION2 = true ? "0.5.2" : "dev";
68335
68390
  function readStdin() {
68336
68391
  return new Promise((resolve22, reject) => {
68337
68392
  const chunks = [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "astracode-agent",
3
- "version": "0.5.0",
3
+ "version": "0.5.2",
4
4
  "description": "The AstraCode agent, headless: run one task from a shell, a CI job or a script.",
5
5
  "license": "SEE LICENSE IN LICENSE.md",
6
6
  "homepage": "https://astracode.io",