cc-viewer 1.0.0 → 1.0.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/cli.js CHANGED
@@ -137,23 +137,25 @@ if (showAll) {
137
137
 
138
138
  try {
139
139
  const cliResult = injectCliJs();
140
- if (cliResult === 'exists') {
141
- console.log(t('cli.inject.exists'));
142
- } else {
143
- console.log(t('cli.inject.success'));
144
- }
145
-
146
140
  const shellResult = installShellHook();
147
- if (shellResult.status === 'installed') {
148
- console.log(t('cli.hook.installed', { path: shellResult.path }));
149
- } else if (shellResult.status === 'exists') {
150
- console.log(t('cli.hook.exists', { path: shellResult.path }));
141
+
142
+ if (cliResult === 'exists' && shellResult.status === 'exists') {
143
+ console.log(t('cli.alreadyWorking'));
151
144
  } else {
152
- console.log(t('cli.hook.fail', { error: shellResult.error }));
145
+ if (cliResult === 'exists') {
146
+ console.log(t('cli.inject.exists'));
147
+ } else {
148
+ console.log(t('cli.inject.success'));
149
+ }
150
+
151
+ if (shellResult.status === 'installed') {
152
+ console.log(t('cli.hook.installed', { path: shellResult.path }));
153
+ } else if (shellResult.status !== 'exists') {
154
+ console.log(t('cli.hook.fail', { error: shellResult.error }));
155
+ }
153
156
  }
154
157
 
155
158
  console.log(t('cli.usage.hint'));
156
- console.log(t('cli.usage.uninstallHint'));
157
159
  } catch (err) {
158
160
  if (err.code === 'ENOENT') {
159
161
  console.error(t('cli.inject.notFound', { path: cliPath }));
package/interceptor.js CHANGED
@@ -18,7 +18,9 @@ function generateLogFilePath() {
18
18
  + String(now.getHours()).padStart(2, '0')
19
19
  + String(now.getMinutes()).padStart(2, '0')
20
20
  + String(now.getSeconds()).padStart(2, '0');
21
- const projectName = basename(process.cwd()).replace(/[^a-zA-Z0-9_\-\.]/g, '_');
21
+ let cwd;
22
+ try { cwd = process.cwd(); } catch { cwd = homedir(); }
23
+ const projectName = basename(cwd).replace(/[^a-zA-Z0-9_\-\.]/g, '_');
22
24
  const dir = join(homedir(), '.claude', 'cc-viewer');
23
25
  try { mkdirSync(dir, { recursive: true }); } catch {}
24
26
  return join(dir, `${projectName}_${ts}.jsonl`);
@@ -208,7 +210,7 @@ export function setupInterceptor() {
208
210
 
209
211
  requestEntry = {
210
212
  timestamp,
211
- project: basename(process.cwd()),
213
+ project: (() => { try { return basename(process.cwd()); } catch { return 'unknown'; } })(),
212
214
  url: urlStr,
213
215
  method: options?.method || 'GET',
214
216
  headers,