client-handover 1.0.3 → 1.0.4

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
@@ -14,7 +14,11 @@ Uses the [Claude API](https://console.anthropic.com) (Anthropic) under the hood.
14
14
  npm install -g client-handover
15
15
  ```
16
16
 
17
- Then set your Anthropic API key as an environment variable:
17
+ ### API key setup
18
+
19
+ **If you have Claude Code installed**, no setup needed — `client-handover` will automatically use your existing Claude credentials.
20
+
21
+ **Otherwise**, set your Anthropic API key as an environment variable:
18
22
 
19
23
  ```bash
20
24
  # macOS / Linux
package/cli.js CHANGED
@@ -91,7 +91,7 @@ async function main() {
91
91
  await runAll(projectInfo, folderName)
92
92
  } catch (err) {
93
93
  if (err.status === 401) {
94
- console.error(chalk.red('\n❌ Invalid API key. Set your ANTHROPIC_API_KEY environment variable.\n'))
94
+ console.error(chalk.red('\n❌ Authentication failed. Set ANTHROPIC_API_KEY or install Claude Code.\n'))
95
95
  } else {
96
96
  console.error(chalk.red(`\n❌ Error: ${err.message}\n`))
97
97
  }
@@ -117,7 +117,7 @@ async function main() {
117
117
  await generateDoc(prompt, docName, './output')
118
118
  } catch (err) {
119
119
  if (err.status === 401) {
120
- console.error(chalk.red('\n❌ Invalid API key. Set your ANTHROPIC_API_KEY environment variable.\n'))
120
+ console.error(chalk.red('\n❌ Authentication failed. Set ANTHROPIC_API_KEY or install Claude Code.\n'))
121
121
  } else {
122
122
  console.error(chalk.red(`\n❌ Error: ${err.message}\n`))
123
123
  }
package/generator.js CHANGED
@@ -2,8 +2,35 @@ import Anthropic from '@anthropic-ai/sdk'
2
2
  import { marked } from 'marked'
3
3
  import fs from 'fs'
4
4
  import path from 'path'
5
+ import os from 'os'
5
6
 
6
- const client = new Anthropic()
7
+ function resolveApiKey() {
8
+ if (process.env.ANTHROPIC_API_KEY) return process.env.ANTHROPIC_API_KEY
9
+
10
+ const credentialsPath = path.join(os.homedir(), '.claude', '.credentials.json')
11
+ if (fs.existsSync(credentialsPath)) {
12
+ try {
13
+ const creds = JSON.parse(fs.readFileSync(credentialsPath, 'utf-8'))
14
+ const token = creds?.claudeAiOauth?.accessToken
15
+ const expiresAt = creds?.claudeAiOauth?.expiresAt
16
+ if (token && (!expiresAt || expiresAt > Date.now())) {
17
+ return token
18
+ }
19
+ } catch {
20
+ // ignore malformed credentials file
21
+ }
22
+ }
23
+
24
+ return null
25
+ }
26
+
27
+ const apiKey = resolveApiKey()
28
+ if (!apiKey) {
29
+ console.error('\n❌ No API key found. Set ANTHROPIC_API_KEY or install Claude Code (code.visualstudio.com/download).\n')
30
+ process.exit(1)
31
+ }
32
+
33
+ const client = new Anthropic({ apiKey })
7
34
 
8
35
  /**
9
36
  * Generate a handover document using the Claude API
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "client-handover",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "description": "AI-powered handover document generator for frontend developers handing off client websites",
5
5
  "type": "module",
6
6
  "main": "index.js",