@stav-ai/cli 0.1.7 → 0.1.9

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/stav.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /** The Stav calls the CLI makes, typed. */
2
- import { MODEL_RE } from './adapters/index.js';
2
+ import { isRouted, MODEL_RE } from './adapters/index.js';
3
3
  import { StavError } from './errors.js';
4
4
  import { request } from './http.js';
5
5
  /**
@@ -78,11 +78,11 @@ export class Stav {
78
78
  if (!Array.isArray(m.stav_surfaces) || !m.stav_surfaces.includes('chat'))
79
79
  continue;
80
80
  seen.add(m.id);
81
- const router = m.id === 'auto' || m.id.startsWith('@');
81
+ const router = isRouted(m.id);
82
82
  const n = m.context_length;
83
83
  out.push({ id: m.id, contextWindow: !router && typeof n === 'number' && Number.isInteger(n) && n > 0 ? n : null });
84
84
  }
85
- const rank = (id) => (id === 'auto' ? 0 : id.startsWith('@') ? 1 : 2);
85
+ const rank = (id) => (!isRouted(id) ? 2 : id.startsWith('@') ? 1 : 0);
86
86
  // Array.prototype.sort is stable: the gateway's order holds inside each group.
87
87
  return out.sort((a, b) => rank(a.id) - rank(b.id));
88
88
  }
@@ -36,6 +36,16 @@ export class FileStore {
36
36
  return {};
37
37
  }
38
38
  }
39
+ /** The file is there but cannot be read: every name in it would look missing. */
40
+ async damaged() {
41
+ try {
42
+ const parsed = JSON.parse(await fs.readFile(this.file, 'utf8'));
43
+ return !parsed || typeof parsed !== 'object';
44
+ }
45
+ catch (e) {
46
+ return e.code !== 'ENOENT';
47
+ }
48
+ }
39
49
  async write(data) {
40
50
  await fs.mkdir(path.dirname(this.file), { recursive: true, mode: 0o700 });
41
51
  const tmp = `${this.file}.${process.pid}.tmp`;
package/dist/version.js CHANGED
@@ -1,2 +1,2 @@
1
1
  /** The CLI's own version. Kept equal to package.json by units.test.ts ("VERSION matches package.json"). */
2
- export const VERSION = '0.1.7';
2
+ export const VERSION = '0.1.9';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stav-ai/cli",
3
- "version": "0.1.7",
3
+ "version": "0.1.9",
4
4
  "description": "Run your coding agent on Stav: sign in, get a key for the app, and start it pointed at the Stav gateway.",
5
5
  "type": "module",
6
6
  "bin": {