zapdev 0.11.0 → 1.1.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.
Files changed (3) hide show
  1. package/README.md +72 -39
  2. package/dist/cli.js +1814 -2080
  3. package/package.json +2 -3
package/README.md CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  **zapdev** is a lightweight TypeScript CLI that makes small, repetitive Git chores fast and precise.
6
6
 
7
- It stages changes, scans them for secrets, generates Conventional Commit messages with Ollama, and streamlines repository cleanup.
7
+ It stages changes, scans them for secrets, and generates Conventional Commit messages for one repository or several direct child repositories in a single review flow.
8
8
 
9
9
  ## Project Architecture
10
10
 
@@ -16,24 +16,27 @@ flowchart LR
16
16
  Commands --> Types["src/types"]
17
17
  Lib --> Prompts["src/prompts"]
18
18
  Lib --> Types
19
- Lib --> Tools["Git, Gitleaks, Ollama"]
19
+ Lib --> Tools["Git, Gitleaks, LLM API"]
20
20
  ```
21
21
 
22
22
  - `src/index.ts`: bin launcher; enables the V8 compile cache, then loads `cli.js`.
23
- - `src/cli.ts`: CLI entry; registers subcommands and opens the interactive menu.
23
+ - `src/cli.ts`: CLI entry; registers `commit` as the default command.
24
24
  - `src/commands/`: command UI and orchestration.
25
- - `src/lib/`: pure logic and isolated Git, Gitleaks, and Ollama side effects.
25
+ - `src/lib/`: pure logic and isolated Git, Gitleaks, and LLM side effects.
26
26
  - `src/prompts/`: LLM prompts inlined into the bundle at build time.
27
27
  - `src/types/`: shared type declarations.
28
28
 
29
29
  ## Environment Variables
30
30
 
31
- | Variable | Default | Required | Description |
32
- | --- | --- | --- | --- |
33
- | `OLLAMA_URL` | `http://localhost:11434` | No | Ollama base URL |
34
- | `OLLAMA_MODEL` | `deepseek-v4-flash:cloud` | No | Model used to generate commit messages |
35
- | `OLLAMA_BACKUP_MODEL` | - | No | Model used when generation with the primary model fails |
36
- | `OLLAMA_EFFORT` | `low` | No | Ollama thinking effort (`low`, `medium`, `high`, or `max`) |
31
+ | Variable | Required | Description |
32
+ | -------- | -------- | ----------- |
33
+ | `ZD_URL` | For `commit` | Complete HTTP(S) Chat Completions endpoint, including its path |
34
+ | `ZD_MODEL` | For `commit` | Model identifier supported by the endpoint |
35
+ | `ZD_EFFORT` | For `commit` | Sent as `reasoning_effort`; use a value supported by your model, such as `low`, `medium`, or `high` |
36
+
37
+ There are no defaults, automatic provider detection, or backup models. CLI flags override these variables. Legacy `OLLAMA_*` variables are no longer read.
38
+
39
+ Requests use the OpenAI Chat Completions format over plain `fetch`, without a provider SDK. No authentication headers are sent; use an endpoint that does not require them. The endpoint and model must support `reasoning_effort`.
37
40
 
38
41
  ## Setup
39
42
 
@@ -41,7 +44,7 @@ flowchart LR
41
44
 
42
45
  - **Node.js >= 20 (required):** runs the CLI.
43
46
  - **Git (required):** provides the repository operations.
44
- - **Ollama (required for `commit`):** generates Conventional Commit messages.
47
+ - **OpenAI-compatible Chat Completions endpoint (required for `commit`):** generates Conventional Commit messages.
45
48
  - **Gitleaks (recommended):** scans staged changes before message generation when available on `PATH`.
46
49
 
47
50
  ### Install
@@ -52,6 +55,14 @@ Install zapdev globally for daily use:
52
55
  npm install -g zapdev
53
56
  ```
54
57
 
58
+ Configure your endpoint and model before running `commit` (replace these example values):
59
+
60
+ ```bash
61
+ export ZD_URL="http://localhost:1234/v1/chat/completions"
62
+ export ZD_MODEL="your-model-id"
63
+ export ZD_EFFORT="low"
64
+ ```
65
+
55
66
  Or run it once without installing:
56
67
 
57
68
  ```bash
@@ -75,62 +86,84 @@ npm run build # bundle to dist/ with esbuild
75
86
 
76
87
  ## Usage
77
88
 
78
- Run `zapdev` with no command to pick one from an interactive menu. Without a TTY, zapdev displays its usage instead.
89
+ Run `zapdev` or `zapdev commit` to start the commit flow. Both accept the flags below.
79
90
 
80
91
  ### `zapdev commit`
81
92
 
82
- Stages all changes, scans them with Gitleaks when installed, generates a Conventional Commit message, and optionally pushes the commit.
93
+ Stages all changes, scans them with Gitleaks when installed, generates Conventional Commit messages, and optionally pushes the commits.
94
+
95
+ - **Inside a Git repository:** uses that repository only, including when launched from a subdirectory. Does not inspect child repositories.
96
+ - **Outside a Git repository:** processes only direct child repositories. No recursive search; `node_modules` is excluded.
97
+ - **Unified review:** generates messages in parallel, then presents every message with its repository name.
98
+ - **Actions:** commit all, commit only a named repository, edit a named repository's message, or cancel. Editing returns to the review menu.
99
+
100
+ Repositories with nothing to commit are skipped. Unselected or cancelled changes remain staged. Push confirmation is asked once for the successfully committed repositories.
83
101
 
