@peasant-labs/fairtrade 0.0.37 → 0.0.39

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.
@@ -1,3 +1,10 @@
1
+ /**
2
+ * Is this wire turn one of Claude Code's session metadata records rather than conversation?
3
+ * @param {TurnDetail} turn
4
+ * @param {string | undefined} harness the session's harness
5
+ * @returns {boolean}
6
+ */
7
+ export function isSessionMetadataTurn(turn: TurnDetail, harness: string | undefined): boolean;
1
8
  /**
2
9
  * Default turn prefilter the adapter applies independently per partition:
3
10
  * preserve normalized evidence, including unknown provenance and folded refs.
@@ -8,16 +15,6 @@
8
15
  * @returns {TurnDetail[]}
9
16
  */
10
17
  export function prefilterTurns(turns: TurnDetail[]): TurnDetail[];
11
- /**
12
- * Dependency-free line diff (LCS) → cooked `DiffLineVM[]`. fairtrade ships no
13
- * `diff` package, so the adapter computes hunks itself. Line numbers are 1-based
14
- * within the supplied snippet (the wire carries the edit snippet, not the file
15
- * offset). Deterministic — no clock/randomness — so it is screenshot-stable.
16
- * @param {string} oldText
17
- * @param {string} newText
18
- * @returns {DiffLineVM[]}
19
- */
20
- export function diffLines(oldText: string, newText: string): DiffLineVM[];
21
18
  /**
22
19
  * Project the canonical wire payload (folded turns) into the cooked
23
20
  * `TranscriptViewModel` every dumb transcript component renders. The SOLE
@@ -30,6 +27,7 @@ export function diffLines(oldText: string, newText: string): DiffLineVM[];
30
27
  * @returns {TranscriptViewModel}
31
28
  */
32
29
  export function adaptTranscript(payload: TranscriptWireInput, annotations?: AnnotationSummary[], analytics?: TranscriptAnalyticsVM, options?: AdaptTranscriptOptions): TranscriptViewModel;
30
+ export { diffLines };
33
31
  export type TranscriptWireInput = import("./wire-types.js").TranscriptWireInput;
34
32
  export type SessionDetailPayload = import("./wire-types.js").SessionDetailPayload;
35
33
  export type TurnDetail = import("./wire-types.js").TurnDetail;
@@ -44,6 +42,7 @@ export type SessionVM = import("./view-model.js").SessionVM;
44
42
  export type SessionGitVM = import("./view-model.js").SessionGitVM;
45
43
  export type CommitVM = import("./view-model.js").CommitVM;
46
44
  export type TurnVM = import("./view-model.js").TurnVM;
45
+ export type TaskGroupVM = import("./view-model.js").TaskGroupVM;
47
46
  export type ToolCallVM = import("./view-model.js").ToolCallVM;
48
47
  export type ToolGroup = import("./view-model.js").ToolGroup;
49
48
  export type DiffLineVM = import("./view-model.js").DiffLineVM;
@@ -64,3 +63,4 @@ export type AdaptTranscriptOptions = {
64
63
  */
65
64
  relationshipNavigation?: import("@peasant-labs/schema").SessionRelationshipNavigation[];
66
65
  };
66
+ import { diffLines } from './adapter.parse.js';
@@ -1,4 +1,5 @@
1
1
  /** @typedef {import('./wire-types.js').ToolCallDetail} ToolCallDetail */
2
+ /** @typedef {import('./view-model.js').DiffLineVM} DiffLineVM */
2
3
  /**
3
4
  * The SOLE `JSON.parse` of a wire-encoded tool string in the lifted code. Every
4
5
  * other parse helper here, the adapter, and the analytics util route through it,
@@ -55,9 +56,35 @@ export function editPairs(call: ToolCallDetail): EditPair[];
55
56
  */
56
57
  export function writeContent(call: ToolCallDetail): string;
57
58
  /**
58
- * Lines inserted / removed for an edit-family or write tool call. Consolidates
59
- * the THREE duplicate `countDiff` definitions. Pure: depends only on the parsed
60
- * arguments, never a clock or the file system.
59
+ * Dependency-free line diff (LCS) → cooked `DiffLineVM[]`. fairtrade ships no
60
+ * `diff` package, so the adapter computes hunks itself. Line numbers are 1-based
61
+ * within the supplied snippet (the wire carries the edit snippet, not the file
62
+ * offset). Deterministic — no clock/randomness — so it is screenshot-stable.
63
+ * @param {string} oldText
64
+ * @param {string} newText
65
+ * @returns {DiffLineVM[]}
66
+ */
67
+ export function diffLines(oldText: string, newText: string): DiffLineVM[];
68
+ /**
69
+ * The cooked line diff of an edit-family or write tool call (one line list per replaced span) and
70
+ * its churn: the + and − lines of that same diff, so a rewrite of three lines counts +3 −3 and every
71
+ * count (the tool call, the diffs tab, a task's churn) agrees with the lines it heads. A span's
72
+ * trailing empty line is the newline artifact, not a line anyone wrote, so it is not counted, as the
73
+ * renderer does not show it. Undefined for any other kind, or an edit with no replacement. Memoised
74
+ * per call object, because the adapter and the analytics both ask and the line diff is quadratic in
75
+ * the span length.
76
+ * @param {ToolCallDetail} call
77
+ * @returns {{ spans: DiffLineVM[][], adds: number, dels: number } | undefined}
78
+ */
79
+ export function callDiff(call: ToolCallDetail): {
80
+ spans: DiffLineVM[][];
81
+ adds: number;
82
+ dels: number;
83
+ } | undefined;
84
+ /**
85
+ * Lines inserted / removed for an edit-family or write tool call: the churn of `callDiff`, zero
86
+ * for any other kind. Consolidates the THREE duplicate `countDiff` definitions. Pure: depends only
87
+ * on the parsed arguments, never a clock or the file system.
61
88
  * @param {ToolCallDetail} call
62
89
  * @returns {{ adds: number, dels: number }}
63
90
  */
@@ -66,6 +93,7 @@ export function countDiff(call: ToolCallDetail): {
66
93
  dels: number;
67
94
  };
68
95
  export type ToolCallDetail = import("./wire-types.js").ToolCallDetail;
96
+ export type DiffLineVM = import("./view-model.js").DiffLineVM;
69
97
  /**
70
98
  * One old→new replacement inside an Edit / MultiEdit / NotebookEdit call.
71
99
  */
@@ -72,9 +72,9 @@ export type PhaseVM = import("./view-model.js").PhaseVM;
72
72
  export type ScorecardBandVM = import("./view-model.js").ScorecardBandVM;
73
73
  export type TranscriptAnalyticsVM = import("./view-model.js").TranscriptAnalyticsVM;
74
74
  export { ROLES, ENTRY_TYPES, TOOL_CALL_KINDS, STOP_REASONS, SESSION_OUTCOMES, HARNESSES } from "./wire-types.js";
75
- export { adaptTranscript, prefilterTurns, diffLines } from "./adapter.js";
75
+ export { adaptTranscript, prefilterTurns, isSessionMetadataTurn, diffLines } from "./adapter.js";
76
76
  export { computeTasks, computeTurnLabels, buildTaskWaterfall, annotateTranscript, computePersonalMedians, detectPhases, assessScorecard, computeAnalytics, computeTaskGroups, phaseLabel } from "./analytics.js";
77
- export { formatRelative, formatDurationMins, formatDateLong } from "./time.js";
78
- export { summarizePrompt, composeSessionTitle, projectLabel } from "./title.js";
77
+ export { formatRelative, formatDurationMins, formatDurationMs, formatDurationSeconds, formatDateLong, isKnownTime } from "./time.js";
78
+ export { summarizePrompt, composeSessionTitle, projectLabel, cleanSessionTitle, unwrapUserQuery } from "./title.js";
79
79
  export { default as TranscriptDiffEntryCard, DiffHunks as TranscriptDiffHunks } from "./DiffEntryCard.jsx";
80
80
  export { advanceTranscriptInitialPositionConsumption, normalizeTranscriptInitialPosition, resolveTranscriptInitialPosition, shouldApplyTranscriptInitialPosition, transcriptInitialPositionReadiness, transcriptInitialPositionToken } from "./initial-position.js";
