ai-dev-requirements 0.1.3 → 0.1.5

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 CHANGED
@@ -1,4 +1,4 @@
1
-
1
+ #!/usr/bin/env node
2
2
  //#region \0rolldown/runtime.js
3
3
  var __create = Object.create;
4
4
  var __defProp = Object.defineProperty;
@@ -553,13 +553,53 @@ function resolveAuthEnv(auth) {
553
553
  return resolved;
554
554
  }
555
555
  /**
556
- * Load and validate the MCP config file.
557
- * Searches from `startDir` (defaults to cwd) upward.
556
+ * Try to build config purely from environment variables.
557
+ * Required env vars: ONES_API_BASE, ONES_ACCOUNT, ONES_PASSWORD
558
+ * Returns null if the required env vars are not all present.
559
+ */
560
+ function loadConfigFromEnv() {
561
+ const apiBase = process.env.ONES_API_BASE;
562
+ const account = process.env.ONES_ACCOUNT;
563
+ const password = process.env.ONES_PASSWORD;
564
+ if (!apiBase || !account || !password) return null;
565
+ return {
566
+ sources: { ones: {
567
+ enabled: true,
568
+ apiBase,
569
+ auth: {
570
+ type: "ones-pkce",
571
+ emailEnv: "ONES_ACCOUNT",
572
+ passwordEnv: "ONES_PASSWORD"
573
+ }
574
+ } },
575
+ defaultSource: "ones"
576
+ };
577
+ }
578
+ /**
579
+ * Load and validate the MCP config.
580
+ * Priority: env vars (ONES_API_BASE + ONES_ACCOUNT + ONES_PASSWORD) > config file (.requirements-mcp.json).
581
+ * Searches from `startDir` (defaults to cwd) upward for the file.
558
582
  */
559
583
  function loadConfig(startDir) {
560
- const dir = startDir ?? process.cwd();
561
- const configPath = findConfigFile(dir);
562
- if (!configPath) throw new Error(`Config file "${CONFIG_FILENAME}" not found. Searched from "${dir}" to root. Create one based on .requirements-mcp.json.example`);
584
+ const envConfig = loadConfigFromEnv();
585
+ if (envConfig) {
586
+ const sources = [];
587
+ for (const [type, sourceConfig] of Object.entries(envConfig.sources)) if (sourceConfig && sourceConfig.enabled) {
588
+ const resolvedAuth = resolveAuthEnv(sourceConfig.auth);
589
+ sources.push({
590
+ type,
591
+ config: sourceConfig,
592
+ resolvedAuth
593
+ });
594
+ }
595
+ return {
596
+ config: envConfig,
597
+ sources,
598
+ configPath: "env"
599
+ };
600
+ }
601
+ const configPath = findConfigFile(startDir ?? process.cwd());
602
+ if (!configPath) throw new Error(`Config not found. Either set env vars (ONES_API_BASE, ONES_ACCOUNT, ONES_PASSWORD) or create "${CONFIG_FILENAME}" based on .requirements-mcp.json.example`);
563
603
  const raw = (0, node_fs.readFileSync)(configPath, "utf-8");
564
604
  let parsed;
565
605
  try {
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
-
1
+ #!/usr/bin/env node
2
2
  import { existsSync, readFileSync } from "node:fs";
3
3
  import { dirname, resolve } from "node:path";
4
4
  import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
@@ -525,13 +525,53 @@ function resolveAuthEnv(auth) {
525
525
  return resolved;
526
526
  }
527
527
  /**
528
- * Load and validate the MCP config file.
529
- * Searches from `startDir` (defaults to cwd) upward.
528
+ * Try to build config purely from environment variables.
529
+ * Required env vars: ONES_API_BASE, ONES_ACCOUNT, ONES_PASSWORD
530
+ * Returns null if the required env vars are not all present.
531
+ */
532
+ function loadConfigFromEnv() {
533
+ const apiBase = process.env.ONES_API_BASE;
534
+ const account = process.env.ONES_ACCOUNT;
535
+ const password = process.env.ONES_PASSWORD;
536
+ if (!apiBase || !account || !password) return null;
537
+ return {
538
+ sources: { ones: {
539
+ enabled: true,
540
+ apiBase,
541
+ auth: {
542
+ type: "ones-pkce",
543
+ emailEnv: "ONES_ACCOUNT",
544
+ passwordEnv: "ONES_PASSWORD"
545
+ }
546
+ } },
547
+ defaultSource: "ones"
548
+ };
549
+ }
550
+ /**
551
+ * Load and validate the MCP config.
552
+ * Priority: env vars (ONES_API_BASE + ONES_ACCOUNT + ONES_PASSWORD) > config file (.requirements-mcp.json).
553
+ * Searches from `startDir` (defaults to cwd) upward for the file.
530
554
  */
531
555
  function loadConfig(startDir) {
532
- const dir = startDir ?? process.cwd();
533
- const configPath = findConfigFile(dir);
534
- if (!configPath) throw new Error(`Config file "${CONFIG_FILENAME}" not found. Searched from "${dir}" to root. Create one based on .requirements-mcp.json.example`);
556
+ const envConfig = loadConfigFromEnv();
557
+ if (envConfig) {
558
+ const sources = [];
559
+ for (const [type, sourceConfig] of Object.entries(envConfig.sources)) if (sourceConfig && sourceConfig.enabled) {
560
+ const resolvedAuth = resolveAuthEnv(sourceConfig.auth);
561
+ sources.push({
562
+ type,
563
+ config: sourceConfig,
564
+ resolvedAuth
565
+ });
566
+ }
567
+ return {
568
+ config: envConfig,
569
+ sources,
570
+ configPath: "env"
571
+ };
572
+ }
573
+ const configPath = findConfigFile(startDir ?? process.cwd());
574
+ if (!configPath) throw new Error(`Config not found. Either set env vars (ONES_API_BASE, ONES_ACCOUNT, ONES_PASSWORD) or create "${CONFIG_FILENAME}" based on .requirements-mcp.json.example`);
535
575
  const raw = readFileSync(configPath, "utf-8");
536
576
  let parsed;
537
577
  try {
@@ -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 * Load and validate the MCP config file.\n * Searches from `startDir` (defaults to cwd) upward.\n */\nexport function loadConfig(startDir?: string): LoadConfigResult {\n const dir = startDir ?? process.cwd()\n const configPath = findConfigFile(dir)\n\n if (!configPath) {\n throw new Error(\n `Config file \"${CONFIG_FILENAME}\" not found. `\n + `Searched from \"${dir}\" to root. `\n + `Create one 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, 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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AI;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-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-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AM,OAAO,QAAQ,UAAU;;AAGjC,MAAM,CAAC,OAAO,QAAQ;AACpB,SAAQ,MAAM,mCAAmC,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",
3
+ "version": "0.1.5",
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",