Prompts and any language, composed into repeatable programs.
script run_tests = 'npm test'
export def main() {
# When the tests fail, an agent fixes the code
# and the tests run again.
run_tests() recover (failure) {
prompt "The tests failed. Fix the code. ${failure}"
}
return "tests pass"
}
This program runs a project's tests. When the tests fail, it sends the failure to an agent, and then it runs the tests again. The Graph tab shows the steps as a chart, and the Terminal Output tab shows one run.
Drawn by jaiph graph fix_tests.jh. Nothing runs.
How to read the chart
➜ ./fix_tests.jh
Jaiph: Running fix_tests.jh
def main
▸ script run_tests
✗ script run_tests (0s)
▸ prompt fix-agent "The tests failed. Fix th..." (failure="> test > node test.js expected s...")
✓ prompt fix-agent (0s)
▸ script run_tests
✓ script run_tests (0s)
✓ PASS def main (0.8s)
tests pass
One run in which the tests fail once. A small test program played the agent in
this run, so the prompt line shows its name, fix-agent, instead of
cursor.
curl -fsSL https://jaiph.org/run | bash -s 'export def main() { const response = prompt "Say: Hello, I am [model name]!" log response}'
Installs v0.16.2 to ~/.local/bin if needed, then runs the snippet with Cursor CLI (the default backend).
Jaiph is under heavy development. Expect breaking changes before v1.0.0.
curl -fsSL https://jaiph.org/init | bash
Installs Jaiph if needed, then runs jaiph init in this directory.
curl -fsSL https://jaiph.org/install | bash
Writes v0.16.2 to ~/.local/bin. Switch later
with jaiph use nightly or jaiph use <version>.
irm https://jaiph.org/install.ps1 | iex
Installs v0.16.2 to %LOCALAPPDATA%\jaiph\bin
and adds it to your PATH. Then run a sample below, or
jaiph init in a project directory.
Jaiph is under heavy development. Expect breaking changes before v1.0.0.
Jaiph is a small language and a runtime for jobs that mix AI agents with
ordinary scripts in Bash, Python, Node, or another language. You write the steps in a
.jh file. Jaiph runs the steps in order, saves what each step printed, and
stops with a clear error when a step fails.
The same file runs from the command line with jaiph run, as tools for
Claude Code or Cursor with jaiph mcp, and as
an HTTP API with jaiph serve.
A test file replaces each agent reply with fixed text, so a test gives the same result on every run and can run in CI.
Jaiph saves the output of every step and every agent reply under
.jaiph/runs/, and it can
export traces to your monitoring tools.
A script gets a secret from your shell only when the file asks for that secret and you grant it when you start the run.
Jaiph runs on the machine where you start it, and it is not a sandbox. To isolate a run, start it in a container. Each release publishes a runner image.
Cursor, Claude, and Codex work today, and one config line switches between them. The source is under the Apache 2.0 license, and Jaiph has no tracking.
#!/usr/bin/env jaiph
# check the name before calling the agent
def valid_name(name_arg) {
return match name_arg {
/[A-Z][a-z]+/ => name_arg
_ => fail "You provided an invalid name :("
}
}
# jaiph run starts at export def main
export def main(name_arg) {
const name = valid_name(name_arg)
# a prompt calls an agent (Cursor by default)
const response = prompt """
Say hello to ${name} and provide a fun fact
about a person with the same name.
Respond with a single line.
Do not inspect files or run tools.
"""
return response
}
A .jh file is a program. A def is a procedure, a
prompt step calls an agent, and a script runs code.
jaiph run starts at export def main.
To get structured data from a prompt, add
returns "{ hello: string, fact: string }" to the prompt and read
${response.hello}.
Drawn by jaiph graph say_hello.jh. Nothing runs.
How to read the chart
➜ ./say_hello.jh Adam
Jaiph: Running say_hello.jh
def main (name_arg="Adam")
▸ def valid_name (name_arg="Adam")
✓ def valid_name (0s)
▸ prompt cursor "Say hello to ${name} and..." (name="Adam")
✓ prompt cursor (5s)
✓ PASS def main (5.1s)
Hello, Adam—Adam Smith, the 18th-century Scottish economist and philosopher, is often called the father of modern economics for his landmark work *The Wealth of Nations*.
With the name Adam, the agent replies with a greeting.
➜ ./say_hello.jh
Jaiph: Running say_hello.jh
def main
▸ def valid_name
✗ def valid_name (0s)
✗ FAIL def main (0.4s)
Logs: <path>
Summary: <path>
out: <path>
err: <path>
Output of failed step:
You provided an invalid name :(
Without a name, the run fails before the agent is called.
A file named *.test.jh is a test file. A test replaces the agent's reply
with fixed text, so the test gives the same result on every run.
The first test below fails on purpose, so that you can see what a failed test prints. Its
expected text leaves out the trailing :(. The second test passes.
#!/usr/bin/env jaiph
import "say_hello.jh" as hello
# We expect this test to fail due to mismatch in error message
# between the actual failure and the expected string in the test file:
# the expected string drops the trailing ":(". We use it to verify the
# test works and the error message output is correct.
test "without name, main fails with validation message" {
# When
const response = hello.main() allow_failure
# Then
expect_equal response "You provided an invalid name"
}
test "with name, returns greeting and logs response" {
# Given
const expected_response = "Hello Alice! Fun fact: Alice in Wonderland was written by Lewis Carroll."
mock prompt expected_response
# When
const response = hello.main("Alice")
# Then
expect_equal response expected_response
}
Running the test file:
➜ ./say_hello.test.jh
testing say_hello.test.jh
▸ without name, main fails with validation message
✗ expect_equal failed: 0s
- You provided an invalid name
+ You provided an invalid name :(
▸ with name, returns greeting and logs response
✓ 0s
✗ 1 / 2 test(s) failed
- without name, main fails with validation message
#!/usr/bin/env jaiph
# a script body goes in '…' or '''…''' quotes
# it is bash by default; for another language, put the
# interpreter before the quotes: node'''…''', python3'''…'''
script check_report_exists = '''
test -f report.txt
'''
export def main() {
# when check_report_exists() fails, the recover body runs,
# and then check_report_exists() runs again (up to 10 times)
check_report_exists() recover (failure) {
logerr "Failed to check report.txt"
prompt "report.txt is missing. Create it with a short dummy summary."
}
# a script can also be written inline
return 'cat report.txt'()
}
When a step fails, its recover body runs and then the step runs
again, up to 10 times by default.
Drawn by jaiph graph recover_loop.jh. Nothing runs.
How to read the chart
➜ ./recover_loop.jh
Jaiph: Running recover_loop.jh
def main
▸ script check_report_exists
✗ script check_report_exists (0s)
! Failed to check report.txt
▸ prompt cursor "report.txt is missing. C..."
✓ prompt cursor (5s)
▸ script check_report_exists
✓ script check_report_exists (0s)
▸ script __inline_752d3a136cc9
✓ script __inline_752d3a136cc9 (0s)
✓ PASS def main (6.1s)
Summary
-------
This is a placeholder report. No build or test results were generated for
this file; it exists only to satisfy tooling or documentation that expects
`report.txt` to be present.
- Status: OK (dummy)
- Artifacts: none
- Next steps: replace with a real report when you add automated reporting
The first check fails, the agent creates the file, and the second check passes. To
handle a failure once without a retry, use catch.
#!/usr/bin/env jaiph
channel findings -> analyst
channel report -> reviewer
def scanner() {
log "Scanning for issues..."
send "Found 3 issues in auth module" -> findings
}
def analyst(msg) {
send "Summary: ${msg}" -> report
}
def reviewer(msg) {
logerr "Critical issue: ${msg}"
}
export def main() {
scanner()
}
A channel passes messages between defs. channel findings -> analyst
calls analyst once for every message sent to findings.
Drawn by jaiph graph agent_inbox.jh. Nothing runs.
How to read the chart
➜ ./agent_inbox.jh
Jaiph: Running agent_inbox.jh
def main
▸ def scanner
· ℹ Scanning for issues...
✓ def scanner (0s)
▸ def analyst (msg="Found 3 issues in auth module")
✓ def analyst (0s)
▸ def reviewer (msg="Summary: Found 3 issues in auth ...")
· ! Critical issue: Summary: Found 3 issues in auth module
✓ def reviewer (0s)
✓ PASS def main (0s)
#!/usr/bin/env jaiph
const prompt_text = "Say: Greetings! I am [model name]."
def cursor_say_hello(name) {
config {
agent.backend = "cursor"
}
const response = prompt "${prompt_text}"
log response
}
def claude_say_hello(name) {
config {
agent.backend = "claude"
}
const response = prompt "${prompt_text}"
log response
}
# main waits until both async calls finish
export def main(name) {
async cursor_say_hello(name)
async claude_say_hello(name)
}
async starts a call without waiting for it. Here Cursor and Claude get
the same prompt at the same time, and main waits for both.
Drawn by jaiph graph async.jh. Nothing runs.
How to read the chart
➜ ./async.jh
Jaiph: Running async.jh
def main
₁▸ def cursor_say_hello
₂▸ def claude_say_hello
₁· ▸ prompt cursor "Say: Greetings! I am [mo..."
₂· ▸ prompt claude "Say: Greetings! I am [mo..."
₁· ✓ prompt cursor (3s)
₁· ℹ Greetings! I am **Composer**, a language model trained by Cursor.
₁✓ def cursor_say_hello (3s)
₂· ✓ prompt claude (4s)
₂· ℹ Greetings! I am Claude Opus 4.6.
₂✓ def claude_say_hello (4s)
✓ PASS def main (4.6s)
Cursor finished first in this run.
#!/usr/bin/env jaiph
# stdin connects scripts with ->, and the data streams
# from one script to the next without being held in memory
script gen = bash'''
printf 'alpha\nbeta\ngamma\n'
'''
script upper = bash'''
tr 'a-z' 'A-Z'
'''
script count = bash'''
wc -l | tr -d ' '
'''
export def main() {
# make three lines -> uppercase them -> count them
const n = stdin gen() -> upper() -> count()
return n
}
stdin connects scripts with ->. The first call produces
the data, and each script after it reads stdin and writes stdout. The data streams
from one script to the next, so a large output is never held in memory.
Drawn by jaiph graph stdin.jh. Nothing runs.
How to read the chart
➜ ./stdin.jh
Jaiph: Running stdin.jh
def main
▸ script gen
· ▸ script upper
· · ▸ script count
✓ script gen (0s)
· ✓ script upper (0s)
· · ✓ script count (0s)
✓ PASS def main (0.1s)
3
Each script is its own step, and main returns the line count.
Takes five minutes and needs no API key. You write a file and watch it run.
jaiph mcp ./tools.jh gives your defs to Claude Code, Cursor, or any MCP client as tools.
Add a prompt step, and choose Cursor, Claude, or Codex as the backend.
jaiph serve ./tools.jh adds a REST API, an OpenAPI document, Swagger UI, and HTTP MCP.
Write *.test.jh files with mocked agent replies and assertions, and run them in CI.
Look up defs, prompts, scripts, recover, and channels.