Skip to content

forcedotcom/sf-skills / plugins/builder/service-omni/skills/service-omni-channel-limits-analyze

service-omni-channel-limits-analyze

Verified

Use to report Omni-Channel Pending Service Routing usage without changing the org: query the current PendingServiceRouting count, compare it with an admin-supplied maximum or a labeled routing-model reference default, and explain which live values are unavailable through supported APIs. TRIGGER when: check Omni-Channel limits, inspect PSR limits, analyze PendingServiceRouting usage, review pending routing capacity, or report queued work usage. Do not use to change limits or scrape Salesforce Setup.

FileKindSize
SKILL.mdskill md3.8 KB
references/api-notes.mdmarkdown1.3 KB
scripts/analyze.shexecutablescript4.7 KB
scripts/tests/_bootstrap.pyscript2.6 KB
scripts/tests/test_limits_analyze_contracts.pyexecutablescript4.5 KB

scripts/tests/_bootstrap.py

View on GitHub
"""Fake Salesforce CLI harness for the Omni-Channel limits analyzer."""
from __future__ import annotations

import json
import os
import shutil
import subprocess
import tempfile
from pathlib import Path

SKILLS_ROOT = Path(__file__).resolve().parents[3]
SCRIPT = SKILLS_ROOT / "service-omni-channel-limits-analyze/scripts/analyze.sh"

_FAKE_SF = r'''#!/usr/bin/env bash
command_name="${1:-} ${2:-}"
case "$command_name" in
  "org display")
    if [ "${FAKE_AUTH:-ok}" = "fail" ]; then
      echo '{"status":1,"message":"not authenticated"}' >&2
      exit 1
    fi
    echo '{"status":0,"result":{}}'
    ;;
  "data query")
    printf '%s\n' "$*" >> "${FAKE_SF_LOG:?}"
    if [ -n "${FAKE_QUERY_BODY:-}" ]; then
      printf '%s\n' "$FAKE_QUERY_BODY"
    else
      printf '%s\n' '{"status":0,"result":{"totalSize":2,"records":[]}}'
    fi
    if [ "${FAKE_QUERY_STATUS:-ok}" = "fail" ]; then
      exit 1
    fi
    ;;
  *)
    echo '{"status":1,"message":"unexpected command"}' >&2
    exit 1
    ;;
esac
'''


class FakeSf:
    def __enter__(self):
        self._directory = tempfile.mkdtemp(prefix="omni-limits-fake-sf-")
        self.log_path = Path(self._directory) / "commands.log"
        sf_path = Path(self._directory) / "sf"
        sf_path.write_text(_FAKE_SF)
        sf_path.chmod(0o755)
        return self

    def run(self, args: list[str], **values):
        env = dict(os.environ)
        env["PATH"] = self._directory + os.pathsep + env.get("PATH", "")
        env["FAKE_SF_LOG"] = str(self.log_path)
        for key, value in values.items():
            env[key] = json.dumps(value) if key == "FAKE_QUERY_BODY" and not isinstance(value, str) else str(value)
        process = subprocess.run(
            ["bash", str(SCRIPT), *args],
            capture_output=True,
            text=True,
            env=env,
            cwd=str(SKILLS_ROOT),
        )
        commands = self.log_path.read_text() if self.log_path.exists() else ""
        return process.returncode, process.stdout + process.stderr, commands

    def __exit__(self, *_):
        shutil.rmtree(self._directory, ignore_errors=True)


def last_json(output: str) -> dict:
    decoder = json.JSONDecoder()
    parsed = None
    position = 0
    while position < len(output):
        if output[position] == "{":
            try:
                candidate, end = decoder.raw_decode(output, position)
                parsed = candidate
                position = end
                continue
            except json.JSONDecodeError:
                pass
        position += 1
    assert parsed is not None, f"No JSON object found in output:\n{output}"
    return parsed
receiving-code-reviewobra/superpowersUse when receiving code review feedback, before implementing suggestions, especially if feedback seems unclear or technically questionable - requires technical rigor and verification, not performative agreement or blind implementationStars: 322kUpdated Claude CodeCodexVerifiedInstall
requesting-code-reviewobra/superpowersUse when completing tasks, implementing major features, or before merging to verify work meets requirementsStars: 322kUpdated Claude CodeCodexVerifiedInstall
using-git-worktreesobra/superpowersUse when starting feature work that needs isolation from current workspace or before executing implementation plans - ensures an isolated workspace exists via native tools or git worktree fallbackStars: 322kUpdated Claude CodeCodexVerifiedInstall
verification-before-completionobra/superpowersUse when about to claim work is complete, fixed, or passing, before committing or creating PRs - requires running verification commands and confirming output before making any success claims; evidence before assertions alwaysStars: 322kUpdated Claude CodeCodexVerifiedInstall