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.
- package/.claude/settings.local.json +19 -0
- package/.env.local +2 -0
- package/CLAUDE_PLAN.md +621 -0
- package/IMPLEMENTATION_REPORT.md +1690 -0
- package/README.md +277 -0
- package/UNIVERSAL_PLAN.md +31 -0
- package/handcash.js +36 -0
- package/index.js +158 -0
- package/index.js.backup +69 -0
- package/lib/auth.js +273 -0
- package/lib/banner.js +17 -0
- package/lib/command-router.js +191 -0
- package/lib/commands.js +157 -0
- package/lib/config.js +438 -0
- package/lib/constants.js +57 -0
- package/lib/crypto.js +164 -0
- package/lib/oauth-server.js +300 -0
- package/lib/payment.js +287 -0
- package/lib/token-manager.js +179 -0
- package/package.json +45 -0
package/README.md
ADDED
|
@@ -0,0 +1,277 @@
|
|
|
1
|
+
# bgit - Bitcoin-Enabled Git Wrapper
|
|
2
|
+
|
|
3
|
+
**Version:** 2.0.0
|
|
4
|
+
**Timestamp your commits on BitcoinSV blockchain using HandCash OAuth**
|
|
5
|
+
|
|
6
|
+
```
|
|
7
|
+
██████╗ ██████╗ ██╗████████╗
|
|
8
|
+
██╔══██╗ ██╔════╝ ██║╚══██╔══╝
|
|
9
|
+
██████╔╝ ██║ ███╗ ██║ ██║
|
|
10
|
+
██╔══██╗ ██║ ██║ ██║ ██║
|
|
11
|
+
██████╔╝ ██╗ ╚██████╔╝ ██║ ██║
|
|
12
|
+
╚═════╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝
|
|
13
|
+
|
|
14
|
+
> Bitcoin-Native Git Wrapper
|
|
15
|
+
> Pay-to-Operate • Universal History
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
## What is bgit?
|
|
21
|
+
|
|
22
|
+
bgit is a Git wrapper that timestamps your commits on the **BitcoinSV blockchain** using **HandCash** micropayments. Every commit you make gets a cryptographically provable timestamp on-chain, creating an immutable record of your code history.
|
|
23
|
+
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
## Quick Start
|
|
27
|
+
|
|
28
|
+
### Installation
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
# Install globally
|
|
32
|
+
npm install -g bgit-cli
|
|
33
|
+
|
|
34
|
+
# Verify installation
|
|
35
|
+
bgit --version
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### First-Time Setup
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
# Authenticate with HandCash (opens browser)
|
|
42
|
+
bgit auth login
|
|
43
|
+
|
|
44
|
+
# Check authentication status
|
|
45
|
+
bgit auth status
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### Use It Like Git
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
# Free commands (no payment)
|
|
52
|
+
bgit status
|
|
53
|
+
bgit log
|
|
54
|
+
bgit diff
|
|
55
|
+
|
|
56
|
+
# Paid commands (0.001 BSV each)
|
|
57
|
+
bgit commit -m "Initial commit" # ← Timestamps commit hash on-chain
|
|
58
|
+
bgit push origin main # ← Payment required before push
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
---
|
|
62
|
+
|
|
63
|
+
## Payment Model
|
|
64
|
+
|
|
65
|
+
bgit uses a **minimal payment model** for maximum usability:
|
|
66
|
+
|
|
67
|
+
### 🆓 Free Commands
|
|
68
|
+
|
|
69
|
+
All **read-only** operations are FREE:
|
|
70
|
+
- `bgit status` - Check working tree
|
|
71
|
+
- `bgit log` - View commit history
|
|
72
|
+
- `bgit diff` - See changes
|
|
73
|
+
- `bgit show` - Inspect commits
|
|
74
|
+
- `bgit branch` - List branches
|
|
75
|
+
- ... and 150+ other read commands
|
|
76
|
+
|
|
77
|
+
### 💰 Paid Commands (0.001 BSV each)
|
|
78
|
+
|
|
79
|
+
Only **"publishing"** operations require payment:
|
|
80
|
+
- `bgit commit` - Create commit + timestamp hash on-chain
|
|
81
|
+
- `bgit push` - Payment gatekeeper before push
|
|
82
|
+
|
|
83
|
+
**Why this model?** Developers run status/log hundreds of times per day. Paying for reads would cost $10-50/day. Commits/pushes are "publishing" events worth timestamping.
|
|
84
|
+
|
|
85
|
+
### 🔧 Universal Mode (Optional)
|
|
86
|
+
|
|
87
|
+
Enable payment for ALL 155 git commands:
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
# Enable universal mode
|
|
91
|
+
bgit config payment-mode universal
|
|
92
|
+
|
|
93
|
+
# Now EVERY command requires payment
|
|
94
|
+
bgit status # ← Costs 0.001 BSV
|
|
95
|
+
bgit log # ← Costs 0.001 BSV
|
|
96
|
+
|
|
97
|
+
# Switch back to minimal
|
|
98
|
+
bgit config payment-mode minimal
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
---
|
|
102
|
+
|
|
103
|
+
## Authentication
|
|
104
|
+
|
|
105
|
+
### OAuth Flow
|
|
106
|
+
|
|
107
|
+
1. Run `bgit auth login`
|
|
108
|
+
2. Browser opens to HandCash authorization page
|
|
109
|
+
3. Click "Authorize" to connect your wallet
|
|
110
|
+
4. Token is encrypted and saved locally
|
|
111
|
+
5. All future commands use saved token
|
|
112
|
+
|
|
113
|
+
### Auth Commands
|
|
114
|
+
|
|
115
|
+
```bash
|
|
116
|
+
bgit auth login # Authenticate with HandCash
|
|
117
|
+
bgit auth status # Show auth status + wallet balance
|
|
118
|
+
bgit auth logout # Delete credentials
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
### Security Features
|
|
122
|
+
|
|
123
|
+
- **AES-256-GCM Encryption** - Bank-grade token encryption
|
|
124
|
+
- **Machine-Specific Key** - Token only works on your machine
|
|
125
|
+
- **File Permissions** - 600 (config), 700 (directory)
|
|
126
|
+
- **No Token Logging** - Tokens never appear in logs
|
|
127
|
+
|
|
128
|
+
---
|
|
129
|
+
|
|
130
|
+
## How It Works
|
|
131
|
+
|
|
132
|
+
### Commit Flow
|
|
133
|
+
|
|
134
|
+
```bash
|
|
135
|
+
bgit commit -m "Add feature"
|
|
136
|
+
|
|
137
|
+
# What happens:
|
|
138
|
+
# 1. Execute git commit FIRST
|
|
139
|
+
# 2. Capture commit hash (abc123...)
|
|
140
|
+
# 3. Send 0.001 BSV payment to $b0ase
|
|
141
|
+
# 4. Payment note: "bgit commit: abc123..."
|
|
142
|
+
# 5. ✅ Commit hash timestamped on BitcoinSV!
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
### Money Flow
|
|
146
|
+
|
|
147
|
+
```
|
|
148
|
+
Your HandCash Wallet
|
|
149
|
+
↓
|
|
150
|
+
0.001 BSV (developer premium) + 0.00001 BSV (network fee)
|
|
151
|
+
↓
|
|
152
|
+
├──→ 0.001 BSV → $b0ase (developer)
|
|
153
|
+
└──→ 0.00001 BSV → BSV miners
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
---
|
|
157
|
+
|
|
158
|
+
## Configuration
|
|
159
|
+
|
|
160
|
+
```bash
|
|
161
|
+
# Show current payment mode
|
|
162
|
+
bgit config payment-mode
|
|
163
|
+
|
|
164
|
+
# Set to minimal (default: commit/push only)
|
|
165
|
+
bgit config payment-mode minimal
|
|
166
|
+
|
|
167
|
+
# Set to universal (all 155 commands)
|
|
168
|
+
bgit config payment-mode universal
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
**Config Location:** `~/.bgit/config.json`
|
|
172
|
+
|
|
173
|
+
---
|
|
174
|
+
|
|
175
|
+
## Examples
|
|
176
|
+
|
|
177
|
+
### Daily Workflow
|
|
178
|
+
|
|
179
|
+
```bash
|
|
180
|
+
# Check status (free)
|
|
181
|
+
bgit status
|
|
182
|
+
|
|
183
|
+
# Work on code
|
|
184
|
+
bgit checkout -b new-feature
|
|
185
|
+
bgit add src/
|
|
186
|
+
|
|
187
|
+
# Commit (paid: 0.001 BSV)
|
|
188
|
+
bgit commit -m "Implement feature"
|
|
189
|
+
|
|
190
|
+
# Push (paid: 0.001 BSV)
|
|
191
|
+
bgit push origin new-feature
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
**Total cost:** 0.002 BSV (~$0.10)
|
|
195
|
+
|
|
196
|
+
---
|
|
197
|
+
|
|
198
|
+
## FAQ
|
|
199
|
+
|
|
200
|
+
**Q: Why only commit/push by default?**
|
|
201
|
+
A: Usability. Developers run status/log 100+ times/day. Charging for reads kills adoption. Commits/pushes are publishing events worth timestamping.
|
|
202
|
+
|
|
203
|
+
**Q: How much does it cost?**
|
|
204
|
+
A: Minimal mode: ~$0.50-1/day for typical developer (10-20 commits). Universal mode: $2.50-25/day depending on usage.
|
|
205
|
+
|
|
206
|
+
**Q: Where do payments go?**
|
|
207
|
+
A: Developer wallet ($b0ase). This is revenue for maintaining bgit.
|
|
208
|
+
|
|
209
|
+
**Q: Is my token secure?**
|
|
210
|
+
A: Yes. AES-256-GCM encryption with machine-specific key. File permissions 600.
|
|
211
|
+
|
|
212
|
+
**Q: What if payment fails?**
|
|
213
|
+
A: Commits succeed, payment failure is warned. Pushes are blocked until payment succeeds.
|
|
214
|
+
|
|
215
|
+
---
|
|
216
|
+
|
|
217
|
+
## Requirements
|
|
218
|
+
|
|
219
|
+
- **Node.js:** >= 16.0.0
|
|
220
|
+
- **Git:** Any version
|
|
221
|
+
- **HandCash Account:** https://handcash.io
|
|
222
|
+
- **BSV Funds:** At least 0.01 BSV (~$0.50)
|
|
223
|
+
|
|
224
|
+
---
|
|
225
|
+
|
|
226
|
+
## Troubleshooting
|
|
227
|
+
|
|
228
|
+
**"No auth token found"**
|
|
229
|
+
```bash
|
|
230
|
+
bgit auth login
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
**"Insufficient balance"**
|
|
234
|
+
Add funds at https://handcash.io
|
|
235
|
+
|
|
236
|
+
**"Config corrupted"**
|
|
237
|
+
```bash
|
|
238
|
+
rm -rf ~/.bgit/
|
|
239
|
+
bgit auth login
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
---
|
|
243
|
+
|
|
244
|
+
## Development
|
|
245
|
+
|
|
246
|
+
```bash
|
|
247
|
+
# Clone
|
|
248
|
+
git clone https://github.com/yourusername/bgit.git
|
|
249
|
+
cd bgit
|
|
250
|
+
|
|
251
|
+
# Install
|
|
252
|
+
npm install
|
|
253
|
+
|
|
254
|
+
# Test
|
|
255
|
+
./index.js auth login
|
|
256
|
+
./index.js commit -m "test"
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
---
|
|
260
|
+
|
|
261
|
+
## License
|
|
262
|
+
|
|
263
|
+
ISC
|
|
264
|
+
|
|
265
|
+
---
|
|
266
|
+
|
|
267
|
+
## Links
|
|
268
|
+
|
|
269
|
+
- **GitHub:** https://github.com/yourusername/bgit
|
|
270
|
+
- **HandCash:** https://handcash.io
|
|
271
|
+
- **Issues:** https://github.com/yourusername/bgit/issues
|
|
272
|
+
|
|
273
|
+
---
|
|
274
|
+
|
|
275
|
+
**Made with ❤️ for the Bitcoin developer community**
|
|
276
|
+
|
|
277
|
+
Timestamp your code. Prove your work. Build on BSV.
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# Plan: Universal bgit Integration
|
|
2
|
+
|
|
3
|
+
The current implementation by Claude provides a robust OAuth foundation but lacks two critical features requested by the user:
|
|
4
|
+
1. **Universal History**: Currently, only `commit` and `push` are paid. We need *all* 155 commands to be paid.
|
|
5
|
+
2. **Aesthetics**: The ASCII Banner is missing from the entry point.
|
|
6
|
+
|
|
7
|
+
## Execution Steps
|
|
8
|
+
|
|
9
|
+
### 1. Refactor `lib/command-router.js`
|
|
10
|
+
**Current Logic:**
|
|
11
|
+
```javascript
|
|
12
|
+
const PAYMENT_GATED_COMMANDS = ['commit', 'push'];
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
**New Logic:**
|
|
16
|
+
- Import `commands` from `lib/commands.js`.
|
|
17
|
+
- Treat **all** of them as payment-gated.
|
|
18
|
+
- Unified flow: `ensureAuth` -> `pay` -> `execute`.
|
|
19
|
+
|
|
20
|
+
### 2. Restore Banner in `index.js`
|
|
21
|
+
- Import `showBanner` from `lib/banner.js`.
|
|
22
|
+
- Call it at the start of `main()` (if no specific subcommands like `json` output are requested, to avoid breaking scripts).
|
|
23
|
+
|
|
24
|
+
### 3. Verify
|
|
25
|
+
- Run `node index.js status`.
|
|
26
|
+
- Expectation:
|
|
27
|
+
- Banner shows.
|
|
28
|
+
- "Opening browser..." (if not authed) OR "Paying..." (if authed).
|
|
29
|
+
- `git status` output.
|
|
30
|
+
|
|
31
|
+
This aligns the robust "Claude" architecture with the "b0ase" Vision.
|
package/handcash.js
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
const { HandCashConnect } = require('@handcash/handcash-connect');
|
|
2
|
+
|
|
3
|
+
async function pay(note) {
|
|
4
|
+
const appId = process.env.HANDCASH_APP_ID;
|
|
5
|
+
const appSecret = process.env.HANDCASH_APP_SECRET;
|
|
6
|
+
const authToken = process.env.HANDCASH_AUTH_TOKEN;
|
|
7
|
+
const treasury = process.env.BGIT_TREASURY_HANDLE || '$b0ase';
|
|
8
|
+
|
|
9
|
+
if (!appId || !appSecret || !authToken) {
|
|
10
|
+
console.error('Missing HandCash Credentials (APP_ID, APP_SECRET, or AUTH_TOKEN)');
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
try {
|
|
15
|
+
const handCashConnect = new HandCashConnect({
|
|
16
|
+
appId: appId,
|
|
17
|
+
appSecret: appSecret,
|
|
18
|
+
});
|
|
19
|
+
const account = handCashConnect.getAccountFromAuthToken(authToken);
|
|
20
|
+
|
|
21
|
+
const paymentParameters = {
|
|
22
|
+
description: note || 'bGit Commit',
|
|
23
|
+
payments: [
|
|
24
|
+
{ destination: treasury, currencyCode: 'BSV', sendAmount: 0.001 }
|
|
25
|
+
]
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const result = await account.wallet.pay(paymentParameters);
|
|
29
|
+
console.log(`[bGit] Payment Sent! ID: ${result.transactionId}`);
|
|
30
|
+
if (note) console.log(`[bGit] Timestamp: ${note}`);
|
|
31
|
+
} catch (error) {
|
|
32
|
+
console.error('[bGit] Payment Failed:', error.message);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
module.exports = { pay };
|
package/index.js
ADDED
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* bgit - Bitcoin-enabled Git wrapper
|
|
5
|
+
*
|
|
6
|
+
* Usage:
|
|
7
|
+
* bgit <git-command> [args...] - Execute git command with optional payment
|
|
8
|
+
* bgit auth login - Authenticate with HandCash
|
|
9
|
+
* bgit auth logout - Log out and delete credentials
|
|
10
|
+
* bgit auth status - Show authentication status
|
|
11
|
+
*
|
|
12
|
+
* Payment-gated commands: commit, push
|
|
13
|
+
* All other git commands pass through without payment
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
const chalk = require('chalk');
|
|
17
|
+
const showBanner = require('./lib/banner');
|
|
18
|
+
const { ensureAuthenticated, loginCommand, logoutCommand, statusCommand } = require('./lib/auth');
|
|
19
|
+
const { routeCommand, needsAuthentication } = require('./lib/command-router');
|
|
20
|
+
const { getPaymentMode, setPaymentMode } = require('./lib/config');
|
|
21
|
+
|
|
22
|
+
async function main() {
|
|
23
|
+
try {
|
|
24
|
+
// Parse command-line arguments
|
|
25
|
+
const args = process.argv.slice(2);
|
|
26
|
+
|
|
27
|
+
if (args.length === 0) {
|
|
28
|
+
// No arguments - show help
|
|
29
|
+
showHelp();
|
|
30
|
+
process.exit(0);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const command = args[0];
|
|
34
|
+
const subcommand = args[1];
|
|
35
|
+
|
|
36
|
+
// Show banner for git commands (not auth/config subcommands)
|
|
37
|
+
if (command !== 'auth' && command !== 'config') {
|
|
38
|
+
showBanner();
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// Handle special 'auth' commands
|
|
42
|
+
if (command === 'auth') {
|
|
43
|
+
if (subcommand === 'login') {
|
|
44
|
+
await loginCommand();
|
|
45
|
+
process.exit(0);
|
|
46
|
+
} else if (subcommand === 'logout') {
|
|
47
|
+
await logoutCommand();
|
|
48
|
+
process.exit(0);
|
|
49
|
+
} else if (subcommand === 'status') {
|
|
50
|
+
await statusCommand();
|
|
51
|
+
process.exit(0);
|
|
52
|
+
} else {
|
|
53
|
+
console.error(chalk.red(`Unknown auth command: ${subcommand}`));
|
|
54
|
+
console.log(chalk.gray('\nAvailable auth commands:'));
|
|
55
|
+
console.log(chalk.gray(' bgit auth login - Authenticate with HandCash'));
|
|
56
|
+
console.log(chalk.gray(' bgit auth logout - Log out and delete credentials'));
|
|
57
|
+
console.log(chalk.gray(' bgit auth status - Show authentication status\n'));
|
|
58
|
+
process.exit(1);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// Handle special 'config' commands
|
|
63
|
+
if (command === 'config') {
|
|
64
|
+
if (subcommand === 'payment-mode') {
|
|
65
|
+
const mode = args[2]; // 'minimal' or 'universal'
|
|
66
|
+
|
|
67
|
+
if (!mode) {
|
|
68
|
+
// Show current mode
|
|
69
|
+
const current = getPaymentMode();
|
|
70
|
+
console.log(chalk.blue.bold('\n💰 Payment Mode Configuration\n'));
|
|
71
|
+
console.log(`Current mode: ${chalk.cyan(current)}\n`);
|
|
72
|
+
console.log(chalk.bold('Available modes:'));
|
|
73
|
+
console.log(chalk.gray(' minimal - Only commit/push require payment (default)'));
|
|
74
|
+
console.log(chalk.gray(' universal - All 155 git commands require payment\n'));
|
|
75
|
+
console.log(chalk.bold('Usage:'));
|
|
76
|
+
console.log(chalk.gray(' bgit config payment-mode <mode>\n'));
|
|
77
|
+
console.log(chalk.bold('Examples:'));
|
|
78
|
+
console.log(chalk.gray(' bgit config payment-mode minimal'));
|
|
79
|
+
console.log(chalk.gray(' bgit config payment-mode universal\n'));
|
|
80
|
+
process.exit(0);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// Set mode
|
|
84
|
+
try {
|
|
85
|
+
setPaymentMode(mode);
|
|
86
|
+
process.exit(0);
|
|
87
|
+
} catch (error) {
|
|
88
|
+
console.error(chalk.red(`\n❌ ${error.message}\n`));
|
|
89
|
+
process.exit(1);
|
|
90
|
+
}
|
|
91
|
+
} else {
|
|
92
|
+
console.error(chalk.red(`Unknown config command: ${subcommand}`));
|
|
93
|
+
console.log(chalk.gray('\nAvailable config commands:'));
|
|
94
|
+
console.log(chalk.gray(' bgit config payment-mode - Configure payment mode\n'));
|
|
95
|
+
process.exit(1);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// For git commands, check if authentication is needed
|
|
100
|
+
let authToken = null;
|
|
101
|
+
|
|
102
|
+
if (needsAuthentication(command)) {
|
|
103
|
+
// Payment-gated command - ensure authenticated
|
|
104
|
+
authToken = await ensureAuthenticated();
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// Route to appropriate git command handler
|
|
108
|
+
const exitCode = await routeCommand(args, authToken);
|
|
109
|
+
process.exit(exitCode);
|
|
110
|
+
} catch (error) {
|
|
111
|
+
console.error(chalk.red(`\n❌ Error: ${error.message}\n`));
|
|
112
|
+
|
|
113
|
+
// Show helpful hints for common errors
|
|
114
|
+
if (error.message.includes('authentication') || error.message.includes('token')) {
|
|
115
|
+
console.log(chalk.gray('Try running: bgit auth login\n'));
|
|
116
|
+
} else if (error.message.includes('payment') || error.message.includes('balance')) {
|
|
117
|
+
console.log(chalk.gray('Add funds to your HandCash wallet: https://handcash.io\n'));
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
process.exit(1);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Show help message
|
|
126
|
+
*/
|
|
127
|
+
function showHelp() {
|
|
128
|
+
console.log(chalk.blue.bold('\nbgit - Bitcoin-enabled Git wrapper\n'));
|
|
129
|
+
console.log(chalk.bold('Usage:'));
|
|
130
|
+
console.log(' bgit <git-command> [args...] Execute git command with optional payment');
|
|
131
|
+
console.log(' bgit auth <subcommand> Manage authentication\n');
|
|
132
|
+
|
|
133
|
+
console.log(chalk.bold('Authentication Commands:'));
|
|
134
|
+
console.log(' bgit auth login Authenticate with HandCash');
|
|
135
|
+
console.log(' bgit auth logout Log out and delete credentials');
|
|
136
|
+
console.log(' bgit auth status Show authentication status\n');
|
|
137
|
+
|
|
138
|
+
console.log(chalk.bold('Payment-Gated Commands:'));
|
|
139
|
+
console.log(' bgit commit Git commit + on-chain timestamp (0.001 BSV)');
|
|
140
|
+
console.log(' bgit push Git push + payment (0.001 BSV)\n');
|
|
141
|
+
|
|
142
|
+
console.log(chalk.bold('Pass-Through Commands:'));
|
|
143
|
+
console.log(' All other git commands work without payment (status, log, diff, etc.)\n');
|
|
144
|
+
|
|
145
|
+
console.log(chalk.bold('Examples:'));
|
|
146
|
+
console.log(chalk.gray(' bgit auth login # First-time setup'));
|
|
147
|
+
console.log(chalk.gray(' bgit commit -m "Initial commit" # Commit + timestamp'));
|
|
148
|
+
console.log(chalk.gray(' bgit push origin main # Push with payment'));
|
|
149
|
+
console.log(chalk.gray(' bgit status # Free, no payment'));
|
|
150
|
+
console.log(chalk.gray(' bgit log # Free, no payment\n'));
|
|
151
|
+
|
|
152
|
+
console.log(chalk.bold('Learn More:'));
|
|
153
|
+
console.log(' GitHub: https://github.com/yourusername/bgit');
|
|
154
|
+
console.log(' HandCash: https://handcash.io\n');
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
// Run main function
|
|
158
|
+
main();
|
package/index.js.backup
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const { program } = require('commander');
|
|
4
|
+
const { pay } = require('./handcash');
|
|
5
|
+
const { exec } = require('child_process');
|
|
6
|
+
const commands = require('./lib/commands');
|
|
7
|
+
const showBanner = require('./lib/banner');
|
|
8
|
+
|
|
9
|
+
program
|
|
10
|
+
.name('bgit')
|
|
11
|
+
.description('Bitcoin Git - Pay to Operate')
|
|
12
|
+
.version('0.0.1');
|
|
13
|
+
|
|
14
|
+
// Show banner if running without specific command (just 'bgit')
|
|
15
|
+
if (process.argv.length <= 2) {
|
|
16
|
+
showBanner();
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// Universal Command Handler
|
|
20
|
+
const handleCommand = (cmd, args) => {
|
|
21
|
+
// Construct git command
|
|
22
|
+
const gitCmd = `git ${cmd} ${args.join(' ')}`;
|
|
23
|
+
|
|
24
|
+
// Execute Git
|
|
25
|
+
exec(gitCmd, (error, stdout, stderr) => {
|
|
26
|
+
if (error) {
|
|
27
|
+
console.error(`[bGit] Error: ${error.message}`);
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
if (stderr) {
|
|
31
|
+
console.error(stderr);
|
|
32
|
+
}
|
|
33
|
+
console.log(stdout);
|
|
34
|
+
|
|
35
|
+
// Pay-to-Operate for ALL commands
|
|
36
|
+
let note = `bgit-${cmd}`;
|
|
37
|
+
|
|
38
|
+
// Extract commit hash if available
|
|
39
|
+
if (cmd === 'commit') {
|
|
40
|
+
const match = stdout.match(/\[.* ([a-f0-9]+)\]/);
|
|
41
|
+
if (match) {
|
|
42
|
+
note += ` ${match[1]}`;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
pay(note).catch(err => console.error('[bGit] Payment Error:', err.message));
|
|
47
|
+
});
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
// Register all 155 commands
|
|
51
|
+
commands.forEach(cmd => {
|
|
52
|
+
program
|
|
53
|
+
.command(cmd, { isDefault: false })
|
|
54
|
+
.description(`Executes git ${cmd} and pays for usage`)
|
|
55
|
+
.allowUnknownOption()
|
|
56
|
+
.action((options, command) => {
|
|
57
|
+
// Reconstruct args
|
|
58
|
+
const args = command.args;
|
|
59
|
+
handleCommand(cmd, args);
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
// Catch-all for any args passed to known commands
|
|
64
|
+
program.on('command:*', function (operands) {
|
|
65
|
+
console.error(`error: unknown command '${operands[0]}'`);
|
|
66
|
+
process.exit(1);
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
program.parse(process.argv);
|