specweave 1.0.550 → 1.0.552
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CLAUDE.md +1 -1
- package/bin/specweave.js +23 -1
- package/dist/src/cli/commands/hook.d.ts +15 -0
- package/dist/src/cli/commands/hook.d.ts.map +1 -0
- package/dist/src/cli/commands/hook.js +61 -0
- package/dist/src/cli/commands/hook.js.map +1 -0
- package/dist/src/cli/commands/init.d.ts.map +1 -1
- package/dist/src/cli/commands/init.js +5 -0
- package/dist/src/cli/commands/init.js.map +1 -1
- package/dist/src/cli/commands/refresh-plugins.d.ts.map +1 -1
- package/dist/src/cli/commands/refresh-plugins.js +11 -1
- package/dist/src/cli/commands/refresh-plugins.js.map +1 -1
- package/dist/src/cli/commands/sync-setup.d.ts.map +1 -1
- package/dist/src/cli/commands/sync-setup.js +7 -3
- package/dist/src/cli/commands/sync-setup.js.map +1 -1
- package/dist/src/cli/helpers/issue-tracker/project-mapping-wizard.d.ts +9 -0
- package/dist/src/cli/helpers/issue-tracker/project-mapping-wizard.d.ts.map +1 -1
- package/dist/src/cli/helpers/issue-tracker/project-mapping-wizard.js +9 -3
- package/dist/src/cli/helpers/issue-tracker/project-mapping-wizard.js.map +1 -1
- package/dist/src/config/types.d.ts +2 -2
- package/dist/src/core/config/types.d.ts +18 -2
- package/dist/src/core/config/types.d.ts.map +1 -1
- package/dist/src/core/config/types.js.map +1 -1
- package/dist/src/core/hooks/handlers/hook-router.d.ts +19 -0
- package/dist/src/core/hooks/handlers/hook-router.d.ts.map +1 -0
- package/dist/src/core/hooks/handlers/hook-router.js +75 -0
- package/dist/src/core/hooks/handlers/hook-router.js.map +1 -0
- package/dist/src/core/hooks/handlers/index.d.ts +10 -0
- package/dist/src/core/hooks/handlers/index.d.ts.map +1 -0
- package/dist/src/core/hooks/handlers/index.js +9 -0
- package/dist/src/core/hooks/handlers/index.js.map +1 -0
- package/dist/src/core/hooks/handlers/post-tool-use-analytics.d.ts +11 -0
- package/dist/src/core/hooks/handlers/post-tool-use-analytics.d.ts.map +1 -0
- package/dist/src/core/hooks/handlers/post-tool-use-analytics.js +73 -0
- package/dist/src/core/hooks/handlers/post-tool-use-analytics.js.map +1 -0
- package/dist/src/core/hooks/handlers/post-tool-use.d.ts +11 -0
- package/dist/src/core/hooks/handlers/post-tool-use.d.ts.map +1 -0
- package/dist/src/core/hooks/handlers/post-tool-use.js +76 -0
- package/dist/src/core/hooks/handlers/post-tool-use.js.map +1 -0
- package/dist/src/core/hooks/handlers/pre-compact.d.ts +11 -0
- package/dist/src/core/hooks/handlers/pre-compact.d.ts.map +1 -0
- package/dist/src/core/hooks/handlers/pre-compact.js +77 -0
- package/dist/src/core/hooks/handlers/pre-compact.js.map +1 -0
- package/dist/src/core/hooks/handlers/pre-tool-use.d.ts +11 -0
- package/dist/src/core/hooks/handlers/pre-tool-use.d.ts.map +1 -0
- package/dist/src/core/hooks/handlers/pre-tool-use.js +318 -0
- package/dist/src/core/hooks/handlers/pre-tool-use.js.map +1 -0
- package/dist/src/core/hooks/handlers/session-start.d.ts +9 -0
- package/dist/src/core/hooks/handlers/session-start.d.ts.map +1 -0
- package/dist/src/core/hooks/handlers/session-start.js +111 -0
- package/dist/src/core/hooks/handlers/session-start.js.map +1 -0
- package/dist/src/core/hooks/handlers/stop-auto.d.ts +16 -0
- package/dist/src/core/hooks/handlers/stop-auto.d.ts.map +1 -0
- package/dist/src/core/hooks/handlers/stop-auto.js +122 -0
- package/dist/src/core/hooks/handlers/stop-auto.js.map +1 -0
- package/dist/src/core/hooks/handlers/stop-reflect.d.ts +14 -0
- package/dist/src/core/hooks/handlers/stop-reflect.d.ts.map +1 -0
- package/dist/src/core/hooks/handlers/stop-reflect.js +43 -0
- package/dist/src/core/hooks/handlers/stop-reflect.js.map +1 -0
- package/dist/src/core/hooks/handlers/stop-sync.d.ts +15 -0
- package/dist/src/core/hooks/handlers/stop-sync.d.ts.map +1 -0
- package/dist/src/core/hooks/handlers/stop-sync.js +68 -0
- package/dist/src/core/hooks/handlers/stop-sync.js.map +1 -0
- package/dist/src/core/hooks/handlers/types.d.ts +63 -0
- package/dist/src/core/hooks/handlers/types.d.ts.map +1 -0
- package/dist/src/core/hooks/handlers/types.js +27 -0
- package/dist/src/core/hooks/handlers/types.js.map +1 -0
- package/dist/src/core/hooks/handlers/user-prompt-submit.d.ts +14 -0
- package/dist/src/core/hooks/handlers/user-prompt-submit.d.ts.map +1 -0
- package/dist/src/core/hooks/handlers/user-prompt-submit.js +173 -0
- package/dist/src/core/hooks/handlers/user-prompt-submit.js.map +1 -0
- package/dist/src/core/hooks/handlers/utils.d.ts +25 -0
- package/dist/src/core/hooks/handlers/utils.d.ts.map +1 -0
- package/dist/src/core/hooks/handlers/utils.js +64 -0
- package/dist/src/core/hooks/handlers/utils.js.map +1 -0
- package/dist/src/core/increment/completion-validator.d.ts.map +1 -1
- package/dist/src/core/increment/completion-validator.js +32 -0
- package/dist/src/core/increment/completion-validator.js.map +1 -1
- package/dist/src/init/research/types.d.ts +1 -1
- package/dist/src/sync/sync-target-resolver.js.map +1 -1
- package/dist/src/utils/lock-manager.d.ts.map +1 -1
- package/dist/src/utils/lock-manager.js +5 -0
- package/dist/src/utils/lock-manager.js.map +1 -1
- package/dist/src/utils/plugin-copier.d.ts +10 -0
- package/dist/src/utils/plugin-copier.d.ts.map +1 -1
- package/dist/src/utils/plugin-copier.js +63 -35
- package/dist/src/utils/plugin-copier.js.map +1 -1
- package/package.json +1 -1
- package/plugins/specweave/agents/sw-closer.md +3 -2
- package/plugins/specweave/hooks/hooks.json +10 -10
- package/plugins/specweave/skills/code-reviewer/SKILL.md +180 -16
- package/plugins/specweave/skills/code-reviewer/agents/reviewer-comments.md +83 -0
- package/plugins/specweave/skills/code-reviewer/agents/reviewer-silent-failures.md +19 -0
- package/plugins/specweave/skills/code-reviewer/agents/reviewer-spec-compliance.md +19 -0
- package/plugins/specweave/skills/code-reviewer/agents/reviewer-tests.md +101 -0
- package/plugins/specweave/skills/code-reviewer/agents/reviewer-types.md +20 -0
- package/plugins/specweave/skills/done/SKILL.md +56 -21
- package/plugins/specweave/skills/grill/SKILL.md +1 -1
- package/plugins/specweave/skills/team-lead/agents/reviewer-logic.md +19 -0
- package/plugins/specweave/skills/team-lead/agents/reviewer-performance.md +20 -0
- package/plugins/specweave/skills/team-lead/agents/reviewer-security.md +20 -0
- package/src/templates/CLAUDE.md.template +7 -4
- package/plugins/specweave/hooks/README.md +0 -493
- package/plugins/specweave/hooks/_archive/stop-auto-v4-legacy.sh +0 -1319
- package/plugins/specweave/hooks/lib/common-setup.sh +0 -144
- package/plugins/specweave/hooks/lib/hook-errors.sh +0 -414
- package/plugins/specweave/hooks/lib/migrate-increment-work.sh +0 -245
- package/plugins/specweave/hooks/lib/resolve-package.sh +0 -146
- package/plugins/specweave/hooks/lib/scheduler-startup.sh +0 -135
- package/plugins/specweave/hooks/lib/score-increment.sh +0 -87
- package/plugins/specweave/hooks/lib/sync-spec-content.sh +0 -193
- package/plugins/specweave/hooks/lib/update-active-increment.sh +0 -95
- package/plugins/specweave/hooks/lib/update-status-line.sh +0 -233
- package/plugins/specweave/hooks/lib/validate-spec-status.sh +0 -171
- package/plugins/specweave/hooks/llm-judge-validator.sh +0 -219
- package/plugins/specweave/hooks/log-decision.sh +0 -168
- package/plugins/specweave/hooks/pre-compact.sh +0 -64
- package/plugins/specweave/hooks/startup-health-check.sh +0 -64
- package/plugins/specweave/hooks/stop-auto-v5.sh +0 -276
- package/plugins/specweave/hooks/stop-reflect.sh +0 -336
- package/plugins/specweave/hooks/stop-sync.sh +0 -283
- package/plugins/specweave/hooks/tests/test-auto-context-integration.sh +0 -126
- package/plugins/specweave/hooks/tests/test-stop-auto-enriched.sh +0 -128
- package/plugins/specweave/hooks/universal/dispatcher.mjs +0 -336
- package/plugins/specweave/hooks/universal/fail-fast-wrapper.sh +0 -325
- package/plugins/specweave/hooks/universal/hook-wrapper.cmd +0 -26
- package/plugins/specweave/hooks/universal/hook-wrapper.sh +0 -69
- package/plugins/specweave/hooks/universal/run-hook.sh +0 -20
- package/plugins/specweave/hooks/universal/session-start.cmd +0 -16
- package/plugins/specweave/hooks/universal/session-start.ps1 +0 -16
- package/plugins/specweave/hooks/user-prompt-submit.sh +0 -2550
- package/plugins/specweave/hooks/v2/detectors/lifecycle-detector.sh +0 -87
- package/plugins/specweave/hooks/v2/detectors/us-completion-detector.sh +0 -186
- package/plugins/specweave/hooks/v2/dispatchers/post-tool-use-analytics.sh +0 -83
- package/plugins/specweave/hooks/v2/dispatchers/post-tool-use.sh +0 -447
- package/plugins/specweave/hooks/v2/dispatchers/pre-tool-use.sh +0 -104
- package/plugins/specweave/hooks/v2/dispatchers/session-start.sh +0 -270
- package/plugins/specweave/hooks/v2/guards/completion-guard.sh +0 -14
- package/plugins/specweave/hooks/v2/guards/increment-duplicate-guard.sh +0 -14
- package/plugins/specweave/hooks/v2/guards/increment-existence-guard.sh +0 -240
- package/plugins/specweave/hooks/v2/guards/interview-enforcement-guard.sh +0 -171
- package/plugins/specweave/hooks/v2/guards/metadata-json-guard.sh +0 -14
- package/plugins/specweave/hooks/v2/guards/skill-chain-enforcement-guard.sh +0 -222
- package/plugins/specweave/hooks/v2/guards/spec-template-enforcement-guard.sh +0 -21
- package/plugins/specweave/hooks/v2/guards/spec-validation-guard.sh +0 -14
- package/plugins/specweave/hooks/v2/guards/status-completion-guard.sh +0 -84
- package/plugins/specweave/hooks/v2/guards/task-ac-sync-guard.sh +0 -475
- package/plugins/specweave/hooks/v2/guards/tdd-enforcement-guard.sh +0 -268
- package/plugins/specweave/hooks/v2/handlers/ac-sync-dispatcher.sh +0 -332
- package/plugins/specweave/hooks/v2/handlers/ac-validation-handler.sh +0 -50
- package/plugins/specweave/hooks/v2/handlers/github-sync-handler.sh +0 -347
- package/plugins/specweave/hooks/v2/handlers/living-docs-handler.sh +0 -83
- package/plugins/specweave/hooks/v2/handlers/living-specs-handler.sh +0 -268
- package/plugins/specweave/hooks/v2/handlers/project-bridge-handler.sh +0 -104
- package/plugins/specweave/hooks/v2/handlers/status-line-handler.sh +0 -165
- package/plugins/specweave/hooks/v2/handlers/status-update.sh +0 -61
- package/plugins/specweave/hooks/v2/handlers/universal-auto-create-dispatcher.sh +0 -270
- package/plugins/specweave/hooks/v2/integrations/ado-post-living-docs-update.sh +0 -367
- package/plugins/specweave/hooks/v2/integrations/ado-post-task.sh +0 -179
- package/plugins/specweave/hooks/v2/integrations/github-auto-create-handler.sh +0 -553
- package/plugins/specweave/hooks/v2/integrations/github-post-task.sh +0 -345
- package/plugins/specweave/hooks/v2/integrations/jira-post-task.sh +0 -180
- package/plugins/specweave/hooks/v2/lib/check-provider-enabled.sh +0 -52
- package/plugins/specweave/hooks/v2/queue/enqueue.sh +0 -81
- package/plugins/specweave/hooks/v2/session-end.sh +0 -139
- package/plugins/specweave/hooks/validate-skill-activations.sh +0 -227
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
# lifecycle-detector.sh - Detect increment lifecycle changes
|
|
3
|
-
# Events: increment.created, increment.done, increment.archived, increment.reopened
|
|
4
|
-
#
|
|
5
|
-
# Called from post-tool-use.sh when metadata.json is edited
|
|
6
|
-
# Compares current vs previous status to detect transitions
|
|
7
|
-
#
|
|
8
|
-
# IMPORTANT: This script must be fast (<10ms) and never crash
|
|
9
|
-
set +e
|
|
10
|
-
|
|
11
|
-
[[ "${SPECWEAVE_DISABLE_HOOKS:-0}" == "1" ]] && exit 0
|
|
12
|
-
|
|
13
|
-
INC_ID="${1:-}"
|
|
14
|
-
[[ -z "$INC_ID" ]] && exit 0
|
|
15
|
-
|
|
16
|
-
# Find project root
|
|
17
|
-
PROJECT_ROOT="$PWD"
|
|
18
|
-
while [[ "$PROJECT_ROOT" != "/" ]] && [[ ! -f "$PROJECT_ROOT/.specweave/config.json" ]]; do
|
|
19
|
-
PROJECT_ROOT=$(dirname "$PROJECT_ROOT")
|
|
20
|
-
done
|
|
21
|
-
[[ ! -f "$PROJECT_ROOT/.specweave/config.json" ]] && exit 0
|
|
22
|
-
|
|
23
|
-
STATE_DIR="$PROJECT_ROOT/.specweave/state"
|
|
24
|
-
PREV_STATUS_FILE="$STATE_DIR/.prev-status-$INC_ID"
|
|
25
|
-
META_FILE="$PROJECT_ROOT/.specweave/increments/$INC_ID/metadata.json"
|
|
26
|
-
ARCHIVE_META="$PROJECT_ROOT/.specweave/increments/_archive/$INC_ID/metadata.json"
|
|
27
|
-
|
|
28
|
-
mkdir -p "$STATE_DIR" 2>/dev/null
|
|
29
|
-
|
|
30
|
-
# Detect event
|
|
31
|
-
EVENT=""
|
|
32
|
-
EVENT_DATA="$INC_ID"
|
|
33
|
-
|
|
34
|
-
# Check if archived (folder moved to _archive/)
|
|
35
|
-
if [[ -f "$ARCHIVE_META" ]] && [[ ! -f "$META_FILE" ]]; then
|
|
36
|
-
# Check if we already detected this
|
|
37
|
-
PREV=$(cat "$PREV_STATUS_FILE" 2>/dev/null || echo "")
|
|
38
|
-
if [[ "$PREV" != "archived" ]]; then
|
|
39
|
-
EVENT="increment.archived"
|
|
40
|
-
echo "archived" > "$PREV_STATUS_FILE"
|
|
41
|
-
fi
|
|
42
|
-
|
|
43
|
-
elif [[ -f "$META_FILE" ]]; then
|
|
44
|
-
# Get current status (fast grep, no jq)
|
|
45
|
-
CURRENT_STATUS=$(grep -o '"status"[[:space:]]*:[[:space:]]*"[^"]*"' "$META_FILE" | head -1 | sed 's/.*"\([^"]*\)".*/\1/')
|
|
46
|
-
[[ -z "$CURRENT_STATUS" ]] && exit 0
|
|
47
|
-
|
|
48
|
-
# Get previous status
|
|
49
|
-
PREV_STATUS=$(cat "$PREV_STATUS_FILE" 2>/dev/null || echo "")
|
|
50
|
-
|
|
51
|
-
# Detect transitions
|
|
52
|
-
if [[ -z "$PREV_STATUS" ]]; then
|
|
53
|
-
# First time seeing this increment
|
|
54
|
-
# Note: "planned" is the initial status when increment is created via prompt
|
|
55
|
-
# "planning" and "active" are also valid initial statuses
|
|
56
|
-
if [[ "$CURRENT_STATUS" == "planned" ]] || [[ "$CURRENT_STATUS" == "planning" ]] || [[ "$CURRENT_STATUS" == "active" ]]; then
|
|
57
|
-
EVENT="increment.created"
|
|
58
|
-
fi
|
|
59
|
-
elif [[ "$PREV_STATUS" != "$CURRENT_STATUS" ]]; then
|
|
60
|
-
# Status changed
|
|
61
|
-
case "$CURRENT_STATUS" in
|
|
62
|
-
completed)
|
|
63
|
-
EVENT="increment.done"
|
|
64
|
-
;;
|
|
65
|
-
active)
|
|
66
|
-
# Was it completed before? That's a reopen
|
|
67
|
-
if [[ "$PREV_STATUS" == "completed" ]]; then
|
|
68
|
-
EVENT="increment.reopened"
|
|
69
|
-
fi
|
|
70
|
-
;;
|
|
71
|
-
paused|abandoned)
|
|
72
|
-
# Status changes we don't emit events for
|
|
73
|
-
;;
|
|
74
|
-
esac
|
|
75
|
-
fi
|
|
76
|
-
|
|
77
|
-
# Save current status
|
|
78
|
-
echo "$CURRENT_STATUS" > "$PREV_STATUS_FILE"
|
|
79
|
-
fi
|
|
80
|
-
|
|
81
|
-
# Fire event if detected
|
|
82
|
-
if [[ -n "$EVENT" ]]; then
|
|
83
|
-
HOOK_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
|
84
|
-
bash "$HOOK_DIR/queue/enqueue.sh" "$EVENT" "$EVENT_DATA" 2>/dev/null
|
|
85
|
-
fi
|
|
86
|
-
|
|
87
|
-
exit 0
|
|
@@ -1,186 +0,0 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
# us-completion-detector.sh - Detect user story completion
|
|
3
|
-
# Events: user-story.completed, user-story.reopened
|
|
4
|
-
#
|
|
5
|
-
# A user story is complete when:
|
|
6
|
-
# 1. ALL tasks for that US are completed ([x])
|
|
7
|
-
# 2. ALL ACs for that US are checked ([x])
|
|
8
|
-
#
|
|
9
|
-
# Called from post-tool-use.sh when tasks.md or spec.md is edited
|
|
10
|
-
#
|
|
11
|
-
# CRITICAL FIX (v1.0.127): Rewritten for bash 3.2 compatibility
|
|
12
|
-
# - Removed associative arrays (requires bash 4+)
|
|
13
|
-
# - Uses temp files instead for US tracking
|
|
14
|
-
#
|
|
15
|
-
# CROSS-PLATFORM (v1.0.127): Works on macOS, Linux, and Windows (Git Bash/WSL)
|
|
16
|
-
# - Uses portable commands (grep, sed, cat, echo)
|
|
17
|
-
# - mktemp with fallback for different systems
|
|
18
|
-
# - No stat commands (different syntax per OS)
|
|
19
|
-
#
|
|
20
|
-
# IDEMPOTENCY (v1.0.148): No locks needed - idempotent by design:
|
|
21
|
-
# - State file tracks previous completion status per US
|
|
22
|
-
# - Events only emitted on state TRANSITIONS (no→yes or yes→no)
|
|
23
|
-
# - enqueue.sh has 10s deduplication window for extra safety
|
|
24
|
-
# - Multiple concurrent runs produce same result (idempotent)
|
|
25
|
-
#
|
|
26
|
-
# IMPORTANT: This script must be fast (<50ms) and never crash
|
|
27
|
-
set +e
|
|
28
|
-
|
|
29
|
-
[[ "${SPECWEAVE_DISABLE_HOOKS:-0}" == "1" ]] && exit 0
|
|
30
|
-
|
|
31
|
-
INC_ID="${1:-}"
|
|
32
|
-
[[ -z "$INC_ID" ]] && exit 0
|
|
33
|
-
|
|
34
|
-
# Find project root
|
|
35
|
-
PROJECT_ROOT="$PWD"
|
|
36
|
-
while [[ "$PROJECT_ROOT" != "/" ]] && [[ ! -f "$PROJECT_ROOT/.specweave/config.json" ]]; do
|
|
37
|
-
PROJECT_ROOT=$(dirname "$PROJECT_ROOT")
|
|
38
|
-
done
|
|
39
|
-
[[ ! -f "$PROJECT_ROOT/.specweave/config.json" ]] && exit 0
|
|
40
|
-
|
|
41
|
-
STATE_DIR="$PROJECT_ROOT/.specweave/state"
|
|
42
|
-
TASKS_FILE="$PROJECT_ROOT/.specweave/increments/$INC_ID/tasks.md"
|
|
43
|
-
SPEC_FILE="$PROJECT_ROOT/.specweave/increments/$INC_ID/spec.md"
|
|
44
|
-
US_STATE_FILE="$STATE_DIR/.us-completion-$INC_ID"
|
|
45
|
-
|
|
46
|
-
mkdir -p "$STATE_DIR" 2>/dev/null
|
|
47
|
-
|
|
48
|
-
[[ ! -f "$TASKS_FILE" ]] && exit 0
|
|
49
|
-
[[ ! -f "$SPEC_FILE" ]] && exit 0
|
|
50
|
-
|
|
51
|
-
# Create temp directory for processing
|
|
52
|
-
TEMP_DIR=$(mktemp -d 2>/dev/null || mktemp -d -t 'us-detect')
|
|
53
|
-
trap "rm -rf $TEMP_DIR" EXIT
|
|
54
|
-
|
|
55
|
-
# Initialize temp files for tracking
|
|
56
|
-
mkdir -p "$TEMP_DIR/tasks_total" "$TEMP_DIR/tasks_done" "$TEMP_DIR/acs_total" "$TEMP_DIR/acs_done" 2>/dev/null
|
|
57
|
-
|
|
58
|
-
# Parse tasks.md to find US -> Tasks mapping and completion status
|
|
59
|
-
# Format: ### T-001: Title
|
|
60
|
-
# **User Story**: US-003
|
|
61
|
-
# **Status**: [x] completed
|
|
62
|
-
|
|
63
|
-
CURRENT_TASK=""
|
|
64
|
-
CURRENT_STATUS=""
|
|
65
|
-
CURRENT_US=""
|
|
66
|
-
|
|
67
|
-
while IFS= read -r line; do
|
|
68
|
-
# Detect task header
|
|
69
|
-
if echo "$line" | grep -qE '^###[[:space:]]+T-[0-9]+'; then
|
|
70
|
-
# Process previous task
|
|
71
|
-
if [[ -n "$CURRENT_US" ]] && [[ -n "$CURRENT_TASK" ]]; then
|
|
72
|
-
# Increment task count for this US
|
|
73
|
-
COUNT=$(cat "$TEMP_DIR/tasks_total/$CURRENT_US" 2>/dev/null || echo 0)
|
|
74
|
-
echo $((COUNT + 1)) > "$TEMP_DIR/tasks_total/$CURRENT_US"
|
|
75
|
-
|
|
76
|
-
if [[ "$CURRENT_STATUS" == "done" ]]; then
|
|
77
|
-
DONE=$(cat "$TEMP_DIR/tasks_done/$CURRENT_US" 2>/dev/null || echo 0)
|
|
78
|
-
echo $((DONE + 1)) > "$TEMP_DIR/tasks_done/$CURRENT_US"
|
|
79
|
-
fi
|
|
80
|
-
fi
|
|
81
|
-
CURRENT_TASK=$(echo "$line" | grep -o 'T-[0-9][0-9][0-9]' | head -1)
|
|
82
|
-
CURRENT_STATUS=""
|
|
83
|
-
CURRENT_US=""
|
|
84
|
-
fi
|
|
85
|
-
|
|
86
|
-
# Detect User Story reference (format: US-001, US-002, etc.)
|
|
87
|
-
if echo "$line" | grep -qE 'User[[:space:]]*Story.*:[[:space:]]*US-[0-9]+'; then
|
|
88
|
-
CURRENT_US=$(echo "$line" | grep -o 'US-[0-9][0-9][0-9]' | head -1)
|
|
89
|
-
fi
|
|
90
|
-
|
|
91
|
-
# Detect completion status
|
|
92
|
-
if echo "$line" | grep -qE 'Status.*\[x\]'; then
|
|
93
|
-
CURRENT_STATUS="done"
|
|
94
|
-
fi
|
|
95
|
-
done < "$TASKS_FILE"
|
|
96
|
-
|
|
97
|
-
# Process last task
|
|
98
|
-
if [[ -n "$CURRENT_US" ]] && [[ -n "$CURRENT_TASK" ]]; then
|
|
99
|
-
COUNT=$(cat "$TEMP_DIR/tasks_total/$CURRENT_US" 2>/dev/null || echo 0)
|
|
100
|
-
echo $((COUNT + 1)) > "$TEMP_DIR/tasks_total/$CURRENT_US"
|
|
101
|
-
|
|
102
|
-
if [[ "$CURRENT_STATUS" == "done" ]]; then
|
|
103
|
-
DONE=$(cat "$TEMP_DIR/tasks_done/$CURRENT_US" 2>/dev/null || echo 0)
|
|
104
|
-
echo $((DONE + 1)) > "$TEMP_DIR/tasks_done/$CURRENT_US"
|
|
105
|
-
fi
|
|
106
|
-
fi
|
|
107
|
-
|
|
108
|
-
# Parse spec.md for AC completion status
|
|
109
|
-
# Format: - [x] **AC-US1-01**: Description
|
|
110
|
-
# CRITICAL FIX (v1.0.127): Pad US number to match tasks.md format (US-001, US-002, etc.)
|
|
111
|
-
|
|
112
|
-
while IFS= read -r line; do
|
|
113
|
-
# Find AC lines with US reference (AC-US1-01, AC-US2-05, etc.)
|
|
114
|
-
if echo "$line" | grep -qE 'AC-US[0-9]+-[0-9]+'; then
|
|
115
|
-
# Extract US number from AC-USX-YY pattern
|
|
116
|
-
US_NUM=$(echo "$line" | sed -n 's/.*AC-US\([0-9]*\)-.*/\1/p' | head -1)
|
|
117
|
-
|
|
118
|
-
if [[ -n "$US_NUM" ]]; then
|
|
119
|
-
# Pad to 3 digits to match tasks.md format (US-001, US-002, etc.)
|
|
120
|
-
US_ID=$(printf "US-%03d" "$US_NUM")
|
|
121
|
-
|
|
122
|
-
# Increment AC count for this US
|
|
123
|
-
COUNT=$(cat "$TEMP_DIR/acs_total/$US_ID" 2>/dev/null || echo 0)
|
|
124
|
-
echo $((COUNT + 1)) > "$TEMP_DIR/acs_total/$US_ID"
|
|
125
|
-
|
|
126
|
-
if echo "$line" | grep -qE '\[x\]'; then
|
|
127
|
-
DONE=$(cat "$TEMP_DIR/acs_done/$US_ID" 2>/dev/null || echo 0)
|
|
128
|
-
echo $((DONE + 1)) > "$TEMP_DIR/acs_done/$US_ID"
|
|
129
|
-
fi
|
|
130
|
-
fi
|
|
131
|
-
fi
|
|
132
|
-
done < "$SPEC_FILE"
|
|
133
|
-
|
|
134
|
-
# Load previous completion state
|
|
135
|
-
# Format: US-001=yes, US-002=no
|
|
136
|
-
if [[ -f "$US_STATE_FILE" ]]; then
|
|
137
|
-
while IFS='=' read -r us status; do
|
|
138
|
-
[[ -n "$us" ]] && echo "$status" > "$TEMP_DIR/prev/$us"
|
|
139
|
-
done < "$US_STATE_FILE"
|
|
140
|
-
fi
|
|
141
|
-
mkdir -p "$TEMP_DIR/prev" 2>/dev/null
|
|
142
|
-
|
|
143
|
-
# Check completion for each US that has tasks
|
|
144
|
-
HOOK_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
|
145
|
-
NEW_STATE=""
|
|
146
|
-
|
|
147
|
-
for US_FILE in "$TEMP_DIR/tasks_total"/*; do
|
|
148
|
-
[[ ! -f "$US_FILE" ]] && continue
|
|
149
|
-
|
|
150
|
-
US_ID=$(basename "$US_FILE")
|
|
151
|
-
|
|
152
|
-
TASKS_TOTAL=$(cat "$TEMP_DIR/tasks_total/$US_ID" 2>/dev/null || echo 0)
|
|
153
|
-
TASKS_DONE=$(cat "$TEMP_DIR/tasks_done/$US_ID" 2>/dev/null || echo 0)
|
|
154
|
-
ACS_TOTAL=$(cat "$TEMP_DIR/acs_total/$US_ID" 2>/dev/null || echo 0)
|
|
155
|
-
ACS_DONE=$(cat "$TEMP_DIR/acs_done/$US_ID" 2>/dev/null || echo 0)
|
|
156
|
-
|
|
157
|
-
# US is complete if ALL tasks done AND ALL ACs checked
|
|
158
|
-
CURRENT_COMPLETE="no"
|
|
159
|
-
if [[ $TASKS_TOTAL -gt 0 ]] && [[ $TASKS_DONE -eq $TASKS_TOTAL ]]; then
|
|
160
|
-
if [[ $ACS_TOTAL -gt 0 ]] && [[ $ACS_DONE -eq $ACS_TOTAL ]]; then
|
|
161
|
-
CURRENT_COMPLETE="yes"
|
|
162
|
-
elif [[ $ACS_TOTAL -eq 0 ]]; then
|
|
163
|
-
# No ACs defined, just check tasks
|
|
164
|
-
CURRENT_COMPLETE="yes"
|
|
165
|
-
fi
|
|
166
|
-
fi
|
|
167
|
-
|
|
168
|
-
PREV=$(cat "$TEMP_DIR/prev/$US_ID" 2>/dev/null || echo "no")
|
|
169
|
-
|
|
170
|
-
# Detect transitions and emit events
|
|
171
|
-
if [[ "$CURRENT_COMPLETE" == "yes" ]] && [[ "$PREV" == "no" ]]; then
|
|
172
|
-
# User story just completed - emit event
|
|
173
|
-
bash "$HOOK_DIR/queue/enqueue.sh" "user-story.completed" "$INC_ID:$US_ID" 2>/dev/null
|
|
174
|
-
elif [[ "$CURRENT_COMPLETE" == "no" ]] && [[ "$PREV" == "yes" ]]; then
|
|
175
|
-
# User story reopened - emit event
|
|
176
|
-
bash "$HOOK_DIR/queue/enqueue.sh" "user-story.reopened" "$INC_ID:$US_ID" 2>/dev/null
|
|
177
|
-
fi
|
|
178
|
-
|
|
179
|
-
NEW_STATE="${NEW_STATE}${US_ID}=${CURRENT_COMPLETE}
|
|
180
|
-
"
|
|
181
|
-
done
|
|
182
|
-
|
|
183
|
-
# Save new state
|
|
184
|
-
echo "$NEW_STATE" > "$US_STATE_FILE"
|
|
185
|
-
|
|
186
|
-
exit 0
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
# post-tool-use-analytics.sh - Track Skill and Task tool usage for analytics
|
|
3
|
-
#
|
|
4
|
-
# PostToolUse hook for Skill|Task tools (separate from Edit|Write dispatcher)
|
|
5
|
-
# Extracts skill/agent info from stdin JSON and calls track-analytics.sh
|
|
6
|
-
#
|
|
7
|
-
# CRITICAL: Must exit 0, never block, run <5s
|
|
8
|
-
|
|
9
|
-
set +e
|
|
10
|
-
|
|
11
|
-
[[ "${SPECWEAVE_DISABLE_HOOKS:-0}" == "1" ]] && exit 0
|
|
12
|
-
|
|
13
|
-
# Project root detection
|
|
14
|
-
PROJECT_ROOT="$PWD"
|
|
15
|
-
while [[ "$PROJECT_ROOT" != "/" ]] && [[ ! -f "$PROJECT_ROOT/.specweave/config.json" ]]; do
|
|
16
|
-
PROJECT_ROOT=$(dirname "$PROJECT_ROOT")
|
|
17
|
-
done
|
|
18
|
-
[[ ! -f "$PROJECT_ROOT/.specweave/config.json" ]] && exit 0
|
|
19
|
-
|
|
20
|
-
# Read stdin (tool result JSON)
|
|
21
|
-
INPUT=""
|
|
22
|
-
if command -v gtimeout >/dev/null 2>&1; then
|
|
23
|
-
INPUT=$(gtimeout 1 cat 2>/dev/null || echo '{}')
|
|
24
|
-
elif command -v timeout >/dev/null 2>&1; then
|
|
25
|
-
INPUT=$(timeout 1 cat 2>/dev/null || echo '{}')
|
|
26
|
-
else
|
|
27
|
-
INPUT=$(cat 2>/dev/null || echo '{}')
|
|
28
|
-
fi
|
|
29
|
-
|
|
30
|
-
[[ -z "$INPUT" ]] && exit 0
|
|
31
|
-
|
|
32
|
-
# Script paths
|
|
33
|
-
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
34
|
-
PLUGIN_ROOT="$(cd "$SCRIPT_DIR/../../.." && pwd)"
|
|
35
|
-
TRACK_SCRIPT="$PLUGIN_ROOT/scripts/track-analytics.sh"
|
|
36
|
-
|
|
37
|
-
[[ ! -f "$TRACK_SCRIPT" ]] && exit 0
|
|
38
|
-
|
|
39
|
-
# Detect active increment for context
|
|
40
|
-
ACTIVE_INCREMENT=""
|
|
41
|
-
CACHE_FILE="$PROJECT_ROOT/.specweave/state/status-line.json"
|
|
42
|
-
if [[ -f "$CACHE_FILE" ]] && command -v jq >/dev/null 2>&1; then
|
|
43
|
-
ACTIVE_INCREMENT=$(jq -r '.incrementId // ""' "$CACHE_FILE" 2>/dev/null || echo "")
|
|
44
|
-
fi
|
|
45
|
-
|
|
46
|
-
# Extract tool_name
|
|
47
|
-
TOOL_NAME=$(echo "$INPUT" | grep -o '"tool_name"[[:space:]]*:[[:space:]]*"[^"]*"' | head -1 | sed 's/.*"\([^"]*\)".*/\1/')
|
|
48
|
-
|
|
49
|
-
# Fallback: detect tool type from input fields
|
|
50
|
-
if [[ -z "$TOOL_NAME" ]]; then
|
|
51
|
-
if echo "$INPUT" | grep -q '"skill"[[:space:]]*:'; then
|
|
52
|
-
TOOL_NAME="Skill"
|
|
53
|
-
elif echo "$INPUT" | grep -q '"subagent_type"[[:space:]]*:'; then
|
|
54
|
-
TOOL_NAME="Task"
|
|
55
|
-
fi
|
|
56
|
-
fi
|
|
57
|
-
|
|
58
|
-
case "$TOOL_NAME" in
|
|
59
|
-
Skill)
|
|
60
|
-
SKILL_NAME=$(echo "$INPUT" | grep -o '"skill"[[:space:]]*:[[:space:]]*"[^"]*"' | head -1 | sed 's/.*"\([^"]*\)".*/\1/')
|
|
61
|
-
[[ -z "$SKILL_NAME" ]] && exit 0
|
|
62
|
-
|
|
63
|
-
# Extract plugin from skill name prefix
|
|
64
|
-
PLUGIN="specweave"
|
|
65
|
-
if [[ "$SKILL_NAME" == *:* ]]; then
|
|
66
|
-
PREFIX="${SKILL_NAME%%:*}"
|
|
67
|
-
if [[ "$PREFIX" != "sw" ]]; then
|
|
68
|
-
PLUGIN="$PREFIX"
|
|
69
|
-
fi
|
|
70
|
-
fi
|
|
71
|
-
|
|
72
|
-
bash "$TRACK_SCRIPT" skill "$SKILL_NAME" --plugin "$PLUGIN" --success --increment "$ACTIVE_INCREMENT" 2>/dev/null &
|
|
73
|
-
;;
|
|
74
|
-
|
|
75
|
-
Task)
|
|
76
|
-
AGENT_TYPE=$(echo "$INPUT" | grep -o '"subagent_type"[[:space:]]*:[[:space:]]*"[^"]*"' | head -1 | sed 's/.*"\([^"]*\)".*/\1/')
|
|
77
|
-
[[ -z "$AGENT_TYPE" ]] && AGENT_TYPE="general"
|
|
78
|
-
|
|
79
|
-
bash "$TRACK_SCRIPT" agent "$AGENT_TYPE" --plugin specweave --success --increment "$ACTIVE_INCREMENT" 2>/dev/null &
|
|
80
|
-
;;
|
|
81
|
-
esac
|
|
82
|
-
|
|
83
|
-
exit 0
|