xwang 0.0.10 → 0.0.11

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.
@@ -6,6 +6,7 @@
6
6
  "xwang/scripts/xwang-state.sh",
7
7
  "xwang/scripts/xwang-guard.sh",
8
8
  "xwang/scripts/xwang-doc-lang-check.sh",
9
+ "xwang/scripts/xwang-create-change.sh",
9
10
  "xwang-open/SKILL.md",
10
11
  "xwang-open/scripts/xwang-open-check.sh",
11
12
  "xwang-design/SKILL.md",
@@ -0,0 +1,151 @@
1
+ #!/bin/bash
2
+ # xwang-create-change — create an OpenSpec change directory scaffold with a given name.
3
+ # Usage: xwang-create-change.sh <change-name> <workflow> [schema]
4
+ # Creates openspec/changes/<change-name>/ with .openspec.yaml and minimal artifact stubs.
5
+ # Exits 0 on success, 1 on error.
6
+
7
+ set -euo pipefail
8
+
9
+ name="${1:-}"
10
+ workflow="${2:-}"
11
+ schema="${3:-spec-driven}"
12
+
13
+ if [ -z "$name" ] || [ -z "$workflow" ]; then
14
+ echo "Usage: $0 <change-name> <workflow> [schema]" >&2
15
+ exit 2
16
+ fi
17
+
18
+ # Validate name using the same rules as xwang-state/xwang-guard
19
+ if [[ "$name" =~ \.\. ]]; then
20
+ echo "ERROR: Change name cannot contain '..'" >&2
21
+ exit 1
22
+ fi
23
+ if printf '%s' "$name" | perl -ne 'exit 1 if m{[/\\\s\0-\x1F\x7F;|&$`()<>{}[\]*'"'"'"!#@%^=+~]}; exit 0'; then
24
+ : # valid
25
+ else
26
+ echo "ERROR: Invalid change name: '$name'" >&2
27
+ echo "Avoid: / \\ spaces control chars and shell metacharacters" >&2
28
+ exit 1
29
+ fi
30
+
31
+ # Determine project root
32
+ find_project_root() {
33
+ if [ -n "${XWANG_PROJECT_ROOT:-}" ]; then
34
+ printf '%s' "$XWANG_PROJECT_ROOT"
35
+ return 0
36
+ fi
37
+ local git_root
38
+ git_root=$(git rev-parse --show-toplevel 2>/dev/null || true)
39
+ if [ -n "$git_root" ]; then
40
+ printf '%s' "$git_root"
41
+ return 0
42
+ fi
43
+ local dir="$PWD"
44
+ while [ "$dir" != "/" ]; do
45
+ if [ -d "$dir/openspec/changes" ]; then
46
+ printf '%s' "$dir"
47
+ return 0
48
+ fi
49
+ dir=$(dirname "$dir")
50
+ done
51
+ printf '%s' "$PWD"
52
+ }
53
+
54
+ PROJECT_ROOT=$(find_project_root)
55
+ CHANGE_DIR="$PROJECT_ROOT/openspec/changes/$name"
56
+
57
+ if [ -d "$CHANGE_DIR" ]; then
58
+ echo "ERROR: change directory already exists: $CHANGE_DIR" >&2
59
+ exit 1
60
+ fi
61
+
62
+ mkdir -p "$CHANGE_DIR"
63
+
64
+ # .openspec.yaml
65
+ cat > "$CHANGE_DIR/.openspec.yaml" <<EOF
66
+ schema: $schema
67
+ created: $(date -u +%Y-%m-%d)
68
+ EOF
69
+
70
+ # Minimal stubs; the caller (xwang-design/hotfix/tweak) should overwrite with real content.
71
+ case "$workflow" in
72
+ full)
73
+ cat > "$CHANGE_DIR/proposal.md" <<'EOF'
74
+ ## Why
75
+
76
+ ## What Changes
77
+
78
+ ## Capabilities
79
+
80
+ ### New Capabilities
81
+
82
+ 无。
83
+
84
+ ### Modified Capabilities
85
+
86
+ ## Impact
87
+ EOF
88
+ cat > "$CHANGE_DIR/design.md" <<'EOF'
89
+ ## Context
90
+
91
+ ## Goals / Non-Goals
92
+
93
+ **Goals:**
94
+
95
+ **Non-Goals:**
96
+
97
+ ## Decisions
98
+
99
+ ## Risks / Trade-offs
100
+ EOF
101
+ cat > "$CHANGE_DIR/tasks.md" <<'EOF'
102
+ ## Tasks
103
+
104
+ - [ ] Task 1
105
+ EOF
106
+ ;;
107
+ quick|hotfix)
108
+ cat > "$CHANGE_DIR/proposal.md" <<'EOF'
109
+ ## Why
110
+
111
+ ## What Changes
112
+
113
+ ## Impact
114
+ EOF
115
+ cat > "$CHANGE_DIR/design.md" <<'EOF'
116
+ ## Context
117
+
118
+ ## Solution
119
+
120
+ ## Risks / Trade-offs
121
+ EOF
122
+ cat > "$CHANGE_DIR/tasks.md" <<'EOF'
123
+ ## Tasks
124
+
125
+ - [ ] Task 1
126
+ EOF
127
+ ;;
128
+ tweak)
129
+ cat > "$CHANGE_DIR/proposal.md" <<'EOF'
130
+ ## Why
131
+
132
+ ## What Changes
133
+
134
+ ## Impact
135
+ EOF
136
+ cat > "$CHANGE_DIR/design.md" <<'EOF'
137
+ ## Solution
138
+ EOF
139
+ cat > "$CHANGE_DIR/tasks.md" <<'EOF'
140
+ ## Tasks
141
+
142
+ - [ ] Task 1
143
+ EOF
144
+ ;;
145
+ *)
146
+ echo "ERROR: unknown workflow: $workflow" >&2
147
+ exit 1
148
+ ;;
149
+ esac
150
+
151
+ echo "$CHANGE_DIR"
@@ -76,6 +76,17 @@ if [ -z "${XWANG_DOC_LANG_CHECK:-}" ]; then
76
76
  fi
