cicy-code 0.2.16 → 2.1.46

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/bin/cicy-code.js CHANGED
@@ -6,10 +6,8 @@ const https = require('https');
6
6
 
7
7
  const pkg = require('../package.json');
8
8
  const binPath = path.join(__dirname, 'cicy-code');
9
- const os = require('os');
10
9
 
11
10
  const cn = process.argv.includes('--cn') || process.env.CN_MIRROR === '1';
12
- const desktopMode = process.argv.includes('--desktop');
13
11
 
14
12
  if (process.argv.includes('--cn')) {
15
13
  process.env.CN_MIRROR = '1';
@@ -88,11 +86,6 @@ async function main() {
88
86
  process.exit(1);
89
87
  }
90
88
 
91
- // Desktop mode: start API server in background, then launch Electron
92
- if (desktopMode) {
93
- return launchDesktop();
94
- }
95
-
96
89
  const child = spawn(binPath, process.argv.slice(2), {
97
90
  stdio: 'inherit',
98
91
  env: process.env
@@ -100,128 +93,4 @@ async function main() {
100
93
  child.on('exit', (code) => process.exit(code || 0));
101
94
  }
102
95
 
103
- function getToken() {
104
- try {
105
- const globalJson = path.join(os.homedir(), 'global.json');
106
- const data = JSON.parse(fs.readFileSync(globalJson, 'utf8'));
107
- return data.api_token || '';
108
- } catch { return ''; }
109
- }
110
-
111
- function waitForServer(port, timeout) {
112
- const http = require('http');
113
- const start = Date.now();
114
- return new Promise((resolve, reject) => {
115
- const check = () => {
116
- if (Date.now() - start > timeout) return reject(new Error('Server start timeout'));
117
- const req = http.get(`http://127.0.0.1:${port}/api/health`, (res) => {
118
- resolve();
119
- });
120
- req.on('error', () => setTimeout(check, 500));
121
- req.setTimeout(1000, () => { req.destroy(); setTimeout(check, 500); });
122
- };
123
- check();
124
- });
125
- }
126
-
127
- async function launchDesktop() {
128
- const port = process.env.PORT || 8008;
129
- const desktopPort = 18101;
130
-
131
- // 0. Kill existing electron/cicy-code and free ports
132
- try { execSync(`pkill -f 'electron' 2>/dev/null || true`, { shell: true }); } catch {}
133
- try { execSync(`lsof -ti:${desktopPort} | xargs kill -9 2>/dev/null || true`, { shell: true }); } catch {}
134
- try { execSync(`lsof -ti:${port} | xargs kill -9 2>/dev/null || true`, { shell: true }); } catch {}
135
- await new Promise(resolve => setTimeout(resolve, 500));
136
-
137
- // 1. Start API server in background
138
- const serverArgs = process.argv.slice(2).filter(a => a !== '--desktop');
139
- const isWin = process.platform === 'win32';
140
- const server = spawn(isWin ? binPath : 'nohup', isWin ? serverArgs : [binPath, ...serverArgs], {
141
- stdio: 'ignore',
142
- detached: true,
143
- env: { ...process.env, CICY_NO_BROWSER: '1', TERM: process.env.TERM || 'xterm-256color' }
144
- });
145
- server.on('exit', (code, signal) => console.error(` ⚠️ Server exited code=${code} signal=${signal}`));
146
- server.unref();
147
- console.log(` 🚀 Starting cicy-code server (PID: ${server.pid})...`);
148
-
149
- // 2. Wait for server ready
150
- try {
151
- await waitForServer(port, 30000);
152
- } catch {
153
- console.error(' ❌ Server failed to start within 30s');
154
- process.exit(1);
155
- }
156
- console.log(` ✅ Server ready on port ${port}`);
157
-
158
- // 3. Get token
159
- const token = getToken();
160
- const url = `http://127.0.0.1:${port}/?token=${token}`;
161
-
162
- // 4. Launch Electron via global 'electron' binary (no signing needed)
163
- // cicy-desktop uses official Electron binary + our JS code
164
- // RPC/MCP server starts on desktopPort (18101)
165
- let electronBinary = null;
166
- try {
167
- electronBinary = execSync('which electron 2>/dev/null', { encoding: 'utf8' }).trim();
168
- } catch {}
169
-
170
- if (!electronBinary) {
171
- console.log(' ⚠️ Electron not found. Installing...');
172
- try {
173
- execSync('npm install -g electron', { stdio: 'inherit' });
174
- electronBinary = execSync('which electron', { encoding: 'utf8' }).trim();
175
- } catch {
176
- console.error(' ❌ Failed to install Electron. Install manually: npm install -g electron');
177
- console.log(` 📱 Fallback: open browser → ${url}`);
178
- return;
179
- }
180
- }
181
-
182
- // Find cicy-desktop package (global cicy or bundled desktop/)
183
- let desktopDir = null;
184
-
185
- // Check global 'cicy-desktop' package
186
- try {
187
- const cicyBin = execSync('which cicy 2>/dev/null', { encoding: 'utf8' }).trim();
188
- desktopDir = path.resolve(path.dirname(cicyBin), '..', 'lib', 'node_modules', 'cicy-desktop');
189
- if (!fs.existsSync(path.join(desktopDir, 'src', 'main.js'))) desktopDir = null;
190
- } catch {}
191
-
192
- // Fallback: bundled desktop/ submodule
193
- if (!desktopDir) {
194
- const bundled = path.join(__dirname, '..', '..', 'desktop');
195
- if (fs.existsSync(path.join(bundled, 'src', 'main.js'))) {
196
- desktopDir = bundled;
197
- }
198
- }
199
-
200
- if (!desktopDir) {
201
- console.log(' ⚠️ cicy-desktop not found. Installing...');
202
- try {
203
- execSync('npm install -g cicy-desktop', { stdio: 'inherit' });
204
- const cicyBin = execSync('which cicy', { encoding: 'utf8' }).trim();
205
- desktopDir = path.resolve(path.dirname(cicyBin), '..', 'lib', 'node_modules', 'cicy-desktop');
206
- } catch {
207
- console.error(' ❌ Failed to install cicy. Install manually: npm install -g cicy-desktop');
208
- console.log(` 📱 Fallback: open browser → ${url}`);
209
- return;
210
- }
211
- }
212
-
213
- console.log(` 🖥️ Opening desktop: ${url}`);
214
- console.log(` 🔧 RPC/MCP server: http://127.0.0.1:${desktopPort}`);
215
-
216
- const desktop = spawn(electronBinary, [desktopDir, `--url=${url}`, `--port=${desktopPort}`], {
217
- stdio: 'inherit',
218
- env: { ...process.env, PORT: String(desktopPort) }
219
- });
220
-
221
- desktop.on('exit', (code) => {
222
- try { process.kill(server.pid); } catch {}
223
- process.exit(code || 0);
224
- });
225
- }
226
-
227
96
  main();
package/package.json CHANGED
@@ -1,7 +1,14 @@
1
1
  {
2
2
  "name": "cicy-code",
3
- "version": "0.2.16",
3
+ "publishConfig": {
4
+ "access": "public"
5
+ },
6
+ "version": "2.1.46",
4
7
  "description": "CiCy Code - AI-powered development environment",
8
+ "author": {
9
+ "name": "cicybot",
10
+ "email": "support@cicy-ai.com"
11
+ },
5
12
  "bin": {
6
13
  "cicy-code": "bin/cicy-code.js"
7
14
  },
@@ -9,7 +16,7 @@
9
16
  "postinstall": "node scripts/install.js"
10
17
  },
11
18
  "files": [
12
- "bin/",
19
+ "bin/cicy-code.js",
13
20
  "scripts/"
14
21
  ],
15
22
  "repository": {
@@ -17,7 +24,13 @@
17
24
  "url": "git+https://github.com/cicy-ai/cicy-code.git"
18
25
  },
19
26
  "homepage": "https://github.com/cicy-ai/cicy-code",
20
- "keywords": ["cicy", "code", "ai", "agent", "development"],
27
+ "keywords": [
28
+ "cicy",
29
+ "code",
30
+ "ai",
31
+ "agent",
32
+ "development"
33
+ ],
21
34
  "license": "MIT",
22
35
  "engines": {
23
36
  "node": ">=14"
package/bin/cicy-code DELETED
Binary file