From dc4bd6ca916c03c61d1e8bd9473f5699bcbb3c26 Mon Sep 17 00:00:00 2001 From: abearxiong Date: Tue, 20 Jan 2026 23:04:09 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=9B=B4=E6=96=B0=E5=BE=85=E5=8A=9E?= =?UTF-8?q?=E4=BB=BB=E5=8A=A1=E5=8A=9F=E8=83=BD=EF=BC=8C=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E5=88=9D=E5=A7=8B=E5=8C=96=E3=80=81=E5=88=97=E5=87=BA=E3=80=81?= =?UTF-8?q?=E5=AE=8C=E6=88=90=E3=80=81=E6=B7=BB=E5=8A=A0=E5=92=8C=E6=B8=85?= =?UTF-8?q?=E7=90=86=E4=BB=BB=E5=8A=A1=E7=9A=84=E8=B7=AF=E7=94=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .cnb.yml | 2 +- src/routes/index.ts | 2 +- src/routes/md.ts | 41 ----------- src/routes/todo.ts | 164 ++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 166 insertions(+), 43 deletions(-) delete mode 100644 src/routes/md.ts create mode 100644 src/routes/todo.ts diff --git a/.cnb.yml b/.cnb.yml index 4d1d4f2..90b789b 100644 --- a/.cnb.yml +++ b/.cnb.yml @@ -4,7 +4,7 @@ include: .common_env: &common_env env: - TO_REPO: kevisual/template-docs + TO_REPO: kevisual/frontend-starter-skill TO_URL: git.xiongxiao.me imports: - https://cnb.cool/kevisual/env/-/blob/main/.env.development diff --git a/src/routes/index.ts b/src/routes/index.ts index 506e3e9..7d51add 100644 --- a/src/routes/index.ts +++ b/src/routes/index.ts @@ -1 +1 @@ -import './md.ts'; \ No newline at end of file +import './todo.ts'; \ No newline at end of file diff --git a/src/routes/md.ts b/src/routes/md.ts deleted file mode 100644 index 30a0d34..0000000 --- a/src/routes/md.ts +++ /dev/null @@ -1,41 +0,0 @@ -import * as docs from '../generated/docs.ts'; - -import { app } from '../app.ts' -import path from 'path'; -import fs from 'fs'; -import { createSkill, tool } from '@kevisual/router'; - -// 初始化init-web-todo 任务, 使用astro -app.route({ - path: 'web-todo', - key: 'init', - description: '初始化需要做的任务', - metadata: { - tags: ['opencode'], - ...createSkill({ - skill: 'init-web-todo', - title: '初始化 Web Todo 项目', - summary: '初始化需要做的任务', - args: { - type: tool.schema.string().describe('初始化类型, astro 或者 nextjs'), - force: tool.schema.boolean().optional().describe('是否强制覆盖已存在的 TODO.md 文件'), - } - }) - } -}).define(async (ctx) => { - const type = ctx.query?.type || 'astro'; - const force = ctx.query?.force ?? false; - const todo = path.join(process.cwd(), 'TODO.md'); - if (fs.existsSync(todo)) { - if (!force) { - ctx.body = { - content: 'TODO.md 文件已经存在。如需覆盖,请使用 --force 参数。', - } - return; - } - } - const template = type === 'nextjs' ? docs.enterprise_website_features : docs.website_features_breakdown; - ctx.body = { - content: `根据下面的文档,生成一个任务清单,写入到TODO.md 文件中, 使用技术:${type}:\n\n${template}`, - } -}).addTo(app); \ No newline at end of file diff --git a/src/routes/todo.ts b/src/routes/todo.ts new file mode 100644 index 0000000..f97dfdb --- /dev/null +++ b/src/routes/todo.ts @@ -0,0 +1,164 @@ +import * as docs from '../generated/docs.ts'; + +import { app } from '../app.ts' +import path from 'path'; +import fs from 'fs'; +import { createSkill, tool } from '@kevisual/router'; + +// 初始化init-web-todo 任务, 使用astro +app.route({ + path: 'web-todo', + key: 'init', + description: '初始化需要做的任务', + metadata: { + tags: ['opencode'], + ...createSkill({ + skill: 'init-web-todo', + title: '初始化 Web Todo 项目', + summary: '初始化需要做的任务', + args: { + type: tool.schema.string().describe('初始化类型, astro 或者 nextjs'), + force: tool.schema.boolean().optional().describe('是否强制覆盖已存在的 TODO.md 文件'), + } + }) + } +}).define(async (ctx) => { + const type = ctx.query?.type || 'astro'; + const force = ctx.query?.force ?? false; + const todo = path.join(process.cwd(), 'TODO.md'); + if (fs.existsSync(todo)) { + if (!force) { + ctx.body = { + content: 'TODO.md 文件已经存在。如需覆盖,请使用 forec 参数。', + } + return; + } + } + const template = type === 'nextjs' ? docs.enterprise_website_features : docs.website_features_breakdown; + ctx.body = { + content: `根据下面的文档,生成一个任务清单,写入到TODO.md 文件中, 使用技术:${type}:\n\n${template}`, + } +}).addTo(app); + + +app.route({ + path: 'web-todo', + key: 'list', + description: '列出当前的待办任务', + metadata: { + tags: ['opencode'], + ...createSkill({ + skill: 'list-web-todo', + title: '列出当前的待办任务', + summary: '列出当前的待办任务', + }) + } +}).define(async (ctx) => { + const todo = path.join(process.cwd(), 'TODO.md'); + if (!fs.existsSync(todo)) { + ctx.body = { + content: '当前没有待办任务。请先初始化任务列表。', + } + return; + } + const content = fs.readFileSync(todo, 'utf-8'); + ctx.body = { + content, + } +}).addTo(app); + +app.route({ + path: 'web-todo', + key: 'complete', + description: '完成一个待办任务', + metadata: { + tags: ['opencode'], + ...createSkill({ + skill: 'complete-web-todo', + title: '完成一个待办任务', + summary: '完成一个待办任务', + args: { + task: tool.schema.string().describe('要完成的任务描述'), + } + }) + } +}).define(async (ctx) => { + const task = ctx.query?.task; + if (!task) { + ctx.body = { + content: '请提供要完成的任务描述。', + } + return; + } + const todo = path.join(process.cwd(), 'TODO.md'); + if (!fs.existsSync(todo)) { + ctx.body = { + content: '当前没有待办任务。请先初始化任务列表。', + } + return; + } + ctx.body = { + content: `当前的任务已经完成,对TODO.md的内容进行修改。${task}`, + } +}).addTo(app); + +app.route({ + path: 'web-todo', + key: 'add', + description: '添加一个待办任务', + metadata: { + tags: ['opencode'], + ...createSkill({ + skill: 'add-web-todo', + title: '添加一个待办任务', + summary: '添加一个待办任务', + args: { + task: tool.schema.string().describe('要添加的任务描述'), + } + }) + } +}).define(async (ctx) => { + const task = ctx.query?.task; + if (!task) { + ctx.body = { + content: '请提供要添加的任务描述。', + } + return; + } + const todo = path.join(process.cwd(), 'TODO.md'); + if (!fs.existsSync(todo)) { + ctx.body = { + content: '当前没有待办任务。请先初始化任务列表。', + } + return; + } + ctx.body = { + content: `添加一个新的任务到TODO.md文件中。${task}`, + } +}).addTo(app); + +app.route({ + path: 'web-todo', + key: 'clear', + description: '清理已经完成的待办任务', + metadata: { + tags: ['opencode'], + ...createSkill({ + skill: 'clear-web-todo', + title: '清理已经完成的待办任务', + summary: '清理已经完成的待办任务', + }) + } +}).define(async (ctx) => { + const todo = path.join(process.cwd(), 'TODO.md'); + if (!fs.existsSync(todo)) { + ctx.body = { + content: '当前没有待办任务。请先初始化任务列表。', + } + return; + } + ctx.body = { + content: `清理TODO.md文件中已经完成的任务,只保留未完成的任务。`, + } +}).addTo(app); +