Skip to content

feat(think): add create-think package and starter templates#1695

Merged
threepointone merged 2 commits into
mainfrom
create-think-and-starters
Jun 7, 2026
Merged

feat(think): add create-think package and starter templates#1695
threepointone merged 2 commits into
mainfrom
create-think-and-starters

Conversation

@threepointone
Copy link
Copy Markdown
Contributor

@threepointone threepointone commented Jun 7, 2026

Summary

Adds create-think (npm create think) plus a top-level think-starters/ directory of complete, runnable starter apps, and reworks 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 and double 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.

create-think

  • New 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, guards, no-op, dry-run, inspect/types on generated app).
  • Normalize pending changesets to patch bumps; add changesets for @cloudflare/think and the new create-think package.

Notes for reviewers

  • Remote fetch resolves cloudflare/agents/think-starters/<t>#main, so npm create think against the registry only works once these land on main. Local in-repo scaffolding works today.
  • Scaffolded apps currently pin SDK deps to latest after the workspace:* rewrite — flagged as a possible follow-up to pin the exact shipped version for reproducibility.

Checks

pnpm run check green (102 projects typecheck + sherif + exports + format + lint); @cloudflare/think test suite passes.


Open in Devin Review

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-bot
Copy link
Copy Markdown

changeset-bot Bot commented Jun 7, 2026

🦋 Changeset detected

Latest commit: fc42b5e

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 8 packages
Name Type
@cloudflare/think Patch
agents Patch
@cloudflare/worker-bundler Patch
create-think Patch
think-basic-starter Patch
think-coding-agent-starter Patch
think-customer-support-starter Patch
think-personal-assistant-starter Patch

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

Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 2 potential issues.

View 5 additional findings in Devin Review.

Open in Devin Review

Comment thread packages/think/src/cli/templates.ts Outdated
Comment thread packages/think/src/cli/init.ts Outdated
@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Jun 7, 2026

Open in StackBlitz

agents

npm i https://pkg.pr.new/cloudflare/agents@1695

@cloudflare/ai-chat

npm i https://pkg.pr.new/cloudflare/agents/@cloudflare/ai-chat@1695

@cloudflare/codemode

npm i https://pkg.pr.new/cloudflare/agents/@cloudflare/codemode@1695

create-think

npm i https://pkg.pr.new/cloudflare/agents/create-think@1695

hono-agents

npm i https://pkg.pr.new/cloudflare/agents/hono-agents@1695

@cloudflare/shell

npm i https://pkg.pr.new/cloudflare/agents/@cloudflare/shell@1695

@cloudflare/think

npm i https://pkg.pr.new/cloudflare/agents/@cloudflare/think@1695

@cloudflare/voice

npm i https://pkg.pr.new/cloudflare/agents/@cloudflare/voice@1695

@cloudflare/worker-bundler

npm i https://pkg.pr.new/cloudflare/agents/@cloudflare/worker-bundler@1695

commit: fc42b5e

- 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.
@threepointone threepointone merged commit b545e86 into main Jun 7, 2026
4 checks passed
@threepointone threepointone deleted the create-think-and-starters branch June 7, 2026 13:35
@github-actions github-actions Bot mentioned this pull request Jun 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant