copilot-tracer 1.0.7 → 1.0.8

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/dist/cli.js +36 -1
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -11,6 +11,7 @@ import { renderConsoleTable } from './consoleUi.js';
11
11
  import { startWebServer } from './webServer.js';
12
12
  import { runSetup } from './setup.js';
13
13
  import open from 'open';
14
+ import os from 'os';
14
15
  program
15
16
  .name('copilot-tracer')
16
17
  .description('Real-time monitor and tracer for GitHub Copilot CLI')
@@ -30,7 +31,41 @@ const port = parseInt(opts.port);
30
31
  // Handle --setup: patch env files, apply to current process, then fall through to start web UI
31
32
  if (opts.setup) {
32
33
  runSetup(port, opts.daemon);
33
- if (!opts.daemon) {
34
+ if (opts.daemon) {
35
+ // Relaunch as a detached background daemon so the terminal doesn't need to stay open.
36
+ const dir = path.join(os.homedir(), '.copilot-tracer');
37
+ fs.mkdirSync(dir, { recursive: true });
38
+ const pidFile = path.join(dir, 'daemon.pid');
39
+ const existingPid = fs.existsSync(pidFile) ? parseInt(fs.readFileSync(pidFile, 'utf8'), 10) : NaN;
40
+ const alreadyRunning = !isNaN(existingPid) && (() => {
41
+ try {
42
+ process.kill(existingPid, 0);
43
+ return true;
44
+ }
45
+ catch {
46
+ return false;
47
+ }
48
+ })();
49
+ if (alreadyRunning) {
50
+ console.log(`\n 🤖 Daemon already running (pid ${existingPid})`);
51
+ console.log(` 🌐 Dashboard: http://localhost:${port}/\n`);
52
+ }
53
+ else {
54
+ const logFile = fs.openSync(path.join(dir, 'daemon.log'), 'a');
55
+ const child = spawn(process.execPath, [process.argv[1], '--daemon', '--port', String(port)], {
56
+ detached: true,
57
+ stdio: ['ignore', logFile, logFile],
58
+ });
59
+ child.unref();
60
+ fs.writeFileSync(pidFile, String(child.pid));
61
+ console.log(`\n 🤖 Daemon started in background (pid ${child.pid})`);
62
+ console.log(` 🌐 Dashboard: http://localhost:${port}/`);
63
+ console.log(` 📄 Logs: ${path.join(dir, 'daemon.log')}`);
64
+ console.log(` Stop it with: kill ${child.pid}\n`);
65
+ }
66
+ process.exit(0);
67
+ }
68
+ else {
34
69
  opts.proxy = false;
35
70
  opts.ui = 'web';
36
71
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "copilot-tracer",
3
- "version": "1.0.7",
3
+ "version": "1.0.8",
4
4
  "description": "Real-time tracing and prompt-refinement companion for GitHub Copilot CLI and VS Code Copilot — tracks tokens, AI credits, tool calls, and refined prompts with console and web UI",
5
5
  "keywords": [
6
6
  "copilot",