feat(think): add create-think package and starter templates#1695
Merged
Conversation
Introduce `create-think` (`npm create think`) and a top-level `think-starters/` directory of complete, runnable starter apps, and rework `think init` to scaffold from them via a `--template` flag. Templates - New `think-starters/` workspace members (added to pnpm-workspace.yaml): - basic — minimal Think chat agent + small React UI - personal-assistant — persistent memory (configureSession) + scheduled tasks - coding-agent — workspace file tools + a coding skill (Worker Loader) - customer-support — custom tools + an escalation skill - Each is a self-contained, deployable Workers app (own package.json, wrangler.jsonc, vite.config.ts, agents/**, generated think.d.ts) and uses `workspace:*` deps so they build/test in CI as in-repo examples. think init / @cloudflare/think/cli - Add `--template` (default `basic`) and `--ref` flags to `think init`. - Replace the single inline scaffolder with a template-fetch model: copy from the local `think-starters/` dir when in-repo, otherwise use an injected remote fetcher. On fetch, set the package name and rewrite `workspace:*` deps to published ranges so the app installs standalone. - Expose `initCommand` and template helpers via a new side-effect-free `@cloudflare/think/cli` export (added to build entries + package exports). create-think - New `create-think` package: a thin bin that forwards argv to `initCommand` and injects a degit (tiged) fetcher pulling starters from `cloudflare/agents/think-starters`. Tests / housekeeping - Rewrite CLI init tests for the template model: default template, all templates + workspace-version rewrite, unknown template, injected fetcher (ref/name handling), non-empty/outside-root guards, existing-app no-op, dry-run, and inspect/types on a generated app. - Normalize pending changesets to patch bumps; add changesets for `@cloudflare/think` and the new `create-think` package.
🦋 Changeset detectedLatest commit: fc42b5e The changes in this PR will be included in the next version bump. This PR includes changesets to release 8 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
agents
@cloudflare/ai-chat
@cloudflare/codemode
create-think
hono-agents
@cloudflare/shell
@cloudflare/think
@cloudflare/voice
@cloudflare/worker-bundler
commit: |
- finalizeTemplate now also rewrites the `name` field in the scaffolded wrangler config to the user's project name (targeted replacement that preserves JSONC comments/formatting), so apps no longer all deploy under the shared template Worker name (e.g. "think-basic-starter"). Renamed finalizeTemplatePackageJson -> finalizeTemplate. - Remove the `--route-prefix` option from `think init`: the template-based scaffolder no longer generates config, so the flag was accepted but silently ignored. Also drop the now-unused `routePrefix` from InitCommandOptions and refresh the stale init command description. - Extend the all-templates init test to assert the Worker name is rewritten.
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.
Summary
Adds
create-think(npm create think) plus a top-levelthink-starters/directory of complete, runnable starter apps, and reworksthink initto scaffold from them via a--templateflag.Templates
New
think-starters/workspace members (added topnpm-workspace.yaml):configureSession) + scheduled tasksEach is a self-contained, deployable Workers app (own
package.json,wrangler.jsonc,vite.config.ts,agents/**, generatedthink.d.ts) and usesworkspace:*deps so they build/test in CI and double as in-repo examples.think init/@cloudflare/think/cli--template(defaultbasic) and--refflags tothink init.think-starters/dir when in-repo, otherwise use an injected remote fetcher. On fetch, set the package name and rewriteworkspace:*deps to published ranges so the app installs standalone.initCommandand template helpers via a new side-effect-free@cloudflare/think/cliexport.create-thinkinitCommandand injects a degit (tiged) fetcher pulling starters fromcloudflare/agents/think-starters.Tests / housekeeping
@cloudflare/thinkand the newcreate-thinkpackage.Notes for reviewers
cloudflare/agents/think-starters/<t>#main, sonpm create thinkagainst the registry only works once these land onmain. Local in-repo scaffolding works today.latestafter theworkspace:*rewrite — flagged as a possible follow-up to pin the exact shipped version for reproducibility.Checks
pnpm run checkgreen (102 projects typecheck + sherif + exports + format + lint);@cloudflare/thinktest suite passes.