xwang 0.0.4 → 0.0.6
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.
|
@@ -21,6 +21,39 @@ yellow() { echo -e "\033[33m$1\033[0m" >&2; }
|
|
|
21
21
|
# shellcheck disable=SC2034
|
|
22
22
|
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
|
23
23
|
|
|
24
|
+
# --- Project root resolution ---
|
|
25
|
+
|
|
26
|
+
find_project_root() {
|
|
27
|
+
# Explicit override
|
|
28
|
+
if [ -n "${XWANG_PROJECT_ROOT:-}" ]; then
|
|
29
|
+
printf '%s' "$XWANG_PROJECT_ROOT"
|
|
30
|
+
return 0
|
|
31
|
+
fi
|
|
32
|
+
|
|
33
|
+
# Use git root if available
|
|
34
|
+
local git_root
|
|
35
|
+
git_root=$(git rev-parse --show-toplevel 2>/dev/null || true)
|
|
36
|
+
if [ -n "$git_root" ]; then
|
|
37
|
+
printf '%s' "$git_root"
|
|
38
|
+
return 0
|
|
39
|
+
fi
|
|
40
|
+
|
|
41
|
+
# Search upward for openspec/changes directory
|
|
42
|
+
local dir="$PWD"
|
|
43
|
+
while [ "$dir" != "/" ]; do
|
|
44
|
+
if [ -d "$dir/openspec/changes" ]; then
|
|
45
|
+
printf '%s' "$dir"
|
|
46
|
+
return 0
|
|
47
|
+
fi
|
|
48
|
+
dir=$(dirname "$dir")
|
|
49
|
+
done
|
|
50
|
+
|
|
51
|
+
# Fallback to current directory
|
|
52
|
+
printf '%s' "$PWD"
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
PROJECT_ROOT=$(find_project_root)
|
|
56
|
+
|
|
24
57
|
# --- Input validation ---
|
|
25
58
|
|
|
26
59
|
validate_change_name() {
|
|
@@ -60,12 +93,12 @@ validate_enum() {
|
|
|
60
93
|
|
|
61
94
|
yaml_file_for() {
|
|
62
95
|
local change_name="$1"
|
|
63
|
-
echo "openspec/changes/$change_name/.xwang.yaml"
|
|
96
|
+
echo "$PROJECT_ROOT/openspec/changes/$change_name/.xwang.yaml"
|
|
64
97
|
}
|
|
65
98
|
|
|
66
99
|
change_dir_for() {
|
|
67
100
|
local change_name="$1"
|
|
68
|
-
echo "openspec/changes/$change_name"
|
|
101
|
+
echo "$PROJECT_ROOT/openspec/changes/$change_name"
|
|
69
102
|
}
|
|
70
103
|
|
|
71
104
|
yaml_field() {
|
|
@@ -6,6 +6,35 @@
|
|
|
6
6
|
|
|
7
7
|
set -euo pipefail
|
|
8
8
|
|
|
9
|
+
# --- Project root resolution ---
|
|
10
|
+
|
|
11
|
+
find_project_root() {
|
|
12
|
+
if [ -n "${XWANG_PROJECT_ROOT:-}" ]; then
|
|
13
|
+
printf '%s' "$XWANG_PROJECT_ROOT"
|
|
14
|
+
return 0
|
|
15
|
+
fi
|
|
16
|
+
|
|
17
|
+
local git_root
|
|
18
|
+
git_root=$(git rev-parse --show-toplevel 2>/dev/null || true)
|
|
19
|
+
if [ -n "$git_root" ]; then
|
|
20
|
+
printf '%s' "$git_root"
|
|
21
|
+
return 0
|
|
22
|
+
fi
|
|
23
|
+
|
|
24
|
+
local dir="$PWD"
|
|
25
|
+
while [ "$dir" != "/" ]; do
|
|
26
|
+
if [ -d "$dir/openspec/changes" ]; then
|
|
27
|
+
printf '%s' "$dir"
|
|
28
|
+
return 0
|
|
29
|
+
fi
|
|
30
|
+
dir=$(dirname "$dir")
|
|
31
|
+
done
|
|
32
|
+
|
|
33
|
+
printf '%s' "$PWD"
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
PROJECT_ROOT=$(find_project_root)
|
|
37
|
+
|
|
9
38
|
# --- Colors ---
|
|
10
39
|
red() { echo -e "\033[31m$1\033[0m" >&2; }
|
|
11
40
|
yellow() { echo -e "\033[33m$1\033[0m" >&2; }
|
|
@@ -43,7 +72,7 @@ count_unchecked_tasks() {
|
|
|
43
72
|
}
|
|
44
73
|
|
|
45
74
|
# --- Detect active changes ---
|
|
46
|
-
CHANGES_DIR="openspec/changes"
|
|
75
|
+
CHANGES_DIR="$PROJECT_ROOT/openspec/changes"
|
|
47
76
|
JSON_ENTRIES=()
|
|
48
77
|
TEXT_LINES=()
|
|
49
78
|
SIGNAL_COUNT=0
|
|
@@ -127,6 +156,29 @@ if [ -d "$CHANGES_DIR" ]; then
|
|
|
127
156
|
done < <(find "$CHANGES_DIR" -maxdepth 1 -mindepth 1 -type d -print)
|
|
128
157
|
fi
|
|
129
158
|
|
|
159
|
+
# 1b. Orphaned OpenSpec changes (OpenSpec artifacts without .xwang.yaml)
|
|
160
|
+
if [ -d "$CHANGES_DIR" ]; then
|
|
161
|
+
while IFS= read -r change_dir; do
|
|
162
|
+
[ -z "$change_dir" ] && continue
|
|
163
|
+
change_name=$(basename "$change_dir")
|
|
164
|
+
|
|
165
|
+
# Skip the archive directory and changes that already have xwang state.
|
|
166
|
+
[ "$change_name" = "archive" ] && continue
|
|
167
|
+
[ -f "$change_dir/.xwang.yaml" ] && continue
|
|
168
|
+
|
|
169
|
+
# Detect common OpenSpec change artifacts.
|
|
170
|
+
if [ -f "$change_dir/.openspec.yaml" ] || \
|
|
171
|
+
[ -f "$change_dir/proposal.md" ] || \
|
|
172
|
+
[ -f "$change_dir/design.md" ] || \
|
|
173
|
+
[ -f "$change_dir/tasks.md" ] || \
|
|
174
|
+
[ -d "$change_dir/specs" ]; then
|
|
175
|
+
JSON_ENTRIES+=("{\"source\":\"openspec-orphan\",\"name\":\"$change_name\",\"status\":\"orphaned\",\"details\":\"OpenSpec artifacts without .xwang.yaml\",\"action\":\"initialize xwang state or archive before starting new work\"}")
|
|
176
|
+
TEXT_LINES+=(" - [openspec-orphan] $change_name: OpenSpec artifacts present but no .xwang.yaml → initialize xwang state or archive before starting new work")
|
|
177
|
+
SIGNAL_COUNT=$((SIGNAL_COUNT + 1))
|
|
178
|
+
fi
|
|
179
|
+
done < <(find "$CHANGES_DIR" -maxdepth 1 -mindepth 1 -type d -print)
|
|
180
|
+
fi
|
|
181
|
+
|
|
130
182
|
# 2. Git dirty worktree
|
|
131
183
|
GIT_DIRTY=0
|
|
132
184
|
GIT_DETAILS=""
|