cicy-code 2.1.48 → 2.1.49

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/bin/cicy-code.js +43 -33
  2. package/package.json +1 -1
package/bin/cicy-code.js CHANGED
@@ -1,15 +1,19 @@
1
1
  #!/usr/bin/env node
2
2
  // Launcher for the npm distribution. Resolves the prebuilt binary that ships
3
3
  // in the platform-specific optionalDependency (cicy-code-<os>-<cpu>) and execs
4
- // it — no network, no postinstall download.
4
+ // it — no network, no postinstall download. ALL binary args/subcommands are
5
+ // passed straight through (skill <...>, --dev, --hot, --helper=1, --agents=…,
6
+ // --public, --cn, etc.), so `npx cicy-code <anything>` == the binary.
5
7
  //
6
- // Before exec it mirrors dev.py's startup: if PORT (default 8008) is already
7
- // held by a *cicy-code* process it kills it and waits, so a stale instance
8
- // never blocks the new one. A non-cicy occupant is left alone and we abort
9
- // with a clear message (don't clobber someone else's server).
8
+ // Only when actually starting the server, it mirrors dev.py's startup: if PORT
9
+ // (default 8008) is held by a *cicy-code* process it kills it and waits, so a
10
+ // stale instance never blocks the new one. A non-cicy occupant is left alone
11
+ // and we abort. Utility invocations (--help/--version, `skill …`) skip the
12
+ // port dance entirely — `npx cicy-code --version` must never touch :8008.
10
13
  const { spawn, execSync } = require('child_process');
11
14
  const fs = require('fs');
12
15
 
16
+ const args = process.argv.slice(2);
13
17
  const PORT = process.env.PORT || '8008';
14
18
 
15
19
  const platformPkg = `cicy-code-${process.platform}-${process.arch}`;
@@ -26,7 +30,40 @@ try {
26
30
  }
27
31
  try { fs.chmodSync(binPath, 0o755); } catch {}
28
32
 
29
- // --- dev.py-style port hygiene on PORT (default 8008) ----------------------
33
+ // Utility invocations don't start the server, so they must NOT kill :8008.
34
+ const isUtility =
35
+ args.some((a) => a === '-h' || a === '--help' || a === '-v' || a === '--version') ||
36
+ args[0] === 'skill';
37
+
38
+ if (!isUtility) ensurePortFree(PORT);
39
+
40
+ const child = spawn(binPath, args, {
41
+ stdio: 'inherit',
42
+ env: { ...process.env, PORT },
43
+ });
44
+ child.on('exit', (code, signal) => {
45
+ if (signal) process.kill(process.pid, signal);
46
+ else process.exit(code == null ? 0 : code);
47
+ });
48
+
49
+ // --- dev.py-style port hygiene --------------------------------------------
50
+
51
+ function ensurePortFree(port) {
52
+ const existing = pidOnPort(port);
53
+ if (!existing) return;
54
+ const cmd = processCommand(existing);
55
+ if (/cicy-code/.test(cmd)) {
56
+ console.log(`cicy-code: stopping existing instance on :${port} (pid=${existing})`);
57
+ if (!killPid(existing) || pidOnPort(port)) {
58
+ console.error(`cicy-code: port ${port} still in use after kill — aborting`);
59
+ process.exit(1);
60
+ }
61
+ } else {
62
+ console.error(`cicy-code: port ${port} is held by a non-cicy process (pid=${existing}): ${cmd}`);
63
+ console.error(`cicy-code: free it or set PORT=<other> — aborting`);
64
+ process.exit(1);
65
+ }
66
+ }
30
67
 
31
68
  function pidOnPort(port) {
32
69
  // lsof first (macOS + Linux), then ss (Linux without lsof).
@@ -76,30 +113,3 @@ function killPid(pid) {
76
113
  catch (e) { if (e.code === 'ESRCH') return true; }
77
114
  return waitExit(pid, 2000);
78
115
  }
79
-
80
- const existing = pidOnPort(PORT);
81
- if (existing) {
82
- const cmd = processCommand(existing);
83
- if (/cicy-code/.test(cmd)) {
84
- console.log(`cicy-code: stopping existing instance on :${PORT} (pid=${existing})`);
85
- if (!killPid(existing) || pidOnPort(PORT)) {
86
- console.error(`cicy-code: port ${PORT} still in use after kill — aborting`);
87
- process.exit(1);
88
- }
89
- } else {
90
- console.error(`cicy-code: port ${PORT} is held by a non-cicy process (pid=${existing}): ${cmd}`);
91
- console.error(`cicy-code: free it or set PORT=<other> — aborting`);
92
- process.exit(1);
93
- }
94
- }
95
-
96
- // --- launch ----------------------------------------------------------------
97
-
98
- const child = spawn(binPath, process.argv.slice(2), {
99
- stdio: 'inherit',
100
- env: { ...process.env, PORT },
101
- });
102
- child.on('exit', (code, signal) => {
103
- if (signal) process.kill(process.pid, signal);
104
- else process.exit(code == null ? 0 : code);
105
- });
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "2.1.48",
6
+ "version": "2.1.49",
7
7
  "description": "CiCy Code - AI-powered development environment",
8
8
  "author": {
9
9
  "name": "cicybot",