@ccode-si/cli 1.7.1 → 1.8.1
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 +1 -0
- package/bin/ccode.js +50 -1
- package/package.json +7 -7
package/README.md
CHANGED
|
@@ -73,6 +73,7 @@ ccode update # install the newest version
|
|
|
73
73
|
| `ctrl+v` | paste an image from the clipboard (`alt+v` also works) |
|
|
74
74
|
| `esc esc` | stop the response |
|
|
75
75
|
| `ctrl+b` | move the running command to the background |
|
|
76
|
+
| `ctrl+x` `ctrl+s` | send a queued message now (a running command goes to the background) |
|
|
76
77
|
| `ctrl+t` / `ctrl+n` | with tabs on: new tab / next tab |
|
|
77
78
|
| `ctrl+c` twice | quit |
|
|
78
79
|
|
package/bin/ccode.js
CHANGED
|
@@ -16,9 +16,58 @@ try {
|
|
|
16
16
|
console.error("If yours is one of them, reinstall: npm install -g " + "@ccode-si/cli" + " --prefer-online");
|
|
17
17
|
process.exit(1);
|
|
18
18
|
}
|
|
19
|
-
|
|
19
|
+
if (process.platform === "win32") removeLeftovers();
|
|
20
|
+
// Here to take over "ccode update" on Windows (see updateFromHere).
|
|
21
|
+
const env = { ...process.env, CCODE_UPDATE_HANDOFF: "1" };
|
|
22
|
+
const result = spawnSync(binary, process.argv.slice(2), { stdio: "inherit", env });
|
|
20
23
|
if (result.error) {
|
|
21
24
|
console.error(result.error.message);
|
|
22
25
|
process.exit(1);
|
|
23
26
|
}
|
|
27
|
+
if (process.platform === "win32" && process.argv[2] === "update" && result.status === 75) process.exit(updateFromHere());
|
|
24
28
|
process.exit(result.status ?? (result.signal ? 1 : 0));
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Windows keeps a running program's files locked, so an update npm ran
|
|
32
|
+
* while CCode was open couldn't remove the old version: npm moved this
|
|
33
|
+
* whole package aside (".cli-1a2b3c4d" beside it, the binary inside, ~100
|
|
34
|
+
* MB) and left it. Removed here, at the next start — one still in use
|
|
35
|
+
* (another CCode window) only in part, the rest next time. A nested
|
|
36
|
+
* platform package's leftovers (".cli-win32-x64-…") too.
|
|
37
|
+
*/
|
|
38
|
+
function removeLeftovers() {
|
|
39
|
+
const { readdirSync, rmSync } = require("node:fs");
|
|
40
|
+
const { basename } = require("node:path");
|
|
41
|
+
const self = join(__dirname, "..");
|
|
42
|
+
const platform = dirname(dirname(binary));
|
|
43
|
+
for (const pkgDir of [self, platform]) {
|
|
44
|
+
const scope = dirname(pkgDir);
|
|
45
|
+
const leftover = "." + basename(pkgDir) + "-";
|
|
46
|
+
try {
|
|
47
|
+
for (const entry of readdirSync(scope)) {
|
|
48
|
+
if (!entry.startsWith(leftover)) continue;
|
|
49
|
+
try {
|
|
50
|
+
rmSync(join(scope, entry), { recursive: true, force: true });
|
|
51
|
+
} catch {
|
|
52
|
+
// still in use: next time
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
} catch {
|
|
56
|
+
// no scope folder to look in
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* "ccode update" on Windows: the binary found a newer version and exited,
|
|
63
|
+
* so npm can now replace it (see removeLeftovers).
|
|
64
|
+
*/
|
|
65
|
+
function updateFromHere() {
|
|
66
|
+
removeLeftovers();
|
|
67
|
+
console.log("(Close any other CCode windows first: Windows can't replace a program that's running.)");
|
|
68
|
+
// One command line (npm is npm.cmd: only a shell finds it).
|
|
69
|
+
const npm = spawnSync("npm install -g @ccode-si/cli@latest --prefer-online", { stdio: "inherit", shell: true });
|
|
70
|
+
if (npm.status === 0) console.log("Updated.");
|
|
71
|
+
else console.error("The update didn't finish. Close other CCode windows and run: ccode update");
|
|
72
|
+
return npm.status ?? 1;
|
|
73
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ccode-si/cli",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.8.1",
|
|
4
4
|
"description": "CCode — a coding agent for your terminal.",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE",
|
|
6
6
|
"bin": {
|
|
@@ -15,11 +15,11 @@
|
|
|
15
15
|
"node": ">=18"
|
|
16
16
|
},
|
|
17
17
|
"optionalDependencies": {
|
|
18
|
-
"@ccode-si/cli-darwin-arm64": "1.
|
|
19
|
-
"@ccode-si/cli-darwin-x64": "1.
|
|
20
|
-
"@ccode-si/cli-win32-x64": "1.
|
|
21
|
-
"@ccode-si/cli-win32-arm64": "1.
|
|
22
|
-
"@ccode-si/cli-linux-x64": "1.
|
|
23
|
-
"@ccode-si/cli-linux-arm64": "1.
|
|
18
|
+
"@ccode-si/cli-darwin-arm64": "1.8.1",
|
|
19
|
+
"@ccode-si/cli-darwin-x64": "1.8.1",
|
|
20
|
+
"@ccode-si/cli-win32-x64": "1.8.1",
|
|
21
|
+
"@ccode-si/cli-win32-arm64": "1.8.1",
|
|
22
|
+
"@ccode-si/cli-linux-x64": "1.8.1",
|
|
23
|
+
"@ccode-si/cli-linux-arm64": "1.8.1"
|
|
24
24
|
}
|
|
25
25
|
}
|