feat: add bundled OpenCode skills and refine module flow
Some checks failed
Electron E2E / Electron E2E (macos-latest) (push) Has been cancelled
Electron E2E / Electron E2E (ubuntu-latest) (push) Has been cancelled
Electron E2E / Electron E2E (windows-latest) (push) Has been cancelled

This commit is contained in:
inman
2026-08-14 18:15:55 +08:00
parent 88f9ee8708
commit c809002180
31 changed files with 1153 additions and 241 deletions

View File

@@ -7,6 +7,7 @@ import {
unlinkSync,
} from 'node:fs';
import { join } from 'node:path';
import { BUNDLED_OPENCODE_SKILL_IDS } from '../../shared/opencode-skills';
export interface BundledSkillsPathInput {
isPackaged: boolean;
@@ -19,9 +20,7 @@ export interface EnsureBundledCourseSkillsOptions {
sourceDir?: string;
}
export const BUNDLED_COURSE_SKILL_IDS = [
'agent-browser',
] as const;
export const BUNDLED_COURSE_SKILL_IDS = BUNDLED_OPENCODE_SKILL_IDS;
const RETIRED_COURSE_SKILL_IDS = [
'course-stage-review',
'student-growth-logger',

View File

@@ -199,7 +199,10 @@ function buildAgentMarkdown(config: ProjectConfig, agent: ProjectAgentConfig): s
].join('\n');
const shellPermission = agent.skillIds.includes('game-assets') ? ' bash: allow\n' : '';
const model = agent.model;
const prompt = agent.prompt.trim() || buildProjectAgentPrompt(config, agent);
const prompt = [
agent.prompt.trim() || buildProjectAgentPrompt(config, agent),
buildSelectedSkillGuidance(agent.skillIds),
].filter(Boolean).join('\n\n');
return `---
description: ${yamlString(agent.name)}
mode: all
@@ -212,6 +215,29 @@ ${skills}
${prompt}`;
}
function buildSelectedSkillGuidance(skillIds: string[]): string {
const guidance: string[] = [];
if (skillIds.includes('frontend-slides')) {
guidance.push([
'## 自动调用:项目演示',
'当用户要求项目汇报、结题展示、答辩、项目介绍或其他演示文稿时,主动调用 `frontend-slides`,把当前项目的真实内容整理成可播放的本地 HTML 幻灯片。项目接近完成且交付清单需要项目演示时,主动提醒用户并准备生成;不要生成 PPTX、不要部署到云端。',
].join('\n'));
}
if (skillIds.includes('grilling')) {
guidance.push([
'## 自动调用:方案质询',
'当任务涉及重要实现、设计、架构或其他未确认的高影响决策时,主动调用 `grilling`。在用户确认共享理解前,不要修改项目状态。',
].join('\n'));
}
if (skillIds.includes('planning-with-files')) {
guidance.push([
'## 自动调用:项目规划',
'当任务包含多个阶段、需要研究或可能跨会话继续时,主动调用 `planning-with-files`,并按该技能在 `.niancode/agent-planning/` 中维护规划文件。',
].join('\n'));
}
return guidance.join('\n\n');
}
async function areMaterializedAgentsCurrent(projectPath: string, config: ProjectConfig): Promise<boolean> {
if (!config.initialized || config.agents.length === 0) return true;