@pmelab/gtd 7.6.0 → 7.6.1

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/bin/gtd +15 -5
  2. package/docs/loop.md +8 -4
  3. package/package.json +1 -1
package/bin/gtd CHANGED
@@ -184,15 +184,25 @@ report_commits() {
184
184
 
185
185
  # ── Log file (resolve_log_path, gtd log) ────────────────────────────────────
186
186
 
187
+ # worktree_git_dir — the git dir of the working tree gtd is operating in,
188
+ # derived purely from the cwd. GIT_DIR/GIT_WORK_TREE are scrubbed for this one
189
+ # call so an inherited GIT_DIR (e.g. leaked from a parent git process, a hook,
190
+ # or another worktree's shell) can never point our per-worktree state at a
191
+ # DIFFERENT worktree — that would let two concurrently looping worktrees
192
+ # collide on one log/memory file. A linked worktree's git-dir is its own
193
+ # private .git/worktrees/<name>, so this is per-repository AND per-worktree.
194
+ worktree_git_dir() {
195
+ env -u GIT_DIR -u GIT_WORK_TREE -u GIT_COMMON_DIR -u GIT_INDEX_FILE \
196
+ git rev-parse --git-dir
197
+ }
198
+
187
199
  # resolve_log_path — echoes the loop's logfile path: $GTD_LOOP_LOG verbatim if
188
- # set, else "$(git rev-parse --git-dir)/gtd-loop.log" (per-repository AND
189
- # per-worktree automatically, since a linked worktree's git-dir is its own
190
- # private .git/worktrees/<name>).
200
+ # set, else "$(worktree_git_dir)/gtd-loop.log".
191
201
  resolve_log_path() {
192
202
  if [[ -n "${GTD_LOOP_LOG:-}" ]]; then
193
203
  echo "$GTD_LOOP_LOG"
194
204
  else
195
- echo "$(git rev-parse --git-dir)/gtd-loop.log"
205
+ echo "$(worktree_git_dir)/gtd-loop.log"
196
206
  fi
197
207
  }
198
208
 
@@ -385,7 +395,7 @@ prev_state=""
385
395
  prev_content=""
386
396
  # Where the last "prompt" turn's `memory` scope + session id are remembered
387
397
  # across iterations and across restarts. In the git dir, never the work tree.
388
- memory_marker="$(git rev-parse --git-dir 2>/dev/null || echo .git)/gtd-loop-memory"
398
+ memory_marker="$(worktree_git_dir 2>/dev/null || echo .git)/gtd-loop-memory"
389
399
 
390
400
  # Truncated once here (not every iteration), so the file always reflects the
391
401
  # current run but survives after the loop exits for a later `gtd log`.
package/docs/loop.md CHANGED
@@ -165,10 +165,14 @@ The driver — not the prompt text — owns ending the agent's turn
165
165
  prompt says explicitly not to run `gtd step agent` itself.
166
166
 
167
167
  `bin/gtd log` opens the current repo/worktree's loop logfile —
168
- `"$(git rev-parse --git-dir)/gtd-loop.log"` by default, or `$GTD_LOOP_LOG`
169
- verbatim when set — in `${VISUAL:-$EDITOR}`, the same editor resolution
170
- `bin/gtd edit` uses. It takes no arguments and errors out (rather than opening
171
- an empty buffer) if no loop has produced a log yet.
168
+ `"$(worktree_git_dir)/gtd-loop.log"` by default, or `$GTD_LOOP_LOG` verbatim
169
+ when set — in `${VISUAL:-$EDITOR}`, the same editor resolution `bin/gtd edit`
170
+ uses. It takes no arguments and errors out (rather than opening an empty buffer)
171
+ if no loop has produced a log yet. `worktree_git_dir` derives the git dir from
172
+ the cwd with `GIT_DIR`/`GIT_WORK_TREE` scrubbed, so an inherited `GIT_DIR`
173
+ (leaked from a parent git process, a hook, or another worktree's shell) can
174
+ never key the log — or the loop's memory marker — to a different worktree; two
175
+ worktrees looping at once each keep their own log.
172
176
 
173
177
  ## Rendered output and logging
174
178
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pmelab/gtd",
3
- "version": "7.6.0",
3
+ "version": "7.6.1",
4
4
  "private": false,
5
5
  "description": "Git-aware CLI that emits the next prompt for an autonomous coding agent based on the current repository state",
6
6
  "bin": {