pi-sleep-agent 0.8.11 → 0.8.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/package.json +1 -1
- package/sleepkit/cli.py +40 -1
package/README.md
CHANGED
|
@@ -34,6 +34,7 @@ Sleep adds a reviewable memory cycle to nine selectable coding-agent targets. It
|
|
|
34
34
|
- **Project isolation.** A project's provisional memory is injected only into that project.
|
|
35
35
|
- **Reviewable permanence.** Each approved memory in your index carries its review date and source, so you can tell when a saved instruction was pinned.
|
|
36
36
|
- **Relevance-ranked injection.** With a query, provisional memory is ordered by overlap with the live request and each line carries its age, so the most relevant record survives the `--max` cut and stale facts read as stale.
|
|
37
|
+
- **Indexed by default.** A long observation is injected as its opening claim plus a pointer (`[+714 chars: sleep.py show <id>]`) instead of its whole narrative; `inject --full` prints the complete bodies. Measured on a live pool of 11 records: 5581 -> 3377 characters per injection.
|
|
37
38
|
- **Stale-value scan.** `doctor --stale <value>` finds which approved records still hold a value you know has changed (for example a deployment URL). Unreviewed provisional candidates are also flagged: a fact the agent proposed once and never rediscovered for 4+ weeks keeps getting injected into every session's context, so `doctor` surfaces it as `stale-candidate-unrediscovered` (a report line it never acts on, nothing is dropped).
|
|
38
39
|
- **Safety gates.** Secrets are redacted, hostile text is quarantined, and machine-generated prompts cannot claim user provenance.
|
|
39
40
|
|
|
@@ -335,6 +336,7 @@ name: it routes through its own config, so only `SLEEP_MODEL` reaches it.
|
|
|
335
336
|
| `./sleep.py supersede <old> <new>` | Mark `<old>` invalid as of now and `<new>` valid as of now (`valid_until` / `valid_from`), so the window a memory was true is readable from the files |
|
|
336
337
|
| `./sleep.py inject --project "$PWD"` | Print provisional context for the current project, newest first, each line dated |
|
|
337
338
|
| `./sleep.py inject --project "$PWD" --query "..."` | Same, but rank records by overlap with the live request so the most relevant survive `--max` |
|
|
339
|
+
| `./sleep.py inject --project "$PWD" --full` | Print each record's whole body instead of the index line |
|
|
338
340
|
|
|
339
341
|
Run `./sleep.py <command> --help` for command-specific options.
|
|
340
342
|
|
package/package.json
CHANGED
package/sleepkit/cli.py
CHANGED
|
@@ -506,10 +506,38 @@ def _inject_rank(records: list, query: str) -> list:
|
|
|
506
506
|
return sorted(records, key=lambda c: c.get("ts", ""), reverse=True)
|
|
507
507
|
|
|
508
508
|
|
|
509
|
+
INDEX_CHARS = 160
|
|
510
|
+
|
|
511
|
+
|
|
512
|
+
def _index_line(body: str, cid: str) -> str:
|
|
513
|
+
"""First sentence up to INDEX_CHARS, plus how much text and how to read the rest.
|
|
514
|
+
|
|
515
|
+
The pointer is the whole point: an index that hides the remainder without naming a
|
|
516
|
+
way to open it turns a disclosure step into a dead end.
|
|
517
|
+
"""
|
|
518
|
+
text = " ".join((body or "").split())
|
|
519
|
+
if len(text) <= INDEX_CHARS:
|
|
520
|
+
return text
|
|
521
|
+
cut = text[:INDEX_CHARS]
|
|
522
|
+
stop = max(cut.rfind(". "), cut.rfind("; "))
|
|
523
|
+
if stop > 60:
|
|
524
|
+
cut = cut[: stop + 1]
|
|
525
|
+
else:
|
|
526
|
+
# no sentence ended inside the window: break on a word boundary rather than
|
|
527
|
+
# mid-token, then close any parenthesis the cut left open
|
|
528
|
+
space = cut.rfind(" ")
|
|
529
|
+
if space > 40:
|
|
530
|
+
cut = cut[:space]
|
|
531
|
+
cut = cut.rstrip() + ("…" if cut.count("(") > cut.count(")") else "")
|
|
532
|
+
rest = len(text) - len(cut.rstrip("…"))
|
|
533
|
+
return "%s [+%d chars: sleep.py show %s]" % (cut.rstrip(), rest, cid)
|
|
534
|
+
|
|
535
|
+
|
|
509
536
|
def cmd_inject(a) -> int:
|
|
510
537
|
"""Print the provisional-memory block for a session's context. Framed as context."""
|
|
511
538
|
pool = [c for c in store.list_candidates(status="provisional", with_body=True)
|
|
512
539
|
if _within_project(c.get("cwd", ""), a.project)]
|
|
540
|
+
full = bool(getattr(a, "full", False))
|
|
513
541
|
recs = []
|
|
514
542
|
for c in _inject_rank(pool, getattr(a, "query", "") or ""):
|
|
515
543
|
body = c.get("_body", "")
|
|
@@ -520,7 +548,16 @@ def cmd_inject(a) -> int:
|
|
|
520
548
|
# its concrete targets masked so a wrong guess stays unactionable.
|
|
521
549
|
if not (src == "user" and trust == "verified"):
|
|
522
550
|
body, _ = safety.mask_unverified_targets(body)
|
|
523
|
-
|
|
551
|
+
if full:
|
|
552
|
+
shown = body
|
|
553
|
+
else:
|
|
554
|
+
# Progressive disclosure: the body of a long observation can run past 1000
|
|
555
|
+
# characters (measured: 11 records = 5581 chars carried in full), and most of
|
|
556
|
+
# that is narrative a session does not need to act. The index carries what a
|
|
557
|
+
# session needs to judge relevance - the claim's opening and how to open the
|
|
558
|
+
# rest - so the full text is one command away instead of always in context.
|
|
559
|
+
shown = _index_line(body, c.get("id", ""))
|
|
560
|
+
line = safety.render_for_context({"text": shown, "source": src, "trust": trust})
|
|
524
561
|
age = _age_label(c.get("ts", ""))
|
|
525
562
|
if age:
|
|
526
563
|
line += " (recorded %s)" % age
|
|
@@ -676,6 +713,8 @@ def main(argv=None) -> int:
|
|
|
676
713
|
ij.add_argument("--query", default="",
|
|
677
714
|
help="rank provisional records by overlap with this text "
|
|
678
715
|
"(the live request); newest first when omitted")
|
|
716
|
+
ij.add_argument("--full", action="store_true",
|
|
717
|
+
help="print each record's whole body instead of the index line")
|
|
679
718
|
ij.set_defaults(fn=cmd_inject)
|
|
680
719
|
|
|
681
720
|
a = ap.parse_args(argv)
|