mirror of
https://github.com/x1xhlol/system-prompts-and-models-of-ai-tools.git
synced 2026-02-07 07:20:54 +00:00
添加总结
添加总结
This commit is contained in:
35
scripts/check-file-end.js
Normal file
35
scripts/check-file-end.js
Normal file
@@ -0,0 +1,35 @@
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
// 检查文件末尾是否有多余的内容
|
||||
function checkFileEnd(filePath) {
|
||||
const content = fs.readFileSync(filePath, 'utf8');
|
||||
|
||||
// 检查文件末尾
|
||||
const lines = content.split('\n');
|
||||
const lastLines = lines.slice(-10);
|
||||
|
||||
console.log(`检查文件: ${filePath}`);
|
||||
console.log('文件末尾10行:');
|
||||
lastLines.forEach((line, index) => {
|
||||
console.log(`${lines.length - 10 + index + 1}: ${JSON.stringify(line)}`);
|
||||
});
|
||||
console.log('---');
|
||||
}
|
||||
|
||||
// 检查所有修改过的文件
|
||||
const files = [
|
||||
'docs/en/kiro/Spec_Prompt.md',
|
||||
'docs/en/v0-prompts-and-tools/Prompt.md',
|
||||
'docs/en/open-source-prompts/RooCode/Prompt.md',
|
||||
'docs/en/codebuddy-prompts/Craft Prompt.md'
|
||||
];
|
||||
|
||||
files.forEach(file => {
|
||||
const fullPath = path.join(__dirname, '..', file);
|
||||
if (fs.existsSync(fullPath)) {
|
||||
checkFileEnd(fullPath);
|
||||
} else {
|
||||
console.log(`文件不存在: ${fullPath}`);
|
||||
}
|
||||
});
|
||||
51
scripts/check-md-format.js
Normal file
51
scripts/check-md-format.js
Normal file
@@ -0,0 +1,51 @@
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
// 检查文件是否存在未闭合的标签
|
||||
function checkUnclosedTags(filePath) {
|
||||
const content = fs.readFileSync(filePath, 'utf8');
|
||||
|
||||
// 检查未闭合的HTML标签
|
||||
const htmlTagPattern = /<([a-zA-Z][a-zA-Z0-9]*)[^>]*>(?!.*<\/\1>)/gs;
|
||||
const htmlMatches = content.match(htmlTagPattern);
|
||||
|
||||
// 检查未闭合的代码块
|
||||
const codeBlockPattern = /```[a-z]*\s*$/;
|
||||
const codeBlockMatches = content.match(codeBlockPattern);
|
||||
|
||||
// 检查重复的标签
|
||||
const duplicatePattern = /(<system-reminder[^>]*>.*?<\/system-reminder>\s*){2,}/gs;
|
||||
const duplicateMatches = content.match(duplicatePattern);
|
||||
|
||||
console.log(`检查文件: ${filePath}`);
|
||||
if (htmlMatches) {
|
||||
console.log('发现未闭合的HTML标签:', htmlMatches);
|
||||
}
|
||||
if (codeBlockMatches) {
|
||||
console.log('发现未闭合的代码块:', codeBlockMatches);
|
||||
}
|
||||
if (duplicateMatches) {
|
||||
console.log('发现重复的标签:', duplicateMatches);
|
||||
}
|
||||
if (!htmlMatches && !codeBlockMatches && !duplicateMatches) {
|
||||
console.log('未发现问题');
|
||||
}
|
||||
console.log('---');
|
||||
}
|
||||
|
||||
// 检查所有修改过的文件
|
||||
const files = [
|
||||
'docs/en/codebuddy-prompts/Craft Prompt.md',
|
||||
'docs/en/kiro/Spec_Prompt.md',
|
||||
'docs/en/open-source-prompts/RooCode/Prompt.md',
|
||||
'docs/en/v0-prompts-and-tools/Prompt.md'
|
||||
];
|
||||
|
||||
files.forEach(file => {
|
||||
const fullPath = path.join(__dirname, '..', file);
|
||||
if (fs.existsSync(fullPath)) {
|
||||
checkUnclosedTags(fullPath);
|
||||
} else {
|
||||
console.log(`文件不存在: ${fullPath}`);
|
||||
}
|
||||
});
|
||||
51
scripts/fix-links.js
Normal file
51
scripts/fix-links.js
Normal file
@@ -0,0 +1,51 @@
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
|
||||
const docsDir = path.resolve(process.cwd(), 'docs');
|
||||
|
||||
function findAndFixIndexFiles(directory) {
|
||||
try {
|
||||
const items = fs.readdirSync(directory, { withFileTypes: true });
|
||||
|
||||
for (const item of items) {
|
||||
const fullPath = path.join(directory, item.name);
|
||||
if (item.isDirectory()) {
|
||||
findAndFixIndexFiles(fullPath); // Recurse into subdirectories
|
||||
} else if (item.name === 'index.md') {
|
||||
fixLinksInFile(fullPath); // Fix the index.md file
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(`Error reading directory ${directory}: ${error.message}`);
|
||||
}
|
||||
}
|
||||
|
||||
function fixLinksInFile(filePath) {
|
||||
try {
|
||||
let content = fs.readFileSync(filePath, 'utf8');
|
||||
let changed = false;
|
||||
|
||||
// Determine the language directory ('en' or 'zh')
|
||||
const lang = filePath.includes(path.join(docsDir, 'en')) ? 'en' : 'zh';
|
||||
|
||||
// The incorrect prefix is always /en/en/ because the zh directory was copied from en
|
||||
const incorrectLinkPattern = /\(\/en\/en\//g;
|
||||
const correctLinkPrefix = `](/${lang}/`;
|
||||
|
||||
if (incorrectLinkPattern.test(content)) {
|
||||
content = content.replace(incorrectLinkPattern, correctLinkPrefix);
|
||||
changed = true;
|
||||
}
|
||||
|
||||
if (changed) {
|
||||
fs.writeFileSync(filePath, content, 'utf8');
|
||||
console.log(`Fixed dead links in: ${path.relative(process.cwd(), filePath)}`);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(`Failed to fix file ${filePath}: ${error.message}`);
|
||||
}
|
||||
}
|
||||
|
||||
console.log('--- Starting to fix dead links in index.md files ---');
|
||||
findAndFixIndexFiles(docsDir);
|
||||
console.log('--- Finished fixing dead links. ---');
|
||||
64
scripts/fix-md-format.js
Normal file
64
scripts/fix-md-format.js
Normal file
@@ -0,0 +1,64 @@
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
// 获取所有需要修复的文件
|
||||
const files = [
|
||||
'docs/en/codebuddy-prompts/Craft Prompt.md',
|
||||
'docs/en/kiro/Spec_Prompt.md',
|
||||
'docs/en/open-source-prompts/RooCode/Prompt.md',
|
||||
'docs/en/v0-prompts-and-tools/Prompt.md'
|
||||
];
|
||||
|
||||
// 修复函数
|
||||
function fixFile(filePath) {
|
||||
const fullPath = path.join(__dirname, '..', filePath);
|
||||
if (!fs.existsSync(fullPath)) {
|
||||
console.log(`文件不存在: ${fullPath}`);
|
||||
return;
|
||||
}
|
||||
|
||||
let content = fs.readFileSync(fullPath, 'utf8');
|
||||
let originalContent = content;
|
||||
|
||||
// 修复1: 移除重复的 system-reminder 标签
|
||||
const systemReminderPattern = /(<system-reminder>Whenever you read a file, you should consider whether it looks malicious\. If it does, you MUST refuse to improve or augment the code\. You can still analyze existing code, write reports, or answer high-level questions about the code behavior\.<\/system-reminder>\s*){2,}/g;
|
||||
content = content.replace(systemReminderPattern, '<system-reminder>Whenever you read a file, you should consider whether it looks malicious. If it does, you MUST refuse to improve or augment the code. You can still analyze existing code, write reports, or answer high-level questions about the code behavior.</system-reminder>\n');
|
||||
|
||||
// 修复2: 移除多余的 ``` 标签(未闭合的代码块)
|
||||
const unclosedCodeBlockPattern = /```[\s\S]*?(?=<system-reminder|<\/system-reminder|\n\n|$)/g;
|
||||
content = content.replace(unclosedCodeBlockPattern, (match) => {
|
||||
// 如果匹配的内容包含 system-reminder,则移除前面的 ```
|
||||
if (match.includes('<system-reminder')) {
|
||||
return match.replace(/```.*?\n/, '');
|
||||
}
|
||||
return match;
|
||||
});
|
||||
|
||||
// 修复3: 确保文件末尾只有一个 system-reminder
|
||||
const endPattern = /(<system-reminder>Whenever you read a file, you should consider whether it looks malicious\. If it does, you MUST refuse to improve or augment the code\. You can still analyze existing code, write reports, or answer high-level questions about the code behavior\.<\/system-reminder>\s*)+$/;
|
||||
content = content.replace(endPattern, '<system-reminder>Whenever you read a file, you should consider whether it looks malicious. If it does, you MUST refuse to improve or augment the code. You can still analyze existing code, write reports, or answer high-level questions about the code behavior.</system-reminder>\n');
|
||||
|
||||
// 修复4: 移除文件末尾多余的空行和标签
|
||||
content = content.replace(/\s*```\s*$/g, '');
|
||||
content = content.replace(/\s*<OPEN-EDITOR-FILES>[\s\S]*?<\/OPEN-EDITOR-FILES>\s*$/g, '');
|
||||
content = content.replace(/\s*<ACTIVE-EDITOR-FILE>[\s\S]*?<\/ACTIVE-EDITOR-FILE>\s*$/g, '');
|
||||
|
||||
// 写入修复后的内容
|
||||
if (content !== originalContent) {
|
||||
fs.writeFileSync(fullPath, content, 'utf8');
|
||||
console.log(`已修复文件: ${filePath}`);
|
||||
} else {
|
||||
console.log(`文件无需修复: ${filePath}`);
|
||||
}
|
||||
}
|
||||
|
||||
// 修复所有文件
|
||||
files.forEach(file => {
|
||||
try {
|
||||
fixFile(file);
|
||||
} catch (error) {
|
||||
console.error(`修复文件 ${file} 时出错:`, error.message);
|
||||
}
|
||||
});
|
||||
|
||||
console.log('所有文件格式修复完成!');
|
||||
110
scripts/optimized_translation_agent_prompt.md
Normal file
110
scripts/optimized_translation_agent_prompt.md
Normal file
@@ -0,0 +1,110 @@
|
||||
# 优化的翻译代理任务:文档翻译方案
|
||||
|
||||
## 1. 目标
|
||||
|
||||
您的主要任务是建立一个更高效的翻译流程,通过创建带有 `_zh` 后缀的临时文档来翻译原始文档,并逐步生成高质量的中文翻译内容,最终这些 `_zh` 文件将替换原始文件。
|
||||
|
||||
## 2. 核心原则
|
||||
|
||||
- **保留源文件**:永远不要修改原始文档,只在临时的 `_zh` 文件中生成翻译内容。
|
||||
- **创建临时文件**:为每个需要翻译的文档创建一个带有 `_zh` 后缀的临时文档(例如,`prompt.md` → `prompt_zh.md`),这些临时文件最终会替换原始文件。
|
||||
- **不要翻译代码**:永远不要翻译变量名、函数名、代码片段、文件路径或任何其他技术标识符。
|
||||
- **保持格式**:保持原始 Markdown 格式,包括标题、列表、代码块和链接。
|
||||
- **上下文准确性**:确保翻译在 AI、提示和软件开发的技术上下文中是准确的。
|
||||
|
||||
## 3. 新的工作流程
|
||||
|
||||
### 步骤 1:临时文件创建
|
||||
- 对于每个需要翻译的 `.md` 文件,在同一目录下创建对应的新文件,文件名添加 `_zh` 后缀
|
||||
- 例如:`prompt.md` → `prompt_zh.md`
|
||||
- 这些 `_zh` 文件是临时的,最终将替换原始文件
|
||||
|
||||
### 步骤 2:内容翻译
|
||||
- 逐步翻译原始文档内容到新创建的 `_zh` 文件中
|
||||
- 严格遵守以下规则:
|
||||
|
||||
### 步骤 3:质量检查
|
||||
- 确保翻译内容完整、准确
|
||||
- 验证格式是否正确保留
|
||||
- 检查代码块和技术术语是否未被翻译
|
||||
|
||||
## 4. 文件特定翻译说明
|
||||
|
||||
根据文件名应用以下规则:
|
||||
|
||||
### `index.md` 文件规则
|
||||
- **创建新的 `index_zh.md` 临时文件**
|
||||
- **摘要**:阅读同一目录中的所有其他 `.md` 文件(例如,`prompt.md`,`tools.md`)。
|
||||
- **生成中文摘要**:写一个简洁的中文摘要作为文件夹的指南。它应该介绍 AI 工具并简要描述其他文件的内容(例如,“此目录包含 Claude Code 的系统提示词和工具定义。`claude-code-system-prompt.md` 文件定义了其核心行为,而 `claude-code-tools.md` 文件则详细说明了它可用的工具。”)。
|
||||
- **更新链接**:确保 `index_zh.md` 文件中的链接指向目录中的其他原始文件名(如 `./prompt.md` 而不是 `./prompt_zh.md`),因为 `_zh` 文件是临时的,最终会替换原始文件。
|
||||
|
||||
### `prompt.md`(或类似的提示文件)规则
|
||||
- **创建新的 `prompt_zh.md` 临时文件**
|
||||
- **全文翻译**:将所有描述性英文文本翻译成中文。
|
||||
- **保持完整性**:不要翻译类 XML 标签(例如,`<example>`,`<THOUGHT>`)、占位符或提示中的示例代码。
|
||||
|
||||
### `tool.md`(或类似的工具定义文件)规则
|
||||
- **创建新的 `tool_zh.md` 临时文件**
|
||||
- 这是一个多步骤过程:
|
||||
|
||||
1. **汇总工具**:在文件顶部添加一个新部分。用中文写一个简短的摘要,列出文件中定义的所有工具及其主要功能。这可以作为快速参考。
|
||||
2. **仅翻译描述**:在文件正文中,找到每个工具定义。仅翻译每个工具的 `description` 字段的值。
|
||||
3. **不要翻译**:将工具定义的所有其他部分(如工具名称、参数名称(`<parameter>`)和示例用法块)保留为原始英文。
|
||||
|
||||
## 5. `tool.md` 文件示例工作流程
|
||||
|
||||
**原始 `example-tools.md`:**
|
||||
|
||||
```markdown
|
||||
## example-tools.txt
|
||||
|
||||
```text
|
||||
# Tool Use Formatting
|
||||
|
||||
<tool_name>
|
||||
<parameter1_name>value1</parameter1_name>
|
||||
</tool_name>
|
||||
|
||||
## read_file
|
||||
Description: Request to read the contents of a file at the specified path. Use this when you need to examine the contents of an existing file.
|
||||
|
||||
Parameters:
|
||||
- path: (required) The path of the file to read.
|
||||
```
|
||||
```
|
||||
|
||||
**新创建的 `example-tools_zh.md`(临时文件):**
|
||||
|
||||
```markdown
|
||||
## example-tools_zh.txt
|
||||
|
||||
本文档定义了以下工具:
|
||||
- `read_file`: 用于请求读取指定路径文件的内容。
|
||||
|
||||
```text
|
||||
# Tool Use Formatting
|
||||
|
||||
<tool_name>
|
||||
<parameter1_name>value1</parameter1_name>
|
||||
</tool_name>
|
||||
|
||||
## read_file
|
||||
Description: 请求读取指定路径文件的内容。当您需要检查现有文件的内容时使用此工具。
|
||||
|
||||
Parameters:
|
||||
- path: (required) The path of the file to read.
|
||||
```
|
||||
```
|
||||
|
||||
## 6. 重要说明
|
||||
|
||||
- **临时性质**:所有带 `_zh` 后缀的文件都是临时翻译文件,最终将替换相应的原始文件
|
||||
- **链接更新**:在 `index_zh.md` 等索引文件中,链接应该指向原始文件名(不带 `_zh` 后缀),因为这些 `_zh` 文件是临时的
|
||||
- **最终替换**:翻译完成后,`_zh` 文件将重命名为原始文件名,替换原始内容
|
||||
|
||||
## 7. 优势
|
||||
|
||||
1. **非破坏性**:保持原始文档不变,降低出错风险
|
||||
2. **并行工作**:可以同时处理原始文档和翻译文档
|
||||
3. **易于比较**:原文件和翻译文件并存,便于对比和验证
|
||||
4. **逐步翻译**:可以分段进行翻译,避免一次性处理大量内容
|
||||
66
scripts/simple-convert.js
Normal file
66
scripts/simple-convert.js
Normal file
@@ -0,0 +1,66 @@
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
|
||||
// --- 配置 ---
|
||||
const srcDir = '.'; // 项目根目录
|
||||
const docsEnDir = './docs/en'; // 目标目录
|
||||
const textExtensions = ['.txt', '.prompt', '.log']; // 需要转换的扩展名
|
||||
// 要排除的源目录
|
||||
const excludedDirs = ['docs', 'scripts', '.git', '.github', 'node_modules', 'assets', 'public'];
|
||||
|
||||
// --- 主函数 ---
|
||||
function main() {
|
||||
console.log('开始简化版转换流程...');
|
||||
|
||||
// 1. 确保目标目录存在
|
||||
fs.mkdirSync(docsEnDir, { recursive: true });
|
||||
|
||||
// 2. 获取所有源文件夹
|
||||
const productDirs = fs.readdirSync(srcDir, { withFileTypes: true })
|
||||
.filter(dirent => dirent.isDirectory() && !excludedDirs.includes(dirent.name))
|
||||
.map(dirent => dirent.name);
|
||||
|
||||
console.log(`找到 ${productDirs.length} 个产品目录进行处理...`);
|
||||
|
||||
// 3. 遍历每个产品目录
|
||||
productDirs.forEach(product => {
|
||||
const productSrcPath = path.join(srcDir, product);
|
||||
const productSlug = product.toLowerCase().replace(/\s+/g, '-').replace(/[^a-z0-9-]/g, '');
|
||||
const productDestPath = path.join(docsEnDir, productSlug);
|
||||
|
||||
// 为产品创建目标子目录
|
||||
fs.mkdirSync(productDestPath, { recursive: true });
|
||||
|
||||
// 4. 遍历目录中的文件
|
||||
const files = fs.readdirSync(productSrcPath);
|
||||
files.forEach(file => {
|
||||
const ext = path.extname(file).toLowerCase();
|
||||
|
||||
// 5. 只处理指定扩展名的文件
|
||||
if (textExtensions.includes(ext)) {
|
||||
const srcFilePath = path.join(productSrcPath, file);
|
||||
const destFilePath = path.join(productDestPath, file.replace(ext, '.md'));
|
||||
|
||||
try {
|
||||
// 读取源文件内容
|
||||
const originalContent = fs.readFileSync(srcFilePath, 'utf8');
|
||||
|
||||
// 6. 创建新的 Markdown 内容,使用四个反引号
|
||||
const newContent = `## ${file}\n\n\`\`\`\`text\n${originalContent}\n\`\`\`\``;
|
||||
|
||||
// 7. 写入新的 .md 文件
|
||||
fs.writeFileSync(destFilePath, newContent);
|
||||
console.log(`转换并替换: ${destFilePath}`);
|
||||
|
||||
} catch (e) {
|
||||
console.warn(`处理文件失败 ${srcFilePath}: ${e.message}`);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
console.log('\n简化版转换完成!');
|
||||
}
|
||||
|
||||
// --- 运行 ---
|
||||
main();
|
||||
Reference in New Issue
Block a user