pi-usereq 0.55.0 → 0.56.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,4 +1,4 @@
1
- # PI-useReq/pi-usereq (0.55.0)
1
+ # PI-useReq/pi-usereq (0.56.0)
2
2
 
3
3
  <p align="center">
4
4
  <img src="https://img.shields.io/badge/python-3.11%2B-3776AB?style=flat-square&logo=python&logoColor=white" alt="Python 3.11+">
@@ -9,19 +9,22 @@
9
9
  </p>
10
10
 
11
11
  <p align="center">
12
- <strong>TODO: complete with one line project descrition.</strong><br>
13
- TODO: complete with complete molti-line project descrition.<br>
14
- This allows them to be run both as a Python package (installed as <b>req</b>, <b>usereq</b>, or <b>use-req</b>) and directly using <b>uvx</b>.
12
+ <strong>pi-usereq is a pi extension that runs a requirements-first development workflow.</strong><br>
13
+ It turns a User Request into a living <em>Software Requirements Specification</em> (SRS), implements the corresponding
14
+ source code, and keeps the project documentation (<code>WORKFLOW.md</code>, <code>REFERENCES.md</code>, <code>FLOWCHART.md</code>, <code>README.md</code>)
15
+ in sync with the repository. All capabilities are exposed as slash commands and agent tools inside
16
+ <a href="https://pi.dev"><strong>pi</strong></a> (<code>pi-coding-agent</code> 0.80.4+).
15
17
  </p>
16
18
 
17
19
  <p align="center">
18
20
  <a href="#quick-start">Quick Start</a> |
21
+ <a href="#requirements">Requirements</a> |
19
22
  <a href="#feature-highlights">Feature Highlights</a> |
20
23
  <a href="#prompts-and-agents">Prompts and Agents</a> |
21
24
  <a href="#default-workflow">Default Workflow</a> |
22
- <a href="#supported-clis-agents-and-extensions">Supported CLIs, Agents, and Extensions</a> |
23
- <a href="#known-issues">Known Issues</a> |
24
- <a href="#legacy-mode">Legacy Mode</a>
25
+ <a href="#install-uninstall">Install/Uninstall</a> |
26
+ <a href="#extension-usage">Extension Usage</a> |
27
+ <a href="#note-on-git-usage">Note on Git usage</a>
25
28
  </p>
26
29
  <p align="center">
27
30
  <br>
