opsward.weekly#
The weekly look: the agent setup’s five numbers, against last week, and one proposed change.
The setup-self-improvement loop asks for one improvement a week, chosen from five numbers
and passed through a human gate. This module prints the numbers; the user picks the change.
It only reads, and the only thing it writes is its own history (one JSON file per run).
The five numbers, over the last days (30 by default):
Search before write: of the new source files an agent wrote, the share written after the session had searched what the fleet already has (an Explore agent, a search skill such as
fleet-protocol, orir/projreg/priv find/gh searchin Bash). Local greps are counted beside it as context: agents run them in nearly every session. A file counts as new when the session writes it without having read or edited it first.Skills never invoked: the share of installed skills no session invoked (with the invocation count per skill). Never-invoked skills are candidates for name-only or deletion, not for a longer description.
CLAUDE.md before edit: of the packages a session edited, the share whose nearest
CLAUDE.mdthe session had loaded first (its cwd is inside the package, or it read the file before the first edit).Component issues per week: issues titled
Component: ...the owner filed.Corrections written back:
writeback-seenevents over the triggers (trigger-prompt,trigger-fix-commit) in the fix-at-source hook’s event log.
Only metadata is read: tool names, file paths, skill names, timestamps. Never prompt or file
text. Every source is a keyword argument (sessions, skills_dirs, search,
events, history), so a caller or a test can point it elsewhere.
>>> NUMBERS[0].key, NUMBERS[1].better
('search_before_write', 'lower')
Module Attributes
an Explore agent, a search skill, or a fleet search command at the start of a Bash command (not after a pipe). |
|
Grep and Glob, or rg/grep/find/fd starting a Bash command. |
|
|
Functions
|
Number 3: (session, package) pairs whose nearest |
|
Number 4: |
|
Number 5: corrections written back ( |
|
How many issues the |
|
Skill names: the folders holding a |
|
One target condition: the number that got worse the most since last time; with no history, the weakest of the shares (a share's distance from its best value). |
|
The fix-at-source hook's events ( |
|
The weekly look as a markdown page: the numbers, the change since last time, one proposal. |
|
Number 1: new source files written after a fleet search, over all new source files. |
|
Number 2: invocations per skill, and the installed skills no session invoked. |
|
|
|
Top-level Claude Code transcripts under |
|
The five numbers over the last |
Classes
|
One of the five: where its value is in the result, which way is better, and the change it suggests. |
- opsward.weekly.LOCAL_SEARCH_TOOLS = ('Grep', 'Glob')#
Grep and Glob, or rg/grep/find/fd starting a Bash command. Agents do this in nearly every session, so it is reported as context, not as the number.
- Type:
A local search
- class opsward.weekly.Number(key, label, field, better, target)[source]#
Bases:
objectOne of the five: where its value is in the result, which way is better, and the change it suggests.
- opsward.weekly.SEARCH_AGENTS = ('Explore',)#
an Explore agent, a search skill, or a fleet search command at the start of a Bash command (not after a pipe).
- Type:
A search of what the fleet already has (the fleet-protocol meaning)
- opsward.weekly.claude_md_before_edit(sessions, *, is_file=None, stop='~')[source]#
Number 3: (session, package) pairs whose nearest
CLAUDE.mdwas loaded before the first edit.Loaded means the session’s cwd is inside the package (Claude Code loads it), or the session read the file.
stopis where the search for aCLAUDE.mdends (default: home).- Return type:
- opsward.weekly.component_issues(*, days, now, search=<function gh_component_issues>)[source]#
Number 4:
Component:issues filed in the window, and per week.- Return type:
- opsward.weekly.corrections(events, *, days, now)[source]#
Number 5: corrections written back (
writeback-seen) over triggers, in the window.- Return type:
- opsward.weekly.gh_component_issues(*, since, title='Component:', limit=500)[source]#
How many issues the
ghuser filed sincesince(a date) whose title hastitle.- Return type:
- opsward.weekly.installed_skills(dirs)[source]#
Skill names: the folders holding a
SKILL.mddirectly under each ofdirs.
- opsward.weekly.propose(result, previous)[source]#
One target condition: the number that got worse the most since last time; with no history, the weakest of the shares (a share’s distance from its best value).
>>> r = {"search_before_write": {"ratio": 0.9}, "corrections": {"ratio": 0.4}} >>> propose(r, None)["key"] 'corrections' >>> propose(r, {"numbers": {"search_before_write": 1.0, "corrections": 0.4}})["key"] 'search_before_write'
- Return type:
- opsward.weekly.read_events(path=None)[source]#
The fix-at-source hook’s events (
$FIX_AT_SOURCE_LOG, else its default path).
- opsward.weekly.render(result)[source]#
The weekly look as a markdown page: the numbers, the change since last time, one proposal.
- Return type:
- opsward.weekly.search_before_write(sessions, *, suffixes=('.py', '.ts', '.tsx', '.js', '.jsx', '.mjs', '.cjs', '.rs', '.swift', '.go', '.kt', '.java', '.rb', '.sh', '.c', '.cc', '.cpp', '.h'))[source]#
Number 1: new source files written after a fleet search, over all new source files.
local_first(after at least a Grep, a Glob or anrg) is context.>>> def use(name, **args): ... return {"type": "assistant", "message": {"content": [{"type": "tool_use", "name": name, "input": args}]}} >>> s = [use("Write", file_path="/a.py"), use("Grep", pattern="x"), use("Write", file_path="/b.py"), ... use("Bash", command="projreg find x"), use("Write", file_path="/c.py"), use("Write", file_path="/c.py")] >>> search_before_write([("s", s)]) {'new_source_files': 3, 'searched_first': 1, 'ratio': 0.333, 'local_first': 2}
- Return type:
- opsward.weekly.skill_use(sessions, *, installed)[source]#
Number 2: invocations per skill, and the installed skills no session invoked.
- Return type:
- opsward.weekly.tool_uses(records)[source]#
(cwd, tool name, input)for every tool call in a transcript, in order.>>> rec = {"type": "assistant", "cwd": "/w", "message": {"content": [ ... {"type": "tool_use", "name": "Grep", "input": {"pattern": "x"}}]}} >>> list(tool_uses([rec])) [('/w', 'Grep', {'pattern': 'x'})]
- opsward.weekly.transcripts(home=None, *, days=30)[source]#
Top-level Claude Code transcripts under
home(default~/.claude) modified withindays, as(session_id, records); a session found twice is read once.
- opsward.weekly.weekly(*, days=30, home=None, sessions=None, skills_dirs=None, search=<function gh_component_issues>, events=None, history=None, save=True, now=None)[source]#
The five numbers over the last
days, last time’s values, and one proposed change.Saves this run’s numbers to
history($OPSWARD_WEEKLY_DIR, else~/.local/share/opsward/weekly) asYYYY-MM-DD.jsonunlesssave=False.- Return type: