Skip to content

Commit 8852092

Browse files
authored
Merge pull request #17 from ersinkoc/master
2 parents 91fdd52 + b960832 commit 8852092

File tree

7 files changed

+75
-31
lines changed

7 files changed

+75
-31
lines changed

editors/antigravity.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const { execSync } = require('child_process');
1+
const { execSync, execFileSync } = require('child_process');
22
const os = require('os');
33

44
// Static fallback for legacy placeholders no longer returned by the LS
@@ -62,16 +62,19 @@ const IS_WINDOWS = process.platform === 'win32';
6262
function getProcessList() {
6363
try {
6464
if (IS_WINDOWS) {
65-
const output = execSync('wmic process get CommandLine,ProcessId /format:csv', {
65+
// Use PowerShell Get-Process (WMIC is deprecated in Windows 10/11)
66+
const output = execFileSync('powershell', ['-Command', 'Get-Process | Select-Object Id, Path, CommandLine | ConvertTo-Csv -NoTypeInformation'], {
6667
encoding: 'utf-8',
6768
maxBuffer: 10 * 1024 * 1024,
6869
});
70+
// Parse CSV: skip header
6971
const lines = output.split('\n').slice(1);
7072
return lines.map(line => {
7173
const parts = line.split(',');
72-
if (parts.length < 2) return null;
73-
const commandLine = parts.slice(0, -1).join(',').trim().replace(/^"|"$/g, '');
74-
const pid = parts[parts.length - 1].trim();
74+
if (parts.length < 3) return null;
75+
const pid = parts[0].trim().replace(/^"|"$/g, '');
76+
const commandLine = parts[2].trim().replace(/^"|"$/g, '');
77+
if (!pid || !commandLine) return null;
7578
return { commandLine, pid };
7679
}).filter(Boolean);
7780
} else {
@@ -90,7 +93,8 @@ function getProcessList() {
9093
function getListeningPorts(pid) {
9194
try {
9295
if (IS_WINDOWS) {
93-
const output = execSync(`netstat -ano | findstr ${pid}`, {
96+
// Use PowerShell to get netstat output and filter by PID
97+
const output = execFileSync('powershell', ['-Command', `netstat -ano | Select-String "${pid}$"`], {
9498
encoding: 'utf-8',
9599
maxBuffer: 10 * 1024 * 1024,
96100
});

editors/goose.js

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,36 @@
11
const path = require('path');
22
const fs = require('fs');
33
const os = require('os');
4-
const { execSync } = require('child_process');
54

65
const GOOSE_DIR = path.join(os.homedir(), '.local', 'share', 'goose', 'sessions');
76
const DB_PATH = path.join(GOOSE_DIR, 'sessions.db');
87
const CONFIG_PATH = path.join(os.homedir(), '.config', 'goose', 'config.yaml');
98

109
// ============================================================
11-
// Query SQLite via CLI
10+
// Query SQLite via better-sqlite3 (cross-platform)
1211
// ============================================================
1312

13+
let Database;
14+
function getDatabase() {
15+
if (!Database) {
16+
try {
17+
Database = require('better-sqlite3');
18+
} catch {
19+
// better-sqlite3 not available
20+
}
21+
}
22+
return Database;
23+
}
24+
1425
function queryDb(sql) {
1526
if (!fs.existsSync(DB_PATH)) return [];
27+
const Db = getDatabase();
28+
if (!Db) return []; // Fallback if better-sqlite3 not available
1629
try {
17-
const raw = execSync(
18-
`sqlite3 -json ${JSON.stringify(DB_PATH)} ${JSON.stringify(sql)}`,
19-
{ encoding: 'utf-8', maxBuffer: 10 * 1024 * 1024, stdio: ['pipe', 'pipe', 'pipe'] }
20-
);
21-
return JSON.parse(raw);
30+
const db = new Db(DB_PATH, { readonly: true });
31+
const rows = db.prepare(sql).all();
32+
db.close();
33+
return rows;
2234
} catch { return []; }
2335
}
2436

editors/windsurf.js

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const { execSync } = require('child_process');
1+
const { execSync, execFileSync } = require('child_process');
22
const path = require('path');
33
const os = require('os');
44
const fs = require('fs');
@@ -18,18 +18,19 @@ const IS_WINDOWS = process.platform === 'win32';
1818
function getProcessList() {
1919
try {
2020
if (IS_WINDOWS) {
21-
// wmic provides CSV-formatted process data
22-
const output = execSync('wmic process get CommandLine,ProcessId /format:csv', {
21+
// Use PowerShell Get-Process (WMIC is deprecated in Windows 10/11)
22+
const output = execFileSync('powershell', ['-Command', 'Get-Process | Select-Object Id, Path, CommandLine | ConvertTo-Csv -NoTypeInformation'], {
2323
encoding: 'utf-8',
2424
maxBuffer: 10 * 1024 * 1024,
2525
});
26-
// Parse CSV: skip header, split by comma
26+
// Parse CSV: skip header
2727
const lines = output.split('\n').slice(1);
2828
return lines.map(line => {
2929
const parts = line.split(',');
30-
if (parts.length < 2) return null;
31-
const commandLine = parts.slice(0, -1).join(',').trim().replace(/^"|"$/g, '');
32-
const pid = parts[parts.length - 1].trim();
30+
if (parts.length < 3) return null;
31+
const pid = parts[0].trim().replace(/^"|"$/g, '');
32+
const commandLine = parts[2].trim().replace(/^"|"$/g, '');
33+
if (!pid || !commandLine) return null;
3334
return { commandLine, pid };
3435
}).filter(Boolean);
3536
} else {
@@ -49,8 +50,8 @@ function getProcessList() {
4950
function getListeningPorts(pid) {
5051
try {
5152
if (IS_WINDOWS) {
52-
// netstat -ano shows PID in the last column
53-
const output = execSync(`netstat -ano | findstr ${pid}`, {
53+
// Use PowerShell to get netstat output and filter by PID
54+
const output = execFileSync('powershell', ['-Command', `netstat -ano | Select-String "${pid}$"`], {
5455
encoding: 'utf-8',
5556
maxBuffer: 10 * 1024 * 1024,
5657
});

editors/zed.js

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
const path = require('path');
22
const fs = require('fs');
33
const os = require('os');
4-
const { execSync } = require('child_process');
54

65
const Database = require('better-sqlite3');
76

@@ -24,15 +23,36 @@ function getZedDataPath() {
2423
const THREADS_DB = path.join(getZedDataPath(), 'threads', 'threads.db');
2524

2625
// ============================================================
27-
// Decompress zstd blob via CLI
26+
// Decompress zstd blob via CLI (with cross-platform support)
2827
// ============================================================
2928

3029
function decompressZstd(buf) {
3130
const tmpIn = path.join(os.tmpdir(), `zed_thread_${Date.now()}.zst`);
3231
const tmpOut = tmpIn.replace('.zst', '.json');
3332
try {
3433
fs.writeFileSync(tmpIn, buf);
35-
execSync(`zstd -d -f -q ${JSON.stringify(tmpIn)} -o ${JSON.stringify(tmpOut)}`, { stdio: ['pipe', 'pipe', 'pipe'] });
34+
35+
// Try zstd CLI first
36+
try {
37+
const { execFileSync } = require('child_process');
38+
const zstdCmd = process.platform === 'win32' ? 'zstd.exe' : 'zstd';
39+
execFileSync(zstdCmd, ['-d', '-f', '-q', tmpIn, '-o', tmpOut], { stdio: ['pipe', 'pipe', 'pipe'] });
40+
} catch {
41+
// Fallback: try using Node.js zstd library if available
42+
try {
43+
const zlib = require('zlib');
44+
// Check if Node version supports zstd natively (v22+)
45+
if (zlib.createZstdDecompress) {
46+
const decompressed = zlib.zstdDecompressSync(buf);
47+
fs.writeFileSync(tmpOut, decompressed);
48+
} else {
49+
throw new Error('zstd not available');
50+
}
51+
} catch {
52+
throw new Error('zstd decompression not available on this system');
53+
}
54+
}
55+
3656
const data = fs.readFileSync(tmpOut, 'utf-8');
3757
return data;
3858
} finally {

server.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,8 +338,15 @@ app.get('/api/check-ai', async (req, res) => {
338338
if (!folder) return res.status(400).json({ error: 'folder query param required' });
339339
try {
340340
const { execFile } = require('child_process');
341+
const isWindows = process.platform === 'win32';
342+
// On Windows, use npx.cmd with shell; on Unix, use npx directly
343+
const cmd = isWindows ? 'npx.cmd' : 'npx';
341344
const result = await new Promise((resolve, reject) => {
342-
execFile('npx', ['-y', 'check-ai', '--json', folder], { timeout: 60000, maxBuffer: 1024 * 1024 }, (err, stdout) => {
345+
execFile(cmd, ['-y', 'check-ai', '--json', folder], {
346+
timeout: 60000,
347+
maxBuffer: 1024 * 1024,
348+
shell: isWindows
349+
}, (err, stdout) => {
343350
try {
344351
const json = JSON.parse(stdout);
345352
resolve(json);

ui/src/components/AiAuditCard.jsx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,14 @@ function Tip({ missing }) {
6868
}
6969

7070
export default function AiAuditCard({ folder }) {
71+
console.log('AiAuditCard rendering, folder:', folder)
7172
const [audit, setAudit] = useState(null)
7273
const [loading, setLoading] = useState(false)
7374
const [error, setError] = useState(null)
7475
const [expanded, setExpanded] = useState(new Set())
75-
const ran = useRef(false)
7676

7777
const runAudit = async () => {
78+
if (!folder) return
7879
setLoading(true)
7980
setError(null)
8081
try {
@@ -88,10 +89,8 @@ export default function AiAuditCard({ folder }) {
8889
}
8990

9091
useEffect(() => {
91-
if (folder && !ran.current) {
92-
ran.current = true
93-
runAudit()
94-
}
92+
console.log('AiAuditCard useEffect triggered, folder:', folder)
93+
runAudit()
9594
}, [folder])
9695

9796
if (loading) {

ui/src/pages/ProjectDetail.jsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,7 @@ export default function ProjectDetail() {
235235
</div>
236236

237237
{/* AI Readiness Audit */}
238+
{console.log('Rendering AiAuditCard, folder:', folder)}
238239
<AiAuditCard folder={folder} />
239240

240241
{/* Sessions */}

0 commit comments

Comments
 (0)