dsh-github-flow 0.3.0 → 0.5.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/README.en.md +287 -143
- package/README.md +270 -125
- package/docs/UPGRADE-NOTES.md +12 -9
- package/docs/architecture.md +126 -126
- package/lib/api/routes-actions.js +249 -0
- package/lib/api/routes-overview.js +94 -2
- package/lib/cache.d.ts +4 -0
- package/lib/cache.js +14 -0
- package/lib/client.d.ts +14 -1
- package/lib/client.js +4287 -2500
- package/lib/commands/gh.d.ts +6 -1
- package/lib/commands/gh.js +144 -71
- package/lib/executor/git-parser.d.ts +57 -0
- package/lib/executor/git-parser.js +255 -0
- package/lib/executor/platform-guide.d.ts +14 -0
- package/lib/executor/platform-guide.js +40 -0
- package/lib/executor/process-utils.d.ts +51 -0
- package/lib/executor/process-utils.js +162 -0
- package/lib/executor/version-utils.d.ts +12 -0
- package/lib/executor/version-utils.js +27 -0
- package/lib/executor.d.ts +70 -48
- package/lib/executor.js +371 -356
- package/lib/git-watcher.d.ts +36 -0
- package/lib/git-watcher.js +91 -0
- package/lib/main.js +37 -3
- package/lib/renderers/agent-task.d.ts +16 -0
- package/lib/renderers/agent-task.js +107 -0
- package/lib/renderers/cache.d.ts +8 -0
- package/lib/renderers/cache.js +66 -0
- package/lib/renderers/codespace.d.ts +16 -0
- package/lib/renderers/codespace.js +103 -0
- package/lib/renderers/common.d.ts +24 -0
- package/lib/renderers/common.js +88 -0
- package/lib/renderers/discussion.d.ts +16 -0
- package/lib/renderers/discussion.js +101 -0
- package/lib/renderers/gist.d.ts +15 -0
- package/lib/renderers/gist.js +99 -0
- package/lib/renderers/issue.d.ts +4 -0
- package/lib/renderers/issue.js +70 -0
- package/lib/renderers/label.d.ts +4 -0
- package/lib/renderers/label.js +48 -0
- package/lib/renderers/markdown.d.ts +19 -32
- package/lib/renderers/markdown.js +19 -624
- package/lib/renderers/pr.d.ts +4 -0
- package/lib/renderers/pr.js +107 -0
- package/lib/renderers/project.d.ts +20 -0
- package/lib/renderers/project.js +128 -0
- package/lib/renderers/release.d.ts +4 -0
- package/lib/renderers/release.js +74 -0
- package/lib/renderers/repo.d.ts +4 -0
- package/lib/renderers/repo.js +149 -0
- package/lib/renderers/ruleset.d.ts +4 -0
- package/lib/renderers/ruleset.js +74 -0
- package/lib/renderers/run.d.ts +4 -0
- package/lib/renderers/run.js +79 -0
- package/lib/renderers/skill.d.ts +34 -0
- package/lib/renderers/skill.js +241 -0
- package/lib/renderers/status.d.ts +28 -0
- package/lib/renderers/status.js +176 -0
- package/lib/telemetry.d.ts +70 -0
- package/lib/telemetry.js +161 -0
- package/lib/tools/agent-task.d.ts +54 -0
- package/lib/tools/agent-task.js +135 -0
- package/lib/tools/cache.d.ts +64 -0
- package/lib/tools/cache.js +186 -0
- package/lib/tools/codespace.d.ts +51 -0
- package/lib/tools/codespace.js +154 -0
- package/lib/tools/discussion.d.ts +70 -0
- package/lib/tools/discussion.js +195 -0
- package/lib/tools/gist.d.ts +155 -0
- package/lib/tools/gist.js +190 -0
- package/lib/tools/help.js +214 -13
- package/lib/tools/image-utils.d.ts +8 -0
- package/lib/tools/image-utils.js +34 -0
- package/lib/tools/issue.d.ts +8 -1
- package/lib/tools/issue.js +26 -4
- package/lib/tools/label.d.ts +80 -0
- package/lib/tools/label.js +237 -0
- package/lib/tools/pr.d.ts +8 -0
- package/lib/tools/pr.js +48 -3
- package/lib/tools/project.d.ts +80 -0
- package/lib/tools/project.js +241 -0
- package/lib/tools/repo.js +13 -1
- package/lib/tools/ruleset.d.ts +80 -0
- package/lib/tools/ruleset.js +177 -0
- package/lib/tools/skill.d.ts +24 -1
- package/lib/tools/skill.js +115 -5
- package/lib/tools/status.d.ts +40 -0
- package/lib/tools/status.js +58 -0
- package/lib/types.d.ts +44 -0
- package/lib/ui/auth-guide-card.d.ts +4 -0
- package/lib/ui/auth-guide-card.js +161 -0
- package/lib/ui/branch-selector.d.ts +10 -0
- package/lib/ui/branch-selector.js +163 -0
- package/lib/ui/commit-modal.d.ts +8 -0
- package/lib/ui/commit-modal.js +219 -0
- package/lib/ui/help-modal.d.ts +15 -0
- package/lib/ui/help-modal.js +202 -0
- package/lib/ui/icons.d.ts +7 -0
- package/lib/ui/icons.js +53 -0
- package/lib/ui/network-banner.d.ts +10 -0
- package/lib/ui/network-banner.js +54 -0
- package/lib/ui/storage.d.ts +35 -0
- package/lib/ui/storage.js +158 -0
- package/lib/ui/styles.d.ts +6 -0
- package/lib/ui/styles.js +1544 -0
- package/lib/ui/sync-settings-modal.d.ts +11 -0
- package/lib/ui/sync-settings-modal.js +350 -0
- package/lib/ui/sync-status-badge.d.ts +8 -0
- package/lib/ui/sync-status-badge.js +64 -0
- package/lib/ui/upgrade-card.d.ts +7 -0
- package/lib/ui/upgrade-card.js +222 -0
- package/lib/ui/utils.d.ts +45 -0
- package/lib/ui/utils.js +226 -0
- package/lib/ui/workspace-panel.d.ts +4 -0
- package/lib/ui/workspace-panel.js +489 -0
- package/lib/upgrade-manager.d.ts +5 -1
- package/lib/upgrade-manager.js +24 -1
- package/lib/version.d.ts +1 -1
- package/lib/version.js +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { sanitizeCell } from './common.js';
|
|
2
|
+
/**
|
|
3
|
+
* 格式化 Discussion 状态徽标
|
|
4
|
+
*/
|
|
5
|
+
export function formatDiscussionStateBadge(state, answered, closed) {
|
|
6
|
+
if (answered)
|
|
7
|
+
return '🟢 ANSWERED';
|
|
8
|
+
const effective = state ? String(state).toUpperCase() : (closed ? 'CLOSED' : 'OPEN');
|
|
9
|
+
if (effective === 'OPEN')
|
|
10
|
+
return '🔵 OPEN';
|
|
11
|
+
if (effective === 'CLOSED')
|
|
12
|
+
return '🟣 CLOSED';
|
|
13
|
+
return `⚪ ${effective}`;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* 渲染 Discussion 列表表格
|
|
17
|
+
*/
|
|
18
|
+
export function renderDiscussionList(items) {
|
|
19
|
+
const list = items.filter(Boolean);
|
|
20
|
+
if (list.length === 0) {
|
|
21
|
+
return '📭 暂无讨论主题 (Discussions)。';
|
|
22
|
+
}
|
|
23
|
+
const rows = list.map((d) => {
|
|
24
|
+
const num = d.number ? `#${d.number}` : '-';
|
|
25
|
+
const link = d.url ? `[${num}](${d.url})` : num;
|
|
26
|
+
const title = sanitizeCell(d.title || '(无标题)', 45);
|
|
27
|
+
const category = sanitizeCell(d.category?.name || d.category || 'General', 15);
|
|
28
|
+
const stateBadge = formatDiscussionStateBadge(d.state, d.answered, d.closed);
|
|
29
|
+
const author = d.author?.login || d.author || '-';
|
|
30
|
+
const updated = d.updatedAt ? d.updatedAt.split('T')[0] : (d.createdAt ? d.createdAt.split('T')[0] : '-');
|
|
31
|
+
return `| ${link} | ${title} | \`${category}\` | ${stateBadge} | @${author} | ${updated} |`;
|
|
32
|
+
});
|
|
33
|
+
return [
|
|
34
|
+
`**讨论主题列表 (${list.length} 条):**\n`,
|
|
35
|
+
'| 编号 | 标题 | 分类 | 状态 | 作者 | 更新日期 |',
|
|
36
|
+
'| :--- | :--- | :--- | :--- | :--- | :--- |',
|
|
37
|
+
...rows,
|
|
38
|
+
].join('\n');
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* 渲染单个 Discussion 详情卡片
|
|
42
|
+
*/
|
|
43
|
+
export function renderDiscussionView(d) {
|
|
44
|
+
if (!d || typeof d !== 'object') {
|
|
45
|
+
return '无讨论详情数据';
|
|
46
|
+
}
|
|
47
|
+
const num = d.number ? `#${d.number}` : '';
|
|
48
|
+
const title = d.title || '(无标题)';
|
|
49
|
+
const stateBadge = formatDiscussionStateBadge(d.state, d.answered, d.closed);
|
|
50
|
+
const category = d.category?.name || d.category || 'General';
|
|
51
|
+
const author = d.author?.login || d.author || '-';
|
|
52
|
+
const created = d.createdAt || '-';
|
|
53
|
+
const link = d.url ? `[查看原始讨论](${d.url})` : '';
|
|
54
|
+
const lines = [
|
|
55
|
+
`### 💬 Discussion ${num}: ${title}\n`,
|
|
56
|
+
`- **状态**: ${stateBadge}`,
|
|
57
|
+
`- **分类**: \`${category}\``,
|
|
58
|
+
`- **发起人**: @${author}`,
|
|
59
|
+
`- **创建时间**: ${created}`,
|
|
60
|
+
];
|
|
61
|
+
if (link)
|
|
62
|
+
lines.push(`- **链接**: ${link}`);
|
|
63
|
+
if (Array.isArray(d.labels) && d.labels.length > 0) {
|
|
64
|
+
const labelBadges = d.labels.map((l) => `\`${l.name || l}\``).join(' ');
|
|
65
|
+
lines.push(`- **标签**: ${labelBadges}`);
|
|
66
|
+
}
|
|
67
|
+
if (d.body) {
|
|
68
|
+
lines.push('\n**正文内容:**', '---', d.body.trim(), '---');
|
|
69
|
+
}
|
|
70
|
+
// 渲染关联评论列表
|
|
71
|
+
if (Array.isArray(d.comments) && d.comments.length > 0) {
|
|
72
|
+
lines.push(`\n**讨论回复 (${d.comments.length} 条):**`);
|
|
73
|
+
d.comments.forEach((c, index) => {
|
|
74
|
+
const cAuthor = c.author?.login || c.author || '匿名';
|
|
75
|
+
const cTime = c.createdAt ? c.createdAt.replace('T', ' ').slice(0, 19) : '';
|
|
76
|
+
const cBody = (c.body || '').trim();
|
|
77
|
+
lines.push(`\n> **#${index + 1} 楼 @${cAuthor}** (${cTime}):\n> ${cBody.replace(/\n/g, '\n> ')}`);
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
return lines.join('\n');
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Discussion 领域综合渲染入口
|
|
84
|
+
*/
|
|
85
|
+
export function renderDiscussionMarkdown(args, value) {
|
|
86
|
+
if (!value)
|
|
87
|
+
return '无返回内容';
|
|
88
|
+
if (typeof value.result === 'string')
|
|
89
|
+
return value.result;
|
|
90
|
+
if (typeof value.message === 'string' && !value.items) {
|
|
91
|
+
const extra = value.detail || value.output || value.url;
|
|
92
|
+
return `**${value.message}**` + (extra ? `\n\`\`\`\n${extra}\n\`\`\`` : '');
|
|
93
|
+
}
|
|
94
|
+
if (Array.isArray(value.items) && args?.action === 'list') {
|
|
95
|
+
return renderDiscussionList(value.items);
|
|
96
|
+
}
|
|
97
|
+
if (args?.action === 'view' || value.number) {
|
|
98
|
+
return renderDiscussionView(value);
|
|
99
|
+
}
|
|
100
|
+
return JSON.stringify(value, null, 2);
|
|
101
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export interface ParsedGistSummary {
|
|
2
|
+
id: string;
|
|
3
|
+
description: string;
|
|
4
|
+
filesCount: string;
|
|
5
|
+
visibility: string;
|
|
6
|
+
updatedAt: string;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* 解析 gh gist list 的制表符/多列纯文本输出
|
|
10
|
+
*/
|
|
11
|
+
export declare function parseGistListOutput(output: string): ParsedGistSummary[];
|
|
12
|
+
/**
|
|
13
|
+
* Gist 领域渲染器:负责 GitHub Gist 列表、代码正文、创建/删除反馈的 Markdown 格式化
|
|
14
|
+
*/
|
|
15
|
+
export declare function renderGistMarkdown(args: any, value: any): string;
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { sanitizeCell } from './common.js';
|
|
2
|
+
/**
|
|
3
|
+
* 解析 gh gist list 的制表符/多列纯文本输出
|
|
4
|
+
*/
|
|
5
|
+
export function parseGistListOutput(output) {
|
|
6
|
+
const trimmed = (output || '').trim();
|
|
7
|
+
if (!trimmed)
|
|
8
|
+
return [];
|
|
9
|
+
const lines = trimmed.split(/[\r\n]+/).map((l) => l.trim()).filter(Boolean);
|
|
10
|
+
const results = [];
|
|
11
|
+
for (const line of lines) {
|
|
12
|
+
let parts = line.split('\t');
|
|
13
|
+
if (parts.length < 2) {
|
|
14
|
+
parts = line.split(/\s{2,}/);
|
|
15
|
+
}
|
|
16
|
+
if (parts.length >= 1 && parts[0].length >= 8) {
|
|
17
|
+
results.push({
|
|
18
|
+
id: parts[0].trim(),
|
|
19
|
+
description: (parts[1] || '').trim(),
|
|
20
|
+
filesCount: (parts[2] || '').trim(),
|
|
21
|
+
visibility: (parts[3] || 'secret').trim(),
|
|
22
|
+
updatedAt: (parts[4] || '').trim(),
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return results;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Gist 领域渲染器:负责 GitHub Gist 列表、代码正文、创建/删除反馈的 Markdown 格式化
|
|
30
|
+
*/
|
|
31
|
+
export function renderGistMarkdown(args, value) {
|
|
32
|
+
if (!value)
|
|
33
|
+
return '无返回内容';
|
|
34
|
+
// 1. 高危操作确认拦截报告
|
|
35
|
+
if (value.status === 'AWAITING_CONFIRMATION') {
|
|
36
|
+
return [
|
|
37
|
+
`> ### ${value.warning || '⚠️ 操作确认拦截'}`,
|
|
38
|
+
`> - **影响评估**: ${value.impact || ''}`,
|
|
39
|
+
`> - **确认指引**: ${value.requiredAction || '如确认继续,请在参数中附加 \\`confirm: true\\` 重新调用。'}`,
|
|
40
|
+
].join('\n');
|
|
41
|
+
}
|
|
42
|
+
if (typeof value.result === 'string')
|
|
43
|
+
return value.result;
|
|
44
|
+
// 2. create 操作卡片展示
|
|
45
|
+
if (args?.action === 'create' && value.url) {
|
|
46
|
+
const visBadge = value.public ? '🌐 Public' : '🔒 Secret (Unlisted)';
|
|
47
|
+
const descHint = value.description ? `\n> - **描述**: ${value.description}` : '';
|
|
48
|
+
return [
|
|
49
|
+
`✅ **成功创建 Gist 代码片段**:\n`,
|
|
50
|
+
`- **访问链接**: [${value.url}](${value.url})`,
|
|
51
|
+
`- **Gist ID**: \`${value.gist_id}\``,
|
|
52
|
+
`- **可见性**: ${visBadge}${descHint}`,
|
|
53
|
+
'',
|
|
54
|
+
'> ⚠️ **安全须知**: Secret Gist 属于未列出(Unlisted)公开可寻址资源,拥有链接的任何人均可访问,切勿存放私有凭证或敏感机密。',
|
|
55
|
+
].join('\n');
|
|
56
|
+
}
|
|
57
|
+
// 3. view 操作展示
|
|
58
|
+
if (args?.action === 'view') {
|
|
59
|
+
const raw = (value.content || value.rawText || '').trim();
|
|
60
|
+
const id = value.gist_id || args?.gist_id || '';
|
|
61
|
+
const fileHint = args?.filename ? ` (${args.filename})` : '';
|
|
62
|
+
return [
|
|
63
|
+
`### 📄 Gist 代码片段: \`${id}\`${fileHint}\n`,
|
|
64
|
+
'```',
|
|
65
|
+
raw || '无代码内容',
|
|
66
|
+
'```',
|
|
67
|
+
].join('\n');
|
|
68
|
+
}
|
|
69
|
+
// 4. list 操作表格展示
|
|
70
|
+
if (args?.action === 'list') {
|
|
71
|
+
const list = Array.isArray(value.items) ? value.items : [];
|
|
72
|
+
if (list.length === 0) {
|
|
73
|
+
return '📭 当前 GitHub 账号下尚未创建任何 Gist 代码片段。';
|
|
74
|
+
}
|
|
75
|
+
const rows = list.map((g) => {
|
|
76
|
+
const id = g.id ? `\`${g.id}\`` : '-';
|
|
77
|
+
const desc = sanitizeCell(g.description, 35);
|
|
78
|
+
const files = g.filesCount ? `\`${g.filesCount}\`` : '-';
|
|
79
|
+
const vis = g.visibility === 'public' ? '🌐 public' : '🔒 secret';
|
|
80
|
+
const updated = sanitizeCell(g.updatedAt, 20);
|
|
81
|
+
return `| ${id} | ${desc} | ${files} | ${vis} | ${updated} |`;
|
|
82
|
+
});
|
|
83
|
+
return [
|
|
84
|
+
`**Gist 代码片段列表 (${list.length} 个):**\n`,
|
|
85
|
+
'| Gist ID | 描述 / 摘要 | 文件数 | 可见性 | 最近更新 |',
|
|
86
|
+
'| :--- | :--- | :--- | :--- | :--- |',
|
|
87
|
+
...rows,
|
|
88
|
+
'',
|
|
89
|
+
'> 💡 **查看指南**: 调用 `github_gist(action: \'view\', gist_id: \'...\')` 可查看完整代码正文。',
|
|
90
|
+
].join('\n');
|
|
91
|
+
}
|
|
92
|
+
// 5. 消息提示(delete, edit 等)
|
|
93
|
+
if (typeof value.message === 'string') {
|
|
94
|
+
const extra = value.detail || value.output;
|
|
95
|
+
return `**${value.message}**` + (extra ? `\n\`\`\`\n${extra}\n\`\`\`` : '');
|
|
96
|
+
}
|
|
97
|
+
// 6. 兜底
|
|
98
|
+
return JSON.stringify(value, null, 2);
|
|
99
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { sanitizeCell, formatStateBadge } from './common.js';
|
|
2
|
+
/**
|
|
3
|
+
* Issue 领域渲染器:负责 Issue 列表多标签表格、单卡详情、指派人与图片附件提示
|
|
4
|
+
*/
|
|
5
|
+
export function renderIssueMarkdown(args, value) {
|
|
6
|
+
if (!value)
|
|
7
|
+
return '无返回内容';
|
|
8
|
+
if (value.status === 'AWAITING_CONFIRMATION') {
|
|
9
|
+
return [
|
|
10
|
+
`> ### ${value.warning || '⚠️ 高危操作拦截警告'}`,
|
|
11
|
+
`> - **影响评估**: ${value.impact || '该操作将改变远端仓库状态。'}`,
|
|
12
|
+
`> - **确认指引**: ${value.requiredAction || '如确认继续,请向用户核实并在参数中附加 `confirm: true` 重新调用。'}`,
|
|
13
|
+
].join('\n');
|
|
14
|
+
}
|
|
15
|
+
if (typeof value.result === 'string')
|
|
16
|
+
return value.result;
|
|
17
|
+
if (typeof value.message === 'string' && !value.items) {
|
|
18
|
+
const extra = value.detail || value.output;
|
|
19
|
+
return `**${value.message}**` + (value.url ? `\n🔗 链接: ${value.url}` : '') + (extra ? `\n\`\`\`\n${extra}\n\`\`\`` : '');
|
|
20
|
+
}
|
|
21
|
+
// 2.1 Issue 列表
|
|
22
|
+
if (Array.isArray(value.items) && args?.action === 'list') {
|
|
23
|
+
const list = value.items.filter(Boolean);
|
|
24
|
+
if (list.length === 0)
|
|
25
|
+
return '📭 当前仓库暂无匹配的 Issue。';
|
|
26
|
+
const rows = list.map((i) => {
|
|
27
|
+
const numLink = i.url ? `[#${i.number}](${i.url})` : `#${i.number}`;
|
|
28
|
+
const badge = formatStateBadge(i.state);
|
|
29
|
+
const title = sanitizeCell(i.title, 60);
|
|
30
|
+
const labels = Array.isArray(i.labels) && i.labels.length > 0
|
|
31
|
+
? i.labels.map((l) => `\`${sanitizeCell(l.name || l, 15)}\``).join(' ')
|
|
32
|
+
: '-';
|
|
33
|
+
const author = i.author?.login ? `@${i.author.login}` : (typeof i.author === 'string' ? `@${i.author}` : '-');
|
|
34
|
+
const date = i.updatedAt ? i.updatedAt.slice(0, 10) : '-';
|
|
35
|
+
return `| ${numLink} | ${badge} | ${title} | ${labels} | ${author} | ${date} |`;
|
|
36
|
+
});
|
|
37
|
+
return [
|
|
38
|
+
`**找到 ${list.length} 个 Issue:**\n`,
|
|
39
|
+
'| 编号 | 状态 | 标题 | 标签 | 作者 | 更新日期 |',
|
|
40
|
+
'| :--- | :--- | :--- | :--- | :--- | :--- |',
|
|
41
|
+
...rows,
|
|
42
|
+
].join('\n');
|
|
43
|
+
}
|
|
44
|
+
// 2.2 Issue View 详情
|
|
45
|
+
if (args?.action === 'view' && value.number) {
|
|
46
|
+
const link = value.url ? `[#${value.number}](${value.url})` : `#${value.number}`;
|
|
47
|
+
const badge = formatStateBadge(value.state);
|
|
48
|
+
const author = value.author?.login ? `@${value.author.login}` : '-';
|
|
49
|
+
const lines = [
|
|
50
|
+
`### ${badge} ${value.title} (${link})`,
|
|
51
|
+
`- **作者**: ${author} | **更新时间**: ${value.updatedAt?.slice(0, 16) || '-'}`,
|
|
52
|
+
];
|
|
53
|
+
if (Array.isArray(value.labels) && value.labels.length > 0) {
|
|
54
|
+
lines.push(`- **标签**: ${value.labels.map((l) => `\`${l.name || l}\``).join(' ')}`);
|
|
55
|
+
}
|
|
56
|
+
if (Array.isArray(value.assignees) && value.assignees.length > 0) {
|
|
57
|
+
lines.push(`- **指派人**: ${value.assignees.map((a) => `@${a.login || a}`).join(' ')}`);
|
|
58
|
+
}
|
|
59
|
+
if (value.body) {
|
|
60
|
+
lines.push('\n**议题正文:**\n```markdown\n' + sanitizeCell(value.body, 300) + '\n```');
|
|
61
|
+
}
|
|
62
|
+
// 图片附件清单(view 附带 URL 清单,view_images 按需下载查看)
|
|
63
|
+
if (Array.isArray(value.images) && value.images.length > 0) {
|
|
64
|
+
lines.push(`- **📎 图片附件 (${value.images.length}):** 调用 \`github_issue(action: 'view_images', issue_number: ${value.number})\` 可下载查看`);
|
|
65
|
+
}
|
|
66
|
+
return lines.join('\n');
|
|
67
|
+
}
|
|
68
|
+
// 兜底降级
|
|
69
|
+
return JSON.stringify(value, null, 2);
|
|
70
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { sanitizeCell } from './common.js';
|
|
2
|
+
/**
|
|
3
|
+
* Label 领域渲染器:负责 GitHub Labels 列表、创建、编辑、克隆与删除的 Markdown 格式化
|
|
4
|
+
*/
|
|
5
|
+
export function renderLabelMarkdown(args, value) {
|
|
6
|
+
if (!value)
|
|
7
|
+
return '无返回内容';
|
|
8
|
+
// 1. 高危操作确认拦截报告
|
|
9
|
+
if (value.status === 'AWAITING_CONFIRMATION') {
|
|
10
|
+
return [
|
|
11
|
+
`> ### ${value.warning || '⚠️ 操作确认拦截'}`,
|
|
12
|
+
`> - **影响评估**: ${value.impact || ''}`,
|
|
13
|
+
`> - **确认指引**: ${value.requiredAction || '如确认继续,请在参数中附加 \`confirm: true\` 重新调用。'}`,
|
|
14
|
+
].join('\n');
|
|
15
|
+
}
|
|
16
|
+
if (typeof value.result === 'string')
|
|
17
|
+
return value.result;
|
|
18
|
+
// 2. 单操作消息提示(create, edit, delete, clone 等)
|
|
19
|
+
if (typeof value.message === 'string' && !value.items) {
|
|
20
|
+
const extra = value.detail || value.output;
|
|
21
|
+
return `**${value.message}**` + (extra ? `\n\`\`\`\n${extra}\n\`\`\`` : '');
|
|
22
|
+
}
|
|
23
|
+
// 3. 标签列表展示
|
|
24
|
+
if (Array.isArray(value.items)) {
|
|
25
|
+
const list = value.items.filter(Boolean);
|
|
26
|
+
if (list.length === 0) {
|
|
27
|
+
return args?.search
|
|
28
|
+
? `📭 未检索到匹配关键词 "${args.search}" 的标签。`
|
|
29
|
+
: '📭 仓库中尚未创建任何标签。';
|
|
30
|
+
}
|
|
31
|
+
const rows = list.map((item) => {
|
|
32
|
+
const name = item.name ? `\`${sanitizeCell(item.name, 40)}\`` : '-';
|
|
33
|
+
const colorRaw = item.color ? String(item.color).replace(/^#/, '') : '';
|
|
34
|
+
const color = colorRaw ? `\`#${colorRaw.toLowerCase()}\`` : '-';
|
|
35
|
+
const desc = sanitizeCell(item.description, 60);
|
|
36
|
+
return `| ${name} | ${color} | ${desc} |`;
|
|
37
|
+
});
|
|
38
|
+
const searchHint = args?.search ? ` (过滤关键词: "${args.search}")` : '';
|
|
39
|
+
return [
|
|
40
|
+
`**仓库标签列表 (${list.length} 个)${searchHint}:**\n`,
|
|
41
|
+
'| 标签 | 颜色 | 描述 |',
|
|
42
|
+
'| :--- | :--- | :--- |',
|
|
43
|
+
...rows,
|
|
44
|
+
].join('\n');
|
|
45
|
+
}
|
|
46
|
+
// 4. 兜底降级
|
|
47
|
+
return JSON.stringify(value, null, 2);
|
|
48
|
+
}
|
|
@@ -1,35 +1,22 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* DSH GitHub Flow - Native Markdown
|
|
2
|
+
* DSH GitHub Flow - Native Markdown 格式化渲染引擎门面入口
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* 2. 节省 70%+ 的会话上下文 Token,极大加速长对话推理速度;
|
|
7
|
-
* 3. 嵌入可点击超链接与直观的状态药丸 Emoji,提升人类与模型阅读体验;
|
|
8
|
-
* 4. 严谨防御 Markdown 表格竖线破坏、缺失值回退与异常对象降级。
|
|
4
|
+
* 为保持向后兼容性与构建产物一致性,本入口统一 Re-export 全部领域渲染器
|
|
5
|
+
* 与通用徽章工具,各 Agent Tool 与自动化单测可无感引用。
|
|
9
6
|
*/
|
|
10
|
-
|
|
11
|
-
export
|
|
12
|
-
|
|
13
|
-
export
|
|
14
|
-
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
|
|
20
|
-
export
|
|
21
|
-
|
|
22
|
-
export
|
|
23
|
-
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
* 不同 gh 版本上走不同链路);一条 blockquote 注释成本一行,换链路透明。
|
|
27
|
-
*/
|
|
28
|
-
export declare function appendDegradedNote(value: any): string;
|
|
29
|
-
export declare function renderPrMarkdown(args: any, value: any): string;
|
|
30
|
-
export declare function renderIssueMarkdown(args: any, value: any): string;
|
|
31
|
-
export declare function renderRunMarkdown(args: any, value: any): string;
|
|
32
|
-
export declare function renderRepoMarkdown(args: any, value: any): string;
|
|
33
|
-
export declare function formatReleaseBadge(isDraft?: boolean, isPrerelease?: boolean): string;
|
|
34
|
-
export declare function renderReleaseMarkdown(args: any, value: any): string;
|
|
35
|
-
export declare function renderSkillMarkdown(args: any, value: any): string;
|
|
7
|
+
export * from './common.js';
|
|
8
|
+
export * from './pr.js';
|
|
9
|
+
export * from './issue.js';
|
|
10
|
+
export * from './run.js';
|
|
11
|
+
export * from './repo.js';
|
|
12
|
+
export * from './release.js';
|
|
13
|
+
export * from './skill.js';
|
|
14
|
+
export * from './label.js';
|
|
15
|
+
export * from './ruleset.js';
|
|
16
|
+
export * from './cache.js';
|
|
17
|
+
export * from './gist.js';
|
|
18
|
+
export * from './status.js';
|
|
19
|
+
export * from './agent-task.js';
|
|
20
|
+
export * from './discussion.js';
|
|
21
|
+
export * from './project.js';
|
|
22
|
+
export * from './codespace.js';
|