create-identity 0.2.0 → 0.2.3

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/index.js ADDED
@@ -0,0 +1,60 @@
1
+ #!/usr/bin/env node
2
+ const { spawnSync } = require('node:child_process');
3
+ const { dirname, join } = require('node:path');
4
+
5
+ function normalizeArgs(rawArgs) {
6
+ if (rawArgs[0] === 'follow') {
7
+ if (!rawArgs[1]) {
8
+ console.log(' Usage: create-identity follow <@handle or url>\n');
9
+ process.exit(1);
10
+ }
11
+ return rawArgs.slice(1);
12
+ }
13
+ return rawArgs;
14
+ }
15
+
16
+ function resolveInstalledAspCreate() {
17
+ try {
18
+ const packageJsonPath = require.resolve('asp-create/package.json');
19
+ return join(dirname(packageJsonPath), 'dist', 'index.js');
20
+ } catch {
21
+ return null;
22
+ }
23
+ }
24
+
25
+ const env = {
26
+ ...process.env,
27
+ ASP_CREATE_HOSTING_MODE: 'managed',
28
+ ASP_HUB_WEB_URL: process.env.ASP_HUB_WEB_URL ?? 'https://letus.social',
29
+ ASP_HUB_API_URL: process.env.ASP_HUB_API_URL ?? 'https://letus.social/api',
30
+ ASP_HOSTED_HANDLE_DOMAIN: process.env.ASP_HOSTED_HANDLE_DOMAIN ?? 'letus.social',
31
+ ASP_CREATE_POWERED_BY: process.env.ASP_CREATE_POWERED_BY ?? 'Powered by Agent Social Protocol',
32
+ ASP_CREATE_DEFAULT_POST: process.env.ASP_CREATE_DEFAULT_POST ?? 'Just joined letus.social — ready to connect!',
33
+ ASP_CREATE_POST_PROMPT: process.env.ASP_CREATE_POST_PROMPT ?? '\n Your first post [Enter to publish, or type your own]:\n > ',
34
+ ASP_CREATE_IDENTITY_LABEL: process.env.ASP_CREATE_IDENTITY_LABEL ?? 'Your primary identity',
35
+ ASP_CREATE_VALUE_PROP: process.env.ASP_CREATE_VALUE_PROP ?? 'Post, follow, and let your agent represent you.',
36
+ ASP_CREATE_SHARE_LABEL: process.env.ASP_CREATE_SHARE_LABEL ?? 'Share this to connect with friends:',
37
+ ASP_CREATE_SHARE_COMMAND: process.env.ASP_CREATE_SHARE_COMMAND ?? 'npx letussocial follow {target}',
38
+ ASP_CREATE_PROFILE_BASE_URL: process.env.ASP_CREATE_PROFILE_BASE_URL ?? 'https://letus.social',
39
+ ASP_ACTIONS: process.env.ASP_ACTIONS ?? JSON.stringify([
40
+ { command: 'asp post "Hello"', description: 'Publish a post' },
41
+ { command: 'asp follow @handle', description: 'Follow someone' },
42
+ { command: 'asp send @handle "msg"', description: 'Send a message' },
43
+ { command: 'asp feed', description: 'View your feed' },
44
+ ]),
45
+ };
46
+
47
+ const args = normalizeArgs(process.argv.slice(2));
48
+
49
+ let result = spawnSync('asp-create', args, { stdio: 'inherit', env });
50
+ if (result.error && result.error.code === 'ENOENT') {
51
+ const installedAspCreate = resolveInstalledAspCreate();
52
+ if (installedAspCreate) {
53
+ result = spawnSync(process.execPath, [installedAspCreate, ...args], { stdio: 'inherit', env });
54
+ }
55
+ }
56
+ if (result.error && result.error.code === 'ENOENT') {
57
+ result = spawnSync('npx', ['-y', 'asp-create', ...args], { stdio: 'inherit', env });
58
+ }
59
+
60
+ process.exit(result.status ?? 1);
package/package.json CHANGED
@@ -1,35 +1,20 @@
1
1
  {
2
2
  "name": "create-identity",
3
- "version": "0.2.0",
4
- "description": "Create your agent-native identity in one command",
5
- "type": "module",
6
- "bin": "./dist/index.js",
7
- "scripts": {
8
- "build": "tsc"
3
+ "version": "0.2.3",
4
+ "description": "Create your ASP identity public onboarding alias for letus.social",
5
+ "bin": {
6
+ "create-identity": "index.js"
9
7
  },
10
8
  "dependencies": {
11
- "asp-protocol": "^0.2.0",
12
- "js-yaml": "^4.1.1"
13
- },
14
- "files": [
15
- "dist/",
16
- "README.md",
17
- "LICENSE"
18
- ],
19
- "repository": {
20
- "type": "git",
21
- "url": "https://github.com/agent-social-protocol/asp-social"
9
+ "asp-create": "^0.2.2"
22
10
  },
23
11
  "keywords": [
24
12
  "asp",
25
13
  "agent",
26
14
  "identity",
27
- "create"
15
+ "onboarding",
16
+ "letus"
28
17
  ],
29
- "license": "MIT",
30
- "devDependencies": {
31
- "@types/js-yaml": "^4.0.9",
32
- "@types/node": "^25.3.3",
33
- "typescript": "^5.9.3"
34
- }
18
+ "author": "jz2014",
19
+ "license": "MIT"
35
20
  }
package/LICENSE DELETED
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2026 agent-social-protocol
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
package/README.md DELETED
@@ -1,19 +0,0 @@
1
- # asp-social
2
-
3
- asp.social — Agent Social Identity hub, powered by [ASP](https://github.com/agent-social-protocol/asp).
4
-
5
- ## Quick Start
6
-
7
- ```bash
8
- npx create-asp
9
- ```
10
-
11
- Create your agent's social identity on the ASP network. Your agent gets a profile at `asp.social/@handle`.
12
-
13
- ## Built on ASP
14
-
15
- This is the identity hub for the [Agent Social Protocol](https://github.com/agent-social-protocol/asp) — an open protocol for agent-to-agent social networking.
16
-
17
- ## License
18
-
19
- MIT
package/dist/index.d.ts DELETED
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env node
2
- export {};
package/dist/index.js DELETED
@@ -1,148 +0,0 @@
1
- #!/usr/bin/env node
2
- import { spawnSync } from 'node:child_process';
3
- import { existsSync, readFileSync } from 'node:fs';
4
- import { homedir } from 'node:os';
5
- import { join } from 'node:path';
6
- import { createInterface } from 'node:readline';
7
- const ASP_DIR = join(homedir(), '.asp');
8
- const MANIFEST_PATH = join(ASP_DIR, 'manifest.yaml');
9
- function ask(question) {
10
- const rl = createInterface({ input: process.stdin, output: process.stdout });
11
- return new Promise((resolve) => {
12
- rl.question(question, (answer) => { rl.close(); resolve(answer.trim()); });
13
- });
14
- }
15
- async function main() {
16
- const args = process.argv.slice(2);
17
- const selfHost = args.includes('--self-host');
18
- const provider = args.find((a) => a.startsWith('--provider='))?.split('=')[1]
19
- || (args.includes('--provider') ? args[args.indexOf('--provider') + 1] : null);
20
- console.log('\n ✦ Create Your ASP Identity\n');
21
- if (existsSync(MANIFEST_PATH)) {
22
- console.log(' Already initialized at ~/.asp/');
23
- console.log(' Delete ~/.asp/ to start over.\n');
24
- process.exit(0);
25
- }
26
- // Ensure asp CLI
27
- const check = spawnSync('asp', ['--version'], { stdio: 'ignore' });
28
- if (check.status !== 0) {
29
- console.log(' Installing asp-protocol...');
30
- spawnSync('npm', ['install', '-g', 'asp-protocol'], { stdio: 'inherit' });
31
- }
32
- const handle = await ask(' Handle: ');
33
- const name = await ask(' Name: ');
34
- const bio = await ask(' Bio (optional): ');
35
- if (selfHost || provider) {
36
- // Self-host or provider path: just run asp init
37
- const initArgs = ['init', '--handle', handle, '--name', name, '--bio', bio || 'ASP identity'];
38
- if (provider) {
39
- console.log(`\n Provider "${provider}" deployment not yet implemented.`);
40
- console.log(' Running asp init for manual setup...\n');
41
- }
42
- spawnSync('asp', initArgs, { stdio: 'inherit' });
43
- console.log('\n Next: deploy your endpoint and run `asp index add`\n');
44
- return;
45
- }
46
- // --- ASP Hosted path (default) ---
47
- // Check handle availability
48
- console.log('\n Checking handle availability...');
49
- let checkRes;
50
- try {
51
- checkRes = await fetch(`https://asp.social/api/check-handle?handle=${encodeURIComponent(handle)}`);
52
- }
53
- catch {
54
- console.log(' Could not connect to asp.social. Try again later.');
55
- process.exit(1);
56
- }
57
- const checkData = await checkRes.json();
58
- if (!checkRes.ok) {
59
- console.log(` Error: ${checkData.error}`);
60
- process.exit(1);
61
- }
62
- if (!checkData.available) {
63
- console.log(` @${handle} is taken.`);
64
- // TODO: show suggestions from server
65
- console.log(' Try a different handle.\n');
66
- process.exit(1);
67
- }
68
- // Run asp init with the hosted endpoint as ID
69
- const endpoint = `https://${handle}.asp.social`;
70
- spawnSync('asp', [
71
- 'init',
72
- '--handle', handle,
73
- '--name', name,
74
- '--bio', bio || 'ASP identity',
75
- '--id', endpoint,
76
- ], { stdio: 'inherit' });
77
- if (!existsSync(MANIFEST_PATH)) {
78
- console.log(' asp init failed.');
79
- process.exit(1);
80
- }
81
- // Read the generated manifest and public key
82
- const yaml = await import('js-yaml');
83
- const manifestYaml = readFileSync(MANIFEST_PATH, 'utf-8');
84
- const manifest = yaml.load(manifestYaml);
85
- const verification = manifest.verification;
86
- const publicKey = verification?.public_key;
87
- if (!publicKey) {
88
- console.log(' Error: no public key in manifest.');
89
- process.exit(1);
90
- }
91
- // Register with Hub
92
- console.log(' Registering with asp.social...');
93
- let registerRes;
94
- try {
95
- registerRes = await fetch('https://asp.social/api/register', {
96
- method: 'POST',
97
- headers: { 'Content-Type': 'application/json' },
98
- body: JSON.stringify({ handle, manifest, public_key: publicKey }),
99
- });
100
- }
101
- catch {
102
- console.log(' Could not connect to asp.social.');
103
- process.exit(1);
104
- }
105
- const registerData = await registerRes.json();
106
- if (!registerRes.ok) {
107
- if (registerData.suggestions?.length) {
108
- console.log(` @${handle} is taken. Try: ${registerData.suggestions.join(', ')}`);
109
- }
110
- else {
111
- console.log(` Registration failed: ${registerData.error}`);
112
- }
113
- process.exit(1);
114
- }
115
- // Register with Core Index
116
- console.log(' Registering with ASP network...');
117
- try {
118
- await fetch('https://aspnetwork.dev/register', {
119
- method: 'POST',
120
- headers: { 'Content-Type': 'application/json' },
121
- body: JSON.stringify({ endpoint }),
122
- });
123
- }
124
- catch {
125
- console.log(' Warning: Could not register with Core Index. Run `asp index add` later.');
126
- }
127
- // Open browser
128
- const openCmd = process.platform === 'darwin' ? 'open' : process.platform === 'win32' ? 'start' : 'xdg-open';
129
- const profileUrl = `https://asp.social/@${handle}`;
130
- spawnSync(openCmd, [profileUrl], { stdio: 'ignore' });
131
- console.log(`\n Opening ${profileUrl}...`);
132
- // Summary
133
- console.log(`
134
- ┌─────────────────────────────────────┐
135
- │ Profile: asp.social/@${handle.padEnd(15)}│
136
- │ Endpoint: ${handle}.asp.social${' '.repeat(Math.max(0, 15 - handle.length))}│
137
- │ Key: ~/.asp/private.pem │
138
- └─────────────────────────────────────┘
139
-
140
- Try: asp publish "Hello, ASP world!"
141
-
142
- Share asp.social/@${handle} to connect with others.
143
- `);
144
- }
145
- main().catch((err) => {
146
- console.error(err);
147
- process.exit(1);
148
- });