claude-token-saver 2.0.3 → 2.1.0
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 +49 -0
- package/bin/cli.js +222 -9
- package/package.json +1 -1
- package/src/advice.js +48 -41
- package/src/config.js +151 -0
- package/src/demo.js +251 -0
- package/src/formatters/statusline.js +36 -19
- package/src/formatters/table.js +9 -9
- package/src/history.js +123 -0
- package/src/installer.js +136 -0
- package/src/paths.js +41 -0
package/src/paths.js
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cross-platform user-data path resolution.
|
|
3
|
+
*
|
|
4
|
+
* Order of precedence:
|
|
5
|
+
* 1. $XDG_CONFIG_HOME (explicit override, honored on every platform)
|
|
6
|
+
* 2. %APPDATA% on Windows (e.g. C:\Users\foo\AppData\Roaming)
|
|
7
|
+
* 3. ~/Library/Application Support on macOS
|
|
8
|
+
* 4. ~/.config on Linux / fallback
|
|
9
|
+
*
|
|
10
|
+
* All paths are joined via node:path so the OS-correct separator is used
|
|
11
|
+
* automatically. Callers are responsible for `mkdirSync(..., { recursive: true })`
|
|
12
|
+
* before writing — every helper here returns a path string only.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import { join } from 'node:path';
|
|
16
|
+
import { homedir } from 'node:os';
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Returns the base directory for this tool's user-level data
|
|
20
|
+
* (config, history, last-chip state).
|
|
21
|
+
*/
|
|
22
|
+
export function userDataDir() {
|
|
23
|
+
if (process.env.XDG_CONFIG_HOME) {
|
|
24
|
+
return join(process.env.XDG_CONFIG_HOME, 'claude-token-saver');
|
|
25
|
+
}
|
|
26
|
+
if (process.platform === 'win32' && process.env.APPDATA) {
|
|
27
|
+
return join(process.env.APPDATA, 'claude-token-saver');
|
|
28
|
+
}
|
|
29
|
+
if (process.platform === 'darwin') {
|
|
30
|
+
return join(homedir(), 'Library', 'Application Support', 'claude-token-saver');
|
|
31
|
+
}
|
|
32
|
+
return join(homedir(), '.config', 'claude-token-saver');
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Returns the user's Claude Code config root (~/.claude on every OS Claude
|
|
37
|
+
* Code supports — the CLI itself uses this path on Windows and macOS too).
|
|
38
|
+
*/
|
|
39
|
+
export function claudeUserDir() {
|
|
40
|
+
return join(homedir(), '.claude');
|
|
41
|
+
}
|