### CouncilKit 30-second example: create council and deliberate Source: https://github.com/albertofettucini/councilkit/blob/main/README.md Creates a Council with three advisors, each pairing a backend (Claude, GPT, Gemini) with a persona (analyst, practitioner, skeptic), then calls deliberate with a question. Prints the synthesis, divergence score, and dissent answer. Requires importing CouncilKit and having API keys configured for the backends. ```swift import CouncilKit // Three advisors: each a backend + a persona, for real divergence. let council = Council(advisors: [ Advisor(backend: .claude, persona: .analyst), Advisor(backend: .gpt, persona: .practitioner), Advisor(backend: .gemini, persona: .skeptic), ]) let result = try await council.deliberate( "Should a two-person startup adopt microservices on day one?" ) print(result.synthesis ?? "") // decision-ready distillation print(result.divergence?.score ?? 0) // 0–100: how far apart they landed print(result.dissent?.answer ?? "") // the outlier's full case, if there is one ``` -------------------------------- ### Fail on high disagreement with --fail-above Source: https://github.com/albertofettucini/councilkit/blob/main/README.md Sets a failure threshold for council disagreement. The command exits with status 1 if the council's divergence exceeds the specified value (40 in this example). ```sh council "..." --fail-above 40 # exit 1 if the council diverges too much ``` -------------------------------- ### Create Advisor with custom OpenAI-compatible endpoint Source: https://github.com/albertofettucini/councilkit/blob/main/README.md Use this snippet to point an advisor at any OpenAI-compatible server (e.g., llama.cpp, LM Studio, vLLM). The endpoint and key are held transiently for the call and never written to disk or Keychain. The apiKey is optional for servers that don't require auth. ```swift let advisor = Advisor(backend: .custom1, model: "my-model", apiKey: serverKey, // optional — some servers need auth endpoint: URL(string: "http://localhost:8080")!) ``` -------------------------------- ### Create Council with keyProvider closure Source: https://github.com/albertofettucini/councilkit/blob/main/README.md Use this snippet to create a Council instance with advisors and a custom key provider. The keyProvider closure is used when an Advisor has no apiKey; returning nil falls back to the Keychain. This is handy off macOS, in CI, or with your own secrets store. ```swift let council = Council( advisors: [Advisor(backend: .claude, persona: .analyst, apiKey: claudeKey)], keyProvider: { backend in myVault[backend] } // used when an Advisor has no apiKey; nil ⇒ Keychain ) ``` -------------------------------- ### Run a council with multiple model providers Source: https://github.com/albertofettucini/councilkit/blob/main/README.md Invokes the council CLI with a prompt and specifies the model providers to use as seats. The --seats flag accepts a comma-separated list of model identifiers. ```sh council "should we ship now or wait?" --seats claude,gpt,gemini ``` -------------------------------- ### Review a file with structured JSON output Source: https://github.com/albertofettucini/councilkit/blob/main/README.md Runs a council review on a specified file and outputs structured JSON conforming to the schema council.cli.v1. The --file flag points to the file to review, and --json enables structured output. ```sh council "review this" --file design.md --json # structured output (schema council.cli.v1) ``` -------------------------------- ### Stream council events with for-await-in Source: https://github.com/albertofettucini/councilkit/blob/main/README.md Use this snippet to iterate over streaming events from a council. Each event type corresponds to a specific stage: token, advisorFailed, critique, divergence, synthesis, or failure. Handle each case to react to live answers, peer reviews, divergence reports, and final synthesis. ```swift for await event in council.stream("…") { switch event { case .token(let advisor, let text): break // live answer, per advisor case .advisorFailed(let advisor, let error): break // an advisor dropped out (non-terminal) case .critique(let advisor, let text): break // blind peer review case .divergence(let report): break // report.score / .camps / .outlier / .analysis case .synthesis(let text): break // final distillation case .failure(let error): break // setup / no-answer failure (terminal) } } ``` -------------------------------- ### Pipe a document via stdin Source: https://github.com/albertofettucini/councilkit/blob/main/README.md Pipes the content of a file into the council CLI via standard input, allowing the council to review the piped content without specifying a file flag. ```sh cat design.md | council "review this" # …or pipe it in on stdin ``` -------------------------------- ### Add CouncilKit as a Swift Package Manager dependency Source: https://github.com/albertofettucini/councilkit/blob/main/README.md Add this package dependency to your Package.swift to use CouncilKit. It's pre-1.0, so pin to an exact minor version to avoid breaking changes. ```swift .package(url: "https://github.com/albertofettucini/CouncilKit.git", .upToNextMinor(from: "0.1.0")) ``` -------------------------------- ### Set API key in Keychain with Council.setKey Source: https://github.com/albertofettucini/councilkit/blob/main/README.md Use this snippet to store a provider API key in the macOS Keychain under your app's bundle identifier. The key is scoped to the writing process, so save it from your own binary or pass it directly in code. ```swift try Council.setKey("sk-…", for: .claude) // → the Keychain, under YOUR app's bundle id ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.