Skip to content

armgit / cindy

Public Imported from GitHub
0

Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。

feat(scheduler): 内置自动化模板换血并接入四语言 i18n (#316)

Chris Zhangfee8fdc8d6c4
diff --git a/apps/desktop/src/renderer/__tests__/schedulerTemplateEntry.test.ts b/apps/desktop/src/renderer/__tests__/schedulerTemplateEntry.test.ts
index d7fc800151..d2181ffcd8 100644
--- a/apps/desktop/src/renderer/__tests__/schedulerTemplateEntry.test.ts
+++ b/apps/desktop/src/renderer/__tests__/schedulerTemplateEntry.test.ts
@@ -14,7 +14,8 @@ const template: ScheduleTemplate = {
id: 'review-template',
name: 'Review Template',
description: 'Open a prefilled automation form',
- category: 'code-quality',
+ // 必须是 TEMPLATE_CATEGORIES 里存在的分类,否则 TemplateGallery 不渲染该卡片。
+ category: 'dev-automation',
source: 'builtin',
prompt: 'Check open pull requests',
cronExpr: '30 10 * * 1',
@@ -32,6 +33,9 @@ vi.mock('react-i18next', () => ({
useTranslation: () => ({
t: (key: string, values?: Record<string, unknown>) =>
values?.count != null ? `${key}:${String(values.count)}` : key,
+ // useTemplates 走 i18n.getResource 做模板本地化;fixture id 不在 locale 里,
+ // 返回 undefined 让模板原文直通。
+ i18n: { language: 'en', getResource: () => undefined },
}),
}));
diff --git a/apps/desktop/src/renderer/__tests__/schedulerTemplateLocalization.test.ts b/apps/desktop/src/renderer/__tests__/schedulerTemplateLocalization.test.ts
new file mode 100644
index 0000000000..527f0a1e3a
--- /dev/null
+++ b/apps/desktop/src/renderer/__tests__/schedulerTemplateLocalization.test.ts
@@ -0,0 +1,121 @@
+import { describe, expect, it } from 'vitest';
+import { BUILTIN_TEMPLATES, TEMPLATE_CATEGORIES } from '@cindy/maker-scheduler/templates';
+
+import enCommon from '../i18n/locales/en/common.json';
+import zhCNCommon from '../i18n/locales/zh-CN/common.json';
+import jaCommon from '../i18n/locales/ja/common.json';
+import koCommon from '../i18n/locales/ko/common.json';
+
+/**
+ * 内置模板多语言同步测试。
+ *
+ * 包内 builtin-templates.ts 的中文是唯一正本,renderer 用
+ * scheduler.builtinTemplates 覆盖展示文案。这组断言锁两件事:
+ * 1. 四语言块结构完整——每个模板/分类/参数在每种语言都有非空文案;
+ * 2. zh-CN 块与包正本逐字一致——防止"改包不改 JSON"或反向的静默漂移。
+ */
+
+interface ItemL10n {
+ name: string;
+ description: string;
+ prompt: string;
+ params?: Record<string, { label: string; placeholder?: string }>;
+}
+
+interface BuiltinTemplatesBlock {
+ categories: Record<string, string>;
+ items: Record<string, ItemL10n>;
+}
+
+interface SchedulerL10n {
+ template: { capability: Record<string, string> };
+ builtinTemplates: BuiltinTemplatesBlock;
+}
+
+const LOCALES: Record<string, SchedulerL10n> = {
+ 'zh-CN': (zhCNCommon as { scheduler: SchedulerL10n }).scheduler,
+ en: (enCommon as { scheduler: SchedulerL10n }).scheduler,
+ ja: (jaCommon as { scheduler: SchedulerL10n }).scheduler,
+ ko: (koCommon as { scheduler: SchedulerL10n }).scheduler,
+};
+
+// 正则与运行时替换(maker-scheduler engine/template.ts)完全一致:更宽松的写法
+// (如 `{{ topic }}`)会测试通过但运行时不替换。
+function promptPlaceholders(prompt: string): string[] {
+ return [...prompt.matchAll(/\{\{([A-Za-z0-9_-]+)\}\}/g)].map((m) => m[1]).sort();
+}
+
+describe.each(Object.entries(LOCALES))('scheduler.builtinTemplates (%s)', (_locale, scheduler) => {
+ const block = scheduler.builtinTemplates;
+
+ it('covers every builtin template with non-empty copy, and has no orphan entries', () => {
+ const builtinIds = BUILTIN_TEMPLATES.map((t) => t.id).sort();
+ expect(Object.keys(block.items).sort()).toEqual(builtinIds);
+ for (const template of BUILTIN_TEMPLATES) {
+ const item = block.items[template.id];
+ expect(item.name.trim().length, `${template.id} name`).toBeGreaterThan(0);
+ expect(item.description.trim().length, `${template.id} description`).toBeGreaterThan(0);
+ expect(item.prompt.trim().length, `${template.id} prompt`).toBeGreaterThan(0);
+ }
+ });
+
+ it('covers every category with a non-empty name, and has no orphan categories', () => {
+ const categoryIds = TEMPLATE_CATEGORIES.map((c) => c.id).sort();
+ expect(Object.keys(block.categories).sort()).toEqual(categoryIds);
+ for (const id of categoryIds) {
+ expect(block.categories[id].trim().length, `category ${id}`).toBeGreaterThan(0);
+ }
+ });
+
+ it('keeps prompt placeholders aligned with template parameters', () => {
+ for (const template of BUILTIN_TEMPLATES) {
+ const item = block.items[template.id];
+ const paramKeys = (template.parameters ?? []).map((p) => p.key).sort();
+ expect(promptPlaceholders(item.prompt), `${template.id} placeholders`).toEqual(paramKeys);
+ expect(Object.keys(item.params ?? {}).sort(), `${template.id} params block`).toEqual(
+ paramKeys,
+ );
+ for (const key of paramKeys) {
+ expect(item.params?.[key]?.label.trim().length, `${template.id}.${key} label`).toBeGreaterThan(0);
+ }
+ }
+ });
+
+ it('has a label for every capability used by builtin templates', () => {
+ const used = new Set(BUILTIN_TEMPLATES.flatMap((t) => t.capabilities ?? []));
+ for (const capability of used) {
+ expect(
+ scheduler.template.capability[capability]?.trim().length,
+ `capability ${capability}`,
+ ).toBeGreaterThan(0);
+ }
+ });
+});
+
+describe('zh-CN block mirrors the package source verbatim', () => {
+ const block = LOCALES['zh-CN'].builtinTemplates;
+
+ it('categories match', () => {
+ for (const category of TEMPLATE_CATEGORIES) {
+ expect(block.categories[category.id], `category ${category.id}`).toBe(category.name);
+ }
+ });
+
+ it('template copy matches', () => {
+ for (const template of BUILTIN_TEMPLATES) {
+ const item = block.items[template.id];
+ expect(item.name, `${template.id} name`).toBe(template.name);
+ expect(item.description, `${template.id} description`).toBe(template.description);
+ expect(item.prompt, `${template.id} prompt`).toBe(template.prompt);
+ for (const parameter of template.parameters ?? []) {
+ expect(item.params?.[parameter.key]?.label, `${template.id}.${parameter.key} label`).toBe(
+ parameter.label,
+ );
+ expect(
+ item.params?.[parameter.key]?.placeholder,
+ `${template.id}.${parameter.key} placeholder`,
+ ).toBe(parameter.placeholder);
+ }
+ }
+ });
+});
diff --git a/apps/desktop/src/renderer/features/scheduler/components/ScheduleFormDialog.tsx b/apps/desktop/src/renderer/features/scheduler/components/ScheduleFormDialog.tsx
index 9fc48680d7..6a92106fbb 100644
--- a/apps/desktop/src/renderer/features/scheduler/components/ScheduleFormDialog.tsx
+++ b/apps/desktop/src/renderer/features/scheduler/components/ScheduleFormDialog.tsx
@@ -324,6 +324,14 @@ export function ScheduleFormDialog({
}
applyTemplateAgentFields(template);
if (template.useWorktree !== undefined) setField('useWorktree', template.useWorktree);
+ // useWorktree 只在 project workspace 且无会话绑定时会被 buildScheduleInput 保留;
+ // 模板要求 worktree 时把表单切到 project 模式并清掉绑定会话(绑定与 worktree
+ // 互斥,语义同 setDestination('worktree')),否则保存会被静默打回 false,与
+ // 卡片上的「隔离工作区」承诺不符(workingDir 为空时 validate 会要求选目录)。
+ if (template.useWorktree) {
+ setField('workspaceKind', 'project');
+ setField('targetSessionId', '');
+ }
if (template.persistentSession !== undefined) setField('persistentSession', template.persistentSession);
if (template.silentWhenIdle !== undefined) setField('silentWhenIdle', template.silentWhenIdle);
if (template.notify) {
diff --git a/apps/desktop/src/renderer/features/scheduler/components/TemplateCard.tsx b/apps/desktop/src/renderer/features/scheduler/components/TemplateCard.tsx
index 82d250404b..5c7c5f76a3 100644
--- a/apps/desktop/src/renderer/features/scheduler/components/TemplateCard.tsx
+++ b/apps/desktop/src/renderer/features/scheduler/components/TemplateCard.tsx
@@ -1,19 +1,20 @@
import type { ComponentType } from 'react';
+import { useTranslation } from 'react-i18next';
import {
- Activity,
- Boxes,
- Bug,
- CalendarDays,
- ClipboardCheck,
+ BookOpenCheck,
FileText,
FlaskConical,
+ GitBranch,
GitPullRequest,
- Package,
+ Globe,
+ Radar,
+ SlidersHorizontal,
Sparkles,
+ Telescope,
Timer,
type LucideProps,
} from 'lucide-react';
-import type { ScheduleTemplate } from '@cindy/maker-scheduler';
+import type { ScheduleTemplate, TemplateCapability } from '@cindy/maker-scheduler';
import { cn } from '@/lib/utils';
import { cronToHuman } from '../lib/cronToHuman';
@@ -25,8 +26,14 @@ interface TemplateCardProps {
}
export function TemplateCard({ template, selected = false, onSelect }: TemplateCardProps) {
+ const { t } = useTranslation();
const Icon = iconForTemplate(template.id);
const scheduleText = template.cronExpr ? cronToHuman(template.cronExpr) : '';
+ // user/project 模板的 capabilities 不受包词表约束:Object.hasOwn(而不是 in)挡住
+ // 'toString' 这类原型链 key,Set 去重避免重复项撞 React key。
+ const capabilities = [...new Set(template.capabilities ?? [])].filter(
+ (capability): capability is TemplateCapability => Object.hasOwn(CAPABILITY_ICONS, capability),
+ );
return (
<button
@@ -62,36 +69,55 @@ export function TemplateCard({ template, selected = false, onSelect }: TemplateC
{template.description}
</p>
- {scheduleText && (
- <span className="mt-auto inline-flex h-5 max-w-full items-center gap-[5px] rounded-full bg-[var(--chat-input-chip-bg)] px-2 text-11 leading-none text-[var(--settings-section-desc)]">
- <Timer size={10} strokeWidth={1.8} className="shrink-0 text-[var(--cmd-palette-item-meta)]" />
- <span className="truncate">{scheduleText}</span>
- </span>
- )}
+ <span className="mt-auto flex max-w-full flex-wrap items-center gap-1.5">
+ {scheduleText && (
+ <span className="inline-flex h-5 max-w-full items-center gap-[5px] rounded-full bg-[var(--chat-input-chip-bg)] px-2 text-11 leading-none text-[var(--settings-section-desc)]">
+ <Timer size={10} strokeWidth={1.8} className="shrink-0 text-[var(--cmd-palette-item-meta)]" />
+ <span className="truncate">{scheduleText}</span>
+ </span>
+ )}
+ {capabilities.map((capability) => {
+ const CapabilityIcon = CAPABILITY_ICONS[capability];
+ return (
+ <span
+ key={capability}
+ className="inline-flex h-5 items-center gap-[5px] rounded-full bg-[var(--chat-input-chip-bg)] px-2 text-11 leading-none text-[var(--settings-section-desc)]"
+ >
+ <CapabilityIcon
+ size={10}
+ strokeWidth={1.8}
+ className="shrink-0 text-[var(--cmd-palette-item-meta)]"
+ />
+ <span className="truncate">{t(`scheduler.template.capability.${capability}`)}</span>
+ </span>
+ );
+ })}
+ </span>
</button>
);
}
+const CAPABILITY_ICONS: Record<TemplateCapability, ComponentType<LucideProps>> = {
+ worktree: GitBranch,
+ pr: GitPullRequest,
+ web: Globe,
+ params: SlidersHorizontal,
+};
+
function iconForTemplate(id: string): ComponentType<LucideProps> {
switch (id) {
- case 'standup-summary':
- return CalendarDays;
- case 'weekly-mr-summary':
+ case 'nightly-test-heal':
+ return FlaskConical;
+ case 'pr-gatekeeper':
return GitPullRequest;
- case 'weekly-release-notes':
- return Package;
- case 'pre-release-check':
- return ClipboardCheck;
- case 'update-changelog':
+ case 'domain-radar':
+ return Radar;
+ case 'competitor-watch':
+ return Telescope;
+ case 'weekly-work-draft':
return FileText;
- case 'daily-bug-scan':
- return Bug;
- case 'test-gap-detection':
- return FlaskConical;
- case 'nightly-ci-report':
- return Activity;
- case 'dependency-sweep':
- return Boxes;
+ case 'knowledge-freshness':
+ return BookOpenCheck;
default:
return Sparkles;
}
diff --git a/apps/desktop/src/renderer/features/scheduler/hooks/useTemplates.ts b/apps/desktop/src/renderer/features/scheduler/hooks/useTemplates.ts
index bcde43d2b4..ffc18c7dad 100644
--- a/apps/desktop/src/renderer/features/scheduler/hooks/useTemplates.ts
+++ b/apps/desktop/src/renderer/features/scheduler/hooks/useTemplates.ts
@@ -1,7 +1,10 @@
-import { useEffect, useState } from 'react';
+import { useEffect, useMemo, useState } from 'react';
+import { useTranslation } from 'react-i18next';
import type { ScheduleTemplate, TemplateCategory } from '@cindy/maker-scheduler';
import { TEMPLATE_CATEGORIES } from '@cindy/maker-scheduler/templates';
+import { localizeTemplate, localizeTemplateCategory } from '../lib/templateLocalization';
+
interface UseTemplatesResult {
templates: ScheduleTemplate[];
categories: TemplateCategory[];
@@ -10,7 +13,9 @@ interface UseTemplatesResult {
}
export function useTemplates(): UseTemplatesResult {
- const [templates, setTemplates] = useState<ScheduleTemplate[]>([]);
+ // useTranslation 订阅语言切换,语言变化时本地化结果跟着重算。
+ const { i18n } = useTranslation();
+ const [rawTemplates, setRawTemplates] = useState<ScheduleTemplate[]>([]);
const [loading, setLoading] = useState(true);
const [error, setError] = useState<string | null>(null);
@@ -19,7 +24,7 @@ export function useTemplates(): UseTemplatesResult {
void (async () => {
try {
const list = (await window.electronAPI.maker.schedule.listTemplates()) as ScheduleTemplate[];
- if (!cancelled) setTemplates(list);
+ if (!cancelled) setRawTemplates(list);
} catch (e) {
if (!cancelled) setError(e instanceof Error ? e.message : String(e));
} finally {
@@ -31,5 +36,15 @@ export function useTemplates(): UseTemplatesResult {
};
}, []);
- return { templates, categories: TEMPLATE_CATEGORIES, loading, error };
+ const language = i18n.language;
+ const templates = useMemo(
+ () => rawTemplates.map((template) => localizeTemplate(i18n, template)),
+ [rawTemplates, i18n, language],
+ );
+ const categories = useMemo(
+ () => TEMPLATE_CATEGORIES.map((category) => localizeTemplateCategory(i18n, category)),
+ [i18n, language],
+ );
+
+ return { templates, categories, loading, error };
}
diff --git a/apps/desktop/src/renderer/features/scheduler/lib/templateLocalization.ts b/apps/desktop/src/renderer/features/scheduler/lib/templateLocalization.ts
new file mode 100644
index 0000000000..418b00f4a7
--- /dev/null
+++ b/apps/desktop/src/renderer/features/scheduler/lib/templateLocalization.ts
@@ -0,0 +1,49 @@
+import type { i18n as I18nInstance } from 'i18next';
+import type { ScheduleTemplate, TemplateCategory } from '@cindy/maker-scheduler';
+
+/**
+ * 内置模板本地化:包内 `builtin-templates.ts` 的中文是唯一正本,各语言文案
+ * 存放在 locale common.json 的 `scheduler.builtinTemplates` 块,这里做覆盖。
+ *
+ * 不用 t() 而用 getResource 取原始字符串:模板 prompt 里的 `{{topic}}` 是
+ * 调度器自己的参数占位符,走 t() 会被 i18next 当插值变量吃掉。
+ * 回落链与 fallbackLng 一致:当前语言 → en → 包正本。
+ */
+function rawResource(i18n: I18nInstance, key: string): string | undefined {
+ for (const lng of [i18n.language, 'en']) {
+ const value: unknown = i18n.getResource(lng, 'common', key);
+ if (typeof value === 'string' && value.length > 0) return value;
+ }
+ return undefined;
+}
+
+/** builtin 模板按当前语言覆盖 name/description/prompt/参数文案;其它来源原样返回。 */
+export function localizeTemplate(i18n: I18nInstance, template: ScheduleTemplate): ScheduleTemplate {
+ if (template.source !== 'builtin') return template;
+ const base = `scheduler.builtinTemplates.items.${template.id}`;
+ const localized: ScheduleTemplate = {
+ ...template,
+ name: rawResource(i18n, `${base}.name`) ?? template.name,
+ description: rawResource(i18n, `${base}.description`) ?? template.description,
+ };
+ const prompt = rawResource(i18n, `${base}.prompt`);
+ if (prompt !== undefined && template.prompt !== undefined) localized.prompt = prompt;
+ if (template.parameters?.length) {
+ localized.parameters = template.parameters.map((parameter) => ({
+ ...parameter,
+ label: rawResource(i18n, `${base}.params.${parameter.key}.label`) ?? parameter.label,
+ placeholder:
+ rawResource(i18n, `${base}.params.${parameter.key}.placeholder`) ?? parameter.placeholder,
+ }));
+ }
+ return localized;
+}
+
+/** 分类名按当前语言覆盖,缺译回落包正本。 */
+export function localizeTemplateCategory(
+ i18n: I18nInstance,
+ category: TemplateCategory,
+): TemplateCategory {
+ const name = rawResource(i18n, `scheduler.builtinTemplates.categories.${category.id}`);
+ return name ? { ...category, name } : category;
+}
diff --git a/apps/desktop/src/renderer/i18n/locales/en/common.json b/apps/desktop/src/renderer/i18n/locales/en/common.json
index f360a8cb5b..da4d44a6e8 100644
--- a/apps/desktop/src/renderer/i18n/locales/en/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/en/common.json
@@ -5232,6 +5232,12 @@
},
"gallery": {
"heading": "Start from a template"
+ },
+ "capability": {
+ "worktree": "Isolated worktree",
+ "pr": "PR automation",
+ "web": "Web search",
+ "params": "Customizable"
}
},
"projectAutomation": {
@@ -5650,6 +5656,57 @@
"confirm": "Delete",
"cancel": "Cancel"
}
+ },
+ "builtinTemplates": {
+ "categories": {
+ "dev-automation": "Development automation",
+ "info-radar": "Information radar",
+ "office-docs": "Docs & office work"
+ },
+ "items": {
+ "nightly-test-heal": {
+ "name": "Nightly test self-healing",
+ "description": "Run tests every night and attempt minimal fixes for failures in an isolated worktree",
+ "prompt": "Run the project's test suite. If there are failures, attempt a minimal fix in an isolated worktree.\nConstraints:\n- Determine the standard test command from the repo docs or package scripts before running the full suite\n- Only fix issues backed by clear failing evidence; prefer the smallest possible change and avoid drive-by refactoring\n- Re-run the affected tests after fixing to confirm they pass, and review the full diff\n- Deliver fixes through the repo's workflow (e.g. create a branch and open a PR); never commit directly to the main branch\n- For failures that cannot be fixed safely, report the cause, suspicious files, and suggested next steps"
+ },
+ "pr-gatekeeper": {
+ "name": "PR gatekeeper",
+ "description": "Pre-review new changes on open PRs each weekday and report risks by severity",
+ "prompt": "Review the repository's open PRs and pre-screen their new changes.\nConstraints:\n- Go through open PRs with new commits in the past 24 hours (on Monday, look back over the whole weekend), citing PR numbers, file paths, and concrete diffs\n- Focus on correctness, security, data-loss, and compatibility issues, graded by severity\n- Only report issues backed by evidence and describe the failure scenario; do not nitpick on style preferences\n- Unless explicitly authorized, only output review conclusions; do not comment on PRs or change code"
+ },
+ "domain-radar": {
+ "name": "Domain radar",
+ "description": "Periodically collect the latest updates in a topic you follow and deliver an opinionated digest",
+ "prompt": "Collect the latest developments about \"{{topic}}\" from the past 24 hours (on Monday, look back over the whole weekend) and produce an opinionated digest.\nConstraints:\n- Use web search, cross-check multiple sources before trusting a claim, and cite the source link for every item\n- Prefer substantive developments (releases, research, policy, notable discussions); filter out marketing fluff and reposts\n- For each item, add a one-line judgement on why it matters instead of dumping links\n- When information is scarce or sources are questionable, say so honestly; never fabricate",
+ "params": {
+ "topic": {
+ "label": "Topic to follow",
+ "placeholder": "e.g. AI agents, EV market, frontend frameworks"
+ }
+ }
+ },
+ "competitor-watch": {
+ "name": "Competitor watch",
+ "description": "Weekly roundup of competitors' product and market moves, with impact analysis",
+ "prompt": "Track the past week's activity of these competitors: {{competitors}}.\nConstraints:\n- Use web search to cover product updates, releases, pricing changes, market moves, and user sentiment, citing sources\n- Distinguish official information from third-party accounts; clearly mark unverified rumors\n- For each significant update, analyze what it means for us and suggest a response\n- If nothing substantive happened, say so honestly instead of padding the report",
+ "params": {
+ "competitors": {
+ "label": "Competitors",
+ "placeholder": "e.g. Notion, Linear, Figma"
+ }
+ }
+ },
+ "weekly-work-draft": {
+ "name": "Weekly report drafter",
+ "description": "Compile this week's work from documents in the working directory into a report draft",
+ "prompt": "Based on this week's changes to documents, notes, and deliverables in the working directory, compile a weekly report draft.\nConstraints:\n- Only use content with actual modification traces in the working directory as evidence, citing the files\n- Organize as \"Done this week / In progress / Next week / Needs coordination\", concise enough to submit directly\n- Separate substantive progress from routine chores and highlight valuable output\n- Leave placeholders with notes where the material is insufficient so the user can fill them in"
+ },
+ "knowledge-freshness": {
+ "name": "Knowledge base freshness check",
+ "description": "Monthly health check of working-directory docs for outdated or conflicting content",
+ "prompt": "Health-check the documents in the working directory and find content that needs updating.\nConstraints:\n- Look for outdated information (stale dates, dead links, deprecated processes or tools), contradictions, and duplication\n- Cite the file path and location for every issue and explain the reasoning\n- Categorize as \"update / merge / delete\" suggestions and produce a revision checklist\n- Only output the report; do not modify the documents"
+ }
+ }
}
},
"issueTracker": {
diff --git a/apps/desktop/src/renderer/i18n/locales/ja/common.json b/apps/desktop/src/renderer/i18n/locales/ja/common.json
index 0c328f3c41..0e2774f652 100644
--- a/apps/desktop/src/renderer/i18n/locales/ja/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/ja/common.json
@@ -5222,6 +5222,12 @@
},
"gallery": {
"heading": "テンプレートから開始"
+ },
+ "capability": {
+ "worktree": "分離ワークツリー",
+ "pr": "PR 自動化",
+ "web": "Web 検索",
+ "params": "カスタマイズ可"
}
},
"projectAutomation": {
@@ -5640,6 +5646,57 @@
"confirm": "削除",
"cancel": "キャンセル"
}
+ },
+ "builtinTemplates": {
+ "categories": {
+ "dev-automation": "開発自動化",
+ "info-radar": "情報レーダー",
+ "office-docs": "ドキュメントとオフィスワーク"
+ },
+ "items": {
+ "nightly-test-heal": {
+ "name": "夜間セルフヒーリングテスト",
+ "description": "毎晩テストを実行し、失敗項目を分離ワークツリーで最小修正",
+ "prompt": "Run the project's test suite. If there are failures, attempt a minimal fix in an isolated worktree.\nConstraints:\n- Determine the standard test command from the repo docs or package scripts before running the full suite\n- Only fix issues backed by clear failing evidence; prefer the smallest possible change and avoid drive-by refactoring\n- Re-run the affected tests after fixing to confirm they pass, and review the full diff\n- Deliver fixes through the repo's workflow (e.g. create a branch and open a PR); never commit directly to the main branch\n- For failures that cannot be fixed safely, report the cause, suspicious files, and suggested next steps"
+ },
+ "pr-gatekeeper": {
+ "name": "PR ゲートキーパー",
+ "description": "平日にオープン PR の新規変更を事前レビューし、重大度別にリスクを報告",
+ "prompt": "Review the repository's open PRs and pre-screen their new changes.\nConstraints:\n- Go through open PRs with new commits in the past 24 hours (on Monday, look back over the whole weekend), citing PR numbers, file paths, and concrete diffs\n- Focus on correctness, security, data-loss, and compatibility issues, graded by severity\n- Only report issues backed by evidence and describe the failure scenario; do not nitpick on style preferences\n- Unless explicitly authorized, only output review conclusions; do not comment on PRs or change code"
+ },
+ "domain-radar": {
+ "name": "分野レーダー",
+ "description": "注目分野の最新動向を定期収集し、見解付きサマリーを出力",
+ "prompt": "Collect the latest developments about \"{{topic}}\" from the past 24 hours (on Monday, look back over the whole weekend) and produce an opinionated digest.\nConstraints:\n- Use web search, cross-check multiple sources before trusting a claim, and cite the source link for every item\n- Prefer substantive developments (releases, research, policy, notable discussions); filter out marketing fluff and reposts\n- For each item, add a one-line judgement on why it matters instead of dumping links\n- When information is scarce or sources are questionable, say so honestly; never fabricate",
+ "params": {
+ "topic": {
+ "label": "注目テーマ",
+ "placeholder": "例:AI エージェント、新エネルギー、フロントエンド"
+ }
+ }
+ },
+ "competitor-watch": {
+ "name": "競合ウォッチ",
+ "description": "競合の製品・市場動向を週次でまとめ、自社への影響を分析",
+ "prompt": "Track the past week's activity of these competitors: {{competitors}}.\nConstraints:\n- Use web search to cover product updates, releases, pricing changes, market moves, and user sentiment, citing sources\n- Distinguish official information from third-party accounts; clearly mark unverified rumors\n- For each significant update, analyze what it means for us and suggest a response\n- If nothing substantive happened, say so honestly instead of padding the report",
+ "params": {
+ "competitors": {
+ "label": "競合リスト",
+ "placeholder": "例:Notion、Linear、Figma"
+ }
+ }
+ },
+ "weekly-work-draft": {
+ "name": "週報ドラフトアシスタント",
+ "description": "作業ディレクトリのドキュメントから今週の作業を整理し、週報ドラフトを生成",
+ "prompt": "Based on this week's changes to documents, notes, and deliverables in the working directory, compile a weekly report draft.\nConstraints:\n- Only use content with actual modification traces in the working directory as evidence, citing the files\n- Organize as \"Done this week / In progress / Next week / Needs coordination\", concise enough to submit directly\n- Separate substantive progress from routine chores and highlight valuable output\n- Leave placeholders with notes where the material is insufficient so the user can fill them in"
+ },
+ "knowledge-freshness": {
+ "name": "ナレッジベース鮮度チェック",
+ "description": "毎月ドキュメントを点検し、古い内容や矛盾を洗い出す",
+ "prompt": "Health-check the documents in the working directory and find content that needs updating.\nConstraints:\n- Look for outdated information (stale dates, dead links, deprecated processes or tools), contradictions, and duplication\n- Cite the file path and location for every issue and explain the reasoning\n- Categorize as \"update / merge / delete\" suggestions and produce a revision checklist\n- Only output the report; do not modify the documents"
+ }
+ }
}
},
"issueTracker": {
diff --git a/apps/desktop/src/renderer/i18n/locales/ko/common.json b/apps/desktop/src/renderer/i18n/locales/ko/common.json
index 60988d20d2..d808ad516a 100644
--- a/apps/desktop/src/renderer/i18n/locales/ko/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/ko/common.json
@@ -5222,6 +5222,12 @@
},
"gallery": {
"heading": "템플릿에서 시작"
+ },
+ "capability": {
+ "worktree": "격리 워크트리",
+ "pr": "PR 자동화",
+ "web": "웹 검색",
+ "params": "사용자 지정 가능"
}
},
"projectAutomation": {
@@ -5640,6 +5646,57 @@
"confirm": "삭제",
"cancel": "취소"
}
+ },
+ "builtinTemplates": {
+ "categories": {
+ "dev-automation": "개발 자동화",
+ "info-radar": "정보 레이더",
+ "office-docs": "문서와 사무"
+ },
+ "items": {
+ "nightly-test-heal": {
+ "name": "야간 자가 복구 테스트",
+ "description": "매일 밤 테스트를 실행하고 실패 항목을 격리 워크트리에서 최소 수정",
+ "prompt": "Run the project's test suite. If there are failures, attempt a minimal fix in an isolated worktree.\nConstraints:\n- Determine the standard test command from the repo docs or package scripts before running the full suite\n- Only fix issues backed by clear failing evidence; prefer the smallest possible change and avoid drive-by refactoring\n- Re-run the affected tests after fixing to confirm they pass, and review the full diff\n- Deliver fixes through the repo's workflow (e.g. create a branch and open a PR); never commit directly to the main branch\n- For failures that cannot be fixed safely, report the cause, suspicious files, and suggested next steps"
+ },
+ "pr-gatekeeper": {
+ "name": "PR 게이트키퍼",
+ "description": "평일마다 오픈 PR의 새 변경을 사전 리뷰하고 심각도별로 위험 보고",
+ "prompt": "Review the repository's open PRs and pre-screen their new changes.\nConstraints:\n- Go through open PRs with new commits in the past 24 hours (on Monday, look back over the whole weekend), citing PR numbers, file paths, and concrete diffs\n- Focus on correctness, security, data-loss, and compatibility issues, graded by severity\n- Only report issues backed by evidence and describe the failure scenario; do not nitpick on style preferences\n- Unless explicitly authorized, only output review conclusions; do not comment on PRs or change code"
+ },
+ "domain-radar": {
+ "name": "관심 분야 레이더",
+ "description": "관심 분야의 최신 동향을 정기 수집해 관점 있는 요약 제공",
+ "prompt": "Collect the latest developments about \"{{topic}}\" from the past 24 hours (on Monday, look back over the whole weekend) and produce an opinionated digest.\nConstraints:\n- Use web search, cross-check multiple sources before trusting a claim, and cite the source link for every item\n- Prefer substantive developments (releases, research, policy, notable discussions); filter out marketing fluff and reposts\n- For each item, add a one-line judgement on why it matters instead of dumping links\n- When information is scarce or sources are questionable, say so honestly; never fabricate",
+ "params": {
+ "topic": {
+ "label": "관심 주제",
+ "placeholder": "예: AI 에이전트, 신에너지, 프런트엔드"
+ }
+ }
+ },
+ "competitor-watch": {
+ "name": "경쟁사 동향 추적",
+ "description": "경쟁사의 제품·시장 동향을 매주 정리하고 영향 분석",
+ "prompt": "Track the past week's activity of these competitors: {{competitors}}.\nConstraints:\n- Use web search to cover product updates, releases, pricing changes, market moves, and user sentiment, citing sources\n- Distinguish official information from third-party accounts; clearly mark unverified rumors\n- For each significant update, analyze what it means for us and suggest a response\n- If nothing substantive happened, say so honestly instead of padding the report",
+ "params": {
+ "competitors": {
+ "label": "경쟁사 목록",
+ "placeholder": "예: Notion, Linear, Figma"
+ }
+ }
+ },
+ "weekly-work-draft": {
+ "name": "주간 보고서 초안 도우미",
+ "description": "작업 디렉터리의 문서와 산출물로 주간 보고서 초안 생성",
+ "prompt": "Based on this week's changes to documents, notes, and deliverables in the working directory, compile a weekly report draft.\nConstraints:\n- Only use content with actual modification traces in the working directory as evidence, citing the files\n- Organize as \"Done this week / In progress / Next week / Needs coordination\", concise enough to submit directly\n- Separate substantive progress from routine chores and highlight valuable output\n- Leave placeholders with notes where the material is insufficient so the user can fill them in"
+ },
+ "knowledge-freshness": {
+ "name": "지식 베이스 신선도 점검",
+ "description": "매월 문서를 점검해 오래된 내용과 모순 찾기",
+ "prompt": "Health-check the documents in the working directory and find content that needs updating.\nConstraints:\n- Look for outdated information (stale dates, dead links, deprecated processes or tools), contradictions, and duplication\n- Cite the file path and location for every issue and explain the reasoning\n- Categorize as \"update / merge / delete\" suggestions and produce a revision checklist\n- Only output the report; do not modify the documents"
+ }
+ }
}
},
"issueTracker": {
diff --git a/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json b/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json
index 1fc9a2d786..194384a46c 100644
--- a/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json
@@ -5222,6 +5222,12 @@
},
"gallery": {
"heading": "从模板开始"
+ },
+ "capability": {
+ "worktree": "隔离工作区",
+ "pr": "PR 自动化",
+ "web": "Web 搜索",
+ "params": "可自定义"
}
},
"projectAutomation": {
@@ -5640,6 +5646,57 @@
"confirm": "删除",
"cancel": "取消"
}
+ },
+ "builtinTemplates": {
+ "categories": {
+ "dev-automation": "开发自动化",
+ "info-radar": "信息雷达",
+ "office-docs": "文档与办公"
+ },
+ "items": {
+ "nightly-test-heal": {
+ "name": "夜间自愈测试",
+ "description": "每晚跑测试,失败项在隔离工作区尝试最小修复",
+ "prompt": "运行项目的测试套件,如果有失败项,在隔离工作区尝试给出最小修复。\n约束:\n- 先按仓库文档或 package 脚本确定标准测试命令,再完整运行\n- 只修复有明确失败证据的问题,采用影响面最小的改法,避免顺手重构\n- 修复后重跑相关测试确认通过,并复核完整 diff\n- 按仓库工作流交付修复(如创建分支并开 PR),不要直接改动主分支\n- 无法安全修复的失败项,输出失败原因、疑点文件和建议的排查步骤"
+ },
+ "pr-gatekeeper": {
+ "name": "PR 守门人",
+ "description": "工作日预审开放 PR 的新增改动,按严重程度报告风险",
+ "prompt": "检查仓库当前开放的 PR,对新增改动做一轮预审。\n约束:\n- 逐个查看过去 24 小时内有新提交的开放 PR(周一回看整个周末),引用 PR 编号、文件路径和具体 diff\n- 重点找正确性、安全、数据丢失和兼容性问题,按严重程度分级\n- 只报告有证据支撑的问题,说明失败场景,不要凭风格偏好挑刺\n- 除非用户明确授权,只输出审查结论,不要直接在 PR 上留言或改动代码"
+ },
+ "domain-radar": {
+ "name": "领域雷达",
+ "description": "定期搜集你关注领域的最新动态,输出有观点的摘要",
+ "prompt": "围绕主题「{{topic}}」搜集过去 24 小时的最新动态(周一回看整个周末),输出一份有观点的摘要。\n约束:\n- 用 Web 搜索获取信息,交叉核对多个来源后再采信,标注每条信息的来源链接\n- 优先收录有实质内容的进展(发布、研究、政策、重要讨论),过滤营销软文和重复转载\n- 对每条动态给出一句\"为什么值得关注\"的判断,而不是罗列链接\n- 信息不足或来源存疑时如实说明,不要臆造",
+ "params": {
+ "topic": {
+ "label": "关注主题",
+ "placeholder": "如:AI Agent、新能源、前端框架"
+ }
+ }
+ },
+ "competitor-watch": {
+ "name": "竞品动态追踪",
+ "description": "每周汇总竞品的产品与市场动态,分析对我们的影响",
+ "prompt": "追踪以下竞品最近一周的动态:{{competitors}}。\n约束:\n- 用 Web 搜索覆盖产品更新、版本发布、定价变化、市场动作和用户口碑,标注来源\n- 区分官方信息和第三方转述,未经证实的传闻要明确标注\n- 对每条重要动态给出\"对我们意味着什么\"的分析和建议\n- 没有实质动态时如实说明,不要凑数",
+ "params": {
+ "competitors": {
+ "label": "竞品名单",
+ "placeholder": "如:Notion、Linear、Figma"
+ }
+ }
+ },
+ "weekly-work-draft": {
+ "name": "周报草稿助手",
+ "description": "从工作目录的文档和产出物整理本周工作,生成周报草稿",
+ "prompt": "根据工作目录中本周的文档、笔记和产出物变化,整理一份周报草稿。\n约束:\n- 只使用工作目录内有实际修改痕迹的内容作为证据,注明对应文件\n- 按\"本周完成 / 进行中 / 下周计划 / 需要协调\"组织,语言简洁可直接提交\n- 区分实质进展和例行事务,突出有价值的产出\n- 材料不足以判断的部分留出占位并说明,方便用户补充"
+ },
+ "knowledge-freshness": {
+ "name": "知识库保鲜",
+ "description": "每月体检工作目录文档,找出过期与矛盾内容",
+ "prompt": "体检工作目录中的文档,找出需要更新的内容。\n约束:\n- 检查过期信息(旧日期、失效链接、已废弃的流程或工具)、前后矛盾和重复内容\n- 每个问题都注明文件路径和具体位置,说明判断依据\n- 按\"建议更新 / 建议合并 / 建议删除\"分类,给出修订建议清单\n- 只输出体检报告,不要直接修改文档"
+ }
+ }
}
},
"issueTracker": {
diff --git a/apps/mobile/app/automations/[deviceId].tsx b/apps/mobile/app/automations/[deviceId].tsx
index 3c9af37d72..c77e8c80e5 100644
--- a/apps/mobile/app/automations/[deviceId].tsx
+++ b/apps/mobile/app/automations/[deviceId].tsx
@@ -2082,11 +2082,11 @@ function markRunReadLocally(list: readonly RemoteScheduleRun[], runId: string):
return list.map((run) => (run.id === runId ? { ...run, readAt } : run));
}
+// 与 packages/maker-scheduler builtin-templates.ts 的 TEMPLATE_CATEGORIES order 保持一致。
const TEMPLATE_CATEGORY_RANK: Record<string, number> = {
- 'status-reports': 1,
- 'release-prep': 2,
- 'code-quality': 3,
- 'repo-maintenance': 4,
+ 'dev-automation': 1,
+ 'info-radar': 2,
+ 'office-docs': 3,
};
function sortTemplatesForMobile(
diff --git a/packages/maker-scheduler/src/__tests__/builtin-templates.test.ts b/packages/maker-scheduler/src/__tests__/builtin-templates.test.ts
new file mode 100644
index 0000000000..7c945e33fd
--- /dev/null
+++ b/packages/maker-scheduler/src/__tests__/builtin-templates.test.ts
@@ -0,0 +1,95 @@
+import { describe, expect, it } from 'vitest';
+
+import { BUILTIN_TEMPLATES, TEMPLATE_CATEGORIES } from '../builtin-templates.js';
+import { nextRun } from '../engine/cron.js';
+import type { TemplateCapability } from '../types.js';
+
+const CAPABILITY_VOCABULARY: TemplateCapability[] = ['worktree', 'pr', 'web', 'params'];
+
+/**
+ * 提取 prompt 里的 {{param}} 占位符集合。
+ * 正则与运行时替换(engine/template.ts)完全一致:更宽松的写法(如 `{{ topic }}`)
+ * 会测试通过但运行时不替换。
+ */
+function promptPlaceholders(prompt: string): Set<string> {
+ const keys = new Set<string>();
+ for (const match of prompt.matchAll(/\{\{([A-Za-z0-9_-]+)\}\}/g)) {
+ keys.add(match[1]);
+ }
+ return keys;
+}
+
+describe('BUILTIN_TEMPLATES', () => {
+ it('has unique ids', () => {
+ const ids = BUILTIN_TEMPLATES.map((t) => t.id);
+ expect(new Set(ids).size).toBe(ids.length);
+ });
+
+ it('every template belongs to a declared category, with exactly 2 per category', () => {
+ const categoryIds = new Set(TEMPLATE_CATEGORIES.map((c) => c.id));
+ for (const template of BUILTIN_TEMPLATES) {
+ expect(categoryIds.has(template.category), `${template.id} category`).toBe(true);
+ }
+ // desktop 模板网格是两列,每类超过 2 条会折行(2026-07-24 产品确认每类固定 2 条)。
+ for (const category of TEMPLATE_CATEGORIES) {
+ expect(
+ BUILTIN_TEMPLATES.filter((t) => t.category === category.id).length,
+ `category ${category.id} template count`,
+ ).toBe(2);
+ }
+ });
+
+ it('has non-empty name / description / prompt and a schedulable cron', () => {
+ for (const template of BUILTIN_TEMPLATES) {
+ expect(template.name.trim().length, `${template.id} name`).toBeGreaterThan(0);
+ expect(template.description.trim().length, `${template.id} description`).toBeGreaterThan(0);
+ expect(template.prompt?.trim().length ?? 0, `${template.id} prompt`).toBeGreaterThan(0);
+ expect(template.cronExpr, `${template.id} cronExpr`).toBeTruthy();
+ expect(template.timezone, `${template.id} timezone`).toBeTruthy();
+ const from = Date.UTC(2026, 0, 1);
+ const next = nextRun(template.cronExpr!, from, template.timezone!);
+ expect(next, `${template.id} nextRun`).toBeGreaterThan(from);
+ }
+ });
+
+ it('prompt placeholders and declared parameters stay in sync (both directions)', () => {
+ for (const template of BUILTIN_TEMPLATES) {
+ const placeholders = promptPlaceholders(template.prompt ?? '');
+ const paramKeys = new Set((template.parameters ?? []).map((p) => p.key));
+ expect(placeholders, `${template.id} placeholders vs parameters`).toEqual(paramKeys);
+ }
+ });
+
+ it('parameters have non-empty labels and unique keys', () => {
+ for (const template of BUILTIN_TEMPLATES) {
+ const params = template.parameters ?? [];
+ const keys = params.map((p) => p.key);
+ expect(new Set(keys).size, `${template.id} parameter keys unique`).toBe(keys.length);
+ for (const param of params) {
+ expect(param.label.trim().length, `${template.id}.${param.key} label`).toBeGreaterThan(0);
+ }
+ }
+ });
+
+ it('capabilities stay within the vocabulary and mirror actual behavior flags', () => {
+ for (const template of BUILTIN_TEMPLATES) {
+ const capabilities = template.capabilities ?? [];
+ expect(new Set(capabilities).size, `${template.id} capabilities unique`).toBe(
+ capabilities.length,
+ );
+ for (const capability of capabilities) {
+ expect(CAPABILITY_VOCABULARY, `${template.id} capability ${capability}`).toContain(
+ capability,
+ );
+ }
+ // chip 与真实行为字段联动,防止手工双写漂移:
+ // 有参数 ⇔ 标 params;开 worktree ⇔ 标 worktree。
+ expect(capabilities.includes('params'), `${template.id} params chip`).toBe(
+ (template.parameters ?? []).length > 0,
+ );
+ expect(capabilities.includes('worktree'), `${template.id} worktree chip`).toBe(
+ template.useWorktree === true,
+ );
+ }
+ });
+});
diff --git a/packages/maker-scheduler/src/builtin-templates.ts b/packages/maker-scheduler/src/builtin-templates.ts
index 21ec7f0835..15bf9901f9 100644
--- a/packages/maker-scheduler/src/builtin-templates.ts
+++ b/packages/maker-scheduler/src/builtin-templates.ts
@@ -1,104 +1,144 @@
import type { ScheduleTemplate, TemplateCategory } from './types.js';
+/**
+ * 内置自动化模板。
+ *
+ * 本文件的中文文案是唯一正本:desktop renderer 通过
+ * `apps/desktop/src/renderer/i18n/locales/<locale>/common.json` 的
+ * `scheduler.builtinTemplates` 块做多语言覆盖(zh-CN 块必须与这里逐字一致,
+ * 由 desktop 侧 schedulerTemplateLocalization 测试锁死);mobile 经
+ * `maker:schedule:list-templates` 拿到的仍是这里的中文正本。
+ *
+ * 选题原则(2026-07-22 与产品确认):
+ * - 数据来源只限工作目录/仓库(agent 本来就有权限的范围)和公开 Web;
+ * 绝不周期性读取用户私人账号数据(邮箱、IM、日程)——那类任务每次运行
+ * 都消耗用户 token 并把隐私数据喂进定时任务,不作为官方推荐。
+ * - 产出必须是可交付物(报告 / 草稿 / PR),不是提醒。
+ * - 兼顾开发与非开发办公场景。
+ * - 每个分类固定 2 条:desktop 模板网格是两列,超过 2 条会折行(2026-07-24)。
+ */
+
const DEFAULT_TIMEZONE = 'Asia/Shanghai';
const DEFAULT_NOTIFY = { desktop: true, feishu: false } as const;
export const TEMPLATE_CATEGORIES: TemplateCategory[] = [
- { id: 'status-reports', name: '状态报告', order: 1 },
- { id: 'release-prep', name: '发布准备', order: 2 },
- { id: 'code-quality', name: '代码质量', order: 3 },
- { id: 'repo-maintenance', name: '仓库维护', order: 4 },
+ { id: 'dev-automation', name: '开发自动化', order: 1 },
+ { id: 'info-radar', name: '信息雷达', order: 2 },
+ { id: 'office-docs', name: '文档与办公', order: 3 },
];
export const BUILTIN_TEMPLATES: ScheduleTemplate[] = [
{
- id: 'standup-summary',
- name: '站会摘要',
- description: '总结昨天的 git 活动,锚定 commit/MR/文件',
- category: 'status-reports',
+ id: 'nightly-test-heal',
+ name: '夜间自愈测试',
+ description: '每晚跑测试,失败项在隔离工作区尝试最小修复',
+ category: 'dev-automation',
source: 'builtin',
- prompt: `总结昨天的 git 活动,生成适合站会同步的摘要。
+ prompt: `运行项目的测试套件,如果有失败项,在隔离工作区尝试给出最小修复。
约束:
-- 只使用仓库中的具体证据,包括 commit SHA、MR、文件路径、diff、测试结果或 CI 信号
-- 按主题归纳,不要按流水账罗列全部提交
-- 明确列出已完成、进行中、阻塞项和需要团队关注的风险
-- 如果证据不足,请说明缺口,不要补编进展`,
- cronExpr: '0 9 * * 1-5',
+- 先按仓库文档或 package 脚本确定标准测试命令,再完整运行
+- 只修复有明确失败证据的问题,采用影响面最小的改法,避免顺手重构
+- 修复后重跑相关测试确认通过,并复核完整 diff
+- 按仓库工作流交付修复(如创建分支并开 PR),不要直接改动主分支
+- 无法安全修复的失败项,输出失败原因、疑点文件和建议的排查步骤`,
+ cronExpr: '0 2 * * *',
timezone: DEFAULT_TIMEZONE,
recurring: true,
agentKind: 'claude-code',
- useWorktree: false,
+ useWorktree: true,
notify: DEFAULT_NOTIFY,
+ capabilities: ['worktree', 'pr'],
},
{
- id: 'weekly-mr-summary',
- name: '每周 MR 摘要',
- description: '按成员和主题总结上周 MR,突出风险',
- category: 'status-reports',
+ id: 'pr-gatekeeper',
+ name: 'PR 守门人',
+ description: '工作日预审开放 PR 的新增改动,按严重程度报告风险',
+ category: 'dev-automation',
source: 'builtin',
- prompt: `总结上周合并或仍在评审中的 MR,生成团队周报摘要。
+ prompt: `检查仓库当前开放的 PR,对新增改动做一轮预审。
约束:
-- 按成员和主题组织内容,引用 MR 编号、标题、相关 commit 和关键文件
-- 突出高风险改动、未完成评审、测试缺口和可能影响发布的事项
-- 不要把没有证据的推测写成事实
-- 输出应便于团队快速决定下周优先级`,
- cronExpr: '0 9 * * 1',
+- 逐个查看过去 24 小时内有新提交的开放 PR(周一回看整个周末),引用 PR 编号、文件路径和具体 diff
+- 重点找正确性、安全、数据丢失和兼容性问题,按严重程度分级
+- 只报告有证据支撑的问题,说明失败场景,不要凭风格偏好挑刺
+- 除非用户明确授权,只输出审查结论,不要直接在 PR 上留言或改动代码`,
+ cronExpr: '0 10 * * 1-5',
timezone: DEFAULT_TIMEZONE,
recurring: true,
agentKind: 'claude-code',
useWorktree: false,
notify: DEFAULT_NOTIFY,
+ capabilities: ['pr'],
},
{
- id: 'weekly-release-notes',
- name: '每周发布说明',
- description: '根据已合并 MR 起草发布说明',
- category: 'release-prep',
+ id: 'domain-radar',
+ name: '领域雷达',
+ description: '定期搜集你关注领域的最新动态,输出有观点的摘要',
+ category: 'info-radar',
source: 'builtin',
- prompt: `根据本周已合并 MR 起草发布说明。
+ prompt: `围绕主题「{{topic}}」搜集过去 24 小时的最新动态(周一回看整个周末),输出一份有观点的摘要。
约束:
-- 只纳入有明确 MR、commit 或 changelog 证据的变化
-- 按用户可感知的功能、修复、性能、内部维护分类
-- 对破坏性变更、迁移步骤和配置变更单独标注
-- 保留 MR 链接或编号,方便发布负责人追溯`,
- cronExpr: '0 9 * * 5',
+- 用 Web 搜索获取信息,交叉核对多个来源后再采信,标注每条信息的来源链接
+- 优先收录有实质内容的进展(发布、研究、政策、重要讨论),过滤营销软文和重复转载
+- 对每条动态给出一句"为什么值得关注"的判断,而不是罗列链接
+- 信息不足或来源存疑时如实说明,不要臆造`,
+ cronExpr: '0 9 * * 1-5',
timezone: DEFAULT_TIMEZONE,
recurring: true,
agentKind: 'claude-code',
useWorktree: false,
notify: DEFAULT_NOTIFY,
+ parameters: [
+ {
+ key: 'topic',
+ label: '关注主题',
+ type: 'string',
+ required: true,
+ placeholder: '如:AI Agent、新能源、前端框架',
+ },
+ ],
+ capabilities: ['web', 'params'],
},
{
- id: 'pre-release-check',
- name: '发版前检查',
- description: '打 tag 前核对 changelog、迁移、测试',
- category: 'release-prep',
+ id: 'competitor-watch',
+ name: '竞品动态追踪',
+ description: '每周汇总竞品的产品与市场动态,分析对我们的影响',
+ category: 'info-radar',
source: 'builtin',
- prompt: `执行发版前检查,确认当前仓库是否适合打 tag。
+ prompt: `追踪以下竞品最近一周的动态:{{competitors}}。
约束:
-- 检查 changelog、版本号、数据库迁移、构建脚本、测试和 CI 状态
-- 引用具体文件路径、命令输出、MR 或 commit 作为证据
-- 将问题按阻塞、建议修复、可接受风险分类
-- 不要修改代码;只输出检查结论和最小修复建议`,
- cronExpr: '0 13 * * 4',
+- 用 Web 搜索覆盖产品更新、版本发布、定价变化、市场动作和用户口碑,标注来源
+- 区分官方信息和第三方转述,未经证实的传闻要明确标注
+- 对每条重要动态给出"对我们意味着什么"的分析和建议
+- 没有实质动态时如实说明,不要凑数`,
+ cronExpr: '0 9 * * 1',
timezone: DEFAULT_TIMEZONE,
recurring: true,
agentKind: 'claude-code',
useWorktree: false,
notify: DEFAULT_NOTIFY,
+ parameters: [
+ {
+ key: 'competitors',
+ label: '竞品名单',
+ type: 'string',
+ required: true,
+ placeholder: '如:Notion、Linear、Figma',
+ },
+ ],
+ capabilities: ['web', 'params'],
},
{
- id: 'update-changelog',
- name: '更新变更日志',
- description: '用本周亮点和 MR 链接更新 changelog',
- category: 'release-prep',
+ id: 'weekly-work-draft',
+ name: '周报草稿助手',
+ description: '从工作目录的文档和产出物整理本周工作,生成周报草稿',
+ category: 'office-docs',
source: 'builtin',
- prompt: `根据本周亮点和已合并 MR 更新 changelog 草稿。
+ prompt: `根据工作目录中本周的文档、笔记和产出物变化,整理一份周报草稿。
约束:
-- 复用仓库现有 changelog 格式,不引入新的排版风格
-- 每条变更都关联 MR、commit 或文件路径证据
-- 优先写用户可理解的变化,避免内部实现细节淹没重点
-- 如果 changelog 文件不存在或格式不明确,先说明建议方案,不要凭空创建结构`,
+- 只使用工作目录内有实际修改痕迹的内容作为证据,注明对应文件
+- 按"本周完成 / 进行中 / 下周计划 / 需要协调"组织,语言简洁可直接提交
+- 区分实质进展和例行事务,突出有价值的产出
+- 材料不足以判断的部分留出占位并说明,方便用户补充`,
cronExpr: '0 16 * * 5',
timezone: DEFAULT_TIMEZONE,
recurring: true,
@@ -107,79 +147,22 @@ export const BUILTIN_TEMPLATES: ScheduleTemplate[] = [
notify: DEFAULT_NOTIFY,
},
{
- id: 'daily-bug-scan',
- name: '每日 Bug 扫描',
- description: '扫描近期 commit 查找 bug 并提出最小修复',
- category: 'code-quality',
- source: 'builtin',
- prompt: `扫描最近的 commit(自上次运行以来,或过去 24 小时内),查找可能的 bug 并提出最小修复方案。
-约束:
-- 只使用仓库中的具体证据(commit SHA、MR、文件路径、diff、失败的测试、CI 信号)
-- 不要臆造 bug;如果证据不足,请说明并跳过
-- 优先选择最小且安全的修复;避免重构和无关清理
-- 对每个疑点说明影响范围、复现线索和建议验证方式`,
- cronExpr: '0 9 * * *',
- timezone: DEFAULT_TIMEZONE,
- recurring: true,
- agentKind: 'claude-code',
- useWorktree: false,
- notify: DEFAULT_NOTIFY,
- },
- {
- id: 'test-gap-detection',
- name: '测试盲区检测',
- description: '找出变更中未测试的路径,补充测试',
- category: 'code-quality',
- source: 'builtin',
- prompt: `检查近期变更中的测试盲区,并提出补充测试方案。
-约束:
-- 对照 diff、现有测试文件、测试命令和失败记录判断覆盖缺口
-- 优先指出高风险路径,包括状态机、数据迁移、IPC、权限和跨平台逻辑
-- 给出最小测试用例建议,说明应验证的行为和失败条件
-- 不要为了提高覆盖率建议无意义快照或脆弱测试`,
- cronExpr: '0 15 * * *',
- timezone: DEFAULT_TIMEZONE,
- recurring: true,
- agentKind: 'claude-code',
- useWorktree: false,
- notify: DEFAULT_NOTIFY,
- },
- {
- id: 'nightly-ci-report',
- name: '每晚 CI 报告',
- description: '总结 CI 失败和不稳定测试,提出修复建议',
- category: 'code-quality',
+ id: 'knowledge-freshness',
+ name: '知识库保鲜',
+ description: '每月体检工作目录文档,找出过期与矛盾内容',
+ category: 'office-docs',
source: 'builtin',
- prompt: `总结当天 CI 失败和不稳定测试,提出下一步修复建议。
+ prompt: `体检工作目录中的文档,找出需要更新的内容。
约束:
-- 引用具体 pipeline、job、测试名称、错误片段、commit 或 MR 作为证据
-- 区分确定失败、疑似 flaky、环境问题和缺少信息的情况
-- 对每个问题给出最小排查路径和优先级
-- 不要把网络抖动或缓存问题直接归因到代码,除非有证据支持`,
- cronExpr: '0 21 * * *',
+- 检查过期信息(旧日期、失效链接、已废弃的流程或工具)、前后矛盾和重复内容
+- 每个问题都注明文件路径和具体位置,说明判断依据
+- 按"建议更新 / 建议合并 / 建议删除"分类,给出修订建议清单
+- 只输出体检报告,不要直接修改文档`,
+ cronExpr: '0 10 1 * *',
timezone: DEFAULT_TIMEZONE,
recurring: true,
agentKind: 'claude-code',
useWorktree: false,
notify: DEFAULT_NOTIFY,
},
- {
- id: 'dependency-sweep',
- name: '依赖清扫',
- description: '扫描过时依赖,提出安全升级方案',
- category: 'repo-maintenance',
- source: 'builtin',
- prompt: `扫描仓库依赖状态,提出安全且可回滚的升级方案。
-约束:
-- 优先关注安全漏洞、已知兼容性问题和项目实际使用到的关键依赖
-- 引用 package 文件、lockfile、release note 或安全公告作为证据
-- 将升级分为可直接升级、需要适配、建议暂缓三类
-- 不要批量升级无关依赖;每个建议都要包含验证命令和回滚方式`,
- cronExpr: '0 9 1 * *',
- timezone: DEFAULT_TIMEZONE,
- recurring: true,
- agentKind: 'claude-code',
- useWorktree: true,
- notify: DEFAULT_NOTIFY,
- },
];
diff --git a/packages/maker-scheduler/src/types.ts b/packages/maker-scheduler/src/types.ts
index ce8066e3b0..c9d2d68bb5 100644
--- a/packages/maker-scheduler/src/types.ts
+++ b/packages/maker-scheduler/src/types.ts
@@ -392,6 +392,12 @@ export interface TemplateCategory {
order: number;
}
+/**
+ * 模板能力标签,desktop 在模板卡片上渲染为能力 chip。
+ * 词表收敛在这里而不是放开 string,让渲染端的图标/文案映射可以被 typecheck 兜住。
+ */
+export type TemplateCapability = 'worktree' | 'pr' | 'web' | 'params';
+
export interface ScheduleTemplate {
id: string;
name: string;
@@ -421,6 +427,8 @@ export interface ScheduleTemplate {
notify?: ScheduleNotifyConfig;
parameters?: TemplateParameter[];
+ /** 能力标签(隔离工作区 / PR 自动化 / Web 搜索 / 可自定义),仅影响展示。 */
+ capabilities?: TemplateCapability[];
createdAt?: number;
updatedAt?: number;
diff --git a/packages/maker-shared/src/__tests__/scheduleForm.test.ts b/packages/maker-shared/src/__tests__/scheduleForm.test.ts
index 4c0e12fdee..a783f09152 100644
--- a/packages/maker-shared/src/__tests__/scheduleForm.test.ts
+++ b/packages/maker-shared/src/__tests__/scheduleForm.test.ts
@@ -271,6 +271,39 @@ describe('mobile schedule form model', () => {
expect(validateTemplateParamValues(template, { scope: 'today' })).toBeNull();
});
+ it('switches a worktree template draft into project workspace so useWorktree survives serialization', () => {
+ const template: RemoteScheduleTemplate = {
+ id: 'nightly-test-heal',
+ name: '夜间自愈测试',
+ description: 'Nightly test healing',
+ category: 'dev-automation',
+ source: 'builtin',
+ prompt: 'Run tests and fix failures',
+ cronExpr: '0 2 * * *',
+ timezone: 'Asia/Shanghai',
+ recurring: true,
+ agentKind: 'claude-code',
+ useWorktree: true,
+ notify: { desktop: true, feishu: false },
+ };
+ // 默认空 draft 是 dialogue workspace;不切 project 的话 useWorktree 会在
+ // buildMobileScheduleInput 里被静默打回 false(review #316 P1)。
+ const draft = applyTemplateToMobileScheduleDraft(createMobileScheduleDraft(null), template);
+
+ expect(draft.workspaceKind).toBe('project');
+ expect(draft.useWorktree).toBe(true);
+ expect(validateMobileScheduleDraft(draft)).toMatchObject({ field: 'workingDir' });
+ expect(buildMobileScheduleInput({ ...draft, workingDir: '/repo' }).useWorktree).toBe(true);
+
+ // 绑定会话的 draft 上应用 worktree 模板:绑定与 worktree 互斥,必须清掉
+ // targetSessionId,否则序列化的 heartbeat 分支同样会打回 false。
+ const boundDraft = updateDraftBoundSessionId(createMobileScheduleDraft(null), 'session-1');
+ const fromBound = applyTemplateToMobileScheduleDraft(boundDraft, template);
+ expect(fromBound.targetSessionId).toBe('');
+ expect(fromBound.useWorktree).toBe(true);
+ expect(buildMobileScheduleInput({ ...fromBound, workingDir: '/repo' }).useWorktree).toBe(true);
+ });
+
it('flags missing required template parameters without defaults', () => {
const template: RemoteScheduleTemplate = {
id: 'custom',
diff --git a/packages/maker-shared/src/scheduleForm.ts b/packages/maker-shared/src/scheduleForm.ts
index 2006f4ff21..74c7e7f44c 100644
--- a/packages/maker-shared/src/scheduleForm.ts
+++ b/packages/maker-shared/src/scheduleForm.ts
@@ -141,6 +141,12 @@ export function applyTemplateToMobileScheduleDraft(
effort: template.effort ?? '',
fastMode: template.fastMode === true,
useWorktree: template.useWorktree ?? draft.useWorktree,
+ // useWorktree 只在 project workspace 且无会话绑定时会被 buildMobileScheduleInput
+ // 保留;模板要求 worktree 时把 draft 一并切到 project 模式并清掉绑定会话
+ // (绑定与 worktree 互斥),否则保存会被静默打回 false,与模板承诺的隔离
+ // 工作区不符(workingDir 为空由 draft 校验兜底)。
+ workspaceKind: template.useWorktree ? 'project' : draft.workspaceKind,
+ targetSessionId: template.useWorktree ? '' : draft.targetSessionId,
persistentSession: template.persistentSession ?? draft.persistentSession,
notifyDesktop: template.notify?.desktop ?? draft.notifyDesktop,
notifyFeishu: template.notify?.feishu ?? draft.notifyFeishu,