@bitpub/cli 2.0.1 → 2.0.2
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/package.json +1 -1
- package/src/commands/init.js +5 -0
- package/src/commands/setup.js +71 -0
- package/src/commands/welcome.js +3 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bitpub/cli",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.2",
|
|
4
4
|
"description": "BitPub CLI — local-first shared memory for AI agents. Six daily verbs (save/load/list/find/sync/delete), zero-config private namespace, encrypted client-side.",
|
|
5
5
|
"bin": {
|
|
6
6
|
"bitpub": "./bin/bitpub.js"
|
package/src/commands/init.js
CHANGED
|
@@ -15,6 +15,7 @@ const {
|
|
|
15
15
|
ensureIdentity,
|
|
16
16
|
ensureWorkspace,
|
|
17
17
|
ensureSkill,
|
|
18
|
+
runFirstRunWelcome,
|
|
18
19
|
} = require('./setup');
|
|
19
20
|
const { DEFAULT_CLOUD_URL } = require('../config');
|
|
20
21
|
|
|
@@ -27,6 +28,7 @@ module.exports = function registerInit(program) {
|
|
|
27
28
|
.option('--no-workspace', 'Skip creating a .bitpub/workspace.json in the current folder')
|
|
28
29
|
.option('--workspace-label <string>', 'Override the workspace label (defaults to folder name)')
|
|
29
30
|
.option('--force', 'Overwrite an existing identity (the old key is unrecoverable)')
|
|
31
|
+
.option('--no-welcome', 'Skip the post-install welcome (save first memory + open browser)')
|
|
30
32
|
.option('--import-from <path>', 'Import an existing TollBit config')
|
|
31
33
|
.option('--no-import', 'Skip auto-import')
|
|
32
34
|
.action(async (opts) => {
|
|
@@ -41,6 +43,9 @@ module.exports = function registerInit(program) {
|
|
|
41
43
|
ensureWorkspace({ owner: config.owner, label: opts.workspaceLabel });
|
|
42
44
|
}
|
|
43
45
|
await ensureSkill({});
|
|
46
|
+
if (config && !opts.localOnly && opts.welcome !== false) {
|
|
47
|
+
await runFirstRunWelcome(config);
|
|
48
|
+
}
|
|
44
49
|
} catch (err) {
|
|
45
50
|
console.error(`\n✗ ${err.message}`);
|
|
46
51
|
process.exit(1);
|
package/src/commands/setup.js
CHANGED
|
@@ -23,6 +23,7 @@
|
|
|
23
23
|
const path = require('path');
|
|
24
24
|
const fs = require('fs');
|
|
25
25
|
const os = require('os');
|
|
26
|
+
const { spawn } = require('child_process');
|
|
26
27
|
const axios = require('axios');
|
|
27
28
|
const {
|
|
28
29
|
readConfig,
|
|
@@ -169,6 +170,65 @@ async function ensureSkill({ quiet = false } = {}) {
|
|
|
169
170
|
}
|
|
170
171
|
}
|
|
171
172
|
|
|
173
|
+
/**
|
|
174
|
+
* First-run welcome: save the Welcome slice and (if interactive) open the
|
|
175
|
+
* browser to view it. Shared by `bitpub setup` and the deprecated
|
|
176
|
+
* `bitpub init` so any install path lands the user in the same place.
|
|
177
|
+
*
|
|
178
|
+
* Idempotent through welcome.js's `welcome_saved_at` config flag. The
|
|
179
|
+
* browser tab only opens on a *fresh* save (so re-running setup doesn't
|
|
180
|
+
* pop new tabs forever); when the slice already exists we just print a
|
|
181
|
+
* pointer to `bitpub browser`.
|
|
182
|
+
*
|
|
183
|
+
* Auto-open is gated:
|
|
184
|
+
* - `BITPUB_SKIP_WELCOME=1` → skip
|
|
185
|
+
* - non-TTY stdout (CI, headless agents w/o pty) → skip with a pointer
|
|
186
|
+
* - otherwise → spawn `bitpub welcome --serve` detached so the server
|
|
187
|
+
* outlives this process and the user gets their shell back.
|
|
188
|
+
*/
|
|
189
|
+
async function runFirstRunWelcome(config) {
|
|
190
|
+
const { saveWelcomeSlice } = require('./welcome');
|
|
191
|
+
|
|
192
|
+
let result;
|
|
193
|
+
try {
|
|
194
|
+
result = await saveWelcomeSlice(config, {});
|
|
195
|
+
} catch (err) {
|
|
196
|
+
console.error(`\n(welcome: could not save first memory — ${err.message})`);
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
// Re-run on an already-welcomed machine — quietly skip the browser
|
|
201
|
+
// open so a `bitpub setup` re-invocation isn't disruptive.
|
|
202
|
+
if (!result.saved) return;
|
|
203
|
+
|
|
204
|
+
console.log(`\n✓ Saved your first memory → ${result.address} (v${result.version})`);
|
|
205
|
+
|
|
206
|
+
const skipReason = welcomeSkipReason();
|
|
207
|
+
if (skipReason) {
|
|
208
|
+
console.log(` (skipping auto browser open: ${skipReason})`);
|
|
209
|
+
console.log(' Run `bitpub welcome --serve` to open it when you\'re ready.');
|
|
210
|
+
return;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
try {
|
|
214
|
+
const child = spawn(process.execPath, [process.argv[1], 'welcome', '--serve'], {
|
|
215
|
+
detached: true,
|
|
216
|
+
stdio: 'ignore',
|
|
217
|
+
});
|
|
218
|
+
child.unref();
|
|
219
|
+
console.log(' Opening your browser at http://localhost:4141 …');
|
|
220
|
+
} catch (err) {
|
|
221
|
+
console.error(` (could not auto-open browser: ${err.message})`);
|
|
222
|
+
console.error(' Run `bitpub welcome --serve` manually.');
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
function welcomeSkipReason() {
|
|
227
|
+
if (process.env.BITPUB_SKIP_WELCOME === '1') return 'BITPUB_SKIP_WELCOME=1';
|
|
228
|
+
if (!process.stdout.isTTY) return 'non-interactive shell';
|
|
229
|
+
return null;
|
|
230
|
+
}
|
|
231
|
+
|
|
172
232
|
module.exports = function registerSetup(program) {
|
|
173
233
|
const setup = program
|
|
174
234
|
.command('setup')
|
|
@@ -178,6 +238,7 @@ module.exports = function registerSetup(program) {
|
|
|
178
238
|
.option('--no-anchor', 'Skip anchoring this folder as a project')
|
|
179
239
|
.option('--label <string>', 'Override the project label (defaults to folder name)')
|
|
180
240
|
.option('--force', 'Overwrite an existing identity (the old key is unrecoverable after this)')
|
|
241
|
+
.option('--no-welcome', 'Skip the post-install welcome (save first memory + open browser)')
|
|
181
242
|
.option('--import-from <path>', 'Import an existing TollBit config (defaults to ~/.tollbit/config.json if present)')
|
|
182
243
|
.option('--no-import', 'Skip auto-import even if a legacy ~/.tollbit/ config is present')
|
|
183
244
|
.action(async (opts) => {
|
|
@@ -191,6 +252,15 @@ module.exports = function registerSetup(program) {
|
|
|
191
252
|
ensureWorkspace({ owner: config.owner, label: opts.label });
|
|
192
253
|
}
|
|
193
254
|
await ensureSkill({});
|
|
255
|
+
|
|
256
|
+
// Welcome flow: save a first memory + open the browser. Idempotent
|
|
257
|
+
// and gated — re-running `bitpub setup` doesn't keep popping tabs.
|
|
258
|
+
// Skipped in --local-only (no cloud identity to write to) and when
|
|
259
|
+
// the user opted out via --no-welcome or BITPUB_SKIP_WELCOME=1.
|
|
260
|
+
if (config && !opts.localOnly && opts.welcome !== false) {
|
|
261
|
+
await runFirstRunWelcome(config);
|
|
262
|
+
}
|
|
263
|
+
|
|
194
264
|
console.log('\nTry it:');
|
|
195
265
|
console.log(' bitpub save notes "first slice"');
|
|
196
266
|
console.log(' bitpub list # see what\'s in this project');
|
|
@@ -310,3 +380,4 @@ function maybeImportLegacyConfig({ quiet = false } = {}) {
|
|
|
310
380
|
module.exports.ensureIdentity = ensureIdentity;
|
|
311
381
|
module.exports.ensureWorkspace = ensureWorkspace;
|
|
312
382
|
module.exports.ensureSkill = ensureSkill;
|
|
383
|
+
module.exports.runFirstRunWelcome = runFirstRunWelcome;
|
package/src/commands/welcome.js
CHANGED
|
@@ -80,8 +80,8 @@ function buildWelcomeContent(config) {
|
|
|
80
80
|
'Generate a link teammates can click to join your group namespace and',
|
|
81
81
|
'read shared context. No GitHub invites, no repo access, no PRs.',
|
|
82
82
|
'',
|
|
83
|
-
'> *One-click sharing coming soon. Today: `bitpub
|
|
84
|
-
'> yourcompany.com` joins an existing team namespace.*',
|
|
83
|
+
'> *One-click sharing coming soon. Today: `bitpub setup team --key K',
|
|
84
|
+
'> --domain yourcompany.com` joins an existing team namespace.*',
|
|
85
85
|
'',
|
|
86
86
|
'### 3. See what you can build',
|
|
87
87
|
'',
|
|
@@ -89,7 +89,7 @@ function buildWelcomeContent(config) {
|
|
|
89
89
|
'can put here — research notes, prompts, drafts, agent configs, job',
|
|
90
90
|
'queues. Multiple agents can read and write the same slices.',
|
|
91
91
|
'',
|
|
92
|
-
'> Read the [Cookbook](https://github.com/tollbit/
|
|
92
|
+
'> Read the [Cookbook](https://github.com/tollbit/bitpub/blob/main/COOKBOOK.md)',
|
|
93
93
|
'> for real patterns teams have built on top of these primitives.',
|
|
94
94
|
'',
|
|
95
95
|
'---',
|