ULTCAN.COM

Tritium help guide cli demos

Guide

Tritium converts Pseudocode → Python / C / Rust (Pseudocode → IR → emit). --lang python|c|rust is the emit language, not a different way to write Pseudocode.

Write Pseudocode as a small program: named bindings, control flow, and library calls — not past-tense English in place of structure. Mark fills with a Tritium token (@tritium): that is how you hand Tritium the high-level program structure to convert.

Maximize Tritium: keep height and structure inside @tritium. A high-level description that is complete and correct still names what is stored and returned (distances = …; return distances). If Tritium cannot convert (HTTP 422 / MISS), lower one notch. HIT → completion_tokens=0.

[https://ultcan.com/tritium](https://ultcan.com/tritium)

Program structure (required at every height)

High level is not “English only.” Past-tense prose hides the program:

# BAD — result named in English; no storage site
fn find_paths(roots, pattern, filters):
  return kept paths
# GOOD — high spine with structure intact
fn find_paths(roots, pattern, filters):
  kept_paths = []
  for root in roots:
    for path in walk(root):
      if rejects(path, filters):
        continue
      kept_paths.append(path)
  return kept_paths
# GOOD — max-high call with a named bind
fn shortest(graph, source):
  distances = dijkstra(graph, source)
  return distances

Rules:

1. Bind results to identifiers (name = …), then return name. 2. Keep library verbs as calls (dijkstra(...), walk(...)), not only as English phrases. 3. Prefer the highest complete form that still shows the program. 4. Do not replace structure with past-tense English (return kept paths).

Tritium tokens — why they exist

Developers, vibe coders, and agents write the host (I/O, glue, callers). @tritium marks the hole where you put the high-level Pseudocode program — structure included — so Tritium can convert it to Python / C / Rust. The token exists so that structure stays in the listing; Tritium expands the hole. It is not a place to dump past-tense English and hope for a HIT.

You write the host. Put structured Pseudocode under @tritium. Call Tritium on that body. Append the generated code after the @tritium lines.

def solve():
    L, R = map(int, input().split())
    print(count_snake(L, R))

def count_snake(L, R):
    """@tritium
    fn count_snake(L, R):
      return f(R) - f(L - 1)
    """
    # append generated code here — emit head always carries hash + height score:
    #   # TRITIUM-PROVENANCE sha256=<hash> lang=python
    #   # TRITIUM-HEIGHT high=0.65 mid=0.35 low=0.00
    # high/mid/low = how much of your Pseudocode maximized Tritium (library reuse).
tritium -c 'fn count_snake(L, R):
  return f(R) - f(L - 1)' --lang python
# → generated file begins with TRITIUM-PROVENANCE + TRITIUM-HEIGHT

Example emit head (every HIT)

# TRITIUM-PROVENANCE sha256=<64-hex> lang=python
# TRITIUM-HEIGHT high=1.00 mid=0.00 low=0.00
def …:
    …

Library max-high → high=1.00. More expanded Pseudocode → lower high, higher mid/low. Read the score next to the hash after every convert.

How to read TRITIUM-HEIGHT (evaluate Pseudocode and code)

Every HIT emit carries two height views. Do not mix them up.

1) Module head — score your Pseudocode

# TRITIUM-HEIGHT high=… mid=… low=…

This mixture is about what you wrote under @tritium / -c, not about how pretty the emit looks:

mostly high — library calls with named binds (distances = dijkstra(...)); goal for product spines.
mostly mid — structured control + binds, few library calls; OK when lowering one notch after a 422.
mostly low — index loops / raw arithmetic spelled out; use only when mid/high will not convert.

How to use it: after tritium -c … or tritium generate …, read the head score. If high is thin and you intended a product spine, rewrite Pseudocode with named binds + library calls. Do not “fix” a low head score by deleting structure into past-tense English. tritium generate 'algo.…' is library max-high → expect high≈1.00 on the head.

2) Per-function lines — score the generated body

# TRITIUM-PSEUDO fn=strip_auth_from_url
#| fn strip_auth_from_url(codes):
#|   start = find_authority_start(codes)
#|   …
# TRITIUM-HEIGHT fn=strip_auth_from_url high=0.28 mid=0.54 low=0.19
def strip_auth_from_url(...):
    …

