keystone-cli 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +136 -0
- package/logo.png +0 -0
- package/package.json +45 -0
- package/src/cli.ts +775 -0
- package/src/db/workflow-db.test.ts +99 -0
- package/src/db/workflow-db.ts +265 -0
- package/src/expression/evaluator.test.ts +247 -0
- package/src/expression/evaluator.ts +517 -0
- package/src/parser/agent-parser.test.ts +123 -0
- package/src/parser/agent-parser.ts +59 -0
- package/src/parser/config-schema.ts +54 -0
- package/src/parser/schema.ts +157 -0
- package/src/parser/workflow-parser.test.ts +212 -0
- package/src/parser/workflow-parser.ts +228 -0
- package/src/runner/llm-adapter.test.ts +329 -0
- package/src/runner/llm-adapter.ts +306 -0
- package/src/runner/llm-executor.test.ts +537 -0
- package/src/runner/llm-executor.ts +256 -0
- package/src/runner/mcp-client.test.ts +122 -0
- package/src/runner/mcp-client.ts +123 -0
- package/src/runner/mcp-manager.test.ts +143 -0
- package/src/runner/mcp-manager.ts +85 -0
- package/src/runner/mcp-server.test.ts +242 -0
- package/src/runner/mcp-server.ts +436 -0
- package/src/runner/retry.test.ts +52 -0
- package/src/runner/retry.ts +58 -0
- package/src/runner/shell-executor.test.ts +123 -0
- package/src/runner/shell-executor.ts +166 -0
- package/src/runner/step-executor.test.ts +465 -0
- package/src/runner/step-executor.ts +354 -0
- package/src/runner/timeout.test.ts +20 -0
- package/src/runner/timeout.ts +30 -0
- package/src/runner/tool-integration.test.ts +198 -0
- package/src/runner/workflow-runner.test.ts +358 -0
- package/src/runner/workflow-runner.ts +955 -0
- package/src/ui/dashboard.tsx +165 -0
- package/src/utils/auth-manager.test.ts +152 -0
- package/src/utils/auth-manager.ts +88 -0
- package/src/utils/config-loader.test.ts +52 -0
- package/src/utils/config-loader.ts +85 -0
- package/src/utils/mermaid.test.ts +51 -0
- package/src/utils/mermaid.ts +87 -0
- package/src/utils/redactor.test.ts +66 -0
- package/src/utils/redactor.ts +60 -0
- package/src/utils/workflow-registry.test.ts +108 -0
- package/src/utils/workflow-registry.ts +121 -0
package/README.md
ADDED
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
# ποΈ Keystone CLI
|
|
2
|
+
|
|
3
|
+
[](https://bun.sh)
|
|
4
|
+
[](https://www.npmjs.com/package/keystone-cli)
|
|
5
|
+
[](https://opensource.org/licenses/MIT)
|
|
6
|
+
|
|
7
|
+
**Keystone** is a local-first, declarative, agentic workflow orchestrator built on **Bun**.
|
|
8
|
+
|
|
9
|
+
It allows you to define complex automation workflows using a simple YAML syntax, featuring first-class support for LLM agents, persistent state management via SQLite, and high-concurrency execution with built-in resilience.
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## β¨ Key Features
|
|
14
|
+
|
|
15
|
+
- β‘ **Local-First & Fast:** Powered by Bun with a local SQLite database. No external "cloud state" requiredβyour data and workflow history stay on your machine.
|
|
16
|
+
- π§© **Declarative Workflows:** Define logic in YAML. Keystone automatically calculates the execution graph (DAG) and detects dependencies from your expressions.
|
|
17
|
+
- π€ **Agentic by Design:** Seamlessly integrate LLM agents defined in Markdown. Agents can use tools, which are just other workflow steps.
|
|
18
|
+
- π **Built-in MCP Server:** Expose your workflows as tools to other AI assistants (like Claude Desktop) using the Model Context Protocol.
|
|
19
|
+
- π **Resilient Execution:** Built-in retries, exponential backoff, and timeouts. Interrupted workflows can be resumed exactly where they stopped.
|
|
20
|
+
- π§βπ» **Human-in-the-Loop:** Support for manual approval and text input steps for sensitive or creative operations.
|
|
21
|
+
- π **Interactive TUI:** A beautiful terminal dashboard to monitor concurrent runs and history.
|
|
22
|
+
- π‘οΈ **Security-First:** Automatic secret redaction from logs/database and AST-based safe expression evaluation.
|
|
23
|
+
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
## π Installation
|
|
27
|
+
|
|
28
|
+
Ensure you have [Bun](https://bun.sh) installed (v1.0.0 or higher).
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
# Install globally via Bun
|
|
32
|
+
bun add -g keystone-cli
|
|
33
|
+
|
|
34
|
+
# Or via NPM
|
|
35
|
+
npm install -g keystone-cli
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### Shell Completion
|
|
39
|
+
|
|
40
|
+
To enable tab completion for workflow names and commands:
|
|
41
|
+
|
|
42
|
+
**Zsh:** Add `source <(keystone completion zsh)` to your `.zshrc`
|
|
43
|
+
**Bash:** Add `source <(keystone completion bash)` to your `.bashrc`
|
|
44
|
+
|
|
45
|
+
---
|
|
46
|
+
|
|
47
|
+
## π₯ Quick Start
|
|
48
|
+
|
|
49
|
+
### 1. Initialize a Project
|
|
50
|
+
```bash
|
|
51
|
+
keystone init
|
|
52
|
+
```
|
|
53
|
+
This creates a `.keystone/` directory for configuration and a `workflows/` directory for your files.
|
|
54
|
+
|
|
55
|
+
### 2. Configure Environment
|
|
56
|
+
Add your API keys to the generated `.env` file:
|
|
57
|
+
```env
|
|
58
|
+
OPENAI_API_KEY=sk-...
|
|
59
|
+
ANTHROPIC_API_KEY=sk-ant-...
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### 3. Run Your First Workflow
|
|
63
|
+
```bash
|
|
64
|
+
keystone run basic-shell
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
---
|
|
68
|
+
|
|
69
|
+
## βοΈ How it Works
|
|
70
|
+
|
|
71
|
+
### Workflows (.yaml)
|
|
72
|
+
Workflows are defined by steps. Steps run in **parallel** by default unless a dependency is defined via `needs` or detected in an expression like `${{ steps.previous_step.output }}`.
|
|
73
|
+
|
|
74
|
+
```yaml
|
|
75
|
+
name: analyze-repo
|
|
76
|
+
steps:
|
|
77
|
+
- id: list_files
|
|
78
|
+
type: shell
|
|
79
|
+
run: ls -R
|
|
80
|
+
transform: stdout.split('\n')
|
|
81
|
+
|
|
82
|
+
- id: analyze
|
|
83
|
+
type: llm
|
|
84
|
+
foreach: ${{ steps.list_files.output }}
|
|
85
|
+
concurrency: 5
|
|
86
|
+
agent: code-reviewer
|
|
87
|
+
prompt: "Analyze this file: ${{ item }}"
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
### Agents (.md)
|
|
91
|
+
Agents are defined in Markdown with YAML frontmatter. This keeps the "personality" and tools of the agent together in a human-readable format.
|
|
92
|
+
|
|
93
|
+
```markdown
|
|
94
|
+
---
|
|
95
|
+
name: code-reviewer
|
|
96
|
+
model: claude-3-5-sonnet-latest
|
|
97
|
+
tools:
|
|
98
|
+
- name: read_file
|
|
99
|
+
execution:
|
|
100
|
+
type: file
|
|
101
|
+
op: read
|
|
102
|
+
path: "${{ args.path }}"
|
|
103
|
+
---
|
|
104
|
+
You are an expert security researcher. Review the provided code for vulnerabilities.
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
---
|
|
108
|
+
|
|
109
|
+
## π οΈ CLI Reference
|
|
110
|
+
|
|
111
|
+
| Command | Description |
|
|
112
|
+
| :--- | :--- |
|
|
113
|
+
| `init` | Initialize a new Keystone project |
|
|
114
|
+
| `run <workflow>` | Execute a workflow (supports `-i key=val` for inputs) |
|
|
115
|
+
| `resume <run_id>` | Resume a paused or failed workflow run |
|
|
116
|
+
| `ui` | Open the interactive TUI dashboard |
|
|
117
|
+
| `mcp` | Start the MCP server to use workflows in other tools |
|
|
118
|
+
| `graph <workflow>` | Visualize the DAG as an ASCII or Mermaid diagram |
|
|
119
|
+
| `history` | List recent runs and their status |
|
|
120
|
+
| `auth login` | Authenticate with GitHub for Copilot support |
|
|
121
|
+
| `validate` | Check workflow files for schema and logic errors |
|
|
122
|
+
|
|
123
|
+
---
|
|
124
|
+
|
|
125
|
+
## π Security & Privacy
|
|
126
|
+
|
|
127
|
+
1. **Local State:** All run history, logs, and outputs are stored in a local SQLite database (`.keystone/state.db`).
|
|
128
|
+
2. **Redaction:** Keystone automatically scans for your environment variables and masks them in all logs and database entries.
|
|
129
|
+
3. **AST Evaluation:** Expressions are parsed into an Abstract Syntax Tree and executed in a sandbox, preventing arbitrary code execution within `${{ }}` blocks.
|
|
130
|
+
4. **Shell Safety:** Use the built-in `escape()` function when passing user input to shell commands to prevent injection.
|
|
131
|
+
|
|
132
|
+
---
|
|
133
|
+
|
|
134
|
+
## π License
|
|
135
|
+
|
|
136
|
+
MIT Β© [Mark Hingston](https://github.com/mhingston)
|
package/logo.png
ADDED
|
Binary file
|
package/package.json
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "keystone-cli",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "A local-first, declarative, agentic workflow orchestrator built on Bun",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"keystone": "./src/cli.ts"
|
|
8
|
+
},
|
|
9
|
+
"scripts": {
|
|
10
|
+
"dev": "bun run src/cli.ts",
|
|
11
|
+
"test": "bun test",
|
|
12
|
+
"lint": "biome check .",
|
|
13
|
+
"lint:fix": "biome check --write .",
|
|
14
|
+
"format": "biome format --write ."
|
|
15
|
+
},
|
|
16
|
+
"keywords": ["workflow", "orchestrator", "agentic", "automation", "bun"],
|
|
17
|
+
"author": "Mark Hingston",
|
|
18
|
+
"license": "MIT",
|
|
19
|
+
"repository": {
|
|
20
|
+
"type": "git",
|
|
21
|
+
"url": "https://github.com/mhingston/keystone-cli.git"
|
|
22
|
+
},
|
|
23
|
+
"homepage": "https://github.com/mhingston/keystone-cli#readme",
|
|
24
|
+
"files": ["src", "README.md", "LICENSE", "logo.png"],
|
|
25
|
+
"dependencies": {
|
|
26
|
+
"@jsep-plugin/arrow": "^1.0.6",
|
|
27
|
+
"@jsep-plugin/object": "^1.2.2",
|
|
28
|
+
"@types/react": "^19.2.7",
|
|
29
|
+
"commander": "^12.1.0",
|
|
30
|
+
"ink": "^6.5.1",
|
|
31
|
+
"ink-select-input": "3.1.2",
|
|
32
|
+
"ink-spinner": "^5.0.0",
|
|
33
|
+
"js-yaml": "^4.1.0",
|
|
34
|
+
"jsep": "^1.4.0",
|
|
35
|
+
"react": "^19.2.3",
|
|
36
|
+
"zod": "^3.23.8"
|
|
37
|
+
},
|
|
38
|
+
"devDependencies": {
|
|
39
|
+
"@biomejs/biome": "^1.9.4",
|
|
40
|
+
"@types/js-yaml": "^4.0.9"
|
|
41
|
+
},
|
|
42
|
+
"engines": {
|
|
43
|
+
"bun": ">=1.0.0"
|
|
44
|
+
}
|
|
45
|
+
}
|