77
77
  export XWANG_DOC_LANG_CHECK
78
78
 
79
+ # Locate xwang-create-change.sh using the same approach.
80
+ if [ -z "${XWANG_CREATE_CHANGE:-}" ]; then
81
+ XWANG_CREATE_CHANGE_SIBLING="${XWANG_SCRIPT_DIR}/xwang-create-change.sh"
82
+ if [ -f "$XWANG_CREATE_CHANGE_SIBLING" ]; then
83
+ XWANG_CREATE_CHANGE="$(cd "$(dirname "$XWANG_CREATE_CHANGE_SIBLING")" && pwd)/$(basename "$XWANG_CREATE_CHANGE_SIBLING")"
84
+ else
85
+ XWANG_CREATE_CHANGE="$(locate_by_glob '*/xwang/scripts/xwang-create-change.sh' "${SEARCH_DIRS[@]}" 2>/dev/null || true)"
86
+ fi
87
+ fi
88
+ export XWANG_CREATE_CHANGE
89
+
79
90
  if [ -z "$XWANG_OPEN_CHECK" ] || [ ! -f "$XWANG_OPEN_CHECK" ]; then
80
91
  echo "WARNING: xwang-open-check.sh not found" >&2
81
92
  fi
@@ -87,3 +98,7 @@ fi
87
98
  if [ -z "$XWANG_DOC_LANG_CHECK" ] || [ ! -f "$XWANG_DOC_LANG_CHECK" ]; then
88
99
  echo "WARNING: xwang-doc-lang-check.sh not found" >&2
89
100
  fi
101
+
102
+ if [ -z "$XWANG_CREATE_CHANGE" ] || [ ! -f "$XWANG_CREATE_CHANGE" ]; then
103
+ echo "WARNING: xwang-create-change.sh not found" >&2
104
+ fi
@@ -127,8 +127,17 @@ grilling 确认完成后、生成 PRD 前,**必须**执行 PRD 拆分预检并
127
127
 
128
128
  ### Step 3:创建 OpenSpec change
129
129
 
130
- - [ ] 直接调用 `/openspec-new-change` 创建 change:change 名称为 `<name>`,文档/描述使用 PRD 的中文内容,过程中不再询问用户确认;若其流程中出现确认提示(如“是否继续创建 proposal.md?”),直接代为确认并继续。
131
- - [ ] **`/openspec-new-change` 生成的所有文档/artifact 必须使用中文表述,包括但不限于 `proposal.md`、`design.md`、`tasks.md` 以及 `specs/*/spec.md`**。
130
+ - [ ] 使用 xwang 自带脚本创建中文 change 目录和 OpenSpec 骨架(绕过 `/openspec-new-change` 的英文 kebab-case 限制,避免中文文件被删除或重命名):
131
+
132
+ ```bash
133
+ XWANG_ENV="${XWANG_ENV:-$(find . "$HOME"/.*/skills "$HOME/.config" -path '*/xwang/scripts/xwang-env.sh' -type f -print -quit 2>/dev/null)}"
134
+ . "$XWANG_ENV"
135
+ "$XWANG_CREATE_CHANGE" <name> full
136
+ ```
137
+
138
+ - [ ] 基于 PRD 内容覆盖 `openspec/changes/<name>/proposal.md`、`design.md`、`tasks.md`,确保所有 artifact 使用中文表述。
139
+ - [ ] 如需生成 delta spec,创建 `openspec/changes/<name>/specs/<name>/spec.md`。
140
+ - [ ] **中文名称保护**:任何情况下不得删除、重命名或迁移已创建的中文文件(包括 `openspec/changes/<中文名>/` 和 `docs/mattpocock/<中文名>-prd.md`)。如果创建过程中报错,停止并报告,而不是改为英文。
132
141
 