84
102
  ```bash
85
103
  zapdev commit
86
104
  ```
87
105
 
88
- | Flag | Description |
89
- | --- | --- |
90
- | `--model <model>` | Override the Ollama model |
106
+ | Flag | Description |
107
+ | ------------------- | ----------------------------------------------------------------- |
108
+ | `--url <url>` | Override the complete Chat Completions endpoint |
109
+ | `--model <model>` | Override the model |
110
+ | `--effort <effort>` | Override the reasoning effort |
91
111
  | `-t, --type <type>` | Force the Conventional Commit type (`feat`, `fix`, `chore`, etc.) |
92
- | `-p, --push` | Push after committing without asking |
93
- | `-s, --staged` | Commit only changes that are already staged |
94
- | `-r, --rebase` | Rebase on upstream if the push is rejected |
95
- | `-m, --merge` | Merge upstream if the push is rejected |
96
- | `-y, --yes` | Skip prompts and commit directly |
112
+ | `-p, --push` | Push after committing without asking |
113
+ | `-s, --staged` | Commit only changes that are already staged |
114
+ | `-r, --rebase` | Rebase on upstream if the push is rejected |
115
+ | `-m, --merge` | Merge upstream if the push is rejected |
116
+ | `-y, --yes` | Skip prompts and commit all prepared repositories |
97
117
 
98
118
  ```bash
99
119
  zapdev commit -t feat # force the type
100
120
  zapdev commit --staged # leave unstaged changes untouched
101
121
  ```
102
122
 
103
- Before contacting Ollama, zapdev runs `gitleaks git --staged` when Gitleaks is installed. A failed scan stops the commit; when Gitleaks is absent, the scan is skipped.
123
+ Before contacting the LLM endpoint, zapdev runs `gitleaks git --staged` in each changed repository when Gitleaks is installed. A failed scan skips that repository without sending its diff; when Gitleaks is absent, the scan is skipped. The staged diff is sent to the configured endpoint, which may be remote.
124
+
125
+ Failures are reported per repository while the others continue. Any failure produces a nonzero exit code.
104
126
 
105
127
  Pushing is optimistic, with no preliminary fetch. If the branch is behind upstream, `--rebase` runs `git pull --rebase`, while `--merge` runs `git pull --no-rebase --no-edit`; zapdev then retries once. Without either flag, interactive runs ask whether to rebase, merge, or quit. Runs using `--yes` or without a TTY must provide one of the flags.
106
128
 
107
- Without a TTY, zapdev commits automatically and only pushes when `--push` is set.
129
+ Without a TTY, zapdev commits all prepared repositories automatically and only pushes when `--push` is set.
108
130
 
109
- ### `zapdev reset`
131
+ ### Zed IDE
110
132
 
111
- Operates on a Git repository or the direct child repositories of a directory. It fetches and prunes, switches branch, then permanently removes other local branches and linked worktrees.
133
+ For a faster review and commit workflow, review and stage changes from Zed's Git panel, then run `zapdev commit -syp` from a task. The command commits only staged changes, skips prompts, and pushes the commit.
112
134
 
113
- ```bash
114
- zapdev reset # reset the current repo or direct child repos
115
- zapdev reset ~/dev # reset repos under a directory
116
- zapdev reset -p # switch to the principal branch without prompting
117
- zapdev reset -t dev # switch to dev or fall back to the principal branch
118
- ```
135
+ Add the following tasks to `.zed/tasks.json`:
119
136
 
120
- | Flag | Description |
121
- | --- | --- |
122
- | `-p, --principal` | Switch every repo to its resolved principal branch (`origin/HEAD`) |
123
- | `-t, --target <branch>` | Switch to a target branch, falling back to the principal branch |
124
- | `--pull` | Pull the checked-out branch after reset without asking |
125
- | `-y, --yes` | Switch and delete without confirmation |
137
+ ```json
138
+ [
139
+ {
140
+ "label": "Safely commit staged changes.",
141
+ "command": "zapdev commit -s",
142
+ "reveal": "always",
143
+ "hide": "on_success",
144
+ "reveal_target": "center"
145
+ }
146
+ ]
147
+ ```
126
148
 
127
- Deletion is permanent. Branches are removed with `git branch -D`; worktrees are removed with `git worktree remove --force`. Without a TTY, pass `--yes` or the destructive step is refused. `node_modules` is never scanned.
149
+ Add this entry to Zed's `keymap.json` to run the commit task with `ctrl-cmd-enter`:
150
+
151
+ ```json
152
+ {
153
+ "context": "Pane",
154
+ "bindings": {
155
+ "ctrl-cmd-enter": [
156
+ "task::Spawn",
157
+ { "task_name": "Safely commit staged changes." }
158
+ ]
159
+ }
160
+ }
161
+ ```
128
162
 
129
163
  ### Shell Aliases
130
164
 
131
165
  ```bash
132
166
  alias commit="zapdev commit --yes"
133
- alias git-reset="zapdev reset --yes --principal --pull"
134
167
  ```
135
168
 
136
169
  ## Other