diff --git a/repl.lua b/repl.lua index 03a6eb9..dbb0c3c 100644 --- a/repl.lua +++ b/repl.lua @@ -151,6 +151,8 @@ Meta commands: :tree [] scan cwd file-tree, inject as [project] block in system prompt :tree refresh re-scan with last opts (or config defaults) :tree off clear the [project] block + :diff [] git diff -> inject as [diff ...] exec_output + examples: :diff :diff --cached :diff main..feature :delegate

one-shot sub-broker call to preset

; prints reply :help this message ]] @@ -684,6 +686,15 @@ function M.run(config) end end + -- Phase 6 (B1): every git invocation that flows back into context + -- MUST suppress git's interactive pager + color output. Forkpty + -- makes git think stdout is a TTY, which enables both. Helper + -- prepends `git --no-pager -c color.ui=never `; + -- used by :diff and the @.. @-mention path in commit #4. + local function _git_clean_cmd(subcmd_and_args) + return "git --no-pager -c color.ui=never " .. subcmd_and_args + end + -- Phase 6 (§6 + N4): project file-tree scanner. Prefers -- `git -C

ls-files --cached --others --exclude-standard` -- when is inside a git repo (free .gitignore honor); @@ -1763,6 +1774,29 @@ function M.run(config) -- :tree scan with depth=N; cached as _project_opts -- :tree refresh re-scan with cached opts; else config defaults -- :tree off clear ctx.project AND ctx._project_opts + -- Phase 6: :diff meta — `git diff ` (B1-clean), appends as + -- [diff ]\n exec_output. Reads cwd at invocation + -- time (R6: differs from :tree's scan-time cwd capture). Empty + -- diff or git failure emits status and skips — never pollutes + -- context with empty or error noise. + meta.diff = function(args) + args = (args or ""):gsub("^%s+", ""):gsub("%s+$", "") + local cmd = _git_clean_cmd("diff " .. args) + local out, code = executor.exec(cmd) + if code ~= 0 then + renderer.status(("diff failed (exit %d): %s") + :format(code, args == "" and "(working tree)" or args)) + return + end + if not out or out:gsub("%s", "") == "" then + renderer.status(("(no diff): %s"):format( + args == "" and "(working tree)" or args)) + return + end + local label = args == "" and "(working tree)" or args + ctx:append_exec_output(("[diff %s]\n%s"):format(label, out)) + renderer.status(("diff injected: %s (%d bytes)"):format(label, #out)) + end meta.tree = function(args) local sub = (args or ""):match("^%s*(%S*)") or "" if sub == "off" then