Current section

Files

Jump to

mix.exs

if bootstrap = System.get_env("MIX_WORKSPACE_OPS_BOOTSTRAP"), do: Code.require_file(bootstrap)

defmodule CliSubprocessCore.MixProject do
  use Mix.Project

  @version "0.9.4"
  @source_url "https://github.com/nshkrdotcom/cli_subprocess_core"
  @homepage_url "https://hex.pm/packages/cli_subprocess_core"
  @docs_url "https://hexdocs.pm/cli_subprocess_core"

  def project do
    [
      app: :cli_subprocess_core,
      name: "CliSubprocessCore",
      version: @version,
      elixir: "~> 1.18",
      elixirc_paths: elixirc_paths(Mix.env()),
      start_permanent: Mix.env() == :prod,
      deps: deps(),
      aliases: aliases(),
      homepage_url: @homepage_url,
      source_url: @source_url,
      docs: docs(),
      package: package(),
      description: description(),
      dialyzer: dialyzer()
    ]
  end

  defp elixirc_paths(:test), do: ["lib", "test/support"]
  defp elixirc_paths(_), do: ["lib"]

  defp docs do
    [
      main: "overview",
      source_ref: "v#{@version}",
      homepage_url: @homepage_url,
      assets: %{"assets" => "assets"},
      logo: "assets/cli_subprocess_core.svg",
      extras: [
        "README.md": [title: "Overview", filename: "overview"],
        "guides/provider-model-audit-2026-09-29.md": [title: "Provider Model Audit"],
        "guides/release-train-2026-09-29.md": [title: "2026-09-29 Release Train"],
        "CHANGELOG.md": [title: "Changelog"],
        LICENSE: [title: "License"],
        "guides/getting-started.md": [title: "Getting Started"],
        "guides/execution-surface-compatibility.md": [title: "Execution Surface Compatibility"],
        "guides/event-and-payload-model.md": [title: "Event And Payload Model"],
        "guides/recovery-envelope.md": [title: "Recovery Envelope"],
        "guides/provider-profile-contract.md": [title: "Provider Profile Contract"],
        "guides/custom-provider-profiles.md": [title: "Custom Provider Profiles"],
        "guides/built-in-provider-profiles.md": [title: "Built-In Provider Profiles"],
        "guides/provider-feature-manifests.md": [title: "Provider Feature Manifests"],
        "guides/developer-guide-model-registry.md": [title: "Developer Guide: Model Registry"],
        "guides/developer-guide-runtime-layers.md": [title: "Developer Guide: Runtime Layers"],
        "guides/developer-guide-claude-backends.md": [title: "Developer Guide: Claude Backends"],
        "guides/developer-guide-codex-backends.md": [title: "Developer Guide: Codex Backends"],
        "guides/developer-guide-adding-transports.md": [
          title: "Developer Guide: Adding Transports"
        ],
        "guides/developer-guide-provider-profiles.md": [
          title: "Developer Guide: Provider Profiles"
        ],
        "guides/command-api.md": [title: "Command API"],
        "guides/raw-transport.md": [title: "Raw Sessions And Transport"],
        "guides/channel-api.md": [title: "Channel API"],
        "guides/json-rpc.md": [title: "JSON-RPC"],
        "guides/session-api.md": [title: "Session API"],
        "guides/shutdown-and-timeouts.md": [title: "Shutdown And Timeouts"],
        "examples/README.md": [title: "Examples", filename: "examples"],
        "guides/testing-and-conformance.md": [title: "Testing And Conformance"]
      ],
      groups_for_extras: [
        "Project Overview": ["README.md"],
        Examples: ["examples/README.md"],
        "Provider Profiles": [
          "guides/provider-profile-contract.md",
          "guides/custom-provider-profiles.md",
          "guides/built-in-provider-profiles.md",
          "guides/provider-feature-manifests.md"
        ],
        "Developer Guides": [
          "guides/developer-guide-model-registry.md",
          "guides/developer-guide-runtime-layers.md",
          "guides/developer-guide-claude-backends.md",
          "guides/developer-guide-codex-backends.md",
          "guides/developer-guide-adding-transports.md",
          "guides/developer-guide-provider-profiles.md"
        ],
        "Runtime & APIs": [
          "guides/getting-started.md",
          "guides/execution-surface-compatibility.md",
          "guides/recovery-envelope.md",
          "guides/raw-transport.md",
          "guides/event-and-payload-model.md",
          "guides/command-api.md",
          "guides/channel-api.md",
          "guides/json-rpc.md",
          "guides/session-api.md"
        ],
        "Operations & Conformance": [
          "guides/shutdown-and-timeouts.md",
          "guides/testing-and-conformance.md"
        ],
        "Project Reference": ["CHANGELOG.md", "LICENSE"]
      ],
      formatters: ["html", "epub", "markdown"],
      source_url: @source_url
    ]
  end

  defp package do
    [
      name: "cli_subprocess_core",
      description: description(),
      files: ~w(lib priv/models guides examples mix.exs README* CHANGELOG* LICENSE* assets),
      licenses: ["MIT"],
      maintainers: ["nshkrdotcom"],
      links: %{
        "GitHub" => @source_url,
        "Hex" => @homepage_url,
        "HexDocs" => @docs_url,
        "Changelog" => "#{@source_url}/blob/main/CHANGELOG.md",
        "License" => "#{@source_url}/blob/main/LICENSE"
      }
    ]
  end

  defp description do
    "Shared CLI subprocess runtime foundation with first-party common provider profiles."
  end

  # Run "mix help compile.app" to learn about applications.
  def application do
    [
      extra_applications: [:logger, :inets, :ssl, :crypto],
      mod: {CliSubprocessCore.Application, []}
    ]
  end

  def cli do
    [preferred_envs: ["test.live": :test]]
  end

  defp deps do
    execution_plane = execution_plane_dep()

    [execution_plane, execution_plane_process_dep(), execution_plane_jsonrpc_dep()] ++
      local_ground_overrides(execution_plane) ++
      [
        {:jason, "~> 1.4.5"},
        {:zoi, "~> 0.18.11"},
        {:ex_doc, "~> 0.40.4", only: :dev, runtime: false},
        {:credo, "~> 1.7.19", only: [:dev, :test], runtime: false},
        {:dialyxir, "~> 1.4.8", only: :dev, runtime: false}
      ]
  end

  defp execution_plane_dep, do: workspace_dep({:execution_plane, "~> 0.3.0"})

  defp execution_plane_process_dep,
    do: workspace_dep({:execution_plane_process, "~> 0.3.1"})

  defp execution_plane_jsonrpc_dep,
    do: workspace_dep({:execution_plane_jsonrpc, "~> 0.2.0"})

  defp workspace_dep(committed) do
    if function_exported?(MixWorkspaceOpsBootstrap, :dep, 2),
      do: apply(MixWorkspaceOpsBootstrap, :dep, [committed, __DIR__]),
      else: committed
  end

  # The Execution Plane core package declares ordinary Hex Ground
  # dependencies. Until those parents are published, local and source
  # consumers override them at the top level. Hex mode omits these entries, so
  # they never enter the published CLI package dependency surface.
  defp local_ground_overrides({:execution_plane, opts}) when is_list(opts) do
    if local_ground_paths_available?() do
      [
        workspace_dep({:ground_plane_contracts, "~> 0.1.1", override: true}),
        workspace_dep({:ground_plane_persistence_policy, "~> 0.1.0", override: true})
      ]
    else
      []
    end
  end

  defp local_ground_overrides(_execution_plane), do: []

  defp local_ground_paths_available? do
    File.dir?(Path.expand("../ground_plane/core/ground_plane_contracts", __DIR__)) and
      File.dir?(Path.expand("../ground_plane/core/persistence_policy", __DIR__))
  end

  defp dialyzer do
    [
      plt_add_apps: [:mix, :ex_unit],
      plt_core_path: "priv/plts/core",
      plt_local_path: "priv/plts",
      flags: [:error_handling, :underspecs]
    ]
  end

  defp aliases do
    [
      ci: [
        "format --check-formatted",
        "compile --warnings-as-errors",
        "cmd ./scripts/atom_guard.sh",
        "cmd ./scripts/secrets_guard.sh",
        "credo --strict",
        "cmd env MIX_ENV=test mix test",
        "dialyzer"
      ],
      "test.live": ["test --include live"]
    ]
  end
end