@@ -31,38 +34,66 @@ This allows them to be run both as a Python package (installed as <b>req</b>, <b
31
34
  <p>
32
35
 
33
36
 
37
+ ## Quick Start
34
38
 
35
- ## Requirements
36
-
37
- - TODO: complete the bulle list with requiremets
39
+ 1. **Install the extension** (see [Install](#install)) and restart pi.
40
+ 2. **Configure the project** (optional): run `/pi-usereq` to set the documentation directory, unit-tests directory, source directories, static code checkers, enabled tools, git automation, and notifications.
41
+ 3. **Write the requirements**: run `/req-write <User Request>` to produce a first SRS draft, or `/req-create` to derive the SRS from the existing source code.
42
+ 4. **Implement the source code**: run `/req-implement` to build the source from the requirements, or `/req-cover` to make the minimal changes that cover uncovered requirements.
43
+ 5. **Update the documentation**: run `/req-workflow`, `/req-flowchart`, and/or `/req-references` to regenerate the project documentation from the source; `/req-readme` keeps this file aligned with the implementation.
44
+ 6. **Iterate**: use `/req-change`, `/req-new`, `/req-fix`, `/req-refactor`, and `/req-check` to evolve requirements and code together.
45
+ 7. **Recover** (if a run fails or is interrupted): run `/req-reset` to restore the original base path and remove generated worktrees and branches.
38
46
 
39
47
 
40
- ## Feature Highlights
41
- - TODO: complete the bulle list with feature highlights
48
+ ## Requirements
42
49
 
50
+ - **pi CLI** (`pi.dev`) - the extension runs inside pi; requires `@earendil-works/pi-coding-agent` 0.80.4 or newer (Node.js 22.19+, per the pi CLI requirement).
51
+ - **Git repository** - every `req-*` command runs slash-command-owned git validation: the project must be inside a git work tree, the tracked working tree must be clean, and `HEAD` must resolve (a detached `HEAD` is tolerated; a working branch is recommended because the branch name is embedded in generated worktree names).
52
+ - **Requirements documentation** - the configured `docs-dir` (default `pi-usereq/docs`) must contain the canonical documents required by each command (`REQUIREMENTS.md`, `WORKFLOW.md`, `REFERENCES.md`); commands such as `/req-write`, `/req-create`, and `/req-workflow` are the entry points that generate them.
53
+ - **Static code checkers** - the bundled checkers (`pyright`, `ruff`, `eslint`) install automatically through the `postinstall` script; the native C/C++ checkers (`cppcheck`, `clang-format`) require a one-line system install (see [Install](#install)). Default configured languages: C, C++, JavaScript, Python, TypeScript.
43
54
 
44
- ## Extension Custom Commands
45
55
 
46
- TODO: complete table with the extension custom commands
56
+ ## Feature Highlights
47
57
 
48
- | Prompt | Description |
49
- | --- | --- |
50
- | `write` | Produce a *SRS* draft based on the User Request description |
51
- | `create` | Write a *Software Requirements Specification* using the project's source code |
52
- | `recreate` | Reorganize and update the *Software Requirements Specification* based on source code analysis (preserve requirement IDs) |
53
- | `renumber` | Deterministically renumber requirement IDs in the *Software Requirements Specification* without changing requirement text or order |
54
- | `analyze` | Produce an analysis report |
55
- | `change` | Update the requirements and implement the corresponding changes |
56
- | `check` | Run the requirements check |
57
- | `cover` | Implement minimal changes to cover uncovered existing requirements |
58
- | `fix` | Fix a defect without changing the requirements |
59
- | `implement` | Implement source code from requirements (from scratch) |
60
- | `new` | Implement a new requirement and the corresponding source code changes |
61
- | `refactor` | Perform a refactor without changing the requirements |
62
- | `readme` | Write `README.md` from user-visible implementation evidence |
63
- | `req-references` | Write a `REFERENCES.md` using the project's source code |
64
- | `workflow` | Write a `WORKFLOW.md` using the project's source code |
65
- | `flowchart` | Write a `FLOWCHART.md` using the project's source code |
58
+ - **17 slash commands** - 15 prompt-backed `req-*` commands plus the dedicated non-agentic `/req-references` and `/req-reset` commands.
59
+ - **11 built-in agent tools** - token counting, summarization, compression, construct search, and static-check tools for explicit files or for the configured project surface.
60
+ - **Interactive configuration menu** - `/pi-usereq` manages local (`<base-path>/.pi-usereq.json`) and global (`~/.config/pi-usereq/config.json`) configuration with no manual JSON editing required.
61
+ - **Worktree-isolated runs** - prompt-command executions run in an isolated git worktree (created with `<prefix><project>-<branch>-<YYYYMMDDHHMMSS>` names) and are merged back with a stash-assisted fast-forward on success.
62
+ - **Automatic commit guidance** - `AUTO_GIT_COMMIT=enable` (default) injects structured commit instructions (`<TYPE>(<COMPONENT>): <DESCRIPTION> [useReq]`) into every prompt; disabling it forces read-only git behavior and turns worktree orchestration off.
63
+ - **Notifications** - desktop notify command, sound effects (levels `none`/`low`/`mid`/`high`, default `alt+s` toggle) and Pushover push messages on prompt completion, interruption, or failure.
64
+ - **Runtime status bar** - the extension renders its workflow state, current branch, context usage, elapsed time, and sound level in the pi status line.
65
+ - **Debug surface** - config-gated `debug-*` slash commands and a standalone debug harness (`scripts/debug-extension.ts`, `scripts/pi-usereq-debug.sh`) for offline inspection and replay.
66
+
67
+
68
+ ## Prompts and Agents
69
+
70
+ Each `req-*` command is invoked as `/req-<name> <User Request>` inside pi. Prompt commands first run git validation and the
71
+ prompt-specific required-document checks, then (when `Auto git commit` and `Git worktree` are enabled) switch the session into an
72
+ isolated worktree, render the bundled prompt with the project context, and on success merge the changes back and leave the
73
+ repository clean. `/req-references` and `/req-reset` are non-agentic: they execute directly without starting an LLM session or
74
+ creating a worktree.
75
+
76
+ | Command | Description | Required docs |
77
+ | --- | --- | --- |
78
+ | `/req-write` | Produce a *SRS* draft based on the User Request description | none |
79
+ | `/req-create` | Write a *Software Requirements Specification* using the project's source code | none |
80
+ | `/req-recreate` | Reorganize and update the *Software Requirements Specification* based on source code analysis (preserve requirement IDs) | `REQUIREMENTS.md`, `WORKFLOW.md`, `REFERENCES.md` |
81
+ | `/req-renumber` | Deterministically renumber requirement IDs in the *Software Requirements Specification* without changing requirement text or order | `REQUIREMENTS.md`, `WORKFLOW.md`, `REFERENCES.md` |
82
+ | `/req-analyze` | Produce an analysis report | `REQUIREMENTS.md`, `WORKFLOW.md`, `REFERENCES.md` |
83
+ | `/req-change` | Update the requirements and implement the corresponding changes | `REQUIREMENTS.md`, `WORKFLOW.md`, `REFERENCES.md` |
84
+ | `/req-check` | Run the requirements check | `REQUIREMENTS.md`, `WORKFLOW.md`, `REFERENCES.md` |
85
+ | `/req-cover` | Implement minimal changes to cover uncovered existing requirements | `REQUIREMENTS.md`, `WORKFLOW.md`, `REFERENCES.md` |
86
+ | `/req-fix` | Fix a defect without changing the requirements | `REQUIREMENTS.md`, `WORKFLOW.md`, `REFERENCES.md` |
87
+ | `/req-implement` | Implement source code from requirements | `REQUIREMENTS.md` |
88
+ | `/req-new` | Implement a new requirement and the corresponding source code changes | `REQUIREMENTS.md`, `WORKFLOW.md`, `REFERENCES.md` |
89
+ | `/req-refactor` | Perform a refactor without changing the requirements | `REQUIREMENTS.md`, `WORKFLOW.md`, `REFERENCES.md` |
90
+ | `/req-readme` | Write `README.md` from user-visible implementation evidence | `REQUIREMENTS.md`, `WORKFLOW.md`, `REFERENCES.md` |
91
+ | `/req-references` | Write a `REFERENCES.md` using the project's source code (non-agentic, commits the regenerated file) | none |
92
+ | `/req-workflow` | Write a `WORKFLOW.md` using the project's source code | none |
93
+ | `/req-flowchart` | Write a `FLOWCHART.md` using the project's source code | `REQUIREMENTS.md`, `WORKFLOW.md`, `REFERENCES.md` |
94
+ | `/req-reset` | Reset the req workflow state, restore the base path, and remove generated worktrees and branches (non-agentic) | none |
95
+
96
+ Bundled prompts substitute project-derived values through `%%` placeholders, including `%%SRC_PATHS%%` (configured source directories), `%%ARGS%%` (command arguments), `%%PROMPT%%` (command name), `%%COMMIT%%` (git commit or read-only instruction), and `%%CONTEXT_FILES%%` (the canonical docs, when the corresponding context-file toggles are enabled in the settings menu).
66
97
 
67
98
 
68
99
  ## Default Workflow
@@ -74,47 +105,48 @@ Click to zoom flowchart image.
74
105
 
75
106
  ## Project's Documentation
76
107
 
77
-
78
108
  ### Project's Tree
79
109
 
80
- TODO: update/rewrite the project tree
81
-
82
110
  ```text
83
111
  .
84
- ├── .req/
85
- │ └── useReq/req files
86
- ├── docs/
87
- │ ├── FLOWCHART.md
88
- │ ├── REQUIREMENTS.md
89
- │ ├── REFERENCES.md
90
- │ └── WORKFLOW.md
91
- ├── guidelines/
92
- │ └── User's guidelines
93
- ├── src/
94
- │ └── Source code
95
- └── tests/
96
- └── Unit tests suite
112
+ ├── .pi-usereq.json # local project configuration (auto-generated)
113
+ ├── pi-usereq/ # configured docs-dir (default)
114
+ │ └── docs/
115
+ │ ├── REQUIREMENTS.md # Software Requirements Specification (SRS)
116
+ │ ├── WORKFLOW.md # runtime/execution units and call traces
117
+ │ ├── REFERENCES.md # symbol index generated from the source
118
+ │ └── FLOWCHART.md # workflow flowchart (generated on demand)
119
+ ├── src/ # source code
120
+ ├── tests/ # unit tests suite
121
+ ├── scripts/ # debug harness and checker installer
122
+ ├── images/ # project assets (flowchart, logo)
123
+ └── ~/.config/pi-usereq/ # global configuration (outside the repo)
124
+ └── config.json # cross-project settings (checkers, git, notifications)
97
125
  ```
98
126
 
127
+ The documentation directory, unit-tests directory, and source directories are configurable via the
128
+ [settings menu](#extension-usage) (defaults: `pi-usereq/docs`, `tests`, `src`).
129
+
130
+
99
131
  ## Install/Uninstall
100
132
 
101
133
  ### Install
102
134
 
103
- Install:
135
+ Install the extension package with the pi CLI:
136
+
104
137
  ```bash
105
138
  pi install npm:pi-usereq
106
139
  ```
107
140
 
108
- Or via git:
141
+ Or install it directly from the git repository:
142
+
109
143
  ```bash
110
144
  pi install git:github.com/Ogekuri/PI-useReq
111
145
  ```
112
146
 
113
- Reload Pi.
147
+ Reload pi (restart the session).
114
148
 
115
- Bundled static checkers (`pyright`, `ruff`, `eslint`) install automatically via the
116
- `postinstall` script. Native checkers (`cppcheck`, `clang-format`) require a one-line
117
- system install:
149
+ Bundled static checkers (`pyright`, `ruff`, `eslint`) install automatically via the `postinstall` script. Native checkers (`cppcheck`, `clang-format`) require a one-line system install:
118
150
 
119
151
  - Debian/Ubuntu: `sudo apt install cppcheck clang-format`
120
152
  - macOS: `brew install cppcheck clang-format`
@@ -123,33 +155,29 @@ system install:
123
155
 
124
156
  ### Uninstall
125
157
 
126
- TODO: complete uninstall istructions
158
+ Remove the extension package with the pi CLI (use the same source you installed from):
127
159
 
128
160
  ```bash
129
-
161
+ pi remove npm:pi-usereq
130
162
  ```
131
163
 
132
- ## Quick Start
133
-
134
- TODO: complete/reeview with a quick start guide with a complete quick start guide
164
+ Or, if it was installed from git:
135
165
 
136
- 1. Install extension, tun pi-dev CLI
137
- 2. Use `/req-write` or `/req-create` to create requirements
138
- 3. Use `/req-implement` to implement source-code from requirements, or `/req-cover` to cover new requirements (documentation).
139
- 4. Use `/req-workflow`, `/req-flowchart`, and/or `/req-references` to update project's documentation.
140
- 5. Start to use `/req-change`, `/req-new`, and `/req-fix`.
166
+ ```bash
167
+ pi remove git:github.com/Ogekuri/PI-useReq
168
+ ```
141
169
 
142
- ## Extension Usage
170
+ Then reload pi. Optionally delete the persisted configuration files: the global `~/.config/pi-usereq/config.json`
171
+ and the project-local `.pi-usereq.json` files.
143
172
 
144
- TODO: document all extension features in details
145
173
 
146
- ### Extension Custom Commands
174
+ ## Extension Usage
147
175
 
148
- TODO: complete with the extension custom commands full documentation
176
+ > The bulk of the extension capabilities are covered by the [Prompts and Agents](#prompts-and-agents) table; this section documents the tools, the standalone CLI, the settings menu, and the side features.
149
177
 
150
178
  ### Extension Custom Tools
151
179
 
152
- TODO: complete with the extension custom tools full documentasions
180
+ The extension registers the following agent tools (available to the LLM inside pi). All parameters are exposed through the pi tool-call contract; `FILE` entries may be project-relative or absolute paths. Optional `enableLineNumbers` adds `<n>:` line prefixes to compressed/search output.
153
181
 
154
182
  - Count tokens and chars for the given files
155
183
  `files-tokens FILE [FILE ...]`
@@ -158,54 +186,36 @@ TODO: complete with the extension custom tools full documentasions
158
186
  `files-summarize FILE [FILE ...]`
159
187
 
160
188
  - Generate compressed output for the given files
161
- `files-compress FILE [FILE ...]`
189
+ `files-compress FILE [FILE ...] [enableLineNumbers]`
162
190
 
163
191
  - Find and extract specific constructs from the given files
164
- `files-find TAG PATTERN FILE [FILE ...]`
192
+ `files-search TAG PATTERN FILE [FILE ...] [enableLineNumbers]`
165
193
 
166
- - Run static analysis on the given files using tools configured in `.req/config.json`
194
+ - Run static analysis on the given files using the checkers configured for their extensions
167
195
  `files-static-check FILE [FILE ...]`
168
196
 
169
- - Count tokens and chars for canonical docs files in configured `docs-dir` (`REQUIREMENTS.md`, `WORKFLOW.md`, `REFERENCES.md`).
197
+ - Count tokens and chars for the canonical docs in the configured `docs-dir` (`REQUIREMENTS.md`, `WORKFLOW.md`, `REFERENCES.md`)
170
198
  `tokens`
171
199
 
172
- - Generate LLM summary markdown for source files selected by `git ls-files cached others exclude-standard` under configured `src-dir` directories.
200
+ - Generate LLM summary markdown for the configured `src-dir` directories
173
201
  `summarize`
174
202
 
175
- - Generate compressed output for source files selected by `git ls-files cached others exclude-standard` under configured `src-dir` directories.
176
- `compress`
177
-
178
- - Find and extract specific constructs from source files selected by `git ls-files cached others exclude-standard` under configured `src-dir` directories.
179
- `find TAG PATTERN`
180
-
181
- - Run static analysis on source files selected by `git ls-files cached others exclude-standard` under configured `src-dir` directories (plus configured `tests-dir`, excluding `fixtures/`).
182
- `static-check`
183
-
184
- - Check repository integrity for the configured git path: clean working tree and valid HEAD.
185
- `git-check`
203
+ - Generate `REFERENCES.md` from the configured `src-dir` directories and overwrite `<docs-dir>/REFERENCES.md`
204
+ `references`
186
205
 
187
- - Check canonical docs presence in configured `docs-dir`: `REQUIREMENTS.md`, `WORKFLOW.md`, `REFERENCES.md`.
188
- `docs-check`
206
+ - Generate compressed output for the configured `src-dir` directories
207
+ `compress [enableLineNumbers]`
189
208
 
190
- - Create an isolated git worktree and branch with the provided name; also copies `.req/`, active provider directories, and `.venv` (when present) into the new worktree context.
191
- `git-wt-create WT_NAME`
209
+ - Find and extract specific constructs from the configured `src-dir` directories
210
+ `search TAG PATTERN [enableLineNumbers]`
192
211
 
193
- - Remove the git worktree and branch identified by name.
194
- `git-wt-delete WT_NAME`
195
-
196
- - Print the configured `git-path` value from `.req/config.json`; if `.req/config.json` is missing, the command fails with `Error: .req/config.json not found in the project root`.
197
- `git-path`
198
-
199
- - Print the configured `base-path` value from `.req/config.json`; if `.req/config.json` is missing, the command fails with `Error: .req/config.json not found in the project root`.
200
- `get-base-path`
201
-
202
-
203
- - Add `enable-line-numbers` to include `<n>:` prefixes in `files-compress`, `compress`, `files-find`, and `find` output.
212
+ - Run static analysis on the configured `src-dir` plus `tests-dir` selections (excluding `fixtures/`)
213
+ `static-check`
204
214
 
205
- - Test static check configuration and execution (standalone).
206
- `test-static-check {dummy,pylance,ruff,command} [FILES...]`
215
+ The set of startup tools active for a project is configurable through `Enable tools` in the
216
+ [settings menu](#settings-menu-pi-usereq).
207
217
 
208
- #### Supported <TAG> in `find` commands
218
+ #### Supported `<TAG>` in search commands
209
219
 
210
220
  - **Python**: CLASS, FUNCTION, DECORATOR, IMPORT, VARIABLE
211
221
  - **C**: STRUCT, UNION, ENUM, TYPEDEF, MACRO, FUNCTION, IMPORT, VARIABLE
@@ -228,39 +238,89 @@ TODO: complete with the extension custom tools full documentasions
228
238
  - **Zig**: FUNCTION, STRUCT, ENUM, UNION, CONSTANT, VARIABLE, IMPORT
229
239
  - **Elixir**: MODULE, FUNCTION, PROTOCOL, IMPL, STRUCT, IMPORT
230
240
 
241
+ ### Standalone CLI
242
+
243
+ The extension ships a standalone CLI entry point (`src/cli.ts`, runnable with `npm run cli -- <options>`) that mirrors the agent tools for scripting and debugging:
244
+
245
+ ```text
246
+ --files-tokens FILE [FILE ...]
247
+ --files-summarize FILE [FILE ...]
248
+ --files-compress FILE [FILE ...] [--enable-line-numbers] [--verbose]
249
+ --files-find TAG PATTERN FILE [FILE ...] [--enable-line-numbers] [--verbose]
250
+ --files-static-check FILE [FILE ...]
251
+ --summarize [--verbose]
252
+ --compress [--enable-line-numbers] [--verbose]
253
+ --find TAG PATTERN [--enable-line-numbers] [--verbose]
254
+ --tokens
255
+ --static-check
256
+ --test-static-check {dummy,command} [FILES...]
257
+ --enable-static-check LANG=MODULE[,CMD[,PARAM...]] (repeatable; e.g. --enable-static-check python=command,ruff,check)
258
+ --base <path> # project base for project-scoped commands
259
+ --here # use the current directory as project base
260
+ --verbose
261
+ ```
262
+
263
+ Project-scoped commands (`--summarize`, `--compress`, `--tokens`, `--find`, `--static-check`) always target the current project configuration and reject `--base` (use `--here`).
264
+
265
+ ### Settings Menu (`/pi-usereq`)
266
+
267
+ The interactive configuration menu exposes every user-facing setting; changes are persisted automatically:
268
+
269
+ - **Documentation directory** — `docs-dir` (default `pi-usereq/docs`) used for the canonical documents.
270
+ - **Unit tests directory** — `tests-dir` (default `tests`).
271
+ - **Source directories** — `src-dir` (default `["src"]`) used by the analysis tools.
272
+ - **Context Files** — toggles to inject `REQUIREMENTS.md`, `WORKFLOW.md`, and `REFERENCES.md` into the prompt context through `%%CONTEXT_FILES%%`.
273
+ - **Auto git commit** — `enable` (default) injects git commit instructions into every prompt; `disable` forces read-only git behavior (`git_read-only.md`) and turns worktree orchestration off.
274
+ - **Git worktree** / **Worktree prefix** — enable/disable prompt-command worktree isolation and set the name prefix (default `PI-useReq-`).
275
+ - **Language static code checkers** — per-language `enable`/`disable` flags and the global `Command`-module checker definitions (view/remove/reset with confirmation).
276
+ - **Enable tools** — the subset of configurable startup tools activated for the project (`files-*` and project tools plus the embedded `read`, `bash`, `edit`, `write` quartet).
277
+ - **Notifications** — command-notify, sound, and Pushover settings with per-event routing (completed/interrupted/failed).
278
+ - **Debug** — local debug logging: log file, log-on-status filter, status-change/workflow-event toggles, enabled tools/prompts, and `Enable debug commands for tools`.
279
+ - **Show local/global configuration** — write the exact config file contents into the editor.
280
+ - **Reset defaults** — restore the default configuration with a confirmation preview.
281
+
231
282
  ### Extension Side Features
232
283
 
233
- TODO: complete with extension side defatures
284
+ #### Sound
234
285
 
235
- #### Sound
286
+ The extension plays a bundled sound effect when a prompt ends (completed, interrupted, or failed - each event is independently toggleable).
236
287
 
237
- TODO: complete with sound extension feature description
288
+ - Sound levels: `none` → `low` → `mid` → `high`.
289
+ - Default toggle shortcut: `alt+s` (cycles the active runtime level; configurable via `notify-sound-toggle-shortcut`).
290
+ - Each level maps to a configurable shell command; the defaults use `paplay` on the bundled `Soft-high-tech-notification-sound-effect.mp3` with the `%%INSTALLATION_PATH%%` keyword resolved to the installed extension path.
238
291
 
239
- ## Note on Git usage
292
+ #### Notifications
240
293
 
241
- TODO: review and rewrite git section according extension features.
294
+ - **Command notify** — a configurable desktop-notification command (`PI_NOTIFY_CMD`) run when the selected prompt-end events occur.
295
+ - **Pushover** — optional Pushover push notifications (`notify-pushover-*`): user key, API token, priority, title, and text template; disabled until both credentials are set.
242
296
 
243
- This section describes the Git behavior when executing the commands provided by the scripts.
297
+ #### Status Bar
244
298
 
245
- - Required state before execution:
246
- - Execute commands from a working branch (not in detached HEAD).
247
- - Preferably, the working tree should be clean: avoid unintended changes in the repository before starting the scripts.
248
- - Save all files and verify that you are in the correct project directory.
249
- - **IMPORTANT:** in clude on repository the directory configured in the extension.
250
-
251
- - What the scripts do to the repository:
252
- - The scripts may modify, create, or remove files in the working tree (files on disk).
253
- - They do not modify Git history (HEAD), branches, or tags automatically.
254
- - The index (staging area) and history remain unchanged until the user manually performs staging/commit operations.
255
-
256
- - How to commit (recommended practice):
257
- - Review changes generated by the scripts before including them in a commit.
258
- - Manually add files to commit using `git add <file...>`.
259
- - Execute the commit with a structured message, for example:
260
- `git commit -m "change(<COMPONENT>): <SHORT-DESCRIPTION> [<DATE>]"`.
261
- - Staging and commit operations are under the user's control; the scripts do not perform automatic commits or update Git references.
262
-
263
- - Practical warnings:
264
- - Do not use destructive commands (e.g., `git reset --hard`, `git clean -fd`) to "clean" the repository without verifying the impact.
265
- - If you prefer to isolate changes, execute commands in a branch or a copy of the repository.
299
+ The extension renders a status field in the pi status line showing: extension identity, workflow state (`idle`/`checking`/`running`/`merging`/`error`), current branch, context usage, elapsed run time, and the active sound level.
300
+
301
+ #### Debug
302
+
303
+ - Config-gated slash commands that run the project tools and write the output into the editor: `debug-compress`, `debug-references`, `debug-static-check`, `debug-summarize`, `debug-tokens`.
304
+ - Standalone debug harness: `scripts/pi-usereq-debug.sh` (bash wrapper) and `scripts/debug-extension.ts` with subcommands `inspect`, `session-start`, `command`, `tool`, and `sdk-smoke`.
305
+ - Debug logging writes to the configured `DEBUG_LOG_FILE`, filtered by prompt/tool name and workflow status.
266
306
 
307
+
308
+ ## Note on Git usage
309
+
310
+ This section describes the Git behavior of the `req-*` commands. The commands own their git workflow: validation happens before dispatch and finalization happens at the end of each run.
311
+
312
+ - Required state before execution:
313
+ - The project must be inside a git work tree with a **clean tracked working tree** (`git status --porcelain` empty; the configured debug-log file is ignored by the validation).
314
+ - `HEAD` must resolve. A working branch is recommended: the current branch name is embedded in the generated worktree names (it falls back to `unknown` on a detached `HEAD`).
315
+ - All files must be saved and you must be in the correct project directory.
316
+
317
+ - What the commands do to the repository:
318
+ - Each `req-*` prompt command runs git validation and the required-document checks, then (when `Auto git commit` and `Git worktree` are enabled) creates an isolated **git worktree and branch** named `<GIT_WORKTREE_PREFIX><project>-<branch>-<YYYYMMDDHHMMSS>` (default prefix `PI-useReq-`), switches the session into it, and executes the prompt there.
319
+ - On success the extension restores the original `base-path` session, applies a stash-assisted fast-forward merge of the worktree branch, and deletes the worktree and branch.
320
+ - On failure or interruption the worktree and branch are **kept** and the workflow is parked in the `error` state so the produced artifacts can be inspected or recovered: run `/req-reset` to restore the original base path and force-remove the generated worktrees and branches.
321
+ - With `Auto git commit = enable` (default), every prompt receives structured commit instructions and commits follow the message template `<TYPE>(<COMPONENT>)<BREAKING>: <DESCRIPTION> [useReq]`. With `Auto git commit = disable`, prompts receive a read-only git restriction and worktree orchestration is forced off.
322
+ - The extension never rewrites history and never runs destructive cleanup on your behalf.
323
+
324
+ - Recommended practice:
325
+ - Review the changes produced by each command before pushing them.
326
+ - Do not use destructive commands (e.g., `git reset --hard`, `git clean -fd`) to "clean" the repository without verifying the impact; prefer `/req-reset` for worktree cleanup after failed runs.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-usereq",
3
- "version": "0.55.0",
3
+ "version": "0.56.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/Ogekuri/PI-useReq.git"
@@ -116,6 +116,47 @@ function getGitAddTargetPath(gitRoot: string, absolutePath: string): string {
116
116
  return relativePath.split(path.sep).join("/");
117
117
  }
118
118
 
119
+ /**
120
+ * @brief Detects whether the git index holds staged differences for the given target paths.
121
+ * @details Executes `git diff --cached --quiet -- <paths>`; exit code `1` signals at least one staged difference, exit code `0` signals no staged difference for the target paths, and any other status or spawn failure is converted into a deterministic `ReqError`. Runtime is dominated by one git subprocess. Side effects include subprocess creation. No index or worktree mutation occurs.
122
+ * @param[in] gitRoot {string} Absolute git root path.
123
+ * @param[in] targetPaths {string[]} Git-add target paths inspected in the cached index.
124
+ * @return {boolean} `true` when at least one staged difference exists for the target paths.
125
+ * @throws {ReqError} Throws when staged-difference inspection fails.
126
+ * @satisfies REQ-357
127
+ */
128
+ function hasStagedChangesForPaths(gitRoot: string, targetPaths: string[]): boolean {
129
+ const diffResult = runCapture(["git", "diff", "--cached", "--quiet", "--", ...targetPaths], gitRoot);
130
+ if (diffResult.error || diffResult.status === null || diffResult.status < 0 || diffResult.status > 1) {
131
+ throw new ReqError("ERROR: Unable to inspect staged changes before git commit.", 1);
132
+ }
133
+ return diffResult.status === 1;
134
+ }
135
+
136
+ /**
137
+ * @brief Executes one guarded `git commit` invocation for the staged target paths.
138
+ * @details Runs a staged-changes precheck against the cached index and returns without creating a commit when no staged difference exists for the target paths, preventing empty-commit failures such as `nothing to commit, working tree clean`. When a staged difference exists, delegates to `git commit -m <commitMessage>` and converts any non-zero result into a deterministic `ReqError`. Runtime is dominated by up to two git subprocesses. Side effects include subprocess creation and conditional commit creation.
139
+ * @param[in] gitRoot {string} Absolute git root path.
140
+ * @param[in] targetPaths {string[]} Git-add target paths inspected by the staged-changes precheck.
141
+ * @param[in] commitMessage {string} Commit message used when a staged difference exists.
142
+ * @return {void} No return value.
143
+ * @throws {ReqError} Throws when staged-difference inspection or commit creation fails.
144
+ * @satisfies REQ-357, REQ-358
145
+ */
146
+ function runGuardedGitCommit(gitRoot: string, targetPaths: string[], commitMessage: string): void {
147
+ if (!hasStagedChangesForPaths(gitRoot, targetPaths)) {
148
+ return;
149
+ }
150
+ const commitResult = runCapture(["git", "commit", "-m", commitMessage], gitRoot);
151
+ if (commitResult.error || commitResult.status !== 0) {
152
+ const diagnostic = commitResult.stderr.trim()
153
+ || commitResult.stdout.trim()
154
+ || commitResult.error?.message
155
+ || "unknown error";
156
+ throw new ReqError(`ERROR: git commit failed: ${diagnostic}`, 1);
157
+ }
158
+ }
159
+
119
160
  /**
120
161
  * @brief Prepares the specialized `req-references` execution plan.
121
162
  * @details Reuses slash-command-owned git validation, resolves the configured references document path, and returns the fixed commit metadata consumed by the direct-write workflow. Runtime is dominated by git validation subprocesses. Side effects include subprocess creation delegated through `validatePromptGitState(...)`.
@@ -142,12 +183,12 @@ export function prepareReqReferencesCommandExecution(
142
183
 
143
184
  /**
144
185
  * @brief Executes the specialized `req-references` direct-write workflow.
145
- * @details Regenerates `REFERENCES.md` through the same source-summary path used by the `references` tool, stages only the target file, creates the fixed-message commit, and verifies that no residual git-status rows remain after ignored extension-owned debug artifacts are filtered out. Runtime is dominated by summary generation plus three git subprocesses. Side effects include documentation writes, index mutation, commit creation, and subprocess creation.
186
+ * @details Regenerates `REFERENCES.md` through the same source-summary path used by the `references` tool, stages only the target file, creates the fixed-message commit through the guarded commit helper whenever a staged difference exists, and verifies that no residual git-status rows remain after ignored extension-owned debug artifacts are filtered out. Runtime is dominated by summary generation plus two to four git subprocesses. Side effects include documentation writes, index mutation, conditional commit creation, and subprocess creation.
146
187
  * @param[in] plan {ReqReferencesCommandPlan} Prepared direct-write execution plan.
147
188
  * @param[in] config {UseReqConfig} Effective project configuration.
148
189
  * @return {void} No return value.
149
- * @throws {ReqError} Throws when reference generation, staging, commit creation, or cleanliness verification fails.
150
- * @satisfies REQ-300, REQ-301, REQ-302, REQ-303
190
+ * @throws {ReqError} Throws when reference generation, staging, guarded commit creation, or cleanliness verification fails.
191
+ * @satisfies REQ-300, REQ-301, REQ-302, REQ-303, REQ-357, REQ-358
151
192
  */
152
193
  export function executeReqReferencesCommandExecution(
153
194
  plan: ReqReferencesCommandPlan,
@@ -160,14 +201,7 @@ export function executeReqReferencesCommandExecution(
160
201
  const diagnostic = addResult.stderr.trim() || addResult.error?.message || "unknown error";
161
202
  throw new ReqError(`ERROR: git add failed for ${addTargetPath}: ${diagnostic}`, 1);
162
203
  }
163
- const commitResult = runCapture(["git", "commit", "-m", plan.commitMessage], plan.gitPath);
164
- if (commitResult.error || commitResult.status !== 0) {
165
- const diagnostic = commitResult.stderr.trim()
166
- || commitResult.stdout.trim()
167
- || commitResult.error?.message
168
- || "unknown error";
169
- throw new ReqError(`ERROR: git commit failed: ${diagnostic}`, 1);
170
- }
204
+ runGuardedGitCommit(plan.gitPath, [addTargetPath], plan.commitMessage);
171
205
  const residualStatusLines = listResidualGitStatusLines(plan.basePath, plan.gitPath, config);
172
206
  if (residualStatusLines.length > 0) {
173
207
  throw new ReqError("ERROR: Git repository is not clean after req-references commit.", 1);