cli-atom 0.2.4 → 0.2.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/atom.js +39 -5
  2. package/package.json +1 -1
package/atom.js CHANGED
@@ -39,7 +39,7 @@ const IGNORE_EXTS = [".png", ".jpg", ".jpeg", ".gif", ".ico", ".svg", ".woff", "
39
39
  const MAX_FILE_SIZE = 15_000;
40
40
  let MODEL = "z-ai/glm-5-turbo";
41
41
  let MODEL_LABEL = "glm-5-turbo";
42
- const VERSION = "0.2.4";
42
+ const VERSION = "0.2.6";
43
43
 
44
44
  const MODELS = [
45
45
  { id: "z-ai/glm-5-turbo", label: "glm-5-turbo" },
@@ -178,17 +178,21 @@ function elapsed() {
178
178
  return s < 60 ? `${s}s` : `${Math.floor(s / 60)}m ${s % 60}s`;
179
179
  }
180
180
 
181
- function scanDir(dirPath, prefix = "") {
181
+ const MAX_FILES = 50;
182
+ const MAX_CONTEXT_CHARS = 60_000;
183
+
184
+ function scanDir(dirPath, prefix = "", _count = { n: 0 }) {
182
185
  let tree = "";
183
186
  let files = [];
184
187
  try {
185
188
  const entries = fs.readdirSync(dirPath, { withFileTypes: true });
186
189
  for (const entry of entries) {
190
+ if (_count.n >= MAX_FILES) break;
187
191
  if (IGNORE_DIRS.includes(entry.name)) continue;
188
192
  const fullPath = path.join(dirPath, entry.name);
189
193
  if (entry.isDirectory()) {
190
194
  tree += `${prefix}${entry.name}/\n`;
191
- const sub = scanDir(fullPath, prefix + " ");
195
+ const sub = scanDir(fullPath, prefix + " ", _count);
192
196
  tree += sub.tree;
193
197
  files.push(...sub.files);
194
198
  } else {
@@ -201,6 +205,7 @@ function scanDir(dirPath, prefix = "") {
201
205
  ? fs.readFileSync(fullPath, "utf-8")
202
206
  : "[file too large — truncated]";
203
207
  files.push({ path: fullPath.replace(/\\/g, "/"), content });
208
+ _count.n++;
204
209
  } catch { /* skip unreadable files */ }
205
210
  }
206
211
  }
@@ -240,9 +245,16 @@ function buildContext() {
240
245
 
241
246
  let ctx = `\n--- PROJECT CONTEXT (${cwd}) ---\n`;
242
247
  ctx += `File tree:\n${tree}\n`;
248
+ let totalChars = ctx.length;
243
249
  for (const f of files) {
244
250
  const rel = path.relative(cwd, f.path).replace(/\\/g, "/");
245
- ctx += `--- ${rel} ---\n${f.content}\n--- end ${rel} ---\n\n`;
251
+ const block = `--- ${rel} ---\n${f.content}\n--- end ${rel} ---\n\n`;
252
+ if (totalChars + block.length > MAX_CONTEXT_CHARS) {
253
+ ctx += `[context limit reached — ${files.length} files total, showing partial]\n`;
254
+ break;
255
+ }
256
+ ctx += block;
257
+ totalChars += block.length;
246
258
  }
247
259
  ctx += `--- END PROJECT CONTEXT ---\n`;
248
260
 
@@ -642,7 +654,7 @@ async function handleInput(raw) {
642
654
  const masked = config.apiKey ? config.apiKey.slice(0, 10) + "..." + config.apiKey.slice(-6) : "none";
643
655
  console.log(`\n ${t.violet}API Key${t.reset}`);
644
656
  console.log(` ${t.muted}current: ${masked}${t.reset}`);
645
- console.log(` ${t.dim}To change your key, type ${t.accent}/login${t.dim} or run ${t.accent}atom login${t.dim} in your terminal.${t.reset}\n`);
657
+ console.log(` ${t.dim}To change your key, type ${t.accent}/login${t.dim}.${t.reset}\n`);
646
658
  askPrompt();
647
659
  return;
648
660
  }
@@ -943,6 +955,18 @@ function getDate() {
943
955
  }
944
956
 
945
957
 
958
+
959
+ async function checkForUpdate() {
960
+ try {
961
+ const res = await fetch(`https://registry.npmjs.org/cli-atom/latest`, { signal: AbortSignal.timeout(3000) });
962
+ if (!res.ok) return null;
963
+ const data = await res.json();
964
+ return data.version || null;
965
+ } catch {
966
+ return null;
967
+ }
968
+ }
969
+
946
970
  async function start() {
947
971
  console.clear();
948
972
 
@@ -954,6 +978,10 @@ async function start() {
954
978
  const now = getNow();
955
979
  const date = getDate();
956
980
 
981
+ // check for update in background
982
+ const latestVersion = await checkForUpdate();
983
+ const hasUpdate = latestVersion && latestVersion !== VERSION;
984
+
957
985
  console.log();
958
986
  console.log(rule("─"));
959
987
  console.log();
@@ -986,6 +1014,12 @@ async function start() {
986
1014
  console.log(rule("─"));
987
1015
  console.log();
988
1016
 
1017
+ if (hasUpdate) {
1018
+ console.log(` ${t.warn}update available${t.reset} ${t.muted}v${VERSION} → ${t.accent}v${latestVersion}${t.reset}`);
1019
+ console.log(` ${t.dim}run ${t.accent}npm install -g cli-atom${t.dim} to update${t.reset}`);
1020
+ console.log();
1021
+ }
1022
+
989
1023
  console.log(`${t.violetDim}ready${t.reset}`);
990
1024
 
991
1025
  askPrompt();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cli-atom",
3
- "version": "0.2.4",
3
+ "version": "0.2.6",
4
4
  "description": "ATOM - Coding Agent",
5
5
  "license": "ISC",
6
6
  "author": "Redwxll",