@h1r-ai/croche-cli 0.5.1 → 0.5.2

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
@@ -120,6 +120,11 @@ On macOS the base is `~/Library/Application Support`; on Windows it is
120
120
  - `$env:LOCALAPPDATA\croche\debugger\connection.json`
121
121
  - `$env:LOCALAPPDATA\croche\control\connection.json`
122
122
 
123
+ Set `CROCHE_STATE_DIR` to an absolute directory to override the state root on any OS
124
+ (for example, to isolate tests). Files live beneath `CROCHE_STATE_DIR/croche/`;
125
+ relative values are refused. `XDG_STATE_HOME` applies only on Linux; macOS and
126
+ Windows retain their native defaults when `CROCHE_STATE_DIR` is unset.
127
+
123
128
  Nondefault ports use `connection-PORT.json`. `--connection-file`
124
129
  selects a debugger file; `--control-connection-file` or
125
130
  `CROCHE_CONTROL_CONNECTION_FILE` selects a broker file. Existing legacy debugger
package/dist/debugger.js CHANGED
@@ -28,7 +28,8 @@ function portNumber(value, fallback) { if (value === undefined)
28
28
  return fallback; if (!/^\d+$/.test(value) || Number(value) < 1 || Number(value) > 65535)
29
29
  throw new CliError('invalid_argument', 'Port must be an integer from 1 to 65535.'); return Number(value); }
30
30
  export function defaultConnectionFile(kind, env = process.env, port = kind === 'debugger' ? 8790 : 8791) {
31
- const state = process.platform === 'win32' ? (env.LOCALAPPDATA ?? join(homedir(), 'AppData', 'Local')) : process.platform === 'darwin' ? join(homedir(), 'Library', 'Application Support') : (env.XDG_STATE_HOME ?? join(homedir(), '.local', 'state'));
31
+ // Croche's explicit override isolates tests/embeddings without changing native OS defaults.
32
+ const state = env.CROCHE_STATE_DIR ?? (process.platform === 'win32' ? (env.LOCALAPPDATA ?? join(homedir(), 'AppData', 'Local')) : process.platform === 'darwin' ? join(homedir(), 'Library', 'Application Support') : (env.XDG_STATE_HOME ?? join(homedir(), '.local', 'state')));
32
33
  if (!isAbsolute(state))
33
34
  throw new CliError('invalid_configuration', 'The OS user state directory must be absolute.');
34
35
  return join(state, 'croche', kind, port === (kind === 'debugger' ? 8790 : 8791) ? 'connection.json' : `connection-${port}.json`);
@@ -163,7 +164,7 @@ async function launch(kind, connection, options = {}) {
163
164
  const script = fileURLToPath(new URL(kind === 'debugger' ? './debugger/server/server.js' : './bin.js', import.meta.url));
164
165
  // The children (debugger server, control broker) never resolve the state directory or touch
165
166
  // the connection file: the parent owns it and passes only the port and token. If a child ever
166
- // does, pass the variables defaultConnectionFile reads (LOCALAPPDATA, USERPROFILE, XDG_STATE_HOME, HOME).
167
+ // does, pass the variables defaultConnectionFile reads (CROCHE_STATE_DIR, LOCALAPPDATA, XDG_STATE_HOME).
167
168
  const env = {};
168
169
  for (const name of ['PATH', 'SystemRoot', 'WINDIR', 'TMPDIR', 'TEMP'])
169
170
  if (process.env[name])
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@h1r-ai/croche-cli",
3
- "version": "0.5.1",
3
+ "version": "0.5.2",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },