@onthink/prompt-observer 0.1.1 → 0.2.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/PROMPT_OBSERVER.md +36 -8
- package/README.md +46 -14
- package/bin/prompt-observer.mjs +734 -246
- package/package.json +2 -1
- package/pricing/models.json +23 -0
- package/schema/event.schema.json +48 -84
package/PROMPT_OBSERVER.md
CHANGED
|
@@ -7,9 +7,9 @@ Follow this contract after every user-requested task. Complete the task first, t
|
|
|
7
7
|
1. Use only information visible in the conversation, tool results, file changes, and verification output.
|
|
8
8
|
2. Never store the full user prompt, the full assistant response, system instructions, private reasoning, chain-of-thought, credentials, access tokens, or other secrets.
|
|
9
9
|
3. `prompt_summary` must be a short, redacted description of the request, not a quotation or close reproduction.
|
|
10
|
-
4.
|
|
10
|
+
4. Prefer platform-reported usage. When it is unavailable, estimate token counts only from the visible user input and final response with the deterministic heuristic below. Never guess a model name. The logger calculates estimated cost only for an exact model match in `.prompt-observer/pricing.json`.
|
|
11
11
|
5. Base execution signals only on observed results. Do not claim a file changed or a test passed without evidence.
|
|
12
|
-
6. Use schema version `1.
|
|
12
|
+
6. Use schema version `1.1` and conform to `.prompt-observer/event.schema.json`.
|
|
13
13
|
7. Do not manufacture criticism. If the prompt is clear and sufficient for the task, keep `weaknesses` and `improvement_suggestions` empty.
|
|
14
14
|
8. Evaluate against objective task requirements, not personal preferences about wording, tone, verbosity, formatting, workflow, or technology choices.
|
|
15
15
|
|
|
@@ -53,6 +53,31 @@ If writing files or running the logger is unavailable, do not pretend the event
|
|
|
53
53
|
|
|
54
54
|
Score only prompt quality. Do not lower a score because implementation was difficult when the request itself was clear.
|
|
55
55
|
|
|
56
|
+
## Structured insights
|
|
57
|
+
|
|
58
|
+
In schema `1.1`, every strength and improvement suggestion is an object with:
|
|
59
|
+
|
|
60
|
+
- `category`: one of `intent_clarity`, `context_sufficiency`, `scope_definition`, `constraints_quality`, `acceptance_criteria`, `verification_plan`, `output_format`, or `other`
|
|
61
|
+
- `message`: one concise, evidence-based observation
|
|
62
|
+
|
|
63
|
+
Legacy schema `1.0` events with string arrays remain readable, but all new events must use the structured `1.1` form.
|
|
64
|
+
|
|
65
|
+
## Usage precedence and estimation
|
|
66
|
+
|
|
67
|
+
1. If the platform reports any model, token, or cost metrics, record only those reported metrics, keep unreported metrics `null`, use `source: "platform_reported"`, and keep `estimation_method: null`.
|
|
68
|
+
2. Otherwise, if the Agent can inspect the complete visible user input and its final response, estimate each side independently using `agent_text_heuristic_v1`:
|
|
69
|
+
- Ignore whitespace.
|
|
70
|
+
- Count ASCII letters and digits as `characters / 4`.
|
|
71
|
+
- Count non-ASCII letters, digits, and combining marks as `characters / 2`.
|
|
72
|
+
- Count punctuation and symbols as `characters / 2`.
|
|
73
|
+
- Add the three values and round up to the next integer.
|
|
74
|
+
3. Store the two counts with `source: "estimated"` and `estimation_method: "agent_text_heuristic_v1"`.
|
|
75
|
+
4. Set `model` only when the runtime explicitly identifies it. Never infer a model from the product name.
|
|
76
|
+
5. Leave `cost_usd: null`. During `log`, the CLI fills it only when both token counts exist and `model` exactly matches `.prompt-observer/pricing.json`; the pricing snapshot identifier is then appended to `estimation_method`.
|
|
77
|
+
6. If neither reported nor safely estimated usage is available, keep all metrics `null`, use `source: "unavailable"`, and keep `estimation_method: null`.
|
|
78
|
+
|
|
79
|
+
Estimated usage is directional, not billing data. Never include hidden system instructions, tool payloads, cached-token adjustments, subscription fees, or guessed reasoning tokens in the estimate.
|
|
80
|
+
|
|
56
81
|
## Evidence threshold and neutrality
|
|
57
82
|
|
|
58
83
|
- Record a weakness only when a concrete omission, ambiguity, contradiction, or constraint creates a meaningful risk of wrong execution, wasted work, or unverifiable completion.
|
|
@@ -66,7 +91,7 @@ Score only prompt quality. Do not lower a score because implementation was diffi
|
|
|
66
91
|
|
|
67
92
|
```json
|
|
68
93
|
{
|
|
69
|
-
"schema_version": "1.
|
|
94
|
+
"schema_version": "1.1",
|
|
70
95
|
"event_id": "evt-20260901-7f3a92c1",
|
|
71
96
|
"timestamp": "2026-09-01T12:00:00.000Z",
|
|
72
97
|
"task_type": "coding",
|
|
@@ -79,7 +104,10 @@ Score only prompt quality. Do not lower a score because implementation was diffi
|
|
|
79
104
|
"verification_plan": 9,
|
|
80
105
|
"ambiguity_risk": "low",
|
|
81
106
|
"strengths": [
|
|
82
|
-
|
|
107
|
+
{
|
|
108
|
+
"category": "constraints_quality",
|
|
109
|
+
"message": "The requested deliverables and runtime constraints are explicit."
|
|
110
|
+
}
|
|
83
111
|
],
|
|
84
112
|
"weaknesses": [],
|
|
85
113
|
"improvement_suggestions": [],
|
|
@@ -97,11 +125,11 @@ Score only prompt quality. Do not lower a score because implementation was diffi
|
|
|
97
125
|
},
|
|
98
126
|
"usage": {
|
|
99
127
|
"model": null,
|
|
100
|
-
"input_tokens":
|
|
101
|
-
"output_tokens":
|
|
128
|
+
"input_tokens": 280,
|
|
129
|
+
"output_tokens": 640,
|
|
102
130
|
"cost_usd": null,
|
|
103
|
-
"source": "
|
|
104
|
-
"estimation_method":
|
|
131
|
+
"source": "estimated",
|
|
132
|
+
"estimation_method": "agent_text_heuristic_v1"
|
|
105
133
|
}
|
|
106
134
|
}
|
|
107
135
|
```
|
package/README.md
CHANGED
|
@@ -9,9 +9,9 @@ It is designed for Vibe Coding workflows and works without a browser extension,
|
|
|
9
9
|
## What it records
|
|
10
10
|
|
|
11
11
|
- Prompt-quality dimensions: clarity, context, scope, constraints, acceptance criteria, and verification plan
|
|
12
|
-
-
|
|
12
|
+
- Structured strengths, actionable weaknesses, and improvement suggestions
|
|
13
13
|
- Observed execution signals: result status, changed files, and test outcomes
|
|
14
|
-
-
|
|
14
|
+
- Exact platform usage when available, otherwise clearly labeled token estimates and model-matched cost estimates
|
|
15
15
|
|
|
16
16
|
Raw prompts, raw responses, private reasoning, system instructions, and secrets are prohibited from the event format.
|
|
17
17
|
|
|
@@ -57,27 +57,59 @@ Each initialized project receives:
|
|
|
57
57
|
event.schema.json Versioned event schema
|
|
58
58
|
prompt-observer.mjs Portable local CLI
|
|
59
59
|
events.jsonl Generated append-only event log
|
|
60
|
-
|
|
60
|
+
pricing.json Versioned model-pricing snapshot
|
|
61
|
+
report.md Compact GitHub-friendly report
|
|
62
|
+
report.html Interactive offline dashboard
|
|
61
63
|
```
|
|
62
64
|
|
|
63
|
-
The generated log and
|
|
65
|
+
The generated log and reports are excluded by the local `.prompt-observer/.gitignore`; the contract, schema, and pricing snapshot can safely be committed.
|
|
64
66
|
|
|
65
|
-
##
|
|
67
|
+
## Automatic behavior
|
|
66
68
|
|
|
67
|
-
|
|
69
|
+
After the project instruction is added, the coding agent handles event creation and logging after each task. You do **not** need to run `validate` or `log` yourself during normal use.
|
|
68
70
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
71
|
+
The agent creates a temporary event, validates it, appends it to `.prompt-observer/events.jsonl`, and removes the temporary file after a successful save.
|
|
72
|
+
|
|
73
|
+
## View reports
|
|
72
74
|
|
|
73
|
-
|
|
74
|
-
node .prompt-observer/prompt-observer.mjs log .prompt-observer/pending/example.json
|
|
75
|
+
Generate reports from the latest 50 events:
|
|
75
76
|
|
|
76
|
-
|
|
77
|
+
```powershell
|
|
77
78
|
node .prompt-observer/prompt-observer.mjs report .
|
|
78
79
|
```
|
|
79
80
|
|
|
80
|
-
The report
|
|
81
|
+
This creates `.prompt-observer/report.md` and `.prompt-observer/report.html`. The Markdown report is a compact repository-friendly summary. The self-contained HTML dashboard adds KPI cards, quality and trend charts, filters, recurring strengths, weaknesses, improvement suggestions, verification results, and usage coverage. It embeds only the selected window's already-redacted analytical fields, not changed-file lists or test names.
|
|
82
|
+
|
|
83
|
+
Choose another bounded window or explicitly analyze all events:
|
|
84
|
+
|
|
85
|
+
```powershell
|
|
86
|
+
node .prompt-observer/prompt-observer.mjs report . --limit 100
|
|
87
|
+
node .prompt-observer/prompt-observer.mjs report . --all
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
The default reader streams the JSONL history and retains only the latest 50 events plus the previous 50-event comparison window. The complete append-only log remains available without making the generated reports grow forever.
|
|
91
|
+
|
|
92
|
+
## Usage accuracy and estimates
|
|
93
|
+
|
|
94
|
+
Prompt Observer uses this precedence:
|
|
95
|
+
|
|
96
|
+
1. Metrics explicitly reported by the Agent platform are stored as `platform_reported`.
|
|
97
|
+
2. When the platform exposes no usage but the Agent can see the input and final response, token counts are estimated with the documented `agent_text_heuristic_v1` method.
|
|
98
|
+
3. Estimated cost is calculated only when the runtime reports an exact model ID that exists in the local versioned `pricing.json` snapshot.
|
|
99
|
+
4. Unknown values remain `null` and are reported as unavailable.
|
|
100
|
+
|
|
101
|
+
The dashboard always separates exact, estimated, and unavailable values. Cost estimates exclude cached tokens, tools, subscription pricing, discounts, long-context premiums, and provider-specific charges, so they must not be treated as invoices.
|
|
102
|
+
|
|
103
|
+
## Manual event troubleshooting (advanced)
|
|
104
|
+
|
|
105
|
+
`validate` and `log` are diagnostic commands for a temporary event that an agent has already created. They are not part of the normal setup or daily workflow, and `example.json` is not created by `init`.
|
|
106
|
+
|
|
107
|
+
Use them only when inspecting a real pending event before it is logged:
|
|
108
|
+
|
|
109
|
+
```powershell
|
|
110
|
+
node .prompt-observer/prompt-observer.mjs validate .prompt-observer/pending/<event-id>.json
|
|
111
|
+
node .prompt-observer/prompt-observer.mjs log .prompt-observer/pending/<event-id>.json
|
|
112
|
+
```
|
|
81
113
|
|
|
82
114
|
## No-filesystem fallback
|
|
83
115
|
|
|
@@ -102,7 +134,7 @@ npm run check
|
|
|
102
134
|
npm test
|
|
103
135
|
```
|
|
104
136
|
|
|
105
|
-
`prepublishOnly` runs both checks automatically before `npm publish`. The package is published publicly under the `@onthink` scope. The project uses only Node.js built-ins; JSONL
|
|
137
|
+
`prepublishOnly` runs both checks automatically before `npm publish`. The package is published publicly under the `@onthink` scope. The project uses only Node.js built-ins; JSONL remains the source of truth, while SQLite export is intentionally deferred.
|
|
106
138
|
|
|
107
139
|
## License
|
|
108
140
|
|