bgit-cli 2.0.0

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.
@@ -0,0 +1,19 @@
1
+ {
2
+ "permissions": {
3
+ "allow": [
4
+ "Bash(test:*)",
5
+ "Bash(cat:*)",
6
+ "WebSearch",
7
+ "WebFetch(domain:docs.handcash.io)",
8
+ "WebFetch(domain:github.com)",
9
+ "Bash(npm install:*)",
10
+ "Bash(chmod:*)",
11
+ "Bash(./index.js)",
12
+ "Bash(node index.js:*)",
13
+ "Bash(./index.js status:*)",
14
+ "Bash(./index.js config:*)",
15
+ "Bash(./index.js auth:*)",
16
+ "Bash(tee:*)"
17
+ ]
18
+ }
19
+ }
package/.env.local ADDED
@@ -0,0 +1,2 @@
1
+ HANDCASH_APP_ID: '6959a82a9b2206d9465b3fe4',
2
+ HANDCASH_APP_SECRET: '964f849219ff0feb2c03a2322fc1441d9c0ec1b0d6c3a98e60b393a94a2cac2c',
package/CLAUDE_PLAN.md ADDED
@@ -0,0 +1,621 @@
1
+ # Claude's Plan: Reconciling OAuth Implementation with Universal Pay-to-Operate Vision
2
+
3
+ **Date:** 2026-01-04
4
+ **Status:** Implementation Complete, Vision Alignment Needed
5
+ **Goal:** Integrate production OAuth with universal payment model + aesthetics
6
+
7
+ ---
8
+
9
+ ## Analysis: Current State vs. Original Vision
10
+
11
+ ### What Claude Built (Current Implementation)
12
+ ✅ **Production-ready OAuth** - Full browser-based authentication
13
+ ✅ **Encrypted token storage** - AES-256-GCM security
14
+ ✅ **Smart routing** - Only commit/push are payment-gated
15
+ ✅ **Pass-through** - All other commands are FREE (status, log, diff, etc.)
16
+ ✅ **Professional UX** - Colored output, error handling
17
+
18
+ **Philosophy:** Minimal friction, only pay for "publishing" actions
19
+
20
+ ### What b0ase Originally Wanted (Gemini's Plan)
21
+ 🎯 **Universal Payment** - ALL 155 git commands require payment
22
+ 🎯 **ASCII Banner** - Beautiful bgit branding
23
+ 🎯 **Pay-to-Operate** - Every git operation costs 0.001 BSV
24
+
25
+ **Philosophy:** Complete git history monetization, every command is valuable
26
+
27
+ ---
28
+
29
+ ## The Fundamental Question
30
+
31
+ **Should users pay for EVERY git command?**
32
+
33
+ ### Arguments FOR Universal Payment (Gemini's Vision)
34
+ 1. **Complete History** - Every git operation is timestamped on-chain
35
+ 2. **Universal Proof** - Even `git status` has provable timestamp
36
+ 3. **Consistency** - Simple model: "all commands cost 0.001 BSV"
37
+ 4. **Revenue** - More payments = more developer revenue
38
+ 5. **Original Intent** - This was the user's initial vision
39
+
40
+ ### Arguments AGAINST Universal Payment (Claude's Implementation)
41
+ 1. **User Friction** - Paying for `git status` seems excessive
42
+ 2. **Developer Workflow** - Devs run status/log hundreds of times per day
43
+ 3. **Cost Barrier** - Could cost $10-50/day for active developer
44
+ 4. **Adoption** - Nobody will use a tool that charges for `git status`
45
+ 5. **Value Proposition** - Timestamping READ operations has little value
46
+
47
+ ### My Recommendation: Hybrid Model ⭐
48
+
49
+ **Tier 1: Free (Read-Only Operations)**
50
+ - status, log, diff, show, branch, grep, etc.
51
+ - No payment, no authentication required
52
+ - Users can inspect code freely
53
+
54
+ **Tier 2: Paid Write Operations (Current Implementation)**
55
+ - commit, push
56
+ - 0.001 BSV each
57
+ - Timestamps on-chain
58
+
59
+ **Tier 3: Optional Premium (Future)**
60
+ - All other commands (configurable)
61
+ - User can enable "full history mode"
62
+ - Toggle: `bgit config --set payment-mode=universal`
63
+
64
+ **Rationale:**
65
+ - Maintains usability
66
+ - Reduces friction
67
+ - Provides upgrade path
68
+ - Respects both visions
69
+
70
+ ---
71
+
72
+ ## Implementation Plan
73
+
74
+ ### Option A: Keep Current Model (Recommended)
75
+ **Effort:** 1 hour
76
+ **Impact:** Add banner, document philosophy, ship v2.0
77
+
78
+ **Steps:**
79
+ 1. ✅ Add banner to index.js (5 min)
80
+ 2. ✅ Update docs to explain payment model (15 min)
81
+ 3. ✅ Add config option for future universal mode (30 min)
82
+ 4. ✅ Test and ship (10 min)
83
+
84
+ **Pros:**
85
+ - Ships immediately
86
+ - Usable product
87
+ - Respects both visions
88
+ - Easy to expand later
89
+
90
+ **Cons:**
91
+ - Deviates from original "universal" vision
92
+ - Lower revenue potential
93
+
94
+ ---
95
+
96
+ ### Option B: Implement Universal Payment (Gemini's Plan)
97
+ **Effort:** 2-3 hours
98
+ **Impact:** Complete rewrite of payment logic
99
+
100
+ **Steps:**
101
+ 1. ✅ Import ALL commands from lib/commands.js
102
+ 2. ✅ Refactor command-router.js:
103
+ - Remove PAYMENT_GATED_COMMANDS array
104
+ - Make ALL commands payment-gated
105
+ - Update routing logic
106
+ 3. ✅ Add banner to index.js
107
+ 4. ✅ Update payment.js:
108
+ - Format notes for all commands: "bgit-status", "bgit-log", etc.
109
+ - Adjust payment amounts (all 0.001 BSV)
110
+ 5. ✅ Update index.js:
111
+ - Require auth for ALL git commands
112
+ - Show banner on every run
113
+ 6. ✅ Test every command type
114
+ 7. ✅ Update documentation
115
+
116
+ **Pros:**
117
+ - Matches original vision
118
+ - Complete on-chain history
119
+ - Consistent payment model
120
+
121
+ **Cons:**
122
+ - Users pay for `git status` (terrible UX)
123
+ - High cost for developers ($10-50/day)
124
+ - Adoption will be near-zero
125
+ - Needs deep pockets for testing
126
+
127
+ ---
128
+
129
+ ### Option C: Configurable Hybrid (Best of Both)
130
+ **Effort:** 4-5 hours
131
+ **Impact:** Flexible system that satisfies everyone
132
+
133
+ **Steps:**
134
+ 1. ✅ Add configuration system
135
+ ```javascript
136
+ // lib/config.js
137
+ const PAYMENT_MODES = {
138
+ minimal: ['commit', 'push'], // Default
139
+ standard: ['commit', 'push', 'merge', 'rebase'],
140
+ universal: [...commands] // All 155
141
+ };
142
+ ```
143
+
144
+ 2. ✅ Add CLI commands:
145
+ ```bash
146
+ bgit config payment-mode minimal # Default (current)
147
+ bgit config payment-mode universal # Pay for everything
148
+ bgit config payment-mode custom # User picks commands
149
+ ```
150
+
151
+ 3. ✅ Refactor command-router.js:
152
+ ```javascript
153
+ function isPaymentGated(command) {
154
+ const mode = loadPaymentMode(); // From config
155
+ const gatedCommands = PAYMENT_MODES[mode];
156
+ return gatedCommands.includes(command);
157
+ }
158
+ ```
159
+
160
+ 4. ✅ Add banner to index.js
161
+ 5. ✅ Update documentation with all modes
162
+ 6. ✅ Add in-app upgrade prompts:
163
+ ```
164
+ 💡 Tip: Enable full history mode for complete on-chain tracking
165
+ Run: bgit config payment-mode universal
166
+ ```
167
+
168
+ **Pros:**
169
+ - Flexible for different use cases
170
+ - Default is usable (minimal)
171
+ - Power users can go universal
172
+ - Revenue potential for both
173
+ - Future-proof
174
+
175
+ **Cons:**
176
+ - More complex
177
+ - More code to maintain
178
+ - More testing required
179
+
180
+ ---
181
+
182
+ ## Detailed Implementation: Option A (Quick Ship)
183
+
184
+ ### Step 1: Add Banner (5 minutes)
185
+
186
+ **File:** `index.js`
187
+
188
+ ```javascript
189
+ const chalk = require('chalk');
190
+ const showBanner = require('./lib/banner'); // ADD THIS
191
+ const { ensureAuthenticated, loginCommand, logoutCommand, statusCommand } = require('./lib/auth');
192
+ const { routeCommand, needsAuthentication } = require('./lib/command-router');
193
+
194
+ async function main() {
195
+ try {
196
+ const args = process.argv.slice(2);
197
+
198
+ // Show banner for git commands (not auth subcommands)
199
+ if (args.length > 0 && args[0] !== 'auth') {
200
+ showBanner(); // ADD THIS
201
+ }
202
+
203
+ // ... rest of main()
204
+ }
205
+ }
206
+ ```
207
+
208
+ ### Step 2: Document Payment Philosophy (15 minutes)
209
+
210
+ **File:** `README.md` (create or update)
211
+
212
+ ```markdown
213
+ ## Payment Model
214
+
215
+ bgit uses a **minimal payment model** designed for usability:
216
+
217
+ ### Free Commands (No Payment)
218
+ All read-only git operations are FREE:
219
+ - `bgit status` - Check working tree
220
+ - `bgit log` - View commit history
221
+ - `bgit diff` - See changes
222
+ - `bgit show` - Inspect commits
223
+ - `bgit branch` - List branches
224
+ - ... and all other read operations
225
+
226
+ ### Paid Commands (0.001 BSV each)
227
+ Only "publishing" operations require payment:
228
+ - `bgit commit` - Timestamp commit hash on BitcoinSV
229
+ - `bgit push` - Payment gatekeeper before push
230
+
231
+ **Why this model?**
232
+ - Developers run status/log hundreds of times per day
233
+ - Paying for reads would cost $10-50/day (adoption killer)
234
+ - Commits/pushes are "publishing" events worth timestamping
235
+ - Minimal friction = higher adoption
236
+
237
+ ### Future: Universal Mode (Coming Soon)
238
+ For users who want complete on-chain history:
239
+ ```bash
240
+ bgit config payment-mode universal
241
+ ```
242
+ This will enable payments for ALL 155 git commands.
243
+ ```
244
+
245
+ ### Step 3: Add Config Placeholder (30 minutes)
246
+
247
+ **File:** `lib/config.js` (add to existing file)
248
+
249
+ ```javascript
250
+ // Add after existing functions
251
+
252
+ /**
253
+ * Payment mode configuration
254
+ */
255
+ const PAYMENT_MODES = {
256
+ minimal: ['commit', 'push'],
257
+ universal: require('./commands') // All 155 commands
258
+ };
259
+
260
+ /**
261
+ * Get current payment mode
262
+ * @returns {string} Payment mode ('minimal' or 'universal')
263
+ */
264
+ function getPaymentMode() {
265
+ const configPath = getConfigPath();
266
+ if (!fs.existsSync(configPath)) return 'minimal'; // Default
267
+
268
+ try {
269
+ const config = JSON.parse(fs.readFileSync(configPath, 'utf8'));
270
+ return config.paymentMode || 'minimal';
271
+ } catch (error) {
272
+ return 'minimal';
273
+ }
274
+ }
275
+
276
+ /**
277
+ * Set payment mode
278
+ * @param {string} mode - 'minimal' or 'universal'
279
+ */
280
+ function setPaymentMode(mode) {
281
+ if (!PAYMENT_MODES[mode]) {
282
+ throw new Error(`Invalid payment mode: ${mode}. Use 'minimal' or 'universal'`);
283
+ }
284
+
285
+ ensureConfigDir();
286
+ const configPath = getConfigPath();
287
+
288
+ let config = {};
289
+ if (fs.existsSync(configPath)) {
290
+ config = JSON.parse(fs.readFileSync(configPath, 'utf8'));
291
+ }
292
+
293
+ config.paymentMode = mode;
294
+ fs.writeFileSync(configPath, JSON.stringify(config, null, 2), { mode: FILE_PERMISSIONS });
295
+ console.log(`✓ Payment mode set to: ${mode}`);
296
+ }
297
+
298
+ /**
299
+ * Get list of payment-gated commands for current mode
300
+ * @returns {string[]} Array of command names
301
+ */
302
+ function getPaymentGatedCommands() {
303
+ const mode = getPaymentMode();
304
+ return PAYMENT_MODES[mode];
305
+ }
306
+
307
+ module.exports = {
308
+ // ... existing exports
309
+ getPaymentMode,
310
+ setPaymentMode,
311
+ getPaymentGatedCommands,
312
+ PAYMENT_MODES
313
+ };
314
+ ```
315
+
316
+ **File:** `lib/command-router.js` (update)
317
+
318
+ ```javascript
319
+ const { getPaymentGatedCommands } = require('./config');
320
+
321
+ // OLD:
322
+ // const PAYMENT_GATED_COMMANDS = ['commit', 'push'];
323
+
324
+ // NEW:
325
+ function isPaymentGated(command) {
326
+ const gatedCommands = getPaymentGatedCommands();
327
+ return gatedCommands.includes(command);
328
+ }
329
+
330
+ // Rest stays the same
331
+ ```
332
+
333
+ ### Step 4: Add Config Command (10 minutes)
334
+
335
+ **File:** `index.js` (update auth handler)
336
+
337
+ ```javascript
338
+ // Handle special 'auth' and 'config' commands
339
+ if (command === 'auth') {
340
+ // ... existing auth logic
341
+ } else if (command === 'config') {
342
+ // NEW: Config command
343
+ if (subcommand === 'payment-mode') {
344
+ const mode = args[2]; // 'minimal' or 'universal'
345
+ if (!mode) {
346
+ const current = getPaymentMode();
347
+ console.log(`Current payment mode: ${current}`);
348
+ console.log('\nAvailable modes:');
349
+ console.log(' minimal - Only commit/push (default)');
350
+ console.log(' universal - All 155 git commands');
351
+ console.log('\nUsage: bgit config payment-mode <mode>');
352
+ process.exit(0);
353
+ }
354
+ try {
355
+ setPaymentMode(mode);
356
+ console.log(`✓ Payment mode updated to: ${mode}`);
357
+ console.log('This will take effect on next command.');
358
+ process.exit(0);
359
+ } catch (error) {
360
+ console.error(chalk.red(error.message));
361
+ process.exit(1);
362
+ }
363
+ }
364
+ }
365
+ ```
366
+
367
+ ---
368
+
369
+ ## Detailed Implementation: Option B (Universal Payment)
370
+
371
+ ### Step 1: Update command-router.js
372
+
373
+ ```javascript
374
+ const commands = require('./commands');
375
+
376
+ // OLD:
377
+ // const PAYMENT_GATED_COMMANDS = ['commit', 'push'];
378
+
379
+ // NEW: All commands are payment-gated
380
+ const PAYMENT_GATED_COMMANDS = commands;
381
+
382
+ function isPaymentGated(command) {
383
+ return PAYMENT_GATED_COMMANDS.includes(command);
384
+ }
385
+
386
+ // Update executeGitCommand to add payment for all
387
+ async function executeGitCommand(args, authToken) {
388
+ const command = args[0];
389
+
390
+ // If command is payment-gated (all of them now)
391
+ if (isPaymentGated(command)) {
392
+ console.log(chalk.blue(`💰 Payment required for git ${command}...`));
393
+
394
+ try {
395
+ await executePayment(
396
+ 0.001,
397
+ `bgit-${command}`,
398
+ authToken
399
+ );
400
+ console.log(chalk.green('✓ Payment successful!\n'));
401
+ } catch (error) {
402
+ console.error(chalk.red(`\n❌ Payment failed: ${error.message}`));
403
+ console.error(chalk.red('Command cancelled.\n'));
404
+ return 1;
405
+ }
406
+ }
407
+
408
+ // Execute git command
409
+ return new Promise((resolve) => {
410
+ const gitProcess = spawn('git', args, { stdio: 'inherit' });
411
+ gitProcess.on('close', (code) => resolve(code));
412
+ gitProcess.on('error', (error) => {
413
+ console.error(chalk.red(`Failed to execute git: ${error.message}`));
414
+ resolve(1);
415
+ });
416
+ });
417
+ }
418
+ ```
419
+
420
+ ### Step 2: Update index.js
421
+
422
+ ```javascript
423
+ const showBanner = require('./lib/banner');
424
+
425
+ async function main() {
426
+ try {
427
+ const args = process.argv.slice(2);
428
+
429
+ // Show banner for all commands
430
+ if (args.length > 0 && args[0] !== 'auth') {
431
+ showBanner();
432
+ }
433
+
434
+ // ... existing auth command handling
435
+
436
+ // For ALL git commands, require authentication
437
+ let authToken = null;
438
+ if (args.length > 0 && args[0] !== 'auth') {
439
+ authToken = await ensureAuthenticated();
440
+ }
441
+
442
+ // Route command
443
+ const exitCode = await routeCommand(args, authToken);
444
+ process.exit(exitCode);
445
+ }
446
+ }
447
+ ```
448
+
449
+ ---
450
+
451
+ ## Testing Plan
452
+
453
+ ### For Option A (Minimal Model + Banner)
454
+
455
+ ```bash
456
+ # Test 1: Banner shows on git commands
457
+ ./index.js status
458
+ # Expected: Banner + git status output (no payment)
459
+
460
+ # Test 2: Banner doesn't show on auth commands
461
+ ./index.js auth status
462
+ # Expected: No banner, just auth status
463
+
464
+ # Test 3: Config commands work
465
+ ./index.js config payment-mode
466
+ # Expected: Shows current mode (minimal)
467
+
468
+ ./index.js config payment-mode universal
469
+ # Expected: Changes to universal mode
470
+
471
+ # Test 4: Universal mode works
472
+ ./index.js config payment-mode universal
473
+ ./index.js status
474
+ # Expected: Payment required for status
475
+
476
+ ./index.js config payment-mode minimal
477
+ ./index.js status
478
+ # Expected: No payment for status
479
+ ```
480
+
481
+ ### For Option B (Universal Payment)
482
+
483
+ ```bash
484
+ # Test 1: All commands require payment
485
+ ./index.js status
486
+ # Expected: Banner + "Payment required" + git status
487
+
488
+ ./index.js log
489
+ # Expected: Banner + "Payment required" + git log
490
+
491
+ ./index.js diff
492
+ # Expected: Banner + "Payment required" + git diff
493
+
494
+ # Test 2: Verify payments on HandCash
495
+ # Check transaction history
496
+ # Should see: bgit-status, bgit-log, bgit-diff
497
+
498
+ # Test 3: Cost calculation
499
+ # Run 20 commands
500
+ # Expected cost: 20 × 0.001 BSV = 0.02 BSV
501
+ ```
502
+
503
+ ---
504
+
505
+ ## Recommendation & Decision Matrix
506
+
507
+ | Factor | Option A (Minimal) | Option B (Universal) | Option C (Hybrid) |
508
+ |--------|-------------------|---------------------|-------------------|
509
+ | **Time to Ship** | 1 hour ✅ | 2-3 hours | 4-5 hours |
510
+ | **User Adoption** | High ✅ | Very Low ❌ | Medium-High ✅ |
511
+ | **Revenue Potential** | Medium | High | High ✅ |
512
+ | **Complexity** | Low ✅ | Low ✅ | Medium |
513
+ | **Future-Proof** | Medium | Low ❌ | High ✅ |
514
+ | **Matches Vision** | Partial | Yes ✅ | Yes ✅ |
515
+ | **Testing Burden** | Low ✅ | Medium | High |
516
+
517
+ ### My Recommendation: **Option A First, Then Option C**
518
+
519
+ **Phase 1 (Today - 1 hour):**
520
+ - Ship Option A (minimal + banner)
521
+ - Get to v2.0 release
522
+ - Start gathering user feedback
523
+
524
+ **Phase 2 (Next Week - 4 hours):**
525
+ - Implement Option C (hybrid model)
526
+ - Release v2.1 with configurable modes
527
+ - Market to different user segments
528
+
529
+ **Rationale:**
530
+ - Option A ships today, validates OAuth
531
+ - Option C addresses both visions
532
+ - Incremental approach reduces risk
533
+ - User feedback guides v2.1 features
534
+
535
+ ---
536
+
537
+ ## Questions for User (b0ase)
538
+
539
+ Before proceeding, I need clarification:
540
+
541
+ 1. **Philosophy:**
542
+ - Do you REALLY want users to pay for `git status`?
543
+ - Is the "universal payment" a hard requirement or a nice-to-have?
544
+
545
+ 2. **Use Case:**
546
+ - Who is the target user? (Yourself? Other devs? Enterprises?)
547
+ - How many git commands do you run per day? (10? 100? 500?)
548
+
549
+ 3. **Pricing:**
550
+ - At 0.001 BSV per command, 100 commands/day = 0.1 BSV/day = ~$5/day
551
+ - Is this acceptable to you? To other users?
552
+
553
+ 4. **Priority:**
554
+ - Ship v2.0 today with minimal model? (Get it working)
555
+ - OR delay release for universal payment? (Match original vision)
556
+
557
+ 5. **Banner:**
558
+ - Should banner show on EVERY command? (Gets annoying)
559
+ - OR only on first command per session?
560
+ - OR only on paid commands?
561
+
562
+ ---
563
+
564
+ ## My Suggested Next Steps
565
+
566
+ **Immediate (Next 30 minutes):**
567
+ 1. Wait for user decision on payment model
568
+ 2. If minimal → implement Option A (1 hour)
569
+ 3. If universal → implement Option B (2-3 hours)
570
+ 4. If undecided → implement Option A, plan Option C
571
+
572
+ **Short-term (Next 2 days):**
573
+ 1. Get HandCash credentials
574
+ 2. Test OAuth flow
575
+ 3. Fix dependency issues (chalk, open, express)
576
+ 4. Ship v2.0
577
+
578
+ **Medium-term (Next week):**
579
+ 1. Gather user feedback
580
+ 2. Implement configurable payment modes (Option C)
581
+ 3. Add analytics to track usage patterns
582
+ 4. Release v2.1
583
+
584
+ ---
585
+
586
+ ## Conclusion
587
+
588
+ **Current State:**
589
+ - ✅ Production OAuth implemented
590
+ - ✅ Secure token storage
591
+ - ✅ Professional error handling
592
+ - ⚠️ Only commit/push are paid (deviates from vision)
593
+ - ⚠️ No banner (missing aesthetics)
594
+
595
+ **Gemini's Vision:**
596
+ - 🎯 ALL commands should be paid
597
+ - 🎯 Beautiful ASCII banner
598
+ - 🎯 Complete on-chain history
599
+
600
+ **My Recommendation:**
601
+ - 🚀 **Ship Option A today** (minimal + banner)
602
+ - 🔄 **Gather feedback**
603
+ - 📈 **Iterate to Option C** (configurable hybrid)
604
+
605
+ **Why?**
606
+ - Ships immediately
607
+ - Validates OAuth
608
+ - Respects usability
609
+ - Provides upgrade path
610
+ - De-risks the product
611
+
612
+ **The Question:**
613
+ Should we prioritize **adoption** (minimal model) or **vision** (universal payment)?
614
+
615
+ My vote: **Adoption first, vision second.** But it's your call.
616
+
617
+ ---
618
+
619
+ **End of Plan**
620
+
621
+ Awaiting user decision on payment model before proceeding with implementation.