Add per-file regex
This commit is contained in:
parent
cbf784b1a7
commit
399039e980
2 changed files with 122 additions and 52 deletions
92
README.org
92
README.org
|
@ -138,7 +138,7 @@ I don't think there's much reason to ever allow partial results, which leads me
|
|||
|
||||
(defun gptel-org-tools--result-limit (result)
|
||||
(if (>= (length (format "%s" result)) gptel-org-tools-result-limit)
|
||||
(format "Results over %s character. Please try with a more specific query." gptel-org-tools-result-limit)
|
||||
(format "Results over %s character. Stop. Analyze. Find a different solution, or use a more specific query." gptel-org-tools-result-limit)
|
||||
result))
|
||||
|
||||
|
||||
|
@ -238,7 +238,7 @@ Not using ~ibuffer~ to avoid customization differences between users. Argument r
|
|||
:description "Does nothing."
|
||||
:optional t))
|
||||
:category "emacs"
|
||||
:description "List buffers open in Emacs, including file names and full paths. After using this, evaluate which files are most likely to be relevant to the user's request."))
|
||||
:description "List buffers open in Emacs, including file names and full paths. After using this, stop. Then evaluate which files are most likely to be relevant to the user's request."))
|
||||
#+end_src
|
||||
|
||||
**** dired
|
||||
|
@ -261,7 +261,7 @@ You can customize the function to point to your org directory, if you wish. I'm
|
|||
(gptel-make-tool
|
||||
:function #'gptel-org-tools--dir
|
||||
:name "gptel-org-tools--dir"
|
||||
:description "List directory contents."
|
||||
:description "List directory contents. After using this, stop. Evaluate for relevance. Then use your findings to fulfill user's request."
|
||||
:args (list '(:name "dir"
|
||||
:type string
|
||||
:description "Directory path"
|
||||
|
@ -304,7 +304,7 @@ Opens a file into an inactive (background) buffer for processing.
|
|||
(gptel-make-tool
|
||||
:function #'gptel-org-tools--open-file-inactive
|
||||
:name "gptel-org-tools--open-file-inactive"
|
||||
:description "Open the file in a background buffer. This doesn't interfere with the user."
|
||||
:description "Open the file in a background buffer. This doesn't interfere with the user. After calling this tool, stop. Then continue fulfilling user's request."
|
||||
:args (list '(:name "file"
|
||||
:type string
|
||||
:description "Path to file.."))
|
||||
|
@ -324,7 +324,7 @@ Opens a file into an inactive (background) buffer for processing.
|
|||
(gptel-make-tool
|
||||
:function #'gptel-org-tools--read-file-contents
|
||||
:name "gptel-org-tools--read-file-contents"
|
||||
:description "Reads and return the contents of a specified file."
|
||||
:description "Reads and return the contents of a specified file. After calling this tool, stop. Then continue fulfilling user's request."
|
||||
:args (list '(:name "filename"
|
||||
:type string
|
||||
:description "The filename to read."))
|
||||
|
@ -338,13 +338,13 @@ Opens a file into an inactive (background) buffer for processing.
|
|||
(let ((symbol (intern var)))
|
||||
(if (boundp symbol)
|
||||
(prin1-to-string (symbol-value symbol))
|
||||
(format "Variable %s is not bound. This means the variable doesn't exist. Reassess what you're trying to do, examine the situation, and continue. " var))))
|
||||
(format "Variable %s is not bound. This means the variable doesn't exist. Stop. Reassess what you're trying to do, examine the situation, and continue. " var))))
|
||||
|
||||
(add-to-list 'gptel-org-tools
|
||||
(gptel-make-tool
|
||||
:function #'gptel-org-tools--describe-variable
|
||||
:name "gptel-org-tools--describe-variable"
|
||||
:description "Returns variable contents."
|
||||
:description "Returns variable contents. After calling this tool, stop. Evaluate if the result helps. Then continue fulfilling user's request."
|
||||
:args (list '(:name "var"
|
||||
:type string
|
||||
:description "Variable name"))
|
||||
|
@ -364,7 +364,7 @@ Opens a file into an inactive (background) buffer for processing.
|
|||
(gptel-make-tool
|
||||
:function #'gptel-org-tools--describe-function
|
||||
:name "gptel-org-tools--describe-function"
|
||||
:description "Returns function description"
|
||||
:description "Returns function description. After calling this tool, stop. Evaluate if the result helps. Then continue fulfilling user's request."
|
||||
:args (list '(:name "fun"
|
||||
:type string
|
||||
:description "Function name"
|
||||
|
@ -408,7 +408,7 @@ LLMs are not intelligent, despite claims to the contrary.
|
|||
:type string
|
||||
:description "The Org buffer to extract tags from."))
|
||||
:category "org-mode"
|
||||
:description "Returns all tags from an org-mode buffer. When using this, evaluate the relevance of each tag to the user's request."))
|
||||
:description "Returns all tags from an org-mode buffer. When using this, evaluate the relevance of each tag to the user's request. After calling this tool, stop. Then continue fulfilling user's request."))
|
||||
#+end_src
|
||||
**** org-extract-headings
|
||||
#+begin_src elisp
|
||||
|
@ -426,7 +426,7 @@ LLMs are not intelligent, despite claims to the contrary.
|
|||
(gptel-make-tool
|
||||
:function #'gptel-org-tools--org-extract-headings
|
||||
:name "gptel-org-tools--org-extract-headings"
|
||||
:description "Returns all headings from an org-mode buffer. After using this, evaluate the relevance of the headings to the user's request."
|
||||
:description "Returns all headings from an org-mode buffer. After using this, stop. Then evaluate the relevance of the headings to the user's request. Then continue."
|
||||
:args (list '(:name "buffer"
|
||||
:type string
|
||||
:description "The Org buffer to extract headings from."))
|
||||
|
@ -462,7 +462,7 @@ QUERY can be any valid org-ql-select query."
|
|||
:type string
|
||||
:description "The query to pass into org-ql-select. See org-ql documentation for syntax. Usually `(tags \"tag1\" \"tag2\")` is sufficient. Possible predicates: `tags` (finds both local and inherited tags), `tags-local` (finds only local tags), `rifle` (matches against both heading and body text). This is a sexp, not a string."))
|
||||
:category "org"
|
||||
:description "Return entries matching QUERY from BUFFER.."))
|
||||
:description "Return entries matching QUERY from BUFFER. After using this, stop. Then evaluate the relevance of the results to the user's request. Then continue."))
|
||||
#+end_src
|
||||
**** Somewhat working tools
|
||||
***** org-ql-select-by-date
|
||||
|
@ -493,16 +493,17 @@ DATE is the date or date range to match."
|
|||
(if (bufferp buffer)
|
||||
(if (eq mode 'org-mode)
|
||||
(let ((result
|
||||
(concat
|
||||
(org-ql-select buffer
|
||||
`(heading ,date)
|
||||
:action #'gptel-org-tools--heading-subtree)
|
||||
"Results end here. Proceed with the next action.")))
|
||||
(gptel-org-tools--result-limit result))
|
||||
:action #'gptel-org-tools--heading-subtree)))
|
||||
(concat (gptel-org-tools--result-limit result) "Results end here. Proceed with the next action."))
|
||||
(message "Buffer '%s' isn't an org-mode buffer." buf))
|
||||
(message "Buffer '%s' does not exist." buf))))
|
||||
#+end_src
|
||||
|
||||
#+RESULTS:
|
||||
: gptel-org-tools--org-ql-select-date
|
||||
|
||||
#+begin_src elisp
|
||||
(add-to-list 'gptel-org-tools
|
||||
(gptel-make-tool
|
||||
|
@ -518,7 +519,9 @@ DATE is the date or date range to match."
|
|||
:description "Returns all timestamped headings and all of their subheadings matching query. Query may be: YYYY, YYYY-MM, YYYY-MM-DD.
|
||||
Examples:
|
||||
- \"YYYY\": gets all entries from year YYYY
|
||||
- \"YYYY-MM\": gets all entries from month MM of year YYYY"))
|
||||
- \"YYYY-MM\": gets all entries from month MM of year YYYY
|
||||
|
||||
After using this, stop. Then evaluate the relevance of the entries to the user's request. Then continue."))
|
||||
#+end_src
|
||||
|
||||
***** org-agenda-seek
|
||||
|
@ -542,7 +545,10 @@ It works, in principle, but I haven't been able to find a use for it yet. The re
|
|||
:type integer
|
||||
:description "Days. Positive = future. Negative = past. Default: 14"))
|
||||
:category "org"
|
||||
:description "Return user's agenda (tasking) spanning X days from the current moment. This can be used to get all agenda tasks that are due or scheduled in the next X days, or in the past X days, depending on whether the days argument is positive or negative. Example: get all agenda tasks due in the next 7 days: \"7\""))
|
||||
:description "Return user's agenda (tasking) spanning X days from the current moment. Example:
|
||||
- Get all tasks due in the next 7 days: \"7\"
|
||||
- Get all tasks in the last 14 days: \"-14\"
|
||||
After using this, stop. Evaluate the relevance of the results. Then continue."))
|
||||
#+end_src
|
||||
**** Completely WIP tools
|
||||
***** org-ql-select-headings
|
||||
|
@ -559,7 +565,7 @@ Retrieve the headings where the heading matches query. This is very much the sam
|
|||
(get-buffer buf)
|
||||
`(heading ,query)
|
||||
:action #''gptel-org-tools--heading)))
|
||||
(gptel-org-tools--result-limit result))
|
||||
(concat (gptel-org-tools--result-limit result) "Results end here. Proceed with the next action."))
|
||||
(message "Buffer '%s' isn't an org-mode buffer." buf))
|
||||
(message "Buffer '%s' does not exist." buf))))
|
||||
|
||||
|
@ -596,7 +602,7 @@ Retrieve all the headings where either heading or content matches query.
|
|||
(gptel-make-tool
|
||||
:function #'gptel-org-tools--org-ql-select-headings-rifle
|
||||
:name "gptel-org-tools--org-ql-select-headings-rifle"
|
||||
:description "Returns headings matching QUERY from BUFFER. Matches against both heading and content, but only returns headings. After using this, continue completing user's request."
|
||||
:description "Returns headings matching QUERY from BUFFER. Matches against both heading and content, but only returns headings. After using this, stop. Evaluate results. Then continue completing user's request."
|
||||
:args (list '(:name "buffer"
|
||||
:type string
|
||||
:description "The name of the buffer. See the NAME column in ~list-buffers~.")
|
||||
|
@ -636,7 +642,7 @@ This pulls all the headings (and their contents) when they match tags (without i
|
|||
:type string
|
||||
:description "The string match entry tags against."))
|
||||
:category "org-ql"
|
||||
:description "Returns entries whose tags match QUERY from BUFFER, without tag inheritance. After using this, evaluate results for relevance, and proceed with completing user's request."))
|
||||
:description "Returns entries whose tags match QUERY from BUFFER, without tag inheritance. After using this, stop. Evaluate results for relevance, then proceed with completing user's request."))
|
||||
#+end_src
|
||||
|
||||
***** org-ql-select-tags-local-count
|
||||
|
@ -666,7 +672,7 @@ This pulls all the local tags (without inheritance) from buffer, and returns the
|
|||
:type string
|
||||
:description "The string match entry tags against."))
|
||||
:category "org-ql"
|
||||
:description "Returns count of entries tagged with tag QUERY from BUFFER, without tag inheritance."))
|
||||
:description "Returns count of entries tagged with tag QUERY from BUFFER, without tag inheritance. After using this, stop. Evaluate results. Then proceed."))
|
||||
#+end_src
|
||||
|
||||
***** org-ql-select-tags
|
||||
|
@ -698,7 +704,7 @@ This pulls all the headings (and their contents) when they match tags (with inhe
|
|||
:type string
|
||||
:description "The string to match entry headings against."))
|
||||
:category "org-ql"
|
||||
:description "Returns entries tagged QUERY from BUFFER, with tag inheritance."))
|
||||
:description "Returns entries tagged QUERY from BUFFER, with tag inheritance. After using this, stop. Evaluate results. Only then proceed."))
|
||||
#+end_src
|
||||
|
||||
***** org-ql-select-rifle
|
||||
|
@ -730,7 +736,39 @@ And, the "grab everything that matches" tool.
|
|||
:type string
|
||||
:description "A single string to search for."))
|
||||
:category "org-ql"
|
||||
:description "Returns entries (heading and body) matching QUERY from BUFFER. This may pull too many results, only use if other tools fail."))
|
||||
:description "Returns entries (heading and body) matching QUERY from BUFFER. This may pull too many results, only use if other tools fail. After using this, stop. Evaluate results. If necessary, re-plan. Only then proceed."))
|
||||
#+end_src
|
||||
|
||||
***** org-ql-select-regexp
|
||||
#+begin_src elisp
|
||||
(defun gptel-org-tools--org-ql-select-regexp (buf query)
|
||||
(let* ((buffer (get-buffer buf))
|
||||
(mode (buffer-local-value 'major-mode buffer)))
|
||||
(if buffer
|
||||
(if (eq mode 'org-mode)
|
||||
(let ((result
|
||||
(org-ql-select
|
||||
buffer
|
||||
`(regexp ,query)
|
||||
:action #'gptel-org-tools--heading-body)))
|
||||
(gptel-org-tools--result-limit result))
|
||||
(message "Buffer '%s' isn't an org-mode buffer." buf))
|
||||
(message "Buffer '%s' does not exist." buf))))
|
||||
|
||||
|
||||
(add-to-list 'gptel-org-tools
|
||||
(gptel-make-tool
|
||||
:function #'gptel-org-tools--org-ql-select-regexp
|
||||
:name "gptel-org-tools--org-ql-select-regexp"
|
||||
:description "Run regexp on ALL files at once."
|
||||
:args (list '(:name "buffer"
|
||||
:type string
|
||||
:description "The name of the buffer. See the NAME column in `list-buffers`. Using filename fails.")
|
||||
'(:name "query"
|
||||
:type string
|
||||
:description "Regexp, Emacs Lisp format. Automatically wrapped in a word boundary by the tool."))
|
||||
:category "org-ql"
|
||||
:description "Returns entries matching regexp QUERY from BUFFER. After using this, stop. Evaluate results for relevance, and proceed with completing user's request. The regexp *must* be in Emacs rx format!" ))
|
||||
#+end_src
|
||||
|
||||
***** org-ql-select-all-tags-local
|
||||
|
@ -755,7 +793,7 @@ This pulls all the headings (and their contents) when they match tags (without i
|
|||
:type string
|
||||
:description "A single word to scan for."))
|
||||
:category "org-ql"
|
||||
:description "Returns entries whose tags match QUERY from all files, without tag inheritance. After using this, evaluate results for relevance, and proceed with completing user's request."))
|
||||
:description "Returns entries whose tags match QUERY from all files, without tag inheritance. After using this, stop. Evaluate results. Then proceed with completing user's request."))
|
||||
#+end_src
|
||||
|
||||
***** org-ql-select-all-tags
|
||||
|
@ -780,7 +818,7 @@ with inheritance, in org-agenda-files.
|
|||
:type string
|
||||
:description "A simple (single) string to scan for."))
|
||||
:category "org-ql"
|
||||
:description "Returns entries whose tags match QUERY from BUFFER, with tag inheritance. After using this, evaluate results for relevance, and proceed with completing user's request."))
|
||||
:description "Returns entries whose tags match QUERY from BUFFER, with tag inheritance. After using this, stop. Evaluate results for relevance, and proceed with completing user's request."))
|
||||
#+end_src
|
||||
|
||||
***** org-ql-select-all-rifle
|
||||
|
@ -814,7 +852,7 @@ This means that /every org-mode file I have/ is part of this search. If you're u
|
|||
:type string
|
||||
:description "The string to match entry headings and content against."))
|
||||
:category "org-ql"
|
||||
:description "Returns entries matching QUERY from all files. After using this, evaluate results for relevance, and proceed with completing user's request." ))
|
||||
:description "Returns entries matching QUERY from all files. After using this, stop. Evaluate results for relevance, and proceed with completing user's request." ))
|
||||
#+end_src
|
||||
|
||||
|
||||
|
@ -839,7 +877,7 @@ This means that /every org-mode file I have/ is part of this search. If you're u
|
|||
:type string
|
||||
:description "Regexp, Emacs Lisp format. Automatically wrapped in a word boundary by the tool."))
|
||||
:category "org-ql"
|
||||
:description "Returns entries matching regexp QUERY from BUFFER. After using this, evaluate results for relevance, and proceed with completing user's request. The regexp *must* be in Emacs rx format!" ))
|
||||
:description "Returns entries matching regexp QUERY from all files. After using this, stop. Evaluate results for relevance, and proceed with completing user's request. The regexp *must* be in Emacs rx format!" ))
|
||||
#+end_src
|
||||
|
||||
** End
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
|
||||
(defun gptel-org-tools--result-limit (result)
|
||||
(if (>= (length (format "%s" result)) gptel-org-tools-result-limit)
|
||||
(format "Results over %s character. Please try with a more specific query." gptel-org-tools-result-limit)
|
||||
(format "Results over %s character. Stop. Analyze. Find a different solution, or use a more specific query." gptel-org-tools-result-limit)
|
||||
result))
|
||||
|
||||
(defun gptel-org-tools--heading ()
|
||||
|
@ -84,7 +84,7 @@
|
|||
:description "Does nothing."
|
||||
:optional t))
|
||||
:category "emacs"
|
||||
:description "List buffers open in Emacs, including file names and full paths. After using this, evaluate which files are most likely to be relevant to the user's request."))
|
||||
:description "List buffers open in Emacs, including file names and full paths. After using this, stop. Then evaluate which files are most likely to be relevant to the user's request."))
|
||||
|
||||
(defun gptel-org-tools--dir (dir)
|
||||
"Return directory listing."
|
||||
|
@ -98,7 +98,7 @@
|
|||
(gptel-make-tool
|
||||
:function #'gptel-org-tools--dir
|
||||
:name "gptel-org-tools--dir"
|
||||
:description "List directory contents."
|
||||
:description "List directory contents. After using this, stop. Evaluate for relevance. Then use your findings to fulfill user's request."
|
||||
:args (list '(:name "dir"
|
||||
:type string
|
||||
:description "Directory path"
|
||||
|
@ -116,7 +116,7 @@
|
|||
(gptel-make-tool
|
||||
:function #'gptel-org-tools--open-file-inactive
|
||||
:name "gptel-org-tools--open-file-inactive"
|
||||
:description "Open the file in a background buffer. This doesn't interfere with the user."
|
||||
:description "Open the file in a background buffer. This doesn't interfere with the user. After calling this tool, stop. Then continue fulfilling user's request."
|
||||
:args (list '(:name "file"
|
||||
:type string
|
||||
:description "Path to file.."))
|
||||
|
@ -127,13 +127,13 @@
|
|||
(let ((symbol (intern var)))
|
||||
(if (boundp symbol)
|
||||
(prin1-to-string (symbol-value symbol))
|
||||
(format "Variable %s is not bound. This means the variable doesn't exist. Reassess what you're trying to do, examine the situation, and continue. " var))))
|
||||
(format "Variable %s is not bound. This means the variable doesn't exist. Stop. Reassess what you're trying to do, examine the situation, and continue. " var))))
|
||||
|
||||
(add-to-list 'gptel-org-tools
|
||||
(gptel-make-tool
|
||||
:function #'gptel-org-tools--describe-variable
|
||||
:name "gptel-org-tools--describe-variable"
|
||||
:description "Returns variable contents."
|
||||
:description "Returns variable contents. After calling this tool, stop. Evaluate if the result helps. Then continue fulfilling user's request."
|
||||
:args (list '(:name "var"
|
||||
:type string
|
||||
:description "Variable name"))
|
||||
|
@ -150,7 +150,7 @@
|
|||
(gptel-make-tool
|
||||
:function #'gptel-org-tools--describe-function
|
||||
:name "gptel-org-tools--describe-function"
|
||||
:description "Returns function description"
|
||||
:description "Returns function description. After calling this tool, stop. Evaluate if the result helps. Then continue fulfilling user's request."
|
||||
:args (list '(:name "fun"
|
||||
:type string
|
||||
:description "Function name"
|
||||
|
@ -178,7 +178,7 @@
|
|||
:type string
|
||||
:description "The Org buffer to extract tags from."))
|
||||
:category "org-mode"
|
||||
:description "Returns all tags from an org-mode buffer. When using this, evaluate the relevance of each tag to the user's request."))
|
||||
:description "Returns all tags from an org-mode buffer. When using this, evaluate the relevance of each tag to the user's request. After calling this tool, stop. Then continue fulfilling user's request."))
|
||||
|
||||
(defun gptel-org-tools--org-extract-headings (buffer)
|
||||
"Return all headings from BUFFER."
|
||||
|
@ -194,7 +194,7 @@
|
|||
(gptel-make-tool
|
||||
:function #'gptel-org-tools--org-extract-headings
|
||||
:name "gptel-org-tools--org-extract-headings"
|
||||
:description "Returns all headings from an org-mode buffer. After using this, evaluate the relevance of the headings to the user's request."
|
||||
:description "Returns all headings from an org-mode buffer. After using this, stop. Then evaluate the relevance of the headings to the user's request. Then continue."
|
||||
:args (list '(:name "buffer"
|
||||
:type string
|
||||
:description "The Org buffer to extract headings from."))
|
||||
|
@ -211,12 +211,10 @@ DATE is the date or date range to match."
|
|||
(if (bufferp buffer)
|
||||
(if (eq mode 'org-mode)
|
||||
(let ((result
|
||||
(concat
|
||||
(org-ql-select buffer
|
||||
`(heading ,date)
|
||||
:action #'gptel-org-tools--heading-subtree)
|
||||
"Results end here. Proceed with the next action.")))
|
||||
(gptel-org-tools--result-limit result))
|
||||
:action #'gptel-org-tools--heading-subtree)))
|
||||
(concat (gptel-org-tools--result-limit result) "Results end here. Proceed with the next action."))
|
||||
(message "Buffer '%s' isn't an org-mode buffer." buf))
|
||||
(message "Buffer '%s' does not exist." buf))))
|
||||
|
||||
|
@ -234,7 +232,9 @@ DATE is the date or date range to match."
|
|||
:description "Returns all timestamped headings and all of their subheadings matching query. Query may be: YYYY, YYYY-MM, YYYY-MM-DD.
|
||||
Examples:
|
||||
- \"YYYY\": gets all entries from year YYYY
|
||||
- \"YYYY-MM\": gets all entries from month MM of year YYYY"))
|
||||
- \"YYYY-MM\": gets all entries from month MM of year YYYY
|
||||
|
||||
After using this, stop. Then evaluate the relevance of the entries to the user's request. Then continue."))
|
||||
|
||||
(defun gptel-org-tools--org-agenda-seek (days)
|
||||
"Return the results of org-agenda-list spanning now to DAYS."
|
||||
|
@ -252,7 +252,10 @@ Examples:
|
|||
:type integer
|
||||
:description "Days. Positive = future. Negative = past. Default: 14"))
|
||||
:category "org"
|
||||
:description "Return user's agenda (tasking) spanning X days from the current moment. This can be used to get all agenda tasks that are due or scheduled in the next X days, or in the past X days, depending on whether the days argument is positive or negative. Example: get all agenda tasks due in the next 7 days: \"7\""))
|
||||
:description "Return user's agenda (tasking) spanning X days from the current moment. Example:
|
||||
- Get all tasks due in the next 7 days: \"7\"
|
||||
- Get all tasks in the last 14 days: \"-14\"
|
||||
After using this, stop. Evaluate the relevance of the results. Then continue."))
|
||||
|
||||
(defun gptel-org-tools--org-ql-select-headings (buf query)
|
||||
"Return headings matching QUERY from BUFFER."
|
||||
|
@ -265,7 +268,7 @@ Examples:
|
|||
(get-buffer buf)
|
||||
`(heading ,query)
|
||||
:action #''gptel-org-tools--heading)))
|
||||
(gptel-org-tools--result-limit result))
|
||||
(concat (gptel-org-tools--result-limit result) "Results end here. Proceed with the next action."))
|
||||
(message "Buffer '%s' isn't an org-mode buffer." buf))
|
||||
(message "Buffer '%s' does not exist." buf))))
|
||||
|
||||
|
@ -298,7 +301,7 @@ Examples:
|
|||
(gptel-make-tool
|
||||
:function #'gptel-org-tools--org-ql-select-headings-rifle
|
||||
:name "gptel-org-tools--org-ql-select-headings-rifle"
|
||||
:description "Returns headings matching QUERY from BUFFER. Matches against both heading and content, but only returns headings. After using this, continue completing user's request."
|
||||
:description "Returns headings matching QUERY from BUFFER. Matches against both heading and content, but only returns headings. After using this, stop. Evaluate results. Then continue completing user's request."
|
||||
:args (list '(:name "buffer"
|
||||
:type string
|
||||
:description "The name of the buffer. See the NAME column in ~list-buffers~.")
|
||||
|
@ -334,7 +337,7 @@ Examples:
|
|||
:type string
|
||||
:description "The string match entry tags against."))
|
||||
:category "org-ql"
|
||||
:description "Returns entries whose tags match QUERY from BUFFER, without tag inheritance. After using this, evaluate results for relevance, and proceed with completing user's request."))
|
||||
:description "Returns entries whose tags match QUERY from BUFFER, without tag inheritance. After using this, stop. Evaluate results for relevance, then proceed with completing user's request."))
|
||||
|
||||
(defun gptel-org-tools--org-ql-select-tags-local-count (buf query)
|
||||
"Return count of entries tagged QUERY in BUFFER."
|
||||
|
@ -360,7 +363,7 @@ Examples:
|
|||
:type string
|
||||
:description "The string match entry tags against."))
|
||||
:category "org-ql"
|
||||
:description "Returns count of entries tagged with tag QUERY from BUFFER, without tag inheritance."))
|
||||
:description "Returns count of entries tagged with tag QUERY from BUFFER, without tag inheritance. After using this, stop. Evaluate results. Then proceed."))
|
||||
|
||||
(defun gptel-org-tools--org-ql-select-tags (buf query)
|
||||
"Return every entry tagged QUERY from BUFFER."
|
||||
|
@ -388,7 +391,7 @@ Examples:
|
|||
:type string
|
||||
:description "The string to match entry headings against."))
|
||||
:category "org-ql"
|
||||
:description "Returns entries tagged QUERY from BUFFER, with tag inheritance."))
|
||||
:description "Returns entries tagged QUERY from BUFFER, with tag inheritance. After using this, stop. Evaluate results. Only then proceed."))
|
||||
|
||||
(defun gptel-org-tools--org-ql-select-rifle (buf query)
|
||||
"Return every entry matching keyword QUERY from BUFFER."
|
||||
|
@ -416,7 +419,36 @@ Examples:
|
|||
:type string
|
||||
:description "A single string to search for."))
|
||||
:category "org-ql"
|
||||
:description "Returns entries (heading and body) matching QUERY from BUFFER. This may pull too many results, only use if other tools fail."))
|
||||
:description "Returns entries (heading and body) matching QUERY from BUFFER. This may pull too many results, only use if other tools fail. After using this, stop. Evaluate results. If necessary, re-plan. Only then proceed."))
|
||||
|
||||
(defun gptel-org-tools--org-ql-select-regexp (buf query)
|
||||
(let* ((buffer (get-buffer buf))
|
||||
(mode (buffer-local-value 'major-mode buffer)))
|
||||
(if buffer
|
||||
(if (eq mode 'org-mode)
|
||||
(let ((result
|
||||
(org-ql-select
|
||||
buffer
|
||||
`(regexp ,query)
|
||||
:action #'gptel-org-tools--heading-body)))
|
||||
(gptel-org-tools--result-limit result))
|
||||
(message "Buffer '%s' isn't an org-mode buffer." buf))
|
||||
(message "Buffer '%s' does not exist." buf))))
|
||||
|
||||
|
||||
(add-to-list 'gptel-org-tools
|
||||
(gptel-make-tool
|
||||
:function #'gptel-org-tools--org-ql-select-regexp
|
||||
:name "gptel-org-tools--org-ql-select-regexp"
|
||||
:description "Run regexp on ALL files at once."
|
||||
:args (list '(:name "buffer"
|
||||
:type string
|
||||
:description "The name of the buffer. See the NAME column in `list-buffers`. Using filename fails.")
|
||||
'(:name "query"
|
||||
:type string
|
||||
:description "Regexp, Emacs Lisp format. Automatically wrapped in a word boundary by the tool."))
|
||||
:category "org-ql"
|
||||
:description "Returns entries matching regexp QUERY from BUFFER. After using this, stop. Evaluate results for relevance, and proceed with completing user's request. The regexp *must* be in Emacs rx format!" ))
|
||||
|
||||
(defun gptel-org-tools--org-ql-select-all-tags-local (query)
|
||||
"Return entries whose tags match QUERY in org-agenda-files.
|
||||
|
@ -437,7 +469,7 @@ Examples:
|
|||
:type string
|
||||
:description "A single word to scan for."))
|
||||
:category "org-ql"
|
||||
:description "Returns entries whose tags match QUERY from all files, without tag inheritance. After using this, evaluate results for relevance, and proceed with completing user's request."))
|
||||
:description "Returns entries whose tags match QUERY from all files, without tag inheritance. After using this, stop. Evaluate results. Then proceed with completing user's request."))
|
||||
|
||||
(defun gptel-org-tools--org-ql-select-all-tags (query)
|
||||
"Return entries whose tags match QUERY,
|
||||
|
@ -458,7 +490,7 @@ with inheritance, in org-agenda-files.
|
|||
:type string
|
||||
:description "A simple (single) string to scan for."))
|
||||
:category "org-ql"
|
||||
:description "Returns entries whose tags match QUERY from BUFFER, with tag inheritance. After using this, evaluate results for relevance, and proceed with completing user's request."))
|
||||
:description "Returns entries whose tags match QUERY from BUFFER, with tag inheritance. After using this, stop. Evaluate results for relevance, and proceed with completing user's request."))
|
||||
|
||||
(defun gptel-org-tools--org-ql-select-all-rifle (query)
|
||||
"Return entries containing QUERY from org-agenda-files.
|
||||
|
@ -479,7 +511,7 @@ with inheritance, in org-agenda-files.
|
|||
:type string
|
||||
:description "The string to match entry headings and content against."))
|
||||
:category "org-ql"
|
||||
:description "Returns entries matching QUERY from all files. After using this, evaluate results for relevance, and proceed with completing user's request." ))
|
||||
:description "Returns entries matching QUERY from all files. After using this, stop. Evaluate results for relevance, and proceed with completing user's request." ))
|
||||
|
||||
(defun gptel-org-tools--org-ql-select-all-regexp (query)
|
||||
"Return all entries matching regexp QUERY in org-agenda-files.
|
||||
|
@ -500,7 +532,7 @@ with inheritance, in org-agenda-files.
|
|||
:type string
|
||||
:description "Regexp, Emacs Lisp format. Automatically wrapped in a word boundary by the tool."))
|
||||
:category "org-ql"
|
||||
:description "Returns entries matching regexp QUERY from BUFFER. After using this, evaluate results for relevance, and proceed with completing user's request. The regexp *must* be in Emacs rx format!" ))
|
||||
:description "Returns entries matching regexp QUERY from all files. After using this, stop. Evaluate results for relevance, and proceed with completing user's request. The regexp *must* be in Emacs rx format!" ))
|
||||
|
||||
(provide 'gptel-org-tools)
|
||||
;;; gptel-org-tools.el ends here
|
||||
|
|
Loading…
Add table
Reference in a new issue