@ywldan/kiro 0.2.7 → 0.2.8
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 +12 -0
- package/dist/index.js +13 -0
- package/dist/update.js +95 -0
- package/dist/version.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -129,6 +129,15 @@ Key handling for `kiro model add`:
|
|
|
129
129
|
- `--api-key-env <VAR>` with no key stores nothing; it references the variable, which must already be set in the environment or in `~/.kiro/.env`.
|
|
130
130
|
- Omitting both creates a profile with no key, suitable for local servers.
|
|
131
131
|
|
|
132
|
+
### Staying up to date
|
|
133
|
+
|
|
134
|
+
```bash
|
|
135
|
+
kiro check # installed version vs the latest on npm
|
|
136
|
+
kiro update # npm install -g @ywldan/kiro@latest
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
`check` exits `0` when current, `1` when an update is available, `2` when the registry cannot be reached. `update` shows the npm output and needs the same permissions as a global npm install.
|
|
140
|
+
|
|
132
141
|
### Where keys live
|
|
133
142
|
|
|
134
143
|
The config file contains only `apiKeyEnv`, the *name* of a variable. Values live in the environment or in `~/.kiro/.env`:
|
|
@@ -241,6 +250,9 @@ kiro [options]
|
|
|
241
250
|
--no-alt-screen Do not switch to the terminal's alternate screen
|
|
242
251
|
-h, --help Show help
|
|
243
252
|
-v, --version Show version
|
|
253
|
+
|
|
254
|
+
kiro check Compare the installed version with the latest on npm
|
|
255
|
+
kiro update Install the latest version from npm globally
|
|
244
256
|
```
|
|
245
257
|
|
|
246
258
|
`--flag=value` works as well. CLI overrides last for the current process only.
|
package/dist/index.js
CHANGED
|
@@ -10,6 +10,7 @@ import { registerSecretEnv } from './secrets.js';
|
|
|
10
10
|
import { latestSession, loadSession } from './sessions.js';
|
|
11
11
|
import { MOUSE_OFF } from './ui/mouse.js';
|
|
12
12
|
import { App } from './ui/App.js';
|
|
13
|
+
import { runCheck, runUpdate } from './update.js';
|
|
13
14
|
import { VERSION } from './version.js';
|
|
14
15
|
const HELP = `Kiro — a small terminal coding agent
|
|
15
16
|
|
|
@@ -42,6 +43,10 @@ Model commands:
|
|
|
42
43
|
kiro model remove <n>
|
|
43
44
|
kiro model test [n]
|
|
44
45
|
|
|
46
|
+
Update commands:
|
|
47
|
+
kiro check Compare the installed version with the latest on npm
|
|
48
|
+
kiro update Install the latest version from npm globally
|
|
49
|
+
|
|
45
50
|
Config: ~/.kiro/config.json (created with a template on first run)
|
|
46
51
|
Keys: ~/.kiro/.env (mode 0600), or the environment variable named by "apiKeyEnv".
|
|
47
52
|
Sessions: ~/.kiro/sessions (one directory per working directory)
|
|
@@ -180,6 +185,14 @@ async function main() {
|
|
|
180
185
|
process.exitCode = await runModelCli(rawArgs.slice(1));
|
|
181
186
|
return;
|
|
182
187
|
}
|
|
188
|
+
if (rawArgs[0] === 'check') {
|
|
189
|
+
process.exitCode = await runCheck();
|
|
190
|
+
return;
|
|
191
|
+
}
|
|
192
|
+
if (rawArgs[0] === 'update') {
|
|
193
|
+
process.exitCode = await runUpdate();
|
|
194
|
+
return;
|
|
195
|
+
}
|
|
183
196
|
let options;
|
|
184
197
|
try {
|
|
185
198
|
options = parseArgs(rawArgs);
|
package/dist/update.js
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { spawn } from 'node:child_process';
|
|
2
|
+
import { VERSION } from './version.js';
|
|
3
|
+
const PACKAGE_NAME = '@ywldan/kiro';
|
|
4
|
+
/** npm on Windows is npm.cmd; only .cmd/.bat need a shell when spawning. */
|
|
5
|
+
function npmCommand() {
|
|
6
|
+
if (process.platform === 'win32')
|
|
7
|
+
return { command: 'npm.cmd', shell: true };
|
|
8
|
+
return { command: 'npm', shell: false };
|
|
9
|
+
}
|
|
10
|
+
function runNpm(args, capture) {
|
|
11
|
+
const { command, shell } = npmCommand();
|
|
12
|
+
return new Promise((resolve, reject) => {
|
|
13
|
+
const child = spawn(command, args, {
|
|
14
|
+
stdio: capture ? ['ignore', 'pipe', 'pipe'] : 'inherit',
|
|
15
|
+
shell,
|
|
16
|
+
windowsHide: true,
|
|
17
|
+
});
|
|
18
|
+
let stdout = '';
|
|
19
|
+
if (capture && child.stdout)
|
|
20
|
+
child.stdout.on('data', (chunk) => (stdout += String(chunk)));
|
|
21
|
+
child.on('error', reject);
|
|
22
|
+
child.on('close', (code) => resolve({ code: code ?? 1, stdout }));
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
/** Compares dotted numeric versions; returns -1, 0 or 1. Non-numeric parts fall back to string compare. */
|
|
26
|
+
function compareVersions(a, b) {
|
|
27
|
+
if (a === b)
|
|
28
|
+
return 0;
|
|
29
|
+
const left = a.split('.').map(Number);
|
|
30
|
+
const right = b.split('.').map(Number);
|
|
31
|
+
if (left.some(Number.isNaN) || right.some(Number.isNaN))
|
|
32
|
+
return a < b ? -1 : 1;
|
|
33
|
+
const length = Math.max(left.length, right.length);
|
|
34
|
+
for (let index = 0; index < length; index++) {
|
|
35
|
+
const x = left[index] ?? 0;
|
|
36
|
+
const y = right[index] ?? 0;
|
|
37
|
+
if (x !== y)
|
|
38
|
+
return x < y ? -1 : 1;
|
|
39
|
+
}
|
|
40
|
+
return 0;
|
|
41
|
+
}
|
|
42
|
+
async function latestVersion() {
|
|
43
|
+
const { code, stdout } = await runNpm(['view', PACKAGE_NAME, 'version'], true);
|
|
44
|
+
const latest = stdout.trim().split(/\r?\n/).pop() ?? '';
|
|
45
|
+
if (code !== 0 || !/^\d+\.\d+\.\d+/.test(latest)) {
|
|
46
|
+
throw new Error('Could not read the latest version from the npm registry.');
|
|
47
|
+
}
|
|
48
|
+
return latest;
|
|
49
|
+
}
|
|
50
|
+
/** `kiro check` — compare the installed version with the registry. Exit 0 current, 1 update available, 2 check failed. */
|
|
51
|
+
export async function runCheck() {
|
|
52
|
+
let latest;
|
|
53
|
+
try {
|
|
54
|
+
latest = await latestVersion();
|
|
55
|
+
}
|
|
56
|
+
catch (error) {
|
|
57
|
+
console.error(`Kiro ${VERSION} — version check failed: ${error.message}`);
|
|
58
|
+
console.error('Check manually with: npm view @ywldan/kiro version');
|
|
59
|
+
return 2;
|
|
60
|
+
}
|
|
61
|
+
if (compareVersions(VERSION, latest) >= 0) {
|
|
62
|
+
process.stdout.write(`Kiro ${VERSION} — up to date\n`);
|
|
63
|
+
return 0;
|
|
64
|
+
}
|
|
65
|
+
process.stdout.write(`Kiro ${VERSION} → ${latest} available. Run "kiro update" to upgrade.\n`);
|
|
66
|
+
return 1;
|
|
67
|
+
}
|
|
68
|
+
/** `kiro update` — install the latest published version globally through npm. */
|
|
69
|
+
export async function runUpdate() {
|
|
70
|
+
let latest;
|
|
71
|
+
try {
|
|
72
|
+
latest = await latestVersion();
|
|
73
|
+
}
|
|
74
|
+
catch {
|
|
75
|
+
latest = 'latest';
|
|
76
|
+
}
|
|
77
|
+
if (latest !== 'latest' && compareVersions(VERSION, latest) >= 0) {
|
|
78
|
+
process.stdout.write(`Kiro ${VERSION} — already up to date, nothing to do\n`);
|
|
79
|
+
return 0;
|
|
80
|
+
}
|
|
81
|
+
process.stdout.write(`Updating Kiro ${VERSION} → ${latest} via npm…\n`);
|
|
82
|
+
const { command, shell } = npmCommand();
|
|
83
|
+
const result = await runNpm(['install', '-g', `${PACKAGE_NAME}@latest`], false).catch((error) => {
|
|
84
|
+
console.error(`Kiro: could not start "${command}": ${error.message}`);
|
|
85
|
+
return { code: 2, stdout: '' };
|
|
86
|
+
});
|
|
87
|
+
if (result.code !== 0) {
|
|
88
|
+
console.error(`Kiro: npm exited with code ${result.code}. Update manually with:`);
|
|
89
|
+
console.error(` ${command} install -g ${PACKAGE_NAME}@latest`);
|
|
90
|
+
return result.code;
|
|
91
|
+
}
|
|
92
|
+
process.stdout.write(`Kiro updated to ${latest}. Restart kiro to use the new version.\n`);
|
|
93
|
+
return 0;
|
|
94
|
+
}
|
|
95
|
+
//# sourceMappingURL=update.js.map
|
package/dist/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const VERSION = '0.2.
|
|
1
|
+
export const VERSION = '0.2.8';
|
|
2
2
|
//# sourceMappingURL=version.js.map
|