gitlocal 0.2.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 GitLocal
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,212 @@
1
+ # GitLocal
2
+
3
+ [![CI](https://github.com/ehud-am/gitlocal/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/ehud-am/gitlocal/actions/workflows/ci.yml)
4
+ [![npm version](https://img.shields.io/npm/v/gitlocal)](https://www.npmjs.com/package/gitlocal)
5
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
6
+ [![Node.js](https://img.shields.io/badge/node-%3E%3D22-brightgreen)](https://nodejs.org)
7
+
8
+ A local git repository viewer that gives you a GitHub-like browsing experience — without leaving your machine. Built for non-developers who use tools like [Claude Code](https://claude.ai/code) to work in git repositories and want a clean way to read, navigate, and review their code without a full IDE. Everything runs locally; no accounts, no telemetry, no internet required.
9
+
10
+ ---
11
+
12
+ ## Requirements
13
+
14
+ | Dependency | Version |
15
+ |-----------|---------|
16
+ | Node.js | 22+ |
17
+ | git | 2.22+ |
18
+
19
+ ---
20
+
21
+ ## Install
22
+
23
+ ```bash
24
+ npm install -g gitlocal
25
+ ```
26
+
27
+ Or run without installing:
28
+
29
+ ```bash
30
+ npx gitlocal
31
+ ```
32
+
33
+ ### From source
34
+
35
+ ```bash
36
+ git clone https://github.com/ehud-am/gitlocal.git
37
+ cd gitlocal
38
+ npm ci
39
+ npm --prefix ui ci
40
+ npm run build
41
+ ```
42
+
43
+ ---
44
+
45
+ ## Usage
46
+
47
+ ### Open a specific repository
48
+
49
+ ```bash
50
+ gitlocal <path-to-git-repo>
51
+ ```
52
+
53
+ **Examples:**
54
+
55
+ ```bash
56
+ # View this repo
57
+ gitlocal .
58
+
59
+ # View a project by absolute path
60
+ gitlocal ~/projects/my-app
61
+
62
+ # View any path — GitLocal shows an error screen if it's not a git repo
63
+ gitlocal /tmp/not-a-repo
64
+ ```
65
+
66
+ GitLocal starts an HTTP server on a random available port, prints the URL, and opens your default browser automatically. The README is shown immediately if one is found.
67
+
68
+ ```
69
+ gitlocal listening on http://localhost:54321
70
+ ```
71
+
72
+ Press **Ctrl+C** to stop the server.
73
+
74
+ ### Open with a folder picker
75
+
76
+ Run `gitlocal` with no arguments to open a browser-based folder picker:
77
+
78
+ ```bash
79
+ gitlocal
80
+ ```
81
+
82
+ Select a folder in the picker, then:
83
+
84
+ - click **Browse** for a normal folder to move deeper into it
85
+ - click **Open** for a detected git repository to open it immediately
86
+
87
+ You can still paste a path manually in the selected-folder field when needed.
88
+
89
+ ---
90
+
91
+ ## What it does
92
+
93
+ - **Browse the file tree** — expand and collapse folders lazily, just like GitHub
94
+ - **Read files beautifully** — Markdown renders as formatted HTML with GitHub Flavored Markdown; code files get syntax highlighting; images display inline
95
+ - **See git status** — current branch, recent commits, and a branch switcher (read-only)
96
+ - **Auto-opens README** — when you open a repo, the README is shown immediately if one exists
97
+ - **Folder picker** — run `gitlocal` with no arguments to open a browser-based folder picker
98
+ - **Clear folder actions** — non-git folders can be browsed deeper, while detected git repositories can be opened directly
99
+ - **No internet required** — everything runs locally; no accounts, no telemetry, no registration
100
+
101
+ ---
102
+
103
+ ## Development
104
+
105
+ ### Prerequisites
106
+
107
+ - Node.js 22+
108
+
109
+ ### Run in dev mode
110
+
111
+ ```bash
112
+ # Terminal 1: Vite dev server for the frontend (hot-reload)
113
+ npm run dev:ui
114
+
115
+ # Terminal 2: Backend with auto-restart on changes
116
+ npm run dev:server
117
+ ```
118
+
119
+ ### Run tests
120
+
121
+ ```bash
122
+ npm test
123
+ ```
124
+
125
+ Runs backend tests (Vitest + coverage) and frontend tests. All source files must maintain **≥90% branch coverage** per file.
126
+
127
+ ### Backend tests only
128
+
129
+ ```bash
130
+ npm run test:server
131
+ ```
132
+
133
+ ### Build
134
+
135
+ ```bash
136
+ npm run build
137
+ ```
138
+
139
+ Builds the React frontend (Vite) and compiles the Node.js backend (esbuild) into `dist/cli.js`.
140
+
141
+ ### Full verification
142
+
143
+ ```bash
144
+ npm run verify
145
+ ```
146
+
147
+ Runs tests, builds, and dependency audits for both the root package and the UI package.
148
+
149
+ ---
150
+
151
+ ## Architecture
152
+
153
+ GitLocal is a Node.js CLI that serves a React SPA:
154
+
155
+ ```
156
+ gitlocal/
157
+ ├── src/
158
+ │ ├── cli.ts — entry point: arg parsing, server start, browser open
159
+ │ ├── server.ts — Hono app, route registration, static serving + SPA fallback
160
+ │ ├── git/
161
+ │ │ ├── repo.ts — getInfo, getBranches, getCommits, findReadme, detectFileType
162
+ │ │ └── tree.ts — listDir (git ls-tree wrapper, sorted dirs-first)
163
+ │ └── handlers/
164
+ │ ├── git.ts — /api/info, /api/readme, /api/branches, /api/commits
165
+ │ ├── files.ts — /api/tree, /api/file
166
+ │ └── pick.ts — /api/pick and /api/pick/browse for the folder picker
167
+ └── ui/src/
168
+ ├── App.tsx — layout, state, README auto-load, picker mode
169
+ ├── components/
170
+ │ ├── FileTree/ — lazy expand/collapse tree
171
+ │ ├── Breadcrumb/ — path navigation
172
+ │ ├── ContentPanel/ — Markdown, code, image, binary rendering
173
+ │ ├── GitInfo/ — branch switcher + commit list
174
+ │ └── Picker/ — PickerPage folder browser with Browse/Open actions
175
+ └── services/api.ts — typed fetch wrappers for all endpoints
176
+ ```
177
+
178
+ **Key design decisions:**
179
+
180
+ - **No external runtime dependencies beyond Node.js** — all git operations shell out to the local `git` binary via `child_process.spawnSync`
181
+ - **Single npm toolchain** — build, test, and install all via `npm`; no Go, no Makefile, no shell scripts
182
+ - **Hash-based routing** — `HashRouter` means the server only needs to serve `index.html` for all non-asset routes
183
+ - **Read-only** — GitLocal never writes to the repository; it only reads via `git ls-tree`, `git cat-file`, and `git log`
184
+
185
+ ---
186
+
187
+ ## API
188
+
189
+ All endpoints are served under `/api/`:
190
+
191
+ | Endpoint | Description |
192
+ |----------|-------------|
193
+ | `GET /api/info` | Repository metadata (name, branch, isGitRepo, pickerMode) |
194
+ | `GET /api/readme` | Detects and returns the README filename for the current repo |
195
+ | `GET /api/branches` | List of branches with `isCurrent` flag |
196
+ | `GET /api/tree?path=&branch=` | Directory listing (dirs first, alphabetical) |
197
+ | `GET /api/file?path=&branch=` | File content with type and language detection |
198
+ | `GET /api/commits?branch=&limit=` | Recent commits (default 10, max 100) |
199
+ | `GET /api/pick/browse?path=` | Folder-picker directory listing with git-repo detection |
200
+ | `POST /api/pick` | Set the repo path from the picker UI (body: `{"path":"..."}`) |
201
+
202
+ ---
203
+
204
+ ## License
205
+
206
+ MIT — see [LICENSE](LICENSE).
207
+
208
+ ---
209
+
210
+ ## Contributing
211
+
212
+ Issues and pull requests are welcome. This project follows the [GitLocal constitution](.specify/memory/constitution.md) — all changes must maintain ≥90% branch coverage per file.