@pmelab/gtd 7.6.0 → 7.6.2
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/bin/gtd +15 -5
- package/docs/loop.md +8 -4
- 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 "$(
|
|
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 "$(
|
|
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="$(
|
|
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
|
-
`"$(
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
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
|
|