133
142
  ### Step 4:初始化状态并推进
134
143
 
@@ -30,13 +30,21 @@ fi
30
30
  ### Step 1:快速开启
31
31
 
32
32
  - [ ] 确认用户要触发 hotfix(关键词:xwang-hotfix、hotfix、bugfix、快速修复)。
33
- - [ ] 用户未提供 change 名称时,根据修复主题生成一个简洁的 kebab-case 名称 `<name>`。
34
- - [ ] 直接调用 `/openspec-new-change` 创建精简 change:
33
+ - [ ] 用户未提供 change 名称时,根据修复主题生成一个简洁的中文名称 `<name>`(如 `登录按钮失效修复`)。
34
+ - [ ] 使用 xwang 自带脚本创建中文 change 目录和 OpenSpec 骨架(绕过 `/openspec-new-change` kebab-case 限制):
35
+
36
+ ```bash
37
+ XWANG_ENV="${XWANG_ENV:-$(find . "$HOME"/.*/skills "$HOME/.config" -path '*/xwang/scripts/xwang-env.sh' -type f -print -quit 2>/dev/null)}"
38
+ . "$XWANG_ENV"
39
+ "$XWANG_CREATE_CHANGE" <name> hotfix
40
+ ```
41
+
42
+ - [ ] 基于修复内容覆盖 `openspec/changes/<name>/proposal.md`、`design.md`、`tasks.md`:
35
43
  - `proposal.md`:问题描述 + 根因分析 + 修复目标
36
44
  - `design.md`:修复方案(1 个即可,无需多方案对比)
37
45
  - `tasks.md`:修复任务清单
38
46
  - 通常**无需 delta spec**(除非修复改变了已有 spec 的验收场景)
39
- - [ ] **`/openspec-new-change` 生成的所有文档/artifact 必须使用中文表述**。
47
+ - [ ] **`openspec/changes/<name>/` 下的所有文档/artifact 必须使用中文表述**。
40
48
  - [ ] 调用 `"$XWANG_STATE" init <name> quick` 初始化状态(`workflow: quick`,`phase: build`,跳过 design)。
41
49
 
42
50
  ### Step 2:直接构建
@@ -31,13 +31,21 @@ fi
31
31
  ### Step 1:快速开启
32
32
 
33
33
  - [ ] 确认用户要触发 tweak(关键词:xwang-tweak、tweak、小改动、局部优化)。
34
- - [ ] 用户未提供 change 名称时,根据变更主题生成一个简洁的 kebab-case 名称 `<name>`。
35
- - [ ] 直接调用 `/openspec-new-change` 创建精简 change:
34
+ - [ ] 用户未提供 change 名称时,根据变更主题生成一个简洁的中文名称 `<name>`(如 `文案优化`)。
35
+ - [ ] 使用 xwang 自带脚本创建中文 change 目录和 OpenSpec 骨架(绕过 `/openspec-new-change` kebab-case 限制):
36
+
37
+ ```bash
38
+ XWANG_ENV="${XWANG_ENV:-$(find . "$HOME"/.*/skills "$HOME/.config" -path '*/xwang/scripts/xwang-env.sh' -type f -print -quit 2>/dev/null)}"
39
+ . "$XWANG_ENV"
40
+ "$XWANG_CREATE_CHANGE" <name> tweak
41
+ ```
42
+
43
+ - [ ] 基于变更内容覆盖 `openspec/changes/<name>/proposal.md`、`design.md`、`tasks.md`:
36
44
  - `proposal.md`:变更动机 + 目标 + 范围
37
45
  - `design.md`:简短实现说明(无需方案对比)
38
46
  - `tasks.md`:不超过 3 个任务
39
47
  - **无需 delta spec**(一旦需要,升级为完整 `/xwang`)
40
- - [ ] **`/openspec-new-change` 生成的所有文档/artifact 必须使用中文表述**。
48
+ - [ ] **`openspec/changes/<name>/` 下的所有文档/artifact 必须使用中文表述**。
41
49
  - [ ] 调用 `"$XWANG_STATE" init <name> tweak` 初始化状态(`workflow: tweak`,`phase: build`,跳过 design)。
42
50
 
43
51
  ### Step 2:轻量构建
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xwang",
3
- "version": "0.0.10",
3
+ "version": "0.0.11",
4
4
  "description": "xwang CLI",
5
5
  "keywords": [
6
6
  "xwang",