@unity-china/codely-cli 1.0.0-rc.4 → 1.0.0-rc.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +203 -0
- package/README.md +332 -0
- package/README.zh-CN.md +336 -0
- package/bundle/builtin/skill-creator/SKILL.md +381 -0
- package/bundle/builtin/skill-creator/scripts/init_skill.cjs +237 -0
- package/bundle/builtin/skill-creator/scripts/package_skill.cjs +142 -0
- package/bundle/builtin/skill-creator/scripts/validate_skill.cjs +137 -0
- package/bundle/example-prompts/README.md +56 -0
- package/bundle/example-prompts/analyze.toml +47 -0
- package/bundle/example-prompts/explain-code.toml +200 -0
- package/bundle/example-prompts/git-commit.toml +48 -0
- package/bundle/gemini.js +7258 -0
- package/bundle/gemini.js.LEGAL.txt +373 -0
- package/bundle/policies/plan.toml +137 -0
- package/bundle/policies/read-only.toml +75 -0
- package/bundle/policies/write.toml +44 -0
- package/bundle/policies/yolo.toml +9 -0
- package/bundle/sandbox-macos-permissive-closed.sb +32 -0
- package/bundle/sandbox-macos-permissive-open.sb +25 -0
- package/bundle/sandbox-macos-permissive-proxied.sb +37 -0
- package/bundle/sandbox-macos-restrictive-closed.sb +93 -0
- package/bundle/sandbox-macos-restrictive-open.sb +96 -0
- package/bundle/sandbox-macos-restrictive-proxied.sb +98 -0
- package/bundle/tiktoken_bg.wasm +0 -0
- package/bundle/web-ui/dist/public/app.css +2860 -0
- package/bundle/web-ui/dist/public/app.js +140 -0
- package/bundle/web-ui/dist/public/index.html +17 -0
- package/package.json +101 -81
- package/dist/index.js +0 -19
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Skill Packager - Creates a distributable .skill file of a skill folder
|
|
3
|
+
*
|
|
4
|
+
* Usage:
|
|
5
|
+
* node package_skill.js <path/to/skill-folder> [output-directory]
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
const path = require('node:path');
|
|
9
|
+
const os = require('node:os');
|
|
10
|
+
const fs = require('node:fs');
|
|
11
|
+
const { spawnSync } = require('node:child_process');
|
|
12
|
+
const { validateSkill } = require('./validate_skill.cjs');
|
|
13
|
+
|
|
14
|
+
const DEFAULT_OUTPUT_DIR = path.join(os.tmpdir(), 'codely-skills');
|
|
15
|
+
|
|
16
|
+
async function main() {
|
|
17
|
+
const args = process.argv.slice(2);
|
|
18
|
+
if (args.length < 1) {
|
|
19
|
+
console.log(
|
|
20
|
+
'Usage: node package_skill.cjs <path/to/skill-folder> [output-directory]',
|
|
21
|
+
);
|
|
22
|
+
console.log(
|
|
23
|
+
` output-directory: optional, default: ${DEFAULT_OUTPUT_DIR}`,
|
|
24
|
+
);
|
|
25
|
+
process.exit(1);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const skillPathArg = args[0];
|
|
29
|
+
const outputDirArg = args[1];
|
|
30
|
+
|
|
31
|
+
if (
|
|
32
|
+
skillPathArg.includes('..') ||
|
|
33
|
+
(outputDirArg && outputDirArg.includes('..'))
|
|
34
|
+
) {
|
|
35
|
+
console.error('❌ Error: Path traversal detected in arguments.');
|
|
36
|
+
process.exit(1);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const skillPath = path.resolve(skillPathArg);
|
|
40
|
+
const outputDir = outputDirArg
|
|
41
|
+
? path.resolve(outputDirArg)
|
|
42
|
+
: DEFAULT_OUTPUT_DIR;
|
|
43
|
+
|
|
44
|
+
if (!outputDirArg) {
|
|
45
|
+
fs.mkdirSync(outputDir, { recursive: true });
|
|
46
|
+
}
|
|
47
|
+
const skillName = path.basename(skillPath);
|
|
48
|
+
|
|
49
|
+
// 1. Validate first
|
|
50
|
+
console.log('🔍 Validating skill...');
|
|
51
|
+
const result = validateSkill(skillPath);
|
|
52
|
+
if (!result.valid) {
|
|
53
|
+
console.error(`❌ Validation failed: ${result.message}`);
|
|
54
|
+
process.exit(1);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
if (result.warning) {
|
|
58
|
+
console.warn(`⚠️ ${result.warning}`);
|
|
59
|
+
console.log('Please resolve all TODOs before packaging.');
|
|
60
|
+
process.exit(1);
|
|
61
|
+
}
|
|
62
|
+
if (result.checks && result.checks.length > 0) {
|
|
63
|
+
for (const check of result.checks) {
|
|
64
|
+
console.log(`✓ ${check}`);
|
|
65
|
+
}
|
|
66
|
+
} else {
|
|
67
|
+
console.log('✅ Skill is valid!');
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// 2. Package
|
|
71
|
+
const outputFilename = path.join(outputDir, `${skillName}.skill`);
|
|
72
|
+
|
|
73
|
+
try {
|
|
74
|
+
// Zip everything except junk, keeping the folder structure
|
|
75
|
+
// We'll use the native 'zip' command for simplicity in a CLI environment
|
|
76
|
+
// or we could use a JS library, but zip is ubiquitous on darwin/linux.
|
|
77
|
+
|
|
78
|
+
// Command to zip:
|
|
79
|
+
// -r: recursive
|
|
80
|
+
// -x: exclude patterns
|
|
81
|
+
// Run the zip command from within the directory to avoid parent folder nesting
|
|
82
|
+
let zipProcess = spawnSync('zip', ['-r', outputFilename, '.'], {
|
|
83
|
+
cwd: skillPath,
|
|
84
|
+
stdio: 'inherit',
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
if (zipProcess.error || zipProcess.status !== 0) {
|
|
88
|
+
if (process.platform === 'win32') {
|
|
89
|
+
// Fallback to PowerShell Compress-Archive on Windows
|
|
90
|
+
// Note: Compress-Archive only supports .zip extension, so we zip to .zip and rename
|
|
91
|
+
console.log('zip command not found, falling back to PowerShell...');
|
|
92
|
+
const tempZip = outputFilename + '.zip';
|
|
93
|
+
// Escape single quotes for PowerShell (replace ' with '') and use single quotes for the path
|
|
94
|
+
const safeTempZip = tempZip.replace(/'/g, "''");
|
|
95
|
+
zipProcess = spawnSync(
|
|
96
|
+
'powershell.exe',
|
|
97
|
+
[
|
|
98
|
+
'-NoProfile',
|
|
99
|
+
'-Command',
|
|
100
|
+
`Compress-Archive -Path .\\* -DestinationPath '${safeTempZip}' -Force`,
|
|
101
|
+
],
|
|
102
|
+
{
|
|
103
|
+
cwd: skillPath,
|
|
104
|
+
stdio: 'inherit',
|
|
105
|
+
},
|
|
106
|
+
);
|
|
107
|
+
|
|
108
|
+
if (zipProcess.status === 0 && fs.existsSync(tempZip)) {
|
|
109
|
+
fs.renameSync(tempZip, outputFilename);
|
|
110
|
+
}
|
|
111
|
+
} else {
|
|
112
|
+
// Fallback to tar on Unix-like systems
|
|
113
|
+
console.log('zip command not found, falling back to tar...');
|
|
114
|
+
zipProcess = spawnSync(
|
|
115
|
+
'tar',
|
|
116
|
+
['-a', '-c', '--format=zip', '-f', outputFilename, '.'],
|
|
117
|
+
{
|
|
118
|
+
cwd: skillPath,
|
|
119
|
+
stdio: 'inherit',
|
|
120
|
+
},
|
|
121
|
+
);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
if (zipProcess.error) {
|
|
126
|
+
throw zipProcess.error;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
if (zipProcess.status !== 0) {
|
|
130
|
+
throw new Error(
|
|
131
|
+
`Packaging command failed with exit code ${zipProcess.status}`,
|
|
132
|
+
);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
console.log(`✅ Successfully packaged skill to: ${outputFilename}`);
|
|
136
|
+
} catch (err) {
|
|
137
|
+
console.error(`❌ Error packaging: ${err.message}`);
|
|
138
|
+
process.exit(1);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
main();
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Quick validation logic for skills.
|
|
9
|
+
* Leveraging existing dependencies when possible or providing a zero-dep fallback.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
const fs = require('node:fs');
|
|
13
|
+
const path = require('node:path');
|
|
14
|
+
|
|
15
|
+
function validateSkill(skillPath) {
|
|
16
|
+
if (!fs.existsSync(skillPath) || !fs.statSync(skillPath).isDirectory()) {
|
|
17
|
+
return { valid: false, message: `Path is not a directory: ${skillPath}` };
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const skillMdPath = path.join(skillPath, 'SKILL.md');
|
|
21
|
+
if (!fs.existsSync(skillMdPath)) {
|
|
22
|
+
return { valid: false, message: 'SKILL.md not found' };
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const content = fs.readFileSync(skillMdPath, 'utf8');
|
|
26
|
+
if (!content.startsWith('---')) {
|
|
27
|
+
return { valid: false, message: 'No YAML frontmatter found' };
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const parts = content.split('---');
|
|
31
|
+
if (parts.length < 3) {
|
|
32
|
+
return { valid: false, message: 'Invalid frontmatter format' };
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const frontmatterText = parts[1];
|
|
36
|
+
|
|
37
|
+
const nameMatch = frontmatterText.match(/^name:\s*(.+)$/m);
|
|
38
|
+
// Match description: "text" or description: 'text' or description: text
|
|
39
|
+
const descMatch = frontmatterText.match(
|
|
40
|
+
/^description:\s*(?:'([^']*)'|"([^"]*)"|(.+))$/m,
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
if (!nameMatch)
|
|
44
|
+
return { valid: false, message: 'Missing "name" in frontmatter' };
|
|
45
|
+
if (!descMatch)
|
|
46
|
+
return {
|
|
47
|
+
valid: false,
|
|
48
|
+
message: 'Description must be a single-line string: description: ...',
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
const name = nameMatch[1].trim();
|
|
52
|
+
const description = (
|
|
53
|
+
descMatch[1] !== undefined
|
|
54
|
+
? descMatch[1]
|
|
55
|
+
: descMatch[2] !== undefined
|
|
56
|
+
? descMatch[2]
|
|
57
|
+
: descMatch[3] || ''
|
|
58
|
+
).trim();
|
|
59
|
+
|
|
60
|
+
if (description.includes('\n')) {
|
|
61
|
+
return {
|
|
62
|
+
valid: false,
|
|
63
|
+
message: 'Description must be a single line (no newlines)',
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
if (!/^[a-z0-9-]+$/.test(name)) {
|
|
68
|
+
return { valid: false, message: `Name "${name}" should be hyphen-case` };
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
if (description.length > 1024) {
|
|
72
|
+
return { valid: false, message: 'Description is too long (max 1024)' };
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// Check for TODOs
|
|
76
|
+
const files = getAllFiles(skillPath);
|
|
77
|
+
for (const file of files) {
|
|
78
|
+
const fileContent = fs.readFileSync(file, 'utf8');
|
|
79
|
+
if (fileContent.includes('TODO:')) {
|
|
80
|
+
return {
|
|
81
|
+
valid: true,
|
|
82
|
+
message: 'Skill has unresolved TODOs',
|
|
83
|
+
warning: `Found unresolved TODO in ${path.relative(skillPath, file)}`,
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
return { valid: true, message: 'Skill is valid!' };
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function getAllFiles(dir, fileList = []) {
|
|
92
|
+
const files = fs.readdirSync(dir);
|
|
93
|
+
files.forEach((file) => {
|
|
94
|
+
const name = path.join(dir, file);
|
|
95
|
+
if (fs.statSync(name).isDirectory()) {
|
|
96
|
+
if (!['node_modules', '.git', '__pycache__'].includes(file)) {
|
|
97
|
+
getAllFiles(name, fileList);
|
|
98
|
+
}
|
|
99
|
+
} else {
|
|
100
|
+
fileList.push(name);
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
return fileList;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
if (require.main === module) {
|
|
107
|
+
const args = process.argv.slice(2);
|
|
108
|
+
if (args.length !== 1) {
|
|
109
|
+
console.log('Usage: node validate_skill.js <skill_directory>');
|
|
110
|
+
process.exit(1);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
const skillDirArg = args[0];
|
|
114
|
+
if (skillDirArg.includes('..')) {
|
|
115
|
+
console.error('❌ Error: Path traversal detected in skill directory path.');
|
|
116
|
+
process.exit(1);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
const result = validateSkill(path.resolve(skillDirArg));
|
|
120
|
+
if (result.warning) {
|
|
121
|
+
console.warn(`⚠️ ${result.warning}`);
|
|
122
|
+
}
|
|
123
|
+
if (result.valid) {
|
|
124
|
+
if (result.checks && result.checks.length > 0) {
|
|
125
|
+
for (const check of result.checks) {
|
|
126
|
+
console.log(`✓ ${check}`);
|
|
127
|
+
}
|
|
128
|
+
} else {
|
|
129
|
+
console.log(`✅ ${result.message}`);
|
|
130
|
+
}
|
|
131
|
+
} else {
|
|
132
|
+
console.error(`❌ ${result.message}`);
|
|
133
|
+
process.exit(1);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
module.exports = { validateSkill };
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# Example Prompts
|
|
2
|
+
|
|
3
|
+
This directory contains example prompts that can be used with the CLI. These prompts are bundled with the CLI package for easy access.
|
|
4
|
+
|
|
5
|
+
## Available Example Prompts
|
|
6
|
+
|
|
7
|
+
- `git-commit` - Review Git staged changes, generate commit message and commit
|
|
8
|
+
- `analyze` - Analyze an open/complex topic across a very large codebase
|
|
9
|
+
- `explain-code` - Analyze and explain code functionality in detail
|
|
10
|
+
|
|
11
|
+
## Using Example Prompts
|
|
12
|
+
|
|
13
|
+
### In Non-Interactive Mode
|
|
14
|
+
|
|
15
|
+
You can use these example prompts directly in non-interactive mode with the `--example-prompt` flag:
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
# Run the git-commit example
|
|
19
|
+
codely --yolo --example-prompt git-commit
|
|
20
|
+
|
|
21
|
+
# List all available example prompts
|
|
22
|
+
codely --list-example-prompts
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
### In Interactive Mode
|
|
26
|
+
|
|
27
|
+
In interactive mode, you can use the `/example-prompt` slash command:
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
# Start interactive mode
|
|
31
|
+
codely
|
|
32
|
+
|
|
33
|
+
# Then use the command:
|
|
34
|
+
/example-prompt git-commit
|
|
35
|
+
|
|
36
|
+
# Or for the explain-code prompt:
|
|
37
|
+
/example-prompt explain-code
|
|
38
|
+
|
|
39
|
+
# Or list available prompts:
|
|
40
|
+
/example-prompt
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Features
|
|
44
|
+
|
|
45
|
+
This functionality allows you to:
|
|
46
|
+
|
|
47
|
+
- Execute pre-defined prompts without needing to type them out
|
|
48
|
+
- Create reusable prompt templates for common tasks
|
|
49
|
+
- Share standardized prompts across your team
|
|
50
|
+
- List all available prompts to see what's available
|
|
51
|
+
|
|
52
|
+
## Notes
|
|
53
|
+
|
|
54
|
+
- The `--example-prompt` flag cannot be used together with `--prompt` or `--prompt-interactive`
|
|
55
|
+
- Example prompts must be TOML files with at least a `prompt` field
|
|
56
|
+
- The `description` field is optional but recommended for better documentation
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
description = "Analyze an open/complex topic across a very large codebase"
|
|
2
|
+
prompt = """
|
|
3
|
+
You are an expert in Unity Game Engine and a large-repo explorer. Your task is to investigate an open/complex topic across a very large Unity/engine-adjacent codebase and produce evidence-backed findings with prioritized recommendations. Provide analysis only; do not modify any code or files.
|
|
4
|
+
|
|
5
|
+
Analysis Topic: {input}
|
|
6
|
+
|
|
7
|
+
Topic-driven goals:
|
|
8
|
+
1. **Topic Framing**: Restate the topic; define scope, assumptions, hypotheses, key questions, and success criteria.
|
|
9
|
+
2. **Relevance Mapping**: Identify likely subsystems, languages, directories, services, data models, build/CI pieces, and runtime contexts that relate to the topic.
|
|
10
|
+
3. **Investigation Plan**: Break work into steps using sequential_think and create a plan with job_create; prefer independent steps in parallel; set an IO/search budget per step.
|
|
11
|
+
4. **Evidence Gathering**: Use semantic search first, then narrow with exact matches; read only focused file ranges; capture citations with file paths and line numbers.
|
|
12
|
+
5. **Synthesis**: Connect evidence to findings; quantify impact and risk; propose concrete changes.
|
|
13
|
+
|
|
14
|
+
Search and tooling rules (MANDATORY):
|
|
15
|
+
- **MUST use sequential_think first** to define scope and create a plan with job_create before any search.
|
|
16
|
+
- **ALWAYS keep searches tightly scoped** to specific directories/files; avoid using project root "./" as the target.
|
|
17
|
+
- Prefer codebase_search for semantic discovery; use grep/glob only for exact symbols/strings within the scoped paths.
|
|
18
|
+
- Use read_file only for specific, bounded ranges; avoid opening entire large files unless necessary.
|
|
19
|
+
- Run independent searches/reads in parallel (limit 3–5 concurrent) to improve throughput.
|
|
20
|
+
- Respect .gitignore; skip vendor, build artifacts, logs, binaries, and large auto-generated files.
|
|
21
|
+
|
|
22
|
+
Operating constraints (MANDATORY):
|
|
23
|
+
- Analysis-only mode: Do not create/edit/delete files, refactor code, or apply patches.
|
|
24
|
+
- Do not run any state-changing commands; propose commands as suggestions without executing them.
|
|
25
|
+
- Avoid large code dumps or sweeping rewrites; use minimal illustrative snippets only when strictly necessary.
|
|
26
|
+
|
|
27
|
+
Output format (ADAPTIVE):
|
|
28
|
+
Always include:
|
|
29
|
+
- **Executive Summary (3–7 bullets)**: Key findings, impact, confidence.
|
|
30
|
+
- **Topic Framing**: Scope, assumptions, hypotheses, key questions, success criteria.
|
|
31
|
+
- **Findings & Evidence**: Evidence-backed observations with citations; note trade-offs and confidence.
|
|
32
|
+
- **Key Examples**: Code Fragments, Functions and Classes.
|
|
33
|
+
- **Appendix**: Citations with file paths and line ranges.
|
|
34
|
+
|
|
35
|
+
Citation requirements:
|
|
36
|
+
- When quoting code, include minimal necessary lines and show file path and line numbers.
|
|
37
|
+
- Keep snippets small; prefer targeted additional reads over large dumps.
|
|
38
|
+
|
|
39
|
+
Notes:
|
|
40
|
+
- If the topic is ambiguous, briefly state assumptions and proceed; do not stall.
|
|
41
|
+
- Optimize for breadth-first discovery first, then go deep where evidence indicates hotspots.
|
|
42
|
+
- Keep explanations concise but precise; avoid generic claims without evidence.
|
|
43
|
+
|
|
44
|
+
**CRITICAL**: You MUST NOT use Grep/Glob tool under project root "./". You MUST use sequential_thining to narrow down the search scope to folder.
|
|
45
|
+
|
|
46
|
+
Focus on providing constructive, actionable feedback suitable for large-scale codebases.
|
|
47
|
+
"""
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
description = "Analyze and explain code functionality in detail"
|
|
2
|
+
prompt = """
|
|
3
|
+
You are an expert software engineer and code analyst. Your task is to analyze and explain the functionality of the provided code in detail. Provide a comprehensive analysis only; do not modify any code or files.
|
|
4
|
+
|
|
5
|
+
Code to analyze: {input}
|
|
6
|
+
|
|
7
|
+
Follow this systematic approach to explain the code:
|
|
8
|
+
|
|
9
|
+
1. **Code Context Analysis**
|
|
10
|
+
- Identify the programming language and framework
|
|
11
|
+
- Understand the broader context and purpose of the code
|
|
12
|
+
- Identify the file location and its role in the project
|
|
13
|
+
- Review related imports, dependencies, and configurations
|
|
14
|
+
|
|
15
|
+
2. **High-Level Overview**
|
|
16
|
+
- Provide a summary of what the code does
|
|
17
|
+
- Explain the main purpose and functionality
|
|
18
|
+
- Identify the problem the code is solving
|
|
19
|
+
- Describe how it fits into the larger system
|
|
20
|
+
|
|
21
|
+
3. **Code Structure Breakdown**
|
|
22
|
+
- Break down the code into logical sections
|
|
23
|
+
- Identify classes, functions, and methods
|
|
24
|
+
- Explain the overall architecture and design patterns
|
|
25
|
+
- Map out data flow and control flow
|
|
26
|
+
|
|
27
|
+
4. **Line-by-Line Analysis**
|
|
28
|
+
- Explain complex or non-obvious lines of code
|
|
29
|
+
- Describe variable declarations and their purposes
|
|
30
|
+
- Explain function calls and their parameters
|
|
31
|
+
- Clarify conditional logic and loops
|
|
32
|
+
|
|
33
|
+
5. **Algorithm and Logic Explanation**
|
|
34
|
+
- Describe the algorithm or approach being used
|
|
35
|
+
- Explain the logic behind complex calculations
|
|
36
|
+
- Break down nested conditions and loops
|
|
37
|
+
- Clarify recursive or asynchronous operations
|
|
38
|
+
|
|
39
|
+
6. **Data Structures and Types**
|
|
40
|
+
- Explain data types and structures being used
|
|
41
|
+
- Describe how data is transformed or processed
|
|
42
|
+
- Explain object relationships and hierarchies
|
|
43
|
+
- Clarify input and output formats
|
|
44
|
+
|
|
45
|
+
7. **Framework and Library Usage**
|
|
46
|
+
- Explain framework-specific patterns and conventions
|
|
47
|
+
- Describe library functions and their purposes
|
|
48
|
+
- Explain API calls and their expected responses
|
|
49
|
+
- Clarify configuration and setup code
|
|
50
|
+
|
|
51
|
+
8. **Error Handling and Edge Cases**
|
|
52
|
+
- Explain error handling mechanisms
|
|
53
|
+
- Describe exception handling and recovery
|
|
54
|
+
- Identify edge cases being handled
|
|
55
|
+
- Explain validation and defensive programming
|
|
56
|
+
|
|
57
|
+
9. **Performance Considerations**
|
|
58
|
+
- Identify performance-critical sections
|
|
59
|
+
- Explain optimization techniques being used
|
|
60
|
+
- Describe complexity and scalability implications
|
|
61
|
+
- Point out potential bottlenecks or inefficiencies
|
|
62
|
+
|
|
63
|
+
10. **Security Implications**
|
|
64
|
+
- Identify security-related code sections
|
|
65
|
+
- Explain authentication and authorization logic
|
|
66
|
+
- Describe input validation and sanitization
|
|
67
|
+
- Point out potential security vulnerabilities
|
|
68
|
+
|
|
69
|
+
11. **Testing and Debugging**
|
|
70
|
+
- Explain how the code can be tested
|
|
71
|
+
- Identify debugging points and logging
|
|
72
|
+
- Describe mock data or test scenarios
|
|
73
|
+
- Explain test helpers and utilities
|
|
74
|
+
|
|
75
|
+
12. **Dependencies and Integrations**
|
|
76
|
+
- Explain external service integrations
|
|
77
|
+
- Describe database operations and queries
|
|
78
|
+
- Explain API interactions and protocols
|
|
79
|
+
- Clarify third-party library usage
|
|
80
|
+
|
|
81
|
+
**Explanation Format Examples:**
|
|
82
|
+
|
|
83
|
+
**For Complex Algorithms:**
|
|
84
|
+
```
|
|
85
|
+
This function implements a depth-first search algorithm:
|
|
86
|
+
|
|
87
|
+
1. Line 1-3: Initialize a stack with the starting node and a visited set
|
|
88
|
+
2. Line 4-8: Main loop - continue until stack is empty
|
|
89
|
+
3. Line 9-11: Pop a node and check if it's the target
|
|
90
|
+
4. Line 12-15: Add unvisited neighbors to the stack
|
|
91
|
+
5. Line 16: Return null if target not found
|
|
92
|
+
|
|
93
|
+
Time Complexity: O(V + E) where V is vertices and E is edges
|
|
94
|
+
Space Complexity: O(V) for the visited set and stack
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
**For API Integration Code:**
|
|
98
|
+
```
|
|
99
|
+
This code handles user authentication with a third-party service:
|
|
100
|
+
|
|
101
|
+
1. Extract credentials from request headers
|
|
102
|
+
2. Validate credential format and required fields
|
|
103
|
+
3. Make API call to authentication service
|
|
104
|
+
4. Handle response and extract user data
|
|
105
|
+
5. Create session token and set cookies
|
|
106
|
+
6. Return user profile or error response
|
|
107
|
+
|
|
108
|
+
Error Handling: Catches network errors, invalid credentials, and service unavailability
|
|
109
|
+
Security: Uses HTTPS, validates inputs, and sanitizes responses
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
**For Database Operations:**
|
|
113
|
+
```
|
|
114
|
+
This function performs a complex database query with joins:
|
|
115
|
+
|
|
116
|
+
1. Build base query with primary table
|
|
117
|
+
2. Add LEFT JOIN for related user data
|
|
118
|
+
3. Apply WHERE conditions for filtering
|
|
119
|
+
4. Add ORDER BY for consistent sorting
|
|
120
|
+
5. Implement pagination with LIMIT/OFFSET
|
|
121
|
+
6. Execute query and handle potential errors
|
|
122
|
+
7. Transform raw results into domain objects
|
|
123
|
+
|
|
124
|
+
Performance Notes: Uses indexes on filtered columns, implements connection pooling
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
13. **Common Patterns and Idioms**
|
|
128
|
+
- Identify language-specific patterns and idioms
|
|
129
|
+
- Explain design patterns being implemented
|
|
130
|
+
- Describe architectural patterns in use
|
|
131
|
+
- Clarify naming conventions and code style
|
|
132
|
+
|
|
133
|
+
14. **Potential Improvements**
|
|
134
|
+
- Suggest code improvements and optimizations
|
|
135
|
+
- Identify possible refactoring opportunities
|
|
136
|
+
- Point out maintainability concerns
|
|
137
|
+
- Recommend best practices and standards
|
|
138
|
+
|
|
139
|
+
15. **Related Code and Context**
|
|
140
|
+
- Reference related functions and classes
|
|
141
|
+
- Explain how this code interacts with other components
|
|
142
|
+
- Describe the calling context and usage patterns
|
|
143
|
+
- Point to relevant documentation and resources
|
|
144
|
+
|
|
145
|
+
16. **Debugging and Troubleshooting**
|
|
146
|
+
- Explain how to debug issues in this code
|
|
147
|
+
- Identify common failure points
|
|
148
|
+
- Describe logging and monitoring approaches
|
|
149
|
+
- Suggest testing strategies
|
|
150
|
+
|
|
151
|
+
**Language-Specific Considerations:**
|
|
152
|
+
|
|
153
|
+
**JavaScript/TypeScript:**
|
|
154
|
+
- Explain async/await and Promise handling
|
|
155
|
+
- Describe closure and scope behavior
|
|
156
|
+
- Clarify this binding and arrow functions
|
|
157
|
+
- Explain event handling and callbacks
|
|
158
|
+
|
|
159
|
+
**Python:**
|
|
160
|
+
- Explain list comprehensions and generators
|
|
161
|
+
- Describe decorator usage and purpose
|
|
162
|
+
- Clarify context managers and with statements
|
|
163
|
+
- Explain class inheritance and method resolution
|
|
164
|
+
|
|
165
|
+
**Java:**
|
|
166
|
+
- Explain generics and type parameters
|
|
167
|
+
- Describe annotation usage and processing
|
|
168
|
+
- Clarify stream operations and lambda expressions
|
|
169
|
+
- Explain exception hierarchy and handling
|
|
170
|
+
|
|
171
|
+
**C#:**
|
|
172
|
+
- Explain LINQ queries and expressions
|
|
173
|
+
- Describe async/await and Task handling
|
|
174
|
+
- Clarify delegate and event usage
|
|
175
|
+
- Explain nullable reference types
|
|
176
|
+
|
|
177
|
+
**Go:**
|
|
178
|
+
- Explain goroutines and channel usage
|
|
179
|
+
- Describe interface implementation
|
|
180
|
+
- Clarify error handling patterns
|
|
181
|
+
- Explain package structure and imports
|
|
182
|
+
|
|
183
|
+
**Rust:**
|
|
184
|
+
- Explain ownership and borrowing
|
|
185
|
+
- Describe lifetime annotations
|
|
186
|
+
- Clarify pattern matching and Option/Result types
|
|
187
|
+
- Explain trait implementations
|
|
188
|
+
|
|
189
|
+
Remember to:
|
|
190
|
+
- Use clear, non-technical language when possible
|
|
191
|
+
- Provide examples and analogies for complex concepts
|
|
192
|
+
- Structure explanations logically from high-level to detailed
|
|
193
|
+
- Include visual diagrams or flowcharts when helpful
|
|
194
|
+
- Tailor the explanation level to the intended audience
|
|
195
|
+
|
|
196
|
+
Operating constraints (MANDATORY):
|
|
197
|
+
- Analysis-only mode: Do not create/edit/delete files, refactor code, or apply patches.
|
|
198
|
+
- Do not run any state-changing commands; propose commands as suggestions without executing them.
|
|
199
|
+
- Avoid large code dumps or sweeping rewrites; use minimal illustrative snippets only when strictly necessary.
|
|
200
|
+
"""
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
description = "Review Git staged changes, generate commit message and commit"
|
|
2
|
+
prompt = """
|
|
3
|
+
You are a professional Git user assistant. Your task is to help users complete the following operations:
|
|
4
|
+
1. Review current Git staged changes
|
|
5
|
+
2. Generate appropriate commit messages based on the changes
|
|
6
|
+
3. Execute git commit command to commit the changes
|
|
7
|
+
|
|
8
|
+
Please follow these steps:
|
|
9
|
+
1. First run `git diff --cached` command to view the staged changes
|
|
10
|
+
2. Analyze these changes to understand the content and purpose of modifications
|
|
11
|
+
3. Generate a clear, concise and conventional commit message based on the changes
|
|
12
|
+
- Must use English and keep commit messages consistency
|
|
13
|
+
- Follow conventional commits specification (use prefixes like feat:, fix:, docs:, style:, refactor:, perf:, test:, chore:, etc.)
|
|
14
|
+
- Structure:
|
|
15
|
+
* First line: concise title with conventional commit prefix. Title length MUST be less than 50
|
|
16
|
+
* Second line: blank line (required)
|
|
17
|
+
* Body paragraph: a descriptive paragraph (within 200 words) explaining the target of the commit - what feature is being added or what problem is being fixed. This should provide context and motivation for the changes.
|
|
18
|
+
* Third line: blank line (required)
|
|
19
|
+
* Bullet points: use bullet points (with '-' prefix) to list main changes
|
|
20
|
+
* Each bullet point should be concise and focused on one specific change
|
|
21
|
+
* Group related changes together logically
|
|
22
|
+
* Keep each bullet point to one line when possible
|
|
23
|
+
- Example format:
|
|
24
|
+
```
|
|
25
|
+
feat: enhance compress command and update system prompt
|
|
26
|
+
|
|
27
|
+
This commit improves the compress command functionality to provide better user experience and feedback. The main goal is to enhance logging capabilities, display detailed compression statistics, and improve test coverage. Additionally, it updates the system prompt to reflect the rebranding of the agent to 'Codely CLI', ensuring consistency across the codebase.
|
|
28
|
+
|
|
29
|
+
- Improve compress command with better logging and user feedback
|
|
30
|
+
- Add detailed compression ratio information and summary display
|
|
31
|
+
- Enhance test coverage with console spies and assertions
|
|
32
|
+
- Update system prompt to rename agent to 'Codely CLI'
|
|
33
|
+
```
|
|
34
|
+
4. Show the generated commit message to the user
|
|
35
|
+
5. IMPORTANT: Execute the commit using `git commit -m "commit_message"` command
|
|
36
|
+
- Must use the ShellTool to execute the git commit command
|
|
37
|
+
- Always use the `-m` flag with the message in double quotes
|
|
38
|
+
- For multiline commit messages, MUST use multiple `-m` flags to specify each line
|
|
39
|
+
- Example: `git commit -m "feat: add feature" -m "This commit adds a new feature to improve..." -m "- Change A" -m "- Change B"`
|
|
40
|
+
- The system will automatically handle any additional metadata
|
|
41
|
+
- If precommit hook failed, we MUST stop commit. We SHOULD NOT fix them.
|
|
42
|
+
6. Report the commit result to the user or report errors and stop
|
|
43
|
+
|
|
44
|
+
Please note:
|
|
45
|
+
- If there are no staged changes, remind the user to first use `git add` to add changes to the staging area
|
|
46
|
+
- Keep interactions friendly and ensure the user understands each step of the operation
|
|
47
|
+
"""
|
|
48
|
+
|