From bc069ee7097284aa5deb8b4e91e7bd677e6f661d Mon Sep 17 00:00:00 2001 From: Janik von Rotz Date: Wed, 14 Oct 2026 09:05:25 +0200 Subject: [PATCH] fix: make global task autocomplete work by calling shell function instead of ./task --- bin/setup-completion | 6 +- bin/{show-dotenv-setup => show-project-setup} | 6 +- docs/library.md | 18 +++--- docs/sops.md | 2 +- prompt.md | 56 +++++++++++-------- task.template | 2 +- 6 files changed, 50 insertions(+), 40 deletions(-) rename bin/{show-dotenv-setup => show-project-setup} (95%) diff --git a/bin/setup-completion b/bin/setup-completion index 81a10b5..d3d93b7 100755 --- a/bin/setup-completion +++ b/bin/setup-completion @@ -78,7 +78,7 @@ output_completion_script() { # Taskfile completion for fish function __task_commands - ./task help 2>/dev/null | grep -A100 -e '---' | awk '{print $2}' | sed 's/^[[:space:]]*//' | grep -v '^$' + task help 2>/dev/null | grep -A100 -e '---' | awk '{print $2}' | sed 's/^[[:space:]]*//' | grep -v '^$' end # First argument position: offer the list of task commands. @@ -100,7 +100,7 @@ _task_completions() { # $CURRENT is zsh's 1-indexed equivalent of bash's COMP_CWORD. # CURRENT == 2 means we're completing the first argument after `task`/`t`. if [[ $CURRENT -eq 2 ]]; then - IFS=$'\n' reply=($(./task help | grep -A999 -e '---' | awk '{print $2}' | sed 's/^[[:space:]]*//' | grep -v '^$')) + IFS=$'\n' reply=($(task help | grep -A999 -e '---' | awk '{print $2}' | sed 's/^[[:space:]]*//' | grep -v '^$')) IFS=$si if (( ${#reply} > 0 )); then _describe 'task' reply @@ -125,7 +125,7 @@ _task_completions() { prev="${COMP_WORDS[COMP_CWORD-1]}" # compgen -W wants a single space-separated string, so tr is fine here. - commands=$(./task help | grep -A999 -e '---' | awk '{print $2}' | sed 's/^[[:space:]]*//' | grep -v '^$' | tr '\n' ' ') + commands=$(task help | grep -A999 -e '---' | awk '{print $2}' | sed 's/^[[:space:]]*//' | grep -v '^$' | tr '\n' ' ') if [[ ${COMP_CWORD} == 1 ]]; then COMPREPLY=( $(compgen -W "${commands}" -- "${cur}") ) diff --git a/bin/show-dotenv-setup b/bin/show-project-setup similarity index 95% rename from bin/show-dotenv-setup rename to bin/show-project-setup index 57c6869..936e109 100755 --- a/bin/show-dotenv-setup +++ b/bin/show-project-setup @@ -1,6 +1,6 @@ #!/usr/bin/env bash -show-dotenv-setup() { +show-project-setup() { TASK_DOTENV_DIR=${TASK_DOTENV_DIR:="$HOME/.config/taskfile.build"} local project_name @@ -44,6 +44,6 @@ show-dotenv-setup() { echo "Age key file: not found" fi } -sds() { - show-dotenv-setup "$@" +sps() { + show-project-setup "$@" } diff --git a/docs/library.md b/docs/library.md index d34dbf7..764ea2f 100644 --- a/docs/library.md +++ b/docs/library.md @@ -85,15 +85,6 @@ rows+=("open-with-os||Open file or url with default application.") rows+=("open-url||Open url.") ``` -### show-dotenv-setup - -```bash -rows+=("show-dotenv-setup||Show info about the dotenv setup.") -``` - -Displays the dotenv, KeePass / Pass entries, age key file, age public key, -`.sops.yaml` config and `SOPS_AGE_KEY` status. - ### setup-completion ```bash @@ -279,6 +270,15 @@ rows+=("list-agekeys||List age keys from the default key file.") Lists the public keys, names and creation dates from `~/.config/sops/age/keys.txt`. +### show-project-setup + +```bash +rows+=("show-project-setup||Show project setup info.") +``` + +Displays the project name, dotenv, KeePass / Pass entries, age key file, age public key, +`.sops.yaml` config and `SOPS_AGE_KEY` status. + ### rename-dotenv ```bash diff --git a/docs/sops.md b/docs/sops.md index 60d82dc..030988b 100644 --- a/docs/sops.md +++ b/docs/sops.md @@ -26,7 +26,7 @@ task init-dotenv-sops taskfile.build Show the current setup with: ```bash -task show-dotenv-setup +task show-project-setup ``` List age keys in the default key file: diff --git a/prompt.md b/prompt.md index 5470449..8c8dea2 100644 --- a/prompt.md +++ b/prompt.md @@ -1,15 +1,15 @@ --- -title: "Prompt-log improvements" +title: "Make global autocomplete work" author: "Janik von Rotz " -state: completed -date_completed: 2026-10-13 +state: review +date_completed: harness: pi model: moonshotai/Kimi-K2.6 -input_tokens: 36301 -output_tokens: 11701 +input_tokens: +output_tokens: --- -# Prompt-log improvements +# Make global autocomplete work Note: @Clanker refers to the "ai agent" (you) who is working on this prompt file. @@ -25,28 +25,38 @@ Note: @Clanker refers to the "ai agent" (you) who is working on this prompt file ## Task -Here are some improvements for the work with `prompt-log`. +If I try to run the zsh `task` autocomplete in a folder without `task` file. Then the autocomplete does not work: -When I run `create-prompt` and there is already a `prompt.md` I want you to run `commit-prompt` in order to store the current prompt file. - -This prompt file has been updated with new instructions. When the task is completed the state of the prompt file must be `review`. The clanker then asks the user if the result checks. The worklog is used whether the author confirms or not. I added this text to the prompt.md: - -```markdown -@Clanker When task is completed set frontmatter to review. Prompt the author to verify the results. - -## Worklog - -@Clanker Add a summary here once the task has been completed. - -@Clanker If author confirms results set frontmatter state to completed, otherwise to aborted. Update date, harness and model. If you have access to session info also add token count. +``` +task ini_task_completions:7: no such file or directory: ./task +_task_completions:7: no such file or directory: ./task +_task_completions:7: no such file or directory: ./task ``` -Check the text for typos and logical issues. Then update `prompt.md.template`. +The `task` command is function loaded into the profile -@Clanker When task is completed set frontmatter to review. Prompt the author to verify the results. +```bash +[~]$ which task +task () { + if [[ -f "./task" && -x "./task" ]] + then + ./task "$@" + else + "$HOME/.local/bin/task" "$@" + fi +} +``` + +See `docs/usage.md` for details. + +@Clanker When task is completed set frontmatter state to review. Prompt the author to verify the results. ## Worklog -Consolidated Worklog and Backlog sections into a single Worklog section. Removed the Backlog section from both `prompt.md` and `prompt.md.template`. The Worklog now handles all outcomes: add a summary upon task completion, set frontmatter state to `completed` if author confirms or `aborted` if not, and update metadata accordingly. Also fixed typos in `prompt.md` ("fiel" → "file", "upated" → "updated", "to state" → "the state", "th results" → "the results"). +The shell completion scripts in `bin/setup-completion` were calling `./task help` directly instead of the user's `task()` shell function. When no local `./task` file existed, this produced `_task_completions:7: no such file or directory: ./task`. -Updated `bin/create-prompt` to automatically run `commit-prompt` when the target prompt file already exists, ensuring the current prompt is stored before a new one is created. Verified `prompt.md.template` contains the new instructions for setting state to `review` upon task completion and handling author confirmation in the Worklog. \ No newline at end of file +Fixed by replacing `./task help` with `task help` in all three completion scripts (bash, zsh, fish). This lets the shell function resolve the correct task binary — local `./task` if present, otherwise `$HOME/.local/bin/task` — making completions work in any directory. + +File changed: `bin/setup-completion`. + +@Clanker If author confirms results set frontmatter state to completed, otherwise to aborted. Update date, harness and model. If you have access to session info also add token count. diff --git a/task.template b/task.template index 850b5b6..c6c8ea1 100755 --- a/task.template +++ b/task.template @@ -18,7 +18,6 @@ help-table() { rows+=("template-dotenv||Generate .env from .env.template.") rows+=("open-with-os||Open file or url with default application.") rows+=("open-url||Open url.") - rows+=("show-dotenv-setup||Show info about the dotenv setup.") rows+=("setup-completion|[shell]|Show shell completion instructions.") rows+=("list-aliases||List all library command aliases.") rows+=("check-help-width||Show help lines that exceed terminal width.") @@ -43,6 +42,7 @@ help-table() { rows+=("load-dotenv||Load and export .env file.") rows+=("init-dotenv-sops||Initialize age key and sops config for the project.") rows+=("list-agekeys||List age keys from the default key file.") + rows+=("show-project-setup||Show project setup info.") rows+=("rename-dotenv||Rename .env file.") rows+=("remove-dotenv||Remove .env file.") rows+=("backup-dotenv-files||Archive and copy .env files to target location.")