Files
sisi/sisi/cli.py
T
swaitsandClaude Opus 5.5 2a68ead05f revert no longer undoes moves between levels; it names the command back
A change that moves rules between levels (sisi rules move, or an organize
that moves lines across levels) prints the exact reverse command when it
succeeds, and revert after it changes nothing and prints the same command.
Revert keeps undoing learn, retro and single-level organize. The multi-file
undo record and its restore loop are gone.

Fixes the five findings of the fix review: a store with no .git starts its
history with the rules as they are (no undo goes past them); revert reads the
undo record even when its bytes did not change; a trailing slash in SISI_DATA
is still the store; organize takes the user lock and refuses a linked
drops.jsonl. Also: rules usage names canon; a non-UTF-8 file is named.
Product code 2427 -> 2426 lines.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-01 16:28:30 -07:00

86 lines
5.0 KiB
Python

"""sisi: hooks that force a retro and turn what it finds into rules, and a models table to delegate by."""
import os, sys, time
HELP = """sisi: a self-improvement loop for AI coding agents.
Before and after the work
sisi done --goal G --check C [--check C ...] --next N
record what done means and what the person will need next; nothing starts before
sisi done --pass N EVIDENCE | --fail N WHY
give a check its verdict; `sisi done` alone shows it
sisi fault [TEXT | --started|--blocked|--fixed N NOTE] open faults in this project; alone lists them
The learning loop
sisi retro what happened in this piece of work, to set against the objective
sisi retro --gap G --cause C --improve I --term T --problem N|"..." --level core|user|project
record the gap and problem; the improvement is a rule at once
sisi retro --no-gap TEXT --term T --better B | --later TEXT
nothing fell short; or the work is not finished yet
sisi learn --level core|user|project TEXT [--means HOW]
the person's own words become a rule at once
sisi rules the learned rules in force here
sisi rules organize [--record FILE]
the brief for a cheap worker to audit and organize them; record its answer
sisi rules move "<start>" core|user|project|canon [--project PATH]
move one rule to another level (canon: out of the queue once in canon/core.md)
sisi rules revert undo the last learn, retro or organize (a second re-applies it); declines if the
project file changed since; a move is not undone: both print the command back
Delegation
sisi models the workers you have: what each is good at and what it costs
sisi models research [--record FILE]
the brief for a research worker to rebuild that table; record its answer
sisi pick routine|ordinary|hard [--review-of WORKER] [--not WORKER ...] [--limit MINUTES] [--branch NAME]
the wheel gives you one worker of that class; one pick, one delegation
sisi judge WORKER good|bad|out WHY | extend MINUTES WHY [--newest]
how a delegation went (`out` with the provider's own message when it hit a
limit: sisi tries it again by itself), or give a running job more time
sisi direct REASON allow yourself more direct tool calls this turn, with the reason
Setting up
sisi install | uninstall | doctor
put the rulebook (and hooks, where the tool has them) into every agent tool
installed here; take them out again; show how each tool stands
sisi release | rollback make this copy the one the hooks run; go back to the one before
sisi update fetch the newest sisi from where this release came from and release it
Hooks (the agent tool calls these): sisi tick | prompt | watch | gate
Your own rules, models table and retro log live in ~/.local/share/sisi ($SISI_DATA, else $XDG_DATA_HOME/sisi), a git repository;
a project's rules live in its .sisi/rules.md. Settings: "core" in
its config.json (gate, meter, direct_calls, direct_extension, rules_lines, rules_chars, organize_after,
research_days, shell_workers, worker_minutes, retro_minutes, disk_free_percent, disk_drop_percent, checkouts)."""
def main(argv):
from . import hooks, models, rules, store
cmd, args = (argv[0] if argv else "help"), argv[1:]
if cmd in ("tick", "prompt", "watch", "gate"):
try:
p = hooks.payload()
if cmd == "gate":
return hooks.gate(p, "--subagent" in args)
return {"tick": hooks.tick, "prompt": hooks.prompt, "watch": hooks.watch}[cmd](p)
except Exception as e: # a hook must never break the agent's session
store.append(os.path.join(store.STATE, "core-errors.log"), "%s %s: %r" % (time.strftime("%Y-%m-%dT%H:%M:%S"), cmd, e))
return 0
if cmd in ("retro", "done"):
from . import retro
return (retro.run if cmd == "retro" else retro.done)(args)
if cmd == "fault":
from . import faults
return faults.run(args)
one = {"rules": rules.run, "pick": models.pick, "learn": rules.learn, "models": models.run, "judge": models.judge,
"direct": hooks.direct}
if cmd in one:
return one[cmd](args)
if cmd in ("install", "uninstall", "release", "update", "rollback", "doctor"):
from . import install
cmd == "release" and models.sync_shared()
return getattr(install, cmd)()
if cmd in ("rulebook", "version"):
print(rules.build_rulebook() if cmd == "rulebook" else store.read(os.path.join(store.ROOT, "VERSION")).strip())
return 0
print(HELP)
return 0 if cmd in ("help", "--help", "-h") else 1