aicp-tracker 1.1.5 → 1.1.6
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/package.json +1 -1
- package/src/daemon-worker.js +12 -1
- package/src/daemon.js +13 -4
package/package.json
CHANGED
package/src/daemon-worker.js
CHANGED
|
@@ -5,11 +5,22 @@
|
|
|
5
5
|
const path = require('path');
|
|
6
6
|
const fs = require('fs');
|
|
7
7
|
const { CONFIG_DIR } = require('./config');
|
|
8
|
-
const { tick } = require('./daemon');
|
|
8
|
+
const { tick, PROJECT_PATH } = require('./daemon');
|
|
9
9
|
|
|
10
10
|
const PID_FILE = path.join(CONFIG_DIR, 'daemon.pid');
|
|
11
|
+
const LOG_FILE = path.join(CONFIG_DIR, 'daemon.log');
|
|
12
|
+
|
|
13
|
+
fs.mkdirSync(CONFIG_DIR, { recursive: true });
|
|
11
14
|
fs.writeFileSync(PID_FILE, String(process.pid), 'utf8');
|
|
12
15
|
|
|
16
|
+
// Redirect stdout/stderr to log file so we can inspect daemon activity
|
|
17
|
+
const logStream = fs.createWriteStream(LOG_FILE, { flags: 'a' });
|
|
18
|
+
const origWrite = (chunk) => logStream.write(`[${new Date().toISOString()}] ${chunk}`);
|
|
19
|
+
process.stdout.write = origWrite;
|
|
20
|
+
process.stderr.write = origWrite;
|
|
21
|
+
|
|
22
|
+
console.log(`[daemon-worker] started, tracking project: ${PROJECT_PATH}`);
|
|
23
|
+
|
|
13
24
|
process.on('SIGTERM', () => {
|
|
14
25
|
try { fs.unlinkSync(PID_FILE); } catch {}
|
|
15
26
|
process.exit(0);
|
package/src/daemon.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
const path = require('path');
|
|
4
4
|
const fs = require('fs');
|
|
5
|
+
const os = require('os');
|
|
5
6
|
const { findJsonlFiles } = require('./log-scanner');
|
|
6
7
|
const { parseNewLines } = require('./log-parser');
|
|
7
8
|
const wal = require('./wal');
|
|
@@ -78,9 +79,17 @@ function stop() {
|
|
|
78
79
|
function status() {
|
|
79
80
|
const pid = readPid();
|
|
80
81
|
const running = pid ? (() => { try { process.kill(pid, 0); return true; } catch { return false; } })() : false;
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
82
|
+
const { pathToProjectFolder } = require('./log-scanner');
|
|
83
|
+
const claudeFolder = pathToProjectFolder(PROJECT_PATH);
|
|
84
|
+
const claudeDir = path.join(os.homedir(), '.claude', 'projects');
|
|
85
|
+
const available = fs.existsSync(claudeDir) ? fs.readdirSync(claudeDir).filter(e => fs.statSync(path.join(claudeDir, e)).isDirectory()) : [];
|
|
86
|
+
const matched = available.includes(claudeFolder);
|
|
87
|
+
console.log(`[daemon] Status: ${running ? `running (pid ${pid})` : 'stopped'}`);
|
|
88
|
+
console.log(`[daemon] Project path: ${PROJECT_PATH}`);
|
|
89
|
+
console.log(`[daemon] Claude folder: ${claudeFolder} ${matched ? '✔ found' : '✘ NOT FOUND in ~/.claude/projects'}`);
|
|
90
|
+
if (!matched) console.log(`[daemon] Available: ${available.join(', ')}`);
|
|
91
|
+
console.log(`[daemon] WAL pending: ${wal.pendingCount()} records`);
|
|
92
|
+
console.log(`[daemon] Log file: ${path.join(CONFIG_DIR, 'daemon.log')}`);
|
|
84
93
|
}
|
|
85
94
|
|
|
86
|
-
module.exports = { start, stop, status, tick };
|
|
95
|
+
module.exports = { start, stop, status, tick, PROJECT_PATH };
|