cc-devflow 2.5.0 → 4.1.0

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.
Files changed (190) hide show
  1. package/.claude/CLAUDE.md +1065 -53
  2. package/.claude/agents/dev-implementer.md +195 -0
  3. package/.claude/commands/{flow-archive.md → flow/archive.md} +46 -11
  4. package/.claude/commands/flow/context.md +150 -0
  5. package/.claude/commands/flow/delta.md +245 -0
  6. package/.claude/commands/{flow-dev.md → flow/dev.md} +112 -11
  7. package/.claude/commands/flow/init.md +45 -0
  8. package/.claude/commands/flow/quality.md +159 -0
  9. package/.claude/commands/flow/spec.md +186 -0
  10. package/.claude/commands/flow/workspace.md +146 -0
  11. package/.claude/commands/{cancel-ralph.md → util/cancel-ralph.md} +1 -0
  12. package/.claude/config/quality-gates.yml +305 -0
  13. package/.claude/docs/guides/TEAM_MODE_GUIDE.md +313 -0
  14. package/.claude/docs/templates/DELTA_SPEC_TEMPLATE.md +91 -0
  15. package/.claude/docs/templates/DESIGN_DECISIONS_TEMPLATE.md +151 -0
  16. package/.claude/docs/templates/JOURNAL_TEMPLATE.md +75 -0
  17. package/.claude/docs/templates/_shared/CLAUDE.md +36 -0
  18. package/.claude/docs/templates/_shared/CONSTITUTION_CHECK.md +125 -0
  19. package/.claude/docs/templates/_shared/VALIDATION_CHECKLIST.md +187 -0
  20. package/.claude/docs/templates/_shared/YAML_FRONTMATTER.md +164 -0
  21. package/.claude/docs/templates/context/dev.jsonl.template +6 -0
  22. package/.claude/docs/templates/context/epic.jsonl.template +5 -0
  23. package/.claude/docs/templates/context/prd.jsonl.template +4 -0
  24. package/.claude/docs/templates/context/research.jsonl.template +4 -0
  25. package/.claude/docs/templates/context/review.jsonl.template +5 -0
  26. package/.claude/docs/templates/context/tech.jsonl.template +5 -0
  27. package/.claude/hooks/CLAUDE.md +342 -0
  28. package/.claude/hooks/inject-agent-context.ts +480 -0
  29. package/.claude/hooks/inject-skill-context.ts +359 -0
  30. package/.claude/hooks/ralph-loop.ts +931 -0
  31. package/.claude/hooks/task-completed-hook.ts +593 -0
  32. package/.claude/hooks/teammate-idle-hook.ts +690 -0
  33. package/.claude/hooks/types/team-types.d.ts +238 -0
  34. package/.claude/rules/devflow-conventions.md +82 -9
  35. package/.claude/scripts/archive-requirement.sh +44 -1
  36. package/.claude/scripts/common.sh +670 -3
  37. package/.claude/scripts/delta-parser.ts +527 -0
  38. package/.claude/scripts/detect-file-conflicts.sh +151 -0
  39. package/.claude/scripts/flow-context-add.sh +134 -0
  40. package/.claude/scripts/flow-context-init.sh +133 -0
  41. package/.claude/scripts/flow-context-validate.sh +144 -0
  42. package/.claude/scripts/flow-delta-apply.sh +297 -0
  43. package/.claude/scripts/flow-delta-archive.sh +71 -0
  44. package/.claude/scripts/flow-delta-create.sh +202 -0
  45. package/.claude/scripts/flow-delta-list.sh +142 -0
  46. package/.claude/scripts/flow-delta-status.sh +235 -0
  47. package/.claude/scripts/flow-quality-full.sh +184 -0
  48. package/.claude/scripts/flow-quality-quick.sh +64 -0
  49. package/.claude/scripts/flow-workspace-init.sh +117 -0
  50. package/.claude/scripts/flow-workspace-record.sh +164 -0
  51. package/.claude/scripts/flow-workspace-start.sh +88 -0
  52. package/.claude/scripts/get-workflow-status.sh +415 -0
  53. package/.claude/scripts/parse-task-dependencies.js +334 -0
  54. package/.claude/scripts/record-quality-error.sh +165 -0
  55. package/.claude/scripts/run-quality-gates.sh +242 -0
  56. package/.claude/scripts/team-dev-init.sh +319 -0
  57. package/.claude/scripts/team-state-recovery.sh +229 -0
  58. package/.claude/scripts/workflow-status.ts +433 -0
  59. package/.claude/settings.json +19 -0
  60. package/.claude/skills/cc-devflow-orchestrator/SKILL.md +85 -200
  61. package/.claude/skills/domain/using-git-worktrees/SKILL.md +252 -0
  62. package/.claude/skills/domain/using-git-worktrees/assets/SHELL_ALIASES.md +133 -0
  63. package/.claude/skills/domain/using-git-worktrees/context.jsonl +4 -0
  64. package/.claude/skills/domain/using-git-worktrees/scripts/worktree-cleanup.sh +218 -0
  65. package/.claude/skills/domain/using-git-worktrees/scripts/worktree-create.sh +232 -0
  66. package/.claude/skills/domain/using-git-worktrees/scripts/worktree-list.sh +130 -0
  67. package/.claude/skills/domain/using-git-worktrees/scripts/worktree-status.sh +140 -0
  68. package/.claude/skills/domain/using-git-worktrees/scripts/worktree-switch.sh +70 -0
  69. package/.claude/skills/utility/skill-creator/LICENSE.txt +202 -0
  70. package/.claude/skills/utility/skill-creator/SKILL.md +356 -0
  71. package/.claude/skills/utility/skill-creator/references/output-patterns.md +82 -0
  72. package/.claude/skills/utility/skill-creator/references/workflows.md +28 -0
  73. package/.claude/skills/utility/skill-creator/scripts/init_skill.py +303 -0
  74. package/.claude/skills/utility/skill-creator/scripts/package_skill.py +110 -0
  75. package/.claude/skills/utility/skill-creator/scripts/quick_validate.py +95 -0
  76. package/.claude/skills/workflow/flow-dev/CLAUDE.md +78 -0
  77. package/.claude/skills/workflow/flow-dev/SKILL.md +96 -0
  78. package/.claude/skills/workflow/flow-dev/assets/IMPLEMENTATION_PLAN_TEMPLATE.md +71 -0
  79. package/.claude/skills/workflow/flow-dev/context.jsonl +8 -0
  80. package/.claude/skills/workflow/flow-dev/dev-implementer.jsonl +8 -0
  81. package/.claude/skills/workflow/flow-dev/scripts/entry-gate.sh +116 -0
  82. package/.claude/skills/workflow/flow-dev/scripts/exit-gate.sh +101 -0
  83. package/.claude/skills/workflow/flow-dev/scripts/task-orchestrator.sh +106 -0
  84. package/.claude/skills/workflow/flow-fix/SKILL.md +105 -0
  85. package/.claude/skills/workflow/flow-fix/context.jsonl +6 -0
  86. package/.claude/skills/workflow/flow-fix/references/bug-analyzer.md +381 -0
  87. package/.claude/skills/workflow/flow-init/SKILL.md +211 -0
  88. package/.claude/skills/workflow/flow-init/assets/BRAINSTORM_TEMPLATE.md +148 -0
  89. package/.claude/skills/workflow/flow-init/assets/INIT_FLOW_TEMPLATE.md +198 -0
  90. package/.claude/skills/workflow/flow-init/assets/RESEARCH_TEMPLATE.md +276 -0
  91. package/.claude/skills/workflow/flow-init/context.jsonl +5 -0
  92. package/.claude/skills/workflow/flow-init/references/flow-researcher.md +132 -0
  93. package/.claude/skills/workflow/flow-init/scripts/check-prerequisites.sh +232 -0
  94. package/.claude/skills/workflow/flow-init/scripts/consolidate-research.sh +182 -0
  95. package/.claude/skills/workflow/flow-init/scripts/create-requirement.sh +515 -0
  96. package/.claude/skills/workflow/flow-init/scripts/generate-research-tasks.sh +157 -0
  97. package/.claude/skills/workflow/flow-init/scripts/populate-research-tasks.sh +284 -0
  98. package/.claude/skills/workflow/flow-init/scripts/validate-research.sh +332 -0
  99. package/.claude/skills/workflow/flow-quality/SKILL.md +94 -0
  100. package/.claude/skills/workflow/flow-quality/context.jsonl +6 -0
  101. package/.claude/skills/workflow/flow-quality/references/code-quality-reviewer.md +205 -0
  102. package/.claude/skills/workflow/flow-quality/references/qa-tester.md +313 -0
  103. package/.claude/skills/workflow/flow-quality/references/security-reviewer.md +314 -0
  104. package/.claude/skills/workflow/flow-quality/references/spec-reviewer.md +221 -0
  105. package/.claude/skills/workflow/flow-release/SKILL.md +126 -0
  106. package/.claude/skills/workflow/flow-release/context.jsonl +7 -0
  107. package/.claude/skills/workflow/flow-release/references/release-manager.md +295 -0
  108. package/.claude/skills/workflow/flow-spec/CLAUDE.md +103 -0
  109. package/.claude/skills/workflow/flow-spec/SKILL.md +545 -0
  110. package/.claude/skills/workflow/flow-spec/context.jsonl +7 -0
  111. package/.claude/skills/workflow/flow-spec/scripts/entry-gate.sh +194 -0
  112. package/.claude/skills/workflow/flow-spec/scripts/exit-gate.sh +244 -0
  113. package/.claude/skills/workflow/flow-spec/scripts/parallel-orchestrator.sh +205 -0
  114. package/.claude/skills/workflow/flow-spec/scripts/team-communication.sh +353 -0
  115. package/.claude/skills/workflow/flow-spec/scripts/team-init.sh +195 -0
  116. package/.claude/skills/workflow/flow-spec/scripts/test-team-mode.sh +496 -0
  117. package/.claude/skills/workflow/flow-spec/team-config.json +165 -0
  118. package/.claude/skills/workflow.yaml +417 -0
  119. package/CHANGELOG.md +233 -0
  120. package/README.md +193 -33
  121. package/README.zh-CN.md +206 -46
  122. package/lib/compiler/CLAUDE.md +77 -46
  123. package/lib/compiler/__tests__/multi-module-emitters.test.js +508 -0
  124. package/lib/compiler/context-expander.js +179 -0
  125. package/lib/compiler/emitters/antigravity-emitter.js +195 -5
  126. package/lib/compiler/emitters/base-emitter.js +217 -2
  127. package/lib/compiler/emitters/codex-emitter.js +200 -4
  128. package/lib/compiler/emitters/cursor-emitter.js +307 -3
  129. package/lib/compiler/emitters/qwen-emitter.js +196 -4
  130. package/lib/compiler/index.js +197 -2
  131. package/lib/compiler/platforms.js +270 -21
  132. package/package.json +2 -2
  133. package/.claude/commands/flow-epic.md +0 -183
  134. package/.claude/commands/flow-init.md +0 -370
  135. package/.claude/commands/flow-prd.md +0 -144
  136. package/.claude/commands/flow-qa.md +0 -93
  137. package/.claude/commands/flow-review.md +0 -257
  138. package/.claude/commands/flow-tech.md +0 -142
  139. package/.claude/commands/flow-ui.md +0 -189
  140. package/.claude/skills/file-header-guardian/SKILL.md +0 -56
  141. package/.claude/skills/skill-developer/ADVANCED.md +0 -197
  142. package/.claude/skills/skill-developer/HOOK_MECHANISMS.md +0 -306
  143. package/.claude/skills/skill-developer/PATTERNS_LIBRARY.md +0 -152
  144. package/.claude/skills/skill-developer/SKILL.md +0 -426
  145. package/.claude/skills/skill-developer/SKILL_RULES_REFERENCE.md +0 -315
  146. package/.claude/skills/skill-developer/TRIGGER_TYPES.md +0 -305
  147. package/.claude/skills/skill-developer/TROUBLESHOOTING.md +0 -514
  148. package/.claude/skills/writing-skills/SKILL.md +0 -655
  149. package/.claude/skills/writing-skills/anthropic-best-practices.md +0 -1150
  150. package/.claude/skills/writing-skills/examples/CLAUDE_MD_TESTING.md +0 -189
  151. package/.claude/skills/writing-skills/graphviz-conventions.dot +0 -172
  152. package/.claude/skills/writing-skills/persuasion-principles.md +0 -187
  153. package/.claude/skills/writing-skills/render-graphs.js +0 -168
  154. package/.claude/skills/writing-skills/testing-skills-with-subagents.md +0 -384
  155. package/.claude/tsc-cache/795ba6e3-b98a-423b-bab2-51aa62812569/affected-repos.txt +0 -1
  156. package/.claude/tsc-cache/ae335694-be5a-4ba4-a1a0-b676c09a7906/affected-repos.txt +0 -1
  157. /package/.claude/commands/{core-architecture.md → core/architecture.md} +0 -0
  158. /package/.claude/commands/{core-guidelines.md → core/guidelines.md} +0 -0
  159. /package/.claude/commands/{core-roadmap.md → core/roadmap.md} +0 -0
  160. /package/.claude/commands/{core-style.md → core/style.md} +0 -0
  161. /package/.claude/commands/{flow-checklist.md → flow/checklist.md} +0 -0
  162. /package/.claude/commands/{flow-clarify.md → flow/clarify.md} +0 -0
  163. /package/.claude/commands/{flow-constitution.md → flow/constitution.md} +0 -0
  164. /package/.claude/commands/{flow-fix.md → flow/fix.md} +0 -0
  165. /package/.claude/commands/{flow-ideate.md → flow/ideate.md} +0 -0
  166. /package/.claude/commands/{flow-new.md → flow/new.md} +0 -0
  167. /package/.claude/commands/{flow-release.md → flow/release.md} +0 -0
  168. /package/.claude/commands/{flow-restart.md → flow/restart.md} +0 -0
  169. /package/.claude/commands/{flow-status.md → flow/status.md} +0 -0
  170. /package/.claude/commands/{flow-update.md → flow/update.md} +0 -0
  171. /package/.claude/commands/{flow-upgrade.md → flow/upgrade.md} +0 -0
  172. /package/.claude/commands/{flow-verify.md → flow/verify.md} +0 -0
  173. /package/.claude/commands/{code-review-high.md → util/code-review.md} +0 -0
  174. /package/.claude/commands/{git-commit.md → util/git-commit.md} +0 -0
  175. /package/.claude/commands/{problem-analyzer.md → util/problem-analyzer.md} +0 -0
  176. /package/.claude/skills/{flow-attention-refresh → domain/attention-refresh}/SKILL.md +0 -0
  177. /package/.claude/skills/{flow-brainstorming → domain/brainstorming}/SKILL.md +0 -0
  178. /package/.claude/skills/{flow-debugging → domain/debugging}/SKILL.md +0 -0
  179. /package/.claude/skills/{flow-finishing-branch → domain/finishing-branch}/SKILL.md +0 -0
  180. /package/.claude/skills/{flow-receiving-review → domain/receiving-review}/SKILL.md +0 -0
  181. /package/.claude/skills/{flow-tdd → domain/tdd}/SKILL.md +0 -0
  182. /package/.claude/skills/{verification-before-completion → domain/verification}/SKILL.md +0 -0
  183. /package/.claude/skills/{constitution-guardian → guardrail/constitution-guardian}/SKILL.md +0 -0
  184. /package/.claude/skills/{devflow-tdd-enforcer → guardrail/tdd-enforcer}/SKILL.md +0 -0
  185. /package/.claude/skills/{devflow-constitution-quick-ref → utility/constitution-quick-ref}/SKILL.md +0 -0
  186. /package/.claude/skills/{devflow-file-standards → utility/file-standards}/SKILL.md +0 -0
  187. /package/.claude/skills/{fractal-docs-generator → utility/fractal-docs}/SKILL.md +0 -0
  188. /package/.claude/skills/{journey-coherence-checker → utility/journey-checker}/SKILL.md +0 -0
  189. /package/.claude/skills/{journey-coherence-checker → utility/journey-checker}/pressure-scenarios.md +0 -0
  190. /package/.claude/skills/{npm-release → utility/npm-release}/SKILL.md +0 -0
