@githits/mcp 0.38.0 → 0.39.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.
@@ -3,7 +3,7 @@ var EXPECTED_MCP_TOOLS=["quick_start","get_example","search","search_status","li
3
3
  `).find((value)=>value.startsWith(" after="));assert(line!==undefined,`${context}: missing after continuation`);const parsed=parseJson(line.slice(" after=".length),context);assert(typeof parsed==="string"&&parsed.length>0,`${context}: invalid after continuation`);return parsed}function assertGrepResult(value,context){assertRecord(value,context);assert(Array.isArray(value.pathWarnings)&&value.pathWarnings.every((warning)=>typeof warning==="string"),`${context}: pathWarnings must contain compact warning strings`);assert(Array.isArray(value.hits),`${context}: hits must be an array`);assert(Array.isArray(value.targets),`${context}: targets must be an array`);assert(Array.isArray(value.unavailableTargets),`${context}: unavailableTargets must be an array`);assert(["COMPLETE","RESUMABLE_LIMIT","NON_RESUMABLE_PARTIAL","FAILED","CURSOR_EXPIRED"].includes(value.traversal),`${context}: unknown traversal state`);assert(value.nextCursor===null||typeof value.nextCursor==="string"&&value.nextCursor.length>0,`${context}: invalid nextCursor`);assert(Number.isSafeInteger(value.totalMatches)&&value.totalMatches>=0,`${context}: invalid totalMatches`);if(value.traversal==="RESUMABLE_LIMIT"){assert(typeof value.nextCursor==="string"&&value.nextCursor.length>0,`${context}: resumable page missing nextCursor`)}const targetByIndex=new Map;for(const[index,target]of value.targets.entries()){assertRecord(target,`${context}.targets[${index}]`);assert(Number.isSafeInteger(target.targetIndex),`${context}.targets[${index}]: invalid targetIndex`);assert(Array.isArray(target.requestedInputIndices)&&target.requestedInputIndices.every(Number.isSafeInteger),`${context}.targets[${index}]: invalid requestedInputIndices`);assert(target.kind==="REPOSITORY"||target.kind==="SITE",`${context}.targets[${index}]: invalid kind`);assert(["UNSPECIFIED","CURRENT","STALE","NOT_AVAILABLE","MISSING_REF","READER_OPEN_FAILED","INCOMPLETE","RESOURCE_LIMIT","VERSION_UNSUPPORTED","READ_FAILED"].includes(target.readiness)&&["COMPLETE","RESUMABLE_LIMIT","NON_RESUMABLE_PARTIAL","FAILED","CURSOR_EXPIRED"].includes(target.traversal),`${context}.targets[${index}]: missing readiness or traversal`);targetByIndex.set(target.targetIndex,target)}for(const[index,hit]of value.hits.entries()){const hitContext=`${context}.hits[${index}]`;assertRecord(hit,hitContext);const scope=targetByIndex.get(hit.targetIndex);assert(scope,`${hitContext}: no matching target status`);assertRecord(hit.read,`${hitContext}.read`);assert(typeof hit.read.target==="string"&&Number.isSafeInteger(hit.read.startLine)&&Number.isSafeInteger(hit.read.endLine),`${hitContext}: incomplete read action`);assertRecord(hit.lineSlice,`${hitContext}.lineSlice`);assert(typeof hit.lineSlice.content==="string"&&Number.isSafeInteger(hit.matchStartByte)&&Number.isSafeInteger(hit.matchEndByte),`${hitContext}: incomplete match evidence`);if(hit.__typename==="GrepRepositoryHit"){assert(scope.kind==="REPOSITORY"&&typeof hit.read.path==="string"&&typeof hit.filePath==="string",`${hitContext}: invalid repository hit or read action`)}else if(hit.__typename==="GrepSiteHit"){assert(scope.kind==="SITE"&&hit.read.path===null&&typeof hit.pageUrl==="string",`${hitContext}: invalid hosted documentation hit or read action`)}else{throw new Error(`${hitContext}: unknown hit type`)}}return value}function grepReadArgs(hit,format){const read=hit.read;return{target:read.target,...typeof read.path==="string"?{path:read.path}:{},start_line:read.startLine,end_line:read.endLine,...format?{format}:{}}}function assertSearchDefaultText(text,context){const lines=text.split(`
4
4
  `);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(`
5
5
  `);const firstLine=lines[0]?.trim()??"";assert(firstLine.length>0,`${context}: missing outcome first line`);assert(/^(?:Found \d+ |No results? )/.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 outcomeLines=formatterLines.filter((line)=>/^(?:Found \d+ |No results? )/.test(line));assert(outcomeLines.length===1,`${context}: duplicate 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 footerLabels=["Read:","More results:","Follow-up:"];const presentFooters=formatterLines.filter((line)=>footerLabels.includes(line));assert(new Set(presentFooters).size===presentFooters.length,`${context}: duplicated footer section`);assert(presentFooters.join()===footerLabels.filter((label)=>presentFooters.includes(label)).join(),`${context}: footer sections out of order`);assert(!firstLine.includes("|")&&!/partial|interim|ready|offset/.test(firstLine),`${context}: headline must contain only the outcome`);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 statusActions=formatterLines.filter((line)=>line.startsWith(" search_status "));const searchRefOccurrences=formatterText.match(/search_ref=/g)?.length??0;assert(statusActions.length<=1&&searchRefOccurrences===statusActions.length,`${context}: expected at most one native status action`);const statusAction=statusActions[0];if(statusAction){assert(formatterLines.includes("Follow-up:")&&formatterLines.indexOf("Follow-up:")<formatterLines.indexOf(statusAction),`${context}: status action must be in Follow-up`);assert(/^ {2}search_status search_ref="[^"]+" wait_timeout_ms=\d+$/.test(statusAction),`${context}: invalid native status action`)}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)||formatterLines.includes("Follow-up:")||formatterLines.includes("More results:"),`${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}`)}function assertInlineSearchSuccess(value,expectedQuery,context){assertRecord(value,context);assertRecord(value.query,`${context}: query`);assert(value.query.raw===expectedQuery,`${context}: raw query mismatch`);assert(Array.isArray(value.results)&&value.results.length>0,`${context}: missing ranked results`);for(const[index,result]of value.results.entries()){assertRecord(result,`${context}: results[${index}]`);assertRecord(result.locator,`${context}: results[${index}].locator`);const filePath=result.locator.filePath;assert(typeof filePath==="string"&&filePath.startsWith("lib/")&&filePath.endsWith(".js"),`${context}: result escaped JavaScript lib/ scope`)}if("warnings"in value){assert(Array.isArray(value.warnings),`${context}: warnings must be an array`)}if(!("sourceStatus"in value))return;assert(Array.isArray(value.sourceStatus),`${context}: sourceStatus must be an array`);const unsupportedFeatures=[];for(const[index,entry]of value.sourceStatus.entries()){assertRecord(entry,`${context}: sourceStatus[${index}] must be an object`);for(const field of["ignoredQueryFeatures","incompatibleQueryFeatures"]){const features=entry[field];if(features===undefined)continue;assert(Array.isArray(features),`${context}: sourceStatus[${index}].${field} must be an array`);for(const feature of features){assert(typeof feature==="string",`${context}: sourceStatus[${index}].${field} must contain strings`);unsupportedFeatures.push(feature)}}}if(unsupportedFeatures.length===0)return;assert(Array.isArray(value.warnings),`${context}: unsupported qualifiers must be surfaced in warnings`);const warningText=value.warnings.join(" ").toLowerCase();for(const feature of unsupportedFeatures){assert(warningText.includes(feature.toLowerCase()),`${context}: qualifier ${feature} was lost without a warning`)}}function assertInlineSearchError(result,context){const envelope=assertCleanErrorEnvelope(result,context);assert(envelope.code==="INVALID_ARGUMENT",`${context}: expected INVALID_ARGUMENT, got ${envelope.code}`);assert(envelope.retryable===false,`${context}: error must not be retryable`);for(const field of["searchRef","search_ref","continuation"]){assert(!(field in envelope),`${context}: error exposed ${field}`)}}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,"pkg_info",{target:"npm:express",format:"json"});if(result.isError===true){const envelope=assertCleanErrorEnvelope(result,"pkg_info auth probe");assert(envelope.code==="AUTH_REQUIRED",`auth probe returned unexpected code ${envelope.code}`);const authAction=envelope.details?.action;assert(typeof authAction==="string"&&authAction.trim().length>0,"pkg_info auth probe: missing authentication action");for(const[format,label]of[[undefined,"omitted"],["text","text"]]){const textResult=await callTool(caller,"pkg_info",{target:"npm:express",...format===undefined?{}:{format}});const context=`pkg_info ${label} auth probe`;assert(textResult.isError===true,`${context}: expected MCP error result`);const text=resultText(textResult,context);assertNotJson(text,context);assert(text.includes(authAction),`${context}: missing authentication action from JSON probe`)}logger.log("AUTH_REQUIRED: live smoke skipped");return false}return true}function isResolveDirectTargetUnwarned(output,target){if(/^Warning:/m.test(output))return false;const escapedTarget=target.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");const candidatePattern=new RegExp(`^(?: {2}\\d+\\. | {7})${escapedTarget}(?:\\s|$)`);const lines=output.split(`
6
- `);const candidateIndex=lines.findIndex((line)=>candidatePattern.test(line));if(candidateIndex<0)return false;const candidateLine=lines[candidateIndex]??"";const nested=candidateLine.startsWith(" ");if(candidateLine.includes(" · related ")||candidateLine.includes("[related;")){return false}const detailIndent=nested?" ":" ";for(let index=candidateIndex+1;index<lines.length;index+=1){const line=lines[index]??"";if(line.trim()==="Related targets:")break;if(!line.startsWith(detailIndent))break;if(line.includes("Warning:"))return false}return true}function assertMcpResolveText(resolveTextBody){assert(resolveTextBody.includes("npm:express")&&!resolveTextBody.includes("githits ")&&!resolveTextBody.includes("--"),"resolve text should include MCP-native candidate guidance");const directTarget=resolveTextBody.match(/Next: pass the returned target "([^"]+)"/)?.[1];if(directTarget){assert(isResolveDirectTargetUnwarned(resolveTextBody,directTarget),"direct resolve action should target a listed direct candidate without a warning");return}if(resolveTextBody.includes("Warning:")){assert(!resolveTextBody.includes("Next:"),"malicious-blocked resolve text should omit the normal next action")}else if(resolveTextBody.includes("Ambiguous:")){assert(resolveTextBody.includes("never auto-select")&&resolveTextBody.includes("explicitly choose a candidate"),"ambiguous resolve text should require an explicit choice")}else{assert(resolveTextBody.includes("never auto-select the best match")&&resolveTextBody.includes("explicitly choose a candidate"),"unconfirmed resolve text should require an explicit choice")}}async function runLiveSmoke(caller){for(const probe of[{tool:"pkg_deps",target:"npm:express@99.99.99",code:"VERSION_NOT_FOUND",fact:"availablePackageVersions"},{tool:"list",target:"github:expressjs/express@v99.99.99-nope",code:"REF_NOT_FOUND",fact:"suggestedRefs"}]){const result=await callTool(caller,probe.tool,{target:probe.target});assert(result.isError===true,"recovery probe must fail for the original target");const text=resultText(result,"version/ref recovery text");assert(text.includes(`Retry ${probe.tool} with target=`),"recovery probe missing native argument correction");const envelope=assertCleanErrorEnvelope(await callTool(caller,probe.tool,{target:probe.target,format:"json"}),"version/ref recovery JSON");assert(envelope.code===probe.code,"recovery probe lost backend error code");const details=envelope.details;const alternatives=details?.[probe.fact];assert(Array.isArray(alternatives)&&alternatives.length>0,"recovery probe dropped structured alternatives");assert(typeof details?.action==="string"&&details.action.startsWith(`Retry ${probe.tool} with target=`),"recovery probe JSON missing native action")}await runResolveSmoke(caller);const diffArgs={target:"npm:express",from:"5.2.0",to:"5.2.1",max_files:2};const diffText=assertDefaultText(await callTool(caller,"code_diff",diffArgs),"code_diff default");assert(diffText.includes("Resolved endpoints:")&&diffText.includes("Scope: repository"),"code_diff default missing exact resolution or scope");const diffJson=assertJsonResult(await callTool(caller,"code_diff",{...diffArgs,format:"json"}),"code_diff json");assertRecord(diffJson,"code_diff json");assertRecord(diffJson.from,"code_diff from");assertRecord(diffJson.to,"code_diff to");assertRecord(diffJson.scope,"code_diff scope");assert(diffJson.view==="name-status"&&diffJson.from.requested===diffArgs.from&&diffJson.to.requested===diffArgs.to&&diffJson.scope.status==="repository","code_diff default projection or identity mismatch");assert(Array.isArray(diffJson.files)&&diffJson.files.length>0&&diffJson.files.length<=2&&diffJson.hasMoreFiles===true,"code_diff file bound or truncation missing");const diffPatch=assertJsonResult(await callTool(caller,"code_diff",{...diffArgs,view:"patch",path_glob:"lib/utils.js",format:"json"}),"code_diff scoped patch");assertRecord(diffPatch,"code_diff scoped patch");assert(diffPatch.view==="patch"&&Array.isArray(diffPatch.files)&&diffPatch.files.length===1,"code_diff scoped patch missing filtered file");const diffFile=diffPatch.files[0];assertRecord(diffFile,"code_diff patch file");assert(diffFile.path==="lib/utils.js"&&typeof diffFile.patch==="string"&&diffFile.patch.startsWith("diff --git"),"code_diff scoped patch missing unified content");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",{target:"npm: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",{target:"npm:express",format:"json"}),"pkg_info json");let rustVersion;for(const target of["crates:serde","cargo:serde"]){const context=`pkg_info ${target}`;const metadata=assertJsonResult(await callTool(caller,"pkg_info",{target,format:"json"}),context);assertRecord(metadata,context);assert(metadata.registry==="crates"&&metadata.name==="serde",`${context}: expected canonical crates identity`);assert(typeof metadata.version==="string",`${context}: missing version`);if(rustVersion!==undefined)assert(metadata.version===rustVersion,`${context}: alias version mismatch`);rustVersion=metadata.version}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",{target:"npm: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",{target:"npm: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",{target:"npm: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",{target:"npm: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",{target:"npm: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",{target:"npm: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",{target: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",{target: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",{target:"npm:lodash@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",{target:"npm: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",{target:"npm:lodash@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",{target:"npm:express",advisory_scope:"non_affecting"}),"pkg_vulns scoped default");assert(scopedVulnsText.includes("Scope non-affecting 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",{target:"npm: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 unknownVulnsText=assertDefaultText(await callTool(caller,"pkg_vulns",{target:"npm:lodash@4.17.20",advisory_scope:"unknown"}),"pkg_vulns unknown scope");assert(unknownVulnsText.includes("Scope unknown"),"pkg_vulns unknown scope missing scope echo");const unknownVulnsJson=assertJsonResult(await callTool(caller,"pkg_vulns",{target:"npm:lodash@4.17.20",advisory_scope:"unknown",format:"json"}),"pkg_vulns unknown json");assertRecord(unknownVulnsJson,"pkg_vulns unknown json");assertRecord(unknownVulnsJson.summary,"pkg_vulns unknown summary");assert(typeof unknownVulnsJson.summary.unknownVulnerabilityCount==="number","pkg_vulns missing unknown count");assert(typeof unknownVulnsJson.summary.assessmentStatus==="string","pkg_vulns missing assessment status in JSON");const transitiveUnknown=assertJsonResult(await callTool(caller,"pkg_vulns",{target:"pypi:torchvision@0.20.1",advisory_scope:"unknown",include_transitive:true,format:"json"}),"pkg_vulns transitive unknown");assertRecord(transitiveUnknown,"pkg_vulns transitive unknown");assertRecord(transitiveUnknown.transitive,"pkg_vulns transitive unknown audit");assertRecord(transitiveUnknown.transitive.summary,"pkg_vulns transitive unknown summary");assert(typeof transitiveUnknown.transitive.summary.unknownCount==="number","pkg_vulns missing transitive unknown count");assert(transitiveUnknown.transitive.advisoryScope==="unknown","pkg_vulns missing transitive unknown scope");assertTransitiveVulnerabilityJson(transitiveUnknown,"pkg_vulns transitive unknown");assert(Array.isArray(transitiveUnknown.transitive.packages),"pkg_vulns missing packages");for(const pkg of transitiveUnknown.transitive.packages){assertRecord(pkg,"pkg_vulns unknown package");assert(Array.isArray(pkg.occurrences),"pkg_vulns missing occurrences");for(const row of pkg.occurrences){assertRecord(row,"pkg_vulns unknown occurrence");assert(row.affectsResolvedVersion===false,"pkg_vulns unknown row claims a match");assert(typeof row.assessmentStatus==="string","pkg_vulns missing occurrence status");assert(Array.isArray(row.assessmentReasons),"pkg_vulns missing occurrence reasons")}}const changelogText=assertToolText(await callTool(caller,"pkg_changelog",{target:"npm:express",limit:1}),"pkg_changelog default");assert(!changelogText.includes("--verbose"),"pkg_changelog default leaked CLI verbose flag");if(changelogText.includes("more lines")||changelogText.includes("full bodies")){assert(changelogText.includes("pass verbatim=true"),"pkg_changelog truncation hint is not MCP-native")}const changelogBodyLinesText=assertDefaultText(await callTool(caller,"pkg_changelog",{target:"npm:express",limit:2,body_lines:3}),"pkg_changelog body_lines");if(changelogBodyLinesText.includes("more lines")||changelogBodyLinesText.includes("full bodies")){assert(changelogBodyLinesText.includes("pass verbatim=true"),"pkg_changelog body_lines missing MCP-native truncation hint")}assert(!changelogBodyLinesText.includes("--verbose"),"pkg_changelog body_lines leaked CLI verbose flag");const changelogFullBodiesText=assertToolText(await callTool(caller,"pkg_changelog",{target:"npm:express",limit:2,body_lines:3,verbatim:true}),"pkg_changelog verbose overrides preview controls");assert(!changelogFullBodiesText.includes("pass verbatim=true"),"pkg_changelog verbose still truncated body previews");const changelogJson=assertJsonResult(await callTool(caller,"pkg_changelog",{target:"npm:express",limit:1,format:"json"}),"pkg_changelog json");assertRecord(changelogJson,"pkg_changelog json");assertRecord(changelogJson.entries,"pkg_changelog json entries");assertRecord(changelogJson.statements,"pkg_changelog json statements");assert(Array.isArray(changelogJson.statements.items),"pkg_changelog json missing parsed statements");assert(Array.isArray(changelogJson.statements.coverage),"pkg_changelog json missing coverage");assert(Array.isArray(changelogJson.entries.items)&&changelogJson.entries.items.every((entry)=>typeof entry==="object"&&entry!==null&&!("body"in entry)),"pkg_changelog default JSON over-fetched note bodies");const filteredChangelog=assertJsonResult(await callTool(caller,"pkg_changelog",{target:"npm:express@5.2.1",changes:"actionable",format:"json"}),"pkg_changelog actionable");assertRecord(filteredChangelog,"pkg_changelog actionable");assertRecord(filteredChangelog.statements,"pkg_changelog filtered statements");assert(Array.isArray(filteredChangelog.statements.items)&&filteredChangelog.statements.items.every((item)=>typeof item==="object"&&item!==null&&("classification"in item)&&typeof item.classification==="object"&&item.classification!==null&&("tier"in item.classification)&&item.classification.tier==="must_act"),"pkg_changelog actionable includes another tier");const timelineChangelog=assertJsonResult(await callTool(caller,"pkg_changelog",{target:"npm:express",limit:1,omit_bodies:true,changes:"ignored",format:"json"}),"pkg_changelog timeline-only");assertRecord(timelineChangelog,"pkg_changelog timeline-only");assert(!("statements"in timelineChangelog),"pkg_changelog timeline-only classified notes");const changelogExact=assertJsonResult(await callTool(caller,"pkg_changelog",{target:"npm:express@5.2.1",format:"json"}),"pkg_changelog exact json");assertRecord(changelogExact,"pkg_changelog exact json");assert(changelogExact.mode==="exact","pkg_changelog exact json mode");const exactEntries=changelogExact.entries;assert(exactEntries?.items?.[0]?.version==="5.2.1","pkg_changelog exact json resolved version");assert(typeof exactEntries?.items?.[0]?.hasChangelog==="boolean","pkg_changelog exact json missing hasChangelog");const changelogRepo=await callTool(caller,"pkg_changelog",{target:"github:expressjs/express",format:"json"});const changelogRepoEnvelope=assertCleanErrorEnvelope(changelogRepo,"pkg_changelog repository target");assert(changelogRepoEnvelope.code==="INVALID_ARGUMENT",`pkg_changelog repository target: expected INVALID_ARGUMENT, got ${changelogRepoEnvelope.code}`);const changelogTimeline=assertDefaultText(await callTool(caller,"pkg_changelog",{target:"npm: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=assertToolText(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(`
6
+ `);const candidateIndex=lines.findIndex((line)=>candidatePattern.test(line));if(candidateIndex<0)return false;const candidateLine=lines[candidateIndex]??"";const nested=candidateLine.startsWith(" ");if(candidateLine.includes(" · related ")||candidateLine.includes("[related;")){return false}const detailIndent=nested?" ":" ";for(let index=candidateIndex+1;index<lines.length;index+=1){const line=lines[index]??"";if(line.trim()==="Related targets:")break;if(!line.startsWith(detailIndent))break;if(line.includes("Warning:"))return false}return true}function assertMcpResolveText(resolveTextBody){assert(resolveTextBody.includes("npm:express")&&!resolveTextBody.includes("githits ")&&!resolveTextBody.includes("--"),"resolve text should include MCP-native candidate guidance");const directTarget=resolveTextBody.match(/Next: pass the returned target "([^"]+)"/)?.[1];if(directTarget){assert(isResolveDirectTargetUnwarned(resolveTextBody,directTarget),"direct resolve action should target a listed direct candidate without a warning");return}if(resolveTextBody.includes("Warning:")){assert(!resolveTextBody.includes("Next:"),"malicious-blocked resolve text should omit the normal next action")}else if(resolveTextBody.includes("Ambiguous:")){assert(resolveTextBody.includes("never auto-select")&&resolveTextBody.includes("explicitly choose a candidate"),"ambiguous resolve text should require an explicit choice")}else{assert(resolveTextBody.includes("never auto-select the best match")&&resolveTextBody.includes("explicitly choose a candidate"),"unconfirmed resolve text should require an explicit choice")}}async function runLiveSmoke(caller){for(const probe of[{tool:"pkg_deps",target:"npm:express@99.99.99",code:"VERSION_NOT_FOUND",fact:"availablePackageVersions"},{tool:"list",target:"github:expressjs/express@v99.99.99-nope",code:"REF_NOT_FOUND",fact:"suggestedRefs"}]){const result=await callTool(caller,probe.tool,{target:probe.target});assert(result.isError===true,"recovery probe must fail for the original target");const text=resultText(result,"version/ref recovery text");assert(text.includes(`Retry ${probe.tool} with target=`),"recovery probe missing native argument correction");const envelope=assertCleanErrorEnvelope(await callTool(caller,probe.tool,{target:probe.target,format:"json"}),"version/ref recovery JSON");assert(envelope.code===probe.code,"recovery probe lost backend error code");const details=envelope.details;const alternatives=details?.[probe.fact];assert(Array.isArray(alternatives)&&alternatives.length>0,"recovery probe dropped structured alternatives");assert(typeof details?.action==="string"&&details.action.startsWith(`Retry ${probe.tool} with target=`),"recovery probe JSON missing native action")}await runResolveSmoke(caller);const diffArgs={target:"npm:express",from:"5.2.0",to:"5.2.1",max_files:2};const diffText=assertDefaultText(await callTool(caller,"code_diff",diffArgs),"code_diff default");assert(diffText.includes("Resolved endpoints:")&&diffText.includes("Scope: repository"),"code_diff default missing exact resolution or scope");const diffJson=assertJsonResult(await callTool(caller,"code_diff",{...diffArgs,format:"json"}),"code_diff json");assertRecord(diffJson,"code_diff json");assertRecord(diffJson.from,"code_diff from");assertRecord(diffJson.to,"code_diff to");assertRecord(diffJson.scope,"code_diff scope");assert(diffJson.view==="name-status"&&diffJson.from.requested===diffArgs.from&&diffJson.to.requested===diffArgs.to&&diffJson.scope.status==="repository","code_diff default projection or identity mismatch");assert(Array.isArray(diffJson.files)&&diffJson.files.length>0&&diffJson.files.length<=2&&diffJson.hasMoreFiles===true,"code_diff file bound or truncation missing");const diffPatch=assertJsonResult(await callTool(caller,"code_diff",{...diffArgs,view:"patch",path_glob:"lib/utils.js",format:"json"}),"code_diff scoped patch");assertRecord(diffPatch,"code_diff scoped patch");assert(diffPatch.view==="patch"&&Array.isArray(diffPatch.files)&&diffPatch.files.length===1,"code_diff scoped patch missing filtered file");const diffFile=diffPatch.files[0];assertRecord(diffFile,"code_diff patch file");assert(diffFile.path==="lib/utils.js"&&typeof diffFile.patch==="string"&&diffFile.patch.startsWith("diff --git"),"code_diff scoped patch missing unified content");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",{target:"npm: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",{target:"npm:express",format:"json"}),"pkg_info json");let rustVersion;for(const target of["crates:serde","cargo:serde"]){const context=`pkg_info ${target}`;const metadata=assertJsonResult(await callTool(caller,"pkg_info",{target,format:"json"}),context);assertRecord(metadata,context);assert(metadata.registry==="crates"&&metadata.name==="serde",`${context}: expected canonical crates identity`);assert(typeof metadata.version==="string",`${context}: missing version`);if(rustVersion!==undefined)assert(metadata.version===rustVersion,`${context}: alias version mismatch`);rustVersion=metadata.version}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.latestVersion==="string","pkg_info json missing registry latest 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",{target:"npm: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",{target:"npm: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",{target:"npm: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",{target:"npm: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",{target:"npm: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",{target:"npm: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",{target: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",{target: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",{target:"npm:lodash@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",{target:"npm: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",{target:"npm:lodash@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",{target:"npm:express",advisory_scope:"non_affecting"}),"pkg_vulns scoped default");assert(scopedVulnsText.includes("Scope non-affecting 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",{target:"npm: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 unknownVulnsText=assertDefaultText(await callTool(caller,"pkg_vulns",{target:"npm:lodash@4.17.20",advisory_scope:"unknown"}),"pkg_vulns unknown scope");assert(unknownVulnsText.includes("Scope unknown"),"pkg_vulns unknown scope missing scope echo");const unknownVulnsJson=assertJsonResult(await callTool(caller,"pkg_vulns",{target:"npm:lodash@4.17.20",advisory_scope:"unknown",format:"json"}),"pkg_vulns unknown json");assertRecord(unknownVulnsJson,"pkg_vulns unknown json");assertRecord(unknownVulnsJson.summary,"pkg_vulns unknown summary");assert(typeof unknownVulnsJson.summary.unknownVulnerabilityCount==="number","pkg_vulns missing unknown count");assert(typeof unknownVulnsJson.summary.assessmentStatus==="string","pkg_vulns missing assessment status in JSON");const transitiveUnknown=assertJsonResult(await callTool(caller,"pkg_vulns",{target:"pypi:torchvision@0.20.1",advisory_scope:"unknown",include_transitive:true,format:"json"}),"pkg_vulns transitive unknown");assertRecord(transitiveUnknown,"pkg_vulns transitive unknown");assertRecord(transitiveUnknown.transitive,"pkg_vulns transitive unknown audit");assertRecord(transitiveUnknown.transitive.summary,"pkg_vulns transitive unknown summary");assert(typeof transitiveUnknown.transitive.summary.unknownCount==="number","pkg_vulns missing transitive unknown count");assert(transitiveUnknown.transitive.advisoryScope==="unknown","pkg_vulns missing transitive unknown scope");assertTransitiveVulnerabilityJson(transitiveUnknown,"pkg_vulns transitive unknown");assert(Array.isArray(transitiveUnknown.transitive.packages),"pkg_vulns missing packages");for(const pkg of transitiveUnknown.transitive.packages){assertRecord(pkg,"pkg_vulns unknown package");assert(Array.isArray(pkg.occurrences),"pkg_vulns missing occurrences");for(const row of pkg.occurrences){assertRecord(row,"pkg_vulns unknown occurrence");assert(row.affectsResolvedVersion===false,"pkg_vulns unknown row claims a match");assert(typeof row.assessmentStatus==="string","pkg_vulns missing occurrence status");assert(Array.isArray(row.assessmentReasons),"pkg_vulns missing occurrence reasons")}}const changelogText=assertToolText(await callTool(caller,"pkg_changelog",{target:"npm:express",limit:1}),"pkg_changelog default");assert(!changelogText.includes("--verbose"),"pkg_changelog default leaked CLI verbose flag");if(changelogText.includes("more lines")||changelogText.includes("full bodies")){assert(changelogText.includes("pass verbatim=true"),"pkg_changelog truncation hint is not MCP-native")}const changelogBodyLinesText=assertDefaultText(await callTool(caller,"pkg_changelog",{target:"npm:express",limit:2,body_lines:3}),"pkg_changelog body_lines");if(changelogBodyLinesText.includes("more lines")||changelogBodyLinesText.includes("full bodies")){assert(changelogBodyLinesText.includes("pass verbatim=true"),"pkg_changelog body_lines missing MCP-native truncation hint")}assert(!changelogBodyLinesText.includes("--verbose"),"pkg_changelog body_lines leaked CLI verbose flag");const changelogFullBodiesText=assertToolText(await callTool(caller,"pkg_changelog",{target:"npm:express",limit:2,body_lines:3,verbatim:true}),"pkg_changelog verbose overrides preview controls");assert(!changelogFullBodiesText.includes("pass verbatim=true"),"pkg_changelog verbose still truncated body previews");const changelogJson=assertJsonResult(await callTool(caller,"pkg_changelog",{target:"npm:express",limit:1,format:"json"}),"pkg_changelog json");assertRecord(changelogJson,"pkg_changelog json");assertRecord(changelogJson.entries,"pkg_changelog json entries");assertRecord(changelogJson.statements,"pkg_changelog json statements");assert(Array.isArray(changelogJson.statements.items),"pkg_changelog json missing parsed statements");assert(Array.isArray(changelogJson.statements.coverage),"pkg_changelog json missing coverage");assert(Array.isArray(changelogJson.entries.items)&&changelogJson.entries.items.every((entry)=>typeof entry==="object"&&entry!==null&&!("body"in entry)),"pkg_changelog default JSON over-fetched note bodies");const filteredChangelog=assertJsonResult(await callTool(caller,"pkg_changelog",{target:"npm:express@5.2.1",changes:"actionable",format:"json"}),"pkg_changelog actionable");assertRecord(filteredChangelog,"pkg_changelog actionable");assertRecord(filteredChangelog.statements,"pkg_changelog filtered statements");assert(Array.isArray(filteredChangelog.statements.items)&&filteredChangelog.statements.items.every((item)=>typeof item==="object"&&item!==null&&("classification"in item)&&typeof item.classification==="object"&&item.classification!==null&&("tier"in item.classification)&&item.classification.tier==="must_act"),"pkg_changelog actionable includes another tier");const timelineChangelog=assertJsonResult(await callTool(caller,"pkg_changelog",{target:"npm:express",limit:1,omit_bodies:true,changes:"ignored",format:"json"}),"pkg_changelog timeline-only");assertRecord(timelineChangelog,"pkg_changelog timeline-only");assert(!("statements"in timelineChangelog),"pkg_changelog timeline-only classified notes");const changelogExact=assertJsonResult(await callTool(caller,"pkg_changelog",{target:"npm:express@5.2.1",format:"json"}),"pkg_changelog exact json");assertRecord(changelogExact,"pkg_changelog exact json");assert(changelogExact.mode==="exact","pkg_changelog exact json mode");const exactEntries=changelogExact.entries;assert(exactEntries?.items?.[0]?.version==="5.2.1","pkg_changelog exact json resolved version");assert(typeof exactEntries?.items?.[0]?.hasChangelog==="boolean","pkg_changelog exact json missing hasChangelog");const changelogRepo=await callTool(caller,"pkg_changelog",{target:"github:expressjs/express",format:"json"});const changelogRepoEnvelope=assertCleanErrorEnvelope(changelogRepo,"pkg_changelog repository target");assert(changelogRepoEnvelope.code==="INVALID_ARGUMENT",`pkg_changelog repository target: expected INVALID_ARGUMENT, got ${changelogRepoEnvelope.code}`);const changelogTimeline=assertDefaultText(await callTool(caller,"pkg_changelog",{target:"npm: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=assertToolText(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(`
7
7
  `)[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(`
8
8
  Security
9
9
  `)&&upgradeReviewText.includes(`
package/dist/tools.d.ts CHANGED
@@ -1,4 +1,15 @@
1
1
  /**
2
+ * Optional per-call controls shared by network-backed service methods.
3
+ *
4
+ * `signal` is the caller's cancellation signal, such as an MCP request
5
+ * cancellation. Services combine it with their own request deadline: a caller
6
+ * abort rejects with the signal's reason and is never retried, while an
7
+ * internal deadline keeps each service's timeout error mapping.
8
+ */
9
+ interface ServiceRequestOptions {
10
+ signal?: AbortSignal;
11
+ }
12
+ /**
2
13
  * Optional per-call progress correlation for backend requests.
3
14
  *
4
15
  * Progress is best effort: the HTTP result stays authoritative. The backend
@@ -56,17 +67,6 @@ declare const registryMap: {
56
67
  readonly pub: "PUB";
57
68
  };
58
69
  type PkgseerRegistry = (typeof registryMap)[keyof typeof registryMap];
59
- /**
60
- * Optional per-call controls shared by network-backed service methods.
61
- *
62
- * `signal` is the caller's cancellation signal, such as an MCP request
63
- * cancellation. Services combine it with their own request deadline: a caller
64
- * abort rejects with the signal's reason and is never retried, while an
65
- * internal deadline keeps each service's timeout error mapping.
66
- */
67
- interface ServiceRequestOptions {
68
- signal?: AbortSignal;
69
- }
70
70
  type ResolveTargetKind = "PACKAGE" | "REPOSITORY" | "SITE";
71
71
  type KnownLatestVersionMaliciousStatus = "NOT_APPLICABLE" | "CLEAR" | "AFFECTED" | "UNKNOWN";
72
72
  /**
package/dist/tools.js CHANGED
@@ -1 +1 @@
1
- import{ProviderReauthenticationRequiredError2,TermsAcceptanceRequiredError2,FetchTimeoutError2,AuthenticationError2,ApiRateLimitError2}from"./shared/chunk-99jxrjze.js";import{createGetExampleTool2,createResearchTool2,createResolveTargetTool2}from"./shared/chunk-j3smtn4t.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 ProviderReauthenticationRequiredError=ProviderReauthenticationRequiredError2;var AuthenticationError=AuthenticationError2;var ApiRateLimitError=ApiRateLimitError2;var FetchTimeoutError=FetchTimeoutError2;var TermsAcceptanceRequiredError=TermsAcceptanceRequiredError2;export{ApiRateLimitError,AuthenticationError,FetchTimeoutError,ProviderReauthenticationRequiredError,TermsAcceptanceRequiredError,createGetExampleTool2 as createGetExampleTool,createResearchTool2 as createResearchTool,createResolveTargetTool2 as createResolveTargetTool,toCallableTool};
1
+ import{ProviderReauthenticationRequiredError2,TermsAcceptanceRequiredError2,FetchTimeoutError2,AuthenticationError2,ApiRateLimitError2}from"./shared/chunk-yv5er0y7.js";import{createGetExampleTool2,createResearchTool2,createResolveTargetTool2}from"./shared/chunk-k55ev4d4.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 ProviderReauthenticationRequiredError=ProviderReauthenticationRequiredError2;var AuthenticationError=AuthenticationError2;var ApiRateLimitError=ApiRateLimitError2;var FetchTimeoutError=FetchTimeoutError2;var TermsAcceptanceRequiredError=TermsAcceptanceRequiredError2;export{ApiRateLimitError,AuthenticationError,FetchTimeoutError,ProviderReauthenticationRequiredError,TermsAcceptanceRequiredError,createGetExampleTool2 as createGetExampleTool,createResearchTool2 as createResearchTool,createResolveTargetTool2 as createResolveTargetTool,toCallableTool};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@githits/mcp",
3
- "version": "0.38.0",
3
+ "version": "0.39.0",
4
4
  "description": "Reusable MCP server APIs and tools for GitHits",
5
5
  "type": "module",
6
6
  "files": [