@yinuo-ngm/mcp-server 0.1.2 → 0.1.3
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 +191 -208
- package/lib/audit/audit-event.d.ts +14 -0
- package/lib/audit/audit-event.js +2 -0
- package/lib/audit/audit-log.service.d.ts +7 -0
- package/lib/audit/audit-log.service.js +187 -0
- package/lib/audit/redact.d.ts +3 -0
- package/lib/audit/redact.js +28 -0
- package/lib/catalog/capabilities/blocked-local-actions.d.ts +1 -0
- package/lib/catalog/capabilities/blocked-local-actions.js +18 -0
- package/lib/catalog/capabilities/frontend-standard.d.ts +2 -0
- package/lib/catalog/capabilities/frontend-standard.js +36 -0
- package/lib/catalog/capabilities/hub-v2.d.ts +2 -0
- package/lib/catalog/capabilities/hub-v2.js +34 -0
- package/lib/catalog/capabilities/nginx.d.ts +2 -0
- package/lib/catalog/capabilities/nginx.js +23 -0
- package/lib/catalog/capabilities/project.d.ts +2 -0
- package/lib/catalog/capabilities/project.js +23 -0
- package/lib/catalog/capabilities/router.d.ts +2 -0
- package/lib/catalog/capabilities/router.js +11 -0
- package/lib/catalog/capabilities/runtime.d.ts +2 -0
- package/lib/catalog/capabilities/runtime.js +17 -0
- package/lib/catalog/capabilities/workspace.d.ts +2 -0
- package/lib/catalog/capabilities/workspace.js +23 -0
- package/lib/catalog/helpers.d.ts +3 -0
- package/lib/catalog/helpers.js +42 -0
- package/lib/catalog/index.d.ts +4 -0
- package/lib/catalog/index.js +23 -0
- package/lib/catalog/tools/frontend-standard.d.ts +2 -0
- package/lib/catalog/tools/frontend-standard.js +166 -0
- package/lib/catalog/tools/hub-v2-api.d.ts +2 -0
- package/lib/catalog/tools/hub-v2-api.js +124 -0
- package/lib/catalog/tools/hub-v2-docs.d.ts +2 -0
- package/lib/catalog/tools/hub-v2-docs.js +40 -0
- package/lib/catalog/tools/nginx.d.ts +2 -0
- package/lib/catalog/tools/nginx.js +96 -0
- package/lib/catalog/tools/project.d.ts +2 -0
- package/lib/catalog/tools/project.js +138 -0
- package/lib/catalog/tools/router.d.ts +2 -0
- package/lib/catalog/tools/router.js +26 -0
- package/lib/catalog/tools/runtime.d.ts +2 -0
- package/lib/catalog/tools/runtime.js +47 -0
- package/lib/catalog/tools/workspace.d.ts +2 -0
- package/lib/catalog/tools/workspace.js +75 -0
- package/lib/catalog/types.d.ts +15 -0
- package/lib/catalog/types.js +2 -0
- package/lib/context/create-tool-context.js +11 -10
- package/lib/context/local-server-client.d.ts +2 -0
- package/lib/context/local-server-client.js +174 -0
- package/lib/context/tool-context.d.ts +36 -0
- package/lib/doctor.d.ts +8 -0
- package/lib/doctor.js +221 -0
- package/lib/errors/error-codes.d.ts +12 -0
- package/lib/errors/error-codes.js +14 -0
- package/lib/errors/mcp-tool-error.d.ts +8 -0
- package/lib/errors/mcp-tool-error.js +14 -0
- package/lib/filesystem/project-files.d.ts +18 -0
- package/lib/filesystem/project-files.js +112 -0
- package/lib/git/local-git-read-service.d.ts +2 -0
- package/lib/git/local-git-read-service.js +96 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.js +4 -0
- package/lib/policy/assert-tool-policy.js +10 -1
- package/lib/register-tools.js +67 -10
- package/lib/registry/tool-names.d.ts +95 -0
- package/lib/registry/tool-names.js +97 -0
- package/lib/services/path-guard.service.d.ts +4 -0
- package/lib/services/path-guard.service.js +75 -0
- package/lib/services/permission.service.d.ts +5 -0
- package/lib/services/permission.service.js +38 -0
- package/lib/services/project-resolver.service.d.ts +32 -0
- package/lib/services/project-resolver.service.js +95 -0
- package/lib/standard/frontend-standard.default.d.ts +2 -0
- package/lib/standard/frontend-standard.default.js +51 -0
- package/lib/standard/frontend-standard.schema.d.ts +196 -0
- package/lib/standard/frontend-standard.schema.js +61 -0
- package/lib/standard/frontend-standard.service.d.ts +79 -0
- package/lib/standard/frontend-standard.service.js +115 -0
- package/lib/standard/project-scan.d.ts +9 -0
- package/lib/standard/project-scan.js +91 -0
- package/lib/standard/validators/angular-structure.validator.d.ts +4 -0
- package/lib/standard/validators/angular-structure.validator.js +75 -0
- package/lib/standard/validators/component.validator.d.ts +4 -0
- package/lib/standard/validators/component.validator.js +94 -0
- package/lib/standard/validators/git.validator.d.ts +8 -0
- package/lib/standard/validators/git.validator.js +32 -0
- package/lib/standard/validators/review.validator.d.ts +15 -0
- package/lib/standard/validators/review.validator.js +67 -0
- package/lib/standard/validators/test.validator.d.ts +19 -0
- package/lib/standard/validators/test.validator.js +89 -0
- package/lib/tool-catalog.d.ts +2 -0
- package/lib/tool-catalog.js +6 -0
- package/lib/tools/angular/angular-standard.tools.d.ts +2 -0
- package/lib/tools/angular/angular-standard.tools.js +53 -0
- package/lib/tools/angular/index.d.ts +1 -0
- package/lib/tools/angular/index.js +5 -0
- package/lib/tools/capability.tools.d.ts +2 -0
- package/lib/tools/capability.tools.js +205 -0
- package/lib/tools/controlled/index.d.ts +2 -0
- package/lib/tools/controlled/index.js +13 -0
- package/lib/tools/controlled/local-server.d.ts +6 -0
- package/lib/tools/controlled/local-server.js +17 -0
- package/lib/tools/controlled/operation-policy.d.ts +22 -0
- package/lib/tools/controlled/operation-policy.js +50 -0
- package/lib/tools/controlled/operation-result.d.ts +30 -0
- package/lib/tools/controlled/operation-result.js +33 -0
- package/lib/tools/controlled/schemas.d.ts +159 -0
- package/lib/tools/controlled/schemas.js +49 -0
- package/lib/tools/controlled.tools.d.ts +1 -0
- package/lib/tools/controlled.tools.js +5 -0
- package/lib/tools/file-write.tools.d.ts +2 -0
- package/lib/tools/file-write.tools.js +70 -0
- package/lib/tools/git.tools.js +109 -8
- package/lib/tools/hub-v2/client.d.ts +6 -1
- package/lib/tools/hub-v2/client.js +15 -0
- package/lib/tools/hub-v2/config/config-paths.d.ts +2 -0
- package/lib/tools/hub-v2/config/config-paths.js +17 -0
- package/lib/tools/hub-v2/config/env.d.ts +1 -0
- package/lib/tools/hub-v2/config/env.js +12 -0
- package/lib/tools/hub-v2/config/index.d.ts +8 -0
- package/lib/tools/hub-v2/config/index.js +18 -0
- package/lib/tools/hub-v2/config/jsonc.d.ts +5 -0
- package/lib/tools/hub-v2/config/jsonc.js +86 -0
- package/lib/tools/hub-v2/config/load-config.d.ts +18 -0
- package/lib/tools/hub-v2/config/load-config.js +93 -0
- package/lib/tools/hub-v2/config/project-selector.d.ts +5 -0
- package/lib/tools/hub-v2/config/project-selector.js +92 -0
- package/lib/tools/hub-v2/config/resolve-context.d.ts +13 -0
- package/lib/tools/hub-v2/config/resolve-context.js +33 -0
- package/lib/tools/hub-v2/docs.tools.js +138 -4
- package/lib/tools/hub-v2/index.js +2 -0
- package/lib/tools/hub-v2/issues-workflow.tools.d.ts +2 -0
- package/lib/tools/hub-v2/issues-workflow.tools.js +199 -0
- package/lib/tools/hub-v2/issues.tools.js +96 -6
- package/lib/tools/hub-v2/projects.tools.js +16 -3
- package/lib/tools/hub-v2/raw.d.ts +8 -0
- package/lib/tools/hub-v2/raw.js +33 -0
- package/lib/tools/hub-v2/rd.tools.js +167 -8
- package/lib/tools/hub-v2/schemas.d.ts +668 -71
- package/lib/tools/hub-v2/schemas.js +152 -1
- package/lib/tools/hub-v2/upload.tools.js +53 -5
- package/lib/tools/index.d.ts +1 -0
- package/lib/tools/index.js +22 -0
- package/lib/tools/log.tools.js +33 -6
- package/lib/tools/nginx/index.d.ts +1 -0
- package/lib/tools/nginx/index.js +5 -0
- package/lib/tools/nginx/nginx-control.tools.d.ts +2 -0
- package/lib/tools/nginx/nginx-control.tools.js +133 -0
- package/lib/tools/nginx/nginx-proxy.d.ts +24 -0
- package/lib/tools/nginx/nginx-proxy.js +154 -0
- package/lib/tools/nginx.tools.d.ts +2 -0
- package/lib/tools/nginx.tools.js +111 -0
- package/lib/tools/project/index.d.ts +2 -0
- package/lib/tools/project/index.js +7 -0
- package/lib/tools/project/launch-status.d.ts +10 -0
- package/lib/tools/project/launch-status.js +78 -0
- package/lib/tools/project/local-diagnostics.d.ts +19 -0
- package/lib/tools/project/local-diagnostics.js +97 -0
- package/lib/tools/project/observe-redaction.d.ts +3 -0
- package/lib/tools/project/observe-redaction.js +25 -0
- package/lib/tools/project/observe-runtime.d.ts +72 -0
- package/lib/tools/project/observe-runtime.js +147 -0
- package/lib/tools/project/project-control.tools.d.ts +2 -0
- package/lib/tools/project/project-control.tools.js +216 -0
- package/lib/tools/project/project-observe.tools.d.ts +2 -0
- package/lib/tools/project/project-observe.tools.js +191 -0
- package/lib/tools/project/runtime-config.d.ts +7 -0
- package/lib/tools/project/runtime-config.js +50 -0
- package/lib/tools/project-observe.tools.d.ts +1 -0
- package/lib/tools/project-observe.tools.js +5 -0
- package/lib/tools/project.tools.d.ts +8 -0
- package/lib/tools/project.tools.js +97 -6
- package/lib/tools/proxy.tools.js +4 -4
- package/lib/tools/review/index.d.ts +1 -0
- package/lib/tools/review/index.js +5 -0
- package/lib/tools/review/review.tools.d.ts +2 -0
- package/lib/tools/review/review.tools.js +152 -0
- package/lib/tools/runtime/index.d.ts +1 -0
- package/lib/tools/runtime/index.js +5 -0
- package/lib/tools/runtime/runtime-control.tools.d.ts +2 -0
- package/lib/tools/runtime/runtime-control.tools.js +89 -0
- package/lib/tools/runtime.tools.js +41 -4
- package/lib/tools/standard/index.d.ts +1 -0
- package/lib/tools/standard/index.js +5 -0
- package/lib/tools/standard/standard.tools.d.ts +2 -0
- package/lib/tools/standard/standard.tools.js +91 -0
- package/lib/tools/task.tools.js +44 -9
- package/lib/tools/test/index.d.ts +1 -0
- package/lib/tools/test/index.js +5 -0
- package/lib/tools/test/test-standard.tools.d.ts +2 -0
- package/lib/tools/test/test-standard.tools.js +51 -0
- package/lib/tools/tool-catalog.d.ts +2 -0
- package/lib/tools/tool-catalog.js +7 -0
- package/lib/tools/workflow/frontend-workflow.tools.d.ts +2 -0
- package/lib/tools/workflow/frontend-workflow.tools.js +364 -0
- package/lib/tools/workflow/index.d.ts +1 -0
- package/lib/tools/workflow/index.js +5 -0
- package/lib/tools/workspace-package.d.ts +22 -0
- package/lib/tools/workspace-package.js +130 -0
- package/lib/tools/workspace.tools.d.ts +7 -0
- package/lib/tools/workspace.tools.js +336 -0
- package/lib/utils/errors.js +6 -1
- package/lib/utils/result.d.ts +9 -0
- package/lib/utils/result.js +9 -0
- package/lib/workflow/frontend-task.schema.d.ts +83 -0
- package/lib/workflow/frontend-task.schema.js +25 -0
- package/lib/workflow/frontend-task.service.d.ts +57 -0
- package/lib/workflow/frontend-task.service.js +195 -0
- package/lib/workflow/workflow-status.d.ts +2 -0
- package/lib/workflow/workflow-status.js +14 -0
- package/lib/workflow/workflow-transition.d.ts +9 -0
- package/lib/workflow/workflow-transition.js +38 -0
- package/package.json +5 -3
- package/lib/tools/hub-v2/config.d.ts +0 -34
- package/lib/tools/hub-v2/config.js +0 -297
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.hubV2IssueWorkflowTools = hubV2IssueWorkflowTools;
|
|
4
|
+
const client_1 = require("./client");
|
|
5
|
+
const index_1 = require("./config/index");
|
|
6
|
+
const raw_1 = require("./raw");
|
|
7
|
+
const schemas_1 = require("./schemas");
|
|
8
|
+
const result_1 = require("../../utils/result");
|
|
9
|
+
function hubV2IssueWorkflowTools() {
|
|
10
|
+
return [
|
|
11
|
+
issueReadTool("hub_v2_issues_logs_list", "List Hub V2 issue logs with Project Token.", "logs"),
|
|
12
|
+
issueReadTool("hub_v2_issues_comments_list", "List Hub V2 issue comments with Project Token.", "comments"),
|
|
13
|
+
issueReadTool("hub_v2_issues_participants_list", "List Hub V2 issue participants with Project Token.", "participants"),
|
|
14
|
+
issueReadTool("hub_v2_issues_attachments_list", "List Hub V2 issue attachments with Project Token.", "attachments"),
|
|
15
|
+
issueReadTool("hub_v2_issues_branches_list", "List Hub V2 issue collaboration branches with Project Token.", "branches"),
|
|
16
|
+
{
|
|
17
|
+
name: "hub_v2_issues_attachment_raw_get",
|
|
18
|
+
description: "Read one Hub V2 issue attachment raw file as base64 with Project Token.",
|
|
19
|
+
riskLevel: "read",
|
|
20
|
+
inputSchema: schemas_1.issueAttachmentRawSchema,
|
|
21
|
+
async handler(args) {
|
|
22
|
+
const ctx = (0, index_1.resolveHubV2Context)(args, "project");
|
|
23
|
+
const client = new client_1.HubV2Client(ctx);
|
|
24
|
+
const data = await (0, raw_1.readRawAsBase64)(client, client.tokenUrl(`/issues/${encodeURIComponent(args.issueId)}/attachments/${encodeURIComponent(args.attachmentId)}/raw`), args.maxBytes);
|
|
25
|
+
return (0, result_1.ok)("hub_v2_issues_attachment_raw_get", data);
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
name: "hub_v2_issues_upload_raw_get",
|
|
30
|
+
description: "Read one Hub V2 issue Markdown upload raw file as base64 with Project Token.",
|
|
31
|
+
riskLevel: "read",
|
|
32
|
+
inputSchema: schemas_1.issueUploadRawSchema,
|
|
33
|
+
async handler(args) {
|
|
34
|
+
const ctx = (0, index_1.resolveHubV2Context)(args, "project");
|
|
35
|
+
const client = new client_1.HubV2Client(ctx);
|
|
36
|
+
const data = await (0, raw_1.readRawAsBase64)(client, client.tokenUrl(`/issues/${encodeURIComponent(args.issueId)}/uploads/${encodeURIComponent(args.uploadId)}/raw`), args.maxBytes);
|
|
37
|
+
return (0, result_1.ok)("hub_v2_issues_upload_raw_get", data);
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
issueSimpleWriteTool("hub_v2_issues_claim", "Preview or claim a Hub V2 issue with Personal Token.", "claim", "issue:assign:write"),
|
|
41
|
+
{
|
|
42
|
+
name: "hub_v2_issues_participant_remove",
|
|
43
|
+
description: "Preview or remove a Hub V2 issue collaborator with Personal Token.",
|
|
44
|
+
riskLevel: "write",
|
|
45
|
+
inputSchema: schemas_1.issueParticipantRemoveSchema,
|
|
46
|
+
allowPreviewWhenBlocked: true,
|
|
47
|
+
isConfirmed: (args) => args.confirm === true,
|
|
48
|
+
async handler(args) {
|
|
49
|
+
const path = `/issues/${encodeURIComponent(args.issueId)}/participants/${encodeURIComponent(args.participantId)}`;
|
|
50
|
+
if (!args.confirm) {
|
|
51
|
+
return (0, result_1.ok)("hub_v2_issues_participant_remove", {
|
|
52
|
+
code: "PREVIEW",
|
|
53
|
+
message: "set confirm=true to execute this write operation",
|
|
54
|
+
data: {
|
|
55
|
+
method: "DELETE",
|
|
56
|
+
path,
|
|
57
|
+
requiredScope: "issue:participant:write",
|
|
58
|
+
},
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
const ctx = (0, index_1.resolveHubV2Context)(args, "personal");
|
|
62
|
+
const client = new client_1.HubV2Client(ctx);
|
|
63
|
+
const data = await client.request("DELETE", client.personalUrl(path));
|
|
64
|
+
return (0, result_1.ok)("hub_v2_issues_participant_remove", data);
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
name: "hub_v2_issues_branch_start_mine",
|
|
69
|
+
description: "Preview or start the current user's Hub V2 issue collaboration branch with Personal Token.",
|
|
70
|
+
riskLevel: "write",
|
|
71
|
+
inputSchema: schemas_1.issueBranchStartMineSchema,
|
|
72
|
+
allowPreviewWhenBlocked: true,
|
|
73
|
+
isConfirmed: (args) => args.confirm === true,
|
|
74
|
+
async handler(args) {
|
|
75
|
+
return issueBodyWrite("hub_v2_issues_branch_start_mine", args, "branches/start-mine", "issue:branch:write", {
|
|
76
|
+
title: args.title,
|
|
77
|
+
});
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
issueBranchActionTool("hub_v2_issues_branch_start", "Preview or start a Hub V2 issue collaboration branch with Personal Token.", "start"),
|
|
81
|
+
{
|
|
82
|
+
name: "hub_v2_issues_branch_complete",
|
|
83
|
+
description: "Preview or complete a Hub V2 issue collaboration branch with Personal Token.",
|
|
84
|
+
riskLevel: "write",
|
|
85
|
+
inputSchema: schemas_1.issueBranchCompleteSchema,
|
|
86
|
+
allowPreviewWhenBlocked: true,
|
|
87
|
+
isConfirmed: (args) => args.confirm === true,
|
|
88
|
+
async handler(args) {
|
|
89
|
+
const path = `branches/${encodeURIComponent(args.branchId)}/complete`;
|
|
90
|
+
return issueBodyWrite("hub_v2_issues_branch_complete", args, path, "issue:branch:write", {
|
|
91
|
+
summary: args.summary,
|
|
92
|
+
});
|
|
93
|
+
},
|
|
94
|
+
},
|
|
95
|
+
issueSimpleWriteTool("hub_v2_issues_start", "Preview or start Hub V2 issue processing with Personal Token.", "start", "issue:transition:write"),
|
|
96
|
+
issueSimpleWriteTool("hub_v2_issues_wait_update", "Preview or move a Hub V2 issue to waiting-update with Personal Token.", "wait-update", "issue:transition:write"),
|
|
97
|
+
{
|
|
98
|
+
name: "hub_v2_issues_resolve",
|
|
99
|
+
description: "Preview or resolve a Hub V2 issue with Personal Token.",
|
|
100
|
+
riskLevel: "write",
|
|
101
|
+
inputSchema: schemas_1.issueResolveSchema,
|
|
102
|
+
allowPreviewWhenBlocked: true,
|
|
103
|
+
isConfirmed: (args) => args.confirm === true,
|
|
104
|
+
async handler(args) {
|
|
105
|
+
return issueBodyWrite("hub_v2_issues_resolve", args, "resolve", "issue:transition:write", {
|
|
106
|
+
resolutionSummary: args.resolutionSummary,
|
|
107
|
+
});
|
|
108
|
+
},
|
|
109
|
+
},
|
|
110
|
+
issueSimpleWriteTool("hub_v2_issues_verify", "Preview or verify a Hub V2 issue with Personal Token.", "verify", "issue:transition:write"),
|
|
111
|
+
{
|
|
112
|
+
name: "hub_v2_issues_reopen",
|
|
113
|
+
description: "Preview or reopen a Hub V2 issue with Personal Token.",
|
|
114
|
+
riskLevel: "write",
|
|
115
|
+
inputSchema: schemas_1.issueReopenSchema,
|
|
116
|
+
allowPreviewWhenBlocked: true,
|
|
117
|
+
isConfirmed: (args) => args.confirm === true,
|
|
118
|
+
async handler(args) {
|
|
119
|
+
return issueBodyWrite("hub_v2_issues_reopen", args, "reopen", "issue:transition:write", {
|
|
120
|
+
remark: args.remark,
|
|
121
|
+
});
|
|
122
|
+
},
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
name: "hub_v2_issues_close",
|
|
126
|
+
description: "Preview or close a Hub V2 issue with Personal Token.",
|
|
127
|
+
riskLevel: "write",
|
|
128
|
+
inputSchema: schemas_1.issueCloseSchema,
|
|
129
|
+
allowPreviewWhenBlocked: true,
|
|
130
|
+
isConfirmed: (args) => args.confirm === true,
|
|
131
|
+
async handler(args) {
|
|
132
|
+
return issueBodyWrite("hub_v2_issues_close", args, "close", "issue:transition:write", {
|
|
133
|
+
reason: args.reason,
|
|
134
|
+
remark: args.remark,
|
|
135
|
+
});
|
|
136
|
+
},
|
|
137
|
+
},
|
|
138
|
+
];
|
|
139
|
+
}
|
|
140
|
+
function issueReadTool(name, description, suffix) {
|
|
141
|
+
return {
|
|
142
|
+
name,
|
|
143
|
+
description,
|
|
144
|
+
riskLevel: "read",
|
|
145
|
+
inputSchema: schemas_1.issueReadDetailSchema,
|
|
146
|
+
async handler(args) {
|
|
147
|
+
const ctx = (0, index_1.resolveHubV2Context)(args, "project");
|
|
148
|
+
const client = new client_1.HubV2Client(ctx);
|
|
149
|
+
const data = await client.request("GET", client.tokenUrl(`/issues/${encodeURIComponent(args.issueId)}/${suffix}`));
|
|
150
|
+
return (0, result_1.ok)(name, data);
|
|
151
|
+
},
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
function issueSimpleWriteTool(name, description, suffix, requiredScope) {
|
|
155
|
+
return {
|
|
156
|
+
name,
|
|
157
|
+
description,
|
|
158
|
+
riskLevel: "write",
|
|
159
|
+
inputSchema: schemas_1.issueSimpleWriteSchema,
|
|
160
|
+
allowPreviewWhenBlocked: true,
|
|
161
|
+
isConfirmed: (args) => args.confirm === true,
|
|
162
|
+
async handler(args) {
|
|
163
|
+
return issueBodyWrite(name, args, suffix, requiredScope);
|
|
164
|
+
},
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
function issueBranchActionTool(name, description, suffix) {
|
|
168
|
+
return {
|
|
169
|
+
name,
|
|
170
|
+
description,
|
|
171
|
+
riskLevel: "write",
|
|
172
|
+
inputSchema: schemas_1.issueBranchActionSchema,
|
|
173
|
+
allowPreviewWhenBlocked: true,
|
|
174
|
+
isConfirmed: (args) => args.confirm === true,
|
|
175
|
+
async handler(args) {
|
|
176
|
+
return issueBodyWrite(name, args, `branches/${encodeURIComponent(args.branchId)}/${suffix}`, "issue:branch:write");
|
|
177
|
+
},
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
async function issueBodyWrite(name, args, suffix, requiredScope, body = {}) {
|
|
181
|
+
const path = `/issues/${encodeURIComponent(args.issueId)}/${suffix}`;
|
|
182
|
+
const compactBody = (0, client_1.compact)(body);
|
|
183
|
+
if (!args.confirm) {
|
|
184
|
+
return (0, result_1.ok)(name, {
|
|
185
|
+
code: "PREVIEW",
|
|
186
|
+
message: "set confirm=true to execute this write operation",
|
|
187
|
+
data: {
|
|
188
|
+
method: "POST",
|
|
189
|
+
path,
|
|
190
|
+
requiredScope,
|
|
191
|
+
...(Object.keys(compactBody).length > 0 ? { body: compactBody } : {}),
|
|
192
|
+
},
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
const ctx = (0, index_1.resolveHubV2Context)(args, "personal");
|
|
196
|
+
const client = new client_1.HubV2Client(ctx);
|
|
197
|
+
const data = await client.request("POST", client.personalUrl(path), compactBody);
|
|
198
|
+
return (0, result_1.ok)(name, data);
|
|
199
|
+
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.hubV2IssuesTools = hubV2IssuesTools;
|
|
4
4
|
const client_1 = require("./client");
|
|
5
|
-
const
|
|
5
|
+
const index_1 = require("./config/index");
|
|
6
6
|
const schemas_1 = require("./schemas");
|
|
7
7
|
const result_1 = require("../../utils/result");
|
|
8
8
|
function hubV2IssuesTools() {
|
|
@@ -13,7 +13,7 @@ function hubV2IssuesTools() {
|
|
|
13
13
|
riskLevel: "read",
|
|
14
14
|
inputSchema: schemas_1.issuesListSchema,
|
|
15
15
|
async handler(args) {
|
|
16
|
-
const ctx = (0,
|
|
16
|
+
const ctx = (0, index_1.resolveHubV2Context)(args, "project");
|
|
17
17
|
const client = new client_1.HubV2Client(ctx);
|
|
18
18
|
const data = await client.request("GET", client.tokenUrl("/issues", {
|
|
19
19
|
page: args.page ?? 1,
|
|
@@ -34,7 +34,7 @@ function hubV2IssuesTools() {
|
|
|
34
34
|
riskLevel: "read",
|
|
35
35
|
inputSchema: schemas_1.issueGetSchema,
|
|
36
36
|
async handler(args) {
|
|
37
|
-
const ctx = (0,
|
|
37
|
+
const ctx = (0, index_1.resolveHubV2Context)(args, "project");
|
|
38
38
|
const client = new client_1.HubV2Client(ctx);
|
|
39
39
|
const data = await client.request("GET", client.tokenUrl(`/issues/${encodeURIComponent(args.issueId)}`));
|
|
40
40
|
return (0, result_1.ok)("hub_v2_issues_get", data);
|
|
@@ -73,7 +73,7 @@ function hubV2IssuesTools() {
|
|
|
73
73
|
},
|
|
74
74
|
});
|
|
75
75
|
}
|
|
76
|
-
const ctx = (0,
|
|
76
|
+
const ctx = (0, index_1.resolveHubV2Context)(args, "personal");
|
|
77
77
|
const client = new client_1.HubV2Client(ctx);
|
|
78
78
|
const data = await client.request("POST", client.personalUrl(path), body);
|
|
79
79
|
return (0, result_1.ok)("hub_v2_issues_create", data);
|
|
@@ -104,12 +104,102 @@ function hubV2IssuesTools() {
|
|
|
104
104
|
},
|
|
105
105
|
});
|
|
106
106
|
}
|
|
107
|
-
const ctx = (0,
|
|
107
|
+
const ctx = (0, index_1.resolveHubV2Context)(args, "personal");
|
|
108
108
|
const client = new client_1.HubV2Client(ctx);
|
|
109
109
|
const data = await client.request("POST", client.personalUrl(path), body);
|
|
110
110
|
return (0, result_1.ok)("hub_v2_issues_comment", data);
|
|
111
111
|
},
|
|
112
112
|
},
|
|
113
|
+
{
|
|
114
|
+
name: "hub_v2_issues_assign",
|
|
115
|
+
description: "Preview or assign a Hub V2 issue assignee with Personal Token.",
|
|
116
|
+
riskLevel: "write",
|
|
117
|
+
inputSchema: schemas_1.issueAssignSchema,
|
|
118
|
+
allowPreviewWhenBlocked: true,
|
|
119
|
+
isConfirmed: (args) => args.confirm === true,
|
|
120
|
+
async handler(args) {
|
|
121
|
+
const path = `/issues/${encodeURIComponent(args.issueId)}/assign`;
|
|
122
|
+
const body = { assigneeId: args.assigneeId };
|
|
123
|
+
if (!args.confirm) {
|
|
124
|
+
return (0, result_1.ok)("hub_v2_issues_assign", {
|
|
125
|
+
code: "PREVIEW",
|
|
126
|
+
message: "set confirm=true to execute this write operation",
|
|
127
|
+
data: {
|
|
128
|
+
method: "POST",
|
|
129
|
+
path,
|
|
130
|
+
requiredScope: "issue:assign:write",
|
|
131
|
+
body,
|
|
132
|
+
},
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
const ctx = (0, index_1.resolveHubV2Context)(args, "personal");
|
|
136
|
+
const client = new client_1.HubV2Client(ctx);
|
|
137
|
+
const data = await client.request("POST", client.personalUrl(path), body);
|
|
138
|
+
return (0, result_1.ok)("hub_v2_issues_assign", data);
|
|
139
|
+
},
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
name: "hub_v2_issues_participant_add",
|
|
143
|
+
description: "Preview or add a Hub V2 issue collaborator, optionally creating a collaborator task branch.",
|
|
144
|
+
riskLevel: "write",
|
|
145
|
+
inputSchema: schemas_1.issueParticipantAddSchema,
|
|
146
|
+
allowPreviewWhenBlocked: true,
|
|
147
|
+
isConfirmed: (args) => args.confirm === true,
|
|
148
|
+
async handler(args) {
|
|
149
|
+
const path = `/issues/${encodeURIComponent(args.issueId)}/participants`;
|
|
150
|
+
const body = (0, client_1.compact)({
|
|
151
|
+
userId: args.userId,
|
|
152
|
+
taskTitle: args.taskTitle,
|
|
153
|
+
});
|
|
154
|
+
if (!args.confirm) {
|
|
155
|
+
return (0, result_1.ok)("hub_v2_issues_participant_add", {
|
|
156
|
+
code: "PREVIEW",
|
|
157
|
+
message: "set confirm=true to execute this write operation",
|
|
158
|
+
data: {
|
|
159
|
+
method: "POST",
|
|
160
|
+
path,
|
|
161
|
+
requiredScope: "issue:participant:write",
|
|
162
|
+
body,
|
|
163
|
+
},
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
const ctx = (0, index_1.resolveHubV2Context)(args, "personal");
|
|
167
|
+
const client = new client_1.HubV2Client(ctx);
|
|
168
|
+
const data = await client.request("POST", client.personalUrl(path), body);
|
|
169
|
+
return (0, result_1.ok)("hub_v2_issues_participant_add", data);
|
|
170
|
+
},
|
|
171
|
+
},
|
|
172
|
+
{
|
|
173
|
+
name: "hub_v2_issues_branch_create",
|
|
174
|
+
description: "Preview or create a Hub V2 issue collaboration branch for an existing collaborator.",
|
|
175
|
+
riskLevel: "write",
|
|
176
|
+
inputSchema: schemas_1.issueBranchCreateSchema,
|
|
177
|
+
allowPreviewWhenBlocked: true,
|
|
178
|
+
isConfirmed: (args) => args.confirm === true,
|
|
179
|
+
async handler(args) {
|
|
180
|
+
const path = `/issues/${encodeURIComponent(args.issueId)}/branches`;
|
|
181
|
+
const body = {
|
|
182
|
+
ownerUserId: args.ownerUserId,
|
|
183
|
+
title: args.title,
|
|
184
|
+
};
|
|
185
|
+
if (!args.confirm) {
|
|
186
|
+
return (0, result_1.ok)("hub_v2_issues_branch_create", {
|
|
187
|
+
code: "PREVIEW",
|
|
188
|
+
message: "set confirm=true to execute this write operation",
|
|
189
|
+
data: {
|
|
190
|
+
method: "POST",
|
|
191
|
+
path,
|
|
192
|
+
requiredScope: "issue:branch:write",
|
|
193
|
+
body,
|
|
194
|
+
},
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
const ctx = (0, index_1.resolveHubV2Context)(args, "personal");
|
|
198
|
+
const client = new client_1.HubV2Client(ctx);
|
|
199
|
+
const data = await client.request("POST", client.personalUrl(path), body);
|
|
200
|
+
return (0, result_1.ok)("hub_v2_issues_branch_create", data);
|
|
201
|
+
},
|
|
202
|
+
},
|
|
113
203
|
{
|
|
114
204
|
name: "hub_v2_issues_update",
|
|
115
205
|
description: "Preview or update Hub V2 issue basic fields with Personal Token.",
|
|
@@ -144,7 +234,7 @@ function hubV2IssuesTools() {
|
|
|
144
234
|
},
|
|
145
235
|
});
|
|
146
236
|
}
|
|
147
|
-
const ctx = (0,
|
|
237
|
+
const ctx = (0, index_1.resolveHubV2Context)(args, "personal");
|
|
148
238
|
const client = new client_1.HubV2Client(ctx);
|
|
149
239
|
const data = await client.request("PATCH", client.personalUrl(path), body, { preserveNull: true });
|
|
150
240
|
return (0, result_1.ok)("hub_v2_issues_update", data);
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.hubV2ProjectsTools = hubV2ProjectsTools;
|
|
4
|
-
const
|
|
4
|
+
const client_1 = require("./client");
|
|
5
|
+
const index_1 = require("./config/index");
|
|
5
6
|
const schemas_1 = require("./schemas");
|
|
6
7
|
const result_1 = require("../../utils/result");
|
|
7
8
|
function hubV2ProjectsTools() {
|
|
@@ -12,7 +13,7 @@ function hubV2ProjectsTools() {
|
|
|
12
13
|
riskLevel: "read",
|
|
13
14
|
inputSchema: schemas_1.projectSelectorSchema,
|
|
14
15
|
handler(args) {
|
|
15
|
-
return (0, result_1.ok)("hub_v2_projects_list", (0,
|
|
16
|
+
return (0, result_1.ok)("hub_v2_projects_list", (0, index_1.listConfiguredProjects)(args.project ?? args.projectKey));
|
|
16
17
|
},
|
|
17
18
|
},
|
|
18
19
|
{
|
|
@@ -21,7 +22,19 @@ function hubV2ProjectsTools() {
|
|
|
21
22
|
riskLevel: "read",
|
|
22
23
|
inputSchema: schemas_1.projectSelectorSchema,
|
|
23
24
|
handler(args) {
|
|
24
|
-
return (0, result_1.ok)("hub_v2_projects_get", (0,
|
|
25
|
+
return (0, result_1.ok)("hub_v2_projects_get", (0, index_1.getConfiguredProject)(args));
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
name: "hub_v2_project_members_list",
|
|
30
|
+
description: "List Hub V2 project members with Project Token for assignment and mention candidates.",
|
|
31
|
+
riskLevel: "read",
|
|
32
|
+
inputSchema: schemas_1.projectMembersListSchema,
|
|
33
|
+
async handler(args) {
|
|
34
|
+
const ctx = (0, index_1.resolveHubV2Context)(args, "project");
|
|
35
|
+
const client = new client_1.HubV2Client(ctx);
|
|
36
|
+
const data = await client.request("GET", client.tokenUrl("/members"));
|
|
37
|
+
return (0, result_1.ok)("hub_v2_project_members_list", data);
|
|
25
38
|
},
|
|
26
39
|
},
|
|
27
40
|
];
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { HubV2Client } from "./client";
|
|
2
|
+
export declare function readRawAsBase64(client: HubV2Client, url: string, maxBytes?: number): Promise<{
|
|
3
|
+
contentBase64: string;
|
|
4
|
+
contentType: string;
|
|
5
|
+
fileName: string | null;
|
|
6
|
+
sizeBytes: number;
|
|
7
|
+
truncated: boolean;
|
|
8
|
+
}>;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.readRawAsBase64 = readRawAsBase64;
|
|
4
|
+
async function readRawAsBase64(client, url, maxBytes) {
|
|
5
|
+
const limit = maxBytes ?? 1024 * 1024;
|
|
6
|
+
const raw = await client.raw("GET", url);
|
|
7
|
+
if (raw.content.byteLength > limit) {
|
|
8
|
+
throw new Error(`raw file is too large: ${raw.content.byteLength} bytes exceeds maxBytes=${limit}`);
|
|
9
|
+
}
|
|
10
|
+
return {
|
|
11
|
+
contentBase64: raw.content.toString("base64"),
|
|
12
|
+
contentType: raw.contentType,
|
|
13
|
+
fileName: extractFileName(raw.contentDisposition),
|
|
14
|
+
sizeBytes: raw.content.byteLength,
|
|
15
|
+
truncated: false,
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
function extractFileName(contentDisposition) {
|
|
19
|
+
if (!contentDisposition) {
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
const utf8Match = /filename\*=UTF-8''([^;]+)/i.exec(contentDisposition);
|
|
23
|
+
if (utf8Match) {
|
|
24
|
+
try {
|
|
25
|
+
return decodeURIComponent(utf8Match[1]);
|
|
26
|
+
}
|
|
27
|
+
catch {
|
|
28
|
+
return utf8Match[1];
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
const asciiMatch = /filename="([^"]+)"/i.exec(contentDisposition);
|
|
32
|
+
return asciiMatch?.[1] ?? null;
|
|
33
|
+
}
|