pi-workfeed 0.0.0-stage → 0.1.0
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/CHANGELOG.md +54 -0
- package/LICENSE +21 -0
- package/README.md +437 -2
- package/docs/README.md +12 -0
- package/docs/schema.md +454 -0
- package/docs/verification.md +141 -0
- package/docs/versioning.md +91 -0
- package/extensions/journal/digest.ts +318 -0
- package/extensions/journal/index.ts +664 -0
- package/extensions/journal/replay.ts +359 -0
- package/extensions/todo/index.ts +324 -0
- package/package.json +54 -4
- package/schemas/workfeed-event-v1.schema.json +176 -0
- package/skills/workfeed-analysis/SKILL.md +142 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## [0.1.0] - 2026-11-10
|
|
4
|
+
|
|
5
|
+
**First public release.**
|
|
6
|
+
|
|
7
|
+
Numbering note: this package was built in the open, and iteration was tagged as it happened —
|
|
8
|
+
`0.1.0` through `0.4.6` are development milestones, none of them published. The published
|
|
9
|
+
line starts here, so a reader of the package metadata sees a first release rather than the
|
|
10
|
+
tail of an internal counter. That iteration log lives in `HISTORY.md` in the repository and
|
|
11
|
+
is deliberately not shipped, because a 30 kB pre-release diary beside a first version tells
|
|
12
|
+
a stranger more about how the sausage was made than about the sausage. The development milestones are
|
|
13
|
+
tagged `dev/<version>` (`dev/0.3.1` … `dev/0.4.6`) for the same reason: a `v0.4.6` tag sitting
|
|
14
|
+
next to an npm `0.1.0` reads as "the latest version is 0.4.6" on GitHub, and a tag list that
|
|
15
|
+
contradicts the installable package is worse than no tag list.
|
|
16
|
+
|
|
17
|
+
What ships in this release:
|
|
18
|
+
|
|
19
|
+
- **Todo tracking with per-item timing** — `workfeed_todo` (`write` / `list` / `clear`),
|
|
20
|
+
ids that are never reused, and a cleared item that keeps the time it already spent
|
|
21
|
+
(`dropped`, with its elapsed time, instead of disappearing). The tool's own prompt
|
|
22
|
+
guidelines now ask for the list to be written in a turn of its own, before the tools it
|
|
23
|
+
tracks: attribution is captured only while an item is `in_progress`, so a list bundled with
|
|
24
|
+
a `bash` call leaves that call without an item and shows up as a lower attribution rate.
|
|
25
|
+
- **One append-only event log per session** (`workfeed-<sid>.jsonl`) whose lines share the
|
|
26
|
+
four join keys the docs promise: `v`, `ts`, `sid`, `task`, plus `item` when work is
|
|
27
|
+
attributed. Task numbering continues when the same session file is reopened.
|
|
28
|
+
- **A digest derived from the log, never authoritative** — tasks, tool rollup, slowest
|
|
29
|
+
calls, last failures, per-item todo timing, and a `## data quality` block that states
|
|
30
|
+
coverage (attribution ratio, prompts without a settle, dropped log lines, compaction
|
|
31
|
+
outcomes) so a reader can tell a hedged conclusion from a solid one.
|
|
32
|
+
- **Wire format `schemaVersion = 1`, frozen for this release** — no new fields, no new event
|
|
33
|
+
types; a snapshot test fails on any addition. `docs/schema.md` is the normative protocol,
|
|
34
|
+
`schemas/workfeed-event-v1.schema.json` its machine-readable companion.
|
|
35
|
+
- **Verified on real hosts, not only against stubs** — Windows (pi 1.5.0) end to end
|
|
36
|
+
including restart, `clear`, compaction and a killed session; Linux (Ubuntu 24.04,
|
|
37
|
+
pi 1.5.1) by a second-environment rerun of the same flow. macOS is declared unverified
|
|
38
|
+
(no hardware) with a request to report problems. Details in
|
|
39
|
+
[`docs/verification.md`](docs/verification.md).
|
|
40
|
+
- **No CLI, by decision.** The replay/aggregate/digest layer is a library so the data has
|
|
41
|
+
one consumer surface, the agent's own session. The README lists only the surfaces that
|
|
42
|
+
exist — pi slash commands and the `rebuildDigest(path)` library call — because a reader
|
|
43
|
+
who has never seen a `workfeed-digest` CLI does not need a section defending its absence;
|
|
44
|
+
the argument stays here, where a decision belongs.
|
|
45
|
+
- **Durations keep their resolution.** The digest used to floor every duration to whole
|
|
46
|
+
seconds, which printed a column of `0s` for fast tool calls — in a digest whose stated job
|
|
47
|
+
is answering "which call was slow". One decimal below ten seconds, milliseconds below one.
|
|
48
|
+
- **Recording announces itself once.** The first log file a session creates triggers a single
|
|
49
|
+
`ui.notify` naming the path and the off switch (`PI_WORKFEED_CONTENT=0`), instead of the
|
|
50
|
+
privacy policy living only in a README nobody re-reads after install. The README also states
|
|
51
|
+
that logs are never rotated, and how to reclaim the space.
|
|
52
|
+
- **The bundled skill resolves its own paths.** `SKILL.md` referred to `docs/schema.md` and
|
|
53
|
+
`extensions/journal/replay.ts` as if the reader stood at the package root; an agent holding
|
|
54
|
+
the skill file stands in the skill directory. Both are now relative to it (`../../docs/…`).
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Wren-Xin
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,438 @@
|
|
|
1
|
-
#
|
|
1
|
+
# pi-workfeed
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://github.com/Wren-Xin/pi-workfeed/actions/workflows/test.yml)
|
|
4
|
+
[](https://www.npmjs.com/package/pi-workfeed)
|
|
5
|
+
[](https://github.com/Wren-Xin/pi-workfeed/blob/main/LICENSE)
|
|
6
|
+
|
|
7
|
+
**Agent Workflow Evidence** — workflow telemetry for the [pi](https://pi.dev) coding agent.
|
|
8
|
+
|
|
9
|
+
> Record the Work. Preserve the Evidence.
|
|
10
|
+
|
|
11
|
+
Not another todo list and not another tracer. `pi-workfeed` is a **data entry point**:
|
|
12
|
+
it records what the agent did, in a form a model can read and reason about, so that
|
|
13
|
+
answers like "where did this task's time go" or "why was this run slow" are derived
|
|
14
|
+
from evidence instead of impressions.
|
|
15
|
+
|
|
16
|
+
Three smallest necessary pieces:
|
|
17
|
+
|
|
18
|
+
1. **`workfeed_todo` tool with per-item timing** — the task structure the agent already
|
|
19
|
+
maintains, now with timing attached. The tool is deliberately named `workfeed_todo` so it
|
|
20
|
+
can coexist with other todo extensions instead of failing to load on a name conflict.
|
|
21
|
+
2. **event journal** — tasks, turns, tool calls, tokens, todo changes as one JSONL stream.
|
|
22
|
+
3. **digest** — a small derived summary so the model reads 200 lines, not 20 000.
|
|
23
|
+
|
|
24
|
+
Read it two ways. As the person installing it, top to bottom: Install → Privacy → the digest
|
|
25
|
+
sample. As the model at run time, the digest plus `skills/workfeed-analysis/SKILL.md`, which is
|
|
26
|
+
the contract for interpreting it — the file below is for you, not for the parser.
|
|
27
|
+
|
|
28
|
+
**Contents:** [How it fits together](#how-it-fits-together) · [Install](#install) ·
|
|
29
|
+
[Privacy](#privacy) · [What you get](#what-you-get) ·
|
|
30
|
+
[What the digest looks like](#what-the-digest-looks-like) ·
|
|
31
|
+
[Ask the agent](#ask-the-agent-not-a-dashboard) · [Design philosophy](#design-philosophy) ·
|
|
32
|
+
[Verification](#verification) · [中文速用](#中文速用)
|
|
33
|
+
|
|
34
|
+
## How it fits together
|
|
35
|
+
|
|
36
|
+
```text
|
|
37
|
+
pi session ── tasks · turns · tool calls · tokens
|
|
38
|
+
│
|
|
39
|
+
├─ todo extension ─────────► per-item timing (in_progress elapsed, ids never reused)
|
|
40
|
+
│
|
|
41
|
+
└─ journal extension ──────► JSONL journal (truth: append-only, one event per line)
|
|
42
|
+
workfeed-<sid>.jsonl
|
|
43
|
+
every line shares v · sid · task · item
|
|
44
|
+
│
|
|
45
|
+
▼ replay.ts: parse → aggregate
|
|
46
|
+
digest (derived: rebuilt, never authoritative)
|
|
47
|
+
workfeed-<sid>.digest.md
|
|
48
|
+
│
|
|
49
|
+
▼ read by the model, with the bundled skill
|
|
50
|
+
"where did this task's time go, and which call was slow"
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
The arrows only go one way: the extensions write the log, the digest is computed from the
|
|
54
|
+
log, and nothing feeds the digest back into the log. That is why `rebuildDigest(path)` can
|
|
55
|
+
rebuild it for a session this process never saw.
|
|
56
|
+
|
|
57
|
+
Here is what the stream actually looks like — the same call at `start` and at `end`, taken
|
|
58
|
+
verbatim from a real session (only the session id is shortened, nothing else edited):
|
|
59
|
+
|
|
60
|
+
```json
|
|
61
|
+
{"v":1,"ts":1794306999849,"sid":"<sid>","task":1,"item":1,"t":"tool","phase":"start","id":"call_00_ET_8lw2J5KaRKaxvp6nfIEi3067","name":"edit","args":{"path":"note.txt"}}
|
|
62
|
+
{"v":1,"ts":1794306999854,"sid":"<sid>","task":1,"item":1,"t":"tool","phase":"end","id":"call_00_ET_8lw2J5KaRKaxvp6nfIEi3067","name":"edit","durMs":4,"wallMs":5,"isError":false,"outBytes":45,"out":"Successfully replaced 1 block(s) in note.txt."}
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
- `t` is the event type, `ts` is epoch milliseconds, and `id` is what joins the two lines.
|
|
66
|
+
- `task` and `item` are identical on both because **attribution is frozen when the call
|
|
67
|
+
starts** — if the todo list moves mid-call, the start and the end still belong together.
|
|
68
|
+
- `durMs` is monotonic execution time; `wallMs` includes scheduling, so it is an upper bound.
|
|
69
|
+
- This producer writes `args` only on `start` and `out` only on `end`; the schema allows
|
|
70
|
+
either as optional, and a digest must not assume otherwise.
|
|
71
|
+
|
|
72
|
+
The field tables, per-`phase` required keys, envelope rules and the consumer checklist live in
|
|
73
|
+
the package's docs bundle; [`docs/README.md`](https://github.com/Wren-Xin/pi-workfeed/blob/main/docs/README.md) is the index and the protocol is
|
|
74
|
+
its first entry. The machine-checkable twin is
|
|
75
|
+
[`schemas/workfeed-event-v1.schema.json`](https://github.com/Wren-Xin/pi-workfeed/blob/main/schemas/workfeed-event-v1.schema.json), and
|
|
76
|
+
`test/schema-docs.test.mjs` parses the two lines above and fails if they use a field the schema
|
|
77
|
+
does not declare.
|
|
78
|
+
|
|
79
|
+
## Install
|
|
80
|
+
|
|
81
|
+
> **Before you install: this records what you and the agent typed.** Prompt text and tool
|
|
82
|
+
> output go to a JSONL log under `~/.pi/agent/logs/<date>/`. Redaction is best effort
|
|
83
|
+
> (truncation, argument masking, path basenames) — not a guarantee. `PI_WORKFEED_CONTENT=0`
|
|
84
|
+
> turns content recording off and keeps timing. Read [Privacy](#privacy) before turning it on
|
|
85
|
+
> in a repository you would not want logged.
|
|
86
|
+
|
|
87
|
+
Requirements:
|
|
88
|
+
|
|
89
|
+
| Requirement | What this release was actually checked against |
|
|
90
|
+
|---|---|
|
|
91
|
+
| Node.js | **22.19.0 or newer** — pi's own floor (`@earendil-works/pi-coding-agent` declares the same in its `engines`), not a stricter one this package invented. Below it you are outside the version support is *stated* against, which is not the same as "will not run": the suites have also come back green on Node 22.12.0, and the first thing that would break on an older 22.x is the `--experimental-strip-types` flag itself |
|
|
92
|
+
| pi coding agent | **1.5.0 and 1.5.1** — the two versions this release was exercised on end to end, not a compatibility range. Other versions are untested; a mismatch in event field names is exactly the kind of break this package survives by reporting rather than guessing |
|
|
93
|
+
| OS | **Windows 11 and Ubuntu 24.04 only**; macOS is untested (no Apple hardware here) |
|
|
94
|
+
|
|
95
|
+
The extensions import four packages they do not ship: `@earendil-works/pi-ai`,
|
|
96
|
+
`@earendil-works/pi-coding-agent`, `@earendil-works/pi-tui` and `typebox`. All four are
|
|
97
|
+
supplied by the running pi host, so they are declared as `peerDependencies` with `*` —
|
|
98
|
+
a version range there would promise compatibility this package cannot verify, and the copy
|
|
99
|
+
that actually loads is pi's, not npm's.
|
|
100
|
+
|
|
101
|
+
Which Node, which pi and which OS each of those numbers came from is stated in exactly one
|
|
102
|
+
place: [Verification](#verification).
|
|
103
|
+
|
|
104
|
+
Install through `pi install`; a bare `npm i pi-workfeed` makes npm resolve those peers on its
|
|
105
|
+
own, which is not how this package is meant to be loaded.
|
|
106
|
+
|
|
107
|
+
### 1. Install the package
|
|
108
|
+
|
|
109
|
+
```bash
|
|
110
|
+
pi install npm:pi-workfeed # personal: written to ~/.pi/agent/settings.json
|
|
111
|
+
pi install ./pi-workfeed # from a checkout
|
|
112
|
+
pi install ./pi-workfeed -l # project-local: .pi/settings.json, loads after project trust
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
`pi list` prints the declaration back if you want to confirm it landed.
|
|
116
|
+
|
|
117
|
+
### 2. Enable it
|
|
118
|
+
|
|
119
|
+
```
|
|
120
|
+
/reload
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
A new session picks the package up at startup; an already-open session needs `/reload`.
|
|
124
|
+
Two extensions (`todo`, `journal`) and one skill (`workfeed-analysis`) load together.
|
|
125
|
+
|
|
126
|
+
### 3. Verify that all three arrived
|
|
127
|
+
|
|
128
|
+
| Check | What it proves |
|
|
129
|
+
|---|---|
|
|
130
|
+
| `pi config` (Tab switches personal / project scope) | the package is listed and its resources — two extensions and the skill — are there and enabled |
|
|
131
|
+
| `/wf-todos` in a session | the todo extension loaded: it prints the current list (empty at first) |
|
|
132
|
+
| `/workfeed` | the journal loaded and is already writing: it prints the session id and both file paths |
|
|
133
|
+
| the first prompt after `/reload` | one line appears naming the log file — that is the journal announcing itself once, not a second install |
|
|
134
|
+
|
|
135
|
+
If `/wf-todos` and `/workfeed` work but the skill never appears in `pi config`, the skill
|
|
136
|
+
directory was filtered out: check that `pi.skills` in the installed `package.json` still
|
|
137
|
+
points at `./skills`.
|
|
138
|
+
|
|
139
|
+
**What gets created.** One entry in the pi settings file at install time, nothing else. After
|
|
140
|
+
the first session there are two files under `~/.pi/agent/logs/<date>/` — what each one is for
|
|
141
|
+
is in [What you get](#what-you-get). The digest appears only once the first task settles, and
|
|
142
|
+
is refreshed at session start, at session end and on `/workfeed-digest`; nothing is written
|
|
143
|
+
outside that directory.
|
|
144
|
+
|
|
145
|
+
**To uninstall.** `pi remove pi-workfeed` (or delete the entry from
|
|
146
|
+
`~/.pi/agent/settings.json`). That removes the code and stops all recording; the logs stay
|
|
147
|
+
until you delete `~/.pi/agent/logs/` — they are yours, not the package's.
|
|
148
|
+
|
|
149
|
+
**To stop recording content** before the first prompt: `PI_WORKFEED_CONTENT=0` — timing,
|
|
150
|
+
tool names and todo structure still recorded, prompt text and tool output never written.
|
|
151
|
+
The per-channel detail is in [Privacy](#privacy).
|
|
152
|
+
|
|
153
|
+
## Privacy
|
|
154
|
+
|
|
155
|
+
The first session after install prints one line — where the log is, that prompt text and
|
|
156
|
+
tool output are recorded, and the switch that stops it — so the policy is visible at the
|
|
157
|
+
moment it starts applying, not only here.
|
|
158
|
+
|
|
159
|
+
What each channel records is a fixed policy, not an accident — a log is expected to be
|
|
160
|
+
shared, attached to a bug report, or read by a colleague:
|
|
161
|
+
|
|
162
|
+
| Data | Default | `PI_WORKFEED_CONTENT=0` |
|
|
163
|
+
|---|---|---|
|
|
164
|
+
| tool name, duration, exit code, error flag | kept | kept |
|
|
165
|
+
| token counts, turn and task counters | kept | kept |
|
|
166
|
+
| todo id / status / elapsed | kept | kept |
|
|
167
|
+
| command text | kept, clipped, credential patterns redacted | **never** |
|
|
168
|
+
| prompt text | kept ≤3000 chars, redacted | **never** |
|
|
169
|
+
| tool output | kept ≤`PI_WORKFEED_EXCERPT` bytes (head + tail), redacted | **never** |
|
|
170
|
+
| file content (`write` / `edit` bodies) | never — byte counts only | never |
|
|
171
|
+
| paths (cwd, session file, read/write targets) | full | last segment only, `<…>/name` |
|
|
172
|
+
| other tool arguments | per-tool summary (`redacted`) | key names + byte counts (`shape`) |
|
|
173
|
+
| todo text | kept ≤120 chars | omitted, length only |
|
|
174
|
+
|
|
175
|
+
`PI_WORKFEED_ARGS` overrides the argument channel alone: `full` (debugging), `redacted`,
|
|
176
|
+
`shape`, `off`. Argument values are scrubbed in **every** mode, including `full` and the
|
|
177
|
+
fallback branch used for tools this package does not know (MCP servers, other extensions).
|
|
178
|
+
|
|
179
|
+
**Redaction is best effort, not a guarantee.** It matches common shapes: `--token …`,
|
|
180
|
+
`Authorization: …`, `API_KEY=…`, `sk-…`, `AKIA…`, JWTs, inline PEM keys, `curl -u u:p`,
|
|
181
|
+
`DATABASE_URL=…`, and `scheme://user:password@host` DSNs. A secret that reads like an
|
|
182
|
+
ordinary word will survive — no pattern list can fix that. The log is written `0600` in a
|
|
183
|
+
`0700` directory (best effort on Windows, which has no POSIX modes) because even a
|
|
184
|
+
metadata-only log reveals which tools ran, on which files, and for how long. Treat the
|
|
185
|
+
directory as sensitive either way.
|
|
186
|
+
|
|
187
|
+
## What you get
|
|
188
|
+
|
|
189
|
+
```text
|
|
190
|
+
~/.pi/agent/logs/<YYYY-MM-DD>/
|
|
191
|
+
├── workfeed-<sid>.jsonl # truth: one event per line, append-only
|
|
192
|
+
└── workfeed-<sid>.digest.md # derived: rebuilt from the .jsonl above, not from memory
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
Status line shows `⏱ elapsed · tool · #item · tN · calls`.
|
|
196
|
+
|
|
197
|
+
Two surfaces, both real:
|
|
198
|
+
|
|
199
|
+
| Surface | What it is | How you reach it |
|
|
200
|
+
|---|---|---|
|
|
201
|
+
| `/wf-todos`, `/workfeed`, `/workfeed-digest` | **pi slash commands**, handled in-process by the extension | type them inside a pi session — they are not shell commands |
|
|
202
|
+
| `rebuildDigest(path)` | **library API** (`extensions/journal/replay.ts`), returns `{ text, integrity }` | import it from your own script; `hasDamage(integrity)` gives the same verdict |
|
|
203
|
+
|
|
204
|
+
Why the names differ: `wf-` is the short form for the command you type *while working*, and
|
|
205
|
+
`wf-todos` names the noun it touches because another todo extension may be loaded beside this
|
|
206
|
+
one; `workfeed` stays whole on the two commands that report on the record itself.
|
|
207
|
+
|
|
208
|
+
`/workfeed-digest` rebuilds the digest *inside a session* (after a restart, or when a digest
|
|
209
|
+
looks stale); rebuilding offline is the library call, not a command. There is no shell command
|
|
210
|
+
and no `npx` entry — the reasoning is in the CHANGELOG.
|
|
211
|
+
|
|
212
|
+
## What the digest looks like
|
|
213
|
+
|
|
214
|
+
One real session — three prompts, seven tool calls, one failed bash, one todo list that was
|
|
215
|
+
partly cleared — rebuilt offline from the JSONL. Session id and paths shortened, nothing else
|
|
216
|
+
edited:
|
|
217
|
+
|
|
218
|
+
```text
|
|
219
|
+
# workfeed digest
|
|
220
|
+
|
|
221
|
+
> derived from workfeed-<sid>.jsonl at 2026-11-10T10:36:44.368Z — regenerate, do not hand-edit.
|
|
222
|
+
|
|
223
|
+
- session: <sid>
|
|
224
|
+
- date: 2026-11-10
|
|
225
|
+
- model: deepseek-flash (deepseek)
|
|
226
|
+
- cwd: <…>/proj
|
|
227
|
+
- events: 43
|
|
228
|
+
|
|
229
|
+
## data quality
|
|
230
|
+
|
|
231
|
+
- tool calls: 7 finished
|
|
232
|
+
- item attribution: 4/7 calls carry an item (57%)
|
|
233
|
+
- token totals: 3/3 tasks report a non-zero total
|
|
234
|
+
- task coverage: 3/3 prompts have a settle
|
|
235
|
+
- compaction: 0 completed, 0 failed, 1 skipped — skipped: Compaction failed: Nothing to compact (session too small)
|
|
236
|
+
|
|
237
|
+
## tasks (3, wall clock 6.9s)
|
|
238
|
+
|
|
239
|
+
| # | time | turns | tools | tokens | status |
|
|
240
|
+
|---|---|---|---|---|---|
|
|
241
|
+
| 1 | 3.1s | 3 | 4 | 9.8k in / 286 out / 10.1k total | ok |
|
|
242
|
+
| 2 | 2.5s | 2 | 2 | 7.3k in / 249 out / 7.5k total | ok |
|
|
243
|
+
| 3 | 1.3s | 2 | 1 | 7.8k in / 44 out / 7.8k total | ok |
|
|
244
|
+
|
|
245
|
+
## tools (7 calls, 1 failed)
|
|
246
|
+
|
|
247
|
+
| tool | calls | total | avg | max | failed |
|
|
248
|
+
|---|---|---|---|---|---|
|
|
249
|
+
| bash | 2 | 192ms | 96ms | 108ms | 1 |
|
|
250
|
+
| read | 1 | 40ms | 40ms | 40ms | 0 |
|
|
251
|
+
| workfeed_todo | 3 | 6ms | 2ms | 4ms | 0 |
|
|
252
|
+
| edit | 1 | 4ms | 4ms | 4ms | 0 |
|
|
253
|
+
|
|
254
|
+
slowest calls
|
|
255
|
+
|
|
256
|
+
- 108ms · bash · task 2 · item 1 · FAILED
|
|
257
|
+
- 84ms · bash · task 1
|
|
258
|
+
- 40ms · read · task 1
|
|
259
|
+
- 4ms · workfeed_todo · task 1
|
|
260
|
+
- 4ms · edit · task 1 · item 1
|
|
261
|
+
|
|
262
|
+
last failures
|
|
263
|
+
|
|
264
|
+
- bash · task 2 · 10:36:41
|
|
265
|
+
|
|
266
|
+
## todo items (3)
|
|
267
|
+
|
|
268
|
+
1/3 completed · accumulated in-progress time 2.5s · 3 dropped from the list (timing kept)
|
|
269
|
+
|
|
270
|
+
| id | status | elapsed | share | text |
|
|
271
|
+
|---|---|---|---|---|
|
|
272
|
+
| 1 | completed · dropped | 2.5s | 100% | probe todo timing |
|
|
273
|
+
| 2 | in_progress · dropped | 0s | 0% | run a command |
|
|
274
|
+
| 3 | pending · dropped | 0s | 0% | edit a file |
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
What each block is for, in the order to read them:
|
|
278
|
+
|
|
279
|
+
- **`## data quality` first, on purpose.** `4/7 calls carry an item (57%)` says the item column
|
|
280
|
+
is a lower bound; `1 skipped` is pi answering "nothing to compact" on a small session, not a
|
|
281
|
+
failure — calling that an error would make a healthy install look broken.
|
|
282
|
+
- **`## tasks`** — one row per prompt; `ok` means a `settle` arrived, and a killed prompt shows
|
|
283
|
+
up as started-without-settle instead of vanishing.
|
|
284
|
+
- **`## tools`** — keeps a slow tool and a broken tool apart (separate `failed` count) and keeps
|
|
285
|
+
sub-second detail (`108ms`, `1.4s`): a floored column of `0s` cannot answer "which call was
|
|
286
|
+
slow", which is the question this digest exists for.
|
|
287
|
+
- **`slowest calls` / `last failures`** — ranked evidence with `task` and `item` attached. Only
|
|
288
|
+
two of these five carry an `item`; the ratio above is what tells you that.
|
|
289
|
+
- **`## todo items`** — `dropped (timing kept)`: an item that left the list keeps the time it
|
|
290
|
+
already spent, so 2.5s does not collapse into "0 items".
|
|
291
|
+
- **Ranked lists are capped, and a missing row means "outside the cap", not "did not happen".**
|
|
292
|
+
`## tools` keeps the eight tool names with the highest total, `slowest calls` is the top five
|
|
293
|
+
by `durMs`, `last failures` is the last five failing calls. The counters still cover every
|
|
294
|
+
call — the caps are on rendering, not on counting.
|
|
295
|
+
|
|
296
|
+
## Ask the agent, not a dashboard
|
|
297
|
+
|
|
298
|
+
There is deliberately no report generator, no HTML page, no metrics daemon. The entry
|
|
299
|
+
point is the files; the consumer is the model. Typical prompts that work out of the box:
|
|
300
|
+
|
|
301
|
+
- "read today's workfeed digest and tell me where this session's time went"
|
|
302
|
+
- "which tool calls were slow, and were they slow because of the tool or the model?"
|
|
303
|
+
- "which todo item ate the most time, and did it actually finish?"
|
|
304
|
+
- "look at the last failures and tell me whether they are one root cause"
|
|
305
|
+
|
|
306
|
+
The bundled skill gives the agent the measurement definitions and the drill-down
|
|
307
|
+
procedure, so it does not guess what `durationMs` means or confuse wall clock with
|
|
308
|
+
monotonic tool time.
|
|
309
|
+
|
|
310
|
+
## Design philosophy
|
|
311
|
+
|
|
312
|
+
A session is a workflow — tasks, work items, turns, tool calls, outcomes — not a transcript, and
|
|
313
|
+
recording it as correlated events is what makes "where did the time go" answerable. Raw events
|
|
314
|
+
are the truth and the digest is derived: rebuilt from the log by `replay.ts`
|
|
315
|
+
(`parse → aggregate → digest`), never accumulated in memory, so 2 000 calls still count 2 000.
|
|
316
|
+
Models are the consumer, not dashboards; every number has a definition, and where the log
|
|
317
|
+
cannot answer, the answer is "not recorded".
|
|
318
|
+
|
|
319
|
+
Every line carries the four join keys (`v` / `sid` / `task` / `item`), which is what makes the
|
|
320
|
+
stream joinable. The protocol — per-type field tables, the digest contract, the invariants —
|
|
321
|
+
lives in the docs bundle ([`docs/README.md`](https://github.com/Wren-Xin/pi-workfeed/blob/main/docs/README.md) is the index), with a
|
|
322
|
+
machine-readable twin at
|
|
323
|
+
[`schemas/workfeed-event-v1.schema.json`](https://github.com/Wren-Xin/pi-workfeed/blob/main/schemas/workfeed-event-v1.schema.json).
|
|
324
|
+
|
|
325
|
+
## How this relates to other tooling
|
|
326
|
+
|
|
327
|
+
- **SQLite tool-call audit extensions** are forensic logs for humans: what ran, in what
|
|
328
|
+
order, after the fact. Workfeed records the layer above the command — which task and which
|
|
329
|
+
work item the call belonged to — so "where did this task's time go" is already in the data
|
|
330
|
+
rather than reconstructed by hand.
|
|
331
|
+
- **OpenTelemetry's GenAI semantic conventions** describe model and tool activity as spans
|
|
332
|
+
for exporters and backends. This is not an OTLP exporter and does not replace tracing: it
|
|
333
|
+
writes a local JSONL plus a digest the agent reads in-session. Fleet-level latency and cost
|
|
334
|
+
live there; "what happened during this task, and why was it slow" lives here.
|
|
335
|
+
|
|
336
|
+
## Environment variables
|
|
337
|
+
|
|
338
|
+
| Variable | Default | Effect |
|
|
339
|
+
|---|---|---|
|
|
340
|
+
| `PI_WORKFEED_DIR` | `~/.pi/agent/logs` | log root |
|
|
341
|
+
| `PI_WORKFEED_EXCERPT` | `2048` | bytes of tool output kept per call, `0` keeps none |
|
|
342
|
+
| `PI_WORKFEED_CONTENT` | `1` | `0` = metadata only: no prompt text, no tool output, no command text, no todo text, paths reduced to basenames |
|
|
343
|
+
| `PI_WORKFEED_ARGS` | `redacted` (`shape` when `PI_WORKFEED_CONTENT=0`) | tool arguments: `full` \| `redacted` \| `shape` \| `off` |
|
|
344
|
+
| `PI_WORKFEED_OFF` | — | `1` disables the journal |
|
|
345
|
+
| `PI_WORKFEED_TODO_OFF` | — | `1` disables the todo extension |
|
|
346
|
+
|
|
347
|
+
## Honest notes
|
|
348
|
+
|
|
349
|
+
- **Cost is not recorded.** Self-hosted OpenAI-compatible endpoints report `cost: 0`;
|
|
350
|
+
writing that number into a log teaches wrong lessons. Tokens are recorded, price them
|
|
351
|
+
yourself.
|
|
352
|
+
- **Todo state is stored twice on purpose**: in tool result `details` (correct after
|
|
353
|
+
`/fork` and `/tree`) and in a `pi.appendEntry` custom entry (survives compaction, which
|
|
354
|
+
drops old messages). Losing the list on `/compact` is the bug this design avoids.
|
|
355
|
+
- **Item timing cannot separate agent time from human time.** It measures how long an item
|
|
356
|
+
stayed `in_progress`.
|
|
357
|
+
- **Attribution is frozen at tool start, not at settle.** A slow call keeps the `task` and
|
|
358
|
+
`item` that launched it; if the todo list moves mid-call the `todo` line moves, the call
|
|
359
|
+
does not. Read each line's own `item` instead of pairing lines by timestamp.
|
|
360
|
+
- **File names are prefixed `workfeed-`** so this logger never collides with another
|
|
361
|
+
extension that writes `session-*.jsonl` into the same directory. Two loggers in one
|
|
362
|
+
folder would interleave foreign lines into each other's files.
|
|
363
|
+
- **Path handling is portable** (`os.homedir()` + `path.join`, no separators assumed); which
|
|
364
|
+
platforms that was actually checked on is in [Verification](#verification).
|
|
365
|
+
- **Logs are never rotated or deleted** by this package, and their size is predictable: a
|
|
366
|
+
three-prompt, seven-call session wrote **11.7 KB** of JSONL and a **1.7 KB** digest (43
|
|
367
|
+
events, ≈270 bytes per event), so a 2 000-call day is roughly half a megabyte. Every session
|
|
368
|
+
appends to `~/.pi/agent/logs/<date>/`, so delete the date folders you no longer need; a
|
|
369
|
+
digest is derived, so removing it costs nothing, and removing a day removes that day's
|
|
370
|
+
evidence. Each session prints its log path on startup, so a cleanup never has to guess.
|
|
371
|
+
|
|
372
|
+
## Verification
|
|
373
|
+
|
|
374
|
+
Reproduce the suite yourself from a git checkout — the suite is **not** shipped in the
|
|
375
|
+
tarball, so this cannot be run from an npm install; no build step or dev install beyond Node:
|
|
376
|
+
|
|
377
|
+
```bash
|
|
378
|
+
node --experimental-strip-types test/run.mjs # exactly what `npm test` calls
|
|
379
|
+
```
|
|
380
|
+
|
|
381
|
+
The run ends with `ALL SUITES PASS`. `--experimental-strip-types` needs Node 22.6+ (the
|
|
382
|
+
suites import the TypeScript sources directly); Node 22.19+ is the version this release
|
|
383
|
+
states support against.
|
|
384
|
+
|
|
385
|
+
Test suites run against stubs, and a stub can only prove the code matches *our description*
|
|
386
|
+
of pi's interface. A real session was therefore run end to end — real extension loading,
|
|
387
|
+
real `bash`/`read`/`edit`, real compaction, real fork, real restart — and it found two
|
|
388
|
+
field names the stubs had got wrong. The record — what the run covered, what the stubs could
|
|
389
|
+
not prove, and the platform matrix — is the third entry in the
|
|
390
|
+
[`docs/` index](https://github.com/Wren-Xin/pi-workfeed/blob/main/docs/README.md).
|
|
391
|
+
|
|
392
|
+
The matrix in full — this is the only place the exact versions are written down:
|
|
393
|
+
|
|
394
|
+
- Windows 11 (pi 1.5.0, Node 22.23.2): verified.
|
|
395
|
+
- Ubuntu 24.04 (pi 1.5.1, Node 24.22.1): verified by a second-environment rerun of the
|
|
396
|
+
same flow (the maintainer's own run on another machine, not a third party)
|
|
397
|
+
— all suites pass, the nine-step scenario completed with a real compaction, 11
|
|
398
|
+
JSONL↔digest cross-checks matched, and `0600`/`0700` file modes held.
|
|
399
|
+
- macOS: **not verified** — this project is limited by resources and has no Apple hardware
|
|
400
|
+
available, so it was never exercised on macOS. If you run it there and hit a problem,
|
|
401
|
+
[file an issue](https://github.com/Wren-Xin/pi-workfeed/issues/new/choose); the form asks
|
|
402
|
+
for pi version, Node version and the `## data quality` block, which is exactly what a
|
|
403
|
+
report needs to be diagnosable.
|
|
404
|
+
|
|
405
|
+
## Versioning
|
|
406
|
+
|
|
407
|
+
Wire, package and source versions are independent on purpose, and only the wire one is a
|
|
408
|
+
contract: it is **frozen at `v: 1` for this release** — no new fields, no new event types,
|
|
409
|
+
enforced by a snapshot test instead of a note in a document. Bump criteria, the release
|
|
410
|
+
checklist and the rules that keep the three numbers apart are one click in:
|
|
411
|
+
[`docs/README.md`](https://github.com/Wren-Xin/pi-workfeed/blob/main/docs/README.md) (second entry).
|
|
412
|
+
|
|
413
|
+
## Roadmap
|
|
414
|
+
|
|
415
|
+
- v0.1.0 (this)
|
|
416
|
+
|
|
417
|
+
Next, in no promised order:
|
|
418
|
+
|
|
419
|
+
- per-task token attribution to work items
|
|
420
|
+
- cross-session query examples in the bundled skill
|
|
421
|
+
|
|
422
|
+
Release history — the pre-release iteration from `0.1.0-dev` to `0.4.6` — is in
|
|
423
|
+
[`HISTORY.md`](https://github.com/Wren-Xin/pi-workfeed/blob/main/HISTORY.md), kept in the
|
|
424
|
+
repository and deliberately not shipped in the package (so the link points at GitHub, not at
|
|
425
|
+
a path inside the tarball).
|
|
426
|
+
|
|
427
|
+
## 中文速用
|
|
428
|
+
|
|
429
|
+
- 安装:`pi install npm:pi-workfeed`,然后 `/reload`。
|
|
430
|
+
- 产出:`~/.pi/agent/logs/<日期>/workfeed-<会话>.jsonl`(真值)与 `workfeed-<会话>.digest.md`(派生,可删)。
|
|
431
|
+
- 用法:不要自己翻日志,直接让 agent 读 digest 给结论;摘要里已带慢命令、失败与各 todo 项耗时。
|
|
432
|
+
- 隐私:`PI_WORKFEED_CONTENT=0` 只记元数据——不落提示词、工具输出、命令正文与 todo 文本,路径只留末段;
|
|
433
|
+
参数通道单独由 `PI_WORKFEED_ARGS`(`full`/`redacted`/`shape`/`off`)控制;任何模式下参数值都会过一遍脱敏(含 `full` 与未知工具的兜底分支)。
|
|
434
|
+
- 脱敏是**尽力而为**:能认出 `--token …`、`Authorization:`、`API_KEY=`、`sk-`、`AKIA`、JWT、PEM 私钥、`curl -u`、`DATABASE_URL=`、`scheme://user:pw@host` 这类形状,认不出「长得像普通单词」的密钥。日志文件按 `0600` 写在 `0700` 目录里(Windows 只能尽力),但无论哪种模式都请把它当敏感数据。
|
|
435
|
+
|
|
436
|
+
## License
|
|
437
|
+
|
|
438
|
+
MIT
|
package/docs/README.md
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# Docs
|
|
2
|
+
|
|
3
|
+
- [schema.md](schema.md) — the wire protocol: envelope, join keys, every event type, the
|
|
4
|
+
digest contract, privacy and damage reporting
|
|
5
|
+
- [versioning.md](versioning.md) — wire / package / source versions, bump criteria, release
|
|
6
|
+
checklist
|
|
7
|
+
- [verification.md](verification.md) — what a real pi session covered, what the stubs could
|
|
8
|
+
not prove, and the platform matrix
|
|
9
|
+
|
|
10
|
+
The machine-readable form of the protocol is
|
|
11
|
+
[`schemas/workfeed-event-v1.schema.json`](../schemas/workfeed-event-v1.schema.json);
|
|
12
|
+
`test/schema-docs.test.mjs` fails when it and `schema.md` disagree.
|