Core Concepts
/

Packages

Overview

Packages are how VoiceCode groups commands and code by domain/application/scope etc.

A package can define one or many

  • Scopes
  • Commands
  • Actions
  • Implementations
  • Befores
  • Afters
  • Settings
  • Vocabularies
  • Chain pre-processors

some of the larger packages (atom, chrome) also run lots of custom support code, which allows for tight integration with their respective applications.

Registering a package

The following returns a `Package` instance:

unboundmusic/6068de22ef8b0e1fbe06ca9381353701

Unless a specific `scope` is specified, `applications` and `condition` will be used to auto generate a `Scope` with the same `name` as the package. This Scope will be applied to all commands defined/implemented by the package unless explicitly specified otherwise.

`name` is the machine name for this package. All commands defined will be prefixed by it, like `my-package:first-command`

Defining commands

A package can define one or many `Commands`. Each command must have a `spoken` parameter, which is the vocal trigger. The package does not necessarily need to implement, i.e provide an `action` for a given command. Implementations could reside elsewhere.

unboundmusic/048eae23cc2598fb90ab800fe41bf81d

Implementing commands

By implementing a command, you can attach a new action to a previously defined command. If a `scope` is set, this new action will "override" the existing action only when the specified scope is "active"

unboundmusic/d0c853dcc0f0d08ce72760525218bca5

Custom scopes

See Scopes for definition of my-custom-scope

unboundmusic/1bd496ad042691fa0142ffecb4cab9a0

Miscellaneous

Packages::await

If you need to wait for another package to initialize before running some code:

unboundmusic/2cc65160fef4b64eba0f0f0a6546f127

Package::defer

Useful if your package code needs to wait until all other packages and user settings have been evaluated. A common case would be if the package creates commands based on a list of settings, and those settings might be modified by user code.

unboundmusic/95cfe58deaff341ed273b301a51101eb

Packages codebase

http://updates.voicecode.io/packages/

Workflow for contributing to packages

  • go to http://updates.voicecode.io/packages/
  • fork the package repo
  • quit VoiceCode
  • cd `~/voicecode/packages`
  • `rm -rf <package name>`
  • `cd ~/voicecode`
  • `git clone <forked package url>`
  • `cd <package name>` then `npm install` (if the package has a package.json file and needs external dependencies)
  • start VoiceCode
  • make changes (will update live in VoiceCode)
  • commit with informative messages
  • git push
  • when ready, pull-request