{
  "schemaVersion": 2,
  "type": "pi-forge.prompt-stack",
  "id": "regex-hack",
  "name": "Regex Hack Pack",
  "description": "Default layout plus outgoing-history regex rules: ANSI escapes are removed and illustrative sk-/ghp_ token shapes are redacted. This is a non-exhaustive demo, not a general secret scanner.",
  "autoActivate": false,
  "mode": "replace",
  "defaults": {
    "syntheticMessagesVisible": false,
    "unresolvedMacroPolicy": "warn"
  },
  "context": {
    "allowDuplicateChatHistory": false
  },
  "tools": {
    "allow": [
      "*"
    ]
  },
  "items": [
    {
      "kind": "block",
      "id": "main-role",
      "name": "Pi Default Role",
      "enabled": true,
      "role": "system",
      "content": "You are an expert coding assistant operating inside pi, a coding agent harness. You help users by reading files, executing commands, editing code, and writing new files."
    },
    {
      "kind": "slot",
      "id": "tools",
      "name": "Available Tools",
      "enabled": true,
      "role": "system",
      "slot": "tools",
      "options": {
        "format": "plain",
        "onlyWithSnippets": true
      }
    },
    {
      "kind": "slot",
      "id": "project-context",
      "name": "Project Context",
      "enabled": true,
      "role": "system",
      "slot": "project-context"
    },
    {
      "kind": "slot",
      "id": "date-cwd",
      "name": "Date and Working Directory",
      "enabled": true,
      "role": "system",
      "slot": "date-cwd"
    },
    {
      "kind": "slot",
      "id": "chat-history",
      "name": "Chat History",
      "enabled": true,
      "slot": "chat-history",
      "options": {
        "stripAssistantThinking": false
      }
    }
  ],
  "regex": {
    "schemaVersion": 1,
    "rules": [
      {
        "id": "strip-ansi-escapes",
        "name": "ANSI terminal escape codes removed from outgoing history",
        "enabled": true,
        "stage": "history",
        "targets": [
          "messages"
        ],
        "pattern": "\\x1B\\[[0-?]*[ -/]*[@-~]",
        "flags": "g",
        "replace": ""
      },
      {
        "id": "redact-api-keys-outgoing",
        "name": "Illustrative sk-/ghp_ token shapes redacted on every provider request",
        "enabled": true,
        "stage": "history",
        "effect": "outgoing",
        "frequency": "request",
        "targets": [
          "messages"
        ],
        "pattern": "\\b(sk-[A-Za-z0-9_-]{12,}|ghp_[A-Za-z0-9]{20,})\\b",
        "flags": "g",
        "replace": "[REDACTED]"
      },
      {
        "id": "redact-api-keys-finalize",
        "name": "Illustrative sk-/ghp_ token shapes scrubbed from the stored transcript",
        "enabled": true,
        "stage": "compiled",
        "effect": "finalize",
        "targets": [
          "messages"
        ],
        "roles": [
          "assistant",
          "toolResult"
        ],
        "pattern": "\\b(sk-[A-Za-z0-9_-]{12,}|ghp_[A-Za-z0-9]{20,})\\b",
        "flags": "g",
        "replace": "[REDACTED]"
      }
    ]
  },
  "parameters": {}
}
