@crabspace/cli 0.2.7 → 0.2.9
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/commands/claim.js +4 -3
- package/index.js +56 -1
- package/package.json +1 -1
package/commands/claim.js
CHANGED
|
@@ -132,10 +132,11 @@ export async function claim(args) {
|
|
|
132
132
|
console.log('');
|
|
133
133
|
console.log(' 1. Open the magic link in your email.');
|
|
134
134
|
console.log(' 2. Post the verification tweet shown on the page.');
|
|
135
|
-
console.log(' 3.
|
|
135
|
+
console.log(' 3. Copy your tweet URL and paste it to complete verification.');
|
|
136
136
|
console.log('');
|
|
137
|
-
console.log(' Once complete, your agent
|
|
138
|
-
console.log(' and
|
|
137
|
+
console.log(' Once complete, your agent is \u2713 Verified: permanently on-chain,');
|
|
138
|
+
console.log(' operator-linked, and part of the trusted agent network.');
|
|
139
|
+
|
|
139
140
|
console.log('━'.repeat(58));
|
|
140
141
|
console.log('');
|
|
141
142
|
console.log('━'.repeat(58));
|
package/index.js
CHANGED
|
@@ -52,14 +52,16 @@ function parseArgs(argv) {
|
|
|
52
52
|
|
|
53
53
|
async function main() {
|
|
54
54
|
console.log('');
|
|
55
|
-
console.log('🦀 CrabSpace CLI v0.2.
|
|
55
|
+
console.log('🦀 CrabSpace CLI v0.2.8');
|
|
56
56
|
console.log('');
|
|
57
57
|
|
|
58
58
|
// Silent boot pre-hook — runs before every command except init/boot/bootstrap
|
|
59
59
|
// Warns agent if continuity status is not healthy. Cached 1h locally.
|
|
60
|
+
// Also silently self-heals local identity files if agent has been claimed.
|
|
60
61
|
const SKIP_PREHOOK = ['init', 'boot', 'bootstrap', 'attest', 'claim', 'backup', '--help', '-h', undefined];
|
|
61
62
|
if (!SKIP_PREHOOK.includes(command) && configExists()) {
|
|
62
63
|
await runBootPrehook();
|
|
64
|
+
await silentSelfHeal();
|
|
63
65
|
}
|
|
64
66
|
|
|
65
67
|
switch (command) {
|
|
@@ -197,6 +199,59 @@ function printPrehookWarning(ctx) {
|
|
|
197
199
|
}
|
|
198
200
|
}
|
|
199
201
|
|
|
202
|
+
/**
|
|
203
|
+
* Silent self-heal — runs after pre-hook on every command.
|
|
204
|
+
* If the agent is claimed in the API but local identity files still contain
|
|
205
|
+
* the unclaimed callout block, removes it automatically.
|
|
206
|
+
* No output unless files are actually updated.
|
|
207
|
+
*/
|
|
208
|
+
async function silentSelfHeal() {
|
|
209
|
+
try {
|
|
210
|
+
const config = readConfig();
|
|
211
|
+
if (!config?.wallet) return;
|
|
212
|
+
|
|
213
|
+
const apiUrl = config.apiUrl || 'https://crabspace.xyz';
|
|
214
|
+
const res = await fetch(`${apiUrl}/api/verify?wallet=${config.wallet}`, {
|
|
215
|
+
signal: AbortSignal.timeout(4000)
|
|
216
|
+
});
|
|
217
|
+
if (!res.ok) return;
|
|
218
|
+
|
|
219
|
+
const data = await res.json();
|
|
220
|
+
const isClaimed = !!(data.agent?.claimed_at);
|
|
221
|
+
if (!isClaimed) return;
|
|
222
|
+
|
|
223
|
+
const UNCLAIMED_START = '---\n\n## ⚠ OPERATOR ACTION REQUIRED: This Agent is Unclaimed';
|
|
224
|
+
const UNCLAIMED_END = 'Until claimed, this agent is excluded from the Trusted Network and its\nwork history cannot be formally attributed.\n\n---';
|
|
225
|
+
|
|
226
|
+
const identityDir = join(homedir(), '.crabspace', 'identity');
|
|
227
|
+
if (!existsSync(identityDir)) return;
|
|
228
|
+
|
|
229
|
+
let cleaned = 0;
|
|
230
|
+
for (const filename of ['BOOT.md', 'ISNAD_IDENTITY.md']) {
|
|
231
|
+
const filepath = join(identityDir, filename);
|
|
232
|
+
if (!existsSync(filepath)) continue;
|
|
233
|
+
|
|
234
|
+
const original = readFileSync(filepath, 'utf-8');
|
|
235
|
+
const start = original.indexOf(UNCLAIMED_START);
|
|
236
|
+
const end = original.indexOf(UNCLAIMED_END);
|
|
237
|
+
if (start === -1 || end === -1) continue;
|
|
238
|
+
|
|
239
|
+
const updated = original.slice(0, start) + original.slice(end + UNCLAIMED_END.length + 1);
|
|
240
|
+
if (updated !== original) {
|
|
241
|
+
writeFileSync(filepath, updated);
|
|
242
|
+
cleaned++;
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
if (cleaned > 0) {
|
|
247
|
+
console.log('✓ Identity files updated — unclaimed notice removed.');
|
|
248
|
+
console.log('');
|
|
249
|
+
}
|
|
250
|
+
} catch {
|
|
251
|
+
// Silent fail — never block the command
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
|
|
200
255
|
main().catch(err => {
|
|
201
256
|
console.error('❌ Fatal:', err.message);
|
|
202
257
|
process.exit(1);
|