@codyswann/lisa 2.221.6 → 2.222.1
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/dist/utils/usage-accounting.d.ts +3 -1
- package/dist/utils/usage-accounting.d.ts.map +1 -1
- package/dist/utils/usage-accounting.js +142 -47
- package/dist/utils/usage-accounting.js.map +1 -1
- package/package.json +1 -1
- package/plugins/lisa/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa/.codex-plugin/skills/lisa-usage-accounting/SKILL.md +12 -0
- package/plugins/lisa/rules/eager/usage-accounting.md +7 -2
- package/plugins/lisa/rules/reference/usage-accounting.md +47 -5
- package/plugins/lisa/skills/lisa-usage-accounting/SKILL.md +12 -0
- package/plugins/lisa-agy/plugin.json +1 -1
- package/plugins/lisa-agy/skills/lisa-usage-accounting/SKILL.md +12 -0
- package/plugins/lisa-cdk/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-cdk/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-cdk-agy/plugin.json +1 -1
- package/plugins/lisa-cdk-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-cdk-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-copilot/rules/eager/usage-accounting.md +7 -2
- package/plugins/lisa-copilot/rules/reference/usage-accounting.md +47 -5
- package/plugins/lisa-copilot/skills/lisa-usage-accounting/SKILL.md +12 -0
- package/plugins/lisa-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-cursor/rules/usage-accounting-reference.mdc +47 -5
- package/plugins/lisa-cursor/rules/usage-accounting.mdc +7 -2
- package/plugins/lisa-cursor/skills/lisa-usage-accounting/SKILL.md +12 -0
- package/plugins/lisa-expo/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-expo/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-expo-agy/plugin.json +1 -1
- package/plugins/lisa-expo-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-expo-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-harper-fabric/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-harper-fabric/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-harper-fabric-agy/plugin.json +1 -1
- package/plugins/lisa-harper-fabric-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-harper-fabric-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-nestjs/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-nestjs/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-nestjs-agy/plugin.json +1 -1
- package/plugins/lisa-nestjs-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-nestjs-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-openclaw/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-openclaw/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-openclaw-agy/plugin.json +1 -1
- package/plugins/lisa-openclaw-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-openclaw-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-phaser/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-phaser/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-phaser-agy/plugin.json +1 -1
- package/plugins/lisa-phaser-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-phaser-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-rails/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-rails/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-rails-agy/plugin.json +1 -1
- package/plugins/lisa-rails-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-rails-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-typescript/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-typescript/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-typescript-agy/plugin.json +1 -1
- package/plugins/lisa-typescript-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-typescript-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-wiki/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-wiki/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-wiki-agy/plugin.json +1 -1
- package/plugins/lisa-wiki-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-wiki-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/src/base/rules/eager/usage-accounting.md +7 -2
- package/plugins/src/base/rules/reference/usage-accounting.md +47 -5
- package/plugins/src/base/skills/lisa-usage-accounting/SKILL.md +12 -0
|
@@ -16,7 +16,8 @@ Every artifact with inline body content gets exactly one section:
|
|
|
16
16
|
|
|
17
17
|
Each direct entry records ONE logical Lisa run on ONE artifact. `entry_id` is the stable dedupe key — rewriting the same logical run with the same `entry_id` updates in place; a different run gets a different `entry_id`.
|
|
18
18
|
|
|
19
|
-
- **`source`**: `observed` (runtime supplied) / `estimated` (derived from trustworthy metadata + pricing contract) / `unavailable`.
|
|
19
|
+
- **`source`**: `observed` (runtime supplied) / `estimated` (derived from trustworthy metadata + pricing contract) / `measured-subset` (a trustworthy subtotal exists, but the complete run total is unknown) / `unavailable`.
|
|
20
|
+
- **`measured_subset_tokens`**: optional measured subtotal for `measured-subset` entries only. Omission is normalized to `null` for backward-compatible callers. Keep `total_tokens = null` so rollups do not treat a subset as a complete total.
|
|
20
21
|
- **`pricing_status`**: same trinary plus `missing` (cost not known but should be).
|
|
21
22
|
- **Absence ≠ zero.** `null` means unknown; `0` means explicitly zero. Always write the entry — never silently omit.
|
|
22
23
|
- Do NOT replace observed counts with estimates.
|
|
@@ -25,4 +26,8 @@ Each direct entry records ONE logical Lisa run on ONE artifact. `entry_id` is th
|
|
|
25
26
|
|
|
26
27
|
Container artifacts (Epic, PRD, etc.) roll up usage from their direct children. Roll-up is recursive — a parent's `## Lisa Usage` aggregates its descendants' direct entries. Re-writes are idempotent: re-running an intake or lifecycle skill must not duplicate entries.
|
|
27
28
|
|
|
28
|
-
|
|
29
|
+
Measured-child incompleteness is durable across ordinary rewrites through the optional
|
|
30
|
+
`lisa:usage-rollup-token-status` extension. Do not infer completeness merely because a rewrite did
|
|
31
|
+
not re-fetch child ledgers.
|
|
32
|
+
|
|
33
|
+
Full schema (backward-compatible 17-field primary marker, correlated measured-subset extension, pricing semantics, rollup math, idempotent-migration rules): [reference/usage-accounting.md](../reference/usage-accounting.md).
|
|
@@ -25,12 +25,13 @@ Each direct usage entry records one logical Lisa run or sub-run on one artifact.
|
|
|
25
25
|
| `run_id` | Runtime/session identifier when available; empty only when the runtime exposes no stable run id. |
|
|
26
26
|
| `provider` | Model provider name. |
|
|
27
27
|
| `model` | Model identifier. |
|
|
28
|
-
| `source` | `observed`, `estimated`, or `unavailable`. |
|
|
28
|
+
| `source` | `observed`, `estimated`, `measured-subset`, or `unavailable`. |
|
|
29
29
|
| `input_tokens` | Prompt/input tokens, or `null` when unavailable. |
|
|
30
30
|
| `cached_input_tokens` | Cached/reused input tokens, or `null` when unavailable/not exposed. |
|
|
31
31
|
| `output_tokens` | Output/completion tokens, or `null` when unavailable. |
|
|
32
32
|
| `reasoning_tokens` | Reasoning/internal tokens, or `null` when unavailable/not exposed. |
|
|
33
33
|
| `total_tokens` | Total trustworthy tokens for the entry, or `null`. |
|
|
34
|
+
| `measured_subset_tokens` | Optional trustworthy measured subtotal for a known subset of the run. Omission is normalized to `null` so callers written before this field remain source-compatible. |
|
|
34
35
|
| `cost` | Observed or estimated cost for this entry, or `null`. |
|
|
35
36
|
| `currency` | ISO currency code when `cost` is known, otherwise `null`. |
|
|
36
37
|
| `pricing_status` | `observed`, `estimated`, `missing`, or `unavailable`. |
|
|
@@ -46,13 +47,17 @@ Each direct usage entry records one logical Lisa run or sub-run on one artifact.
|
|
|
46
47
|
|
|
47
48
|
- `observed`: the runtime supplied the usage directly. Do not replace observed counts with estimates.
|
|
48
49
|
- `estimated`: Lisa derived counts or cost from trustworthy runtime metadata plus an explicit pricing contract. Estimates are allowed only when the derivation inputs are real and attributable to the run.
|
|
50
|
+
- `measured-subset`: Lisa measured a known subset of the run, but not enough to claim a complete `total_tokens` value. Preserve the subtotal in `measured_subset_tokens`, keep `total_tokens = null`, and keep rollup totals unknown instead of treating the subset as the whole run.
|
|
49
51
|
- `unavailable`: Lisa could not obtain trustworthy usage data. Write the entry anyway with `null` token/cost fields rather than silently omitting the row.
|
|
50
52
|
|
|
51
53
|
The absence of data is never treated as zero. `null` means unknown; `0` means explicitly observed or derived zero.
|
|
52
54
|
|
|
53
55
|
For example, an unavailable Verify run still records a direct entry with `source = unavailable`,
|
|
54
56
|
`pricing_status = unavailable`, and `null` token/cost fields so downstream readers can distinguish
|
|
55
|
-
"missing telemetry" from "zero usage."
|
|
57
|
+
"missing telemetry" from "zero usage." A Plan run with measured sub-agent usage but unmeasured
|
|
58
|
+
main-loop usage records `source = measured-subset`, `measured_subset_tokens = <subtotal>`, and
|
|
59
|
+
`total_tokens = null` so the subtotal is durable without being misrepresented as the complete run
|
|
60
|
+
total.
|
|
56
61
|
|
|
57
62
|
## Pricing semantics
|
|
58
63
|
|
|
@@ -64,16 +69,34 @@ For example, an unavailable Verify run still records a direct entry with `source
|
|
|
64
69
|
- `unavailable`: the runtime exposed neither trustworthy cost nor enough trustworthy token data to estimate cost.
|
|
65
70
|
|
|
66
71
|
Runtime-observed cost always wins over estimates. Estimated cost never overwrites an observed value. Missing pricing preserves token counts and a `null` cost.
|
|
72
|
+
Token completeness and cost trust are independent: a `measured-subset` entry may still carry an
|
|
73
|
+
observed trustworthy whole-run cost. Token rollups remain unknown, but that cost participates in
|
|
74
|
+
cost rollups under the normal pricing and currency rules.
|
|
67
75
|
|
|
68
76
|
## Machine-readable tokens
|
|
69
77
|
|
|
70
|
-
Every visible direct entry row
|
|
78
|
+
Every visible direct entry row contains the backward-compatible 17-field primary token:
|
|
71
79
|
|
|
72
80
|
```text
|
|
73
81
|
<!-- lisa:usage-entry entry_id=<id> flow=<flow> run_id=<run-id> provider=<provider> model=<model> source=<source> input_tokens=<n|null> cached_input_tokens=<n|null> output_tokens=<n|null> reasoning_tokens=<n|null> total_tokens=<n|null> cost=<decimal|null> currency=<code|null> pricing_status=<status> pricing_source=<ref|null> artifact_ref=<ref> parent_artifact_ref=<ref-or-empty> -->
|
|
74
82
|
```
|
|
75
83
|
|
|
76
|
-
|
|
84
|
+
The row immediately follows it with a correlated measured-subset extension. Writers serialize an
|
|
85
|
+
omitted value as `null` instead of `undefined`:
|
|
86
|
+
|
|
87
|
+
```text
|
|
88
|
+
<!-- lisa:usage-entry-measured-subset entry_id=<id> measured_subset_tokens=<n|null> -->
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
The primary field order is fixed and deliberately matches the pre-measured-subset contract so
|
|
92
|
+
legacy 17-field readers continue to enumerate entries. Current readers correlate the extension by
|
|
93
|
+
its percent-encoded `entry_id`. They also accept the `@codyswann/lisa@2.222.0` transitional marker,
|
|
94
|
+
which placed `measured_subset_tokens` between `total_tokens` and `cost`, and migrate it to the
|
|
95
|
+
primary-plus-extension layout on rewrite. Only that transitional additive field accepts the literal
|
|
96
|
+
`undefined` emitted by an older caller and normalizes it to `null`; established numeric fields
|
|
97
|
+
remain strict. String fields are percent-encoded before rendering and decoded after parsing, so
|
|
98
|
+
whitespace, commas, and HTML comment terminators inside source values cannot split or truncate the
|
|
99
|
+
token.
|
|
77
100
|
|
|
78
101
|
Every managed section also ends with exactly one rollup token:
|
|
79
102
|
|
|
@@ -86,6 +109,23 @@ Every managed section also ends with exactly one rollup token:
|
|
|
86
109
|
- `child_refs` enumerates the child artifacts consulted for the rollup.
|
|
87
110
|
- `total_*` fields equal direct plus child totals over the deduped entry set.
|
|
88
111
|
|
|
112
|
+
If a direct entry or freshly resolved child entry is `measured-subset`, the corresponding token
|
|
113
|
+
scope and combined `total_tokens` are `null`; a measured subtotal is never added to complete token
|
|
114
|
+
counts. Other established nullable-entry behavior is unchanged. Cost rollups are computed
|
|
115
|
+
independently, so a trustworthy whole-run cost is not discarded merely because token completeness
|
|
116
|
+
is unknown.
|
|
117
|
+
|
|
118
|
+
When freshly resolved child work contains a measured subset, the primary rollup token is followed
|
|
119
|
+
by this optional backward-compatible extension:
|
|
120
|
+
|
|
121
|
+
```text
|
|
122
|
+
<!-- lisa:usage-rollup-token-status child_tokens_incomplete=true -->
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
The extension preserves child-token incompleteness across ordinary direct-entry rewrites that do
|
|
126
|
+
not resolve children again. It is omitted when child token totals are not known to be incomplete,
|
|
127
|
+
so legacy rollup objects and readers retain their established shape.
|
|
128
|
+
|
|
89
129
|
The rollup token is the machine-readable summary. The visible rollup table mirrors it for humans. List fields are comma-delimited after encoding each item independently; commas inside an item are encoded as data, not treated as separators.
|
|
90
130
|
|
|
91
131
|
## Visible rendering contract
|
|
@@ -138,7 +178,9 @@ The rollup contract is additive across the hierarchy: PRDs may roll up Epics/Sto
|
|
|
138
178
|
- Recompute the entire section on every write; never append ad hoc rows.
|
|
139
179
|
- Sort direct entries deterministically by `(flow, run_id, entry_id)`.
|
|
140
180
|
- Preserve existing entries with unchanged `entry_id` and refreshed field values.
|
|
141
|
-
- Re-running with the same logical entry set must produce byte-identical output.
|
|
181
|
+
- Re-running with the same logical entry set must produce byte-identical output. Rewriting a legacy
|
|
182
|
+
primary-only marker or the 2.222.0 transitional marker migrates once to the canonical
|
|
183
|
+
primary-plus-extension layout; subsequent rewrites are byte-identical.
|
|
142
184
|
- Do not include timestamps in the section preamble or token lines.
|
|
143
185
|
|
|
144
186
|
Idempotency is enforced by `entry_id` for direct entries and by the fixed rollup token field order for totals.
|
|
@@ -67,6 +67,13 @@ and artifact refs. Callers do not get to omit the "unavailable" case; when trust
|
|
|
67
67
|
missing they still pass an explicit entry with `source: unavailable` and nullable token/cost
|
|
68
68
|
fields.
|
|
69
69
|
|
|
70
|
+
When the runtime exposes only a trustworthy subtotal, callers MUST use `source: measured-subset`,
|
|
71
|
+
write the subtotal to `measured_subset_tokens`, and leave `total_tokens: null`. Do not coerce a
|
|
72
|
+
known subset into `total_tokens`; rollups use `total_tokens` only for complete totals. The
|
|
73
|
+
`measured_subset_tokens` field is optional for backward compatibility with callers that construct
|
|
74
|
+
ordinary observed, estimated, or unavailable entries; the shared serializer normalizes omission
|
|
75
|
+
to `null`. A trustworthy whole-run cost remains valid independently of incomplete token telemetry.
|
|
76
|
+
|
|
70
77
|
## Return shape
|
|
71
78
|
|
|
72
79
|
Return structured output so callers can persist or log what happened without reparsing prose:
|
|
@@ -164,6 +171,11 @@ failures into a generic "usage update failed."
|
|
|
164
171
|
canonical `usage-accounting` rule.
|
|
165
172
|
- Never append a second `## Lisa Usage` section or a second managed usage comment.
|
|
166
173
|
- Never treat missing usage as zero. Callers must record explicit `source: unavailable` entries.
|
|
174
|
+
- Never add a measured subset to complete token totals. A mixed complete-plus-measured-subset
|
|
175
|
+
direct or child scope has `null` token rollups, while trustworthy whole-run cost rolls up
|
|
176
|
+
independently.
|
|
177
|
+
- Never discard the optional child-token incompleteness state parsed from an existing rollup when
|
|
178
|
+
`child_refs` were not refreshed. Preserve it through ordinary direct-entry rewrites.
|
|
167
179
|
- Never skip rollup dedupe. Child totals are keyed by stable `entry_id`, not by child ref count.
|
|
168
180
|
- Never silently drop to comments. Return `outcome: comment-fallback` so the caller can surface the
|
|
169
181
|
writable surface that actually holds the ledger.
|