@wwkit/harness 1.0.31 → 1.0.33
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/LICENSE +21 -21
- package/README.md +128 -128
- package/agents/scrum.md +186 -180
- package/agents/sprint.md +121 -118
- package/bin/index.js +226 -226
- package/commands/fix.md +87 -87
- package/commands/git-sync.md +217 -217
- package/commands/net-port.md +364 -364
- package/commands/pytest.md +10 -10
- package/commands/resume.md +104 -104
- package/commands/tl.md +11 -11
- package/package.json +8 -7
- package/plugin.js +19 -19
- package/readme/development.md +39 -39
- package/readme/publish.md +41 -41
- package/readme/testing.md +44 -36
- package/scripts/postinstall.js +58 -58
- package/skills/better-skill/SKILL.md +124 -124
- package/skills/blame-skill/SKILL.md +201 -201
- package/skills/extract/SKILL.md +119 -119
- package/skills/extract/references/build-xpath.js +30 -30
- package/skills/extract/references/clean-html.js +90 -90
- package/skills/extract/references/detail.md +54 -54
- package/skills/extract/references/detail.schema.json5 +48 -48
- package/skills/extract/references/extract-detail.js +71 -71
- package/skills/extract/references/extract-regex.js +81 -81
- package/skills/extract/references/extract-sample.js +48 -48
- package/skills/extract/references/list-rule-gen.md +109 -109
- package/skills/extract/references/list.md +134 -134
- package/skills/extract/references/list.schema.json5 +33 -33
- package/skills/extract/references/navi.md +44 -44
- package/skills/extract/references/navi.schema.json5 +23 -23
- package/skills/extract/references/text.md +40 -40
- package/skills/extract/references/text.schema.json5 +21 -21
- package/skills/extract/references/to-text.js +20 -20
- package/skills/extract/references/validate-schema.js +39 -39
- package/skills/jstest/SKILL.md +561 -561
- package/skills/jstest/references/case-create.md +327 -327
- package/skills/jstest/references/case-fix.md +273 -273
- package/skills/jstest/references/config.md +148 -148
- package/skills/jstest/references/coverage-analyze.md +247 -247
- package/skills/jstest/references/env-ensure.md +210 -210
- package/skills/jstest/references/execute.md +168 -168
- package/skills/jstest/references/sample.md +166 -166
- package/skills/jstest/references/scoring-rules.md +75 -75
- package/skills/jstest/references/src/jstest-sample/Calculator.js +80 -80
- package/skills/jstest/references/src/jstest-sample/ConfigManager.js +72 -72
- package/skills/jstest/references/src/jstest-sample/FileProcessor.js +57 -57
- package/skills/jstest/references/src/jstest-sample/OrderService.js +98 -98
- package/skills/jstest/references/src/jstest-sample/TokenGenerator.js +60 -60
- package/skills/jstest/references/src/jstest-sample/UserService.js +56 -56
- package/skills/jstest/references/src/jstest-sample/index.js +6 -6
- package/skills/jstest/references/suitability-check.md +232 -232
- package/skills/jstest/references/test-standards.md +288 -288
- package/skills/lint/SKILL.md +440 -440
- package/skills/lint/references/ai-fix.md +137 -137
- package/skills/lint/references/config-setup.md +102 -102
- package/skills/lint/references/config.md +65 -65
- package/skills/lint/references/detect-language.js +65 -65
- package/skills/lint/references/env-ensure.md +88 -88
- package/skills/lint/references/language-detect.md +75 -75
- package/skills/lint/references/languages/js.md +110 -110
- package/skills/lint/references/languages/py.md +89 -89
- package/skills/lint/references/rules-analyze.md +125 -125
- package/skills/lint/references/suitability-check.md +81 -81
- package/skills/lint/references/tool-fix.md +90 -90
- package/skills/new-skill/SKILL.md +227 -227
- package/skills/new-skill/references/template.md +53 -53
- package/skills/new-skill/references/workflow-patterns.md +104 -104
- package/skills/pytest/SKILL.md +555 -555
- package/skills/pytest/references/case-create.md +324 -324
- package/skills/pytest/references/case-fix.md +271 -271
- package/skills/pytest/references/config.md +145 -145
- package/skills/pytest/references/coverage-analyze.md +223 -223
- package/skills/pytest/references/env-ensure.md +195 -195
- package/skills/pytest/references/execute.md +152 -152
- package/skills/pytest/references/sample.md +159 -159
- package/skills/pytest/references/scoring-rules.md +57 -57
- package/skills/pytest/references/src/pytest-sample/Calculator.py +67 -67
- package/skills/pytest/references/src/pytest-sample/ConfigManager.py +68 -68
- package/skills/pytest/references/src/pytest-sample/FileProcessor.py +53 -53
- package/skills/pytest/references/src/pytest-sample/OrderService.py +82 -82
- package/skills/pytest/references/src/pytest-sample/TokenGenerator.py +50 -50
- package/skills/pytest/references/src/pytest-sample/UserService.py +45 -45
- package/skills/pytest/references/suitability-check.md +220 -220
- package/skills/pytest/references/test-standards.md +244 -244
- package/skills/query/SKILL.md +71 -71
- package/skills/read-docs/SKILL.md +134 -134
- package/skills/read-docs/references/opencode/agents/cases.md +206 -206
- package/skills/read-docs/references/opencode/agents/design-pattern.md +47 -47
- package/skills/read-docs/references/opencode/agents/detail.md +191 -191
- package/skills/read-docs/references/opencode/agents/examples.md +100 -100
- package/skills/read-docs/references/opencode/agents/index.md +309 -309
- package/skills/read-docs/references/opencode/agents/parallel-dispatch.md +149 -149
- package/skills/read-docs/references/opencode/agents/subagent-internals.md +217 -217
- package/skills/read-docs/references/opencode/agents/workflow.md +161 -161
- package/skills/read-docs/references/opencode/cli/commands/acp.md +31 -31
- package/skills/read-docs/references/opencode/cli/commands/agent.md +16 -16
- package/skills/read-docs/references/opencode/cli/commands/attach.md +20 -20
- package/skills/read-docs/references/opencode/cli/commands/mcp.md +37 -37
- package/skills/read-docs/references/opencode/cli/commands/others.md +48 -48
- package/skills/read-docs/references/opencode/cli/commands/plugin.md +12 -12
- package/skills/read-docs/references/opencode/cli/commands/provider.md +43 -43
- package/skills/read-docs/references/opencode/cli/commands/run.md +81 -81
- package/skills/read-docs/references/opencode/cli/commands/serve.md +84 -84
- package/skills/read-docs/references/opencode/cli/commands/session.md +37 -37
- package/skills/read-docs/references/opencode/cli/commands/web.md +14 -14
- package/skills/read-docs/references/opencode/cli/env.md +38 -38
- package/skills/read-docs/references/opencode/cli/index.md +18 -18
- package/skills/read-docs/references/opencode/cli/tui.md +35 -35
- package/skills/read-docs/references/opencode/commands/examples.md +42 -42
- package/skills/read-docs/references/opencode/commands/index.md +185 -185
- package/skills/read-docs/references/opencode/config/provider.md +151 -151
- package/skills/read-docs/references/opencode/formatter/index.md +70 -70
- package/skills/read-docs/references/opencode/guide/config.md +419 -419
- package/skills/read-docs/references/opencode/guide/formatters.md +70 -70
- package/skills/read-docs/references/opencode/guide/index.md +37 -37
- package/skills/read-docs/references/opencode/guide/providers.md +31 -31
- package/skills/read-docs/references/opencode/guide/rules.md +63 -63
- package/skills/read-docs/references/opencode/plugins/examples.md +75 -75
- package/skills/read-docs/references/opencode/plugins/index.md +188 -188
- package/skills/read-docs/references/opencode/reference/index.md +118 -118
- package/skills/read-docs/references/opencode/rule/index.md +77 -77
- package/skills/read-docs/references/opencode/skills/detail.md +113 -113
- package/skills/read-docs/references/opencode/skills/examples.md +141 -141
- package/skills/read-docs/references/opencode/skills/index.md +126 -126
- package/skills/read-docs/references/opencode/skills/workflow.md +146 -146
- package/skills/read-docs/references/opencode/tests/agent.md +9 -9
- package/skills/read-docs/references/opencode/tests/config.md +59 -59
- package/skills/read-docs/references/opencode/tests/file.md +11 -11
- package/skills/read-docs/references/opencode/tests/serve.md +17 -17
- package/skills/read-docs/references/opencode/tests/session.md +30 -30
- package/skills/read-docs/references/opencode/tests/web.md +16 -16
- package/skills/read-docs/references/opencode/tools/arguments.md +305 -305
- package/skills/read-docs/references/opencode/tools/context.md +17 -17
- package/skills/read-docs/references/opencode/tools/custom.md +110 -110
- package/skills/read-docs/references/opencode/tools/detail.md +104 -104
- package/skills/read-docs/references/opencode/tools/examples.md +71 -71
- package/skills/read-docs/references/opencode/tools/index.md +56 -56
- package/skills/read-docs/references/opencode/tools/lsp.md +25 -25
- package/skills/read-docs/references/opencode/tools/mcp.md +132 -132
- package/skills/read-docs/references/opencode/train/README.md +134 -134
- package/skills/read-docs/references/opencode/train/agent-basic.md +771 -771
- package/skills/read-docs/references/opencode/train/command-basic.md +667 -667
- package/skills/read-docs/references/opencode/train/config-basic.md +508 -508
- package/skills/read-docs/references/opencode/train/index.md +163 -163
- package/skills/read-docs/references/opencode/train/practice.md +872 -872
- package/skills/read-docs/references/opencode/train/skill-basic.md +607 -607
- package/skills/read-docs/references/opencode/tui/commands/config.md +31 -31
- package/skills/read-docs/references/opencode/tui/commands/editor.md +46 -46
- package/skills/read-docs/references/opencode/tui/commands/index.md +124 -124
- package/skills/read-docs/references/opencode/tui/commands/init.md +4 -4
- package/skills/read-docs/references/opencode/tui/index.md +26 -26
- package/skills/read-docs/references/superpowers/bootstrap.md +107 -107
- package/skills/read-docs/references/superpowers/comparison.md +77 -77
- package/skills/read-docs/references/superpowers/context.md +71 -71
- package/skills/read-docs/references/superpowers/index.md +58 -58
- package/skills/read-docs/references/superpowers/parallel.md +49 -49
- package/skills/read-docs/references/superpowers/sdd.md +183 -183
- package/skills/read-docs/references/superpowers/skills.md +68 -68
- package/skills/read-docs/references/superpowers/workflow.md +83 -83
- package/skills/revise/SKILL.md +121 -121
- package/skills/revise/references/article.md +36 -36
- package/skills/revise/references/article.schema.json5 +40 -40
- package/skills/revise/references/gallery.md +34 -34
- package/skills/revise/references/gallery.schema.json5 +40 -40
- package/skills/revise/references/question.md +32 -32
- package/skills/revise/references/question.schema.json5 +31 -31
- package/skills/revise/references/status.md +31 -31
- package/skills/revise/references/status.schema.json5 +27 -27
- package/skills/revise/references/validate-schema.js +39 -39
- package/src/config.js +29 -29
- package/src/config.json5 +19 -19
package/commands/git-sync.md
CHANGED
|
@@ -1,218 +1,218 @@
|
|
|
1
|
-
---
|
|
2
|
-
description: Git commit all changes and push to remote branch with auto-detected change type
|
|
3
|
-
---
|
|
4
|
-
|
|
5
|
-
You are a Git commit assistant. Execute the following steps strictly:
|
|
6
|
-
|
|
7
|
-
## Step 0: Pre-flight Checks
|
|
8
|
-
|
|
9
|
-
1. **Check if in a git repository**:
|
|
10
|
-
```bash
|
|
11
|
-
git rev-parse --is-inside-work-tree
|
|
12
|
-
```
|
|
13
|
-
- If failed, output "Not a git repository" and stop
|
|
14
|
-
|
|
15
|
-
2. **Check for unresolved conflicts**:
|
|
16
|
-
```bash
|
|
17
|
-
git status | grep -E "(Unmerged paths|rebase|merge)"
|
|
18
|
-
```
|
|
19
|
-
- If conflicts exist, output "Please resolve conflicts first" and stop
|
|
20
|
-
|
|
21
|
-
3. **Check if there are changes**:
|
|
22
|
-
```bash
|
|
23
|
-
git status --porcelain
|
|
24
|
-
```
|
|
25
|
-
- If empty, output "No changes to commit" and stop
|
|
26
|
-
|
|
27
|
-
4. **Generate timestamp** (used for branch naming):
|
|
28
|
-
```bash
|
|
29
|
-
TIMESTAMP=$(date +"%Y%m%d%H%M%S")
|
|
30
|
-
```
|
|
31
|
-
- Format includes seconds to avoid collisions
|
|
32
|
-
|
|
33
|
-
## Step 1: Analyze Changes and Detect Type
|
|
34
|
-
|
|
35
|
-
1. **Read changed files**:
|
|
36
|
-
```bash
|
|
37
|
-
git status
|
|
38
|
-
git diff --stat
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
2. **Detect change type (kind)** based on content:
|
|
42
|
-
- `feat`: New features, new files added
|
|
43
|
-
- `fix`: Bug fixes, issue fixes
|
|
44
|
-
- `docs`: Documentation changes (README, comments, doc files)
|
|
45
|
-
- `style`: Code formatting (no functionality change)
|
|
46
|
-
- `refactor`: Code refactoring (neither new feature nor fix)
|
|
47
|
-
- `perf`: Performance optimization
|
|
48
|
-
- `test`: Test-related changes
|
|
49
|
-
- `chore`: Build process, auxiliary tools, dependency updates
|
|
50
|
-
- `ci`: CI configuration changes
|
|
51
|
-
- `revert`: Revert previous commit
|
|
52
|
-
|
|
53
|
-
Priority when multiple types: feat > fix > perf > refactor > test > docs > style > chore > ci
|
|
54
|
-
|
|
55
|
-
3. **Generate commit description**:
|
|
56
|
-
- Extract brief description from changes (in English)
|
|
57
|
-
- Format: `<kind>: <brief description>`
|
|
58
|
-
|
|
59
|
-
## Step 2: Determine Remote Branch Name
|
|
60
|
-
|
|
61
|
-
Based on parameter `$1`, determine the target remote branch name:
|
|
62
|
-
|
|
63
|
-
### Scenario A: No parameter ($1 is empty)
|
|
64
|
-
- Use current branch name as remote branch name:
|
|
65
|
-
```bash
|
|
66
|
-
REMOTE_BRANCH=$(git branch --show-current)
|
|
67
|
-
```
|
|
68
|
-
|
|
69
|
-
### Scenario B: Parameter is "new"
|
|
70
|
-
- Generate new remote branch name with personal identifier: `ss-<kind>-<timestamp>`
|
|
71
|
-
- Example: `ss-feat-20260702153045`
|
|
72
|
-
```bash
|
|
73
|
-
REMOTE_BRANCH="ss-<kind>-<timestamp>"
|
|
74
|
-
```
|
|
75
|
-
- `ss-` prefix: personal identifier
|
|
76
|
-
- Timestamp includes seconds to avoid collisions
|
|
77
|
-
|
|
78
|
-
### Scenario C: Parameter is a branch name (user-specified)
|
|
79
|
-
- Use the specified name as remote branch name:
|
|
80
|
-
```bash
|
|
81
|
-
REMOTE_BRANCH="$1"
|
|
82
|
-
```
|
|
83
|
-
|
|
84
|
-
## Step 3: Commit Changes (on current local branch)
|
|
85
|
-
|
|
86
|
-
**Important**: Stay on current local branch, no switching needed
|
|
87
|
-
|
|
88
|
-
1. **Add all changes**:
|
|
89
|
-
```bash
|
|
90
|
-
git add -A
|
|
91
|
-
```
|
|
92
|
-
|
|
93
|
-
2. **Execute commit**:
|
|
94
|
-
```bash
|
|
95
|
-
git commit -m "<kind>: <description>"
|
|
96
|
-
```
|
|
97
|
-
|
|
98
|
-
3. **Commit Failure Handling**:
|
|
99
|
-
- **If pre-commit hook fails**: Output hook error and stop
|
|
100
|
-
- **If no user name/email**: Output "Please configure git user.name and user.email" and stop
|
|
101
|
-
- **If nothing to commit**: Output "Nothing to commit" and stop
|
|
102
|
-
|
|
103
|
-
## Step 4: Push to Remote Branch
|
|
104
|
-
|
|
105
|
-
**Important**: Use HEAD syntax to push to target remote branch without switching local branch
|
|
106
|
-
|
|
107
|
-
1. **Push using HEAD syntax**:
|
|
108
|
-
```bash
|
|
109
|
-
git push origin HEAD:$REMOTE_BRANCH
|
|
110
|
-
```
|
|
111
|
-
- This pushes current commit to the specified remote branch
|
|
112
|
-
- Local branch name can be different from remote branch name
|
|
113
|
-
- Remote branch is mainly for creating Merge Request (MR)
|
|
114
|
-
|
|
115
|
-
2. **Push Conflict Handling**:
|
|
116
|
-
- If push fails due to remote conflicts, push to new remote branch:
|
|
117
|
-
```bash
|
|
118
|
-
git push origin HEAD:$REMOTE_BRANCH-merge-$TIMESTAMP
|
|
119
|
-
```
|
|
120
|
-
- Output: "Remote branch has conflicts, pushed to $REMOTE_BRANCH-merge-$TIMESTAMP"
|
|
121
|
-
|
|
122
|
-
3. **Other Push Failures**:
|
|
123
|
-
- **Network error**: Retry once, then output "Network error, please try again"
|
|
124
|
-
- **Permission denied**: Output "Permission denied, check your credentials"
|
|
125
|
-
- **Remote repository not found**: Output "Remote repository not found"
|
|
126
|
-
- **Pre-push hook fails**: Output hook error and stop
|
|
127
|
-
|
|
128
|
-
## Step 5: Final Status Check
|
|
129
|
-
|
|
130
|
-
After successful push, show summary:
|
|
131
|
-
```bash
|
|
132
|
-
git log -1 --oneline
|
|
133
|
-
git status
|
|
134
|
-
```
|
|
135
|
-
|
|
136
|
-
Output:
|
|
137
|
-
```
|
|
138
|
-
✓ Committed and pushed to remote branch '$REMOTE_BRANCH'
|
|
139
|
-
- Local branch: <current-local-branch>
|
|
140
|
-
- Remote branch: $REMOTE_BRANCH (for MR)
|
|
141
|
-
- Commit: <commit-message>
|
|
142
|
-
```
|
|
143
|
-
|
|
144
|
-
## Important Notes
|
|
145
|
-
|
|
146
|
-
- Never modify git config
|
|
147
|
-
- Never use --force push
|
|
148
|
-
- Never use --no-verify to skip hooks
|
|
149
|
-
- Use English for commit messages
|
|
150
|
-
- Keep timestamp consistent throughout the process
|
|
151
|
-
- Stop execution and inform user on any error
|
|
152
|
-
- **No local branch switching** - stay on current branch
|
|
153
|
-
- Remote branch name is for MR creation, not required to match local branch
|
|
154
|
-
|
|
155
|
-
## Error Handling Summary
|
|
156
|
-
|
|
157
|
-
| Error Type | Detection | Handling |
|
|
158
|
-
|------------|-----------|----------|
|
|
159
|
-
| Not a git repo | `git rev-parse` | Stop with message |
|
|
160
|
-
| Unresolved conflicts | `git status` | Stop with message |
|
|
161
|
-
| No changes | `git status --porcelain` | Stop with message |
|
|
162
|
-
| Commit hook failure | `git commit` fails | Stop with hook error |
|
|
163
|
-
| Push conflict | `git push` fails | Push to new remote branch |
|
|
164
|
-
| Network error | `git push` timeout | Retry once, then stop |
|
|
165
|
-
| Permission error | `git push` denied | Stop with message |
|
|
166
|
-
|
|
167
|
-
## Execution Examples
|
|
168
|
-
|
|
169
|
-
**Example 1: No parameter, push to current remote branch**
|
|
170
|
-
```
|
|
171
|
-
User: /git-sync
|
|
172
|
-
→ Check: git repository OK
|
|
173
|
-
→ Check: no conflicts
|
|
174
|
-
→ Analyze: added api.ts
|
|
175
|
-
→ Type: feat
|
|
176
|
-
→ Local branch: dev (stay here)
|
|
177
|
-
→ Remote branch: dev
|
|
178
|
-
→ Commit: feat: add API interface wrapper
|
|
179
|
-
→ Push: git push origin HEAD:dev
|
|
180
|
-
→ Success: pushed to remote 'dev' (for MR)
|
|
181
|
-
```
|
|
182
|
-
|
|
183
|
-
**Example 2: Parameter "new", push to new remote branch**
|
|
184
|
-
```
|
|
185
|
-
User: /git-sync new
|
|
186
|
-
→ Check: git repository OK
|
|
187
|
-
→ Analyze: fixed login bug
|
|
188
|
-
→ Type: fix
|
|
189
|
-
→ Timestamp: 20260702153045 (includes seconds)
|
|
190
|
-
→ Local branch: dev (stay here)
|
|
191
|
-
→ Remote branch: ss-fix-20260702153045 (new)
|
|
192
|
-
→ Commit: fix: fix login validation logic error
|
|
193
|
-
→ Push: git push origin HEAD:ss-fix-20260702153045
|
|
194
|
-
→ Success: pushed to remote 'ss-fix-20260702153045' (for MR)
|
|
195
|
-
```
|
|
196
|
-
|
|
197
|
-
**Example 3: Parameter is branch name, push to specified remote**
|
|
198
|
-
```
|
|
199
|
-
User: /git-sync feature-user-auth
|
|
200
|
-
→ Analyze: updated auth module
|
|
201
|
-
→ Type: refactor
|
|
202
|
-
→ Local branch: dev (stay here)
|
|
203
|
-
→ Remote branch: feature-user-auth (user specified)
|
|
204
|
-
→ Commit: refactor: refactor user authentication module
|
|
205
|
-
→ Push: git push origin HEAD:feature-user-auth
|
|
206
|
-
→ Success: pushed to remote 'feature-user-auth' (for MR)
|
|
207
|
-
```
|
|
208
|
-
|
|
209
|
-
**Example 4: Push conflict**
|
|
210
|
-
```
|
|
211
|
-
User: /git-sync feature-user-auth
|
|
212
|
-
→ Local branch: dev
|
|
213
|
-
→ Remote branch: feature-user-auth
|
|
214
|
-
→ Commit: feat: new feature
|
|
215
|
-
→ Push: CONFLICT (remote has diverged)
|
|
216
|
-
→ Action: git push origin HEAD:feature-user-auth-merge-20260702153245
|
|
217
|
-
→ Success: pushed to remote 'feature-user-auth-merge-20260702153245' (for MR)
|
|
1
|
+
---
|
|
2
|
+
description: Git commit all changes and push to remote branch with auto-detected change type
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
You are a Git commit assistant. Execute the following steps strictly:
|
|
6
|
+
|
|
7
|
+
## Step 0: Pre-flight Checks
|
|
8
|
+
|
|
9
|
+
1. **Check if in a git repository**:
|
|
10
|
+
```bash
|
|
11
|
+
git rev-parse --is-inside-work-tree
|
|
12
|
+
```
|
|
13
|
+
- If failed, output "Not a git repository" and stop
|
|
14
|
+
|
|
15
|
+
2. **Check for unresolved conflicts**:
|
|
16
|
+
```bash
|
|
17
|
+
git status | grep -E "(Unmerged paths|rebase|merge)"
|
|
18
|
+
```
|
|
19
|
+
- If conflicts exist, output "Please resolve conflicts first" and stop
|
|
20
|
+
|
|
21
|
+
3. **Check if there are changes**:
|
|
22
|
+
```bash
|
|
23
|
+
git status --porcelain
|
|
24
|
+
```
|
|
25
|
+
- If empty, output "No changes to commit" and stop
|
|
26
|
+
|
|
27
|
+
4. **Generate timestamp** (used for branch naming):
|
|
28
|
+
```bash
|
|
29
|
+
TIMESTAMP=$(date +"%Y%m%d%H%M%S")
|
|
30
|
+
```
|
|
31
|
+
- Format includes seconds to avoid collisions
|
|
32
|
+
|
|
33
|
+
## Step 1: Analyze Changes and Detect Type
|
|
34
|
+
|
|
35
|
+
1. **Read changed files**:
|
|
36
|
+
```bash
|
|
37
|
+
git status
|
|
38
|
+
git diff --stat
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
2. **Detect change type (kind)** based on content:
|
|
42
|
+
- `feat`: New features, new files added
|
|
43
|
+
- `fix`: Bug fixes, issue fixes
|
|
44
|
+
- `docs`: Documentation changes (README, comments, doc files)
|
|
45
|
+
- `style`: Code formatting (no functionality change)
|
|
46
|
+
- `refactor`: Code refactoring (neither new feature nor fix)
|
|
47
|
+
- `perf`: Performance optimization
|
|
48
|
+
- `test`: Test-related changes
|
|
49
|
+
- `chore`: Build process, auxiliary tools, dependency updates
|
|
50
|
+
- `ci`: CI configuration changes
|
|
51
|
+
- `revert`: Revert previous commit
|
|
52
|
+
|
|
53
|
+
Priority when multiple types: feat > fix > perf > refactor > test > docs > style > chore > ci
|
|
54
|
+
|
|
55
|
+
3. **Generate commit description**:
|
|
56
|
+
- Extract brief description from changes (in English)
|
|
57
|
+
- Format: `<kind>: <brief description>`
|
|
58
|
+
|
|
59
|
+
## Step 2: Determine Remote Branch Name
|
|
60
|
+
|
|
61
|
+
Based on parameter `$1`, determine the target remote branch name:
|
|
62
|
+
|
|
63
|
+
### Scenario A: No parameter ($1 is empty)
|
|
64
|
+
- Use current branch name as remote branch name:
|
|
65
|
+
```bash
|
|
66
|
+
REMOTE_BRANCH=$(git branch --show-current)
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### Scenario B: Parameter is "new"
|
|
70
|
+
- Generate new remote branch name with personal identifier: `ss-<kind>-<timestamp>`
|
|
71
|
+
- Example: `ss-feat-20260702153045`
|
|
72
|
+
```bash
|
|
73
|
+
REMOTE_BRANCH="ss-<kind>-<timestamp>"
|
|
74
|
+
```
|
|
75
|
+
- `ss-` prefix: personal identifier
|
|
76
|
+
- Timestamp includes seconds to avoid collisions
|
|
77
|
+
|
|
78
|
+
### Scenario C: Parameter is a branch name (user-specified)
|
|
79
|
+
- Use the specified name as remote branch name:
|
|
80
|
+
```bash
|
|
81
|
+
REMOTE_BRANCH="$1"
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## Step 3: Commit Changes (on current local branch)
|
|
85
|
+
|
|
86
|
+
**Important**: Stay on current local branch, no switching needed
|
|
87
|
+
|
|
88
|
+
1. **Add all changes**:
|
|
89
|
+
```bash
|
|
90
|
+
git add -A
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
2. **Execute commit**:
|
|
94
|
+
```bash
|
|
95
|
+
git commit -m "<kind>: <description>"
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
3. **Commit Failure Handling**:
|
|
99
|
+
- **If pre-commit hook fails**: Output hook error and stop
|
|
100
|
+
- **If no user name/email**: Output "Please configure git user.name and user.email" and stop
|
|
101
|
+
- **If nothing to commit**: Output "Nothing to commit" and stop
|
|
102
|
+
|
|
103
|
+
## Step 4: Push to Remote Branch
|
|
104
|
+
|
|
105
|
+
**Important**: Use HEAD syntax to push to target remote branch without switching local branch
|
|
106
|
+
|
|
107
|
+
1. **Push using HEAD syntax**:
|
|
108
|
+
```bash
|
|
109
|
+
git push origin HEAD:$REMOTE_BRANCH
|
|
110
|
+
```
|
|
111
|
+
- This pushes current commit to the specified remote branch
|
|
112
|
+
- Local branch name can be different from remote branch name
|
|
113
|
+
- Remote branch is mainly for creating Merge Request (MR)
|
|
114
|
+
|
|
115
|
+
2. **Push Conflict Handling**:
|
|
116
|
+
- If push fails due to remote conflicts, push to new remote branch:
|
|
117
|
+
```bash
|
|
118
|
+
git push origin HEAD:$REMOTE_BRANCH-merge-$TIMESTAMP
|
|
119
|
+
```
|
|
120
|
+
- Output: "Remote branch has conflicts, pushed to $REMOTE_BRANCH-merge-$TIMESTAMP"
|
|
121
|
+
|
|
122
|
+
3. **Other Push Failures**:
|
|
123
|
+
- **Network error**: Retry once, then output "Network error, please try again"
|
|
124
|
+
- **Permission denied**: Output "Permission denied, check your credentials"
|
|
125
|
+
- **Remote repository not found**: Output "Remote repository not found"
|
|
126
|
+
- **Pre-push hook fails**: Output hook error and stop
|
|
127
|
+
|
|
128
|
+
## Step 5: Final Status Check
|
|
129
|
+
|
|
130
|
+
After successful push, show summary:
|
|
131
|
+
```bash
|
|
132
|
+
git log -1 --oneline
|
|
133
|
+
git status
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
Output:
|
|
137
|
+
```
|
|
138
|
+
✓ Committed and pushed to remote branch '$REMOTE_BRANCH'
|
|
139
|
+
- Local branch: <current-local-branch>
|
|
140
|
+
- Remote branch: $REMOTE_BRANCH (for MR)
|
|
141
|
+
- Commit: <commit-message>
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
## Important Notes
|
|
145
|
+
|
|
146
|
+
- Never modify git config
|
|
147
|
+
- Never use --force push
|
|
148
|
+
- Never use --no-verify to skip hooks
|
|
149
|
+
- Use English for commit messages
|
|
150
|
+
- Keep timestamp consistent throughout the process
|
|
151
|
+
- Stop execution and inform user on any error
|
|
152
|
+
- **No local branch switching** - stay on current branch
|
|
153
|
+
- Remote branch name is for MR creation, not required to match local branch
|
|
154
|
+
|
|
155
|
+
## Error Handling Summary
|
|
156
|
+
|
|
157
|
+
| Error Type | Detection | Handling |
|
|
158
|
+
|------------|-----------|----------|
|
|
159
|
+
| Not a git repo | `git rev-parse` | Stop with message |
|
|
160
|
+
| Unresolved conflicts | `git status` | Stop with message |
|
|
161
|
+
| No changes | `git status --porcelain` | Stop with message |
|
|
162
|
+
| Commit hook failure | `git commit` fails | Stop with hook error |
|
|
163
|
+
| Push conflict | `git push` fails | Push to new remote branch |
|
|
164
|
+
| Network error | `git push` timeout | Retry once, then stop |
|
|
165
|
+
| Permission error | `git push` denied | Stop with message |
|
|
166
|
+
|
|
167
|
+
## Execution Examples
|
|
168
|
+
|
|
169
|
+
**Example 1: No parameter, push to current remote branch**
|
|
170
|
+
```
|
|
171
|
+
User: /git-sync
|
|
172
|
+
→ Check: git repository OK
|
|
173
|
+
→ Check: no conflicts
|
|
174
|
+
→ Analyze: added api.ts
|
|
175
|
+
→ Type: feat
|
|
176
|
+
→ Local branch: dev (stay here)
|
|
177
|
+
→ Remote branch: dev
|
|
178
|
+
→ Commit: feat: add API interface wrapper
|
|
179
|
+
→ Push: git push origin HEAD:dev
|
|
180
|
+
→ Success: pushed to remote 'dev' (for MR)
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
**Example 2: Parameter "new", push to new remote branch**
|
|
184
|
+
```
|
|
185
|
+
User: /git-sync new
|
|
186
|
+
→ Check: git repository OK
|
|
187
|
+
→ Analyze: fixed login bug
|
|
188
|
+
→ Type: fix
|
|
189
|
+
→ Timestamp: 20260702153045 (includes seconds)
|
|
190
|
+
→ Local branch: dev (stay here)
|
|
191
|
+
→ Remote branch: ss-fix-20260702153045 (new)
|
|
192
|
+
→ Commit: fix: fix login validation logic error
|
|
193
|
+
→ Push: git push origin HEAD:ss-fix-20260702153045
|
|
194
|
+
→ Success: pushed to remote 'ss-fix-20260702153045' (for MR)
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
**Example 3: Parameter is branch name, push to specified remote**
|
|
198
|
+
```
|
|
199
|
+
User: /git-sync feature-user-auth
|
|
200
|
+
→ Analyze: updated auth module
|
|
201
|
+
→ Type: refactor
|
|
202
|
+
→ Local branch: dev (stay here)
|
|
203
|
+
→ Remote branch: feature-user-auth (user specified)
|
|
204
|
+
→ Commit: refactor: refactor user authentication module
|
|
205
|
+
→ Push: git push origin HEAD:feature-user-auth
|
|
206
|
+
→ Success: pushed to remote 'feature-user-auth' (for MR)
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
**Example 4: Push conflict**
|
|
210
|
+
```
|
|
211
|
+
User: /git-sync feature-user-auth
|
|
212
|
+
→ Local branch: dev
|
|
213
|
+
→ Remote branch: feature-user-auth
|
|
214
|
+
→ Commit: feat: new feature
|
|
215
|
+
→ Push: CONFLICT (remote has diverged)
|
|
216
|
+
→ Action: git push origin HEAD:feature-user-auth-merge-20260702153245
|
|
217
|
+
→ Success: pushed to remote 'feature-user-auth-merge-20260702153245' (for MR)
|
|
218
218
|
```
|