@codyswann/lisa 2.222.0 → 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 -2
- package/dist/utils/usage-accounting.d.ts.map +1 -1
- package/dist/utils/usage-accounting.js +127 -48
- 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 +9 -1
- package/plugins/lisa/rules/eager/usage-accounting.md +6 -2
- package/plugins/lisa/rules/reference/usage-accounting.md +42 -5
- package/plugins/lisa/skills/lisa-usage-accounting/SKILL.md +9 -1
- package/plugins/lisa-agy/plugin.json +1 -1
- package/plugins/lisa-agy/skills/lisa-usage-accounting/SKILL.md +9 -1
- 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 +6 -2
- package/plugins/lisa-copilot/rules/reference/usage-accounting.md +42 -5
- package/plugins/lisa-copilot/skills/lisa-usage-accounting/SKILL.md +9 -1
- package/plugins/lisa-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-cursor/rules/usage-accounting-reference.mdc +42 -5
- package/plugins/lisa-cursor/rules/usage-accounting.mdc +6 -2
- package/plugins/lisa-cursor/skills/lisa-usage-accounting/SKILL.md +9 -1
- 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 +6 -2
- package/plugins/src/base/rules/reference/usage-accounting.md +42 -5
- package/plugins/src/base/skills/lisa-usage-accounting/SKILL.md +9 -1
|
@@ -17,7 +17,7 @@ Every artifact with inline body content gets exactly one section:
|
|
|
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
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`**: measured subtotal for `measured-subset` entries only. Keep `total_tokens = null` so rollups do not treat a subset as a complete total.
|
|
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.
|
|
21
21
|
- **`pricing_status`**: same trinary plus `missing` (cost not known but should be).
|
|
22
22
|
- **Absence ≠ zero.** `null` means unknown; `0` means explicitly zero. Always write the entry — never silently omit.
|
|
23
23
|
- Do NOT replace observed counts with estimates.
|
|
@@ -26,4 +26,8 @@ Each direct entry records ONE logical Lisa run on ONE artifact. `entry_id` is th
|
|
|
26
26
|
|
|
27
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.
|
|
28
28
|
|
|
29
|
-
|
|
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).
|
|
@@ -31,7 +31,7 @@ Each direct usage entry records one logical Lisa run or sub-run on one artifact.
|
|
|
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` |
|
|
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. |
|
|
35
35
|
| `cost` | Observed or estimated cost for this entry, or `null`. |
|
|
36
36
|
| `currency` | ISO currency code when `cost` is known, otherwise `null`. |
|
|
37
37
|
| `pricing_status` | `observed`, `estimated`, `missing`, or `unavailable`. |
|
|
@@ -69,16 +69,34 @@ total.
|
|
|
69
69
|
- `unavailable`: the runtime exposed neither trustworthy cost nor enough trustworthy token data to estimate cost.
|
|
70
70
|
|
|
71
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.
|
|
72
75
|
|
|
73
76
|
## Machine-readable tokens
|
|
74
77
|
|
|
75
|
-
Every visible direct entry row
|
|
78
|
+
Every visible direct entry row contains the backward-compatible 17-field primary token:
|
|
76
79
|
|
|
77
80
|
```text
|
|
78
|
-
<!-- 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>
|
|
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> -->
|
|
79
82
|
```
|
|
80
83
|
|
|
81
|
-
|
|
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.
|
|
82
100
|
|
|
83
101
|
Every managed section also ends with exactly one rollup token:
|
|
84
102
|
|
|
@@ -91,6 +109,23 @@ Every managed section also ends with exactly one rollup token:
|
|
|
91
109
|
- `child_refs` enumerates the child artifacts consulted for the rollup.
|
|
92
110
|
- `total_*` fields equal direct plus child totals over the deduped entry set.
|
|
93
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
|
+
|
|
94
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.
|
|
95
130
|
|
|
96
131
|
## Visible rendering contract
|
|
@@ -143,7 +178,9 @@ The rollup contract is additive across the hierarchy: PRDs may roll up Epics/Sto
|
|
|
143
178
|
- Recompute the entire section on every write; never append ad hoc rows.
|
|
144
179
|
- Sort direct entries deterministically by `(flow, run_id, entry_id)`.
|
|
145
180
|
- Preserve existing entries with unchanged `entry_id` and refreshed field values.
|
|
146
|
-
- 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.
|
|
147
184
|
- Do not include timestamps in the section preamble or token lines.
|
|
148
185
|
|
|
149
186
|
Idempotency is enforced by `entry_id` for direct entries and by the fixed rollup token field order for totals.
|
|
@@ -69,7 +69,10 @@ fields.
|
|
|
69
69
|
|
|
70
70
|
When the runtime exposes only a trustworthy subtotal, callers MUST use `source: measured-subset`,
|
|
71
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.
|
|
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.
|
|
73
76
|
|
|
74
77
|
## Return shape
|
|
75
78
|
|
|
@@ -168,6 +171,11 @@ failures into a generic "usage update failed."
|
|
|
168
171
|
canonical `usage-accounting` rule.
|
|
169
172
|
- Never append a second `## Lisa Usage` section or a second managed usage comment.
|
|
170
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.
|
|
171
179
|
- Never skip rollup dedupe. Child totals are keyed by stable `entry_id`, not by child ref count.
|
|
172
180
|
- Never silently drop to comments. Return `outcome: comment-fallback` so the caller can surface the
|
|
173
181
|
writable surface that actually holds the ledger.
|