@guuey/create-agentic-app 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.
- package/LICENSE +21 -0
- package/README.md +31 -0
- package/dist/chunk-JD4RAKEG.js +203 -0
- package/dist/chunk-U7JDNY6B.js +149 -0
- package/dist/cli.cjs +293 -0
- package/dist/cli.d.cts +1 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +128 -0
- package/dist/index.cjs +233 -0
- package/dist/index.d.cts +76 -0
- package/dist/index.d.ts +76 -0
- package/dist/index.js +10 -0
- package/dist/templates/claude-agent-sdk/.env.example +4 -0
- package/dist/templates/claude-agent-sdk/.mcp.json +1 -0
- package/dist/templates/claude-agent-sdk/README.md +107 -0
- package/dist/templates/claude-agent-sdk/ggui/blueprints/.gitkeep +0 -0
- package/dist/templates/claude-agent-sdk/ggui/ggui.json +15 -0
- package/dist/templates/claude-agent-sdk/ggui/themes/.gitkeep +0 -0
- package/dist/templates/claude-agent-sdk/guuey.json +13 -0
- package/dist/templates/claude-agent-sdk/mcps/todo/Dockerfile +46 -0
- package/dist/templates/claude-agent-sdk/mcps/todo/package.json +22 -0
- package/dist/templates/claude-agent-sdk/mcps/todo/src/server.ts +173 -0
- package/dist/templates/claude-agent-sdk/mcps/todo/tsconfig.json +15 -0
- package/dist/templates/claude-agent-sdk/package.json +22 -0
- package/dist/templates/claude-agent-sdk/pnpm-workspace.yaml +24 -0
- package/dist/templates/claude-agent-sdk/prompts/system.md +4 -0
- package/dist/templates/claude-agent-sdk/scripts/dev.mjs +44 -0
- package/dist/templates/claude-agent-sdk/src/agent-config.ts +70 -0
- package/dist/templates/claude-agent-sdk/src/worker.ts +89 -0
- package/dist/templates/claude-agent-sdk/tsconfig.json +15 -0
- package/dist/templates/claude-agent-sdk/tsup.config.ts +9 -0
- package/dist/templates/claude-agent-sdk/web/.env.example +17 -0
- package/dist/templates/claude-agent-sdk/web/index.html +13 -0
- package/dist/templates/claude-agent-sdk/web/package.json +25 -0
- package/dist/templates/claude-agent-sdk/web/sandbox-proxy.ts +239 -0
- package/dist/templates/claude-agent-sdk/web/src/App.tsx +272 -0
- package/dist/templates/claude-agent-sdk/web/src/main.tsx +12 -0
- package/dist/templates/claude-agent-sdk/web/src/useAgentChat.ts +122 -0
- package/dist/templates/claude-agent-sdk/web/src/vite-env.d.ts +27 -0
- package/dist/templates/claude-agent-sdk/web/tsconfig.json +20 -0
- package/dist/templates/claude-agent-sdk/web/vite.config.ts +12 -0
- package/dist/templates/mcp-base/Dockerfile +46 -0
- package/dist/templates/mcp-base/package.json +22 -0
- package/dist/templates/mcp-base/src/server.ts +113 -0
- package/dist/templates/mcp-base/tsconfig.json +15 -0
- package/dist/templates/openai-agents-sdk/.env.example +4 -0
- package/dist/templates/openai-agents-sdk/.mcp.json +1 -0
- package/dist/templates/openai-agents-sdk/README.md +107 -0
- package/dist/templates/openai-agents-sdk/ggui/blueprints/.gitkeep +0 -0
- package/dist/templates/openai-agents-sdk/ggui/ggui.json +15 -0
- package/dist/templates/openai-agents-sdk/ggui/themes/.gitkeep +0 -0
- package/dist/templates/openai-agents-sdk/guuey.json +13 -0
- package/dist/templates/openai-agents-sdk/mcps/todo/Dockerfile +46 -0
- package/dist/templates/openai-agents-sdk/mcps/todo/package.json +22 -0
- package/dist/templates/openai-agents-sdk/mcps/todo/src/server.ts +173 -0
- package/dist/templates/openai-agents-sdk/mcps/todo/tsconfig.json +15 -0
- package/dist/templates/openai-agents-sdk/package.json +22 -0
- package/dist/templates/openai-agents-sdk/pnpm-workspace.yaml +24 -0
- package/dist/templates/openai-agents-sdk/prompts/system.md +4 -0
- package/dist/templates/openai-agents-sdk/scripts/dev.mjs +44 -0
- package/dist/templates/openai-agents-sdk/src/agent-config.ts +70 -0
- package/dist/templates/openai-agents-sdk/src/worker.ts +75 -0
- package/dist/templates/openai-agents-sdk/tsconfig.json +15 -0
- package/dist/templates/openai-agents-sdk/tsup.config.ts +9 -0
- package/dist/templates/openai-agents-sdk/web/.env.example +17 -0
- package/dist/templates/openai-agents-sdk/web/index.html +13 -0
- package/dist/templates/openai-agents-sdk/web/package.json +25 -0
- package/dist/templates/openai-agents-sdk/web/sandbox-proxy.ts +239 -0
- package/dist/templates/openai-agents-sdk/web/src/App.tsx +272 -0
- package/dist/templates/openai-agents-sdk/web/src/main.tsx +12 -0
- package/dist/templates/openai-agents-sdk/web/src/useAgentChat.ts +122 -0
- package/dist/templates/openai-agents-sdk/web/src/vite-env.d.ts +27 -0
- package/dist/templates/openai-agents-sdk/web/tsconfig.json +20 -0
- package/dist/templates/openai-agents-sdk/web/vite.config.ts +12 -0
- package/package.json +45 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Loqu, Inc.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# @guuey/create-agentic-app
|
|
2
|
+
|
|
3
|
+
Scaffold a deployable AI agent for [guuey](https://guuey.com) — agent code,
|
|
4
|
+
MCP servers, and generative UI, in one workspace.
|
|
5
|
+
|
|
6
|
+
```
|
|
7
|
+
npx @guuey/create-agentic-app my-agent
|
|
8
|
+
cd my-agent
|
|
9
|
+
pnpm install
|
|
10
|
+
pnpm dev # local: your agent + your MCP servers, hot reload
|
|
11
|
+
guuey login
|
|
12
|
+
guuey deploy # hosted: agent + MCP servers live on guuey
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## What you get
|
|
16
|
+
|
|
17
|
+
- **A code-mode agent worker** (Claude Agent SDK or OpenAI Agents SDK — pick
|
|
18
|
+
with `--framework`) built on the open
|
|
19
|
+
[`@guuey/worker`](https://www.npmjs.com/package/@guuey/worker) protocol.
|
|
20
|
+
The same worker runs locally and on guuey's hosted runtime, sandboxed and
|
|
21
|
+
scaled to zero when idle.
|
|
22
|
+
- **A hosted MCP server template** (`mcps/todo`) — your agent's tools, built
|
|
23
|
+
and hosted by `guuey deploy` alongside the agent.
|
|
24
|
+
- **`guuey.json`** — the single config file describing the agent, its MCP
|
|
25
|
+
servers, and its ggui generative-UI assets.
|
|
26
|
+
|
|
27
|
+
## Options
|
|
28
|
+
|
|
29
|
+
```
|
|
30
|
+
npx @guuey/create-agentic-app <dir> [--framework claude-agent-sdk|openai-agents-sdk] [--skip-install]
|
|
31
|
+
```
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
// src/scaffold.ts
|
|
2
|
+
import { promises as fs2 } from "fs";
|
|
3
|
+
import { join, dirname, resolve } from "path";
|
|
4
|
+
import { fileURLToPath } from "url";
|
|
5
|
+
import { execFile } from "child_process";
|
|
6
|
+
import { promisify } from "util";
|
|
7
|
+
|
|
8
|
+
// src/rename.ts
|
|
9
|
+
function renameContent(content, name, scope) {
|
|
10
|
+
return content.replaceAll("@agentic-app-template/", `@${scope}/`).replaceAll("agentic-app-template", name);
|
|
11
|
+
}
|
|
12
|
+
function isProbablyText(buf) {
|
|
13
|
+
const window = buf.subarray(0, 8192);
|
|
14
|
+
return !window.includes(0);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// src/shared.ts
|
|
18
|
+
import { promises as fs } from "fs";
|
|
19
|
+
var NAME_PATTERN = /^[a-z0-9][a-z0-9._-]*$/;
|
|
20
|
+
function isNpmSafeName(name) {
|
|
21
|
+
return NAME_PATTERN.test(name);
|
|
22
|
+
}
|
|
23
|
+
function assertNpmSafeName(name, label) {
|
|
24
|
+
if (!isNpmSafeName(name)) {
|
|
25
|
+
throw new Error(
|
|
26
|
+
`Invalid ${label} name "${name}": must be npm-safe (match ${NAME_PATTERN.toString()}).`
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
function isErrnoException(err) {
|
|
31
|
+
return err instanceof Error && "code" in err;
|
|
32
|
+
}
|
|
33
|
+
async function pathExists(path) {
|
|
34
|
+
try {
|
|
35
|
+
await fs.access(path);
|
|
36
|
+
return true;
|
|
37
|
+
} catch (err) {
|
|
38
|
+
if (isErrnoException(err) && err.code === "ENOENT") return false;
|
|
39
|
+
throw err;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
async function ensureTargetDir(targetDir, force) {
|
|
43
|
+
if (!await pathExists(targetDir)) {
|
|
44
|
+
await fs.mkdir(targetDir, { recursive: true });
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
const entries = await fs.readdir(targetDir);
|
|
48
|
+
if (entries.length > 0 && !force) {
|
|
49
|
+
throw new Error(
|
|
50
|
+
`Target directory "${targetDir}" is not empty. Pass force: true (or --force) to scaffold into it anyway.`
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// src/scaffold.ts
|
|
56
|
+
var execFileAsync = promisify(execFile);
|
|
57
|
+
var here = dirname(fileURLToPath(import.meta.url));
|
|
58
|
+
var packageRoot = join(here, "..");
|
|
59
|
+
var defaultTemplatesDir = join(packageRoot, "dist", "templates");
|
|
60
|
+
async function listAvailableFrameworks(templatesDir) {
|
|
61
|
+
try {
|
|
62
|
+
const entries = await fs2.readdir(templatesDir, { withFileTypes: true });
|
|
63
|
+
return entries.filter((entry) => entry.isDirectory()).map((entry) => entry.name);
|
|
64
|
+
} catch (err) {
|
|
65
|
+
if (isErrnoException(err) && err.code === "ENOENT") return [];
|
|
66
|
+
throw err;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
async function resolveTemplateDir(templatesDir, framework) {
|
|
70
|
+
const dir = join(templatesDir, framework);
|
|
71
|
+
if (await pathExists(dir)) return dir;
|
|
72
|
+
const available = await listAvailableFrameworks(templatesDir);
|
|
73
|
+
const list = available.length > 0 ? available.join(", ") : `(none found under ${templatesDir})`;
|
|
74
|
+
throw new Error(`No template for framework "${framework}". Available frameworks: ${list}`);
|
|
75
|
+
}
|
|
76
|
+
async function copyTree(src, dest, name, scope) {
|
|
77
|
+
await fs2.mkdir(dest, { recursive: true });
|
|
78
|
+
const entries = await fs2.readdir(src, { withFileTypes: true });
|
|
79
|
+
for (const entry of entries) {
|
|
80
|
+
const destName = renameContent(entry.name, name, scope);
|
|
81
|
+
const srcPath = join(src, entry.name);
|
|
82
|
+
const destPath = join(dest, destName);
|
|
83
|
+
if (entry.isDirectory()) {
|
|
84
|
+
await copyTree(srcPath, destPath, name, scope);
|
|
85
|
+
} else {
|
|
86
|
+
const buf = await fs2.readFile(srcPath);
|
|
87
|
+
if (isProbablyText(buf)) {
|
|
88
|
+
await fs2.writeFile(destPath, renameContent(buf.toString("utf8"), name, scope), "utf8");
|
|
89
|
+
} else {
|
|
90
|
+
await fs2.writeFile(destPath, buf);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
async function seedEnvLocal(projectDir) {
|
|
96
|
+
const envExample = join(projectDir, ".env.example");
|
|
97
|
+
const envLocal = join(projectDir, ".env.local");
|
|
98
|
+
if (!await pathExists(envExample)) return;
|
|
99
|
+
if (await pathExists(envLocal)) return;
|
|
100
|
+
await fs2.copyFile(envExample, envLocal);
|
|
101
|
+
}
|
|
102
|
+
async function initGit(projectDir) {
|
|
103
|
+
try {
|
|
104
|
+
await execFileAsync("git", ["init"], { cwd: projectDir });
|
|
105
|
+
await execFileAsync("git", ["add", "-A"], { cwd: projectDir });
|
|
106
|
+
await execFileAsync(
|
|
107
|
+
"git",
|
|
108
|
+
[
|
|
109
|
+
"-c",
|
|
110
|
+
"user.name=guuey",
|
|
111
|
+
"-c",
|
|
112
|
+
"user.email=scaffold@guuey.com",
|
|
113
|
+
"commit",
|
|
114
|
+
"-m",
|
|
115
|
+
"chore: scaffold"
|
|
116
|
+
],
|
|
117
|
+
{ cwd: projectDir }
|
|
118
|
+
);
|
|
119
|
+
} catch {
|
|
120
|
+
console.error(
|
|
121
|
+
`Warning: git init failed; the project was scaffolded without a repo. Initialize it manually:
|
|
122
|
+
cd ${projectDir}
|
|
123
|
+
git init && git add -A && git commit -m "chore: scaffold"`
|
|
124
|
+
);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
async function runInstall(projectDir) {
|
|
128
|
+
try {
|
|
129
|
+
await execFileAsync("pnpm", ["install"], { cwd: projectDir });
|
|
130
|
+
} catch {
|
|
131
|
+
console.error(
|
|
132
|
+
`Warning: "pnpm install" failed to run automatically. Run it manually:
|
|
133
|
+
cd ${projectDir}
|
|
134
|
+
pnpm install`
|
|
135
|
+
);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
async function scaffold(opts) {
|
|
139
|
+
assertNpmSafeName(opts.name, "project");
|
|
140
|
+
const scope = opts.scope ?? opts.name;
|
|
141
|
+
const templatesDir = opts.templatesDir ?? defaultTemplatesDir;
|
|
142
|
+
const templateDir = await resolveTemplateDir(templatesDir, opts.framework);
|
|
143
|
+
const projectDir = resolve(opts.targetDir);
|
|
144
|
+
await ensureTargetDir(projectDir, opts.force);
|
|
145
|
+
await copyTree(templateDir, projectDir, opts.name, scope);
|
|
146
|
+
await seedEnvLocal(projectDir);
|
|
147
|
+
if (opts.git !== false) {
|
|
148
|
+
await initGit(projectDir);
|
|
149
|
+
}
|
|
150
|
+
if (opts.install) {
|
|
151
|
+
await runInstall(projectDir);
|
|
152
|
+
}
|
|
153
|
+
return { projectDir };
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
// src/scaffold-mcp.ts
|
|
157
|
+
import { promises as fs3 } from "fs";
|
|
158
|
+
import { join as join2, dirname as dirname2, resolve as resolve2 } from "path";
|
|
159
|
+
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
160
|
+
var here2 = dirname2(fileURLToPath2(import.meta.url));
|
|
161
|
+
var packageRoot2 = join2(here2, "..");
|
|
162
|
+
var defaultTemplatesDir2 = join2(packageRoot2, "dist", "templates");
|
|
163
|
+
function renameMcpTokens(content, name, scope) {
|
|
164
|
+
return renameContent(content.replaceAll("NAME_PLACEHOLDER", name), scope, scope);
|
|
165
|
+
}
|
|
166
|
+
async function copyMcpTree(src, dest, name, scope) {
|
|
167
|
+
await fs3.mkdir(dest, { recursive: true });
|
|
168
|
+
const entries = await fs3.readdir(src, { withFileTypes: true });
|
|
169
|
+
for (const entry of entries) {
|
|
170
|
+
const destName = renameMcpTokens(entry.name, name, scope);
|
|
171
|
+
const srcPath = join2(src, entry.name);
|
|
172
|
+
const destPath = join2(dest, destName);
|
|
173
|
+
if (entry.isDirectory()) {
|
|
174
|
+
await copyMcpTree(srcPath, destPath, name, scope);
|
|
175
|
+
} else {
|
|
176
|
+
const buf = await fs3.readFile(srcPath);
|
|
177
|
+
if (isProbablyText(buf)) {
|
|
178
|
+
await fs3.writeFile(destPath, renameMcpTokens(buf.toString("utf8"), name, scope), "utf8");
|
|
179
|
+
} else {
|
|
180
|
+
await fs3.writeFile(destPath, buf);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
async function scaffoldMcp(opts) {
|
|
186
|
+
assertNpmSafeName(opts.name, "MCP");
|
|
187
|
+
const scope = opts.scope ?? opts.name;
|
|
188
|
+
const templatesDir = opts.templatesDir ?? defaultTemplatesDir2;
|
|
189
|
+
const templateDir = join2(templatesDir, "mcp-base");
|
|
190
|
+
if (!await pathExists(templateDir)) {
|
|
191
|
+
throw new Error(`No mcp-base template found at ${templateDir}.`);
|
|
192
|
+
}
|
|
193
|
+
const mcpDir = resolve2(opts.targetDir);
|
|
194
|
+
await ensureTargetDir(mcpDir, void 0);
|
|
195
|
+
await copyMcpTree(templateDir, mcpDir, opts.name, scope);
|
|
196
|
+
return { mcpDir };
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
export {
|
|
200
|
+
isNpmSafeName,
|
|
201
|
+
scaffold,
|
|
202
|
+
scaffoldMcp
|
|
203
|
+
};
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
// src/scaffold.ts
|
|
2
|
+
import { promises as fs } from "fs";
|
|
3
|
+
import { join, dirname, resolve } from "path";
|
|
4
|
+
import { fileURLToPath } from "url";
|
|
5
|
+
import { execFile } from "child_process";
|
|
6
|
+
import { promisify } from "util";
|
|
7
|
+
|
|
8
|
+
// src/rename.ts
|
|
9
|
+
function renameContent(content, name, scope) {
|
|
10
|
+
return content.replaceAll("@agentic-app-template/", `@${scope}/`).replaceAll("agentic-app-template", name);
|
|
11
|
+
}
|
|
12
|
+
function isProbablyText(buf) {
|
|
13
|
+
const window = buf.subarray(0, 8192);
|
|
14
|
+
return !window.includes(0);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// src/scaffold.ts
|
|
18
|
+
var execFileAsync = promisify(execFile);
|
|
19
|
+
var NAME_PATTERN = /^[a-z0-9][a-z0-9._-]*$/;
|
|
20
|
+
var here = dirname(fileURLToPath(import.meta.url));
|
|
21
|
+
var packageRoot = join(here, "..");
|
|
22
|
+
var defaultTemplatesDir = join(packageRoot, "dist", "templates");
|
|
23
|
+
function isErrnoException(err) {
|
|
24
|
+
return err instanceof Error && "code" in err;
|
|
25
|
+
}
|
|
26
|
+
async function pathExists(path) {
|
|
27
|
+
try {
|
|
28
|
+
await fs.access(path);
|
|
29
|
+
return true;
|
|
30
|
+
} catch (err) {
|
|
31
|
+
if (isErrnoException(err) && err.code === "ENOENT") return false;
|
|
32
|
+
throw err;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
async function listAvailableFrameworks(templatesDir) {
|
|
36
|
+
try {
|
|
37
|
+
const entries = await fs.readdir(templatesDir, { withFileTypes: true });
|
|
38
|
+
return entries.filter((entry) => entry.isDirectory()).map((entry) => entry.name);
|
|
39
|
+
} catch (err) {
|
|
40
|
+
if (isErrnoException(err) && err.code === "ENOENT") return [];
|
|
41
|
+
throw err;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
async function resolveTemplateDir(templatesDir, framework) {
|
|
45
|
+
const dir = join(templatesDir, framework);
|
|
46
|
+
if (await pathExists(dir)) return dir;
|
|
47
|
+
const available = await listAvailableFrameworks(templatesDir);
|
|
48
|
+
const list = available.length > 0 ? available.join(", ") : `(none found under ${templatesDir})`;
|
|
49
|
+
throw new Error(`No template for framework "${framework}". Available frameworks: ${list}`);
|
|
50
|
+
}
|
|
51
|
+
async function ensureTargetDir(targetDir, force) {
|
|
52
|
+
if (!await pathExists(targetDir)) {
|
|
53
|
+
await fs.mkdir(targetDir, { recursive: true });
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
const entries = await fs.readdir(targetDir);
|
|
57
|
+
if (entries.length > 0 && !force) {
|
|
58
|
+
throw new Error(
|
|
59
|
+
`Target directory "${targetDir}" is not empty. Pass force: true (or --force) to scaffold into it anyway.`
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
async function copyTree(src, dest, name, scope) {
|
|
64
|
+
await fs.mkdir(dest, { recursive: true });
|
|
65
|
+
const entries = await fs.readdir(src, { withFileTypes: true });
|
|
66
|
+
for (const entry of entries) {
|
|
67
|
+
const destName = renameContent(entry.name, name, scope);
|
|
68
|
+
const srcPath = join(src, entry.name);
|
|
69
|
+
const destPath = join(dest, destName);
|
|
70
|
+
if (entry.isDirectory()) {
|
|
71
|
+
await copyTree(srcPath, destPath, name, scope);
|
|
72
|
+
} else {
|
|
73
|
+
const buf = await fs.readFile(srcPath);
|
|
74
|
+
if (isProbablyText(buf)) {
|
|
75
|
+
await fs.writeFile(destPath, renameContent(buf.toString("utf8"), name, scope), "utf8");
|
|
76
|
+
} else {
|
|
77
|
+
await fs.writeFile(destPath, buf);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
async function seedEnvLocal(projectDir) {
|
|
83
|
+
const envExample = join(projectDir, ".env.example");
|
|
84
|
+
const envLocal = join(projectDir, ".env.local");
|
|
85
|
+
if (!await pathExists(envExample)) return;
|
|
86
|
+
if (await pathExists(envLocal)) return;
|
|
87
|
+
await fs.copyFile(envExample, envLocal);
|
|
88
|
+
}
|
|
89
|
+
async function initGit(projectDir) {
|
|
90
|
+
try {
|
|
91
|
+
await execFileAsync("git", ["init"], { cwd: projectDir });
|
|
92
|
+
await execFileAsync("git", ["add", "-A"], { cwd: projectDir });
|
|
93
|
+
await execFileAsync(
|
|
94
|
+
"git",
|
|
95
|
+
[
|
|
96
|
+
"-c",
|
|
97
|
+
"user.name=guuey",
|
|
98
|
+
"-c",
|
|
99
|
+
"user.email=scaffold@guuey.com",
|
|
100
|
+
"commit",
|
|
101
|
+
"-m",
|
|
102
|
+
"chore: scaffold"
|
|
103
|
+
],
|
|
104
|
+
{ cwd: projectDir }
|
|
105
|
+
);
|
|
106
|
+
} catch {
|
|
107
|
+
console.error(
|
|
108
|
+
`Warning: git init failed; the project was scaffolded without a repo. Initialize it manually:
|
|
109
|
+
cd ${projectDir}
|
|
110
|
+
git init && git add -A && git commit -m "chore: scaffold"`
|
|
111
|
+
);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
async function runInstall(projectDir) {
|
|
115
|
+
try {
|
|
116
|
+
await execFileAsync("pnpm", ["install"], { cwd: projectDir });
|
|
117
|
+
} catch {
|
|
118
|
+
console.error(
|
|
119
|
+
`Warning: "pnpm install" failed to run automatically. Run it manually:
|
|
120
|
+
cd ${projectDir}
|
|
121
|
+
pnpm install`
|
|
122
|
+
);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
async function scaffold(opts) {
|
|
126
|
+
if (!NAME_PATTERN.test(opts.name)) {
|
|
127
|
+
throw new Error(
|
|
128
|
+
`Invalid project name "${opts.name}": must be npm-safe (match ${NAME_PATTERN.toString()}).`
|
|
129
|
+
);
|
|
130
|
+
}
|
|
131
|
+
const scope = opts.scope ?? opts.name;
|
|
132
|
+
const templatesDir = opts.templatesDir ?? defaultTemplatesDir;
|
|
133
|
+
const templateDir = await resolveTemplateDir(templatesDir, opts.framework);
|
|
134
|
+
const projectDir = resolve(opts.targetDir);
|
|
135
|
+
await ensureTargetDir(projectDir, opts.force);
|
|
136
|
+
await copyTree(templateDir, projectDir, opts.name, scope);
|
|
137
|
+
await seedEnvLocal(projectDir);
|
|
138
|
+
if (opts.git !== false) {
|
|
139
|
+
await initGit(projectDir);
|
|
140
|
+
}
|
|
141
|
+
if (opts.install) {
|
|
142
|
+
await runInstall(projectDir);
|
|
143
|
+
}
|
|
144
|
+
return { projectDir };
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
export {
|
|
148
|
+
scaffold
|
|
149
|
+
};
|
package/dist/cli.cjs
ADDED
|
@@ -0,0 +1,293 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
|
|
4
|
+
// src/cli.ts
|
|
5
|
+
var import_promises = require("readline/promises");
|
|
6
|
+
var import_node_process = require("process");
|
|
7
|
+
|
|
8
|
+
// src/scaffold.ts
|
|
9
|
+
var import_node_fs2 = require("fs");
|
|
10
|
+
var import_node_path = require("path");
|
|
11
|
+
var import_node_url = require("url");
|
|
12
|
+
var import_node_child_process = require("child_process");
|
|
13
|
+
var import_node_util = require("util");
|
|
14
|
+
|
|
15
|
+
// src/rename.ts
|
|
16
|
+
function renameContent(content, name, scope) {
|
|
17
|
+
return content.replaceAll("@agentic-app-template/", `@${scope}/`).replaceAll("agentic-app-template", name);
|
|
18
|
+
}
|
|
19
|
+
function isProbablyText(buf) {
|
|
20
|
+
const window = buf.subarray(0, 8192);
|
|
21
|
+
return !window.includes(0);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// src/shared.ts
|
|
25
|
+
var import_node_fs = require("fs");
|
|
26
|
+
var NAME_PATTERN = /^[a-z0-9][a-z0-9._-]*$/;
|
|
27
|
+
function isNpmSafeName(name) {
|
|
28
|
+
return NAME_PATTERN.test(name);
|
|
29
|
+
}
|
|
30
|
+
function assertNpmSafeName(name, label) {
|
|
31
|
+
if (!isNpmSafeName(name)) {
|
|
32
|
+
throw new Error(
|
|
33
|
+
`Invalid ${label} name "${name}": must be npm-safe (match ${NAME_PATTERN.toString()}).`
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
function isErrnoException(err) {
|
|
38
|
+
return err instanceof Error && "code" in err;
|
|
39
|
+
}
|
|
40
|
+
async function pathExists(path) {
|
|
41
|
+
try {
|
|
42
|
+
await import_node_fs.promises.access(path);
|
|
43
|
+
return true;
|
|
44
|
+
} catch (err) {
|
|
45
|
+
if (isErrnoException(err) && err.code === "ENOENT") return false;
|
|
46
|
+
throw err;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
async function ensureTargetDir(targetDir, force) {
|
|
50
|
+
if (!await pathExists(targetDir)) {
|
|
51
|
+
await import_node_fs.promises.mkdir(targetDir, { recursive: true });
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
const entries = await import_node_fs.promises.readdir(targetDir);
|
|
55
|
+
if (entries.length > 0 && !force) {
|
|
56
|
+
throw new Error(
|
|
57
|
+
`Target directory "${targetDir}" is not empty. Pass force: true (or --force) to scaffold into it anyway.`
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// src/scaffold.ts
|
|
63
|
+
var import_meta = {};
|
|
64
|
+
var execFileAsync = (0, import_node_util.promisify)(import_node_child_process.execFile);
|
|
65
|
+
var here = (0, import_node_path.dirname)((0, import_node_url.fileURLToPath)(import_meta.url));
|
|
66
|
+
var packageRoot = (0, import_node_path.join)(here, "..");
|
|
67
|
+
var defaultTemplatesDir = (0, import_node_path.join)(packageRoot, "dist", "templates");
|
|
68
|
+
async function listAvailableFrameworks(templatesDir) {
|
|
69
|
+
try {
|
|
70
|
+
const entries = await import_node_fs2.promises.readdir(templatesDir, { withFileTypes: true });
|
|
71
|
+
return entries.filter((entry) => entry.isDirectory()).map((entry) => entry.name);
|
|
72
|
+
} catch (err) {
|
|
73
|
+
if (isErrnoException(err) && err.code === "ENOENT") return [];
|
|
74
|
+
throw err;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
async function resolveTemplateDir(templatesDir, framework) {
|
|
78
|
+
const dir = (0, import_node_path.join)(templatesDir, framework);
|
|
79
|
+
if (await pathExists(dir)) return dir;
|
|
80
|
+
const available = await listAvailableFrameworks(templatesDir);
|
|
81
|
+
const list = available.length > 0 ? available.join(", ") : `(none found under ${templatesDir})`;
|
|
82
|
+
throw new Error(`No template for framework "${framework}". Available frameworks: ${list}`);
|
|
83
|
+
}
|
|
84
|
+
async function copyTree(src, dest, name, scope) {
|
|
85
|
+
await import_node_fs2.promises.mkdir(dest, { recursive: true });
|
|
86
|
+
const entries = await import_node_fs2.promises.readdir(src, { withFileTypes: true });
|
|
87
|
+
for (const entry of entries) {
|
|
88
|
+
const destName = renameContent(entry.name, name, scope);
|
|
89
|
+
const srcPath = (0, import_node_path.join)(src, entry.name);
|
|
90
|
+
const destPath = (0, import_node_path.join)(dest, destName);
|
|
91
|
+
if (entry.isDirectory()) {
|
|
92
|
+
await copyTree(srcPath, destPath, name, scope);
|
|
93
|
+
} else {
|
|
94
|
+
const buf = await import_node_fs2.promises.readFile(srcPath);
|
|
95
|
+
if (isProbablyText(buf)) {
|
|
96
|
+
await import_node_fs2.promises.writeFile(destPath, renameContent(buf.toString("utf8"), name, scope), "utf8");
|
|
97
|
+
} else {
|
|
98
|
+
await import_node_fs2.promises.writeFile(destPath, buf);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
async function seedEnvLocal(projectDir) {
|
|
104
|
+
const envExample = (0, import_node_path.join)(projectDir, ".env.example");
|
|
105
|
+
const envLocal = (0, import_node_path.join)(projectDir, ".env.local");
|
|
106
|
+
if (!await pathExists(envExample)) return;
|
|
107
|
+
if (await pathExists(envLocal)) return;
|
|
108
|
+
await import_node_fs2.promises.copyFile(envExample, envLocal);
|
|
109
|
+
}
|
|
110
|
+
async function initGit(projectDir) {
|
|
111
|
+
try {
|
|
112
|
+
await execFileAsync("git", ["init"], { cwd: projectDir });
|
|
113
|
+
await execFileAsync("git", ["add", "-A"], { cwd: projectDir });
|
|
114
|
+
await execFileAsync(
|
|
115
|
+
"git",
|
|
116
|
+
[
|
|
117
|
+
"-c",
|
|
118
|
+
"user.name=guuey",
|
|
119
|
+
"-c",
|
|
120
|
+
"user.email=scaffold@guuey.com",
|
|
121
|
+
"commit",
|
|
122
|
+
"-m",
|
|
123
|
+
"chore: scaffold"
|
|
124
|
+
],
|
|
125
|
+
{ cwd: projectDir }
|
|
126
|
+
);
|
|
127
|
+
} catch {
|
|
128
|
+
console.error(
|
|
129
|
+
`Warning: git init failed; the project was scaffolded without a repo. Initialize it manually:
|
|
130
|
+
cd ${projectDir}
|
|
131
|
+
git init && git add -A && git commit -m "chore: scaffold"`
|
|
132
|
+
);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
async function runInstall(projectDir) {
|
|
136
|
+
try {
|
|
137
|
+
await execFileAsync("pnpm", ["install"], { cwd: projectDir });
|
|
138
|
+
} catch {
|
|
139
|
+
console.error(
|
|
140
|
+
`Warning: "pnpm install" failed to run automatically. Run it manually:
|
|
141
|
+
cd ${projectDir}
|
|
142
|
+
pnpm install`
|
|
143
|
+
);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
async function scaffold(opts) {
|
|
147
|
+
assertNpmSafeName(opts.name, "project");
|
|
148
|
+
const scope = opts.scope ?? opts.name;
|
|
149
|
+
const templatesDir = opts.templatesDir ?? defaultTemplatesDir;
|
|
150
|
+
const templateDir = await resolveTemplateDir(templatesDir, opts.framework);
|
|
151
|
+
const projectDir = (0, import_node_path.resolve)(opts.targetDir);
|
|
152
|
+
await ensureTargetDir(projectDir, opts.force);
|
|
153
|
+
await copyTree(templateDir, projectDir, opts.name, scope);
|
|
154
|
+
await seedEnvLocal(projectDir);
|
|
155
|
+
if (opts.git !== false) {
|
|
156
|
+
await initGit(projectDir);
|
|
157
|
+
}
|
|
158
|
+
if (opts.install) {
|
|
159
|
+
await runInstall(projectDir);
|
|
160
|
+
}
|
|
161
|
+
return { projectDir };
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
// src/scaffold-mcp.ts
|
|
165
|
+
var import_node_fs3 = require("fs");
|
|
166
|
+
var import_node_path2 = require("path");
|
|
167
|
+
var import_node_url2 = require("url");
|
|
168
|
+
var import_meta2 = {};
|
|
169
|
+
var here2 = (0, import_node_path2.dirname)((0, import_node_url2.fileURLToPath)(import_meta2.url));
|
|
170
|
+
var packageRoot2 = (0, import_node_path2.join)(here2, "..");
|
|
171
|
+
var defaultTemplatesDir2 = (0, import_node_path2.join)(packageRoot2, "dist", "templates");
|
|
172
|
+
|
|
173
|
+
// src/cli.ts
|
|
174
|
+
var FRAMEWORKS = ["claude-agent-sdk", "openai-agents-sdk"];
|
|
175
|
+
function isFramework(value) {
|
|
176
|
+
return FRAMEWORKS.includes(value);
|
|
177
|
+
}
|
|
178
|
+
function parseArgs(argv) {
|
|
179
|
+
const positional = [];
|
|
180
|
+
const flags = {};
|
|
181
|
+
for (let i = 0; i < argv.length; i++) {
|
|
182
|
+
const arg = argv[i];
|
|
183
|
+
if (arg.startsWith("--")) {
|
|
184
|
+
const key = arg.slice(2);
|
|
185
|
+
const next = argv[i + 1];
|
|
186
|
+
if (next && !next.startsWith("--")) {
|
|
187
|
+
flags[key] = next;
|
|
188
|
+
i++;
|
|
189
|
+
} else {
|
|
190
|
+
flags[key] = true;
|
|
191
|
+
}
|
|
192
|
+
} else {
|
|
193
|
+
positional.push(arg);
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
return { positional, flags };
|
|
197
|
+
}
|
|
198
|
+
function printHelp() {
|
|
199
|
+
console.log(`create-agentic-app -- scaffold a guuey agentic app
|
|
200
|
+
|
|
201
|
+
Usage: create-agentic-app [target] [options]
|
|
202
|
+
|
|
203
|
+
Arguments:
|
|
204
|
+
target Directory to create the project in (prompted if omitted)
|
|
205
|
+
|
|
206
|
+
Options:
|
|
207
|
+
--name <name> Project name (default: derived from target)
|
|
208
|
+
--scope <scope> npm scope for @<scope>/* packages (default: name)
|
|
209
|
+
--framework <f> Framework: ${FRAMEWORKS.join(" | ")}
|
|
210
|
+
--agent <f> Alias for --framework
|
|
211
|
+
--install Run "pnpm install" after scaffolding
|
|
212
|
+
--no-git Skip "git init" + initial commit
|
|
213
|
+
--force Scaffold into a non-empty target directory
|
|
214
|
+
--list-agents List available frameworks and exit
|
|
215
|
+
--help Show this help
|
|
216
|
+
|
|
217
|
+
Examples:
|
|
218
|
+
create-agentic-app my-app --framework claude-agent-sdk
|
|
219
|
+
create-agentic-app my-app --agent openai-agents-sdk --install
|
|
220
|
+
`);
|
|
221
|
+
}
|
|
222
|
+
function deriveName(target) {
|
|
223
|
+
const base = target.split(/[\\/]/).filter(Boolean).pop() ?? target;
|
|
224
|
+
const slug = base.toLowerCase().replace(/[^a-z0-9._-]+/g, "-").replace(/^-+/, "");
|
|
225
|
+
return slug || "agentic-app";
|
|
226
|
+
}
|
|
227
|
+
async function promptFor(question) {
|
|
228
|
+
const rl = (0, import_promises.createInterface)({ input: import_node_process.stdin, output: import_node_process.stdout });
|
|
229
|
+
try {
|
|
230
|
+
return (await rl.question(question)).trim();
|
|
231
|
+
} finally {
|
|
232
|
+
rl.close();
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
async function main() {
|
|
236
|
+
const { positional, flags } = parseArgs(process.argv.slice(2));
|
|
237
|
+
if (flags.help) {
|
|
238
|
+
printHelp();
|
|
239
|
+
return;
|
|
240
|
+
}
|
|
241
|
+
if (flags["list-agents"]) {
|
|
242
|
+
console.log(FRAMEWORKS.join("\n"));
|
|
243
|
+
return;
|
|
244
|
+
}
|
|
245
|
+
let target = positional[0];
|
|
246
|
+
if (!target) {
|
|
247
|
+
target = await promptFor("Project directory: ");
|
|
248
|
+
}
|
|
249
|
+
if (!target) {
|
|
250
|
+
console.error("A target directory is required.");
|
|
251
|
+
process.exit(1);
|
|
252
|
+
return;
|
|
253
|
+
}
|
|
254
|
+
const frameworkFlag = flags.framework ?? flags.agent;
|
|
255
|
+
let frameworkInput = typeof frameworkFlag === "string" ? frameworkFlag : void 0;
|
|
256
|
+
if (!frameworkInput) {
|
|
257
|
+
frameworkInput = await promptFor(`Framework (${FRAMEWORKS.join(" | ")}): `);
|
|
258
|
+
}
|
|
259
|
+
if (!isFramework(frameworkInput)) {
|
|
260
|
+
console.error(`Unknown framework "${frameworkInput}". Available: ${FRAMEWORKS.join(", ")}`);
|
|
261
|
+
process.exit(1);
|
|
262
|
+
return;
|
|
263
|
+
}
|
|
264
|
+
const framework = frameworkInput;
|
|
265
|
+
const name = typeof flags.name === "string" ? flags.name : deriveName(target);
|
|
266
|
+
const scope = typeof flags.scope === "string" ? flags.scope : void 0;
|
|
267
|
+
const install = flags.install === true;
|
|
268
|
+
const { projectDir } = await scaffold({
|
|
269
|
+
targetDir: target,
|
|
270
|
+
name,
|
|
271
|
+
framework,
|
|
272
|
+
scope,
|
|
273
|
+
install,
|
|
274
|
+
git: flags["no-git"] !== true,
|
|
275
|
+
force: flags.force === true
|
|
276
|
+
});
|
|
277
|
+
console.log(`
|
|
278
|
+
Scaffolded "${name}" in ${projectDir}
|
|
279
|
+
`);
|
|
280
|
+
console.log("Next steps:");
|
|
281
|
+
console.log(` cd ${projectDir}`);
|
|
282
|
+
if (!install) console.log(" pnpm install");
|
|
283
|
+
console.log(" pnpm dev");
|
|
284
|
+
console.log(" guuey login && guuey deploy");
|
|
285
|
+
}
|
|
286
|
+
main().catch((err) => {
|
|
287
|
+
if (err instanceof Error) {
|
|
288
|
+
console.error(`\u2717 ${err.message}`);
|
|
289
|
+
} else {
|
|
290
|
+
console.error(`\u2717 ${err}`);
|
|
291
|
+
}
|
|
292
|
+
process.exit(1);
|
|
293
|
+
});
|
package/dist/cli.d.cts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
#!/usr/bin/env node
|