@githits/mcp 0.16.2 → 0.17.0

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.
@@ -1,8 +1,8 @@
1
- var EXPECTED_MCP_TOOLS=["quick_start","get_example","search_language","pkg_info","pkg_deps","pkg_vulns","pkg_changelog","pkg_upgrade_review","docs_list","docs_read","code_files","code_read","code_grep","search","search_status"];var DEFAULT_TEXT_LIMIT=12000;var TARGET_DETAIL_STATE_PATTERN=/^ {2}(?:(?:indexing|searched|available|unavailable|using):|(?:ready|pending|provisional|older snapshot)$|(?:not found|unresolved|version unavailable|repository ref unresolved|(?:package|repository|site|target) (?:not found|unresolved)):)/;var SMOKE_PACKAGE_VERSION="5.2.1";var SMOKE_PACKAGE_TARGET={registry:"npm",package_name:"express",version:SMOKE_PACKAGE_VERSION};var SMOKE_TRANSITIVE_VULNERABILITY_TARGET={registry:"npm",package_name:"express",version:"4.17.1"};function assert(condition,message){if(!condition){throw new Error(message)}}function parseJson(text,context){try{return JSON.parse(text)}catch(error){const message=error instanceof Error?error.message:"unknown error";throw new Error(`${context}: expected parseable JSON (${message})`)}}function assertNotJson(text,context){try{JSON.parse(text)}catch{return}throw new Error(`${context}: default response unexpectedly parsed as JSON`)}function assertRecord(value,context){assert(value!==null&&typeof value==="object"&&!Array.isArray(value),`${context}: expected object`)}function assertTransitiveVulnerabilityText(text,context){assert(text.includes("Resolved dependencies"),`${context}: missing resolved-dependencies section`);assert(!text.includes("use -v"),`${context}: CLI-native transitive hint leaked into MCP output`);if(text.includes("... (+")){assert(text.includes("use verbose=true or format=json"),`${context}: capped transitive output missing MCP-native hint`)}}function assertTransitiveVulnerabilityJson(value,context){assertRecord(value,context);assertRecord(value.transitive,`${context}.transitive`);assert(value.transitive.scope==="resolved_dependencies",`${context}: unexpected transitive scope`);assert(["affected","non_affecting","all"].includes(value.transitive.advisoryScope),`${context}: unexpected transitive advisory scope`);assert(value.transitive.withdrawnAdvisoriesIncluded===false,`${context}: transitive withdrawn-advisory flag must be false`);assertRecord(value.transitive.summary,`${context}.transitive.summary`);for(const key of["totalPackagesAnalyzed","packageCount","occurrenceCount"]){assert(typeof value.transitive.summary[key]==="number",`${context}: transitive summary missing numeric ${key}`)}assert(Array.isArray(value.transitive.packages),`${context}: transitive packages must be an array`)}function headerValue(headers,name){if(!headers)return null;if("get"in headers&&typeof headers.get==="function"){return headers.get(name)}const lowerName=name.toLowerCase();for(const[key,value]of Object.entries(headers)){if(key.toLowerCase()===lowerName)return value??null}return null}function resultText(result,context){assert(Array.isArray(result.content),`${context}: expected content array`);const first=result.content[0];assert(first?.type==="text",`${context}: expected text content`);assert(typeof first.text==="string",`${context}: expected text string`);return first.text}function assertCleanErrorEnvelope(result,context){assert(result.isError===true,`${context}: expected MCP error result`);const payload=parseJson(resultText(result,context),context);assertRecord(payload,context);assert(typeof payload.error==="string"&&payload.error.length>0,`${context}: missing error`);assert(typeof payload.code==="string"&&payload.code.length>0,`${context}: missing code`);assert(typeof payload.retryable==="boolean",`${context}: missing retryable`);return payload}function assertHttpUnauthorizedChallenge(metadata,context="unauthenticated HTTP challenge"){assert(metadata.status===401,`${context}: expected HTTP 401`);const challenge=headerValue(metadata.headers,"www-authenticate");assert(typeof challenge==="string"&&challenge.length>0,`${context}: missing WWW-Authenticate header`);assert(/^Bearer\b/i.test(challenge),`${context}: expected Bearer challenge, got ${challenge}`)}function assertDefaultText(result,context){assert(result.isError!==true,`${context}: expected success`);const text=resultText(result,context);assert(text.length>0,`${context}: expected non-empty text`);assert(text.length<DEFAULT_TEXT_LIMIT,`${context}: default text too large (${text.length} chars)`);assertNotJson(text,context);assert(!text.includes("--lifecycle"),`${context}: leaked CLI lifecycle flag`);assert(!text.includes("--verbose"),`${context}: leaked CLI verbose flag`);return text}function assertSearchDefaultText(text,context){const lines=text.split(`
1
+ var EXPECTED_MCP_TOOLS=["quick_start","get_example","search_language","pkg_info","pkg_deps","pkg_vulns","pkg_changelog","pkg_upgrade_review","docs_list","code_files","read","code_grep","search","search_status"];var DEFAULT_TEXT_LIMIT=12000;var TARGET_DETAIL_STATE_PATTERN=/^ {2}(?:(?:indexing|searched|available|unavailable|using):|(?:ready|pending|provisional|older snapshot)$|(?:not found|unresolved|version unavailable|repository ref unresolved|(?:package|repository|site|target) (?:not found|unresolved)):)/;var SMOKE_PACKAGE_VERSION="5.2.1";var SMOKE_PACKAGE_TARGET={registry:"npm",package_name:"express",version:SMOKE_PACKAGE_VERSION};var SMOKE_TRANSITIVE_VULNERABILITY_TARGET={registry:"npm",package_name:"express",version:"4.17.1"};function assert(condition,message){if(!condition){throw new Error(message)}}function parseJson(text,context){try{return JSON.parse(text)}catch(error){const message=error instanceof Error?error.message:"unknown error";throw new Error(`${context}: expected parseable JSON (${message})`)}}function assertNotJson(text,context){try{JSON.parse(text)}catch{return}throw new Error(`${context}: default response unexpectedly parsed as JSON`)}function assertRecord(value,context){assert(value!==null&&typeof value==="object"&&!Array.isArray(value),`${context}: expected object`)}function assertTransitiveVulnerabilityText(text,context){assert(text.includes("Resolved dependencies"),`${context}: missing resolved-dependencies section`);assert(!text.includes("use -v"),`${context}: CLI-native transitive hint leaked into MCP output`);if(text.includes("... (+")){assert(text.includes("use verbose=true or format=json"),`${context}: capped transitive output missing MCP-native hint`)}}function assertTransitiveVulnerabilityJson(value,context){assertRecord(value,context);assertRecord(value.transitive,`${context}.transitive`);assert(value.transitive.scope==="resolved_dependencies",`${context}: unexpected transitive scope`);assert(["affected","non_affecting","all"].includes(value.transitive.advisoryScope),`${context}: unexpected transitive advisory scope`);assert(value.transitive.withdrawnAdvisoriesIncluded===false,`${context}: transitive withdrawn-advisory flag must be false`);assertRecord(value.transitive.summary,`${context}.transitive.summary`);for(const key of["totalPackagesAnalyzed","packageCount","occurrenceCount"]){assert(typeof value.transitive.summary[key]==="number",`${context}: transitive summary missing numeric ${key}`)}assert(Array.isArray(value.transitive.packages),`${context}: transitive packages must be an array`)}function headerValue(headers,name){if(!headers)return null;if("get"in headers&&typeof headers.get==="function"){return headers.get(name)}const lowerName=name.toLowerCase();for(const[key,value]of Object.entries(headers)){if(key.toLowerCase()===lowerName)return value??null}return null}function resultText(result,context){assert(Array.isArray(result.content),`${context}: expected content array`);const first=result.content[0];assert(first?.type==="text",`${context}: expected text content`);assert(typeof first.text==="string",`${context}: expected text string`);return first.text}function assertCleanErrorEnvelope(result,context){assert(result.isError===true,`${context}: expected MCP error result`);const payload=parseJson(resultText(result,context),context);assertRecord(payload,context);assert(typeof payload.error==="string"&&payload.error.length>0,`${context}: missing error`);assert(typeof payload.code==="string"&&payload.code.length>0,`${context}: missing code`);assert(typeof payload.retryable==="boolean",`${context}: missing retryable`);return payload}function assertHttpUnauthorizedChallenge(metadata,context="unauthenticated HTTP challenge"){assert(metadata.status===401,`${context}: expected HTTP 401`);const challenge=headerValue(metadata.headers,"www-authenticate");assert(typeof challenge==="string"&&challenge.length>0,`${context}: missing WWW-Authenticate header`);assert(/^Bearer\b/i.test(challenge),`${context}: expected Bearer challenge, got ${challenge}`)}function assertDefaultText(result,context){assert(result.isError!==true,`${context}: expected success`);const text=resultText(result,context);assert(text.length>0,`${context}: expected non-empty text`);assert(text.length<DEFAULT_TEXT_LIMIT,`${context}: default text too large (${text.length} chars)`);assertNotJson(text,context);assert(!text.includes("--lifecycle"),`${context}: leaked CLI lifecycle flag`);assert(!text.includes("--verbose"),`${context}: leaked CLI verbose flag`);return text}function assertSearchDefaultText(text,context){const lines=text.split(`
2
2
  `);let pathOnlyBlock=false;for(const line of lines){if(/^\[\d+\] /.test(line)){pathOnlyBlock=/\[repo (?:code|doc), path match\]$/.test(line)}else if(pathOnlyBlock){assert(!/^\s*>?\s*\d+ \|/.test(line),`${context}: path-only hit contains an arbitrary source snippet`)}}const formatterLines=searchFormatterLines(lines);const formatterText=formatterLines.join(`
3
- `);const firstLine=lines[0]?.trim()??"";assert(firstLine.length>0,`${context}: missing outcome first line`);assert(/^(?:No result snapshot yet|No results yet|No result snapshot|No results)\b|^\d+ (?:partial |interim )?results?\b/.test(firstLine),`${context}: missing outcome headline`);assert(!firstLine.startsWith("search |")&&!firstLine.startsWith("search_status |"),`${context}: legacy header precedes outcome`);assert(!formatterLines.some((line)=>/^status\s*:/i.test(line.trim())),`${context}: duplicated lifecycle status line`);assert(!formatterLines.some((line)=>/^Search\s+\S+\s+\|/.test(line)),`${context}: separate Search <ref> session summary`);const lifecycleOutcomeLines=lines.filter((line)=>/\|\s+(?:preparing|indexing|searching)(?:\s*\||$)/.test(line));assert(lifecycleOutcomeLines.length<=1,`${context}: duplicate lifecycle outcome lines`);assert(!formatterText.includes("searchRef="),`${context}: leaked searchRef=`);assert(!formatterText.includes("indexingRef"),`${context}: leaked indexingRef`);const forbiddenSections=["Ready:","Waiting:","Available but not searched:","Indexed alternatives:"];for(const section of forbiddenSections){assert(!lines.some((line)=>line.startsWith(section)),`${context}: legacy flat section ${section}`)}assert(!lines.some((line)=>line==="Evidence may change."),`${context}: vague evidence policy prose`);assert(!lines.some((line)=>line.startsWith("Do not repeat")),`${context}: repeat policy prose`);assert(!lines.some((line)=>line.startsWith("Do not poll")),`${context}: poll policy prose`);const hasReadinessText=formatterLines.some((line)=>TARGET_DETAIL_STATE_PATTERN.test(line));if(hasReadinessText){assert(formatterLines.some((line)=>/^-\s+\S/.test(line)),`${context}: readiness details must be grouped under a target`)}const nextLines=lines.filter((line)=>line.startsWith("Next:"));assert(nextLines.length<=1,`${context}: multiple Next actions are not allowed`);const searchRefOccurrences=formatterText.match(/search_ref=/g)?.length??0;assert(searchRefOccurrences<=1,`${context}: search_ref= must appear at most once`);if(searchRefOccurrences===1){const refLine=formatterLines.find((line)=>line.includes("search_ref="));assert(refLine?.trimStart().startsWith("Next:"),`${context}: search_ref= must appear only on a Next line`);assert(refLine?.startsWith("Next: search_status "),`${context}: search_ref= must use the MCP search_status action`);assert(refLine!==undefined,`${context}: search_ref= must appear only on a Next line`);const match=refLine.match(/search_ref=(?:"([^"]+)"|(\S+))/);const searchRef=match?.[1]??match?.[2];assert(searchRef!==undefined,`${context}: missing search_ref value`)}assert(!formatterText.includes("githits search-status ")&&!formatterText.includes("githits code read ")&&!formatterText.includes("githits docs read ")&&!formatterText.includes(" --wait ")&&!formatterText.includes(" --offset "),`${context}: CLI command syntax leaked into MCP output`);assert(hasHumanSearchHitLocator(lines)||hasTargetRecovery(formatterLines)||lines.some((line)=>line.startsWith("Next:")),`${context}: missing usable result locator or status follow-up`)}function hasTargetRecovery(lines){return lines.some((line,index)=>{if(!/^ {2}(?:Fix|Try):\s+\S/.test(line))return false;for(let previousIndex=index-1;previousIndex>=0;previousIndex-=1){const previous=lines[previousIndex];if(!previous||previous.trim()==="")continue;if(/^-\s+\S/.test(previous))return true;if(previous.startsWith(" "))continue;return false}return false})}function hasHumanSearchHitLocator(lines){return lines.some((line,index)=>{const docsMatch=/^\[\d+\]\s+(\S+)\s+\[docs page\]\s+(.+)$/.exec(line);if(docsMatch){const pageId=docsMatch[1];const docsDetails=docsMatch[2];if(!pageId||pageId==="page ID unavailable"||!docsDetails){return false}const firstDivider=docsDetails.indexOf(" - ");if(firstDivider<=0)return false;const sourceAndTitle=docsDetails.slice(firstDivider+3);const secondDivider=sourceAndTitle.indexOf(" - ");if(secondDivider>0){const source=sourceAndTitle.slice(0,secondDivider).trim();const title=sourceAndTitle.slice(secondDivider+3).trim();return source.length>0&&(title.length>0||hasWrappedHitTitle(lines,index))}if(!sourceAndTitle.endsWith(" -"))return false;const source=sourceAndTitle.slice(0,-2).trim();return source.length>0&&hasWrappedHitTitle(lines,index)}const match=/^\[\d+\]\s+(.+?)\s+\[(repo doc|repo code|repo symbol)(?:, path match)?\](?: -(?: (.*))?)?$/.exec(line);if(!match)return false;const locatorText=match[1];if(!locatorText)return false;const locator=locatorText.trim().split(/\s+/);if(locator.length>=2&&!locatorText.trim().endsWith("location unavailable")&&locator.every((part)=>part.length>0)){const title=match[3];return title===undefined?!line.endsWith(" -")||hasWrappedHitTitle(lines,index):title.trim().length>0||hasWrappedHitTitle(lines,index)}return false})}function hasWrappedHitTitle(lines,index){const titleLine=lines[index+1];return titleLine?.startsWith(" ")===true&&titleLine.trim().length>0}function searchFormatterLines(lines){let inHit=false;return lines.filter((line)=>{if(/^\[\d+\]\s/.test(line)){inHit=true;return true}if(inHit&&line.length>0&&!line.startsWith(" "))inHit=false;return!inHit})}function assertJsonResult(result,context){assert(result.isError!==true,`${context}: expected success`);return parseJson(resultText(result,context),context)}function assertErrorCode(result,context,code){const envelope=assertCleanErrorEnvelope(result,context);assert(envelope.code===code,`${context}: expected ${code}, got ${envelope.code}`)}async function callTool(caller,name,args){return await caller.callTool(name,args)}async function callToolText(caller,name,args){const result=await caller.callTool(name,args);const text=resultText(result,name);if(result.isError===true){throw new Error(text)}return text}async function assertLiveOrAuthRequired(caller,logger){const result=await callTool(caller,"search_language",{query:"python"});if(result.isError===true){const envelope=assertCleanErrorEnvelope(result,"search_language auth probe");assert(envelope.code==="AUTH_REQUIRED",`auth probe returned unexpected code ${envelope.code}`);logger.log("AUTH_REQUIRED: live smoke skipped");return false}const text=assertDefaultText(result,"search_language default");assert(text.includes("python (Python)"),"search_language default missing Python display name");assert(text.includes("aliases:"),"search_language default missing aliases");const packageResult=await callTool(caller,"pkg_info",{registry:"npm",package_name:"express"});if(packageResult.isError===true){const envelope=assertCleanErrorEnvelope(packageResult,"pkg_info auth probe");assert(envelope.code==="AUTH_REQUIRED",`pkg_info auth probe returned unexpected code ${envelope.code}`);logger.log("AUTH_REQUIRED: live smoke skipped");return false}return true}async function runLiveSmoke(caller){const languageJson=assertJsonResult(await callTool(caller,"search_language",{query:"python",format:"json"}),"search_language json");assert(Array.isArray(languageJson),"search_language json: expected array");const exampleText=assertDefaultText(await callTool(caller,"get_example",{query:"express hello world",language:"javascript"}),"get_example default");assert(exampleText.includes("solution_id:"),"get_example default missing solution_id hint");const exampleJson=assertJsonResult(await callTool(caller,"get_example",{query:"express hello world",language:"javascript",format:"json"}),"get_example json");assertRecord(exampleJson,"get_example json");assert(typeof exampleJson.result==="string","get_example json missing result");const pkgInfoText=assertDefaultText(await callTool(caller,"pkg_info",{registry:"npm",package_name:"express"}),"pkg_info default");assert(pkgInfoText.includes("express"),"pkg_info default missing package name");assert(pkgInfoText.includes("Repository")&&pkgInfoText.includes("stars"),"pkg_info default missing repository popularity");assert(pkgInfoText.includes("Vulnerabilities"),"pkg_info default missing vulnerability status");assert(pkgInfoText.includes("Latest:"),"pkg_info default missing latest vulnerability scope");assert(pkgInfoText.includes("History:"),"pkg_info default missing package-wide vulnerability history scope");assert(!pkgInfoText.includes("Install")&&!pkgInfoText.includes("Usage"),"pkg_info default should not include quickstart fields");const pkgInfoJson=assertJsonResult(await callTool(caller,"pkg_info",{registry:"npm",package_name:"express",format:"json"}),"pkg_info json");assertRecord(pkgInfoJson,"pkg_info json");assert(pkgInfoJson.registry==="npm","pkg_info json registry mismatch");assert(pkgInfoJson.name==="express","pkg_info json name mismatch");assert(typeof pkgInfoJson.version==="string","pkg_info json missing version");assert(typeof pkgInfoJson.versionCount==="number","pkg_info json missing version count");assertRecord(pkgInfoJson.downloads,"pkg_info json downloads");assert(typeof pkgInfoJson.downloads.refreshedAt==="string","pkg_info json missing download refresh date");assertRecord(pkgInfoJson.advisoryHistory,"pkg_info json advisory history");assert(typeof pkgInfoJson.advisoryHistory.total==="number","pkg_info json missing advisory history count");assert(!("install"in pkgInfoJson)&&!("usage"in pkgInfoJson),"pkg_info json should not include quickstart fields");const depsText=assertDefaultText(await callTool(caller,"pkg_deps",{registry:"npm",package_name:"express"}),"pkg_deps default");assert(depsText.includes("Runtime dependencies:"),"pkg_deps default missing runtime heading");assert(depsText.includes('pass lifecycle="all"'),"pkg_deps default missing MCP-native lifecycle hint");const depsAllText=assertDefaultText(await callTool(caller,"pkg_deps",{registry:"npm",package_name:"express",lifecycle:"all"}),"pkg_deps lifecycle all");assert(depsAllText.includes("Dependency groups:"),"pkg_deps lifecycle all missing groups heading");assert(!depsAllText.includes("Hidden groups:"),"pkg_deps lifecycle all still hides groups");const depsJson=assertJsonResult(await callTool(caller,"pkg_deps",{registry:"npm",package_name:"express",format:"json"}),"pkg_deps json");assertRecord(depsJson,"pkg_deps json");assertRecord(depsJson.runtime,"pkg_deps json runtime");const depsIssuesText=assertDefaultText(await callTool(caller,"pkg_deps",{registry:"npm",package_name:"express",include_issues:true}),"pkg_deps issues default");assert(depsIssuesText.includes("Dependency issues"),"pkg_deps issues default missing issue heading");const depsIssuesJson=assertJsonResult(await callTool(caller,"pkg_deps",{registry:"npm",package_name:"express",include_issues:true,format:"json"}),"pkg_deps issues json");assertRecord(depsIssuesJson,"pkg_deps issues json");assert(!("transitive"in depsIssuesJson),"pkg_deps issues json should not expose ordinary transitive output");assertRecord(depsIssuesJson.issues,"pkg_deps issues json issues");assertRecord(depsIssuesJson.issues.scope,"pkg_deps issues json scope");assert(depsIssuesJson.issues.scope.mode==="full","pkg_deps issues json should report full scope");for(const category of["deprecated","outdated","duplicates","conflicts"]){assertRecord(depsIssuesJson.issues[category],`pkg_deps issues json ${category}`);assert(typeof depsIssuesJson.issues[category].count==="number",`pkg_deps issues json ${category} missing count`);assert(Array.isArray(depsIssuesJson.issues[category].items),`pkg_deps issues json ${category} missing items`)}const vulnsText=assertDefaultText(await callTool(caller,"pkg_vulns",{registry:"npm",package_name:"express"}),"pkg_vulns default");assert(vulnsText.includes("express")||vulnsText.includes("vulnerab"),"pkg_vulns default missing context");assert(!vulnsText.includes("use -v"),"pkg_vulns leaked CLI -v hint");const transitiveVulnsText=assertDefaultText(await callTool(caller,"pkg_vulns",{...SMOKE_TRANSITIVE_VULNERABILITY_TARGET,include_transitive:true}),"pkg_vulns transitive default");assertTransitiveVulnerabilityText(transitiveVulnsText,"pkg_vulns transitive default");const transitiveVulnsJson=assertJsonResult(await callTool(caller,"pkg_vulns",{...SMOKE_TRANSITIVE_VULNERABILITY_TARGET,include_transitive:true,advisory_scope:"all",format:"json"}),"pkg_vulns transitive json");assertTransitiveVulnerabilityJson(transitiveVulnsJson,"pkg_vulns transitive json");assertRecord(transitiveVulnsJson,"pkg_vulns transitive json");assert(transitiveVulnsJson.transitive.advisoryScope==="all","pkg_vulns transitive json did not apply all advisory scope");const filteredVulnsText=assertDefaultText(await callTool(caller,"pkg_vulns",{registry:"npm",package_name:"lodash",version:"4.17.20",min_severity:"high"}),"pkg_vulns filtered default");assert(filteredVulnsText.includes("Filter severity >= high"),"pkg_vulns filtered default missing filter echo");assert(!filteredVulnsText.includes("use -v"),"pkg_vulns filtered default leaked CLI -v hint");const vulnsJson=assertJsonResult(await callTool(caller,"pkg_vulns",{registry:"npm",package_name:"express",format:"json"}),"pkg_vulns json");assertRecord(vulnsJson,"pkg_vulns json");assert("summary"in vulnsJson||"advisories"in vulnsJson,"pkg_vulns json missing vulnerability data");const filteredVulnsJson=assertJsonResult(await callTool(caller,"pkg_vulns",{registry:"npm",package_name:"lodash",version:"4.17.20",min_severity:"high",format:"json"}),"pkg_vulns filtered json");assertRecord(filteredVulnsJson,"pkg_vulns filtered json");assertRecord(filteredVulnsJson.filter,"pkg_vulns filtered json filter");assert(filteredVulnsJson.filter.minSeverity==="high","pkg_vulns filtered json missing severity filter echo");const scopedVulnsText=assertDefaultText(await callTool(caller,"pkg_vulns",{registry:"npm",package_name:"express",advisory_scope:"non_affecting"}),"pkg_vulns scoped default");assert(scopedVulnsText.includes("Scope historical advisories only"),"pkg_vulns scoped default missing scope echo");assert(scopedVulnsText.includes("No active vulnerabilities affect this version"),"pkg_vulns scoped default missing current-risk statement");assert(!scopedVulnsText.includes("use -v"),"pkg_vulns scoped default leaked CLI -v hint");const scopedVulnsJson=assertJsonResult(await callTool(caller,"pkg_vulns",{registry:"npm",package_name:"express",advisory_scope:"non_affecting",format:"json"}),"pkg_vulns scoped json");assertRecord(scopedVulnsJson,"pkg_vulns scoped json");assertRecord(scopedVulnsJson.filter,"pkg_vulns scoped json filter");assert(scopedVulnsJson.filter.advisoryScope==="non_affecting","pkg_vulns scoped json missing advisory scope echo");const changelogText=assertDefaultText(await callTool(caller,"pkg_changelog",{registry:"npm",package_name:"express",limit:1}),"pkg_changelog default");assert(!changelogText.includes("--verbose"),"pkg_changelog default leaked CLI verbose flag");if(changelogText.includes("truncated")||changelogText.includes("full bodies")){assert(changelogText.includes('pass verbose=true, body_lines=<n>, or format="json"'),"pkg_changelog truncation hint is not MCP-native")}const changelogBodyLinesText=assertDefaultText(await callTool(caller,"pkg_changelog",{registry:"npm",package_name:"express",limit:2,body_lines:3}),"pkg_changelog body_lines");assert(changelogBodyLinesText.includes('pass verbose=true, body_lines=<n>, or format="json"'),"pkg_changelog body_lines missing MCP-native truncation hint");assert(!changelogBodyLinesText.includes("--verbose"),"pkg_changelog body_lines leaked CLI verbose flag");const changelogJson=assertJsonResult(await callTool(caller,"pkg_changelog",{registry:"npm",package_name:"express",limit:1,format:"json"}),"pkg_changelog json");assertRecord(changelogJson,"pkg_changelog json");assertRecord(changelogJson.entries,"pkg_changelog json entries");const changelogTimeline=assertDefaultText(await callTool(caller,"pkg_changelog",{registry:"npm",package_name:"express",limit:2,omit_bodies:true}),"pkg_changelog timeline");assert(!changelogTimeline.includes("What's Changed"),"pkg_changelog omit_bodies=true still emitted bodies");const upgradeReviewText=assertDefaultText(await callTool(caller,"pkg_upgrade_review",{registry:"npm",package_name:"express",current_version:"5.0.0",target_version:"5.2.1",skip_transitive_security:true}),"pkg_upgrade_review default");const upgradeReviewFirstLine=upgradeReviewText.split(`
3
+ `);const firstLine=lines[0]?.trim()??"";assert(firstLine.length>0,`${context}: missing outcome first line`);assert(/^(?:No result snapshot yet|No results yet|No result snapshot|No results)\b|^\d+ (?:partial |interim )?results?\b/.test(firstLine),`${context}: missing outcome headline`);assert(!firstLine.startsWith("search |")&&!firstLine.startsWith("search_status |"),`${context}: legacy header precedes outcome`);assert(!formatterLines.some((line)=>/^status\s*:/i.test(line.trim())),`${context}: duplicated lifecycle status line`);assert(!formatterLines.some((line)=>/^Search\s+\S+\s+\|/.test(line)),`${context}: separate Search <ref> session summary`);const lifecycleOutcomeLines=lines.filter((line)=>/\|\s+(?:preparing|indexing|searching)(?:\s*\||$)/.test(line));assert(lifecycleOutcomeLines.length<=1,`${context}: duplicate lifecycle outcome lines`);assert(!formatterText.includes("searchRef="),`${context}: leaked searchRef=`);assert(!formatterText.includes("indexingRef"),`${context}: leaked indexingRef`);const forbiddenSections=["Ready:","Waiting:","Available but not searched:","Indexed alternatives:"];for(const section of forbiddenSections){assert(!lines.some((line)=>line.startsWith(section)),`${context}: legacy flat section ${section}`)}assert(!lines.some((line)=>line==="Evidence may change."),`${context}: vague evidence policy prose`);assert(!lines.some((line)=>line.startsWith("Do not repeat")),`${context}: repeat policy prose`);assert(!lines.some((line)=>line.startsWith("Do not poll")),`${context}: poll policy prose`);const hasReadinessText=formatterLines.some((line)=>TARGET_DETAIL_STATE_PATTERN.test(line));if(hasReadinessText){assert(formatterLines.some((line)=>/^-\s+\S/.test(line)),`${context}: readiness details must be grouped under a target`)}const nextLines=lines.filter((line)=>line.startsWith("Next:"));assert(nextLines.length<=1,`${context}: multiple Next actions are not allowed`);const searchRefOccurrences=formatterText.match(/search_ref=/g)?.length??0;assert(searchRefOccurrences<=1,`${context}: search_ref= must appear at most once`);if(searchRefOccurrences===1){const refLine=formatterLines.find((line)=>line.includes("search_ref="));assert(refLine?.trimStart().startsWith("Next:"),`${context}: search_ref= must appear only on a Next line`);assert(refLine?.startsWith("Next: search_status "),`${context}: search_ref= must use the MCP search_status action`);assert(refLine!==undefined,`${context}: search_ref= must appear only on a Next line`);const match=refLine.match(/search_ref=(?:"([^"]+)"|(\S+))/);const searchRef=match?.[1]??match?.[2];assert(searchRef!==undefined,`${context}: missing search_ref value`)}assert(!formatterText.includes("githits search-status ")&&!formatterText.includes("githits read ")&&!formatterText.includes("githits code read ")&&!formatterText.includes("githits docs read ")&&!formatterText.includes(" --wait ")&&!formatterText.includes(" --offset "),`${context}: CLI command syntax leaked into MCP output`);assert(hasHumanSearchHitLocator(lines)||hasTargetRecovery(formatterLines)||lines.some((line)=>line.startsWith("Next:")),`${context}: missing usable result locator or status follow-up`)}function hasTargetRecovery(lines){return lines.some((line,index)=>{if(!/^ {2}(?:Fix|Try):\s+\S/.test(line))return false;for(let previousIndex=index-1;previousIndex>=0;previousIndex-=1){const previous=lines[previousIndex];if(!previous||previous.trim()==="")continue;if(/^-\s+\S/.test(previous))return true;if(previous.startsWith(" "))continue;return false}return false})}function hasHumanSearchHitLocator(lines){return lines.some((line,index)=>{const docsMatch=/^\[\d+\]\s+(\S+)\s+\[docs page\]\s+(.+)$/.exec(line);if(docsMatch){const pageId=docsMatch[1];const docsDetails=docsMatch[2];if(!pageId||pageId==="page ID unavailable"||!docsDetails){return false}const firstDivider=docsDetails.indexOf(" - ");if(firstDivider<=0)return false;const sourceAndTitle=docsDetails.slice(firstDivider+3);const secondDivider=sourceAndTitle.indexOf(" - ");if(secondDivider>0){const source=sourceAndTitle.slice(0,secondDivider).trim();const title=sourceAndTitle.slice(secondDivider+3).trim();return source.length>0&&(title.length>0||hasWrappedHitTitle(lines,index))}if(!sourceAndTitle.endsWith(" -"))return false;const source=sourceAndTitle.slice(0,-2).trim();return source.length>0&&hasWrappedHitTitle(lines,index)}const match=/^\[\d+\]\s+(.+?)\s+\[(repo doc|repo code|repo symbol)(?:, path match)?\](?: -(?: (.*))?)?$/.exec(line);if(!match)return false;const locatorText=match[1];if(!locatorText)return false;const locator=locatorText.trim().split(/\s+/);if(locator.length>=2&&!locatorText.trim().endsWith("location unavailable")&&locator.every((part)=>part.length>0)){const title=match[3];return title===undefined?!line.endsWith(" -")||hasWrappedHitTitle(lines,index):title.trim().length>0||hasWrappedHitTitle(lines,index)}return false})}function hasWrappedHitTitle(lines,index){const titleLine=lines[index+1];return titleLine?.startsWith(" ")===true&&titleLine.trim().length>0}function searchFormatterLines(lines){let inHit=false;return lines.filter((line)=>{if(/^\[\d+\]\s/.test(line)){inHit=true;return true}if(inHit&&line.length>0&&!line.startsWith(" "))inHit=false;return!inHit})}function assertJsonResult(result,context){assert(result.isError!==true,`${context}: expected success`);return parseJson(resultText(result,context),context)}function assertErrorCode(result,context,code){const envelope=assertCleanErrorEnvelope(result,context);assert(envelope.code===code,`${context}: expected ${code}, got ${envelope.code}`)}async function callTool(caller,name,args){return await caller.callTool(name,args)}async function callToolText(caller,name,args){const result=await caller.callTool(name,args);const text=resultText(result,name);if(result.isError===true){throw new Error(text)}return text}async function assertLiveOrAuthRequired(caller,logger){const result=await callTool(caller,"search_language",{query:"python"});if(result.isError===true){const envelope=assertCleanErrorEnvelope(result,"search_language auth probe");assert(envelope.code==="AUTH_REQUIRED",`auth probe returned unexpected code ${envelope.code}`);logger.log("AUTH_REQUIRED: live smoke skipped");return false}const text=assertDefaultText(result,"search_language default");assert(text.includes("python (Python)"),"search_language default missing Python display name");assert(text.includes("aliases:"),"search_language default missing aliases");const packageResult=await callTool(caller,"pkg_info",{registry:"npm",package_name:"express"});if(packageResult.isError===true){const envelope=assertCleanErrorEnvelope(packageResult,"pkg_info auth probe");assert(envelope.code==="AUTH_REQUIRED",`pkg_info auth probe returned unexpected code ${envelope.code}`);logger.log("AUTH_REQUIRED: live smoke skipped");return false}return true}async function runLiveSmoke(caller){const languageJson=assertJsonResult(await callTool(caller,"search_language",{query:"python",format:"json"}),"search_language json");assert(Array.isArray(languageJson),"search_language json: expected array");const exampleText=assertDefaultText(await callTool(caller,"get_example",{query:"express hello world",language:"javascript"}),"get_example default");assert(exampleText.includes("solution_id:"),"get_example default missing solution_id hint");const exampleJson=assertJsonResult(await callTool(caller,"get_example",{query:"express hello world",language:"javascript",format:"json"}),"get_example json");assertRecord(exampleJson,"get_example json");assert(typeof exampleJson.result==="string","get_example json missing result");const pkgInfoText=assertDefaultText(await callTool(caller,"pkg_info",{registry:"npm",package_name:"express"}),"pkg_info default");assert(pkgInfoText.includes("express"),"pkg_info default missing package name");assert(pkgInfoText.includes("Repository")&&pkgInfoText.includes("stars"),"pkg_info default missing repository popularity");assert(pkgInfoText.includes("Vulnerabilities"),"pkg_info default missing vulnerability status");assert(pkgInfoText.includes("Latest:"),"pkg_info default missing latest vulnerability scope");assert(pkgInfoText.includes("History:"),"pkg_info default missing package-wide vulnerability history scope");assert(!pkgInfoText.includes("Install")&&!pkgInfoText.includes("Usage"),"pkg_info default should not include quickstart fields");const pkgInfoJson=assertJsonResult(await callTool(caller,"pkg_info",{registry:"npm",package_name:"express",format:"json"}),"pkg_info json");assertRecord(pkgInfoJson,"pkg_info json");assert(pkgInfoJson.registry==="npm","pkg_info json registry mismatch");assert(pkgInfoJson.name==="express","pkg_info json name mismatch");assert(typeof pkgInfoJson.version==="string","pkg_info json missing version");assert(typeof pkgInfoJson.versionCount==="number","pkg_info json missing version count");assertRecord(pkgInfoJson.downloads,"pkg_info json downloads");assert(typeof pkgInfoJson.downloads.refreshedAt==="string","pkg_info json missing download refresh date");assertRecord(pkgInfoJson.advisoryHistory,"pkg_info json advisory history");assert(typeof pkgInfoJson.advisoryHistory.total==="number","pkg_info json missing advisory history count");assert(!("install"in pkgInfoJson)&&!("usage"in pkgInfoJson),"pkg_info json should not include quickstart fields");const depsText=assertDefaultText(await callTool(caller,"pkg_deps",{registry:"npm",package_name:"express"}),"pkg_deps default");assert(depsText.includes("Runtime dependencies:"),"pkg_deps default missing runtime heading");assert(depsText.includes('pass lifecycle="all"'),"pkg_deps default missing MCP-native lifecycle hint");const depsAllText=assertDefaultText(await callTool(caller,"pkg_deps",{registry:"npm",package_name:"express",lifecycle:"all"}),"pkg_deps lifecycle all");assert(depsAllText.includes("Dependency groups:"),"pkg_deps lifecycle all missing groups heading");assert(!depsAllText.includes("Hidden groups:"),"pkg_deps lifecycle all still hides groups");const depsJson=assertJsonResult(await callTool(caller,"pkg_deps",{registry:"npm",package_name:"express",format:"json"}),"pkg_deps json");assertRecord(depsJson,"pkg_deps json");assertRecord(depsJson.runtime,"pkg_deps json runtime");const depsIssuesText=assertDefaultText(await callTool(caller,"pkg_deps",{registry:"npm",package_name:"express",include_issues:true}),"pkg_deps issues default");assert(depsIssuesText.includes("Dependency issues"),"pkg_deps issues default missing issue heading");const depsIssuesJson=assertJsonResult(await callTool(caller,"pkg_deps",{registry:"npm",package_name:"express",include_issues:true,format:"json"}),"pkg_deps issues json");assertRecord(depsIssuesJson,"pkg_deps issues json");assert(!("transitive"in depsIssuesJson),"pkg_deps issues json should not expose ordinary transitive output");assertRecord(depsIssuesJson.issues,"pkg_deps issues json issues");assertRecord(depsIssuesJson.issues.scope,"pkg_deps issues json scope");assert(depsIssuesJson.issues.scope.mode==="full","pkg_deps issues json should report full scope");for(const category of["deprecated","outdated","duplicates","conflicts"]){assertRecord(depsIssuesJson.issues[category],`pkg_deps issues json ${category}`);assert(typeof depsIssuesJson.issues[category].count==="number",`pkg_deps issues json ${category} missing count`);assert(Array.isArray(depsIssuesJson.issues[category].items),`pkg_deps issues json ${category} missing items`)}const vulnsText=assertDefaultText(await callTool(caller,"pkg_vulns",{registry:"npm",package_name:"express"}),"pkg_vulns default");assert(vulnsText.includes("express")||vulnsText.includes("vulnerab"),"pkg_vulns default missing context");assert(!vulnsText.includes("use -v"),"pkg_vulns leaked CLI -v hint");const transitiveVulnsText=assertDefaultText(await callTool(caller,"pkg_vulns",{...SMOKE_TRANSITIVE_VULNERABILITY_TARGET,include_transitive:true}),"pkg_vulns transitive default");assertTransitiveVulnerabilityText(transitiveVulnsText,"pkg_vulns transitive default");const transitiveVulnsJson=assertJsonResult(await callTool(caller,"pkg_vulns",{...SMOKE_TRANSITIVE_VULNERABILITY_TARGET,include_transitive:true,advisory_scope:"all",format:"json"}),"pkg_vulns transitive json");assertTransitiveVulnerabilityJson(transitiveVulnsJson,"pkg_vulns transitive json");assertRecord(transitiveVulnsJson,"pkg_vulns transitive json");assert(transitiveVulnsJson.transitive.advisoryScope==="all","pkg_vulns transitive json did not apply all advisory scope");const filteredVulnsText=assertDefaultText(await callTool(caller,"pkg_vulns",{registry:"npm",package_name:"lodash",version:"4.17.20",min_severity:"high"}),"pkg_vulns filtered default");assert(filteredVulnsText.includes("Filter severity >= high"),"pkg_vulns filtered default missing filter echo");assert(!filteredVulnsText.includes("use -v"),"pkg_vulns filtered default leaked CLI -v hint");const vulnsJson=assertJsonResult(await callTool(caller,"pkg_vulns",{registry:"npm",package_name:"express",format:"json"}),"pkg_vulns json");assertRecord(vulnsJson,"pkg_vulns json");assert("summary"in vulnsJson||"advisories"in vulnsJson,"pkg_vulns json missing vulnerability data");const filteredVulnsJson=assertJsonResult(await callTool(caller,"pkg_vulns",{registry:"npm",package_name:"lodash",version:"4.17.20",min_severity:"high",format:"json"}),"pkg_vulns filtered json");assertRecord(filteredVulnsJson,"pkg_vulns filtered json");assertRecord(filteredVulnsJson.filter,"pkg_vulns filtered json filter");assert(filteredVulnsJson.filter.minSeverity==="high","pkg_vulns filtered json missing severity filter echo");const scopedVulnsText=assertDefaultText(await callTool(caller,"pkg_vulns",{registry:"npm",package_name:"express",advisory_scope:"non_affecting"}),"pkg_vulns scoped default");assert(scopedVulnsText.includes("Scope historical advisories only"),"pkg_vulns scoped default missing scope echo");assert(scopedVulnsText.includes("No active vulnerabilities affect this version"),"pkg_vulns scoped default missing current-risk statement");assert(!scopedVulnsText.includes("use -v"),"pkg_vulns scoped default leaked CLI -v hint");const scopedVulnsJson=assertJsonResult(await callTool(caller,"pkg_vulns",{registry:"npm",package_name:"express",advisory_scope:"non_affecting",format:"json"}),"pkg_vulns scoped json");assertRecord(scopedVulnsJson,"pkg_vulns scoped json");assertRecord(scopedVulnsJson.filter,"pkg_vulns scoped json filter");assert(scopedVulnsJson.filter.advisoryScope==="non_affecting","pkg_vulns scoped json missing advisory scope echo");const changelogText=assertDefaultText(await callTool(caller,"pkg_changelog",{registry:"npm",package_name:"express",limit:1}),"pkg_changelog default");assert(!changelogText.includes("--verbose"),"pkg_changelog default leaked CLI verbose flag");if(changelogText.includes("truncated")||changelogText.includes("full bodies")){assert(changelogText.includes('pass verbose=true, body_lines=<n>, or format="json"'),"pkg_changelog truncation hint is not MCP-native")}const changelogBodyLinesText=assertDefaultText(await callTool(caller,"pkg_changelog",{registry:"npm",package_name:"express",limit:2,body_lines:3}),"pkg_changelog body_lines");assert(changelogBodyLinesText.includes('pass verbose=true, body_lines=<n>, or format="json"'),"pkg_changelog body_lines missing MCP-native truncation hint");assert(!changelogBodyLinesText.includes("--verbose"),"pkg_changelog body_lines leaked CLI verbose flag");const changelogJson=assertJsonResult(await callTool(caller,"pkg_changelog",{registry:"npm",package_name:"express",limit:1,format:"json"}),"pkg_changelog json");assertRecord(changelogJson,"pkg_changelog json");assertRecord(changelogJson.entries,"pkg_changelog json entries");const changelogTimeline=assertDefaultText(await callTool(caller,"pkg_changelog",{registry:"npm",package_name:"express",limit:2,omit_bodies:true}),"pkg_changelog timeline");assert(!changelogTimeline.includes("What's Changed"),"pkg_changelog omit_bodies=true still emitted bodies");const upgradeReviewText=assertDefaultText(await callTool(caller,"pkg_upgrade_review",{registry:"npm",package_name:"express",current_version:"5.0.0",target_version:"5.2.1",skip_transitive_security:true}),"pkg_upgrade_review default");const upgradeReviewFirstLine=upgradeReviewText.split(`
4
4
  `)[0]?.trim();assert(upgradeReviewFirstLine==="Upgrade review - 1 package","pkg_upgrade_review default missing outcome headline");assert(upgradeReviewText.includes("npm:express 5.0.0 -> 5.2.1")&&upgradeReviewText.includes(`
5
5
  Security
6
6
  `)&&upgradeReviewText.includes(`
7
7
  Changes
8
- `),"pkg_upgrade_review default missing grouped evidence");assert(!upgradeReviewText.includes("pkg_upgrade_review")&&!/\b(?:recommendation|risk level|assessment)\b/i.test(upgradeReviewText),"pkg_upgrade_review default leaked assessment language");const upgradeReviewJson=assertJsonResult(await callTool(caller,"pkg_upgrade_review",{registry:"npm",package_name:"express",current_version:"5.0.0",target_version:"5.2.1",skip_transitive_security:true,format:"json"}),"pkg_upgrade_review json");assertRecord(upgradeReviewJson,"pkg_upgrade_review json");assertRecord(upgradeReviewJson.summary,"pkg_upgrade_review json summary");assert(Array.isArray(upgradeReviewJson.reviews),"pkg_upgrade_review json missing reviews array");const firstUpgradeReview=upgradeReviewJson.reviews[0];assert(firstUpgradeReview,"pkg_upgrade_review json missing first review");for(const forbidden of["risk","riskLevel","recommendation","findings","verification"]){assert(!(forbidden in firstUpgradeReview),`pkg_upgrade_review json leaked judgment field ${forbidden}`)}const docsJson=assertJsonResult(await callTool(caller,"docs_list",{...SMOKE_PACKAGE_TARGET,limit:500,format:"json"}),"docs_list json");assertRecord(docsJson,"docs_list json");assert(Array.isArray(docsJson.pages),"docs_list json missing pages array");const docsPages=docsJson.pages;const crawledPage=docsPages.find((page)=>typeof page==="object"&&page!==null&&page.sourceKind==="crawled"&&typeof page.docsReadTarget==="string"&&/^https?:\/\//.test(page.docsReadTarget));const repoPage=docsPages.find((page)=>typeof page==="object"&&page!==null&&page.sourceKind==="repo");assert(crawledPage&&typeof crawledPage.docsReadTarget==="string"&&typeof crawledPage.pageId==="string"&&typeof crawledPage.sourceUrl==="string","docs_list json missing crawled URL target, stable page ID, or source URL");assert(repoPage&&typeof repoPage.docsReadTarget==="string"&&typeof repoPage.pageId==="string"&&typeof repoPage.sourceUrl==="string","docs_list json missing repo-backed target, stable page ID, or source URL");assert(repoPage.docsReadTarget===repoPage.pageId,"docs_list json repo-backed docsReadTarget should remain snapshot-pinned");const crawledPageIndex=docsPages.indexOf(crawledPage);let crawledPageAfter;if(crawledPageIndex>0){const precedingDocs=assertJsonResult(await callTool(caller,"docs_list",{...SMOKE_PACKAGE_TARGET,limit:crawledPageIndex,format:"json"}),"docs_list crawled target cursor");assertRecord(precedingDocs,"docs_list crawled target cursor");assert(typeof precedingDocs.nextCursor==="string","docs_list crawled target cursor missing nextCursor");crawledPageAfter=precedingDocs.nextCursor}const docsText=assertDefaultText(await callTool(caller,"docs_list",{...SMOKE_PACKAGE_TARGET,limit:1,...crawledPageAfter?{after:crawledPageAfter}:{}}),"docs_list crawled target default");assert(docsText.includes(`docs_read page_id=${JSON.stringify(crawledPage.docsReadTarget)}`),"docs_list default missing crawled URL follow-up");const docReadText=assertDefaultText(await callTool(caller,"docs_read",{page_id:crawledPage.docsReadTarget,start_line:1,end_line:5}),"docs_read crawled URL default");assert(docReadText.length>0,"docs_read crawled URL default missing content");const docReadJson=assertJsonResult(await callTool(caller,"docs_read",{page_id:crawledPage.docsReadTarget,start_line:1,end_line:5,format:"json"}),"docs_read crawled URL json");assertRecord(docReadJson,"docs_read crawled URL json");assert(docReadJson.docsReadTarget===crawledPage.docsReadTarget&&docReadJson.pageId===crawledPage.pageId&&docReadJson.sourceUrl===crawledPage.sourceUrl&&typeof docReadJson.content==="string"&&docReadJson.startLine===1&&typeof docReadJson.endLine==="number"&&docReadJson.endLine>=1&&docReadJson.endLine<=5&&typeof docReadJson.totalLines==="number"&&docReadJson.totalLines>=docReadJson.endLine,"docs_read crawled URL json missing locators, content, or backend range");const legacyCrawledRead=assertJsonResult(await callTool(caller,"docs_read",{page_id:crawledPage.pageId,start_line:1,end_line:5,format:"json"}),"docs_read legacy crawled ID json");assertRecord(legacyCrawledRead,"docs_read legacy crawled ID json");assert(legacyCrawledRead.pageId===docReadJson.pageId&&legacyCrawledRead.content===docReadJson.content,"docs_read URL and legacy crawled ID returned different ranged content");const repoRead=assertJsonResult(await callTool(caller,"docs_read",{page_id:repoPage.docsReadTarget,format:"json"}),"docs_read repo-backed ID json");assertRecord(repoRead,"docs_read repo-backed ID json");assert(repoRead.docsReadTarget===repoPage.docsReadTarget&&repoRead.pageId===repoPage.pageId&&typeof repoRead.content==="string"&&typeof repoRead.totalLines==="number"&&(repoRead.totalLines===0||typeof repoRead.startLine==="number"&&typeof repoRead.endLine==="number"),"docs_read repo-backed ID json missing snapshot locators, content, or range");assertErrorCode(await callTool(caller,"docs_read",{page_id:"https://docs.example.invalid/githits-smoke-unknown",format:"json"}),"docs_read unknown URL","NOT_FOUND");const codeFilesText=assertDefaultText(await callTool(caller,"code_files",{target:SMOKE_PACKAGE_TARGET,path_prefix:"package.json",limit:1}),"code_files default");assert(codeFilesText.includes("package.json"),"code_files default missing package.json");const codeFilesJson=assertJsonResult(await callTool(caller,"code_files",{target:SMOKE_PACKAGE_TARGET,path_prefix:"package.json",limit:1,format:"json"}),"code_files json");assertRecord(codeFilesJson,"code_files json");assert(Array.isArray(codeFilesJson.files),"code_files json missing files array");const codeReadText=assertDefaultText(await callTool(caller,"code_read",{target:SMOKE_PACKAGE_TARGET,path:"package.json",start_line:1,end_line:5}),"code_read default");assert(/^1\s+/m.test(codeReadText),"code_read default missing line numbers");const codeReadJson=assertJsonResult(await callTool(caller,"code_read",{target:SMOKE_PACKAGE_TARGET,path:"package.json",start_line:1,end_line:5,format:"json"}),"code_read json");assertRecord(codeReadJson,"code_read json");assert(codeReadJson.path==="package.json","code_read json path mismatch");const codeGrepText=assertDefaultText(await callTool(caller,"code_grep",{target:SMOKE_PACKAGE_TARGET,pattern:"express",path:"package.json",max_matches:1,context_lines_after:12}),"code_grep default");assert(codeGrepText.includes("package.json"),"code_grep default missing package.json");assert(codeGrepText.includes("requested 0 / 12"),"code_grep missing context clamping notice");const codeGrepJson=assertJsonResult(await callTool(caller,"code_grep",{target:SMOKE_PACKAGE_TARGET,pattern:"express",path:"package.json",max_matches:1,context_lines_after:12,format:"json"}),"code_grep json");assertRecord(codeGrepJson,"code_grep json");assert("matches"in codeGrepJson||"totalMatches"in codeGrepJson,"code_grep json missing matches");assertRecord(codeGrepJson.contextClamping,"code_grep context clamping");assert(codeGrepJson.contextClamping.requestedAfter===12&&codeGrepJson.contextClamping.effectiveAfter===10,"code_grep context clamping mismatch");assertErrorCode(await callTool(caller,"search",{target:SMOKE_PACKAGE_TARGET,query:"router",source:"docs",path_prefix:"docs/",format:"json"}),"search unsupported path prefix","INVALID_ARGUMENT");const searchText=assertDefaultText(await callTool(caller,"search",{target:SMOKE_PACKAGE_TARGET,query:"router",limit:1}),"search default");assertSearchDefaultText(searchText,"search default");const searchJson=assertJsonResult(await callTool(caller,"search",{target:SMOKE_PACKAGE_TARGET,query:"router",limit:1,format:"json"}),"search json");assertRecord(searchJson,"search json");const searchRef=typeof searchJson.searchRef==="string"?searchJson.searchRef:undefined;if(searchRef){const statusJson=assertJsonResult(await callTool(caller,"search_status",{search_ref:searchRef,wait_timeout_ms:0,format:"json"}),"search_status json");assertRecord(statusJson,"search_status json");assert("completed"in statusJson||"progress"in statusJson,"search_status json missing status data")}else{assertErrorCode(await callTool(caller,"search_status",{search_ref:"smoke-invalid-search-ref",wait_timeout_ms:0}),"search_status invalid ref","NOT_FOUND")}}async function runMcpSmoke(caller,options={}){const logger=options.logger??console;const includeLiveTools=options.includeLiveTools??true;const toolsResponse=await caller.listTools();const toolNames=new Set(toolsResponse.tools.map((tool)=>tool.name));assert(!toolNames.has("feedback"),"listTools advertises removed feedback tool");for(const expected of EXPECTED_MCP_TOOLS){assert(toolNames.has(expected),`listTools missing ${expected}`)}for(const tool of toolsResponse.tools){assert(tool.annotations?.readOnlyHint===true,`${tool.name} must advertise readOnlyHint: true`)}const quickStart=assertDefaultText(await callTool(caller,"quick_start",{}),"quick_start default");for(const expected of["GitHits routing guide","`search`","`code_grep`"]){assert(quickStart.includes(expected),`quick_start default missing ${expected}`)}if(!includeLiveTools)return;if(await assertLiveOrAuthRequired(caller,logger)){await runLiveSmoke(caller);logger.log("MCP smoke passed")}}export{EXPECTED_MCP_TOOLS,assertCleanErrorEnvelope,assertDefaultText,assertHttpUnauthorizedChallenge,assertJsonResult,callToolText,resultText,runMcpSmoke};
8
+ `),"pkg_upgrade_review default missing grouped evidence");assert(!upgradeReviewText.includes("pkg_upgrade_review")&&!/\b(?:recommendation|risk level|assessment)\b/i.test(upgradeReviewText),"pkg_upgrade_review default leaked assessment language");const upgradeReviewJson=assertJsonResult(await callTool(caller,"pkg_upgrade_review",{registry:"npm",package_name:"express",current_version:"5.0.0",target_version:"5.2.1",skip_transitive_security:true,format:"json"}),"pkg_upgrade_review json");assertRecord(upgradeReviewJson,"pkg_upgrade_review json");assertRecord(upgradeReviewJson.summary,"pkg_upgrade_review json summary");assert(Array.isArray(upgradeReviewJson.reviews),"pkg_upgrade_review json missing reviews array");const firstUpgradeReview=upgradeReviewJson.reviews[0];assert(firstUpgradeReview,"pkg_upgrade_review json missing first review");for(const forbidden of["risk","riskLevel","recommendation","findings","verification"]){assert(!(forbidden in firstUpgradeReview),`pkg_upgrade_review json leaked judgment field ${forbidden}`)}const docsJson=assertJsonResult(await callTool(caller,"docs_list",{...SMOKE_PACKAGE_TARGET,limit:500,format:"json"}),"docs_list json");assertRecord(docsJson,"docs_list json");assert(Array.isArray(docsJson.pages),"docs_list json missing pages array");const docsPages=docsJson.pages;const crawledPage=docsPages.find((page)=>typeof page==="object"&&page!==null&&page.sourceKind==="crawled"&&typeof page.docsReadTarget==="string"&&/^https?:\/\//.test(page.docsReadTarget));const repoPage=docsPages.find((page)=>typeof page==="object"&&page!==null&&page.sourceKind==="repo");assert(crawledPage&&typeof crawledPage.docsReadTarget==="string"&&typeof crawledPage.pageId==="string"&&typeof crawledPage.sourceUrl==="string","docs_list json missing crawled URL target, stable page ID, or source URL");assert(repoPage&&typeof repoPage.docsReadTarget==="string"&&typeof repoPage.pageId==="string"&&typeof repoPage.sourceUrl==="string","docs_list json missing repo-backed target, stable page ID, or source URL");assert(repoPage.docsReadTarget===repoPage.pageId,"docs_list json repo-backed docsReadTarget should remain snapshot-pinned");const crawledPageIndex=docsPages.indexOf(crawledPage);let crawledPageAfter;if(crawledPageIndex>0){const precedingDocs=assertJsonResult(await callTool(caller,"docs_list",{...SMOKE_PACKAGE_TARGET,limit:crawledPageIndex,format:"json"}),"docs_list crawled target cursor");assertRecord(precedingDocs,"docs_list crawled target cursor");assert(typeof precedingDocs.nextCursor==="string","docs_list crawled target cursor missing nextCursor");crawledPageAfter=precedingDocs.nextCursor}const docsText=assertDefaultText(await callTool(caller,"docs_list",{...SMOKE_PACKAGE_TARGET,limit:1,...crawledPageAfter?{after:crawledPageAfter}:{}}),"docs_list crawled target default");assert(docsText.includes(`read target=${JSON.stringify(crawledPage.docsReadTarget)}`),"docs_list default missing crawled URL follow-up");const docReadText=assertDefaultText(await callTool(caller,"read",{target:crawledPage.docsReadTarget,start_line:1,end_line:5}),"read crawled URL default");assert(docReadText.length>0,"read crawled URL default missing content");const docReadJson=assertJsonResult(await callTool(caller,"read",{target:crawledPage.docsReadTarget,start_line:1,end_line:5,format:"json"}),"read crawled URL json");assertRecord(docReadJson,"read crawled URL json");assert(docReadJson.docsReadTarget===crawledPage.docsReadTarget&&docReadJson.pageId===crawledPage.pageId&&docReadJson.sourceUrl===crawledPage.sourceUrl&&typeof docReadJson.content==="string"&&docReadJson.startLine===1&&typeof docReadJson.endLine==="number"&&docReadJson.endLine>=1&&docReadJson.endLine<=5&&typeof docReadJson.totalLines==="number"&&docReadJson.totalLines>=docReadJson.endLine,"read crawled URL json missing locators, content, or backend range");const legacyCrawledRead=assertJsonResult(await callTool(caller,"read",{target:crawledPage.pageId,start_line:1,end_line:5,format:"json"}),"read legacy crawled ID json");assertRecord(legacyCrawledRead,"read legacy crawled ID json");assert(legacyCrawledRead.pageId===docReadJson.pageId&&legacyCrawledRead.content===docReadJson.content,"read URL and legacy crawled ID returned different ranged content");const repoRead=assertJsonResult(await callTool(caller,"read",{target:repoPage.docsReadTarget,format:"json"}),"read repo-backed ID json");assertRecord(repoRead,"read repo-backed ID json");assert(repoRead.docsReadTarget===repoPage.docsReadTarget&&repoRead.pageId===repoPage.pageId&&typeof repoRead.content==="string"&&typeof repoRead.totalLines==="number"&&(repoRead.totalLines===0||typeof repoRead.startLine==="number"&&typeof repoRead.endLine==="number"),"read repo-backed ID json missing snapshot locators, content, or range");assertErrorCode(await callTool(caller,"read",{target:"https://docs.example.invalid/githits-smoke-unknown",format:"json"}),"read unknown URL","NOT_FOUND");const codeFilesText=assertDefaultText(await callTool(caller,"code_files",{target:SMOKE_PACKAGE_TARGET,path_prefix:"package.json",limit:1}),"code_files default");assert(codeFilesText.includes("package.json"),"code_files default missing package.json");const codeFilesJson=assertJsonResult(await callTool(caller,"code_files",{target:SMOKE_PACKAGE_TARGET,path_prefix:"package.json",limit:1,format:"json"}),"code_files json");assertRecord(codeFilesJson,"code_files json");assert(Array.isArray(codeFilesJson.files),"code_files json missing files array");const codeReadText=assertDefaultText(await callTool(caller,"read",{target:`npm:express@${SMOKE_PACKAGE_VERSION}`,path:"package.json",start_line:1,end_line:5}),"read default");assert(/^1\s+/m.test(codeReadText),"read default missing line numbers");const codeReadJson=assertJsonResult(await callTool(caller,"read",{target:`npm:express@${SMOKE_PACKAGE_VERSION}`,path:"package.json",start_line:1,end_line:5,format:"json"}),"read json");assertRecord(codeReadJson,"read json");assert(codeReadJson.path==="package.json","read json path mismatch");const codeGrepText=assertDefaultText(await callTool(caller,"code_grep",{target:SMOKE_PACKAGE_TARGET,pattern:"express",path:"package.json",max_matches:1,context_lines_after:12}),"code_grep default");assert(codeGrepText.includes("package.json"),"code_grep default missing package.json");assert(codeGrepText.includes("requested 0 / 12"),"code_grep missing context clamping notice");const codeGrepJson=assertJsonResult(await callTool(caller,"code_grep",{target:SMOKE_PACKAGE_TARGET,pattern:"express",path:"package.json",max_matches:1,context_lines_after:12,format:"json"}),"code_grep json");assertRecord(codeGrepJson,"code_grep json");assert("matches"in codeGrepJson||"totalMatches"in codeGrepJson,"code_grep json missing matches");assertRecord(codeGrepJson.contextClamping,"code_grep context clamping");assert(codeGrepJson.contextClamping.requestedAfter===12&&codeGrepJson.contextClamping.effectiveAfter===10,"code_grep context clamping mismatch");assertErrorCode(await callTool(caller,"search",{target:SMOKE_PACKAGE_TARGET,query:"router",source:"docs",path_prefix:"docs/",format:"json"}),"search unsupported path prefix","INVALID_ARGUMENT");const searchText=assertDefaultText(await callTool(caller,"search",{target:SMOKE_PACKAGE_TARGET,query:"router",limit:1}),"search default");assertSearchDefaultText(searchText,"search default");const searchJson=assertJsonResult(await callTool(caller,"search",{target:SMOKE_PACKAGE_TARGET,query:"router",limit:1,format:"json"}),"search json");assertRecord(searchJson,"search json");const searchRef=typeof searchJson.searchRef==="string"?searchJson.searchRef:undefined;if(searchRef){const statusJson=assertJsonResult(await callTool(caller,"search_status",{search_ref:searchRef,wait_timeout_ms:0,format:"json"}),"search_status json");assertRecord(statusJson,"search_status json");assert("completed"in statusJson||"progress"in statusJson,"search_status json missing status data")}else{assertErrorCode(await callTool(caller,"search_status",{search_ref:"smoke-invalid-search-ref",wait_timeout_ms:0}),"search_status invalid ref","NOT_FOUND")}}async function runMcpSmoke(caller,options={}){const logger=options.logger??console;const includeLiveTools=options.includeLiveTools??true;const toolsResponse=await caller.listTools();const toolNames=new Set(toolsResponse.tools.map((tool)=>tool.name));assert(!toolNames.has("feedback"),"listTools advertises removed feedback tool");for(const expected of EXPECTED_MCP_TOOLS){assert(toolNames.has(expected),`listTools missing ${expected}`)}for(const tool of toolsResponse.tools){assert(tool.annotations?.readOnlyHint===true,`${tool.name} must advertise readOnlyHint: true`)}const quickStart=assertDefaultText(await callTool(caller,"quick_start",{}),"quick_start default");for(const expected of["GitHits routing guide","`search`","`code_grep`"]){assert(quickStart.includes(expected),`quick_start default missing ${expected}`)}if(!includeLiveTools)return;if(await assertLiveOrAuthRequired(caller,logger)){await runLiveSmoke(caller);logger.log("MCP smoke passed")}}export{EXPECTED_MCP_TOOLS,assertCleanErrorEnvelope,assertDefaultText,assertHttpUnauthorizedChallenge,assertJsonResult,callToolText,resultText,runMcpSmoke};
package/dist/tools.js CHANGED
@@ -1 +1 @@
1
- import{createGetExampleTool2}from"./shared/chunk-8xv6evhm.js";import{AuthenticationError2,ApiRateLimitError2,FetchTimeoutError2,TermsAcceptanceRequiredError2}from"./shared/chunk-q07qg1z9.js";import{z}from"zod";function toCallableTool(definition){const input=z.object(definition.schema);const inputSchema=z.toJSONSchema(input,{io:"input"});return{name:definition.name,description:definition.description,inputSchema,annotations:definition.annotations,execute:async(value,options)=>{const args=input.parse(value);const context={authAction:"Authenticate with GitHits, then retry.",...options?.signal?{signal:options.signal}:{}};return definition.handler(args,context)}}}var AuthenticationError=AuthenticationError2;var ApiRateLimitError=ApiRateLimitError2;var FetchTimeoutError=FetchTimeoutError2;var TermsAcceptanceRequiredError=TermsAcceptanceRequiredError2;export{ApiRateLimitError,AuthenticationError,FetchTimeoutError,TermsAcceptanceRequiredError,createGetExampleTool2 as createGetExampleTool,toCallableTool};
1
+ import{createGetExampleTool2}from"./shared/chunk-mee23na1.js";import{AuthenticationError2,ApiRateLimitError2,FetchTimeoutError2,TermsAcceptanceRequiredError2}from"./shared/chunk-q07qg1z9.js";import{z}from"zod";function toCallableTool(definition){const input=z.object(definition.schema);const inputSchema=z.toJSONSchema(input,{io:"input"});return{name:definition.name,description:definition.description,inputSchema,annotations:definition.annotations,execute:async(value,options)=>{const args=input.parse(value);const context={authAction:"Authenticate with GitHits, then retry.",...options?.signal?{signal:options.signal}:{}};return definition.handler(args,context)}}}var AuthenticationError=AuthenticationError2;var ApiRateLimitError=ApiRateLimitError2;var FetchTimeoutError=FetchTimeoutError2;var TermsAcceptanceRequiredError=TermsAcceptanceRequiredError2;export{ApiRateLimitError,AuthenticationError,FetchTimeoutError,TermsAcceptanceRequiredError,createGetExampleTool2 as createGetExampleTool,toCallableTool};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@githits/mcp",
3
- "version": "0.16.2",
3
+ "version": "0.17.0",
4
4
  "description": "Reusable MCP server APIs and tools for GitHits",
5
5
  "type": "module",
6
6
  "files": [