@opengsd/gsd-core 1.16.0 → 1.17.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.
Files changed (58) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/.claude-plugin/plugin.json +1 -2
  3. package/.opencode/plugins/gsd-core.js +251 -1
  4. package/.opencode/plugins/gsd-statusline/tui.tsx +55 -0
  5. package/GEMINI.md +1 -1
  6. package/agents/gsd-debug-session-manager.compact.md +6 -0
  7. package/agents/gsd-debug-session-manager.md +6 -0
  8. package/bin/gsd-mcp-server.js +3 -1
  9. package/bin/install.js +361 -94
  10. package/gsd-core/bin/gsd-tools.cjs +17 -2
  11. package/gsd-core/bin/lib/adr-parser.cjs +37 -5
  12. package/gsd-core/bin/lib/capability-registry.cjs +132 -80
  13. package/gsd-core/bin/lib/capability-validator.cjs +2 -1
  14. package/gsd-core/bin/lib/capability-writer.cjs +2 -1
  15. package/gsd-core/bin/lib/commands.cjs +28 -8
  16. package/gsd-core/bin/lib/gate-context-drift.cjs +5 -4
  17. package/gsd-core/bin/lib/gate-ui-safety.cjs +2 -1
  18. package/gsd-core/bin/lib/graphify.cjs +3 -2
  19. package/gsd-core/bin/lib/init.cjs +32 -12
  20. package/gsd-core/bin/lib/install-engine.cjs +11 -0
  21. package/gsd-core/bin/lib/install-shadow-report.cjs +12 -0
  22. package/gsd-core/bin/lib/installer-migrations/011-opencode-mcp-no-prompts.cjs +99 -0
  23. package/gsd-core/bin/lib/installer-migrations.cjs +54 -1
  24. package/gsd-core/bin/lib/jsonc-edit.cjs +418 -0
  25. package/gsd-core/bin/lib/loop-host-contract.cjs +2 -1
  26. package/gsd-core/bin/lib/mcp-server.cjs +5 -1
  27. package/gsd-core/bin/lib/opencode-mcp-entry.cjs +39 -0
  28. package/gsd-core/bin/lib/opencode-version.cjs +486 -0
  29. package/gsd-core/bin/lib/phase.cjs +21 -0
  30. package/gsd-core/bin/lib/quick-batch-dispatch.cjs +2 -1
  31. package/gsd-core/bin/lib/runtime-artifact-conversion.cjs +95 -4
  32. package/gsd-core/bin/lib/runtime-hooks-surface.cjs +58 -3
  33. package/gsd-core/bin/lib/runtime-slash.cjs +13 -0
  34. package/gsd-core/bin/lib/smart-entry.cjs +92 -53
  35. package/gsd-core/bin/lib/state-transition.cjs +67 -9
  36. package/gsd-core/bin/lib/state.cjs +454 -66
  37. package/gsd-core/bin/lib/update-context.cjs +18 -1
  38. package/gsd-core/bin/lib/verification.cjs +107 -17
  39. package/gsd-core/workflows/code-review.md +16 -1
  40. package/gsd-core/workflows/execute-phase/steps/executor-isolation-dispatch.md +1 -1
  41. package/gsd-core/workflows/execute-phase.md +3 -1
  42. package/gsd-core/workflows/resume-project.md +14 -10
  43. package/hooks/dist/gsd-check-update.js +26 -20
  44. package/hooks/dist/gsd-context-monitor.js +14 -5
  45. package/hooks/dist/gsd-secret-read-guard.js +117 -1
  46. package/hooks/dist/gsd-statusline.js +321 -22
  47. package/hooks/gsd-check-update.js +26 -20
  48. package/hooks/gsd-context-monitor.js +14 -5
  49. package/hooks/gsd-secret-read-guard.js +117 -1
  50. package/hooks/gsd-statusline.js +321 -22
  51. package/package.json +1 -1
  52. package/scripts/gen-capability-registry.cjs +7 -1
  53. package/scripts/gen-loop-host-contract.cjs +4 -1
  54. package/scripts/lib/macos-conformance-tier.generated.cjs +4 -0
  55. package/scripts/lib/platform-conformance-tier.generated.cjs +10 -0
  56. package/scripts/mutation-matrix.cjs +3 -1
  57. package/scripts/release-tarball-smoke.cjs +14 -7
  58. package/vscode/package.json +1 -1
@@ -170,6 +170,303 @@ function readStateFileOrNull(statePath) {
170
170
  }
171
171
  }
172
172
 
