Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .jules/bolt.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
## 2026-01-16 - [Shell Dependency Check Overhead]
**Learning:** `lib/core/common.sh` functions like `safe_json_get_key` re-check dependencies (`command -v jq`) on every invocation. In tight loops, this adds significant overhead (~13% in micro-benchmark).
**Action:** Cache dependency checks in global variables (e.g., `_JSON_PROCESSOR_CACHE`) when the script is sourced, rather than checking inside hot functions.
## 2025-05-22 - [Awk vs Grep Loop]
**Learning:** Attempted to replace a loop of `grep` calls (checking multiple strings in a file) with a single `awk` script using `tolower($0) ~ pattern`. Benchmarking showed `awk` was significantly slower (~3x) because `grep`'s internal text search optimization (C implementation) far outperforms `awk`'s interpreted regex matching loop, even when avoiding multiple process spawns.
**Action:** Stick to multiple `grep` calls for simple string searching unless the pattern complexity or number of patterns is very high.
## 2025-02-18 - [Bash Subshell Caching]
**Learning:** Caching detection results in a shell function (e.g. `get_json_processor`) is ineffective if the function is commonly called inside command substitution `$(...)`, as variables set in the subshell are lost.
**Action:** Detect and export the cached value at the library source time (parent shell) so subshells inherit it.
Expand Down
53 changes: 46 additions & 7 deletions lib/task_manager/simple.sh
Original file line number Diff line number Diff line change
Expand Up @@ -97,22 +97,47 @@ create_task() {
local depends_on="${4:-}"
local tags="${5:-}"

if [ -z "$description" ]; then
if command -v log_error >/dev/null; then
log_error "Task description required"
else
echo "Error: Task description required" >&2
fi
return 1
fi

init_tasks

local id=$(generate_hierarchical_id "$parent")
local timestamp=$(date -u +"%Y-%m-%dT%H:%M:%SZ" 2>/dev/null || date -u +"%Y-%m-%d %H:%M:%S")
local id=""

if [ "$JQ_CMD" = "jq" ]; then
# Optimized single-pass jq execution for array creation and appending
jq --arg id "$id" \
--arg desc "$description" \
# Generate random suffix for potential use (if root task)
local random_suffix=$(generate_id)

# Optimized single-pass jq execution: count children (if needed), generate ID, and append
# Outputs the new ID to stderr for capture to avoid second read
jq --arg desc "$description" \
--arg priority "$priority" \
--arg parent "${parent:-null}" \
--arg tags "$tags" \
--arg depends "$depends_on" \
--arg timestamp "$timestamp" \
'.tasks += [{
id: $id,
--arg random_suffix "$random_suffix" \
'
(if $parent == "null" or $parent == "" then
"task-" + $random_suffix
else
# Count children for hierarchical ID
([.tasks[] | select(.parent == $parent)] | length) as $count |
$parent + "." + ($count + 1 | tostring)
end) as $new_id |

# Side effect: print ID to stderr
($new_id | stderr) as $ignored |

.tasks += [{
id: $new_id,
description: $desc,
status: "todo",
priority: $priority,
Expand All @@ -122,8 +147,22 @@ create_task() {
comments: [],
created_at: $timestamp,
updated_at: $timestamp
}] | .next_id += 1' "$TASKS_FILE" > "${TASKS_FILE}.tmp" && mv "${TASKS_FILE}.tmp" "$TASKS_FILE"
}] | .next_id += 1' "$TASKS_FILE" > "${TASKS_FILE}.tmp" 2> "${TASKS_FILE}.id"

if [ $? -eq 0 ]; then
mv "${TASKS_FILE}.tmp" "$TASKS_FILE"
if [ -f "${TASKS_FILE}.id" ]; then
id=$(cat "${TASKS_FILE}.id")
rm "${TASKS_FILE}.id"
fi
else
rm -f "${TASKS_FILE}.tmp" "${TASKS_FILE}.id"
echo "Error: Failed to create task using jq" >&2
return 1
fi

elif [ "$JQ_CMD" = "python3" ]; then
id=$(generate_hierarchical_id "$parent")
python3 <<PYTHON
import json
from datetime import datetime
Expand Down
1 change: 1 addition & 0 deletions node_modules/.bin/bats

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions node_modules/.package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

53 changes: 53 additions & 0 deletions node_modules/bats/LICENSE.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

135 changes: 135 additions & 0 deletions node_modules/bats/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

75 changes: 75 additions & 0 deletions node_modules/bats/bin/bats

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading