shadow-git 0.1.0 → 1.0.3

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.
Files changed (54) hide show
  1. package/.claude/settings.local.json +5 -1
  2. package/.temp/.sgit/index +0 -0
  3. package/.temp/.sgit/info/exclude +16 -7
  4. package/.temp/.sgit/objects/03/7f4e37a02573e40ab78b35dd4b442cc6110bae +0 -0
  5. package/.temp/.sgit/objects/2f/f0fd85dec20039eef6ff63ead905778a88843f +0 -0
  6. package/.temp/.sgit/objects/c3/2432f724b666f647fe21a1ce16535cd7693f74 +0 -0
  7. package/.temp/.sgit/objects/e6/9de29bb2d1d6434b8b29ae775ad8c2e48c5391 +0 -0
  8. package/.temp/.sgit/objects/ee/9dd32cca3b134623d184eb4de5805704c493e3 +0 -0
  9. package/.temp/.sgit.json +6 -2
  10. package/.temp/README.md +0 -3
  11. package/.temp/rec1/rec2/test +0 -0
  12. package/.temp/temp/shouldnt-track +0 -0
  13. package/.temp/test/1 +0 -0
  14. package/CLAUDE.md +10 -2
  15. package/README.md +17 -30
  16. package/dist/cli.js +810 -119
  17. package/package.json +1 -1
  18. package/src/cli.ts +50 -19
  19. package/src/commands/debug/gitignores.ts +28 -0
  20. package/src/commands/debug/index.ts +32 -0
  21. package/src/commands/track/add.ts +11 -0
  22. package/src/commands/track/clone.ts +213 -0
  23. package/src/commands/track/completion.ts +50 -15
  24. package/src/commands/track/destroy.ts +97 -19
  25. package/src/commands/track/ignore.ts +55 -0
  26. package/src/commands/track/index.ts +23 -1
  27. package/src/commands/track/init.ts +5 -2
  28. package/src/commands/track/sync.ts +1 -1
  29. package/src/commands/track/unignore.ts +50 -0
  30. package/src/commands/track/verify.ts +93 -20
  31. package/src/core/errors.ts +23 -2
  32. package/src/core/exclude.ts +40 -43
  33. package/src/core/gitignore.ts +242 -0
  34. package/src/core/hooks.ts +19 -0
  35. package/src/core/manifest.ts +33 -1
  36. package/src/core/paths.ts +21 -3
  37. package/src/core/repository.ts +17 -2
  38. package/tests/commands/track/add.test.ts +31 -1
  39. package/tests/commands/track/clone.test.ts +315 -0
  40. package/tests/commands/track/completion.test.ts +1 -1
  41. package/tests/commands/track/destroy.test.ts +68 -2
  42. package/tests/commands/track/ignore.test.ts +109 -0
  43. package/tests/commands/track/init.test.ts +27 -4
  44. package/tests/commands/track/remove.test.ts +1 -1
  45. package/tests/commands/track/sync.test.ts +3 -3
  46. package/tests/commands/track/unignore.test.ts +72 -0
  47. package/tests/commands/track/verify.test.ts +132 -1
  48. package/tests/core/exclude.test.ts +107 -19
  49. package/tests/core/gitignore.test.ts +561 -0
  50. package/tests/core/hooks.test.ts +34 -0
  51. package/tests/core/paths.test.ts +24 -0
  52. package/tests/core/repository.test.ts +39 -5
  53. package/tests/helpers/guard-child.mjs +125 -0
  54. package/tests/helpers.ts +37 -0
@@ -33,7 +33,11 @@
33
33
  "Bash(complete -p)",
34
34
  "Bash(pkg-config --variable=completionsdir bash-completion)",
35
35
  "Bash(dpkg -l bash-completion)",
