modelstat 0.12.0 → 0.13.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/dist/cli.mjs CHANGED
@@ -5153,7 +5153,12 @@ var init_schemas = __esm({
5153
5153
  correction_count: external_exports.number().int().nonnegative().default(0),
5154
5154
  /** 0-1 frustration estimate (re-prompt density + negative mood tags). */
5155
5155
  frustration: external_exports.number().min(0).max(1).default(0)
5156
- }).optional()
5156
+ }).optional(),
5157
+ /** Distilled "what the developer asked for / how they directed the AI" — from
5158
+ * their MESSAGES ONLY (not the assistant's actions), redacted, ≤512. The
5159
+ * source Insights' rule + skill detectors mine, distinct from the outcome
5160
+ * `abstract`. Optional; absent from daemons that predate it. */
5161
+ user_intent: external_exports.string().max(512).optional()
5157
5162
  });
5158
5163
  ToolAction = external_exports.object({
5159
5164
  /** Where it ran: `shell`, `mcp`, `builtin`, `browser`. (tier 0) */
@@ -35879,6 +35884,7 @@ Write a \u2264${ABSTRACT_OUTPUT_MAX_CHARS}-char summary (1-2 sentences) naming e
35879
35884
  } catch {
35880
35885
  segmentEmbedding = void 0;
35881
35886
  }
35887
+ const userIntent = await summariseUserIntent(slice, adapters2);
35882
35888
  const sourceEventIds = slice.map((e) => e.source_event_id);
35883
35889
  const id = segmentId(sessionId, startedAtMs, endedAtMs, sourceEventIds);
35884
35890
  return {
@@ -35901,9 +35907,40 @@ Write a \u2264${ABSTRACT_OUTPUT_MAX_CHARS}-char summary (1-2 sentences) naming e
35901
35907
  redaction: redacted.counts,
35902
35908
  source_event_ids: sourceEventIds,
35903
35909
  abstract_embedding: segmentEmbedding && segmentEmbedding.length === 384 ? segmentEmbedding : void 0,
35904
- behavior
35910
+ behavior,
35911
+ user_intent: userIntent
35905
35912
  };
35906
35913
  }
