dsh-task-board-tapd 0.5.3 → 0.6.0
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/INSTALL.md +1 -1
- package/README.md +3 -3
- package/client.js +112 -16
- package/package.json +1 -1
- package/src/host/service.js +62 -10
- package/src/host/tapd.js +76 -0
package/INSTALL.md
CHANGED
|
@@ -85,7 +85,7 @@ dsh plugin --profile desktop list
|
|
|
85
85
|
2. 顶部显示「更新于 HH:mm:ss」。
|
|
86
86
|
3. 设置入口可以显示 Token、端点和工作区状态。
|
|
87
87
|
4. 任务详情中出现「AI 执行(DeepSeek)」和「定时执行」。
|
|
88
|
-
5. 看板只显示当前个人 Token
|
|
88
|
+
5. 看板只显示当前个人 Token 对应用户负责的工作项。\n5.1 切换空间后泳道应随该空间的状态配置变化(状态名、数量都跟着 TAPD 走),空状态也保留列。\n5.2 新建工作项可选类型(需求/任务/缺陷)与创建模板,选择模板后标题结构与字段默认值自动预填。
|
|
89
89
|
6. 卡片可拖到其他状态泳道改状态;无写权限时顶部会给出 TAPD 权限开通指引。
|
|
90
90
|
7. 创建自动任务后,对应 DSH 工作区会话标题是 `bug#<id>` / `story#<id>` / `task#<id>` 固定格式,而不是「未知」。
|
|
91
91
|
8. 首次打开看板自动弹出使用说明(配置步骤、快速上手、版本信息);点击头部版本号可再次打开。
|
package/README.md
CHANGED
|
@@ -7,7 +7,7 @@ DeepSeek Harness(DSH)内的 **TAPD 任务看板** 插件:在客户端侧
|
|
|
7
7
|
## 功能
|
|
8
8
|
|
|
9
9
|
- 侧栏面板行 + 主栏看板页(shell 官方座位,非 DOM 接管)
|
|
10
|
-
- 类型页签:需求 / 任务 /
|
|
10
|
+
- 类型页签:需求 / 任务 / 缺陷,泳道**完全来自 TAPD 字段配置**(get_fields_info 返回的状态集合与标签),空状态也保留;切换空间后即使状态命名不同也能正确显示全部泳道,不再依赖任何硬编码状态值
|
|
11
11
|
- 泳道拖拽:把卡片拖到目标状态列即调用 TAPD 更新状态,拖拽中目标列高亮、原卡片半透明;改状态失败时卡片回到原列并在顶部显示错误
|
|
12
12
|
- 默认只显示当前用户在配置工作区内负责的工作项(需求/任务按 `owner`,缺陷按 `current_owner`),不会展示其他人的任务
|
|
13
13
|
- 搜索(标题 / ID)、手动刷新(顶部明确显示「更新于 HH:mm:ss」,刷新时显示进行中,完成后显示已更新时间)、自动轮询(`refreshSeconds`)
|
|
@@ -16,7 +16,7 @@ DeepSeek Harness(DSH)内的 **TAPD 任务看板** 插件:在客户端侧
|
|
|
16
16
|
- AI 对话闭环:详情中一键复制带任务上下文的 DeepSeek 执行提示,Agent 可使用 TAPD 工具直接读取、改状态和评论
|
|
17
17
|
- 定时执行闭环(自动):在工作项详情中直接选择执行时间和该任务的 DSH 执行工作区,插件自动创建会话并注册 DSH 原生 schedule,到点自动唤醒 Agent 用 TAPD 工具执行(无需手动复制请求);会话标题固定为 `<type>#<id>`(如 `story#1018732`、`task#1018732`、`bug#1018732`),不再显示「未知」,便于在会话列表中按任务编号定位;TAPD 工作区只表示任务登记归属,不作为所有任务的统一执行空间;每条任务可独立选择已登记的 DSH 工作区(绑定代码工程),也可在详情中登记新的代码工程工作区,未选择时使用默认空间;已创建的自动执行可通过 `deleteSchedule` 取消
|
|
18
18
|
- 多工作区:配置 `TAPD_WORKSPACE_IDS`(逗号分隔)时,头部出现工作区下拉框,可切换查看不同空间的任务
|
|
19
|
-
-
|
|
19
|
+
- 新建工作项:支持**需求 / 任务 / 缺陷**三种类型,可选择 TAPD 创建模板( emplate_list)自动预填标题结构与字段默认值(get_default_story_template);描述在纯文本与 TAPD HTML 之间自动互转
|
|
20
20
|
- 首次使用引导:首次打开自动弹出使用说明弹窗(TAPD 配置步骤、快速上手手册、当前版本与 Token 状态),随时点头部版本号可再次打开
|
|
21
21
|
- 版本检查与一键更新:打开看板或点击「检查更新」时查询 npm registry 最新版本;有新版本时「设置」按钮显示红点;点击进入设置或使用说明弹窗即可一键更新(更新后重启 DSH 生效)
|
|
22
22
|
- 5 个 Agent 工具:`tapd_board_list` / `tapd_board_get` / `tapd_board_move` / `tapd_board_comment` / `tapd_board_create_story`
|
|
@@ -32,7 +32,7 @@ DeepSeek Harness(DSH)内的 **TAPD 任务看板** 插件:在客户端侧
|
|
|
32
32
|
| 状态目录 | `GET /{entity}s/get_fields_info` | status.options → `值→中文标签` |
|
|
33
33
|
| 状态更新 | `POST /{entity}s`(带 id) | 保存语义,与 tapd-cli 的 `story/bug/task update` 一致;status 物理值(open/status_N) |
|
|
34
34
|
| 评论 | `POST /comments` | entry_type(复数)/entry_id/description/author |
|
|
35
|
-
| 新建需求 | `POST /stories` | name/description/owner/priority/workitem_type_id |
|
|
35
|
+
| 新建需求 | `POST /stories` | name/description/owner/priority/workitem_type_id |\n| 创建模板列表 | `GET /{entity}s/template_list` | id/name/default/sort(tasks 常 403,需降级) |\n| 模板字段默认值 | `GET /{entity}s/get_default_story_template` | field/value/required(仅 story 稳定可用) |
|
|
36
36
|
|
|
37
37
|
## 安装
|
|
38
38
|
|
package/client.js
CHANGED
|
@@ -32,9 +32,9 @@ window.__ModuleLoader__.load({
|
|
|
32
32
|
search: '搜索标题 / ID', newStory: '新建需求', mineOnly: '只看我的', showAll: '全部',
|
|
33
33
|
fields: { status: '状态', owner: '处理人', creator: '创建人', priority: '优先级', due: '截止', begin: '开始', created: '创建时间', modified: '修改时间', module: '模块', severity: '严重程度', reporter: '报告人', iterationId: '迭代', id: 'ID', url: '打开 TAPD' },
|
|
34
34
|
detail: '详情', close: '关闭', move: '改状态', save: '保存', commentPlaceholder: '输入评论…', comment: '评论', comments: '评论', empty: '暂无数据', noResult: '没有匹配的工作项',
|
|
35
|
-
create: { title: '
|
|
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: '其他', welcomeTitle: '欢迎使用 TAPD 看板', welcomeSubtitle: '第一次使用请先完成 TAPD 配置;已配置可跳过。', welcomeVersionLabel: '当前版本', 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', welcomeUpdateTitle: '3. 版本更新', welcomeUpToDate: '已是最新版本', welcomeNewVersion: '发现新版本', welcomeCheckUpdate: '检查更新', welcomeChecking: '正在检查…', welcomeUpdateNow: '立即更新', welcomeUpdating: '正在更新…', welcomeUpdated: '已更新,重启 DSH 后生效', welcomeOpenSettings: '打开设置', welcomeGotIt: '知道了', help: '帮助', versionLabel: '版本', newVersionBadge: '有新版本', currentVersion: '当前版本', latestVersion: '最新版本', checkUpdate: '检查更新', updateNow: '立即更新', updateRestartHint: '更新后需完全退出并重启 DSH 才能生效', versionSection: '版本与更新', updateDone: '已安装新版本', updateFailed: '更新失败', updateError: '检查更新失败',
|
|
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 配置;已配置可跳过。', welcomeVersionLabel: '当前版本', 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', welcomeUpdateTitle: '3. 版本更新', welcomeUpToDate: '已是最新版本', welcomeNewVersion: '发现新版本', welcomeCheckUpdate: '检查更新', welcomeChecking: '正在检查…', welcomeUpdateNow: '立即更新', welcomeUpdating: '正在更新…', welcomeUpdated: '已更新,重启 DSH 后生效', welcomeOpenSettings: '打开设置', welcomeGotIt: '知道了', help: '帮助', versionLabel: '版本', newVersionBadge: '有新版本', currentVersion: '当前版本', latestVersion: '最新版本', checkUpdate: '检查更新', updateNow: '立即更新', updateRestartHint: '更新后需完全退出并重启 DSH 才能生效', versionSection: '版本与更新', updateDone: '已安装新版本', updateFailed: '更新失败', updateError: '检查更新失败',
|
|
38
38
|
},
|
|
39
39
|
en: {
|
|
40
40
|
entry: 'TAPD Board',
|
|
@@ -44,15 +44,14 @@ window.__ModuleLoader__.load({
|
|
|
44
44
|
search: 'Search title / ID', newStory: 'New Story', mineOnly: 'Mine', showAll: 'All',
|
|
45
45
|
fields: { status: 'Status', owner: 'Owner', creator: 'Creator', priority: 'Priority', due: 'Due', begin: 'Start', created: 'Created', modified: 'Modified', module: 'Module', severity: 'Severity', reporter: 'Reporter', iterationId: 'Iteration', id: 'ID', url: 'Open TAPD' },
|
|
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
|
-
create: { title: 'New
|
|
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', welcomeTitle: 'Welcome to TAPD Board', welcomeSubtitle: 'On first use, complete the TAPD configuration below. Skip it if already configured.', welcomeVersionLabel: 'Current version', 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', welcomeUpdateTitle: '3. Updates', welcomeUpToDate: 'Up to date', welcomeNewVersion: 'New version available', welcomeCheckUpdate: 'Check for updates', welcomeChecking: 'Checking…', welcomeUpdateNow: 'Update now', welcomeUpdating: 'Updating…', welcomeUpdated: 'Updated. Restart DSH to apply', welcomeOpenSettings: 'Open settings', welcomeGotIt: 'Got it', help: 'Help', versionLabel: 'Version', newVersionBadge: 'Update available', currentVersion: 'Current version', latestVersion: 'Latest version', checkUpdate: 'Check for updates', updateNow: 'Update now', updateRestartHint: 'Restart DSH fully after updating to apply it', versionSection: 'Version & updates', updateDone: 'New version installed', updateFailed: 'Update failed', updateError: 'Failed to check for updates',
|
|
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.', welcomeVersionLabel: 'Current version', 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', welcomeUpdateTitle: '3. Updates', welcomeUpToDate: 'Up to date', welcomeNewVersion: 'New version available', welcomeCheckUpdate: 'Check for updates', welcomeChecking: 'Checking…', welcomeUpdateNow: 'Update now', welcomeUpdating: 'Updating…', welcomeUpdated: 'Updated. Restart DSH to apply', welcomeOpenSettings: 'Open settings', welcomeGotIt: 'Got it', help: 'Help', versionLabel: 'Version', newVersionBadge: 'Update available', currentVersion: 'Current version', latestVersion: 'Latest version', checkUpdate: 'Check for updates', updateNow: 'Update now', updateRestartHint: 'Restart DSH fully after updating to apply it', versionSection: 'Version & updates', updateDone: 'New version installed', updateFailed: 'Update failed', updateError: 'Failed to check for updates',
|
|
50
50
|
},
|
|
51
51
|
}
|
|
52
52
|
const fallback = dicts.zh
|
|
53
53
|
let translate = key => fallback[key]
|
|
54
54
|
let pickDirectory = null
|
|
55
|
-
const STATUS_ORDER = ['open', 'status_1', 'status_6', 'status_2', 'status_11', 'status_3', 'in_progress', 'done', 'status_4', 'status_12', 'status_5']
|
|
56
55
|
const TYPE_KEYS = ['story', 'task', 'bug']
|
|
57
56
|
const TYPE_GLYPHS = { story: '📋', task: '✅', bug: '🐛' }
|
|
58
57
|
const STATUS_GLYPHS = { open: '○', done: '●', in_progress: '◐', status_11: '◐', status_4: '●' }
|
|
@@ -87,6 +86,37 @@ window.__ModuleLoader__.load({
|
|
|
87
86
|
return doc.body.innerHTML
|
|
88
87
|
}
|
|
89
88
|
function pluralize(items) { return Array.isArray(items) ? items.length : 0 }
|
|
89
|
+
|
|
90
|
+
/** 把 TAPD 模板里的 HTML 描述转成纯文本,供 textarea 预填。 */
|
|
91
|
+
function htmlToText(html) {
|
|
92
|
+
if (!html) return ''
|
|
93
|
+
return String(html)
|
|
94
|
+
.replace(/<br\s*\/?>/gi, '\n')
|
|
95
|
+
.replace(/<\/(p|div|h[1-6]|li|tr|blockquote)>/gi, '\n')
|
|
96
|
+
.replace(/<li[^>]*>/gi, '- ')
|
|
97
|
+
.replace(/<[^>]+>/g, '')
|
|
98
|
+
.replace(/ /g, ' ')
|
|
99
|
+
.replace(/</g, '<')
|
|
100
|
+
.replace(/>/g, '>')
|
|
101
|
+
.replace(/"/g, '"')
|
|
102
|
+
.replace(/'/g, "'")
|
|
103
|
+
.replace(/&/g, '&')
|
|
104
|
+
.replace(/[ \t]+\n/g, '\n')
|
|
105
|
+
.replace(/\n{3,}/g, '\n\n')
|
|
106
|
+
.trim()
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/** 把 textarea 的纯文本转回 TAPD 需要的 HTML 段落(保留换行)。 */
|
|
110
|
+
function textToHtml(text) {
|
|
111
|
+
const value = String(text || '').trim()
|
|
112
|
+
if (!value) return ''
|
|
113
|
+
const escape = value.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>')
|
|
114
|
+
return escape
|
|
115
|
+
.split(/\n{2,}/)
|
|
116
|
+
.map(paragraph => `<p>${paragraph.replace(/\n/g, '<br/>')}</p>`)
|
|
117
|
+
.join('')
|
|
118
|
+
}
|
|
119
|
+
|
|
90
120
|
function formatUpdated(value) {
|
|
91
121
|
if (!value) return '-'
|
|
92
122
|
const date = new Date(value)
|
|
@@ -266,14 +296,15 @@ window.__ModuleLoader__.load({
|
|
|
266
296
|
if (!buckets.has(key)) buckets.set(key, [])
|
|
267
297
|
buckets.get(key).push(item)
|
|
268
298
|
}
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
299
|
+
// 泳道完全来自 TAPD 字段配置(支持各空间自定义状态),空状态也保留,
|
|
300
|
+
// 避免切换到状态命名不同的空间时只剩有数据的列、看不到其他泳道。
|
|
301
|
+
const keys = Object.keys(labels || {})
|
|
302
|
+
for (const key of buckets.keys()) if (!keys.includes(key)) keys.push(key)
|
|
303
|
+
return keys.map(key => ({
|
|
304
|
+
key,
|
|
305
|
+
label: key === 'unknown' ? translate('unknown') : (labels[key] || key),
|
|
306
|
+
items: buckets.get(key) || [],
|
|
307
|
+
}))
|
|
277
308
|
}, [filtered, labels])
|
|
278
309
|
|
|
279
310
|
// —— 泳道拖拽改状态(HTML5 DnD)——
|
|
@@ -464,7 +495,7 @@ window.__ModuleLoader__.load({
|
|
|
464
495
|
}))
|
|
465
496
|
: h('div', { className: 'tbx-empty' }, query ? translate('noResult') : translate('empty'))),
|
|
466
497
|
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,
|
|
467
|
-
createOpen ? h(CreateDialog, { labels, ownerDefault: state?.user?.name || '', onCancel: () => setCreateOpen(false), onCreate: (input) => runAction('
|
|
498
|
+
createOpen ? h(CreateDialog, { labels, ownerDefault: state?.user?.name || '', onCancel: () => setCreateOpen(false), onCreate: (input) => runAction('createItem', input).then(() => setCreateOpen(false)) }) : null,
|
|
468
499
|
settingsOpen ? h(SettingsDialog, { config: state?.config, settings: state?.settings, version: state?.version, onClose: () => setSettingsOpen(false), onSave: payload => runAction('saveSettings', payload).then(() => setSettingsOpen(false)), onCheckUpdate: () => handleCheckUpdate(true), checking, onUpdate: handleUpdate, updating }) : null,
|
|
469
500
|
aboutOpen ? h(WelcomeDialog, { version: state?.version, settings: state?.settings, onClose: () => { setAboutOpen(false); try { localStorage.setItem('tapd-task-board:welcome-v1', '1') } catch { /* 忽略 */ } }, onOpenSettings: () => { setAboutOpen(false); setSettingsOpen(true) }, onCheckUpdate: () => handleCheckUpdate(true), checking, onUpdate: handleUpdate, updating }) : null)
|
|
470
501
|
}
|
|
@@ -568,22 +599,87 @@ window.__ModuleLoader__.load({
|
|
|
568
599
|
}
|
|
569
600
|
|
|
570
601
|
/** New-story dialog. */
|
|
571
|
-
function CreateDialog({ labels, ownerDefault, onCancel, onCreate }) {
|
|
602
|
+
function CreateDialog({ labels, ownerDefault, onCancel, onCreate, initialType = 'story' }) {
|
|
572
603
|
const c = translate('create')
|
|
604
|
+
const [type, setType] = useState(initialType)
|
|
573
605
|
const [name, setName] = useState('')
|
|
574
606
|
const [description, setDescription] = useState('')
|
|
575
607
|
const [owner, setOwner] = useState(ownerDefault)
|
|
576
608
|
const [priority, setPriority] = useState('2')
|
|
609
|
+
const [templates, setTemplates] = useState([])
|
|
610
|
+
const [templateId, setTemplateId] = useState('')
|
|
611
|
+
const [templateNote, setTemplateNote] = useState('')
|
|
612
|
+
const [templateBusy, setTemplateBusy] = useState(false)
|
|
613
|
+
|
|
614
|
+
// 选择模板后按 TAPD 模板字段默认值预填表单
|
|
615
|
+
const applyTemplate = useCallback(async (id) => {
|
|
616
|
+
if (!id) return
|
|
617
|
+
setTemplateBusy(true)
|
|
618
|
+
try {
|
|
619
|
+
const result = await postAction('templateFields', { type, templateId: id })
|
|
620
|
+
if (result?.ok && result.templateFields) {
|
|
621
|
+
const fields = result.templateFields
|
|
622
|
+
const desc = fields.description?.value
|
|
623
|
+
if (desc) setDescription(htmlToText(desc))
|
|
624
|
+
const ownerValue = String(fields.owner?.value || fields.current_owner?.value || '').replace(/[;\s]+$/, '')
|
|
625
|
+
if (ownerValue) setOwner(ownerValue)
|
|
626
|
+
const priorityValue = String(fields.priority_label?.value || '').trim()
|
|
627
|
+
if (priorityValue) {
|
|
628
|
+
const mapped = { High: '1', Middle: '2', Low: '3', 高: '1', 中: '2', 低: '3' }[priorityValue] || priorityValue
|
|
629
|
+
if (['1', '2', '3'].includes(mapped)) setPriority(mapped)
|
|
630
|
+
}
|
|
631
|
+
}
|
|
632
|
+
} catch { /* 模板字段不可用时不阻断创建 */ } finally { setTemplateBusy(false) }
|
|
633
|
+
}, [type])
|
|
634
|
+
|
|
635
|
+
// 打开弹窗时加载该类型的模板列表,并默认选中 TAPD 的默认模板
|
|
636
|
+
useEffect(() => {
|
|
637
|
+
let cancelled = false
|
|
638
|
+
;(async () => {
|
|
639
|
+
setTemplateBusy(true)
|
|
640
|
+
try {
|
|
641
|
+
const result = await postAction('templateList', { type })
|
|
642
|
+
if (cancelled) return
|
|
643
|
+
if (result?.ok) {
|
|
644
|
+
const list = result.templates || []
|
|
645
|
+
setTemplates(list)
|
|
646
|
+
if (result.templateError) setTemplateNote(result.templateError)
|
|
647
|
+
else if (!list.length) setTemplateNote(translate('templateUnavailable'))
|
|
648
|
+
else {
|
|
649
|
+
const preset = list.find(item => item.isDefault) || list[0]
|
|
650
|
+
setTemplateId(preset.id)
|
|
651
|
+
applyTemplate(preset.id)
|
|
652
|
+
}
|
|
653
|
+
} else setTemplateNote(result?.error || '')
|
|
654
|
+
} catch (error) {
|
|
655
|
+
if (!cancelled) setTemplateNote(error instanceof Error ? error.message : String(error))
|
|
656
|
+
} finally { if (!cancelled) setTemplateBusy(false) }
|
|
657
|
+
})()
|
|
658
|
+
return () => { cancelled = true }
|
|
659
|
+
}, [type, applyTemplate])
|
|
660
|
+
|
|
661
|
+
const selectTemplate = (id) => { setTemplateId(id); if (id) applyTemplate(id) }
|
|
662
|
+
|
|
577
663
|
return h('div', { className: 'tbx-dialog', onClick: event => { if (event.target === event.currentTarget) onCancel() } },
|
|
578
664
|
h('div', { className: 'tbx-dialog-box' },
|
|
579
665
|
h('div', { style: { fontWeight: 600, fontSize: 14 } }, c.title),
|
|
666
|
+
h('label', { className: 'tbx-field' },
|
|
667
|
+
h('span', { className: 'tbx-field-k' }, c.type),
|
|
668
|
+
h('select', { className: 'tbx-input', value: type, onChange: event => setType(event.target.value) },
|
|
669
|
+
TYPE_KEYS.map(key => h('option', { key, value: key }, translate(key))))),
|
|
670
|
+
h('label', { className: 'tbx-field' },
|
|
671
|
+
h('span', { className: 'tbx-field-k' }, c.template),
|
|
672
|
+
h('select', { className: 'tbx-input', value: templateId, onChange: event => selectTemplate(event.target.value) },
|
|
673
|
+
h('option', { value: '' }, c.templateNone),
|
|
674
|
+
templates.map(template => h('option', { key: template.id, value: template.id }, template.isDefault ? `${template.name} ★` : template.name)))),
|
|
675
|
+
templateNote ? h('span', { className: 'tbx-note' }, templateNote) : null,
|
|
580
676
|
h('input', { className: 'tbx-input', placeholder: c.name, value: name, onChange: event => setName(event.target.value) }),
|
|
581
677
|
h('textarea', { className: 'tbx-textarea', placeholder: c.description, value: description, onChange: event => setDescription(event.target.value) }),
|
|
582
678
|
h('div', { className: 'tbx-row' }, h('input', { className: 'tbx-input', placeholder: c.owner, value: owner, onChange: event => setOwner(event.target.value) })),
|
|
583
679
|
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}`)))),
|
|
584
680
|
h('div', { className: 'tbx-row', style: { justifyContent: 'flex-end' } },
|
|
585
681
|
h('button', { className: 'tbx-btn', onClick: onCancel, type: 'button' }, c.cancel),
|
|
586
|
-
h('button', { className: 'tbx-btn primary', onClick: () => { if (name.trim()) onCreate({ name: name.trim(), description, owner: owner.trim(), priority }) }, type: 'button', disabled: !name.trim() }, c.create))))
|
|
682
|
+
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))))
|
|
587
683
|
}
|
|
588
684
|
|
|
589
685
|
/** 首次打开/点击版本徽标时的使用说明弹窗:配置引导 + 版本信息 + 使用手册 + 更新入口。 */
|
package/package.json
CHANGED
package/src/host/service.js
CHANGED
|
@@ -160,12 +160,35 @@ export class TapdBoardService {
|
|
|
160
160
|
await this.client.addComment(payload.type, payload.id, String(payload.content).trim(), this.user?.name)
|
|
161
161
|
return this.refresh()
|
|
162
162
|
}
|
|
163
|
+
if (action === 'createItem') {
|
|
164
|
+
// 按类型创建(story / task / bug),可按模板预填后的字段提交
|
|
165
|
+
const type = String(payload.type || 'story')
|
|
166
|
+
if (!['story', 'task', 'bug'].includes(type)) throw new Error('createItem.type 必须为 story / task / bug')
|
|
167
|
+
if (!String(payload.name || '').trim()) throw new Error('标题不能为空')
|
|
168
|
+
const first = this.snapshot().items[type]?.[0]
|
|
169
|
+
await this.client.createItem(type, {
|
|
170
|
+
name: String(payload.name).trim(),
|
|
171
|
+
description: payload.description || '',
|
|
172
|
+
owner: payload.owner || this.user?.name,
|
|
173
|
+
priority: payload.priority,
|
|
174
|
+
workitemTypeId: payload.workitemTypeId || (type === 'story' ? this.config.storyWorkitemTypeId : undefined) || first?.workitemTypeId,
|
|
175
|
+
})
|
|
176
|
+
return this.refresh()
|
|
177
|
+
}
|
|
163
178
|
if (action === 'createStory') {
|
|
164
179
|
if (!String(payload.name || '').trim()) throw new Error('需求标题不能为空')
|
|
165
180
|
const first = this.snapshot().items.story[0]
|
|
166
181
|
await this.client.createStory({ name: String(payload.name).trim(), description: payload.description || '', owner: payload.owner || this.user?.name, priority: payload.priority, workitemTypeId: this.config.storyWorkitemTypeId || first?.workitemTypeId })
|
|
167
182
|
return this.refresh()
|
|
168
183
|
}
|
|
184
|
+
if (action === 'templateList') {
|
|
185
|
+
// 工作项创建模板列表(TAPD 的 /{entity}/template_list);tasks 常因权限 403,按降级返回
|
|
186
|
+
return this.templateList(payload)
|
|
187
|
+
}
|
|
188
|
+
if (action === 'templateFields') {
|
|
189
|
+
// 指定模板的字段默认值,用于「选择模板 → 预填表单」
|
|
190
|
+
return this.templateFields(payload)
|
|
191
|
+
}
|
|
169
192
|
if (action === 'scheduleTask') {
|
|
170
193
|
// 创建真正的自动执行:注册 DSH 原生 schedule,到点向该 TAPD 工作项投递 Agent 指令,
|
|
171
194
|
// Agent 会自动创建会话并用 tapd_board_* 工具执行(无需手动复制 prompt)。
|
|
@@ -190,6 +213,33 @@ export class TapdBoardService {
|
|
|
190
213
|
throw new Error(`不支持的动作:${action}`)
|
|
191
214
|
}
|
|
192
215
|
|
|
216
|
+
/**
|
|
217
|
+
* 列出工作项创建模板。
|
|
218
|
+
* 返回 { templates, templateError };templateError 非空表示该类型模板不可用(如 tasks 403)。
|
|
219
|
+
*/
|
|
220
|
+
async templateList(payload = {}) {
|
|
221
|
+
const type = String(payload.type || 'story')
|
|
222
|
+
if (!['story', 'task', 'bug'].includes(type)) throw new Error('templateList.type 必须为 story / task / bug')
|
|
223
|
+
let templates = []
|
|
224
|
+
let templateError = ''
|
|
225
|
+
try {
|
|
226
|
+
templates = await this.client.templateList(type)
|
|
227
|
+
} catch (error) {
|
|
228
|
+
templateError = error instanceof Error ? error.message : String(error)
|
|
229
|
+
}
|
|
230
|
+
return { ...this.snapshot(), templates, templateError, templateType: type }
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
/** 读取指定模板的字段默认值({ field: { value, required } })。 */
|
|
234
|
+
async templateFields(payload = {}) {
|
|
235
|
+
const type = String(payload.type || 'story')
|
|
236
|
+
if (!['story', 'task', 'bug'].includes(type)) throw new Error('templateFields.type 必须为 story / task / bug')
|
|
237
|
+
const templateId = String(payload.templateId || '').trim()
|
|
238
|
+
if (!templateId) throw new Error('templateFields 需要 templateId')
|
|
239
|
+
const templateFields = await this.client.templateFields(type, templateId)
|
|
240
|
+
return { ...this.snapshot(), templateFields, templateId, templateType: type }
|
|
241
|
+
}
|
|
242
|
+
|
|
193
243
|
async checkVersion(payload = {}) {
|
|
194
244
|
const cacheMs = 10 * 60 * 1000
|
|
195
245
|
if (payload.force !== true && this.versionInfo && Date.now() - this.versionCheckedAt < cacheMs) {
|
|
@@ -289,16 +339,6 @@ export class TapdBoardService {
|
|
|
289
339
|
sessionId = created?.sessionId || ''
|
|
290
340
|
}
|
|
291
341
|
if (!sessionId) throw new Error('无法创建独立会话')
|
|
292
|
-
// 会话创建接口不接收标题,标题通过 rename 设置;rename 失败仅降级,不阻断调度创建
|
|
293
|
-
if (sessionId) {
|
|
294
|
-
try {
|
|
295
|
-
if (typeof sessions.rename === 'function') {
|
|
296
|
-
await sessions.rename({ sessionId, title: sessionTitle })
|
|
297
|
-
}
|
|
298
|
-
} catch (error) {
|
|
299
|
-
console.warn(`[tapd-task-board] rename session ${sessionId} failed: ${error?.message || error}`)
|
|
300
|
-
}
|
|
301
|
-
}
|
|
302
342
|
|
|
303
343
|
// ③ 到点触发的 Agent 指令(Agent 具备 tapd_board_* 工具,可读详情、改状态、评论等)
|
|
304
344
|
const item = { type, id, title: payload.title || '', url: payload.url || '' }
|
|
@@ -326,6 +366,18 @@ export class TapdBoardService {
|
|
|
326
366
|
target: { kind: 'session', sessionId },
|
|
327
367
|
})
|
|
328
368
|
|
|
369
|
+
// ⑤ 调度创建成功后,才给会话设置固定标题 `<type>#<id>`。
|
|
370
|
+
// 顺序很重要:改名必须晚于 schedule.create —— 否则调度失败会遗留一个
|
|
371
|
+
// 「已被改名为 story#… 的空白会话」,而 DSH 新建会话时会复用未归档的空白会话,
|
|
372
|
+
// 导致用户手动创建的会话继承这个错误标题。改名失败仅告警,不影响已注册的调度。
|
|
373
|
+
try {
|
|
374
|
+
if (typeof sessions.rename === 'function') {
|
|
375
|
+
await sessions.rename({ sessionId, title: sessionTitle })
|
|
376
|
+
}
|
|
377
|
+
} catch (error) {
|
|
378
|
+
console.warn(`[tapd-task-board] rename session ${sessionId} failed: ${error?.message || error}`)
|
|
379
|
+
}
|
|
380
|
+
|
|
329
381
|
const run = {
|
|
330
382
|
id: String(record?.id || ''), scheduledAt: at, sessionId, type, itemId: id,
|
|
331
383
|
workspaceId, dshWorkspaceId, workspacePath,
|
package/src/host/tapd.js
CHANGED
|
@@ -144,6 +144,51 @@ export class TapdClient {
|
|
|
144
144
|
return this.request('GET', '/users/info')
|
|
145
145
|
}
|
|
146
146
|
|
|
147
|
+
/**
|
|
148
|
+
* 获取某类型的工作项创建模板列表(TAPD:/{entity}/template_list)。
|
|
149
|
+
* 注意:tasks 的该接口常因 Token 权限返回 403,调用方需自行降级。
|
|
150
|
+
*/
|
|
151
|
+
async templateList(type) {
|
|
152
|
+
const data = await this.request('GET', `/${entityPath(type)}/template_list`, { workspace_id: this.workspaceId })
|
|
153
|
+
const rows = Array.isArray(data) ? data : []
|
|
154
|
+
return rows
|
|
155
|
+
.map(row => row?.WorkitemTemplate || row)
|
|
156
|
+
.filter(Boolean)
|
|
157
|
+
.map(template => ({
|
|
158
|
+
id: String(template.id || ''),
|
|
159
|
+
name: String(template.name || ''),
|
|
160
|
+
description: String(template.description || ''),
|
|
161
|
+
isDefault: String(template.default ?? '0') === '1',
|
|
162
|
+
sort: Number(template.sort || 0),
|
|
163
|
+
creator: String(template.creator || ''),
|
|
164
|
+
}))
|
|
165
|
+
.filter(template => template.id && template.name)
|
|
166
|
+
.sort((a, b) => Number(b.isDefault) - Number(a.isDefault) || a.sort - b.sort)
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* 获取指定模板的字段默认值(TAPD:/{entity}/get_default_story_template)。
|
|
171
|
+
* 返回 { 字段名: { value, required } };仅 story 稳定可用。
|
|
172
|
+
*/
|
|
173
|
+
async templateFields(type, templateId) {
|
|
174
|
+
const data = await this.request('GET', `/${entityPath(type)}/get_default_story_template`, {
|
|
175
|
+
workspace_id: this.workspaceId,
|
|
176
|
+
template_id: templateId,
|
|
177
|
+
'use-priority-label': 1,
|
|
178
|
+
})
|
|
179
|
+
const rows = Array.isArray(data) ? data : []
|
|
180
|
+
const result = {}
|
|
181
|
+
for (const row of rows) {
|
|
182
|
+
const field = row?.WorkitemTemplateField || row
|
|
183
|
+
if (!field || !field.field) continue
|
|
184
|
+
result[String(field.field)] = {
|
|
185
|
+
value: String(field.value ?? ''),
|
|
186
|
+
required: String(field.required ?? '0') === '1',
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
return result
|
|
190
|
+
}
|
|
191
|
+
|
|
147
192
|
async update(type, id, patch) {
|
|
148
193
|
// TAPD 的保存/更新语义:POST /{entity} 带 id 即为更新(与 tapd-cli 的
|
|
149
194
|
// `story/bug/task update` 一致);POST /{entity}/update 需要额外的
|
|
@@ -162,6 +207,37 @@ export class TapdClient {
|
|
|
162
207
|
})
|
|
163
208
|
}
|
|
164
209
|
|
|
210
|
+
/**
|
|
211
|
+
* 按工作项类型创建(story / task / bug)。
|
|
212
|
+
* 字段差异:story、task 用 `name`;bug 用 `title` + `current_owner`。
|
|
213
|
+
* task 在新任务项目里以 story 承载(需 workitem_type_id),否则走 /tasks。
|
|
214
|
+
*/
|
|
215
|
+
async createItem(type, input) {
|
|
216
|
+
const description = input.description || ''
|
|
217
|
+
const priority = input.priority || undefined
|
|
218
|
+
const owner = input.owner || undefined
|
|
219
|
+
if (type === 'bug') {
|
|
220
|
+
return this.request('POST', '/bugs', {
|
|
221
|
+
workspace_id: this.workspaceId,
|
|
222
|
+
title: input.name,
|
|
223
|
+
description,
|
|
224
|
+
priority,
|
|
225
|
+
current_owner: owner,
|
|
226
|
+
})
|
|
227
|
+
}
|
|
228
|
+
if (type === 'task' && !input.workitemTypeId) {
|
|
229
|
+
return this.request('POST', '/tasks', { workspace_id: this.workspaceId, name: input.name, description, priority, owner })
|
|
230
|
+
}
|
|
231
|
+
return this.request('POST', '/stories', {
|
|
232
|
+
workspace_id: this.workspaceId,
|
|
233
|
+
name: input.name,
|
|
234
|
+
description,
|
|
235
|
+
priority,
|
|
236
|
+
owner,
|
|
237
|
+
workitem_type_id: input.workitemTypeId || undefined,
|
|
238
|
+
})
|
|
239
|
+
}
|
|
240
|
+
|
|
165
241
|
async addComment(type, id, content, author) {
|
|
166
242
|
return this.request('POST', '/comments', {
|
|
167
243
|
workspace_id: this.workspaceId,
|