36
- "Bash(git diff:*)"
36
+ "Bash(git diff:*)",
37
+ "Bash(git --git-dir=.sgit --work-tree=. diff --cached --name-only)",
38
+ "Bash(git --git-dir=.sgit --work-tree=. reset HEAD temp/shouldnt-track)",
39
+ "Bash(git --git-dir=.sgit --work-tree=. add .)",
40
+ "Bash(git stash:*)"
37
41
  ]
38
42
  }
39
43
  }
package/.temp/.sgit/index CHANGED
Binary file
@@ -1,11 +1,20 @@
1
- # Exclude everything by default
1
+ # sgit-managed
2
2
  *
3
-
4
- # .sgit.json (always tracked)
5
3
  !.sgit.json
6
-
7
- # temp.md
8
4
  !temp.md
9
-
10
- # README.md
11
5
  !README.md
6
+ !temp/
7
+ temp/*
8
+ !temp/should-track
9
+ !temp2/
10
+ !temp2/**
11
+ !test/
12
+ test/*
13
+ !test/1
14
+ !rec1/
15
+ rec1/*
16
+ !rec1/rec2/
17
+ rec1/rec2/*
18
+ !rec1/rec2/test
19
+ .gitignore-sgit.bat
20
+ # end: sgit-managed
package/.temp/.sgit.json CHANGED
@@ -1,6 +1,10 @@
1
1
  {
2
2
  "paths": [
3
3
  "temp.md",
4
- "README.md"
4
+ "README.md",
5
+ "temp/should-track",
6
+ "temp2/",
7
+ "test/1",
8
+ "rec1/rec2/test"
5
9
  ]
6
- }
10
+ }
package/.temp/README.md CHANGED
@@ -1,3 +0,0 @@
1
- # Demo Project
2
-
3
- A sample project for testing.
File without changes
File without changes
package/.temp/test/1 ADDED
File without changes
package/CLAUDE.md CHANGED
@@ -12,6 +12,8 @@ npm run dev # Build in watch mode
12
12
 
13
13
  After building, the global `sgit` command uses `dist/cli.js`. Rebuild after source changes to test CLI manually.
14
14
 
15
+ Always run `npm run lint` after making changes to verify the code type-checks.
16
+
15
17
  ## Architecture
16
18
 
17
19
  ```
@@ -19,6 +21,9 @@ src/
19
21
  cli.ts # Entry point, routes to track commands or git passthrough
20
22
  commands/
21
23
  forward.ts # Forwards non-track commands to shadow git
24
+ debug/
25
+ index.ts # Commander registration for hidden debug subcommands
26
+ gitignores.ts # Disable .gitignore files for 10s then re-enable
22
27
  track/
23
28
  index.ts # Commander registration for all track subcommands
24
29
  init.ts # Initialize .sgit/ repo
@@ -37,6 +42,7 @@ src/
37
42
  exclude.ts # Generate .git/info/exclude and .sgit/info/exclude
38
43
  hooks.ts # Install/uninstall pre-commit hooks
39
44
  errors.ts # Custom error classes (SgitError hierarchy)
45
+ gitignore.ts # Disable/enable .gitignore files during sgit operations
40
46
  utils/
41
47
  logger.ts # Color-coded stdout/stderr logging
42
48
  process.ts # Child process execution
@@ -45,7 +51,9 @@ src/
45
51
  ## Key Conventions
46
52
 
47
53
  - All paths in `.sgit.json` use forward slashes, relative to repo root
48
- - Directories are stored with trailing `/` (e.g., `docs/.internal/`)
49
- - The `.git/info/exclude` sgit section uses `# sgit` marker comments on their own line (not inline) above each entry
54
+ - Directories are stored with trailing `/` (e.g., `docs/.internal/`) and track all contents recursively
55
+ - Exclude files use block markers: `# sgit-managed` and `# end: sgit-managed` — everything between is replaced on sync
50
56
  - Shadow repo exclude uses a deny-all + allow-list pattern (`*` then `!path`)
51
57
  - Error classes extend `SgitError`; the CLI catches these and prints the message
58
+ - Hidden `debug` commands (`sgit debug <cmd>`) are registered with `{ hidden: true }` so they don't appear in `sgit --help`. They are only visible via `sgit debug --help`. Debug commands manage their own gitignore guard (the CLI-level guard is skipped for them). No tests are written for debug commands.
59
+ - **HARD RULE — gitignore revert guarantee:** `.gitignore` files inside sgit-tracked directories are temporarily renamed to `.gitignore-sgit.bat` during sgit command execution (via `setupGitignoreGuard` in `src/core/gitignore.ts`). **The rename MUST always be reverted** when the command ends — whether it succeeds, fails, is cancelled (Ctrl+C), or receives SIGTERM. The guard uses `try/finally`, signal handlers, and `process.on('exit')` to ensure this. Any new code that executes sgit operations must use the guard or equivalent cleanup guarantees. Pre-commit hooks verify no `.gitignore-sgit.bat` files exist at commit time.
package/README.md CHANGED
@@ -7,57 +7,44 @@ Shadow-git (`sgit`) creates a `.sgit/` repository alongside your `.git/` directo
7
7
  ## Installation
8
8
 
9
9
  ```bash
10
- npm install -g .
11
- # or
12
- npm link
10
+ npm install -g shadow-git
13
11
  ```
14
12
 
15
- ## Quick Start
13
+ Optionally, install shell completions (bash, zsh, or fish):
16
14
 
17
15
  ```bash
18
- # Initialize shadow repo in an existing git project
19
- sgit track init
20
-
21
- # Start tracking a file
22
- sgit track add notes/todo.md
23
-
24
- # Move a main-git-tracked file to shadow tracking
25
- sgit track add --adopt config.local.json
16
+ sgit track completion install
17
+ ```
26
18
 
27
- # List tracked files
28
- sgit track list
19
+ ## Quick Start
29
20
 
30
- # Use git commands against the shadow repo
31
- sgit status
32
- sgit commit -m "update notes"
33
- sgit log
21
+ ```bash
22
+ sgit track init # Initialize shadow repo
23
+ sgit track add notes/todo.md # Start tracking a file
24
+ sgit track add --adopt config.local # Move a main-git file to shadow tracking
25
+ sgit track list # List tracked paths
26
+ sgit status # Git status in shadow repo
27
+ sgit commit -m "update notes" # Commit to shadow repo
34
28
  ```
35
29
 
36
30
  ## Commands
37
31
 
38
- ### Track Management
39
-
40
32
  | Command | Description |
41
33
  |---|---|
42
34
  | `sgit track init` | Initialize shadow repository |
35
+ | `sgit track clone <url>` | Clone a shadow repository from a remote URL |
43
36
  | `sgit track add <paths...>` | Start shadow-tracking paths |
44
37
  | `sgit track add --adopt <paths...>` | Move main-git-tracked files to shadow tracking |
45
38
  | `sgit track remove <paths...>` | Stop shadow-tracking paths |
46
39
  | `sgit track list` | List all shadow-tracked paths |
47
40
  | `sgit track sync` | Regenerate exclude files from manifest |
48
41
  | `sgit track verify` | Validate staged files against manifest |
42
+ | `sgit track ignore <paths...>` | Ignore paths within tracked directories |
43
+ | `sgit track unignore <paths...>` | Stop ignoring paths within tracked directories |
49
44
  | `sgit track destroy` | Remove shadow repository entirely |
45
+ | `sgit track completion [install]` | Print or install shell completion scripts |
50
46
 
51
- ### Git Passthrough
52
-
53
- Any command not listed above is forwarded directly to git using the shadow repository:
54
-
55
- ```bash
56
- sgit status # git status in shadow repo
57
- sgit diff # git diff in shadow repo
58
- sgit commit -m "msg" # commit to shadow repo
59
- sgit log # log of shadow repo
60
- ```
47
+ Any non-track command is forwarded to git using the shadow repository (e.g. `sgit status`, `sgit log`, `sgit diff`).
61
48
 
62
49
  ## How It Works
63
50