@yinuo-ngm/mcp-server 0.1.1 → 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 +225 -188
- 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 +70 -9
- 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 +20 -0
- package/lib/tools/hub-v2/client.js +112 -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.d.ts +2 -0
- package/lib/tools/hub-v2/docs.tools.js +215 -0
- package/lib/tools/hub-v2/errors.d.ts +8 -0
- package/lib/tools/hub-v2/errors.js +27 -0
- package/lib/tools/hub-v2/index.d.ts +2 -0
- package/lib/tools/hub-v2/index.js +19 -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.d.ts +2 -0
- package/lib/tools/hub-v2/issues.tools.js +244 -0
- package/lib/tools/hub-v2/projects.tools.d.ts +2 -0
- package/lib/tools/hub-v2/projects.tools.js +41 -0
- 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.d.ts +2 -0
- package/lib/tools/hub-v2/rd.tools.js +361 -0
- package/lib/tools/hub-v2/schemas.d.ts +1182 -0
- package/lib/tools/hub-v2/schemas.js +318 -0
- package/lib/tools/hub-v2/upload.tools.d.ts +2 -0
- package/lib/tools/hub-v2/upload.tools.js +198 -0
- package/lib/tools/index.d.ts +3 -0
- package/lib/tools/index.js +24 -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.d.ts +5 -0
- package/lib/utils/errors.js +17 -0
- package/lib/utils/result.d.ts +20 -2
- package/lib/utils/result.js +108 -3
- 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 +10 -4
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.hubV2DocsTools = hubV2DocsTools;
|
|
4
|
+
const client_1 = require("./client");
|
|
5
|
+
const index_1 = require("./config/index");
|
|
6
|
+
const schemas_1 = require("./schemas");
|
|
7
|
+
const result_1 = require("../../utils/result");
|
|
8
|
+
function hubV2DocsTools() {
|
|
9
|
+
return [
|
|
10
|
+
{
|
|
11
|
+
name: "hub_v2_docs_list",
|
|
12
|
+
description: "List Hub V2 project documents with Project Token.",
|
|
13
|
+
riskLevel: "read",
|
|
14
|
+
inputSchema: schemas_1.docsListSchema,
|
|
15
|
+
async handler(args) {
|
|
16
|
+
const ctx = (0, index_1.resolveHubV2Context)(args, "project");
|
|
17
|
+
const client = new client_1.HubV2Client(ctx);
|
|
18
|
+
const status = args.status;
|
|
19
|
+
const data = await client.request("GET", client.tokenUrl("/docs", {
|
|
20
|
+
page: args.page ?? 1,
|
|
21
|
+
pageSize: args.pageSize ?? 20,
|
|
22
|
+
status,
|
|
23
|
+
statusGroup: status ? undefined : "active",
|
|
24
|
+
keyword: args.keyword,
|
|
25
|
+
category: args.category,
|
|
26
|
+
categoryId: args.categoryId,
|
|
27
|
+
}));
|
|
28
|
+
return (0, result_1.ok)("hub_v2_docs_list", data);
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
name: "hub_v2_docs_get",
|
|
33
|
+
description: "Read one Hub V2 project document by id with Project Token.",
|
|
34
|
+
riskLevel: "read",
|
|
35
|
+
inputSchema: schemas_1.docsGetSchema,
|
|
36
|
+
async handler(args) {
|
|
37
|
+
const ctx = (0, index_1.resolveHubV2Context)(args, "project");
|
|
38
|
+
const client = new client_1.HubV2Client(ctx);
|
|
39
|
+
const data = await client.request("GET", client.tokenUrl(`/docs/${encodeURIComponent(args.docId)}`));
|
|
40
|
+
return (0, result_1.ok)("hub_v2_docs_get", data);
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
name: "hub_v2_docs_get_by_slug",
|
|
45
|
+
description: "Read one Hub V2 project document by slug with Project Token.",
|
|
46
|
+
riskLevel: "read",
|
|
47
|
+
inputSchema: schemas_1.docsGetBySlugSchema,
|
|
48
|
+
async handler(args) {
|
|
49
|
+
const ctx = (0, index_1.resolveHubV2Context)(args, "project");
|
|
50
|
+
const client = new client_1.HubV2Client(ctx);
|
|
51
|
+
const payload = await client.request("GET", client.tokenUrl(`/docs/by-slug/${encodeURIComponent(args.slug)}`));
|
|
52
|
+
if (args.contentOnly) {
|
|
53
|
+
const content = extractDocumentContent(payload);
|
|
54
|
+
if (typeof content === "string") {
|
|
55
|
+
return (0, result_1.ok)("hub_v2_docs_get_by_slug", content);
|
|
56
|
+
}
|
|
57
|
+
return (0, result_1.fail)("hub_v2_docs_get_by_slug", "Hub V2 document response did not include data.contentMd or data.item.contentMd", {
|
|
58
|
+
code: "DOCUMENT_CONTENT_NOT_FOUND",
|
|
59
|
+
detail: {
|
|
60
|
+
slug: args.slug,
|
|
61
|
+
responseKeys: Object.keys(payload),
|
|
62
|
+
},
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
return (0, result_1.ok)("hub_v2_docs_get_by_slug", payload);
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
name: "hub_v2_docs_create",
|
|
70
|
+
description: "Preview or create a Hub V2 project document draft with Personal Token.",
|
|
71
|
+
riskLevel: "write",
|
|
72
|
+
inputSchema: schemas_1.docsCreateSchema,
|
|
73
|
+
allowPreviewWhenBlocked: true,
|
|
74
|
+
isConfirmed: (args) => args.confirm === true,
|
|
75
|
+
async handler(args) {
|
|
76
|
+
const path = "/docs";
|
|
77
|
+
if (!hasDocumentContent(args)) {
|
|
78
|
+
return (0, result_1.fail)("hub_v2_docs_create", "content or contentMd is required", {
|
|
79
|
+
code: "VALIDATION_ERROR",
|
|
80
|
+
detail: { field: "content" },
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
const ctx = args.confirm ? (0, index_1.resolveHubV2Context)(args, "personal") : undefined;
|
|
84
|
+
const body = (0, client_1.compact)({
|
|
85
|
+
title: args.title,
|
|
86
|
+
content: args.content,
|
|
87
|
+
contentMd: args.contentMd,
|
|
88
|
+
slug: args.slug,
|
|
89
|
+
category: args.category,
|
|
90
|
+
categoryId: args.categoryId,
|
|
91
|
+
summary: args.summary,
|
|
92
|
+
tags: args.tags,
|
|
93
|
+
status: args.status ?? "draft",
|
|
94
|
+
source: args.source ?? ctx?.source,
|
|
95
|
+
version: args.version,
|
|
96
|
+
});
|
|
97
|
+
if (!args.confirm) {
|
|
98
|
+
return (0, result_1.ok)("hub_v2_docs_create", {
|
|
99
|
+
code: "PREVIEW",
|
|
100
|
+
message: "set confirm=true to execute this write operation",
|
|
101
|
+
data: {
|
|
102
|
+
method: "POST",
|
|
103
|
+
path,
|
|
104
|
+
requiredScope: "doc:create:write",
|
|
105
|
+
body,
|
|
106
|
+
},
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
const client = new client_1.HubV2Client(ctx);
|
|
110
|
+
const data = await client.request("POST", client.personalUrl(path), body);
|
|
111
|
+
return (0, result_1.ok)("hub_v2_docs_create", data);
|
|
112
|
+
},
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
name: "hub_v2_docs_update",
|
|
116
|
+
description: "Preview or update a Hub V2 project document with Personal Token.",
|
|
117
|
+
riskLevel: "write",
|
|
118
|
+
inputSchema: schemas_1.docsUpdateSchema,
|
|
119
|
+
allowPreviewWhenBlocked: true,
|
|
120
|
+
isConfirmed: (args) => args.confirm === true,
|
|
121
|
+
async handler(args) {
|
|
122
|
+
const path = `/docs/${encodeURIComponent(args.docId)}`;
|
|
123
|
+
if (!hasDocumentUpdateField(args)) {
|
|
124
|
+
return (0, result_1.fail)("hub_v2_docs_update", "at least one document field is required", {
|
|
125
|
+
code: "VALIDATION_ERROR",
|
|
126
|
+
detail: { field: "title" },
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
const ctx = args.confirm ? (0, index_1.resolveHubV2Context)(args, "personal") : undefined;
|
|
130
|
+
const body = (0, client_1.compactUndefined)({
|
|
131
|
+
title: args.title,
|
|
132
|
+
content: args.content,
|
|
133
|
+
contentMd: args.contentMd,
|
|
134
|
+
slug: args.slug,
|
|
135
|
+
category: args.category,
|
|
136
|
+
categoryId: args.categoryId,
|
|
137
|
+
summary: args.summary,
|
|
138
|
+
tags: args.tags,
|
|
139
|
+
source: args.source ?? ctx?.source,
|
|
140
|
+
version: args.version,
|
|
141
|
+
});
|
|
142
|
+
if (!args.confirm) {
|
|
143
|
+
return (0, result_1.ok)("hub_v2_docs_update", {
|
|
144
|
+
code: "PREVIEW",
|
|
145
|
+
message: "set confirm=true to execute this write operation",
|
|
146
|
+
data: {
|
|
147
|
+
method: "PATCH",
|
|
148
|
+
path,
|
|
149
|
+
requiredScope: "doc:update:write",
|
|
150
|
+
body,
|
|
151
|
+
},
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
const client = new client_1.HubV2Client(ctx);
|
|
155
|
+
const data = await client.request("PATCH", client.personalUrl(path), body, { preserveNull: true });
|
|
156
|
+
return (0, result_1.ok)("hub_v2_docs_update", data);
|
|
157
|
+
},
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
name: "hub_v2_docs_publish",
|
|
161
|
+
description: "Preview or publish a Hub V2 project document with Personal Token.",
|
|
162
|
+
riskLevel: "write",
|
|
163
|
+
inputSchema: schemas_1.docsPublishSchema,
|
|
164
|
+
allowPreviewWhenBlocked: true,
|
|
165
|
+
isConfirmed: (args) => args.confirm === true,
|
|
166
|
+
async handler(args) {
|
|
167
|
+
const path = `/docs/${encodeURIComponent(args.docId)}/publish`;
|
|
168
|
+
const ctx = args.confirm ? (0, index_1.resolveHubV2Context)(args, "personal") : undefined;
|
|
169
|
+
const body = (0, client_1.compact)({
|
|
170
|
+
source: args.source ?? ctx?.source,
|
|
171
|
+
});
|
|
172
|
+
if (!args.confirm) {
|
|
173
|
+
return (0, result_1.ok)("hub_v2_docs_publish", {
|
|
174
|
+
code: "PREVIEW",
|
|
175
|
+
message: "set confirm=true to execute this write operation",
|
|
176
|
+
data: {
|
|
177
|
+
method: "POST",
|
|
178
|
+
path,
|
|
179
|
+
requiredScope: "doc:publish:write",
|
|
180
|
+
body,
|
|
181
|
+
},
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
const client = new client_1.HubV2Client(ctx);
|
|
185
|
+
const data = await client.request("POST", client.personalUrl(path), body);
|
|
186
|
+
return (0, result_1.ok)("hub_v2_docs_publish", data);
|
|
187
|
+
},
|
|
188
|
+
},
|
|
189
|
+
];
|
|
190
|
+
}
|
|
191
|
+
function extractDocumentContent(payload) {
|
|
192
|
+
const data = payload.data && typeof payload.data === "object" && !Array.isArray(payload.data)
|
|
193
|
+
? payload.data
|
|
194
|
+
: undefined;
|
|
195
|
+
if (typeof data?.contentMd === "string") {
|
|
196
|
+
return data.contentMd;
|
|
197
|
+
}
|
|
198
|
+
const item = data?.item && typeof data.item === "object" && !Array.isArray(data.item)
|
|
199
|
+
? data.item
|
|
200
|
+
: undefined;
|
|
201
|
+
return typeof item?.contentMd === "string" ? item.contentMd : undefined;
|
|
202
|
+
}
|
|
203
|
+
function hasDocumentContent(args) {
|
|
204
|
+
return Boolean(args.content?.trim() || args.contentMd?.trim());
|
|
205
|
+
}
|
|
206
|
+
function hasDocumentUpdateField(args) {
|
|
207
|
+
return (args.title !== undefined ||
|
|
208
|
+
args.content !== undefined ||
|
|
209
|
+
args.contentMd !== undefined ||
|
|
210
|
+
args.slug !== undefined ||
|
|
211
|
+
args.category !== undefined ||
|
|
212
|
+
args.categoryId !== undefined ||
|
|
213
|
+
args.summary !== undefined ||
|
|
214
|
+
args.version !== undefined);
|
|
215
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare class HubV2HttpError extends Error {
|
|
2
|
+
readonly status: number;
|
|
3
|
+
readonly code?: string | undefined;
|
|
4
|
+
readonly detail?: unknown | undefined;
|
|
5
|
+
constructor(message: string, status: number, code?: string | undefined, detail?: unknown | undefined);
|
|
6
|
+
}
|
|
7
|
+
export declare function formatHubV2HttpError(status: number, statusText: string, body: unknown): string;
|
|
8
|
+
export declare function toHubV2HttpError(status: number, statusText: string, body: unknown): HubV2HttpError;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.HubV2HttpError = void 0;
|
|
4
|
+
exports.formatHubV2HttpError = formatHubV2HttpError;
|
|
5
|
+
exports.toHubV2HttpError = toHubV2HttpError;
|
|
6
|
+
class HubV2HttpError extends Error {
|
|
7
|
+
constructor(message, status, code, detail) {
|
|
8
|
+
super(message);
|
|
9
|
+
this.status = status;
|
|
10
|
+
this.code = code;
|
|
11
|
+
this.detail = detail;
|
|
12
|
+
this.name = "HubV2HttpError";
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
exports.HubV2HttpError = HubV2HttpError;
|
|
16
|
+
function formatHubV2HttpError(status, statusText, body) {
|
|
17
|
+
const record = body && typeof body === "object" && !Array.isArray(body) ? body : {};
|
|
18
|
+
const code = typeof record.code === "string" ? record.code : "HTTP_ERROR";
|
|
19
|
+
const message = typeof record.message === "string" ? record.message : statusText;
|
|
20
|
+
return `Hub V2 HTTP ${status} ${code}: ${message}`;
|
|
21
|
+
}
|
|
22
|
+
function toHubV2HttpError(status, statusText, body) {
|
|
23
|
+
const record = body && typeof body === "object" && !Array.isArray(body) ? body : {};
|
|
24
|
+
const code = typeof record.code === "string" ? record.code : "HTTP_ERROR";
|
|
25
|
+
const detail = record.detail ?? record.data ?? body;
|
|
26
|
+
return new HubV2HttpError(formatHubV2HttpError(status, statusText, body), status, code, detail);
|
|
27
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.hubV2Tools = hubV2Tools;
|
|
4
|
+
const docs_tools_1 = require("./docs.tools");
|
|
5
|
+
const issues_tools_1 = require("./issues.tools");
|
|
6
|
+
const issues_workflow_tools_1 = require("./issues-workflow.tools");
|
|
7
|
+
const projects_tools_1 = require("./projects.tools");
|
|
8
|
+
const rd_tools_1 = require("./rd.tools");
|
|
9
|
+
const upload_tools_1 = require("./upload.tools");
|
|
10
|
+
function hubV2Tools() {
|
|
11
|
+
return [
|
|
12
|
+
...(0, projects_tools_1.hubV2ProjectsTools)(),
|
|
13
|
+
...(0, docs_tools_1.hubV2DocsTools)(),
|
|
14
|
+
...(0, issues_tools_1.hubV2IssuesTools)(),
|
|
15
|
+
...(0, issues_workflow_tools_1.hubV2IssueWorkflowTools)(),
|
|
16
|
+
...(0, rd_tools_1.hubV2RdTools)(),
|
|
17
|
+
...(0, upload_tools_1.hubV2UploadTools)(),
|
|
18
|
+
];
|
|
19
|
+
}
|
|
@@ -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
|
+
}
|