coolhand-cli 0.9.0 → 0.10.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 +4 -2
- package/dist/api/last-sync.d.ts.map +1 -1
- package/dist/api/last-sync.js +2 -1
- package/dist/api/last-sync.js.map +1 -1
- package/dist/base-url.d.ts +7 -0
- package/dist/base-url.d.ts.map +1 -0
- package/dist/base-url.js +14 -0
- package/dist/base-url.js.map +1 -0
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +85 -2
- package/dist/cli.js.map +1 -1
- package/dist/commands/analyze-claude-sessions.d.ts.map +1 -1
- package/dist/commands/analyze-claude-sessions.js +10 -21
- package/dist/commands/analyze-claude-sessions.js.map +1 -1
- package/dist/commands/login.d.ts.map +1 -1
- package/dist/commands/login.js +3 -2
- package/dist/commands/login.js.map +1 -1
- package/dist/commands/map-claude-projects.d.ts +22 -0
- package/dist/commands/map-claude-projects.d.ts.map +1 -0
- package/dist/commands/map-claude-projects.js +282 -0
- package/dist/commands/map-claude-projects.js.map +1 -0
- package/dist/commands/upload-client-file.d.ts +3 -0
- package/dist/commands/upload-client-file.d.ts.map +1 -0
- package/dist/commands/upload-client-file.js +43 -0
- package/dist/commands/upload-client-file.js.map +1 -0
- package/dist/commands/wildcard.d.ts +6 -6
- package/dist/commands/wildcard.d.ts.map +1 -1
- package/dist/commands/wildcard.js +14 -11
- package/dist/commands/wildcard.js.map +1 -1
- package/dist/config.d.ts +11 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +31 -8
- package/dist/config.js.map +1 -1
- package/dist/errors.d.ts +1 -1
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js.map +1 -1
- package/dist/log-request.d.ts +4 -0
- package/dist/log-request.d.ts.map +1 -1
- package/dist/log-request.js +8 -1
- package/dist/log-request.js.map +1 -1
- package/dist/logger.d.ts +1 -0
- package/dist/logger.d.ts.map +1 -1
- package/dist/logger.js +30 -1
- package/dist/logger.js.map +1 -1
- package/dist/proxy/certs.d.ts.map +1 -1
- package/dist/proxy/certs.js +145 -5
- package/dist/proxy/certs.js.map +1 -1
- package/dist/proxy/interceptor.d.ts +8 -1
- package/dist/proxy/interceptor.d.ts.map +1 -1
- package/dist/proxy/interceptor.js +36 -3
- package/dist/proxy/interceptor.js.map +1 -1
- package/dist/proxy/proxy.d.ts.map +1 -1
- package/dist/proxy/proxy.js +4 -3
- package/dist/proxy/proxy.js.map +1 -1
- package/dist/proxy/wrap-runner.d.ts +0 -12
- package/dist/proxy/wrap-runner.d.ts.map +1 -1
- package/dist/proxy/wrap-runner.js +24 -11
- package/dist/proxy/wrap-runner.js.map +1 -1
- package/dist/sessions/claude-scanner.d.ts +3 -0
- package/dist/sessions/claude-scanner.d.ts.map +1 -1
- package/dist/sessions/claude-scanner.js +8 -0
- package/dist/sessions/claude-scanner.js.map +1 -1
- package/dist/sessions/cowork-scanner.d.ts.map +1 -1
- package/dist/sessions/cowork-scanner.js +6 -1
- package/dist/sessions/cowork-scanner.js.map +1 -1
- package/dist/sessions/redact-secrets.d.ts.map +1 -1
- package/dist/sessions/redact-secrets.js +10 -2
- package/dist/sessions/redact-secrets.js.map +1 -1
- package/dist/sessions/session-filter.d.ts +3 -1
- package/dist/sessions/session-filter.d.ts.map +1 -1
- package/dist/sessions/session-filter.js +9 -3
- package/dist/sessions/session-filter.js.map +1 -1
- package/dist/types.d.ts +22 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/upload-client-file.d.ts +31 -0
- package/dist/upload-client-file.d.ts.map +1 -0
- package/dist/upload-client-file.js +81 -0
- package/dist/upload-client-file.js.map +1 -0
- package/dist/version.d.ts +2 -2
- package/dist/version.d.ts.map +1 -1
- package/dist/version.js +1 -1
- package/dist/version.js.map +1 -1
- package/package.json +6 -4
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { MapClaudeProjectsOptions } from '../types.js';
|
|
2
|
+
export interface MapClaudeProjectsDeps {
|
|
3
|
+
homedir?: () => string;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Find every directory named "claude" (see `isClaudeDirName`), searching recursively from
|
|
7
|
+
* `root`. A match is not itself searched further — its full contents are captured by
|
|
8
|
+
* `appendTree` instead, so a nested "claude" folder inside a match isn't double-reported as its
|
|
9
|
+
* own match. A *symlinked* "claude"/".claude" directory still counts as a match (dotfile
|
|
10
|
+
* managers like chezmoi/Stow/yadm commonly manage `~/.claude` this way) — only non-matching
|
|
11
|
+
* symlinked directories are skipped during further recursion, to avoid link loops and escaping
|
|
12
|
+
* `root`. Unreadable directories (permissions, etc.) are skipped rather than aborting the whole
|
|
13
|
+
* scan.
|
|
14
|
+
*
|
|
15
|
+
* Being recorded as a match here does not by itself mean its contents get walked — a matched
|
|
16
|
+
* symlink whose target resolves outside `root` is caller-checked (see `resolvesWithinRoot`,
|
|
17
|
+
* used in `run()`) and its contents are never enumerated, since nothing here constrains where a
|
|
18
|
+
* "claude"-named symlink's target actually lives.
|
|
19
|
+
*/
|
|
20
|
+
export declare function findClaudeDirs(root: string): Promise<string[]>;
|
|
21
|
+
export declare function run(opts: MapClaudeProjectsOptions, deps?: MapClaudeProjectsDeps): Promise<number>;
|
|
22
|
+
//# sourceMappingURL=map-claude-projects.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"map-claude-projects.d.ts","sourceRoot":"","sources":["../../src/commands/map-claude-projects.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAC;AAE5D,MAAM,WAAW,qBAAqB;IACpC,OAAO,CAAC,EAAE,MAAM,MAAM,CAAC;CACxB;AASD;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAgDpE;AA4HD,wBAAsB,GAAG,CAAC,IAAI,EAAE,wBAAwB,EAAE,IAAI,GAAE,qBAA0B,GAAG,OAAO,CAAC,MAAM,CAAC,CA0G3G"}
|
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
import { promises as fs } from 'fs';
|
|
2
|
+
import * as os from 'os';
|
|
3
|
+
import * as path from 'path';
|
|
4
|
+
import { randomBytes } from 'crypto';
|
|
5
|
+
import { CliError, ExitCode } from '../errors.js';
|
|
6
|
+
import { logger, redact } from '../logger.js';
|
|
7
|
+
import { uploadClientFile } from '../upload-client-file.js';
|
|
8
|
+
/** Matches "claude"/"Claude" and also the dotfile convention "`.claude`"/"`.Claude`" (Claude
|
|
9
|
+
* Code's own home directory) — a leading dot is stripped before comparison, everything else
|
|
10
|
+
* must match exactly (not a substring match, so "claude-code" or "my-claude-notes" don't count). */
|
|
11
|
+
function isClaudeDirName(name) {
|
|
12
|
+
return name.replace(/^\./, '').toLowerCase() === 'claude';
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Find every directory named "claude" (see `isClaudeDirName`), searching recursively from
|
|
16
|
+
* `root`. A match is not itself searched further — its full contents are captured by
|
|
17
|
+
* `appendTree` instead, so a nested "claude" folder inside a match isn't double-reported as its
|
|
18
|
+
* own match. A *symlinked* "claude"/".claude" directory still counts as a match (dotfile
|
|
19
|
+
* managers like chezmoi/Stow/yadm commonly manage `~/.claude` this way) — only non-matching
|
|
20
|
+
* symlinked directories are skipped during further recursion, to avoid link loops and escaping
|
|
21
|
+
* `root`. Unreadable directories (permissions, etc.) are skipped rather than aborting the whole
|
|
22
|
+
* scan.
|
|
23
|
+
*
|
|
24
|
+
* Being recorded as a match here does not by itself mean its contents get walked — a matched
|
|
25
|
+
* symlink whose target resolves outside `root` is caller-checked (see `resolvesWithinRoot`,
|
|
26
|
+
* used in `run()`) and its contents are never enumerated, since nothing here constrains where a
|
|
27
|
+
* "claude"-named symlink's target actually lives.
|
|
28
|
+
*/
|
|
29
|
+
export async function findClaudeDirs(root) {
|
|
30
|
+
if (isClaudeDirName(path.basename(root))) {
|
|
31
|
+
// Unlike every match found via walk() below, root is handed to us directly rather than
|
|
32
|
+
// discovered via fs.readdir — nothing has confirmed it actually exists or is a directory
|
|
33
|
+
// yet. Without this check, a nonexistent or wrong-type --root (e.g. `--root ~/.claude` on a
|
|
34
|
+
// machine where that path doesn't exist — exactly the usage docs/commands.md recommends)
|
|
35
|
+
// would be reported as a real match, and the empty/failing walk downstream would silently
|
|
36
|
+
// produce and upload a near-empty "successful" report instead of a clear "not found" result.
|
|
37
|
+
const rootStat = await fs.stat(root).catch(() => null);
|
|
38
|
+
return rootStat?.isDirectory() ? [root] : [];
|
|
39
|
+
}
|
|
40
|
+
const matches = [];
|
|
41
|
+
async function walk(dir) {
|
|
42
|
+
let entries;
|
|
43
|
+
try {
|
|
44
|
+
entries = await fs.readdir(dir, { withFileTypes: true });
|
|
45
|
+
}
|
|
46
|
+
catch {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
for (const entry of entries) {
|
|
50
|
+
const fullPath = path.join(dir, entry.name);
|
|
51
|
+
if (isClaudeDirName(entry.name)) {
|
|
52
|
+
if (entry.isDirectory()) {
|
|
53
|
+
matches.push(fullPath);
|
|
54
|
+
}
|
|
55
|
+
else if (entry.isSymbolicLink()) {
|
|
56
|
+
// Resolve the target to confirm it's actually a directory before recording it as a
|
|
57
|
+
// match (a symlink to a plain file literally named "claude" wouldn't be one). A
|
|
58
|
+
// broken/looping symlink fails fs.stat and is simply not reported as a match.
|
|
59
|
+
const targetStat = await fs.stat(fullPath).catch(() => null);
|
|
60
|
+
if (targetStat?.isDirectory()) {
|
|
61
|
+
matches.push(fullPath);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
continue; // matched (or matched-by-name-but-not-a-dir) — never searched further either way
|
|
65
|
+
}
|
|
66
|
+
if (entry.isSymbolicLink() || !entry.isDirectory()) {
|
|
67
|
+
continue; // non-matching symlink or non-directory — never followed
|
|
68
|
+
}
|
|
69
|
+
await walk(fullPath);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
await walk(root);
|
|
73
|
+
return matches;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Wrap `text` in a markdown inline-code span that's safe even if `text` itself contains
|
|
77
|
+
* backticks (a literal backtick in a filename would otherwise prematurely close the span and
|
|
78
|
+
* mangle the rest of the report) — CommonMark's own rule: a code span delimited by N backticks
|
|
79
|
+
* can safely contain any run of fewer than N backticks, as long as it's not at the very edge.
|
|
80
|
+
*
|
|
81
|
+
* A literal newline (legal in a POSIX filename) is replaced with a visible placeholder rather
|
|
82
|
+
* than left as-is: CommonMark only collapses line endings *inside* a code span when the span
|
|
83
|
+
* stays within one block, which doesn't hold across an ATX heading's own line boundary (this
|
|
84
|
+
* function is also used to build `## <match>` headings) — an embedded `\n` would otherwise split
|
|
85
|
+
* the heading into two lines, one with an unclosed code span.
|
|
86
|
+
*/
|
|
87
|
+
function mdInlineCode(text) {
|
|
88
|
+
const singleLine = text.replace(/\r\n|\r|\n/g, '');
|
|
89
|
+
const runs = singleLine.match(/`+/g);
|
|
90
|
+
const longestRun = runs ? Math.max(...runs.map((r) => r.length)) : 0;
|
|
91
|
+
if (longestRun === 0) {
|
|
92
|
+
return `\`${singleLine}\``;
|
|
93
|
+
}
|
|
94
|
+
const fence = '`'.repeat(longestRun + 1);
|
|
95
|
+
return `${fence} ${singleLine} ${fence}`;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Resolve both `root` and `target` to their canonical (symlink-free) paths and report whether
|
|
99
|
+
* `target` actually lives under `root` — used to decide whether a *matched* symlinked directory
|
|
100
|
+
* (see `findClaudeDirs`) is safe to walk. A `claude`/`.claude` symlink is recorded as a match
|
|
101
|
+
* without regard for where it points, so without this check a planted symlink anywhere under the
|
|
102
|
+
* search root (a malicious repo clone, an extracted archive) could point at an arbitrary
|
|
103
|
+
* unrelated directory — `/`, `~/.ssh`, a mounted volume — and have its entire contents (every
|
|
104
|
+
* filename, size, and timestamp) enumerated into the uploaded report. If either path fails to
|
|
105
|
+
* resolve (e.g. a dangling symlink), this conservatively reports "does not resolve within root".
|
|
106
|
+
*/
|
|
107
|
+
async function resolvesWithinRoot(root, target) {
|
|
108
|
+
const [realRoot, realTarget] = await Promise.all([
|
|
109
|
+
fs.realpath(root).catch(() => null),
|
|
110
|
+
fs.realpath(target).catch(() => null),
|
|
111
|
+
]);
|
|
112
|
+
if (realRoot === null || realTarget === null) {
|
|
113
|
+
return { within: false, realTarget };
|
|
114
|
+
}
|
|
115
|
+
const relative = path.relative(realRoot, realTarget);
|
|
116
|
+
const within = relative === '' || (!relative.startsWith('..') && !path.isAbsolute(relative));
|
|
117
|
+
return { within, realTarget };
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Depth-first append of `dir`'s full contents (recursive, no exclusions) to `lines` as an
|
|
121
|
+
* indented markdown list, one entry per file/directory, each annotated with basic metadata
|
|
122
|
+
* (size, extension, created/modified times for files). Never reads file *contents* — only
|
|
123
|
+
* filesystem metadata — so nothing from inside these folders leaves the machine except names
|
|
124
|
+
* and stats.
|
|
125
|
+
*/
|
|
126
|
+
async function appendTree(lines, dir, depth) {
|
|
127
|
+
const indent = ' '.repeat(depth);
|
|
128
|
+
let entries;
|
|
129
|
+
try {
|
|
130
|
+
entries = await fs.readdir(dir, { withFileTypes: true });
|
|
131
|
+
}
|
|
132
|
+
catch (err) {
|
|
133
|
+
lines.push(`${indent}- ⚠️ (unreadable: ${err.message})`);
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
entries.sort((a, b) => a.name.localeCompare(b.name));
|
|
137
|
+
for (const entry of entries) {
|
|
138
|
+
const fullPath = path.join(dir, entry.name);
|
|
139
|
+
if (entry.isSymbolicLink()) {
|
|
140
|
+
// Resolve the target only to tell a file from a directory — a symlinked directory is
|
|
141
|
+
// never followed (avoids link loops and escaping dir), but a symlinked file is safe to
|
|
142
|
+
// list (using the target's metadata) since nothing recurses into it.
|
|
143
|
+
let targetStat;
|
|
144
|
+
try {
|
|
145
|
+
targetStat = await fs.stat(fullPath);
|
|
146
|
+
}
|
|
147
|
+
catch (err) {
|
|
148
|
+
lines.push(`${indent}- ${mdInlineCode(entry.name)} (broken symlink: ${err.message})`);
|
|
149
|
+
continue;
|
|
150
|
+
}
|
|
151
|
+
if (targetStat.isDirectory()) {
|
|
152
|
+
lines.push(`${indent}- 📁 ${mdInlineCode(`${entry.name}/`)} (symlink to a directory, not followed)`);
|
|
153
|
+
continue;
|
|
154
|
+
}
|
|
155
|
+
const ext = path.extname(entry.name) || '(none)';
|
|
156
|
+
const kb = (targetStat.size / 1024).toFixed(1);
|
|
157
|
+
lines.push(`${indent}- 📄 ${mdInlineCode(entry.name)} (symlink) — ${kb} KB, ${ext}, ` +
|
|
158
|
+
`created ${targetStat.birthtime.toISOString()}, modified ${targetStat.mtime.toISOString()}`);
|
|
159
|
+
continue;
|
|
160
|
+
}
|
|
161
|
+
let stat;
|
|
162
|
+
try {
|
|
163
|
+
stat = await fs.stat(fullPath);
|
|
164
|
+
}
|
|
165
|
+
catch (err) {
|
|
166
|
+
lines.push(`${indent}- ${mdInlineCode(entry.name)} (unreadable: ${err.message})`);
|
|
167
|
+
continue;
|
|
168
|
+
}
|
|
169
|
+
if (entry.isDirectory()) {
|
|
170
|
+
lines.push(`${indent}- 📁 ${mdInlineCode(`${entry.name}/`)} — modified ${stat.mtime.toISOString()}`);
|
|
171
|
+
await appendTree(lines, fullPath, depth + 1);
|
|
172
|
+
continue;
|
|
173
|
+
}
|
|
174
|
+
if (!entry.isFile()) {
|
|
175
|
+
// A special file — socket, FIFO, block/char device. Rare under a Claude config directory,
|
|
176
|
+
// but "no exclusions" means it still gets a line rather than vanishing without a trace.
|
|
177
|
+
lines.push(`${indent}- ${mdInlineCode(entry.name)} (special file, not a regular file or directory)`);
|
|
178
|
+
continue;
|
|
179
|
+
}
|
|
180
|
+
const ext = path.extname(entry.name) || '(none)';
|
|
181
|
+
const kb = (stat.size / 1024).toFixed(1);
|
|
182
|
+
lines.push(`${indent}- 📄 ${mdInlineCode(entry.name)} — ${kb} KB, ${ext}, ` +
|
|
183
|
+
`created ${stat.birthtime.toISOString()}, modified ${stat.mtime.toISOString()}`);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
export async function run(opts, deps = {}) {
|
|
187
|
+
try {
|
|
188
|
+
const root = opts.root ?? (deps.homedir ?? os.homedir)();
|
|
189
|
+
const matches = await findClaudeDirs(root);
|
|
190
|
+
if (matches.length === 0) {
|
|
191
|
+
if (opts.json) {
|
|
192
|
+
logger.json({ ok: true, matches: 0, matchedPaths: [] });
|
|
193
|
+
}
|
|
194
|
+
else {
|
|
195
|
+
logger.info(`No folders named "claude" found under ${root}.`);
|
|
196
|
+
}
|
|
197
|
+
return ExitCode.OK;
|
|
198
|
+
}
|
|
199
|
+
const lines = [
|
|
200
|
+
'# Claude Folders Map',
|
|
201
|
+
'',
|
|
202
|
+
`Generated ${new Date().toISOString()} — ${matches.length} folder(s) matching "claude" found under ${mdInlineCode(root)}.`,
|
|
203
|
+
'',
|
|
204
|
+
];
|
|
205
|
+
for (const match of matches) {
|
|
206
|
+
// mdInlineCode also replaces any stray newline byte in a directory name, not just
|
|
207
|
+
// backticks — a heading built from a raw, unescaped path could otherwise be split across
|
|
208
|
+
// lines (see mdInlineCode's own doc comment for why the newline handling lives there).
|
|
209
|
+
lines.push(`## ${mdInlineCode(match)}`, '');
|
|
210
|
+
const matchLstat = await fs.lstat(match).catch(() => null);
|
|
211
|
+
const escape = matchLstat?.isSymbolicLink() ? await resolvesWithinRoot(root, match) : null;
|
|
212
|
+
if (escape && !escape.within) {
|
|
213
|
+
lines.push(`- ⚠️ This is a symlink that resolves outside the search root` +
|
|
214
|
+
(escape.realTarget ? ` (to ${mdInlineCode(escape.realTarget)})` : ' (target could not be resolved)') +
|
|
215
|
+
` — not followed, to avoid leaking an unrelated location's contents via a planted symlink.`);
|
|
216
|
+
}
|
|
217
|
+
else {
|
|
218
|
+
await appendTree(lines, match, 0);
|
|
219
|
+
}
|
|
220
|
+
lines.push('');
|
|
221
|
+
}
|
|
222
|
+
const markdown = `${lines.join('\n')}\n`;
|
|
223
|
+
if (opts.output) {
|
|
224
|
+
// Same sensitivity as the upload temp file below (real filenames from every matched
|
|
225
|
+
// folder) — 0o600, and written before the upload attempt so it's available for inspection
|
|
226
|
+
// even if the upload itself fails.
|
|
227
|
+
await fs.writeFile(opts.output, markdown, { encoding: 'utf8', mode: 0o600 });
|
|
228
|
+
}
|
|
229
|
+
const tmpPath = path.join(os.tmpdir(), `coolhand-claude-map-${randomBytes(6).toString('hex')}.md`);
|
|
230
|
+
// The report lists real filenames (and thus can be sensitive) from every matched folder —
|
|
231
|
+
// 0o600 keeps it unreadable by other local users for as long as it exists on disk, matching
|
|
232
|
+
// the mode used for other sensitive files elsewhere (src/config.ts, capture-state.ts).
|
|
233
|
+
await fs.writeFile(tmpPath, markdown, { encoding: 'utf8', mode: 0o600 });
|
|
234
|
+
try {
|
|
235
|
+
const result = await uploadClientFile({
|
|
236
|
+
filePath: tmpPath,
|
|
237
|
+
name: 'Claude Folders Map',
|
|
238
|
+
fileType: 'report',
|
|
239
|
+
description: `File tree map of ${matches.length} folder(s) named "claude" under ${root} (names and metadata only — no file contents).`,
|
|
240
|
+
metadata: { source: 'map-claude-projects', matchCount: matches.length, root },
|
|
241
|
+
}, { clientId: opts.clientId, dryRun: opts.dryRun });
|
|
242
|
+
const mb = (result.sizeBytes / (1024 * 1024)).toFixed(2);
|
|
243
|
+
if (opts.json) {
|
|
244
|
+
logger.json({
|
|
245
|
+
ok: true,
|
|
246
|
+
dryRun: result.status === 'dry-run',
|
|
247
|
+
matches: matches.length,
|
|
248
|
+
matchedPaths: matches,
|
|
249
|
+
sizeBytes: result.sizeBytes,
|
|
250
|
+
...(opts.output && { outputPath: opts.output }),
|
|
251
|
+
result: result.response,
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
else if (result.status === 'dry-run') {
|
|
255
|
+
logger.info(`Dry run: found ${matches.length} folder(s), map is ${mb}MB. Nothing sent.` +
|
|
256
|
+
(opts.output ? ` Report written to ${opts.output}.` : ''));
|
|
257
|
+
}
|
|
258
|
+
else {
|
|
259
|
+
logger.info(`Uploaded a map of ${matches.length} folder(s) (${mb}MB) as client file ` +
|
|
260
|
+
`"${result.response?.name}" (id: ${result.response?.id}).` +
|
|
261
|
+
(opts.output ? ` Report also written to ${opts.output}.` : ''));
|
|
262
|
+
}
|
|
263
|
+
return ExitCode.OK;
|
|
264
|
+
}
|
|
265
|
+
finally {
|
|
266
|
+
await fs.rm(tmpPath, { force: true }).catch(() => undefined);
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
catch (err) {
|
|
270
|
+
if (err instanceof CliError) {
|
|
271
|
+
if (opts.json) {
|
|
272
|
+
logger.json({ ok: false, error: err.code, message: redact(err.message) });
|
|
273
|
+
}
|
|
274
|
+
else {
|
|
275
|
+
logger.info(`Error: ${redact(err.message)} [${err.code}]`);
|
|
276
|
+
}
|
|
277
|
+
return err.exitCode;
|
|
278
|
+
}
|
|
279
|
+
throw err;
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
//# sourceMappingURL=map-claude-projects.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"map-claude-projects.js","sourceRoot":"","sources":["../../src/commands/map-claude-projects.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,IAAI,EAAE,EAAE,MAAM,IAAI,CAAC;AACpC,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AACrC,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAO5D;;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AAC;AAE3D,wBAAsB,GAAG,CAAC,IAAI,EAAE,uBAAuB,GAAG,OAAO,CAAC,MAAM,CAAC,CAyCxE"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { CliError, ExitCode } from '../errors.js';
|
|
2
|
+
import { logger, redact } from '../logger.js';
|
|
3
|
+
import { uploadClientFile } from '../upload-client-file.js';
|
|
4
|
+
export async function run(opts) {
|
|
5
|
+
try {
|
|
6
|
+
const result = await uploadClientFile({
|
|
7
|
+
filePath: opts.filePath,
|
|
8
|
+
name: opts.name,
|
|
9
|
+
fileType: opts.fileType,
|
|
10
|
+
description: opts.description,
|
|
11
|
+
}, { clientId: opts.clientId, dryRun: opts.dryRun });
|
|
12
|
+
const mb = (result.sizeBytes / (1024 * 1024)).toFixed(2);
|
|
13
|
+
if (opts.json) {
|
|
14
|
+
logger.json({
|
|
15
|
+
ok: true,
|
|
16
|
+
dryRun: result.status === 'dry-run',
|
|
17
|
+
sizeBytes: result.sizeBytes,
|
|
18
|
+
result: result.response,
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
else if (result.status === 'dry-run') {
|
|
22
|
+
logger.info(`Dry run: would upload "${opts.filePath}" (${mb}MB). Nothing sent.`);
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
logger.info(`Uploaded "${opts.filePath}" (${mb}MB) as client file "${result.response?.name}" ` +
|
|
26
|
+
`(id: ${result.response?.id}, status: ${result.response?.status}).`);
|
|
27
|
+
}
|
|
28
|
+
return ExitCode.OK;
|
|
29
|
+
}
|
|
30
|
+
catch (err) {
|
|
31
|
+
if (err instanceof CliError) {
|
|
32
|
+
if (opts.json) {
|
|
33
|
+
logger.json({ ok: false, error: err.code, message: redact(err.message) });
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
logger.info(`Error: ${redact(err.message)} [${err.code}]`);
|
|
37
|
+
}
|
|
38
|
+
return err.exitCode;
|
|
39
|
+
}
|
|
40
|
+
throw err;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=upload-client-file.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"upload-client-file.js","sourceRoot":"","sources":["../../src/commands/upload-client-file.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAG5D,MAAM,CAAC,KAAK,UAAU,GAAG,CAAC,IAA6B;IACrD,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,MAAM,gBAAgB,CACnC;YACE,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,WAAW,EAAE,IAAI,CAAC,WAAW;SAC9B,EACD,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,CACjD,CAAC;QAEF,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,SAAS,GAAG,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;QAEzD,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;YACd,MAAM,CAAC,IAAI,CAAC;gBACV,EAAE,EAAE,IAAI;gBACR,MAAM,EAAE,MAAM,CAAC,MAAM,KAAK,SAAS;gBACnC,SAAS,EAAE,MAAM,CAAC,SAAS;gBAC3B,MAAM,EAAE,MAAM,CAAC,QAAQ;aACxB,CAAC,CAAC;QACL,CAAC;aAAM,IAAI,MAAM,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;YACvC,MAAM,CAAC,IAAI,CAAC,0BAA0B,IAAI,CAAC,QAAQ,MAAM,EAAE,oBAAoB,CAAC,CAAC;QACnF,CAAC;aAAM,CAAC;YACN,MAAM,CAAC,IAAI,CACT,aAAa,IAAI,CAAC,QAAQ,MAAM,EAAE,uBAAuB,MAAM,CAAC,QAAQ,EAAE,IAAI,IAAI;gBAChF,QAAQ,MAAM,CAAC,QAAQ,EAAE,EAAE,aAAa,MAAM,CAAC,QAAQ,EAAE,MAAM,IAAI,CACtE,CAAC;QACJ,CAAC;QACD,OAAO,QAAQ,CAAC,EAAE,CAAC;IACrB,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,IAAI,GAAG,YAAY,QAAQ,EAAE,CAAC;YAC5B,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;gBACd,MAAM,CAAC,IAAI,CAAC,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,CAAC,IAAI,EAAE,OAAO,EAAE,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;YAC5E,CAAC;iBAAM,CAAC;gBACN,MAAM,CAAC,IAAI,CAAC,UAAU,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,KAAK,GAAG,CAAC,IAAI,GAAG,CAAC,CAAC;YAC7D,CAAC;YACD,OAAO,GAAG,CAAC,QAAQ,CAAC;QACtB,CAAC;QACD,MAAM,GAAG,CAAC;IACZ,CAAC;AACH,CAAC"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { type ComplaintBoxOptions } from '../types.js';
|
|
2
2
|
/**
|
|
3
|
-
* Records an agent's free-form "I am blocked
|
|
4
|
-
* complaint as feedback (tagged creator_type: "agent"),
|
|
5
|
-
* de-loop message and exits 0 so the agent stops and moves
|
|
6
|
-
* fires — even when the feedback could not be recorded —
|
|
7
|
-
*
|
|
8
|
-
* sandbox is exactly who this command is for). When recording fails it says so
|
|
3
|
+
* Records an agent's free-form "I am blocked — a capability doesn't exist, or this
|
|
4
|
+
* task would take too long" complaint as feedback (tagged creator_type: "agent"),
|
|
5
|
+
* then prints a terminal de-loop message and exits 0 so the agent stops and moves
|
|
6
|
+
* on. The de-loop ALWAYS fires — even when the feedback could not be recorded —
|
|
7
|
+
* because the blocker is real regardless of server state (and a logged-out agent in
|
|
8
|
+
* a sandbox is exactly who this command is for). When recording fails it says so
|
|
9
9
|
* plainly and logs a warning, so the failure still surfaces without trapping the
|
|
10
10
|
* agent in the retry loop the command exists to break.
|
|
11
11
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wildcard.d.ts","sourceRoot":"","sources":["../../src/commands/wildcard.ts"],"names":[],"mappings":"AAMA,OAAO,EAAoB,KAAK,mBAAmB,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"wildcard.d.ts","sourceRoot":"","sources":["../../src/commands/wildcard.ts"],"names":[],"mappings":"AAMA,OAAO,EAAoB,KAAK,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAgCzE;;;;;;;;;GASG;AACH,wBAAsB,GAAG,CAAC,IAAI,EAAE,mBAAmB,GAAG,OAAO,CAAC,MAAM,CAAC,CAsIpE"}
|
|
@@ -9,28 +9,31 @@ import { DEFAULT_BASE_URL } from '../types.js';
|
|
|
9
9
|
// capability is real regardless of whether we could reach the Coolhand server, so
|
|
10
10
|
// the de-loop is the agent's decision to make, not the server's.
|
|
11
11
|
const STOP_GUIDANCE = 'Do not retry this action or attempt alternative ways to perform it; continue with the rest of your task.';
|
|
12
|
+
// Shared opening clause: the blocker is either a capability that genuinely doesn't
|
|
13
|
+
// exist, or a task that would take too long to complete in this environment.
|
|
14
|
+
const BLOCKER_CLAUSE = 'This capability is not available, or the task would take too long to complete, in this environment.';
|
|
12
15
|
// Printed when the blocker was successfully recorded server-side.
|
|
13
|
-
const DELOOP_RECORDED =
|
|
16
|
+
const DELOOP_RECORDED = `${BLOCKER_CLAUSE} Your feedback has been recorded. ` + STOP_GUIDANCE;
|
|
14
17
|
// Printed when the blocker could NOT be recorded (e.g. the server did not confirm).
|
|
15
18
|
// We still de-loop the agent, but stay honest: we never claim a recording happened,
|
|
16
19
|
// and a warning is logged separately so the failure surfaces.
|
|
17
|
-
const DELOOP_UNRECORDED =
|
|
20
|
+
const DELOOP_UNRECORDED = `${BLOCKER_CLAUSE} Your feedback could not be recorded ` +
|
|
18
21
|
'(the server did not confirm — run `coolhand login` to enable reporting). ' +
|
|
19
22
|
STOP_GUIDANCE;
|
|
20
23
|
// Printed when the blocker was saved locally because the API key is unavailable
|
|
21
24
|
// (not logged in, no default client set, or private-only login). The data is not
|
|
22
25
|
// lost: it uploads when credentials are available. The specific reason is already
|
|
23
26
|
// in the logger.warn() call above, so this message stays generic.
|
|
24
|
-
const DELOOP_SAVED =
|
|
27
|
+
const DELOOP_SAVED = `${BLOCKER_CLAUSE} Your feedback was saved locally ` +
|
|
25
28
|
'and will be uploaded once a Coolhand account with a public API key is configured. ' +
|
|
26
29
|
STOP_GUIDANCE;
|
|
27
30
|
/**
|
|
28
|
-
* Records an agent's free-form "I am blocked
|
|
29
|
-
* complaint as feedback (tagged creator_type: "agent"),
|
|
30
|
-
* de-loop message and exits 0 so the agent stops and moves
|
|
31
|
-
* fires — even when the feedback could not be recorded —
|
|
32
|
-
*
|
|
33
|
-
* sandbox is exactly who this command is for). When recording fails it says so
|
|
31
|
+
* Records an agent's free-form "I am blocked — a capability doesn't exist, or this
|
|
32
|
+
* task would take too long" complaint as feedback (tagged creator_type: "agent"),
|
|
33
|
+
* then prints a terminal de-loop message and exits 0 so the agent stops and moves
|
|
34
|
+
* on. The de-loop ALWAYS fires — even when the feedback could not be recorded —
|
|
35
|
+
* because the blocker is real regardless of server state (and a logged-out agent in
|
|
36
|
+
* a sandbox is exactly who this command is for). When recording fails it says so
|
|
34
37
|
* plainly and logs a warning, so the failure still surfaces without trapping the
|
|
35
38
|
* agent in the retry loop the command exists to break.
|
|
36
39
|
*/
|
|
@@ -131,14 +134,14 @@ export async function run(opts) {
|
|
|
131
134
|
if (err instanceof CliError && err.code === 'CLIENT_NOT_FOUND') {
|
|
132
135
|
// Bad --client-id value — not a server or auth failure; give actionable guidance.
|
|
133
136
|
deloopFallback =
|
|
134
|
-
|
|
137
|
+
`${BLOCKER_CLAUSE} The specified client was not found ` +
|
|
135
138
|
'(pass --client-id with a valid client ID, or run `coolhand clients` to list configured clients). ' +
|
|
136
139
|
STOP_GUIDANCE;
|
|
137
140
|
}
|
|
138
141
|
else if (err instanceof CliError && err.code === 'INVALID_ARGS') {
|
|
139
142
|
// Client selection prompt timed out or received invalid input — not a server failure.
|
|
140
143
|
deloopFallback =
|
|
141
|
-
|
|
144
|
+
`${BLOCKER_CLAUSE} Client selection was not completed ` +
|
|
142
145
|
'(prompt timed out or received invalid input — pass --client-id to select a client directly). ' +
|
|
143
146
|
STOP_GUIDANCE;
|
|
144
147
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wildcard.js","sourceRoot":"","sources":["../../src/commands/wildcard.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAA8B,MAAM,eAAe,CAAC;AACrE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AACzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAA4B,MAAM,aAAa,CAAC;AAEzE,6EAA6E;AAC7E,kFAAkF;AAClF,iEAAiE;AACjE,MAAM,aAAa,GACjB,0GAA0G,CAAC;AAE7G,kEAAkE;AAClE,MAAM,eAAe,
|
|
1
|
+
{"version":3,"file":"wildcard.js","sourceRoot":"","sources":["../../src/commands/wildcard.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAA8B,MAAM,eAAe,CAAC;AACrE,OAAO,EAAE,Q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AE,CAAC;AACrB,CAAC"}
|
package/dist/config.d.ts
CHANGED
|
@@ -24,4 +24,15 @@ export declare function setDefault(clientId: string): Promise<ConfigFile>;
|
|
|
24
24
|
* knows which account's data they are looking at.
|
|
25
25
|
*/
|
|
26
26
|
export declare function resolveClient(cfg: ConfigFile, clientId?: string): Promise<ClientEntry>;
|
|
27
|
+
/**
|
|
28
|
+
* `resolveClient`, but tolerant of "no clients configured at all" — returns `undefined` in that
|
|
29
|
+
* one case instead of throwing, so a `--dry-run` caller can still run fully unauthenticated. Any
|
|
30
|
+
* other resolution error (a bad --client-id, multiple clients with no default set, etc.)
|
|
31
|
+
* propagates exactly as `resolveClient` would throw it.
|
|
32
|
+
*
|
|
33
|
+
* Shared by every command whose `--dry-run` mode should work without any stored credentials
|
|
34
|
+
* (`analyze-claude-sessions`, `map-claude-projects`, `upload-client-file`, and anything built on
|
|
35
|
+
* `uploadClientFile`'s shared core).
|
|
36
|
+
*/
|
|
37
|
+
export declare function resolveClientForDryRun(cfg: ConfigFile, clientId?: string): Promise<ClientEntry | undefined>;
|
|
27
38
|
//# sourceMappingURL=config.d.ts.map
|
package/dist/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAM1D,wBAAgB,SAAS,IAAI,MAAM,CAMlC;AAED,wBAAgB,UAAU,IAAI,MAAM,CAEnC;AAMD,wBAAsB,UAAU,IAAI,OAAO,CAAC,UAAU,CAAC,CAyBtD;AAWD;;;;;GAKG;AACH,wBAAsB,eAAe,CACnC,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,MAAM,EACZ,IAAI,GAAE,MAAkB,GACvB,OAAO,CAAC,IAAI,CAAC,CAef;AAED,wBAAsB,UAAU,CAAC,GAAG,EAAE,UAAU,GAAG,OAAO,CAAC,IAA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AW,GAAG,SAAS,CAMrF;AAED,wBAAsB,YAAY,CAAC,KAAK,EAAE,WAAW,EAAE,WAAW,UAAO,GAAG,OAAO,CAAC,UAAU,CAAC,CAY9F;AAED,wBAAsB,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC,CAgB/E;AAED,wBAAsB,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAQtE;AA2CD;;;;;;;GAOG;AACH,wBAAsB,aAAa,CAAC,GAAG,EAAE,UAAU,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,CAyE5F;AAED;;;;;;;;;GASG;AACH,wBAAsB,sBAAsB,CAAC,GAAG,EAAE,UAAU,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,GAAG,SAAS,CAAC,CAajH"}
|
package/dist/config.js
CHANGED
|
@@ -4,7 +4,7 @@ import * as os from 'os';
|
|
|
4
4
|
import * as path from 'path';
|
|
5
5
|
import { randomBytes } from 'crypto';
|
|
6
6
|
import { CliError } from './errors.js';
|
|
7
|
-
import { logger } from './logger.js';
|
|
7
|
+
import { logger, stripAnsiEscapes } from './logger.js';
|
|
8
8
|
const CONFIG_FILENAME = 'config.json';
|
|
9
9
|
const DIR_MODE = 0o700;
|
|
10
10
|
const FILE_MODE = 0o600;
|
|
@@ -141,7 +141,7 @@ export async function setDefault(clientId) {
|
|
|
141
141
|
const PROMPT_TIMEOUT_MS = 30000;
|
|
142
142
|
async function promptClientSelection(clients) {
|
|
143
143
|
return new Promise((resolve, reject) => {
|
|
144
|
-
const lines = clients.map((c, i) => ` ${i + 1}. ${c.client_name} (${c.client_id})`).join('\n');
|
|
144
|
+
const lines = clients.map((c, i) => ` ${i + 1}. ${stripAnsiEscapes(c.client_name)} (${c.client_id})`).join('\n');
|
|
145
145
|
process.stderr.write(`Multiple clients configured — which one?\n${lines}\nEnter number: `);
|
|
146
146
|
const rl = createInterface({ input: process.stdin, output: process.stderr });
|
|
147
147
|
let settled = false;
|
|
@@ -200,7 +200,7 @@ export async function resolveClient(cfg, clientId) {
|
|
|
200
200
|
if (!entry) {
|
|
201
201
|
throw new CliError('CLIENT_NOT_FOUND', `No client "${clientId}" is configured.`);
|
|
202
202
|
}
|
|
203
|
-
process.stderr.write(`Client: ${entry.client_name} (${entry.client_id})\n`);
|
|
203
|
+
process.stderr.write(`Client: ${stripAnsiEscapes(entry.client_name)} (${entry.client_id})\n`);
|
|
204
204
|
return entry;
|
|
205
205
|
}
|
|
206
206
|
// 2. COOLHAND_CLIENT_ID env var
|
|
@@ -214,14 +214,14 @@ export async function resolveClient(cfg, clientId) {
|
|
|
214
214
|
if (!entry) {
|
|
215
215
|
throw new CliError('CLIENT_NOT_FOUND', `COOLHAND_CLIENT_ID="${envClientId}" does not match any configured client.`);
|
|
216
216
|
}
|
|
217
|
-
process.stderr.write(`Client: ${entry.client_name} (${entry.client_id})\n`);
|
|
217
|
+
process.stderr.write(`Client: ${stripAnsiEscapes(entry.client_name)} (${entry.client_id})\n`);
|
|
218
218
|
return entry;
|
|
219
219
|
}
|
|
220
220
|
// 3. Configured default
|
|
221
221
|
if (cfg.default_client_id) {
|
|
222
222
|
const entry = cfg.clients[cfg.default_client_id];
|
|
223
223
|
if (entry) {
|
|
224
|
-
process.stderr.write(`Client: ${entry.client_name} (${entry.client_id})\n`);
|
|
224
|
+
process.stderr.write(`Client: ${stripAnsiEscapes(entry.client_name)} (${entry.client_id})\n`);
|
|
225
225
|
return entry;
|
|
226
226
|
}
|
|
227
227
|
logger.warn(`Configured default client "${cfg.default_client_id}" no longer exists. Run \`coolhand clients use <id>\` to reset it.`);
|
|
@@ -234,7 +234,7 @@ export async function resolveClient(cfg, clientId) {
|
|
|
234
234
|
// 5. Exactly one client — auto-pick without prompting
|
|
235
235
|
if (clients.length === 1) {
|
|
236
236
|
const entry = clients[0];
|
|
237
|
-
process.stderr.write(`Client: ${entry.client_name} (${entry.client_id})\n`);
|
|
237
|
+
process.stderr.write(`Client: ${stripAnsiEscapes(entry.client_name)} (${entry.client_id})\n`);
|
|
238
238
|
return entry;
|
|
239
239
|
}
|
|
240
240
|
// 6. Multiple clients, no default — prompt interactively when both stdin and stderr are a
|
|
@@ -243,10 +243,33 @@ export async function resolveClient(cfg, clientId) {
|
|
|
243
243
|
// cannot type a selection, so the descriptive error path is cleaner.
|
|
244
244
|
if (process.stdin.isTTY && process.stderr.isTTY) {
|
|
245
245
|
const entry = await promptClientSelection(clients);
|
|
246
|
-
process.stderr.write(`Client: ${entry.client_name} (${entry.client_id})\n`);
|
|
246
|
+
process.stderr.write(`Client: ${stripAnsiEscapes(entry.client_name)} (${entry.client_id})\n`);
|
|
247
247
|
return entry;
|
|
248
248
|
}
|
|
249
|
-
const list = clients.map((c) => ` ${c.client_id} ${c.client_name}`).join('\n');
|
|
249
|
+
const list = clients.map((c) => ` ${c.client_id} ${stripAnsiEscapes(c.client_name)}`).join('\n');
|
|
250
250
|
throw new CliError('NOT_CONFIGURED', `Multiple clients configured but no default is set.\n\nConfigured clients:\n${list}\n\nRun \`coolhand clients use <id>\` to set a default, or pass --client-id.`);
|
|
251
251
|
}
|
|
252
|
+
/**
|
|
253
|
+
* `resolveClient`, but tolerant of "no clients configured at all" — returns `undefined` in that
|
|
254
|
+
* one case instead of throwing, so a `--dry-run` caller can still run fully unauthenticated. Any
|
|
255
|
+
* other resolution error (a bad --client-id, multiple clients with no default set, etc.)
|
|
256
|
+
* propagates exactly as `resolveClient` would throw it.
|
|
257
|
+
*
|
|
258
|
+
* Shared by every command whose `--dry-run` mode should work without any stored credentials
|
|
259
|
+
* (`analyze-claude-sessions`, `map-claude-projects`, `upload-client-file`, and anything built on
|
|
260
|
+
* `uploadClientFile`'s shared core).
|
|
261
|
+
*/
|
|
262
|
+
export async function resolveClientForDryRun(cfg, clientId) {
|
|
263
|
+
try {
|
|
264
|
+
return await resolveClient(cfg, clientId);
|
|
265
|
+
}
|
|
266
|
+
catch (err) {
|
|
267
|
+
if (!(err instanceof CliError) ||
|
|
268
|
+
err.code !== 'NOT_CONFIGURED' ||
|
|
269
|
+
Object.keys(cfg.clients).length > 0) {
|
|
270
|
+
throw err;
|
|
271
|
+
}
|
|
272
|
+
return undefined;
|
|
273
|
+
}
|
|
274
|
+
}
|
|
252
275
|
//# sourceMappingURL=config.js.map
|