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.
- package/bin/create-agent.js +9 -8
- package/package.json +2 -2
package/bin/create-agent.js
CHANGED
|
@@ -14,11 +14,13 @@ function isGitRepo() {
|
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
// Check if
|
|
18
|
-
function
|
|
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
|
-
|
|
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[
|
|
30
|
-
|
|
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 (
|
|
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