Item 5: sisi help grouped under four headings in 47 lines; long text per command. done 5 / next 6 (learn receipt)
This commit is contained in:
1 parent
6787ef0ae9
commit
4061733430
5 files changed
+192
-105
No files matched your search
+18
-103
@@ -1,107 +1,6 @@
|
|||||||
"""Command dispatch. Heavy modules are imported lazily so hooks (tick, gate) stay fast."""
|
"""Command dispatch. Heavy modules are imported lazily so hooks (tick, gate) stay fast."""
|
||||||
import json, os, sys
|
import json, os, sys
|
||||||
|
|
||||||
HELP = """sisi is still improving
|
|
||||||
|
|
||||||
A shared rulebook and enforced definitions of done for every AI coding CLI.
|
|
||||||
|
|
||||||
sisi contract init [--goal TEXT] start a work unit: create .sisi/contract.json here (refuses while one is open)
|
|
||||||
sisi contract check validate the contract (vacuous checks are refused)
|
|
||||||
sisi contract waive [--check ID] "<reason>"
|
|
||||||
record a deviation: a waived check does not pass; the unit closes as a deviation and the report must say so
|
|
||||||
sisi contract trust | untrust allow / stop allowing this project's contract to run commands
|
|
||||||
sisi unit close [--abandon "<reason>"]
|
|
||||||
archive the unit to .sisi/units/<id>.json with its scorecard; --abandon records why it stopped
|
|
||||||
sisi unit pause "<what it waits for>"
|
|
||||||
record a wait; the turn may end with no demands
|
|
||||||
sisi unit show [ID] | list print the open unit or an archived record; list this project's units
|
|
||||||
sisi verify [--json] run the selected fast checks (five statuses; nothing unrun passes); exit 0 ok, 1 failure, 2 no contract, 3 untrusted
|
|
||||||
sisi verify --deep [--background] run the deep (long) checks; --background detaches and returns at once
|
|
||||||
sisi verify --all | --state run every check in both tiers; print only the deep-check state (with --json)
|
|
||||||
sisi gate [--tool NAME] end-of-turn hook (reads hook JSON on stdin; NAME selects the tool's hook shape)
|
|
||||||
sisi tick [--tool NAME] session-start hook
|
|
||||||
sisi prompt [--tool NAME] prompt-submission hook: prints the matching recipe and lessons for the human's request as added context (silent when nothing strictly matches); `sisi prompt "<request>"` tries it by hand
|
|
||||||
sisi rule [N|ID] the effective rules and how each is enforced; with N or ID: one rule in full (reasons, history, lessons behind it, how it is enforced)
|
|
||||||
sisi watch [--before|--after] before/after shell-tool hook: measures whether the command changed the project
|
|
||||||
sisi install [--dry-run] | uninstall | doctor
|
|
||||||
wire sisi into the tools (by reference), undo, inspect; --dry-run only prints what would change
|
|
||||||
sisi release [--deep] run the source's checks, then make the stable copy the tools run (see docs/developing.md)
|
|
||||||
sisi rollback switch the stable copy back to the previous release
|
|
||||||
sisi promote [ID|L-NNNN] [--apply] | --export [PATH]
|
|
||||||
no ID: list items not yet in the product (learnings that change
|
|
||||||
sisi itself, or earned organization scope); an ID scrubs a
|
|
||||||
personal overlay item into the source folder and drops the
|
|
||||||
personal copy once the product contains it (dry run unless
|
|
||||||
--apply); L-NNNN promotes the rule or recipe a learning was
|
|
||||||
folded into, from the clone; --export writes a contribution file
|
|
||||||
(universal text only; nothing is sent anywhere)
|
|
||||||
sisi update fast-forward the product clone, then back up, migrate and rebuild personal data
|
|
||||||
sisi export [PATH] | import PATH one tar.gz of personal data, results and session records; restore it
|
|
||||||
sisi overlay list|diff|add-rule|replace-rule|disable-rule|enable-rule|add-verifier|...|revert COMMIT
|
|
||||||
learned changes to rules, verifiers and recipes; each one a commit in your personal repo
|
|
||||||
sisi retro print the unit's record and what stands out in it
|
|
||||||
sisi retro --finding F --cause C --impact value|correctness|time|cost|attention --disposition promote|record|drop [--same-as ID | --new] [--target ID]
|
|
||||||
record one finding; promote also needs --change, --mechanism,
|
|
||||||
--expect and --validate; record needs --limits; drop needs --why-not;
|
|
||||||
a match in scope is printed and attached as a recurrence (--new records
|
|
||||||
a learning of its own); --target names the rule or recipe it concerns
|
|
||||||
sisi retro --adopt ID a parent adopts a subagent's candidate learning, by id
|
|
||||||
sisi lessons [--json] | show ID the learning records and their statuses
|
|
||||||
sisi cycle [due|apply FILE|check FILE|revert [ID]|help]
|
|
||||||
turn proposed learnings into mechanisms (no scheduler:
|
|
||||||
due-ness is a counter); apply validates and replays before
|
|
||||||
promoting; help prints the cycle file format
|
|
||||||
sisi approve [ID --yes|--no] list, in full, the consequential changes waiting for the owner; decide one
|
|
||||||
(in a terminal: an agent's --yes without one is refused)
|
|
||||||
sisi learn [--scope user|project] TEXT
|
|
||||||
record an owner statement; it takes effect at once and
|
|
||||||
`sisi oracle` prints it. Scope for other learnings is
|
|
||||||
earned by evidence, never claimed
|
|
||||||
sisi learn --withdraw ID --reason WHY
|
|
||||||
take a statement recorded by mistake out of delivery (kept in history)
|
|
||||||
sisi risk [--json] risk floor for the working-tree change, with reasons and
|
|
||||||
what that profile requires
|
|
||||||
sisi handover [--all] | done ID --where PATH [--quote FRAGMENT]
|
|
||||||
project-scope learnings waiting to be filed in this project's own docs or
|
|
||||||
work list; done confirms one is filed (the named file must contain
|
|
||||||
its key text) and removes it from the list
|
|
||||||
sisi oracle print what the human wants: the standing principles from
|
|
||||||
`sisi learn`, live at once (project-scoped ones only in their project)
|
|
||||||
sisi status [--json] [--learning] recent units with their scorecards, then trends by project, risk profile, model and policy version (median and p95; no single score)
|
|
||||||
sisi verifiers [WORDS] [--lang L] [--kind K] [--rung N] [--section S] [--installed] [--json]
|
|
||||||
list ways to know work is correct, by section
|
|
||||||
sisi verifiers show ID [--trace] one entry in full, and whether its tool is installed here; --trace also prints where each folded lesson lives in it
|
|
||||||
sisi verifiers for "<claim>" best-matching verifiers for a claim or piece of work
|
|
||||||
sisi verifiers doctor | lint which tools are installed; validate the library
|
|
||||||
sisi done [ID] [--trace] recipes: which checks make a kind of work done; --trace also prints where each folded lesson lives in the recipe
|
|
||||||
sisi done for "<work>" best-matching recipe
|
|
||||||
sisi workers [--refresh] the agent tools and models found here, what is usable now and why not, allowance and price where known, delegations waiting for a judgement, and the judged record as three tables
|
|
||||||
sisi workers fact W --price N|--score N --source S record a price (per million tokens) or benchmark standing (0-100), with its source and date
|
|
||||||
sisi workers avoid|prefer PATTERN --why TEXT your own routing constraints, honoured by `sisi route`
|
|
||||||
sisi workers down W --reason limit|auth|missing|error [--until DATE] | up W mark a worker unavailable / available again
|
|
||||||
sisi workers import FILE merge another ledger file into the delegation ledger (row counts printed; safe to repeat)
|
|
||||||
sisi route --kind K --difficulty N [--review-of W] [--explain]
|
|
||||||
the most affordable usable worker for this kind and difficulty, and the mechanism to start it with (host subagents, host cross-provider delegation, or sisi delegate); --explain says why
|
|
||||||
sisi delegate brief | check FILE | guide the delegation-contract template (eight parts); which parts a brief lacks; the orchestration playbook
|
|
||||||
sisi delegate --kind K --difficulty N --brief FILE [--worker W] [--review-of W] [--cwd DIR]
|
|
||||||
run one brief on the chosen worker unattended; prints only its final report, the transcript path, and the judge command; a brief without outcome, acceptance or files it may change is refused
|
|
||||||
sisi delegate judge ID --outcome accepted|rejected --check none|diffstat|tests|read|review [--minutes N]
|
|
||||||
record your judgement of a delegation run, so the next choice learns from it; judge work run any other way with --worker W --type K --difficulty N instead of ID
|
|
||||||
sisi delegate amend ID | recent [-n N] [--project P] mark a judged delegation that later proved wrong; list recent judgements to find an id
|
|
||||||
sisi eval list|add|run|compare|shadow|judge|status|import
|
|
||||||
the evaluation harness: benchmark cases from real work, isolated
|
|
||||||
replay, policy comparison and independent judging (see docs/evaluation.md);
|
|
||||||
`sisi eval` alone prints status; run without --tasks replays check cases only
|
|
||||||
sisi version | --version print the product version (the VERSION file in the product folder)
|
|
||||||
sisi help this text
|
|
||||||
|
|
||||||
Three places: the product (this clone, never written at run time), your personal data
|
|
||||||
(~/.local/share/sisi, its own git repository), and scratch (~/.local/state/sisi).
|
|
||||||
Environment: SISI_HOME (stands in for the home directory), SISI_DATA (personal data folder),
|
|
||||||
SISI_STATE (scratch dir), SISI_LIB (where stable releases live, default ~/.local/lib/sisi), SISI_TOOL (name recorded with results), SISI_VERIFIERS and SISI_DONE
|
|
||||||
(library directories, default verifiers/ and done/ in the product).
|
|
||||||
"""
|
|
||||||
|
|
||||||
|
|
||||||
def _pop_opt(args, name):
|
def _pop_opt(args, name):
|
||||||
"""Remove `name VALUE` from args, return value or None."""
|
"""Remove `name VALUE` from args, return value or None."""
|
||||||
@@ -285,12 +184,29 @@ def cmd_personal(cmd, args):
|
|||||||
return 64
|
return 64
|
||||||
|
|
||||||
|
|
||||||
|
def cmd_help(args):
|
||||||
|
"""`sisi help` (four groups, one line per command) or `sisi help COMMAND` (that command in full)."""
|
||||||
|
from . import helptext
|
||||||
|
if not args:
|
||||||
|
print(helptext.short(), end="")
|
||||||
|
return 0
|
||||||
|
text = helptext.long(args[0])
|
||||||
|
if text is None:
|
||||||
|
print("sisi: no command %r (try `sisi help`)" % args[0], file=sys.stderr)
|
||||||
|
return 64
|
||||||
|
print(text, end="" if text.endswith("\n") else "\n")
|
||||||
|
return 0
|
||||||
|
|
||||||
|
|
||||||
def main(argv):
|
def main(argv):
|
||||||
args = list(argv)
|
args = list(argv)
|
||||||
t = _pop_opt(args, "--tool")
|
t = _pop_opt(args, "--tool")
|
||||||
if t:
|
if t:
|
||||||
os.environ["SISI_TOOL"] = t
|
os.environ["SISI_TOOL"] = t
|
||||||
cmd = args.pop(0) if args else "help"
|
cmd = args.pop(0) if args else "help"
|
||||||
|
if args[:1] in (["--help"], ["-h"]) and cmd not in ("help", "-h", "--help"):
|
||||||
|
args = [cmd]
|
||||||
|
cmd = "help"
|
||||||
if cmd == "gate":
|
if cmd == "gate":
|
||||||
if t and t != "claude-code":
|
if t and t != "claude-code":
|
||||||
from . import hookio
|
from . import hookio
|
||||||
@@ -332,8 +248,7 @@ def main(argv):
|
|||||||
return 1
|
return 1
|
||||||
return 0
|
return 0
|
||||||
if cmd in ("help", "-h", "--help"):
|
if cmd in ("help", "-h", "--help"):
|
||||||
print(HELP, end="")
|
return cmd_help(args)
|
||||||
return 0
|
|
||||||
if cmd == "contract":
|
if cmd == "contract":
|
||||||
return cmd_contract(args)
|
return cmd_contract(args)
|
||||||
if cmd == "verify":
|
if cmd == "verify":
|
||||||
|
|||||||
@@ -0,0 +1,123 @@
|
|||||||
|
"""Help text for `sisi help`: four groups of commands, one line each, and the long text per command.
|
||||||
|
|
||||||
|
`sisi help` must fit 60 lines of 110 characters (tests/test_public.py checks it); the long explanation of a
|
||||||
|
command is printed by `sisi help COMMAND` and `sisi COMMAND --help`.
|
||||||
|
"""
|
||||||
|
|
||||||
|
LONG = {
|
||||||
|
'contract': ' sisi contract init [--goal TEXT] start a work unit: create .sisi/contract.json here (refuses while one is open)\n sisi contract check validate the contract (vacuous checks are refused)\n sisi contract waive [--check ID] "<reason>"\n record a deviation: a waived check does not pass; the unit closes as a deviation and the report must say so\n sisi contract trust | untrust allow / stop allowing this project\'s contract to run commands',
|
||||||
|
'unit': ' sisi unit close [--abandon "<reason>"]\n archive the unit to .sisi/units/<id>.json with its scorecard; --abandon records why it stopped\n sisi unit pause "<what it waits for>"\n record a wait; the turn may end with no demands\n sisi unit show [ID] | list print the open unit or an archived record; list this project\'s units',
|
||||||
|
'verify': ' sisi verify [--json] run the selected fast checks (five statuses; nothing unrun passes); exit 0 ok, 1 failure, 2 no contract, 3 untrusted\n sisi verify --deep [--background] run the deep (long) checks; --background detaches and returns at once\n sisi verify --all | --state run every check in both tiers; print only the deep-check state (with --json)',
|
||||||
|
'gate': " sisi gate [--tool NAME] end-of-turn hook (reads hook JSON on stdin; NAME selects the tool's hook shape)",
|
||||||
|
'tick': ' sisi tick [--tool NAME] session-start hook',
|
||||||
|
'prompt': ' sisi prompt [--tool NAME] prompt-submission hook: prints the matching recipe and lessons for the human\'s request as added context (silent when nothing strictly matches); `sisi prompt "<request>"` tries it by hand',
|
||||||
|
'rule': ' sisi rule [N|ID] the effective rules and how each is enforced; with N or ID: one rule in full (reasons, history, lessons behind it, how it is enforced)',
|
||||||
|
'watch': ' sisi watch [--before|--after] before/after shell-tool hook: measures whether the command changed the project',
|
||||||
|
'install': ' sisi install [--dry-run] | uninstall | doctor\n wire sisi into the tools (by reference), undo, inspect; --dry-run only prints what would change',
|
||||||
|
'release': " sisi release [--deep] run the source's checks, then make the stable copy the tools run (see docs/developing.md)",
|
||||||
|
'rollback': ' sisi rollback switch the stable copy back to the previous release',
|
||||||
|
'promote': ' sisi promote [ID|L-NNNN] [--apply] | --export [PATH]\n no ID: list items not yet in the product (learnings that change\n sisi itself, or earned organization scope); an ID scrubs a\n personal overlay item into the source folder and drops the\n personal copy once the product contains it (dry run unless\n --apply); L-NNNN promotes the rule or recipe a learning was\n folded into, from the clone; --export writes a contribution file\n (universal text only; nothing is sent anywhere)',
|
||||||
|
'update': ' sisi update fast-forward the product clone, then back up, migrate and rebuild personal data',
|
||||||
|
'export': ' sisi export [PATH] | import PATH one tar.gz of personal data, results and session records; restore it',
|
||||||
|
'overlay': ' sisi overlay list|diff|add-rule|replace-rule|disable-rule|enable-rule|add-verifier|...|revert COMMIT\n learned changes to rules, verifiers and recipes; each one a commit in your personal repo',
|
||||||
|
'retro': " sisi retro print the unit's record and what stands out in it\n sisi retro --finding F --cause C --impact value|correctness|time|cost|attention --disposition promote|record|drop [--same-as ID | --new] [--target ID]\n record one finding; promote also needs --change, --mechanism,\n --expect and --validate; record needs --limits; drop needs --why-not;\n a match in scope is printed and attached as a recurrence (--new records\n a learning of its own); --target names the rule or recipe it concerns\n sisi retro --adopt ID a parent adopts a subagent's candidate learning, by id",
|
||||||
|
'lessons': ' sisi lessons [--json] | show ID the learning records and their statuses',
|
||||||
|
'cycle': ' sisi cycle [due|apply FILE|check FILE|revert [ID]|help]\n turn proposed learnings into mechanisms (no scheduler:\n due-ness is a counter); apply validates and replays before\n promoting; help prints the cycle file format',
|
||||||
|
'approve': " sisi approve [ID --yes|--no] list, in full, the consequential changes waiting for the owner; decide one\n (in a terminal: an agent's --yes without one is refused)",
|
||||||
|
'learn': ' sisi learn [--scope user|project] TEXT\n record an owner statement; it takes effect at once and\n `sisi oracle` prints it. Scope for other learnings is\n earned by evidence, never claimed\n sisi learn --withdraw ID --reason WHY\n take a statement recorded by mistake out of delivery (kept in history)',
|
||||||
|
'risk': ' sisi risk [--json] risk floor for the working-tree change, with reasons and\n what that profile requires',
|
||||||
|
'handover': " sisi handover [--all] | done ID --where PATH [--quote FRAGMENT]\n project-scope learnings waiting to be filed in this project's own docs or\n work list; done confirms one is filed (the named file must contain\n its key text) and removes it from the list",
|
||||||
|
'oracle': ' sisi oracle print what the human wants: the standing principles from\n `sisi learn`, live at once (project-scoped ones only in their project)',
|
||||||
|
'status': ' sisi status [--json] [--learning] recent units with their scorecards, then trends by project, risk profile, model and policy version (median and p95; no single score)',
|
||||||
|
'verifiers': ' sisi verifiers [WORDS] [--lang L] [--kind K] [--rung N] [--section S] [--installed] [--json]\n list ways to know work is correct, by section\n sisi verifiers show ID [--trace] one entry in full, and whether its tool is installed here; --trace also prints where each folded lesson lives in it\n sisi verifiers for "<claim>" best-matching verifiers for a claim or piece of work\n sisi verifiers doctor | lint which tools are installed; validate the library',
|
||||||
|
'done': ' sisi done [ID] [--trace] recipes: which checks make a kind of work done; --trace also prints where each folded lesson lives in the recipe\n sisi done for "<work>" best-matching recipe',
|
||||||
|
'workers': ' sisi workers [--refresh] the agent tools and models found here, what is usable now and why not, allowance and price where known, delegations waiting for a judgement, and the judged record as three tables\n sisi workers fact W --price N|--score N --source S record a price (per million tokens) or benchmark standing (0-100), with its source and date\n sisi workers avoid|prefer PATTERN --why TEXT your own routing constraints, honoured by `sisi route`\n sisi workers down W --reason limit|auth|missing|error [--until DATE] | up W mark a worker unavailable / available again\n sisi workers import FILE merge another ledger file into the delegation ledger (row counts printed; safe to repeat)',
|
||||||
|
'route': ' sisi route --kind K --difficulty N [--review-of W] [--explain]\n the most affordable usable worker for this kind and difficulty, and the mechanism to start it with (host subagents, host cross-provider delegation, or sisi delegate); --explain says why',
|
||||||
|
'delegate': ' sisi delegate brief | check FILE | guide the delegation-contract template (eight parts); which parts a brief lacks; the orchestration playbook\n sisi delegate --kind K --difficulty N --brief FILE [--worker W] [--review-of W] [--cwd DIR]\n run one brief on the chosen worker unattended; prints only its final report, the transcript path, and the judge command; a brief without outcome, acceptance or files it may change is refused\n sisi delegate judge ID --outcome accepted|rejected --check none|diffstat|tests|read|review [--minutes N]\n record your judgement of a delegation run, so the next choice learns from it; judge work run any other way with --worker W --type K --difficulty N instead of ID\n sisi delegate amend ID | recent [-n N] [--project P] mark a judged delegation that later proved wrong; list recent judgements to find an id',
|
||||||
|
'eval': ' sisi eval list|add|run|compare|shadow|judge|status|import\n the evaluation harness: benchmark cases from real work, isolated\n replay, policy comparison and independent judging (see docs/evaluation.md);\n `sisi eval` alone prints status; run without --tasks replays check cases only',
|
||||||
|
'version': ' sisi version | --version print the product version (the VERSION file in the product folder)',
|
||||||
|
'help': ' sisi help this text',
|
||||||
|
}
|
||||||
|
|
||||||
|
ENV = (
|
||||||
|
"Three places: the product (this clone, read-only at run time), your personal data (~/.local/share/sisi,\n"
|
||||||
|
"its own git repository), and scratch (~/.local/state/sisi). Environment: SISI_HOME, SISI_DATA, SISI_STATE,\n"
|
||||||
|
"SISI_LIB, SISI_TOOL, SISI_VERIFIERS, SISI_DONE (what each means: `sisi help help`).\n")
|
||||||
|
|
||||||
|
# (heading, [(command names, usage shown, one line)]) in reading order. Every command the dispatcher
|
||||||
|
# accepts is named in exactly one row.
|
||||||
|
GROUPS = (
|
||||||
|
("For the person", (
|
||||||
|
(("install", "uninstall", "doctor"), "install [--dry-run] | uninstall | doctor", "wire sisi into your tools, undo it, check it"),
|
||||||
|
(("update",), "update", "update the product; back up, migrate, rebuild your data"),
|
||||||
|
(("status",), "status [--json] [--learning]", "recent units with scorecards, then trends"),
|
||||||
|
(("rollback",), "rollback", "switch the stable copy back to the previous release"),
|
||||||
|
(("approve",), "approve [ID --yes|--no]", "list what waits for you; decide one (terminal only)"),
|
||||||
|
(("oracle",), "oracle", "what you want: the principles recorded by `sisi learn`"),
|
||||||
|
(("export", "import"), "export [PATH] | import PATH", "one tar.gz of personal data and results; restore it"),
|
||||||
|
)),
|
||||||
|
("For the agent at work", (
|
||||||
|
(("contract",), "contract init|check|waive|trust|untrust", "start, validate and bend the unit's contract"),
|
||||||
|
(("unit",), "unit close|pause|show|list", "close a unit with its scorecard, record a wait, look back"),
|
||||||
|
(("risk",), "risk [--json]", "the risk floor of the working-tree change; what it requires"),
|
||||||
|
(("verify",), "verify [--deep|--all|--state] [--json]", "run the contract's checks; nothing unrun passes"),
|
||||||
|
(("retro",), "retro [--finding F ...|--adopt ID]", "the unit's record; record a finding, with its cause and fix"),
|
||||||
|
(("learn",), "learn [--scope S] TEXT | --withdraw ID", "record what the owner said; take a mistaken one back"),
|
||||||
|
(("route",), "route --kind K --difficulty N [--explain]", "the most affordable usable worker for a task"),
|
||||||
|
(("delegate",), "delegate brief|check|guide|judge|amend", "write, check, run and judge a brief for a worker"),
|
||||||
|
(("workers",), "workers [fact|avoid|prefer|down|up|import]", "workers found here, what each costs, the judged record"),
|
||||||
|
(("verifiers",), "verifiers show|for|doctor|lint|WORDS", "ways to know work is correct"),
|
||||||
|
(("done",), "done [ID|for \"<work>\"]", "the recipe saying what makes a kind of work done"),
|
||||||
|
(("rule",), "rule [N|ID]", "the rules and how each is enforced"),
|
||||||
|
(("handover",), "handover [--all] | done ID --where PATH", "learnings waiting to be filed in this project's docs"),
|
||||||
|
(("lessons",), "lessons [--json] | show ID", "the learning records and their statuses"),
|
||||||
|
(("eval",), "eval list|add|run|compare|shadow|status", "the evaluation harness: cases, replay, comparison"),
|
||||||
|
)),
|
||||||
|
("Hooks (the tools call these)", (
|
||||||
|
(("tick",), "tick [--tool NAME]", "session start"),
|
||||||
|
(("prompt",), "prompt [--tool NAME]", "each request: the matching recipe and lessons as context"),
|
||||||
|
(("gate",), "gate [--tool NAME]", "end of turn: sends the agent back if the work is not ready"),
|
||||||
|
(("watch",), "watch [--before|--after]", "around shell commands: did the project change?"),
|
||||||
|
)),
|
||||||
|
("Maintaining sisi", (
|
||||||
|
(("release",), "release [--deep]", "check the source, then make the stable copy the tools run"),
|
||||||
|
(("promote",), "promote [ID|L-NNNN] [--apply] | --export", "move a personal item or learning into the product"),
|
||||||
|
(("cycle",), "cycle [due|apply|check|revert|help]", "turn proposed learnings into mechanisms"),
|
||||||
|
(("overlay",), "overlay list|diff|add-rule|...|revert", "your learned changes to rules, verifiers, recipes"),
|
||||||
|
(("harvest", "tasks", "escapes", "checks"), "harvest | tasks | escapes | checks", "the data layer behind `sisi eval`"),
|
||||||
|
(("version",), "version", "print the product version"),
|
||||||
|
(("help",), "help [COMMAND]", "this text, or one command in full"),
|
||||||
|
)),
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
LONG["help"] = (
|
||||||
|
" sisi help [COMMAND] this text, or one command in full (also `sisi COMMAND --help`)\n"
|
||||||
|
" Environment: SISI_HOME (stands in for the home directory), SISI_DATA (personal data folder),\n"
|
||||||
|
" SISI_STATE (scratch dir), SISI_LIB (where stable releases live, default ~/.local/lib/sisi),\n"
|
||||||
|
" SISI_TOOL (name recorded with results), SISI_VERIFIERS and SISI_DONE (library directories,\n"
|
||||||
|
" default verifiers/ and done/ in the product).\n")
|
||||||
|
|
||||||
|
|
||||||
|
def names():
|
||||||
|
"""Every command named in GROUPS."""
|
||||||
|
return [n for _h, rows in GROUPS for row in rows for n in row[0]]
|
||||||
|
|
||||||
|
|
||||||
|
def short():
|
||||||
|
out = ["sisi: a shared rulebook and enforced definitions of done for every AI coding CLI.",
|
||||||
|
"`sisi help COMMAND` or `sisi COMMAND --help` explains one command in full."]
|
||||||
|
for heading, rows in GROUPS:
|
||||||
|
out += ["", heading]
|
||||||
|
out += [" sisi %-41s %s" % (usage, text) for _names, usage, text in rows]
|
||||||
|
out += ["", ENV.rstrip("\n")]
|
||||||
|
return "\n".join(out) + "\n"
|
||||||
|
|
||||||
|
|
||||||
|
def long(cmd):
|
||||||
|
"""The full text for one command, or None when `cmd` is not a command."""
|
||||||
|
for _h, rows in GROUPS:
|
||||||
|
for names_, usage, text in rows:
|
||||||
|
if cmd in names_:
|
||||||
|
return LONG.get(cmd) or " sisi %s %s\n" % (usage, text)
|
||||||
|
return None
|
||||||
@@ -103,6 +103,54 @@ class PublishableTree(unittest.TestCase):
|
|||||||
self.assertFalse(os.path.exists(os.path.join(REPO, "docs", "superpowers")))
|
self.assertFalse(os.path.exists(os.path.join(REPO, "docs", "superpowers")))
|
||||||
|
|
||||||
|
|
||||||
|
class HelpIsGrouped(SisiCase):
|
||||||
|
"""`sisi help` is for its readers: four headings, one line per command, short enough to read at a glance."""
|
||||||
|
|
||||||
|
HEADINGS = ["For the person", "For the agent at work", "Hooks (the tools call these)", "Maintaining sisi"]
|
||||||
|
|
||||||
|
def dispatched(self):
|
||||||
|
"""Every command name the dispatcher in cli.main compares `cmd` to, plus the data-layer subcommands."""
|
||||||
|
import ast, argparse
|
||||||
|
from sisi import cli, learn_cli
|
||||||
|
tree = ast.parse(open(cli.__file__, encoding="utf-8").read())
|
||||||
|
main = next(n for n in tree.body if isinstance(n, ast.FunctionDef) and n.name == "main")
|
||||||
|
found = set()
|
||||||
|
for n in ast.walk(main):
|
||||||
|
if isinstance(n, ast.Compare) and isinstance(n.left, ast.Name) and n.left.id == "cmd":
|
||||||
|
for c in n.comparators:
|
||||||
|
for k in (c.elts if isinstance(c, ast.Tuple) else [c]):
|
||||||
|
if isinstance(k, ast.Constant) and isinstance(k.value, str) and not k.value.startswith("-"):
|
||||||
|
found.add(k.value)
|
||||||
|
ap = argparse.ArgumentParser()
|
||||||
|
sub = ap.add_subparsers()
|
||||||
|
learn_cli.register(sub)
|
||||||
|
return found | set(sub.choices)
|
||||||
|
|
||||||
|
def test_the_whole_help_fits_60_lines_of_110_characters_under_four_headings(self):
|
||||||
|
out = self.sisi("help").stdout
|
||||||
|
lines = out.splitlines()
|
||||||
|
self.assertLessEqual(len(lines), 60)
|
||||||
|
self.assertLessEqual(max(map(len, lines)), 110)
|
||||||
|
at = [lines.index(h) for h in self.HEADINGS]
|
||||||
|
self.assertEqual(at, sorted(at))
|
||||||
|
|
||||||
|
def test_every_command_the_dispatcher_accepts_is_listed_once_and_nothing_else(self):
|
||||||
|
from sisi import helptext
|
||||||
|
listed = helptext.names()
|
||||||
|
self.assertEqual(len(listed), len(set(listed)), "a command is listed twice")
|
||||||
|
self.assertEqual(set(listed), self.dispatched())
|
||||||
|
text = self.sisi("help").stdout
|
||||||
|
for name in listed:
|
||||||
|
self.assertTrue(re.search(r"(^ sisi |\| |, )%s\b" % re.escape(name), text, re.M), name)
|
||||||
|
|
||||||
|
def test_the_long_explanation_is_one_help_away(self):
|
||||||
|
a, b = self.sisi("help", "retro"), self.sisi("retro", "--help")
|
||||||
|
self.assertEqual((a.returncode, b.returncode), (0, 0))
|
||||||
|
self.assertEqual(a.stdout, b.stdout)
|
||||||
|
self.assertIn("--disposition promote|record|drop", a.stdout)
|
||||||
|
self.assertEqual(self.sisi("help", "nonesuch").returncode, 64)
|
||||||
|
|
||||||
|
|
||||||
NOT_BUILT = {"build", "inbox"} # designed in docs/design.md, named in the README as not built
|
NOT_BUILT = {"build", "inbox"} # designed in docs/design.md, named in the README as not built
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+2
-1
@@ -515,8 +515,9 @@ class StatusTests(UnitCase):
|
|||||||
helptext = self.sisi("help").stdout
|
helptext = self.sisi("help").stdout
|
||||||
for gone in ("sisi time", "sisi scoreboard", "sisi improve", "sisi backlog"):
|
for gone in ("sisi time", "sisi scoreboard", "sisi improve", "sisi backlog"):
|
||||||
self.assertNotIn(gone, helptext)
|
self.assertNotIn(gone, helptext)
|
||||||
for kept in ("sisi unit close", "sisi unit pause", "sisi unit show", "sisi status"):
|
for kept in ("sisi unit close|pause|show|list", "sisi status"):
|
||||||
self.assertIn(kept, helptext)
|
self.assertIn(kept, helptext)
|
||||||
|
self.assertIn("sisi unit pause", self.sisi("help", "unit").stdout)
|
||||||
for cmd in ("time", "scoreboard"):
|
for cmd in ("time", "scoreboard"):
|
||||||
self.assertNotEqual(self.sisi(cmd).returncode, 0, cmd)
|
self.assertNotEqual(self.sisi(cmd).returncode, 0, cmd)
|
||||||
|
|
||||||
|
|||||||
@@ -303,7 +303,7 @@ class LintCrossCheckTests(LibCase):
|
|||||||
|
|
||||||
class CoreMdTests(SisiCase):
|
class CoreMdTests(SisiCase):
|
||||||
def test_help_lists_new_commands(self):
|
def test_help_lists_new_commands(self):
|
||||||
out = self.sisi("help").stdout
|
out = self.sisi("help").stdout + self.sisi("help", "verifiers").stdout + self.sisi("help", "done").stdout
|
||||||
for w in ("verifiers show", "verifiers for", "verifiers doctor | lint", "sisi done", "done for"):
|
for w in ("verifiers show", "verifiers for", "verifiers doctor | lint", "sisi done", "done for"):
|
||||||
self.assertIn(w, out)
|
self.assertIn(w, out)
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user