create-agent 0.0.14 → 0.0.16

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/CNAME ADDED
@@ -0,0 +1 @@
1
+ init-agent.com
@@ -1,46 +1,70 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  import { generateAgent } from '../index.js'
4
+ import { execSync } from 'child_process'
5
+ import fs from 'fs'
6
+
7
+ // Check if in a git repo
8
+ function isGitRepo() {
9
+ try {
10
+ execSync('git rev-parse --git-dir', { stdio: 'ignore' })
11
+ return true
12
+ } catch {
13
+ return false
14
+ }
15
+ }
16
+
17
+ // Check if privkey already exists
18
+ function hasPrivkey() {
19
+ try {
20
+ const result = execSync('git config nostr.privkey', { encoding: 'utf8' }).trim()
21
+ return result.length > 0
22
+ } catch {
23
+ return false
24
+ }
25
+ }
26
+
27
+ // Main
28
+ 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)
32
+ }
33
+
34
+ if (hasPrivkey()) {
35
+ console.error('\x1b[33mAgent identity already exists.\x1b[0m')
36
+ console.error('Privkey found in: git config nostr.privkey')
37
+ console.error('To regenerate, first run: git config --unset nostr.privkey')
38
+ process.exit(1)
39
+ }
4
40
 
5
41
  // Generate agent identity
6
42
  const { privkey, pubkey, nsec, npub, did } = generateAgent()
7
43
 
