Repository navigation
LOU-D3: loushy init scaffolds a runnable project in one command - #61
Merged
Merged
Conversation
Move the generator into the SDK (src/cli/init.ts + src/cli/init/) and add it to the loushy CLI. create-loushy-agent becomes a thin wrapper that runs the installed SDK's loushy init, so there is one generator behind both npx loushy init and npm create loushy-agent. The generated project depends on @loushy/build-ai-agent by caret range of the generating SDK version (read from its own package.json); --sdk-path / LOUSHY_SDK_PATH keeps local development and the e2e test on a packed tarball. Templates: minimal, tools, yaml. Flags: --provider, --template, --yes, --no-install, --no-git, --package-manager, --force.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Resolve providerSpec.ts (keep detectProviderFromEnv and main's peerInstallCommand); with provider packages now loaded lazily, generated projects depend only on the chosen provider's package.
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
loushy init [dir] [--provider openai|anthropic|openrouter|ollama] [--template minimal|tools|yaml] [--yes] [--no-install] [--no-git] [--package-manager npm|pnpm|yarn|bun] [--force] [--sdk-path <dir|tarball>]scaffolds a runnable project in one command, installs dependencies and runsgit init.Generated project (ESM, TypeScript strict):
package.json(scriptsdev,test,typecheck,doctor),tsconfig.json,.gitignore,.env.examplewith the chosen provider's key name, a README with the next 3 commands,src/agent.ts(createAgent({ model, instructions })plusdefineToolexample tool(s)),src/agent.test.ts(usesmockModelfrom/testing, passes offline),src/index.ts(terminal chat fornpm run dev). Theyamltemplate shipsagent.yamlinstead (anddevisloushy dev agent.yaml). Next steps (cd, set the key,npm run dev) are printed at the end.prompts.--yesor no TTY: defaults (minimal, provider auto-detected from the API key env var viaproviderSpec.ts, else openai).--force.--package-manager, elsenpm_config_user_agent, else npm.--sdk-path <checkout|.tgz>/LOUSHY_SDK_PATHis the documented local-dev escape hatch: a checkout isnpm packed, a tarball is copied, and the project depends onfile:./<tarball>.findSdkRoot()is gone.Why / design choice
One generator, two front doors. The logic lives in the SDK (
src/cli/init.ts+src/cli/init/), because the SDK shipsbin/+dist/, sonpx loushy initworks from the published SDK with no sibling checkout.create-loushy-agentis now a ~25-line wrapper that depends on@loushy/build-ai-agent(same version line) and spawns itsloushy initwith the same args, sonpm create loushy-agentworks from the published scaffolder with zero duplicated code. The alternative (SDK importing the scaffolder's build) would make the SDK depend on a package that depends on it, and the SDK'sfileswould not include the scaffolder. Trade-off:npm create loushy-agentnow pulls the SDK as a dependency.How verified (merged origin/main 995f649 immediately before; all re-run on the merged result)
npx tsc --noEmit: cleannpm run lint: 0 errors (433 warnings, none from the new files)npm run buildandnpm run build --workspace=packages/create-loushy-agent: successnpm run test:coverage: Test Files 120 passed (120), Tests 1722 passed, 4 skipped; thresholds met. Includes the rewritten e2e (about 50s): scaffolds into a temp dir with--sdk-path(packs the local SDK),initruns the realnpm install, thennpm run typecheckand the generatednpm test(2 passed) run offline with provider env vars stripped.npm run fallow: exit 0, no issues, no duplicationnpm run docs:verify-snippets: all 57 snippets type-check;npm run test:types: no errors;npm run docs:llms:check: ok (llms files regenerated)yamlproject's test passes.Notes for reviewer
package.jsonaddsprompts(dependency) and@types/prompts(devDependency) becauseprompts.tsmoved into the SDK;package-lock.jsonupdated accordingly.packages/create-loushy-agent/package.json: droppedprompts/@types/prompts/staletemplatesinfiles, added the@loushy/build-ai-agentdependency.bin/loushy.js(newinitcommand),tsup.config.ts(entrycli/init),.fallowrc.json(entry glob),src/providers/providerSpec.ts(addsdefaultModeltoProviderInfoanddetectProviderFromEnv()).packages/create-loushy-agent/src/{prompts,template}.tsandprompts.test.tsmoved tosrc/cli/init/(template.ts becamesdkDependency.ts);cli.integration.test.tsandtemplate.env.test.tsreplaced bysrc/cli/init.test.tsandpackages/create-loushy-agent/src/index.test.ts. The old create-loushy-agent flags (--name,--dir,--tools) are replaced byinit's positional dir and--template; the package was never published.docs/quick-start.mdleads with "Start a new project", README Quickstart/CLI anddocs/installation.mdupdated; nothing claims the package is published and no badges added. Note a barenpx loushy initonly resolves the SDK's bin once the SDK is installed (an unrelatedloushypackage may exist on the registry), so the quick start also givesnpx @loushy/build-ai-agent init my-agent.packages/create-loushy-agent/package-lock.jsonis stale (pre-existing, unused by the workspace install); left untouched.🤖 Generated with Claude Code