That score is the emit body after Tritium’s readable pass (nest height). Same mixture as the module head — read the numbers:

mostly high — this nest calls named helpers / library calls; goal for product spines.
mostly mid — structured control + binds; fine for leaf helpers (find, sift, charset).
mostly low — index loops / raw arithmetic still spelled here; raise Pseudocode: bind a mid helper, then compose.

How to use it: walk the listing. Product spines and NAMED cards should compose (high/mid). A tiny helper that is the scan may sit mid/low — that is honest. A named product function whose body is still an index walk instead of start = find_…(...) needs a Pseudocode raise. A separate def is not a license for lowest-level body — height should nest (@tritium structure cascades).

Quick checklist

1. Run the same $ lines as the demo card (tritium generate / tritium -c).
2. Confirm HIT (completion_tokens=0) and a non-empty emit.
3. Read module HEIGHT → did your Pseudocode maximize Tritium?
4. Skim per-fn HEIGHT / PSEUDO → does the code keep nest height?
5. Prefer raising Pseudocode first; then expect emit height to follow.

Maximize Tritium (high first, structure kept)

pip install ultcan-tritium --index-url https://ultcan.com/simple/

# HIGH — named bind + library call (complete program, short surface)
PSEUDO='def shortest(graph, source):
    """@tritium
    fn shortest(graph, source):
      distances = dijkstra(graph, source)
      return distances
    """
    ...'
tritium -c "$PSEUDO" --lang python

# HIGH — bare Pseudocode (no @tritium wrapper; same convert path)
PSEUDO='fn shortest(graph, source):
  distances = dijkstra(graph, source)
  return distances'
tritium -c "$PSEUDO" --lang python

# other emit languages (same Pseudocode; --lang is emit only)
tritium -c "$PSEUDO" --lang c
tritium -c "$PSEUDO" --lang rust

If Tritium cannot convert — lower one notch

HTTP 422 / MISS means Tritium could not convert that Pseudocode. Keep the same problem; add missing binds or typed steps. Never invent a cousin name. Never accept a thin emit (def imul alone on a counting problem is a miss). Never “fix” a MISS by erasing structure into past-tense English.

# MID — name the structure (use when high-level description did not convert)
PSEUDO='fn solve(grid):
  answer = min_path_sum(grid)
  return answer'
tritium -c "$PSEUDO" --lang python

# LOW — typed steps that fully compute and return the answer (always a path)
PSEUDO='fn solve(A, B):
  return (A + B) * (A + B)'
tritium -c "$PSEUDO" --lang python

# LOW — tiny typed body
PSEUDO='fn add(a, b):
  return a + b'
tritium -c "$PSEUDO" --lang python

# LOW — loop spelled out (when no library form fits yet)
PSEUDO='fn max_adjacent_distance(nums):
  n = len(nums)
  best = 0
  for i in range(n):
    d = abs(nums[i] - nums[(i + 1) % n])
    if d > best:
      best = d
  return best'
tritium -c "$PSEUDO" --lang python

HTTPS (same Pseudocode)

BASE='https://ultcan.com/tritium/api'
curl -sS "$BASE/v1/chat/completions" \
  -H 'Content-Type: application/json' \
  -d '{"model":"tritium","metadata":{"lang":"python"},"messages":[{"role":"user","content":"def shortest(graph, source):\n    \"\"\"@tritium\n    fn shortest(graph, source):\n      distances = dijkstra(graph, source)\n      return distances\n    \"\"\"\n    ..."}]}'

curl -sS "$BASE/v1/generate?q=dijkstra&lang=python"

Success: completion_tokens=0. 422 → lower Pseudocode until HIT (keep binds). 429 → wait retry_after_s.

MCP (thinking agents)

Thin hosted MCP wraps the same HTTPS API. Tools: generate(pseudo, lang) and health. Not a control plane — convert only.

MCP='https://ultcan.com/tritium/mcp'

# Cursor ~/.cursor/mcp.json (or project .cursor/mcp.json):
# {
#   "mcpServers": {
#     "tritium": { "url": "https://ultcan.com/tritium/mcp" }
#   }
# }

Same HIT/MISS contract as HTTPS. Prefer high-level Pseudocode; on MISS lower one notch (see above).

ULTCAN.COM