feat(gptel): store plans outside project directory
This commit is contained in:
@@ -18,8 +18,9 @@ Agentes y prompts internos para `gptel-agent`, portados de [opencode](https://op
|
|||||||
(el último dir gana) sobreescriba los agentes por defecto del paquete `gptel-agent`.
|
(el último dir gana) sobreescriba los agentes por defecto del paquete `gptel-agent`.
|
||||||
- Los `{{AGENTS}}`/`{{SKILLS}}` del cuerpo se expanden automáticamente por `gptel-agent`.
|
- Los `{{AGENTS}}`/`{{SKILLS}}` del cuerpo se expanden automáticamente por `gptel-agent`.
|
||||||
- Las tools LSP (`lsp_diagnostics` y `lsp_symbols`, basadas en eglot/flymake),
|
- Las tools LSP (`lsp_diagnostics` y `lsp_symbols`, basadas en eglot/flymake),
|
||||||
`apply_patch` (diff unificado vía `patch`) y `plan_write` (guarda planes en
|
`apply_patch` (diff unificado vía `patch`) y `plan_write` (guarda planes
|
||||||
`.gptel/plans/`) se definen en `configs/init-ai.el` y se referencian desde los
|
fuera del proyecto, en `kj-gptel-plans-dir` con nombre `<hash>--<proyecto>--<plan>.md`)
|
||||||
|
se definen en `configs/init-ai.el` y se referencian desde los
|
||||||
agentes correspondientes.
|
agentes correspondientes.
|
||||||
- `confirm-tool-calls`: build y general usan `auto` (confirmación por tool);
|
- `confirm-tool-calls`: build y general usan `auto` (confirmación por tool);
|
||||||
plan y explore usan `false` (solo lectura, sin confirmar cada lectura).
|
plan y explore usan `false` (solo lectura, sin confirmar cada lectura).
|
||||||
|
|||||||
@@ -203,6 +203,15 @@ content do not break gptel-magit."
|
|||||||
nil uses the current session's model."
|
nil uses the current session's model."
|
||||||
:type '(choice (const :tag "Current session model" nil) string)
|
:type '(choice (const :tag "Current session model" nil) string)
|
||||||
:group 'gptel)
|
:group 'gptel)
|
||||||
|
|
||||||
|
(defcustom kj-gptel-plans-dir
|
||||||
|
(expand-file-name "gptel-plans" user-emacs-directory)
|
||||||
|
"Directory where gptel-agent plans are stored, outside the project.
|
||||||
|
Plans are named <hash>--<project>--<name>.md, where <hash> is a
|
||||||
|
truncated md5 of the project root, so plans never pollute the project
|
||||||
|
directory and can be mapped back to their project."
|
||||||
|
:type 'directory
|
||||||
|
:group 'gptel)
|
||||||
(defun kj-gptel-load-agents-md ()
|
(defun kj-gptel-load-agents-md ()
|
||||||
"Add AGENTS.md rules to the current gptel buffer context.
|
"Add AGENTS.md rules to the current gptel buffer context.
|
||||||
Loads AGENTS.md from the project root and from `user-emacs-directory',
|
Loads AGENTS.md from the project root and from `user-emacs-directory',
|
||||||
@@ -406,11 +415,20 @@ Tries `patch -p1' first and falls back to `-p0'."
|
|||||||
(car r1) (cdr r1)))))))
|
(car r1) (cdr r1)))))))
|
||||||
|
|
||||||
(defun kj-gptel-plan-write (filename content)
|
(defun kj-gptel-plan-write (filename content)
|
||||||
"Write CONTENT to `.gptel/plans/FILENAME' in the project. Return status."
|
"Write CONTENT to a plan file for the current project and return status.
|
||||||
|
Plans are stored in `kj-gptel-plans-dir' (outside the project), named
|
||||||
|
<md5-prefix>--<project>--<name>.md so that each project keeps its own
|
||||||
|
plans without adding extra files to the project directory."
|
||||||
(let* ((root (kj-gptel--project-root))
|
(let* ((root (kj-gptel--project-root))
|
||||||
(dir (expand-file-name ".gptel/plans" root))
|
(hash (substring (md5 root) 0 12))
|
||||||
(file (expand-file-name (file-name-nondirectory filename) dir)))
|
(project (replace-regexp-in-string
|
||||||
(make-directory dir t)
|
"[^A-Za-z0-9._-]" "-"
|
||||||
|
(file-name-nondirectory (directory-file-name root))))
|
||||||
|
(name (file-name-nondirectory filename))
|
||||||
|
(file (expand-file-name
|
||||||
|
(format "%s--%s--%s" hash project name)
|
||||||
|
kj-gptel-plans-dir)))
|
||||||
|
(make-directory kj-gptel-plans-dir t)
|
||||||
(with-temp-file file (insert content))
|
(with-temp-file file (insert content))
|
||||||
(format "Plan saved to %s" file)))
|
(format "Plan saved to %s" file)))
|
||||||
|
|
||||||
@@ -584,9 +602,9 @@ Takes a unified diff (git format or --- a/ / +++ b/). It is applied with the pat
|
|||||||
(gptel-make-tool
|
(gptel-make-tool
|
||||||
:name "plan_write"
|
:name "plan_write"
|
||||||
:function #'kj-gptel-plan-write
|
:function #'kj-gptel-plan-write
|
||||||
:description "Save the current plan as a Markdown file in .gptel/plans/ of the project.
|
:description "Save the current plan as a Markdown file in the Emacs directory, outside the project.
|
||||||
|
|
||||||
Use it when you have drafted a plan, to persist it to disk and be able to resume it later. Saves the content to .gptel/plans/<name>.md. Does not modify any other file."
|
Use it when you have drafted a plan, to persist it to disk and be able to resume it later. Plans are stored in `kj-gptel-plans-dir' (inside the Emacs directory) named <hash>--<project>--<name>.md, where <hash> is a truncated md5 of the project root, so each project keeps its own plans without adding files to the project directory. Does not modify any project file."
|
||||||
:args '((:name "filename"
|
:args '((:name "filename"
|
||||||
:type string
|
:type string
|
||||||
:description "Name of the plan file (e.g. refactor-auth.md).")
|
:description "Name of the plan file (e.g. refactor-auth.md).")
|
||||||
|
|||||||
Reference in New Issue
Block a user