@maheidem/pi-delegate 0.3.1 → 0.3.2

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/application.ts CHANGED
@@ -289,10 +289,12 @@ export class DelegateApplicationImpl implements DelegateApplication {
289
289
  // Strip the overlay's diagnostic keys so only real config fields
290
290
  // reach the runner (a spurious key would survive into metadata).
291
291
  const overlay = applyProjectOverlay(this.liveConfig, request.projectRoot);
292
- const { projectOverrides, projectCorrupt, ...rest } = overlay as unknown as DelegateConfigV1 & {
292
+ const { projectOverrides, projectSetKeys, projectCorrupt, ...rest } = overlay as unknown as DelegateConfigV1 & {
293
293
  projectOverrides: string[];
294
+ projectSetKeys: string[];
294
295
  projectCorrupt?: string;
295
296
  };
297
+ void projectSetKeys; // display-only; run resolution uses projectOverrides
296
298
  projectSetsHard = projectOverrides.includes("hardTimeoutMs");
297
299
  baseCfg = { ...(rest as unknown as DelegateConfigV1) } as DelegateConfigV1;
298
300
  }
@@ -529,20 +531,27 @@ export class DelegateApplicationImpl implements DelegateApplication {
529
531
  if (projectRoot) {
530
532
  const overlay = applyProjectOverlay(cfg, projectRoot) as unknown as DelegateConfigV1 & {
531
533
  projectOverrides: string[];
534
+ projectSetKeys: string[];
532
535
  projectCorrupt?: string;
533
536
  };
534
- const { projectOverrides, projectCorrupt, ...rest } = overlay;
537
+ const { projectOverrides, projectSetKeys, projectCorrupt, ...rest } = overlay;
535
538
  const eff = rest as unknown as DelegateConfigV1;
539
+ // Provenance (source) keeps the override semantics: the effective value
540
+ // only comes "from the project" when it differs. Reporting does not:
541
+ // projectHardMs is present whenever the key is in the project FILE, so a
542
+ // project value equal to the user value is still visible to the panel.
536
543
  const projectSetsHard = projectOverrides.includes("hardTimeoutMs");
544
+ const hardFromFile = projectSetKeys.includes("hardTimeoutMs");
537
545
  timeouts = {
538
546
  hardMs: eff.hardTimeoutMs,
539
547
  inactivityMs: eff.inactivityTimeoutMs,
540
548
  source: projectSetsHard ? "project" : "user",
541
549
  userHardMs: cfg.hardTimeoutMs,
542
550
  userInactivityMs: cfg.inactivityTimeoutMs,
543
- ...(projectSetsHard ? { projectHardMs: eff.hardTimeoutMs } : {}),
551
+ ...(hardFromFile ? { projectHardMs: eff.hardTimeoutMs } : {}),
544
552
  projectPath: projectConfigPath(projectRoot),
545
553
  projectOverrides,
554
+ projectSetKeys,
546
555
  ...(projectCorrupt ? { projectCorrupt } : {}),
547
556
  };
548
557
  }
package/config.ts CHANGED
@@ -327,15 +327,24 @@ export function projectConfigPath(projectRoot: string): string {
327
327
  * (a broken project file must never break delegations);
328
328
  * - only keys PRESENT in the project file override (no default backfill);
329
329
  * - values are clamped by the same min/max bounds as the user config.
330
+ * Two diagnostic arrays, deliberately different:
331
+ * - `projectOverrides`: keys that CHANGE the effective value (equality vs
332
+ * base). Resolution/provenance logic depends on this — do not widen.
333
+ * - `projectSetKeys`: every known key explicitly PRESENT in the file,
334
+ * regardless of equality with the base. Display code must use this, so a
335
+ * project value that happens to equal the user value never renders as
336
+ * "not set". A key whose value is invalid is still reported as set (it
337
+ * is in the file); its effective value then equals the base value.
330
338
  * Returns a NEW config object; the base is never mutated.
331
339
  */
332
340
  export function applyProjectOverlay(
333
341
  base: DelegateConfigV1,
334
342
  projectRoot: string,
335
- ): DelegateConfigV1 & { projectOverrides: string[]; projectCorrupt?: string } {
336
- const result: DelegateConfigV1 & { projectOverrides: string[]; projectCorrupt?: string } = {
343
+ ): DelegateConfigV1 & { projectOverrides: string[]; projectSetKeys: string[]; projectCorrupt?: string } {
344
+ const result: DelegateConfigV1 & { projectOverrides: string[]; projectSetKeys: string[]; projectCorrupt?: string } = {
337
345
  ...base,
338
346
  projectOverrides: [],
347
+ projectSetKeys: [],
339
348
  };
340
349
  const pPath = projectConfigPath(projectRoot);
341
350
  let raw: unknown;
@@ -351,9 +360,13 @@ export function applyProjectOverlay(
351
360
  const record = raw as Record<string, unknown>;
352
361
  const known = new Set<string>(Object.keys(DEFAULT_DELEGATE_CONFIG));
353
362
  const overrides: string[] = [];
363
+ const setKeys: string[] = [];
354
364
  for (const key of Object.keys(record)) {
355
365
  if (key === "schemaVersion") continue;
356
366
  if (!knownKey(key)) continue; // unknown keys in project overlay ignored
367
+ // File truth: present in the project file counts as set even when the
368
+ // normalized value equals the base value (the override list would omit it).
369
+ setKeys.push(key);
357
370
  try {
358
371
  const probe: DelegateConfigV1 = { ...DEFAULT_DELEGATE_CONFIG };
359
372
  applyKnownField(probe, key, record[key]);
@@ -367,6 +380,7 @@ export function applyProjectOverlay(
367
380
  }
368
381
  }
369
382
  result.projectOverrides = overrides;
383
+ result.projectSetKeys = setKeys;
370
384
  return result;
371
385
  }
372
386
 
@@ -382,14 +396,15 @@ export function loadConfigCascade(
382
396
  agentDir: string,
383
397
  projectRoot?: string,
384
398
  configPath?: string,
385
- ): ConfigLoadResult & { projectOverrides: string[]; projectCorrupt?: string } {
399
+ ): ConfigLoadResult & { projectOverrides: string[]; projectSetKeys: string[]; projectCorrupt?: string } {
386
400
  const base = loadConfig(agentDir, configPath);
387
401
  if (!projectRoot) {
388
- return { ...base, projectOverrides: [] };
402
+ return { ...base, projectOverrides: [], projectSetKeys: [] };
389
403
  }
390
404
  const overlay = applyProjectOverlay(base.config, projectRoot);
391
- const { projectOverrides, projectCorrupt, ...rest } = overlay as unknown as DelegateConfigV1 & {
405
+ const { projectOverrides, projectSetKeys, projectCorrupt, ...rest } = overlay as unknown as DelegateConfigV1 & {
392
406
  projectOverrides: string[];
407
+ projectSetKeys: string[];
393
408
  projectCorrupt?: string;
394
409
  };
395
410
  const config: DelegateConfigV1 = { ...(rest as unknown as DelegateConfigV1) };
@@ -397,6 +412,7 @@ export function loadConfigCascade(
397
412
  ...base,
398
413
  config,
399
414
  projectOverrides: overlay.projectOverrides,
415
+ projectSetKeys: overlay.projectSetKeys,
400
416
  projectCorrupt: overlay.projectCorrupt,
401
417
  };
402
418
  }
package/index.ts CHANGED
@@ -39,7 +39,7 @@ import type {
39
39
  SessionEntryLike,
40
40
  } from "./types.ts";
41
41
  import { SettingsPanel, type PanelSnapshot, type PanelActionResult, type PanelSection, type PanelRow } from "./ui/settings-panel.ts";
42
- import { shortModel, formatTokens, formatCost, stateGlyph, progressBar } from "./ui/format.ts";
42
+ import { shortModel, formatTokens, formatCost, stateGlyph, progressBar, projectValueCell } from "./ui/format.ts";
43
43
  import { RunningView, type RunningViewState } from "./ui/running-view.ts";
44
44
  import { PeekView } from "./ui/peek-view.ts";
45
45
  import { FeedRing, feedEventsFromTranscript, renderFeedEvents } from "./transcript-feed.ts";
@@ -949,7 +949,7 @@ export default function delegateExtension(pi: ExtensionAPI) {
949
949
  rows: [
950
950
  { key: "cfg:user:hardTimeoutMs", label: "Hard · user-wide", value: formatDuration(t.userHardMs), rawValue: String(t.userHardMs), kind: "input", inputHint: "e.g. 30m / 2h / 1d — user config" },
951
951
  { key: "cfg:user:inactivityTimeoutMs", label: "Idle · user-wide", value: formatDuration(t.userInactivityMs), rawValue: String(t.userInactivityMs), kind: "input", inputHint: "no-output watchdog; capped at ½ hard" },
952
- { key: "cfg:project:hardTimeoutMs", label: "Hard · project", value: t.projectHardMs !== undefined ? formatDuration(t.projectHardMs) : "not set", rawValue: t.projectHardMs !== undefined ? String(t.projectHardMs) : "", kind: "input", inputHint: `merges into ${t.projectPath ?? ".pi/delegate/config.json"}` },
952
+ { key: "cfg:project:hardTimeoutMs", label: "Hard · project", value: projectValueCell(t.projectHardMs, t.userHardMs), rawValue: t.projectHardMs !== undefined ? String(t.projectHardMs) : "", kind: "input", inputHint: `merges into ${t.projectPath ?? ".pi/delegate/config.json"}` },
953
953
  ...(t.projectCorrupt
954
954
  ? [{ key: "project-corrupt", label: "Project config", value: "corrupt — user values used", kind: "info" as const, valueStyle: "warning" as const }]
955
955
  : []),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@maheidem/pi-delegate",
3
- "version": "0.3.1",
3
+ "version": "0.3.2",
4
4
  "type": "module",
5
5
  "description": "Foreground isolated delegation and strict coordinator mode for the Pi coding agent.",
6
6
  "license": "MIT",
package/types.ts CHANGED
@@ -346,11 +346,13 @@ export interface DelegateStatus {
346
346
  source: "user" | "project";
347
347
  userHardMs: number;
348
348
  userInactivityMs: number;
349
- /** Present when the project file overrides the hard timeout. */
349
+ /** Present when the project file sets the hard timeout (file truth, even when equal to user). */
350
350
  projectHardMs?: number;
351
351
  projectPath?: string;
352
- /** Config keys overridden by the project file. */
352
+ /** Config keys that CHANGE the effective value (equality vs the user layer). */
353
353
  projectOverrides?: string[];
354
+ /** Config keys PRESENT in the project file, whether or not they differ from user. */
355
+ projectSetKeys?: string[];
354
356
  /** Set when a corrupt project file was ignored (user values used). */
355
357
  projectCorrupt?: string;
356
358
  };
package/ui/format.ts CHANGED
@@ -20,6 +20,19 @@ export function formatTokens(n: number | undefined): string {
20
20
  return `${Math.round(n / 100_000) / 10}M`;
21
21
  }
22
22
 
23
+ /**
24
+ * Project-layer config cell for dashboard rows. The project FILE is the
25
+ * source of truth for presence: a value equal to the user layer renders as
26
+ * `2h (= user)` instead of reading as unset, and "not set" appears ONLY when
27
+ * the key is absent from the file. `undefined` means absent.
28
+ */
29
+ export function projectValueCell(value: number | undefined, userValue: number | undefined): string {
30
+ if (value === undefined || !Number.isFinite(value)) return "not set";
31
+ const text = formatDuration(value);
32
+ if (userValue !== undefined && Number.isFinite(userValue) && value === userValue) return `${text} (= user)`;
33
+ return text;
34
+ }
35
+
23
36
  /** Cost as `$X.YZ` (2 dp) or `$0.00`. Never emoji. */
24
37
  export function formatCost(cost: number | undefined): string {
25
38
  return `$${(cost ?? 0).toFixed(2)}`;