All Projects → hliyan → Jarvis

hliyan / Jarvis

Licence: mit
J.A.R.V.I.S - Just Another Rudimentary Verbal Instruction Shell

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Jarvis

Yoda
Wise and powerful personal assistant, available in your nearest terminal
Stars: ✭ 674 (+476.07%)
Mutual labels:  chatbot, cli
Chatette
A powerful dataset generator for Rasa NLU, inspired by Chatito
Stars: ✭ 205 (+75.21%)
Mutual labels:  chatbot, cli
Mojo Webqq
【重要通知:WebQQ将在2019年1月1日停止服务,此项目目前已停止维护,感谢大家四年来的一路陪伴】使用Perl语言(不会没关系)编写的smartqq/webqq客户端框架(非GUI),可通过插件提供基于HTTP协议的api接口供其他语言或系统调用
Stars: ✭ 1,755 (+1400%)
Mutual labels:  chatbot, cli
Mojo Weixin
使用Perl语言(不会没关系)编写的个人账号微信/weixin/wechat客户端框架(非GUI),可通过插件提供基于HTTP协议的api接口供其他语言或系统调用
Stars: ✭ 1,181 (+909.4%)
Mutual labels:  chatbot, cli
Wordup Cli
Wordup is a fully integrated development platform for WordPress. Develop plugins and themes locally. Preview in the cloud. Automatic updates in WP.
Stars: ✭ 116 (-0.85%)
Mutual labels:  cli
Openterm
OpenTerm is a sandboxed command line interface for iOS.
Stars: ✭ 1,504 (+1185.47%)
Mutual labels:  cli
As Pect
🔥Blazing🔥 fast testing with AssemblyScript
Stars: ✭ 115 (-1.71%)
Mutual labels:  cli
Droid
A command-line tool for checking Android OS version history written by Rust.
Stars: ✭ 115 (-1.71%)
Mutual labels:  cli
Asdf
Extendable version manager with support for Ruby, Node.js, Elixir, Erlang & more
Stars: ✭ 12,594 (+10664.1%)
Mutual labels:  cli
Python N26
💵 Unofficial Python client for n26 (Number 26) - https://n26.com/
Stars: ✭ 116 (-0.85%)
Mutual labels:  cli
Zoya
Truly highly composable logging utility
Stars: ✭ 116 (-0.85%)
Mutual labels:  cli
Ytmdl
A simple app to get songs from YouTube in mp3 format with artist name, album name etc from sources like iTunes, Spotify, LastFM, Deezer, Gaana etc.
Stars: ✭ 2,070 (+1669.23%)
Mutual labels:  cli
Know Your Intent
State of the Art results in Intent Classification using Sematic Hashing for three datasets: AskUbuntu, Chatbot and WebApplication.
Stars: ✭ 116 (-0.85%)
Mutual labels:  chatbot
Kafka Connect Tools
Kafka Connect Tooling
Stars: ✭ 115 (-1.71%)
Mutual labels:  cli
Stanford Tensorflow Tutorials
This repository contains code examples for the Stanford's course: TensorFlow for Deep Learning Research.
Stars: ✭ 10,098 (+8530.77%)
Mutual labels:  chatbot
Wechatrobot
个人微信号自动回复、陪聊、查天气、查垃圾分类。新增查看今日新闻和知乎热榜功能。
Stars: ✭ 115 (-1.71%)
Mutual labels:  chatbot
Afctl
afctl helps to manage and deploy Apache Airflow projects faster and smoother.
Stars: ✭ 116 (-0.85%)
Mutual labels:  cli
Autobahn
CLI tool written in Swift heavily inspired by https://github.com/fastlane/fastlane
Stars: ✭ 116 (-0.85%)
Mutual labels:  cli
Termy
A terminal with autocomplete
Stars: ✭ 112 (-4.27%)
Mutual labels:  cli
Learning Bitcoin From The Command Line
A complete course for learning Bitcoin programming and usage from the command
Stars: ✭ 2,010 (+1617.95%)
Mutual labels:  cli

J.A.R.V.I.S - Just Another Rudimentary Verbal Instruction Shell (BETA)

build Coverage Status

Table of Contents

Introduction

JARVIS helps you write rudimentary English wrappers around libraries or APIs, like this:

// wrap your JavaScript function with an English API:
jarvis.addCommand({
  command: '$number to the power of $power',
  handler: ({args: {number, power}}) => {
    const result = Math.pow(parseInt(number), parseInt(power));
    return `${number} to the power of ${power} is ${result}!`;
  }
});

Use it from an interactive command line prompt

> 2 to the power of 3
  2 to the power of 3 is 8!

Installation

npm install --save hliyan/jarvis

Basic example: wrapping an existing library

Invoke an API using natural language.

const Jarvis = require('jarvis');            // use jarvis to
const IssueClient = require('issue-client'); // wrap this with a basic english API

const app = new Jarvis();
const client = new IssueClient();

// register command
app.addCommand({
  command: 'connectToRepository $repoName',
  aliases: [
    'connect to $repoName',
    'connect repo $repoName',
    'connect to $repoName repo'
  ],
  handler: async ({args: {repoName}}) => {
    const res = await client.connect(repoName);
    return res.success ? `Connected to ${repoName}.` : `Could not connect to ${repoName}. Here's the error: ${res.error}`;
  }
});

// exercise the command
const res = await app.send('connect to hliyan/jarvis');
console.log(res); // "Connected to hliyan/jarvis."

Command line integration

Invoke an API using natural language, as a shell command.

const FAQClient = require('./faq');   // business logic from here
const Jarvis = require('jarvis');     // wrapped by jarvis 
const readline = require('readline'); // and connected to a command line

const app = new Jarvis();
const client = new FAQClient();

// register the command
app.addCommand({
  command: 'getCountryPresident $country',
  aliases: [
    'who is the president of $country',
    '$country president'
  ],
  handler: async ({args: {country}}) => {
    const president = await client.getPresident(country);
    return president ? `the president of ${country} is ${president}`
      : `i don't know ${country}`;
  }
});

// start the CLI
const rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout,
  prompt: 'jarvis> '
});

rl.prompt();

// feed CLI input to the app, and app output back to CLI
rl.on('line', async (line) => {
  const res = await app.send(line.trim());
  console.log(res ? `  ${res}` : '  I don\'t understand');
  rl.prompt();
});

// TODO: error handling and other best practices

Running:

$ node index.js
jarvis> who is the president of russia
  the president of russia is Vladamir Putin
jarvis> usa president
  the president of usa is Barack Obama
jarvis> us president
  i don't know us
jarvis> foo
  I don't understand
jarvis> 

Interactive CLI

Use this when the workflow you're trying to wrap is too complicated to execute as a single line command.

You can enter an interactive command session using jarvis.startCommand($name) and exit that particular session using jarvis.endCommand(). State that needs to be maintained for the duration of the interactive session can be set using jarvis.setCommandState($object).

  const jarvis = new Jarvis();
  jarvis.addCommand({
    command: 'repl',
    handler: ({context, line}) => {
      if (!context.activeCommand) {
        context.startCommand('repl');
        context.setCommandState({status: 'awaitInput'});
        return 'Enter input: ';
      }
  
      if (context.state.status === 'awaitInput') {
        const out = 'Handled: ' + line;
        return out;
      }
    }
  });

Expected output

$ repl
$ Enter input:
$ bar
$ Handled: bar
$ ..  # built in exit
$ Done with repl.

Script mode

You can use this to run your natural language commands as a script.

Create a script file, e.g.

start
  connect to repo 'hliyan/jarvis'
  get open issues
  write issues to 'home/john/issues.json'
end

Create a script runner with the correct bindings

const Jarvis = require('jarvis');
const app = new Jarvis();

// bind commands as described earlier

// run script
app.run('test.jarvis', function(input, output) {
  console.log(input);
  console.log(output);
});

Constants

in this context
  HOME is 'https://foo.bar.com'
  USER is 'john'
end

Macros and variables

You can use this to re-use blocks of commands within a script.

in this context
  PI is 3.14
end

how to get area of circle with radius $radius
  # more statements here
end
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].