create-eidentic 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +45 -0
  3. package/dist/index.js +672 -0
  4. package/package.json +49 -0
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or Derivative
95
+ Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work, excluding
103
+ those notices that do not pertain to any part of the Derivative
104
+ Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and do
117
+ not modify the License. You may add Your own attribution notices
118
+ within Derivative Works that You distribute, alongside or as an
119
+ addendum to the NOTICE text from the Work, provided that such
120
+ additional attribution notices cannot be construed as modifying
121
+ the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2026 Baran Özdemir
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,45 @@
1
+ # create-eidentic
2
+
3
+ Scaffold a new Eidentic agent project with a single command — choose your model provider
4
+ and project template, then get a ready-to-run TypeScript project with an agent, store,
5
+ and dev configuration wired up.
6
+
7
+ ## Usage
8
+
9
+ ```bash
10
+ npm create eidentic@latest my-agent
11
+ # or
12
+ npx create-eidentic my-agent
13
+ ```
14
+
15
+ Follow the interactive prompts to choose:
16
+
17
+ - **Provider:** anthropic | openai | google | deepseek | mistral
18
+ - **Template:**
19
+ - `default` — bare Node.js agent script (no framework)
20
+ - `nextjs-chat` — Next.js App Router chat UI with `@eidentic/nextjs` + `useChat`
21
+ - `bun-agent` — Bun-native agent script with `@eidentic/sqlite`
22
+
23
+ ### Non-interactive
24
+
25
+ ```bash
26
+ npm create eidentic@latest my-agent -- --provider anthropic --template nextjs-chat
27
+ ```
28
+
29
+ ### After scaffolding
30
+
31
+ ```bash
32
+ cd my-agent
33
+ pnpm install
34
+ # Set your API key, e.g.:
35
+ export ANTHROPIC_API_KEY=sk-ant-...
36
+ pnpm dev
37
+ ```
38
+
39
+ ## Links
40
+
41
+ - [GitHub](https://github.com/eidentic/eidentic)
42
+ - [Issue tracker](https://github.com/eidentic/eidentic/issues)
43
+ - [Root README](https://github.com/eidentic/eidentic#readme)
44
+
45
+ Apache-2.0
package/dist/index.js ADDED
@@ -0,0 +1,672 @@
1
+ #!/usr/bin/env node
2
+
3
+ // src/index.ts
4
+ import { intro, outro, text, select, confirm, isCancel, cancel } from "@clack/prompts";
5
+ import pc from "picocolors";
6
+ import { resolve } from "node:path";
7
+
8
+ // src/scaffold.ts
9
+ import { mkdirSync, writeFileSync, existsSync, readdirSync } from "node:fs";
10
+ import { join, basename } from "node:path";
11
+ var PROVIDERS = {
12
+ anthropic: {
13
+ package: "@ai-sdk/anthropic",
14
+ envVar: "ANTHROPIC_API_KEY",
15
+ importLine: 'import { anthropic } from "@ai-sdk/anthropic";',
16
+ modelId: "claude-sonnet-4-5",
17
+ providerFn: "anthropic"
18
+ },
19
+ openai: {
20
+ package: "@ai-sdk/openai",
21
+ envVar: "OPENAI_API_KEY",
22
+ importLine: 'import { openai } from "@ai-sdk/openai";',
23
+ modelId: "gpt-4o",
24
+ providerFn: "openai"
25
+ },
26
+ google: {
27
+ package: "@ai-sdk/google",
28
+ envVar: "GOOGLE_GENERATIVE_AI_API_KEY",
29
+ importLine: 'import { google } from "@ai-sdk/google";',
30
+ modelId: "gemini-2.5-pro",
31
+ providerFn: "google"
32
+ },
33
+ deepseek: {
34
+ package: "@ai-sdk/deepseek",
35
+ envVar: "DEEPSEEK_API_KEY",
36
+ importLine: 'import { deepseek } from "@ai-sdk/deepseek";',
37
+ modelId: "deepseek-chat",
38
+ providerFn: "deepseek"
39
+ },
40
+ mistral: {
41
+ package: "@ai-sdk/mistral",
42
+ envVar: "MISTRAL_API_KEY",
43
+ importLine: 'import { mistral } from "@ai-sdk/mistral";',
44
+ modelId: "mistral-large-latest",
45
+ providerFn: "mistral"
46
+ }
47
+ };
48
+ var TSCONFIG = `{
49
+ "compilerOptions": {
50
+ "target": "ESNext",
51
+ "module": "ESNext",
52
+ "moduleResolution": "bundler",
53
+ "strict": true,
54
+ "esModuleInterop": true,
55
+ "skipLibCheck": true,
56
+ "verbatimModuleSyntax": true,
57
+ "noEmit": true
58
+ },
59
+ "include": ["src"]
60
+ }
61
+ `;
62
+ var GITIGNORE = `node_modules
63
+ dist
64
+ *.sqlite
65
+ .env
66
+ `;
67
+ function envExample(providerMeta) {
68
+ return `# Get a key at https://console.anthropic.com (or your provider's dashboard)
69
+ ${providerMeta.envVar}=
70
+ `;
71
+ }
72
+ function agentTs(providerMeta) {
73
+ return `import { Agent, AIModel, SqliteStore, createTool } from "eidentic";
74
+ ${providerMeta.importLine}
75
+ import { z } from "zod";
76
+
77
+ // Persistent, event-sourced session store (durable resume comes for free).
78
+ const store = new SqliteStore("./eidentic.sqlite");
79
+ await store.migrate();
80
+
81
+ // A tiny example tool \u2014 replace with your own.
82
+ const getTime = createTool({
83
+ id: "get_time",
84
+ description: "Get the current server time as an ISO string.",
85
+ inputSchema: z.object({}),
86
+ execute: async () => ({ now: new Date().toISOString() }),
87
+ });
88
+
89
+ const agent = new Agent({
90
+ id: "my-agent",
91
+ instructions: "You are a helpful assistant. Use tools when relevant, then answer concisely.",
92
+ model: new AIModel(${providerMeta.providerFn}("${providerMeta.modelId}")), // needs ${providerMeta.envVar}
93
+ tools: [getTime],
94
+ store,
95
+ });
96
+
97
+ for await (const ev of agent.query("What time is it right now?", { sessionId: "session-1" })) {
98
+ if (ev.type === "result") console.log("\\n" + String(ev.output));
99
+ }
100
+
101
+ await store.close();
102
+ `;
103
+ }
104
+ function packageJson(name, providerMeta) {
105
+ return JSON.stringify(
106
+ {
107
+ name,
108
+ version: "0.1.0",
109
+ private: true,
110
+ type: "module",
111
+ scripts: { dev: "tsx src/agent.ts", typecheck: "tsc --noEmit" },
112
+ dependencies: {
113
+ eidentic: "latest",
114
+ ai: "^6.0.0",
115
+ [providerMeta.package]: "^1.0.0",
116
+ zod: "^4.0.0"
117
+ },
118
+ devDependencies: { tsx: "^4.19.0", typescript: "^5.9.0" }
119
+ },
120
+ null,
121
+ 2
122
+ ) + "\n";
123
+ }
124
+ function readme(name) {
125
+ return `# ${name}
126
+
127
+ A [Eidentic](https://github.com/eidentic/eidentic) agent project.
128
+
129
+ ## Quickstart
130
+
131
+ \`\`\`bash
132
+ npm install
133
+ cp .env.example .env # add your API key
134
+ npm run dev
135
+ \`\`\`
136
+
137
+ ## Add optional power-ups
138
+
139
+ Eidentic's adapters are \xE0 la carte \u2014 install only what you use:
140
+
141
+ \`\`\`bash
142
+ npm i @eidentic/pgvector # PostgreSQL vector memory
143
+ npm i @eidentic/lancedb # embedded LanceDB vector memory
144
+ npm i @eidentic/transformers # local embeddings / reranking
145
+ npm i @eidentic/mcp # connect MCP servers
146
+ npm i @eidentic/e2b # sandboxed code execution
147
+ npm i @eidentic/eval # agent evaluation harness
148
+ \`\`\`
149
+ `;
150
+ }
151
+ function nextjsChatRoute(providerMeta) {
152
+ return `import { Agent, AIModel } from "eidentic";
153
+ import { LibsqlStore } from "@eidentic/libsql";
154
+ import { withEidentic } from "@eidentic/nextjs";
155
+ ${providerMeta.importLine}
156
+
157
+ // LibsqlStore is bundler-safe (no native addon). "file:eidentic.db" persists
158
+ // sessions to a local SQLite file via @libsql/client.
159
+ const store = new LibsqlStore("file:eidentic.db");
160
+ // Run migrations before the first request (top-level await is valid in Next.js
161
+ // App Router route modules, which are treated as ESM with async context).
162
+ await store.migrate();
163
+
164
+ const agent = new Agent({
165
+ id: "chat-agent",
166
+ instructions: "You are a helpful assistant.",
167
+ model: new AIModel(${providerMeta.providerFn}("${providerMeta.modelId}")),
168
+ store,
169
+ });
170
+
171
+ // withEidentic wraps the agent in a Next.js App Router POST handler.
172
+ // Default protocol is "ai-sdk-ui" \u2014 compatible with useChat from @ai-sdk/react.
173
+ export const POST = withEidentic(agent);
174
+
175
+ // Eidentic requires the Node.js runtime (crypto, LibSQL, etc.).
176
+ export const runtime = "nodejs";
177
+ `;
178
+ }
179
+ function nextjsChatPage() {
180
+ return `"use client";
181
+
182
+ import { useChat } from "@ai-sdk/react";
183
+
184
+ export default function ChatPage() {
185
+ const { messages, input, handleInputChange, handleSubmit, status } = useChat({
186
+ api: "/api/chat",
187
+ });
188
+
189
+ return (
190
+ <main className="flex flex-col items-center min-h-screen p-8 max-w-2xl mx-auto">
191
+ <h1 className="text-2xl font-bold mb-6">Eidentic Chat</h1>
192
+
193
+ {/* Message list */}
194
+ <div className="flex flex-col gap-4 w-full flex-1 mb-6">
195
+ {messages.map((m) => (
196
+ <div
197
+ key={m.id}
198
+ className={\`rounded-lg px-4 py-2 text-sm max-w-[85%] whitespace-pre-wrap \${
199
+ m.role === "user"
200
+ ? "self-end bg-blue-600 text-white"
201
+ : "self-start bg-gray-100 text-gray-900"
202
+ }\`}
203
+ >
204
+ {m.parts
205
+ .filter((p) => p.type === "text")
206
+ .map((p, i) => (
207
+ // @ts-expect-error \u2014 text part type is narrowed
208
+ <span key={i}>{p.text}</span>
209
+ ))}
210
+ </div>
211
+ ))}
212
+ {status === "streaming" && (
213
+ <div className="self-start text-gray-400 text-sm italic">Thinking\u2026</div>
214
+ )}
215
+ </div>
216
+
217
+ {/* Input form */}
218
+ <form onSubmit={handleSubmit} className="flex gap-2 w-full">
219
+ <input
220
+ className="flex-1 rounded-lg border border-gray-300 px-4 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-blue-500"
221
+ placeholder="Type a message\u2026"
222
+ value={input}
223
+ onChange={handleInputChange}
224
+ disabled={status === "streaming"}
225
+ />
226
+ <button
227
+ type="submit"
228
+ disabled={status === "streaming" || !input.trim()}
229
+ className="rounded-lg bg-blue-600 text-white px-4 py-2 text-sm font-medium disabled:opacity-50 hover:bg-blue-700 transition-colors"
230
+ >
231
+ Send
232
+ </button>
233
+ </form>
234
+ </main>
235
+ );
236
+ }
237
+ `;
238
+ }
239
+ function nextjsConfig() {
240
+ return `import { eidenticNextConfig } from "@eidentic/nextjs";
241
+ import type { NextConfig } from "next";
242
+
243
+ const nextConfig: NextConfig = {};
244
+
245
+ export default eidenticNextConfig(nextConfig);
246
+ `;
247
+ }
248
+ function nextjsPackageJson(name, providerMeta) {
249
+ return JSON.stringify(
250
+ {
251
+ name,
252
+ version: "0.1.0",
253
+ private: true,
254
+ scripts: {
255
+ dev: "next dev",
256
+ build: "next build",
257
+ start: "next start",
258
+ typecheck: "tsc --noEmit"
259
+ },
260
+ dependencies: {
261
+ eidentic: "latest",
262
+ "@eidentic/nextjs": "latest",
263
+ "@eidentic/libsql": "latest",
264
+ ai: "^6.0.0",
265
+ "@ai-sdk/react": "^1.0.0",
266
+ [providerMeta.package]: "^1.0.0",
267
+ next: "^15.0.0",
268
+ react: "^19.0.0",
269
+ "react-dom": "^19.0.0"
270
+ },
271
+ devDependencies: {
272
+ typescript: "^5.9.0",
273
+ "@types/node": "^22.0.0",
274
+ "@types/react": "^19.0.0",
275
+ "@types/react-dom": "^19.0.0"
276
+ }
277
+ },
278
+ null,
279
+ 2
280
+ ) + "\n";
281
+ }
282
+ function nextjsEnvLocalExample(providerMeta) {
283
+ return `# Copy this file to .env.local and fill in your key.
284
+ # Get a key at: https://console.anthropic.com (or your provider's dashboard)
285
+ ${providerMeta.envVar}=
286
+ `;
287
+ }
288
+ function nextjsReadme(name) {
289
+ return `# ${name}
290
+
291
+ A streaming AI chat app built with [Eidentic](https://github.com/eidentic/eidentic) + Next.js.
292
+
293
+ ## Quickstart
294
+
295
+ \`\`\`bash
296
+ npm install
297
+ cp .env.local.example .env.local # add your API key
298
+ npm run dev
299
+ \`\`\`
300
+
301
+ Open [http://localhost:3000](http://localhost:3000) to start chatting.
302
+
303
+ ## How it works
304
+
305
+ - **\`app/api/chat/route.ts\`** \u2014 Eidentic agent wrapped with \`withEidentic\` from \`@eidentic/nextjs\`.
306
+ Uses the default \`"ai-sdk-ui"\` protocol so the frontend can use \`useChat\` directly.
307
+ - **\`app/page.tsx\`** \u2014 Minimal chat UI using \`useChat\` from \`@ai-sdk/react\`.
308
+ - **\`next.config.ts\`** \u2014 \`eidenticNextConfig\` ensures native modules are not bundled by Webpack.
309
+ - **\`LibsqlStore("file:eidentic.db")\`** \u2014 Durable session store backed by a local SQLite file
310
+ via \`@libsql/client\` (no native addon, works in serverless/edge Node runtimes).
311
+
312
+ ## Add power-ups
313
+
314
+ \`\`\`bash
315
+ npm i @eidentic/pgvector # PostgreSQL vector memory
316
+ npm i @eidentic/lancedb # embedded LanceDB vector memory
317
+ npm i @eidentic/transformers # local embeddings / reranking
318
+ npm i @eidentic/mcp # connect MCP servers
319
+ npm i @eidentic/e2b # sandboxed code execution
320
+ npm i @eidentic/eval # agent evaluation harness
321
+ \`\`\`
322
+ `;
323
+ }
324
+ function nextjsGitignore() {
325
+ return `node_modules
326
+ .next
327
+ out
328
+ *.db
329
+ *.sqlite
330
+ .env.local
331
+ .env
332
+ `;
333
+ }
334
+ function nextjsTsConfig() {
335
+ return `{
336
+ "compilerOptions": {
337
+ "target": "ESNext",
338
+ "lib": ["dom", "dom.iterable", "esnext"],
339
+ "module": "ESNext",
340
+ "moduleResolution": "bundler",
341
+ "allowJs": true,
342
+ "strict": true,
343
+ "esModuleInterop": true,
344
+ "skipLibCheck": true,
345
+ "verbatimModuleSyntax": true,
346
+ "noEmit": true,
347
+ "jsx": "preserve",
348
+ "incremental": true,
349
+ "plugins": [{ "name": "next" }],
350
+ "paths": { "@/*": ["./*"] }
351
+ },
352
+ "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
353
+ "exclude": ["node_modules"]
354
+ }
355
+ `;
356
+ }
357
+ function bunAgentServer(providerMeta) {
358
+ return `import { Agent, AIModel } from "eidentic";
359
+ import { LibsqlStore } from "@eidentic/libsql";
360
+ import { createServer } from "@eidentic/server";
361
+ ${providerMeta.importLine}
362
+
363
+ // LibsqlStore is pure-JS and bundler-safe \u2014 works under Bun without native addons.
364
+ const store = new LibsqlStore("file:eidentic.db");
365
+ await store.migrate();
366
+
367
+ const agent = new Agent({
368
+ id: "my-agent",
369
+ instructions: "You are a helpful assistant.",
370
+ model: new AIModel(${providerMeta.providerFn}("${providerMeta.modelId}")), // needs ${providerMeta.envVar}
371
+ store,
372
+ });
373
+
374
+ // createServer returns a Hono app \u2014 Bun can serve it directly.
375
+ const app = createServer({ agents: { "my-agent": agent } });
376
+
377
+ // Bun.serve accepts any fetch-compatible handler (Hono implements the interface).
378
+ const server = Bun.serve({
379
+ port: Number(process.env["PORT"] ?? 3000),
380
+ fetch: app.fetch,
381
+ });
382
+
383
+ console.log(\`Eidentic agent running at http://localhost:\${server.port}\`);
384
+ console.log("POST /v1/agents/my-agent/query \u2014 SSE stream");
385
+ `;
386
+ }
387
+ function bunAgentPackageJson(name, providerMeta) {
388
+ return JSON.stringify(
389
+ {
390
+ name,
391
+ version: "0.1.0",
392
+ private: true,
393
+ type: "module",
394
+ scripts: {
395
+ dev: "bun run --watch src/server.ts",
396
+ start: "bun run src/server.ts",
397
+ typecheck: "tsc --noEmit"
398
+ },
399
+ dependencies: {
400
+ eidentic: "latest",
401
+ "@eidentic/server": "latest",
402
+ "@eidentic/libsql": "latest",
403
+ ai: "^6.0.0",
404
+ [providerMeta.package]: "^1.0.0",
405
+ hono: "^4.0.0"
406
+ },
407
+ devDependencies: {
408
+ "bun-types": "latest",
409
+ typescript: "^5.9.0"
410
+ }
411
+ },
412
+ null,
413
+ 2
414
+ ) + "\n";
415
+ }
416
+ function bunfig() {
417
+ return `# Bun configuration
418
+ [install]
419
+ # Use the lockfile from the project root
420
+ production = false
421
+ `;
422
+ }
423
+ function bunAgentTsConfig() {
424
+ return `{
425
+ "compilerOptions": {
426
+ "target": "ESNext",
427
+ "lib": ["ESNext"],
428
+ "module": "ESNext",
429
+ "moduleResolution": "bundler",
430
+ "types": ["bun-types"],
431
+ "strict": true,
432
+ "esModuleInterop": true,
433
+ "skipLibCheck": true,
434
+ "verbatimModuleSyntax": true,
435
+ "noEmit": true
436
+ },
437
+ "include": ["src"]
438
+ }
439
+ `;
440
+ }
441
+ function bunAgentEnvExample(providerMeta) {
442
+ return `# Copy this file to .env and fill in your key.
443
+ # Get a key at: https://console.anthropic.com (or your provider's dashboard)
444
+ ${providerMeta.envVar}=
445
+ PORT=3000
446
+ `;
447
+ }
448
+ function bunAgentGitignore() {
449
+ return `node_modules
450
+ *.db
451
+ *.sqlite
452
+ .env
453
+ `;
454
+ }
455
+ function bunAgentReadme(name) {
456
+ return `# ${name}
457
+
458
+ A [Eidentic](https://github.com/eidentic/eidentic) agent server running natively on Bun.
459
+
460
+ ## Quickstart
461
+
462
+ \`\`\`bash
463
+ bun install
464
+ cp .env.example .env # add your API key
465
+ bun run dev
466
+ \`\`\`
467
+
468
+ The server starts at http://localhost:3000.
469
+
470
+ ## Query the agent
471
+
472
+ \`\`\`bash
473
+ curl -N -X POST http://localhost:3000/v1/agents/my-agent/query \\
474
+ -H "Content-Type: application/json" \\
475
+ -d '{"input":"Hello!","sessionId":"demo"}'
476
+ \`\`\`
477
+
478
+ ## How it works
479
+
480
+ - **\`src/server.ts\`** \u2014 Eidentic agent wrapped with \`createServer\` from \`@eidentic/server\`
481
+ (returns a Hono app), served via \`Bun.serve\`.
482
+ - **\`LibsqlStore("file:eidentic.db")\`** \u2014 Durable session store backed by a local SQLite file
483
+ via \`@libsql/client\` (pure-JS, no native addon).
484
+ - **Hot-reload** \u2014 \`bun run --watch\` restarts on file changes.
485
+
486
+ ## Add power-ups
487
+
488
+ \`\`\`bash
489
+ bun add @eidentic/pgvector # PostgreSQL vector memory
490
+ bun add @eidentic/lancedb # embedded LanceDB vector memory
491
+ bun add @eidentic/transformers # local embeddings / reranking
492
+ bun add @eidentic/mcp # connect MCP servers
493
+ bun add @eidentic/e2b # sandboxed code execution
494
+ bun add @eidentic/eval # agent evaluation harness
495
+ \`\`\`
496
+ `;
497
+ }
498
+ function scaffold(targetDir, opts = {}) {
499
+ if (existsSync(targetDir) && readdirSync(targetDir).length > 0) {
500
+ throw new Error(`Target directory "${targetDir}" already exists and is not empty.`);
501
+ }
502
+ const projectName = opts.name ?? (basename(targetDir) || "my-eidentic-app");
503
+ const provider = opts.provider ?? "anthropic";
504
+ const providerMeta = PROVIDERS[provider];
505
+ const template = opts.template ?? "default";
506
+ if (template === "bun-agent") {
507
+ mkdirSync(join(targetDir, "src"), { recursive: true });
508
+ const files2 = {
509
+ "package.json": bunAgentPackageJson(projectName, providerMeta),
510
+ "tsconfig.json": bunAgentTsConfig(),
511
+ "bunfig.toml": bunfig(),
512
+ "src/server.ts": bunAgentServer(providerMeta),
513
+ ".env.example": bunAgentEnvExample(providerMeta),
514
+ ".gitignore": bunAgentGitignore(),
515
+ "README.md": bunAgentReadme(projectName)
516
+ };
517
+ const written2 = [];
518
+ for (const [rel, content] of Object.entries(files2)) {
519
+ writeFileSync(join(targetDir, rel), content);
520
+ written2.push(rel);
521
+ }
522
+ return written2;
523
+ }
524
+ if (template === "nextjs-chat") {
525
+ mkdirSync(join(targetDir, "app", "api", "chat"), { recursive: true });
526
+ const files2 = {
527
+ "package.json": nextjsPackageJson(projectName, providerMeta),
528
+ "tsconfig.json": nextjsTsConfig(),
529
+ "next.config.ts": nextjsConfig(),
530
+ "app/api/chat/route.ts": nextjsChatRoute(providerMeta),
531
+ "app/page.tsx": nextjsChatPage(),
532
+ ".env.local.example": nextjsEnvLocalExample(providerMeta),
533
+ ".gitignore": nextjsGitignore(),
534
+ "README.md": nextjsReadme(projectName)
535
+ };
536
+ const written2 = [];
537
+ for (const [rel, content] of Object.entries(files2)) {
538
+ writeFileSync(join(targetDir, rel), content);
539
+ written2.push(rel);
540
+ }
541
+ return written2;
542
+ }
543
+ mkdirSync(join(targetDir, "src"), { recursive: true });
544
+ const files = {
545
+ "package.json": packageJson(projectName, providerMeta),
546
+ "tsconfig.json": TSCONFIG,
547
+ "src/agent.ts": agentTs(providerMeta),
548
+ ".env.example": envExample(providerMeta),
549
+ ".gitignore": GITIGNORE,
550
+ "README.md": readme(projectName)
551
+ };
552
+ const written = [];
553
+ for (const [rel, content] of Object.entries(files)) {
554
+ writeFileSync(join(targetDir, rel), content);
555
+ written.push(rel);
556
+ }
557
+ return written;
558
+ }
559
+
560
+ // src/index.ts
561
+ var rawArgv = process.argv.slice(2);
562
+ var argv = rawArgv.filter((a) => !a.startsWith("-"));
563
+ var dirArg = argv[0];
564
+ function getFlagValue(flag) {
565
+ const eqForm = rawArgv.find((a) => a.startsWith(`--${flag}=`));
566
+ if (eqForm) return eqForm.slice(`--${flag}=`.length);
567
+ const idx = rawArgv.indexOf(`--${flag}`);
568
+ const next = idx !== -1 ? rawArgv[idx + 1] : void 0;
569
+ if (next !== void 0 && !next.startsWith("-")) {
570
+ return next;
571
+ }
572
+ return void 0;
573
+ }
574
+ var templateArg = getFlagValue("template");
575
+ var isInteractive = process.stdin.isTTY && !dirArg;
576
+ async function run() {
577
+ intro(pc.bold("create-eidentic"));
578
+ let projectDir;
579
+ if (dirArg) {
580
+ projectDir = dirArg;
581
+ } else if (isInteractive) {
582
+ const answer = await text({
583
+ message: "Project name",
584
+ placeholder: "my-eidentic-app",
585
+ defaultValue: "my-eidentic-app"
586
+ });
587
+ if (isCancel(answer)) {
588
+ cancel("Cancelled.");
589
+ process.exit(0);
590
+ }
591
+ projectDir = answer || "my-eidentic-app";
592
+ } else {
593
+ projectDir = "my-eidentic-app";
594
+ }
595
+ let template = templateArg ?? "default";
596
+ if (isInteractive && !templateArg) {
597
+ const templateAnswer = await select({
598
+ message: "Template",
599
+ options: [
600
+ { value: "default", label: "Default", hint: "bare Node script \u2014 fast, zero framework" },
601
+ { value: "nextjs-chat", label: "Next.js Chat", hint: "streaming chat UI \u2014 App Router + useChat" }
602
+ ]
603
+ });
604
+ if (isCancel(templateAnswer)) {
605
+ cancel("Cancelled.");
606
+ process.exit(0);
607
+ }
608
+ template = templateAnswer;
609
+ }
610
+ let provider = "anthropic";
611
+ if (isInteractive) {
612
+ const providerAnswer = await select({
613
+ message: "Model provider",
614
+ options: [
615
+ { value: "anthropic", label: "Anthropic", hint: "Claude \u2014 needs ANTHROPIC_API_KEY" },
616
+ { value: "openai", label: "OpenAI", hint: "GPT-4o \u2014 needs OPENAI_API_KEY" },
617
+ { value: "google", label: "Google", hint: "Gemini \u2014 needs GOOGLE_GENERATIVE_AI_API_KEY" },
618
+ { value: "deepseek", label: "DeepSeek", hint: "needs DEEPSEEK_API_KEY" },
619
+ { value: "mistral", label: "Mistral", hint: "needs MISTRAL_API_KEY" }
620
+ ]
621
+ });
622
+ if (isCancel(providerAnswer)) {
623
+ cancel("Cancelled.");
624
+ process.exit(0);
625
+ }
626
+ provider = providerAnswer;
627
+ }
628
+ if (isInteractive && template === "default") {
629
+ const addVector = await confirm({
630
+ message: "Add a vector memory adapter? (you can install one later)"
631
+ });
632
+ if (isCancel(addVector)) {
633
+ cancel("Cancelled.");
634
+ process.exit(0);
635
+ }
636
+ if (addVector) {
637
+ }
638
+ }
639
+ const target = resolve(process.cwd(), projectDir);
640
+ let files;
641
+ try {
642
+ files = scaffold(target, { provider, template });
643
+ } catch (err) {
644
+ cancel(`Error: ${err.message}`);
645
+ process.exit(1);
646
+ }
647
+ for (const f of files) {
648
+ process.stdout.write(` ${pc.green("+")} ${f}
649
+ `);
650
+ }
651
+ const envKey = {
652
+ anthropic: "ANTHROPIC_API_KEY",
653
+ openai: "OPENAI_API_KEY",
654
+ google: "GOOGLE_GENERATIVE_AI_API_KEY",
655
+ deepseek: "DEEPSEEK_API_KEY",
656
+ mistral: "MISTRAL_API_KEY"
657
+ }[provider];
658
+ const isNextjs = template === "nextjs-chat";
659
+ outro(
660
+ [
661
+ pc.bold("Next steps:"),
662
+ ` ${pc.cyan(`cd ${projectDir}`)}`,
663
+ ` ${pc.cyan("npm install")}`,
664
+ isNextjs ? ` ${pc.cyan("cp .env.local.example .env.local")} ${pc.dim(`# add your ${envKey}`)}` : ` ${pc.cyan("cp .env.example .env")} ${pc.dim(`# add your ${envKey}`)}`,
665
+ ` ${pc.cyan("npm run dev")}`
666
+ ].join("\n")
667
+ );
668
+ }
669
+ run().catch((err) => {
670
+ cancel(`Unexpected error: ${err.message}`);
671
+ process.exit(1);
672
+ });
package/package.json ADDED
@@ -0,0 +1,49 @@
1
+ {
2
+ "name": "create-eidentic",
3
+ "version": "0.1.0",
4
+ "type": "module",
5
+ "license": "Apache-2.0",
6
+ "description": "Scaffold a new Eidentic agent project — `npm create eidentic@latest` for default, Next.js chat, or Bun agent templates.",
7
+ "publishConfig": {
8
+ "access": "public"
9
+ },
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "git+https://github.com/eidentic/eidentic.git",
13
+ "directory": "packages/create-eidentic"
14
+ },
15
+ "bin": {
16
+ "create-eidentic": "./dist/index.js"
17
+ },
18
+ "files": [
19
+ "dist",
20
+ "LICENSE",
21
+ "README.md"
22
+ ],
23
+ "sideEffects": false,
24
+ "dependencies": {
25
+ "@clack/prompts": "^1.5.1",
26
+ "picocolors": "^1.1.1"
27
+ },
28
+ "keywords": [
29
+ "ai",
30
+ "agents",
31
+ "typescript",
32
+ "eidentic",
33
+ "scaffold",
34
+ "create",
35
+ "starter",
36
+ "template"
37
+ ],
38
+ "homepage": "https://github.com/eidentic/eidentic#readme",
39
+ "bugs": {
40
+ "url": "https://github.com/eidentic/eidentic/issues"
41
+ },
42
+ "engines": {
43
+ "node": ">=22"
44
+ },
45
+ "scripts": {
46
+ "build": "tsup src/index.ts --format esm --clean",
47
+ "typecheck": "tsc --noEmit"
48
+ }
49
+ }