Giter Site home page Giter Site logo

alfred's Introduction

alfred2 Build Status

a natural language interface for programs.

NPM

Why '2'?

alfred "1" was never actually made public but I used it in Detective and a few other private projects. Afterwards, there were a few features I desperately wanted to add in and since 'alfred' was already a package on npm, I decided to go with 'alfred2'.

Usage

This module will expose a function that will create a new alfred stream for usage. The purpose of having a stream is to realize that alfred itself is simply a middleware between your inputs and your code. Due to this, you must first link alfred to some output by piping it out and bring in some line of output (from a stream or whatever else you'd like to use).

For the purposes of this README, we will use stdin as alfred's input and stdout as alfred's output. This will create a sort of REPL with alfred.

For example:

// create a new alfred instance
const alfred = require ( 'alfred2' )();

// push stdin into alfred
process.stdin.pipe(alfred);

// push alfred into stdout
alfred.pipe(process.stdout);

// what gets written to alfred is the natural
// language input, and what alfred outputs is
// what alfred wants to say

Registering a prompt with alfred

alfred uses pennyworth as its prompt-handling library. Therefore, please see the pennyworth docs regarding how to format prompts.

To register the prompt with an action, use alfred.add() with either a function or a generator. For instance, to create a simple hello world prompt that replies with a hello, do:

alfred.add('hi, there.', function* () {
    const age = parseInt(yield 'What is your age?' , 10);
});

License

Licensed under GPL-3.0. See LICENSE.

alfred's People

Contributors

karimsa avatar

Stargazers

 avatar

Watchers

 avatar

alfred's Issues

open access to pennyworth

This would allow developers to add pennyworth filters and directives and use them in their commands.

alfred should have a proper router

Function generators are great when the logic within the generator is synchronous but this is rarely the case with programs that converse with the user.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.