Skip to content

fix: use case-insensitive matching for prometheus agent detection#1770

Merged
code-yeongyu merged 2 commits intodevfrom
fix/prometheus-md-only-agent-name-matching
Feb 11, 2026
Merged

fix: use case-insensitive matching for prometheus agent detection#1770
code-yeongyu merged 2 commits intodevfrom
fix/prometheus-md-only-agent-name-matching

Conversation

@code-yeongyu
Copy link
Owner

@code-yeongyu code-yeongyu commented Feb 11, 2026

Summary

  • Fix prometheus-md-only hook's agent name detection which used exact string equality (agentName !== "prometheus") and failed when display names like "Prometheus (Plan Builder)" were stored in session state
  • Replace with case-insensitive substring matching via isPrometheusAgent() helper, consistent with the pattern used in keyword-detector hook

Problem

The prometheus-md-only hook enforces that Prometheus can only write .md files inside .sisyphus/. However, the agent detection logic used exact match:

// Before (fragile)
if (agentName !== PROMETHEUS_AGENT) return

getSessionAgent() can return display names (e.g., "Prometheus (Plan Builder)", "Prometheus (Planner)") depending on how OpenCode stores the agent name. When this happens, the hook silently fails to activate, allowing Prometheus to write arbitrary files — bypassing the policy enforcement.

Solution

Extract a robust matcher into agent-matcher.ts:

export function isPrometheusAgent(agentName: string | undefined): boolean {
  return agentName?.toLowerCase().includes(PROMETHEUS_AGENT) ?? false
}

This matches the pattern already used by keyword-detector/ultrawork/source-detector.ts.

Testing

Added 6 new test cases covering:

  • Exact name "prometheus" → blocked ✅
  • Display name "Prometheus (Plan Builder)" → blocked ✅
  • Display name "Prometheus (Planner)" → blocked ✅
  • Uppercase "PROMETHEUS" → blocked ✅
  • Non-Prometheus agent "sisyphus" → not blocked ✅
  • Undefined agent → not blocked ✅

All 35 tests pass. Typecheck clean.

Related

Closes #1764 (Bug 3: Prometheus Detection)


Summary by cubic

Make Prometheus md-only enforcement reliable by detecting the agent with case-insensitive substring matching. Also clarify errors for namespaced marketplace slash commands.

Written for commit c12c6fa. Summary will update on new commits.

- Detect namespaced commands (containing ':') from Claude marketplace plugins
- Provide clear error message explaining marketplace plugins are not supported
- Point users to .claude/commands/ as alternative for custom commands
- Fixes issue where /daplug:run-prompt gave ambiguous 'command not found'

Closes #1682
…prometheus-md-only hook

The hook used exact string equality (agentName !== "prometheus") which fails
when display names like "Prometheus (Plan Builder)" are stored in session state.
Replace with case-insensitive substring matching via isPrometheusAgent() helper,
consistent with the pattern used in keyword-detector hook.

Closes #1764 (Bug 3)
Copy link

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 5 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Auto-approved: Changes are low-risk: 1) Error message improvements for marketplace plugin commands (better UX, no logic change), 2) Refactored agent matching from exact string to case-insensitive includes (safer, no

@code-yeongyu code-yeongyu merged commit 306c7f4 into dev Feb 11, 2026
8 checks passed
@code-yeongyu code-yeongyu deleted the fix/prometheus-md-only-agent-name-matching branch February 11, 2026 18:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant