Skip to content

Erchiusx/magent

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

magent — a Markdown-flavoured lightweighted agent CLI

magent is a lightweighted, Markdown-flavoured agent CLI REPL environment. Based on zx, magent provides hyper flexibility and control to interact with JavaScript and use addons to control data exchange between the agent and your computer.

plots

hello, world!

installation and setup

just clone this repo into your ~/.agent and setup your key in ~/.agent/agent.secrets.mjs.

setup this repository

git clone https://github.com/Erchiusx/magent/ ~/.agent
cd ~/.agent
yarn

Then you may create a executable or a shell function to invoke this agent conveniently. For example,

#!/usr/bin/bash
# an executable file set up in your $PATH
node ~/.agent
function magent(){
    node ~/.agent
}

setup secret keys

Put your secret keys into exports from ~/.agent/agent.secrets.mjs. An example is like

export const openai = "sk-...";

and invoke with openai.

usage

magent will invoke an REPL environment and provides a builtin function ask.

The ask function accepts calls chained with the tagged template string syntax. Most content would be sent to the agent as-is.

To embed JavaScript values, simply use the ${} syntax.

Most syntax in markdown are the same, while you should use \`for`and````for````.

When the prompt is finished, call the function with no arguments to fetch. for example

// use with care, this consumes token
let variable = "variable";
ask`Hello, world!
``this is a fenced area, implemented with JavaScript tagged template feature``
simply slice the ${variable} into this prompt!
`()
    .then( ({content}) => console.log(content) )

using addons

use 4 backticks for addons

ask`Here is an example using the shell addon
````shell
ls
````
will send the output of ``ls`` to the agent
`()
    .then( ({content}) => console.log( content ) )

TODO

  • Implement more addons
  • debugging
  • print these stuff in terminal with kitty

About

magent — a Markdown-flavoured lightweighted agent CLI

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published