deepcode-ai 1.1.26 → 1.1.27

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/dist/index.js CHANGED
@@ -2281,8 +2281,8 @@ var PermissionDeniedError = class extends DeepCodeError {
2281
2281
  }
2282
2282
  };
2283
2283
  var PathNotAllowedError = class extends DeepCodeError {
2284
- constructor(path15, reason) {
2285
- super(`Path is not allowed: ${path15}. ${reason}`, "PATH_NOT_ALLOWED");
2284
+ constructor(path152, reason) {
2285
+ super(`Path is not allowed: ${path152}. ${reason}`, "PATH_NOT_ALLOWED");
2286
2286
  this.name = "PathNotAllowedError";
2287
2287
  }
2288
2288
  };
@@ -5043,13 +5043,13 @@ var GitHubClient = class {
5043
5043
  }
5044
5044
  return parseGitHubRemote(result.stdout.trim());
5045
5045
  }
5046
- async request(path15, init = {}) {
5046
+ async request(path152, init = {}) {
5047
5047
  if (!this.options.token) {
5048
5048
  throw new Error(
5049
5049
  "GitHub token is required. Set GITHUB_TOKEN or .deepcode/config.json github.token."
5050
5050
  );
5051
5051
  }
5052
- const response = await fetch(`${this.apiBase}${path15}`, {
5052
+ const response = await fetch(`${this.apiBase}${path152}`, {
5053
5053
  ...init,
5054
5054
  headers: {
5055
5055
  accept: "application/vnd.github+json",
@@ -5065,13 +5065,13 @@ var GitHubClient = class {
5065
5065
  if (response.status === 204) return void 0;
5066
5066
  return await response.json();
5067
5067
  }
5068
- async requestText(path15, init = {}) {
5068
+ async requestText(path152, init = {}) {
5069
5069
  if (!this.options.token) {
5070
5070
  throw new Error(
5071
5071
  "GitHub token is required. Set GITHUB_TOKEN or .deepcode/config.json github.token."
5072
5072
  );
5073
5073
  }
5074
- const response = await fetch(`${this.apiBase}${path15}`, {
5074
+ const response = await fetch(`${this.apiBase}${path152}`, {
5075
5075
  ...init,
5076
5076
  headers: {
5077
5077
  accept: "application/vnd.github+json",
@@ -5539,12 +5539,12 @@ function fromFileUri(uri) {
5539
5539
  var SECRET_KEY_PATTERN = /(api[_-]?key|token|authorization|secret|password|passwd|credential|private[_-]?key)/i;
5540
5540
  var MIN_SECRET_VALUE_LENGTH = 4;
5541
5541
  function redactSecrets(value, options = {}) {
5542
- const path15 = options.path ?? [];
5542
+ const path152 = options.path ?? [];
5543
5543
  const secretPlaceholder = options.secretPlaceholder ?? "[redacted]";
5544
5544
  const emptySecretPlaceholder = options.emptySecretPlaceholder ?? "[empty]";
5545
5545
  const secretValues = options.secretValues ?? collectSecretValues();
5546
5546
  if (typeof value === "string") {
5547
- if (isSecretPath(path15)) {
5547
+ if (isSecretPath(path152)) {
5548
5548
  return value.length > 0 ? secretPlaceholder : emptySecretPlaceholder;
5549
5549
  }
5550
5550
  return redactText(value, secretValues, secretPlaceholder);
@@ -5553,7 +5553,7 @@ function redactSecrets(value, options = {}) {
5553
5553
  return value.map(
5554
5554
  (item, index) => redactSecrets(item, {
5555
5555
  ...options,
5556
- path: [...path15, String(index)],
5556
+ path: [...path152, String(index)],
5557
5557
  secretValues
5558
5558
  })
5559
5559
  );
@@ -5564,7 +5564,7 @@ function redactSecrets(value, options = {}) {
5564
5564
  key,
5565
5565
  redactSecrets(item, {
5566
5566
  ...options,
5567
- path: [...path15, key],
5567
+ path: [...path152, key],
5568
5568
  secretValues
5569
5569
  })
5570
5570
  ])
@@ -5602,8 +5602,8 @@ function collectSecretValues(config) {
5602
5602
  }
5603
5603
  return [...values].sort((left, right) => right.length - left.length);
5604
5604
  }
5605
- function isSecretPath(path15) {
5606
- const key = path15[path15.length - 1] ?? "";
5605
+ function isSecretPath(path152) {
5606
+ const key = path152[path152.length - 1] ?? "";
5607
5607
  if (/(api[_-]?key|token|secret|credential).*file/i.test(key)) return false;
5608
5608
  return SECRET_KEY_PATTERN.test(key);
5609
5609
  }
@@ -7824,8 +7824,8 @@ import { useState as useState22, useEffect as useEffect22, useCallback as useCal
7824
7824
  import { Box as Box2, Text as Text22, useInput as useInput2, useApp as useApp2 } from "ink";
7825
7825
  import path42 from "path";
7826
7826
  import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
7827
- import fs7 from "fs";
7828
- import path142 from "path";
7827
+ import fs8 from "fs";
7828
+ import path15 from "path";
7829
7829
  import { isValidElement, useCallback as useCallback26, useEffect as useEffect27, useMemo as useMemo18, useRef as useRef17, useState as useState29 } from "react";
7830
7830
  import { Box as Box42, Text as Text50, useInput as useInput6, useStdin as useStdin3 } from "ink";
7831
7831
  import os4 from "os";
@@ -9810,6 +9810,9 @@ import { jsx as jsx39, jsxs as jsxs35 } from "react/jsx-runtime";
9810
9810
  import { Box as Box31, Text as Text39 } from "ink";
9811
9811
  import { jsx as jsx40, jsxs as jsxs36 } from "react/jsx-runtime";
9812
9812
  import { jsx as jsx41, jsxs as jsxs37 } from "react/jsx-runtime";
9813
+ import fs6 from "fs";
9814
+ import os5 from "os";
9815
+ import path132 from "path";
9813
9816
  import { Box as Box33, Text as Text41 } from "ink";
9814
9817
  import { jsx as jsx42, jsxs as jsxs38 } from "react/jsx-runtime";
9815
9818
  import { useCallback as useCallback19, useMemo as useMemo11, useRef as useRef14 } from "react";
@@ -9827,8 +9830,8 @@ import { jsx as jsx46, jsxs as jsxs42 } from "react/jsx-runtime";
9827
9830
  import { useCallback as useCallback23, useEffect as useEffect25, useMemo as useMemo15, useRef as useRef16, useState as useState27 } from "react";
9828
9831
  import { Box as Box38, Text as Text46, useInput as useInput4 } from "ink";
9829
9832
  import { jsx as jsx47, jsxs as jsxs43 } from "react/jsx-runtime";
9830
- import fs6 from "fs";
9831
- import path132 from "path";
9833
+ import fs7 from "fs";
9834
+ import path142 from "path";
9832
9835
  import { useCallback as useCallback24, useMemo as useMemo16 } from "react";
9833
9836
  import { Box as Box39, Text as Text47 } from "ink";
9834
9837
  import { jsx as jsx48, jsxs as jsxs44 } from "react/jsx-runtime";
@@ -28039,6 +28042,109 @@ var compactCommand = {
28039
28042
  await context.ui.compact();
28040
28043
  }
28041
28044
  };
28045
+ var CACHE_TTL_MS = 24 * 60 * 60 * 1e3;
28046
+ var PACKAGE_NAME = "deepcode-ai";
28047
+ function cachePath() {
28048
+ const cacheHome = process.env["XDG_CACHE_HOME"] ?? path132.join(os5.homedir(), ".cache");
28049
+ return path132.join(cacheHome, "deepcode-ai", "update.json");
28050
+ }
28051
+ function readCache() {
28052
+ try {
28053
+ const raw = fs6.readFileSync(cachePath(), "utf8");
28054
+ const parsed = JSON.parse(raw);
28055
+ if (typeof parsed.checkedAt !== "number" || typeof parsed.latest !== "string" || Date.now() - parsed.checkedAt >= CACHE_TTL_MS) {
28056
+ return null;
28057
+ }
28058
+ return {
28059
+ checkedAt: parsed.checkedAt,
28060
+ latest: parsed.latest,
28061
+ stable: typeof parsed.stable === "string" ? parsed.stable : null
28062
+ };
28063
+ } catch {
28064
+ return null;
28065
+ }
28066
+ }
28067
+ function writeCache(cache) {
28068
+ try {
28069
+ const filePath = cachePath();
28070
+ fs6.mkdirSync(path132.dirname(filePath), { recursive: true });
28071
+ fs6.writeFileSync(filePath, `${JSON.stringify(cache)}
28072
+ `, "utf8");
28073
+ } catch {
28074
+ }
28075
+ }
28076
+ async function checkForUpdate(_currentVersion, options = {}) {
28077
+ if (process.env["CI"] || process.env["NODE_ENV"] === "test" || process.env["DEEPCODE_DISABLE_UPDATE_CHECK"] === "1") {
28078
+ return null;
28079
+ }
28080
+ if (!options.force) {
28081
+ const cached = readCache();
28082
+ if (cached) {
28083
+ return { latest: cached.latest, stable: cached.stable };
28084
+ }
28085
+ }
28086
+ try {
28087
+ const response = await fetch(
28088
+ `https://registry.npmjs.org/-/package/${PACKAGE_NAME}/dist-tags`,
28089
+ { signal: AbortSignal.timeout(3e3) }
28090
+ );
28091
+ if (!response.ok) return null;
28092
+ const tags = await response.json();
28093
+ const latest = tags["latest"];
28094
+ if (typeof latest !== "string" || latest.length === 0) return null;
28095
+ const stable = typeof tags["stable"] === "string" && tags["stable"].length > 0 ? tags["stable"] : null;
28096
+ const update = { latest, stable };
28097
+ writeCache({ ...update, checkedAt: Date.now() });
28098
+ return update;
28099
+ } catch {
28100
+ return null;
28101
+ }
28102
+ }
28103
+ function isNewer(current, candidate) {
28104
+ const currentParts = parseVersion2(current);
28105
+ const candidateParts = parseVersion2(candidate);
28106
+ if (!currentParts || !candidateParts) return false;
28107
+ for (let index = 0; index < 3; index += 1) {
28108
+ const currentPart = currentParts[index] ?? 0;
28109
+ const candidatePart = candidateParts[index] ?? 0;
28110
+ if (candidatePart !== currentPart) {
28111
+ return candidatePart > currentPart;
28112
+ }
28113
+ }
28114
+ return false;
28115
+ }
28116
+ function parseVersion2(version) {
28117
+ const match = version.trim().match(/^v?(\d+)\.(\d+)\.(\d+)(?:[-+].*)?$/);
28118
+ if (!match) return null;
28119
+ return [Number(match[1]), Number(match[2]), Number(match[3])];
28120
+ }
28121
+ var VERSION = "1.1.27".length > 0 ? "1.1.27" : "0.0.0-dev";
28122
+ var updateCommand = {
28123
+ name: "update",
28124
+ description: "Check published DeepCode versions",
28125
+ kind: "built-in",
28126
+ supportedModes: ["interactive"],
28127
+ action: async () => {
28128
+ const update = await checkForUpdate(VERSION, { force: true });
28129
+ const lines = [`Current version: ${VERSION}`];
28130
+ if (!update) {
28131
+ lines.push("Could not reach the npm registry right now.");
28132
+ } else {
28133
+ const latestStatus = isNewer(VERSION, update.latest) ? "available" : "current or older";
28134
+ lines.push(`Latest version: ${update.latest} (${latestStatus})`);
28135
+ if (update.stable) {
28136
+ const stableStatus = isNewer(VERSION, update.stable) ? "available" : "current or older";
28137
+ lines.push(`Stable version: ${update.stable} (${stableStatus})`);
28138
+ } else {
28139
+ lines.push("Stable version: not published yet");
28140
+ }
28141
+ }
28142
+ lines.push("");
28143
+ lines.push("Install latest: npm install -g deepcode-ai@latest");
28144
+ lines.push("Install stable: npm install -g deepcode-ai@stable");
28145
+ return { type: "message", messageType: "info", content: lines.join("\n") };
28146
+ }
28147
+ };
28042
28148
  function sessionNotReady() {
28043
28149
  return {
28044
28150
  type: "message",
@@ -29093,11 +29199,11 @@ var RATINGS = [
29093
29199
  ];
29094
29200
  var CANCEL_VALUE2 = "__cancel__";
29095
29201
  function appendFeedbackEntry(cwd, rating, label) {
29096
- const file = path132.join(cwd, ".deepcode", "feedback.log");
29202
+ const file = path142.join(cwd, ".deepcode", "feedback.log");
29097
29203
  const entry = JSON.stringify({ ts: (/* @__PURE__ */ new Date()).toISOString(), rating, label });
29098
29204
  try {
29099
- fs6.mkdirSync(path132.dirname(file), { recursive: true });
29100
- fs6.appendFileSync(file, `${entry}
29205
+ fs7.mkdirSync(path142.dirname(file), { recursive: true });
29206
+ fs7.appendFileSync(file, `${entry}
29101
29207
  `, "utf8");
29102
29208
  } catch {
29103
29209
  }
@@ -29674,12 +29780,12 @@ var AppContainer = ({ cwd, config, provider, model, resumeSessionId }) => {
29674
29780
  const configAdapter = configAdapterRef.current ?? new DeepCodeConfigAdapter(cwd);
29675
29781
  const isValidPath = useCallback26(
29676
29782
  (candidate) => {
29677
- const resolved = path142.resolve(cwd, candidate);
29678
- const relative2 = path142.relative(cwd, resolved);
29679
- if (relative2.startsWith("..") || path142.isAbsolute(relative2)) {
29783
+ const resolved = path15.resolve(cwd, candidate);
29784
+ const relative2 = path15.relative(cwd, resolved);
29785
+ if (relative2.startsWith("..") || path15.isAbsolute(relative2)) {
29680
29786
  return false;
29681
29787
  }
29682
- return fs7.existsSync(resolved);
29788
+ return fs8.existsSync(resolved);
29683
29789
  },
29684
29790
  [cwd]
29685
29791
  );
@@ -29709,6 +29815,7 @@ var AppContainer = ({ cwd, config, provider, model, resumeSessionId }) => {
29709
29815
  modelCommand,
29710
29816
  modeCommand,
29711
29817
  renameCommand,
29818
+ updateCommand,
29712
29819
  settingsDialogCommand,
29713
29820
  themeDialogCommand,
29714
29821
  permissionsDialogCommand,
@@ -30091,6 +30198,25 @@ var AppContainer = ({ cwd, config, provider, model, resumeSessionId }) => {
30091
30198
  );
30092
30199
  }
30093
30200
  setIsInitializing(false);
30201
+ checkForUpdate(VERSION).then((update) => {
30202
+ if (!mounted || !update) return;
30203
+ const available = [];
30204
+ if (isNewer(VERSION, update.latest)) {
30205
+ available.push(`latest v${update.latest}`);
30206
+ }
30207
+ if (update.stable && isNewer(VERSION, update.stable)) {
30208
+ available.push(`stable v${update.stable}`);
30209
+ }
30210
+ if (available.length === 0) return;
30211
+ addHistoryItem(
30212
+ {
30213
+ type: "info",
30214
+ text: `Update available: ${available.join(", ")}. Run /update for install commands.`
30215
+ },
30216
+ Date.now()
30217
+ );
30218
+ }).catch(() => {
30219
+ });
30094
30220
  } catch (error) {
30095
30221
  if (!mounted) return;
30096
30222
  const message = error instanceof Error ? error.message : String(error);
@@ -30963,7 +31089,7 @@ var AppContainer = ({ cwd, config, provider, model, resumeSessionId }) => {
30963
31089
  mainControlsRef,
30964
31090
  constrainHeight: false,
30965
31091
  currentModel,
30966
- sessionName: path142.basename(cwd),
31092
+ sessionName: path15.basename(cwd),
30967
31093
  isConfigInitialized: !isInitializing && !initError,
30968
31094
  sessionStats: {
30969
31095
  lastPromptTokenCount,
@@ -31202,11 +31328,11 @@ function isInteractiveDialog(dialog) {
31202
31328
  return dialog === "theme" || dialog === "permissions" || dialog === "auth" || dialog === "provider" || dialog === "model" || dialog === "feedback" || dialog === "sessions";
31203
31329
  }
31204
31330
  function tuiThemeFilePath(cwd) {
31205
- return path142.join(cwd, ".deepcode", "tui-theme.json");
31331
+ return path15.join(cwd, ".deepcode", "tui-theme.json");
31206
31332
  }
31207
31333
  function readSavedTheme(cwd) {
31208
31334
  try {
31209
- const parsed = JSON.parse(fs7.readFileSync(tuiThemeFilePath(cwd), "utf8"));
31335
+ const parsed = JSON.parse(fs8.readFileSync(tuiThemeFilePath(cwd), "utf8"));
31210
31336
  return typeof parsed.theme === "string" ? parsed.theme : null;
31211
31337
  } catch {
31212
31338
  return null;
@@ -31214,8 +31340,8 @@ function readSavedTheme(cwd) {
31214
31340
  }
31215
31341
  function writeSavedTheme(cwd, themeName) {
31216
31342
  const file = tuiThemeFilePath(cwd);
31217
- fs7.mkdirSync(path142.dirname(file), { recursive: true });
31218
- fs7.writeFileSync(file, `${JSON.stringify({ theme: themeName }, null, 2)}
31343
+ fs8.mkdirSync(path15.dirname(file), { recursive: true });
31344
+ fs8.writeFileSync(file, `${JSON.stringify({ theme: themeName }, null, 2)}
31219
31345
  `);
31220
31346
  }
31221
31347
  function errorMessage(error) {
@@ -31354,7 +31480,7 @@ function createProgram() {
31354
31480
  writeOut: writeStdoutSync,
31355
31481
  writeErr: writeStderrSync
31356
31482
  });
31357
- program.name("deepcode").description("AI coding agent for the terminal").version("1.0.0").option("-C, --cwd <path>", "working directory", process.cwd()).option("--config <path>", "config file path");
31483
+ program.name("deepcode").description("AI coding agent for the terminal").version(VERSION).option("-C, --cwd <path>", "working directory", process.cwd()).option("--config <path>", "config file path");
31358
31484
  program.command("init").description("create .deepcode/config.json").action(async () => {
31359
31485
  await initCommand(program.opts().cwd);
31360
31486
  });