173
+ /**
174
+ * The env vars Claude Code itself consults to switch auto-compaction off, and
175
+ * the values it accepts as true. Both are taken from the shipped binary's own
176
+ * resolution — `Boolean(truthy(DISABLE_COMPACT) || DISABLE_AUTO_COMPACT)`, and
177
+ * only when that is false does `autoCompactEnabled` decide — rather than
178
+ * guessed: an invented name reads as "not disabled" forever, which is exactly
179
+ * the defect this gate exists to close.
180
+ *
181
+ * The truthy set applies to both keys: in the binary (claude 2.1.292) the
182
+ * second operand is the env registry's `D.bool()` field, which runs the same
183
+ * `["1","true","yes","on"]` helper as `DISABLE_COMPACT`.
184
+ */
185
+ const AUTO_COMPACT_DISABLE_ENV_KEYS = ['DISABLE_AUTO_COMPACT', 'DISABLE_COMPACT'];
186
+ const AUTO_COMPACT_ENV_TRUTHY = ['1', 'true', 'yes', 'on'];
187
+
188
+ /**
189
+ * Is Claude Code's auto-compact switched off for this session? When it is,
190
+ * the auto-compact buffer is ordinary usable context, so the meter's 100% is
191
+ * the model window — otherwise the bar pins at 100% early and the last of
192
+ * the window is invisible.
193
+ *
194
+ * The sources and their precedence mirror Claude Code's own resolution —
195
+ * either env var wins over the setting, and only then does the setting decide:
196
+ * 1. env: DISABLE_AUTO_COMPACT, or DISABLE_COMPACT (which switches off
197
+ * manual `/compact` as well). Truthy is `1` / `true` / `yes` / `on`,
198
+ * trimmed and case-insensitive — Claude Code's own accepted set.
199
+ * 2. <dir>/.claude/settings.local.json, <dir>/.claude/settings.json
200
+ * 3. (CLAUDE_CONFIG_DIR || ~/.claude)/settings.local.json, settings.json
201
+ * reading the boolean `autoCompactEnabled`. Fail-soft: anything unreadable
202
+ * or absent means "not disabled" (current behaviour).
203
+ */
204
+ function isAutoCompactDisabled(dir, env = process.env) {
205
+ for (const key of AUTO_COMPACT_DISABLE_ENV_KEYS) {
206
+ const v = env[key];
207
+ if (typeof v === 'string' && AUTO_COMPACT_ENV_TRUTHY.includes(v.trim().toLowerCase())) return true;
208
+ }
209
+ return readClaudeSetting(dir, env, 'autoCompactEnabled', v => typeof v === 'boolean') === false;
210
+ }
211
+
212
+ /**
213
+ * The first value of `key` that `accept` takes, reading the Claude Code
214
+ * settings files highest precedence first:
215
+ * <dir>/.claude/settings.local.json, <dir>/.claude/settings.json,
216
+ * (CLAUDE_CONFIG_DIR || ~/.claude)/settings.local.json, settings.json.
217
+ * Fail-soft: an absent or unparseable file is skipped; nothing found is
218
+ * `undefined`.
219
+ */
220
+ function readClaudeSetting(dir, env, key, accept) {
221
+ // Lazy: stop at the first file that answers, so a lower file is never read.
222
+ for (const file of claudeSettingsPaths(dir, env)) {
223
+ const settings = readSettingsFile(file);
224
+ if (settings && accept(settings[key])) return settings[key];
225
+ }
226
+ return undefined;
227
+ }
228
+
229
+ /**
230
+ * The parsed Claude Code settings files, highest precedence first. An absent,
231
+ * unparseable or non-object file is left out.
232
+ */
233
+ function readClaudeSettingsFiles(dir, env) {
234
+ return claudeSettingsPaths(dir, env).map(readSettingsFile).filter(Boolean);
235
+ }
236
+
237
+ /**
238
+ * A settings file larger than this is treated as absent. Claude Code's own
239
+ * settings files are a few kilobytes; the cap keeps a hostile project's
240
+ * `.claude/settings.json` from bloating a read that runs on every render.
241
+ */
242
+ const SETTINGS_FILE_MAX_BYTES = 1024 * 1024;
243
+
244
+ /**
245
+ * The parsed settings object in `file`, or null. Only a regular file of at
246
+ * most SETTINGS_FILE_MAX_BYTES is read: the project's `.claude/` is
247
+ * repository content, and a FIFO there would block the statusline forever.
248
+ * The file is opened non-blocking and checked through its own descriptor,
249
+ * so the check and the read see the same file, and at most the checked size
250
+ * is read: a file that grew or shrank after the check is absent. A symlink
251
+ * is followed — a settings file linked in from a dotfiles repo is ordinary.
252
+ */
253
+ function readSettingsFile(file) {
254
+ let fd;
255
+ try {
256
+ fd = fs.openSync(file, fs.constants.O_RDONLY | (fs.constants.O_NONBLOCK || 0));
257
+ const st = fs.fstatSync(fd);
258
+ if (!st.isFile() || st.size > SETTINGS_FILE_MAX_BYTES) return null;
259
+ // One byte past the checked size, so growth after the check shows as a longer read.
260
+ const buf = Buffer.alloc(st.size + 1);
261
+ let n = 0;
262
+ for (let r; n < buf.length && (r = fs.readSync(fd, buf, n, buf.length - n, n)) > 0;) n += r;
263
+ if (n !== st.size) return null;
264
+ const settings = JSON.parse(buf.toString('utf8', 0, n));
265
+ return settings && typeof settings === 'object' && !Array.isArray(settings) ? settings : null;
266
+ } catch (e) {
267
+ return null; // absent, unreadable or unparseable — keep looking
268
+ } finally {
269
+ if (fd !== undefined) {
270
+ try { fs.closeSync(fd); } catch (e) { /* already closed */ }
271
+ }
272
+ }
273
+ }
274
+
275
+ /**
276
+ * The Claude Code settings file paths, highest precedence first:
277
+ * <dir>/.claude/settings.local.json, <dir>/.claude/settings.json,
278
+ * (CLAUDE_CONFIG_DIR || ~/.claude)/settings.local.json, settings.json.
279
+ */
280
+ function claudeSettingsPaths(dir, env) {
281
+ const candidates = [];
282
+ if (dir) {
283
+ candidates.push(path.join(dir, '.claude', 'settings.local.json'));
284
+ candidates.push(path.join(dir, '.claude', 'settings.json'));
285
+ }
286
+ let claudeDir;
287
+ try {
288
+ claudeDir = env.CLAUDE_CONFIG_DIR || path.join(os.homedir(), '.claude');
289
+ } catch (e) {
290
+ claudeDir = null;
291
+ }
292
+ if (claudeDir) {
293
+ candidates.push(path.join(claudeDir, 'settings.local.json'));
294
+ candidates.push(path.join(claudeDir, 'settings.json'));
295
+ }
296
+ return candidates;
297
+ }
298
+
299
+ /**
300
+ * Claude Code's settings key for a model: its canonical name, which also
301
+ * matches the dated, `[1m]`, Bedrock and Vertex spellings of it
302
+ * (`claude-opus-5-5[1m]`, `us.anthropic.claude-opus-5-5-v1:0` and
303
+ * `claude-opus-5-5@20260101` all key as `claude-opus-5-5`). A Bedrock
304
+ * revision suffix is stripped only after a version or date segment, so a
305
+ * model whose own name ends in `-v<n>` (`anthropic.claude-v2`) keeps it.
306
+ * The rules repeat until nothing changes, so a key is its own key: one pass
307
+ * left `x[1m][1m]` as `x[1m]`. Lowercasing runs once, before the loop (it
308
+ * can lengthen a string: `İ` becomes two characters); inside the loop every
309
+ * rule only removes characters, so it ends. A key longer than
310
+ * MODEL_KEY_MAX_LENGTH is no model's — '' — which also bounds the loop's
311
+ * work on a hostile settings file. '' for a non-string.
312
+ */
313
+ const MODEL_KEY_MAX_LENGTH = 256;
314
+
315
+ function canonicalModelKey(id) {
316
+ if (typeof id !== 'string') return '';
317
+ let key = id.toLowerCase();
318
+ if (key.length > MODEL_KEY_MAX_LENGTH) return '';
319
+ for (let prev; prev !== key;) {
320
+ prev = key;
321
+ key = key.trim()
322
+ .replace(/(?:\[1m\])+$/, '')
323
+ .replace(/^(?:[a-z]+\.)?anthropic\./, '')
324
+ .replace(/(\d)-v\d+(?::\d+)?$/, '$1')
325
+ .replace(/@\d{8}$/, '')
326
+ .replace(/-\d{8}$/, '');
327
+ }
328
+ return key;
329
+ }
330
+
331
+ function isAutoCompactWindowValue(v) {
332
+ return v === 'auto' ||
333
+ (Number.isInteger(v) && v >= AUTO_COMPACT_WINDOW_MIN && v <= AUTO_COMPACT_WINDOW_MAX);
334
+ }
335
+
336
+ /**
337
+ * The `autoCompactWindow` setting for this model, merged across the settings
338
+ * files the way Claude Code merges it (claude 2.1.292): lowest precedence
339
+ * first, each file's `modelSettings.<model>.autoCompactWindow` entries
340
+ * layer over the lower files', and a file that sets a top-level
341
+ * `autoCompactWindow` replaces the default and drops the lower files'
342
+ * per-model entries. The model's own entry wins over the default.
343
+ * `/autocompact` saves the per-model entry; older versions saved the
344
+ * top-level one. `"auto"` (Claude Code's tuned window) and an absent setting
345
+ * are null, so the caller falls back to the model window. An invalid value
346
+ * is treated as absent.
347
+ */
348
+ function readAutoCompactWindowSetting(dir, env, modelId) {
349
+ let fallback;
350
+ let byModel = {};
351
+ for (const settings of readClaudeSettingsFiles(dir, env).reverse()) {
352
+ const own = {};
353
+ const perModel = settings.modelSettings;
354
+ if (perModel && typeof perModel === 'object' && !Array.isArray(perModel)) {
355
+ for (const [name, entry] of Object.entries(perModel)) {
356
+ const v = entry && typeof entry === 'object' ? entry.autoCompactWindow : undefined;
357
+ if (!isAutoCompactWindowValue(v)) continue;
358
+ const key = canonicalModelKey(name);
359
+ // A canonically spelled key wins over another spelling of it.
360
+ if (name === key || !Object.hasOwn(own, key)) own[key] = v;
361
+ }
362
+ }
363
+ if (isAutoCompactWindowValue(settings.autoCompactWindow)) {
364
+ fallback = settings.autoCompactWindow;
365
+ byModel = own;
366
+ } else {
367
+ byModel = { ...byModel, ...own };
368
+ }
369
+ }
370
+ const key = canonicalModelKey(modelId);
371
+ const value = key && Object.hasOwn(byModel, key) ? byModel[key] : fallback;
372
+ return Number.isInteger(value) ? value : null;
373
+ }
374
+
375
+ /**
376
+ * Where Claude Code auto-compacts (#4985). The meter's 100% is this token
377
+ * count, so it has to be resolved the way Claude Code resolves it:
378
+ *
379
+ * window CLAUDE_CODE_AUTO_COMPACT_WINDOW (an unparseable or non-positive
380
+ * value is ignored; capped at 1M, raised to 100k), else the
381
+ * `autoCompactWindow` setting `/autocompact` saves, per model or
382
+ * top-level (an integer in 100k–1M; see
383
+ * readAutoCompactWindowSetting), else the model window. Always
384
+ * capped at the model window.
385
+ * threshold window − min(model max output, 20,000) − 13,000, lowered to
386
+ * floor((window − 20,000) × pct / 100) when
387
+ * CLAUDE_AUTOCOMPACT_PCT_OVERRIDE (0 < pct ≤ 100) is lower.
388
+ *
389
+ * `/context` shows the 33,000 as "Autocompact buffer". The hardcoded 16.5%
390
+ * this replaces is 33,000 / 200,000, so it was right only on a 200K window
391
+ * with nothing configured. Every current model's max output is at least
392
+ * 20,000, so the reserve is taken as 20,000.
393
+ *
394
+ * Not visible to a statusline, so not modelled: the `--autocompact` launch
395
+ * flag, managed-policy settings, and Claude Code's server-side and per-model
396
+ * window defaults (what `"auto"` resolves to). Those sessions fall back to
397
+ * the model window.
398
+ */
399
+ const AUTO_COMPACT_WINDOW_MIN = 100_000;
400
+ const AUTO_COMPACT_WINDOW_MAX = 1_000_000;
401
+ const AUTO_COMPACT_OUTPUT_RESERVE = 20_000;
402
+ const AUTO_COMPACT_SUMMARY_BUFFER = 13_000;
403
+
404
+ function parseAutoCompactWindowEnv(raw) {
405
+ if (typeof raw !== 'string' || raw.trim() === '') return null;
406
+ const s = raw.trim();
407
+ const n = /^\d[\d_,]*$/.test(s) ? parseInt(s.replace(/[_,]/g, ''), 10) : parseInt(s, 10);
408
+ if (!Number.isFinite(n) || n <= 0) return null;
409
+ return Math.max(AUTO_COMPACT_WINDOW_MIN, Math.min(AUTO_COMPACT_WINDOW_MAX, n));
410
+ }
411
+
412
+ /**
413
+ * The token count at which Claude Code auto-compacts this session, or null
414
+ * when auto-compaction is off (see isAutoCompactDisabled).
415
+ */
416
+ function resolveAutoCompactThreshold(modelWindow, dir, env = process.env, modelId) {
417
+ if (!(modelWindow > 0) || isAutoCompactDisabled(dir, env)) return null;
418
+ let window = parseAutoCompactWindowEnv(env.CLAUDE_CODE_AUTO_COMPACT_WINDOW);
419
+ if (window === null) {
420
+ window = readAutoCompactWindowSetting(dir, env, modelId) ?? modelWindow;
421
+ }
422
+ const effective = Math.min(window, modelWindow) - AUTO_COMPACT_OUTPUT_RESERVE;
423
+ let threshold = effective - AUTO_COMPACT_SUMMARY_BUFFER;
424
+ const pct = parseFloat(env.CLAUDE_AUTOCOMPACT_PCT_OVERRIDE);
425
+ if (Number.isFinite(pct) && pct > 0 && pct <= 100) {
426
+ threshold = Math.min(threshold, Math.floor(effective * (pct / 100)));
427
+ }
428
+ return threshold > 0 ? threshold : null;
429
+ }
430
+
431
+ /**
432
+ * The context meter, in one scale: `used` + `remaining` = 100, where 100% is
433
+ * the auto-compact threshold, or the model window when compaction is off.
434
+ * `usedTokens` is Claude Code's own count (input + cache creation + cache
435
+ * read of the last turn, the sum /context reports) and `limitTokens` the
436
+ * token count 100% stands for.
437
+ *
438
+ * Taken from token counts, not by re-scaling `remaining_percentage`: that
439
+ * value is already rounded against the model window, which loses up to 5,000
440
+ * tokens on a 1M model. Without `current_usage` the tokens are recovered
441
+ * from the percentage; without `context_window_size` the window is unknown,
442
+ * so the meter shows Claude Code's own percentage unscaled. Returns null
443
+ * when there is no usage yet.
444
+ */
445
+ function contextMeter(contextWindow, dir, env = process.env, modelId) {
446
+ if (!contextWindow || typeof contextWindow !== 'object') return null;
447
+ const size = Number(contextWindow.context_window_size);
448
+ const usage = contextWindow.current_usage;
449
+ const remainingPct = contextWindow.remaining_percentage;
450
+ if (size > 0) {
451
+ let usedTokens = null;
452
+ if (usage && typeof usage === 'object') {
453
+ usedTokens = (Number(usage.input_tokens) || 0) +
454
+ (Number(usage.cache_creation_input_tokens) || 0) +
455
+ (Number(usage.cache_read_input_tokens) || 0);
456
+ } else if (remainingPct != null) {
457
+ usedTokens = Math.round(((100 - remainingPct) * size) / 100);
458
+ }
459
+ if (usedTokens !== null) {
460
+ const limitTokens = resolveAutoCompactThreshold(size, dir, env, modelId) ?? size;
461
+ const used = Math.max(0, Math.min(100, Math.round((usedTokens / limitTokens) * 100)));
462
+ return { used, remaining: 100 - used, usedTokens, limitTokens };
463
+ }
464
+ }
465
+ if (remainingPct == null) return null;
466
+ const used = Math.max(0, Math.min(100, Math.round(100 - remainingPct)));
467
+ return { used, remaining: 100 - used, usedTokens: null, limitTokens: null };
468
+ }
469
+
173
470
  /**
174
471
  * Walk up from dir looking for .planning/STATE.md (flat mode). If an ancestor
175
472
  * has no flat STATE.md but IS in workstream mode (.planning/workstreams/
@@ -830,28 +1127,22 @@ function runStatusline() {
830
1127
  const model = compactModelName(data.model?.display_name || 'Claude');
831
1128
  const dir = data.workspace?.current_dir || process.cwd();
832
1129
  const session = data.session_id || '';
833
- const remaining = data.context_window?.remaining_percentage;
834
1130
 
835
1131
  // Read .planning config once — used by the context meter (token suffix)
836
1132
  // and the last-command/position block below. Fail-soft to {}.
837
1133
  let cfg = {};
838
1134
  try { cfg = readGsdConfig(dir); } catch (e) {}
839
1135
 
840
- // Context window display (shows USED percentage scaled to usable context)
841
- // Claude Code reserves a buffer for autocompact. By default this is ~16.5%
842
- // of the total window, but users can override it via CLAUDE_CODE_AUTO_COMPACT_WINDOW
843
- // (a token count). When the env var is set, compute the buffer % dynamically so
844
- // the meter correctly reflects early-compaction configurations (#2219).
845
- const totalCtx = data.context_window?.total_tokens || 1_000_000;
846
- const acw = parseInt(process.env.CLAUDE_CODE_AUTO_COMPACT_WINDOW || '0', 10);
847
- const AUTO_COMPACT_BUFFER_PCT = acw > 0
848
- ? Math.min(100, Math.max(0, (1 - acw / totalCtx) * 100))
849
- : 16.5;
1136
+ // Context window display: USED percentage of the auto-compact threshold,
1137
+ // so 100% is where Claude Code compacts — resolved from
1138
+ // CLAUDE_CODE_AUTO_COMPACT_WINDOW, the `autoCompactWindow` setting, or the
1139
+ // model window (#2219, #4985). With auto-compact disabled (#4844) 100% is
1140
+ // the model window. Project settings are read from workspace.project_dir,
1141
+ // Claude Code's launch directory, not the current directory.
1142
+ const meter = contextMeter(data.context_window, data.workspace?.project_dir || dir, process.env, data.model?.id);
850
1143
  let ctx = '';
851
- if (remaining != null) {
852
- // Normalize: subtract buffer from remaining, scale to usable range
853
- const usableRemaining = Math.max(0, ((remaining - AUTO_COMPACT_BUFFER_PCT) / (100 - AUTO_COMPACT_BUFFER_PCT)) * 100);
854
- const used = Math.max(0, Math.min(100, Math.round(100 - usableRemaining)));
1144
+ if (meter) {
1145
+ const { used } = meter;
855
1146
 
856
1147
  // Write context metrics to bridge file for the context-monitor PostToolUse hook.
857
1148
  // The monitor reads this file to inject agent-facing warnings when context is low.
@@ -861,15 +1152,20 @@ function runStatusline() {
861
1152
  if (sessionSafe) {
862
1153
  try {
863
1154
  const bridgePath = path.join(os.tmpdir(), `claude-ctx-${session}.json`);
864
- // used_pct written to the bridge must match CC's native /context reporting:
865
- // raw used = 100 - remaining_percentage (no buffer normalization applied).
866
- // The normalized `used` value is correct for the statusline progress bar but
867
- // inflates the context monitor warning messages by ~13 points (#2451).
868
- const rawUsedPct = Math.round(100 - remaining);
1155
+ // The bridge is on the bar's scale: remaining_percentage counts down
1156
+ // to the auto-compact threshold, so the monitor's WARNING/CRITICAL
1157
+ // fire before compaction rather than after it (#4985). The token
1158
+ // counts let its message match /context, which is what #2451 kept
1159
+ // the bridge raw for; they are absent when the payload has no
1160
+ // context_window_size.
869
1161
  const bridgeData = JSON.stringify({
870
1162
  session_id: session,
871
- remaining_percentage: remaining,
872
- used_pct: rawUsedPct,
1163
+ remaining_percentage: meter.remaining,
1164
+ used_pct: used,
1165
+ ...(meter.usedTokens !== null && {
1166
+ used_tokens: meter.usedTokens,
1167
+ threshold_tokens: meter.limitTokens,
1168
+ }),
873
1169
  timestamp: Math.floor(Date.now() / 1000)
874
1170
  });
875
1171
  fs.writeFileSync(bridgePath, bridgeData);
@@ -1097,6 +1393,9 @@ module.exports = {
1097
1393
  readStateHeadCommits, parseRevListCounts, deriveStateFreshness,
1098
1394
  formatStateFreshness, resolveStatuslineOptions,
1099
1395
  renderBracketPhaseDisplay, renderBracketMilestoneDisplay,
1396
+ isAutoCompactDisabled, AUTO_COMPACT_DISABLE_ENV_KEYS, AUTO_COMPACT_ENV_TRUTHY,
1397
+ resolveAutoCompactThreshold, contextMeter, SETTINGS_FILE_MAX_BYTES,
1398
+ parseAutoCompactWindowEnv, canonicalModelKey, isAutoCompactWindowValue,
1100
1399
  };
1101
1400
 
1102
1401
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opengsd/gsd-core",
3
- "version": "1.16.0",
3
+ "version": "1.17.0",
4
4
  "description": "GSD Core is a meta-prompting, context engineering, and spec-driven development system for AI coding agents.",
5
5
  "main": ".opencode/plugins/gsd-core.js",
6
6
  "bin": {
@@ -38,6 +38,7 @@ const { getWiredKinds } = require('./gen-loop-host-contract.cjs');
38
38
 
39
39
  // Capability validator — shared runtime-callable module extracted per ADR-1244 D2.
40
40
  const capValidator = require('../gsd-core/bin/lib/capability-validator.cjs');
41
+ const { transformContentToHyphen, readCmdNames } = require('./fix-slash-commands.cjs');
41
42
  // Destructure only what the generator's own function bodies reference directly.
42
43
  // Everything else is re-exported from capValidator in module.exports below.
43
44
  const {
@@ -795,7 +796,12 @@ function serializeRegistry(registry, capMap) {
795
796
  lines.push('};');
796
797
  lines.push('');
797
798
 
798
- return lines.join('\n');
799
+ // #4859: capability descriptions and fragment `inline` text are compiled into this
800
+ // file and printed verbatim — the install-time conversion of markdown artifacts never
801
+ // reaches them — so the colon form `/gsd:<cmd>` (the repo-source spelling, which no
802
+ // install route registers) is rewritten to the hyphen form here. Same-length rewrite,
803
+ // restricted to known command names, so `/gsd:section` and other tokens are untouched.
804
+ return transformContentToHyphen(lines.join('\n'), readCmdNames());
799
805
  }
800
806
 
801
807
  // ─── --check diff helper ──────────────────────────────────────────────────────
@@ -85,6 +85,9 @@ const ROLE_TO_AGENT = {
85
85
  checker: 'gsd-plan-checker',
86
86
  executor: 'gsd-executor',
87
87
  verifier: 'gsd-verifier',
88
+ // #4790 — the built-in source-code reviewer the code-review skill dispatches one hop below
89
+ // `execute:post`. Admitting the role is what lets a capability contribution name it.
90
+ 'code-reviewer': 'gsd-code-reviewer',
88
91
  };
89
92
 
90
93
  // #4740 — Role → family mapping. Three families: orchestration, planning,
@@ -94,7 +97,7 @@ const ROLE_TO_AGENT = {
94
97
  const ROLE_FAMILY = {
95
98
  orchestrator: 'orchestration',
96
99
  researcher: 'planning', planner: 'planning', checker: 'planning',
97
- executor: 'execution', verifier: 'execution',
100
+ executor: 'execution', verifier: 'execution', 'code-reviewer': 'execution',
98
101
  };
99
102
  const EXPECTED_FAMILY_BY_STEP = {
100
103
  discuss: 'orchestration',
@@ -143,7 +143,11 @@ module.exports = {
143
143
  "tests/nsegment-phase-grammar.test.cjs",
144
144
  "tests/observability/event.test.cjs",
145
145
  "tests/onboard-command.test.cjs",
146
+ "tests/opencode-generations.smoke.test.cjs",
147
+ "tests/opencode-install-notices.test.cjs",
148
+ "tests/opencode-parity-hooks.test.cjs",
146
149
  "tests/opencode-plugin-adapter.test.cjs",
150
+ "tests/opencode-uninstall-roundtrip.test.cjs",
147
151
  "tests/pause-work-context-detection.test.cjs",
148
152
  "tests/pause-work-improvements.test.cjs",
149
153
  "tests/perf-317-context-monitor-fs.test.cjs",
@@ -39,6 +39,7 @@ module.exports = {
39
39
  "tests/check-tdd-review-checkpoint-e2e.test.cjs",
40
40
  "tests/check-ui-safety-gate.test.cjs",
41
41
  "tests/check-update-config-dir.test.cjs",
42
+ "tests/check-update-fail-open.test.cjs",
42
43
  "tests/chunked-planning-parallel.test.cjs",
43
44
  "tests/ci-docs-guard-registry.test.cjs",
44
45
  "tests/ci-rebase-check.test.cjs",
@@ -51,11 +52,13 @@ module.exports = {
51
52
  "tests/code-review-pipeline-regression.test.cjs",
52
53
  "tests/code-review-tier3-files-override-scoping.test.cjs",
53
54
  "tests/code-review.test.cjs",
55
+ "tests/code-reviewer-contribution.test.cjs",
54
56
  "tests/codex-config-agents.test.cjs",
55
57
  "tests/codex-config-hooks.test.cjs",
56
58
  "tests/codex-config-install.test.cjs",
57
59
  "tests/codex-config.test.cjs",
58
60
  "tests/codex-inherit-smoke.test.cjs",
61
+ "tests/codex-windows-shim-node-resolution.test.cjs",
59
62
  "tests/command-routing-hub.test.cjs",
60
63
  "tests/commands.platform.test.cjs",
61
64
  "tests/commit-files-deletion.test.cjs",
@@ -70,6 +73,7 @@ module.exports = {
70
73
  "tests/config.platform.test.cjs",
71
74
  "tests/configured-entrypoint-validation.test.cjs",
72
75
  "tests/context-drift.test.cjs",
76
+ "tests/context-monitor-host-contract.test.cjs",
73
77
  "tests/copilot-install.test.cjs",
74
78
  "tests/copilot-upgrades.test.cjs",
75
79
  "tests/core-utils.test.cjs",
@@ -195,7 +199,13 @@ module.exports = {
195
199
  "tests/nsegment-phase-grammar.test.cjs",
196
200
  "tests/onboard-command.test.cjs",
197
201
  "tests/opencode-command-dir-plural.test.cjs",
202
+ "tests/opencode-config-jsonc.test.cjs",
203
+ "tests/opencode-generations.smoke.test.cjs",
204
+ "tests/opencode-install-notices.test.cjs",
205
+ "tests/opencode-parity-hooks.test.cjs",
198
206
  "tests/opencode-plugin-adapter.test.cjs",
207
+ "tests/opencode-statusline-plugin.test.cjs",
208
+ "tests/opencode-uninstall-roundtrip.test.cjs",
199
209
  "tests/overlay-repo-helpers.test.cjs",
200
210
  "tests/packaging-shipped-scripts-require-only-shipped.test.cjs",
201
211
  "tests/path-replacement.test.cjs",
@@ -480,7 +480,9 @@ const COVERED = {
480
480
  // dependency of something else under test.
481
481
  'adr-parser': {
482
482
  cjs: 'gsd-core/bin/lib/adr-parser.cjs',
483
- minScore: 68,
483
+ // CI (2026-10-13, #5227 PR): measured 73.24% after the list-entry splitter tests. Floor =
484
+ // floor(73.24) - 1 = 72.
485
+ minScore: 72,
484
486
  },
485
487
  'config-schema': {
486
488
  cjs: 'gsd-core/bin/lib/config-schema.cjs',
@@ -325,22 +325,29 @@ const RUNTIME_CONFIG_FILES = Object.freeze(['settings.json', 'hooks.json', 'conf
325
325
  * embeds a launch path without registering it, which a structured
326
326
  * JSON.parse of the expected schema would miss entirely.
327
327
  *
328
- * Windows configs store paths with backslashes, which JSON/TOML doubles on
329
- * write; collapsing `\\` to `\` first makes the raw text scan work on both
330
- * platforms without parsing each config format separately (POSIX text has no
331
- * backslashes, so the collapse is a no-op there).
332
- *
333
328
  * Every writer bakes `configDir` through the same posixNormalize seam
334
329
  * (src/runtime-hooks-surface.cts) before writing it into config text, on
335
330
  * every platform — so the anchor must match that projection, not the
336
331
  * OS-native `configDir` string this function receives.
332
+ *
333
+ * The scanned text goes through that same projection (#5084): a registration
334
+ * the installer did not write — a hand-edited settings.json, another tool's
335
+ * writer — may spell its path with Windows-native backslashes, and an anchor
336
+ * and haystack in different separator forms never match, so the dangling-hook
337
+ * check would skip it silently. Scan both the backslash-unescaped projection
338
+ * (JSON and TOML basic strings) and the unchanged projection (TOML literal
339
+ * strings). Unescaping a literal UNC prefix drops a leading separator, so
340
+ * neither projection alone is sufficient. A Set combines identical paths.
337
341
  */
