Lines 1-21javascript
1import{a as e,n as t,o as n,r,s as i,t as a}from"./import-resolver-BYpgxrwI.js";import{access as o,mkdir as s,readFile as c,readdir as l,rename as u,stat as d,writeFile as f}from"node:fs/promises";import{basename as p,dirname as m,extname as h,isAbsolute as g,join as _,relative as v,resolve as y,sep as b}from"node:path";import{DependencyAnalyzer as x,DiagramGenerator as S,EntryPointAnalyzer as C,PatternAnalyzer as w,StructureAnalyzer as T,SymbolAnalyzer as ee,extractRegexCallGraph as te,extractTsCallGraph as ne}from"../../analyzers/dist/index.js";import{exec as E,execFile as D,execFileSync as ...
2`)){if(!a)continue;if(a.startsWith(`## `)){i=a.slice(3).split(`...`)[0];continue}let e=a[0],o=a[1],s=a.slice(3).trim();e===`?`&&o===`?`?r.push(s):(e!==` `&&e!==`?`&&t.push({status:$e(e),file:s}),o!==` `&&o!==`?`&&n.push({status:$e(o),file:s}))}return{staged:t,unstaged:n,untracked:r,branch:i}}function $e(e){return{M:`modified`,A:`added`,D:`deleted`,R:`renamed`,C:`copied`,U:`unmerged`}[e]??e}function et(e,t){let n=t??tt(e);switch(n){case`tsc`:return{tool:`tsc
3`).trim()||t.message||`Command failed`}async function ot(e={}){if(it>=2)throw Error(`Too many concurrent check runs (${it}/2). Retry when one finishes or use targeted check({ files: [...] }).`);it++;try{return await st(e)}finally{it--}}async function st(e){let t=e.cwd??process.cwd(),n={errors:[],passed:!0,raw:``},r={errors:[],passed:!0,raw:``};if(!e.skipTypes)try{if(e.files?.length){let n=[`--noEmit`,...e.files];await nt(`npx --yes tsc ${n.join(` `)}`,{cwd:t,timeout:rt})}else{let e=_(t,`package.json`),n=null;try{n=JSON.parse(await c(e,`utf-8`)).scripts?.typecheck??null}catch{}n?await nt(`npm r ...
4`).length-1,a=t.slice(r).match(/export\s+(?:async\s+)?(\w+)/);l.push({name:n[1],path:e.record.sourcePath,line:e.record.startLine+i,kind:a?.[1]??`unknown`})}}let f=/* @__PURE__ */ new Map;for(let e of l){let t=`${e.path}:${e.name}`;f.has(t)||f.set(t,e)}let p=[];for(let e of f.values()){let n=lt(e.name),r=RegExp(`import\\s+.*\\b${n}\\b.*from`,`m`),i=RegExp(`export\\s+\\{[^}]*\\b${n}\\b`,`m`),a=await t.ftsSearch(`import ${e.name}`,{limit:10}),o=a.some(t=>t.record.sourcePath!==e.path&&r.test(t.record.content)),s=a.some(t=>t.record.sourcePath!==e.path&&i.test(t.record.content));!o&&!s&&p.push(e)}le ...
5`)){let e=t.match(/^\s*-\s+['"]?([^'"#\s]+)['"]?\s*$/);e&&n.push(e[1])}}let i=[];for(let t of n)if(t.endsWith(`/*`)||t.endsWith(`/**`)){let n=_(e,t.replace(/\/\*+$/,``));if(F(n))try{for(let e of R(n,{withFileTypes:!0}))e.isDirectory()&&F(_(n,e.name,`package.json`))&&i.push(_(n,e.name))}catch{}}else{let n=_(e,t);F(_(n,`package.json`))&&i.push(n)}return i}function gt(e,t,n){let r=0,i=0,a=/* @__PURE__ */ new Map;for(let e of t)try{let t=JSON.parse(L(_(e,`package.json`),`utf-8`));t.scripts?.test||r++,!t.exports&&!t.main&&i++;let n={...t.dependencies,...t.devDependencies};for(let e of Object.values ...
6`).map(e=>e.trim()).filter(e=>e.length>0)}}function jt(e){let t=[];for(let n of e){if(n.length<=Ot){t.push(n);continue}let e=n.split(`
7`),r=``;for(let n of e){let e=Mt(n);for(let n of e)r.length+n.length+1>Ot&&r.length>0&&(t.push(r.trim()),r=``),r+=(r.length>0?`
HighCloud Metadata Access
Source reaches cloud instance metadata or link-local credential endpoints.
packages/tools/dist/index.jsView on unpkg · L1 MediumUnsafe Vm Context
Package source executes code through a VM context API.
packages/tools/dist/index.jsView on unpkg · L1 LowWeak Crypto
Package source references weak cryptographic algorithms.
packages/tools/dist/index.jsView on unpkg · L1 8`:``)+n}r.trim().length>0&&t.push(r.trim())}return t}function Mt(e){if(e.length<=Ot)return e.trim().length>0?[e]:[];let t=[];for(let n=0;n<e.length;n+=Ot)t.push(e.slice(n,n+Ot));return t}function Nt(e,t){let n=0,r=0,i=0;for(let a=0;a<e.length;a++)n+=e[a]*t[a],r+=e[a]*e[a],i+=t[a]*t[a];let a=Math.sqrt(r)*Math.sqrt(i);return a===0?0:n/a}function Pt(e){if(e.length<=2)return e;let t=Array(e.length),n=0,r=e.length-1;for(let i=0;i<e.length;i++)i%2==0?t[n++]=e[i]:t[r--]=e[i];return t}function Ft(e,t,n,r,i){let a=typeof n==`string`?n:JSON.stringify(n);return{ok:!0,tool:e,summary:t,data:n,meta:{duratio ...
9`)){if(/^packages\s*:/.test(e)){r=!0;continue}if(r){let t=e.match(/^\s+-\s+['"]?([^'"]+)['"]?\s*$/);if(t)n.push(t[1]);else if(/^\S/.test(e))break}}if(n.length>0){let t=0;for(let r of n){let n=r.replace(/\/\*.*$/,``);try{let r=await l(_(e,n),{withFileTypes:!0});for(let i of r)if(i.isDirectory()&&i.name!==`node_modules`&&!i.name.startsWith(`.`))try{await c(_(e,n,i.name,`package.json`),`utf-8`),t++}catch{}}catch{}}if(t>0)return t}}catch{}let t=[`packages`,`functions`,`libs`,`apps`,`cdk`],n=0;for(let r of t)try{let t=await l(_(e,r),{withFileTypes:!0});for(let i of t)if(i.isDirectory()&&i.name!==
11`);for(let t of e.recommendations){let e=t.priority===`high`?`🔴`:t.priority===`medium`?`🟡`:`🟢`;n.push(`${e} **${t.area}:** ${t.message}`)}}if(e.patterns&&e.patterns.length>0){if(t===`full`){n.push(`
13`),n.push(`| Pattern | Confidence | Count |`),n.push(`|---------|-----------|-------|`);for(let t of e.patterns)n.push(`| ${t.name} | ${t.confidence} | ${t.count} |`)}else t===`normal`&&n.push(`\n**Patterns:** ${e.patterns.map(e=>e.name).join(`, `)}`)}return n.join(`
14`)}const Vt=/^[a-zA-Z0-9_./\-~^@{}]+$/;function Ht(e){let{from:t,to:n=`HEAD`,format:r=`grouped`,includeBreaking:i=!0,cwd:a=process.cwd()}=e;if(!Vt.test(t))throw Error(`Invalid git ref: ${t}`);if(!Vt.test(n))throw Error(`Invalid git ref: ${n}`);let o;try{o=O(`git`,[`log`,`${t}..${n}`,`--format=%H%s%b%an%ai`],{cwd:a,encoding:`utf8`,maxBuffer:10485760,timeout:3e4})}catch{throw Error(`Git log failed. Ensure "${t}" and "${n}" are valid refs.`)}let s=o.split(``).map(e=>e.trim()).filter(Boolean).map(e=>{let[t=``,n=``,r=``,i=``,a=``]=e.split(``),o=n.match(/^(
15`)}const Wt=/^[a-z0-9][a-z0-9-]*$/,Gt=/* @__PURE__ */ new Map;function Kt(e){let t=y(e),n=Gt.get(t);if(n!==void 0)return n;try{return O(`git`,[`rev-parse`,`--git-dir`],{cwd:t,timeout:1e4,encoding:`utf8`,stdio:[`ignore`,`pipe`,`pipe`],windowsHide:!0}),Gt.set(t,!0),!0}catch{return Gt.set(t,!1),!1}}function qt(e,t,n,r){try{return O(`git`,e,{cwd:t,timeout:1e4,input:n,encoding:`utf8`,stdio:[`pipe`,`pipe`,`pipe`],windowsHide:!0}).trim()}catch(t){r||console.warn(`Git operation failed (${e.join(`
16`),`utf-8`)))}return!a&&m.length>0&&En(`codemod`,m,`codemod: ${n.length} rules, ${p} files`),{changes:u,rulesApplied:d.size,filesModified:p,dryRun:a}}const jn=new ze({max:1e4,ttl:18e5}),Mn=new ze({max:500,ttl:18e5});function Nn(e){return W(`sha256`).update(e).digest(`hex`).slice(0,24)}function Pn(e,t){return`${e.modelId}:${e.dimensions}:${Nn(t)}`}async function Fn(e,t,n,r){}async function In(e,t,n){if(t.length===0)return[];let r=Array(t.length),i=[],a=[];for(let n=0;n<t.length;n++){let o=t[n],s=jn.get(Pn(e,o));if(s){r[n]=s;continue}i.push(o),a.push(n)}if(i.length>0){let t=await e.embedBatch(i, ...
18`);return u({text:C,originalChars:p.length,compressedChars:C.length,ratio:C.length/p.length,segmentsKept:x.length,segmentsTotal:m.length})}function ur(e){return{id:e.id,description:`${e.toolName} → use ${e.alternative}`,toolMatch:e.toolName,commandPatterns:e.commandPatterns==null?null:[...e.commandPatterns],heuristic:e.heuristic??null}}const dr=/vitest|jest|mocha|pnpm test|npm test/i,fr=/\btsc\b|pnpm check|pnpm typecheck|pnpm lint|biome/i,pr=/\bgrep\b|\bfind\b|\brg\b|Select-String/i,mr=/* @__PURE__ */ new Set([`apply_patch`,`codemod`,`create_file`,`rename`,`restore`,`replace_string_in_file`,`v ...
Long lines were clipped for display.