Repository navigation
LOU-D1: five-line hello world - #50
Merged
Merged
Conversation
createAgent now accepts a 'provider/model' string (resolved with the existing resolveProvider, key from the conventional env var) as an alternative to a provider instance. With neither, it uses LOUSHY_MODEL, else the first present key (OPENAI, ANTHROPIC, OPENROUTER, OLLAMA_BASE_URL), else throws listing every fix. 'instructions' is the preferred, optional system prompt; 'prompt' stays as an alias; both is an error. Options are proper unions (no any). Errors: missing key, unknown prefix (supported list + closest match by edit distance), missing optional peer (exact npm install), nothing configured. Docs and the create-loushy-agent template lead with the short form; verify-docs-snippets gains a no-run fence flag for snippets that need a real key. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
createAgentnow supports a five-line hello world:model: 'provider/model'is an alternative toprovider. It is resolved with the existingresolveProvider, with the key read from the provider's env var.providerandmodel,provideris used andmodelbecomes the per-agent model setting (agent.settings.model). This is documented.LOUSHY_MODEL. Otherwise the first provider with a key set is used, in the order OPENAI_API_KEY, ANTHROPIC_API_KEY, OPENROUTER_API_KEY, OLLAMA_BASE_URL. If none is set, it throws an error listing every fix.instructionsis the preferred system prompt and is optional (defaults to "You are a helpful assistant.").promptremains a working alias, and passing both is an error that names both.CreateAgentBase & CreateAgentInstructions & CreateAgentModelSource, so editors showmodelandprovideras alternatives. Noany.createAgent: OPENAI_API_KEY is not set. Set it in your environment, or pass a provider instance: createAgent({ provider: ... }).npm install <pkg>@<range>command.agent.send()still returnsExecutionResultwith a typedtext. Norunalias was added.Why
Hello world previously needed two imports and the
resolveProviderconcept. Competitors need two files (eve) or about 10 lines (open-harness).How verified
Run on the result of merging origin/main at 89d199f:
npx tsc --noEmit: clean.npm run lint: 0 errors, 425 warnings, none from the changed files (pre-existing).npm run buildand the create-loushy-agent build: both succeed.npm run test:coverage: Test Files 98 passed (98), Tests 1300 passed | 3 skipped (1303). Thresholds met.npm run fallow: exit 0.npm run docs:verify-snippets: all 35 snippet(s) type-check against src/; 6 also run cleanly.packages/create-loushy-agent,npx vitest run: Test Files 4 passed, Tests 8 passed.Notes for reviewer
src/providers/providerSpec.tsis not exported from the barrel.resolveProvideris now a thin wrapper, so the same messages are used with a caller prefix (resolveProvider:orcreateAgent:).resolveProvider: a missing API key for openai, anthropic or openrouter now throws immediately instead of passingundefinedthrough. Ollama still needs no env var.scripts/verify-docs-snippets.tsgains ano-runfence flag. It is type-checked in both stages but not executed.createAgent({ provider: undefined as any })now stubs the provider env vars and drops theany, becauseprovideris now optional by design.create-loushy-agenttemplate now generatesmodel: '<provider>/<model>', instructions: ....npm installhint covers the factory path only. A follow-up ticket is worth filing.🤖 Generated with Claude Code