gent-cli 5.0.3 → 6.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/README.md CHANGED
@@ -1,306 +1,639 @@
1
1
  # Gent CLI
2
2
 
3
- ![npm](https://img.shields.io/npm/v/gent-cli)
4
- ![downloads](https://img.shields.io/npm/dw/gent-cli)
5
-
6
- > A modern, Git-like version control CLI with built-in cloud authentication and global user identity management.
7
-
8
- Gent is a lightweight version control system that feels like Git but handles user identity automatically through the cloud. No more configuring `user.name` and `user.email` for every repository.
9
-
10
- ## Highlights
11
-
12
- - **Cloud Authentication** — Login once, work everywhere. JWT-based auth with automatic token refresh.
13
- - **Git-like Experience** — Familiar commands: `init`, `add`, `commit`, `status`, `log`, `branch`, `checkout`, `merge`, `push`, `pull`, `clone`, and more.
14
- - **Zero Configuration** — `gent init` auto-detects your authenticated user profile.
15
- - **Global Identity** — Commits are automatically authored with your cloud profile.
16
- - **Content-Addressable Storage** — SHA-256 object store with zlib compression and deduplication.
17
- - **Smart Diff & Merge** — Line-level LCS diff, three-way merge with conflict detection.
18
- - **Remote Sync** — Push, pull, and clone repositories from the cloud backend.
19
- - **Secure** — Tokens stored with AES encryption in `~/.gent/auth.json`.
20
-
21
- ## Table of Contents
22
-
23
- - [Requirements](#requirements)
24
- - [Installation](#installation)
25
- - [Quickstart](#quickstart)
26
- - [Authentication](#authentication)
27
- - [Commands](#commands)
28
- - [Repository Setup](#repository-setup)
29
- - [Staging & Working Tree](#staging--working-tree)
30
- - [History](#history)
31
- - [Branching & Merging](#branching--merging)
32
- - [Remote & Sync](#remote--sync)
33
- - [Authentication Commands](#authentication-commands)
34
- - [Usage Examples](#usage-examples)
35
- - [Repository Structure](#repository-structure)
36
- - [Configuration](#configuration)
37
- - [Docs](#docs)
38
- - [Troubleshooting](#troubleshooting)
39
- - [Contributing](#contributing)
40
- - [License](#license)
3
+ Gent is a Git-like version control CLI with cloud authentication and remote sync.
4
+
5
+ Global API URL:
6
+
7
+ ```text
8
+ https://gent-api.onrender.com
9
+ ```
10
+
11
+ The CLI is configured in `src/utils/constants.js` to use that deployed API. Do not use a local API URL for normal CLI work.
41
12
 
42
13
  ## Requirements
43
14
 
44
- - Node.js >= 14
15
+ - Node.js 14 or newer
16
+ - Internet access to `https://gent-api.onrender.com`
17
+ - A Gent account, created with `gent register`
45
18
 
46
- ## Installation
19
+ ## Install
20
+
21
+ From npm:
47
22
 
48
23
  ```bash
49
24
  npm install -g gent-cli
25
+ gent --help
50
26
  ```
51
27
 
52
- Run locally without installing:
28
+ From this repository:
53
29
 
54
30
  ```bash
55
31
  cd apps/Cli
56
32
  npm install
33
+ npm link
34
+ gent --help
35
+ ```
36
+
37
+ Run without linking:
38
+
39
+ ```bash
57
40
  node src/index.js --help
58
41
  ```
59
42
 
60
- ## Quickstart
43
+ ## Full Step-by-Step Workflow
44
+
45
+ ### 1. Create an account
46
+
47
+ Interactive:
61
48
 
62
49
  ```bash
63
- # 1) Authenticate
64
- gent login
50
+ gent register
51
+ ```
65
52
 
66
- # 2) Initialize a repo
67
- gent init
53
+ Non-interactive:
68
54
 
69
- # 3) Make a first commit
70
- gent add .
71
- gent commit -m "Initial commit"
55
+ ```bash
56
+ gent register \
57
+ -e user@example.com \
58
+ -p StrongPass123! \
59
+ --password-confirm StrongPass123! \
60
+ --first-name YourFirstName \
61
+ --last-name YourLastName
72
62
  ```
73
63
 
74
- ## Authentication
64
+ After registration, the CLI stores your encrypted auth tokens in:
65
+
66
+ ```text
67
+ ~/.gent/auth.json
68
+ ```
75
69
 
76
- Gent uses a global authentication system. You only need to log in once.
70
+ ### 2. Log in
77
71
 
78
- ### Register a New Account
72
+ Interactive:
79
73
 
80
74
  ```bash
81
- gent register
75
+ gent login
82
76
  ```
83
77
 
84
- ### Login
78
+ Non-interactive:
85
79
 
86
80
  ```bash
87
- gent login
88
- # or with flags
89
- gent login -e user@example.com -p YourPassword
81
+ gent login -e user@example.com -p StrongPass123!
90
82
  ```
91
83
 
92
- ### Check Current User
84
+ ### 3. Confirm the logged-in user
93
85
 
94
86
  ```bash
95
87
  gent whoami
96
88
  ```
97
89
 
98
- ### Logout
90
+ Expected result: your email, name, account ID, joined date, and active status.
91
+
92
+ ### 4. Create a project folder
99
93
 
100
94
  ```bash
101
- gent logout
95
+ mkdir my-project
96
+ cd my-project
102
97
  ```
103
98
 
104
- ## Commands
99
+ ### 5. Initialize a Gent repository
105
100
 
106
- ### Repository Setup
101
+ ```bash
102
+ gent init
103
+ ```
104
+
105
+ This creates:
106
+
107
+ ```text
108
+ .gent/
109
+ .gentignore
110
+ ```
111
+
112
+ The `.gent` directory stores local commits, objects, branches, tags, staging data, and config.
113
+
114
+ ### 6. Create a remote repository
107
115
 
108
- | Command | Description |
109
- |---|---|
110
- | `gent init [-y]` | Initialize a new Gent repository in the current directory. Use `-y` to skip prompts. |
111
- | `gent clone <url> [directory]` | Clone a remote repository from the cloud backend. |
116
+ ```bash
117
+ gent repos --create my-project --description "My first Gent repository"
118
+ ```
112
119
 
113
- ### Staging & Working Tree
120
+ Expected output includes a remote path like:
114
121
 
115
- | Command | Description |
116
- |---|---|
117
- | `gent status [-s]` | Show the working tree status. Use `-s` for short format. |
118
- | `gent add <files...> [-A]` | Add files to the staging area. Use `-A` or `--all` to add all files. |
119
- | `gent rm <files...> [--cached]` | Remove files from the working tree and staging area. Use `--cached` to keep the file on disk. |
120
- | `gent reset [files...] [--hard <hash> \| --soft <hash>]` | Unstage files or reset HEAD to a specific commit. |
121
- | `gent diff [files...] [--staged] [--stat]` | Show changes between working tree, staging area, and commits. |
122
+ ```text
123
+ /api/repos/2/my-project
124
+ ```
122
125
 
123
- ### History
126
+ Keep this path. It is not a local URL. The CLI combines it with the global API URL:
124
127
 
125
- | Command | Description |
126
- |---|---|
127
- | `gent commit [-m <message>] [-a]` | Record changes to the repository. Use `-a` to auto-stage all modified files. |
128
- | `gent log [-n <count>] [--oneline] [--stat]` | Show commit history. Default limit is 10 commits. |
129
- | `gent show [ref] [--no-patch]` | Show commit details and diff. |
130
- | `gent tag [name] [-m <message>] [-d <name>]` | Create, list, or delete tags. |
128
+ ```text
129
+ https://gent-api.onrender.com/api/repos/2/my-project
130
+ ```
131
131
 
132
- ### Branching & Merging
132
+ ### 7. Link the local repo to the remote repo
133
133
 
134
- | Command | Description |
135
- |---|---|
136
- | `gent branch [name] [-d <name>] [-a]` | List, create, or delete branches. |
137
- | `gent checkout <branch> [-b]` | Switch branches. Use `-b` to create and switch to a new branch. |
138
- | `gent merge <branch> [-m <message>]` | Merge a branch into the current branch using a three-way smart merge. |
139
- | `gent stash [pop \| list \| drop \| apply] [-m <message>] [-i <index>]` | Stash working tree changes. |
134
+ Use the `/api/repos/<owner_id>/<repo_name>` path from the previous command:
140
135
 
141
- ### Remote & Sync
136
+ ```bash
137
+ gent remote add origin /api/repos/2/my-project
138
+ ```
142
139
 
143
- | Command | Description |
144
- |---|---|
145
- | `gent remote [add \| remove \| set-url] [args...] [-v]` | Manage remote connections. |
146
- | `gent push [remote] [branch] [-f]` | Push local commits to the remote. Use `-f` to force push. |
147
- | `gent pull [remote] [branch]` | Pull and merge remote commits into the current branch. |
140
+ Check it:
148
141
 
149
- ### Authentication Commands
142
+ ```bash
143
+ gent remote -v
144
+ ```
150
145
 
151
- | Command | Description |
152
- |---|---|
153
- | `gent register` | Create a new user account interactively. |
154
- | `gent login [-e <email>] [-p <password>]` | Log in to your account. |
155
- | `gent logout` | Log out and clear stored tokens. |
156
- | `gent whoami` | Display the currently logged-in user. |
146
+ Expected output:
157
147
 
158
- ## Usage Examples
148
+ ```text
149
+ origin -> /api/repos/2/my-project
150
+ ```
159
151
 
160
- ### Initialize a Repository
152
+ ### 8. Create files
161
153
 
162
154
  ```bash
163
- gent init
164
- # Output: Initialized empty Gent repository in /path/to/project
155
+ echo "Hello Gent" > README.md
156
+ mkdir src
157
+ echo "console.log('hello')" > src/index.js
158
+ ```
159
+
160
+ ### 9. Check status
161
+
162
+ ```bash
163
+ gent status
164
+ ```
165
+
166
+ Expected result: untracked files.
167
+
168
+ ### 10. Stage files
169
+
170
+ Stage specific files:
171
+
172
+ ```bash
173
+ gent add README.md src/index.js
165
174
  ```
166
175
 
167
- ### Stage and Commit
176
+ Or stage everything:
168
177
 
169
178
  ```bash
170
179
  gent add .
180
+ ```
181
+
182
+ ### 11. Review staged changes
183
+
184
+ ```bash
185
+ gent diff --staged
186
+ ```
187
+
188
+ Short summary:
189
+
190
+ ```bash
191
+ gent diff --staged --stat
192
+ ```
193
+
194
+ ### 12. Commit
195
+
196
+ ```bash
171
197
  gent commit -m "Initial commit"
172
198
  ```
173
199
 
174
- ### Work with Branches
200
+ Expected result: a commit hash, author, date, tree hash, and file stats.
201
+
202
+ ### 13. View history
203
+
204
+ ```bash
205
+ gent log
206
+ gent log --oneline
207
+ gent show --no-patch
208
+ ```
209
+
210
+ ### 14. Push to the remote API
211
+
212
+ ```bash
213
+ gent push
214
+ ```
215
+
216
+ Expected result:
217
+
218
+ ```text
219
+ Pushed 1 commit(s) to origin/main
220
+ ```
221
+
222
+ Run it again to confirm nothing else needs syncing:
223
+
224
+ ```bash
225
+ gent push
226
+ ```
227
+
228
+ Expected result:
229
+
230
+ ```text
231
+ Everything up-to-date
232
+ ```
233
+
234
+ ### 15. Clone from the remote API
235
+
236
+ Go outside your current project:
175
237
 
176
238
  ```bash
177
- # Create and switch to a new branch
178
- gent checkout -b feature-login
239
+ cd ..
240
+ gent clone /api/repos/2/my-project my-project-clone
241
+ cd my-project-clone
242
+ ```
179
243
 
180
- # List branches
244
+ Check the cloned files:
245
+
246
+ ```bash
247
+ cat README.md
248
+ gent status
249
+ gent log --oneline
250
+ ```
251
+
252
+ ### 16. Make another change in the original repo
253
+
254
+ ```bash
255
+ cd ../my-project
256
+ echo "Second line" >> README.md
257
+ gent add README.md
258
+ gent commit -m "Update README"
259
+ gent push
260
+ ```
261
+
262
+ ### 17. Pull the change into the clone
263
+
264
+ ```bash
265
+ cd ../my-project-clone
266
+ gent pull
267
+ cat README.md
268
+ gent status
269
+ ```
270
+
271
+ Expected result: the clone fast-forwards, `README.md` includes the new line, and status shows no staged changes.
272
+
273
+ ### 18. Create and sync a branch
274
+
275
+ From a repository with at least one commit and an `origin` remote:
276
+
277
+ ```bash
278
+ gent branch feature-login
181
279
  gent branch
280
+ ```
182
281
 
183
- # Switch back to main
282
+ Switch to the branch:
283
+
284
+ ```bash
285
+ gent checkout feature-login
286
+ ```
287
+
288
+ Make a change:
289
+
290
+ ```bash
291
+ echo "feature work" > feature.txt
292
+ gent add feature.txt
293
+ gent commit -m "Add feature work"
294
+ gent push origin feature-login
295
+ ```
296
+
297
+ Switch back to main:
298
+
299
+ ```bash
184
300
  gent checkout main
301
+ ```
302
+
303
+ ### 19. Merge a branch
304
+
305
+ ```bash
306
+ gent merge feature-login
307
+ gent push
308
+ ```
309
+
310
+ If there are conflicts, resolve the files, then:
311
+
312
+ ```bash
313
+ gent add .
314
+ gent commit -m "Resolve merge"
315
+ gent push
316
+ ```
317
+
318
+ ### 20. Create and sync a tag
319
+
320
+ Create a lightweight tag:
321
+
322
+ ```bash
323
+ gent tag v1.0.0
324
+ ```
325
+
326
+ Create an annotated tag:
327
+
328
+ ```bash
329
+ gent tag v1.0.1 -m "Release v1.0.1"
330
+ ```
331
+
332
+ List tags:
333
+
334
+ ```bash
335
+ gent tag
336
+ ```
337
+
338
+ Delete a tag:
339
+
340
+ ```bash
341
+ gent tag -d v1.0.0
342
+ ```
343
+
344
+ ### 21. Use stash when needed
345
+
346
+ Save local work:
347
+
348
+ ```bash
349
+ gent stash
350
+ ```
351
+
352
+ List stashes:
353
+
354
+ ```bash
355
+ gent stash list
356
+ ```
357
+
358
+ Apply latest stash:
359
+
360
+ ```bash
361
+ gent stash pop
362
+ ```
363
+
364
+ ### 22. Log out
365
+
366
+ ```bash
367
+ gent logout
368
+ ```
369
+
370
+ Confirm:
371
+
372
+ ```bash
373
+ gent whoami
374
+ ```
375
+
376
+ Expected result: not logged in.
377
+
378
+ ## One-Command Remote Repo Setup
379
+
380
+ You can initialize a local repo and create the remote repo in one command:
381
+
382
+ ```bash
383
+ mkdir another-project
384
+ cd another-project
385
+ gent init --remote another-project
386
+ gent remote -v
387
+ ```
388
+
389
+ This creates the remote repository on `https://gent-api.onrender.com` and configures `origin` automatically.
390
+
391
+ ## Command Reference
392
+
393
+ ### Authentication
394
+
395
+ ```bash
396
+ gent register
397
+ gent register -e user@example.com -p StrongPass123! --password-confirm StrongPass123!
398
+ gent login
399
+ gent login -e user@example.com -p StrongPass123!
400
+ gent whoami
401
+ gent logout
402
+ ```
403
+
404
+ ### Repository Setup
185
405
 
186
- # Delete a branch
187
- gent branch -d feature-login
406
+ ```bash
407
+ gent init
408
+ gent init --remote my-repo
409
+ gent clone /api/repos/<owner_id>/<repo_name> [directory]
188
410
  ```
189
411
 
190
- ### View History
412
+ ### Staging and Working Tree
191
413
 
192
414
  ```bash
415
+ gent status
416
+ gent status -s
417
+ gent add <files...>
418
+ gent add .
419
+ gent rm <files...>
420
+ gent rm <files...> --cached
421
+ gent reset [files...]
422
+ gent reset --soft <commit_hash>
423
+ gent reset --hard <commit_hash>
424
+ gent diff
425
+ gent diff --staged
426
+ gent diff --stat
427
+ ```
428
+
429
+ ### History
430
+
431
+ ```bash
432
+ gent commit -m "Message"
193
433
  gent log
194
434
  gent log --oneline
195
435
  gent log -n 5
436
+ gent show
437
+ gent show <commit_hash>
438
+ gent show --no-patch
196
439
  ```
197
440
 
198
- ### Remote Workflow
441
+ ### Branching and Merging
199
442
 
200
443
  ```bash
201
- # Add a remote
202
- gent remote add origin https://gent-api.onrender.com/api/repos/123/
444
+ gent branch
445
+ gent branch <name>
446
+ gent branch -d <name>
447
+ gent checkout <branch>
448
+ gent checkout -b <branch>
449
+ gent merge <branch>
450
+ gent merge <branch> -m "Merge message"
451
+ ```
203
452
 
204
- # Push to remote
205
- gent push origin main
453
+ ### Tags
206
454
 
207
- # Pull from remote
455
+ ```bash
456
+ gent tag
457
+ gent tag <name>
458
+ gent tag <name> -m "Message"
459
+ gent tag -d <name>
460
+ ```
461
+
462
+ ### Remotes and Sync
463
+
464
+ ```bash
465
+ gent repos
466
+ gent repos --create <name>
467
+ gent repos --create <name> --description "Description"
468
+ gent repos --create <name> --private
469
+ gent remote
470
+ gent remote -v
471
+ gent remote add origin /api/repos/<owner_id>/<repo_name>
472
+ gent remote set-url origin /api/repos/<owner_id>/<repo_name>
473
+ gent remote remove origin
474
+ gent push
475
+ gent push origin main
476
+ gent pull
208
477
  gent pull origin main
478
+ ```
479
+
480
+ ## Remote URL Rules
209
481
 
210
- # Clone a repository
211
- gent clone https://gent-api.onrender.com/api/repos/123/ my-project
482
+ The global API base is fixed:
483
+
484
+ ```text
485
+ https://gent-api.onrender.com
486
+ ```
487
+
488
+ Remote repository paths should be stored like this:
489
+
490
+ ```text
491
+ /api/repos/<owner_id>/<repo_name>
212
492
  ```
213
493
 
214
- ## Repository Structure
494
+ Example:
215
495
 
216
- Gent creates a `.gent` directory in your project root:
496
+ ```bash
497
+ gent remote add origin /api/repos/2/my-project
498
+ ```
217
499
 
500
+ Do not use:
501
+
502
+ ```text
503
+ http://localhost:8000
504
+ http://127.0.0.1:8000
218
505
  ```
506
+
507
+ ## Files Created by Gent
508
+
509
+ Inside each repo:
510
+
511
+ ```text
219
512
  .gent/
220
- ├── config.json # Project configuration, remotes, user info
221
- ├── commits.json # Full commit history, branches, and tags
222
- ├── staging.json # Current staging area
223
- ├── stash.json # Stashed changes (created on first stash)
224
- ├── HEAD # Current branch reference
225
- ├── objects/ # Content-addressable blob and tree store
226
- │ ├── ab/ # First 2 characters of SHA-256 hash
227
- │ │ └── cdef... # zlib-compressed object
228
- │ └── ...
513
+ ├── config.json
514
+ ├── commits.json
515
+ ├── staging.json
516
+ ├── HEAD
517
+ ├── objects/
229
518
  └── refs/
230
- ├── heads/ # Branch references (reserved for future use)
231
- └── tags/ # Tag references (reserved for future use)
519
+
520
+ .gentignore
232
521
  ```
233
522
 
234
- Your authentication tokens are stored globally in `~/.gent/auth.json`.
523
+ Global auth:
235
524
 
236
- ## Configuration
525
+ ```text
526
+ ~/.gent/auth.json
527
+ ```
237
528
 
238
- ### Ignore Files
529
+ ## Ignore Rules
239
530
 
240
- Create a `.gentignore` file in your repository root to exclude files from tracking:
531
+ Gent creates a `.gentignore` file by default:
241
532
 
242
- ```
533
+ ```text
243
534
  node_modules/
244
- dist/
245
- .env
535
+ .DS_Store
246
536
  *.log
537
+ .env
538
+ .gent/
247
539
  ```
248
540
 
249
- Default ignored patterns include: `.gent`, `node_modules`, `.git`, `.DS_Store`, `.env`, `dist`, `build`, `coverage`, `.vscode`, `.idea`, and `*.log`.
541
+ Add project-specific ignored files there.
250
542
 
251
- ### Remotes
543
+ ## Test the Full Remote Flow
252
544
 
253
- Remotes are stored in `.gent/config.json`:
545
+ This repository includes a remote-only E2E test. It uses only:
254
546
 
255
- ```json
256
- {
257
- "remotes": {
258
- "origin": {
259
- "url": "https://gent-api.onrender.com/api/repos/123/"
260
- }
261
- }
262
- }
547
+ ```text
548
+ https://gent-api.onrender.com
263
549
  ```
264
550
 
551
+ Run syntax checks:
552
+
553
+ ```bash
554
+ npm test
555
+ ```
556
+
557
+ Run the full remote scenario:
558
+
559
+ ```bash
560
+ npm run test:remote:e2e
561
+ ```
562
+
563
+ The test covers:
564
+
565
+ - API health check
566
+ - Register, login, whoami, logout
567
+ - Create and list remote repositories
568
+ - Init, remote add, status, add, diff, commit
569
+ - Push and up-to-date push
570
+ - Branch sync
571
+ - Tag sync
572
+ - Clone from remote
573
+ - Second commit and push
574
+ - Pull into clone and verify working tree content
575
+ - `init --remote`
576
+ - Unauthenticated guard
577
+ - Version flag
578
+
265
579
  ## Troubleshooting
266
580
 
267
- **Command not found?**
581
+ ### Command not found
582
+
583
+ Install or link the CLI:
584
+
585
+ ```bash
586
+ npm install -g gent-cli
587
+ ```
588
+
589
+ or:
268
590
 
269
- Make sure the CLI is linked globally:
270
591
  ```bash
592
+ cd apps/Cli
271
593
  npm link
272
594
  ```
273
595
 
274
- Or run it directly:
596
+ ### Not authenticated
597
+
598
+ Log in again:
599
+
275
600
  ```bash
276
- node src/index.js <command>
601
+ gent login
277
602
  ```
278
603
 
279
- **Not a Gent repository?**
604
+ ### Not a Gent repository
280
605
 
281
- Run `gent init` in your project directory first.
606
+ Run commands inside a folder initialized with:
282
607
 
283
- **No changes to commit?**
608
+ ```bash
609
+ gent init
610
+ ```
284
611
 
285
- Stage files with `gent add <files>` before committing.
612
+ ### Remote not found
286
613
 
287
- **Authentication errors?**
614
+ Add an origin remote:
288
615
 
289
- Run `gent login` to refresh your session. Tokens expire automatically and should refresh; if not, log in again.
616
+ ```bash
617
+ gent remote add origin /api/repos/<owner_id>/<repo_name>
618
+ ```
290
619
 
291
- ## Docs
620
+ ### Push says everything up-to-date
292
621
 
293
- - [QUICKSTART.md](QUICKSTART.md)
294
- - [docs/ARCHITECTURE.md](docs/ARCHITECTURE.md)
622
+ That means the local branch has no new commits compared to the last pushed remote ref.
295
623
 
296
- ## Contributing
624
+ ### Render cold start
297
625
 
298
- Contributions are welcome! Please fork the repository and submit a Pull Request.
626
+ The deployed API may take several seconds to respond after inactivity. Retry the command if the first request times out.
299
627
 
300
- ## License
628
+ ## Version
301
629
 
302
- ISC
630
+ Show the CLI version:
303
631
 
304
- ---
632
+ ```bash
633
+ gent -V
634
+ gent --version
635
+ ```
305
636
 
306
- Built with love by [Abdalrahman Kanawati](https://github.com/abdo-ka)
637
+ ## License
638
+
639
+ ISC