@raytrace-cli/cli 0.17.14 → 0.17.15

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/README.md CHANGED
@@ -24,6 +24,7 @@
24
24
  <a href="https://pypi.org/project/raytrace-cli/">PyPI</a> ·
25
25
  <a href="docs/mcp.md">MCP</a> ·
26
26
  <a href="CONTRIBUTING.md">Contributing</a> ·
27
+ <a href="https://discord.gg/k7VWV5Gac9">Discord</a> ·
27
28
  <a href="https://github.com/Godcreatebugs/raytrace-cli/issues">Report an issue</a>
28
29
  </p>
29
30
 
@@ -32,6 +33,7 @@
32
33
  <a href="https://pypi.org/project/raytrace-cli/"><img src="https://img.shields.io/pypi/v/raytrace-cli?style=flat-square" alt="PyPI" /></a>
33
34
  <a href="LICENSE"><img src="https://img.shields.io/badge/license-MIT-blue?style=flat-square" alt="MIT license" /></a>
34
35
  <a href="https://www.raytracer.si/"><img src="https://img.shields.io/badge/website-raytracer.si-111315?style=flat-square" alt="raytracer.si" /></a>
36
+ <a href="https://discord.gg/k7VWV5Gac9"><img src="https://img.shields.io/badge/Discord-join-5865F2?style=flat-square&logo=discord&logoColor=white" alt="Discord" /></a>
35
37
  </p>
36
38
 
37
39
  ## Why sandboxing matters
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@raytrace-cli/cli",
3
- "version": "0.17.14",
3
+ "version": "0.17.15",
4
4
  "mcpName": "io.github.Godcreatebugs/raytrace",
5
5
  "description": "See what your coding agent did: traces, tool calls, cost and step-by-step evidence for Claude Code and Codex.",
6
6
  "license": "MIT",
package/src/commands.mjs CHANGED
@@ -7,6 +7,7 @@ import { portOf, proxyEnv, readConfig, writeConfig } from './config.mjs';
7
7
  import { checkRunningPid, dashboardLink, healthy, portInUse, PROXY_API, proxyApi, runningPid, start, status, stop } from './proxy-process.mjs';
8
8
  import { HOOK_COMMAND, hookState, setHook } from './claude-code.mjs';
9
9
  import { askSecret, confirm, interactive } from './prompt.mjs';
10
+ import { maybeStarPrompt } from './star.mjs';
10
11
 
11
12
  const say = (line = '') => console.log(line);
12
13
  const CLOUD_URL = 'https://app.raytracer.si';
@@ -65,10 +66,11 @@ export async function setup(flags) {
65
66
 
66
67
  // A proxy this CLI started is restarted so the new settings apply.
67
68
  const port = portOf(readConfig());
68
- if (runningPid()) { await stop(); say('\nRestarting RayTrace with the new settings.'); await startCommand(); return; }
69
- if (await healthy(port)) { say(`\nA RayTrace proxy started outside this CLI is answering on :${port}; stop it to use these settings.`); return; }
70
- if (flags['no-start'] || (!yes && !(await confirm('\nStart RayTrace now?', true)))) { say('\nRun `raytrace start` when you are ready.'); return; }
71
- await startCommand({ open: !yes });
69
+ if (runningPid()) { await stop(); say('\nRestarting RayTrace with the new settings.'); await startCommand(); }
70
+ else if (await healthy(port)) say(`\nA RayTrace proxy started outside this CLI is answering on :${port}; stop it to use these settings.`);
71
+ else if (flags['no-start'] || (!yes && !(await confirm('\nStart RayTrace now?', true)))) say('\nRun `raytrace start` when you are ready.');
72
+ else await startCommand({ open: !yes });
73
+ maybeStarPrompt(flags);
72
74
  }
73
75
 
74
76
  // --------------------------------------------------------- start / stop / status
package/src/star.mjs ADDED
@@ -0,0 +1,61 @@
1
+ // One line after the first successful `raytrace setup`. It never asks a
2
+ // question or opens a browser. A file in the RayTrace home (next to
3
+ // config.env) remembers that this machine already saw it. A run that is not
4
+ // a person at a terminal does not print it and does not write that file, so
5
+ // the next real setup still can.
6
+ import { existsSync, mkdirSync, writeFileSync } from 'node:fs';
7
+ import { join } from 'node:path';
8
+ import { paths } from './paths.mjs';
9
+
10
+ export const STAR_URL = 'https://github.com/Godcreatebugs/raytrace-cli';
11
+ export const STAR_LINE = `If RayTrace is useful to you, a star on the repo helps other developers find it: ${STAR_URL}`;
12
+ const FLAG = 'star-prompted';
13
+
14
+ function optedOut(env) {
15
+ const value = env.RAYTRACE_NO_STAR_PROMPT;
16
+ return value === '1' || value === 'true';
17
+ }
18
+
19
+ // Any non-empty CI value counts, including "false": the variable being set is
20
+ // the signal that this run is not a person sitting at the setup output.
21
+ function ciSet(env) {
22
+ return typeof env.CI === 'string' && env.CI !== '';
23
+ }
24
+
25
+ function machineReadable(flags) {
26
+ if (!flags) return false;
27
+ if (flags.json || flags.quiet || flags.silent) return true;
28
+ return String(flags.format || '').toLowerCase() === 'json';
29
+ }
30
+
31
+ function suppressed(flags, env, stdout, stdin) {
32
+ if (optedOut(env)) return true;
33
+ if (ciSet(env)) return true;
34
+ if (!stdout?.isTTY || !stdin?.isTTY) return true;
35
+ return machineReadable(flags);
36
+ }
37
+
38
+ /**
39
+ * Print the star line when this machine has not seen it and this run is an
40
+ * interactive terminal. Returns whether it printed. `deps` is for tests.
41
+ */
42
+ export function maybeStarPrompt(flags = {}, deps = {}) {
43
+ const env = deps.env ?? process.env;
44
+ const stdout = deps.stdout ?? process.stdout;
45
+ const stdin = deps.stdin ?? process.stdin;
46
+ const log = deps.log ?? ((line) => console.log(line));
47
+ const home = deps.home ?? paths.home;
48
+ if (suppressed(flags, env, stdout, stdin)) return false;
49
+ const flag = join(home, FLAG);
50
+ if (existsSync(flag)) return false;
51
+ try {
52
+ mkdirSync(home, { recursive: true });
53
+ writeFileSync(flag, '1\n', { flag: 'wx' });
54
+ } catch {
55
+ // Setup must not fail, or ask again on every run, because the flag could
56
+ // not be saved. Skip the line instead.
57
+ return false;
58
+ }
59
+ log(STAR_LINE);
60
+ return true;
61
+ }