<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<installer-gui-script minSpecVersion="2">
    <title>Papika</title>
    <options customize="always" require-scripts="true"/>
    <domains enable_anywhere="false" enable_currentUserHome="false" enable_localSystem="true"/>
    <allowed-os-versions>
        <os-version min="13.0"/>
    </allowed-os-versions>
    <choices-outline>
        <line choice="papika-core"/>
        <line choice="claude-code"/>
        <line choice="codex"/>
    </choices-outline>
    <choice id="papika-core" title="Papika" description="Papika app and command-line tool" start_enabled="false" start_selected="true" start_visible="false">
        <pkg-ref id="com.lambdaphi.papika.pkg"/>
    </choice>
    <choice id="claude-code" title="Claude Code" description="Install the Papika hook and skill, and grant Claude Code access to Papika session mirrors. Reopen Claude Code sessions that were open before this installation if their Papika doorway was started from a version before 0.9.3: it keeps running the previous version until then. A doorway started from 0.9.3 or later refreshes itself after an upgrade." start_enabled="true" start_selected="true" visible="claudeCodeDetected()">
        <pkg-ref id="com.lambdaphi.papika.claude-code.pkg"/>
    </choice>
    <choice id="codex" title="Codex" description="Install Papika's managed PreToolUse identity hook, exact-command PermissionRequest hook, skill, and session mirror. The skill originates one command sandbox escalation; only the exact identity-bound Papika command is silently authorized, so no Codex CLI login, /hooks review, repeated command approval, or broad Full Access is required. Restart Codex after installation if its Papika doorway was started from a version before 0.9.3: open Codex threads keep running the previous Papika version until then. A doorway started from 0.9.3 or later refreshes itself after an upgrade." start_enabled="true" start_selected="true" visible="codexDetected()">
        <pkg-ref id="com.lambdaphi.papika.codex.pkg"/>
    </choice>
    <script><![CDATA[
    function claudeCodeDetected() {
      var home = system.env.HOME || "";
      var candidates = [
        home + "/.claude",
        home + "/.local/bin/claude",
        home + "/.claude/local/claude",
        home + "/.npm-global/bin/claude",
        "/usr/local/bin/claude",
        "/opt/homebrew/bin/claude"
      ];
      for (var index = 0; index < candidates.length; index++) {
        if (system.files.fileExistsAtPath(candidates[index])) return true;
      }
      return false;
    }

    function codexDetected() {
      var home = system.env.HOME || "";
      var candidates = [
        home + "/.codex",
        home + "/.local/bin/codex",
        home + "/.npm-global/bin/codex",
        home + "/Applications/Codex.app",
        "/usr/local/bin/codex",
        "/opt/homebrew/bin/codex",
        "/Applications/Codex.app"
      ];
      for (var index = 0; index < candidates.length; index++) {
        if (system.files.fileExistsAtPath(candidates[index])) return true;
      }
      return false;
    }
  ]]></script>
    <pkg-ref id="com.lambdaphi.papika.pkg" version="0.9.4" installKBytes="15807">#PapikaCore.pkg</pkg-ref>
    <pkg-ref id="com.lambdaphi.papika.claude-code.pkg" version="0.9.4" active="claudeCodeDetected()" installKBytes="0">#PapikaClaudeCode.pkg</pkg-ref>
    <pkg-ref id="com.lambdaphi.papika.codex.pkg" version="0.9.4" active="codexDetected()" installKBytes="0">#PapikaCodex.pkg</pkg-ref>
    <pkg-ref id="com.lambdaphi.papika.pkg">
        <bundle-version>
            <bundle CFBundleShortVersionString="0.9.4" CFBundleVersion="0.9.4" id="com.lambdaphi.papika" path="Applications/Papika.app"/>
        </bundle-version>
    </pkg-ref>
    <pkg-ref id="com.lambdaphi.papika.claude-code.pkg">
        <bundle-version/>
    </pkg-ref>
    <pkg-ref id="com.lambdaphi.papika.codex.pkg">
        <bundle-version/>
    </pkg-ref>
</installer-gui-script>