feat(7835): what resembles the work but is not shown is named by id in one pointer line
CI & Build / Python lint (push) Successful in 3s
CI & Build / Plugin hooks (push) Successful in 13s
CI & Build / TypeScript typecheck (push) Successful in 35s
CI & Build / Python tests (push) Failing after 2m1s
CI & Build / integration (push) Successful in 2m20s
CI & Build / Build & push image (push) Skipped
CI & Build / Python lint (push) Successful in 3s
CI & Build / Plugin hooks (push) Successful in 13s
CI & Build / TypeScript typecheck (push) Successful in 35s
CI & Build / Python tests (push) Failing after 2m1s
CI & Build / integration (push) Successful in 2m20s
CI & Build / Build & push image (push) Skipped
A pointer before a payload:
- the notes arms fetch a few results past the menu; those that cleared
the floor but were held back by the gate, the band or the budget are
named by id per kind, with the call that opens each kind, in one line
("Also resembling this, not shown: ...") at the message and the write
path;
- they are recorded in the record ledger as `pointed`, so an open that
follows is counted apart from pushed lines;
- setting a task in progress returns records_in_area: the notes and open
issues tagged to the task's areas, by id (a work.start row in the
kind x moment table says which kinds; it answers in a tool reply, so it
is shown as unmeasured).
The static context says what a pointer line means. Plugin version minted.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -31,10 +31,10 @@ back to its default removes the stored change.
|
||||
|
||||
THE DOORS
|
||||
|
||||
A door is a point where a record search fires: a catalog moment
|
||||
(`work.change`), or the operator's message, which is when a session first
|
||||
hears what the work is and is not a moment rules mount on, so it has its
|
||||
own key (`message`).
|
||||
A door is a point where records are offered: a catalog moment
|
||||
(`work.change` before a write, `work.start` when a task is taken up), or the
|
||||
operator's message, which is when a session first hears what the work is and
|
||||
is not a moment rules mount on, so it has its own key (`message`).
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
@@ -98,6 +98,13 @@ DOORS: dict[str, Door] = {
|
||||
sources=("write_path_semantic", "write_path_place", "write_path_sync",
|
||||
"write_path_linked"),
|
||||
),
|
||||
# Taking up a task: what is recorded in the task's own areas, named by id
|
||||
# in the reply that set it in progress. Notes for what is known there,
|
||||
# open issues for what is still wrong there.
|
||||
"work.start": Door(
|
||||
"work.start", "Taking up a piece of work", "when a task is set in progress",
|
||||
frozenset({"note", "task:issue"}),
|
||||
),
|
||||
}
|
||||
|
||||
|
||||
@@ -139,6 +146,59 @@ def kinds_clause(kinds: Iterable[str]):
|
||||
return or_(*parts) if parts else false()
|
||||
|
||||
|
||||
# A pointer line names at most this many records of a kind; the count says
|
||||
# how many there were.
|
||||
POINTER_IDS = 3
|
||||
_PLURALS = {
|
||||
"snippet": "snippets", "note": "notes", "lesson": "lessons", "process": "processes",
|
||||
"task:issue": "issues", "task:work": "tasks", "task:spike": "spikes",
|
||||
"task:plan": "plans",
|
||||
}
|
||||
|
||||
|
||||
def opener(kind: str) -> str:
|
||||
"""The MCP call that opens a record of this kind."""
|
||||
if kind.startswith(TASK_PREFIX):
|
||||
return "get_task"
|
||||
return {"snippet": "get_snippet", "lesson": "get_lesson",
|
||||
"process": "get_process"}.get(kind, "get_note")
|
||||
|
||||
|
||||
def pointer_line(
|
||||
pointers: dict[str, list[int]], lead: str, *, capped_at: int | None = None,
|
||||
) -> tuple[str, list[int]] | None:
|
||||
"""One line naming records by id, per kind, with the call that opens each
|
||||
kind; and the ids it named. None when there is nothing to point at.
|
||||
|
||||
A line and a passage per record is what a payload cannot afford for
|
||||
everything that may bear on the work; an id costs a few characters, and
|
||||
the session is the one placed to judge whether to open it. A kind with
|
||||
more records than it names says how many; `capped_at` is the depth the
|
||||
lookup stopped at, so a count that reached it reads as "at least".
|
||||
"""
|
||||
named: list[int] = []
|
||||
phrases: list[str] = []
|
||||
for kind in KINDS:
|
||||
ids = pointers.get(kind) or []
|
||||
if not ids:
|
||||
continue
|
||||
shown = ids[:POINTER_IDS]
|
||||
named.extend(shown)
|
||||
count = ""
|
||||
if len(ids) > len(shown):
|
||||
count = f"{len(ids)}+ " if capped_at and len(ids) >= capped_at else f"{len(ids)} "
|
||||
phrases.append(
|
||||
f"{count}{_PLURALS[kind]} " + ", ".join(f"#{i}" for i in shown)
|
||||
+ f" (`{opener(kind)}(id)`)"
|
||||
)
|
||||
if not phrases:
|
||||
return None
|
||||
return (
|
||||
f"> {lead}: " + "; ".join(phrases) + ". Open one if it may bear on the work.",
|
||||
named,
|
||||
)
|
||||
|
||||
|
||||
async def _stored(user_id: int) -> dict[str, frozenset[str]]:
|
||||
from grimoire.services.settings import get_setting
|
||||
|
||||
@@ -195,6 +255,9 @@ async def table(user_id: int, days: int = 30) -> dict:
|
||||
"kinds": sorted(stored.get(d.key, d.default), key=KINDS.index),
|
||||
"default": sorted(d.default, key=KINDS.index),
|
||||
"changed": d.key in stored,
|
||||
# A door whose lines reach the session in a tool reply rather
|
||||
# than a plugin hook has no session to record them against.
|
||||
"measured": bool(d.sources),
|
||||
"evidence": (evidence or {}).get(d.key, {}),
|
||||
}
|
||||
for d in DOORS.values()
|
||||
|
||||
Reference in New Issue
Block a user