Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

@avcodes/mi

Package Overview
Dependencies
Maintainers
1
Versions
35
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@avcodes/mi - npm Package Compare versions

Comparing version
1.0.2
to
1.0.3
+4
-4
index.mjs
#!/usr/bin/env node
import { createInterface } from 'readline'; import { execSync } from 'child_process'; import { readFileSync, writeFileSync } from 'fs';
import { createInterface } from 'readline'; import { spawn } from 'child_process'; import { readFileSync, writeFileSync } from 'fs';
const tools = {
bash: ({cmd}) => { try { return execSync(cmd,{encoding:'utf8',stdio:'pipe'}) } catch(e) { return e.stderr||e.message } },
bash: ({command})=>new Promise(r=>{const c=spawn('bash',['-c',command],{stdio:['ignore','pipe','pipe'],detached:true});let o='';c.stdout.on('data',d=>o+=d);c.stderr.on('data',d=>o+=d);const h=()=>{try{process.kill(-c.pid)}catch(e){}};process.on('SIGINT',h);c.on('exit',()=>{process.off('SIGINT',h);r(o)})}),
read: ({path}) => readFileSync(path,'utf8'),

@@ -9,3 +9,3 @@ write: ({path,content}) => (writeFileSync(path,content),'ok'),

const mkp = (...keys) => ({type:'object',properties:Object.fromEntries(keys.map(k=>[k,{type:'string'}])),required:keys});
const defs = [{name:'bash',description:'run bash cmd',parameters:mkp('cmd')},{name:'read',description:'read a file',parameters:mkp('path')},
const defs = [{name:'bash',description:'run bash cmd',parameters:mkp('command')},{name:'read',description:'read a file',parameters:mkp('path')},
{name:'write',description:'write a file',parameters:mkp('path','content')}].map(f=>({type:'function',function:f}));

@@ -22,3 +22,3 @@ async function run(msgs) { while (true) {

console.log(dim(`⟡ ${name}(${JSON.stringify(args)})`));
const out=String(tools[name](args)); console.log(dim(out.length>200?out.slice(0,200)+'…':out));
const out=String(await tools[name](args)); console.log(dim(out.length>200?out.slice(0,200)+'…':out));
msgs.push({role:'tool',tool_call_id:t.id,content:out});

@@ -25,0 +25,0 @@ }

{
"name": "@avcodes/mi",
"version": "1.0.2",
"version": "1.0.3",
"description": "agentic coding in 30 loc. a loop, three tools, and an llm.",

@@ -5,0 +5,0 @@ "type": "module",