instar 0.28.35 → 0.28.42
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/dashboard/index.html +40 -30
- package/dist/commands/server.d.ts.map +1 -1
- package/dist/commands/server.js +105 -46
- package/dist/commands/server.js.map +1 -1
- package/dist/core/CoherenceGate.d.ts +7 -0
- package/dist/core/CoherenceGate.d.ts.map +1 -1
- package/dist/core/CoherenceGate.js +7 -6
- package/dist/core/CoherenceGate.js.map +1 -1
- package/dist/core/CoherenceReviewer.d.ts +20 -5
- package/dist/core/CoherenceReviewer.d.ts.map +1 -1
- package/dist/core/CoherenceReviewer.js +36 -6
- package/dist/core/CoherenceReviewer.js.map +1 -1
- package/dist/core/OutboundDedupGate.d.ts +56 -0
- package/dist/core/OutboundDedupGate.d.ts.map +1 -0
- package/dist/core/OutboundDedupGate.js +90 -0
- package/dist/core/OutboundDedupGate.js.map +1 -0
- package/dist/core/PostUpdateMigrator.d.ts +0 -14
- package/dist/core/PostUpdateMigrator.d.ts.map +1 -1
- package/dist/core/PostUpdateMigrator.js +2 -123
- package/dist/core/PostUpdateMigrator.js.map +1 -1
- package/dist/core/SessionManager.d.ts +9 -0
- package/dist/core/SessionManager.d.ts.map +1 -1
- package/dist/core/SessionManager.js +18 -0
- package/dist/core/SessionManager.js.map +1 -1
- package/dist/core/UpdateChecker.d.ts.map +1 -1
- package/dist/core/UpdateChecker.js +6 -2
- package/dist/core/UpdateChecker.js.map +1 -1
- package/dist/core/junk-payload.d.ts +14 -0
- package/dist/core/junk-payload.d.ts.map +1 -0
- package/dist/core/junk-payload.js +32 -0
- package/dist/core/junk-payload.js.map +1 -0
- package/dist/monitoring/CompactionSentinel.d.ts +143 -0
- package/dist/monitoring/CompactionSentinel.d.ts.map +1 -0
- package/dist/monitoring/CompactionSentinel.js +262 -0
- package/dist/monitoring/CompactionSentinel.js.map +1 -0
- package/dist/monitoring/PresenceProxy.d.ts +0 -40
- package/dist/monitoring/PresenceProxy.d.ts.map +1 -1
- package/dist/monitoring/PresenceProxy.js +4 -156
- package/dist/monitoring/PresenceProxy.js.map +1 -1
- package/dist/monitoring/PromptGate.d.ts.map +1 -1
- package/dist/monitoring/PromptGate.js +0 -75
- package/dist/monitoring/PromptGate.js.map +1 -1
- package/dist/threadline/adapters/RESTServer.d.ts +7 -1
- package/dist/threadline/adapters/RESTServer.d.ts.map +1 -1
- package/dist/threadline/adapters/RESTServer.js +62 -1
- package/dist/threadline/adapters/RESTServer.js.map +1 -1
- package/dist/threadline/relay/OfflineQueue.js +1 -1
- package/dist/threadline/relay/OfflineQueue.js.map +1 -1
- package/package.json +1 -1
- package/scripts/check-upgrade-guide.js +9 -115
- package/scripts/collect-metrics.py +25 -120
- package/scripts/upgrade-guide-validator.mjs +221 -0
- package/src/data/builtin-manifest.json +18 -18
- package/upgrades/0.28.36.md +40 -0
- package/upgrades/0.28.37.md +69 -0
- package/upgrades/0.28.38.md +41 -0
- package/upgrades/0.28.39.md +29 -0
- package/upgrades/0.28.40.md +32 -0
- package/upgrades/0.28.42.md +25 -0
- package/upgrades/NEXT.md +18 -0
- package/upgrades/0.28.10.md +0 -19
- package/upgrades/0.28.11.md +0 -19
- package/upgrades/0.28.13.md +0 -11
- package/upgrades/0.28.15.md +0 -11
- package/upgrades/0.28.18.md +0 -12
- package/upgrades/0.28.20.md +0 -19
- package/upgrades/0.28.21.md +0 -23
- package/upgrades/0.28.22.md +0 -23
- package/upgrades/0.28.23.md +0 -19
- package/upgrades/0.28.24.md +0 -18
- package/upgrades/0.28.25.md +0 -21
- package/upgrades/0.28.26.md +0 -20
- package/upgrades/0.28.27.md +0 -20
- package/upgrades/0.28.28.md +0 -20
- package/upgrades/0.28.30.md +0 -25
- package/upgrades/0.28.31.md +0 -38
- package/upgrades/0.28.32.md +0 -22
- package/upgrades/0.28.33.md +0 -22
- package/upgrades/0.28.35.md +0 -37
- package/upgrades/0.28.5.md +0 -17
- package/upgrades/0.28.7.md +0 -24
- package/upgrades/0.28.8.md +0 -21
|
@@ -31,6 +31,12 @@
|
|
|
31
31
|
import fs from 'node:fs';
|
|
32
32
|
import path from 'node:path';
|
|
33
33
|
import { fileURLToPath } from 'node:url';
|
|
34
|
+
import {
|
|
35
|
+
REQUIRED_SECTIONS,
|
|
36
|
+
NEXT_TEMPLATE,
|
|
37
|
+
validateGuideContent,
|
|
38
|
+
parseBumpType,
|
|
39
|
+
} from './upgrade-guide-validator.mjs';
|
|
34
40
|
|
|
35
41
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
36
42
|
const ROOT = path.resolve(__dirname, '..');
|
|
@@ -42,125 +48,13 @@ const nextPath = path.join(ROOT, 'upgrades', 'NEXT.md');
|
|
|
42
48
|
const guideExists = fs.existsSync(guidePath);
|
|
43
49
|
const nextExists = fs.existsSync(nextPath);
|
|
44
50
|
|
|
45
|
-
// Required sections for a well-formed guide
|
|
46
|
-
const REQUIRED_SECTIONS = [
|
|
47
|
-
'## What Changed',
|
|
48
|
-
'## What to Tell Your User',
|
|
49
|
-
'## Summary of New Capabilities',
|
|
50
|
-
];
|
|
51
|
-
|
|
52
|
-
const MIN_LENGTH = 200;
|
|
53
|
-
|
|
54
|
-
// Template for a fresh NEXT.md after finalization
|
|
55
|
-
const NEXT_TEMPLATE = `# Upgrade Guide — vNEXT
|
|
56
|
-
|
|
57
|
-
<!-- bump: patch -->
|
|
58
|
-
<!-- Valid values: patch, minor, major -->
|
|
59
|
-
<!-- patch = bug fixes, refactors, test additions, doc updates -->
|
|
60
|
-
<!-- minor = new features, new APIs, new capabilities (backwards-compatible) -->
|
|
61
|
-
<!-- major = breaking changes to existing APIs or behavior -->
|
|
62
|
-
|
|
63
|
-
## What Changed
|
|
64
|
-
|
|
65
|
-
<!-- Describe what changed technically. What new features, APIs, behavioral changes? -->
|
|
66
|
-
<!-- Write this for the AGENT — they need to understand the system deeply. -->
|
|
67
|
-
|
|
68
|
-
## What to Tell Your User
|
|
69
|
-
|
|
70
|
-
<!-- Write talking points the agent should relay to their user. -->
|
|
71
|
-
<!-- This should be warm, conversational, user-facing — not a changelog. -->
|
|
72
|
-
<!-- Focus on what THEY can now do, not internal plumbing. -->
|
|
73
|
-
<!-- -->
|
|
74
|
-
<!-- PROHIBITED in this section (will fail validation): -->
|
|
75
|
-
<!-- camelCase config keys: silentReject, maxRetries, telegramNotify -->
|
|
76
|
-
<!-- Inline code backtick references like silentReject: false -->
|
|
77
|
-
<!-- Fenced code blocks -->
|
|
78
|
-
<!-- Instructions to edit files or run commands -->
|
|
79
|
-
<!-- -->
|
|
80
|
-
<!-- CORRECT style: "I can turn that on for you" not "set X to false" -->
|
|
81
|
-
<!-- The agent relays this to their user — keep it human. -->
|
|
82
|
-
|
|
83
|
-
- **[Feature name]**: "[Brief, friendly description of what this means for the user]"
|
|
84
|
-
|
|
85
|
-
## Summary of New Capabilities
|
|
86
|
-
|
|
87
|
-
| Capability | How to Use |
|
|
88
|
-
|-----------|-----------|
|
|
89
|
-
| [Capability] | [Endpoint, command, or "automatic"] |
|
|
90
|
-
`;
|
|
91
|
-
|
|
92
51
|
/**
|
|
93
|
-
* Validate a guide file
|
|
52
|
+
* Validate a guide file. Thin wrapper around validateGuideContent that handles
|
|
53
|
+
* the file read.
|
|
94
54
|
*/
|
|
95
55
|
function validateGuide(filePath) {
|
|
96
56
|
const content = fs.readFileSync(filePath, 'utf-8');
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
for (const section of REQUIRED_SECTIONS) {
|
|
100
|
-
if (!content.includes(section)) {
|
|
101
|
-
issues.push(`missing "${section}" section`);
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
if (content.length < MIN_LENGTH) {
|
|
106
|
-
issues.push(`guide is too short (${content.length} chars, minimum ${MIN_LENGTH}) — probably incomplete`);
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
// Check for template placeholders that were never filled in
|
|
110
|
-
if (content.includes('<!-- Describe what changed')) {
|
|
111
|
-
issues.push(`"What Changed" section still contains template placeholder — fill it in`);
|
|
112
|
-
}
|
|
113
|
-
if (content.includes('[Feature name]') || content.includes('[Brief, friendly description')) {
|
|
114
|
-
issues.push(`"What to Tell Your User" section still contains template placeholder — fill it in`);
|
|
115
|
-
}
|
|
116
|
-
if (content.includes('[Capability]') && content.includes('[Endpoint, command')) {
|
|
117
|
-
issues.push(`"Summary of New Capabilities" section still contains template placeholder — fill it in`);
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
// Validate "What to Tell Your User" section for technical leakage.
|
|
121
|
-
// This section is relayed verbatim to users — it must be conversational, not a config reference.
|
|
122
|
-
const userSectionMatch = content.match(/## What to Tell Your User([\s\S]*?)(?:##|$)/);
|
|
123
|
-
if (userSectionMatch) {
|
|
124
|
-
const userSection = userSectionMatch[1];
|
|
125
|
-
|
|
126
|
-
// Detect camelCase config key references (e.g. silentReject, maxRetries, telegramNotify)
|
|
127
|
-
const camelCaseConfigKey = /\b[a-z]+[A-Z][a-zA-Z]+\s*(?::|=)/.test(userSection);
|
|
128
|
-
if (camelCaseConfigKey) {
|
|
129
|
-
issues.push(
|
|
130
|
-
`"What to Tell Your User" contains a camelCase config key reference (e.g. "silentReject: false"). ` +
|
|
131
|
-
`Users should never be told to edit config directly. ` +
|
|
132
|
-
`Rephrase conversationally: "I can turn that on for you" not "set silentReject: false".`
|
|
133
|
-
);
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
// Detect inline code blocks — config syntax, CLI commands, file paths
|
|
137
|
-
const hasInlineCode = /`[^`]+`/.test(userSection);
|
|
138
|
-
if (hasInlineCode) {
|
|
139
|
-
issues.push(
|
|
140
|
-
`"What to Tell Your User" contains inline code (\`...\`). ` +
|
|
141
|
-
`Remove code formatting — user-facing language should be plain and conversational.`
|
|
142
|
-
);
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
// Detect fenced code blocks
|
|
146
|
-
if (/```/.test(userSection)) {
|
|
147
|
-
issues.push(
|
|
148
|
-
`"What to Tell Your User" contains a fenced code block. ` +
|
|
149
|
-
`This section is for user-facing narrative — move technical examples to "What Changed".`
|
|
150
|
-
);
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
return issues;
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
/**
|
|
158
|
-
* Parse the declared bump type from a guide's <!-- bump: TYPE --> comment.
|
|
159
|
-
* Returns 'patch' | 'minor' | 'major' | null.
|
|
160
|
-
*/
|
|
161
|
-
function parseBumpType(content) {
|
|
162
|
-
const match = /<!--\s*bump:\s*(patch|minor|major)\s*-->/.exec(content);
|
|
163
|
-
return match ? match[1] : null;
|
|
57
|
+
return validateGuideContent(content);
|
|
164
58
|
}
|
|
165
59
|
|
|
166
60
|
/**
|
|
@@ -123,76 +123,37 @@ def fetch_github_metrics():
|
|
|
123
123
|
return metrics
|
|
124
124
|
|
|
125
125
|
|
|
126
|
-
def compute_trends(
|
|
127
|
-
"""Compare current metrics to
|
|
128
|
-
|
|
129
|
-
Returns dict with:
|
|
130
|
-
- alerts: list of significant changes detected
|
|
131
|
-
- baseline_npm_day: 7-day rolling median (from prior days only)
|
|
132
|
-
- comparison: raw comparison data
|
|
133
|
-
"""
|
|
126
|
+
def compute_trends(state_dir):
|
|
127
|
+
"""Compare current metrics to previous snapshots for trend detection."""
|
|
134
128
|
history_file = Path(state_dir) / "telemetry.jsonl"
|
|
135
129
|
if not history_file.exists():
|
|
136
|
-
return
|
|
137
|
-
|
|
138
|
-
# Get today's date
|
|
139
|
-
today_str = current_snapshot.get("timestamp", "").split("T")[0]
|
|
130
|
+
return None
|
|
140
131
|
|
|
141
|
-
# Read
|
|
132
|
+
# Read last 7 entries
|
|
142
133
|
lines = history_file.read_text().strip().split("\n")
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
for line in lines:
|
|
134
|
+
recent = []
|
|
135
|
+
for line in lines[-7:]:
|
|
146
136
|
try:
|
|
147
|
-
|
|
148
|
-
snap_date = snap.get("timestamp", "").split("T")[0]
|
|
149
|
-
npm_day = snap.get("npm", {}).get("last_day")
|
|
150
|
-
if npm_day is not None:
|
|
151
|
-
# Keep the latest snapshot for each date
|
|
152
|
-
daily_values[snap_date] = npm_day
|
|
137
|
+
recent.append(json.loads(line))
|
|
153
138
|
except json.JSONDecodeError:
|
|
154
139
|
continue
|
|
155
140
|
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
if
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
if current_npm_day is not None and baseline > 0:
|
|
174
|
-
# Alert if >20% deviation from baseline
|
|
175
|
-
pct_change = ((current_npm_day - baseline) / baseline) * 100
|
|
176
|
-
if abs(pct_change) > 20:
|
|
177
|
-
direction = "📈" if pct_change > 0 else "📉"
|
|
178
|
-
alerts.append({
|
|
179
|
-
"type": "npm_anomaly",
|
|
180
|
-
"message": f"{direction} npm downloads {abs(pct_change):.0f}% from baseline ({current_npm_day} vs {baseline} median)",
|
|
181
|
-
"current": current_npm_day,
|
|
182
|
-
"baseline": baseline,
|
|
183
|
-
"pct_change": pct_change
|
|
184
|
-
})
|
|
185
|
-
|
|
186
|
-
return {
|
|
187
|
-
"alerts": alerts,
|
|
188
|
-
"baseline_npm_day": baseline,
|
|
189
|
-
"comparison": {
|
|
190
|
-
"current": current_npm_day,
|
|
191
|
-
"baseline": baseline,
|
|
192
|
-
"history_count": len(sorted_values),
|
|
193
|
-
"prior_days": len(prior_days)
|
|
194
|
-
}
|
|
195
|
-
}
|
|
141
|
+
if len(recent) < 2:
|
|
142
|
+
return None
|
|
143
|
+
|
|
144
|
+
prev = recent[-2] if len(recent) >= 2 else None
|
|
145
|
+
week_ago = recent[0] if len(recent) >= 7 else recent[0]
|
|
146
|
+
|
|
147
|
+
trends = {}
|
|
148
|
+
if prev:
|
|
149
|
+
prev_npm = prev.get("npm", {}).get("last_day")
|
|
150
|
+
trends["npm_day_prev"] = prev_npm
|
|
151
|
+
|
|
152
|
+
if week_ago:
|
|
153
|
+
week_npm = week_ago.get("npm", {}).get("last_week")
|
|
154
|
+
trends["npm_week_prev"] = week_npm
|
|
155
|
+
|
|
156
|
+
return trends
|
|
196
157
|
|
|
197
158
|
|
|
198
159
|
def save_snapshot(snapshot, state_dir):
|
|
@@ -211,49 +172,6 @@ def save_snapshot(snapshot, state_dir):
|
|
|
211
172
|
json.dump(snapshot, f, indent=2)
|
|
212
173
|
|
|
213
174
|
|
|
214
|
-
def send_telegram_notification(alerts, snapshot):
|
|
215
|
-
"""Send Telegram notification if significant alerts exist."""
|
|
216
|
-
if not alerts:
|
|
217
|
-
return
|
|
218
|
-
|
|
219
|
-
# Build message
|
|
220
|
-
ts = snapshot.get("timestamp", "").split("T")[0] # Date only
|
|
221
|
-
lines = [f"🔔 Instar Metrics Alert ({ts})"]
|
|
222
|
-
|
|
223
|
-
for alert in alerts:
|
|
224
|
-
lines.append(f"\n{alert['message']}")
|
|
225
|
-
|
|
226
|
-
message = "\n".join(lines)
|
|
227
|
-
|
|
228
|
-
# Try multiple locations for the telegram-reply script
|
|
229
|
-
possible_paths = [
|
|
230
|
-
os.path.expanduser("~/.dawn-server/scripts/telegram-reply.py"),
|
|
231
|
-
os.path.expanduser("~/.claude/scripts/telegram-reply.py"),
|
|
232
|
-
"./.claude/scripts/telegram-reply.py",
|
|
233
|
-
]
|
|
234
|
-
|
|
235
|
-
script_path = None
|
|
236
|
-
for path in possible_paths:
|
|
237
|
-
if os.path.exists(path):
|
|
238
|
-
script_path = path
|
|
239
|
-
break
|
|
240
|
-
|
|
241
|
-
if script_path:
|
|
242
|
-
# Topic ID 2278 is the instar metrics topic
|
|
243
|
-
cmd = [
|
|
244
|
-
"python3", script_path, "2278", message
|
|
245
|
-
]
|
|
246
|
-
try:
|
|
247
|
-
result = subprocess.run(cmd, capture_output=True, text=True, timeout=10)
|
|
248
|
-
print(f"[Telegram] Sent alert notification to topic 2278")
|
|
249
|
-
if result.returncode != 0 and result.stderr:
|
|
250
|
-
print(f"[Telegram] Warning: {result.stderr}")
|
|
251
|
-
except Exception as e:
|
|
252
|
-
print(f"[Telegram] Failed to send notification: {e}")
|
|
253
|
-
else:
|
|
254
|
-
print(f"[Telegram] Script not found in any expected location (skipping notification)")
|
|
255
|
-
|
|
256
|
-
|
|
257
175
|
def format_summary(snapshot):
|
|
258
176
|
"""Format a human-readable summary."""
|
|
259
177
|
lines = []
|
|
@@ -311,30 +229,17 @@ def main():
|
|
|
311
229
|
# Collect
|
|
312
230
|
snapshot["npm"] = fetch_npm_downloads()
|
|
313
231
|
snapshot["github"] = fetch_github_metrics()
|
|
232
|
+
snapshot["trends"] = compute_trends(args.state_dir)
|
|
314
233
|
|
|
315
234
|
# Save
|
|
316
235
|
save_snapshot(snapshot, args.state_dir)
|
|
317
236
|
|
|
318
|
-
# Analyze trends and detect anomalies
|
|
319
|
-
trends_analysis = compute_trends(snapshot, args.state_dir)
|
|
320
|
-
snapshot["trends"] = trends_analysis
|
|
321
|
-
|
|
322
|
-
# Send Telegram notification if alerts detected
|
|
323
|
-
alerts = trends_analysis.get("alerts", [])
|
|
324
|
-
if alerts:
|
|
325
|
-
send_telegram_notification(alerts, snapshot)
|
|
326
|
-
|
|
327
237
|
# Output
|
|
328
238
|
if not args.quiet:
|
|
329
239
|
if args.json:
|
|
330
240
|
print(json.dumps(snapshot, indent=2))
|
|
331
241
|
else:
|
|
332
|
-
|
|
333
|
-
if alerts:
|
|
334
|
-
summary += "\n\n⚠️ Alerts:\n"
|
|
335
|
-
for alert in alerts:
|
|
336
|
-
summary += f" • {alert['message']}\n"
|
|
337
|
-
print(summary)
|
|
242
|
+
print(format_summary(snapshot))
|
|
338
243
|
|
|
339
244
|
return 0
|
|
340
245
|
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
// Pure validation logic for upgrade guides — no filesystem side effects.
|
|
2
|
+
// The CLI entry point (check-upgrade-guide.js) wraps this with I/O.
|
|
3
|
+
// Extracted for unit testability.
|
|
4
|
+
|
|
5
|
+
export const REQUIRED_SECTIONS = [
|
|
6
|
+
'## What Changed',
|
|
7
|
+
'## What to Tell Your User',
|
|
8
|
+
'## Summary of New Capabilities',
|
|
9
|
+
];
|
|
10
|
+
|
|
11
|
+
export const MIN_LENGTH = 200;
|
|
12
|
+
|
|
13
|
+
// Keywords that indicate the guide is claiming to fix a bug. When any of these
|
|
14
|
+
// appear inside "## What Changed", the Evidence section becomes mandatory.
|
|
15
|
+
// Limited to "What Changed" (not the whole doc) to reduce false positives from
|
|
16
|
+
// marketing language in "What to Tell Your User".
|
|
17
|
+
const FIX_PATTERNS = [
|
|
18
|
+
/\bfix(es|ed|ing)?\b/i,
|
|
19
|
+
/\bbug(fix)?\b/i,
|
|
20
|
+
/\bregression\b/i,
|
|
21
|
+
/\bresolves?\b/i,
|
|
22
|
+
/\bresolved\b/i,
|
|
23
|
+
/\bcrashes?\b/i,
|
|
24
|
+
/\bcrashed\b/i,
|
|
25
|
+
/\bcrashing\b/i,
|
|
26
|
+
/\bbroken\b/i,
|
|
27
|
+
/\bstall(s|ed|ing)?\b/i,
|
|
28
|
+
];
|
|
29
|
+
|
|
30
|
+
export const NEXT_TEMPLATE = `# Upgrade Guide — vNEXT
|
|
31
|
+
|
|
32
|
+
<!-- bump: patch -->
|
|
33
|
+
<!-- Valid values: patch, minor, major -->
|
|
34
|
+
<!-- patch = bug fixes, refactors, test additions, doc updates -->
|
|
35
|
+
<!-- minor = new features, new APIs, new capabilities (backwards-compatible) -->
|
|
36
|
+
<!-- major = breaking changes to existing APIs or behavior -->
|
|
37
|
+
|
|
38
|
+
## What Changed
|
|
39
|
+
|
|
40
|
+
<!-- Describe what changed technically. What new features, APIs, behavioral changes? -->
|
|
41
|
+
<!-- Write this for the AGENT — they need to understand the system deeply. -->
|
|
42
|
+
|
|
43
|
+
## What to Tell Your User
|
|
44
|
+
|
|
45
|
+
<!-- Write talking points the agent should relay to their user. -->
|
|
46
|
+
<!-- This should be warm, conversational, user-facing — not a changelog. -->
|
|
47
|
+
<!-- Focus on what THEY can now do, not internal plumbing. -->
|
|
48
|
+
<!-- -->
|
|
49
|
+
<!-- PROHIBITED in this section (will fail validation): -->
|
|
50
|
+
<!-- camelCase config keys: silentReject, maxRetries, telegramNotify -->
|
|
51
|
+
<!-- Inline code backtick references like silentReject: false -->
|
|
52
|
+
<!-- Fenced code blocks -->
|
|
53
|
+
<!-- Instructions to edit files or run commands -->
|
|
54
|
+
<!-- -->
|
|
55
|
+
<!-- CORRECT style: "I can turn that on for you" not "set X to false" -->
|
|
56
|
+
<!-- The agent relays this to their user — keep it human. -->
|
|
57
|
+
|
|
58
|
+
- **[Feature name]**: "[Brief, friendly description of what this means for the user]"
|
|
59
|
+
|
|
60
|
+
## Summary of New Capabilities
|
|
61
|
+
|
|
62
|
+
| Capability | How to Use |
|
|
63
|
+
|-----------|-----------|
|
|
64
|
+
| [Capability] | [Endpoint, command, or "automatic"] |
|
|
65
|
+
|
|
66
|
+
## Evidence
|
|
67
|
+
|
|
68
|
+
<!-- REQUIRED if this release claims to fix a bug. -->
|
|
69
|
+
<!-- Unit tests passing is NOT evidence. Provide ONE of: -->
|
|
70
|
+
<!-- (a) Reproduction steps + observed before/after on a live system. -->
|
|
71
|
+
<!-- Include log excerpts, observed command output, or behavior -->
|
|
72
|
+
<!-- description. Make it specific enough that a future reader can -->
|
|
73
|
+
<!-- re-run it and see the same thing. -->
|
|
74
|
+
<!-- (b) "Not reproducible in dev — [concrete reason]" if the failure -->
|
|
75
|
+
<!-- mode truly can't be exercised locally (race conditions, -->
|
|
76
|
+
<!-- event-driven paths requiring external signals, etc). -->
|
|
77
|
+
<!-- -->
|
|
78
|
+
<!-- If this release doesn't claim a bug fix (pure feature / refactor), -->
|
|
79
|
+
<!-- leave this section blank or delete it — it's only enforced when -->
|
|
80
|
+
<!-- "What Changed" describes a fix. -->
|
|
81
|
+
|
|
82
|
+
[Describe reproduction + verified fix, OR "Not reproducible in dev — [concrete reason]"]
|
|
83
|
+
`;
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Extract the content of a markdown H2 section by title. Returns the section
|
|
87
|
+
* body (between `## Title` and the next `## ` or end of file), or null if the
|
|
88
|
+
* section isn't present.
|
|
89
|
+
*/
|
|
90
|
+
export function extractSection(content, title) {
|
|
91
|
+
const pattern = new RegExp(`## ${title.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}([\\s\\S]*?)(?:\\n## |$)`);
|
|
92
|
+
const m = content.match(pattern);
|
|
93
|
+
return m ? m[1] : null;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Does the guide claim to fix a bug? Scans "## What Changed" for fix-indicating
|
|
98
|
+
* keywords. Returns true when any pattern matches.
|
|
99
|
+
*/
|
|
100
|
+
export function claimsFix(content) {
|
|
101
|
+
const section = extractSection(content, 'What Changed');
|
|
102
|
+
if (!section) return false;
|
|
103
|
+
return FIX_PATTERNS.some(p => p.test(section));
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Validate the Evidence section when a fix is claimed. Returns an array of
|
|
108
|
+
* issue strings (empty when valid).
|
|
109
|
+
*/
|
|
110
|
+
export function evidenceIssues(content) {
|
|
111
|
+
const issues = [];
|
|
112
|
+
const section = extractSection(content, 'Evidence');
|
|
113
|
+
if (section === null) {
|
|
114
|
+
issues.push(
|
|
115
|
+
'"What Changed" claims a bug fix, but the guide has no "## Evidence" section. ' +
|
|
116
|
+
'Add one with reproduction + observed before/after, or "Not reproducible in dev — [reason]". ' +
|
|
117
|
+
'Unit tests passing is not evidence.'
|
|
118
|
+
);
|
|
119
|
+
return issues;
|
|
120
|
+
}
|
|
121
|
+
// Strip HTML comments and trim
|
|
122
|
+
const stripped = section.replace(/<!--[\s\S]*?-->/g, '').trim();
|
|
123
|
+
if (!stripped) {
|
|
124
|
+
issues.push(
|
|
125
|
+
'"## Evidence" section is empty (only template comments). ' +
|
|
126
|
+
'Fill it in with reproduction + verified fix, or "Not reproducible in dev — [reason]".'
|
|
127
|
+
);
|
|
128
|
+
return issues;
|
|
129
|
+
}
|
|
130
|
+
// Reject obvious placeholder text
|
|
131
|
+
if (
|
|
132
|
+
/\[Describe reproduction/i.test(stripped) ||
|
|
133
|
+
/\[evidence goes here\]/i.test(stripped) ||
|
|
134
|
+
/TODO\b/.test(stripped) ||
|
|
135
|
+
/FIXME\b/.test(stripped)
|
|
136
|
+
) {
|
|
137
|
+
issues.push(
|
|
138
|
+
'"## Evidence" section still contains placeholder text. ' +
|
|
139
|
+
'Replace it with a real reproduction + verification, or explicit "Not reproducible in dev — [reason]".'
|
|
140
|
+
);
|
|
141
|
+
return issues;
|
|
142
|
+
}
|
|
143
|
+
// Require at least 80 chars of real content — any less and it can't describe
|
|
144
|
+
// a reproduction meaningfully.
|
|
145
|
+
if (stripped.length < 80) {
|
|
146
|
+
issues.push(
|
|
147
|
+
`"## Evidence" section is too short (${stripped.length} chars). ` +
|
|
148
|
+
'Include concrete reproduction + observed before/after, or "Not reproducible in dev" with a concrete reason.'
|
|
149
|
+
);
|
|
150
|
+
}
|
|
151
|
+
return issues;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* Full structural validation of a guide's content. Returns issue strings.
|
|
156
|
+
*/
|
|
157
|
+
export function validateGuideContent(content) {
|
|
158
|
+
const issues = [];
|
|
159
|
+
|
|
160
|
+
for (const section of REQUIRED_SECTIONS) {
|
|
161
|
+
if (!content.includes(section)) {
|
|
162
|
+
issues.push(`missing "${section}" section`);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
if (content.length < MIN_LENGTH) {
|
|
167
|
+
issues.push(`guide is too short (${content.length} chars, minimum ${MIN_LENGTH}) — probably incomplete`);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
// Template placeholders that were never filled in
|
|
171
|
+
if (content.includes('<!-- Describe what changed')) {
|
|
172
|
+
issues.push('"What Changed" section still contains template placeholder — fill it in');
|
|
173
|
+
}
|
|
174
|
+
if (content.includes('[Feature name]') || content.includes('[Brief, friendly description')) {
|
|
175
|
+
issues.push('"What to Tell Your User" section still contains template placeholder — fill it in');
|
|
176
|
+
}
|
|
177
|
+
if (content.includes('[Capability]') && content.includes('[Endpoint, command')) {
|
|
178
|
+
issues.push('"Summary of New Capabilities" section still contains template placeholder — fill it in');
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
// "What to Tell Your User" technical-leakage checks
|
|
182
|
+
const userSection = extractSection(content, 'What to Tell Your User');
|
|
183
|
+
if (userSection) {
|
|
184
|
+
const camelCaseConfigKey = /\b[a-z]+[A-Z][a-zA-Z]+\s*(?::|=)/.test(userSection);
|
|
185
|
+
if (camelCaseConfigKey) {
|
|
186
|
+
issues.push(
|
|
187
|
+
'"What to Tell Your User" contains a camelCase config key reference (e.g. "silentReject: false"). ' +
|
|
188
|
+
'Users should never be told to edit config directly. ' +
|
|
189
|
+
'Rephrase conversationally: "I can turn that on for you" not "set silentReject: false".'
|
|
190
|
+
);
|
|
191
|
+
}
|
|
192
|
+
if (/`[^`]+`/.test(userSection)) {
|
|
193
|
+
issues.push(
|
|
194
|
+
'"What to Tell Your User" contains inline code (`...`). ' +
|
|
195
|
+
'Remove code formatting — user-facing language should be plain and conversational.'
|
|
196
|
+
);
|
|
197
|
+
}
|
|
198
|
+
if (/```/.test(userSection)) {
|
|
199
|
+
issues.push(
|
|
200
|
+
'"What to Tell Your User" contains a fenced code block. ' +
|
|
201
|
+
'This section is for user-facing narrative — move technical examples to "What Changed".'
|
|
202
|
+
);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
// Evidence bar — when the guide claims a fix, require an Evidence section.
|
|
207
|
+
if (claimsFix(content)) {
|
|
208
|
+
issues.push(...evidenceIssues(content));
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
return issues;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* Parse the declared bump type from a guide's <!-- bump: TYPE --> comment.
|
|
216
|
+
* Returns 'patch' | 'minor' | 'major' | null.
|
|
217
|
+
*/
|
|
218
|
+
export function parseBumpType(content) {
|
|
219
|
+
const match = /<!--\s*bump:\s*(patch|minor|major)\s*-->/.exec(content);
|
|
220
|
+
return match ? match[1] : null;
|
|
221
|
+
}
|