@xirang-ai/dsh-teamflow 0.1.1 → 0.1.2
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.en.md +15 -11
- package/README.md +15 -11
- package/RELEASE.md +6 -6
- package/cordis.patch.yml +2 -0
- package/lib/client.js +179 -38
- package/lib/index.d.ts +7 -1
- package/lib/index.js +10 -4
- package/lib/remote/contract.d.ts +34 -1
- package/lib/remote/contract.js +16 -0
- package/lib/remote/service.d.ts +15 -2
- package/lib/remote/service.js +49 -6
- package/lib/requirement-discussion.d.ts +23 -0
- package/lib/requirement-discussion.js +26 -0
- package/lib/store/db.d.ts +8 -3
- package/lib/store/db.js +34 -2
- package/lib/store/docs.d.ts +9 -11
- package/lib/store/docs.js +25 -52
- package/lib/store/model.d.ts +23 -0
- package/lib/store/model.js +4 -0
- package/lib/store/paths.d.ts +20 -0
- package/lib/store/paths.js +54 -1
- package/lib/store/schema.js +71 -14
- package/lib/store/workflow.d.ts +50 -25
- package/lib/store/workflow.js +210 -97
- package/lib/tools/get-bug.js +1 -1
- package/lib/tools/get-design-doc.js +1 -1
- package/lib/tools/get-requirement.js +1 -1
- package/lib/tools/get-story.js +1 -1
- package/lib/tools/index.js +7 -0
- package/lib/tools/link-session.d.ts +3 -0
- package/lib/tools/link-session.js +87 -0
- package/locale/en.json +2 -0
- package/locale/zh.json +2 -0
- package/package.json +1 -1
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `teamflow_link_session` — confirm the discussion prepared for this conversation.
|
|
3
|
+
*
|
|
4
|
+
* The browser creates the session and registers a pending binding before the
|
|
5
|
+
* first message, so the Agent must not need a record id. The session id is the
|
|
6
|
+
* durable identity of the conversation; linking is idempotent. Requirements,
|
|
7
|
+
* stories and defects share this tool; `teamflow_link_requirement_session`
|
|
8
|
+
* stays as a compatibility alias with the same implementation.
|
|
9
|
+
*
|
|
10
|
+
* @module
|
|
11
|
+
*/
|
|
12
|
+
import { defineTool } from '@deepseek-ai/dsh-tools';
|
|
13
|
+
/** Where the Agent should read the record after linking. */
|
|
14
|
+
function nextStep(subjectType) {
|
|
15
|
+
if (subjectType === 'story')
|
|
16
|
+
return 'teamflow_get_story';
|
|
17
|
+
if (subjectType === 'bug')
|
|
18
|
+
return 'teamflow_get_bug';
|
|
19
|
+
return 'teamflow_get_requirement';
|
|
20
|
+
}
|
|
21
|
+
/** Build the generic session-linking tool bound to one Host context. */
|
|
22
|
+
export function linkSessionTool(environment) {
|
|
23
|
+
return defineTool({
|
|
24
|
+
name: 'teamflow_link_session',
|
|
25
|
+
description: 'Confirm that this conversation belongs to the requirement, story or defect it was started from. Call it once at the very beginning of a discussion; it takes no arguments and returns the subject type, id, title and confirmation time.',
|
|
26
|
+
parameters: {},
|
|
27
|
+
output: {
|
|
28
|
+
schema: {
|
|
29
|
+
type: 'object',
|
|
30
|
+
additionalProperties: false,
|
|
31
|
+
properties: {
|
|
32
|
+
subjectType: { type: 'string', required: true },
|
|
33
|
+
subjectId: { type: 'string', required: true },
|
|
34
|
+
title: { type: 'string', required: true },
|
|
35
|
+
sessionId: { type: 'string', required: true },
|
|
36
|
+
kind: { type: 'string', required: true },
|
|
37
|
+
linkedAt: { type: 'string', required: true },
|
|
38
|
+
alreadyLinked: { type: 'boolean', required: true },
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
render: (_args, value) => [
|
|
42
|
+
{
|
|
43
|
+
type: 'text',
|
|
44
|
+
text: [
|
|
45
|
+
`已把本会话登记到${subjectLabel(value.subjectType)} ${value.subjectId}《${value.title}》。`,
|
|
46
|
+
`接下来调用 ${nextStep(value.subjectType)} 读取正文,再结合用户补充继续讨论。`,
|
|
47
|
+
].join('\n'),
|
|
48
|
+
},
|
|
49
|
+
],
|
|
50
|
+
},
|
|
51
|
+
async execute(_args, exec) {
|
|
52
|
+
exec.signal.throwIfAborted();
|
|
53
|
+
const sessionId = exec.agent?.session.header.id?.trim() ?? '';
|
|
54
|
+
if (sessionId.length === 0) {
|
|
55
|
+
throw new Error('teamflow: 无法从当前会话取得 session id,不能登记讨论会话。');
|
|
56
|
+
}
|
|
57
|
+
const before = environment.database.workflow.getDiscussionSession(sessionId);
|
|
58
|
+
const session = environment.database.workflow.linkDiscussionSession(sessionId);
|
|
59
|
+
const title = subjectTitle(environment, session.subjectType, session.subjectId);
|
|
60
|
+
return {
|
|
61
|
+
subjectType: session.subjectType,
|
|
62
|
+
subjectId: session.subjectId,
|
|
63
|
+
title,
|
|
64
|
+
sessionId: session.sessionId,
|
|
65
|
+
kind: session.kind,
|
|
66
|
+
linkedAt: session.linkedAt ?? session.preparedAt ?? session.createdAt,
|
|
67
|
+
alreadyLinked: before?.linkedAt != null,
|
|
68
|
+
};
|
|
69
|
+
},
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
function subjectLabel(subjectType) {
|
|
73
|
+
if (subjectType === 'story')
|
|
74
|
+
return '故事';
|
|
75
|
+
if (subjectType === 'bug')
|
|
76
|
+
return '缺陷';
|
|
77
|
+
return '需求';
|
|
78
|
+
}
|
|
79
|
+
/** Record title, falling back to the id so a dangling row still reports something readable. */
|
|
80
|
+
function subjectTitle(environment, subjectType, subjectId) {
|
|
81
|
+
const workflow = environment.database.workflow;
|
|
82
|
+
if (subjectType === 'story')
|
|
83
|
+
return workflow.getStory(subjectId)?.title ?? subjectId;
|
|
84
|
+
if (subjectType === 'bug')
|
|
85
|
+
return workflow.getBug(subjectId)?.title ?? subjectId;
|
|
86
|
+
return workflow.getRequirement(subjectId)?.title ?? subjectId;
|
|
87
|
+
}
|
package/locale/en.json
CHANGED
|
@@ -133,6 +133,7 @@
|
|
|
133
133
|
"delete.statusMissing": "—",
|
|
134
134
|
"delete.summary": "{total} record(s), {deletable} deletable",
|
|
135
135
|
"detail.branch": "Branch",
|
|
136
|
+
"detail.bugDiscussion": "Discuss this bug in a new session",
|
|
136
137
|
"detail.bugBody": "What happened",
|
|
137
138
|
"detail.completedAt": "Completed",
|
|
138
139
|
"detail.description": "Description",
|
|
@@ -148,6 +149,7 @@
|
|
|
148
149
|
"detail.discussionNewDetail": "Discuss the detailed design in a new conversation",
|
|
149
150
|
"detail.discussionNewSplit": "Split Stories in a new conversation",
|
|
150
151
|
"detail.discussionOpen": "Open",
|
|
152
|
+
"detail.storyDiscussion": "Discuss this story in a new session",
|
|
151
153
|
"detail.discussionStarting": "Creating conversation…",
|
|
152
154
|
"detail.docs": "Detailed design",
|
|
153
155
|
"detail.docsEmpty": "No detailed design written yet.",
|
package/locale/zh.json
CHANGED
|
@@ -133,6 +133,7 @@
|
|
|
133
133
|
"delete.statusMissing": "—",
|
|
134
134
|
"delete.summary": "共 {total} 条,可删除 {deletable} 条",
|
|
135
135
|
"detail.branch": "分支",
|
|
136
|
+
"detail.bugDiscussion": "在新会话中进行缺陷讨论",
|
|
136
137
|
"detail.bugBody": "缺陷说明",
|
|
137
138
|
"detail.completedAt": "完成时间",
|
|
138
139
|
"detail.description": "故事说明",
|
|
@@ -148,6 +149,7 @@
|
|
|
148
149
|
"detail.discussionNewDetail": "在新会话中进行详细设计讨论",
|
|
149
150
|
"detail.discussionNewSplit": "在新会话中进行故事拆分",
|
|
150
151
|
"detail.discussionOpen": "打开",
|
|
152
|
+
"detail.storyDiscussion": "在新会话中进行故事讨论",
|
|
151
153
|
"detail.discussionStarting": "正在创建会话…",
|
|
152
154
|
"detail.docs": "详细设计",
|
|
153
155
|
"detail.docsEmpty": "还没有写详细设计。",
|