# `Spectre.Stack`
[🔗](https://github.com/elchemista/spectre/blob/0.4.0/lib/spectre/stack.ex#L1)

Compile-time installer and resolver for Spectre packages.

A Stack describes one immutable environment. Packages contribute manifests,
local DSL compilers, optional tool descriptors and caller-owned resources.
Secrets and live clients belong in runtime configuration, not this definition.

    defmodule MyApp.AI do
      use Spectre.Stack

      install MyApp.Inference do
        provider :openrouter, MyApp.OpenRouter
        model :fast, id: "small-model"
      end
    end

Selecting `stack: MyApp.AI` in `Spectre.Agent` connects package-declared Agent
extensions. Selecting `tools: MyApp.AI` in `Spectre.Server` generates private
helpers from installed `c:Spectre.Stack.Installable.tools/1` descriptors.
Packages do not need to export those helper functions themselves.

Helpers append commands; runtime adapters resolve named Stack resources,
return cognitive results or normalize bound consequences to GAM proposals.
Installation and `bind:` configuration do not grant authority. Governed
operations need authenticated host scope, contracts, mandate and executors.
See the Stack Tools and GAM guides.

`Spectre.Stack.Runtime` supervises declared resources when explicitly started
by the host. Pass its stable name as `stack_runtime:` to resource-using Servers.
Standalone package APIs and older Instance/Run integrations remain separate
compatibility paths.

# `__using__`
*macro* 

Initializes a Stack definition.

# `config`

```elixir
@spec config(module(), term()) :: {:ok, map() | keyword()} | {:error, term()}
```

Returns immutable configuration for a package bound to an Agent.

# `definition`

```elixir
@spec definition(module()) :: Spectre.Stack.Definition.t()
```

Returns the immutable definition for a Stack module.

# `install`
*macro* 

Installs and compiles one package.

# `install`
*macro* 

Installs a package with explicit options and a package-local DSL block.

# `installation`

```elixir
@spec installation(module(), term()) ::
  {:ok, Spectre.Stack.Installation.t()} | {:error, term()}
```

Returns the immutable installation selected through an Agent's Stack.

# `resolve`

```elixir
@spec resolve(module(), Spectre.Stack.Definition.capability_kind(), term()) ::
  {:ok, Spectre.Stack.Ref.t()} | {:error, term()}
```

Resolves a logical capability from a Stack module.

# `start_link`

```elixir
@spec start_link(
  module(),
  keyword()
) :: Supervisor.on_start()
```

Starts a caller-owned runtime for a Stack.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