35914
+ async function summariseUserIntent(slice, adapters2) {
35915
+ const userExcerpts = slice.filter((e) => e.kind === "user_message").map((e) => e.content_excerpt?.replace(/\s+/g, " ").trim()).filter((x) => !!x && x.length > 0);
35916
+ if (userExcerpts.length === 0) return void 0;
35917
+ const sample = userExcerpts.length <= 6 ? userExcerpts : [...userExcerpts.slice(0, 4), ...userExcerpts.slice(-2)];
35918
+ const block = sample.map((e, i) => ` [msg ${i + 1}] "${e.slice(0, 240)}"`).join("\n");
35919
+ try {
35920
+ const raw = await adapters2.summarize({
35921
+ prompt: `The developer's own messages to an AI coding assistant (already redacted of PII and secrets):
35922
+ ${block}
35923
+
35924
+ In \u2264${USER_INTENT_MAX_CHARS} chars, summarise WHAT THE DEVELOPER ASKED FOR or DIRECTED \u2014 their goal or task in their own framing, AND any standing preferences / directives / conventions they expressed (e.g. "always be thorough", "ship fast", a naming or workflow convention). Focus on the DEVELOPER'S intent and voice, NOT what the assistant did. Reply with only the summary.`,
35925
+ maxTokens: USER_INTENT_MAX_TOKENS,
35926
+ excerpts: sample,
35927
+ facts: ""
35928
+ });
35929
+ if (!raw || !raw.trim()) return void 0;
35930
+ const regexPass = redact(raw);
35931
+ let text = regexPass.text;
35932
+ if (adapters2.redact) {
35933
+ try {
35934
+ text = (await adapters2.redact(regexPass.text)).text;
35935
+ } catch {
35936
+ }
35937
+ }
35938
+ const trimmed = text.trim().slice(0, USER_INTENT_MAX_CHARS);
35939
+ return trimmed.length > 0 ? trimmed : void 0;
35940
+ } catch {
35941
+ return void 0;
35942
+ }
35943
+ }
35907
35944
  function computeBehavior(slice, cognition) {
35908
35945
  let userTurns = 0;
35909
35946
  let correctionCount = 0;
@@ -35983,7 +36020,7 @@ function inferEnvironment(branch) {
35983
36020
  if (b === "dev" || b === "develop" || b.startsWith("dev/")) return "Dev";
35984
36021
  return null;
35985
36022
  }
35986
- var SEGMENT_TIME_GAP_MS, SEGMENT_TOPIC_THRESHOLD, SEGMENT_MAX_TURNS, SEGMENT_MAX_DURATION_MS, SEGMENT_MAX_CONTENT_CHARS, ABSTRACT_MAX_CHARS, FRUSTRATION_MARKERS;
36023
+ var SEGMENT_TIME_GAP_MS, SEGMENT_TOPIC_THRESHOLD, SEGMENT_MAX_TURNS, SEGMENT_MAX_DURATION_MS, SEGMENT_MAX_CONTENT_CHARS, ABSTRACT_MAX_CHARS, USER_INTENT_MAX_CHARS, USER_INTENT_MAX_TOKENS, FRUSTRATION_MARKERS;
35987
36024
  var init_pipeline = __esm({
35988
36025
  "../../packages/daemon-core/src/pipeline/index.ts"() {
35989
36026
  "use strict";
@@ -36005,6 +36042,8 @@ var init_pipeline = __esm({
36005
36042
  SEGMENT_MAX_DURATION_MS = 30 * 6e4;
36006
36043
  SEGMENT_MAX_CONTENT_CHARS = 12e3;
36007
36044
  ABSTRACT_MAX_CHARS = 512;
36045
+ USER_INTENT_MAX_CHARS = 240;
36046
+ USER_INTENT_MAX_TOKENS = 120;
36008
36047
  FRUSTRATION_MARKERS = [
36009
36048
  "frustrat",
36010
36049
  "annoy",
@@ -37319,7 +37358,7 @@ var init_scan = __esm({
37319
37358
  init_api();
37320
37359
  init_config2();
37321
37360
  init_pipeline2();
37322
- DAEMON_VERSION = true ? "daemon-0.12.0" : "daemon-dev";
37361
+ DAEMON_VERSION = true ? "daemon-0.13.0" : "daemon-dev";
37323
37362
  BATCH_MAX_EVENTS = INGEST_BATCH_MAX_EVENTS;
37324
37363
  BATCH_MAX_TOOL_CALLS = 2e4;
37325
37364
  BATCH_BUFFER_HARD_CAP = BATCH_MAX_EVENTS * 2;
@@ -37886,7 +37925,7 @@ var PROCESSING_VERSION;
37886
37925
  var init_processing_version = __esm({
37887
37926
  "src/processing-version.ts"() {
37888
37927
  "use strict";
37889
- PROCESSING_VERSION = 10;
37928
+ PROCESSING_VERSION = 11;
37890
37929
  }
37891
37930
  });
37892
37931
 
@@ -40266,7 +40305,7 @@ var init_daemon = __esm({
40266
40305
  init_scan();
40267
40306
  init_single_flight();
40268
40307
  init_update();
40269
- DAEMON_VERSION2 = true ? "daemon-0.12.0" : "daemon-dev";
40308
+ DAEMON_VERSION2 = true ? "daemon-0.13.0" : "daemon-dev";
40270
40309
  HEARTBEAT_INTERVAL_MS = 1e4;
40271
40310
  SCAN_INTERVAL_MS = 5 * 60 * 1e3;
40272
40311
  DISCOVERY_INTERVAL_MS = 6e4;
@@ -40898,7 +40937,7 @@ function tryOpenBrowser(url) {
40898
40937
  return false;
40899
40938
  }
40900
40939
  }
40901
- var DAEMON_VERSION3 = true ? "daemon-0.12.0" : "daemon-dev";
40940
+ var DAEMON_VERSION3 = true ? "daemon-0.13.0" : "daemon-dev";
40902
40941
  function osFamily() {
40903
40942
  const p = platform6();
40904
40943
  if (p === "darwin") return "macos";