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.
just clone this repo into your ~/.agent and setup your key in ~/.agent/agent.secrets.mjs.
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 ~/.agentfunction magent(){
node ~/.agent
}Put your secret keys into exports from ~/.agent/agent.secrets.mjs.
An example is like
export const openai = "sk-...";and invoke with openai.
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) )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 ) )- Implement more addons
- debugging
- print these stuff in terminal with kitty