338
342
  function configuredEntrypointsIn(text, configDir) {
339
343
  const normalizedPrefix = shellCmdProjection.posixNormalize(configDir).replace(/\/+$/, '') + '/';
340
344
  const scriptPathRe = new RegExp(`${escapeRegex(normalizedPrefix)}[^"']{0,400}?\\.(?:js|cjs|mjs|sh|cmd|ps1)`, 'g');
341
345
  const found = new Set();
342
- for (const match of text.replace(/\\\\/g, '\\').matchAll(scriptPathRe)) {
343
- found.add(path.resolve(match[0]));
346
+ for (const candidateText of [text.replace(/\\\\/g, '\\'), text]) {
347
+ const scannedText = shellCmdProjection.posixNormalize(candidateText);
348
+ for (const match of scannedText.matchAll(scriptPathRe)) {
349
+ found.add(path.resolve(match[0]));
350
+ }
344
351
  }
345
352
  return [...found];
346
353
  }
@@ -2,7 +2,7 @@
2
2
  "name": "gsd-core-vscode",
3
3
  "displayName": "GSD Core",
4
4
  "description": "GSD orchestration engine embedded in VS Code (ADR-1239 IDE profile).",
5
- "version": "1.16.0",
5
+ "version": "1.17.0",
6
6
  "publisher": "opengsd",
7
7
  "engines": {
8
8
  "vscode": "^1.105.0"