Retire note, propose, audit, dev mode, build-canon, canon cost and migrate commands
This commit is contained in:
1 parent
9fcd617391
commit
9b69d41950
16 files changed
+126
-343
No files matched your search
+10
-1
@@ -1,2 +1,11 @@
|
|||||||
"""sisi: one rulebook and enforced definitions of done for every AI coding CLI."""
|
"""sisi: one rulebook and enforced definitions of done for every AI coding CLI."""
|
||||||
__version__ = "0.1.0"
|
import os
|
||||||
|
|
||||||
|
def _version():
|
||||||
|
try:
|
||||||
|
with open(os.path.join(os.path.dirname(os.path.dirname(os.path.realpath(__file__))), "VERSION"), encoding="utf-8") as f:
|
||||||
|
return f.read().strip()
|
||||||
|
except OSError:
|
||||||
|
return "unknown"
|
||||||
|
|
||||||
|
__version__ = _version()
|
||||||
-119
@@ -1,119 +0,0 @@
|
|||||||
"""Inventory of standing instructions each tool loads. Counts lines; does not judge."""
|
|
||||||
import glob, json, os, re
|
|
||||||
|
|
||||||
from . import paths
|
|
||||||
|
|
||||||
|
|
||||||
def _lines(p):
|
|
||||||
try:
|
|
||||||
with open(p, "rb") as f:
|
|
||||||
return f.read().count(b"\n") + 1
|
|
||||||
except OSError:
|
|
||||||
return None
|
|
||||||
|
|
||||||
|
|
||||||
def _imports(p, depth=0, seen=None):
|
|
||||||
"""Files pulled in by `@path` lines (Claude Code import syntax)."""
|
|
||||||
seen = seen if seen is not None else set()
|
|
||||||
out = []
|
|
||||||
try:
|
|
||||||
text = open(p, encoding="utf-8", errors="replace").read()
|
|
||||||
except OSError:
|
|
||||||
return out
|
|
||||||
for m in re.finditer(r"^@(\S+)\s*$", text, re.M):
|
|
||||||
q = os.path.expanduser(m.group(1))
|
|
||||||
if not os.path.isabs(q):
|
|
||||||
q = os.path.join(os.path.dirname(p), q)
|
|
||||||
if q not in seen and os.path.isfile(q):
|
|
||||||
seen.add(q)
|
|
||||||
out.append(("import of %s" % os.path.basename(p), q))
|
|
||||||
if depth < 4:
|
|
||||||
out += _imports(q, depth + 1, seen)
|
|
||||||
return out
|
|
||||||
|
|
||||||
|
|
||||||
def _skills(d, label):
|
|
||||||
return [(label, f) for f in sorted(glob.glob(os.path.join(d, "*", "SKILL.md")))]
|
|
||||||
|
|
||||||
|
|
||||||
def _dirmd(d, label):
|
|
||||||
return [(label, f) for f in sorted(glob.glob(os.path.join(d, "**", "*.md"), recursive=True))]
|
|
||||||
|
|
||||||
|
|
||||||
def collect():
|
|
||||||
h = paths.home()
|
|
||||||
j = lambda *a: os.path.join(h, *a)
|
|
||||||
inv = {}
|
|
||||||
cl = []
|
|
||||||
for f in (j(".claude", "CLAUDE.md"),):
|
|
||||||
if os.path.isfile(f):
|
|
||||||
cl.append(("global instructions", f))
|
|
||||||
cl += _imports(f)
|
|
||||||
cl += _dirmd(j(".claude", "rules"), "rules")
|
|
||||||
cl += _skills(j(".claude", "skills"), "skill")
|
|
||||||
cl += _skills(j(".agents", "skills"), "skill (shared)")
|
|
||||||
try:
|
|
||||||
with open(j(".claude", "plugins", "installed_plugins.json"), encoding="utf-8") as f:
|
|
||||||
plugins = json.load(f).get("plugins", {})
|
|
||||||
except (OSError, ValueError, AttributeError):
|
|
||||||
plugins = {}
|
|
||||||
for name, entries in sorted(plugins.items()):
|
|
||||||
for e in entries if isinstance(entries, list) else []:
|
|
||||||
ip = e.get("installPath") if isinstance(e, dict) else None
|
|
||||||
if ip:
|
|
||||||
pl = "plugin " + name
|
|
||||||
cl += _skills(ip, pl + " skill") + _dirmd(os.path.join(ip, "commands"), pl + " command") \
|
|
||||||
+ _dirmd(os.path.join(ip, "agents"), pl + " agent")
|
|
||||||
inv["claude-code"] = cl
|
|
||||||
cx = []
|
|
||||||
for n in ("AGENTS.override.md", "AGENTS.md"):
|
|
||||||
f = j(".codex", n)
|
|
||||||
if os.path.isfile(f):
|
|
||||||
cx.append(("global instructions", f))
|
|
||||||
cx += _skills(j(".codex", "skills"), "skill") + _skills(j(".agents", "skills"), "skill (shared)")
|
|
||||||
inv["codex"] = cx
|
|
||||||
oc = []
|
|
||||||
f = j(".config", "opencode", "AGENTS.md")
|
|
||||||
if os.path.isfile(f):
|
|
||||||
oc.append(("global instructions", f))
|
|
||||||
else:
|
|
||||||
f2 = j(".claude", "CLAUDE.md")
|
|
||||||
if os.path.isfile(f2):
|
|
||||||
oc.append(("global instructions (fallback to Claude's file)", f2))
|
|
||||||
for n in ("opencode.json", "opencode.jsonc"):
|
|
||||||
cf = j(".config", "opencode", n)
|
|
||||||
try:
|
|
||||||
for ins in json.load(open(cf, encoding="utf-8")).get("instructions", []):
|
|
||||||
q = os.path.expanduser(ins)
|
|
||||||
if os.path.isfile(q):
|
|
||||||
oc.append(("config instructions", q))
|
|
||||||
except (OSError, ValueError, AttributeError):
|
|
||||||
pass
|
|
||||||
oc += _dirmd(j(".config", "opencode", "agents"), "agent") + _dirmd(j(".config", "opencode", "commands"), "command")
|
|
||||||
oc += _skills(j(".agents", "skills"), "skill (shared)")
|
|
||||||
inv["opencode"] = oc
|
|
||||||
mu = []
|
|
||||||
for f in (j(".config", "muse", "AGENTS.md"),):
|
|
||||||
if os.path.isfile(f):
|
|
||||||
mu.append(("global instructions", f))
|
|
||||||
mu += _skills(j(".agents", "skills"), "skill (shared)")
|
|
||||||
inv["muse"] = mu
|
|
||||||
return inv
|
|
||||||
|
|
||||||
|
|
||||||
def main(args=()):
|
|
||||||
inv = collect()
|
|
||||||
grand = 0
|
|
||||||
for tool, items in inv.items():
|
|
||||||
print("%s" % tool)
|
|
||||||
tot = 0
|
|
||||||
for label, f in items:
|
|
||||||
n = _lines(f) or 0
|
|
||||||
tot += n
|
|
||||||
print(" %6d %-34s %s" % (n, label[:34], f))
|
|
||||||
if not items:
|
|
||||||
print(" (none found)")
|
|
||||||
print(" %6d total\n" % tot)
|
|
||||||
grand += tot
|
|
||||||
print("all tools: %d lines (shared files counted once per tool)" % grand)
|
|
||||||
return 0
|
|
||||||
+8
-44
@@ -21,7 +21,6 @@ A shared rulebook and enforced definitions of done for every AI coding CLI.
|
|||||||
wire sisi into the tools (by reference), undo, inspect; --dry-run only prints what would change
|
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 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 rollback switch the stable copy back to the previous release
|
||||||
sisi dev on [PATH] | off | status developer mode: where the source folder is
|
|
||||||
sisi promote [ID|lesson:N] [--apply] | --export [PATH]
|
sisi promote [ID|lesson:N] [--apply] | --export [PATH]
|
||||||
no ID: list core-tier items not yet in the product; an ID
|
no ID: list core-tier items not yet in the product; an ID
|
||||||
scrubs a personal overlay item into the source folder and
|
scrubs a personal overlay item into the source folder and
|
||||||
@@ -29,14 +28,10 @@ A shared rulebook and enforced definitions of done for every AI coding CLI.
|
|||||||
run unless --apply); lesson:N promotes a core lesson on a
|
run unless --apply); lesson:N promotes a core lesson on a
|
||||||
developer install; --export writes a contribution file
|
developer install; --export writes a contribution file
|
||||||
(universal text only; nothing is sent anywhere)
|
(universal text only; nothing is sent anywhere)
|
||||||
sisi migrate move an older installation's personal data into the personal folder (safe to repeat)
|
|
||||||
sisi update fast-forward the product clone, then back up, migrate and rebuild personal data
|
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 export [PATH] | import PATH one tar.gz of personal data, results and session records; restore it
|
||||||
sisi build-canon regenerate the effective rulebook (base rules + your overlay)
|
|
||||||
sisi canon cost size of what is always loaded: rulebook lines and characters against both budgets, lessons block maximum
|
|
||||||
sisi overlay list|diff|add-rule|replace-rule|disable-rule|enable-rule|add-verifier|...|revert COMMIT
|
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
|
learned changes to rules, verifiers and recipes; each one a commit in your personal repo
|
||||||
sisi audit inventory of standing instructions per tool
|
|
||||||
sisi retro --scope core|user|project --aim A --moment M --cause C --change-kind K --change X --when "csv, tsv, spreadsheet, tabular data, import, parse, delimited file" --pattern "the general failure of thinking, one line" [--pattern-id N] [--target ID] [--same-as ID | --new] [--short "one plain sentence"] [--topic "1-3 lower-case words"]
|
sisi retro --scope core|user|project --aim A --moment M --cause C --change-kind K --change X --when "csv, tsv, spreadsheet, tabular data, import, parse, delimited file" --pattern "the general failure of thinking, one line" [--pattern-id N] [--target ID] [--same-as ID | --new] [--short "one plain sentence"] [--topic "1-3 lower-case words"]
|
||||||
(or --json - with the same keys on stdin)
|
(or --json - with the same keys on stdin)
|
||||||
end of every piece of work: HOW it could have gone better; --when (at least
|
end of every piece of work: HOW it could have gone better; --when (at least
|
||||||
@@ -59,8 +54,6 @@ A shared rulebook and enforced definitions of done for every AI coding CLI.
|
|||||||
when none is due; check/--dry-run prints what would change, changing
|
when none is due; check/--dry-run prints what would change, changing
|
||||||
nothing; help prints the full cycle file format
|
nothing; help prints the full cycle file format
|
||||||
sisi improve is it getting better? lessons, recurrence, send-backs, time, rulebook size
|
sisi improve is it getting better? lessons, recurrence, send-backs, time, rulebook size
|
||||||
sisi note TEXT (older; prefer retro) record something that went wrong
|
|
||||||
sisi propose TEXT (older; prefer retro) suggest a rule change
|
|
||||||
sisi learn --scope core|user|project TEXT
|
sisi learn --scope core|user|project TEXT
|
||||||
record a human-stated preference; it takes effect at once.
|
record a human-stated preference; it takes effect at once.
|
||||||
--scope is required, by two questions: (a) does it apply to
|
--scope is required, by two questions: (a) does it apply to
|
||||||
@@ -212,18 +205,6 @@ def _commit_personal(path, msg):
|
|||||||
pdata.commit(msg, [os.path.basename(path)])
|
pdata.commit(msg, [os.path.basename(path)])
|
||||||
|
|
||||||
|
|
||||||
def cmd_store(kind, args):
|
|
||||||
from . import store
|
|
||||||
text = " ".join(args).strip()
|
|
||||||
if not text:
|
|
||||||
print("usage: sisi %s TEXT" % {"notes": "note", "proposals": "propose"}[kind])
|
|
||||||
return 1
|
|
||||||
store.append(kind, store.stamp({"text": text}))
|
|
||||||
_commit_personal(store.file_path(kind), "%s: %s" % ({"notes": "note", "proposals": "proposal"}[kind], " ".join(text.split())[:60]))
|
|
||||||
print("recorded")
|
|
||||||
return 0
|
|
||||||
|
|
||||||
|
|
||||||
def cmd_oracle():
|
def cmd_oracle():
|
||||||
from . import principles
|
from . import principles
|
||||||
sys.stdout.write(principles.oracle_text())
|
sys.stdout.write(principles.oracle_text())
|
||||||
@@ -343,6 +324,11 @@ def cmd_wiring(name, args=()):
|
|||||||
if r.get("action"):
|
if r.get("action"):
|
||||||
line += " | you need to: " + r["action"]
|
line += " | you need to: " + r["action"]
|
||||||
print(line)
|
print(line)
|
||||||
|
try:
|
||||||
|
from . import overlay
|
||||||
|
print("always loaded : " + overlay.cost_line())
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
return 0
|
return 0
|
||||||
rc, notes = getattr(wiring, name)()
|
rc, notes = getattr(wiring, name)()
|
||||||
for n in notes:
|
for n in notes:
|
||||||
@@ -357,23 +343,6 @@ def cmd_personal(cmd, args):
|
|||||||
return overlay.main(args)
|
return overlay.main(args)
|
||||||
if cmd == "update":
|
if cmd == "update":
|
||||||
return lifecycle.cmd_update(args)
|
return lifecycle.cmd_update(args)
|
||||||
if cmd == "migrate":
|
|
||||||
for n in lifecycle.run() or ["nothing to migrate: personal data is in place"]:
|
|
||||||
print(n)
|
|
||||||
return 0
|
|
||||||
if cmd == "build-canon":
|
|
||||||
b = overlay.build_canon()
|
|
||||||
print("%s: %d lines, %d characters%s" % (b["path"], b["lines"], b["chars"], "" if b["changed"] else " (unchanged)"))
|
|
||||||
if b["over_budget"]:
|
|
||||||
print("sisi: over the %d-line budget; shorten or replace a rule" % overlay.MAX_LINES, file=sys.stderr)
|
|
||||||
return 1
|
|
||||||
return 0
|
|
||||||
if cmd == "canon":
|
|
||||||
if args[:1] == ["cost"]:
|
|
||||||
print(overlay.cost_line())
|
|
||||||
return 0
|
|
||||||
print("usage: sisi canon cost")
|
|
||||||
return 1
|
|
||||||
if cmd == "export":
|
if cmd == "export":
|
||||||
print("exported to %s" % lifecycle.export(args[0] if args else None))
|
print("exported to %s" % lifecycle.export(args[0] if args else None))
|
||||||
return 0
|
return 0
|
||||||
@@ -447,27 +416,22 @@ def main(argv):
|
|||||||
return verify.cmd_verify(args)
|
return verify.cmd_verify(args)
|
||||||
if cmd in ("install", "uninstall", "doctor"):
|
if cmd in ("install", "uninstall", "doctor"):
|
||||||
return cmd_wiring(cmd, args)
|
return cmd_wiring(cmd, args)
|
||||||
if cmd in ("migrate", "update", "export", "import", "build-canon", "canon", "overlay"):
|
if cmd in ("update", "export", "import", "overlay"):
|
||||||
return cmd_personal(cmd, args)
|
return cmd_personal(cmd, args)
|
||||||
if cmd in ("release", "rollback", "dev", "promote"):
|
if cmd in ("release", "rollback", "promote"):
|
||||||
from . import release
|
from . import release
|
||||||
try:
|
try:
|
||||||
return {"release": release.cmd_release, "rollback": release.cmd_rollback,
|
return {"release": release.cmd_release, "rollback": release.cmd_rollback,
|
||||||
"dev": release.cmd_dev, "promote": release.cmd_promote}[cmd](args)
|
"promote": release.cmd_promote}[cmd](args)
|
||||||
except release.ReleaseError as e:
|
except release.ReleaseError as e:
|
||||||
print("sisi %s: %s" % (cmd, e), file=sys.stderr)
|
print("sisi %s: %s" % (cmd, e), file=sys.stderr)
|
||||||
return 1
|
return 1
|
||||||
if cmd == "audit":
|
|
||||||
from . import audit
|
|
||||||
return audit.main(args)
|
|
||||||
if cmd == "learn":
|
if cmd == "learn":
|
||||||
from . import scope
|
from . import scope
|
||||||
return scope.cmd_learn(args)
|
return scope.cmd_learn(args)
|
||||||
if cmd == "handover":
|
if cmd == "handover":
|
||||||
from . import handover
|
from . import handover
|
||||||
return handover.main(args)
|
return handover.main(args)
|
||||||
if cmd in ("note", "propose"):
|
|
||||||
return cmd_store({"note": "notes", "propose": "proposals"}[cmd], args)
|
|
||||||
if cmd == "retro":
|
if cmd == "retro":
|
||||||
from . import retro
|
from . import retro
|
||||||
return retro.cmd_retro(args)
|
return retro.cmd_retro(args)
|
||||||
|
|||||||
+4
-4
@@ -564,8 +564,8 @@ Notes - one object per decision; the same lesson may appear several times (split
|
|||||||
(b) would it be useful to every user who installs sisi? Both yes: core -
|
(b) would it be useful to every user who installs sisi? Both yes: core -
|
||||||
examples: "write delimited files with a quoting writer"; "use what the host
|
examples: "write delimited files with a quoting writer"; "use what the host
|
||||||
tool already provides instead of building a replacement". (a) yes, (b) no:
|
tool already provides instead of building a replacement". (a) yes, (b) no:
|
||||||
user - examples: "always ask this owner questions as options with a
|
user - examples: "always present questions as options with a
|
||||||
recommendation"; "prefer this owner's flat-rate plans over per-use ones".
|
recommendation"; "prefer flat-rate plans over per-use ones where available".
|
||||||
(a) no: project - examples: "this product's settings page keeps advanced
|
(a) no: project - examples: "this product's settings page keeps advanced
|
||||||
options behind one toggle"; "this app uses the left control key for search".
|
options behind one toggle"; "this app uses the left control key for search".
|
||||||
Core and user require the delivered text (change, short, when) to be
|
Core and user require the delivered text (change, short, when) to be
|
||||||
@@ -613,8 +613,8 @@ Learn statements - the equivalent for `sisi learn` statements ("learn" at the to
|
|||||||
project moves it to that project's handover pile, out of the global store. Tier by the two
|
project moves it to that project's handover pile, out of the global store. Tier by the two
|
||||||
questions at set-scope above: a statement about how sisi itself should behave for everyone
|
questions at set-scope above: a statement about how sisi itself should behave for everyone
|
||||||
is core ("sisi should anticipate what is needed from what was already said"; "checks, not
|
is core ("sisi should anticipate what is needed from what was already said"; "checks, not
|
||||||
advice"); how this owner wants work done is user ("always ask questions as options with a
|
advice"); how the user wants work done is user ("always present questions as options with
|
||||||
recommendation"; "never set up scheduled jobs or timers"); a fact about one product is
|
a recommendation"; "never set up scheduled jobs or timers"); a fact about one product is
|
||||||
project ("this product's settings page keeps advanced options behind one toggle"; "this app
|
project ("this product's settings page keeps advanced options behind one toggle"; "this app
|
||||||
uses the left control key for search").
|
uses the left control key for search").
|
||||||
|
|
||||||
|
|||||||
+4
-4
@@ -12,7 +12,7 @@ Files, all under <personal>/overlay/:
|
|||||||
done/disabled.txt ids of recipes switched off
|
done/disabled.txt ids of recipes switched off
|
||||||
bases.json for each replacement: the hash of the base item it was made against
|
bases.json for each replacement: the hash of the base item it was made against
|
||||||
|
|
||||||
The effective rulebook (base + overlay) is generated to <personal>/generated/core.md by `build-canon`.
|
The effective rulebook (base + overlay) is generated to <personal>/generated/core.md.
|
||||||
Every command that changes the overlay is one commit in the personal git repository and is refused when the
|
Every command that changes the overlay is one commit in the personal git repository and is refused when the
|
||||||
generated rulebook would exceed MAX_LINES.
|
generated rulebook would exceed MAX_LINES.
|
||||||
"""
|
"""
|
||||||
@@ -222,7 +222,7 @@ def render():
|
|||||||
base_h = sha(open(paths.canon("core.md"), "rb").read())[:8]
|
base_h = sha(open(paths.canon("core.md"), "rb").read())[:8]
|
||||||
except OSError:
|
except OSError:
|
||||||
base_h = "missing"
|
base_h = "missing"
|
||||||
head = "<!-- generated by sisi build-canon from the product canon/core.md (%s) and the personal overlay (%s); " \
|
head = "<!-- generated by sisi from the product canon/core.md (%s) and the personal overlay (%s); " \
|
||||||
"do not edit -->" % (base_h, overlay_hash())
|
"do not edit -->" % (base_h, overlay_hash())
|
||||||
parts = [head]
|
parts = [head]
|
||||||
if pre.strip():
|
if pre.strip():
|
||||||
@@ -245,7 +245,7 @@ def build_canon(strict=False):
|
|||||||
over = lines > MAX_LINES or chars > MAX_CHARS
|
over = lines > MAX_LINES or chars > MAX_CHARS
|
||||||
if over and strict:
|
if over and strict:
|
||||||
raise OverlayError("the rulebook would be %d lines and %d characters; the budgets are %d lines and %d "
|
raise OverlayError("the rulebook would be %d lines and %d characters; the budgets are %d lines and %d "
|
||||||
"characters. Shorten or replace another rule first (`sisi canon cost` shows the size)"
|
"characters. Shorten or replace another rule first (`sisi doctor` shows the size)"
|
||||||
% (lines, chars, MAX_LINES, MAX_CHARS))
|
% (lines, chars, MAX_LINES, MAX_CHARS))
|
||||||
pdata.ensure()
|
pdata.ensure()
|
||||||
p = paths.generated()
|
p = paths.generated()
|
||||||
@@ -294,7 +294,7 @@ def cost():
|
|||||||
def cost_line(c=None):
|
def cost_line(c=None):
|
||||||
c = c or cost()
|
c = c or cost()
|
||||||
if c["rulebook_lines"] is None:
|
if c["rulebook_lines"] is None:
|
||||||
return "rulebook not generated yet (run `sisi build-canon`); lessons block at most %d characters" % c["lessons_block_max_chars"]
|
return "rulebook not generated yet (run `sisi update`); lessons block at most %d characters" % c["lessons_block_max_chars"]
|
||||||
return "rulebook %d lines (budget %d), %d characters (budget %d); session-start lessons block at most %d characters, %d lines" % (
|
return "rulebook %d lines (budget %d), %d characters (budget %d); session-start lessons block at most %d characters, %d lines" % (
|
||||||
c["rulebook_lines"], c["rulebook_budget_lines"], c["rulebook_chars"], c.get("rulebook_budget_chars", MAX_CHARS), c["lessons_block_max_chars"], c["lessons_block_max_lines"])
|
c["rulebook_lines"], c["rulebook_budget_lines"], c["rulebook_chars"], c.get("rulebook_budget_chars", MAX_CHARS), c["lessons_block_max_chars"], c["lessons_block_max_lines"])
|
||||||
|
|
||||||
|
|||||||
+15
-49
@@ -30,22 +30,14 @@ def is_source(d):
|
|||||||
return all(os.path.exists(os.path.join(d, p)) for p in ("bin/sisi", "sisi/cli.py", "canon/core.md"))
|
return all(os.path.exists(os.path.join(d, p)) for p in ("bin/sisi", "sisi/cli.py", "canon/core.md"))
|
||||||
|
|
||||||
|
|
||||||
def dev_source():
|
|
||||||
s = (paths.personal_config().get("developer") or {}).get("source")
|
|
||||||
return s if isinstance(s, str) and s else None
|
|
||||||
|
|
||||||
|
|
||||||
def source(explicit=None):
|
def source(explicit=None):
|
||||||
"""The source folder: the one given, else the folder sisi runs from (unless that is a release), else the
|
"""The source folder: the one given, else the product folder of the launcher that is running."""
|
||||||
developer setting."""
|
|
||||||
if explicit:
|
if explicit:
|
||||||
s = os.path.abspath(os.path.expanduser(explicit))
|
s = os.path.abspath(os.path.expanduser(explicit))
|
||||||
elif not in_lib(paths.REPO):
|
elif not in_lib(paths.REPO):
|
||||||
s = paths.REPO
|
s = paths.REPO
|
||||||
else:
|
else:
|
||||||
s = dev_source()
|
raise ReleaseError("no source folder: run this from the source folder (bin/sisi release from the clone)")
|
||||||
if not s:
|
|
||||||
raise ReleaseError("no source folder: run this from the source folder, or set it with `sisi dev on PATH`")
|
|
||||||
if not is_source(s):
|
if not is_source(s):
|
||||||
raise ReleaseError("%s does not look like the sisi source folder (bin/sisi, sisi/, canon/core.md)" % s)
|
raise ReleaseError("%s does not look like the sisi source folder (bin/sisi, sisi/, canon/core.md)" % s)
|
||||||
return s
|
return s
|
||||||
@@ -188,10 +180,13 @@ def prune(keep=KEEP):
|
|||||||
|
|
||||||
|
|
||||||
def _rebuild_rulebook():
|
def _rebuild_rulebook():
|
||||||
"""Regenerate the rulebook with the code that is now live (not the code that is switching it)."""
|
"""Regenerate the rulebook with the code that is now live."""
|
||||||
launcher = os.path.join(paths.current_link(), "bin", "sisi")
|
try:
|
||||||
r = subprocess.run([sys.executable, launcher, "build-canon"], capture_output=True, text=True)
|
from . import overlay
|
||||||
return (r.stdout + r.stderr).strip(), r.returncode
|
b = overlay.build_canon()
|
||||||
|
return ("%s: %d lines, %d characters" % (b["path"], b["lines"], b["chars"])), 0
|
||||||
|
except Exception as e:
|
||||||
|
return str(e), 1
|
||||||
|
|
||||||
|
|
||||||
def run_checks(src, deep=False):
|
def run_checks(src, deep=False):
|
||||||
@@ -252,40 +247,11 @@ def cmd_rollback(args):
|
|||||||
return 0 if ok else 1
|
return 0 if ok else 1
|
||||||
|
|
||||||
|
|
||||||
# ---- developer mode ---------------------------------------------------------
|
|
||||||
def cmd_dev(args):
|
|
||||||
sub = args[0] if args else "status"
|
|
||||||
if sub == "on":
|
|
||||||
cand = args[1] if len(args) > 1 else (os.getcwd() if is_source(os.getcwd()) else
|
|
||||||
(paths.REPO if not in_lib(paths.REPO) else None))
|
|
||||||
if not cand:
|
|
||||||
print("usage: sisi dev on PATH", file=sys.stderr)
|
|
||||||
return 1
|
|
||||||
cand = os.path.abspath(os.path.expanduser(cand))
|
|
||||||
if not is_source(cand):
|
|
||||||
print("sisi dev: %s does not look like the sisi source folder" % cand, file=sys.stderr)
|
|
||||||
return 1
|
|
||||||
paths.set_personal_config(("developer", "source"), cand, "developer mode on: " + cand)
|
|
||||||
print("developer mode on: source is %s" % cand)
|
|
||||||
return 0
|
|
||||||
if sub == "off":
|
|
||||||
paths.set_personal_config(("developer", "source"), None, "developer mode off")
|
|
||||||
print("developer mode off")
|
|
||||||
return 0
|
|
||||||
if sub == "status":
|
|
||||||
s = dev_source()
|
|
||||||
print("developer mode: " + ("on, source %s%s" % (s, "" if is_source(s) else " (NOT a sisi source folder)") if s else "off"))
|
|
||||||
print("live copy: " + live_text())
|
|
||||||
return 0
|
|
||||||
print("usage: sisi dev on [PATH] | off | status", file=sys.stderr)
|
|
||||||
return 1
|
|
||||||
|
|
||||||
|
|
||||||
def live_text():
|
def live_text():
|
||||||
cur = current_name()
|
cur = current_name()
|
||||||
if not cur or not os.path.isdir(paths.current_link()):
|
if not cur or not os.path.isdir(paths.current_link()):
|
||||||
return "the clone %s (no release made)" % paths.REPO
|
return "the clone %s (no release made)" % paths.REPO
|
||||||
s = dev_source() or (paths.REPO if not in_lib(paths.REPO) and is_source(paths.REPO) else None)
|
s = paths.REPO if not in_lib(paths.REPO) and is_source(paths.REPO) else None
|
||||||
txt = "release %s at %s" % (cur, os.path.realpath(paths.current_link()))
|
txt = "release %s at %s" % (cur, os.path.realpath(paths.current_link()))
|
||||||
if s and is_source(s):
|
if s and is_source(s):
|
||||||
a, c, r = diff(s, paths.current_link())
|
a, c, r = diff(s, paths.current_link())
|
||||||
@@ -543,12 +509,12 @@ def _promote_lesson(lid, apply):
|
|||||||
"(`sisi cycle`) first, then promote it; or send it upstream with "
|
"(`sisi cycle`) first, then promote it; or send it upstream with "
|
||||||
"`sisi promote --export`." % lid, file=sys.stderr)
|
"`sisi promote --export`." % lid, file=sys.stderr)
|
||||||
return 1
|
return 1
|
||||||
src = dev_source()
|
try:
|
||||||
if not src or not is_source(src):
|
src = source()
|
||||||
print("sisi promote: this is not a developer install (no developer source set): nothing "
|
except ReleaseError:
|
||||||
|
print("sisi promote: run this from the source folder (bin/sisi promote from the clone): nothing "
|
||||||
"was written. `sisi promote --export` writes a contribution file you may send "
|
"was written. `sisi promote --export` writes a contribution file you may send "
|
||||||
"upstream; on a developer install (`sisi dev on PATH`) promote writes into the "
|
"upstream.", file=sys.stderr)
|
||||||
"source tree.", file=sys.stderr)
|
|
||||||
return 1
|
return 1
|
||||||
return _promote_overlay(pid, apply, src)
|
return _promote_overlay(pid, apply, src)
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -3,7 +3,7 @@ import json, os, re, time
|
|||||||
|
|
||||||
from . import paths
|
from . import paths
|
||||||
|
|
||||||
FILES = {"results": "results.jsonl", "notes": "notes.jsonl", "proposals": "proposals.jsonl",
|
FILES = {"results": "results.jsonl",
|
||||||
"learn": "learn.jsonl", "quarantine": "learn.jsonl", "waivers": "waivers.jsonl",
|
"learn": "learn.jsonl", "quarantine": "learn.jsonl", "waivers": "waivers.jsonl",
|
||||||
"deliveries": "deliveries.jsonl"}
|
"deliveries": "deliveries.jsonl"}
|
||||||
|
|
||||||
@@ -82,7 +82,7 @@ def session_id():
|
|||||||
return os.environ.get("SISI_SESSION_ID") or None
|
return os.environ.get("SISI_SESSION_ID") or None
|
||||||
|
|
||||||
|
|
||||||
PERSONAL = ("notes", "proposals", "learn", "quarantine") # what the person told or taught sisi: personal data, the rest is scratch
|
PERSONAL = ("learn", "quarantine") # what the person told or taught sisi: personal data, the rest is scratch
|
||||||
|
|
||||||
|
|
||||||
def file_path(name):
|
def file_path(name):
|
||||||
|
|||||||
+6
-7
@@ -117,18 +117,17 @@ def read_ledger(home=None):
|
|||||||
|
|
||||||
def worker_class(worker):
|
def worker_class(worker):
|
||||||
w = (worker or "").lower()
|
w = (worker or "").lower()
|
||||||
for c in ("haiku", "sonnet", "opus"):
|
if not w:
|
||||||
if w == c or w.startswith(c + "-"):
|
return None
|
||||||
return c
|
return w.split("/")[0].split(":")[0] or None
|
||||||
return None
|
|
||||||
|
|
||||||
|
|
||||||
def sub_class(models, meta):
|
def sub_class(models, meta):
|
||||||
found = set()
|
found = set()
|
||||||
for m in list(models) + [str((meta or {}).get("model") or "")]:
|
for m in list(models) + [str((meta or {}).get("model") or "")]:
|
||||||
for c in ("haiku", "sonnet", "opus"):
|
c = worker_class(m)
|
||||||
if c in m.lower():
|
if c:
|
||||||
found.add(c)
|
found.add(c)
|
||||||
return found
|
return found
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+5
-7
@@ -378,9 +378,7 @@ def _ours(p):
|
|||||||
return True
|
return True
|
||||||
if t.startswith(os.path.join(paths.lib(), "")):
|
if t.startswith(os.path.join(paths.lib(), "")):
|
||||||
return True # the stable copy
|
return True # the stable copy
|
||||||
from . import release # a link made when the tools ran from the source folder
|
return False
|
||||||
src = release.dev_source()
|
|
||||||
return bool(src) and t.startswith(os.path.join(src, ""))
|
|
||||||
|
|
||||||
|
|
||||||
def _link(m, p, target, notes, label):
|
def _link(m, p, target, notes, label):
|
||||||
@@ -698,12 +696,12 @@ def doctor():
|
|||||||
todo = lifecycle.pending()
|
todo = lifecycle.pending()
|
||||||
rows.append({"tool": "personal", "status": "ok" if pdata.exists() and not todo else "not ready",
|
rows.append({"tool": "personal", "status": "ok" if pdata.exists() and not todo else "not ready",
|
||||||
"detail": "%s (format %d)%s" % (paths.data(), pdata.version(),
|
"detail": "%s (format %d)%s" % (paths.data(), pdata.version(),
|
||||||
"; run `sisi migrate`: still to move: " + ", ".join(todo) if todo else ""),
|
"; run `sisi update`: still to move: " + ", ".join(todo) if todo else ""),
|
||||||
"blocking_hook": "-"})
|
"blocking_hook": "-"})
|
||||||
gen = paths.generated()
|
gen = paths.generated()
|
||||||
cur = os.path.isfile(gen) and not overlay.is_stale()
|
cur = os.path.isfile(gen) and not overlay.is_stale()
|
||||||
rows.append({"tool": "rulebook", "status": "current" if cur else ("stale" if os.path.isfile(gen) else "missing"),
|
rows.append({"tool": "rulebook", "status": "current" if cur else ("stale" if os.path.isfile(gen) else "missing"),
|
||||||
"detail": gen + ("" if cur else "; run `sisi build-canon`"), "blocking_hook": "-"})
|
"detail": gen + ("" if cur else "; run `sisi update` to rebuild"), "blocking_hook": "-"})
|
||||||
return rows
|
return rows
|
||||||
|
|
||||||
|
|
||||||
@@ -715,11 +713,11 @@ def quick_problem():
|
|||||||
refs = any(os.path.islink(p) and os.readlink(p) == core() for _, p in links)
|
refs = any(os.path.islink(p) and os.readlink(p) == core() for _, p in links)
|
||||||
refs = refs or _claude_md_wired(_read(L["claude_md"])) # only complain about a rulebook something points at
|
refs = refs or _claude_md_wired(_read(L["claude_md"])) # only complain about a rulebook something points at
|
||||||
if refs and not os.path.isfile(core()):
|
if refs and not os.path.isfile(core()):
|
||||||
return "the generated rulebook is missing at %s (run `sisi build-canon`)" % core()
|
return "the generated rulebook is missing at %s (run `sisi update` to rebuild)" % core()
|
||||||
if refs:
|
if refs:
|
||||||
from . import overlay
|
from . import overlay
|
||||||
if overlay.is_stale():
|
if overlay.is_stale():
|
||||||
return "the generated rulebook is out of date (run `sisi build-canon`)"
|
return "the generated rulebook is out of date (run `sisi update` to rebuild)"
|
||||||
for k, p in links:
|
for k, p in links:
|
||||||
if os.path.islink(p) and os.readlink(p).startswith((paths.REPO, paths.data())) and not os.path.exists(p):
|
if os.path.islink(p) and os.readlink(p).startswith((paths.REPO, paths.data())) and not os.path.exists(p):
|
||||||
return "%s link is dangling" % k
|
return "%s link is dangling" % k
|
||||||
|
|||||||
+4
-10
@@ -154,7 +154,7 @@ class ImmediateEffectTests(LearningCase):
|
|||||||
self.assertIn("pars", l["triggers"]) # stems: parser/parsing/parse all meet at 'pars'
|
self.assertIn("pars", l["triggers"]) # stems: parser/parsing/parse all meet at 'pars'
|
||||||
self.assertTrue(l["applied_at"])
|
self.assertTrue(l["applied_at"])
|
||||||
|
|
||||||
def test_tool_lessons_backlog_order_and_dev_mode_tick_line(self):
|
def test_tool_lessons_backlog_order(self):
|
||||||
a = self.mk(change_kind="tool", change="Make the gate count session edits separately per session")
|
a = self.mk(change_kind="tool", change="Make the gate count session edits separately per session")
|
||||||
b = self.mk(change_kind="tool", change="Make sisi verify name the slowest check first")
|
b = self.mk(change_kind="tool", change="Make sisi verify name the slowest check first")
|
||||||
c = self.mk(change_kind="tool", change="Cache transcript scans between gate decisions")
|
c = self.mk(change_kind="tool", change="Cache transcript scans between gate decisions")
|
||||||
@@ -163,12 +163,6 @@ class ImmediateEffectTests(LearningCase):
|
|||||||
ids = [int(l.split()[0][1:]) for l in out if l.startswith("#")]
|
ids = [int(l.split()[0][1:]) for l in out if l.startswith("#")]
|
||||||
self.assertEqual(ids, [b, c, a]) # most seen first; the tie goes to the older lesson
|
self.assertEqual(ids, [b, c, a]) # most seen first; the tie goes to the older lesson
|
||||||
self.assertEqual(self.lesson(b)["effect"], "backlog")
|
self.assertEqual(self.lesson(b)["effect"], "backlog")
|
||||||
paths.set_personal_config(("developer", "source"), self.proj, "test")
|
|
||||||
tick = self.sisi("tick", stdin=json.dumps({"session_id": "dev1", "cwd": self.proj, "source": "startup"})).stdout
|
|
||||||
self.assertIn("top sisi backlog #%d" % b, tick)
|
|
||||||
other = os.path.join(self.tmp, "elsewhere"); os.makedirs(other)
|
|
||||||
tick2 = self.sisi("tick", stdin=json.dumps({"session_id": "dev2", "cwd": other, "source": "startup"})).stdout
|
|
||||||
self.assertNotIn("backlog", tick2)
|
|
||||||
|
|
||||||
|
|
||||||
class DeliveryTests(LearningCase):
|
class DeliveryTests(LearningCase):
|
||||||
@@ -1219,9 +1213,9 @@ class CycleGapTests(LearningCase):
|
|||||||
if r2.returncode != 0:
|
if r2.returncode != 0:
|
||||||
self.assertNotIn("add `shortens`", r2.stdout)
|
self.assertNotIn("add `shortens`", r2.stdout)
|
||||||
|
|
||||||
def test_gap15_char_budget_rewrap_and_canon_cost(self):
|
def test_gap15_char_budget_rewrap_and_doctor_size(self):
|
||||||
self.sisi("build-canon")
|
overlay.build_canon()
|
||||||
self.assertIn("characters (budget %d)" % overlay.MAX_CHARS, self.sisi("canon", "cost").stdout)
|
self.assertIn("characters (budget %d)" % overlay.MAX_CHARS, self.sisi("doctor").stdout)
|
||||||
pre, base = overlay.base_rules()
|
pre, base = overlay.base_rules()
|
||||||
title = next(r["title"] for r in base if r["id"] == "know-done")
|
title = next(r["title"] for r in base if r["id"] == "know-done")
|
||||||
body = ("Before non-trivial work write a contract listing the checks that decide success "
|
body = ("Before non-trivial work write a contract listing the checks that decide success "
|
||||||
|
|||||||
+24
-20
@@ -58,6 +58,9 @@ class PersonalCase(SisiCase):
|
|||||||
self.assertEqual(r.returncode, 0, r.stdout + r.stderr)
|
self.assertEqual(r.returncode, 0, r.stdout + r.stderr)
|
||||||
return r
|
return r
|
||||||
|
|
||||||
|
def build_canon(self):
|
||||||
|
return overlay.build_canon()
|
||||||
|
|
||||||
def generated(self):
|
def generated(self):
|
||||||
with open(paths.generated()) as f:
|
with open(paths.generated()) as f:
|
||||||
return f.read()
|
return f.read()
|
||||||
@@ -80,19 +83,19 @@ class PersonalCase(SisiCase):
|
|||||||
|
|
||||||
class OverlayTests(PersonalCase):
|
class OverlayTests(PersonalCase):
|
||||||
def test_first_use_creates_personal_repo(self):
|
def test_first_use_creates_personal_repo(self):
|
||||||
self.ok("build-canon")
|
self.build_canon()
|
||||||
self.assertTrue(os.path.isdir(os.path.join(self.data, ".git")))
|
self.assertTrue(os.path.isdir(os.path.join(self.data, ".git")))
|
||||||
self.assertEqual(open(os.path.join(self.data, "VERSION")).read().strip(), str(pdata.FORMAT_VERSION))
|
self.assertEqual(open(os.path.join(self.data, "VERSION")).read().strip(), str(pdata.FORMAT_VERSION))
|
||||||
self.assertIn("retro.db", open(os.path.join(self.data, ".gitignore")).read())
|
self.assertIn("retro.db", open(os.path.join(self.data, ".gitignore")).read())
|
||||||
g = self.generated()
|
g = self.generated()
|
||||||
self.assertTrue(g.startswith("<!-- generated by sisi build-canon"))
|
self.assertTrue(g.startswith("<!-- generated by sisi "))
|
||||||
self.assertEqual(g.split("\n")[0].count("<!--"), 1)
|
self.assertEqual(g.split("\n")[0].count("<!--"), 1)
|
||||||
self.assertIn("## 1. Alpha rule {#alpha}", g)
|
self.assertIn("## 1. Alpha rule {#alpha}", g)
|
||||||
self.assertEqual(pdata.git("log", "--format=%an <%ae>").stdout.split("\n")[0], "sisi <sisi@localhost>")
|
self.assertEqual(pdata.git("log", "--format=%an <%ae>").stdout.split("\n")[0], "sisi <sisi@localhost>")
|
||||||
self.assertFalse(os.path.exists(os.path.join(self.p1, "oracle.md")))
|
self.assertFalse(os.path.exists(os.path.join(self.p1, "oracle.md")))
|
||||||
|
|
||||||
def test_hooks_and_global_config_are_ignored(self):
|
def test_hooks_and_global_config_are_ignored(self):
|
||||||
self.ok("build-canon")
|
self.build_canon()
|
||||||
hook = os.path.join(self.data, ".git", "hooks", "pre-commit")
|
hook = os.path.join(self.data, ".git", "hooks", "pre-commit")
|
||||||
os.makedirs(os.path.dirname(hook), exist_ok=True)
|
os.makedirs(os.path.dirname(hook), exist_ok=True)
|
||||||
with open(hook, "w") as f:
|
with open(hook, "w") as f:
|
||||||
@@ -158,7 +161,7 @@ class OverlayTests(PersonalCase):
|
|||||||
self.assertRegex(self.ok("verifiers").stdout, r"\n mutmut ")
|
self.assertRegex(self.ok("verifiers").stdout, r"\n mutmut ")
|
||||||
|
|
||||||
def test_size_budget_refuses_and_changes_nothing(self):
|
def test_size_budget_refuses_and_changes_nothing(self):
|
||||||
self.ok("build-canon")
|
self.build_canon()
|
||||||
gen0, log0 = self.generated(), self.git_log()
|
gen0, log0 = self.generated(), self.git_log()
|
||||||
room = overlay.MAX_LINES - len(gen0.splitlines())
|
room = overlay.MAX_LINES - len(gen0.splitlines())
|
||||||
big = rule_file("Big", "\n".join("line %d" % i for i in range(room + 30)))
|
big = rule_file("Big", "\n".join("line %d" % i for i in range(room + 30)))
|
||||||
@@ -180,13 +183,13 @@ class OverlayTests(PersonalCase):
|
|||||||
self.ok("overlay", "add-rule", "--id", "delta", "-", stdin=rule_file("Delta", "Body."))
|
self.ok("overlay", "add-rule", "--id", "delta", "-", stdin=rule_file("Delta", "Body."))
|
||||||
a = self.generated()
|
a = self.generated()
|
||||||
for _ in range(2):
|
for _ in range(2):
|
||||||
self.ok("build-canon")
|
self.build_canon()
|
||||||
self.assertEqual(self.generated(), a)
|
self.assertEqual(self.generated(), a)
|
||||||
self.assertFalse(overlay.is_stale())
|
self.assertFalse(overlay.is_stale())
|
||||||
t = os.stat(os.path.join(self.p1, "canon", "core.md")).st_mtime_ns - 5_000_000_000
|
t = os.stat(os.path.join(self.p1, "canon", "core.md")).st_mtime_ns - 5_000_000_000
|
||||||
os.utime(paths.generated(), ns=(t, t)) # the product's core.md is now newer than the generated file
|
os.utime(paths.generated(), ns=(t, t)) # the product's core.md is now newer than the generated file
|
||||||
self.assertTrue(overlay.is_stale())
|
self.assertTrue(overlay.is_stale())
|
||||||
self.ok("build-canon")
|
self.build_canon()
|
||||||
self.assertFalse(overlay.is_stale())
|
self.assertFalse(overlay.is_stale())
|
||||||
|
|
||||||
def test_stale_rulebook_is_reported_by_tick_only_when_wired(self):
|
def test_stale_rulebook_is_reported_by_tick_only_when_wired(self):
|
||||||
@@ -195,13 +198,13 @@ class OverlayTests(PersonalCase):
|
|||||||
self.assertEqual(wiring.quick_problem(), None)
|
self.assertEqual(wiring.quick_problem(), None)
|
||||||
os.remove(paths.generated())
|
os.remove(paths.generated())
|
||||||
self.assertIn("generated rulebook is missing", wiring.quick_problem())
|
self.assertIn("generated rulebook is missing", wiring.quick_problem())
|
||||||
self.ok("build-canon")
|
self.build_canon()
|
||||||
t = os.stat(os.path.join(self.p1, "canon", "core.md")).st_mtime_ns - 5_000_000_000
|
t = os.stat(os.path.join(self.p1, "canon", "core.md")).st_mtime_ns - 5_000_000_000
|
||||||
os.utime(paths.generated(), ns=(t, t))
|
os.utime(paths.generated(), ns=(t, t))
|
||||||
self.assertIn("out of date", wiring.quick_problem())
|
self.assertIn("out of date", wiring.quick_problem())
|
||||||
|
|
||||||
def test_one_commit_per_change_and_revert_restores_bytes(self):
|
def test_one_commit_per_change_and_revert_restores_bytes(self):
|
||||||
self.ok("build-canon")
|
self.build_canon()
|
||||||
n0 = len(self.git_log())
|
n0 = len(self.git_log())
|
||||||
steps = [(("add-rule", "--id", "delta", "-"), rule_file("Delta", "Body.")),
|
steps = [(("add-rule", "--id", "delta", "-"), rule_file("Delta", "Body.")),
|
||||||
(("replace-rule", "alpha", "-"), rule_file("Alpha, mine", "Mine.")),
|
(("replace-rule", "alpha", "-"), rule_file("Alpha, mine", "Mine.")),
|
||||||
@@ -237,14 +240,14 @@ class OverlayTests(PersonalCase):
|
|||||||
self.ok("overlay", "revert", pdata.git("rev-parse", "--short", "HEAD").stdout.strip())
|
self.ok("overlay", "revert", pdata.git("rev-parse", "--short", "HEAD").stdout.strip())
|
||||||
self.assertEqual(open(paths.generated(), "rb").read(), before)
|
self.assertEqual(open(paths.generated(), "rb").read(), before)
|
||||||
|
|
||||||
def test_canon_cost_and_status(self):
|
def test_doctor_shows_always_loaded_size(self):
|
||||||
self.ok("build-canon")
|
self.build_canon()
|
||||||
out = self.ok("canon", "cost").stdout
|
out = self.ok("doctor").stdout
|
||||||
lines = len(self.generated().splitlines())
|
lines = len(self.generated().splitlines())
|
||||||
self.assertIn("rulebook %d lines" % lines, out)
|
self.assertIn("rulebook %d lines" % lines, out)
|
||||||
self.assertIn("%d characters" % len(self.generated()), out)
|
self.assertIn("%d characters" % len(self.generated()), out)
|
||||||
self.assertIn("lessons block at most %d characters" % retro.LIMIT, out)
|
self.assertIn("lessons block at most %d characters" % retro.LIMIT, out)
|
||||||
self.assertIn(out.strip(), self.ok("status").stdout)
|
self.assertIn("rulebook %d lines" % lines, self.ok("status").stdout)
|
||||||
|
|
||||||
def test_core_md_rules_have_unique_ids_and_the_budget_holds(self):
|
def test_core_md_rules_have_unique_ids_and_the_budget_holds(self):
|
||||||
text = open(os.path.join(REPO, "canon", "core.md")).read()
|
text = open(os.path.join(REPO, "canon", "core.md")).read()
|
||||||
@@ -406,7 +409,7 @@ class MigrationTests(PersonalCase):
|
|||||||
self.legacy_state()
|
self.legacy_state()
|
||||||
before = self.lessons_of(os.path.join(self.state, "retro.db"))
|
before = self.lessons_of(os.path.join(self.state, "retro.db"))
|
||||||
self.assertEqual(len(before[0]), 2)
|
self.assertEqual(len(before[0]), 2)
|
||||||
out = self.ok("migrate").stdout
|
out = self.ok("update", "--post").stdout
|
||||||
self.assertIn("backed up", out)
|
self.assertIn("backed up", out)
|
||||||
for n in ("retro.db", "trusted.json", "config.json", "learn-quarantine.jsonl", "notes.jsonl", "proposals.jsonl", "manifest.json", "backups"):
|
for n in ("retro.db", "trusted.json", "config.json", "learn-quarantine.jsonl", "notes.jsonl", "proposals.jsonl", "manifest.json", "backups"):
|
||||||
self.assertFalse(os.path.exists(os.path.join(self.state, n)), n + " should have moved")
|
self.assertFalse(os.path.exists(os.path.join(self.state, n)), n + " should have moved")
|
||||||
@@ -425,10 +428,11 @@ class MigrationTests(PersonalCase):
|
|||||||
self.assertIn(f, files)
|
self.assertIn(f, files)
|
||||||
self.assertNotIn("retro.db", files)
|
self.assertNotIn("retro.db", files)
|
||||||
self.assertEqual(len(open(os.path.join(self.data, "lessons.jsonl")).read().splitlines()), 2 + len(before[1]))
|
self.assertEqual(len(open(os.path.join(self.data, "lessons.jsonl")).read().splitlines()), 2 + len(before[1]))
|
||||||
self.assertTrue(self.git_log()[0].startswith("migrate:"))
|
self.assertTrue(any(l.startswith("migrate:") for l in self.git_log()))
|
||||||
# the backup has what moved, before it moved
|
# the backup has what moved, before it moved
|
||||||
bk = os.path.join(self.data, "backups")
|
bk = os.path.join(self.data, "backups")
|
||||||
b = os.path.join(bk, os.listdir(bk)[0])
|
b = next(os.path.join(bk, d) for d in sorted(os.listdir(bk))
|
||||||
|
if os.path.exists(os.path.join(bk, d, "state", "retro.db")))
|
||||||
self.assertEqual(self.lessons_of(os.path.join(b, "state", "retro.db")), before)
|
self.assertEqual(self.lessons_of(os.path.join(b, "state", "retro.db")), before)
|
||||||
self.assertTrue(os.path.exists(os.path.join(b, "state", "trusted.json")))
|
self.assertTrue(os.path.exists(os.path.join(b, "state", "trusted.json")))
|
||||||
self.assertTrue(os.path.exists(os.path.join(b, "product", "canon", "oracle.md")))
|
self.assertTrue(os.path.exists(os.path.join(b, "product", "canon", "oracle.md")))
|
||||||
@@ -436,7 +440,7 @@ class MigrationTests(PersonalCase):
|
|||||||
self.assertTrue(os.path.exists(os.path.join(self.p1, "canon", "oracle.md")))
|
self.assertTrue(os.path.exists(os.path.join(self.p1, "canon", "oracle.md")))
|
||||||
# a second run does nothing
|
# a second run does nothing
|
||||||
n = len(self.git_log())
|
n = len(self.git_log())
|
||||||
self.assertIn("nothing to migrate", self.ok("migrate").stdout)
|
self.ok("update", "--post")
|
||||||
self.assertEqual(len(self.git_log()), n)
|
self.assertEqual(len(self.git_log()), n)
|
||||||
self.assertEqual(self.lessons_of(os.path.join(self.data, "retro.db")), before)
|
self.assertEqual(self.lessons_of(os.path.join(self.data, "retro.db")), before)
|
||||||
self.assertEqual(self.ok("lessons", "--json").stdout.count('"change_kind"'), 2)
|
self.assertEqual(self.ok("lessons", "--json").stdout.count('"change_kind"'), 2)
|
||||||
@@ -461,7 +465,7 @@ class MigrationTests(PersonalCase):
|
|||||||
change_kind="rule", change="Run sisi oracle before asking anything", target=None), self.proj, None)
|
change_kind="rule", change="Run sisi oracle before asking anything", target=None), self.proj, None)
|
||||||
con.commit()
|
con.commit()
|
||||||
con.close()
|
con.close()
|
||||||
self.ok("migrate")
|
self.ok("update", "--post")
|
||||||
rows, _ = self.lessons_of(os.path.join(self.data, "retro.db"))
|
rows, _ = self.lessons_of(os.path.join(self.data, "retro.db"))
|
||||||
changes = sorted(r["change"] for r in rows)
|
changes = sorted(r["change"] for r in rows)
|
||||||
self.assertEqual(len(changes), len(set(changes)), "a lesson was duplicated")
|
self.assertEqual(len(changes), len(set(changes)), "a lesson was duplicated")
|
||||||
@@ -472,7 +476,7 @@ class MigrationTests(PersonalCase):
|
|||||||
self.legacy_state()
|
self.legacy_state()
|
||||||
os.makedirs(os.path.join(self.data, "notes"))
|
os.makedirs(os.path.join(self.data, "notes"))
|
||||||
open(os.path.join(self.data, "notes", "fuzz.md"), "w").write("# Field notes for fuzz\n\n- newer note\n")
|
open(os.path.join(self.data, "notes", "fuzz.md"), "w").write("# Field notes for fuzz\n\n- newer note\n")
|
||||||
self.ok("migrate")
|
self.ok("update", "--post")
|
||||||
t = open(os.path.join(self.data, "notes", "fuzz.md")).read()
|
t = open(os.path.join(self.data, "notes", "fuzz.md")).read()
|
||||||
self.assertIn("newer note", t)
|
self.assertIn("newer note", t)
|
||||||
self.assertIn("a field note", t)
|
self.assertIn("a field note", t)
|
||||||
@@ -736,10 +740,10 @@ class ProductIsReadOnlyTests(PersonalCase):
|
|||||||
out.seek(0), err.seek(0)
|
out.seek(0), err.seek(0)
|
||||||
return subprocess.CompletedProcess(a, p.returncode, out.read(), err.read())
|
return subprocess.CompletedProcess(a, p.returncode, out.read(), err.read())
|
||||||
gate_in = json.dumps({"session_id": "s1", "cwd": self.proj, "stop_hook_active": False})
|
gate_in = json.dumps({"session_id": "s1", "cwd": self.proj, "stop_hook_active": False})
|
||||||
cmds = [("install",), ("doctor",), ("tick", "--tool", "t"), ("build-canon",), ("status",),
|
cmds = [("install",), ("doctor",), ("tick", "--tool", "t"), ("status",),
|
||||||
("overlay", "add-rule", "--id", "z", "-"), ("overlay", "diff"), ("overlay", "disable-rule", "z"),
|
("overlay", "add-rule", "--id", "z", "-"), ("overlay", "diff"), ("overlay", "disable-rule", "z"),
|
||||||
("learn", "--scope", "everywhere", "x"), ("lessons", "export"), ("verifiers", "show", "shellcheck"),
|
("learn", "--scope", "everywhere", "x"), ("lessons", "export"), ("verifiers", "show", "shellcheck"),
|
||||||
("contract", "init", "--goal", "g"), ("verify",), ("migrate",), ("update",),
|
("contract", "init", "--goal", "g"), ("verify",), ("update", "--post"),
|
||||||
("export", os.path.join(self.tmp, "e.tar.gz")), ("gate",), ("uninstall",)]
|
("export", os.path.join(self.tmp, "e.tar.gz")), ("gate",), ("uninstall",)]
|
||||||
for c in cmds:
|
for c in cmds:
|
||||||
r = run(*c, stdin=rule_file("Z", "Zed.") if c[:2] == ("overlay", "add-rule") else (gate_in if c == ("gate",) else None))
|
r = run(*c, stdin=rule_file("Z", "Zed.") if c[:2] == ("overlay", "add-rule") else (gate_in if c == ("gate",) else None))
|
||||||
|
|||||||
@@ -125,7 +125,7 @@ class ReadmeIsHonest(SisiCase):
|
|||||||
def test_readme_sub_subcommands_are_in_help(self):
|
def test_readme_sub_subcommands_are_in_help(self):
|
||||||
text = open(os.path.join(REPO, "README.md"), encoding="utf-8").read()
|
text = open(os.path.join(REPO, "README.md"), encoding="utf-8").read()
|
||||||
help_text = self.sisi("help").stdout
|
help_text = self.sisi("help").stdout
|
||||||
for m in set(re.findall(r"`sisi (contract|verifiers|canon|overlay|dev) ([a-z-]+)", text)):
|
for m in set(re.findall(r"`sisi (contract|verifiers|overlay) ([a-z-]+)", text)):
|
||||||
self.assertIn(m[1], help_text, " ".join(m))
|
self.assertIn(m[1], help_text, " ".join(m))
|
||||||
|
|
||||||
def test_python_version_claim_matches_ci_and_code(self):
|
def test_python_version_claim_matches_ci_and_code(self):
|
||||||
@@ -152,8 +152,10 @@ class NoStaleValues(unittest.TestCase):
|
|||||||
|
|
||||||
def test_docs_have_no_stale_values(self):
|
def test_docs_have_no_stale_values(self):
|
||||||
rels = ["CONTRIBUTING.md", "SECURITY.md"]
|
rels = ["CONTRIBUTING.md", "SECURITY.md"]
|
||||||
|
# docs/target.md is the reconciliation build reference: its start date and "as today"
|
||||||
|
# describe that project, not the product, so they do not go stale with the product.
|
||||||
rels += [os.path.join("docs", n) for n in sorted(os.listdir(os.path.join(REPO, "docs")))
|
rels += [os.path.join("docs", n) for n in sorted(os.listdir(os.path.join(REPO, "docs")))
|
||||||
if n.endswith(".md")]
|
if n.endswith(".md") and n != "target.md"]
|
||||||
findings = []
|
findings = []
|
||||||
for rel in rels:
|
for rel in rels:
|
||||||
findings += _stale_value_findings(_text(rel), rel, allow_version_evidence=True)
|
findings += _stale_value_findings(_text(rel), rel, allow_version_evidence=True)
|
||||||
|
|||||||
+19
-39
@@ -225,48 +225,29 @@ class TestInstallUsesStable(ReleaseCase):
|
|||||||
self.assertNotIn("run `sisi install`", r.stdout)
|
self.assertNotIn("run `sisi install`", r.stdout)
|
||||||
|
|
||||||
def test_doctor_reports_live_copy_and_source_ahead(self):
|
def test_doctor_reports_live_copy_and_source_ahead(self):
|
||||||
self.sisi("dev", "on", self.src)
|
|
||||||
self.rel()
|
self.rel()
|
||||||
r = self.sisi("doctor")
|
with mock.patch.object(paths, "REPO", self.src):
|
||||||
self.assertIn("release " + release.current_name(), r.stdout)
|
r = self.sisi("doctor")
|
||||||
self.assertIn("in step", r.stdout)
|
self.assertIn("release " + release.current_name(), r.stdout)
|
||||||
open(os.path.join(self.src, "docs", "more.md"), "w").write("x")
|
self.assertIn("in step", r.stdout)
|
||||||
r = self.sisi("doctor")
|
open(os.path.join(self.src, "docs", "more.md"), "w").write("x")
|
||||||
self.assertIn("ahead (1 file differ)", r.stdout)
|
r = self.sisi("doctor")
|
||||||
|
self.assertIn("ahead (1 file differ)", r.stdout)
|
||||||
|
|
||||||
|
|
||||||
class TestDev(ReleaseCase):
|
class TestSource(ReleaseCase):
|
||||||
def test_on_off_status(self):
|
def test_source_is_the_launcher_folder(self):
|
||||||
self.assertIn("off", self.sisi("dev", "status").stdout)
|
self.assertEqual(release.source(), REPO)
|
||||||
r = self.sisi("dev", "on", self.src)
|
self.assertEqual(release.source(self.src), self.src)
|
||||||
self.assertEqual(r.returncode, 0, r.stderr)
|
with self.assertRaises(release.ReleaseError):
|
||||||
self.assertEqual(paths.personal_config()["developer"]["source"], self.src)
|
release.source(self.proj)
|
||||||
self.assertEqual(store_cfg()["developer"]["source"], self.src)
|
|
||||||
self.assertIn(self.src, self.sisi("dev", "status").stdout)
|
|
||||||
self.assertEqual(self.sisi("dev", "off").returncode, 0)
|
|
||||||
self.assertNotIn("developer", paths.personal_config())
|
|
||||||
self.assertIn("off", self.sisi("dev", "status").stdout)
|
|
||||||
|
|
||||||
def test_on_rejects_non_source_and_keeps_other_config(self):
|
def test_release_from_stable_copy_is_refused(self):
|
||||||
r = self.sisi("dev", "on", self.proj)
|
self.assertEqual(self.sisi("release", self.src).returncode, 0)
|
||||||
self.assertEqual(r.returncode, 1)
|
|
||||||
os.makedirs(self.data, exist_ok=True)
|
|
||||||
json.dump({"gate": {"budget_s": 5}, "developer": {"personal_terms": ["zed"]}}, open(os.path.join(self.data, "config.json"), "w"))
|
|
||||||
self.sisi("dev", "on", self.src)
|
|
||||||
self.sisi("dev", "off")
|
|
||||||
cfg = paths.personal_config()
|
|
||||||
self.assertEqual(cfg["gate"], {"budget_s": 5})
|
|
||||||
self.assertEqual(cfg["developer"], {"personal_terms": ["zed"]})
|
|
||||||
|
|
||||||
def test_release_finds_source_from_release_copy(self):
|
|
||||||
self.sisi("dev", "on", self.src)
|
|
||||||
self.assertEqual(self.sisi("release").returncode, 0)
|
|
||||||
with mock.patch.object(paths, "REPO", self.current()): # now running as the stable copy
|
with mock.patch.object(paths, "REPO", self.current()): # now running as the stable copy
|
||||||
self.assertEqual(release.source(), self.src)
|
|
||||||
self.assertEqual(self.sisi("release").returncode, 0)
|
|
||||||
self.sisi("dev", "off")
|
|
||||||
with self.assertRaises(release.ReleaseError):
|
with self.assertRaises(release.ReleaseError):
|
||||||
release.source()
|
release.source()
|
||||||
|
self.assertEqual(self.sisi("release").returncode, 1)
|
||||||
|
|
||||||
|
|
||||||
def store_cfg():
|
def store_cfg():
|
||||||
@@ -277,10 +258,9 @@ def store_cfg():
|
|||||||
class TestPromote(ReleaseCase):
|
class TestPromote(ReleaseCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super().setUp()
|
super().setUp()
|
||||||
self.sisi("dev", "on", self.src)
|
|
||||||
self.assertEqual(self.rel().returncode, 0)
|
self.assertEqual(self.rel().returncode, 0)
|
||||||
# run as the stable copy, so the source is found through developer mode and never the real repository
|
# run from the clone: the launcher folder is the source, never the real repository
|
||||||
p = mock.patch.object(paths, "REPO", self.current())
|
p = mock.patch.object(paths, "REPO", self.src)
|
||||||
p.start()
|
p.start()
|
||||||
self.addCleanup(p.stop)
|
self.addCleanup(p.stop)
|
||||||
self.assertEqual(release.source(), self.src)
|
self.assertEqual(release.source(), self.src)
|
||||||
@@ -297,7 +277,7 @@ class TestPromote(ReleaseCase):
|
|||||||
|
|
||||||
def test_dry_run_lists_scrubbed_and_writes_nothing(self):
|
def test_dry_run_lists_scrubbed_and_writes_nothing(self):
|
||||||
self.put("done/my-recipe.md", "see /home/alice/Code/x and bob@example.com, alice said Acme rules\n")
|
self.put("done/my-recipe.md", "see /home/alice/Code/x and bob@example.com, alice said Acme rules\n")
|
||||||
json.dump({"developer": {"source": self.src, "personal_terms": ["Acme"]}}, open(os.path.join(self.data, "config.json"), "w"))
|
json.dump({"developer": {"personal_terms": ["Acme"]}}, open(os.path.join(self.data, "config.json"), "w"))
|
||||||
r = self.promote("my-recipe")
|
r = self.promote("my-recipe")
|
||||||
self.assertEqual(r.returncode, 0, r.stderr)
|
self.assertEqual(r.returncode, 0, r.stderr)
|
||||||
for t in ("/home/alice", "bob@example.com", "alice", "Acme", "dry run"):
|
for t in ("/home/alice", "bob@example.com", "alice", "Acme", "dry run"):
|
||||||
|
|||||||
+3
-4
@@ -673,12 +673,11 @@ class CliHookTests(SisiCase):
|
|||||||
self.assertEqual(cli._learn_cli("harvest", []), 70) # import of the module fails
|
self.assertEqual(cli._learn_cli("harvest", []), 70) # import of the module fails
|
||||||
self.assertEqual(self.sisi("help").returncode, 0)
|
self.assertEqual(self.sisi("help").returncode, 0)
|
||||||
|
|
||||||
def test_help_points_to_retro_and_note_propose_still_work(self):
|
def test_help_points_to_retro(self):
|
||||||
out = self.sisi("help").stdout
|
out = self.sisi("help").stdout
|
||||||
self.assertIn("sisi retro", out)
|
self.assertIn("sisi retro", out)
|
||||||
self.assertIn("prefer retro", out)
|
self.assertEqual(self.sisi("note", "still works").returncode, 64)
|
||||||
self.assertEqual(self.sisi("note", "still works").returncode, 0)
|
self.assertEqual(self.sisi("propose", "still works").returncode, 64)
|
||||||
self.assertEqual(self.sisi("propose", "still works").returncode, 0)
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|||||||
+11
-27
@@ -81,23 +81,14 @@ class StoreTests(SisiCase):
|
|||||||
with open(os.path.join(self.data, name)) as f: # what the person taught sisi is personal data
|
with open(os.path.join(self.data, name)) as f: # what the person taught sisi is personal data
|
||||||
return [json.loads(l) for l in f]
|
return [json.loads(l) for l in f]
|
||||||
|
|
||||||
def test_note_propose_learn_append_with_context(self):
|
def test_learn_appends_with_context(self):
|
||||||
for cmd, fn in (("note", "notes.jsonl"), ("propose", "proposals.jsonl"), ("learn", "learn.jsonl")):
|
self.assertEqual(self.sisi("learn", "--scope", "everywhere", "first", "entry", env={"SISI_TOOL": "codex", "SISI_SESSION_ID": "s9"}).returncode, 0)
|
||||||
extra = ["--scope", "everywhere"] if cmd == "learn" else []
|
self.sisi("learn", "--scope", "everywhere", "second")
|
||||||
self.assertEqual(self.sisi(cmd, *(extra + ["first", "entry"]), env={"SISI_TOOL": "codex", "SISI_SESSION_ID": "s9"}).returncode, 0)
|
recs = self.read("learn.jsonl")
|
||||||
self.sisi(cmd, *(extra + ["second"]))
|
self.assertEqual([r["text"] for r in recs], ["first entry", "second"])
|
||||||
recs = self.read(fn)
|
self.assertEqual(recs[0]["cwd"], self.proj)
|
||||||
self.assertEqual([r["text"] for r in recs], ["first entry", "second"])
|
self.assertEqual((recs[0]["tool"], recs[0]["session"]), ("codex", "s9"))
|
||||||
self.assertEqual(recs[0]["cwd"], self.proj)
|
self.assertIn("ts", recs[0])
|
||||||
self.assertEqual((recs[0]["tool"], recs[0]["session"]), ("codex", "s9"))
|
|
||||||
self.assertIn("ts", recs[0])
|
|
||||||
# learn never reaches the other files
|
|
||||||
self.assertEqual(len(self.read("notes.jsonl")), 2)
|
|
||||||
self.assertEqual(len(self.read("proposals.jsonl")), 2)
|
|
||||||
|
|
||||||
def test_empty_text_rejected(self):
|
|
||||||
self.assertEqual(self.sisi("note").returncode, 1)
|
|
||||||
self.assertFalse(os.path.exists(os.path.join(self.data, "notes.jsonl")))
|
|
||||||
|
|
||||||
def test_oracle_prints_file(self):
|
def test_oracle_prints_file(self):
|
||||||
r = self.sisi("oracle")
|
r = self.sisi("oracle")
|
||||||
@@ -107,10 +98,10 @@ class StoreTests(SisiCase):
|
|||||||
import threading
|
import threading
|
||||||
def w(i):
|
def w(i):
|
||||||
for j in range(50):
|
for j in range(50):
|
||||||
store.append("notes", {"i": i, "j": j, "pad": "x" * 200})
|
store.append("learn", {"i": i, "j": j, "pad": "x" * 200})
|
||||||
ts = [threading.Thread(target=w, args=(i,)) for i in range(6)]
|
ts = [threading.Thread(target=w, args=(i,)) for i in range(6)]
|
||||||
[t.start() for t in ts]; [t.join() for t in ts]
|
[t.start() for t in ts]; [t.join() for t in ts]
|
||||||
self.assertEqual(len(self.read("notes.jsonl")), 300)
|
self.assertEqual(len(self.read("learn.jsonl")), 300)
|
||||||
|
|
||||||
def test_status(self):
|
def test_status(self):
|
||||||
self.write_contract(contract([check("a", "true", rung=2), check("b", "true", rung=3), human("h")]))
|
self.write_contract(contract([check("a", "true", rung=2), check("b", "true", rung=3), human("h")]))
|
||||||
@@ -128,7 +119,7 @@ class StoreTests(SisiCase):
|
|||||||
class HelpTests(SisiCase):
|
class HelpTests(SisiCase):
|
||||||
def test_help_and_unknown(self):
|
def test_help_and_unknown(self):
|
||||||
out = self.sisi("help").stdout
|
out = self.sisi("help").stdout
|
||||||
for w in ("verify", "gate", "tick", "install", "audit", "learn", "verifiers"):
|
for w in ("verify", "gate", "tick", "install", "learn", "verifiers"):
|
||||||
self.assertIn(w, out)
|
self.assertIn(w, out)
|
||||||
self.assertNotEqual(self.sisi("bogus").returncode, 0)
|
self.assertNotEqual(self.sisi("bogus").returncode, 0)
|
||||||
|
|
||||||
@@ -145,13 +136,6 @@ class HelpTests(SisiCase):
|
|||||||
r = self.sisi(a)
|
r = self.sisi(a)
|
||||||
self.assertEqual((r.returncode, r.stdout.strip()), (0, want), a)
|
self.assertEqual((r.returncode, r.stdout.strip()), (0, want), a)
|
||||||
|
|
||||||
def test_audit_runs_on_fake_home(self):
|
|
||||||
os.makedirs(os.path.join(self.home, ".claude"))
|
|
||||||
with open(os.path.join(self.home, ".claude", "CLAUDE.md"), "w") as f:
|
|
||||||
f.write("a\nb\n")
|
|
||||||
out = self.sisi("audit").stdout
|
|
||||||
self.assertIn("claude-code", out)
|
|
||||||
self.assertIn("global instructions", out)
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
"""Three tiers (core, user, project): round-trips, migration of `everywhere`, the sisi-name
|
"""Three tiers (core, user, project): round-trips, migration of `everywhere`, the sisi-name
|
||||||
exemption, promote on a developer install, export, and exact cycle revert with tiers."""
|
exemption, promote from the clone, export, and exact cycle revert with tiers."""
|
||||||
import json, os, shutil, subprocess, unittest
|
import json, os, shutil, subprocess, unittest
|
||||||
from support import *
|
from support import *
|
||||||
from sisi import retro, scope, store
|
from sisi import paths, retro, scope, store
|
||||||
|
from unittest import mock
|
||||||
|
|
||||||
WHEN = "csv, tsv, spreadsheet, tabular data, import, export, parse, delimited file"
|
WHEN = "csv, tsv, spreadsheet, tabular data, import, export, parse, delimited file"
|
||||||
PATTERN = "Build the obvious thing instead of using what the environment already provides"
|
PATTERN = "Build the obvious thing instead of using what the environment already provides"
|
||||||
@@ -115,7 +116,9 @@ class PromoteTierTests(SisiCase):
|
|||||||
open(os.path.join(self.src, "sisi", "cli.py"), "w").write("# cli\n")
|
open(os.path.join(self.src, "sisi", "cli.py"), "w").write("# cli\n")
|
||||||
shutil.copy(os.path.join(REPO, "canon", "core.md"), os.path.join(self.src, "canon", "core.md"))
|
shutil.copy(os.path.join(REPO, "canon", "core.md"), os.path.join(self.src, "canon", "core.md"))
|
||||||
os.makedirs(os.path.join(self.data), exist_ok=True)
|
os.makedirs(os.path.join(self.data), exist_ok=True)
|
||||||
json.dump({"developer": {"source": self.src}}, open(os.path.join(self.data, "config.json"), "w"))
|
_p = mock.patch.object(paths, "REPO", self.src) # run from the clone
|
||||||
|
_p.start()
|
||||||
|
self.addCleanup(_p.stop)
|
||||||
|
|
||||||
def core_lesson_folded_to_rule(self):
|
def core_lesson_folded_to_rule(self):
|
||||||
r = retro_cli(self, "core")
|
r = retro_cli(self, "core")
|
||||||
@@ -138,7 +141,7 @@ class PromoteTierTests(SisiCase):
|
|||||||
out = self.sisi("promote").stdout
|
out = self.sisi("promote").stdout
|
||||||
self.assertIn("lesson:1", out)
|
self.assertIn("lesson:1", out)
|
||||||
|
|
||||||
def test_promote_on_dev_install_edits_product_and_drops_personal_copy(self):
|
def test_promote_from_clone_edits_product_and_drops_personal_copy(self):
|
||||||
self.core_lesson_folded_to_rule()
|
self.core_lesson_folded_to_rule()
|
||||||
overlay_file = os.path.join(self.data, "overlay", "rules", "quoting-writer.md")
|
overlay_file = os.path.join(self.data, "overlay", "rules", "quoting-writer.md")
|
||||||
self.assertTrue(os.path.exists(overlay_file))
|
self.assertTrue(os.path.exists(overlay_file))
|
||||||
|
|||||||
Reference in new issue
Block a user