dsh-task-board-tapd 0.6.2 → 0.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -3
- package/client.js +156 -27
- package/package.json +1 -1
- package/src/host/service.js +92 -10
- package/src/host/tools.js +12 -2
package/README.md
CHANGED
|
@@ -7,6 +7,7 @@ DeepSeek Harness(DSH)内的 **TAPD 任务看板** 插件:在客户端侧
|
|
|
7
7
|
## 功能
|
|
8
8
|
|
|
9
9
|
- 侧栏面板行 + 主栏看板页(shell 官方座位,非 DOM 接管)
|
|
10
|
+
- 泳道排序:按状态显示名的业务阶段排列(待受理 → 已受理 → 方案 → 实施/处理 → 验改/验收 → 完成 → 取消/阻塞),不依赖 TAPD 的物理值字典序,因此各空间自定义状态也能得到合理顺序;设置页可关闭「显示空泳道」只看有任务的列
|
|
10
11
|
- 类型页签:需求 / 任务 / 缺陷,泳道**完全来自 TAPD 字段配置**(get_fields_info 返回的状态集合与标签),空状态也保留;切换空间后即使状态命名不同也能正确显示全部泳道,不再依赖任何硬编码状态值
|
|
11
12
|
- 泳道拖拽:把卡片拖到目标状态列即调用 TAPD 更新状态,拖拽中目标列高亮、原卡片半透明;改状态失败时卡片回到原列并在顶部显示错误
|
|
12
13
|
- 默认只显示当前用户在配置工作区内负责的工作项(需求/任务按 `owner`,缺陷按 `current_owner`),不会展示其他人的任务
|
|
@@ -16,9 +17,10 @@ DeepSeek Harness(DSH)内的 **TAPD 任务看板** 插件:在客户端侧
|
|
|
16
17
|
- AI 对话闭环:详情中一键复制带任务上下文的 DeepSeek 执行提示,Agent 可使用 TAPD 工具直接读取、改状态和评论
|
|
17
18
|
- 定时执行闭环(自动):在工作项详情中直接选择执行时间和该任务的 DSH 执行工作区,插件自动创建会话并注册 DSH 原生 schedule,到点自动唤醒 Agent 用 TAPD 工具执行(无需手动复制请求);会话标题固定为 `<type>#<id>`(如 `story#1018732`、`task#1018732`、`bug#1018732`),不再显示「未知」,便于在会话列表中按任务编号定位;TAPD 工作区只表示任务登记归属,不作为所有任务的统一执行空间;每条任务可独立选择已登记的 DSH 工作区(绑定代码工程),也可在详情中登记新的代码工程工作区,未选择时使用默认空间;已创建的自动执行可通过 `deleteSchedule` 取消
|
|
18
19
|
- 多工作区:配置 `TAPD_WORKSPACE_IDS`(逗号分隔)时,头部出现工作区下拉框,可切换查看不同空间的任务
|
|
19
|
-
- 新建工作项:支持**需求 / 任务 /
|
|
20
|
+
- 新建工作项:支持**需求 / 任务 / 缺陷**三种类型;模板可选两类——**本地模板**(在设置页自己维护,存于 profile 配置,AI 也可用)与 **TAPD 平台模板**(读取 `template_list` / `get_default_story_template`);描述在纯文本与 TAPD HTML 之间自动互转
|
|
20
21
|
- 首次使用引导:首次打开自动弹出使用说明弹窗(TAPD 配置步骤、快速上手手册、Token 状态),随时点「设置」可再次查看
|
|
21
|
-
-
|
|
22
|
+
- 本地创建模板:设置页「本地创建模板」可新增/编辑/删除(名称、适用类型、标题前缀、描述骨架、默认处理人、默认优先级、设为默认),保存在 `tapd-board-config.json`;AI 通过 `tapd_board_templates` 读取,`tapd_board_create_item` / `tapd_board_create_story` 带 `template` 参数使用
|
|
23
|
+
- 7 个 Agent 工具:`tapd_board_list` / `tapd_board_get` / `tapd_board_move` / `tapd_board_comment` / `tapd_board_templates` / `tapd_board_create_item` / `tapd_board_create_story`
|
|
22
24
|
- Host 权威缓存:`/api/tapd-board/state` + `/api/tapd-board/action`,同源护栏
|
|
23
25
|
|
|
24
26
|
## 数据面(TAPD OpenAPI)
|
|
@@ -104,7 +106,7 @@ dsh-task-board-tapd
|
|
|
104
106
|
├── service.js # 看板服务:快照/刷新/动作/详情 + checkVersion/updatePlugin
|
|
105
107
|
├── routes.js # /api/tapd-board/state|action|attachment + 同源护栏
|
|
106
108
|
├── config.js # profile 级非敏感设置持久化
|
|
107
|
-
└── tools.js #
|
|
109
|
+
└── tools.js # 7 个 Agent 工具
|
|
108
110
|
```
|
|
109
111
|
|
|
110
112
|
## 验证
|
package/client.js
CHANGED
|
@@ -34,7 +34,7 @@ window.__ModuleLoader__.load({
|
|
|
34
34
|
detail: '详情', close: '关闭', move: '改状态', save: '保存', commentPlaceholder: '输入评论…', comment: '评论', comments: '评论', empty: '暂无数据', noResult: '没有匹配的工作项',
|
|
35
35
|
create: { title: '新建工作项', name: '标题', description: '描述', owner: '处理人', priority: '优先级', create: '创建', cancel: '取消', template: '创建模板', templateNone: '(不使用模板)', type: '类型' },
|
|
36
36
|
priorityLabel: { '1': '高', '2': '中', '3': '低' },
|
|
37
|
-
loading: '正在刷新 TAPD…', updated: '已更新于', settings: '设置', setupTitle: 'TAPD / AI 设置', saveSettings: '保存设置', tokenReady: 'Token 已配置', tokenMissing: '缺少 Token', setupDocs: '首次使用:请在系统环境变量中配置 TAPD_TOKEN、TAPD_WORKSPACE_ID(或 TAPD_WORKSPACE_IDS)、TAPD_API_ENDPOINT,保存后点击刷新。', scheduleHint: '定时执行:在工作项详情中直接选择执行时间;到点会自动创建独立会话并由 Agent 使用 TAPD 工具处理。', aiSection: 'AI 执行(DeepSeek)', chatHint: '复制下方的执行提示,粘贴到任意 DeepSeek 对话中即可让客户端直接处理这条任务(Agent 具备 tapd_board_* 工具,可读详情、改状态、评论、建需求)。', copyPrompt: '复制执行提示', copied: '已复制,可粘贴到对话中直接执行', scheduleSection: '定时执行', scheduleViaChat: '选择时间后,插件会创建独立会话;到点自动唤醒 Agent 执行 TAPD 任务。', scheduleAtLabel: '执行时间', scheduleCreate: '创建自动任务', scheduleCreated: '已创建自动执行任务', scheduleUnavailable: '当前 DSH 未启用定时服务', workspacePathsLabel: 'TAPD 工作区 → DSH 执行工作区', workspacePathPlaceholder: '选择本地目录(如项目根目录)', workspacePathPick: '选择目录', workspacePathNone: '未选择执行工作区,将在默认空间执行', workspaceRegisterHint: '执行空间是当前任务的独立设置;可选择已登记的 DSH 工作区,或登记新的代码工程工作区。', workspacePathHint: '为每个 TAPD 工作区(任务登记的空间)绑定一个 DSH 工作区(任务执行的空间,绑定代码工程目录)。绑定后,该工作区的定时任务到点会自动在该 DSH 工作区打开会话,Agent 可直接读写对应代码工程;未绑定的工作区使用默认空间。可点「登记新工作区」用系统目录选择器把本地项目目录登记为 DSH 工作区。', workspacePathOverride: '执行空间目录(可选)', runInSpace: '执行空间', workspaceBindDefault: '(默认空间)', workspaceRegisterNew: '登记新工作区', workspaceRegistered: '已登记并绑定', workspaceNoRegistry: '当前 DSH 无已登记的工作区', endpointLabel: 'API 端点', workspaceIdsLabel: '工作区 ID(逗号分隔)', refreshSecondsLabel: '自动刷新间隔(秒)', listLimitLabel: '每类型条数上限', modelLabel: '默认模型(provider/model)', announceLabel: '向 Agent 声明本插件工具(对话可操作 TAPD)', error: '出错了', retry: '重试', deleting: '', unknown: '其他', templateUnavailable: '当前类型无可用创建模板(TAPD 该接口可能未授权)', templateLoading: '加载模板…', welcomeTitle: '欢迎使用 TAPD 看板', welcomeSubtitle: '第一次使用请先完成 TAPD 配置;已配置可跳过。', welcomeConfigTitle: '1. TAPD 配置', welcomeConfigStep1: '在系统环境变量中配置 TAPD_TOKEN(个人 Token,必填)', welcomeConfigStep2: '配置 TAPD_WORKSPACE_ID(单个)或 TAPD_WORKSPACE_IDS(多个,逗号分隔)', welcomeConfigStep3: '可选配置 TAPD_API_ENDPOINT,默认 https://api.tapd.cn;完成后完全退出并重开 DSH', welcomeGuideTitle: '2. 快速上手', welcomeGuideDrag: '拖拽卡片到其他泳道即可修改任务状态', welcomeGuideDetail: '点击卡片查看详情、评论、改状态', welcomeGuideSchedule: '在详情中选择执行时间与工作区,可创建到点自动执行的会话', welcomeGuideAgent: '对话中可用 tapd_board_* 工具读取和操作 TAPD', welcomeOpenSettings: '打开设置', welcomeGotIt: '知道了', help: '帮助',
|
|
37
|
+
loading: '正在刷新 TAPD…', updated: '已更新于', settings: '设置', setupTitle: 'TAPD / AI 设置', saveSettings: '保存设置', tokenReady: 'Token 已配置', tokenMissing: '缺少 Token', setupDocs: '首次使用:请在系统环境变量中配置 TAPD_TOKEN、TAPD_WORKSPACE_ID(或 TAPD_WORKSPACE_IDS)、TAPD_API_ENDPOINT,保存后点击刷新。', scheduleHint: '定时执行:在工作项详情中直接选择执行时间;到点会自动创建独立会话并由 Agent 使用 TAPD 工具处理。', aiSection: 'AI 执行(DeepSeek)', chatHint: '复制下方的执行提示,粘贴到任意 DeepSeek 对话中即可让客户端直接处理这条任务(Agent 具备 tapd_board_* 工具,可读详情、改状态、评论、建需求)。', copyPrompt: '复制执行提示', copied: '已复制,可粘贴到对话中直接执行', scheduleSection: '定时执行', scheduleViaChat: '选择时间后,插件会创建独立会话;到点自动唤醒 Agent 执行 TAPD 任务。', scheduleAtLabel: '执行时间', scheduleCreate: '创建自动任务', scheduleCreated: '已创建自动执行任务', scheduleUnavailable: '当前 DSH 未启用定时服务', workspacePathsLabel: 'TAPD 工作区 → DSH 执行工作区', workspacePathPlaceholder: '选择本地目录(如项目根目录)', workspacePathPick: '选择目录', workspacePathNone: '未选择执行工作区,将在默认空间执行', workspaceRegisterHint: '执行空间是当前任务的独立设置;可选择已登记的 DSH 工作区,或登记新的代码工程工作区。', workspacePathHint: '为每个 TAPD 工作区(任务登记的空间)绑定一个 DSH 工作区(任务执行的空间,绑定代码工程目录)。绑定后,该工作区的定时任务到点会自动在该 DSH 工作区打开会话,Agent 可直接读写对应代码工程;未绑定的工作区使用默认空间。可点「登记新工作区」用系统目录选择器把本地项目目录登记为 DSH 工作区。', workspacePathOverride: '执行空间目录(可选)', runInSpace: '执行空间', workspaceBindDefault: '(默认空间)', workspaceRegisterNew: '登记新工作区', workspaceRegistered: '已登记并绑定', workspaceNoRegistry: '当前 DSH 无已登记的工作区', endpointLabel: 'API 端点', workspaceIdsLabel: '工作区 ID(逗号分隔)', refreshSecondsLabel: '自动刷新间隔(秒)', listLimitLabel: '每类型条数上限', modelLabel: '默认模型(provider/model)', announceLabel: '向 Agent 声明本插件工具(对话可操作 TAPD)', showEmptyLabel: '显示没有任务的空泳道(关闭后只显示有任务的列)', tpl: { title: '本地创建模板', add: '新增模板', edit: '编辑', remove: '删除', empty: '还没有本地模板,点「新增模板」创建(保存在本机,AI 也能用)', name: '模板名称', prefix: '标题前缀(可选,如 [运维] )', desc: '描述骨架(创建时填入描述)', owner: '默认处理人(可选)', priorityNone: '默认优先级(不设置)', setDefault: '设为默认:', defaultTag: '默认', localTemplates: '本地模板', tapdTemplates: 'TAPD 模板', localHint: '本地模板由你在设置页维护,AI 可通过 tapd_board_templates 读取并使用' }, error: '出错了', retry: '重试', deleting: '', unknown: '其他', templateUnavailable: '当前类型无可用创建模板(TAPD 该接口可能未授权)', templateLoading: '加载模板…', welcomeTitle: '欢迎使用 TAPD 看板', welcomeSubtitle: '第一次使用请先完成 TAPD 配置;已配置可跳过。', welcomeConfigTitle: '1. TAPD 配置', welcomeConfigStep1: '在系统环境变量中配置 TAPD_TOKEN(个人 Token,必填)', welcomeConfigStep2: '配置 TAPD_WORKSPACE_ID(单个)或 TAPD_WORKSPACE_IDS(多个,逗号分隔)', welcomeConfigStep3: '可选配置 TAPD_API_ENDPOINT,默认 https://api.tapd.cn;完成后完全退出并重开 DSH', welcomeGuideTitle: '2. 快速上手', welcomeGuideDrag: '拖拽卡片到其他泳道即可修改任务状态', welcomeGuideDetail: '点击卡片查看详情、评论、改状态', welcomeGuideSchedule: '在详情中选择执行时间与工作区,可创建到点自动执行的会话', welcomeGuideAgent: '对话中可用 tapd_board_* 工具读取和操作 TAPD', welcomeOpenSettings: '打开设置', welcomeGotIt: '知道了', help: '帮助',
|
|
38
38
|
},
|
|
39
39
|
en: {
|
|
40
40
|
entry: 'TAPD Board',
|
|
@@ -46,13 +46,41 @@ window.__ModuleLoader__.load({
|
|
|
46
46
|
detail: 'Detail', close: 'Close', move: 'Status', save: 'Save', commentPlaceholder: 'Write a comment…', comment: 'Comment', comments: 'Comments', empty: 'No data', noResult: 'No matching items',
|
|
47
47
|
create: { title: 'New Item', name: 'Title', description: 'Description', owner: 'Owner', priority: 'Priority', create: 'Create', cancel: 'Cancel', template: 'Template', templateNone: '(no template)', type: 'Type' },
|
|
48
48
|
priorityLabel: { '1': 'High', '2': 'Medium', '3': 'Low' },
|
|
49
|
-
loading: 'Refreshing TAPD…', updated: 'Updated', settings: 'Settings', setupTitle: 'TAPD / AI Settings', saveSettings: 'Save', tokenReady: 'Token configured', tokenMissing: 'Token missing', setupDocs: 'First run: configure TAPD_TOKEN, TAPD_WORKSPACE_ID (or TAPD_WORKSPACE_IDS) and TAPD_API_ENDPOINT as env vars, then refresh.', scheduleHint: 'Schedule runs from a story/task/bug detail: pick an execution time, and the plugin creates a dedicated Session that the Agent wakes to process the TAPD item.', aiSection: 'AI execution (DeepSeek)', chatHint: 'Copy the execution prompt and paste it into any DeepSeek chat. The Agent has tapd_board_* tools to read, update, comment, and create TAPD items.', copyPrompt: 'Copy prompt', copied: 'Copied. Paste it into a chat to run', scheduleSection: 'Scheduled execution', scheduleViaChat: 'Pick a time. The plugin creates a dedicated Session and wakes an Agent to execute the TAPD task automatically.', scheduleAtLabel: 'Execution time', scheduleCreate: 'Create automatic task', scheduleCreated: 'Automatic task scheduled', scheduleUnavailable: 'DSH scheduling service is not enabled', workspacePathsLabel: 'TAPD workspace → DSH execution workspace', workspacePathPlaceholder: 'Pick a local directory (e.g. project root)', workspacePathPick: 'Pick directory', workspacePathNone: 'No execution workspace chosen; will run in the default space', workspaceRegisterHint: 'The execution workspace is a per-task setting: pick a registered DSH workspace or register a new code project workspace.', workspacePathHint: 'Bind each TAPD workspace (where tasks are registered) to a DSH workspace (where tasks execute; bound to a code project directory). Scheduled tasks from a bound TAPD workspace then open their Session in that DSH workspace so the Agent can read/write the project; unmapped workspaces run in the default space. Use "Register new space" to register a project directory as a DSH workspace via the native picker.', workspacePathOverride: 'Run directory (optional)', runInSpace: 'Runs in space', workspaceBindDefault: '(default space)', workspaceRegisterNew: 'Register new space', workspaceRegistered: 'Registered and bound', workspaceNoRegistry: 'No DSH workspace registered', endpointLabel: 'API endpoint', workspaceIdsLabel: 'Workspace IDs (comma separated)', refreshSecondsLabel: 'Auto-refresh seconds', listLimitLabel: 'Items per type', modelLabel: 'Default model (provider/model)', announceLabel: 'Announce TAPD tools to the Agent', error: 'Error', retry: 'Retry', deleting: '', unknown: 'Other', templateUnavailable: 'No create template available for this type (TAPD API may be unauthorized)', templateLoading: 'Loading templates…', welcomeTitle: 'Welcome to TAPD Board', welcomeSubtitle: 'On first use, complete the TAPD configuration below. Skip it if already configured.', welcomeConfigTitle: '1. TAPD configuration', welcomeConfigStep1: 'Set env var TAPD_TOKEN (personal token, required)', welcomeConfigStep2: 'Set TAPD_WORKSPACE_ID (single) or TAPD_WORKSPACE_IDS (comma separated)', welcomeConfigStep3: 'Optionally set TAPD_API_ENDPOINT (default https://api.tapd.cn); then fully quit and reopen DSH', welcomeGuideTitle: '2. Quick start', welcomeGuideDrag: 'Drag a card to another lane to change its status', welcomeGuideDetail: 'Click a card to view details, comment, or change status', welcomeGuideSchedule: 'Pick an execution time and workspace in the detail drawer to schedule an auto-run session', welcomeGuideAgent: 'Use tapd_board_* tools in chat to read and operate TAPD', welcomeOpenSettings: 'Open settings', welcomeGotIt: 'Got it', help: 'Help',
|
|
49
|
+
loading: 'Refreshing TAPD…', updated: 'Updated', settings: 'Settings', setupTitle: 'TAPD / AI Settings', saveSettings: 'Save', tokenReady: 'Token configured', tokenMissing: 'Token missing', setupDocs: 'First run: configure TAPD_TOKEN, TAPD_WORKSPACE_ID (or TAPD_WORKSPACE_IDS) and TAPD_API_ENDPOINT as env vars, then refresh.', scheduleHint: 'Schedule runs from a story/task/bug detail: pick an execution time, and the plugin creates a dedicated Session that the Agent wakes to process the TAPD item.', aiSection: 'AI execution (DeepSeek)', chatHint: 'Copy the execution prompt and paste it into any DeepSeek chat. The Agent has tapd_board_* tools to read, update, comment, and create TAPD items.', copyPrompt: 'Copy prompt', copied: 'Copied. Paste it into a chat to run', scheduleSection: 'Scheduled execution', scheduleViaChat: 'Pick a time. The plugin creates a dedicated Session and wakes an Agent to execute the TAPD task automatically.', scheduleAtLabel: 'Execution time', scheduleCreate: 'Create automatic task', scheduleCreated: 'Automatic task scheduled', scheduleUnavailable: 'DSH scheduling service is not enabled', workspacePathsLabel: 'TAPD workspace → DSH execution workspace', workspacePathPlaceholder: 'Pick a local directory (e.g. project root)', workspacePathPick: 'Pick directory', workspacePathNone: 'No execution workspace chosen; will run in the default space', workspaceRegisterHint: 'The execution workspace is a per-task setting: pick a registered DSH workspace or register a new code project workspace.', workspacePathHint: 'Bind each TAPD workspace (where tasks are registered) to a DSH workspace (where tasks execute; bound to a code project directory). Scheduled tasks from a bound TAPD workspace then open their Session in that DSH workspace so the Agent can read/write the project; unmapped workspaces run in the default space. Use "Register new space" to register a project directory as a DSH workspace via the native picker.', workspacePathOverride: 'Run directory (optional)', runInSpace: 'Runs in space', workspaceBindDefault: '(default space)', workspaceRegisterNew: 'Register new space', workspaceRegistered: 'Registered and bound', workspaceNoRegistry: 'No DSH workspace registered', endpointLabel: 'API endpoint', workspaceIdsLabel: 'Workspace IDs (comma separated)', refreshSecondsLabel: 'Auto-refresh seconds', listLimitLabel: 'Items per type', modelLabel: 'Default model (provider/model)', announceLabel: 'Announce TAPD tools to the Agent', error: 'Error', retry: 'Retry', deleting: '', unknown: 'Other', templateUnavailable: 'No create template available for this type (TAPD API may be unauthorized)', templateLoading: 'Loading templates…', welcomeTitle: 'Welcome to TAPD Board', welcomeSubtitle: 'On first use, complete the TAPD configuration below. Skip it if already configured.', welcomeConfigTitle: '1. TAPD configuration', welcomeConfigStep1: 'Set env var TAPD_TOKEN (personal token, required)', welcomeConfigStep2: 'Set TAPD_WORKSPACE_ID (single) or TAPD_WORKSPACE_IDS (comma separated)', welcomeConfigStep3: 'Optionally set TAPD_API_ENDPOINT (default https://api.tapd.cn); then fully quit and reopen DSH', welcomeGuideTitle: '2. Quick start', welcomeGuideDrag: 'Drag a card to another lane to change its status', welcomeGuideDetail: 'Click a card to view details, comment, or change status', welcomeGuideSchedule: 'Pick an execution time and workspace in the detail drawer to schedule an auto-run session', welcomeGuideAgent: 'Use tapd_board_* tools in chat to read and operate TAPD', welcomeOpenSettings: 'Open settings', welcomeGotIt: 'Got it', help: 'Help', showEmptyLabel: 'Show empty lanes (turn off to show only lanes with items)', tpl: { title: 'Local create templates', add: 'New template', edit: 'Edit', remove: 'Delete', empty: 'No local template yet. Click New template (stored locally, also usable by AI)', name: 'Template name', prefix: 'Title prefix (optional, e.g. [Ops] )', desc: 'Description skeleton (filled on create)', owner: 'Default owner (optional)', priorityNone: 'Default priority (none)', setDefault: 'Default for: ', defaultTag: 'Default', localTemplates: 'Local templates', tapdTemplates: 'TAPD templates', localHint: 'Local templates are maintained in settings and readable by AI via tapd_board_templates' },
|
|
50
50
|
},
|
|
51
51
|
}
|
|
52
52
|
const fallback = dicts.zh
|
|
53
53
|
let translate = key => fallback[key]
|
|
54
54
|
let pickDirectory = null
|
|
55
55
|
const TYPE_KEYS = ['story', 'task', 'bug']
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* 泳道排序:TAPD 返回的状态 options 是按物理值字典序(done < status_10 < status_2),
|
|
59
|
+
* 直接渲染会出现「已完成排最左、待受理挤中间」的错乱。这里按**状态显示名的语义**
|
|
60
|
+
* 归入业务阶段,不写死任何物理状态值,因此对各空间自定义状态同样生效。
|
|
61
|
+
*/
|
|
62
|
+
const STATUS_STAGE_HINTS = [
|
|
63
|
+
/待受理|未开始|未处理|待处理|新建|待办|待启动|草稿|申请|提出|待提交/,
|
|
64
|
+
/已受理|已确认|已规划|待规划|待排期|已排期|已立项/,
|
|
65
|
+
/方案|设计|分析|调研|规划中|评估/,
|
|
66
|
+
/实施|开发|进行中|处理中|执行|编码|施工|修复中|推进/,
|
|
67
|
+
/测试|验证|验收|评审|联调|待发布|待上线|回归/,
|
|
68
|
+
/完成|已上线|已发布|已交付|已归档|已实现|已修复|已解决|关闭|结项|通过|成功/,
|
|
69
|
+
/取消|作废|驳回|拒绝|终止|阻塞|挂起|暂停|失败|搁置/,
|
|
70
|
+
]
|
|
71
|
+
/** 返回状态所处业务阶段序号(越小越靠前);无法识别时排到最后。 */
|
|
72
|
+
function statusStage(label, key) {
|
|
73
|
+
const text = String(label || '') || String(key || '')
|
|
74
|
+
for (let index = 0; index < STATUS_STAGE_HINTS.length; index += 1) {
|
|
75
|
+
if (STATUS_STAGE_HINTS[index].test(text)) return index
|
|
76
|
+
}
|
|
77
|
+
return STATUS_STAGE_HINTS.length
|
|
78
|
+
}
|
|
79
|
+
/** 同阶段内用状态值里的数字做稳定次序(status_16 -> 16)。 */
|
|
80
|
+
function statusSeq(key) {
|
|
81
|
+
const matched = String(key || '').match(/(\d+)/)
|
|
82
|
+
return matched ? Number(matched[1]) : Number.MAX_SAFE_INTEGER
|
|
83
|
+
}
|
|
56
84
|
const TYPE_GLYPHS = { story: '📋', task: '✅', bug: '🐛' }
|
|
57
85
|
const STATUS_GLYPHS = { open: '○', done: '●', in_progress: '◐', status_11: '◐', status_4: '●' }
|
|
58
86
|
function typeGlyph(type) { return TYPE_GLYPHS[type] || '•' }
|
|
@@ -259,16 +287,23 @@ window.__ModuleLoader__.load({
|
|
|
259
287
|
if (!buckets.has(key)) buckets.set(key, [])
|
|
260
288
|
buckets.get(key).push(item)
|
|
261
289
|
}
|
|
262
|
-
//
|
|
263
|
-
// 避免切换到状态命名不同的空间时只剩有数据的列、看不到其他泳道。
|
|
290
|
+
// 泳道来自 TAPD 字段配置(支持各空间自定义状态),并追加数据里出现但配置缺失的状态
|
|
264
291
|
const keys = Object.keys(labels || {})
|
|
265
292
|
for (const key of buckets.keys()) if (!keys.includes(key)) keys.push(key)
|
|
266
|
-
|
|
293
|
+
// 按业务阶段排序:待受理 → 已受理 → 方案 → 实施/处理 → 验证/验收 → 完成 → 异常
|
|
294
|
+
const ordered = keys.slice().sort((a, b) => {
|
|
295
|
+
const stageDiff = statusStage(labels[a], a) - statusStage(labels[b], b)
|
|
296
|
+
if (stageDiff !== 0) return stageDiff
|
|
297
|
+
return statusSeq(a) - statusSeq(b)
|
|
298
|
+
})
|
|
299
|
+
const showEmpty = state?.config?.showEmptyColumns !== false
|
|
300
|
+
const visible = showEmpty ? ordered : ordered.filter(key => buckets.has(key))
|
|
301
|
+
return visible.map(key => ({
|
|
267
302
|
key,
|
|
268
303
|
label: key === 'unknown' ? translate('unknown') : (labels[key] || key),
|
|
269
304
|
items: buckets.get(key) || [],
|
|
270
305
|
}))
|
|
271
|
-
}, [filtered, labels])
|
|
306
|
+
}, [filtered, labels, state?.config?.showEmptyColumns])
|
|
272
307
|
|
|
273
308
|
// —— 泳道拖拽改状态(HTML5 DnD)——
|
|
274
309
|
const [draggingItem, setDraggingItem] = useState(null)
|
|
@@ -418,6 +453,9 @@ window.__ModuleLoader__.load({
|
|
|
418
453
|
.tbx-dialog-wide{width:520px}
|
|
419
454
|
.tbx-chip-new{color:#ff4d4f;border-color:#ff4d4f}
|
|
420
455
|
.tbx-welcome-title{font-weight:600;font-size:13px;margin-top:2px}
|
|
456
|
+
.tbx-tplmgr{display:flex;flex-direction:column;gap:8px}
|
|
457
|
+
.tbx-tpl-row{display:flex;align-items:center;gap:8px;padding:6px 8px;border:1px solid var(--dsw-alias-border-l1);border-radius:6px}
|
|
458
|
+
.tbx-tpl-form{display:flex;flex-direction:column;gap:8px;padding:10px;border:1px dashed var(--dsw-alias-border-l2);border-radius:8px;background:linear-gradient(var(--dsw-alias-bg-layer-1),var(--dsw-alias-bg-layer-1)) var(--dsw-alias-bg-layer1-fb,#f5f6f8)}
|
|
421
459
|
.tbx-welcome-step{display:flex;gap:8px;align-items:flex-start;font-size:13px;line-height:1.55}
|
|
422
460
|
.tbx-welcome-num{flex:0 0 18px;height:18px;border-radius:50%;background:color-mix(in srgb,var(--dsw-alias-brand-primary) 14%,transparent);color:var(--dsw-alias-brand-primary);display:flex;align-items:center;justify-content:center;font-size:11px;font-weight:600;margin-top:1px}
|
|
423
461
|
@media (max-width:720px){.tbx-head{padding:10px 12px}.tbx-tabs{padding:0 12px}.tbx-board{padding:12px}.tbx-search{flex:1;width:auto}.tbx-col{flex-basis:calc(100vw - 32px);flex-grow:0;flex-shrink:0;min-width:0}.tbx-drawer{width:100%;max-width:100%;min-width:0}.tbx-select{max-width:160px}}
|
|
@@ -455,8 +493,8 @@ window.__ModuleLoader__.load({
|
|
|
455
493
|
}))
|
|
456
494
|
: h('div', { className: 'tbx-empty' }, query ? translate('noResult') : translate('empty'))),
|
|
457
495
|
selected ? h(DetailDrawer, { item: selected, config: state?.config, statusOptions, fieldsOf: fieldsOf(selected), labels, pickDirectory, onClose: () => setSelected(null), onMove: async (status) => { const result = await runAction('move', { type: selected.type, id: selected.id, status }); if (result?.ok) setSelected(null) }, onComment: (content) => runAction('comment', { type: selected.type, id: selected.id, content }), onSchedule: payload => runAction('scheduleTask', payload), onRegisterWorkspace: (path) => runAction('registerWorkspace', { path }) }) : null,
|
|
458
|
-
createOpen ? h(CreateDialog, { labels, ownerDefault: state?.user?.name || '', onCancel: () => setCreateOpen(false), onCreate: (input) => runAction('createItem', input).then(() => setCreateOpen(false)) }) : null,
|
|
459
|
-
settingsOpen ? h(SettingsDialog, { config: state?.config, settings: state?.settings, onClose: () => setSettingsOpen(false), onSave: payload => runAction('saveSettings', payload).then(() => setSettingsOpen(false)) }) : null,
|
|
496
|
+
createOpen ? h(CreateDialog, { labels, ownerDefault: state?.user?.name || '', localTemplates: state?.templates || [], onCancel: () => setCreateOpen(false), onCreate: (input) => runAction('createItem', input).then(() => setCreateOpen(false)) }) : null,
|
|
497
|
+
settingsOpen ? h(SettingsDialog, { config: state?.config, settings: state?.settings, templates: state?.templates || [], onClose: () => setSettingsOpen(false), onSave: payload => runAction('saveSettings', payload).then(() => setSettingsOpen(false)), onSaveTemplate: payload => runAction('saveTemplate', payload), onDeleteTemplate: id => runAction('deleteTemplate', { id }) }) : null,
|
|
460
498
|
aboutOpen ? h(WelcomeDialog, { settings: state?.settings, onClose: () => { setAboutOpen(false); try { localStorage.setItem('tapd-task-board:welcome-v1', '1') } catch { /* 忽略 */ } }, onOpenSettings: () => { setAboutOpen(false); setSettingsOpen(true) } }) : null)
|
|
461
499
|
}
|
|
462
500
|
|
|
@@ -558,8 +596,8 @@ window.__ModuleLoader__.load({
|
|
|
558
596
|
h('button', { className: 'tbx-btn', onClick: () => { if (comment.trim()) { onComment(comment); setComment('') } }, type: 'button', disabled: !comment.trim() }, translate('comment'))))))
|
|
559
597
|
}
|
|
560
598
|
|
|
561
|
-
/** New-
|
|
562
|
-
function CreateDialog({ labels, ownerDefault, onCancel, onCreate, initialType = 'story' }) {
|
|
599
|
+
/** New-item dialog:支持 需求/任务/缺陷,模板可选「本地模板」或「TAPD 模板」。 */
|
|
600
|
+
function CreateDialog({ labels, ownerDefault, onCancel, onCreate, initialType = 'story', localTemplates = [] }) {
|
|
563
601
|
const c = translate('create')
|
|
564
602
|
const [type, setType] = useState(initialType)
|
|
565
603
|
const [name, setName] = useState('')
|
|
@@ -567,9 +605,11 @@ window.__ModuleLoader__.load({
|
|
|
567
605
|
const [owner, setOwner] = useState(ownerDefault)
|
|
568
606
|
const [priority, setPriority] = useState('2')
|
|
569
607
|
const [templates, setTemplates] = useState([])
|
|
570
|
-
const [
|
|
608
|
+
const [templateValue, setTemplateValue] = useState('')
|
|
609
|
+
const [localTemplateName, setLocalTemplateName] = useState('')
|
|
571
610
|
const [templateNote, setTemplateNote] = useState('')
|
|
572
611
|
const [templateBusy, setTemplateBusy] = useState(false)
|
|
612
|
+
const availableLocal = (localTemplates || []).filter(template => (template.types || []).includes(type))
|
|
573
613
|
|
|
574
614
|
// 选择模板后按 TAPD 模板字段默认值预填表单
|
|
575
615
|
const applyTemplate = useCallback(async (id) => {
|
|
@@ -592,7 +632,35 @@ window.__ModuleLoader__.load({
|
|
|
592
632
|
} catch { /* 模板字段不可用时不阻断创建 */ } finally { setTemplateBusy(false) }
|
|
593
633
|
}, [type])
|
|
594
634
|
|
|
595
|
-
//
|
|
635
|
+
// 选择模板:本地模板直接预填本机字段;TAPD 模板拉取字段默认值
|
|
636
|
+
const selectTemplate = useCallback((value) => {
|
|
637
|
+
setTemplateValue(value)
|
|
638
|
+
if (value.startsWith('local:')) {
|
|
639
|
+
const picked = availableLocal.find(template => template.id === value.slice(6))
|
|
640
|
+
setLocalTemplateName(picked?.name || '')
|
|
641
|
+
if (picked?.description) setDescription(picked.description)
|
|
642
|
+
if (picked?.owner) setOwner(picked.owner)
|
|
643
|
+
if (picked?.priority) setPriority(picked.priority)
|
|
644
|
+
setTemplateNote('')
|
|
645
|
+
return
|
|
646
|
+
}
|
|
647
|
+
setLocalTemplateName('')
|
|
648
|
+
if (value.startsWith('tapd:')) applyTemplate(value.slice(5))
|
|
649
|
+
}, [availableLocal, applyTemplate])
|
|
650
|
+
|
|
651
|
+
// 默认模板优先级:本地模板的 defaultFor > TAPD 默认模板
|
|
652
|
+
const initRef = useRef('')
|
|
653
|
+
useEffect(() => {
|
|
654
|
+
const key = `${type}|${availableLocal.length}|${templates.length}`
|
|
655
|
+
if (initRef.current === key) return
|
|
656
|
+
initRef.current = key
|
|
657
|
+
const localDefault = availableLocal.find(template => (template.defaultFor || []).includes(type))
|
|
658
|
+
if (localDefault) { selectTemplate(`local:${localDefault.id}`); return }
|
|
659
|
+
const tapdDefault = templates.find(template => template.isDefault) || templates[0]
|
|
660
|
+
if (tapdDefault) selectTemplate(`tapd:${tapdDefault.id}`)
|
|
661
|
+
}, [type, availableLocal, templates, selectTemplate])
|
|
662
|
+
|
|
663
|
+
// 打开弹窗时加载 TAPD 模板列表(不可用时仅提示,不影响本地模板)
|
|
596
664
|
useEffect(() => {
|
|
597
665
|
let cancelled = false
|
|
598
666
|
;(async () => {
|
|
@@ -605,20 +673,13 @@ window.__ModuleLoader__.load({
|
|
|
605
673
|
setTemplates(list)
|
|
606
674
|
if (result.templateError) setTemplateNote(result.templateError)
|
|
607
675
|
else if (!list.length) setTemplateNote(translate('templateUnavailable'))
|
|
608
|
-
else {
|
|
609
|
-
const preset = list.find(item => item.isDefault) || list[0]
|
|
610
|
-
setTemplateId(preset.id)
|
|
611
|
-
applyTemplate(preset.id)
|
|
612
|
-
}
|
|
613
676
|
} else setTemplateNote(result?.error || '')
|
|
614
677
|
} catch (error) {
|
|
615
678
|
if (!cancelled) setTemplateNote(error instanceof Error ? error.message : String(error))
|
|
616
679
|
} finally { if (!cancelled) setTemplateBusy(false) }
|
|
617
680
|
})()
|
|
618
681
|
return () => { cancelled = true }
|
|
619
|
-
}, [type
|
|
620
|
-
|
|
621
|
-
const selectTemplate = (id) => { setTemplateId(id); if (id) applyTemplate(id) }
|
|
682
|
+
}, [type])
|
|
622
683
|
|
|
623
684
|
return h('div', { className: 'tbx-dialog', onClick: event => { if (event.target === event.currentTarget) onCancel() } },
|
|
624
685
|
h('div', { className: 'tbx-dialog-box' },
|
|
@@ -629,9 +690,16 @@ window.__ModuleLoader__.load({
|
|
|
629
690
|
TYPE_KEYS.map(key => h('option', { key, value: key }, translate(key))))),
|
|
630
691
|
h('label', { className: 'tbx-field' },
|
|
631
692
|
h('span', { className: 'tbx-field-k' }, c.template),
|
|
632
|
-
h('select', { className: 'tbx-input', value:
|
|
693
|
+
h('select', { className: 'tbx-input', value: templateValue, onChange: event => selectTemplate(event.target.value) },
|
|
633
694
|
h('option', { value: '' }, c.templateNone),
|
|
634
|
-
|
|
695
|
+
availableLocal.length
|
|
696
|
+
? h('optgroup', { label: translate('tpl').localTemplates },
|
|
697
|
+
availableLocal.map(template => h('option', { key: `local:${template.id}`, value: `local:${template.id}` }, template.name)))
|
|
698
|
+
: null,
|
|
699
|
+
templates.length
|
|
700
|
+
? h('optgroup', { label: translate('tpl').tapdTemplates },
|
|
701
|
+
templates.map(template => h('option', { key: `tapd:${template.id}`, value: `tapd:${template.id}` }, template.isDefault ? `${template.name} ★` : template.name)))
|
|
702
|
+
: null)),
|
|
635
703
|
templateNote ? h('span', { className: 'tbx-note' }, templateNote) : null,
|
|
636
704
|
h('input', { className: 'tbx-input', placeholder: c.name, value: name, onChange: event => setName(event.target.value) }),
|
|
637
705
|
h('textarea', { className: 'tbx-textarea', placeholder: c.description, value: description, onChange: event => setDescription(event.target.value) }),
|
|
@@ -639,7 +707,7 @@ window.__ModuleLoader__.load({
|
|
|
639
707
|
h('div', { className: 'tbx-row' }, h('select', { className: 'tbx-input', value: priority, onChange: event => setPriority(event.target.value) }, ['1', '2', '3'].map(p => h('option', { key: p, value: p }, `${c.priority} ${p}`)))),
|
|
640
708
|
h('div', { className: 'tbx-row', style: { justifyContent: 'flex-end' } },
|
|
641
709
|
h('button', { className: 'tbx-btn', onClick: onCancel, type: 'button' }, c.cancel),
|
|
642
|
-
h('button', { className: 'tbx-btn primary', onClick: () => { if (name.trim()) onCreate({ type, name: name.trim(), description: textToHtml(description), owner: owner.trim(), priority }) }, type: 'button', disabled: !name.trim() }, c.create))))
|
|
710
|
+
h('button', { className: 'tbx-btn primary', onClick: () => { if (name.trim()) onCreate({ type, name: name.trim(), description: textToHtml(description), owner: owner.trim(), priority, template: localTemplateName || undefined }) }, type: 'button', disabled: !name.trim() }, c.create))))
|
|
643
711
|
}
|
|
644
712
|
|
|
645
713
|
/** 首次打开时的使用说明弹窗:TAPD 配置引导 + 快速上手。 */
|
|
@@ -667,14 +735,72 @@ window.__ModuleLoader__.load({
|
|
|
667
735
|
h('button', { className: 'tbx-btn primary', onClick: onClose, type: 'button' }, translate('welcomeGotIt')))))
|
|
668
736
|
}
|
|
669
737
|
|
|
738
|
+
/**
|
|
739
|
+
* 本地创建模板管理:用户自己维护,存在 tapd-board-config.json。
|
|
740
|
+
* 与 TAPD 平台模板互相独立;AI 通过 tapd_board_templates / tapd_board_create_item 使用同一份数据。
|
|
741
|
+
*/
|
|
742
|
+
function TemplateManager({ templates, onSave, onDelete }) {
|
|
743
|
+
const t = translate('tpl')
|
|
744
|
+
const [draft, setDraft] = useState(null)
|
|
745
|
+
const blank = () => ({ id: '', name: '', types: ['story'], titlePrefix: '', description: '', owner: '', priority: '', defaultFor: [] })
|
|
746
|
+
const toggle = (field, key) => setDraft(current => {
|
|
747
|
+
if (!current) return current
|
|
748
|
+
const list = Array.isArray(current[field]) ? current[field] : []
|
|
749
|
+
const next = list.includes(key) ? list.filter(item => item !== key) : [...list, key]
|
|
750
|
+
const patch = { [field]: next }
|
|
751
|
+
if (field === 'types') patch.defaultFor = (current.defaultFor || []).filter(item => next.includes(item))
|
|
752
|
+
return { ...current, ...patch }
|
|
753
|
+
})
|
|
754
|
+
const submit = () => {
|
|
755
|
+
if (!draft || !draft.name.trim()) return
|
|
756
|
+
onSave({ ...draft, name: draft.name.trim(), types: draft.types.length ? draft.types : ['story'] })
|
|
757
|
+
setDraft(null)
|
|
758
|
+
}
|
|
759
|
+
return h('div', { className: 'tbx-tplmgr' },
|
|
760
|
+
h('div', { className: 'tbx-row' },
|
|
761
|
+
h('span', { className: 'tbx-field-k' }, t.title),
|
|
762
|
+
h('span', { className: 'tbx-spacer' }),
|
|
763
|
+
h('button', { className: 'tbx-btn', onClick: () => setDraft(blank()), type: 'button' }, '+ ', t.add)),
|
|
764
|
+
h('span', { className: 'tbx-note' }, t.localHint),
|
|
765
|
+
(templates || []).length
|
|
766
|
+
? (templates || []).map(item => h('div', { key: item.id, className: 'tbx-tpl-row' },
|
|
767
|
+
h('span', { className: 'tbx-field-v' }, item.name),
|
|
768
|
+
h('span', { className: 'tbx-chip' }, (item.types || []).map(type => translate(type)).join(' / ')),
|
|
769
|
+
(item.defaultFor || []).length ? h('span', { className: 'tbx-chip' }, t.defaultTag) : null,
|
|
770
|
+
h('span', { className: 'tbx-spacer' }),
|
|
771
|
+
h('button', { className: 'tbx-btn', onClick: () => setDraft({ ...blank(), ...item }), type: 'button' }, t.edit),
|
|
772
|
+
h('button', { className: 'tbx-btn', onClick: () => onDelete(item.id), type: 'button' }, t.remove)))
|
|
773
|
+
: h('span', { className: 'tbx-note' }, t.empty),
|
|
774
|
+
draft ? h('div', { className: 'tbx-tpl-form' },
|
|
775
|
+
h('input', { className: 'tbx-input', placeholder: t.name, value: draft.name, onChange: event => setDraft({ ...draft, name: event.target.value }) }),
|
|
776
|
+
h('div', { className: 'tbx-row' }, TYPE_KEYS.map(type => h('label', { key: type, className: 'tbx-check' },
|
|
777
|
+
h('input', { type: 'checkbox', checked: (draft.types || []).includes(type), onChange: () => toggle('types', type) }),
|
|
778
|
+
h('span', {}, translate(type))))),
|
|
779
|
+
h('input', { className: 'tbx-input', placeholder: t.prefix, value: draft.titlePrefix, onChange: event => setDraft({ ...draft, titlePrefix: event.target.value }) }),
|
|
780
|
+
h('textarea', { className: 'tbx-textarea', placeholder: t.desc, value: draft.description, onChange: event => setDraft({ ...draft, description: event.target.value }) }),
|
|
781
|
+
h('div', { className: 'tbx-row' },
|
|
782
|
+
h('input', { className: 'tbx-input', placeholder: t.owner, value: draft.owner, onChange: event => setDraft({ ...draft, owner: event.target.value }) }),
|
|
783
|
+
h('select', { className: 'tbx-input', value: draft.priority, onChange: event => setDraft({ ...draft, priority: event.target.value }) },
|
|
784
|
+
h('option', { value: '' }, t.priorityNone),
|
|
785
|
+
['1', '2', '3'].map(p => h('option', { key: p, value: p }, `P${p}`)))),
|
|
786
|
+
h('div', { className: 'tbx-row' }, (draft.types || []).map(type => h('label', { key: type, className: 'tbx-check' },
|
|
787
|
+
h('input', { type: 'checkbox', checked: (draft.defaultFor || []).includes(type), onChange: () => toggle('defaultFor', type) }),
|
|
788
|
+
h('span', {}, `${t.setDefault}${translate(type)}`)))),
|
|
789
|
+
h('div', { className: 'tbx-row', style: { justifyContent: 'flex-end' } },
|
|
790
|
+
h('button', { className: 'tbx-btn', onClick: () => setDraft(null), type: 'button' }, translate('create').cancel),
|
|
791
|
+
h('button', { className: 'tbx-btn primary', onClick: submit, type: 'button', disabled: !draft.name.trim() }, translate('save'))))
|
|
792
|
+
: null)
|
|
793
|
+
}
|
|
794
|
+
|
|
670
795
|
/** TAPD / AI settings dialog: connection status, editable overlay config, model + schedule hints. */
|
|
671
|
-
function SettingsDialog({ config, settings, onClose, onSave }) {
|
|
796
|
+
function SettingsDialog({ config, settings, templates, onClose, onSave, onSaveTemplate, onDeleteTemplate }) {
|
|
672
797
|
const [endpoint, setEndpoint] = useState(config?.endpoint || '')
|
|
673
798
|
const [workspaceIds, setWorkspaceIds] = useState((config?.workspaceIds || []).join(','))
|
|
674
799
|
const [refreshSeconds, setRefreshSeconds] = useState(String(config?.refreshSeconds ?? 300))
|
|
675
800
|
const [listLimit, setListLimit] = useState(String(config?.listLimit ?? 200))
|
|
676
801
|
const [model, setModel] = useState(config?.model || '')
|
|
677
|
-
const [announce, setAnnounce] = useState(Boolean(config?.announceToAgent))
|
|
802
|
+
const [announce, setAnnounce] = useState(Boolean(config?.announceToAgent))
|
|
803
|
+
const [showEmpty, setShowEmpty] = useState(config?.showEmptyColumns !== false)
|
|
678
804
|
const ready = settings?.tokenConfigured
|
|
679
805
|
const statusText = ready === undefined ? translate('loading') : ready ? '✅ ' + translate('tokenReady') : '⚠️ ' + translate('tokenMissing')
|
|
680
806
|
const statusClass = ready === undefined ? '' : ready ? ' ok' : ' err'
|
|
@@ -689,11 +815,14 @@ window.__ModuleLoader__.load({
|
|
|
689
815
|
h('label', { className: 'tbx-field tbx-grow' }, h('span', { className: 'tbx-field-k' }, translate('refreshSecondsLabel')), h('input', { className: 'tbx-input', type: 'number', min: 30, value: refreshSeconds, onChange: event => setRefreshSeconds(event.target.value) })),
|
|
690
816
|
h('label', { className: 'tbx-field tbx-grow' }, h('span', { className: 'tbx-field-k' }, translate('listLimitLabel')), h('input', { className: 'tbx-input', type: 'number', min: 20, max: 200, value: listLimit, onChange: event => setListLimit(event.target.value) }))),
|
|
691
817
|
h('label', { className: 'tbx-field' }, h('span', { className: 'tbx-field-k' }, translate('modelLabel')), h('input', { className: 'tbx-input', value: model, onChange: event => setModel(event.target.value), placeholder: 'deepseek/deepseek-chat' })),
|
|
692
|
-
h('label', { className: 'tbx-field tbx-check' }, h('input', { type: 'checkbox', checked: announce, onChange: event => setAnnounce(event.target.checked) }), h('span', {}, translate('announceLabel'))),
|
|
818
|
+
h('label', { className: 'tbx-field tbx-check' }, h('input', { type: 'checkbox', checked: announce, onChange: event => setAnnounce(event.target.checked) }), h('span', {}, translate('announceLabel'))),
|
|
819
|
+
h('label', { className: 'tbx-field tbx-check' }, h('input', { type: 'checkbox', checked: showEmpty, onChange: event => setShowEmpty(event.target.checked) }), h('span', {}, translate('showEmptyLabel'))),
|
|
693
820
|
h('span', { className: 'tbx-note' }, translate('scheduleHint')),
|
|
821
|
+
h('div', { style: { borderTop: '1px solid var(--dsw-alias-border-l1)', paddingTop: 12 } },
|
|
822
|
+
h(TemplateManager, { templates, onSave: onSaveTemplate, onDelete: onDeleteTemplate })),
|
|
694
823
|
h('div', { className: 'tbx-row', style: { justifyContent: 'flex-end' } },
|
|
695
824
|
h('button', { className: 'tbx-btn', onClick: onClose, type: 'button' }, translate('close')),
|
|
696
|
-
h('button', { className: 'tbx-btn primary', onClick: () => onSave({ endpoint: endpoint.trim(), workspaceIds, refreshSeconds: Number(refreshSeconds) || 300, listLimit: Number(listLimit) || 200, model: model.trim(), announceToAgent: announce }), type: 'button' }, translate('saveSettings')))))
|
|
825
|
+
h('button', { className: 'tbx-btn primary', onClick: () => onSave({ endpoint: endpoint.trim(), workspaceIds, refreshSeconds: Number(refreshSeconds) || 300, listLimit: Number(listLimit) || 200, model: model.trim(), announceToAgent: announce, showEmptyColumns: showEmpty }), type: 'button' }, translate('saveSettings')))))
|
|
697
826
|
}
|
|
698
827
|
|
|
699
828
|
return {
|
package/package.json
CHANGED
package/src/host/service.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
|
|
2
|
+
import { saveConfig } from './config.js'
|
|
3
|
+
|
|
2
4
|
function shortId(id) { const s = String(id || ''); return s.length > 7 ? s.slice(-7) : s }
|
|
3
5
|
function cleanOwner(value) { return String(value || '').replace(/;+/g, ', ').replace(/^,\s*|,\s*$/g, '') }
|
|
4
6
|
function urlFor(type, workspaceId, id) {
|
|
@@ -30,7 +32,77 @@ export class TapdBoardService {
|
|
|
30
32
|
this.generation = 0
|
|
31
33
|
}
|
|
32
34
|
|
|
33
|
-
snapshot() { return this.state || { revision: 0, workspaceId: this.client.workspaceId, items: { story: [], task: [], bug: [] }, statuses: this.statuses, config: this.viewConfig(), runs: [], settings: this.settingsSnapshot() } }
|
|
35
|
+
snapshot() { return this.state || { revision: 0, workspaceId: this.client.workspaceId, items: { story: [], task: [], bug: [] }, statuses: this.statuses, config: this.viewConfig(), runs: [], settings: this.settingsSnapshot(), templates: this.templatesSnapshot() } }
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* 本地创建模板(用户自己维护,与 TAPD 平台模板互不影响)。
|
|
39
|
+
* 存于 profile 的 tapd-board-config.json → templates[],AI 工具与 UI 共用同一份数据。
|
|
40
|
+
*/
|
|
41
|
+
templatesSnapshot() {
|
|
42
|
+
const list = Array.isArray(this.config.templates) ? this.config.templates : []
|
|
43
|
+
return list.map(template => ({
|
|
44
|
+
id: String(template.id || ''),
|
|
45
|
+
name: String(template.name || ''),
|
|
46
|
+
types: Array.isArray(template.types) ? template.types.filter(type => ['story', 'task', 'bug'].includes(type)) : ['story'],
|
|
47
|
+
titlePrefix: String(template.titlePrefix || ''),
|
|
48
|
+
description: String(template.description || ''),
|
|
49
|
+
owner: String(template.owner || ''),
|
|
50
|
+
priority: String(template.priority || ''),
|
|
51
|
+
defaultFor: Array.isArray(template.defaultFor) ? template.defaultFor : [],
|
|
52
|
+
updatedAt: String(template.updatedAt || ''),
|
|
53
|
+
}))
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/** 按 id 或名称解析本地模板。 */
|
|
57
|
+
resolveTemplate(ref) {
|
|
58
|
+
const key = String(ref || '').trim()
|
|
59
|
+
if (!key) return undefined
|
|
60
|
+
const list = this.templatesSnapshot()
|
|
61
|
+
return list.find(item => item.id === key)
|
|
62
|
+
|| list.find(item => item.name === key)
|
|
63
|
+
|| list.find(item => item.name.toLowerCase() === key.toLowerCase())
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
async saveTemplate(payload = {}) {
|
|
67
|
+
const name = String(payload.name || '').trim()
|
|
68
|
+
if (!name) throw new Error('模板名称不能为空')
|
|
69
|
+
const types = (Array.isArray(payload.types) ? payload.types : ['story'])
|
|
70
|
+
.map(type => String(type).trim())
|
|
71
|
+
.filter(type => ['story', 'task', 'bug'].includes(type))
|
|
72
|
+
if (!types.length) throw new Error('模板适用类型至少要选一个(story / task / bug)')
|
|
73
|
+
const defaultFor = (Array.isArray(payload.defaultFor) ? payload.defaultFor : [])
|
|
74
|
+
.map(type => String(type).trim())
|
|
75
|
+
.filter(type => types.includes(type))
|
|
76
|
+
const id = String(payload.id || '').trim() || `tpl_${Date.now().toString(36)}${Math.random().toString(36).slice(2, 6)}`
|
|
77
|
+
const next = {
|
|
78
|
+
id,
|
|
79
|
+
name,
|
|
80
|
+
types,
|
|
81
|
+
titlePrefix: String(payload.titlePrefix || ''),
|
|
82
|
+
description: String(payload.description || ''),
|
|
83
|
+
owner: String(payload.owner || '').trim(),
|
|
84
|
+
priority: String(payload.priority || '').trim(),
|
|
85
|
+
defaultFor,
|
|
86
|
+
updatedAt: new Date().toISOString(),
|
|
87
|
+
}
|
|
88
|
+
const list = Array.isArray(this.config.templates) ? [...this.config.templates] : []
|
|
89
|
+
const index = list.findIndex(template => String(template?.id || '') === id)
|
|
90
|
+
if (index >= 0) list[index] = next
|
|
91
|
+
else list.push(next)
|
|
92
|
+
this.config = saveConfig({ templates: list })
|
|
93
|
+
if (this.state) this.state.templates = this.templatesSnapshot()
|
|
94
|
+
return { ...this.snapshot(), savedTemplate: next, templates: this.templatesSnapshot() }
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
async deleteTemplate(payload = {}) {
|
|
98
|
+
const id = String(payload.id || '').trim()
|
|
99
|
+
if (!id) throw new Error('deleteTemplate 需要模板 id')
|
|
100
|
+
const list = (Array.isArray(this.config.templates) ? this.config.templates : [])
|
|
101
|
+
.filter(template => String(template?.id || '') !== id)
|
|
102
|
+
this.config = saveConfig({ templates: list })
|
|
103
|
+
if (this.state) this.state.templates = this.templatesSnapshot()
|
|
104
|
+
return { ...this.snapshot(), deleted: id, templates: this.templatesSnapshot() }
|
|
105
|
+
}
|
|
34
106
|
workspaceRegistry() {
|
|
35
107
|
try { return this.ctx.get && this.ctx.get('workspaceRegistry') } catch { return undefined }
|
|
36
108
|
}
|
|
@@ -41,7 +113,7 @@ export class TapdBoardService {
|
|
|
41
113
|
return registry.list().map(ws => ({ id: String(ws.id || ''), title: String(ws.title || ''), path: String(ws.path || '') }))
|
|
42
114
|
} catch { return [] }
|
|
43
115
|
}
|
|
44
|
-
viewConfig() { return { refreshSeconds: Number(this.config.refreshSeconds || 300), listLimit: Number(this.config.listLimit || 200), endpoint: this.client.endpoint, mineOnly: this.mineOnly, allowShowAll: this.allowShowAll, owner: this.owner || (this.mineOnly && this.user ? this.user.name : ''), workspaceId: this.client.workspaceId, workspaceIds: this.client.workspaceIds, workspacePaths: this.config.workspacePaths || {}, workspaceBindings: this.config.workspaceBindings || {}, dshWorkspaces: this.dshWorkspaces(), model: String(this.config.model || ''), allowAiHandoff: this.config.allowAiHandoff !== false, announceToAgent: this.config.announceToAgent === true, scheduleAvailable: Boolean(this.ctx.get?.('schedule')) } }
|
|
116
|
+
viewConfig() { return { refreshSeconds: Number(this.config.refreshSeconds || 300), listLimit: Number(this.config.listLimit || 200), endpoint: this.client.endpoint, mineOnly: this.mineOnly, allowShowAll: this.allowShowAll, owner: this.owner || (this.mineOnly && this.user ? this.user.name : ''), workspaceId: this.client.workspaceId, workspaceIds: this.client.workspaceIds, workspacePaths: this.config.workspacePaths || {}, workspaceBindings: this.config.workspaceBindings || {}, dshWorkspaces: this.dshWorkspaces(), model: String(this.config.model || ''), allowAiHandoff: this.config.allowAiHandoff !== false, announceToAgent: this.config.announceToAgent === true, showEmptyColumns: this.config.showEmptyColumns !== false, scheduleAvailable: Boolean(this.ctx.get?.('schedule')) } }
|
|
45
117
|
settingsSnapshot() {
|
|
46
118
|
let tokenConfigured = false
|
|
47
119
|
try { tokenConfigured = Boolean(this.client.token()) } catch { tokenConfigured = false }
|
|
@@ -102,8 +174,8 @@ export class TapdBoardService {
|
|
|
102
174
|
this.revision += 1
|
|
103
175
|
const previousRuns = this.state?.runs || []
|
|
104
176
|
// 刷新期间空间被切换:本次结果属于旧空间,直接丢弃,避免旧泳道/旧任务覆盖新空间
|
|
105
|
-
if (generation !== this.generation) return this.state || { revision: this.revision, workspaceId: this.client.workspaceId, items, statuses: this.statuses, config: this.viewConfig(), runs: previousRuns, settings: this.settingsSnapshot(), errors }
|
|
106
|
-
this.state = { revision: this.revision, fetchedAt: new Date().toISOString(), workspaceId: this.client.workspaceId, user: this.user ? { id: this.user.id, name: this.user.name, email: this.user.user_email || this.user.email } : undefined, statuses: this.statuses, items, config: this.viewConfig(), settings: this.settingsSnapshot(), runs: previousRuns, errors }
|
|
177
|
+
if (generation !== this.generation) return this.state || { revision: this.revision, workspaceId: this.client.workspaceId, items, statuses: this.statuses, config: this.viewConfig(), runs: previousRuns, settings: this.settingsSnapshot(), templates: this.templatesSnapshot(), errors }
|
|
178
|
+
this.state = { revision: this.revision, fetchedAt: new Date().toISOString(), workspaceId: this.client.workspaceId, user: this.user ? { id: this.user.id, name: this.user.name, email: this.user.user_email || this.user.email } : undefined, statuses: this.statuses, items, config: this.viewConfig(), settings: this.settingsSnapshot(), runs: previousRuns, templates: this.templatesSnapshot(), errors }
|
|
107
179
|
return this.state
|
|
108
180
|
}
|
|
109
181
|
|
|
@@ -124,6 +196,7 @@ export class TapdBoardService {
|
|
|
124
196
|
if (payload.listLimit !== undefined) patch.listLimit = Math.min(200, Math.max(20, Number(payload.listLimit) || 200))
|
|
125
197
|
if (payload.model !== undefined) patch.model = String(payload.model || '').trim()
|
|
126
198
|
if (payload.announceToAgent !== undefined) patch.announceToAgent = Boolean(payload.announceToAgent)
|
|
199
|
+
if (payload.showEmptyColumns !== undefined) patch.showEmptyColumns = Boolean(payload.showEmptyColumns)
|
|
127
200
|
if (payload.workspacePaths !== undefined) {
|
|
128
201
|
const raw = payload.workspacePaths && typeof payload.workspacePaths === 'object' ? payload.workspacePaths : {}
|
|
129
202
|
patch.workspacePaths = Object.fromEntries(Object.entries(raw).map(([key, value]) => [String(key).trim(), String(value || '').trim()]).filter(([, value]) => value))
|
|
@@ -169,17 +242,26 @@ export class TapdBoardService {
|
|
|
169
242
|
await this.client.addComment(payload.type, payload.id, String(payload.content).trim(), this.user?.name)
|
|
170
243
|
return this.refresh()
|
|
171
244
|
}
|
|
245
|
+
if (action === 'listTemplates') return { ...this.snapshot(), templates: this.templatesSnapshot() }
|
|
246
|
+
if (action === 'saveTemplate') return this.saveTemplate(payload)
|
|
247
|
+
if (action === 'deleteTemplate') return this.deleteTemplate(payload)
|
|
172
248
|
if (action === 'createItem') {
|
|
173
|
-
// 按类型创建(story / task / bug
|
|
249
|
+
// 按类型创建(story / task / bug)。可带 template(本地模板 id 或名称),
|
|
250
|
+
// 模板提供标题前缀、描述骨架、默认处理人与优先级;显式传入的字段优先。
|
|
174
251
|
const type = String(payload.type || 'story')
|
|
175
252
|
if (!['story', 'task', 'bug'].includes(type)) throw new Error('createItem.type 必须为 story / task / bug')
|
|
176
|
-
|
|
253
|
+
const rawName = String(payload.name || '').trim()
|
|
254
|
+
if (!rawName) throw new Error('标题不能为空')
|
|
255
|
+
const matched = this.resolveTemplate(payload.template || payload.templateId)
|
|
256
|
+
const template = matched && matched.types.includes(type) ? matched : undefined
|
|
257
|
+
const prefix = String(template?.titlePrefix || '')
|
|
258
|
+
const name = prefix && !rawName.startsWith(prefix.trim()) ? `${prefix}${rawName}` : rawName
|
|
177
259
|
const first = this.snapshot().items[type]?.[0]
|
|
178
260
|
await this.client.createItem(type, {
|
|
179
|
-
name
|
|
180
|
-
description: payload.description || '',
|
|
181
|
-
owner: payload.owner || this.user?.name,
|
|
182
|
-
priority: payload.priority,
|
|
261
|
+
name,
|
|
262
|
+
description: payload.description || template?.description || '',
|
|
263
|
+
owner: payload.owner || template?.owner || this.user?.name,
|
|
264
|
+
priority: payload.priority || template?.priority || undefined,
|
|
183
265
|
workitemTypeId: payload.workitemTypeId || (type === 'story' ? this.config.storyWorkitemTypeId : undefined) || first?.workitemTypeId,
|
|
184
266
|
})
|
|
185
267
|
return this.refresh()
|
package/src/host/tools.js
CHANGED
|
@@ -47,12 +47,22 @@ export function registerTools(ctx, service) {
|
|
|
47
47
|
id: { type: 'string', required: true, description: '工作项 ID' },
|
|
48
48
|
content: { type: 'string', required: true, description: '评论内容' },
|
|
49
49
|
}, async args => ({ ok: true, state: await service.apply('comment', args) })),
|
|
50
|
-
tool('
|
|
50
|
+
tool('tapd_board_templates', '列出用户在本机维护的本地创建模板(需求/任务/缺陷)。调用后可按模板名创建任务。', {}, async () => ({ ok: true, templates: service.templatesSnapshot() })),
|
|
51
|
+
tool('tapd_board_create_item', '在 TAPD 中创建工作项(story/task/bug)。可指定本地模板名(先用 tapd_board_templates 查看),模板会提供标题前缀、描述骨架、默认处理人与优先级。', {
|
|
52
|
+
type: { type: 'string', enum: ['story', 'task', 'bug'], required: true, description: '实体类型' },
|
|
53
|
+
name: { type: 'string', required: true, description: '标题(模板前缀会自动补上)' },
|
|
54
|
+
template: { type: 'string', description: '本地模板名称或 id,可省略' },
|
|
55
|
+
description: { type: 'string', description: '描述;省略时使用模板描述骨架' },
|
|
56
|
+
owner: { type: 'string', description: '处理人,默认模板或当前用户' },
|
|
57
|
+
priority: { type: 'string', description: '优先级 1/2/3' },
|
|
58
|
+
}, async args => ({ ok: true, state: await service.apply('createItem', args) })),
|
|
59
|
+
tool('tapd_board_create_story', '在 TAPD 中创建一条需求(Story),创建后进入看板。可指定本地模板(先用 tapd_board_templates 查看)。', {
|
|
51
60
|
name: { type: 'string', required: true, description: '需求标题' },
|
|
52
61
|
description: { type: 'string', description: '需求描述' },
|
|
53
62
|
owner: { type: 'string', description: '处理人,默认当前用户' },
|
|
54
63
|
priority: { type: 'string', description: '优先级 1/2/3' },
|
|
55
|
-
|
|
64
|
+
template: { type: 'string', description: '本地模板名称或 id,可省略' },
|
|
65
|
+
}, async args => ({ ok: true, state: await service.apply('createItem', { ...args, type: 'story' }) })),
|
|
56
66
|
]
|
|
57
67
|
const disposers = []
|
|
58
68
|
for (const definition of defs) { try { const dispose = registry.register(definition); if (typeof dispose === 'function') disposers.push(dispose) } catch (error) { console.warn('[tapd-task-board] tool registration failed', definition.name, error) } }
|