8
- // =============================================================================
9
- // CONSOLE OUTPUT
10
- // =============================================================================
11
- // First output the initial warning message to stderr
12
- process.stderr.write('\x1b[36m🤖 Creating new Nostr agent identity...\x1b[0m\n');
13
- process.stderr.write('\x1b[36m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\x1b[0m\n');
14
- process.stderr.write('\x1b[33m⚠️ IMPORTANT: Keep your private key (nsec/privkey) secret!\x1b[0m\n');
15
- process.stderr.write('\x1b[33m Never share it with anyone or input it on websites.\x1b[0m\n');
16
- process.stderr.write('\n');
17
-
18
- // Then output the Nostr identity information to stderr
19
- process.stderr.write('\n\x1b[32m📋 Your Nostr Identity:\x1b[0m\n');
20
- process.stderr.write('\x1b[32m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\x1b[0m\n');
21
- process.stderr.write(`\x1b[0mPublic Key (hex) : \x1b[33m${pubkey}\x1b[0m\n`);
22
- process.stderr.write(`\x1b[0mNostr Public Key : \x1b[33m${npub}\x1b[0m\n`);
23
- process.stderr.write(`\x1b[0mPrivate Key (hex): \x1b[31m${privkey}\x1b[0m\n`);
24
- process.stderr.write(`\x1b[0mNostr Secret Key : \x1b[31m${nsec}\x1b[0m\n`);
25
- process.stderr.write('\n');
26
- process.stderr.write('\x1b[36m🔍 Usage:\x1b[0m\n');
27
- process.stderr.write('\x1b[0m- Use your npub to identify yourself to others\x1b[0m\n');
28
- process.stderr.write('\x1b[0m- Add relays to the services array for discovery\x1b[0m\n');
29
- process.stderr.write('\x1b[0m- Use nsec to sign into Nostr clients (handle with extreme care!)\x1b[0m\n');
30
- process.stderr.write('\n');
31
-
32
-
33
- // Then output the DID document to stdout with a clear header in the output
34
- process.stderr.write('\x1b[36m📄 DID Nostr Document:\x1b[0m\n');
35
- process.stderr.write('\x1b[36m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\x1b[0m\n');
36
- console.log(JSON.stringify(did, null, 2));
37
- process.stderr.write('\x1b[36m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\x1b[0m\n');
38
-
39
- // Suggest next steps with aam
40
- process.stderr.write('\n');
41
- process.stderr.write('\x1b[36m🚀 Next Steps:\x1b[0m\n');
42
- process.stderr.write('\x1b[36m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\x1b[0m\n');
43
- process.stderr.write('\x1b[0m- Install the Agentic App Manager: \x1b[33mnpm install -g aam\x1b[0m\n');
44
- process.stderr.write('\x1b[0m- Add skills to your agent: \x1b[33maam skills anthropics/skills\x1b[0m\n');
45
- process.stderr.write('\x1b[0m- Browse the registry: \x1b[33mhttps://aam.wtf\x1b[0m\n');
46
- process.stderr.write('\n');
44
+ // Save DID document to file
45
+ const didFile = 'agent.did.json'
46
+ fs.writeFileSync(didFile, JSON.stringify(did, null, 2) + '\n')
47
+
48
+ // Save privkey to git config
49
+ execSync(`git config nostr.privkey ${privkey}`)
50
+
51
+ // Also output DID to stdout (clean JSON, no npm noise)
52
+ console.log(JSON.stringify(did, null, 2))
53
+
54
+ // Status messages to stderr
55
+ process.stderr.write('\n')
56
+ process.stderr.write('\x1b[32m✓ Agent identity created\x1b[0m\n')
57
+ process.stderr.write(`\x1b[32m✓ DID saved to ${didFile}\x1b[0m\n`)
58
+ process.stderr.write('\x1b[32m✓ Private key saved to git config nostr.privkey\x1b[0m\n')
59
+ process.stderr.write('\n')
60
+ process.stderr.write(`\x1b[36m Public key: \x1b[33m${pubkey}\x1b[0m\n`)
61
+ process.stderr.write(`\x1b[36m npub: \x1b[33m${npub}\x1b[0m\n`)
62
+ process.stderr.write(`\x1b[36m DID: \x1b[33m${did.id}\x1b[0m\n`)
63
+ process.stderr.write('\n')
64
+ process.stderr.write('\x1b[33m⚠ Keep your privkey secret - never commit it\x1b[0m\n')
65
+ process.stderr.write('\x1b[0m View with: git config nostr.privkey\x1b[0m\n')
66
+ process.stderr.write('\n')
67
+ process.stderr.write('\x1b[36mNext steps:\x1b[0m\n')
68
+ process.stderr.write('\x1b[0m npm install -g aam\x1b[0m\n')
69
+ process.stderr.write('\x1b[0m aam skill sign <name> --repo you/repo\x1b[0m\n')
70
+ process.stderr.write('\n')
package/index.html ADDED
@@ -0,0 +1,393 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>npm init agent - Cryptographic Identity for AI Agents</title>
7
+ <meta name="description" content="Give your AI agent an identity. Generate cryptographic keys with did:nostr in one command. The foundation for safe AI agents you can trust.">
8
+
9
+ <!-- Open Graph -->
10
+ <meta property="og:type" content="website">
11
+ <meta property="og:url" content="https://init-agent.com/">
12
+ <meta property="og:title" content="npm init agent - Identity for AI Agents">
13
+ <meta property="og:description" content="Give your AI agent an identity. Generate cryptographic keys with did:nostr in one command.">
14
+ <meta property="og:image" content="https://init-agent.com/og-image.png">
15
+
16
+ <!-- Twitter -->
17
+ <meta name="twitter:card" content="summary_large_image">
18
+ <meta name="twitter:title" content="npm init agent - Identity for AI Agents">
19
+ <meta name="twitter:description" content="Give your AI agent an identity. Generate cryptographic keys with did:nostr in one command.">
20
+ <meta name="twitter:image" content="https://init-agent.com/og-image.png">
21
+
22
+ <link rel="preconnect" href="https://fonts.googleapis.com">
23
+ <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
24
+ <link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap" rel="stylesheet">
25
+ <style>
26
+ :root {
27
+ --bg: #f0f0f8;
28
+ --bg-hero: linear-gradient(180deg, #e8e8f4 0%, #f0f0f8 100%);
29
+ --bg-card: #ffffff;
30
+ --border: #e0e0ec;
31
+ --text: #1a1a2e;
32
+ --text-dim: #6b6b80;
33
+ --accent: #7c3aed;
34
+ --accent-light: #a78bfa;
35
+ --accent-soft: #7c3aed12;
36
+ --green: #10b981;
37
+ }
38
+
39
+ * {
40
+ box-sizing: border-box;
41
+ margin: 0;
42
+ padding: 0;
43
+ }
44
+
45
+ body {
46
+ font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
47
+ background: var(--bg);
48
+ color: var(--text);
49
+ min-height: 100vh;
50
+ line-height: 1.6;
51
+ }
52
+
53
+ .container {
54
+ max-width: 800px;
55
+ margin: 0 auto;
56
+ padding: 0 1.5rem;
57
+ }
58
+
59
+ /* Hero */
60
+ .hero {
61
+ background: var(--bg-hero);
62
+ padding: 5rem 0 4rem;
63
+ text-align: center;
64
+ }
65
+
66
+ .hero h1 {
67
+ font-size: 3rem;
68
+ font-weight: 800;
69
+ line-height: 1.15;
70
+ margin-bottom: 1.25rem;
71
+ color: var(--text);
72
+ letter-spacing: -0.02em;
73
+ }
74
+
75
+ .hero h1 .gradient {
76
+ background: linear-gradient(135deg, var(--accent) 0%, var(--accent-light) 100%);
77
+ -webkit-background-clip: text;
78
+ -webkit-text-fill-color: transparent;
79
+ background-clip: text;
80
+ }
81
+
82
+ .hero p {
83
+ color: var(--text-dim);
84
+ font-size: 1.125rem;
85
+ max-width: 500px;
86
+ margin: 0 auto 2.5rem;
87
+ }
88
+
89
+ .hero p strong {
90
+ color: var(--text);
91
+ }
92
+
93
+ /* Install Box */
94
+ .install-box {
95
+ max-width: 400px;
96
+ margin: 0 auto 2rem;
97
+ background: white;
98
+ border-radius: 12px;
99
+ padding: 1.25rem 1.75rem;
100
+ box-shadow: 0 4px 32px rgba(0, 0, 0, 0.08);
101
+ display: flex;
102
+ align-items: center;
103
+ justify-content: space-between;
104
+ font-family: 'SF Mono', Monaco, 'Cascadia Code', monospace;
105
+ font-size: 1.1rem;
106
+ border: 1px solid var(--border);
107
+ }
108
+
109
+ .install-box .prompt { color: var(--text-dim); }
110
+ .install-box .cmd { color: var(--accent); }
111
+ .install-box .pkg { color: var(--green); }
112
+
113
+ .copy-btn {
114
+ background: var(--bg);
115
+ border: 1px solid var(--border);
116
+ color: var(--text-dim);
117
+ padding: 0.5rem 0.875rem;
118
+ border-radius: 6px;
119
+ cursor: pointer;
120
+ font-size: 0.75rem;
121
+ font-weight: 500;
122
+ font-family: 'Inter', sans-serif;
123
+ transition: all 0.2s;
124
+ }
125
+
126
+ .copy-btn:hover {
127
+ background: var(--accent-soft);
128
+ border-color: var(--accent);
129
+ color: var(--accent);
130
+ }
131
+
132
+ /* Flow */
133
+ .flow {
134
+ padding: 3rem 0;
135
+ background: white;
136
+ }
137
+
138
+ .flow h2 {
139
+ text-align: center;
140
+ font-size: 1.5rem;
141
+ margin-bottom: 2rem;
142
+ }
143
+
144
+ .flow-steps {
145
+ display: flex;
146
+ justify-content: center;
147
+ gap: 1rem;
148
+ flex-wrap: wrap;
149
+ }
150
+
151
+ .flow-step {
152
+ background: var(--bg);
153
+ border: 1px solid var(--border);
154
+ border-radius: 12px;
155
+ padding: 1.5rem;
156
+ text-align: center;
157
+ flex: 1;
158
+ min-width: 200px;
159
+ max-width: 250px;
160
+ }
161
+
162
+ .flow-step .number {
163
+ width: 36px;
164
+ height: 36px;
165
+ background: var(--accent);
166
+ color: white;
167
+ border-radius: 50%;
168
+ display: flex;
169
+ align-items: center;
170
+ justify-content: center;
171
+ margin: 0 auto 1rem;
172
+ font-weight: 700;
173
+ }
174
+
175
+ .flow-step h3 {
176
+ font-size: 1rem;
177
+ margin-bottom: 0.5rem;
178
+ }
179
+
180
+ .flow-step p {
181
+ font-size: 0.875rem;
182
+ color: var(--text-dim);
183
+ }
184
+
185
+ .flow-step code {
186
+ display: block;
187
+ margin-top: 0.75rem;
188
+ background: white;
189
+ border: 1px solid var(--border);
190
+ padding: 0.5rem;
191
+ border-radius: 6px;
192
+ font-size: 0.75rem;
193
+ color: var(--green);
194
+ }
195
+
196
+ /* Output Preview */
197
+ .output {
198
+ padding: 3rem 0;
199
+ }
200
+
201
+ .output h2 {
202
+ text-align: center;
203
+ font-size: 1.5rem;
204
+ margin-bottom: 1.5rem;
205
+ }
206
+
207
+ .output pre {
208
+ background: #1a1a2e;
209
+ color: #e0e0ec;
210
+ padding: 1.5rem;
211
+ border-radius: 12px;
212
+ overflow-x: auto;
213
+ font-size: 0.8rem;
214
+ line-height: 1.5;
215
+ }
216
+
217
+ .output pre .key { color: #a78bfa; }
218
+ .output pre .str { color: #10b981; }
219
+
220
+ /* CTA */
221
+ .cta {
222
+ padding: 3rem 0;
223
+ background: white;
224
+ text-align: center;
225
+ border-top: 1px solid var(--border);
226
+ }
227
+
228
+ .cta h2 {
229
+ font-size: 1.5rem;
230
+ margin-bottom: 0.75rem;
231
+ }
232
+
233
+ .cta p {
234
+ color: var(--text-dim);
235
+ margin-bottom: 1.5rem;
236
+ }
237
+
238
+ .btn {
239
+ display: inline-flex;
240
+ align-items: center;
241
+ gap: 0.5rem;
242
+ padding: 0.9rem 1.75rem;
243
+ border-radius: 10px;
244
+ font-size: 0.9375rem;
245
+ font-weight: 600;
246
+ text-decoration: none;
247
+ transition: all 0.2s ease;
248
+ margin: 0 0.5rem;
249
+ }
250
+
251
+ .btn-primary {
252
+ background: var(--accent);
253
+ color: white;
254
+ box-shadow: 0 2px 8px rgba(124, 58, 237, 0.25);
255
+ }
256
+
257
+ .btn-primary:hover {
258
+ background: #6d28d9;
259
+ transform: translateY(-2px);
260
+ }
261
+
262
+ .btn-secondary {
263
+ background: white;
264
+ color: var(--text);
265
+ border: 1.5px solid var(--border);
266
+ }
267
+
268
+ .btn-secondary:hover {
269
+ border-color: var(--accent);
270
+ }
271
+
272
+ /* Footer */
273
+ footer {
274
+ padding: 2rem 0;
275
+ text-align: center;
276
+ color: var(--text-dim);
277
+ font-size: 0.875rem;
278
+ }
279
+
280
+ footer a {
281
+ color: var(--accent);
282
+ text-decoration: none;
283
+ }
284
+
285
+ footer a:hover {
286
+ text-decoration: underline;
287
+ }
288
+
289
+ @media (max-width: 768px) {
290
+ .hero h1 { font-size: 2rem; }
291
+ .install-box {
292
+ flex-direction: column;
293
+ gap: 1rem;
294
+ text-align: center;
295
+ }
296
+ .flow-steps { flex-direction: column; align-items: center; }
297
+ .flow-step { max-width: 100%; }
298
+ }
299
+ </style>
300
+ </head>
301
+ <body>
302
+ <!-- Hero -->
303
+ <section class="hero">
304
+ <div class="container">
305
+ <h1>Give Your Agent<br>an <span class="gradient">Identity</span></h1>
306
+ <p>Your AI agent can't prove who it is. <strong>Fix that in one command.</strong> Generate cryptographic keys with did:nostr.</p>
307
+
308
+ <div class="install-box">
309
+ <div>
310
+ <span class="prompt">$</span>
311
+ <span class="cmd">npm</span> init
312
+ <span class="pkg">agent</span>
313
+ </div>
314
+ <button class="copy-btn" onclick="copyInstall()">Copy</button>
315
+ </div>
316
+ </div>
317
+ </section>
318
+
319
+ <!-- Flow -->
320
+ <section class="flow">
321
+ <div class="container">
322
+ <h2>From Zero to Trusted Agent</h2>
323
+ <div class="flow-steps">
324
+ <div class="flow-step">
325
+ <div class="number">1</div>
326
+ <h3>Create Identity</h3>
327
+ <p>Generate did:nostr keypair</p>
328
+ <code>npm init agent</code>
329
+ </div>
330
+ <div class="flow-step">
331
+ <div class="number">2</div>
332
+ <h3>Sign Your Work</h3>
333
+ <p>Cryptographically sign skills</p>
334
+ <code>aam skill sign</code>
335
+ </div>
336
+ <div class="flow-step">
337
+ <div class="number">3</div>
338
+ <h3>Build Trust</h3>
339
+ <p>Others verify your identity</p>
340
+ <code>aam skill verify</code>
341
+ </div>
342
+ </div>
343
+ </div>
344
+ </section>
345
+
346
+ <!-- Output Preview -->
347
+ <section class="output">
348
+ <div class="container">
349
+ <h2>What You Get</h2>
350
+ <pre>{
351
+ <span class="key">"id"</span>: <span class="str">"did:nostr:73ca7fc7184ceb1095183663b1d9b2d3..."</span>,
352
+ <span class="key">"type"</span>: <span class="str">"DIDNostr"</span>,
353
+ <span class="key">"verificationMethod"</span>: [{
354
+ <span class="key">"type"</span>: <span class="str">"Multikey"</span>,
355
+ <span class="key">"publicKeyMultibase"</span>: <span class="str">"fe70102..."</span>
356
+ }],
357
+ <span class="key">"authentication"</span>: [<span class="str">"#key1"</span>]
358
+ }</pre>
359
+ </div>
360
+ </section>
361
+
362
+ <!-- CTA -->
363
+ <section class="cta">
364
+ <div class="container">
365
+ <h2>Ready to Sign Your Agents?</h2>
366
+ <p>Use your identity with aam to create safe, trusted AI agents.</p>
367
+ <a href="https://aam.wtf" class="btn btn-primary">Get Started with AAM</a>
368
+ <a href="https://github.com/melvincarvalho/create-agent" class="btn btn-secondary">View on GitHub</a>
369
+ </div>
370
+ </section>
371
+
372
+ <!-- Footer -->
373
+ <footer>
374
+ <div class="container">
375
+ <p>
376
+ <strong>create-agent</strong> |
377
+ <a href="https://aam.wtf">aam.wtf</a> |
378
+ <a href="https://github.com/melvincarvalho/create-agent">GitHub</a> |
379
+ MIT License
380
+ </p>
381
+ </div>
382
+ </footer>
383
+
384
+ <script>
385
+ function copyInstall() {
386
+ navigator.clipboard.writeText('npm init agent');
387
+ const btn = document.querySelector('.copy-btn');
388
+ btn.textContent = 'Copied!';
389
+ setTimeout(() => btn.textContent = 'Copy', 2000);
390
+ }
391
+ </script>
392
+ </body>
393
+ </html>
package/og-image.png ADDED
Binary file
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "create-agent",
3
3
  "type": "module",
4
- "version": "0.0.14",
4
+ "version": "0.0.16",
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
+ }