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