@@ -1,5 +1,14 @@
1
1
  /**
2
- * Human-readable relative time: "3m ago", "2h ago", "4d ago", "Jan 12".
2
+ * Is this a real recorded time? A missing, unparseable, zero, epoch or Go zero-time value
3
+ * ("0001-01-01T00:00:00Z") is unknown: nothing may render it, and no "ago" math runs on it.
4
+ *
5
+ * @param {string | null | undefined} iso
6
+ * @returns {boolean}
7
+ */
8
+ export function isKnownTime(iso: string | null | undefined): boolean;
9
+ /**
10
+ * Human-readable relative time: "just now", "3m ago", "2h ago", "4d ago"; past a week it reads as
11
+ * a date ("oct 14", or "oct 14, 2025" in another year). An unknown time reads as nothing.
3
12
  *
4
13
  * @param {string} iso an ISO 8601 timestamp
5
14
  * @param {number} [now] reference "now" in epoch millis (defaults to `Date.now()`; pass explicitly for deterministic tests)
@@ -7,12 +16,28 @@
7
16
  */
8
17
  export function formatRelative(iso: string, now?: number): string;
9
18
  /**
10
- * A duration expressed in minutes → "1h 16m" / "9m" / "42s".
19
+ * The one duration format: human and short. "12s", "4m 30s", "4m", "1h 12m", "1h"; under a
20
+ * second "<1s"; zero, negative or unknown reads as nothing, so a caller hides the figure.
21
+ *
22
+ * @param {number | null | undefined} seconds
23
+ * @returns {string}
24
+ */
25
+ export function formatDurationSeconds(seconds: number | null | undefined): string;
26
+ /**
27
+ * A duration in minutes, in the one format: 4.5 -> "4m 30s", 76 -> "1h 16m", 0 -> "".
28
+ *
29
+ * @param {number | null | undefined} mins
30
+ * @returns {string}
31
+ */
32
+ export function formatDurationMins(mins: number | null | undefined): string;
33
+ /**
34
+ * A duration in milliseconds: a tool call reads "820ms" or "1.4s" while short, then the one
35
+ * format ("1m 15s"); zero or unknown reads as nothing.
11
36
  *
12
- * @param {number | undefined} mins
37
+ * @param {number | null | undefined} ms
13
38
  * @returns {string}
14
39
  */
15
- export function formatDurationMins(mins: number | undefined): string;
40
+ export function formatDurationMs(ms: number | null | undefined): string;
16
41
  /**
17
42
  * "Jan 12, 4:23 PM" — long datetime for tooltips.
18
43
  *
@@ -1,5 +1,20 @@
1
+ /**
2
+ * The prompt without a harness's <user_query> wrapper: the user's own text, untouched otherwise.
3
+ * @param {string | undefined} text
4
+ * @returns {string}
5
+ */
6
+ export function unwrapUserQuery(text: string | undefined): string;
7
+ /**
8
+ * A stored session title, shown as written: the harness's <user_query> wrapper dropped and the
9
+ * whitespace collapsed, but every word, its case, its dots and an existing trailing "…" kept. For a
10
+ * title, never `summarizePrompt`, which cuts at the first sentence and recases.
11
+ * @param {string | undefined} text
12
+ * @returns {string}
13
+ */
14
+ export function cleanSessionTitle(text: string | undefined): string;
1
15
  /**
2
16
  * Produce a short, human-readable summary of a raw prompt. Heuristic, in order:
17
+ * 0. Drop a harness's <user_query> wrapper (cleanSessionTitle's rule).
3
18
  * 1. Strip leading <system-reminder> blocks and leading fenced code blocks.
4
19
  * 2. Pull out a <command-name> (e.g. `/mcp`) if present, keep following prose.
5
20
  * 3. Strip remaining XML-ish tags, collapse whitespace, take the first sentence.
@@ -308,9 +308,15 @@ export type TurnVM = {
308
308
  */
309
309
  label: string;
310
310
  /**
311
- * markdown body (thinking already extracted)
311
+ * markdown body (thinking already extracted), as recorded
312
312
  */
313
313
  content: string;
314
+ /**
315
+ * the text the turn shows instead of `content`, present only
316
+ * when they differ (a cursor prompt's `<user_query>` wrapper
317
+ * removed); views render `displayContent ?? content`
318
+ */
319
+ displayContent?: string;
314
320
  /**
315
321
  * subagent nesting depth (0 = top level)
316
322
  */
@@ -463,6 +469,10 @@ export type TaskGroupVM = {
463
469
  * user content for the task (case preserved)
464
470
  */
465
471
  prompt: string;
472
+ /**
473
+ * the prompt as its turn shows it, present only when it differs
474
+ */
475
+ displayPrompt?: string;
466
476
  /**
467
477
  * turns belonging to this task
468
478
  */