huly-mcp-sdk 0.2.1
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/.env.example +16 -0
- package/README.md +189 -0
- package/dist/connection.d.ts +5 -0
- package/dist/connection.js +111 -0
- package/dist/connection.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +25 -0
- package/dist/index.js.map +1 -0
- package/dist/schemas.d.ts +177 -0
- package/dist/schemas.js +78 -0
- package/dist/schemas.js.map +1 -0
- package/dist/server.d.ts +2 -0
- package/dist/server.js +48 -0
- package/dist/server.js.map +1 -0
- package/dist/tools/comments.d.ts +9 -0
- package/dist/tools/comments.js +19 -0
- package/dist/tools/comments.js.map +1 -0
- package/dist/tools/documents.d.ts +14 -0
- package/dist/tools/documents.js +27 -0
- package/dist/tools/documents.js.map +1 -0
- package/dist/tools/issues.d.ts +51 -0
- package/dist/tools/issues.js +179 -0
- package/dist/tools/issues.js.map +1 -0
- package/dist/tools/labels.d.ts +35 -0
- package/dist/tools/labels.js +150 -0
- package/dist/tools/labels.js.map +1 -0
- package/dist/tools/members.d.ts +6 -0
- package/dist/tools/members.js +17 -0
- package/dist/tools/members.js.map +1 -0
- package/dist/tools/milestones.d.ts +8 -0
- package/dist/tools/milestones.js +26 -0
- package/dist/tools/milestones.js.map +1 -0
- package/dist/tools/projects.d.ts +14 -0
- package/dist/tools/projects.js +33 -0
- package/dist/tools/projects.js.map +1 -0
- package/dist/tools/relations.d.ts +27 -0
- package/dist/tools/relations.js +103 -0
- package/dist/tools/relations.js.map +1 -0
- package/dist/tools/search.d.ts +9 -0
- package/dist/tools/search.js +32 -0
- package/dist/tools/search.js.map +1 -0
- package/dist/utils/errors.d.ts +11 -0
- package/dist/utils/errors.js +24 -0
- package/dist/utils/errors.js.map +1 -0
- package/dist/utils/format.d.ts +4 -0
- package/dist/utils/format.js +28 -0
- package/dist/utils/format.js.map +1 -0
- package/package.json +63 -0
- package/scripts/cleanup-issues.js +132 -0
- package/scripts/demo.js +193 -0
- package/scripts/import-csv.js +242 -0
- package/scripts/sample-tasks.csv +11 -0
- package/scripts/setup.js +103 -0
package/dist/server.js
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createServer = createServer;
|
|
4
|
+
const mcp_js_1 = require("@modelcontextprotocol/sdk/server/mcp.js");
|
|
5
|
+
const projects_1 = require("./tools/projects");
|
|
6
|
+
const issues_1 = require("./tools/issues");
|
|
7
|
+
const comments_1 = require("./tools/comments");
|
|
8
|
+
const members_1 = require("./tools/members");
|
|
9
|
+
const milestones_1 = require("./tools/milestones");
|
|
10
|
+
const documents_1 = require("./tools/documents");
|
|
11
|
+
const search_1 = require("./tools/search");
|
|
12
|
+
const labels_1 = require("./tools/labels");
|
|
13
|
+
const relations_1 = require("./tools/relations");
|
|
14
|
+
const schemas_1 = require("./schemas");
|
|
15
|
+
function createServer() {
|
|
16
|
+
const server = new mcp_js_1.McpServer({ name: 'huly-mcp', version: '0.2.1' });
|
|
17
|
+
// Projects
|
|
18
|
+
server.tool('list_projects', 'List all projects in the Huly workspace', {}, projects_1.listProjects);
|
|
19
|
+
server.tool('get_project', 'Get a project by its identifier (e.g. "PROJ")', schemas_1.GetProjectSchema.shape, projects_1.getProject);
|
|
20
|
+
// Issues
|
|
21
|
+
server.tool('list_issues', 'List issues in a project with optional filters', schemas_1.ListIssuesSchema.shape, issues_1.listIssues);
|
|
22
|
+
server.tool('get_issue', 'Get full details of an issue by identifier (e.g. "PROJ-123")', schemas_1.GetIssueSchema.shape, issues_1.getIssue);
|
|
23
|
+
server.tool('create_issue', 'Create a new issue in a project', schemas_1.CreateIssueSchema.shape, issues_1.createIssue);
|
|
24
|
+
server.tool('update_issue', 'Update an existing issue (title, status, priority, due date)', schemas_1.UpdateIssueSchema.shape, issues_1.updateIssue);
|
|
25
|
+
server.tool('delete_issue', 'Permanently delete an issue by identifier (e.g. "PROJ-123")', schemas_1.DeleteIssueSchema.shape, issues_1.deleteIssue);
|
|
26
|
+
// Comments
|
|
27
|
+
server.tool('add_comment', 'Add a comment to an issue', schemas_1.AddCommentSchema.shape, comments_1.addComment);
|
|
28
|
+
// Labels
|
|
29
|
+
server.tool('list_labels', 'List all labels in the workspace', schemas_1.ListLabelsSchema.shape, labels_1.listLabels);
|
|
30
|
+
server.tool('create_label', 'Create a new label with an optional hex color', schemas_1.CreateLabelSchema.shape, labels_1.createLabel);
|
|
31
|
+
server.tool('add_label', 'Add a label to an issue (auto-creates the label if it does not exist)', schemas_1.AddLabelSchema.shape, labels_1.addLabel);
|
|
32
|
+
server.tool('remove_label', 'Remove a label from an issue', schemas_1.RemoveLabelSchema.shape, labels_1.removeLabel);
|
|
33
|
+
// Relations
|
|
34
|
+
server.tool('add_relation', 'Mark two issues as related to each other (bidirectional)', schemas_1.AddRelationSchema.shape, relations_1.addRelation);
|
|
35
|
+
server.tool('add_blocked_by', 'Mark an issue as blocked by another issue', schemas_1.AddBlockedBySchema.shape, relations_1.addBlockedBy);
|
|
36
|
+
server.tool('set_parent', 'Set or clear the parent (epic) of an issue', schemas_1.SetParentSchema.shape, relations_1.setParent);
|
|
37
|
+
// Members
|
|
38
|
+
server.tool('list_members', 'List all members in the workspace', {}, members_1.listMembers);
|
|
39
|
+
// Milestones
|
|
40
|
+
server.tool('list_milestones', 'List milestones for a project', schemas_1.ListMilestonesSchema.shape, milestones_1.listMilestones);
|
|
41
|
+
// Documents
|
|
42
|
+
server.tool('list_teamspaces', 'List all document teamspaces in the workspace', {}, documents_1.listTeamspaces);
|
|
43
|
+
server.tool('list_documents', 'List documents in a teamspace', schemas_1.ListDocumentsSchema.shape, documents_1.listDocuments);
|
|
44
|
+
// Search
|
|
45
|
+
server.tool('search_issues', 'Full-text search across all issues', schemas_1.SearchIssuesSchema.shape, search_1.searchIssues);
|
|
46
|
+
return server;
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingUR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,eAAe,EAAE,oCAAoC,EAAE,4BAAkB,CAAC,KAAK,EAAE,qBAAY,CAAC,CAAA;IAE1G,OAAO,MAAM,CAAA;AACf,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.addComment = void 0;
|
|
7
|
+
const tracker_1 = __importDefault(require("@hcengineering/tracker"));
|
|
8
|
+
const chunter_1 = __importDefault(require("@hcengineering/chunter"));
|
|
9
|
+
const connection_1 = require("../connection");
|
|
10
|
+
const errors_1 = require("../utils/errors");
|
|
11
|
+
exports.addComment = (0, errors_1.wrapToolHandler)(async (args) => {
|
|
12
|
+
const client = await (0, connection_1.getConnection)();
|
|
13
|
+
const issue = await client.findOne(tracker_1.default.class.Issue, { identifier: args.identifier });
|
|
14
|
+
if (issue == null)
|
|
15
|
+
throw new Error(`Issue '${args.identifier}' not found.`);
|
|
16
|
+
await client.addCollection(chunter_1.default.class.ChatMessage, issue.space, issue._id, tracker_1.default.class.Issue, 'comments', { message: args.message });
|
|
17
|
+
return `✅ Comment added to **${args.identifier}**.`;
|
|
18
|
+
});
|
|
19
|
+
//# sourceMappingURL=comments.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"comments.js","sourceRoot":"","sources":["../../src/tools/comments.ts"],"names":[],"mappings":";;;;;;AAAA,qEAA4C;AAC5C,qEAA4C;AAC5C,8CAA6C;AAC7C,4CAAiD;AAIpC,QAAA,UAAU,GAAG,IAAA,wBAAe,EAAmC,KAAK,EAAE,IAAI,EAAE,EAAE;IACzF,MAAM,MAAM,GAAG,MAAM,IAAA,0BAAa,GAAE,CAAA;IACpC,MAAM,KAAK,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC,iBAAO,CAAC,KAAK,CAAC,KAAK,EAAE,EAAE,UAAU,EAAE,IAAI,CAAC,UAAU,EAAE,CAAC,CAAA;IACxF,IAAI,KAAK,IAAI,IAAI;QAAE,MAAM,IAAI,KAAK,CAAC,UAAU,IAAI,CAAC,UAAU,cAAc,CAAC,CAAA;IAE3E,MAAM,MAAM,CAAC,aAAa,CACxB,iBAAO,CAAC,KAAK,CAAC,WAAW,EACzB,KAAK,CAAC,KAAK,EACX,KAAK,CAAC,GAAG,EACT,iBAAO,CAAC,KAAK,CAAC,KAAK,EACnB,UAAU,EACV,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,CAC1B,CAAA;IAED,OAAO,wBAAwB,IAAI,CAAC,UAAU,KAAK,CAAA;AACrD,CAAC,CAAC,CAAA"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare const listTeamspaces: (args: Record<string, never>) => Promise<{
|
|
2
|
+
content: Array<{
|
|
3
|
+
type: "text";
|
|
4
|
+
text: string;
|
|
5
|
+
}>;
|
|
6
|
+
}>;
|
|
7
|
+
export declare const listDocuments: (args: {
|
|
8
|
+
teamspaceId: string;
|
|
9
|
+
}) => Promise<{
|
|
10
|
+
content: Array<{
|
|
11
|
+
type: "text";
|
|
12
|
+
text: string;
|
|
13
|
+
}>;
|
|
14
|
+
}>;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.listDocuments = exports.listTeamspaces = void 0;
|
|
7
|
+
const document_1 = __importDefault(require("@hcengineering/document"));
|
|
8
|
+
const core_1 = require("@hcengineering/core");
|
|
9
|
+
const connection_1 = require("../connection");
|
|
10
|
+
const errors_1 = require("../utils/errors");
|
|
11
|
+
exports.listTeamspaces = (0, errors_1.wrapToolHandler)(async () => {
|
|
12
|
+
const client = await (0, connection_1.getConnection)();
|
|
13
|
+
const teamspaces = await client.findAll(document_1.default.class.Teamspace, {});
|
|
14
|
+
if (teamspaces.length === 0)
|
|
15
|
+
return 'No teamspaces found in this workspace.';
|
|
16
|
+
const lines = teamspaces.map((t) => `- **${t.name}** (id: \`${t._id}\`)${t.description != null && t.description !== '' ? `\n ${t.description}` : ''}`);
|
|
17
|
+
return `## Teamspaces (${teamspaces.length})\n\n${lines.join('\n')}`;
|
|
18
|
+
});
|
|
19
|
+
exports.listDocuments = (0, errors_1.wrapToolHandler)(async (args) => {
|
|
20
|
+
const client = await (0, connection_1.getConnection)();
|
|
21
|
+
const docs = await client.findAll(document_1.default.class.Document, { space: args.teamspaceId }, { sort: { rank: core_1.SortingOrder.Ascending }, limit: 100 });
|
|
22
|
+
if (docs.length === 0)
|
|
23
|
+
return 'No documents found in this teamspace.';
|
|
24
|
+
const lines = docs.map((d) => `- **${d.title}** (id: \`${d._id}\`)`);
|
|
25
|
+
return `## Documents (${docs.length})\n\n${lines.join('\n')}`;
|
|
26
|
+
});
|
|
27
|
+
//# sourceMappingURL=documents.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"documents.js","sourceRoot":"","sources":["../../src/tools/documents.ts"],"names":[],"mappings":";;;;;;AAAA,uEAA8C;AAC9C,8CAA4D;AAC5D,8CAA6C;AAC7C,4CAAiD;AAKpC,QAAA,cAAc,GAAG,IAAA,wBAAe,EAAwB,KAAK,IAAI,EAAE;IAC9E,MAAM,MAAM,GAAG,MAAM,IAAA,0BAAa,GAAE,CAAA;IACpC,MAAM,UAAU,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC,kBAAQ,CAAC,KAAK,CAAC,SAAS,EAAE,EAAE,CAAC,CAAA;IAErE,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,wCAAwC,CAAA;IAE5E,MAAM,KAAK,GAAG,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CACjC,OAAO,CAAC,CAAC,IAAI,aAAa,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,WAAW,IAAI,IAAI,IAAI,CAAC,CAAC,WAAW,KAAK,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CACnH,CAAA;IAED,OAAO,kBAAkB,UAAU,CAAC,MAAM,QAAQ,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAA;AACtE,CAAC,CAAC,CAAA;AAEW,QAAA,aAAa,GAAG,IAAA,wBAAe,EAAsC,KAAK,EAAE,IAAI,EAAE,EAAE;IAC/F,MAAM,MAAM,GAAG,MAAM,IAAA,0BAAa,GAAE,CAAA;IACpC,MAAM,IAAI,GAAG,MAAM,MAAM,CAAC,OAAO,CAC/B,kBAAQ,CAAC,KAAK,CAAC,QAAQ,EACvB,EAAE,KAAK,EAAE,IAAI,CAAC,WAA6B,EAAE,EAC7C,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,mBAAY,CAAC,SAAS,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,CACvD,CAAA;IAED,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,uCAAuC,CAAA;IAErE,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,CAAC,KAAK,aAAa,CAAC,CAAC,GAAG,KAAK,CAAC,CAAA;IACpE,OAAO,iBAAiB,IAAI,CAAC,MAAM,QAAQ,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAA;AAC/D,CAAC,CAAC,CAAA"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
export declare const listIssues: (args: {
|
|
2
|
+
projectIdentifier: string;
|
|
3
|
+
limit: number;
|
|
4
|
+
status?: string | undefined;
|
|
5
|
+
priority?: "Medium" | "NoPriority" | "Urgent" | "High" | "Low" | undefined;
|
|
6
|
+
}) => Promise<{
|
|
7
|
+
content: Array<{
|
|
8
|
+
type: "text";
|
|
9
|
+
text: string;
|
|
10
|
+
}>;
|
|
11
|
+
}>;
|
|
12
|
+
export declare const getIssue: (args: {
|
|
13
|
+
identifier: string;
|
|
14
|
+
}) => Promise<{
|
|
15
|
+
content: Array<{
|
|
16
|
+
type: "text";
|
|
17
|
+
text: string;
|
|
18
|
+
}>;
|
|
19
|
+
}>;
|
|
20
|
+
export declare const createIssue: (args: {
|
|
21
|
+
title: string;
|
|
22
|
+
projectIdentifier: string;
|
|
23
|
+
priority: "Medium" | "NoPriority" | "Urgent" | "High" | "Low";
|
|
24
|
+
statusName?: string | undefined;
|
|
25
|
+
dueDate?: string | undefined;
|
|
26
|
+
}) => Promise<{
|
|
27
|
+
content: Array<{
|
|
28
|
+
type: "text";
|
|
29
|
+
text: string;
|
|
30
|
+
}>;
|
|
31
|
+
}>;
|
|
32
|
+
export declare const deleteIssue: (args: {
|
|
33
|
+
identifier: string;
|
|
34
|
+
}) => Promise<{
|
|
35
|
+
content: Array<{
|
|
36
|
+
type: "text";
|
|
37
|
+
text: string;
|
|
38
|
+
}>;
|
|
39
|
+
}>;
|
|
40
|
+
export declare const updateIssue: (args: {
|
|
41
|
+
identifier: string;
|
|
42
|
+
title?: string | undefined;
|
|
43
|
+
priority?: "Medium" | "NoPriority" | "Urgent" | "High" | "Low" | undefined;
|
|
44
|
+
statusName?: string | undefined;
|
|
45
|
+
dueDate?: string | null | undefined;
|
|
46
|
+
}) => Promise<{
|
|
47
|
+
content: Array<{
|
|
48
|
+
type: "text";
|
|
49
|
+
text: string;
|
|
50
|
+
}>;
|
|
51
|
+
}>;
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.updateIssue = exports.deleteIssue = exports.createIssue = exports.getIssue = exports.listIssues = void 0;
|
|
40
|
+
const tracker_1 = __importStar(require("@hcengineering/tracker"));
|
|
41
|
+
const task_1 = __importDefault(require("@hcengineering/task"));
|
|
42
|
+
const core_1 = require("@hcengineering/core");
|
|
43
|
+
const rank_1 = require("@hcengineering/rank");
|
|
44
|
+
const connection_1 = require("../connection");
|
|
45
|
+
const errors_1 = require("../utils/errors");
|
|
46
|
+
const format_1 = require("../utils/format");
|
|
47
|
+
exports.listIssues = (0, errors_1.wrapToolHandler)(async (args) => {
|
|
48
|
+
const client = await (0, connection_1.getConnection)();
|
|
49
|
+
const project = await client.findOne(tracker_1.default.class.Project, { identifier: args.projectIdentifier });
|
|
50
|
+
if (project == null)
|
|
51
|
+
throw new Error(`Project '${args.projectIdentifier}' not found.`);
|
|
52
|
+
const query = { space: project._id };
|
|
53
|
+
if (args.status != null) {
|
|
54
|
+
const status = await client.findOne(tracker_1.default.class.IssueStatus, { space: project._id, name: args.status });
|
|
55
|
+
if (status == null)
|
|
56
|
+
throw new Error(`Status '${args.status}' not found in project '${args.projectIdentifier}'.`);
|
|
57
|
+
query.status = status._id;
|
|
58
|
+
}
|
|
59
|
+
if (args.priority != null) {
|
|
60
|
+
query.priority = tracker_1.IssuePriority[args.priority];
|
|
61
|
+
}
|
|
62
|
+
const issues = await client.findAll(tracker_1.default.class.Issue, query, { limit: args.limit, sort: { modifiedOn: core_1.SortingOrder.Descending } });
|
|
63
|
+
if (issues.length === 0)
|
|
64
|
+
return `No issues found in project ${args.projectIdentifier}.`;
|
|
65
|
+
// Resolve all statuses in one call
|
|
66
|
+
const statuses = await client.findAll(tracker_1.default.class.IssueStatus, { space: project._id });
|
|
67
|
+
const statusMap = new Map(statuses.map((s) => [s._id, s.name]));
|
|
68
|
+
const lines = issues.map((issue) => {
|
|
69
|
+
const statusName = statusMap.get(issue.status) ?? 'Unknown';
|
|
70
|
+
const due = issue.dueDate != null ? ` | Due: ${(0, format_1.formatDate)(issue.dueDate)}` : '';
|
|
71
|
+
return `- **${issue.identifier}** [${statusName}] [${(0, format_1.priorityLabel)(issue.priority)}]${due}\n ${issue.title}`;
|
|
72
|
+
});
|
|
73
|
+
return `## Issues in ${args.projectIdentifier} (${issues.length})\n\n${lines.join('\n')}`;
|
|
74
|
+
});
|
|
75
|
+
exports.getIssue = (0, errors_1.wrapToolHandler)(async (args) => {
|
|
76
|
+
const client = await (0, connection_1.getConnection)();
|
|
77
|
+
const issue = await client.findOne(tracker_1.default.class.Issue, { identifier: args.identifier });
|
|
78
|
+
if (issue == null)
|
|
79
|
+
throw new Error(`Issue '${args.identifier}' not found.`);
|
|
80
|
+
const status = await client.findOne(tracker_1.default.class.IssueStatus, { _id: issue.status });
|
|
81
|
+
return [
|
|
82
|
+
`## ${issue.identifier}: ${issue.title}`,
|
|
83
|
+
`**Status:** ${status?.name ?? 'Unknown'}`,
|
|
84
|
+
`**Priority:** ${(0, format_1.priorityLabel)(issue.priority)}`,
|
|
85
|
+
`**Due date:** ${(0, format_1.formatDate)(issue.dueDate)}`,
|
|
86
|
+
`**Comments:** ${issue.comments ?? 0}`,
|
|
87
|
+
`**Sub-issues:** ${issue.subIssues ?? 0}`,
|
|
88
|
+
`**Estimation:** ${issue.estimation > 0 ? `${issue.estimation}h` : 'None'}`,
|
|
89
|
+
`**Reported time:** ${issue.reportedTime > 0 ? `${issue.reportedTime}h` : 'None'}`
|
|
90
|
+
].join('\n');
|
|
91
|
+
});
|
|
92
|
+
exports.createIssue = (0, errors_1.wrapToolHandler)(async (args) => {
|
|
93
|
+
const client = await (0, connection_1.getConnection)();
|
|
94
|
+
// 1. Find project
|
|
95
|
+
const project = await client.findOne(tracker_1.default.class.Project, { identifier: args.projectIdentifier });
|
|
96
|
+
if (project == null)
|
|
97
|
+
throw new Error(`Project '${args.projectIdentifier}' not found.`);
|
|
98
|
+
// 2. Increment sequence counter
|
|
99
|
+
const incResult = await client.updateDoc(tracker_1.default.class.Project, project.space, project._id, { $inc: { sequence: 1 } }, true);
|
|
100
|
+
const issueNumber = incResult?.object?.sequence ?? project.sequence + 1;
|
|
101
|
+
const identifier = `${project.identifier}-${issueNumber}`;
|
|
102
|
+
// 3. Resolve status
|
|
103
|
+
const statuses = await client.findAll(tracker_1.default.class.IssueStatus, { space: project._id });
|
|
104
|
+
const status = args.statusName != null
|
|
105
|
+
? (statuses.find((s) => s.name === args.statusName) ?? statuses[0])
|
|
106
|
+
: (project.defaultIssueStatus != null
|
|
107
|
+
? (statuses.find((s) => s._id === project.defaultIssueStatus) ?? statuses[0])
|
|
108
|
+
: statuses[0]);
|
|
109
|
+
if (status == null)
|
|
110
|
+
throw new Error(`No statuses found in project '${args.projectIdentifier}'.`);
|
|
111
|
+
// 4. Find TaskType (kind field — required)
|
|
112
|
+
const kind = await client.findOne(task_1.default.class.TaskType, project.type != null ? { parent: project.type } : {});
|
|
113
|
+
if (kind == null)
|
|
114
|
+
throw new Error('Could not find a TaskType for this project.');
|
|
115
|
+
// 5. Compute rank (append after last issue)
|
|
116
|
+
const lastIssue = await client.findOne(tracker_1.default.class.Issue, { space: project._id }, { sort: { rank: core_1.SortingOrder.Descending } });
|
|
117
|
+
const rank = (0, rank_1.makeRank)(lastIssue?.rank, undefined);
|
|
118
|
+
// 6. Create via addCollection (issues are AttachedDoc)
|
|
119
|
+
const issueId = (0, core_1.generateId)();
|
|
120
|
+
await client.addCollection(tracker_1.default.class.Issue, project._id, tracker_1.default.ids.NoParent, tracker_1.default.class.Issue, 'subIssues', {
|
|
121
|
+
title: args.title,
|
|
122
|
+
description: null,
|
|
123
|
+
status: status._id,
|
|
124
|
+
priority: tracker_1.IssuePriority[args.priority],
|
|
125
|
+
number: issueNumber,
|
|
126
|
+
identifier,
|
|
127
|
+
rank,
|
|
128
|
+
kind: kind._id,
|
|
129
|
+
comments: 0,
|
|
130
|
+
subIssues: 0,
|
|
131
|
+
dueDate: args.dueDate != null ? new Date(args.dueDate).getTime() : null,
|
|
132
|
+
assignee: null,
|
|
133
|
+
component: null,
|
|
134
|
+
milestone: null,
|
|
135
|
+
parents: [],
|
|
136
|
+
remainingTime: 0,
|
|
137
|
+
estimation: 0,
|
|
138
|
+
reportedTime: 0,
|
|
139
|
+
reports: 0,
|
|
140
|
+
childInfo: [],
|
|
141
|
+
relations: []
|
|
142
|
+
}, issueId);
|
|
143
|
+
return `✅ Created **${identifier}**: ${args.title}\nStatus: ${status.name} | Priority: ${(0, format_1.priorityLabel)(tracker_1.IssuePriority[args.priority])}`;
|
|
144
|
+
});
|
|
145
|
+
exports.deleteIssue = (0, errors_1.wrapToolHandler)(async (args) => {
|
|
146
|
+
const client = await (0, connection_1.getConnection)();
|
|
147
|
+
const issue = await client.findOne(tracker_1.default.class.Issue, { identifier: args.identifier });
|
|
148
|
+
if (issue == null)
|
|
149
|
+
throw new Error(`Issue '${args.identifier}' not found.`);
|
|
150
|
+
await client.removeCollection(tracker_1.default.class.Issue, issue.space, issue._id, issue.attachedTo, issue.attachedToClass, issue.collection);
|
|
151
|
+
return `✅ Deleted **${args.identifier}**: ${issue.title}`;
|
|
152
|
+
});
|
|
153
|
+
exports.updateIssue = (0, errors_1.wrapToolHandler)(async (args) => {
|
|
154
|
+
const client = await (0, connection_1.getConnection)();
|
|
155
|
+
const issue = await client.findOne(tracker_1.default.class.Issue, { identifier: args.identifier });
|
|
156
|
+
if (issue == null)
|
|
157
|
+
throw new Error(`Issue '${args.identifier}' not found.`);
|
|
158
|
+
const updates = {};
|
|
159
|
+
if (args.title != null)
|
|
160
|
+
updates.title = args.title;
|
|
161
|
+
if (args.statusName != null) {
|
|
162
|
+
const status = await client.findOne(tracker_1.default.class.IssueStatus, { space: issue.space, name: args.statusName });
|
|
163
|
+
if (status == null)
|
|
164
|
+
throw new Error(`Status '${args.statusName}' not found.`);
|
|
165
|
+
updates.status = status._id;
|
|
166
|
+
}
|
|
167
|
+
if (args.priority != null) {
|
|
168
|
+
updates.priority = tracker_1.IssuePriority[args.priority];
|
|
169
|
+
}
|
|
170
|
+
if (args.dueDate !== undefined) {
|
|
171
|
+
updates.dueDate = args.dueDate != null ? new Date(args.dueDate).getTime() : null;
|
|
172
|
+
}
|
|
173
|
+
if (Object.keys(updates).length === 0)
|
|
174
|
+
return `No changes made to ${args.identifier}.`;
|
|
175
|
+
await client.updateDoc(tracker_1.default.class.Issue, issue.space, issue._id, updates);
|
|
176
|
+
const changed = Object.keys(updates).join(', ');
|
|
177
|
+
return `✅ Updated **${args.identifier}** — changed: ${changed}`;
|
|
178
|
+
});
|
|
179
|
+
//# sourceMappingURL=issues.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"issues.js","sourceRoot":"","sources":["../../src/tools/issues.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kEAA2E;AAC3E,+DAAsC;AACtC,8CAA6F;AAC7F,8CAA8C;AAC9C,8CAA6C;AAC7C,4CAAiD;AACjD,4CAA2D;AAU9C,QAAA,UAAU,GAAG,IAAA,wBAAe,EAAmC,KAAK,EAAE,IAAI,EAAE,EAAE;IACzF,MAAM,MAAM,GAAG,MAAM,IAAA,0BAAa,GAAE,CAAA;IACpC,MAAM,OAAO,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC,iBAAO,CAAC,KAAK,CAAC,OAAO,EAAE,EAAE,UAAU,EAAE,IAAI,CAAC,iBAAiB,EAAE,CAAC,CAAA;IACnG,IAAI,OAAO,IAAI,IAAI;QAAE,MAAM,IAAI,KAAK,CAAC,YAAY,IAAI,CAAC,iBAAiB,cAAc,CAAC,CAAA;IAEtF,MAAM,KAAK,GAA4B,EAAE,KAAK,EAAE,OAAO,CAAC,GAAG,EAAE,CAAA;IAE7D,IAAI,IAAI,CAAC,MAAM,IAAI,IAAI,EAAE,CAAC;QACxB,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC,iBAAO,CAAC,KAAK,CAAC,WAAW,EAAE,EAAE,KAAK,EAAE,OAAO,CAAC,GAAG,EAAE,IAAI,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC,CAAA;QACzG,IAAI,MAAM,IAAI,IAAI;YAAE,MAAM,IAAI,KAAK,CAAC,WAAW,IAAI,CAAC,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{
|
|
5
|
+
type: "text";
|
|
6
|
+
text: string;
|
|
7
|
+
}>;
|
|
8
|
+
}>;
|
|
9
|
+
export declare const createLabel: (args: {
|
|
10
|
+
title: string;
|
|
11
|
+
color?: string | undefined;
|
|
12
|
+
}) => Promise<{
|
|
13
|
+
content: Array<{
|
|
14
|
+
type: "text";
|
|
15
|
+
text: string;
|
|
16
|
+
}>;
|
|
17
|
+
}>;
|
|
18
|
+
export declare const addLabel: (args: {
|
|
19
|
+
identifier: string;
|
|
20
|
+
labelName: string;
|
|
21
|
+
}) => Promise<{
|
|
22
|
+
content: Array<{
|
|
23
|
+
type: "text";
|
|
24
|
+
text: string;
|
|
25
|
+
}>;
|
|
26
|
+
}>;
|
|
27
|
+
export declare const removeLabel: (args: {
|
|
28
|
+
identifier: string;
|
|
29
|
+
labelName: string;
|
|
30
|
+
}) => Promise<{
|
|
31
|
+
content: Array<{
|
|
32
|
+
type: "text";
|
|
33
|
+
text: string;
|
|
34
|
+
}>;
|
|
35
|
+
}>;
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.removeLabel = exports.addLabel = exports.createLabel = exports.listLabels = void 0;
|
|
40
|
+
const tags_1 = __importDefault(require("@hcengineering/tags"));
|
|
41
|
+
const tracker_1 = __importDefault(require("@hcengineering/tracker"));
|
|
42
|
+
const core_1 = __importStar(require("@hcengineering/core"));
|
|
43
|
+
const connection_1 = require("../connection");
|
|
44
|
+
const errors_1 = require("../utils/errors");
|
|
45
|
+
exports.listLabels = (0, errors_1.wrapToolHandler)(async (args) => {
|
|
46
|
+
const client = await (0, connection_1.getConnection)();
|
|
47
|
+
const query = args.projectIdentifier != null
|
|
48
|
+
? { targetClass: tracker_1.default.class.Issue }
|
|
49
|
+
: { targetClass: tracker_1.default.class.Issue };
|
|
50
|
+
const allLabels = await client.findAll(tags_1.default.class.TagElement, { targetClass: tracker_1.default.class.Issue });
|
|
51
|
+
if (allLabels.length === 0)
|
|
52
|
+
return 'No labels found in this workspace.';
|
|
53
|
+
const lines = allLabels.map((l) => {
|
|
54
|
+
const color = l.color != null ? ` (color: #${l.color.toString(16).padStart(6, '0')})` : '';
|
|
55
|
+
return `- **${l.title}**${color} — used ${l.refCount ?? 0} time(s) | id: \`${l._id}\``;
|
|
56
|
+
});
|
|
57
|
+
return `## Labels (${allLabels.length})\n\n${lines.join('\n')}`;
|
|
58
|
+
});
|
|
59
|
+
exports.createLabel = (0, errors_1.wrapToolHandler)(async (args) => {
|
|
60
|
+
const client = await (0, connection_1.getConnection)();
|
|
61
|
+
// Check if label already exists
|
|
62
|
+
const existing = await client.findOne(tags_1.default.class.TagElement, {
|
|
63
|
+
targetClass: tracker_1.default.class.Issue,
|
|
64
|
+
title: args.title
|
|
65
|
+
});
|
|
66
|
+
if (existing != null) {
|
|
67
|
+
return `Label **${args.title}** already exists (id: \`${existing._id}\`).`;
|
|
68
|
+
}
|
|
69
|
+
// Find or use the default no-category
|
|
70
|
+
const category = await client.findOne(tags_1.default.class.TagCategory, {
|
|
71
|
+
targetClass: tracker_1.default.class.Issue
|
|
72
|
+
});
|
|
73
|
+
const labelId = (0, core_1.generateId)();
|
|
74
|
+
await client.createDoc(tags_1.default.class.TagElement, core_1.default.space.Workspace, {
|
|
75
|
+
title: args.title,
|
|
76
|
+
targetClass: tracker_1.default.class.Issue,
|
|
77
|
+
description: '',
|
|
78
|
+
color: args.color != null ? parseInt(args.color.replace('#', ''), 16) : 8,
|
|
79
|
+
category: category?._id ?? tags_1.default.category.NoCategory,
|
|
80
|
+
refCount: 0
|
|
81
|
+
}, labelId);
|
|
82
|
+
return `✅ Created label **${args.title}** (id: \`${labelId}\`)`;
|
|
83
|
+
});
|
|
84
|
+
exports.addLabel = (0, errors_1.wrapToolHandler)(async (args) => {
|
|
85
|
+
const client = await (0, connection_1.getConnection)();
|
|
86
|
+
// Find issue
|
|
87
|
+
const issue = await client.findOne(tracker_1.default.class.Issue, { identifier: args.identifier });
|
|
88
|
+
if (issue == null)
|
|
89
|
+
throw new Error(`Issue '${args.identifier}' not found.`);
|
|
90
|
+
// Find label by name or create it
|
|
91
|
+
let label = await client.findOne(tags_1.default.class.TagElement, {
|
|
92
|
+
targetClass: tracker_1.default.class.Issue,
|
|
93
|
+
title: args.labelName
|
|
94
|
+
});
|
|
95
|
+
if (label == null) {
|
|
96
|
+
// Auto-create label
|
|
97
|
+
const category = await client.findOne(tags_1.default.class.TagCategory, {
|
|
98
|
+
targetClass: tracker_1.default.class.Issue
|
|
99
|
+
});
|
|
100
|
+
const labelId = (0, core_1.generateId)();
|
|
101
|
+
await client.createDoc(tags_1.default.class.TagElement, core_1.default.space.Workspace, {
|
|
102
|
+
title: args.labelName,
|
|
103
|
+
targetClass: tracker_1.default.class.Issue,
|
|
104
|
+
description: '',
|
|
105
|
+
color: 8,
|
|
106
|
+
category: category?._id ?? tags_1.default.category.NoCategory,
|
|
107
|
+
refCount: 0
|
|
108
|
+
}, labelId);
|
|
109
|
+
label = await client.findOne(tags_1.default.class.TagElement, { _id: labelId });
|
|
110
|
+
if (label == null)
|
|
111
|
+
throw new Error(`Failed to create label '${args.labelName}'.`);
|
|
112
|
+
}
|
|
113
|
+
// Check if already attached
|
|
114
|
+
const existing = await client.findOne(tags_1.default.class.TagReference, {
|
|
115
|
+
attachedTo: issue._id,
|
|
116
|
+
tag: label._id
|
|
117
|
+
});
|
|
118
|
+
if (existing != null) {
|
|
119
|
+
return `Label **${args.labelName}** is already on **${args.identifier}**.`;
|
|
120
|
+
}
|
|
121
|
+
// Attach label via addCollection
|
|
122
|
+
await client.addCollection(tags_1.default.class.TagReference, issue.space, issue._id, tracker_1.default.class.Issue, 'labels', {
|
|
123
|
+
tag: label._id,
|
|
124
|
+
title: label.title,
|
|
125
|
+
color: label.color
|
|
126
|
+
});
|
|
127
|
+
return `✅ Added label **${args.labelName}** to **${args.identifier}**`;
|
|
128
|
+
});
|
|
129
|
+
exports.removeLabel = (0, errors_1.wrapToolHandler)(async (args) => {
|
|
130
|
+
const client = await (0, connection_1.getConnection)();
|
|
131
|
+
const issue = await client.findOne(tracker_1.default.class.Issue, { identifier: args.identifier });
|
|
132
|
+
if (issue == null)
|
|
133
|
+
throw new Error(`Issue '${args.identifier}' not found.`);
|
|
134
|
+
const label = await client.findOne(tags_1.default.class.TagElement, {
|
|
135
|
+
targetClass: tracker_1.default.class.Issue,
|
|
136
|
+
title: args.labelName
|
|
137
|
+
});
|
|
138
|
+
if (label == null)
|
|
139
|
+
throw new Error(`Label '${args.labelName}' not found.`);
|
|
140
|
+
const ref = await client.findOne(tags_1.default.class.TagReference, {
|
|
141
|
+
attachedTo: issue._id,
|
|
142
|
+
tag: label._id
|
|
143
|
+
});
|
|
144
|
+
if (ref == null) {
|
|
145
|
+
return `Label **${args.labelName}** is not on **${args.identifier}**.`;
|
|
146
|
+
}
|
|
147
|
+
await client.removeCollection(tags_1.default.class.TagReference, issue.space, ref._id, issue._id, tracker_1.default.class.Issue, 'labels');
|
|
148
|
+
return `✅ Removed label **${args.labelName}** from **${args.identifier}**`;
|
|
149
|
+
});
|
|
150
|
+
//# sourceMappingURL=labels.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"labels.js","sourceRoot":"","sources":["../../src/tools/labels.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+DAAsC;AACtC,qEAA4C;AAC5C,4DAAgE;AAEhE,8CAA6C;AAC7C,4CAAiD;AASpC,QAAA,UAAU,GAAG,IAAA,wBAAe,EAAmC,KAAK,EAAE,IAAI,EAAE,EAAE;IACzF,MAAM,MAAM,GAAG,MAAM,IAAA,0BAAa,GAAE,CAAA;IAEpC,MAAM,KAAK,GAAG,IAAI,CAAC,iBAAiB,IAAI,IAAI;QAC1C,CAAC,CAAC,EAAE,WAAW,EAAE,iBAAO,CAAC,KAAK,CAAC,KAAK,EAAE;QACtC,CAAC,CAAC,EAAE,WAAW,EAAE,iBAAO,CAAC,KAAK,CAAC,KAAK,EAAE,CAAA;IAEx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AC,SAAS,cAAc,CAAC,CAAA;IAE1E,MAAM,GAAG,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC,cAAI,CAAC,KAAK,CAAC,YAAY,EAAE;QACxD,UAAU,EAAE,KAAK,CAAC,GAAG;QACrB,GAAG,EAAE,KAAK,CAAC,GAAG;KACf,CAAC,CAAA;IACF,IAAI,GAAG,IAAI,IAAI,EAAE,CAAC;QAChB,OAAO,WAAW,IAAI,CAAC,SAAS,kBAAkB,IAAI,CAAC,UAAU,KAAK,CAAA;IACxE,CAAC;IAED,MAAM,MAAM,CAAC,gBAAgB,CAC3B,cAAI,CAAC,KAAK,CAAC,YAAY,EACvB,KAAK,CAAC,KAAK,EACX,GAAG,CAAC,GAAG,EACP,KAAK,CAAC,GAAG,EACT,iBAAO,CAAC,KAAK,CAAC,KAAK,EACnB,QAAQ,CACT,CAAA;IAED,OAAO,qBAAqB,IAAI,CAAC,SAAS,aAAa,IAAI,CAAC,UAAU,IAAI,CAAA;AAC5E,CAAC,CAAC,CAAA"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.listMembers = void 0;
|
|
4
|
+
const connection_1 = require("../connection");
|
|
5
|
+
const errors_1 = require("../utils/errors");
|
|
6
|
+
exports.listMembers = (0, errors_1.wrapToolHandler)(async () => {
|
|
7
|
+
const accountClient = await (0, connection_1.getAccountClient)();
|
|
8
|
+
const members = await accountClient.getWorkspaceMembers();
|
|
9
|
+
if (members.length === 0)
|
|
10
|
+
return 'No members found in this workspace.';
|
|
11
|
+
const lines = members.map((m) => {
|
|
12
|
+
const role = String(m.role ?? 'member');
|
|
13
|
+
return `- \`${m.person}\` — role: **${role}**`;
|
|
14
|
+
});
|
|
15
|
+
return `## Workspace Members (${members.length})\n\n${lines.join('\n')}`;
|
|
16
|
+
});
|
|
17
|
+
//# sourceMappingURL=members.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"members.js","sourceRoot":"","sources":["../../src/tools/members.ts"],"names":[],"mappings":";;;AAAA,8CAAgD;AAChD,4CAAiD;AAEpC,QAAA,WAAW,GAAG,IAAA,wBAAe,EAAwB,KAAK,IAAI,EAAE;IAC3E,MAAM,aAAa,GAAG,MAAM,IAAA,6BAAgB,GAAE,CAAA;IAC9C,MAAM,OAAO,GAAG,MAAM,aAAa,CAAC,mBAAmB,EAAE,CAAA;IAEzD,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,qCAAqC,CAAA;IAEtE,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE;QAC9B,MAAM,IAAI,GAAG,MAAM,CAAC,CAAC,CAAC,IAAI,IAAI,QAAQ,CAAC,CAAA;QACvC,OAAO,OAAO,CAAC,CAAC,MAAM,gBAAgB,IAAI,IAAI,CAAA;IAChD,CAAC,CAAC,CAAA;IAEF,OAAO,yBAAyB,OAAO,CAAC,MAAM,QAAQ,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAA;AAC1E,CAAC,CAAC,CAAA"}
|