@@ -0,0 +1,130 @@
1
+ #!/usr/bin/env bash
2
+ # =============================================================================
3
+ # worktree-list.sh - List all git worktrees
4
+ # =============================================================================
5
+ #
6
+ # Usage: worktree-list.sh [OPTIONS]
7
+ #
8
+ # OPTIONS:
9
+ # --json Output in JSON format
10
+ # --verbose, -v Show detailed information
11
+ # --help, -h Show help message
12
+ #
13
+ # [PROTOCOL]: 变更时更新此头部,然后检查 CLAUDE.md
14
+
15
+ set -e
16
+
17
+ JSON_MODE=false
18
+ VERBOSE=false
19
+
20
+ while [[ $# -gt 0 ]]; do
21
+ case "$1" in
22
+ --json)
23
+ JSON_MODE=true
24
+ shift
25
+ ;;
26
+ --verbose|-v)
27
+ VERBOSE=true
28
+ shift
29
+ ;;
30
+ --help|-h)
31
+ cat << 'EOF'
32
+ Usage: worktree-list.sh [OPTIONS]
33
+
34
+ List all git worktrees.
35
+
36
+ OPTIONS:
37
+ --json Output in JSON format
38
+ --verbose, -v Show detailed information
39
+ --help, -h Show help message
40
+ EOF
41
+ exit 0
42
+ ;;
43
+ *)
44
+ echo "ERROR: Unknown option '$1'. Use --help for usage." >&2
45
+ exit 1
46
+ ;;
47
+ esac
48
+ done
49
+
50
+ # =============================================================================
51
+ # Source Common Functions
52
+ # =============================================================================
53
+
54
+ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
55
+ COMMON_SH="$SCRIPT_DIR/../../../scripts/common.sh"
56
+
57
+ if [[ -f "$COMMON_SH" ]]; then
58
+ source "$COMMON_SH"
59
+ fi
60
+
61
+ # =============================================================================
62
+ # Get Main Repo
63
+ # =============================================================================
64
+
65
+ MAIN_REPO=$(git rev-parse --show-toplevel 2>/dev/null)
66
+ if [[ -z "$MAIN_REPO" ]]; then
67
+ echo "ERROR: Not in a git repository" >&2
68
+ exit 1
69
+ fi
70
+
71
+ # =============================================================================
72
+ # List Worktrees
73
+ # =============================================================================
74
+
75
+ if $JSON_MODE; then
76
+ echo "["
77
+ first=true
78
+ while IFS= read -r line; do
79
+ if [[ "$line" =~ ^worktree ]]; then
80
+ if ! $first; then
81
+ echo ","
82
+ fi
83
+ first=false
84
+ path="${line#worktree }"
85
+ elif [[ "$line" =~ ^HEAD ]]; then
86
+ head="${line#HEAD }"
87
+ elif [[ "$line" =~ ^branch ]]; then
88
+ branch="${line#branch refs/heads/}"
89
+ # Extract REQ_ID from path
90
+ req_id=""
91
+ if [[ "$path" =~ -([A-Z]+-[0-9]+)$ ]]; then
92
+ req_id="${BASH_REMATCH[1]}"
93
+ fi
94
+ printf '{"path":"%s","branch":"%s","head":"%s","req_id":"%s"}' \
95
+ "$path" "$branch" "$head" "$req_id"
96
+ elif [[ "$line" =~ ^detached ]]; then
97
+ branch="(detached)"
98
+ req_id=""
99
+ if [[ "$path" =~ -([A-Z]+-[0-9]+)$ ]]; then
100
+ req_id="${BASH_REMATCH[1]}"
101
+ fi
102
+ printf '{"path":"%s","branch":"%s","head":"%s","req_id":"%s"}' \
103
+ "$path" "$branch" "$head" "$req_id"
104
+ fi
105
+ done < <(git worktree list --porcelain)
106
+ echo ""
107
+ echo "]"
108
+ else
109
+ echo "Git Worktrees:"
110
+ echo ""
111
+
112
+ if $VERBOSE; then
113
+ git worktree list --porcelain | while IFS= read -r line; do
114
+ if [[ "$line" =~ ^worktree ]]; then
115
+ path="${line#worktree }"
116
+ echo "Path: $path"
117
+ elif [[ "$line" =~ ^HEAD ]]; then
118
+ echo "HEAD: ${line#HEAD }"
119
+ elif [[ "$line" =~ ^branch ]]; then
120
+ echo "Branch: ${line#branch refs/heads/}"
121
+ echo ""
122
+ elif [[ "$line" =~ ^detached ]]; then
123
+ echo "Branch: (detached)"
124
+ echo ""
125
+ fi
126
+ done
127
+ else
128
+ git worktree list
129
+ fi
130
+ fi
@@ -0,0 +1,140 @@
1
+ #!/usr/bin/env bash
2
+ # =============================================================================
3
+ # worktree-status.sh - Check current worktree status
4
+ # =============================================================================
5
+ #
6
+ # Usage: worktree-status.sh [OPTIONS]
7
+ #
8
+ # OPTIONS:
9
+ # --json Output in JSON format
10
+ # --help, -h Show help message
11
+ #
12
+ # [PROTOCOL]: 变更时更新此头部,然后检查 CLAUDE.md
13
+
14
+ set -e
15
+
16
+ JSON_MODE=false
17
+
18
+ while [[ $# -gt 0 ]]; do
19
+ case "$1" in
20
+ --json)
21
+ JSON_MODE=true
22
+ shift
23
+ ;;
24
+ --help|-h)
25
+ cat << 'EOF'
26
+ Usage: worktree-status.sh [OPTIONS]
27
+
28
+ Check current worktree status.
29
+
30
+ OPTIONS:
31
+ --json Output in JSON format
32
+ --help, -h Show help message
33
+ EOF
34
+ exit 0
35
+ ;;
36
+ *)
37
+ echo "ERROR: Unknown option '$1'. Use --help for usage." >&2
38
+ exit 1
39
+ ;;
40
+ esac
41
+ done
42
+
43
+ # =============================================================================
44
+ # Source Common Functions
45
+ # =============================================================================
46
+
47
+ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
48
+ COMMON_SH="$SCRIPT_DIR/../../../scripts/common.sh"
49
+
50
+ if [[ -f "$COMMON_SH" ]]; then
51
+ source "$COMMON_SH"
52
+ fi
53
+
54
+ # =============================================================================
55
+ # Gather Information
56
+ # =============================================================================
57
+
58
+ CURRENT_DIR=$(pwd)
59
+ GIT_ROOT=$(git rev-parse --show-toplevel 2>/dev/null || echo "")
60
+
61
+ if [[ -z "$GIT_ROOT" ]]; then
62
+ if $JSON_MODE; then
63
+ printf '{"error":"not_git_repo"}\n'
64
+ else
65
+ echo "ERROR: Not in a git repository" >&2
66
+ fi
67
+ exit 1
68
+ fi
69
+
70
+ # Check if in worktree
71
+ IS_WORKTREE=false
72
+ MAIN_REPO=""
73
+ WORKTREE_COUNT=0
74
+
75
+ # Get worktree info
76
+ GIT_DIR=$(git rev-parse --git-dir 2>/dev/null)
77
+ if [[ "$GIT_DIR" == *".git/worktrees/"* ]]; then
78
+ IS_WORKTREE=true
79
+ # Extract main repo path from gitdir file
80
+ MAIN_REPO=$(cat "$GIT_ROOT/.git" 2>/dev/null | sed 's/gitdir: //' | sed 's|/.git/worktrees/.*||')
81
+ else
82
+ MAIN_REPO="$GIT_ROOT"
83
+ fi
84
+
85
+ # Count worktrees
86
+ WORKTREE_COUNT=$(git worktree list | wc -l | tr -d ' ')
87
+
88
+ # Get current branch
89
+ BRANCH=$(git rev-parse --abbrev-ref HEAD 2>/dev/null || echo "")
90
+
91
+ # Extract REQ_ID from path or branch
92
+ REQ_ID=""
93
+ if [[ "$GIT_ROOT" =~ -([A-Z]+-[0-9]+)$ ]]; then
94
+ REQ_ID="${BASH_REMATCH[1]}"
95
+ elif [[ "$BRANCH" =~ (REQ-[0-9]+|BUG-[0-9]+) ]]; then
96
+ REQ_ID="${BASH_REMATCH[1]}"
97
+ fi
98
+
99
+ # Check git status
100
+ HAS_CHANGES=false
101
+ if [[ -n $(git status --porcelain 2>/dev/null) ]]; then
102
+ HAS_CHANGES=true
103
+ fi
104
+
105
+ # =============================================================================
106
+ # Output
107
+ # =============================================================================
108
+
109
+ if $JSON_MODE; then
110
+ printf '{"current_dir":"%s","git_root":"%s","is_worktree":%s,"main_repo":"%s","branch":"%s","req_id":"%s","worktree_count":%d,"has_changes":%s}\n' \
111
+ "$CURRENT_DIR" \
112
+ "$GIT_ROOT" \
113
+ "$IS_WORKTREE" \
114
+ "$MAIN_REPO" \
115
+ "$BRANCH" \
116
+ "$REQ_ID" \
117
+ "$WORKTREE_COUNT" \
118
+ "$HAS_CHANGES"
119
+ else
120
+ echo "Worktree Status"
121
+ echo "==============="
122
+ echo ""
123
+ echo "Current Directory: $CURRENT_DIR"
124
+ echo "Git Root: $GIT_ROOT"
125
+ echo "Is Worktree: $IS_WORKTREE"
126
+ echo "Main Repo: $MAIN_REPO"
127
+ echo "Branch: $BRANCH"
128
+ if [[ -n "$REQ_ID" ]]; then
129
+ echo "Requirement ID: $REQ_ID"
130
+ fi
131
+ echo "Total Worktrees: $WORKTREE_COUNT"
132
+ echo "Has Changes: $HAS_CHANGES"
133
+ echo ""
134
+
135
+ if $IS_WORKTREE; then
136
+ echo "You are in a worktree. Main repo is at: $MAIN_REPO"
137
+ else
138
+ echo "You are in the main repository."
139
+ fi
140
+ fi
@@ -0,0 +1,70 @@
1
+ #!/usr/bin/env bash
2
+ # =============================================================================
3
+ # worktree-switch.sh - Switch to a worktree by REQ_ID
4
+ # =============================================================================
5
+ #
6
+ # Usage: worktree-switch.sh REQ_ID
7
+ #
8
+ # This script outputs the path to switch to. Use with:
9
+ # cd $(worktree-switch.sh REQ-123)
10
+ #
11
+ # [PROTOCOL]: 变更时更新此头部,然后检查 CLAUDE.md
12
+
13
+ set -e
14
+
15
+ REQ_ID=""
16
+
17
+ while [[ $# -gt 0 ]]; do
18
+ case "$1" in
19
+ --help|-h)
20
+ cat << 'EOF'
21
+ Usage: worktree-switch.sh REQ_ID
22
+
23
+ Switch to a worktree by REQ_ID.
24
+
25
+ This script outputs the path to switch to. Use with:
26
+ cd $(worktree-switch.sh REQ-123)
27
+
28
+ Or use the zw shell function:
29
+ zw REQ-123
30
+ EOF
31
+ exit 0
32
+ ;;
33
+ -*)
34
+ echo "ERROR: Unknown option '$1'. Use --help for usage." >&2
35
+ exit 1
36
+ ;;
37
+ *)
38
+ REQ_ID="$1"
39
+ shift
40
+ ;;
41
+ esac
42
+ done
43
+
44
+ if [[ -z "$REQ_ID" ]]; then
45
+ echo "ERROR: REQ_ID is required. Use --help for usage." >&2
46
+ exit 1
47
+ fi
48
+
49
+ # Normalize to uppercase
50
+ REQ_ID=$(echo "$REQ_ID" | tr '[:lower:]' '[:upper:]')
51
+
52
+ # =============================================================================
53
+ # Find Worktree
54
+ # =============================================================================
55
+
56
+ MAIN_REPO=$(git rev-parse --show-toplevel 2>/dev/null)
57
+ if [[ -z "$MAIN_REPO" ]]; then
58
+ echo "ERROR: Not in a git repository" >&2
59
+ exit 1
60
+ fi
61
+
62
+ REPO_NAME=$(basename "$MAIN_REPO")
63
+ WORKTREE_DIR="$(dirname "$MAIN_REPO")/${REPO_NAME}-${REQ_ID}"
64
+
65
+ if [[ -d "$WORKTREE_DIR" ]]; then
66
+ echo "$WORKTREE_DIR"
67
+ else
68
+ echo "ERROR: Worktree not found: $WORKTREE_DIR" >&2
69
+ exit 1
70
+ fi
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.