JiuwenSwarm is an intelligent AI Agent built on openJiuwen. It extends the powerful capabilities of large language models directly to your fingertips through various communication apps you use daily.
Python
refactor(tui): remove Chinese prompt template from /init command
ldstyle8dd8c73d64e7a
diff --git a/jiuwenswarm/channels/tui/frontend/src/core/commands/builtins/init.prompts.ts b/jiuwenswarm/channels/tui/frontend/src/core/commands/builtins/init.prompts.tsindex 529631b675..fc659b5fa0 100644--- a/jiuwenswarm/channels/tui/frontend/src/core/commands/builtins/init.prompts.ts+++ b/jiuwenswarm/channels/tui/frontend/src/core/commands/builtins/init.prompts.ts@@ -16,7 +16,6 @@ export interface ExistingFiles {export interface BuildInitPromptArgs {rootDir: string;scopeKey: ScopeKey;- language: "zh" | "en";existing: ExistingFiles;}@@ -36,7 +35,7 @@ export function resolveLanguage(_ctx: CommandContext): "zh" | "en" {// ---------------------------------------------------------------------------export function buildInitPrompt(args: BuildInitPromptArgs): string {- return args.language === "zh" ? buildInitPromptZh(args) : buildInitPromptEn(args);+ return buildInitPromptEn(args);}// ---------------------------------------------------------------------------@@ -212,177 +211,6 @@ Then suggest optimizations as a short checklist, only those relevant to this rep`;}-// ----------------------------------------------------------------------------// Chinese-// -----------------------------------------------------------------------------function buildInitPromptZh({ rootDir, scopeKey, existing }: BuildInitPromptArgs): string {- const scopeLine = SCOPE_DESCRIPTION_ZH[scopeKey];- return `为本仓库生成一份最小可用的 JIUWENSWARM.md(团队共享)与可选的 JIUWENSWARM.local.md(个人私有)。-这些文件会被 ProjectMemoryRail 自动注入到每一轮 coding 模式会话的 system prompt,因此必须**精简** —— 只写"不写就会出错"的信息。--## 关键约束(必读,不可违反)--1. **所有文件操作必须使用绝对路径,根为:\`${rootDir}\`**- 永远不要用相对路径。写入或编辑时总是构造 \`${rootDir}/<文件名>\`。-2. **禁止使用 \`coding_memory_read\` / \`coding_memory_write\` / \`coding_memory_edit\` 工具。** 那是会话级自动记忆,和 /init 是两套系统。/init 只通过文件写入工具产出静态项目文档。-3. **工作区根目录现有文件(已预探测)**:- - JIUWENSWARM.md:${yesNoZh(existing.jiuwenswarmMd)} ${existing.jiuwenswarmMd ? "—— 必须先读取、生成 diff,然后用 \`ask_user\` 的 \`questions\` 参数让用户选择。示例:\`ask_user(query='更新 JIUWENSWARM.md?', questions=[{question: 'JIUWENSWARM.md 已存在,你想怎么处理?', header: '更新', options: [{label: '应用更新', description: '把提议的变更合并到现有文件'}, {label: '跳过(保留当前)', description: '保持文件不变,继续后续步骤'}], multi_select: false}])\`。若用户选「应用更新」,用 Edit 执行 diff;若选「跳过」,保持文件不变继续。严禁静默覆盖。" : ""}- - JIUWENSWARM.local.md:${yesNoZh(existing.jiuwenswarmLocalMd)} ${existing.jiuwenswarmLocalMd ? "— 只能通过 Edit 追加,不要覆盖。" : ""}- - 遗留参考文件(不要删改,可用 markdown 链接引用):CLAUDE.md=${yesNoZh(existing.claudeMd)}, CLAUDE.local.md=${yesNoZh(existing.claudeLocalMd)}, AGENTS.md=${yesNoZh(existing.agentsMd)}, OPENJIUWEN.md=${yesNoZh(existing.openjiuwenMd)}, .cursorrules=${yesNoZh(existing.cursorRules)}, .github/copilot-instructions.md=${yesNoZh(existing.copilotInstructions)}-4. **子代理 bash 命令必须加前缀**:\`cd ${rootDir} && ...\` 或用 \`git -C ${rootDir}\`,因为子代理的 CWD 不保证等于 \`${rootDir}\`。-5. **只要可用,始终优先使用 \`task_tool\` 且 \`subagent_type: "explore_agent"\`。** 若本轮工具列表里没有 \`task_tool\`,就静默降级为用 \`glob\` / \`grep\` / \`read_file\` / \`bash\` 自行探索。-6. **默认只发起一次 \`task_tool\` / \`explore_agent\` 调用。** 若仓库明显较大、为 monorepo,或单次探索信息不足,可按需拆分多个 explore 子代理;只有在确有收益时才并发,避免重复扫描与结果合并噪音。--## 步骤 1:范围(已确定)--用户选择:**${scopeKey}** — ${scopeLine}--## 步骤 2:探索代码库--首选:调用 \`task_tool\`,参数:-\`\`\`-subagent_type: "explore_agent"-task_description: |- 彻底探索仓库 ${rootDir},请求 "very thorough" 级别。- 若存在请读取(用绝对路径):- - 清单:package.json, Cargo.toml, pyproject.toml, go.mod, pom.xml, build.gradle*, setup.py- - 文档:README.*, CONTRIBUTING.*, ARCHITECTURE.*, docs/- - 构建/CI:Makefile, justfile, .github/workflows/*, .gitlab-ci.yml, azure-pipelines.yml- - AI 配置:JIUWENSWARM.md, CLAUDE.md, AGENTS.md, OPENJIUWEN.md,- .jiuwen/rules/*, .claude/rules/*, .cursor/rules/*,- .cursorrules, .github/copilot-instructions.md,- .windsurfrules, .clinerules, .mcp.json- - 配置:.jiuwen/settings*.json(只读,不要重写)- 简洁地汇报以下内容:- - 构建/测试/lint/format 命令(特别是非标准的)- - 主要语言、框架、包管理器- - 项目结构(monorepo / 多模块 / 单包)- - 与语言默认不同的代码风格规则- - 不易察觉的坑、必需环境变量、工作流习惯- - 分支 / PR / commit message 约定- - 执行 \`git -C ${rootDir} worktree list\`,若有多 worktree 请说明- 对于从代码无法推断的问题,记录下来作为后续的访谈问题。-\`\`\`--无 task_tool 时的兜底:用 \`glob\` + \`read_file\` 自己做同样的事,先看清单和 README,再看 Makefile / CI 配置。--## 步骤 3:补齐信息 + 生成提案--收集代码无法回答的问题。用 \`ask_user\` 工具的 \`questions\` 参数提供可选项:--\`\`\`-ask_user(- query="简要说明你在问什么",- questions=[- {- question: "完整的问题文本",- header: "短标签",- options: [- {label: "选项 A", description: "选项 A 的含义"},- {label: "选项 B", description: "选项 B 的含义"},- ],- multi_select: false,- }- ]-)-\`\`\`--根据问题性质选择选项式提问或直接输入式提问;用户始终可以选择「其他」进行自定义输入。--对 \`project\` / \`both\` 范围:询问团队实践 —- 非显而易见的命令、分支 / PR 约定、环境初始化、测试习惯、常见坑位。- README 或清单里已经写清楚的就别问。**不要**给任何选项标记"推荐" —— 这是团队实际做法,不是建议。--对 \`personal\` / \`both\` 范围:询问用户 —- 角色、对本仓库的熟悉度、沙箱 URL / 账号、沟通偏好、本机工具链特殊设置。--**合成提案**:把步骤 2 的发现和步骤 3 的回答整合。当前方案不支持 Skills 和 Hooks,所有条目一律归为 JIUWENSWARM.md(团队)或 JIUWENSWARM.local.md(个人)的记录项。用纯文本列表呈现,按目标文件分组。请求用户确认后再写文件。--**构造偏好队列**:-\`[{type: "note", target: "JIUWENSWARM.md" | "JIUWENSWARM.local.md", content: "..."}]\`-后续写文件步骤会消费此队列。--## 步骤 4:写 JIUWENSWARM.md(当范围是 project 或 both)--目标:\`${rootDir}/JIUWENSWARM.md\`--${existing.jiuwenswarmMd ? "文件已存在 —— 先读取,生成合并 diff,用 \`ask_user\` 的 \`questions\` 参数获取用户确认(选项:「应用更新」 / 「跳过(保留当前)」),确认后用 Edit 应用。绝不要用 Write 静默覆盖。" : "文件不存在 —— 用 Write 创建。"}--消费队列中 \`target == "JIUWENSWARM.md"\` 的条目。--**内容筛选测试**:对每行候选,自问"去掉这行会不会让助手犯错?" 不会就删掉。--**应包含**:-- 助手猜不出的构建 / 测试 / lint / format 命令-- 偏离语言默认的代码风格规则-- 测试习惯(例如"用 \`pytest -k 'x'\` 跑单测")-- 仓库规矩(分支命名、PR 约定、commit message 风格)-- 必需环境变量、初始化步骤-- 从已有的 AI 工具配置文件中提取重要内容(CLAUDE.md、AGENTS.md、.cursorrules、.github/copilot-instructions.md、.windsurfrules、.clinerules 等) —— 提取关键规则,而非只留链接引用-- 不易察觉的坑、值得知道的架构决策-- 简短的 **See also** 段落。短引用可用普通 markdown 链接;若希望保留长文档作为权威来源,可用 \`@path/to/file\` 引用:- ${legacyIncludesZh(existing)}--**不应包含**:-- 逐文件 / 逐组件的结构清单(助手可以自己发现)-- 语言的标准约定(助手已经知道)-- 通用 AI 礼仪 / prompt 工程建议-- 长篇参考材料 —— 用链接引用而非内联-- 清单中显而易见的命令(比如"npm test")-- 频繁变化的信息 —— 用 \`@path/to/doc.md\` 引用源头,确保每次加载的都是最新版本-- 通用建议如"写干净代码"或"处理好错误" —— 只写具体、可执行的规则--**具体性原则**:"TypeScript 用 2 空格缩进"比"代码要格式规范"好。--**禁止虚构段落**:不要自创"常见开发任务"或"开发技巧"之类的标题 —— 只收录你从文件中实际读到的信息。--**文件开头**统一加:-\`\`\`-# JIUWENSWARM.md--This file provides guidance to JiuwenSwarm (and any compatible AI coding assistant) when working with code in this repository.-\`\`\`--对 monorepo:说明支持子目录放独立的 \`JIUWENSWARM.md\` —— ProjectMemoryRail 从 cwd 向上遍历加载。--对团队规模较大的项目:建议把按主题拆分的规则放到 \`.jiuwen/rules/<topic>.md\` —— 当前运行时会自动加载这些规则,并支持用 \`paths:\` frontmatter 按当前工作目录 / workspace 所在子树限定作用域。--## 步骤 5:写 JIUWENSWARM.local.md(当范围是 personal 或 both)--目标:\`${rootDir}/JIUWENSWARM.local.md\`--${existing.jiuwenswarmLocalMd ? "文件已存在 —— 通过 Edit 追加内容,不要覆盖。" : "文件不存在 —— 用 Write 创建。"}--消费队列中 \`target == "JIUWENSWARM.local.md"\` 的条目。--包含:用户的角色、对仓库的熟悉程度、个人 URL / 账号、沟通偏好、本机特有工具链配置。--**写完后幂等更新** \`${rootDir}/.gitignore\`:- 1. 若 \`.gitignore\` 存在先读取(用绝对路径);- 2. 检查下面两行是否已存在(整行精确匹配);- 3. 仅追加缺失的:- - \`JIUWENSWARM.local.md\`- - \`.jiuwen/settings.local.json\`- 4. 若 \`.gitignore\` 不存在,就创建并写入这两行。--## 步骤 6:总结--简要回顾写了哪些文件,每个文件里 3-5 条最重要的内容。--提醒用户:-- 这些文件会被 ProjectMemoryRail 自动加载到每一轮 coding 会话。-- 是起点 —— 可以手工编辑,下一轮就生效。-- 随时可以再跑 \`/init\` 基于新发现重新生成。--然后给一个短清单(只写与当前仓库相关的):-- 若测试缺失 / 稀疏:建议引入测试框架,助手才能自证修改。-- 若没有 formatter / lint 配置:建议添加,并说明一行理由。-- 若步骤 2 发现了 JIUWENSWARM.md 中未引用的遗留 AI 配置文件(CLAUDE.md、AGENTS.md 等):建议以普通链接方式提示用户后续合并。-- **总是包含**:"检查完后运行 \`/compact\` 可把这段初始化会话从历史中精简掉。"-`;-}-// ---------------------------------------------------------------------------// Helpers// ---------------------------------------------------------------------------@@ -393,20 +221,10 @@ const SCOPE_DESCRIPTION_EN: Record<ScopeKey, string> = {both: "write both files (run Step 4 and Step 5).",};-const SCOPE_DESCRIPTION_ZH: Record<ScopeKey, string> = {- project: "只写 JIUWENSWARM.md(执行步骤 4)。",- personal: "只写 JIUWENSWARM.local.md(执行步骤 5)。",- both: "两份都写(步骤 4 和步骤 5 都执行)。",-};-function yesNo(b: boolean): string {return b ? "EXISTS" : "absent";}-function yesNoZh(b: boolean): string {- return b ? "存在" : "不存在";-}-function legacyIncludesEn(existing: ExistingFiles): string {// 当前方案:不用 @path 展开;写普通 markdown 链接const parts: string[] = [];@@ -422,18 +240,3 @@ function legacyIncludesEn(existing: ExistingFiles): string {? `"See also: ${parts.join(", ")}."`: `"(No legacy AI config files detected.)"`;}--function legacyIncludesZh(existing: ExistingFiles): string {- const parts: string[] = [];- if (existing.claudeMd) parts.push("[CLAUDE.md](./CLAUDE.md)");- if (existing.agentsMd) parts.push("[AGENTS.md](./AGENTS.md)");- if (existing.openjiuwenMd) parts.push("[OPENJIUWEN.md](./OPENJIUWEN.md)");- if (existing.cursorRules) parts.push("[.cursorrules](./.cursorrules)");- if (existing.copilotInstructions)- parts.push(- "[.github/copilot-instructions.md](./.github/copilot-instructions.md)",- );- return parts.length- ? `"另见:${parts.join("、")}。"`- : `"(未探测到遗留 AI 配置文件。)"`;-}diff --git a/jiuwenswarm/channels/tui/frontend/src/core/commands/builtins/init.ts b/jiuwenswarm/channels/tui/frontend/src/core/commands/builtins/init.tsindex 477c84b769..aaee9a87ac 100644--- a/jiuwenswarm/channels/tui/frontend/src/core/commands/builtins/init.ts+++ b/jiuwenswarm/channels/tui/frontend/src/core/commands/builtins/init.ts@@ -190,7 +190,7 @@ export function createInitCommand(): SlashCommand {),};- const prompt = buildInitPrompt({ rootDir, scopeKey, language, existing });+ const prompt = buildInitPrompt({ rootDir, scopeKey, existing });// ---- Send ----// The earlier guard 2 already called setMode("code.normal") if needed.