@guuey/create-agentic-app 0.1.0 → 0.1.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@guuey/create-agentic-app",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Scaffold a guuey agentic app: code-mode agent + custom MCP + ggui + web, local pnpm dev, one-command guuey deploy.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -22,7 +22,7 @@
22
22
  "tsup": "^8.5.0",
23
23
  "typescript": "^5.8.0",
24
24
  "vitest": "^3.2.4",
25
- "@guuey/config": "0.1.0"
25
+ "@guuey/config": "0.1.1"
26
26
  },
27
27
  "publishConfig": {
28
28
  "access": "public"
@@ -1,149 +0,0 @@
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
- };