ai-dev-requirements 0.1.5 → 0.1.7
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/dist/index.cjs +336 -1
- package/dist/index.mjs +336 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -133,6 +133,60 @@ const SEARCH_TASKS_QUERY = `
|
|
|
133
133
|
}
|
|
134
134
|
`;
|
|
135
135
|
const TASK_BY_NUMBER_QUERY = SEARCH_TASKS_QUERY;
|
|
136
|
+
const RELATED_TASKS_QUERY = `
|
|
137
|
+
query Task($key: Key) {
|
|
138
|
+
task(key: $key) {
|
|
139
|
+
key
|
|
140
|
+
relatedTasks {
|
|
141
|
+
key
|
|
142
|
+
uuid
|
|
143
|
+
name
|
|
144
|
+
path
|
|
145
|
+
deadline
|
|
146
|
+
project { uuid name }
|
|
147
|
+
priority { value }
|
|
148
|
+
issueType {
|
|
149
|
+
key uuid name detailType
|
|
150
|
+
}
|
|
151
|
+
subIssueType {
|
|
152
|
+
key uuid name detailType
|
|
153
|
+
}
|
|
154
|
+
status {
|
|
155
|
+
uuid name category
|
|
156
|
+
}
|
|
157
|
+
assign {
|
|
158
|
+
uuid name
|
|
159
|
+
}
|
|
160
|
+
sprint {
|
|
161
|
+
name uuid
|
|
162
|
+
}
|
|
163
|
+
statusCategory
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
`;
|
|
168
|
+
const ISSUE_DETAIL_QUERY = `
|
|
169
|
+
query Task($key: Key) {
|
|
170
|
+
task(key: $key) {
|
|
171
|
+
key uuid
|
|
172
|
+
description
|
|
173
|
+
descriptionText
|
|
174
|
+
desc_rich: description
|
|
175
|
+
name
|
|
176
|
+
issueType { key uuid name detailType }
|
|
177
|
+
subIssueType { key uuid name detailType }
|
|
178
|
+
status { uuid name category }
|
|
179
|
+
priority { value }
|
|
180
|
+
assign { uuid name }
|
|
181
|
+
owner { uuid name }
|
|
182
|
+
solver { uuid name }
|
|
183
|
+
project { uuid name }
|
|
184
|
+
severityLevel { value }
|
|
185
|
+
deadline(unit: ONESDATE)
|
|
186
|
+
sprint { name uuid }
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
`;
|
|
136
190
|
const DEFAULT_STATUS_NOT_IN = [
|
|
137
191
|
"FgMGkcaq",
|
|
138
192
|
"NvRwHBSo",
|
|
@@ -301,6 +355,7 @@ var OnesAdapter = class extends BaseAdapter {
|
|
|
301
355
|
accessToken: token.access_token,
|
|
302
356
|
teamUuid,
|
|
303
357
|
orgUuid: orgUser.org_uuid,
|
|
358
|
+
userUuid: orgUser.org_user.org_user_uuid,
|
|
304
359
|
expiresAt: Date.now() + (token.expires_in - 60) * 1e3
|
|
305
360
|
};
|
|
306
361
|
return this.session;
|
|
@@ -340,6 +395,68 @@ var OnesAdapter = class extends BaseAdapter {
|
|
|
340
395
|
return response.json();
|
|
341
396
|
}
|
|
342
397
|
/**
|
|
398
|
+
* Resolve a fresh signed URL for an attachment resource via ONES attachment API.
|
|
399
|
+
* Endpoint: /project/api/project/team/{teamUuid}/res/attachment/{resourceUuid}
|
|
400
|
+
* Returns a redirect URL with a fresh OSS signature.
|
|
401
|
+
*/
|
|
402
|
+
async getAttachmentUrl(resourceUuid) {
|
|
403
|
+
const session = await this.login();
|
|
404
|
+
const url = `${this.config.apiBase}/project/api/project/team/${session.teamUuid}/res/attachment/${resourceUuid}?op=${encodeURIComponent("imageMogr2/auto-orient")}`;
|
|
405
|
+
try {
|
|
406
|
+
const manualRes = await fetch(url, {
|
|
407
|
+
headers: { Authorization: `Bearer ${session.accessToken}` },
|
|
408
|
+
redirect: "manual"
|
|
409
|
+
});
|
|
410
|
+
if (manualRes.status === 302 || manualRes.status === 301) {
|
|
411
|
+
const location = manualRes.headers.get("location");
|
|
412
|
+
if (location) return location;
|
|
413
|
+
}
|
|
414
|
+
const followRes = await fetch(url, {
|
|
415
|
+
headers: { Authorization: `Bearer ${session.accessToken}` },
|
|
416
|
+
redirect: "follow"
|
|
417
|
+
});
|
|
418
|
+
if (followRes.url && followRes.url !== url) return followRes.url;
|
|
419
|
+
if (followRes.ok) {
|
|
420
|
+
const text = await followRes.text();
|
|
421
|
+
if (text.startsWith("http")) return text.trim();
|
|
422
|
+
try {
|
|
423
|
+
return JSON.parse(text).url ?? null;
|
|
424
|
+
} catch {
|
|
425
|
+
return null;
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
console.error(`[getAttachmentUrl] Failed for resource ${resourceUuid}: status ${followRes.status}`);
|
|
429
|
+
return null;
|
|
430
|
+
} catch (err) {
|
|
431
|
+
console.error(`[getAttachmentUrl] Error for resource ${resourceUuid}:`, err);
|
|
432
|
+
return null;
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
/**
|
|
436
|
+
* Replace stale image URLs in HTML with fresh signed URLs from the attachment API.
|
|
437
|
+
* Extracts data-uuid from <img> tags and resolves fresh URLs in parallel.
|
|
438
|
+
*/
|
|
439
|
+
async refreshImageUrls(html) {
|
|
440
|
+
if (!html) return html;
|
|
441
|
+
const matches = Array.from(html.matchAll(/<img\s[^>]*data-uuid="([^"]+)"[^>]*>/g));
|
|
442
|
+
if (matches.length === 0) return html;
|
|
443
|
+
const replacements = await Promise.all(matches.map(async (match) => {
|
|
444
|
+
const dataUuid = match[1];
|
|
445
|
+
const freshUrl = await this.getAttachmentUrl(dataUuid);
|
|
446
|
+
return {
|
|
447
|
+
fullMatch: match[0],
|
|
448
|
+
dataUuid,
|
|
449
|
+
freshUrl
|
|
450
|
+
};
|
|
451
|
+
}));
|
|
452
|
+
let result = html;
|
|
453
|
+
for (const { fullMatch, freshUrl } of replacements) if (freshUrl) {
|
|
454
|
+
const updatedImg = fullMatch.replace(/src="[^"]*"/, `src="${freshUrl}"`);
|
|
455
|
+
result = result.replace(fullMatch, updatedImg);
|
|
456
|
+
}
|
|
457
|
+
return result;
|
|
458
|
+
}
|
|
459
|
+
/**
|
|
343
460
|
* Fetch wiki page content via REST API.
|
|
344
461
|
* Endpoint: /wiki/api/wiki/team/{teamUuid}/online_page/{wikiUuid}/content
|
|
345
462
|
*/
|
|
@@ -397,7 +514,10 @@ var OnesAdapter = class extends BaseAdapter {
|
|
|
397
514
|
if (task.relatedTasks?.length) {
|
|
398
515
|
parts.push("");
|
|
399
516
|
parts.push("## Related Tasks");
|
|
400
|
-
for (const related of task.relatedTasks)
|
|
517
|
+
for (const related of task.relatedTasks) {
|
|
518
|
+
const assignee = related.assign?.name ?? "Unassigned";
|
|
519
|
+
parts.push(`- #${related.number} ${related.name} [${related.issueType?.name}] (${related.status?.name}) — ${assignee}`);
|
|
520
|
+
}
|
|
401
521
|
}
|
|
402
522
|
if (task.parent?.uuid) {
|
|
403
523
|
parts.push("");
|
|
@@ -461,6 +581,79 @@ var OnesAdapter = class extends BaseAdapter {
|
|
|
461
581
|
pageSize
|
|
462
582
|
};
|
|
463
583
|
}
|
|
584
|
+
async getRelatedIssues(params) {
|
|
585
|
+
const session = await this.login();
|
|
586
|
+
const taskKey = params.taskId.startsWith("task-") ? params.taskId : `task-${params.taskId}`;
|
|
587
|
+
const filtered = ((await this.graphql(RELATED_TASKS_QUERY, { key: taskKey }, "Task")).data?.task?.relatedTasks ?? []).filter((t) => {
|
|
588
|
+
const isDefect = t.issueType?.detailType === 3 || t.subIssueType?.detailType === 3;
|
|
589
|
+
const isTodo = t.status?.category === "to_do";
|
|
590
|
+
return isDefect && isTodo;
|
|
591
|
+
});
|
|
592
|
+
const currentUserUuid = session.userUuid;
|
|
593
|
+
filtered.sort((a, b) => {
|
|
594
|
+
return (a.assign?.uuid === currentUserUuid ? 0 : 1) - (b.assign?.uuid === currentUserUuid ? 0 : 1);
|
|
595
|
+
});
|
|
596
|
+
return filtered.map((t) => ({
|
|
597
|
+
key: t.key,
|
|
598
|
+
uuid: t.uuid,
|
|
599
|
+
name: t.name,
|
|
600
|
+
issueTypeName: t.issueType?.name ?? "Unknown",
|
|
601
|
+
statusName: t.status?.name ?? "Unknown",
|
|
602
|
+
statusCategory: t.status?.category ?? "unknown",
|
|
603
|
+
assignName: t.assign?.name ?? null,
|
|
604
|
+
assignUuid: t.assign?.uuid ?? null,
|
|
605
|
+
priorityValue: t.priority?.value ?? null,
|
|
606
|
+
projectName: t.project?.name ?? null
|
|
607
|
+
}));
|
|
608
|
+
}
|
|
609
|
+
async getIssueDetail(params) {
|
|
610
|
+
let issueKey;
|
|
611
|
+
const numMatch = params.issueId.match(/^#?(\d+)$/);
|
|
612
|
+
if (numMatch) {
|
|
613
|
+
const taskNumber = Number.parseInt(numMatch[1], 10);
|
|
614
|
+
const found = ((await this.graphql(SEARCH_TASKS_QUERY, {
|
|
615
|
+
groupBy: { tasks: {} },
|
|
616
|
+
groupOrderBy: null,
|
|
617
|
+
orderBy: { createTime: "DESC" },
|
|
618
|
+
filterGroup: [{ number_in: [taskNumber] }],
|
|
619
|
+
search: null,
|
|
620
|
+
pagination: {
|
|
621
|
+
limit: 10,
|
|
622
|
+
preciseCount: false
|
|
623
|
+
},
|
|
624
|
+
limit: 10
|
|
625
|
+
}, "group-task-data")).data?.buckets?.flatMap((b) => b.tasks ?? []) ?? []).find((t) => t.number === taskNumber);
|
|
626
|
+
if (!found) throw new Error(`ONES: Issue #${taskNumber} not found in current team`);
|
|
627
|
+
issueKey = `task-${found.uuid}`;
|
|
628
|
+
} else issueKey = params.issueId.startsWith("task-") ? params.issueId : `task-${params.issueId}`;
|
|
629
|
+
const task = (await this.graphql(ISSUE_DETAIL_QUERY, { key: issueKey }, "Task")).data?.task;
|
|
630
|
+
if (!task) throw new Error(`ONES: Issue "${issueKey}" not found`);
|
|
631
|
+
const taskInfo = await this.fetchTaskInfo(task.uuid);
|
|
632
|
+
const rawDescription = taskInfo.desc ?? task.description ?? "";
|
|
633
|
+
const rawDescRich = taskInfo.desc_rich ?? task.desc_rich ?? "";
|
|
634
|
+
const freshDescription = await this.refreshImageUrls(rawDescription);
|
|
635
|
+
const freshDescRich = await this.refreshImageUrls(rawDescRich);
|
|
636
|
+
return {
|
|
637
|
+
key: task.key,
|
|
638
|
+
uuid: task.uuid,
|
|
639
|
+
name: task.name,
|
|
640
|
+
description: freshDescription,
|
|
641
|
+
descriptionRich: freshDescRich,
|
|
642
|
+
descriptionText: task.descriptionText ?? "",
|
|
643
|
+
issueTypeName: task.issueType?.name ?? "Unknown",
|
|
644
|
+
statusName: task.status?.name ?? "Unknown",
|
|
645
|
+
statusCategory: task.status?.category ?? "unknown",
|
|
646
|
+
assignName: task.assign?.name ?? null,
|
|
647
|
+
ownerName: task.owner?.name ?? null,
|
|
648
|
+
solverName: task.solver?.name ?? null,
|
|
649
|
+
priorityValue: task.priority?.value ?? null,
|
|
650
|
+
severityLevel: task.severityLevel?.value ?? null,
|
|
651
|
+
projectName: task.project?.name ?? null,
|
|
652
|
+
deadline: task.deadline ?? null,
|
|
653
|
+
sprintName: task.sprint?.name ?? null,
|
|
654
|
+
raw: task
|
|
655
|
+
};
|
|
656
|
+
}
|
|
464
657
|
};
|
|
465
658
|
|
|
466
659
|
//#endregion
|
|
@@ -627,6 +820,122 @@ function loadConfig(startDir) {
|
|
|
627
820
|
};
|
|
628
821
|
}
|
|
629
822
|
|
|
823
|
+
//#endregion
|
|
824
|
+
//#region src/tools/get-issue-detail.ts
|
|
825
|
+
const GetIssueDetailSchema = zod_v4.z.object({
|
|
826
|
+
issueId: zod_v4.z.string().describe("The issue task ID or key (e.g. \"6W9vW3y8J9DO66Pu\" or \"task-6W9vW3y8J9DO66Pu\")"),
|
|
827
|
+
source: zod_v4.z.string().optional().describe("Source to fetch from. If omitted, uses the default source.")
|
|
828
|
+
});
|
|
829
|
+
/**
|
|
830
|
+
* Download an image from URL and return as base64 data URI.
|
|
831
|
+
* Returns null if download fails.
|
|
832
|
+
*/
|
|
833
|
+
async function downloadImageAsBase64(url) {
|
|
834
|
+
try {
|
|
835
|
+
const res = await fetch(url, { redirect: "follow" });
|
|
836
|
+
if (!res.ok) return null;
|
|
837
|
+
const mimeType = (res.headers.get("content-type") ?? "image/png").split(";")[0].trim();
|
|
838
|
+
return {
|
|
839
|
+
base64: Buffer.from(await res.arrayBuffer()).toString("base64"),
|
|
840
|
+
mimeType
|
|
841
|
+
};
|
|
842
|
+
} catch {
|
|
843
|
+
return null;
|
|
844
|
+
}
|
|
845
|
+
}
|
|
846
|
+
/**
|
|
847
|
+
* Extract image URLs from HTML string.
|
|
848
|
+
*/
|
|
849
|
+
function extractImageUrls(html) {
|
|
850
|
+
return Array.from(html.matchAll(/<img[^>]+src="([^"]+)"[^>]*>/g), (m) => m[1]).map((url) => url.replace(/&/g, "&"));
|
|
851
|
+
}
|
|
852
|
+
async function handleGetIssueDetail(input, adapters, defaultSource) {
|
|
853
|
+
const sourceType = input.source ?? defaultSource;
|
|
854
|
+
if (!sourceType) throw new Error("No source specified and no default source configured");
|
|
855
|
+
const adapter = adapters.get(sourceType);
|
|
856
|
+
if (!adapter) throw new Error(`Source "${sourceType}" is not configured. Available: ${[...adapters.keys()].join(", ")}`);
|
|
857
|
+
const detail = await adapter.getIssueDetail({ issueId: input.issueId });
|
|
858
|
+
const imageUrls = detail.descriptionRich ? extractImageUrls(detail.descriptionRich) : [];
|
|
859
|
+
const imageResults = await Promise.all(imageUrls.map((url) => downloadImageAsBase64(url)));
|
|
860
|
+
const content = [{
|
|
861
|
+
type: "text",
|
|
862
|
+
text: formatIssueDetail(detail)
|
|
863
|
+
}];
|
|
864
|
+
for (let i = 0; i < imageResults.length; i++) {
|
|
865
|
+
const img = imageResults[i];
|
|
866
|
+
if (img) content.push({
|
|
867
|
+
type: "image",
|
|
868
|
+
data: img.base64,
|
|
869
|
+
mimeType: img.mimeType
|
|
870
|
+
});
|
|
871
|
+
}
|
|
872
|
+
return { content };
|
|
873
|
+
}
|
|
874
|
+
function formatIssueDetail(detail) {
|
|
875
|
+
const lines = [
|
|
876
|
+
`# ${detail.name}`,
|
|
877
|
+
"",
|
|
878
|
+
`- **Key**: ${detail.key}`,
|
|
879
|
+
`- **UUID**: ${detail.uuid}`,
|
|
880
|
+
`- **Type**: ${detail.issueTypeName}`,
|
|
881
|
+
`- **Status**: ${detail.statusName} (${detail.statusCategory})`,
|
|
882
|
+
`- **Priority**: ${detail.priorityValue ?? "N/A"}`,
|
|
883
|
+
`- **Severity**: ${detail.severityLevel ?? "N/A"}`,
|
|
884
|
+
`- **Assignee**: ${detail.assignName ?? "Unassigned"}`,
|
|
885
|
+
`- **Owner**: ${detail.ownerName ?? "Unknown"}`,
|
|
886
|
+
`- **Solver**: ${detail.solverName ?? "Unassigned"}`
|
|
887
|
+
];
|
|
888
|
+
if (detail.projectName) lines.push(`- **Project**: ${detail.projectName}`);
|
|
889
|
+
if (detail.sprintName) lines.push(`- **Sprint**: ${detail.sprintName}`);
|
|
890
|
+
if (detail.deadline) lines.push(`- **Deadline**: ${detail.deadline}`);
|
|
891
|
+
lines.push("", "## Description", "");
|
|
892
|
+
if (detail.descriptionRich) lines.push(detail.descriptionRich);
|
|
893
|
+
else if (detail.descriptionText) lines.push(detail.descriptionText);
|
|
894
|
+
else lines.push("_No description_");
|
|
895
|
+
return lines.join("\n");
|
|
896
|
+
}
|
|
897
|
+
|
|
898
|
+
//#endregion
|
|
899
|
+
//#region src/tools/get-related-issues.ts
|
|
900
|
+
const GetRelatedIssuesSchema = zod_v4.z.object({
|
|
901
|
+
taskId: zod_v4.z.string().describe("The parent task ID or key (e.g. \"HRL2p8rTX4mQ9xMv\" or \"task-HRL2p8rTX4mQ9xMv\")"),
|
|
902
|
+
source: zod_v4.z.string().optional().describe("Source to fetch from. If omitted, uses the default source.")
|
|
903
|
+
});
|
|
904
|
+
async function handleGetRelatedIssues(input, adapters, defaultSource) {
|
|
905
|
+
const sourceType = input.source ?? defaultSource;
|
|
906
|
+
if (!sourceType) throw new Error("No source specified and no default source configured");
|
|
907
|
+
const adapter = adapters.get(sourceType);
|
|
908
|
+
if (!adapter) throw new Error(`Source "${sourceType}" is not configured. Available: ${[...adapters.keys()].join(", ")}`);
|
|
909
|
+
return { content: [{
|
|
910
|
+
type: "text",
|
|
911
|
+
text: formatRelatedIssues(await adapter.getRelatedIssues({ taskId: input.taskId }))
|
|
912
|
+
}] };
|
|
913
|
+
}
|
|
914
|
+
function formatRelatedIssues(issues) {
|
|
915
|
+
const lines = [`Found **${issues.length}** pending defects:`, ""];
|
|
916
|
+
if (issues.length === 0) {
|
|
917
|
+
lines.push("No pending defects found for this task.");
|
|
918
|
+
return lines.join("\n");
|
|
919
|
+
}
|
|
920
|
+
const grouped = /* @__PURE__ */ new Map();
|
|
921
|
+
for (const issue of issues) {
|
|
922
|
+
const assignee = issue.assignName ?? "Unassigned";
|
|
923
|
+
if (!grouped.has(assignee)) grouped.set(assignee, []);
|
|
924
|
+
grouped.get(assignee).push(issue);
|
|
925
|
+
}
|
|
926
|
+
for (const [assignee, group] of grouped) {
|
|
927
|
+
lines.push(`## ${assignee} (${group.length})`);
|
|
928
|
+
lines.push("");
|
|
929
|
+
for (const issue of group) {
|
|
930
|
+
lines.push(`### ${issue.key}: ${issue.name}`);
|
|
931
|
+
lines.push(`- Status: ${issue.statusName} | Priority: ${issue.priorityValue ?? "N/A"}`);
|
|
932
|
+
if (issue.projectName) lines.push(`- Project: ${issue.projectName}`);
|
|
933
|
+
lines.push("");
|
|
934
|
+
}
|
|
935
|
+
}
|
|
936
|
+
return lines.join("\n");
|
|
937
|
+
}
|
|
938
|
+
|
|
630
939
|
//#endregion
|
|
631
940
|
//#region src/tools/get-requirement.ts
|
|
632
941
|
const GetRequirementSchema = zod_v4.z.object({
|
|
@@ -814,6 +1123,32 @@ async function main() {
|
|
|
814
1123
|
};
|
|
815
1124
|
}
|
|
816
1125
|
});
|
|
1126
|
+
server.tool("get_related_issues", "Get pending defect issues (bugs) related to a requirement task. Returns all pending defects grouped by assignee (current user first).", GetRelatedIssuesSchema.shape, async (params) => {
|
|
1127
|
+
try {
|
|
1128
|
+
return await handleGetRelatedIssues(params, adapters, config.config.defaultSource);
|
|
1129
|
+
} catch (err) {
|
|
1130
|
+
return {
|
|
1131
|
+
content: [{
|
|
1132
|
+
type: "text",
|
|
1133
|
+
text: `Error: ${err.message}`
|
|
1134
|
+
}],
|
|
1135
|
+
isError: true
|
|
1136
|
+
};
|
|
1137
|
+
}
|
|
1138
|
+
});
|
|
1139
|
+
server.tool("get_issue_detail", "Get detailed information about a specific issue/defect including description, rich text, and images", GetIssueDetailSchema.shape, async (params) => {
|
|
1140
|
+
try {
|
|
1141
|
+
return await handleGetIssueDetail(params, adapters, config.config.defaultSource);
|
|
1142
|
+
} catch (err) {
|
|
1143
|
+
return {
|
|
1144
|
+
content: [{
|
|
1145
|
+
type: "text",
|
|
1146
|
+
text: `Error: ${err.message}`
|
|
1147
|
+
}],
|
|
1148
|
+
isError: true
|
|
1149
|
+
};
|
|
1150
|
+
}
|
|
1151
|
+
});
|
|
817
1152
|
const transport = new _modelcontextprotocol_sdk_server_stdio_js.StdioServerTransport();
|
|
818
1153
|
await server.connect(transport);
|
|
819
1154
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -105,6 +105,60 @@ const SEARCH_TASKS_QUERY = `
|
|
|
105
105
|
}
|
|
106
106
|
`;
|
|
107
107
|
const TASK_BY_NUMBER_QUERY = SEARCH_TASKS_QUERY;
|
|
108
|
+
const RELATED_TASKS_QUERY = `
|
|
109
|
+
query Task($key: Key) {
|
|
110
|
+
task(key: $key) {
|
|
111
|
+
key
|
|
112
|
+
relatedTasks {
|
|
113
|
+
key
|
|
114
|
+
uuid
|
|
115
|
+
name
|
|
116
|
+
path
|
|
117
|
+
deadline
|
|
118
|
+
project { uuid name }
|
|
119
|
+
priority { value }
|
|
120
|
+
issueType {
|
|
121
|
+
key uuid name detailType
|
|
122
|
+
}
|
|
123
|
+
subIssueType {
|
|
124
|
+
key uuid name detailType
|
|
125
|
+
}
|
|
126
|
+
status {
|
|
127
|
+
uuid name category
|
|
128
|
+
}
|
|
129
|
+
assign {
|
|
130
|
+
uuid name
|
|
131
|
+
}
|
|
132
|
+
sprint {
|
|
133
|
+
name uuid
|
|
134
|
+
}
|
|
135
|
+
statusCategory
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
`;
|
|
140
|
+
const ISSUE_DETAIL_QUERY = `
|
|
141
|
+
query Task($key: Key) {
|
|
142
|
+
task(key: $key) {
|
|
143
|
+
key uuid
|
|
144
|
+
description
|
|
145
|
+
descriptionText
|
|
146
|
+
desc_rich: description
|
|
147
|
+
name
|
|
148
|
+
issueType { key uuid name detailType }
|
|
149
|
+
subIssueType { key uuid name detailType }
|
|
150
|
+
status { uuid name category }
|
|
151
|
+
priority { value }
|
|
152
|
+
assign { uuid name }
|
|
153
|
+
owner { uuid name }
|
|
154
|
+
solver { uuid name }
|
|
155
|
+
project { uuid name }
|
|
156
|
+
severityLevel { value }
|
|
157
|
+
deadline(unit: ONESDATE)
|
|
158
|
+
sprint { name uuid }
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
`;
|
|
108
162
|
const DEFAULT_STATUS_NOT_IN = [
|
|
109
163
|
"FgMGkcaq",
|
|
110
164
|
"NvRwHBSo",
|
|
@@ -273,6 +327,7 @@ var OnesAdapter = class extends BaseAdapter {
|
|
|
273
327
|
accessToken: token.access_token,
|
|
274
328
|
teamUuid,
|
|
275
329
|
orgUuid: orgUser.org_uuid,
|
|
330
|
+
userUuid: orgUser.org_user.org_user_uuid,
|
|
276
331
|
expiresAt: Date.now() + (token.expires_in - 60) * 1e3
|
|
277
332
|
};
|
|
278
333
|
return this.session;
|
|
@@ -312,6 +367,68 @@ var OnesAdapter = class extends BaseAdapter {
|
|
|
312
367
|
return response.json();
|
|
313
368
|
}
|
|
314
369
|
/**
|
|
370
|
+
* Resolve a fresh signed URL for an attachment resource via ONES attachment API.
|
|
371
|
+
* Endpoint: /project/api/project/team/{teamUuid}/res/attachment/{resourceUuid}
|
|
372
|
+
* Returns a redirect URL with a fresh OSS signature.
|
|
373
|
+
*/
|
|
374
|
+
async getAttachmentUrl(resourceUuid) {
|
|
375
|
+
const session = await this.login();
|
|
376
|
+
const url = `${this.config.apiBase}/project/api/project/team/${session.teamUuid}/res/attachment/${resourceUuid}?op=${encodeURIComponent("imageMogr2/auto-orient")}`;
|
|
377
|
+
try {
|
|
378
|
+
const manualRes = await fetch(url, {
|
|
379
|
+
headers: { Authorization: `Bearer ${session.accessToken}` },
|
|
380
|
+
redirect: "manual"
|
|
381
|
+
});
|
|
382
|
+
if (manualRes.status === 302 || manualRes.status === 301) {
|
|
383
|
+
const location = manualRes.headers.get("location");
|
|
384
|
+
if (location) return location;
|
|
385
|
+
}
|
|
386
|
+
const followRes = await fetch(url, {
|
|
387
|
+
headers: { Authorization: `Bearer ${session.accessToken}` },
|
|
388
|
+
redirect: "follow"
|
|
389
|
+
});
|
|
390
|
+
if (followRes.url && followRes.url !== url) return followRes.url;
|
|
391
|
+
if (followRes.ok) {
|
|
392
|
+
const text = await followRes.text();
|
|
393
|
+
if (text.startsWith("http")) return text.trim();
|
|
394
|
+
try {
|
|
395
|
+
return JSON.parse(text).url ?? null;
|
|
396
|
+
} catch {
|
|
397
|
+
return null;
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
console.error(`[getAttachmentUrl] Failed for resource ${resourceUuid}: status ${followRes.status}`);
|
|
401
|
+
return null;
|
|
402
|
+
} catch (err) {
|
|
403
|
+
console.error(`[getAttachmentUrl] Error for resource ${resourceUuid}:`, err);
|
|
404
|
+
return null;
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
/**
|
|
408
|
+
* Replace stale image URLs in HTML with fresh signed URLs from the attachment API.
|
|
409
|
+
* Extracts data-uuid from <img> tags and resolves fresh URLs in parallel.
|
|
410
|
+
*/
|
|
411
|
+
async refreshImageUrls(html) {
|
|
412
|
+
if (!html) return html;
|
|
413
|
+
const matches = Array.from(html.matchAll(/<img\s[^>]*data-uuid="([^"]+)"[^>]*>/g));
|
|
414
|
+
if (matches.length === 0) return html;
|
|
415
|
+
const replacements = await Promise.all(matches.map(async (match) => {
|
|
416
|
+
const dataUuid = match[1];
|
|
417
|
+
const freshUrl = await this.getAttachmentUrl(dataUuid);
|
|
418
|
+
return {
|
|
419
|
+
fullMatch: match[0],
|
|
420
|
+
dataUuid,
|
|
421
|
+
freshUrl
|
|
422
|
+
};
|
|
423
|
+
}));
|
|
424
|
+
let result = html;
|
|
425
|
+
for (const { fullMatch, freshUrl } of replacements) if (freshUrl) {
|
|
426
|
+
const updatedImg = fullMatch.replace(/src="[^"]*"/, `src="${freshUrl}"`);
|
|
427
|
+
result = result.replace(fullMatch, updatedImg);
|
|
428
|
+
}
|
|
429
|
+
return result;
|
|
430
|
+
}
|
|
431
|
+
/**
|
|
315
432
|
* Fetch wiki page content via REST API.
|
|
316
433
|
* Endpoint: /wiki/api/wiki/team/{teamUuid}/online_page/{wikiUuid}/content
|
|
317
434
|
*/
|
|
@@ -369,7 +486,10 @@ var OnesAdapter = class extends BaseAdapter {
|
|
|
369
486
|
if (task.relatedTasks?.length) {
|
|
370
487
|
parts.push("");
|
|
371
488
|
parts.push("## Related Tasks");
|
|
372
|
-
for (const related of task.relatedTasks)
|
|
489
|
+
for (const related of task.relatedTasks) {
|
|
490
|
+
const assignee = related.assign?.name ?? "Unassigned";
|
|
491
|
+
parts.push(`- #${related.number} ${related.name} [${related.issueType?.name}] (${related.status?.name}) — ${assignee}`);
|
|
492
|
+
}
|
|
373
493
|
}
|
|
374
494
|
if (task.parent?.uuid) {
|
|
375
495
|
parts.push("");
|
|
@@ -433,6 +553,79 @@ var OnesAdapter = class extends BaseAdapter {
|
|
|
433
553
|
pageSize
|
|
434
554
|
};
|
|
435
555
|
}
|
|
556
|
+
async getRelatedIssues(params) {
|
|
557
|
+
const session = await this.login();
|
|
558
|
+
const taskKey = params.taskId.startsWith("task-") ? params.taskId : `task-${params.taskId}`;
|
|
559
|
+
const filtered = ((await this.graphql(RELATED_TASKS_QUERY, { key: taskKey }, "Task")).data?.task?.relatedTasks ?? []).filter((t) => {
|
|
560
|
+
const isDefect = t.issueType?.detailType === 3 || t.subIssueType?.detailType === 3;
|
|
561
|
+
const isTodo = t.status?.category === "to_do";
|
|
562
|
+
return isDefect && isTodo;
|
|
563
|
+
});
|
|
564
|
+
const currentUserUuid = session.userUuid;
|
|
565
|
+
filtered.sort((a, b) => {
|
|
566
|
+
return (a.assign?.uuid === currentUserUuid ? 0 : 1) - (b.assign?.uuid === currentUserUuid ? 0 : 1);
|
|
567
|
+
});
|
|
568
|
+
return filtered.map((t) => ({
|
|
569
|
+
key: t.key,
|
|
570
|
+
uuid: t.uuid,
|
|
571
|
+
name: t.name,
|
|
572
|
+
issueTypeName: t.issueType?.name ?? "Unknown",
|
|
573
|
+
statusName: t.status?.name ?? "Unknown",
|
|
574
|
+
statusCategory: t.status?.category ?? "unknown",
|
|
575
|
+
assignName: t.assign?.name ?? null,
|
|
576
|
+
assignUuid: t.assign?.uuid ?? null,
|
|
577
|
+
priorityValue: t.priority?.value ?? null,
|
|
578
|
+
projectName: t.project?.name ?? null
|
|
579
|
+
}));
|
|
580
|
+
}
|
|
581
|
+
async getIssueDetail(params) {
|
|
582
|
+
let issueKey;
|
|
583
|
+
const numMatch = params.issueId.match(/^#?(\d+)$/);
|
|
584
|
+
if (numMatch) {
|
|
585
|
+
const taskNumber = Number.parseInt(numMatch[1], 10);
|
|
586
|
+
const found = ((await this.graphql(SEARCH_TASKS_QUERY, {
|
|
587
|
+
groupBy: { tasks: {} },
|
|
588
|
+
groupOrderBy: null,
|
|
589
|
+
orderBy: { createTime: "DESC" },
|
|
590
|
+
filterGroup: [{ number_in: [taskNumber] }],
|
|
591
|
+
search: null,
|
|
592
|
+
pagination: {
|
|
593
|
+
limit: 10,
|
|
594
|
+
preciseCount: false
|
|
595
|
+
},
|
|
596
|
+
limit: 10
|
|
597
|
+
}, "group-task-data")).data?.buckets?.flatMap((b) => b.tasks ?? []) ?? []).find((t) => t.number === taskNumber);
|
|
598
|
+
if (!found) throw new Error(`ONES: Issue #${taskNumber} not found in current team`);
|
|
599
|
+
issueKey = `task-${found.uuid}`;
|
|
600
|
+
} else issueKey = params.issueId.startsWith("task-") ? params.issueId : `task-${params.issueId}`;
|
|
601
|
+
const task = (await this.graphql(ISSUE_DETAIL_QUERY, { key: issueKey }, "Task")).data?.task;
|
|
602
|
+
if (!task) throw new Error(`ONES: Issue "${issueKey}" not found`);
|
|
603
|
+
const taskInfo = await this.fetchTaskInfo(task.uuid);
|
|
604
|
+
const rawDescription = taskInfo.desc ?? task.description ?? "";
|
|
605
|
+
const rawDescRich = taskInfo.desc_rich ?? task.desc_rich ?? "";
|
|
606
|
+
const freshDescription = await this.refreshImageUrls(rawDescription);
|
|
607
|
+
const freshDescRich = await this.refreshImageUrls(rawDescRich);
|
|
608
|
+
return {
|
|
609
|
+
key: task.key,
|
|
610
|
+
uuid: task.uuid,
|
|
611
|
+
name: task.name,
|
|
612
|
+
description: freshDescription,
|
|
613
|
+
descriptionRich: freshDescRich,
|
|
614
|
+
descriptionText: task.descriptionText ?? "",
|
|
615
|
+
issueTypeName: task.issueType?.name ?? "Unknown",
|
|
616
|
+
statusName: task.status?.name ?? "Unknown",
|
|
617
|
+
statusCategory: task.status?.category ?? "unknown",
|
|
618
|
+
assignName: task.assign?.name ?? null,
|
|
619
|
+
ownerName: task.owner?.name ?? null,
|
|
620
|
+
solverName: task.solver?.name ?? null,
|
|
621
|
+
priorityValue: task.priority?.value ?? null,
|
|
622
|
+
severityLevel: task.severityLevel?.value ?? null,
|
|
623
|
+
projectName: task.project?.name ?? null,
|
|
624
|
+
deadline: task.deadline ?? null,
|
|
625
|
+
sprintName: task.sprint?.name ?? null,
|
|
626
|
+
raw: task
|
|
627
|
+
};
|
|
628
|
+
}
|
|
436
629
|
};
|
|
437
630
|
|
|
438
631
|
//#endregion
|
|
@@ -599,6 +792,122 @@ function loadConfig(startDir) {
|
|
|
599
792
|
};
|
|
600
793
|
}
|
|
601
794
|
|
|
795
|
+
//#endregion
|
|
796
|
+
//#region src/tools/get-issue-detail.ts
|
|
797
|
+
const GetIssueDetailSchema = z.object({
|
|
798
|
+
issueId: z.string().describe("The issue task ID or key (e.g. \"6W9vW3y8J9DO66Pu\" or \"task-6W9vW3y8J9DO66Pu\")"),
|
|
799
|
+
source: z.string().optional().describe("Source to fetch from. If omitted, uses the default source.")
|
|
800
|
+
});
|
|
801
|
+
/**
|
|
802
|
+
* Download an image from URL and return as base64 data URI.
|
|
803
|
+
* Returns null if download fails.
|
|
804
|
+
*/
|
|
805
|
+
async function downloadImageAsBase64(url) {
|
|
806
|
+
try {
|
|
807
|
+
const res = await fetch(url, { redirect: "follow" });
|
|
808
|
+
if (!res.ok) return null;
|
|
809
|
+
const mimeType = (res.headers.get("content-type") ?? "image/png").split(";")[0].trim();
|
|
810
|
+
return {
|
|
811
|
+
base64: Buffer.from(await res.arrayBuffer()).toString("base64"),
|
|
812
|
+
mimeType
|
|
813
|
+
};
|
|
814
|
+
} catch {
|
|
815
|
+
return null;
|
|
816
|
+
}
|
|
817
|
+
}
|
|
818
|
+
/**
|
|
819
|
+
* Extract image URLs from HTML string.
|
|
820
|
+
*/
|
|
821
|
+
function extractImageUrls(html) {
|
|
822
|
+
return Array.from(html.matchAll(/<img[^>]+src="([^"]+)"[^>]*>/g), (m) => m[1]).map((url) => url.replace(/&/g, "&"));
|
|
823
|
+
}
|
|
824
|
+
async function handleGetIssueDetail(input, adapters, defaultSource) {
|
|
825
|
+
const sourceType = input.source ?? defaultSource;
|
|
826
|
+
if (!sourceType) throw new Error("No source specified and no default source configured");
|
|
827
|
+
const adapter = adapters.get(sourceType);
|
|
828
|
+
if (!adapter) throw new Error(`Source "${sourceType}" is not configured. Available: ${[...adapters.keys()].join(", ")}`);
|
|
829
|
+
const detail = await adapter.getIssueDetail({ issueId: input.issueId });
|
|
830
|
+
const imageUrls = detail.descriptionRich ? extractImageUrls(detail.descriptionRich) : [];
|
|
831
|
+
const imageResults = await Promise.all(imageUrls.map((url) => downloadImageAsBase64(url)));
|
|
832
|
+
const content = [{
|
|
833
|
+
type: "text",
|
|
834
|
+
text: formatIssueDetail(detail)
|
|
835
|
+
}];
|
|
836
|
+
for (let i = 0; i < imageResults.length; i++) {
|
|
837
|
+
const img = imageResults[i];
|
|
838
|
+
if (img) content.push({
|
|
839
|
+
type: "image",
|
|
840
|
+
data: img.base64,
|
|
841
|
+
mimeType: img.mimeType
|
|
842
|
+
});
|
|
843
|
+
}
|
|
844
|
+
return { content };
|
|
845
|
+
}
|
|
846
|
+
function formatIssueDetail(detail) {
|
|
847
|
+
const lines = [
|
|
848
|
+
`# ${detail.name}`,
|
|
849
|
+
"",
|
|
850
|
+
`- **Key**: ${detail.key}`,
|
|
851
|
+
`- **UUID**: ${detail.uuid}`,
|
|
852
|
+
`- **Type**: ${detail.issueTypeName}`,
|
|
853
|
+
`- **Status**: ${detail.statusName} (${detail.statusCategory})`,
|
|
854
|
+
`- **Priority**: ${detail.priorityValue ?? "N/A"}`,
|
|
855
|
+
`- **Severity**: ${detail.severityLevel ?? "N/A"}`,
|
|
856
|
+
`- **Assignee**: ${detail.assignName ?? "Unassigned"}`,
|
|
857
|
+
`- **Owner**: ${detail.ownerName ?? "Unknown"}`,
|
|
858
|
+
`- **Solver**: ${detail.solverName ?? "Unassigned"}`
|
|
859
|
+
];
|
|
860
|
+
if (detail.projectName) lines.push(`- **Project**: ${detail.projectName}`);
|
|
861
|
+
if (detail.sprintName) lines.push(`- **Sprint**: ${detail.sprintName}`);
|
|
862
|
+
if (detail.deadline) lines.push(`- **Deadline**: ${detail.deadline}`);
|
|
863
|
+
lines.push("", "## Description", "");
|
|
864
|
+
if (detail.descriptionRich) lines.push(detail.descriptionRich);
|
|
865
|
+
else if (detail.descriptionText) lines.push(detail.descriptionText);
|
|
866
|
+
else lines.push("_No description_");
|
|
867
|
+
return lines.join("\n");
|
|
868
|
+
}
|
|
869
|
+
|
|
870
|
+
//#endregion
|
|
871
|
+
//#region src/tools/get-related-issues.ts
|
|
872
|
+
const GetRelatedIssuesSchema = z.object({
|
|
873
|
+
taskId: z.string().describe("The parent task ID or key (e.g. \"HRL2p8rTX4mQ9xMv\" or \"task-HRL2p8rTX4mQ9xMv\")"),
|
|
874
|
+
source: z.string().optional().describe("Source to fetch from. If omitted, uses the default source.")
|
|
875
|
+
});
|
|
876
|
+
async function handleGetRelatedIssues(input, adapters, defaultSource) {
|
|
877
|
+
const sourceType = input.source ?? defaultSource;
|
|
878
|
+
if (!sourceType) throw new Error("No source specified and no default source configured");
|
|
879
|
+
const adapter = adapters.get(sourceType);
|
|
880
|
+
if (!adapter) throw new Error(`Source "${sourceType}" is not configured. Available: ${[...adapters.keys()].join(", ")}`);
|
|
881
|
+
return { content: [{
|
|
882
|
+
type: "text",
|
|
883
|
+
text: formatRelatedIssues(await adapter.getRelatedIssues({ taskId: input.taskId }))
|
|
884
|
+
}] };
|
|
885
|
+
}
|
|
886
|
+
function formatRelatedIssues(issues) {
|
|
887
|
+
const lines = [`Found **${issues.length}** pending defects:`, ""];
|
|
888
|
+
if (issues.length === 0) {
|
|
889
|
+
lines.push("No pending defects found for this task.");
|
|
890
|
+
return lines.join("\n");
|
|
891
|
+
}
|
|
892
|
+
const grouped = /* @__PURE__ */ new Map();
|
|
893
|
+
for (const issue of issues) {
|
|
894
|
+
const assignee = issue.assignName ?? "Unassigned";
|
|
895
|
+
if (!grouped.has(assignee)) grouped.set(assignee, []);
|
|
896
|
+
grouped.get(assignee).push(issue);
|
|
897
|
+
}
|
|
898
|
+
for (const [assignee, group] of grouped) {
|
|
899
|
+
lines.push(`## ${assignee} (${group.length})`);
|
|
900
|
+
lines.push("");
|
|
901
|
+
for (const issue of group) {
|
|
902
|
+
lines.push(`### ${issue.key}: ${issue.name}`);
|
|
903
|
+
lines.push(`- Status: ${issue.statusName} | Priority: ${issue.priorityValue ?? "N/A"}`);
|
|
904
|
+
if (issue.projectName) lines.push(`- Project: ${issue.projectName}`);
|
|
905
|
+
lines.push("");
|
|
906
|
+
}
|
|
907
|
+
}
|
|
908
|
+
return lines.join("\n");
|
|
909
|
+
}
|
|
910
|
+
|
|
602
911
|
//#endregion
|
|
603
912
|
//#region src/tools/get-requirement.ts
|
|
604
913
|
const GetRequirementSchema = z.object({
|
|
@@ -786,6 +1095,32 @@ async function main() {
|
|
|
786
1095
|
};
|
|
787
1096
|
}
|
|
788
1097
|
});
|
|
1098
|
+
server.tool("get_related_issues", "Get pending defect issues (bugs) related to a requirement task. Returns all pending defects grouped by assignee (current user first).", GetRelatedIssuesSchema.shape, async (params) => {
|
|
1099
|
+
try {
|
|
1100
|
+
return await handleGetRelatedIssues(params, adapters, config.config.defaultSource);
|
|
1101
|
+
} catch (err) {
|
|
1102
|
+
return {
|
|
1103
|
+
content: [{
|
|
1104
|
+
type: "text",
|
|
1105
|
+
text: `Error: ${err.message}`
|
|
1106
|
+
}],
|
|
1107
|
+
isError: true
|
|
1108
|
+
};
|
|
1109
|
+
}
|
|
1110
|
+
});
|
|
1111
|
+
server.tool("get_issue_detail", "Get detailed information about a specific issue/defect including description, rich text, and images", GetIssueDetailSchema.shape, async (params) => {
|
|
1112
|
+
try {
|
|
1113
|
+
return await handleGetIssueDetail(params, adapters, config.config.defaultSource);
|
|
1114
|
+
} catch (err) {
|
|
1115
|
+
return {
|
|
1116
|
+
content: [{
|
|
1117
|
+
type: "text",
|
|
1118
|
+
text: `Error: ${err.message}`
|
|
1119
|
+
}],
|
|
1120
|
+
isError: true
|
|
1121
|
+
};
|
|
1122
|
+
}
|
|
1123
|
+
});
|
|
789
1124
|
const transport = new StdioServerTransport();
|
|
790
1125
|
await server.connect(transport);
|
|
791
1126
|
}
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../src/utils/map-status.ts","../src/adapters/base.ts","../src/adapters/ones.ts","../src/adapters/index.ts","../src/config/loader.ts","../src/tools/get-requirement.ts","../src/tools/list-sources.ts","../src/tools/search-requirements.ts","../src/index.ts"],"sourcesContent":["import type { RequirementPriority, RequirementStatus, RequirementType } from '../types/requirement.js'\n\n// --- ONES status mapping ---\nconst ONES_STATUS_MAP: Record<string, RequirementStatus> = {\n to_do: 'open',\n in_progress: 'in_progress',\n done: 'done',\n closed: 'closed',\n}\n\n// --- Priority mappings ---\nconst ONES_PRIORITY_MAP: Record<string, RequirementPriority> = {\n urgent: 'critical',\n high: 'high',\n normal: 'medium',\n medium: 'medium',\n low: 'low',\n}\n\n// --- Type mappings ---\nconst ONES_TYPE_MAP: Record<string, RequirementType> = {\n demand: 'feature',\n 需求: 'feature',\n task: 'task',\n 任务: 'task',\n bug: 'bug',\n 缺陷: 'bug',\n story: 'story',\n 子任务: 'task',\n 工单: 'task',\n 测试任务: 'task',\n}\n\nexport function mapOnesStatus(status: string): RequirementStatus {\n return ONES_STATUS_MAP[status.toLowerCase()] ?? 'open'\n}\n\nexport function mapOnesPriority(priority: string): RequirementPriority {\n return ONES_PRIORITY_MAP[priority.toLowerCase()] ?? 'medium'\n}\n\nexport function mapOnesType(type: string): RequirementType {\n return ONES_TYPE_MAP[type.toLowerCase()] ?? 'task'\n}\n","import type { SourceConfig } from '../types/config.js'\nimport type { Requirement, SearchResult, SourceType } from '../types/requirement.js'\n\nexport interface GetRequirementParams {\n id: string\n}\n\nexport interface SearchRequirementsParams {\n query: string\n page?: number\n pageSize?: number\n}\n\n/**\n * Abstract base class for source adapters.\n * Each adapter implements platform-specific logic for fetching requirements.\n */\nexport abstract class BaseAdapter {\n readonly sourceType: SourceType\n protected readonly config: SourceConfig\n protected readonly resolvedAuth: Record<string, string>\n\n constructor(\n sourceType: SourceType,\n config: SourceConfig,\n resolvedAuth: Record<string, string>,\n ) {\n this.sourceType = sourceType\n this.config = config\n this.resolvedAuth = resolvedAuth\n }\n\n /**\n * Fetch a single requirement by its ID.\n */\n abstract getRequirement(params: GetRequirementParams): Promise<Requirement>\n\n /**\n * Search requirements by query string.\n */\n abstract searchRequirements(params: SearchRequirementsParams): Promise<SearchResult>\n}\n","import type { SourceConfig } from '../types/config.js'\nimport type { Requirement, SearchResult, SourceType } from '../types/requirement.js'\n\nimport type { GetRequirementParams, SearchRequirementsParams } from './base.js'\nimport crypto from 'node:crypto'\nimport { mapOnesPriority, mapOnesStatus, mapOnesType } from '../utils/map-status.js'\nimport { BaseAdapter } from './base.js'\n\n// ============ ONES GraphQL types ============\n\ninterface OnesTaskNode {\n key?: string\n uuid: string\n number: number\n name: string\n status: { uuid: string, name: string, category?: string }\n priority?: { value: string }\n issueType?: { uuid: string, name: string }\n assign?: { uuid: string, name: string } | null\n owner?: { uuid: string, name: string } | null\n project?: { uuid: string, name: string }\n parent?: { uuid: string, number?: number, issueType?: { uuid: string, name: string } } | null\n relatedTasks?: OnesRelatedTask[]\n relatedWikiPages?: OnesWikiPage[]\n relatedWikiPagesCount?: number\n path?: string\n}\n\ninterface OnesWikiPage {\n uuid: string\n title: string\n referenceType?: number\n subReferenceType?: string\n errorMessage?: string\n}\n\ninterface OnesRelatedTask {\n uuid: string\n number: number\n name: string\n issueType: { uuid: string, name: string }\n status: { uuid: string, name: string, category?: string }\n assign?: { uuid: string, name: string } | null\n}\n\ninterface OnesTokenResponse {\n access_token: string\n token_type: string\n expires_in: number\n}\n\ninterface OnesLoginResponse {\n sid: string\n auth_user_uuid: string\n org_users: Array<{\n region_uuid: string\n org_uuid: string\n org_user: { org_user_uuid: string, name: string }\n org: { org_uuid: string, name: string }\n }>\n}\n\ninterface OnesSession {\n accessToken: string\n teamUuid: string\n orgUuid: string\n expiresAt: number\n}\n\n// ============ GraphQL queries ============\n\nconst TASK_DETAIL_QUERY = `\n query Task($key: Key) {\n task(key: $key) {\n key uuid number name\n issueType { uuid name }\n status { uuid name category }\n priority { value }\n assign { uuid name }\n owner { uuid name }\n project { uuid name }\n parent { uuid number issueType { uuid name } }\n relatedTasks {\n uuid number name\n issueType { uuid name }\n status { uuid name category }\n assign { uuid name }\n }\n relatedWikiPages {\n uuid\n title\n referenceType\n subReferenceType\n errorMessage\n }\n relatedWikiPagesCount\n }\n }\n`\n\nconst SEARCH_TASKS_QUERY = `\n query GROUP_TASK_DATA($groupBy: GroupBy, $groupOrderBy: OrderBy, $orderBy: OrderBy, $filterGroup: [Filter!], $search: Search, $pagination: Pagination, $limit: Int) {\n buckets(groupBy: $groupBy, orderBy: $groupOrderBy, pagination: $pagination, filter: $search) {\n key\n tasks(filterGroup: $filterGroup, orderBy: $orderBy, limit: $limit, includeAncestors: { pathField: \"path\" }) {\n key uuid number name\n issueType { uuid name }\n status { uuid name category }\n priority { value }\n assign { uuid name }\n project { uuid name }\n }\n }\n }\n`\n\n// Query to find a task by its number\nconst TASK_BY_NUMBER_QUERY = SEARCH_TASKS_QUERY\nconst DEFAULT_STATUS_NOT_IN = ['FgMGkcaq', 'NvRwHBSo', 'Dn3k8ffK', 'TbmY2So5']\n\n// ============ Helpers ============\n\nfunction base64Url(buffer: Buffer): string {\n return buffer.toString('base64').replace(/\\+/g, '-').replace(/\\//g, '_').replace(/=+$/g, '')\n}\n\nfunction getSetCookies(response: Response): string[] {\n const headers = response.headers as unknown as { getSetCookie?: () => string[] }\n if (headers.getSetCookie) {\n return headers.getSetCookie()\n }\n const raw = response.headers.get('set-cookie')\n return raw ? [raw] : []\n}\n\nfunction toRequirement(task: OnesTaskNode, description = ''): Requirement {\n return {\n id: task.uuid,\n source: 'ones',\n title: `#${task.number} ${task.name}`,\n description,\n status: mapOnesStatus(task.status?.category ?? 'to_do'),\n priority: mapOnesPriority(task.priority?.value ?? 'normal'),\n type: mapOnesType(task.issueType?.name ?? '任务'),\n labels: [],\n reporter: '',\n assignee: task.assign?.name ?? null,\n // ONES GraphQL does not return timestamps; these are fetch-time placeholders\n createdAt: '',\n updatedAt: '',\n dueDate: null,\n attachments: [],\n raw: task as unknown as Record<string, unknown>,\n }\n}\n\n// ============ ONES Adapter ============\n\nexport class OnesAdapter extends BaseAdapter {\n private session: OnesSession | null = null\n\n constructor(\n sourceType: SourceType,\n config: SourceConfig,\n resolvedAuth: Record<string, string>,\n ) {\n super(sourceType, config, resolvedAuth)\n }\n\n /**\n * ONES OAuth2 PKCE login flow.\n * Reference: D:\\company code\\ones\\packages\\core\\src\\auth.ts\n */\n private async login(): Promise<OnesSession> {\n if (this.session && Date.now() < this.session.expiresAt) {\n return this.session\n }\n\n const baseUrl = this.config.apiBase\n const email = this.resolvedAuth.email\n const password = this.resolvedAuth.password\n\n if (!email || !password) {\n throw new Error('ONES auth requires email and password (ones-pkce auth type)')\n }\n\n // 1. Get encryption certificate\n const certRes = await fetch(`${baseUrl}/identity/api/encryption_cert`, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: '{}',\n })\n if (!certRes.ok) {\n throw new Error(`ONES: Failed to get encryption cert: ${certRes.status}`)\n }\n const cert = (await certRes.json()) as { public_key: string }\n\n // 2. Encrypt password with RSA public key\n const encrypted = crypto.publicEncrypt(\n { key: cert.public_key, padding: crypto.constants.RSA_PKCS1_PADDING },\n Buffer.from(password, 'utf-8'),\n )\n const encryptedPassword = encrypted.toString('base64')\n\n // 3. Login\n const loginRes = await fetch(`${baseUrl}/identity/api/login`, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({ email, password: encryptedPassword }),\n })\n if (!loginRes.ok) {\n const text = await loginRes.text().catch(() => '')\n throw new Error(`ONES: Login failed: ${loginRes.status} ${text}`)\n }\n\n const cookies = getSetCookies(loginRes)\n .map(cookie => cookie.split(';')[0])\n .join('; ')\n const loginData = (await loginRes.json()) as OnesLoginResponse\n\n // Pick org user (first one, or match by config option)\n const orgUuid = this.config.options?.orgUuid as string | undefined\n let orgUser = loginData.org_users[0]\n if (orgUuid) {\n const match = loginData.org_users.find(u => u.org_uuid === orgUuid)\n if (match)\n orgUser = match\n }\n\n // 4. PKCE: generate code verifier + challenge\n const codeVerifier = base64Url(crypto.randomBytes(32))\n const codeChallenge = base64Url(\n crypto.createHash('sha256').update(codeVerifier).digest(),\n )\n\n // 5. Authorize\n const authorizeParams = new URLSearchParams({\n client_id: 'ones.v1',\n scope: `openid offline_access ones:org:${orgUser.region_uuid}:${orgUser.org_uuid}:${orgUser.org_user.org_user_uuid}`,\n response_type: 'code',\n code_challenge_method: 'S256',\n code_challenge: codeChallenge,\n redirect_uri: `${baseUrl}/auth/authorize/callback`,\n state: `org_uuid=${orgUser.org_uuid}`,\n })\n\n const authorizeRes = await fetch(`${baseUrl}/identity/authorize`, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/x-www-form-urlencoded',\n 'Cookie': cookies,\n },\n body: authorizeParams.toString(),\n redirect: 'manual',\n })\n\n const authorizeLocation = authorizeRes.headers.get('location')\n if (!authorizeLocation) {\n throw new Error('ONES: Authorize response missing location header')\n }\n const authRequestId = new URL(authorizeLocation).searchParams.get('id')\n if (!authRequestId) {\n throw new Error('ONES: Cannot parse auth_request_id from authorize redirect')\n }\n\n // 6. Finalize auth request\n const finalizeRes = await fetch(`${baseUrl}/identity/api/auth_request/finalize`, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json;charset=UTF-8',\n 'Cookie': cookies,\n },\n body: JSON.stringify({\n auth_request_id: authRequestId,\n region_uuid: orgUser.region_uuid,\n org_uuid: orgUser.org_uuid,\n org_user_uuid: orgUser.org_user.org_user_uuid,\n }),\n })\n if (!finalizeRes.ok) {\n const text = await finalizeRes.text().catch(() => '')\n throw new Error(`ONES: Finalize failed: ${finalizeRes.status} ${text}`)\n }\n\n // 7. Callback to get authorization code\n const callbackRes = await fetch(\n `${baseUrl}/identity/authorize/callback?id=${authRequestId}&lang=zh`,\n {\n method: 'GET',\n headers: { Cookie: cookies },\n redirect: 'manual',\n },\n )\n\n const callbackLocation = callbackRes.headers.get('location')\n if (!callbackLocation) {\n throw new Error('ONES: Callback response missing location header')\n }\n const code = new URL(callbackLocation).searchParams.get('code')\n if (!code) {\n throw new Error('ONES: Cannot parse authorization code from callback redirect')\n }\n\n // 8. Exchange code for token\n const tokenRes = await fetch(`${baseUrl}/identity/oauth/token`, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/x-www-form-urlencoded',\n 'Cookie': cookies,\n },\n body: new URLSearchParams({\n grant_type: 'authorization_code',\n client_id: 'ones.v1',\n code,\n code_verifier: codeVerifier,\n redirect_uri: `${baseUrl}/auth/authorize/callback`,\n }).toString(),\n })\n if (!tokenRes.ok) {\n const text = await tokenRes.text().catch(() => '')\n throw new Error(`ONES: Token exchange failed: ${tokenRes.status} ${text}`)\n }\n\n const token = (await tokenRes.json()) as OnesTokenResponse\n\n // 9. Get teams to find teamUuid\n const teamsRes = await fetch(\n `${baseUrl}/project/api/project/organization/${orgUser.org_uuid}/stamps/data?t=org_my_team`,\n {\n method: 'POST',\n headers: {\n 'Authorization': `Bearer ${token.access_token}`,\n 'Content-Type': 'application/json;charset=UTF-8',\n },\n body: JSON.stringify({ org_my_team: 0 }),\n },\n )\n if (!teamsRes.ok) {\n throw new Error(`ONES: Failed to fetch teams: ${teamsRes.status}`)\n }\n\n const teamsData = (await teamsRes.json()) as {\n org_my_team?: { teams?: Array<{ uuid: string, name: string }> }\n }\n const teams = teamsData.org_my_team?.teams ?? []\n\n // Pick team by config option or default to first\n const configTeamUuid = this.config.options?.teamUuid as string | undefined\n let teamUuid = teams[0]?.uuid\n if (configTeamUuid) {\n const match = teams.find(t => t.uuid === configTeamUuid)\n if (match)\n teamUuid = match.uuid\n }\n\n if (!teamUuid) {\n throw new Error('ONES: No teams found for this user')\n }\n\n this.session = {\n accessToken: token.access_token,\n teamUuid,\n orgUuid: orgUser.org_uuid,\n expiresAt: Date.now() + (token.expires_in - 60) * 1000, // refresh 60s early\n }\n\n return this.session\n }\n\n /**\n * Execute a GraphQL query against ONES project API.\n */\n private async graphql<T>(query: string, variables: Record<string, unknown>, tag?: string): Promise<T> {\n const session = await this.login()\n const url = `${this.config.apiBase}/project/api/project/team/${session.teamUuid}/items/graphql${tag ? `?t=${encodeURIComponent(tag)}` : ''}`\n\n const response = await fetch(url, {\n method: 'POST',\n headers: {\n 'Authorization': `Bearer ${session.accessToken}`,\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify({ query, variables }),\n })\n\n if (!response.ok) {\n const text = await response.text().catch(() => '')\n throw new Error(`ONES GraphQL error: ${response.status} ${text}`)\n }\n\n return response.json() as Promise<T>\n }\n\n /**\n * Fetch task info via REST API (includes description/rich fields not available in GraphQL).\n * Reference: ones/packages/core/src/tasks.ts → fetchTaskInfo\n */\n private async fetchTaskInfo(taskUuid: string): Promise<Record<string, unknown>> {\n const session = await this.login()\n const url = `${this.config.apiBase}/project/api/project/team/${session.teamUuid}/task/${taskUuid}/info`\n\n const response = await fetch(url, {\n headers: { Authorization: `Bearer ${session.accessToken}` },\n })\n\n if (!response.ok) {\n return {}\n }\n\n return response.json() as Promise<Record<string, unknown>>\n }\n\n /**\n * Fetch wiki page content via REST API.\n * Endpoint: /wiki/api/wiki/team/{teamUuid}/online_page/{wikiUuid}/content\n */\n private async fetchWikiContent(wikiUuid: string): Promise<string> {\n const session = await this.login()\n const url = `${this.config.apiBase}/wiki/api/wiki/team/${session.teamUuid}/online_page/${wikiUuid}/content`\n\n const response = await fetch(url, {\n headers: { Authorization: `Bearer ${session.accessToken}` },\n })\n\n if (!response.ok) {\n return ''\n }\n\n const data = await response.json() as { content?: string }\n return data.content ?? ''\n }\n\n /**\n * Fetch a single task by UUID or number (e.g. \"#95945\" or \"95945\").\n * If a number is given, searches first to resolve the UUID.\n */\n async getRequirement(params: GetRequirementParams): Promise<Requirement> {\n let taskUuid = params.id\n\n // If the ID looks like a number (with or without #), search to find the UUID\n const numMatch = taskUuid.match(/^#?(\\d+)$/)\n if (numMatch) {\n const taskNumber = Number.parseInt(numMatch[1], 10)\n const searchData = await this.graphql<{\n data?: { buckets?: Array<{ tasks?: OnesTaskNode[] }> }\n }>(\n TASK_BY_NUMBER_QUERY,\n {\n groupBy: { tasks: {} },\n groupOrderBy: null,\n orderBy: { createTime: 'DESC' },\n filterGroup: [{ number_in: [taskNumber] }],\n search: null,\n pagination: { limit: 10, preciseCount: false },\n limit: 10,\n },\n 'group-task-data',\n )\n\n const allTasks = searchData.data?.buckets?.flatMap(b => b.tasks ?? []) ?? []\n const found = allTasks.find(t => t.number === taskNumber)\n\n if (!found) {\n throw new Error(`ONES: Task #${taskNumber} not found in current team`)\n }\n taskUuid = found.uuid\n }\n\n // Fetch GraphQL data (structure, relations, wiki pages)\n const graphqlData = await this.graphql<{ data?: { task?: OnesTaskNode } }>(\n TASK_DETAIL_QUERY,\n { key: `task-${taskUuid}` },\n 'Task',\n )\n\n const task = graphqlData.data?.task\n if (!task) {\n throw new Error(`ONES: Task \"${taskUuid}\" not found`)\n }\n\n // Fetch wiki page content for related requirement docs (in parallel)\n const wikiPages = task.relatedWikiPages ?? []\n const wikiContents = await Promise.all(\n wikiPages\n .filter(w => !w.errorMessage)\n .map(async (wiki) => {\n const content = await this.fetchWikiContent(wiki.uuid)\n return { title: wiki.title, uuid: wiki.uuid, content }\n }),\n )\n\n // Build description: task info + wiki requirement docs\n const parts: string[] = []\n\n // Task basic info\n parts.push(`# #${task.number} ${task.name}`)\n parts.push('')\n parts.push(`- **Type**: ${task.issueType?.name ?? 'Unknown'}`)\n parts.push(`- **Status**: ${task.status?.name ?? 'Unknown'}`)\n parts.push(`- **Assignee**: ${task.assign?.name ?? 'Unassigned'}`)\n if (task.owner?.name) {\n parts.push(`- **Owner**: ${task.owner.name}`)\n }\n if (task.project?.name) {\n parts.push(`- **Project**: ${task.project.name}`)\n }\n parts.push(`- **UUID**: ${task.uuid}`)\n\n // Related tasks\n if (task.relatedTasks?.length) {\n parts.push('')\n parts.push('## Related Tasks')\n for (const related of task.relatedTasks) {\n parts.push(`- #${related.number} ${related.name} [${related.issueType?.name}] (${related.status?.name})`)\n }\n }\n\n // Parent task\n if (task.parent?.uuid) {\n parts.push('')\n parts.push('## Parent Task')\n parts.push(`- UUID: ${task.parent.uuid}`)\n if (task.parent.number) {\n parts.push(`- Number: #${task.parent.number}`)\n }\n }\n\n // Wiki requirement documents (the core requirement content)\n if (wikiContents.length > 0) {\n parts.push('')\n parts.push('---')\n parts.push('')\n parts.push('## Requirement Documents')\n for (const wiki of wikiContents) {\n parts.push('')\n parts.push(`### ${wiki.title}`)\n parts.push('')\n if (wiki.content) {\n parts.push(wiki.content)\n }\n else {\n parts.push('(No content available)')\n }\n }\n }\n\n const req = toRequirement(task, parts.join('\\n'))\n\n return req\n }\n\n /**\n * Search tasks assigned to current user via GraphQL.\n * Uses keyword-based local filtering (matching ONES reference implementation).\n */\n async searchRequirements(params: SearchRequirementsParams): Promise<SearchResult> {\n const page = params.page ?? 1\n const pageSize = params.pageSize ?? 50\n\n const data = await this.graphql<{\n data?: {\n buckets?: Array<{\n key: string\n tasks?: OnesTaskNode[]\n }>\n }\n }>(\n SEARCH_TASKS_QUERY,\n {\n groupBy: { tasks: {} },\n groupOrderBy: null,\n orderBy: { position: 'ASC', createTime: 'DESC' },\n filterGroup: [\n {\n assign_in: ['${currentUser}'],\n status_notIn: DEFAULT_STATUS_NOT_IN,\n },\n ],\n search: null,\n pagination: { limit: pageSize * page, preciseCount: false },\n limit: 1000,\n },\n 'group-task-data',\n )\n\n let tasks = data.data?.buckets?.flatMap(b => b.tasks ?? []) ?? []\n\n // Local keyword filter (matching ones-api.ts behavior)\n if (params.query) {\n const keyword = params.query\n const lower = keyword.toLowerCase()\n const numMatch = keyword.match(/^#?(\\d+)$/)\n\n if (numMatch) {\n tasks = tasks.filter(t => t.number === Number.parseInt(numMatch[1], 10))\n }\n else {\n tasks = tasks.filter(t => t.name.toLowerCase().includes(lower))\n }\n }\n\n // Paginate locally\n const total = tasks.length\n const start = (page - 1) * pageSize\n const paged = tasks.slice(start, start + pageSize)\n\n return {\n items: paged.map(t => toRequirement(t)),\n total,\n page,\n pageSize,\n }\n }\n}\n","import type { SourceConfig } from '../types/config.js'\nimport type { SourceType } from '../types/requirement.js'\nimport type { BaseAdapter } from './base.js'\nimport { OnesAdapter } from './ones.js'\n\nconst ADAPTER_MAP: Record<string, new (\n sourceType: SourceType,\n config: SourceConfig,\n resolvedAuth: Record<string, string>,\n) => BaseAdapter> = {\n ones: OnesAdapter,\n}\n\n/**\n * Factory function to create the appropriate adapter based on source type.\n */\nexport function createAdapter(\n sourceType: SourceType,\n config: SourceConfig,\n resolvedAuth: Record<string, string>,\n): BaseAdapter {\n const AdapterClass = ADAPTER_MAP[sourceType]\n if (!AdapterClass) {\n throw new Error(\n `Unsupported source type: \"${sourceType}\". Supported: ${Object.keys(ADAPTER_MAP).join(', ')}`,\n )\n }\n return new AdapterClass(sourceType, config, resolvedAuth)\n}\n\nexport { BaseAdapter } from './base.js'\nexport { OnesAdapter } from './ones.js'\n","import type { AuthConfig } from '../types/auth.js'\nimport type { McpConfig, SourceConfig } from '../types/config.js'\nimport type { SourceType } from '../types/requirement.js'\nimport { existsSync, readFileSync } from 'node:fs'\nimport { dirname, resolve } from 'node:path'\nimport { z } from 'zod/v4'\n\nconst AuthSchema = z.discriminatedUnion('type', [\n z.object({\n type: z.literal('token'),\n tokenEnv: z.string(),\n }),\n z.object({\n type: z.literal('basic'),\n usernameEnv: z.string(),\n passwordEnv: z.string(),\n }),\n z.object({\n type: z.literal('oauth2'),\n clientIdEnv: z.string(),\n clientSecretEnv: z.string(),\n tokenUrl: z.string().url(),\n }),\n z.object({\n type: z.literal('cookie'),\n cookieEnv: z.string(),\n }),\n z.object({\n type: z.literal('custom'),\n headerName: z.string(),\n valueEnv: z.string(),\n }),\n z.object({\n type: z.literal('ones-pkce'),\n emailEnv: z.string(),\n passwordEnv: z.string(),\n }),\n])\n\nconst SourceConfigSchema = z.object({\n enabled: z.boolean(),\n apiBase: z.string().url(),\n auth: AuthSchema,\n headers: z.record(z.string(), z.string()).optional(),\n options: z.record(z.string(), z.unknown()).optional(),\n})\n\nconst SourcesSchema = z.object({\n ones: SourceConfigSchema.optional(),\n})\n\nconst McpConfigSchema = z.object({\n sources: SourcesSchema,\n defaultSource: z.enum(['ones']).optional(),\n})\n\nconst CONFIG_FILENAME = '.requirements-mcp.json'\n\n/**\n * Search for config file starting from `startDir` and walking up to the root.\n */\nfunction findConfigFile(startDir: string): string | null {\n let dir = resolve(startDir)\n while (true) {\n const candidate = resolve(dir, CONFIG_FILENAME)\n if (existsSync(candidate)) {\n return candidate\n }\n const parent = dirname(dir)\n if (parent === dir)\n break\n dir = parent\n }\n return null\n}\n\n/**\n * Resolve environment variable references in auth config.\n * Reads actual env var values for fields ending with \"Env\".\n */\nfunction resolveAuthEnv(auth: AuthConfig): Record<string, string> {\n const resolved: Record<string, string> = {}\n\n for (const [key, value] of Object.entries(auth)) {\n if (key === 'type')\n continue\n if (key.endsWith('Env') && typeof value === 'string') {\n const envValue = process.env[value]\n if (!envValue) {\n throw new Error(`Environment variable \"${value}\" is not set (required by auth.${key})`)\n }\n // Strip the \"Env\" suffix for the resolved key\n const resolvedKey = key.slice(0, -3)\n resolved[resolvedKey] = envValue\n }\n else if (typeof value === 'string') {\n resolved[key] = value\n }\n }\n\n return resolved\n}\n\nexport interface ResolvedSource {\n type: SourceType\n config: SourceConfig\n resolvedAuth: Record<string, string>\n}\n\nexport interface LoadConfigResult {\n config: McpConfig\n sources: ResolvedSource[]\n configPath: string\n}\n\n/**\n * Try to build config purely from environment variables.\n * Required env vars: ONES_API_BASE, ONES_ACCOUNT, ONES_PASSWORD\n * Returns null if the required env vars are not all present.\n */\nfunction loadConfigFromEnv(): McpConfig | null {\n const apiBase = process.env.ONES_API_BASE\n const account = process.env.ONES_ACCOUNT\n const password = process.env.ONES_PASSWORD\n\n if (!apiBase || !account || !password) {\n return null\n }\n\n return {\n sources: {\n ones: {\n enabled: true,\n apiBase,\n auth: {\n type: 'ones-pkce',\n emailEnv: 'ONES_ACCOUNT',\n passwordEnv: 'ONES_PASSWORD',\n },\n },\n },\n defaultSource: 'ones',\n }\n}\n\n/**\n * Load and validate the MCP config.\n * Priority: env vars (ONES_API_BASE + ONES_ACCOUNT + ONES_PASSWORD) > config file (.requirements-mcp.json).\n * Searches from `startDir` (defaults to cwd) upward for the file.\n */\nexport function loadConfig(startDir?: string): LoadConfigResult {\n // 1. Try environment variables first (simplest setup for MCP)\n const envConfig = loadConfigFromEnv()\n if (envConfig) {\n const sources: ResolvedSource[] = []\n for (const [type, sourceConfig] of Object.entries(envConfig.sources)) {\n if (sourceConfig && sourceConfig.enabled) {\n const resolvedAuth = resolveAuthEnv(sourceConfig.auth)\n sources.push({\n type: type as SourceType,\n config: sourceConfig,\n resolvedAuth,\n })\n }\n }\n return { config: envConfig, sources, configPath: 'env' }\n }\n\n // 2. Fall back to config file\n const dir = startDir ?? process.cwd()\n const configPath = findConfigFile(dir)\n\n if (!configPath) {\n throw new Error(\n `Config not found. Either set env vars (ONES_API_BASE, ONES_ACCOUNT, ONES_PASSWORD) `\n + `or create \"${CONFIG_FILENAME}\" based on .requirements-mcp.json.example`,\n )\n }\n\n const raw = readFileSync(configPath, 'utf-8')\n let parsed: unknown\n try {\n parsed = JSON.parse(raw)\n }\n catch {\n throw new Error(`Invalid JSON in ${configPath}`)\n }\n\n const result = McpConfigSchema.safeParse(parsed)\n if (!result.success) {\n throw new Error(\n `Invalid config in ${configPath}:\\n${result.error.issues.map(i => ` - ${i.path.join('.')}: ${i.message}`).join('\\n')}`,\n )\n }\n\n const config = result.data as McpConfig\n\n // Resolve enabled sources\n const sources: ResolvedSource[] = []\n for (const [type, sourceConfig] of Object.entries(config.sources)) {\n if (sourceConfig && sourceConfig.enabled) {\n const resolvedAuth = resolveAuthEnv(sourceConfig.auth)\n sources.push({\n type: type as SourceType,\n config: sourceConfig,\n resolvedAuth,\n })\n }\n }\n\n if (sources.length === 0) {\n throw new Error('No enabled sources found in config. Enable at least one source.')\n }\n\n return { config, sources, configPath }\n}\n\nexport { findConfigFile, loadConfigFromEnv, resolveAuthEnv }\n","import type { BaseAdapter } from '../adapters/base.js'\nimport { z } from 'zod/v4'\n\nexport const GetRequirementSchema = z.object({\n id: z.string().describe('The requirement/issue ID'),\n source: z.string().optional().describe('Source to fetch from. If omitted, uses the default source.'),\n})\n\nexport type GetRequirementInput = z.infer<typeof GetRequirementSchema>\n\nexport async function handleGetRequirement(\n input: GetRequirementInput,\n adapters: Map<string, BaseAdapter>,\n defaultSource?: string,\n) {\n const sourceType = input.source ?? defaultSource\n if (!sourceType) {\n throw new Error('No source specified and no default source configured')\n }\n\n const adapter = adapters.get(sourceType)\n if (!adapter) {\n throw new Error(\n `Source \"${sourceType}\" is not configured. Available: ${[...adapters.keys()].join(', ')}`,\n )\n }\n\n const requirement = await adapter.getRequirement({ id: input.id })\n\n return {\n content: [\n {\n type: 'text' as const,\n text: formatRequirement(requirement),\n },\n ],\n }\n}\n\nfunction formatRequirement(req: import('../types/requirement.js').Requirement): string {\n const lines = [\n `# ${req.title}`,\n '',\n `- **ID**: ${req.id}`,\n `- **Source**: ${req.source}`,\n `- **Status**: ${req.status}`,\n `- **Priority**: ${req.priority}`,\n `- **Type**: ${req.type}`,\n `- **Assignee**: ${req.assignee ?? 'Unassigned'}`,\n `- **Reporter**: ${req.reporter || 'Unknown'}`,\n ]\n\n if (req.createdAt) {\n lines.push(`- **Created**: ${req.createdAt}`)\n }\n if (req.updatedAt) {\n lines.push(`- **Updated**: ${req.updatedAt}`)\n }\n\n if (req.dueDate) {\n lines.push(`- **Due**: ${req.dueDate}`)\n }\n\n if (req.labels.length > 0) {\n lines.push(`- **Labels**: ${req.labels.join(', ')}`)\n }\n\n lines.push('', '## Description', '', req.description || '_No description_')\n\n if (req.attachments.length > 0) {\n lines.push('', '## Attachments')\n for (const att of req.attachments) {\n lines.push(`- [${att.name}](${att.url}) (${att.mimeType}, ${att.size} bytes)`)\n }\n }\n\n return lines.join('\\n')\n}\n","import type { BaseAdapter } from '../adapters/base.js'\nimport type { McpConfig } from '../types/config.js'\n\nexport async function handleListSources(\n adapters: Map<string, BaseAdapter>,\n config: McpConfig,\n) {\n const lines = ['# Configured Sources', '']\n\n if (adapters.size === 0) {\n lines.push('No sources configured.')\n return {\n content: [{ type: 'text' as const, text: lines.join('\\n') }],\n }\n }\n\n for (const [type, adapter] of adapters) {\n const isDefault = config.defaultSource === type\n const sourceConfig = config.sources[adapter.sourceType]\n lines.push(`## ${type}${isDefault ? ' (default)' : ''}`)\n lines.push(`- **API Base**: ${sourceConfig?.apiBase ?? 'N/A'}`)\n lines.push(`- **Auth Type**: ${sourceConfig?.auth.type ?? 'N/A'}`)\n lines.push('')\n }\n\n if (config.defaultSource) {\n lines.push(`> Default source: **${config.defaultSource}**`)\n }\n\n return {\n content: [{ type: 'text' as const, text: lines.join('\\n') }],\n }\n}\n","import type { BaseAdapter } from '../adapters/base.js'\nimport { z } from 'zod/v4'\n\nexport const SearchRequirementsSchema = z.object({\n query: z.string().describe('Search keywords'),\n source: z.string().optional().describe('Source to search. If omitted, searches the default source.'),\n page: z.number().int().min(1).optional().describe('Page number (default: 1)'),\n pageSize: z.number().int().min(1).max(50).optional().describe('Results per page (default: 20, max: 50)'),\n})\n\nexport type SearchRequirementsInput = z.infer<typeof SearchRequirementsSchema>\n\nexport async function handleSearchRequirements(\n input: SearchRequirementsInput,\n adapters: Map<string, BaseAdapter>,\n defaultSource?: string,\n) {\n const sourceType = input.source ?? defaultSource\n if (!sourceType) {\n throw new Error('No source specified and no default source configured')\n }\n\n const adapter = adapters.get(sourceType)\n if (!adapter) {\n throw new Error(\n `Source \"${sourceType}\" is not configured. Available: ${[...adapters.keys()].join(', ')}`,\n )\n }\n\n const result = await adapter.searchRequirements({\n query: input.query,\n page: input.page,\n pageSize: input.pageSize,\n })\n\n const lines = [\n `Found **${result.total}** results (page ${result.page}/${Math.ceil(result.total / result.pageSize) || 1}):`,\n '',\n ]\n\n for (const item of result.items) {\n lines.push(`### ${item.id}: ${item.title}`)\n lines.push(`- Status: ${item.status} | Priority: ${item.priority} | Type: ${item.type}`)\n lines.push(`- Assignee: ${item.assignee ?? 'Unassigned'}`)\n if (item.description) {\n const desc = item.description.length > 200\n ? `${item.description.slice(0, 200)}...`\n : item.description\n lines.push(`- ${desc}`)\n }\n lines.push('')\n }\n\n return {\n content: [\n {\n type: 'text' as const,\n text: lines.join('\\n'),\n },\n ],\n }\n}\n","import type { BaseAdapter } from './adapters/index.js'\nimport type { LoadConfigResult } from './config/loader.js'\nimport { existsSync, readFileSync } from 'node:fs'\nimport { dirname, resolve } from 'node:path'\nimport { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'\nimport { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js'\nimport { createAdapter } from './adapters/index.js'\nimport { loadConfig } from './config/loader.js'\nimport { GetRequirementSchema, handleGetRequirement } from './tools/get-requirement.js'\nimport { handleListSources } from './tools/list-sources.js'\nimport { handleSearchRequirements, SearchRequirementsSchema } from './tools/search-requirements.js'\n\n/**\n * Load .env file into process.env (if it exists).\n * Searches from cwd upward, same as config loader.\n */\nfunction loadEnvFile() {\n let dir = process.cwd()\n while (true) {\n const envPath = resolve(dir, '.env')\n if (existsSync(envPath)) {\n const content = readFileSync(envPath, 'utf-8')\n for (const line of content.split('\\n')) {\n const trimmed = line.trim()\n if (!trimmed || trimmed.startsWith('#'))\n continue\n const eqIndex = trimmed.indexOf('=')\n if (eqIndex === -1)\n continue\n const key = trimmed.slice(0, eqIndex).trim()\n let value = trimmed.slice(eqIndex + 1).trim()\n // Strip surrounding quotes\n if ((value.startsWith('\"') && value.endsWith('\"')) || (value.startsWith('\\'') && value.endsWith('\\''))) {\n value = value.slice(1, -1)\n }\n if (!process.env[key]) {\n process.env[key] = value\n }\n }\n return\n }\n const parent = dirname(dir)\n if (parent === dir)\n break\n dir = parent\n }\n}\n\nasync function main() {\n // Load .env before anything else\n loadEnvFile()\n\n // Load config\n let config: LoadConfigResult\n try {\n config = loadConfig()\n }\n catch (err) {\n console.error(`[requirements-mcp] ${(err as Error).message}`)\n process.exit(1)\n }\n\n // Create adapters for enabled sources\n const adapters = new Map<string, BaseAdapter>()\n for (const source of config.sources) {\n const adapter = createAdapter(source.type, source.config, source.resolvedAuth)\n adapters.set(source.type, adapter)\n }\n\n // Create MCP server\n const server = new McpServer({\n name: 'ai-dev-requirements',\n version: '0.1.0',\n })\n\n // Register tools\n server.tool(\n 'get_requirement',\n 'Fetch a single requirement/issue by its ID from a configured source (ONES)',\n GetRequirementSchema.shape,\n async (params) => {\n try {\n return await handleGetRequirement(params, adapters, config.config.defaultSource)\n }\n catch (err) {\n return {\n content: [{ type: 'text', text: `Error: ${(err as Error).message}` }],\n isError: true,\n }\n }\n },\n )\n\n server.tool(\n 'search_requirements',\n 'Search for requirements/issues by keywords across a configured source',\n SearchRequirementsSchema.shape,\n async (params) => {\n try {\n return await handleSearchRequirements(params, adapters, config.config.defaultSource)\n }\n catch (err) {\n return {\n content: [{ type: 'text', text: `Error: ${(err as Error).message}` }],\n isError: true,\n }\n }\n },\n )\n\n server.tool(\n 'list_sources',\n 'List all configured requirement sources and their status',\n {},\n async () => {\n try {\n return await handleListSources(adapters, config.config)\n }\n catch (err) {\n return {\n content: [{ type: 'text', text: `Error: ${(err as Error).message}` }],\n isError: true,\n }\n }\n },\n )\n\n // Start stdio transport\n const transport = new StdioServerTransport()\n await server.connect(transport)\n}\n\nmain().catch((err) => {\n console.error('[requirements-mcp] Fatal error:', err)\n process.exit(1)\n})\n"],"mappings":";;;;;;;;;AAGA,MAAM,kBAAqD;CACzD,OAAO;CACP,aAAa;CACb,MAAM;CACN,QAAQ;CACT;AAGD,MAAM,oBAAyD;CAC7D,QAAQ;CACR,MAAM;CACN,QAAQ;CACR,QAAQ;CACR,KAAK;CACN;AAGD,MAAM,gBAAiD;CACrD,QAAQ;CACR,IAAI;CACJ,MAAM;CACN,IAAI;CACJ,KAAK;CACL,IAAI;CACJ,OAAO;CACP,KAAK;CACL,IAAI;CACJ,MAAM;CACP;AAED,SAAgB,cAAc,QAAmC;AAC/D,QAAO,gBAAgB,OAAO,aAAa,KAAK;;AAGlD,SAAgB,gBAAgB,UAAuC;AACrE,QAAO,kBAAkB,SAAS,aAAa,KAAK;;AAGtD,S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ACV,CAAC;AAGF,QAAO,KACL,mBACA,8EACA,qBAAqB,OACrB,OAAO,WAAW;AAChB,MAAI;AACF,UAAO,MAAM,qBAAqB,QAAQ,UAAU,OAAO,OAAO,cAAc;WAE3E,KAAK;AACV,UAAO;IACL,SAAS,CAAC;KAAE,MAAM;KAAQ,MAAM,UAAW,IAAc;KAAW,CAAC;IACrE,SAAS;IACV;;GAGN;AAED,QAAO,KACL,uBACA,yEACA,yBAAyB,OACzB,OAAO,WAAW;AAChB,MAAI;AACF,UAAO,MAAM,yBAAyB,QAAQ,UAAU,OAAO,OAAO,cAAc;WAE/E,KAAK;AACV,UAAO;IACL,SAAS,CAAC;KAAE,MAAM;KAAQ,MAAM,UAAW,IAAc;KAAW,CAAC;IACrE,SAAS;IACV;;GAGN;AAED,QAAO,KACL,gBACA,4DACA,EAAE,EACF,YAAY;AACV,MAAI;AACF,UAAO,MAAM,kBAAkB,UAAU,OAAO,OAAO;WAElD,KAAK;AACV,UAAO;IACL,SAAS,CAAC;KAAE,MAAM;KAAQ,MAAM,UAAW,IAAc;KAAW,CAAC;IACrE,SAAS;IACV;;GAGN;CAGD,MAAM,YAAY,IAAI,sBAAsB;AAC5C,OAAM,OAAO,QAAQ,UAAU;;AAGjC,MAAM,CAAC,OAAO,QAAQ;AACpB,SAAQ,MAAM,mCAAmC,IAAI;AACrD,SAAQ,KAAK,EAAE;EACf"}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../src/utils/map-status.ts","../src/adapters/base.ts","../src/adapters/ones.ts","../src/adapters/index.ts","../src/config/loader.ts","../src/tools/get-issue-detail.ts","../src/tools/get-related-issues.ts","../src/tools/get-requirement.ts","../src/tools/list-sources.ts","../src/tools/search-requirements.ts","../src/index.ts"],"sourcesContent":["import type { RequirementPriority, RequirementStatus, RequirementType } from '../types/requirement.js'\n\n// --- ONES status mapping ---\nconst ONES_STATUS_MAP: Record<string, RequirementStatus> = {\n to_do: 'open',\n in_progress: 'in_progress',\n done: 'done',\n closed: 'closed',\n}\n\n// --- Priority mappings ---\nconst ONES_PRIORITY_MAP: Record<string, RequirementPriority> = {\n urgent: 'critical',\n high: 'high',\n normal: 'medium',\n medium: 'medium',\n low: 'low',\n}\n\n// --- Type mappings ---\nconst ONES_TYPE_MAP: Record<string, RequirementType> = {\n demand: 'feature',\n 需求: 'feature',\n task: 'task',\n 任务: 'task',\n bug: 'bug',\n 缺陷: 'bug',\n story: 'story',\n 子任务: 'task',\n 工单: 'task',\n 测试任务: 'task',\n}\n\nexport function mapOnesStatus(status: string): RequirementStatus {\n return ONES_STATUS_MAP[status.toLowerCase()] ?? 'open'\n}\n\nexport function mapOnesPriority(priority: string): RequirementPriority {\n return ONES_PRIORITY_MAP[priority.toLowerCase()] ?? 'medium'\n}\n\nexport function mapOnesType(type: string): RequirementType {\n return ONES_TYPE_MAP[type.toLowerCase()] ?? 'task'\n}\n","import type { SourceConfig } from '../types/config.js'\nimport type { IssueDetail, RelatedIssue, Requirement, SearchResult, SourceType } from '../types/requirement.js'\n\nexport interface GetRequirementParams {\n id: string\n}\n\nexport interface SearchRequirementsParams {\n query: string\n page?: number\n pageSize?: number\n}\n\nexport interface GetRelatedIssuesParams {\n taskId: string\n}\n\nexport interface GetIssueDetailParams {\n issueId: string\n}\n\n/**\n * Abstract base class for source adapters.\n * Each adapter implements platform-specific logic for fetching requirements.\n */\nexport abstract class BaseAdapter {\n readonly sourceType: SourceType\n protected readonly config: SourceConfig\n protected readonly resolvedAuth: Record<string, string>\n\n constructor(\n sourceType: SourceType,\n config: SourceConfig,\n resolvedAuth: Record<string, string>,\n ) {\n this.sourceType = sourceType\n this.config = config\n this.resolvedAuth = resolvedAuth\n }\n\n /**\n * Fetch a single requirement by its ID.\n */\n abstract getRequirement(params: GetRequirementParams): Promise<Requirement>\n\n /**\n * Search requirements by query string.\n */\n abstract searchRequirements(params: SearchRequirementsParams): Promise<SearchResult>\n\n abstract getRelatedIssues(params: GetRelatedIssuesParams): Promise<RelatedIssue[]>\n\n abstract getIssueDetail(params: GetIssueDetailParams): Promise<IssueDetail>\n}\n","import type { SourceConfig } from '../types/config.js'\nimport type { IssueDetail, RelatedIssue, Requirement, SearchResult, SourceType } from '../types/requirement.js'\n\nimport type { GetIssueDetailParams, GetRelatedIssuesParams, GetRequirementParams, SearchRequirementsParams } from './base.js'\nimport crypto from 'node:crypto'\nimport { mapOnesPriority, mapOnesStatus, mapOnesType } from '../utils/map-status.js'\nimport { BaseAdapter } from './base.js'\n\n// ============ ONES GraphQL types ============\n\ninterface OnesTaskNode {\n key?: string\n uuid: string\n number: number\n name: string\n status: { uuid: string, name: string, category?: string }\n priority?: { value: string }\n issueType?: { uuid: string, name: string }\n assign?: { uuid: string, name: string } | null\n owner?: { uuid: string, name: string } | null\n project?: { uuid: string, name: string }\n parent?: { uuid: string, number?: number, issueType?: { uuid: string, name: string } } | null\n relatedTasks?: OnesRelatedTask[]\n relatedWikiPages?: OnesWikiPage[]\n relatedWikiPagesCount?: number\n path?: string\n}\n\ninterface OnesWikiPage {\n uuid: string\n title: string\n referenceType?: number\n subReferenceType?: string\n errorMessage?: string\n}\n\ninterface OnesRelatedTask {\n uuid: string\n number: number\n name: string\n issueType: { uuid: string, name: string }\n status: { uuid: string, name: string, category?: string }\n assign?: { uuid: string, name: string } | null\n}\n\ninterface OnesTokenResponse {\n access_token: string\n token_type: string\n expires_in: number\n}\n\ninterface OnesLoginResponse {\n sid: string\n auth_user_uuid: string\n org_users: Array<{\n region_uuid: string\n org_uuid: string\n org_user: { org_user_uuid: string, name: string }\n org: { org_uuid: string, name: string }\n }>\n}\n\ninterface OnesSession {\n accessToken: string\n teamUuid: string\n orgUuid: string\n userUuid: string\n expiresAt: number\n}\n\n// ============ GraphQL queries ============\n\nconst TASK_DETAIL_QUERY = `\n query Task($key: Key) {\n task(key: $key) {\n key uuid number name\n issueType { uuid name }\n status { uuid name category }\n priority { value }\n assign { uuid name }\n owner { uuid name }\n project { uuid name }\n parent { uuid number issueType { uuid name } }\n relatedTasks {\n uuid number name\n issueType { uuid name }\n status { uuid name category }\n assign { uuid name }\n }\n relatedWikiPages {\n uuid\n title\n referenceType\n subReferenceType\n errorMessage\n }\n relatedWikiPagesCount\n }\n }\n`\n\nconst SEARCH_TASKS_QUERY = `\n query GROUP_TASK_DATA($groupBy: GroupBy, $groupOrderBy: OrderBy, $orderBy: OrderBy, $filterGroup: [Filter!], $search: Search, $pagination: Pagination, $limit: Int) {\n buckets(groupBy: $groupBy, orderBy: $groupOrderBy, pagination: $pagination, filter: $search) {\n key\n tasks(filterGroup: $filterGroup, orderBy: $orderBy, limit: $limit, includeAncestors: { pathField: \"path\" }) {\n key uuid number name\n issueType { uuid name }\n status { uuid name category }\n priority { value }\n assign { uuid name }\n project { uuid name }\n }\n }\n }\n`\n\n// Query to find a task by its number\nconst TASK_BY_NUMBER_QUERY = SEARCH_TASKS_QUERY\nconst RELATED_TASKS_QUERY = `\n query Task($key: Key) {\n task(key: $key) {\n key\n relatedTasks {\n key\n uuid\n name\n path\n deadline\n project { uuid name }\n priority { value }\n issueType {\n key uuid name detailType\n }\n subIssueType {\n key uuid name detailType\n }\n status {\n uuid name category\n }\n assign {\n uuid name\n }\n sprint {\n name uuid\n }\n statusCategory\n }\n }\n }\n`\n\nconst ISSUE_DETAIL_QUERY = `\n query Task($key: Key) {\n task(key: $key) {\n key uuid\n description\n descriptionText\n desc_rich: description\n name\n issueType { key uuid name detailType }\n subIssueType { key uuid name detailType }\n status { uuid name category }\n priority { value }\n assign { uuid name }\n owner { uuid name }\n solver { uuid name }\n project { uuid name }\n severityLevel { value }\n deadline(unit: ONESDATE)\n sprint { name uuid }\n }\n }\n`\n\nconst DEFAULT_STATUS_NOT_IN = ['FgMGkcaq', 'NvRwHBSo', 'Dn3k8ffK', 'TbmY2So5']\n\n// ============ Helpers ============\n\nfunction base64Url(buffer: Buffer): string {\n return buffer.toString('base64').replace(/\\+/g, '-').replace(/\\//g, '_').replace(/=+$/g, '')\n}\n\nfunction getSetCookies(response: Response): string[] {\n const headers = response.headers as unknown as { getSetCookie?: () => string[] }\n if (headers.getSetCookie) {\n return headers.getSetCookie()\n }\n const raw = response.headers.get('set-cookie')\n return raw ? [raw] : []\n}\n\nfunction toRequirement(task: OnesTaskNode, description = ''): Requirement {\n return {\n id: task.uuid,\n source: 'ones',\n title: `#${task.number} ${task.name}`,\n description,\n status: mapOnesStatus(task.status?.category ?? 'to_do'),\n priority: mapOnesPriority(task.priority?.value ?? 'normal'),\n type: mapOnesType(task.issueType?.name ?? '任务'),\n labels: [],\n reporter: '',\n assignee: task.assign?.name ?? null,\n // ONES GraphQL does not return timestamps; these are fetch-time placeholders\n createdAt: '',\n updatedAt: '',\n dueDate: null,\n attachments: [],\n raw: task as unknown as Record<string, unknown>,\n }\n}\n\n// ============ ONES Adapter ============\n\nexport class OnesAdapter extends BaseAdapter {\n private session: OnesSession | null = null\n\n constructor(\n sourceType: SourceType,\n config: SourceConfig,\n resolvedAuth: Record<string, string>,\n ) {\n super(sourceType, config, resolvedAuth)\n }\n\n /**\n * ONES OAuth2 PKCE login flow.\n * Reference: D:\\company code\\ones\\packages\\core\\src\\auth.ts\n */\n private async login(): Promise<OnesSession> {\n if (this.session && Date.now() < this.session.expiresAt) {\n return this.session\n }\n\n const baseUrl = this.config.apiBase\n const email = this.resolvedAuth.email\n const password = this.resolvedAuth.password\n\n if (!email || !password) {\n throw new Error('ONES auth requires email and password (ones-pkce auth type)')\n }\n\n // 1. Get encryption certificate\n const certRes = await fetch(`${baseUrl}/identity/api/encryption_cert`, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: '{}',\n })\n if (!certRes.ok) {\n throw new Error(`ONES: Failed to get encryption cert: ${certRes.status}`)\n }\n const cert = (await certRes.json()) as { public_key: string }\n\n // 2. Encrypt password with RSA public key\n const encrypted = crypto.publicEncrypt(\n { key: cert.public_key, padding: crypto.constants.RSA_PKCS1_PADDING },\n Buffer.from(password, 'utf-8'),\n )\n const encryptedPassword = encrypted.toString('base64')\n\n // 3. Login\n const loginRes = await fetch(`${baseUrl}/identity/api/login`, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({ email, password: encryptedPassword }),\n })\n if (!loginRes.ok) {\n const text = await loginRes.text().catch(() => '')\n throw new Error(`ONES: Login failed: ${loginRes.status} ${text}`)\n }\n\n const cookies = getSetCookies(loginRes)\n .map(cookie => cookie.split(';')[0])\n .join('; ')\n const loginData = (await loginRes.json()) as OnesLoginResponse\n\n // Pick org user (first one, or match by config option)\n const orgUuid = this.config.options?.orgUuid as string | undefined\n let orgUser = loginData.org_users[0]\n if (orgUuid) {\n const match = loginData.org_users.find(u => u.org_uuid === orgUuid)\n if (match)\n orgUser = match\n }\n\n // 4. PKCE: generate code verifier + challenge\n const codeVerifier = base64Url(crypto.randomBytes(32))\n const codeChallenge = base64Url(\n crypto.createHash('sha256').update(codeVerifier).digest(),\n )\n\n // 5. Authorize\n const authorizeParams = new URLSearchParams({\n client_id: 'ones.v1',\n scope: `openid offline_access ones:org:${orgUser.region_uuid}:${orgUser.org_uuid}:${orgUser.org_user.org_user_uuid}`,\n response_type: 'code',\n code_challenge_method: 'S256',\n code_challenge: codeChallenge,\n redirect_uri: `${baseUrl}/auth/authorize/callback`,\n state: `org_uuid=${orgUser.org_uuid}`,\n })\n\n const authorizeRes = await fetch(`${baseUrl}/identity/authorize`, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/x-www-form-urlencoded',\n 'Cookie': cookies,\n },\n body: authorizeParams.toString(),\n redirect: 'manual',\n })\n\n const authorizeLocation = authorizeRes.headers.get('location')\n if (!authorizeLocation) {\n throw new Error('ONES: Authorize response missing location header')\n }\n const authRequestId = new URL(authorizeLocation).searchParams.get('id')\n if (!authRequestId) {\n throw new Error('ONES: Cannot parse auth_request_id from authorize redirect')\n }\n\n // 6. Finalize auth request\n const finalizeRes = await fetch(`${baseUrl}/identity/api/auth_request/finalize`, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json;charset=UTF-8',\n 'Cookie': cookies,\n },\n body: JSON.stringify({\n auth_request_id: authRequestId,\n region_uuid: orgUser.region_uuid,\n org_uuid: orgUser.org_uuid,\n org_user_uuid: orgUser.org_user.org_user_uuid,\n }),\n })\n if (!finalizeRes.ok) {\n const text = await finalizeRes.text().catch(() => '')\n throw new Error(`ONES: Finalize failed: ${finalizeRes.status} ${text}`)\n }\n\n // 7. Callback to get authorization code\n const callbackRes = await fetch(\n `${baseUrl}/identity/authorize/callback?id=${authRequestId}&lang=zh`,\n {\n method: 'GET',\n headers: { Cookie: cookies },\n redirect: 'manual',\n },\n )\n\n const callbackLocation = callbackRes.headers.get('location')\n if (!callbackLocation) {\n throw new Error('ONES: Callback response missing location header')\n }\n const code = new URL(callbackLocation).searchParams.get('code')\n if (!code) {\n throw new Error('ONES: Cannot parse authorization code from callback redirect')\n }\n\n // 8. Exchange code for token\n const tokenRes = await fetch(`${baseUrl}/identity/oauth/token`, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/x-www-form-urlencoded',\n 'Cookie': cookies,\n },\n body: new URLSearchParams({\n grant_type: 'authorization_code',\n client_id: 'ones.v1',\n code,\n code_verifier: codeVerifier,\n redirect_uri: `${baseUrl}/auth/authorize/callback`,\n }).toString(),\n })\n if (!tokenRes.ok) {\n const text = await tokenRes.text().catch(() => '')\n throw new Error(`ONES: Token exchange failed: ${tokenRes.status} ${text}`)\n }\n\n const token = (await tokenRes.json()) as OnesTokenResponse\n\n // 9. Get teams to find teamUuid\n const teamsRes = await fetch(\n `${baseUrl}/project/api/project/organization/${orgUser.org_uuid}/stamps/data?t=org_my_team`,\n {\n method: 'POST',\n headers: {\n 'Authorization': `Bearer ${token.access_token}`,\n 'Content-Type': 'application/json;charset=UTF-8',\n },\n body: JSON.stringify({ org_my_team: 0 }),\n },\n )\n if (!teamsRes.ok) {\n throw new Error(`ONES: Failed to fetch teams: ${teamsRes.status}`)\n }\n\n const teamsData = (await teamsRes.json()) as {\n org_my_team?: { teams?: Array<{ uuid: string, name: string }> }\n }\n const teams = teamsData.org_my_team?.teams ?? []\n\n // Pick team by config option or default to first\n const configTeamUuid = this.config.options?.teamUuid as string | undefined\n let teamUuid = teams[0]?.uuid\n if (configTeamUuid) {\n const match = teams.find(t => t.uuid === configTeamUuid)\n if (match)\n teamUuid = match.uuid\n }\n\n if (!teamUuid) {\n throw new Error('ONES: No teams found for this user')\n }\n\n this.session = {\n accessToken: token.access_token,\n teamUuid,\n orgUuid: orgUser.org_uuid,\n userUuid: orgUser.org_user.org_user_uuid,\n expiresAt: Date.now() + (token.expires_in - 60) * 1000, // refresh 60s early\n }\n\n return this.session\n }\n\n /**\n * Execute a GraphQL query against ONES project API.\n */\n private async graphql<T>(query: string, variables: Record<string, unknown>, tag?: string): Promise<T> {\n const session = await this.login()\n const url = `${this.config.apiBase}/project/api/project/team/${session.teamUuid}/items/graphql${tag ? `?t=${encodeURIComponent(tag)}` : ''}`\n\n const response = await fetch(url, {\n method: 'POST',\n headers: {\n 'Authorization': `Bearer ${session.accessToken}`,\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify({ query, variables }),\n })\n\n if (!response.ok) {\n const text = await response.text().catch(() => '')\n throw new Error(`ONES GraphQL error: ${response.status} ${text}`)\n }\n\n return response.json() as Promise<T>\n }\n\n /**\n * Fetch task info via REST API (includes description/rich fields not available in GraphQL).\n * Reference: ones/packages/core/src/tasks.ts → fetchTaskInfo\n */\n private async fetchTaskInfo(taskUuid: string): Promise<Record<string, unknown>> {\n const session = await this.login()\n const url = `${this.config.apiBase}/project/api/project/team/${session.teamUuid}/task/${taskUuid}/info`\n\n const response = await fetch(url, {\n headers: { Authorization: `Bearer ${session.accessToken}` },\n })\n\n if (!response.ok) {\n return {}\n }\n\n return response.json() as Promise<Record<string, unknown>>\n }\n\n /**\n * Resolve a fresh signed URL for an attachment resource via ONES attachment API.\n * Endpoint: /project/api/project/team/{teamUuid}/res/attachment/{resourceUuid}\n * Returns a redirect URL with a fresh OSS signature.\n */\n private async getAttachmentUrl(resourceUuid: string): Promise<string | null> {\n const session = await this.login()\n const url = `${this.config.apiBase}/project/api/project/team/${session.teamUuid}/res/attachment/${resourceUuid}?op=${encodeURIComponent('imageMogr2/auto-orient')}`\n\n try {\n // First try with redirect: 'manual' to capture 302 Location header\n const manualRes = await fetch(url, {\n headers: { Authorization: `Bearer ${session.accessToken}` },\n redirect: 'manual',\n })\n\n if (manualRes.status === 302 || manualRes.status === 301) {\n const location = manualRes.headers.get('location')\n if (location)\n return location\n }\n\n // Fallback: follow redirects and use the final URL\n const followRes = await fetch(url, {\n headers: { Authorization: `Bearer ${session.accessToken}` },\n redirect: 'follow',\n })\n\n // If redirected, response.url will be the final signed URL\n if (followRes.url && followRes.url !== url) {\n return followRes.url\n }\n\n if (followRes.ok) {\n const text = await followRes.text()\n if (text.startsWith('http')) {\n return text.trim()\n }\n try {\n const data = JSON.parse(text) as { url?: string }\n return data.url ?? null\n }\n catch {\n return null\n }\n }\n\n console.error(`[getAttachmentUrl] Failed for resource ${resourceUuid}: status ${followRes.status}`)\n return null\n }\n catch (err) {\n console.error(`[getAttachmentUrl] Error for resource ${resourceUuid}:`, err)\n return null\n }\n }\n\n /**\n * Replace stale image URLs in HTML with fresh signed URLs from the attachment API.\n * Extracts data-uuid from <img> tags and resolves fresh URLs in parallel.\n */\n private async refreshImageUrls(html: string): Promise<string> {\n if (!html)\n return html\n\n // Extract all img tags with data-uuid\n const imgRegex = /<img\\s[^>]*data-uuid=\"([^\"]+)\"[^>]*>/g\n const matches = Array.from(html.matchAll(imgRegex))\n\n if (matches.length === 0)\n return html\n\n // Resolve fresh URLs in parallel\n const replacements = await Promise.all(\n matches.map(async (match) => {\n const dataUuid = match[1]\n const freshUrl = await this.getAttachmentUrl(dataUuid)\n return { fullMatch: match[0], dataUuid, freshUrl }\n }),\n )\n\n let result = html\n for (const { fullMatch, freshUrl } of replacements) {\n if (freshUrl) {\n // Replace the src attribute in the img tag with the fresh URL\n const updatedImg = fullMatch.replace(/src=\"[^\"]*\"/, `src=\"${freshUrl}\"`)\n result = result.replace(fullMatch, updatedImg)\n }\n }\n\n return result\n }\n\n /**\n * Fetch wiki page content via REST API.\n * Endpoint: /wiki/api/wiki/team/{teamUuid}/online_page/{wikiUuid}/content\n */\n private async fetchWikiContent(wikiUuid: string): Promise<string> {\n const session = await this.login()\n const url = `${this.config.apiBase}/wiki/api/wiki/team/${session.teamUuid}/online_page/${wikiUuid}/content`\n\n const response = await fetch(url, {\n headers: { Authorization: `Bearer ${session.accessToken}` },\n })\n\n if (!response.ok) {\n return ''\n }\n\n const data = await response.json() as { content?: string }\n return data.content ?? ''\n }\n\n /**\n * Fetch a single task by UUID or number (e.g. \"#95945\" or \"95945\").\n * If a number is given, searches first to resolve the UUID.\n */\n async getRequirement(params: GetRequirementParams): Promise<Requirement> {\n let taskUuid = params.id\n\n // If the ID looks like a number (with or without #), search to find the UUID\n const numMatch = taskUuid.match(/^#?(\\d+)$/)\n if (numMatch) {\n const taskNumber = Number.parseInt(numMatch[1], 10)\n const searchData = await this.graphql<{\n data?: { buckets?: Array<{ tasks?: OnesTaskNode[] }> }\n }>(\n TASK_BY_NUMBER_QUERY,\n {\n groupBy: { tasks: {} },\n groupOrderBy: null,\n orderBy: { createTime: 'DESC' },\n filterGroup: [{ number_in: [taskNumber] }],\n search: null,\n pagination: { limit: 10, preciseCount: false },\n limit: 10,\n },\n 'group-task-data',\n )\n\n const allTasks = searchData.data?.buckets?.flatMap(b => b.tasks ?? []) ?? []\n const found = allTasks.find(t => t.number === taskNumber)\n\n if (!found) {\n throw new Error(`ONES: Task #${taskNumber} not found in current team`)\n }\n taskUuid = found.uuid\n }\n\n // Fetch GraphQL data (structure, relations, wiki pages)\n const graphqlData = await this.graphql<{ data?: { task?: OnesTaskNode } }>(\n TASK_DETAIL_QUERY,\n { key: `task-${taskUuid}` },\n 'Task',\n )\n\n const task = graphqlData.data?.task\n if (!task) {\n throw new Error(`ONES: Task \"${taskUuid}\" not found`)\n }\n\n // Fetch wiki page content for related requirement docs (in parallel)\n const wikiPages = task.relatedWikiPages ?? []\n const wikiContents = await Promise.all(\n wikiPages\n .filter(w => !w.errorMessage)\n .map(async (wiki) => {\n const content = await this.fetchWikiContent(wiki.uuid)\n return { title: wiki.title, uuid: wiki.uuid, content }\n }),\n )\n\n // Build description: task info + wiki requirement docs\n const parts: string[] = []\n\n // Task basic info\n parts.push(`# #${task.number} ${task.name}`)\n parts.push('')\n parts.push(`- **Type**: ${task.issueType?.name ?? 'Unknown'}`)\n parts.push(`- **Status**: ${task.status?.name ?? 'Unknown'}`)\n parts.push(`- **Assignee**: ${task.assign?.name ?? 'Unassigned'}`)\n if (task.owner?.name) {\n parts.push(`- **Owner**: ${task.owner.name}`)\n }\n if (task.project?.name) {\n parts.push(`- **Project**: ${task.project.name}`)\n }\n parts.push(`- **UUID**: ${task.uuid}`)\n\n // Related tasks\n if (task.relatedTasks?.length) {\n parts.push('')\n parts.push('## Related Tasks')\n for (const related of task.relatedTasks) {\n const assignee = related.assign?.name ?? 'Unassigned'\n parts.push(`- #${related.number} ${related.name} [${related.issueType?.name}] (${related.status?.name}) — ${assignee}`)\n }\n }\n\n // Parent task\n if (task.parent?.uuid) {\n parts.push('')\n parts.push('## Parent Task')\n parts.push(`- UUID: ${task.parent.uuid}`)\n if (task.parent.number) {\n parts.push(`- Number: #${task.parent.number}`)\n }\n }\n\n // Wiki requirement documents (the core requirement content)\n if (wikiContents.length > 0) {\n parts.push('')\n parts.push('---')\n parts.push('')\n parts.push('## Requirement Documents')\n for (const wiki of wikiContents) {\n parts.push('')\n parts.push(`### ${wiki.title}`)\n parts.push('')\n if (wiki.content) {\n parts.push(wiki.content)\n }\n else {\n parts.push('(No content available)')\n }\n }\n }\n\n const req = toRequirement(task, parts.join('\\n'))\n\n return req\n }\n\n /**\n * Search tasks assigned to current user via GraphQL.\n * Uses keyword-based local filtering (matching ONES reference implementation).\n */\n async searchRequirements(params: SearchRequirementsParams): Promise<SearchResult> {\n const page = params.page ?? 1\n const pageSize = params.pageSize ?? 50\n\n const data = await this.graphql<{\n data?: {\n buckets?: Array<{\n key: string\n tasks?: OnesTaskNode[]\n }>\n }\n }>(\n SEARCH_TASKS_QUERY,\n {\n groupBy: { tasks: {} },\n groupOrderBy: null,\n orderBy: { position: 'ASC', createTime: 'DESC' },\n filterGroup: [\n {\n assign_in: ['${currentUser}'],\n status_notIn: DEFAULT_STATUS_NOT_IN,\n },\n ],\n search: null,\n pagination: { limit: pageSize * page, preciseCount: false },\n limit: 1000,\n },\n 'group-task-data',\n )\n\n let tasks = data.data?.buckets?.flatMap(b => b.tasks ?? []) ?? []\n\n // Local keyword filter (matching ones-api.ts behavior)\n if (params.query) {\n const keyword = params.query\n const lower = keyword.toLowerCase()\n const numMatch = keyword.match(/^#?(\\d+)$/)\n\n if (numMatch) {\n tasks = tasks.filter(t => t.number === Number.parseInt(numMatch[1], 10))\n }\n else {\n tasks = tasks.filter(t => t.name.toLowerCase().includes(lower))\n }\n }\n\n // Paginate locally\n const total = tasks.length\n const start = (page - 1) * pageSize\n const paged = tasks.slice(start, start + pageSize)\n\n return {\n items: paged.map(t => toRequirement(t)),\n total,\n page,\n pageSize,\n }\n }\n\n async getRelatedIssues(params: GetRelatedIssuesParams): Promise<RelatedIssue[]> {\n const session = await this.login()\n\n const taskKey = params.taskId.startsWith('task-')\n ? params.taskId\n : `task-${params.taskId}`\n\n const data = await this.graphql<{\n data?: {\n task?: {\n key: string\n relatedTasks: Array<{\n key: string\n uuid: string\n name: string\n issueType: { key: string, uuid: string, name: string, detailType: number }\n subIssueType?: { key: string, uuid: string, name: string, detailType: number } | null\n status: { uuid: string, name: string, category: string }\n assign?: { uuid: string, name: string } | null\n priority?: { value: string } | null\n project?: { uuid: string, name: string } | null\n }>\n }\n }\n }>(RELATED_TASKS_QUERY, { key: taskKey }, 'Task')\n\n const relatedTasks = data.data?.task?.relatedTasks ?? []\n\n // Filter: detailType === 3 (defect) + status.category === \"to_do\" (pending)\n // Returns ALL pending defects, not just current user's\n const filtered = relatedTasks.filter((t) => {\n const isDefect = t.issueType?.detailType === 3\n || t.subIssueType?.detailType === 3\n const isTodo = t.status?.category === 'to_do'\n return isDefect && isTodo\n })\n\n // Sort: current user's defects first\n const currentUserUuid = session.userUuid\n filtered.sort((a, b) => {\n const aIsCurrent = a.assign?.uuid === currentUserUuid ? 0 : 1\n const bIsCurrent = b.assign?.uuid === currentUserUuid ? 0 : 1\n return aIsCurrent - bIsCurrent\n })\n\n return filtered.map(t => ({\n key: t.key,\n uuid: t.uuid,\n name: t.name,\n issueTypeName: t.issueType?.name ?? 'Unknown',\n statusName: t.status?.name ?? 'Unknown',\n statusCategory: t.status?.category ?? 'unknown',\n assignName: t.assign?.name ?? null,\n assignUuid: t.assign?.uuid ?? null,\n priorityValue: t.priority?.value ?? null,\n projectName: t.project?.name ?? null,\n }))\n }\n\n async getIssueDetail(params: GetIssueDetailParams): Promise<IssueDetail> {\n let issueKey: string\n\n // Support number lookup (e.g. \"98086\" or \"#98086\")\n const numMatch = params.issueId.match(/^#?(\\d+)$/)\n if (numMatch) {\n const taskNumber = Number.parseInt(numMatch[1], 10)\n const searchData = await this.graphql<{\n data?: { buckets?: Array<{ tasks?: Array<{ uuid: string, number: number }> }> }\n }>(\n SEARCH_TASKS_QUERY,\n {\n groupBy: { tasks: {} },\n groupOrderBy: null,\n orderBy: { createTime: 'DESC' },\n filterGroup: [{ number_in: [taskNumber] }],\n search: null,\n pagination: { limit: 10, preciseCount: false },\n limit: 10,\n },\n 'group-task-data',\n )\n\n const allTasks = searchData.data?.buckets?.flatMap(b => b.tasks ?? []) ?? []\n const found = allTasks.find(t => t.number === taskNumber)\n if (!found) {\n throw new Error(`ONES: Issue #${taskNumber} not found in current team`)\n }\n issueKey = `task-${found.uuid}`\n }\n else {\n issueKey = params.issueId.startsWith('task-')\n ? params.issueId\n : `task-${params.issueId}`\n }\n\n const data = await this.graphql<{\n data?: {\n task?: {\n key: string\n uuid: string\n name: string\n description: string\n descriptionText: string\n desc_rich: string\n issueType: { name: string }\n status: { name: string, category: string }\n priority?: { value: string } | null\n assign?: { uuid: string, name: string } | null\n owner?: { uuid: string, name: string } | null\n solver?: { uuid: string, name: string } | null\n project?: { uuid: string, name: string } | null\n severityLevel?: { value: string } | null\n deadline?: string | null\n sprint?: { name: string } | null\n }\n }\n }>(ISSUE_DETAIL_QUERY, { key: issueKey }, 'Task')\n\n const task = data.data?.task\n if (!task) {\n throw new Error(`ONES: Issue \"${issueKey}\" not found`)\n }\n\n // Fetch fresh description via REST API\n const taskInfo = await this.fetchTaskInfo(task.uuid)\n const rawDescription = (taskInfo.desc as string) ?? task.description ?? ''\n const rawDescRich = (taskInfo.desc_rich as string) ?? task.desc_rich ?? ''\n\n // Refresh image URLs via attachment API (signed URLs expire after 1 hour)\n const freshDescription = await this.refreshImageUrls(rawDescription)\n const freshDescRich = await this.refreshImageUrls(rawDescRich)\n\n return {\n key: task.key,\n uuid: task.uuid,\n name: task.name,\n description: freshDescription,\n descriptionRich: freshDescRich,\n descriptionText: task.descriptionText ?? '',\n issueTypeName: task.issueType?.name ?? 'Unknown',\n statusName: task.status?.name ?? 'Unknown',\n statusCategory: task.status?.category ?? 'unknown',\n assignName: task.assign?.name ?? null,\n ownerName: task.owner?.name ?? null,\n solverName: task.solver?.name ?? null,\n priorityValue: task.priority?.value ?? null,\n severityLevel: task.severityLevel?.value ?? null,\n projectName: task.project?.name ?? null,\n deadline: task.deadline ?? null,\n sprintName: task.sprint?.name ?? null,\n raw: task as unknown as Record<string, unknown>,\n }\n }\n}\n","import type { SourceConfig } from '../types/config.js'\nimport type { SourceType } from '../types/requirement.js'\nimport type { BaseAdapter } from './base.js'\nimport { OnesAdapter } from './ones.js'\n\nconst ADAPTER_MAP: Record<string, new (\n sourceType: SourceType,\n config: SourceConfig,\n resolvedAuth: Record<string, string>,\n) => BaseAdapter> = {\n ones: OnesAdapter,\n}\n\n/**\n * Factory function to create the appropriate adapter based on source type.\n */\nexport function createAdapter(\n sourceType: SourceType,\n config: SourceConfig,\n resolvedAuth: Record<string, string>,\n): BaseAdapter {\n const AdapterClass = ADAPTER_MAP[sourceType]\n if (!AdapterClass) {\n throw new Error(\n `Unsupported source type: \"${sourceType}\". Supported: ${Object.keys(ADAPTER_MAP).join(', ')}`,\n )\n }\n return new AdapterClass(sourceType, config, resolvedAuth)\n}\n\nexport { BaseAdapter } from './base.js'\nexport { OnesAdapter } from './ones.js'\n","import type { AuthConfig } from '../types/auth.js'\nimport type { McpConfig, SourceConfig } from '../types/config.js'\nimport type { SourceType } from '../types/requirement.js'\nimport { existsSync, readFileSync } from 'node:fs'\nimport { dirname, resolve } from 'node:path'\nimport { z } from 'zod/v4'\n\nconst AuthSchema = z.discriminatedUnion('type', [\n z.object({\n type: z.literal('token'),\n tokenEnv: z.string(),\n }),\n z.object({\n type: z.literal('basic'),\n usernameEnv: z.string(),\n passwordEnv: z.string(),\n }),\n z.object({\n type: z.literal('oauth2'),\n clientIdEnv: z.string(),\n clientSecretEnv: z.string(),\n tokenUrl: z.string().url(),\n }),\n z.object({\n type: z.literal('cookie'),\n cookieEnv: z.string(),\n }),\n z.object({\n type: z.literal('custom'),\n headerName: z.string(),\n valueEnv: z.string(),\n }),\n z.object({\n type: z.literal('ones-pkce'),\n emailEnv: z.string(),\n passwordEnv: z.string(),\n }),\n])\n\nconst SourceConfigSchema = z.object({\n enabled: z.boolean(),\n apiBase: z.string().url(),\n auth: AuthSchema,\n headers: z.record(z.string(), z.string()).optional(),\n options: z.record(z.string(), z.unknown()).optional(),\n})\n\nconst SourcesSchema = z.object({\n ones: SourceConfigSchema.optional(),\n})\n\nconst McpConfigSchema = z.object({\n sources: SourcesSchema,\n defaultSource: z.enum(['ones']).optional(),\n})\n\nconst CONFIG_FILENAME = '.requirements-mcp.json'\n\n/**\n * Search for config file starting from `startDir` and walking up to the root.\n */\nfunction findConfigFile(startDir: string): string | null {\n let dir = resolve(startDir)\n while (true) {\n const candidate = resolve(dir, CONFIG_FILENAME)\n if (existsSync(candidate)) {\n return candidate\n }\n const parent = dirname(dir)\n if (parent === dir)\n break\n dir = parent\n }\n return null\n}\n\n/**\n * Resolve environment variable references in auth config.\n * Reads actual env var values for fields ending with \"Env\".\n */\nfunction resolveAuthEnv(auth: AuthConfig): Record<string, string> {\n const resolved: Record<string, string> = {}\n\n for (const [key, value] of Object.entries(auth)) {\n if (key === 'type')\n continue\n if (key.endsWith('Env') && typeof value === 'string') {\n const envValue = process.env[value]\n if (!envValue) {\n throw new Error(`Environment variable \"${value}\" is not set (required by auth.${key})`)\n }\n // Strip the \"Env\" suffix for the resolved key\n const resolvedKey = key.slice(0, -3)\n resolved[resolvedKey] = envValue\n }\n else if (typeof value === 'string') {\n resolved[key] = value\n }\n }\n\n return resolved\n}\n\nexport interface ResolvedSource {\n type: SourceType\n config: SourceConfig\n resolvedAuth: Record<string, string>\n}\n\nexport interface LoadConfigResult {\n config: McpConfig\n sources: ResolvedSource[]\n configPath: string\n}\n\n/**\n * Try to build config purely from environment variables.\n * Required env vars: ONES_API_BASE, ONES_ACCOUNT, ONES_PASSWORD\n * Returns null if the required env vars are not all present.\n */\nfunction loadConfigFromEnv(): McpConfig | null {\n const apiBase = process.env.ONES_API_BASE\n const account = process.env.ONES_ACCOUNT\n const password = process.env.ONES_PASSWORD\n\n if (!apiBase || !account || !password) {\n return null\n }\n\n return {\n sources: {\n ones: {\n enabled: true,\n apiBase,\n auth: {\n type: 'ones-pkce',\n emailEnv: 'ONES_ACCOUNT',\n passwordEnv: 'ONES_PASSWORD',\n },\n },\n },\n defaultSource: 'ones',\n }\n}\n\n/**\n * Load and validate the MCP config.\n * Priority: env vars (ONES_API_BASE + ONES_ACCOUNT + ONES_PASSWORD) > config file (.requirements-mcp.json).\n * Searches from `startDir` (defaults to cwd) upward for the file.\n */\nexport function loadConfig(startDir?: string): LoadConfigResult {\n // 1. Try environment variables first (simplest setup for MCP)\n const envConfig = loadConfigFromEnv()\n if (envConfig) {\n const sources: ResolvedSource[] = []\n for (const [type, sourceConfig] of Object.entries(envConfig.sources)) {\n if (sourceConfig && sourceConfig.enabled) {\n const resolvedAuth = resolveAuthEnv(sourceConfig.auth)\n sources.push({\n type: type as SourceType,\n config: sourceConfig,\n resolvedAuth,\n })\n }\n }\n return { config: envConfig, sources, configPath: 'env' }\n }\n\n // 2. Fall back to config file\n const dir = startDir ?? process.cwd()\n const configPath = findConfigFile(dir)\n\n if (!configPath) {\n throw new Error(\n `Config not found. Either set env vars (ONES_API_BASE, ONES_ACCOUNT, ONES_PASSWORD) `\n + `or create \"${CONFIG_FILENAME}\" based on .requirements-mcp.json.example`,\n )\n }\n\n const raw = readFileSync(configPath, 'utf-8')\n let parsed: unknown\n try {\n parsed = JSON.parse(raw)\n }\n catch {\n throw new Error(`Invalid JSON in ${configPath}`)\n }\n\n const result = McpConfigSchema.safeParse(parsed)\n if (!result.success) {\n throw new Error(\n `Invalid config in ${configPath}:\\n${result.error.issues.map(i => ` - ${i.path.join('.')}: ${i.message}`).join('\\n')}`,\n )\n }\n\n const config = result.data as McpConfig\n\n // Resolve enabled sources\n const sources: ResolvedSource[] = []\n for (const [type, sourceConfig] of Object.entries(config.sources)) {\n if (sourceConfig && sourceConfig.enabled) {\n const resolvedAuth = resolveAuthEnv(sourceConfig.auth)\n sources.push({\n type: type as SourceType,\n config: sourceConfig,\n resolvedAuth,\n })\n }\n }\n\n if (sources.length === 0) {\n throw new Error('No enabled sources found in config. Enable at least one source.')\n }\n\n return { config, sources, configPath }\n}\n\nexport { findConfigFile, loadConfigFromEnv, resolveAuthEnv }\n","import type { BaseAdapter } from '../adapters/base.js'\nimport type { IssueDetail } from '../types/requirement.js'\nimport { z } from 'zod/v4'\n\nexport const GetIssueDetailSchema = z.object({\n issueId: z.string().describe('The issue task ID or key (e.g. \"6W9vW3y8J9DO66Pu\" or \"task-6W9vW3y8J9DO66Pu\")'),\n source: z.string().optional().describe('Source to fetch from. If omitted, uses the default source.'),\n})\n\nexport type GetIssueDetailInput = z.infer<typeof GetIssueDetailSchema>\n\n/**\n * Download an image from URL and return as base64 data URI.\n * Returns null if download fails.\n */\nasync function downloadImageAsBase64(url: string): Promise<{ base64: string, mimeType: string } | null> {\n try {\n const res = await fetch(url, { redirect: 'follow' })\n if (!res.ok)\n return null\n\n const contentType = res.headers.get('content-type') ?? 'image/png'\n const mimeType = contentType.split(';')[0].trim()\n const buffer = Buffer.from(await res.arrayBuffer())\n return { base64: buffer.toString('base64'), mimeType }\n }\n catch {\n return null\n }\n}\n\n/**\n * Extract image URLs from HTML string.\n */\nfunction extractImageUrls(html: string): string[] {\n const imgRegex = /<img[^>]+src=\"([^\"]+)\"[^>]*>/g\n return Array.from(html.matchAll(imgRegex), m => m[1])\n .map(url => url.replace(/&/g, '&'))\n}\n\nexport async function handleGetIssueDetail(\n input: GetIssueDetailInput,\n adapters: Map<string, BaseAdapter>,\n defaultSource?: string,\n) {\n const sourceType = input.source ?? defaultSource\n if (!sourceType) {\n throw new Error('No source specified and no default source configured')\n }\n\n const adapter = adapters.get(sourceType)\n if (!adapter) {\n throw new Error(\n `Source \"${sourceType}\" is not configured. Available: ${[...adapters.keys()].join(', ')}`,\n )\n }\n\n const detail = await adapter.getIssueDetail({ issueId: input.issueId })\n\n // Extract and download images from description\n const imageUrls = detail.descriptionRich ? extractImageUrls(detail.descriptionRich) : []\n const imageResults = await Promise.all(imageUrls.map(url => downloadImageAsBase64(url)))\n\n // Build MCP content: text first, then embedded images\n const content: Array<{ type: 'text', text: string } | { type: 'image', data: string, mimeType: string }> = [\n { type: 'text' as const, text: formatIssueDetail(detail) },\n ]\n\n for (let i = 0; i < imageResults.length; i++) {\n const img = imageResults[i]\n if (img) {\n content.push({\n type: 'image' as const,\n data: img.base64,\n mimeType: img.mimeType,\n })\n }\n }\n\n return { content }\n}\n\nfunction formatIssueDetail(detail: IssueDetail): string {\n const lines = [\n `# ${detail.name}`,\n '',\n `- **Key**: ${detail.key}`,\n `- **UUID**: ${detail.uuid}`,\n `- **Type**: ${detail.issueTypeName}`,\n `- **Status**: ${detail.statusName} (${detail.statusCategory})`,\n `- **Priority**: ${detail.priorityValue ?? 'N/A'}`,\n `- **Severity**: ${detail.severityLevel ?? 'N/A'}`,\n `- **Assignee**: ${detail.assignName ?? 'Unassigned'}`,\n `- **Owner**: ${detail.ownerName ?? 'Unknown'}`,\n `- **Solver**: ${detail.solverName ?? 'Unassigned'}`,\n ]\n\n if (detail.projectName)\n lines.push(`- **Project**: ${detail.projectName}`)\n if (detail.sprintName)\n lines.push(`- **Sprint**: ${detail.sprintName}`)\n if (detail.deadline)\n lines.push(`- **Deadline**: ${detail.deadline}`)\n\n lines.push('', '## Description', '')\n if (detail.descriptionRich) {\n lines.push(detail.descriptionRich)\n }\n else if (detail.descriptionText) {\n lines.push(detail.descriptionText)\n }\n else {\n lines.push('_No description_')\n }\n\n return lines.join('\\n')\n}\n","import type { BaseAdapter } from '../adapters/base.js'\nimport type { RelatedIssue } from '../types/requirement.js'\nimport { z } from 'zod/v4'\n\nexport const GetRelatedIssuesSchema = z.object({\n taskId: z.string().describe('The parent task ID or key (e.g. \"HRL2p8rTX4mQ9xMv\" or \"task-HRL2p8rTX4mQ9xMv\")'),\n source: z.string().optional().describe('Source to fetch from. If omitted, uses the default source.'),\n})\n\nexport type GetRelatedIssuesInput = z.infer<typeof GetRelatedIssuesSchema>\n\nexport async function handleGetRelatedIssues(\n input: GetRelatedIssuesInput,\n adapters: Map<string, BaseAdapter>,\n defaultSource?: string,\n) {\n const sourceType = input.source ?? defaultSource\n if (!sourceType) {\n throw new Error('No source specified and no default source configured')\n }\n\n const adapter = adapters.get(sourceType)\n if (!adapter) {\n throw new Error(\n `Source \"${sourceType}\" is not configured. Available: ${[...adapters.keys()].join(', ')}`,\n )\n }\n\n const issues = await adapter.getRelatedIssues({ taskId: input.taskId })\n\n return {\n content: [{ type: 'text' as const, text: formatRelatedIssues(issues) }],\n }\n}\n\nfunction formatRelatedIssues(issues: RelatedIssue[]): string {\n const lines = [\n `Found **${issues.length}** pending defects:`,\n '',\n ]\n\n if (issues.length === 0) {\n lines.push('No pending defects found for this task.')\n return lines.join('\\n')\n }\n\n // Group by assignee name\n const grouped = new Map<string, RelatedIssue[]>()\n for (const issue of issues) {\n const assignee = issue.assignName ?? 'Unassigned'\n if (!grouped.has(assignee))\n grouped.set(assignee, [])\n grouped.get(assignee)!.push(issue)\n }\n\n for (const [assignee, group] of grouped) {\n lines.push(`## ${assignee} (${group.length})`)\n lines.push('')\n for (const issue of group) {\n lines.push(`### ${issue.key}: ${issue.name}`)\n lines.push(`- Status: ${issue.statusName} | Priority: ${issue.priorityValue ?? 'N/A'}`)\n if (issue.projectName) {\n lines.push(`- Project: ${issue.projectName}`)\n }\n lines.push('')\n }\n }\n\n return lines.join('\\n')\n}\n","import type { BaseAdapter } from '../adapters/base.js'\nimport { z } from 'zod/v4'\n\nexport const GetRequirementSchema = z.object({\n id: z.string().describe('The requirement/issue ID'),\n source: z.string().optional().describe('Source to fetch from. If omitted, uses the default source.'),\n})\n\nexport type GetRequirementInput = z.infer<typeof GetRequirementSchema>\n\nexport async function handleGetRequirement(\n input: GetRequirementInput,\n adapters: Map<string, BaseAdapter>,\n defaultSource?: string,\n) {\n const sourceType = input.source ?? defaultSource\n if (!sourceType) {\n throw new Error('No source specified and no default source configured')\n }\n\n const adapter = adapters.get(sourceType)\n if (!adapter) {\n throw new Error(\n `Source \"${sourceType}\" is not configured. Available: ${[...adapters.keys()].join(', ')}`,\n )\n }\n\n const requirement = await adapter.getRequirement({ id: input.id })\n\n return {\n content: [\n {\n type: 'text' as const,\n text: formatRequirement(requirement),\n },\n ],\n }\n}\n\nfunction formatRequirement(req: import('../types/requirement.js').Requirement): string {\n const lines = [\n `# ${req.title}`,\n '',\n `- **ID**: ${req.id}`,\n `- **Source**: ${req.source}`,\n `- **Status**: ${req.status}`,\n `- **Priority**: ${req.priority}`,\n `- **Type**: ${req.type}`,\n `- **Assignee**: ${req.assignee ?? 'Unassigned'}`,\n `- **Reporter**: ${req.reporter || 'Unknown'}`,\n ]\n\n if (req.createdAt) {\n lines.push(`- **Created**: ${req.createdAt}`)\n }\n if (req.updatedAt) {\n lines.push(`- **Updated**: ${req.updatedAt}`)\n }\n\n if (req.dueDate) {\n lines.push(`- **Due**: ${req.dueDate}`)\n }\n\n if (req.labels.length > 0) {\n lines.push(`- **Labels**: ${req.labels.join(', ')}`)\n }\n\n lines.push('', '## Description', '', req.description || '_No description_')\n\n if (req.attachments.length > 0) {\n lines.push('', '## Attachments')\n for (const att of req.attachments) {\n lines.push(`- [${att.name}](${att.url}) (${att.mimeType}, ${att.size} bytes)`)\n }\n }\n\n return lines.join('\\n')\n}\n","import type { BaseAdapter } from '../adapters/base.js'\nimport type { McpConfig } from '../types/config.js'\n\nexport async function handleListSources(\n adapters: Map<string, BaseAdapter>,\n config: McpConfig,\n) {\n const lines = ['# Configured Sources', '']\n\n if (adapters.size === 0) {\n lines.push('No sources configured.')\n return {\n content: [{ type: 'text' as const, text: lines.join('\\n') }],\n }\n }\n\n for (const [type, adapter] of adapters) {\n const isDefault = config.defaultSource === type\n const sourceConfig = config.sources[adapter.sourceType]\n lines.push(`## ${type}${isDefault ? ' (default)' : ''}`)\n lines.push(`- **API Base**: ${sourceConfig?.apiBase ?? 'N/A'}`)\n lines.push(`- **Auth Type**: ${sourceConfig?.auth.type ?? 'N/A'}`)\n lines.push('')\n }\n\n if (config.defaultSource) {\n lines.push(`> Default source: **${config.defaultSource}**`)\n }\n\n return {\n content: [{ type: 'text' as const, text: lines.join('\\n') }],\n }\n}\n","import type { BaseAdapter } from '../adapters/base.js'\nimport { z } from 'zod/v4'\n\nexport const SearchRequirementsSchema = z.object({\n query: z.string().describe('Search keywords'),\n source: z.string().optional().describe('Source to search. If omitted, searches the default source.'),\n page: z.number().int().min(1).optional().describe('Page number (default: 1)'),\n pageSize: z.number().int().min(1).max(50).optional().describe('Results per page (default: 20, max: 50)'),\n})\n\nexport type SearchRequirementsInput = z.infer<typeof SearchRequirementsSchema>\n\nexport async function handleSearchRequirements(\n input: SearchRequirementsInput,\n adapters: Map<string, BaseAdapter>,\n defaultSource?: string,\n) {\n const sourceType = input.source ?? defaultSource\n if (!sourceType) {\n throw new Error('No source specified and no default source configured')\n }\n\n const adapter = adapters.get(sourceType)\n if (!adapter) {\n throw new Error(\n `Source \"${sourceType}\" is not configured. Available: ${[...adapters.keys()].join(', ')}`,\n )\n }\n\n const result = await adapter.searchRequirements({\n query: input.query,\n page: input.page,\n pageSize: input.pageSize,\n })\n\n const lines = [\n `Found **${result.total}** results (page ${result.page}/${Math.ceil(result.total / result.pageSize) || 1}):`,\n '',\n ]\n\n for (const item of result.items) {\n lines.push(`### ${item.id}: ${item.title}`)\n lines.push(`- Status: ${item.status} | Priority: ${item.priority} | Type: ${item.type}`)\n lines.push(`- Assignee: ${item.assignee ?? 'Unassigned'}`)\n if (item.description) {\n const desc = item.description.length > 200\n ? `${item.description.slice(0, 200)}...`\n : item.description\n lines.push(`- ${desc}`)\n }\n lines.push('')\n }\n\n return {\n content: [\n {\n type: 'text' as const,\n text: lines.join('\\n'),\n },\n ],\n }\n}\n","import type { BaseAdapter } from './adapters/index.js'\nimport type { LoadConfigResult } from './config/loader.js'\nimport { existsSync, readFileSync } from 'node:fs'\nimport { dirname, resolve } from 'node:path'\nimport { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'\nimport { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js'\nimport { createAdapter } from './adapters/index.js'\nimport { loadConfig } from './config/loader.js'\nimport { GetIssueDetailSchema, handleGetIssueDetail } from './tools/get-issue-detail.js'\nimport { GetRelatedIssuesSchema, handleGetRelatedIssues } from './tools/get-related-issues.js'\nimport { GetRequirementSchema, handleGetRequirement } from './tools/get-requirement.js'\nimport { handleListSources } from './tools/list-sources.js'\nimport { handleSearchRequirements, SearchRequirementsSchema } from './tools/search-requirements.js'\n\n/**\n * Load .env file into process.env (if it exists).\n * Searches from cwd upward, same as config loader.\n */\nfunction loadEnvFile() {\n let dir = process.cwd()\n while (true) {\n const envPath = resolve(dir, '.env')\n if (existsSync(envPath)) {\n const content = readFileSync(envPath, 'utf-8')\n for (const line of content.split('\\n')) {\n const trimmed = line.trim()\n if (!trimmed || trimmed.startsWith('#'))\n continue\n const eqIndex = trimmed.indexOf('=')\n if (eqIndex === -1)\n continue\n const key = trimmed.slice(0, eqIndex).trim()\n let value = trimmed.slice(eqIndex + 1).trim()\n // Strip surrounding quotes\n if ((value.startsWith('\"') && value.endsWith('\"')) || (value.startsWith('\\'') && value.endsWith('\\''))) {\n value = value.slice(1, -1)\n }\n if (!process.env[key]) {\n process.env[key] = value\n }\n }\n return\n }\n const parent = dirname(dir)\n if (parent === dir)\n break\n dir = parent\n }\n}\n\nasync function main() {\n // Load .env before anything else\n loadEnvFile()\n\n // Load config\n let config: LoadConfigResult\n try {\n config = loadConfig()\n }\n catch (err) {\n console.error(`[requirements-mcp] ${(err as Error).message}`)\n process.exit(1)\n }\n\n // Create adapters for enabled sources\n const adapters = new Map<string, BaseAdapter>()\n for (const source of config.sources) {\n const adapter = createAdapter(source.type, source.config, source.resolvedAuth)\n adapters.set(source.type, adapter)\n }\n\n // Create MCP server\n const server = new McpServer({\n name: 'ai-dev-requirements',\n version: '0.1.0',\n })\n\n // Register tools\n server.tool(\n 'get_requirement',\n 'Fetch a single requirement/issue by its ID from a configured source (ONES)',\n GetRequirementSchema.shape,\n async (params) => {\n try {\n return await handleGetRequirement(params, adapters, config.config.defaultSource)\n }\n catch (err) {\n return {\n content: [{ type: 'text', text: `Error: ${(err as Error).message}` }],\n isError: true,\n }\n }\n },\n )\n\n server.tool(\n 'search_requirements',\n 'Search for requirements/issues by keywords across a configured source',\n SearchRequirementsSchema.shape,\n async (params) => {\n try {\n return await handleSearchRequirements(params, adapters, config.config.defaultSource)\n }\n catch (err) {\n return {\n content: [{ type: 'text', text: `Error: ${(err as Error).message}` }],\n isError: true,\n }\n }\n },\n )\n\n server.tool(\n 'list_sources',\n 'List all configured requirement sources and their status',\n {},\n async () => {\n try {\n return await handleListSources(adapters, config.config)\n }\n catch (err) {\n return {\n content: [{ type: 'text', text: `Error: ${(err as Error).message}` }],\n isError: true,\n }\n }\n },\n )\n\n server.tool(\n 'get_related_issues',\n 'Get pending defect issues (bugs) related to a requirement task. Returns all pending defects grouped by assignee (current user first).',\n GetRelatedIssuesSchema.shape,\n async (params) => {\n try {\n return await handleGetRelatedIssues(params, adapters, config.config.defaultSource)\n }\n catch (err) {\n return {\n content: [{ type: 'text', text: `Error: ${(err as Error).message}` }],\n isError: true,\n }\n }\n },\n )\n\n server.tool(\n 'get_issue_detail',\n 'Get detailed information about a specific issue/defect including description, rich text, and images',\n GetIssueDetailSchema.shape,\n async (params) => {\n try {\n return await handleGetIssueDetail(params, adapters, config.config.defaultSource)\n }\n catch (err) {\n return {\n content: [{ type: 'text', text: `Error: ${(err as Error).message}` }],\n isError: true,\n }\n }\n },\n )\n\n // Start stdio transport\n const transport = new StdioServerTransport()\n await server.connect(transport)\n}\n\nmain().catch((err) => {\n console.error('[requirements-mcp] Fatal error:', err)\n process.exit(1)\n})\n"],"mappings":";;;;;;;;;AAGA,MAAM,kBAAqD;CACzD,OAAO;CACP,aAAa;CACb,MAAM;CACN,QAAQ;CACT;AAGD,MAAM,oBAAyD;CAC7D,QAAQ;CACR,MAAM;CACN,QAAQ;CACR,QAAQ;CACR,KAAK;CACN;AAGD,MAAM,gBAAiD;CACrD,QAAQ;CACR,IAAI;CACJ,MAAM;CACN,IAAI;CACJ,KAAK;CACL,IAAI;CACJ,OAAO;CACP,KAAK;CACL,IAAI;CACJ,MAAM;CACP;AAED,SAAgB,cAAc,QAAmC;AAC/D,QAAO,gBAAgB,OAAO,aAAa,KAAK;;AAGlD,SAAgB,gBAAgB,UAAuC;AACrE,QAAO,kBAAkB,SAAS,aAAa,KAAK;;AAGtD,SAAgB,YAAY,MAA+B;AACzD,QAAO,cAAc,KAAK,aAAa,KAAK;;;;;;;;;ACjB9C,IAAsB,cAAtB,MAAkC;CAChC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C,IAAI;AACrD,SAAQ,KAAK,EAAE;EACf"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ai-dev-requirements",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.7",
|
|
4
4
|
"packageManager": "pnpm@10.28.1",
|
|
5
5
|
"description": "MCP server for fetching requirements from ONES, bundled with a parallel task framework for AI-assisted development",
|
|
6
6
|
"type": "module",
|