@ia-ccun/code-agent-cli 0.0.3 → 0.0.4-8.beta.1
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/README.md +92 -11
- package/bin/cli.js +212 -59
- package/config/agent/APPEND_SYSTEM.md +46 -5
- package/config/agent/bin/fd +0 -0
- package/config/agent/bin/rg +0 -0
- package/config/agent/dangerous-patterns.json +106 -0
- package/config/agent/extensions/aicode-tips.ts +191 -0
- package/config/agent/extensions/bash-check.ts +227 -0
- package/config/agent/extensions/context-monitor.ts +275 -0
- package/config/agent/extensions/context.ts +1 -0
- package/config/agent/extensions/custom-footer.ts +33 -2
- package/config/agent/extensions/custom.ts +24 -91
- package/config/agent/extensions/error-monitor.ts +142 -0
- package/config/agent/extensions/msg-debug.ts +185 -0
- package/config/agent/extensions/review.ts +4 -0
- package/config/agent/extensions/working-msg.ts +39 -20
- package/config/agent/mcp.json +4 -0
- package/config/agent/models.json +16 -43
- package/config/agent/prompts/code-simplifier.md +51 -0
- package/config/agent/prompts/feat.md +2 -2
- package/config/agent/prompts/git-commit.md +9 -15
- package/config/agent/prompts/init-project.md +2 -1
- package/config/agent/prompts/workflow.md +3 -2
- package/config/agent/settings.json +17 -5
- package/config/agent/skills/brainstorming/SKILL.md +167 -0
- package/config/agent/skills/brainstorming/scripts/frame-template.html +214 -0
- package/config/agent/skills/brainstorming/scripts/helper.js +88 -0
- package/config/agent/skills/brainstorming/scripts/server.cjs +338 -0
- package/config/agent/skills/brainstorming/scripts/start-server.sh +153 -0
- package/config/agent/skills/brainstorming/scripts/stop-server.sh +55 -0
- package/config/agent/skills/brainstorming/spec-document-reviewer-prompt.md +49 -0
- package/config/agent/skills/brainstorming/visual-companion.md +286 -0
- package/config/agent/skills/code-review/SKILL.md +4 -2
- package/config/agent/skills/commit/SKILL.md +10 -5
- package/config/agent/skills/csv-data-summarizer/SKILL.md +2 -1
- package/config/agent/skills/design-md/README.md +34 -0
- package/config/agent/skills/design-md/SKILL.md +172 -0
- package/config/agent/skills/design-md/examples/DESIGN.md +154 -0
- package/config/agent/skills/dispatching-parallel-agents/SKILL.md +185 -0
- package/config/agent/skills/executing-plans/SKILL.md +73 -0
- package/config/agent/skills/find-skills/SKILL.md +5 -1
- package/config/agent/skills/finishing-a-development-branch/SKILL.md +204 -0
- package/config/agent/skills/fireworks-tech-graph/LICENSE +21 -0
- package/config/agent/skills/fireworks-tech-graph/README.md +528 -0
- package/config/agent/skills/fireworks-tech-graph/README.zh.md +499 -0
- package/config/agent/skills/fireworks-tech-graph/SKILL.md +537 -0
- package/config/agent/skills/fireworks-tech-graph/agentloop-core.svg +101 -0
- package/config/agent/skills/fireworks-tech-graph/agents/openai.yaml +4 -0
- package/config/agent/skills/fireworks-tech-graph/assets/samples/sample-style1-flat.png +0 -0
- package/config/agent/skills/fireworks-tech-graph/assets/samples/sample-style2-dark.png +0 -0
- package/config/agent/skills/fireworks-tech-graph/assets/samples/sample-style3-blueprint.png +0 -0
- package/config/agent/skills/fireworks-tech-graph/assets/samples/sample-style4-notion.png +0 -0
- package/config/agent/skills/fireworks-tech-graph/assets/samples/sample-style5-glass.png +0 -0
- package/config/agent/skills/fireworks-tech-graph/assets/samples/sample-style6-claude.png +0 -0
- package/config/agent/skills/fireworks-tech-graph/assets/samples/sample-style7-openai.png +0 -0
- package/config/agent/skills/fireworks-tech-graph/fixtures/agent-memory-types-style4.json +181 -0
- package/config/agent/skills/fireworks-tech-graph/fixtures/api-flow-style7.json +40 -0
- package/config/agent/skills/fireworks-tech-graph/fixtures/mem0-style1.json +297 -0
- package/config/agent/skills/fireworks-tech-graph/fixtures/microservices-style3.json +64 -0
- package/config/agent/skills/fireworks-tech-graph/fixtures/multi-agent-style5.json +45 -0
- package/config/agent/skills/fireworks-tech-graph/fixtures/system-architecture-style6.json +48 -0
- package/config/agent/skills/fireworks-tech-graph/fixtures/tool-call-style2.json +182 -0
- package/config/agent/skills/fireworks-tech-graph/package.json +42 -0
- package/config/agent/skills/fireworks-tech-graph/references/icons.md +406 -0
- package/config/agent/skills/fireworks-tech-graph/references/style-1-flat-icon.md +108 -0
- package/config/agent/skills/fireworks-tech-graph/references/style-2-dark-terminal.md +107 -0
- package/config/agent/skills/fireworks-tech-graph/references/style-3-blueprint.md +113 -0
- package/config/agent/skills/fireworks-tech-graph/references/style-4-notion-clean.md +94 -0
- package/config/agent/skills/fireworks-tech-graph/references/style-5-glassmorphism.md +125 -0
- package/config/agent/skills/fireworks-tech-graph/references/style-6-claude-official.md +209 -0
- package/config/agent/skills/fireworks-tech-graph/references/style-7-openai.md +215 -0
- package/config/agent/skills/fireworks-tech-graph/references/style-diagram-matrix.md +135 -0
- package/config/agent/skills/fireworks-tech-graph/references/svg-layout-best-practices.md +100 -0
- package/config/agent/skills/fireworks-tech-graph/scripts/README.md +244 -0
- package/config/agent/skills/fireworks-tech-graph/scripts/generate-diagram.sh +157 -0
- package/config/agent/skills/fireworks-tech-graph/scripts/generate-from-template.py +1556 -0
- package/config/agent/skills/fireworks-tech-graph/scripts/test-all-styles.sh +135 -0
- package/config/agent/skills/fireworks-tech-graph/scripts/validate-svg.sh +292 -0
- package/config/agent/skills/fireworks-tech-graph/templates/agent-architecture.svg +28 -0
- package/config/agent/skills/fireworks-tech-graph/templates/architecture.svg +23 -0
- package/config/agent/skills/fireworks-tech-graph/templates/comparison-matrix.svg +14 -0
- package/config/agent/skills/fireworks-tech-graph/templates/data-flow.svg +28 -0
- package/config/agent/skills/fireworks-tech-graph/templates/er-diagram.svg +21 -0
- package/config/agent/skills/fireworks-tech-graph/templates/flowchart.svg +21 -0
- package/config/agent/skills/fireworks-tech-graph/templates/sequence.svg +20 -0
- package/config/agent/skills/fireworks-tech-graph/templates/state-machine.svg +20 -0
- package/config/agent/skills/fireworks-tech-graph/templates/timeline.svg +19 -0
- package/config/agent/skills/fireworks-tech-graph/templates/use-case.svg +21 -0
- package/config/agent/skills/frontend-design/SKILL.md +4 -1
- package/config/agent/skills/hello/SKILL.md +5 -2
- package/config/agent/skills/impeccable/adapt/SKILL.md +204 -0
- package/config/agent/skills/impeccable/animate/SKILL.md +177 -0
- package/config/agent/skills/impeccable/arrange/SKILL.md +127 -0
- package/config/agent/skills/impeccable/audit/SKILL.md +128 -0
- package/config/agent/skills/impeccable/bolder/SKILL.md +119 -0
- package/config/agent/skills/impeccable/clarify/SKILL.md +185 -0
- package/config/agent/skills/impeccable/colorize/SKILL.md +145 -0
- package/config/agent/skills/impeccable/critique/SKILL.md +122 -0
- package/config/agent/skills/impeccable/delight/SKILL.md +306 -0
- package/config/agent/skills/impeccable/distill/SKILL.md +124 -0
- package/config/agent/skills/impeccable/extract/SKILL.md +94 -0
- package/config/agent/skills/impeccable/frontend-design/reference/color-and-contrast.md +132 -0
- package/config/agent/skills/impeccable/frontend-design/reference/interaction-design.md +123 -0
- package/config/agent/skills/impeccable/frontend-design/reference/motion-design.md +99 -0
- package/config/agent/skills/impeccable/frontend-design/reference/responsive-design.md +114 -0
- package/config/agent/skills/impeccable/frontend-design/reference/spatial-design.md +100 -0
- package/config/agent/skills/impeccable/frontend-design/reference/typography.md +133 -0
- package/config/agent/skills/impeccable/frontend-design/reference/ux-writing.md +107 -0
- package/config/agent/skills/impeccable/harden/SKILL.md +357 -0
- package/config/agent/skills/impeccable/normalize/SKILL.md +73 -0
- package/config/agent/skills/impeccable/onboard/SKILL.md +248 -0
- package/config/agent/skills/impeccable/optimize/SKILL.md +268 -0
- package/config/agent/skills/impeccable/overdrive/SKILL.md +144 -0
- package/config/agent/skills/impeccable/polish/SKILL.md +205 -0
- package/config/agent/skills/impeccable/quieter/SKILL.md +105 -0
- package/config/agent/skills/impeccable/teach-impeccable/SKILL.md +71 -0
- package/config/agent/skills/impeccable/typeset/SKILL.md +118 -0
- package/config/agent/skills/librarian/SKILL.md +5 -1
- package/config/agent/skills/markdown-to-html/SKILL.md +5 -2
- package/config/agent/skills/owasp-security/SKILL.md +539 -0
- package/config/agent/skills/pr/SKILL.md +5 -2
- package/config/agent/skills/receiving-code-review/SKILL.md +216 -0
- package/config/agent/skills/refactor/SKILL.md +5 -2
- package/config/agent/skills/requesting-code-review/SKILL.md +108 -0
- package/config/agent/skills/requesting-code-review/code-reviewer.md +146 -0
- package/config/agent/skills/session-learning/SKILL.md +185 -0
- package/config/agent/skills/skill-creator/SKILL.md +339 -213
- package/config/agent/skills/skill-creator/agents/analyzer.md +274 -0
- package/config/agent/skills/skill-creator/agents/comparator.md +202 -0
- package/config/agent/skills/skill-creator/agents/grader.md +223 -0
- package/config/agent/skills/skill-creator/assets/eval_review.html +146 -0
- package/config/agent/skills/skill-creator/eval-viewer/generate_review.py +471 -0
- package/config/agent/skills/skill-creator/eval-viewer/viewer.html +1325 -0
- package/config/agent/skills/skill-creator/references/schemas.md +430 -0
- package/config/agent/skills/skill-creator/scripts/__init__.py +0 -0
- package/config/agent/skills/skill-creator/scripts/aggregate_benchmark.py +401 -0
- package/config/agent/skills/skill-creator/scripts/generate_report.py +326 -0
- package/config/agent/skills/skill-creator/scripts/improve_description.py +248 -0
- package/config/agent/skills/skill-creator/scripts/package_skill.py +33 -7
- package/config/agent/skills/skill-creator/scripts/quick_validate.py +11 -3
- package/config/agent/skills/skill-creator/scripts/run_eval.py +310 -0
- package/config/agent/skills/skill-creator/scripts/run_loop.py +332 -0
- package/config/agent/skills/skill-creator/scripts/utils.py +47 -0
- package/config/agent/skills/subagent-driven-development/SKILL.md +280 -0
- package/config/agent/skills/subagent-driven-development/code-quality-reviewer-prompt.md +26 -0
- package/config/agent/skills/subagent-driven-development/implementer-prompt.md +113 -0
- package/config/agent/skills/subagent-driven-development/spec-reviewer-prompt.md +61 -0
- package/config/agent/skills/systematic-debugging/CREATION-LOG.md +119 -0
- package/config/agent/skills/systematic-debugging/SKILL.md +300 -0
- package/config/agent/skills/systematic-debugging/condition-based-waiting-example.ts +158 -0
- package/config/agent/skills/systematic-debugging/condition-based-waiting.md +115 -0
- package/config/agent/skills/systematic-debugging/defense-in-depth.md +122 -0
- package/config/agent/skills/systematic-debugging/find-polluter.sh +63 -0
- package/config/agent/skills/systematic-debugging/root-cause-tracing.md +169 -0
- package/config/agent/skills/systematic-debugging/test-academic.md +14 -0
- package/config/agent/skills/systematic-debugging/test-pressure-1.md +58 -0
- package/config/agent/skills/systematic-debugging/test-pressure-2.md +68 -0
- package/config/agent/skills/systematic-debugging/test-pressure-3.md +69 -0
- package/config/agent/skills/test-driven-development/SKILL.md +375 -0
- package/config/agent/skills/test-driven-development/testing-anti-patterns.md +299 -0
- package/config/agent/skills/ui-ux-pro-max/SKILL.md +4 -1
- package/config/agent/skills/unit-test/SKILL.md +4 -2
- package/config/agent/skills/using-git-worktrees/SKILL.md +222 -0
- package/config/agent/skills/using-superpowers/SKILL.md +118 -0
- package/config/agent/skills/using-superpowers/references/codex-tools.md +25 -0
- package/config/agent/skills/using-superpowers/references/gemini-tools.md +33 -0
- package/config/agent/skills/verification-before-completion/SKILL.md +142 -0
- package/config/agent/skills/writing-plans/SKILL.md +148 -0
- package/config/agent/skills/writing-plans/plan-document-reviewer-prompt.md +49 -0
- package/config/agent/skills/writing-skills/SKILL.md +669 -0
- package/config/agent/skills/writing-skills/anthropic-best-practices.md +1150 -0
- package/config/agent/skills/writing-skills/examples/CLAUDE_MD_TESTING.md +189 -0
- package/config/agent/skills/writing-skills/graphviz-conventions.dot +172 -0
- package/config/agent/skills/writing-skills/persuasion-principles.md +187 -0
- package/config/agent/skills/writing-skills/render-graphs.js +168 -0
- package/config/agent/skills/writing-skills/testing-skills-with-subagents.md +384 -0
- package/config.json +23 -2
- package/dist/banner.js +3 -3
- package/dist/banner.js.map +1 -1
- package/package.json +21 -16
- package/scripts/banner.txt +4 -3
- package/scripts/postinstall.js +203 -11
- package/config/agent/prompts/git-rollback.md +0 -91
- package/config/agent/prompts/git-worktree.md +0 -277
- package/config/agent/prompts/help.md +0 -10
- package/config/agent/skills/github/SKILL.md +0 -47
- package/config/agent/skills/skill-creator/references/output-patterns.md +0 -82
- package/config/agent/skills/skill-creator/references/workflows.md +0 -28
- package/config/agent/skills/skill-creator/scripts/init_skill.py +0 -303
package/scripts/postinstall.js
CHANGED
|
@@ -68,6 +68,21 @@ if (existsSync(piAgentConfigJs)) {
|
|
|
68
68
|
}
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
+
// Fix pi-coding-agent slash commands - change "Quit pi" to "Quit aicode-cli"
|
|
72
|
+
const slashCommandsJs = join(__dirname, '..', 'node_modules', '@mariozechner', 'pi-coding-agent', 'dist', 'core', 'slash-commands.js');
|
|
73
|
+
if (existsSync(slashCommandsJs)) {
|
|
74
|
+
try {
|
|
75
|
+
let content = readFileSync(slashCommandsJs, 'utf-8');
|
|
76
|
+
if (content.includes('Quit pi')) {
|
|
77
|
+
content = content.replace(/Quit pi/g, 'Quit aicode-cli');
|
|
78
|
+
writeFileSync(slashCommandsJs, content);
|
|
79
|
+
console.log(`✓ Updated slash command description`);
|
|
80
|
+
}
|
|
81
|
+
} catch (e) {
|
|
82
|
+
console.log(`⚠ Could not update slash commands: ${e.message}`);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
71
86
|
// Ensure .aicode-cli directory exists
|
|
72
87
|
if (!existsSync(aicodeCliDir)) {
|
|
73
88
|
mkdirSync(aicodeCliDir, { recursive: true });
|
|
@@ -114,6 +129,27 @@ function copyDirRecursive(src, dest) {
|
|
|
114
129
|
}
|
|
115
130
|
}
|
|
116
131
|
|
|
132
|
+
// Force copy directory recursively (always overwrite destination)
|
|
133
|
+
function forceCopyDirRecursive(src, dest) {
|
|
134
|
+
if (!existsSync(src)) return;
|
|
135
|
+
|
|
136
|
+
const stats = statSync(src);
|
|
137
|
+
if (stats.isDirectory()) {
|
|
138
|
+
if (!existsSync(dest)) {
|
|
139
|
+
mkdirSync(dest, { recursive: true });
|
|
140
|
+
}
|
|
141
|
+
readdirSync(src).forEach(file => {
|
|
142
|
+
forceCopyDirRecursive(join(src, file), join(dest, file));
|
|
143
|
+
});
|
|
144
|
+
} else {
|
|
145
|
+
const parentDir = dirname(dest);
|
|
146
|
+
if (!existsSync(parentDir)) {
|
|
147
|
+
mkdirSync(parentDir, { recursive: true });
|
|
148
|
+
}
|
|
149
|
+
copyFileSync(src, dest);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
117
153
|
// Copy config.json if it doesn't exist
|
|
118
154
|
const packageConfigFile = join(__dirname, '..', 'config.json');
|
|
119
155
|
const userConfigFile = join(aicodeCliDir, 'config.json');
|
|
@@ -125,8 +161,126 @@ if (existsSync(packageConfigFile) && !existsSync(userConfigFile)) {
|
|
|
125
161
|
console.log('⚠ config.json not found in package');
|
|
126
162
|
}
|
|
127
163
|
|
|
128
|
-
//
|
|
164
|
+
// ============================================================================
|
|
165
|
+
// Files/folders that must be force-overwritten on every install
|
|
166
|
+
// ============================================================================
|
|
129
167
|
const packageConfigDir = join(__dirname, '..', 'config', 'agent');
|
|
168
|
+
|
|
169
|
+
const FORCE_OVERWRITE_LIST = [
|
|
170
|
+
'APPEND_SYSTEM.md',
|
|
171
|
+
'SYSTEM.md',
|
|
172
|
+
'dangerous-patterns.json',
|
|
173
|
+
'settings.json',
|
|
174
|
+
'extensions/working-msg.ts',
|
|
175
|
+
'extensions/custom-footer.ts',
|
|
176
|
+
'extensions/custom.ts',
|
|
177
|
+
'extensions/bash-check.ts',
|
|
178
|
+
'extensions/aicode-tips.ts',
|
|
179
|
+
// Force overwrite all prompts .md files
|
|
180
|
+
'prompts/*.md',
|
|
181
|
+
// Force overwrite all skills SKILL.md files
|
|
182
|
+
'skills/*/SKILL.md',
|
|
183
|
+
];
|
|
184
|
+
|
|
185
|
+
// Function to expand glob patterns like "skills/*/SKILL.md" or "prompts/*.md"
|
|
186
|
+
function expandGlob(pattern) {
|
|
187
|
+
const results = [];
|
|
188
|
+
|
|
189
|
+
if (pattern.includes('*')) {
|
|
190
|
+
const parts = pattern.split('/');
|
|
191
|
+
let currentPaths = [packageConfigDir];
|
|
192
|
+
|
|
193
|
+
for (let i = 0; i < parts.length; i++) {
|
|
194
|
+
const part = parts[i];
|
|
195
|
+
const nextPaths = [];
|
|
196
|
+
const isLastPart = i === parts.length - 1;
|
|
197
|
+
const hasWildcard = part.includes('*');
|
|
198
|
+
|
|
199
|
+
for (const cp of currentPaths) {
|
|
200
|
+
if (!existsSync(cp)) continue;
|
|
201
|
+
|
|
202
|
+
if (hasWildcard) {
|
|
203
|
+
// Handle wildcard patterns like * or *.md
|
|
204
|
+
const entries = readdirSync(cp);
|
|
205
|
+
// Convert glob pattern to regex: *.md -> ^.*\.md$
|
|
206
|
+
const regex = new RegExp('^' + part.replace(/\*/g, '.*') + '$');
|
|
207
|
+
|
|
208
|
+
for (const entry of entries) {
|
|
209
|
+
if (regex.test(entry)) {
|
|
210
|
+
const fullPath = join(cp, entry);
|
|
211
|
+
if (isLastPart) {
|
|
212
|
+
// Last part - match files (not directories)
|
|
213
|
+
if (statSync(fullPath).isFile()) {
|
|
214
|
+
nextPaths.push(fullPath);
|
|
215
|
+
}
|
|
216
|
+
} else {
|
|
217
|
+
// Not the last part - only directories
|
|
218
|
+
if (statSync(fullPath).isDirectory()) {
|
|
219
|
+
nextPaths.push(fullPath);
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
} else {
|
|
225
|
+
nextPaths.push(join(cp, part));
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
currentPaths = nextPaths;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
for (const p of currentPaths) {
|
|
232
|
+
if (existsSync(p)) {
|
|
233
|
+
results.push(relative(packageConfigDir, p));
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
} else {
|
|
237
|
+
results.push(pattern);
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
return results;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
// Function to force overwrite specific files/folders
|
|
244
|
+
function forceOverwriteList(relativePaths) {
|
|
245
|
+
// Expand glob patterns first
|
|
246
|
+
const expandedPaths = [];
|
|
247
|
+
for (const relativePath of relativePaths) {
|
|
248
|
+
expandedPaths.push(...expandGlob(relativePath));
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
expandedPaths.forEach(relativePath => {
|
|
252
|
+
const srcPath = join(packageConfigDir, relativePath);
|
|
253
|
+
const destPath = join(agentDir, relativePath);
|
|
254
|
+
|
|
255
|
+
if (existsSync(srcPath)) {
|
|
256
|
+
try {
|
|
257
|
+
const stats = statSync(srcPath);
|
|
258
|
+
if (stats.isDirectory()) {
|
|
259
|
+
// Force copy directory
|
|
260
|
+
if (!existsSync(destPath)) {
|
|
261
|
+
mkdirSync(destPath, { recursive: true });
|
|
262
|
+
}
|
|
263
|
+
forceCopyDirRecursive(srcPath, destPath);
|
|
264
|
+
console.log(`✓ Force overwritten (dir): ${relativePath}`);
|
|
265
|
+
} else {
|
|
266
|
+
// Force copy file
|
|
267
|
+
const parentDir = dirname(destPath);
|
|
268
|
+
if (!existsSync(parentDir)) {
|
|
269
|
+
mkdirSync(parentDir, { recursive: true });
|
|
270
|
+
}
|
|
271
|
+
copyFileSync(srcPath, destPath);
|
|
272
|
+
console.log(`✓ Force overwritten: ${relativePath}`);
|
|
273
|
+
}
|
|
274
|
+
} catch (e) {
|
|
275
|
+
console.log(`⚠ Could not force overwrite ${relativePath}: ${e.message}`);
|
|
276
|
+
}
|
|
277
|
+
} else {
|
|
278
|
+
console.log(`⚠ Source path does not exist: ${relativePath}`);
|
|
279
|
+
}
|
|
280
|
+
});
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
// Copy config/agent contents to ~/.aicode-cli/agent only if they don't exist (preserve user customizations)
|
|
130
284
|
if (existsSync(packageConfigDir)) {
|
|
131
285
|
console.log(`📁 Syncing default config files to ${agentDir} (preserving user customizations)`);
|
|
132
286
|
|
|
@@ -134,6 +288,11 @@ if (existsSync(packageConfigDir)) {
|
|
|
134
288
|
copyDirRecursive(packageConfigDir, agentDir);
|
|
135
289
|
console.log('✓ Default config files synced successfully');
|
|
136
290
|
|
|
291
|
+
// Force overwrite specified files/folders
|
|
292
|
+
if (FORCE_OVERWRITE_LIST.length > 0) {
|
|
293
|
+
forceOverwriteList(FORCE_OVERWRITE_LIST);
|
|
294
|
+
}
|
|
295
|
+
|
|
137
296
|
// Check for extensions
|
|
138
297
|
const extensionsDir = join(agentDir, 'extensions');
|
|
139
298
|
if (existsSync(extensionsDir)) {
|
|
@@ -150,6 +309,44 @@ if (existsSync(packageConfigDir)) {
|
|
|
150
309
|
console.log('⚠ Configuration directory not found in package');
|
|
151
310
|
}
|
|
152
311
|
|
|
312
|
+
// ============================================================================
|
|
313
|
+
// Reset User-Agent placeholder in models.json (so CLI can replace it on each run)
|
|
314
|
+
// ============================================================================
|
|
315
|
+
const modelsPath = join(agentDir, 'models.json');
|
|
316
|
+
if (existsSync(modelsPath)) {
|
|
317
|
+
try {
|
|
318
|
+
let content = readFileSync(modelsPath, 'utf-8');
|
|
319
|
+
// 只重置 headers.User-Agent 下的版本号为占位符
|
|
320
|
+
try {
|
|
321
|
+
const config = JSON.parse(content);
|
|
322
|
+
for (const provider of Object.values(config.providers || {})) {
|
|
323
|
+
if (provider.headers && provider.headers['User-Agent']) {
|
|
324
|
+
const ua = provider.headers['User-Agent'];
|
|
325
|
+
// 如果是以 aicode-cli/ 开头,替换为占位符
|
|
326
|
+
if (ua && ua.startsWith('aicode-cli/')) {
|
|
327
|
+
provider.headers['User-Agent'] = '${VERSION}';
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
const newContent = JSON.stringify(config, null, 2);
|
|
332
|
+
|
|
333
|
+
if (newContent !== content) {
|
|
334
|
+
writeFileSync(modelsPath, newContent, 'utf-8');
|
|
335
|
+
console.log('✓ Reset User-Agent placeholder in models.json');
|
|
336
|
+
}
|
|
337
|
+
} catch (e) {
|
|
338
|
+
console.log(`⚠ Could not reset User-Agent placeholder: ${e.message}`);
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
if (newContent !== content) {
|
|
342
|
+
writeFileSync(modelsPath, newContent, 'utf-8');
|
|
343
|
+
console.log('✓ Reset User-Agent placeholder in models.json');
|
|
344
|
+
}
|
|
345
|
+
} catch (e) {
|
|
346
|
+
console.log(`⚠ Could not reset User-Agent placeholder: ${e.message}`);
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
|
|
153
350
|
// Create symlink ~/.pi linking to ~/.aicode-cli (if not exists)
|
|
154
351
|
try {
|
|
155
352
|
if (!existsSync(piDir)) {
|
|
@@ -170,24 +367,19 @@ try {
|
|
|
170
367
|
}
|
|
171
368
|
}
|
|
172
369
|
|
|
173
|
-
// Check
|
|
174
|
-
const modelsPath = join(agentDir, 'models.json');
|
|
370
|
+
// Check and display models config
|
|
175
371
|
if (existsSync(modelsPath)) {
|
|
176
372
|
try {
|
|
177
|
-
const models = JSON.parse(readFileSync(modelsPath, '
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
console.log(`✓ Found ${
|
|
181
|
-
console.log(` - ${Object.keys(models).join(', ')}`);
|
|
182
|
-
} else {
|
|
183
|
-
console.log(`✓ Config file exists but no models configured`);
|
|
373
|
+
const models = JSON.parse(readFileSync(modelsPath, 'utf-8'));
|
|
374
|
+
if (models.providers) {
|
|
375
|
+
const providerCount = Object.keys(models.providers).length;
|
|
376
|
+
console.log(`✓ Found ${providerCount} configured provider(s)`);
|
|
184
377
|
}
|
|
185
378
|
} catch (e) {
|
|
186
379
|
console.log(`⚠ Error reading models.json: ${e.message}`);
|
|
187
380
|
}
|
|
188
381
|
} else {
|
|
189
382
|
console.log(`⚠ No models.json found at ${modelsPath}`);
|
|
190
|
-
console.log('\n📌 To configure models, create ~/.aicode-cli/agent/models.json');
|
|
191
383
|
}
|
|
192
384
|
|
|
193
385
|
console.log('\n✨ Setup complete!');
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
description: 交互式回滚 Git 分支到历史版本;列分支、列版本、二次确认后执行 reset / revert
|
|
3
|
-
allowed-tools: Read(**), Exec(git fetch, git branch, git tag, git log, git reflog, git checkout, git reset, git revert, git switch), Write()
|
|
4
|
-
argument-hint: "[--branch <branch>] [--target <rev>] [--mode reset|revert] [--depth <n>] [--dry-run] [--yes]"
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
# examples:
|
|
8
|
-
# - /git-rollback # 全交互模式,dry‑run
|
|
9
|
-
# - /git-rollback --branch dev # 直接选 dev,其他交互
|
|
10
|
-
# - /git-rollback --branch dev --target v1.2.0 --mode reset --yes
|
|
11
|
-
|
|
12
|
-
# Claude Command: Git Rollback
|
|
13
|
-
|
|
14
|
-
**目的**:安全、可视地将指定分支回滚到旧版本。
|
|
15
|
-
默认处于 **只读预览 (`--dry-run`)**;真正执行需加 `--yes` 或在交互中确认。
|
|
16
|
-
|
|
17
|
-
---
|
|
18
|
-
|
|
19
|
-
## Usage
|
|
20
|
-
|
|
21
|
-
```bash
|
|
22
|
-
# 纯交互:列出分支 → 选分支 → 列最近 20 个版本 → 选目标 → 选择 reset 或 revert → 二次确认
|
|
23
|
-
/git-rollback
|
|
24
|
-
|
|
25
|
-
# 指定分支,其他交互
|
|
26
|
-
/git-rollback --branch feature/calculator
|
|
27
|
-
|
|
28
|
-
# 指定分支与目标 commit,并用 hard‑reset 一键执行(危险)
|
|
29
|
-
/git-rollback --branch main --target 1a2b3c4d --mode reset --yes
|
|
30
|
-
|
|
31
|
-
# 只想生成 revert 提交(非破坏式回滚),预览即可
|
|
32
|
-
/git-rollback --branch release/v2.1 --target v2.0.5 --mode revert --dry-run
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
### Options
|
|
36
|
-
|
|
37
|
-
| 选项 | 说明 |
|
|
38
|
-
| ---------------------- | ---------------------------------------------------------------------------------- |
|
|
39
|
-
| `--branch <branch>` | 要回滚的分支;缺省时交互选择。 |
|
|
40
|
-
| `--target <rev>` | 目标版本(commit Hash、Tag、reflog 引用都行);缺省时交互选择近 `--depth` 条记录。 |
|
|
41
|
-
| `--mode reset\|revert` | `reset`:硬回滚历史;`revert`:生成反向提交保持历史完整。默认询问。 |
|
|
42
|
-
| `--depth <n>` | 在交互模式下列出最近 n 个版本(默认 20)。 |
|
|
43
|
-
| `--dry-run` | **默认开启**,只预览即将执行的命令。 |
|
|
44
|
-
| `--yes` | 跳过所有确认直接执行,适合 CI/CD 脚本。 |
|
|
45
|
-
|
|
46
|
-
---
|
|
47
|
-
|
|
48
|
-
## 交互流程
|
|
49
|
-
|
|
50
|
-
1. **同步远端** → `git fetch --all --prune`
|
|
51
|
-
2. **列分支** → `git branch -a`(本地+远端,过滤受保护分支)
|
|
52
|
-
3. **选分支** → 用户输入或传参
|
|
53
|
-
4. **列版本** → `git log --oneline -n <depth>` + `git tag --merged` + `git reflog -n <depth>`
|
|
54
|
-
5. **选目标** → 用户输入 commit hash / tag
|
|
55
|
-
6. **选模式** → `reset` 或 `revert`
|
|
56
|
-
7. **最终确认** (除非 `--yes`)
|
|
57
|
-
8. **执行回滚**
|
|
58
|
-
- `reset`:`git switch <branch> && git reset --hard <target>`
|
|
59
|
-
- `revert`:`git switch <branch> && git revert --no-edit <target>..HEAD`
|
|
60
|
-
9. **推送建议** → 提示是否 `git push --force-with-lease`(reset)或普通 `git push`(revert)
|
|
61
|
-
|
|
62
|
-
---
|
|
63
|
-
|
|
64
|
-
## 安全护栏
|
|
65
|
-
|
|
66
|
-
- **备份**:执行前自动在 reflog 中记录当前 HEAD,可用 `git switch -c backup/<timestamp>` 恢复。
|
|
67
|
-
- **保护分支**:如检测到 `main` / `master` / `production` 等受保护分支且开启 `reset` 模式,将要求额外确认。
|
|
68
|
-
- **--dry-run 默认开启**:防止误操作。
|
|
69
|
-
- **--force 禁止**:不提供 `--force`;如需强推,请手动输入 `git push --force-with-lease`。
|
|
70
|
-
|
|
71
|
-
---
|
|
72
|
-
|
|
73
|
-
## 适用场景示例
|
|
74
|
-
|
|
75
|
-
| 场景 | 调用示例 |
|
|
76
|
-
| ----------------------------------------------- | ---------------------------------------------------------------- |
|
|
77
|
-
| 热修补丁上线后发现 bug,需要回到 Tag `v1.2.0` | `/git-rollback --branch release/v1 --target v1.2.0 --mode reset` |
|
|
78
|
-
| 运维同事误推了 debug 日志提交,需要生成反向提交 | `/git-rollback --branch main --target 3f2e7c9 --mode revert` |
|
|
79
|
-
| 调研历史 bug,引导新人浏览分支历史 | `/git-rollback` (全交互,dry‑run) |
|
|
80
|
-
|
|
81
|
-
---
|
|
82
|
-
|
|
83
|
-
## 注意
|
|
84
|
-
|
|
85
|
-
1. **reset vs revert**
|
|
86
|
-
- **reset** 会改变历史,需要强推并可能影响其他协作者,谨慎使用。
|
|
87
|
-
- **revert** 更安全,生成新提交保留历史,但会增加一次记录。
|
|
88
|
-
2. **嵌入式仓库** 常有大体积二进制文件;回滚前请确保 LFS/子模块状态一致。
|
|
89
|
-
3. 若仓库启用了 CI 强制校验,回滚后可能自动触发流水线;确认管控策略以免误部署旧版本。
|
|
90
|
-
|
|
91
|
-
---
|
|
@@ -1,277 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
description: 管理 Git worktree
|
|
3
|
-
allowed-tools: Read(**), Exec(git worktree add, git worktree list, git worktree remove, git worktree prune, git branch, git checkout, git rev-parse, git stash, git cp, detect-ide, open-ide, which, command, basename, dirname)
|
|
4
|
-
argument-hint: <add|list|remove|prune|migrate> [path] [-b <branch>] [-o|--open] [--track] [--guess-remote] [--detach] [--checkout] [--lock] [--migrate-from <source-path>] [--migrate-stash]
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
# examples:
|
|
8
|
-
# - /git-worktree add feature-ui # 从 main/master 创建新分支 'feature-ui'
|
|
9
|
-
# - /git-worktree add feature-ui -o # 创建 worktree 并直接用 IDE 打开
|
|
10
|
-
# - /git-worktree add hotfix -b fix/login -o # 创建新分支 'fix/login',路径为 'hotfix'
|
|
11
|
-
# - /git-worktree migrate feature-ui --from main # 将主分支未提交内容迁移到 feature-ui
|
|
12
|
-
# - /git-worktree migrate feature-ui --stash # 将当前 stash 迁移到 feature-ui
|
|
13
|
-
|
|
14
|
-
# Claude Command: Git Worktree
|
|
15
|
-
|
|
16
|
-
管理 Git worktree,支持智能默认、IDE 集成和内容迁移,使用结构化的 `../.zcf/项目名/` 路径。
|
|
17
|
-
|
|
18
|
-
直接执行命令并提供简洁结果。
|
|
19
|
-
|
|
20
|
-
---
|
|
21
|
-
|
|
22
|
-
## Usage
|
|
23
|
-
|
|
24
|
-
```bash
|
|
25
|
-
# 基本操作
|
|
26
|
-
/git-worktree add <path> # 从 main/master 创建名为 <path> 的新分支
|
|
27
|
-
/git-worktree add <path> -b <branch> # 创建指定名称的新分支
|
|
28
|
-
/git-worktree add <path> -o # 创建并直接用 IDE 打开
|
|
29
|
-
/git-worktree list # 显示所有 worktree 状态
|
|
30
|
-
/git-worktree remove <path> # 删除指定的 worktree
|
|
31
|
-
/git-worktree prune # 清理无效 worktree 记录
|
|
32
|
-
|
|
33
|
-
# 内容迁移
|
|
34
|
-
/git-worktree migrate <target> --from <source> # 迁移未提交内容
|
|
35
|
-
/git-worktree migrate <target> --stash # 迁移 stash 内容
|
|
36
|
-
```
|
|
37
|
-
|
|
38
|
-
### Options
|
|
39
|
-
|
|
40
|
-
| 选项 | 说明 |
|
|
41
|
-
| ------------------ | -------------------------------------------- |
|
|
42
|
-
| `add [<path>]` | 在 `../.zcf/项目名/<path>` 添加新的 worktree |
|
|
43
|
-
| `migrate <target>` | 迁移内容到指定 worktree |
|
|
44
|
-
| `list` | 列出所有 worktree 及其状态 |
|
|
45
|
-
| `remove <path>` | 删除指定路径的 worktree |
|
|
46
|
-
| `prune` | 清理无效的 worktree 引用 |
|
|
47
|
-
| `-b <branch>` | 创建新分支并检出到 worktree |
|
|
48
|
-
| `-o, --open` | 创建成功后直接用 IDE 打开(跳过询问) |
|
|
49
|
-
| `--from <source>` | 指定迁移源路径(migrate 专用) |
|
|
50
|
-
| `--stash` | 迁移当前 stash 内容(migrate 专用) |
|
|
51
|
-
| `--track` | 设置新分支跟踪对应的远程分支 |
|
|
52
|
-
| `--guess-remote` | 自动猜测远程分支进行跟踪 |
|
|
53
|
-
| `--detach` | 创建分离 HEAD 的 worktree |
|
|
54
|
-
| `--checkout` | 创建后立即检出(默认行为) |
|
|
55
|
-
| `--lock` | 创建后锁定 worktree |
|
|
56
|
-
|
|
57
|
-
---
|
|
58
|
-
|
|
59
|
-
## What This Command Does
|
|
60
|
-
|
|
61
|
-
1. **环境检查**
|
|
62
|
-
- 通过 `git rev-parse --is-inside-work-tree` 验证 Git 仓库
|
|
63
|
-
- 检测是否在主仓库或现有 worktree 中,进行智能路径计算
|
|
64
|
-
|
|
65
|
-
2. **智能路径管理**
|
|
66
|
-
- 使用 worktree 检测自动从主仓库路径计算项目名
|
|
67
|
-
- 在结构化的 `../.zcf/项目名/<path>` 目录创建 worktree
|
|
68
|
-
- 正确处理主仓库和 worktree 执行上下文
|
|
69
|
-
|
|
70
|
-
```bash
|
|
71
|
-
# worktree 检测的核心路径计算逻辑
|
|
72
|
-
get_main_repo_path() {
|
|
73
|
-
local git_common_dir=$(git rev-parse --git-common-dir 2>/dev/null)
|
|
74
|
-
local current_toplevel=$(git rev-parse --show-toplevel 2>/dev/null)
|
|
75
|
-
|
|
76
|
-
# 检测是否在 worktree 中
|
|
77
|
-
if [[ "$git_common_dir" != "$current_toplevel/.git" ]]; then
|
|
78
|
-
# 在 worktree 中,从 git-common-dir 推导主仓库路径
|
|
79
|
-
dirname "$git_common_dir"
|
|
80
|
-
else
|
|
81
|
-
# 在主仓库中
|
|
82
|
-
echo "$current_toplevel"
|
|
83
|
-
fi
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
MAIN_REPO_PATH=$(get_main_repo_path)
|
|
87
|
-
PROJECT_NAME=$(basename "$MAIN_REPO_PATH")
|
|
88
|
-
WORKTREE_BASE="$MAIN_REPO_PATH/../.zcf/$PROJECT_NAME"
|
|
89
|
-
|
|
90
|
-
# 始终使用绝对路径防止嵌套问题
|
|
91
|
-
ABSOLUTE_WORKTREE_PATH="$WORKTREE_BASE/<path>"
|
|
92
|
-
```
|
|
93
|
-
|
|
94
|
-
**关键修复**: 在现有 worktree 内创建新 worktree 时,始终使用绝对路径以防止出现类似 `../.zcf/project/.zcf/project/path` 的路径嵌套问题。
|
|
95
|
-
|
|
96
|
-
3. **Worktree 操作**
|
|
97
|
-
- **add**: 使用智能分支/路径默认创建新 worktree
|
|
98
|
-
- **list**: 显示所有 worktree 的分支和状态
|
|
99
|
-
- **remove**: 安全删除 worktree 并清理引用
|
|
100
|
-
- **prune**: 清理孤立的 worktree 记录
|
|
101
|
-
|
|
102
|
-
4. **智能默认**
|
|
103
|
-
- **分支创建**: 未指定 `-b` 时,使用路径名创建新分支
|
|
104
|
-
- **基础分支**: 新分支从 main/master 分支创建
|
|
105
|
-
- **路径解析**: 未指定路径时使用分支名作为路径
|
|
106
|
-
- **IDE 集成**: 自动检测并提示 IDE 打开
|
|
107
|
-
|
|
108
|
-
5. **内容迁移**
|
|
109
|
-
- 在 worktree 之间迁移未提交改动
|
|
110
|
-
- 将 stash 内容应用到目标 worktree
|
|
111
|
-
- 安全检查防止冲突
|
|
112
|
-
|
|
113
|
-
6. **安全特性**
|
|
114
|
-
- **路径冲突防护**: 创建前检查目录是否已存在
|
|
115
|
-
- **分支检出验证**: 确保分支未被其他地方使用
|
|
116
|
-
- **绝对路径强制**: 防止在 worktree 内创建嵌套的 `.zcf` 目录
|
|
117
|
-
- **删除时自动清理**: 同时清理目录和 git 引用
|
|
118
|
-
- **清晰的状态报告**: 显示 worktree 位置和分支状态
|
|
119
|
-
|
|
120
|
-
7. **环境文件处理**
|
|
121
|
-
- **自动检测**: 扫描 `.gitignore` 文件中的环境变量文件模式
|
|
122
|
-
- **智能复制**: 复制 `.gitignore` 中列出的 `.env` 和 `.env.*` 文件
|
|
123
|
-
- **排除逻辑**: 跳过 `.env.example` 等模板文件
|
|
124
|
-
- **权限保护**: 保持原始文件权限和时间戳
|
|
125
|
-
- **用户反馈**: 提供已复制环境文件的清晰状态信息
|
|
126
|
-
|
|
127
|
-
```bash
|
|
128
|
-
# 环境文件复制实现
|
|
129
|
-
copy_environment_files() {
|
|
130
|
-
local main_repo="$MAIN_REPO_PATH"
|
|
131
|
-
local target_worktree="$ABSOLUTE_WORKTREE_PATH"
|
|
132
|
-
local gitignore_file="$main_repo/.gitignore"
|
|
133
|
-
|
|
134
|
-
# 检查 .gitignore 是否存在
|
|
135
|
-
if [[ ! -f "$gitignore_file" ]]; then
|
|
136
|
-
return 0
|
|
137
|
-
fi
|
|
138
|
-
|
|
139
|
-
local copied_count=0
|
|
140
|
-
|
|
141
|
-
# 检测 .env 文件
|
|
142
|
-
if [[ -f "$main_repo/.env" ]] && grep -q "^\.env$" "$gitignore_file"; then
|
|
143
|
-
cp "$main_repo/.env" "$target_worktree/.env"
|
|
144
|
-
echo "✅ 已复制 .env"
|
|
145
|
-
((copied_count++))
|
|
146
|
-
fi
|
|
147
|
-
|
|
148
|
-
# 检测 .env.* 模式文件(排除 .env.example)
|
|
149
|
-
for env_file in "$main_repo"/.env.*; do
|
|
150
|
-
if [[ -f "$env_file" ]] && [[ "$(basename "$env_file")" != ".env.example" ]]; then
|
|
151
|
-
local filename=$(basename "$env_file")
|
|
152
|
-
if grep -q "^\.env\.\*$" "$gitignore_file"; then
|
|
153
|
-
cp "$env_file" "$target_worktree/$filename"
|
|
154
|
-
echo "✅ 已复制 $filename"
|
|
155
|
-
((copied_count++))
|
|
156
|
-
fi
|
|
157
|
-
fi
|
|
158
|
-
done
|
|
159
|
-
|
|
160
|
-
if [[ $copied_count -gt 0 ]]; then
|
|
161
|
-
echo "📋 已从 .gitignore 复制 $copied_count 个环境文件"
|
|
162
|
-
fi
|
|
163
|
-
}
|
|
164
|
-
```
|
|
165
|
-
|
|
166
|
-
---
|
|
167
|
-
|
|
168
|
-
## Enhanced Features
|
|
169
|
-
|
|
170
|
-
### IDE 集成
|
|
171
|
-
|
|
172
|
-
- **自动检测**: VS Code → Cursor → WebStorm → Sublime Text → Vim
|
|
173
|
-
- **智能提示**: 创建 worktree 后询问是否在 IDE 中打开
|
|
174
|
-
- **直接打开**: 使用 `-o` 标志跳过提示直接打开
|
|
175
|
-
- **自定义配置**: 通过 git config 配置
|
|
176
|
-
|
|
177
|
-
### 内容迁移系统
|
|
178
|
-
|
|
179
|
-
```bash
|
|
180
|
-
# 迁移未提交改动
|
|
181
|
-
/git-worktree migrate feature-ui --from main
|
|
182
|
-
/git-worktree migrate hotfix --from ../other-worktree
|
|
183
|
-
|
|
184
|
-
# 迁移 stash 内容
|
|
185
|
-
/git-worktree migrate feature-ui --stash
|
|
186
|
-
```
|
|
187
|
-
|
|
188
|
-
**迁移流程**:
|
|
189
|
-
|
|
190
|
-
1. 验证源有未提交内容
|
|
191
|
-
2. 确保目标 worktree 干净
|
|
192
|
-
3. 显示即将迁移的改动
|
|
193
|
-
4. 使用 git 命令安全迁移
|
|
194
|
-
5. 确认结果并建议后续步骤
|
|
195
|
-
|
|
196
|
-
---
|
|
197
|
-
|
|
198
|
-
## Examples
|
|
199
|
-
|
|
200
|
-
```bash
|
|
201
|
-
# 基本用法
|
|
202
|
-
/git-worktree add feature-ui # 从 main/master 创建新分支 'feature-ui'
|
|
203
|
-
/git-worktree add feature-ui -b my-feature # 创建新分支 'my-feature',路径为 'feature-ui'
|
|
204
|
-
/git-worktree add feature-ui -o # 创建并直接用 IDE 打开
|
|
205
|
-
|
|
206
|
-
# 内容迁移场景
|
|
207
|
-
/git-worktree add feature-ui -b feature/new-ui # 创建新功能 worktree
|
|
208
|
-
/git-worktree migrate feature-ui --from main # 迁移未提交改动
|
|
209
|
-
/git-worktree migrate hotfix --stash # 迁移 stash 内容
|
|
210
|
-
|
|
211
|
-
# 管理操作
|
|
212
|
-
/git-worktree list # 查看所有 worktree
|
|
213
|
-
/git-worktree remove feature-ui # 删除不需要的 worktree
|
|
214
|
-
/git-worktree prune # 清理无效引用
|
|
215
|
-
```
|
|
216
|
-
|
|
217
|
-
**示例输出**:
|
|
218
|
-
|
|
219
|
-
```
|
|
220
|
-
✅ Worktree created at ../.zcf/项目名/feature-ui
|
|
221
|
-
✅ 已复制 .env
|
|
222
|
-
✅ 已复制 .env.local
|
|
223
|
-
📋 已从 .gitignore 复制 2 个环境文件
|
|
224
|
-
🖥️ 是否在 IDE 中打开 ../.zcf/项目名/feature-ui?[y/n]: y
|
|
225
|
-
🚀 正在用 VS Code 打开 ../.zcf/项目名/feature-ui...
|
|
226
|
-
```
|
|
227
|
-
|
|
228
|
-
---
|
|
229
|
-
|
|
230
|
-
## Directory Structure
|
|
231
|
-
|
|
232
|
-
```
|
|
233
|
-
parent-directory/
|
|
234
|
-
├── your-project/ # 主项目
|
|
235
|
-
│ ├── .git/
|
|
236
|
-
│ └── src/
|
|
237
|
-
└── .zcf/ # worktree 管理
|
|
238
|
-
└── your-project/ # 项目 worktree
|
|
239
|
-
├── feature-ui/ # 功能分支
|
|
240
|
-
├── hotfix/ # 修复分支
|
|
241
|
-
└── debug/ # 调试 worktree
|
|
242
|
-
```
|
|
243
|
-
|
|
244
|
-
---
|
|
245
|
-
|
|
246
|
-
## Configuration
|
|
247
|
-
|
|
248
|
-
### IDE 配置
|
|
249
|
-
|
|
250
|
-
- 支持 VS Code、Cursor、WebStorm、Sublime Text、Vim
|
|
251
|
-
- 通过 git config 配置自定义 IDE
|
|
252
|
-
- 基于优先级的自动检测选择
|
|
253
|
-
|
|
254
|
-
### 自定义 IDE 设置
|
|
255
|
-
|
|
256
|
-
```bash
|
|
257
|
-
# 配置自定义 IDE
|
|
258
|
-
git config worktree.ide.custom.sublime "subl %s"
|
|
259
|
-
git config worktree.ide.preferred "sublime"
|
|
260
|
-
|
|
261
|
-
# 控制自动检测
|
|
262
|
-
git config worktree.ide.autodetect true # 默认
|
|
263
|
-
```
|
|
264
|
-
|
|
265
|
-
---
|
|
266
|
-
|
|
267
|
-
## Notes
|
|
268
|
-
|
|
269
|
-
- **性能**: worktree 共享 `.git` 目录,节省磁盘空间
|
|
270
|
-
- **安全**: 路径冲突防护和分支检出验证
|
|
271
|
-
- **迁移**: 仅限未提交改动;已提交内容需使用 `git cherry-pick`
|
|
272
|
-
- **IDE 要求**: 命令行工具必须在 PATH 中
|
|
273
|
-
- **跨平台**: 支持 Windows、macOS、Linux
|
|
274
|
-
- **环境文件**: 自动复制 `.gitignore` 中列出的环境文件到新 worktree
|
|
275
|
-
- **文件排除**: 模板文件如 `.env.example` 仅保留在主仓库中
|
|
276
|
-
|
|
277
|
-
---
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: github
|
|
3
|
-
description: "Interact with GitHub using the `gh` CLI. Use `gh issue`, `gh pr`, `gh run`, and `gh api` for issues, PRs, CI runs, and advanced queries."
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
# GitHub Skill
|
|
7
|
-
|
|
8
|
-
Use the `gh` CLI to interact with GitHub. Always specify `--repo owner/repo` when not in a git directory, or use URLs directly.
|
|
9
|
-
|
|
10
|
-
## Pull Requests
|
|
11
|
-
|
|
12
|
-
Check CI status on a PR:
|
|
13
|
-
```bash
|
|
14
|
-
gh pr checks 55 --repo owner/repo
|
|
15
|
-
```
|
|
16
|
-
|
|
17
|
-
List recent workflow runs:
|
|
18
|
-
```bash
|
|
19
|
-
gh run list --repo owner/repo --limit 10
|
|
20
|
-
```
|
|
21
|
-
|
|
22
|
-
View a run and see which steps failed:
|
|
23
|
-
```bash
|
|
24
|
-
gh run view <run-id> --repo owner/repo
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
View logs for failed steps only:
|
|
28
|
-
```bash
|
|
29
|
-
gh run view <run-id> --repo owner/repo --log-failed
|
|
30
|
-
```
|
|
31
|
-
|
|
32
|
-
## API for Advanced Queries
|
|
33
|
-
|
|
34
|
-
The `gh api` command is useful for accessing data not available through other subcommands.
|
|
35
|
-
|
|
36
|
-
Get PR with specific fields:
|
|
37
|
-
```bash
|
|
38
|
-
gh api repos/owner/repo/pulls/55 --jq '.title, .state, .user.login'
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
## JSON Output
|
|
42
|
-
|
|
43
|
-
Most commands support `--json` for structured output. You can use `--jq` to filter:
|
|
44
|
-
|
|
45
|
-
```bash
|
|
46
|
-
gh issue list --repo owner/repo --json number,title --jq '.[] | "\(.number): \(.title)"'
|
|
47
|
-
```
|