dimies 0.1.0 → 0.1.2

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.
Files changed (3) hide show
  1. package/README.md +23 -0
  2. package/bin/dimies.js +16 -8
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -32,4 +32,27 @@ Paste into Claude Code (or Cursor, etc.) inside the repo you want instrumented.
32
32
  | `--dir path` | Target directory for `init` (default `.`) |
33
33
  | `--lang node\|python` | Override language detection |
34
34
 
35
+ ## Tracing
36
+
37
+ Pass a `trace` array of spans to `trackConversation(...)` to get a Langfuse-style execution tree on each conversation. Give every span a stable `id`, and set `input`/`output` to the payload — for an `llm` span, the prompt and the completion; for a `tool` span, the args and the result:
38
+
39
+ ```ts
40
+ trackConversation({
41
+ conversation_id: chat.id,
42
+ messages,
43
+ trace: [
44
+ { id: "llm-1", name: "vera.llm", type: "llm",
45
+ model: "gpt-4o", tokens_in: 1240, tokens_out: 85,
46
+ cost: 0.0017, // optional — exact spend; omit and Dimies estimates it
47
+ input: prompt, output: completion },
48
+ ],
49
+ });
50
+ ```
51
+
52
+ Field names are **exact** — `prompt`/`completion`/`response` are silently dropped, so a span sent that way shows *"No payload recorded"*. Merge is field-level and keyed by `id`: resend the same `id` to update a span (e.g. `{ id: "llm-1", status: "error" }`) and only the fields you include change — the rest is preserved.
53
+
54
+ **Cost accuracy:** set `model`, `tokens_in`, `tokens_out` on `llm` spans and the **Costs** dashboard prices them at list rates. For **exact** spend (negotiated rates, caching), also send `cost` in USD from your provider's usage — it's used verbatim instead of the estimate.
55
+
56
+ Full span schema: `<your-instance>/llms.txt`.
57
+
35
58
  MIT.
package/bin/dimies.js CHANGED
@@ -64,12 +64,14 @@ type DimiesSpan = {
64
64
  type?: "llm" | "tool" | "retrieval" | "function" | "other";
65
65
  started_at?: number | string;
66
66
  ended_at?: number | string;
67
- input?: unknown;
68
- output?: unknown;
69
- model?: string;
70
- tokens_in?: number;
71
- tokens_out?: number;
72
- cost?: number;
67
+ input?: unknown; // the payload shown when you click the span. llm: the prompt/messages;
68
+ output?: unknown; // tool: args/result; retrieval: query/docs. Names are exact — "prompt"
69
+ // or "completion" are dropped. Resend only the fields you change.
70
+ model?: string; // llm spans: the model id, e.g. "gpt-4o", "kimi-k2"
71
+ tokens_in?: number; // prompt tokens (needed for cost)
72
+ tokens_out?: number; // completion tokens (needed for cost)
73
+ cost?: number; // USD. Send it for EXACT spend in the Costs dashboard;
74
+ // if omitted, Dimies estimates from model + tokens at list prices.
73
75
  status?: "ok" | "error";
74
76
  error?: string;
75
77
  metadata?: Record<string, unknown>;
@@ -173,8 +175,14 @@ const AGENT_PROMPT = (baseUrl) => `Integrate Dimies conversation analytics into
173
175
  (details in the spec).
174
176
  4. Read DIMIES_API_KEY and DIMIES_URL from environment variables; add them
175
177
  to .env.example. Never hardcode the key.
176
- 5. If the app has tool calls / retrievals around the LLM call, also send them as
177
- a "trace" array (span schema in the spec) so executions are debuggable.
178
+ 5. If the app has LLM / tool / retrieval steps, also send them as a "trace" array
179
+ (span schema in the spec) so executions are debuggable. On each span set
180
+ "input" and "output" (exact field names) to the payload — for an llm span that
181
+ is the prompt and the completion; for a tool span the args and the result.
182
+ On llm spans also set "model", "tokens_in", "tokens_out" (from the provider's
183
+ usage) for cost analytics — and "cost" in USD if you want exact spend instead
184
+ of an estimate. Without payload the span shows "No payload recorded". Give
185
+ every span a stable "id" and resend only the fields you change.
178
186
  6. Verify: run the app, trigger one conversation, and confirm it appears at
179
187
  ${baseUrl}/app (or run \`npx dimies test --key $DIMIES_API_KEY\`).
180
188
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dimies",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "Integrate Dimies (conversation analytics for AI agents) into any codebase in one command — human- and AI-coding-agent-friendly.",
5
5
  "bin": {
6
6
  "dimies": "bin/dimies.js"