create-gace-plugin 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.
@@ -0,0 +1 @@
1
+ #!/usr/bin/env node
package/dist/index.js ADDED
@@ -0,0 +1,70 @@
1
+ #!/usr/bin/env node
2
+
3
+ // src/index.ts
4
+ import { readdir, stat, copyFile, mkdir, readFile, writeFile } from "fs/promises";
5
+ import path from "path";
6
+ import { fileURLToPath } from "url";
7
+ var __dirname = path.dirname(fileURLToPath(import.meta.url));
8
+ var TEMPLATE_DIR = path.resolve(__dirname, "../template");
9
+ async function main() {
10
+ const projectName = process.argv[2];
11
+ if (!projectName) {
12
+ console.log(`
13
+ \x1B[1mcreate-gace-plugin\x1B[0m \u2014 Scaffold a new gace AI plugin
14
+
15
+ \x1B[1mUsage:\x1B[0m
16
+ pnpm create gace-plugin <project-name>
17
+ npx create-gace-plugin <project-name>
18
+
19
+ \x1B[1mExample:\x1B[0m
20
+ pnpm create gace-plugin my-plugin
21
+ cd my-plugin
22
+ pnpm install
23
+ pnpm dev
24
+ `);
25
+ process.exit(1);
26
+ }
27
+ const targetDir = path.resolve(process.cwd(), projectName);
28
+ try {
29
+ await stat(targetDir);
30
+ console.error(`\x1B[31mError: Directory "${projectName}" already exists.\x1B[0m`);
31
+ process.exit(1);
32
+ } catch {
33
+ }
34
+ console.log(`
35
+ Creating gace plugin in \x1B[36m${projectName}/\x1B[0m...
36
+ `);
37
+ await copyDir(TEMPLATE_DIR, targetDir);
38
+ const pkgPath = path.join(targetDir, "package.json");
39
+ const pkgContent = await readFile(pkgPath, "utf-8");
40
+ await writeFile(
41
+ pkgPath,
42
+ pkgContent.replace(/"name": "gace-plugin-template"/, `"name": "${projectName}"`),
43
+ "utf-8"
44
+ );
45
+ console.log(` \x1B[32m\u2713\x1B[0m Plugin scaffolded!`);
46
+ console.log("");
47
+ console.log(` Next steps:`);
48
+ console.log(` cd ${projectName}`);
49
+ console.log(` pnpm install`);
50
+ console.log(` pnpm dev`);
51
+ console.log("");
52
+ }
53
+ async function copyDir(src, dest) {
54
+ await mkdir(dest, { recursive: true });
55
+ const entries = await readdir(src);
56
+ for (const entry of entries) {
57
+ const srcPath = path.join(src, entry);
58
+ const destPath = path.join(dest, entry);
59
+ const s = await stat(srcPath);
60
+ if (s.isDirectory()) {
61
+ await copyDir(srcPath, destPath);
62
+ } else {
63
+ await copyFile(srcPath, destPath);
64
+ }
65
+ }
66
+ }
67
+ main().catch((err) => {
68
+ console.error("\x1B[31mError:\x1B[0m", err.message);
69
+ process.exit(1);
70
+ });
package/package.json ADDED
@@ -0,0 +1,23 @@
1
+ {
2
+ "name": "create-gace-plugin",
3
+ "version": "0.1.0",
4
+ "description": "Scaffold a new gace AI plugin",
5
+ "type": "module",
6
+ "bin": {
7
+ "create-gace-plugin": "./dist/index.js"
8
+ },
9
+ "files": [
10
+ "dist",
11
+ "template"
12
+ ],
13
+ "license": "MIT",
14
+ "devDependencies": {
15
+ "tsup": "^8.1.0",
16
+ "typescript": "^5.6.3",
17
+ "@types/node": "^20.16.10"
18
+ },
19
+ "scripts": {
20
+ "build": "tsup src/index.ts --format esm --target node18 --clean --dts",
21
+ "dev": "tsup src/index.ts --format esm --target node18 --watch"
22
+ }
23
+ }
@@ -0,0 +1,14 @@
1
+ {
2
+ "name": "gace-plugin-template",
3
+ "private": true,
4
+ "version": "0.0.1",
5
+ "type": "module",
6
+ "scripts": {
7
+ "dev": "gace dev",
8
+ "build": "gace build"
9
+ },
10
+ "dependencies": {
11
+ "gace-sdk": "^0.1.0",
12
+ "zod": "^3.23.0"
13
+ }
14
+ }
@@ -0,0 +1,12 @@
1
+ import { Tool } from "gace-sdk";
2
+ import type { GaceSDK } from "gace-sdk";
3
+ import { z } from "zod";
4
+
5
+ @Tool({
6
+ name: "hello",
7
+ description: "Say hello to someone",
8
+ args: z.object({ name: z.string().describe("Name of the person to greet") }),
9
+ })
10
+ export async function hello(sdk: GaceSDK) {
11
+ return `Hello, ${sdk.args.name}! 👋`;
12
+ }
@@ -0,0 +1,20 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2022",
4
+ "module": "ESNext",
5
+ "moduleResolution": "bundler",
6
+ "esModuleInterop": true,
7
+ "strict": true,
8
+ "skipLibCheck": true,
9
+ "experimentalDecorators": true,
10
+ "isolatedModules": true,
11
+ "resolveJsonModule": true
12
+ },
13
+ "include": [
14
+ "src"
15
+ ],
16
+ "exclude": [
17
+ "node_modules",
18
+ "dist"
19
+ ]
20
+ }