npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

cortex-cli

v2.4.3

Published

Command line tool for CognitiveScale Cortex.

Downloads

303

Readme

Cortex CLI

A command line utility for the Cortex Platform.

Build Status

Installation:

From NPM:

npm install -g cortex-cli

From Source:

Once you have the code pulled, run this command from the cortex-cli directory:

npm install -g .

NOTE: When we have a release of this module, it will be published to npm.org for distribution.

For Developers:

You can link your local copy of cortex-cli to your globally installed version:

npm link

The cortex cli can be run directly from the source with a simple wrapper script

git clone https://github.com/CognitiveScale/cortex-cli.git
cat > /usr/local/bin/cortex <<EOM
#!/bin/bash
$PWD/cortex-cli/bin/cortex.js "\$@"
EOM
chmod +x /usr/local/bin/cortex

Changes you make to the source code will now be available immediately (locally).

Usage:

cortex <command> [sub-command] [options]

Common Options

  • -h, --help
  • -v, --version

Getting Started

cortex configure --file /personal/access/token.json --project defaultProject

or

cortex configure --project defaultProject
Cortex Personal Access Token: <paste access token>

Upon successful login, a config file will be saved in your home directory with your authentication token for future use. (NOTE: currently, you will have to re-run the configure command when your token expires).

To see a list of agents:

cortex agents list
[
  {
    "title": "Movie Recommendation Agent",
    "description": "Makes personalized movie recommendations for users.",
    "createdAt": "2017-12-22T03:07:39.863Z",
    "updatedAt": "2017-12-22T03:12:32.159Z",
    "name": "tutorial/movie_recommendation"
  },
  {
    "title": "Trading Insights Agent",
    "description": "Agent to generate personalized insights for traders.",
    "createdAt": "2017-12-22T03:07:40.109Z",
    "updatedAt": "2017-12-22T03:07:40.201Z",
    "name": "default/trading-insights-agent"
  },
  {
    "title": "Client Complaints Agent",
    "description": "Agent to intercept and classify customer complaints early in the process before it even goes to internal audit.",
    "createdAt": "2017-12-22T03:07:41.287Z",
    "updatedAt": "2017-12-22T03:07:41.360Z",
    "name": "default/client-complaints-agent"
  }
]

To use a different profile:

cortex configure --profile myprofile
...
cortex agents list --profile myprofile

Filtering Results using the --json or --query option (DEPRECATION WARNING for --query)

Many of the commands support a --json / --query option for filtering JSON responses. Queries use JMESPath to filter JSON documents. The specification for JMESPath can be found here: http://jmespath.org/. It is similar to the popular JQ tool and supported by Amazon AWS and some other notable services.

For example, if I want to select just the name and title from my previous output:

cortex agents list --json "[].{name: name, title: title}"
[
  {
    "name": "tutorial/movie_recommendation",
    "title": "Movie Recommendation Agent"
  },
  {
    "name": "default/trading-insights-agent",
    "title": "Trading Insights Agent"
  },
  {
    "name": "default/client-complaints-agent",
    "title": "Client Complaints Agent"
  }
]

Standalone binary

We use caxa https://github.com/leafac/caxa to build standalone binaries. Previously, we used pkg but it doesn't support ESM without transpilation as of 07/2023

Executables are created for the following platforms:

  • Linux 64bit intel
  • Windows 64bit intel
  • macOS 64 bit intel.
  • macOS 64 bit M1/M2.

Signed binaries status

  • windows: binaries are currently unsigned
  • macOS: adhoc signature using ldid

Subcommands & Compatibility Checks

The following sequence diagram shows an example running a command with Cortex CLI - namely which HTTP requests. (This diagram can be viewered here).

The Cortex CLI will limit the set of available subcommands, to those which are supported by the Cortex cluster that it is communicating with.

sequenceDiagram
    autonumber
    Actor Dev
    box CLI Commands
        participant C as cortex
        participant Sub as cortex pipelines
    end
    participant Filesystem
    participant S as Sensa API
    participant N as NPM
    Dev->>+C: cortex pipelines list

    critical Load Profile
    C->>+Filesystem: READ $HOME/.cortex/config
    Filesystem->>+C: Cluster URL, Project, etc.

    C->>+S: HTTP GET /fabric/v4/info
    S->>+C: JSON (Server Time Stamp, Feature Flags)
    C-->+C: Limit Subcommands based on feature flags
    end

    alt Is Subcommand Supported?
        C->>Sub: delegate to subcommand
    else
        C->>+Dev: Error: Unknown Command
    end

    Note over Sub,N: Run Compatibility Check

    critical Compatibility Check
    Sub->>S: HTTP GET /fabric/v4/compatibility/applications/cortex-cli
    S->>+Sub: JSON (Required Version)

    Sub->>+N: HTTP GET <npm-registry-url>
    N->>+Sub: JSON (Available CLI Versions)
    end

    Note over Sub,S: Run Action

    critical List Pipelines
    Sub->>S: HTTP GET /fabric/v4/projects/<project>/pipeline-repositories
    S->>+Sub: JSON (Pipelines)
    end

Practical Notes:

  • Only want to load the Profile & perform a Compatibility Check once during command execution
  • Clear downside is that startup for initial help commands are slightly slower due to the dynamic nature of loading subcommands

Preview Features

All preview features cam be enabled in the CLI by setting the PREVIEW_FEATURES_ENABLED environment variable.

Example
```
PREVIEW_FEATURES_ENABLED=* cortex -h
```