incremnt 0.8.1 → 0.8.3

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.
@@ -29,25 +29,25 @@ export function scoreComponentPhrase(name) {
29
29
  return SCORE_COMPONENT_PHRASES[String(name).toLowerCase()] ?? 'another training area';
30
30
  }
31
31
 
32
- // True when the user's question is actually about the Increment Score. Only then
33
- // should the prelude hand the model the bare numeric headline otherwise the
34
- // model parrots "your score is 92/100" into answers about sessions, volume, or
35
- // plans where it was never asked for.
32
+ // True when the user's question is actually about the Increment Score. Defensive
33
+ // Ask profiles still use this to avoid score dashboarding in narrow decisions;
34
+ // expansive Ask profiles intentionally get the headline for richer coaching.
36
35
  export function isScoreQuestion(question) {
37
36
  return /\b(?:increment\s+)?score\b/i.test(String(question ?? ''));
38
37
  }
39
38
 
40
- export function formatIncrementScorePrelude(snapshots, { question = '' } = {}) {
39
+ export function formatIncrementScorePrelude(snapshots, { question = '', responseProfile = 'defensive' } = {}) {
41
40
  if (!Array.isArray(snapshots) || snapshots.length === 0) return null;
42
41
  const latest = snapshots[0];
43
42
  if (latest == null || typeof latest.score !== 'number') return null;
44
43
 
44
+ const allowsHeadline = responseProfile === 'expansive' || isScoreQuestion(question);
45
45
  const lines = [
46
- '[Increment Score — context only. Speak in training reality (recovery, fatigue, consistency, density). Never recite component values, sub-scores, decimals, or daily score numbers. Do not volunteer the overall score number unless the user asked about the score.]'
46
+ allowsHeadline
47
+ ? '[Increment Score — context only. The rounded score headline and drivers may be used in rich Ask Coach answers. Never recite component values, sub-scores, decimals, or daily score numbers.]'
48
+ : '[Increment Score — context only. Speak in training reality (recovery, fatigue, consistency, density). Never recite component values, sub-scores, decimals, or daily score numbers. Do not volunteer the overall score number unless the user asked about the score.]'
47
49
  ];
48
- // Hand over the numeric headline only when the question is score-related; the
49
- // weakest/strongest area and direction below are always safe to provide.
50
- if (isScoreQuestion(question)) {
50
+ if (allowsHeadline) {
51
51
  lines.push(`- Current: ${Math.round(latest.score)}/100`);
52
52
  }
53
53
 
@@ -90,18 +90,21 @@ export function formatIncrementScorePrelude(snapshots, { question = '' } = {}) {
90
90
  const negatives = driverLabels(latest.topNegativeDrivers);
91
91
  if (negatives) lines.push(`- Holding the score back: ${negatives}`);
92
92
 
93
- // Direction words only — no delta number, no daily-score list.
93
+ // Direction words only — no delta number, no daily-score list. Scores are only
94
+ // comparable within one formula version; a formula change makes the direction a
95
+ // cross-ruler lie ("+36 / 77% up"), so suppress the steer across it.
96
+ const latestFormulaVersion = latest.formulaVersion ?? null;
94
97
  if (snapshots.length > 1) {
95
98
  const prior = snapshots[1];
96
- if (typeof prior?.score === 'number') {
99
+ if (typeof prior?.score === 'number' && (prior.formulaVersion ?? null) === latestFormulaVersion) {
97
100
  const delta = latest.score - prior.score;
98
101
  const dir = delta > 0 ? 'up' : delta < 0 ? 'down' : 'flat';
99
102
  lines.push(`- Day-over-day: ${dir}`);
100
103
  }
101
104
  const recent = snapshots
102
105
  .slice(0, 7)
103
- .map((s) => (typeof s?.score === 'number' ? s.score : null))
104
- .filter((s) => s != null);
106
+ .filter((s) => typeof s?.score === 'number' && (s.formulaVersion ?? null) === latestFormulaVersion)
107
+ .map((s) => s.score);
105
108
  if (recent.length >= 3) {
106
109
  const span = recent[0] - recent[recent.length - 1];
107
110
  const trend = span > 2 ? 'rising' : span < -2 ? 'falling' : 'steady';