create-agent 0.0.16 → 0.0.17

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.
@@ -14,11 +14,13 @@ function isGitRepo() {
14
14
  }
15
15
  }
16
16
 
17
- // Check if privkey already exists
18
- function hasPrivkey() {
17
+ // Check if agent identity already exists in THIS repo (not inherited from parent)
18
+ function hasIdentity() {
19
19
  try {
20
- const result = execSync('git config nostr.privkey', { encoding: 'utf8' }).trim()
21
- return result.length > 0
20
+ const result = execSync('git config --local nostr.privkey', { encoding: 'utf8' }).trim()
21
+ const hasLocalPrivkey = result.length > 0
22
+ const hasDIDFile = fs.existsSync('agent.did.json')
23
+ return hasLocalPrivkey && hasDIDFile
22
24
  } catch {
23
25
  return false
24
26
  }
@@ -26,12 +28,11 @@ function hasPrivkey() {
26
28
 
27
29
  // Main
28
30
  if (!isGitRepo()) {
29
- console.error('\x1b[31mError: Not in a git repository.\x1b[0m')
30
- console.error('Run \x1b[33mgit init\x1b[0m first.')
31
- process.exit(1)
31
+ console.error('\x1b[36mInitializing git repository...\x1b[0m')
32
+ execSync('git init', { stdio: 'inherit' })
32
33
  }
33
34
 
34
- if (hasPrivkey()) {
35
+ if (hasIdentity()) {
35
36
  console.error('\x1b[33mAgent identity already exists.\x1b[0m')
36
37
  console.error('Privkey found in: git config nostr.privkey')
37
38
  console.error('To regenerate, first run: git config --unset nostr.privkey')
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "create-agent",
3
3
  "type": "module",
4
- "version": "0.0.16",
4
+ "version": "0.0.17",
5
5
  "description": "create an agent",
6
6
  "scripts": {
7
7
  "test": "node --test"
@@ -27,4 +27,4 @@
27
27
  "dependencies": {
28
28
  "nostr-tools": "^2.10.4"
29
29
  }
30
- }
30
+ }